@stacksjs/stx 0.2.149 → 0.2.151

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 CHANGED
@@ -941,7 +941,7 @@ catch (e) {
941
941
  }
942
942
  throw e;
943
943
  }
944
- `),X.set(U,z)}return z(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class H_{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,X=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,Q=Z>=Y.maxTime;if(!X&&!Q)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:X};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=X?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${J.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let J=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:J?.maxTime,budgetUtilization:J?Y.totalTime/Y.count/J.maxTime*100:void 0}}let Z={};for(let[Y,J]of this.metrics.entries()){let X=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:X?.maxTime,budgetUtilization:X?J.totalTime/J.count/X.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let J of this.violations)if($[J.label]=($[J.label]||0)+1,J.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function WT(){if(!$9)$9=new H_;return $9}var S$,KT=500,gu,$9=null,i1;var $6=D(()=>{S$=new Map;gu=new j_;i1=new Proxy({},{get($,Z){return WT()[Z]}})});var T;var M7=D(()=>{T={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});var FZ={};$0(FZ,{resetCssCache:()=>HT,resetCrosswindCache:()=>OT,rebuildCrosswindCSS:()=>E7,loadCrosswindConfig:()=>Q9,loadCrosswind:()=>X9,injectCrosswindCSS:()=>y0,getCrosswindServeAsset:()=>J9,getCachedCSS:()=>LT,generateCrosswindCSS:()=>VZ,extractClassNames:()=>LZ,buildCrosswindCSS:()=>P$});import w0 from"path";import{hasLocalConfig as UT}from"bunfig";function OZ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function Z9($,Z){if(E4.has($))E4.delete($);else if(E4.size>=L_)E4.delete(E4.keys().next().value);E4.set($,Z)}function zT($){let Z=OZ($);if(n1.has(Z))n1.delete(Z);else if(n1.size>=L_)n1.delete(n1.keys().next().value);return n1.set(Z,$),Z}function J9($){let Z=n1.get($);if(Z===void 0)return;return n1.delete($),n1.set($,Z),Z}async function _T($){if(!Z6)return null;try{let Z=Bun.file(w0.join(Z6,`cw-${OZ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function qT($,Z){if(!Z6)return;try{if(!fs.existsSync(Z6))fs.mkdirSync(Z6,{recursive:!0});await Bun.write(w0.join(Z6,`cw-${OZ($)}.css`),Z)}catch{}}async function O_($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig,extractClasses:Z.extractClasses}}catch{}return null}function BT(){let $=[],Z=process.cwd();while(Z!==w0.dirname(Z))$.push(w0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(w0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(w0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(w0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(w0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(w0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=w0.dirname(Z);return $}function jT(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[w0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),w0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),w0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),w0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),w0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),w0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(w0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(w0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function X9(){if(Y9)return z4;Y9=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await O_(Q);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded from ${w0.dirname(w0.dirname(Q))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let X=w0.resolve(process.env.CROSSWIND_SRC),Q=await $([X]);if(!Q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${X}`);return z4=Q,z4}let Z=await $(BT());if(Z)return z4=Z,z4;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of Y){let Q=await O_(X);if(Q){if(z4=Q,!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded`);return z4}}let J=await $(jT());if(J)return z4=J,z4;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${T.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${T.reset}`),console.warn(`${T.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${T.reset}`),null}}function HT(){E4.clear(),n1.clear()}function OT(){z4=null,Y9=!1,r1=null,T7="",E4.clear(),n1.clear(),HZ=null}async function Q9($){try{if(!UT({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=w0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${T.yellow}[Crosswind]${T.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function P$($){if(b$)return T7;b$=!0;try{let Z=await X9();if(!Z||!Z.build)return b$=!1,"";if(!r1)r1=await Q9($);if(!r1)return b$=!1,"";let Y=Z.defaultConfig?.theme||{},J=r1.theme||{},X={...Z.defaultConfig,...r1,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},Q=performance.now(),G=await Z.build(X),K=performance.now()-Q;if(T7=G.css,console.log(`${T.cyan}[Crosswind]${T.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),X.output){let W=w0.isAbsolute(X.output)?X.output:w0.join($,X.output),U=w0.dirname(W);if(!fs.existsSync(U))fs.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return b$=!1,G.css}catch(Z){return console.error(`${T.red}[Crosswind]${T.reset} Build error:`,Z),b$=!1,T7}}async function E7($){r1=null,await P$($)}function LT(){return T7}function LZ($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,J=Y.exec($);while(J!==null){for(let G of J[1].split(/\s+/))if(G.trim())Z.add(G.trim());J=Y.exec($)}let X=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=X.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}Q=X.exec($)}return Z}async function VZ($,Z){try{let Y=await X9();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):LZ($);if(J.size===0)return"";let X=Z?w0.resolve(Z):process.cwd();if(!Z6)Z6=p0(X,"cache");let Q=[...J].sort().join(" "),G=`${HZ||"default"}::${Q}`,K=E4.get(G);if(K!==void 0)return Z9(G,K),K;let W=await _T(G);if(W!==null)return Z9(G,W),W;if(!r1){let w=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (a0(),AZ)),R=await N(X);if(R.css)if(typeof R.css==="string"){let E=w0.isAbsolute(R.css)?R.css:w0.resolve(X,R.css);if(await Bun.file(E).exists()){let M=await import(E);w=M.default||M,console.log(`${T.green}[Crosswind]${T.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(w={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let E=w0.isAbsolute(R.css.config)?R.css.config:w0.resolve(X,R.css.config);if(await Bun.file(E).exists()){let M=await import(E);w={...M.default||M,...w}}}console.log(`${T.green}[Crosswind]${T.reset} Using inline CSS config from stx.config.ts`)}}catch{}r1=w||await Q9(X);try{HZ=OZ(JSON.stringify(r1??{}))}catch{HZ="unhashable"}}let U=Y.defaultConfig||Y.config,z=r1||{},_=U.theme||{},B=(z.theme||{}).extend||{},j={..._};if(Object.keys(B).length>0)j.extend=B;let H=[...U.safelist||[],...z.safelist||[]],O={...U,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},V=new Y.CSSGenerator(O);for(let w of H)V.generate(w);for(let w of J)V.generate(w);let L=V.toCSS(!0,!1),F=O.shortcuts||z.shortcuts||{};for(let[w,N]of Object.entries(F)){if(!J.has(w)&&!H.includes(w))continue;let R=N.split(/\s+/).filter(Boolean);for(let E of R)V.generate(E)}L=V.toCSS(!0,!1);let A=L.split(`
944
+ `),X.set(U,z)}return z(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class H_{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),J=await Z(),X=performance.now()-Y;return this.recordTime($,X),this.checkBudget($,X),J}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let J=Z/Y.maxTime*100,X=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,Q=Z>=Y.maxTime;if(!X&&!Q)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:X};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=X?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${J.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let J=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:J?.maxTime,budgetUtilization:J?Y.totalTime/Y.count/J.maxTime*100:void 0}}let Z={};for(let[Y,J]of this.metrics.entries()){let X=this.budgets.get(Y);Z[Y]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:X?.maxTime,budgetUtilization:X?J.totalTime/J.count/X.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let J of this.violations)if($[J.label]=($[J.label]||0)+1,J.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function WT(){if(!$9)$9=new H_;return $9}var S$,KT=500,du,$9=null,i1;var $6=D(()=>{S$=new Map;du=new j_;i1=new Proxy({},{get($,Z){return WT()[Z]}})});var T;var M7=D(()=>{T={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});var FZ={};$0(FZ,{resetCssCache:()=>HT,resetCrosswindCache:()=>OT,rebuildCrosswindCSS:()=>E7,loadCrosswindConfig:()=>Q9,loadCrosswind:()=>X9,injectCrosswindCSS:()=>y0,getCrosswindServeAsset:()=>J9,getCachedCSS:()=>LT,generateCrosswindCSS:()=>VZ,extractClassNames:()=>LZ,buildCrosswindCSS:()=>P$});import w0 from"path";import{hasLocalConfig as UT}from"bunfig";function OZ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function Z9($,Z){if(E4.has($))E4.delete($);else if(E4.size>=L_)E4.delete(E4.keys().next().value);E4.set($,Z)}function zT($){let Z=OZ($);if(n1.has(Z))n1.delete(Z);else if(n1.size>=L_)n1.delete(n1.keys().next().value);return n1.set(Z,$),Z}function J9($){let Z=n1.get($);if(Z===void 0)return;return n1.delete($),n1.set($,Z),Z}async function _T($){if(!Z6)return null;try{let Z=Bun.file(w0.join(Z6,`cw-${OZ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function qT($,Z){if(!Z6)return;try{if(!fs.existsSync(Z6))fs.mkdirSync(Z6,{recursive:!0});await Bun.write(w0.join(Z6,`cw-${OZ($)}.css`),Z)}catch{}}async function O_($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig,extractClasses:Z.extractClasses}}catch{}return null}function BT(){let $=[],Z=process.cwd();while(Z!==w0.dirname(Z))$.push(w0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(w0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(w0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(w0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(w0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(w0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=w0.dirname(Z);return $}function jT(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[w0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),w0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),w0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),w0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),w0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),w0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(w0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(w0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function X9(){if(Y9)return z4;Y9=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await O_(Q);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded from ${w0.dirname(w0.dirname(Q))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let X=w0.resolve(process.env.CROSSWIND_SRC),Q=await $([X]);if(!Q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${X}`);return z4=Q,z4}let Z=await $(BT());if(Z)return z4=Z,z4;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of Y){let Q=await O_(X);if(Q){if(z4=Q,!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} CSS engine loaded`);return z4}}let J=await $(jT());if(J)return z4=J,z4;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${T.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${T.reset}`),console.warn(`${T.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${T.reset}`),null}}function HT(){E4.clear(),n1.clear()}function OT(){z4=null,Y9=!1,r1=null,T7="",E4.clear(),n1.clear(),HZ=null}async function Q9($){try{if(!UT({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=w0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${T.green}[Crosswind]${T.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${T.yellow}[Crosswind]${T.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function P$($){if(b$)return T7;b$=!0;try{let Z=await X9();if(!Z||!Z.build)return b$=!1,"";if(!r1)r1=await Q9($);if(!r1)return b$=!1,"";let Y=Z.defaultConfig?.theme||{},J=r1.theme||{},X={...Z.defaultConfig,...r1,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},Q=performance.now(),G=await Z.build(X),K=performance.now()-Q;if(T7=G.css,console.log(`${T.cyan}[Crosswind]${T.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),X.output){let W=w0.isAbsolute(X.output)?X.output:w0.join($,X.output),U=w0.dirname(W);if(!fs.existsSync(U))fs.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return b$=!1,G.css}catch(Z){return console.error(`${T.red}[Crosswind]${T.reset} Build error:`,Z),b$=!1,T7}}async function E7($){r1=null,await P$($)}function LT(){return T7}function LZ($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,J=Y.exec($);while(J!==null){for(let G of J[1].split(/\s+/))if(G.trim())Z.add(G.trim());J=Y.exec($)}let X=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=X.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}Q=X.exec($)}return Z}async function VZ($,Z){try{let Y=await X9();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):LZ($);if(J.size===0)return"";let X=Z?w0.resolve(Z):process.cwd();if(!Z6)Z6=p0(X,"cache");let Q=[...J].sort().join(" "),G=`${HZ||"default"}::${Q}`,K=E4.get(G);if(K!==void 0)return Z9(G,K),K;let W=await _T(G);if(W!==null)return Z9(G,W),W;if(!r1){let w=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (a0(),AZ)),R=await N(X);if(R.css)if(typeof R.css==="string"){let E=w0.isAbsolute(R.css)?R.css:w0.resolve(X,R.css);if(await Bun.file(E).exists()){let M=await import(E);w=M.default||M,console.log(`${T.green}[Crosswind]${T.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(w={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let E=w0.isAbsolute(R.css.config)?R.css.config:w0.resolve(X,R.css.config);if(await Bun.file(E).exists()){let M=await import(E);w={...M.default||M,...w}}}console.log(`${T.green}[Crosswind]${T.reset} Using inline CSS config from stx.config.ts`)}}catch{}r1=w||await Q9(X);try{HZ=OZ(JSON.stringify(r1??{}))}catch{HZ="unhashable"}}let U=Y.defaultConfig||Y.config,z=r1||{},_=U.theme||{},B=(z.theme||{}).extend||{},j={..._};if(Object.keys(B).length>0)j.extend=B;let H=[...U.safelist||[],...z.safelist||[]],O={...U,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},V=new Y.CSSGenerator(O);for(let w of H)V.generate(w);for(let w of J)V.generate(w);let L=V.toCSS(!0,!1),F=O.shortcuts||z.shortcuts||{};for(let[w,N]of Object.entries(F)){if(!J.has(w)&&!H.includes(w))continue;let R=N.split(/\s+/).filter(Boolean);for(let E of R)V.generate(E)}L=V.toCSS(!0,!1);let A=L.split(`
945
945
  `);for(let[w,N]of Object.entries(F)){if(!J.has(w)&&!H.includes(w))continue;let R=N.split(/\s+/).filter(Boolean),E=[],M=[];for(let I of R){let S=I.startsWith("dark:"),y=`.${(S?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<A.length;b++){let h=A[b].trim();if(h===`${y} {`||h.startsWith(`${y} {`)){let r=b,m="";while(r<A.length){if(m+=A[r],A[r].includes("}"))break;r++}let P=m.match(/\{([^}]+)\}/);if(P)if(S)M.push(P[1].trim());else E.push(P[1].trim());break}}}if(E.length)L+=`
946
946
  .${w} { ${E.join(" ")} }`;if(M.length)L+=`
947
947
  @media (prefers-color-scheme: dark) { .dark .${w} { ${M.join(" ")} } }`}return Z9(G,L),qT(G,L),L}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function y0($,Z,Y=!1){let J=await VZ($,Z);if(!J)return $;let X=Y?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${zT(J)}.css">`:`<style data-crosswind="generated">
@@ -1293,7 +1293,7 @@ else {
1293
1293
 
1294
1294
  console.log('[stx] Lifecycle runtime initialized');
1295
1295
  })();
1296
- `}function G9($){return Symbol($)}var pu,iu,nu;var F_=D(()=>{pu=G9("theme"),iu=G9("router"),nu=G9("i18n")});import*as w_ from"crypto";function A_($){let Z=/\$(\w+)\./g,Y=[],J;while((J=Z.exec($))!==null)if(!Y.includes(J[1]))Y.push(J[1]);return Y}function VT(){return`stx-${w_.randomBytes(4).toString("hex")}`}function FT($){return/\$\w+\./.test($)}function N_($){let Z=[],Y=new Set,J=/<(\w+)([^>]*?)(\s*\/?>)/g,X=$;return X=X.replace(J,(Q,G,K,W)=>{if(["script","style","template"].includes(G.toLowerCase()))return Q;let U=[],z=!1,_=K,q=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,B=[...K.matchAll(q)];for(let O of B){let V=O[0],L=O[1],F=O[2];if(FT(F)){z=!0;let A=F.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(A){let w=A[1];if(U.push({attr:L,expr:w,fullMatch:V,originalAttr:L}),A_(w).forEach((R)=>Y.add(R)),L==="text")_=_.replace(V,"");else if(L==="class")_=_.replace(V,'class=""');else if(L==="disabled"||L==="hidden")_=_.replace(V,"");else _=_.replace(V,`${L}=""`)}}}if(!z)return Q;let j=_.match(/\bid\s*=\s*"([^"]+)"/),H;if(j)H=j[1];else H=VT(),_=` id="${H}"${_}`;for(let O of U)Z.push({elementId:H,attribute:O.attr,expression:O.expr,stores:A_(O.expr)});return`<${G}${_}${W}`}),{html:X,bindings:Z,stores:Y}}function R_($,Z){if($.length===0)return"";let Y=Array.from(Z),J=`
1296
+ `}function G9($){return Symbol($)}var nu,ru,au;var F_=D(()=>{nu=G9("theme"),ru=G9("router"),au=G9("i18n")});import*as w_ from"crypto";function A_($){let Z=/\$(\w+)\./g,Y=[],J;while((J=Z.exec($))!==null)if(!Y.includes(J[1]))Y.push(J[1]);return Y}function VT(){return`stx-${w_.randomBytes(4).toString("hex")}`}function FT($){return/\$\w+\./.test($)}function N_($){let Z=[],Y=new Set,J=/<(\w+)([^>]*?)(\s*\/?>)/g,X=$;return X=X.replace(J,(Q,G,K,W)=>{if(["script","style","template"].includes(G.toLowerCase()))return Q;let U=[],z=!1,_=K,q=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,B=[...K.matchAll(q)];for(let O of B){let V=O[0],L=O[1],F=O[2];if(FT(F)){z=!0;let A=F.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(A){let w=A[1];if(U.push({attr:L,expr:w,fullMatch:V,originalAttr:L}),A_(w).forEach((R)=>Y.add(R)),L==="text")_=_.replace(V,"");else if(L==="class")_=_.replace(V,'class=""');else if(L==="disabled"||L==="hidden")_=_.replace(V,"");else _=_.replace(V,`${L}=""`)}}}if(!z)return Q;let j=_.match(/\bid\s*=\s*"([^"]+)"/),H;if(j)H=j[1];else H=VT(),_=` id="${H}"${_}`;for(let O of U)Z.push({elementId:H,attribute:O.attr,expression:O.expr,stores:A_(O.expr)});return`<${G}${_}${W}`}),{html:X,bindings:Z,stores:Y}}function R_($,Z){if($.length===0)return"";let Y=Array.from(Z),J=`
1297
1297
  <script>
1298
1298
  (function() {
1299
1299
  'use strict';
@@ -2242,7 +2242,7 @@ ${aB($).split(",").map((Q)=>Q.trim()).filter(Boolean).map((Q)=>` try { __scopeR
2242
2242
  ${L}
2243
2243
  `,w=Function(...B,F)(...j);if(w&&typeof w==="object")Object.assign(Z,w);Q=Q.replace(U,"")}catch(q){console.error(`Error executing ${J} code block in ${Y}:`,q);let B=q instanceof Error?q.message:String(q),j=E0(`${J} Directive`,`Error executing code: ${B}`,Y,$,_,U);console.error(j),Q=Q.replace(U,"")}return Q}var Zj=D(()=>{$6();R0()});function eI($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function Yj($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,J,X,Q)=>{return eI(J,Q||"_method")})}async function f2($,Z,Y,J,X){if(!J.middleware||J.middleware.length===0)return $;let Q=$,G=J.middleware.filter((K)=>K.timing===X);if(G.length===0)return Q;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(J.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(Q,Z,Y,J);if(typeof W==="string")Q=W;else if(J.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(J.debug)console.error(`Error in middleware ${K.name}:`,W);if(J.debug){let U=E0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
2244
2244
  <div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${f0(U)}</div>
2245
- `)}}}return Q}async function g2($,Z,Y,J){return f2($,Z,Y,J,"before")}async function h2($,Z,Y,J){return f2($,Z,Y,J,"after")}var d2=D(()=>{Z1();R0()});import{defineRoute as sc,defineRoutes as oc,resetRoutes as tc,route as ec,setAppUrl as $p}from"stx-router";import{route as $D}from"stx-router";function Jj($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,J,X,Q)=>{try{let G=X?n0(X,{}):{};return $D(J,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var Xj=D(()=>{r0()});function u2($,Z,Y,J){let X=$;X=X.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,U)=>{if(!U&&W.includes(":")){let z=W.split(":"),_=W,q=z.length>1?z[1]:"";if(q&&Z[q])U=Z[q];else if(_.startsWith("og:")&&Z.openGraph&&Z.openGraph[z[1]])U=Z.openGraph[z[1]];else U="";return U?`<meta property="${z0(_)}" content="${z0(U)}">`:""}return U?`<meta name="${z0(W)}" content="${z0(U)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(X))!==null){let K=G.index,W=K+G[0].length-1,U=1,z=W+1;while(z<X.length&&U>0){if(X[z]==="(")U++;else if(X[z]===")"){if(U--,U===0)break}z++}if(U!==0)break;let _=X.substring(W+1,z).trim(),q=z+1,B=(()=>{try{let j=n0(_,Z);if(!j)return"";let H="<meta";if(j.name)H+=` name="${z0(String(j.name))}"`;if(j.property)H+=` property="${z0(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${z0(String(j.httpEquiv))}"`;if(j.content)H+=` content="${z0(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return H0("MetaTag",H,G0.EVALUATION_ERROR)}})();X=X.substring(0,K)+B+X.substring(q),Q.lastIndex=0}return X}function m2($,Z,Y){let J=$,X=/@structuredData\s*\(/g,Q;while((Q=X.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1;while(U<J.length&&W>0){if(J[U]==="(")W++;else if(J[U]===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=J.substring(K+1,U).trim(),_=U+1,q=(()=>{try{let B=n0(z,Z);if(!B)return"";if(!B["@context"])B["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(B).replace(/<\//g,"<\\/")}</script>`}catch(B){let j=B instanceof Error?B.message:String(B);return H0("StructuredData",j,G0.EVALUATION_ERROR)}})();J=J.substring(0,G)+q+J.substring(_),X.lastIndex=0}return J}function l2($,Z,Y,J){let X=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(X))!==null){let K=X.indexOf("{",G.index+4),W=1,U=K+1,z=null,_=!1;while(U<X.length&&W>0){let V=X[U];if(_){_=!1,U++;continue}if(V==="\\"&&z){_=!0,U++;continue}if(z){if(V===z)z=null;U++;continue}if(V==='"'||V==="'"||V==="`"){z=V,U++;continue}if(V==="{")W++;else if(V==="}")W--;U++}if(W!==0)break;let q=X.substring(U).match(/^\s*\)/);if(!q)break;let B=U+q[0].length,j=X.substring(K,U),H=X.substring(G.index,B),O=((V)=>{try{let L=n0(V,Z);if(!L)return"";let F="";if(L.title)F+=`<title>${z0(L.title)}</title>
2245
+ `)}}}return Q}async function g2($,Z,Y,J){return f2($,Z,Y,J,"before")}async function h2($,Z,Y,J){return f2($,Z,Y,J,"after")}var d2=D(()=>{Z1();R0()});import{defineRoute as tc,defineRoutes as ec,resetRoutes as $p,route as Zp,setAppUrl as Yp}from"stx-router";import{route as $D}from"stx-router";function Jj($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,J,X,Q)=>{try{let G=X?n0(X,{}):{};return $D(J,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var Xj=D(()=>{r0()});function u2($,Z,Y,J){let X=$;X=X.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,U)=>{if(!U&&W.includes(":")){let z=W.split(":"),_=W,q=z.length>1?z[1]:"";if(q&&Z[q])U=Z[q];else if(_.startsWith("og:")&&Z.openGraph&&Z.openGraph[z[1]])U=Z.openGraph[z[1]];else U="";return U?`<meta property="${z0(_)}" content="${z0(U)}">`:""}return U?`<meta name="${z0(W)}" content="${z0(U)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(X))!==null){let K=G.index,W=K+G[0].length-1,U=1,z=W+1;while(z<X.length&&U>0){if(X[z]==="(")U++;else if(X[z]===")"){if(U--,U===0)break}z++}if(U!==0)break;let _=X.substring(W+1,z).trim(),q=z+1,B=(()=>{try{let j=n0(_,Z);if(!j)return"";let H="<meta";if(j.name)H+=` name="${z0(String(j.name))}"`;if(j.property)H+=` property="${z0(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${z0(String(j.httpEquiv))}"`;if(j.content)H+=` content="${z0(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return H0("MetaTag",H,G0.EVALUATION_ERROR)}})();X=X.substring(0,K)+B+X.substring(q),Q.lastIndex=0}return X}function m2($,Z,Y){let J=$,X=/@structuredData\s*\(/g,Q;while((Q=X.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1;while(U<J.length&&W>0){if(J[U]==="(")W++;else if(J[U]===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=J.substring(K+1,U).trim(),_=U+1,q=(()=>{try{let B=n0(z,Z);if(!B)return"";if(!B["@context"])B["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(B).replace(/<\//g,"<\\/")}</script>`}catch(B){let j=B instanceof Error?B.message:String(B);return H0("StructuredData",j,G0.EVALUATION_ERROR)}})();J=J.substring(0,G)+q+J.substring(_),X.lastIndex=0}return J}function l2($,Z,Y,J){let X=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(X))!==null){let K=X.indexOf("{",G.index+4),W=1,U=K+1,z=null,_=!1;while(U<X.length&&W>0){let V=X[U];if(_){_=!1,U++;continue}if(V==="\\"&&z){_=!0,U++;continue}if(z){if(V===z)z=null;U++;continue}if(V==='"'||V==="'"||V==="`"){z=V,U++;continue}if(V==="{")W++;else if(V==="}")W--;U++}if(W!==0)break;let q=X.substring(U).match(/^\s*\)/);if(!q)break;let B=U+q[0].length,j=X.substring(K,U),H=X.substring(G.index,B),O=((V)=>{try{let L=n0(V,Z);if(!L)return"";let F="";if(L.title)F+=`<title>${z0(L.title)}</title>
2246
2246
  `,F+=`<meta name="title" content="${z0(L.title)}">
2247
2247
  `;if(L.description)F+=`<meta name="description" content="${z0(L.description)}">
2248
2248
  `;if(L.keywords){let A=Array.isArray(L.keywords)?L.keywords.join(", "):L.keywords;F+=`<meta name="keywords" content="${z0(A)}">
@@ -15576,14 +15576,14 @@ ${z}`)}else this.warnings.push(`External stylesheet not found: ${U}`)}return""})
15576
15576
  </table>
15577
15577
  </body>
15578
15578
  </html>`}generateAnalysisText($){let Z=["Bundle Analysis","=".repeat(50),""];for(let Y of $.outputs)Z.push(`${Y.path}`),Z.push(` Size: ${Y.sizeFormatted}${Y.gzipSizeFormatted?` (gzip: ${Y.gzipSizeFormatted})`:""}`),Z.push("");return Z.push("=".repeat(50)),Z.push(`Total: ${this.formatSize($.totalSize)} (gzip: ${this.formatSize($.totalGzipSize)})`),Z.join(`
15579
- `)}async runPluginHook($,Z){if(!this.config.plugins)return;for(let Y of this.config.plugins){let J=Y[$];if(typeof J==="function")await J.call(Y,Z||this)}}async runPluginTransform($,Z){if(!this.config.plugins)return $;let Y=$;for(let J of this.config.plugins)if(J.transform){let X=await J.transform(Y,Z);if(X!=null)Y=X}return Y}generateHash($){return xx("sha256").update($).digest("hex")}getOutputName($,Z,Y){let J=Z==="html"?".html":Z==="css"?".css":Z==="js"?".js":"";return`${$}.${Y.slice(0,8)}${J}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!Y3($))vx($,{recursive:!0})}walkDir($,Z){if(!Y3($))return;let Y=gx($,{withFileTypes:!0});for(let J of Y){let X=N4($,J.name);if(J.isDirectory())this.walkDir(X,Z);else Z(X)}}getResult(){let $=Date.now()-this.startTime,Z=this.outputs.reduce((J,X)=>J+X.size,0),Y=this.outputs.reduce((J,X)=>J+(X.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:Z,gzipSize:Y,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function ux($){return new iJ($).build()}function mx($){return new iJ($)}function lx($){return{...lF,...$}}var lF;var cF=D(()=>{lF={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}}});async function cx($,Z={}){return(await pF($,Z)).html}async function YW($,Z={}){let{html:Y,context:J}=await pF($,Z),{extractStreamBoundaries:X}=await Promise.resolve().then(() => (W6(),o6)),Q=X(J),G=$.streamTemplates;if(G&&Object.keys(G).length>0){let{processDirectives:K}=await Promise.resolve().then(() => (q1(),uY)),{defaultConfig:W}=await Promise.resolve().then(() => (a0(),AZ)),U=J.streamBoundaries||{},z={...W,autoShell:!1},_=Object.keys(G).map((B)=>({id:B,render:async()=>{let j=typeof U[B]==="function"?await U[B]():void 0;return K(G[B],{...J,$boundary:j},$.sourceFile,z,new Set)}})),q=new Set(_.map((B)=>B.id));Q=[...(Q||[]).filter((B)=>!q.has(B.id)),..._]}return{html:Y,boundaries:Q&&Q.length>0?Q:void 0}}async function pF($,Z){let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};if(!$.hasServerScripts&&!E$($.html))return{html:$.html,context:Y};for(let X of $.serverScriptContent)try{await k0(X,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!E$($.html))return{html:$.html,context:Y};let J=new Map;for(let[X,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=K1(Q.expression,Y);if(Q.type==="raw")J.set(X,G!==void 0&&G!==null?String(G):"");else J.set(X,G!==void 0&&G!==null?f0(String(G)):"")}catch{J.set(X,"")}return{html:qZ($.html,J),context:Y}}async function px($,Z={}){if(!$.hasServerScripts&&!E$($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let X of $.serverScriptContent)try{await k0(X,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!E$($.fragment))return $.fragment;let J=new Map;for(let[X,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=K1(Q.expression,Y);if(Q.type==="raw")J.set(X,G!==void 0&&G!==null?String(G):"");else J.set(X,G!==void 0&&G!==null?f0(String(G)):"")}catch{J.set(X,"")}return qZ($.fragment,J)}var JW=D(()=>{z6();Z1();V7()});var rF={};$0(rF,{startProductionServer:()=>nF});import iF from"fs";import I6 from"path";var{serve:ix}=globalThis.Bun;async function nF($={}){let Z=I6.resolve($.outputDir||".output"),Y=$.port||3000,J=CK(Z);if(!J)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${J.routes.length} routes...`);let X=new Map,Q=new Map,G=new Map;for(let z of J.routes)try{let _=I6.join(Z,z.compiledPath),q=JSON.parse(await Bun.file(_).text());X.set(z.pattern,q),G.set(z.pattern,s8(q.html));let B=I6.join(Z,z.fragmentPath);if(await Bun.file(B).exists())Q.set(z.pattern,await Bun.file(B).text())}catch(_){console.warn(`[stx] Failed to load route ${z.pattern}:`,_)}let K=new Map,W=[];for(let z of J.routes)if(z.hasParams){let _=[],q=z.pattern.replace(/:([^/]+)/g,(B,j)=>{return _.push(j),"([^/]+)"});W.push({regex:new RegExp(`^${q}$`),route:z,paramNames:_})}else K.set(z.pattern,z);let U=ix({port:Y,async fetch(z){let q=new URL(z.url).pathname;if($.onRequest){let V=await $.onRequest(z);if(V)return V}if($.apiRoutes?.[q])return $.apiRoutes[q](z);if((z.method==="GET"||z.method==="HEAD")&&q!=="/"){let V=I6.resolve(Z,"public"),L;try{L=decodeURIComponent(q)}catch{L=q}if(!L.includes("\x00")){let F=I6.resolve(V,`.${L}`);if(F===V||F.startsWith(`${V}${I6.sep}`))try{if(iF.existsSync(F)&&iF.statSync(F).isFile()){let w=I6.extname(F).toLowerCase(),N=nx[w]||"application/octet-stream",R=q.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(q);return new Response(Bun.file(F),{headers:{"Content-Type":N,"Cache-Control":R?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let B=z.headers.get("X-STX-Router")==="true",j=null,H={};if(j=K.get(q)||null,!j)for(let{regex:V,route:L,paramNames:F}of W){let A=q.match(V);if(A){j=L,F.forEach((w,N)=>{H[w]=A[N+1]});break}}if(!j){let V=K.get("/404")||null;if(V){let L=X.get(V.pattern);if(L)return new Response(L.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(B){let V=Q.get(j.pattern);if(V){let L=G.get(j.pattern);return new Response(V,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...L?{"X-STX-Layout":L.layout,"X-STX-Layout-Group":L.group}:{},"Cache-Control":"no-cache"}})}}let O=X.get(j.pattern);if(!O){let V=K.get("/500")||null;if(V){let L=X.get(V.pattern);if(L)return new Response(L.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!O.hasServerScripts&&Object.keys(O.placeholders).length===0)return new Response(O.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:V,boundaries:L}=await YW(O,{params:H,request:z});if(L&&L.length>0){let{renderStreamingPage:F,streamToResponse:A}=await Promise.resolve().then(() => (W6(),o6));return A(F(V,L,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(V){return console.error(`[stx] Hydration error for ${q}:`,V),new Response(O.html,{headers:{"Content-Type":"text/html"}})}}});return console.log(`[stx] Production server running at http://localhost:${Y}`),console.log(`[stx] Serving ${J.routes.length} routes (${X.size} pre-loaded)`),{port:Y,stop:()=>U.stop()}}var nx;var XW=D(()=>{dJ();JW();u5();nx={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"}});var QW="f9c3713";import{existsSync as Q3,mkdirSync as GW}from"fs";import{join as D6,dirname as rx}from"path";import{execSync as aF}from"child_process";async function sx($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.template||"default",X=D6(process.cwd(),$);if(Q3(X))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{GW(X,{recursive:!0});let Q=ox(J);for(let K of Q)GW(D6(X,K),{recursive:!0});let G=tx(J,$,Z);for(let[K,W]of Object.entries(G)){let U=D6(X,K);G3(rx(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{aF("git init",{cwd:X,stdio:"ignore"}),await Bun.write(D6(X,".gitignore"),_v()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||bv();try{console.log(`
15579
+ `)}async runPluginHook($,Z){if(!this.config.plugins)return;for(let Y of this.config.plugins){let J=Y[$];if(typeof J==="function")await J.call(Y,Z||this)}}async runPluginTransform($,Z){if(!this.config.plugins)return $;let Y=$;for(let J of this.config.plugins)if(J.transform){let X=await J.transform(Y,Z);if(X!=null)Y=X}return Y}generateHash($){return xx("sha256").update($).digest("hex")}getOutputName($,Z,Y){let J=Z==="html"?".html":Z==="css"?".css":Z==="js"?".js":"";return`${$}.${Y.slice(0,8)}${J}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!Y3($))vx($,{recursive:!0})}walkDir($,Z){if(!Y3($))return;let Y=gx($,{withFileTypes:!0});for(let J of Y){let X=N4($,J.name);if(J.isDirectory())this.walkDir(X,Z);else Z(X)}}getResult(){let $=Date.now()-this.startTime,Z=this.outputs.reduce((J,X)=>J+X.size,0),Y=this.outputs.reduce((J,X)=>J+(X.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:Z,gzipSize:Y,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function ux($){return new iJ($).build()}function mx($){return new iJ($)}function lx($){return{...lF,...$}}var lF;var cF=D(()=>{lF={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}}});async function cx($,Z={}){return(await pF($,Z)).html}async function YW($,Z={}){let{html:Y,context:J}=await pF($,Z),{extractStreamBoundaries:X}=await Promise.resolve().then(() => (W6(),o6)),Q=X(J),G=$.streamTemplates;if(G&&Object.keys(G).length>0){let{processDirectives:K}=await Promise.resolve().then(() => (q1(),uY)),{defaultConfig:W}=await Promise.resolve().then(() => (a0(),AZ)),U=J.streamBoundaries||{},z={...W,autoShell:!1},_=Object.keys(G).map((B)=>({id:B,render:async()=>{let j=typeof U[B]==="function"?await U[B]():void 0;return K(G[B],{...J,$boundary:j},$.sourceFile,z,new Set)}})),q=new Set(_.map((B)=>B.id));Q=[...(Q||[]).filter((B)=>!q.has(B.id)),..._]}return{html:Y,boundaries:Q&&Q.length>0?Q:void 0}}async function pF($,Z){let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};if(!$.hasServerScripts&&!E$($.html))return{html:$.html,context:Y};for(let X of $.serverScriptContent)try{await k0(X,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!E$($.html))return{html:$.html,context:Y};let J=new Map;for(let[X,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=K1(Q.expression,Y);if(Q.type==="raw")J.set(X,G!==void 0&&G!==null?String(G):"");else J.set(X,G!==void 0&&G!==null?f0(String(G)):"")}catch{J.set(X,"")}return{html:qZ($.html,J),context:Y}}async function px($,Z={}){if(!$.hasServerScripts&&!E$($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let X of $.serverScriptContent)try{await k0(X,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!E$($.fragment))return $.fragment;let J=new Map;for(let[X,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=K1(Q.expression,Y);if(Q.type==="raw")J.set(X,G!==void 0&&G!==null?String(G):"");else J.set(X,G!==void 0&&G!==null?f0(String(G)):"")}catch{J.set(X,"")}return qZ($.fragment,J)}var JW=D(()=>{z6();Z1();V7()});var rF={};$0(rF,{startProductionServer:()=>nF});import iF from"fs";import I6 from"path";var{serve:ix}=globalThis.Bun;import{patternToRegex as nx}from"stx-router";async function nF($={}){let Z=I6.resolve($.outputDir||".output"),Y=$.port||3000,J=CK(Z);if(!J)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${J.routes.length} routes...`);let X=new Map,Q=new Map,G=new Map;for(let z of J.routes)try{let _=I6.join(Z,z.compiledPath),q=JSON.parse(await Bun.file(_).text());X.set(z.pattern,q),G.set(z.pattern,s8(q.html));let B=I6.join(Z,z.fragmentPath);if(await Bun.file(B).exists())Q.set(z.pattern,await Bun.file(B).text())}catch(_){console.warn(`[stx] Failed to load route ${z.pattern}:`,_)}let K=new Map,W=[];for(let z of J.routes)if(z.hasParams){let{regex:_,params:q}=nx(z.pattern);W.push({regex:_,route:z,paramNames:q})}else K.set(z.pattern,z);let U=ix({port:Y,async fetch(z){let q=new URL(z.url).pathname;if($.onRequest){let V=await $.onRequest(z);if(V)return V}if($.apiRoutes?.[q])return $.apiRoutes[q](z);if((z.method==="GET"||z.method==="HEAD")&&q!=="/"){let V=I6.resolve(Z,"public"),L;try{L=decodeURIComponent(q)}catch{L=q}if(!L.includes("\x00")){let F=I6.resolve(V,`.${L}`);if(F===V||F.startsWith(`${V}${I6.sep}`))try{if(iF.existsSync(F)&&iF.statSync(F).isFile()){let w=I6.extname(F).toLowerCase(),N=rx[w]||"application/octet-stream",R=q.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(q);return new Response(Bun.file(F),{headers:{"Content-Type":N,"Cache-Control":R?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let B=z.headers.get("X-STX-Router")==="true",j=null,H={};if(j=K.get(q)||null,!j)for(let{regex:V,route:L,paramNames:F}of W){let A=q.match(V);if(A){j=L,F.forEach((w,N)=>{H[w]=A[N+1]});break}}if(!j){let V=K.get("/404")||null;if(V){let L=X.get(V.pattern);if(L)return new Response(L.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(B){let V=Q.get(j.pattern);if(V){let L=G.get(j.pattern);return new Response(V,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...L?{"X-STX-Layout":L.layout,"X-STX-Layout-Group":L.group}:{},"Cache-Control":"no-cache"}})}}let O=X.get(j.pattern);if(!O){let V=K.get("/500")||null;if(V){let L=X.get(V.pattern);if(L)return new Response(L.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!O.hasServerScripts&&Object.keys(O.placeholders).length===0)return new Response(O.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:V,boundaries:L}=await YW(O,{params:H,request:z});if(L&&L.length>0){let{renderStreamingPage:F,streamToResponse:A}=await Promise.resolve().then(() => (W6(),o6));return A(F(V,L,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(V){return console.error(`[stx] Hydration error for ${q}:`,V),new Response(O.html,{headers:{"Content-Type":"text/html"}})}}});return console.log(`[stx] Production server running at http://localhost:${Y}`),console.log(`[stx] Serving ${J.routes.length} routes (${X.size} pre-loaded)`),{port:Y,stop:()=>U.stop()}}var rx;var XW=D(()=>{dJ();JW();u5();rx={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"}});var QW="f9c3713";import{existsSync as Q3,mkdirSync as GW}from"fs";import{join as D6,dirname as ax}from"path";import{execSync as aF}from"child_process";async function ox($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.template||"default",X=D6(process.cwd(),$);if(Q3(X))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{GW(X,{recursive:!0});let Q=tx(J);for(let K of Q)GW(D6(X,K),{recursive:!0});let G=ex(J,$,Z);for(let[K,W]of Object.entries(G)){let U=D6(X,K);G3(ax(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{aF("git init",{cwd:X,stdio:"ignore"}),await Bun.write(D6(X,".gitignore"),qv()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||Pv();try{console.log(`
15580
15580
  Installing dependencies with ${K}...`),aF(`${K} install`,{cwd:X,stdio:"inherit"})}catch{Y.errors.push("Failed to install dependencies")}}Y.message=`Created project: ${$}`,console.log(`
15581
15581
  \u2705 ${Y.message}
15582
15582
 
15583
15583
  Next steps:
15584
15584
  cd ${$}
15585
15585
  ${Z.packageManager||"bun"} run dev
15586
- `)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function ox($){let Z=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...Z,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...Z,"src/posts","src/utils"];case"dashboard":return[...Z,"src/stores","src/api","src/utils"];case"landing":return[...Z,"src/sections"];default:return[...Z,"src/stores"]}}function tx($,Z,Y){let J={};if(J["package.json"]=Kv(Z,$,Y),J["stx.config.ts"]=Wv($,Y),J["README.md"]=zv(Z,$),Y.typescript!==!1)J["tsconfig.json"]=Uv();switch($){case"minimal":J["src/index.stx"]=qv();break;case"blog":J["pages/index.stx"]=Ov(),J["pages/[slug].stx"]=Lv(),J["layouts/app.stx"]=Vv(),J["components/PostCard.stx"]=Fv();break;case"dashboard":J["pages/index.stx"]=Av(),J["pages/settings.stx"]=wv(),J["layouts/app.stx"]=Nv(),J["components/Sidebar.stx"]=Rv(),J["components/StatsCard.stx"]=Mv(),J["src/stores/dashboard.ts"]=Tv();break;case"landing":J["pages/index.stx"]=Ev(),J["layouts/app.stx"]=Iv(),J["src/sections/Hero.stx"]=Dv(),J["src/sections/Features.stx"]=kv(),J["src/sections/Pricing.stx"]=Sv(),J["components/Button.stx"]=Cv();break;case"full":J["pages/index.stx"]=sF(),J["pages/about.stx"]=Bv(),J["layouts/app.stx"]=oF(),J["components/Header.stx"]=tF(),J["components/Footer.stx"]=eF(),J["src/stores/app.ts"]=$A(),J["src/i18n/en.json"]=jv("en"),J["test/example.test.ts"]=Hv();break;default:J["pages/index.stx"]=sF(),J["layouts/app.stx"]=oF(),J["components/Header.stx"]=tF(),J["components/Footer.stx"]=eF(),J["src/stores/app.ts"]=$A()}return J}async function ex($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"components",X=KW($),Q=D6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Component ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Jv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created component: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create component: ${G}`}return Y}async function $v($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"pages",X=$.toLowerCase().replace(/\s+/g,"-"),Q=D6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Page ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Xv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created page: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create page: ${G}`}return Y}async function Zv($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"src/stores",X=Pv($),Q=D6(J,`${X}.ts`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Store ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Qv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created store: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create store: ${G}`}return Y}async function Yv($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"layouts",X=$.toLowerCase().replace(/\s+/g,"-"),Q=D6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Layout ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Gv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created layout: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create layout: ${G}`}return Y}function Jv($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
15586
+ `)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function tx($){let Z=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...Z,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...Z,"src/posts","src/utils"];case"dashboard":return[...Z,"src/stores","src/api","src/utils"];case"landing":return[...Z,"src/sections"];default:return[...Z,"src/stores"]}}function ex($,Z,Y){let J={};if(J["package.json"]=Wv(Z,$,Y),J["stx.config.ts"]=Uv($,Y),J["README.md"]=_v(Z,$),Y.typescript!==!1)J["tsconfig.json"]=zv();switch($){case"minimal":J["src/index.stx"]=Bv();break;case"blog":J["pages/index.stx"]=Lv(),J["pages/[slug].stx"]=Vv(),J["layouts/app.stx"]=Fv(),J["components/PostCard.stx"]=Av();break;case"dashboard":J["pages/index.stx"]=wv(),J["pages/settings.stx"]=Nv(),J["layouts/app.stx"]=Rv(),J["components/Sidebar.stx"]=Mv(),J["components/StatsCard.stx"]=Tv(),J["src/stores/dashboard.ts"]=Ev();break;case"landing":J["pages/index.stx"]=Iv(),J["layouts/app.stx"]=Dv(),J["src/sections/Hero.stx"]=kv(),J["src/sections/Features.stx"]=Sv(),J["src/sections/Pricing.stx"]=Cv(),J["components/Button.stx"]=bv();break;case"full":J["pages/index.stx"]=sF(),J["pages/about.stx"]=jv(),J["layouts/app.stx"]=oF(),J["components/Header.stx"]=tF(),J["components/Footer.stx"]=eF(),J["src/stores/app.ts"]=$A(),J["src/i18n/en.json"]=Hv("en"),J["test/example.test.ts"]=Ov();break;default:J["pages/index.stx"]=sF(),J["layouts/app.stx"]=oF(),J["components/Header.stx"]=tF(),J["components/Footer.stx"]=eF(),J["src/stores/app.ts"]=$A()}return J}async function $v($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"components",X=KW($),Q=D6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Component ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Xv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created component: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create component: ${G}`}return Y}async function Zv($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"pages",X=$.toLowerCase().replace(/\s+/g,"-"),Q=D6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Page ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Qv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created page: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create page: ${G}`}return Y}async function Yv($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"src/stores",X=yv($),Q=D6(J,`${X}.ts`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Store ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Gv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created store: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create store: ${G}`}return Y}async function Jv($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},J=Z.dir||"layouts",X=$.toLowerCase().replace(/\s+/g,"-"),Q=D6(J,`${X}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Layout ${X} already exists. Use --force to overwrite.`,Y;try{G3(J);let G=Kv(X,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created layout: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create layout: ${G}`}return Y}function Xv($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
15587
15587
  // Props
15588
15588
  const title = props.title || '${$}'
15589
15589
  const variant = props.variant || 'default'
@@ -15613,7 +15613,7 @@ const variant = props.variant || 'default'
15613
15613
  margin-top: 0.5rem;
15614
15614
  }
15615
15615
  </style>`);return Y.join(`
15616
- `)}function Xv($,Z){let Y=KW($.replace(/-/g," ")),J=[];if(J.push(`<script>
15616
+ `)}function Qv($,Z){let Y=KW($.replace(/-/g," ")),J=[];if(J.push(`<script>
15617
15617
  const title = '${Y}'
15618
15618
  const description = 'Page description'
15619
15619
  </script>
@@ -15626,7 +15626,7 @@ const description = 'Page description'
15626
15626
  <p>{{ description }}</p>
15627
15627
  </div>
15628
15628
  @endsection`),J.join(`
15629
- `)}function Qv($,Z){let Y=`${$}Store`,J=`${KW($)}State`,X=`import { defineStore } from 'stx'
15629
+ `)}function Gv($,Z){let Y=`${$}Store`,J=`${KW($)}State`,X=`import { defineStore } from 'stx'
15630
15630
 
15631
15631
  interface ${J} {
15632
15632
  // Add your state properties here
@@ -15674,7 +15674,7 @@ finally {
15674
15674
  ],
15675
15675
  },
15676
15676
  `;return X+=`})
15677
- `,X}function Gv($,Z){let Y=`<!DOCTYPE html>
15677
+ `,X}function Kv($,Z){let Y=`<!DOCTYPE html>
15678
15678
  <html lang="en">
15679
15679
  <head>
15680
15680
  <meta charset="UTF-8">
@@ -15721,7 +15721,7 @@ finally {
15721
15721
 
15722
15722
  `;return Y+=` @yield('scripts')
15723
15723
  </body>
15724
- </html>`,Y}function Kv($,Z,Y){let J={name:$,version:"0.0.1",type:"module",scripts:{dev:"stx dev pages/index.stx",build:"stx build",preview:"stx serve dist"},dependencies:{stx:"latest"},devDependencies:{}};if(Y.typescript!==!1)J.devDependencies.typescript="^5.0.0";if(Y.tailwind)J.devDependencies.tailwindcss="^3.0.0";if(Z==="full")J.scripts.test="bun test",J.scripts.lint="bun run lint";return JSON.stringify(J,null,2)}function Wv($,Z){return`import { defineConfig } from 'stx'
15724
+ </html>`,Y}function Wv($,Z,Y){let J={name:$,version:"0.0.1",type:"module",scripts:{dev:"stx dev pages/index.stx",build:"stx build",preview:"stx serve dist"},dependencies:{stx:"latest"},devDependencies:{}};if(Y.typescript!==!1)J.devDependencies.typescript="^5.0.0";if(Y.tailwind)J.devDependencies.tailwindcss="^3.0.0";if(Z==="full")J.scripts.test="bun test",J.scripts.lint="bun run lint";return JSON.stringify(J,null,2)}function Uv($,Z){return`import { defineConfig } from 'stx'
15725
15725
 
15726
15726
  export default defineConfig({
15727
15727
  // Template directories
@@ -15742,7 +15742,7 @@ ${Z.pwa?` pwa: { enabled: true },
15742
15742
  // Analytics (configure when ready)
15743
15743
  // analytics: { enabled: true, driver: 'fathom', fathom: { siteId: 'YOUR_SITE_ID' } },
15744
15744
  })
15745
- `}function Uv(){return JSON.stringify({compilerOptions:{target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,skipLibCheck:!0,esModuleInterop:!0,types:["bun-types"]},include:["src/**/*","test/**/*"]},null,2)}function zv($,Z){return`# ${$}
15745
+ `}function zv(){return JSON.stringify({compilerOptions:{target:"ESNext",module:"ESNext",moduleResolution:"bundler",strict:!0,skipLibCheck:!0,esModuleInterop:!0,types:["bun-types"]},include:["src/**/*","test/**/*"]},null,2)}function _v($,Z){return`# ${$}
15746
15746
 
15747
15747
  A stx project created with the \`${Z}\` template.
15748
15748
 
@@ -15774,7 +15774,7 @@ src/
15774
15774
 
15775
15775
  - [stx Documentation](https://stx.dev/docs)
15776
15776
  - [stx GitHub](https://github.com/stacksjs/stx)
15777
- `}function _v(){return`# Dependencies
15777
+ `}function qv(){return`# Dependencies
15778
15778
  node_modules/
15779
15779
  .bun/
15780
15780
 
@@ -15799,7 +15799,7 @@ Thumbs.db
15799
15799
 
15800
15800
  # Logs
15801
15801
  *.log
15802
- `}function qv(){return`<!DOCTYPE html>
15802
+ `}function Bv(){return`<!DOCTYPE html>
15803
15803
  <html lang="en">
15804
15804
  <head>
15805
15805
  <meta charset="UTF-8">
@@ -15844,7 +15844,7 @@ const features = [
15844
15844
  @endforeach
15845
15845
  </div>
15846
15846
  @endsection
15847
- `}function Bv(){return`<script>
15847
+ `}function jv(){return`<script>
15848
15848
  const title = 'About'
15849
15849
  </script>
15850
15850
 
@@ -15932,14 +15932,14 @@ export const appStore = defineStore('app', {
15932
15932
  strategies: [{ key: 'app-preferences', storage: localStorage }],
15933
15933
  },
15934
15934
  })
15935
- `}function jv($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function Hv(){return`import { describe, expect, it } from 'bun:test'
15935
+ `}function Hv($){return JSON.stringify({common:{welcome:"Welcome",home:"Home",about:"About",contact:"Contact"},messages:{loading:"Loading...",error:"An error occurred"}},null,2)}function Ov(){return`import { describe, expect, it } from 'bun:test'
15936
15936
 
15937
15937
  describe('Example', () => {
15938
15938
  it('should work', () => {
15939
15939
  expect(1 + 1).toBe(2)
15940
15940
  })
15941
15941
  })
15942
- `}function Ov(){return"<!-- Blog index -->"}function Lv(){return"<!-- Blog post -->"}function Vv(){return`<!DOCTYPE html>
15942
+ `}function Lv(){return"<!-- Blog index -->"}function Vv(){return"<!-- Blog post -->"}function Fv(){return`<!DOCTYPE html>
15943
15943
  <html lang="en">
15944
15944
  <head>
15945
15945
  <meta charset="UTF-8">
@@ -15979,7 +15979,7 @@ describe('Example', () => {
15979
15979
  </footer>
15980
15980
  @yield('scripts')
15981
15981
  </body>
15982
- </html>`}function Fv(){return"<!-- Post card -->"}function Av(){return"<!-- Dashboard index -->"}function wv(){return"<!-- Settings -->"}function Nv(){return`<!DOCTYPE html>
15982
+ </html>`}function Av(){return"<!-- Post card -->"}function wv(){return"<!-- Dashboard index -->"}function Nv(){return"<!-- Settings -->"}function Rv(){return`<!DOCTYPE html>
15983
15983
  <html lang="en">
15984
15984
  <head>
15985
15985
  <meta charset="UTF-8">
@@ -16015,7 +16015,7 @@ describe('Example', () => {
16015
16015
  </div>
16016
16016
  @yield('scripts')
16017
16017
  </body>
16018
- </html>`}function Rv(){return"<!-- Sidebar -->"}function Mv(){return"<!-- Stats card -->"}function Tv(){return"// Dashboard store"}function Ev(){return"<!-- Landing page -->"}function Iv(){return`<!DOCTYPE html>
16018
+ </html>`}function Mv(){return"<!-- Sidebar -->"}function Tv(){return"<!-- Stats card -->"}function Ev(){return"// Dashboard store"}function Iv(){return"<!-- Landing page -->"}function Dv(){return`<!DOCTYPE html>
16019
16019
  <html lang="en">
16020
16020
  <head>
16021
16021
  <meta charset="UTF-8">
@@ -16050,17 +16050,17 @@ describe('Example', () => {
16050
16050
  </footer>
16051
16051
  @yield('scripts')
16052
16052
  </body>
16053
- </html>`}function Dv(){return"<!-- Hero section -->"}function kv(){return"<!-- Features -->"}function Sv(){return"<!-- Pricing -->"}function Cv(){return"<!-- Button -->"}function G3($){if(!Q3($))GW($,{recursive:!0})}function bv(){if(Q3("bun.lockb"))return"bun";if(Q3("pnpm-lock.yaml"))return"pnpm";if(Q3("yarn.lock"))return"yarn";return"bun"}function KW($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function Pv($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function H$($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var ax;var ZA=D(()=>{ax={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:yv}=globalThis.Bun;import K3 from"fs";import k6 from"path";function xv($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function YA($={}){let{port:Z=3000,root:Y=".",stxOptions:J={},watch:X=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,z=k6.resolve(Y),_=new Map;async function q(L){let F=K3.statSync(L),A=`${L}:${F.mtimeMs}`,w=_.get(A);if(w)return w.content;for(let P of _.keys())if(P.startsWith(`${L}:`)&&P!==A)_.delete(P);let N=await Bun.file(L).text(),R=N,E=B4(N);if(E)R=E.content.trim();let M=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],S=[],k;while((k=M.exec(N))!==null){let P=k[1],d=k[2],l=k[0];if(P.includes("server"))S.push(d);else I.push(l)}let x=N.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:L,__dirname:k6.dirname(L)};for(let P of S)await k0(P,b,L);let m=await B0(y,b,L,J,new Set);if(x.length>0){let P=x.join(`
16053
+ </html>`}function kv(){return"<!-- Hero section -->"}function Sv(){return"<!-- Features -->"}function Cv(){return"<!-- Pricing -->"}function bv(){return"<!-- Button -->"}function G3($){if(!Q3($))GW($,{recursive:!0})}function Pv(){if(Q3("bun.lockb"))return"bun";if(Q3("pnpm-lock.yaml"))return"pnpm";if(Q3("yarn.lock"))return"yarn";return"bun"}function KW($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function yv($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function H$($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var sx;var ZA=D(()=>{sx={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:xv}=globalThis.Bun;import K3 from"fs";import k6 from"path";function vv($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function YA($={}){let{port:Z=3000,root:Y=".",stxOptions:J={},watch:X=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,z=k6.resolve(Y),_=new Map;async function q(L){let F=K3.statSync(L),A=`${L}:${F.mtimeMs}`,w=_.get(A);if(w)return w.content;for(let P of _.keys())if(P.startsWith(`${L}:`)&&P!==A)_.delete(P);let N=await Bun.file(L).text(),R=N,E=B4(N);if(E)R=E.content.trim();let M=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],S=[],k;while((k=M.exec(N))!==null){let P=k[1],d=k[2],l=k[0];if(P.includes("server"))S.push(d);else I.push(l)}let x=N.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:L,__dirname:k6.dirname(L)};for(let P of S)await k0(P,b,L);let m=await B0(y,b,L,J,new Set);if(x.length>0){let P=x.join(`
16054
16054
  `);if(m.match(/(<\/head>)/i))m=m.replace(/(<\/head>)/i,`${P}
16055
16055
  $1`)}if(I.length>0){let{interpolateScriptsInTemplate:P}=await Promise.resolve().then(() => (Z1(),N7)),d=P(I.join(`
16056
16056
  `),b);if(m.match(/(<\/body>)/i))m=m.replace(/(<\/body>)/i,`${d}
16057
16057
  $1`);else m+=`
16058
16058
  ${d}`}return _.set(A,{content:m,mtime:F.mtimeMs}),m}async function B(L){let F=K3.statSync(L),A=`${L}:${F.mtimeMs}`,w=_.get(A);if(w)return w.content;let{content:N}=await P4(L,J);return _.set(A,{content:N,mtime:F.mtimeMs}),N}function j(L){let F=L.startsWith("/")?L.slice(1):L,A=[F,`${F}.stx`,`${F}.md`,`${F}.html`,k6.join(F,"index.stx"),k6.join(F,"index.md"),k6.join(F,"index.html")];for(let w of A){let N=k6.join(z,w);if(K3.existsSync(N)&&K3.statSync(N).isFile())return N}return null}async function H(L){let F=new URL(L.url),A=async()=>{if(G[F.pathname])return await G[F.pathname](L);if(Q){let N=await Q(L);if(N)return N}let w=j(F.pathname);if(!w){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let N,R="text/html";if(w.endsWith(".stx"))N=await q(w);else if(w.endsWith(".md"))N=await B(w);else if(w.endsWith(".html"))N=await Bun.file(w).text();else if(w.endsWith(".css"))N=await Bun.file(w).text(),R="text/css";else if(w.endsWith(".js"))N=await Bun.file(w).text(),R="text/javascript";else if(w.endsWith(".json"))N=await Bun.file(w).text(),R="application/json";else return new Response(Bun.file(w));return new Response(N,{headers:{"Content-Type":R}})}catch(N){if(U)return await U(N,L);let R=N instanceof Error?N.message:String(N),M=J?.debug===!0?`<h1>Error</h1><pre>${R}
16059
- ${N instanceof Error?N.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(M,{status:500,headers:{"Content-Type":"text/html"}})}};for(let w=K.length-1;w>=0;w--){let N=K[w],R=A;A=async()=>await N(L,R)}return await A()}let O=yv({port:Z,fetch:H}),V=null;if(X)V=K3.watch(z,{recursive:!0},(L,F)=>{if(F&&(F.endsWith(".stx")||F.endsWith(".md")||F.endsWith(".html")))_.clear()});return{server:O,url:O.url.toString(),stop(){if(V)V.close();O.stop()}}}async function vv($,Z={}){let Y=k6.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let J=Y.endsWith(".md"),X=Y.endsWith(".stx");if(!J&&!X)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await YA({...Z,root:k6.dirname(Y),routes:{"/":async()=>{let Q;if(J){let{content:G}=await P4(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let z=K.join(`
16060
- `),_=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),q={};if(z.trim())await k0(z,q,Y);let B=new Set;Q=await B0(_,q,Y,Z.stxOptions||{},B)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function fv($){return $}function gv($){return $}var JA=D(()=>{d$();Q5();q1();R0()});import{existsSync as hv,readFileSync as dv}from"fs";class WW{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...uv,...$},this.options.includeBuiltins)Object.entries(XA).forEach(([Z,Y])=>{this.variables.set(Z,Y)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([Z,Y])=>{this.variables.set(Z,Y)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!hv($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let Z=dv($,"utf-8");return this.checkTemplate(Z,$)}checkTemplate($,Z="<inline>"){this.currentFile=Z,this.errors=[],this.warnings=[];let Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)this.analyzeScript(Y[1],$.indexOf(Y[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,Z){let Y=$.split(`
16059
+ ${N instanceof Error?N.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(M,{status:500,headers:{"Content-Type":"text/html"}})}};for(let w=K.length-1;w>=0;w--){let N=K[w],R=A;A=async()=>await N(L,R)}return await A()}let O=xv({port:Z,fetch:H}),V=null;if(X)V=K3.watch(z,{recursive:!0},(L,F)=>{if(F&&(F.endsWith(".stx")||F.endsWith(".md")||F.endsWith(".html")))_.clear()});return{server:O,url:O.url.toString(),stop(){if(V)V.close();O.stop()}}}async function fv($,Z={}){let Y=k6.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let J=Y.endsWith(".md"),X=Y.endsWith(".stx");if(!J&&!X)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await YA({...Z,root:k6.dirname(Y),routes:{"/":async()=>{let Q;if(J){let{content:G}=await P4(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let z=K.join(`
16060
+ `),_=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),q={};if(z.trim())await k0(z,q,Y);let B=new Set;Q=await B0(_,q,Y,Z.stxOptions||{},B)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function gv($){return $}function hv($){return $}var JA=D(()=>{d$();Q5();q1();R0()});import{existsSync as dv,readFileSync as uv}from"fs";class WW{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...mv,...$},this.options.includeBuiltins)Object.entries(XA).forEach(([Z,Y])=>{this.variables.set(Z,Y)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([Z,Y])=>{this.variables.set(Z,Y)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!dv($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let Z=uv($,"utf-8");return this.checkTemplate(Z,$)}checkTemplate($,Z="<inline>"){this.currentFile=Z,this.errors=[],this.warnings=[];let Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)this.analyzeScript(Y[1],$.indexOf(Y[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,Z){let Y=$.split(`
16061
16061
  `),J=this.getLineNumber(Z);for(let X=0;X<Y.length;X++){let Q=Y[X],G=J+X;this.extractTypedVariables(Q,G),this.extractInterfaces(Q,Y,X,G),this.extractTypeAliases(Q,G)}}extractTypedVariables($,Z){let Y=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*:\s*([^=]+?)\s*=/);if(Y){let[,Q,G]=Y,K=this.parseTypeAnnotation(G.trim());this.variables.set(Q,K);return}let J=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(.+)/);if(J){let[,Q,G]=J,K=this.inferType(G.trim());this.variables.set(Q,K);return}let X=$.match(/(?:export\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*(\w+))?/);if(X){let[,Q,G,K]=X,W=this.parseParams(G),U=K?this.parseTypeAnnotation(K):{kind:"primitive",value:"any"};this.variables.set(Q,{kind:"function",params:W,returnType:U})}}extractInterfaces($,Z,Y,J){let X=$.match(/(?:export\s+)?interface\s+(\w+)\s*\{/);if(X){let[,Q]=X,G={},K=1,W=Y+1;while(W<Z.length&&K>0){let U=Z[W].trim();if(U.includes("{"))K++;if(U.includes("}"))K--;let z=U.match(/(\w+)\??\s*:\s*([^;]+)/);if(z&&K>0){let[,_,q]=z;G[_]=this.parseTypeAnnotation(q.trim())}W++}this.variables.set(Q,{kind:"object",name:Q,properties:G})}}extractTypeAliases($,Z){let Y=$.match(/(?:export\s+)?type\s+(\w+)\s*=\s*(.+)/);if(Y){let[,J,X]=Y,Q=this.parseTypeAnnotation(X.trim());Q.name=J,this.variables.set(J,Q)}}parseTypeAnnotation($){let Z=$.trim();if(Z.includes("|"))return{kind:"union",types:Z.split("|").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.includes("&"))return{kind:"intersection",types:Z.split("&").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.endsWith("[]"))return{kind:"array",elementType:this.parseTypeAnnotation(Z.slice(0,-2))};let Y=Z.match(/^Array<(.+)>$/);if(Y)return{kind:"array",elementType:this.parseTypeAnnotation(Y[1])};if(Z.startsWith("{")&&Z.endsWith("}")){let X={},Q=Z.slice(1,-1).trim();if(Q){let G=this.splitByComma(Q);for(let K of G){let W=K.match(/(\w+)\??\s*:\s*(.+)/);if(W){let[,U,z]=W;X[U]=this.parseTypeAnnotation(z.trim())}}}return{kind:"object",properties:X}}if(Z.startsWith('"')||Z.startsWith("'"))return{kind:"literal",value:Z.slice(1,-1)};if(/^\d+$/.test(Z))return{kind:"literal",value:Z};if(Z==="true"||Z==="false")return{kind:"literal",value:Z};if(["string","number","boolean","null","undefined","any","unknown","void","never"].includes(Z))return{kind:"primitive",value:Z};if(this.variables.has(Z))return this.variables.get(Z);return{kind:"primitive",value:"any"}}inferType($){let Z=$.trim().replace(/;$/,"");if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return{kind:"primitive",value:"string"};if(/^-?\d+(\.\d+)?$/.test(Z))return{kind:"primitive",value:"number"};if(Z==="true"||Z==="false")return{kind:"primitive",value:"boolean"};if(Z==="null")return{kind:"primitive",value:"null"};if(Z==="undefined")return{kind:"primitive",value:"undefined"};if(Z.startsWith("[")){let Y=Z.slice(1,-1).trim();if(Y){let J=this.splitByComma(Y)[0];if(J)return{kind:"array",elementType:this.inferType(J.trim())}}return{kind:"array",elementType:{kind:"primitive",value:"any"}}}if(Z.startsWith("{")){let Y={},J=this.extractObjectLiteral(Z);for(let[X,Q]of Object.entries(J))Y[X]=this.inferType(Q);return{kind:"object",properties:Y}}if(Z.includes("=>")){let Y=Z.match(/^\(([^)]*)\)\s*(?::\s*(\w+))?\s*=>/);if(Y){let J=this.parseParams(Y[1]),X=Y[2]?this.parseTypeAnnotation(Y[2]):{kind:"primitive",value:"any"};return{kind:"function",params:J,returnType:X}}}if(/^\w+$/.test(Z)&&this.variables.has(Z))return this.variables.get(Z);if(Z.includes("."))return this.resolvePropertyAccess(Z);if(Z.includes("(")){let Y=Z.split("(")[0],J=this.variables.get(Y);if(J?.kind==="function"&&J.returnType)return J.returnType}return{kind:"primitive",value:"any"}}parseParams($){if(!$.trim())return[];let Z=[],Y=this.splitByComma($);for(let J of Y){let X=J.trim(),Q=X.includes("?"),G=X.match(/(\w+)\??\s*(?::\s*([^=]+))?(?:\s*=)?/);if(G){let[,K,W]=G,U=W?this.parseTypeAnnotation(W.trim()):{kind:"primitive",value:"any"};Z.push({name:K,type:U,optional:Q})}}return Z}checkExpressions($){let Z=/\{\{([\s\S]*?)\}\}/g,Y;while((Y=Z.exec($))!==null){let X=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!X)continue;if(X.startsWith("!")||X.endsWith("!"))continue;this.checkExpression(X,G,K)}let J=/\{!!([\s\S]*?)!!\}/g;while((Y=J.exec($))!==null){let X=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!X)continue;this.checkExpression(X,G,K)}}checkExpression($,Z,Y){if($.includes("?")&&$.includes(":")){let Q=$.split("?");this.checkExpression(Q[0].trim(),Z,Y);let G=Q.slice(1).join("?").split(":");if(G.length>=2)this.checkExpression(G[0].trim(),Z,Y),this.checkExpression(G.slice(1).join(":").trim(),Z,Y);return}for(let Q of["&&","||","??"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}for(let Q of["===","!==","==","!=",">=","<=",">","<"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}if($.startsWith("!")){this.checkExpression($.slice(1).trim(),Z,Y);return}if(this.isLiteral($))return;let J=$.match(/^(\w+(?:\.\w+)*)\s*\(/);if(J){let Q=J[1],G=this.resolvePropertyAccess(Q);if(G.kind!=="function"&&G.value!=="any")this.addWarning(`'${Q}' is not a function`,Z,Y,$);return}if($.includes(".")){if(this.resolvePropertyAccess($).value==="undefined"&&this.options.checkPropertyAccess)this.addWarning(`Property access '${$}' may be undefined`,Z,Y,$);return}let X=$.match(/^\w+/)?.[0];if(X&&!this.variables.has(X))this.addError(`Variable '${X}' is not defined`,Z,Y,$)}checkDirectives($){let Z=/@if\s*\(([^)]+)\)/g,Y;while((Y=Z.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let J=/@foreach\s*\((\w+)\s+(?:as|in)\s+(\w+)(?:\s*,\s*(\w+))?\)/g;while((Y=J.exec($))!==null){let[,G,K,W]=Y,U=Y.index,z=this.getLineNumber(U,$),_=this.getColumn(U,$);if(!this.variables.has(G))this.addError(`Collection '${G}' is not defined`,z,_,Y[0]);else{let q=this.variables.get(G);if(q.kind==="array"&&q.elementType)this.variables.set(K,q.elementType);else this.variables.set(K,{kind:"primitive",value:"any"});if(W)this.variables.set(W,{kind:"primitive",value:"number"})}}let X=/@unless\s*\(([^)]+)\)/g;while((Y=X.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let Q=/@switch\s*\(([^)]+)\)/g;while((Y=Q.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}}resolvePropertyAccess($){let Z=$.split("."),Y=this.variables.get(Z[0])||{kind:"primitive",value:"any"};for(let J=1;J<Z.length;J++){let X=Z[J].replace(/\(\)$/,"");if(Y.kind==="object"&&Y.properties)if(Y.properties[X])Y=Y.properties[X];else if(!this.options.allowAny)return{kind:"primitive",value:"undefined"};else Y={kind:"primitive",value:"any"};else if(Y.kind==="array"&&Y.elementType)if(["length"].includes(X))Y={kind:"primitive",value:"number"};else if(["map","filter","find","forEach","some","every","reduce"].includes(X))Y={kind:"function",returnType:{kind:"primitive",value:"any"}};else if(["join"].includes(X))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else Y={kind:"primitive",value:"any"};else if(Y.kind==="primitive"&&Y.value==="string")if(["length"].includes(X))Y={kind:"primitive",value:"number"};else if(["toUpperCase","toLowerCase","trim","slice","substring"].includes(X))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else if(["split"].includes(X))Y={kind:"function",returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}};else Y={kind:"primitive",value:"any"};else Y={kind:"primitive",value:"any"}}return Y}isLiteral($){let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return!0;if(/^-?\d+(\.\d+)?$/.test(Z))return!0;if(Z==="true"||Z==="false")return!0;if(Z==="null"||Z==="undefined")return!0;return!1}extractObjectLiteral($){let Z={},Y=$.slice(1,-1).trim();if(!Y)return Z;let J=this.splitByComma(Y);for(let X of J){let Q=X.indexOf(":");if(Q>0){let G=X.slice(0,Q).trim(),K=X.slice(Q+1).trim();Z[G]=K}}return Z}splitByComma($){let Z=[],Y="",J=0,X=null;for(let Q=0;Q<$.length;Q++){let G=$[Q],K=Q>0?$[Q-1]:"";if((G==='"'||G==="'"||G==="`")&&K!=="\\"){if(X===G)X=null;else if(!X)X=G}if(!X){if(G==="{"||G==="["||G==="(")J++;if(G==="}"||G==="]"||G===")")J--;if(G===","&&J===0){Z.push(Y.trim()),Y="";continue}}Y+=G}if(Y.trim())Z.push(Y.trim());return Z}getLineNumber($,Z){return((Z||"").slice(0,$).match(/\n/g)||[]).length+1}getColumn($,Z){let J=Z.slice(0,$).lastIndexOf(`
16062
- `);return $-J}addError($,Z,Y,J,X,Q){this.errors.push({message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"error"})}addWarning($,Z,Y,J,X,Q){let G={message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,Z){this.variables.set($,Z)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(XA).forEach(([$,Z])=>{this.variables.set($,Z)})}}function UW($){return new WW($)}function mv($,Z){return UW(Z).checkFile($)}function lv($,Z){return UW(Z).checkTemplate($)}function cv($){let Z=[];for(let Y of $.errors){if(Z.push(`\x1B[31merror\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");if(Y.expected&&Y.received)Z.push(` expected: ${Y.expected}`),Z.push(` received: ${Y.received}`);Z.push("")}for(let Y of $.warnings){if(Z.push(`\x1B[33mwarning\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");Z.push("")}if($.valid)Z.push("\x1B[32m\u2713 No type errors found\x1B[0m");else Z.push(`\x1B[31m\u2717 Found ${$.errors.length} error(s) and ${$.warnings.length} warning(s)\x1B[0m`);return Z.join(`
16063
- `)}var uv,XA;var QA=D(()=>{uv={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},XA={console:{kind:"object",properties:{log:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},error:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},warn:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}}}},Math:{kind:"object",properties:{abs:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},floor:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},ceil:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},round:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},max:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},min:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},random:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},PI:{kind:"primitive",value:"number"},E:{kind:"primitive",value:"number"}}},JSON:{kind:"object",properties:{stringify:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},parse:{kind:"function",params:[{name:"text",type:{kind:"primitive",value:"string"}}],returnType:{kind:"primitive",value:"any"}}}},Date:{kind:"function",returnType:{kind:"object",properties:{getTime:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},toISOString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}},toLocaleDateString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}}}}},Array:{kind:"object",properties:{isArray:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},from:{kind:"function",params:[{name:"arrayLike",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},Object:{kind:"object",properties:{keys:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}},values:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}},entries:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},String:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},Number:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"number"}},Boolean:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},props:{kind:"object",properties:{}},slot:{kind:"primitive",value:"string"},loop:{kind:"object",properties:{index:{kind:"primitive",value:"number"},iteration:{kind:"primitive",value:"number"},first:{kind:"primitive",value:"boolean"},last:{kind:"primitive",value:"boolean"},even:{kind:"primitive",value:"boolean"},odd:{kind:"primitive",value:"boolean"},count:{kind:"primitive",value:"number"},remaining:{kind:"primitive",value:"number"},depth:{kind:"primitive",value:"number"},parent:{kind:"object",properties:{}}}}}});async function zW($,Z,Y){if(!_W)return;try{let J=$.getAttribute("data-island-id"),X=document.querySelector(`script[data-island-props="${J}"]`),Q=X?JSON.parse(X.textContent||"{}"):{},G=await Y(),K=G.default||G.hydrate;if(typeof K!=="function"){console.error(`Island handler for "${Z}" does not export a valid hydration function`);return}await K($,Q),$.setAttribute("data-hydrated","true")}catch(J){console.error(`Failed to hydrate island "${Z}":`,J)}}function pv($){if(!_W)return;let Z=document.querySelectorAll("[data-island]"),Y=[];if(Z.forEach((J)=>{let X=J.getAttribute("data-island"),Q=J.getAttribute("data-priority")||"lazy";if(!X||!$[X]||J.getAttribute("data-hydrated")==="true")return;if(Q==="eager")zW(J,X,$[X]);else Y.push([J,X])}),Y.length>0&&"IntersectionObserver"in window){let J=new IntersectionObserver((X)=>{X.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target,K=G.getAttribute("data-island");if(K&&$[K]&&G.getAttribute("data-hydrated")!=="true")zW(G,K,$[K]),J.unobserve(G)}})},{rootMargin:"200px",threshold:0});Y.forEach(([X])=>{J.observe(X)})}else setTimeout(()=>{Y.forEach(([J,X])=>{if(J.getAttribute("data-hydrated")!=="true")zW(J,X,$[X])})},1000)}function iv($){if(!_W)return;Object.entries($).forEach(([Z,Y])=>{try{let X=Y.toString().match(/import\(['"](.+)['"]\)/);if(X&&X[1]){let Q=document.createElement("link");Q.rel="modulepreload",Q.href=X[1],Q.setAttribute("data-island-module",Z),document.head.appendChild(Q)}}catch(J){console.warn(`Failed to preload island handler for "${Z}":`,J)}})}var _W;var GA=D(()=>{_W=typeof window<"u"&&typeof document<"u"});function KA($){if(!n5)return null;let Z=document.getElementById("stx-loading-indicator");if(Z)Z.remove();let Y=document.createElement("div");Y.id="stx-loading-indicator";let J=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Y.style.cssText=`
16062
+ `);return $-J}addError($,Z,Y,J,X,Q){this.errors.push({message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"error"})}addWarning($,Z,Y,J,X,Q){let G={message:$,file:this.currentFile,line:Z,column:Y,expression:J,expected:X,received:Q,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,Z){this.variables.set($,Z)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(XA).forEach(([$,Z])=>{this.variables.set($,Z)})}}function UW($){return new WW($)}function lv($,Z){return UW(Z).checkFile($)}function cv($,Z){return UW(Z).checkTemplate($)}function pv($){let Z=[];for(let Y of $.errors){if(Z.push(`\x1B[31merror\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");if(Y.expected&&Y.received)Z.push(` expected: ${Y.expected}`),Z.push(` received: ${Y.received}`);Z.push("")}for(let Y of $.warnings){if(Z.push(`\x1B[33mwarning\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");Z.push("")}if($.valid)Z.push("\x1B[32m\u2713 No type errors found\x1B[0m");else Z.push(`\x1B[31m\u2717 Found ${$.errors.length} error(s) and ${$.warnings.length} warning(s)\x1B[0m`);return Z.join(`
16063
+ `)}var mv,XA;var QA=D(()=>{mv={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},XA={console:{kind:"object",properties:{log:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},error:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},warn:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}}}},Math:{kind:"object",properties:{abs:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},floor:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},ceil:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},round:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},max:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},min:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},random:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},PI:{kind:"primitive",value:"number"},E:{kind:"primitive",value:"number"}}},JSON:{kind:"object",properties:{stringify:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},parse:{kind:"function",params:[{name:"text",type:{kind:"primitive",value:"string"}}],returnType:{kind:"primitive",value:"any"}}}},Date:{kind:"function",returnType:{kind:"object",properties:{getTime:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},toISOString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}},toLocaleDateString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}}}}},Array:{kind:"object",properties:{isArray:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},from:{kind:"function",params:[{name:"arrayLike",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},Object:{kind:"object",properties:{keys:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}},values:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}},entries:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},String:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},Number:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"number"}},Boolean:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},props:{kind:"object",properties:{}},slot:{kind:"primitive",value:"string"},loop:{kind:"object",properties:{index:{kind:"primitive",value:"number"},iteration:{kind:"primitive",value:"number"},first:{kind:"primitive",value:"boolean"},last:{kind:"primitive",value:"boolean"},even:{kind:"primitive",value:"boolean"},odd:{kind:"primitive",value:"boolean"},count:{kind:"primitive",value:"number"},remaining:{kind:"primitive",value:"number"},depth:{kind:"primitive",value:"number"},parent:{kind:"object",properties:{}}}}}});async function zW($,Z,Y){if(!_W)return;try{let J=$.getAttribute("data-island-id"),X=document.querySelector(`script[data-island-props="${J}"]`),Q=X?JSON.parse(X.textContent||"{}"):{},G=await Y(),K=G.default||G.hydrate;if(typeof K!=="function"){console.error(`Island handler for "${Z}" does not export a valid hydration function`);return}await K($,Q),$.setAttribute("data-hydrated","true")}catch(J){console.error(`Failed to hydrate island "${Z}":`,J)}}function iv($){if(!_W)return;let Z=document.querySelectorAll("[data-island]"),Y=[];if(Z.forEach((J)=>{let X=J.getAttribute("data-island"),Q=J.getAttribute("data-priority")||"lazy";if(!X||!$[X]||J.getAttribute("data-hydrated")==="true")return;if(Q==="eager")zW(J,X,$[X]);else Y.push([J,X])}),Y.length>0&&"IntersectionObserver"in window){let J=new IntersectionObserver((X)=>{X.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target,K=G.getAttribute("data-island");if(K&&$[K]&&G.getAttribute("data-hydrated")!=="true")zW(G,K,$[K]),J.unobserve(G)}})},{rootMargin:"200px",threshold:0});Y.forEach(([X])=>{J.observe(X)})}else setTimeout(()=>{Y.forEach(([J,X])=>{if(J.getAttribute("data-hydrated")!=="true")zW(J,X,$[X])})},1000)}function nv($){if(!_W)return;Object.entries($).forEach(([Z,Y])=>{try{let X=Y.toString().match(/import\(['"](.+)['"]\)/);if(X&&X[1]){let Q=document.createElement("link");Q.rel="modulepreload",Q.href=X[1],Q.setAttribute("data-island-module",Z),document.head.appendChild(Q)}}catch(J){console.warn(`Failed to preload island handler for "${Z}":`,J)}})}var _W;var GA=D(()=>{_W=typeof window<"u"&&typeof document<"u"});function KA($){if(!n5)return null;let Z=document.getElementById("stx-loading-indicator");if(Z)Z.remove();let Y=document.createElement("div");Y.id="stx-loading-indicator";let J=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Y.style.cssText=`
16064
16064
  position: fixed;
16065
16065
  top: 0;
16066
16066
  left: 0;
@@ -16091,7 +16091,7 @@ ${N instanceof Error?N.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An err
16091
16091
  0% { transform: translateX(-100%); }
16092
16092
  100% { transform: translateX(100%); }
16093
16093
  }
16094
- `,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function nJ($,Z){if(!n5||!I1)return;if(R4=Math.min(Math.max($,0),100),qW)cancelAnimationFrame(qW);qW=requestAnimationFrame(()=>{if(!I1)return;I1.style.opacity=R4>0?"1":"0",I1.style.transform=`scaleX(${R4/100})`})}function nv($){if(!n5)return;if(W3=!0,R4=0,!I1)I1=KA($);if(i5)clearTimeout(i5);if(u4)clearInterval(u4);nJ(10,$),u4=setInterval(()=>{if(!W3)return;let Z=90-R4,Y=Math.max(0.5,Z*0.1);if(R4<90)nJ(R4+Y,$)},$.throttle)}function rv($){if(!n5)return;if(W3=!1,u4)clearInterval(u4),u4=null;nJ(100,$),i5=setTimeout(()=>{if(I1)I1.style.opacity="0";setTimeout(()=>{if(R4=0,I1)I1.style.transform="scaleX(0)"},300)},200)}function av(){if(!n5)return;if(W3=!1,R4=0,u4)clearInterval(u4),u4=null;if(i5)clearTimeout(i5),i5=null;if(I1)I1.style.opacity="0",I1.style.transform="scaleX(0)"}function WA($){let Z={...BW,...$};return{start:()=>nv(Z),set:(Y)=>nJ(Y,Z),finish:()=>rv(Z),clear:()=>av(),get state(){return{isLoading:W3,progress:R4,error:!1}}}}function sv($){if(!n5)return;if(O$)O$(),O$=null;let Z={...BW,...$},Y=WA(Z);I1=KA(Z);let J=!1,X=(z)=>{let q=z.target.closest("a");if(!q)return;let B=q.getAttribute("href");if(!B)return;if(B.startsWith("http")||B.startsWith("#")||B.startsWith("mailto:")||B.startsWith("tel:")||q.target==="_blank"||q.hasAttribute("download"))return;J=!0,Y.start()},Q=()=>{if(!J)Y.start(),J=!0},G=()=>{if(J||Z.autoFinish)Y.finish(),J=!1};document.addEventListener("click",X),window.addEventListener("popstate",Q),window.addEventListener("load",G);let K=window.fetch,W=0,U=async function(...z){let _=typeof z[0]==="string"?z[0]:z[0].url,q=_.includes("/api/")||_.startsWith("/api");if(q){if(W++,W===1&&!J)Y.start()}try{return await K.apply(this,z)}finally{if(q){if(W--,W===0&&!J)Y.finish()}}};window.fetch=U,O$=()=>{if(document.removeEventListener("click",X),window.removeEventListener("popstate",Q),window.removeEventListener("load",G),window.fetch===U)window.fetch=K}}function ov(){if(O$)O$(),O$=null}function tv($){let Z={...BW,...$},Y=Z.initialColor?`linear-gradient(to right, ${Z.initialColor}, ${Z.color})`:Z.color;return`
16094
+ `,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function nJ($,Z){if(!n5||!I1)return;if(R4=Math.min(Math.max($,0),100),qW)cancelAnimationFrame(qW);qW=requestAnimationFrame(()=>{if(!I1)return;I1.style.opacity=R4>0?"1":"0",I1.style.transform=`scaleX(${R4/100})`})}function rv($){if(!n5)return;if(W3=!0,R4=0,!I1)I1=KA($);if(i5)clearTimeout(i5);if(u4)clearInterval(u4);nJ(10,$),u4=setInterval(()=>{if(!W3)return;let Z=90-R4,Y=Math.max(0.5,Z*0.1);if(R4<90)nJ(R4+Y,$)},$.throttle)}function av($){if(!n5)return;if(W3=!1,u4)clearInterval(u4),u4=null;nJ(100,$),i5=setTimeout(()=>{if(I1)I1.style.opacity="0";setTimeout(()=>{if(R4=0,I1)I1.style.transform="scaleX(0)"},300)},200)}function sv(){if(!n5)return;if(W3=!1,R4=0,u4)clearInterval(u4),u4=null;if(i5)clearTimeout(i5),i5=null;if(I1)I1.style.opacity="0",I1.style.transform="scaleX(0)"}function WA($){let Z={...BW,...$};return{start:()=>rv(Z),set:(Y)=>nJ(Y,Z),finish:()=>av(Z),clear:()=>sv(),get state(){return{isLoading:W3,progress:R4,error:!1}}}}function ov($){if(!n5)return;if(O$)O$(),O$=null;let Z={...BW,...$},Y=WA(Z);I1=KA(Z);let J=!1,X=(z)=>{let q=z.target.closest("a");if(!q)return;let B=q.getAttribute("href");if(!B)return;if(B.startsWith("http")||B.startsWith("#")||B.startsWith("mailto:")||B.startsWith("tel:")||q.target==="_blank"||q.hasAttribute("download"))return;J=!0,Y.start()},Q=()=>{if(!J)Y.start(),J=!0},G=()=>{if(J||Z.autoFinish)Y.finish(),J=!1};document.addEventListener("click",X),window.addEventListener("popstate",Q),window.addEventListener("load",G);let K=window.fetch,W=0,U=async function(...z){let _=typeof z[0]==="string"?z[0]:z[0].url,q=_.includes("/api/")||_.startsWith("/api");if(q){if(W++,W===1&&!J)Y.start()}try{return await K.apply(this,z)}finally{if(q){if(W--,W===0&&!J)Y.finish()}}};window.fetch=U,O$=()=>{if(document.removeEventListener("click",X),window.removeEventListener("popstate",Q),window.removeEventListener("load",G),window.fetch===U)window.fetch=K}}function tv(){if(O$)O$(),O$=null}function ev($){let Z={...BW,...$},Y=Z.initialColor?`linear-gradient(to right, ${Z.initialColor}, ${Z.color})`:Z.color;return`
16095
16095
  <div id="stx-loading-indicator" style="
16096
16096
  position: fixed;
16097
16097
  top: 0;
@@ -16500,7 +16500,7 @@ else {
16500
16500
  return (async function() {
16501
16501
  ${$}
16502
16502
  })()
16503
- `;await Function(...Object.keys(Y),J)(...Object.values(Y))}catch(Y){throw console.error("[HMR] Script execution error:",Y),Y}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((Y)=>{let J=Y.getAttribute("data-stx-events");if(!J)return;try{let X=JSON.parse(J);for(let[Q,G]of Object.entries(X))if(typeof window<"u"&&window.stx?.[G])Y.addEventListener(Q,window.stx[G])}catch{}}),$.element.dispatchEvent(new CustomEvent("stx:reinitialize",{bubbles:!0}))}getRegistry(){return this.registry}async refresh($){let Z=this.registry.getInstancesByFile($);for(let Y of Z)if(Y.render&&Y.element)this.registry.captureState(Y.id),Y.element.innerHTML=Y.render(),this.registry.restoreState(Y.id),this.reinitializeInteractivity(Y)}}function ev($){return`
16503
+ `;await Function(...Object.keys(Y),J)(...Object.values(Y))}catch(Y){throw console.error("[HMR] Script execution error:",Y),Y}}reinitializeInteractivity($){if(!$.element)return;$.element.querySelectorAll("[data-stx-events]").forEach((Y)=>{let J=Y.getAttribute("data-stx-events");if(!J)return;try{let X=JSON.parse(J);for(let[Q,G]of Object.entries(X))if(typeof window<"u"&&window.stx?.[G])Y.addEventListener(Q,window.stx[G])}catch{}}),$.element.dispatchEvent(new CustomEvent("stx:reinitialize",{bubbles:!0}))}getRegistry(){return this.registry}async refresh($){let Z=this.registry.getInstancesByFile($);for(let Y of Z)if(Y.render&&Y.element)this.registry.captureState(Y.id),Y.element.innerHTML=Y.render(),this.registry.restoreState(Y.id),this.reinitializeInteractivity(Y)}}function $f($){return`
16504
16504
  <script data-stx-hmr-client>
16505
16505
  (function() {
16506
16506
  'use strict';
@@ -16727,7 +16727,7 @@ else {
16727
16727
  };
16728
16728
  })();
16729
16729
  </script>
16730
- `}function $f($,Z,Y,J){return`
16730
+ `}function Zf($,Z,Y,J){return`
16731
16731
  <div data-stx-component="${$}" data-stx-name="${Z}">
16732
16732
  ${Y}
16733
16733
  </div>
@@ -16767,7 +16767,7 @@ else {
16767
16767
  observer.observe(document.body, { childList: true, subtree: true });
16768
16768
  })();
16769
16769
  </script>
16770
- `}function Zf($){if(!r5)r5=new HW($);return r5}function Yf(){if(r5)r5.getRegistry().clear(),r5=null}var r5=null;var _A=()=>{};function qA($){let Z={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return Z.checksum=BA(Z),JSON.stringify(Z).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function BA($){let Z=JSON.stringify({refs:Object.keys($.refs||{}),reactive:Object.keys($.reactive||{}),props:Object.keys($.props||{})}),Y=0;for(let J=0;J<Z.length;J++){let X=Z.charCodeAt(J);Y=(Y<<5)-Y+X,Y=Y&Y}return Math.abs(Y).toString(36)}function jA($){return`<script id="__STX_STATE__" type="application/json">${qA($)}</script>`}function Jf($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function HA(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let Z=JSON.parse($.textContent||"{}");if(Z.checksum){if(BA(Z)!==Z.checksum)console.warn("[Hydration] State checksum mismatch - state may be corrupted")}return Z}catch(Z){return console.error("[Hydration] Failed to parse state:",Z),null}}class LW{state=null;options;root=null;isHydrated=!1;pendingComponents=new Map;hydratedComponents=new Set;constructor($={}){this.options={root:$.root||"#app",strict:$.strict??!1,onHydrating:$.onHydrating||(()=>{}),onHydrated:$.onHydrated||(()=>{}),onError:$.onError||console.error,performance:$.performance??!1,timeout:$.timeout??1e4}}async hydrate(){if(typeof window>"u")return;if(this.isHydrated)return;let $=this.options.performance?performance.now():0;try{this.root=typeof this.options.root==="string"?document.querySelector(this.options.root)||document.body:this.options.root,this.state=HA(),this.options.onHydrating(),this.root.classList.add("stx-hydrating");let Z=new Promise((Y,J)=>{setTimeout(()=>J(Error("Hydration timeout")),this.options.timeout)});if(await Promise.race([this.runHydration(),Z]),this.isHydrated=!0,this.root.classList.remove("stx-hydrating"),this.root.classList.add("stx-hydrated"),this.options.performance){let Y=performance.now()-$;console.log(`[Hydration] Completed in ${Y.toFixed(2)}ms`)}this.options.onHydrated(),window.dispatchEvent(new CustomEvent("stx:hydrated"))}catch(Z){this.root?.classList.remove("stx-hydrating"),this.root?.classList.add("stx-hydration-error"),this.options.onError(Z),window.dispatchEvent(new CustomEvent("stx:hydration-error",{detail:{error:Z}}))}}async runHydration(){if(!this.root)return;this.restoreGlobalState(),await this.hydrateComponents(),this.bindEventHandlers(),this.initializeReactiveBindings(),this.setupRouterIntegration()}restoreGlobalState(){if(!this.state)return;let $=window.stx;if(!$)return;if(this.state.routeParams&&$.setRouteParams)$.setRouteParams(this.state.routeParams);if(this.state.stores&&$.registerStore)Object.entries(this.state.stores).forEach(([Z,Y])=>{$.registerStore(Z,Y)});window.dispatchEvent(new CustomEvent("stx:state-restored",{detail:this.state}))}async hydrateComponents(){if(!this.root)return;let $=this.root.querySelectorAll("[data-stx-component]");for(let Z of Array.from($)){let Y=Z.getAttribute("data-stx-component"),J=Z.getAttribute("data-stx-name")||Y,X=Z.getAttribute("data-stx-hydrate")||"eager",Q=Z.getAttribute("data-stx-props");if(!Y)continue;let G={id:Y,name:J||Y,strategy:X,props:Q?JSON.parse(Q):{},events:[]};switch(this.pendingComponents.set(Y,G),G.strategy){case"eager":await this.hydrateComponent(Z,G);break;case"lazy":case"visible":this.setupVisibleHydration(Z,G);break;case"idle":this.setupIdleHydration(Z,G);break;case"interaction":this.setupInteractionHydration(Z,G);break}}}async hydrateComponent($,Z){if(this.hydratedComponents.has(Z.id))return;try{let Y=this.state?.refs[Z.id]||this.state?.reactive[Z.id]||{};this.restoreComponentState($,Y),this.bindComponentEvents($),this.initializeComponentReactivity($,Z),this.hydratedComponents.add(Z.id),$.classList.add("stx-hydrated"),$.setAttribute("data-hydrated","true"),$.dispatchEvent(new CustomEvent("stx:component-hydrated",{detail:{id:Z.id,name:Z.name},bubbles:!0}))}catch(Y){if(console.error(`[Hydration] Failed to hydrate component ${Z.id}:`,Y),$.classList.add("stx-hydration-error"),this.options.strict)throw Y}}restoreComponentState($,Z){if(!Z||typeof Z!=="object")return;$.querySelectorAll("[data-stx-bind]").forEach((J)=>{let X=J.getAttribute("data-stx-bind");if(!X||!Z[X])return;let Q=Z[X];if(J instanceof HTMLInputElement)if(J.type==="checkbox"||J.type==="radio")J.checked=Boolean(Q);else J.value=String(Q);else if(J instanceof HTMLSelectElement)J.value=String(Q);else if(J instanceof HTMLTextAreaElement)J.value=String(Q);else J.textContent=String(Q)})}setupVisibleHydration($,Z){if(!("IntersectionObserver"in window)){this.hydrateComponent($,Z);return}let Y=new IntersectionObserver((J)=>{J.forEach((X)=>{if(X.isIntersecting)Y.disconnect(),this.hydrateComponent($,Z)})},{rootMargin:"100px",threshold:0});Y.observe($)}setupIdleHydration($,Z){let Y=()=>this.hydrateComponent($,Z);if("requestIdleCallback"in window)window.requestIdleCallback(Y,{timeout:2000});else setTimeout(Y,200)}setupInteractionHydration($,Z){let Y=["mouseenter","touchstart","focusin"],J=()=>{Y.forEach((X)=>$.removeEventListener(X,J)),this.hydrateComponent($,Z)};Y.forEach((X)=>{$.addEventListener(X,J,{once:!0,passive:!0})})}bindEventHandlers(){if(!this.root)return;this.root.querySelectorAll("[data-stx-events]").forEach((Z)=>this.bindElementEvents(Z)),this.bindDirectiveEvents()}bindElementEvents($){let Z=$.getAttribute("data-stx-events");if(!Z)return;try{JSON.parse(Z).forEach((J)=>{this.bindSingleEvent($,J)})}catch(Y){console.error("[Hydration] Failed to parse events:",Y)}}bindDirectiveEvents(){if(!this.root)return;["click","submit","input","change","focus","blur","keydown","keyup","keypress","mouseenter","mouseleave","touchstart","touchend","scroll","resize"].forEach((Z)=>{let Y=`data-stx-on-${Z}`;this.root.querySelectorAll(`[${Y}]`).forEach((X)=>{let Q=X.getAttribute(Y);if(!Q)return;this.bindSingleEvent(X,{type:Z,handler:Q,modifiers:this.parseModifiers(X,Z)})})})}parseModifiers($,Z){let Y=[],J=$.getAttribute(`data-stx-${Z}-modifiers`);if(J)Y.push(...J.split(",").map((X)=>X.trim()));return Y}bindSingleEvent($,Z){let Y=this.resolveHandler(Z.handler);if(!Y){console.warn(`[Hydration] Handler not found: ${Z.handler}`);return}let J=(Q)=>{if(Z.modifiers?.includes("prevent")||Z.preventDefault)Q.preventDefault();if(Z.modifiers?.includes("stop")||Z.stopPropagation)Q.stopPropagation();try{Y.call($,Q)}catch(G){console.error("[Hydration] Event handler error:",G)}},X={};if(Z.modifiers?.includes("once"))X.once=!0;if(Z.modifiers?.includes("passive"))X.passive=!0;if(Z.modifiers?.includes("capture"))X.capture=!0;$.addEventListener(Z.type,J,X)}resolveHandler($){let Z=window.stx;if(Z&&Z[$])return Z[$];if(window[$])return window[$];try{if($.match(/^\w+\+\+$/)||$.match(/^\w+--$/)){let X=$.replace(/[+-]+$/,"");return()=>{if(Z&&Z[X]){if(typeof Z[X].value<"u")if($.includes("++"))Z[X].value++;else Z[X].value--}}}let Y=$.match(/^(\w+)\s*=\s*(.+)$/);if(Y){let[,X,Q]=Y;return()=>{if(Z&&Z[X]){let G=Function(`return ${Q}`)();if(typeof Z[X].value<"u")Z[X].value=G}}}let J=$.match(/^(\w+)\((.*)\)$/);if(J){let[,X,Q]=J;return(G)=>{let K=Z?.[X]||window[X];if(K){let W=Q?Function("$event",`return [${Q}]`)(G):[];K(...W)}}}return(X)=>{Function("$event","stx",$)(X,Z)}}catch{return null}}bindComponentEvents($){$.querySelectorAll("[data-stx-events]").forEach((Y)=>{this.bindElementEvents(Y)})}initializeComponentReactivity($,Z){if(!window.stx)return;$.querySelectorAll("[data-stx-reactive]").forEach((X)=>{let Q=X.getAttribute("data-stx-reactive");if(!Q)return;this.setupReactiveBinding(X,Q)})}initializeReactiveBindings(){if(!this.root)return;this.getTextNodesWithExpressions(this.root).forEach(({node:Y,expressions:J})=>{J.forEach((X)=>{this.setupTextNodeBinding(Y,X)})}),this.root.querySelectorAll("[data-stx-bind-attrs]").forEach((Y)=>{let J=Y.getAttribute("data-stx-bind-attrs");if(!J)return;try{let X=JSON.parse(J);Object.entries(X).forEach(([Q,G])=>{this.setupAttributeBinding(Y,Q,G)})}catch{}})}getTextNodesWithExpressions($){let Z=[],Y=document.createTreeWalker($,NodeFilter.SHOW_TEXT),J;while(J=Y.nextNode()){let Q=(J.textContent||"").match(/\{\{\s*([^}]+)\s*\}\}/g);if(Q)Z.push({node:J,expressions:Q.map((G)=>G.replace(/\{\{\s*|\s*\}\}/g,""))})}return Z}setupTextNodeBinding($,Z){let Y=window.stx;if(!Y)return;let J=$.textContent||"",X=()=>{try{let G=Function("stx",`with(stx) { return ${Z} }`)(Y);$.textContent=J.replace(new RegExp(`\\{\\{\\s*${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\}\\}`),String(G))}catch{}};X();let Q=Z.match(/^(\w+)(\.value)?$/);if(Q&&Y[Q[1]]?.subscribe)Y[Q[1]].subscribe(X)}setupAttributeBinding($,Z,Y){let J=window.stx;if(!J)return;let X=()=>{try{let G=Function("stx",`with(stx) { return ${Y} }`)(J);if(typeof G==="boolean")if(G)$.setAttribute(Z,"");else $.removeAttribute(Z);else $.setAttribute(Z,String(G))}catch{}};X();let Q=Y.match(/^(\w+)(\.value)?$/);if(Q&&J[Q[1]]?.subscribe)J[Q[1]].subscribe(X)}setupReactiveBinding($,Z){let Y=window.stx;if(!Y)return;let J=()=>{try{let Q=Function("stx",`with(stx) { return ${Z} }`)(Y);$.textContent=String(Q)}catch{}};J();let X=Z.match(/^(\w+)(\.value)?$/);if(X&&Y[X[1]]?.subscribe)Y[X[1]].subscribe(J)}setupRouterIntegration(){window.addEventListener("stx:navigate",($)=>{let{url:Z}=$.detail||{};if(Z){if(window.stx?.setRouteParams){let J=new URL(Z,window.location.origin)}}}),window.addEventListener("stx:load",()=>{this.hydrateComponents(),this.bindEventHandlers()})}get hydrated(){return this.isHydrated}getState(){return this.state}async hydrateById($){let Z=this.pendingComponents.get($),Y=document.querySelector(`[data-stx-component="${$}"]`);if(Z&&Y)await this.hydrateComponent(Y,Z)}}function Xf($){return`
16770
+ `}function Yf($){if(!r5)r5=new HW($);return r5}function Jf(){if(r5)r5.getRegistry().clear(),r5=null}var r5=null;var _A=()=>{};function qA($){let Z={refs:$.refs||{},reactive:$.reactive||{},props:$.props||{},routeParams:$.routeParams||{},stores:$.stores||{},meta:$.meta||{},timestamp:Date.now()};return Z.checksum=BA(Z),JSON.stringify(Z).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/'/g,"\\u0027")}function BA($){let Z=JSON.stringify({refs:Object.keys($.refs||{}),reactive:Object.keys($.reactive||{}),props:Object.keys($.props||{})}),Y=0;for(let J=0;J<Z.length;J++){let X=Z.charCodeAt(J);Y=(Y<<5)-Y+X,Y=Y&Y}return Math.abs(Y).toString(36)}function jA($){return`<script id="__STX_STATE__" type="application/json">${qA($)}</script>`}function Xf($){if($.length===0)return"";return`data-stx-events='${JSON.stringify($)}'`}function HA(){if(typeof window>"u")return null;let $=document.getElementById("__STX_STATE__");if(!$)return null;try{let Z=JSON.parse($.textContent||"{}");if(Z.checksum){if(BA(Z)!==Z.checksum)console.warn("[Hydration] State checksum mismatch - state may be corrupted")}return Z}catch(Z){return console.error("[Hydration] Failed to parse state:",Z),null}}class LW{state=null;options;root=null;isHydrated=!1;pendingComponents=new Map;hydratedComponents=new Set;constructor($={}){this.options={root:$.root||"#app",strict:$.strict??!1,onHydrating:$.onHydrating||(()=>{}),onHydrated:$.onHydrated||(()=>{}),onError:$.onError||console.error,performance:$.performance??!1,timeout:$.timeout??1e4}}async hydrate(){if(typeof window>"u")return;if(this.isHydrated)return;let $=this.options.performance?performance.now():0;try{this.root=typeof this.options.root==="string"?document.querySelector(this.options.root)||document.body:this.options.root,this.state=HA(),this.options.onHydrating(),this.root.classList.add("stx-hydrating");let Z=new Promise((Y,J)=>{setTimeout(()=>J(Error("Hydration timeout")),this.options.timeout)});if(await Promise.race([this.runHydration(),Z]),this.isHydrated=!0,this.root.classList.remove("stx-hydrating"),this.root.classList.add("stx-hydrated"),this.options.performance){let Y=performance.now()-$;console.log(`[Hydration] Completed in ${Y.toFixed(2)}ms`)}this.options.onHydrated(),window.dispatchEvent(new CustomEvent("stx:hydrated"))}catch(Z){this.root?.classList.remove("stx-hydrating"),this.root?.classList.add("stx-hydration-error"),this.options.onError(Z),window.dispatchEvent(new CustomEvent("stx:hydration-error",{detail:{error:Z}}))}}async runHydration(){if(!this.root)return;this.restoreGlobalState(),await this.hydrateComponents(),this.bindEventHandlers(),this.initializeReactiveBindings(),this.setupRouterIntegration()}restoreGlobalState(){if(!this.state)return;let $=window.stx;if(!$)return;if(this.state.routeParams&&$.setRouteParams)$.setRouteParams(this.state.routeParams);if(this.state.stores&&$.registerStore)Object.entries(this.state.stores).forEach(([Z,Y])=>{$.registerStore(Z,Y)});window.dispatchEvent(new CustomEvent("stx:state-restored",{detail:this.state}))}async hydrateComponents(){if(!this.root)return;let $=this.root.querySelectorAll("[data-stx-component]");for(let Z of Array.from($)){let Y=Z.getAttribute("data-stx-component"),J=Z.getAttribute("data-stx-name")||Y,X=Z.getAttribute("data-stx-hydrate")||"eager",Q=Z.getAttribute("data-stx-props");if(!Y)continue;let G={id:Y,name:J||Y,strategy:X,props:Q?JSON.parse(Q):{},events:[]};switch(this.pendingComponents.set(Y,G),G.strategy){case"eager":await this.hydrateComponent(Z,G);break;case"lazy":case"visible":this.setupVisibleHydration(Z,G);break;case"idle":this.setupIdleHydration(Z,G);break;case"interaction":this.setupInteractionHydration(Z,G);break}}}async hydrateComponent($,Z){if(this.hydratedComponents.has(Z.id))return;try{let Y=this.state?.refs[Z.id]||this.state?.reactive[Z.id]||{};this.restoreComponentState($,Y),this.bindComponentEvents($),this.initializeComponentReactivity($,Z),this.hydratedComponents.add(Z.id),$.classList.add("stx-hydrated"),$.setAttribute("data-hydrated","true"),$.dispatchEvent(new CustomEvent("stx:component-hydrated",{detail:{id:Z.id,name:Z.name},bubbles:!0}))}catch(Y){if(console.error(`[Hydration] Failed to hydrate component ${Z.id}:`,Y),$.classList.add("stx-hydration-error"),this.options.strict)throw Y}}restoreComponentState($,Z){if(!Z||typeof Z!=="object")return;$.querySelectorAll("[data-stx-bind]").forEach((J)=>{let X=J.getAttribute("data-stx-bind");if(!X||!Z[X])return;let Q=Z[X];if(J instanceof HTMLInputElement)if(J.type==="checkbox"||J.type==="radio")J.checked=Boolean(Q);else J.value=String(Q);else if(J instanceof HTMLSelectElement)J.value=String(Q);else if(J instanceof HTMLTextAreaElement)J.value=String(Q);else J.textContent=String(Q)})}setupVisibleHydration($,Z){if(!("IntersectionObserver"in window)){this.hydrateComponent($,Z);return}let Y=new IntersectionObserver((J)=>{J.forEach((X)=>{if(X.isIntersecting)Y.disconnect(),this.hydrateComponent($,Z)})},{rootMargin:"100px",threshold:0});Y.observe($)}setupIdleHydration($,Z){let Y=()=>this.hydrateComponent($,Z);if("requestIdleCallback"in window)window.requestIdleCallback(Y,{timeout:2000});else setTimeout(Y,200)}setupInteractionHydration($,Z){let Y=["mouseenter","touchstart","focusin"],J=()=>{Y.forEach((X)=>$.removeEventListener(X,J)),this.hydrateComponent($,Z)};Y.forEach((X)=>{$.addEventListener(X,J,{once:!0,passive:!0})})}bindEventHandlers(){if(!this.root)return;this.root.querySelectorAll("[data-stx-events]").forEach((Z)=>this.bindElementEvents(Z)),this.bindDirectiveEvents()}bindElementEvents($){let Z=$.getAttribute("data-stx-events");if(!Z)return;try{JSON.parse(Z).forEach((J)=>{this.bindSingleEvent($,J)})}catch(Y){console.error("[Hydration] Failed to parse events:",Y)}}bindDirectiveEvents(){if(!this.root)return;["click","submit","input","change","focus","blur","keydown","keyup","keypress","mouseenter","mouseleave","touchstart","touchend","scroll","resize"].forEach((Z)=>{let Y=`data-stx-on-${Z}`;this.root.querySelectorAll(`[${Y}]`).forEach((X)=>{let Q=X.getAttribute(Y);if(!Q)return;this.bindSingleEvent(X,{type:Z,handler:Q,modifiers:this.parseModifiers(X,Z)})})})}parseModifiers($,Z){let Y=[],J=$.getAttribute(`data-stx-${Z}-modifiers`);if(J)Y.push(...J.split(",").map((X)=>X.trim()));return Y}bindSingleEvent($,Z){let Y=this.resolveHandler(Z.handler);if(!Y){console.warn(`[Hydration] Handler not found: ${Z.handler}`);return}let J=(Q)=>{if(Z.modifiers?.includes("prevent")||Z.preventDefault)Q.preventDefault();if(Z.modifiers?.includes("stop")||Z.stopPropagation)Q.stopPropagation();try{Y.call($,Q)}catch(G){console.error("[Hydration] Event handler error:",G)}},X={};if(Z.modifiers?.includes("once"))X.once=!0;if(Z.modifiers?.includes("passive"))X.passive=!0;if(Z.modifiers?.includes("capture"))X.capture=!0;$.addEventListener(Z.type,J,X)}resolveHandler($){let Z=window.stx;if(Z&&Z[$])return Z[$];if(window[$])return window[$];try{if($.match(/^\w+\+\+$/)||$.match(/^\w+--$/)){let X=$.replace(/[+-]+$/,"");return()=>{if(Z&&Z[X]){if(typeof Z[X].value<"u")if($.includes("++"))Z[X].value++;else Z[X].value--}}}let Y=$.match(/^(\w+)\s*=\s*(.+)$/);if(Y){let[,X,Q]=Y;return()=>{if(Z&&Z[X]){let G=Function(`return ${Q}`)();if(typeof Z[X].value<"u")Z[X].value=G}}}let J=$.match(/^(\w+)\((.*)\)$/);if(J){let[,X,Q]=J;return(G)=>{let K=Z?.[X]||window[X];if(K){let W=Q?Function("$event",`return [${Q}]`)(G):[];K(...W)}}}return(X)=>{Function("$event","stx",$)(X,Z)}}catch{return null}}bindComponentEvents($){$.querySelectorAll("[data-stx-events]").forEach((Y)=>{this.bindElementEvents(Y)})}initializeComponentReactivity($,Z){if(!window.stx)return;$.querySelectorAll("[data-stx-reactive]").forEach((X)=>{let Q=X.getAttribute("data-stx-reactive");if(!Q)return;this.setupReactiveBinding(X,Q)})}initializeReactiveBindings(){if(!this.root)return;this.getTextNodesWithExpressions(this.root).forEach(({node:Y,expressions:J})=>{J.forEach((X)=>{this.setupTextNodeBinding(Y,X)})}),this.root.querySelectorAll("[data-stx-bind-attrs]").forEach((Y)=>{let J=Y.getAttribute("data-stx-bind-attrs");if(!J)return;try{let X=JSON.parse(J);Object.entries(X).forEach(([Q,G])=>{this.setupAttributeBinding(Y,Q,G)})}catch{}})}getTextNodesWithExpressions($){let Z=[],Y=document.createTreeWalker($,NodeFilter.SHOW_TEXT),J;while(J=Y.nextNode()){let Q=(J.textContent||"").match(/\{\{\s*([^}]+)\s*\}\}/g);if(Q)Z.push({node:J,expressions:Q.map((G)=>G.replace(/\{\{\s*|\s*\}\}/g,""))})}return Z}setupTextNodeBinding($,Z){let Y=window.stx;if(!Y)return;let J=$.textContent||"",X=()=>{try{let G=Function("stx",`with(stx) { return ${Z} }`)(Y);$.textContent=J.replace(new RegExp(`\\{\\{\\s*${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\}\\}`),String(G))}catch{}};X();let Q=Z.match(/^(\w+)(\.value)?$/);if(Q&&Y[Q[1]]?.subscribe)Y[Q[1]].subscribe(X)}setupAttributeBinding($,Z,Y){let J=window.stx;if(!J)return;let X=()=>{try{let G=Function("stx",`with(stx) { return ${Y} }`)(J);if(typeof G==="boolean")if(G)$.setAttribute(Z,"");else $.removeAttribute(Z);else $.setAttribute(Z,String(G))}catch{}};X();let Q=Y.match(/^(\w+)(\.value)?$/);if(Q&&J[Q[1]]?.subscribe)J[Q[1]].subscribe(X)}setupReactiveBinding($,Z){let Y=window.stx;if(!Y)return;let J=()=>{try{let Q=Function("stx",`with(stx) { return ${Z} }`)(Y);$.textContent=String(Q)}catch{}};J();let X=Z.match(/^(\w+)(\.value)?$/);if(X&&Y[X[1]]?.subscribe)Y[X[1]].subscribe(J)}setupRouterIntegration(){window.addEventListener("stx:navigate",($)=>{let{url:Z}=$.detail||{};if(Z){if(window.stx?.setRouteParams){let J=new URL(Z,window.location.origin)}}}),window.addEventListener("stx:load",()=>{this.hydrateComponents(),this.bindEventHandlers()})}get hydrated(){return this.isHydrated}getState(){return this.state}async hydrateById($){let Z=this.pendingComponents.get($),Y=document.querySelector(`[data-stx-component="${$}"]`);if(Z&&Y)await this.hydrateComponent(Y,Z)}}function Qf($){return`
16771
16771
  ${$?jA($):""}
16772
16772
  <script data-stx-hydration-runtime>
16773
16773
  (function() {
@@ -16865,7 +16865,7 @@ else {
16865
16865
  }
16866
16866
  })();
16867
16867
  </script>
16868
- `}function OA($){if(!OW)OW=new LW($);return OW}async function Qf($){await OA($).hydrate()}function Gf(){return`
16868
+ `}function OA($){if(!OW)OW=new LW($);return OW}async function Gf($){await OA($).hydrate()}function Kf(){return`
16869
16869
  <style data-stx-hydration-styles>
16870
16870
  /* Pre-hydration state */
16871
16871
  [data-stx-component]:not(.stx-hydrated) {
@@ -16898,7 +16898,7 @@ else {
16898
16898
  }
16899
16899
  }
16900
16900
  </style>
16901
- `}var OW=null;var LA=()=>{};import VA from"path";class FA{store=new Map;async get($){let Z=this.store.get($);if(!Z||Z.expires<=Date.now()){if(Z)this.store.delete($);return null}return{...Z.data}}async set($,Z,Y){this.store.set($,{data:{...Z},expires:Date.now()+Y*1000})}async delete($){this.store.delete($)}}async function Kf($,Z={},Y={}){let J=Y.viewsDir||"./views",X=Y.layoutsDir||"./layouts",Q=!$.includes("<")&&!$.includes("@"),G,K;if(Q){if(K=VA.resolve(J,$),!K.endsWith(".stx"))K+=".stx";if(!await Bun.file(K).exists())return new Response(`Template not found: ${$}`,{status:500});G=await Bun.file(K).text()}else G=$,K="inline-template.stx";let W={...Z,props:Z,__filename:K,__dirname:VA.dirname(K)};if(Y.ctx)W.csrf_token=Y.ctx.csrfToken,W.csrf_field=`<input type="hidden" name="_token" value="${Y.ctx.csrfToken}">`,W.old=Y.ctx.old,W.errors=Y.ctx.errors,W.session=Y.ctx.session,W.user=Y.ctx.user(),W.isAuthenticated=Y.ctx.isAuthenticated();let U=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(U){let j=U[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await k0(j,W,K)}let z={layoutsDir:X,...Y.stxOptions},q=await B0(G,W,K,z,new Set),B=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Y.ctx)Y.ctx.responseHeaders.forEach((j,H)=>{B.set(H,j)});return new Response(q,{headers:B})}var AA=D(()=>{b1();q1();R0()});function Wf($,Z){U3.stores.set($,Z)}function VW($){return U3.stores.get($)}function NA($){return U3.stores.has($)}function RA(){return Array.from(U3.stores.keys())}function wA($){if($==="memory")return{getItem:(Z)=>a5.get(Z)??null,setItem:(Z,Y)=>a5.set(Z,Y),removeItem:(Z)=>a5.delete(Z)};if(typeof window>"u")return{getItem:(Z)=>a5.get(Z)??null,setItem:(Z,Y)=>a5.set(Z,Y),removeItem:(Z)=>a5.delete(Z)};return $==="local"?window.localStorage:window.sessionStorage}function Uf($,Z){let Y={};for(let J of Z){let X=J.split("."),Q=$,G=Y,K=!0;for(let W=0;W<X.length-1;W++){let U=X[W];if(Q&&typeof Q==="object"&&U in Q){if(Q=Q[U],!(U in G))G[U]={};G=G[U]}else{K=!1;break}}if(K&&Q&&typeof Q==="object"){let W=X[X.length-1];if(W in Q)G[W]=Q[W]}}return Y}function FW($,Z={}){let{name:Y,persist:J,devtools:X=!1,middleware:Q=[],equals:G=(O,V)=>O===V}=Z,K=$,W=new Set,U=null;if(J){let O=wA(J.storage||"local"),V=J.key||`stx-store:${Y||"unnamed"}`,L=J.deserialize||JSON.parse;try{let F=O.getItem(V);if(F){let A=L(F);if(J.paths&&typeof A==="object"&&A!==null)K={...$,...A};else K=A}}catch{}}let z=(O)=>{if(!J)return;let V=wA(J.storage||"local"),L=J.key||`stx-store:${Y||"unnamed"}`,F=J.serialize||JSON.stringify,A=J.paths&&typeof O==="object"&&O!==null?Uf(O,J.paths):O;if(J.debounce){if(U)clearTimeout(U);U=setTimeout(()=>{V.setItem(L,F(A))},J.debounce)}else V.setItem(L,F(A))},_=(O,V)=>{for(let L of W)try{L(O,V)}catch(F){console.error("[stx-store] Subscriber error:",F)}},q=X?(O,V)=>{if(typeof window<"u"&&window.__STX_DEVTOOLS__)window.__STX_DEVTOOLS__.onStoreChange(Y||"unnamed",O,V)}:()=>{},B=(O)=>{let V=K;if(!G(O,V))K=O,z(O),_(O,V),q("set",O)},j=B,H={get:()=>K,set:(O)=>{if(typeof O==="function")j(O(K));else j(O)},subscribe:(O)=>{return W.add(O),()=>{W.delete(O)}},update:(O)=>{if(typeof K!=="object"||K===null)throw Error("update() can only be used with object stores");let V=typeof O==="function"?O(K):O;H.set({...K,...V})},reset:()=>{H.set($),q("reset",$)},name:Y,destroy:()=>{if(W.clear(),U)clearTimeout(U);if(Y)U3.stores.delete(Y)}};for(let O of Q.reverse())j=O(B,()=>K,H)(j);if(Y)Wf(Y,H);return H}function MA($){let Z=typeof $==="string"?VW($):$;if(!Z)throw Error(`Store "${$}" not found`);return Z.get()}function TA($,Z,Y){if(typeof Z==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,Z,Y);return Z()}let J=Z,{state:X,getters:Q={},actions:G={},persist:K,devtools:W=!0}=J,U=typeof X==="function"?X():X,z=K===!0?{storage:"local",key:`stx-store:${$}`}:K||void 0,_=FW(U,{name:$,persist:z,devtools:W}),q=new Proxy({},{get(B,j){let H=String(j);if(H==="$state")return _.get();if(H==="$subscribe")return _.subscribe;if(H==="$reset")return _.reset;if(H==="$patch")return(V)=>{if(typeof V==="function"){let F={..._.get()};V(F),_.set(F)}else _.update(V)};if(H==="_store")return _;if(H==="$id")return $;if(H in Q)return Q[H](_.get());if(H in G)return(...V)=>{return G[H].apply(q,V)};let O=_.get();if(O&&typeof O==="object"&&H in O)return O[H];return},set(B,j,H){let O=String(j);if(O.startsWith("$")||O==="_store")return!1;let V=_.get();if(V&&typeof V==="object")return _.set({...V,[O]:H}),!0;return!1},has(B,j){let H=String(j),O=_.get();return H.startsWith("$")||H==="_store"||H in Q||H in G||O&&typeof O==="object"&&H in O},ownKeys(){let B=_.get();return[...B&&typeof B==="object"?Object.keys(B):[],...Object.keys(Q),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(B,j){return{enumerable:!0,configurable:!0,get:()=>this.get(B,j,q)}}});return zf.set($,q),q}function EA($){if(typeof window>"u")return;let Z=window;Z.__STX_STORES__=Z.__STX_STORES__||{};for(let[Y,J]of Object.entries($))Z.__STX_STORES__[Y]=J;window.dispatchEvent(new CustomEvent("stx:stores-ready",{detail:Object.keys($)}))}var U3,a5,zf;var IA=D(()=>{U3={stores:new Map,subscriptions:new Map};a5=new Map;zf=new Map});function S0($,Z={}){let Y=[];for(let[X,Q]of Object.entries(Z)){if(Q===void 0||Q===null)continue;if(Array.isArray(Q))Y.push(`${X}=${encodeURIComponent(Q.join(","))}`);else if(typeof Q==="boolean"){if(Q)Y.push(`${X}=true`)}else Y.push(`${X}=${encodeURIComponent(String(Q))}`)}if(Y.length===0)return $;let J=$.includes("?")?"&":"?";return`${$}${J}${Y.join("&")}`}function AW($){let Z=$.indexOf("?");if(Z===-1)return{src:$,params:{}};let Y=$.slice(0,Z),J=$.slice(Z+1),X={};for(let Q of J.split("&")){let[G,K]=Q.split("="),W=K?decodeURIComponent(K):"";if(W==="true")X[G]=!0;else if(W==="false")X[G]=!1;else if(/^-?\d+$/.test(W))X[G]=Number.parseInt(W,10);else if(/^-?\d+\.\d+$/.test(W))X[G]=Number.parseFloat(W);else if(W.includes(","))X[G]=W.split(",");else X[G]=W}return{src:Y,params:X}}function rJ(...$){let Z={};for(let Y of $)if(Y)Object.assign(Z,Y);return Z}function wW($,Z,Y,J){let X={w:Z};if(Y)X.h=Y;if(J)X.fit=J;return S0($,X)}function NW($,Z,Y,J="center"){return S0($,{w:Z,h:Y,fit:"crop",crop:J})}function RW($,Z,Y="center"){return S0($,{w:Z,h:Z,fit:"crop",crop:Y})}function MW($,Z,Y){return S0($,{w:Z,h:Y,fit:"max"})}function TW($,Z,Y){return S0($,{w:Z,h:Y,fit:"crop"})}function EW($,Z){return S0($,{blur:Math.min(2000,Math.max(0,Z))})}function IW($,Z){return S0($,{sharp:Math.min(100,Math.max(0,Z))})}function DW($){return S0($,{sat:-100})}function kW($,Z=100){return S0($,{sepia:Math.min(100,Math.max(0,Z))})}function SW($){return S0($,{invert:!0})}function CW($,Z){return S0($,{bri:Math.min(100,Math.max(-100,Z))})}function bW($,Z){return S0($,{con:Math.min(100,Math.max(-100,Z))})}function PW($,Z){return S0($,{sat:Math.min(100,Math.max(-100,Z))})}function yW($,Z){return S0($,{rot:(Z%360+360)%360})}function xW($){return S0($,{flip:"h"})}function vW($){return S0($,{flip:"v"})}function fW($,Z,Y){let J={fm:Z};if(Y!==void 0)J.q=Y;return S0($,J)}function gW($,Z){return S0($,{q:Math.min(100,Math.max(1,Z))})}function hW($,Z=["format","compress"]){return S0($,{auto:Z})}function dW($,Z,Y={}){return S0($,{mark:Z,markx:Y.x,marky:Y.y,markalpha:Y.alpha,markscale:Y.scale,markalign:Y.align})}function uW($,Z,Y){return S0($,rJ(aJ[Z],Y))}function mW($,Z,Y){return Z.map((J)=>S0($,{...Y,w:J}))}function lW($,Z,Y=[1,2,3],J){return Y.map((X)=>S0($,{...J,w:Math.round(Z*X),dpr:X}))}function cW($){let Z=[];if($.w!==void 0&&($.w<1||$.w>16383))Z.push("Width must be between 1 and 16383");if($.h!==void 0&&($.h<1||$.h>16383))Z.push("Height must be between 1 and 16383");if($.q!==void 0&&($.q<1||$.q>100))Z.push("Quality must be between 1 and 100");if($.blur!==void 0&&($.blur<0||$.blur>2000))Z.push("Blur must be between 0 and 2000");if($.rot!==void 0&&($.rot<0||$.rot>359))Z.push("Rotation must be between 0 and 359");if($.dpr!==void 0&&($.dpr<1||$.dpr>5))Z.push("DPR must be between 1 and 5");return{valid:Z.length===0,errors:Z}}function pW($){let Z={...$};if(Z.w!==void 0)Z.w=Math.min(16383,Math.max(1,Z.w));if(Z.h!==void 0)Z.h=Math.min(16383,Math.max(1,Z.h));if(Z.q!==void 0)Z.q=Math.min(100,Math.max(1,Z.q));if(Z.blur!==void 0)Z.blur=Math.min(2000,Math.max(0,Z.blur));if(Z.rot!==void 0)Z.rot=(Z.rot%360+360)%360;if(Z.dpr!==void 0)Z.dpr=Math.min(5,Math.max(1,Z.dpr));return Z}var aJ;var DA=D(()=>{aJ={web:{fm:"webp",q:80,auto:["format","compress"]},highQuality:{q:95},thumb:{w:150,h:150,fit:"crop",crop:"center"},avatar:{w:200,h:200,fit:"crop",crop:"faces"},social:{w:1200,h:630,fit:"crop"},preview:{w:400,q:70},placeholder:{w:20,blur:200,q:20}}});var kA=D(()=>{EG();DG();nY();_G();DA()});function iW($){let{endpoint:Z,accept:Y,maxSize:J,maxFiles:X=1,fieldName:Q="file",preview:G=!1,dropzone:K=!0,multiple:W=!1,autoUpload:U=!0,showProgress:z=!0,disabled:_=!1,placeholder:q="Drop files here or click to select",label:B}=$,j=$.class||"",H=$.style||"",O=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,V=Array.isArray(Y)?Y.join(","):Y,L=`
16901
+ `}var OW=null;var LA=()=>{};import VA from"path";import{patternToRegex as ht}from"stx-router";class FA{store=new Map;async get($){let Z=this.store.get($);if(!Z||Z.expires<=Date.now()){if(Z)this.store.delete($);return null}return{...Z.data}}async set($,Z,Y){this.store.set($,{data:{...Z},expires:Date.now()+Y*1000})}async delete($){this.store.delete($)}}async function Wf($,Z={},Y={}){let J=Y.viewsDir||"./views",X=Y.layoutsDir||"./layouts",Q=!$.includes("<")&&!$.includes("@"),G,K;if(Q){if(K=VA.resolve(J,$),!K.endsWith(".stx"))K+=".stx";if(!await Bun.file(K).exists())return new Response(`Template not found: ${$}`,{status:500});G=await Bun.file(K).text()}else G=$,K="inline-template.stx";let W={...Z,props:Z,__filename:K,__dirname:VA.dirname(K)};if(Y.ctx)W.csrf_token=Y.ctx.csrfToken,W.csrf_field=`<input type="hidden" name="_token" value="${Y.ctx.csrfToken}">`,W.old=Y.ctx.old,W.errors=Y.ctx.errors,W.session=Y.ctx.session,W.user=Y.ctx.user(),W.isAuthenticated=Y.ctx.isAuthenticated();let U=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(U){let j=U[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await k0(j,W,K)}let z={layoutsDir:X,...Y.stxOptions},q=await B0(G,W,K,z,new Set),B=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Y.ctx)Y.ctx.responseHeaders.forEach((j,H)=>{B.set(H,j)});return new Response(q,{headers:B})}var AA=D(()=>{b1();q1();R0()});function Uf($,Z){U3.stores.set($,Z)}function VW($){return U3.stores.get($)}function NA($){return U3.stores.has($)}function RA(){return Array.from(U3.stores.keys())}function wA($){if($==="memory")return{getItem:(Z)=>a5.get(Z)??null,setItem:(Z,Y)=>a5.set(Z,Y),removeItem:(Z)=>a5.delete(Z)};if(typeof window>"u")return{getItem:(Z)=>a5.get(Z)??null,setItem:(Z,Y)=>a5.set(Z,Y),removeItem:(Z)=>a5.delete(Z)};return $==="local"?window.localStorage:window.sessionStorage}function zf($,Z){let Y={};for(let J of Z){let X=J.split("."),Q=$,G=Y,K=!0;for(let W=0;W<X.length-1;W++){let U=X[W];if(Q&&typeof Q==="object"&&U in Q){if(Q=Q[U],!(U in G))G[U]={};G=G[U]}else{K=!1;break}}if(K&&Q&&typeof Q==="object"){let W=X[X.length-1];if(W in Q)G[W]=Q[W]}}return Y}function FW($,Z={}){let{name:Y,persist:J,devtools:X=!1,middleware:Q=[],equals:G=(O,V)=>O===V}=Z,K=$,W=new Set,U=null;if(J){let O=wA(J.storage||"local"),V=J.key||`stx-store:${Y||"unnamed"}`,L=J.deserialize||JSON.parse;try{let F=O.getItem(V);if(F){let A=L(F);if(J.paths&&typeof A==="object"&&A!==null)K={...$,...A};else K=A}}catch{}}let z=(O)=>{if(!J)return;let V=wA(J.storage||"local"),L=J.key||`stx-store:${Y||"unnamed"}`,F=J.serialize||JSON.stringify,A=J.paths&&typeof O==="object"&&O!==null?zf(O,J.paths):O;if(J.debounce){if(U)clearTimeout(U);U=setTimeout(()=>{V.setItem(L,F(A))},J.debounce)}else V.setItem(L,F(A))},_=(O,V)=>{for(let L of W)try{L(O,V)}catch(F){console.error("[stx-store] Subscriber error:",F)}},q=X?(O,V)=>{if(typeof window<"u"&&window.__STX_DEVTOOLS__)window.__STX_DEVTOOLS__.onStoreChange(Y||"unnamed",O,V)}:()=>{},B=(O)=>{let V=K;if(!G(O,V))K=O,z(O),_(O,V),q("set",O)},j=B,H={get:()=>K,set:(O)=>{if(typeof O==="function")j(O(K));else j(O)},subscribe:(O)=>{return W.add(O),()=>{W.delete(O)}},update:(O)=>{if(typeof K!=="object"||K===null)throw Error("update() can only be used with object stores");let V=typeof O==="function"?O(K):O;H.set({...K,...V})},reset:()=>{H.set($),q("reset",$)},name:Y,destroy:()=>{if(W.clear(),U)clearTimeout(U);if(Y)U3.stores.delete(Y)}};for(let O of Q.reverse())j=O(B,()=>K,H)(j);if(Y)Uf(Y,H);return H}function MA($){let Z=typeof $==="string"?VW($):$;if(!Z)throw Error(`Store "${$}" not found`);return Z.get()}function TA($,Z,Y){if(typeof Z==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,Z,Y);return Z()}let J=Z,{state:X,getters:Q={},actions:G={},persist:K,devtools:W=!0}=J,U=typeof X==="function"?X():X,z=K===!0?{storage:"local",key:`stx-store:${$}`}:K||void 0,_=FW(U,{name:$,persist:z,devtools:W}),q=new Proxy({},{get(B,j){let H=String(j);if(H==="$state")return _.get();if(H==="$subscribe")return _.subscribe;if(H==="$reset")return _.reset;if(H==="$patch")return(V)=>{if(typeof V==="function"){let F={..._.get()};V(F),_.set(F)}else _.update(V)};if(H==="_store")return _;if(H==="$id")return $;if(H in Q)return Q[H](_.get());if(H in G)return(...V)=>{return G[H].apply(q,V)};let O=_.get();if(O&&typeof O==="object"&&H in O)return O[H];return},set(B,j,H){let O=String(j);if(O.startsWith("$")||O==="_store")return!1;let V=_.get();if(V&&typeof V==="object")return _.set({...V,[O]:H}),!0;return!1},has(B,j){let H=String(j),O=_.get();return H.startsWith("$")||H==="_store"||H in Q||H in G||O&&typeof O==="object"&&H in O},ownKeys(){let B=_.get();return[...B&&typeof B==="object"?Object.keys(B):[],...Object.keys(Q),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(B,j){return{enumerable:!0,configurable:!0,get:()=>this.get(B,j,q)}}});return _f.set($,q),q}function EA($){if(typeof window>"u")return;let Z=window;Z.__STX_STORES__=Z.__STX_STORES__||{};for(let[Y,J]of Object.entries($))Z.__STX_STORES__[Y]=J;window.dispatchEvent(new CustomEvent("stx:stores-ready",{detail:Object.keys($)}))}var U3,a5,_f;var IA=D(()=>{U3={stores:new Map,subscriptions:new Map};a5=new Map;_f=new Map});function S0($,Z={}){let Y=[];for(let[X,Q]of Object.entries(Z)){if(Q===void 0||Q===null)continue;if(Array.isArray(Q))Y.push(`${X}=${encodeURIComponent(Q.join(","))}`);else if(typeof Q==="boolean"){if(Q)Y.push(`${X}=true`)}else Y.push(`${X}=${encodeURIComponent(String(Q))}`)}if(Y.length===0)return $;let J=$.includes("?")?"&":"?";return`${$}${J}${Y.join("&")}`}function AW($){let Z=$.indexOf("?");if(Z===-1)return{src:$,params:{}};let Y=$.slice(0,Z),J=$.slice(Z+1),X={};for(let Q of J.split("&")){let[G,K]=Q.split("="),W=K?decodeURIComponent(K):"";if(W==="true")X[G]=!0;else if(W==="false")X[G]=!1;else if(/^-?\d+$/.test(W))X[G]=Number.parseInt(W,10);else if(/^-?\d+\.\d+$/.test(W))X[G]=Number.parseFloat(W);else if(W.includes(","))X[G]=W.split(",");else X[G]=W}return{src:Y,params:X}}function rJ(...$){let Z={};for(let Y of $)if(Y)Object.assign(Z,Y);return Z}function wW($,Z,Y,J){let X={w:Z};if(Y)X.h=Y;if(J)X.fit=J;return S0($,X)}function NW($,Z,Y,J="center"){return S0($,{w:Z,h:Y,fit:"crop",crop:J})}function RW($,Z,Y="center"){return S0($,{w:Z,h:Z,fit:"crop",crop:Y})}function MW($,Z,Y){return S0($,{w:Z,h:Y,fit:"max"})}function TW($,Z,Y){return S0($,{w:Z,h:Y,fit:"crop"})}function EW($,Z){return S0($,{blur:Math.min(2000,Math.max(0,Z))})}function IW($,Z){return S0($,{sharp:Math.min(100,Math.max(0,Z))})}function DW($){return S0($,{sat:-100})}function kW($,Z=100){return S0($,{sepia:Math.min(100,Math.max(0,Z))})}function SW($){return S0($,{invert:!0})}function CW($,Z){return S0($,{bri:Math.min(100,Math.max(-100,Z))})}function bW($,Z){return S0($,{con:Math.min(100,Math.max(-100,Z))})}function PW($,Z){return S0($,{sat:Math.min(100,Math.max(-100,Z))})}function yW($,Z){return S0($,{rot:(Z%360+360)%360})}function xW($){return S0($,{flip:"h"})}function vW($){return S0($,{flip:"v"})}function fW($,Z,Y){let J={fm:Z};if(Y!==void 0)J.q=Y;return S0($,J)}function gW($,Z){return S0($,{q:Math.min(100,Math.max(1,Z))})}function hW($,Z=["format","compress"]){return S0($,{auto:Z})}function dW($,Z,Y={}){return S0($,{mark:Z,markx:Y.x,marky:Y.y,markalpha:Y.alpha,markscale:Y.scale,markalign:Y.align})}function uW($,Z,Y){return S0($,rJ(aJ[Z],Y))}function mW($,Z,Y){return Z.map((J)=>S0($,{...Y,w:J}))}function lW($,Z,Y=[1,2,3],J){return Y.map((X)=>S0($,{...J,w:Math.round(Z*X),dpr:X}))}function cW($){let Z=[];if($.w!==void 0&&($.w<1||$.w>16383))Z.push("Width must be between 1 and 16383");if($.h!==void 0&&($.h<1||$.h>16383))Z.push("Height must be between 1 and 16383");if($.q!==void 0&&($.q<1||$.q>100))Z.push("Quality must be between 1 and 100");if($.blur!==void 0&&($.blur<0||$.blur>2000))Z.push("Blur must be between 0 and 2000");if($.rot!==void 0&&($.rot<0||$.rot>359))Z.push("Rotation must be between 0 and 359");if($.dpr!==void 0&&($.dpr<1||$.dpr>5))Z.push("DPR must be between 1 and 5");return{valid:Z.length===0,errors:Z}}function pW($){let Z={...$};if(Z.w!==void 0)Z.w=Math.min(16383,Math.max(1,Z.w));if(Z.h!==void 0)Z.h=Math.min(16383,Math.max(1,Z.h));if(Z.q!==void 0)Z.q=Math.min(100,Math.max(1,Z.q));if(Z.blur!==void 0)Z.blur=Math.min(2000,Math.max(0,Z.blur));if(Z.rot!==void 0)Z.rot=(Z.rot%360+360)%360;if(Z.dpr!==void 0)Z.dpr=Math.min(5,Math.max(1,Z.dpr));return Z}var aJ;var DA=D(()=>{aJ={web:{fm:"webp",q:80,auto:["format","compress"]},highQuality:{q:95},thumb:{w:150,h:150,fit:"crop",crop:"center"},avatar:{w:200,h:200,fit:"crop",crop:"faces"},social:{w:1200,h:630,fit:"crop"},preview:{w:400,q:70},placeholder:{w:20,blur:200,q:20}}});var kA=D(()=>{EG();DG();nY();_G();DA()});function iW($){let{endpoint:Z,accept:Y,maxSize:J,maxFiles:X=1,fieldName:Q="file",preview:G=!1,dropzone:K=!0,multiple:W=!1,autoUpload:U=!0,showProgress:z=!0,disabled:_=!1,placeholder:q="Drop files here or click to select",label:B}=$,j=$.class||"",H=$.style||"",O=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,V=Array.isArray(Y)?Y.join(","):Y,L=`
16902
16902
  <div id="${O}" class="stx-upload${K?" stx-upload-dropzone":""}${_?" stx-upload-disabled":""}${j?" "+j:""}"${H?` style="${H}"`:""}>
16903
16903
  ${B?`<label class="stx-upload-label">${SA(B)}</label>`:""}
16904
16904
  <div class="stx-upload-area" data-stx-upload-area>
@@ -16916,7 +16916,7 @@ else {
16916
16916
  <path fill="currentColor" d="M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z"/>
16917
16917
  </svg>
16918
16918
  <span class="stx-upload-text">${SA(q)}</span>
16919
- ${J?`<span class="stx-upload-hint">Max size: ${jf(J)}</span>`:""}
16919
+ ${J?`<span class="stx-upload-hint">Max size: ${Hf(J)}</span>`:""}
16920
16920
  </div>
16921
16921
  </div>
16922
16922
  ${G?'<div class="stx-upload-previews" data-stx-upload-previews></div>':""}
@@ -16935,7 +16935,7 @@ else {
16935
16935
  var progressText = progress ? progress.querySelector('.stx-upload-progress-text') : null;
16936
16936
 
16937
16937
  var config = {
16938
- endpoint: '${Bf(Z)}',
16938
+ endpoint: '${jf(Z)}',
16939
16939
  fieldName: '${Q}',
16940
16940
  maxSize: ${J||"null"},
16941
16941
  maxFiles: ${X},
@@ -17187,7 +17187,7 @@ else {
17187
17187
  opacity: 0.5;
17188
17188
  pointer-events: none;
17189
17189
  }
17190
- `.trim();return{html:L,script:F,css:A}}function SA($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Bf($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function jf($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}var CA=()=>{};async function sJ($,Z){let{endpoint:Y,method:J="POST",headers:X={},expirationSeconds:Q=3600,oneTimeUse:G=!1,params:K={}}=Z,W=JSON.stringify({url:$,expirationSeconds:Q,oneTimeUse:G,...K}),U=await fetch(Y,{method:J,headers:{"Content-Type":"application/json",...X},body:J!=="GET"?W:void 0});if(!U.ok)throw Error(`Failed to sign URL: ${U.status} ${U.statusText}`);let z=await U.json();return{url:z.url||z.signedUrl,signature:z.signature,expires:z.expires||Date.now()+Q*1000,oneTimeUse:z.oneTimeUse||G}}async function oJ($,Z){let{endpoint:Y,method:J="POST",headers:X={},expirationSeconds:Q=3600,oneTimeUse:G=!1,params:K={}}=Z,W=JSON.stringify({urls:$,expirationSeconds:Q,oneTimeUse:G,...K}),U=await fetch(Y,{method:J,headers:{"Content-Type":"application/json",...X},body:J!=="GET"?W:void 0});if(!U.ok)throw Error(`Failed to batch sign URLs: ${U.status} ${U.statusText}`);let z=await U.json(),_=new Map,q=new Map;if(Array.isArray(z.results))for(let B of z.results)if(B.error)q.set(B.url,B.error);else _.set(B.url||B.originalUrl,{url:B.signedUrl||B.url,signature:B.signature,expires:B.expires||Date.now()+Q*1000,oneTimeUse:B.oneTimeUse||G});else if(typeof z.signatures==="object"){for(let[B,j]of Object.entries(z.signatures)){let H=j;_.set(B,{url:H.signedUrl||H.url||B,signature:H.signature,expires:H.expires||Date.now()+Q*1000,oneTimeUse:G})}if(z.errors)for(let[B,j]of Object.entries(z.errors))q.set(B,j)}return{signatures:_,errors:q}}async function nW($,Z,Y=10){let J=new Map,X=new Map,Q=[];for(let K=0;K<$.length;K+=Y)Q.push($.slice(K,K+Y));let G=await Promise.all(Q.map((K)=>oJ(K,Z)));for(let K of G){for(let[W,U]of K.signatures)J.set(W,U);for(let[W,U]of K.errors)X.set(W,U)}return{signatures:J,errors:X}}function tJ($){return $.expires>Date.now()}function eJ($){return Math.max(0,$.expires-Date.now())}function $X($,Z=300000){return eJ($)<Z}async function s5($){if($.check)return await $.check();return!0}function _3($){let Z={};if($.role)Z.role=$.role;if($.permission)Z.permission=$.permission;if($.userId)Z.userId=$.userId;return Z}async function rW($,Z){let Y=`${$}:${Z.endpoint}`,J=z3.get(Y);if(J&&tJ(J)&&!$X(J))return J;let X=await sJ($,Z);return z3.set(Y,X),X}function aW(){z3.clear()}function sW(){let $=0,Z=Date.now();for(let[Y,J]of z3)if(J.expires<=Z)z3.delete(Y),$++;return $}function q3(){return`
17190
+ `.trim();return{html:L,script:F,css:A}}function SA($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function jf($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function Hf($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(1)} MB`}var CA=()=>{};async function sJ($,Z){let{endpoint:Y,method:J="POST",headers:X={},expirationSeconds:Q=3600,oneTimeUse:G=!1,params:K={}}=Z,W=JSON.stringify({url:$,expirationSeconds:Q,oneTimeUse:G,...K}),U=await fetch(Y,{method:J,headers:{"Content-Type":"application/json",...X},body:J!=="GET"?W:void 0});if(!U.ok)throw Error(`Failed to sign URL: ${U.status} ${U.statusText}`);let z=await U.json();return{url:z.url||z.signedUrl,signature:z.signature,expires:z.expires||Date.now()+Q*1000,oneTimeUse:z.oneTimeUse||G}}async function oJ($,Z){let{endpoint:Y,method:J="POST",headers:X={},expirationSeconds:Q=3600,oneTimeUse:G=!1,params:K={}}=Z,W=JSON.stringify({urls:$,expirationSeconds:Q,oneTimeUse:G,...K}),U=await fetch(Y,{method:J,headers:{"Content-Type":"application/json",...X},body:J!=="GET"?W:void 0});if(!U.ok)throw Error(`Failed to batch sign URLs: ${U.status} ${U.statusText}`);let z=await U.json(),_=new Map,q=new Map;if(Array.isArray(z.results))for(let B of z.results)if(B.error)q.set(B.url,B.error);else _.set(B.url||B.originalUrl,{url:B.signedUrl||B.url,signature:B.signature,expires:B.expires||Date.now()+Q*1000,oneTimeUse:B.oneTimeUse||G});else if(typeof z.signatures==="object"){for(let[B,j]of Object.entries(z.signatures)){let H=j;_.set(B,{url:H.signedUrl||H.url||B,signature:H.signature,expires:H.expires||Date.now()+Q*1000,oneTimeUse:G})}if(z.errors)for(let[B,j]of Object.entries(z.errors))q.set(B,j)}return{signatures:_,errors:q}}async function nW($,Z,Y=10){let J=new Map,X=new Map,Q=[];for(let K=0;K<$.length;K+=Y)Q.push($.slice(K,K+Y));let G=await Promise.all(Q.map((K)=>oJ(K,Z)));for(let K of G){for(let[W,U]of K.signatures)J.set(W,U);for(let[W,U]of K.errors)X.set(W,U)}return{signatures:J,errors:X}}function tJ($){return $.expires>Date.now()}function eJ($){return Math.max(0,$.expires-Date.now())}function $X($,Z=300000){return eJ($)<Z}async function s5($){if($.check)return await $.check();return!0}function _3($){let Z={};if($.role)Z.role=$.role;if($.permission)Z.permission=$.permission;if($.userId)Z.userId=$.userId;return Z}async function rW($,Z){let Y=`${$}:${Z.endpoint}`,J=z3.get(Y);if(J&&tJ(J)&&!$X(J))return J;let X=await sJ($,Z);return z3.set(Y,X),X}function aW(){z3.clear()}function sW(){let $=0,Z=Date.now();for(let[Y,J]of z3)if(J.expires<=Z)z3.delete(Y),$++;return $}function q3(){return`
17191
17191
  (function() {
17192
17192
  'use strict';
17193
17193
 
@@ -17315,7 +17315,7 @@ else if (el.dataset.fallback) {
17315
17315
  });
17316
17316
  });
17317
17317
  })();
17318
- `.trim(),{html:$,script:Q}}function ZU($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),signatureEndpoint:String(Z.signatureEndpoint||"/api/sign"),auth:Z.auth,fallback:Z.fallback?String(Z.fallback):void 0,oneTimeUse:Z.oneTimeUse!==!1};let J=$.trim();if(J.startsWith("@protected(")||J.startsWith("("))J=J.replace(/^@protected\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=Hf(J);return{src:bA(X[0],Y)||"",alt:bA(X[1],Y)||"",...typeof X[2]==="object"?X[2]:{}}}function Hf($){let Z=[],Y="",J=!1,X="",Q=0;for(let G=0;G<$.length;G++){let K=$[G],W=G>0?$[G-1]:"";if((K==='"'||K==="'")&&W!=="\\"){if(!J)J=!0,X=K;else if(K===X)J=!1;else Y+=K;continue}if(!J){if(K==="{")Q++;if(K==="}")Q--;if(K===","&&Q===0){Z.push(Y.trim()),Y="";continue}}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function bA($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(Z[Y]!==void 0)return Z[Y];if(Y.startsWith("{"))try{return JSON.parse(Y)}catch{}return Y}function c0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var PA=D(()=>{oW()});var yA=D(()=>{oW();PA()});function vA($){let{src:Z,apiKey:Y,bucket:J,allowedTypes:X,maxFileSize:Q,multiple:G=!1,customStyles:K={},callbacks:W={}}=$,U=`stx-media-manager-${Math.random().toString(36).slice(2,8)}`,z={container:`#${U}`};if(Y)z.apiKey=Y;if(J)z.bucket=J;if(X)z.allowedTypes=X;if(Q)z.maxFileSize=Q;if(G)z.multiple=G;if(Object.keys(K).length>0)z.styles=K;let _=`<div id="${U}" class="stx-media-manager"></div>`,q=Object.entries(W).filter(([,j])=>j).map(([j,H])=>{return`manager.on('${j.replace(/^on/,"").toLowerCase()}', ${H});`}).join(`
17318
+ `.trim(),{html:$,script:Q}}function ZU($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),signatureEndpoint:String(Z.signatureEndpoint||"/api/sign"),auth:Z.auth,fallback:Z.fallback?String(Z.fallback):void 0,oneTimeUse:Z.oneTimeUse!==!1};let J=$.trim();if(J.startsWith("@protected(")||J.startsWith("("))J=J.replace(/^@protected\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=Of(J);return{src:bA(X[0],Y)||"",alt:bA(X[1],Y)||"",...typeof X[2]==="object"?X[2]:{}}}function Of($){let Z=[],Y="",J=!1,X="",Q=0;for(let G=0;G<$.length;G++){let K=$[G],W=G>0?$[G-1]:"";if((K==='"'||K==="'")&&W!=="\\"){if(!J)J=!0,X=K;else if(K===X)J=!1;else Y+=K;continue}if(!J){if(K==="{")Q++;if(K==="}")Q--;if(K===","&&Q===0){Z.push(Y.trim()),Y="";continue}}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function bA($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(Z[Y]!==void 0)return Z[Y];if(Y.startsWith("{"))try{return JSON.parse(Y)}catch{}return Y}function c0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var PA=D(()=>{oW()});var yA=D(()=>{oW();PA()});function vA($){let{src:Z,apiKey:Y,bucket:J,allowedTypes:X,maxFileSize:Q,multiple:G=!1,customStyles:K={},callbacks:W={}}=$,U=`stx-media-manager-${Math.random().toString(36).slice(2,8)}`,z={container:`#${U}`};if(Y)z.apiKey=Y;if(J)z.bucket=J;if(X)z.allowedTypes=X;if(Q)z.maxFileSize=Q;if(G)z.multiple=G;if(Object.keys(K).length>0)z.styles=K;let _=`<div id="${U}" class="stx-media-manager"></div>`,q=Object.entries(W).filter(([,j])=>j).map(([j,H])=>{return`manager.on('${j.replace(/^on/,"").toLowerCase()}', ${H});`}).join(`
17319
17319
  `),B=`
17320
17320
  (function() {
17321
17321
  // Load media manager script
@@ -17531,7 +17531,7 @@ else {
17531
17531
  border: none;
17532
17532
  color: white;
17533
17533
  }
17534
- `.trim();return{html:Q,script:G,css:K}}function xA($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ZX(){return"loading"in HTMLImageElement.prototype}function YX(){return"IntersectionObserver"in window}function YU($={}){let Z={...dA,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&ZX())return Y.forEach((X)=>{if(X.tagName==="IMG"||X.tagName==="IFRAME")m4(X,Z)}),()=>{};if(!YX())return Y.forEach((X)=>m4(X,Z)),()=>{};let J=new IntersectionObserver((X)=>{X.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;m4(G,Z),J.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((X)=>J.observe(X)),()=>{J.disconnect()}}function m4($,Z={}){let{onLoad:Y,onLoaded:J,onError:X}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)gA($,J,X);else if(G)hA($,J,X);else if(K)Of($,J,X);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)gA(W,()=>{if(J)J($)},(_)=>{if(X)X($,_)});else if(U)hA(U,()=>{if(J)J($)},(_)=>{if(X)X($,_)});$.querySelectorAll("source[data-srcset]").forEach((_)=>{let q=_;if(q.dataset.srcset)q.srcset=q.dataset.srcset,delete q.dataset.srcset;if(q.dataset.sizes)q.sizes=q.dataset.sizes,delete q.dataset.sizes})}}function gA($,Z,Y){let J=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let Q=$.closest(".stx-img-placeholder");if(Q)Q.classList.add("stx-img-loaded");if(Z)Z($)},X=()=>{if($.classList.add("stx-img-error"),Y)Y($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function hA($,Z,Y){let J=()=>{if($.classList.add("stx-video-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-video-error"),Y)Y($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let K=G;if(K.dataset.src)K.src=K.dataset.src,delete K.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function Of($,Z,Y){let J=()=>{if($.classList.add("stx-iframe-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-iframe-error"),Y)Y($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function JU($){m4($,{})}function XU($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>m4(Y,{}))}function QU($={}){let Z={...dA,...$};return new IntersectionObserver((Y,J)=>{Y.forEach((X)=>{if(X.isIntersecting)m4(X.target,Z),J.unobserve(X.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function GU($,Z){$.observe(Z)}function KU($){$.disconnect()}function B3(){return`
17534
+ `.trim();return{html:Q,script:G,css:K}}function xA($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function ZX(){return"loading"in HTMLImageElement.prototype}function YX(){return"IntersectionObserver"in window}function YU($={}){let Z={...dA,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&ZX())return Y.forEach((X)=>{if(X.tagName==="IMG"||X.tagName==="IFRAME")m4(X,Z)}),()=>{};if(!YX())return Y.forEach((X)=>m4(X,Z)),()=>{};let J=new IntersectionObserver((X)=>{X.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;m4(G,Z),J.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((X)=>J.observe(X)),()=>{J.disconnect()}}function m4($,Z={}){let{onLoad:Y,onLoaded:J,onError:X}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)gA($,J,X);else if(G)hA($,J,X);else if(K)Lf($,J,X);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)gA(W,()=>{if(J)J($)},(_)=>{if(X)X($,_)});else if(U)hA(U,()=>{if(J)J($)},(_)=>{if(X)X($,_)});$.querySelectorAll("source[data-srcset]").forEach((_)=>{let q=_;if(q.dataset.srcset)q.srcset=q.dataset.srcset,delete q.dataset.srcset;if(q.dataset.sizes)q.sizes=q.dataset.sizes,delete q.dataset.sizes})}}function gA($,Z,Y){let J=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let Q=$.closest(".stx-img-placeholder");if(Q)Q.classList.add("stx-img-loaded");if(Z)Z($)},X=()=>{if($.classList.add("stx-img-error"),Y)Y($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function hA($,Z,Y){let J=()=>{if($.classList.add("stx-video-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-video-error"),Y)Y($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let K=G;if(K.dataset.src)K.src=K.dataset.src,delete K.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function Lf($,Z,Y){let J=()=>{if($.classList.add("stx-iframe-loaded"),Z)Z($)},X=()=>{if($.classList.add("stx-iframe-error"),Y)Y($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",J,{once:!0}),$.addEventListener("error",X,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function JU($){m4($,{})}function XU($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>m4(Y,{}))}function QU($={}){let Z={...dA,...$};return new IntersectionObserver((Y,J)=>{Y.forEach((X)=>{if(X.isIntersecting)m4(X.target,Z),J.unobserve(X.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function GU($,Z){$.observe(Z)}function KU($){$.disconnect()}function B3(){return`
17535
17535
  (function() {
17536
17536
  'use strict';
17537
17537
 
@@ -17621,7 +17621,7 @@ else {
17621
17621
  window.STX.lazyLoad = loadElement;
17622
17622
  window.STX.initLazyLoading = init;
17623
17623
  })();
17624
- `.trim()}var dA;var WU=D(()=>{dA={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"}});function JX($,Z={}){let Y={...Lf,...Z},J=$.closest(".stx-img-placeholder");if(!J){Vf($,Y);return}if(J.style.setProperty("--stx-img-transition-duration",`${Y.duration}ms`),J.style.setProperty("--stx-img-transition-easing",Y.easing),Y.loadingClass)J.classList.add(Y.loadingClass);if($.complete&&$.naturalWidth>0)uA($,J,Y);else $.addEventListener("load",()=>uA($,J,Y),{once:!0}),$.addEventListener("error",()=>Ff($,J,Y),{once:!0})}function Vf($,Z){let Y=()=>{$.style.transition=`opacity ${Z.duration}ms ${Z.easing}`,$.style.opacity="1",$.classList.remove(Z.loadingClass),$.classList.add(Z.loadedClass)};if($.complete&&$.naturalWidth>0)Y();else $.style.opacity="0",$.classList.add(Z.loadingClass),$.addEventListener("load",Y,{once:!0})}function uA($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);if(Y.loadedClass)Z.classList.add(Y.loadedClass);if($.style.opacity="1",Y.removePlaceholder)setTimeout(()=>{Z.style.backgroundImage="none"},Y.duration)}function Ff($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);Z.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function UU($,Z){let Y=j3($),J=Z.getContext("2d");if(!J)return;Z.width=Y.w,Z.height=Y.h;let X=J.createImageData(Y.w,Y.h);X.data.set(Y.rgba),J.putImageData(X,0,0)}function j3($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,J=(Z>>6&63)/31.5-1,X=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,z=K>>15!==0,_=Math.max(3,z?G?5:7:G?5:5),q=Math.max(3,z?G?5:5:G?5:7),B=32,j=32,H=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let V=0;V<32;V++){let L=(O*32+V)*4,F=V/31,A=O/31,w=Y+(F-0.5)*Q*0.5+(A-0.5)*Q*0.5,N=J*(1-F*0.3),R=X*(1-A*0.3),E=w-0.6666666666666666*N,M=(3*w-E+R)/2,I=M-R;H[L]=Math.max(0,Math.min(255,Math.round(M*255))),H[L+1]=Math.max(0,Math.min(255,Math.round(I*255))),H[L+2]=Math.max(0,Math.min(255,Math.round(E*255))),H[L+3]=255}return{w:32,h:32,rgba:H}}function zU($){let Z=j3($),Y=document.createElement("canvas");Y.width=Z.w,Y.height=Z.h;let J=Y.getContext("2d");if(!J)return"";let X=J.createImageData(Z.w,Z.h);return X.data.set(Z.rgba),J.putImageData(X,0,0),Y.toDataURL("image/png")}function _U($){let Z=atob($),Y=new Uint8Array(Z.length);for(let J=0;J<Z.length;J++)Y[J]=Z.charCodeAt(J);return Y}function qU($,Z,Y=300){return new Promise((J)=>{$.style.transition=`opacity ${Y}ms ease-out`,Z.style.transition=`opacity ${Y}ms ease-out`,Z.style.opacity="0",Z.offsetWidth,$.style.opacity="0",Z.style.opacity="1",setTimeout(J,Y)})}function BU($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Y)=>{JX(Y,$)})}function H3(){return`
17624
+ `.trim()}var dA;var WU=D(()=>{dA={root:null,rootMargin:"50px 0px",threshold:0,useNative:!0,selector:"[data-stx-lazy]"}});function JX($,Z={}){let Y={...Vf,...Z},J=$.closest(".stx-img-placeholder");if(!J){Ff($,Y);return}if(J.style.setProperty("--stx-img-transition-duration",`${Y.duration}ms`),J.style.setProperty("--stx-img-transition-easing",Y.easing),Y.loadingClass)J.classList.add(Y.loadingClass);if($.complete&&$.naturalWidth>0)uA($,J,Y);else $.addEventListener("load",()=>uA($,J,Y),{once:!0}),$.addEventListener("error",()=>Af($,J,Y),{once:!0})}function Ff($,Z){let Y=()=>{$.style.transition=`opacity ${Z.duration}ms ${Z.easing}`,$.style.opacity="1",$.classList.remove(Z.loadingClass),$.classList.add(Z.loadedClass)};if($.complete&&$.naturalWidth>0)Y();else $.style.opacity="0",$.classList.add(Z.loadingClass),$.addEventListener("load",Y,{once:!0})}function uA($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);if(Y.loadedClass)Z.classList.add(Y.loadedClass);if($.style.opacity="1",Y.removePlaceholder)setTimeout(()=>{Z.style.backgroundImage="none"},Y.duration)}function Af($,Z,Y){if(Y.loadingClass)Z.classList.remove(Y.loadingClass);Z.classList.add("stx-img-error"),$.classList.add("stx-img-error")}function UU($,Z){let Y=j3($),J=Z.getContext("2d");if(!J)return;Z.width=Y.w,Z.height=Y.h;let X=J.createImageData(Y.w,Y.h);X.data.set(Y.rgba),J.putImageData(X,0,0)}function j3($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,J=(Z>>6&63)/31.5-1,X=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,z=K>>15!==0,_=Math.max(3,z?G?5:7:G?5:5),q=Math.max(3,z?G?5:5:G?5:7),B=32,j=32,H=new Uint8ClampedArray(4096);for(let O=0;O<32;O++)for(let V=0;V<32;V++){let L=(O*32+V)*4,F=V/31,A=O/31,w=Y+(F-0.5)*Q*0.5+(A-0.5)*Q*0.5,N=J*(1-F*0.3),R=X*(1-A*0.3),E=w-0.6666666666666666*N,M=(3*w-E+R)/2,I=M-R;H[L]=Math.max(0,Math.min(255,Math.round(M*255))),H[L+1]=Math.max(0,Math.min(255,Math.round(I*255))),H[L+2]=Math.max(0,Math.min(255,Math.round(E*255))),H[L+3]=255}return{w:32,h:32,rgba:H}}function zU($){let Z=j3($),Y=document.createElement("canvas");Y.width=Z.w,Y.height=Z.h;let J=Y.getContext("2d");if(!J)return"";let X=J.createImageData(Z.w,Z.h);return X.data.set(Z.rgba),J.putImageData(X,0,0),Y.toDataURL("image/png")}function _U($){let Z=atob($),Y=new Uint8Array(Z.length);for(let J=0;J<Z.length;J++)Y[J]=Z.charCodeAt(J);return Y}function qU($,Z,Y=300){return new Promise((J)=>{$.style.transition=`opacity ${Y}ms ease-out`,Z.style.transition=`opacity ${Y}ms ease-out`,Z.style.opacity="0",Z.offsetWidth,$.style.opacity="0",Z.style.opacity="1",setTimeout(J,Y)})}function BU($={}){document.querySelectorAll("[data-stx-blur-up], .stx-img-placeholder img").forEach((Y)=>{JX(Y,$)})}function H3(){return`
17625
17625
  (function() {
17626
17626
  'use strict';
17627
17627
 
@@ -17720,7 +17720,7 @@ else {
17720
17720
  .stx-img-error {
17721
17721
  opacity: 0.5;
17722
17722
  }
17723
- `.trim()}var Lf;var jU=D(()=>{Lf={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"}});function XX($,Z={}){if(Z.maxSize&&$.size>Z.maxSize)return{valid:!1,error:`File size (${mA($.size)}) exceeds maximum (${mA(Z.maxSize)})`,code:"FILE_TOO_LARGE"};if(Z.accept&&Z.accept.length>0){if(!Z.accept.some((J)=>{if(J.endsWith("/*")){let X=J.slice(0,-1);return $.type.startsWith(X)}return $.type===J}))return{valid:!1,error:`File type "${$.type}" is not allowed`,code:"INVALID_TYPE"}}return{valid:!0}}function mA($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function QX($,Z,Y){let J={...Af,...Z},X=XX($,J);if(!X.valid)return{success:!1,error:X.error,name:$.name,size:$.size,type:$.type};if(J.chunkSize&&$.size>J.chunkSize)return Nf($,J,Y);return wf($,J,Y)}async function wf($,Z,Y){return new Promise((J)=>{let X=new XMLHttpRequest,Q=Date.now(),G=0,K=Q;X.upload.addEventListener("progress",(U)=>{if(U.lengthComputable&&Y){let z=Date.now(),_=(z-K)/1000,q=U.loaded-G,B=_>0?q/_:0,j=U.total-U.loaded,H=B>0?j/B*1000:void 0;G=U.loaded,K=z,Y({file:$,loaded:U.loaded,total:U.total,percent:Math.round(U.loaded/U.total*100),speed:B,timeRemaining:H})}}),X.addEventListener("load",()=>{if(X.status>=200&&X.status<300)try{let U=JSON.parse(X.responseText);J({success:!0,url:U.url,id:U.id,name:$.name,size:$.size,type:$.type,data:U})}catch{J({success:!0,name:$.name,size:$.size,type:$.type})}else J({success:!1,error:`Upload failed with status ${X.status}`,name:$.name,size:$.size,type:$.type})}),X.addEventListener("error",()=>{J({success:!1,error:"Network error during upload",name:$.name,size:$.size,type:$.type})}),X.addEventListener("timeout",()=>{J({success:!1,error:"Upload timed out",name:$.name,size:$.size,type:$.type})});let W=new FormData;if(W.append(Z.fieldName||"file",$),Z.formData)for(let[U,z]of Object.entries(Z.formData))W.append(U,z);if(X.open(Z.method||"POST",Z.endpoint),X.timeout=Z.timeout||60000,X.withCredentials=Z.withCredentials||!1,Z.headers)for(let[U,z]of Object.entries(Z.headers))X.setRequestHeader(U,z);X.send(W)})}async function Nf($,Z,Y){let J=Z.chunkSize,X=Math.ceil($.size/J),Q=0,G;for(let K=0;K<X;K++){let W=K*J,U=Math.min(W+J,$.size),z=$.slice(W,U),_=new FormData;if(_.append(Z.fieldName||"file",z,$.name),_.append("chunk",String(K)),_.append("totalChunks",String(X)),_.append("fileName",$.name),_.append("fileSize",String($.size)),_.append("fileType",$.type),G)_.append("uploadId",G);if(Z.formData)for(let[q,B]of Object.entries(Z.formData))_.append(q,B);try{let q=await fetch(Z.endpoint,{method:Z.method||"POST",headers:Z.headers,credentials:Z.withCredentials?"include":"same-origin",body:_});if(!q.ok)return{success:!1,error:`Chunk ${K+1}/${X} failed with status ${q.status}`,name:$.name,size:$.size,type:$.type};let B=await q.json();if(!G&&B.uploadId)G=B.uploadId;if(Q=U,Y)Y({file:$,loaded:Q,total:$.size,percent:Math.round(Q/$.size*100),chunk:K+1,totalChunks:X});if(K===X-1)return{success:!0,url:B.url,id:B.id||G,name:$.name,size:$.size,type:$.type,data:B}}catch(q){return{success:!1,error:`Chunk upload failed: ${q}`,name:$.name,size:$.size,type:$.type}}}return{success:!1,error:"Unknown error during chunked upload",name:$.name,size:$.size,type:$.type}}async function HU($,Z,Y,J){let X=[];for(let Q of $){let G=await QX(Q,Z,(K)=>{if(Y)Y(Q,K)});if(X.push(G),J)J(Q,G)}return X}function OU($,Z=200){return new Promise((Y,J)=>{if(!$.type.startsWith("image/")){J(Error("File is not an image"));return}let X=new FileReader;X.onload=(Q)=>{let G=new Image;G.onload=()=>{let K=document.createElement("canvas"),W=G.width,U=G.height;if(W>Z||U>Z)if(W>U)U=Math.round(U*Z/W),W=Z;else W=Math.round(W*Z/U),U=Z;K.width=W,K.height=U;let z=K.getContext("2d");if(z)z.drawImage(G,0,0,W,U),Y(K.toDataURL("image/jpeg",0.7));else J(Error("Could not get canvas context"))},G.onerror=()=>J(Error("Could not load image")),G.src=Q.target?.result},X.onerror=()=>J(Error("Could not read file")),X.readAsDataURL($)})}function LU($){return new Promise((Z,Y)=>{if(!$.type.startsWith("video/")){Y(Error("File is not a video"));return}let J=document.createElement("video"),X=document.createElement("canvas");J.preload="metadata",J.muted=!0,J.playsInline=!0,J.onloadeddata=()=>{J.currentTime=0.1},J.onseeked=()=>{X.width=J.videoWidth,X.height=J.videoHeight;let Q=X.getContext("2d");if(Q)Q.drawImage(J,0,0),Z(X.toDataURL("image/jpeg",0.7));else Y(Error("Could not get canvas context"));URL.revokeObjectURL(J.src)},J.onerror=()=>{URL.revokeObjectURL(J.src),Y(Error("Could not load video"))},J.src=URL.createObjectURL($)})}function L3(){return`
17723
+ `.trim()}var Vf;var jU=D(()=>{Vf={duration:300,easing:"ease-out",removePlaceholder:!1,loadedClass:"stx-img-loaded",loadingClass:"stx-img-loading"}});function XX($,Z={}){if(Z.maxSize&&$.size>Z.maxSize)return{valid:!1,error:`File size (${mA($.size)}) exceeds maximum (${mA(Z.maxSize)})`,code:"FILE_TOO_LARGE"};if(Z.accept&&Z.accept.length>0){if(!Z.accept.some((J)=>{if(J.endsWith("/*")){let X=J.slice(0,-1);return $.type.startsWith(X)}return $.type===J}))return{valid:!1,error:`File type "${$.type}" is not allowed`,code:"INVALID_TYPE"}}return{valid:!0}}function mA($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}async function QX($,Z,Y){let J={...wf,...Z},X=XX($,J);if(!X.valid)return{success:!1,error:X.error,name:$.name,size:$.size,type:$.type};if(J.chunkSize&&$.size>J.chunkSize)return Rf($,J,Y);return Nf($,J,Y)}async function Nf($,Z,Y){return new Promise((J)=>{let X=new XMLHttpRequest,Q=Date.now(),G=0,K=Q;X.upload.addEventListener("progress",(U)=>{if(U.lengthComputable&&Y){let z=Date.now(),_=(z-K)/1000,q=U.loaded-G,B=_>0?q/_:0,j=U.total-U.loaded,H=B>0?j/B*1000:void 0;G=U.loaded,K=z,Y({file:$,loaded:U.loaded,total:U.total,percent:Math.round(U.loaded/U.total*100),speed:B,timeRemaining:H})}}),X.addEventListener("load",()=>{if(X.status>=200&&X.status<300)try{let U=JSON.parse(X.responseText);J({success:!0,url:U.url,id:U.id,name:$.name,size:$.size,type:$.type,data:U})}catch{J({success:!0,name:$.name,size:$.size,type:$.type})}else J({success:!1,error:`Upload failed with status ${X.status}`,name:$.name,size:$.size,type:$.type})}),X.addEventListener("error",()=>{J({success:!1,error:"Network error during upload",name:$.name,size:$.size,type:$.type})}),X.addEventListener("timeout",()=>{J({success:!1,error:"Upload timed out",name:$.name,size:$.size,type:$.type})});let W=new FormData;if(W.append(Z.fieldName||"file",$),Z.formData)for(let[U,z]of Object.entries(Z.formData))W.append(U,z);if(X.open(Z.method||"POST",Z.endpoint),X.timeout=Z.timeout||60000,X.withCredentials=Z.withCredentials||!1,Z.headers)for(let[U,z]of Object.entries(Z.headers))X.setRequestHeader(U,z);X.send(W)})}async function Rf($,Z,Y){let J=Z.chunkSize,X=Math.ceil($.size/J),Q=0,G;for(let K=0;K<X;K++){let W=K*J,U=Math.min(W+J,$.size),z=$.slice(W,U),_=new FormData;if(_.append(Z.fieldName||"file",z,$.name),_.append("chunk",String(K)),_.append("totalChunks",String(X)),_.append("fileName",$.name),_.append("fileSize",String($.size)),_.append("fileType",$.type),G)_.append("uploadId",G);if(Z.formData)for(let[q,B]of Object.entries(Z.formData))_.append(q,B);try{let q=await fetch(Z.endpoint,{method:Z.method||"POST",headers:Z.headers,credentials:Z.withCredentials?"include":"same-origin",body:_});if(!q.ok)return{success:!1,error:`Chunk ${K+1}/${X} failed with status ${q.status}`,name:$.name,size:$.size,type:$.type};let B=await q.json();if(!G&&B.uploadId)G=B.uploadId;if(Q=U,Y)Y({file:$,loaded:Q,total:$.size,percent:Math.round(Q/$.size*100),chunk:K+1,totalChunks:X});if(K===X-1)return{success:!0,url:B.url,id:B.id||G,name:$.name,size:$.size,type:$.type,data:B}}catch(q){return{success:!1,error:`Chunk upload failed: ${q}`,name:$.name,size:$.size,type:$.type}}}return{success:!1,error:"Unknown error during chunked upload",name:$.name,size:$.size,type:$.type}}async function HU($,Z,Y,J){let X=[];for(let Q of $){let G=await QX(Q,Z,(K)=>{if(Y)Y(Q,K)});if(X.push(G),J)J(Q,G)}return X}function OU($,Z=200){return new Promise((Y,J)=>{if(!$.type.startsWith("image/")){J(Error("File is not an image"));return}let X=new FileReader;X.onload=(Q)=>{let G=new Image;G.onload=()=>{let K=document.createElement("canvas"),W=G.width,U=G.height;if(W>Z||U>Z)if(W>U)U=Math.round(U*Z/W),W=Z;else W=Math.round(W*Z/U),U=Z;K.width=W,K.height=U;let z=K.getContext("2d");if(z)z.drawImage(G,0,0,W,U),Y(K.toDataURL("image/jpeg",0.7));else J(Error("Could not get canvas context"))},G.onerror=()=>J(Error("Could not load image")),G.src=Q.target?.result},X.onerror=()=>J(Error("Could not read file")),X.readAsDataURL($)})}function LU($){return new Promise((Z,Y)=>{if(!$.type.startsWith("video/")){Y(Error("File is not a video"));return}let J=document.createElement("video"),X=document.createElement("canvas");J.preload="metadata",J.muted=!0,J.playsInline=!0,J.onloadeddata=()=>{J.currentTime=0.1},J.onseeked=()=>{X.width=J.videoWidth,X.height=J.videoHeight;let Q=X.getContext("2d");if(Q)Q.drawImage(J,0,0),Z(X.toDataURL("image/jpeg",0.7));else Y(Error("Could not get canvas context"));URL.revokeObjectURL(J.src)},J.onerror=()=>{URL.revokeObjectURL(J.src),Y(Error("Could not load video"))},J.src=URL.createObjectURL($)})}function L3(){return`
17724
17724
  (function() {
17725
17725
  'use strict';
17726
17726
 
@@ -17788,18 +17788,18 @@ else {
17788
17788
  return { valid: true };
17789
17789
  };
17790
17790
  })();
17791
- `.trim()}var Af;var VU=D(()=>{Af={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1}});function FU(){return{script:[B3(),H3(),L3()].join(`
17791
+ `.trim()}var wf;var VU=D(()=>{wf={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1}});function FU(){return{script:[B3(),H3(),L3()].join(`
17792
17792
 
17793
- `),css:O3()}}function lA(){let{script:$,css:Z}=FU(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),J=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:J}}var cA=D(()=>{WU();jU();VU();WU();jU();VU()});var pA=D(()=>{L6();sY()});var Rf;var iA=D(()=>{kA();AG();hG();gG();CA();yA();cA();pA();Rf={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}}});import GX from"fs";import L$ from"path";async function AU($,Z={},Y={}){let J=await Bun.file($).text(),X=J.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),Q=X?X[1]:"",G=X?J.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):J;G=G.replace(/<script\s+client\s*>/gi,"<script>");let K={__filename:$,__dirname:L$.dirname($),props:Z,...Z};if(Q)await k0(Q,K,$);let W={...R1,...Y};return await B0(G,K,$,W,new Set)}async function nA($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:J,outputDir:X,componentsDir:Q=L$.join(J,"components"),layoutsDir:G=L$.join(J,"layouts"),partialsDir:K=L$.join(J,"partials"),globalProps:W={},placeholders:U={},views:z,debug:_=!1,generateManifest:q=!0}=$;if(_)console.log("Building STX views..."),console.log(` Source: ${J}`),console.log(` Output: ${X}`);GX.mkdirSync(X,{recursive:!0});let B={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:_},j;if(z&&z.length>0)j=z;else j=GX.readdirSync(J).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=L$.join(J,H.input),V=H.output||H.input.replace(/\.stx$/,".html"),L=L$.join(X,V);if(_)console.log(` Building ${H.input}...`);try{let F={...W,...H.props,...U},A=await AU(O,F,B);await Bun.write(L,A),Y.views.push(V)}catch(F){let A=F instanceof Error?F.message:String(F);if(Y.errors.push({file:H.input,error:A}),Y.success=!1,_)console.error(` Error: ${A}`)}}if(q){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(L$.join(X,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,_)if(Y.success)console.log(`
17793
+ `),css:O3()}}function lA(){let{script:$,css:Z}=FU(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),J=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:J}}var cA=D(()=>{WU();jU();VU();WU();jU();VU()});var pA=D(()=>{L6();sY()});var Mf;var iA=D(()=>{kA();AG();hG();gG();CA();yA();cA();pA();Mf={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}}});import GX from"fs";import L$ from"path";async function AU($,Z={},Y={}){let J=await Bun.file($).text(),X=J.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),Q=X?X[1]:"",G=X?J.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):J;G=G.replace(/<script\s+client\s*>/gi,"<script>");let K={__filename:$,__dirname:L$.dirname($),props:Z,...Z};if(Q)await k0(Q,K,$);let W={...R1,...Y};return await B0(G,K,$,W,new Set)}async function nA($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:J,outputDir:X,componentsDir:Q=L$.join(J,"components"),layoutsDir:G=L$.join(J,"layouts"),partialsDir:K=L$.join(J,"partials"),globalProps:W={},placeholders:U={},views:z,debug:_=!1,generateManifest:q=!0}=$;if(_)console.log("Building STX views..."),console.log(` Source: ${J}`),console.log(` Output: ${X}`);GX.mkdirSync(X,{recursive:!0});let B={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:_},j;if(z&&z.length>0)j=z;else j=GX.readdirSync(J).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=L$.join(J,H.input),V=H.output||H.input.replace(/\.stx$/,".html"),L=L$.join(X,V);if(_)console.log(` Building ${H.input}...`);try{let F={...W,...H.props,...U},A=await AU(O,F,B);await Bun.write(L,A),Y.views.push(V)}catch(F){let A=F instanceof Error?F.message:String(F);if(Y.errors.push({file:H.input,error:A}),Y.success=!1,_)console.error(` Error: ${A}`)}}if(q){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(L$.join(X,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,_)if(Y.success)console.log(`
17794
17794
  \u2705 Built ${Y.views.length} views in ${Y.duration.toFixed(0)}ms`);else console.log(`
17795
- \u26A0\uFE0F Built ${Y.views.length} views with ${Y.errors.length} errors`);return Y}function Mf($,Z){let Y=GX.watch($.viewsDir,{recursive:!0},async(J,X)=>{if(!X)return;if(X.endsWith(".stx")||X.endsWith(".ts")||X.endsWith(".js")){if($.debug)console.log(`
17796
- File changed: ${X}, rebuilding...`);let Q=await nA($);Z?.(Q)}});return{close:()=>Y.close()}}async function Tf($,Z={},Y={}){let J={...Y,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},X=await AU($,Z,J);X=await Ef(X),X=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),X=X.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),X=X.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),X=X.replace(/\n\s*\n\s*\n/g,`
17795
+ \u26A0\uFE0F Built ${Y.views.length} views with ${Y.errors.length} errors`);return Y}function Tf($,Z){let Y=GX.watch($.viewsDir,{recursive:!0},async(J,X)=>{if(!X)return;if(X.endsWith(".stx")||X.endsWith(".ts")||X.endsWith(".js")){if($.debug)console.log(`
17796
+ File changed: ${X}, rebuilding...`);let Q=await nA($);Z?.(Q)}});return{close:()=>Y.close()}}async function Ef($,Z={},Y={}){let J={...Y,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},X=await AU($,Z,J);X=await If(X),X=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),X=X.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),X=X.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),X=X.replace(/\n\s*\n\s*\n/g,`
17797
17797
 
17798
- `).trim();let Q=Df(X);return{html:X,text:Q}}async function Ef($){try{let{generateCrosswindCSS:Z,extractClassNames:Y}=await Promise.resolve().then(() => (_4(),FZ));if(Y($).size===0)return $;let X=await Z($);if(!X)return $;let Q=If(X);if(Q.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,K,W,U,z,_)=>{let q=U.split(/\s+/).filter(Boolean),B=[];for(let V of q){let L=Q.get(V);if(L)B.push(L)}if(B.length===0)return`${K}${W}class="${U}"${z}${_}`;let j=B.join("; "),O=`${W}${z}`.match(/style\s*=\s*"([^"]*)"/);if(O){let V=`${j}; ${O[1]}`,L=W.replace(/style\s*=\s*"[^"]*"/,`style="${V}"`),F=z.replace(/style\s*=\s*"[^"]*"/,`style="${V}"`);return`${K}${L}class="${U}"${F}${_}`}return`${K}${W}class="${U}" style="${j}"${z}${_}`})}catch{return $}}function If($){let Z=new Map,Y=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,J=Y.exec($);while(J!==null){let X=J[1].replace(/\\/g,""),Q=J[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(Q)Z.set(X,Q);J=Y.exec($)}return Z}function Df($){return $.replace(/<br\s*\/?>/gi,`
17798
+ `).trim();let Q=kf(X);return{html:X,text:Q}}async function If($){try{let{generateCrosswindCSS:Z,extractClassNames:Y}=await Promise.resolve().then(() => (_4(),FZ));if(Y($).size===0)return $;let X=await Z($);if(!X)return $;let Q=Df(X);if(Q.size===0)return $;return $.replace(/(<[a-z][a-z0-9]*)((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s+)class\s*=\s*"([^"]*)"((?:\s+[a-z][a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?>)/gi,(G,K,W,U,z,_)=>{let q=U.split(/\s+/).filter(Boolean),B=[];for(let V of q){let L=Q.get(V);if(L)B.push(L)}if(B.length===0)return`${K}${W}class="${U}"${z}${_}`;let j=B.join("; "),O=`${W}${z}`.match(/style\s*=\s*"([^"]*)"/);if(O){let V=`${j}; ${O[1]}`,L=W.replace(/style\s*=\s*"[^"]*"/,`style="${V}"`),F=z.replace(/style\s*=\s*"[^"]*"/,`style="${V}"`);return`${K}${L}class="${U}"${F}${_}`}return`${K}${W}class="${U}" style="${j}"${z}${_}`})}catch{return $}}function Df($){let Z=new Map,Y=/\.([a-zA-Z0-9_-]+(?:\\:[a-zA-Z0-9_-]+)*)\s*\{([^}]+)\}/g,J=Y.exec($);while(J!==null){let X=J[1].replace(/\\/g,""),Q=J[2].split(";").map((G)=>G.trim()).filter(Boolean).join("; ");if(Q)Z.set(X,Q);J=Y.exec($)}return Z}function kf($){return $.replace(/<br\s*\/?>/gi,`
17799
17799
  `).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
17800
17800
  `).replace(/<\/td>/gi,"\t").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&copy;/g,"(c)").replace(/&middot;/g,"-").replace(/\n\s*\n\s*\n/g,`
17801
17801
 
17802
- `).trim()}var rA=D(()=>{z6();a0();q1()});function kf($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Sf($){let Z={};for(let Y of Object.keys($))if(!Y.startsWith("__"))Z[Y]=$[Y];return Z}function Cf($){let{template:Z,context:Y={},title:J="stx App"}=$,X=Sf(Y),Q=kf(JSON.stringify(X));return`<!DOCTYPE html>
17802
+ `).trim()}var rA=D(()=>{z6();a0();q1()});function Sf($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Cf($){let Z={};for(let Y of Object.keys($))if(!Y.startsWith("__"))Z[Y]=$[Y];return Z}function bf($){let{template:Z,context:Y={},title:J="stx App"}=$,X=Cf(Y),Q=Sf(JSON.stringify(X));return`<!DOCTYPE html>
17803
17803
  <html lang="en">
17804
17804
  <head>
17805
17805
  <meta charset="UTF-8">
@@ -17884,7 +17884,7 @@ File changed: ${X}, rebuilding...`);let Q=await nA($);Z?.(Q)}});return{close:()=
17884
17884
  return refs;
17885
17885
  };
17886
17886
  })();
17887
- `}var J4=null,KX;var wU=D(()=>{KX=new Map});function Pf($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function NU($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function zw($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[Kw($)];return $.flat(1/0).map(Kw).filter((Z)=>Z!=="")}function Kw($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function A$($,Z,Y){let{children:J,ref:X,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:zw(J),key:Y??Q??void 0,ref:X??void 0}}function Bw($){return Object.entries($).filter(([,Z])=>Z!=null&&Z!==!1).map(([Z,Y])=>{let J=Z.replace(/[A-Z]/g,(Q)=>`-${Q.toLowerCase()}`),X=typeof Y==="number"&&!J.startsWith("--")&&J!=="opacity"&&J!=="z-index"&&J!=="flex-grow"&&J!=="flex-shrink"&&J!=="order"&&J!=="font-weight"&&J!=="line-height"?`${Y}px`:String(Y);return`${J}: ${X}`}).join("; ")}function RU($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(RU).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function yf($){if(!$)return"";let Z=[];for(let[Y,J]of Object.entries($)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;if(Y.startsWith("on")&&typeof J==="function")continue;let X=Uw[Y]||Y;if(X==="class"||X==="className"){let Q=RU(J);if(Q)Z.push(` class="${NU(Q)}"`);continue}if(X==="style"){let Q=typeof J==="string"?J:Bw(J);if(Q)Z.push(` style="${NU(Q)}"`);continue}if(Ww.has(X)){if(J)Z.push(` ${X}`);continue}if(J!=null&&J!==!1)Z.push(` ${X}="${NU(String(J))}"`)}return Z.join("")}function V$($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return Pf($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(V$).join("");if($.type===F$)return $.children.map(V$).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return V$(Q)}let Z=$.type,Y=yf($.props),J=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(J!=null)return`<${Z}${Y}>${J}</${Z}>`;if(bf.has(Z))return`<${Z}${Y}>`;let X=$.children.map(V$).join("");return`<${Z}${Y}>${X}</${Z}>`}function jw($){return new ReadableStream({start(Z){Z.enqueue(V$($)),Z.close()}})}function xf($,Z){if(!Z)return;for(let[Y,J]of Object.entries(Z)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;let X=Uw[Y]||Y;if(Y.startsWith("on")&&typeof J==="function"){let Q=Y.slice(2).toLowerCase();$.addEventListener(Q,J);continue}if(X==="class"||X==="className"){let Q=RU(J);if(Q)$.setAttribute("class",Q);continue}if(X==="style"){let Q=typeof J==="string"?J:Bw(J);if(Q)$.setAttribute("style",Q);continue}if(Ww.has(X)){if(J)$.setAttribute(X,"");continue}if(J!=null&&J!==!1)$.setAttribute(X,String(J))}}function o5($,Z){if($==null||typeof $==="boolean")return;if(typeof $==="string"){Z.appendChild(document.createTextNode($));return}if(typeof $==="number"){Z.appendChild(document.createTextNode(String($)));return}if(Array.isArray($)){for(let X of $)o5(X,Z);return}if($.type===F$){for(let X of $.children)o5(X,Z);return}if(typeof $.type==="function"){let X=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});o5(X,Z);return}let Y=document.createElement($.type);xf(Y,$.props);let J=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(J!=null)Y.innerHTML=J;else for(let X of $.children)o5(X,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function Hw($){if($.when)return A$(F$,{children:$.children});return $.fallback??null}function Ow($){let Z=$.each;if(!Z||Z.length===0)return $.fallback??null;let Y=Array.isArray($.children)?$.children[0]:$.children,J=Z.map((X,Q)=>Y(X,Q));return A$(F$,{children:J})}function Lw($){return A$(F$,{children:$.children})}function Vw($,Z,...Y){let{key:J,ref:X,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:zw(Y.length===1?Y[0]:Y),key:J??void 0,ref:X??void 0}}var F$,bf,Ww,Uw,_w,qw;var Fw=D(()=>{F$=Symbol.for("stx.Fragment"),bf=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ww=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),Uw={className:"class",htmlFor:"for",tabIndex:"tabindex",autoFocus:"autofocus",autoPlay:"autoplay",crossOrigin:"crossorigin",dateTime:"datetime",encType:"enctype",formAction:"formaction",formEncType:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",frameBorder:"frameborder",hrefLang:"hreflang",httpEquiv:"http-equiv",inputMode:"inputmode",maxLength:"maxlength",mediaGroup:"mediagroup",minLength:"minlength",noModule:"nomodule",noValidate:"novalidate",playsInline:"playsinline",readOnly:"readonly",rowSpan:"rowspan",colSpan:"colspan",srcDoc:"srcdoc",srcLang:"srclang",srcSet:"srcset",useMap:"usemap"};_w=A$,qw=A$});function MU($,Z){let Y=new Set,J=new Map,X=new Map,Q={globalProperties:{},performance:!1,compilerOptions:{}},G={config:Q,_components:J,_directives:X,_installedPlugins:Y,use(K,...W){if(Y.has(K))return G;if(Y.add(K),typeof K==="function")K(G,...W);else if(typeof K.install==="function")K.install(G,...W);return G},provide(K,W){return WX(K,W),G},component(K,W){if(!W)return J.get(K);return J.set(K,W),G},directive(K,W){if(!W)return X.get(K);return X.set(K,W),G},mount(K){if(typeof document<"u"){let W=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(W,Q.globalProperties),document.querySelectorAll("[v-cloak]").forEach((U)=>{U.removeAttribute("v-cloak")})}return G},unmount(){J.clear(),X.clear(),Y.clear()}};return G}function Aw($){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=$}connectedCallback(){if(this._component?.render){let Z=this._component.render();if(typeof Z==="string")this._shadow.innerHTML=Z}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}var ww=D(()=>{wU()});function UX($){return $.endsWith(".md")||$.endsWith(".markdown")}function TU($){let Z=[];J(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let Y=[...Z];J(/<code\b[^>]*>[\s\S]*?<\/code>/gi,Y);function J(G,K){let W;while((W=G.exec($))!==null){let U=W.index,z=U+W[0].length;if(K?.some((_)=>U>=_.start&&z<=_.end))continue;Z.push({start:U,end:z})}}if(Z.length===0)return $;Z.sort((G,K)=>G.start-K.start);let X="",Q=0;for(let G of Z){if(G.start<Q)continue;X+=$.slice(Q,G.start),X+=`@raw${$.slice(G.start,G.end)}@endraw`,Q=G.end}return X+=$.slice(Q),X}async function zX($,Z={}){let{data:Y,content:J}=GZ($),Q=await(Z.renderer??((G)=>v6(G)))(J);return{html:TU(Q),frontmatter:Y??{}}}var EU=()=>{};import{dirname as vf,resolve as Nw}from"path";function ff($){let Z=$,Y=B4($);if(Y)Z=Y.content.trim();let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,X=[],Q=[],G=[],K=(z)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(z),W;while((W=J.exec($))!==null){let z=W[1],_=W[2],q=W[0],B=z.includes("server");if(K(_))G.push(q);else if(B)Q.push(_);else X.push(q)}let U=Z;{let z=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,_,q=[];while((_=z.exec(U))!==null){let B=_.index+_[0].length,j=1,H=B;while(H<U.length&&j>0){let O=U.indexOf("<script",H),V=U.indexOf("</script>",H);if(V===-1)break;if(O!==-1&&O<V)j++,H=O+7;else{if(j--,j===0){q.push({start:_.index,end:V+9});break}H=V+9}}}for(let B=q.length-1;B>=0;B--)U=U.substring(0,q[B].start)+U.substring(q[B].end)}for(let z of X)U=U.replace(z,"");return{templateContent:U,serverScripts:Q,clientScripts:X,signalsScripts:G}}function gf($,Z){return`<!DOCTYPE html>
17887
+ `}var J4=null,KX;var wU=D(()=>{KX=new Map});function yf($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function NU($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function zw($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[Kw($)];return $.flat(1/0).map(Kw).filter((Z)=>Z!=="")}function Kw($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function A$($,Z,Y){let{children:J,ref:X,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:zw(J),key:Y??Q??void 0,ref:X??void 0}}function Bw($){return Object.entries($).filter(([,Z])=>Z!=null&&Z!==!1).map(([Z,Y])=>{let J=Z.replace(/[A-Z]/g,(Q)=>`-${Q.toLowerCase()}`),X=typeof Y==="number"&&!J.startsWith("--")&&J!=="opacity"&&J!=="z-index"&&J!=="flex-grow"&&J!=="flex-shrink"&&J!=="order"&&J!=="font-weight"&&J!=="line-height"?`${Y}px`:String(Y);return`${J}: ${X}`}).join("; ")}function RU($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(RU).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function xf($){if(!$)return"";let Z=[];for(let[Y,J]of Object.entries($)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;if(Y.startsWith("on")&&typeof J==="function")continue;let X=Uw[Y]||Y;if(X==="class"||X==="className"){let Q=RU(J);if(Q)Z.push(` class="${NU(Q)}"`);continue}if(X==="style"){let Q=typeof J==="string"?J:Bw(J);if(Q)Z.push(` style="${NU(Q)}"`);continue}if(Ww.has(X)){if(J)Z.push(` ${X}`);continue}if(J!=null&&J!==!1)Z.push(` ${X}="${NU(String(J))}"`)}return Z.join("")}function V$($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return yf($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(V$).join("");if($.type===F$)return $.children.map(V$).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return V$(Q)}let Z=$.type,Y=xf($.props),J=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(J!=null)return`<${Z}${Y}>${J}</${Z}>`;if(Pf.has(Z))return`<${Z}${Y}>`;let X=$.children.map(V$).join("");return`<${Z}${Y}>${X}</${Z}>`}function jw($){return new ReadableStream({start(Z){Z.enqueue(V$($)),Z.close()}})}function vf($,Z){if(!Z)return;for(let[Y,J]of Object.entries(Z)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;let X=Uw[Y]||Y;if(Y.startsWith("on")&&typeof J==="function"){let Q=Y.slice(2).toLowerCase();$.addEventListener(Q,J);continue}if(X==="class"||X==="className"){let Q=RU(J);if(Q)$.setAttribute("class",Q);continue}if(X==="style"){let Q=typeof J==="string"?J:Bw(J);if(Q)$.setAttribute("style",Q);continue}if(Ww.has(X)){if(J)$.setAttribute(X,"");continue}if(J!=null&&J!==!1)$.setAttribute(X,String(J))}}function o5($,Z){if($==null||typeof $==="boolean")return;if(typeof $==="string"){Z.appendChild(document.createTextNode($));return}if(typeof $==="number"){Z.appendChild(document.createTextNode(String($)));return}if(Array.isArray($)){for(let X of $)o5(X,Z);return}if($.type===F$){for(let X of $.children)o5(X,Z);return}if(typeof $.type==="function"){let X=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});o5(X,Z);return}let Y=document.createElement($.type);vf(Y,$.props);let J=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(J!=null)Y.innerHTML=J;else for(let X of $.children)o5(X,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function Hw($){if($.when)return A$(F$,{children:$.children});return $.fallback??null}function Ow($){let Z=$.each;if(!Z||Z.length===0)return $.fallback??null;let Y=Array.isArray($.children)?$.children[0]:$.children,J=Z.map((X,Q)=>Y(X,Q));return A$(F$,{children:J})}function Lw($){return A$(F$,{children:$.children})}function Vw($,Z,...Y){let{key:J,ref:X,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:zw(Y.length===1?Y[0]:Y),key:J??void 0,ref:X??void 0}}var F$,Pf,Ww,Uw,_w,qw;var Fw=D(()=>{F$=Symbol.for("stx.Fragment"),Pf=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),Ww=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),Uw={className:"class",htmlFor:"for",tabIndex:"tabindex",autoFocus:"autofocus",autoPlay:"autoplay",crossOrigin:"crossorigin",dateTime:"datetime",encType:"enctype",formAction:"formaction",formEncType:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",frameBorder:"frameborder",hrefLang:"hreflang",httpEquiv:"http-equiv",inputMode:"inputmode",maxLength:"maxlength",mediaGroup:"mediagroup",minLength:"minlength",noModule:"nomodule",noValidate:"novalidate",playsInline:"playsinline",readOnly:"readonly",rowSpan:"rowspan",colSpan:"colspan",srcDoc:"srcdoc",srcLang:"srclang",srcSet:"srcset",useMap:"usemap"};_w=A$,qw=A$});function MU($,Z){let Y=new Set,J=new Map,X=new Map,Q={globalProperties:{},performance:!1,compilerOptions:{}},G={config:Q,_components:J,_directives:X,_installedPlugins:Y,use(K,...W){if(Y.has(K))return G;if(Y.add(K),typeof K==="function")K(G,...W);else if(typeof K.install==="function")K.install(G,...W);return G},provide(K,W){return WX(K,W),G},component(K,W){if(!W)return J.get(K);return J.set(K,W),G},directive(K,W){if(!W)return X.get(K);return X.set(K,W),G},mount(K){if(typeof document<"u"){let W=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(W,Q.globalProperties),document.querySelectorAll("[v-cloak]").forEach((U)=>{U.removeAttribute("v-cloak")})}return G},unmount(){J.clear(),X.clear(),Y.clear()}};return G}function Aw($){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=$}connectedCallback(){if(this._component?.render){let Z=this._component.render();if(typeof Z==="string")this._shadow.innerHTML=Z}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}var ww=D(()=>{wU()});function UX($){return $.endsWith(".md")||$.endsWith(".markdown")}function TU($){let Z=[];J(/<pre\b[^>]*>[\s\S]*?<\/pre>/gi);let Y=[...Z];J(/<code\b[^>]*>[\s\S]*?<\/code>/gi,Y);function J(G,K){let W;while((W=G.exec($))!==null){let U=W.index,z=U+W[0].length;if(K?.some((_)=>U>=_.start&&z<=_.end))continue;Z.push({start:U,end:z})}}if(Z.length===0)return $;Z.sort((G,K)=>G.start-K.start);let X="",Q=0;for(let G of Z){if(G.start<Q)continue;X+=$.slice(Q,G.start),X+=`@raw${$.slice(G.start,G.end)}@endraw`,Q=G.end}return X+=$.slice(Q),X}async function zX($,Z={}){let{data:Y,content:J}=GZ($),Q=await(Z.renderer??((G)=>v6(G)))(J);return{html:TU(Q),frontmatter:Y??{}}}var EU=()=>{};import{dirname as ff,resolve as Nw}from"path";function gf($){let Z=$,Y=B4($);if(Y)Z=Y.content.trim();let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,X=[],Q=[],G=[],K=(z)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(z),W;while((W=J.exec($))!==null){let z=W[1],_=W[2],q=W[0],B=z.includes("server");if(K(_))G.push(q);else if(B)Q.push(_);else X.push(q)}let U=Z;{let z=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,_,q=[];while((_=z.exec(U))!==null){let B=_.index+_[0].length,j=1,H=B;while(H<U.length&&j>0){let O=U.indexOf("<script",H),V=U.indexOf("</script>",H);if(V===-1)break;if(O!==-1&&O<V)j++,H=O+7;else{if(j--,j===0){q.push({start:_.index,end:V+9});break}H=V+9}}}for(let B=q.length-1;B>=0;B--)U=U.substring(0,q[B].start)+U.substring(q[B].end)}for(let z of X)U=U.replace(z,"");return{templateContent:U,serverScripts:Q,clientScripts:X,signalsScripts:G}}function hf($,Z){return`<!DOCTYPE html>
17888
17888
  <html lang="en">
17889
17889
  <head>
17890
17890
  <meta charset="UTF-8">
@@ -17894,43 +17894,43 @@ File changed: ${X}, rebuilding...`);let Q=await nA($);Z?.(Q)}});return{close:()=
17894
17894
  <body>
17895
17895
  ${$}
17896
17896
  </body>
17897
- </html>`}async function IU($,Z={}){let Y=Nw($),J=Bun.file(Y);if(!await J.exists())throw Error(`Template file not found: ${Y}`);let X=await J.text(),Q=null;if(UX(Y)){let G=await zX(X,{renderer:Z.markdownRenderer});X=G.html,Q=G.frontmatter}if(Q)Z={...Z,context:{...Q,...Z.context||{}}};if(Z.layout){let G=Nw(Z.layout),K=Bun.file(G);if(!await K.exists())throw Error(`Layout template not found: ${G}`);let{layout:W,injectCSS:U,...z}=Z,_=await V3(X,Y,{...z,injectCSS:!1}),q=await K.text(),B={...Z.context||{},content:_},j={...z,context:B,injectCSS:U};return V3(q,G,j)}return V3(X,Y,Z)}async function hf($,Z={},Y){return V3($,process.cwd(),{context:Z,...Y})}async function V3($,Z,Y={}){let{templateContent:J,serverScripts:X,clientScripts:Q}=ff($),G={...R1,...Y.options},K={__filename:Z,__dirname:vf(Z),__stx:{},__stx_options:G,__stx_sfc_mode:!0,__stx_inject_css:Y.injectCSS!==!1,...Y.context||{}};for(let z of X)await k0(z,K,Z);let W=new Set,U=J;if(U=await B0(U,K,Z,G,W),Y.templateOnly){if(U=U.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),U=U.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),Q.length>0)U+=`
17897
+ </html>`}async function IU($,Z={}){let Y=Nw($),J=Bun.file(Y);if(!await J.exists())throw Error(`Template file not found: ${Y}`);let X=await J.text(),Q=null;if(UX(Y)){let G=await zX(X,{renderer:Z.markdownRenderer});X=G.html,Q=G.frontmatter}if(Q)Z={...Z,context:{...Q,...Z.context||{}}};if(Z.layout){let G=Nw(Z.layout),K=Bun.file(G);if(!await K.exists())throw Error(`Layout template not found: ${G}`);let{layout:W,injectCSS:U,...z}=Z,_=await V3(X,Y,{...z,injectCSS:!1}),q=await K.text(),B={...Z.context||{},content:_},j={...z,context:B,injectCSS:U};return V3(q,G,j)}return V3(X,Y,Z)}async function df($,Z={},Y){return V3($,process.cwd(),{context:Z,...Y})}async function V3($,Z,Y={}){let{templateContent:J,serverScripts:X,clientScripts:Q}=gf($),G={...R1,...Y.options},K={__filename:Z,__dirname:ff(Z),__stx:{},__stx_options:G,__stx_sfc_mode:!0,__stx_inject_css:Y.injectCSS!==!1,...Y.context||{}};for(let z of X)await k0(z,K,Z);let W=new Set,U=J;if(U=await B0(U,K,Z,G,W),Y.templateOnly){if(U=U.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),U=U.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),Q.length>0)U+=`
17898
17898
  ${Q.join(`
17899
17899
  `)}`}else{if(Y.processClientScripts!==!1&&Q.length>0){let z=K.__stx_event_bindings||[],_=r4(K),B=(await Promise.all(Q.map(async(H)=>{let O=H.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!O)return H;return await a4(O[1],{eventBindings:z,templateContent:U,serverData:_,filePath:Z})}))).join(`
17900
17900
  `);if(U.match(/(<\/body>)/i))U=U.replace(/(<\/body>)/i,`${B}
17901
17901
  $1`);else U+=`
17902
- ${B}`}U=await S4(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=gf(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:z}=await Promise.resolve().then(() => (_4(),FZ));U=await z(U)}catch{}return U}var DU=D(()=>{a0();z6();q1();u6();d$();EU()});import t5 from"fs";import S6 from"path";function Rw($){try{return t5.statSync($).mtimeMs}catch{return null}}function _X($,Z){let Y=Math.max(0,Math.round((Z-$)/1000));if(Y<60)return`${Y}s ago`;if(Y<3600)return`${Math.round(Y/60)}m ago`;return`${Math.round(Y/3600)}h ago`}function df($,Z){try{return globalThis.Bun?.resolveSync($,Z)??null}catch{return null}}function kU($,Z="stx"){let Y=S6.resolve($);for(let J=0;J<10;J++){let X=S6.join(Y,"pantry","@stacksjs",Z);if(t5.existsSync(X))return X;let Q=S6.dirname(Y);if(Q===Y)break;Y=Q}return null}async function qX($={}){let Z=$.cwd?S6.resolve($.cwd):process.cwd(),Y=$.resolve??df,J=Date.now(),X=[],Q=Y("@stacksjs/stx",Z);X.push(Q?{name:"@stacksjs/stx resolves to",status:"ok",detail:Q}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let G=Y("bun-plugin-stx",Z);if(G)X.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});let K=kU(Z,"stx");if(!K)X.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let W=S6.join(K,"src/signals.ts"),U=[S6.join(K,"dist/index.js"),S6.join(K,"dist/signals.js")].find((j)=>t5.existsSync(j))||null,z=Rw(W),_=U?Rw(U):null;if(z==null)X.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${K} but no src/signals.ts to compare`});else if(_==null)X.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${K} && bun build.ts`});else if(_<z){let j=Math.round((z-_)/1000);X.push({name:"pantry dist freshness",status:"error",detail:`dist (${_X(_,J)}) is OLDER than src/signals.ts (${_X(z,J)}) by ${j}s \u2014 your edit isn't built`,fix:`cd ${K} && bun build.ts`})}else X.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${_X(z,J)}, dist ${_X(_,J)})`});let q=S6.join(Z,"node_modules/@stacksjs/stx"),B=null;try{B=t5.lstatSync(q)}catch{B=null}if(!B)X.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(B.isSymbolicLink()){let j=null;try{j=t5.realpathSync(q)}catch{}let H=(()=>{try{return t5.realpathSync(K)}catch{return K}})();X.push(j===H?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${j||"(dangling)"}, not pantry`})}else X.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(X.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),$.generateRuntime)try{let U=$.generateRuntime().length;X.push(U>1000?{name:"signals runtime",status:"ok",detail:`generated ${U.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${U} chars \u2014 suspiciously short`})}catch(W){X.push({name:"signals runtime",status:"error",detail:`failed to generate: ${W.message}`})}return{checks:X,ok:!X.some((W)=>W.status==="error")}}function BX($){let Z={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},Y=["stx runtime resolution:"];for(let J of $.checks)if(Y.push(` ${Z[J.status]} ${J.name}: ${J.detail}`),J.fix)Y.push(` \u2192 ${J.fix}`);return Y.push(""),Y.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Y.join(`
17903
- `)}var SU=()=>{};function F3($,Z,Y={},J="/"){let X=Z.seo??{},Q=Y.title??X.title??Z.name,G=Y.description??X.description??Z.description??"",K=Y.image??X.image,W=`${Z.url.replace(/\/$/,"")}${J}`,U=X.siteName??Z.name,z=X.type??"website",_=X.locale??"en_US",q=[];if(X.favicon){let F=X.favicon.toLowerCase().split(".").pop(),A=F==="svg"?"image/svg+xml":F==="ico"?"image/x-icon":F==="png"?"image/png":F==="jpg"||F==="jpeg"?"image/jpeg":"";q.push(`<link rel="icon"${A?` type="${A}"`:""} href="${O1(X.favicon)}">`)}if(q.push(`<title>${uf(Q)}</title>`,`<link rel="canonical" href="${O1(W)}">`,`<meta name="description" content="${O1(G)}">`,`<meta property="og:title" content="${O1(Q)}">`,`<meta property="og:description" content="${O1(G)}">`,`<meta property="og:type" content="${O1(z)}">`,`<meta property="og:url" content="${O1(W)}">`,`<meta property="og:site_name" content="${O1(U)}">`,`<meta property="og:locale" content="${O1(_)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${O1(Q)}">`,`<meta name="twitter:description" content="${O1(G)}">`),K)q.push(`<meta property="og:image" content="${O1(K)}">`),q.push(`<meta name="twitter:image" content="${O1(K)}">`);if(X.twitter)q.push(`<meta name="twitter:site" content="@${O1(X.twitter.replace(/^@/,""))}">`),q.push(`<meta name="twitter:creator" content="@${O1(X.twitter.replace(/^@/,""))}">`);let B=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(B.test($))$=$.replace(B,"");$=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"");let j=$.search(/<\/head>/i),H=j===-1?$:$.slice(0,j),O=(F)=>{if(/^<title[\s>]/i.test(F))return/<title[\s>]/i.test(H);if(/rel="canonical"/i.test(F))return/<link[^>]+rel=["']canonical["']/i.test(H);let N=/(?:property|name)="([^"]+)"/i.exec(F)?.[1];if(!N)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${N.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(H)},V=q.filter((F)=>!O(F));if(V.length===0)return $;let L=`<!-- SEO -->
17902
+ ${B}`}U=await S4(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=hf(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:z}=await Promise.resolve().then(() => (_4(),FZ));U=await z(U)}catch{}return U}var DU=D(()=>{a0();z6();q1();u6();d$();EU()});import t5 from"fs";import S6 from"path";function Rw($){try{return t5.statSync($).mtimeMs}catch{return null}}function _X($,Z){let Y=Math.max(0,Math.round((Z-$)/1000));if(Y<60)return`${Y}s ago`;if(Y<3600)return`${Math.round(Y/60)}m ago`;return`${Math.round(Y/3600)}h ago`}function uf($,Z){try{return globalThis.Bun?.resolveSync($,Z)??null}catch{return null}}function kU($,Z="stx"){let Y=S6.resolve($);for(let J=0;J<10;J++){let X=S6.join(Y,"pantry","@stacksjs",Z);if(t5.existsSync(X))return X;let Q=S6.dirname(Y);if(Q===Y)break;Y=Q}return null}async function qX($={}){let Z=$.cwd?S6.resolve($.cwd):process.cwd(),Y=$.resolve??uf,J=Date.now(),X=[],Q=Y("@stacksjs/stx",Z);X.push(Q?{name:"@stacksjs/stx resolves to",status:"ok",detail:Q}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let G=Y("bun-plugin-stx",Z);if(G)X.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});let K=kU(Z,"stx");if(!K)X.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let W=S6.join(K,"src/signals.ts"),U=[S6.join(K,"dist/index.js"),S6.join(K,"dist/signals.js")].find((j)=>t5.existsSync(j))||null,z=Rw(W),_=U?Rw(U):null;if(z==null)X.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${K} but no src/signals.ts to compare`});else if(_==null)X.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${K} && bun build.ts`});else if(_<z){let j=Math.round((z-_)/1000);X.push({name:"pantry dist freshness",status:"error",detail:`dist (${_X(_,J)}) is OLDER than src/signals.ts (${_X(z,J)}) by ${j}s \u2014 your edit isn't built`,fix:`cd ${K} && bun build.ts`})}else X.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${_X(z,J)}, dist ${_X(_,J)})`});let q=S6.join(Z,"node_modules/@stacksjs/stx"),B=null;try{B=t5.lstatSync(q)}catch{B=null}if(!B)X.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(B.isSymbolicLink()){let j=null;try{j=t5.realpathSync(q)}catch{}let H=(()=>{try{return t5.realpathSync(K)}catch{return K}})();X.push(j===H?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${j||"(dangling)"}, not pantry`})}else X.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(X.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),$.generateRuntime)try{let U=$.generateRuntime().length;X.push(U>1000?{name:"signals runtime",status:"ok",detail:`generated ${U.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${U} chars \u2014 suspiciously short`})}catch(W){X.push({name:"signals runtime",status:"error",detail:`failed to generate: ${W.message}`})}return{checks:X,ok:!X.some((W)=>W.status==="error")}}function BX($){let Z={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},Y=["stx runtime resolution:"];for(let J of $.checks)if(Y.push(` ${Z[J.status]} ${J.name}: ${J.detail}`),J.fix)Y.push(` \u2192 ${J.fix}`);return Y.push(""),Y.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Y.join(`
17903
+ `)}var SU=()=>{};function F3($,Z,Y={},J="/"){let X=Z.seo??{},Q=Y.title??X.title??Z.name,G=Y.description??X.description??Z.description??"",K=Y.image??X.image,W=`${Z.url.replace(/\/$/,"")}${J}`,U=X.siteName??Z.name,z=X.type??"website",_=X.locale??"en_US",q=[];if(X.favicon){let F=X.favicon.toLowerCase().split(".").pop(),A=F==="svg"?"image/svg+xml":F==="ico"?"image/x-icon":F==="png"?"image/png":F==="jpg"||F==="jpeg"?"image/jpeg":"";q.push(`<link rel="icon"${A?` type="${A}"`:""} href="${O1(X.favicon)}">`)}if(q.push(`<title>${mf(Q)}</title>`,`<link rel="canonical" href="${O1(W)}">`,`<meta name="description" content="${O1(G)}">`,`<meta property="og:title" content="${O1(Q)}">`,`<meta property="og:description" content="${O1(G)}">`,`<meta property="og:type" content="${O1(z)}">`,`<meta property="og:url" content="${O1(W)}">`,`<meta property="og:site_name" content="${O1(U)}">`,`<meta property="og:locale" content="${O1(_)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${O1(Q)}">`,`<meta name="twitter:description" content="${O1(G)}">`),K)q.push(`<meta property="og:image" content="${O1(K)}">`),q.push(`<meta name="twitter:image" content="${O1(K)}">`);if(X.twitter)q.push(`<meta name="twitter:site" content="@${O1(X.twitter.replace(/^@/,""))}">`),q.push(`<meta name="twitter:creator" content="@${O1(X.twitter.replace(/^@/,""))}">`);let B=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(B.test($))$=$.replace(B,"");$=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"");let j=$.search(/<\/head>/i),H=j===-1?$:$.slice(0,j),O=(F)=>{if(/^<title[\s>]/i.test(F))return/<title[\s>]/i.test(H);if(/rel="canonical"/i.test(F))return/<link[^>]+rel=["']canonical["']/i.test(H);let N=/(?:property|name)="([^"]+)"/i.exec(F)?.[1];if(!N)return!1;return new RegExp(`<meta[^>]+(?:property|name)=["']${N.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}["']`,"i").test(H)},V=q.filter((F)=>!O(F));if(V.length===0)return $;let L=`<!-- SEO -->
17904
17904
  ${V.join(`
17905
17905
  `)}
17906
17906
  <!-- /SEO -->`;if(j!==-1)return`${$.slice(0,j)}${L}
17907
17907
  ${$.slice(j)}`;if(/<head[^>]*>/i.test($))return $.replace(/<head([^>]*)>/i,`<head$1>
17908
17908
  ${L}`);return`${L}
17909
- ${$}`}function O1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function uf($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function A3($,Z){let Y=$.url.replace(/\/$/,""),J=new Date().toISOString().slice(0,10);return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',Z.filter((Q)=>Q.page?.sitemap!==!1).map((Q)=>{let G=`${Y}${Q.path}`,K=Q.page?.priority??(Q.path==="/"?1:0.8),W=Q.page?.changefreq??"monthly";return[" <url>",` <loc>${mf(G)}</loc>`,` <lastmod>${J}</lastmod>`,` <changefreq>${W}</changefreq>`,` <priority>${K.toFixed(1)}</priority>`," </url>"].join(`
17909
+ ${$}`}function O1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function mf($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function A3($,Z){let Y=$.url.replace(/\/$/,""),J=new Date().toISOString().slice(0,10);return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',Z.filter((Q)=>Q.page?.sitemap!==!1).map((Q)=>{let G=`${Y}${Q.path}`,K=Q.page?.priority??(Q.path==="/"?1:0.8),W=Q.page?.changefreq??"monthly";return[" <url>",` <loc>${lf(G)}</loc>`,` <lastmod>${J}</lastmod>`,` <changefreq>${W}</changefreq>`,` <priority>${K.toFixed(1)}</priority>`," </url>"].join(`
17910
17910
  `)}).join(`
17911
17911
  `),"</urlset>",""].join(`
17912
- `)}function mf($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function w3($){let Z=$.robots??"allow";if(Z===!1)return null;if(typeof Z==="string"&&Z!=="allow"&&Z!=="disallow")return Z.endsWith(`
17912
+ `)}function lf($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function w3($){let Z=$.robots??"allow";if(Z===!1)return null;if(typeof Z==="string"&&Z!=="allow"&&Z!=="disallow")return Z.endsWith(`
17913
17913
  `)?Z:`${Z}
17914
17914
  `;let Y=$.sitemap!==!1?`Sitemap: ${$.url.replace(/\/$/,"")}/sitemap.xml
17915
17915
  `:"";if(Z==="disallow")return["User-agent: *","Disallow: /","",Y].filter(Boolean).join(`
17916
17916
  `);return["User-agent: *","Allow: /","",Y].filter(Boolean).join(`
17917
- `)}async function lf(){if(e5!==null)return e5;try{let $=await import("stx-router");if(typeof $.getRouterScript==="function")e5=$.getRouterScript();else e5=""}catch{e5=""}return e5}async function CU($,Z){let Y=await lf();if(!Y)return $;let J={interceptAllLinks:!0,container:"main",...Z},Q=`${`<script>window.__stxRouterConfig=${JSON.stringify(J)};</script>
17917
+ `)}async function cf(){if(e5!==null)return e5;try{let $=await import("stx-router");if(typeof $.getRouterScript==="function")e5=$.getRouterScript();else e5=""}catch{e5=""}return e5}async function CU($,Z){let Y=await cf();if(!Y)return $;let J={interceptAllLinks:!0,container:"main",...Z},Q=`${`<script>window.__stxRouterConfig=${JSON.stringify(J)};</script>
17918
17918
  `}<script>${Y}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${Q}
17919
17919
  </body>`);return`${$}
17920
17920
  ${Q}`}var e5=null;function N3($,Z){if(Z.theme===!1)return $;let Y=typeof Z.theme==="object"&&Z.theme!==null?Z.theme:{},J=Y.default??"dark",X=Y.storageKey??"theme",Q=Y.colors?.light??"#ffffff",G=Y.colors?.dark??"#000000";if(J==="dark"){if(!/<html\b[^>]*\bclass=/.test($))$=$.replace(/<html\b([^>]*)>/i,'<html$1 class="dark">');else if(!/<html\b[^>]*\bclass="[^"]*\bdark\b/.test($))$=$.replace(/<html\b([^>]*\bclass=")([^"]*)(")/i,"<html$1$2 dark$3")}if(!$.includes("data-stx-theme-meta")&&/<head\b[^>]*>/i.test($)){let K=['<meta name="color-scheme" content="dark light" data-stx-theme-meta="1">',`<meta name="theme-color" media="(prefers-color-scheme: light)" content="${Q}" data-stx-theme-meta="1">`,`<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${G}" data-stx-theme-meta="1">`].join(`
17921
17921
  `);$=$.replace(/<head\b([^>]*)>/i,`<head$1>
17922
- ${K}`)}if(!$.includes("__stxThemeGuard")&&/<head\b[^>]*>/i.test($)){let K=`<script data-stx-theme-guard="1">${cf(J,X,Q,G)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
17923
- ${K}`)}if(!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${pf(X,Q,G)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
17924
- </body>`)}return $}var cf=($,Z,Y,J)=>`(function(){window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};function read(){try{var k=${JSON.stringify(Z)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(J)}:${JSON.stringify(Y)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,pf=($,Z,Y)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Y)}:${JSON.stringify(Z)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;import{existsSync as nf,readFileSync as rf}from"fs";import{join as af,resolve as sf}from"path";import of from"process";function R3($,Z=of.cwd()){let Y=$.i18n;if(!Y||!Array.isArray(Y.locales)||Y.locales.length===0)return null;let J=Y.defaultLocale??Y.locales[0],X=tf(Y,Z);return{locales:Y.locales,defaultLocale:J,labels:Y.labels??Object.fromEntries(Y.locales.map((Q)=>[Q,Q.toUpperCase()])),translations:X,pickerSelector:Y.pickerSelector??"#lang-picker"}}function tf($,Z){let Y=$.translations??{},J={},X=$.translationsDir,Q=X===!1?null:sf(Z,typeof X==="string"&&X?X:"translations"),G=$.format??"json";for(let K of $.locales){let W=Q?ef(Q,K,G):{};J[K]={...W,...Y[K]??{}}}return J}function ef($,Z,Y){let J=Y==="json"?[`${Z}.json`]:[`${Z}.${Y}`,`${Z}.${Y==="yaml"?"yml":"yaml"}`];for(let X of J){let Q=af($,X);if(!nf(Q))continue;try{let G=rf(Q,"utf8"),K=Y==="json"?JSON.parse(G):$g(G);return Mw(K)}catch{continue}}return{}}function Mw($,Z="",Y={}){if(!$||typeof $!=="object")return Y;for(let[J,X]of Object.entries($)){let Q=Z?`${Z}.${J}`:J;if(X&&typeof X==="object"&&!Array.isArray(X))Mw(X,Q,Y);else if(typeof X==="string")Y[Q]=X;else if(typeof X==="number"||typeof X==="boolean")Y[Q]=String(X)}return Y}function $g($){let Z={},Y=[{obj:Z,indent:-1}];for(let J of $.split(`
17925
- `)){let X=J.replace(/#.*$/,"").trimEnd();if(!X.trim())continue;let Q=X.search(/\S/);if(Q===-1)continue;while(Y.length>1&&Y[Y.length-1].indent>=Q)Y.pop();let G=Y[Y.length-1].obj,K=X.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!K)continue;let[,,W,U]=K,z=W.trim(),_=U.trim();if(_==="")G[z]={},Y.push({obj:G[z],indent:Q});else G[z]=Zg(_)}return Z}function Zg($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function jX($,Z,Y){let J=$.translations[Z]?.[Y];if(typeof J==="string")return J;let X=$.translations[$.defaultLocale]?.[Y];if(typeof X==="string")return X;return Y}function M3($,Z,Y){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(J,X,Q)=>{let G=jX(Z,Y,Q);return X==="!"?G:Yg(G)})}function l4($,Z,Y){if(Z===Y)return $;if($==="/")return`/${Z}/`;if($==="/404.html")return`/${Z}/404.html`;return`/${Z}${$}`}function PU($,Z){for(let Y of Z){if($===`/${Y}`||$===`/${Y}/`)return{locale:Y,path:"/"};if($.startsWith(`/${Y}/`))return{locale:Y,path:$.slice(Y.length+1)}}return{locale:null,path:$}}function T3($,Z,Y){let J=$.replace(/\/$/,""),X=[];for(let G of Y.locales){let K=`${J}${l4(Z,G,Y.defaultLocale)}`;X.push(`<link rel="alternate" hreflang="${bU(G)}" href="${bU(K)}">`)}let Q=`${J}${l4(Z,Y.defaultLocale,Y.defaultLocale)}`;return X.push(`<link rel="alternate" hreflang="x-default" href="${bU(Q)}">`),X.join(`
17926
- `)}function E3($,Z){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:Z,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function bU($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Yg($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var yU=()=>{};var{Glob:Jg}=globalThis.Bun;import{cpSync as Xg,existsSync as LX,mkdirSync as Tw,readFileSync as Ew,readdirSync as Qg,rmSync as Gg,statSync as Kg,unlinkSync as Wg,writeFileSync as HX}from"fs";import{dirname as Ug,join as c4,relative as zg}from"path";import Iw from"process";import _g from"bun-plugin-stx";async function vU($){let Z=Date.now(),Y=$.pagesDir??"pages",J=$.outDir??"dist",X=$.publicDir??"public";if(!$.noClean)Gg(J,{recursive:!0,force:!0});Tw(J,{recursive:!0});let Q=new Jg(`${Y}/**/*.stx`),G=await Array.fromAsync(Q.scan("."));if(G.length===0)throw Error(`No .stx files found in ${Y}/`);let K=await Bun.build({entrypoints:G,outdir:J,plugins:[_g()],naming:{entry:"[name].[ext]"}});if(!K.success)throw console.error(K.logs),Error("Build failed");jg(J);let W=fU(J).filter((j)=>j.endsWith(".html")),U=R3($,Iw.cwd()),z=new Set(W.map(OX));for(let j of W){let H=c4(J,j),O=Ew(H,"utf8"),V=OX(j),L=U?U.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let F of L){let A=O;if(A=Hg(A),U)A=M3(A,U,F);if(A=await y0(A,Iw.cwd()),A=F3(A,$,$.pages?.[V],V),U)A=Og(A,$,U,F,V),A=Lg(A,F,U.defaultLocale,z);if(A=N3(A,$),A=Vg(A),U)A=A.replace(/<\/body>/i,`${E3(U,F)}
17927
- </body>`);if($.spa!==!1)A=await CU(A,$.router);let w=U?Bg(V,F,U.defaultLocale):j,N=c4(J,w);if(Tw(qg(N),{recursive:!0}),HX(N,A),U&&F!==U.defaultLocale&&w!==j);}}if(LX(X))Xg(X,J,{recursive:!0});let _=c4(J,"404.html");if(!LX(_)&&LX(c4(J,"index.html"))){let j=Ew(c4(J,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${Fg($.name)}</title>`);HX(_,j)}if($.sitemap!==!1){let j=[],H=W.filter((V)=>V!=="404.html").map(OX),O=U?U.locales:[null];for(let V of H){let L=$.pages?.[V];for(let F of O){let A=F&&U?l4(V,F,U.defaultLocale):V;j.push({path:A,page:L})}}HX(c4(J,"sitemap.xml"),A3($,j))}let q=w3($);if(q!==null)HX(c4(J,"robots.txt"),q);let B=W.map(OX);return{outDir:J,pages:B,durationMs:Date.now()-Z}}function qg($){return Ug($)}function Bg($,Z,Y){let J=l4($,Z,Y);if(J==="/")return"index.html";let X=J.replace(/^\//,"").replace(/\/$/,"");if(!X.includes("/")){if(Z!==Y&&X===Z)return`${Z}/index.html`;return`${X}.html`}return`${X}.html`.replace(/\.html\.html$/,".html")}function OX($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function fU($,Z=$){let Y=[];if(!LX($))return Y;for(let J of Qg($,{withFileTypes:!0})){let X=c4($,J.name);if(J.isDirectory())Y.push(...fU(X,Z));else Y.push(zg(Z,X))}return Y}function jg($){for(let Z of fU($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(Z))continue;let Y=c4($,Z);try{if(Kg(Y).size===0)Wg(Y)}catch{}}}function Hg($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function Og($,Z,Y,J,X){if(!Y)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${J}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${J}">`);let Q=`${Z.url.replace(/\/$/,"")}${l4(X,J,Y.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${xU(Q)}">`);let G=J.includes("_")||J.includes("-")?J:J.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${xU(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${xU(Q)}">`);let K=T3(Z.url,X,Y);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(W)=>`${K}
17928
- ${W}`);return $}function xU($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Lg($,Z,Y,J){if(Z===Y)return $;return $.replace(/<a\b([^>]*?)\bhref="(\/[^"]*)"([^>]*)>/gi,(X,Q,G,K)=>{if(G.startsWith("//"))return X;if(G===`/${Z}`||G===`/${Z}/`||G.startsWith(`/${Z}/`))return X;let W=G.match(/^(\/[^?#]*)(.*)$/);if(!W)return X;let[,U,z]=W,_=U==="/"?"/":U.replace(/\/$/,"");if(!J.has(_))return X;let q=_==="/"?`/${Z}/`:`/${Z}${_}`;return`<a${Q}href="${q}${z}"${K}>`})}function Vg($){if(/<main\b/i.test($)||/\bdata-stx-content\b/i.test($))return $;let Z=$.match(/<body\b[^>]*>/i),Y=$.search(/<\/body\s*>/i);if(!Z||Y<0)return $;let J=Z.index+Z[0].length,X=$.slice(J,Y),Q=0,G=[...X.matchAll(/<\/nav>/gi)];if(G.length>0){let q=G[G.length-1];Q=q.index+q[0].length}let K=X.length,W=X.search(/<footer\b/i);if(W!==-1)K=Math.min(K,W);let U=X.search(/<script\b[^>]*data-stx-(?:theme-toggle|reparent-progress)\b/i);if(U!==-1)K=Math.min(K,U);if(K<=Q)return $;let z=X.slice(Q,K);if(!z.trim())return $;let _=`${X.slice(0,Q)}
17922
+ ${K}`)}if(!$.includes("__stxThemeGuard")&&/<head\b[^>]*>/i.test($)){let K=`<script data-stx-theme-guard="1">${pf(J,X,Q,G)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
17923
+ ${K}`)}if(!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${nf(X,Q,G)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
17924
+ </body>`)}return $}var pf=($,Z,Y,J)=>`(function(){window.__stxThemeIcon=function(isDark){try{var want=isDark?'dark':'light';var pick=document.querySelector('link[rel~="icon"][media*="prefers-color-scheme: '+want+'"]');if(!pick)return;var live=document.querySelector('link[rel~="icon"]:not([media])');if(!live){live=document.createElement('link');live.setAttribute('rel','icon');document.head.appendChild(live)}if(pick.type)live.setAttribute('type',pick.type);var href=pick.getAttribute('href');if(live.getAttribute('href')!==href)live.setAttribute('href',href)}catch(e){}};function read(){try{var k=${JSON.stringify(Z)};var t=localStorage.getItem(k);return t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark'}catch(e){return ${JSON.stringify($)}==='dark'}}function apply(){var isDark=read();var html=document.documentElement;html.classList[isDark?'add':'remove']('dark');var color=isDark?${JSON.stringify(J)}:${JSON.stringify(Y)};if(!document.head)return;var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(!tc){tc=document.createElement('meta');tc.setAttribute('name','theme-color');tc.setAttribute('data-stx-theme-meta','1')}tc.setAttribute('content',color);if(tc!==document.head.firstChild){document.head.insertBefore(tc,document.head.firstChild)}if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)}apply();window.addEventListener('stx:navigate',apply);window.addEventListener('popstate',apply)})();`,nf=($,Z,Y)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Y)}:${JSON.stringify(Z)});if(window.__stxThemeIcon)window.__stxThemeIcon(isDark)});`;import{existsSync as rf,readFileSync as af}from"fs";import{join as sf,resolve as of}from"path";import tf from"process";function R3($,Z=tf.cwd()){let Y=$.i18n;if(!Y||!Array.isArray(Y.locales)||Y.locales.length===0)return null;let J=Y.defaultLocale??Y.locales[0],X=ef(Y,Z);return{locales:Y.locales,defaultLocale:J,labels:Y.labels??Object.fromEntries(Y.locales.map((Q)=>[Q,Q.toUpperCase()])),translations:X,pickerSelector:Y.pickerSelector??"#lang-picker"}}function ef($,Z){let Y=$.translations??{},J={},X=$.translationsDir,Q=X===!1?null:of(Z,typeof X==="string"&&X?X:"translations"),G=$.format??"json";for(let K of $.locales){let W=Q?$g(Q,K,G):{};J[K]={...W,...Y[K]??{}}}return J}function $g($,Z,Y){let J=Y==="json"?[`${Z}.json`]:[`${Z}.${Y}`,`${Z}.${Y==="yaml"?"yml":"yaml"}`];for(let X of J){let Q=sf($,X);if(!rf(Q))continue;try{let G=af(Q,"utf8"),K=Y==="json"?JSON.parse(G):Zg(G);return Mw(K)}catch{continue}}return{}}function Mw($,Z="",Y={}){if(!$||typeof $!=="object")return Y;for(let[J,X]of Object.entries($)){let Q=Z?`${Z}.${J}`:J;if(X&&typeof X==="object"&&!Array.isArray(X))Mw(X,Q,Y);else if(typeof X==="string")Y[Q]=X;else if(typeof X==="number"||typeof X==="boolean")Y[Q]=String(X)}return Y}function Zg($){let Z={},Y=[{obj:Z,indent:-1}];for(let J of $.split(`
17925
+ `)){let X=J.replace(/#.*$/,"").trimEnd();if(!X.trim())continue;let Q=X.search(/\S/);if(Q===-1)continue;while(Y.length>1&&Y[Y.length-1].indent>=Q)Y.pop();let G=Y[Y.length-1].obj,K=X.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(!K)continue;let[,,W,U]=K,z=W.trim(),_=U.trim();if(_==="")G[z]={},Y.push({obj:G[z],indent:Q});else G[z]=Yg(_)}return Z}function Yg($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);return $}function jX($,Z,Y){let J=$.translations[Z]?.[Y];if(typeof J==="string")return J;let X=$.translations[$.defaultLocale]?.[Y];if(typeof X==="string")return X;return Y}function M3($,Z,Y){return $.replace(/\{t(!?):([a-zA-Z][\w.-]*)\}/g,(J,X,Q)=>{let G=jX(Z,Y,Q);return X==="!"?G:Jg(G)})}function l4($,Z,Y){if(Z===Y)return $;if($==="/")return`/${Z}/`;if($==="/404.html")return`/${Z}/404.html`;return`/${Z}${$}`}function PU($,Z){for(let Y of Z){if($===`/${Y}`||$===`/${Y}/`)return{locale:Y,path:"/"};if($.startsWith(`/${Y}/`))return{locale:Y,path:$.slice(Y.length+1)}}return{locale:null,path:$}}function T3($,Z,Y){let J=$.replace(/\/$/,""),X=[];for(let G of Y.locales){let K=`${J}${l4(Z,G,Y.defaultLocale)}`;X.push(`<link rel="alternate" hreflang="${bU(G)}" href="${bU(K)}">`)}let Q=`${J}${l4(Z,Y.defaultLocale,Y.defaultLocale)}`;return X.push(`<link rel="alternate" hreflang="x-default" href="${bU(Q)}">`),X.join(`
17926
+ `)}function E3($,Z){return`<script data-stx-lang-picker="1">window.__stxI18n=${JSON.stringify({locales:$.locales,defaultLocale:$.defaultLocale,current:Z,pickerSelector:$.pickerSelector})};(function(){function cfg(){return window.__stxI18n}function localeFromPath(p){var d=cfg();for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/')return c;if(p.indexOf('/'+c+'/')===0)return c}return d.defaultLocale}function localePathFor(loc,p){var d=cfg();var stripped=p;for(var i=0;i<d.locales.length;i++){var c=d.locales[i];if(p==='/'+c||p==='/'+c+'/'){stripped='/';break}if(p.indexOf('/'+c+'/')===0){stripped=p.slice(c.length+1);break}}if(loc===d.defaultLocale)return stripped;if(stripped==='/')return '/'+loc+'/';return '/'+loc+stripped}cfg().localizeHref=function(href){try{var u=new URL(href,location.origin);if(u.origin!==location.origin)return href;return localePathFor(localeFromPath(location.pathname),u.pathname)+(u.search||'')+(u.hash||'')}catch(_){return href}};function syncFromUrl(){var d=cfg();var loc=localeFromPath(location.pathname);d.current=loc;var picker=document.querySelector(d.pickerSelector);if(picker){var btns=picker.querySelectorAll('[data-lang]');for(var i=0;i<btns.length;i++){var b=btns[i];if(b.getAttribute('data-lang')===loc)b.setAttribute('aria-current','true');else b.removeAttribute('aria-current')}}if(document.documentElement.lang!==loc)document.documentElement.lang=loc}function onLangClick(e){var d=cfg();var btn=e.target&&e.target.closest&&e.target.closest('[data-lang]');if(!btn)return;var picker=document.querySelector(d.pickerSelector);if(!picker||!picker.contains(btn))return;e.preventDefault();e.stopPropagation();var loc=btn.getAttribute('data-lang');if(!loc||loc===localeFromPath(location.pathname))return;var dest=localePathFor(loc,location.pathname);var r=window.__stxRouter;if(r&&r.navigate)r.navigate(dest,true,true);else location.assign(dest)}syncFromUrl();if(window.__stxLangPickerBound){document.removeEventListener('click',window.__stxLangPickerClick,true);window.removeEventListener('stx:navigate',window.__stxLangPickerSync);window.removeEventListener('popstate',window.__stxLangPickerSync)}window.__stxLangPickerClick=onLangClick;window.__stxLangPickerSync=syncFromUrl;window.__stxLangPickerBound=1;document.addEventListener('click',onLangClick,true);window.addEventListener('stx:navigate',syncFromUrl);window.addEventListener('popstate',syncFromUrl)})();</script>`}function bU($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Jg($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var yU=()=>{};var{Glob:Xg}=globalThis.Bun;import{cpSync as Qg,existsSync as LX,mkdirSync as Tw,readFileSync as Ew,readdirSync as Gg,rmSync as Kg,statSync as Wg,unlinkSync as Ug,writeFileSync as HX}from"fs";import{dirname as zg,join as c4,relative as _g}from"path";import Iw from"process";import qg from"bun-plugin-stx";async function vU($){let Z=Date.now(),Y=$.pagesDir??"pages",J=$.outDir??"dist",X=$.publicDir??"public";if(!$.noClean)Kg(J,{recursive:!0,force:!0});Tw(J,{recursive:!0});let Q=new Xg(`${Y}/**/*.stx`),G=await Array.fromAsync(Q.scan("."));if(G.length===0)throw Error(`No .stx files found in ${Y}/`);let K=await Bun.build({entrypoints:G,outdir:J,plugins:[qg()],naming:{entry:"[name].[ext]"}});if(!K.success)throw console.error(K.logs),Error("Build failed");Hg(J);let W=fU(J).filter((j)=>j.endsWith(".html")),U=R3($,Iw.cwd()),z=new Set(W.map(OX));for(let j of W){let H=c4(J,j),O=Ew(H,"utf8"),V=OX(j),L=U?U.locales:[$.seo?.locale?.split(/[_-]/)[0]??"en"];for(let F of L){let A=O;if(A=Og(A),U)A=M3(A,U,F);if(A=await y0(A,Iw.cwd()),A=F3(A,$,$.pages?.[V],V),U)A=Lg(A,$,U,F,V),A=Vg(A,F,U.defaultLocale,z);if(A=N3(A,$),A=Fg(A),U)A=A.replace(/<\/body>/i,`${E3(U,F)}
17927
+ </body>`);if($.spa!==!1)A=await CU(A,$.router);let w=U?jg(V,F,U.defaultLocale):j,N=c4(J,w);if(Tw(Bg(N),{recursive:!0}),HX(N,A),U&&F!==U.defaultLocale&&w!==j);}}if(LX(X))Qg(X,J,{recursive:!0});let _=c4(J,"404.html");if(!LX(_)&&LX(c4(J,"index.html"))){let j=Ew(c4(J,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${Ag($.name)}</title>`);HX(_,j)}if($.sitemap!==!1){let j=[],H=W.filter((V)=>V!=="404.html").map(OX),O=U?U.locales:[null];for(let V of H){let L=$.pages?.[V];for(let F of O){let A=F&&U?l4(V,F,U.defaultLocale):V;j.push({path:A,page:L})}}HX(c4(J,"sitemap.xml"),A3($,j))}let q=w3($);if(q!==null)HX(c4(J,"robots.txt"),q);let B=W.map(OX);return{outDir:J,pages:B,durationMs:Date.now()-Z}}function Bg($){return zg($)}function jg($,Z,Y){let J=l4($,Z,Y);if(J==="/")return"index.html";let X=J.replace(/^\//,"").replace(/\/$/,"");if(!X.includes("/")){if(Z!==Y&&X===Z)return`${Z}/index.html`;return`${X}.html`}return`${X}.html`.replace(/\.html\.html$/,".html")}function OX($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function fU($,Z=$){let Y=[];if(!LX($))return Y;for(let J of Gg($,{withFileTypes:!0})){let X=c4($,J.name);if(J.isDirectory())Y.push(...fU(X,Z));else Y.push(_g(Z,X))}return Y}function Hg($){for(let Z of fU($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(Z))continue;let Y=c4($,Z);try{if(Wg(Y).size===0)Ug(Y)}catch{}}}function Og($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function Lg($,Z,Y,J,X){if(!Y)return $;if(/<html\b[^>]*\blang=/i.test($))$=$.replace(/<html\b([^>]*)\blang="[^"]*"/i,`<html$1lang="${J}"`);else $=$.replace(/<html\b([^>]*)>/i,`<html$1 lang="${J}">`);let Q=`${Z.url.replace(/\/$/,"")}${l4(X,J,Y.defaultLocale)}`;if(/<link rel="canonical"/.test($))$=$.replace(/<link rel="canonical"[^>]*>/,`<link rel="canonical" href="${xU(Q)}">`);let G=J.includes("_")||J.includes("-")?J:J.toLowerCase();if(/<meta property="og:locale"/.test($))$=$.replace(/<meta property="og:locale"[^>]*>/,`<meta property="og:locale" content="${xU(G)}">`);if(/<meta property="og:url"/.test($))$=$.replace(/<meta property="og:url"[^>]*>/,`<meta property="og:url" content="${xU(Q)}">`);let K=T3(Z.url,X,Y);if(!$.includes("hreflang="))$=$.replace(/<link rel="canonical"[^>]*>/,(W)=>`${K}
17928
+ ${W}`);return $}function xU($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Vg($,Z,Y,J){if(Z===Y)return $;return $.replace(/<a\b([^>]*?)\bhref="(\/[^"]*)"([^>]*)>/gi,(X,Q,G,K)=>{if(G.startsWith("//"))return X;if(G===`/${Z}`||G===`/${Z}/`||G.startsWith(`/${Z}/`))return X;let W=G.match(/^(\/[^?#]*)(.*)$/);if(!W)return X;let[,U,z]=W,_=U==="/"?"/":U.replace(/\/$/,"");if(!J.has(_))return X;let q=_==="/"?`/${Z}/`:`/${Z}${_}`;return`<a${Q}href="${q}${z}"${K}>`})}function Fg($){if(/<main\b/i.test($)||/\bdata-stx-content\b/i.test($))return $;let Z=$.match(/<body\b[^>]*>/i),Y=$.search(/<\/body\s*>/i);if(!Z||Y<0)return $;let J=Z.index+Z[0].length,X=$.slice(J,Y),Q=0,G=[...X.matchAll(/<\/nav>/gi)];if(G.length>0){let q=G[G.length-1];Q=q.index+q[0].length}let K=X.length,W=X.search(/<footer\b/i);if(W!==-1)K=Math.min(K,W);let U=X.search(/<script\b[^>]*data-stx-(?:theme-toggle|reparent-progress)\b/i);if(U!==-1)K=Math.min(K,U);if(K<=Q)return $;let z=X.slice(Q,K);if(!z.trim())return $;let _=`${X.slice(0,Q)}
17929
17929
  <main>${z}</main>
17930
- ${X.slice(K)}`;return`${$.slice(0,J)}${_}${$.slice(Y)}`}function Fg($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function gU($){return $}var Dw=D(()=>{_4();yU()});var kw=D(()=>{Dw();yU()});function Ng($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Rg($){let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=Y.exec($))!==null)Z.push([J.index,J.index+J[0].length]);return Z}function Mg($,Z){for(let[Y,J]of $)if(Z>=Y&&Z<J)return!0;return!1}function D3($,Z){let Y=1,J=0;for(let X=0;X<Z&&X<$.length;X++)if($[X]===`
17931
- `)Y++,J=X+1;return{line:Y,column:Z-J+1}}function Tg($,Z,Y){let J=Z.toLowerCase(),X=$.length,Q=1,G=Y;while(G<X){let K=$.indexOf("<",G);if(K===-1)return-1;if(G=K,$.startsWith("<!--",G)){let z=$.indexOf("-->",G+4);if(z===-1)return-1;G=z+3;continue}if($[G+1]==="/"){let z=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(G,G+64));if(!z){G++;continue}if(z[1].toLowerCase()===J){if(Q--,G+=z[0].length,Q===0)return G;continue}G+=z[0].length;continue}let W=/^<([a-z][\w-]*)\b/i.exec($.slice(G,G+64));if(!W){G++;continue}let U=$.indexOf(">",G);if(U===-1)return-1;if(W[1].toLowerCase()===J&&$[U-1]!=="/")Q++;G=U+1}return-1}function Eg($,Z,Y){let J=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,X;while((X=J.exec($))!==null){if(Mg(Z,X.index))continue;let Q=X[1].toLowerCase().split(":")[0];if(Ag.has(Q))continue;let G=X[3].trim();if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(G)){let K=$.indexOf(X[3],X.index),{line:W,column:U}=D3($,K<0?X.index:K);Y.push({ruleId:"stx/no-bare-function-ref-in-event",message:`Event handler @${X[1]}="${G}" is a bare reference and will not fire. Call it: @${X[1]}="${G}()".`,line:W,column:U,severity:"error"})}}}function Ig($,Z,Y){if(Z!=="view")return;let J=/<script\b([^>]*)>/gi,X;while((X=J.exec($))!==null)if(/(?:^|\s)client(?=[\s/=]|$)/i.test(X[1])){let{line:Q,column:G}=D3($,X.index);Y.push({ruleId:"stx/no-view-level-script-client",message:"<script client> at the top level of a view is silently dropped \u2014 only components get client scopes. Move it into a component, or use <script> (server).",line:Q,column:G,severity:"error"})}}function Sw($){let Z=$.split("/"),Y=[];for(let J of Z){if(J===""||J===".")continue;if(J==="..")Y.pop();else Y.push(J)}return Y.join("/")}function Dg($,Z,Y){let J=Z.replace(/\\/g,"/"),X=J.indexOf("resources/stores/");if(X===-1)return;let Q=J.slice(0,X+16),G=J.slice(0,J.lastIndexOf("/")),K=/\b(import|export)\s+(type\s+)?([^'"]*?)\s*from\s*['"]([^'"]+)['"]/g,W;while((W=K.exec($))!==null){if(W[2])continue;let U=W[1],z=W[4],_;if(z.startsWith("."))_=!Sw(`${G}/${z}`).startsWith(Sw(Q));else _=!0;if(_){let{line:q,column:B}=D3($,W.index),j=U==="export"?"Value re-export":"Value import";Y.push({ruleId:"stx/store-value-imports-must-be-local",message:`${j} from "${z}" is outside resources/stores/ and will be stripped from the store bundle. Use \`${U} type\`, or move the value into the stores dir.`,line:q,column:B,severity:"error"})}}}function kg($){let Z=$.trim(),Y=(G)=>{let K=G.match(/[A-Za-z_$][\w$]*/g);return K?K:[]},J=/\bas\s+(.+)$/.exec(Z);if(J){let G=J[1].trim(),K=/^([A-Za-z_$][\w$]*)\s*=>\s*([A-Za-z_$][\w$]*)/.exec(G);if(K)return[K[1],K[2]];let W=/^\(([^)]*)\)/.exec(G);if(W)return Y(W[1]);let U=/^([A-Za-z_$][\w$]*)/.exec(G);return U?[U[1]]:[]}let X=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(Z);if(X)return Y(X[1]);let Q=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(Z);return Q?[Q[1]]:[]}function Sg($,Z){let Y=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,J;while((J=Y.exec($))!==null){let X=kg(J[1]);if(X.length===0)continue;let Q=$.lastIndexOf("<",J.index);if(Q===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(Q,Q+64));if(!G)continue;let K=$.indexOf(">",J.index);if(K===-1)continue;let U=$[K-1]==="/"||wg.has(G[1].toLowerCase())?K+1:Tg($,G[1],K+1),z=U===-1?K+1:U,_=$.indexOf(J[1],J.index),q=$.slice(Q,z);if(_>=0&&_+J[1].length<=z){let B=_-Q;q=q.slice(0,B)+" ".repeat(J[1].length)+q.slice(B+J[1].length)}for(let B of X){let j=new RegExp(`(?<![.\\w$])${Ng(B)}\\s*\\(`,"g"),H;while((H=j.exec(q))!==null){let O=Q+H.index,{line:V,column:L}=D3($,O);Z.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${B}" is a :for iteration variable, not a signal \u2014 calling it as "${B}()" leaves it as a function and silently breaks comparisons. Use "${B}" directly.`,line:V,column:L,severity:"error"})}}}}function Cg($,Z){let Y=/<!--([\s\S]*?)-->/g,J;while((J=Y.exec($))!==null){let Q=J[1].indexOf("`");if(Q!==-1){let G=J.index+4+Q,{line:K,column:W}=D3($,G);Z.push({ruleId:"stx/no-backticks-in-html-comments",message:"Backtick inside an HTML comment leaks into the merged setup function and flips the JS parser into template-literal mode. Remove it or rephrase the comment.",line:K,column:W,severity:"error"})}}}function I3($,Z){return $?.[Z]!==!1}function Cw($,Z={}){let Y=[],J=Rg($),X=(Z.filePath??"").replace(/\\/g,"/"),Q=Z.fileKind??(/\/components?\//i.test(X)?"component":/\/layouts?\//i.test(X)?"layout":"view");if(I3(Z.rules,"stx/no-bare-function-ref-in-event"))Eg($,J,Y);if(I3(Z.rules,"stx/no-view-level-script-client"))Ig($,Q,Y);if(X&&I3(Z.rules,"stx/store-value-imports-must-be-local"))Dg($,X,Y);if(I3(Z.rules,"stx/no-signal-call-in-for-iteration-var"))Sg($,Y);if(I3(Z.rules,"stx/no-backticks-in-html-comments"))Cg($,Y);Y.sort((K,W)=>K.line-W.line||K.column-W.column);let G=new Set;return Y.filter((K)=>{let W=`${K.ruleId}:${K.line}:${K.column}`;if(G.has(W))return!1;return G.add(W),!0})}var Ag,wg;var bw=D(()=>{Ag=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),wg=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});function Pw($,Z){return $.kind===Z}var yw=()=>{};var xw=D(()=>{yw()});function vw($){if($===String)return"string";if($===Number)return"number";if($===Boolean)return"boolean";if($===Array)return"array";if($===Object)return"object";if($===Function)return"function";if($===Date)return"date";if($===Symbol)return"symbol";if(typeof $==="function"&&$.name)return $.name;return"unknown"}function bg($,Z){if($===null||$===void 0)return!0;if(Z===String)return typeof $==="string";if(Z===Number)return typeof $==="number"&&!Number.isNaN($);if(Z===Boolean)return typeof $==="boolean";if(Z===Array)return Array.isArray($);if(Z===Object)return typeof $==="object"&&!Array.isArray($);if(Z===Function)return typeof $==="function";if(Z===Date)return $ instanceof Date;if(Z===Symbol)return typeof $==="symbol";if(typeof Z==="function")return $ instanceof Z;return!0}function fw($,Z,Y,J){let X=J?`[${J}]`:"";if(Y.required&&(Z===void 0||Z===null))return{prop:$,message:`${X} Missing required prop: "${$}"`,value:Z,expected:Y.type?vw(Y.type):void 0};if(Z===void 0||Z===null)return null;if(Y.type){let Q=Array.isArray(Y.type)?Y.type:[Y.type];if(!Q.some((K)=>bg(Z,K))){let K=Q.map((W)=>vw(W)).join(" | ");return{prop:$,message:`${X} Invalid prop type for "${$}": expected ${K}, got ${typeof Z}`,value:Z,expected:K}}}if(Y.validator){if(!Y.validator(Z))return{prop:$,message:`${X} Custom validation failed for prop "${$}"`,value:Z}}return null}function gw($){let Z=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return Z;let Y={...Z};for(let[J,X]of Object.entries($)){let Q=typeof X==="function"||Array.isArray(X)?{type:X}:X||{};if(Y[J]===void 0&&Q.default!==void 0)Y[J]=typeof Q.default==="function"?Q.default():Q.default}return Y}function hw($,Z={}){let{componentName:Y,throwOnError:J=!1,logWarnings:X=!0}=Z,Q=globalThis.__STX_CURRENT_PROPS__||{},G={...Q},K={valid:!0,errors:[],warnings:[]};for(let[W,U]of Object.entries($)){let z=typeof U==="function"||Array.isArray(U)?{type:U}:U||{};if(G[W]===void 0&&z.default!==void 0)G[W]=typeof z.default==="function"?z.default():z.default;let _=fw(W,G[W],z,Y);if(_){if(K.valid=!1,K.errors.push(_),X)console.warn(_.message)}}for(let W of Object.keys(Q))if(!(W in $)){let U=`${Y?`[${Y}]`:""} Unknown prop: "${W}"`;if(K.warnings.push(U),X)console.warn(U)}if(J&&!K.valid){let W=K.errors.map((U)=>U.message).join(`
17930
+ ${X.slice(K)}`;return`${$.slice(0,J)}${_}${$.slice(Y)}`}function Ag($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function gU($){return $}var Dw=D(()=>{_4();yU()});var kw=D(()=>{Dw();yU()});function Rg($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Mg($){let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,J;while((J=Y.exec($))!==null)Z.push([J.index,J.index+J[0].length]);return Z}function Tg($,Z){for(let[Y,J]of $)if(Z>=Y&&Z<J)return!0;return!1}function D3($,Z){let Y=1,J=0;for(let X=0;X<Z&&X<$.length;X++)if($[X]===`
17931
+ `)Y++,J=X+1;return{line:Y,column:Z-J+1}}function Eg($,Z,Y){let J=Z.toLowerCase(),X=$.length,Q=1,G=Y;while(G<X){let K=$.indexOf("<",G);if(K===-1)return-1;if(G=K,$.startsWith("<!--",G)){let z=$.indexOf("-->",G+4);if(z===-1)return-1;G=z+3;continue}if($[G+1]==="/"){let z=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(G,G+64));if(!z){G++;continue}if(z[1].toLowerCase()===J){if(Q--,G+=z[0].length,Q===0)return G;continue}G+=z[0].length;continue}let W=/^<([a-z][\w-]*)\b/i.exec($.slice(G,G+64));if(!W){G++;continue}let U=$.indexOf(">",G);if(U===-1)return-1;if(W[1].toLowerCase()===J&&$[U-1]!=="/")Q++;G=U+1}return-1}function Ig($,Z,Y){let J=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,X;while((X=J.exec($))!==null){if(Tg(Z,X.index))continue;let Q=X[1].toLowerCase().split(":")[0];if(wg.has(Q))continue;let G=X[3].trim();if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(G)){let K=$.indexOf(X[3],X.index),{line:W,column:U}=D3($,K<0?X.index:K);Y.push({ruleId:"stx/no-bare-function-ref-in-event",message:`Event handler @${X[1]}="${G}" is a bare reference and will not fire. Call it: @${X[1]}="${G}()".`,line:W,column:U,severity:"error"})}}}function Dg($,Z,Y){if(Z!=="view")return;let J=/<script\b([^>]*)>/gi,X;while((X=J.exec($))!==null)if(/(?:^|\s)client(?=[\s/=]|$)/i.test(X[1])){let{line:Q,column:G}=D3($,X.index);Y.push({ruleId:"stx/no-view-level-script-client",message:"<script client> at the top level of a view is silently dropped \u2014 only components get client scopes. Move it into a component, or use <script> (server).",line:Q,column:G,severity:"error"})}}function Sw($){let Z=$.split("/"),Y=[];for(let J of Z){if(J===""||J===".")continue;if(J==="..")Y.pop();else Y.push(J)}return Y.join("/")}function kg($,Z,Y){let J=Z.replace(/\\/g,"/"),X=J.indexOf("resources/stores/");if(X===-1)return;let Q=J.slice(0,X+16),G=J.slice(0,J.lastIndexOf("/")),K=/\b(import|export)\s+(type\s+)?([^'"]*?)\s*from\s*['"]([^'"]+)['"]/g,W;while((W=K.exec($))!==null){if(W[2])continue;let U=W[1],z=W[4],_;if(z.startsWith("."))_=!Sw(`${G}/${z}`).startsWith(Sw(Q));else _=!0;if(_){let{line:q,column:B}=D3($,W.index),j=U==="export"?"Value re-export":"Value import";Y.push({ruleId:"stx/store-value-imports-must-be-local",message:`${j} from "${z}" is outside resources/stores/ and will be stripped from the store bundle. Use \`${U} type\`, or move the value into the stores dir.`,line:q,column:B,severity:"error"})}}}function Sg($){let Z=$.trim(),Y=(G)=>{let K=G.match(/[A-Za-z_$][\w$]*/g);return K?K:[]},J=/\bas\s+(.+)$/.exec(Z);if(J){let G=J[1].trim(),K=/^([A-Za-z_$][\w$]*)\s*=>\s*([A-Za-z_$][\w$]*)/.exec(G);if(K)return[K[1],K[2]];let W=/^\(([^)]*)\)/.exec(G);if(W)return Y(W[1]);let U=/^([A-Za-z_$][\w$]*)/.exec(G);return U?[U[1]]:[]}let X=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(Z);if(X)return Y(X[1]);let Q=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(Z);return Q?[Q[1]]:[]}function Cg($,Z){let Y=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,J;while((J=Y.exec($))!==null){let X=Sg(J[1]);if(X.length===0)continue;let Q=$.lastIndexOf("<",J.index);if(Q===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(Q,Q+64));if(!G)continue;let K=$.indexOf(">",J.index);if(K===-1)continue;let U=$[K-1]==="/"||Ng.has(G[1].toLowerCase())?K+1:Eg($,G[1],K+1),z=U===-1?K+1:U,_=$.indexOf(J[1],J.index),q=$.slice(Q,z);if(_>=0&&_+J[1].length<=z){let B=_-Q;q=q.slice(0,B)+" ".repeat(J[1].length)+q.slice(B+J[1].length)}for(let B of X){let j=new RegExp(`(?<![.\\w$])${Rg(B)}\\s*\\(`,"g"),H;while((H=j.exec(q))!==null){let O=Q+H.index,{line:V,column:L}=D3($,O);Z.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${B}" is a :for iteration variable, not a signal \u2014 calling it as "${B}()" leaves it as a function and silently breaks comparisons. Use "${B}" directly.`,line:V,column:L,severity:"error"})}}}}function bg($,Z){let Y=/<!--([\s\S]*?)-->/g,J;while((J=Y.exec($))!==null){let Q=J[1].indexOf("`");if(Q!==-1){let G=J.index+4+Q,{line:K,column:W}=D3($,G);Z.push({ruleId:"stx/no-backticks-in-html-comments",message:"Backtick inside an HTML comment leaks into the merged setup function and flips the JS parser into template-literal mode. Remove it or rephrase the comment.",line:K,column:W,severity:"error"})}}}function I3($,Z){return $?.[Z]!==!1}function Cw($,Z={}){let Y=[],J=Mg($),X=(Z.filePath??"").replace(/\\/g,"/"),Q=Z.fileKind??(/\/components?\//i.test(X)?"component":/\/layouts?\//i.test(X)?"layout":"view");if(I3(Z.rules,"stx/no-bare-function-ref-in-event"))Ig($,J,Y);if(I3(Z.rules,"stx/no-view-level-script-client"))Dg($,Q,Y);if(X&&I3(Z.rules,"stx/store-value-imports-must-be-local"))kg($,X,Y);if(I3(Z.rules,"stx/no-signal-call-in-for-iteration-var"))Cg($,Y);if(I3(Z.rules,"stx/no-backticks-in-html-comments"))bg($,Y);Y.sort((K,W)=>K.line-W.line||K.column-W.column);let G=new Set;return Y.filter((K)=>{let W=`${K.ruleId}:${K.line}:${K.column}`;if(G.has(W))return!1;return G.add(W),!0})}var wg,Ng;var bw=D(()=>{wg=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),Ng=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});function Pw($,Z){return $.kind===Z}var yw=()=>{};var xw=D(()=>{yw()});function vw($){if($===String)return"string";if($===Number)return"number";if($===Boolean)return"boolean";if($===Array)return"array";if($===Object)return"object";if($===Function)return"function";if($===Date)return"date";if($===Symbol)return"symbol";if(typeof $==="function"&&$.name)return $.name;return"unknown"}function Pg($,Z){if($===null||$===void 0)return!0;if(Z===String)return typeof $==="string";if(Z===Number)return typeof $==="number"&&!Number.isNaN($);if(Z===Boolean)return typeof $==="boolean";if(Z===Array)return Array.isArray($);if(Z===Object)return typeof $==="object"&&!Array.isArray($);if(Z===Function)return typeof $==="function";if(Z===Date)return $ instanceof Date;if(Z===Symbol)return typeof $==="symbol";if(typeof Z==="function")return $ instanceof Z;return!0}function fw($,Z,Y,J){let X=J?`[${J}]`:"";if(Y.required&&(Z===void 0||Z===null))return{prop:$,message:`${X} Missing required prop: "${$}"`,value:Z,expected:Y.type?vw(Y.type):void 0};if(Z===void 0||Z===null)return null;if(Y.type){let Q=Array.isArray(Y.type)?Y.type:[Y.type];if(!Q.some((K)=>Pg(Z,K))){let K=Q.map((W)=>vw(W)).join(" | ");return{prop:$,message:`${X} Invalid prop type for "${$}": expected ${K}, got ${typeof Z}`,value:Z,expected:K}}}if(Y.validator){if(!Y.validator(Z))return{prop:$,message:`${X} Custom validation failed for prop "${$}"`,value:Z}}return null}function gw($){let Z=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return Z;let Y={...Z};for(let[J,X]of Object.entries($)){let Q=typeof X==="function"||Array.isArray(X)?{type:X}:X||{};if(Y[J]===void 0&&Q.default!==void 0)Y[J]=typeof Q.default==="function"?Q.default():Q.default}return Y}function hw($,Z={}){let{componentName:Y,throwOnError:J=!1,logWarnings:X=!0}=Z,Q=globalThis.__STX_CURRENT_PROPS__||{},G={...Q},K={valid:!0,errors:[],warnings:[]};for(let[W,U]of Object.entries($)){let z=typeof U==="function"||Array.isArray(U)?{type:U}:U||{};if(G[W]===void 0&&z.default!==void 0)G[W]=typeof z.default==="function"?z.default():z.default;let _=fw(W,G[W],z,Y);if(_){if(K.valid=!1,K.errors.push(_),X)console.warn(_.message)}}for(let W of Object.keys(Q))if(!(W in $)){let U=`${Y?`[${Y}]`:""} Unknown prop: "${W}"`;if(K.warnings.push(U),X)console.warn(U)}if(J&&!K.valid){let W=K.errors.map((U)=>U.message).join(`
17932
17932
  `);throw Error(`Prop validation failed:
17933
- ${W}`)}return{props:G,validation:K}}function dw($,Z){let Y={...$};for(let[J,X]of Object.entries(Z))if(Y[J]===void 0)Y[J]=typeof X==="function"?X():X;return Y}function uw($){return $}function mw($){return{type:$,required:!0}}function lw($,Z){return{type:Z,default:$}}function cw($,Z={}){return{...Z,validator:$}}function pw($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function iw($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function nw($,Z={}){return{...Z,type:Object}}function rw($,Z,Y){if(!Z)return $;let J={};for(let[X,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[X];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=fw(X,K,G,Y);if(W)console.warn(W.message)}J[X]=K}for(let[X,Q]of Object.entries($))if(!(X in J))J[X]=Q;return J}var B$={};$0(B$,{writeNetlifyConfig:()=>x8,writeManifest:()=>SK,writeImageManifest:()=>BK,wrapComponentForHMR:()=>$f,withDefaults:()=>dw,webComponentDirectiveHandler:()=>lG,watermark:()=>dW,watchViews:()=>Mf,watchMultiple:()=>$P,watchEffect:()=>ZP,watch:()=>eb,waitForStore:()=>NP,waitForLocale:()=>gE,videoDirective:()=>E8,validators:()=>kZ,validated:()=>cw,validateValueEnhanced:()=>fq,validateTemplate:()=>OO,validateParams:()=>cW,validateFormEnhanced:()=>IE,validateFile:()=>XX,validateFields:()=>TE,validateField:()=>xq,validateDirective:()=>VO,validateCspDirectives:()=>XE,validateConfig:()=>TL,validateComponentScripts:()=>Ay,validateComponentProps:()=>My,validateClientScript:()=>W8,usesSignalsInScript:()=>l6,userComponentFileExists:()=>p7,useVirtualList:()=>jQ,useTitle:()=>Tq,useStoreOrThrow:()=>wP,useStore:()=>MA,useSlots:()=>Yw,useSeoMeta:()=>g9,useRouteParams:()=>QV,useRouteParamOrThrow:()=>RP,useRouteParam:()=>GV,usePageTitle:()=>Tq,useOptimistic:()=>Lj,useMiddlewareValue:()=>MP,useMiddlewareState:()=>KV,useLoadingIndicator:()=>WA,useHead:()=>gZ,useAttrs:()=>Xw,uploadFiles:()=>HU,uploadFile:()=>QX,updateInstance:()=>UP,untrack:()=>MY,unregisterDirective:()=>gS,unmountInstance:()=>zP,unescapeHtml:()=>BZ,transpileTypeScript:()=>o4,translate:()=>jX,transitionDirective:()=>$Z,toUsers:()=>tV,toUser:()=>oV,thumbnail:()=>RW,thumbHashToRGBA:()=>j3,thumbHashToDataURL:()=>zU,templateCache:()=>JQ,stxClientHelpers:()=>jW,structuredDataDirective:()=>_Y,stripLocalePrefix:()=>PU,stripDocumentWrapper:()=>g4,stripCommentsAndLiterals:()=>pX,stringToStream:()=>Wx,strictCspPreset:()=>_q,streamingSuspenseDirective:()=>o9,streamToResponse:()=>ZB,streamTemplateSimple:()=>oq,streamTemplate:()=>nq,stopHmrServer:()=>b5,stopBroadcasting:()=>aV,stateDirName:()=>M$,stateDir:()=>p0,state:()=>t7,startProductionServer:()=>nF,startInteractive:()=>dF,startBroadcasting:()=>rV,staggerDirective:()=>Rz,srcsetUrls:()=>mW,springDirective:()=>Mz,splitByPipe:()=>SZ,smartBatchSign:()=>nW,slotContentHasExpressions:()=>kO,signUrl:()=>sJ,shouldTranspileTypeScript:()=>s4,shouldReloadOnChange:()=>k8,shouldRefreshSignature:()=>$X,shouldIgnoreFile:()=>S8,shouldCacheComponent:()=>yH,sharpen:()=>IW,shape:()=>nw,setStateDir:()=>lX,setRouteParams:()=>DP,setMiddlewareState:()=>kP,setGlobalProvide:()=>WX,setErrorLocale:()=>v_,setCurrentInstance:()=>rb,setCachedVideoResult:()=>A5,setCachedImageResult:()=>L5,setCached:()=>B5,serveStxFile:()=>k3,serveMultipleStxFiles:()=>S3,serveMarkdownFile:()=>AJ,serveFile:()=>vv,serveApp:()=>C3,serve:()=>YA,serializeState:()=>qA,sepia:()=>kW,seoMetaToHeadConfig:()=>x7,scrollAnimateDirective:()=>ZZ,screenReaderDirective:()=>e3,scopeHTML:()=>FL,scopeCSS:()=>VL,scanForSitemapEntries:()=>JD,scanA11yIssues:()=>xX,saturation:()=>PW,sanitizeParams:()=>pW,sanitizeFilePath:()=>o_,sanitizeExpression:()=>t_,sanitizeDirectiveParams:()=>e_,sanitizeDirectiveParam:()=>C7,sanitizeComponentProps:()=>F9,safeExecuteAsync:()=>q4,safeExecute:()=>r_,runPreProcessingMiddleware:()=>g2,runPostProcessingMiddleware:()=>h2,runMiddleware:()=>i8,runHooks:()=>q$,runDoctor:()=>qX,rotate:()=>yW,rewriteImagesWithSiblings:()=>gY,resolveTemplatePath:()=>q8,resolveI18n:()=>R3,resize:()=>wW,resetPlaceholders:()=>rX,resetHead:()=>Rq,resetHMRHandler:()=>Yf,resetErrorConfig:()=>l_,required:()=>mw,replacePlaceholders:()=>qZ,renderView:()=>AU,renderVideoComponent:()=>T5,renderVendorStyleTags:()=>H7,renderToString:()=>V$,renderToStream:()=>jw,renderToDOM:()=>o5,renderThumbhashToCanvas:()=>UU,renderTemplateString:()=>V3,renderTemplate:()=>IU,renderString:()=>hf,renderStreamingPage:()=>rq,renderSlot:()=>gQ,renderSSRSuspense:()=>VH,renderProtectedVideo:()=>eW,renderProtectedImg:()=>tW,renderMediaUpload:()=>iW,renderMarkdownView:()=>zX,renderImgComponent:()=>F6,renderImageComponent:()=>KK,renderHtmlAttrs:()=>Iq,renderHead:()=>Eq,renderEmail:()=>Tf,renderComponentWithSlot:()=>j4,renderBodyAttrs:()=>Dq,render:()=>Kf,relaxedCspPreset:()=>qq,registerValidationRule:()=>ME,registerStreamingDirectives:()=>eq,registerStoresClient:()=>EA,registerStore:()=>EP,registerSeoDirectives:()=>ZD,registerMiddleware:()=>AP,registerFilters:()=>z_,registerFilter:()=>oX,registerErrorMessages:()=>g_,registerEnhancedValidationRule:()=>EE,registerDirective:()=>CO,registerCspDirectives:()=>JE,registerComponentDirectives:()=>Iy,registerAnimationDirectives:()=>AM,registerA11yDirectives:()=>GM,ref:()=>ob,redirect:()=>Ox,rebaseOntoStateDir:()=>T$,readMarkdownFile:()=>P4,readFileCached:()=>Vj,reactive:()=>YV,quality:()=>gW,pruneSignatureCache:()=>sW,pruneCache:()=>uO,provide:()=>aA,protectCodeBlocks:()=>TU,prop:()=>uw,processVueTemplate:()=>i2,processVirtualListDirectives:()=>vY,processVirtualGridDirectives:()=>OQ,processVideo:()=>UJ,processValidateDirective:()=>vq,processTranslateDirective:()=>n9,processTransitionDirectives:()=>UH,processTransitionAttributes:()=>qH,processTitleDirective:()=>Cq,processTemplateBindings:()=>K9,processTeleportDirectives:()=>ZH,processSuspenseDirectives:()=>OH,processStructuredData:()=>m2,processStreamDirectives:()=>aq,processStaticDirectives:()=>kQ,processStackReplacements:()=>UY,processStackPushDirectives:()=>WY,processSlots:()=>hQ,processShell:()=>gJ,processServerBindings:()=>BY,processSeoDirective:()=>l2,processSectionDirectives:()=>$B,processScopedStyles:()=>n7,processReactiveBindings:()=>N_,processProtectedMedia:()=>$U,processPartialHydrationDirectives:()=>NQ,processOnceDirective:()=>K8,processMiddleware:()=>f2,processMetaDirectives:()=>u2,processMetaDirective:()=>bq,processMarkdownFileDirectives:()=>vQ,processMarkdownDirectives:()=>xQ,processLoops:()=>QY,processKeepAliveDirectives:()=>bH,processJsonDirective:()=>G8,processInfiniteListDirectives:()=>HQ,processIncludes:()=>KY,processImgComponents:()=>MG,processImageComponents:()=>WK,processImage:()=>$4,processHeadDirective:()=>Sq,processForms:()=>RE,processFormInputDirectives:()=>uZ,processExpressions:()=>u1,processEventDirectives:()=>q9,processErrorDirective:()=>mZ,processDynamicComponents:()=>r2,processDirectives:()=>B0,processDirectiveAttributes:()=>lS,processDeferDirectives:()=>tj,processCustomDirectives:()=>y9,processCspDirectives:()=>C9,processComponentProps:()=>rw,processClientScript:()=>a4,processBasicFormDirectives:()=>h$,processAsyncDirectives:()=>TH,processAppearanceBootstrapDirective:()=>v9,processAnimationDirectives:()=>fX,processA11yDirectives:()=>yX,preloadTranslationsBackground:()=>vE,preloadTranslations:()=>dq,preloadIslandHandlers:()=>iv,preloadIconCollection:()=>N2,poolStrings:()=>lV,pluginManager:()=>iG,performLeave:()=>WH,performEnter:()=>KH,peek:()=>J8,partialsCache:()=>_6,parseVideoDirectiveOptions:()=>BL,parseUrl:()=>AW,parseThumbhashString:()=>_U,parseSwitchBlock:()=>CZ,parseSlots:()=>fQ,parseSlotElement:()=>NO,parseScriptDeclarations:()=>Wq,parseSFCComponent:()=>AL,parseProtectedArgs:()=>ZU,parseImgComponent:()=>YJ,parseImageUrl:()=>sQ,parseImageComponent:()=>EJ,parseExpressionWithFilters:()=>Gq,parseCookies:()=>Bx,parseConditionalBlock:()=>w9,parseArguments:()=>N9,parseAnimationShorthand:()=>VM,optional:()=>lw,optimizeTemplate:()=>cV,optimizeImage:()=>CJ,optimizeDirectory:()=>qK,oneOf:()=>pw,onceStore:()=>x2,onUpdated:()=>QP,onUnmounted:()=>KP,onServer:()=>CP,onMounted:()=>JP,onMount:()=>NY,onHydrated:()=>DQ,onErrorCaptured:()=>$w,onDestroy:()=>RY,onDeactivated:()=>gH,onClient:()=>SP,onBeforeUpdate:()=>XP,onBeforeUnmount:()=>GP,onBeforeMount:()=>YP,onActivated:()=>fH,observeElement:()=>GU,notFound:()=>Lx,nextTick:()=>eA,navigateTo:()=>FP,mountInstance:()=>WP,motionDirective:()=>JZ,moderateCspPreset:()=>PZ,minifyHtml:()=>mV,metaDirective:()=>zY,mergeParams:()=>rJ,mergeHeadConfigs:()=>r6,mergeCspDirectives:()=>YE,matchRoute:()=>hJ,markdownDirectiveHandler:()=>cQ,markdownCache:()=>jJ,localizePath:()=>l4,loadTranslationLazy:()=>h7,loadTranslation:()=>mq,loadStxConfig:()=>u0,loadMiddlewareFromDirectory:()=>p8,loadManifest:()=>CK,loadElement:()=>m4,loadChannels:()=>sV,lintStxStrict:()=>Cw,lazyLoadAll:()=>XU,lazyLoad:()=>JU,keyframeDirective:()=>Nz,jsxs:()=>_w,jsxDEV:()=>qw,jsx:()=>A$,jsonResponse:()=>Hx,islandDirective:()=>t9,isTest:()=>I7,isSpaNavigation:()=>FK,isSignatureValid:()=>tJ,isSignal:()=>Z8,isSharpAvailable:()=>f5,isServerEnvironment:()=>ty,isServer:()=>WV,isProduction:()=>y$,isNativeLazySupported:()=>ZX,isMarkdownPath:()=>UX,isLoading:()=>yE,isLoaded:()=>xE,isJavaScriptScript:()=>IO,isIntersectionObserverSupported:()=>YX,isImageFile:()=>g5,isImageBackendAvailable:()=>e1,isICUFormat:()=>pq,isHydrated:()=>IQ,isHydrateTrigger:()=>DO,isEdgeEnvironment:()=>oy,isDirectiveKind:()=>Pw,isDevelopment:()=>Y6,isDerived:()=>Y8,isCssOnlyChange:()=>D8,isClient:()=>UV,isAsyncComponent:()=>IH,invert:()=>SW,invalidateFileCacheByDir:()=>Aj,invalidateFileCache:()=>Fj,interpolateScriptsInTemplate:()=>q_,interpolateScriptExpressions:()=>w7,inlineError:()=>H0,injectThemeBootstrap:()=>N3,injectSeoTags:()=>c2,injectSeo:()=>F3,injectRouterScript:()=>S4,injectHotReload:()=>F4,injectHeatmap:()=>dX,injectCspMetaTag:()=>k9,injectCrosswindCSS:()=>y0,injectConfigHeadTags:()=>ZQ,injectColorModeBootScript:()=>r7,injectCloakStyle:()=>$Q,injectBrowserCoreAutoImports:()=>d6,injectAnalytics:()=>z9,inject:()=>sA,initStoreRegistry:()=>TP,initNetlify:()=>yL,initLoadingIndicator:()=>sv,initLazyLoading:()=>YU,initFile:()=>tK,initBlurUp:()=>JX,initAllBlurUp:()=>BU,imgDirective:()=>M8,imageDirective:()=>zK,hydrateTemplateStream:()=>YW,hydrateTemplate:()=>cx,hydrateIslands:()=>pv,hydrateIsland:()=>MQ,hydrateFragment:()=>px,hydrateByStrategy:()=>TQ,hydrateAll:()=>EQ,hydrate:()=>Qf,htmlResponse:()=>xv,hoistLeadingHeadTags:()=>Hj,heatmapDirective:()=>uX,hashString:()=>aY,hashFilePath:()=>o$,hashFile:()=>J1,hashBuffer:()=>xO,hasVueTemplateSyntax:()=>zj,hasVariables:()=>P2,hasStore:()=>NA,hasPlaceholders:()=>E$,hasNetlifyConfig:()=>v8,hasMiddleware:()=>VP,hasEventDirectives:()=>CT,hasDocumentShell:()=>LY,hasDirectives:()=>FO,hasDOMSupport:()=>Hz,handleImageRequest:()=>d8,handleError:()=>Zw,h:()=>Vw,groupVariantsByFormat:()=>U$,grayscale:()=>DW,gitHash:()=>QW,getUnusedDirectives:()=>fV,getTranslationSync:()=>uq,getTranslationCacheStats:()=>CE,getTranslationAsync:()=>fE,getTranslation:()=>lZ,getTotalSize:()=>y4,getTimeUntilExpiry:()=>eJ,getStoreNames:()=>RA,getStore:()=>VW,getSourceLineInfo:()=>lQ,getScreenReaderOnlyStyle:()=>YM,getScopeAttribute:()=>eC,getRouteParams:()=>cP,getPublicEnvDefine:()=>A1,getPublicEnv:()=>bz,getPositionInfo:()=>LO,getPlaceholderRegistry:()=>aX,getPlaceholderCacheStats:()=>zG,getPageMeta:()=>fZ,getNonce:()=>Q6,getMimeType:()=>g1,getMiddlewareNames:()=>c8,getMiddleware:()=>LP,getLoadingState:()=>PE,getLoadingLocales:()=>hE,getImageMetadata:()=>G$,getHydrationRuntime:()=>OA,getHydratedStoreState:()=>IP,getHmrServer:()=>C8,getHead:()=>vZ,getHMRHandler:()=>Zf,getFormatExtension:()=>$G,getFileMtime:()=>w8,getFallbackVariant:()=>W$,getErrorMessage:()=>H9,getErrorLocale:()=>f_,getErrorConfig:()=>D7,getErrorCodeName:()=>RZ,getDirectives:()=>fS,getDirective:()=>vS,getCurrentInstance:()=>ab,getCspPreset:()=>ZE,getCspHeaderName:()=>Oq,getCrosswindServeAsset:()=>J9,getComponentCacheStats:()=>xS,getCachedVideoResult:()=>F5,getCachedSignature:()=>rW,getCachedSignalsRuntime:()=>Rj,getCachedRouterScript:()=>Mj,getCachedPlaceholder:()=>A8,getCachedImageResult:()=>O5,getCached:()=>q5,getCacheStats:()=>dO,getBroadcastServer:()=>nV,getBestVariant:()=>eQ,getAllFilters:()=>tX,generateWidthSrcset:()=>O6,generateVirtualListCSS:()=>BQ,generateVideoPreview:()=>LU,generateValidationScript:()=>DE,generateUploadRuntime:()=>L3,generateTreeShakenBundle:()=>gV,generateTransitionRuntime:()=>_H,generateTransitionCSS:()=>zH,generateThumbnails:()=>N5,generateThumbhashPlaceholder:()=>JG,generateTemplatesDocs:()=>OF,generateSuspenseRuntime:()=>AH,generateSuspenseCSS:()=>FH,generateStateScript:()=>jA,generateSrcsetData:()=>oQ,generateSrcset:()=>eY,generateSrcSet:()=>M6,generateSpriteSheet:()=>KJ,generateSpaShell:()=>Cf,generateSourceTags:()=>tQ,generateSizesFromBreakpoints:()=>rQ,generateSizesAttribute:()=>K5,generateSizes:()=>K$,generateSitemapIndex:()=>YD,generateSitemap:()=>A3,generateSimpleMediaPicker:()=>fA,generateSignatureRuntime:()=>q3,generateSignalsRuntimeDev:()=>$$,generateSignalsRuntime:()=>X8,generateServerDataBridge:()=>O7,generateScopeId:()=>_J,generateSFCWebComponent:()=>wL,generateRouteTypes:()=>iP,generateRouteManifest:()=>pP,generateRobotsTxt:()=>Qj,generateRobots:()=>w3,generateResponsiveVariants:()=>tY,generateReactiveWebComponentTS:()=>Yb,generateReactiveWebComponent:()=>Zb,generateReactiveRuntime:()=>Xb,generateReactiveMixin:()=>Jb,generatePoster:()=>w5,generatePlaceholderStyle:()=>WG,generatePlaceholderCSS:()=>F8,generatePlaceholder:()=>V8,generatePartialHydrationCSS:()=>RQ,generateNonce:()=>I9,generateNetlifyToml:()=>NJ,generateMinifiedMediaRuntime:()=>lA,generateMediaRuntime:()=>FU,generateMediaManagerEmbed:()=>vA,generateManifest:()=>kK,generateLoadingIndicatorHtml:()=>tv,generateLazyLoadRuntime:()=>B3,generateLQIP:()=>QG,generateKeepAliveRuntime:()=>vH,generateKeepAliveCSS:()=>xH,generateIslandManifest:()=>SQ,generateImagePreview:()=>OU,generateImageManifest:()=>bJ,generateHydrationScript:()=>Xf,generateHydrationRuntime:()=>YB,generateHydrationCSS:()=>Gf,generateHydrationBootstrap:()=>VQ,generateHotReloadScript:()=>bL,generateHeatmapScript:()=>hX,generateHMRClientScript:()=>ev,generateHLSManifest:()=>R5,generateEventBindings:()=>Jf,generateDprSrcsetWithVariableQuality:()=>nQ,generateDprSrcset:()=>G5,generateDocumentShell:()=>Oj,generateDocs:()=>wF,generateDirectivesDocs:()=>LF,generateDirectiveRuntime:()=>mS,generateDefaultRobotsTxt:()=>XD,generateDASHManifest:()=>M5,generateCspMetaTag:()=>yZ,generateCspHeader:()=>D9,generateCrosswindCSS:()=>VZ,generateCompositionRuntime:()=>Gw,generateComponentsDocs:()=>HF,generateComponentManifest:()=>yk,generateComponentDoc:()=>jF,generateColorPlaceholder:()=>KG,generateColorModeBootScript:()=>OY,generateClientRuntime:()=>_P,generateCacheKey:()=>z5,generateBrowserAutoImportDestructuring:()=>pz,generateBlurUpRuntime:()=>H3,generateBlurUpCSS:()=>O3,generateBindingsRuntime:()=>R_,generateAutoWidthSrcset:()=>iQ,generateAutoImportDestructuring:()=>KZ,generateAsyncComponentRuntime:()=>kH,generateAsyncComponentCSS:()=>DH,generateAnimationRuntime:()=>FM,generateAnimationCSS:()=>LM,generateAnalyticsScript:()=>U9,formatTypeErrors:()=>cv,formatStxContent:()=>pJ,formatSize:()=>R6,formatRoutes:()=>wK,formatMarkdownContent:()=>aK,formatLocalizedError:()=>d_,formatICU:()=>lq,formatFilePath:()=>k7,formatError:()=>EZ,formatDoctorReport:()=>BX,formatDocsAsMarkdown:()=>VF,formatDocsAsJson:()=>AF,formatDocsAsHtml:()=>FF,format:()=>fW,foldConstants:()=>uV,flipVertical:()=>vW,flipHorizontal:()=>xW,fingerprint:()=>NK,findPantryPackage:()=>kU,findMatchingEndTag:()=>X6,findMatchingDelimiter:()=>s0,findIfBlocks:()=>g$,findExpressions:()=>Qq,findErrorPage:()=>AK,findDirectiveBlocks:()=>P7,findDeadCode:()=>hV,findDeadBranches:()=>hV,findComponentFiles:()=>mK,findCommonDir:()=>hU,filterRequiredFiles:()=>y8,fileExists:()=>Q0,extractVariables:()=>k0,extractStreamBoundaries:()=>sq,extractState:()=>HA,extractSlotContent:()=>MO,extractScriptFromTemplate:()=>b2,extractPlaceholders:()=>ZT,extractParenthesizedExpression:()=>D4,extractPageResponseStatus:()=>xJ,extractLayoutMetadata:()=>s8,extractDominantColor:()=>GG,extractDirectiveParams:()=>Kq,extractDirectiveNames:()=>AO,extractContainerContent:()=>a8,extractComponentProps:()=>qF,extractComponentName:()=>FQ,extractComponentDescription:()=>BF,extractClassNames:()=>LZ,extractBridgeData:()=>r4,extractBoundProps:()=>AQ,extractBalancedExpression:()=>A9,extractAndStripCssImports:()=>j7,extractAndScopeStyles:()=>$b,extractAndProcessEvents:()=>k_,evaluateExpression:()=>K1,evaluateConstant:()=>mJ,evaluateAuthExpression:()=>I4,escapeHtml:()=>f0,errorRecovery:()=>IZ,errorLogger:()=>W1,ensureTeleportTargets:()=>YH,ensureDocumentShell:()=>s7,enhancedValidationRules:()=>u9,eliminateDeadCode:()=>dV,effect:()=>$8,dprUrls:()=>lW,docsCommand:()=>lK,disconnectObserver:()=>KU,devHelpers:()=>f$,detectShell:()=>VK,detectRuntime:()=>c5,detectProjectConfig:()=>y5,detectFormat:()=>ZG,detectBuildMode:()=>Fy,derived:()=>e7,deploy:()=>PL,defineStxConfig:()=>ML,defineStore:()=>TA,defineSlots:()=>Jw,defineSiteConfig:()=>gU,definePropsWithValidation:()=>hw,defineProps:()=>gw,definePlugin:()=>I5,definePageMeta:()=>Mq,defineMiddleware:()=>OP,defineExpose:()=>tA,defineEmits:()=>oA,defineDirective:()=>m0,defineCustomElement:()=>Aw,defineConfig:()=>lx,defineClientDirective:()=>hS,defineAsyncComponent:()=>EH,defaultMediaConfig:()=>Rf,defaultImageConfig:()=>tL,defaultI18nConfig:()=>cZ,defaultHeatmapConfig:()=>Dz,defaultFormClasses:()=>dZ,defaultFilters:()=>D$,defaultCspConfig:()=>GE,defaultConfig:()=>R1,default:()=>Pg,dedupeScopedStyles:()=>t2,decodeThumbhash:()=>XG,cspNonceDirective:()=>Hq,cspDirective:()=>jq,crossfadeTransition:()=>qU,crop:()=>NW,createVirtualList:()=>xY,createVideoDirective:()=>zJ,createVercelHandler:()=>_x,createTypeChecker:()=>UW,createTranslateFilter:()=>XI,createTextEncoderStream:()=>Kx,createStxApp:()=>MU,createStreamingResponse:()=>Gx,createStreamRenderer:()=>tq,createStore:()=>FW,createStorageManager:()=>HP,createServerCookieManager:()=>jP,createScope:()=>ZV,createSSRSuspense:()=>LH,createRouter:()=>h4,createRouteLocation:()=>l8,createRoute:()=>gv,createRef:()=>ob,createReactive:()=>YV,createProvideContext:()=>Qw,createProject:()=>sx,createProductionBuild:()=>mx,createPlaceholder:()=>L7,createOptimizedBuild:()=>wy,createNetlifyHandler:()=>qx,createNetlifyClient:()=>b8,createMiddlewareContext:()=>m8,createMiddleware:()=>fv,createLazyObserver:()=>QU,createKeepAliveCache:()=>PH,createKVNamespace:()=>MF,createIslandRegistry:()=>wQ,createImgDirective:()=>JJ,createImagePlugin:()=>_K,createImageHandler:()=>TJ,createImageDirective:()=>kJ,createHeatmapAggregator:()=>RM,createFileManifest:()=>P8,createEnvAccessor:()=>RF,createEnhancedError:()=>n_,createEdgeHandler:()=>$3,createEdgeCache:()=>TF,createDetailedErrorMessage:()=>E0,createDenoHandler:()=>zx,createDefaultNetlifyConfig:()=>x5,createCspHeaders:()=>QE,createCookie:()=>jx,createComputed:()=>tb,createComponentInstance:()=>sb,createCloudflareHandler:()=>Ux,createClientCookieManager:()=>BP,createBuiltinDirectives:()=>uS,createApp:()=>MU,createAnimationTimeline:()=>OM,cover:()=>TW,convertToCommonJS:()=>$Y,contrast:()=>bW,contain:()=>MW,consoleError:()=>i_,configureErrorHandling:()=>m_,config:()=>E1,computed:()=>tb,composeShellWithPage:()=>r8,componentDirective:()=>QF,componentClientSignalNames:()=>SO,compileTemplate:()=>EK,collectDeployFiles:()=>P5,clearVideoCache:()=>QJ,clearTranslationCache:()=>SE,clearSignatureCache:()=>aW,clearPlaceholderCache:()=>UG,clearOnceStore:()=>oI,clearNonce:()=>$E,clearMiddleware:()=>u8,clearImageCache:()=>DJ,clearErrorMessages:()=>h_,clearDevCaches:()=>Tj,clearCustomFilters:()=>__,clearComponentCache:()=>O4,clearCache:()=>j5,cleanupLoadingIndicator:()=>ov,classifyScript:()=>qV,classifyAllScripts:()=>HK,checkTemplateFile:()=>mv,checkTemplate:()=>lv,checkCache:()=>DY,checkAuthAccess:()=>s5,checkA11y:()=>o3,channel:()=>ZF,captureScreenshots:()=>bF,captureScreenshot:()=>nK,cancelPendingLoads:()=>dE,calculateSha1:()=>wJ,calculateOptimalWidths:()=>iY,cacheTemplate:()=>kY,buildWebComponents:()=>uG,buildViews:()=>nA,buildUrl:()=>S0,buildSuspenseResolveScript:()=>iZ,buildStaticSite:()=>vU,buildRuntimeAsset:()=>RK,buildRouterAsset:()=>MK,buildLangPickerScript:()=>E3,buildImageUrl:()=>o1,buildForProduction:()=>DV,buildComponentLibrary:()=>hK,buildAuthParams:()=>_3,buildApp:()=>SV,buildAlternateLinks:()=>T3,build:()=>ux,broadcastPrivate:()=>eV,broadcastPresence:()=>$F,broadcast:()=>vK,brightness:()=>CW,blur:()=>EW,batchSignUrls:()=>oJ,batch:()=>wY,autoFixA11yFile:()=>Vz,autoFixA11yDirectory:()=>QM,autoFixA11y:()=>Lz,auto:()=>hW,assetTags:()=>qy,arrayOf:()=>iw,applyTranslations:()=>M3,applyTransformations:()=>R8,applySlots:()=>TO,applyPropDefaults:()=>Ty,applyPreset:()=>uW,applyHead:()=>kq,applyFilters:()=>eX,apiCspPreset:()=>Bq,animationGroupDirective:()=>YZ,analyzeVideo:()=>T8,analyzeUsage:()=>yK,analyzeTemplate:()=>_V,analyzeProject:()=>jK,analyzeDirectiveUsage:()=>yK,analyticsDirective:()=>TT,addStore:()=>Zv,addPage:()=>$v,addNonceToInlineContent:()=>S9,addLayout:()=>Yv,addComponent:()=>ex,abortNavigation:()=>qP,a11yDirective:()=>t3,__setSignalsGeneratorsForTest:()=>Nj,VideoProcessorCache:()=>V5,TransitionType:()=>Fz,TransitionEase:()=>wz,TransitionDirection:()=>Az,Tokenizer:()=>b7,TemplateTypeChecker:()=>WW,TEMPLATE_PRESETS:()=>Dx,StxValidationError:()=>S7,StxSyntaxError:()=>O9,StxSecurityError:()=>L9,StxRuntimeError:()=>a1,StxFileError:()=>v$,StxError:()=>J6,Show:()=>Hw,SUSPENSE_RESOLVER_RUNTIME:()=>s9,STATE_DIR_ENV_VAR:()=>Pz,SPRING_PRESETS:()=>vX,ProductionBuild:()=>iJ,Portal:()=>Lw,PROJECT_TEMPLATES:()=>ax,PRESETS:()=>aJ,MemorySessionStore:()=>FA,MIME_TYPES:()=>O8,MEDIA_DEFAULT_WIDTHS:()=>V4,MEDIA_DEFAULT_FORMATS:()=>b4,ImageProcessorCache:()=>H5,ImageProcessingError:()=>z$,HydrationRuntime:()=>LW,HotReloadServer:()=>eG,HeatmapAggregator:()=>mX,Fragment:()=>F$,For:()=>Ow,ErrorLogger:()=>DZ,ErrorCodes:()=>G0,DeployError:()=>v4,DEFAULT_WIDTHS:()=>x1,DEFAULT_TRANSITION_OPTIONS:()=>G4,DEFAULT_STATE_DIR:()=>f6,DEFAULT_QUALITY:()=>f1,DEFAULT_PLACEHOLDER_OPTIONS:()=>rY,DEFAULT_FORMATS:()=>v1,DEFAULT_DPR_VALUES:()=>H8,ComponentHMRHandler:()=>HW,COMMON_SIZES:()=>aQ,COLOR_MODE_BOOT_MARKER:()=>SD,COLOR_MODE_BOOT_GLOBAL:()=>CD,CLOAK_STYLE:()=>e2,BroadcastServer:()=>JF,Broadcast:()=>YF,BLUR_UP_CSS:()=>U5});var Pg;var T6=D(()=>{RJ();PJ();R0();D2();n4();IA();p2();wU();Fw();ww();nG();_4();SU();kw();bw();EU();JV();a6();vJ();m9();R$();_9();XZ();f9();Q5();u5();j9();PK();TK();yV();pV();lJ();Y$();GF();dK();a7();a0();b9();x9();RJ();dU();VY();j8();cK();EF();rK();b1();B9();Z1();sK();QZ();r9();n$();eK();$W();GY();mY();d2();y7();dJ();V7();q1();cF();bK();XW();o8();ZA();OK();qY();JA();K4();HY();IK();JW();W6();QA();cG();LQ();CQ();GA();UA();W9();u6();_A();LA();AA();PJ();iA();rA();a$();n2();a2();DU();R0();lY();xw();Pg={}});import b3 from"path";var $7;var VX=D(()=>{T6();b1();Z1();$6();q1();d$();$7={name:"bun-plugin-stx",async setup($){let Y={...await u0(),...$.config?.stx},J=new Set,X=Y.webComponents?.enabled?`./${b3.relative(b3.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await uG(Y,J);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await DY(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await q4(()=>Bun.file(G).text(),"",(H)=>{throw new v$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new v$(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:z,allScripts:_}=i1.time("script-extraction",()=>{let H=W,O=B4(W);if(O)H=O.content.trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let w of V){let N=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=w.match(/<script\b([^>]*)>/i),E=R?R[1]:"";if(/\bserver\b/i.test(E))L=N;else F.push(w)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),q={__filename:G,__dirname:b3.dirname(G),__stx:{webComponentsPath:X,builtComponents:Q}};await q4(()=>k0(U,q,G),void 0,(H)=>{let O=new a1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(W1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await i1.timeAsync("directive-processing",async()=>{return await B0(z,q,G,Y,K)});if(_.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (Z1(),N7)),O=H(_.join(`
17933
+ ${W}`)}return{props:G,validation:K}}function dw($,Z){let Y={...$};for(let[J,X]of Object.entries(Z))if(Y[J]===void 0)Y[J]=typeof X==="function"?X():X;return Y}function uw($){return $}function mw($){return{type:$,required:!0}}function lw($,Z){return{type:Z,default:$}}function cw($,Z={}){return{...Z,validator:$}}function pw($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function iw($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function nw($,Z={}){return{...Z,type:Object}}function rw($,Z,Y){if(!Z)return $;let J={};for(let[X,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[X];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=fw(X,K,G,Y);if(W)console.warn(W.message)}J[X]=K}for(let[X,Q]of Object.entries($))if(!(X in J))J[X]=Q;return J}var B$={};$0(B$,{writeNetlifyConfig:()=>x8,writeManifest:()=>SK,writeImageManifest:()=>BK,wrapComponentForHMR:()=>Zf,withDefaults:()=>dw,webComponentDirectiveHandler:()=>lG,watermark:()=>dW,watchViews:()=>Tf,watchMultiple:()=>$P,watchEffect:()=>ZP,watch:()=>eb,waitForStore:()=>NP,waitForLocale:()=>gE,videoDirective:()=>E8,validators:()=>kZ,validated:()=>cw,validateValueEnhanced:()=>fq,validateTemplate:()=>OO,validateParams:()=>cW,validateFormEnhanced:()=>IE,validateFile:()=>XX,validateFields:()=>TE,validateField:()=>xq,validateDirective:()=>VO,validateCspDirectives:()=>XE,validateConfig:()=>TL,validateComponentScripts:()=>Ay,validateComponentProps:()=>My,validateClientScript:()=>W8,usesSignalsInScript:()=>l6,userComponentFileExists:()=>p7,useVirtualList:()=>jQ,useTitle:()=>Tq,useStoreOrThrow:()=>wP,useStore:()=>MA,useSlots:()=>Yw,useSeoMeta:()=>g9,useRouteParams:()=>QV,useRouteParamOrThrow:()=>RP,useRouteParam:()=>GV,usePageTitle:()=>Tq,useOptimistic:()=>Lj,useMiddlewareValue:()=>MP,useMiddlewareState:()=>KV,useLoadingIndicator:()=>WA,useHead:()=>gZ,useAttrs:()=>Xw,uploadFiles:()=>HU,uploadFile:()=>QX,updateInstance:()=>UP,untrack:()=>MY,unregisterDirective:()=>gS,unmountInstance:()=>zP,unescapeHtml:()=>BZ,transpileTypeScript:()=>o4,translate:()=>jX,transitionDirective:()=>$Z,toUsers:()=>tV,toUser:()=>oV,thumbnail:()=>RW,thumbHashToRGBA:()=>j3,thumbHashToDataURL:()=>zU,templateCache:()=>JQ,stxClientHelpers:()=>jW,structuredDataDirective:()=>_Y,stripLocalePrefix:()=>PU,stripDocumentWrapper:()=>g4,stripCommentsAndLiterals:()=>pX,stringToStream:()=>Wx,strictCspPreset:()=>_q,streamingSuspenseDirective:()=>o9,streamToResponse:()=>ZB,streamTemplateSimple:()=>oq,streamTemplate:()=>nq,stopHmrServer:()=>b5,stopBroadcasting:()=>aV,stateDirName:()=>M$,stateDir:()=>p0,state:()=>t7,startProductionServer:()=>nF,startInteractive:()=>dF,startBroadcasting:()=>rV,staggerDirective:()=>Rz,srcsetUrls:()=>mW,springDirective:()=>Mz,splitByPipe:()=>SZ,smartBatchSign:()=>nW,slotContentHasExpressions:()=>kO,signUrl:()=>sJ,shouldTranspileTypeScript:()=>s4,shouldReloadOnChange:()=>k8,shouldRefreshSignature:()=>$X,shouldIgnoreFile:()=>S8,shouldCacheComponent:()=>yH,sharpen:()=>IW,shape:()=>nw,setStateDir:()=>lX,setRouteParams:()=>DP,setMiddlewareState:()=>kP,setGlobalProvide:()=>WX,setErrorLocale:()=>v_,setCurrentInstance:()=>rb,setCachedVideoResult:()=>A5,setCachedImageResult:()=>L5,setCached:()=>B5,serveStxFile:()=>k3,serveMultipleStxFiles:()=>S3,serveMarkdownFile:()=>AJ,serveFile:()=>fv,serveApp:()=>C3,serve:()=>YA,serializeState:()=>qA,sepia:()=>kW,seoMetaToHeadConfig:()=>x7,scrollAnimateDirective:()=>ZZ,screenReaderDirective:()=>e3,scopeHTML:()=>FL,scopeCSS:()=>VL,scanForSitemapEntries:()=>JD,scanA11yIssues:()=>xX,saturation:()=>PW,sanitizeParams:()=>pW,sanitizeFilePath:()=>o_,sanitizeExpression:()=>t_,sanitizeDirectiveParams:()=>e_,sanitizeDirectiveParam:()=>C7,sanitizeComponentProps:()=>F9,safeExecuteAsync:()=>q4,safeExecute:()=>r_,runPreProcessingMiddleware:()=>g2,runPostProcessingMiddleware:()=>h2,runMiddleware:()=>i8,runHooks:()=>q$,runDoctor:()=>qX,rotate:()=>yW,rewriteImagesWithSiblings:()=>gY,resolveTemplatePath:()=>q8,resolveI18n:()=>R3,resize:()=>wW,resetPlaceholders:()=>rX,resetHead:()=>Rq,resetHMRHandler:()=>Jf,resetErrorConfig:()=>l_,required:()=>mw,replacePlaceholders:()=>qZ,renderView:()=>AU,renderVideoComponent:()=>T5,renderVendorStyleTags:()=>H7,renderToString:()=>V$,renderToStream:()=>jw,renderToDOM:()=>o5,renderThumbhashToCanvas:()=>UU,renderTemplateString:()=>V3,renderTemplate:()=>IU,renderString:()=>df,renderStreamingPage:()=>rq,renderSlot:()=>gQ,renderSSRSuspense:()=>VH,renderProtectedVideo:()=>eW,renderProtectedImg:()=>tW,renderMediaUpload:()=>iW,renderMarkdownView:()=>zX,renderImgComponent:()=>F6,renderImageComponent:()=>KK,renderHtmlAttrs:()=>Iq,renderHead:()=>Eq,renderEmail:()=>Ef,renderComponentWithSlot:()=>j4,renderBodyAttrs:()=>Dq,render:()=>Wf,relaxedCspPreset:()=>qq,registerValidationRule:()=>ME,registerStreamingDirectives:()=>eq,registerStoresClient:()=>EA,registerStore:()=>EP,registerSeoDirectives:()=>ZD,registerMiddleware:()=>AP,registerFilters:()=>z_,registerFilter:()=>oX,registerErrorMessages:()=>g_,registerEnhancedValidationRule:()=>EE,registerDirective:()=>CO,registerCspDirectives:()=>JE,registerComponentDirectives:()=>Iy,registerAnimationDirectives:()=>AM,registerA11yDirectives:()=>GM,ref:()=>ob,redirect:()=>Ox,rebaseOntoStateDir:()=>T$,readMarkdownFile:()=>P4,readFileCached:()=>Vj,reactive:()=>YV,quality:()=>gW,pruneSignatureCache:()=>sW,pruneCache:()=>uO,provide:()=>aA,protectCodeBlocks:()=>TU,prop:()=>uw,processVueTemplate:()=>i2,processVirtualListDirectives:()=>vY,processVirtualGridDirectives:()=>OQ,processVideo:()=>UJ,processValidateDirective:()=>vq,processTranslateDirective:()=>n9,processTransitionDirectives:()=>UH,processTransitionAttributes:()=>qH,processTitleDirective:()=>Cq,processTemplateBindings:()=>K9,processTeleportDirectives:()=>ZH,processSuspenseDirectives:()=>OH,processStructuredData:()=>m2,processStreamDirectives:()=>aq,processStaticDirectives:()=>kQ,processStackReplacements:()=>UY,processStackPushDirectives:()=>WY,processSlots:()=>hQ,processShell:()=>gJ,processServerBindings:()=>BY,processSeoDirective:()=>l2,processSectionDirectives:()=>$B,processScopedStyles:()=>n7,processReactiveBindings:()=>N_,processProtectedMedia:()=>$U,processPartialHydrationDirectives:()=>NQ,processOnceDirective:()=>K8,processMiddleware:()=>f2,processMetaDirectives:()=>u2,processMetaDirective:()=>bq,processMarkdownFileDirectives:()=>vQ,processMarkdownDirectives:()=>xQ,processLoops:()=>QY,processKeepAliveDirectives:()=>bH,processJsonDirective:()=>G8,processInfiniteListDirectives:()=>HQ,processIncludes:()=>KY,processImgComponents:()=>MG,processImageComponents:()=>WK,processImage:()=>$4,processHeadDirective:()=>Sq,processForms:()=>RE,processFormInputDirectives:()=>uZ,processExpressions:()=>u1,processEventDirectives:()=>q9,processErrorDirective:()=>mZ,processDynamicComponents:()=>r2,processDirectives:()=>B0,processDirectiveAttributes:()=>lS,processDeferDirectives:()=>tj,processCustomDirectives:()=>y9,processCspDirectives:()=>C9,processComponentProps:()=>rw,processClientScript:()=>a4,processBasicFormDirectives:()=>h$,processAsyncDirectives:()=>TH,processAppearanceBootstrapDirective:()=>v9,processAnimationDirectives:()=>fX,processA11yDirectives:()=>yX,preloadTranslationsBackground:()=>vE,preloadTranslations:()=>dq,preloadIslandHandlers:()=>nv,preloadIconCollection:()=>N2,poolStrings:()=>lV,pluginManager:()=>iG,performLeave:()=>WH,performEnter:()=>KH,peek:()=>J8,partialsCache:()=>_6,parseVideoDirectiveOptions:()=>BL,parseUrl:()=>AW,parseThumbhashString:()=>_U,parseSwitchBlock:()=>CZ,parseSlots:()=>fQ,parseSlotElement:()=>NO,parseScriptDeclarations:()=>Wq,parseSFCComponent:()=>AL,parseProtectedArgs:()=>ZU,parseImgComponent:()=>YJ,parseImageUrl:()=>sQ,parseImageComponent:()=>EJ,parseExpressionWithFilters:()=>Gq,parseCookies:()=>Bx,parseConditionalBlock:()=>w9,parseArguments:()=>N9,parseAnimationShorthand:()=>VM,optional:()=>lw,optimizeTemplate:()=>cV,optimizeImage:()=>CJ,optimizeDirectory:()=>qK,oneOf:()=>pw,onceStore:()=>x2,onUpdated:()=>QP,onUnmounted:()=>KP,onServer:()=>CP,onMounted:()=>JP,onMount:()=>NY,onHydrated:()=>DQ,onErrorCaptured:()=>$w,onDestroy:()=>RY,onDeactivated:()=>gH,onClient:()=>SP,onBeforeUpdate:()=>XP,onBeforeUnmount:()=>GP,onBeforeMount:()=>YP,onActivated:()=>fH,observeElement:()=>GU,notFound:()=>Lx,nextTick:()=>eA,navigateTo:()=>FP,mountInstance:()=>WP,motionDirective:()=>JZ,moderateCspPreset:()=>PZ,minifyHtml:()=>mV,metaDirective:()=>zY,mergeParams:()=>rJ,mergeHeadConfigs:()=>r6,mergeCspDirectives:()=>YE,matchRoute:()=>hJ,markdownDirectiveHandler:()=>cQ,markdownCache:()=>jJ,localizePath:()=>l4,loadTranslationLazy:()=>h7,loadTranslation:()=>mq,loadStxConfig:()=>u0,loadMiddlewareFromDirectory:()=>p8,loadManifest:()=>CK,loadElement:()=>m4,loadChannels:()=>sV,lintStxStrict:()=>Cw,lazyLoadAll:()=>XU,lazyLoad:()=>JU,keyframeDirective:()=>Nz,jsxs:()=>_w,jsxDEV:()=>qw,jsx:()=>A$,jsonResponse:()=>Hx,islandDirective:()=>t9,isTest:()=>I7,isSpaNavigation:()=>FK,isSignatureValid:()=>tJ,isSignal:()=>Z8,isSharpAvailable:()=>f5,isServerEnvironment:()=>ty,isServer:()=>WV,isProduction:()=>y$,isNativeLazySupported:()=>ZX,isMarkdownPath:()=>UX,isLoading:()=>yE,isLoaded:()=>xE,isJavaScriptScript:()=>IO,isIntersectionObserverSupported:()=>YX,isImageFile:()=>g5,isImageBackendAvailable:()=>e1,isICUFormat:()=>pq,isHydrated:()=>IQ,isHydrateTrigger:()=>DO,isEdgeEnvironment:()=>oy,isDirectiveKind:()=>Pw,isDevelopment:()=>Y6,isDerived:()=>Y8,isCssOnlyChange:()=>D8,isClient:()=>UV,isAsyncComponent:()=>IH,invert:()=>SW,invalidateFileCacheByDir:()=>Aj,invalidateFileCache:()=>Fj,interpolateScriptsInTemplate:()=>q_,interpolateScriptExpressions:()=>w7,inlineError:()=>H0,injectThemeBootstrap:()=>N3,injectSeoTags:()=>c2,injectSeo:()=>F3,injectRouterScript:()=>S4,injectHotReload:()=>F4,injectHeatmap:()=>dX,injectCspMetaTag:()=>k9,injectCrosswindCSS:()=>y0,injectConfigHeadTags:()=>ZQ,injectColorModeBootScript:()=>r7,injectCloakStyle:()=>$Q,injectBrowserCoreAutoImports:()=>d6,injectAnalytics:()=>z9,inject:()=>sA,initStoreRegistry:()=>TP,initNetlify:()=>yL,initLoadingIndicator:()=>ov,initLazyLoading:()=>YU,initFile:()=>tK,initBlurUp:()=>JX,initAllBlurUp:()=>BU,imgDirective:()=>M8,imageDirective:()=>zK,hydrateTemplateStream:()=>YW,hydrateTemplate:()=>cx,hydrateIslands:()=>iv,hydrateIsland:()=>MQ,hydrateFragment:()=>px,hydrateByStrategy:()=>TQ,hydrateAll:()=>EQ,hydrate:()=>Gf,htmlResponse:()=>vv,hoistLeadingHeadTags:()=>Hj,heatmapDirective:()=>uX,hashString:()=>aY,hashFilePath:()=>o$,hashFile:()=>J1,hashBuffer:()=>xO,hasVueTemplateSyntax:()=>zj,hasVariables:()=>P2,hasStore:()=>NA,hasPlaceholders:()=>E$,hasNetlifyConfig:()=>v8,hasMiddleware:()=>VP,hasEventDirectives:()=>CT,hasDocumentShell:()=>LY,hasDirectives:()=>FO,hasDOMSupport:()=>Hz,handleImageRequest:()=>d8,handleError:()=>Zw,h:()=>Vw,groupVariantsByFormat:()=>U$,grayscale:()=>DW,gitHash:()=>QW,getUnusedDirectives:()=>fV,getTranslationSync:()=>uq,getTranslationCacheStats:()=>CE,getTranslationAsync:()=>fE,getTranslation:()=>lZ,getTotalSize:()=>y4,getTimeUntilExpiry:()=>eJ,getStoreNames:()=>RA,getStore:()=>VW,getSourceLineInfo:()=>lQ,getScreenReaderOnlyStyle:()=>YM,getScopeAttribute:()=>eC,getRouteParams:()=>cP,getPublicEnvDefine:()=>A1,getPublicEnv:()=>bz,getPositionInfo:()=>LO,getPlaceholderRegistry:()=>aX,getPlaceholderCacheStats:()=>zG,getPageMeta:()=>fZ,getNonce:()=>Q6,getMimeType:()=>g1,getMiddlewareNames:()=>c8,getMiddleware:()=>LP,getLoadingState:()=>PE,getLoadingLocales:()=>hE,getImageMetadata:()=>G$,getHydrationRuntime:()=>OA,getHydratedStoreState:()=>IP,getHmrServer:()=>C8,getHead:()=>vZ,getHMRHandler:()=>Yf,getFormatExtension:()=>$G,getFileMtime:()=>w8,getFallbackVariant:()=>W$,getErrorMessage:()=>H9,getErrorLocale:()=>f_,getErrorConfig:()=>D7,getErrorCodeName:()=>RZ,getDirectives:()=>fS,getDirective:()=>vS,getCurrentInstance:()=>ab,getCspPreset:()=>ZE,getCspHeaderName:()=>Oq,getCrosswindServeAsset:()=>J9,getComponentCacheStats:()=>xS,getCachedVideoResult:()=>F5,getCachedSignature:()=>rW,getCachedSignalsRuntime:()=>Rj,getCachedRouterScript:()=>Mj,getCachedPlaceholder:()=>A8,getCachedImageResult:()=>O5,getCached:()=>q5,getCacheStats:()=>dO,getBroadcastServer:()=>nV,getBestVariant:()=>eQ,getAllFilters:()=>tX,generateWidthSrcset:()=>O6,generateVirtualListCSS:()=>BQ,generateVideoPreview:()=>LU,generateValidationScript:()=>DE,generateUploadRuntime:()=>L3,generateTreeShakenBundle:()=>gV,generateTransitionRuntime:()=>_H,generateTransitionCSS:()=>zH,generateThumbnails:()=>N5,generateThumbhashPlaceholder:()=>JG,generateTemplatesDocs:()=>OF,generateSuspenseRuntime:()=>AH,generateSuspenseCSS:()=>FH,generateStateScript:()=>jA,generateSrcsetData:()=>oQ,generateSrcset:()=>eY,generateSrcSet:()=>M6,generateSpriteSheet:()=>KJ,generateSpaShell:()=>bf,generateSourceTags:()=>tQ,generateSizesFromBreakpoints:()=>rQ,generateSizesAttribute:()=>K5,generateSizes:()=>K$,generateSitemapIndex:()=>YD,generateSitemap:()=>A3,generateSimpleMediaPicker:()=>fA,generateSignatureRuntime:()=>q3,generateSignalsRuntimeDev:()=>$$,generateSignalsRuntime:()=>X8,generateServerDataBridge:()=>O7,generateScopeId:()=>_J,generateSFCWebComponent:()=>wL,generateRouteTypes:()=>iP,generateRouteManifest:()=>pP,generateRobotsTxt:()=>Qj,generateRobots:()=>w3,generateResponsiveVariants:()=>tY,generateReactiveWebComponentTS:()=>Yb,generateReactiveWebComponent:()=>Zb,generateReactiveRuntime:()=>Xb,generateReactiveMixin:()=>Jb,generatePoster:()=>w5,generatePlaceholderStyle:()=>WG,generatePlaceholderCSS:()=>F8,generatePlaceholder:()=>V8,generatePartialHydrationCSS:()=>RQ,generateNonce:()=>I9,generateNetlifyToml:()=>NJ,generateMinifiedMediaRuntime:()=>lA,generateMediaRuntime:()=>FU,generateMediaManagerEmbed:()=>vA,generateManifest:()=>kK,generateLoadingIndicatorHtml:()=>ev,generateLazyLoadRuntime:()=>B3,generateLQIP:()=>QG,generateKeepAliveRuntime:()=>vH,generateKeepAliveCSS:()=>xH,generateIslandManifest:()=>SQ,generateImagePreview:()=>OU,generateImageManifest:()=>bJ,generateHydrationScript:()=>Qf,generateHydrationRuntime:()=>YB,generateHydrationCSS:()=>Kf,generateHydrationBootstrap:()=>VQ,generateHotReloadScript:()=>bL,generateHeatmapScript:()=>hX,generateHMRClientScript:()=>$f,generateHLSManifest:()=>R5,generateEventBindings:()=>Xf,generateDprSrcsetWithVariableQuality:()=>nQ,generateDprSrcset:()=>G5,generateDocumentShell:()=>Oj,generateDocs:()=>wF,generateDirectivesDocs:()=>LF,generateDirectiveRuntime:()=>mS,generateDefaultRobotsTxt:()=>XD,generateDASHManifest:()=>M5,generateCspMetaTag:()=>yZ,generateCspHeader:()=>D9,generateCrosswindCSS:()=>VZ,generateCompositionRuntime:()=>Gw,generateComponentsDocs:()=>HF,generateComponentManifest:()=>yk,generateComponentDoc:()=>jF,generateColorPlaceholder:()=>KG,generateColorModeBootScript:()=>OY,generateClientRuntime:()=>_P,generateCacheKey:()=>z5,generateBrowserAutoImportDestructuring:()=>pz,generateBlurUpRuntime:()=>H3,generateBlurUpCSS:()=>O3,generateBindingsRuntime:()=>R_,generateAutoWidthSrcset:()=>iQ,generateAutoImportDestructuring:()=>KZ,generateAsyncComponentRuntime:()=>kH,generateAsyncComponentCSS:()=>DH,generateAnimationRuntime:()=>FM,generateAnimationCSS:()=>LM,generateAnalyticsScript:()=>U9,formatTypeErrors:()=>pv,formatStxContent:()=>pJ,formatSize:()=>R6,formatRoutes:()=>wK,formatMarkdownContent:()=>aK,formatLocalizedError:()=>d_,formatICU:()=>lq,formatFilePath:()=>k7,formatError:()=>EZ,formatDoctorReport:()=>BX,formatDocsAsMarkdown:()=>VF,formatDocsAsJson:()=>AF,formatDocsAsHtml:()=>FF,format:()=>fW,foldConstants:()=>uV,flipVertical:()=>vW,flipHorizontal:()=>xW,fingerprint:()=>NK,findPantryPackage:()=>kU,findMatchingEndTag:()=>X6,findMatchingDelimiter:()=>s0,findIfBlocks:()=>g$,findExpressions:()=>Qq,findErrorPage:()=>AK,findDirectiveBlocks:()=>P7,findDeadCode:()=>hV,findDeadBranches:()=>hV,findComponentFiles:()=>mK,findCommonDir:()=>hU,filterRequiredFiles:()=>y8,fileExists:()=>Q0,extractVariables:()=>k0,extractStreamBoundaries:()=>sq,extractState:()=>HA,extractSlotContent:()=>MO,extractScriptFromTemplate:()=>b2,extractPlaceholders:()=>ZT,extractParenthesizedExpression:()=>D4,extractPageResponseStatus:()=>xJ,extractLayoutMetadata:()=>s8,extractDominantColor:()=>GG,extractDirectiveParams:()=>Kq,extractDirectiveNames:()=>AO,extractContainerContent:()=>a8,extractComponentProps:()=>qF,extractComponentName:()=>FQ,extractComponentDescription:()=>BF,extractClassNames:()=>LZ,extractBridgeData:()=>r4,extractBoundProps:()=>AQ,extractBalancedExpression:()=>A9,extractAndStripCssImports:()=>j7,extractAndScopeStyles:()=>$b,extractAndProcessEvents:()=>k_,evaluateExpression:()=>K1,evaluateConstant:()=>mJ,evaluateAuthExpression:()=>I4,escapeHtml:()=>f0,errorRecovery:()=>IZ,errorLogger:()=>W1,ensureTeleportTargets:()=>YH,ensureDocumentShell:()=>s7,enhancedValidationRules:()=>u9,eliminateDeadCode:()=>dV,effect:()=>$8,dprUrls:()=>lW,docsCommand:()=>lK,disconnectObserver:()=>KU,devHelpers:()=>f$,detectShell:()=>VK,detectRuntime:()=>c5,detectProjectConfig:()=>y5,detectFormat:()=>ZG,detectBuildMode:()=>Fy,derived:()=>e7,deploy:()=>PL,defineStxConfig:()=>ML,defineStore:()=>TA,defineSlots:()=>Jw,defineSiteConfig:()=>gU,definePropsWithValidation:()=>hw,defineProps:()=>gw,definePlugin:()=>I5,definePageMeta:()=>Mq,defineMiddleware:()=>OP,defineExpose:()=>tA,defineEmits:()=>oA,defineDirective:()=>m0,defineCustomElement:()=>Aw,defineConfig:()=>lx,defineClientDirective:()=>hS,defineAsyncComponent:()=>EH,defaultMediaConfig:()=>Mf,defaultImageConfig:()=>tL,defaultI18nConfig:()=>cZ,defaultHeatmapConfig:()=>Dz,defaultFormClasses:()=>dZ,defaultFilters:()=>D$,defaultCspConfig:()=>GE,defaultConfig:()=>R1,default:()=>yg,dedupeScopedStyles:()=>t2,decodeThumbhash:()=>XG,cspNonceDirective:()=>Hq,cspDirective:()=>jq,crossfadeTransition:()=>qU,crop:()=>NW,createVirtualList:()=>xY,createVideoDirective:()=>zJ,createVercelHandler:()=>_x,createTypeChecker:()=>UW,createTranslateFilter:()=>XI,createTextEncoderStream:()=>Kx,createStxApp:()=>MU,createStreamingResponse:()=>Gx,createStreamRenderer:()=>tq,createStore:()=>FW,createStorageManager:()=>HP,createServerCookieManager:()=>jP,createScope:()=>ZV,createSSRSuspense:()=>LH,createRouter:()=>h4,createRouteLocation:()=>l8,createRoute:()=>hv,createRef:()=>ob,createReactive:()=>YV,createProvideContext:()=>Qw,createProject:()=>ox,createProductionBuild:()=>mx,createPlaceholder:()=>L7,createOptimizedBuild:()=>wy,createNetlifyHandler:()=>qx,createNetlifyClient:()=>b8,createMiddlewareContext:()=>m8,createMiddleware:()=>gv,createLazyObserver:()=>QU,createKeepAliveCache:()=>PH,createKVNamespace:()=>MF,createIslandRegistry:()=>wQ,createImgDirective:()=>JJ,createImagePlugin:()=>_K,createImageHandler:()=>TJ,createImageDirective:()=>kJ,createHeatmapAggregator:()=>RM,createFileManifest:()=>P8,createEnvAccessor:()=>RF,createEnhancedError:()=>n_,createEdgeHandler:()=>$3,createEdgeCache:()=>TF,createDetailedErrorMessage:()=>E0,createDenoHandler:()=>zx,createDefaultNetlifyConfig:()=>x5,createCspHeaders:()=>QE,createCookie:()=>jx,createComputed:()=>tb,createComponentInstance:()=>sb,createCloudflareHandler:()=>Ux,createClientCookieManager:()=>BP,createBuiltinDirectives:()=>uS,createApp:()=>MU,createAnimationTimeline:()=>OM,cover:()=>TW,convertToCommonJS:()=>$Y,contrast:()=>bW,contain:()=>MW,consoleError:()=>i_,configureErrorHandling:()=>m_,config:()=>E1,computed:()=>tb,composeShellWithPage:()=>r8,componentDirective:()=>QF,componentClientSignalNames:()=>SO,compileTemplate:()=>EK,collectDeployFiles:()=>P5,clearVideoCache:()=>QJ,clearTranslationCache:()=>SE,clearSignatureCache:()=>aW,clearPlaceholderCache:()=>UG,clearOnceStore:()=>oI,clearNonce:()=>$E,clearMiddleware:()=>u8,clearImageCache:()=>DJ,clearErrorMessages:()=>h_,clearDevCaches:()=>Tj,clearCustomFilters:()=>__,clearComponentCache:()=>O4,clearCache:()=>j5,cleanupLoadingIndicator:()=>tv,classifyScript:()=>qV,classifyAllScripts:()=>HK,checkTemplateFile:()=>lv,checkTemplate:()=>cv,checkCache:()=>DY,checkAuthAccess:()=>s5,checkA11y:()=>o3,channel:()=>ZF,captureScreenshots:()=>bF,captureScreenshot:()=>nK,cancelPendingLoads:()=>dE,calculateSha1:()=>wJ,calculateOptimalWidths:()=>iY,cacheTemplate:()=>kY,buildWebComponents:()=>uG,buildViews:()=>nA,buildUrl:()=>S0,buildSuspenseResolveScript:()=>iZ,buildStaticSite:()=>vU,buildRuntimeAsset:()=>RK,buildRouterAsset:()=>MK,buildLangPickerScript:()=>E3,buildImageUrl:()=>o1,buildForProduction:()=>DV,buildComponentLibrary:()=>hK,buildAuthParams:()=>_3,buildApp:()=>SV,buildAlternateLinks:()=>T3,build:()=>ux,broadcastPrivate:()=>eV,broadcastPresence:()=>$F,broadcast:()=>vK,brightness:()=>CW,blur:()=>EW,batchSignUrls:()=>oJ,batch:()=>wY,autoFixA11yFile:()=>Vz,autoFixA11yDirectory:()=>QM,autoFixA11y:()=>Lz,auto:()=>hW,assetTags:()=>qy,arrayOf:()=>iw,applyTranslations:()=>M3,applyTransformations:()=>R8,applySlots:()=>TO,applyPropDefaults:()=>Ty,applyPreset:()=>uW,applyHead:()=>kq,applyFilters:()=>eX,apiCspPreset:()=>Bq,animationGroupDirective:()=>YZ,analyzeVideo:()=>T8,analyzeUsage:()=>yK,analyzeTemplate:()=>_V,analyzeProject:()=>jK,analyzeDirectiveUsage:()=>yK,analyticsDirective:()=>TT,addStore:()=>Yv,addPage:()=>Zv,addNonceToInlineContent:()=>S9,addLayout:()=>Jv,addComponent:()=>$v,abortNavigation:()=>qP,a11yDirective:()=>t3,__setSignalsGeneratorsForTest:()=>Nj,VideoProcessorCache:()=>V5,TransitionType:()=>Fz,TransitionEase:()=>wz,TransitionDirection:()=>Az,Tokenizer:()=>b7,TemplateTypeChecker:()=>WW,TEMPLATE_PRESETS:()=>Dx,StxValidationError:()=>S7,StxSyntaxError:()=>O9,StxSecurityError:()=>L9,StxRuntimeError:()=>a1,StxFileError:()=>v$,StxError:()=>J6,Show:()=>Hw,SUSPENSE_RESOLVER_RUNTIME:()=>s9,STATE_DIR_ENV_VAR:()=>Pz,SPRING_PRESETS:()=>vX,ProductionBuild:()=>iJ,Portal:()=>Lw,PROJECT_TEMPLATES:()=>sx,PRESETS:()=>aJ,MemorySessionStore:()=>FA,MIME_TYPES:()=>O8,MEDIA_DEFAULT_WIDTHS:()=>V4,MEDIA_DEFAULT_FORMATS:()=>b4,ImageProcessorCache:()=>H5,ImageProcessingError:()=>z$,HydrationRuntime:()=>LW,HotReloadServer:()=>eG,HeatmapAggregator:()=>mX,Fragment:()=>F$,For:()=>Ow,ErrorLogger:()=>DZ,ErrorCodes:()=>G0,DeployError:()=>v4,DEFAULT_WIDTHS:()=>x1,DEFAULT_TRANSITION_OPTIONS:()=>G4,DEFAULT_STATE_DIR:()=>f6,DEFAULT_QUALITY:()=>f1,DEFAULT_PLACEHOLDER_OPTIONS:()=>rY,DEFAULT_FORMATS:()=>v1,DEFAULT_DPR_VALUES:()=>H8,ComponentHMRHandler:()=>HW,COMMON_SIZES:()=>aQ,COLOR_MODE_BOOT_MARKER:()=>SD,COLOR_MODE_BOOT_GLOBAL:()=>CD,CLOAK_STYLE:()=>e2,BroadcastServer:()=>JF,Broadcast:()=>YF,BLUR_UP_CSS:()=>U5});var yg;var T6=D(()=>{RJ();PJ();R0();D2();n4();IA();p2();wU();Fw();ww();nG();_4();SU();kw();bw();EU();JV();a6();vJ();m9();R$();_9();XZ();f9();Q5();u5();j9();PK();TK();yV();pV();lJ();Y$();GF();dK();a7();a0();b9();x9();RJ();dU();VY();j8();cK();EF();rK();b1();B9();Z1();sK();QZ();r9();n$();eK();$W();GY();mY();d2();y7();dJ();V7();q1();cF();bK();XW();o8();ZA();OK();qY();JA();K4();HY();IK();JW();W6();QA();cG();LQ();CQ();GA();UA();W9();u6();_A();LA();AA();PJ();iA();rA();a$();n2();a2();DU();R0();lY();xw();yg={}});import b3 from"path";var $7;var VX=D(()=>{T6();b1();Z1();$6();q1();d$();$7={name:"bun-plugin-stx",async setup($){let Y={...await u0(),...$.config?.stx},J=new Set,X=Y.webComponents?.enabled?`./${b3.relative(b3.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await uG(Y,J);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await DY(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await q4(()=>Bun.file(G).text(),"",(H)=>{throw new v$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new v$(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:z,allScripts:_}=i1.time("script-extraction",()=>{let H=W,O=B4(W);if(O)H=O.content.trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let w of V){let N=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=w.match(/<script\b([^>]*)>/i),E=R?R[1]:"";if(/\bserver\b/i.test(E))L=N;else F.push(w)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),q={__filename:G,__dirname:b3.dirname(G),__stx:{webComponentsPath:X,builtComponents:Q}};await q4(()=>k0(U,q,G),void 0,(H)=>{let O=new a1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(W1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await i1.timeAsync("directive-processing",async()=>{return await B0(z,q,G,Y,K)});if(_.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (Z1(),N7)),O=H(_.join(`
17934
17934
  `),q),V=j.search(/<\/body>/i);if(V!==-1)j=j.slice(0,V)+O+`
17935
17935
  `+j.slice(V);else j+=`
17936
17936
  ${O}`}if(j=await S4(j),K.forEach((H)=>J.add(H)),Y.cache&&Y.cachePath){if(await kY(G,j,K,Y),Y.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:j,loader:"html"}}catch(K){let W=K instanceof Error?K:new a1(`Plugin processing failed: ${String(K)}`,G);if(W1.log(W,{filePath:G,buildConfig:$.config}),f$.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),Y.debug)console.error("stx Plugin Error:",W);let U=W,z=U.line||null,_=U.context||null;return{contents:Y.debug||Y6()?`<!DOCTYPE html>
@@ -17993,12 +17993,12 @@ ${O}`}if(j=await S4(j),K.forEach((H)=>J.add(H)),Y.cache&&Y.cachePath){if(await k
17993
17993
  <h1>Something went wrong</h1>
17994
17994
  <p>An internal error occurred. Please try again later.</p>
17995
17995
  </body>
17996
- </html>`,loader:"html"}}})}}});var{serve:yg}=globalThis.Bun;import X4 from"fs";import D1 from"path";async function k3($,Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=D1.resolve($);if(!X4.existsSync(K))return console.error(`${T.red}Error: File not found: ${T.bright}${K}${T.reset}`),!1;if(K.endsWith(".md"))return AJ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${T.red}Error: Unsupported file type: ${T.bright}${K}${T.reset}. Only .stx and .md files are supported.`),!1;let W=p0(process.cwd(),"output");X4.mkdirSync(W,{recursive:!0}),console.log(`${T.blue}Building ${T.bright}${$}${T.reset}...`);let U=null,z=async()=>{try{let L={name:"public-assets",setup(N){N.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},F=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,$7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!F.success)return console.error(`${T.red}Build failed:${T.reset}`,F.logs),!1;let A=F.outputs.find((N)=>N.path.endsWith(".html"));if(!A)return console.error(`${T.red}No HTML output found${T.reset}`),!1;return U=await Bun.file(A.path).text(),!0}catch(L){return console.error(`${T.red}Error building stx file:${T.reset}`,L),!1}};if(!await z())return!1;let q=D1.dirname(K);await P$(q);let B=Y;try{if(B=await w6(Y),B!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${B} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}if(X){let L=Z.hmrPort||B+1;Q=C8({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (T6(),B$)),F=await L();if(F?.apiRouter)H=F?.apiRouter,console.log(`${T.blue}Using custom router for API handling${T.reset}`);if(F?.apiRoutes){j=F.apiRoutes;let A=Object.keys(j).length;if(A>0)console.log(`${T.blue}Loaded ${T.bright}${A} API route${A>1?"s":""}${T.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:A,loadChannels:w}=await Promise.resolve().then(() => (lJ(),fK)),N=F.broadcasting;await A(N);let R=N.port??6001;console.log(`${T.magenta}Broadcasting on ${T.cyan}ws://localhost:${R}/ws${T.reset}`);let E=D1.join(process.cwd(),"channels.ts");if(X4.existsSync(E))try{let M=await w(E);console.log(`${T.blue}Loaded ${T.bright}${M} broadcast channel${M!==1?"s":""}${T.blue} from channels.ts${T.reset}`)}catch(M){console.warn(`${T.yellow}Failed to load channels.ts: ${M.message}${T.reset}`)}}catch(A){console.warn(`${T.yellow}Broadcasting failed to start: ${A.message}${T.reset}`)}}catch{}if(console.log(`${T.blue}Starting server on ${T.cyan}http://localhost:${B}/${T.reset}...`),X)console.log(`${T.magenta}Hot reload enabled on ws://localhost:${G}${T.reset}`);let O=yg({port:B,async fetch(L){let F=new URL(L.url);if(H)try{let E=await H.handleRequest(L);if(E.status!==404)return E}catch{}if(j[F.pathname])try{return await j[F.pathname](L)}catch(E){return new Response(JSON.stringify({error:E.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(F.pathname==="/")return(async()=>{let M=await y0(U||"");if(X)M=F4(M,G);if(Z.native)if(M.includes("<head>"))M=M.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(M.includes("<html"))M=M.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;if(Z.titlebarHidden)if(M.includes("<head>"))M=M.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(M.includes("<html"))M=M.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else M=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${M}`;return M})().then((M)=>new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let A=D1.join(W,F.pathname);if(X4.existsSync(A)&&X4.statSync(A).isFile()){let E=Bun.file(A),M=D1.extname(A).toLowerCase(),I="text/plain";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let w=D1.dirname(K),N=D1.join(w,F.pathname);if(X4.existsSync(N)&&X4.statSync(N).isFile()){let E=Bun.file(N),M=D1.extname(N).toLowerCase(),I="text/plain";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let R=D1.join(process.cwd(),"public",F.pathname);if(X4.existsSync(R)&&X4.statSync(R).isFile()){let E=Bun.file(R),M=D1.extname(R).toLowerCase(),I="application/octet-stream";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
17996
+ </html>`,loader:"html"}}})}}});var{serve:xg}=globalThis.Bun;import X4 from"fs";import D1 from"path";async function k3($,Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=D1.resolve($);if(!X4.existsSync(K))return console.error(`${T.red}Error: File not found: ${T.bright}${K}${T.reset}`),!1;if(K.endsWith(".md"))return AJ(K,Z);else if(!K.endsWith(".stx"))return console.error(`${T.red}Error: Unsupported file type: ${T.bright}${K}${T.reset}. Only .stx and .md files are supported.`),!1;let W=p0(process.cwd(),"output");X4.mkdirSync(W,{recursive:!0}),console.log(`${T.blue}Building ${T.bright}${$}${T.reset}...`);let U=null,z=async()=>{try{let L={name:"public-assets",setup(N){N.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},F=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,$7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!F.success)return console.error(`${T.red}Build failed:${T.reset}`,F.logs),!1;let A=F.outputs.find((N)=>N.path.endsWith(".html"));if(!A)return console.error(`${T.red}No HTML output found${T.reset}`),!1;return U=await Bun.file(A.path).text(),!0}catch(L){return console.error(`${T.red}Error building stx file:${T.reset}`,L),!1}};if(!await z())return!1;let q=D1.dirname(K);await P$(q);let B=Y;try{if(B=await w6(Y),B!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${B} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}if(X){let L=Z.hmrPort||B+1;Q=C8({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (T6(),B$)),F=await L();if(F?.apiRouter)H=F?.apiRouter,console.log(`${T.blue}Using custom router for API handling${T.reset}`);if(F?.apiRoutes){j=F.apiRoutes;let A=Object.keys(j).length;if(A>0)console.log(`${T.blue}Loaded ${T.bright}${A} API route${A>1?"s":""}${T.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:A,loadChannels:w}=await Promise.resolve().then(() => (lJ(),fK)),N=F.broadcasting;await A(N);let R=N.port??6001;console.log(`${T.magenta}Broadcasting on ${T.cyan}ws://localhost:${R}/ws${T.reset}`);let E=D1.join(process.cwd(),"channels.ts");if(X4.existsSync(E))try{let M=await w(E);console.log(`${T.blue}Loaded ${T.bright}${M} broadcast channel${M!==1?"s":""}${T.blue} from channels.ts${T.reset}`)}catch(M){console.warn(`${T.yellow}Failed to load channels.ts: ${M.message}${T.reset}`)}}catch(A){console.warn(`${T.yellow}Broadcasting failed to start: ${A.message}${T.reset}`)}}catch{}if(console.log(`${T.blue}Starting server on ${T.cyan}http://localhost:${B}/${T.reset}...`),X)console.log(`${T.magenta}Hot reload enabled on ws://localhost:${G}${T.reset}`);let O=xg({port:B,async fetch(L){let F=new URL(L.url);if(H)try{let E=await H.handleRequest(L);if(E.status!==404)return E}catch{}if(j[F.pathname])try{return await j[F.pathname](L)}catch(E){return new Response(JSON.stringify({error:E.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(F.pathname==="/")return(async()=>{let M=await y0(U||"");if(X)M=F4(M,G);if(Z.native)if(M.includes("<head>"))M=M.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(M.includes("<html"))M=M.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else M="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+M;if(Z.titlebarHidden)if(M.includes("<head>"))M=M.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(M.includes("<html"))M=M.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else M=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${M}`;return M})().then((M)=>new Response(M,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let A=D1.join(W,F.pathname);if(X4.existsSync(A)&&X4.statSync(A).isFile()){let E=Bun.file(A),M=D1.extname(A).toLowerCase(),I="text/plain";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let w=D1.dirname(K),N=D1.join(w,F.pathname);if(X4.existsSync(N)&&X4.statSync(N).isFile()){let E=Bun.file(N),M=D1.extname(N).toLowerCase(),I="text/plain";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}let R=D1.join(process.cwd(),"public",F.pathname);if(X4.existsSync(R)&&X4.statSync(R).isFile()){let E=Bun.file(R),M=D1.extname(R).toLowerCase(),I="application/octet-stream";if(M===".ts"||M===".tsx"){let S=new Bun.Transpiler({loader:M===".tsx"?"tsx":"ts"}),k=await E.text(),x=S.transformSync(k);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(M){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
17997
17997
  ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
17998
17998
  ${T.blue}stx${T.reset} ${T.green}${process.env.stx_VERSION||"v0.0.10"}${T.reset} ${T.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${T.reset}`),console.log(`
17999
17999
  ${T.bright}\u2192 ${T.cyan}http://localhost:${B}/${T.reset}`),console.log(`
18000
18000
  ${T.yellow}Routes:${T.reset}`);let V=D1.relative(process.cwd(),K);if(console.log(` ${T.green}\u2514\u2500 /${T.reset} \u2192 ${T.bright}${V}${T.reset}`),console.log(`
18001
- Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),N6(O.url.toString(),()=>{if(J)X4.watch(D1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),F=FJ(L);await k5(B,{title:D1.basename(K,".stx"),titlebarHidden:Z.titlebarHidden===!0,nativeSidebar:!!F,sidebarConfig:F})}if(J){let L=D1.dirname(K);console.log(`${T.blue}Watching ${T.bright}${L}${T.reset} for changes...`);let F=X4.watch(L,{recursive:!0},async(A,w)=>{if(!w||S8(w))return;if(k8(w)){console.log(`${T.yellow}File ${T.bright}${w}${T.yellow} changed, rebuilding...${T.reset}`),_6.clear(),O4();let N=await z();if(await E7(q),X&&Q)if(N)Q.reload(w);else Q.error("Build failed - check console for details")}else if(D8(w)){if(console.log(`${T.cyan}CSS ${T.bright}${w}${T.cyan} changed${T.reset}`),X&&Q)Q.updateCss(w)}});process.on("SIGINT",()=>{if(F.close(),Q)b5();O.stop(),process.exit(0)})}return!0}var aw=D(()=>{n$();K4();VX();R0();I8();tG()});var{serve:xg}=globalThis.Bun;import C6 from"fs";import L1 from"path";function hU($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((J)=>J.split(L1.sep)),Y=[];for(let J=0;J<Z[0].length;J++){let X=Z[0][J];if(Z.every((Q)=>Q[J]===X))Y.push(X);else break}return Y.join(L1.sep)}async function S3($,Z={}){let Y=Z.port||3000,J=Z.watch!==!1;for(let j of $){let H=L1.resolve(j);if(!C6.existsSync(H))return console.error(`${T.red}Error: File not found: ${T.bright}${H}${T.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${T.red}Error: Unsupported file type: ${T.bright}${H}${T.reset}. Only .stx and .md files are supported.`),!1}let X=p0(process.cwd(),"output");C6.mkdirSync(X,{recursive:!0});let Q=hU($.map((j)=>L1.dirname(L1.resolve(j))));console.log(`${T.blue}Processing ${T.bright}${$.length}${T.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=L1.resolve(j);if(H.endsWith(".md"))try{let{content:V,data:L}=await P4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:E1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),F=Z.markdown?.syntaxHighlighting||E1.markdown?.syntaxHighlighting,A=F?.defaultTheme||"github-dark",w=["github-dark"],N=F?.additionalThemes||[],E=[...new Set([...w,...N])].map((k)=>`<option value="${k}"${k===A?" selected":""}>${k}</option>`).join(`
18001
+ Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),N6(O.url.toString(),()=>{if(J)X4.watch(D1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),F=FJ(L);await k5(B,{title:D1.basename(K,".stx"),titlebarHidden:Z.titlebarHidden===!0,nativeSidebar:!!F,sidebarConfig:F})}if(J){let L=D1.dirname(K);console.log(`${T.blue}Watching ${T.bright}${L}${T.reset} for changes...`);let F=X4.watch(L,{recursive:!0},async(A,w)=>{if(!w||S8(w))return;if(k8(w)){console.log(`${T.yellow}File ${T.bright}${w}${T.yellow} changed, rebuilding...${T.reset}`),_6.clear(),O4();let N=await z();if(await E7(q),X&&Q)if(N)Q.reload(w);else Q.error("Build failed - check console for details")}else if(D8(w)){if(console.log(`${T.cyan}CSS ${T.bright}${w}${T.cyan} changed${T.reset}`),X&&Q)Q.updateCss(w)}});process.on("SIGINT",()=>{if(F.close(),Q)b5();O.stop(),process.exit(0)})}return!0}var aw=D(()=>{n$();K4();VX();R0();I8();tG()});var{serve:vg}=globalThis.Bun;import C6 from"fs";import L1 from"path";import{bracketPathToRegex as fg}from"stx-router";function hU($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((J)=>J.split(L1.sep)),Y=[];for(let J=0;J<Z[0].length;J++){let X=Z[0][J];if(Z.every((Q)=>Q[J]===X))Y.push(X);else break}return Y.join(L1.sep)}async function S3($,Z={}){let Y=Z.port||3000,J=Z.watch!==!1;for(let j of $){let H=L1.resolve(j);if(!C6.existsSync(H))return console.error(`${T.red}Error: File not found: ${T.bright}${H}${T.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${T.red}Error: Unsupported file type: ${T.bright}${H}${T.reset}. Only .stx and .md files are supported.`),!1}let X=p0(process.cwd(),"output");C6.mkdirSync(X,{recursive:!0});let Q=hU($.map((j)=>L1.dirname(L1.resolve(j))));console.log(`${T.blue}Processing ${T.bright}${$.length}${T.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=L1.resolve(j);if(H.endsWith(".md"))try{let{content:V,data:L}=await P4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:E1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),F=Z.markdown?.syntaxHighlighting||E1.markdown?.syntaxHighlighting,A=F?.defaultTheme||"github-dark",w=["github-dark"],N=F?.additionalThemes||[],E=[...new Set([...w,...N])].map((k)=>`<option value="${k}"${k===A?" selected":""}>${k}</option>`).join(`
18002
18002
  `),M=`
18003
18003
  <!DOCTYPE html>
18004
18004
  <html lang="en">
@@ -18161,26 +18161,26 @@ Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),N6(O.u
18161
18161
  </script>
18162
18162
  </body>
18163
18163
  </html>
18164
- `,S=`/${L1.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:M,fileType:"md"}}catch(V){console.error(`${T.red}Error processing Markdown file ${T.bright}${j}${T.reset}:`,V);continue}else{let V={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:X,plugins:[V,$7],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${T.red}Build failed for ${T.bright}${j}${T.reset}:`,L.logs);continue}let F=L.outputs.find((R)=>R.path.endsWith(".html"));if(!F){console.error(`${T.red}No HTML output found for ${T.bright}${j}${T.reset}`);continue}let A=await Bun.file(F.path).text(),N=`/${L1.relative(Q,H).replace(/\.stx$/,"")}`;if(N.endsWith("/index"))N=N.slice(0,-6)||"/";if(N.includes("[")){let R=[...N.matchAll(/\[([^\]]+)\]/g)].map((M)=>M[1]),E=N.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:R,filePath:H,routeTemplate:N,fileType:"stx"}),G[N]={filePath:H,content:A,fileType:"stx"}}else G[N||"/"]={filePath:H,content:A,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${T.red}No files were successfully processed${T.reset}`),!1;return!0}catch(j){return console.error(`${T.red}Error processing files:${T.reset}`,j),!1}};if(!await W())return!1;let z=Y;try{if(z=await w6(Y),z!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${z} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}console.log(`${T.blue}Starting server on ${T.cyan}http://localhost:${z}/${T.reset}...`);let _=xg({port:z,async fetch(j){let H=new URL(j.url),O=L1.join(process.cwd(),"public",H.pathname);if(C6.existsSync(O)&&C6.statSync(O).isFile()){let F=Bun.file(O),A=L1.extname(O).toLowerCase(),w="application/octet-stream";if(A===".ts"||A===".tsx"){let N=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),R=await F.text(),E=N.transformSync(R);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":w="text/html";break;case".css":w="text/css";break;case".js":w="text/javascript";break;case".json":w="application/json";break;case".png":w="image/png";break;case".jpg":case".jpeg":w="image/jpeg";break;case".gif":w="image/gif";break;case".svg":w="image/svg+xml";break;case".ico":w="image/x-icon";break;case".woff":w="font/woff";break;case".woff2":w="font/woff2";break;case".ttf":w="font/ttf";break;case".otf":w="font/otf";break;case".eot":w="application/vnd.ms-fontobject";break}return new Response(F,{headers:{"Content-Type":w}})}let V=G[H.pathname];if(!V&&!H.pathname.endsWith("/"))V=G[`${H.pathname}/`];if(!V)for(let F of K){let A=H.pathname.match(F.pattern);if(A){let w=G[F.routeTemplate];if(w){let N={};for(let M=0;M<F.paramNames.length;M++)N[F.paramNames[M]]=decodeURIComponent(A[M+1]);let R=w.content,E=`<script>window.__routeParams = ${JSON.stringify(N)};</script>`;if(R.includes("</head>"))R=R.replace("</head>",`${E}
18164
+ `,S=`/${L1.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:M,fileType:"md"}}catch(V){console.error(`${T.red}Error processing Markdown file ${T.bright}${j}${T.reset}:`,V);continue}else{let V={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:X,plugins:[V,$7],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${T.red}Build failed for ${T.bright}${j}${T.reset}:`,L.logs);continue}let F=L.outputs.find((R)=>R.path.endsWith(".html"));if(!F){console.error(`${T.red}No HTML output found for ${T.bright}${j}${T.reset}`);continue}let A=await Bun.file(F.path).text(),N=`/${L1.relative(Q,H).replace(/\.stx$/,"")}`;if(N.endsWith("/index"))N=N.slice(0,-6)||"/";if(N.includes("[")){let{regex:R,params:E}=fg(N);K.push({pattern:R,paramNames:E,filePath:H,routeTemplate:N,fileType:"stx"}),G[N]={filePath:H,content:A,fileType:"stx"}}else G[N||"/"]={filePath:H,content:A,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${T.red}No files were successfully processed${T.reset}`),!1;return!0}catch(j){return console.error(`${T.red}Error processing files:${T.reset}`,j),!1}};if(!await W())return!1;let z=Y;try{if(z=await w6(Y),z!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${z} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}console.log(`${T.blue}Starting server on ${T.cyan}http://localhost:${z}/${T.reset}...`);let _=vg({port:z,async fetch(j){let H=new URL(j.url),O=L1.join(process.cwd(),"public",H.pathname);if(C6.existsSync(O)&&C6.statSync(O).isFile()){let F=Bun.file(O),A=L1.extname(O).toLowerCase(),w="application/octet-stream";if(A===".ts"||A===".tsx"){let N=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),R=await F.text(),E=N.transformSync(R);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":w="text/html";break;case".css":w="text/css";break;case".js":w="text/javascript";break;case".json":w="application/json";break;case".png":w="image/png";break;case".jpg":case".jpeg":w="image/jpeg";break;case".gif":w="image/gif";break;case".svg":w="image/svg+xml";break;case".ico":w="image/x-icon";break;case".woff":w="font/woff";break;case".woff2":w="font/woff2";break;case".ttf":w="font/ttf";break;case".otf":w="font/otf";break;case".eot":w="application/vnd.ms-fontobject";break}return new Response(F,{headers:{"Content-Type":w}})}let V=G[H.pathname];if(!V&&!H.pathname.endsWith("/"))V=G[`${H.pathname}/`];if(!V)for(let F of K){let A=H.pathname.match(F.pattern);if(A){let w=G[F.routeTemplate];if(w){let N={};for(let M=0;M<F.paramNames.length;M++)N[F.paramNames[M]]=decodeURIComponent(A[M+1]);let R=w.content,E=`<script>window.__routeParams = ${JSON.stringify(N)};</script>`;if(R.includes("</head>"))R=R.replace("</head>",`${E}
18165
18165
  </head>`);else R=E+R;V={...w,content:R}}break}}if(V)return y0(V.content).then((F)=>{if(F.includes("</head>"))F=F.replace("</head>",`${jW}
18166
18166
  </head>`);return new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let L=L1.join(X,H.pathname);if(C6.existsSync(L)&&C6.statSync(L).isFile()){let F=Bun.file(L),A=L1.extname(L).toLowerCase(),w="text/plain";if(A===".ts"||A===".tsx"){let N=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),R=await F.text(),E=N.transformSync(R);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":w="text/html";break;case".css":w="text/css";break;case".js":w="text/javascript";break;case".json":w="application/json";break;case".png":w="image/png";break;case".jpg":case".jpeg":w="image/jpeg";break;case".gif":w="image/gif";break;case".svg":w="image/svg+xml";break;case".ico":w="image/x-icon";break;case".woff":w="font/woff";break;case".woff2":w="font/woff2";break;case".ttf":w="font/ttf";break;case".otf":w="font/otf";break;case".eot":w="application/vnd.ms-fontobject";break}return new Response(F,{headers:{"Content-Type":w}})}if(H.pathname!=="/"&&G["/"]){let F=j.headers.get("X-STX-Router")==="true";return y0(G["/"].content).then((A)=>{if(F){let w=A.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(w){let N=A.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=`<!DOCTYPE html><html><head><title>${N?N[1]:""}</title></head><body><main>${w[1]}</main></body></html>`;return new Response(E,{headers:{"Content-Type":"text/html","X-STX-Partial":"true","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}return new Response(A,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(j){return new Response(`<pre>${j}
18167
18167
  ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
18168
18168
  ${T.blue}stx${T.reset} ${T.green}${process.env.stx_VERSION||"v0.0.10"}${T.reset} ${T.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${T.reset}`),console.log(`
18169
18169
  ${T.bright}\u2192 ${T.cyan}http://localhost:${z}/${T.reset}`),console.log(`
18170
18170
  ${T.yellow}Routes:${T.reset}`);let q=new Set(K.map((j)=>j.routeTemplate)),B=Object.entries(G).filter(([j])=>!q.has(j)).sort(([j],[H])=>j.localeCompare(H)).map(([j,H])=>({route:j==="/"?"/":j,filePath:L1.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let j of K){let H=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");B.push({route:H,filePath:L1.relative(process.cwd(),j.filePath),fileType:"stx"})}if(B.sort((j,H)=>j.route.localeCompare(H.route)),B.forEach((j,H)=>{let V=H===B.length-1?"\u2514\u2500 ":"\u251C\u2500 ",L=j.fileType==="md"?`${T.magenta}(markdown)${T.reset}`:"";console.log(` ${T.green}${V}${j.route}${T.reset} \u2192 ${T.bright}${j.filePath}${T.reset} ${L}`)}),console.log(`
18171
- Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),N6(_.url.toString(),()=>{if(J)C6.watch(Q,{recursive:!0}).close();_.stop()}),J){console.log(`${T.blue}Watching for changes...${T.reset}`);let j=C6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${T.yellow}File ${T.bright}${O}${T.yellow} changed, rebuilding...${T.reset}`),_6.clear(),O4(),await W()});process.on("SIGINT",()=>{j.close(),_.stop(),process.exit(0)})}return!0}var sw=D(()=>{Q5();a0();n$();K4();VX();R0();I8()});var{serve:vg}=globalThis.Bun;import k1 from"fs";import I0 from"path";async function ow($){try{return xJ(await Bun.file($).text())}catch{return}}function uU($){let Z=Bun.file($),Y=I0.extname($).toLowerCase(),J={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":J[Y]||"application/octet-stream",...Q}})}async function C3($=".",Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=I0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (T6(),B$)),U=await W(K),z=U.root&&U.root!=="."?I0.join(K,U.root):K,_=U.pagesDir||"pages",q=I0.join(z,_);if(!k1.existsSync(q))return console.error(`${T.red}Error: No '${_}' directory found in ${T.bright}${z}${T.reset}`),console.log(`${T.dim}Create a ${_}/ directory with .stx files to define your routes.${T.reset}`),console.log(`${T.dim}Example: ${_}/index.stx for the homepage.${T.reset}`),!1;let B=h4(z);if(B.length===0)return console.error(`${T.red}Error: No page files found in ${T.bright}${q}${T.reset}`),!1;console.log(`${T.blue}Found ${T.bright}${B.length}${T.blue} routes${T.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:P,prefix:d}of j)if(k1.existsSync(P)){let l=h4(I0.dirname(P),{pagesDir:I0.basename(P)});for(let c of l){let a=d==="/"?c.pattern:`${d}${c.pattern==="/"?"":c.pattern}`;H.push({route:{...c,pattern:a},prefix:d})}if(l.length>0)console.log(`${T.blue}Plugin pages: ${T.bright}${l.length}${T.blue} routes at ${T.cyan}${d}${T.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await VK(K,Z.stxOptions?.shell),L){if(V=await gJ(L,Z.stxOptions||{}),V)console.log(`${T.blue}Using app shell: ${T.bright}${I0.relative(K,L)}${T.reset} ${T.dim}(deprecated: use layouts/default.stx instead)${T.reset}`)}}u8(),await p8(K);let F=c8();if(F.length>0)console.log(`${T.blue}Loaded ${T.bright}${F.length}${T.blue} middleware: ${T.dim}${F.join(", ")}${T.reset}`);let A={},w=null;try{let{loadStxConfig:P}=await Promise.resolve().then(() => (T6(),B$)),d=await P(K);if(d?.apiRouter)w=d?.apiRouter,console.log(`${T.blue}Using custom router for API handling${T.reset}`);if(d?.apiRoutes){A=d.apiRoutes;let l=Object.keys(A).length;if(l>0)console.log(`${T.blue}Loaded ${T.bright}${l} API route${l>1?"s":""}${T.reset}`)}if(d?.broadcasting?.enabled)try{let{startBroadcasting:l,loadChannels:c}=await Promise.resolve().then(() => (lJ(),fK)),a=d.broadcasting;await l(a);let X0=a.port??6001;console.log(`${T.magenta}Broadcasting on ${T.cyan}ws://localhost:${X0}/ws${T.reset}`);let K0=I0.join(process.cwd(),"channels.ts");if(k1.existsSync(K0))try{let b0=await c(K0);console.log(`${T.blue}Loaded ${T.bright}${b0} broadcast channel${b0!==1?"s":""}${T.blue} from channels.ts${T.reset}`)}catch(b0){console.warn(`${T.yellow}Failed to load channels.ts: ${b0.message}${T.reset}`)}}catch(l){console.warn(`${T.yellow}Broadcasting failed to start: ${l.message}${T.reset}`)}}catch{}let N=p0(K,"output");k1.mkdirSync(N,{recursive:!0});let R=new Map,E=new Set,M=async(P)=>{let d=AK(q,P);if(!d)return null;try{let l=await Bun.build({entrypoints:[d],outdir:N,plugins:[$7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!l.success)return null;let c=l.outputs.find((a)=>a.path.endsWith(".html"));if(!c)return null;return await Bun.file(c.path).text()}catch{return null}},I=async(P,d)=>{try{let{processDirectives:l,extractVariables:c,defaultConfig:a,loadStxConfig:X0,injectRouterScript:K0}=await Promise.resolve().then(() => (T6(),B$)),{checkCache:b0,cacheTemplate:_1,readFileCached:P0,templateCache:c1}=await Promise.resolve().then(() => (Y$(),t$)),W0=await X0(K),p=(V0)=>{if(!V0)return V0;if(I0.isAbsolute(V0))return V0;return I0.resolve(K,V0)},t={...a,...W0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)t.debug=!0;t.partialsDir=p(t.partialsDir),t.componentsDir=p(t.componentsDir),t.layoutsDir=p(t.layoutsDir),t.storesDir=p(t.storesDir||"stores"),t.cachePath=p(t.cachePath)??p0(K,"cache");let _0=!d&&!Z.profile,v=t.cache!==!1;if(v&&_0){let V0=c1.get(P.filePath);if(V0)try{if((await k1.promises.stat(P.filePath)).mtime.getTime()<=V0.mtime){let v0=!0;for(let d0 of V0.dependencies){if(!k1.existsSync(d0)){v0=!1;break}if((await k1.promises.stat(d0)).mtime.getTime()>V0.mtime){v0=!1;break}}if(v0){let d0=V0.output;if(V)d0=g4(d0,{preserveHead:!0});return{route:P,content:d0,status:await ow(P.filePath)}}}}catch{}let q0=await b0(P.filePath,t);if(q0){let J0=q0;if(V)J0=g4(J0,{preserveHead:!0});return{route:P,content:J0,status:await ow(P.filePath)}}}let C=v?await P0(P.filePath):await Bun.file(P.filePath).text(),u=xJ(C),{classifyAllScripts:e}=await Promise.resolve().then(() => (T6(),B$)),n=e(C),j0=n.server.map((V0)=>V0.content),D0=C;for(let V0 of n.server)D0=D0.replace(V0.fullTag,"");let h0={__filename:P.filePath,__dirname:I0.dirname(P.filePath),params:d??{},__stx_runtime_head:{}};for(let V0 of j0)try{await c(V0,h0,P.filePath)}catch(q0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,q0?.message||q0)}let G1=new Set,C0;if(Z.profile){let V0=performance.now();C0=await l(D0,h0,P.filePath,t,G1);let q0=performance.now()-V0,J0=I0.relative(K,P.filePath)||P.filePath;console.log(`[stx:profile] ${J0} \u2192 ${q0.toFixed(2)}ms`)}else C0=await l(D0,h0,P.filePath,t,G1);if(!V)C0=await K0(C0);{let{interpolateScriptExpressions:V0}=await Promise.resolve().then(() => (Z1(),N7));C0=C0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(q0,J0,v0)=>{if(!/function\s+__stx_setup_/.test(v0))return q0;return`<script${J0}>${V0(v0,h0)}</script>`})}if(V)C0=g4(C0,{preserveHead:!0});if(v&&_0)await _1(P.filePath,C0,G1,t);let{extractStreamBoundaries:S1}=await Promise.resolve().then(() => (W6(),o6)),V1=S1(h0),F1=h0.__streamTemplates;if(F1&&typeof F1==="object"&&Object.keys(F1).length>0){let V0=h0.streamBoundaries||{},q0={...t,autoShell:!1},J0=Object.keys(F1).map((d0)=>({id:d0,render:async()=>{let M4=typeof V0[d0]==="function"?await V0[d0]():void 0;return l(F1[d0],{...h0,$boundary:M4},P.filePath,q0,new Set)}})),v0=new Set(J0.map((d0)=>d0.id));V1=[...(V1||[]).filter((d0)=>!v0.has(d0.id)),...J0]}if(V1&&V1.length>0)E.add(P.pattern);else V1=void 0;return{route:P,content:C0,status:u,boundaries:V1}}catch(l){return console.error(`${T.red}Error building ${T.bright}${P.pattern}${T.reset}:`,l),null}},S=8,k=async()=>{R.clear(),O.clear();for(let P=0;P<B.length;P+=S){let d=B.slice(P,P+S),l=await Promise.all(d.map((c)=>I(c)));for(let c of l)if(c)R.set(c.route.pattern,c)}for(let P=0;P<H.length;P+=S){let d=H.slice(P,P+S),l=await Promise.all(d.map(({route:c})=>I(c)));for(let c of l)if(c)O.set(c.route.pattern,c)}return R.size>0};if(console.log(`${T.blue}Building pages...${T.reset}`),!await k())return console.error(`${T.red}No pages were successfully built${T.reset}`),!1;await P$(K);let y=Y;try{if(y=await w6(Y),y!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${y} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}if(X){let P=Z.hmrPort||y+1;Q=C8({wsPort:P,verbose:!1}),G=Q.start(P)}let b=(P,d)=>{let c=`<script data-stx-route-params>(function(){var p=${JSON.stringify(d).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${c}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${c}`);return c+P};console.log(`${T.blue}Starting server...${T.reset}`);let h=vg({port:y,async fetch(P){let d=new URL(P.url),l=U?.publicDir||"public",c=I0.join(K,l,d.pathname),a=I0.join(K,d.pathname),X0=I0.join(N,d.pathname),[K0,b0,_1]=await Promise.all([k1.promises.stat(c).catch(()=>null),k1.promises.stat(a).catch(()=>null),k1.promises.stat(X0).catch(()=>null)]);if(K0?.isFile())return uU(c);if(b0?.isFile())return uU(a);if(_1?.isFile())return uU(X0);if(d.pathname.startsWith("/_stx/component/")){let p=decodeURIComponent(d.pathname.slice(16));if(p)try{let t=`<${p} />`,_0={...buildConfig,autoShell:!1},v=await processDirectives(t,{},I0.join(K,"components",`${p}.stx`),_0,new Set);return new Response(v,{headers:{"Content-Type":"text/html"}})}catch(t){return new Response(`<div class="stx-async-error">${t.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(d.pathname==="/_stx/img"){let{handleImageRequest:p}=await Promise.resolve().then(() => (GK(),pL)),t=await p(P,{publicDir:I0.join(K,l),cacheDir:p0(K,"cache","img")});if(t)return t}if(w)try{let p=await w.handleRequest(P);if(p.status!==404)return p}catch{}if(A[d.pathname])try{return await A[d.pathname](P)}catch(p){return new Response(JSON.stringify({error:p.message}),{status:500,headers:{"Content-Type":"application/json"}})}let P0=hJ(d.pathname,B);if(P0){let p=R.get(P0.route.pattern),t=E.has(P0.route.pattern);if(P0.route.isDynamic&&Object.keys(P0.params).length>0||t){let _0=await I(P0.route,P0.params);if(_0)p=_0}if(p){let _0=p.status??200,v=fZ();if(v.validate){if(!await v.validate({params:P0.params})){let e=await M(404);if(e){let n=e;if(n=await y0(n,K),X)n=F4(n,G);return new Response(n,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(v.middleware){let u=l8(d.pathname,P0.params,v,d.search),e=m8(u,null,P),n=await i8(v.middleware,e);if(n.redirect){let j0=n.redirect.path,D0=n.redirect.options.redirectCode||302,h0=new Headers(n.responseHeaders);return h0.set("Location",j0),new Response(null,{status:D0,headers:h0})}if(n.abort){let{statusCode:j0,message:D0}=n.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${j0}</title></head><body><h1>Error ${j0}</h1><p>${D0}</p></body></html>`,{status:j0,headers:{"Content-Type":"text/html"}})}if(Object.keys(n.state).length>0){let j0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(n.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;p.content=p.content.replace("</head>",`${j0}</head>`)}}let C=p.content;if(V&&FK(P)){let u=s8(C),e=C.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=e?e[1].trim():"";if(Object.keys(P0.params).length>0)C=b(C,P0.params);C=await y0(C,K);let j0=U?.router?.container||"main";return C=a8(C,j0),new Response(C,{status:_0,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":u.layout,"X-STX-Layout-Group":u.group,...n&&{"X-STX-Title":encodeURIComponent(n)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)C=r8(V,C);if(Object.keys(P0.params).length>0)C=b(C,P0.params);if(C=await y0(C,K),X)C=F4(C,G);if(Z.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;if(Z.titlebarHidden)if(C.includes("<head>"))C=C.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else C=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${C}`;if(p.boundaries&&p.boundaries.length>0){let{renderStreamingPage:u,streamToResponse:e}=await Promise.resolve().then(() => (W6(),o6));return e(u(C,p.boundaries,{timeoutMs:30000}),{status:_0,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(C,{status:_0,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let p=H.map((_0)=>_0.route),t=hJ(d.pathname,p);if(t){let _0=O.get(t.route.pattern);if(_0){let v=_0.content;if(V)v=r8(V,v);if(Object.keys(t.params).length>0)v=b(v,t.params);if(v=await y0(v,K),X)v=F4(v,G);return new Response(v,{status:_0.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:_0}of j)if(_0!=="/"&&d.pathname.startsWith(_0)){let v=O.get(_0)||O.get(_0+"/");if(v){let C=v.content;if(V)C=r8(V,C);if(C=await y0(C,K),X)C=F4(C,G);return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let c1=R.get("/");if(c1){let p=c1.content;if(p=await y0(p,K),X)p=F4(p,G);if(Z.native)if(p.includes("<head>"))p=p.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else p="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+p;return new Response(p,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let W0=await M(404);if(W0){let p=W0;if(p=await y0(p,K),X)p=F4(p,G);return new Response(p,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let d=await M(500);if(d)return new Response(d,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
18171
+ Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),N6(_.url.toString(),()=>{if(J)C6.watch(Q,{recursive:!0}).close();_.stop()}),J){console.log(`${T.blue}Watching for changes...${T.reset}`);let j=C6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${T.yellow}File ${T.bright}${O}${T.yellow} changed, rebuilding...${T.reset}`),_6.clear(),O4(),await W()});process.on("SIGINT",()=>{j.close(),_.stop(),process.exit(0)})}return!0}var sw=D(()=>{Q5();a0();n$();K4();VX();R0();I8()});var{serve:gg}=globalThis.Bun;import k1 from"fs";import I0 from"path";async function ow($){try{return xJ(await Bun.file($).text())}catch{return}}function uU($){let Z=Bun.file($),Y=I0.extname($).toLowerCase(),J={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":J[Y]||"application/octet-stream",...Q}})}async function C3($=".",Z={}){let Y=Z.port||3000,J=Z.watch!==!1,X=Z.hotReload!==!1&&J,Q=null,G=Z.hmrPort||Y+1,K=I0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (T6(),B$)),U=await W(K),z=U.root&&U.root!=="."?I0.join(K,U.root):K,_=U.pagesDir||"pages",q=I0.join(z,_);if(!k1.existsSync(q))return console.error(`${T.red}Error: No '${_}' directory found in ${T.bright}${z}${T.reset}`),console.log(`${T.dim}Create a ${_}/ directory with .stx files to define your routes.${T.reset}`),console.log(`${T.dim}Example: ${_}/index.stx for the homepage.${T.reset}`),!1;let B=h4(z);if(B.length===0)return console.error(`${T.red}Error: No page files found in ${T.bright}${q}${T.reset}`),!1;console.log(`${T.blue}Found ${T.bright}${B.length}${T.blue} routes${T.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:P,prefix:d}of j)if(k1.existsSync(P)){let l=h4(I0.dirname(P),{pagesDir:I0.basename(P)});for(let c of l){let a=d==="/"?c.pattern:`${d}${c.pattern==="/"?"":c.pattern}`;H.push({route:{...c,pattern:a},prefix:d})}if(l.length>0)console.log(`${T.blue}Plugin pages: ${T.bright}${l.length}${T.blue} routes at ${T.cyan}${d}${T.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await VK(K,Z.stxOptions?.shell),L){if(V=await gJ(L,Z.stxOptions||{}),V)console.log(`${T.blue}Using app shell: ${T.bright}${I0.relative(K,L)}${T.reset} ${T.dim}(deprecated: use layouts/default.stx instead)${T.reset}`)}}u8(),await p8(K);let F=c8();if(F.length>0)console.log(`${T.blue}Loaded ${T.bright}${F.length}${T.blue} middleware: ${T.dim}${F.join(", ")}${T.reset}`);let A={},w=null;try{let{loadStxConfig:P}=await Promise.resolve().then(() => (T6(),B$)),d=await P(K);if(d?.apiRouter)w=d?.apiRouter,console.log(`${T.blue}Using custom router for API handling${T.reset}`);if(d?.apiRoutes){A=d.apiRoutes;let l=Object.keys(A).length;if(l>0)console.log(`${T.blue}Loaded ${T.bright}${l} API route${l>1?"s":""}${T.reset}`)}if(d?.broadcasting?.enabled)try{let{startBroadcasting:l,loadChannels:c}=await Promise.resolve().then(() => (lJ(),fK)),a=d.broadcasting;await l(a);let X0=a.port??6001;console.log(`${T.magenta}Broadcasting on ${T.cyan}ws://localhost:${X0}/ws${T.reset}`);let K0=I0.join(process.cwd(),"channels.ts");if(k1.existsSync(K0))try{let b0=await c(K0);console.log(`${T.blue}Loaded ${T.bright}${b0} broadcast channel${b0!==1?"s":""}${T.blue} from channels.ts${T.reset}`)}catch(b0){console.warn(`${T.yellow}Failed to load channels.ts: ${b0.message}${T.reset}`)}}catch(l){console.warn(`${T.yellow}Broadcasting failed to start: ${l.message}${T.reset}`)}}catch{}let N=p0(K,"output");k1.mkdirSync(N,{recursive:!0});let R=new Map,E=new Set,M=async(P)=>{let d=AK(q,P);if(!d)return null;try{let l=await Bun.build({entrypoints:[d],outdir:N,plugins:[$7],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!l.success)return null;let c=l.outputs.find((a)=>a.path.endsWith(".html"));if(!c)return null;return await Bun.file(c.path).text()}catch{return null}},I=async(P,d)=>{try{let{processDirectives:l,extractVariables:c,defaultConfig:a,loadStxConfig:X0,injectRouterScript:K0}=await Promise.resolve().then(() => (T6(),B$)),{checkCache:b0,cacheTemplate:_1,readFileCached:P0,templateCache:c1}=await Promise.resolve().then(() => (Y$(),t$)),W0=await X0(K),p=(V0)=>{if(!V0)return V0;if(I0.isAbsolute(V0))return V0;return I0.resolve(K,V0)},t={...a,...W0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)t.debug=!0;t.partialsDir=p(t.partialsDir),t.componentsDir=p(t.componentsDir),t.layoutsDir=p(t.layoutsDir),t.storesDir=p(t.storesDir||"stores"),t.cachePath=p(t.cachePath)??p0(K,"cache");let _0=!d&&!Z.profile,v=t.cache!==!1;if(v&&_0){let V0=c1.get(P.filePath);if(V0)try{if((await k1.promises.stat(P.filePath)).mtime.getTime()<=V0.mtime){let v0=!0;for(let d0 of V0.dependencies){if(!k1.existsSync(d0)){v0=!1;break}if((await k1.promises.stat(d0)).mtime.getTime()>V0.mtime){v0=!1;break}}if(v0){let d0=V0.output;if(V)d0=g4(d0,{preserveHead:!0});return{route:P,content:d0,status:await ow(P.filePath)}}}}catch{}let q0=await b0(P.filePath,t);if(q0){let J0=q0;if(V)J0=g4(J0,{preserveHead:!0});return{route:P,content:J0,status:await ow(P.filePath)}}}let C=v?await P0(P.filePath):await Bun.file(P.filePath).text(),u=xJ(C),{classifyAllScripts:e}=await Promise.resolve().then(() => (T6(),B$)),n=e(C),j0=n.server.map((V0)=>V0.content),D0=C;for(let V0 of n.server)D0=D0.replace(V0.fullTag,"");let h0={__filename:P.filePath,__dirname:I0.dirname(P.filePath),params:d??{},__stx_runtime_head:{}};for(let V0 of j0)try{await c(V0,h0,P.filePath)}catch(q0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",P.filePath,q0?.message||q0)}let G1=new Set,C0;if(Z.profile){let V0=performance.now();C0=await l(D0,h0,P.filePath,t,G1);let q0=performance.now()-V0,J0=I0.relative(K,P.filePath)||P.filePath;console.log(`[stx:profile] ${J0} \u2192 ${q0.toFixed(2)}ms`)}else C0=await l(D0,h0,P.filePath,t,G1);if(!V)C0=await K0(C0);{let{interpolateScriptExpressions:V0}=await Promise.resolve().then(() => (Z1(),N7));C0=C0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(q0,J0,v0)=>{if(!/function\s+__stx_setup_/.test(v0))return q0;return`<script${J0}>${V0(v0,h0)}</script>`})}if(V)C0=g4(C0,{preserveHead:!0});if(v&&_0)await _1(P.filePath,C0,G1,t);let{extractStreamBoundaries:S1}=await Promise.resolve().then(() => (W6(),o6)),V1=S1(h0),F1=h0.__streamTemplates;if(F1&&typeof F1==="object"&&Object.keys(F1).length>0){let V0=h0.streamBoundaries||{},q0={...t,autoShell:!1},J0=Object.keys(F1).map((d0)=>({id:d0,render:async()=>{let M4=typeof V0[d0]==="function"?await V0[d0]():void 0;return l(F1[d0],{...h0,$boundary:M4},P.filePath,q0,new Set)}})),v0=new Set(J0.map((d0)=>d0.id));V1=[...(V1||[]).filter((d0)=>!v0.has(d0.id)),...J0]}if(V1&&V1.length>0)E.add(P.pattern);else V1=void 0;return{route:P,content:C0,status:u,boundaries:V1}}catch(l){return console.error(`${T.red}Error building ${T.bright}${P.pattern}${T.reset}:`,l),null}},S=8,k=async()=>{R.clear(),O.clear();for(let P=0;P<B.length;P+=S){let d=B.slice(P,P+S),l=await Promise.all(d.map((c)=>I(c)));for(let c of l)if(c)R.set(c.route.pattern,c)}for(let P=0;P<H.length;P+=S){let d=H.slice(P,P+S),l=await Promise.all(d.map(({route:c})=>I(c)));for(let c of l)if(c)O.set(c.route.pattern,c)}return R.size>0};if(console.log(`${T.blue}Building pages...${T.reset}`),!await k())return console.error(`${T.red}No pages were successfully built${T.reset}`),!1;await P$(K);let y=Y;try{if(y=await w6(Y),y!==Y)console.log(`${T.yellow}Port ${Y} is busy, using port ${y} instead${T.reset}`)}catch{return console.error(`${T.red}Could not find an available port${T.reset}`),!1}if(X){let P=Z.hmrPort||y+1;Q=C8({wsPort:P,verbose:!1}),G=Q.start(P)}let b=(P,d)=>{let c=`<script data-stx-route-params>(function(){var p=${JSON.stringify(d).replace(/</g,"\\u003C").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")};window.__stx_rp=p;if(window.stx){window.stx._rp=p;if(window.stx.setRouteParams)window.stx.setRouteParams(p)}})()</script>`;if(P.includes("</head>"))return P.replace("</head>",`${c}</head>`);if(P.includes("<body"))return P.replace(/<body([^>]*)>/,`<body$1>${c}`);return c+P};console.log(`${T.blue}Starting server...${T.reset}`);let h=gg({port:y,async fetch(P){let d=new URL(P.url),l=U?.publicDir||"public",c=I0.join(K,l,d.pathname),a=I0.join(K,d.pathname),X0=I0.join(N,d.pathname),[K0,b0,_1]=await Promise.all([k1.promises.stat(c).catch(()=>null),k1.promises.stat(a).catch(()=>null),k1.promises.stat(X0).catch(()=>null)]);if(K0?.isFile())return uU(c);if(b0?.isFile())return uU(a);if(_1?.isFile())return uU(X0);if(d.pathname.startsWith("/_stx/component/")){let p=decodeURIComponent(d.pathname.slice(16));if(p)try{let t=`<${p} />`,_0={...buildConfig,autoShell:!1},v=await processDirectives(t,{},I0.join(K,"components",`${p}.stx`),_0,new Set);return new Response(v,{headers:{"Content-Type":"text/html"}})}catch(t){return new Response(`<div class="stx-async-error">${t.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(d.pathname==="/_stx/img"){let{handleImageRequest:p}=await Promise.resolve().then(() => (GK(),pL)),t=await p(P,{publicDir:I0.join(K,l),cacheDir:p0(K,"cache","img")});if(t)return t}if(w)try{let p=await w.handleRequest(P);if(p.status!==404)return p}catch{}if(A[d.pathname])try{return await A[d.pathname](P)}catch(p){return new Response(JSON.stringify({error:p.message}),{status:500,headers:{"Content-Type":"application/json"}})}let P0=hJ(d.pathname,B);if(P0){let p=R.get(P0.route.pattern),t=E.has(P0.route.pattern);if(P0.route.isDynamic&&Object.keys(P0.params).length>0||t){let _0=await I(P0.route,P0.params);if(_0)p=_0}if(p){let _0=p.status??200,v=fZ();if(v.validate){if(!await v.validate({params:P0.params})){let e=await M(404);if(e){let n=e;if(n=await y0(n,K),X)n=F4(n,G);return new Response(n,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(v.middleware){let u=l8(d.pathname,P0.params,v,d.search),e=m8(u,null,P),n=await i8(v.middleware,e);if(n.redirect){let j0=n.redirect.path,D0=n.redirect.options.redirectCode||302,h0=new Headers(n.responseHeaders);return h0.set("Location",j0),new Response(null,{status:D0,headers:h0})}if(n.abort){let{statusCode:j0,message:D0}=n.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${j0}</title></head><body><h1>Error ${j0}</h1><p>${D0}</p></body></html>`,{status:j0,headers:{"Content-Type":"text/html"}})}if(Object.keys(n.state).length>0){let j0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(n.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;p.content=p.content.replace("</head>",`${j0}</head>`)}}let C=p.content;if(V&&FK(P)){let u=s8(C),e=C.match(/<title[^>]*>([\s\S]*?)<\/title>/i),n=e?e[1].trim():"";if(Object.keys(P0.params).length>0)C=b(C,P0.params);C=await y0(C,K);let j0=U?.router?.container||"main";return C=a8(C,j0),new Response(C,{status:_0,headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":u.layout,"X-STX-Layout-Group":u.group,...n&&{"X-STX-Title":encodeURIComponent(n)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)C=r8(V,C);if(Object.keys(P0.params).length>0)C=b(C,P0.params);if(C=await y0(C,K),X)C=F4(C,G);if(Z.native)if(C.includes("<head>"))C=C.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else C="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+C;if(Z.titlebarHidden)if(C.includes("<head>"))C=C.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else C=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${C}`;if(p.boundaries&&p.boundaries.length>0){let{renderStreamingPage:u,streamToResponse:e}=await Promise.resolve().then(() => (W6(),o6));return e(u(C,p.boundaries,{timeoutMs:30000}),{status:_0,headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(C,{status:_0,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let p=H.map((_0)=>_0.route),t=hJ(d.pathname,p);if(t){let _0=O.get(t.route.pattern);if(_0){let v=_0.content;if(V)v=r8(V,v);if(Object.keys(t.params).length>0)v=b(v,t.params);if(v=await y0(v,K),X)v=F4(v,G);return new Response(v,{status:_0.status??200,headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:_0}of j)if(_0!=="/"&&d.pathname.startsWith(_0)){let v=O.get(_0)||O.get(_0+"/");if(v){let C=v.content;if(V)C=r8(V,C);if(C=await y0(C,K),X)C=F4(C,G);return new Response(C,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let c1=R.get("/");if(c1){let p=c1.content;if(p=await y0(p,K),X)p=F4(p,G);if(Z.native)if(p.includes("<head>"))p=p.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else p="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+p;return new Response(p,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let W0=await M(404);if(W0){let p=W0;if(p=await y0(p,K),X)p=F4(p,G);return new Response(p,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(P){let d=await M(500);if(d)return new Response(d,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${P}
18172
18172
  ${P.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
18173
18173
  ${T.blue}stx${T.reset} ${T.green}${process.env.stx_VERSION||"v0.0.10"}${T.reset} ${T.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${T.reset}`),console.log(`
18174
18174
  ${T.bright}\u2192 ${T.cyan}http://localhost:${y}/${T.reset}`),X)console.log(`${T.dim} HMR: ws://localhost:${G}${T.reset}`);console.log(`
18175
18175
  ${T.yellow}Routes:${T.reset}`);let m=[...wK(B,K)];for(let{route:P}of H)m.push(`${P.pattern}`);if(m.forEach((P,d)=>{let c=d===m.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${T.green}${c}${T.reset}${P}`)}),console.log(`
18176
- Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),N6(h.url.toString(),()=>{if(Q)b5();h.stop()}),Z.native){let P,d=I0.join(q,"index.stx");if(k1.existsSync(d)){let c=await Bun.file(d).text();P=FJ(c)}let l=U?.app?.window??{};await k5(y,{title:U?.app?.head?.title||I0.basename(K)||"stx App",width:l.width,height:l.height,darkMode:l.darkMode,hotReload:l.hotReload,titlebarHidden:l.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(J){console.log(`${T.blue}Watching for changes...${T.reset}`);let P=(c)=>{return c.startsWith("public/")||c.startsWith("public\\")},d=(c)=>{let a=c.toLowerCase();return a.endsWith(".stx")||a.endsWith(".html")||a.endsWith(".md")},l=k1.watch(K,{recursive:!0},async(c,a)=>{if(!a||S8(a))return;if(k8(a))if(P(a)){if(console.log(`${T.cyan}${a} changed${T.reset}`),X&&Q)Q.reload(a)}else if(d(a)){console.log(`${T.yellow}${a} changed, rebuilding...${T.reset}`),_6.clear(),O4();try{let{invalidateFileCache:X0,templateCache:K0}=await Promise.resolve().then(() => (Y$(),t$));X0(I0.resolve(K,a)),K0.delete(I0.resolve(K,a))}catch{}if(L&&a){if(I0.resolve(K,a)===L||I0.basename(L)===a){let K0=await gJ(L,Z.stxOptions||{});if(K0)V=K0}}if(await k(),await E7(K),X&&Q)Q.reload(a)}else{console.log(`${T.yellow}${a} changed, rebuilding...${T.reset}`),_6.clear(),O4();try{let{invalidateFileCache:X0,templateCache:K0}=await Promise.resolve().then(() => (Y$(),t$));X0(I0.resolve(K,a)),K0.delete(I0.resolve(K,a))}catch{}if(await k(),X&&Q)Q.reload(a)}else if(D8(a)){if(console.log(`${T.cyan}CSS ${a} changed${T.reset}`),X&&Q)Q.updateCss(a)}});process.on("SIGINT",()=>{if(l.close(),Q)b5();h.stop(),process.exit(0)})}return!0}var tw=D(()=>{u5();n$();K4();VX();o8();vJ();a6();R0();I8()});var dU=D(()=>{tG();aw();sw();tw()});var YN={};$0(YN,{runPwaAudit:()=>fg,formatAuditResult:()=>gg,calculateAuditResult:()=>ZN,auditConfig:()=>ew,auditBuildOutput:()=>$N});import w$ from"fs";import FX from"path";function ew($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let J=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:J.includes(192),message:J.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:J.includes(512),message:J.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let X=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:X.length>0,message:X.length>0?`${X.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function $N($){let Z=[],Y=FX.join($,"manifest.json"),J=w$.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:J,message:J?"manifest.json exists":"manifest.json not found in build output"}),J)try{let z=JSON.parse(w$.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(z.icons)&&z.icons.length>0,message:z.icons?.length?`${z.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let X=FX.join($,"sw.js"),Q=w$.existsSync(X);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=FX.join($,"offline.html"),K=w$.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=FX.join($,"pwa-icons");if(w$.existsSync(W)){let z=w$.readdirSync(W).filter((_)=>_.endsWith(".png")||_.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:z.length>0,message:z.length>0?`${z.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function ZN($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),J=Z.filter((W)=>W.passed).length,X=Y.filter((W)=>W.passed).length,Q=Z.length>0?J/Z.length*70:70,G=Y.length>0?X/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function fg($,Z){let Y=ew($),J=Z&&w$.existsSync(Z)?$N(Z):[];return ZN([...Y,...J])}function gg($){let Z=[];Z.push(`
18176
+ Press ${T.cyan}h${T.reset} + ${T.cyan}Enter${T.reset} to show shortcuts`),N6(h.url.toString(),()=>{if(Q)b5();h.stop()}),Z.native){let P,d=I0.join(q,"index.stx");if(k1.existsSync(d)){let c=await Bun.file(d).text();P=FJ(c)}let l=U?.app?.window??{};await k5(y,{title:U?.app?.head?.title||I0.basename(K)||"stx App",width:l.width,height:l.height,darkMode:l.darkMode,hotReload:l.hotReload,titlebarHidden:l.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!P,sidebarConfig:P})}if(J){console.log(`${T.blue}Watching for changes...${T.reset}`);let P=(c)=>{return c.startsWith("public/")||c.startsWith("public\\")},d=(c)=>{let a=c.toLowerCase();return a.endsWith(".stx")||a.endsWith(".html")||a.endsWith(".md")},l=k1.watch(K,{recursive:!0},async(c,a)=>{if(!a||S8(a))return;if(k8(a))if(P(a)){if(console.log(`${T.cyan}${a} changed${T.reset}`),X&&Q)Q.reload(a)}else if(d(a)){console.log(`${T.yellow}${a} changed, rebuilding...${T.reset}`),_6.clear(),O4();try{let{invalidateFileCache:X0,templateCache:K0}=await Promise.resolve().then(() => (Y$(),t$));X0(I0.resolve(K,a)),K0.delete(I0.resolve(K,a))}catch{}if(L&&a){if(I0.resolve(K,a)===L||I0.basename(L)===a){let K0=await gJ(L,Z.stxOptions||{});if(K0)V=K0}}if(await k(),await E7(K),X&&Q)Q.reload(a)}else{console.log(`${T.yellow}${a} changed, rebuilding...${T.reset}`),_6.clear(),O4();try{let{invalidateFileCache:X0,templateCache:K0}=await Promise.resolve().then(() => (Y$(),t$));X0(I0.resolve(K,a)),K0.delete(I0.resolve(K,a))}catch{}if(await k(),X&&Q)Q.reload(a)}else if(D8(a)){if(console.log(`${T.cyan}CSS ${a} changed${T.reset}`),X&&Q)Q.updateCss(a)}});process.on("SIGINT",()=>{if(l.close(),Q)b5();h.stop(),process.exit(0)})}return!0}var tw=D(()=>{u5();n$();K4();VX();o8();vJ();a6();R0();I8()});var dU=D(()=>{tG();aw();sw();tw()});var YN={};$0(YN,{runPwaAudit:()=>hg,formatAuditResult:()=>dg,calculateAuditResult:()=>ZN,auditConfig:()=>ew,auditBuildOutput:()=>$N});import w$ from"fs";import FX from"path";function ew($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let J=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:J.includes(192),message:J.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:J.includes(512),message:J.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let X=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:X.length>0,message:X.length>0?`${X.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function $N($){let Z=[],Y=FX.join($,"manifest.json"),J=w$.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:J,message:J?"manifest.json exists":"manifest.json not found in build output"}),J)try{let z=JSON.parse(w$.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(z.icons)&&z.icons.length>0,message:z.icons?.length?`${z.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let X=FX.join($,"sw.js"),Q=w$.existsSync(X);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=FX.join($,"offline.html"),K=w$.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=FX.join($,"pwa-icons");if(w$.existsSync(W)){let z=w$.readdirSync(W).filter((_)=>_.endsWith(".png")||_.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:z.length>0,message:z.length>0?`${z.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function ZN($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),J=Z.filter((W)=>W.passed).length,X=Y.filter((W)=>W.passed).length,Q=Z.length>0?J/Z.length*70:70,G=Y.length>0?X/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function hg($,Z){let Y=ew($),J=Z&&w$.existsSync(Z)?$N(Z):[];return ZN([...Y,...J])}function dg($){let Z=[];Z.push(`
18177
18177
  === PWA Audit Report ===
18178
18178
  `);let Y=$.score>=90?"32":$.score>=70?"33":"31";Z.push(`Score: \x1B[${Y}m${$.score}/100\x1B[0m`),Z.push(`Passed: ${$.passed} | Failed: ${$.failed} | Warnings: ${$.warnings}
18179
18179
  `);let J=["required","recommended","optional"];for(let X of J){let Q=$.checks.filter((G)=>G.category===X);if(Q.length===0)continue;Z.push(`
18180
18180
  ${X.toUpperCase()}:`);for(let G of Q){let K=G.passed?"\x1B[32m\u2713\x1B[0m":"\x1B[31m\u2717\x1B[0m";if(Z.push(` ${K} ${G.name}: ${G.message}`),G.details)Z.push(` ${G.details}`)}}return Z.push(""),Z.join(`
18181
- `)}var JN=()=>{};import P3 from"fs";import Z7 from"path";import{gzipSync as hg}from"zlib";import{createHash as dg}from"crypto";async function y3($,Z={}){let{includeSourceMaps:Y=!1,parseImports:J=!0,detectDuplicates:X=!0,topModulesCount:Q=20}=Z;if(!P3.existsSync($))throw Error(`Build directory not found: ${$}`);if(!P3.statSync($).isDirectory())throw Error(`Not a directory: ${$}`);let K=await lg($,Y),W=[],U=[];for(let O of K)try{let V=await cg(O,$,J);W.push(V)}catch(V){U.push(`Failed to process ${O}: ${V}`)}let z=rg(W,$),_=W.reduce((O,V)=>O+V.size,0),q=W.reduce((O,V)=>O+V.gzipSize,0),B=ag(W),j=X?sg(W):[],H=[...W].sort((O,V)=>V.size-O.size).slice(0,Q);return{timestamp:Date.now(),buildDir:Z7.resolve($),chunks:z,totalSize:_,totalGzipSize:q,moduleCount:W.length,duplicates:j,byType:B,largestModules:H,warnings:U}}async function lg($,Z){let Y=[];async function J(X){let Q=await P3.promises.readdir(X,{withFileTypes:!0});for(let G of Q){let K=Z7.join(X,G.name);if(G.isDirectory()){if(!G.name.startsWith(".")&&G.name!=="node_modules")await J(K)}else if(G.isFile()){if(!Z&&G.name.endsWith(".map"))continue;Y.push(K)}}}return await J($),Y}async function cg($,Z,Y){let J=await P3.promises.readFile($),X=Z7.relative(Z,$),Q=Z7.extname($).toLowerCase(),G=J.length,K=pg(J),W=ig(J,Q),U=dg("md5").update(J).digest("hex").slice(0,8),z=XN[Q]||"other",_=[];if(Y&&z==="js")_.push(...ng(J.toString("utf-8")));return{id:X,path:X,size:G,gzipSize:K,parsedSize:W,extension:Q,type:z,imports:_,importedBy:[],hash:U}}function pg($){try{let Z=hg($,{level:9}).length;return Math.min(Z,$.length)}catch{return $.length}}function ig($,Z){if(Z.includes(".min.")||$.length<1000)return $.length;let J=XN[Z];if(J==="js")return Math.round($.length*0.6);if(J==="css")return Math.round($.length*0.7);return $.length}function ng($){let Z=[],Y=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,J;while((J=Y.exec($))!==null)Z.push(J[1]);let X=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((J=X.exec($))!==null)Z.push(J[1]);let Q=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((J=Q.exec($))!==null)Z.push(J[1]);return[...new Set(Z)]}function rg($,Z){let Y=new Map;for(let X of $){let Q=X.path.split(Z7.sep),G;if(Q.length===1)G=Z7.basename(X.path,X.extension);else G=Q[0];let K=Y.get(G)||[];K.push(X),Y.set(G,K)}let J=[];for(let[X,Q]of Y){let G=Q.reduce((z,_)=>z+_.size,0),K=Q.reduce((z,_)=>z+_.gzipSize,0),W=Q.some((z)=>mg.some((_)=>_.test(z.path))),U=Q.some((z)=>ug.some((_)=>_.test(z.path)));J.push({name:X,files:Q.map((z)=>z.path),modules:Q,size:G,gzipSize:K,isEntry:W,isVendor:U})}return J.sort((X,Q)=>Q.size-X.size)}function ag($){let Z={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let Y of $)Z[Y.type].count++,Z[Y.type].size+=Y.size,Z[Y.type].gzipSize+=Y.gzipSize;return Z}function sg($){let Z=new Map;for(let J of $){let X=Z.get(J.hash)||[];X.push(J),Z.set(J.hash,X)}let Y=[];for(let[,J]of Z)if(J.length>1){let X=J[0];Y.push({path:X.path,count:J.length,wastedBytes:X.size*(J.length-1),locations:J.map((Q)=>Q.path)})}return Y.sort((J,X)=>X.wastedBytes-J.wastedBytes)}function U0($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}function AX($){let Z=$.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!Z)return 0;let Y=Number.parseFloat(Z[1]);switch((Z[2]||"B").toUpperCase()){case"KB":return Y*1024;case"MB":return Y*1024*1024;case"GB":return Y*1024*1024*1024;default:return Y}}function x3($,Z){if(Z===0)return"0%";return`${($/Z*100).toFixed(1)}%`}var XN,ug,mg;var v3=D(()=>{XN={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},ug=[/node_modules/,/vendor/,/bower_components/,/\.min\./],mg=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/]});function wX($,Z){switch(Z.format){case"json":return og($,Z);case"markdown":return eg($,Z);case"text":default:return tg($,Z)}}function og($,Z){let Y=f3($,Z);return JSON.stringify({timestamp:$.timestamp,buildDir:$.buildDir,summary:{totalSize:$.totalSize,totalSizeFormatted:U0($.totalSize),totalGzipSize:$.totalGzipSize,totalGzipSizeFormatted:U0($.totalGzipSize),moduleCount:$.moduleCount,chunkCount:$.chunks.length,duplicateCount:$.duplicates.length},byType:Object.fromEntries(Object.entries($.byType).map(([J,X])=>[J,{...X,sizeFormatted:U0(X.size),gzipSizeFormatted:U0(X.gzipSize)}])),chunks:$.chunks.map((J)=>({name:J.name,size:J.size,sizeFormatted:U0(J.size),gzipSize:J.gzipSize,gzipSizeFormatted:U0(J.gzipSize),moduleCount:J.modules.length,isEntry:J.isEntry,isVendor:J.isVendor})),largestModules:$.largestModules.slice(0,Z.topModules||10).map((J)=>({path:J.path,size:J.size,sizeFormatted:U0(J.size),gzipSize:J.gzipSize,gzipSizeFormatted:U0(J.gzipSize),type:J.type})),duplicates:$.duplicates,analysis:Y,warnings:$.warnings},null,2)}function tg($,Z){let Y=[],J=Z.showGzip!==!1;if(Y.push(""),Y.push("Bundle Analysis Report"),Y.push("\u2550".repeat(50)),Y.push(""),Y.push("Summary"),Y.push("\u2500".repeat(50)),J)Y.push(`Total Size: ${U0($.totalSize)} (${U0($.totalGzipSize)} gzip)`);else Y.push(`Total Size: ${U0($.totalSize)}`);if(Y.push(`Modules: ${$.moduleCount}`),Y.push(`Chunks: ${$.chunks.length}`),$.duplicates.length>0)Y.push(`Duplicates: ${$.duplicates.length}`);if(Y.push(""),Z.threshold&&$.totalSize>Z.threshold)Y.push(`\u26A0\uFE0F Bundle exceeds threshold of ${U0(Z.threshold)}!`),Y.push("");Y.push("Size by Type"),Y.push("\u2500".repeat(50));let X=["js","css","html","image","font","other"];for(let G of X){let K=$.byType[G];if(K.count>0){let W=x3(K.size,$.totalSize),U=J?` (${U0(K.gzipSize)} gzip)`:"";Y.push(` ${G.padEnd(8)} ${U0(K.size).padStart(12)}${U} ${W.padStart(6)} (${K.count} files)`)}}Y.push(""),Y.push("Chunks"),Y.push("\u2500".repeat(50));for(let G of $.chunks.slice(0,10)){let K=[];if(G.isEntry)K.push("entry");if(G.isVendor)K.push("vendor");let W=K.length>0?` [${K.join(", ")}]`:"",U=J?` (${U0(G.gzipSize)} gzip)`:"";Y.push(` ${G.name.padEnd(20)} ${U0(G.size).padStart(12)}${U}${W}`)}if($.chunks.length>10)Y.push(` ... and ${$.chunks.length-10} more chunks`);Y.push("");let Q=Z.topModules||10;Y.push(`Largest Modules (Top ${Q})`),Y.push("\u2500".repeat(50));for(let G=0;G<Math.min(Q,$.largestModules.length);G++){let K=$.largestModules[G],W=J?` (${U0(K.gzipSize)} gzip)`:"";Y.push(` ${(G+1).toString().padStart(2)}. ${K.path}`),Y.push(` ${U0(K.size)}${W}`)}if(Y.push(""),$.duplicates.length>0){Y.push("Duplicate Modules"),Y.push("\u2500".repeat(50));for(let G of $.duplicates.slice(0,5))Y.push(` ${G.path}`),Y.push(` ${G.count} copies, wasting ${U0(G.wastedBytes)}`);if($.duplicates.length>5)Y.push(` ... and ${$.duplicates.length-5} more duplicates`);Y.push("")}if(Z.recommendations!==!1){let G=f3($,Z);if(G.recommendations.length>0){Y.push("Recommendations"),Y.push("\u2500".repeat(50));for(let K of G.recommendations.slice(0,5)){let W=K.impact==="high"?"\u26A1":K.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";Y.push(` ${W} ${K.title}`),Y.push(` ${K.description}`)}Y.push("")}}if($.warnings.length>0){Y.push("Warnings"),Y.push("\u2500".repeat(50));for(let G of $.warnings)Y.push(` \u26A0\uFE0F ${G}`);Y.push("")}return Y.join(`
18182
- `)}function eg($,Z){let Y=[],J=Z.showGzip!==!1;if(Y.push("# Bundle Analysis Report"),Y.push(""),Y.push(`Generated: ${new Date($.timestamp).toISOString()}`),Y.push(""),Y.push("## Summary"),Y.push(""),Y.push("| Metric | Value |"),Y.push("|--------|-------|"),Y.push(`| Total Size | ${U0($.totalSize)} |`),J)Y.push(`| Gzip Size | ${U0($.totalGzipSize)} |`);Y.push(`| Modules | ${$.moduleCount} |`),Y.push(`| Chunks | ${$.chunks.length} |`),Y.push(`| Duplicates | ${$.duplicates.length} |`),Y.push(""),Y.push("## Size by Type"),Y.push(""),Y.push("| Type | Size | Gzip | % | Files |"),Y.push("|------|------|------|---|-------|");let X=["js","css","html","image","font","other"];for(let G of X){let K=$.byType[G];if(K.count>0)Y.push(`| ${G} | ${U0(K.size)} | ${U0(K.gzipSize)} | ${x3(K.size,$.totalSize)} | ${K.count} |`)}Y.push(""),Y.push("## Chunks"),Y.push(""),Y.push("| Name | Size | Gzip | Modules | Type |"),Y.push("|------|------|------|---------|------|");for(let G of $.chunks.slice(0,15)){let K=G.isEntry?"Entry":G.isVendor?"Vendor":"-";Y.push(`| ${G.name} | ${U0(G.size)} | ${U0(G.gzipSize)} | ${G.modules.length} | ${K} |`)}Y.push("");let Q=Z.topModules||10;Y.push(`## Largest Modules (Top ${Q})`),Y.push(""),Y.push("| # | Path | Size | Gzip |"),Y.push("|---|------|------|------|");for(let G=0;G<Math.min(Q,$.largestModules.length);G++){let K=$.largestModules[G];Y.push(`| ${G+1} | \`${K.path}\` | ${U0(K.size)} | ${U0(K.gzipSize)} |`)}if(Y.push(""),$.duplicates.length>0){Y.push("## Duplicates"),Y.push(""),Y.push("| Path | Copies | Wasted |"),Y.push("|------|--------|--------|");for(let G of $.duplicates.slice(0,10))Y.push(`| \`${G.path}\` | ${G.count} | ${U0(G.wastedBytes)} |`);Y.push("")}if(Z.recommendations!==!1){let G=f3($,Z);if(G.recommendations.length>0){Y.push("## Recommendations"),Y.push("");for(let K of G.recommendations)Y.push(`### ${K.title}`),Y.push(""),Y.push(K.description),Y.push(""),Y.push(`- **Impact:** ${K.impact}`),Y.push(`- **Effort:** ${K.effort}`),Y.push("")}}return Y.join(`
18183
- `)}function f3($,Z){let Y=[],J=[];if(Z.threshold&&$.totalSize>Z.threshold)Y.push({severity:"error",message:`Bundle size (${U0($.totalSize)}) exceeds threshold (${U0(Z.threshold)})`});if($.totalSize>1048576)Y.push({severity:"warning",message:`Bundle is over 1MB (${U0($.totalSize)})`,details:"Large bundles can significantly impact load time"});if($.duplicates.length>0){let K=$.duplicates.reduce((W,U)=>W+U.wastedBytes,0);Y.push({severity:"warning",message:`${$.duplicates.length} duplicate modules found, wasting ${U0(K)}`}),J.push({title:"Remove Duplicate Modules",description:"Consider using import aliases or ensuring consistent package versions to eliminate duplicates.",impact:"medium",effort:"low"})}if($.byType.js.size/$.totalSize>0.8&&$.totalSize>512000)J.push({title:"Code Splitting",description:"Over 80% of your bundle is JavaScript. Consider splitting code by route or feature.",impact:"high",effort:"medium"});let Q=$.largestModules.filter((K)=>K.size>102400);if(Q.length>0){Y.push({severity:"info",message:`${Q.length} modules are over 100KB`});for(let K of Q){if(K.path.includes("lodash")&&!K.path.includes("lodash-es"))J.push({title:"Use lodash-es instead of lodash",description:"lodash-es supports tree-shaking and can significantly reduce bundle size.",impact:"high",effort:"low"});if(K.path.includes("moment"))J.push({title:"Replace moment.js",description:"Consider using date-fns or dayjs for smaller date handling libraries.",impact:"high",effort:"medium"})}}if($.byType.image.size>512000)J.push({title:"Optimize Images",description:`Images account for ${U0($.byType.image.size)}. Consider using WebP/AVIF formats and responsive images.`,impact:"high",effort:"low"});let G=100;if($.totalSize>1048576)G-=20;else if($.totalSize>512000)G-=10;if(G-=Math.min(20,$.duplicates.length*2),G-=Math.min(15,Q.length*3),Z.threshold&&$.totalSize>Z.threshold)G-=25;return{score:Math.max(0,G),issues:Y,recommendations:J}}function QN($){for(let[Z,Y]of Object.entries($h))if($.includes(Z))return{title:`Optimize ${Z}`,description:`Consider using ${Y.alternative}. Potential savings: ${Y.savings}`,impact:"high",effort:"low"};return null}var $h;var mU=D(()=>{v3();$h={lodash:{alternative:"lodash-es or individual imports",savings:"~70%"},moment:{alternative:"date-fns or dayjs",savings:"~90%"},"chart.js":{alternative:"chart.js with tree-shaking",savings:"~50%"},"highlight.js":{alternative:"Selective language imports",savings:"~80%"},fontawesome:{alternative:"Individual icon imports",savings:"~90%"},"material-ui":{alternative:"Named imports from @mui/*",savings:"~60%"}}});function NX($,Z={}){let{title:Y="Bundle Analysis",gzip:J=!0,colorScheme:X="default"}=Z,Q=Zh[X],G=Yh($),K=JSON.stringify(G);return`<!DOCTYPE html>
18181
+ `)}var JN=()=>{};import P3 from"fs";import Z7 from"path";import{gzipSync as ug}from"zlib";import{createHash as mg}from"crypto";async function y3($,Z={}){let{includeSourceMaps:Y=!1,parseImports:J=!0,detectDuplicates:X=!0,topModulesCount:Q=20}=Z;if(!P3.existsSync($))throw Error(`Build directory not found: ${$}`);if(!P3.statSync($).isDirectory())throw Error(`Not a directory: ${$}`);let K=await pg($,Y),W=[],U=[];for(let O of K)try{let V=await ig(O,$,J);W.push(V)}catch(V){U.push(`Failed to process ${O}: ${V}`)}let z=sg(W,$),_=W.reduce((O,V)=>O+V.size,0),q=W.reduce((O,V)=>O+V.gzipSize,0),B=og(W),j=X?tg(W):[],H=[...W].sort((O,V)=>V.size-O.size).slice(0,Q);return{timestamp:Date.now(),buildDir:Z7.resolve($),chunks:z,totalSize:_,totalGzipSize:q,moduleCount:W.length,duplicates:j,byType:B,largestModules:H,warnings:U}}async function pg($,Z){let Y=[];async function J(X){let Q=await P3.promises.readdir(X,{withFileTypes:!0});for(let G of Q){let K=Z7.join(X,G.name);if(G.isDirectory()){if(!G.name.startsWith(".")&&G.name!=="node_modules")await J(K)}else if(G.isFile()){if(!Z&&G.name.endsWith(".map"))continue;Y.push(K)}}}return await J($),Y}async function ig($,Z,Y){let J=await P3.promises.readFile($),X=Z7.relative(Z,$),Q=Z7.extname($).toLowerCase(),G=J.length,K=ng(J),W=rg(J,Q),U=mg("md5").update(J).digest("hex").slice(0,8),z=XN[Q]||"other",_=[];if(Y&&z==="js")_.push(...ag(J.toString("utf-8")));return{id:X,path:X,size:G,gzipSize:K,parsedSize:W,extension:Q,type:z,imports:_,importedBy:[],hash:U}}function ng($){try{let Z=ug($,{level:9}).length;return Math.min(Z,$.length)}catch{return $.length}}function rg($,Z){if(Z.includes(".min.")||$.length<1000)return $.length;let J=XN[Z];if(J==="js")return Math.round($.length*0.6);if(J==="css")return Math.round($.length*0.7);return $.length}function ag($){let Z=[],Y=/import\s+(?:[\w*{}\s,]+\s+from\s+)?['"]([^'"]+)['"]/g,J;while((J=Y.exec($))!==null)Z.push(J[1]);let X=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((J=X.exec($))!==null)Z.push(J[1]);let Q=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g;while((J=Q.exec($))!==null)Z.push(J[1]);return[...new Set(Z)]}function sg($,Z){let Y=new Map;for(let X of $){let Q=X.path.split(Z7.sep),G;if(Q.length===1)G=Z7.basename(X.path,X.extension);else G=Q[0];let K=Y.get(G)||[];K.push(X),Y.set(G,K)}let J=[];for(let[X,Q]of Y){let G=Q.reduce((z,_)=>z+_.size,0),K=Q.reduce((z,_)=>z+_.gzipSize,0),W=Q.some((z)=>cg.some((_)=>_.test(z.path))),U=Q.some((z)=>lg.some((_)=>_.test(z.path)));J.push({name:X,files:Q.map((z)=>z.path),modules:Q,size:G,gzipSize:K,isEntry:W,isVendor:U})}return J.sort((X,Q)=>Q.size-X.size)}function og($){let Z={js:{count:0,size:0,gzipSize:0},css:{count:0,size:0,gzipSize:0},html:{count:0,size:0,gzipSize:0},image:{count:0,size:0,gzipSize:0},font:{count:0,size:0,gzipSize:0},other:{count:0,size:0,gzipSize:0}};for(let Y of $)Z[Y.type].count++,Z[Y.type].size+=Y.size,Z[Y.type].gzipSize+=Y.gzipSize;return Z}function tg($){let Z=new Map;for(let J of $){let X=Z.get(J.hash)||[];X.push(J),Z.set(J.hash,X)}let Y=[];for(let[,J]of Z)if(J.length>1){let X=J[0];Y.push({path:X.path,count:J.length,wastedBytes:X.size*(J.length-1),locations:J.map((Q)=>Q.path)})}return Y.sort((J,X)=>X.wastedBytes-J.wastedBytes)}function U0($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}function AX($){let Z=$.match(/^([\d.]+)\s*(B|KB|MB|GB)?$/i);if(!Z)return 0;let Y=Number.parseFloat(Z[1]);switch((Z[2]||"B").toUpperCase()){case"KB":return Y*1024;case"MB":return Y*1024*1024;case"GB":return Y*1024*1024*1024;default:return Y}}function x3($,Z){if(Z===0)return"0%";return`${($/Z*100).toFixed(1)}%`}var XN,lg,cg;var v3=D(()=>{XN={".js":"js",".mjs":"js",".cjs":"js",".ts":"js",".jsx":"js",".tsx":"js",".css":"css",".scss":"css",".sass":"css",".less":"css",".html":"html",".htm":"html",".png":"image",".jpg":"image",".jpeg":"image",".gif":"image",".svg":"image",".webp":"image",".avif":"image",".ico":"image",".woff":"font",".woff2":"font",".ttf":"font",".eot":"font",".otf":"font"},lg=[/node_modules/,/vendor/,/bower_components/,/\.min\./],cg=[/index\.(js|ts|html)$/,/main\.(js|ts)$/,/app\.(js|ts)$/,/entry\.(js|ts)$/]});function wX($,Z){switch(Z.format){case"json":return eg($,Z);case"markdown":return Zh($,Z);case"text":default:return $h($,Z)}}function eg($,Z){let Y=f3($,Z);return JSON.stringify({timestamp:$.timestamp,buildDir:$.buildDir,summary:{totalSize:$.totalSize,totalSizeFormatted:U0($.totalSize),totalGzipSize:$.totalGzipSize,totalGzipSizeFormatted:U0($.totalGzipSize),moduleCount:$.moduleCount,chunkCount:$.chunks.length,duplicateCount:$.duplicates.length},byType:Object.fromEntries(Object.entries($.byType).map(([J,X])=>[J,{...X,sizeFormatted:U0(X.size),gzipSizeFormatted:U0(X.gzipSize)}])),chunks:$.chunks.map((J)=>({name:J.name,size:J.size,sizeFormatted:U0(J.size),gzipSize:J.gzipSize,gzipSizeFormatted:U0(J.gzipSize),moduleCount:J.modules.length,isEntry:J.isEntry,isVendor:J.isVendor})),largestModules:$.largestModules.slice(0,Z.topModules||10).map((J)=>({path:J.path,size:J.size,sizeFormatted:U0(J.size),gzipSize:J.gzipSize,gzipSizeFormatted:U0(J.gzipSize),type:J.type})),duplicates:$.duplicates,analysis:Y,warnings:$.warnings},null,2)}function $h($,Z){let Y=[],J=Z.showGzip!==!1;if(Y.push(""),Y.push("Bundle Analysis Report"),Y.push("\u2550".repeat(50)),Y.push(""),Y.push("Summary"),Y.push("\u2500".repeat(50)),J)Y.push(`Total Size: ${U0($.totalSize)} (${U0($.totalGzipSize)} gzip)`);else Y.push(`Total Size: ${U0($.totalSize)}`);if(Y.push(`Modules: ${$.moduleCount}`),Y.push(`Chunks: ${$.chunks.length}`),$.duplicates.length>0)Y.push(`Duplicates: ${$.duplicates.length}`);if(Y.push(""),Z.threshold&&$.totalSize>Z.threshold)Y.push(`\u26A0\uFE0F Bundle exceeds threshold of ${U0(Z.threshold)}!`),Y.push("");Y.push("Size by Type"),Y.push("\u2500".repeat(50));let X=["js","css","html","image","font","other"];for(let G of X){let K=$.byType[G];if(K.count>0){let W=x3(K.size,$.totalSize),U=J?` (${U0(K.gzipSize)} gzip)`:"";Y.push(` ${G.padEnd(8)} ${U0(K.size).padStart(12)}${U} ${W.padStart(6)} (${K.count} files)`)}}Y.push(""),Y.push("Chunks"),Y.push("\u2500".repeat(50));for(let G of $.chunks.slice(0,10)){let K=[];if(G.isEntry)K.push("entry");if(G.isVendor)K.push("vendor");let W=K.length>0?` [${K.join(", ")}]`:"",U=J?` (${U0(G.gzipSize)} gzip)`:"";Y.push(` ${G.name.padEnd(20)} ${U0(G.size).padStart(12)}${U}${W}`)}if($.chunks.length>10)Y.push(` ... and ${$.chunks.length-10} more chunks`);Y.push("");let Q=Z.topModules||10;Y.push(`Largest Modules (Top ${Q})`),Y.push("\u2500".repeat(50));for(let G=0;G<Math.min(Q,$.largestModules.length);G++){let K=$.largestModules[G],W=J?` (${U0(K.gzipSize)} gzip)`:"";Y.push(` ${(G+1).toString().padStart(2)}. ${K.path}`),Y.push(` ${U0(K.size)}${W}`)}if(Y.push(""),$.duplicates.length>0){Y.push("Duplicate Modules"),Y.push("\u2500".repeat(50));for(let G of $.duplicates.slice(0,5))Y.push(` ${G.path}`),Y.push(` ${G.count} copies, wasting ${U0(G.wastedBytes)}`);if($.duplicates.length>5)Y.push(` ... and ${$.duplicates.length-5} more duplicates`);Y.push("")}if(Z.recommendations!==!1){let G=f3($,Z);if(G.recommendations.length>0){Y.push("Recommendations"),Y.push("\u2500".repeat(50));for(let K of G.recommendations.slice(0,5)){let W=K.impact==="high"?"\u26A1":K.impact==="medium"?"\uD83D\uDCCA":"\uD83D\uDCA1";Y.push(` ${W} ${K.title}`),Y.push(` ${K.description}`)}Y.push("")}}if($.warnings.length>0){Y.push("Warnings"),Y.push("\u2500".repeat(50));for(let G of $.warnings)Y.push(` \u26A0\uFE0F ${G}`);Y.push("")}return Y.join(`
18182
+ `)}function Zh($,Z){let Y=[],J=Z.showGzip!==!1;if(Y.push("# Bundle Analysis Report"),Y.push(""),Y.push(`Generated: ${new Date($.timestamp).toISOString()}`),Y.push(""),Y.push("## Summary"),Y.push(""),Y.push("| Metric | Value |"),Y.push("|--------|-------|"),Y.push(`| Total Size | ${U0($.totalSize)} |`),J)Y.push(`| Gzip Size | ${U0($.totalGzipSize)} |`);Y.push(`| Modules | ${$.moduleCount} |`),Y.push(`| Chunks | ${$.chunks.length} |`),Y.push(`| Duplicates | ${$.duplicates.length} |`),Y.push(""),Y.push("## Size by Type"),Y.push(""),Y.push("| Type | Size | Gzip | % | Files |"),Y.push("|------|------|------|---|-------|");let X=["js","css","html","image","font","other"];for(let G of X){let K=$.byType[G];if(K.count>0)Y.push(`| ${G} | ${U0(K.size)} | ${U0(K.gzipSize)} | ${x3(K.size,$.totalSize)} | ${K.count} |`)}Y.push(""),Y.push("## Chunks"),Y.push(""),Y.push("| Name | Size | Gzip | Modules | Type |"),Y.push("|------|------|------|---------|------|");for(let G of $.chunks.slice(0,15)){let K=G.isEntry?"Entry":G.isVendor?"Vendor":"-";Y.push(`| ${G.name} | ${U0(G.size)} | ${U0(G.gzipSize)} | ${G.modules.length} | ${K} |`)}Y.push("");let Q=Z.topModules||10;Y.push(`## Largest Modules (Top ${Q})`),Y.push(""),Y.push("| # | Path | Size | Gzip |"),Y.push("|---|------|------|------|");for(let G=0;G<Math.min(Q,$.largestModules.length);G++){let K=$.largestModules[G];Y.push(`| ${G+1} | \`${K.path}\` | ${U0(K.size)} | ${U0(K.gzipSize)} |`)}if(Y.push(""),$.duplicates.length>0){Y.push("## Duplicates"),Y.push(""),Y.push("| Path | Copies | Wasted |"),Y.push("|------|--------|--------|");for(let G of $.duplicates.slice(0,10))Y.push(`| \`${G.path}\` | ${G.count} | ${U0(G.wastedBytes)} |`);Y.push("")}if(Z.recommendations!==!1){let G=f3($,Z);if(G.recommendations.length>0){Y.push("## Recommendations"),Y.push("");for(let K of G.recommendations)Y.push(`### ${K.title}`),Y.push(""),Y.push(K.description),Y.push(""),Y.push(`- **Impact:** ${K.impact}`),Y.push(`- **Effort:** ${K.effort}`),Y.push("")}}return Y.join(`
18183
+ `)}function f3($,Z){let Y=[],J=[];if(Z.threshold&&$.totalSize>Z.threshold)Y.push({severity:"error",message:`Bundle size (${U0($.totalSize)}) exceeds threshold (${U0(Z.threshold)})`});if($.totalSize>1048576)Y.push({severity:"warning",message:`Bundle is over 1MB (${U0($.totalSize)})`,details:"Large bundles can significantly impact load time"});if($.duplicates.length>0){let K=$.duplicates.reduce((W,U)=>W+U.wastedBytes,0);Y.push({severity:"warning",message:`${$.duplicates.length} duplicate modules found, wasting ${U0(K)}`}),J.push({title:"Remove Duplicate Modules",description:"Consider using import aliases or ensuring consistent package versions to eliminate duplicates.",impact:"medium",effort:"low"})}if($.byType.js.size/$.totalSize>0.8&&$.totalSize>512000)J.push({title:"Code Splitting",description:"Over 80% of your bundle is JavaScript. Consider splitting code by route or feature.",impact:"high",effort:"medium"});let Q=$.largestModules.filter((K)=>K.size>102400);if(Q.length>0){Y.push({severity:"info",message:`${Q.length} modules are over 100KB`});for(let K of Q){if(K.path.includes("lodash")&&!K.path.includes("lodash-es"))J.push({title:"Use lodash-es instead of lodash",description:"lodash-es supports tree-shaking and can significantly reduce bundle size.",impact:"high",effort:"low"});if(K.path.includes("moment"))J.push({title:"Replace moment.js",description:"Consider using date-fns or dayjs for smaller date handling libraries.",impact:"high",effort:"medium"})}}if($.byType.image.size>512000)J.push({title:"Optimize Images",description:`Images account for ${U0($.byType.image.size)}. Consider using WebP/AVIF formats and responsive images.`,impact:"high",effort:"low"});let G=100;if($.totalSize>1048576)G-=20;else if($.totalSize>512000)G-=10;if(G-=Math.min(20,$.duplicates.length*2),G-=Math.min(15,Q.length*3),Z.threshold&&$.totalSize>Z.threshold)G-=25;return{score:Math.max(0,G),issues:Y,recommendations:J}}function QN($){for(let[Z,Y]of Object.entries(Yh))if($.includes(Z))return{title:`Optimize ${Z}`,description:`Consider using ${Y.alternative}. Potential savings: ${Y.savings}`,impact:"high",effort:"low"};return null}var Yh;var mU=D(()=>{v3();Yh={lodash:{alternative:"lodash-es or individual imports",savings:"~70%"},moment:{alternative:"date-fns or dayjs",savings:"~90%"},"chart.js":{alternative:"chart.js with tree-shaking",savings:"~50%"},"highlight.js":{alternative:"Selective language imports",savings:"~80%"},fontawesome:{alternative:"Individual icon imports",savings:"~90%"},"material-ui":{alternative:"Named imports from @mui/*",savings:"~60%"}}});function NX($,Z={}){let{title:Y="Bundle Analysis",gzip:J=!0,colorScheme:X="default"}=Z,Q=Jh[X],G=Xh($),K=JSON.stringify(G);return`<!DOCTYPE html>
18184
18184
  <html lang="en">
18185
18185
  <head>
18186
18186
  <meta charset="UTF-8">
@@ -18675,7 +18675,7 @@ ${X.toUpperCase()}:`);for(let G of Q){let K=G.passed?"\x1B[32m\u2713\x1B[0m":"\x
18675
18675
  render();
18676
18676
  </script>
18677
18677
  </body>
18678
- </html>`}function Yh($){let Z={name:"root",size:$.totalSize,gzipSize:$.totalGzipSize,children:[]};for(let Y of $.chunks){let J={name:Y.name,size:Y.size,gzipSize:Y.gzipSize,children:[]};for(let X of Y.modules)Jh(J,X);Z.children.push(J)}return Z}function Jh($,Z){let Y=Z.path.split("/"),J=$;for(let Q=0;Q<Y.length-1;Q++){let G=Y[Q],K=J.children?.find((W)=>W.name===G);if(!K){if(K={name:G,size:0,gzipSize:0,children:[]},!J.children)J.children=[];J.children.push(K)}J=K}let X=Y[Y.length-1];if(!J.children)J.children=[];J.children.push({name:X,path:Z.path,size:Z.size,gzipSize:Z.gzipSize,type:Z.type}),Xh($,Z.size,Z.gzipSize)}function Xh($,Z,Y){}function GN($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function RX($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var Zh;var lU=D(()=>{v3();Zh={default:{js:"#f7df1e",css:"#264de4",html:"#e34c26",image:"#4caf50",font:"#9c27b0",other:"#607d8b",vendor:"#ff5722"},pastel:{js:"#fff3b0",css:"#b0d4ff",html:"#ffb0b0",image:"#b0ffb0",font:"#e0b0ff",other:"#d0d0d0",vendor:"#ffcfb0"},monochrome:{js:"#333333",css:"#555555",html:"#777777",image:"#999999",font:"#bbbbbb",other:"#dddddd",vendor:"#444444"}}});var WN={};$0(WN,{percentage:()=>x3,parseSize:()=>AX,openInBrowser:()=>RX,getModuleRecommendation:()=>QN,getBundleSummary:()=>Gh,generateTreemap:()=>NX,generateReport:()=>wX,formatBytes:()=>U0,collectBundleStats:()=>y3,analyzeBundle:()=>f3,analyze:()=>Qh});import KN from"fs";import cU from"path";async function Qh($={}){let{directory:Z="dist",output:Y,format:J="html",open:X=!0,gzip:Q=!0,threshold:G,recommendations:K=!0,topModules:W=20,parseImports:U=!0}=$,_=await y3(Z,{parseImports:U,detectDuplicates:!0,topModulesCount:W}),q=G?typeof G==="string"?AX(G):G:void 0,B=q?_.totalSize>q:!1,j,H;if(J==="html"){let O={title:`Bundle Analysis - ${cU.basename(cU.resolve(Z))}`,gzip:Q};if(j=NX(_,O),H=Y||cU.join(Z,"bundle-report.html"),await KN.promises.writeFile(H,j),X)RX(H)}else if(j=wX(_,{format:J,threshold:q,recommendations:K,topModules:W,showGzip:Q}),Y)H=Y,await KN.promises.writeFile(H,j);return{stats:_,report:j,outputPath:H,exceedsThreshold:B}}async function Gh($){let Z=await y3($,{parseImports:!1,detectDuplicates:!1,topModulesCount:0});return{totalSize:Z.totalSize,totalSizeFormatted:U0(Z.totalSize),gzipSize:Z.totalGzipSize,gzipSizeFormatted:U0(Z.totalGzipSize),moduleCount:Z.moduleCount,chunkCount:Z.chunks.length}}var UN=D(()=>{v3();mU();lU();v3();mU();lU()});function Kh($={}){let{debug:Z=!1,timeout:Y=30000}=$;return`
18678
+ </html>`}function Xh($){let Z={name:"root",size:$.totalSize,gzipSize:$.totalGzipSize,children:[]};for(let Y of $.chunks){let J={name:Y.name,size:Y.size,gzipSize:Y.gzipSize,children:[]};for(let X of Y.modules)Qh(J,X);Z.children.push(J)}return Z}function Qh($,Z){let Y=Z.path.split("/"),J=$;for(let Q=0;Q<Y.length-1;Q++){let G=Y[Q],K=J.children?.find((W)=>W.name===G);if(!K){if(K={name:G,size:0,gzipSize:0,children:[]},!J.children)J.children=[];J.children.push(K)}J=K}let X=Y[Y.length-1];if(!J.children)J.children=[];J.children.push({name:X,path:Z.path,size:Z.size,gzipSize:Z.gzipSize,type:Z.type}),Gh($,Z.size,Z.gzipSize)}function Gh($,Z,Y){}function GN($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function RX($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var Jh;var lU=D(()=>{v3();Jh={default:{js:"#f7df1e",css:"#264de4",html:"#e34c26",image:"#4caf50",font:"#9c27b0",other:"#607d8b",vendor:"#ff5722"},pastel:{js:"#fff3b0",css:"#b0d4ff",html:"#ffb0b0",image:"#b0ffb0",font:"#e0b0ff",other:"#d0d0d0",vendor:"#ffcfb0"},monochrome:{js:"#333333",css:"#555555",html:"#777777",image:"#999999",font:"#bbbbbb",other:"#dddddd",vendor:"#444444"}}});var WN={};$0(WN,{percentage:()=>x3,parseSize:()=>AX,openInBrowser:()=>RX,getModuleRecommendation:()=>QN,getBundleSummary:()=>Wh,generateTreemap:()=>NX,generateReport:()=>wX,formatBytes:()=>U0,collectBundleStats:()=>y3,analyzeBundle:()=>f3,analyze:()=>Kh});import KN from"fs";import cU from"path";async function Kh($={}){let{directory:Z="dist",output:Y,format:J="html",open:X=!0,gzip:Q=!0,threshold:G,recommendations:K=!0,topModules:W=20,parseImports:U=!0}=$,_=await y3(Z,{parseImports:U,detectDuplicates:!0,topModulesCount:W}),q=G?typeof G==="string"?AX(G):G:void 0,B=q?_.totalSize>q:!1,j,H;if(J==="html"){let O={title:`Bundle Analysis - ${cU.basename(cU.resolve(Z))}`,gzip:Q};if(j=NX(_,O),H=Y||cU.join(Z,"bundle-report.html"),await KN.promises.writeFile(H,j),X)RX(H)}else if(j=wX(_,{format:J,threshold:q,recommendations:K,topModules:W,showGzip:Q}),Y)H=Y,await KN.promises.writeFile(H,j);return{stats:_,report:j,outputPath:H,exceedsThreshold:B}}async function Wh($){let Z=await y3($,{parseImports:!1,detectDuplicates:!1,topModulesCount:0});return{totalSize:Z.totalSize,totalSizeFormatted:U0(Z.totalSize),gzipSize:Z.totalGzipSize,gzipSizeFormatted:U0(Z.totalGzipSize),moduleCount:Z.moduleCount,chunkCount:Z.chunks.length}}var UN=D(()=>{v3();mU();lU();v3();mU();lU()});function Uh($={}){let{debug:Z=!1,timeout:Y=30000}=$;return`
18679
18679
  <script>
18680
18680
  (function() {
18681
18681
  'use strict';
@@ -19141,7 +19141,7 @@ else if (data.type === 'event' && data.method) {
19141
19141
  }
19142
19142
  })();
19143
19143
  </script>
19144
- `.replace("debug: false,",`debug: ${Z},`).replace("timeout: 30000",`timeout: ${Y}`)}function zN($,Z={}){if($.includes("__craftBridgeInitialized"))return $;let Y=Kh(Z);if($.includes("</head>"))return $.replace("</head>",`${Y}
19144
+ `.replace("debug: false,",`debug: ${Z},`).replace("timeout: 30000",`timeout: ${Y}`)}function zN($,Z={}){if($.includes("__craftBridgeInitialized"))return $;let Y=Uh(Z);if($.includes("</head>"))return $.replace("</head>",`${Y}
19145
19145
  </head>`);if($.includes("<body"))return $.replace(/(<body[^>]*>)/,`$1
19146
19146
  ${Y}`);return Y+$}var _N=()=>{};function BN($,Z={}){let{classPrefix:Y="craft"}=Z;if(!$.includes("craft-component-styles"))if($.includes("</head>"))$=$.replace("</head>",`${`
19147
19147
  <style id="craft-component-styles">
@@ -20608,28 +20608,28 @@ ${Y}`);return Y+$}var _N=()=>{};function BN($,Z={}){let{classPrefix:Y="craft"}=Z
20608
20608
  document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
20609
20609
  })();
20610
20610
  </script>
20611
- `;return $=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(J,X,Q)=>{return MX("sidebar",X,Q.trim(),Z,Y)}),$=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(J,X)=>{return MX("sidebar",X,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(J,X,Q)=>{return MX(X,Q,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(J,X,Q,G)=>{return MX(X,Q,G.trim(),Z,Y)}),$}function MX($,Z,Y,J,X){let Q=J.components?.[$]||Wh[$];if(!Q)return console.warn(`[stx] Unknown Craft component: @craft-${$}`),`<div class="${X}-unknown" data-component="${$}">${Y}</div>`;let G=TX(Z),K=[Q.fallbackClasses||`${X}-${$}`];if(G.class)K.push(G.class),delete G.class;if(Q.render)return G.__fallbackClasses=K.join(" "),Q.render(G,Y);let W=Ah(G,Q,K);if(["input","hr","br","img"].includes(Q.fallbackTag))return`<${Q.fallbackTag} ${W}>`;return`<${Q.fallbackTag} ${W}>${Y}</${Q.fallbackTag}>`}function TX($){let Z={},Y=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,J;while((J=Y.exec($))!==null){let[X,Q,G,K]=J,W=G??K;if(X.startsWith(":"))Z[Q]=W;else if(X.startsWith("@"))Z[`on${Q.charAt(0).toUpperCase()}${Q.slice(1)}`]=W;else if(W===void 0)Z[Q]=!0;else Z[Q]=W}return Z}function Uh($,Z){let Y=Y7(String($.id||`craft-sidebar-${Vh(Z||JSON.stringify($))}`)),J=Hh($.spaces)||jh(Z),X=J.length?[]:Lh($.sections)||jN(Z),Q=String($.selectedSpace||J[0]?.id||""),G=J.find((j)=>j.id===Q)||J[0],K=String($.selectedItem||$.selected||(J.length?G?.sections[0]?.items[0]?.id:X[0]?.items[0]?.id)||""),W={id:Y,variant:String($.variant||"desktop"),material:String($.material||"sidebar"),backgroundEffect:String($.backgroundEffect||"shimmer"),allowsVibrancy:$.allowsVibrancy!==!1&&$.allowsVibrancy!=="false",materialOpacity:Number($.materialOpacity??0.68),materialDarkOpacity:$.materialDarkOpacity===void 0?void 0:Number($.materialDarkOpacity),minWidth:$.minWidth===void 0?240:Number($.minWidth),maxWidth:$.maxWidth===void 0?340:Number($.maxWidth),canCollapse:$.canCollapse!==!1&&$.canCollapse!=="false",searchPlaceholder:$.searchPlaceholder?String($.searchPlaceholder):void 0,selectedItem:K,sections:X,spaces:J,selectedSpace:Q||void 0},U=String($.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),z=Number($.width||$.sidebarWidth||286),_=$.native===!1||$.native==="false"?"false":"true",q=W.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${p4(W.searchPlaceholder)}"></div>`:"",B;if(J.length)B=Oh(J,Q,K);else if(X.length)B=X.map((j)=>HN(j,K)).join("");else B=Z;return`<aside class="${d1(U)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${d1(Y)}" data-native="${_}" style="--craft-sidebar-width:${z}px">
20611
+ `;return $=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(J,X,Q)=>{return MX("sidebar",X,Q.trim(),Z,Y)}),$=$.replace(/<@craft-sidebar(?![-\w])\s*([^>]*?)\/>/g,(J,X)=>{return MX("sidebar",X,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(J,X,Q)=>{return MX(X,Q,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(J,X,Q,G)=>{return MX(X,Q,G.trim(),Z,Y)}),$}function MX($,Z,Y,J,X){let Q=J.components?.[$]||zh[$];if(!Q)return console.warn(`[stx] Unknown Craft component: @craft-${$}`),`<div class="${X}-unknown" data-component="${$}">${Y}</div>`;let G=TX(Z),K=[Q.fallbackClasses||`${X}-${$}`];if(G.class)K.push(G.class),delete G.class;if(Q.render)return G.__fallbackClasses=K.join(" "),Q.render(G,Y);let W=Nh(G,Q,K);if(["input","hr","br","img"].includes(Q.fallbackTag))return`<${Q.fallbackTag} ${W}>`;return`<${Q.fallbackTag} ${W}>${Y}</${Q.fallbackTag}>`}function TX($){let Z={},Y=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,J;while((J=Y.exec($))!==null){let[X,Q,G,K]=J,W=G??K;if(X.startsWith(":"))Z[Q]=W;else if(X.startsWith("@"))Z[`on${Q.charAt(0).toUpperCase()}${Q.slice(1)}`]=W;else if(W===void 0)Z[Q]=!0;else Z[Q]=W}return Z}function _h($,Z){let Y=Y7(String($.id||`craft-sidebar-${Ah(Z||JSON.stringify($))}`)),J=Lh($.spaces)||Oh(Z),X=J.length?[]:Fh($.sections)||jN(Z),Q=String($.selectedSpace||J[0]?.id||""),G=J.find((j)=>j.id===Q)||J[0],K=String($.selectedItem||$.selected||(J.length?G?.sections[0]?.items[0]?.id:X[0]?.items[0]?.id)||""),W={id:Y,variant:String($.variant||"desktop"),material:String($.material||"sidebar"),backgroundEffect:String($.backgroundEffect||"shimmer"),allowsVibrancy:$.allowsVibrancy!==!1&&$.allowsVibrancy!=="false",materialOpacity:Number($.materialOpacity??0.68),materialDarkOpacity:$.materialDarkOpacity===void 0?void 0:Number($.materialDarkOpacity),minWidth:$.minWidth===void 0?240:Number($.minWidth),maxWidth:$.maxWidth===void 0?340:Number($.maxWidth),canCollapse:$.canCollapse!==!1&&$.canCollapse!=="false",searchPlaceholder:$.searchPlaceholder?String($.searchPlaceholder):void 0,selectedItem:K,sections:X,spaces:J,selectedSpace:Q||void 0},U=String($.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),z=Number($.width||$.sidebarWidth||286),_=$.native===!1||$.native==="false"?"false":"true",q=W.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${p4(W.searchPlaceholder)}"></div>`:"",B;if(J.length)B=Vh(J,Q,K);else if(X.length)B=X.map((j)=>HN(j,K)).join("");else B=Z;return`<aside class="${d1(U)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${d1(Y)}" data-native="${_}" style="--craft-sidebar-width:${z}px">
20612
20612
  ${q}
20613
20613
  ${B}
20614
20614
  </aside>
20615
- <script type="application/json" data-craft-sidebar-config="${d1(Y)}">${Fh(W)}</script>`}function zh($,Z){let Y=Y7(String($.id||$.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${d1(Y)}">
20615
+ <script type="application/json" data-craft-sidebar-config="${d1(Y)}">${wh(W)}</script>`}function qh($,Z){let Y=Y7(String($.id||$.label||"space"));return`<section class="craft-sidebar-space" data-craft="craft-sidebar-space" data-space-id="${d1(Y)}">
20616
20616
  ${$.label?`<div class="craft-sidebar-space-title">${p4(String($.label))}</div>`:""}
20617
20617
  ${Z}
20618
- </section>`}function _h($,Z){let Y=String($.header||$.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${d1(String($.id||"section"))}">
20618
+ </section>`}function Bh($,Z){let Y=String($.header||$.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${d1(String($.id||"section"))}">
20619
20619
  ${Y?`<div class="craft-sidebar-section-title">${p4(Y)}</div>`:""}
20620
20620
  ${Z}
20621
- </section>`}function qh($,Z){let Y={id:String($.id||Y7(String($.label||Z||"item"))),label:String($.label||Z||""),icon:$.icon?String($.icon):void 0,badge:$.badge?String($.badge):void 0,tintColor:$.tintColor?String($.tintColor):void 0};return ON(Y,String($.selected||"")==="true")}function jN($){let Z=[],Y=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,J;while((J=Y.exec($))!==null){let X=TX(J[1]||""),Q=J[2]||"",G=String(X.id||Y7(String(X.header||X.title||`section-${Z.length+1}`))),K=String(X.header||X.title||G),W=Bh(Q);Z.push({id:G,header:K,title:K,items:W})}return Z}function Bh($){let Z=[],Y=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,J;while((J=Y.exec($))!==null){let X=TX(J[1]||""),Q=String(X.label||(J[2]||"").replace(/<[^>]*>/g,"").trim()),G=String(X.id||Y7(Q||`item-${Z.length+1}`));Z.push({id:G,label:Q,icon:X.icon?String(X.icon):void 0,badge:X.badge?String(X.badge):void 0,tintColor:X.tintColor?String(X.tintColor):void 0})}return Z}function jh($){let Z=[],Y=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,J;while((J=Y.exec($))!==null){let X=TX(J[1]||""),Q=J[2]||"",G=String(X.label||X.title||`Space ${Z.length+1}`);Z.push({id:String(X.id||Y7(G)),label:G,icon:X.icon?String(X.icon):void 0,tint:X.tint?String(X.tint):void 0,sections:jN(Q)})}return Z}function Hh($){if(!$)return;if(Array.isArray($))return $;if(typeof $!=="string")return;try{let Z=JSON.parse($);return Array.isArray(Z)?Z:void 0}catch{return}}function Oh($,Z,Y){let J=$.map((Q)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${d1(Q.id)}" data-selected="${Q.id===Z?"true":"false"}" title="${d1(Q.label||Q.id)}">${Q.icon?`<span class="craft-sidebar-item-icon" data-icon="${d1(Q.icon)}"></span>`:p4((Q.label||Q.id).charAt(0))}</button>`).join("");return`<div class="craft-sidebar-spaces">${$.map((Q)=>`<section class="craft-sidebar-space" data-space-id="${d1(Q.id)}" data-selected="${Q.id===Z?"true":"false"}">
20621
+ </section>`}function jh($,Z){let Y={id:String($.id||Y7(String($.label||Z||"item"))),label:String($.label||Z||""),icon:$.icon?String($.icon):void 0,badge:$.badge?String($.badge):void 0,tintColor:$.tintColor?String($.tintColor):void 0};return ON(Y,String($.selected||"")==="true")}function jN($){let Z=[],Y=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,J;while((J=Y.exec($))!==null){let X=TX(J[1]||""),Q=J[2]||"",G=String(X.id||Y7(String(X.header||X.title||`section-${Z.length+1}`))),K=String(X.header||X.title||G),W=Hh(Q);Z.push({id:G,header:K,title:K,items:W})}return Z}function Hh($){let Z=[],Y=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,J;while((J=Y.exec($))!==null){let X=TX(J[1]||""),Q=String(X.label||(J[2]||"").replace(/<[^>]*>/g,"").trim()),G=String(X.id||Y7(Q||`item-${Z.length+1}`));Z.push({id:G,label:Q,icon:X.icon?String(X.icon):void 0,badge:X.badge?String(X.badge):void 0,tintColor:X.tintColor?String(X.tintColor):void 0})}return Z}function Oh($){let Z=[],Y=/<@craft-sidebar-space\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-space>)/g,J;while((J=Y.exec($))!==null){let X=TX(J[1]||""),Q=J[2]||"",G=String(X.label||X.title||`Space ${Z.length+1}`);Z.push({id:String(X.id||Y7(G)),label:G,icon:X.icon?String(X.icon):void 0,tint:X.tint?String(X.tint):void 0,sections:jN(Q)})}return Z}function Lh($){if(!$)return;if(Array.isArray($))return $;if(typeof $!=="string")return;try{let Z=JSON.parse($);return Array.isArray(Z)?Z:void 0}catch{return}}function Vh($,Z,Y){let J=$.map((Q)=>`<button class="craft-sidebar-space-tab" type="button" data-space-target="${d1(Q.id)}" data-selected="${Q.id===Z?"true":"false"}" title="${d1(Q.label||Q.id)}">${Q.icon?`<span class="craft-sidebar-item-icon" data-icon="${d1(Q.icon)}"></span>`:p4((Q.label||Q.id).charAt(0))}</button>`).join("");return`<div class="craft-sidebar-spaces">${$.map((Q)=>`<section class="craft-sidebar-space" data-space-id="${d1(Q.id)}" data-selected="${Q.id===Z?"true":"false"}">
20622
20622
  ${Q.label?`<div class="craft-sidebar-space-title">${p4(Q.label)}</div>`:""}
20623
20623
  ${Q.sections.map((G)=>HN(G,Y)).join("")}
20624
20624
  </section>`).join("")}</div>
20625
- <div class="craft-sidebar-space-switcher">${J}</div>`}function Lh($){if(!$)return;if(Array.isArray($))return $;if(typeof $!=="string")return;try{let Z=JSON.parse($);return Array.isArray(Z)?Z:void 0}catch{return}}function HN($,Z){let Y=$.header||$.title||$.id;return`<section class="craft-sidebar-section" data-section-id="${d1($.id)}">
20625
+ <div class="craft-sidebar-space-switcher">${J}</div>`}function Fh($){if(!$)return;if(Array.isArray($))return $;if(typeof $!=="string")return;try{let Z=JSON.parse($);return Array.isArray(Z)?Z:void 0}catch{return}}function HN($,Z){let Y=$.header||$.title||$.id;return`<section class="craft-sidebar-section" data-section-id="${d1($.id)}">
20626
20626
  <div class="craft-sidebar-section-title">${p4(Y)}</div>
20627
20627
  ${$.items.map((J)=>ON(J,J.id===Z)).join("")}
20628
20628
  </section>`}function ON($,Z){let Y=$.tintColor?` style="--craft-sidebar-icon-color:${d1($.tintColor)}"`:"";return`<button class="craft-sidebar-item" type="button" data-item-id="${d1($.id)}" data-selected="${Z?"true":"false"}">
20629
20629
  ${$.icon?`<span class="craft-sidebar-item-icon" data-icon="${d1($.icon)}"${Y}></span>`:""}
20630
20630
  <span class="craft-sidebar-item-label">${p4($.label)}</span>
20631
20631
  ${$.badge?`<span class="craft-sidebar-item-badge">${p4($.badge)}</span>`:""}
20632
- </button>`}function Y7($){return $.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function Vh($){let Z=5381;for(let Y=0;Y<$.length;Y++)Z=Z*33^$.charCodeAt(Y);return(Z>>>0).toString(36)}function p4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function d1($){return p4($).replace(/`/g,"&#96;")}function Fh($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function Ah($,Z,Y){let J=[];J.push(`class="${Y.join(" ")}"`),J.push(`data-craft="${Z.nativeType}"`);for(let[X,Q]of Object.entries($))if(Q===!0)J.push(X);else if(Q!==!1&&Q!==void 0&&Q!==null){let G=String(Q).replace(/"/g,"&quot;");J.push(`${X}="${G}"`)}return J.join(" ")}var Wh,qN=`
20632
+ </button>`}function Y7($){return $.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function Ah($){let Z=5381;for(let Y=0;Y<$.length;Y++)Z=Z*33^$.charCodeAt(Y);return(Z>>>0).toString(36)}function p4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function d1($){return p4($).replace(/`/g,"&#96;")}function wh($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function Nh($,Z,Y){let J=[];J.push(`class="${Y.join(" ")}"`),J.push(`data-craft="${Z.nativeType}"`);for(let[X,Q]of Object.entries($))if(Q===!0)J.push(X);else if(Q!==!1&&Q!==void 0&&Q!==null){let G=String(Q).replace(/"/g,"&quot;");J.push(`${X}="${G}"`)}return J.join(" ")}var zh,qN=`
20633
20633
  <style id="craft-component-styles">
20634
20634
  /* Craft Component Base Styles */
20635
20635
  .craft-button {
@@ -21047,7 +21047,7 @@ ${Y}`);return Y+$}var _N=()=>{};function BN($,Z={}){let{classPrefix:Y="craft"}=Z
21047
21047
  }
21048
21048
  }
21049
21049
  </style>
21050
- `;var LN=D(()=>{Wh={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:($,Z)=>{let Y=$.checked?"checked":"",J=$.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
21050
+ `;var LN=D(()=>{zh={button:{nativeType:"craft-button",fallbackTag:"button",fallbackClasses:"craft-button",nativeProps:["variant","size","disabled","loading"]},"text-input":{nativeType:"craft-text-input",fallbackTag:"input",fallbackClasses:"craft-text-input",nativeProps:["placeholder","value","type","disabled","readonly"]},textarea:{nativeType:"craft-textarea",fallbackTag:"textarea",fallbackClasses:"craft-textarea",nativeProps:["placeholder","value","rows","disabled","readonly"]},checkbox:{nativeType:"craft-checkbox",fallbackTag:"input",fallbackClasses:"craft-checkbox",nativeProps:["checked","disabled","label"],render:($,Z)=>{let Y=$.checked?"checked":"",J=$.disabled?"disabled":"";return`<label class="craft-checkbox-wrapper">
21051
21051
  <input type="checkbox" class="craft-checkbox" ${Y} ${J}>
21052
21052
  <span class="craft-checkbox-label">${Z||$.label||""}</span>
21053
21053
  </label>`}},radio:{nativeType:"craft-radio",fallbackTag:"input",fallbackClasses:"craft-radio",nativeProps:["checked","disabled","name","value","label"]},select:{nativeType:"craft-select",fallbackTag:"select",fallbackClasses:"craft-select",nativeProps:["value","disabled","options","placeholder"]},slider:{nativeType:"craft-slider",fallbackTag:"input",fallbackClasses:"craft-slider",nativeProps:["value","min","max","step","disabled"],render:($,Z)=>{let Y=$.min??0,J=$.max??100,X=$.step??1,Q=$.value??50,G=$.disabled?"disabled":"";return`<input type="range" class="craft-slider" min="${Y}" max="${J}" step="${X}" value="${Q}" ${G}>`}},label:{nativeType:"craft-label",fallbackTag:"span",fallbackClasses:"craft-label",nativeProps:["text","for"]},badge:{nativeType:"craft-badge",fallbackTag:"span",fallbackClasses:"craft-badge",nativeProps:["variant","size"]},avatar:{nativeType:"craft-avatar",fallbackTag:"div",fallbackClasses:"craft-avatar",nativeProps:["src","alt","size","fallback"],render:($,Z)=>{let Y=$.size||40,J=$.src,X=String($.alt||""),Q=$.fallback||(X?X.charAt(0).toUpperCase():"?");if(J)return`<img class="craft-avatar" src="${J}" alt="${X}" style="width:${Y}px;height:${Y}px;border-radius:50%">`;return`<div class="craft-avatar craft-avatar-fallback" style="width:${Y}px;height:${Y}px;border-radius:50%;display:flex;align-items:center;justify-content:center">${Q}</div>`}},progress:{nativeType:"craft-progress",fallbackTag:"div",fallbackClasses:"craft-progress",nativeProps:["value","max","variant"],render:($,Z)=>{let Y=Number($.value)||0,J=Number($.max)||100;return`<div class="craft-progress"><div class="craft-progress-bar" style="width:${Math.min(100,Math.max(0,Y/J*100))}%"></div></div>`}},spinner:{nativeType:"craft-spinner",fallbackTag:"div",fallbackClasses:"craft-spinner",nativeProps:["size"],render:($,Z)=>{let Y=$.size||24;return`<div class="craft-spinner" style="width:${Y}px;height:${Y}px"></div>`}},card:{nativeType:"craft-card",fallbackTag:"div",fallbackClasses:"craft-card",nativeProps:["title","subtitle","variant"]},modal:{nativeType:"craft-modal",fallbackTag:"dialog",fallbackClasses:"craft-modal",nativeProps:["open","title","closable","size"],render:($,Z)=>{let Y=$.open?"open":"",J=$.title||"";return`<dialog class="craft-modal" ${Y}>
@@ -21061,16 +21061,16 @@ ${Y}`);return Y+$}var _N=()=>{};function BN($,Z={}){let{classPrefix:Y="craft"}=Z
21061
21061
  </details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:($,Z)=>{let Y=$.variant||"info",J=$.title||"";return`<div class="craft-alert craft-alert-${Y}" role="alert">
21062
21062
  ${J?`<div class="craft-alert-title">${J}</div>`:""}
21063
21063
  <div class="craft-alert-content">${Z}</div>
21064
- </div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:($,Z)=>{let Y=$.content||"",J=$.position||"top";return`<span class="craft-tooltip" data-tooltip="${Y}" data-position="${J}">${Z}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:Uh},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:zh},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:_h},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:qh},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:($,Z)=>{return`<input type="color" class="craft-color-picker" value="${$.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:($,Z)=>{let Y=$.value||"",J=$.min||"",X=$.max||"";return`<input type="date" class="craft-date-picker" value="${Y}" min="${J}" max="${X}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:($,Z)=>{return`<input type="time" class="craft-time-picker" value="${$.value||""}">`}}}});var MN={};$0(MN,{getAvailableTargets:()=>NN,getAvailableFormats:()=>RN,default:()=>gh,buildNative:()=>wN});import{existsSync as FN,mkdirSync as l1,copyFileSync as b6,chmodSync as P6}from"fs";import{join as o,basename as wh}from"path";import{spawn as EX,execSync as Nh}from"child_process";import{tmpdir as AN,homedir as pU,platform as Rh}from"os";async function wN($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||g3(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||g3(),J=$.format||bh(Y),X=$.output||o(process.cwd(),"dist","native");if(!FN(X))l1(X,{recursive:!0});let Q=await IU($.input,{context:$.context,options:{isDev:!1}});if(Q=zN(Q,{debug:$.verbose}),Q=BN(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${qN}
21065
- </head>`)}let G=$.name||wh($.input,".stx"),K=$.version||"1.0.0",W=$.craftPath||await Ch();if(!W)return{success:!1,target:Y,format:J,error:"Craft binary not found. Please install Craft or specify craftPath."};if($.verbose)console.log(`\uD83D\uDCE6 Building native app for ${Y}...`),console.log(` Input: ${$.input}`),console.log(` Output: ${X}`),console.log(` Craft: ${W}`);let U;switch(Y){case"macos":U=await Mh(Q,G,K,X,J,$,W);break;case"windows":U=await Ih(Q,G,K,X,J,$,W);break;case"linux":U=await Dh(Q,G,K,X,J,$,W);break;case"ios":U=await kh(Q,G,K,X,$,W);break;case"android":U=await Sh(Q,G,K,X,$,W);break;default:U={success:!1,target:Y,format:J,error:`Unsupported target: ${Y}`}}return U.duration=Date.now()-Z,U}catch(Y){return{success:!1,target:$.target||g3(),format:$.format||"app",error:Y.message,duration:Date.now()-Z}}}async function Mh($,Z,Y,J,X,Q,G){let K=Q.bundleId||`com.stx.${Z.toLowerCase().replace(/[^a-z0-9]/g,"")}`,W=o(J,`${Z}.app`),U=o(W,"Contents"),z=o(U,"MacOS"),_=o(U,"Resources");l1(z,{recursive:!0}),l1(_,{recursive:!0});let q=o(_,"index.html");await Bun.write(q,$);let B="";if(Q.sidebar?.enabled&&Q.sidebar?.config)B=o(_,"sidebar-config.json"),await Bun.write(B,JSON.stringify(Q.sidebar.config));let j=Q.sidebar?.enabled?`--native-sidebar --sidebar-width ${Q.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",H=Q.menubarOnly??Q.systemTray;if((Q.bundleStyle||(await Th(G)?"executable":"launcher"))==="executable"){let F=o(z,Z);b6(G,F),P6(F,493);let A={html:"index.html",title:Q.window?.title||Z,width:Q.window?.width||1200,height:Q.window?.height||800,devTools:Boolean(Q.devTools)};if(H)A.menubarOnly=!0;else if(Q.systemTray)A.systemTray=!0;if(Q.window?.frameless)A.frameless=!0;if(Q.window?.transparent)A.transparent=!0;if(Q.window?.alwaysOnTop)A.alwaysOnTop=!0;if(Q.window?.resizable===!1)A.resizable=!1;await Bun.write(o(_,"craft.json"),`${JSON.stringify(A,null,2)}
21064
+ </div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:($,Z)=>{let Y=$.content||"",J=$.position||"top";return`<span class="craft-tooltip" data-tooltip="${Y}" data-position="${J}">${Z}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections","spaces","selectedSpace"],render:_h},"sidebar-space":{nativeType:"craft-sidebar-space",fallbackTag:"section",fallbackClasses:"craft-sidebar-space",nativeProps:["id","label","icon","tint"],render:qh},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:Bh},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:jh},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:($,Z)=>{return`<input type="color" class="craft-color-picker" value="${$.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:($,Z)=>{let Y=$.value||"",J=$.min||"",X=$.max||"";return`<input type="date" class="craft-date-picker" value="${Y}" min="${J}" max="${X}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:($,Z)=>{return`<input type="time" class="craft-time-picker" value="${$.value||""}">`}}}});var MN={};$0(MN,{getAvailableTargets:()=>NN,getAvailableFormats:()=>RN,default:()=>dh,buildNative:()=>wN});import{existsSync as FN,mkdirSync as l1,copyFileSync as b6,chmodSync as P6}from"fs";import{join as o,basename as Rh}from"path";import{spawn as EX,execSync as Mh}from"child_process";import{tmpdir as AN,homedir as pU,platform as Th}from"os";async function wN($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||g3(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||g3(),J=$.format||yh(Y),X=$.output||o(process.cwd(),"dist","native");if(!FN(X))l1(X,{recursive:!0});let Q=await IU($.input,{context:$.context,options:{isDev:!1}});if(Q=zN(Q,{debug:$.verbose}),Q=BN(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${qN}
21065
+ </head>`)}let G=$.name||Rh($.input,".stx"),K=$.version||"1.0.0",W=$.craftPath||await Ph();if(!W)return{success:!1,target:Y,format:J,error:"Craft binary not found. Please install Craft or specify craftPath."};if($.verbose)console.log(`\uD83D\uDCE6 Building native app for ${Y}...`),console.log(` Input: ${$.input}`),console.log(` Output: ${X}`),console.log(` Craft: ${W}`);let U;switch(Y){case"macos":U=await Eh(Q,G,K,X,J,$,W);break;case"windows":U=await kh(Q,G,K,X,J,$,W);break;case"linux":U=await Sh(Q,G,K,X,J,$,W);break;case"ios":U=await Ch(Q,G,K,X,$,W);break;case"android":U=await bh(Q,G,K,X,$,W);break;default:U={success:!1,target:Y,format:J,error:`Unsupported target: ${Y}`}}return U.duration=Date.now()-Z,U}catch(Y){return{success:!1,target:$.target||g3(),format:$.format||"app",error:Y.message,duration:Date.now()-Z}}}async function Eh($,Z,Y,J,X,Q,G){let K=Q.bundleId||`com.stx.${Z.toLowerCase().replace(/[^a-z0-9]/g,"")}`,W=o(J,`${Z}.app`),U=o(W,"Contents"),z=o(U,"MacOS"),_=o(U,"Resources");l1(z,{recursive:!0}),l1(_,{recursive:!0});let q=o(_,"index.html");await Bun.write(q,$);let B="";if(Q.sidebar?.enabled&&Q.sidebar?.config)B=o(_,"sidebar-config.json"),await Bun.write(B,JSON.stringify(Q.sidebar.config));let j=Q.sidebar?.enabled?`--native-sidebar --sidebar-width ${Q.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",H=Q.menubarOnly??Q.systemTray;if((Q.bundleStyle||(await Ih(G)?"executable":"launcher"))==="executable"){let F=o(z,Z);b6(G,F),P6(F,493);let A={html:"index.html",title:Q.window?.title||Z,width:Q.window?.width||1200,height:Q.window?.height||800,devTools:Boolean(Q.devTools)};if(H)A.menubarOnly=!0;else if(Q.systemTray)A.systemTray=!0;if(Q.window?.frameless)A.frameless=!0;if(Q.window?.transparent)A.transparent=!0;if(Q.window?.alwaysOnTop)A.alwaysOnTop=!0;if(Q.window?.resizable===!1)A.resizable=!1;await Bun.write(o(_,"craft.json"),`${JSON.stringify(A,null,2)}
21066
21066
  `)}else{let F=o(z,"craft");b6(G,F),P6(F,493);let A=Q.sidebar?.enabled?`--native-sidebar --sidebar-width ${Q.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",N=`#!/bin/bash
21067
21067
  set -euo pipefail
21068
21068
  DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
21069
21069
  RESOURCES="$DIR/../Resources"
21070
21070
  exec "$DIR/craft" --html-file "$RESOURCES/index.html" \\
21071
21071
  ${[`--title "${Q.window?.title||Z}"`,`--width ${Q.window?.width||1200}`,`--height ${Q.window?.height||800}`,H?"--menubar-only":Q.systemTray?"--system-tray":"",Q.devTools?"":"--no-devtools",Q.window?.frameless?"--frameless":"",Q.window?.transparent?"--transparent":"",Q.window?.alwaysOnTop?"--always-on-top":"",Q.window?.resizable===!1?"--no-resize":"",A].filter(Boolean).join(" \\\n ")}
21072
- `,R=o(z,Z);await Bun.write(R,N),P6(R,493)}let V=Boolean(Q.icon&&await Bun.file(Q.icon).exists());if(V)b6(Q.icon,o(_,"AppIcon.icns"));let L={CFBundleExecutable:Z,CFBundleIdentifier:K,CFBundleName:Z,CFBundleDisplayName:Z,CFBundleShortVersionString:Y,CFBundleVersion:Y,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:Q.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:Q.menubarOnly??Boolean(Q.systemTray),...V?{CFBundleIconFile:"AppIcon"}:{},...Q.category?{LSApplicationCategoryType:Q.category}:{},...Q.copyright?{NSHumanReadableCopyright:Q.copyright}:{},...Q.infoPlist||{}};if(await Bun.write(o(U,"Info.plist"),Eh(L)),X==="dmg"){let F=o(J,`${Z}-${Y}.dmg`),A=await Ph(W,F,Z);if(!A.success)return{success:!1,target:"macos",format:"dmg",error:A.error};return{success:!0,target:"macos",format:"dmg",outputPath:F}}return{success:!0,target:"macos",format:"app",outputPath:W}}async function Th($){try{let Z=Bun.spawn([$,"--version"],{stdout:"pipe",stderr:"pipe"}),[Y,J]=await Promise.all([new Response(Z.stdout).text(),new Response(Z.stderr).text()]);await Z.exited;let Q=`${Y}
21073
- ${J}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!Q)return!1;let[G,K,W]=Q.slice(1).map(Number);if(G>0||K>0)return!0;return W>=57}catch{return!1}}function VN($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Eh($){return`<?xml version="1.0" encoding="UTF-8"?>
21072
+ `,R=o(z,Z);await Bun.write(R,N),P6(R,493)}let V=Boolean(Q.icon&&await Bun.file(Q.icon).exists());if(V)b6(Q.icon,o(_,"AppIcon.icns"));let L={CFBundleExecutable:Z,CFBundleIdentifier:K,CFBundleName:Z,CFBundleDisplayName:Z,CFBundleShortVersionString:Y,CFBundleVersion:Y,CFBundlePackageType:"APPL",CFBundleSignature:"????",LSMinimumSystemVersion:Q.minimumSystemVersion||"13.0",NSHighResolutionCapable:!0,NSSupportsAutomaticGraphicsSwitching:!0,LSUIElement:Q.menubarOnly??Boolean(Q.systemTray),...V?{CFBundleIconFile:"AppIcon"}:{},...Q.category?{LSApplicationCategoryType:Q.category}:{},...Q.copyright?{NSHumanReadableCopyright:Q.copyright}:{},...Q.infoPlist||{}};if(await Bun.write(o(U,"Info.plist"),Dh(L)),X==="dmg"){let F=o(J,`${Z}-${Y}.dmg`),A=await xh(W,F,Z);if(!A.success)return{success:!1,target:"macos",format:"dmg",error:A.error};return{success:!0,target:"macos",format:"dmg",outputPath:F}}return{success:!0,target:"macos",format:"app",outputPath:W}}async function Ih($){try{let Z=Bun.spawn([$,"--version"],{stdout:"pipe",stderr:"pipe"}),[Y,J]=await Promise.all([new Response(Z.stdout).text(),new Response(Z.stderr).text()]);await Z.exited;let Q=`${Y}
21073
+ ${J}`.match(/(\d+)\.(\d+)\.(\d+)/);if(!Q)return!1;let[G,K,W]=Q.slice(1).map(Number);if(G>0||K>0)return!0;return W>=57}catch{return!1}}function VN($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Dh($){return`<?xml version="1.0" encoding="UTF-8"?>
21074
21074
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
21075
21075
  <plist version="1.0">
21076
21076
  <dict>
@@ -21079,7 +21079,7 @@ ${Object.entries($).map(([Y,J])=>{let X=typeof J==="boolean"?`<${J}/>`:typeof J=
21079
21079
  `)}
21080
21080
  </dict>
21081
21081
  </plist>
21082
- `}async function Ih($,Z,Y,J,X,Q,G){let K=o(J,Z);l1(K,{recursive:!0});let W=o(K,"index.html");await Bun.write(W,$),b6(G,o(K,"craft.exe"));let U=`@echo off
21082
+ `}async function kh($,Z,Y,J,X,Q,G){let K=o(J,Z);l1(K,{recursive:!0});let W=o(K,"index.html");await Bun.write(W,$),b6(G,o(K,"craft.exe"));let U=`@echo off
21083
21083
  set DIR=%~dp0
21084
21084
  "%DIR%craft.exe" --html-file "%DIR%index.html" ^
21085
21085
  --title "${Q.window?.title||Z}" ^
@@ -21087,7 +21087,7 @@ set DIR=%~dp0
21087
21087
  --height ${Q.window?.height||800} ^
21088
21088
  ${Q.systemTray?"--system-tray":""} ^
21089
21089
  ${Q.devTools?"":"--no-devtools"}
21090
- `;if(await Bun.write(o(K,`${Z}.bat`),U),X==="zip"){let z=o(J,`${Z}-${Y}-windows.zip`),_=await yh(K,z);if(!_.success)return{success:!1,target:"windows",format:"zip",error:_.error};return{success:!0,target:"windows",format:"zip",outputPath:z}}return{success:!0,target:"windows",format:"app",outputPath:K}}async function Dh($,Z,Y,J,X,Q,G){let K=o(J,Z);l1(K,{recursive:!0});let W=o(K,"index.html");await Bun.write(W,$);let U=o(K,"craft");b6(G,U),P6(U,493);let z=`#!/bin/bash
21090
+ `;if(await Bun.write(o(K,`${Z}.bat`),U),X==="zip"){let z=o(J,`${Z}-${Y}-windows.zip`),_=await vh(K,z);if(!_.success)return{success:!1,target:"windows",format:"zip",error:_.error};return{success:!0,target:"windows",format:"zip",outputPath:z}}return{success:!0,target:"windows",format:"app",outputPath:K}}async function Sh($,Z,Y,J,X,Q,G){let K=o(J,Z);l1(K,{recursive:!0});let W=o(K,"index.html");await Bun.write(W,$);let U=o(K,"craft");b6(G,U),P6(U,493);let z=`#!/bin/bash
21091
21091
  set -euo pipefail
21092
21092
  DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
21093
21093
  exec "$DIR/craft" --html-file "$DIR/index.html" \\
@@ -21102,8 +21102,8 @@ Name=${Z}
21102
21102
  Exec=${_}
21103
21103
  Terminal=false
21104
21104
  Categories=Utility;
21105
- `;if(await Bun.write(o(K,`${Z.toLowerCase()}.desktop`),q),X==="deb"){let B=o(J,`${Z.toLowerCase()}_${Y}_amd64.deb`),j=await xh(K,B,Z,Y,Q);if(!j.success)return{success:!1,target:"linux",format:"deb",error:j.error};return{success:!0,target:"linux",format:"deb",outputPath:B}}if(X==="appimage"){let B=o(J,`${Z}-${Y}-x86_64.AppImage`),j=await vh(K,B,Z,Q);if(!j.success)return{success:!1,target:"linux",format:"appimage",error:j.error};return{success:!0,target:"linux",format:"appimage",outputPath:B}}return{success:!0,target:"linux",format:"app",outputPath:K}}async function kh($,Z,Y,J,X,Q){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${Z}' to create an iOS project.`}}async function Sh($,Z,Y,J,X,Q){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${Z}' to create an Android project.`}}async function Ch(){if(process.env.CRAFT_BIN&&await Bun.file(process.env.CRAFT_BIN).exists())return process.env.CRAFT_BIN;let $=[o(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft"),o(process.cwd(),"../craft/packages/zig/zig-out/bin/craft"),o(pU(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),o(pU(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",o(pU(),".local/bin/craft"),o(process.env.LOCALAPPDATA||"","craft","craft.exe"),o(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let Z of $)if(await Bun.file(Z).exists())return Z;try{let Y=Nh("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
21106
- `)[0];if(Y&&await Bun.file(Y).exists())return Y}catch{}return null}function g3(){switch(Rh()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function bh($){switch($){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function Ph($,Z,Y){return new Promise((J)=>{let X=EX("hdiutil",["create","-volname",Y,"-srcfolder",$,"-ov","-format","UDZO",Z]);X.on("close",(Q)=>{if(Q===0)J({success:!0});else J({success:!1,error:`hdiutil exited with code ${Q}`})}),X.on("error",(Q)=>{J({success:!1,error:Q.message})})})}async function yh($,Z){return new Promise((Y)=>{let J=EX("zip",["-r",Z,"."],{cwd:$});J.on("close",(X)=>{if(X===0)Y({success:!0});else Y({success:!1,error:`zip exited with code ${X}`})}),J.on("error",(X)=>{Y({success:!1,error:X.message})})})}async function xh($,Z,Y,J,X){return new Promise((Q)=>{try{let G=o(AN(),`stx-deb-${Date.now()}`),K=o(G,"DEBIAN"),W=o(G,"usr","bin"),U=o(G,"usr","share","applications"),z=o(G,"usr","share",Y.toLowerCase());l1(K,{recursive:!0}),l1(W,{recursive:!0}),l1(U,{recursive:!0}),l1(z,{recursive:!0});let _=Z0("fs").readdirSync($);for(let H of _)b6(o($,H),o(z,H));let q=`#!/bin/bash
21105
+ `;if(await Bun.write(o(K,`${Z.toLowerCase()}.desktop`),q),X==="deb"){let B=o(J,`${Z.toLowerCase()}_${Y}_amd64.deb`),j=await fh(K,B,Z,Y,Q);if(!j.success)return{success:!1,target:"linux",format:"deb",error:j.error};return{success:!0,target:"linux",format:"deb",outputPath:B}}if(X==="appimage"){let B=o(J,`${Z}-${Y}-x86_64.AppImage`),j=await gh(K,B,Z,Q);if(!j.success)return{success:!1,target:"linux",format:"appimage",error:j.error};return{success:!0,target:"linux",format:"appimage",outputPath:B}}return{success:!0,target:"linux",format:"app",outputPath:K}}async function Ch($,Z,Y,J,X,Q){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${Z}' to create an iOS project.`}}async function bh($,Z,Y,J,X,Q){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${Z}' to create an Android project.`}}async function Ph(){if(process.env.CRAFT_BIN&&await Bun.file(process.env.CRAFT_BIN).exists())return process.env.CRAFT_BIN;let $=[o(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft"),o(process.cwd(),"../craft/packages/zig/zig-out/bin/craft"),o(pU(),"Code/Tools/craft/packages/zig/zig-out/bin/craft"),o(pU(),"Code/craft/packages/zig/zig-out/bin/craft"),"/usr/local/bin/craft","/usr/bin/craft",o(pU(),".local/bin/craft"),o(process.env.LOCALAPPDATA||"","craft","craft.exe"),o(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let Z of $)if(await Bun.file(Z).exists())return Z;try{let Y=Mh("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
21106
+ `)[0];if(Y&&await Bun.file(Y).exists())return Y}catch{}return null}function g3(){switch(Th()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function yh($){switch($){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function xh($,Z,Y){return new Promise((J)=>{let X=EX("hdiutil",["create","-volname",Y,"-srcfolder",$,"-ov","-format","UDZO",Z]);X.on("close",(Q)=>{if(Q===0)J({success:!0});else J({success:!1,error:`hdiutil exited with code ${Q}`})}),X.on("error",(Q)=>{J({success:!1,error:Q.message})})})}async function vh($,Z){return new Promise((Y)=>{let J=EX("zip",["-r",Z,"."],{cwd:$});J.on("close",(X)=>{if(X===0)Y({success:!0});else Y({success:!1,error:`zip exited with code ${X}`})}),J.on("error",(X)=>{Y({success:!1,error:X.message})})})}async function fh($,Z,Y,J,X){return new Promise((Q)=>{try{let G=o(AN(),`stx-deb-${Date.now()}`),K=o(G,"DEBIAN"),W=o(G,"usr","bin"),U=o(G,"usr","share","applications"),z=o(G,"usr","share",Y.toLowerCase());l1(K,{recursive:!0}),l1(W,{recursive:!0}),l1(U,{recursive:!0}),l1(z,{recursive:!0});let _=Z0("fs").readdirSync($);for(let H of _)b6(o($,H),o(z,H));let q=`#!/bin/bash
21107
21107
  exec /usr/share/${Y.toLowerCase()}/${Y.toLowerCase()} "$@"`;Z0("fs").writeFileSync(o(W,Y.toLowerCase()),q),P6(o(W,Y.toLowerCase()),493);let B=`Package: ${Y.toLowerCase()}
21108
21108
  Version: ${J}
21109
21109
  Section: utils
@@ -21112,7 +21112,7 @@ Architecture: amd64
21112
21112
  Depends: libgtk-3-0, libwebkit2gtk-4.0-37
21113
21113
  Maintainer: ${X.author||"Unknown"}
21114
21114
  Description: ${X.description||Y}
21115
- `;Z0("fs").writeFileSync(o(K,"control"),B);let j=EX("dpkg-deb",["--build",G,Z]);j.on("close",(H)=>{if(Z0("fs").rmSync(G,{recursive:!0,force:!0}),H===0)Q({success:!0});else Q({success:!1,error:`dpkg-deb exited with code ${H}`})}),j.on("error",(H)=>{Z0("fs").rmSync(G,{recursive:!0,force:!0}),Q({success:!1,error:H.message})})}catch(G){Q({success:!1,error:G.message})}})}async function vh($,Z,Y,J){return new Promise((X)=>{try{let Q=o(AN(),`stx-appimage-${Date.now()}`),G=o(Q,`${Y}.AppDir`),K=o(G,"usr"),W=o(K,"bin"),U=o(K,"share");l1(W,{recursive:!0}),l1(U,{recursive:!0});let z=o(U,Y.toLowerCase());l1(z,{recursive:!0});let _=Z0("fs").readdirSync($);for(let O of _)b6(o($,O),o(z,O));let q=`#!/bin/bash
21115
+ `;Z0("fs").writeFileSync(o(K,"control"),B);let j=EX("dpkg-deb",["--build",G,Z]);j.on("close",(H)=>{if(Z0("fs").rmSync(G,{recursive:!0,force:!0}),H===0)Q({success:!0});else Q({success:!1,error:`dpkg-deb exited with code ${H}`})}),j.on("error",(H)=>{Z0("fs").rmSync(G,{recursive:!0,force:!0}),Q({success:!1,error:H.message})})}catch(G){Q({success:!1,error:G.message})}})}async function gh($,Z,Y,J){return new Promise((X)=>{try{let Q=o(AN(),`stx-appimage-${Date.now()}`),G=o(Q,`${Y}.AppDir`),K=o(G,"usr"),W=o(K,"bin"),U=o(K,"share");l1(W,{recursive:!0}),l1(U,{recursive:!0});let z=o(U,Y.toLowerCase());l1(z,{recursive:!0});let _=Z0("fs").readdirSync($);for(let O of _)b6(o($,O),o(z,O));let q=`#!/bin/bash
21116
21116
  SELF=$(readlink -f "$0")
21117
21117
  HERE=\${SELF%/*}
21118
21118
  export PATH="\${HERE}/usr/bin:\${PATH}"
@@ -21124,7 +21124,7 @@ Exec=${Y.toLowerCase()}
21124
21124
  Terminal=false
21125
21125
  Categories=Utility;
21126
21126
  Icon=${Y.toLowerCase()}
21127
- `;Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.desktop`),B);let j=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.png`),j),J.icon&&FN(J.icon))b6(J.icon,o(G,`${Y.toLowerCase()}.png`));let H=EX("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if(Z0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)P6(Z,493),X({success:!0});else X({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(O)=>{Z0("fs").rmSync(Q,{recursive:!0,force:!0}),X({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){X({success:!1,error:Q.message})}})}function NN(){return[g3()]}function RN($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var fh,gh;var TN=D(()=>{_N();LN();DU();fh={buildNative:wN,getAvailableTargets:NN,getAvailableFormats:RN,detectPlatform:g3},gh=fh});function h3($,Z){return`${hh[Z]}${$}\x1B[0m`}function IN($,Z){return`${dh[Z]}${$}\x1B[0m`}function d3(){console.log(""),console.log(Q1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(Q1(" \u2551")+Q4(" \uD83D\uDCD6 STX Story ")+Q1("\u2551")),console.log(Q1(" \u2551")+DX(" Component Showcase & Testing ")+Q1("\u2551")),console.log(Q1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function nU($,Z){if(console.log(Q4(" Server running at:")),console.log(""),console.log(` ${DX("\u279C")} ${Q4("Local:")} ${Q1($)}`),Z)console.log(` ${DX("\u279C")} ${Q4("Network:")} ${Q1(Z)}`);console.log("")}function u3($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?IX:iU;console.log(` ${Y(Z)} Found ${Q4(String($))} story ${$===1?"file":"files"}`)}function DN($,Z){if(console.log(""),console.log(` ${EN("\u2717")} ${Q4(EN("Error:"))} ${$}`),Z)console.log(` ${DX(Z)}`);console.log("")}function J7($){console.log(` ${iU("\u26A0")} ${iU("Warning:")} ${$}`)}function kN($){console.log(` ${uh("\u2139")} ${$}`)}function SN($,Z,Y){console.log(""),console.log(Q1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(Q1(" \u2551")+Q4(" Build Complete ")+Q1("\u2551")),console.log(Q1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${IX("\u2713")} Stories: ${Q4(String($))}`),console.log(` ${IX("\u2713")} Output: ${Q4(Z)}`),console.log(` ${IX("\u2713")} Time: ${Q4(`${Y}ms`)}`),console.log("")}function rU(){console.log(""),console.log(Q4(" Keyboard Shortcuts:")),console.log(""),console.log(` ${Q1("h")} Show this help`),console.log(` ${Q1("o")} Open in browser`),console.log(` ${Q1("r")} Restart server`),console.log(` ${Q1("c")} Clear console`),console.log(` ${Q1("q")} Quit`),console.log("")}var hh,dh,EN=($)=>h3($,"red"),IX=($)=>h3($,"green"),iU=($)=>h3($,"yellow"),uh=($)=>h3($,"blue"),Q1=($)=>h3($,"cyan"),Q4=($)=>IN($,"bold"),DX=($)=>IN($,"dim");var kX=D(()=>{hh={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},dh={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import CN from"fs";import aU from"path";function bN($,Z){let Y=[aU.join($.root,"stx.config.ts"),aU.join($.root,"stx.config.js"),aU.join($.root,"stx.config.mjs")],J=Z.debounceMs??300,X=null,Q=[];for(let G of Y)try{if(!CN.existsSync(G))continue;let K=CN.watch(G,(W)=>{if(W==="change"){if(X)clearTimeout(X);X=setTimeout(async()=>{kN("Config file changed, restarting...");try{await Z.onChange()}catch(U){J7(`Failed to restart: ${U}`)}},J)}});Q.push(K)}catch{}return{stop(){if(X)clearTimeout(X);for(let G of Q)G.close()}}}var PN=D(()=>{kX()});function fN($){let Z={...mh,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...vN,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??yN,backgroundPresets:Z.backgroundPresets??xN,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var yN,xN,vN,mh;var gN=D(()=>{yN=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],xN=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],vN={file:"title",order:"asc",groups:[]},mh={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:vN,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:yN,backgroundPresets:xN,autoApplyContrastColor:!1,port:6006}});var hN={};$0(hN,{updateContextTree:()=>G7,updateContextStoryFiles:()=>Q7,createContext:()=>X7});import lh from"path";async function X7($){let Z=$.root??process.cwd(),Y;try{let G=await import(lh.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let J={...Y,...$.config},X=fN(J);return{root:Z,config:X,storyFiles:[],tree:void 0,mode:$.mode}}function Q7($,Z){$.storyFiles=Z}function G7($,Z){$.tree=Z}var m3=D(()=>{gN()});import sU from"fs";import dN from"path";class oU{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=dN.join($,ch),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=sU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:ph,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=dN.dirname(this.storagePath);if(await sU.promises.mkdir($,{recursive:!0}),this.storage.events.length>uN)this.storage.events=this.storage.events.slice(-uN);await sU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:ih(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,Z){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:Z}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let Z=this.viewStartTimes.get($);if(Z){let Y=Date.now()-Z;this.track({type:"view",componentId:$,metadata:{duration:Y,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,Z,Y){this.track({type:"prop_change",componentId:$,propName:Z,metadata:{value:Y}})}trackVariantSwitch($,Z){this.track({type:"variant_switch",componentId:$,variantId:Z})}trackSearch($,Z){this.track({type:"search",query:$,metadata:{resultCount:Z}})}getComponentAnalytics($,Z){let Y=this.storage.events.filter((q)=>q.componentId===$),J=Y.filter((q)=>q.type==="view"&&!q.metadata?.endView),X=Y.filter((q)=>q.type==="prop_change"),Q=Y.filter((q)=>q.type==="variant_switch"),G={};for(let q of X)if(q.propName)G[q.propName]=(G[q.propName]||0)+1;let K={};for(let q of Q)if(q.variantId)K[q.variantId]=(K[q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((q)=>q.componentViews.includes($)).map((q)=>q.id)),U=Y.filter((q)=>q.metadata?.duration).map((q)=>q.metadata.duration),z=U.length>0?U.reduce((q,B)=>q+B,0)/U.length:0,_=Object.entries(G).sort((q,B)=>B[1]-q[1]).slice(0,5).map(([q])=>q);return{componentId:$,componentName:Z,viewCount:J.length,uniqueViews:W.size,lastViewed:J[J.length-1]?.timestamp,propChanges:G,topChangedProps:_,variantViews:K,avgTimeSpent:z}}getMostViewedComponents($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="view"&&Y.componentId&&!Y.metadata?.endView)Z.set(Y.componentId,(Z.get(Y.componentId)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({componentId:Y,viewCount:J})).sort((Y,J)=>J.viewCount-Y.viewCount).slice(0,$)}getMostChangedProps($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="prop_change"&&Y.propName)Z.set(Y.propName,(Z.get(Y.propName)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({propName:Y,changeCount:J})).sort((Y,J)=>J.changeCount-Y.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((X)=>X.type==="search"),Z=new Map,Y=0;for(let X of $){if(X.query)Z.set(X.query,(Z.get(X.query)||0)+1);if(X.metadata?.resultCount!==void 0)Y+=X.metadata.resultCount}let J=Array.from(Z.entries()).map(([X,Q])=>({query:X,count:Q})).sort((X,Q)=>Q.count-X.count).slice(0,10);return{totalSearches:$.length,topQueries:J,avgResultCount:$.length>0?Y/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function ih(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var ch=".stx/story/analytics.json",ph=1,uN=1e4;var mN=()=>{};import tU from"fs";import lN from"path";class eU{storage;storagePath;dirty=!1;constructor($){this.storagePath=lN.join($,nh),this.storage=this.loadStorage()}loadStorage(){try{let $=tU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:rh,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=lN.dirname(this.storagePath);await tU.promises.mkdir($,{recursive:!0}),await tU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,J={}){let X={id:ah(),name:J.name||`${$}/${Z}`,storyId:$,variantId:Z,props:Y,created:Date.now(),notes:J.notes,color:J.color};return this.storage.bookmarks.push(X),this.dirty=!0,X}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((Z)=>Z.storyId===$)}getBookmark($){return this.storage.bookmarks.find((Z)=>Z.id===$)}isBookmarked($,Z){return this.storage.bookmarks.some((Y)=>Y.storyId===$&&Y.variantId===Z)}updateBookmark($,Z){let Y=this.getBookmark($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deleteBookmark($){let Z=this.storage.bookmarks.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.bookmarks.splice(Z,1),this.dirty=!0,!0}toggleBookmark($,Z,Y){let J=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===Z);if(J)return this.deleteBookmark(J.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,Z,Y)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,Z=!0){let Y=JSON.parse($),J=0;for(let X of Y.bookmarks){if(Z){let Q=this.storage.bookmarks.find((G)=>G.id===X.id);if(Q)Object.assign(Q,X);else this.storage.bookmarks.push(X)}else this.storage.bookmarks.push(X);J++}if(J>0)this.dirty=!0;return J}}function ah(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var nh=".stx/story/bookmarks.json",rh=1;var cN=()=>{};import $z from"fs";import l3 from"path";async function c3($){let{root:Z,config:Y}=$,J=[],X=await sh(Z,Y.storyMatch,Y.storyIgnored);for(let Q of X){let G=l3.resolve(Z,Q),K=Zz(Q,G);J.push(K)}return J}async function sh($,Z,Y){let J=[];async function X(Q,G){let K=await $z.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=l3.join(Q,W.name),z=l3.relative(G,U);if(pN(z,Y))continue;if(W.isDirectory())await X(U,G);else if(W.isFile()){if(iN(z,Z))J.push(z)}}}return await X($,$),J}function pN($,Z){for(let Y of Z)if(nN($,Y))return!0;return!1}function iN($,Z){for(let Y of Z)if(nN($,Y))return!0;return!1}function nN($,Z){let Y=$.replace(/\\/g,"/"),X=Z.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return X=`^${X}$`,new RegExp(X).test(Y)}function Zz($,Z){let Y=l3.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:Z,relativePath:$,fileName:Y,treeFile:{title:Y,path:$}}}function rN($,Z){let{root:Y,config:J}=$,X=[],Q=$z.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!iN(W,J.storyMatch))return;if(pN(W,J.storyIgnored))return;let U=l3.resolve(Y,W);try{await $z.promises.access(U);let z=Zz(W,U);Z(G==="rename"?"add":"change",z)}catch{let z=Zz(W,U);Z("unlink",z)}});return X.push(Q),()=>{for(let G of X)G.close()}}var Yz=()=>{};function oh($,Z){let Y=Z.treeFile||{title:Z.fileName,path:Z.relativePath};if($.tree.file==="title")return Y.title.split("/");if($.tree.file==="path")return[...Z.relativePath.split("/").slice(0,-1),Y.title];if(typeof $.tree.file==="function")return $.tree.file(Y);return[Y.title]}function p3($,Z){for(let G of Z)G.treePath=oh($,G);let Y=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),J={treeObject:{}};Y.push(J);for(let G=0;G<Z.length;G++){let K=Z[G],W=th(K,Y,J);eh(K.treePath,G,W.treeObject)}let X=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Y)if(G===J)Q.push(...Jz(G.treeObject,X));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:Jz(G.treeObject,X)});return Q}function th($,Z,Y){let J=$.treeFile||{title:$.fileName,path:$.relativePath};for(let X of Z)if(X.groupConfig?.include&&X.groupConfig.include(J))return X;return Y}function eh($,Z,Y){let J=Y;for(let X=0;X<$.length;X++){let Q=$[X];if(X===$.length-1)if(J[Q]!==void 0){let K=1;while(J[`${Q}-${K}`]!==void 0)K++;J[`${Q}-${K}`]=Z}else J[Q]=Z;else{if(J[Q]===void 0)J[Q]={};else if(typeof J[Q]==="number"){let K=J[Q];J[Q]={"":K}}J=J[Q]}}}function Jz($,Z){let Y=[];for(let[J,X]of Object.entries($))if(typeof X==="number")Y.push({title:J,index:X});else Y.push({title:J,children:Jz(X,Z)});return Y.sort((J,X)=>Z(J.title,X.title)),Y}function aN(){return{open($){SX.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){SX.delete($)},message($,Z){}}}function Xz($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of SX)try{Y.send(Z)}catch{SX.delete(Y)}}function sN($,Z){Xz({type:"story-update",data:{storyId:$,...Z}})}function oN($,Z){Xz({type:"story-add",data:{storyId:$,...Z}})}function tN($){Xz({type:"story-remove",data:{storyId:$}})}function eN($){return`
21127
+ `;Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.desktop`),B);let j=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(Z0("fs").writeFileSync(o(G,`${Y.toLowerCase()}.png`),j),J.icon&&FN(J.icon))b6(J.icon,o(G,`${Y.toLowerCase()}.png`));let H=EX("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if(Z0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)P6(Z,493),X({success:!0});else X({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(O)=>{Z0("fs").rmSync(Q,{recursive:!0,force:!0}),X({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){X({success:!1,error:Q.message})}})}function NN(){return[g3()]}function RN($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var hh,dh;var TN=D(()=>{_N();LN();DU();hh={buildNative:wN,getAvailableTargets:NN,getAvailableFormats:RN,detectPlatform:g3},dh=hh});function h3($,Z){return`${uh[Z]}${$}\x1B[0m`}function IN($,Z){return`${mh[Z]}${$}\x1B[0m`}function d3(){console.log(""),console.log(Q1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(Q1(" \u2551")+Q4(" \uD83D\uDCD6 STX Story ")+Q1("\u2551")),console.log(Q1(" \u2551")+DX(" Component Showcase & Testing ")+Q1("\u2551")),console.log(Q1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function nU($,Z){if(console.log(Q4(" Server running at:")),console.log(""),console.log(` ${DX("\u279C")} ${Q4("Local:")} ${Q1($)}`),Z)console.log(` ${DX("\u279C")} ${Q4("Network:")} ${Q1(Z)}`);console.log("")}function u3($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?IX:iU;console.log(` ${Y(Z)} Found ${Q4(String($))} story ${$===1?"file":"files"}`)}function DN($,Z){if(console.log(""),console.log(` ${EN("\u2717")} ${Q4(EN("Error:"))} ${$}`),Z)console.log(` ${DX(Z)}`);console.log("")}function J7($){console.log(` ${iU("\u26A0")} ${iU("Warning:")} ${$}`)}function kN($){console.log(` ${lh("\u2139")} ${$}`)}function SN($,Z,Y){console.log(""),console.log(Q1(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(Q1(" \u2551")+Q4(" Build Complete ")+Q1("\u2551")),console.log(Q1(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${IX("\u2713")} Stories: ${Q4(String($))}`),console.log(` ${IX("\u2713")} Output: ${Q4(Z)}`),console.log(` ${IX("\u2713")} Time: ${Q4(`${Y}ms`)}`),console.log("")}function rU(){console.log(""),console.log(Q4(" Keyboard Shortcuts:")),console.log(""),console.log(` ${Q1("h")} Show this help`),console.log(` ${Q1("o")} Open in browser`),console.log(` ${Q1("r")} Restart server`),console.log(` ${Q1("c")} Clear console`),console.log(` ${Q1("q")} Quit`),console.log("")}var uh,mh,EN=($)=>h3($,"red"),IX=($)=>h3($,"green"),iU=($)=>h3($,"yellow"),lh=($)=>h3($,"blue"),Q1=($)=>h3($,"cyan"),Q4=($)=>IN($,"bold"),DX=($)=>IN($,"dim");var kX=D(()=>{uh={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},mh={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import CN from"fs";import aU from"path";function bN($,Z){let Y=[aU.join($.root,"stx.config.ts"),aU.join($.root,"stx.config.js"),aU.join($.root,"stx.config.mjs")],J=Z.debounceMs??300,X=null,Q=[];for(let G of Y)try{if(!CN.existsSync(G))continue;let K=CN.watch(G,(W)=>{if(W==="change"){if(X)clearTimeout(X);X=setTimeout(async()=>{kN("Config file changed, restarting...");try{await Z.onChange()}catch(U){J7(`Failed to restart: ${U}`)}},J)}});Q.push(K)}catch{}return{stop(){if(X)clearTimeout(X);for(let G of Q)G.close()}}}var PN=D(()=>{kX()});function fN($){let Z={...ch,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...vN,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??yN,backgroundPresets:Z.backgroundPresets??xN,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var yN,xN,vN,ch;var gN=D(()=>{yN=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],xN=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],vN={file:"title",order:"asc",groups:[]},ch={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:vN,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:yN,backgroundPresets:xN,autoApplyContrastColor:!1,port:6006}});var hN={};$0(hN,{updateContextTree:()=>G7,updateContextStoryFiles:()=>Q7,createContext:()=>X7});import ph from"path";async function X7($){let Z=$.root??process.cwd(),Y;try{let G=await import(ph.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let J={...Y,...$.config},X=fN(J);return{root:Z,config:X,storyFiles:[],tree:void 0,mode:$.mode}}function Q7($,Z){$.storyFiles=Z}function G7($,Z){$.tree=Z}var m3=D(()=>{gN()});import sU from"fs";import dN from"path";class oU{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=dN.join($,ih),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=sU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:nh,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=dN.dirname(this.storagePath);if(await sU.promises.mkdir($,{recursive:!0}),this.storage.events.length>uN)this.storage.events=this.storage.events.slice(-uN);await sU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:rh(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,Z){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:Z}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let Z=this.viewStartTimes.get($);if(Z){let Y=Date.now()-Z;this.track({type:"view",componentId:$,metadata:{duration:Y,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,Z,Y){this.track({type:"prop_change",componentId:$,propName:Z,metadata:{value:Y}})}trackVariantSwitch($,Z){this.track({type:"variant_switch",componentId:$,variantId:Z})}trackSearch($,Z){this.track({type:"search",query:$,metadata:{resultCount:Z}})}getComponentAnalytics($,Z){let Y=this.storage.events.filter((q)=>q.componentId===$),J=Y.filter((q)=>q.type==="view"&&!q.metadata?.endView),X=Y.filter((q)=>q.type==="prop_change"),Q=Y.filter((q)=>q.type==="variant_switch"),G={};for(let q of X)if(q.propName)G[q.propName]=(G[q.propName]||0)+1;let K={};for(let q of Q)if(q.variantId)K[q.variantId]=(K[q.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((q)=>q.componentViews.includes($)).map((q)=>q.id)),U=Y.filter((q)=>q.metadata?.duration).map((q)=>q.metadata.duration),z=U.length>0?U.reduce((q,B)=>q+B,0)/U.length:0,_=Object.entries(G).sort((q,B)=>B[1]-q[1]).slice(0,5).map(([q])=>q);return{componentId:$,componentName:Z,viewCount:J.length,uniqueViews:W.size,lastViewed:J[J.length-1]?.timestamp,propChanges:G,topChangedProps:_,variantViews:K,avgTimeSpent:z}}getMostViewedComponents($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="view"&&Y.componentId&&!Y.metadata?.endView)Z.set(Y.componentId,(Z.get(Y.componentId)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({componentId:Y,viewCount:J})).sort((Y,J)=>J.viewCount-Y.viewCount).slice(0,$)}getMostChangedProps($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="prop_change"&&Y.propName)Z.set(Y.propName,(Z.get(Y.propName)||0)+1);return Array.from(Z.entries()).map(([Y,J])=>({propName:Y,changeCount:J})).sort((Y,J)=>J.changeCount-Y.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((X)=>X.type==="search"),Z=new Map,Y=0;for(let X of $){if(X.query)Z.set(X.query,(Z.get(X.query)||0)+1);if(X.metadata?.resultCount!==void 0)Y+=X.metadata.resultCount}let J=Array.from(Z.entries()).map(([X,Q])=>({query:X,count:Q})).sort((X,Q)=>Q.count-X.count).slice(0,10);return{totalSearches:$.length,topQueries:J,avgResultCount:$.length>0?Y/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function rh(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var ih=".stx/story/analytics.json",nh=1,uN=1e4;var mN=()=>{};import tU from"fs";import lN from"path";class eU{storage;storagePath;dirty=!1;constructor($){this.storagePath=lN.join($,ah),this.storage=this.loadStorage()}loadStorage(){try{let $=tU.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:sh,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=lN.dirname(this.storagePath);await tU.promises.mkdir($,{recursive:!0}),await tU.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,J={}){let X={id:oh(),name:J.name||`${$}/${Z}`,storyId:$,variantId:Z,props:Y,created:Date.now(),notes:J.notes,color:J.color};return this.storage.bookmarks.push(X),this.dirty=!0,X}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((Z)=>Z.storyId===$)}getBookmark($){return this.storage.bookmarks.find((Z)=>Z.id===$)}isBookmarked($,Z){return this.storage.bookmarks.some((Y)=>Y.storyId===$&&Y.variantId===Z)}updateBookmark($,Z){let Y=this.getBookmark($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deleteBookmark($){let Z=this.storage.bookmarks.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.bookmarks.splice(Z,1),this.dirty=!0,!0}toggleBookmark($,Z,Y){let J=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===Z);if(J)return this.deleteBookmark(J.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,Z,Y)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,Z=!0){let Y=JSON.parse($),J=0;for(let X of Y.bookmarks){if(Z){let Q=this.storage.bookmarks.find((G)=>G.id===X.id);if(Q)Object.assign(Q,X);else this.storage.bookmarks.push(X)}else this.storage.bookmarks.push(X);J++}if(J>0)this.dirty=!0;return J}}function oh(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var ah=".stx/story/bookmarks.json",sh=1;var cN=()=>{};import $z from"fs";import l3 from"path";async function c3($){let{root:Z,config:Y}=$,J=[],X=await th(Z,Y.storyMatch,Y.storyIgnored);for(let Q of X){let G=l3.resolve(Z,Q),K=Zz(Q,G);J.push(K)}return J}async function th($,Z,Y){let J=[];async function X(Q,G){let K=await $z.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=l3.join(Q,W.name),z=l3.relative(G,U);if(pN(z,Y))continue;if(W.isDirectory())await X(U,G);else if(W.isFile()){if(iN(z,Z))J.push(z)}}}return await X($,$),J}function pN($,Z){for(let Y of Z)if(nN($,Y))return!0;return!1}function iN($,Z){for(let Y of Z)if(nN($,Y))return!0;return!1}function nN($,Z){let Y=$.replace(/\\/g,"/"),X=Z.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return X=`^${X}$`,new RegExp(X).test(Y)}function Zz($,Z){let Y=l3.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:Z,relativePath:$,fileName:Y,treeFile:{title:Y,path:$}}}function rN($,Z){let{root:Y,config:J}=$,X=[],Q=$z.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!iN(W,J.storyMatch))return;if(pN(W,J.storyIgnored))return;let U=l3.resolve(Y,W);try{await $z.promises.access(U);let z=Zz(W,U);Z(G==="rename"?"add":"change",z)}catch{let z=Zz(W,U);Z("unlink",z)}});return X.push(Q),()=>{for(let G of X)G.close()}}var Yz=()=>{};function eh($,Z){let Y=Z.treeFile||{title:Z.fileName,path:Z.relativePath};if($.tree.file==="title")return Y.title.split("/");if($.tree.file==="path")return[...Z.relativePath.split("/").slice(0,-1),Y.title];if(typeof $.tree.file==="function")return $.tree.file(Y);return[Y.title]}function p3($,Z){for(let G of Z)G.treePath=eh($,G);let Y=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),J={treeObject:{}};Y.push(J);for(let G=0;G<Z.length;G++){let K=Z[G],W=$d(K,Y,J);Zd(K.treePath,G,W.treeObject)}let X=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Y)if(G===J)Q.push(...Jz(G.treeObject,X));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:Jz(G.treeObject,X)});return Q}function $d($,Z,Y){let J=$.treeFile||{title:$.fileName,path:$.relativePath};for(let X of Z)if(X.groupConfig?.include&&X.groupConfig.include(J))return X;return Y}function Zd($,Z,Y){let J=Y;for(let X=0;X<$.length;X++){let Q=$[X];if(X===$.length-1)if(J[Q]!==void 0){let K=1;while(J[`${Q}-${K}`]!==void 0)K++;J[`${Q}-${K}`]=Z}else J[Q]=Z;else{if(J[Q]===void 0)J[Q]={};else if(typeof J[Q]==="number"){let K=J[Q];J[Q]={"":K}}J=J[Q]}}}function Jz($,Z){let Y=[];for(let[J,X]of Object.entries($))if(typeof X==="number")Y.push({title:J,index:X});else Y.push({title:J,children:Jz(X,Z)});return Y.sort((J,X)=>Z(J.title,X.title)),Y}function aN(){return{open($){SX.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){SX.delete($)},message($,Z){}}}function Xz($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of SX)try{Y.send(Z)}catch{SX.delete(Y)}}function sN($,Z){Xz({type:"story-update",data:{storyId:$,...Z}})}function oN($,Z){Xz({type:"story-add",data:{storyId:$,...Z}})}function tN($){Xz({type:"story-remove",data:{storyId:$}})}function eN($){return`
21128
21128
  <script>
21129
21129
  (function() {
21130
21130
  const ws = new WebSocket('${$}');
@@ -21348,7 +21348,7 @@ else {
21348
21348
  }
21349
21349
  })();
21350
21350
  </script>
21351
- `}function $d($){let Z=[];if($.modifiers)for(let J of $.modifiers)switch(J){case"meta":Z.push("\u2318");break;case"ctrl":Z.push("Ctrl");break;case"alt":Z.push("Alt");break;case"shift":Z.push("\u21E7");break}let Y=$.key;switch(Y){case"ArrowUp":Y="\u2191";break;case"ArrowDown":Y="\u2193";break;case"ArrowLeft":Y="\u2190";break;case"ArrowRight":Y="\u2192";break;case"Enter":Y="\u21B5";break;case"Escape":Y="Esc";break;default:Y=Y.toUpperCase()}return Z.push(Y),Z.join(" + ")}function JR($=YR){let Z=new Map;for(let J of $){let X=Z.get(J.category)||[];X.push(J),Z.set(J.category,X)}return`
21351
+ `}function Yd($){let Z=[];if($.modifiers)for(let J of $.modifiers)switch(J){case"meta":Z.push("\u2318");break;case"ctrl":Z.push("Ctrl");break;case"alt":Z.push("Alt");break;case"shift":Z.push("\u21E7");break}let Y=$.key;switch(Y){case"ArrowUp":Y="\u2191";break;case"ArrowDown":Y="\u2193";break;case"ArrowLeft":Y="\u2190";break;case"ArrowRight":Y="\u2192";break;case"Enter":Y="\u21B5";break;case"Escape":Y="Esc";break;default:Y=Y.toUpperCase()}return Z.push(Y),Z.join(" + ")}function JR($=YR){let Z=new Map;for(let J of $){let X=Z.get(J.category)||[];X.push(J),Z.set(J.category,X)}return`
21352
21352
  <div class="shortcuts-modal" id="shortcuts-modal" style="display: none;">
21353
21353
  <div class="shortcuts-backdrop" onclick="closeShortcutsModal()"></div>
21354
21354
  <div class="shortcuts-content">
@@ -21364,7 +21364,7 @@ else {
21364
21364
  ${X.map((Q)=>`
21365
21365
  <div class="shortcut-item">
21366
21366
  <span class="shortcut-desc">${Q.description}</span>
21367
- <kbd class="shortcut-key">${$d(Q)}</kbd>
21367
+ <kbd class="shortcut-key">${Yd(Q)}</kbd>
21368
21368
  </div>
21369
21369
  `).join("")}
21370
21370
  </div>
@@ -21681,9 +21681,9 @@ window.__stxPerformance = {
21681
21681
 
21682
21682
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
21683
21683
  </script>
21684
- `}var x$0;var zR=D(()=>{x$0=new KR});import Qz from"fs";import _R from"path";class Kz{storage;storagePath;dirty=!1;constructor($){this.storagePath=_R.join($,Zd),this.storage=this.loadStorage()}loadStorage(){try{let $=Qz.readFileSync(this.storagePath,"utf-8"),Z=JSON.parse($);if(Z.version!==Gz)return this.migrateStorage(Z);return Z}catch{return{version:Gz,presets:[],recentIds:[]}}}migrateStorage($){return{version:Gz,presets:$.presets||[],recentIds:$.recentIds||[]}}async save(){if(!this.dirty)return;let $=_R.dirname(this.storagePath);await Qz.promises.mkdir($,{recursive:!0}),await Qz.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset($,Z,Y={}){let J={id:Jd(),name:$,description:Y.description,props:Z,componentId:Y.componentId,created:Date.now(),usageCount:0,tags:Y.tags};return this.storage.presets.push(J),this.dirty=!0,J}getPreset($){return this.storage.presets.find((Z)=>Z.id===$)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent($){return this.storage.presets.filter((Z)=>!Z.componentId||Z.componentId===$)}getRecentPresets(){return this.storage.recentIds.map(($)=>this.getPreset($)).filter(($)=>$!==void 0)}usePreset($){let Z=this.getPreset($);if(!Z)return;return Z.lastUsed=Date.now(),Z.usageCount++,this.storage.recentIds=[$,...this.storage.recentIds.filter((Y)=>Y!==$)].slice(0,Yd),this.dirty=!0,Z}updatePreset($,Z){let Y=this.getPreset($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deletePreset($){let Z=this.storage.presets.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.presets.splice(Z,1),this.storage.recentIds=this.storage.recentIds.filter((Y)=>Y!==$),this.dirty=!0,!0}searchPresets($){let Z=$.toLowerCase();return this.storage.presets.filter((Y)=>{if(Y.name.toLowerCase().includes(Z))return!0;if(Y.description?.toLowerCase().includes(Z))return!0;if(Y.tags?.some((J)=>J.toLowerCase().includes(Z)))return!0;return!1})}getMostUsedPresets($=5){return[...this.storage.presets].sort((Z,Y)=>Y.usageCount-Z.usageCount).slice(0,$)}exportPresets($){let Z=$?this.storage.presets.filter((Y)=>$.includes(Y.id)):this.storage.presets;return JSON.stringify({presets:Z},null,2)}importPresets($,Z=!1){let Y=JSON.parse($),J=0;for(let X of Y.presets){let Q=this.storage.presets.find((G)=>G.id===X.id);if(Q&&!Z)continue;if(Q)Object.assign(Q,X);else this.storage.presets.push(X);J++}if(J>0)this.dirty=!0;return J}}function Jd(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Zd=".stx/story/presets.json",Gz=1,Yd=10;var qR=()=>{};import Wz from"fs";async function CX($,Z,Y={}){let J=performance.now(),X=[];try{let Q=await Wz.promises.stat(Z),G=BR.get(Z),K;if(G&&G.mtime===Q.mtimeMs)K=G.content;else K=await Wz.promises.readFile(Z,"utf-8"),BR.set(Z,{content:K,mtime:Q.mtimeMs,analyzed:null});let{processDirectives:W}=await Promise.resolve().then(() => (q1(),uY)),U={},z=i3(K);if(z)try{await k0(z,U,Z)}catch(H){X.push(`Warning: Could not extract script variables: ${H instanceof Error?H.message:String(H)}`)}if(Y.props)Object.assign(U,Y.props);let q=await W(K,U,Z,{},new Set),B=HR(K),j=i3(K);return q=OR(q),q=LR(q,U),{html:q,css:B,js:j,errors:X,duration:performance.now()-J}}catch(Q){return X.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${VR(X[0])}</div>`,css:"",js:"",errors:X,duration:performance.now()-J}}}async function Xd($){try{let Z=await Wz.promises.readFile($,"utf-8"),Y=i3(Z);if(!Y)return null;let J={};if(await k0(Y,J,$),Array.isArray(J.variants))return J.variants;return null}catch{return null}}async function jR($,Z,Y,J){let X=Z.story?.variants;if(!X){let K=await Xd(Z.path);if(K)X=K}if(!X&&Y==="default")return CX($,Z.path,{props:J||{}});if(!X)return CX($,Z.path,{props:J||{}});let Q=X.find((K)=>K.id===Y);if(!Q&&Y==="default")return CX($,Z.path,{props:J||{}});if(!Q)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Y}' not found`],duration:0};let G={...Q.state,...J};if(Q.source)return Qd($,Q.source,G);return CX($,Z.path,{props:G})}async function Qd($,Z,Y={}){let J=performance.now(),X=[];try{let{processDirectives:Q}=await Promise.resolve().then(() => (q1(),uY)),G={...Y},K=i3(Z);if(K)try{await k0(K,G,"inline-template.stx")}catch{}let U=await Q(Z,G,"inline-template.stx",{},new Set);return U=OR(U),U=LR(U,G),{html:U,css:HR(Z),js:i3(Z),errors:X,duration:performance.now()-J}}catch(Q){return X.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${VR(X[0])}</div>`,css:"",js:"",errors:X,duration:performance.now()-J}}}function HR($){let Z=[],Y=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,J=Y.exec($);while(J!==null)Z.push(J[1].trim()),J=Y.exec($);return Z.join(`
21684
+ `}var u$0;var zR=D(()=>{u$0=new KR});import Qz from"fs";import _R from"path";class Kz{storage;storagePath;dirty=!1;constructor($){this.storagePath=_R.join($,Jd),this.storage=this.loadStorage()}loadStorage(){try{let $=Qz.readFileSync(this.storagePath,"utf-8"),Z=JSON.parse($);if(Z.version!==Gz)return this.migrateStorage(Z);return Z}catch{return{version:Gz,presets:[],recentIds:[]}}}migrateStorage($){return{version:Gz,presets:$.presets||[],recentIds:$.recentIds||[]}}async save(){if(!this.dirty)return;let $=_R.dirname(this.storagePath);await Qz.promises.mkdir($,{recursive:!0}),await Qz.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset($,Z,Y={}){let J={id:Qd(),name:$,description:Y.description,props:Z,componentId:Y.componentId,created:Date.now(),usageCount:0,tags:Y.tags};return this.storage.presets.push(J),this.dirty=!0,J}getPreset($){return this.storage.presets.find((Z)=>Z.id===$)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent($){return this.storage.presets.filter((Z)=>!Z.componentId||Z.componentId===$)}getRecentPresets(){return this.storage.recentIds.map(($)=>this.getPreset($)).filter(($)=>$!==void 0)}usePreset($){let Z=this.getPreset($);if(!Z)return;return Z.lastUsed=Date.now(),Z.usageCount++,this.storage.recentIds=[$,...this.storage.recentIds.filter((Y)=>Y!==$)].slice(0,Xd),this.dirty=!0,Z}updatePreset($,Z){let Y=this.getPreset($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deletePreset($){let Z=this.storage.presets.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.presets.splice(Z,1),this.storage.recentIds=this.storage.recentIds.filter((Y)=>Y!==$),this.dirty=!0,!0}searchPresets($){let Z=$.toLowerCase();return this.storage.presets.filter((Y)=>{if(Y.name.toLowerCase().includes(Z))return!0;if(Y.description?.toLowerCase().includes(Z))return!0;if(Y.tags?.some((J)=>J.toLowerCase().includes(Z)))return!0;return!1})}getMostUsedPresets($=5){return[...this.storage.presets].sort((Z,Y)=>Y.usageCount-Z.usageCount).slice(0,$)}exportPresets($){let Z=$?this.storage.presets.filter((Y)=>$.includes(Y.id)):this.storage.presets;return JSON.stringify({presets:Z},null,2)}importPresets($,Z=!1){let Y=JSON.parse($),J=0;for(let X of Y.presets){let Q=this.storage.presets.find((G)=>G.id===X.id);if(Q&&!Z)continue;if(Q)Object.assign(Q,X);else this.storage.presets.push(X);J++}if(J>0)this.dirty=!0;return J}}function Qd(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Jd=".stx/story/presets.json",Gz=1,Xd=10;var qR=()=>{};import Wz from"fs";async function CX($,Z,Y={}){let J=performance.now(),X=[];try{let Q=await Wz.promises.stat(Z),G=BR.get(Z),K;if(G&&G.mtime===Q.mtimeMs)K=G.content;else K=await Wz.promises.readFile(Z,"utf-8"),BR.set(Z,{content:K,mtime:Q.mtimeMs,analyzed:null});let{processDirectives:W}=await Promise.resolve().then(() => (q1(),uY)),U={},z=i3(K);if(z)try{await k0(z,U,Z)}catch(H){X.push(`Warning: Could not extract script variables: ${H instanceof Error?H.message:String(H)}`)}if(Y.props)Object.assign(U,Y.props);let q=await W(K,U,Z,{},new Set),B=HR(K),j=i3(K);return q=OR(q),q=LR(q,U),{html:q,css:B,js:j,errors:X,duration:performance.now()-J}}catch(Q){return X.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${VR(X[0])}</div>`,css:"",js:"",errors:X,duration:performance.now()-J}}}async function Gd($){try{let Z=await Wz.promises.readFile($,"utf-8"),Y=i3(Z);if(!Y)return null;let J={};if(await k0(Y,J,$),Array.isArray(J.variants))return J.variants;return null}catch{return null}}async function jR($,Z,Y,J){let X=Z.story?.variants;if(!X){let K=await Gd(Z.path);if(K)X=K}if(!X&&Y==="default")return CX($,Z.path,{props:J||{}});if(!X)return CX($,Z.path,{props:J||{}});let Q=X.find((K)=>K.id===Y);if(!Q&&Y==="default")return CX($,Z.path,{props:J||{}});if(!Q)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Y}' not found`],duration:0};let G={...Q.state,...J};if(Q.source)return Kd($,Q.source,G);return CX($,Z.path,{props:G})}async function Kd($,Z,Y={}){let J=performance.now(),X=[];try{let{processDirectives:Q}=await Promise.resolve().then(() => (q1(),uY)),G={...Y},K=i3(Z);if(K)try{await k0(K,G,"inline-template.stx")}catch{}let U=await Q(Z,G,"inline-template.stx",{},new Set);return U=OR(U),U=LR(U,G),{html:U,css:HR(Z),js:i3(Z),errors:X,duration:performance.now()-J}}catch(Q){return X.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${VR(X[0])}</div>`,css:"",js:"",errors:X,duration:performance.now()-J}}}function HR($){let Z=[],Y=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,J=Y.exec($);while(J!==null)Z.push(J[1].trim()),J=Y.exec($);return Z.join(`
21685
21685
  `)}function OR($){return $.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function i3($){let Z=[],Y=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,J=Y.exec($);while(J!==null)Z.push(J[1].trim()),J=Y.exec($);return Z.join(`
21686
- `)}function LR($,Z){let Y=`<script>window.__stxProps = ${JSON.stringify(Z)};</script>`;return $+Y}function VR($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var BR;var FR=D(()=>{R0();BR=new Map});async function AR($,Z){let Y=await c3($);Q7($,Y);let J=p3($.config,Y);G7($,J),console.log(` Found ${Y.length} story files`);let X=typeof Z.host==="string"?Z.host:Z.host===!0?"0.0.0.0":"localhost",Q=new Kz($.root),G=new eU($.root),K=new oU($.root),W=aN(),U=Bun.serve({port:Z.port,hostname:X,fetch:async(q,B)=>{let H=new URL(q.url).pathname;if(H==="/__hmr"){if(B.upgrade(q,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(H.startsWith("/api/"))return Gd($,H,q,{presetsManager:Q,bookmarksManager:G,analyticsTracker:K});return Kd($,H,Z.port)},websocket:{open(q){W.open(q)},close(q){W.close(q)},message(q,B){W.message(q,B)}}}),z=`http://${X}:${Z.port}`,_=rN($,async(q,B)=>{console.log(` [${q}] ${B.relativePath}`);let j=await c3($);Q7($,j);let H=p3($.config,j);if(G7($,H),q==="add")oN(B.id,{fileName:B.fileName});else if(q==="unlink")tN(B.id);else sN(B.id,{fileName:B.fileName})});if(Z.open){let q=z;try{let{exec:B}=await import("child_process"),j=process.platform;B(`${j==="darwin"?"open":j==="win32"?"start":"xdg-open"} ${q}`)}catch{}}return{server:U,url:z,close:async()=>{_(),U.stop()}}}async function Gd($,Z,Y,J){let{presetsManager:X,bookmarksManager:Q,analyticsTracker:G}=J;if(Z==="/api/stories")return Response.json({files:$.storyFiles.map((K)=>({id:K.id,fileName:K.fileName,relativePath:K.relativePath,treePath:K.treePath})),tree:$.tree});if(Z.startsWith("/api/story/")){let K=Z.slice(11),W=$.storyFiles.find((U)=>U.id===K);if(!W)return new Response("Story not found",{status:404});try{let U=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:U})}catch{return new Response("Error reading story",{status:500})}}if(Z==="/api/config")return Response.json({theme:$.config.theme,responsivePresets:$.config.responsivePresets,backgroundPresets:$.config.backgroundPresets});if(Z.startsWith("/api/render/")){let K=new URL(Y.url),W=Z.slice(12).split("/"),U=W[0],z=W[1]||"default",_,q=K.searchParams.get("props");if(q)try{_=JSON.parse(q)}catch{}let B=$.storyFiles.find((j)=>j.id===U);if(!B)return new Response("Story not found",{status:404});try{let j=await jR($,B,z,_);return Response.json({html:j.html,css:j.css,js:j.js,errors:j.errors,duration:j.duration})}catch(j){return Response.json({html:"",css:"",js:"",errors:[j instanceof Error?j.message:String(j)],duration:0},{status:500})}}if(Z==="/api/presets"&&Y.method==="GET")return Response.json({presets:X.getAllPresets()});if(Z==="/api/presets"&&Y.method==="POST")try{let K=await Y.json(),W=X.createPreset(K.name,K.props,{componentId:K.componentId,description:K.description});return await X.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/presets/")&&!Z.includes("/use")&&Y.method==="GET"){let K=Z.slice(13),W=X.getPreset(K);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(Z.endsWith("/use")&&Y.method==="POST"){let K=Z.slice(13,-4),W=X.usePreset(K);if(!W)return new Response("Preset not found",{status:404});return await X.save(),Response.json(W)}if(Z.startsWith("/api/presets/")&&Y.method==="DELETE"){let K=Z.slice(13);if(!X.deletePreset(K))return new Response("Preset not found",{status:404});return await X.save(),Response.json({success:!0})}if(Z==="/api/bookmarks"&&Y.method==="GET")return Response.json({bookmarks:Q.getAllBookmarks()});if(Z==="/api/bookmarks"&&Y.method==="POST")try{let K=await Y.json(),W=Q.addBookmark(K.storyId,K.variantId,K.props,{name:K.name,notes:K.notes,color:K.color});return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/bookmarks/toggle"&&Y.method==="POST")try{let K=await Y.json(),W=Q.toggleBookmark(K.storyId,K.variantId,K.props);return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/bookmarks/")&&Z!=="/api/bookmarks/toggle"&&Y.method==="GET"){let K=Z.slice(15),W=Q.getBookmark(K);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(Z.startsWith("/api/bookmarks/")&&Y.method==="DELETE"){let K=Z.slice(15);if(!Q.deleteBookmark(K))return new Response("Bookmark not found",{status:404});return await Q.save(),Response.json({success:!0})}if(Z==="/api/analytics/track"&&Y.method==="POST")try{let K=await Y.json();if(K.type==="view"&&K.componentId)G.trackView(K.componentId,K.variantId);else if(K.type==="prop_change"&&K.componentId&&K.propName)G.trackPropChange(K.componentId,K.propName,null);else if(K.type==="variant_switch"&&K.componentId&&K.variantId)G.trackVariantSwitch(K.componentId,K.variantId);else if(K.type==="search"&&K.query)G.trackSearch(K.query,0);return await G.save(),Response.json({success:!0})}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/analytics/summary"&&Y.method==="GET")return Response.json({mostViewed:G.getMostViewedComponents(10),mostChangedProps:G.getMostChangedProps(10),searchAnalytics:G.getSearchAnalytics()});if(Z.startsWith("/api/analytics/component/")&&Y.method==="GET"){let K=Z.slice(25),W=$.storyFiles.find((z)=>z.id===K),U=G.getComponentAnalytics(K,W?.fileName||K);return Response.json(U)}return new Response("Not found",{status:404})}function Kd($,Z,Y){let J=Wd($,Y);return new Response(J,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function Wd($,Z){let{theme:Y}=$.config,J=Y.title||"STX Story",X=`ws://localhost:${Z}/__hmr`,Q=eN(X);return`<!DOCTYPE html>
21686
+ `)}function LR($,Z){let Y=`<script>window.__stxProps = ${JSON.stringify(Z)};</script>`;return $+Y}function VR($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var BR;var FR=D(()=>{R0();BR=new Map});async function AR($,Z){let Y=await c3($);Q7($,Y);let J=p3($.config,Y);G7($,J),console.log(` Found ${Y.length} story files`);let X=typeof Z.host==="string"?Z.host:Z.host===!0?"0.0.0.0":"localhost",Q=new Kz($.root),G=new eU($.root),K=new oU($.root),W=aN(),U=Bun.serve({port:Z.port,hostname:X,fetch:async(q,B)=>{let H=new URL(q.url).pathname;if(H==="/__hmr"){if(B.upgrade(q,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(H.startsWith("/api/"))return Wd($,H,q,{presetsManager:Q,bookmarksManager:G,analyticsTracker:K});return Ud($,H,Z.port)},websocket:{open(q){W.open(q)},close(q){W.close(q)},message(q,B){W.message(q,B)}}}),z=`http://${X}:${Z.port}`,_=rN($,async(q,B)=>{console.log(` [${q}] ${B.relativePath}`);let j=await c3($);Q7($,j);let H=p3($.config,j);if(G7($,H),q==="add")oN(B.id,{fileName:B.fileName});else if(q==="unlink")tN(B.id);else sN(B.id,{fileName:B.fileName})});if(Z.open){let q=z;try{let{exec:B}=await import("child_process"),j=process.platform;B(`${j==="darwin"?"open":j==="win32"?"start":"xdg-open"} ${q}`)}catch{}}return{server:U,url:z,close:async()=>{_(),U.stop()}}}async function Wd($,Z,Y,J){let{presetsManager:X,bookmarksManager:Q,analyticsTracker:G}=J;if(Z==="/api/stories")return Response.json({files:$.storyFiles.map((K)=>({id:K.id,fileName:K.fileName,relativePath:K.relativePath,treePath:K.treePath})),tree:$.tree});if(Z.startsWith("/api/story/")){let K=Z.slice(11),W=$.storyFiles.find((U)=>U.id===K);if(!W)return new Response("Story not found",{status:404});try{let U=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:U})}catch{return new Response("Error reading story",{status:500})}}if(Z==="/api/config")return Response.json({theme:$.config.theme,responsivePresets:$.config.responsivePresets,backgroundPresets:$.config.backgroundPresets});if(Z.startsWith("/api/render/")){let K=new URL(Y.url),W=Z.slice(12).split("/"),U=W[0],z=W[1]||"default",_,q=K.searchParams.get("props");if(q)try{_=JSON.parse(q)}catch{}let B=$.storyFiles.find((j)=>j.id===U);if(!B)return new Response("Story not found",{status:404});try{let j=await jR($,B,z,_);return Response.json({html:j.html,css:j.css,js:j.js,errors:j.errors,duration:j.duration})}catch(j){return Response.json({html:"",css:"",js:"",errors:[j instanceof Error?j.message:String(j)],duration:0},{status:500})}}if(Z==="/api/presets"&&Y.method==="GET")return Response.json({presets:X.getAllPresets()});if(Z==="/api/presets"&&Y.method==="POST")try{let K=await Y.json(),W=X.createPreset(K.name,K.props,{componentId:K.componentId,description:K.description});return await X.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/presets/")&&!Z.includes("/use")&&Y.method==="GET"){let K=Z.slice(13),W=X.getPreset(K);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(Z.endsWith("/use")&&Y.method==="POST"){let K=Z.slice(13,-4),W=X.usePreset(K);if(!W)return new Response("Preset not found",{status:404});return await X.save(),Response.json(W)}if(Z.startsWith("/api/presets/")&&Y.method==="DELETE"){let K=Z.slice(13);if(!X.deletePreset(K))return new Response("Preset not found",{status:404});return await X.save(),Response.json({success:!0})}if(Z==="/api/bookmarks"&&Y.method==="GET")return Response.json({bookmarks:Q.getAllBookmarks()});if(Z==="/api/bookmarks"&&Y.method==="POST")try{let K=await Y.json(),W=Q.addBookmark(K.storyId,K.variantId,K.props,{name:K.name,notes:K.notes,color:K.color});return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/bookmarks/toggle"&&Y.method==="POST")try{let K=await Y.json(),W=Q.toggleBookmark(K.storyId,K.variantId,K.props);return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/bookmarks/")&&Z!=="/api/bookmarks/toggle"&&Y.method==="GET"){let K=Z.slice(15),W=Q.getBookmark(K);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(Z.startsWith("/api/bookmarks/")&&Y.method==="DELETE"){let K=Z.slice(15);if(!Q.deleteBookmark(K))return new Response("Bookmark not found",{status:404});return await Q.save(),Response.json({success:!0})}if(Z==="/api/analytics/track"&&Y.method==="POST")try{let K=await Y.json();if(K.type==="view"&&K.componentId)G.trackView(K.componentId,K.variantId);else if(K.type==="prop_change"&&K.componentId&&K.propName)G.trackPropChange(K.componentId,K.propName,null);else if(K.type==="variant_switch"&&K.componentId&&K.variantId)G.trackVariantSwitch(K.componentId,K.variantId);else if(K.type==="search"&&K.query)G.trackSearch(K.query,0);return await G.save(),Response.json({success:!0})}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/analytics/summary"&&Y.method==="GET")return Response.json({mostViewed:G.getMostViewedComponents(10),mostChangedProps:G.getMostChangedProps(10),searchAnalytics:G.getSearchAnalytics()});if(Z.startsWith("/api/analytics/component/")&&Y.method==="GET"){let K=Z.slice(25),W=$.storyFiles.find((z)=>z.id===K),U=G.getComponentAnalytics(K,W?.fileName||K);return Response.json(U)}return new Response("Not found",{status:404})}function Ud($,Z,Y){let J=zd($,Y);return new Response(J,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function zd($,Z){let{theme:Y}=$.config,J=Y.title||"STX Story",X=`ws://localhost:${Z}/__hmr`,Q=eN(X);return`<!DOCTYPE html>
21687
21687
  <html lang="en" class="${Y.darkClass||"dark"}">
21688
21688
  <head>
21689
21689
  <meta charset="UTF-8">
@@ -22401,8 +22401,8 @@ else {
22401
22401
  <style>${XR()}</style>
22402
22402
  ${JR()}
22403
22403
  </body>
22404
- </html>`}var wR=D(()=>{mN();cN();Yz();m3();$R();GR();zR();qR();FR()});import Ud from"fs";import zd from"path";async function NR($){let Z=$.config.setupFile;if(!Z)return;let Y=zd.resolve($.root,Z);try{await Ud.promises.access(Y)}catch{return}let J={storyContext:$,registerComponent:(X,Q)=>{_d.set(X,Q)},addCSS:(X)=>{qd.push(X)},addScript:(X)=>{Bd.push(X)},setState:(X,Q)=>{jd.set(X,Q)}};try{let X=await import(Y);if(typeof X.default==="function")await X.default(J);else if(typeof X.setupStory==="function")await X.setupStory(J)}catch(X){console.warn(`Warning: Failed to load setup file: ${X}`)}}var _d,qd,Bd,jd;var RR=D(()=>{_d=new Map,qd=[],Bd=[],jd=new Map});var TR={};$0(TR,{devCommand:()=>MR,dev:()=>Hd});async function MR($={}){d3();let Z=await X7({mode:"dev"});if(!Z.config.enabled){J7("Story feature is disabled in config.");return}await NR(Z);let Y=$.port??Z.config.port,J,X=async()=>{J=await AR(Z,{port:Y,open:$.open,host:$.host}),u3(Z.storyFiles.length),nU(J.url),rU()};await X();let Q=bN(Z,{onChange:async()=>{await J.close();let K=await X7({mode:"dev"});Object.assign(Z,K),await X()}}),G=async()=>{console.log(`
22405
- `),Q.stop(),await J.close(),process.exit(0)};if(process.on("SIGINT",G),process.on("SIGTERM",G),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(K)=>{switch(K.toString()){case"h":rU();break;case"o":try{let{exec:U}=await import("child_process"),z=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";U(`${z} ${J.url}`)}catch{DN("Failed to open browser")}break;case"r":await J.close(),await X();break;case"c":console.clear(),d3(),u3(Z.storyFiles.length),nU(J.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var Hd;var ER=D(()=>{PN();m3();kX();wR();RR();Hd=MR});function IR($){n3=[];for(let Z of $.storyFiles)if(n3.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),n3.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)n3.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function DR(){return JSON.stringify(n3)}var n3;var kR=D(()=>{n3=[]});var CR={};$0(CR,{buildCommand:()=>SR,build:()=>Ld});import y6 from"fs";import N$ from"path";async function SR($={}){let Z=Date.now();d3();let Y=await X7({mode:"build"});if(!Y.config.enabled){J7("Story feature is disabled in config.");return}let J=await c3(Y);Q7(Y,J);let X=p3(Y.config,J);G7(Y,X),u3(J.length);let Q=$.outDir??Y.config.outDir,G=N$.resolve(Y.root,Q);await y6.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=Od(Y);await y6.promises.writeFile(N$.join(G,"index.html"),K);let W={files:J.map((B)=>({id:B.id,fileName:B.fileName,relativePath:B.relativePath,treePath:B.treePath})),tree:X};await y6.promises.writeFile(N$.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await y6.promises.writeFile(N$.join(G,"config.json"),JSON.stringify(U,null,2));let z=N$.join(G,"stories");await y6.promises.mkdir(z,{recursive:!0});for(let B of J){let j=await y6.promises.readFile(B.path,"utf-8");await y6.promises.writeFile(N$.join(z,`${B.id}.stx`),j)}IR(Y);let _=DR();await y6.promises.writeFile(N$.join(G,"search-index.json"),_);let q=Date.now()-Z;SN(J.length,Q,q)}function Od($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
22404
+ </html>`}var wR=D(()=>{mN();cN();Yz();m3();$R();GR();zR();qR();FR()});import _d from"fs";import qd from"path";async function NR($){let Z=$.config.setupFile;if(!Z)return;let Y=qd.resolve($.root,Z);try{await _d.promises.access(Y)}catch{return}let J={storyContext:$,registerComponent:(X,Q)=>{Bd.set(X,Q)},addCSS:(X)=>{jd.push(X)},addScript:(X)=>{Hd.push(X)},setState:(X,Q)=>{Od.set(X,Q)}};try{let X=await import(Y);if(typeof X.default==="function")await X.default(J);else if(typeof X.setupStory==="function")await X.setupStory(J)}catch(X){console.warn(`Warning: Failed to load setup file: ${X}`)}}var Bd,jd,Hd,Od;var RR=D(()=>{Bd=new Map,jd=[],Hd=[],Od=new Map});var TR={};$0(TR,{devCommand:()=>MR,dev:()=>Ld});async function MR($={}){d3();let Z=await X7({mode:"dev"});if(!Z.config.enabled){J7("Story feature is disabled in config.");return}await NR(Z);let Y=$.port??Z.config.port,J,X=async()=>{J=await AR(Z,{port:Y,open:$.open,host:$.host}),u3(Z.storyFiles.length),nU(J.url),rU()};await X();let Q=bN(Z,{onChange:async()=>{await J.close();let K=await X7({mode:"dev"});Object.assign(Z,K),await X()}}),G=async()=>{console.log(`
22405
+ `),Q.stop(),await J.close(),process.exit(0)};if(process.on("SIGINT",G),process.on("SIGTERM",G),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(K)=>{switch(K.toString()){case"h":rU();break;case"o":try{let{exec:U}=await import("child_process"),z=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";U(`${z} ${J.url}`)}catch{DN("Failed to open browser")}break;case"r":await J.close(),await X();break;case"c":console.clear(),d3(),u3(Z.storyFiles.length),nU(J.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var Ld;var ER=D(()=>{PN();m3();kX();wR();RR();Ld=MR});function IR($){n3=[];for(let Z of $.storyFiles)if(n3.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),n3.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)n3.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function DR(){return JSON.stringify(n3)}var n3;var kR=D(()=>{n3=[]});var CR={};$0(CR,{buildCommand:()=>SR,build:()=>Fd});import y6 from"fs";import N$ from"path";async function SR($={}){let Z=Date.now();d3();let Y=await X7({mode:"build"});if(!Y.config.enabled){J7("Story feature is disabled in config.");return}let J=await c3(Y);Q7(Y,J);let X=p3(Y.config,J);G7(Y,X),u3(J.length);let Q=$.outDir??Y.config.outDir,G=N$.resolve(Y.root,Q);await y6.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=Vd(Y);await y6.promises.writeFile(N$.join(G,"index.html"),K);let W={files:J.map((B)=>({id:B.id,fileName:B.fileName,relativePath:B.relativePath,treePath:B.treePath})),tree:X};await y6.promises.writeFile(N$.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await y6.promises.writeFile(N$.join(G,"config.json"),JSON.stringify(U,null,2));let z=N$.join(G,"stories");await y6.promises.mkdir(z,{recursive:!0});for(let B of J){let j=await y6.promises.readFile(B.path,"utf-8");await y6.promises.writeFile(N$.join(z,`${B.id}.stx`),j)}IR(Y);let _=DR();await y6.promises.writeFile(N$.join(G,"search-index.json"),_);let q=Date.now()-Z;SN(J.length,Q,q)}function Vd($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
22406
22406
  <html lang="en">
22407
22407
  <head>
22408
22408
  <meta charset="UTF-8">
@@ -22516,14 +22516,14 @@ else {
22516
22516
  }
22517
22517
  </script>
22518
22518
  </body>
22519
- </html>`}var Ld;var bR=D(()=>{Yz();m3();kX();kR();Ld=SR});var yR={};$0(yR,{updateSnapshots:()=>Ad,runVisualTests:()=>PR,runA11yTests:()=>Td,formatTestResults:()=>Md});import bX from"fs";import Vd from"path";async function PR($,Z={}){let Y=Date.now(),J={total:0,passed:0,failed:0,new:0,failures:[],duration:0},X=Z.snapshotDir||p0($.root,"story","snapshots");await bX.promises.mkdir(X,{recursive:!0});let Q=$.storyFiles;if(Z.filter&&Z.filter.length>0)Q=Q.filter((G)=>Z.filter.some((K)=>G.fileName.toLowerCase().includes(K.toLowerCase())));for(let G of Q)await Fd(G,X,Z,J);return J.duration=Date.now()-Y,J}async function Fd($,Z,Y,J){let X=$.story;if(!X)return;for(let Q of X.variants){J.total++;let G=Vd.join(Z,`${$.id}-${Q.id}.snap`),K=wd(Q.source||""),W=await Rd(G);if(Y.update||!W){let U={storyId:$.id,variantId:Q.id,component:$.fileName,timestamp:Date.now(),hash:K};if(await bX.promises.writeFile(G,JSON.stringify(U,null,2)),!W)J.new++;J.passed++}else try{let U=await bX.promises.readFile(G,"utf-8"),z=JSON.parse(U);if(z.hash===K)J.passed++;else J.failed++,J.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:"Snapshot mismatch",difference:Nd(z.hash,K)})}catch(U){J.failed++,J.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:`Error reading snapshot: ${U}`})}}}async function Ad($,Z={}){return(await PR($,{...Z,update:!0})).total}function wd($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Z.toString(16)}function Nd($,Z){if($===Z)return 0;let Y=Math.abs(Number.parseInt($,16)-Number.parseInt(Z,16));return Math.min(Y/1e6,1)}async function Rd($){try{return await bX.promises.access($),!0}catch{return!1}}function Md($){let Z=[];if(Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(" STX Story Visual Regression Tests"),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),$.failures.length>0){Z.push(" \u274C Failures:"),Z.push("");for(let Y of $.failures){if(Z.push(` \u2022 ${Y.component} / ${Y.variantId}`),Z.push(` ${Y.message}`),Y.difference!==void 0)Z.push(` Difference: ${(Y.difference*100).toFixed(2)}%`);Z.push("")}}if(Z.push(" Summary:"),Z.push(` Total: ${$.total}`),Z.push(` Passed: ${$.passed} \u2713`),Z.push(` Failed: ${$.failed} \u2717`),$.new>0)Z.push(` New: ${$.new} \u26A1`);return Z.push(` Time: ${$.duration}ms`),Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),Z.join(`
22520
- `)}async function Td($,Z={}){let Y=performance.now(),J=[],X=0,Q=0;for(let K of $.storyFiles)try{let W=await Bun.file(K.path).text(),U=await o3(W,K.path);if(U.length>0){for(let z of U)J.push({storyId:K.id,variantId:"default",component:K.component,message:`A11y: ${z.message}`,expected:"No accessibility violations",actual:`${z.type}: ${z.message} (impact: ${z.impact})`});Q++}else X++}catch(W){J.push({storyId:K.id,variantId:"default",component:K.component,message:`Failed to check a11y: ${W instanceof Error?W.message:String(W)}`,expected:"File readable for a11y check",actual:"File read error"}),Q++}let G=performance.now()-Y;return{total:$.storyFiles.length,passed:X,failed:Q,new:0,failures:J,duration:G}}var xR=D(()=>{R$();K4()});var iR={};$0(iR,{default:()=>rd,createHotReloadServer:()=>pR,compileToNative:()=>fR,NATIVE_COMPONENTS:()=>qz});async function fR($,Z={}){let Y=performance.now(),J={target:Z.target||"universal",format:Z.format||"zig",optimize:Z.optimize??!0,treeShake:Z.treeShake??!0,hotReload:Z.hotReload??!1,debug:Z.debug??!1,sourceMaps:Z.sourceMaps??!1,bundle:Z.bundle??!0,minify:Z.minify??!1,components:Z.components||qz},X=typeof $==="string"?Ed($):$,Q=Dd(X.tree,J),G=xd(Q),K=J.treeShake?fd(Q,G):Q,W=new Map;if(J.target==="universal"){let B=["macos","windows","linux","ios","android"];for(let j of B){let H=Uz(K,{...J,target:j});W.set(j,H)}}else{let B=Uz(K,J);W.set(J.target,B)}let U=dd(K,J,W),z=ud(X,K,J),_={compilationTime:performance.now()-Y,totalComponents:zz(X.tree),nativeComponents:_z(K),webComponents:zz(X.tree)-_z(K),bundleSize:U.length,treeShakenSize:J.treeShake?gd(Q,K):U.length,warnings:[],errors:[]},q;if(J.sourceMaps)q=md(X,K);return{code:U,platformCode:W,dependencies:G,manifest:z,sourceMaps:q,stats:_}}function Ed($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),J=Y?Y[1]:$;return gR(J,Z),{id:lR(),hash:cR($),tree:Z,scripts:pd($),styles:id($),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:$.includes("{{"),hasEventHandlers:$.includes("onclick")||$.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:$.length}}}function gR($,Z){let Y=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,J;while((J=Y.exec($))!==null){let[,X,Q,G]=J,K=X.startsWith("@craft-"),W={type:K?"component":"element",tag:K?X.slice(1):X,props:Id(Q),children:[],componentName:K?X.slice(1):void 0};if(G){let U=G.replace(/<[^>]+>/g,"").trim();if(U)W.children=W.children??[],W.children.push({type:"text",text:U});gR(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function Id($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,J;while((J=Y.exec($))!==null){let[,X,Q]=J;Z[X]=Q??!0}return Z}function Dd($,Z){return hR($,Z)}function hR($,Z){let Y=$.componentName?Z.components?.get($.componentName):void 0,J="craft.View";if(Y)J=Y.zigType;else if($.type==="text")J="craft.Text";else if($.tag)J=kd($.tag);let X={};if($.props)for(let[W,U]of Object.entries($.props))X[W]=Sd(U);let Q=[];if($.children)for(let W of $.children)Q.push(hR(W,Z));let G=new Map;if($.props){for(let[W,U]of Object.entries($.props))if(W.startsWith("on")&&typeof U==="string")G.set(W.slice(2).toLowerCase(),U)}let K=bd($);return{type:Cd($,Y),zigType:J,props:X,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function kd($){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[$.toLowerCase()]||"craft.View"}function Sd($){if(typeof $==="string"){if($.startsWith("{{")&&$.endsWith("}}"))return{type:"binding",path:$.slice(2,-2).trim()};if($.includes("(")&&$.includes(")"))return{type:"callback",handler:$};return{type:"literal",value:$}}if(typeof $==="number"||typeof $==="boolean")return{type:"literal",value:$};return{type:"literal",value:String($)}}function Cd($,Z){if(Z){let J=Z.name.toLowerCase();if(J.includes("button"))return"button";if(J.includes("input")||J.includes("text"))return"input";if(J.includes("image")||J.includes("avatar"))return"image";if(J.includes("list")||J.includes("table"))return"list";if(J.includes("scroll"))return"scroll";return"custom"}if($.type==="text")return"text";let Y=$.tag?.toLowerCase();if(Y==="button")return"button";if(Y==="input"||Y==="textarea")return"input";if(Y==="img")return"image";if(Y==="ul"||Y==="ol")return"list";return"view"}function bd($){let Z=$.props?.style,Y={},J={};if(Z){let X=Z.split(";").filter(Boolean);for(let Q of X){let[G,K]=Q.split(":").map((W)=>W.trim());if(!G||!K)continue;switch(G){case"display":Y.display=K;break;case"flex-direction":Y.flexDirection=K;break;case"justify-content":Y.justifyContent=Pd(K);break;case"align-items":Y.alignItems=yd(K);break;case"gap":Y.gap=Number.parseInt(K,10);break;case"padding":Y.padding=Number.parseInt(K,10);break;case"margin":Y.margin=Number.parseInt(K,10);break;case"width":Y.width=K==="auto"?"auto":Number.parseInt(K,10);break;case"height":Y.height=K==="auto"?"auto":Number.parseInt(K,10);break;case"background-color":case"background":J.backgroundColor=K;break;case"border-color":J.borderColor=K;break;case"border-width":J.borderWidth=Number.parseInt(K,10);break;case"border-radius":J.borderRadius=Number.parseInt(K,10);break;case"opacity":J.opacity=Number.parseFloat(K);break}}}return{layout:Y,appearance:J}}function Pd($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function yd($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function xd($){let Z=[],Y=new Set;function J(X,Q){let G=X.id||lR();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:X.zigType,dependencies:Q?[Q]:[],size:dR(X),isStatic:vd(X)};Z.push(K);for(let W of X.children)J(W,G)}return J($),Z}function dR($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function vd($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function fd($,Z){return $}function gd($,Z){let Y=0;function J(X){Y+=dR(X);for(let Q of X.children)J(Q)}return J(Z),Y}function Uz($,Z){switch(Z.format){case"zig":return vR($,Z);case"typescript":return hd($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return vR($,Z)}}function vR($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('const std = @import("std");'),Y.push('const craft = @import("craft");'),Y.push(""),Y.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),Y.push(" return try build(allocator);"),Y.push("}"),Y.push(""),uR($,Y,0),Y.join(`
22521
- `)}function uR($,Z,Y){let J=" ".repeat(Y);if(Y===0)Z.push("fn build(allocator: std.mem.Allocator) !craft.Element {");let X=`node_${Y}`;Z.push(`${J} var ${X} = try ${$.zigType}.init(allocator);`);for(let[Q,G]of Object.entries($.props))if(G.type==="literal"){let K=typeof G.value==="string"?`"${G.value}"`:String(G.value);Z.push(`${J} ${X}.set${cd(Q)}(${K});`)}for(let Q=0;Q<$.children.length;Q++){let G=$.children[Q];if(G.type==="text"){let K=G.props.text?.type==="literal"?String(G.props.text.value):"";Z.push(`${J} try ${X}.addChild(try craft.Text.init(allocator, "${K}"));`)}else uR(G,Z,Y+1),Z.push(`${J} try ${X}.addChild(node_${Y+1});`)}if(Y===0)Z.push(` return ${X}.element();`),Z.push("}")}function hd($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('import { Craft } from "@stacksjs/craft";'),Y.push(""),Y.push("export function render(): Craft.Element {"),Y.push(" return "+mR($,1)+";"),Y.push("}"),Y.join(`
22519
+ </html>`}var Fd;var bR=D(()=>{Yz();m3();kX();kR();Fd=SR});var yR={};$0(yR,{updateSnapshots:()=>Nd,runVisualTests:()=>PR,runA11yTests:()=>Id,formatTestResults:()=>Ed});import bX from"fs";import Ad from"path";async function PR($,Z={}){let Y=Date.now(),J={total:0,passed:0,failed:0,new:0,failures:[],duration:0},X=Z.snapshotDir||p0($.root,"story","snapshots");await bX.promises.mkdir(X,{recursive:!0});let Q=$.storyFiles;if(Z.filter&&Z.filter.length>0)Q=Q.filter((G)=>Z.filter.some((K)=>G.fileName.toLowerCase().includes(K.toLowerCase())));for(let G of Q)await wd(G,X,Z,J);return J.duration=Date.now()-Y,J}async function wd($,Z,Y,J){let X=$.story;if(!X)return;for(let Q of X.variants){J.total++;let G=Ad.join(Z,`${$.id}-${Q.id}.snap`),K=Rd(Q.source||""),W=await Td(G);if(Y.update||!W){let U={storyId:$.id,variantId:Q.id,component:$.fileName,timestamp:Date.now(),hash:K};if(await bX.promises.writeFile(G,JSON.stringify(U,null,2)),!W)J.new++;J.passed++}else try{let U=await bX.promises.readFile(G,"utf-8"),z=JSON.parse(U);if(z.hash===K)J.passed++;else J.failed++,J.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:"Snapshot mismatch",difference:Md(z.hash,K)})}catch(U){J.failed++,J.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:`Error reading snapshot: ${U}`})}}}async function Nd($,Z={}){return(await PR($,{...Z,update:!0})).total}function Rd($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Z.toString(16)}function Md($,Z){if($===Z)return 0;let Y=Math.abs(Number.parseInt($,16)-Number.parseInt(Z,16));return Math.min(Y/1e6,1)}async function Td($){try{return await bX.promises.access($),!0}catch{return!1}}function Ed($){let Z=[];if(Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(" STX Story Visual Regression Tests"),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),$.failures.length>0){Z.push(" \u274C Failures:"),Z.push("");for(let Y of $.failures){if(Z.push(` \u2022 ${Y.component} / ${Y.variantId}`),Z.push(` ${Y.message}`),Y.difference!==void 0)Z.push(` Difference: ${(Y.difference*100).toFixed(2)}%`);Z.push("")}}if(Z.push(" Summary:"),Z.push(` Total: ${$.total}`),Z.push(` Passed: ${$.passed} \u2713`),Z.push(` Failed: ${$.failed} \u2717`),$.new>0)Z.push(` New: ${$.new} \u26A1`);return Z.push(` Time: ${$.duration}ms`),Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),Z.join(`
22520
+ `)}async function Id($,Z={}){let Y=performance.now(),J=[],X=0,Q=0;for(let K of $.storyFiles)try{let W=await Bun.file(K.path).text(),U=await o3(W,K.path);if(U.length>0){for(let z of U)J.push({storyId:K.id,variantId:"default",component:K.component,message:`A11y: ${z.message}`,expected:"No accessibility violations",actual:`${z.type}: ${z.message} (impact: ${z.impact})`});Q++}else X++}catch(W){J.push({storyId:K.id,variantId:"default",component:K.component,message:`Failed to check a11y: ${W instanceof Error?W.message:String(W)}`,expected:"File readable for a11y check",actual:"File read error"}),Q++}let G=performance.now()-Y;return{total:$.storyFiles.length,passed:X,failed:Q,new:0,failures:J,duration:G}}var xR=D(()=>{R$();K4()});var iR={};$0(iR,{default:()=>sd,createHotReloadServer:()=>pR,compileToNative:()=>fR,NATIVE_COMPONENTS:()=>qz});async function fR($,Z={}){let Y=performance.now(),J={target:Z.target||"universal",format:Z.format||"zig",optimize:Z.optimize??!0,treeShake:Z.treeShake??!0,hotReload:Z.hotReload??!1,debug:Z.debug??!1,sourceMaps:Z.sourceMaps??!1,bundle:Z.bundle??!0,minify:Z.minify??!1,components:Z.components||qz},X=typeof $==="string"?Dd($):$,Q=Sd(X.tree,J),G=fd(Q),K=J.treeShake?hd(Q,G):Q,W=new Map;if(J.target==="universal"){let B=["macos","windows","linux","ios","android"];for(let j of B){let H=Uz(K,{...J,target:j});W.set(j,H)}}else{let B=Uz(K,J);W.set(J.target,B)}let U=md(K,J,W),z=ld(X,K,J),_={compilationTime:performance.now()-Y,totalComponents:zz(X.tree),nativeComponents:_z(K),webComponents:zz(X.tree)-_z(K),bundleSize:U.length,treeShakenSize:J.treeShake?dd(Q,K):U.length,warnings:[],errors:[]},q;if(J.sourceMaps)q=cd(X,K);return{code:U,platformCode:W,dependencies:G,manifest:z,sourceMaps:q,stats:_}}function Dd($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),J=Y?Y[1]:$;return gR(J,Z),{id:lR(),hash:cR($),tree:Z,scripts:nd($),styles:rd($),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:$.includes("{{"),hasEventHandlers:$.includes("onclick")||$.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:$.length}}}function gR($,Z){let Y=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,J;while((J=Y.exec($))!==null){let[,X,Q,G]=J,K=X.startsWith("@craft-"),W={type:K?"component":"element",tag:K?X.slice(1):X,props:kd(Q),children:[],componentName:K?X.slice(1):void 0};if(G){let U=G.replace(/<[^>]+>/g,"").trim();if(U)W.children=W.children??[],W.children.push({type:"text",text:U});gR(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function kd($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,J;while((J=Y.exec($))!==null){let[,X,Q]=J;Z[X]=Q??!0}return Z}function Sd($,Z){return hR($,Z)}function hR($,Z){let Y=$.componentName?Z.components?.get($.componentName):void 0,J="craft.View";if(Y)J=Y.zigType;else if($.type==="text")J="craft.Text";else if($.tag)J=Cd($.tag);let X={};if($.props)for(let[W,U]of Object.entries($.props))X[W]=bd(U);let Q=[];if($.children)for(let W of $.children)Q.push(hR(W,Z));let G=new Map;if($.props){for(let[W,U]of Object.entries($.props))if(W.startsWith("on")&&typeof U==="string")G.set(W.slice(2).toLowerCase(),U)}let K=yd($);return{type:Pd($,Y),zigType:J,props:X,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function Cd($){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[$.toLowerCase()]||"craft.View"}function bd($){if(typeof $==="string"){if($.startsWith("{{")&&$.endsWith("}}"))return{type:"binding",path:$.slice(2,-2).trim()};if($.includes("(")&&$.includes(")"))return{type:"callback",handler:$};return{type:"literal",value:$}}if(typeof $==="number"||typeof $==="boolean")return{type:"literal",value:$};return{type:"literal",value:String($)}}function Pd($,Z){if(Z){let J=Z.name.toLowerCase();if(J.includes("button"))return"button";if(J.includes("input")||J.includes("text"))return"input";if(J.includes("image")||J.includes("avatar"))return"image";if(J.includes("list")||J.includes("table"))return"list";if(J.includes("scroll"))return"scroll";return"custom"}if($.type==="text")return"text";let Y=$.tag?.toLowerCase();if(Y==="button")return"button";if(Y==="input"||Y==="textarea")return"input";if(Y==="img")return"image";if(Y==="ul"||Y==="ol")return"list";return"view"}function yd($){let Z=$.props?.style,Y={},J={};if(Z){let X=Z.split(";").filter(Boolean);for(let Q of X){let[G,K]=Q.split(":").map((W)=>W.trim());if(!G||!K)continue;switch(G){case"display":Y.display=K;break;case"flex-direction":Y.flexDirection=K;break;case"justify-content":Y.justifyContent=xd(K);break;case"align-items":Y.alignItems=vd(K);break;case"gap":Y.gap=Number.parseInt(K,10);break;case"padding":Y.padding=Number.parseInt(K,10);break;case"margin":Y.margin=Number.parseInt(K,10);break;case"width":Y.width=K==="auto"?"auto":Number.parseInt(K,10);break;case"height":Y.height=K==="auto"?"auto":Number.parseInt(K,10);break;case"background-color":case"background":J.backgroundColor=K;break;case"border-color":J.borderColor=K;break;case"border-width":J.borderWidth=Number.parseInt(K,10);break;case"border-radius":J.borderRadius=Number.parseInt(K,10);break;case"opacity":J.opacity=Number.parseFloat(K);break}}}return{layout:Y,appearance:J}}function xd($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function vd($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function fd($){let Z=[],Y=new Set;function J(X,Q){let G=X.id||lR();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:X.zigType,dependencies:Q?[Q]:[],size:dR(X),isStatic:gd(X)};Z.push(K);for(let W of X.children)J(W,G)}return J($),Z}function dR($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function gd($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function hd($,Z){return $}function dd($,Z){let Y=0;function J(X){Y+=dR(X);for(let Q of X.children)J(Q)}return J(Z),Y}function Uz($,Z){switch(Z.format){case"zig":return vR($,Z);case"typescript":return ud($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return vR($,Z)}}function vR($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('const std = @import("std");'),Y.push('const craft = @import("craft");'),Y.push(""),Y.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),Y.push(" return try build(allocator);"),Y.push("}"),Y.push(""),uR($,Y,0),Y.join(`
22521
+ `)}function uR($,Z,Y){let J=" ".repeat(Y);if(Y===0)Z.push("fn build(allocator: std.mem.Allocator) !craft.Element {");let X=`node_${Y}`;Z.push(`${J} var ${X} = try ${$.zigType}.init(allocator);`);for(let[Q,G]of Object.entries($.props))if(G.type==="literal"){let K=typeof G.value==="string"?`"${G.value}"`:String(G.value);Z.push(`${J} ${X}.set${id(Q)}(${K});`)}for(let Q=0;Q<$.children.length;Q++){let G=$.children[Q];if(G.type==="text"){let K=G.props.text?.type==="literal"?String(G.props.text.value):"";Z.push(`${J} try ${X}.addChild(try craft.Text.init(allocator, "${K}"));`)}else uR(G,Z,Y+1),Z.push(`${J} try ${X}.addChild(node_${Y+1});`)}if(Y===0)Z.push(` return ${X}.element();`),Z.push("}")}function ud($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('import { Craft } from "@stacksjs/craft";'),Y.push(""),Y.push("export function render(): Craft.Element {"),Y.push(" return "+mR($,1)+";"),Y.push("}"),Y.join(`
22522
22522
  `)}function mR($,Z){let Y=" ".repeat(Z),J=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);J.push(`${K}: ${U}`)}let X=J.length>0?`{ ${J.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:mR(K,Z+1)),G=Q.length>0?`,
22523
22523
  ${Y} [${Q.join(`,
22524
- ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${X}${G})`}function dd($,Z,Y){if(Z.target==="universal"){let J=[];J.push("// Universal entry point"),J.push("");for(let[X,Q]of Y)J.push(`// --- ${X.toUpperCase()} ---`),J.push(`#if ${X.toUpperCase()}`),J.push(Q),J.push("#endif"),J.push("");return J.join(`
22525
- `)}return Y.get(Z.target)||Uz($,Z)}function ud($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:cR(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)X(G)}return X(Z),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function md($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function lR(){return`id_${++ld}`}function cR($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Math.abs(Z).toString(36)}function cd($){return $.charAt(0).toUpperCase()+$.slice(1)}function pd($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function id($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function zz($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=zz(Y);return Z}function _z($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=_z(Y);return Z}function pR($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var qz,ld=0,nd,rd;var nR=D(()=>{qz=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);nd={compileToNative:fR,createHotReloadServer:pR,NATIVE_COMPONENTS:qz},rd=nd});import{spawn as sR}from"child_process";import g0 from"fs";import ad from"os";import Y0 from"path";import f from"process";import{CLI as sd}from"@stacksjs/clapp";var x6="0.2.149";R$();dU();cK();eK();$6();sK();dK();SU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",A0=new sd("stx");function rR($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function aR($){try{if(!g0.existsSync($)){let Y=Y0.dirname($),J=Y0.basename($);if(g0.existsSync(Y)){let Q=g0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(g0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function Bz($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var W7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),od=($)=>$.endsWith(".stx")||$.endsWith(".md");function K7($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}function td($){if(!$)return;let Z;try{Z=JSON.parse($)}catch(Y){console.error(`\u274C --info-plist is not valid JSON: ${Y.message}`),f.exit(1)}if(typeof Z!=="object"||Z===null||Array.isArray(Z))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),f.exit(1);for(let[Y,J]of Object.entries(Z))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Y}" must be a string, number or boolean`),f.exit(1);return Z}async function ed($,Z){try{let Y=["test"],J=[];if($&&$.length>0)for(let W of $)if(W7(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(J.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...J),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(ad.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let X={...f.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=sR(Q,Y,{stdio:"inherit",shell:!1,env:X});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),f.on("SIGINT",()=>{console.log(`
22526
- Test run interrupted`),K.kill("SIGINT"),f.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var $u=f.argv.length>=3&&(od(f.argv[2])&&g0.existsSync(f.argv[2])||W7(f.argv[2]));if($u){let $=f.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<f.argv.length;Y++){let J=f.argv[Y];if(J==="--port"&&Y+1<f.argv.length){let X=rR(f.argv[++Y]);if(!X.isValid)K7(X);Z.port=Number.parseInt(f.argv[Y],10)}else if(J==="--no-watch")Z.watch=!1;else if(J==="--highlight-theme"&&Y+1<f.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=f.argv[++Y]}else if(J==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(J==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(J==="--no-cache")Z.cache=!1;else if(J==="--native")Z.native=!0}if(W7($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),J=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),X=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(X);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((z)=>/\[.+\]/.test(Y0.basename(z)));for(let z of U)if(!J.includes(z))J.push(z)}catch{}if(J.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),f.exit(1);if(!await S3(J,Z))f.exit(1)}catch(Y){console.error("Failed to process files:",Y),f.exit(1)}else k3($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),f.exit(1)})}else{let $=function(J,X){let Q=[];for(let G=0;G<=X.length;G++)Q[G]=[G];for(let G=0;G<=J.length;G++)Q[0][G]=G;for(let G=1;G<=X.length;G++)for(let K=1;K<=J.length;K++)if(X.charAt(G-1)===J.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[X.length][J.length]};A0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(J)=>{try{if(await lK(J))console.log("Documentation generated successfully."),f.exit(0);else console.error("Documentation generation failed."),f.exit(1)}catch(X){console.error("Error generating documentation:",X),f.exit(1)}}),A0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(J,X)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(J==="list"){console.log(`
22524
+ ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${X}${G})`}function md($,Z,Y){if(Z.target==="universal"){let J=[];J.push("// Universal entry point"),J.push("");for(let[X,Q]of Y)J.push(`// --- ${X.toUpperCase()} ---`),J.push(`#if ${X.toUpperCase()}`),J.push(Q),J.push("#endif"),J.push("");return J.join(`
22525
+ `)}return Y.get(Z.target)||Uz($,Z)}function ld($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:cR(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)X(G)}return X(Z),{version:"1.0.0",components:J,entry:$.id,assets:[],styles:$.styles}}function cd($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function lR(){return`id_${++pd}`}function cR($){let Z=0;for(let Y=0;Y<$.length;Y++){let J=$.charCodeAt(Y);Z=(Z<<5)-Z+J,Z=Z&Z}return Math.abs(Z).toString(36)}function id($){return $.charAt(0).toUpperCase()+$.slice(1)}function nd($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function rd($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function zz($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=zz(Y);return Z}function _z($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=_z(Y);return Z}function pR($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var qz,pd=0,ad,sd;var nR=D(()=>{qz=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);ad={compileToNative:fR,createHotReloadServer:pR,NATIVE_COMPONENTS:qz},sd=ad});import{spawn as sR}from"child_process";import g0 from"fs";import od from"os";import Y0 from"path";import f from"process";import{CLI as td}from"@stacksjs/clapp";var x6="0.2.151";R$();dU();cK();eK();$6();sK();dK();SU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",A0=new td("stx");function rR($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function aR($){try{if(!g0.existsSync($)){let Y=Y0.dirname($),J=Y0.basename($);if(g0.existsSync(Y)){let Q=g0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(J.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(g0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function Bz($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var W7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),ed=($)=>$.endsWith(".stx")||$.endsWith(".md");function K7($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}function $u($){if(!$)return;let Z;try{Z=JSON.parse($)}catch(Y){console.error(`\u274C --info-plist is not valid JSON: ${Y.message}`),f.exit(1)}if(typeof Z!=="object"||Z===null||Array.isArray(Z))console.error(`\u274C --info-plist must be a JSON object, e.g. '{"NSFocusStatusUsageDescription":"\u2026"}'`),f.exit(1);for(let[Y,J]of Object.entries(Z))if(typeof J!=="string"&&typeof J!=="number"&&typeof J!=="boolean")console.error(`\u274C --info-plist value for "${Y}" must be a string, number or boolean`),f.exit(1);return Z}async function Zu($,Z){try{let Y=["test"],J=[];if($&&$.length>0)for(let W of $)if(W7(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(J.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else J.push(W);if(J.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...J),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(od.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let X={...f.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=sR(Q,Y,{stdio:"inherit",shell:!1,env:X});return new Promise((W)=>{K.on("close",(U)=>{let _=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),f.on("SIGINT",()=>{console.log(`
22526
+ Test run interrupted`),K.kill("SIGINT"),f.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var Yu=f.argv.length>=3&&(ed(f.argv[2])&&g0.existsSync(f.argv[2])||W7(f.argv[2]));if(Yu){let $=f.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<f.argv.length;Y++){let J=f.argv[Y];if(J==="--port"&&Y+1<f.argv.length){let X=rR(f.argv[++Y]);if(!X.isValid)K7(X);Z.port=Number.parseInt(f.argv[Y],10)}else if(J==="--no-watch")Z.watch=!1;else if(J==="--highlight-theme"&&Y+1<f.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=f.argv[++Y]}else if(J==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(J==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(J==="--no-cache")Z.cache=!1;else if(J==="--native")Z.native=!0}if(W7($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),J=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),X=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(X);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((z)=>/\[.+\]/.test(Y0.basename(z)));for(let z of U)if(!J.includes(z))J.push(z)}catch{}if(J.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),f.exit(1);if(!await S3(J,Z))f.exit(1)}catch(Y){console.error("Failed to process files:",Y),f.exit(1)}else k3($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),f.exit(1)})}else{let $=function(J,X){let Q=[];for(let G=0;G<=X.length;G++)Q[G]=[G];for(let G=0;G<=J.length;G++)Q[0][G]=G;for(let G=1;G<=X.length;G++)for(let K=1;K<=J.length;K++)if(X.charAt(G-1)===J.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[X.length][J.length]};A0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(J)=>{try{if(await lK(J))console.log("Documentation generated successfully."),f.exit(0);else console.error("Documentation generation failed."),f.exit(1)}catch(X){console.error("Error generating documentation:",X),f.exit(1)}}),A0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(J,X)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(J==="list"){console.log(`
22527
22527
  \uD83D\uDCDA Fetching available icon collections...
22528
22528
  `);let K=await Q(),W=Object.entries(K).sort((U,z)=>z[1].total-U[1].total);console.log(`Available collections:
22529
22529
  `);for(let[U,z]of W){let _=z;console.log(` ${U.padEnd(30)} ${_.name} (${_.total} icons)`)}console.log(`
@@ -22631,7 +22631,7 @@ Would generate ~${A} image variants`);return}console.log(`
22631
22631
  \u2713 Report generated: ${B.outputPath}`),X.open!==!1)console.log(" Opening in browser...")}else console.log(B.report);if(B.exceedsThreshold){let j=X.threshold;console.error(`
22632
22632
  \u274C Bundle size (${G(B.stats.totalSize)}) exceeds threshold (${j})`),f.exit(1)}if(q==="html"){if(console.log(`
22633
22633
  \uD83D\uDCCA Summary:`),console.log(` Total Size: ${G(B.stats.totalSize)}`),console.log(` Gzip Size: ${G(B.stats.totalGzipSize)}`),console.log(` Modules: ${B.stats.moduleCount}`),console.log(` Chunks: ${B.stats.chunks.length}`),B.stats.duplicates.length>0)console.log(` Duplicates: ${B.stats.duplicates.length}`)}}catch(Q){console.error(`
22634
- \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),f.exit(1)}}),A0.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(J,X)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${x6} (${QW})\x1B[0m`),X.timeout){let K=Bz(X.timeout);if(!K.isValid)K7(K)}let Q=typeof J==="string"?[J]:J||[];if(Q.length===0)Q.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(X.verbose)console.log("Test patterns:",Q),console.log("Options:",JSON.stringify({watch:X.watch||!1,filter:X.filter||"none",reporter:X.reporter||"default",timeout:X.timeout||5000,coverage:X.coverage||!1,ui:X.ui||!1},null,2));if(!await i1.timeAsync("test-execution",()=>ed(Q,X))&&!X.watch)f.exit(1)}catch(Q){console.error("Error running tests:",Q),f.exit(1)}}),A0.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(J="index.stx",X)=>{try{if(await tK(J,{force:X.force,template:X.template}))console.log(`
22634
+ \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),f.exit(1)}}),A0.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(J,X)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${x6} (${QW})\x1B[0m`),X.timeout){let K=Bz(X.timeout);if(!K.isValid)K7(K)}let Q=typeof J==="string"?[J]:J||[];if(Q.length===0)Q.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(X.verbose)console.log("Test patterns:",Q),console.log("Options:",JSON.stringify({watch:X.watch||!1,filter:X.filter||"none",reporter:X.reporter||"default",timeout:X.timeout||5000,coverage:X.coverage||!1,ui:X.ui||!1},null,2));if(!await i1.timeAsync("test-execution",()=>Zu(Q,X))&&!X.watch)f.exit(1)}catch(Q){console.error("Error running tests:",Q),f.exit(1)}}),A0.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(J="index.stx",X)=>{try{if(await tK(J,{force:X.force,template:X.template}))console.log(`
22635
22635
  \u2728 Successfully created file: ${J}`),console.log(`
22636
22636
  To view it in the development server:`),console.log(` stx dev ${J}
22637
22637
  `);else console.error(`
@@ -22665,7 +22665,7 @@ Press Ctrl+C to stop watching...
22665
22665
  \u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),f.exit(1)}}),A0.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(J,X)=>{let{captureScreenshots:Q}=await Promise.resolve().then(() => (rK(),PF)),G=J||"dist";try{let K=await Q(G,X.out,{width:Number.parseInt(X.width,10),height:Number.parseInt(X.height,10),waitMs:Number.parseInt(X.wait,10),timeoutMs:Number.parseInt(X.timeout,10),fullPage:Boolean(X.fullPage),waitSelector:X.waitSelector,format:X.format,backend:X.backend});for(let W of K)console.log(`\uD83D\uDCF8 ${W.output} (${(W.bytes/1024).toFixed(0)} KB)`);console.log(`
22666
22666
  \u2728 Captured ${K.length} screenshot(s) to ${X.out}/ via Bun WebView`)}catch(K){console.error(`Screenshot failed: ${K.message}`),f.exit(1)}}),A0.command("version","Show the version of the CLI").action(()=>{console.log(x6)}),A0.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(J)=>{let{startInteractive:X}=await Promise.resolve().then(() => ($W(),uF)),Q={};if(J.context){let G=Y0.resolve(J.context);if(g0.existsSync(G))try{let K=g0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),f.exit(1)}else console.error(`Context file not found: ${G}`),f.exit(1)}await X({context:Q,cwd:J.cwd?Y0.resolve(J.cwd):f.cwd(),verbose:J.verbose})}),A0.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--menubar-only","Run without a dock icon (implied by --system-tray)").option("--category <type>","LSApplicationCategoryType (macOS)").option("--copyright <text>","NSHumanReadableCopyright (macOS)").option("--min-system-version <v>","LSMinimumSystemVersion (macOS)").option("--info-plist <json>","Extra Info.plist keys as a JSON object (macOS)").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(J,X)=>{try{let{buildNative:Q,getAvailableTargets:G,getAvailableFormats:K}=await Promise.resolve().then(() => (TN(),MN)),W=Y0.resolve(J);if(!g0.existsSync(W))console.error(`\u274C Input file not found: ${J}`),f.exit(1);let U=G();if(X.target&&!["macos","windows","linux","ios","android"].includes(X.target))console.error(`\u274C Invalid target: ${X.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${U.join(", ")}`),f.exit(1);let z=X.target||U[0],_=K(z);if(X.format&&!_.includes(X.format))console.error(`\u274C Invalid format for ${z}: ${X.format}`),console.error(`\uD83D\uDCA1 Available formats: ${_.join(", ")}`),f.exit(1);console.log(`
22667
22667
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${J}`),console.log(` Target: ${z}`),console.log(` Format: ${X.format||"default"}`),console.log(` Output: ${X.output}
22668
- `);let q=await Q({input:W,output:Y0.resolve(X.output),target:z,format:X.format,name:X.name,version:X.version,description:X.description,author:X.author,bundleId:X.bundleId,icon:X.icon?Y0.resolve(X.icon):void 0,window:{title:X.title,width:Number.parseInt(X.width,10),height:Number.parseInt(X.height,10),frameless:X.frameless,alwaysOnTop:X.alwaysOnTop},systemTray:X.systemTray,menubarOnly:X.menubarOnly,category:X.category,copyright:X.copyright,minimumSystemVersion:X.minSystemVersion,infoPlist:td(X.infoPlist),devTools:X.devTools,craftPath:X.craftPath,verbose:X.verbose});if(q.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${q.outputPath}`),q.duration)console.log(` Duration: ${(q.duration/1000).toFixed(2)}s`);if(z==="macos"&&q.format==="app")console.log(`
22668
+ `);let q=await Q({input:W,output:Y0.resolve(X.output),target:z,format:X.format,name:X.name,version:X.version,description:X.description,author:X.author,bundleId:X.bundleId,icon:X.icon?Y0.resolve(X.icon):void 0,window:{title:X.title,width:Number.parseInt(X.width,10),height:Number.parseInt(X.height,10),frameless:X.frameless,alwaysOnTop:X.alwaysOnTop},systemTray:X.systemTray,menubarOnly:X.menubarOnly,category:X.category,copyright:X.copyright,minimumSystemVersion:X.minSystemVersion,infoPlist:$u(X.infoPlist),devTools:X.devTools,craftPath:X.craftPath,verbose:X.verbose});if(q.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${q.outputPath}`),q.duration)console.log(` Duration: ${(q.duration/1000).toFixed(2)}s`);if(z==="macos"&&q.format==="app")console.log(`
22669
22669
  \uD83D\uDCA1 To run: open "${q.outputPath}"`);else if(z==="linux"&&q.format==="appimage")console.log(`
22670
22670
  \uD83D\uDCA1 To run: chmod +x "${q.outputPath}" && "${q.outputPath}"`)}else console.error(`\u274C Build failed: ${q.error}`),f.exit(1)}catch(Q){console.error(`\u274C Build error: ${Q.message}`),f.exit(1)}}),A0.command("story","Start component showcase and testing server").option("-p, --port <port>","Server port",{default:"6006"}).option("-o, --open","Open browser automatically",{default:!1}).option("--host <host>","Host to bind to",{default:"localhost"}).example("stx story").example("stx story --port 3000 --open").action(async(J)=>{try{let{devCommand:X}=await Promise.resolve().then(() => (ER(),TR));await X({port:J.port?Number.parseInt(J.port,10):6006,open:J.open,host:J.host})}catch(X){console.error(`\u274C Story error: ${X.message}`),f.exit(1)}}),A0.command("story:build","Build static story site").option("-o, --outDir <dir>","Output directory",{default:".stx/dist/story"}).example("stx story:build").example("stx story:build --outDir ./docs/components").action(async(J)=>{try{let{buildCommand:X}=await Promise.resolve().then(() => (bR(),CR));await X({outDir:J.outDir})}catch(X){console.error(`\u274C Story build error: ${X.message}`),f.exit(1)}}),A0.command("story:test","Run visual regression tests").option("-u, --update","Update snapshots",{default:!1}).option("-f, --filter <name>","Filter components by name").example("stx story:test").example("stx story:test --update").example("stx story:test --filter Button").action(async(J)=>{try{let{createContext:X}=await Promise.resolve().then(() => (m3(),hN)),{runVisualTests:Q,updateSnapshots:G,formatTestResults:K}=await Promise.resolve().then(() => (xR(),yR)),W=await X({mode:"build"});if(J.update){let U=await G(W,{filter:J.filter?[J.filter]:void 0});console.log(`Updated ${U} snapshots`)}else{let U=await Q(W,{filter:J.filter?[J.filter]:void 0});if(console.log(K(U)),U.failed>0)f.exit(1)}}catch(X){console.error(`\u274C Story test error: ${X.message}`),f.exit(1)}}),A0.command("compile <input>","Compile stx template to native Craft component code").option("--target <platform>","Target platform: macos, windows, linux, ios, android, universal",{default:"universal"}).option("--format <format>","Output format: zig, typescript, json",{default:"zig"}).option("--output <path>","Output directory for compiled files",{default:"./dist"}).option("--optimize","Enable optimizations",{default:!0}).option("--tree-shake","Enable tree shaking",{default:!0}).option("--hot-reload","Enable hot reload support",{default:!1}).option("--sourcemaps","Generate source maps",{default:!1}).option("--bundle","Bundle all dependencies",{default:!0}).option("--minify","Minify output",{default:!1}).option("--verbose","Show detailed output",{default:!1}).example("stx compile app.stx").example("stx compile app.stx --target macos --format zig").example("stx compile app.stx --format typescript --output ./native").example("stx compile app.stx --optimize --tree-shake --minify").action(async(J,X)=>{try{let{compileToNative:Q}=await Promise.resolve().then(() => (nR(),iR)),G=Y0.resolve(J);if(!g0.existsSync(G))console.error(`\u274C Input file not found: ${J}`),f.exit(1);let K=["macos","windows","linux","ios","android","universal"];if(!K.includes(X.target))console.error(`\u274C Invalid target: ${X.target}`),console.error(`\uD83D\uDCA1 Available targets: ${K.join(", ")}`),f.exit(1);let W=["zig","typescript","json"];if(!W.includes(X.format))console.error(`\u274C Invalid format: ${X.format}`),console.error(`\uD83D\uDCA1 Available formats: ${W.join(", ")}`),f.exit(1);console.log(`
22671
22671
  \uD83D\uDD27 Compiling stx template to native code...`),console.log(` Input: ${J}`),console.log(` Target: ${X.target}`),console.log(` Format: ${X.format}`),console.log(` Output: ${X.output}