@stacksjs/stx 0.2.147 → 0.2.148

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 __{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 XT(){if(!oX)oX=new __;return oX}var k$,JT=500,yu,oX=null,i1;var $6=D(()=>{k$=new Map;yu=new z_;i1=new Proxy({},{get($,Z){return XT()[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 VZ={};$0(VZ,{resetCssCache:()=>_T,resetCrosswindCache:()=>qT,rebuildCrosswindCSS:()=>E7,loadCrosswindConfig:()=>Y9,loadCrosswind:()=>Z9,injectCrosswindCSS:()=>y0,getCrosswindServeAsset:()=>$9,getCachedCSS:()=>BT,generateCrosswindCSS:()=>LZ,extractClassNames:()=>OZ,buildCrosswindCSS:()=>b$});import w0 from"path";import{hasLocalConfig as QT}from"bunfig/discovery";function HZ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function tX($,Z){if(E4.has($))E4.delete($);else if(E4.size>=B_)E4.delete(E4.keys().next().value);E4.set($,Z)}function GT($){let Z=HZ($);if(n1.has(Z))n1.delete(Z);else if(n1.size>=B_)n1.delete(n1.keys().next().value);return n1.set(Z,$),Z}function $9($){let Z=n1.get($);if(Z===void 0)return;return n1.delete($),n1.set($,Z),Z}async function KT($){if(!Z6)return null;try{let Z=Bun.file(w0.join(Z6,`cw-${HZ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function WT($,Z){if(!Z6)return;try{if(!fs.existsSync(Z6))fs.mkdirSync(Z6,{recursive:!0});await Bun.write(w0.join(Z6,`cw-${HZ($)}.css`),Z)}catch{}}async function q_($){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 UT(){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 zT(){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 Z9(){if(eX)return z4;eX=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await q_(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 $(UT());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 q_(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 $(zT());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 _T(){E4.clear(),n1.clear()}function qT(){z4=null,eX=!1,r1=null,T7="",E4.clear(),n1.clear(),jZ=null}async function Y9($){try{if(!QT({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 b$($){if(C$)return T7;C$=!0;try{let Z=await Z9();if(!Z||!Z.build)return C$=!1,"";if(!r1)r1=await Y9($);if(!r1)return C$=!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 C$=!1,G.css}catch(Z){return console.error(`${T.red}[Crosswind]${T.reset} Build error:`,Z),C$=!1,T7}}async function E7($){r1=null,await b$($)}function BT(){return T7}function OZ($){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 LZ($,Z){try{let Y=await Z9();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):OZ($);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=`${jZ||"default"}::${Q}`,K=E4.get(G);if(K!==void 0)return tX(G,K),K;let W=await KT(G);if(W!==null)return tX(G,W),W;if(!r1){let w=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (a0(),FZ)),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 Y9(X);try{jZ=HZ(JSON.stringify(r1??{}))}catch{jZ="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 __{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 XT(){if(!oX)oX=new __;return oX}var k$,JT=500,yu,oX=null,i1;var $6=D(()=>{k$=new Map;yu=new z_;i1=new Proxy({},{get($,Z){return XT()[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 VZ={};$0(VZ,{resetCssCache:()=>_T,resetCrosswindCache:()=>qT,rebuildCrosswindCSS:()=>E7,loadCrosswindConfig:()=>Y9,loadCrosswind:()=>Z9,injectCrosswindCSS:()=>y0,getCrosswindServeAsset:()=>$9,getCachedCSS:()=>BT,generateCrosswindCSS:()=>LZ,extractClassNames:()=>OZ,buildCrosswindCSS:()=>b$});import w0 from"path";import{hasLocalConfig as QT}from"bunfig";function HZ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function tX($,Z){if(E4.has($))E4.delete($);else if(E4.size>=B_)E4.delete(E4.keys().next().value);E4.set($,Z)}function GT($){let Z=HZ($);if(n1.has(Z))n1.delete(Z);else if(n1.size>=B_)n1.delete(n1.keys().next().value);return n1.set(Z,$),Z}function $9($){let Z=n1.get($);if(Z===void 0)return;return n1.delete($),n1.set($,Z),Z}async function KT($){if(!Z6)return null;try{let Z=Bun.file(w0.join(Z6,`cw-${HZ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function WT($,Z){if(!Z6)return;try{if(!fs.existsSync(Z6))fs.mkdirSync(Z6,{recursive:!0});await Bun.write(w0.join(Z6,`cw-${HZ($)}.css`),Z)}catch{}}async function q_($){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 UT(){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 zT(){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 Z9(){if(eX)return z4;eX=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await q_(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 $(UT());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 q_(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 $(zT());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 _T(){E4.clear(),n1.clear()}function qT(){z4=null,eX=!1,r1=null,T7="",E4.clear(),n1.clear(),jZ=null}async function Y9($){try{if(!QT({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 b$($){if(C$)return T7;C$=!0;try{let Z=await Z9();if(!Z||!Z.build)return C$=!1,"";if(!r1)r1=await Y9($);if(!r1)return C$=!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 C$=!1,G.css}catch(Z){return console.error(`${T.red}[Crosswind]${T.reset} Build error:`,Z),C$=!1,T7}}async function E7($){r1=null,await b$($)}function BT(){return T7}function OZ($){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 LZ($,Z){try{let Y=await Z9();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):OZ($);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=`${jZ||"default"}::${Q}`,K=E4.get(G);if(K!==void 0)return tX(G,K),K;let W=await KT(G);if(W!==null)return tX(G,W),W;if(!r1){let w=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (a0(),FZ)),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 Y9(X);try{jZ=HZ(JSON.stringify(r1??{}))}catch{jZ="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 tX(G,L),WT(G,L),L}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function y0($,Z,Y=!1){let J=await LZ($,Z);if(!J)return $;let X=Y?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${GT(J)}.css">`:`<style data-crosswind="generated">
@@ -22522,7 +22522,7 @@ else {
22522
22522
  `)}function gR($,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:""}"`:gR(K,Z+1)),G=Q.length>0?`,
22523
22523
  ${Y} [${Q.join(`,
22524
22524
  ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${X}${G})`}function vd($,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)||Xz($,Z)}function fd($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:dR(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 gd($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function hR(){return`id_${++hd}`}function dR($){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 dd($){return $.charAt(0).toUpperCase()+$.slice(1)}function ud($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function md($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function Qz($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=Qz(Y);return Z}function Gz($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=Gz(Y);return Z}function uR($){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 Kz,hd=0,ld,cd;var lR=D(()=>{Kz=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"}]]);ld={compileToNative:PR,createHotReloadServer:uR,NATIVE_COMPONENTS:Kz},cd=ld});import{spawn as iR}from"child_process";import g0 from"fs";import pd from"os";import Y0 from"path";import f from"process";import{CLI as id}from"@stacksjs/clapp";var x6="0.2.147";N$();xU();uK();sK();$6();nK();fK();TU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",A0=new id("stx");function cR($){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 pR($){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 Wz($){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 K7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),nd=($)=>$.endsWith(".stx")||$.endsWith(".md");function G7($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}function rd($){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 ad($,Z){try{let Y=["test"],J=[];if($&&$.length>0)for(let W of $)if(K7(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(pd.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=iR(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(`
22525
+ `)}return Y.get(Z.target)||Xz($,Z)}function fd($,Z,Y){let J=[];function X(Q){J.push({name:Q.zigType,hash:dR(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 gd($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function hR(){return`id_${++hd}`}function dR($){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 dd($){return $.charAt(0).toUpperCase()+$.slice(1)}function ud($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function md($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,J;while((J=Y.exec($))!==null)Z.push(J[1]);return Z}function Qz($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=Qz(Y);return Z}function Gz($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=Gz(Y);return Z}function uR($){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 Kz,hd=0,ld,cd;var lR=D(()=>{Kz=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"}]]);ld={compileToNative:PR,createHotReloadServer:uR,NATIVE_COMPONENTS:Kz},cd=ld});import{spawn as iR}from"child_process";import g0 from"fs";import pd from"os";import Y0 from"path";import f from"process";import{CLI as id}from"@stacksjs/clapp";var x6="0.2.148";N$();xU();uK();sK();$6();nK();fK();TU();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",A0=new id("stx");function cR($){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 pR($){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 Wz($){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 K7=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),nd=($)=>$.endsWith(".stx")||$.endsWith(".md");function G7($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);f.exit(Z)}function rd($){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 ad($,Z){try{let Y=["test"],J=[];if($&&$.length>0)for(let W of $)if(K7(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(pd.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=iR(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
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 sd=f.argv.length>=3&&(nd(f.argv[2])&&g0.existsSync(f.argv[2])||K7(f.argv[2]));if(sd){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=cR(f.argv[++Y]);if(!X.isValid)G7(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(K7($))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 dK(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:
package/dist/craft.js CHANGED
@@ -770,7 +770,7 @@ catch (e) {
770
770
  }
771
771
  throw e;
772
772
  }
773
- `),Q.set(W,U)}return U(...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 l8{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(),X=Z(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),X}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=await Z(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),X}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let X=Z/Y.maxTime*100,Q=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,J=Z>=Y.maxTime;if(!Q&&!J)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:X,timestamp:new Date,isWarning:Q};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let q of this.violationHandlers)try{q(G)}catch{}let K=Q?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${X.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(X-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(J)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 X=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:X?.maxTime,budgetUtilization:X?Y.totalTime/Y.count/X.maxTime*100:void 0}}let Z={};for(let[Y,X]of this.metrics.entries()){let Q=this.budgets.get(Y);Z[Y]={count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:Q?.maxTime,budgetUtilization:Q?X.totalTime/X.count/Q.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let X of this.violations)if($[X.label]=($[X.label]||0)+1,X.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 Xq(){if(!x7)x7=new l8;return x7}var H5,Yq=500,UL,x7=null,p8;var L5=k(()=>{H5=new Map;UL=new m8;p8=new Proxy({},{get($,Z){return Xq()[Z]}})});var j0;var c8=k(()=>{j0={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 a8={};t(a8,{resetCssCache:()=>zq,resetCrosswindCache:()=>_q,rebuildCrosswindCSS:()=>Bq,loadCrosswindConfig:()=>u7,loadCrosswind:()=>h7,injectCrosswindCSS:()=>d7,getCrosswindServeAsset:()=>Gq,getCachedCSS:()=>jq,generateCrosswindCSS:()=>o8,extractClassNames:()=>r8,buildCrosswindCSS:()=>s8});import X0 from"path";import{hasLocalConfig as Jq}from"bunfig/discovery";function c$($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function f7($,Z){if(_1.has($))_1.delete($);else if(_1.size>=n8)_1.delete(_1.keys().next().value);_1.set($,Z)}function Qq($){let Z=c$($);if(e0.has(Z))e0.delete(Z);else if(e0.size>=n8)e0.delete(e0.keys().next().value);return e0.set(Z,$),Z}function Gq($){let Z=e0.get($);if(Z===void 0)return;return e0.delete($),e0.set($,Z),Z}async function Kq($){if(!M1)return null;try{let Z=Bun.file(X0.join(M1,`cw-${c$($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function qq($,Z){if(!M1)return;try{if(!fs.existsSync(M1))fs.mkdirSync(M1,{recursive:!0});await Bun.write(X0.join(M1,`cw-${c$($)}.css`),Z)}catch{}}async function i8($){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 Wq(){let $=[],Z=process.cwd();while(Z!==X0.dirname(Z))$.push(X0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=X0.dirname(Z);return $}function Uq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function h7(){if(g7)return Q1;g7=!0;try{let $=async(Q)=>{for(let J of Q){if(!await Bun.file(J).exists())continue;let G=await i8(J);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${j0.green}[Crosswind]${j0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(J))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let Q=X0.resolve(process.env.CROSSWIND_SRC),J=await $([Q]);if(!J)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Q}`);return Q1=J,Q1}let Z=await $(Wq());if(Z)return Q1=Z,Q1;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Q of Y){let J=await i8(Q);if(J){if(Q1=J,!process.env.STACKS_DEV_QUIET)console.log(`${j0.green}[Crosswind]${j0.reset} CSS engine loaded`);return Q1}}let X=await $(Uq());if(X)return Q1=X,Q1;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${j0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${j0.reset}`),console.warn(`${j0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${j0.reset}`),null}}function zq(){_1.clear(),e0.clear()}function _q(){Q1=null,g7=!1,$1=null,G$="",_1.clear(),e0.clear(),p$=null}async function u7($){try{if(!Jq({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 X=X0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${j0.green}[Crosswind]${j0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${j0.yellow}[Crosswind]${j0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function s8($){if(F5)return G$;F5=!0;try{let Z=await h7();if(!Z||!Z.build)return F5=!1,"";if(!$1)$1=await u7($);if(!$1)return F5=!1,"";let Y=Z.defaultConfig?.theme||{},X=$1.theme||{},Q={...Z.defaultConfig,...$1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},J=performance.now(),G=await Z.build(Q),K=performance.now()-J;if(G$=G.css,console.log(`${j0.cyan}[Crosswind]${j0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),Q.output){let q=X0.isAbsolute(Q.output)?Q.output:X0.join($,Q.output),W=X0.dirname(q);if(!fs.existsSync(W))fs.mkdirSync(W,{recursive:!0});await Bun.write(q,G.css)}return F5=!1,G.css}catch(Z){return console.error(`${j0.red}[Crosswind]${j0.reset} Build error:`,Z),F5=!1,G$}}async function Bq($){$1=null,await s8($)}function jq(){return G$}function r8($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}J=Q.exec($)}return Z}async function o8($,Z){try{let Y=await h7();if(!Y)return"";let X=typeof Y.extractClasses==="function"?Y.extractClasses($):r8($);if(X.size===0)return"";let Q=Z?X0.resolve(Z):process.cwd();if(!M1)M1=o5(Q,"cache");let J=[...X].sort().join(" "),G=`${p$||"default"}::${J}`,K=_1.get(G);if(K!==void 0)return f7(G,K),K;let q=await Kq(G);if(q!==null)return f7(G,q),q;if(!$1){let A=null;try{let{loadStxConfig:M}=await Promise.resolve().then(() => (c1(),t8)),R=await M(Q);if(R.css)if(typeof R.css==="string"){let N=X0.isAbsolute(R.css)?R.css:X0.resolve(Q,R.css);if(await Bun.file(N).exists()){let T=await import(N);A=T.default||T,console.log(`${j0.green}[Crosswind]${j0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let N=X0.isAbsolute(R.css.config)?R.css.config:X0.resolve(Q,R.css.config);if(await Bun.file(N).exists()){let T=await import(N);A={...T.default||T,...A}}}console.log(`${j0.green}[Crosswind]${j0.reset} Using inline CSS config from stx.config.ts`)}}catch{}$1=A||await u7(Q);try{p$=c$(JSON.stringify($1??{}))}catch{p$="unhashable"}}let W=Y.defaultConfig||Y.config,U=$1||{},z=W.theme||{},B=(U.theme||{}).extend||{},j={...z};if(Object.keys(B).length>0)j.extend=B;let H=[...W.safelist||[],...U.safelist||[]],L={...W,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of X)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[A,M]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=M.split(/\s+/).filter(Boolean);for(let N of R)F.generate(N)}O=F.toCSS(!0,!1);let w=O.split(`
773
+ `),Q.set(W,U)}return U(...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 l8{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(),X=Z(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),X}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=await Z(),Q=performance.now()-Y;return this.recordTime($,Q),this.checkBudget($,Q),X}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let X=Z/Y.maxTime*100,Q=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,J=Z>=Y.maxTime;if(!Q&&!J)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:X,timestamp:new Date,isWarning:Q};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let q of this.violationHandlers)try{q(G)}catch{}let K=Q?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${X.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(X-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(J)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 X=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:X?.maxTime,budgetUtilization:X?Y.totalTime/Y.count/X.maxTime*100:void 0}}let Z={};for(let[Y,X]of this.metrics.entries()){let Q=this.budgets.get(Y);Z[Y]={count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:Q?.maxTime,budgetUtilization:Q?X.totalTime/X.count/Q.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let X of this.violations)if($[X.label]=($[X.label]||0)+1,X.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 Xq(){if(!x7)x7=new l8;return x7}var H5,Yq=500,UL,x7=null,p8;var L5=k(()=>{H5=new Map;UL=new m8;p8=new Proxy({},{get($,Z){return Xq()[Z]}})});var j0;var c8=k(()=>{j0={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 a8={};t(a8,{resetCssCache:()=>zq,resetCrosswindCache:()=>_q,rebuildCrosswindCSS:()=>Bq,loadCrosswindConfig:()=>u7,loadCrosswind:()=>h7,injectCrosswindCSS:()=>d7,getCrosswindServeAsset:()=>Gq,getCachedCSS:()=>jq,generateCrosswindCSS:()=>o8,extractClassNames:()=>r8,buildCrosswindCSS:()=>s8});import X0 from"path";import{hasLocalConfig as Jq}from"bunfig";function c$($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function f7($,Z){if(_1.has($))_1.delete($);else if(_1.size>=n8)_1.delete(_1.keys().next().value);_1.set($,Z)}function Qq($){let Z=c$($);if(e0.has(Z))e0.delete(Z);else if(e0.size>=n8)e0.delete(e0.keys().next().value);return e0.set(Z,$),Z}function Gq($){let Z=e0.get($);if(Z===void 0)return;return e0.delete($),e0.set($,Z),Z}async function Kq($){if(!M1)return null;try{let Z=Bun.file(X0.join(M1,`cw-${c$($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function qq($,Z){if(!M1)return;try{if(!fs.existsSync(M1))fs.mkdirSync(M1,{recursive:!0});await Bun.write(X0.join(M1,`cw-${c$($)}.css`),Z)}catch{}}async function i8($){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 Wq(){let $=[],Z=process.cwd();while(Z!==X0.dirname(Z))$.push(X0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=X0.dirname(Z);return $}function Uq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function h7(){if(g7)return Q1;g7=!0;try{let $=async(Q)=>{for(let J of Q){if(!await Bun.file(J).exists())continue;let G=await i8(J);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${j0.green}[Crosswind]${j0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(J))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let Q=X0.resolve(process.env.CROSSWIND_SRC),J=await $([Q]);if(!J)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Q}`);return Q1=J,Q1}let Z=await $(Wq());if(Z)return Q1=Z,Q1;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Q of Y){let J=await i8(Q);if(J){if(Q1=J,!process.env.STACKS_DEV_QUIET)console.log(`${j0.green}[Crosswind]${j0.reset} CSS engine loaded`);return Q1}}let X=await $(Uq());if(X)return Q1=X,Q1;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${j0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${j0.reset}`),console.warn(`${j0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${j0.reset}`),null}}function zq(){_1.clear(),e0.clear()}function _q(){Q1=null,g7=!1,$1=null,G$="",_1.clear(),e0.clear(),p$=null}async function u7($){try{if(!Jq({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 X=X0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${j0.green}[Crosswind]${j0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${j0.yellow}[Crosswind]${j0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function s8($){if(F5)return G$;F5=!0;try{let Z=await h7();if(!Z||!Z.build)return F5=!1,"";if(!$1)$1=await u7($);if(!$1)return F5=!1,"";let Y=Z.defaultConfig?.theme||{},X=$1.theme||{},Q={...Z.defaultConfig,...$1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},J=performance.now(),G=await Z.build(Q),K=performance.now()-J;if(G$=G.css,console.log(`${j0.cyan}[Crosswind]${j0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),Q.output){let q=X0.isAbsolute(Q.output)?Q.output:X0.join($,Q.output),W=X0.dirname(q);if(!fs.existsSync(W))fs.mkdirSync(W,{recursive:!0});await Bun.write(q,G.css)}return F5=!1,G.css}catch(Z){return console.error(`${j0.red}[Crosswind]${j0.reset} Build error:`,Z),F5=!1,G$}}async function Bq($){$1=null,await s8($)}function jq(){return G$}function r8($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}J=Q.exec($)}return Z}async function o8($,Z){try{let Y=await h7();if(!Y)return"";let X=typeof Y.extractClasses==="function"?Y.extractClasses($):r8($);if(X.size===0)return"";let Q=Z?X0.resolve(Z):process.cwd();if(!M1)M1=o5(Q,"cache");let J=[...X].sort().join(" "),G=`${p$||"default"}::${J}`,K=_1.get(G);if(K!==void 0)return f7(G,K),K;let q=await Kq(G);if(q!==null)return f7(G,q),q;if(!$1){let A=null;try{let{loadStxConfig:M}=await Promise.resolve().then(() => (c1(),t8)),R=await M(Q);if(R.css)if(typeof R.css==="string"){let N=X0.isAbsolute(R.css)?R.css:X0.resolve(Q,R.css);if(await Bun.file(N).exists()){let T=await import(N);A=T.default||T,console.log(`${j0.green}[Crosswind]${j0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let N=X0.isAbsolute(R.css.config)?R.css.config:X0.resolve(Q,R.css.config);if(await Bun.file(N).exists()){let T=await import(N);A={...T.default||T,...A}}}console.log(`${j0.green}[Crosswind]${j0.reset} Using inline CSS config from stx.config.ts`)}}catch{}$1=A||await u7(Q);try{p$=c$(JSON.stringify($1??{}))}catch{p$="unhashable"}}let W=Y.defaultConfig||Y.config,U=$1||{},z=W.theme||{},B=(U.theme||{}).extend||{},j={...z};if(Object.keys(B).length>0)j.extend=B;let H=[...W.safelist||[],...U.safelist||[]],L={...W,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of X)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[A,M]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=M.split(/\s+/).filter(Boolean);for(let N of R)F.generate(N)}O=F.toCSS(!0,!1);let w=O.split(`
774
774
  `);for(let[A,M]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=M.split(/\s+/).filter(Boolean),N=[],T=[];for(let I of R){let D=I.startsWith("dark:"),S=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let v=w[b].trim();if(v===`${S} {`||v.startsWith(`${S} {`)){let h=b,f="";while(h<w.length){if(f+=w[h],w[h].includes("}"))break;h++}let m=f.match(/\{([^}]+)\}/);if(m)if(D)T.push(m[1].trim());else N.push(m[1].trim());break}}}if(N.length)O+=`
775
775
  .${A} { ${N.join(" ")} }`;if(T.length)O+=`
776
776
  @media (prefers-color-scheme: dark) { .dark .${A} { ${T.join(" ")} } }`}return f7(G,O),qq(G,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function d7($,Z,Y=!1){let X=await o8($,Z);if(!X)return $;let Q=Y?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${Qq(X)}.css">`:`<style data-crosswind="generated">
@@ -1,5 +1,5 @@
1
1
  import path from "node:path";
2
- import { hasLocalConfig } from "bunfig/discovery";
2
+ import { hasLocalConfig } from "bunfig";
3
3
  import { stateDir } from "../state-dir.js";
4
4
  import { colors } from "./terminal-colors.js";
5
5
  let crosswindModule = null, crosswindLoadAttempted = !1, cachedConfig = null, cachedCSS = "", isBuilding = !1;
package/dist/pwa.js CHANGED
@@ -9496,7 +9496,7 @@ ${U}
9496
9496
  customElements.define('${Z}', ${G});
9497
9497
  `}async function g2($,Z,Y,X){if(Z.length<1)return e("WebComponent","@webcomponent directive requires at least the tag name parameter",o.INVALID_DIRECTIVE_SYNTAX);let Q=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[q$.join(q$.dirname(X),G,`${Q}.stx`),q$.join(process.cwd(),G,`${Q}.stx`),q$.join(q$.dirname(X),`${Q}.stx`)],q=null;for(let z of K)if(await p(z)){q=await Bun.file(z).text();break}if(!q)return e("WebComponent",`Component file not found: ${Q}.stx`,o.FILE_NOT_FOUND);let W=GU(q,Q);return`<script type="module">
9498
9498
  ${KU(W)}
9499
- </script>`}var h2=k(()=>{G1();F0()});var d2={};s(d2,{timingPlugin:()=>jU,pluginManager:()=>qU,definePlugin:()=>m4,debugPlugin:()=>zU,createVariablesPlugin:()=>BU,createFilterPlugin:()=>UU,createDirectivePlugin:()=>WU,PluginManager:()=>n3});function m4($){return $}class n3{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let J=await Q(Y);if(J){if(J.template!==void 0)Y.template=J.template;if(J.context)Y.context={...Y.context,...J.context};if(J.metadata)Y.metadata={...Y.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${X.name}" ${$} hook:`,J)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return X}}function WU($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function UU($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function BU($){return m4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var qU,zU,jU;var m2=k(()=>{qU=new n3;zU=m4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),jU=m4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var l2={};s(l2,{validateConfig:()=>FU,loadStxConfig:()=>O5,defineStxConfig:()=>LU,defaultConfig:()=>u1,config:()=>s3});import o3 from"fs";import k0 from"path";import{loadConfigWithResult as _U}from"bunfig";function HU($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=k0.join(process.cwd(),"resources","views"),Q=k0.join(process.cwd(),"resources","layouts");if(o3.existsSync(X)&&o3.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=k0.join(process.cwd(),"resources","views","pages");if(o3.existsSync(J))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}function OU($){if(b9($.stateDir),$.stateDir=v5(),$.cachePath=f5($.cachePath),$.build)$.build.cacheDir=f5($.build.cacheDir);if($.media?.cache)$.media.cache.directory=f5($.media.cache.directory);if($.story)$.story.outDir=f5($.story.outDir)}async function O5($){if(!$){if(H5)return H5;if(u4)return u4}let Z=$?k0.resolve($):process.cwd(),Y=u2.get(Z);if(Y)return Y;let X=(async()=>{let J=(await _U({name:"stx",alias:"ui",cwd:Z,defaultConfig:u1,verbose:!1})).config;OU(J);let G=HU(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!k0.isAbsolute(J.partialsDir))J.partialsDir=k0.join(K,J.partialsDir);if(J.componentsDir&&!k0.isAbsolute(J.componentsDir))J.componentsDir=k0.join(K,J.componentsDir);if(J.layoutsDir&&!k0.isAbsolute(J.layoutsDir))J.layoutsDir=k0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (m2(),d2)),q=[],W=[];for(let U of J.plugins){let z=typeof U==="string"?U:U[0],j=typeof U==="string"?{}:U[1]||{};try{let _,B;try{_=await import(z),B=k0.dirname(q0.resolve(z))}catch{let L=k0.resolve(process.cwd(),z);_=await import(L),B=k0.dirname(L)}let H=_.default||_;if(K.register(H,J),H.components){let L=k0.resolve(B,H.components);q.push(L)}if(H.pages){let L=k0.resolve(B,H.pages),F=j.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(F)},addRoute:(F,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[F]=O},addMiddleware:(F)=>{J.middleware=J.middleware||[],J.middleware.push(F)},pluginDir:B,config:J};await H.setup(j,L)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(_){console.warn(`[stx] Failed to load plugin ${z}:`,_.message)}}J._pluginComponentDirs=q,J._pluginPageDirs=W}return J})();if(u2.set(Z,X),!$)u4=X,X.then((Q)=>{H5=Q}).catch(()=>{});return X}function LU($){return $}function FU($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!X.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var u1,H5=null,u2,u4=null,s3;var L5=k(()=>{N7();M7();T7();I7();K3();Z2();g3();d3();i3();k$();h2();u1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:Z5,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:DZ,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:g2,hasEndTag:!1,description:"Include a web component in the template"},P9,C9,x2,f2,v9,f9,g9,x9,u9,c9,$2,f3,...h3],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};u2=new Map;s3=new Proxy(u1,{get($,Z){if(H5&&Z in H5)return H5[Z];if(!u4)O5().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import G0 from"path";import{hasLocalConfig as VU}from"bunfig/discovery";function p4($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function a3($,Z){if(l1.has($))l1.delete($);else if(l1.size>=i2)l1.delete(l1.keys().next().value);l1.set($,Z)}function wU($){let Z=p4($);if(F5.has(Z))F5.delete(Z);else if(F5.size>=i2)F5.delete(F5.keys().next().value);return F5.set(Z,$),Z}async function AU($){if(!V1)return null;try{let Z=Bun.file(G0.join(V1,`cw-${p4($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function RU($,Z){if(!V1)return;try{if(!fs.existsSync(V1))fs.mkdirSync(V1,{recursive:!0});await Bun.write(G0.join(V1,`cw-${p4($)}.css`),Z)}catch{}}async function c2($){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 NU(){let $=[],Z=process.cwd();while(Z!==G0.dirname(Z))$.push(G0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(G0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(G0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(G0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(G0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(G0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=G0.dirname(Z);return $}function MU(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[G0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),G0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),G0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),G0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),G0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),G0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(G0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(G0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function TU(){if(p2)return K1;p2=!0;try{let $=async(Q)=>{for(let J of Q){if(!await Bun.file(J).exists())continue;let G=await c2(J);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded from ${G0.dirname(G0.dirname(J))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let Q=G0.resolve(process.env.CROSSWIND_SRC),J=await $([Q]);if(!J)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Q}`);return K1=J,K1}let Z=await $(NU());if(Z)return K1=Z,K1;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Q of Y){let J=await c2(Q);if(J){if(K1=J,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded`);return K1}}let X=await $(MU());if(X)return K1=X,K1;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${L0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${L0.reset}`),console.warn(`${L0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${L0.reset}`),null}}async function IU($){try{if(!VU({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 X=G0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${L0.yellow}[Crosswind]${L0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function DU($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}J=Q.exec($)}return Z}async function EU($,Z){try{let Y=await TU();if(!Y)return"";let X=typeof Y.extractClasses==="function"?Y.extractClasses($):DU($);if(X.size===0)return"";let Q=Z?G0.resolve(Z):process.cwd();if(!V1)V1=x5(Q,"cache");let J=[...X].sort().join(" "),G=`${r3||"default"}::${J}`,K=l1.get(G);if(K!==void 0)return a3(G,K),K;let q=await AU(G);if(q!==null)return a3(G,q),q;if(!l4){let A=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (L5(),l2)),R=await N(Q);if(R.css)if(typeof R.css==="string"){let M=G0.isAbsolute(R.css)?R.css:G0.resolve(Q,R.css);if(await Bun.file(M).exists()){let T=await import(M);A=T.default||T,console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let M=G0.isAbsolute(R.css.config)?R.css.config:G0.resolve(Q,R.css.config);if(await Bun.file(M).exists()){let T=await import(M);A={...T.default||T,...A}}}console.log(`${L0.green}[Crosswind]${L0.reset} Using inline CSS config from stx.config.ts`)}}catch{}l4=A||await IU(Q);try{r3=p4(JSON.stringify(l4??{}))}catch{r3="unhashable"}}let W=Y.defaultConfig||Y.config,U=l4||{},z=W.theme||{},_=(U.theme||{}).extend||{},B={...z};if(Object.keys(_).length>0)B.extend=_;let H=[...W.safelist||[],...U.safelist||[]],L={...W,...U,content:[],output:"",preflight:!0,minify:!1,theme:B,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of X)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[A,N]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean);for(let M of R)F.generate(M)}O=F.toCSS(!0,!1);let w=O.split(`
9499
+ </script>`}var h2=k(()=>{G1();F0()});var d2={};s(d2,{timingPlugin:()=>jU,pluginManager:()=>qU,definePlugin:()=>m4,debugPlugin:()=>zU,createVariablesPlugin:()=>BU,createFilterPlugin:()=>UU,createDirectivePlugin:()=>WU,PluginManager:()=>n3});function m4($){return $}class n3{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let J=await Q(Y);if(J){if(J.template!==void 0)Y.template=J.template;if(J.context)Y.context={...Y.context,...J.context};if(J.metadata)Y.metadata={...Y.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${X.name}" ${$} hook:`,J)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return X}}function WU($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function UU($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function BU($){return m4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var qU,zU,jU;var m2=k(()=>{qU=new n3;zU=m4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),jU=m4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var l2={};s(l2,{validateConfig:()=>FU,loadStxConfig:()=>O5,defineStxConfig:()=>LU,defaultConfig:()=>u1,config:()=>s3});import o3 from"fs";import k0 from"path";import{loadConfigWithResult as _U}from"bunfig";function HU($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=k0.join(process.cwd(),"resources","views"),Q=k0.join(process.cwd(),"resources","layouts");if(o3.existsSync(X)&&o3.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=k0.join(process.cwd(),"resources","views","pages");if(o3.existsSync(J))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}function OU($){if(b9($.stateDir),$.stateDir=v5(),$.cachePath=f5($.cachePath),$.build)$.build.cacheDir=f5($.build.cacheDir);if($.media?.cache)$.media.cache.directory=f5($.media.cache.directory);if($.story)$.story.outDir=f5($.story.outDir)}async function O5($){if(!$){if(H5)return H5;if(u4)return u4}let Z=$?k0.resolve($):process.cwd(),Y=u2.get(Z);if(Y)return Y;let X=(async()=>{let J=(await _U({name:"stx",alias:"ui",cwd:Z,defaultConfig:u1,verbose:!1})).config;OU(J);let G=HU(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!k0.isAbsolute(J.partialsDir))J.partialsDir=k0.join(K,J.partialsDir);if(J.componentsDir&&!k0.isAbsolute(J.componentsDir))J.componentsDir=k0.join(K,J.componentsDir);if(J.layoutsDir&&!k0.isAbsolute(J.layoutsDir))J.layoutsDir=k0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (m2(),d2)),q=[],W=[];for(let U of J.plugins){let z=typeof U==="string"?U:U[0],j=typeof U==="string"?{}:U[1]||{};try{let _,B;try{_=await import(z),B=k0.dirname(q0.resolve(z))}catch{let L=k0.resolve(process.cwd(),z);_=await import(L),B=k0.dirname(L)}let H=_.default||_;if(K.register(H,J),H.components){let L=k0.resolve(B,H.components);q.push(L)}if(H.pages){let L=k0.resolve(B,H.pages),F=j.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(F)},addRoute:(F,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[F]=O},addMiddleware:(F)=>{J.middleware=J.middleware||[],J.middleware.push(F)},pluginDir:B,config:J};await H.setup(j,L)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(_){console.warn(`[stx] Failed to load plugin ${z}:`,_.message)}}J._pluginComponentDirs=q,J._pluginPageDirs=W}return J})();if(u2.set(Z,X),!$)u4=X,X.then((Q)=>{H5=Q}).catch(()=>{});return X}function LU($){return $}function FU($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!X.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var u1,H5=null,u2,u4=null,s3;var L5=k(()=>{N7();M7();T7();I7();K3();Z2();g3();d3();i3();k$();h2();u1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:Z5,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:DZ,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:g2,hasEndTag:!1,description:"Include a web component in the template"},P9,C9,x2,f2,v9,f9,g9,x9,u9,c9,$2,f3,...h3],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};u2=new Map;s3=new Proxy(u1,{get($,Z){if(H5&&Z in H5)return H5[Z];if(!u4)O5().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import G0 from"path";import{hasLocalConfig as VU}from"bunfig";function p4($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function a3($,Z){if(l1.has($))l1.delete($);else if(l1.size>=i2)l1.delete(l1.keys().next().value);l1.set($,Z)}function wU($){let Z=p4($);if(F5.has(Z))F5.delete(Z);else if(F5.size>=i2)F5.delete(F5.keys().next().value);return F5.set(Z,$),Z}async function AU($){if(!V1)return null;try{let Z=Bun.file(G0.join(V1,`cw-${p4($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function RU($,Z){if(!V1)return;try{if(!fs.existsSync(V1))fs.mkdirSync(V1,{recursive:!0});await Bun.write(G0.join(V1,`cw-${p4($)}.css`),Z)}catch{}}async function c2($){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 NU(){let $=[],Z=process.cwd();while(Z!==G0.dirname(Z))$.push(G0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(G0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(G0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(G0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(G0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(G0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=G0.dirname(Z);return $}function MU(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[G0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),G0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),G0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),G0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),G0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),G0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(G0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(G0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function TU(){if(p2)return K1;p2=!0;try{let $=async(Q)=>{for(let J of Q){if(!await Bun.file(J).exists())continue;let G=await c2(J);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded from ${G0.dirname(G0.dirname(J))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let Q=G0.resolve(process.env.CROSSWIND_SRC),J=await $([Q]);if(!J)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Q}`);return K1=J,K1}let Z=await $(NU());if(Z)return K1=Z,K1;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Q of Y){let J=await c2(Q);if(J){if(K1=J,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded`);return K1}}let X=await $(MU());if(X)return K1=X,K1;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${L0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${L0.reset}`),console.warn(`${L0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${L0.reset}`),null}}async function IU($){try{if(!VU({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 X=G0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${L0.yellow}[Crosswind]${L0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function DU($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}J=Q.exec($)}return Z}async function EU($,Z){try{let Y=await TU();if(!Y)return"";let X=typeof Y.extractClasses==="function"?Y.extractClasses($):DU($);if(X.size===0)return"";let Q=Z?G0.resolve(Z):process.cwd();if(!V1)V1=x5(Q,"cache");let J=[...X].sort().join(" "),G=`${r3||"default"}::${J}`,K=l1.get(G);if(K!==void 0)return a3(G,K),K;let q=await AU(G);if(q!==null)return a3(G,q),q;if(!l4){let A=null;try{let{loadStxConfig:N}=await Promise.resolve().then(() => (L5(),l2)),R=await N(Q);if(R.css)if(typeof R.css==="string"){let M=G0.isAbsolute(R.css)?R.css:G0.resolve(Q,R.css);if(await Bun.file(M).exists()){let T=await import(M);A=T.default||T,console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(A={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let M=G0.isAbsolute(R.css.config)?R.css.config:G0.resolve(Q,R.css.config);if(await Bun.file(M).exists()){let T=await import(M);A={...T.default||T,...A}}}console.log(`${L0.green}[Crosswind]${L0.reset} Using inline CSS config from stx.config.ts`)}}catch{}l4=A||await IU(Q);try{r3=p4(JSON.stringify(l4??{}))}catch{r3="unhashable"}}let W=Y.defaultConfig||Y.config,U=l4||{},z=W.theme||{},_=(U.theme||{}).extend||{},B={...z};if(Object.keys(_).length>0)B.extend=_;let H=[...W.safelist||[],...U.safelist||[]],L={...W,...U,content:[],output:"",preflight:!0,minify:!1,theme:B,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of X)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[A,N]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean);for(let M of R)F.generate(M)}O=F.toCSS(!0,!1);let w=O.split(`
9500
9500
  `);for(let[A,N]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let R=N.split(/\s+/).filter(Boolean),M=[],T=[];for(let I of R){let E=I.startsWith("dark:"),S=`.${(E?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let v=w[b].trim();if(v===`${S} {`||v.startsWith(`${S} {`)){let h=b,f="";while(h<w.length){if(f+=w[h],w[h].includes("}"))break;h++}let m=f.match(/\{([^}]+)\}/);if(m)if(E)T.push(m[1].trim());else M.push(m[1].trim());break}}}if(M.length)O+=`
9501
9501
  .${A} { ${M.join(" ")} }`;if(T.length)O+=`
9502
9502
  @media (prefers-color-scheme: dark) { .dark .${A} { ${T.join(" ")} } }`}return a3(G,O),RU(G,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function n2($,Z,Y=!1){let X=await EU($,Z);if(!X)return $;let Q=Y?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${wU(X)}.css">`:`<style data-crosswind="generated">
package/dist/ssg.js CHANGED
@@ -8305,7 +8305,7 @@ ${z}
8305
8305
  customElements.define('${Z}', ${G});
8306
8306
  `}async function B2($,Z,Y,J){if(Z.length<1)return $0("WebComponent","@webcomponent directive requires at least the tag name parameter",o.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[W$.join(W$.dirname(J),G,`${X}.stx`),W$.join(process.cwd(),G,`${X}.stx`),W$.join(W$.dirname(J),`${X}.stx`)],W=null;for(let U of K)if(await c(U)){W=await Bun.file(U).text();break}if(!W)return $0("WebComponent",`Component file not found: ${X}.stx`,o.FILE_NOT_FOUND);let q=Aq(W,X);return`<script type="module">
8307
8307
  ${Rq(q)}
8308
- </script>`}var H2=b(()=>{U1();M0()});var O2={};a(O2,{timingPlugin:()=>Dq,pluginManager:()=>Nq,definePlugin:()=>x4,debugPlugin:()=>Iq,createVariablesPlugin:()=>Eq,createFilterPlugin:()=>Tq,createDirectivePlugin:()=>Mq,PluginManager:()=>v3});function x4($){return $}class v3{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,J]of this.plugins)if(J.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let J of this.sortedPlugins){let X=J[$];if(X)try{let Q=await X(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let G=await Q(Z,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${X.name}" ${$} hook:`,G)}}return J}}function Mq($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function Tq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Eq($){return x4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var Nq,Iq,Dq;var L2=b(()=>{Nq=new v3;Iq=x4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),Dq=x4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var V2={};a(V2,{validateConfig:()=>Pq,loadStxConfig:()=>j1,defineStxConfig:()=>yq,defaultConfig:()=>o1,config:()=>f3});import x3 from"fs";import y0 from"path";import{loadConfigWithResult as kq}from"bunfig";function bq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=y0.join(process.cwd(),"resources","views"),X=y0.join(process.cwd(),"resources","layouts");if(x3.existsSync(J)&&x3.existsSync(X))return{root:"resources",pagesDir:"views"};let Q=y0.join(process.cwd(),"resources","views","pages");if(x3.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}function Sq($){if(Q9($.stateDir),$.stateDir=v5(),$.cachePath=x5($.cachePath),$.build)$.build.cacheDir=x5($.build.cacheDir);if($.media?.cache)$.media.cache.directory=x5($.media.cache.directory);if($.story)$.story.outDir=x5($.story.outDir)}async function j1($){if(!$){if(V5)return V5;if(f4)return f4}let Z=$?y0.resolve($):process.cwd(),Y=F2.get(Z);if(Y)return Y;let J=(async()=>{let Q=(await kq({name:"stx",alias:"ui",cwd:Z,defaultConfig:o1,verbose:!1})).config;Sq(Q);let G=bq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!y0.isAbsolute(Q.partialsDir))Q.partialsDir=y0.join(K,Q.partialsDir);if(Q.componentsDir&&!y0.isAbsolute(Q.componentsDir))Q.componentsDir=y0.join(K,Q.componentsDir);if(Q.layoutsDir&&!y0.isAbsolute(Q.layoutsDir))Q.layoutsDir=y0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (L2(),O2)),W=[],q=[];for(let z of Q.plugins){let U=typeof z==="string"?z:z[0],j=typeof z==="string"?{}:z[1]||{};try{let _,B;try{_=await import(U),B=y0.dirname(_0.resolve(U))}catch{let L=y0.resolve(process.cwd(),U);_=await import(L),B=y0.dirname(L)}let H=_.default||_;if(K.register(H,Q),H.components){let L=y0.resolve(B,H.components);W.push(L)}if(H.pages){let L=y0.resolve(B,H.pages),F=j.path||"/";q.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:B,config:Q};await H.setup(j,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(_){console.warn(`[stx] Failed to load plugin ${U}:`,_.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=q}return Q})();if(F2.set(Z,J),!$)f4=J,J.then((X)=>{V5=X}).catch(()=>{});return J}function yq($){return $}function Pq($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${J.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let J=["AA","AAA"];if(!J.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${X}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${X}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${X}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${X}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${X}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((X,Q)=>{if(!X.pattern||typeof X.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(X.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(X.maxAgeSeconds!==void 0&&(typeof X.maxAgeSeconds!=="number"||X.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(X.maxEntries!==void 0&&(typeof X.maxEntries!=="number"||X.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((X)=>typeof X!=="number"||X<16||X>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var o1,V5=null,F2,f4=null,f3;var s1=b(()=>{j7();_7();B7();H7();a7();kZ();E3();Z2();C3();f5();H2();o1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:Q5,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:ZZ,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:B2,hasEndTag:!1,description:"Include a web component in the template"},W9,q9,j2,_2,z9,j9,_9,U9,L9,w9,EZ,D3,...$2],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};F2=new Map;f3=new Proxy(o1,{get($,Z){if(V5&&Z in V5)return V5[Z];if(!f4)j1().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var T2={};a(T2,{resetCssCache:()=>uq,resetCrosswindCache:()=>mq,rebuildCrosswindCSS:()=>pq,loadCrosswindConfig:()=>u3,loadCrosswind:()=>d3,injectCrosswindCSS:()=>z$,getCrosswindServeAsset:()=>xq,getCachedCSS:()=>lq,generateCrosswindCSS:()=>M2,extractClassNames:()=>N2,buildCrosswindCSS:()=>R2});import J0 from"path";import{hasLocalConfig as Cq}from"bunfig/discovery";function h4($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function g3($,Z){if(_1.has($))_1.delete($);else if(_1.size>=A2)_1.delete(_1.keys().next().value);_1.set($,Z)}function vq($){let Z=h4($);if($1.has(Z))$1.delete(Z);else if($1.size>=A2)$1.delete($1.keys().next().value);return $1.set(Z,$),Z}function xq($){let Z=$1.get($);if(Z===void 0)return;return $1.delete($),$1.set($,Z),Z}async function fq($){if(!I1)return null;try{let Z=Bun.file(J0.join(I1,`cw-${h4($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function gq($,Z){if(!I1)return;try{if(!fs.existsSync(I1))fs.mkdirSync(I1,{recursive:!0});await Bun.write(J0.join(I1,`cw-${h4($)}.css`),Z)}catch{}}async function w2($){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 hq(){let $=[],Z=process.cwd();while(Z!==J0.dirname(Z))$.push(J0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(J0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(J0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(J0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(J0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(J0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=J0.dirname(Z);return $}function dq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[J0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function d3(){if(h3)return Q1;h3=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await w2(Q);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${O0.green}[Crosswind]${O0.reset} CSS engine loaded from ${J0.dirname(J0.dirname(Q))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let X=J0.resolve(process.env.CROSSWIND_SRC),Q=await $([X]);if(!Q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${X}`);return Q1=Q,Q1}let Z=await $(hq());if(Z)return Q1=Z,Q1;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of Y){let Q=await w2(X);if(Q){if(Q1=Q,!process.env.STACKS_DEV_QUIET)console.log(`${O0.green}[Crosswind]${O0.reset} CSS engine loaded`);return Q1}}let J=await $(dq());if(J)return Q1=J,Q1;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${O0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${O0.reset}`),console.warn(`${O0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${O0.reset}`),null}}function uq(){_1.clear(),$1.clear()}function mq(){Q1=null,h3=!1,Z1=null,q$="",_1.clear(),$1.clear(),g4=null}async function u3($){try{if(!Cq({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=J0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${O0.green}[Crosswind]${O0.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${O0.yellow}[Crosswind]${O0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function R2($){if(w5)return q$;w5=!0;try{let Z=await d3();if(!Z||!Z.build)return w5=!1,"";if(!Z1)Z1=await u3($);if(!Z1)return w5=!1,"";let Y=Z.defaultConfig?.theme||{},J=Z1.theme||{},X={...Z.defaultConfig,...Z1,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},Q=performance.now(),G=await Z.build(X),K=performance.now()-Q;if(q$=G.css,console.log(`${O0.cyan}[Crosswind]${O0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),X.output){let W=J0.isAbsolute(X.output)?X.output:J0.join($,X.output),q=J0.dirname(W);if(!fs.existsSync(q))fs.mkdirSync(q,{recursive:!0});await Bun.write(W,G.css)}return w5=!1,G.css}catch(Z){return console.error(`${O0.red}[Crosswind]${O0.reset} Build error:`,Z),w5=!1,q$}}async function pq($){Z1=null,await R2($)}function lq(){return q$}function N2($){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 M2($,Z){try{let Y=await d3();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):N2($);if(J.size===0)return"";let X=Z?J0.resolve(Z):process.cwd();if(!I1)I1=L1(X,"cache");let Q=[...J].sort().join(" "),G=`${g4||"default"}::${Q}`,K=_1.get(G);if(K!==void 0)return g3(G,K),K;let W=await fq(G);if(W!==null)return g3(G,W),W;if(!Z1){let A=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (s1(),V2)),N=await R(X);if(N.css)if(typeof N.css==="string"){let M=J0.isAbsolute(N.css)?N.css:J0.resolve(X,N.css);if(await Bun.file(M).exists()){let T=await import(M);A=T.default||T,console.log(`${O0.green}[Crosswind]${O0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(A={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=J0.isAbsolute(N.css.config)?N.css.config:J0.resolve(X,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);A={...T.default||T,...A}}}console.log(`${O0.green}[Crosswind]${O0.reset} Using inline CSS config from stx.config.ts`)}}catch{}Z1=A||await u3(X);try{g4=h4(JSON.stringify(Z1??{}))}catch{g4="unhashable"}}let q=Y.defaultConfig||Y.config,z=Z1||{},U=q.theme||{},_=(z.theme||{}).extend||{},B={...U};if(Object.keys(_).length>0)B.extend=_;let H=[...q.safelist||[],...z.safelist||[]],L={...q,...z,content:[],output:"",preflight:!0,minify:!1,theme:B,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of J)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||z.shortcuts||{};for(let[A,R]of Object.entries(V)){if(!J.has(A)&&!H.includes(A))continue;let N=R.split(/\s+/).filter(Boolean);for(let M of N)F.generate(M)}O=F.toCSS(!0,!1);let w=O.split(`
8308
+ </script>`}var H2=b(()=>{U1();M0()});var O2={};a(O2,{timingPlugin:()=>Dq,pluginManager:()=>Nq,definePlugin:()=>x4,debugPlugin:()=>Iq,createVariablesPlugin:()=>Eq,createFilterPlugin:()=>Tq,createDirectivePlugin:()=>Mq,PluginManager:()=>v3});function x4($){return $}class v3{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,J]of this.plugins)if(J.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let J of this.sortedPlugins){let X=J[$];if(X)try{let Q=await X(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let G=await Q(Z,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${X.name}" ${$} hook:`,G)}}return J}}function Mq($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function Tq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Eq($){return x4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var Nq,Iq,Dq;var L2=b(()=>{Nq=new v3;Iq=x4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),Dq=x4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var V2={};a(V2,{validateConfig:()=>Pq,loadStxConfig:()=>j1,defineStxConfig:()=>yq,defaultConfig:()=>o1,config:()=>f3});import x3 from"fs";import y0 from"path";import{loadConfigWithResult as kq}from"bunfig";function bq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=y0.join(process.cwd(),"resources","views"),X=y0.join(process.cwd(),"resources","layouts");if(x3.existsSync(J)&&x3.existsSync(X))return{root:"resources",pagesDir:"views"};let Q=y0.join(process.cwd(),"resources","views","pages");if(x3.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}function Sq($){if(Q9($.stateDir),$.stateDir=v5(),$.cachePath=x5($.cachePath),$.build)$.build.cacheDir=x5($.build.cacheDir);if($.media?.cache)$.media.cache.directory=x5($.media.cache.directory);if($.story)$.story.outDir=x5($.story.outDir)}async function j1($){if(!$){if(V5)return V5;if(f4)return f4}let Z=$?y0.resolve($):process.cwd(),Y=F2.get(Z);if(Y)return Y;let J=(async()=>{let Q=(await kq({name:"stx",alias:"ui",cwd:Z,defaultConfig:o1,verbose:!1})).config;Sq(Q);let G=bq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!y0.isAbsolute(Q.partialsDir))Q.partialsDir=y0.join(K,Q.partialsDir);if(Q.componentsDir&&!y0.isAbsolute(Q.componentsDir))Q.componentsDir=y0.join(K,Q.componentsDir);if(Q.layoutsDir&&!y0.isAbsolute(Q.layoutsDir))Q.layoutsDir=y0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (L2(),O2)),W=[],q=[];for(let z of Q.plugins){let U=typeof z==="string"?z:z[0],j=typeof z==="string"?{}:z[1]||{};try{let _,B;try{_=await import(U),B=y0.dirname(_0.resolve(U))}catch{let L=y0.resolve(process.cwd(),U);_=await import(L),B=y0.dirname(L)}let H=_.default||_;if(K.register(H,Q),H.components){let L=y0.resolve(B,H.components);W.push(L)}if(H.pages){let L=y0.resolve(B,H.pages),F=j.path||"/";q.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:B,config:Q};await H.setup(j,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(_){console.warn(`[stx] Failed to load plugin ${U}:`,_.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=q}return Q})();if(F2.set(Z,J),!$)f4=J,J.then((X)=>{V5=X}).catch(()=>{});return J}function yq($){return $}function Pq($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${J.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let J=["AA","AAA"];if(!J.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${X}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${X}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${X}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${X}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${X}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((X,Q)=>{if(!X.pattern||typeof X.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(X.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(X.maxAgeSeconds!==void 0&&(typeof X.maxAgeSeconds!=="number"||X.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(X.maxEntries!==void 0&&(typeof X.maxEntries!=="number"||X.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((X)=>typeof X!=="number"||X<16||X>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var o1,V5=null,F2,f4=null,f3;var s1=b(()=>{j7();_7();B7();H7();a7();kZ();E3();Z2();C3();f5();H2();o1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,stateDir:Q5,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:ZZ,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:B2,hasEndTag:!1,description:"Include a web component in the template"},W9,q9,j2,_2,z9,j9,_9,U9,L9,w9,EZ,D3,...$2],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};F2=new Map;f3=new Proxy(o1,{get($,Z){if(V5&&Z in V5)return V5[Z];if(!f4)j1().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var T2={};a(T2,{resetCssCache:()=>uq,resetCrosswindCache:()=>mq,rebuildCrosswindCSS:()=>pq,loadCrosswindConfig:()=>u3,loadCrosswind:()=>d3,injectCrosswindCSS:()=>z$,getCrosswindServeAsset:()=>xq,getCachedCSS:()=>lq,generateCrosswindCSS:()=>M2,extractClassNames:()=>N2,buildCrosswindCSS:()=>R2});import J0 from"path";import{hasLocalConfig as Cq}from"bunfig";function h4($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function g3($,Z){if(_1.has($))_1.delete($);else if(_1.size>=A2)_1.delete(_1.keys().next().value);_1.set($,Z)}function vq($){let Z=h4($);if($1.has(Z))$1.delete(Z);else if($1.size>=A2)$1.delete($1.keys().next().value);return $1.set(Z,$),Z}function xq($){let Z=$1.get($);if(Z===void 0)return;return $1.delete($),$1.set($,Z),Z}async function fq($){if(!I1)return null;try{let Z=Bun.file(J0.join(I1,`cw-${h4($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function gq($,Z){if(!I1)return;try{if(!fs.existsSync(I1))fs.mkdirSync(I1,{recursive:!0});await Bun.write(J0.join(I1,`cw-${h4($)}.css`),Z)}catch{}}async function w2($){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 hq(){let $=[],Z=process.cwd();while(Z!==J0.dirname(Z))$.push(J0.join(Z,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(J0.join(Z,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(J0.join(Z,"pantry","@cwcss","crosswind","dist","index.js")),$.push(J0.join(Z,"pantry","@cwcss","crosswind","src","index.ts")),$.push(J0.join(Z,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(J0.join(Z,"pantry","@stacksjs","crosswind","dist","index.js")),Z=J0.dirname(Z);return $}function dq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"";if(Z){let Y=[J0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),J0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),J0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...Y)}return $.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(J0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function d3(){if(h3)return Q1;h3=!0;try{let $=async(X)=>{for(let Q of X){if(!await Bun.file(Q).exists())continue;let G=await w2(Q);if(G){if(!process.env.STACKS_DEV_QUIET)console.log(`${O0.green}[Crosswind]${O0.reset} CSS engine loaded from ${J0.dirname(J0.dirname(Q))}`);return G}}return null};if(process.env.CROSSWIND_SRC){let X=J0.resolve(process.env.CROSSWIND_SRC),Q=await $([X]);if(!Q)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${X}`);return Q1=Q,Q1}let Z=await $(hq());if(Z)return Q1=Z,Q1;let Y=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let X of Y){let Q=await w2(X);if(Q){if(Q1=Q,!process.env.STACKS_DEV_QUIET)console.log(`${O0.green}[Crosswind]${O0.reset} CSS engine loaded`);return Q1}}let J=await $(dq());if(J)return Q1=J,Q1;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${O0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${O0.reset}`),console.warn(`${O0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${O0.reset}`),null}}function uq(){_1.clear(),$1.clear()}function mq(){Q1=null,h3=!1,Z1=null,q$="",_1.clear(),$1.clear(),g4=null}async function u3($){try{if(!Cq({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=J0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${O0.green}[Crosswind]${O0.reset} Loaded config from ${J||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${O0.yellow}[Crosswind]${O0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function R2($){if(w5)return q$;w5=!0;try{let Z=await d3();if(!Z||!Z.build)return w5=!1,"";if(!Z1)Z1=await u3($);if(!Z1)return w5=!1,"";let Y=Z.defaultConfig?.theme||{},J=Z1.theme||{},X={...Z.defaultConfig,...Z1,theme:{...Y,...J,extend:{...Y.extend||{},...J.extend||{}}}},Q=performance.now(),G=await Z.build(X),K=performance.now()-Q;if(q$=G.css,console.log(`${O0.cyan}[Crosswind]${O0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),X.output){let W=J0.isAbsolute(X.output)?X.output:J0.join($,X.output),q=J0.dirname(W);if(!fs.existsSync(q))fs.mkdirSync(q,{recursive:!0});await Bun.write(W,G.css)}return w5=!1,G.css}catch(Z){return console.error(`${O0.red}[Crosswind]${O0.reset} Build error:`,Z),w5=!1,q$}}async function pq($){Z1=null,await R2($)}function lq(){return q$}function N2($){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 M2($,Z){try{let Y=await d3();if(!Y)return"";let J=typeof Y.extractClasses==="function"?Y.extractClasses($):N2($);if(J.size===0)return"";let X=Z?J0.resolve(Z):process.cwd();if(!I1)I1=L1(X,"cache");let Q=[...J].sort().join(" "),G=`${g4||"default"}::${Q}`,K=_1.get(G);if(K!==void 0)return g3(G,K),K;let W=await fq(G);if(W!==null)return g3(G,W),W;if(!Z1){let A=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (s1(),V2)),N=await R(X);if(N.css)if(typeof N.css==="string"){let M=J0.isAbsolute(N.css)?N.css:J0.resolve(X,N.css);if(await Bun.file(M).exists()){let T=await import(M);A=T.default||T,console.log(`${O0.green}[Crosswind]${O0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(A={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=J0.isAbsolute(N.css.config)?N.css.config:J0.resolve(X,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);A={...T.default||T,...A}}}console.log(`${O0.green}[Crosswind]${O0.reset} Using inline CSS config from stx.config.ts`)}}catch{}Z1=A||await u3(X);try{g4=h4(JSON.stringify(Z1??{}))}catch{g4="unhashable"}}let q=Y.defaultConfig||Y.config,z=Z1||{},U=q.theme||{},_=(z.theme||{}).extend||{},B={...U};if(Object.keys(_).length>0)B.extend=_;let H=[...q.safelist||[],...z.safelist||[]],L={...q,...z,content:[],output:"",preflight:!0,minify:!1,theme:B,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of J)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||z.shortcuts||{};for(let[A,R]of Object.entries(V)){if(!J.has(A)&&!H.includes(A))continue;let N=R.split(/\s+/).filter(Boolean);for(let M of N)F.generate(M)}O=F.toCSS(!0,!1);let w=O.split(`
8309
8309
  `);for(let[A,R]of Object.entries(V)){if(!J.has(A)&&!H.includes(A))continue;let N=R.split(/\s+/).filter(Boolean),M=[],T=[];for(let I of N){let E=I.startsWith("dark:"),S=`.${(E?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let k=0;k<w.length;k++){let v=w[k].trim();if(v===`${S} {`||v.startsWith(`${S} {`)){let g=k,f="";while(g<w.length){if(f+=w[g],w[g].includes("}"))break;g++}let d=f.match(/\{([^}]+)\}/);if(d)if(E)T.push(d[1].trim());else M.push(d[1].trim());break}}}if(M.length)O+=`
8310
8310
  .${A} { ${M.join(" ")} }`;if(T.length)O+=`
8311
8311
  @media (prefers-color-scheme: dark) { .dark .${A} { ${T.join(" ")} } }`}return g3(G,O),gq(G,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function z$($,Z,Y=!1){let J=await M2($,Z);if(!J)return $;let X=Y?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${vq(J)}.css">`:`<style data-crosswind="generated">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.147",
4
+ "version": "0.2.148",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.14",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.147",
121
- "@stacksjs/sanitizer": "0.2.147",
120
+ "@stacksjs/desktop": "0.2.148",
121
+ "@stacksjs/sanitizer": "0.2.148",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.147",
124
- "bunfig": "^0.15.15",
125
- "stx-router": "0.2.147",
123
+ "bun-plugin-stx": "0.2.148",
124
+ "bunfig": "^0.15.17",
125
+ "stx-router": "0.2.148",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"