@stacksjs/stx 0.2.98 → 0.2.99
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 +135 -135
- package/dist/pwa.js +70 -70
- package/dist/ssg.js +67 -67
- package/dist/template-tag-balance.js +1 -1
- package/package.json +5 -5
package/dist/ssg.js
CHANGED
|
@@ -639,11 +639,11 @@ ${H}
|
|
|
639
639
|
`),J)Q=Q.replace(/\n/g,`<br />
|
|
640
640
|
`);for(let z=0;z<X.length;z++)Q=Q.replace(`\x00CODEBLOCK${z}\x00`,X[z]);return Q=Q.replace(/<p>\s*<\/p>/g,""),Q.trim()}function $1($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(J,Q)=>{return`const { ${Q.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
|
|
641
641
|
`});let Y=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return $=$.replace(Y,(J,Q)=>{return`const { ${Q.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__composables
|
|
642
|
-
`}),$}import YX from"process";function o0($="STX_PUBLIC_"){let Z={},Y={};for(let[J,Q]of Object.entries(YX.env)){if(!J.startsWith($)||Q===void 0)continue;Z[`import.meta.env.${J}`]=JSON.stringify(Q),Y[J]=Q}return Z["import.meta.env"]=JSON.stringify(Y),Z}var
|
|
642
|
+
`}),$}import YX from"process";function o0($="STX_PUBLIC_"){let Z={},Y={};for(let[J,Q]of Object.entries(YX.env)){if(!J.startsWith($)||Q===void 0)continue;Z[`import.meta.env.${J}`]=JSON.stringify(Q),Y[J]=Q}return Z["import.meta.env"]=JSON.stringify(Y),Z}var d1=()=>{};var c5={};r(c5,{hasUserImports:()=>JX,bundleClientScript:()=>QX});import O0 from"path";import h0 from"fs";function JX($){let Z=/^\s*import\s+(?!type\s)/gm;if(!$.match(Z))return!1;let J=/^\s*import\s+(?!type\s).*?\s+from\s+['"]([^'"]+)['"]/gm,Q;while((Q=J.exec($))!==null){let G=Q[1];if(!R6.some((q)=>q.test(G)))return console.log("[stx:bundler] detected user import:",G),!0}let X=/^\s*import\s+['"]([^'"]+)['"]/gm;while((Q=X.exec($))!==null){let G=Q[1];if(/\.css(?:\?.*)?$/.test(G))continue;if(!R6.some((q)=>q.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function XX($,Z,Y,J){let Q=(X,G)=>{let K=X===Y?Z:O0.dirname(X),q=O0.resolve(K,G),W=[q,`${q}.ts`,`${q}.tsx`,`${q}.js`,`${q}.mjs`,`${q}.jsx`,O0.join(q,"index.ts"),O0.join(q,"index.tsx"),O0.join(q,"index.js"),O0.join(q,"index.mjs")];for(let z of W)try{if(h0.existsSync(z)&&h0.statSync(z,{throwIfNoEntry:!1})?.isFile())return z}catch{}return q};return{name:"stx-client-bundle",setup(X){X.onResolve({filter:/^(stx|@stacksjs\/stx|@stacksjs\/browser)$/},(G)=>({path:G.path,external:!0})),X.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),X.onResolve({filter:/^\.\.?\//},(G)=>{let K=Q(G.importer,G.path);return J.add(K),{path:K}}),X.onResolve({filter:/^[@~]\//},(G)=>{let K=O0.resolve($,G.path.slice(2)),q=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,O0.join(K,"index.ts"),O0.join(K,"index.tsx"),O0.join(K,"index.js"),O0.join(K,"index.mjs")];for(let W of q)if(h0.existsSync(W)&&h0.statSync(W,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",W),J.add(W),{path:W};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}})}}}async function QX($,Z,Y={}){let J=Y.projectRoot||process.cwd(),Q=Y.minify??!1,X=Y.cacheDir||O0.join(J,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),q=O0.join(X,`${K}.js`),W=O0.join(X,`${K}.deps.json`),z=Bun.file(q);if(await z.exists()){let A=Bun.file(W),N=!0;if(await A.exists())try{let R=JSON.parse(await A.text());for(let T of R.files)try{if(h0.statSync(T.path).mtimeMs!==T.mtimeMs){N=!1;break}}catch{N=!1;break}}catch{N=!1}if(N)return console.log("[stx:bundler] cache hit:",K),await z.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let U=O0.join(J,".stx","bundle-tmp"),_=O0.join(U,`${K}.ts`),B=O0.join(U,"out",K);h0.mkdirSync(U,{recursive:!0}),h0.mkdirSync(B,{recursive:!0});let j=O0.dirname(Z),H=[],L=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,F=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,O;while((O=L.exec($))!==null){if(O[1])continue;if(O[2])O[2].split(",").forEach((A)=>{let N=A.split(":")[0].trim();if(N)H.push(N)});else if(O[3])H.push(O[3])}while((O=F.exec($))!==null){if(O[1])continue;H.push(O[2])}let V=H.length>0?`
|
|
643
643
|
export { ${H.join(", ")} }`:"";await Bun.write(_,$+V),console.log("[stx:bundler] bundling:",K,"from:",O0.basename(Z));let w=new Set;try{let A=await Bun.build({entrypoints:[_],outdir:B,target:"browser",format:"esm",minify:Q,plugins:[XX(J,j,_,w)],define:{"process.env.NODE_ENV":Q?'"production"':'"development"',...o0()},root:J});if(!A.success){let M=A.logs.filter((I)=>I.level==="error").map((I)=>I.message).join(", ");return console.warn("[stx:bundler] build failed:",M),$}let N="";for(let M of A.outputs){N=await M.text();break}let R=[];for(let M of N.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of M[1].split(",")){let D=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D&&D[1]!==D[2])R.push([D[2],D[1]])}if(N=N.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),R.length>0){let M=R.map(([I,D])=>`${JSON.stringify(I)}: ${D}`).join(", ");N+=`
|
|
644
644
|
var __stxScopeRenames = { ${M} };`}console.log("[stx:bundler] bundled:",K,"output:",N.length,"bytes"),h0.mkdirSync(X,{recursive:!0}),await Bun.write(q,N);let T=Array.from(w).map((M)=>{try{return{path:M,mtimeMs:h0.statSync(M).mtimeMs}}catch{return null}}).filter((M)=>M!==null);return await Bun.write(W,JSON.stringify({files:T})),N}catch(A){let N=A instanceof Error?A.message:String(A),R=A?.errors,T=Array.isArray(R)&&R.length>0?`
|
|
645
645
|
${R.map((M)=>`- ${M?.message??M}`).join(`
|
|
646
|
-
`)}`:"";return console.warn(`[stx:bundler] error: ${N}${T}`),$}finally{try{h0.rmSync(_,{force:!0}),h0.rmSync(B,{recursive:!0,force:!0})}catch{}}}var R6;var i5=S(()=>{
|
|
646
|
+
`)}`:"";return console.warn(`[stx:bundler] error: ${N}${T}`),$}finally{try{h0.rmSync(_,{force:!0}),h0.rmSync(B,{recursive:!0,force:!0})}catch{}}}var R6;var i5=S(()=>{d1();R6=[/^stx$/,/^@stacksjs\/stx$/,/^@stacksjs\/browser$/,/^@stores$/,/^stx\/stores$/,/^@composables$/]});var D6={};r(D6,{renderVendorStyleTags:()=>I6,processClientScript:()=>B5,generateServerDataBridge:()=>n5,extractBridgeData:()=>_5,extractAndStripCssImports:()=>M6});import V1 from"path";import U5 from"fs";function KX($){if($.startsWith(".")||$.startsWith("/"))return null;if($.startsWith("@")){let Y=$.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!Y)return null;return{pkg:Y[1],subpath:Y[2]||""}}let Z=$.match(/^([^/]+)(\/.*)?$/);if(!Z)return null;return{pkg:Z[1],subpath:Z[2]||""}}function qX($,Z){let Y=Z;while(!0){let J=V1.join(Y,"node_modules",$,"package.json");if(U5.existsSync(J))return V1.dirname(J);let Q=V1.dirname(Y);if(Q===Y)return null;Y=Q}}function zX($,Z){if(!$||typeof $!=="object")return null;let Y=(Q)=>{if(typeof Q==="string")return Q;if(Q&&typeof Q==="object"){if(typeof Q.import==="string")return Q.import;if(typeof Q.default==="string")return Q.default;if(typeof Q.import==="object")return Y(Q.import);if(typeof Q.default==="object")return Y(Q.default)}return null};if(Object.prototype.hasOwnProperty.call($,Z))return Y($[Z]);let J=null;for(let Q of Object.keys($)){let X=Q.indexOf("*");if(X===-1)continue;let G=Q.slice(0,X),K=Q.slice(X+1);if(!Z.startsWith(G)||!Z.endsWith(K))continue;if(Z.length<G.length+K.length)continue;if(!J||G.length>J.prefix.length)J={pattern:Q,prefix:G,suffix:K}}if(J){let Q=Z.slice(J.prefix.length,Z.length-J.suffix.length),X=Y($[J.pattern]);if(X)return X.replace("*",Q)}return null}function WX($,Z){let Y=KX($);if(!Y||!Y.subpath)return null;let J=qX(Y.pkg,Z);if(!J)return null;let Q;try{Q=JSON.parse(U5.readFileSync(V1.join(J,"package.json"),"utf8"))}catch{return null}let X=`.${Y.subpath}`,G=zX(Q.exports,X);if(!G)return null;let K=V1.resolve(J,G);return U5.existsSync(K)?K:null}function M6($,Z){let Y=Z.filePath?V1.dirname(Z.filePath):Z.projectRoot||process.cwd(),J=Z.projectRoot||process.cwd(),Q=new Set,X=[];return{code:$.replace(GX,(K,q)=>{let W;try{if(q.startsWith("./")||q.startsWith("../")||q.startsWith("/")){if(W=q.startsWith("/")?q:V1.resolve(Y,q),!U5.existsSync(W))throw Error(`file not found: ${W}`)}else{let z=null;try{z=Bun.resolveSync(q,J)}catch{z=WX(q,J)}if(!z)throw Error(`could not resolve ${q} (Bun.resolveSync + exports fallback both failed)`);W=z}}catch(z){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(q)} (from ${Z.filePath||"<unknown>"}): ${z?.message||z}`),""}if(Q.has(W))return"";Q.add(W);try{let z=U5.readFileSync(W,"utf8");X.push({source:q,resolvedPath:W,contents:z})}catch(z){console.warn(`[stx:vendor-css] could not read ${W}: ${z?.message||z}`)}return""}),styles:X}}function UX($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function I6($){if($.length===0)return"";return`${$.map((Z)=>{return`<style data-stx-vendor="${UX(Z.source)}" data-stx-layer="vendor">
|
|
647
647
|
@layer vendor {
|
|
648
648
|
${Z.contents}
|
|
649
649
|
}
|
|
@@ -695,7 +695,7 @@ else {
|
|
|
695
695
|
// STX: auto-generated event bindings
|
|
696
696
|
${$.map((Y,J)=>wX(Y,J)).join(`
|
|
697
697
|
`)}`}function T6($){let Z=[],Y=new Set,J=$.replace(/^\s*import\s+.*$/gm,""),Q=0,X=J.length,G=0;while(G<X){let K=J[G];if(K==="'"||K==='"'||K==="`"){let q=K;if(G++,q==="`"){let W=0;while(G<X){if(J[G]==="\\"){G+=2;continue}if(J[G]==="`"&&W===0){G++;break}if(J[G]==="$"&&J[G+1]==="{"){W++,G+=2;continue}if(J[G]==="}"&&W>0){W--,G++;continue}G++}}else while(G<X){if(J[G]==="\\"){G+=2;continue}if(J[G]===q){G++;break}G++}continue}if(K==="/"&&J[G+1]==="/"){while(G<X&&J[G]!==`
|
|
698
|
-
`)G++;continue}if(K==="/"&&J[G+1]==="*"){G+=2;while(G<X-1&&!(J[G]==="*"&&J[G+1]==="/"))G++;G+=2;continue}if(K==="{"){Q++,G++;continue}if(K==="}"){Q--,G++;continue}if(Q===0){let q=J.slice(G),W=q.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(W){let _=W[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=W[0].length;continue}let z=q.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(z){z[1].split(",").forEach((_)=>{let B=_.trim(),j=B.indexOf(":"),H=j>=0?B.slice(j+1).trim().split(/[\s=]/)[0]:B.split(/[\s=]/)[0];if(H&&!H.startsWith("_")&&!Y.has(H))Z.push(H),Y.add(H)}),G+=z[0].length;continue}let U=q.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(U){let _=U[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=U[0].length;continue}}G++}return Z}function RX($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function J(_){let B;while((B=Y.exec(_))!==null){let j=B[0];if(!NX.has(j))Z.add(j)}}let Q=/\{\{([\s\S]*?)\}\}/g,X;while((X=Q.exec($))!==null)J(X[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((X=G.exec($))!==null)J(X[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((X=K.exec($))!==null)J(X[1]);let q=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((X=q.exec($))!==null)J(X[1]);let W=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((X=W.exec($))!==null)J(X[1]);let z=/@model\s*=\s*["']([^"']*)["']/gi;while((X=z.exec($))!==null)J(X[1]);let U=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((X=U.exec($))!==null)J(X[1]);return Z}async function B5($,Z={}){let Y=$,J="",Q=!1,X=M6(Y,{filePath:Z.filePath,projectRoot:Z.projectRoot});Y=X.code;let G=I6(X.styles),{hasUserImports:K,bundleClientScript:q}=await Promise.resolve().then(() => (i5(),c5));if(K(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await q(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),Q=!0;if(Z.autoImports!==!1){let L=OX(Y);Y=L.code,J=LX(L.stxImports,L.browserImports)}if(J=`${n5(Y,Z.serverData)}${J}`,Y=$1(Y),!Q&&
|
|
698
|
+
`)G++;continue}if(K==="/"&&J[G+1]==="*"){G+=2;while(G<X-1&&!(J[G]==="*"&&J[G+1]==="/"))G++;G+=2;continue}if(K==="{"){Q++,G++;continue}if(K==="}"){Q--,G++;continue}if(Q===0){let q=J.slice(G),W=q.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(W){let _=W[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=W[0].length;continue}let z=q.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(z){z[1].split(",").forEach((_)=>{let B=_.trim(),j=B.indexOf(":"),H=j>=0?B.slice(j+1).trim().split(/[\s=]/)[0]:B.split(/[\s=]/)[0];if(H&&!H.startsWith("_")&&!Y.has(H))Z.push(H),Y.add(H)}),G+=z[0].length;continue}let U=q.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(U){let _=U[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=U[0].length;continue}}G++}return Z}function RX($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function J(_){let B;while((B=Y.exec(_))!==null){let j=B[0];if(!NX.has(j))Z.add(j)}}let Q=/\{\{([\s\S]*?)\}\}/g,X;while((X=Q.exec($))!==null)J(X[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((X=G.exec($))!==null)J(X[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((X=K.exec($))!==null)J(X[1]);let q=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((X=q.exec($))!==null)J(X[1]);let W=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((X=W.exec($))!==null)J(X[1]);let z=/@model\s*=\s*["']([^"']*)["']/gi;while((X=z.exec($))!==null)J(X[1]);let U=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((X=U.exec($))!==null)J(X[1]);return Z}async function B5($,Z={}){let Y=$,J="",Q=!1,X=M6(Y,{filePath:Z.filePath,projectRoot:Z.projectRoot});Y=X.code;let G=I6(X.styles),{hasUserImports:K,bundleClientScript:q}=await Promise.resolve().then(() => (i5(),c5));if(K(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await q(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),Q=!0;if(Z.autoImports!==!1){let L=OX(Y);Y=L.code,J=LX(L.stxImports,L.browserImports)}if(J=`${n5(Y,Z.serverData)}${J}`,Y=$1(Y),!Q&&w1(Z.attrs||""))Y=A1(Y);let W=AX(Z.eventBindings||[]),z=(Z.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(z)){let L=z.replace(/\btype\s*=\s*["']module["']/i,"").trim(),F=`type="module" data-stx-scoped${L?` ${L}`:""}`;return`${G}<script ${F}>
|
|
699
699
|
${J}${Y}
|
|
700
700
|
${W}
|
|
701
701
|
</script>`}let _=/\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|batch|untrack|peek)\s*(?:<[^>]*>)?\s*\(/.test($),B=/function __stx_setup_/.test(Y),j=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test($);function H(L){let F=L.length>0?`
|
|
@@ -720,7 +720,7 @@ catch (e) {
|
|
|
720
720
|
}
|
|
721
721
|
throw e;
|
|
722
722
|
}
|
|
723
|
-
`),K=G([]);if(X.length===Z.length)return E6(K,X,G);return E6((...W)=>{let z=Array(Q.length);for(let U=0;U<Q.length;U++)z[U]=W[Q[U]];return K(...z)},X,G,(W)=>{K=G(W)})}function E6($,Z,Y,J){let X=/^(\w+) is not defined$/,G=$,K=[],q=new Set(Z);return(...W)=>{for(let z=0;z<=8;z++)try{return G(...W)}catch(U){let _=U instanceof Error?U.message:"",B=X.exec(_);if(!(U instanceof ReferenceError)||!B)return;let j=B[1];if(q.has(j)||y6.has(j))return;q.add(j),K.push(j),G=Y(K),J?.(K)}return}}function s5($){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 TX,k6,b6,MX,S6,IX,y6;var R0=S(()=>{TX={maxSanitizeDepth:10,allowBracketNotation:!1},k6={...TX},b6=[/\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/],MX=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"]),S6=new Set(["__proto__","constructor","prototype"]),IX=/[\w)\]]\s*\[\s*['"]/;y6=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 r5($,Z){let Y=SX++,J=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return yX.set(J,{type:$,expression:Z}),J}var SX=0,yX;var C6=S(()=>{yX=new Map});function P6($,Z,Y,J){Y.lastIndex=Z;let Q=Y.exec($);if(!Q||Q.index!==Z)return-1;J.lastIndex=Y.lastIndex;let X=J.exec($);if(!X)return-1;return X.index+X[0].length}function a5($,Z){return P6($,Z,CX,PX)}function v6($,Z){return P6($,Z,vX,xX)}function x6($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function H5($,Z,Y){let J=[],Q="",X=0,G=$.length,K=!1,q=null;while(X<G){let W=$[X];if(K){if(Q+=W,q){if(W===q)q=null}else if(W==='"'||W==="'")q=W;else if(W===">")K=!1;X++;continue}if(W==="<"){let z=Z($,X);if(z>X){Q+=Y($.slice(X,z),J.length),J.push($.slice(X,z)),X=z;continue}if(/^<\/?[a-zA-Z]/.test($.slice(X,X+2)))K=!0;Q+=W,X++;continue}Q+=W,X++}return{output:Q,tokens:J}}function E$($){let{output:Z,tokens:Y}=H5($,a5,(J,Q)=>`\x00STX_SCRIPT_${Q}\x00`);return{output:Z,scripts:Y}}function k$($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,J)=>Z[+J]??"")}var CX,PX,vX,xX;var t5=S(()=>{CX=/<script\b[^>]*>/iy,PX=/<\/script\s*>/ig,vX=/<style\b[^>]*>/iy,xX=/<\/style\s*>/ig});var p6={};r(p6,{usesSignalsInScript:()=>u1,unescapeHtml:()=>b$,registerFilters:()=>gX,registerFilter:()=>h6,processExpressions:()=>s0,interpolateScriptsInTemplate:()=>dX,interpolateScriptExpressions:()=>m6,getAllFilters:()=>d6,evaluateExpression:()=>d0,escapeHtml:()=>u0,defaultFilters:()=>L5,clearCustomFilters:()=>hX,applyFilters:()=>u6});function fX($){let Z=f6.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),f6.set($,Z)}return Z.lastIndex=0,Z}function h6($,Z){if($ in L5)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);O5[$]=Z}function gX($){for(let[Z,Y]of Object.entries($))h6(Z,Y)}function d6(){return{...L5,...O5}}function hX(){for(let $ of Object.keys(O5))delete O5[$]}function u0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function u1($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let J=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(J))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 g6($,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,""),Q="",X=!1,G=0;for(let W=0;W<J.length;W++){let z=J[W];if(!X&&z==="`"){X=!0,G=0;continue}if(X){if(z==="`"&&G===0){X=!1;continue}if(z==="$"&&J[W+1]==="{"){G++,W++;continue}if(z==="}"&&G>0){G--;continue}continue}Q+=z}J=Q;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,q;while((q=K.exec(J))!==null){let W=q[1];if(!J.substring(0,q.index).trimEnd().endsWith(".")){if(!Y.includes(W)&&!(W in Z))return!1}}return!0}function m6($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(J,Q)=>{try{let X=d0(Q,Z);if(X===void 0)return J;return X===null?"":String(X)}catch{return J}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(J,Q)=>{let X=Q.trim();if(/^__[A-Z_]+__$/.test(X))return J;try{let G=d0(Q,Z);if(G===void 0)return J;return JSON.stringify(G)}catch{return J}}),Y}function dX($,Z,Y={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(J,Q,X)=>{if(/\bsrc\s*=/.test(Q))return J;if(/\bdata-raw\b/.test(Q))return J;if(/\btype\s*=\s*["']application\/json["']/.test(Q))return J;if(Y.skipServer&&/\bserver\b/.test(Q))return J;let G=m6(X,Z);return`<script${Q}>${G}</script>`})}function s0($,Z,Y,J){let Q=$,X=(z,U)=>{let _=v6(z,U);if(_===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(z.slice(U,_))?-1:_},G=(z,U,_,B)=>{let j=_.length,{output:H,tokens:L}=H5(z,U,(F,O)=>B(j+O));return _.push(...L),H},K=[];Q=G(Q,X,K,(z)=>`<!--__STX_STYLE_${z}__-->`);let q=[];Q=G(Q,a5,q,(z)=>`<!--__STX_SCRIPT_EXPR_${z}__-->`);let W=J?.forceSignals===!0||u1($);Q=Q.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(z,U,_)=>{try{let B=d0(U,Z);return B!==void 0&&B!==null?String(B):""}catch(B){let j=B instanceof Error?B.message:String(B);return K0("Expression",`Error evaluating: {{{ ${U.trim()}}}}: ${j}`,Y,$,_,z)}}),Q=Q.replace(/\{!!([\s\S]*?)!!\}/g,(z,U,_)=>{try{let B=d0(U,Z);if(B===void 0&&Z.__stx_buildMode==="compile")return r5("raw",U.trim());return B!==void 0&&B!==null?String(B):""}catch(B){if(Z.__stx_buildMode==="compile")return r5("raw",U.trim());let j=B instanceof Error?B.message:String(B);return K0("Expression",`Error evaluating: {!! ${U.trim()} !!}: ${j}`,Y,$,_,z)}}),Q=G(Q,a5,q,(z)=>`<!--__STX_SCRIPT_EXPR_${z}__-->`),Q=G(Q,X,K,(z)=>`<!--__STX_STYLE_${z}__-->`),Q=Q.replace(/\{\{([\s\S]*?)\}\}/g,(z,U,_)=>{let B=U.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=B.match(H)?.[1],O=F&&((F in Z)||j.includes(F)),V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,w=B.match(V),A=w&&!j.includes(w[1])&&!(w[1]in Z);if(/^__[A-Z_]+__$/.test(B))return"";try{let N=d0(U,Z);if(N===void 0&&W&&!g6(B,Z))return z;if(N===void 0&&Z.__stx_buildMode==="compile"&&!W)return r5("expr",B);return N!==void 0&&N!==null?u0(String(N)):""}catch(N){if(W&&!g6(B,Z))return z;if(A)return z;let R=N instanceof Error?N.message:String(N);return K0("Expression",`Error evaluating: {{ ${B} }}: ${R}`,Y,$,_,z)}});for(let z=0;z<q.length;z++)Q=Q.replace(`<!--__STX_SCRIPT_EXPR_${z}__-->`,()=>q[z]);for(let z=0;z<K.length;z++)Q=Q.replace(`<!--__STX_STYLE_${z}__-->`,()=>K[z]);return Q}function u6($,Z,Y){if(!Z.trim())return $;let J=$,Q=Z.trim();while(Q.length>0){let X=Q.match(/^(\w+)/);if(!X)break;let G=X[1];Q=Q.substring(G.length).trim();let K=O5[G]||L5[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(d6()).join(", ")}`);let q=[];if(Q.startsWith(":")){let W=Q.match(/^:([^|\s]+)/);if(W){let z=W[1].trim();try{let U=Number(z);q=[Number.isNaN(U)?z:U]}catch{q=[z]}Q=Q.substring(W[0].length).trim()}}else if(Q.startsWith("(")){let W=1,z=1;while(W>0&&z<Q.length){if(Q[z]==="(")W++;if(Q[z]===")")W--;z++}if(W===0){let U=Q.substring(1,z-1).trim();if(U)try{if(U.startsWith("{")&&U.endsWith("}"))q=[d0(`(${U})`,Y,!0)];else{let _=[],B="",j=null,H=0,L=0,F=0,O=!1;for(let V=0;V<U.length;V++){let w=U[V];if(O){B+=w,O=!1;continue}if(w==="\\"){B+=w,O=!0;continue}if(j){if(B+=w,w===j)j=null;continue}if(w==='"'||w==="'"||w==="`"){j=w,B+=w;continue}if(w==="(")H++;else if(w===")")H--;else if(w==="[")L++;else if(w==="]")L--;else if(w==="{")F++;else if(w==="}")F--;if(w===","&&H===0&&L===0&&F===0){_.push(B),B="";continue}B+=w}if(B)_.push(B);q=_.map((V)=>{let w=V.trim();return d0(w,Y,!0)})}}catch{q=[U]}Q=Q.substring(z).trim()}}try{J=K(J,Y,...q)}catch(W){let z=W instanceof Error?W.message:String(W);throw Error(`Error applying filter '${G}': ${z}`)}if(Q.startsWith("|"))Q=Q.substring(1).trim();else break}return J}function mX($){let Z=!1,Y="",J=0,Q=0,X=0,G=!1;for(let K=0;K<$.length;K++){let q=$[K],W=$[K+1];if(Z&&G){G=!1;continue}if(Z&&q==="\\"){G=!0;continue}if(G=!1,(q==='"'||q==="'"||q==="`")&&!G){if(!Z)Z=!0,Y=q;else if(q===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&q==="$"&&W==="{"){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(q==="(")J++;else if(q===")")J--;else if(q==="[")Q++;else if(q==="]")Q--;else if(q==="{")X++;else if(q==="}")X--;if(q==="|"&&J===0&&Q===0&&X===0){if(W==="|"){K++;continue}if(W==="="){K++;continue}return K}}return-1}function d0($,Z,Y=!1){try{let J=$.trim(),Q=mX(J);if(Q>0){let X=J.substring(0,Q).trim(),G=J.substring(Q+1).trim(),K=d0(X,Z,!0);return u6(K,G,Z)}if(!Q0(J)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${J}`);return Y0(J,Z)}try{let X=Object.keys(Z),G=Object.values(Z);return G0(J,X)(...G)}catch{return Y0(J,Z)}}catch(J){if(J instanceof ReferenceError){let Q=/(\b\w+)\s+is not defined/.exec(J.message);if(Q){let X=Q[1],G=uX(X,Object.keys(Z));if(G&&G!==X)J.message=`${J.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,J);throw J}}function uX($,Z){let Y=null;for(let Q of Z){if(Q===$)continue;let X=pX($,Q);if(Y===null||X<Y.dist)Y={key:Q,dist:X}}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 pX($,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,$],Q=Array(Y.length+1),X=Array(Y.length+1);for(let G=0;G<=Y.length;G++)Q[G]=G;for(let G=1;G<=J.length;G++){X[0]=G;for(let K=1;K<=Y.length;K++){let q=Y[K-1]===J[G-1]?0:1;X[K]=Math.min(X[K-1]+1,Q[K]+1,Q[K-1]+q)}for(let K=0;K<=Y.length;K++)Q[K]=X[K]}return Q[Y.length]}function b$($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var O5,f6,L5;var r0=S(()=>{R0();A0();C6();t5();O5={},f6=new Map;L5={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 u0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let J=Z.__translations,Q=Z.__i18nConfig?.fallbackToKey??!0,X=String($).split("."),G=J;for(let q of X){if(G===void 0||G===null)break;G=G[q]}if(G===void 0||G===null)return Q?$:"";let K=String(G);return Object.entries(Y).forEach(([q,W])=>{K=K.replace(fX(q),String(W))}),K},t:($,Z,Y={})=>{return L5.translate($,Z,Y)},truncate:($,Z,Y=50,J="...")=>{if($===void 0||$===null)return"";let Q=String($);if(Q.length<=Y)return Q;if(Y<=J.length)return J.substring(0,Y);return Q.substring(0,Y-J.length)+J},date:($,Z,Y="short",J="en-US")=>{if($===void 0||$===null)return"";try{let Q=$ instanceof Date?$:new Date($);if(Number.isNaN(Q.getTime()))return String($);let X={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 Q.toISOString();return new Intl.DateTimeFormat(J,X[Y]||X.short).format(Q)}catch{return String($)}},currency:($,Z,Y="USD",J="en-US")=>{if($===void 0||$===null)return"";try{let Q=Number($);if(Number.isNaN(Q))return String($);return new Intl.NumberFormat(J,{style:"currency",currency:Y}).format(Q)}catch{return String($)}},pluralize:($,Z,Y,J)=>{let Q=Number($);if(Number.isNaN(Q))return Y;let X=J||`${Y}s`;return Q===1?Y:X},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 Q=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(Q,"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 Q=10**Y;return Math.round(J*Q)/Q}}});class F5{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 l1($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!p1.has(Y)){if(p1.size>=lX){let J=p1.keys().next().value;if(J)p1.delete(J)}p1.set(Y,new RegExp($,Z))}return p1.get(Y)}class l6{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 Q=this.fnCache,X=this.fnCacheMaxSize,G=(...K)=>{return(q)=>{try{let W=`${Y}:${q}`,z=Q.get(W);if(!z){if(Q.size>=X){let U=Q.keys().next().value;if(U)Q.delete(U)}z=Function(...Z,`
|
|
723
|
+
`),K=G([]);if(X.length===Z.length)return E6(K,X,G);return E6((...W)=>{let z=Array(Q.length);for(let U=0;U<Q.length;U++)z[U]=W[Q[U]];return K(...z)},X,G,(W)=>{K=G(W)})}function E6($,Z,Y,J){let X=/^(\w+) is not defined$/,G=$,K=[],q=new Set(Z);return(...W)=>{for(let z=0;z<=8;z++)try{return G(...W)}catch(U){let _=U instanceof Error?U.message:"",B=X.exec(_);if(!(U instanceof ReferenceError)||!B)return;let j=B[1];if(q.has(j)||y6.has(j))return;q.add(j),K.push(j),G=Y(K),J?.(K)}return}}function s5($){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 TX,k6,b6,MX,S6,IX,y6;var R0=S(()=>{TX={maxSanitizeDepth:10,allowBracketNotation:!1},k6={...TX},b6=[/\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/],MX=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"]),S6=new Set(["__proto__","constructor","prototype"]),IX=/[\w)\]]\s*\[\s*['"]/;y6=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 r5($,Z){let Y=SX++,J=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return yX.set(J,{type:$,expression:Z}),J}var SX=0,yX;var C6=S(()=>{yX=new Map});function P6($,Z,Y,J){Y.lastIndex=Z;let Q=Y.exec($);if(!Q||Q.index!==Z)return-1;J.lastIndex=Y.lastIndex;let X=J.exec($);if(!X)return-1;return X.index+X[0].length}function a5($,Z){return P6($,Z,CX,PX)}function v6($,Z){return P6($,Z,vX,xX)}function x6($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function H5($,Z,Y){let J=[],Q="",X=0,G=$.length,K=!1,q=null;while(X<G){let W=$[X];if(K){if(Q+=W,q){if(W===q)q=null}else if(W==='"'||W==="'")q=W;else if(W===">")K=!1;X++;continue}if(W==="<"){let z=Z($,X);if(z>X){Q+=Y($.slice(X,z),J.length),J.push($.slice(X,z)),X=z;continue}if(/^<\/?[a-zA-Z]/.test($.slice(X,X+2)))K=!0;Q+=W,X++;continue}Q+=W,X++}return{output:Q,tokens:J}}function E$($){let{output:Z,tokens:Y}=H5($,a5,(J,Q)=>`\x00STX_SCRIPT_${Q}\x00`);return{output:Z,scripts:Y}}function k$($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,J)=>Z[+J]??"")}var CX,PX,vX,xX;var t5=S(()=>{CX=/<script\b[^>]*>/iy,PX=/<\/script\s*>/ig,vX=/<style\b[^>]*>/iy,xX=/<\/style\s*>/ig});var p6={};r(p6,{usesSignalsInScript:()=>m1,unescapeHtml:()=>b$,registerFilters:()=>gX,registerFilter:()=>h6,processExpressions:()=>s0,interpolateScriptsInTemplate:()=>dX,interpolateScriptExpressions:()=>m6,getAllFilters:()=>d6,evaluateExpression:()=>d0,escapeHtml:()=>u0,defaultFilters:()=>L5,clearCustomFilters:()=>hX,applyFilters:()=>u6});function fX($){let Z=f6.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),f6.set($,Z)}return Z.lastIndex=0,Z}function h6($,Z){if($ in L5)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);O5[$]=Z}function gX($){for(let[Z,Y]of Object.entries($))h6(Z,Y)}function d6(){return{...L5,...O5}}function hX(){for(let $ of Object.keys(O5))delete O5[$]}function u0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function m1($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let J=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(J))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 g6($,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,""),Q="",X=!1,G=0;for(let W=0;W<J.length;W++){let z=J[W];if(!X&&z==="`"){X=!0,G=0;continue}if(X){if(z==="`"&&G===0){X=!1;continue}if(z==="$"&&J[W+1]==="{"){G++,W++;continue}if(z==="}"&&G>0){G--;continue}continue}Q+=z}J=Q;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,q;while((q=K.exec(J))!==null){let W=q[1];if(!J.substring(0,q.index).trimEnd().endsWith(".")){if(!Y.includes(W)&&!(W in Z))return!1}}return!0}function m6($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(J,Q)=>{try{let X=d0(Q,Z);if(X===void 0)return J;return X===null?"":String(X)}catch{return J}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(J,Q)=>{let X=Q.trim();if(/^__[A-Z_]+__$/.test(X))return J;try{let G=d0(Q,Z);if(G===void 0)return J;return JSON.stringify(G)}catch{return J}}),Y}function dX($,Z,Y={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(J,Q,X)=>{if(/\bsrc\s*=/.test(Q))return J;if(/\bdata-raw\b/.test(Q))return J;if(/\btype\s*=\s*["']application\/json["']/.test(Q))return J;if(Y.skipServer&&/\bserver\b/.test(Q))return J;let G=m6(X,Z);return`<script${Q}>${G}</script>`})}function s0($,Z,Y,J){let Q=$,X=(z,U)=>{let _=v6(z,U);if(_===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(z.slice(U,_))?-1:_},G=(z,U,_,B)=>{let j=_.length,{output:H,tokens:L}=H5(z,U,(F,O)=>B(j+O));return _.push(...L),H},K=[];Q=G(Q,X,K,(z)=>`<!--__STX_STYLE_${z}__-->`);let q=[];Q=G(Q,a5,q,(z)=>`<!--__STX_SCRIPT_EXPR_${z}__-->`);let W=J?.forceSignals===!0||m1($);Q=Q.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(z,U,_)=>{try{let B=d0(U,Z);return B!==void 0&&B!==null?String(B):""}catch(B){let j=B instanceof Error?B.message:String(B);return K0("Expression",`Error evaluating: {{{ ${U.trim()}}}}: ${j}`,Y,$,_,z)}}),Q=Q.replace(/\{!!([\s\S]*?)!!\}/g,(z,U,_)=>{try{let B=d0(U,Z);if(B===void 0&&Z.__stx_buildMode==="compile")return r5("raw",U.trim());return B!==void 0&&B!==null?String(B):""}catch(B){if(Z.__stx_buildMode==="compile")return r5("raw",U.trim());let j=B instanceof Error?B.message:String(B);return K0("Expression",`Error evaluating: {!! ${U.trim()} !!}: ${j}`,Y,$,_,z)}}),Q=G(Q,a5,q,(z)=>`<!--__STX_SCRIPT_EXPR_${z}__-->`),Q=G(Q,X,K,(z)=>`<!--__STX_STYLE_${z}__-->`),Q=Q.replace(/\{\{([\s\S]*?)\}\}/g,(z,U,_)=>{let B=U.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=B.match(H)?.[1],O=F&&((F in Z)||j.includes(F)),V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,w=B.match(V),A=w&&!j.includes(w[1])&&!(w[1]in Z);if(/^__[A-Z_]+__$/.test(B))return"";try{let N=d0(U,Z);if(N===void 0&&W&&!g6(B,Z))return z;if(N===void 0&&Z.__stx_buildMode==="compile"&&!W)return r5("expr",B);return N!==void 0&&N!==null?u0(String(N)):""}catch(N){if(W&&!g6(B,Z))return z;if(A)return z;let R=N instanceof Error?N.message:String(N);return K0("Expression",`Error evaluating: {{ ${B} }}: ${R}`,Y,$,_,z)}});for(let z=0;z<q.length;z++)Q=Q.replace(`<!--__STX_SCRIPT_EXPR_${z}__-->`,()=>q[z]);for(let z=0;z<K.length;z++)Q=Q.replace(`<!--__STX_STYLE_${z}__-->`,()=>K[z]);return Q}function u6($,Z,Y){if(!Z.trim())return $;let J=$,Q=Z.trim();while(Q.length>0){let X=Q.match(/^(\w+)/);if(!X)break;let G=X[1];Q=Q.substring(G.length).trim();let K=O5[G]||L5[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(d6()).join(", ")}`);let q=[];if(Q.startsWith(":")){let W=Q.match(/^:([^|\s]+)/);if(W){let z=W[1].trim();try{let U=Number(z);q=[Number.isNaN(U)?z:U]}catch{q=[z]}Q=Q.substring(W[0].length).trim()}}else if(Q.startsWith("(")){let W=1,z=1;while(W>0&&z<Q.length){if(Q[z]==="(")W++;if(Q[z]===")")W--;z++}if(W===0){let U=Q.substring(1,z-1).trim();if(U)try{if(U.startsWith("{")&&U.endsWith("}"))q=[d0(`(${U})`,Y,!0)];else{let _=[],B="",j=null,H=0,L=0,F=0,O=!1;for(let V=0;V<U.length;V++){let w=U[V];if(O){B+=w,O=!1;continue}if(w==="\\"){B+=w,O=!0;continue}if(j){if(B+=w,w===j)j=null;continue}if(w==='"'||w==="'"||w==="`"){j=w,B+=w;continue}if(w==="(")H++;else if(w===")")H--;else if(w==="[")L++;else if(w==="]")L--;else if(w==="{")F++;else if(w==="}")F--;if(w===","&&H===0&&L===0&&F===0){_.push(B),B="";continue}B+=w}if(B)_.push(B);q=_.map((V)=>{let w=V.trim();return d0(w,Y,!0)})}}catch{q=[U]}Q=Q.substring(z).trim()}}try{J=K(J,Y,...q)}catch(W){let z=W instanceof Error?W.message:String(W);throw Error(`Error applying filter '${G}': ${z}`)}if(Q.startsWith("|"))Q=Q.substring(1).trim();else break}return J}function mX($){let Z=!1,Y="",J=0,Q=0,X=0,G=!1;for(let K=0;K<$.length;K++){let q=$[K],W=$[K+1];if(Z&&G){G=!1;continue}if(Z&&q==="\\"){G=!0;continue}if(G=!1,(q==='"'||q==="'"||q==="`")&&!G){if(!Z)Z=!0,Y=q;else if(q===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&q==="$"&&W==="{"){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(q==="(")J++;else if(q===")")J--;else if(q==="[")Q++;else if(q==="]")Q--;else if(q==="{")X++;else if(q==="}")X--;if(q==="|"&&J===0&&Q===0&&X===0){if(W==="|"){K++;continue}if(W==="="){K++;continue}return K}}return-1}function d0($,Z,Y=!1){try{let J=$.trim(),Q=mX(J);if(Q>0){let X=J.substring(0,Q).trim(),G=J.substring(Q+1).trim(),K=d0(X,Z,!0);return u6(K,G,Z)}if(!Q0(J)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${J}`);return Y0(J,Z)}try{let X=Object.keys(Z),G=Object.values(Z);return G0(J,X)(...G)}catch{return Y0(J,Z)}}catch(J){if(J instanceof ReferenceError){let Q=/(\b\w+)\s+is not defined/.exec(J.message);if(Q){let X=Q[1],G=uX(X,Object.keys(Z));if(G&&G!==X)J.message=`${J.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,J);throw J}}function uX($,Z){let Y=null;for(let Q of Z){if(Q===$)continue;let X=pX($,Q);if(Y===null||X<Y.dist)Y={key:Q,dist:X}}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 pX($,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,$],Q=Array(Y.length+1),X=Array(Y.length+1);for(let G=0;G<=Y.length;G++)Q[G]=G;for(let G=1;G<=J.length;G++){X[0]=G;for(let K=1;K<=Y.length;K++){let q=Y[K-1]===J[G-1]?0:1;X[K]=Math.min(X[K-1]+1,Q[K]+1,Q[K-1]+q)}for(let K=0;K<=Y.length;K++)Q[K]=X[K]}return Q[Y.length]}function b$($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var O5,f6,L5;var r0=S(()=>{R0();A0();C6();t5();O5={},f6=new Map;L5={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 u0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let J=Z.__translations,Q=Z.__i18nConfig?.fallbackToKey??!0,X=String($).split("."),G=J;for(let q of X){if(G===void 0||G===null)break;G=G[q]}if(G===void 0||G===null)return Q?$:"";let K=String(G);return Object.entries(Y).forEach(([q,W])=>{K=K.replace(fX(q),String(W))}),K},t:($,Z,Y={})=>{return L5.translate($,Z,Y)},truncate:($,Z,Y=50,J="...")=>{if($===void 0||$===null)return"";let Q=String($);if(Q.length<=Y)return Q;if(Y<=J.length)return J.substring(0,Y);return Q.substring(0,Y-J.length)+J},date:($,Z,Y="short",J="en-US")=>{if($===void 0||$===null)return"";try{let Q=$ instanceof Date?$:new Date($);if(Number.isNaN(Q.getTime()))return String($);let X={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 Q.toISOString();return new Intl.DateTimeFormat(J,X[Y]||X.short).format(Q)}catch{return String($)}},currency:($,Z,Y="USD",J="en-US")=>{if($===void 0||$===null)return"";try{let Q=Number($);if(Number.isNaN(Q))return String($);return new Intl.NumberFormat(J,{style:"currency",currency:Y}).format(Q)}catch{return String($)}},pluralize:($,Z,Y,J)=>{let Q=Number($);if(Number.isNaN(Q))return Y;let X=J||`${Y}s`;return Q===1?Y:X},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 Q=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(Q,"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 Q=10**Y;return Math.round(J*Q)/Q}}});class F5{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 p1($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!u1.has(Y)){if(u1.size>=lX){let J=u1.keys().next().value;if(J)u1.delete(J)}u1.set(Y,new RegExp($,Z))}return u1.get(Y)}class l6{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 Q=this.fnCache,X=this.fnCacheMaxSize,G=(...K)=>{return(q)=>{try{let W=`${Y}:${q}`,z=Q.get(W);if(!z){if(Q.size>=X){let U=Q.keys().next().value;if(U)Q.delete(U)}z=Function(...Z,`
|
|
724
724
|
'use strict';
|
|
725
725
|
try {
|
|
726
726
|
return ${q};
|
|
@@ -731,38 +731,38 @@ catch (e) {
|
|
|
731
731
|
}
|
|
732
732
|
throw e;
|
|
733
733
|
}
|
|
734
|
-
`),Q.set(W,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 c6{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(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,Q=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,X=Z>=Y.maxTime;if(!Q&&!X)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:Q};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let q of this.violationHandlers)try{q(G)}catch{}let K=Q?`[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(X)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 Q=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:Q?.maxTime,budgetUtilization:Q?J.totalTime/J.count/Q.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 cX(){if(!S$)S$=new c6;return S$}var
|
|
734
|
+
`),Q.set(W,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 c6{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(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,Q=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,X=Z>=Y.maxTime;if(!Q&&!X)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:Q};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let q of this.violationHandlers)try{q(G)}catch{}let K=Q?`[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(X)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 Q=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:Q?.maxTime,budgetUtilization:Q?J.totalTime/J.count/Q.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 cX(){if(!S$)S$=new c6;return S$}var u1,lX=500,GB,S$=null,i6;var l1=S(()=>{u1=new Map;GB=new l6;i6=new Proxy({},{get($,Z){return cX()[Z]}})});function n6($,Z=""){let Y=`${$}${Z}`,J=0;for(let Q=0;Q<Y.length;Q++){let X=Y.charCodeAt(Q);J=(J<<5)-J+X,J=J&J}return`stx-${Math.abs(J).toString(36)}`}function o6($,Z,Y={}){let{prefix:J="",preserveHost:Q=!0,scopeKeyframes:X=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=y$($),q=[],W=new Map;if(X)for(let z of K){let U=z.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(U){let _=U[1],B=`${Z}_${_}`;W.set(_,B)}}for(let z of K){let U=s6(z,Z,J,Q,W,G);q.push(U)}return q.join(`
|
|
735
735
|
|
|
736
736
|
`)}function y$($){let Z=[],Y=$.replace(/\/\*[\s\S]*?\*\//g,""),J=0,Q="",X=!1,G="";for(let K=0;K<Y.length;K++){let q=Y[K];if(q==="@"&&J===0)X=!0;if(q==="{")J++;else if(q==="}"){if(J--,J===0){if(X){G+=q;let W=G.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(W){let[,z,U,_]=W;if(z==="keyframes")Z.push({selector:`@keyframes ${U.trim()}`,declarations:_.trim()});else if(z==="media"||z==="supports"||z==="container"){let B=y$(_);Z.push({selector:`@${z} ${U.trim()}`,declarations:B.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
|
|
737
737
|
`)})}else Z.push({selector:`@${z} ${U.trim()}`,declarations:_.trim()})}G="",X=!1}else if(Q.trim()){Q+=q;let W=Q.match(/([^{]+)\{([^}]*)\}/);if(W)Z.push({selector:W[1].trim(),declarations:W[2].trim()});Q=""}continue}}if(X)G+=q;else Q+=q}return Z}function s6($,Z,Y,J,Q,X){let{selector:G,declarations:K}=$;if(G.startsWith("@")){if(G.startsWith("@keyframes")){let z=G.replace("@keyframes ","").trim();return`@keyframes ${Q.get(z)||z} { ${K} }`}if(G.startsWith("@media")||G.startsWith("@supports")||G.startsWith("@container")){let U=y$(`x { ${K} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((_)=>s6(_,Z,Y,J,Q,X)).join(`
|
|
738
738
|
`);return`${G} {
|
|
739
739
|
${U}
|
|
740
|
-
}`}return`${G} { ${K} }`}let q=iX(G,Z,Y,J),W=K;for(let[z,U]of Q)W=W.replace(new RegExp(`\\b${z}\\b`,"g"),U);if(X)W=W.replace(/--([a-z-]+)/gi,`--${Z}-$1`);return`${q} { ${W} }`}function iX($,Z,Y,J){let Q=$.split(",").map((G)=>G.trim()),X=[];for(let G of Q){if(G.startsWith(":host")){if(J)X.push(G);else{let q=G.replace(/:host(\([^)]*\))?/,`.${Z}$1`);X.push(q)}continue}if(G.includes("::slotted")){X.push(G);continue}if(G===":root"){X.push(`:root .${Z}`);continue}let K=Y?`${Y} .${Z}`:`.${Z}`;X.push(`${K} ${G}`)}return X.join(", ")}function e5($,Z){if(!/<style\s+[^>]*\bscoped\b/i.test($))return{html:$,hasScoped:!1};let Y=n6(Z),J=`data-v-${Y}`,Q=$,X=/<style\s+([^>]*\bscoped\b[^>]*)>([\s\S]*?)<\/style>/gi,G=!1;if(Q=Q.replace(X,(K,q,W)=>{G=!0;let z=nX(W,J),U=q.replace(/\bscoped\b/gi,"").trim(),_=U?` ${U}`:"";return`<style data-stx-scoped="${Y}"${_}>${z}</style>`}),!G)return{html:$,hasScoped:!1};return Q=oX(Q,J),{html:Q,hasScoped:!0}}function nX($,Z){return o6($,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${Z}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${Z}]`)}function oX($,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,Q,X)=>{if(Y.has(Q.toLowerCase()))return J;if(J.includes(Z))return J;if(Q.toLowerCase()==="style"||Q.toLowerCase()==="script")return J;if(X)return J.replace(`<${Q}${X}`,`<${Q} ${Z}${X}`);if(J.endsWith("/>"))return`<${Q} ${Z} />`;return`<${Q} ${Z}>`})}var C$=()=>{};var r6=()=>{};function S0($,Z,Y,J=0){let Q=0,X=J,G=null,K=0,q=!1;while(X<$.length){let W=$[X];if(G&&q){q=!1,X++;continue}if(G&&W==="\\"){q=!0,X++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,X++;continue}if(W===G&&G!=="`"){G=null,X++;continue}if(G==="`"&&W==="$"&&$[X+1]==="{"){K++,X+=2;continue}if(K>0&&W==="}"){K--,X++;continue}if(W==="`"&&G==="`"&&K===0){G=null,X++;continue}if(G){X++;continue}if(W===Z)Q++;else if(W===Y){if(Q--,Q===0)return X}X++}return-1}var P$={};r(P$,{useTitle:()=>$Q,useSeoMeta:()=>Z4,usePageTitle:()=>$Q,useHead:()=>
|
|
741
|
-
`)}function YQ($=G1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${
|
|
742
|
-
`,""}),headContent:Z.trim()}}function GQ($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,J,Q,X)=>{let G=J?Q:Z[(X||"").trim()]??X;return
|
|
740
|
+
}`}return`${G} { ${K} }`}let q=iX(G,Z,Y,J),W=K;for(let[z,U]of Q)W=W.replace(new RegExp(`\\b${z}\\b`,"g"),U);if(X)W=W.replace(/--([a-z-]+)/gi,`--${Z}-$1`);return`${q} { ${W} }`}function iX($,Z,Y,J){let Q=$.split(",").map((G)=>G.trim()),X=[];for(let G of Q){if(G.startsWith(":host")){if(J)X.push(G);else{let q=G.replace(/:host(\([^)]*\))?/,`.${Z}$1`);X.push(q)}continue}if(G.includes("::slotted")){X.push(G);continue}if(G===":root"){X.push(`:root .${Z}`);continue}let K=Y?`${Y} .${Z}`:`.${Z}`;X.push(`${K} ${G}`)}return X.join(", ")}function e5($,Z){if(!/<style\s+[^>]*\bscoped\b/i.test($))return{html:$,hasScoped:!1};let Y=n6(Z),J=`data-v-${Y}`,Q=$,X=/<style\s+([^>]*\bscoped\b[^>]*)>([\s\S]*?)<\/style>/gi,G=!1;if(Q=Q.replace(X,(K,q,W)=>{G=!0;let z=nX(W,J),U=q.replace(/\bscoped\b/gi,"").trim(),_=U?` ${U}`:"";return`<style data-stx-scoped="${Y}"${_}>${z}</style>`}),!G)return{html:$,hasScoped:!1};return Q=oX(Q,J),{html:Q,hasScoped:!0}}function nX($,Z){return o6($,"__SCOPE_PLACEHOLDER__",{preserveHost:!1}).replace(/\.(__SCOPE_PLACEHOLDER__) /g,`[${Z}] `).replace(/\.(__SCOPE_PLACEHOLDER__)/g,`[${Z}]`)}function oX($,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,Q,X)=>{if(Y.has(Q.toLowerCase()))return J;if(J.includes(Z))return J;if(Q.toLowerCase()==="style"||Q.toLowerCase()==="script")return J;if(X)return J.replace(`<${Q}${X}`,`<${Q} ${Z}${X}`);if(J.endsWith("/>"))return`<${Q} ${Z} />`;return`<${Q} ${Z}>`})}var C$=()=>{};var r6=()=>{};function S0($,Z,Y,J=0){let Q=0,X=J,G=null,K=0,q=!1;while(X<$.length){let W=$[X];if(G&&q){q=!1,X++;continue}if(G&&W==="\\"){q=!0,X++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,X++;continue}if(W===G&&G!=="`"){G=null,X++;continue}if(G==="`"&&W==="$"&&$[X+1]==="{"){K++,X+=2;continue}if(K>0&&W==="}"){K--,X++;continue}if(W==="`"&&G==="`"&&K===0){G=null,X++;continue}if(G){X++;continue}if(W===Z)Q++;else if(W===Y){if(Q--,Q===0)return X}X++}return-1}var P$={};r(P$,{useTitle:()=>$Q,useSeoMeta:()=>Z4,usePageTitle:()=>$Q,useHead:()=>R1,resetHead:()=>aX,renderHtmlAttrs:()=>YQ,renderHead:()=>ZQ,renderBodyAttrs:()=>JQ,processTitleDirective:()=>GQ,processMetaDirective:()=>KQ,processHeadDirective:()=>QQ,getPageMeta:()=>rX,getHead:()=>V5,definePageMeta:()=>eX,applyHead:()=>XQ});function V5(){return G1}function rX(){return $4}function aX(){G1={},sX.length=0,$4={}}function R1($){G1=tX(G1,$)}function tX($,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 Z4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}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 Q=$.twitterTitle??$.title,X=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(Q)Z.push({name:"twitter:title",content:Q});if(X)Z.push({name:"twitter:description",content:X});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 q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});R1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function eX($){if($4={...$4,...$},$.title||$.description)Z4({title:$.title,description:$.description})}function $Q($){let Z=typeof $==="function"?$():$;R1({title:Z})}function ZQ($=G1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${N1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([J,Q])=>`${J}="${N1(Q)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let J=Object.entries(Y).filter(([Q,X])=>X!==void 0).map(([Q,X])=>{return`${Q==="httpEquiv"?"http-equiv":Q}="${N1(String(X))}"`}).join(" ");Z.push(`<meta ${J}>`)}for(let Y of $.link||[]){let J=Object.entries(Y).filter(([Q,X])=>X!==void 0).map(([Q,X])=>`${Q}="${N1(String(X))}"`).join(" ");Z.push(`<link ${J}>`)}for(let Y of $.script||[]){let{content:J,...Q}=Y,X=Object.entries(Q).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${N1(String(K))}"`}).filter(Boolean).join(" ");if(J)Z.push(`<script ${X}>${J}</script>`);else Z.push(`<script ${X}></script>`)}for(let Y of $.style||[]){let J=Y.type?` type="${Y.type}"`:"";Z.push(`<style${J}>${Y.content}</style>`)}return Z.join(`
|
|
741
|
+
`)}function YQ($=G1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${N1(Y)}"`).join(" ")}function JQ($=G1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${N1(Y)}"`).join(" ")}function N1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function XQ($=G1){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[Q,X]of Object.entries(Z))if(X!==void 0)J.setAttribute(Q,String(X))}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 QQ($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(J,Q)=>{return Z+=Q.trim()+`
|
|
742
|
+
`,""}),headContent:Z.trim()}}function GQ($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,J,Q,X)=>{let G=J?Q:Z[(X||"").trim()]??X;return R1({title:G}),""})}function KQ($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,J,Q,X,G,K)=>{let q=X?G:K,W=X?q:Z[(q||"").trim()]??q,U=Q.includes(":")?{property:Q,content:W}:{name:Q,content:W};return R1({meta:[U]}),""})}var G1,sX,$4;var w5=S(()=>{G1={},sX=[],$4={}});var Y4={};r(Y4,{stripTypeScript:()=>Z9,hasVariables:()=>G9,extractVariables:()=>T1,extractScriptFromTemplate:()=>Q9,convertToCommonJS:()=>x$});import c1 from"path";import A5 from"process";function qQ($){let Z=[],Y=0,J=$.split(`
|
|
743
743
|
`);for(let Q of J){let X=Y,G=null,K=!1;for(let q=0;q<Q.length;q++){let W=Q[q];if(K){K=!1;continue}if(W==="\\"){K=!0;continue}if(G){if(W===G)G=null;continue}if(W==="'"||W==='"'||W==="`"){G=W;continue}if(W==="/"&&q+1<Q.length&&Q[q+1]==="/")break;if(W==="{")Y++;else if(W==="}")Y--}if(X===0){let q=Q.match(/(?:const|let|var)\s+(\w+)\s*=/);if(q)Z.push(q[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(Q)){let W=Q.match(/(?:const|let|var)\s+(\w+)/);if(W)Z.push(W[1])}else{let W=Q.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(W){let U=W[1].slice(1,-1).split(",").map((_)=>{let B=_.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((_)=>/^\w+$/.test(_));Z.push(...U)}}}}return[...new Set(Z)]}function Z9($){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 Q=[],X="",G=0,K=0,q=null;for(let W=0;W<J.length;W++){let z=J[W];if(q){if(X+=z,z===q)q=null;continue}if(z==='"'||z==="'"||z==="`"){q=z,X+=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){Q.push(X),X="";continue}X+=z}if(X)Q.push(X);return Q.map((W)=>{let z=W.trim(),U=z.startsWith("..."),_=U?z.slice(3):z,B=-1,j=0;for(let A=0;A<_.length;A++)if(_[A]==="<")j++;else if(_[A]===">")j--;else if(_[A]===":"&&j===0){B=A;break}if(B===-1)return W;let L=_.substring(0,B).trim().replace(/\?$/,""),F=_.substring(B+1),O=-1,V=0;for(let A=0;A<F.length;A++)if(F[A]==="<")V++;else if(F[A]===">")V--;else if(F[A]==="="&&V===0){O=A;break}let w=U?"...":"";if(O!==-1)return`${w}${L} = ${F.substring(O+1).trim()}`;return`${w}${L}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(J,Q,X)=>{if(!X.includes(":"))return J;return`${Q}(${Y(X)})`});{let J=/\b(function\s+\w*\s*)\(/g,Q,X=[];while((Q=J.exec(Z))!==null){let G=Q.index+Q[0].length-1,K=1,q=G+1,W=0,z=null;while(q<Z.length&&K>0){let B=Z[q];if(z){if(B===z)z=null;q++;continue}if(B==='"'||B==="'"||B==="`"){z=B,q++;continue}if(B==="<")W++;else if(B===">"&&W>0)W--;else if(W===0){if(B==="(")K++;else if(B===")")K--}if(K>0)q++}if(K!==0)continue;let U=Z.substring(G+1,q);if(!U.includes(":"))continue;let _=Y(U);X.push({start:G+1,end:q,replacement:_})}for(let G=X.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=X[G];Z=Z.substring(0,K)+W+Z.substring(q)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(J,Q)=>{if(!Q.includes(":"))return J;if(Q.includes("{")||Q.includes("}"))return J;return`(${Q.split(",").map((G)=>{let[K,...q]=G.split("="),W=K.split(":")[0].trim();if(q.length>0)return`${W} = ${q.join("=").trim()}`;return W}).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,`
|
|
744
744
|
|
|
745
|
-
`),Z}async function
|
|
746
|
-
`),
|
|
745
|
+
`),Z}async function T1($,Z,Y,J={}){if(!$.trim())return;let Q;try{let v=new Bun.Transpiler({loader:"ts",target:"browser",define:o0()}),f=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");f=f.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Q=v.transformSync(f)}catch{Q=Z9($)}let X={exports:{}},G=X.exports,K=A5.cwd(),q={},W=[...Q.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 W)try{let f=c1.resolve(K,"node_modules",v),C=c1.join(f,"package.json"),x=JSON.parse(z0("fs").readFileSync(C,"utf8")),u=x.main||"index.js";if(x.exports){let p=typeof x.exports==="string"?x.exports:x.exports["."];if(typeof p==="string")u=p;else if(p?.bun)u=p.bun;else if(p?.import)u=p.import;else if(p?.default)u=p.default}q[v]=await import(c1.resolve(f,u))}catch{}let z=(v)=>{if(q[v])return q[v];return z0(v)},U=Z.props||{},_=(v)=>{if(!v)return U;let f={};for(let[C,x]of Object.entries(v)){let u=U[C];if(u!==void 0)f[C]=u;else if(typeof x==="function")f[C]=x();else f[C]=x}return f};for(let[v,f]of Object.entries(U))Object.defineProperty(_,v,{value:f,enumerable:!0,configurable:!0,writable:!0});let B=(v)=>{if(!v)return U;let f={...U};for(let[C,x]of Object.entries(v)){let u=x&&typeof x==="object"&&!Array.isArray(x)?x:{type:x};if(f[C]===void 0&&u.default!==void 0)f[C]=typeof u.default==="function"?u.default():u.default}return f},j=()=>Z.slots||{},H=(v,f)=>{let C={...v};for(let[x,u]of Object.entries(f))if(C[x]===void 0)if(typeof u==="function")C[x]=u();else C[x]=u;return C},L=(v)=>{let f=()=>v;return f.set=(C)=>{},f.update=(C)=>{},f},F=(v)=>{let f,C=!1;return()=>{if(!C)try{f=v(),C=!0}catch{f=void 0}return f}},O=(v)=>{},V=(v)=>v(),w=(v)=>{},A=(v)=>{},N=(v)=>{},R=()=>{let v=Z.__stxServeContext,f=Z.__stxServeSearch??v?.search??"",C=v?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(f)),path:C,name:"",fullPath:C+f,hash:"",matched:[]}},T=()=>({push:(v)=>{},replace:(v)=>{},back:()=>{},forward:()=>{},go:(v)=>{}}),M=(v)=>{R1(v);let f=Z.__stx_runtime_head||{},C=v||{};Z.__stx_runtime_head={...f,...C.title&&{title:C.title},meta:[...f.meta||[],...C.meta||[]],link:[...f.link||[],...C.link||[]],script:[...f.script||[],...C.script||[]],htmlAttrs:{...f.htmlAttrs||{},...C.htmlAttrs||{}},bodyAttrs:{...f.bodyAttrs||{},...C.bodyAttrs||{}}}},I=(v)=>{Z4(v);let f=V5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...f.title&&{title:f.title},meta:f.meta?[...f.meta]:[]}},D=(v)=>({value:v}),E=(v)=>v,P=(v)=>({value:typeof v==="function"?v():v}),b=(v,f)=>{},k=(v)=>{},y=(v)=>{},g=(v)=>v?v():Promise.resolve(),h=(v)=>(f,...C)=>{},m=(v)=>{},i=(v,f)=>{},l=(v,f)=>f,q0=()=>({value:"light"}),V0=()=>({value:!1}),_0={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:{}},Z0=new Proxy(_0,{get(v,f){if(f in v)return v[f];return},set(v,f,C){return v[f]=C,!0}}),k0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},f0=console;try{let v=x$(Q,Y),f=new Set(Object.keys(U)),C=Object.keys(Z).filter((a)=>!f.has(a)&&a!=="props"),x=C.map((a)=>Z[a]),u=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"]),p=[],X0=[];for(let[a,F1]of Object.entries(U)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(a))continue;if(u.has(a))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${a}\\b`).test(v))continue;p.push(a),X0.push(F1)}let b0=qQ(v).map((a)=>`module.exports.${a} = typeof ${a} !== 'undefined' ? ${a} : module.exports.${a};`).join(`
|
|
746
|
+
`),h1=Z.params??{},g0=[],X1=[];for(let a=0;a<C.length;a++){if(C[a]==="params")continue;g0.push(C[a]),X1.push(x[a])}let L1=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...p,...g0,`return (async () => {
|
|
747
747
|
${v}
|
|
748
748
|
${b0}
|
|
749
749
|
return module.exports
|
|
750
|
-
})()`)(X,G,z,U,_,B,H,L,F,O,V,w,A,N,R,T,M,I,D,E,P,b,k,y,g,h,m,j,i,l,q0,V0,Z0,k0,f0,_0.confirm,_0.alert,_0.fetch,
|
|
751
|
-
`),Q=[],X=0;while(X<J.length){let G=J[X].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(;X<J.length;X++){for(let q of J[X])if(q==="{")K++;else if(q==="}")K--;if(K<=0)break}}X++;continue}if(G.startsWith("definePageMeta(")){let K=0,q=!1;for(let W=X;W<J.length&&!q;W++){let z=null,U=!1,_=J[W];for(let B=0;B<_.length;B++){let j=_[B];if(U){U=!1;continue}if(j==="\\"){U=!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){X=W+1,q=!0;break}}}}if(!q)X=J.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),q=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+['"](.+)['"]/),z=(U)=>{if(U.startsWith("."))return
|
|
750
|
+
})()`)(X,G,z,U,_,B,H,L,F,O,V,w,A,N,R,T,M,I,D,E,P,b,k,y,g,h,m,j,i,l,q0,V0,Z0,k0,f0,_0.confirm,_0.alert,_0.fetch,h1,...X0,...X1);if(J.preserveExisting){for(let[a,F1]of Object.entries(L1))if(!(a in Z)||Z[a]===void 0)Z[a]=F1}else Object.assign(Z,L1);for(let[a,F1]of Object.entries(U))if(!(a in Z))Z[a]=F1}catch(v){if(A5.env.STX_DEBUG){let f=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: ${f}`)}try{await BQ(Q,Z,Y)}catch(f){if(A5.env.STX_DEBUG){let C=f instanceof Error?f.message:String(f);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${C}`)}}}}function x$($,Z){let Y=Z?c1.dirname(Z):A5.cwd(),J=$.split(`
|
|
751
|
+
`),Q=[],X=0;while(X<J.length){let G=J[X].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(;X<J.length;X++){for(let q of J[X])if(q==="{")K++;else if(q==="}")K--;if(K<=0)break}}X++;continue}if(G.startsWith("definePageMeta(")){let K=0,q=!1;for(let W=X;W<J.length&&!q;W++){let z=null,U=!1,_=J[W];for(let B=0;B<_.length;B++){let j=_[B];if(U){U=!1;continue}if(j==="\\"){U=!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){X=W+1,q=!0;break}}}}if(!q)X=J.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),q=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+['"](.+)['"]/),z=(U)=>{if(U.startsWith("."))return c1.resolve(Y,U);return U};if(K){let[,U,_]=K,B=z(_);Q.push(`const ${U} = await import('${B}')`),Q.push(`module.exports.${U} = ${U};`)}else if(q){let[,U,_]=q,B=U.trim(),j=z(_);Q.push(`const { ${B} } = await import('${j}')`);for(let H of B.split(",")){let L=H.trim().split(/\s+as\s+/).pop()?.trim();if(L)Q.push(`module.exports.${L} = ${L};`)}}else if(W){let U=z(W[1]);Q.push(`await import('${U}')`)}else Q.push(G);X++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))Q.push(J[X]),X++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=a6(J,X),{type:q,name:W,value:z}=K;Q.push(`${q} ${W} = ${z};`),Q.push(`module.exports.${W} = ${W};`),X=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=v$(J,X);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),X=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=a6(J,X),{type:q,name:W,value:z}=K;Q.push(`${q} ${W} = ${z};`),Q.push(`module.exports.${W} = ${W};`),X=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=v$(J,X);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),X=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=J[X].replace(/^(\s*)export\s+default\s+/,"$1"),q=[...J];q[X]=K;let W=v$(q,X);if(Q.push(W.functionCode),W.name)Q.push(`module.exports.default = ${W.name};`);X=W.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");Q.push(`module.exports.default = ${K};`),X++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let q=K[1],W=J[X].replace(/^export\s+/,""),z=0,U=X;for(;U<J.length;U++){let _=J[U];for(let B of _)if(B==="{")z++;else if(B==="}")z--;if(U>X)W+=`
|
|
752
752
|
`+_;if(z<=0&&U>=X)break}Q.push(W),Q.push(`module.exports.${q} = ${q};`),X=U+1}else Q.push(G),X++}else if(G.includes("module.exports"))Q.push(G),X++;else if(G.trim()&&!G.startsWith("//"))Q.push(G),X++;else X++}return zQ(Q.join(`
|
|
753
753
|
`),Y)}function zQ($,Z){let Y=$.length,J="",Q=0,X=null,G=!1,K=!1,q=0;while(Q<Y){let W=$[Q],z=$[Q+1];if(G){if(J+=W,W===`
|
|
754
|
-
`)G=!1;Q++;continue}if(K){if(J+=W,W==="*"&&z==="/"){J+=z,Q+=2,K=!1;continue}Q++;continue}if(!X&&W==="/"&&z==="/"){G=!0,J+=W,Q++;continue}if(!X&&W==="/"&&z==="*"){K=!0,J+=W,Q++;continue}if(X){if(J+=W,W==="\\"){J+=z,Q+=2;continue}if(W===X&&X!=="`"){X=null,Q++;continue}if(X==="`"){if(W==="$"&&z==="{"){q++,J+=z,Q+=2;continue}if(W==="`"){X=null,Q++;continue}}Q++;continue}if(q>0){if(W==="{")q++;else if(W==="}")q--}if(W==='"'||W==="'"||W==="`"){X=W,J+=W,Q++;continue}if(W==="a"&&$.startsWith("await",Q)){let U=WQ($,Q);if(U){let{quote:_,path:B,end:j}=U;if(B.startsWith(".")){let H=
|
|
754
|
+
`)G=!1;Q++;continue}if(K){if(J+=W,W==="*"&&z==="/"){J+=z,Q+=2,K=!1;continue}Q++;continue}if(!X&&W==="/"&&z==="/"){G=!0,J+=W,Q++;continue}if(!X&&W==="/"&&z==="*"){K=!0,J+=W,Q++;continue}if(X){if(J+=W,W==="\\"){J+=z,Q+=2;continue}if(W===X&&X!=="`"){X=null,Q++;continue}if(X==="`"){if(W==="$"&&z==="{"){q++,J+=z,Q+=2;continue}if(W==="`"){X=null,Q++;continue}}Q++;continue}if(q>0){if(W==="{")q++;else if(W==="}")q--}if(W==='"'||W==="'"||W==="`"){X=W,J+=W,Q++;continue}if(W==="a"&&$.startsWith("await",Q)){let U=WQ($,Q);if(U){let{quote:_,path:B,end:j}=U;if(B.startsWith(".")){let H=c1.resolve(Z,B);J+=`await import(${_}${H}${_})`,Q=j;continue}}}J+=W,Q++}return J}function WQ($,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 Q=Y;while(Y<$.length&&$[Y]!==J)if($[Y]==="\\")Y+=2;else Y++;if(Y>=$.length)return null;let X=$.slice(Q,Y);Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!==")")return null;return{quote:J,path:X,end:Y+1}}function Y9($,Z){let Y=$[Z];if(Y!=="{"&&Y!=="[")return null;let Q=S0($,Y,Y==="{"?"}":"]",Z);if(Q===-1)return null;return{pattern:$.slice(Z,Q+1),endPos:Q+1}}function J9($){let Z=[],Y=$.slice(1,-1).trim();if(!Y)return Z;let J=0,Q=0,X="";while(J<Y.length){let G=Y[J];if(G==="{"||G==="["){if(Q++,Q===1){let K=Y9(Y,J);if(K){let q=J9(K.pattern);Z.push(...q),J=K.endPos,X="";continue}}}else if(G==="}"||G==="]")Q--;if(Q>0){J++;continue}if(G===","){if(X.trim())Z.push(X.trim());X="",J++;continue}if(G===":"){X="",J++;continue}if(G==="="){if(X.trim())Z.push(X.trim());X="",J++;while(J<Y.length&&Y[J]!==","&&Q===0){if(Y[J]==="{"||Y[J]==="[")Q++;else if(Y[J]==="}"||Y[J]==="]")Q--;J++}continue}if(/[\w$]/.test(G))X+=G;J++}if(X.trim())Z.push(X.trim());return Z}function a6($,Z){let Y=$[Z].trim(),J=Y.match(/^(?:export\s+)?(const|let|var)\s+(\w+)\s*=\s*(.*)$/);if(!J){let W=Y.match(/^(?:export\s+)?(const|let|var)\s+/);if(W){let z=Y.slice(W[0].length),U=Z;if((z.startsWith("{")||z.startsWith("["))&&!z.includes(z.startsWith("{")?"}":"]")){let B=z.startsWith("{")?"}":"]",j=z;for(let H=Z+1;H<$.length;H++)if(j+=" "+$[H].trim(),U=H,$[H].includes(B))break;z=j}let _=Y9(z,0);if(_){let B=W[1],j=_.pattern,H=z.slice(_.endPos).trim();if(H.startsWith("=")){let L=H.slice(1).trim(),F=L,O=Math.max(U,Z);if(t6(L)){let N=e6($,O,L);F=N.value,O=N.nextIndex}else O=O+1;F=F.trim().replace(/;$/,"");let V=J9(j),w=`__stx_src_${Z}`,A=V.map((N)=>`module.exports.${N} = ${N};`).join(`
|
|
755
755
|
`);return{type:B,name:w,value:`${F}; ${B} ${j} = ${w};
|
|
756
756
|
${A}`,nextIndex:O}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}let[,Q,X,G]=J,K=G,q=Z;if(t6(G)){let W=e6($,Z,G);K=W.value,q=W.nextIndex}else q=Z+1;while(q<$.length){let W=$[q].trim();if(W.startsWith(".")||W.startsWith("?."))K+=`
|
|
757
757
|
${$[q]}`,q++;else break}return K=K.trim().replace(/;$/,""),{type:Q,name:X,value:K,nextIndex:q}}function v$($,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[,Q]=J,X=Y.replace(/^export\s+/,""),G=Z;if(UQ(Y)){let K=_Q($,Z,X);X=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:Q,functionCode:X,nextIndex:G}}function t6($){let Z=$.trim();if(Z.startsWith("{"))return S0(Z,"{","}",0)===-1;if(Z.startsWith("["))return S0(Z,"[","]",0)===-1;return!X9(Z)}function X9($){let Z={paren:0,bracket:0,brace:0},Y=null,J=0;for(let Q=0;Q<$.length;Q++){let X=$[Q];if((Q>0?$[Q-1]:"")==="\\"&&Y)continue;if((X==='"'||X==="'")&&!Y){Y=X;continue}if(X===Y&&Y!=="`"){Y=null;continue}if(X==="`"&&!Y){Y="`";continue}if(X==="`"&&Y==="`"&&J===0){Y=null;continue}if(Y==="`"&&X==="$"&&$[Q+1]==="{"){J++,Q++;continue}if(J>0&&X==="{"){J++;continue}if(J>0&&X==="}"){J--;continue}if(Y)continue;if(X==="(")Z.paren++;else if(X===")")Z.paren--;else if(X==="[")Z.bracket++;else if(X==="]")Z.bracket--;else if(X==="{")Z.brace++;else if(X==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&Y===null}function UQ($){let Z=$.indexOf("{");if(Z===-1)return!0;return S0($,"{","}",Z)===-1}function e6($,Z,Y){let J=Y,Q=Z+1;while(Q<$.length&&!X9(J)){let X=$[Q];J+=`
|
|
758
758
|
${X}`,Q++}while(Q<$.length){let X=$[Q].trim();if(X.startsWith(".")||X.startsWith("?."))J+=`
|
|
759
759
|
${$[Q]}`,Q++;else break}return{value:J,nextIndex:Q}}function _Q($,Z,Y){let J=Y,Q=Z+1;while(Q<$.length){let X=J.indexOf("{");if(X!==-1){if(S0(J,"{","}",X)!==-1)break}let G=$[Q];J+=`
|
|
760
|
-
${G}`,Q++}return{functionCode:J,nextIndex:Q}}function $9($,Z){let Y=Y0($,Z)??Y0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let J={...Z,process:Object.freeze({env:{...A5.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 BQ($,Z,Y){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let X of J){let[,,G,K]=X;try{let q=K.trim().replace(/;$/,""),W=$9(q,Z);if(W!==void 0)Z[G]=W}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}let Q=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let X of Q){let[,,G,K]=X;if(!(G in Z))try{let q=K.trim().replace(/;$/,""),W=$9(q,Z);if(W!==void 0)Z[G]=W}catch{}}}function Q9($){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 G9($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var N5=S(()=>{w5();
|
|
761
|
-
`)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<X-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},W=()=>{if(J!==0)return;let z=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(Q).match(/^async\s+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)}};while(Q<X){if(q())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){J++,Q++;continue}if($[Q]==="}"){J--,Q++;continue}if(J===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))W();Q++}return Z}function TQ($){let Z=[],Y=0,J=0,Q=null;for(let X=0;X<$.length;X++){let G=$[X];if(Q){if(G==="\\"){X++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(J,X)),J=X+1}if(J<$.length)Z.push($.slice(J));return Z}function MQ($){let Z=0,Y=null;for(let J=0;J<$.length;J++){let Q=$[J];if(Y){if(Q==="\\"){J++;continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let X=$[J-1],G=$[J+1];if(X==="!"||X==="<"||X===">"||X==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function IQ($,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 Q=J,X=0,G=-1;for(;J>=0;J--){let q=$[J];if(q==="}")X++;else if(q==="{"){if(X--,X===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let q of TQ(K)){let W=q.trim();if(!W||W.startsWith("..."))continue;let z=MQ(W);if(z===-1)continue;let U=W.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let _=W.slice(z+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[U]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function _9($,Z,Y,J,Q){let X=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[X,X.toLowerCase(),G(X),K(X)])if(q.has(L))return!0}let W=[...new Set([`${X}.stx`,`${G(X)}.stx`,`${K(X)}.stx`])],z=typeof Q.root==="string"?d.resolve(Q.root):void 0,U=z??d.dirname(J),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(d.join(d.dirname(j),"components"));B(Z),B(d.join(d.dirname(J),"components")),B(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(z)B(d.resolve(z,"resources/views/components")),B(d.resolve(z,"resources/components")),B(d.resolve(z,"src/components")),B(d.resolve(z,"components"));if(X.startsWith("./")||X.startsWith("../"))return n(d.resolve(d.dirname(J),`${X}.stx`));for(let L of _){let F=d.isAbsolute(L)?L:d.resolve(U,L);for(let O of W)if(await n(d.join(F,O)))return!0}return!1}function DQ($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function
|
|
760
|
+
${G}`,Q++}return{functionCode:J,nextIndex:Q}}function $9($,Z){let Y=Y0($,Z)??Y0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let J={...Z,process:Object.freeze({env:{...A5.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 BQ($,Z,Y){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let X of J){let[,,G,K]=X;try{let q=K.trim().replace(/;$/,""),W=$9(q,Z);if(W!==void 0)Z[G]=W}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}let Q=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let X of Q){let[,,G,K]=X;if(!(G in Z))try{let q=K.trim().replace(/;$/,""),W=$9(q,Z);if(W!==void 0)Z[G]=W}catch{}}}function Q9($){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 G9($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var N5=S(()=>{w5();d1();R0()});var f$={};r(f$,{renderSlot:()=>q9,processSlots:()=>W9,parseSlots:()=>K9,parseSlotElement:()=>HQ,extractSlotContent:()=>FQ,applySlots:()=>VQ});function jQ($,Z){let Y=1,J=Z,Q="<template",X="</template";while(J<$.length&&Y>0){let G=$.indexOf("<",J);if(G===-1)break;if(J=G,$.startsWith(Q,J)&&(J+Q.length>=$.length||/[\s>\/]/.test($[J+Q.length]))){Y++,J+=Q.length;continue}if($.startsWith(X,J)){let K=$.indexOf(">",J+X.length);if(K!==-1){if(Y--,Y===0)return K+1;J=K+1;continue}}J++}return Y===0?J:-1}function K9($){let Z={default:"",named:new Map},Y=$,J=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,Q=[],X;while((X=J.exec($))!==null){let[z,U,_,B,j]=X,H=U||_||B,L=X.index+z.length,F=jQ($,L);if(F!==-1){let O=$.slice(L,F-11).trim();Q.push({start:X.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}Q.sort((z,U)=>U.start-z.start);for(let z of Q)Y=Y.slice(0,z.start)+Y.slice(z.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,q;while((q=K.exec(Y))!==null){let[z,U,_,B,j,H]=q,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${U}${O?" "+O:""}>${H}</${U}>`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:V})}let W=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((q=W.exec(Y))!==null){let[z,U,_,B,j]=q,H=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${U}${F?" "+F:""} />`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:O})}G.sort((z,U)=>U.start-z.start);for(let z of G){let U=Z.named.get(z.slotName);if(U)U.content+=z.element;else Z.named.set(z.slotName,{name:z.slotName,content:z.element});Y=Y.slice(0,z.start)+Y.slice(z.end)}return Z.default=Y.trim(),Z}function HQ($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",J={},Q=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,X;while((X=Q.exec($))!==null)J[X[1]]=X[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:J,defaultContent:K}}async function q9($,Z,Y,J){if(!$)return Y;let Q=$.content;if($.propsBinding&&Object.keys(Z).length>0){let X=$.propsBinding.trim(),G={...J};if(X.startsWith("{")&&X.endsWith("}")){let K=X.slice(1,-1).split(",").map((q)=>q.trim()).filter(Boolean);for(let q of K){let[W,z]=q.split(":").map((_)=>_.trim()),U=z||W;if(Z[W]!==void 0)G[U]=Z[W]}}else G[X]=Z;Q=OQ(Q,G)}return Q}function OQ($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,J)=>{try{let Q=J.trim(),X=z9(Q,Z);return u0(String(X??""))}catch{return`{{ ${J} }}`}})}function z9($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let J=$.split("."),Q=Z;for(let X of J)if(Q&&typeof Q==="object"&&X in Q)Q=Q[X];else return;return Q}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,J,Q,X]=Y,G=Z[J],K=parseInt(X,10);if(typeof G==="number")switch(Q){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!Q0($))return;return G0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function W9($,Z,Y){let J=$;J=await LQ(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,q,W)=>{let z=Z.named.get(K),U=W?.trim()||"",_=q||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(_))!==null){let L=H[1],F=H[2];B[L]=z9(F,Y)}return await q9(z,B,U,Y)});let X=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(X,(G,K)=>{if(G.includes("name="))return G;let q=K?.trim()||"";return Z.default||q}),J}async function LQ($,Z,Y){let J=[],Q=[];$.replace(Z,(K,...q)=>{let W=q[q.length-2];return Q.push({match:K,index:W}),J.push(Y(K,...q.slice(0,-2))),K});let X=await Promise.all(J),G=$;for(let K=Q.length-1;K>=0;K--){let{match:q,index:W}=Q[K];G=G.slice(0,W)+X[K]+G.slice(W+q.length)}return G}function FQ($){let Z=K9($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function VQ($,Z,Y,J){return await W9($,{default:Z,named:Y},J)}var g$=S(()=>{r0();R0()});import wQ from"fs";import d from"path";function U9($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function NQ($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function w1($){return!NQ($)}function A1($){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,(X)=>{let G=Y.length;return Y.push(X),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(X)=>{let G=Y.length;return Y.push(X),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(X)=>{let G=Y.length;return Y.push(X),`"__STX_EXPR_${G}__"`});let Q=new Bun.Transpiler({loader:"ts",target:"browser",define:o0()}).transformSync(Z);for(let X=0;X<Y.length;X++)Q=Q.replace(`"__STX_EXPR_${X}__"`,Y[X]),Q=Q.replace(`'__STX_EXPR_${X}__'`,Y[X]);return Q}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function RQ($){let Z=[],Y=new Set,J=0,Q=0,X=$.length,G=(z)=>{Q++;while(Q<X){if($[Q]==="\\"){Q+=2;continue}if($[Q]===z){Q++;return}Q++}},K=()=>{Q++;while(Q<X){if($[Q]==="\\"){Q+=2;continue}if($[Q]==="`"){Q++;return}if($[Q]==="$"&&$[Q+1]==="{"){Q+=2;let z=1;while(Q<X&&z>0)if($[Q]==="{")z++,Q++;else if($[Q]==="}")z--,Q++;else if($[Q]==="'"||$[Q]==='"')G($[Q]);else if($[Q]==="`")K();else Q++;continue}Q++}},q=()=>{if($[Q]==="/"&&$[Q+1]==="/"){while(Q<X&&$[Q]!==`
|
|
761
|
+
`)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<X-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},W=()=>{if(J!==0)return;let z=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(Q).match(/^async\s+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)}};while(Q<X){if(q())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){J++,Q++;continue}if($[Q]==="}"){J--,Q++;continue}if(J===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))W();Q++}return Z}function TQ($){let Z=[],Y=0,J=0,Q=null;for(let X=0;X<$.length;X++){let G=$[X];if(Q){if(G==="\\"){X++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(J,X)),J=X+1}if(J<$.length)Z.push($.slice(J));return Z}function MQ($){let Z=0,Y=null;for(let J=0;J<$.length;J++){let Q=$[J];if(Y){if(Q==="\\"){J++;continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let X=$[J-1],G=$[J+1];if(X==="!"||X==="<"||X===">"||X==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function IQ($,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 Q=J,X=0,G=-1;for(;J>=0;J--){let q=$[J];if(q==="}")X++;else if(q==="{"){if(X--,X===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let q of TQ(K)){let W=q.trim();if(!W||W.startsWith("..."))continue;let z=MQ(W);if(z===-1)continue;let U=W.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let _=W.slice(z+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[U]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function _9($,Z,Y,J,Q){let X=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[X,X.toLowerCase(),G(X),K(X)])if(q.has(L))return!0}let W=[...new Set([`${X}.stx`,`${G(X)}.stx`,`${K(X)}.stx`])],z=typeof Q.root==="string"?d.resolve(Q.root):void 0,U=z??d.dirname(J),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(d.join(d.dirname(j),"components"));B(Z),B(d.join(d.dirname(J),"components")),B(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(z)B(d.resolve(z,"resources/views/components")),B(d.resolve(z,"resources/components")),B(d.resolve(z,"src/components")),B(d.resolve(z,"components"));if(X.startsWith("./")||X.startsWith("../"))return n(d.resolve(d.dirname(J),`${X}.stx`));for(let L of _){let F=d.isAbsolute(L)?L:d.resolve(U,L);for(let O of W)if(await n(d.join(F,O)))return!0}return!1}function DQ($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function M1($,Z,Y,J,Q,X,G,K=new Set,q){let{extractVariables:W}=await Promise.resolve().then(() => (N5(),Y4)),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let U=new Set(z);U.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&DQ(_)?_:"";try{let j=(C)=>C.split("-").map((x)=>x.charAt(0).toUpperCase()+x.slice(1)).join(""),H=(C)=>C.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=Q.__importedComponents;if(O){let C=[L,L.toLowerCase(),j(L),H(L)];for(let x of C)if(O.has(x)){F=O.get(x);break}}let V=[];if(!F){let C=[`${L}.stx`,`${j(L)}.stx`,`${H(L)}.stx`],x=[...new Set(C)],u=Q.__originalFilePath,p=[];if(u){let H0=d.join(d.dirname(u),"components");p.push(H0)}if(J)p.push(J);let X0=d.join(d.dirname(X),"components");if(!p.includes(X0))p.push(X0);if(G.componentsDir&&G.componentsDir!==J&&!p.includes(G.componentsDir))p.push(G.componentsDir);let W0=G._pluginComponentDirs;if(Array.isArray(W0)){for(let H0 of W0)if(typeof H0==="string"&&!p.includes(H0))p.push(H0)}let b0=typeof G.root==="string"?d.resolve(G.root):void 0,h1=b0??d.dirname(X),g0=[];if(b0)g0.push(d.resolve(b0,"resources/views/components")),g0.push(d.resolve(b0,"resources/components")),g0.push(d.resolve(b0,"src/components")),g0.push(d.resolve(b0,"components"));g0.push(d.resolve(import.meta.dir,"components"));for(let H0 of g0)if(!p.includes(H0))p.push(H0);let X1=[...new Set(p.map((H0)=>{if(!H0)return H0;return d.isAbsolute(H0)?H0:d.resolve(h1,H0)}))];if(p.length=0,p.push(...X1),L.startsWith("./")||L.startsWith("../"))F=d.resolve(d.dirname(X),`${L}.stx`),V.push(F);else for(let H0 of p){if(!H0)continue;for(let L1 of x){let a=d.join(H0,L1);if(V.push(a),await n(a)){F=a;break}}if(F)break;if(!F)try{let L1=await import("fs");if(!L1.statSync(H0,{throwIfNoEntry:!1})?.isDirectory())continue;let F1=8,u5=[{path:H0,depth:0}];while(u5.length>0&&!F){let p5=u5.pop();if(p5.depth>=F1)continue;let X6;try{X6=L1.readdirSync(p5.path,{withFileTypes:!0})}catch{continue}for(let l5 of X6){if(!l5.isDirectory())continue;if(l5.name==="node_modules"||l5.name.startsWith("."))continue;let Q6=d.join(p5.path,l5.name);for(let uJ of x){let A$=d.join(Q6,uJ);if(V.push(A$),await n(A$)){F=A$;break}}if(F)break;u5.push({path:Q6,depth:p5.depth+1})}}}catch{}if(F)break}}if(!F||!await n(F)){let C=V.length>0?`
|
|
762
762
|
Searched paths:
|
|
763
763
|
${V.map((x)=>` - ${x}`).join(`
|
|
764
|
-
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}q.add(F);let w;if(h$.has(F))w=h$.get(F);else try{w=await Bun.file(F).text(),h$.set(F,w)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[C,x]of Object.entries(Q))if(!C.startsWith("__")||A.has(C))N[C]=x;let{extractSlotContent:R}=await Promise.resolve().then(() => (g$(),f$)),T=R(Y),M={};if(T.defaultSlot?.trim())M.default=T.defaultSlot;for(let[C,x]of T.namedSlots)M[C]=x.content;let I={...N,...Z,props:Z,slot:Y,$slots:M,__processedComponents:U,__sections:{}};IQ(w,I);let D=w,E=D.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(E)D=E[1].trim();let P=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,b=[...w.matchAll(P)],k=[];for(let C of b){let x=C[1]||"",u=C[2]||"",p=x.includes("server");if(
|
|
765
|
-
`)}`}if(Y&&l.includes("{{ text || slot }}"))l=l.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{applySlots:q0}=await Promise.resolve().then(() => (g$(),f$)),{defaultSlot:V0,namedSlots:_0}=T;l=await q0(l,V0||Y,_0,I);for(let[C,x]of Object.entries(I))if(typeof x==="string"){if(x.includes("<")&&x.includes(">")||x.includes("<")||x.includes(""")){let u=b$(x);I[C]=u}}let Z0=k.some((C)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),k0={...G,componentsDir:d.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:Z0,defaultLayout:void 0};I.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let f0=await j0(l,I,F,k0,q),v=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++AQ}_${Math.random().toString(36).slice(2,8)}`,f=f0;if(Z0){let C="";if(Object.keys(Z).length>0)try{C=` data-stx-props="${U9(JSON.stringify(Z))}"`}catch{}let x=B?` stx-hydrate="${U9(B)}"`:"";if(f=`<div data-stx-scope="${v}"${C}${x}>${f0}</div>`,f=k.map((p)=>{let X0=p.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!X0)return p;let[,W0,b0]=X0,
|
|
764
|
+
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}q.add(F);let w;if(h$.has(F))w=h$.get(F);else try{w=await Bun.file(F).text(),h$.set(F,w)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[C,x]of Object.entries(Q))if(!C.startsWith("__")||A.has(C))N[C]=x;let{extractSlotContent:R}=await Promise.resolve().then(() => (g$(),f$)),T=R(Y),M={};if(T.defaultSlot?.trim())M.default=T.defaultSlot;for(let[C,x]of T.namedSlots)M[C]=x.content;let I={...N,...Z,props:Z,slot:Y,$slots:M,__processedComponents:U,__sections:{}};IQ(w,I);let D=w,E=D.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(E)D=E[1].trim();let P=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,b=[...w.matchAll(P)],k=[];for(let C of b){let x=C[1]||"",u=C[2]||"",p=x.includes("server");if(w1(x)&&u.trim())u=A1(u);if(p&&u)try{await W(u,I,F)}catch(W0){}if(!p){let W0=u.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(W0.includes("{{")&&W0.includes("}}"))W0=s0(W0,I,F);let b0=x.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");k.push(`<script${b0}>${W0}</script>`)}}let y=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),g=y?y[1]:"",h=y?y[2]:"",m="",i=g&&/\bscoped\b/i.test(g);if(y)m=`<style${g}>${h}</style>`;let l=D;if(l=l.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y)l=l.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let C=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,x=[];if(l=l.replace(C,(u,p)=>{let X0=p.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(X0)x.push(`<style${X0[1]}>${X0[2]}</style>`);return""}),l=l.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),x.length>0)m=`${m}${x.join(`
|
|
765
|
+
`)}`}if(Y&&l.includes("{{ text || slot }}"))l=l.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{applySlots:q0}=await Promise.resolve().then(() => (g$(),f$)),{defaultSlot:V0,namedSlots:_0}=T;l=await q0(l,V0||Y,_0,I);for(let[C,x]of Object.entries(I))if(typeof x==="string"){if(x.includes("<")&&x.includes(">")||x.includes("<")||x.includes(""")){let u=b$(x);I[C]=u}}let Z0=k.some((C)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),k0={...G,componentsDir:d.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:Z0,defaultLayout:void 0};I.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let f0=await j0(l,I,F,k0,q),v=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++AQ}_${Math.random().toString(36).slice(2,8)}`,f=f0;if(Z0){let C="";if(Object.keys(Z).length>0)try{C=` data-stx-props="${U9(JSON.stringify(Z))}"`}catch{}let x=B?` stx-hydrate="${U9(B)}"`:"";if(f=`<div data-stx-scope="${v}"${C}${x}>${f0}</div>`,f=k.map((p)=>{let X0=p.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!X0)return p;let[,W0,b0]=X0,h1=$1(b0),g0=`
|
|
766
766
|
(function() {
|
|
767
767
|
const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
|
|
768
768
|
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
@@ -774,12 +774,12 @@ ${V.map((x)=>` - ${x}`).join(`
|
|
|
774
774
|
const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
|
|
775
775
|
const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
|
|
776
776
|
|
|
777
|
-
${
|
|
777
|
+
${h1}
|
|
778
778
|
|
|
779
779
|
// Register all defined signals and functions in this scope
|
|
780
780
|
const __localVars = {};
|
|
781
781
|
try {
|
|
782
|
-
${RQ(
|
|
782
|
+
${RQ(h1).map((X1)=>`if (typeof ${X1} !== 'undefined') __localVars['${X1}'] = ${X1};`).join(`
|
|
783
783
|
`)}
|
|
784
784
|
}
|
|
785
785
|
catch (e) {}
|
|
@@ -805,8 +805,8 @@ ${t.yellow}${t.bold}Message:${t.reset} ${Z}
|
|
|
805
805
|
`,K)z+=`
|
|
806
806
|
${t.blue}${t.bold}Context:${t.reset}
|
|
807
807
|
${t.dim}${K}${t.reset}
|
|
808
|
-
`;return z}var h$,AQ=0,t;var A0=S(()=>{j5();r0();
|
|
809
|
-
`||O==="\r"||O===" "||O===void 0)U++;_=L+9}else{if(U--,U===0){B=F;break}_=F+12}}if(B===-1)continue;let j=$.slice(z,B),H=$.slice(K,B+12);Q.push({fullMatch:H,options:W,content:j,index:K}),X.lastIndex=B+12}for(let{fullMatch:K,options:q,content:W,index:z}of Q)try{let U={};if(q)q.split(",").forEach((j)=>{let H=j.trim();if(H)U[H]=!0});let _={gfm:U.gfm??!0,breaks:U.breaks??!1},B=W5(W.trim(),_);J=J.split(K).join(B)}catch(U){let _=U instanceof Error?U.message:String(U),B=K0("Markdown Directive",`Error processing markdown: ${_}`,Y,$,z,K);J=J.split(K).join(B)}return J}async function H9($,Z,Y,J){let Q={gfm:!0,breaks:!1};return Z.forEach((X)=>{let G=X.trim().replace(/['"]/g,"");if(G==="breaks")Q.breaks=!0;if(G==="no-gfm")Q.gfm=!1}),W5($.trim(),Q)}var u$=S(()=>{A0()});function SQ($){if(kQ.set($.name,$),$.client)bQ.set($.name,$.client)}function X4($){return SQ($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,J,Q,X)=>{let G=yQ(J,$.defaults);if($.validate){let q=$.validate(G);if(q!==!0){let W=typeof q==="string"?q:`Invalid parameters for @${$.name}`;throw Error(W)}}let K=Y;if($.transform)K=await $.transform(Y,G,Q,X);if($.clientScript){let q=$.clientScript(G);K+=`<script>${q}</script>`}if($.css){let q=$.css(G);K+=`<style>${q}</style>`}return K}}}function yQ($,Z){let Y={...Z};for(let J of $){let Q=J.indexOf(":"),X=J.indexOf("="),G=Q>=0&&(X<0||Q<X)?Q:X;if(G>=0){let K=J.slice(0,G).trim(),q=J.slice(G+1).trim();if(q==="true")q=!0;else if(q==="false")q=!1;else if(q==="null")q=null;else if(!Number.isNaN(Number(q)))q=Number(q);else if(typeof q==="string"&&q.startsWith("{"))try{q=JSON.parse(q)}catch{}Y[K]=q}else{let K=Object.keys(Y).filter((q)=>!Z||!(q in Z)).length;Y[K===0?"value":`arg${K}`]=J}}return Y}var kQ,bQ;var p$=S(()=>{kQ=new Map,bQ=new Map});function l$($,Z=
|
|
808
|
+
`;return z}var h$,AQ=0,t;var A0=S(()=>{j5();r0();l1();J4();d1();C$();r6();N5();h$=new F5(500);t={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function j9($,Z,Y=""){let J=$,Q=[],X=/@markdown(?:\([^)]*\))?/g,G;while((G=X.exec($))!==null){let K=G.index,q=G[0].match(/@markdown\(([^)]*)\)/),W=q?q[1]:"",z=K+G[0].length,U=1,_=z,B=-1;while(U>0&&_<$.length){let L=$.indexOf("@markdown",_),F=$.indexOf("@endmarkdown",_);if(F===-1)break;if(L!==-1&&L<F&&L!==K){let O=$[L+9];if(O==="("||O===`
|
|
809
|
+
`||O==="\r"||O===" "||O===void 0)U++;_=L+9}else{if(U--,U===0){B=F;break}_=F+12}}if(B===-1)continue;let j=$.slice(z,B),H=$.slice(K,B+12);Q.push({fullMatch:H,options:W,content:j,index:K}),X.lastIndex=B+12}for(let{fullMatch:K,options:q,content:W,index:z}of Q)try{let U={};if(q)q.split(",").forEach((j)=>{let H=j.trim();if(H)U[H]=!0});let _={gfm:U.gfm??!0,breaks:U.breaks??!1},B=W5(W.trim(),_);J=J.split(K).join(B)}catch(U){let _=U instanceof Error?U.message:String(U),B=K0("Markdown Directive",`Error processing markdown: ${_}`,Y,$,z,K);J=J.split(K).join(B)}return J}async function H9($,Z,Y,J){let Q={gfm:!0,breaks:!1};return Z.forEach((X)=>{let G=X.trim().replace(/['"]/g,"");if(G==="breaks")Q.breaks=!0;if(G==="no-gfm")Q.gfm=!1}),W5($.trim(),Q)}var u$=S(()=>{A0()});function SQ($){if(kQ.set($.name,$),$.client)bQ.set($.name,$.client)}function X4($){return SQ($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,J,Q,X)=>{let G=yQ(J,$.defaults);if($.validate){let q=$.validate(G);if(q!==!0){let W=typeof q==="string"?q:`Invalid parameters for @${$.name}`;throw Error(W)}}let K=Y;if($.transform)K=await $.transform(Y,G,Q,X);if($.clientScript){let q=$.clientScript(G);K+=`<script>${q}</script>`}if($.css){let q=$.css(G);K+=`<style>${q}</style>`}return K}}}function yQ($,Z){let Y={...Z};for(let J of $){let Q=J.indexOf(":"),X=J.indexOf("="),G=Q>=0&&(X<0||Q<X)?Q:X;if(G>=0){let K=J.slice(0,G).trim(),q=J.slice(G+1).trim();if(q==="true")q=!0;else if(q==="false")q=!1;else if(q==="null")q=null;else if(!Number.isNaN(Number(q)))q=Number(q);else if(typeof q==="string"&&q.startsWith("{"))try{q=JSON.parse(q)}catch{}Y[K]=q}else{let K=Object.keys(Y).filter((q)=>!Z||!(q in Z)).length;Y[K===0?"value":`arg${K}`]=J}}return Y}var kQ,bQ;var p$=S(()=>{kQ=new Map,bQ=new Map});function l$($,Z=i1,Y={},J){return Z.sort((Q,X)=>Q-X).map((Q)=>{return`${T5($,{...Y,w:Q,fm:J})} ${Q}w`}).join(", ")}function O9($,Z,Y=CQ,J={},Q){return Y.sort((X,G)=>X-G).map((X)=>{let G=Math.round(Z*X);return`${T5($,{...J,w:G,dpr:X,fm:Q})} ${X}x`}).join(", ")}function c$($,Z="100vw"){if(!$||Object.keys($).length===0)return Z;let J=Object.entries($).map(([Q,X])=>{let G=/^\d+$/.test(Q)?`${Q}px`:Q;return{bp:G,size:X,numericBp:Number.parseInt(G)||0}}).sort((Q,X)=>Q.numericBp-X.numericBp).map(({bp:Q,size:X})=>`(max-width: ${Q}) ${X}`);return J.push(Z),J.join(", ")}function T5($,Z={}){let Y=Object.entries(Z).filter(([,X])=>X!==void 0&&X!==null).map(([X,G])=>{if(Array.isArray(G))return[X,G.join(",")];return[X,String(G)]});if(Y.length===0)return $;let J=Y.map(([X,G])=>`${X}=${encodeURIComponent(G)}`).join("&"),Q=$.includes("?")?"&":"?";return`${$}${Q}${J}`}function i$($){return PQ[$]||"application/octet-stream"}var i1,CQ,R5,PQ;var n$=S(()=>{i1=[320,480,640,768,1024,1280,1536,1920,2560],CQ=[1,1.5,2,3],R5=["avif","webp","jpeg"],PQ={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"}});async function xQ(){try{return await import("ts-images")}catch{return null}}async function fQ($,Z={}){let Y={...vQ,...Z},J=await xQ();if(J)try{return await gQ($,Y,J)}catch(Q){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${Q}`)}return hQ($,Y)}async function gQ($,Z,Y){let{generatePlaceholder:J,generateThumbHash:Q}=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 Q($)).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 hQ($,Z){let Y=Z.width||20,J=Z.height||Y,Q="#e5e7eb",X=`<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(X)}`,width:Y,height:J,aspectRatio:Y/J,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}function L9($,Z,Y={}){let J=Y.transitionDuration||300,Q=Y.easing||"ease-out";return`
|
|
810
810
|
#${$} {
|
|
811
811
|
--stx-img-transition-duration: ${J}ms;
|
|
812
812
|
--stx-img-transition-easing: ${Q};
|
|
@@ -852,8 +852,8 @@ ${t.dim}${K}${t.reset}
|
|
|
852
852
|
filter: blur(0);
|
|
853
853
|
transform: scale(1);
|
|
854
854
|
}
|
|
855
|
-
`.trim();o$=new Map});import{createHash as A9}from"crypto";import{readFile as dQ,stat as N9}from"fs/promises";async function I0($){try{let Z=await dQ($);return A9("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function w9($){return A9("sha256").update($).digest("hex").slice(0,16)}function Q4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${w9($)}-${w9(Y)}`}async function r$($){try{return(await N9($)).mtimeMs}catch{return 0}}async function M0($){try{return await N9($),!0}catch{return!1}}var D1=()=>{};import{mkdir as mQ,readFile as uQ,writeFile as pQ,readdir as sB,rm as lQ,stat as rB}from"fs/promises";import{join as T9,dirname as cQ}from"path";async function iQ($){try{await mQ($,{recursive:!0})}catch{}}function M9($,Z,Y){return T9($,Y,`${Z}.json`)}async function R9($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await r$(Z)!==$.srcMtime)return!1;return!0}async function G4($,Z,Y,J=a$){if(!J.enabled)return null;let Q=Q4($,Z),X=o1.get(Q);if(X){if(await R9(X,$,J.maxAge))return X.lastAccessedAt=Date.now(),X.data;o1.delete(Q)}let G=M9(J.directory,Q,Y);if(await M0(G))try{let K=await uQ(G,"utf-8"),q=JSON.parse(K);if(await R9(q,$,J.maxAge))return q.lastAccessedAt=Date.now(),o1.set(Q,q),q.data}catch{}return null}async function K4($,Z,Y,J,Q=a$){if(!Q.enabled)return;let X=Q4($,Z),G=await I0($),K=await r$($),q={key:X,src:$,srcHash:G,srcMtime:K,optionsHash:Q4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};o1.set(X,q);let W=M9(Q.directory,X,J);try{await iQ(cQ(W)),await pQ(W,JSON.stringify(q,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function q4($,Z=a$){if($==="all")o1.clear();else o1.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let Q=T9(Z.directory,J);try{await lQ(Q,{recursive:!0,force:!0})}catch{}}}var o1,a$;var t$=S(()=>{D1();o1=new Map,a$={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class W4{config;constructor($={}){this.config={...nQ,...$}}async get($,Z){return G4($,Z,"image",this.config)}async set($,Z,Y){return K4($,Z,Y,"image",this.config)}async clear(){return q4("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function e$($){if(!z4)z4=new W4($);else if($)z4.updateConfig($);return z4}async function U4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return e$(J).get($,Z)}async function _4($,Z,Y,J){let Q=J?{directory:`${J.outputDir}/../.cache`}:{};return e$(Q).set($,Z,Y)}async function I9(){return e$().clear()}var nQ,z4=null;var $7=S(()=>{t$();nQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as oQ,basename as sQ,extname as rQ,join as aQ}from"path";import{mkdir as tQ}from"fs/promises";async function Z7(){try{return await import("ts-images")}catch{return null}}function D9($){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 eQ($,Z){let Y=Z?D9(Z):D9("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 E9($,Z,Y){let J=await Z7();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await U4($,Z,Y);if(Q)return Q;try{let X=oQ($);if(!await M0(X))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=eQ(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await tQ(K,{recursive:!0});let W=await I0(X),z=sQ($,rQ($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await Y7(X,Z.transformations,J);for(let j of U){let H=G[j]||{},L=`${z}-${W}.${j}`,F=aQ(K,L);try{let O=await J.optimizeImage({input:B||X,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await J.generateThumbHash(X);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await J.generatePlaceholder(X,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await _4($,Z,_,Y),_}catch(X){return{src:$,processed:!1,errors:[`Processing failed: ${X}`]}}}async function k9($,Z,Y,J){let Q=await Z7();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(X){return{success:!1,error:String(X)}}}async function Y7($,Z,Y){let J=Y||await Z7();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await J.decode($);for(let X of Z){let G=X.options||{};switch(X.type){case"resize":if(G.width||G.height)Q=await J.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await J.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await J.sharpen(Q,G.amount);break;case"grayscale":Q=await J.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await J.rotate(Q,G.angle);break;case"flip":Q=await J.flip(Q);break;case"flop":Q=await J.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await J.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await J.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await J.saturation(Q,G.value);break}}return await J.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var b9=S(()=>{D1();$7()});import{resolve as $G,basename as ZG,extname as YG,join as JG}from"path";import{mkdir as XG}from"fs/promises";async function QG(){try{return await import("ts-images")}catch{return null}}async function S9($,Z,Y){let J=await QG();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=$G($);if(!await M0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let X=Z.responsiveWidths||Y.breakpoints||GG,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await XG(K,{recursive:!0});let W=await I0(Q),z=ZG($,YG($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of X){let F=`${z}-${L}w-${W}.${j}`,O=JG(K,F),V=`${q}/${F}`;try{let w=U[j]?.quality||80;if(await M0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let A=await J.processImage({input:Q,output:O,format:j,quality:w,resize:{width:L}});if(A)_.byFormat[j].push({path:O,url:V,width:L,height:A.height||Math.round(L*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await J.generateThumbHash(Q);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await J.generatePlaceholder(Q,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||KG(X),_}catch(X){return console.error(`[stx-media] Responsive generation failed: ${X}`),null}}function KG($){let Z=[...$].sort((J,Q)=>J-Q),Y=[];for(let J=0;J<Z.length-1;J++){let Q=Z[J];Y.push(`(max-width: ${Q}px) ${Q}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function y9($,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 GG;var C9=S(()=>{D1();GG=[320,480,640,768,1024,1280,1536,1920]});var P9={};r(P9,{setCachedImageResult:()=>_4,processImage:()=>E9,optimizeImage:()=>k9,getCachedImageResult:()=>U4,generateSrcset:()=>y9,generateResponsiveVariants:()=>S9,clearImageCache:()=>I9,applyTransformations:()=>Y7,ImageProcessorCache:()=>W4});var v9=S(()=>{b9();C9();$7()});async function qG(){try{return await Promise.resolve().then(() => (v9(),P9))}catch($){if(!x9)console.warn("[stx-media] Image processor not available, some features disabled:",$),x9=!0;return null}}async function B4($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return _G(J,Y)}if(Y.processedResult?.processed)return G7($,Y.processedResult,Z);if(Y.responsiveVariants)return d9($,Y.responsiveVariants,Z);let{src:Q,alt:X,width:G,height:K,sizes:q,widths:W=n1,dpr:z,formats:U=R5,quality:_=J7,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":H4,decoding:V=j4,fetchpriority:w,objectFit:A,objectPosition:N,crossorigin:R,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:P=!1,baseUrl:b=""}=Z;if(P&&!Z.optimize)return UG($);let k,y,g=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{k=await F9(Q,{strategy:j,...H}),y=L9(g,k,H)}catch{}let h=z!==void 0&&G!==void 0,m;if(h)m=WG($,g,k,Z);else m=await zG($,g,k,Z);let i;if(F){let V0=U.includes("webp")?"webp":U[0],_0=l$(Q,W,{...B,q:_},V0),Z0=typeof q==="object"?c$(q):q||"100vw";i=`<link rel="preload" as="image" imagesrcset="${_0}" imagesizes="${Z0}" />`}let l=[];if(!f9&&j!=="none")l.push(s$),f9=!0;if(y)l.push(y);let q0=L?h9(g):void 0;return{html:m,preloadLink:i,css:l.length>0?l.join(`
|
|
856
|
-
`):void 0,script:q0}}async function zG($,Z,Y,J){let{src:Q,alt:X,width:G,height:K,sizes:q,widths:W=
|
|
855
|
+
`.trim();o$=new Map});import{createHash as A9}from"crypto";import{readFile as dQ,stat as N9}from"fs/promises";async function I0($){try{let Z=await dQ($);return A9("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function w9($){return A9("sha256").update($).digest("hex").slice(0,16)}function Q4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${w9($)}-${w9(Y)}`}async function r$($){try{return(await N9($)).mtimeMs}catch{return 0}}async function M0($){try{return await N9($),!0}catch{return!1}}var I1=()=>{};import{mkdir as mQ,readFile as uQ,writeFile as pQ,readdir as sB,rm as lQ,stat as rB}from"fs/promises";import{join as T9,dirname as cQ}from"path";async function iQ($){try{await mQ($,{recursive:!0})}catch{}}function M9($,Z,Y){return T9($,Y,`${Z}.json`)}async function R9($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await r$(Z)!==$.srcMtime)return!1;return!0}async function G4($,Z,Y,J=a$){if(!J.enabled)return null;let Q=Q4($,Z),X=n1.get(Q);if(X){if(await R9(X,$,J.maxAge))return X.lastAccessedAt=Date.now(),X.data;n1.delete(Q)}let G=M9(J.directory,Q,Y);if(await M0(G))try{let K=await uQ(G,"utf-8"),q=JSON.parse(K);if(await R9(q,$,J.maxAge))return q.lastAccessedAt=Date.now(),n1.set(Q,q),q.data}catch{}return null}async function K4($,Z,Y,J,Q=a$){if(!Q.enabled)return;let X=Q4($,Z),G=await I0($),K=await r$($),q={key:X,src:$,srcHash:G,srcMtime:K,optionsHash:Q4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};n1.set(X,q);let W=M9(Q.directory,X,J);try{await iQ(cQ(W)),await pQ(W,JSON.stringify(q,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function q4($,Z=a$){if($==="all")n1.clear();else n1.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let Q=T9(Z.directory,J);try{await lQ(Q,{recursive:!0,force:!0})}catch{}}}var n1,a$;var t$=S(()=>{I1();n1=new Map,a$={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class W4{config;constructor($={}){this.config={...nQ,...$}}async get($,Z){return G4($,Z,"image",this.config)}async set($,Z,Y){return K4($,Z,Y,"image",this.config)}async clear(){return q4("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function e$($){if(!z4)z4=new W4($);else if($)z4.updateConfig($);return z4}async function U4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return e$(J).get($,Z)}async function _4($,Z,Y,J){let Q=J?{directory:`${J.outputDir}/../.cache`}:{};return e$(Q).set($,Z,Y)}async function I9(){return e$().clear()}var nQ,z4=null;var $7=S(()=>{t$();nQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as oQ,basename as sQ,extname as rQ,join as aQ}from"path";import{mkdir as tQ}from"fs/promises";async function Z7(){try{return await import("ts-images")}catch{return null}}function D9($){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 eQ($,Z){let Y=Z?D9(Z):D9("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 E9($,Z,Y){let J=await Z7();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await U4($,Z,Y);if(Q)return Q;try{let X=oQ($);if(!await M0(X))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=eQ(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await tQ(K,{recursive:!0});let W=await I0(X),z=sQ($,rQ($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await Y7(X,Z.transformations,J);for(let j of U){let H=G[j]||{},L=`${z}-${W}.${j}`,F=aQ(K,L);try{let O=await J.optimizeImage({input:B||X,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await J.generateThumbHash(X);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await J.generatePlaceholder(X,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await _4($,Z,_,Y),_}catch(X){return{src:$,processed:!1,errors:[`Processing failed: ${X}`]}}}async function k9($,Z,Y,J){let Q=await Z7();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(X){return{success:!1,error:String(X)}}}async function Y7($,Z,Y){let J=Y||await Z7();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await J.decode($);for(let X of Z){let G=X.options||{};switch(X.type){case"resize":if(G.width||G.height)Q=await J.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await J.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await J.sharpen(Q,G.amount);break;case"grayscale":Q=await J.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await J.rotate(Q,G.angle);break;case"flip":Q=await J.flip(Q);break;case"flop":Q=await J.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await J.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await J.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await J.saturation(Q,G.value);break}}return await J.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var b9=S(()=>{I1();$7()});import{resolve as $G,basename as ZG,extname as YG,join as JG}from"path";import{mkdir as XG}from"fs/promises";async function QG(){try{return await import("ts-images")}catch{return null}}async function S9($,Z,Y){let J=await QG();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=$G($);if(!await M0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let X=Z.responsiveWidths||Y.breakpoints||GG,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await XG(K,{recursive:!0});let W=await I0(Q),z=ZG($,YG($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of X){let F=`${z}-${L}w-${W}.${j}`,O=JG(K,F),V=`${q}/${F}`;try{let w=U[j]?.quality||80;if(await M0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let A=await J.processImage({input:Q,output:O,format:j,quality:w,resize:{width:L}});if(A)_.byFormat[j].push({path:O,url:V,width:L,height:A.height||Math.round(L*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await J.generateThumbHash(Q);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await J.generatePlaceholder(Q,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||KG(X),_}catch(X){return console.error(`[stx-media] Responsive generation failed: ${X}`),null}}function KG($){let Z=[...$].sort((J,Q)=>J-Q),Y=[];for(let J=0;J<Z.length-1;J++){let Q=Z[J];Y.push(`(max-width: ${Q}px) ${Q}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function y9($,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 GG;var C9=S(()=>{I1();GG=[320,480,640,768,1024,1280,1536,1920]});var P9={};r(P9,{setCachedImageResult:()=>_4,processImage:()=>E9,optimizeImage:()=>k9,getCachedImageResult:()=>U4,generateSrcset:()=>y9,generateResponsiveVariants:()=>S9,clearImageCache:()=>I9,applyTransformations:()=>Y7,ImageProcessorCache:()=>W4});var v9=S(()=>{b9();C9();$7()});async function qG(){try{return await Promise.resolve().then(() => (v9(),P9))}catch($){if(!x9)console.warn("[stx-media] Image processor not available, some features disabled:",$),x9=!0;return null}}async function B4($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return _G(J,Y)}if(Y.processedResult?.processed)return G7($,Y.processedResult,Z);if(Y.responsiveVariants)return d9($,Y.responsiveVariants,Z);let{src:Q,alt:X,width:G,height:K,sizes:q,widths:W=i1,dpr:z,formats:U=R5,quality:_=J7,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":H4,decoding:V=j4,fetchpriority:w,objectFit:A,objectPosition:N,crossorigin:R,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:P=!1,baseUrl:b=""}=Z;if(P&&!Z.optimize)return UG($);let k,y,g=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{k=await F9(Q,{strategy:j,...H}),y=L9(g,k,H)}catch{}let h=z!==void 0&&G!==void 0,m;if(h)m=WG($,g,k,Z);else m=await zG($,g,k,Z);let i;if(F){let V0=U.includes("webp")?"webp":U[0],_0=l$(Q,W,{...B,q:_},V0),Z0=typeof q==="object"?c$(q):q||"100vw";i=`<link rel="preload" as="image" imagesrcset="${_0}" imagesizes="${Z0}" />`}let l=[];if(!f9&&j!=="none")l.push(s$),f9=!0;if(y)l.push(y);let q0=L?h9(g):void 0;return{html:m,preloadLink:i,css:l.length>0?l.join(`
|
|
856
|
+
`):void 0,script:q0}}async function zG($,Z,Y,J){let{src:Q,alt:X,width:G,height:K,sizes:q,widths:W=i1,formats:z=R5,quality:U=J7,params:_={},lazy:B=!0,priority:j=!1,loading:H=j?"eager":H4,decoding:L=j4,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,N=$.class,R=$.style,T=$.data||{},M=typeof q==="object"?c$(q):q||"100vw",I=[];for(let P of z){let b=l$(Q,W,{..._,q:U},P),k=i$(P);if(B&&!j)I.push(` <source type="${k}" data-srcset="${b}" data-sizes="${M}" />`);else I.push(` <source type="${k}" srcset="${b}" sizes="${M}" />`)}let D=X7({src:T5(Q,{..._,q:U}),alt:X,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A,className:g9(N,Y),style:Q7(R,O,V,Y),lazy:B&&!j,data:T}),E;if(Y){let P=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${P}">
|
|
857
857
|
<picture>
|
|
858
858
|
${I.join(`
|
|
859
859
|
`)}
|
|
@@ -913,11 +913,11 @@ ${A.join(`
|
|
|
913
913
|
`)}
|
|
914
914
|
<img ${R.join(" ")} />
|
|
915
915
|
</picture>`;let P=[];if(Z.placeholder)P.push(s$);let b=G?h9(j):void 0,k;if(K&&V)k=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:E,preloadLink:k,css:P.length>0?P.join(`
|
|
916
|
-
`):void 0,script:b}}async function d9($,Z,Y){let J={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[Q,X]of Object.entries(Z.byFormat))if(X)J.variants.push(...X);return G7($,J,Y)}var x9=!1,J7=80,j4="async",H4="lazy",f9=!1;var m9=S(()=>{n$();V9()});function BG(){return X4({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,J)=>{let{src:Q,alt:X,options:G}=jG($,Z,Y);if(!Q)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:Q,alt:X||"",widths:G.widths||
|
|
916
|
+
`):void 0,script:b}}async function d9($,Z,Y){let J={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[Q,X]of Object.entries(Z.byFormat))if(X)J.variants.push(...X);return G7($,J,Y)}var x9=!1,J7=80,j4="async",H4="lazy",f9=!1;var m9=S(()=>{n$();V9()});function BG(){return X4({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,J)=>{let{src:Q,alt:X,options:G}=jG($,Z,Y);if(!Q)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:Q,alt:X||"",widths:G.widths||i1,formats:G.formats||R5,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},q=Y.__isDev||!1,W=await B4(K,{isDev:q}),z=W.html;if(W.preloadLink)z=W.preloadLink+`
|
|
917
917
|
`+z;if(W.css)z+=`
|
|
918
918
|
<style>${W.css}</style>`;if(W.script)z+=`
|
|
919
|
-
<script>${W.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function jG($,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 Q=HG(J),X=K7(Q[0],Y)||"",G=K7(Q[1],Y)||"",K={};if(Q[2]){let q=K7(Q[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof Q[2]==="string")try{K=JSON.parse(Q[2])}catch{}}return{src:X,alt:G,options:K}}function HG($){let Z=[],Y="",J=!1,Q="",X=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],W=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&W!=="\\"){if(!J)J=!0,Q=q;else if(q===Q)J=!1,Q="";else Y+=q;continue}if(!J){if(q==="{")X++;if(q==="}")X--;if(q==="[")G++;if(q==="]")G--;if(q===","&&X===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function K7($,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 u9;var p9=S(()=>{p$();m9();n$();u9=BG()});class L4{config;constructor($={}){this.config={...OG,...$}}async get($,Z){return G4($,Z,"video",this.config)}async set($,Z,Y){return K4($,Z,Y,"video",this.config)}async clear(){return q4("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function q7($){if(!O4)O4=new L4($);else if($)O4.updateConfig($);return O4}async function F4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return q7(J).get($,Z)}async function V4($,Z,Y,J){let Q=J?{directory:`${J.outputDir}/../.cache`}:{};return q7(Q).set($,Z,Y)}async function l9(){return q7().clear()}var OG,O4=null;var z7=S(()=>{t$();OG={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as W7,basename as U7,extname as _7,join as w4}from"path";import{mkdir as B7}from"fs/promises";async function j7(){try{return await import("ts-videos")}catch{return null}}async function A4($,Z,Y,J){let Q=await j7();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let X=W7($);if(!await M0(X))return null;await B7(Y,{recursive:!0});let G=await I0(X),K=U7($,_7($)),q=Z.format||"webp",W=Z.timestamp||0,z=`${K}-poster-${G}.${q}`,U=w4(Y,z),_=await Q.extractThumbnails(X,{timestamps:[W],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:z.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:U,url:`${J}/${z}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:W,size:B.size||0}}return null}catch(X){return console.warn(`[stx-media] Failed to generate poster: ${X}`),null}}async function N4($,Z,Y,J){let Q=await j7();if(!Q)return[];try{let X=W7($);if(!await M0(X))return[];await B7(Y,{recursive:!0});let G=await I0(X),K=U7($,_7($)),q=Z.format||"webp",U=(await new Q.Input(X).getInfo()).duration||60,_=Z.count||10,B=Z.interval||U/_,j=[];for(let L=0;L<_&&L*B<U;L++)j.push(L*B);let H=await Q.extractThumbnails(X,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||w4(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${J}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(X){return console.warn(`[stx-media] Failed to generate thumbnails: ${X}`),[]}}async function c9($,Z,Y,J){let Q=await j7();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let X=W7($);if(!await M0(X))return null;await B7(Y,{recursive:!0});let G=await I0(X),K=U7($,_7($)),z=(await new Q.Input(X).getInfo()).duration||60,U=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(z/_),F=Math.ceil(L/U),O=`${K}-sprite-${G}.${H}`,V=w4(Y,O),w=[];for(let N=0;N<L;N++)w.push(N*_);let A=await Q.extractThumbnails(X,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:w4(Y,".temp")});if(!A||A.length===0)return null;try{let N=await import("ts-images"),R=U*B,T=F*j,M=await N.createSprite({images:A.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${J}/${O}`,path:V,columns:U,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(X){return console.warn(`[stx-media] Failed to generate sprite sheet: ${X}`),null}}var H7=S(()=>{
|
|
920
|
-
`)}async function M4($,Z,Y,J,Q){let X=await a9();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=n9($);if(!await M0(G))return null;let K=await I0(G),q=o9($,s9($)),W=
|
|
919
|
+
<script>${W.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function jG($,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 Q=HG(J),X=K7(Q[0],Y)||"",G=K7(Q[1],Y)||"",K={};if(Q[2]){let q=K7(Q[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof Q[2]==="string")try{K=JSON.parse(Q[2])}catch{}}return{src:X,alt:G,options:K}}function HG($){let Z=[],Y="",J=!1,Q="",X=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],W=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&W!=="\\"){if(!J)J=!0,Q=q;else if(q===Q)J=!1,Q="";else Y+=q;continue}if(!J){if(q==="{")X++;if(q==="}")X--;if(q==="[")G++;if(q==="]")G--;if(q===","&&X===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function K7($,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 u9;var p9=S(()=>{p$();m9();n$();u9=BG()});class L4{config;constructor($={}){this.config={...OG,...$}}async get($,Z){return G4($,Z,"video",this.config)}async set($,Z,Y){return K4($,Z,Y,"video",this.config)}async clear(){return q4("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function q7($){if(!O4)O4=new L4($);else if($)O4.updateConfig($);return O4}async function F4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return q7(J).get($,Z)}async function V4($,Z,Y,J){let Q=J?{directory:`${J.outputDir}/../.cache`}:{};return q7(Q).set($,Z,Y)}async function l9(){return q7().clear()}var OG,O4=null;var z7=S(()=>{t$();OG={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as W7,basename as U7,extname as _7,join as w4}from"path";import{mkdir as B7}from"fs/promises";async function j7(){try{return await import("ts-videos")}catch{return null}}async function A4($,Z,Y,J){let Q=await j7();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let X=W7($);if(!await M0(X))return null;await B7(Y,{recursive:!0});let G=await I0(X),K=U7($,_7($)),q=Z.format||"webp",W=Z.timestamp||0,z=`${K}-poster-${G}.${q}`,U=w4(Y,z),_=await Q.extractThumbnails(X,{timestamps:[W],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:z.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:U,url:`${J}/${z}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:W,size:B.size||0}}return null}catch(X){return console.warn(`[stx-media] Failed to generate poster: ${X}`),null}}async function N4($,Z,Y,J){let Q=await j7();if(!Q)return[];try{let X=W7($);if(!await M0(X))return[];await B7(Y,{recursive:!0});let G=await I0(X),K=U7($,_7($)),q=Z.format||"webp",U=(await new Q.Input(X).getInfo()).duration||60,_=Z.count||10,B=Z.interval||U/_,j=[];for(let L=0;L<_&&L*B<U;L++)j.push(L*B);let H=await Q.extractThumbnails(X,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||w4(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${J}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(X){return console.warn(`[stx-media] Failed to generate thumbnails: ${X}`),[]}}async function c9($,Z,Y,J){let Q=await j7();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let X=W7($);if(!await M0(X))return null;await B7(Y,{recursive:!0});let G=await I0(X),K=U7($,_7($)),z=(await new Q.Input(X).getInfo()).duration||60,U=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(z/_),F=Math.ceil(L/U),O=`${K}-sprite-${G}.${H}`,V=w4(Y,O),w=[];for(let N=0;N<L;N++)w.push(N*_);let A=await Q.extractThumbnails(X,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:w4(Y,".temp")});if(!A||A.length===0)return null;try{let N=await import("ts-images"),R=U*B,T=F*j,M=await N.createSprite({images:A.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${J}/${O}`,path:V,columns:U,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(X){return console.warn(`[stx-media] Failed to generate sprite sheet: ${X}`),null}}var H7=S(()=>{I1()});import{resolve as n9,basename as o9,extname as s9,join as D1}from"path";import{mkdir as R4,writeFile as r9}from"fs/promises";async function a9(){try{return await import("ts-videos")}catch{return null}}async function T4($,Z,Y,J,Q){let X=await a9();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=n9($);if(!await M0(G))return null;let K=await I0(G),q=o9($,s9($)),W=D1(Y,`${q}-${K}-hls`);await R4(W,{recursive:!0});let z=Z.length>0?Z:t9,U=Q?.segmentDuration||6,j=(await new X.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of z){let w=D1(W,V.label);await R4(w,{recursive:!0});let A=`${V.label}.m3u8`,N=D1(w,A);try{let R=await X.generateHLS(G,{outputDir:w,segmentDuration:U,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(R)H.push({quality:V,url:`${J}/${q}-${K}-hls/${V.label}/${A}`,path:N}),L+=R.segmentCount||Math.ceil(j/U)}catch(R){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${R}`)}}if(H.length===0)return null;let F=D1(W,"master.m3u8"),O=LG(H,J,q,K);return await r9(F,O),{manifestUrl:`${J}/${q}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function LG($,Z,Y,J){let Q=["#EXTM3U","#EXT-X-VERSION:3"];for(let X of $){let{quality:G}=X,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;Q.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return Q.join(`
|
|
920
|
+
`)}async function M4($,Z,Y,J,Q){let X=await a9();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=n9($);if(!await M0(G))return null;let K=await I0(G),q=o9($,s9($)),W=D1(Y,`${q}-${K}-dash`);await R4(W,{recursive:!0});let z=Z.length>0?Z:t9,U=Q?.segmentDuration||4,_=Q?.minBufferTime||2,H=(await new X.Input(G).getInfo()).duration||0,L=[],F=[];for(let A of z){let N=D1(W,A.label);await R4(N,{recursive:!0});try{if(await X.generateDASH(G,{outputDir:N,segmentDuration:U,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(L.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${J}/${q}-${K}-dash/${A.label}/video`}),A.audioBitrate)F.push({bandwidth:A.audioBitrate,url:`${J}/${q}-${K}-dash/${A.label}/audio`})}}catch(R){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${R}`)}}if(L.length===0)return null;let O=D1(W,"manifest.mpd"),V=FG(L,F,H,U,_);await r9(O,V);let w=[{type:"video",representations:L}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${J}/${q}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function FG($,Z,Y,J,Q){let X=i9(Y),G=i9(Q),K=`<?xml version="1.0" encoding="UTF-8"?>
|
|
921
921
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
922
922
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
923
923
|
xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
|
|
@@ -943,7 +943,7 @@ ${A.join(`
|
|
|
943
943
|
</Representation>
|
|
944
944
|
`}K+=` </AdaptationSet>
|
|
945
945
|
`}return K+=` </Period>
|
|
946
|
-
</MPD>`,K}function i9($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),Q="PT";if(Z>0)Q+=`${Z}H`;if(Y>0)Q+=`${Y}M`;return Q+=`${J}S`,Q}var t9;var O7=S(()=>{
|
|
946
|
+
</MPD>`,K}function i9($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),Q="PT";if(Z>0)Q+=`${Z}H`;if(Y>0)Q+=`${Y}M`;return Q+=`${J}S`,Q}var t9;var O7=S(()=>{I1();t9=[{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 e9,basename as VG,extname as wG,join as AG}from"path";import{mkdir as NG}from"fs/promises";async function $8(){try{return await import("ts-videos")}catch{return null}}function RG($){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 TG($){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 L7($){let Z=await $8();if(!Z)return null;try{let Y=e9($),Q=await new Z.Input(Y).getInfo();return{duration:Q.duration||0,width:Q.width||0,height:Q.height||0,frameRate:Q.frameRate||0,bitrate:Q.bitrate||0,codec:Q.videoCodec||"",audioCodec:Q.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function Z8($,Z,Y,J){let Q=await $8();if(!Q)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let X=await F4($,Z,Y);if(X)return X;try{let G=e9($);if(!await M0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await NG(K,{recursive:!0});let W=await I0(G),z=VG($,wG($)),U={src:$,processed:!0,hash:W};J?.({percentage:5,stage:"analyzing"}),U.metadata=await L7(G)||void 0;let _={};if(Z.quality)_.bitrate=RG(Z.quality);if(Z.platform)Object.assign(_,TG(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){J?.({percentage:10,stage:"transcoding"});let B=`${z}-${W}.mp4`,j=AG(K,B);try{let H=await MG(G,j,_,Q,(L)=>J?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)U.transcoded={path:j,url:`${q}/${B}`,duration:H.duration,size:H.size,video:{codec:_.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(H){U.errors=U.errors||[],U.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){J?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await A4(G,B,K,q);if(j)U.poster=j}if(Y.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let B=await N4(G,Y.thumbnails,K,q);if(B.length>0)U.thumbnails=B}if(Z.streaming){J?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await T4(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,hls:j}}if(B.format==="dash"){let j=await M4(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,dash:j}}}if(Z.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await V4($,Z,U,Y),U}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function MG($,Z,Y,J,Q){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)=>{Q?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(X){return console.error(`[stx-media] Transcoding failed: ${X}`),null}}var Y8=S(()=>{I1();z7();H7();O7()});var J8={};r(J8,{setCachedVideoResult:()=>V4,processVideo:()=>Z8,getCachedVideoResult:()=>F4,generateThumbnails:()=>N4,generateSpriteSheet:()=>c9,generatePoster:()=>A4,generateHLSManifest:()=>T4,generateDASHManifest:()=>M4,clearVideoCache:()=>l9,analyzeVideo:()=>L7,VideoProcessorCache:()=>L4});var X8=S(()=>{Y8();H7();O7();z7()});async function G8(){try{return await Promise.resolve().then(() => (X8(),J8))}catch($){if(!Q8)console.warn("[stx-media] Video processor not available, some features disabled:",$),Q8=!0;return null}}async function I4($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return SG(J,Y)}if(Y.processedResult?.processed)return W8($,Y.processedResult,Z);let Q;if(J.generatePoster&&J.src&&!$.poster)Q=await yG(J,Y);let{src:X,sources:G=[],poster:K,posterPlaceholder:q,controls:W=K8,autoplay:z=!1,muted:U=!1,loop:_=!1,preload:B=q8,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:N=!1}=$,R=Q||K,T=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return EG($,Z);if(F&&F!=="video")return DG(X||"",F,$);let D=G.length>0?G:X?[{src:X,type:z8(X)}]:[],E=[`id="${I}"`];if(W)E.push("controls");if(z)E.push("autoplay");if(U)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(A)E.push("disablepictureinpicture");if(N)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),R)E.push(`data-poster="${w0(R)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),R)E.push(`poster="${w0(R)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(T)E.push(`class="${w0(T)}"`);if(M)E.push(`style="${w0(M)}"`);let P=D.map((y)=>{return` <source ${H?`data-src="${w0(y.src)}"`:`src="${w0(y.src)}"`} type="${y.type}"${y.media?` media="${y.media}"`:""} />`}).join(`
|
|
947
947
|
`),b=`<video ${E.join(" ")}>
|
|
948
948
|
${P}
|
|
949
949
|
Your browser does not support the video tag.
|
|
@@ -1501,7 +1501,7 @@ catch (error) {
|
|
|
1501
1501
|
init();
|
|
1502
1502
|
}
|
|
1503
1503
|
})();
|
|
1504
|
-
</script>`}var hG,dG,mG,uG,j8;var H8=S(()=>{hG={name:"pwa.installButton",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return vG($,Q)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},dG={name:"pwa.updatePrompt",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return xG($,Q)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},mG={name:"pwa.offlineIndicator",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return fG($,Q)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},uG={name:"pwa.pushSubscribe",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return gG($,Q)},hasEndTag:!0,description:"Renders a push notification subscription button"},j8=[hG,dG,mG,uG]});function w7($){for(let[Z,Y]of Object.entries(s))if(Y===$)return Z;return}var s;var D4=S(()=>{s={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function M5(){return!1}function I5(){return!M5()||process.env.STX_DEBUG==="true"}function E4(){return!1}import pG from"path";function k4(){return{...A7}}function b4($){if(!A7.showRelativePaths||!$)return $;let Z=A7.baseDir||process.cwd();try{let Y=pG.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var lG,A7,S4,
|
|
1504
|
+
</script>`}var hG,dG,mG,uG,j8;var H8=S(()=>{hG={name:"pwa.installButton",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return vG($,Q)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},dG={name:"pwa.updatePrompt",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return xG($,Q)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},mG={name:"pwa.offlineIndicator",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return fG($,Q)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},uG={name:"pwa.pushSubscribe",handler:($,Z,Y,J)=>{let Q=Y.__stx_options||{};return gG($,Q)},hasEndTag:!0,description:"Renders a push notification subscription button"},j8=[hG,dG,mG,uG]});function w7($){for(let[Z,Y]of Object.entries(s))if(Y===$)return Z;return}var s;var D4=S(()=>{s={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function M5(){return!1}function I5(){return!M5()||process.env.STX_DEBUG==="true"}function E4(){return!1}import pG from"path";function k4(){return{...A7}}function b4($){if(!A7.showRelativePaths||!$)return $;let Z=A7.baseDir||process.cwd();try{let Y=pG.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var lG,A7,S4,E1,y4;var C4=S(()=>{D4();lG={showRelativePaths:!1,enableAutoRecovery:I5(),logRecoveryWarnings:!0},A7={...lG};S4=class S4 extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,Y,J,Q,X,G){super($);this.code=Z;this.filePath=Y;this.line=J;this.column=Q;this.context=X;if(this.name="StxError",this.numericCode=G||s.EVALUATION_ERROR,this.filePath)this.filePath=b4(this.filePath)}};E1=class E1 extends S4{constructor($,Z,Y,J,Q,X){super($,"stx_RUNTIME_ERROR",Z,Y,J,Q,X||s.EVALUATION_ERROR);this.name="StxRuntimeError"}};y4=class y4 extends S4{isFatal=!0;constructor($,Z,Y,J,Q,X){super($,"stx_VALIDATION_ERROR",Z,Y,J,Q,X||s.DOM_API_VIOLATION);this.name="StxValidationError"}}});function L8($){let{type:Z,message:Y,code:J,filePath:Q,line:X,column:G,template:K,offset:q,snippet:W,suggestion:z,format:U="text"}=$,_=X,B=G;if(!_&&K&&q!==void 0){let O=rG(K,q);_=O.line,B=O.column}let j=Q?b4(Q):void 0,H=J?w7(J):void 0,L={type:Z,code:J,codeName:H,message:Y,filePath:j,line:_,column:B,snippet:W,suggestion:z,timestamp:new Date().toISOString()},F;switch(U){case"html":F=iG(L);break;case"json":F=JSON.stringify(L,null,2);break;case"console":F=nG(L,K,q);break;case"text":default:F=cG(L,K,q);break}return{formatted:F,data:L}}function cG($,Z,Y){let J=[],Q=$.code?` [${$.codeName||$.code}]`:"";if(J.push(`[${$.type} Error${Q}]`),$.filePath){let X=$.filePath;if($.line){if(X+=`:${$.line}`,$.column)X+=`:${$.column}`}J.push(`at ${X}`)}if(J.push(`
|
|
1505
1505
|
${$.message}`),Z&&$.line){let X=oG(Z,$.line,2);if(X)J.push(`
|
|
1506
1506
|
${X}`)}if($.snippet)J.push(`
|
|
1507
1507
|
Snippet: ${$.snippet}`);if($.suggestion)J.push(`
|
|
@@ -1519,7 +1519,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
1519
1519
|
`)}function sG($,Z,Y){let J=$.split(`
|
|
1520
1520
|
`),Q=Math.max(0,Z-Y-1),X=Math.min(J.length-1,Z+Y-1),G="\x1B[90m",K="\x1B[31m",q="\x1B[0m",W=[];for(let z=Q;z<=X;z++){let U=(z+1).toString().padStart(4),_=z===Z-1,B=_?"\x1B[31m>\x1B[0m":" ",j=_?`\x1B[31m${J[z]}\x1B[0m`:`\x1B[90m${J[z]}\x1B[0m`;W.push(`${B}\x1B[90m${U}\x1B[0m | ${j}`)}return W.join(`
|
|
1521
1521
|
`)}function O8($){return $.replace(/--/g,"- -").replace(/>/g,">")}function rG($,Z){let J=$.substring(0,Z).split(`
|
|
1522
|
-
`);return{line:J.length,column:J[J.length-1].length}}function e($,Z,Y){return L8({type:$,message:Z,code:Y,format:"html"}).formatted}async function
|
|
1522
|
+
`);return{line:J.length,column:J[J.length-1].length}}function e($,Z,Y){return L8({type:$,message:Z,code:Y,format:"html"}).formatted}async function o1($,Z,Y){try{return await $()}catch(J){if(Y&&J instanceof Error)Y(J);return Z}}var F8=S(()=>{D4();C4()});class R7{errors=[];maxErrors;enableFileLogging;logFilePath;logFormat;maxFileSize;maxLogFiles;minLevel;writeQueue=Promise.resolve();constructor($={}){this.maxErrors=$.maxErrors??1000,this.enableFileLogging=$.enableFileLogging??!1,this.logFilePath=$.logFilePath??".stx/errors.log",this.logFormat=$.logFormat??"json",this.maxFileSize=$.maxFileSize??10485760,this.maxLogFiles=$.maxLogFiles??5,this.minLevel=$.minLevel??"all"}configure($){if($.maxErrors!==void 0)this.maxErrors=$.maxErrors;if($.enableFileLogging!==void 0)this.enableFileLogging=$.enableFileLogging;if($.logFilePath!==void 0)this.logFilePath=$.logFilePath;if($.logFormat!==void 0)this.logFormat=$.logFormat;if($.maxFileSize!==void 0)this.maxFileSize=$.maxFileSize;if($.maxLogFiles!==void 0)this.maxLogFiles=$.maxLogFiles;if($.minLevel!==void 0)this.minLevel=$.minLevel}log($,Z,Y="error"){let J={timestamp:new Date,error:$,context:Z,level:Y};if(this.errors.push(J),this.errors.length>this.maxErrors)this.errors=this.errors.slice(-this.maxErrors);if(this.enableFileLogging&&this.shouldLog(Y))this.writeToFile(J)}shouldLog($){if(this.minLevel==="all")return!0;if(this.minLevel==="warning")return $==="error"||$==="warning";if(this.minLevel==="error")return $==="error";return!0}formatEntry($){if(this.logFormat==="json")return JSON.stringify({timestamp:$.timestamp.toISOString(),level:$.level||"error",type:$.error.constructor.name,message:$.error.message,stack:$.error.stack,context:$.context});let Z=[`[${$.timestamp.toISOString()}] [${($.level||"error").toUpperCase()}] ${$.error.constructor.name}: ${$.error.message}`];if($.error.stack)Z.push(` Stack: ${$.error.stack.split(`
|
|
1523
1523
|
`).slice(1).join(`
|
|
1524
1524
|
`)}`);if($.context)Z.push(` Context: ${JSON.stringify($.context)}`);return Z.join(`
|
|
1525
1525
|
`)}writeToFile($){this.writeQueue=this.writeQueue.then(async()=>{try{let Z=await import("fs"),J=(await import("path")).dirname(this.logFilePath);if(!Z.existsSync(J))Z.mkdirSync(J,{recursive:!0});await this.rotateIfNeeded(Z);let Q=`${this.formatEntry($)}
|
|
@@ -1618,14 +1618,14 @@ ${z}
|
|
|
1618
1618
|
customElements.define('${Z}', ${G});
|
|
1619
1619
|
`}async function E8($,Z,Y,J){if(Z.length<1)return e("WebComponent","@webcomponent directive requires at least the tag name parameter",s.INVALID_DIRECTIVE_SYNTAX);let Q=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[D5.join(D5.dirname(J),G,`${Q}.stx`),D5.join(process.cwd(),G,`${Q}.stx`),D5.join(D5.dirname(J),`${Q}.stx`)],q=null;for(let U of K)if(await n(U)){q=await Bun.file(U).text();break}if(!q)return e("WebComponent",`Component file not found: ${Q}.stx`,s.FILE_NOT_FOUND);let W=aG(q,Q);return`<script type="module">
|
|
1620
1620
|
${tG(W)}
|
|
1621
|
-
</script>`}var k8=S(()=>{Z1();A0()});var b8={};r(b8,{timingPlugin:()=>JK,pluginManager:()=>eG,definePlugin:()=>P4,debugPlugin:()=>YK,createVariablesPlugin:()=>XK,createFilterPlugin:()=>ZK,createDirectivePlugin:()=>$K,PluginManager:()=>I7});function P4($){return $}class I7{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 Q=J[$];if(Q)try{let X=await Q(Y);if(X){if(X.template!==void 0)Y.template=X.template;if(X.context)Y.context={...Y.context,...X.context};if(X.metadata)Y.metadata={...Y.metadata,...X.metadata};if(X.skip)break}}catch(X){console.error(`Error in plugin "${J.name}" ${$} hook:`,X)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let Q of this.sortedPlugins){let X=Q[$];if(X)try{let G=await X(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 "${Q.name}" ${$} hook:`,G)}}return J}}function $K($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function ZK($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function XK($){return P4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var eG,YK,JK;var S8=S(()=>{eG=new I7;YK=P4({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)}}),JK=P4({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 C8={};r(C8,{validateConfig:()=>qK,loadStxConfig:()=>S1,defineStxConfig:()=>KK,defaultConfig:()=>b1,config:()=>E7});import D7 from"fs";import D0 from"path";import{loadConfigWithResult as QK}from"bunfig";function GK($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=D0.join(process.cwd(),"resources","views"),Q=D0.join(process.cwd(),"resources","layouts");if(D7.existsSync(J)&&D7.existsSync(Q))return{root:"resources",pagesDir:"views"};let X=D0.join(process.cwd(),"resources","views","pages");if(D7.existsSync(X))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function S1($){if(!$){if(r1)return r1;if(v4)return v4}let Z=$?D0.resolve($):process.cwd(),Y=y8.get(Z);if(Y)return Y;let J=(async()=>{let X=(await QK({name:"stx",alias:"ui",cwd:Z,defaultConfig:b1,verbose:!1})).config,G=GK(X.root,X.pagesDir);if(X.root=G.root,X.pagesDir=G.pagesDir,X.root&&X.root!=="."){let K=X.root;if(X.partialsDir&&!D0.isAbsolute(X.partialsDir))X.partialsDir=D0.join(K,X.partialsDir);if(X.componentsDir&&!D0.isAbsolute(X.componentsDir))X.componentsDir=D0.join(K,X.componentsDir);if(X.layoutsDir&&!D0.isAbsolute(X.layoutsDir))X.layoutsDir=D0.join(K,X.layoutsDir)}if(X.plugins&&X.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (S8(),b8)),q=[],W=[];for(let z of X.plugins){let U=typeof z==="string"?z:z[0],_=typeof z==="string"?{}:z[1]||{};try{let B,j;try{B=await import(U),j=D0.dirname(z0.resolve(U))}catch{let L=D0.resolve(process.cwd(),U);B=await import(L),j=D0.dirname(L)}let H=B.default||B;if(K.register(H,X),H.components){let L=D0.resolve(j,H.components);q.push(L)}if(H.pages){let L=D0.resolve(j,H.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{X.customDirectives=X.customDirectives||[],X.customDirectives.push(F)},addRoute:(F,O)=>{X.apiRoutes=X.apiRoutes||{},X.apiRoutes[F]=O},addMiddleware:(F)=>{X.middleware=X.middleware||[],X.middleware.push(F)},pluginDir:j,config:X};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(B){console.warn(`[stx] Failed to load plugin ${U}:`,B.message)}}X._pluginComponentDirs=q,X._pluginPageDirs=W}return X})();if(y8.set(Z,J),!$)v4=J,J.then((Q)=>{r1=Q}).catch(()=>{});return J}function KK($){return $}function qK($){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,Q)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,Q)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let 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((Q,X)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${X}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(Q.strategy))Z.push({path:`pwa.routes[${X}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${X}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${X}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((X)=>!J.includes(X)).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 b1,r1=null,y8,v4=null,E7;var a1=S(()=>{R$();T$();M$();I$();u$();p9();V7();H8();M7();k8();b1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:H9,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:E8,hasEndTag:!1,description:"Include a web component in the template"},q6,z6,I8,D8,W6,_6,B6,U6,L6,w6,u9,F7,...j8],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}};y8=new Map;E7=new Proxy(b1,{get($,Z){if(r1&&Z in r1)return r1[Z];if(!v4)S1().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var g8={};r(g8,{resetCssCache:()=>jK,resetCrosswindCache:()=>HK,rebuildCrosswindCSS:()=>OK,loadCrosswindConfig:()=>C7,loadCrosswind:()=>y7,injectCrosswindCSS:()=>k5,getCachedCSS:()=>LK,generateCrosswindCSS:()=>f8,extractClassNames:()=>x8,buildCrosswindCSS:()=>v8});import $0 from"path";import{hasLocalConfig as zK}from"bunfig/discovery";function S7($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function k7($,Z){if(Y1.has($))Y1.delete($);else if(Y1.size>=WK)Y1.delete(Y1.keys().next().value);Y1.set($,Z)}async function UK($){if(!K1)return null;try{let Z=Bun.file($0.join(K1,`cw-${S7($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function _K($,Z){if(!K1)return;try{if(!fs.existsSync(K1))fs.mkdirSync(K1,{recursive:!0});await Bun.write($0.join(K1,`cw-${S7($)}.css`),Z)}catch{}}async function P8($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function BK(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==$0.dirname(Y))$.push($0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push($0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push($0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push($0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push($0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push($0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=$0.dirname(Y);if(Z){let J=[$0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),$0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),$0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),$0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),$0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),$0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...J)}return $.push($0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push($0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function y7(){if(b7)return e1;b7=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let J=await P8(Y);if(J){if(e1=J,!process.env.STACKS_DEV_QUIET)console.log(`${B0.green}[Crosswind]${B0.reset} CSS engine loaded`);return e1}}let Z=BK();for(let Y of Z)if(await Bun.file(Y).exists()){let J=await P8(Y);if(J){if(e1=J,!process.env.STACKS_DEV_QUIET)console.log(`${B0.green}[Crosswind]${B0.reset} CSS engine loaded from ${$0.dirname($0.dirname(Y))}`);return e1}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${B0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${B0.reset}`),console.warn(`${B0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${B0.reset}`),null}}function jK(){Y1.clear()}function HK(){e1=null,b7=!1,c0=null,E5="",Y1.clear(),x4=null}async function C7($){try{if(!zK({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=$0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${B0.green}[Crosswind]${B0.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${B0.yellow}[Crosswind]${B0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function v8($){if(t1)return E5;t1=!0;try{let Z=await y7();if(!Z||!Z.build)return t1=!1,"";if(!c0)c0=await C7($);if(!c0)return t1=!1,"";let Y=Z.defaultConfig?.theme||{},J=c0.theme||{},Q={...Z.defaultConfig,...c0,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},X=performance.now(),G=await Z.build(Q),K=performance.now()-X;if(E5=G.css,console.log(`${B0.cyan}[Crosswind]${B0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),Q.output){let q=$0.isAbsolute(Q.output)?Q.output:$0.join($,Q.output),W=$0.dirname(q);if(!fs.existsSync(W))fs.mkdirSync(W,{recursive:!0});await Bun.write(q,G.css)}return t1=!1,G.css}catch(Z){return console.error(`${B0.red}[Crosswind]${B0.reset} Build error:`,Z),t1=!1,E5}}async function OK($){c0=null,await v8($)}function LK(){return E5}function x8($){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 Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,X=Q.exec($);while(X!==null){let G=X[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}X=Q.exec($)}return Z}async function f8($,Z){try{let Y=await y7();if(!Y)return"";let J=x8($);if(J.size===0)return"";let Q=Z?$0.resolve(Z):process.cwd();if(!K1)K1=$0.join(Q,".stx/cache");let X=[...J].sort().join(" "),G=`${x4||"default"}::${X}`,K=Y1.get(G);if(K!==void 0)return k7(G,K),K;let q=await UK(G);if(q!==null)return k7(G,q),q;if(!c0){let A=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (a1(),C8)),R=await N(Q);if(R.css)if(typeof R.css==="string"){let T=$0.isAbsolute(R.css)?R.css:$0.resolve(Q,R.css);if(await Bun.file(T).exists()){let M=await import(T);A=M.default||M,console.log(`${B0.green}[Crosswind]${B0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=$0.isAbsolute(R.css.config)?R.css.config:$0.resolve(Q,R.css.config);if(await Bun.file(T).exists()){let M=await import(T);A={...M.default||M,...A}}}console.log(`${B0.green}[Crosswind]${B0.reset} Using inline CSS config from stx.config.ts`)}}catch{}c0=A||await C7(Q);try{x4=S7(JSON.stringify(c0??{}))}catch{x4="unhashable"}}let W=Y.defaultConfig||Y.config,z=c0||{},U=W.theme||{},B=(z.theme||{}).extend||{},j={...U};if(Object.keys(B).length>0)j.extend=B;let H=[...W.safelist||[],...z.safelist||[]],L={...W,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of J)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||z.shortcuts||{};for(let[A,N]of Object.entries(V)){if(!J.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean);for(let T of R)F.generate(T)}O=F.toCSS(!0,!1);let w=O.split(`
|
|
1621
|
+
</script>`}var k8=S(()=>{Z1();A0()});var b8={};r(b8,{timingPlugin:()=>JK,pluginManager:()=>eG,definePlugin:()=>P4,debugPlugin:()=>YK,createVariablesPlugin:()=>XK,createFilterPlugin:()=>ZK,createDirectivePlugin:()=>$K,PluginManager:()=>I7});function P4($){return $}class I7{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 Q=J[$];if(Q)try{let X=await Q(Y);if(X){if(X.template!==void 0)Y.template=X.template;if(X.context)Y.context={...Y.context,...X.context};if(X.metadata)Y.metadata={...Y.metadata,...X.metadata};if(X.skip)break}}catch(X){console.error(`Error in plugin "${J.name}" ${$} hook:`,X)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let Q of this.sortedPlugins){let X=Q[$];if(X)try{let G=await X(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 "${Q.name}" ${$} hook:`,G)}}return J}}function $K($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function ZK($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function XK($){return P4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var eG,YK,JK;var S8=S(()=>{eG=new I7;YK=P4({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)}}),JK=P4({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 C8={};r(C8,{validateConfig:()=>qK,loadStxConfig:()=>b1,defineStxConfig:()=>KK,defaultConfig:()=>k1,config:()=>E7});import D7 from"fs";import D0 from"path";import{loadConfigWithResult as QK}from"bunfig";function GK($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=D0.join(process.cwd(),"resources","views"),Q=D0.join(process.cwd(),"resources","layouts");if(D7.existsSync(J)&&D7.existsSync(Q))return{root:"resources",pagesDir:"views"};let X=D0.join(process.cwd(),"resources","views","pages");if(D7.existsSync(X))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function b1($){if(!$){if(s1)return s1;if(v4)return v4}let Z=$?D0.resolve($):process.cwd(),Y=y8.get(Z);if(Y)return Y;let J=(async()=>{let X=(await QK({name:"stx",alias:"ui",cwd:Z,defaultConfig:k1,verbose:!1})).config,G=GK(X.root,X.pagesDir);if(X.root=G.root,X.pagesDir=G.pagesDir,X.root&&X.root!=="."){let K=X.root;if(X.partialsDir&&!D0.isAbsolute(X.partialsDir))X.partialsDir=D0.join(K,X.partialsDir);if(X.componentsDir&&!D0.isAbsolute(X.componentsDir))X.componentsDir=D0.join(K,X.componentsDir);if(X.layoutsDir&&!D0.isAbsolute(X.layoutsDir))X.layoutsDir=D0.join(K,X.layoutsDir)}if(X.plugins&&X.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (S8(),b8)),q=[],W=[];for(let z of X.plugins){let U=typeof z==="string"?z:z[0],_=typeof z==="string"?{}:z[1]||{};try{let B,j;try{B=await import(U),j=D0.dirname(z0.resolve(U))}catch{let L=D0.resolve(process.cwd(),U);B=await import(L),j=D0.dirname(L)}let H=B.default||B;if(K.register(H,X),H.components){let L=D0.resolve(j,H.components);q.push(L)}if(H.pages){let L=D0.resolve(j,H.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{X.customDirectives=X.customDirectives||[],X.customDirectives.push(F)},addRoute:(F,O)=>{X.apiRoutes=X.apiRoutes||{},X.apiRoutes[F]=O},addMiddleware:(F)=>{X.middleware=X.middleware||[],X.middleware.push(F)},pluginDir:j,config:X};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(B){console.warn(`[stx] Failed to load plugin ${U}:`,B.message)}}X._pluginComponentDirs=q,X._pluginPageDirs=W}return X})();if(y8.set(Z,J),!$)v4=J,J.then((Q)=>{s1=Q}).catch(()=>{});return J}function KK($){return $}function qK($){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,Q)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,Q)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let 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((Q,X)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${X}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(Q.strategy))Z.push({path:`pwa.routes[${X}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${X}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${X}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((X)=>!J.includes(X)).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 k1,s1=null,y8,v4=null,E7;var r1=S(()=>{R$();T$();M$();I$();u$();p9();V7();H8();M7();k8();k1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:H9,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:E8,hasEndTag:!1,description:"Include a web component in the template"},q6,z6,I8,D8,W6,_6,B6,U6,L6,w6,u9,F7,...j8],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}};y8=new Map;E7=new Proxy(k1,{get($,Z){if(s1&&Z in s1)return s1[Z];if(!v4)b1().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var g8={};r(g8,{resetCssCache:()=>jK,resetCrosswindCache:()=>HK,rebuildCrosswindCSS:()=>OK,loadCrosswindConfig:()=>C7,loadCrosswind:()=>y7,injectCrosswindCSS:()=>k5,getCachedCSS:()=>LK,generateCrosswindCSS:()=>f8,extractClassNames:()=>x8,buildCrosswindCSS:()=>v8});import $0 from"path";import{hasLocalConfig as zK}from"bunfig/discovery";function S7($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function k7($,Z){if(Y1.has($))Y1.delete($);else if(Y1.size>=WK)Y1.delete(Y1.keys().next().value);Y1.set($,Z)}async function UK($){if(!K1)return null;try{let Z=Bun.file($0.join(K1,`cw-${S7($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function _K($,Z){if(!K1)return;try{if(!fs.existsSync(K1))fs.mkdirSync(K1,{recursive:!0});await Bun.write($0.join(K1,`cw-${S7($)}.css`),Z)}catch{}}async function P8($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function BK(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==$0.dirname(Y))$.push($0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push($0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push($0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push($0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push($0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push($0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=$0.dirname(Y);if(Z){let J=[$0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),$0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),$0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),$0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),$0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),$0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...J)}return $.push($0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push($0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function y7(){if(b7)return t1;b7=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let J=await P8(Y);if(J){if(t1=J,!process.env.STACKS_DEV_QUIET)console.log(`${B0.green}[Crosswind]${B0.reset} CSS engine loaded`);return t1}}let Z=BK();for(let Y of Z)if(await Bun.file(Y).exists()){let J=await P8(Y);if(J){if(t1=J,!process.env.STACKS_DEV_QUIET)console.log(`${B0.green}[Crosswind]${B0.reset} CSS engine loaded from ${$0.dirname($0.dirname(Y))}`);return t1}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${B0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${B0.reset}`),console.warn(`${B0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${B0.reset}`),null}}function jK(){Y1.clear()}function HK(){t1=null,b7=!1,c0=null,E5="",Y1.clear(),x4=null}async function C7($){try{if(!zK({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=$0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${B0.green}[Crosswind]${B0.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${B0.yellow}[Crosswind]${B0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function v8($){if(a1)return E5;a1=!0;try{let Z=await y7();if(!Z||!Z.build)return a1=!1,"";if(!c0)c0=await C7($);if(!c0)return a1=!1,"";let Y=Z.defaultConfig?.theme||{},J=c0.theme||{},Q={...Z.defaultConfig,...c0,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},X=performance.now(),G=await Z.build(Q),K=performance.now()-X;if(E5=G.css,console.log(`${B0.cyan}[Crosswind]${B0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),Q.output){let q=$0.isAbsolute(Q.output)?Q.output:$0.join($,Q.output),W=$0.dirname(q);if(!fs.existsSync(W))fs.mkdirSync(W,{recursive:!0});await Bun.write(q,G.css)}return a1=!1,G.css}catch(Z){return console.error(`${B0.red}[Crosswind]${B0.reset} Build error:`,Z),a1=!1,E5}}async function OK($){c0=null,await v8($)}function LK(){return E5}function x8($){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 Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,X=Q.exec($);while(X!==null){let G=X[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}X=Q.exec($)}return Z}async function f8($,Z){try{let Y=await y7();if(!Y)return"";let J=x8($);if(J.size===0)return"";let Q=Z?$0.resolve(Z):process.cwd();if(!K1)K1=$0.join(Q,".stx/cache");let X=[...J].sort().join(" "),G=`${x4||"default"}::${X}`,K=Y1.get(G);if(K!==void 0)return k7(G,K),K;let q=await UK(G);if(q!==null)return k7(G,q),q;if(!c0){let A=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (r1(),C8)),R=await N(Q);if(R.css)if(typeof R.css==="string"){let T=$0.isAbsolute(R.css)?R.css:$0.resolve(Q,R.css);if(await Bun.file(T).exists()){let M=await import(T);A=M.default||M,console.log(`${B0.green}[Crosswind]${B0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=$0.isAbsolute(R.css.config)?R.css.config:$0.resolve(Q,R.css.config);if(await Bun.file(T).exists()){let M=await import(T);A={...M.default||M,...A}}}console.log(`${B0.green}[Crosswind]${B0.reset} Using inline CSS config from stx.config.ts`)}}catch{}c0=A||await C7(Q);try{x4=S7(JSON.stringify(c0??{}))}catch{x4="unhashable"}}let W=Y.defaultConfig||Y.config,z=c0||{},U=W.theme||{},B=(z.theme||{}).extend||{},j={...U};if(Object.keys(B).length>0)j.extend=B;let H=[...W.safelist||[],...z.safelist||[]],L={...W,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of J)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||z.shortcuts||{};for(let[A,N]of Object.entries(V)){if(!J.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean);for(let T of R)F.generate(T)}O=F.toCSS(!0,!1);let w=O.split(`
|
|
1622
1622
|
`);for(let[A,N]of Object.entries(V)){if(!J.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean),T=[],M=[];for(let I of R){let D=I.startsWith("dark:"),b=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let k=0;k<w.length;k++){let y=w[k].trim();if(y===`${b} {`||y.startsWith(`${b} {`)){let g=k,h="";while(g<w.length){if(h+=w[g],w[g].includes("}"))break;g++}let m=h.match(/\{([^}]+)\}/);if(m)if(D)M.push(m[1].trim());else T.push(m[1].trim());break}}}if(T.length)O+=`
|
|
1623
1623
|
.${A} { ${T.join(" ")} }`;if(M.length)O+=`
|
|
1624
1624
|
@media (prefers-color-scheme: dark) { .dark .${A} { ${M.join(" ")} } }`}return k7(G,O),_K(G,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function k5($,Z){let Y=await f8($,Z);if(!Y)return $;let J=`<style data-crosswind="generated">
|
|
1625
1625
|
${Y}
|
|
1626
1626
|
</style>`,Q=/<style data-crosswind="generated">[\s\S]*?<\/style>/g;if(Q.test($)){let X=!1;return $.replace(Q,()=>{if(X)return"";return X=!0,J})}if($.includes("</head>"))return $.replace("</head>",`${J}
|
|
1627
1627
|
</head>`);if($.includes("<body"))return $.replace(/<body([^>]*)>/,`<body$1>
|
|
1628
|
-
${J}`);return J+$}var
|
|
1628
|
+
${J}`);return J+$}var t1=null,b7=!1,c0=null,E5="",a1=!1,WK=256,Y1,K1=null,x4=null;var f4=S(()=>{G6();Y1=new Map});function h8(){return`
|
|
1629
1629
|
// STX Lifecycle Runtime
|
|
1630
1630
|
(function() {
|
|
1631
1631
|
if (typeof window === 'undefined') return;
|
|
@@ -2510,11 +2510,11 @@ window.__stx_reactive = (function() {
|
|
|
2510
2510
|
${hK()}
|
|
2511
2511
|
${Y}
|
|
2512
2512
|
</script>`}function JZ($,Z,Y){if(YZ=0,!uK($))return $;let J=vK($);if(J.length===0)return $;let Q=mK($,J),X=dK(J,Z),G=Q.lastIndexOf("</body>");if(G!==-1)Q=Q.slice(0,G)+X+`
|
|
2513
|
-
`+Q.slice(G);else Q+=X;return Q}function mK($,Z){let Y=$;for(let J of Z){let X=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${g4(J.stateExpr)}["']`,"gi").exec(Y);if(X)J.id=X[1],J.selector=`[data-stx-scope="${J.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${g4(J.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)J.id=K[1],J.selector=`[data-stx-scope="${J.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${g4(J.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${J.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${g4(J.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${J.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function uK($){return/x-data\s*=\s*["']/.test($)}var YZ=0,PK=0;var XZ=S(()=>{r0()});import pK from"fs";import v7 from"path";import{createHighlighter as lK}from"ts-syntax-highlighter";async function cK($,Z={}){try{if(!await n($))throw Error(`Markdown file not found: ${$}`);let J=(await pK.promises.stat($)).mtime.getTime();if(Z.cache&&x7.has($)){let U=x7.get($);if(U.updatedAt>=J)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:X,content:G}=N6(Q),K=Z.markdown||E7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=W5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await iK(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:W,data:X||{}};if(Z.cache)x7.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:K0("Markdown File",`Error reading/parsing markdown file: ${J}`,$,"",0,""),data:{}}}}async function iK($,Z,Y){let J=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!h4)try{h4=await lK({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,q,W,z)=>{let U=z.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!h4.getSupportedLanguages().includes(_))return K;return(await h4.highlight(U,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},X=$,G=$.matchAll(J);for(let K of G){let[q,W,z,U]=K,_=await Q(q,W,z,U);X=X.replace(q,_)}return X}async function QZ($,Z,Y="",J={}){return await nK($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,W)=>{try{let z=K;if(!v7.isAbsolute(K))z=v7.resolve(v7.dirname(Y),K);let U={};if(q)try{try{U=JSON.parse(q)}catch{if(J.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),T=N.startsWith("'")&&N.endsWith("'");if(R||T)N=N.substring(1,N.length-1);U[A]=N}}}}catch(F){if(J.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await cK(z,J),j={...Z,...B,...U},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(z){let U=z instanceof Error?z.message:String(z);return K0("Markdown File",`Error including markdown file: ${U}`,Y,$,W,G)}})}async function nK($,Z,Y){let J=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],q=Q.index,W=Q;J.push(Y(...W).then((z)=>({match:K,replacement:z,index:q})))}let X=await Promise.all(J);X.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of X)G=G.replace(K,()=>q);return G}var x7,h4=null;var GZ=S(()=>{a1();A0();x7=new Map});function q1($,Z){try{let Y=$.trim();if(Q0(Y))return G0(Y,Object.keys(Z))(...Object.values(Z));else return Y0(Y,Z)}catch{return!1}}var KZ=S(()=>{R0()});function z1($,Z){let Y=oK($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function oK($,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 y1($,Z,Y,J){let Q=1,X=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(X<$.length&&Q>0){G.lastIndex=X,K.lastIndex=X;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)Q++,X=z+q[0].length;else if(U<1/0){if(Q--,Q===0)return U;X=U+W[0].length}else break}return-1}function qZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,Q=z1($,J);if(!Q)return null;let X=Q.endPos,G=y1($,"if","endif",X);if(G===-1)return null;let K=$.slice(X,G),q=[],W=0,z="if",U=Q.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:X+_,end:X+W});let F=W+L[0].length,O=z1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:X+_,end:X+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:X+_,end:X+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function b5($){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 X=qZ($,J.index);if(X)Z.push(X),Y.lastIndex=X.end;J=Y.exec($)}return Z}function d4($,Z,Y){let J=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),X=Q.exec($);while(X!==null){if(J.some((H)=>X.index>H.start&&X.index<H.end)){X=Q.exec($);continue}let K=X.index,q=K+X[0].length-1,W=S0($,"(",")",q);if(W===-1){X=Q.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=y1($,Z,Y,U);if(_===-1){X=Q.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),Q.lastIndex=j,X=Q.exec($)}return J}function f7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,Q=z1($,J);if(!Q)return null;let X=Q.endPos,G=y1($,"switch","endswitch",X);if(G===-1)return null;let K=$.slice(X,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=z1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:q,start:Z,end:G+10}}var zZ=()=>{};var WZ=()=>{};var m4=S(()=>{zZ();WZ()});function tK($,Z,Y){let J=$,Q=!0;while(Q){Q=!1;let X=J.match(/@switch\s*\(/);if(!X||X.index===void 0)break;let G=X.index,K=f7(J,G);if(!K)break;try{let q;if(Q0(K.expression))q=G0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Y0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&Q0(U.value))_=G0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Y0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+W+J.substring(K.end),Q=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=e("Switch",`Error evaluating @switch expression: ${W}`,s.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function C1($,Z,Y){let J=$;J=tK(J,Z,Y);{let X=!0;while(X){X=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=z1(J,K+7);if(!q)break;let W=q.endPos,z=y1(J,"unless","endunless",W);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 U=J.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){B=A.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;J=J.substring(0,K)+j+J.substring(z+10),X=!0}}J=h7(J,Z,Y),J=d7(J,Z,Y),J=g7(J,Z);let Q=()=>{let X=b5(J);if(X.length===0)return!1;for(let G=X.length-1;G>=0;G--){let K=X[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&Q0(z.condition))U=G0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Y0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=e(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,s.EVALUATION_ERROR),W=!0}}J=J.substring(0,K.start)+q+J.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=e("If",`Error processing @if block: ${W}`,s.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let X=J;if(!Q())break;if(J===X)break}return J}function UZ($){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 Q=$[Z];if(Q==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}J.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function g7($,Z){let Y=$;function J(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function Q(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=UZ(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=J(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?q1(`auth?.check && auth?.user?.[${z}]`,Z):q1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=UZ(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=J(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?q1(`!auth?.check || !auth?.user?.[${z}]`,Z):q1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function X(K,q,W){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(q)z.push(q);if(W){let U=q1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=J(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${q}(?![a-z])`,"g"),N=new RegExp(`@${W}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((k,y)=>k.pos-y.pos);for(let k of T){if(k.type==="open"){V++;continue}if(k.type==="close"){V--;continue}if(V===0)O.push(k)}let I=[],D=0;for(let k=0;k<O.length;k++){let y=O[k];if(I.push({content:F.slice(D,y.pos),ability:void 0}),y.type==="elseDirective"){let g=F.slice(y.pos+`@${W}`.length),h=G(g);if(h){I[I.length-1]={content:F.slice(D,y.pos)},D=y.pos+`@${W}`.length+h.paramsEnd,I.push({content:"",ability:h.ability,type:h.type,id:h.id}),I.pop();let m=O[k+1],i=m?m.pos:F.length;I.push({content:F.slice(D,i),ability:h.ability,type:h.type,id:h.id}),D=i}}else D=y.pos+5}if(D<F.length){let k=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=X(j.ability,j.type,j.id),P=K==="can"?E:!E,b="";if(P)b=I[0]?.content||"";else{let k=!1;for(let y=1;y<I.length;y++){let g=I[y];if(g.isFinalElse){b=g.content,k=!0;break}if(g.ability){let h=X(g.ability,g.type,g.id);if(K==="can"?h:!h){b=g.content,k=!0;break}}}if(!k&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),z=!0}}return Y}function h7($,Z,Y){let J=$;function Q(X,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=X.match(U);if(!_||_.index===void 0)break;let B=_.index,j=z1(X,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=y1(X,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=X.slice(H,L),O=j.expression,V=-1,w=0,A=0;while(A<F.length){let N=F.indexOf("@",A);if(N===-1)break;let R=F.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=N;break}A=N+1}try{let N=q(O.trim()),R;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);R=N?T:M}else R=N?F:"";X=X.substring(0,B)+R+X.substring(L+`@${K}`.length),z=!0}catch(N){let R=N instanceof Error?N.message:String(N),T=e(W,`Error processing @${G} directive: ${R}`,s.EVALUATION_ERROR);X=X.substring(0,B)+T+X.substring(L+`@${K}`.length);break}}return X}return J=Q(J,"isset","endisset",(X)=>{let G=q1(X,Z);return G!==void 0&&G!==null},"Isset"),J=Q(J,"empty","endempty",(X)=>{let G=q1(X,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 d7($,Z,Y){let J=$,Q="development";function X(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=Q===E[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let E=z.exec(j),P=U.exec(j),b=E?E.index:1/0,k=P?P.index:1/0;if(b<k)V++,w=b+E[0].length;else if(k<1/0){if(V--,V===0){A=k;break}w=k+P[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let N=j.substring(O,A),R=-1,T=0,M=0;while(M<N.length){let E=N.indexOf("@",M);if(E===-1)break;let P=N.substring(E);if(_.test(P)){T++,M=E+1;continue}if(B.test(P)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(P)){R=E;break}M=E+1}let I;if(R!==-1){let E=N.slice(0,R),P=N.slice(R+5);I=W?E:P}else I=W?N:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(A+D),H=!0}return j}return J=X(J,"env","endenv",!1),J=X(J,"production","endproduction",Q==="production"),J=X(J,"development","enddevelopment",Q==="development"),J=X(J,"staging","endstaging",Q==="staging"),J=X(J,"testing","endtesting",Q==="testing"),J}var u4=S(()=>{KZ();Z1();m4();R0()});function BZ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function p4($,Z){if(!$)return Z?.nonceGenerator?.()??BZ();let Y=_Z.get($);if(!Y)Y=Z?.nonceGenerator?.()??BZ(),_Z.set($,Y);return Y}function eK($,Z){let Y=[];for(let[J,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(J);continue}if(Array.isArray(Q)){let X=[...Q];if(Z&&(J==="script-src"||J==="style-src"))X=X.filter((G)=>!G.startsWith("'nonce-")),X.push(`'nonce-${Z}'`);if(X.length>0)Y.push(`${J} ${X.join(" ")}`)}}return Y.join("; ")}function jZ($,Z){return`<meta http-equiv="Content-Security-Policy" content="${eK($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function HZ($,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?p4(Y,Z):void 0,Q=jZ(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
2514
|
-
${Q}`)}function OZ($,Z,Y,J){let Q=$,X=J.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!X?.enabled||!X.directives)return"<!-- CSP not configured -->";let G=X.useNonce?p4(Z,X):void 0;return jZ(X.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!X?.enabled||!X.useNonce)return"";return p4(Z,X)}),X?.enabled&&X.useNonce)Z.cspNonce=p4(Z,X);return Q}var _Z;var LZ=S(()=>{_Z=new WeakMap});import $q from"crypto";function Yq($=Zq){let Z=$q.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return m7=Z,Z}function Jq(){if(!m7)Yq();return m7}function Xq($=FZ){let Z=Jq();return`<input type="hidden" name="${$}" value="${Z}">`}function VZ($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,J)=>{return Xq(J||FZ)})}var Zq=40,FZ="_token",m7=null;var wZ=()=>{};async function AZ($,Z,Y,J){if(!J.customDirectives||J.customDirectives.length===0)return $;let Q=$;for(let X of J.customDirectives){if(!X.name||typeof X.handler!=="function"){if(J.debug)console.warn("Invalid custom directive:",X);continue}if(X.hasEndTag)Q=await Qq(Q,X,Z,Y,J);else Q=await Gq(Q,X,Z,Y,J)}return Q}async function Qq($,Z,Y,J,Q){let{name:X,handler:G}=Z,K=`@${X}`,q=`@end${X}`,W=$,z=
|
|
2513
|
+
`+Q.slice(G);else Q+=X;return Q}function mK($,Z){let Y=$;for(let J of Z){let X=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${g4(J.stateExpr)}["']`,"gi").exec(Y);if(X)J.id=X[1],J.selector=`[data-stx-scope="${J.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${g4(J.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)J.id=K[1],J.selector=`[data-stx-scope="${J.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${g4(J.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${J.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${g4(J.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${J.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function uK($){return/x-data\s*=\s*["']/.test($)}var YZ=0,PK=0;var XZ=S(()=>{r0()});import pK from"fs";import v7 from"path";import{createHighlighter as lK}from"ts-syntax-highlighter";async function cK($,Z={}){try{if(!await n($))throw Error(`Markdown file not found: ${$}`);let J=(await pK.promises.stat($)).mtime.getTime();if(Z.cache&&x7.has($)){let U=x7.get($);if(U.updatedAt>=J)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:X,content:G}=N6(Q),K=Z.markdown||E7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=W5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await iK(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:W,data:X||{}};if(Z.cache)x7.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:K0("Markdown File",`Error reading/parsing markdown file: ${J}`,$,"",0,""),data:{}}}}async function iK($,Z,Y){let J=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!h4)try{h4=await lK({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,q,W,z)=>{let U=z.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!h4.getSupportedLanguages().includes(_))return K;return(await h4.highlight(U,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},X=$,G=$.matchAll(J);for(let K of G){let[q,W,z,U]=K,_=await Q(q,W,z,U);X=X.replace(q,_)}return X}async function QZ($,Z,Y="",J={}){return await nK($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,W)=>{try{let z=K;if(!v7.isAbsolute(K))z=v7.resolve(v7.dirname(Y),K);let U={};if(q)try{try{U=JSON.parse(q)}catch{if(J.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),T=N.startsWith("'")&&N.endsWith("'");if(R||T)N=N.substring(1,N.length-1);U[A]=N}}}}catch(F){if(J.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await cK(z,J),j={...Z,...B,...U},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(z){let U=z instanceof Error?z.message:String(z);return K0("Markdown File",`Error including markdown file: ${U}`,Y,$,W,G)}})}async function nK($,Z,Y){let J=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],q=Q.index,W=Q;J.push(Y(...W).then((z)=>({match:K,replacement:z,index:q})))}let X=await Promise.all(J);X.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of X)G=G.replace(K,()=>q);return G}var x7,h4=null;var GZ=S(()=>{r1();A0();x7=new Map});function q1($,Z){try{let Y=$.trim();if(Q0(Y))return G0(Y,Object.keys(Z))(...Object.values(Z));else return Y0(Y,Z)}catch{return!1}}var KZ=S(()=>{R0()});function z1($,Z){let Y=oK($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function oK($,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 S1($,Z,Y,J){let Q=1,X=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(X<$.length&&Q>0){G.lastIndex=X,K.lastIndex=X;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)Q++,X=z+q[0].length;else if(U<1/0){if(Q--,Q===0)return U;X=U+W[0].length}else break}return-1}function qZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,Q=z1($,J);if(!Q)return null;let X=Q.endPos,G=S1($,"if","endif",X);if(G===-1)return null;let K=$.slice(X,G),q=[],W=0,z="if",U=Q.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:X+_,end:X+W});let F=W+L[0].length,O=z1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:X+_,end:X+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:X+_,end:X+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function b5($){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 X=qZ($,J.index);if(X)Z.push(X),Y.lastIndex=X.end;J=Y.exec($)}return Z}function d4($,Z,Y){let J=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),X=Q.exec($);while(X!==null){if(J.some((H)=>X.index>H.start&&X.index<H.end)){X=Q.exec($);continue}let K=X.index,q=K+X[0].length-1,W=S0($,"(",")",q);if(W===-1){X=Q.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=S1($,Z,Y,U);if(_===-1){X=Q.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),Q.lastIndex=j,X=Q.exec($)}return J}function f7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,Q=z1($,J);if(!Q)return null;let X=Q.endPos,G=S1($,"switch","endswitch",X);if(G===-1)return null;let K=$.slice(X,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=z1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:q,start:Z,end:G+10}}var zZ=()=>{};var WZ=()=>{};var m4=S(()=>{zZ();WZ()});function tK($,Z,Y){let J=$,Q=!0;while(Q){Q=!1;let X=J.match(/@switch\s*\(/);if(!X||X.index===void 0)break;let G=X.index,K=f7(J,G);if(!K)break;try{let q;if(Q0(K.expression))q=G0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Y0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&Q0(U.value))_=G0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Y0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+W+J.substring(K.end),Q=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=e("Switch",`Error evaluating @switch expression: ${W}`,s.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function y1($,Z,Y){let J=$;J=tK(J,Z,Y);{let X=!0;while(X){X=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=z1(J,K+7);if(!q)break;let W=q.endPos,z=S1(J,"unless","endunless",W);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 U=J.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){B=A.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;J=J.substring(0,K)+j+J.substring(z+10),X=!0}}J=h7(J,Z,Y),J=d7(J,Z,Y),J=g7(J,Z);let Q=()=>{let X=b5(J);if(X.length===0)return!1;for(let G=X.length-1;G>=0;G--){let K=X[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&Q0(z.condition))U=G0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Y0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=e(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,s.EVALUATION_ERROR),W=!0}}J=J.substring(0,K.start)+q+J.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=e("If",`Error processing @if block: ${W}`,s.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let X=J;if(!Q())break;if(J===X)break}return J}function UZ($){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 Q=$[Z];if(Q==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}J.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function g7($,Z){let Y=$;function J(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function Q(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=UZ(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=J(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?q1(`auth?.check && auth?.user?.[${z}]`,Z):q1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=UZ(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=J(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?q1(`!auth?.check || !auth?.user?.[${z}]`,Z):q1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function X(K,q,W){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(q)z.push(q);if(W){let U=q1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=J(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${q}(?![a-z])`,"g"),N=new RegExp(`@${W}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((k,y)=>k.pos-y.pos);for(let k of T){if(k.type==="open"){V++;continue}if(k.type==="close"){V--;continue}if(V===0)O.push(k)}let I=[],D=0;for(let k=0;k<O.length;k++){let y=O[k];if(I.push({content:F.slice(D,y.pos),ability:void 0}),y.type==="elseDirective"){let g=F.slice(y.pos+`@${W}`.length),h=G(g);if(h){I[I.length-1]={content:F.slice(D,y.pos)},D=y.pos+`@${W}`.length+h.paramsEnd,I.push({content:"",ability:h.ability,type:h.type,id:h.id}),I.pop();let m=O[k+1],i=m?m.pos:F.length;I.push({content:F.slice(D,i),ability:h.ability,type:h.type,id:h.id}),D=i}}else D=y.pos+5}if(D<F.length){let k=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=X(j.ability,j.type,j.id),P=K==="can"?E:!E,b="";if(P)b=I[0]?.content||"";else{let k=!1;for(let y=1;y<I.length;y++){let g=I[y];if(g.isFinalElse){b=g.content,k=!0;break}if(g.ability){let h=X(g.ability,g.type,g.id);if(K==="can"?h:!h){b=g.content,k=!0;break}}}if(!k&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),z=!0}}return Y}function h7($,Z,Y){let J=$;function Q(X,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=X.match(U);if(!_||_.index===void 0)break;let B=_.index,j=z1(X,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=S1(X,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=X.slice(H,L),O=j.expression,V=-1,w=0,A=0;while(A<F.length){let N=F.indexOf("@",A);if(N===-1)break;let R=F.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=N;break}A=N+1}try{let N=q(O.trim()),R;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);R=N?T:M}else R=N?F:"";X=X.substring(0,B)+R+X.substring(L+`@${K}`.length),z=!0}catch(N){let R=N instanceof Error?N.message:String(N),T=e(W,`Error processing @${G} directive: ${R}`,s.EVALUATION_ERROR);X=X.substring(0,B)+T+X.substring(L+`@${K}`.length);break}}return X}return J=Q(J,"isset","endisset",(X)=>{let G=q1(X,Z);return G!==void 0&&G!==null},"Isset"),J=Q(J,"empty","endempty",(X)=>{let G=q1(X,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 d7($,Z,Y){let J=$,Q="development";function X(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=Q===E[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let E=z.exec(j),P=U.exec(j),b=E?E.index:1/0,k=P?P.index:1/0;if(b<k)V++,w=b+E[0].length;else if(k<1/0){if(V--,V===0){A=k;break}w=k+P[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let N=j.substring(O,A),R=-1,T=0,M=0;while(M<N.length){let E=N.indexOf("@",M);if(E===-1)break;let P=N.substring(E);if(_.test(P)){T++,M=E+1;continue}if(B.test(P)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(P)){R=E;break}M=E+1}let I;if(R!==-1){let E=N.slice(0,R),P=N.slice(R+5);I=W?E:P}else I=W?N:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(A+D),H=!0}return j}return J=X(J,"env","endenv",!1),J=X(J,"production","endproduction",Q==="production"),J=X(J,"development","enddevelopment",Q==="development"),J=X(J,"staging","endstaging",Q==="staging"),J=X(J,"testing","endtesting",Q==="testing"),J}var u4=S(()=>{KZ();Z1();m4();R0()});function BZ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function p4($,Z){if(!$)return Z?.nonceGenerator?.()??BZ();let Y=_Z.get($);if(!Y)Y=Z?.nonceGenerator?.()??BZ(),_Z.set($,Y);return Y}function eK($,Z){let Y=[];for(let[J,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(J);continue}if(Array.isArray(Q)){let X=[...Q];if(Z&&(J==="script-src"||J==="style-src"))X=X.filter((G)=>!G.startsWith("'nonce-")),X.push(`'nonce-${Z}'`);if(X.length>0)Y.push(`${J} ${X.join(" ")}`)}}return Y.join("; ")}function jZ($,Z){return`<meta http-equiv="Content-Security-Policy" content="${eK($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function HZ($,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?p4(Y,Z):void 0,Q=jZ(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
2514
|
+
${Q}`)}function OZ($,Z,Y,J){let Q=$,X=J.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!X?.enabled||!X.directives)return"<!-- CSP not configured -->";let G=X.useNonce?p4(Z,X):void 0;return jZ(X.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!X?.enabled||!X.useNonce)return"";return p4(Z,X)}),X?.enabled&&X.useNonce)Z.cspNonce=p4(Z,X);return Q}var _Z;var LZ=S(()=>{_Z=new WeakMap});import $q from"crypto";function Yq($=Zq){let Z=$q.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return m7=Z,Z}function Jq(){if(!m7)Yq();return m7}function Xq($=FZ){let Z=Jq();return`<input type="hidden" name="${$}" value="${Z}">`}function VZ($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,J)=>{return Xq(J||FZ)})}var Zq=40,FZ="_token",m7=null;var wZ=()=>{};async function AZ($,Z,Y,J){if(!J.customDirectives||J.customDirectives.length===0)return $;let Q=$;for(let X of J.customDirectives){if(!X.name||typeof X.handler!=="function"){if(J.debug)console.warn("Invalid custom directive:",X);continue}if(X.hasEndTag)Q=await Qq(Q,X,Z,Y,J);else Q=await Gq(Q,X,Z,Y,J)}return Q}async function Qq($,Z,Y,J,Q){let{name:X,handler:G}=Z,K=`@${X}`,q=`@end${X}`,W=$,z=p1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),U=[],_=z.exec(W);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?NZ(j):[],O=H.trim(),V=await G(O,F,Y,J);U.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(Q.debug)console.error(`Error processing custom directive @${X}:`,F);U.push({original:B,processed:e("CustomDirective",`Error in @${X}${j?`(${j})`:""}: ${O}`,s.EVALUATION_ERROR),startIndex:L})}_=z.exec(W)}for(let B=U.length-1;B>=0;B--){let{original:j,processed:H}=U[B];W=W.replace(j,H)}return W}async function Gq($,Z,Y,J,Q){let{name:X,handler:G}=Z,K=$,q=p1(`@${X}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],z=q.exec(K);while(z!==null){let[B,j=""]=z,H=z.index||0;try{let L=NZ(j),F=await G("",L,Y,J);W.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(Q.debug)console.error(`Error processing custom directive @${X}:`,L);W.push({original:B,processed:e("CustomDirective",`Error in @${X}(${j}): ${F}`,s.EVALUATION_ERROR),startIndex:H})}z=q.exec(K)}let U=p1(`@${X}(?!\\w)(?!\\s*\\()`,"g"),_=U.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,J);W.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(Q.debug)console.error(`Error processing custom directive @${X}:`,H);W.push({original:B,processed:e("CustomDirective",`Error in @${X}: ${L}`,s.EVALUATION_ERROR),startIndex:j})}_=U.exec(K)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];K=K.replace(j,H)}return K}function NZ($){if(!$.trim())return[];let Z=[],Y="",J=!1,Q="";for(let X=0;X<$.length;X++){let G=$[X];if((G==='"'||G==="'")&&(X===0||$[X-1]!=="\\"))if(!J)J=!0,Q=G;else if(G===Q)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((X)=>{let G=X.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var RZ=S(()=>{Z1();l1()});import Kq from"crypto";function T0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function l4($,Z,Y,J){let Q=$||Z;return Y?`${Q} ${J}`:Q}function qq(){return Kq.randomUUID()}function c4($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let J=qq();Z.csrf={token:J}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${T0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(J,Q)=>{let X=Q.toUpperCase();if(Q&&!["GET","POST"].includes(X))return`<input type="hidden" name="_method" value="${T0(X)}">`;return J}),Y}function IZ($,Z,Y=MZ){let J=$;return J=J.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Q,X,G,K,q,W="")=>{let z=X||G||"POST",U=K||q||"",_=W1(W),B=z.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${T0(j)}" action="${T0(U)}"${_?` ${_}`:""}>`;if(H+=`
|
|
2515
2515
|
${c4("@csrf",Z)}`,!["GET","POST"].includes(B))H+=`
|
|
2516
2516
|
${c4(`@method('${B}')`,Z)}`;return H}),J=J.replace(/@endform/g,"</form>"),J=J.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(Q,X,G,K,q,W="")=>{let z=X||G||"",U=K||q||"",_=W1(W),B=S5(z,Z),j=B!==void 0&&B!==null?B:U||"",H=_.match(/type=['"]([^'"]+)['"]/i),L=H?H[1]:"text",F=y5(z,Z),O=_.match(/class=['"]([^'"]+)['"]/i),V=l4(O?O[1]:"",Y.input,F,Y.inputError),w=_.replace(/class=['"][^'"]+['"]/i,"");return w=w.replace(/type=['"][^'"]+['"]/i,""),`<input type="${T0(L)}" name="${T0(z)}" value="${T0(j)}" class="${V}"${w?` ${w}`:""}>`}),J=J.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(Q,X,G="",K="")=>{let q=W1(G),W=S5(X,Z)||K.trim(),z=y5(X,Z),U=q.match(/class=['"]([^'"]+)['"]/i),_=l4(U?U[1]:"",Y.input,z,Y.inputError),B=q.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${T0(X)}" class="${_}"${B?` ${B}`:""}>${T0(W)}</textarea>`}),J=J.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(Q,X,G="",K)=>{let q=W1(G),W=S5(X,Z),z=y5(X,Z),U=q.match(/class=['"]([^'"]+)['"]/i),_=l4(U?U[1]:"",Y.input,z,Y.inputError),B=q.replace(/class=['"][^'"]+['"]/i,""),j=K;if(W!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,L,F)=>{if((Array.isArray(W)?W.some((V)=>String(V)===F):String(W)===F)&&!L.includes("selected"))return L.replace(/(<option)/,"$1 selected");return H});return`<select name="${T0(X)}" class="${_}"${B?` ${B}`:""}>${j}</select>`}),J=J.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(Q,X,G="1",K="")=>{let q=W1(K),W=S5(X,Z),z=W!==void 0&&(Array.isArray(W)?W.some((j)=>String(j)===G):W===!0||String(W)===G),U=q.match(/class=['"]([^'"]+)['"]/i),_=U?U[1]:Y.checkInput,B=q.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${T0(X)}" value="${T0(G)}" class="${_}"${z?" checked":""}${B?` ${B}`:""}>`}),J=J.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(Q,X,G,K="")=>{let q=W1(K),W=S5(X,Z),z=W!==void 0&&W===G,U=q.match(/class=['"]([^'"]+)['"]/i),_=U?U[1]:Y.checkInput,B=q.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${T0(X)}" value="${T0(G)}" class="${_}"${z?" checked":""}${B?` ${B}`:""}>`}),J=J.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(Q,X,G="")=>{let K=W1(G),q=K.match(/accept=['"]([^'"]+)['"]/i),W=q?q[1]:"",z=K.includes("multiple"),U=y5(X,Z),_=K.match(/class=['"]([^'"]+)['"]/i),B=l4(_?_[1]:"",Y.input,U,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${T0(X)}"`,`class="${B}"`];if(W)H.push(`accept="${T0(W)}"`);if(z)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),J=J.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(Q,X,G="",K)=>{let q=W1(G),W=q.match(/class=['"]([^'"]+)['"]/i),z=W?W[1]:Y.label,U=q.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${T0(X)}" class="${z}"${U?` ${U}`:""}>${K}</label>`}),J}function DZ($,Z,Y=MZ){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(J,Q,X)=>{try{if(y5(Q,Z))return X.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return TZ(Q,Z);if(K.trim().includes("errors.first")||K.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(Q);return TZ(Q,Z)}let q=K.trim();if(Q0(q)){let W=Y0(q,Z);return W!==void 0?String(W):q}return q}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),J}})}function y5($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function TZ($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let Y=Z.errors[$];return Array.isArray(Y)?Y[0]:String(Y)}return""}function S5($,Z){let Y;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let J=$.slice(0,-2);if(Y=Z[J],Y!==void 0)return Y}return Z[$]}function W1($){if(!$.trim())return"";let Z=[],Y=$.trim(),J=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,Q;while((Q=J.exec(Y))!==null){let[,X,,G]=Q;Z.push(`${X}="${G.trim()}"`)}return Z.join(" ")}var MZ;var EZ=S(()=>{R0();MZ={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"}});import l7 from"path";async function zq(){if(C5!==void 0)return C5;try{C5=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{C5=null}return C5}function Wq($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}async function Uq($,Z){if({...n7,...Z.i18n}.cache&&c7[$]){let Q=c7[$],X=Z.i18n?.cacheMaxAge??0;if(!Wq(Q,X))return Q.translations}if(P5[$]?.state==="loading")return P5[$].promise;u7[$]="loading";let J=i7($,Z).then((Q)=>{return u7[$]="loaded",delete P5[$],Q}).catch((Q)=>{throw u7[$]="error",P5[$]={promise:J,state:"error",error:Q instanceof Error?Q:Error(String(Q))},Q});return P5[$]={promise:J,state:"loading"},J}async function i7($,Z){let Y={...n7,...Z.i18n},J=l7.isAbsolute(Y.translationsDir)?Y.translationsDir:l7.resolve(Z.root||process.cwd(),Y.translationsDir);try{let Q=await zq(),X=Q?await Q($,{translationsDir:J,defaultLocale:Y.defaultLocale,sources:Oq(Y.format)}):await _q($,Y,J);if(X===void 0){if($!==Y.defaultLocale)return i7(Y.defaultLocale,Z);return{}}let G=X;if(Y.cache)c7[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(Q){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,Q);if($!==Y.defaultLocale)return i7(Y.defaultLocale,Z);return{}}}async function _q($,Z,Y){let J=l7.join(Y,`${$}${Bq(Z.format)}`);try{let Q=await import(J);return Q.default||Q}catch(Q){try{let X=await Bun.file(J).text();if(Z.format==="yaml"||Z.format==="yml")return jq(X);if(Z.format==="json")return JSON.parse(X);throw Q}catch{return}}}function Bq($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function jq($){let Z={},Y=$.split(`
|
|
2517
|
-
`),J=[{obj:Z,indent:-1}];for(let Q of Y){let X=Q.replace(/#.*$/,"").trimEnd();if(!X.trim())continue;let G=X.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,q=X.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(q){let[,,W,z]=q,U=W.trim(),_=z.trim();if(_==="")K[U]={},J.push({obj:K[U],indent:G});else K[U]=Hq(_)}}return Z}function Hq($){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 Oq($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function Lq($,Z){return Uq($,Z)}function Fq($,Z){for(let Y of $){let J=Y.trim(),Q=J.match(/^\{(\d+)\}\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10);if(Z===G)return Q[2];continue}let X=J.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(X){let G=Number.parseInt(X[1],10),K=X[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(X[2],10);if(Z>=G&&Z<=K)return X[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function Vq($,Z={}){return SZ($,Z)}function SZ($,Z){let Y="",J=0;while(J<$.length)if($[J]==="{"){let Q=wq($,J);if(Q===-1){Y+=$[J],J++;continue}let X=$.slice(J+1,Q);Y+=Aq(X,Z),J=Q+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 wq($,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 Aq($,Z){let Y=Nq($);if(Y.length===0)return`{${$}}`;let J=Y[0].trim(),Q=Z[J];if(Y.length===1)return Q!==void 0?String(Q):`{${J}}`;switch(Y[1].trim().toLowerCase()){case"plural":return Rq(Q,Y.slice(2).join(","),Z);case"select":return Mq(Q,Y.slice(2).join(","));case"selectordinal":return Iq(Q,Y.slice(2).join(","));case"number":return Eq(Q,Y[2]?.trim());case"date":return kq(Q,Y[2]?.trim());case"time":return bq(Q,Y[2]?.trim());default:return Q!==void 0?String(Q):`{${$}}`}}function Nq($){let Z=[],Y="",J=0;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X==="{")J++,Y+=X;else if(X==="}")J--,Y+=X;else if(X===","&&J===0)Z.push(Y),Y="";else Y+=X}if(Y)Z.push(Y);return Z}function Rq($,Z,Y){let J=Number($)||0,Q=o7(Z),X=`=${J}`;if(Q[X])return p7(Q[X],J,Y);let G=Tq(J);if(Q[G])return p7(Q[G],J,Y);if(Q.other)return p7(Q.other,J,Y);return String(J)}function p7($,Z,Y){let J=$.replace(/#/g,String(Z));return SZ(J,Y)}function Tq($){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 Mq($,Z){let Y=String($||""),J=o7(Z);if(J[Y])return J[Y];return J.other||String($)}function Iq($,Z){let Y=Number($)||0,J=o7(Z),Q=Dq(Y);if(J[Q])return J[Q].replace(/#/g,String(Y));if(J.other)return J.other.replace(/#/g,String(Y));return String(Y)}function Dq($){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 o7($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,J=Y.exec($);while(J!==null)Z[J[1]]=J[2],J=Y.exec($);return Z}function Eq($,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 kq($,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 bq($,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 Sq($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function kZ($,Z,Y=!0,J={}){let Q=$.split("."),X=Z;for(let K of Q){if(X===void 0||X===null)break;X=X[K]}if(X===void 0||X===null)return Y?$:"";let G=String(X);if(Sq(G))return Vq(G,J);if(G.includes("|")&&"count"in J){let K=Number(J.count),q=G.split("|");G=Fq(q,K)}for(let[K,q]of Object.entries(J)){let W=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${W}`,"g"),String(q))}return G}async function yZ($,Z,Y,J){let Q=$,X=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...n7,...J.i18n},K=await Lq(G.locale,J);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,Q=await bZ(Q,X,async(z,U,_,B,j)=>{try{let H={};if(_)try{let F=[()=>JSON.parse(_),()=>{let O=`{"data":${_}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return N0(_,Z)}];for(let O of F)try{if(H=O(),Object.keys(H).length>0)break}catch{}}catch(F){if(J.debug)console.error("Error parsing parameters for @translate directive:",F)}return kZ(U,K,G.fallbackToKey,H)||B.trim()}catch(H){if(J.debug)console.error("Error processing @translate directive:",H);return e("Translate",`Error in @translate('${U}'): ${H instanceof Error?H.message:String(H)}`,s.EVALUATION_ERROR)}});let q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(J.debug){console.warn(`Processing translations in template. Sections: ${Q.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let z=[...Q.matchAll(q)];console.warn(`Found ${z.length} @translate matches`),z.forEach((U,_)=>console.warn(`Match ${_}: ${U[0]}, Key: ${U[1]}, Params: ${U[2]||"none"}`))}return Q=await bZ(Q,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(z,U,_,B)=>{try{let j={};if(_)try{let H=[()=>JSON.parse(_),()=>{let L=`{"data":${_}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return N0(_,Z)}];for(let L of H)try{if(j=L(),Object.keys(j).length>0)break}catch{}}catch(H){if(J.debug)console.error("Error parsing parameters for @translate directive:",H)}return kZ(U,K,G.fallbackToKey,j)}catch(j){if(J.debug)console.error("Error processing @translate directive:",j);return e("Translate",`Error in @translate('${U}'): ${j instanceof Error?j.message:String(j)}`,s.EVALUATION_ERROR)}}),Q}async function bZ($,Z,Y){let J=[];return $.replace(Z,(X,...G)=>{let K=Y(X,...G).then((q)=>({match:X,replacement:q}));return J.push(K),X}),(await Promise.all(J)).reduce((X,{match:G,replacement:K})=>X.replace(G,K),$)}var C5,n7,c7,P5,u7;var CZ=S(()=>{Z1();R0();n7={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},c7={},P5={},u7={}});var a7={};r(a7,{streamingSuspenseDirective:()=>xZ,streamToResponse:()=>pq,streamTemplateSimple:()=>hq,streamTemplate:()=>Cq,renderStreamingPage:()=>vq,registerStreamingDirectives:()=>mq,processStreamDirectives:()=>fq,processSectionDirectives:()=>uq,islandDirective:()=>fZ,generateHydrationRuntime:()=>lq,extractStreamBoundaries:()=>gq,createStreamRenderer:()=>dq,buildSuspenseResolveScript:()=>r7,SUSPENSE_RESOLVER_RUNTIME:()=>vZ});import i4 from"path";function yq($){let Z=[],Y=0,J;PZ.lastIndex=0;while((J=PZ.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 Q=J[1],X=J[2];Z.push({type:"suspense",name:Q,content:X}),Y=J.index+J[0].length}if(Y<$.length){let Q=$.slice(Y);if(Q.trim())Z.push({type:Z.length===0?"shell":"content",content:Q})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function Cq($,Z={},Y={}){let J={...
|
|
2517
|
+
`),J=[{obj:Z,indent:-1}];for(let Q of Y){let X=Q.replace(/#.*$/,"").trimEnd();if(!X.trim())continue;let G=X.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,q=X.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(q){let[,,W,z]=q,U=W.trim(),_=z.trim();if(_==="")K[U]={},J.push({obj:K[U],indent:G});else K[U]=Hq(_)}}return Z}function Hq($){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 Oq($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function Lq($,Z){return Uq($,Z)}function Fq($,Z){for(let Y of $){let J=Y.trim(),Q=J.match(/^\{(\d+)\}\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10);if(Z===G)return Q[2];continue}let X=J.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(X){let G=Number.parseInt(X[1],10),K=X[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(X[2],10);if(Z>=G&&Z<=K)return X[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function Vq($,Z={}){return SZ($,Z)}function SZ($,Z){let Y="",J=0;while(J<$.length)if($[J]==="{"){let Q=wq($,J);if(Q===-1){Y+=$[J],J++;continue}let X=$.slice(J+1,Q);Y+=Aq(X,Z),J=Q+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 wq($,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 Aq($,Z){let Y=Nq($);if(Y.length===0)return`{${$}}`;let J=Y[0].trim(),Q=Z[J];if(Y.length===1)return Q!==void 0?String(Q):`{${J}}`;switch(Y[1].trim().toLowerCase()){case"plural":return Rq(Q,Y.slice(2).join(","),Z);case"select":return Mq(Q,Y.slice(2).join(","));case"selectordinal":return Iq(Q,Y.slice(2).join(","));case"number":return Eq(Q,Y[2]?.trim());case"date":return kq(Q,Y[2]?.trim());case"time":return bq(Q,Y[2]?.trim());default:return Q!==void 0?String(Q):`{${$}}`}}function Nq($){let Z=[],Y="",J=0;for(let Q=0;Q<$.length;Q++){let X=$[Q];if(X==="{")J++,Y+=X;else if(X==="}")J--,Y+=X;else if(X===","&&J===0)Z.push(Y),Y="";else Y+=X}if(Y)Z.push(Y);return Z}function Rq($,Z,Y){let J=Number($)||0,Q=o7(Z),X=`=${J}`;if(Q[X])return p7(Q[X],J,Y);let G=Tq(J);if(Q[G])return p7(Q[G],J,Y);if(Q.other)return p7(Q.other,J,Y);return String(J)}function p7($,Z,Y){let J=$.replace(/#/g,String(Z));return SZ(J,Y)}function Tq($){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 Mq($,Z){let Y=String($||""),J=o7(Z);if(J[Y])return J[Y];return J.other||String($)}function Iq($,Z){let Y=Number($)||0,J=o7(Z),Q=Dq(Y);if(J[Q])return J[Q].replace(/#/g,String(Y));if(J.other)return J.other.replace(/#/g,String(Y));return String(Y)}function Dq($){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 o7($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,J=Y.exec($);while(J!==null)Z[J[1]]=J[2],J=Y.exec($);return Z}function Eq($,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 kq($,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 bq($,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 Sq($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function kZ($,Z,Y=!0,J={}){let Q=$.split("."),X=Z;for(let K of Q){if(X===void 0||X===null)break;X=X[K]}if(X===void 0||X===null)return Y?$:"";let G=String(X);if(Sq(G))return Vq(G,J);if(G.includes("|")&&"count"in J){let K=Number(J.count),q=G.split("|");G=Fq(q,K)}for(let[K,q]of Object.entries(J)){let W=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${W}`,"g"),String(q))}return G}async function yZ($,Z,Y,J){let Q=$,X=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...n7,...J.i18n},K=await Lq(G.locale,J);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,Q=await bZ(Q,X,async(z,U,_,B,j)=>{try{let H={};if(_)try{let F=[()=>JSON.parse(_),()=>{let O=`{"data":${_}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return N0(_,Z)}];for(let O of F)try{if(H=O(),Object.keys(H).length>0)break}catch{}}catch(F){if(J.debug)console.error("Error parsing parameters for @translate directive:",F)}return kZ(U,K,G.fallbackToKey,H)||B.trim()}catch(H){if(J.debug)console.error("Error processing @translate directive:",H);return e("Translate",`Error in @translate('${U}'): ${H instanceof Error?H.message:String(H)}`,s.EVALUATION_ERROR)}});let q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(J.debug){console.warn(`Processing translations in template. Sections: ${Q.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let z=[...Q.matchAll(q)];console.warn(`Found ${z.length} @translate matches`),z.forEach((U,_)=>console.warn(`Match ${_}: ${U[0]}, Key: ${U[1]}, Params: ${U[2]||"none"}`))}return Q=await bZ(Q,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(z,U,_,B)=>{try{let j={};if(_)try{let H=[()=>JSON.parse(_),()=>{let L=`{"data":${_}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return N0(_,Z)}];for(let L of H)try{if(j=L(),Object.keys(j).length>0)break}catch{}}catch(H){if(J.debug)console.error("Error parsing parameters for @translate directive:",H)}return kZ(U,K,G.fallbackToKey,j)}catch(j){if(J.debug)console.error("Error processing @translate directive:",j);return e("Translate",`Error in @translate('${U}'): ${j instanceof Error?j.message:String(j)}`,s.EVALUATION_ERROR)}}),Q}async function bZ($,Z,Y){let J=[];return $.replace(Z,(X,...G)=>{let K=Y(X,...G).then((q)=>({match:X,replacement:q}));return J.push(K),X}),(await Promise.all(J)).reduce((X,{match:G,replacement:K})=>X.replace(G,K),$)}var C5,n7,c7,P5,u7;var CZ=S(()=>{Z1();R0();n7={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},c7={},P5={},u7={}});var a7={};r(a7,{streamingSuspenseDirective:()=>xZ,streamToResponse:()=>pq,streamTemplateSimple:()=>hq,streamTemplate:()=>Cq,renderStreamingPage:()=>vq,registerStreamingDirectives:()=>mq,processStreamDirectives:()=>fq,processSectionDirectives:()=>uq,islandDirective:()=>fZ,generateHydrationRuntime:()=>lq,extractStreamBoundaries:()=>gq,createStreamRenderer:()=>dq,buildSuspenseResolveScript:()=>r7,SUSPENSE_RESOLVER_RUNTIME:()=>vZ});import i4 from"path";function yq($){let Z=[],Y=0,J;PZ.lastIndex=0;while((J=PZ.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 Q=J[1],X=J[2];Z.push({type:"suspense",name:Q,content:X}),Y=J.index+J[0].length}if(Y<$.length){let Q=$.slice(Y);if(Q.trim())Z.push({type:Z.length===0?"shell":"content",content:Q})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function Cq($,Z={},Y={}){let J={...k1,...Y,streaming:{...s7,...Y.streaming}},Q=J.streaming?.bufferSize||16384;return new ReadableStream({async start(X){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),q=K?K[1]:"",W=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={...Z,__filename:$,__dirname:i4.dirname($)};if(q.trim())await T1(q,z,$);let U=yq(W),_=new Set;if(!U.some((j)=>j.type==="suspense")){let j=J.streaming?.strategy||"auto",H=new RegExp(C1.source,"g");if(!(j!=="manual"&&H.test(W))){let F=await j0(W,z,$,J,_);for(let O=0;O<F.length;O+=Q)X.enqueue(F.slice(O,O+Q)),await new Promise((V)=>setTimeout(V,0))}else{let F=[],O=new RegExp(C1.source,"g"),V;while((V=O.exec(W))!==null)F.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let w=0;for(let A of F){if(A.start>w){let R=W.slice(w,A.start);if(R.trim()){let T=await j0(R,z,$,J,_);X.enqueue(T),await new Promise((M)=>setTimeout(M,0))}}let N=await j0(A.content,z,$,J,_);X.enqueue(N),await new Promise((R)=>setTimeout(R,0)),w=A.end}if(w<W.length){let A=W.slice(w);if(A.trim()){let N=await j0(A,z,$,J,_);X.enqueue(N)}}}}else{let j=new Map;for(let L of U)if(L.type==="shell"||L.type==="content"){let F=await j0(L.content,z,$,J,_);X.enqueue(F)}else if(L.type==="suspense"&&L.name){let F=`stx-suspense-${L.name}`;X.enqueue(`<div id="${F}" data-suspense="${L.name}" style="display:contents;">
|
|
2518
2518
|
<template data-suspense-fallback>Loading...</template>
|
|
2519
2519
|
</div>`),j.set(L.name,j0(L.content,z,$,J,_))}X.enqueue(`
|
|
2520
2520
|
<script>
|
|
@@ -2538,7 +2538,7 @@ window.__stxSuspense.resolve('${$}', \`${J}\`);
|
|
|
2538
2538
|
</script>`}catch(Y){let J=Y instanceof Error?Y.message:String(Y);return`
|
|
2539
2539
|
<script>
|
|
2540
2540
|
window.__stxSuspense.resolve('${$}', '<div class="stx-error">Error loading content: ${u0(J)}</div>');
|
|
2541
|
-
</script>`}}function Pq($,Z,Y){if(!Z||Z<=0)return $;let J,Q=new Promise((X,G)=>{J=setTimeout(()=>G(Error(`streaming boundary "${Y}" timed out after ${Z}ms`)),Z)});return Promise.race([$,Q]).finally(()=>clearTimeout(J))}function vq($,Z=[],Y={}){let J=Y.timeoutMs??0;return new ReadableStream({async start(Q){try{if(Q.enqueue($),Z.length>0)Q.enqueue(vZ),await Promise.all(Z.map(async(X)=>{let G=Pq(X.render(),J,X.id);Q.enqueue(await r7(X.id,G))}));Q.close()}catch(X){Q.error(X)}}})}function fq($,Z){return $.replace(xq,(Y,J,Q)=>{let X=J.trim(),G=Q.split(/@fallback/i),K=G[0].trim(),q=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[X]=K,`<div data-suspense="${X}">${q}</div>`})}function gq($){let Z=$?.streamBoundaries;if(!Z||typeof Z!=="object")return;let Y=Object.entries(Z).filter(([,J])=>typeof J==="function");return Y.length>0?Y.map(([J,Q])=>({id:J,render:Q})):void 0}async function hq($,Z={},Y={}){let J={...
|
|
2541
|
+
</script>`}}function Pq($,Z,Y){if(!Z||Z<=0)return $;let J,Q=new Promise((X,G)=>{J=setTimeout(()=>G(Error(`streaming boundary "${Y}" timed out after ${Z}ms`)),Z)});return Promise.race([$,Q]).finally(()=>clearTimeout(J))}function vq($,Z=[],Y={}){let J=Y.timeoutMs??0;return new ReadableStream({async start(Q){try{if(Q.enqueue($),Z.length>0)Q.enqueue(vZ),await Promise.all(Z.map(async(X)=>{let G=Pq(X.render(),J,X.id);Q.enqueue(await r7(X.id,G))}));Q.close()}catch(X){Q.error(X)}}})}function fq($,Z){return $.replace(xq,(Y,J,Q)=>{let X=J.trim(),G=Q.split(/@fallback/i),K=G[0].trim(),q=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[X]=K,`<div data-suspense="${X}">${q}</div>`})}function gq($){let Z=$?.streamBoundaries;if(!Z||typeof Z!=="object")return;let Y=Object.entries(Z).filter(([,J])=>typeof J==="function");return Y.length>0?Y.map(([J,Q])=>({id:J,render:Q})):void 0}async function hq($,Z={},Y={}){let J={...k1,...Y,streaming:{...s7,...Y.streaming}},Q=J.streaming?.bufferSize||16384;return new ReadableStream({async start(X){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),q=K?K[1]:"",W=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={...Z,__filename:$,__dirname:i4.dirname($)};if(q.trim())await T1(q,z,$);let U=new Set,_=J.streaming?.strategy||"auto",B=new RegExp(C1.source,"g");if(!(_!=="manual"&&B.test(W))){let H=await j0(W,z,$,J,U);for(let L=0;L<H.length;L+=Q)X.enqueue(H.slice(L,L+Q))}else{let H=[],L=new RegExp(C1.source,"g"),F;while((F=L.exec(W))!==null)H.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let O=0;for(let V of H){if(V.start>O){let A=W.slice(O,V.start);if(A.trim()){let N=await j0(A,z,$,J,U);X.enqueue(N)}}let w=await j0(V.content,z,$,J,U);X.enqueue(w),O=V.end}if(O<W.length){let V=W.slice(O);if(V.trim()){let w=await j0(V,z,$,J,U);X.enqueue(w)}}}X.close()}catch(G){X.error(G)}}})}async function dq($,Z={}){let Y={...k1,...Z,streaming:{...s7,...Z.streaming}},J=await Bun.file($).text(),Q=J.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),X=Q?Q[1]:"",G=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),K=G,q={},W;C1.lastIndex=0;while((W=C1.exec(G))!==null){let _=W[1],B=W[2];q[_]=B}let z=G.replace(C1,"");return{renderShell:async(_={})=>{let B={..._,__filename:$,__dirname:i4.dirname($)};return await T1(X,B,$),j0(z,B,$,Y,new Set)},renderSection:async(_,B={})=>{try{if(!q[_])return`<div class="error-message">Section "${u0(_)}" not found in template "${u0($)}"</div>`;let j={...B,__filename:$,__dirname:i4.dirname($)};await T1(X,j,$);let H=new Set;return await j0(q[_],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return K0("Expression",H,$,q[_]||"",0,q[_]||"")}},getSections:()=>{return Object.keys(q)},getTemplate:()=>{return K}}}function mq($={}){let Z=[];if($.streaming?.enabled)Z.push(xZ);if($.hydration?.enabled)Z.push(fZ);return Z}async function uq($,Z,Y,J={}){return $}function pq($,Z={}){let Y=new TextEncoder,J=$.pipeThrough(new TransformStream({transform(X,G){G.enqueue(Y.encode(X))}})),Q=new Headers(Z.headers);if(!Q.has("Content-Type"))Q.set("Content-Type","text/html; charset=utf-8");if(!Q.has("Transfer-Encoding"))Q.set("Transfer-Encoding","chunked");if(!Q.has("X-Content-Type-Options"))Q.set("X-Content-Type-Options","nosniff");if(!Q.has("X-Accel-Buffering"))Q.set("X-Accel-Buffering","no");return new Response(J,{...Z,headers:Q})}function lq($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:J=!0}=$,Q=Object.entries(Y).map(([X,G])=>`'${X}': ${J?`() => import('${G}')`:`require('${G}')`}`).join(`,
|
|
2542
2542
|
`);if(Z==="loader")return`
|
|
2543
2543
|
(function() {
|
|
2544
2544
|
window.__stx = window.__stx || {};
|
|
@@ -2680,7 +2680,7 @@ else {
|
|
|
2680
2680
|
else {
|
|
2681
2681
|
stx.hydrate();
|
|
2682
2682
|
}
|
|
2683
|
-
})();`}var s7,
|
|
2683
|
+
})();`}var s7,C1,PZ,vZ=`
|
|
2684
2684
|
<script>
|
|
2685
2685
|
(function(){
|
|
2686
2686
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -2700,18 +2700,18 @@ else {
|
|
|
2700
2700
|
}
|
|
2701
2701
|
};
|
|
2702
2702
|
})();
|
|
2703
|
-
</script>`,xq,xZ,fZ;var t7=S(()=>{
|
|
2703
|
+
</script>`,xq,xZ,fZ;var t7=S(()=>{r1();r0();J4();A0();s7={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},C1=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,PZ=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;xq=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;xZ={name:"suspense",hasEndTag:!0,handler:($,Z,Y,J)=>{if(!Z||Z.length===0)throw Error("Suspense directive requires a name parameter");let Q=Z[0].replace(/['"`]/g,"");return`<!-- @suspense:${Q} -->${$}<!-- @endsuspense:${Q} -->`}},fZ={name:"island",hasEndTag:!0,handler:($,Z,Y,J)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let Q=Z[0].replace(/['"`]/g,""),X=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${Q}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),q=K?K[1].trim():"",W=K?$.replace(K[0],""):$;return`<div data-island="${Q}" data-island-id="${G}" data-priority="${X}">
|
|
2704
2704
|
${W}
|
|
2705
2705
|
<script type="application/json" data-island-props="${G}">
|
|
2706
2706
|
${q?`{${q}}`:"{}"}
|
|
2707
2707
|
</script>
|
|
2708
|
-
</div>`}}});var dZ={};r(dZ,{warnUnbalancedTags:()=>e7,findUnbalancedTags:()=>hZ});function
|
|
2709
|
-
`).length;Y.set(q,{count:1,firstLine:U})}}}let G=[];for(let K of new Set([...Y.keys(),...J.keys()])){if(iq.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,W=J.get(K)??0;if(q!==W)G.push({tag:K,opened:q,closed:W,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function e7($,Z){let Y;try{Y=hZ($)}catch{return}if(Y.length===0)return;let J=`${Z}:${$.length}`;if(gZ.has(J))return;gZ.add(J);let Q=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:X,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let W=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${Q}: <${X}> ${G} opened, ${K} closed \u2014 an unclosed <${X}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${Q}: <${X}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${X}>.`)}var cq,iq,gZ;var $3=S(()=>{cq=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),iq=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);gZ=new Set});import m0 from"path";import Z3 from"fs";function mZ($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function uZ($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class pZ{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 Q=$.endsWith(".stx")?$.slice(0,-4):$,X=J?.__importedComponents;if(X){let B=[Q,Q.toLowerCase(),mZ(Q),uZ(Q)];for(let j of B)if(X.has(j))return X.get(j)}let G=[...new Set([`${Q}.stx`,`${mZ(Q)}.stx`,`${uZ(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let B=m0.resolve(m0.dirname(Z),`${Q}.stx`);if(await n(B))return B;return null}let K=[],q=Y.componentsDir||"",W=J?.__originalFilePath;if(W)K.push(m0.join(m0.dirname(W),"components"));if(q)K.push(q);let z=m0.join(m0.dirname(Z),"components");if(!K.includes(z))K.push(z);let U=process.cwd(),_=[m0.resolve(U,"src/components"),m0.resolve(U,"components"),m0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=m0.join(B,j);if(await n(H))return H}try{if(!Z3.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=Z3.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=m0.join(B,L.name);for(let O of G){let V=m0.join(F,O);if(await n(V))return V}}}catch{}}return null}}var y0;var Y3=S(()=>{A0();y0=new pZ});function
|
|
2708
|
+
</div>`}}});var dZ={};r(dZ,{warnUnbalancedTags:()=>e7,findUnbalancedTags:()=>hZ});function e1($){return $.replace(/[^\n]/g," ")}function hZ($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,e1).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,e1).replace(/<!--[\s\S]*?-->/g,e1).replace(/\{\{\{[\s\S]*?\}\}\}/g,e1).replace(/\{\{[\s\S]*?\}\}/g,e1).replace(/\{!![\s\S]*?!!\}/g,e1),Y=new Map,J=new Map,Q=/<(\/?)([A-Za-z][\w-]*)\b(?:[^>"']|"[^"]*"|'[^']*')*?(\/?)>/g,X;while((X=Q.exec(Z))!==null){let K=X[1]==="/",q=X[2],W=X[3]==="/";if(cq.has(q.toLowerCase()))continue;if(W)continue;if(K)J.set(q,(J.get(q)??0)+1);else{let z=Y.get(q);if(z)z.count++;else{let U=Z.slice(0,X.index).split(`
|
|
2709
|
+
`).length;Y.set(q,{count:1,firstLine:U})}}}let G=[];for(let K of new Set([...Y.keys(),...J.keys()])){if(iq.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,W=J.get(K)??0;if(q!==W)G.push({tag:K,opened:q,closed:W,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function e7($,Z){let Y;try{Y=hZ($)}catch{return}if(Y.length===0)return;let J=`${Z}:${$.length}`;if(gZ.has(J))return;gZ.add(J);let Q=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:X,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let W=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${Q}: <${X}> ${G} opened, ${K} closed \u2014 an unclosed <${X}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${Q}: <${X}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${X}>.`)}var cq,iq,gZ;var $3=S(()=>{cq=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),iq=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);gZ=new Set});import m0 from"path";import Z3 from"fs";function mZ($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function uZ($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class pZ{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 Q=$.endsWith(".stx")?$.slice(0,-4):$,X=J?.__importedComponents;if(X){let B=[Q,Q.toLowerCase(),mZ(Q),uZ(Q)];for(let j of B)if(X.has(j))return X.get(j)}let G=[...new Set([`${Q}.stx`,`${mZ(Q)}.stx`,`${uZ(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let B=m0.resolve(m0.dirname(Z),`${Q}.stx`);if(await n(B))return B;return null}let K=[],q=Y.componentsDir||"",W=J?.__originalFilePath;if(W)K.push(m0.join(m0.dirname(W),"components"));if(q)K.push(q);let z=m0.join(m0.dirname(Z),"components");if(!K.includes(z))K.push(z);let U=process.cwd(),_=[m0.resolve(U,"src/components"),m0.resolve(U,"components"),m0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=m0.join(B,j);if(await n(H))return H}try{if(!Z3.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=Z3.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=m0.join(B,L.name);for(let O of G){let V=m0.join(F,O);if(await n(V))return V}}}catch{}}return null}}var y0;var Y3=S(()=>{A0();y0=new pZ});function U1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function nq($){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 J3;var X3=S(()=>{J3={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let J=nq($),Q=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),X=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,q=[];if(J.reactive)q.push(`:href="${U1(J.value)}"`);else q.push(`href="${U1(J.value)}"`);if(Q)q.push(`class="${U1(Q)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${U1(X)}"`),q.push(`data-stx-exact-active-class="${U1(G)}"`),K)q.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[z,U]of Object.entries($.static)){if(W.has(z))continue;if(typeof U==="boolean"){if(U)q.push(U1(z))}else q.push(`${U1(z)}="${U1(U)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function L0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function E0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function G3($,Z,Y=!1){let J=$.serverDynamic[Z];if(J!==void 0)return J!==!1&&J!=="false";let Q=$.static[Z];if(Q!==void 0)return Q!=="false"&&Q!==!1;return Y}function lZ($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let J of Z)if(J.includes(":")){let[Q,X]=J.split(":"),G=oq[Q];if(G)Y.push(`(max-width: ${G}px) ${X}`);else{let K=Number.parseInt(Q);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${X}`)}}else Y.push(J);return Y.join(", ")}function K3($,Z,Y,J){return Z.map((Q)=>`${v5($,Q,void 0,Y,J)} ${Q}w`).join(", ")}function sq($,Z,Y,J,Q){return Z.map((X)=>{let G=Y?Y*X:void 0;return`${v5($,G,void 0,J,Q)} ${X}x`}).join(", ")}function v5($,Z,Y,J,Q){if(!J||J==="local"||J==="static")return $;if(J==="cloudinary"){let X=[];if(Z)X.push(`w_${Z}`);if(Y)X.push(`h_${Y}`);if(Q)X.push(`f_${Q}`);X.push("q_auto");let G=X.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(J==="imgix"){let X=new URLSearchParams;if(Z)X.set("w",String(Z));if(Y)X.set("h",String(Y));if(Q)X.set("fm",Q);X.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${X.toString()}`}if(J==="bunny"){let X=new URLSearchParams;if(Z)X.set("width",String(Z));if(Y)X.set("height",String(Y));if(Q)X.set("format",Q);let G=$.includes("?")?"&":"?";return`${$}${G}${X.toString()}`}return $}function rq($,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 oq,Q3,q3;var z3=S(()=>{oq={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Q3=[320,640,768,1024,1280,1536,1920];q3={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let J=E0($,"src")||"",Q=E0($,"alt")||"",X=E0($,"width"),G=E0($,"height"),K=E0($,"sizes"),q=E0($,"srcset"),W=E0($,"densities"),z=E0($,"format"),U=E0($,"placeholder"),_=E0($,"placeholderColor")||"#e5e7eb",B=E0($,"provider"),j=E0($,"class")||E0($,"className")||"",H=E0($,"style")||"",L=E0($,"quality"),F=G3($,"lazy",!0),O=G3($,"preload",!1),V=G3($,"picture",!1)||!!z,w=X?Number.parseInt(X):void 0,A=G?Number.parseInt(G):void 0,N=q||"",R="";if(!N&&K)N=K3(J,Q3,B,z),R=lZ(K);else if(!N&&W){let b=W.split(/\s+/).map((k)=>Number.parseFloat(k.replace("x","")));N=sq(J,b,w,B,z)}else if(K)R=lZ(K);let T=[];if(H)T.push(H);if(w&&A)T.push(`aspect-ratio:${w}/${A}`);if(U==="blur"||U==="color"||U==="thumbhash"){let b=rq(w||16,A||9,_);T.push(`background-image:url(${b})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(U&&U!=="empty"&&U!=="none")T.push(`background-image:url(${L0(U)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let M=v5(J,w,A,B,z),I=[];if(I.push(`src="${L0(M)}"`),I.push(`alt="${L0(Q)}"`),X)I.push(`width="${L0(X)}"`);if(G)I.push(`height="${L0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${L0(j)}"`);if(T.length>0)I.push(`style="${L0(T.join(";"))}"`);if(N)I.push(`srcset="${L0(N)}"`);if(R)I.push(`sizes="${L0(R)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[b,k]of Object.entries($.static)){if(D.has(b))continue;if(typeof k==="boolean"){if(k)I.push(L0(b))}else I.push(`${L0(b)}="${L0(k)}"`)}let E=`<img ${I.join(" ")} />`,P="";if(O){let k=z==="webp"?"image/webp":z==="avif"?"image/avif":"";P=`<link rel="preload" as="image" href="${L0(M)}"${k?` type="${k}"`:""}${N?` imagesrcset="${L0(N)}"`:""}${R?` imagesizes="${L0(R)}"`:""} />
|
|
2710
2710
|
`}if(V){let b=[];if(z==="avif"||z==="auto"){let k=v5(J,w,A,B,"avif"),y=N?K3(J,Q3,B,"avif"):`${k}`;b.push(`<source type="image/avif" srcset="${L0(y)}"${R?` sizes="${L0(R)}"`:""} />`)}if(z==="webp"||z==="auto"){let k=v5(J,w,A,B,"webp"),y=N?K3(J,Q3,B,"webp"):`${k}`;b.push(`<source type="image/webp" srcset="${L0(y)}"${R?` sizes="${L0(R)}"`:""} />`)}return`${P}<picture>
|
|
2711
2711
|
${b.join(`
|
|
2712
2712
|
`)}
|
|
2713
2713
|
${E}
|
|
2714
|
-
</picture>`}return`${P}${E}`}}});function
|
|
2714
|
+
</picture>`}return`${P}${E}`}}});function _1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function $5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var aq="<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'/images/safe-image-default.svg';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>",W3;var U3=S(()=>{W3={name:"SafeImage",aliases:["safe-image","safe-img"],render($,Z,Y){let J=$5($,"src")||"",Q=$5($,"alt")||"",X=$5($,"fallback")||"/images/safe-image-default.svg",G=$5($,"class")||$5($,"className")||"",K=$5($,"fallbackClassName")||"",q=[];if(q.push(`src="${_1(J)}"`),q.push(`alt="${_1(Q)}"`),G)q.push(`class="${_1(G)}"`);if(q.push(`data-fallback="${_1(X)}"`),K)q.push(`data-fallback-class="${_1(K)}"`);q.push('onerror="window.__stxSafeImageHandler(this)"');let W=new Set(["src","alt","fallback","class","className","fallbackClassName"]);for(let[_,B]of Object.entries($.static)){if(W.has(_))continue;if(typeof B==="boolean"){if(B)q.push(_1(_))}else q.push(`${_1(_)}="${_1(B)}"`)}let z=`<img ${q.join(" ")} />`,U=Y.context;if(!U.__safeImageHandlerEmitted)return U.__safeImageHandlerEmitted=!0,`${aq}${z}`;return z}}});function _3($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function x5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function n4($,Z,Y){let J=x5($,Z);if(J!==void 0){let Q=Number.parseInt(J,10);if(!Number.isNaN(Q))return Q}return Y}var B3;var j3=S(()=>{B3={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let J=_3(x5($,"color")||"#6366f1"),Q=_3(x5($,"initialColor")||x5($,"initial-color")||""),X=_3(x5($,"height")||"3px"),G=n4($,"duration",2000),K=n4($,"throttle",200),q=n4($,"zIndex",999999)||n4($,"z-index",999999),W=Q?`linear-gradient(to right, ${Q}, ${J})`:J;return`
|
|
2715
2715
|
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${X};background:${W};z-index:${q};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
2716
2716
|
<div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
|
|
2717
2717
|
</div>
|
|
@@ -2744,8 +2744,8 @@ ${E}
|
|
|
2744
2744
|
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
2745
2745
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
2746
2746
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
2747
|
-
</style>`}}});var aZ={};r(aZ,{preloadIconCollection:()=>rZ,IconBuiltin:()=>s4});import{existsSync as eq,readFileSync as $z}from"fs";function sZ($){try{return z0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(eq(Y))return Y;return null}function Zz($){if(
|
|
2748
|
-
`||T==="\t")F++;O=N+H.length}else{if(F--,F===0){V=R;break}O=R+L.length}}if(V===-1){Q=_;continue}let w=$.slice(_,V),A=V+L.length;J.push({fullMatch:$.slice(X,A),tagName:q,attributes:j,content:w,startIndex:X,endIndex:A,isSelfClosing:!1}),Q=A}}return J}function X2($,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 Q2=S(()=>{R0();A0();t5()});var U2={};r(U2,{processESImports:()=>W2,processComponents:()=>e4});import t4 from"fs";import v0 from"path";function Xz($,Z,Y){let J={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),X=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){J.events[q]=K;continue}if(q.startsWith("__stx_")){let W=X(q.slice(6));J.serverDynamic[W]=X2(K,Y);continue}if(q.startsWith(":")){let W=X(q.slice(1)),z=K==="true"?W:K;try{if(!Q0(z)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${z}`);J.clientReactive[W]=z;continue}let U=Object.keys(Z),B=G0(z,U)(...Object.values(Z));if(B===void 0){let j=z.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!U.includes(F))){J.clientReactive[W]=z;continue}}J.serverDynamic[W]=B}catch{J.clientReactive[W]=z}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let z=W[1];if(Q0(z)){let _=G0(z,Object.keys(Z))(...Object.values(Z));J.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${z}`);J.static[q]=K}}catch(z){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,z);J.static[q]=K}else{let z=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=U.exec(K))!==null)try{let B=_[1];if(!Q0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=G0(B,Object.keys(Z))(...Object.values(Z));z=z.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}J.static[q]=z}continue}J.static[q]=K}return J}function Qz($){let Z={},Y=0,J=$.length;while(Y<J){while(Y<J&&/\s/.test($[Y]))Y++;if(Y>=J)break;let Q="";while(Y<J&&!/[\s=]/.test($[Y]))Q+=$[Y],Y++;if(!Q)break;while(Y<J&&/\s/.test($[Y]))Y++;if(Y<J&&$[Y]==="="){Y++;while(Y<J&&/\s/.test($[Y]))Y++;let X="";if(Y<J&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<J){let K=$[Y];if(K==="\\"&&Y+1<J){Y++,X+=$[Y],Y++;continue}if(K===G){Y++;break}X+=K,Y++}}else while(Y<J&&!/\s/.test($[Y]))X+=$[Y],Y++;Z[Q]=X}else Z[Q]="true"}return Z}function K2($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Gz($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Y.exec($))!==null){let Q=J[1];if(y0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function Kz($){let Z=q2.get($);if(Z)return Z;let Y=new Map,J=[v0.join($,"src"),v0.join($,"dist"),$];function Q(X,G){if(G>6)return;let K;try{K=t4.readdirSync(X,{withFileTypes:!0})}catch{return}for(let q of K){let W=v0.join(X,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;Q(W,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let z=q.name.slice(0,-4);if(!Y.has(z))Y.set(z,W);let U=z.toLowerCase();if(!Y.has(U))Y.set(U,W);let _=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let X of J)if(Q(X,0),Y.size>0)break;return q2.set($,Y),Y}function qz($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let J=v0.join(Y,"node_modules",$);try{if(t4.statSync(J).isDirectory())return J}catch{}let Q=v0.dirname(Y);if(Q===Y)return null;Y=Q}}async function W2($,Z,Y,J,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let X=Z.__importedComponents,G=v0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(W,z,U)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=U,j,H=[];while((j=_.exec(U))!==null){let[L,F,O,V]=j,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=v0.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let M=`${T}.stx`;try{if(t4.statSync(M).isFile())A=M}catch{try{if(t4.statSync(T).isDirectory())w=T}catch{}}}}else w=qz(V,G);if(!w&&!A)continue;let N=!1,R=(T,M)=>{X.set(T,M),X.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();X.set(I,M),Q.add(M)};if(O&&A)R(O,A),N=!0;else if(F){let T=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?Kz(w):null;for(let{source:I,local:D}of T){let E=null;if(A)E=A;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)R(D,E),N=!0}}if(N)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return W;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${z}>${B}</script>`}),K}async function zz($,Z,Y,J,Q){let X=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(X))!==null){let[W,z]=q,U=z.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of U){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[v0.resolve(v0.dirname(Y),`${_}.stx`),v0.resolve(v0.dirname(Y),_),v0.resolve(J.componentsDir||"components",`${_}.stx`),v0.resolve(J.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),Q.add(F),J.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${_}`)}X=X.replace(W,""),K.lastIndex=0}return X}async function Wz($,Z,Y,J,Q){let X=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,W;while((W=q.exec(X))!==null){let z=W.index,U=z+W[0].length-1,_=1,B=U+1;while(B<X.length&&_>0){if(X[B]==="(")_++;else if(X[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=X.substring(U+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let A={};if(O)try{A=N0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);X=X.replace(X.substring(z,H),`[Error parsing component props: ${E}]`);continue}let N="",R=H,M=X.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)N=M[1].trim(),R=H+M[0].length;let I=await I1(F,A,N,G,Z,Y,J,K,Q);X=X.substring(0,z)+I+X.substring(R),q.lastIndex=0}return X}async function Uz($,Z,Y,J,Q){if(!$)return $;let X=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=E$(X);return X=q.output,X=await _(X,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),X=await _(X,/[A-Z][a-zA-Z0-9]*/,!0),X=await _(X,/[a-z][a-z0-9]*/,!1,Jz),X=k$(X,q.scripts),X;async function _(B,j,H,L){if(!B)return B;let F=B,O=J2(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],A=H?Y2(w.tagName):w.tagName,N=Qz(w.attributes),R=Xz(N,Z,J),T=y0.getBuiltin(w.tagName),M=T?await _9(A,G,Z,Y,J):!1;if(T&&!M){let P={context:Z,filePath:Y,options:J,dependencies:Q},b=T.render(R,w.content,P);if(Object.keys(R.clientReactive).length>0)b=z2(b,R.clientReactive);if(Object.keys(R.events).length>0){let k=Object.entries(R.events).map(([y,g])=>`${y}="${K2(g)}"`).join(" ");b=b.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${k}`)}F=F.substring(0,w.startIndex)+b+F.substring(w.endIndex);continue}let I={};for(let[P,b]of Object.entries(R.static))I[P]=b;for(let[P,b]of Object.entries(R.serverDynamic))I[P]=b;let E=await I1(A,I,w.content,G,Z,Y,J,K,Q);if(Object.keys(R.clientReactive).length>0)E=z2(E,R.clientReactive);if(Object.keys(R.events).length>0){let P=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(P){let b=Object.entries(R.events).map(([y,g])=>`${y}="${K2(g)}"`).join(" "),k=P[1].length+P[2].length;E=E.substring(0,k)+" "+b+E.substring(k)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function z2($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let J=Object.entries(Z).map(([X,G])=>`:${X}="${G.replace(/"/g,""")}"`).join(" "),Q=Y[1].length+Y[2].length;return $.substring(0,Q)+" "+J+$.substring(Q)}async function e4($,Z,Y,J,Q){if(!G2)$2(),G2=!0;let X=await W2($,Z,Y,J,Q);X=await zz(X,Z,Y,J,Q),X=await Wz(X,Z,Y,J,Q);for(let G=0;G<3;G++){let K=X;if(X=await Uz(X,Z,Y,J,Q),X===K)break}if(J.debug){let G=Gz(X);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return X}var G2=!1,Jz,q2;var M3=S(()=>{Y3();Z2();Q2();A0();R0();Jz=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);q2=new Map});var F2={};r(F2,{processLoops:()=>I3});function jz($,Z){let Y=/@component\s*\(/g,J=$,Q,X=[];while((Q=Y.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,W=K+1;while(W<J.length&&q>0){if(J[W]==="(")q++;else if(J[W]===")"){if(q--,q===0)break}W++}if(q!==0)continue;let z=J.substring(K+1,W),U=W+1,_=z.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=z.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=N0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;X.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=X.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=X[G];J=J.substring(0,K)+W+J.substring(q)}return J}function $$($,Z,Y){let J=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),X;while((X=Q.exec(J))!==null){let G=X.index,K=G+X[0].length-1,q=1,W=K+1,z=null,U=!1;while(W<J.length&&q>0){let j=J[W];if(U){U=!1,W++;continue}if(j==="\\"&&z){U=!0,W++;continue}if(z){if(j===z)z=null;W++;continue}if(j==='"'||j==="'"||j==="`"){z=j,W++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}W++}if(q!==0)break;let _=J.substring(K+1,W),B=Y(_);J=J.substring(0,G)+B+J.substring(W+1)}return J}function Hz($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(J,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return J}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(J,Q,X)=>{try{let G=Object.keys(Z),K=Object.values(Z);o5(X);let W=G0(X,G)(...K),z=JSON.stringify(W),U=Buffer.from(z,"utf8").toString("base64");return`__stx_${Q}="${U}"`}catch(G){return J}}),Y}function Oz($,Z){let Y=$;return Y=$$(Y,"@break",(J)=>{try{let X=`!!(${J.trim()})`,G;if(Q0(X)){let K=G0(X,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Y0(X,Z));return G?Z$:""}catch{return""}}),Y=$$(Y,"@continue",(J)=>{try{let X=`!!(${J.trim()})`,G;if(Q0(X)){let K=G0(X,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Y0(X,Z));return G?Y$:""}catch{return""}}),Y}function Lz($){let Z=$;return Z=Z.replace(/@break(?!\()/g,Z$),Z=Z.replace(/@continue(?!\()/g,Y$),Z}function _2($){let Z=$.includes(Z$),Y=Z?$.substring(0,$.indexOf(Z$)):$;return{hasBreak:Z,content:Y}}function B2($){let Z=$.includes(Y$),Y=Z?$.substring(0,$.indexOf(Y$)):$;return{hasContinue:Z,content:Y}}function H2($){let Z=$;return Z=$$(Z,"@break",(Y)=>{let J=Y.trim();if(!s5(J))return"";return`\`; if (${J}) { break; } result += \``}),Z=$$(Z,"@continue",(Y)=>{let J=Y.trim();if(!s5(J))return"";return`\`; if (${J}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Fz($){let Z=/@forelse\s*\(/g,Y,J=[],Q=/@foreach\s*\(/g,X=/@endforeach/g,G;while((G=Q.exec($))!==null)J.push({pos:G.index,delta:1});while((G=X.exec($))!==null)J.push({pos:G.index,delta:-1});J.sort((z,U)=>z.pos-U.pos);let K=[],q=0;for(let z of J)q+=z.delta,K.push({pos:z.pos,depth:q});function W(z){let U=0,_=K.length-1,B=0;while(U<=_){let j=U+_>>1;if(K[j].pos<=z)B=K[j].depth,U=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let z=Y.index,U=Y.index+Y[0].length-1,_=1,B=U+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(U+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,A=V,N=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(w>0&&A<$.length){N.lastIndex=A,R.lastIndex=A;let b=N.exec($),k=R.exec($);if(!k)break;if(b&&b.index<k.index)w++,A=b.index+b[0].length;else{if(w--,w===0){T=k.index;break}A=k.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,P=0;while(P<M.length){let b=M.indexOf("@",P);if(b===-1)break;let k=M.substring(b);if(/^@forelse\s*\(/.test(k))E++,P=b+1;else if(k.startsWith("@endforelse"))E--,P=b+11;else if(E===0&&k.startsWith("@empty")){if(M.length<=b+6||!/[a-z]/i.test(M[b+6])){D=b;break}P=b+1}else P=b+1}if(D===-1)continue;return{start:z,end:I,arrayExpr:F,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function j2($,Z){let Y=$;while(!0){let J=Fz(Y);if(!J)break;let{start:Q,end:X,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:W}=J;try{let z;if(Q0(G))z=G0(G,Object.keys(Z))(...Object.values(Z));else z=Y0(G,Z);let U;if(!Array.isArray(z)||z.length===0)U=W;else U=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,Q)+U+Y.substring(X)}catch(z){let U=z instanceof Error?z.message:String(z),_=e("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,s.EVALUATION_ERROR);Y=Y.substring(0,Q)+_+Y.substring(X)}}return Y}function I3($,Z,Y,J){let Q=$;Q=j2(Q,Z);function X(q){let W=/@foreach\s*\(/g,z;while((z=W.exec(q))!==null){let U=z.index,_=z.index+z[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=U,V=L.substring(0,F),w=L.substring(F+4),A=H+1,N=1,R=A,T=/@foreach\s*\(/g,M=/@endforeach/g;while(N>0&&R<q.length){T.lastIndex=R,M.lastIndex=R;let I=T.exec(q),D=M.exec(q);if(!D)break;if(I&&I.index<D.index)N++,R=I.index+I[0].length;else{if(N--,N===0){let E=q.substring(A,D.index),P=D.index+11;return{start:O,end:P,arrayExpr:V,itemVar:w,content:E}}R=D.index+11}}}return null}function G(q,W){let z=q;while(!0){let U=X(z);if(!U)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=U;try{let F=j.trim(),O;if(Q0(F))O=G0(F,Object.keys(W))(...Object.values(W));else O=Y0(F,W);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=e("Foreach",`Error in @foreach: ${F} is not iterable`,s.TYPE_ERROR);z=z.substring(0,_)+D+z.substring(B);continue}let w=J?.loops?.useAltLoopVariable??Bz,A=H.trim(),N=null,R,T=!1;if(A.includes("=>")){let D=A.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],R=D[1];else R=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let D=A.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],N=D[1],T=!0;else R=A}else R=A;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],P={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},b={...W,loop:P,$loop:P};if(R.startsWith("[")&&R.endsWith("]")){let h=R.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))h.forEach((m,i)=>{if(m)b[m]=E[i]});else b[R]=E}else b[R]=E;if(N)if(!T&&V&&Array.isArray(E)&&E.length===2)b[N]=E[0],b[R]=E[1];else b[N]=D;let k=Oz(L,b),y=B2(k);if(y.hasContinue){M+=y.content;continue}let g=_2(k);if(g.hasBreak){M+=g.content;break}if(k=j2(k,b),k=G(k,b),k=C1(k,b,Y),k=Lz(k),g=_2(k),g.hasBreak){M+=g.content;break}if(y=B2(k),y.hasContinue){M+=y.content;continue}k=s0(k,b,Y),k=Hz(k,b),k=jz(k,b),M+=k}z=z.substring(0,_)+M+z.substring(B)}catch(F){let O=e("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,s.EVALUATION_ERROR);z=z.substring(0,_)+O+z.substring(B)}}return z}Q=G(Q,Z),Q=L2(Q,Z,Y,J);let K=J?.loops?.maxWhileIterations??_z;return Q=Az(Q,Z,K),Q}function O2($){return s5($)}function L2($,Z,Y,J){let Q=$,X=!0;while(X){X=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=K+G[0].length-1,W=S0(Q,"(",")",q);if(W===-1)break;let z=Q.slice(q+1,W),U=W+1,_=d4(Q.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!O2(z)){let H=e("For",`Unsafe expression in @for: ${z}`,s.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(j),X=!0;continue}try{let H=Vz(z),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let N=wz({forExpr:z,content:B,iterVarNames:H,context:Z,filePath:Y,options:J});Q=Q.substring(0,K)+N+Q.substring(j),X=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(N,R)=>{return`\${${R}}`});V=H2(V);let A=Function(...F,`
|
|
2747
|
+
</style>`}}});var aZ={};r(aZ,{preloadIconCollection:()=>rZ,IconBuiltin:()=>s4});import{existsSync as eq,readFileSync as $z}from"fs";function sZ($){try{return z0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(eq(Y))return Y;return null}function Zz($){if(P1.has($))return P1.get($);let Z=sZ($);if(!Z)return null;try{let Y=JSON.parse($z(Z,"utf8"));return P1.set($,Y.icons),Y.icons}catch{return null}}async function Yz($){if(P1.has($))return P1.get($);let Z=sZ($);if(!Z)return null;try{let Y=await Bun.file(Z).json();return P1.set($,Y.icons),Y.icons}catch{return null}}function Y5($,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 rZ($="lucide"){await Yz($)}var P1,s4;var r4=S(()=>{P1=new Map;s4={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let J=Y5($,"name")??Y5($,"icon");if(!J)return"<!-- Icon: missing name/icon prop -->";let Q="lucide",X=J;if(J.includes(":")){let O=J.split(":");Q=O[0],X=O[1]}let G=i0(Y5($,"size")||"24"),K=i0(Y5($,"color")||"currentColor"),q=i0(Y5($,"class")||""),W=i0(Y5($,"style")||""),z=P1.get(Q)??Zz(Q);if(!z)return`<!-- Icon: collection "${Q}" not loaded -->`;let U=z[X];if(!U)return`<!-- Icon: "${X}" not found in ${Q} -->`;let _=U.width||24,B=U.height||24,j=`0 0 ${_} ${B}`,H=U.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let L=q?` class="${q}"`:"",F=W?` style="${W}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${L}${F}>${H}</svg>`}}});function tZ($,...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 eZ($,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 A3;var N3=S(()=>{A3={name:"Suspense",aliases:["suspense"],render($,Z,Y){let J=eZ(Z,"fallback"),Q=J.rest,X=eZ(Q,"error"),G=X.rest,K=J.region??tZ($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',q=X.region??tZ($,"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>${q}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function a4($,...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 R3;var T3=S(()=>{R3={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let J=(a4($,"name")||"v").replace(/["'<>]/g,""),Q=(a4($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",X=a4($,"class"),G=a4($,"id"),K=[`data-stx-transition-group="${J}"`,X?`class="${X}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${Q} ${K}>${Z}</${Q}>`}}});function $2(){y0.registerBuiltin(J3),y0.registerBuiltin(q3),y0.registerBuiltin(W3),y0.registerBuiltin(B3),y0.registerBuiltin(H3),y0.registerBuiltin(L3),y0.registerBuiltin(V3),y0.registerBuiltin(s4),y0.registerBuiltin(A3),y0.registerBuiltin(R3)}var Z2=S(()=>{X3();z3();U3();j3();O3();F3();w3();r4();N3();T3();Y3();X3();z3();U3();j3();O3();F3();w3();r4();N3();T3()});function Y2($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function J2($,Z,Y){let J=[],Q=0;while(Q<$.length){let X=$.indexOf("<",Q);if(X===-1)break;let K=$.slice(X+1).match(new RegExp(`^(${Z.source})`));if(!K){Q=X+1;continue}let q=K[1];if(Y&&Y.has(q.toLowerCase())){let H=X+1+q.length;while(H<$.length&&$[H]!==">")H++;Q=H+1;continue}let W=X+1+q.length,z=null,U=W,_=-1,B=!1;while(W<$.length){let H=$[W];if(z){if(H==="\\"&&W+1<$.length){W+=2;continue}if(H===z)z=null;W++;continue}if(H==='"'||H==="'"){z=H,W++;continue}if(H==="/"&&W+1<$.length&&$[W+1]===">"){_=W+2,B=!0;break}if(H===">"){_=W+1;break}W++}if(_===-1){Q=X+1;continue}let j=$.slice(U,B?_-2:_-1).trim();if(B)J.push({fullMatch:$.slice(X,_),tagName:q,attributes:j,content:"",startIndex:X,endIndex:_,isSelfClosing:!0}),Q=_;else{let H=`<${q}`,L=`</${q}>`,F=1,O=_,V=-1;while(F>0&&O<$.length){let N=$.indexOf(H,O),R=$.indexOf(L,O);if(R===-1)break;if(N!==-1&&N<R){let T=$[N+H.length];if(T===" "||T===">"||T==="/"||T===`
|
|
2748
|
+
`||T==="\t")F++;O=N+H.length}else{if(F--,F===0){V=R;break}O=R+L.length}}if(V===-1){Q=_;continue}let w=$.slice(_,V),A=V+L.length;J.push({fullMatch:$.slice(X,A),tagName:q,attributes:j,content:w,startIndex:X,endIndex:A,isSelfClosing:!1}),Q=A}}return J}function X2($,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 Q2=S(()=>{R0();A0();t5()});var U2={};r(U2,{processESImports:()=>W2,processComponents:()=>e4});import t4 from"fs";import v0 from"path";function Xz($,Z,Y){let J={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),X=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){J.events[q]=K;continue}if(q.startsWith("__stx_")){let W=X(q.slice(6));J.serverDynamic[W]=X2(K,Y);continue}if(q.startsWith(":")){let W=X(q.slice(1)),z=K==="true"?W:K;try{if(!Q0(z)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${z}`);J.clientReactive[W]=z;continue}let U=Object.keys(Z),B=G0(z,U)(...Object.values(Z));if(B===void 0){let j=z.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!U.includes(F))){J.clientReactive[W]=z;continue}}J.serverDynamic[W]=B}catch{J.clientReactive[W]=z}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let z=W[1];if(Q0(z)){let _=G0(z,Object.keys(Z))(...Object.values(Z));J.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${z}`);J.static[q]=K}}catch(z){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,z);J.static[q]=K}else{let z=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=U.exec(K))!==null)try{let B=_[1];if(!Q0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=G0(B,Object.keys(Z))(...Object.values(Z));z=z.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}J.static[q]=z}continue}J.static[q]=K}return J}function Qz($){let Z={},Y=0,J=$.length;while(Y<J){while(Y<J&&/\s/.test($[Y]))Y++;if(Y>=J)break;let Q="";while(Y<J&&!/[\s=]/.test($[Y]))Q+=$[Y],Y++;if(!Q)break;while(Y<J&&/\s/.test($[Y]))Y++;if(Y<J&&$[Y]==="="){Y++;while(Y<J&&/\s/.test($[Y]))Y++;let X="";if(Y<J&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<J){let K=$[Y];if(K==="\\"&&Y+1<J){Y++,X+=$[Y],Y++;continue}if(K===G){Y++;break}X+=K,Y++}}else while(Y<J&&!/\s/.test($[Y]))X+=$[Y],Y++;Z[Q]=X}else Z[Q]="true"}return Z}function K2($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function Gz($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Y.exec($))!==null){let Q=J[1];if(y0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function Kz($){let Z=q2.get($);if(Z)return Z;let Y=new Map,J=[v0.join($,"src"),v0.join($,"dist"),$];function Q(X,G){if(G>6)return;let K;try{K=t4.readdirSync(X,{withFileTypes:!0})}catch{return}for(let q of K){let W=v0.join(X,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;Q(W,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let z=q.name.slice(0,-4);if(!Y.has(z))Y.set(z,W);let U=z.toLowerCase();if(!Y.has(U))Y.set(U,W);let _=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let X of J)if(Q(X,0),Y.size>0)break;return q2.set($,Y),Y}function qz($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let J=v0.join(Y,"node_modules",$);try{if(t4.statSync(J).isDirectory())return J}catch{}let Q=v0.dirname(Y);if(Q===Y)return null;Y=Q}}async function W2($,Z,Y,J,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let X=Z.__importedComponents,G=v0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(W,z,U)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=U,j,H=[];while((j=_.exec(U))!==null){let[L,F,O,V]=j,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=v0.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let M=`${T}.stx`;try{if(t4.statSync(M).isFile())A=M}catch{try{if(t4.statSync(T).isDirectory())w=T}catch{}}}}else w=qz(V,G);if(!w&&!A)continue;let N=!1,R=(T,M)=>{X.set(T,M),X.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();X.set(I,M),Q.add(M)};if(O&&A)R(O,A),N=!0;else if(F){let T=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?Kz(w):null;for(let{source:I,local:D}of T){let E=null;if(A)E=A;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)R(D,E),N=!0}}if(N)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return W;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${z}>${B}</script>`}),K}async function zz($,Z,Y,J,Q){let X=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(X))!==null){let[W,z]=q,U=z.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of U){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[v0.resolve(v0.dirname(Y),`${_}.stx`),v0.resolve(v0.dirname(Y),_),v0.resolve(J.componentsDir||"components",`${_}.stx`),v0.resolve(J.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),Q.add(F),J.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${_}`)}X=X.replace(W,""),K.lastIndex=0}return X}async function Wz($,Z,Y,J,Q){let X=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,W;while((W=q.exec(X))!==null){let z=W.index,U=z+W[0].length-1,_=1,B=U+1;while(B<X.length&&_>0){if(X[B]==="(")_++;else if(X[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=X.substring(U+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let A={};if(O)try{A=N0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);X=X.replace(X.substring(z,H),`[Error parsing component props: ${E}]`);continue}let N="",R=H,M=X.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)N=M[1].trim(),R=H+M[0].length;let I=await M1(F,A,N,G,Z,Y,J,K,Q);X=X.substring(0,z)+I+X.substring(R),q.lastIndex=0}return X}async function Uz($,Z,Y,J,Q){if(!$)return $;let X=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=E$(X);return X=q.output,X=await _(X,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),X=await _(X,/[A-Z][a-zA-Z0-9]*/,!0),X=await _(X,/[a-z][a-z0-9]*/,!1,Jz),X=k$(X,q.scripts),X;async function _(B,j,H,L){if(!B)return B;let F=B,O=J2(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],A=H?Y2(w.tagName):w.tagName,N=Qz(w.attributes),R=Xz(N,Z,J),T=y0.getBuiltin(w.tagName),M=T?await _9(A,G,Z,Y,J):!1;if(T&&!M){let P={context:Z,filePath:Y,options:J,dependencies:Q},b=T.render(R,w.content,P);if(Object.keys(R.clientReactive).length>0)b=z2(b,R.clientReactive);if(Object.keys(R.events).length>0){let k=Object.entries(R.events).map(([y,g])=>`${y}="${K2(g)}"`).join(" ");b=b.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${k}`)}F=F.substring(0,w.startIndex)+b+F.substring(w.endIndex);continue}let I={};for(let[P,b]of Object.entries(R.static))I[P]=b;for(let[P,b]of Object.entries(R.serverDynamic))I[P]=b;let E=await M1(A,I,w.content,G,Z,Y,J,K,Q);if(Object.keys(R.clientReactive).length>0)E=z2(E,R.clientReactive);if(Object.keys(R.events).length>0){let P=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(P){let b=Object.entries(R.events).map(([y,g])=>`${y}="${K2(g)}"`).join(" "),k=P[1].length+P[2].length;E=E.substring(0,k)+" "+b+E.substring(k)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function z2($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let J=Object.entries(Z).map(([X,G])=>`:${X}="${G.replace(/"/g,""")}"`).join(" "),Q=Y[1].length+Y[2].length;return $.substring(0,Q)+" "+J+$.substring(Q)}async function e4($,Z,Y,J,Q){if(!G2)$2(),G2=!0;let X=await W2($,Z,Y,J,Q);X=await zz(X,Z,Y,J,Q),X=await Wz(X,Z,Y,J,Q);for(let G=0;G<3;G++){let K=X;if(X=await Uz(X,Z,Y,J,Q),X===K)break}if(J.debug){let G=Gz(X);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return X}var G2=!1,Jz,q2;var M3=S(()=>{Y3();Z2();Q2();A0();R0();Jz=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);q2=new Map});var F2={};r(F2,{processLoops:()=>I3});function jz($,Z){let Y=/@component\s*\(/g,J=$,Q,X=[];while((Q=Y.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,W=K+1;while(W<J.length&&q>0){if(J[W]==="(")q++;else if(J[W]===")"){if(q--,q===0)break}W++}if(q!==0)continue;let z=J.substring(K+1,W),U=W+1,_=z.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=z.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=N0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;X.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=X.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=X[G];J=J.substring(0,K)+W+J.substring(q)}return J}function $$($,Z,Y){let J=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),X;while((X=Q.exec(J))!==null){let G=X.index,K=G+X[0].length-1,q=1,W=K+1,z=null,U=!1;while(W<J.length&&q>0){let j=J[W];if(U){U=!1,W++;continue}if(j==="\\"&&z){U=!0,W++;continue}if(z){if(j===z)z=null;W++;continue}if(j==='"'||j==="'"||j==="`"){z=j,W++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}W++}if(q!==0)break;let _=J.substring(K+1,W),B=Y(_);J=J.substring(0,G)+B+J.substring(W+1)}return J}function Hz($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(J,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return J}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(J,Q,X)=>{try{let G=Object.keys(Z),K=Object.values(Z);o5(X);let W=G0(X,G)(...K),z=JSON.stringify(W),U=Buffer.from(z,"utf8").toString("base64");return`__stx_${Q}="${U}"`}catch(G){return J}}),Y}function Oz($,Z){let Y=$;return Y=$$(Y,"@break",(J)=>{try{let X=`!!(${J.trim()})`,G;if(Q0(X)){let K=G0(X,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Y0(X,Z));return G?Z$:""}catch{return""}}),Y=$$(Y,"@continue",(J)=>{try{let X=`!!(${J.trim()})`,G;if(Q0(X)){let K=G0(X,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Y0(X,Z));return G?Y$:""}catch{return""}}),Y}function Lz($){let Z=$;return Z=Z.replace(/@break(?!\()/g,Z$),Z=Z.replace(/@continue(?!\()/g,Y$),Z}function _2($){let Z=$.includes(Z$),Y=Z?$.substring(0,$.indexOf(Z$)):$;return{hasBreak:Z,content:Y}}function B2($){let Z=$.includes(Y$),Y=Z?$.substring(0,$.indexOf(Y$)):$;return{hasContinue:Z,content:Y}}function H2($){let Z=$;return Z=$$(Z,"@break",(Y)=>{let J=Y.trim();if(!s5(J))return"";return`\`; if (${J}) { break; } result += \``}),Z=$$(Z,"@continue",(Y)=>{let J=Y.trim();if(!s5(J))return"";return`\`; if (${J}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Fz($){let Z=/@forelse\s*\(/g,Y,J=[],Q=/@foreach\s*\(/g,X=/@endforeach/g,G;while((G=Q.exec($))!==null)J.push({pos:G.index,delta:1});while((G=X.exec($))!==null)J.push({pos:G.index,delta:-1});J.sort((z,U)=>z.pos-U.pos);let K=[],q=0;for(let z of J)q+=z.delta,K.push({pos:z.pos,depth:q});function W(z){let U=0,_=K.length-1,B=0;while(U<=_){let j=U+_>>1;if(K[j].pos<=z)B=K[j].depth,U=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let z=Y.index,U=Y.index+Y[0].length-1,_=1,B=U+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(U+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,A=V,N=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(w>0&&A<$.length){N.lastIndex=A,R.lastIndex=A;let b=N.exec($),k=R.exec($);if(!k)break;if(b&&b.index<k.index)w++,A=b.index+b[0].length;else{if(w--,w===0){T=k.index;break}A=k.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,P=0;while(P<M.length){let b=M.indexOf("@",P);if(b===-1)break;let k=M.substring(b);if(/^@forelse\s*\(/.test(k))E++,P=b+1;else if(k.startsWith("@endforelse"))E--,P=b+11;else if(E===0&&k.startsWith("@empty")){if(M.length<=b+6||!/[a-z]/i.test(M[b+6])){D=b;break}P=b+1}else P=b+1}if(D===-1)continue;return{start:z,end:I,arrayExpr:F,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function j2($,Z){let Y=$;while(!0){let J=Fz(Y);if(!J)break;let{start:Q,end:X,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:W}=J;try{let z;if(Q0(G))z=G0(G,Object.keys(Z))(...Object.values(Z));else z=Y0(G,Z);let U;if(!Array.isArray(z)||z.length===0)U=W;else U=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,Q)+U+Y.substring(X)}catch(z){let U=z instanceof Error?z.message:String(z),_=e("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,s.EVALUATION_ERROR);Y=Y.substring(0,Q)+_+Y.substring(X)}}return Y}function I3($,Z,Y,J){let Q=$;Q=j2(Q,Z);function X(q){let W=/@foreach\s*\(/g,z;while((z=W.exec(q))!==null){let U=z.index,_=z.index+z[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=U,V=L.substring(0,F),w=L.substring(F+4),A=H+1,N=1,R=A,T=/@foreach\s*\(/g,M=/@endforeach/g;while(N>0&&R<q.length){T.lastIndex=R,M.lastIndex=R;let I=T.exec(q),D=M.exec(q);if(!D)break;if(I&&I.index<D.index)N++,R=I.index+I[0].length;else{if(N--,N===0){let E=q.substring(A,D.index),P=D.index+11;return{start:O,end:P,arrayExpr:V,itemVar:w,content:E}}R=D.index+11}}}return null}function G(q,W){let z=q;while(!0){let U=X(z);if(!U)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=U;try{let F=j.trim(),O;if(Q0(F))O=G0(F,Object.keys(W))(...Object.values(W));else O=Y0(F,W);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=e("Foreach",`Error in @foreach: ${F} is not iterable`,s.TYPE_ERROR);z=z.substring(0,_)+D+z.substring(B);continue}let w=J?.loops?.useAltLoopVariable??Bz,A=H.trim(),N=null,R,T=!1;if(A.includes("=>")){let D=A.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],R=D[1];else R=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let D=A.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],N=D[1],T=!0;else R=A}else R=A;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],P={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},b={...W,loop:P,$loop:P};if(R.startsWith("[")&&R.endsWith("]")){let h=R.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))h.forEach((m,i)=>{if(m)b[m]=E[i]});else b[R]=E}else b[R]=E;if(N)if(!T&&V&&Array.isArray(E)&&E.length===2)b[N]=E[0],b[R]=E[1];else b[N]=D;let k=Oz(L,b),y=B2(k);if(y.hasContinue){M+=y.content;continue}let g=_2(k);if(g.hasBreak){M+=g.content;break}if(k=j2(k,b),k=G(k,b),k=y1(k,b,Y),k=Lz(k),g=_2(k),g.hasBreak){M+=g.content;break}if(y=B2(k),y.hasContinue){M+=y.content;continue}k=s0(k,b,Y),k=Hz(k,b),k=jz(k,b),M+=k}z=z.substring(0,_)+M+z.substring(B)}catch(F){let O=e("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,s.EVALUATION_ERROR);z=z.substring(0,_)+O+z.substring(B)}}return z}Q=G(Q,Z),Q=L2(Q,Z,Y,J);let K=J?.loops?.maxWhileIterations??_z;return Q=Az(Q,Z,K),Q}function O2($){return s5($)}function L2($,Z,Y,J){let Q=$,X=!0;while(X){X=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=K+G[0].length-1,W=S0(Q,"(",")",q);if(W===-1)break;let z=Q.slice(q+1,W),U=W+1,_=d4(Q.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!O2(z)){let H=e("For",`Unsafe expression in @for: ${z}`,s.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(j),X=!0;continue}try{let H=Vz(z),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let N=wz({forExpr:z,content:B,iterVarNames:H,context:Z,filePath:Y,options:J});Q=Q.substring(0,K)+N+Q.substring(j),X=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(N,R)=>{return`\${${R}}`});V=H2(V);let A=Function(...F,`
|
|
2749
2749
|
let result = '';
|
|
2750
2750
|
for (${z}) {
|
|
2751
2751
|
result += \`${V}\`;
|
|
@@ -2755,7 +2755,7 @@ ${E}
|
|
|
2755
2755
|
for (${Z}) {
|
|
2756
2756
|
__pushIter([${J.join(", ")}])
|
|
2757
2757
|
}
|
|
2758
|
-
`),z=[];W(...q,(B)=>{z.push(B)});let U=X??"inline.stx",_="";for(let B of z){let j={...Q};J.forEach((L,F)=>{j[L]=B[F]});let H=L2(Y,j,X,G);H=
|
|
2758
|
+
`),z=[];W(...q,(B)=>{z.push(B)});let U=X??"inline.stx",_="";for(let B of z){let j={...Q};J.forEach((L,F)=>{j[L]=B[F]});let H=L2(Y,j,X,G);H=y1(H,j,U),H=s0(H,j,U),_+=H}return _}function Az($,Z,Y){let J=$,Q=!0;while(Q){Q=!1;let X=J.match(/@while\s*\(/);if(!X||X.index===void 0)break;let G=X.index,K=G+X[0].length-1,q=S0(J,"(",")",K);if(q===-1)break;let W=J.slice(K+1,q),z=d4(J.slice(G),"while","endwhile");if(z.length===0)break;let U=z[0].content,_=G+z[0].end;if(!O2(W)){let B=e("While",`Unsafe expression in @while: ${W}`,s.UNSAFE_EXPRESSION);J=J.substring(0,G)+B+J.substring(_),Q=!0;continue}try{let B=Object.keys(Z),j=Object.values(Z),H=U.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(O,V)=>{return`\${${V}}`});H=H2(H);let F=Function(...B,`
|
|
2759
2759
|
let result = '';
|
|
2760
2760
|
let maxIterations = ${Y}; // Configurable safety limit
|
|
2761
2761
|
let counter = 0;
|
|
@@ -2802,28 +2802,28 @@ ${Tz($).split(",").map((q)=>q.trim()).filter(Boolean).map((q)=>` try { __scopeR
|
|
|
2802
2802
|
} finally {
|
|
2803
2803
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
2804
2804
|
}
|
|
2805
|
-
})();`}function Iz($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let Q=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let X=Y[1],G=Y[2],K=Y[3];return{html:`${X}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function Ez($){if($.__onceStore instanceof Set)return $.__onceStore;return Dz}async function k3($,Z,Y,J,Q,X=new Set){let G=J.partialsDir||U0.join(U0.dirname(Y),"partials");if(G&&!U0.isAbsolute(G))G=U0.resolve(process.cwd(),G);let K=Nz($,"@partial","@include"),q=Ez(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let N=A[1],R=W(N,G,Y),T="";if(R&&await Bun.file(R).exists())Q.add(R),T=`@include(${w})`;K=K.substring(0,L)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let N=K.substring(V+1,A-1),R=E3(N,0);if(R===-1){L.lastIndex=A;continue}let T=N.substring(0,R).trim(),M=N.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=A;continue}let D=I[1],E=M.substring(I[0].length),P,b=E3(E,0);if(b!==-1)P=E.substring(b+1).trim();try{let k=`Boolean(${T})`,y;if(Q0(k)){let m=G0(k,Object.keys(Z));y=Boolean(m(...Object.values(Z)))}else y=Boolean(Y0(k,Z));let g=H?!y:y,h="";if(g){let m=W(D,G,Y);if(m&&await Bun.file(m).exists())Q.add(m);h=`@include('${D}'${P?`, ${P}`:""})`}K=K.substring(0,O)+h+K.substring(A),L.lastIndex=0}catch(k){let y=k instanceof Error?k.message:String(k),g=K0("Include",`Error evaluating ${j} condition: ${y}`,Y,$,O);K=K.substring(0,O)+g+K.substring(A),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),N=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let[,R,T,M,I]=N;try{let D,E=T.trim();if(Q0(E))D=G0(E,Object.keys(Z))(...Object.values(Z));else D=Y0(E,Z);let P="";if(Array.isArray(D)&&D.length>0)for(let b of D){let k={...Z,[M]:b},y=await U(R,k,$,L);P+=y}else if(I)P=await U(I,{},$,L);K=K.substring(0,L)+P+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+K0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),N=w.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let R=N[1],T=w.slice(N[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let P=1,b=1;while(b<T.length&&P>0){if(T[b]==="{")P++;else if(T[b]==="}"){if(P--,P===0)break}b++}M=T.substring(0,b+1),T=T.slice(b+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let P=JSON.parse(R.replace(/'/g,'"')),b={};if(M)try{b=N0(M,Z)}catch(y){let g=y instanceof Error?y.message:String(y);if(J.debug){let h=K0("Include",`Error parsing includeFirst variables: ${g}`,Y,$,L,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>D||"");continue}let k=!1;for(let y of P){let g=W(y,G,Y);if(!g)continue;if(await n(g)){let h=await U(y,b,$,L);K=K.replace(A,()=>h),k=!0;break}}if(!k)if(D!==void 0)K=K.replace(A,()=>D);else if(J.debug){let y=K0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,L,A);K=K.replace(A,()=>y)}else K=K.replace(A,"")}catch(P){let b=P instanceof Error?P.message:String(P),k=K0("Include",`Error processing @includeFirst: ${b}`,Y,$,L,A);K=K.replace(A,()=>k)}j.lastIndex=0}}function W(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=U0.resolve(H),V=U0.resolve(U0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=U0.resolve(H,F);else w=U0.resolve(V,F);let A=U0.normalize(w),N=A.startsWith(O+U0.sep)||A===O,R=A.startsWith(V+U0.sep)||A===V,T=!1,M=U0.dirname(V);if(A.startsWith(M+U0.sep)){if(!U0.relative(M,A).split(U0.sep).some((P)=>P.startsWith(".")&&P!=="."&&P!==".."))T=!0}if(!N&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let z=U0.resolve(Y);X.add(z);async function U(j,H={},L,F){let O=W(j,G,Y);if(!O)return K0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=U0.resolve(O);if(X.has(V)){let w=[...X,V].map((A)=>U0.basename(A)).join(" -> ");return K0("Include",`Circular include detected: ${w}`,Y,L,F)}try{Q.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(h){let m=h instanceof Error?h.message:String(h);return K0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:h}=await Promise.resolve().then(() => (t7(),a7));w=h(w,Z)}if(w&&(J.debug||!M5()&&!E4()))try{let{warnUnbalancedTags:h}=await Promise.resolve().then(() => ($3(),dZ));h(w,O)}catch{}let A=w;try{let{processESImports:h}=await Promise.resolve().then(() => (M3(),U2));await h(w,Z,O,J,Q)}catch(h){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,h instanceof Error?h.message:h)}let N=A.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(N)A=N[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[h,m]of Object.entries(H))I[h]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],P="",b=null;for(let h of E){let m=h[1]||"",i=h[2]||"",l=m.includes("server"),q0=
|
|
2805
|
+
})();`}function Iz($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let Q=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let X=Y[1],G=Y[2],K=Y[3];return{html:`${X}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function Ez($){if($.__onceStore instanceof Set)return $.__onceStore;return Dz}async function k3($,Z,Y,J,Q,X=new Set){let G=J.partialsDir||U0.join(U0.dirname(Y),"partials");if(G&&!U0.isAbsolute(G))G=U0.resolve(process.cwd(),G);let K=Nz($,"@partial","@include"),q=Ez(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let N=A[1],R=W(N,G,Y),T="";if(R&&await Bun.file(R).exists())Q.add(R),T=`@include(${w})`;K=K.substring(0,L)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let N=K.substring(V+1,A-1),R=E3(N,0);if(R===-1){L.lastIndex=A;continue}let T=N.substring(0,R).trim(),M=N.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=A;continue}let D=I[1],E=M.substring(I[0].length),P,b=E3(E,0);if(b!==-1)P=E.substring(b+1).trim();try{let k=`Boolean(${T})`,y;if(Q0(k)){let m=G0(k,Object.keys(Z));y=Boolean(m(...Object.values(Z)))}else y=Boolean(Y0(k,Z));let g=H?!y:y,h="";if(g){let m=W(D,G,Y);if(m&&await Bun.file(m).exists())Q.add(m);h=`@include('${D}'${P?`, ${P}`:""})`}K=K.substring(0,O)+h+K.substring(A),L.lastIndex=0}catch(k){let y=k instanceof Error?k.message:String(k),g=K0("Include",`Error evaluating ${j} condition: ${y}`,Y,$,O);K=K.substring(0,O)+g+K.substring(A),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),N=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let[,R,T,M,I]=N;try{let D,E=T.trim();if(Q0(E))D=G0(E,Object.keys(Z))(...Object.values(Z));else D=Y0(E,Z);let P="";if(Array.isArray(D)&&D.length>0)for(let b of D){let k={...Z,[M]:b},y=await U(R,k,$,L);P+=y}else if(I)P=await U(I,{},$,L);K=K.substring(0,L)+P+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+K0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),N=w.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let R=N[1],T=w.slice(N[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let P=1,b=1;while(b<T.length&&P>0){if(T[b]==="{")P++;else if(T[b]==="}"){if(P--,P===0)break}b++}M=T.substring(0,b+1),T=T.slice(b+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let P=JSON.parse(R.replace(/'/g,'"')),b={};if(M)try{b=N0(M,Z)}catch(y){let g=y instanceof Error?y.message:String(y);if(J.debug){let h=K0("Include",`Error parsing includeFirst variables: ${g}`,Y,$,L,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>D||"");continue}let k=!1;for(let y of P){let g=W(y,G,Y);if(!g)continue;if(await n(g)){let h=await U(y,b,$,L);K=K.replace(A,()=>h),k=!0;break}}if(!k)if(D!==void 0)K=K.replace(A,()=>D);else if(J.debug){let y=K0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,L,A);K=K.replace(A,()=>y)}else K=K.replace(A,"")}catch(P){let b=P instanceof Error?P.message:String(P),k=K0("Include",`Error processing @includeFirst: ${b}`,Y,$,L,A);K=K.replace(A,()=>k)}j.lastIndex=0}}function W(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=U0.resolve(H),V=U0.resolve(U0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=U0.resolve(H,F);else w=U0.resolve(V,F);let A=U0.normalize(w),N=A.startsWith(O+U0.sep)||A===O,R=A.startsWith(V+U0.sep)||A===V,T=!1,M=U0.dirname(V);if(A.startsWith(M+U0.sep)){if(!U0.relative(M,A).split(U0.sep).some((P)=>P.startsWith(".")&&P!=="."&&P!==".."))T=!0}if(!N&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let z=U0.resolve(Y);X.add(z);async function U(j,H={},L,F){let O=W(j,G,Y);if(!O)return K0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=U0.resolve(O);if(X.has(V)){let w=[...X,V].map((A)=>U0.basename(A)).join(" -> ");return K0("Include",`Circular include detected: ${w}`,Y,L,F)}try{Q.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(h){let m=h instanceof Error?h.message:String(h);return K0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:h}=await Promise.resolve().then(() => (t7(),a7));w=h(w,Z)}if(w&&(J.debug||!M5()&&!E4()))try{let{warnUnbalancedTags:h}=await Promise.resolve().then(() => ($3(),dZ));h(w,O)}catch{}let A=w;try{let{processESImports:h}=await Promise.resolve().then(() => (M3(),U2));await h(w,Z,O,J,Q)}catch(h){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,h instanceof Error?h.message:h)}let N=A.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(N)A=N[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[h,m]of Object.entries(H))I[h]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],P="",b=null;for(let h of E){let m=h[1]||"",i=h[2]||"",l=m.includes("server"),q0=w1(m),V0="";try{let{extractAndStripCssImports:Z0,renderVendorStyleTags:k0}=await Promise.resolve().then(() => (j5(),D6)),f0=Z0(i,{filePath:O,projectRoot:process.cwd()});i=f0.code,V0=k0(f0.styles)}catch(Z0){if(J.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,Z0 instanceof Error?Z0.message:Z0)}if(q0&&i.trim())i=A1(i);if(!l)try{let{hasUserImports:Z0,bundleClientScript:k0}=await Promise.resolve().then(() => (i5(),c5));if(Z0(i))i=await k0(i,O,{projectRoot:process.cwd()})}catch(Z0){if(J.debug)console.warn(`[stx] bundler skipped for ${O}:`,Z0 instanceof Error?Z0.message:Z0)}let _0=Rz(i);if(_0&&!l){b=`stx_scope_${U0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++V2}`;let Z0=$1(i),k0=Mz(Z0,b);P+=`${V0}<script data-stx-scoped>${k0}</script>
|
|
2806
2806
|
`;continue}if(l)try{let{extractVariables:Z0}=await Promise.resolve().then(() => (N5(),Y4));await Z0(i,I,O)}catch(Z0){if(J.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,Z0)}if(!l&&!_0){let Z0=m.replace(/\bclient\b/i,"").trim();b=`stx_scope_${U0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++V2}`;let k0=$1(i),f0=`
|
|
2807
2807
|
if (!window.stx._scopes) window.stx._scopes = {};
|
|
2808
2808
|
window.stx._scopes['${b}'] = { __destroyCallbacks: __destroyHooks };
|
|
2809
2809
|
`,v=w2(k0,f0);P+=`${V0}<script data-stx-scoped${Z0?` ${Z0}`:""}>${v}</script>
|
|
2810
|
-
`}}if(b){let h=Iz(A,b);if(A=h.html,h.mergedIntoExisting)P=P.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${h.mergedIntoExisting}']`),b=h.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await k3(A,I,O,J,Q,X);let{processLoops:k}=await Promise.resolve().then(() => (D3(),F2)),y=k(A,I,O);y=
|
|
2810
|
+
`}}if(b){let h=Iz(A,b);if(A=h.html,h.mergedIntoExisting)P=P.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${h.mergedIntoExisting}']`),b=h.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await k3(A,I,O,J,Q,X);let{processLoops:k}=await Promise.resolve().then(() => (D3(),F2)),y=k(A,I,O);y=y1(y,I,O);let g=m1(w);if(y=s0(y,I,O,{forceSignals:g}),M)y+=`
|
|
2811
2811
|
`+M;if(P)y+=`
|
|
2812
2812
|
`+P;return y}catch(w){let A=w instanceof Error?w.message:String(w);return K0("Include",`Error processing include ${j}: ${A}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,H=j+B[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){_.lastIndex=F;continue}let A=w[1],N,R=V.substring(w[0].length),T=E3(R,0);if(T!==-1)N=R.substring(T+1).trim();let M={};if(N)try{M=N0(N,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,K0("Include",`Error parsing include variables for ${A}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await U(A,M,$,j);K=K.substring(0,j)+I+K.substring(F),_.lastIndex=0}return K}function b3($,Z){let Y=$;function J(Q,X,G,K){let q=Q,W=!0;while(W){W=!1;let z=new RegExp(`@${X}\\(['"]([^'"]+)['"]\\)`),U=q.match(z);if(!U||U.index===void 0)break;let _=U.index,B=U[1],j=_+U[0].length,H=new RegExp(`@${X}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<q.length){let A=q.slice(O),N=A.match(H),R=A.match(L),T=N?O+N.index:1/0,M=R?O+R.index:1/0;if(T<M)F++,O=T+(N[0].length||1);else if(M<1/0){if(F--,F===0){V=M;break}O=M+G.length+1}else break}if(V===-1)break;let w=q.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(w);else Z[B].push(w);q=q.substring(0,_)+q.substring(V+`@${G}`.length),W=!0}return q}return Y=J(Y,"push","endpush",!1),Y=J(Y,"prepend","endprepend",!0),Y}function S3($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,J)=>{if(!Z[J]||Z[J].length===0)return"";return Z[J].join(`
|
|
2813
|
-
`)})}var V2=0,TF,Dz;var A2=S(()=>{u4();r0();
|
|
2813
|
+
`)})}var V2=0,TF,Dz;var A2=S(()=>{u4();r0();l1();R0();A0();TF=new F5(500),Dz=new Set});import*as y3 from"path";async function N2($,Z,Y=""){if(y3.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 T2($,Z,Y,"@js","@endjs")}async function R2($,Z,Y=""){if(y3.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((X)=>({...X,displayName:`User ${X.id}: ${X.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return T2($,Z,Y,"@ts","@endts")}async function T2($,Z,Y,J,Q){let X=$,G=p1(`${J}([\\s\\S]*?)${Q}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:W,content:z,index:U}of K)try{let _=Object.keys(Z),B=Object.values(Z),j=z.trim();if(J==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let L=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((A)=>A.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=L.length>0?`return { ${L.join(", ")} };`:"return {};",O=`
|
|
2814
2814
|
${j}
|
|
2815
2815
|
${F}
|
|
2816
|
-
`,w=Function(..._,O)(...B);if(w&&typeof w==="object")Object.assign(Z,w);X=X.replace(W,"")}catch(_){console.error(`Error executing ${J} code block in ${Y}:`,_);let B=_ instanceof Error?_.message:String(_),j=K0(`${J} Directive`,`Error executing code: ${B}`,Y,$,U,W);console.error(j),X=X.replace(W,"")}return X}var M2=S(()=>{
|
|
2816
|
+
`,w=Function(..._,O)(...B);if(w&&typeof w==="object")Object.assign(Z,w);X=X.replace(W,"")}catch(_){console.error(`Error executing ${J} code block in ${Y}:`,_);let B=_ instanceof Error?_.message:String(_),j=K0(`${J} Directive`,`Error executing code: ${B}`,Y,$,U,W);console.error(j),X=X.replace(W,"")}return X}var M2=S(()=>{l1();A0()});function kz($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function I2($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,J,Q,X)=>{return kz(J,X||"_method")})}async function D2($,Z,Y,J,Q){if(!J.middleware||J.middleware.length===0)return $;let X=$,G=J.middleware.filter((K)=>K.timing===Q);if(G.length===0)return X;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(J.debug)console.warn("Invalid middleware:",K);continue}try{let q=await K.handler(X,Z,Y,J);if(typeof q==="string")X=q;else if(J.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(q){if(J.debug)console.error(`Error in middleware ${K.name}:`,q);if(J.debug){let W=K0("Middleware",`Error in middleware '${K.name}': ${q instanceof Error?q.message:String(q)}`,Y,$);X=X.replace(/<body[^>]*>/,`$&
|
|
2817
2817
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${u0(W)}</div>
|
|
2818
|
-
`)}}}return X}async function E2($,Z,Y,J){return D2($,Z,Y,J,"before")}async function k2($,Z,Y,J){return D2($,Z,Y,J,"after")}var b2=S(()=>{r0();A0()});import{defineRoute as fF,defineRoutes as gF,resetRoutes as hF,route as dF,setAppUrl as mF}from"stx-router";import{route as bz}from"stx-router";function S2($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,J,Q,X)=>{try{let G=Q?N0(Q,{}):{};return bz(J,G,X==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var y2=S(()=>{R0()});async function C2($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(f5.exact[$])for(let J of f5.exact[$])await Promise.resolve(J(Z,$));if(f5.exact[Y])for(let J of f5.exact[Y])await Promise.resolve(J(Z,$));for(let{pattern:J,callback:Q}of f5.patterns)if(J.test($)||J.test(Y))await Promise.resolve(Q(Z,$))}var f5;var P2=S(()=>{f5={patterns:[],exact:{}}});function v2($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>v2(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function x2($,Z){if(!/:[\w-]+=/.test($))return $;let Y=$,J=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,Q=[],X;while((X=J.exec($))!==null)Q.push([X.index,X.index+X[0].length]);function G(W){return Q.some(([z,U])=>W>=z&&W<U)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,q=[];while((X=K.exec(Y))!==null){if(G(X.index))continue;let W=X[0],z=X[2];if(!z||!z.includes(":"))continue;let U=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,_,B=z,j=!1;while((_=U.exec(z))!==null){let H=_[1],L=_[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let F=Object.keys(Z),O=Object.values(Z),V=L.match(/^([a-zA-Z_$][\w$]*)/);if(V&&!F.includes(V[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(V[1]))continue;let A=Function(...F,`return (${L})`)(...O);if(H==="class"){let N=v2(A);if(N){let R=B.match(/\sclass="([^"]*)"/);if(R)B=B.replace(R[0],` class="${R[1]} ${N}"`);else B=B.replace(_[0],` class="${N}"`)}else B=B.replace(_[0],"");j=!0;continue}if(Sz.has(H)){if(A)B=B.replace(_[0],` ${H}`);else B=B.replace(_[0],"");j=!0;continue}if(A===null||A===void 0||A===!1)B=B.replace(_[0],"");else{let N=String(A).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");B=B.replace(_[0],` ${H}="${N}"`)}j=!0}catch{continue}}if(j){let H=W.endsWith("/>")?" /":"",F=`<${X[1]}${B}${H}>`;q.push({start:X.index,end:X.index+W.length,replacement:F})}}for(let W=q.length-1;W>=0;W--){let{start:z,end:U,replacement:_}=q[W];Y=Y.slice(0,z)+_+Y.slice(U)}return Y}var Sz;var f2=S(()=>{Sz=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function
|
|
2818
|
+
`)}}}return X}async function E2($,Z,Y,J){return D2($,Z,Y,J,"before")}async function k2($,Z,Y,J){return D2($,Z,Y,J,"after")}var b2=S(()=>{r0();A0()});import{defineRoute as fF,defineRoutes as gF,resetRoutes as hF,route as dF,setAppUrl as mF}from"stx-router";import{route as bz}from"stx-router";function S2($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,J,Q,X)=>{try{let G=Q?N0(Q,{}):{};return bz(J,G,X==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var y2=S(()=>{R0()});async function C2($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(f5.exact[$])for(let J of f5.exact[$])await Promise.resolve(J(Z,$));if(f5.exact[Y])for(let J of f5.exact[Y])await Promise.resolve(J(Z,$));for(let{pattern:J,callback:Q}of f5.patterns)if(J.test($)||J.test(Y))await Promise.resolve(Q(Z,$))}var f5;var P2=S(()=>{f5={patterns:[],exact:{}}});function v2($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>v2(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function x2($,Z){if(!/:[\w-]+=/.test($))return $;let Y=$,J=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,Q=[],X;while((X=J.exec($))!==null)Q.push([X.index,X.index+X[0].length]);function G(W){return Q.some(([z,U])=>W>=z&&W<U)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,q=[];while((X=K.exec(Y))!==null){if(G(X.index))continue;let W=X[0],z=X[2];if(!z||!z.includes(":"))continue;let U=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,_,B=z,j=!1;while((_=U.exec(z))!==null){let H=_[1],L=_[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let F=Object.keys(Z),O=Object.values(Z),V=L.match(/^([a-zA-Z_$][\w$]*)/);if(V&&!F.includes(V[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(V[1]))continue;let A=Function(...F,`return (${L})`)(...O);if(H==="class"){let N=v2(A);if(N){let R=B.match(/\sclass="([^"]*)"/);if(R)B=B.replace(R[0],` class="${R[1]} ${N}"`);else B=B.replace(_[0],` class="${N}"`)}else B=B.replace(_[0],"");j=!0;continue}if(Sz.has(H)){if(A)B=B.replace(_[0],` ${H}`);else B=B.replace(_[0],"");j=!0;continue}if(A===null||A===void 0||A===!1)B=B.replace(_[0],"");else{let N=String(A).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");B=B.replace(_[0],` ${H}="${N}"`)}j=!0}catch{continue}}if(j){let H=W.endsWith("/>")?" /":"",F=`<${X[1]}${B}${H}>`;q.push({start:X.index,end:X.index+W.length,replacement:F})}}for(let W=q.length-1;W>=0;W--){let{start:z,end:U,replacement:_}=q[W];Y=Y.slice(0,z)+_+Y.slice(U)}return Y}var Sz;var f2=S(()=>{Sz=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function v1($,Z){let Y=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;Y.lastIndex=Z;let J=Y.exec($);if(!J)return null;return{full:J[0],tag:J[1],attrs:J[2],selfClosing:J[3].includes("/")||yz.has(J[1].toLowerCase()),start:J.index,end:J.index+J[0].length}}function Pz($,Z,Y){let J=1,Q=Y,X=new RegExp(`<${Z}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),G=new RegExp(`</${Z}\\s*>`,"gi");while(J>0&&Q<$.length){X.lastIndex=Q,G.lastIndex=Q;let K=X.exec($),q=G.exec($);if(!q)return-1;if(K&&K.index<q.index)J++,Q=K.index+K[0].length;else{if(J--,J===0)return q.index+q[0].length;Q=q.index+q[0].length}}return-1}function a0($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=Pz($,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 g2($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function J5($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return J?J[1]:null}function B1($,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 j1($,Z,Y){let J=Z.selfClosing?" /":"",Q=`<${Z.tag}${Y}${J}>`;return $.slice(0,Z.start)+Q+$.slice(Z.end)}function vz($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function xz($){let Z=$,Y=0;while(Y<Z.length){let J=v1(Z,Y);if(!J)break;let Q=J5(J.attrs,"v-for");if(Q===null){Y=J.end;continue}let X=Q.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!X){Y=J.end;continue}let G=X[1].trim(),K=X[2].trim(),q;if(G.includes(",")){let L=G.split(",").map((V)=>V.trim()),F=L[0],O=L[1];q=`${K} as ${O} => ${F}`}else q=`${K} as ${G}`;let W=B1(J.attrs,"v-for"),z=B1(W,":key").replace(/\s*v-bind:key="[^"]*"/g,""),U=a0(Z,J),_=Z.slice(U.outerStart,U.outerEnd),B=j1(_,{...J,start:0,end:J.end-J.start},z),j=`@foreach(${q})
|
|
2819
2819
|
`,H=`${j}${B}
|
|
2820
|
-
@endforeach`;Z=Z.slice(0,U.outerStart)+H+Z.slice(U.outerEnd),Y=U.outerStart+j.length}return Z}function fz($){let Z=$,Y=0;while(Y<Z.length){let J=
|
|
2820
|
+
@endforeach`;Z=Z.slice(0,U.outerStart)+H+Z.slice(U.outerEnd),Y=U.outerStart+j.length}return Z}function fz($){let Z=$,Y=0;while(Y<Z.length){let J=v1(Z,Y);if(!J)break;let Q=J5(J.attrs,"v-if");if(Q===null){Y=J.end;continue}let X=[],G=a0(Z,J),K=B1(J.attrs,"v-if"),q=j1(Z.slice(G.outerStart,G.outerEnd),{...J,start:0,end:J.end-J.start},K);X.push({type:"if",expr:Q,outerStart:G.outerStart,outerEnd:G.outerEnd,element:q,parsedTag:J});let W=G.outerEnd,z=!0;while(z){let H=Z.slice(W).match(/^\s*/),L=H?H[0].length:0,F=v1(Z,W+L);if(!F){z=!1;break}let O=J5(F.attrs,"v-else-if"),V=g2(F.attrs,"v-else");if(O!==null){let w=a0(Z,F),A=B1(F.attrs,"v-else-if"),N=j1(Z.slice(w.outerStart,w.outerEnd),{...F,start:0,end:F.end-F.start},A);X.push({type:"else-if",expr:O,outerStart:W,outerEnd:w.outerEnd,element:N,parsedTag:F}),W=w.outerEnd}else if(V){let w=a0(Z,F),A=B1(F.attrs,"v-else"),N=j1(Z.slice(w.outerStart,w.outerEnd),{...F,start:0,end:F.end-F.start},A);X.push({type:"else",outerStart:W,outerEnd:w.outerEnd,element:N,parsedTag:F}),z=!1}else z=!1}let U=[];for(let H of X)if(H.type==="if")U.push(`@if(${H.expr})
|
|
2821
2821
|
${H.element}`);else if(H.type==="else-if")U.push(`@elseif(${H.expr})
|
|
2822
2822
|
${H.element}`);else U.push(`@else
|
|
2823
2823
|
${H.element}`);U.push("@endif");let _=U.join(`
|
|
2824
|
-
`),B=X[0].outerStart,j=X[X.length-1].outerEnd;Z=Z.slice(0,B)+_+Z.slice(j),Y=B+_.length}return Z}function gz($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function hz($){let Z=$,Y=0;while(Y<Z.length){let J=
|
|
2825
|
-
${
|
|
2826
|
-
@endonce`;Z=Z.slice(0,X.outerStart)+q+Z.slice(X.outerEnd),Y=X.outerStart+q.length}return Z}function iz($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function nz($){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 h2($){if(!vz($))return $;let Z=$;return Z=xz(Z),Z=fz(Z),Z=cz(Z),Z=dz(Z),Z=mz(Z),Z=hz(Z),Z=gz(Z),Z=nz(Z),Z=uz(Z),Z=pz(Z),Z=lz(Z),Z=iz(Z),Z}var yz,Cz;var d2=S(()=>{yz=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Cz=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 J$($){return $.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}async function m2($,Z,Y,J,Q){let X=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],q;while((q=G.exec(X))!==null)K.push({full:q[0],expr:q[1],attrs:q[2],slotContent:q[3],index:q.index});for(let W=K.length-1;W>=0;W--){let z=K[W];try{let U=Y0(z.expr,Z);if(!U||typeof U!=="string"){let O=`<!-- dynamic component: could not resolve "${J$(z.expr)}" -->`;X=X.slice(0,z.index)+O+X.slice(z.index+z.full.length);continue}let _=z.attrs.trim(),B={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,H;while((H=j.exec(_))!==null){let O=H[1]||H[2],V=H[3];if(H[1])try{B[O]=Y0(V,Z)}catch{B[O]=V}else B[O]=V}let L=J.componentsDir||"components",F=await
|
|
2824
|
+
`),B=X[0].outerStart,j=X[X.length-1].outerEnd;Z=Z.slice(0,B)+_+Z.slice(j),Y=B+_.length}return Z}function gz($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function hz($){let Z=$,Y=0;while(Y<Z.length){let J=v1(Z,Y);if(!J)break;let Q=J.attrs,X=!1,G=/v-model:([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z.]+))?\s*=\s*"([^"]*)"/,K=Q.match(G);while(K){X=!0;let z=K[1],U=K[2],_=K[3];Q=Q.replace(K[0],""),Q+=` :${z}="${_}" @update:${z}="${_} = $event"`,K=Q.match(G)}if(X){let z=a0(Z,J),U=Z.slice(z.outerStart,z.outerEnd),_=j1(U,{...J,start:0,end:J.end-J.start},Q);Z=Z.slice(0,z.outerStart)+_+Z.slice(z.outerEnd),Y=z.outerStart+_.length;continue}let q=J5(J.attrs,"v-model");if(q===null){Y=J.end;continue}if(Cz.has(J.tag.toLowerCase())){let z=J.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${q}"`,U=a0(Z,J),_=Z.slice(U.outerStart,U.outerEnd),B=j1(_,{...J,start:0,end:J.end-J.start},z);Z=Z.slice(0,U.outerStart)+B+Z.slice(U.outerEnd),Y=U.outerStart+B.length}else{let z=J.attrs.replace(/\s*v-model="[^"]*"/g,"");z+=` :modelValue="${q}" @update:modelValue="${q} = $event"`;let U=a0(Z,J),_=Z.slice(U.outerStart,U.outerEnd),B=j1(_,{...J,start:0,end:J.end-J.start},z);Z=Z.slice(0,U.outerStart)+B+Z.slice(U.outerEnd),Y=U.outerStart+B.length}}return Z}function dz($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function mz($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function uz($){let Z=$,Y=0;while(Y<Z.length){let J=v1(Z,Y);if(!J)break;let Q=J5(J.attrs,"v-html");if(Q===null){Y=J.end;continue}if(J.selfClosing){Y=J.end;continue}let X=a0(Z,J),G=B1(J.attrs,"v-html"),K=J.selfClosing?" /":"",q=`<${J.tag}${G}${K}>{!! ${Q} !!}</${J.tag}>`;Z=Z.slice(0,X.outerStart)+q+Z.slice(X.outerEnd),Y=X.outerStart+q.length}return Z}function pz($){let Z=$,Y=0;while(Y<Z.length){let J=v1(Z,Y);if(!J)break;let Q=J5(J.attrs,"v-text");if(Q===null){Y=J.end;continue}if(J.selfClosing){Y=J.end;continue}let X=a0(Z,J),G=B1(J.attrs,"v-text"),K=J.selfClosing?" /":"",q=`<${J.tag}${G}${K}>{{ ${Q} }}</${J.tag}>`;Z=Z.slice(0,X.outerStart)+q+Z.slice(X.outerEnd),Y=X.outerStart+q.length}return Z}function lz($){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 cz($){let Z=$,Y=0;while(Y<Z.length){let J=v1(Z,Y);if(!J)break;if(!g2(J.attrs,"v-once")){Y=J.end;continue}let Q=B1(J.attrs,"v-once"),X=a0(Z,J),G=Z.slice(X.outerStart,X.outerEnd),q=`@once
|
|
2825
|
+
${j1(G,{...J,start:0,end:J.end-J.start},Q)}
|
|
2826
|
+
@endonce`;Z=Z.slice(0,X.outerStart)+q+Z.slice(X.outerEnd),Y=X.outerStart+q.length}return Z}function iz($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function nz($){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 h2($){if(!vz($))return $;let Z=$;return Z=xz(Z),Z=fz(Z),Z=cz(Z),Z=dz(Z),Z=mz(Z),Z=hz(Z),Z=gz(Z),Z=nz(Z),Z=uz(Z),Z=pz(Z),Z=lz(Z),Z=iz(Z),Z}var yz,Cz;var d2=S(()=>{yz=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Cz=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 J$($){return $.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}async function m2($,Z,Y,J,Q){let X=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],q;while((q=G.exec(X))!==null)K.push({full:q[0],expr:q[1],attrs:q[2],slotContent:q[3],index:q.index});for(let W=K.length-1;W>=0;W--){let z=K[W];try{let U=Y0(z.expr,Z);if(!U||typeof U!=="string"){let O=`<!-- dynamic component: could not resolve "${J$(z.expr)}" -->`;X=X.slice(0,z.index)+O+X.slice(z.index+z.full.length);continue}let _=z.attrs.trim(),B={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,H;while((H=j.exec(_))!==null){let O=H[1]||H[2],V=H[3];if(H[1])try{B[O]=Y0(V,Z)}catch{B[O]=V}else B[O]=V}let L=J.componentsDir||"components",F=await M1(U,B,z.slotContent,L,Z,Y,J,new Set,Q??new Set);X=X.slice(0,z.index)+F+X.slice(z.index+z.full.length)}catch(U){let _=U instanceof Error?U.message:String(U),B=`<!-- dynamic component error: ${J$(_)} -->`;X=X.slice(0,z.index)+B+X.slice(z.index+z.full.length)}}return X=await oz(X,Z,Y,J,Q),X}async function oz($,Z,Y,J,Q){let X=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,K=[],q;while((q=G.exec(X))!==null)K.push({full:q[0],expr:q[1],attrs:q[2],index:q.index});for(let W=K.length-1;W>=0;W--){let z=K[W];try{let U=Y0(z.expr,Z);if(!U||typeof U!=="string"){let j=`<!-- dynamic component: could not resolve "${J$(z.expr)}" -->`;X=X.slice(0,z.index)+j+X.slice(z.index+z.full.length);continue}let _=J.componentsDir||"components",B=await M1(U,{},"",_,Z,Y,J,new Set,Q??new Set);X=X.slice(0,z.index)+B+X.slice(z.index+z.full.length)}catch(U){let _=U instanceof Error?U.message:String(U),B=`<!-- dynamic component error: ${J$(_)} -->`;X=X.slice(0,z.index)+B+X.slice(z.index+z.full.length)}}return X}var u2=S(()=>{A0();R0()});function p2($){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>
|
|
2827
2827
|
${$.slice(Z)}`}function sz($,Z={},Y={}){let{title:J="stx App",lang:Q="en",meta:X=[],link:G=[],script:K=[],headRaw:q="",bodyClass:W="",bodyAttrs:z={}}=Z,U=Y.title||J,j=[...[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],...X].map((A)=>{return` <meta ${Object.entries(A).map(([R,T])=>`${R}="${T}"`).join(" ")}>`}).join(`
|
|
2828
2828
|
`),H=G.map((A)=>{return` <link ${Object.entries(A).map(([R,T])=>`${R}="${T}"`).join(" ")}>`}).join(`
|
|
2829
2829
|
`),L=K.map((A)=>{if(A.src)return` <script ${Object.entries(A).filter(([R])=>R!=="content").map(([R,T])=>`${R}="${T}"`).join(" ")}></script>`;if(A.content)return` <script>${A.content}</script>`;return""}).filter(Boolean).join(`
|
|
@@ -8060,7 +8060,7 @@ catch (e) { console.warn('[stx] mount callback error:', e); }
|
|
|
8060
8060
|
}
|
|
8061
8061
|
}
|
|
8062
8062
|
})();
|
|
8063
|
-
`}var $W;var o2=S(()=>{g3();g3();$W={state:G$,derived:K$,effect:q$,batch:P3,onMount:v3,onDestroy:x3,isSignal:z$,isDerived:W$,untrack:f3,peek:U$,generateSignalsRuntime:i2,generateSignalsRuntimeDev:_$}});var h3={};r(h3,{templateCache:()=>s2,readFileCached:()=>ZW,invalidateFileCacheByDir:()=>JW,invalidateFileCache:()=>YW,hashFilePath:()=>h5,getCachedSignalsRuntime:()=>GW,getCachedRouterScript:()=>KW,clearDevCaches:()=>qW,checkCache:()=>zW,cacheTemplate:()=>WW,__setSignalsGeneratorsForTest:()=>QW});import
|
|
8063
|
+
`}var $W;var o2=S(()=>{g3();g3();$W={state:G$,derived:K$,effect:q$,batch:P3,onMount:v3,onDestroy:x3,isSignal:z$,isDerived:W$,untrack:f3,peek:U$,generateSignalsRuntime:i2,generateSignalsRuntimeDev:_$}});var h3={};r(h3,{templateCache:()=>s2,readFileCached:()=>ZW,invalidateFileCacheByDir:()=>JW,invalidateFileCache:()=>YW,hashFilePath:()=>h5,getCachedSignalsRuntime:()=>GW,getCachedRouterScript:()=>KW,clearDevCaches:()=>qW,checkCache:()=>zW,cacheTemplate:()=>WW,__setSignalsGeneratorsForTest:()=>QW});import H1 from"fs";import X5 from"path";async function ZW($){let Y;for(let J=0;J<3;J++)try{let X=(await H1.promises.stat($)).mtime.getTime(),G=x1.get($);if(G&&G.mtime===X)return G.content;let K=await Bun.file($).text(),W=(await H1.promises.stat($)).mtime.getTime();if(W!==X)continue;return x1.set($,{content:K,mtime:W}),K}catch(Q){Y=Q;break}throw x1.delete($),Error(`File not found: ${$}${Y?` (${Y.message})`:""}`)}function YW($){x1.delete($)}function JW($){for(let Z of x1.keys())if(Z.startsWith($))x1.delete(Z)}function QW($){r2=$}async function GW($=!1){let Z=r2??await Promise.resolve().then(() => (o2(),n2));if($)return Z.generateSignalsRuntimeDev();if(B$===null)B$=Z.generateSignalsRuntime();return B$}async function KW(){if(j$===null){let{getRouterScript:$}=await import("stx-router");j$=$()}return j$}function qW(){x1.clear(),B$=null,XW=null,j$=null}function a2($){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 zW($,Z){try{if(!Z.cachePath)return null;let Y=X5.resolve(Z.cachePath),J=X5.join(Y,`${h5($)}.html`),Q=X5.join(Y,`${h5($)}.meta.json`);if(!await n(J)||!await n(Q))return null;let X=await Bun.file(Q).text(),G=JSON.parse(X);if(G.cacheVersion!==Z.cacheVersion)return null;if(G.optionsSignature!==a2(Z))return null;if((await H1.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let q of G.dependencies)if(await n(q)){if((await H1.promises.stat(q)).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 WW($,Z,Y,J){try{if(!J.cachePath)return;let Q=X5.resolve(J.cachePath);await H1.promises.mkdir(Q,{recursive:!0});let X=X5.join(Q,`${h5($)}.html`),G=X5.join(Q,`${h5($)}.meta.json`),K=await H1.promises.stat($);await Bun.write(X,Z);let q={sourcePath:$,mtime:K.mtime.getTime(),dependencies:Array.from(Y),cacheVersion:J.cacheVersion,optionsSignature:a2(J),generatedAt:Date.now()};await Bun.write(G,JSON.stringify(q,null,2)),s2.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(Q){console.warn(`Failed to cache template ${$}:`,Q)}}function h5($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,UW)}var s2,x1,B$=null,XW=null,r2=null,j$=null,UW=16;var d3=S(()=>{A0();s2=new Map,x1=new Map});function t2($){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]+`
|
|
8064
8064
|
`;let Q=/\{\{([\s\S]*?)\}\}/g;while((J=Q.exec($))!==null)Y+=J[1]+`
|
|
8065
8065
|
`;if(!Y.trim())return $;let G=["browserQuery","BrowserQueryBuilder","configureBrowser","createBrowserModel"].some((_)=>{return new RegExp(`\\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"]),q=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,W,z=!1;while((W=q.exec(Y))!==null)if(!K.has(W[1])){z=!0;break}if(!G&&!z)return $;let U=`<script type="module">
|
|
8066
8066
|
// STX: Auto-load @stacksjs/browser (auto-initializes API and loads models)
|
|
@@ -8081,7 +8081,7 @@ ${U}`);return U+`
|
|
|
8081
8081
|
</body>`+$.slice(G+7)}var qY={};r(qY,{scanScriptTags:()=>XY,processSignals:()=>i3,processScriptSetup:()=>GY,preEvalLiteralReactiveIfs:()=>l3,parseLoopExpression:()=>QY,hasSignalsSyntax:()=>L$,extractExports:()=>KY,convertSignalLoopsToAttributes:()=>c3,convertSignalDirectivesToAttributes:()=>p3});function XY($,Z={}){let Y=[];H$.lastIndex=0;let J;while((J=H$.exec($))!==null){let Q=J[1],X=J.index+J[0].length,G=$.toLowerCase().indexOf("</script>",X);if(G===-1)break;let K=G+9;if(Z.skipAttrs&&Z.skipAttrs.test(Q)){H$.lastIndex=K;continue}Y.push({fullMatch:$.slice(J.index,K),attrs:Q,body:$.slice(X,G),start:J.index,end:K}),H$.lastIndex=K}return Y}function QY($){let Z=$.trim(),Y=Z.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(Y){let Q=Y[1].trim(),X=Y[2].trim(),{itemVar:G,indexVar:K}=$Y(X);if(G)return{style:"as",iterable:Q,itemVar:G,indexVar:K}}let J=Z.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(J){let Q=J[1].trim(),X=J[2].trim(),{itemVar:G,indexVar:K}=$Y(Q);if(G)return{style:"in",iterable:X,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function $Y($){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 Q=Z.match(/^(\w+)\s*,\s*(\w+)$/);if(Q)return{itemVar:Q[1],indexVar:Q[2]};let X=Z.match(/^(\w+)$/);if(X)return{itemVar:X[1],indexVar:null};return{itemVar:null,indexVar:null}}function L$($){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*\(/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/].some((Y)=>Y.test($))}function BW($){let Z=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,Y=0,J;while((J=Z.exec($))!==null){let Q=J[1];if(Q.startsWith("if"))Y++;else if(Q==="endif")Y--;else if(Y===0)return!0}return!1}function jW($){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,Q;while((Q=Y.exec($))!==null){let X=Q[1],G;while((G=J.exec(X))!==null)Z.add(G[1])}return Z}function HW($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function YY($,Z,Y){if(!$)return!1;let J=HW($),Q=!1,X=!1,G=!1,K=/([a-zA-Z_$][\w$]*)/g,q;while((q=K.exec(J))!==null){let _=q[1];if(J.slice(0,q.index).trimEnd().endsWith("."))continue;if(ZY.has(_))continue;if(Z.has(_))Q=!0;else if(Y&&_ in Y)X=!0}let W=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,z;while((z=W.exec(J))!==null){let _=z[1];if(J.slice(0,z.index).trimEnd().endsWith("."))continue;if(ZY.has(_)||Y&&_ in Y)continue;G=!0}return(Q||G)&&!X}function O$($,Z,Y){let J=Y===void 0?` ${Z}`:` ${Z}="${Y.replace(/"/g,""")}"`,Q=$.trim(),X=Q.match(JY);if(X&&OW(X[3],X[1])){let[,G,K,q]=X;return`<${G}${K}${J}>${q}</${G}>`}return`<template${J}>${Q}</template>`}function OW($,Z){let Y=new RegExp(`<(/)?${Z}(?=[\\s/>])`,"gi"),J=0,Q;while((Q=Y.exec($))!==null)if(Q[1]){if(J--,J<0)return!1}else J++;return!0}function p3($,Z){let Y=$,J=jW($),Q=/@if\s*\(/g,X,G=[];while((X=Q.exec(Y))!==null){let K=X.index,q=K+X[0].length,W=1,z=q;while(z<Y.length&&W>0){if(Y[z]==="(")W++;else if(Y[z]===")")W--;z++}if(W!==0)continue;let U=Y.substring(q,z-1).trim(),_=z,B=1,j=_,H=/@(if\s*\(|endif)/g;H.lastIndex=_;let L;while((L=H.exec(Y))!==null)if(L[1].startsWith("if"))B++;else if(L[1]==="endif"){if(B--,B===0){j=L.index+L[0].length;break}}if(B!==0)continue;let F=Y.substring(_,j-6).trim(),O;if(BW(F)){let V=b5(Y.substring(K,j));if(V.length===0)continue;let w=V[0].branches.filter((R)=>R.type!=="else");if(!(w.length>0&&w.every((R)=>YY(R.condition,J,Z))))continue;O=V[0].branches.map((R)=>{if(R.type==="elseif")return O$(R.content,"@else-if",R.condition??"");if(R.type==="else")return O$(R.content,"@else");return O$(R.content,"@if",R.condition??"")}).join(`
|
|
8082
8082
|
`)}else{if(!YY(U,J,Z))continue;O=O$(F,"@if",U)}G.push({start:K,end:j,replacement:O})}for(let K=G.length-1;K>=0;K--){let{start:q,end:W,replacement:z}=G[K];Y=Y.substring(0,q)+z+Y.substring(W)}return Y}function LW($){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 Q=Number(Z);return Q!==0&&!Number.isNaN(Q)}let Y=Z.match(/^'((?:\\.|[^'\\])*)'$/);if(Y)return Y[1].length>0;let J=Z.match(/^"((?:\\.|[^"\\])*)"$/);if(J)return J[1].length>0;return}function FW($,Z,Y,J){if(u3.has(Y.toLowerCase()))return J;let Q=Y.toLowerCase(),X=$.toLowerCase(),G=$.length,K=1,q=J;while(q<G){let W=$.indexOf("<",q);if(W===-1)return-1;if(q=W,$.startsWith("<!--",q)){let B=$.indexOf("-->",q+4);if(B===-1)return-1;q=B+3;continue}let z=/^<(script|style)\b/i.exec($.slice(q,q+8));if(z){let B=$.indexOf(">",q);if(B===-1)return-1;if($[B-1]==="/"){q=B+1;continue}let j=X.indexOf(`</${z[1].toLowerCase()}`,q);if(j===-1)return-1;let H=$.indexOf(">",j);if(H===-1)return-1;q=H+1;continue}if($[q+1]==="/"){let B=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(q,q+64));if(!B){q++;continue}if(B[1].toLowerCase()===Q){if(K--,q+=B[0].length,K===0)return q;continue}q+=B[0].length;continue}let U=/^<([a-z][\w-]*)\b/i.exec($.slice(q,q+64));if(!U){q++;continue}let _=$.indexOf(">",q);if(_===-1)return-1;if(U[1].toLowerCase()===Q){let B=$.slice(q,_+1);if(!(/\/\s*>$/.test(B)||u3.has(Q)))K++}q=_+1}return-1}function wW($,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 Q=$.indexOf(">",Y);if(Q===-1)return!1;let X=$.slice(Y,Q+1);return VW.test(X)}function l3($){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 Q=(U)=>Z.some(([_,B])=>U>=_&&U<B),X=/<([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=X.exec($))!==null){if(Q(K.index))continue;let[U,_,B,j,H,L,F]=K,O=LW(H);if(O===void 0)continue;let V=K.index,w=V+U.length,R=!!F||/\/\s*>$/.test(U)||u3.has(_.toLowerCase())?w:FW($,V,_,w);if(R===-1)continue;if((j===":if"||j==="x-if"||j==="@if")&&wW($,R)){X.lastIndex=w;continue}if(O===!0){let M=`<${_}${B}${L}${F}>`;G.push({start:V,end:w,replacement:M});continue}G.push({start:V,end:R,replacement:""}),X.lastIndex=R}if(G.length===0)return $;G.sort((U,_)=>U.start-_.start);let q=[],W=-1;for(let U of G){if(U.start<W)continue;q.push(U),W=U.end}let z=$;for(let U=q.length-1;U>=0;U--){let{start:_,end:B,replacement:j}=q[U];z=z.substring(0,_)+j+z.substring(B)}return z}function c3($,Z){let Y=$,J=/@(for|foreach)\s*\(/g,Q,X=[];while((Q=J.exec(Y))!==null){let G=Q[1],K=Q.index,q=K+Q[0].length,W=1,z=q;while(z<Y.length&&W>0){if(Y[z]==="(")W++;else if(Y[z]===")")W--;z++}if(W!==0)continue;let U=Y.substring(q,z-1).trim(),_=z,B=QY(U);if(B.iterable){let N=B.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(B.style==="as")U=B.indexVar?`(${B.itemVar}, ${B.indexVar}) in ${B.iterable}`:`${B.itemVar} in ${B.iterable}`;let j=G==="for"?"@endfor":"@endforeach",H=1,L=_,F=G==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${G}\\s*\\(|end${G})`,"g");F.lastIndex=_;let O;while((O=F.exec(Y))!==null)if(O[1].startsWith(G))H++;else if(H--,H===0){L=O.index+O[0].length;break}if(H!==0)continue;let V=Y.substring(_,L-j.length).trim(),w=V.match(JY),A;if(w){let[,N,R,T]=w;A=`<${N}${R} @for="${U}">${T}</${N}>`}else A=`<template @for="${U}">${V}</template>`;X.push({start:K,end:L,replacement:A})}for(let G=X.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=X[G];Y=Y.substring(0,K)+W+Y.substring(q)}return Y}function AW($){let Z=new Set,Y=[],J=0,Q=0,X=$.length,G=(z)=>{let U=J+1;while(U<X){let _=$[U];if(_==="\\"){U+=2;continue}if(_===z)return U+1;U++}return X},K=()=>{let z=J+2;while(z<X&&$[z]!==`
|
|
8083
8083
|
`)z++;return z},q=()=>{let z=J+2;while(z<X-1){if($[z]==="*"&&$[z+1]==="/")return z+2;z++}return X},W=(z)=>{let U=z,_=0;while(U<X){let B=$[U];if(B==="/"&&$[U+1]==="/"){let j=U+2;while(j<X&&$[j]!==`
|
|
8084
|
-
`)j++;U=j;continue}if(B==="/"&&$[U+1]==="*"){let j=U+2;while(j<X-1&&!($[j]==="*"&&$[j+1]==="/"))j++;U=j+2;continue}if(B==='"'||B==="'"||B==="`"){let j=U+1;while(j<X){if($[j]==="\\"){j+=2;continue}if($[j]===B){j++;break}j++}U=j;continue}if(B==="("||B==="["||B==="{"){_++,U++;continue}if(B===")"||B==="]"||B==="}"){_--,U++;continue}if(B===";"&&_===0)return U+1;U++}return X};while(J<X){let z=$[J];if(z==="/"&&$[J+1]==="/"){let U=K();Y.push($.slice(J,U)),J=U;continue}if(z==="/"&&$[J+1]==="*"){let U=q();Y.push($.slice(J,U)),J=U;continue}if(z==='"'||z==="'"||z==="`"){let U=G(z);Y.push($.slice(J,U)),J=U;continue}if(z==="{"){Q++,Y.push(z),J++;continue}if(z==="}"){Q--,Y.push(z),J++;continue}if(Q===0){let U=J>0?$[J-1]:"";if(U===""||/\s/.test(U)||U===";"||U==="}"||U==="{"){let B=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(B){let j=B[2],H=W(J+B[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 GY($,Z,Y){let J=XY($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),Q=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,X=[];for(let H of J){let L=H.body;if(
|
|
8084
|
+
`)j++;U=j;continue}if(B==="/"&&$[U+1]==="*"){let j=U+2;while(j<X-1&&!($[j]==="*"&&$[j+1]==="/"))j++;U=j+2;continue}if(B==='"'||B==="'"||B==="`"){let j=U+1;while(j<X){if($[j]==="\\"){j+=2;continue}if($[j]===B){j++;break}j++}U=j;continue}if(B==="("||B==="["||B==="{"){_++,U++;continue}if(B===")"||B==="]"||B==="}"){_--,U++;continue}if(B===";"&&_===0)return U+1;U++}return X};while(J<X){let z=$[J];if(z==="/"&&$[J+1]==="/"){let U=K();Y.push($.slice(J,U)),J=U;continue}if(z==="/"&&$[J+1]==="*"){let U=q();Y.push($.slice(J,U)),J=U;continue}if(z==='"'||z==="'"||z==="`"){let U=G(z);Y.push($.slice(J,U)),J=U;continue}if(z==="{"){Q++,Y.push(z),J++;continue}if(z==="}"){Q--,Y.push(z),J++;continue}if(Q===0){let U=J>0?$[J-1]:"";if(U===""||/\s/.test(U)||U===";"||U==="}"||U==="{"){let B=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(B){let j=B[2],H=W(J+B[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 GY($,Z,Y){let J=XY($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),Q=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,X=[];for(let H of J){let L=H.body;if(w1(H.attrs))L=A1(L);if(Q.test(L))X.push({fullMatch:H.fullMatch,attrs:H.attrs,content:L})}if(X.length===0)return{output:$,setupCode:null};let G=`__stx_setup_${Date.now()}_${_W++}`,{hasUserImports:K,bundleClientScript:q}=await Promise.resolve().then(() => (i5(),c5)),W=[];for(let H=0;H<X.length;H++){let L=X[H].content;if(K(L))console.log("[stx:bundler] bundling signal script imports"),L=await q(L,Z||"",{projectRoot:process.cwd()});L=L.replace(/^\s*import\s+(?:type\s+)?\{[^}]*\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,"// [stx import stripped \u2014 resolved via window.stx in __stx_setup]");let F=$1(L);W.push(`// \u2500\u2500 merged signal script #${H+1} \u2500\u2500
|
|
8085
8085
|
${F}`)}let z=W.join(`
|
|
8086
8086
|
|
|
8087
8087
|
`);z=AW(z);let U=KY(z),_=n5(z,Y),B=`
|
|
@@ -8103,17 +8103,17 @@ ${j}
|
|
|
8103
8103
|
</script>`;J=J.replace(W,H),X.lastIndex=0}catch(j){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,q;while((q=K.exec(J))!==null){let[W,z,U,_]=q,B=z+_;if(zY(U))continue;if(/rel=["']stylesheet["']/.test(B)||U.endsWith(".css")){let H=await WY(U,Q,Z);if(H)try{let L=await Bun.file(H).text();Y.add(H);let F=`<style>
|
|
8104
8104
|
/* Source: ${U} */
|
|
8105
8105
|
${L}
|
|
8106
|
-
</style>`;J=J.replace(W,F),K.lastIndex=0}catch(L){}}}return J}var _Y=S(()=>{
|
|
8106
|
+
</style>`;J=J.replace(W,F),K.lastIndex=0}catch(L){}}}return J}var _Y=S(()=>{d1()});function o3($,Z){let Y=$,J=/@json\s*\(/g,Q;while((Q=J.exec(Y))!==null){let X=Q.index,G=X+Q[0].length-1,K=1,q=G+1,W=null,z=!1;while(q<Y.length&&K>0){let V=Y[q];if(z){z=!1,q++;continue}if(V==="\\"&&W){z=!0,q++;continue}if(W){if(V===W)W=null;q++;continue}if(V==='"'||V==="'"||V==="`"){W=V,q++;continue}if(V==="(")K++;else if(V===")"){if(K--,K===0)break}q++}if(K!==0)break;let U=Y.substring(G+1,q).trim(),_=Y.substring(X,q+1),B=-1,j=0,H=null,L=!1;for(let V=0;V<U.length;V++){let w=U[V];if(L){L=!1;continue}if(w==="\\"&&H){L=!0;continue}if(H){if(w===H)H=null;continue}if(w==='"'||w==="'"||w==="`"){H=w;continue}if(w==="("||w==="["||w==="{")j++;else if(w===")"||w==="]"||w==="}")j--;if(w===","&&j===0){B=V;break}}let F=B>=0?U.substring(0,B).trim():U,O=B>=0?U.substring(B+1).trim():void 0;try{let V=F.trim(),w;if(Q0(V))w=G0(V,Object.keys(Z))(...Object.values(Z));else w=void 0;let A;if(O==="true")A=JSON.stringify(w,null,2);else A=JSON.stringify(w);let N=A.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,X)+N+Y.substring(q+1),J.lastIndex=X+N.length}catch(V){l0.log(V instanceof Error?V:Error(String(V)),{directive:"@json"},"error"),J.lastIndex=X+_.length}}return Y}function s3($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function BY($){let Z=$,Y=/@memo\s*\(/g,J,Q=[];while((J=Y.exec(Z))!==null){let X=J.index,G=X+J[0].length,K=1,q=G;while(q<Z.length&&K>0){if(Z[q]==="(")K++;else if(Z[q]===")")K--;q++}if(K!==0)continue;let W=Z.slice(G,q-1).trim(),z=q,U=Z.slice(z),_=U.indexOf("@endmemo");if(_===-1)continue;let B=U.slice(0,_),j=z+_+8,H=B.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),L=H?H[0].length:0,F=B.slice(L),O=B.match(/(\s*)$/),V=O?O[0].length:0,w=F.slice(0,F.length-V),A=w.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),N;if(A){let[R,T,M="",I]=A,D=`<${T}${M} data-stx-memo="${W}"${I}>`;N=B.slice(0,L)+D+w.slice(R.length)+B.slice(L+w.length)}else N=`${B.slice(0,L)}<div data-stx-memo="${W}">${w}</div>${B.slice(L+w.length)}`;Q.push({start:X,end:j,replacement:N}),Y.lastIndex=j}for(let X=Q.length-1;X>=0;X--){let G=Q[X];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function r3($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function jY($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),J="",Q=0,X;while((X=Y.exec($))!==null){let G=X.index,K=G+X[0].length,q=!1,W=!1,z=-1;while(K<$.length){let H=$[K];if(q){if(H==="'")q=!1}else if(W){if(H==='"')W=!1}else if(H==="'")q=!0;else if(H==='"')W=!0;else if(H===">"){z=K;break}K++}if(z===-1)continue;if($.slice(G,z+1).includes("x-cloak"))continue;let _=$.slice(z+1),B=_.indexOf("</"),j=B>=0?_.slice(0,B):_.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))J+=$.slice(Q,z)+" x-cloak>",Q=z+1}return J+=$.slice(Q),J}function HY($){let Z=/<[a-z][\w-]*/gi,Y="",J=0,Q;while((Q=Z.exec($))!==null){let X=Q.index,G=Q[0].slice(1).toLowerCase();if(G==="script"||G==="style"){let j=`</${G}>`,H=$.toLowerCase().indexOf(j,X);if(H!==-1)Z.lastIndex=H+j.length;continue}let K=X+Q[0].length,q=!1,W=!1,z=-1;while(K<$.length){let j=$[K];if(q){if(j==="'")q=!1}else if(W){if(j==='"')W=!1}else if(j==="'")q=!0;else if(j==='"')W=!0;else if(j===">"){z=K;break}K++}if(z===-1)continue;let U=$.slice(X+Q[0].length,z);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(U))continue;if(!NW.test(U))continue;let _=$[z-1]==="/",B=_?z-1:z;Y+=`${$.slice(J,B)} x-cloak${_?" ":""}`,J=B}return Y+=$.slice(J),Y}var NW;var a3=S(()=>{Z1();R0();NW=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/});function t3($,Z,Y){let J=typeof Y==="boolean"?{enabled:Y,failOnViolation:Y}:Y??{enabled:!1},Q=J.allowPatterns??[],X=[];for(let{pattern:G,message:K,suggestion:q}of RW){if(Q.some((z)=>K.includes(z)||G.source.includes(z)))continue;G.lastIndex=0;let W=$.match(G);if(W&&W.length>0){let z=$.split(`
|
|
8107
8107
|
`),U=[];z.forEach((B,j)=>{if(G.lastIndex=0,G.test(B))U.push(j+1)});let _=U.length>0?` (line${U.length>1?"s":""}: ${U.join(", ")})`:"";X.push(` \u2717 ${K}${_}
|
|
8108
8108
|
\u2192 ${q}`)}}if(X.length>0&&J.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
|
|
8109
8109
|
${X.join(`
|
|
8110
8110
|
`)}
|
|
8111
|
-
Tip: prefer useRef(), navigate(), and composables for component code`;if(J.failOnViolation)throw Error(K);else console.warn(K)}}var RW;var e3=S(()=>{RW=[{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 OY={};r(OY,{getStoreScript:()=>TW,clearStoreCache:()=>MW});import F$ from"path";async function TW($){let Z;if($)Z=F$.resolve($);else{let z=await
|
|
8111
|
+
Tip: prefer useRef(), navigate(), and composables for component code`;if(J.failOnViolation)throw Error(K);else console.warn(K)}}var RW;var e3=S(()=>{RW=[{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 OY={};r(OY,{getStoreScript:()=>TW,clearStoreCache:()=>MW});import F$ from"path";async function TW($){let Z;if($)Z=F$.resolve($);else{let z=await b1();Z=F$.resolve(z.root||process.cwd(),z.storesDir||"stores")}let Y=G5.get(Z);if(Y!==void 0)return Y||null;let J=new Bun.Glob("*.ts"),Q=[];try{for await(let z of J.scan({cwd:Z,absolute:!0})){let U=F$.basename(z,".ts");if(["index","types"].includes(U))continue;if(z.includes(".d.ts"))continue;Q.push(z)}}catch{return G5.set(Z,""),null}if(Q.length===0)return G5.set(Z,""),null;let X=[];for(let z of Q){let U=await Bun.file(z).text();X.push({file:z,hasUseStore:/useStore\s*\(/.test(U)})}X.sort((z,U)=>{if(z.hasUseStore===U.hasUseStore)return 0;return z.hasUseStore?1:-1});let G=X.map((z)=>z.file),K=[],q=new Bun.Transpiler({loader:"ts",target:"browser",define:o0()});for(let z of G)try{let U=await Bun.file(z).text(),_=F$.basename(z,".ts");U=U.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),U=U.replace(/^export\s+(default\s+)?/gm,""),U=q.transformSync(U),K.push(`// Store: ${_}
|
|
8112
8112
|
${U.trim()}`)}catch(U){console.warn(`[stx] Failed to load store ${z}:`,U)}if(K.length===0)return G5.set(Z,""),null;let W=`;(function(){
|
|
8113
8113
|
${K.join(`
|
|
8114
8114
|
|
|
8115
8115
|
`)}
|
|
8116
|
-
})();`;return G5.set(Z,W),W}function MW(){G5.clear()}var G5;var LY=S(()=>{
|
|
8116
|
+
})();`;return G5.set(Z,W),W}function MW(){G5.clear()}var G5;var LY=S(()=>{r1();d1();G5=new Map});var VY={};r(VY,{processDeferDirectives:()=>bW});function IW(){return`stx-defer-${++FY}`}function DW($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function EW($,Z,Y){let{trigger:J,value:Q}=DW(Z),X=Y,G,K,q,W=Y.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(W)G=W[1].trim(),X=X.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let z=Y.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(z)K=z[1].trim(),X=X.replace(/@loading[\s\S]*?(?=@error|$)/,"");let U=Y.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(U)q=U[2].trim(),X=X.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return X=X.trim(),{trigger:J,triggerValue:Q,content:X,placeholder:G,loading:K,error:q}}function kW($,Z){let{trigger:Y,triggerValue:J}=Z,Q;switch(Y){case"visible":Q=`
|
|
8117
8117
|
const observer = new IntersectionObserver((entries) => {
|
|
8118
8118
|
if (entries[0].isIntersecting) {
|
|
8119
8119
|
observer.disconnect();
|
|
@@ -10451,7 +10451,7 @@ else {
|
|
|
10451
10451
|
<script type="application/json" id="stx-island-manifest">
|
|
10452
10452
|
${JSON.stringify(Z)}
|
|
10453
10453
|
</script>
|
|
10454
|
-
`}var SU;var ZJ=S(()=>{SU={processPartialHydrationDirectives:cY,processStaticDirectives:tY,generatePartialHydrationCSS:iY,generateIslandManifest:eY,createIslandRegistry:lY,hydrateIsland:nY,hydrateByStrategy:oY,hydrateAll:sY,isHydrated:rY,onHydrated:aY}});var _J={};r(_J,{watchMultiple:()=>GJ,watchEffect:()=>KJ,watch:()=>QJ,unref:()=>YJ,toRefs:()=>JJ,throttledComputed:()=>UJ,stxWatchMultiple:()=>GJ,stxWatchEffect:()=>KJ,stxWatch:()=>QJ,stxUnref:()=>YJ,stxToRefs:()=>JJ,stxThrottledComputed:()=>UJ,stxShallowRef:()=>XJ,stxRef:()=>q5,stxIsRef:()=>
|
|
10454
|
+
`}var SU;var ZJ=S(()=>{SU={processPartialHydrationDirectives:cY,processStaticDirectives:tY,generatePartialHydrationCSS:iY,generateIslandManifest:eY,createIslandRegistry:lY,hydrateIsland:nY,hydrateByStrategy:oY,hydrateAll:sY,isHydrated:rY,onHydrated:aY}});var _J={};r(_J,{watchMultiple:()=>GJ,watchEffect:()=>KJ,watch:()=>QJ,unref:()=>YJ,toRefs:()=>JJ,throttledComputed:()=>UJ,stxWatchMultiple:()=>GJ,stxWatchEffect:()=>KJ,stxWatch:()=>QJ,stxUnref:()=>YJ,stxToRefs:()=>JJ,stxThrottledComputed:()=>UJ,stxShallowRef:()=>XJ,stxRef:()=>q5,stxIsRef:()=>O1,stxDebouncedComputed:()=>WJ,stxComputed:()=>m5,shallowRef:()=>XJ,ref:()=>q5,processWatchDirectives:()=>zJ,processComputedDirectives:()=>qJ,isRef:()=>O1,default:()=>yU,debouncedComputed:()=>WJ,computed:()=>m5});function q5($){let Z=$,Y=new Set,J={get value(){if(t0){let Q=d5.get(J);if(!Q)Q=new Set,d5.set(J,Q);Q.add(t0)}return Z},set value(Q){if(!Object.is(Z,Q)){Z=Q,Y.forEach((G)=>G(Q));let X=d5.get(J);if(X)X.forEach((G)=>G())}},subscribe(Q){return Y.add(Q),()=>Y.delete(Q)},peek(){return Z}};return J}function O1($){return $!==null&&typeof $==="object"&&"value"in $&&"subscribe"in $&&"peek"in $}function YJ($){return O1($)?$.value:$}function JJ($){let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=q5($[Y]);return Z}function XJ($){return q5($)}function m5($){let Z=typeof $==="function",Y=Z?$:$.get,J=Z?void 0:$.set,Q=Z?Object.is:$.equals||Object.is,X,G=!0,K=new Set,q=new Set,W=()=>{if(G=!0,q.size>0){let _=U.value;q.forEach((B)=>B(_))}};function z(){K.clear();let _=t0;t0=W,V$.push(W);try{return Y()}finally{V$.pop(),t0=_}}let U={get value(){if(t0){let _=d5.get(U);if(!_)_=new Set,d5.set(U,_);_.add(t0)}if(G){let _=z();if(!Q(X,_))X=_;G=!1}return X},set value(_){if(J)J(_);else console.warn("Computed property is readonly")},subscribe(_){return q.add(_),()=>q.delete(_)},peek(){if(G)X=Y(),G=!1;return X},invalidate(){G=!0},get dirty(){return G},get deps(){return K}};return U}function QJ($,Z,Y={}){let{immediate:J=!1,deep:Q=!1,flush:X="pre",once:G=!1}=Y,K,q=!0,W=!1,z=()=>{if(O1($))return Q?f1($.value):$.value;return $()},U=()=>{if(!q||W)return;let j=z();if(K!==void 0&&Object.is(K,j)&&!Q)return;let H=()=>{if(Z(j,K),K=Q?f1(j):j,G)B()};if(X==="sync")H();else if(X==="post")queueMicrotask(H);else Promise.resolve().then(H)},_=null;if(O1($))_=$.subscribe(()=>U());else _=m5($).subscribe(()=>U());if(J)K=void 0,U();else K=z();let B=()=>{if(q=!1,_)_(),_=null};return B.pause=()=>{W=!0},B.resume=()=>{W=!1},B}function GJ($,Z,Y={}){let{immediate:J=!1,once:Q=!1}=Y,X=$.map((U)=>O1(U)?U.value:void 0),G=!0,K=!1,q=()=>{if(!G||K)return;let U=$.map((_)=>O1(_)?_.value:void 0);if(Z(U,X),X=[...U],Q)z()},W=$.map((U)=>{if(O1(U))return U.subscribe(()=>q());return()=>{}});if(J)q();let z=()=>{G=!1,W.forEach((U)=>U())};return z.pause=()=>{K=!0},z.resume=()=>{K=!1},z}function KJ($,Z={}){let{flush:Y="pre"}=Z,J,Q=!0,X=!1,G=()=>{if(!Q||X)return;if(J)J();let q=t0;t0=G,V$.push(G);try{J=$()}finally{V$.pop(),t0=q}};if(Y==="sync")G();else if(Y==="post")queueMicrotask(G);else Promise.resolve().then(G);let K=()=>{if(Q=!1,J)J()};return K.pause=()=>{X=!0},K.resume=()=>{X=!1},K}function qJ($,Z={},Y){let J=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return $.replace(J,(Q,X,G)=>{try{let q=Function(...Object.keys(Z),`return ${G}`)(...Object.values(Z));return Z[X]=q,`<!-- computed: ${X} = ${q} -->`}catch(K){return`<!-- computed error: ${X} - ${K} -->`}})}function zJ($,Z={},Y){let J=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return $.replace(J,(Q,X,G)=>{return`
|
|
10455
10455
|
<script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
|
|
10456
10456
|
(function() {
|
|
10457
10457
|
// Watch implementation for ${X}
|
|
@@ -10463,7 +10463,7 @@ else {
|
|
|
10463
10463
|
}
|
|
10464
10464
|
})();
|
|
10465
10465
|
</script>
|
|
10466
|
-
`})}function
|
|
10466
|
+
`})}function f1($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>f1(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((J,Q)=>Y.set(f1(Q),f1(J))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((J)=>Y.add(f1(J))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=f1($[Y]);return Z}function WJ($,Z=100){let Y=q5($()),J=null,Q=()=>{if(J)clearTimeout(J);J=setTimeout(()=>{Y.value=$()},Z)};return m5($).subscribe(()=>Q()),{get value(){return Y.value},set value(G){console.warn("Debounced computed is readonly")},subscribe:Y.subscribe,peek:Y.peek,invalidate(){Q()},get dirty(){return!1},get deps(){return new Set}}}function UJ($,Z=100){let Y=q5($()),J=0,Q=()=>{let G=Date.now();if(G-J>=Z)J=G,Y.value=$()};return m5($).subscribe(()=>Q()),{get value(){return Y.value},set value(G){console.warn("Throttled computed is readonly")},subscribe:Y.subscribe,peek:Y.peek,invalidate(){Q()},get dirty(){return!1},get deps(){return new Set}}}var t0=null,V$,d5,yU;var BJ=S(()=>{V$=[],d5=new WeakMap;yU={ref:q5,computed:m5,watch:QJ,watchMultiple:GJ,watchEffect:KJ,isRef:O1,unref:YJ,toRefs:JJ,shallowRef:XJ,debouncedComputed:WJ,throttledComputed:UJ,processComputedDirectives:qJ,processWatchDirectives:zJ}});var LJ={};r(LJ,{v:()=>CU,processHasErrorsDirective:()=>OJ,processFormValidationDirectives:()=>vU,processErrorsDirective:()=>HJ,processErrorDirective:()=>jJ,defineForm:()=>PU,Validator:()=>z5});class z5{rules=[];defaultValue="";addRule($){let Z=new z5;return Z.rules=[...this.rules,$],Z.defaultValue=this.defaultValue,Z}required($="This field is required"){return this.addRule({name:"required",message:$,validate:(Z)=>{if(Z===null||Z===void 0)return $;if(typeof Z==="string"&&Z.trim()==="")return $;if(Array.isArray(Z)&&Z.length===0)return $;return!0}})}email($="Please enter a valid email"){return this.addRule({name:"email",message:$,validate:(Z)=>{if(!Z)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(Z))||$}})}url($="Please enter a valid URL"){return this.addRule({name:"url",message:$,validate:(Z)=>{if(!Z)return!0;try{return new URL(String(Z)),!0}catch{return $}}})}min($,Z){let Y=Z||`Must be at least ${$} characters`;return this.addRule({name:"min",message:Y,validate:(J)=>{if(!J)return!0;return String(J).length>=$||Y}})}max($,Z){let Y=Z||`Must be no more than ${$} characters`;return this.addRule({name:"max",message:Y,validate:(J)=>{if(!J)return!0;return String(J).length<=$||Y}})}length($,Z,Y){let J=Y||`Must be between ${$} and ${Z} characters`;return this.addRule({name:"length",message:J,validate:(Q)=>{if(!Q)return!0;let X=String(Q).length;return X>=$&&X<=Z||J}})}pattern($,Z="Invalid format"){return this.addRule({name:"pattern",message:Z,validate:(Y)=>{if(!Y)return!0;return $.test(String(Y))||Z}})}hasUppercase($="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,$)}hasLowercase($="Must contain a lowercase letter"){return this.pattern(/[a-z]/,$)}hasNumber($="Must contain a number"){return this.pattern(/\d/,$)}hasSpecial($="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,$)}alphanumeric($="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,$)}startsWithLetter($="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,$)}noSpaces($="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:$,validate:(Z)=>{if(!Z)return!0;return!String(Z).includes(" ")||$}})}number($="Must be a number"){let Z=this.addRule({name:"number",message:$,validate:(Y)=>{if(!Y&&Y!==0)return!0;return!Number.isNaN(Number(Y))||$}});return Z.defaultValue=0,Z}integer($="Must be a whole number"){return this.addRule({name:"integer",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number.isInteger(Number(Z))||$}})}positive($="Must be a positive number"){return this.addRule({name:"positive",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number(Z)>0||$}})}negative($="Must be a negative number"){return this.addRule({name:"negative",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number(Z)<0||$}})}minValue($,Z){let Y=Z||`Must be at least ${$}`;return this.addRule({name:"minValue",message:Y,validate:(J)=>{if(!J&&J!==0)return!0;return Number(J)>=$||Y}})}maxValue($,Z){let Y=Z||`Must be no more than ${$}`;return this.addRule({name:"maxValue",message:Y,validate:(J)=>{if(!J&&J!==0)return!0;return Number(J)<=$||Y}})}between($,Z,Y){let J=Y||`Must be between ${$} and ${Z}`;return this.addRule({name:"between",message:J,validate:(Q)=>{if(!Q&&Q!==0)return!0;let X=Number(Q);return X>=$&&X<=Z||J}})}matches($,Z){let Y=Z||`Must match ${$}`;return this.addRule({name:"matches",message:Y,validate:(J,Q)=>{if(!Q)return!0;return J===Q[$]||Y}})}oneOf($,Z){let Y=Z||`Must be one of: ${$.join(", ")}`;return this.addRule({name:"oneOf",message:Y,validate:(J)=>{if(!J)return!0;return $.includes(J)||Y}})}notOneOf($,Z){let Y=Z||`Cannot be one of: ${$.join(", ")}`;return this.addRule({name:"notOneOf",message:Y,validate:(J)=>{if(!J)return!0;return!$.includes(J)||Y}})}date($="Must be a valid date"){return this.addRule({name:"date",message:$,validate:(Z)=>{if(!Z)return!0;let Y=new Date(String(Z));return!Number.isNaN(Y.getTime())||$}})}before($,Z){let Y=new Date($),J=Z||`Must be before ${Y.toLocaleDateString()}`;return this.addRule({name:"before",message:J,validate:(Q)=>{if(!Q)return!0;return new Date(String(Q))<Y||J}})}after($,Z){let Y=new Date($),J=Z||`Must be after ${Y.toLocaleDateString()}`;return this.addRule({name:"after",message:J,validate:(Q)=>{if(!Q)return!0;return new Date(String(Q))>Y||J}})}custom($,Z="Invalid value"){return this.addRule({name:"custom",message:Z,validate:$})}async($,Z="Invalid value"){return this.addRule({name:"async",message:Z,async:!0,validate:$})}when($,Z){let Y=new z5;Y.rules=[...this.rules],Y.defaultValue=this.defaultValue;for(let J of Z.getRules())Y.rules.push({...J,validate:(Q,X)=>{if(!$(Q,X||{}))return!0;return J.validate(Q,X)}});return Y}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default($){let Z=new z5;return Z.rules=[...this.rules],Z.defaultValue=$,Z}async validate($,Z){let Y=[];for(let J of this.rules){let Q=await J.validate($,Z);if(Q!==!0)Y.push(Q)}return Y}validateSync($,Z){let Y=[];for(let J of this.rules){if(J.async)continue;let Q=J.validate($,Z);if(Q!==!0)Y.push(Q)}return Y}}function PU($,Z){let Y=Object.keys($),J={},Q={},X={},G={},K={};for(let O of Y)J[O]=Z?.[O]??$[O].getDefaultValue(),Q[O]=[],X[O]=!1,G[O]=!1,K[O]=!1;let q=!1;async function W(O){K[O]=!0;let V=await $[O].validate(J[O],J);return Q[O]=V,K[O]=!1,V.length===0}async function z(){q=!0;let O=await Promise.all(Y.map(W));return q=!1,O.every(Boolean)}function U(){for(let O of Y)J[O]=Z?.[O]??$[O].getDefaultValue(),Q[O]=[],X[O]=!1,G[O]=!1}function _(O){for(let V of Y)if(V in O)J[V]=O[V],G[V]=!0}function B(O,V){J[O]=V,G[O]=!0}function j(O,V=!0){if(X[O]=V,V)W(O)}function H(O){return{value:J[O],errors:Q[O],touched:X[O],dirty:G[O],valid:Q[O].length===0,validating:K[O]}}function L(O){return async(V)=>{V?.preventDefault?.();for(let A of Y)X[A]=!0;if(await z())await O(J)}}return{values:J,errors:Q,touched:X,dirty:G,get isValid(){return Y.every((O)=>Q[O].length===0)},get isValidating(){return q||Y.some((O)=>K[O])},get isDirty(){return Y.some((O)=>G[O])},validate:z,validateField:W,reset:U,setValues:_,setFieldValue:B,setFieldTouched:j,getFieldState:H,handleSubmit:L}}function jJ($,Z,Y){let J=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return $.replace(J,(Q,X,G)=>{try{let K=X.trim().split("."),q=Z;for(let z of K)if(q&&typeof q==="object"&&z in q)q=q[z];else return"";let W=q;if(!W||!Array.isArray(W)||W.length===0)return"";return W.map((z)=>{return G.replace(/\{\{\s*message\s*\}\}/g,z)}).join(`
|
|
10467
10467
|
`)}catch{return""}})}function HJ($,Z,Y){let J=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return $.replace(J,(Q,X,G)=>{try{let K=X.trim().split("."),q=Z;for(let z of K)if(q&&typeof q==="object"&&z in q)q=q[z];else return"";let W=q;if(!W||!Array.isArray(W)||W.length===0)return"";return W.map((z)=>G.replace(/\{\{\s*message\s*\}\}/g,z)).join(`
|
|
10468
10468
|
`)}catch{return""}})}function OJ($,Z,Y){let J=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return $.replace(J,(Q,X,G)=>{try{let K=X.trim().split("."),q=Z;for(let z of K)if(q&&typeof q==="object"&&z in q)q=q[z];else return"";let W=q;if(!W||!Array.isArray(W)||W.length===0)return"";return G}catch{return""}})}function vU($,Z,Y){let J=$;return J=jJ(J,Z,Y),J=HJ(J,Z,Y),J=OJ(J,Z,Y),J}var CU;var FJ=S(()=>{CU=new z5});var AJ={};r(AJ,{processXElementDirectives:()=>xU,hasXElementDirectives:()=>wJ,generateXElementRuntime:()=>VJ});function VJ(){return`<script data-stx-scoped>
|
|
10469
10469
|
(function() {
|
|
@@ -10816,13 +10816,13 @@ if ('serviceWorker' in navigator) {
|
|
|
10816
10816
|
`),...W.htmlAttrs&&{htmlAttrs:{...K.htmlAttrs||{},...W.htmlAttrs}},...W.bodyAttrs&&{bodyAttrs:{...K.bodyAttrs||{},...W.bodyAttrs}}},L=C3(G);if(G=c2(G,H),L)G=l2(G,K);let F=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(F&&G.includes("<head")){let V=F[1],w=sU(V);G=G.replace("<head>",`<head>
|
|
10817
10817
|
<meta name="stx-layout" content="${EJ(V)}">
|
|
10818
10818
|
<meta name="stx-layout-group" content="${EJ(w)}">`)}let O=G.match(/function (__stx_setup_\d+_\d+)\(/);if(O&&G.includes("<body")&&!G.match(/<body[^>]*data-stx=/)){G=G.replace(/<body([^>]*)>/,`<body$1 data-stx="${O[1]}">`);let V=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${O[1]}"`,"i");G=G.replace(V,"$1")}}if(X)G=p2(G);if(X)try{let{getStoreScript:K}=await Promise.resolve().then(() => (LY(),OY)),q=J.storesDir,W=await K(q);if(W){let z=`<script data-stx-stores>${W}</script>`,U=G.indexOf("<script data-stx-scoped>");if(U!==-1){let _=G.indexOf("</script>",U+24);if(_!==-1){let B=_+9;G=G.slice(0,B)+`
|
|
10819
|
-
`+z+G.slice(B)}}}}catch{}if(X&&Z.__stx_inject_css!==!1)G=await k5(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof y4)throw G;let K=G instanceof Error?G.message:String(G),q=new
|
|
10819
|
+
`+z+G.slice(B)}}}}catch{}if(X&&Z.__stx_inject_css!==!1)G=await k5(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof y4)throw G;let K=G instanceof Error?G.message:String(G),q=new E1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(l0.log(q,{filePath:Y,context:Z}),T7.logDetailedError(q,{filePath:Y,template:$.substring(0,500)}),J.debug)throw q;return N7.createFallbackContent("Template Processing",q)}}async function aU($,Z,Y,J,Q){let X=process.cwd(),G={...J,partialsDir:J.partialsDir&&!C0.isAbsolute(J.partialsDir)?C0.resolve(X,J.partialsDir):J.partialsDir,componentsDir:J.componentsDir&&!C0.isAbsolute(J.componentsDir)?C0.resolve(X,J.componentsDir):J.componentsDir,layoutsDir:J.layoutsDir&&!C0.isAbsolute(J.layoutsDir)?C0.resolve(X,J.layoutsDir):J.layoutsDir},K=G,q=$;await $_(Y,Z),eU(Z,K),q=await o1(()=>E2(q,Z,Y,K),q,(O)=>{l0.log(O,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${O.message}`)}),q=q.replace(/\{\{--[\s\S]*?--\}\}/g,"");let W=H5(q,x6,(O,V)=>`\x00STX_HTML_COMMENT_${V}\x00`);q=W.output;let z=W.tokens,U=(O)=>z.length===0?O:O.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(V,w)=>z[Number(w)]??""),_="\x00STX_ESCAPED_AT\x00";q=q.replace(/@@/g,_),q=q.replace(/@\{\{([\s\S]*?)\}\}/g,(O,V)=>{return`{{ ${V} }}`}),q=h2(q),q=await UY(q,Y,Q);let B={};q=b3(q,B);let j={...Z.__sections||{}},H="",L=/@nolayout\b/.test(q);if(L)q=q.replace(/@nolayout\b\s*/g,"");let F=q.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F)H=F[1],q=q.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!H&&!L&&K.defaultLayout){let O=/<!DOCTYPE\s/i.test(q),V=/@section\s*\(/.test(q);if(!O||V){let w="",A=C0.dirname(Y),N=K.layoutsDir?C0.dirname(K.layoutsDir):process.cwd();for(let R=0;R<20;R++){let T=C0.join(A,"_layout.stx");if(await n(T)){w=T;break}let M=C0.dirname(A);if(M===A||M.length<N.length)break;A=M}if(w)H=w;else if(K.layoutsDir){let R=C0.isAbsolute(K.layoutsDir)?K.layoutsDir:C0.resolve(process.cwd(),K.layoutsDir),T=C0.join(R,`${K.defaultLayout}.stx`);if(await n(T))H=T}if(H&&!V)q=`@section('content')
|
|
10820
10820
|
${q.trim()}
|
|
10821
|
-
@endsection`}}if(q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(O,V,w)=>{return j[V]=w,""}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(O,V,w)=>{if(/^(['"]).*\1$/.test(w.trim()))return O;try{let A=Y0(w.trim(),Z);if(A===void 0)return O;return j[V]=String(A??""),""}catch{return O}}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(O,V,w)=>{if(w.includes("@parent"))j[V]=w.replace("@parent",
|
|
10821
|
+
@endsection`}}if(q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(O,V,w)=>{return j[V]=w,""}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(O,V,w)=>{if(/^(['"]).*\1$/.test(w.trim()))return O;try{let A=Y0(w.trim(),Z);if(A===void 0)return O;return j[V]=String(A??""),""}catch{return O}}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(O,V,w)=>{if(w.includes("@parent"))j[V]=w.replace("@parent",g1);else j[V]=w.trim();return""}),Z.__sections=j,q=q.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(O,V,w)=>{return j[V]||w||""}),!("slot"in Z)||Z.slot===void 0)q=q.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""});if(q=S3(q,B),H){let O=[];if(q=q.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi,(V)=>{return O.push(V),""}),O.length>0){let V=O.join(`
|
|
10822
10822
|
`);j.content=j.content?`${j.content}
|
|
10823
|
-
${V}`:V,Z.__sections=j}}if(H)try{let O;if(C0.isAbsolute(H))O=H,Q.add(H);else O=await
|
|
10824
|
-
${q}`,U(q)}catch(O){return l0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return U(await kJ(q,Z,Y,G,Q))}function tU($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,J,Q)=>{let X=Z[J];if(X!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(X))return X}return Q||""})}function eU($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",J={};for(let[Q,X]of Object.entries(process.env))if(Q.startsWith(Y)&&X!==void 0)J[Q]=X;$.$env=J}async function $_($,Z){await
|
|
10825
|
-
`;if(X=M(X,Z),X=I(X,Z),X=S2(X),X=g7(X,Z),X=VZ(X),X=I2(X),X=await k3(X,Z,Y,G,Q),X=await e4(X,Z,Y,G,Q),X=X.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),X=r3(X),X=
|
|
10823
|
+
${V}`:V,Z.__sections=j}}if(H)try{let O;if(C0.isAbsolute(H))O=H,Q.add(H);else O=await o1(()=>m$(H,Y,G,Q),null,()=>{throw new E1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!O){let T=`Layout not found: ${H} (referenced from ${Y})`;if(l0.log(Error(T),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new E1(T,Y);return q}let V=await o1(()=>Bun.file(O).text(),"",()=>{throw new E1(`Failed to read layout file: ${O}`,Y,void 0,void 0,"Layout content could not be loaded")}),w=V.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(w){if(G.debug)console.log(`Found nested layout: ${w[1]} in ${O}`);let T={},M=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(E,P,b)=>{return T[P]=b.trim(),""});for(let[E,P]of Object.entries(T))if(j[E]&&j[E].includes(g1)){let b=j[E].indexOf(g1);j[E]=j[E].slice(0,b)+P+j[E].slice(b+g1.length)}else if(!j[E])j[E]=P;let I={...Z,__sections:j},D=`@layout('${w[1]}')${M}`;return await j0(D,I,O,G,Q)}let A=V.replace(/\{\{--[\s\S]*?--\}\}/g,""),N=b3(A,B),R={};return N=N.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,M,I)=>{return R[M]=I.trim(),`@slot('${M}')`}),N=N.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(T,M,I)=>{if(j[M]){let D=j[M];if(D.includes(g1)){let E=R[M]||"",P=D.indexOf(g1);D=D.slice(0,P)+E+D.slice(P+g1.length)}return D}return I||""}),N=tU(N,j),N=N.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),N=S3(N,B),Z.__originalFilePath=Y,q=await kJ(N,Z,O,G,Q),q=`<!-- stx-layout: ${H} -->
|
|
10824
|
+
${q}`,U(q)}catch(O){return l0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return U(await kJ(q,Z,Y,G,Q))}function tU($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,J,Q)=>{let X=Z[J];if(X!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(X))return X}return Q||""})}function eU($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",J={};for(let[Q,X]of Object.entries(process.env))if(Q.startsWith(Y)&&X!==void 0)J[Q]=X;$.$env=J}async function $_($,Z){await o1(()=>C2($,Z),void 0,(Y)=>{l0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function Z_($,Z,Y){let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let X=Q[1],G=Q[2];if(!/\bserver\b/.test(X)||!G.trim())continue;try{let{extractVariables:q}=await Promise.resolve().then(() => (N5(),Y4));await q(G,Z,Y,{preserveExisting:!0})}catch(q){let W=q instanceof Error?q:Error(String(q));l0.log(W,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${W.message}`)}}}async function Y_($,Z,Y){try{let{interpolateScriptsInTemplate:J}=await Promise.resolve().then(() => (r0(),p6));return J($,Z,{skipServer:!0})}catch(J){let Q=J instanceof Error?J:Error(String(J));return l0.log(Q,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${Q.message}`),$}}async function kJ($,Z,Y,J,Q){let X=$,G=J;if(await Z_(X,Z,Y),X=await Y_(X,Z,Y),X=await N2(X,Z,Y),X=await R2(X,Z,Y),X=await AZ(X,Z,Y,G),m1(X))X=p3(X,Z),X=c3(X,Z);X=l3(X);let{processStreamDirectives:K}=await Promise.resolve().then(() => (t7(),a7));X=K(X,Z),X=I3(X,Z,Y,G),X=await e4(X,Z,Y,G,Q),X=await m2(X,Z,Y,G,Q),X=j6(X,Z,Y,G);let{processDeferDirectives:q}=await Promise.resolve().then(() => VY);X=q(X,Z,Y);let{processTeleportDirectives:W}=await Promise.resolve().then(() => AY);X=W(X,Z,Y);let{processTransitionDirectives:z,processTransitionAttributes:U}=await Promise.resolve().then(() => MY);X=z(X,Z,Y),X=U(X);let{processErrorBoundaryDirectives:_}=await Promise.resolve().then(() => DY);X=_(X,Z,Y);let{processSuspenseDirectives:B}=await Promise.resolve().then(() => EY);X=B(X,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => yY);X=j(X,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => PY);X=H(X,Z,Y);let{processVirtualListDirectives:L,processVirtualGridDirectives:F,processInfiniteListDirectives:O}=await Promise.resolve().then(() => (dY(),hY));X=L(X,Z,Y),X=F(X,Z,Y),X=O(X,Z,Y);let{processPartialHydrationDirectives:V,processStaticDirectives:w}=await Promise.resolve().then(() => (ZJ(),$J));X=V(X,Z,Y),X=w(X);let{processComputedDirectives:A,processWatchDirectives:N}=await Promise.resolve().then(() => (BJ(),_J));X=A(X,Z,Y),X=N(X,Z,Y);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (FJ(),LJ));X=R(X,Z,Y);let{processHeadDirective:T,processTitleDirective:M,processMetaDirective:I,resetHead:D}=await Promise.resolve().then(() => (w5(),P$));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let E=T(X);if(X=E.content,E.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${E.headContent}
|
|
10825
|
+
`;if(X=M(X,Z),X=I(X,Z),X=S2(X),X=g7(X,Z),X=VZ(X),X=I2(X),X=await k3(X,Z,Y,G,Q),X=await e4(X,Z,Y,G,Q),X=X.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),X=r3(X),X=y1(X,Z,Y),X=h7(X,Z),X=d7(X,Z),X=c4(X,Z),X=IZ(X,Z),X=DZ(X,Z),X=await QZ(X,Z,Y,G),X=await j9(X,Z,Y),X=await yZ(X,Z,Y,G),X=K6(X,Z,Y,G),X=N8(X,Z,Y,G),X=R8(X,Z,Y),X=T8(X,Z,Y,G),X=OZ(X,Z,Y,G),X=o3(X,Z),X=s3(X),X=BY(X),!G.skipEventDirectives)X=t8(X,Z,Y);if(X=JZ(X,Z,Y),G.debug){let C=/\bx-data\s*=/.test(X),x=L$($);if(C&&x)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
10826
10826
|
Both work on the same page, but they manage separate scopes.
|
|
10827
10827
|
Prefer signals (state/derived/effect) for new components.`)}X=x2(X,Z),X=await s0(X,Z,Y),X=jY(X),X=HY(X),X=p8(X);let{processXElementDirectives:P}=await Promise.resolve().then(() => AJ);X=P(X);let b=Z.__originalFilePath||Y,k=_5(Z);if(X=await i3(X,G,b,k),X=await k2(X,Z,Y,G),G.media?.image?.autoSiblings){let C=G.publicDir||"public",{rewriteImagesWithSiblings:x}=await Promise.resolve().then(() => (RJ(),NJ));X=await x(X,{publicDir:C})}if(G.seo?.enabled)X=M8(X,Z,G);let y=(C,x)=>{if(!x)return C;if(/<\/head>/i.test(C))return C.replace(/<\/head>/i,`${x}
|
|
10828
10828
|
</head>`);if(/<head\b[^>]*>/i.test(C))return C.replace(/(<head\b[^>]*>)/i,`$1
|
|
@@ -10835,7 +10835,7 @@ ${h8()}
|
|
|
10835
10835
|
`+b0}else X=X.replace("</head>",`${x}
|
|
10836
10836
|
</head>`)}else if(X.includes("<body"))X=X.replace(/<body([^>]*)>/,`<body$1>
|
|
10837
10837
|
${x}`);else X=x+`
|
|
10838
|
-
`+X}{let C=/<script\s+server\b[^>]*>/gi,x,u=[];while((x=C.exec(X))!==null){let p=x.index+x[0].length,X0=rU(X,p);if(X0===-1)continue;let W0=X0+9;while(W0<X.length&&/\s/.test(X[W0]))W0++;u.push({start:x.index,end:W0}),C.lastIndex=W0}for(let p=u.length-1;p>=0;p--){let{start:X0,end:W0}=u[p];X=X.substring(0,X0)+X.substring(W0)}}let _0=e5(X,Y);if(_0.hasScoped)X=_0.html;let Z0=Z.__stx_event_bindings||[],k0=!1,f0=[],v=/\s:[a-z][\w.-]*\s*=/.test(X),{scanScriptTags:f}=await Promise.resolve().then(() => (n3(),qY));for(let C of f(X,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))f0.push({match:C.fullMatch,attrs:C.attrs,content:C.body});for(let{match:C,attrs:x,content:u}of f0){k0=!0;let p=u;t3(u,Y,J.strict);let X0=await B5(u,{eventBindings:Z0,attrs:x,hasColonDirectives:v,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:J.buildMode==="compile",serverData:k});X=X.replace(C,()=>X0)}if(k0)Z.__stx_event_bindings=[];return X}var
|
|
10838
|
+
`+X}{let C=/<script\s+server\b[^>]*>/gi,x,u=[];while((x=C.exec(X))!==null){let p=x.index+x[0].length,X0=rU(X,p);if(X0===-1)continue;let W0=X0+9;while(W0<X.length&&/\s/.test(X[W0]))W0++;u.push({start:x.index,end:W0}),C.lastIndex=W0}for(let p=u.length-1;p>=0;p--){let{start:X0,end:W0}=u[p];X=X.substring(0,X0)+X.substring(W0)}}let _0=e5(X,Y);if(_0.hasScoped)X=_0.html;let Z0=Z.__stx_event_bindings||[],k0=!1,f0=[],v=/\s:[a-z][\w.-]*\s*=/.test(X),{scanScriptTags:f}=await Promise.resolve().then(() => (n3(),qY));for(let C of f(X,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))f0.push({match:C.fullMatch,attrs:C.attrs,content:C.body});for(let{match:C,attrs:x,content:u}of f0){k0=!0;let p=u;t3(u,Y,J.strict);let X0=await B5(u,{eventBindings:Z0,attrs:x,hasColonDirectives:v,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:J.buildMode==="compile",serverData:k});X=X.replace(C,()=>X0)}if(k0)Z.__stx_event_bindings=[];return X}var g1="<!--PARENT_CONTENT_PLACEHOLDER-->";var J4=S(()=>{f4();t5();R$();d8();l8();i8();I$();T$();e8();j5();XZ();GZ();u4();LZ();wZ();RZ();Z1();w5();r0();EZ();CZ();A2();M2();D3();u$();b2();l1();y2();M7();A0();P2();f2();d2();u2();C$();n3();M3();_Y();a3();e3();R0();$3();a3();e3()});import F0 from"fs";import J0 from"path";import{matchRoute as M_,Router as iJ}from"stx-router";import{findErrorPage as E_,formatRoutes as k_,generateRouteManifest as b_,generateRouteTypes as S_,matchRoute as y_}from"stx-router";function N$($,Z={}){return new iJ($,Z).routes}J4();import{createHash as J_}from"crypto";function X_($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}var Q_=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;function G_($){return Bun.hash($).toString(16)}function bJ($,Z={}){if(!$.includes('type="stx/island"'))return{html:$,chunks:[]};let Y=new Map,J=$.replace(Q_,(X,G,K,q)=>{let W=q.trim();if(!W)return X;if(/\bdata-stx-src=/.test(K))return X;if(Z.minify)W=X_(W);let z=G_(W);if(!Y.has(z))Y.set(z,W);let U=Z.integrity?` data-stx-integrity="sha384-${J_("sha384").update(W).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${G}" data-stx-src="/_stx/islands/${z}.js"${U}${K}></script>`}),Q=Array.from(Y,([X,G])=>({hash:X,code:G}));return{html:J,chunks:Q}}var K_=new Set(["visible","idle"]);function SJ($){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 Q=new Set,X=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,G;while((G=X.exec($))!==null)if(K_.has(Z.get(G[1])||""))Q.add(G[2]);let K=$.lastIndexOf("</head>");if(Q.size===0||K===-1)return $;let q=Array.from(Q).filter((W)=>!$.includes(`rel="prefetch" href="${W}"`)).map((W)=>`<link rel="prefetch" href="${W}" as="script">`).join("");if(!q)return $;return $.slice(0,K)+q+$.slice(K)}r1();f4();import{abortNavigation as kw,clearMiddleware as yJ,createClientCookieManager as bw,createMiddlewareContext as CJ,createRouteLocation as PJ,createServerCookieManager as Sw,createStorageManager as yw,defineMiddleware as Cw,getMiddleware as Pw,getMiddlewareNames as vJ,hasMiddleware as vw,loadMiddlewareFromDirectory as xJ,navigateTo as xw,registerMiddleware as fw,runMiddleware as fJ}from"stx-router";class gJ{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=J0.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 F0.promises.mkdir(this.cacheDir,{recursive:!0});let $=J0.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=F0.statSync($),J=`${$}:${Y.mtimeMs}`;for(let X of Z)if(F0.existsSync(X)){let G=F0.statSync(X);J+=`:${X}:${G.mtimeMs}`}let Q=0;for(let X=0;X<J.length;X++){let G=J.charCodeAt(X);Q=(Q<<5)-Q+G,Q=Q&Q}return Math.abs(Q).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 Q=this.getHash(Z,Y);this.cache.set($,{hash:Q,html:J,generatedAt:Date.now(),dependencies:Y})}}class hJ{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return J0.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 F0.promises.mkdir(J0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await F0.promises.unlink(Z)}async invalidatePattern($){let Z=J0.join(this.cacheDir,"isr");if(!F0.existsSync(Z))return;let Y=await F0.promises.readdir(Z);for(let J of Y){let Q=J.replace(/_/g,"/").replace(".json","");if($.test(Q))await F0.promises.unlink(J0.join(Z,J))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function q_($){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 Q=J.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!Q)return null;return await Function(`
|
|
10839
10839
|
return (async function getStaticPaths() {
|
|
10840
10840
|
${Q[1]}
|
|
10841
10841
|
})()
|
|
@@ -10875,7 +10875,7 @@ ${$.map((J)=>{let Q=new URL(J.loc,Z).href,X=` <url>
|
|
|
10875
10875
|
${Y.join(`
|
|
10876
10876
|
`)}
|
|
10877
10877
|
</channel>
|
|
10878
|
-
</rss>`}async function O_($={}){let Z=Date.now(),Y=await
|
|
10878
|
+
</rss>`}async function O_($={}){let Z=Date.now(),Y=await b1(),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||".stx/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},Q={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},X=new Set,G=0,K={},q={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&F0.existsSync(J.outputDir))await F0.promises.rm(J.outputDir,{recursive:!0});await F0.promises.mkdir(J.outputDir,{recursive:!0});let z=new gJ(J.cacheDir);if(J.cache)await z.load();try{let{preloadIconCollection:V}=await Promise.resolve().then(() => (r4(),aZ));await V("lucide")}catch{}try{let{generateCrosswindCSS:V}=await Promise.resolve().then(() => (f4(),g8));await V('<div class="bg-black"></div>')}catch{}yJ();let U=Y?.routeMiddleware?.dir||"middleware";await xJ(process.cwd(),U);let _=vJ();if(_.length>0)console.log(`Loaded ${_.length} middleware: ${_.join(", ")}`);let B=Y?.routeMiddleware?.global||[],j=N$(".",{pagesDir:J.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let V of j){let w=await z_(V);for(let A of w)H.push({route:V,url:A.url,params:A.params,props:A.props,revalidate:A.revalidate??J.revalidate})}Q.totalPages=H.length,console.log(`Generating ${Q.totalPages} pages...`);let L=[],F=[];for(let V=0;V<H.length;V+=J.concurrency)F.push(H.slice(V,V+J.concurrency));for(let V of F)await Promise.all(V.map(async(w)=>{let{route:A,url:N,params:R,props:T,revalidate:M}=w;try{await J.hooks.onPageStart?.(N);let I=await Bun.file(A.filePath).text(),D=w_(I),E=D?.middleware?Array.isArray(D.middleware)?D.middleware:[D.middleware]:[],P=[...B,...E];if(P.length>0){let m=PJ(N,R,D||{}),i=CJ(m,null),l=await fJ(P,i);if(l.redirect){let q0=typeof l.redirect==="string"?l.redirect:l.redirect.path||l.redirect,V0=A_(String(q0),N),_0=N_(N,J);await F0.promises.mkdir(J0.dirname(_0),{recursive:!0}),await Bun.write(_0,V0),Q.successCount++,Q.pages.push({route:N,outputPath:_0,size:Buffer.byteLength(V0),cached:!1}),L.push({loc:N,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${N} \u2192 redirect to ${q0}`);return}if(l.abort){let q0=typeof l.abort==="string"?l.abort:l.abort?.error?.message||"aborted";console.warn(` \u21B3 ${N} \u2014 middleware aborted: ${q0}`);return}}let b=I.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(b)try{if(!await Function("route",`
|
|
10879
10879
|
const validate = ${b[1]};
|
|
10880
10880
|
return validate(route);
|
|
10881
10881
|
`)({params:R})){console.warn(`Validation failed for ${N}, skipping...`);return}}catch{}let k=null,y=!1;if(J.cache){if(k=z.get(N,A.filePath),k)y=!0,Q.cachedCount++}if(!k){let m=await dJ(A,R,T,J,Y);if(k=m.html,J.cache)z.set(N,A.filePath,m.dependencies,k)}let g;if(J.trailingSlash)g=J0.join(J.outputDir,N,"index.html");else g=N==="/"?J0.join(J.outputDir,"index.html"):J0.join(J.outputDir,`${N}.html`);if(J.chunkIslands){let{html:m,chunks:i}=bJ(k,{integrity:J.integrityIslands,minify:J.minify});if(i.length>0){let l=J0.join(J.outputDir,"_stx","islands");await F0.promises.mkdir(l,{recursive:!0});for(let q0 of i){let V0=J0.join(l,`${q0.hash}.js`);if(!await Bun.file(V0).exists())await Bun.write(V0,q0.code);if(!X.has(q0.hash)){X.add(q0.hash);let _0=Buffer.byteLength(q0.code,"utf8");G+=_0,K[q0.hash]={bytes:_0,file:`/_stx/islands/${q0.hash}.js`}}}if(q[N]=i.map((q0)=>q0.hash),k=m,J.prefetchIslands)k=SJ(k)}}await F0.promises.mkdir(J0.dirname(g),{recursive:!0}),await Bun.write(g,k),L.push({loc:N,lastmod:new Date().toISOString().split("T")[0],priority:N==="/"?1:0.8});let h={route:N,outputPath:g,size:Buffer.byteLength(k,"utf8"),cached:y};if(M!==!1)h.revalidateAt=Date.now()+M*1000;Q.pages.push(h),Q.successCount++,await J.hooks.onPageEnd?.(N,k)}catch(I){Q.failedCount++,Q.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 V=J0.join(J.pagesDir,"404.stx");if(await Bun.file(V).exists()){let w=new Set,A={...Y,debug:!1,cache:!1},N=await j0(await Bun.file(V).text(),{},V,A,w);await Bun.write(J0.join(J.outputDir,"404.html"),N)}else await Bun.write(J0.join(J.outputDir,"404.html"),`<!DOCTYPE html>
|
|
@@ -10907,7 +10907,7 @@ Build complete!
|
|
|
10907
10907
|
Cached: ${Q.cachedCount}
|
|
10908
10908
|
Failed: ${Q.failedCount}
|
|
10909
10909
|
Time: ${Q.buildTime}ms${W}
|
|
10910
|
-
`),Q}async function mJ($,Z){let Y=await F0.promises.readdir($,{withFileTypes:!0});for(let J of Y){let Q=J0.join($,J.name),X=J0.join(Z,J.name);if(J.isDirectory())await F0.promises.mkdir(X,{recursive:!0}),await mJ(Q,X);else await F0.promises.copyFile(Q,X)}}function L_($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new hJ(Z),J=$.revalidate||3600;return{async get(Q){let X=await Y.get(Q);if(!X)return null;if(Date.now()>X.revalidateAfter)this.revalidate(Q).catch(console.error);return{html:X.html,headers:{"Cache-Control":`public, max-age=${J}, stale-while-revalidate=${J*2}`,ETag:X.etag,"X-ISR-Generated":new Date(X.generatedAt).toISOString(),...X.headers}}},async revalidate(Q){let G=N$(".",{pagesDir:$.pagesDir||"pages"}).find((U)=>{return Q.match(U.regex)!==null});if(!G){console.warn(`Route not found for revalidation: ${Q}`);return}let K=Q.match(G.regex),q={};if(K)G.params.forEach((U,_)=>{q[U]=K[_+1]});let W=await
|
|
10910
|
+
`),Q}async function mJ($,Z){let Y=await F0.promises.readdir($,{withFileTypes:!0});for(let J of Y){let Q=J0.join($,J.name),X=J0.join(Z,J.name);if(J.isDirectory())await F0.promises.mkdir(X,{recursive:!0}),await mJ(Q,X);else await F0.promises.copyFile(Q,X)}}function L_($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new hJ(Z),J=$.revalidate||3600;return{async get(Q){let X=await Y.get(Q);if(!X)return null;if(Date.now()>X.revalidateAfter)this.revalidate(Q).catch(console.error);return{html:X.html,headers:{"Cache-Control":`public, max-age=${J}, stale-while-revalidate=${J*2}`,ETag:X.etag,"X-ISR-Generated":new Date(X.generatedAt).toISOString(),...X.headers}}},async revalidate(Q){let G=N$(".",{pagesDir:$.pagesDir||"pages"}).find((U)=>{return Q.match(U.regex)!==null});if(!G){console.warn(`Route not found for revalidation: ${Q}`);return}let K=Q.match(G.regex),q={};if(K)G.params.forEach((U,_)=>{q[U]=K[_+1]});let W=await b1(),{html:z}=await dJ(G,q,{},$,W);await Y.set(Q,{html:z,generatedAt:Date.now(),revalidateAfter:Date.now()+J*1000,etag:B_(z)}),console.log(`Revalidated: ${Q}`)},async invalidate(Q){if(typeof Q==="string")await Y.invalidate(Q);else await Y.invalidatePattern(Q)}}}function F_($){return async()=>{return{paths:await $(),fallback:!1}}}function V_(){return{name:"markdown",extensions:[".md",".mdx"],async load($){let Z=await Bun.file($).text(),Y=Z.match(/^---\n([\s\S]*?)\n---/),J={},Q=Z;if(Y){let W=Y[1];Q=Z.slice(Y[0].length).trim();for(let z of W.split(`
|
|
10911
10911
|
`)){let U=z.indexOf(":");if(U>0){let _=z.slice(0,U).trim(),B=z.slice(U+1).trim();if(B==="true")B=!0;else if(B==="false")B=!1;else if(/^\d+$/.test(B))B=parseInt(B,10);else if(/^\d+\.\d+$/.test(B))B=parseFloat(B);else if(B.startsWith("[")&&B.endsWith("]"))B=B.slice(1,-1).split(",").map((j)=>j.trim().replace(/^['"]|['"]$/g,""));J[_]=B}}}let X=Q.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,q;while((q=K.exec(X))!==null){let W=parseInt(q[1],10),z=q[2],U=z.toLowerCase().replace(/[^a-z0-9]+/g,"-");G.push({id:U,text:z,level:W})}return{content:X,data:J,toc:G}}}}function w_($){let Z=$.match(/definePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!Z)return null;try{return Function(`return ${Z[1]}`)()}catch{return null}}function A_($,Z){return`<!DOCTYPE html>
|
|
10912
10912
|
<html>
|
|
10913
10913
|
<head>
|