@stacksjs/stx 0.2.86 → 0.2.88

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
@@ -880,7 +880,7 @@ ${U}${V}
880
880
  'use strict';
881
881
  ${X}${Y}
882
882
  ${U}
883
- })()</script>`}var Nw,Iw,Dw,kw,Pw,fw;var R6=D(()=>{A0();Nw=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;Iw=["state","derived","effect","batch","untrack","peek","isSignal","isDerived","onMount","onDestroy","useRef","navigate","goBack","goForward","useRoute","setRouteParams","useSearchParams","useFetch","useQuery","useMutation","useOptimistic","useReactiveProp","useLocalStorage","useSessionStorage","useCookie","useWebSocket","useHead","useSeoMeta","definePageMeta","useEventListener","useMeta","useDebounce","useDebouncedValue","useThrottle","useInterval","useTimeout","useToggle","useCounter","useClickOutside","useFocus","useAsync","useColorMode","useDark","ref","reactive","computed","watch","watchEffect","watchMultiple","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","defineProps","withDefaults","defineEmits","defineExpose","defineSlots","provide","inject","nextTick","getCurrentInstance","onErrorCaptured","useSlots","useAttrs","createStore","defineStore","useStore","action","createSelector","h","Fragment"],Dw=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],kw=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);Pw={left:0,middle:1,right:2};fw=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"])});function mw($){let Z="",Y=null,X=!1;for(let J=0;J<$.length;J++){let Q=$[J];if(X){X=!1;continue}if(Q==="\\"&&Y){X=!0;continue}if(Y){if(Y==="`"&&Q==="$"&&J+1<$.length&&$[J+1]==="{"){let G=1;J+=2;while(J<$.length&&G>0){if($[J]==="{")G++;else if($[J]==="}")G--;if(G>0)Z+=$[J],J++}continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}Z+=Q}return Z}function cw($,Z){let Y=/[$A-Z_a-z][$\w]*/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=$[X.index-1];if(dw.has(J))throw Error(`Potentially unsafe expression (matched /\\b${J}\\b/; identifier ${J}): ${Z}`);if(Q==="."&&wU.has(J))throw Error(`Potentially unsafe expression (matched /.${J}/; property ${J}): ${Z}`)}}function lw($){let Z=/\[\s*(['"])(.*?)\1\s*\]/g,Y;while((Y=Z.exec($))!==null){let X=Y[2];if(!wU.has(X))continue;let J=$.slice(0,Y.index).match(/\S(?=\s*$)/)?.[0],Q=$.slice(Y.index+Y[0].length).match(/^\s*(\S)/)?.[1];if(!((J==="{"||J===",")&&Q===":"))throw Error(`Potentially unsafe expression (bracket key ${Y[2]}): ${$}`)}}function N3($){let Z=$.trim(),Y=mw(Z);cw(Y,Z),lw(Z);for(let X of NU)if(X.test(Y))throw Error(`Potentially unsafe expression (matched /${X.source}/): ${Z}`);if(!AU.allowBracketNotation&&uw.test(Z))throw Error(`Bracket notation with strings not allowed: ${Z}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return Z}function pw($){let Z={};Z.Math=Math,Z.JSON=JSON,Z.Date=Date,Z.String=String,Z.Number=Number,Z.Boolean=Boolean,Z.Array=Array,Z.parseInt=Number.parseInt,Z.parseFloat=Number.parseFloat,Z.isNaN=Number.isNaN,Z.isFinite=Number.isFinite,Z.encodeURIComponent=encodeURIComponent,Z.decodeURIComponent=decodeURIComponent;for(let[Y,X]of Object.entries($)){if(Y.startsWith("__")||NU.some((J)=>J.test(Y)))continue;if(X&&typeof X==="object"&&!Array.isArray(X))Z[Y]=rX(X);else Z[Y]=X}return Z}function rX($,Z=0){if(Z>=AU.maxSanitizeDepth)return"[Object too deep]";if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((X)=>rX(X,Z+1));if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error)return $;let Y={};for(let[X,J]of Object.entries($)){if(X.startsWith("__")||X==="constructor"||X==="prototype")continue;if(J&&typeof J==="object")Y[X]=rX(J,Z+1);else Y[X]=J}return Y}function L0($,Z){try{let Y=pw(Z),X=Object.keys(Y),J=Object.values(Y);return w0($,X)(...J)}catch{return}}function N0($){try{return N3($),!0}catch{return!1}}function d0($,Z){try{let Y=L0($,Z);if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Y;return{}}catch{return{}}}function w0($,Z){let Y=N3($),X=/^[A-Za-z_$][\w$]*$/,J=[],Q=[];for(let U=0;U<Z.length;U++){let _=Z[U];if(!X.test(_))continue;if(RU.has(_))continue;J.push(U),Q.push(_)}let G=(U)=>Function(...Q,...U,`
883
+ })()</script>`}var Nw,Iw,Dw,kw,Pw,fw;var R6=D(()=>{N0();Nw=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;Iw=["state","derived","effect","batch","untrack","peek","isSignal","isDerived","onMount","onDestroy","useRef","navigate","goBack","goForward","useRoute","setRouteParams","useSearchParams","useFetch","useQuery","useMutation","useOptimistic","useReactiveProp","useLocalStorage","useSessionStorage","useCookie","useWebSocket","useHead","useSeoMeta","definePageMeta","useEventListener","useMeta","useDebounce","useDebouncedValue","useThrottle","useInterval","useTimeout","useToggle","useCounter","useClickOutside","useFocus","useAsync","useColorMode","useDark","ref","reactive","computed","watch","watchEffect","watchMultiple","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","defineProps","withDefaults","defineEmits","defineExpose","defineSlots","provide","inject","nextTick","getCurrentInstance","onErrorCaptured","useSlots","useAttrs","createStore","defineStore","useStore","action","createSelector","h","Fragment"],Dw=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],kw=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);Pw={left:0,middle:1,right:2};fw=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"])});function mw($){let Z="",Y=null,X=!1;for(let J=0;J<$.length;J++){let Q=$[J];if(X){X=!1;continue}if(Q==="\\"&&Y){X=!0;continue}if(Y){if(Y==="`"&&Q==="$"&&J+1<$.length&&$[J+1]==="{"){let G=1;J+=2;while(J<$.length&&G>0){if($[J]==="{")G++;else if($[J]==="}")G--;if(G>0)Z+=$[J],J++}continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}Z+=Q}return Z}function cw($,Z){let Y=/[$A-Z_a-z][$\w]*/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=$[X.index-1];if(dw.has(J))throw Error(`Potentially unsafe expression (matched /\\b${J}\\b/; identifier ${J}): ${Z}`);if(Q==="."&&wU.has(J))throw Error(`Potentially unsafe expression (matched /.${J}/; property ${J}): ${Z}`)}}function lw($){let Z=/\[\s*(['"])(.*?)\1\s*\]/g,Y;while((Y=Z.exec($))!==null){let X=Y[2];if(!wU.has(X))continue;let J=$.slice(0,Y.index).match(/\S(?=\s*$)/)?.[0],Q=$.slice(Y.index+Y[0].length).match(/^\s*(\S)/)?.[1];if(!((J==="{"||J===",")&&Q===":"))throw Error(`Potentially unsafe expression (bracket key ${Y[2]}): ${$}`)}}function N3($){let Z=$.trim(),Y=mw(Z);cw(Y,Z),lw(Z);for(let X of NU)if(X.test(Y))throw Error(`Potentially unsafe expression (matched /${X.source}/): ${Z}`);if(!AU.allowBracketNotation&&uw.test(Z))throw Error(`Bracket notation with strings not allowed: ${Z}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return Z}function pw($){let Z={};Z.Math=Math,Z.JSON=JSON,Z.Date=Date,Z.String=String,Z.Number=Number,Z.Boolean=Boolean,Z.Array=Array,Z.parseInt=Number.parseInt,Z.parseFloat=Number.parseFloat,Z.isNaN=Number.isNaN,Z.isFinite=Number.isFinite,Z.encodeURIComponent=encodeURIComponent,Z.decodeURIComponent=decodeURIComponent;for(let[Y,X]of Object.entries($)){if(Y.startsWith("__")||NU.some((J)=>J.test(Y)))continue;if(X&&typeof X==="object"&&!Array.isArray(X))Z[Y]=rX(X);else Z[Y]=X}return Z}function rX($,Z=0){if(Z>=AU.maxSanitizeDepth)return"[Object too deep]";if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((X)=>rX(X,Z+1));if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error)return $;let Y={};for(let[X,J]of Object.entries($)){if(X.startsWith("__")||X==="constructor"||X==="prototype")continue;if(J&&typeof J==="object")Y[X]=rX(J,Z+1);else Y[X]=J}return Y}function L0($,Z){try{let Y=pw(Z),X=Object.keys(Y),J=Object.values(Y);return R0($,X)(...J)}catch{return}}function w0($){try{return N3($),!0}catch{return!1}}function d0($,Z){try{let Y=L0($,Z);if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Y;return{}}catch{return{}}}function R0($,Z){let Y=N3($),X=/^[A-Za-z_$][\w$]*$/,J=[],Q=[];for(let U=0;U<Z.length;U++){let _=Z[U];if(!X.test(_))continue;if(RU.has(_))continue;J.push(U),Q.push(_)}let G=(U)=>Function(...Q,...U,`
884
884
  'use strict';
885
885
  try {
886
886
  return ${Y};
@@ -891,7 +891,7 @@ catch (e) {
891
891
  }
892
892
  throw e;
893
893
  }
894
- `),K=G([]);if(Q.length===Z.length)return FU(K,Q,G);return FU((...U)=>{let _=Array(J.length);for(let z=0;z<J.length;z++)_[z]=U[J[z]];return K(..._)},Q,G,(U)=>{K=G(U)})}function FU($,Z,Y,X){let Q=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...U)=>{for(let _=0;_<=8;_++)try{return G(...U)}catch(z){let B=z instanceof Error?z.message:"",q=Q.exec(B);if(!(z instanceof ReferenceError)||!q)return;let j=q[1];if(W.has(j)||RU.has(j))return;W.add(j),K.push(j),G=Y(K),X?.(K)}return}}function w3($){let Z=$.trim(),Y=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let X of Y)if(X.test(Z))return!1;return!0}var hw,AU,NU,dw,wU,uw,RU;var p0=D(()=>{hw={maxSanitizeDepth:10,allowBracketNotation:!1},AU={...hw},NU=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],dw=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),wU=new Set(["__proto__","constructor","prototype"]),uw=/[\w)\]]\s*\[\s*['"]/;RU=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});function aX(){MU=0,R3.clear()}function d5($,Z){let Y=MU++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return R3.set(X,{type:$,expression:Z}),X}function sX(){let $={};for(let[Z,Y]of R3)$[Z]={type:Y.type,expression:Y.expression};return $}function iw($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=R3.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function M3($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function X$($){return $.includes("<!--__STX_")}var MU=0,R3;var u5=D(()=>{R3=new Map});function TU($,Z,Y,X){Y.lastIndex=Z;let J=Y.exec($);if(!J||J.index!==Z)return-1;X.lastIndex=Y.lastIndex;let Q=X.exec($);if(!Q)return-1;return Q.index+Q[0].length}function T3($,Z){return TU($,Z,nw,rw)}function EU($,Z){return TU($,Z,aw,sw)}function IU($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function m5($,Z,Y){let X=[],J="",Q=0,G=$.length,K=!1,W=null;while(Q<G){let U=$[Q];if(K){if(J+=U,W){if(U===W)W=null}else if(U==='"'||U==="'")W=U;else if(U===">")K=!1;Q++;continue}if(U==="<"){let _=Z($,Q);if(_>Q){J+=Y($.slice(Q,_),X.length),X.push($.slice(Q,_)),Q=_;continue}if(/^<\/?[a-zA-Z]/.test($.slice(Q,Q+2)))K=!0;J+=U,Q++;continue}J+=U,Q++}return{output:J,tokens:X}}function oX($){let{output:Z,tokens:Y}=m5($,T3,(X,J)=>`\x00STX_SCRIPT_${J}\x00`);return{output:Z,scripts:Y}}function tX($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,X)=>Z[+X]??"")}var nw,rw,aw,sw;var E3=D(()=>{nw=/<script\b[^>]*>/iy,rw=/<\/script\s*>/ig,aw=/<style\b[^>]*>/iy,sw=/<\/style\s*>/ig});var l5={};e(l5,{usesSignalsInScript:()=>M6,unescapeHtml:()=>I3,registerFilters:()=>SU,registerFilter:()=>eX,processExpressions:()=>j1,interpolateScriptsInTemplate:()=>bU,interpolateScriptExpressions:()=>ZJ,getAllFilters:()=>$J,evaluateExpression:()=>X1,escapeHtml:()=>P0,defaultFilters:()=>J$,clearCustomFilters:()=>CU,applyFilters:()=>YJ});function ow($){let Z=DU.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),DU.set($,Z)}return Z.lastIndex=0,Z}function eX($,Z){if($ in J$)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);c5[$]=Z}function SU($){for(let[Z,Y]of Object.entries($))eX(Z,Y)}function $J(){return{...J$,...c5}}function CU(){for(let $ of Object.keys(c5))delete c5[$]}function P0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function M6($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function kU($,Z){let Y=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],X=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),J="",Q=!1,G=0;for(let U=0;U<X.length;U++){let _=X[U];if(!Q&&_==="`"){Q=!0,G=0;continue}if(Q){if(_==="`"&&G===0){Q=!1;continue}if(_==="$"&&X[U+1]==="{"){G++,U++;continue}if(_==="}"&&G>0){G--;continue}continue}J+=_}X=J;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,W;while((W=K.exec(X))!==null){let U=W[1];if(!X.substring(0,W.index).trimEnd().endsWith(".")){if(!Y.includes(U)&&!(U in Z))return!1}}return!0}function ZJ($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=X1(J,Z);if(Q===void 0)return X;return Q===null?"":String(Q)}catch{return X}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return X;try{let G=X1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function bU($,Z,Y={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(X,J,Q)=>{if(/\bsrc\s*=/.test(J))return X;if(/\bdata-raw\b/.test(J))return X;if(/\btype\s*=\s*["']application\/json["']/.test(J))return X;if(Y.skipServer&&/\bserver\b/.test(J))return X;let G=ZJ(Q,Z);return`<script${J}>${G}</script>`})}function j1($,Z,Y,X){let J=$,Q=(_,z)=>{let B=EU(_,z);if(B===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(_.slice(z,B))?-1:B},G=(_,z,B,q)=>{let j=B.length,{output:H,tokens:O}=m5(_,z,(V,L)=>q(j+L));return B.push(...O),H},K=[];J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`);let W=[];J=G(J,T3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`);let U=X?.forceSignals===!0||M6($);J=J.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(_,z,B)=>{try{let q=X1(z,Z);return q!==void 0&&q!==null?String(q):""}catch(q){let j=q instanceof Error?q.message:String(q);return R0("Expression",`Error evaluating: {{{ ${z.trim()}}}}: ${j}`,Y,$,B,_)}}),J=J.replace(/\{!!([\s\S]*?)!!\}/g,(_,z,B)=>{try{let q=X1(z,Z);if(q===void 0&&Z.__stx_buildMode==="compile")return d5("raw",z.trim());return q!==void 0&&q!==null?String(q):""}catch(q){if(Z.__stx_buildMode==="compile")return d5("raw",z.trim());let j=q instanceof Error?q.message:String(q);return R0("Expression",`Error evaluating: {!! ${z.trim()} !!}: ${j}`,Y,$,B,_)}}),J=G(J,T3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`),J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`),J=J.replace(/\{\{([\s\S]*?)\}\}/g,(_,z,B)=>{let q=z.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,V=q.match(H)?.[1],L=V&&((V in Z)||j.includes(V)),F=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=q.match(F),N=A&&!j.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(q))return"";try{let w=X1(z,Z);if(w===void 0&&U&&!kU(q,Z))return _;if(w===void 0&&Z.__stx_buildMode==="compile"&&!U)return d5("expr",q);return w!==void 0&&w!==null?P0(String(w)):""}catch(w){if(U&&!kU(q,Z))return _;if(N)return _;let R=w instanceof Error?w.message:String(w);return R0("Expression",`Error evaluating: {{ ${q} }}: ${R}`,Y,$,B,_)}});for(let _=0;_<W.length;_++)J=J.replace(`<!--__STX_SCRIPT_EXPR_${_}__-->`,()=>W[_]);for(let _=0;_<K.length;_++)J=J.replace(`<!--__STX_STYLE_${_}__-->`,()=>K[_]);return J}function YJ($,Z,Y){if(!Z.trim())return $;let X=$,J=Z.trim();while(J.length>0){let Q=J.match(/^(\w+)/);if(!Q)break;let G=Q[1];J=J.substring(G.length).trim();let K=c5[G]||J$[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys($J()).join(", ")}`);let W=[];if(J.startsWith(":")){let U=J.match(/^:([^|\s]+)/);if(U){let _=U[1].trim();try{let z=Number(_);W=[Number.isNaN(z)?_:z]}catch{W=[_]}J=J.substring(U[0].length).trim()}}else if(J.startsWith("(")){let U=1,_=1;while(U>0&&_<J.length){if(J[_]==="(")U++;if(J[_]===")")U--;_++}if(U===0){let z=J.substring(1,_-1).trim();if(z)try{if(z.startsWith("{")&&z.endsWith("}"))W=[X1(`(${z})`,Y,!0)];else{let B=[],q="",j=null,H=0,O=0,V=0,L=!1;for(let F=0;F<z.length;F++){let A=z[F];if(L){q+=A,L=!1;continue}if(A==="\\"){q+=A,L=!0;continue}if(j){if(q+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,q+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")O++;else if(A==="]")O--;else if(A==="{")V++;else if(A==="}")V--;if(A===","&&H===0&&O===0&&V===0){B.push(q),q="";continue}q+=A}if(q)B.push(q);W=B.map((F)=>{let A=F.trim();return X1(A,Y,!0)})}}catch{W=[z]}J=J.substring(_).trim()}}try{X=K(X,Y,...W)}catch(U){let _=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${_}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function tw($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let _=1;K+=2;while(K<$.length&&_>0){if($[K]==="{")_++;else if($[K]==="}")_--;if(_>0)K++}continue}if(Z)continue;if(W==="(")X++;else if(W===")")X--;else if(W==="[")J++;else if(W==="]")J--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&X===0&&J===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function X1($,Z,Y=!1){try{let X=$.trim(),J=tw(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=X1(Q,Z,!0);return YJ(K,G,Z)}if(!N0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return L0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return w0(X,Q)(...G)}catch{return L0(X,Z)}}catch(X){if(X instanceof ReferenceError){let J=/(\b\w+)\s+is not defined/.exec(X.message);if(J){let Q=J[1],G=ew(Q,Object.keys(Z));if(G&&G!==Q)X.message=`${X.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,X);throw X}}function ew($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=$R($,J);if(Y===null||Q<Y.dist)Y={key:J,dist:Q}}if(!Y)return null;let X=Math.max($.length,Y.key.length);if(Y.dist<=2||Y.dist/X<=0.35)return Y.key;return null}function $R($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[Y,X]=$.length<Z.length?[$,Z]:[Z,$],J=Array(Y.length+1),Q=Array(Y.length+1);for(let G=0;G<=Y.length;G++)J[G]=G;for(let G=1;G<=X.length;G++){Q[0]=G;for(let K=1;K<=Y.length;K++){let W=Y[K-1]===X[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,J[K]+1,J[K-1]+W)}for(let K=0;K<=Y.length;K++)J[K]=Q[K]}return J[Y.length]}function I3($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var c5,DU,J$;var o0=D(()=>{p0();A0();u5();E3();c5={},DU=new Map;J$={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let X=Number($);return Number.isNaN(X)?"":X.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return X.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return P0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let X=Z.__translations,J=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=X;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(ow(W),String(U))}),K},t:($,Z,Y={})=>{return J$.translate($,Z,Y)},truncate:($,Z,Y=50,X="...")=>{if($===void 0||$===null)return"";let J=String($);if(J.length<=Y)return J;if(Y<=X.length)return X.substring(0,Y);return J.substring(0,Y-X.length)+X},date:($,Z,Y="short",X="en-US")=>{if($===void 0||$===null)return"";try{let J=$ instanceof Date?$:new Date($);if(Number.isNaN(J.getTime()))return String($);let Q={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(Y==="iso")return J.toISOString();return new Intl.DateTimeFormat(X,Q[Y]||Q.short).format(J)}catch{return String($)}},currency:($,Z,Y="USD",X="en-US")=>{if($===void 0||$===null)return"";try{let J=Number($);if(Number.isNaN(J))return String($);return new Intl.NumberFormat(X,{style:"currency",currency:Y}).format(J)}catch{return String($)}},pluralize:($,Z,Y,X)=>{let J=Number($);if(Number.isNaN(J))return Y;let Q=X||`${Y}s`;return J===1?Y:Q},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let Y=String($);return Y.charAt(Y.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,Y=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return Y?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,Y="")=>{return $===void 0||$===null||$===""?Y:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,Y=0,X)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(Y,X);return $},replace:($,Z,Y,X="")=>{if($===void 0||$===null)return"";let J=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(J,"g"),()=>X)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let Y=Number($);return Number.isNaN(Y)?0:Math.abs(Y)},round:($,Z,Y=0)=>{let X=Number($);if(Number.isNaN(X))return 0;let J=10**Y;return Math.round(X*J)/J}}});class p5{cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let Y=this.cache.keys().next().value;if(Y!==void 0)this.cache.delete(Y)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function G$($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!Q$.has(Y)){if(Q$.size>=ZR){let X=Q$.keys().next().value;if(X)Q$.delete(X)}Q$.set(Y,new RegExp($,Z))}return Q$.get(Y)}class PU{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),X=this.pool.find((K)=>K.context.join(",")===Y);if(X)return X.func;let J=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,_=J.get(U);if(!_){if(J.size>=Q){let z=J.keys().next().value;if(z)J.delete(z)}_=Function(...Z,`
894
+ `),K=G([]);if(Q.length===Z.length)return FU(K,Q,G);return FU((...U)=>{let _=Array(J.length);for(let z=0;z<J.length;z++)_[z]=U[J[z]];return K(..._)},Q,G,(U)=>{K=G(U)})}function FU($,Z,Y,X){let Q=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...U)=>{for(let _=0;_<=8;_++)try{return G(...U)}catch(z){let B=z instanceof Error?z.message:"",q=Q.exec(B);if(!(z instanceof ReferenceError)||!q)return;let j=q[1];if(W.has(j)||RU.has(j))return;W.add(j),K.push(j),G=Y(K),X?.(K)}return}}function w3($){let Z=$.trim(),Y=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let X of Y)if(X.test(Z))return!1;return!0}var hw,AU,NU,dw,wU,uw,RU;var p0=D(()=>{hw={maxSanitizeDepth:10,allowBracketNotation:!1},AU={...hw},NU=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],dw=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),wU=new Set(["__proto__","constructor","prototype"]),uw=/[\w)\]]\s*\[\s*['"]/;RU=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});function aX(){MU=0,R3.clear()}function d5($,Z){let Y=MU++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return R3.set(X,{type:$,expression:Z}),X}function sX(){let $={};for(let[Z,Y]of R3)$[Z]={type:Y.type,expression:Y.expression};return $}function iw($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=R3.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function M3($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function X$($){return $.includes("<!--__STX_")}var MU=0,R3;var u5=D(()=>{R3=new Map});function TU($,Z,Y,X){Y.lastIndex=Z;let J=Y.exec($);if(!J||J.index!==Z)return-1;X.lastIndex=Y.lastIndex;let Q=X.exec($);if(!Q)return-1;return Q.index+Q[0].length}function T3($,Z){return TU($,Z,nw,rw)}function EU($,Z){return TU($,Z,aw,sw)}function IU($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function m5($,Z,Y){let X=[],J="",Q=0,G=$.length,K=!1,W=null;while(Q<G){let U=$[Q];if(K){if(J+=U,W){if(U===W)W=null}else if(U==='"'||U==="'")W=U;else if(U===">")K=!1;Q++;continue}if(U==="<"){let _=Z($,Q);if(_>Q){J+=Y($.slice(Q,_),X.length),X.push($.slice(Q,_)),Q=_;continue}if(/^<\/?[a-zA-Z]/.test($.slice(Q,Q+2)))K=!0;J+=U,Q++;continue}J+=U,Q++}return{output:J,tokens:X}}function oX($){let{output:Z,tokens:Y}=m5($,T3,(X,J)=>`\x00STX_SCRIPT_${J}\x00`);return{output:Z,scripts:Y}}function tX($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,X)=>Z[+X]??"")}var nw,rw,aw,sw;var E3=D(()=>{nw=/<script\b[^>]*>/iy,rw=/<\/script\s*>/ig,aw=/<style\b[^>]*>/iy,sw=/<\/style\s*>/ig});var l5={};e(l5,{usesSignalsInScript:()=>M6,unescapeHtml:()=>I3,registerFilters:()=>SU,registerFilter:()=>eX,processExpressions:()=>j1,interpolateScriptsInTemplate:()=>bU,interpolateScriptExpressions:()=>ZJ,getAllFilters:()=>$J,evaluateExpression:()=>X1,escapeHtml:()=>P0,defaultFilters:()=>J$,clearCustomFilters:()=>CU,applyFilters:()=>YJ});function ow($){let Z=DU.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),DU.set($,Z)}return Z.lastIndex=0,Z}function eX($,Z){if($ in J$)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);c5[$]=Z}function SU($){for(let[Z,Y]of Object.entries($))eX(Z,Y)}function $J(){return{...J$,...c5}}function CU(){for(let $ of Object.keys(c5))delete c5[$]}function P0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function M6($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function kU($,Z){let Y=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],X=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),J="",Q=!1,G=0;for(let U=0;U<X.length;U++){let _=X[U];if(!Q&&_==="`"){Q=!0,G=0;continue}if(Q){if(_==="`"&&G===0){Q=!1;continue}if(_==="$"&&X[U+1]==="{"){G++,U++;continue}if(_==="}"&&G>0){G--;continue}continue}J+=_}X=J;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,W;while((W=K.exec(X))!==null){let U=W[1];if(!X.substring(0,W.index).trimEnd().endsWith(".")){if(!Y.includes(U)&&!(U in Z))return!1}}return!0}function ZJ($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=X1(J,Z);if(Q===void 0)return X;return Q===null?"":String(Q)}catch{return X}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return X;try{let G=X1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function bU($,Z,Y={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(X,J,Q)=>{if(/\bsrc\s*=/.test(J))return X;if(/\bdata-raw\b/.test(J))return X;if(/\btype\s*=\s*["']application\/json["']/.test(J))return X;if(Y.skipServer&&/\bserver\b/.test(J))return X;let G=ZJ(Q,Z);return`<script${J}>${G}</script>`})}function j1($,Z,Y,X){let J=$,Q=(_,z)=>{let B=EU(_,z);if(B===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(_.slice(z,B))?-1:B},G=(_,z,B,q)=>{let j=B.length,{output:H,tokens:O}=m5(_,z,(V,L)=>q(j+L));return B.push(...O),H},K=[];J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`);let W=[];J=G(J,T3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`);let U=X?.forceSignals===!0||M6($);J=J.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(_,z,B)=>{try{let q=X1(z,Z);return q!==void 0&&q!==null?String(q):""}catch(q){let j=q instanceof Error?q.message:String(q);return M0("Expression",`Error evaluating: {{{ ${z.trim()}}}}: ${j}`,Y,$,B,_)}}),J=J.replace(/\{!!([\s\S]*?)!!\}/g,(_,z,B)=>{try{let q=X1(z,Z);if(q===void 0&&Z.__stx_buildMode==="compile")return d5("raw",z.trim());return q!==void 0&&q!==null?String(q):""}catch(q){if(Z.__stx_buildMode==="compile")return d5("raw",z.trim());let j=q instanceof Error?q.message:String(q);return M0("Expression",`Error evaluating: {!! ${z.trim()} !!}: ${j}`,Y,$,B,_)}}),J=G(J,T3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`),J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`),J=J.replace(/\{\{([\s\S]*?)\}\}/g,(_,z,B)=>{let q=z.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,V=q.match(H)?.[1],L=V&&((V in Z)||j.includes(V)),F=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=q.match(F),N=A&&!j.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(q))return"";try{let w=X1(z,Z);if(w===void 0&&U&&!kU(q,Z))return _;if(w===void 0&&Z.__stx_buildMode==="compile"&&!U)return d5("expr",q);return w!==void 0&&w!==null?P0(String(w)):""}catch(w){if(U&&!kU(q,Z))return _;if(N)return _;let R=w instanceof Error?w.message:String(w);return M0("Expression",`Error evaluating: {{ ${q} }}: ${R}`,Y,$,B,_)}});for(let _=0;_<W.length;_++)J=J.replace(`<!--__STX_SCRIPT_EXPR_${_}__-->`,()=>W[_]);for(let _=0;_<K.length;_++)J=J.replace(`<!--__STX_STYLE_${_}__-->`,()=>K[_]);return J}function YJ($,Z,Y){if(!Z.trim())return $;let X=$,J=Z.trim();while(J.length>0){let Q=J.match(/^(\w+)/);if(!Q)break;let G=Q[1];J=J.substring(G.length).trim();let K=c5[G]||J$[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys($J()).join(", ")}`);let W=[];if(J.startsWith(":")){let U=J.match(/^:([^|\s]+)/);if(U){let _=U[1].trim();try{let z=Number(_);W=[Number.isNaN(z)?_:z]}catch{W=[_]}J=J.substring(U[0].length).trim()}}else if(J.startsWith("(")){let U=1,_=1;while(U>0&&_<J.length){if(J[_]==="(")U++;if(J[_]===")")U--;_++}if(U===0){let z=J.substring(1,_-1).trim();if(z)try{if(z.startsWith("{")&&z.endsWith("}"))W=[X1(`(${z})`,Y,!0)];else{let B=[],q="",j=null,H=0,O=0,V=0,L=!1;for(let F=0;F<z.length;F++){let A=z[F];if(L){q+=A,L=!1;continue}if(A==="\\"){q+=A,L=!0;continue}if(j){if(q+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,q+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")O++;else if(A==="]")O--;else if(A==="{")V++;else if(A==="}")V--;if(A===","&&H===0&&O===0&&V===0){B.push(q),q="";continue}q+=A}if(q)B.push(q);W=B.map((F)=>{let A=F.trim();return X1(A,Y,!0)})}}catch{W=[z]}J=J.substring(_).trim()}}try{X=K(X,Y,...W)}catch(U){let _=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${_}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function tw($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let _=1;K+=2;while(K<$.length&&_>0){if($[K]==="{")_++;else if($[K]==="}")_--;if(_>0)K++}continue}if(Z)continue;if(W==="(")X++;else if(W===")")X--;else if(W==="[")J++;else if(W==="]")J--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&X===0&&J===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function X1($,Z,Y=!1){try{let X=$.trim(),J=tw(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=X1(Q,Z,!0);return YJ(K,G,Z)}if(!w0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return L0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return R0(X,Q)(...G)}catch{return L0(X,Z)}}catch(X){if(X instanceof ReferenceError){let J=/(\b\w+)\s+is not defined/.exec(X.message);if(J){let Q=J[1],G=ew(Q,Object.keys(Z));if(G&&G!==Q)X.message=`${X.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,X);throw X}}function ew($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=$R($,J);if(Y===null||Q<Y.dist)Y={key:J,dist:Q}}if(!Y)return null;let X=Math.max($.length,Y.key.length);if(Y.dist<=2||Y.dist/X<=0.35)return Y.key;return null}function $R($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[Y,X]=$.length<Z.length?[$,Z]:[Z,$],J=Array(Y.length+1),Q=Array(Y.length+1);for(let G=0;G<=Y.length;G++)J[G]=G;for(let G=1;G<=X.length;G++){Q[0]=G;for(let K=1;K<=Y.length;K++){let W=Y[K-1]===X[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,J[K]+1,J[K-1]+W)}for(let K=0;K<=Y.length;K++)J[K]=Q[K]}return J[Y.length]}function I3($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var c5,DU,J$;var o0=D(()=>{p0();N0();u5();E3();c5={},DU=new Map;J$={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let X=Number($);return Number.isNaN(X)?"":X.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return X.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return P0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let X=Z.__translations,J=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=X;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(ow(W),String(U))}),K},t:($,Z,Y={})=>{return J$.translate($,Z,Y)},truncate:($,Z,Y=50,X="...")=>{if($===void 0||$===null)return"";let J=String($);if(J.length<=Y)return J;if(Y<=X.length)return X.substring(0,Y);return J.substring(0,Y-X.length)+X},date:($,Z,Y="short",X="en-US")=>{if($===void 0||$===null)return"";try{let J=$ instanceof Date?$:new Date($);if(Number.isNaN(J.getTime()))return String($);let Q={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(Y==="iso")return J.toISOString();return new Intl.DateTimeFormat(X,Q[Y]||Q.short).format(J)}catch{return String($)}},currency:($,Z,Y="USD",X="en-US")=>{if($===void 0||$===null)return"";try{let J=Number($);if(Number.isNaN(J))return String($);return new Intl.NumberFormat(X,{style:"currency",currency:Y}).format(J)}catch{return String($)}},pluralize:($,Z,Y,X)=>{let J=Number($);if(Number.isNaN(J))return Y;let Q=X||`${Y}s`;return J===1?Y:Q},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let Y=String($);return Y.charAt(Y.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,Y=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return Y?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,Y="")=>{return $===void 0||$===null||$===""?Y:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,Y=0,X)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(Y,X);return $},replace:($,Z,Y,X="")=>{if($===void 0||$===null)return"";let J=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(J,"g"),()=>X)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let Y=Number($);return Number.isNaN(Y)?0:Math.abs(Y)},round:($,Z,Y=0)=>{let X=Number($);if(Number.isNaN(X))return 0;let J=10**Y;return Math.round(X*J)/J}}});class p5{cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let Y=this.cache.keys().next().value;if(Y!==void 0)this.cache.delete(Y)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function G$($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!Q$.has(Y)){if(Q$.size>=ZR){let X=Q$.keys().next().value;if(X)Q$.delete(X)}Q$.set(Y,new RegExp($,Z))}return Q$.get(Y)}class PU{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),X=this.pool.find((K)=>K.context.join(",")===Y);if(X)return X.func;let J=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,_=J.get(U);if(!_){if(J.size>=Q){let z=J.keys().next().value;if(z)J.delete(z)}_=Function(...Z,`
895
895
  'use strict';
896
896
  try {
897
897
  return ${W};
@@ -1794,7 +1794,7 @@ window.__stx_reactive = (function() {
1794
1794
  ${kR()}
1795
1795
  ${Y}
1796
1796
  </script>`}function oU($,Z,Y){if(sU=0,!bR($))return $;let X=TR($);if(X.length===0)return $;let J=CR($,X),Q=SR(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
1797
- `+J.slice(G);else J+=Q;return J}function CR($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${y3(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${y3(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${y3(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${y3(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function bR($){return/x-data\s*=\s*["']/.test($)}var sU=0,MR=0;var tU=D(()=>{o0()});function _4($,Z){try{let Y=$.trim();if(N0(Y))return w0(Y,Object.keys(Z))(...Object.values(Z));else return L0(Y,Z)}catch{return!1}}var LJ=D(()=>{p0()});function $_($){eU=$}function Z_(){return eU}function Y_($){x3={...x3,...$}}function X_(){x3={}}function VJ($,Z={}){let Y=x3[$]||PR[$]||{message:`Unknown error (code: ${$})`},X=Y.message,J=Y.help;for(let[Q,G]of Object.entries(Z)){let K=`{{${Q}}}`;if(X=X.replace(new RegExp(K,"g"),G),J)J=J.replace(new RegExp(K,"g"),G)}return{message:X,help:J}}function J_($,Z={}){let{message:Y,help:X}=VJ($,Z);return X?`${Y}
1797
+ `+J.slice(G);else J+=Q;return J}function CR($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${y3(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${y3(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${y3(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${y3(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function bR($){return/x-data\s*=\s*["']/.test($)}var sU=0,MR=0;var tU=D(()=>{o0()});function _4($,Z){try{let Y=$.trim();if(w0(Y))return R0(Y,Object.keys(Z))(...Object.values(Z));else return L0(Y,Z)}catch{return!1}}var LJ=D(()=>{p0()});function $_($){eU=$}function Z_(){return eU}function Y_($){x3={...x3,...$}}function X_(){x3={}}function VJ($,Z={}){let Y=x3[$]||PR[$]||{message:`Unknown error (code: ${$})`},X=Y.message,J=Y.help;for(let[Q,G]of Object.entries(Z)){let K=`{{${Q}}}`;if(X=X.replace(new RegExp(K,"g"),G),J)J=J.replace(new RegExp(K,"g"),G)}return{message:X,help:J}}function J_($,Z={}){let{message:Y,help:X}=VJ($,Z);return X?`${Y}
1798
1798
  Help: ${X}`:Y}function v3($){for(let[Z,Y]of Object.entries(J0))if(Y===$)return Z;return}var PR,x3,eU="en",J0;var f3=D(()=>{PR={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},x3={};J0={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function _$(){return!1}function f4(){return!_$()||process.env.STX_DEBUG==="true"}function a5(){return!1}import yR from"path";function G_($){z$={...z$,...$}}function s5(){return{...z$}}function K_(){z$={...Q_}}function o5($){if(!z$.showRelativePaths||!$)return $;let Z=z$.baseDir||process.cwd();try{let Y=yR.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var Q_,z$,g4,FJ,h1,AJ,B$,t5;var g3=D(()=>{f3();Q_={showRelativePaths:!1,enableAutoRecovery:f4(),logRecoveryWarnings:!0},z$={...Q_};g4=class g4 extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,Y,X,J,Q,G){super($);this.code=Z;this.filePath=Y;this.line=X;this.column=J;this.context=Q;if(this.name="StxError",this.numericCode=G||J0.EVALUATION_ERROR,this.filePath)this.filePath=o5(this.filePath)}};FJ=class FJ extends g4{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||J0.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};h1=class h1 extends g4{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||J0.EVALUATION_ERROR);this.name="StxRuntimeError"}};AJ=class AJ extends g4{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||J0.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};B$=class B$ extends g4{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||J0.FILE_NOT_FOUND);this.name="StxFileError"}};t5=class t5 extends g4{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||J0.DOM_API_VIOLATION);this.name="StxValidationError"}}});function h3($){let{type:Z,message:Y,code:X,filePath:J,line:Q,column:G,template:K,offset:W,snippet:U,suggestion:_,format:z="text"}=$,B=Q,q=G;if(!B&&K&&W!==void 0){let L=U_(K,W);B=L.line,q=L.column}let j=J?o5(J):void 0,H=X?v3(X):void 0,O={type:Z,code:X,codeName:H,message:Y,filePath:j,line:B,column:q,snippet:U,suggestion:_,timestamp:new Date().toISOString()},V;switch(z){case"html":V=vR(O);break;case"json":V=JSON.stringify(O,null,2);break;case"console":V=fR(O,K,W);break;case"text":default:V=xR(O,K,W);break}return{formatted:V,data:O}}function xR($,Z,Y){let X=[],J=$.code?` [${$.codeName||$.code}]`:"";if(X.push(`[${$.type} Error${J}]`),$.filePath){let Q=$.filePath;if($.line){if(Q+=`:${$.line}`,$.column)Q+=`:${$.column}`}X.push(`at ${Q}`)}if(X.push(`
1799
1799
  ${$.message}`),Z&&$.line){let Q=gR(Z,$.line,2);if(Q)X.push(`
1800
1800
  ${Q}`)}if($.snippet)X.push(`
@@ -1829,12 +1829,12 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
1829
1829
  @end${K}`;X.push(`Added ${_} missing @end${K}`)}}if(X.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),X.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:X}},createFallbackContent($,Z){if(f4())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};J1=new u3,q$={isDevelopment(){return f4()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
1830
1830
  `)}}});import NJ from"path";function dR($){let Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function e5($,Z={}){let{allowHtml:Y=!1,maxLength:X=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],K=$,W=!1;if(Q){let _=Q(K);if(_!==K)K=_,W=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),W=!0,G.push("Null bytes removed from parameter");if(K.length>X)K=K.substring(0,X),W=!0,G.push(`Parameter truncated to ${X} characters`);if(!Y&&/<[^>]+>/.test(K))K=dR(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:_,replacement:z,name:B}of U)if(_.test(K))K=K.replace(_,z),W=!0,G.push(`Removed ${B} from parameter`);if(!J){let _=K;if(K=K.split("").filter((z)=>{let B=z.charCodeAt(0);return B>=32&&B!==127}).join(""),K!==_)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function H_($,Z){let Y=$.replace(/\0/g,"");Y=Y.replace(/\\/g,"/"),Y=Y.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Y.includes("../")||Y.includes("./"))Y=Y.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!m3.isValidFilePath(Y,Z))return null;return Y}function O_($){let Z=[],Y=$.trim(),X=Y!==$,J=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of J)if(Q.test(Y))Z.push(`Potentially dangerous pattern detected: ${G}`);if(Y.includes("\x00"))Y=Y.replace(/\0/g,""),X=!0,Z.push("Null bytes removed from expression");return{value:Y,modified:X,warnings:Z}}function L_($,Z={}){return $.map((Y)=>e5(Y,Z))}function wJ($){let Z={};for(let[Y,X]of Object.entries($)){if(!m3.isValidVariableName(Y))continue;if(typeof X==="string"){let J=e5(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?e5(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=wJ(X);else Z[Y]=X}return Z}var m3;var V_=D(()=>{m3={isValidFilePath($,Z){let Y=$.replace(/\\/g,"/");if(Y.includes("\x00"))return!1;if(Y.includes("../")||Y.includes("..\\")||Y===".."||Y.startsWith("../")||Y.endsWith("/..")||Y.includes("/..\\")||Y.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Y))return!1;if(Y.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>Y===Q.slice(0,-1)||Y.startsWith(Q)))return!1}if(/^[a-z]:/i.test(Y)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>Y.includes(Q)))return!1}if(Z){let J=NJ.resolve(Z,$),Q=NJ.resolve(Z);if(!J.startsWith(Q+NJ.sep)&&J!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Y)=>Y.test($))}}});var F_=D(()=>{f3();q_();j_();V_();g3()});var R1=D(()=>{F_()});class $7{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,Y=this.column,X=this.source[this.pos];if(/\s/.test(X))return this.readWhitespace($,Z,Y);if(X==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(X==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(X==='"'||X==="'")return this.readString(X,$,Z,Y);if(X==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(X)||X==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(X))return this.readIdentifier($,Z,Y);if(X==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(X==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(X==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(X==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(X))return this.advance(),{type:"OPERATOR",value:X,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(X))return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
1831
1831
  `)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readBlockComment($,Z,Y){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readString($,Z,Y,X){this.advance();while(this.pos<this.source.length){let J=this.source[this.pos];if(J==="\\"){this.advance(2);continue}if(J===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:Y,column:X}}readTemplateString($,Z,Y){this.advance();let X=0,J=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(X>=J){this.pos=this.source.length;break}this.advance(2),X++;continue}if(Q==="{"&&X>0){X++,this.advance();continue}if(Q==="}"&&X>0){X--,this.advance();continue}if(Q==="`"&&X===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readNumber($,Z,Y){if(this.source[this.pos]==="0"){let X=this.peek(1)?.toLowerCase();if(X==="x"||X==="o"||X==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readIdentifier($,Z,Y){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readDirective($,Z,Y){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
1832
- `)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function u0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function RJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function c3($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function z4($,Z){let Y=uR($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function uR($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=u0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function h4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,z=U?U.index:1/0;if(_<z)J++,Q=_+W[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function MJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",z=J.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=z4(K,V);if(!L){U++;continue}_="elseif",z=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U}),_="else",z=void 0,U+=5,B=U;continue}}U++}return W.push({type:_,condition:z,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function j$($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=MJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function Z7($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=u0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),z=U+1,B=h4($,Z,Y,z);if(B===-1){Q=J.exec($);continue}let q=$.slice(z,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function l3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,z=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(z++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(z--,_)_.content+=j[0];U+=j[0].length;continue}if(z>0){if(_)_.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,F=z4(K,L);if(!F){U++;continue}_={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var A_=()=>{};function R_($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=mR($,U,W);if(_===-1){Y=G+1;continue}let z=$.slice(U,_).trim(),B=_+W.length;Z.push({fullMatch:$.slice(G,B),expression:z,start:G,end:B,isRaw:Q}),Y=B}return Z}function mR($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function M_($){let Z=c3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=cR(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function cR($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=u0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=TJ(G);return{name:X,args:K}}function TJ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function T_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=u0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function E_($){let Z=[],X=new $7($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,B=N_(X,J,$);J=B.nextIndex,Z.push({type:"variable",name:_,value:$.slice(z,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,z=U.value==="{"?"}":"]",B=u0($,U.value,z,_);if(B!==-1){let q=$.slice(_,B+1);if(J=w_(X,B+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=N_(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let B=u0($,"{","}",z);if(B!==-1)Z.push({type:"function",name:_,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),J=w_(X,B+1)}}}else J++}return Z}function N_($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function w_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var I_=()=>{};var Y7=D(()=>{A_();I_()});function lR($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=l3(X,G);if(!K)break;try{let W;if(N0(K.expression))W=w0(K.expression,Object.keys(Z))(...Object.values(Z));else W=L0(K.expression,Z);let U="",_=!1;for(let z of K.cases)if(z.type==="default"){if(!_)U=z.content.trim()}else try{let B;if(z.value&&N0(z.value))B=w0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)B=L0(z.value,Z);if(W===B){U=z.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("Switch",`Error evaluating @switch expression: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function T6($,Z,Y){let X=$;X=lR(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z4(X,K+7);if(!W)break;let U=W.endPos,_=h4(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,_),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(z))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(z))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(z))!==null)F.push({pos:A.index,type:"else"});F.sort((N,w)=>N.pos-w.pos);for(let N of F)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){q=N.pos;break}}let j;if(q!==-1){let H=z.slice(0,q),O=z.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${z}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=IJ(X,Z,Y),X=DJ(X,Z,Y),X=EJ(X,Z);let J=()=>{let Q=j$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let z;if(_.condition&&N0(_.condition))z=w0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)z=L0(_.condition,Z);if(z)W=_.content,U=!0}catch(z){W=U0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${z instanceof Error?z.message:String(z)}`,J0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("If",`Error processing @if block: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function D_($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function EJ($,Z){let Y=$;function X(K,W,U,_){let z=1,B=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&z>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)z++,B=V+H[0].length;else if(L<1/0){if(z--,z===0)return L;B=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,z=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=z.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+5),q=D_(B);if(q)_=q.value,z=U+5+q.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=_?_4(`auth?.check && auth?.user?.[${_}]`,Z):_4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+6),q=D_(B);if(q)_=q.value,z=U+6+q.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=_?_4(`!auth?.check || !auth?.user?.[${_}]`,Z):_4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let z=_4(U,Z);_.push(z)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let B=z.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],E;while((E=A.exec(V))!==null)T.push({pos:E.index,type:"open"});while((E=N.exec(V))!==null)T.push({pos:E.index,type:"close"});while((E=w.exec(V))!==null)T.push({pos:E.index,type:"elseDirective"});while((E=R.exec(V))!==null)T.push({pos:E.index,type:"else"});T.sort((C,g)=>C.pos-g.pos);for(let C of T){if(C.type==="open"){F++;continue}if(C.type==="close"){F--;continue}if(F===0)L.push(C)}let I=[],k=0;for(let C=0;C<L.length;C++){let g=L[C];if(I.push({content:V.slice(k,g.pos),ability:void 0}),g.type==="elseDirective"){let s=V.slice(g.pos+`@${U}`.length),m=G(s);if(m){I[I.length-1]={content:V.slice(k,g.pos)},k=g.pos+`@${U}`.length+m.paramsEnd,I.push({content:"",ability:m.ability,type:m.type,id:m.id}),I.pop();let b=L[C+1],d=b?b.pos:V.length;I.push({content:V.slice(k,d),ability:m.ability,type:m.type,id:m.id}),k=d}}else k=g.pos+5}if(k<V.length){let C=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(k),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(k)})}let S=Q(j.ability,j.type,j.id),x=K==="can"?S:!S,P="";if(x)P=I[0]?.content||"";else{let C=!1;for(let g=1;g<I.length;g++){let s=I[g];if(s.isFinalElse){P=s.content,C=!0;break}if(s.ability){let m=Q(s.ability,s.type,s.id);if(K==="can"?m:!m){P=s.content,C=!0;break}}}if(!C&&I.length>0){let g=I[I.length-1];if(g.isFinalElse)P=g.content}}Y=Y.substring(0,B)+P+Y.substring(O+`@${W}`.length),_=!0}}return Y}function IJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let z=new RegExp(`@${G}\\s*\\(`),B=Q.match(z);if(!B||B.index===void 0)break;let q=B.index,j=z4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=h4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,N=0;while(N<V.length){let w=V.indexOf("@",N);if(w===-1)break;let R=V.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=w;break}N=w+1}try{let w=W(L.trim()),R;if(F!==-1){let T=V.slice(0,F),E=V.slice(F+5);R=w?T:E}else R=w?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),_=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=U0(U,`Error processing @${G} directive: ${R}`,J0.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=_4(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=_4(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function DJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),z=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let S=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;L+=S[0].length,U=J===S[2]}let F=1,A=L,N=-1;while(F>0&&A<j.length){_.lastIndex=A,z.lastIndex=A;let S=_.exec(j),x=z.exec(j),P=S?S.index:1/0,C=x?x.index:1/0;if(P<C)F++,A=P+S[0].length;else if(C<1/0){if(F--,F===0){N=C;break}A=C+x[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,N),R=-1,T=0,E=0;while(E<w.length){let S=w.indexOf("@",E);if(S===-1)break;let x=w.substring(S);if(B.test(x)){T++,E=S+1;continue}if(q.test(x)){T--,E=S+1;continue}if(T===0&&/^@else(?![a-z])/.test(x)){R=S;break}E=S+1}let I;if(R!==-1){let S=w.slice(0,R),x=w.slice(R+5);I=U?S:x}else I=U?w:"";let k=`@${W}`.length;j=j.substring(0,V)+I+j.substring(N+k),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p3=D(()=>{LJ();R1();Y7();p0()});function SJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function d4($,Z){if(!$)return Z?.nonceGenerator?.()??SJ();let Y=kJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??SJ(),kJ.set($,Y);return Y}function pR($){kJ.delete($)}function CJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function n3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${CJ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function iR($){return{enabled:!0,directives:{strict:k_,moderate:i3,relaxed:S_,api:C_}[$]||i3,useNonce:$==="strict",addMetaTag:!0}}function nR($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function bJ($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?d4(Y,Z):void 0,J=n3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1832
+ `)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function u0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function RJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function c3($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function z4($,Z){let Y=uR($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function uR($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=u0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function h4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,z=U?U.index:1/0;if(_<z)J++,Q=_+W[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function MJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",z=J.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=z4(K,V);if(!L){U++;continue}_="elseif",z=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U}),_="else",z=void 0,U+=5,B=U;continue}}U++}return W.push({type:_,condition:z,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function j$($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=MJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function Z7($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=u0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),z=U+1,B=h4($,Z,Y,z);if(B===-1){Q=J.exec($);continue}let q=$.slice(z,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function l3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=z4($,X);if(!J)return null;let Q=J.endPos,G=h4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,z=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(z++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(z--,_)_.content+=j[0];U+=j[0].length;continue}if(z>0){if(_)_.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,F=z4(K,L);if(!F){U++;continue}_={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var A_=()=>{};function R_($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=mR($,U,W);if(_===-1){Y=G+1;continue}let z=$.slice(U,_).trim(),B=_+W.length;Z.push({fullMatch:$.slice(G,B),expression:z,start:G,end:B,isRaw:Q}),Y=B}return Z}function mR($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function M_($){let Z=c3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=cR(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function cR($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=u0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=TJ(G);return{name:X,args:K}}function TJ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function T_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=u0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function E_($){let Z=[],X=new $7($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,B=N_(X,J,$);J=B.nextIndex,Z.push({type:"variable",name:_,value:$.slice(z,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,z=U.value==="{"?"}":"]",B=u0($,U.value,z,_);if(B!==-1){let q=$.slice(_,B+1);if(J=w_(X,B+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=N_(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let B=u0($,"{","}",z);if(B!==-1)Z.push({type:"function",name:_,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),J=w_(X,B+1)}}}else J++}return Z}function N_($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function w_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var I_=()=>{};var Y7=D(()=>{A_();I_()});function lR($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=l3(X,G);if(!K)break;try{let W;if(w0(K.expression))W=R0(K.expression,Object.keys(Z))(...Object.values(Z));else W=L0(K.expression,Z);let U="",_=!1;for(let z of K.cases)if(z.type==="default"){if(!_)U=z.content.trim()}else try{let B;if(z.value&&w0(z.value))B=R0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)B=L0(z.value,Z);if(W===B){U=z.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("Switch",`Error evaluating @switch expression: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function T6($,Z,Y){let X=$;X=lR(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z4(X,K+7);if(!W)break;let U=W.endPos,_=h4(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,_),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(z))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(z))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(z))!==null)F.push({pos:A.index,type:"else"});F.sort((N,w)=>N.pos-w.pos);for(let N of F)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){q=N.pos;break}}let j;if(q!==-1){let H=z.slice(0,q),O=z.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${z}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=IJ(X,Z,Y),X=DJ(X,Z,Y),X=EJ(X,Z);let J=()=>{let Q=j$(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let z;if(_.condition&&w0(_.condition))z=R0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)z=L0(_.condition,Z);if(z)W=_.content,U=!0}catch(z){W=U0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${z instanceof Error?z.message:String(z)}`,J0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=U0("If",`Error processing @if block: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function D_($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function EJ($,Z){let Y=$;function X(K,W,U,_){let z=1,B=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&z>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)z++,B=V+H[0].length;else if(L<1/0){if(z--,z===0)return L;B=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,z=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=z.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+5),q=D_(B);if(q)_=q.value,z=U+5+q.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=_?_4(`auth?.check && auth?.user?.[${_}]`,Z):_4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+6),q=D_(B);if(q)_=q.value,z=U+6+q.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=_?_4(`!auth?.check || !auth?.user?.[${_}]`,Z):_4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let z=_4(U,Z);_.push(z)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let B=z.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],E;while((E=A.exec(V))!==null)T.push({pos:E.index,type:"open"});while((E=N.exec(V))!==null)T.push({pos:E.index,type:"close"});while((E=w.exec(V))!==null)T.push({pos:E.index,type:"elseDirective"});while((E=R.exec(V))!==null)T.push({pos:E.index,type:"else"});T.sort((C,g)=>C.pos-g.pos);for(let C of T){if(C.type==="open"){F++;continue}if(C.type==="close"){F--;continue}if(F===0)L.push(C)}let I=[],k=0;for(let C=0;C<L.length;C++){let g=L[C];if(I.push({content:V.slice(k,g.pos),ability:void 0}),g.type==="elseDirective"){let s=V.slice(g.pos+`@${U}`.length),m=G(s);if(m){I[I.length-1]={content:V.slice(k,g.pos)},k=g.pos+`@${U}`.length+m.paramsEnd,I.push({content:"",ability:m.ability,type:m.type,id:m.id}),I.pop();let b=L[C+1],d=b?b.pos:V.length;I.push({content:V.slice(k,d),ability:m.ability,type:m.type,id:m.id}),k=d}}else k=g.pos+5}if(k<V.length){let C=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(k),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(k)})}let S=Q(j.ability,j.type,j.id),x=K==="can"?S:!S,P="";if(x)P=I[0]?.content||"";else{let C=!1;for(let g=1;g<I.length;g++){let s=I[g];if(s.isFinalElse){P=s.content,C=!0;break}if(s.ability){let m=Q(s.ability,s.type,s.id);if(K==="can"?m:!m){P=s.content,C=!0;break}}}if(!C&&I.length>0){let g=I[I.length-1];if(g.isFinalElse)P=g.content}}Y=Y.substring(0,B)+P+Y.substring(O+`@${W}`.length),_=!0}}return Y}function IJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let z=new RegExp(`@${G}\\s*\\(`),B=Q.match(z);if(!B||B.index===void 0)break;let q=B.index,j=z4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=h4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,N=0;while(N<V.length){let w=V.indexOf("@",N);if(w===-1)break;let R=V.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=w;break}N=w+1}try{let w=W(L.trim()),R;if(F!==-1){let T=V.slice(0,F),E=V.slice(F+5);R=w?T:E}else R=w?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),_=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=U0(U,`Error processing @${G} directive: ${R}`,J0.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=_4(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=_4(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function DJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),z=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let S=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;L+=S[0].length,U=J===S[2]}let F=1,A=L,N=-1;while(F>0&&A<j.length){_.lastIndex=A,z.lastIndex=A;let S=_.exec(j),x=z.exec(j),P=S?S.index:1/0,C=x?x.index:1/0;if(P<C)F++,A=P+S[0].length;else if(C<1/0){if(F--,F===0){N=C;break}A=C+x[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,N),R=-1,T=0,E=0;while(E<w.length){let S=w.indexOf("@",E);if(S===-1)break;let x=w.substring(S);if(B.test(x)){T++,E=S+1;continue}if(q.test(x)){T--,E=S+1;continue}if(T===0&&/^@else(?![a-z])/.test(x)){R=S;break}E=S+1}let I;if(R!==-1){let S=w.slice(0,R),x=w.slice(R+5);I=U?S:x}else I=U?w:"";let k=`@${W}`.length;j=j.substring(0,V)+I+j.substring(N+k),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p3=D(()=>{LJ();R1();Y7();p0()});function SJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function d4($,Z){if(!$)return Z?.nonceGenerator?.()??SJ();let Y=kJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??SJ(),kJ.set($,Y);return Y}function pR($){kJ.delete($)}function CJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function n3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${CJ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function iR($){return{enabled:!0,directives:{strict:k_,moderate:i3,relaxed:S_,api:C_}[$]||i3,useNonce:$==="strict",addMetaTag:!0}}function nR($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function bJ($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let X=Z.useNonce?d4(Y,Z):void 0,J=n3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1833
1833
  ${J}`)}function rR($,Z){let Y=$;return Y=Y.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<script nonce="${Z}"${J}>`}),Y=Y.replace(/<style([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<style nonce="${Z}"${J}>`}),Y}function PJ($,Z,Y,X){let J=$,Q=X.csp;if(J=J.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?d4(Z,Q):void 0;return n3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return d4(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=d4(Z,Q);return J}function aR(){return[b_,P_]}function sR($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,X]of Object.entries($))if(Array.isArray(X)&&X.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function y_($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function oR($,Z){if(!$.enabled)return{};let Y=$.useNonce?d4(Z,$):void 0,X=CJ($.directives,Y);return{[y_($.reportOnly)]:X}}var kJ,k_,i3,S_,C_,b_,P_,tR;var yJ=D(()=>{kJ=new WeakMap;k_={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},i3={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},S_={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},C_={"default-src":["'none'"],"frame-ancestors":["'none'"]};b_={name:"csp",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?d4(Y,Q):void 0;return n3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},P_={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return d4(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};tR={enabled:!1,reportOnly:!1,directives:i3,useNonce:!1,addMetaTag:!0}});import eR from"crypto";function ZM($=$M){let Z=eR.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return xJ=Z,Z}function YM(){if(!xJ)ZM();return xJ}function XM($=x_){let Z=YM();return`<input type="hidden" name="${$}" value="${Z}">`}function v_($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return XM(X||x_)})}var $M=40,x_="_token",xJ=null;var f_=()=>{};async function vJ($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let J=$;for(let Q of X.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await JM(J,Q,Z,Y,X);else J=await QM(J,Q,Z,Y,X)}return J}async function JM($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=G$(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),z=[],B=_.exec(U);while(B!==null){let[q,j="",H=""]=B,O=B.index||0;try{let V=j?g_(j):[],L=H.trim(),F=await G(L,V,Y,X);z.push({original:q,processed:F,startIndex:O})}catch(V){let L=V instanceof Error?V.message:String(V);if(J.debug)console.error(`Error processing custom directive @${Q}:`,V);z.push({original:q,processed:U0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,J0.EVALUATION_ERROR),startIndex:O})}B=_.exec(U)}for(let q=z.length-1;q>=0;q--){let{original:j,processed:H}=z[q];U=U.replace(j,H)}return U}async function QM($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=G$(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let O=g_(j),V=await G("",O,Y,X);U.push({original:q,processed:V,startIndex:H})}catch(O){let V=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:U0("CustomDirective",`Error in @${Q}(${j}): ${V}`,J0.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let z=G$(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),B=z.exec(K);while(B!==null){let[q]=B,j=B.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:U0("CustomDirective",`Error in @${Q}: ${O}`,J0.EVALUATION_ERROR),startIndex:j})}B=z.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function g_($){if(!$.trim())return[];let Z=[],Y="",X=!1,J="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!X)X=!0,J=G;else if(G===J)X=!1;else Y+=G;else if(G===","&&!X)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var fJ=D(()=>{R1();x4()});var s3={};e(s3,{useTitle:()=>u_,useSeoMeta:()=>X7,usePageTitle:()=>u_,useHead:()=>m4,resetHead:()=>h_,renderHtmlAttrs:()=>c_,renderHead:()=>m_,renderBodyAttrs:()=>l_,processTitleDirective:()=>n_,processMetaDirective:()=>r_,processHeadDirective:()=>i_,getPageMeta:()=>a3,getHead:()=>H$,definePageMeta:()=>d_,applyHead:()=>p_});function H$(){return u4}function a3(){return r3}function h_(){u4={},GM.length=0,r3={}}function m4($){u4=KM(u4,$)}function KM($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function X7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});m4({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function d_($){if(r3={...r3,...$},$.title||$.description)X7({title:$.title,description:$.description})}function u_($){let Z=typeof $==="function"?$():$;m4({title:Z})}function m_($=u4){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${E6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${E6(J)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>{return`${J==="httpEquiv"?"http-equiv":J}="${E6(String(Q))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>`${J}="${E6(String(Q))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...J}=Y,Q=Object.entries(J).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${E6(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
1834
1834
  `)}function c_($=u4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${E6(Y)}"`).join(" ")}function l_($=u4){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${E6(Y)}"`).join(" ")}function E6($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function p_($=u4){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let X=document.querySelector(Y);if(!X){if(X=document.createElement("meta"),Z.name)X.setAttribute("name",Z.name);if(Z.property)X.setAttribute("property",Z.property);document.head.appendChild(X)}X.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,X=document.querySelector(Y);if(!X)X=document.createElement("link"),document.head.appendChild(X);for(let[J,Q]of Object.entries(Z))if(Q!==void 0)X.setAttribute(J,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function i_($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
1835
1835
  `,""}),headContent:Z.trim()}}function n_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return m4({title:G}),""})}function r_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,z=J.includes(":")?{property:J,content:U}:{name:J,content:U};return m4({meta:[z]}),""})}var u4,GM,r3;var c4=D(()=>{u4={},GM=[],r3={}});import WM from"crypto";function t0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function UM($){return{...t3,...$.forms?.classes}}function o3($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function _M(){return WM.randomUUID()}function zM($,Z,Y,X){let J=UM(X),Q=$;return Q=t_(Q,Z),Q=O$(Q,Z),Q=e3(Q,Z,J),Q=$Z(Q,Z,J),Q}function O$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=_M();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${t0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${t0(Q)}">`;return X}),Y}function e3($,Z,Y=t3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"POST",z=K||W||"",B=l4(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${t0(j)}" action="${t0(z)}"${B?` ${B}`:""}>`;if(H+=`
1836
1836
  ${O$("@csrf",Z)}`,!["GET","POST"].includes(q))H+=`
1837
- ${O$(`@method('${q}')`,Z)}`;return H}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"",z=K||W||"",B=l4(U),q=J7(_,Z),j=q!==void 0&&q!==null?q:z||"",H=B.match(/type=['"]([^'"]+)['"]/i),O=H?H[1]:"text",V=Q7(_,Z),L=B.match(/class=['"]([^'"]+)['"]/i),F=o3(L?L[1]:"",Y.input,V,Y.inputError),A=B.replace(/class=['"][^'"]+['"]/i,"");return A=A.replace(/type=['"][^'"]+['"]/i,""),`<input type="${t0(O)}" name="${t0(_)}" value="${t0(j)}" class="${F}"${A?` ${A}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let W=l4(G),U=J7(Q,Z)||K.trim(),_=Q7(Q,Z),z=W.match(/class=['"]([^'"]+)['"]/i),B=o3(z?z[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${t0(Q)}" class="${B}"${q?` ${q}`:""}>${t0(U)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(J,Q,G="",K)=>{let W=l4(G),U=J7(Q,Z),_=Q7(Q,Z),z=W.match(/class=['"]([^'"]+)['"]/i),B=o3(z?z[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,""),j=K;if(U!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,O,V)=>{if((Array.isArray(U)?U.some((F)=>String(F)===V):String(U)===V)&&!O.includes("selected"))return O.replace(/(<option)/,"$1 selected");return H});return`<select name="${t0(Q)}" class="${B}"${q?` ${q}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="1",K="")=>{let W=l4(K),U=J7(Q,Z),_=U!==void 0&&(Array.isArray(U)?U.some((j)=>String(j)===G):U===!0||String(U)===G),z=W.match(/class=['"]([^'"]+)['"]/i),B=z?z[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${t0(Q)}" value="${t0(G)}" class="${B}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,K="")=>{let W=l4(K),U=J7(Q,Z),_=U!==void 0&&U===G,z=W.match(/class=['"]([^'"]+)['"]/i),B=z?z[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${t0(Q)}" value="${t0(G)}" class="${B}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="")=>{let K=l4(G),W=K.match(/accept=['"]([^'"]+)['"]/i),U=W?W[1]:"",_=K.includes("multiple"),z=Q7(Q,Z),B=K.match(/class=['"]([^'"]+)['"]/i),q=o3(B?B[1]:"",Y.input,z,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${t0(Q)}"`,`class="${q}"`];if(U)H.push(`accept="${t0(U)}"`);if(_)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(J,Q,G="",K)=>{let W=l4(G),U=W.match(/class=['"]([^'"]+)['"]/i),_=U?U[1]:Y.label,z=W.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${t0(Q)}" class="${_}"${z?` ${z}`:""}>${K}</label>`}),X}function $Z($,Z,Y=t3){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(Q7(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return a_(J,Z);if(K.trim().includes("errors.first")||K.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(J);return a_(J,Z)}let W=K.trim();if(N0(W)){let U=L0(W,Z);return U!==void 0?String(U):W}return W}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),X}})}function Q7($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function a_($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let Y=Z.errors[$];return Array.isArray(Y)?Y[0]:String(Y)}return""}function J7($,Z){let Y;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let X=$.slice(0,-2);if(Y=Z[X],Y!==void 0)return Y}return Z[$]}function l4($){if(!$.trim())return"";let Z=[],Y=$.trim(),X=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,J;while((J=X.exec(Y))!==null){let[,Q,,G]=J;Z.push(`${Q}="${G.trim()}"`)}return Z.join(" ")}function BM($,Z){s_[$]=Z}function gJ($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function o_($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=gJ(G),W=s_[K.name];if(!W){console.warn(`Unknown validation rule: ${K.name}`);continue}if(K.name==="confirmed"){let _=`${$}_confirmation`;K.params=[X[_]]}let U=W(Z,K.params||[],$);if(U)J.push(K.message||U)}return{field:$,valid:J.length===0,errors:J}}function qM($,Z){let Y={};for(let[X,J]of Object.entries(Z)){let Q=o_(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function t_($,Z){return $.replace(/@validate\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]*)\})?\s*\)/g,(Y,X,J,Q)=>{let G=J.split("|").map((W)=>W.trim()),K=[];for(let W of G){let U=gJ(W);switch(U.name){case"required":K.push("required");break;case"email":K.push('type="email"');break;case"url":K.push('type="url"');break;case"numeric":case"integer":if(K.push('type="number"'),U.name==="integer")K.push('step="1"');break;case"min":if(U.params?.[0])K.push(`minlength="${U.params[0]}"`);break;case"max":if(U.params?.[0])K.push(`maxlength="${U.params[0]}"`);break;case"regex":if(U.params?.[0])K.push(`pattern="${U.params[0]}"`);break}}return`<!-- @validate:${X}:${J} -->${K.length>0?`<!-- attrs:${K.join(" ")} -->`:""}`})}function jM($){hJ[$.name]=$}function e_($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=gJ(Q),K=hJ[G.name];if(!K){console.warn(`Unknown validation rule: ${G.name}`);continue}let W=K.validate($,G.params||[],Y);if(W!==!0)X.push(W)}return{valid:X.length===0,errors:X}}function HM($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=e_($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function OM($,Z){let Y=JSON.stringify(Z);return`
1837
+ ${O$(`@method('${q}')`,Z)}`;return H}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"",z=K||W||"",B=l4(U),q=J7(_,Z),j=q!==void 0&&q!==null?q:z||"",H=B.match(/type=['"]([^'"]+)['"]/i),O=H?H[1]:"text",V=Q7(_,Z),L=B.match(/class=['"]([^'"]+)['"]/i),F=o3(L?L[1]:"",Y.input,V,Y.inputError),A=B.replace(/class=['"][^'"]+['"]/i,"");return A=A.replace(/type=['"][^'"]+['"]/i,""),`<input type="${t0(O)}" name="${t0(_)}" value="${t0(j)}" class="${F}"${A?` ${A}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let W=l4(G),U=J7(Q,Z)||K.trim(),_=Q7(Q,Z),z=W.match(/class=['"]([^'"]+)['"]/i),B=o3(z?z[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${t0(Q)}" class="${B}"${q?` ${q}`:""}>${t0(U)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(J,Q,G="",K)=>{let W=l4(G),U=J7(Q,Z),_=Q7(Q,Z),z=W.match(/class=['"]([^'"]+)['"]/i),B=o3(z?z[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,""),j=K;if(U!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,O,V)=>{if((Array.isArray(U)?U.some((F)=>String(F)===V):String(U)===V)&&!O.includes("selected"))return O.replace(/(<option)/,"$1 selected");return H});return`<select name="${t0(Q)}" class="${B}"${q?` ${q}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="1",K="")=>{let W=l4(K),U=J7(Q,Z),_=U!==void 0&&(Array.isArray(U)?U.some((j)=>String(j)===G):U===!0||String(U)===G),z=W.match(/class=['"]([^'"]+)['"]/i),B=z?z[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${t0(Q)}" value="${t0(G)}" class="${B}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,K="")=>{let W=l4(K),U=J7(Q,Z),_=U!==void 0&&U===G,z=W.match(/class=['"]([^'"]+)['"]/i),B=z?z[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${t0(Q)}" value="${t0(G)}" class="${B}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="")=>{let K=l4(G),W=K.match(/accept=['"]([^'"]+)['"]/i),U=W?W[1]:"",_=K.includes("multiple"),z=Q7(Q,Z),B=K.match(/class=['"]([^'"]+)['"]/i),q=o3(B?B[1]:"",Y.input,z,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${t0(Q)}"`,`class="${q}"`];if(U)H.push(`accept="${t0(U)}"`);if(_)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(J,Q,G="",K)=>{let W=l4(G),U=W.match(/class=['"]([^'"]+)['"]/i),_=U?U[1]:Y.label,z=W.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${t0(Q)}" class="${_}"${z?` ${z}`:""}>${K}</label>`}),X}function $Z($,Z,Y=t3){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(Q7(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return a_(J,Z);if(K.trim().includes("errors.first")||K.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(J);return a_(J,Z)}let W=K.trim();if(w0(W)){let U=L0(W,Z);return U!==void 0?String(U):W}return W}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),X}})}function Q7($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function a_($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let Y=Z.errors[$];return Array.isArray(Y)?Y[0]:String(Y)}return""}function J7($,Z){let Y;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let X=$.slice(0,-2);if(Y=Z[X],Y!==void 0)return Y}return Z[$]}function l4($){if(!$.trim())return"";let Z=[],Y=$.trim(),X=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,J;while((J=X.exec(Y))!==null){let[,Q,,G]=J;Z.push(`${Q}="${G.trim()}"`)}return Z.join(" ")}function BM($,Z){s_[$]=Z}function gJ($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function o_($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=gJ(G),W=s_[K.name];if(!W){console.warn(`Unknown validation rule: ${K.name}`);continue}if(K.name==="confirmed"){let _=`${$}_confirmation`;K.params=[X[_]]}let U=W(Z,K.params||[],$);if(U)J.push(K.message||U)}return{field:$,valid:J.length===0,errors:J}}function qM($,Z){let Y={};for(let[X,J]of Object.entries(Z)){let Q=o_(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function t_($,Z){return $.replace(/@validate\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]*)\})?\s*\)/g,(Y,X,J,Q)=>{let G=J.split("|").map((W)=>W.trim()),K=[];for(let W of G){let U=gJ(W);switch(U.name){case"required":K.push("required");break;case"email":K.push('type="email"');break;case"url":K.push('type="url"');break;case"numeric":case"integer":if(K.push('type="number"'),U.name==="integer")K.push('step="1"');break;case"min":if(U.params?.[0])K.push(`minlength="${U.params[0]}"`);break;case"max":if(U.params?.[0])K.push(`maxlength="${U.params[0]}"`);break;case"regex":if(U.params?.[0])K.push(`pattern="${U.params[0]}"`);break}}return`<!-- @validate:${X}:${J} -->${K.length>0?`<!-- attrs:${K.join(" ")} -->`:""}`})}function jM($){hJ[$.name]=$}function e_($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=gJ(Q),K=hJ[G.name];if(!K){console.warn(`Unknown validation rule: ${G.name}`);continue}let W=K.validate($,G.params||[],Y);if(W!==!0)X.push(W)}return{valid:X.length===0,errors:X}}function HM($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=e_($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function OM($,Z){let Y=JSON.stringify(Z);return`
1838
1838
  <script>
1839
1839
  (function() {
1840
1840
  const form = document.getElementById('${$}');
@@ -1887,7 +1887,7 @@ catch { return 'Please enter a valid URL'; } },
1887
1887
  });
1888
1888
  })();
1889
1889
  </script>`.trim()}var t3,s_,hJ;var dJ=D(()=>{p0();t3={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};s_={required:($,Z,Y)=>{if($===void 0||$===null||$===""||Array.isArray($)&&$.length===0)return`The ${Y} field is required.`;return null},email:($,Z,Y)=>{if(!$)return null;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($)))return`The ${Y} field must be a valid email address.`;return null},min:($,Z,Y)=>{if(!$)return null;let X=Number(Z[0]);if(typeof $==="string"&&$.length<X)return`The ${Y} field must be at least ${X} characters.`;if(typeof $==="number"&&$<X)return`The ${Y} field must be at least ${X}.`;if(Array.isArray($)&&$.length<X)return`The ${Y} field must have at least ${X} items.`;return null},max:($,Z,Y)=>{if(!$)return null;let X=Number(Z[0]);if(typeof $==="string"&&$.length>X)return`The ${Y} field must not exceed ${X} characters.`;if(typeof $==="number"&&$>X)return`The ${Y} field must not exceed ${X}.`;if(Array.isArray($)&&$.length>X)return`The ${Y} field must not have more than ${X} items.`;return null},confirmed:($,Z,Y)=>{if(Z[0]!==void 0&&$!==Z[0])return`The ${Y} confirmation does not match.`;return null},numeric:($,Z,Y)=>{if(!$)return null;if(Number.isNaN(Number($)))return`The ${Y} field must be a number.`;return null},integer:($,Z,Y)=>{if(!$)return null;if(!Number.isInteger(Number($)))return`The ${Y} field must be an integer.`;return null},alpha:($,Z,Y)=>{if(!$)return null;if(!/^[a-z]+$/i.test(String($)))return`The ${Y} field must only contain letters.`;return null},alphanumeric:($,Z,Y)=>{if(!$)return null;if(!/^[a-z0-9]+$/i.test(String($)))return`The ${Y} field must only contain letters and numbers.`;return null},url:($,Z,Y)=>{if(!$)return null;try{return new URL(String($))?null:null}catch{return`The ${Y} field must be a valid URL.`}},regex:($,Z,Y)=>{if(!$)return null;try{if(!new RegExp(Z[0]).test(String($)))return`The ${Y} field format is invalid.`;return null}catch{return`The ${Y} field has an invalid validation pattern.`}},in:($,Z,Y)=>{if(!$)return null;if(!Z.includes(String($)))return`The ${Y} field must be one of: ${Z.join(", ")}.`;return null},notIn:($,Z,Y)=>{if(!$)return null;if(Z.includes(String($)))return`The ${Y} field must not be: ${Z.join(", ")}.`;return null},date:($,Z,Y)=>{if(!$)return null;let X=new Date($);if(Number.isNaN(X.getTime()))return`The ${Y} field must be a valid date.`;return null},before:($,Z,Y)=>{if(!$)return null;let X=new Date($),J=new Date(Z[0]);if(X>=J)return`The ${Y} field must be before ${Z[0]}.`;return null},after:($,Z,Y)=>{if(!$)return null;let X=new Date($),J=new Date(Z[0]);if(X<=J)return`The ${Y} field must be after ${Z[0]}.`;return null}};hJ={required:{name:"required",validate:($)=>{if($===null||$===void 0||$==="")return"This field is required";if(Array.isArray($)&&$.length===0)return"This field is required";return!0},toHtml5:()=>["required"],message:"This field is required"},email:{name:"email",validate:($)=>{if(!$)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($))||"Please enter a valid email address"},toHtml5:()=>['type="email"'],message:"Please enter a valid email address"},url:{name:"url",validate:($)=>{if(!$)return!0;try{return new URL(String($)).protocol.startsWith("http")||"Please enter a valid URL"}catch{return"Please enter a valid URL"}},toHtml5:()=>['type="url"'],message:"Please enter a valid URL"},numeric:{name:"numeric",validate:($)=>{if(!$)return!0;return!Number.isNaN(Number($))||"Please enter a number"},toHtml5:()=>['type="number"'],message:"Please enter a number"},integer:{name:"integer",validate:($)=>{if(!$)return!0;let Z=Number($);return Number.isInteger(Z)||"Please enter a whole number"},toHtml5:()=>['type="number"','step="1"'],message:"Please enter a whole number"},alpha:{name:"alpha",validate:($)=>{if(!$)return!0;return/^[a-z]+$/i.test(String($))||"Please enter only letters"},toHtml5:()=>['pattern="[a-zA-Z]+"'],message:"Please enter only letters"},alphanumeric:{name:"alphanumeric",validate:($)=>{if(!$)return!0;return/^[a-z0-9]+$/i.test(String($))||"Please enter only letters and numbers"},toHtml5:()=>['pattern="[a-zA-Z0-9]+"'],message:"Please enter only letters and numbers"},min:{name:"min",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length>=Y||`Must be at least ${Y} characters`;if(typeof $==="number")return $>=Y||`Must be at least ${Y}`;if(Array.isArray($))return $.length>=Y||`Must have at least ${Y} items`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`min="${$[0]}"`],message:"Must be at least {{param}} characters"},max:{name:"max",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length<=Y||`Must be no more than ${Y} characters`;if(typeof $==="number")return $<=Y||`Must be no more than ${Y}`;if(Array.isArray($))return $.length<=Y||`Must have no more than ${Y} items`;return!0},toHtml5:($)=>[`maxlength="${$[0]}"`,`max="${$[0]}"`],message:"Must be no more than {{param}} characters"},between:{name:"between",validate:($,Z)=>{if(!$)return!0;let[Y,X]=Z.map(Number);if(typeof $==="string")return $.length>=Y&&$.length<=X||`Must be between ${Y} and ${X} characters`;if(typeof $==="number")return $>=Y&&$<=X||`Must be between ${Y} and ${X}`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`maxlength="${$[1]}"`],message:"Must be between {{min}} and {{max}}"},confirmed:{name:"confirmed",validate:($,Z,Y)=>{let X=Object.keys(Y);for(let J of X)if(J.endsWith("_confirmation")&&Y[J]===$)return!0;return"Confirmation does not match"},message:"Confirmation does not match"},in:{name:"in",validate:($,Z)=>{if(!$)return!0;return Z.includes(String($))||`Must be one of: ${Z.join(", ")}`},message:"Must be one of: {{values}}"},notIn:{name:"notIn",validate:($,Z)=>{if(!$)return!0;return!Z.includes(String($))||`Must not be: ${Z.join(", ")}`},message:"Must not be: {{values}}"},regex:{name:"regex",validate:($,Z)=>{if(!$)return!0;try{return new RegExp(Z[0]).test(String($))||"Invalid format"}catch{return"Invalid format"}},toHtml5:($)=>[`pattern="${$[0]}"`],message:"Invalid format"},date:{name:"date",validate:($)=>{if(!$)return!0;let Z=new Date(String($));return!Number.isNaN(Z.getTime())||"Please enter a valid date"},toHtml5:()=>['type="date"'],message:"Please enter a valid date"},before:{name:"before",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),X=new Date(Z[0]);return Y<X||`Must be before ${Z[0]}`},toHtml5:($)=>[`max="${$[0]}"`],message:"Must be before {{date}}"},after:{name:"after",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),X=new Date(Z[0]);return Y>X||`Must be after ${Z[0]}`},toHtml5:($)=>[`min="${$[0]}"`],message:"Must be after {{date}}"},size:{name:"size",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length===Y||`Must be exactly ${Y} characters`;if(Array.isArray($))return $.length===Y||`Must have exactly ${Y} items`;return!0},message:"Must be exactly {{size}}"},phone:{name:"phone",validate:($)=>{if(!$)return!0;return/^\+?\(?\d{1,4}\)?[-\s./\d]*$/.test(String($))||"Please enter a valid phone number"},toHtml5:()=>['type="tel"','pattern="\\+?\\(?\\d{1,4}\\)?[-\\s./\\d]*"'],message:"Please enter a valid phone number"}}});import mJ from"path";async function LM(){if(G7!==void 0)return G7;try{G7=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{G7=null}return G7}function VM($){if($)delete H1[$];else for(let Z of Object.keys(H1))delete H1[Z]}function FM(){let $=Object.entries(H1).map(([Z,Y])=>({locale:Z,loadedAt:new Date(Y.loadedAt),keyCount:Zz(Y.translations)}));return{size:Object.keys(H1).length,locales:Object.keys(H1),entries:$}}function Zz($,Z=0){for(let Y of Object.values($))if(Z++,Y&&typeof Y==="object"&&!Array.isArray(Y))Z=Zz(Y,Z);return Z}function AM($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}function NM($){if(H1[$])return"loaded";return B4[$]||"idle"}function wM($){return B4[$]==="loading"}function RM($){return!!H1[$]}async function Yz($,Z){let{locales:Y,parallel:X=!0,priority:J={},onLocaleLoaded:Q,onComplete:G,onError:K}=$,W=X?Y:[...Y].sort((U,_)=>(J[_]||0)-(J[U]||0));if(X){let U=W.map(async(_)=>{try{await K7(_,Z),Q?.(_)}catch(z){K?.(_,z instanceof Error?z:Error(String(z)))}});await Promise.all(U)}else for(let U of W)try{await K7(U,Z),Q?.(U)}catch(_){K?.(U,_ instanceof Error?_:Error(String(_)))}G?.()}function MM($,Z){queueMicrotask(()=>{Yz($,Z).catch((Y)=>{if(Z.debug)console.error("Background preload error:",Y)})})}async function K7($,Z){if({...YZ,...Z.i18n}.cache&&H1[$]){let J=H1[$],Q=Z.i18n?.cacheMaxAge??0;if(!AM(J,Q))return J.translations}if(d1[$]?.state==="loading")return d1[$].promise;B4[$]="loading";let X=cJ($,Z).then((J)=>{return B4[$]="loaded",delete d1[$],J}).catch((J)=>{throw B4[$]="error",d1[$]={promise:X,state:"error",error:J instanceof Error?J:Error(String(J))},J});return d1[$]={promise:X,state:"loading"},X}function Xz($){return H1[$]?.translations}async function TM($,Z){let Y=Xz($);if(Y)return Y;return K7($,Z)}async function EM($,Z){if(H1[$])return H1[$].translations;if(d1[$]){if(Z)return Promise.race([d1[$].promise,new Promise((Y,X)=>setTimeout(()=>X(Error(`Timeout waiting for locale: ${$}`)),Z))]);return d1[$].promise}throw Error(`Locale "${$}" is not loading. Call loadTranslationLazy first.`)}function IM(){return Object.entries(B4).filter(([$,Z])=>Z==="loading").map(([$])=>$)}function DM($){if($)delete d1[$],delete B4[$];else{for(let Z of Object.keys(d1))delete d1[Z];for(let Z of Object.keys(B4))delete B4[Z]}}async function cJ($,Z){let Y={...YZ,...Z.i18n},X=mJ.isAbsolute(Y.translationsDir)?Y.translationsDir:mJ.resolve(Z.root||process.cwd(),Y.translationsDir);try{let J=await LM(),Q=J?await J($,{translationsDir:X,defaultLocale:Y.defaultLocale,sources:PM(Y.format)}):await kM($,Y,X);if(Q===void 0){if($!==Y.defaultLocale)return cJ(Y.defaultLocale,Z);return{}}let G=Q;if(Y.cache)H1[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(J){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,J);if($!==Y.defaultLocale)return cJ(Y.defaultLocale,Z);return{}}}async function kM($,Z,Y){let X=mJ.join(Y,`${$}${SM(Z.format)}`);try{let J=await import(X);return J.default||J}catch(J){try{let Q=await Bun.file(X).text();if(Z.format==="yaml"||Z.format==="yml")return CM(Q);if(Z.format==="json")return JSON.parse(Q);throw J}catch{return}}}function SM($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function CM($){let Z={},Y=$.split(`
1890
- `),X=[{obj:Z,indent:-1}];for(let J of Y){let Q=J.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(X.length>1&&X[X.length-1].indent>=G)X.pop();let K=X[X.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,_]=W,z=U.trim(),B=_.trim();if(B==="")K[z]={},X.push({obj:K[z],indent:G});else K[z]=bM(B)}}return Z}function bM($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);let Z=$.toLowerCase();if(Z==="true"||Z==="yes")return!0;if(Z==="false"||Z==="no")return!1;if(Z==="null"||Z==="~")return null;let Y=Number($);if(!Number.isNaN(Y)&&$!=="")return Y;return $}function PM($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function Jz($,Z){return K7($,Z)}function yM($,Z){for(let Y of $){let X=Y.trim(),J=X.match(/^\{(\d+)\}\s*(.*)$/);if(J){let G=Number.parseInt(J[1],10);if(Z===G)return J[2];continue}let Q=X.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10),K=Q[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(Q[2],10);if(Z>=G&&Z<=K)return Q[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function Qz($,Z={}){return Gz($,Z)}function Gz($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=xM($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=vM(Q,Z),X=J+1}else if($[X]==="'"&&X+1<$.length)if($[X+1]==="'")Y+="'",X+=2;else if($[X+1]==="{"||$[X+1]==="}")Y+=$[X+1],X+=2;else Y+=$[X],X++;else Y+=$[X],X++;return Y}function xM($,Z){let Y=0;for(let X=Z;X<$.length;X++)if($[X]==="{")Y++;else if($[X]==="}"){if(Y--,Y===0)return X}return-1}function vM($,Z){let Y=fM($);if(Y.length===0)return`{${$}}`;let X=Y[0].trim(),J=Z[X];if(Y.length===1)return J!==void 0?String(J):`{${X}}`;switch(Y[1].trim().toLowerCase()){case"plural":return gM(J,Y.slice(2).join(","),Z);case"select":return dM(J,Y.slice(2).join(","));case"selectordinal":return uM(J,Y.slice(2).join(","));case"number":return cM(J,Y[2]?.trim());case"date":return lM(J,Y[2]?.trim());case"time":return pM(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function fM($){let Z=[],Y="",X=0;for(let J=0;J<$.length;J++){let Q=$[J];if(Q==="{")X++,Y+=Q;else if(Q==="}")X--,Y+=Q;else if(Q===","&&X===0)Z.push(Y),Y="";else Y+=Q}if(Y)Z.push(Y);return Z}function gM($,Z,Y){let X=Number($)||0,J=lJ(Z),Q=`=${X}`;if(J[Q])return uJ(J[Q],X,Y);let G=hM(X);if(J[G])return uJ(J[G],X,Y);if(J.other)return uJ(J.other,X,Y);return String(X)}function uJ($,Z,Y){let X=$.replace(/#/g,String(Z));return Gz(X,Y)}function hM($){let Z=Math.abs($),Y=Math.floor(Z),X=String($).includes(".")?String($).split(".")[1].length:0;if(Y===1&&X===0)return"one";return"other"}function dM($,Z){let Y=String($||""),X=lJ(Z);if(X[Y])return X[Y];return X.other||String($)}function uM($,Z){let Y=Number($)||0,X=lJ(Z),J=mM(Y);if(X[J])return X[J].replace(/#/g,String(Y));if(X.other)return X.other.replace(/#/g,String(Y));return String(Y)}function mM($){let Z=Math.abs($),Y=Z%10,X=Z%100;if(Y===1&&X!==11)return"one";if(Y===2&&X!==12)return"two";if(Y===3&&X!==13)return"few";return"other"}function lJ($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function cM($,Z){let Y=Number($);if(Number.isNaN(Y))return String($);switch(Z){case"integer":return Math.floor(Y).toLocaleString();case"percent":return`${(Y*100).toFixed(0)}%`;case"currency":return Y.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return Y.toLocaleString()}}function lM($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.dateStyle="short";break;case"medium":X.dateStyle="medium";break;case"long":X.dateStyle="long";break;case"full":X.dateStyle="full";break;default:X.dateStyle="medium"}return Y.toLocaleDateString(void 0,X)}function pM($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.timeStyle="short";break;case"medium":X.timeStyle="medium";break;case"long":X.timeStyle="long";break;case"full":X.timeStyle="full";break;default:X.timeStyle="short"}return Y.toLocaleTimeString(void 0,X)}function Kz($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function ZZ($,Z,Y=!0,X={}){let J=$.split("."),Q=Z;for(let K of J){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(Kz(G))return Qz(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),W=G.split("|");G=yM(W,K)}for(let[K,W]of Object.entries(X)){let U=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${U}`,"g"),String(W))}return G}async function pJ($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...YZ,...X.i18n},K=await Jz(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await $z(J,Q,async(_,z,B,q,j)=>{try{let H={};if(B)try{let V=[()=>JSON.parse(B),()=>{let L=`{"data":${B}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return d0(B,Z)}];for(let L of V)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(V){if(X.debug)console.error("Error parsing parameters for @translate directive:",V)}return ZZ(z,K,G.fallbackToKey,H)||q.trim()}catch(H){if(X.debug)console.error("Error processing @translate directive:",H);return U0("Translate",`Error in @translate('${z}'): ${H instanceof Error?H.message:String(H)}`,J0.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(X.debug){console.warn(`Processing translations in template. Sections: ${J.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let _=[...J.matchAll(W)];console.warn(`Found ${_.length} @translate matches`),_.forEach((z,B)=>console.warn(`Match ${B}: ${z[0]}, Key: ${z[1]}, Params: ${z[2]||"none"}`))}return J=await $z(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(_,z,B,q)=>{try{let j={};if(B)try{let H=[()=>JSON.parse(B),()=>{let O=`{"data":${B}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return d0(B,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(X.debug)console.error("Error parsing parameters for @translate directive:",H)}return ZZ(z,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return U0("Translate",`Error in @translate('${z}'): ${j instanceof Error?j.message:String(j)}`,J0.EVALUATION_ERROR)}}),J}async function $z($,Z,Y){let X=[];return $.replace(Z,(Q,...G)=>{let K=Y(Q,...G).then((W)=>({match:Q,replacement:W}));return X.push(K),Q}),(await Promise.all(X)).reduce((Q,{match:G,replacement:K})=>Q.replace(G,K),$)}function iM($,Z=!0){return(Y,X={})=>{return ZZ(Y,$,Z,X)}}var G7,YZ,H1,d1,B4;var iJ=D(()=>{R1();p0();YZ={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},H1={},d1={},B4={}});var D6={};e(D6,{streamingSuspenseDirective:()=>aJ,streamToResponse:()=>Lz,streamTemplateSimple:()=>qz,streamTemplate:()=>Uz,renderStreamingPage:()=>_z,registerStreamingDirectives:()=>Hz,processStreamDirectives:()=>zz,processSectionDirectives:()=>Oz,islandDirective:()=>sJ,generateHydrationRuntime:()=>Vz,extractStreamBoundaries:()=>Bz,createStreamRenderer:()=>jz,buildSuspenseResolveScript:()=>JZ,SUSPENSE_RESOLVER_RUNTIME:()=>rJ});import XZ from"path";function nM($){let Z=[],Y=0,X;Wz.lastIndex=0;while((X=Wz.exec($))!==null){if(X.index>Y){let G=$.slice(Y,X.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let J=X[1],Q=X[2];Z.push({type:"suspense",name:J,content:Q}),Y=X.index+X[0].length}if(Y<$.length){let J=$.slice(Y);if(J.trim())Z.push({type:Z.length===0?"shell":"content",content:J})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function Uz($,Z={},Y={}){let X={...O1,...Y,streaming:{...nJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:XZ.dirname($)};if(W.trim())await E0(W,_,$);let z=nM(U),B=new Set;if(!z.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(I6.source,"g");if(!(j!=="manual"&&H.test(U))){let V=await W0(U,_,$,X,B);for(let L=0;L<V.length;L+=J)Q.enqueue(V.slice(L,L+J)),await new Promise((F)=>setTimeout(F,0))}else{let V=[],L=new RegExp(I6.source,"g"),F;while((F=L.exec(U))!==null)V.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let A=0;for(let N of V){if(N.start>A){let R=U.slice(A,N.start);if(R.trim()){let T=await W0(R,_,$,X,B);Q.enqueue(T),await new Promise((E)=>setTimeout(E,0))}}let w=await W0(N.content,_,$,X,B);Q.enqueue(w),await new Promise((R)=>setTimeout(R,0)),A=N.end}if(A<U.length){let N=U.slice(A);if(N.trim()){let w=await W0(N,_,$,X,B);Q.enqueue(w)}}}}else{let j=new Map;for(let O of z)if(O.type==="shell"||O.type==="content"){let V=await W0(O.content,_,$,X,B);Q.enqueue(V)}else if(O.type==="suspense"&&O.name){let V=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${V}" data-suspense="${O.name}" style="display:contents;">
1890
+ `),X=[{obj:Z,indent:-1}];for(let J of Y){let Q=J.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(X.length>1&&X[X.length-1].indent>=G)X.pop();let K=X[X.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,_]=W,z=U.trim(),B=_.trim();if(B==="")K[z]={},X.push({obj:K[z],indent:G});else K[z]=bM(B)}}return Z}function bM($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);let Z=$.toLowerCase();if(Z==="true"||Z==="yes")return!0;if(Z==="false"||Z==="no")return!1;if(Z==="null"||Z==="~")return null;let Y=Number($);if(!Number.isNaN(Y)&&$!=="")return Y;return $}function PM($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function Jz($,Z){return K7($,Z)}function yM($,Z){for(let Y of $){let X=Y.trim(),J=X.match(/^\{(\d+)\}\s*(.*)$/);if(J){let G=Number.parseInt(J[1],10);if(Z===G)return J[2];continue}let Q=X.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10),K=Q[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(Q[2],10);if(Z>=G&&Z<=K)return Q[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function Qz($,Z={}){return Gz($,Z)}function Gz($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=xM($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=vM(Q,Z),X=J+1}else if($[X]==="'"&&X+1<$.length)if($[X+1]==="'")Y+="'",X+=2;else if($[X+1]==="{"||$[X+1]==="}")Y+=$[X+1],X+=2;else Y+=$[X],X++;else Y+=$[X],X++;return Y}function xM($,Z){let Y=0;for(let X=Z;X<$.length;X++)if($[X]==="{")Y++;else if($[X]==="}"){if(Y--,Y===0)return X}return-1}function vM($,Z){let Y=fM($);if(Y.length===0)return`{${$}}`;let X=Y[0].trim(),J=Z[X];if(Y.length===1)return J!==void 0?String(J):`{${X}}`;switch(Y[1].trim().toLowerCase()){case"plural":return gM(J,Y.slice(2).join(","),Z);case"select":return dM(J,Y.slice(2).join(","));case"selectordinal":return uM(J,Y.slice(2).join(","));case"number":return cM(J,Y[2]?.trim());case"date":return lM(J,Y[2]?.trim());case"time":return pM(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function fM($){let Z=[],Y="",X=0;for(let J=0;J<$.length;J++){let Q=$[J];if(Q==="{")X++,Y+=Q;else if(Q==="}")X--,Y+=Q;else if(Q===","&&X===0)Z.push(Y),Y="";else Y+=Q}if(Y)Z.push(Y);return Z}function gM($,Z,Y){let X=Number($)||0,J=lJ(Z),Q=`=${X}`;if(J[Q])return uJ(J[Q],X,Y);let G=hM(X);if(J[G])return uJ(J[G],X,Y);if(J.other)return uJ(J.other,X,Y);return String(X)}function uJ($,Z,Y){let X=$.replace(/#/g,String(Z));return Gz(X,Y)}function hM($){let Z=Math.abs($),Y=Math.floor(Z),X=String($).includes(".")?String($).split(".")[1].length:0;if(Y===1&&X===0)return"one";return"other"}function dM($,Z){let Y=String($||""),X=lJ(Z);if(X[Y])return X[Y];return X.other||String($)}function uM($,Z){let Y=Number($)||0,X=lJ(Z),J=mM(Y);if(X[J])return X[J].replace(/#/g,String(Y));if(X.other)return X.other.replace(/#/g,String(Y));return String(Y)}function mM($){let Z=Math.abs($),Y=Z%10,X=Z%100;if(Y===1&&X!==11)return"one";if(Y===2&&X!==12)return"two";if(Y===3&&X!==13)return"few";return"other"}function lJ($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function cM($,Z){let Y=Number($);if(Number.isNaN(Y))return String($);switch(Z){case"integer":return Math.floor(Y).toLocaleString();case"percent":return`${(Y*100).toFixed(0)}%`;case"currency":return Y.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return Y.toLocaleString()}}function lM($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.dateStyle="short";break;case"medium":X.dateStyle="medium";break;case"long":X.dateStyle="long";break;case"full":X.dateStyle="full";break;default:X.dateStyle="medium"}return Y.toLocaleDateString(void 0,X)}function pM($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.timeStyle="short";break;case"medium":X.timeStyle="medium";break;case"long":X.timeStyle="long";break;case"full":X.timeStyle="full";break;default:X.timeStyle="short"}return Y.toLocaleTimeString(void 0,X)}function Kz($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function ZZ($,Z,Y=!0,X={}){let J=$.split("."),Q=Z;for(let K of J){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(Kz(G))return Qz(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),W=G.split("|");G=yM(W,K)}for(let[K,W]of Object.entries(X)){let U=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${U}`,"g"),String(W))}return G}async function pJ($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...YZ,...X.i18n},K=await Jz(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await $z(J,Q,async(_,z,B,q,j)=>{try{let H={};if(B)try{let V=[()=>JSON.parse(B),()=>{let L=`{"data":${B}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return d0(B,Z)}];for(let L of V)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(V){if(X.debug)console.error("Error parsing parameters for @translate directive:",V)}return ZZ(z,K,G.fallbackToKey,H)||q.trim()}catch(H){if(X.debug)console.error("Error processing @translate directive:",H);return U0("Translate",`Error in @translate('${z}'): ${H instanceof Error?H.message:String(H)}`,J0.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(X.debug){console.warn(`Processing translations in template. Sections: ${J.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let _=[...J.matchAll(W)];console.warn(`Found ${_.length} @translate matches`),_.forEach((z,B)=>console.warn(`Match ${B}: ${z[0]}, Key: ${z[1]}, Params: ${z[2]||"none"}`))}return J=await $z(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(_,z,B,q)=>{try{let j={};if(B)try{let H=[()=>JSON.parse(B),()=>{let O=`{"data":${B}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return d0(B,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(X.debug)console.error("Error parsing parameters for @translate directive:",H)}return ZZ(z,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return U0("Translate",`Error in @translate('${z}'): ${j instanceof Error?j.message:String(j)}`,J0.EVALUATION_ERROR)}}),J}async function $z($,Z,Y){let X=[];return $.replace(Z,(Q,...G)=>{let K=Y(Q,...G).then((W)=>({match:Q,replacement:W}));return X.push(K),Q}),(await Promise.all(X)).reduce((Q,{match:G,replacement:K})=>Q.replace(G,K),$)}function iM($,Z=!0){return(Y,X={})=>{return ZZ(Y,$,Z,X)}}var G7,YZ,H1,d1,B4;var iJ=D(()=>{R1();p0();YZ={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},H1={},d1={},B4={}});var D6={};e(D6,{streamingSuspenseDirective:()=>aJ,streamToResponse:()=>Lz,streamTemplateSimple:()=>qz,streamTemplate:()=>Uz,renderStreamingPage:()=>_z,registerStreamingDirectives:()=>Hz,processStreamDirectives:()=>zz,processSectionDirectives:()=>Oz,islandDirective:()=>sJ,generateHydrationRuntime:()=>Vz,extractStreamBoundaries:()=>Bz,createStreamRenderer:()=>jz,buildSuspenseResolveScript:()=>JZ,SUSPENSE_RESOLVER_RUNTIME:()=>rJ});import XZ from"path";function nM($){let Z=[],Y=0,X;Wz.lastIndex=0;while((X=Wz.exec($))!==null){if(X.index>Y){let G=$.slice(Y,X.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let J=X[1],Q=X[2];Z.push({type:"suspense",name:J,content:Q}),Y=X.index+X[0].length}if(Y<$.length){let J=$.slice(Y);if(J.trim())Z.push({type:Z.length===0?"shell":"content",content:J})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function Uz($,Z={},Y={}){let X={...O1,...Y,streaming:{...nJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:XZ.dirname($)};if(W.trim())await I0(W,_,$);let z=nM(U),B=new Set;if(!z.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(I6.source,"g");if(!(j!=="manual"&&H.test(U))){let V=await W0(U,_,$,X,B);for(let L=0;L<V.length;L+=J)Q.enqueue(V.slice(L,L+J)),await new Promise((F)=>setTimeout(F,0))}else{let V=[],L=new RegExp(I6.source,"g"),F;while((F=L.exec(U))!==null)V.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let A=0;for(let N of V){if(N.start>A){let R=U.slice(A,N.start);if(R.trim()){let T=await W0(R,_,$,X,B);Q.enqueue(T),await new Promise((E)=>setTimeout(E,0))}}let w=await W0(N.content,_,$,X,B);Q.enqueue(w),await new Promise((R)=>setTimeout(R,0)),A=N.end}if(A<U.length){let N=U.slice(A);if(N.trim()){let w=await W0(N,_,$,X,B);Q.enqueue(w)}}}}else{let j=new Map;for(let O of z)if(O.type==="shell"||O.type==="content"){let V=await W0(O.content,_,$,X,B);Q.enqueue(V)}else if(O.type==="suspense"&&O.name){let V=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${V}" data-suspense="${O.name}" style="display:contents;">
1891
1891
  <template data-suspense-fallback>Loading...</template>
1892
1892
  </div>`),j.set(O.name,W0(O.content,_,$,X,B))}Q.enqueue(`
1893
1893
  <script>
@@ -1911,7 +1911,7 @@ window.__stxSuspense.resolve('${$}', \`${X}\`);
1911
1911
  </script>`}catch(Y){let X=Y instanceof Error?Y.message:String(Y);return`
1912
1912
  <script>
1913
1913
  window.__stxSuspense.resolve('${$}', '<div class="stx-error">Error loading content: ${P0(X)}</div>');
1914
- </script>`}}function rM($,Z,Y){if(!Z||Z<=0)return $;let X,J=new Promise((Q,G)=>{X=setTimeout(()=>G(Error(`streaming boundary "${Y}" timed out after ${Z}ms`)),Z)});return Promise.race([$,J]).finally(()=>clearTimeout(X))}function _z($,Z=[],Y={}){let X=Y.timeoutMs??0;return new ReadableStream({async start(J){try{if(J.enqueue($),Z.length>0)J.enqueue(rJ),await Promise.all(Z.map(async(Q)=>{let G=rM(Q.render(),X,Q.id);J.enqueue(await JZ(Q.id,G))}));J.close()}catch(Q){J.error(Q)}}})}function zz($,Z){return $.replace(aM,(Y,X,J)=>{let Q=X.trim(),G=J.split(/@fallback/i),K=G[0].trim(),W=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[Q]=K,`<div data-suspense="${Q}">${W}</div>`})}function Bz($){let Z=$?.streamBoundaries;if(!Z||typeof Z!=="object")return;let Y=Object.entries(Z).filter(([,X])=>typeof X==="function");return Y.length>0?Y.map(([X,J])=>({id:X,render:J})):void 0}async function qz($,Z={},Y={}){let X={...O1,...Y,streaming:{...nJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:XZ.dirname($)};if(W.trim())await E0(W,_,$);let z=new Set,B=X.streaming?.strategy||"auto",q=new RegExp(I6.source,"g");if(!(B!=="manual"&&q.test(U))){let H=await W0(U,_,$,X,z);for(let O=0;O<H.length;O+=J)Q.enqueue(H.slice(O,O+J))}else{let H=[],O=new RegExp(I6.source,"g"),V;while((V=O.exec(U))!==null)H.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let L=0;for(let F of H){if(F.start>L){let N=U.slice(L,F.start);if(N.trim()){let w=await W0(N,_,$,X,z);Q.enqueue(w)}}let A=await W0(F.content,_,$,X,z);Q.enqueue(A),L=F.end}if(L<U.length){let F=U.slice(L);if(F.trim()){let A=await W0(F,_,$,X,z);Q.enqueue(A)}}}Q.close()}catch(G){Q.error(G)}}})}async function jz($,Z={}){let Y={...O1,...Z,streaming:{...nJ,...Z.streaming}},X=await Bun.file($).text(),J=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),K=G,W={},U;I6.lastIndex=0;while((U=I6.exec(G))!==null){let B=U[1],q=U[2];W[B]=q}let _=G.replace(I6,"");return{renderShell:async(B={})=>{let q={...B,__filename:$,__dirname:XZ.dirname($)};return await E0(Q,q,$),W0(_,q,$,Y,new Set)},renderSection:async(B,q={})=>{try{if(!W[B])return`<div class="error-message">Section "${P0(B)}" not found in template "${P0($)}"</div>`;let j={...q,__filename:$,__dirname:XZ.dirname($)};await E0(Q,j,$);let H=new Set;return await W0(W[B],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return R0("Expression",H,$,W[B]||"",0,W[B]||"")}},getSections:()=>{return Object.keys(W)},getTemplate:()=>{return K}}}function Hz($={}){let Z=[];if($.streaming?.enabled)Z.push(aJ);if($.hydration?.enabled)Z.push(sJ);return Z}async function Oz($,Z,Y,X={}){return $}function Lz($,Z={}){let Y=new TextEncoder,X=$.pipeThrough(new TransformStream({transform(Q,G){G.enqueue(Y.encode(Q))}})),J=new Headers(Z.headers);if(!J.has("Content-Type"))J.set("Content-Type","text/html; charset=utf-8");if(!J.has("Transfer-Encoding"))J.set("Transfer-Encoding","chunked");if(!J.has("X-Content-Type-Options"))J.set("X-Content-Type-Options","nosniff");if(!J.has("X-Accel-Buffering"))J.set("X-Accel-Buffering","no");return new Response(X,{...Z,headers:J})}function Vz($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
1914
+ </script>`}}function rM($,Z,Y){if(!Z||Z<=0)return $;let X,J=new Promise((Q,G)=>{X=setTimeout(()=>G(Error(`streaming boundary "${Y}" timed out after ${Z}ms`)),Z)});return Promise.race([$,J]).finally(()=>clearTimeout(X))}function _z($,Z=[],Y={}){let X=Y.timeoutMs??0;return new ReadableStream({async start(J){try{if(J.enqueue($),Z.length>0)J.enqueue(rJ),await Promise.all(Z.map(async(Q)=>{let G=rM(Q.render(),X,Q.id);J.enqueue(await JZ(Q.id,G))}));J.close()}catch(Q){J.error(Q)}}})}function zz($,Z){return $.replace(aM,(Y,X,J)=>{let Q=X.trim(),G=J.split(/@fallback/i),K=G[0].trim(),W=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[Q]=K,`<div data-suspense="${Q}">${W}</div>`})}function Bz($){let Z=$?.streamBoundaries;if(!Z||typeof Z!=="object")return;let Y=Object.entries(Z).filter(([,X])=>typeof X==="function");return Y.length>0?Y.map(([X,J])=>({id:X,render:J})):void 0}async function qz($,Z={},Y={}){let X={...O1,...Y,streaming:{...nJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:XZ.dirname($)};if(W.trim())await I0(W,_,$);let z=new Set,B=X.streaming?.strategy||"auto",q=new RegExp(I6.source,"g");if(!(B!=="manual"&&q.test(U))){let H=await W0(U,_,$,X,z);for(let O=0;O<H.length;O+=J)Q.enqueue(H.slice(O,O+J))}else{let H=[],O=new RegExp(I6.source,"g"),V;while((V=O.exec(U))!==null)H.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let L=0;for(let F of H){if(F.start>L){let N=U.slice(L,F.start);if(N.trim()){let w=await W0(N,_,$,X,z);Q.enqueue(w)}}let A=await W0(F.content,_,$,X,z);Q.enqueue(A),L=F.end}if(L<U.length){let F=U.slice(L);if(F.trim()){let A=await W0(F,_,$,X,z);Q.enqueue(A)}}}Q.close()}catch(G){Q.error(G)}}})}async function jz($,Z={}){let Y={...O1,...Z,streaming:{...nJ,...Z.streaming}},X=await Bun.file($).text(),J=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),K=G,W={},U;I6.lastIndex=0;while((U=I6.exec(G))!==null){let B=U[1],q=U[2];W[B]=q}let _=G.replace(I6,"");return{renderShell:async(B={})=>{let q={...B,__filename:$,__dirname:XZ.dirname($)};return await I0(Q,q,$),W0(_,q,$,Y,new Set)},renderSection:async(B,q={})=>{try{if(!W[B])return`<div class="error-message">Section "${P0(B)}" not found in template "${P0($)}"</div>`;let j={...q,__filename:$,__dirname:XZ.dirname($)};await I0(Q,j,$);let H=new Set;return await W0(W[B],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return M0("Expression",H,$,W[B]||"",0,W[B]||"")}},getSections:()=>{return Object.keys(W)},getTemplate:()=>{return K}}}function Hz($={}){let Z=[];if($.streaming?.enabled)Z.push(aJ);if($.hydration?.enabled)Z.push(sJ);return Z}async function Oz($,Z,Y,X={}){return $}function Lz($,Z={}){let Y=new TextEncoder,X=$.pipeThrough(new TransformStream({transform(Q,G){G.enqueue(Y.encode(Q))}})),J=new Headers(Z.headers);if(!J.has("Content-Type"))J.set("Content-Type","text/html; charset=utf-8");if(!J.has("Transfer-Encoding"))J.set("Transfer-Encoding","chunked");if(!J.has("X-Content-Type-Options"))J.set("X-Content-Type-Options","nosniff");if(!J.has("X-Accel-Buffering"))J.set("X-Accel-Buffering","no");return new Response(X,{...Z,headers:J})}function Vz($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
1915
1915
  `);if(Z==="loader")return`
1916
1916
  (function() {
1917
1917
  window.__stx = window.__stx || {};
@@ -2073,13 +2073,13 @@ else {
2073
2073
  }
2074
2074
  };
2075
2075
  })();
2076
- </script>`,aM,aJ,sJ;var p4=D(()=>{i0();o0();U1();A0();nJ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},I6=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,Wz=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;aM=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;aJ={name:"suspense",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Suspense directive requires a name parameter");let J=Z[0].replace(/['"`]/g,"");return`<!-- @suspense:${J} -->${$}<!-- @endsuspense:${J} -->`}},sJ={name:"island",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let J=Z[0].replace(/['"`]/g,""),Q=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${J}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),W=K?K[1].trim():"",U=K?$.replace(K[0],""):$;return`<div data-island="${J}" data-island-id="${G}" data-priority="${Q}">
2076
+ </script>`,aM,aJ,sJ;var p4=D(()=>{i0();o0();U1();N0();nJ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},I6=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,Wz=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;aM=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;aJ={name:"suspense",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Suspense directive requires a name parameter");let J=Z[0].replace(/['"`]/g,"");return`<!-- @suspense:${J} -->${$}<!-- @endsuspense:${J} -->`}},sJ={name:"island",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let J=Z[0].replace(/['"`]/g,""),Q=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${J}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),W=K?K[1].trim():"",U=K?$.replace(K[0],""):$;return`<div data-island="${J}" data-island-id="${G}" data-priority="${Q}">
2077
2077
  ${U}
2078
2078
  <script type="application/json" data-island-props="${G}">
2079
2079
  ${W?`{${W}}`:"{}"}
2080
2080
  </script>
2081
2081
  </div>`}}});var Nz={};e(Nz,{warnUnbalancedTags:()=>oJ,findUnbalancedTags:()=>Az});function i4($){return $.replace(/[^\n]/g," ")}function Az($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,i4).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,i4).replace(/<!--[\s\S]*?-->/g,i4).replace(/\{\{\{[\s\S]*?\}\}\}/g,i4).replace(/\{\{[\s\S]*?\}\}/g,i4).replace(/\{!![\s\S]*?!!\}/g,i4).replace(/"[^"]*"/g,i4).replace(/'[^']*'/g,i4),Y=new Map,X=new Map,J=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,Q;while((Q=J.exec(Z))!==null){let K=Q[1]==="/",W=Q[2],U=Q[3]==="/";if(sM.has(W.toLowerCase()))continue;if(U)continue;if(K)X.set(W,(X.get(W)??0)+1);else{let _=Y.get(W);if(_)_.count++;else{let z=Z.slice(0,Q.index).split(`
2082
- `).length;Y.set(W,{count:1,firstLine:z})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(oM.has(K.toLowerCase()))continue;let W=Y.get(K)?.count??0,U=X.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function oJ($,Z){let Y;try{Y=Az($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(Fz.has(X))return;Fz.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Y)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var sM,oM,Fz;var tJ=D(()=>{sM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),oM=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);Fz=new Set});import P1 from"path";import eJ from"fs";function wz($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function Rz($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class Mz{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),wz(J),Rz(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${wz(J)}.stx`,`${Rz(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=P1.resolve(P1.dirname(Z),`${J}.stx`);if(await X0(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(P1.join(P1.dirname(U),"components"));if(W)K.push(W);let _=P1.join(P1.dirname(Z),"components");if(!K.includes(_))K.push(_);let z=process.cwd(),B=[P1.resolve(z,"src/components"),P1.resolve(z,"components"),P1.resolve(import.meta.dir,"components")];for(let q of B)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=P1.join(q,j);if(await X0(H))return H}try{if(!eJ.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=eJ.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let V=P1.join(q,O.name);for(let L of G){let F=P1.join(V,L);if(await X0(F))return F}}}catch{}}return null}}var L1;var $9=D(()=>{A0();L1=new Mz});function n4($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function tM($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var Z9;var Y9=D(()=>{Z9={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=tM($),J=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,W=[];if(X.reactive)W.push(`:href="${n4(X.value)}"`);else W.push(`href="${n4(X.value)}"`);if(J)W.push(`class="${n4(J)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${n4(Q)}"`),W.push(`data-stx-exact-active-class="${n4(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[_,z]of Object.entries($.static)){if(U.has(_))continue;if(typeof z==="boolean"){if(z)W.push(n4(_))}else W.push(`${n4(_)}="${n4(z)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function m0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function J9($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let J=$.static[Z];if(J!==void 0)return J!=="false"&&J!==!1;return Y}function Tz($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=eM[J];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(J);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(X);return Y.join(", ")}function Q9($,Z,Y,X){return Z.map((J)=>`${W7($,J,void 0,Y,X)} ${J}w`).join(", ")}function $T($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${W7($,G,void 0,X,J)} ${Q}x`}).join(", ")}function W7($,Z,Y,X,J){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(J)Q.push(`f_${J}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(J)Q.set("fm",J);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(X==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(J)Q.set("format",J);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function ZT($,Z,Y="#e5e7eb"){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(X)}`}var eM,X9,G9;var K9=D(()=>{eM={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},X9=[320,640,768,1024,1280,1536,1920];G9={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=_1($,"src")||"",J=_1($,"alt")||"",Q=_1($,"width"),G=_1($,"height"),K=_1($,"sizes"),W=_1($,"srcset"),U=_1($,"densities"),_=_1($,"format"),z=_1($,"placeholder"),B=_1($,"placeholderColor")||"#e5e7eb",q=_1($,"provider"),j=_1($,"class")||_1($,"className")||"",H=_1($,"style")||"",O=_1($,"quality"),V=J9($,"lazy",!0),L=J9($,"preload",!1),F=J9($,"picture",!1)||!!_,A=Q?Number.parseInt(Q):void 0,N=G?Number.parseInt(G):void 0,w=W||"",R="";if(!w&&K)w=Q9(X,X9,q,_),R=Tz(K);else if(!w&&U){let P=U.split(/\s+/).map((C)=>Number.parseFloat(C.replace("x","")));w=$T(X,P,A,q,_)}else if(K)R=Tz(K);let T=[];if(H)T.push(H);if(A&&N)T.push(`aspect-ratio:${A}/${N}`);if(z==="blur"||z==="color"||z==="thumbhash"){let P=ZT(A||16,N||9,B);T.push(`background-image:url(${P})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(z&&z!=="empty"&&z!=="none")T.push(`background-image:url(${m0(z)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let E=W7(X,A,N,q,_),I=[];if(I.push(`src="${m0(E)}"`),I.push(`alt="${m0(J)}"`),Q)I.push(`width="${m0(Q)}"`);if(G)I.push(`height="${m0(G)}"`);if(V)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${m0(j)}"`);if(T.length>0)I.push(`style="${m0(T.join(";"))}"`);if(w)I.push(`srcset="${m0(w)}"`);if(R)I.push(`sizes="${m0(R)}"`);let k=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[P,C]of Object.entries($.static)){if(k.has(P))continue;if(typeof C==="boolean"){if(C)I.push(m0(P))}else I.push(`${m0(P)}="${m0(C)}"`)}let S=`<img ${I.join(" ")} />`,x="";if(L){let C=_==="webp"?"image/webp":_==="avif"?"image/avif":"";x=`<link rel="preload" as="image" href="${m0(E)}"${C?` type="${C}"`:""}${w?` imagesrcset="${m0(w)}"`:""}${R?` imagesizes="${m0(R)}"`:""} />
2082
+ `).length;Y.set(W,{count:1,firstLine:z})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(oM.has(K.toLowerCase()))continue;let W=Y.get(K)?.count??0,U=X.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function oJ($,Z){let Y;try{Y=Az($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(Fz.has(X))return;Fz.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Y)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var sM,oM,Fz;var tJ=D(()=>{sM=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),oM=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);Fz=new Set});import P1 from"path";import eJ from"fs";function wz($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function Rz($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class Mz{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),wz(J),Rz(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${wz(J)}.stx`,`${Rz(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=P1.resolve(P1.dirname(Z),`${J}.stx`);if(await X0(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(P1.join(P1.dirname(U),"components"));if(W)K.push(W);let _=P1.join(P1.dirname(Z),"components");if(!K.includes(_))K.push(_);let z=process.cwd(),B=[P1.resolve(z,"src/components"),P1.resolve(z,"components"),P1.resolve(import.meta.dir,"components")];for(let q of B)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=P1.join(q,j);if(await X0(H))return H}try{if(!eJ.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=eJ.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let V=P1.join(q,O.name);for(let L of G){let F=P1.join(V,L);if(await X0(F))return F}}}catch{}}return null}}var L1;var $9=D(()=>{N0();L1=new Mz});function n4($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function tM($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var Z9;var Y9=D(()=>{Z9={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=tM($),J=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,W=[];if(X.reactive)W.push(`:href="${n4(X.value)}"`);else W.push(`href="${n4(X.value)}"`);if(J)W.push(`class="${n4(J)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${n4(Q)}"`),W.push(`data-stx-exact-active-class="${n4(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[_,z]of Object.entries($.static)){if(U.has(_))continue;if(typeof z==="boolean"){if(z)W.push(n4(_))}else W.push(`${n4(_)}="${n4(z)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function m0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function J9($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let J=$.static[Z];if(J!==void 0)return J!=="false"&&J!==!1;return Y}function Tz($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=eM[J];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(J);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(X);return Y.join(", ")}function Q9($,Z,Y,X){return Z.map((J)=>`${W7($,J,void 0,Y,X)} ${J}w`).join(", ")}function $T($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${W7($,G,void 0,X,J)} ${Q}x`}).join(", ")}function W7($,Z,Y,X,J){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(J)Q.push(`f_${J}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(J)Q.set("fm",J);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(X==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(J)Q.set("format",J);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function ZT($,Z,Y="#e5e7eb"){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(X)}`}var eM,X9,G9;var K9=D(()=>{eM={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},X9=[320,640,768,1024,1280,1536,1920];G9={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=_1($,"src")||"",J=_1($,"alt")||"",Q=_1($,"width"),G=_1($,"height"),K=_1($,"sizes"),W=_1($,"srcset"),U=_1($,"densities"),_=_1($,"format"),z=_1($,"placeholder"),B=_1($,"placeholderColor")||"#e5e7eb",q=_1($,"provider"),j=_1($,"class")||_1($,"className")||"",H=_1($,"style")||"",O=_1($,"quality"),V=J9($,"lazy",!0),L=J9($,"preload",!1),F=J9($,"picture",!1)||!!_,A=Q?Number.parseInt(Q):void 0,N=G?Number.parseInt(G):void 0,w=W||"",R="";if(!w&&K)w=Q9(X,X9,q,_),R=Tz(K);else if(!w&&U){let P=U.split(/\s+/).map((C)=>Number.parseFloat(C.replace("x","")));w=$T(X,P,A,q,_)}else if(K)R=Tz(K);let T=[];if(H)T.push(H);if(A&&N)T.push(`aspect-ratio:${A}/${N}`);if(z==="blur"||z==="color"||z==="thumbhash"){let P=ZT(A||16,N||9,B);T.push(`background-image:url(${P})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(z&&z!=="empty"&&z!=="none")T.push(`background-image:url(${m0(z)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let E=W7(X,A,N,q,_),I=[];if(I.push(`src="${m0(E)}"`),I.push(`alt="${m0(J)}"`),Q)I.push(`width="${m0(Q)}"`);if(G)I.push(`height="${m0(G)}"`);if(V)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${m0(j)}"`);if(T.length>0)I.push(`style="${m0(T.join(";"))}"`);if(w)I.push(`srcset="${m0(w)}"`);if(R)I.push(`sizes="${m0(R)}"`);let k=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[P,C]of Object.entries($.static)){if(k.has(P))continue;if(typeof C==="boolean"){if(C)I.push(m0(P))}else I.push(`${m0(P)}="${m0(C)}"`)}let S=`<img ${I.join(" ")} />`,x="";if(L){let C=_==="webp"?"image/webp":_==="avif"?"image/avif":"";x=`<link rel="preload" as="image" href="${m0(E)}"${C?` type="${C}"`:""}${w?` imagesrcset="${m0(w)}"`:""}${R?` imagesizes="${m0(R)}"`:""} />
2083
2083
  `}if(F){let P=[];if(_==="avif"||_==="auto"){let C=W7(X,A,N,q,"avif"),g=w?Q9(X,X9,q,"avif"):`${C}`;P.push(`<source type="image/avif" srcset="${m0(g)}"${R?` sizes="${m0(R)}"`:""} />`)}if(_==="webp"||_==="auto"){let C=W7(X,A,N,q,"webp"),g=w?Q9(X,X9,q,"webp"):`${C}`;P.push(`<source type="image/webp" srcset="${m0(g)}"${R?` sizes="${m0(R)}"`:""} />`)}return`${x}<picture>
2084
2084
  ${P.join(`
2085
2085
  `)}
@@ -2118,15 +2118,15 @@ ${S}
2118
2118
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
2119
2119
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
2120
2120
  </style>`}}});var Cz={};e(Cz,{preloadIconCollection:()=>WZ,IconBuiltin:()=>KZ});import{existsSync as JT,readFileSync as QT}from"fs";function Sz($){try{return $0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(JT(Y))return Y;return null}function GT($){if(k6.has($))return k6.get($);let Z=Sz($);if(!Z)return null;try{let Y=JSON.parse(QT(Z,"utf8"));return k6.set($,Y.icons),Y.icons}catch{return null}}async function KT($){if(k6.has($))return k6.get($);let Z=Sz($);if(!Z)return null;try{let Y=await Bun.file(Z).json();return k6.set($,Y.icons),Y.icons}catch{return null}}function F$($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function WZ($="lucide"){await KT($)}var k6,KZ;var UZ=D(()=>{k6=new Map;KZ={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=F$($,"name")??F$($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let L=X.split(":");J=L[0],Q=L[1]}let G=u1(F$($,"size")||"24"),K=u1(F$($,"color")||"currentColor"),W=u1(F$($,"class")||""),U=u1(F$($,"style")||""),_=k6.get(J)??GT(J);if(!_)return`<!-- Icon: collection "${J}" not loaded -->`;let z=_[Q];if(!z)return`<!-- Icon: "${Q}" not found in ${J} -->`;let B=z.width||24,q=z.height||24,j=`0 0 ${B} ${q}`,H=z.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",V=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${V}>${H}</svg>`}}});function bz($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}function Pz($,Z){let Y=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),X=$.match(Y);if(!X)return{region:null,rest:$};return{region:X[2],rest:$.replace(X[0],"")}}var F9;var A9=D(()=>{F9={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=Pz(Z,"fallback"),J=X.rest,Q=Pz(J,"error"),G=Q.rest,K=X.region??bz($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',W=Q.region??bz($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${W}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function _Z($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}var N9;var w9=D(()=>{N9={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(_Z($,"name")||"v").replace(/["'<>]/g,""),J=(_Z($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=_Z($,"class"),G=_Z($,"id"),K=[`data-stx-transition-group="${X}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${J} ${K}>${Z}</${J}>`}}});function yz(){L1.registerBuiltin(Z9),L1.registerBuiltin(G9),L1.registerBuiltin(W9),L1.registerBuiltin(z9),L1.registerBuiltin(q9),L1.registerBuiltin(H9),L1.registerBuiltin(L9),L1.registerBuiltin(KZ),L1.registerBuiltin(F9),L1.registerBuiltin(N9)}var R9=D(()=>{Y9();K9();U9();B9();j9();O9();V9();UZ();A9();w9();$9();Y9();K9();U9();B9();j9();O9();V9();UZ();A9();w9()});function xz($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function vz($,Z,Y){let X=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){J=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;J=H+1;continue}let U=Q+1+W.length,_=null,z=U,B=-1,q=!1;while(U<$.length){let H=$[U];if(_){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===_)_=null;U++;continue}if(H==='"'||H==="'"){_=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){B=U+2,q=!0;break}if(H===">"){B=U+1;break}U++}if(B===-1){J=Q+1;continue}let j=$.slice(z,q?B-2:B-1).trim();if(q)X.push({fullMatch:$.slice(Q,B),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:B,isSelfClosing:!0}),J=B;else{let H=`<${W}`,O=`</${W}>`,V=1,L=B,F=-1;while(V>0&&L<$.length){let w=$.indexOf(H,L),R=$.indexOf(O,L);if(R===-1)break;if(w!==-1&&w<R){let T=$[w+H.length];if(T===" "||T===">"||T==="/"||T===`
2121
- `||T==="\t")V++;L=w+H.length}else{if(V--,V===0){F=R;break}L=R+O.length}}if(F===-1){J=B;continue}let A=$.slice(B,F),N=F+O.length;X.push({fullMatch:$.slice(Q,N),tagName:W,attributes:j,content:A,startIndex:Q,endIndex:N,isSelfClosing:!1}),J=N}}return X}function fz($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var gz=D(()=>{p0();A0();E3()});var lz={};e(lz,{processESImports:()=>cz,processComponents:()=>BZ});import zZ from"fs";import M1 from"path";function UT($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));X.serverDynamic[U]=fz(K,Y);continue}if(W.startsWith(":")){let U=Q(W.slice(1)),_=K==="true"?U:K;try{if(!N0(_)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${_}`);X.clientReactive[U]=_;continue}let z=Object.keys(Z),q=w0(_,z)(...Object.values(Z));if(q===void 0){let j=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((V)=>!H.has(V)&&!z.includes(V))){X.clientReactive[U]=_;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=_}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let _=U[1];if(N0(_)){let B=w0(_,Object.keys(Z))(...Object.values(Z));X.static[W]=B!=null?String(B):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${_}`);X.static[W]=K}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,_);X.static[W]=K}else{let _=K,z=/\{\{\s*([\s\S]+?)\s*\}\}/g,B;while((B=z.exec(K))!==null)try{let q=B[1];if(!N0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=w0(q,Object.keys(Z))(...Object.values(Z));_=_.replace(B[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=_}continue}X.static[W]=K}return X}function _T($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]="true"}return Z}function dz($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zT($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let J=X[1];if(L1.isBuiltin(J))Z.add(J)}return[...Z].sort()}function BT($){let Z=uz.get($);if(Z)return Z;let Y=new Map,X=[M1.join($,"src"),M1.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=zZ.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=M1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;J(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let _=W.name.slice(0,-4);if(!Y.has(_))Y.set(_,U);let z=_.toLowerCase();if(!Y.has(z))Y.set(z,U);let B=_.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,U)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return uz.set($,Y),Y}function qT($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=M1.join(Y,"node_modules",$);try{if(zZ.statSync(X).isDirectory())return X}catch{}let J=M1.dirname(Y);if(J===Y)return null;Y=J}}async function cz($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=M1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,_,z)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=z,j,H=[];while((j=B.exec(z))!==null){let[O,V,L,F]=j,A=null,N=null;if(F.startsWith(".")||F.startsWith("/")){let T=M1.resolve(G,F);if(T.endsWith(".stx"))N=T;else{let E=`${T}.stx`;try{if(zZ.statSync(E).isFile())N=E}catch{try{if(zZ.statSync(T).isDirectory())A=T}catch{}}}}else A=qT(F,G);if(!A&&!N)continue;let w=!1,R=(T,E)=>{Q.set(T,E),Q.set(T.toLowerCase(),E);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,E),J.add(E)};if(L&&N)R(L,N),w=!0;else if(V){let T=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let k=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k)return{source:k[1],local:k[2]};return{source:I,local:I}}),E=A?BT(A):null;for(let{source:I,local:k}of T){let S=null;if(N)S=N;else if(E)S=E.get(I)??E.get(I.toLowerCase())??E.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(S)R(k,S),w=!0}}if(w)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${_}>${q}</script>`}),K}async function jT($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,_]=W,z=_.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of z){let q=B.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),V=null,L=[M1.resolve(M1.dirname(Y),`${B}.stx`),M1.resolve(M1.dirname(Y),B),M1.resolve(X.componentsDir||"components",`${B}.stx`),M1.resolve(X.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let F of L)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(O,V),G.set(H,V),G.set(H.toLowerCase(),V);let F=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),J.add(V),X.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${B}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function HT($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let _=U.index,z=_+U[0].length-1,B=1,q=z+1;while(q<Q.length&&B>0){if(Q[q]==="(")B++;else if(Q[q]===")"){if(B--,B===0)break}q++}if(B!==0)break;let j=Q.substring(z+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let V=O[1],L,F=j.slice(O[0].length),A=F.match(/^\s*,\s*/);if(A)L=F.slice(A[0].length).trim();let N={};if(L)try{N=d0(L,Z)}catch(k){let S=k instanceof Error?k.message:String(k);Q=Q.replace(Q.substring(_,H),`[Error parsing component props: ${S}]`);continue}let w="",R=H,E=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(E)w=E[1].trim(),R=H+E[0].length;let I=await e1(V,N,w,G,Z,Y,X,K,J);Q=Q.substring(0,_)+I+Q.substring(R),W.lastIndex=0}return Q}async function OT($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=oX(Q);return Q=W.output,Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,WT),Q=tX(Q,W.scripts),Q;async function B(q,j,H,O){if(!q)return q;let V=q,L=vz(V,j,O);for(let F=L.length-1;F>=0;F--){let A=L[F],N=H?xz(A.tagName):A.tagName,w=_T(A.attributes),R=UT(w,Z,X),T=L1.getBuiltin(A.tagName),E=T?await T9(N,G,Z,Y,X):!1;if(T&&!E){let x={context:Z,filePath:Y,options:X,dependencies:J},P=T.render(R,A.content,x);if(Object.keys(R.clientReactive).length>0)P=mz(P,R.clientReactive);if(Object.keys(R.events).length>0){let C=Object.entries(R.events).map(([g,s])=>`${g}="${dz(s)}"`).join(" ");P=P.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${C}`)}V=V.substring(0,A.startIndex)+P+V.substring(A.endIndex);continue}let I={};for(let[x,P]of Object.entries(R.static))I[x]=P;for(let[x,P]of Object.entries(R.serverDynamic))I[x]=P;let S=await e1(N,I,A.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)S=mz(S,R.clientReactive);if(Object.keys(R.events).length>0){let x=S.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(x){let P=Object.entries(R.events).map(([g,s])=>`${g}="${dz(s)}"`).join(" "),C=x[1].length+x[2].length;S=S.substring(0,C)+" "+P+S.substring(C)}}V=V.substring(0,A.startIndex)+S+V.substring(A.endIndex)}return V}}function mz($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function BZ($,Z,Y,X,J){if(!hz)yz(),hz=!0;let Q=await cz($,Z,Y,X,J);Q=await jT(Q,Z,Y,X,J),Q=await HT(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await OT(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=zT(Q);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var hz=!1,WT,uz;var M9=D(()=>{$9();R9();gz();A0();p0();WT=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);uz=new Map});var jZ={};e(jZ,{stripTypeScript:()=>az,hasVariables:()=>D9,extractVariables:()=>E0,extractScriptFromTemplate:()=>I9,convertToCommonJS:()=>qZ});import A$ from"path";import _7 from"process";function LT($){let Z=[],Y=0,X=$.split(`
2121
+ `||T==="\t")V++;L=w+H.length}else{if(V--,V===0){F=R;break}L=R+O.length}}if(F===-1){J=B;continue}let A=$.slice(B,F),N=F+O.length;X.push({fullMatch:$.slice(Q,N),tagName:W,attributes:j,content:A,startIndex:Q,endIndex:N,isSelfClosing:!1}),J=N}}return X}function fz($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var gz=D(()=>{p0();N0();E3()});var lz={};e(lz,{processESImports:()=>cz,processComponents:()=>BZ});import zZ from"fs";import M1 from"path";function UT($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));X.serverDynamic[U]=fz(K,Y);continue}if(W.startsWith(":")){let U=Q(W.slice(1)),_=K==="true"?U:K;try{if(!w0(_)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${_}`);X.clientReactive[U]=_;continue}let z=Object.keys(Z),q=R0(_,z)(...Object.values(Z));if(q===void 0){let j=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((V)=>!H.has(V)&&!z.includes(V))){X.clientReactive[U]=_;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=_}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let _=U[1];if(w0(_)){let B=R0(_,Object.keys(Z))(...Object.values(Z));X.static[W]=B!=null?String(B):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${_}`);X.static[W]=K}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,_);X.static[W]=K}else{let _=K,z=/\{\{\s*([\s\S]+?)\s*\}\}/g,B;while((B=z.exec(K))!==null)try{let q=B[1];if(!w0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=R0(q,Object.keys(Z))(...Object.values(Z));_=_.replace(B[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=_}continue}X.static[W]=K}return X}function _T($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]="true"}return Z}function dz($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function zT($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let J=X[1];if(L1.isBuiltin(J))Z.add(J)}return[...Z].sort()}function BT($){let Z=uz.get($);if(Z)return Z;let Y=new Map,X=[M1.join($,"src"),M1.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=zZ.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=M1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;J(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let _=W.name.slice(0,-4);if(!Y.has(_))Y.set(_,U);let z=_.toLowerCase();if(!Y.has(z))Y.set(z,U);let B=_.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,U)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return uz.set($,Y),Y}function qT($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=M1.join(Y,"node_modules",$);try{if(zZ.statSync(X).isDirectory())return X}catch{}let J=M1.dirname(Y);if(J===Y)return null;Y=J}}async function cz($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=M1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,_,z)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=z,j,H=[];while((j=B.exec(z))!==null){let[O,V,L,F]=j,A=null,N=null;if(F.startsWith(".")||F.startsWith("/")){let T=M1.resolve(G,F);if(T.endsWith(".stx"))N=T;else{let E=`${T}.stx`;try{if(zZ.statSync(E).isFile())N=E}catch{try{if(zZ.statSync(T).isDirectory())A=T}catch{}}}}else A=qT(F,G);if(!A&&!N)continue;let w=!1,R=(T,E)=>{Q.set(T,E),Q.set(T.toLowerCase(),E);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,E),J.add(E)};if(L&&N)R(L,N),w=!0;else if(V){let T=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let k=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k)return{source:k[1],local:k[2]};return{source:I,local:I}}),E=A?BT(A):null;for(let{source:I,local:k}of T){let S=null;if(N)S=N;else if(E)S=E.get(I)??E.get(I.toLowerCase())??E.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(S)R(k,S),w=!0}}if(w)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${_}>${q}</script>`}),K}async function jT($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,_]=W,z=_.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of z){let q=B.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),V=null,L=[M1.resolve(M1.dirname(Y),`${B}.stx`),M1.resolve(M1.dirname(Y),B),M1.resolve(X.componentsDir||"components",`${B}.stx`),M1.resolve(X.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let F of L)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(O,V),G.set(H,V),G.set(H.toLowerCase(),V);let F=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),J.add(V),X.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${B}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function HT($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let _=U.index,z=_+U[0].length-1,B=1,q=z+1;while(q<Q.length&&B>0){if(Q[q]==="(")B++;else if(Q[q]===")"){if(B--,B===0)break}q++}if(B!==0)break;let j=Q.substring(z+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let V=O[1],L,F=j.slice(O[0].length),A=F.match(/^\s*,\s*/);if(A)L=F.slice(A[0].length).trim();let N={};if(L)try{N=d0(L,Z)}catch(k){let S=k instanceof Error?k.message:String(k);Q=Q.replace(Q.substring(_,H),`[Error parsing component props: ${S}]`);continue}let w="",R=H,E=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(E)w=E[1].trim(),R=H+E[0].length;let I=await e1(V,N,w,G,Z,Y,X,K,J);Q=Q.substring(0,_)+I+Q.substring(R),W.lastIndex=0}return Q}async function OT($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=oX(Q);return Q=W.output,Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,WT),Q=tX(Q,W.scripts),Q;async function B(q,j,H,O){if(!q)return q;let V=q,L=vz(V,j,O);for(let F=L.length-1;F>=0;F--){let A=L[F],N=H?xz(A.tagName):A.tagName,w=_T(A.attributes),R=UT(w,Z,X),T=L1.getBuiltin(A.tagName),E=T?await T9(N,G,Z,Y,X):!1;if(T&&!E){let x={context:Z,filePath:Y,options:X,dependencies:J},P=T.render(R,A.content,x);if(Object.keys(R.clientReactive).length>0)P=mz(P,R.clientReactive);if(Object.keys(R.events).length>0){let C=Object.entries(R.events).map(([g,s])=>`${g}="${dz(s)}"`).join(" ");P=P.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${C}`)}V=V.substring(0,A.startIndex)+P+V.substring(A.endIndex);continue}let I={};for(let[x,P]of Object.entries(R.static))I[x]=P;for(let[x,P]of Object.entries(R.serverDynamic))I[x]=P;let S=await e1(N,I,A.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)S=mz(S,R.clientReactive);if(Object.keys(R.events).length>0){let x=S.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(x){let P=Object.entries(R.events).map(([g,s])=>`${g}="${dz(s)}"`).join(" "),C=x[1].length+x[2].length;S=S.substring(0,C)+" "+P+S.substring(C)}}V=V.substring(0,A.startIndex)+S+V.substring(A.endIndex)}return V}}function mz($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function BZ($,Z,Y,X,J){if(!hz)yz(),hz=!0;let Q=await cz($,Z,Y,X,J);Q=await jT(Q,Z,Y,X,J),Q=await HT(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await OT(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=zT(Q);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var hz=!1,WT,uz;var M9=D(()=>{$9();R9();gz();N0();p0();WT=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);uz=new Map});var jZ={};e(jZ,{stripTypeScript:()=>az,hasVariables:()=>D9,extractVariables:()=>I0,extractScriptFromTemplate:()=>I9,convertToCommonJS:()=>qZ});import A$ from"path";import _7 from"process";function LT($){let Z=[],Y=0,X=$.split(`
2122
2122
  `);for(let J of X){let Q=Y,G=null,K=!1;for(let W=0;W<J.length;W++){let U=J[W];if(K){K=!1;continue}if(U==="\\"){K=!0;continue}if(G){if(U===G)G=null;continue}if(U==="'"||U==='"'||U==="`"){G=U;continue}if(U==="/"&&W+1<J.length&&J[W+1]==="/")break;if(U==="{")Y++;else if(U==="}")Y--}if(Q===0){let W=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(W)Z.push(W[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let U=J.match(/(?:const|let|var)\s+(\w+)/);if(U)Z.push(U[1])}else{let U=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(U){let z=U[1].slice(1,-1).split(",").map((B)=>{let q=B.split(":");return(q.length>1?q[1]:q[0]).trim()}).filter((B)=>/^\w+$/.test(B));Z.push(...z)}}}}return[...new Set(Z)]}function az($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(X){if(!X.includes(":"))return X;let J=[],Q="",G=0,K=0,W=null;for(let U=0;U<X.length;U++){let _=X[U];if(W){if(Q+=_,_===W)W=null;continue}if(_==='"'||_==="'"||_==="`"){W=_,Q+=_;continue}if(_==="<")G++;else if(_===">"&&G>0)G--;else if(_==="(")K++;else if(_===")")K--;if(_===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=_}if(Q)J.push(Q);return J.map((U)=>{let _=U.trim(),z=_.startsWith("..."),B=z?_.slice(3):_,q=-1,j=0;for(let N=0;N<B.length;N++)if(B[N]==="<")j++;else if(B[N]===">")j--;else if(B[N]===":"&&j===0){q=N;break}if(q===-1)return U;let O=B.substring(0,q).trim().replace(/\?$/,""),V=B.substring(q+1),L=-1,F=0;for(let N=0;N<V.length;N++)if(V[N]==="<")F++;else if(V[N]===">")F--;else if(V[N]==="="&&F===0){L=N;break}let A=z?"...":"";if(L!==-1)return`${A}${O} = ${V.substring(L+1).trim()}`;return`${A}${O}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,W=G+1,U=0,_=null;while(W<Z.length&&K>0){let q=Z[W];if(_){if(q===_)_=null;W++;continue}if(q==='"'||q==="'"||q==="`"){_=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let z=Z.substring(G+1,W);if(!z.includes(":"))continue;let B=Y(z);Q.push({start:G+1,end:W,replacement:B})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Z=Z.substring(0,K)+U+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,J)=>{if(!J.includes(":"))return X;if(J.includes("{")||J.includes("}"))return X;return`(${J.split(",").map((G)=>{let[K,...W]=G.split("="),U=K.split(":")[0].trim();if(W.length>0)return`${U} = ${W.join("=").trim()}`;return U}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
2123
2123
 
2124
- `),Z}async function E0($,Z,Y,X={}){if(!$.trim())return;let J;try{let y=new Bun.Transpiler({loader:"ts",target:"browser",define:C1()}),u=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");u=u.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=y.transformSync(u)}catch{J=az($)}let Q={exports:{}},G=Q.exports,K=_7.cwd(),W={},U=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((y)=>y[1]).filter((y)=>!y.startsWith("node:")&&!y.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(y));for(let y of U)try{let u=A$.resolve(K,"node_modules",y),c=A$.join(u,"package.json"),h=JSON.parse($0("fs").readFileSync(c,"utf8")),p=h.main||"index.js";if(h.exports){let t=typeof h.exports==="string"?h.exports:h.exports["."];if(typeof t==="string")p=t;else if(t?.bun)p=t.bun;else if(t?.import)p=t.import;else if(t?.default)p=t.default}W[y]=await import(A$.resolve(u,p))}catch{}let _=(y)=>{if(W[y])return W[y];return $0(y)},z=Z.props||{},B=Object.assign((y)=>{if(!y)return z;let u={};for(let[c,h]of Object.entries(y)){let p=z[c];if(p!==void 0)u[c]=p;else if(typeof h==="function")u[c]=h();else u[c]=h}return u},z),q=(y)=>{if(!y)return z;let u={...z};for(let[c,h]of Object.entries(y)){let p=h&&typeof h==="object"&&!Array.isArray(h)?h:{type:h};if(u[c]===void 0&&p.default!==void 0)u[c]=typeof p.default==="function"?p.default():p.default}return u},j=()=>Z.slots||{},H=(y,u)=>{let c={...y};for(let[h,p]of Object.entries(u))if(c[h]===void 0)if(typeof p==="function")c[h]=p();else c[h]=p;return c},O=(y)=>{let u=()=>y;return u.set=(c)=>{},u.update=(c)=>{},u},V=(y)=>{let u,c=!1;return()=>{if(!c)try{u=y(),c=!0}catch{u=void 0}return u}},L=(y)=>{},F=(y)=>y(),A=(y)=>{},N=(y)=>{},w=(y)=>{},R=()=>{let y=Z.__stxServeContext,u=Z.__stxServeSearch??y?.search??"",c=y?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(u)),path:c,name:"",fullPath:c+u,hash:"",matched:[]}},T=()=>({push:(y)=>{},replace:(y)=>{},back:()=>{},forward:()=>{},go:(y)=>{}}),E=(y)=>{m4(y);let u=Z.__stx_runtime_head||{},c=y||{};Z.__stx_runtime_head={...u,...c.title&&{title:c.title},meta:[...u.meta||[],...c.meta||[]],link:[...u.link||[],...c.link||[]],script:[...u.script||[],...c.script||[]],htmlAttrs:{...u.htmlAttrs||{},...c.htmlAttrs||{}},bodyAttrs:{...u.bodyAttrs||{},...c.bodyAttrs||{}}}},I=(y)=>{X7(y);let u=H$();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...u.title&&{title:u.title},meta:u.meta?[...u.meta]:[]}},k=(y)=>({value:y}),S=(y)=>y,x=(y)=>({value:typeof y==="function"?y():y}),P=(y,u)=>{},C=(y)=>{},g=(y)=>{},s=(y)=>y?y():Promise.resolve(),m=(y)=>(u,...c)=>{},b=(y)=>{},d=(y,u)=>{},l=(y,u)=>u,r=()=>({value:"light"}),a=()=>({value:!1}),B0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},Q0=new Proxy(B0,{get(y,u){if(u in y)return y[u];return},set(y,u,c){return y[u]=c,!0}}),M0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},k0=console;try{let y=qZ(J,Y),u=new Set(Object.keys(z)),c=Object.keys(Z).filter((z0)=>!u.has(z0)&&z0!=="props"),h=c.map((z0)=>Z[z0]),p=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),t=[],n=[];for(let[z0,x0]of Object.entries(z)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(z0))continue;if(p.has(z0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${z0}\\b`).test(y))continue;t.push(z0),n.push(x0)}let S0=LT(y).map((z0)=>`module.exports.${z0} = typeof ${z0} !== 'undefined' ? ${z0} : module.exports.${z0};`).join(`
2125
- `),D0=Z.params??{},q0=[],Y1=[];for(let z0=0;z0<c.length;z0++){if(c[z0]==="params")continue;q0.push(c[z0]),Y1.push(h[z0])}let Z$=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...t,...q0,`return (async () => {
2124
+ `),Z}async function I0($,Z,Y,X={}){if(!$.trim())return;let J;try{let y=new Bun.Transpiler({loader:"ts",target:"browser",define:C1()}),u=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");u=u.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=y.transformSync(u)}catch{J=az($)}let Q={exports:{}},G=Q.exports,K=_7.cwd(),W={},U=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((y)=>y[1]).filter((y)=>!y.startsWith("node:")&&!y.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(y));for(let y of U)try{let u=A$.resolve(K,"node_modules",y),c=A$.join(u,"package.json"),h=JSON.parse($0("fs").readFileSync(c,"utf8")),p=h.main||"index.js";if(h.exports){let t=typeof h.exports==="string"?h.exports:h.exports["."];if(typeof t==="string")p=t;else if(t?.bun)p=t.bun;else if(t?.import)p=t.import;else if(t?.default)p=t.default}W[y]=await import(A$.resolve(u,p))}catch{}let _=(y)=>{if(W[y])return W[y];return $0(y)},z=Z.props||{},B=Object.assign((y)=>{if(!y)return z;let u={};for(let[c,h]of Object.entries(y)){let p=z[c];if(p!==void 0)u[c]=p;else if(typeof h==="function")u[c]=h();else u[c]=h}return u},z),q=(y)=>{if(!y)return z;let u={...z};for(let[c,h]of Object.entries(y)){let p=h&&typeof h==="object"&&!Array.isArray(h)?h:{type:h};if(u[c]===void 0&&p.default!==void 0)u[c]=typeof p.default==="function"?p.default():p.default}return u},j=()=>Z.slots||{},H=(y,u)=>{let c={...y};for(let[h,p]of Object.entries(u))if(c[h]===void 0)if(typeof p==="function")c[h]=p();else c[h]=p;return c},O=(y)=>{let u=()=>y;return u.set=(c)=>{},u.update=(c)=>{},u},V=(y)=>{let u,c=!1;return()=>{if(!c)try{u=y(),c=!0}catch{u=void 0}return u}},L=(y)=>{},F=(y)=>y(),A=(y)=>{},N=(y)=>{},w=(y)=>{},R=()=>{let y=Z.__stxServeContext,u=Z.__stxServeSearch??y?.search??"",c=y?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(u)),path:c,name:"",fullPath:c+u,hash:"",matched:[]}},T=()=>({push:(y)=>{},replace:(y)=>{},back:()=>{},forward:()=>{},go:(y)=>{}}),E=(y)=>{m4(y);let u=Z.__stx_runtime_head||{},c=y||{};Z.__stx_runtime_head={...u,...c.title&&{title:c.title},meta:[...u.meta||[],...c.meta||[]],link:[...u.link||[],...c.link||[]],script:[...u.script||[],...c.script||[]],htmlAttrs:{...u.htmlAttrs||{},...c.htmlAttrs||{}},bodyAttrs:{...u.bodyAttrs||{},...c.bodyAttrs||{}}}},I=(y)=>{X7(y);let u=H$();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...u.title&&{title:u.title},meta:u.meta?[...u.meta]:[]}},k=(y)=>({value:y}),S=(y)=>y,x=(y)=>({value:typeof y==="function"?y():y}),P=(y,u)=>{},C=(y)=>{},g=(y)=>{},s=(y)=>y?y():Promise.resolve(),m=(y)=>(u,...c)=>{},b=(y)=>{},d=(y,u)=>{},l=(y,u)=>u,r=()=>({value:"light"}),a=()=>({value:!1}),q0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},Q0=new Proxy(q0,{get(y,u){if(u in y)return y[u];return},set(y,u,c){return y[u]=c,!0}}),T0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},S0=console;try{let y=qZ(J,Y),u=new Set(Object.keys(z)),c=Object.keys(Z).filter((z0)=>!u.has(z0)&&z0!=="props"),h=c.map((z0)=>Z[z0]),p=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),t=[],i=[];for(let[z0,x0]of Object.entries(z)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(z0))continue;if(p.has(z0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${z0}\\b`).test(y))continue;t.push(z0),i.push(x0)}let k0=LT(y).map((z0)=>`module.exports.${z0} = typeof ${z0} !== 'undefined' ? ${z0} : module.exports.${z0};`).join(`
2125
+ `),F0=Z.params??{},B0=[],Y1=[];for(let z0=0;z0<c.length;z0++){if(c[z0]==="params")continue;B0.push(c[z0]),Y1.push(h[z0])}let Z$=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...t,...B0,`return (async () => {
2126
2126
  ${y}
2127
- ${S0}
2127
+ ${k0}
2128
2128
  return module.exports
2129
- })()`)(Q,G,_,z,B,q,H,O,V,L,F,A,N,w,R,T,E,I,k,S,x,P,C,g,s,m,b,j,d,l,r,a,Q0,M0,k0,B0.confirm,B0.alert,B0.fetch,D0,...n,...Y1);if(X.preserveExisting){for(let[z0,x0]of Object.entries(Z$))if(!(z0 in Z)||Z[z0]===void 0)Z[z0]=x0}else Object.assign(Z,Z$);for(let[z0,x0]of Object.entries(z))if(!(z0 in Z))Z[z0]=x0}catch(y){if(_7.env.STX_DEBUG){let u=y instanceof Error?y.message:String(y);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${u}`)}try{await wT(J,Z,Y)}catch(u){if(_7.env.STX_DEBUG){let c=u instanceof Error?u.message:String(u);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${c}`)}}}}function qZ($,Z){let Y=Z?A$.dirname(Z):_7.cwd(),X=$.split(`
2129
+ })()`)(Q,G,_,z,B,q,H,O,V,L,F,A,N,w,R,T,E,I,k,S,x,P,C,g,s,m,b,j,d,l,r,a,Q0,T0,S0,q0.confirm,q0.alert,q0.fetch,F0,...i,...Y1);if(X.preserveExisting){for(let[z0,x0]of Object.entries(Z$))if(!(z0 in Z)||Z[z0]===void 0)Z[z0]=x0}else Object.assign(Z,Z$);for(let[z0,x0]of Object.entries(z))if(!(z0 in Z))Z[z0]=x0}catch(y){if(_7.env.STX_DEBUG){let u=y instanceof Error?y.message:String(y);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${u}`)}try{await wT(J,Z,Y)}catch(u){if(_7.env.STX_DEBUG){let c=u instanceof Error?u.message:String(u);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${c}`)}}}}function qZ($,Z){let Y=Z?A$.dirname(Z):_7.cwd(),X=$.split(`
2130
2130
  `),J=[],Q=0;while(Q<X.length){let G=X[Q].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;Q<X.length;Q++){for(let W of X[Q])if(W==="{")K++;else if(W==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,W=!1;for(let U=Q;U<X.length&&!W;U++){let _=null,z=!1,B=X[U];for(let q=0;q<B.length;q++){let j=B[q];if(z){z=!1;continue}if(j==="\\"){z=!0;continue}if(_){if(j===_)_=null;continue}if(j==='"'||j==="'"||j==="`"){_=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=U+1,W=!0;break}}}}if(!W)Q=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),U=G.match(/^import\s+['"](.+)['"]/),_=(z)=>{if(z.startsWith("."))return A$.resolve(Y,z);return z};if(K){let[,z,B]=K,q=_(B);J.push(`const ${z} = await import('${q}')`),J.push(`module.exports.${z} = ${z};`)}else if(W){let[,z,B]=W,q=z.trim(),j=_(B);J.push(`const { ${q} } = await import('${j}')`);for(let H of q.split(",")){let O=H.trim().split(/\s+as\s+/).pop()?.trim();if(O)J.push(`module.exports.${O} = ${O};`)}}else if(U){let z=_(U[1]);J.push(`await import('${z}')`)}else J.push(G);Q++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))J.push(X[Q]),Q++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=pz(X,Q),{type:W,name:U,value:_}=K;J.push(`${W} ${U} = ${_};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=E9(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=pz(X,Q),{type:W,name:U,value:_}=K;J.push(`${W} ${U} = ${_};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=E9(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=X[Q].replace(/^(\s*)export\s+default\s+/,"$1"),W=[...X];W[Q]=K;let U=E9(W,Q);if(J.push(U.functionCode),U.name)J.push(`module.exports.default = ${U.name};`);Q=U.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");J.push(`module.exports.default = ${K};`),Q++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let W=K[1],U=X[Q].replace(/^export\s+/,""),_=0,z=Q;for(;z<X.length;z++){let B=X[z];for(let q of B)if(q==="{")_++;else if(q==="}")_--;if(z>Q)U+=`
2131
2131
  `+B;if(_<=0&&z>=Q)break}J.push(U),J.push(`module.exports.${W} = ${W};`),Q=z+1}else J.push(G),Q++}else if(G.includes("module.exports"))J.push(G),Q++;else if(G.trim()&&!G.startsWith("//"))J.push(G),Q++;else Q++}return VT(J.join(`
2132
2132
  `),Y)}function VT($,Z){let Y=$.length,X="",J=0,Q=null,G=!1,K=!1,W=0;while(J<Y){let U=$[J],_=$[J+1];if(G){if(X+=U,U===`
@@ -2136,7 +2136,7 @@ ${N}`,nextIndex:L}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}l
2136
2136
  ${$[W]}`,W++;else break}return K=K.trim().replace(/;$/,""),{type:J,name:Q,value:K,nextIndex:W}}function E9($,Z){let Y=$[Z].trim(),X=Y.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!X)throw Error(`Failed to parse function declaration: ${Y}`);let[,J]=X,Q=Y.replace(/^export\s+/,""),G=Z;if(AT(Y)){let K=NT($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:J,functionCode:Q,nextIndex:G}}function iz($){let Z=$.trim();if(Z.startsWith("{"))return u0(Z,"{","}",0)===-1;if(Z.startsWith("["))return u0(Z,"[","]",0)===-1;return!tz(Z)}function tz($){let Z={paren:0,bracket:0,brace:0},Y=null,X=0;for(let J=0;J<$.length;J++){let Q=$[J];if((J>0?$[J-1]:"")==="\\"&&Y)continue;if((Q==='"'||Q==="'")&&!Y){Y=Q;continue}if(Q===Y&&Y!=="`"){Y=null;continue}if(Q==="`"&&!Y){Y="`";continue}if(Q==="`"&&Y==="`"&&X===0){Y=null;continue}if(Y==="`"&&Q==="$"&&$[J+1]==="{"){X++,J++;continue}if(X>0&&Q==="{"){X++;continue}if(X>0&&Q==="}"){X--;continue}if(Y)continue;if(Q==="(")Z.paren++;else if(Q===")")Z.paren--;else if(Q==="[")Z.bracket++;else if(Q==="]")Z.bracket--;else if(Q==="{")Z.brace++;else if(Q==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&Y===null}function AT($){let Z=$.indexOf("{");if(Z===-1)return!0;return u0($,"{","}",Z)===-1}function nz($,Z,Y){let X=Y,J=Z+1;while(J<$.length&&!tz(X)){let Q=$[J];X+=`
2137
2137
  ${Q}`,J++}while(J<$.length){let Q=$[J].trim();if(Q.startsWith(".")||Q.startsWith("?."))X+=`
2138
2138
  ${$[J]}`,J++;else break}return{value:X,nextIndex:J}}function NT($,Z,Y){let X=Y,J=Z+1;while(J<$.length){let Q=X.indexOf("{");if(Q!==-1){if(u0(X,"{","}",Q)!==-1)break}let G=$[J];X+=`
2139
- ${G}`,J++}return{functionCode:X,nextIndex:J}}function rz($,Z){let Y=L0($,Z)??L0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{..._7.env}})};try{return Function(...Object.keys(X),`'use strict'; return (${$});`)(...Object.values(X))}catch{try{return Function(...Object.keys(X),`'use strict'; return ${$};`)(...Object.values(X))}catch{return}}}async function wT($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of X){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=rz(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let J=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of J){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=rz(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function I9($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",X=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:X}}function D9($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var a4=D(()=>{c4();N6();p0()});var QB={};e(QB,{processLoops:()=>VZ});function TT($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let _=X.substring(K+1,U),z=U+1,B=_.match(/^\s*['"]([^'"]+)['"]/);if(!B)continue;let q=B[1],j=_.slice(B[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let V=d0(O,Z),L=JSON.stringify(V),F=`@component('${q}', ${L})`;Q.push({start:G,end:z,replacement:F})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}return X}function HZ($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,_=null,z=!1;while(U<X.length&&W>0){let j=X[U];if(z){z=!1,U++;continue}if(j==="\\"&&_){z=!0,U++;continue}if(_){if(j===_)_=null;U++;continue}if(j==='"'||j==="'"||j==="`"){_=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let B=X.substring(K+1,U),q=Y(B);X=X.substring(0,G)+q+X.substring(U+1)}return X}function ET($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,J)=>{if(J in Z)return`:${J}="${J}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,J,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);N3(Q);let U=w0(Q,G)(...K),_=JSON.stringify(U),z=Buffer.from(_,"utf8").toString("base64");return`__stx_${J}="${z}"`}catch(G){return X}}),Y}function IT($,Z){let Y=$;return Y=HZ(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(N0(Q)){let K=w0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(L0(Q,Z));return G?OZ:""}catch{return""}}),Y=HZ(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(N0(Q)){let K=w0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(L0(Q,Z));return G?LZ:""}catch{return""}}),Y}function DT($){let Z=$;return Z=Z.replace(/@break(?!\()/g,OZ),Z=Z.replace(/@continue(?!\()/g,LZ),Z}function ez($){let Z=$.includes(OZ),Y=Z?$.substring(0,$.indexOf(OZ)):$;return{hasBreak:Z,content:Y}}function $B($){let Z=$.includes(LZ),Y=Z?$.substring(0,$.indexOf(LZ)):$;return{hasContinue:Z,content:Y}}function YB($){let Z=$;return Z=HZ(Z,"@break",(Y)=>{let X=Y.trim();if(!w3(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=HZ(Z,"@continue",(Y)=>{let X=Y.trim();if(!w3(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function kT($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((_,z)=>_.pos-z.pos);let K=[],W=0;for(let _ of X)W+=_.delta,K.push({pos:_.pos,depth:W});function U(_){let z=0,B=K.length-1,q=0;while(z<=B){let j=z+B>>1;if(K[j].pos<=_)q=K[j].depth,z=j+1;else B=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let _=Y.index,z=Y.index+Y[0].length-1,B=1,q=z+1,j=-1;while(q<$.length&&B>0){if($[q]==="(")B++;else if($[q]===")"){if(B--,B===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(z+1,j),O=H.indexOf(" as ");if(O===-1)continue;let V=H.substring(0,O).trim(),L=H.substring(O+4).trim(),F=j+1,A=1,N=F,w=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(A>0&&N<$.length){w.lastIndex=N,R.lastIndex=N;let P=w.exec($),C=R.exec($);if(!C)break;if(P&&P.index<C.index)A++,N=P.index+P[0].length;else{if(A--,A===0){T=C.index;break}N=C.index+11}}if(T===-1)continue;let E=$.substring(F,T),I=T+11,k=-1,S=0,x=0;while(x<E.length){let P=E.indexOf("@",x);if(P===-1)break;let C=E.substring(P);if(/^@forelse\s*\(/.test(C))S++,x=P+1;else if(C.startsWith("@endforelse"))S--,x=P+11;else if(S===0&&C.startsWith("@empty")){if(E.length<=P+6||!/[a-z]/i.test(E[P+6])){k=P;break}x=P+1}else x=P+1}if(k===-1)continue;return{start:_,end:I,arrayExpr:V,itemVar:L,foreachContent:E.substring(0,k),emptyContent:E.substring(k+6)}}return null}function ZB($,Z){let Y=$;while(!0){let X=kT(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(N0(G))_=w0(G,Object.keys(Z))(...Object.values(Z));else _=L0(G,Z);let z;if(!Array.isArray(_)||_.length===0)z=U;else z=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+z+Y.substring(Q)}catch(_){let z=_ instanceof Error?_.message:String(_),B=U0("Forelse",`Error in @forelse(${G} as ${K}): ${z}`,J0.EVALUATION_ERROR);Y=Y.substring(0,J)+B+Y.substring(Q)}}return Y}function VZ($,Z,Y,X){let J=$;J=ZB(J,Z);function Q(W){let U=/@foreach\s*\(/g,_;while((_=U.exec(W))!==null){let z=_.index,B=_.index+_[0].length-1,q=1,j=B+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(B+1,H),V=O.indexOf(" as ");if(V===-1)continue;let L=z,F=O.substring(0,V),A=O.substring(V+4),N=H+1,w=1,R=N,T=/@foreach\s*\(/g,E=/@endforeach/g;while(w>0&&R<W.length){T.lastIndex=R,E.lastIndex=R;let I=T.exec(W),k=E.exec(W);if(!k)break;if(I&&I.index<k.index)w++,R=I.index+I[0].length;else{if(w--,w===0){let S=W.substring(N,k.index),x=k.index+11;return{start:L,end:x,arrayExpr:F,itemVar:A,content:S}}R=k.index+11}}}return null}function G(W,U){let _=W;while(!0){let z=Q(_);if(!z)break;let{start:B,end:q,arrayExpr:j,itemVar:H,content:O}=z;try{let V=j.trim(),L;if(N0(V))L=w0(V,Object.keys(U))(...Object.values(U));else L=L0(V,U);let F=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),F=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),F=!0;else{let k=U0("Foreach",`Error in @foreach: ${V} is not iterable`,J0.TYPE_ERROR);_=_.substring(0,B)+k+_.substring(q);continue}let A=X?.loops?.useAltLoopVariable??MT,N=H.trim(),w=null,R,T=!1;if(N.includes("=>")){let k=N.split("=>").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])w=k[0],R=k[1];else R=N}else if(!N.startsWith("[")&&!N.startsWith("{")&&N.includes(",")){let k=N.split(",").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])R=k[0],w=k[1],T=!0;else R=N}else R=N;let E="",I=L;for(let k=0;k<I.length;k++){let S=I[k],x={index:k,iteration:k+1,first:k===0,last:k===I.length-1,count:I.length},P={...U,loop:x,$loop:x};if(R.startsWith("[")&&R.endsWith("]")){let m=R.slice(1,-1).split(",").map((b)=>b.trim());if(Array.isArray(S))m.forEach((b,d)=>{if(b)P[b]=S[d]});else P[R]=S}else P[R]=S;if(w)if(!T&&F&&Array.isArray(S)&&S.length===2)P[w]=S[0],P[R]=S[1];else P[w]=k;let C=IT(O,P),g=$B(C);if(g.hasContinue){E+=g.content;continue}let s=ez(C);if(s.hasBreak){E+=s.content;break}if(C=ZB(C,P),C=G(C,P),C=T6(C,P,Y),C=DT(C),s=ez(C),s.hasBreak){E+=s.content;break}if(g=$B(C),g.hasContinue){E+=g.content;continue}C=j1(C,P,Y),C=ET(C,P),C=TT(C,P),E+=C}_=_.substring(0,B)+E+_.substring(q)}catch(V){let L=U0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${V instanceof Error?V.message:String(V)}`,J0.EVALUATION_ERROR);_=_.substring(0,B)+L+_.substring(q)}}return _}J=G(J,Z),J=JB(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??RT;return J=bT(J,Z,K),J}function XB($){return w3($)}function JB($,Z,Y,X){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=u0(J,"(",")",W);if(U===-1)break;let _=J.slice(W+1,U),z=U+1,B=Z7(J.slice(K),"for","endfor");if(B.length===0)break;let q=B[0].content,j=K+B[0].end;if(!XB(_)){let H=U0("For",`Unsafe expression in @for: ${_}`,J0.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=ST(_),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let w=CT({forExpr:_,content:q,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+w+J.substring(j),Q=!0;continue}let V=Object.keys(Z),L=Object.values(Z),F=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,R)=>{return`\${${R}}`});F=YB(F);let N=Function(...V,`
2139
+ ${G}`,J++}return{functionCode:X,nextIndex:J}}function rz($,Z){let Y=L0($,Z)??L0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{..._7.env}})};try{return Function(...Object.keys(X),`'use strict'; return (${$});`)(...Object.values(X))}catch{try{return Function(...Object.keys(X),`'use strict'; return ${$};`)(...Object.values(X))}catch{return}}}async function wT($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of X){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=rz(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let J=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of J){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=rz(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function I9($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",X=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:X}}function D9($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var a4=D(()=>{c4();N6();p0()});var QB={};e(QB,{processLoops:()=>VZ});function TT($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let _=X.substring(K+1,U),z=U+1,B=_.match(/^\s*['"]([^'"]+)['"]/);if(!B)continue;let q=B[1],j=_.slice(B[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let V=d0(O,Z),L=JSON.stringify(V),F=`@component('${q}', ${L})`;Q.push({start:G,end:z,replacement:F})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}return X}function HZ($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,_=null,z=!1;while(U<X.length&&W>0){let j=X[U];if(z){z=!1,U++;continue}if(j==="\\"&&_){z=!0,U++;continue}if(_){if(j===_)_=null;U++;continue}if(j==='"'||j==="'"||j==="`"){_=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let B=X.substring(K+1,U),q=Y(B);X=X.substring(0,G)+q+X.substring(U+1)}return X}function ET($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,J)=>{if(J in Z)return`:${J}="${J}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,J,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);N3(Q);let U=R0(Q,G)(...K),_=JSON.stringify(U),z=Buffer.from(_,"utf8").toString("base64");return`__stx_${J}="${z}"`}catch(G){return X}}),Y}function IT($,Z){let Y=$;return Y=HZ(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(w0(Q)){let K=R0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(L0(Q,Z));return G?OZ:""}catch{return""}}),Y=HZ(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(w0(Q)){let K=R0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(L0(Q,Z));return G?LZ:""}catch{return""}}),Y}function DT($){let Z=$;return Z=Z.replace(/@break(?!\()/g,OZ),Z=Z.replace(/@continue(?!\()/g,LZ),Z}function ez($){let Z=$.includes(OZ),Y=Z?$.substring(0,$.indexOf(OZ)):$;return{hasBreak:Z,content:Y}}function $B($){let Z=$.includes(LZ),Y=Z?$.substring(0,$.indexOf(LZ)):$;return{hasContinue:Z,content:Y}}function YB($){let Z=$;return Z=HZ(Z,"@break",(Y)=>{let X=Y.trim();if(!w3(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=HZ(Z,"@continue",(Y)=>{let X=Y.trim();if(!w3(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function kT($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((_,z)=>_.pos-z.pos);let K=[],W=0;for(let _ of X)W+=_.delta,K.push({pos:_.pos,depth:W});function U(_){let z=0,B=K.length-1,q=0;while(z<=B){let j=z+B>>1;if(K[j].pos<=_)q=K[j].depth,z=j+1;else B=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let _=Y.index,z=Y.index+Y[0].length-1,B=1,q=z+1,j=-1;while(q<$.length&&B>0){if($[q]==="(")B++;else if($[q]===")"){if(B--,B===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(z+1,j),O=H.indexOf(" as ");if(O===-1)continue;let V=H.substring(0,O).trim(),L=H.substring(O+4).trim(),F=j+1,A=1,N=F,w=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(A>0&&N<$.length){w.lastIndex=N,R.lastIndex=N;let P=w.exec($),C=R.exec($);if(!C)break;if(P&&P.index<C.index)A++,N=P.index+P[0].length;else{if(A--,A===0){T=C.index;break}N=C.index+11}}if(T===-1)continue;let E=$.substring(F,T),I=T+11,k=-1,S=0,x=0;while(x<E.length){let P=E.indexOf("@",x);if(P===-1)break;let C=E.substring(P);if(/^@forelse\s*\(/.test(C))S++,x=P+1;else if(C.startsWith("@endforelse"))S--,x=P+11;else if(S===0&&C.startsWith("@empty")){if(E.length<=P+6||!/[a-z]/i.test(E[P+6])){k=P;break}x=P+1}else x=P+1}if(k===-1)continue;return{start:_,end:I,arrayExpr:V,itemVar:L,foreachContent:E.substring(0,k),emptyContent:E.substring(k+6)}}return null}function ZB($,Z){let Y=$;while(!0){let X=kT(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(w0(G))_=R0(G,Object.keys(Z))(...Object.values(Z));else _=L0(G,Z);let z;if(!Array.isArray(_)||_.length===0)z=U;else z=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+z+Y.substring(Q)}catch(_){let z=_ instanceof Error?_.message:String(_),B=U0("Forelse",`Error in @forelse(${G} as ${K}): ${z}`,J0.EVALUATION_ERROR);Y=Y.substring(0,J)+B+Y.substring(Q)}}return Y}function VZ($,Z,Y,X){let J=$;J=ZB(J,Z);function Q(W){let U=/@foreach\s*\(/g,_;while((_=U.exec(W))!==null){let z=_.index,B=_.index+_[0].length-1,q=1,j=B+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(B+1,H),V=O.indexOf(" as ");if(V===-1)continue;let L=z,F=O.substring(0,V),A=O.substring(V+4),N=H+1,w=1,R=N,T=/@foreach\s*\(/g,E=/@endforeach/g;while(w>0&&R<W.length){T.lastIndex=R,E.lastIndex=R;let I=T.exec(W),k=E.exec(W);if(!k)break;if(I&&I.index<k.index)w++,R=I.index+I[0].length;else{if(w--,w===0){let S=W.substring(N,k.index),x=k.index+11;return{start:L,end:x,arrayExpr:F,itemVar:A,content:S}}R=k.index+11}}}return null}function G(W,U){let _=W;while(!0){let z=Q(_);if(!z)break;let{start:B,end:q,arrayExpr:j,itemVar:H,content:O}=z;try{let V=j.trim(),L;if(w0(V))L=R0(V,Object.keys(U))(...Object.values(U));else L=L0(V,U);let F=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),F=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),F=!0;else{let k=U0("Foreach",`Error in @foreach: ${V} is not iterable`,J0.TYPE_ERROR);_=_.substring(0,B)+k+_.substring(q);continue}let A=X?.loops?.useAltLoopVariable??MT,N=H.trim(),w=null,R,T=!1;if(N.includes("=>")){let k=N.split("=>").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])w=k[0],R=k[1];else R=N}else if(!N.startsWith("[")&&!N.startsWith("{")&&N.includes(",")){let k=N.split(",").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])R=k[0],w=k[1],T=!0;else R=N}else R=N;let E="",I=L;for(let k=0;k<I.length;k++){let S=I[k],x={index:k,iteration:k+1,first:k===0,last:k===I.length-1,count:I.length},P={...U,loop:x,$loop:x};if(R.startsWith("[")&&R.endsWith("]")){let m=R.slice(1,-1).split(",").map((b)=>b.trim());if(Array.isArray(S))m.forEach((b,d)=>{if(b)P[b]=S[d]});else P[R]=S}else P[R]=S;if(w)if(!T&&F&&Array.isArray(S)&&S.length===2)P[w]=S[0],P[R]=S[1];else P[w]=k;let C=IT(O,P),g=$B(C);if(g.hasContinue){E+=g.content;continue}let s=ez(C);if(s.hasBreak){E+=s.content;break}if(C=ZB(C,P),C=G(C,P),C=T6(C,P,Y),C=DT(C),s=ez(C),s.hasBreak){E+=s.content;break}if(g=$B(C),g.hasContinue){E+=g.content;continue}C=j1(C,P,Y),C=ET(C,P),C=TT(C,P),E+=C}_=_.substring(0,B)+E+_.substring(q)}catch(V){let L=U0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${V instanceof Error?V.message:String(V)}`,J0.EVALUATION_ERROR);_=_.substring(0,B)+L+_.substring(q)}}return _}J=G(J,Z),J=JB(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??RT;return J=bT(J,Z,K),J}function XB($){return w3($)}function JB($,Z,Y,X){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=u0(J,"(",")",W);if(U===-1)break;let _=J.slice(W+1,U),z=U+1,B=Z7(J.slice(K),"for","endfor");if(B.length===0)break;let q=B[0].content,j=K+B[0].end;if(!XB(_)){let H=U0("For",`Unsafe expression in @for: ${_}`,J0.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=ST(_),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let w=CT({forExpr:_,content:q,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+w+J.substring(j),Q=!0;continue}let V=Object.keys(Z),L=Object.values(Z),F=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,R)=>{return`\${${R}}`});F=YB(F);let N=Function(...V,`
2140
2140
  let result = '';
2141
2141
  for (${_}) {
2142
2142
  result += \`${F}\`;
@@ -2193,20 +2193,20 @@ ${xT($).split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>` try { __scopeR
2193
2193
  } finally {
2194
2194
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
2195
2195
  }
2196
- })();`}function fT($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function gT(){S9.clear()}function hT($){if($.__onceStore instanceof Set)return $.__onceStore;return S9}async function AZ($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||b0.join(b0.dirname(Y),"partials");if(G&&!b0.isAbsolute(G))G=b0.resolve(process.cwd(),G);let K=PT($,"@partial","@include"),W=hT(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let V=H.trim(),L=`${Y}:${V}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let A=K.substring(V+1,F-1),N=A.match(/^\s*['"]([^'"]+)['"]/);if(!N){j.lastIndex=F;continue}let w=N[1],R=U(w,G,Y),T="";if(R&&await Bun.file(R).exists())J.add(R),T=`@include(${A})`;K=K.substring(0,O)+T+K.substring(F),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=O.exec(K))!==null){let L=V.index,F=L+V[0].length-1,A=1,N=F+1;while(N<K.length&&A>0){if(K[N]==="(")A++;else if(K[N]===")")A--;N++}if(A!==0)break;let w=K.substring(F+1,N-1),R=k9(w,0);if(R===-1){O.lastIndex=N;continue}let T=w.substring(0,R).trim(),E=w.substring(R+1).trim(),I=E.match(/^\s*['"]([^'"]+)['"]/);if(!I){O.lastIndex=N;continue}let k=I[1],S=E.substring(I[0].length),x,P=k9(S,0);if(P!==-1)x=S.substring(P+1).trim();try{let C=`Boolean(${T})`,g;if(N0(C)){let b=w0(C,Object.keys(Z));g=Boolean(b(...Object.values(Z)))}else g=Boolean(L0(C,Z));let s=H?!g:g,m="";if(s){let b=U(k,G,Y);if(b&&await Bun.file(b).exists())J.add(b);m=`@include('${k}'${x?`, ${x}`:""})`}K=K.substring(0,L)+m+K.substring(N),O.lastIndex=0}catch(C){let g=C instanceof Error?C.message:String(C),s=R0("Include",`Error evaluating ${j} condition: ${g}`,Y,$,L);K=K.substring(0,L)+s+K.substring(N),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let[,R,T,E,I]=w;try{let k,S=T.trim();if(N0(S))k=w0(S,Object.keys(Z))(...Object.values(Z));else k=L0(S,Z);let x="";if(Array.isArray(k)&&k.length>0)for(let P of k){let C={...Z,[E]:P},g=await z(R,C,$,O);x+=g}else if(I)x=await z(I,{},$,O);K=K.substring(0,O)+x+K.substring(F+1),j.lastIndex=0}catch(k){let S=k instanceof Error?k.message:String(k);K=K.substring(0,O)+R0("Each",`Error in @each: ${S}`,Y,$,O)+K.substring(F+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let R=w[1],T=A.slice(w[0].length),E,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let x=1,P=1;while(P<T.length&&x>0){if(T[P]==="{")x++;else if(T[P]==="}"){if(x--,x===0)break}P++}E=T.substring(0,P+1),T=T.slice(P+1)}let k,S=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(S)k=S[1];try{let x=JSON.parse(R.replace(/'/g,'"')),P={};if(E)try{P=d0(E,Z)}catch(g){let s=g instanceof Error?g.message:String(g);if(X.debug){let m=R0("Include",`Error parsing includeFirst variables: ${s}`,Y,$,O,N);K=K.replace(N,()=>m)}else K=K.replace(N,()=>k||"");continue}let C=!1;for(let g of x){let s=U(g,G,Y);if(!s)continue;if(await X0(s)){let m=await z(g,P,$,O);K=K.replace(N,()=>m),C=!0;break}}if(!C)if(k!==void 0)K=K.replace(N,()=>k);else if(X.debug){let g=R0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,N);K=K.replace(N,()=>g)}else K=K.replace(N,"")}catch(x){let P=x instanceof Error?x.message:String(x),C=R0("Include",`Error processing @includeFirst: ${P}`,Y,$,O,N);K=K.replace(N,()=>C)}j.lastIndex=0}}function U(j,H,O){try{let V=j;if(!j.endsWith(".stx"))V=`${j}.stx`;let L=b0.resolve(H),F=b0.resolve(b0.dirname(O)),A;if(!V.startsWith("./")&&!V.startsWith("../"))A=b0.resolve(H,V);else A=b0.resolve(F,V);let N=b0.normalize(A),w=N.startsWith(L+b0.sep)||N===L,R=N.startsWith(F+b0.sep)||N===F,T=!1,E=b0.dirname(F);if(N.startsWith(E+b0.sep)){if(!b0.relative(E,N).split(b0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))T=!0}if(!w&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${L}, ${F}`),null;return N}catch(V){return console.error(`Error resolving path ${j}: ${V}`),null}}let _=b0.resolve(Y);Q.add(_);async function z(j,H={},O,V){let L=U(j,G,Y);if(!L)return R0("Include",`Could not resolve path for include: ${j}`,Y,O,V);let F=b0.resolve(L);if(Q.has(F)){let A=[...Q,F].map((N)=>b0.basename(N)).join(" -> ");return R0("Include",`Circular include detected: ${A}`,Y,O,V)}try{J.add(L);let A;if(!A)try{A=await Bun.file(L).text()}catch(m){let b=m instanceof Error?m.message:String(m);return R0("Include",`Error loading include file ${j}: ${b}`,Y,O,V)}if(A&&A.includes("@stream")){let{processStreamDirectives:m}=await Promise.resolve().then(() => (p4(),D6));A=m(A,Z)}if(A&&(X.debug||!_$()&&!a5()))try{let{warnUnbalancedTags:m}=await Promise.resolve().then(() => (tJ(),Nz));m(A,L)}catch{}let N=A;try{let{processESImports:m}=await Promise.resolve().then(() => (M9(),lz));await m(A,Z,L,X,J)}catch(m){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,m instanceof Error?m.message:m)}let w=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)N=w[1].trim();let T=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(T)E=`<style${T[1]}>${T[2]}</style>`;N=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),N=N.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[m,b]of Object.entries(H))I[m]=b;let k=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...A.matchAll(k)],x="",P=null;for(let m of S){let b=m[1]||"",d=m[2]||"",l=b.includes("server"),r=P4(b),a="";try{let{extractAndStripCssImports:Q0,renderVendorStyleTags:M0}=await Promise.resolve().then(() => (R6(),VU)),k0=Q0(d,{filePath:L,projectRoot:process.cwd()});d=k0.code,a=M0(k0.styles)}catch(Q0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${L}:`,Q0 instanceof Error?Q0.message:Q0)}if(r&&d.trim())d=y4(d);if(!l)try{let{hasUserImports:Q0,bundleClientScript:M0}=await Promise.resolve().then(() => (A3(),F3));if(Q0(d))d=await M0(d,L,{projectRoot:process.cwd()})}catch(Q0){if(X.debug)console.warn(`[stx] bundler skipped for ${L}:`,Q0 instanceof Error?Q0.message:Q0)}let B0=yT(d);if(B0&&!l){P=`stx_scope_${b0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++GB}`;let Q0=W4(d),M0=vT(Q0,P);x+=`${a}<script data-stx-scoped>${M0}</script>
2197
- `;continue}if(l)try{let{extractVariables:Q0}=await Promise.resolve().then(() => (a4(),jZ));await Q0(d,I,L)}catch(Q0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,Q0)}if(!l&&!B0){let Q0=b.replace(/\bclient\b/i,"").trim();P=`stx_scope_${b0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++GB}`;let M0=W4(d),k0=`
2196
+ })();`}function fT($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function gT(){S9.clear()}function hT($){if($.__onceStore instanceof Set)return $.__onceStore;return S9}async function AZ($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||b0.join(b0.dirname(Y),"partials");if(G&&!b0.isAbsolute(G))G=b0.resolve(process.cwd(),G);let K=PT($,"@partial","@include"),W=hT(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let V=H.trim(),L=`${Y}:${V}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let A=K.substring(V+1,F-1),N=A.match(/^\s*['"]([^'"]+)['"]/);if(!N){j.lastIndex=F;continue}let w=N[1],R=U(w,G,Y),T="";if(R&&await Bun.file(R).exists())J.add(R),T=`@include(${A})`;K=K.substring(0,O)+T+K.substring(F),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=O.exec(K))!==null){let L=V.index,F=L+V[0].length-1,A=1,N=F+1;while(N<K.length&&A>0){if(K[N]==="(")A++;else if(K[N]===")")A--;N++}if(A!==0)break;let w=K.substring(F+1,N-1),R=k9(w,0);if(R===-1){O.lastIndex=N;continue}let T=w.substring(0,R).trim(),E=w.substring(R+1).trim(),I=E.match(/^\s*['"]([^'"]+)['"]/);if(!I){O.lastIndex=N;continue}let k=I[1],S=E.substring(I[0].length),x,P=k9(S,0);if(P!==-1)x=S.substring(P+1).trim();try{let C=`Boolean(${T})`,g;if(w0(C)){let b=R0(C,Object.keys(Z));g=Boolean(b(...Object.values(Z)))}else g=Boolean(L0(C,Z));let s=H?!g:g,m="";if(s){let b=U(k,G,Y);if(b&&await Bun.file(b).exists())J.add(b);m=`@include('${k}'${x?`, ${x}`:""})`}K=K.substring(0,L)+m+K.substring(N),O.lastIndex=0}catch(C){let g=C instanceof Error?C.message:String(C),s=M0("Include",`Error evaluating ${j} condition: ${g}`,Y,$,L);K=K.substring(0,L)+s+K.substring(N),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let[,R,T,E,I]=w;try{let k,S=T.trim();if(w0(S))k=R0(S,Object.keys(Z))(...Object.values(Z));else k=L0(S,Z);let x="";if(Array.isArray(k)&&k.length>0)for(let P of k){let C={...Z,[E]:P},g=await z(R,C,$,O);x+=g}else if(I)x=await z(I,{},$,O);K=K.substring(0,O)+x+K.substring(F+1),j.lastIndex=0}catch(k){let S=k instanceof Error?k.message:String(k);K=K.substring(0,O)+M0("Each",`Error in @each: ${S}`,Y,$,O)+K.substring(F+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let R=w[1],T=A.slice(w[0].length),E,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let x=1,P=1;while(P<T.length&&x>0){if(T[P]==="{")x++;else if(T[P]==="}"){if(x--,x===0)break}P++}E=T.substring(0,P+1),T=T.slice(P+1)}let k,S=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(S)k=S[1];try{let x=JSON.parse(R.replace(/'/g,'"')),P={};if(E)try{P=d0(E,Z)}catch(g){let s=g instanceof Error?g.message:String(g);if(X.debug){let m=M0("Include",`Error parsing includeFirst variables: ${s}`,Y,$,O,N);K=K.replace(N,()=>m)}else K=K.replace(N,()=>k||"");continue}let C=!1;for(let g of x){let s=U(g,G,Y);if(!s)continue;if(await X0(s)){let m=await z(g,P,$,O);K=K.replace(N,()=>m),C=!0;break}}if(!C)if(k!==void 0)K=K.replace(N,()=>k);else if(X.debug){let g=M0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,N);K=K.replace(N,()=>g)}else K=K.replace(N,"")}catch(x){let P=x instanceof Error?x.message:String(x),C=M0("Include",`Error processing @includeFirst: ${P}`,Y,$,O,N);K=K.replace(N,()=>C)}j.lastIndex=0}}function U(j,H,O){try{let V=j;if(!j.endsWith(".stx"))V=`${j}.stx`;let L=b0.resolve(H),F=b0.resolve(b0.dirname(O)),A;if(!V.startsWith("./")&&!V.startsWith("../"))A=b0.resolve(H,V);else A=b0.resolve(F,V);let N=b0.normalize(A),w=N.startsWith(L+b0.sep)||N===L,R=N.startsWith(F+b0.sep)||N===F,T=!1,E=b0.dirname(F);if(N.startsWith(E+b0.sep)){if(!b0.relative(E,N).split(b0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))T=!0}if(!w&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${L}, ${F}`),null;return N}catch(V){return console.error(`Error resolving path ${j}: ${V}`),null}}let _=b0.resolve(Y);Q.add(_);async function z(j,H={},O,V){let L=U(j,G,Y);if(!L)return M0("Include",`Could not resolve path for include: ${j}`,Y,O,V);let F=b0.resolve(L);if(Q.has(F)){let A=[...Q,F].map((N)=>b0.basename(N)).join(" -> ");return M0("Include",`Circular include detected: ${A}`,Y,O,V)}try{J.add(L);let A;if(!A)try{A=await Bun.file(L).text()}catch(m){let b=m instanceof Error?m.message:String(m);return M0("Include",`Error loading include file ${j}: ${b}`,Y,O,V)}if(A&&A.includes("@stream")){let{processStreamDirectives:m}=await Promise.resolve().then(() => (p4(),D6));A=m(A,Z)}if(A&&(X.debug||!_$()&&!a5()))try{let{warnUnbalancedTags:m}=await Promise.resolve().then(() => (tJ(),Nz));m(A,L)}catch{}let N=A;try{let{processESImports:m}=await Promise.resolve().then(() => (M9(),lz));await m(A,Z,L,X,J)}catch(m){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,m instanceof Error?m.message:m)}let w=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(w)N=w[1].trim();let T=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(T)E=`<style${T[1]}>${T[2]}</style>`;N=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),N=N.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[m,b]of Object.entries(H))I[m]=b;let k=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...A.matchAll(k)],x="",P=null;for(let m of S){let b=m[1]||"",d=m[2]||"",l=b.includes("server"),r=P4(b),a="";try{let{extractAndStripCssImports:Q0,renderVendorStyleTags:T0}=await Promise.resolve().then(() => (R6(),VU)),S0=Q0(d,{filePath:L,projectRoot:process.cwd()});d=S0.code,a=T0(S0.styles)}catch(Q0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${L}:`,Q0 instanceof Error?Q0.message:Q0)}if(r&&d.trim())d=y4(d);if(!l)try{let{hasUserImports:Q0,bundleClientScript:T0}=await Promise.resolve().then(() => (A3(),F3));if(Q0(d))d=await T0(d,L,{projectRoot:process.cwd()})}catch(Q0){if(X.debug)console.warn(`[stx] bundler skipped for ${L}:`,Q0 instanceof Error?Q0.message:Q0)}let q0=yT(d);if(q0&&!l){P=`stx_scope_${b0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++GB}`;let Q0=W4(d),T0=vT(Q0,P);x+=`${a}<script data-stx-scoped>${T0}</script>
2197
+ `;continue}if(l)try{let{extractVariables:Q0}=await Promise.resolve().then(() => (a4(),jZ));await Q0(d,I,L)}catch(Q0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,Q0)}if(!l&&!q0){let Q0=b.replace(/\bclient\b/i,"").trim();P=`stx_scope_${b0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++GB}`;let T0=W4(d),S0=`
2198
2198
  if (!window.stx._scopes) window.stx._scopes = {};
2199
2199
  window.stx._scopes['${P}'] = { __destroyCallbacks: __destroyHooks };
2200
- `,y=KB(M0,k0);x+=`${a}<script data-stx-scoped${Q0?` ${Q0}`:""}>${y}</script>
2200
+ `,y=KB(T0,S0);x+=`${a}<script data-stx-scoped${Q0?` ${Q0}`:""}>${y}</script>
2201
2201
  `}}if(P){let m=fT(N,P);if(N=m.html,m.mergedIntoExisting)x=x.replace(`window.stx._scopes['${P}']`,`window.stx._scopes['${m.mergedIntoExisting}']`),P=m.mergedIntoExisting}if(N.includes("@include")||N.includes("@partial"))N=await AZ(N,I,L,X,J,Q);let{processLoops:C}=await Promise.resolve().then(() => (FZ(),QB)),g=C(N,I,L);g=T6(g,I,L);let s=M6(A);if(g=j1(g,I,L,{forceSignals:s}),E)g+=`
2202
2202
  `+E;if(x)g+=`
2203
- `+x;return g}catch(A){let N=A instanceof Error?A.message:String(A);return R0("Include",`Error processing include ${j}: ${N}`,Y,O,V)}}let B=/@include\s*\(/g,q;while((q=B.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,V=H+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let L=K.substring(j,V),F=K.substring(H+1,V-1),A=F.match(/^\s*['"]([^'"]+)['"]/);if(!A){B.lastIndex=V;continue}let N=A[1],w,R=F.substring(A[0].length),T=k9(R,0);if(T!==-1)w=R.substring(T+1).trim();let E={};if(w)try{E=d0(w,Z)}catch(k){let S=k instanceof Error?k.message:String(k);K=K.replace(L,R0("Include",`Error parsing include variables for ${N}: ${S}`,Y,$,j)),B.lastIndex=0;continue}let I=await z(N,E,$,j);K=K.substring(0,j)+I+K.substring(V),B.lastIndex=0}return K}function NZ($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let _=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),z=W.match(_);if(!z||z.index===void 0)break;let B=z.index,q=z[1],j=B+z[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),V=1,L=j,F=-1;while(V>0&&L<W.length){let N=W.slice(L),w=N.match(H),R=N.match(O),T=w?L+w.index:1/0,E=R?L+R.index:1/0;if(T<E)V++,L=T+(w[0].length||1);else if(E<1/0){if(V--,V===0){F=E;break}L=E+G.length+1}else break}if(F===-1)break;let A=W.slice(j,F);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(A);else Z[q].push(A);W=W.substring(0,B)+W.substring(F+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function wZ($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
2204
- `)})}var GB=0,s4,S9;var N$=D(()=>{p3();o0();x4();p0();A0();s4=new p5(500),S9=new Set});import*as C9 from"path";async function WB($,Z,Y=""){if(C9.basename(Y)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return _B($,Z,Y,"@js","@endjs")}async function UB($,Z,Y=""){if(C9.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return _B($,Z,Y,"@ts","@endts")}async function _B($,Z,Y,X,J){let Q=$,G=G$(`${X}([\\s\\S]*?)${J}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:_,index:z}of K)try{let B=Object.keys(Z),q=Object.values(Z),j=_.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let O=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),V=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
2203
+ `+x;return g}catch(A){let N=A instanceof Error?A.message:String(A);return M0("Include",`Error processing include ${j}: ${N}`,Y,O,V)}}let B=/@include\s*\(/g,q;while((q=B.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,V=H+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let L=K.substring(j,V),F=K.substring(H+1,V-1),A=F.match(/^\s*['"]([^'"]+)['"]/);if(!A){B.lastIndex=V;continue}let N=A[1],w,R=F.substring(A[0].length),T=k9(R,0);if(T!==-1)w=R.substring(T+1).trim();let E={};if(w)try{E=d0(w,Z)}catch(k){let S=k instanceof Error?k.message:String(k);K=K.replace(L,M0("Include",`Error parsing include variables for ${N}: ${S}`,Y,$,j)),B.lastIndex=0;continue}let I=await z(N,E,$,j);K=K.substring(0,j)+I+K.substring(V),B.lastIndex=0}return K}function NZ($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let _=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),z=W.match(_);if(!z||z.index===void 0)break;let B=z.index,q=z[1],j=B+z[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),V=1,L=j,F=-1;while(V>0&&L<W.length){let N=W.slice(L),w=N.match(H),R=N.match(O),T=w?L+w.index:1/0,E=R?L+R.index:1/0;if(T<E)V++,L=T+(w[0].length||1);else if(E<1/0){if(V--,V===0){F=E;break}L=E+G.length+1}else break}if(F===-1)break;let A=W.slice(j,F);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(A);else Z[q].push(A);W=W.substring(0,B)+W.substring(F+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function wZ($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
2204
+ `)})}var GB=0,s4,S9;var N$=D(()=>{p3();o0();x4();p0();N0();s4=new p5(500),S9=new Set});import*as C9 from"path";async function WB($,Z,Y=""){if(C9.basename(Y)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return _B($,Z,Y,"@js","@endjs")}async function UB($,Z,Y=""){if(C9.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return _B($,Z,Y,"@ts","@endts")}async function _B($,Z,Y,X,J){let Q=$,G=G$(`${X}([\\s\\S]*?)${J}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:_,index:z}of K)try{let B=Object.keys(Z),q=Object.values(Z),j=_.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let O=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),V=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
2205
2205
  ${j}
2206
2206
  ${V}
2207
- `,A=Function(...B,L)(...q);if(A&&typeof A==="object")Object.assign(Z,A);Q=Q.replace(U,"")}catch(B){console.error(`Error executing ${X} code block in ${Y}:`,B);let q=B instanceof Error?B.message:String(B),j=R0(`${X} Directive`,`Error executing code: ${q}`,Y,$,z,U);console.error(j),Q=Q.replace(U,"")}return Q}var zB=D(()=>{x4();A0()});function dT($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function BB($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return dT(X,Q||"_method")})}async function b9($,Z,Y,X,J){if(!X.middleware||X.middleware.length===0)return $;let Q=$,G=X.middleware.filter((K)=>K.timing===J);if(G.length===0)return Q;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(X.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(Q,Z,Y,X);if(typeof W==="string")Q=W;else if(X.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(X.debug)console.error(`Error in middleware ${K.name}:`,W);if(X.debug){let U=R0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
2207
+ `,A=Function(...B,L)(...q);if(A&&typeof A==="object")Object.assign(Z,A);Q=Q.replace(U,"")}catch(B){console.error(`Error executing ${X} code block in ${Y}:`,B);let q=B instanceof Error?B.message:String(B),j=M0(`${X} Directive`,`Error executing code: ${q}`,Y,$,z,U);console.error(j),Q=Q.replace(U,"")}return Q}var zB=D(()=>{x4();N0()});function dT($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function BB($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return dT(X,Q||"_method")})}async function b9($,Z,Y,X,J){if(!X.middleware||X.middleware.length===0)return $;let Q=$,G=X.middleware.filter((K)=>K.timing===J);if(G.length===0)return Q;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(X.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(Q,Z,Y,X);if(typeof W==="string")Q=W;else if(X.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(X.debug)console.error(`Error in middleware ${K.name}:`,W);if(X.debug){let U=M0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
2208
2208
  <div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${P0(U)}</div>
2209
- `)}}}return Q}async function P9($,Z,Y,X){return b9($,Z,Y,X,"before")}async function y9($,Z,Y,X){return b9($,Z,Y,X,"after")}var x9=D(()=>{o0();A0()});import{defineRoute as Au,defineRoutes as Nu,resetRoutes as wu,route as Ru,setAppUrl as Mu}from"stx-router";import{route as uT}from"stx-router";function qB($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,X,J,Q)=>{try{let G=J?d0(J,{}):{};return uT(X,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var jB=D(()=>{p0()});function v9($,Z,Y,X){let J=$;J=J.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,U)=>{if(!U&&W.includes(":")){let _=W.split(":"),z=W,B=_.length>1?_[1]:"";if(B&&Z[B])U=Z[B];else if(z.startsWith("og:")&&Z.openGraph&&Z.openGraph[_[1]])U=Z.openGraph[_[1]];else U="";return U?`<meta property="${K0(z)}" content="${K0(U)}">`:""}return U?`<meta name="${K0(W)}" content="${K0(U)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(J))!==null){let K=G.index,W=K+G[0].length-1,U=1,_=W+1;while(_<J.length&&U>0){if(J[_]==="(")U++;else if(J[_]===")"){if(U--,U===0)break}_++}if(U!==0)break;let z=J.substring(W+1,_).trim(),B=_+1,q=(()=>{try{let j=d0(z,Z);if(!j)return"";let H="<meta";if(j.name)H+=` name="${K0(String(j.name))}"`;if(j.property)H+=` property="${K0(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${K0(String(j.httpEquiv))}"`;if(j.content)H+=` content="${K0(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return U0("MetaTag",H,J0.EVALUATION_ERROR)}})();J=J.substring(0,K)+q+J.substring(B),Q.lastIndex=0}return J}function f9($,Z,Y){let X=$,J=/@structuredData\s*\(/g,Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)break;let _=X.substring(K+1,U).trim(),z=U+1,B=(()=>{try{let q=d0(_,Z);if(!q)return"";if(!q["@context"])q["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(q).replace(/<\//g,"<\\/")}</script>`}catch(q){let j=q instanceof Error?q.message:String(q);return U0("StructuredData",j,J0.EVALUATION_ERROR)}})();X=X.substring(0,G)+B+X.substring(z),J.lastIndex=0}return X}function g9($,Z,Y,X){let J=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(J))!==null){let K=J.indexOf("{",G.index+4),W=1,U=K+1,_=null,z=!1;while(U<J.length&&W>0){let V=J[U];if(z){z=!1,U++;continue}if(V==="\\"&&_){z=!0,U++;continue}if(_){if(V===_)_=null;U++;continue}if(V==='"'||V==="'"||V==="`"){_=V,U++;continue}if(V==="{")W++;else if(V==="}")W--;U++}if(W!==0)break;let B=J.substring(U).match(/^\s*\)/);if(!B)break;let q=U+B[0].length,j=J.substring(K,U),H=J.substring(G.index,q),O=((V)=>{try{let L=d0(V,Z);if(!L)return"";let F="";if(L.title)F+=`<title>${K0(L.title)}</title>
2209
+ `)}}}return Q}async function P9($,Z,Y,X){return b9($,Z,Y,X,"before")}async function y9($,Z,Y,X){return b9($,Z,Y,X,"after")}var x9=D(()=>{o0();N0()});import{defineRoute as Au,defineRoutes as Nu,resetRoutes as wu,route as Ru,setAppUrl as Mu}from"stx-router";import{route as uT}from"stx-router";function qB($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,X,J,Q)=>{try{let G=J?d0(J,{}):{};return uT(X,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var jB=D(()=>{p0()});function v9($,Z,Y,X){let J=$;J=J.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,U)=>{if(!U&&W.includes(":")){let _=W.split(":"),z=W,B=_.length>1?_[1]:"";if(B&&Z[B])U=Z[B];else if(z.startsWith("og:")&&Z.openGraph&&Z.openGraph[_[1]])U=Z.openGraph[_[1]];else U="";return U?`<meta property="${K0(z)}" content="${K0(U)}">`:""}return U?`<meta name="${K0(W)}" content="${K0(U)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(J))!==null){let K=G.index,W=K+G[0].length-1,U=1,_=W+1;while(_<J.length&&U>0){if(J[_]==="(")U++;else if(J[_]===")"){if(U--,U===0)break}_++}if(U!==0)break;let z=J.substring(W+1,_).trim(),B=_+1,q=(()=>{try{let j=d0(z,Z);if(!j)return"";let H="<meta";if(j.name)H+=` name="${K0(String(j.name))}"`;if(j.property)H+=` property="${K0(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${K0(String(j.httpEquiv))}"`;if(j.content)H+=` content="${K0(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return U0("MetaTag",H,J0.EVALUATION_ERROR)}})();J=J.substring(0,K)+q+J.substring(B),Q.lastIndex=0}return J}function f9($,Z,Y){let X=$,J=/@structuredData\s*\(/g,Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)break;let _=X.substring(K+1,U).trim(),z=U+1,B=(()=>{try{let q=d0(_,Z);if(!q)return"";if(!q["@context"])q["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(q).replace(/<\//g,"<\\/")}</script>`}catch(q){let j=q instanceof Error?q.message:String(q);return U0("StructuredData",j,J0.EVALUATION_ERROR)}})();X=X.substring(0,G)+B+X.substring(z),J.lastIndex=0}return X}function g9($,Z,Y,X){let J=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(J))!==null){let K=J.indexOf("{",G.index+4),W=1,U=K+1,_=null,z=!1;while(U<J.length&&W>0){let V=J[U];if(z){z=!1,U++;continue}if(V==="\\"&&_){z=!0,U++;continue}if(_){if(V===_)_=null;U++;continue}if(V==='"'||V==="'"||V==="`"){_=V,U++;continue}if(V==="{")W++;else if(V==="}")W--;U++}if(W!==0)break;let B=J.substring(U).match(/^\s*\)/);if(!B)break;let q=U+B[0].length,j=J.substring(K,U),H=J.substring(G.index,q),O=((V)=>{try{let L=d0(V,Z);if(!L)return"";let F="";if(L.title)F+=`<title>${K0(L.title)}</title>
2210
2210
  `,F+=`<meta name="title" content="${K0(L.title)}">
2211
2211
  `;if(L.description)F+=`<meta name="description" content="${K0(L.description)}">
2212
2212
  `;if(L.keywords){let A=Array.isArray(L.keywords)?L.keywords.join(", "):L.keywords;F+=`<meta name="keywords" content="${K0(A)}">
@@ -2260,7 +2260,7 @@ ${H.element}`);else z.push(`@else
2260
2260
  ${H.element}`);z.push("@endif");let B=z.join(`
2261
2261
  `),q=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,q)+B+Z.slice(j),Y=q+B.length}return Z}function eT($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function $E($){let Z=$,Y=0;while(Y<Z.length){let X=S6(Z,Y);if(!X)break;let J=X.attrs,Q=!1,G=/v-model:([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z.]+))?\s*=\s*"([^"]*)"/,K=J.match(G);while(K){Q=!0;let _=K[1],z=K[2],B=K[3];J=J.replace(K[0],""),J+=` :${_}="${B}" @update:${_}="${B} = $event"`,K=J.match(G)}if(Q){let _=$4(Z,X),z=Z.slice(_.outerStart,_.outerEnd),B=t4(z,{...X,start:0,end:X.end-X.start},J);Z=Z.slice(0,_.outerStart)+B+Z.slice(_.outerEnd),Y=_.outerStart+B.length;continue}let W=w$(X.attrs,"v-model");if(W===null){Y=X.end;continue}if(aT.has(X.tag.toLowerCase())){let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${W}"`,z=$4(Z,X),B=Z.slice(z.outerStart,z.outerEnd),q=t4(B,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,z.outerStart)+q+Z.slice(z.outerEnd),Y=z.outerStart+q.length}else{let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"");_+=` :modelValue="${W}" @update:modelValue="${W} = $event"`;let z=$4(Z,X),B=Z.slice(z.outerStart,z.outerEnd),q=t4(B,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,z.outerStart)+q+Z.slice(z.outerEnd),Y=z.outerStart+q.length}}return Z}function ZE($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function YE($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function XE($){let Z=$,Y=0;while(Y<Z.length){let X=S6(Z,Y);if(!X)break;let J=w$(X.attrs,"v-html");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=$4(Z,X),G=o4(X.attrs,"v-html"),K=X.selfClosing?" /":"",W=`<${X.tag}${G}${K}>{!! ${J} !!}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function JE($){let Z=$,Y=0;while(Y<Z.length){let X=S6(Z,Y);if(!X)break;let J=w$(X.attrs,"v-text");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=$4(Z,X),G=o4(X.attrs,"v-text"),K=X.selfClosing?" /":"",W=`<${X.tag}${G}${K}>{{ ${J} }}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function QE($){return $.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function GE($){let Z=$,Y=0;while(Y<Z.length){let X=S6(Z,Y);if(!X)break;if(!FB(X.attrs,"v-once")){Y=X.end;continue}let J=o4(X.attrs,"v-once"),Q=$4(Z,X),G=Z.slice(Q.outerStart,Q.outerEnd),W=`@once
2262
2262
  ${t4(G,{...X,start:0,end:X.end-X.start},J)}
2263
- @endonce`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function KE($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function WE($){return $.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function u9($){if(!AB($))return $;let Z=$;return Z=oT(Z),Z=tT(Z),Z=GE(Z),Z=ZE(Z),Z=YE(Z),Z=$E(Z),Z=eT(Z),Z=WE(Z),Z=XE(Z),Z=JE(Z),Z=QE(Z),Z=KE(Z),Z}var rT,aT;var m9=D(()=>{rT=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),aT=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"])});function IZ($){return $.replace(/--/g,"- -").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function c9($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],slotContent:W[3],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let z=L0(_.expr,Z);if(!z||typeof z!=="string"){let L=`<!-- dynamic component: could not resolve "${IZ(_.expr)}" -->`;Q=Q.slice(0,_.index)+L+Q.slice(_.index+_.full.length);continue}let B=_.attrs.trim(),q={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,H;while((H=j.exec(B))!==null){let L=H[1]||H[2],F=H[3];if(H[1])try{q[L]=L0(F,Z)}catch{q[L]=F}else q[L]=F}let O=X.componentsDir||"components",V=await e1(z,q,_.slotContent,O,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+V+Q.slice(_.index+_.full.length)}catch(z){let B=z instanceof Error?z.message:String(z),q=`<!-- dynamic component error: ${IZ(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q=await UE(Q,Z,Y,X,J),Q}async function UE($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let z=L0(_.expr,Z);if(!z||typeof z!=="string"){let j=`<!-- dynamic component: could not resolve "${IZ(_.expr)}" -->`;Q=Q.slice(0,_.index)+j+Q.slice(_.index+_.full.length);continue}let B=X.componentsDir||"components",q=await e1(z,{},"",B,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}catch(z){let B=z instanceof Error?z.message:String(z),q=`<!-- dynamic component error: ${IZ(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q}var l9=D(()=>{A0();p0()});function NB($,Z=""){let Y=`${$}${Z}`,X=0;for(let J=0;J<Y.length;J++){let Q=Y.charCodeAt(J);X=(X<<5)-X+Q,X=X&X}return`stx-${Math.abs(X).toString(36)}`}function wB($,Z,Y={}){let{prefix:X="",preserveHost:J=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=p9($),W=[],U=new Map;if(Q)for(let _ of K){let z=_.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(z){let B=z[1],q=`${Z}_${B}`;U.set(B,q)}}for(let _ of K){let z=RB(_,Z,X,J,U,G);W.push(z)}return W.join(`
2263
+ @endonce`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function KE($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function WE($){return $.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function u9($){if(!AB($))return $;let Z=$;return Z=oT(Z),Z=tT(Z),Z=GE(Z),Z=ZE(Z),Z=YE(Z),Z=$E(Z),Z=eT(Z),Z=WE(Z),Z=XE(Z),Z=JE(Z),Z=QE(Z),Z=KE(Z),Z}var rT,aT;var m9=D(()=>{rT=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),aT=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"])});function IZ($){return $.replace(/--/g,"- -").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function c9($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],slotContent:W[3],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let z=L0(_.expr,Z);if(!z||typeof z!=="string"){let L=`<!-- dynamic component: could not resolve "${IZ(_.expr)}" -->`;Q=Q.slice(0,_.index)+L+Q.slice(_.index+_.full.length);continue}let B=_.attrs.trim(),q={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,H;while((H=j.exec(B))!==null){let L=H[1]||H[2],F=H[3];if(H[1])try{q[L]=L0(F,Z)}catch{q[L]=F}else q[L]=F}let O=X.componentsDir||"components",V=await e1(z,q,_.slotContent,O,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+V+Q.slice(_.index+_.full.length)}catch(z){let B=z instanceof Error?z.message:String(z),q=`<!-- dynamic component error: ${IZ(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q=await UE(Q,Z,Y,X,J),Q}async function UE($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let z=L0(_.expr,Z);if(!z||typeof z!=="string"){let j=`<!-- dynamic component: could not resolve "${IZ(_.expr)}" -->`;Q=Q.slice(0,_.index)+j+Q.slice(_.index+_.full.length);continue}let B=X.componentsDir||"components",q=await e1(z,{},"",B,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}catch(z){let B=z instanceof Error?z.message:String(z),q=`<!-- dynamic component error: ${IZ(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q}var l9=D(()=>{N0();p0()});function NB($,Z=""){let Y=`${$}${Z}`,X=0;for(let J=0;J<Y.length;J++){let Q=Y.charCodeAt(J);X=(X<<5)-X+Q,X=X&X}return`stx-${Math.abs(X).toString(36)}`}function wB($,Z,Y={}){let{prefix:X="",preserveHost:J=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=p9($),W=[],U=new Map;if(Q)for(let _ of K){let z=_.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(z){let B=z[1],q=`${Z}_${B}`;U.set(B,q)}}for(let _ of K){let z=RB(_,Z,X,J,U,G);W.push(z)}return W.join(`
2264
2264
 
2265
2265
  `)}function p9($){let Z=[],Y=$.replace(/\/\*[\s\S]*?\*\//g,""),X=0,J="",Q=!1,G="";for(let K=0;K<Y.length;K++){let W=Y[K];if(W==="@"&&X===0)Q=!0;if(W==="{")X++;else if(W==="}"){if(X--,X===0){if(Q){G+=W;let U=G.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(U){let[,_,z,B]=U;if(_==="keyframes")Z.push({selector:`@keyframes ${z.trim()}`,declarations:B.trim()});else if(_==="media"||_==="supports"||_==="container"){let q=p9(B);Z.push({selector:`@${_} ${z.trim()}`,declarations:q.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
2266
2266
  `)})}else Z.push({selector:`@${_} ${z.trim()}`,declarations:B.trim()})}G="",Q=!1}else if(J.trim()){J+=W;let U=J.match(/([^{]+)\{([^}]*)\}/);if(U)Z.push({selector:U[1].trim(),declarations:U[2].trim()});J=""}continue}}if(Q)G+=W;else J+=W}return Z}function RB($,Z,Y,X,J,Q){let{selector:G,declarations:K}=$;if(G.startsWith("@")){if(G.startsWith("@keyframes")){let _=G.replace("@keyframes ","").trim();return`@keyframes ${J.get(_)||_} { ${K} }`}if(G.startsWith("@media")||G.startsWith("@supports")||G.startsWith("@container")){let z=p9(`x { ${K} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((B)=>RB(B,Z,Y,X,J,Q)).join(`
@@ -7503,7 +7503,7 @@ catch (e) { console.warn('[stx] mount callback error:', e); }
7503
7503
  }
7504
7504
  }
7505
7505
  })();
7506
- `}var LE;var R$=D(()=>{r9();r9();LE={state:H7,derived:O7,effect:L7,batch:bZ,onMount:PZ,onDestroy:yZ,isSignal:V7,isDerived:F7,untrack:xZ,peek:A7,generateSignalsRuntime:N7,generateSignalsRuntimeDev:C6}});var E$={};e(E$,{templateCache:()=>a9,readFileCached:()=>EB,invalidateFileCacheByDir:()=>DB,invalidateFileCache:()=>IB,hashFilePath:()=>T$,getCachedSignalsRuntime:()=>CB,getCachedRouterScript:()=>bB,clearDevCaches:()=>PB,checkCache:()=>hZ,cacheTemplate:()=>dZ,__setSignalsGeneratorsForTest:()=>SB});import e4 from"fs";import M$ from"path";async function EB($){let Y;for(let X=0;X<3;X++)try{let Q=(await e4.promises.stat($)).mtime.getTime(),G=b6.get($);if(G&&G.mtime===Q)return G.content;let K=await Bun.file($).text(),U=(await e4.promises.stat($)).mtime.getTime();if(U!==Q)continue;return b6.set($,{content:K,mtime:U}),K}catch(J){Y=J;break}throw b6.delete($),Error(`File not found: ${$}${Y?` (${Y.message})`:""}`)}function IB($){b6.delete($)}function DB($){for(let Z of b6.keys())if(Z.startsWith($))b6.delete(Z)}function SB($){kB=$}async function CB($=!1){let Z=kB??await Promise.resolve().then(() => (R$(),vZ));if($)return Z.generateSignalsRuntimeDev();if(fZ===null)fZ=Z.generateSignalsRuntime();return fZ}async function bB(){if(gZ===null){let{getRouterScript:$}=await import("stx-router");gZ=$()}return gZ}function PB(){b6.clear(),fZ=null,VE=null,gZ=null}function yB($){let Z={debug:$.debug===!0,middleware:($.middleware??[]).map((Y)=>({name:Y.name,timing:Y.timing,handler:String(Y.handler)})),customDirectives:($.customDirectives??[]).map((Y)=>({name:Y.name,hasEndTag:Y.hasEndTag===!0,handler:String(Y.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(Z)).digest("hex")}async function hZ($,Z){try{if(!Z.cachePath)return null;let Y=M$.resolve(Z.cachePath),X=M$.join(Y,`${T$($)}.html`),J=M$.join(Y,`${T$($)}.meta.json`);if(!await X0(X)||!await X0(J))return null;let Q=await Bun.file(J).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if(G.optionsSignature!==yB(Z))return null;if((await e4.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await X0(W)){if((await e4.promises.stat(W)).mtime.getTime()>G.mtime)return null}else return null;return await Bun.file(X).text()}catch(Y){return console.warn(`Cache error for ${$}:`,Y),null}}async function dZ($,Z,Y,X){try{if(!X.cachePath)return;let J=M$.resolve(X.cachePath);await e4.promises.mkdir(J,{recursive:!0});let Q=M$.join(J,`${T$($)}.html`),G=M$.join(J,`${T$($)}.meta.json`),K=await e4.promises.stat($);await Bun.write(Q,Z);let W={sourcePath:$,mtime:K.mtime.getTime(),dependencies:Array.from(Y),cacheVersion:X.cacheVersion,optionsSignature:yB(X),generatedAt:Date.now()};await Bun.write(G,JSON.stringify(W,null,2)),a9.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(J){console.warn(`Failed to cache template ${$}:`,J)}}function T$($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,FE)}var a9,b6,fZ=null,VE=null,kB=null,gZ=null,FE=16;var P6=D(()=>{A0();a9=new Map,b6=new Map});function xB($){if($.includes("window.StacksBrowser")||$.includes("StacksBrowser ="))return $;let Z=/<script\b(?![^>]*\bserver\b)[^>]*>([\s\S]*?)<\/script>/gi,Y="",X;while((X=Z.exec($))!==null)Y+=X[1]+`
7506
+ `}var LE;var R$=D(()=>{r9();r9();LE={state:H7,derived:O7,effect:L7,batch:bZ,onMount:PZ,onDestroy:yZ,isSignal:V7,isDerived:F7,untrack:xZ,peek:A7,generateSignalsRuntime:N7,generateSignalsRuntimeDev:C6}});var E$={};e(E$,{templateCache:()=>a9,readFileCached:()=>EB,invalidateFileCacheByDir:()=>DB,invalidateFileCache:()=>IB,hashFilePath:()=>T$,getCachedSignalsRuntime:()=>CB,getCachedRouterScript:()=>bB,clearDevCaches:()=>PB,checkCache:()=>hZ,cacheTemplate:()=>dZ,__setSignalsGeneratorsForTest:()=>SB});import e4 from"fs";import M$ from"path";async function EB($){let Y;for(let X=0;X<3;X++)try{let Q=(await e4.promises.stat($)).mtime.getTime(),G=b6.get($);if(G&&G.mtime===Q)return G.content;let K=await Bun.file($).text(),U=(await e4.promises.stat($)).mtime.getTime();if(U!==Q)continue;return b6.set($,{content:K,mtime:U}),K}catch(J){Y=J;break}throw b6.delete($),Error(`File not found: ${$}${Y?` (${Y.message})`:""}`)}function IB($){b6.delete($)}function DB($){for(let Z of b6.keys())if(Z.startsWith($))b6.delete(Z)}function SB($){kB=$}async function CB($=!1){let Z=kB??await Promise.resolve().then(() => (R$(),vZ));if($)return Z.generateSignalsRuntimeDev();if(fZ===null)fZ=Z.generateSignalsRuntime();return fZ}async function bB(){if(gZ===null){let{getRouterScript:$}=await import("stx-router");gZ=$()}return gZ}function PB(){b6.clear(),fZ=null,VE=null,gZ=null}function yB($){let Z={debug:$.debug===!0,middleware:($.middleware??[]).map((Y)=>({name:Y.name,timing:Y.timing,handler:String(Y.handler)})),customDirectives:($.customDirectives??[]).map((Y)=>({name:Y.name,hasEndTag:Y.hasEndTag===!0,handler:String(Y.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(Z)).digest("hex")}async function hZ($,Z){try{if(!Z.cachePath)return null;let Y=M$.resolve(Z.cachePath),X=M$.join(Y,`${T$($)}.html`),J=M$.join(Y,`${T$($)}.meta.json`);if(!await X0(X)||!await X0(J))return null;let Q=await Bun.file(J).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if(G.optionsSignature!==yB(Z))return null;if((await e4.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await X0(W)){if((await e4.promises.stat(W)).mtime.getTime()>G.mtime)return null}else return null;return await Bun.file(X).text()}catch(Y){return console.warn(`Cache error for ${$}:`,Y),null}}async function dZ($,Z,Y,X){try{if(!X.cachePath)return;let J=M$.resolve(X.cachePath);await e4.promises.mkdir(J,{recursive:!0});let Q=M$.join(J,`${T$($)}.html`),G=M$.join(J,`${T$($)}.meta.json`),K=await e4.promises.stat($);await Bun.write(Q,Z);let W={sourcePath:$,mtime:K.mtime.getTime(),dependencies:Array.from(Y),cacheVersion:X.cacheVersion,optionsSignature:yB(X),generatedAt:Date.now()};await Bun.write(G,JSON.stringify(W,null,2)),a9.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(J){console.warn(`Failed to cache template ${$}:`,J)}}function T$($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,FE)}var a9,b6,fZ=null,VE=null,kB=null,gZ=null,FE=16;var P6=D(()=>{N0();a9=new Map,b6=new Map});function xB($){if($.includes("window.StacksBrowser")||$.includes("StacksBrowser ="))return $;let Z=/<script\b(?![^>]*\bserver\b)[^>]*>([\s\S]*?)<\/script>/gi,Y="",X;while((X=Z.exec($))!==null)Y+=X[1]+`
7507
7507
  `;let J=/\{\{([\s\S]*?)\}\}/g;while((X=J.exec($))!==null)Y+=X[1]+`
7508
7508
  `;if(!Y.trim())return $;let G=["browserQuery","BrowserQueryBuilder","configureBrowser","createBrowserModel"].some((B)=>{return new RegExp(`\\b${B}\\b`).test(Y)}),K=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process"]),W=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,U,_=!1;while((U=W.exec(Y))!==null)if(!K.has(U[1])){_=!0;break}if(!G&&!_)return $;let z=`<script type="module">
7509
7509
  // STX: Auto-load @stacksjs/browser (auto-initializes API and loads models)
@@ -7540,13 +7540,13 @@ if(window.stx)window.stx._latestSetup=${G};
7540
7540
  `)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},q=()=>{if(J!==0)return;let j=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let F=j[2];if(!X.has(F))Y.push(F),X.add(F);return}let H=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(H){H[1].split(",").forEach((F)=>{let A=F.trim();if(!A)return;let N=A.indexOf(":"),R=(N>=0?A.slice(N+1).trim():A).split(/[\s=]/)[0];if(R&&!X.has(R))Y.push(R),X.add(R)});return}let O=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(O){O[1].split(",").forEach((F)=>{let A=F.trim().replace(/^\.\.\./,"");if(!A)return;let N=A.split(/[\s=]/)[0];if(N&&!X.has(N))Y.push(N),X.add(N)});return}let V=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(V){let F=V[1];if(!X.has(F))Y.push(F),X.add(F);return}let L=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let F=L[1];if(!X.has(F))Y.push(F),X.add(F)}};while(Q<G){if(B())continue;if(Z[Q]==="'"||Z[Q]==='"'){_(Z[Q]),K=Z[Q-1];continue}if(Z[Q]==="`"){z(),K="`";continue}if(Z[Q]==="/"&&Z[Q+1]!=="/"&&Z[Q+1]!=="*"&&U()){W(),K="/";continue}if(Z[Q]==="{"){J++,K="{",Q++;continue}if(Z[Q]==="}"){J--,K="}",Q++;continue}if(J===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))q();if(!/\s/.test(Z[Q]))K=Z[Q];Q++}return Y.join(", ")}async function $2($,Z,Y,X){if(!cZ($))return $;let J=$;if(Z.skipSignalsRuntime)return J;let{output:Q,setupCode:G}=await cB(J,Y,X);if(J=Q,J=await vB(J,Z),J=xB(J),G)if(J.includes("</head>"))J=J.replace("</head>",`${G}
7541
7541
  </head>`);else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
7542
7542
  ${G}`);else J=J+`
7543
- `+G;let W=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),U=W&&/data-stx/.test(W[1]);if(!G&&!U&&W&&!/data-stx-auto/.test(W[1])){let _=/<body[^>]*>/i,z=/<(script|style)\b[\s\S]*?<\/\1>/gi,B=[],q;while((q=z.exec(J))!==null)B.push([q.index,q.index+q[0].length]);let j=0,H=-1;while(j<J.length){_.lastIndex=j;let O=_.exec(J.slice(j));if(!O)break;let V=j+O.index;if(!B.some(([F,A])=>V>=F&&V<A)){H=V;break}j=V+O[0].length}if(H!==-1){let O=J.slice(0,H),V=J.slice(H).replace(_,(L)=>L.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));J=O+V}}return J}var AE=0,uZ,dB,gB,s9,IE;var Z2=D(()=>{R6();Y7();A0();uZ=/<script\b([^>]*)>/gi,dB=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;gB=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);s9=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);IE=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/});import I$ from"path";function iB($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}async function nB($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=I$.join(J,$);if(await Bun.file(G).exists())return G;J=I$.dirname(J)}X=I$.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=I$.resolve(Z,$);else X=I$.resolve(Z,$);if(await Bun.file(X).exists())return X;return null}catch{return null}}async function rB($,Z,Y){let X=$,J=I$.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,z,B]=G;if(iB(z))continue;let q=await nB(z,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),z.endsWith(".ts")||z.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:C1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
7543
+ `+G;let W=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),U=W&&/data-stx/.test(W[1]);if(!G&&!U&&W&&!/data-stx-auto/.test(W[1])){let _=/<body[^>]*>/i,z=/<(script|style)\b[\s\S]*?<\/\1>/gi,B=[],q;while((q=z.exec(J))!==null)B.push([q.index,q.index+q[0].length]);let j=0,H=-1;while(j<J.length){_.lastIndex=j;let O=_.exec(J.slice(j));if(!O)break;let V=j+O.index;if(!B.some(([F,A])=>V>=F&&V<A)){H=V;break}j=V+O[0].length}if(H!==-1){let O=J.slice(0,H),V=J.slice(H).replace(_,(L)=>L.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));J=O+V}}return J}var AE=0,uZ,dB,gB,s9,IE;var Z2=D(()=>{R6();Y7();N0();uZ=/<script\b([^>]*)>/gi,dB=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;gB=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);s9=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);IE=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/});import I$ from"path";function iB($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}async function nB($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=I$.join(J,$);if(await Bun.file(G).exists())return G;J=I$.dirname(J)}X=I$.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=I$.resolve(Z,$);else X=I$.resolve(Z,$);if(await Bun.file(X).exists())return X;return null}catch{return null}}async function rB($,Z,Y){let X=$,J=I$.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,z,B]=G;if(iB(z))continue;let q=await nB(z,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),z.endsWith(".ts")||z.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:C1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
7544
7544
  // Source: ${z}
7545
7545
  ${j}
7546
7546
  </script>`;X=X.replace(U,H),Q.lastIndex=0}catch(j){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,W;while((W=K.exec(X))!==null){let[U,_,z,B]=W,q=_+B;if(iB(z))continue;if(/rel=["']stylesheet["']/.test(q)||z.endsWith(".css")){let H=await nB(z,J,Z);if(H)try{let O=await Bun.file(H).text();Y.add(H);let V=`<style>
7547
7547
  /* Source: ${z} */
7548
7548
  ${O}
7549
- </style>`;X=X.replace(U,V),K.lastIndex=0}catch(O){}}}return X}var aB=D(()=>{N6()});function w7($,Z){let Y=$,X=/@json\s*\(/g,J;while((J=X.exec(Y))!==null){let Q=J.index,G=Q+J[0].length-1,K=1,W=G+1,U=null,_=!1;while(W<Y.length&&K>0){let F=Y[W];if(_){_=!1,W++;continue}if(F==="\\"&&U){_=!0,W++;continue}if(U){if(F===U)U=null;W++;continue}if(F==='"'||F==="'"||F==="`"){U=F,W++;continue}if(F==="(")K++;else if(F===")"){if(K--,K===0)break}W++}if(K!==0)break;let z=Y.substring(G+1,W).trim(),B=Y.substring(Q,W+1),q=-1,j=0,H=null,O=!1;for(let F=0;F<z.length;F++){let A=z[F];if(O){O=!1;continue}if(A==="\\"&&H){O=!0;continue}if(H){if(A===H)H=null;continue}if(A==='"'||A==="'"||A==="`"){H=A;continue}if(A==="("||A==="["||A==="{")j++;else if(A===")"||A==="]"||A==="}")j--;if(A===","&&j===0){q=F;break}}let V=q>=0?z.substring(0,q).trim():z,L=q>=0?z.substring(q+1).trim():void 0;try{let F=V.trim(),A;if(N0(F))A=w0(F,Object.keys(Z))(...Object.values(Z));else A=void 0;let N;if(L==="true")N=JSON.stringify(A,null,2);else N=JSON.stringify(A);let w=N.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+w+Y.substring(W+1),X.lastIndex=Q+w.length}catch(F){J1.log(F instanceof Error?F:Error(String(F)),{directive:"@json"},"error"),X.lastIndex=Q+B.length}}return Y}function R7($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function sB($){let Z=$,Y=/@memo\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.slice(G,W-1).trim(),_=W,z=Z.slice(_),B=z.indexOf("@endmemo");if(B===-1)continue;let q=z.slice(0,B),j=_+B+8,H=q.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),O=H?H[0].length:0,V=q.slice(O),L=q.match(/(\s*)$/),F=L?L[0].length:0,A=V.slice(0,V.length-F),N=A.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),w;if(N){let[R,T,E="",I]=N,k=`<${T}${E} data-stx-memo="${U}"${I}>`;w=q.slice(0,O)+k+A.slice(R.length)+q.slice(O+A.length)}else w=`${q.slice(0,O)}<div data-stx-memo="${U}">${A}</div>${q.slice(O+A.length)}`;J.push({start:Q,end:j,replacement:w}),Y.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function Y2($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function oB($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),X="",J=0,Q;while((Q=Y.exec($))!==null){let G=Q.index,K=G+Q[0].length,W=!1,U=!1,_=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(U){if(H==='"')U=!1}else if(H==="'")W=!0;else if(H==='"')U=!0;else if(H===">"){_=K;break}K++}if(_===-1)continue;if($.slice(G,_+1).includes("x-cloak"))continue;let B=$.slice(_+1),q=B.indexOf("</"),j=q>=0?B.slice(0,q):B.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,_)+" x-cloak>",J=_+1}return X+=$.slice(J),X}function tB($){let Z=/<[a-z][\w-]*/gi,Y="",X=0,J;while((J=Z.exec($))!==null){let Q=J.index,G=J[0].slice(1).toLowerCase();if(G==="script"||G==="style"){let j=`</${G}>`,H=$.toLowerCase().indexOf(j,Q);if(H!==-1)Z.lastIndex=H+j.length;continue}let K=Q+J[0].length,W=!1,U=!1,_=-1;while(K<$.length){let j=$[K];if(W){if(j==="'")W=!1}else if(U){if(j==='"')U=!1}else if(j==="'")W=!0;else if(j==='"')U=!0;else if(j===">"){_=K;break}K++}if(_===-1)continue;let z=$.slice(Q+J[0].length,_);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(z))continue;if(!SE.test(z))continue;let B=$[_-1]==="/",q=B?_-1:_;Y+=`${$.slice(X,q)} x-cloak${B?" ":""}`,X=q}return Y+=$.slice(X),Y}var SE;var X2=D(()=>{R1();p0();SE=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/});function M7($,Z,Y){let X=typeof Y==="boolean"?{enabled:Y,failOnViolation:Y}:Y??{enabled:!1},J=X.allowPatterns??[],Q=[];for(let{pattern:G,message:K,suggestion:W}of CE){if(J.some((_)=>K.includes(_)||G.source.includes(_)))continue;G.lastIndex=0;let U=$.match(G);if(U&&U.length>0){let _=$.split(`
7549
+ </style>`;X=X.replace(U,V),K.lastIndex=0}catch(O){}}}return X}var aB=D(()=>{N6()});function w7($,Z){let Y=$,X=/@json\s*\(/g,J;while((J=X.exec(Y))!==null){let Q=J.index,G=Q+J[0].length-1,K=1,W=G+1,U=null,_=!1;while(W<Y.length&&K>0){let F=Y[W];if(_){_=!1,W++;continue}if(F==="\\"&&U){_=!0,W++;continue}if(U){if(F===U)U=null;W++;continue}if(F==='"'||F==="'"||F==="`"){U=F,W++;continue}if(F==="(")K++;else if(F===")"){if(K--,K===0)break}W++}if(K!==0)break;let z=Y.substring(G+1,W).trim(),B=Y.substring(Q,W+1),q=-1,j=0,H=null,O=!1;for(let F=0;F<z.length;F++){let A=z[F];if(O){O=!1;continue}if(A==="\\"&&H){O=!0;continue}if(H){if(A===H)H=null;continue}if(A==='"'||A==="'"||A==="`"){H=A;continue}if(A==="("||A==="["||A==="{")j++;else if(A===")"||A==="]"||A==="}")j--;if(A===","&&j===0){q=F;break}}let V=q>=0?z.substring(0,q).trim():z,L=q>=0?z.substring(q+1).trim():void 0;try{let F=V.trim(),A;if(w0(F))A=R0(F,Object.keys(Z))(...Object.values(Z));else A=void 0;let N;if(L==="true")N=JSON.stringify(A,null,2);else N=JSON.stringify(A);let w=N.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+w+Y.substring(W+1),X.lastIndex=Q+w.length}catch(F){J1.log(F instanceof Error?F:Error(String(F)),{directive:"@json"},"error"),X.lastIndex=Q+B.length}}return Y}function R7($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function sB($){let Z=$,Y=/@memo\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.slice(G,W-1).trim(),_=W,z=Z.slice(_),B=z.indexOf("@endmemo");if(B===-1)continue;let q=z.slice(0,B),j=_+B+8,H=q.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),O=H?H[0].length:0,V=q.slice(O),L=q.match(/(\s*)$/),F=L?L[0].length:0,A=V.slice(0,V.length-F),N=A.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),w;if(N){let[R,T,E="",I]=N,k=`<${T}${E} data-stx-memo="${U}"${I}>`;w=q.slice(0,O)+k+A.slice(R.length)+q.slice(O+A.length)}else w=`${q.slice(0,O)}<div data-stx-memo="${U}">${A}</div>${q.slice(O+A.length)}`;J.push({start:Q,end:j,replacement:w}),Y.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function Y2($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function oB($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),X="",J=0,Q;while((Q=Y.exec($))!==null){let G=Q.index,K=G+Q[0].length,W=!1,U=!1,_=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(U){if(H==='"')U=!1}else if(H==="'")W=!0;else if(H==='"')U=!0;else if(H===">"){_=K;break}K++}if(_===-1)continue;if($.slice(G,_+1).includes("x-cloak"))continue;let B=$.slice(_+1),q=B.indexOf("</"),j=q>=0?B.slice(0,q):B.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,_)+" x-cloak>",J=_+1}return X+=$.slice(J),X}function tB($){let Z=/<[a-z][\w-]*/gi,Y="",X=0,J;while((J=Z.exec($))!==null){let Q=J.index,G=J[0].slice(1).toLowerCase();if(G==="script"||G==="style"){let j=`</${G}>`,H=$.toLowerCase().indexOf(j,Q);if(H!==-1)Z.lastIndex=H+j.length;continue}let K=Q+J[0].length,W=!1,U=!1,_=-1;while(K<$.length){let j=$[K];if(W){if(j==="'")W=!1}else if(U){if(j==='"')U=!1}else if(j==="'")W=!0;else if(j==='"')U=!0;else if(j===">"){_=K;break}K++}if(_===-1)continue;let z=$.slice(Q+J[0].length,_);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(z))continue;if(!SE.test(z))continue;let B=$[_-1]==="/",q=B?_-1:_;Y+=`${$.slice(X,q)} x-cloak${B?" ":""}`,X=q}return Y+=$.slice(X),Y}var SE;var X2=D(()=>{R1();p0();SE=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/});function M7($,Z,Y){let X=typeof Y==="boolean"?{enabled:Y,failOnViolation:Y}:Y??{enabled:!1},J=X.allowPatterns??[],Q=[];for(let{pattern:G,message:K,suggestion:W}of CE){if(J.some((_)=>K.includes(_)||G.source.includes(_)))continue;G.lastIndex=0;let U=$.match(G);if(U&&U.length>0){let _=$.split(`
7550
7550
  `),z=[];_.forEach((q,j)=>{if(G.lastIndex=0,G.test(q))z.push(j+1)});let B=z.length>0?` (line${z.length>1?"s":""}: ${z.join(", ")})`:"";Q.push(` \u2717 ${K}${B}
7551
7551
  \u2192 ${W}`)}}if(Q.length>0&&X.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
7552
7552
  ${Q.join(`
@@ -10280,21 +10280,21 @@ ${h}`);if(/<html\b[^>]*>/i.test(c))return c.replace(/(<html\b[^>]*>)/i,`$1
10280
10280
  ${h}
10281
10281
  </head>`);return c},{renderHead:s,getHead:m}=await Promise.resolve().then(() => (c4(),s3)),b=Z.__stx_runtime_head,d=b&&(b.title||b.meta?.length||b.link?.length)?b:m();if(d.title||d.meta?.length||d.link?.length){let c=s(d);if(c)Q=g(Q,c)}if(S.headContent)Q=g(Q,S.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)Q=bJ(Q,G.csp,Z);if(G.analytics?.enabled)Q=qJ(Q,G);if(G.heatmap?.enabled)Q=cX(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:c}=await Promise.resolve().then(() => (Oj(),Hj));Q=c(Q,G)}let l=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),r=/\bSTX\.\w+/.test(Q),a=/window\.STX\s*=/.test(Q);if(l&&r&&!a){let h=`<script data-stx-scoped>
10282
10282
  ${vU()}
10283
- </script>`;if(Q.includes("</head>")){let p=Q.indexOf("</head>"),n=Q.slice(0,p).indexOf("<script");if(n!==-1){let _0=Q.slice(0,n),S0=Q.slice(n);Q=_0+h+`
10284
- `+S0}else Q=Q.replace("</head>",`${h}
10283
+ </script>`;if(Q.includes("</head>")){let p=Q.indexOf("</head>"),i=Q.slice(0,p).indexOf("<script");if(i!==-1){let _0=Q.slice(0,i),k0=Q.slice(i);Q=_0+h+`
10284
+ `+k0}else Q=Q.replace("</head>",`${h}
10285
10285
  </head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
10286
10286
  ${h}`);else Q=h+`
10287
- `+Q}{let c=/<script\s+server\b[^>]*>/gi,h,p=[];while((h=c.exec(Q))!==null){let t=h.index+h[0].length,n=bI(Q,t);if(n===-1)continue;let _0=n+9;while(_0<Q.length&&/\s/.test(Q[_0]))_0++;p.push({start:h.index,end:_0}),c.lastIndex=_0}for(let t=p.length-1;t>=0;t--){let{start:n,end:_0}=p[t];Q=Q.substring(0,n)+Q.substring(_0)}}let B0=B7(Q,Y);if(B0.hasScoped)Q=B0.html;let Q0=Z.__stx_event_bindings||[],M0=!1,k0=[],y=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:u}=await Promise.resolve().then(() => (Z2(),pB));for(let c of u(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))k0.push({match:c.fullMatch,attrs:c.attrs,content:c.body});for(let{match:c,attrs:h,content:p}of k0){M0=!0;let t=p;M7(p,Y,X.strict);let n=await b4(p,{eventBindings:Q0,attrs:h,hasColonDirectives:y,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:C});Q=Q.replace(c,()=>n)}if(M0)Z.__stx_event_bindings=[];return Q}var x6="<!--PARENT_CONTENT_PLACEHOLDER-->";var U1=D(()=>{o1();E3();Y$();fU();zJ();jJ();V3();L3();OJ();R6();tU();b$();p3();yJ();f_();fJ();R1();c4();o0();dJ();iJ();N$();zB();FZ();oZ();x9();x4();jB();TZ();A0();LB();d9();m9();l9();DZ();Z2();M9();aB();X2();J2();p0();tJ();X2();J2()});function Fj($){let Z=[],Y=[];return mI($,Z),cI($,Z,Y),lI($,Y),pI($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function mI($,Z){let Y=($.match(/\{\{/g)||[]).length,X=($.match(/\}\}/g)||[]).length;if(Y!==X)Z.push({type:"expression",message:`Unclosed expression brackets: found ${Y} opening '{{' and ${X} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function cI($,Z,Y){for(let X of hI){let J=new RegExp(`${X.open}(?:\\s|\\()`,"g"),Q=new RegExp(X.close,"g"),G=($.match(J)||[]).length,K=($.match(Q)||[]).length;if(X.altClose){let W=new RegExp(X.altClose,"g");K+=($.match(W)||[]).length}if(G>K)Z.push({type:"directive",message:`Unclosed @${X.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${X.close} tag(s)`});else if(K>G)Y.push({type:"directive",message:`Extra ${X.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${X.close} tags`})}}function lI($,Z){for(let Y of dI)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function pI($,Z){for(let Y of uI)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function Aj($,Z){let Y=$.slice(0,Z).split(`
10288
- `);return{line:Y.length,column:Y[Y.length-1].length+1}}function Nj($,Z,Y){let X=[];switch($){case"if":case"elseif":case"unless":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Y.length===0||!Y[0].includes(" as "))X.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Y.length===0)X.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Y.length===0)X.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Y.length===0)X.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return X}function wj($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function Rj($){let Z=$.matchAll(/@([a-z]+)/gi),Y=new Set;for(let X of Z){let J=X[1].toLowerCase();if(!J.startsWith("end"))Y.add(J)}return Array.from(Y)}var hI,dI,uI;var Mj=D(()=>{hI=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],dI=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],uI=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var kj={};e(kj,{renderSlot:()=>S2,processSlots:()=>C2,parseSlots:()=>k2,parseSlotElement:()=>Tj,extractSlotContent:()=>Ij,applySlots:()=>Dj});function iI($,Z){let Y=1,X=Z,J="<template",Q="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(J,X)&&(X+J.length>=$.length||/[\s>\/]/.test($[X+J.length]))){Y++,X+=J.length;continue}if($.startsWith(Q,X)){let K=$.indexOf(">",X+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function k2($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,J=[],Q;while((Q=X.exec($))!==null){let[_,z,B,q,j]=Q,H=z||B||q,O=Q.index+_.length,V=iI($,O);if(V!==-1){let L=$.slice(O,V-11).trim();J.push({start:Q.index,end:V,slotName:H,content:L,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:L,propsBinding:j||void 0})}}J.sort((_,z)=>z.start-_.start);for(let _ of J)Y=Y.slice(0,_.start)+Y.slice(_.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(Y))!==null){let[_,z,B,q,j,H]=W,O=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(O+V).trim(),F=`<${z}${L?" "+L:""}>${H}</${z}>`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:F})}let U=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=U.exec(Y))!==null){let[_,z,B,q,j]=W,H=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=(H+O).trim(),L=`<${z}${V?" "+V:""} />`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:L})}G.sort((_,z)=>z.start-_.start);for(let _ of G){let z=Z.named.get(_.slotName);if(z)z.content+=_.element;else Z.named.set(_.slotName,{name:_.slotName,content:_.element});Y=Y.slice(0,_.start)+Y.slice(_.end)}return Z.default=Y.trim(),Z}function Tj($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},J=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=J.exec($))!==null)X[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function S2($,Z,Y,X){if(!$)return Y;let J=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...X};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,_]=W.split(":").map((B)=>B.trim()),z=_||U;if(Z[U]!==void 0)G[z]=Z[U]}}else G[Q]=Z;J=nI(J,G)}return J}function nI($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=Ej(J,Z);return P0(String(Q??""))}catch{return`{{ ${X} }}`}})}function Ej($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),J=Z;for(let Q of X)if(J&&typeof J==="object"&&Q in J)J=J[Q];else return;return J}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,J,Q]=Y,G=Z[X],K=parseInt(Q,10);if(typeof G==="number")switch(J){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!N0($))return;return w0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function C2($,Z,Y){let X=$;X=await rI(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let _=Z.named.get(K),z=U?.trim()||"",B=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(B))!==null){let O=H[1],V=H[2];q[O]=Ej(V,Y)}return await S2(_,q,z,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),X}async function rI($,Z,Y){let X=[],J=[];$.replace(Z,(K,...W)=>{let U=W[W.length-2];return J.push({match:K,index:U}),X.push(Y(K,...W.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:W,index:U}=J[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function Ij($){let Z=k2($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function Dj($,Z,Y,X){return await C2($,{default:Z,named:Y},X)}var b2=D(()=>{o0();p0()});import aI from"fs";import o from"path";function Sj($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Cj($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function P4($){return!Cj($)}function y4($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let J=new Bun.Transpiler({loader:"ts",target:"browser",define:C1()}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)J=J.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),J=J.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return J}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function oI($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(_)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===_){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let _=1;while(J<Q&&_>0)if($[J]==="{")_++,J++;else if($[J]==="}")_--,J++;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},W=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
10289
- `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let z=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(z){let j=z[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}function tI($){let Z=[],Y=0,X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(J){if(G==="\\"){Q++;continue}if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,Q)),X=Q+1}if(X<$.length)Z.push($.slice(X));return Z}function eI($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let J=$[X];if(Y){if(J==="\\"){X++;continue}if(J===Y)Y=null;continue}if(J==='"'||J==="'"||J==="`"){Y=J;continue}if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J==="="&&Z===0){let Q=$[X-1],G=$[X+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function $D($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let J=X,Q=0,G=-1;for(;X>=0;X--){let W=$[X];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let W of tI(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let _=eI(U);if(_===-1)continue;let z=U.slice(0,_).trim();if(!/^[A-Z_$][\w$]*$/i.test(z))continue;if(Z[z]!==void 0)continue;let B=U.slice(_+1).trim();if(!B)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${B});`);Z[z]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function T9($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],_=typeof J.root==="string"?o.resolve(J.root):void 0,z=_??o.dirname(X),B=[],q=(O)=>{if(O&&!B.includes(O))B.push(O)},j=Y.__originalFilePath;if(j)q(o.join(o.dirname(j),"components"));q(Z),q(o.join(o.dirname(X),"components")),q(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let O of H)q(typeof O==="string"?O:null);if(_)q(o.resolve(_,"resources/views/components")),q(o.resolve(_,"resources/components")),q(o.resolve(_,"src/components")),q(o.resolve(_,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return X0(o.resolve(o.dirname(X),`${Q}.stx`));for(let O of B){let V=o.isAbsolute(O)?O:o.resolve(z,O);for(let L of U)if(await X0(o.join(V,L)))return!0}return!1}function bj($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function e1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (a4(),jZ)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let z=new Set(_);z.add($);let B=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let q=B&&B!=="load"&&bj(B)?B:"";try{let j=(y)=>y.split("-").map((u)=>u.charAt(0).toUpperCase()+u.slice(1)).join(""),H=(y)=>y.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,V=null,L=J.__importedComponents;if(L){let y=[O,O.toLowerCase(),j(O),H(O)];for(let u of y)if(L.has(u)){V=L.get(u);break}}let F=[];if(!V){let y=[`${O}.stx`,`${j(O)}.stx`,`${H(O)}.stx`],u=[...new Set(y)],c=J.__originalFilePath,h=[];if(c){let q0=o.join(o.dirname(c),"components");h.push(q0)}if(X)h.push(X);let p=o.join(o.dirname(Q),"components");if(!h.includes(p))h.push(p);if(G.componentsDir&&G.componentsDir!==X&&!h.includes(G.componentsDir))h.push(G.componentsDir);let t=G._pluginComponentDirs;if(Array.isArray(t)){for(let q0 of t)if(typeof q0==="string"&&!h.includes(q0))h.push(q0)}let n=typeof G.root==="string"?o.resolve(G.root):void 0,_0=n??o.dirname(Q),S0=[];if(n)S0.push(o.resolve(n,"resources/views/components")),S0.push(o.resolve(n,"resources/components")),S0.push(o.resolve(n,"src/components")),S0.push(o.resolve(n,"components"));S0.push(o.resolve(import.meta.dir,"components"));for(let q0 of S0)if(!h.includes(q0))h.push(q0);let D0=[...new Set(h.map((q0)=>{if(!q0)return q0;return o.isAbsolute(q0)?q0:o.resolve(_0,q0)}))];if(h.length=0,h.push(...D0),O.startsWith("./")||O.startsWith("../"))V=o.resolve(o.dirname(Q),`${O}.stx`),F.push(V);else for(let q0 of h){if(!q0)continue;for(let Y1 of u){let s0=o.join(q0,Y1);if(F.push(s0),await X0(s0)){V=s0;break}}if(V)break;if(!V)try{let Y1=await import("fs");if(!Y1.statSync(q0,{throwIfNoEntry:!1})?.isDirectory())continue;let Z$=8,z0=[{path:q0,depth:0}];while(z0.length>0&&!V){let x0=z0.pop();if(x0.depth>=Z$)continue;let v5;try{v5=Y1.readdirSync(x0.path,{withFileTypes:!0})}catch{continue}for(let x1 of v5){if(!x1.isDirectory())continue;if(x1.name==="node_modules"||x1.name.startsWith("."))continue;let D4=o.join(x0.path,x1.name);for(let T0 of u){let K1=o.join(D4,T0);if(F.push(K1),await X0(K1)){V=K1;break}}if(V)break;z0.push({path:D4,depth:x0.depth+1})}}}catch{}if(V)break}}if(!V||!await X0(V)){let y=F.length>0?`
10287
+ `+Q}{let c=/<script\s+server\b[^>]*>/gi,h,p=[];while((h=c.exec(Q))!==null){let t=h.index+h[0].length,i=bI(Q,t);if(i===-1)continue;let _0=i+9;while(_0<Q.length&&/\s/.test(Q[_0]))_0++;p.push({start:h.index,end:_0}),c.lastIndex=_0}for(let t=p.length-1;t>=0;t--){let{start:i,end:_0}=p[t];Q=Q.substring(0,i)+Q.substring(_0)}}let q0=B7(Q,Y);if(q0.hasScoped)Q=q0.html;let Q0=Z.__stx_event_bindings||[],T0=!1,S0=[],y=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:u}=await Promise.resolve().then(() => (Z2(),pB));for(let c of u(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))S0.push({match:c.fullMatch,attrs:c.attrs,content:c.body});for(let{match:c,attrs:h,content:p}of S0){T0=!0;let t=p;M7(p,Y,X.strict);let i=await b4(p,{eventBindings:Q0,attrs:h,hasColonDirectives:y,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:C});Q=Q.replace(c,()=>i)}if(T0)Z.__stx_event_bindings=[];return Q}var x6="<!--PARENT_CONTENT_PLACEHOLDER-->";var U1=D(()=>{o1();E3();Y$();fU();zJ();jJ();V3();L3();OJ();R6();tU();b$();p3();yJ();f_();fJ();R1();c4();o0();dJ();iJ();N$();zB();FZ();oZ();x9();x4();jB();TZ();N0();LB();d9();m9();l9();DZ();Z2();M9();aB();X2();J2();p0();tJ();X2();J2()});function Fj($){let Z=[],Y=[];return mI($,Z),cI($,Z,Y),lI($,Y),pI($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function mI($,Z){let Y=($.match(/\{\{/g)||[]).length,X=($.match(/\}\}/g)||[]).length;if(Y!==X)Z.push({type:"expression",message:`Unclosed expression brackets: found ${Y} opening '{{' and ${X} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function cI($,Z,Y){for(let X of hI){let J=new RegExp(`${X.open}(?:\\s|\\()`,"g"),Q=new RegExp(X.close,"g"),G=($.match(J)||[]).length,K=($.match(Q)||[]).length;if(X.altClose){let W=new RegExp(X.altClose,"g");K+=($.match(W)||[]).length}if(G>K)Z.push({type:"directive",message:`Unclosed @${X.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${X.close} tag(s)`});else if(K>G)Y.push({type:"directive",message:`Extra ${X.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${X.close} tags`})}}function lI($,Z){for(let Y of dI)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function pI($,Z){for(let Y of uI)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function Aj($,Z){let Y=$.slice(0,Z).split(`
10288
+ `);return{line:Y.length,column:Y[Y.length-1].length+1}}function Nj($,Z,Y){let X=[];switch($){case"if":case"elseif":case"unless":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Y.length===0||!Y[0].includes(" as "))X.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Y.length===0)X.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Y.length===0)X.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Y.length===0)X.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return X}function wj($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function Rj($){let Z=$.matchAll(/@([a-z]+)/gi),Y=new Set;for(let X of Z){let J=X[1].toLowerCase();if(!J.startsWith("end"))Y.add(J)}return Array.from(Y)}var hI,dI,uI;var Mj=D(()=>{hI=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],dI=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],uI=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var kj={};e(kj,{renderSlot:()=>S2,processSlots:()=>C2,parseSlots:()=>k2,parseSlotElement:()=>Tj,extractSlotContent:()=>Ij,applySlots:()=>Dj});function iI($,Z){let Y=1,X=Z,J="<template",Q="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(J,X)&&(X+J.length>=$.length||/[\s>\/]/.test($[X+J.length]))){Y++,X+=J.length;continue}if($.startsWith(Q,X)){let K=$.indexOf(">",X+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function k2($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,J=[],Q;while((Q=X.exec($))!==null){let[_,z,B,q,j]=Q,H=z||B||q,O=Q.index+_.length,V=iI($,O);if(V!==-1){let L=$.slice(O,V-11).trim();J.push({start:Q.index,end:V,slotName:H,content:L,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:L,propsBinding:j||void 0})}}J.sort((_,z)=>z.start-_.start);for(let _ of J)Y=Y.slice(0,_.start)+Y.slice(_.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(Y))!==null){let[_,z,B,q,j,H]=W,O=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(O+V).trim(),F=`<${z}${L?" "+L:""}>${H}</${z}>`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:F})}let U=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=U.exec(Y))!==null){let[_,z,B,q,j]=W,H=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=(H+O).trim(),L=`<${z}${V?" "+V:""} />`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:L})}G.sort((_,z)=>z.start-_.start);for(let _ of G){let z=Z.named.get(_.slotName);if(z)z.content+=_.element;else Z.named.set(_.slotName,{name:_.slotName,content:_.element});Y=Y.slice(0,_.start)+Y.slice(_.end)}return Z.default=Y.trim(),Z}function Tj($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},J=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=J.exec($))!==null)X[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function S2($,Z,Y,X){if(!$)return Y;let J=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...X};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,_]=W.split(":").map((B)=>B.trim()),z=_||U;if(Z[U]!==void 0)G[z]=Z[U]}}else G[Q]=Z;J=nI(J,G)}return J}function nI($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=Ej(J,Z);return P0(String(Q??""))}catch{return`{{ ${X} }}`}})}function Ej($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),J=Z;for(let Q of X)if(J&&typeof J==="object"&&Q in J)J=J[Q];else return;return J}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,J,Q]=Y,G=Z[X],K=parseInt(Q,10);if(typeof G==="number")switch(J){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!w0($))return;return R0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function C2($,Z,Y){let X=$;X=await rI(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let _=Z.named.get(K),z=U?.trim()||"",B=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(B))!==null){let O=H[1],V=H[2];q[O]=Ej(V,Y)}return await S2(_,q,z,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),X}async function rI($,Z,Y){let X=[],J=[];$.replace(Z,(K,...W)=>{let U=W[W.length-2];return J.push({match:K,index:U}),X.push(Y(K,...W.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:W,index:U}=J[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function Ij($){let Z=k2($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function Dj($,Z,Y,X){return await C2($,{default:Z,named:Y},X)}var b2=D(()=>{o0();p0()});import aI from"fs";import o from"path";function Sj($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Cj($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function P4($){return!Cj($)}function y4($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let J=new Bun.Transpiler({loader:"ts",target:"browser",define:C1()}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)J=J.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),J=J.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return J}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function oI($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(_)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===_){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let _=1;while(J<Q&&_>0)if($[J]==="{")_++,J++;else if($[J]==="}")_--,J++;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},W=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
10289
+ `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let z=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(z){let j=z[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}function tI($){let Z=[],Y=0,X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(J){if(G==="\\"){Q++;continue}if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,Q)),X=Q+1}if(X<$.length)Z.push($.slice(X));return Z}function eI($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let J=$[X];if(Y){if(J==="\\"){X++;continue}if(J===Y)Y=null;continue}if(J==='"'||J==="'"||J==="`"){Y=J;continue}if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J==="="&&Z===0){let Q=$[X-1],G=$[X+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function $D($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let J=X,Q=0,G=-1;for(;X>=0;X--){let W=$[X];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let W of tI(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let _=eI(U);if(_===-1)continue;let z=U.slice(0,_).trim();if(!/^[A-Z_$][\w$]*$/i.test(z))continue;if(Z[z]!==void 0)continue;let B=U.slice(_+1).trim();if(!B)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${B});`);Z[z]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function T9($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],_=typeof J.root==="string"?o.resolve(J.root):void 0,z=_??o.dirname(X),B=[],q=(O)=>{if(O&&!B.includes(O))B.push(O)},j=Y.__originalFilePath;if(j)q(o.join(o.dirname(j),"components"));q(Z),q(o.join(o.dirname(X),"components")),q(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let O of H)q(typeof O==="string"?O:null);if(_)q(o.resolve(_,"resources/views/components")),q(o.resolve(_,"resources/components")),q(o.resolve(_,"src/components")),q(o.resolve(_,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return X0(o.resolve(o.dirname(X),`${Q}.stx`));for(let O of B){let V=o.isAbsolute(O)?O:o.resolve(z,O);for(let L of U)if(await X0(o.join(V,L)))return!0}return!1}function bj($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function e1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (a4(),jZ)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let z=new Set(_);z.add($);let B=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let q=B&&B!=="load"&&bj(B)?B:"";try{let j=(y)=>y.split("-").map((u)=>u.charAt(0).toUpperCase()+u.slice(1)).join(""),H=(y)=>y.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,V=null,L=J.__importedComponents;if(L){let y=[O,O.toLowerCase(),j(O),H(O)];for(let u of y)if(L.has(u)){V=L.get(u);break}}let F=[];if(!V){let y=[`${O}.stx`,`${j(O)}.stx`,`${H(O)}.stx`],u=[...new Set(y)],c=J.__originalFilePath,h=[];if(c){let B0=o.join(o.dirname(c),"components");h.push(B0)}if(X)h.push(X);let p=o.join(o.dirname(Q),"components");if(!h.includes(p))h.push(p);if(G.componentsDir&&G.componentsDir!==X&&!h.includes(G.componentsDir))h.push(G.componentsDir);let t=G._pluginComponentDirs;if(Array.isArray(t)){for(let B0 of t)if(typeof B0==="string"&&!h.includes(B0))h.push(B0)}let i=typeof G.root==="string"?o.resolve(G.root):void 0,_0=i??o.dirname(Q),k0=[];if(i)k0.push(o.resolve(i,"resources/views/components")),k0.push(o.resolve(i,"resources/components")),k0.push(o.resolve(i,"src/components")),k0.push(o.resolve(i,"components"));k0.push(o.resolve(import.meta.dir,"components"));for(let B0 of k0)if(!h.includes(B0))h.push(B0);let F0=[...new Set(h.map((B0)=>{if(!B0)return B0;return o.isAbsolute(B0)?B0:o.resolve(_0,B0)}))];if(h.length=0,h.push(...F0),O.startsWith("./")||O.startsWith("../"))V=o.resolve(o.dirname(Q),`${O}.stx`),F.push(V);else for(let B0 of h){if(!B0)continue;for(let Y1 of u){let s0=o.join(B0,Y1);if(F.push(s0),await X0(s0)){V=s0;break}}if(V)break;if(!V)try{let Y1=await import("fs");if(!Y1.statSync(B0,{throwIfNoEntry:!1})?.isDirectory())continue;let Z$=8,z0=[{path:B0,depth:0}];while(z0.length>0&&!V){let x0=z0.pop();if(x0.depth>=Z$)continue;let v5;try{v5=Y1.readdirSync(x0.path,{withFileTypes:!0})}catch{continue}for(let x1 of v5){if(!x1.isDirectory())continue;if(x1.name==="node_modules"||x1.name.startsWith("."))continue;let D4=o.join(x0.path,x1.name);for(let E0 of u){let K1=o.join(D4,E0);if(F.push(K1),await X0(K1)){V=K1;break}}if(V)break;z0.push({path:D4,depth:x0.depth+1})}}}catch{}if(V)break}}if(!V||!await X0(V)){let y=F.length>0?`
10290
10290
  Searched paths:
10291
10291
  ${F.map((u)=>` - ${u}`).join(`
10292
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${y}`}W.add(V);let A;if(D7.has(V))A=D7.get(V);else try{A=await Bun.file(V).text(),D7.set(V,A)}catch(y){return`[Error loading component: ${y instanceof Error?y.message:String(y)}]`}let N=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[y,u]of Object.entries(J))if(!y.startsWith("__")||N.has(y))w[y]=u;let R={...w,...Z,props:Z,slot:Y,__processedComponents:z,__sections:{}};$D(A,R);let T=A,E=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(E)T=E[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...A.matchAll(I)],S=[];for(let y of k){let u=y[1]||"",c=y[2]||"",h=u.includes("server");if(P4(u)&&c.trim())c=y4(c);if(h&&c)try{await U(c,R,V)}catch(t){}if(!h){let t=c.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(t.includes("{{")&&t.includes("}}"))t=j1(t,R,V);let n=u.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");S.push(`<script${n}>${t}</script>`)}}let x=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),P=x?x[1]:"",C=x?x[2]:"",g="",s=P&&/\bscoped\b/i.test(P);if(x)g=`<style${P}>${C}</style>`;let m=T;if(m=m.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),x)m=m.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let y=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,u=[];if(m=m.replace(y,(c,h)=>{let p=h.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(p)u.push(`<style${p[1]}>${p[2]}</style>`);return""}),m=m.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),u.length>0)g=`${g}${u.join(`
10293
- `)}`}if(Y&&m.includes("{{ text || slot }}"))m=m.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:b,applySlots:d}=await Promise.resolve().then(() => (b2(),kj)),{defaultSlot:l,namedSlots:r}=b(Y);m=await d(m,l||Y,r,R);for(let[y,u]of Object.entries(R))if(typeof u==="string"){if(u.includes("<")&&u.includes(">")||u.includes("&lt;")||u.includes("&quot;")){let c=I3(u);R[y]=c}}let a=S.some((y)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(y)),B0={...G,componentsDir:o.dirname(V),skipSignalsRuntime:!0,skipEventDirectives:a,defaultLayout:void 0};R.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let Q0=await W0(m,R,V,B0,W),M0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++sI}_${Math.random().toString(36).slice(2,8)}`,k0=Q0;if(a){let y="";if(Object.keys(Z).length>0)try{y=` data-stx-props="${Sj(JSON.stringify(Z))}"`}catch{}let u=q?` stx-hydrate="${Sj(q)}"`:"";if(k0=`<div data-stx-scope="${M0}"${y}${u}>${Q0}</div>`,k0=S.map((h)=>{let p=h.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!p)return h;let[,t,n]=p,_0=W4(n),S0=`
10292
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${y}`}W.add(V);let A;if(D7.has(V))A=D7.get(V);else try{A=await Bun.file(V).text(),D7.set(V,A)}catch(y){return`[Error loading component: ${y instanceof Error?y.message:String(y)}]`}let N=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[y,u]of Object.entries(J))if(!y.startsWith("__")||N.has(y))w[y]=u;let R={...w,...Z,props:Z,slot:Y,__processedComponents:z,__sections:{}};$D(A,R);let T=A,E=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(E)T=E[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,k=[...A.matchAll(I)],S=[];for(let y of k){let u=y[1]||"",c=y[2]||"",h=u.includes("server");if(P4(u)&&c.trim())c=y4(c);if(h&&c)try{await U(c,R,V)}catch(t){}if(!h){let t=c.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(t.includes("{{")&&t.includes("}}"))t=j1(t,R,V);let i=u.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");S.push(`<script${i}>${t}</script>`)}}let x=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),P=x?x[1]:"",C=x?x[2]:"",g="",s=P&&/\bscoped\b/i.test(P);if(x)g=`<style${P}>${C}</style>`;let m=T;if(m=m.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),x)m=m.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let y=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,u=[];if(m=m.replace(y,(c,h)=>{let p=h.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(p)u.push(`<style${p[1]}>${p[2]}</style>`);return""}),m=m.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),u.length>0)g=`${g}${u.join(`
10293
+ `)}`}if(Y&&m.includes("{{ text || slot }}"))m=m.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:b,applySlots:d}=await Promise.resolve().then(() => (b2(),kj)),{defaultSlot:l,namedSlots:r}=b(Y);m=await d(m,l||Y,r,R);for(let[y,u]of Object.entries(R))if(typeof u==="string"){if(u.includes("<")&&u.includes(">")||u.includes("&lt;")||u.includes("&quot;")){let c=I3(u);R[y]=c}}let a=S.some((y)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(y)),q0={...G,componentsDir:o.dirname(V),skipSignalsRuntime:!0,skipEventDirectives:a,defaultLayout:void 0};R.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let Q0=await W0(m,R,V,q0,W),T0=`stx_${O.replace(/[^a-zA-Z0-9]/g,"_")}_${++sI}_${Math.random().toString(36).slice(2,8)}`,S0=Q0;if(a){let y="";if(Object.keys(Z).length>0)try{y=` data-stx-props="${Sj(JSON.stringify(Z))}"`}catch{}let u=q?` stx-hydrate="${Sj(q)}"`:"";if(S0=`<div data-stx-scope="${T0}"${y}${u}>${Q0}</div>`,S0=S.map((h)=>{let p=h.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!p)return h;let[,t,i]=p,_0=W4(i),k0=`
10294
10294
  (function() {
10295
10295
  const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
10296
10296
  const __scope = window.stx._scopes = window.stx._scopes || {};
10297
- const __scopeVars = __scope['${M0}'] = __scope['${M0}'] || {};
10297
+ const __scopeVars = __scope['${T0}'] = __scope['${T0}'] || {};
10298
10298
 
10299
10299
  // Scope-specific lifecycle callbacks
10300
10300
  __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
@@ -10307,20 +10307,20 @@ ${_0}
10307
10307
  // Register all defined signals and functions in this scope
10308
10308
  const __localVars = {};
10309
10309
  try {
10310
- ${oI(_0).map((D0)=>`if (typeof ${D0} !== 'undefined') __localVars['${D0}'] = ${D0};`).join(`
10310
+ ${oI(_0).map((F0)=>`if (typeof ${F0} !== 'undefined') __localVars['${F0}'] = ${F0};`).join(`
10311
10311
  `)}
10312
10312
  }
10313
10313
  catch (e) {}
10314
10314
  Object.assign(__scopeVars, __localVars);
10315
- })();`;if(q)return`<script type="stx/island" data-stx-island="${M0}" data-stx-scoped${t}>${S0}</script>`;return`<script data-stx-scoped${t}>${S0}</script>`}).join(`
10315
+ })();`;if(q)return`<script type="stx/island" data-stx-island="${T0}" data-stx-scoped${t}>${k0}</script>`;return`<script data-stx-scoped${t}>${k0}</script>`}).join(`
10316
10316
  `)+`
10317
- `+k0,g)k0+=`
10318
- `+g}else{if(g)k0+=`
10319
- `+g;if(S.length>0){let y=R.__stx_event_bindings||[],u=C4(R),c=await Promise.all(S.map(async(h)=>{let p=h.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!p)return h;return await b4(p[1],{eventBindings:y,templateContent:k0,filePath:V,projectRoot:process.cwd(),serverData:u})}));k0+=`
10317
+ `+S0,g)S0+=`
10318
+ `+g}else{if(g)S0+=`
10319
+ `+g;if(S.length>0){let y=R.__stx_event_bindings||[],u=C4(R),c=await Promise.all(S.map(async(h)=>{let p=h.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!p)return h;return await b4(p[1],{eventBindings:y,templateContent:S0,filePath:V,projectRoot:process.cwd(),serverData:u})}));S0+=`
10320
10320
  `+c.join(`
10321
- `),R.__stx_event_bindings=[]}}if(s){let y=B7(k0,V);if(y.hasScoped)k0=y.html}return k0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{_.delete($)}}async function X0($){return Bun.file($).exists()}function P2($,Z){let Y=o.resolve(Z),X=o.resolve($),J=Y.endsWith(o.sep)?Y:Y+o.sep;if(X===Y||X.startsWith(J))return X;return null}async function I7($,Z,Y,X){let J=await ZD($,Z,Y,X);if(J===null)return null;let Q=P2(J,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=o.isAbsolute(K)?K:o.resolve(process.cwd(),K);if(P2(J,W))return o.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function ZD($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=o.dirname(Z),Q=process.cwd();if($.startsWith("/")){let B=o.join(Q,$),q=P2(B,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await X0(q)&&X)X.add(q);return q}let G=o.join(J,$);if(await X0(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let B of[".stx",".tsx",".jsx"]){let q=`${G}${B}`;if(await X0(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let K="",W=o.resolve(J),U=process.cwd();for(let B=0;B<10;B++){let q=o.join(W,"layouts"),j=!1;try{j=aI.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=o.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let B=$.startsWith("layouts/")?$.slice(8):$,q=o.join(K,B);if(await X0(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!B.endsWith(".stx")){let j=`${q}.stx`;if(await X0(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let B=o.isAbsolute(Y.layoutsDir)?Y.layoutsDir:o.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=o.join(B,q);if(await X0(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await X0(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let B=$.split("layouts/"),q=o.join(Y.partialsDir||J,"layouts",B[1]);if(await X0(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await X0(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=o.join(Y.partialsDir,"layouts"),await X0(K)){let B=o.join(K,$);if(await X0(B)){if(Y.debug)console.log(`Found in partials layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let q=`${B}.stx`;if(await X0(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let _=Y.partialsDir||o.join(process.cwd(),"views"),z=o.join(_,$);if(await X0(z)){if(Y.debug)console.log(`Found in views path: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let B=`${z}.stx`;if(await X0(B)){if(Y.debug)console.log(`Found in views path with extension: ${B}`);if(X)X.add(B);return B}}if(J.includes("temp")){let B=o.join(o.dirname(J),"layouts",$);if(await X0(B)){if(Y.debug)console.log(`Found in temp layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let q=`${B}.stx`;if(await X0(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function y2($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10321
+ `),R.__stx_event_bindings=[]}}if(s){let y=B7(S0,V);if(y.hasScoped)S0=y.html}return S0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{_.delete($)}}async function X0($){return Bun.file($).exists()}function P2($,Z){let Y=o.resolve(Z),X=o.resolve($),J=Y.endsWith(o.sep)?Y:Y+o.sep;if(X===Y||X.startsWith(J))return X;return null}async function I7($,Z,Y,X){let J=await ZD($,Z,Y,X);if(J===null)return null;let Q=P2(J,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let W=o.isAbsolute(K)?K:o.resolve(process.cwd(),K);if(P2(J,W))return o.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function ZD($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=o.dirname(Z),Q=process.cwd();if($.startsWith("/")){let B=o.join(Q,$),q=P2(B,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await X0(q)&&X)X.add(q);return q}let G=o.join(J,$);if(await X0(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let B of[".stx",".tsx",".jsx"]){let q=`${G}${B}`;if(await X0(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let K="",W=o.resolve(J),U=process.cwd();for(let B=0;B<10;B++){let q=o.join(W,"layouts"),j=!1;try{j=aI.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=o.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let B=$.startsWith("layouts/")?$.slice(8):$,q=o.join(K,B);if(await X0(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!B.endsWith(".stx")){let j=`${q}.stx`;if(await X0(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let B=o.isAbsolute(Y.layoutsDir)?Y.layoutsDir:o.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=o.join(B,q);if(await X0(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await X0(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let B=$.split("layouts/"),q=o.join(Y.partialsDir||J,"layouts",B[1]);if(await X0(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await X0(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=o.join(Y.partialsDir,"layouts"),await X0(K)){let B=o.join(K,$);if(await X0(B)){if(Y.debug)console.log(`Found in partials layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let q=`${B}.stx`;if(await X0(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let _=Y.partialsDir||o.join(process.cwd(),"views"),z=o.join(_,$);if(await X0(z)){if(Y.debug)console.log(`Found in views path: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let B=`${z}.stx`;if(await X0(B)){if(Y.debug)console.log(`Found in views path with extension: ${B}`);if(X)X.add(B);return B}}if(J.includes("temp")){let B=o.join(o.dirname(J),"layouts",$);if(await X0(B)){if(Y.debug)console.log(`Found in temp layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let q=`${B}.stx`;if(await X0(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function y2($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10322
10322
  `),K=0;for(let W=0;W<G.length;W++)if(K+=G[W].length+1,K>=Z){X=W+1,J=G[W].trim();let U=Math.max(0,W-2),_=Math.min(G.length,W+3);Q=G.slice(U,_).map((z,B)=>{let q=U+B+1;return`${q===X?"> ":" "}${q}: ${z}`}).join(`
10323
- `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return y2($,G)}}catch{}return{lineNumber:X,lineContent:J,context:Q}}function R0($,Z,Y,X,J,Q){let{lineNumber:G,context:K}=y2(X,J,Q),W=Y.split("/").pop(),U=0;if(typeof J==="number"&&J>=0&&X){let z=X.lastIndexOf(`
10323
+ `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return y2($,G)}}catch{}return{lineNumber:X,lineContent:J,context:Q}}function M0($,Z,Y,X,J,Q){let{lineNumber:G,context:K}=y2(X,J,Q),W=Y.split("/").pop(),U=0;if(typeof J==="number"&&J>=0&&X){let z=X.lastIndexOf(`
10324
10324
  `,Math.max(0,J-1));U=J-(z+1)+1}let _="";if(G>0)_+=`
10325
10325
  ${Y}:${G}${U>0?`:${U}`:""}: ${$.toLowerCase()} error: ${Z}
10326
10326
  `;if(_+=`
@@ -10333,8 +10333,8 @@ ${j0.yellow}${j0.bold}Message:${j0.reset} ${Z}
10333
10333
  `,K)_+=`
10334
10334
  ${j0.blue}${j0.bold}Context:${j0.reset}
10335
10335
  ${j0.dim}${K}${j0.reset}
10336
- `;return _}function Z6(){D7.clear()}function YD(){return{size:D7.size,maxSize:500}}var D7,sI=0,j0;var A0=D(()=>{R6();o0();x4();U1();N6();DZ();Mj();a4();D7=new p5(500);j0={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function I2($,Z,Y=""){let X=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let K=G.index,W=G[0].match(/@markdown\(([^)]*)\)/),U=W?W[1]:"",_=K+G[0].length,z=1,B=_,q=-1;while(z>0&&B<$.length){let O=$.indexOf("@markdown",B),V=$.indexOf("@endmarkdown",B);if(V===-1)break;if(O!==-1&&O<V&&O!==K){let L=$[O+9];if(L==="("||L===`
10337
- `||L==="\r"||L===" "||L===void 0)z++;B=O+9}else{if(z--,z===0){q=V;break}B=V+12}}if(q===-1)continue;let j=$.slice(_,q),H=$.slice(K,q+12);J.push({fullMatch:H,options:U,content:j,index:K}),Q.lastIndex=q+12}for(let{fullMatch:K,options:W,content:U,index:_}of J)try{let z={};if(W)W.split(",").forEach((j)=>{let H=j.trim();if(H)z[H]=!0});let B={gfm:z.gfm??!0,breaks:z.breaks??!1},q=f5(U.trim(),B);X=X.split(K).join(q)}catch(z){let B=z instanceof Error?z.message:String(z),q=R0("Markdown Directive",`Error processing markdown: ${B}`,Y,$,_,K);X=X.split(K).join(q)}return X}async function x2($,Z,Y,X){let J={gfm:!0,breaks:!1};return Z.forEach((Q)=>{let G=Q.trim().replace(/['"]/g,"");if(G==="breaks")J.breaks=!0;if(G==="no-gfm")J.gfm=!1}),f5($.trim(),J)}var oZ=D(()=>{A0()});function Pj($){if(tZ.set($.name,$),$.client)v2.set($.name,$.client)}function XD($){return tZ.get($)}function JD(){return Array.from(tZ.values())}function QD($){return v2.delete($),tZ.delete($)}function v0($){return Pj($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,X,J,Q)=>{let G=KD(X,$.defaults);if($.validate){let W=$.validate(G);if(W!==!0){let U=typeof W==="string"?W:`Invalid parameters for @${$.name}`;throw Error(U)}}let K=Y;if($.transform)K=await $.transform(Y,G,J,Q);if($.clientScript){let W=$.clientScript(G);K+=`<script>${W}</script>`}if($.css){let W=$.css(G);K+=`<style>${W}</style>`}return K}}}function GD($,Z){let Y=typeof Z==="function"?{mounted:Z}:Z;return v2.set($,Y),Y}function KD($,Z){let Y={...Z};for(let X of $){let J=X.indexOf(":"),Q=X.indexOf("="),G=J>=0&&(Q<0||J<Q)?J:Q;if(G>=0){let K=X.slice(0,G).trim(),W=X.slice(G+1).trim();if(W==="true")W=!0;else if(W==="false")W=!1;else if(W==="null")W=null;else if(!Number.isNaN(Number(W)))W=Number(W);else if(typeof W==="string"&&W.startsWith("{"))try{W=JSON.parse(W)}catch{}Y[K]=W}else{let K=Object.keys(Y).filter((W)=>!Z||!(W in Z)).length;Y[K===0?"value":`arg${K}`]=X}}return Y}function WD(){return[v0({name:"uppercase",description:"Convert content to uppercase",transform:($)=>$.toUpperCase()}),v0({name:"lowercase",description:"Convert content to lowercase",transform:($)=>$.toLowerCase()}),v0({name:"capitalize",description:"Capitalize first letter of content",transform:($)=>$.charAt(0).toUpperCase()+$.slice(1)}),v0({name:"trim",description:"Remove leading and trailing whitespace",transform:($)=>$.trim()}),v0({name:"truncate",description:"Truncate content to specified length",defaults:{length:100,suffix:"..."},transform:($,{length:Z,suffix:Y})=>$.length>Z?$.slice(0,Z)+Y:$}),v0({name:"highlight",description:"Highlight content with background color",defaults:{color:"yellow"},transform:($,{color:Z})=>`<mark style="background-color: ${Z}; padding: 0.1em 0.2em; border-radius: 0.2em;">${$}</mark>`}),v0({name:"badge",description:"Create a badge/tag",defaults:{variant:"default",color:""},transform:($,{variant:Z,color:Y})=>{let X={default:"background: #e5e7eb; color: #374151;",primary:"background: #3b82f6; color: white;",success:"background: #10b981; color: white;",warning:"background: #f59e0b; color: white;",danger:"background: #ef4444; color: white;",info:"background: #06b6d4; color: white;"};return`<span style="${Y?`background: ${Y}; color: white;`:X[Z]||X.default} padding: 0.25em 0.5em; border-radius: 9999px; font-size: 0.875em; font-weight: 500;">${$}</span>`}}),v0({name:"code",description:"Style content as inline code",transform:($)=>`<code style="background: #f3f4f6; padding: 0.2em 0.4em; border-radius: 0.25em; font-family: ui-monospace, monospace; font-size: 0.875em;">${$}</code>`}),v0({name:"tooltip",description:"Add a tooltip to content",defaults:{text:"",position:"top"},hasEndTag:!0,transform:($,{text:Z,position:Y})=>`<span class="stx-tooltip" data-tooltip="${Z}" data-tooltip-position="${Y}" style="position: relative; cursor: help;">${$}</span>`,css:()=>`
10336
+ `;return _}function Z6(){D7.clear()}function YD(){return{size:D7.size,maxSize:500}}var D7,sI=0,j0;var N0=D(()=>{R6();o0();x4();U1();N6();DZ();Mj();a4();D7=new p5(500);j0={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function I2($,Z,Y=""){let X=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let K=G.index,W=G[0].match(/@markdown\(([^)]*)\)/),U=W?W[1]:"",_=K+G[0].length,z=1,B=_,q=-1;while(z>0&&B<$.length){let O=$.indexOf("@markdown",B),V=$.indexOf("@endmarkdown",B);if(V===-1)break;if(O!==-1&&O<V&&O!==K){let L=$[O+9];if(L==="("||L===`
10337
+ `||L==="\r"||L===" "||L===void 0)z++;B=O+9}else{if(z--,z===0){q=V;break}B=V+12}}if(q===-1)continue;let j=$.slice(_,q),H=$.slice(K,q+12);J.push({fullMatch:H,options:U,content:j,index:K}),Q.lastIndex=q+12}for(let{fullMatch:K,options:W,content:U,index:_}of J)try{let z={};if(W)W.split(",").forEach((j)=>{let H=j.trim();if(H)z[H]=!0});let B={gfm:z.gfm??!0,breaks:z.breaks??!1},q=f5(U.trim(),B);X=X.split(K).join(q)}catch(z){let B=z instanceof Error?z.message:String(z),q=M0("Markdown Directive",`Error processing markdown: ${B}`,Y,$,_,K);X=X.split(K).join(q)}return X}async function x2($,Z,Y,X){let J={gfm:!0,breaks:!1};return Z.forEach((Q)=>{let G=Q.trim().replace(/['"]/g,"");if(G==="breaks")J.breaks=!0;if(G==="no-gfm")J.gfm=!1}),f5($.trim(),J)}var oZ=D(()=>{N0()});function Pj($){if(tZ.set($.name,$),$.client)v2.set($.name,$.client)}function XD($){return tZ.get($)}function JD(){return Array.from(tZ.values())}function QD($){return v2.delete($),tZ.delete($)}function v0($){return Pj($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,X,J,Q)=>{let G=KD(X,$.defaults);if($.validate){let W=$.validate(G);if(W!==!0){let U=typeof W==="string"?W:`Invalid parameters for @${$.name}`;throw Error(U)}}let K=Y;if($.transform)K=await $.transform(Y,G,J,Q);if($.clientScript){let W=$.clientScript(G);K+=`<script>${W}</script>`}if($.css){let W=$.css(G);K+=`<style>${W}</style>`}return K}}}function GD($,Z){let Y=typeof Z==="function"?{mounted:Z}:Z;return v2.set($,Y),Y}function KD($,Z){let Y={...Z};for(let X of $){let J=X.indexOf(":"),Q=X.indexOf("="),G=J>=0&&(Q<0||J<Q)?J:Q;if(G>=0){let K=X.slice(0,G).trim(),W=X.slice(G+1).trim();if(W==="true")W=!0;else if(W==="false")W=!1;else if(W==="null")W=null;else if(!Number.isNaN(Number(W)))W=Number(W);else if(typeof W==="string"&&W.startsWith("{"))try{W=JSON.parse(W)}catch{}Y[K]=W}else{let K=Object.keys(Y).filter((W)=>!Z||!(W in Z)).length;Y[K===0?"value":`arg${K}`]=X}}return Y}function WD(){return[v0({name:"uppercase",description:"Convert content to uppercase",transform:($)=>$.toUpperCase()}),v0({name:"lowercase",description:"Convert content to lowercase",transform:($)=>$.toLowerCase()}),v0({name:"capitalize",description:"Capitalize first letter of content",transform:($)=>$.charAt(0).toUpperCase()+$.slice(1)}),v0({name:"trim",description:"Remove leading and trailing whitespace",transform:($)=>$.trim()}),v0({name:"truncate",description:"Truncate content to specified length",defaults:{length:100,suffix:"..."},transform:($,{length:Z,suffix:Y})=>$.length>Z?$.slice(0,Z)+Y:$}),v0({name:"highlight",description:"Highlight content with background color",defaults:{color:"yellow"},transform:($,{color:Z})=>`<mark style="background-color: ${Z}; padding: 0.1em 0.2em; border-radius: 0.2em;">${$}</mark>`}),v0({name:"badge",description:"Create a badge/tag",defaults:{variant:"default",color:""},transform:($,{variant:Z,color:Y})=>{let X={default:"background: #e5e7eb; color: #374151;",primary:"background: #3b82f6; color: white;",success:"background: #10b981; color: white;",warning:"background: #f59e0b; color: white;",danger:"background: #ef4444; color: white;",info:"background: #06b6d4; color: white;"};return`<span style="${Y?`background: ${Y}; color: white;`:X[Z]||X.default} padding: 0.25em 0.5em; border-radius: 9999px; font-size: 0.875em; font-weight: 500;">${$}</span>`}}),v0({name:"code",description:"Style content as inline code",transform:($)=>`<code style="background: #f3f4f6; padding: 0.2em 0.4em; border-radius: 0.25em; font-family: ui-monospace, monospace; font-size: 0.875em;">${$}</code>`}),v0({name:"tooltip",description:"Add a tooltip to content",defaults:{text:"",position:"top"},hasEndTag:!0,transform:($,{text:Z,position:Y})=>`<span class="stx-tooltip" data-tooltip="${Z}" data-tooltip-position="${Y}" style="position: relative; cursor: help;">${$}</span>`,css:()=>`
10338
10338
  .stx-tooltip::after {
10339
10339
  content: attr(data-tooltip);
10340
10340
  position: absolute;
@@ -10527,7 +10527,7 @@ ${j0.dim}${K}${j0.reset}
10527
10527
  filter: blur(0);
10528
10528
  transform: scale(1);
10529
10529
  }
10530
- `.trim();x$=new Map});import{createHash as XQ}from"crypto";import{readFile as BD,stat as vj}from"fs/promises";async function e0($){try{let Z=await BD($);return XQ("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function fj($){return XQ("sha256").update($).digest("hex").slice(0,16)}function YY($){return XQ("sha256").update($).digest("hex").slice(0,16)}function f$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${YY($)}-${YY(Y)}`}async function v7($){try{return(await vj($)).mtimeMs}catch{return 0}}async function $1($){try{return await vj($),!0}catch{return!1}}var X6=()=>{};import{mkdir as qD,readFile as hj,writeFile as jD,readdir as dj,rm as JQ,stat as HD}from"fs/promises";import{join as g$,dirname as OD}from"path";async function LD($){try{await qD($,{recursive:!0})}catch{}}function uj($,Z,Y){return g$($,Y,`${Z}.json`)}async function gj($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await v7(Z)!==$.srcMtime)return!1;return!0}async function h$($,Z,Y,X=f7){if(!X.enabled)return null;let J=f$($,Z),Q=J6.get(J);if(Q){if(await gj(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;J6.delete(J)}let G=uj(X.directory,J,Y);if(await $1(G))try{let K=await hj(G,"utf-8"),W=JSON.parse(K);if(await gj(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),J6.set(J,W),W.data}catch{}return null}async function d$($,Z,Y,X,J=f7){if(!J.enabled)return;let Q=f$($,Z),G=await e0($),K=await v7($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:f$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};J6.set(Q,W);let U=uj(J.directory,Q,X);try{await LD(OD(U)),await jD(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function u$($,Z=f7){if($==="all")J6.clear();else J6.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=g$(Z.directory,X);try{await JQ(J,{recursive:!0,force:!0})}catch{}}}async function mj($=f7){let Z={memoryEntries:J6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=g$($.directory,Y);try{let J=await dj(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=g$(X,Q),K=await HD(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function cj($=f7){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=g$($.directory,X);try{let Q=await dj(J);for(let G of Q){let K=g$(J,G);try{let W=await hj(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await JQ(K),J6.delete(U.key),Z++}catch{await JQ(K).catch(()=>{}),Z++}}}catch{}}return Z}var J6,f7;var XY=D(()=>{X6();J6=new Map,f7={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class m${config;constructor($={}){this.config={...VD,...$}}async get($,Z){return h$($,Z,"image",this.config)}async set($,Z,Y){return d$($,Z,Y,"image",this.config)}async clear(){return u$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function QQ($){if(!JY)JY=new m$($);else if($)JY.updateConfig($);return JY}async function c$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return QQ(X).get($,Z)}async function l$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return QQ(J).set($,Z,Y)}async function GQ(){return QQ().clear()}var VD,JY=null;var KQ=D(()=>{XY();VD={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as FD,basename as AD,extname as ND,join as wD}from"path";import{mkdir as RD}from"fs/promises";async function WQ(){try{return await import("ts-images")}catch{return null}}function lj($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function MD($,Z){let Y=Z?lj(Z):lj("web"),X=$.formatQuality||{};return{jpeg:{...Y.jpeg,...X.jpeg},png:{...Y.png,...X.png},webp:{...Y.webp,...X.webp},avif:{...Y.avif,...X.avif}}}async function UQ($,Z,Y){let X=await WQ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await c$($,Z,Y);if(J)return J;try{let Q=FD($);if(!await $1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=MD(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await RD(K,{recursive:!0});let U=await e0(Q),_=AD($,ND($)),z=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await g7(Q,Z.transformations,X);for(let j of z){let H=G[j]||{},O=`${_}-${U}.${j}`,V=wD(K,O);try{let L=await X.optimizeImage({input:q||Q,output:V,format:j,quality:H.quality,progressive:H.progressive});if(L){if(B.variants.push({path:V,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!B.originalWidth&&L.width)B.originalWidth=L.width,B.originalHeight=L.height}}catch(L){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);B.placeholder=j.dataUrl}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await l$($,Z,B,Y),B}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function _Q($,Z,Y,X){let J=await WQ();if(!J)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await J.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function g7($,Z,Y){let X=Y||await WQ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let J=await X.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)J=await X.resize(J,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)J=await X.blur(J,G.sigma);break;case"sharpen":if(G.amount!==void 0)J=await X.sharpen(J,G.amount);break;case"grayscale":J=await X.grayscale(J);break;case"rotate":if(G.angle!==void 0)J=await X.rotate(J,G.angle);break;case"flip":J=await X.flip(J);break;case"flop":J=await X.flop(J);break;case"brightness":if(G.value!==void 0)J=await X.brightness(J,G.value);break;case"contrast":if(G.value!==void 0)J=await X.contrast(J,G.value);break;case"saturation":if(G.value!==void 0)J=await X.saturation(J,G.value);break}}return await X.encode(J,"png")}catch(J){return console.error(`[stx-media] Transformation failed: ${J}`),null}}var pj=D(()=>{X6();KQ()});import{resolve as TD,basename as ED,extname as ID,join as DD}from"path";import{mkdir as kD}from"fs/promises";async function SD(){try{return await import("ts-images")}catch{return null}}async function QY($,Z,Y){let X=await SD();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=TD($);if(!await $1(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||CD,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await kD(K,{recursive:!0});let U=await e0(J),_=ED($,ID($)),z=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},B={src:$,byFormat:{},srcsets:{}};for(let j of G){B.byFormat[j]=[];let H=[];for(let O of Q){let V=`${_}-${O}w-${U}.${j}`,L=DD(K,V),F=`${W}/${V}`;try{let A=z[j]?.quality||80;if(await $1(L)){B.byFormat[j].push({path:L,url:F,width:O,height:0,format:j,size:0}),H.push(`${F} ${O}w`);continue}let N=await X.processImage({input:J,output:L,format:j,quality:A,resize:{width:O}});if(N)B.byFormat[j].push({path:L,url:F,width:O,height:N.height||Math.round(O*(N.height||1)/(N.width||1)),format:j,size:N.outputSize||0}),H.push(`${F} ${O}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${A}`)}}B.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||bD(Q),B}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function bD($){let Z=[...$].sort((X,J)=>X-J),Y=[];for(let X=0;X<Z.length-1;X++){let J=Z[X];Y.push(`(max-width: ${J}px) ${J}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function GY($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var CD;var ij=D(()=>{X6();CD=[320,480,640,768,1024,1280,1536,1920]});var nj={};e(nj,{setCachedImageResult:()=>l$,processImage:()=>UQ,optimizeImage:()=>_Q,getCachedImageResult:()=>c$,generateSrcset:()=>GY,generateResponsiveVariants:()=>QY,clearImageCache:()=>GQ,applyTransformations:()=>g7,ImageProcessorCache:()=>m$});var zQ=D(()=>{pj();ij();KQ()});async function PD(){try{return await Promise.resolve().then(() => (zQ(),nj))}catch($){if(!rj)console.warn("[stx-media] Image processor not available, some features disabled:",$),rj=!0;return null}}async function Q6($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return fD(X,Y)}if(Y.processedResult?.processed)return OQ($,Y.processedResult,Z);if(Y.responsiveVariants)return tj($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=Y4,dpr:_,formats:z=H4,quality:B=BQ,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:V=!1,loading:L=V?"eager":WY,decoding:F=KY,fetchpriority:A,objectFit:N,objectPosition:w,crossorigin:R,referrerpolicy:T}=$,E=$.class,I=$.style,k=$.id,S=$.data||{},{isDev:x=!1,baseUrl:P=""}=Z;if(x&&!Z.optimize)return vD($);let C,g,s=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!V)try{C=await x7(J,{strategy:j,...H}),g=y7(s,C,H)}catch{}let m=_!==void 0&&G!==void 0,b;if(m)b=xD($,s,C,Z);else b=await yD($,s,C,Z);let d;if(V){let a=z.includes("webp")?"webp":z[0],B0=Y6(J,U,{...q,q:B},a),Q0=typeof W==="object"?y$(W):W||"100vw";d=`<link rel="preload" as="image" imagesrcset="${B0}" imagesizes="${Q0}" />`}let l=[];if(!aj&&j!=="none")l.push(v$),aj=!0;if(g)l.push(g);let r=O?oj(s):void 0;return{html:b,preloadLink:d,css:l.length>0?l.join(`
10530
+ `.trim();x$=new Map});import{createHash as XQ}from"crypto";import{readFile as BD,stat as vj}from"fs/promises";async function e0($){try{let Z=await BD($);return XQ("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function fj($){return XQ("sha256").update($).digest("hex").slice(0,16)}function YY($){return XQ("sha256").update($).digest("hex").slice(0,16)}function f$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${YY($)}-${YY(Y)}`}async function v7($){try{return(await vj($)).mtimeMs}catch{return 0}}async function $1($){try{return await vj($),!0}catch{return!1}}var X6=()=>{};import{mkdir as qD,readFile as hj,writeFile as jD,readdir as dj,rm as JQ,stat as HD}from"fs/promises";import{join as g$,dirname as OD}from"path";async function LD($){try{await qD($,{recursive:!0})}catch{}}function uj($,Z,Y){return g$($,Y,`${Z}.json`)}async function gj($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await v7(Z)!==$.srcMtime)return!1;return!0}async function h$($,Z,Y,X=f7){if(!X.enabled)return null;let J=f$($,Z),Q=J6.get(J);if(Q){if(await gj(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;J6.delete(J)}let G=uj(X.directory,J,Y);if(await $1(G))try{let K=await hj(G,"utf-8"),W=JSON.parse(K);if(await gj(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),J6.set(J,W),W.data}catch{}return null}async function d$($,Z,Y,X,J=f7){if(!J.enabled)return;let Q=f$($,Z),G=await e0($),K=await v7($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:f$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};J6.set(Q,W);let U=uj(J.directory,Q,X);try{await LD(OD(U)),await jD(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function u$($,Z=f7){if($==="all")J6.clear();else J6.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=g$(Z.directory,X);try{await JQ(J,{recursive:!0,force:!0})}catch{}}}async function mj($=f7){let Z={memoryEntries:J6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=g$($.directory,Y);try{let J=await dj(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=g$(X,Q),K=await HD(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function cj($=f7){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=g$($.directory,X);try{let Q=await dj(J);for(let G of Q){let K=g$(J,G);try{let W=await hj(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await JQ(K),J6.delete(U.key),Z++}catch{await JQ(K).catch(()=>{}),Z++}}}catch{}}return Z}var J6,f7;var XY=D(()=>{X6();J6=new Map,f7={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class m${config;constructor($={}){this.config={...VD,...$}}async get($,Z){return h$($,Z,"image",this.config)}async set($,Z,Y){return d$($,Z,Y,"image",this.config)}async clear(){return u$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function QQ($){if(!JY)JY=new m$($);else if($)JY.updateConfig($);return JY}async function c$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return QQ(X).get($,Z)}async function l$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return QQ(J).set($,Z,Y)}async function GQ(){return QQ().clear()}var VD,JY=null;var KQ=D(()=>{XY();VD={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as FD,basename as AD,extname as ND,join as wD}from"path";import{mkdir as RD}from"fs/promises";async function WQ(){try{return await import("ts-images")}catch{return null}}function lj($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function MD($,Z){let Y=Z?lj(Z):lj("web"),X=$.formatQuality||{};return{jpeg:{...Y.jpeg,...X.jpeg},png:{...Y.png,...X.png},webp:{...Y.webp,...X.webp},avif:{...Y.avif,...X.avif}}}async function UQ($,Z,Y){let X=await WQ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await c$($,Z,Y);if(J)return J;try{let Q=FD($);if(!await $1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=MD(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await RD(K,{recursive:!0});let U=await e0(Q),_=AD($,ND($)),z=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await g7(Q,Z.transformations,X);for(let j of z){let H=G[j]||{},O=`${_}-${U}.${j}`,V=wD(K,O);try{let L=await X.optimizeImage({input:q||Q,output:V,format:j,quality:H.quality,progressive:H.progressive});if(L){if(B.variants.push({path:V,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!B.originalWidth&&L.width)B.originalWidth=L.width,B.originalHeight=L.height}}catch(L){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);B.placeholder=j.dataUrl}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await l$($,Z,B,Y),B}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function _Q($,Z,Y,X){let J=await WQ();if(!J)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await J.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function g7($,Z,Y){let X=Y||await WQ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let J=await X.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)J=await X.resize(J,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)J=await X.blur(J,G.sigma);break;case"sharpen":if(G.amount!==void 0)J=await X.sharpen(J,G.amount);break;case"grayscale":J=await X.grayscale(J);break;case"rotate":if(G.angle!==void 0)J=await X.rotate(J,G.angle);break;case"flip":J=await X.flip(J);break;case"flop":J=await X.flop(J);break;case"brightness":if(G.value!==void 0)J=await X.brightness(J,G.value);break;case"contrast":if(G.value!==void 0)J=await X.contrast(J,G.value);break;case"saturation":if(G.value!==void 0)J=await X.saturation(J,G.value);break}}return await X.encode(J,"png")}catch(J){return console.error(`[stx-media] Transformation failed: ${J}`),null}}var pj=D(()=>{X6();KQ()});import{resolve as TD,basename as ED,extname as ID,join as DD}from"path";import{mkdir as kD}from"fs/promises";async function SD(){try{return await import("ts-images")}catch{return null}}async function QY($,Z,Y){let X=await SD();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=TD($);if(!await $1(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||CD,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await kD(K,{recursive:!0});let U=await e0(J),_=ED($,ID($)),z=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},B={src:$,byFormat:{},srcsets:{}};for(let j of G){B.byFormat[j]=[];let H=[];for(let O of Q){let V=`${_}-${O}w-${U}.${j}`,L=DD(K,V),F=`${W}/${V}`;try{let A=z[j]?.quality||80;if(await $1(L)){B.byFormat[j].push({path:L,url:F,width:O,height:0,format:j,size:0}),H.push(`${F} ${O}w`);continue}let N=await X.processImage({input:J,output:L,format:j,quality:A,resize:{width:O}});if(N)B.byFormat[j].push({path:L,url:F,width:O,height:N.height||Math.round(O*(N.height||1)/(N.width||1)),format:j,size:N.outputSize||0}),H.push(`${F} ${O}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${A}`)}}B.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||bD(Q),B}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function bD($){let Z=[...$].sort((X,J)=>X-J),Y=[];for(let X=0;X<Z.length-1;X++){let J=Z[X];Y.push(`(max-width: ${J}px) ${J}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function GY($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var CD;var ij=D(()=>{X6();CD=[320,480,640,768,1024,1280,1536,1920]});var nj={};e(nj,{setCachedImageResult:()=>l$,processImage:()=>UQ,optimizeImage:()=>_Q,getCachedImageResult:()=>c$,generateSrcset:()=>GY,generateResponsiveVariants:()=>QY,clearImageCache:()=>GQ,applyTransformations:()=>g7,ImageProcessorCache:()=>m$});var zQ=D(()=>{pj();ij();KQ()});async function PD(){try{return await Promise.resolve().then(() => (zQ(),nj))}catch($){if(!rj)console.warn("[stx-media] Image processor not available, some features disabled:",$),rj=!0;return null}}async function Q6($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return fD(X,Y)}if(Y.processedResult?.processed)return OQ($,Y.processedResult,Z);if(Y.responsiveVariants)return tj($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=Y4,dpr:_,formats:z=H4,quality:B=BQ,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:V=!1,loading:L=V?"eager":WY,decoding:F=KY,fetchpriority:A,objectFit:N,objectPosition:w,crossorigin:R,referrerpolicy:T}=$,E=$.class,I=$.style,k=$.id,S=$.data||{},{isDev:x=!1,baseUrl:P=""}=Z;if(x&&!Z.optimize)return vD($);let C,g,s=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!V)try{C=await x7(J,{strategy:j,...H}),g=y7(s,C,H)}catch{}let m=_!==void 0&&G!==void 0,b;if(m)b=xD($,s,C,Z);else b=await yD($,s,C,Z);let d;if(V){let a=z.includes("webp")?"webp":z[0],q0=Y6(J,U,{...q,q:B},a),Q0=typeof W==="object"?y$(W):W||"100vw";d=`<link rel="preload" as="image" imagesrcset="${q0}" imagesizes="${Q0}" />`}let l=[];if(!aj&&j!=="none")l.push(v$),aj=!0;if(g)l.push(g);let r=O?oj(s):void 0;return{html:b,preloadLink:d,css:l.length>0?l.join(`
10531
10531
  `):void 0,script:r}}async function yD($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=Y4,formats:_=H4,quality:z=BQ,params:B={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":WY,decoding:O=KY,fetchpriority:V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:N}=$,w=$.class,R=$.style,T=$.data||{},E=typeof W==="object"?y$(W):W||"100vw",I=[];for(let x of _){let P=Y6(J,U,{...B,q:z},x),C=b7(x);if(q&&!j)I.push(` <source type="${C}" data-srcset="${P}" data-sizes="${E}" />`);else I.push(` <source type="${C}" srcset="${P}" sizes="${E}" />`)}let k=qQ({src:m1(J,{...B,q:z}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:N,className:sj(w,Y),style:jQ(R,L,F,Y),lazy:q&&!j,data:T}),S;if(Y){let x=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;S=`<div id="${Z}" class="stx-img-placeholder" style="${x}">
10532
10532
  <picture>
10533
10533
  ${I.join(`
@@ -12255,7 +12255,7 @@ ${_}
12255
12255
  customElements.define('${Z}', ${G});
12256
12256
  `}async function yQ($,Z,Y,X){if(Z.length<1)return U0("WebComponent","@webcomponent directive requires at least the tag name parameter",J0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[G6.join(G6.dirname(X),G,`${J}.stx`),G6.join(process.cwd(),G,`${J}.stx`),G6.join(G6.dirname(X),`${J}.stx`)],W=null;for(let z of K)if(await X0(z)){W=await Bun.file(z).text();break}if(!W)return U0("WebComponent",`Component file not found: ${J}.stx`,J0.FILE_NOT_FOUND);let U=wH(W,J);return`<script type="module">
12257
12257
  ${RH(U)}
12258
- </script>`}var PQ;var xQ=D(()=>{R1();A0();PQ={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var MH={};e(MH,{timingPlugin:()=>kk,pluginManager:()=>fQ,definePlugin:()=>$5,debugPlugin:()=>Dk,createVariablesPlugin:()=>Sk,createFilterPlugin:()=>Ik,createDirectivePlugin:()=>Ek,PluginManager:()=>vQ});function $5($){return $}class vQ{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 J=X[$];if(J)try{let Q=await J(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 "${X.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let J of this.sortedPlugins){let Q=J[$];if(Q)try{let G=await Q(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 "${J.name}" ${$} hook:`,G)}}return X}}function Ek($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function Ik($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Sk($){return $5({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var fQ,Dk,kk;var gQ=D(()=>{fQ=new vQ;Dk=$5({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)}}),kk=$5({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 P3={};e(P3,{validateConfig:()=>IH,loadStxConfig:()=>c0,defineStxConfig:()=>EH,defaultConfig:()=>O1,config:()=>F1});import hQ from"fs";import z1 from"path";import{loadConfigWithResult as Ck}from"bunfig";function bk($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=z1.join(process.cwd(),"resources","views"),J=z1.join(process.cwd(),"resources","layouts");if(hQ.existsSync(X)&&hQ.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=z1.join(process.cwd(),"resources","views","pages");if(hQ.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function c0($){if(!$){if(Z5)return Z5;if(FY)return FY}let Z=$?z1.resolve($):process.cwd(),Y=TH.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await Ck({name:"stx",alias:"ui",cwd:Z,defaultConfig:O1,verbose:!1})).config,G=bk(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!z1.isAbsolute(Q.partialsDir))Q.partialsDir=z1.join(K,Q.partialsDir);if(Q.componentsDir&&!z1.isAbsolute(Q.componentsDir))Q.componentsDir=z1.join(K,Q.componentsDir);if(Q.layoutsDir&&!z1.isAbsolute(Q.layoutsDir))Q.layoutsDir=z1.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (gQ(),MH)),W=[],U=[];for(let _ of Q.plugins){let z=typeof _==="string"?_:_[0],B=typeof _==="string"?{}:_[1]||{};try{let q,j;try{q=await import(z),j=z1.dirname($0.resolve(z))}catch{let O=z1.resolve(process.cwd(),z);q=await import(O),j=z1.dirname(O)}let H=q.default||q;if(K.register(H,Q),H.components){let O=z1.resolve(j,H.components);W.push(O)}if(H.pages){let O=z1.resolve(j,H.pages),V=B.path||"/";U.push({dir:O,prefix:V})}if(H.setup){let O={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=L},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:j,config:Q};await H.setup(B,O)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(q){console.warn(`[stx] Failed to load plugin ${z}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(TH.set(Z,X),!$)FY=X,X.then((J)=>{Z5=J}).catch(()=>{});return X}function EH($){return $}function IH($){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,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].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,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].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((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.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((J)=>typeof J!=="number"||J<16||J>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((Q)=>!X.includes(Q)).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 O1,Z5=null,TH,FY=null,F1;var i0=D(()=>{Y$();L3();uX();V3();oZ();FQ();CQ();FH();TZ();xQ();O1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:x2,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:yQ,hasEndTag:!1,description:"Include a web component in the template"},z3,B3,RZ,MZ,q3,H3,O3,j3,_U,lX,h7,u7,...VH],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}};TH=new Map;F1=new Proxy(O1,{get($,Z){if(Z5&&Z in Z5)return Z5[Z];if(!FY)c0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import Pk from"fs";import dQ from"path";import{createHighlighter as yk}from"ts-syntax-highlighter";async function O4($,Z={}){try{if(!await X0($))throw Error(`Markdown file not found: ${$}`);let X=(await Pk.promises.stat($)).mtime.getTime();if(Z.cache&&NY.has($)){let z=NY.get($);if(z.updatedAt>=X)return{content:z.content,data:z.data}}let J=await Bun.file($).text(),{data:Q,content:G}=qU(J),K=Z.markdown||F1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=f5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await xk(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)NY.set($,{..._,updatedAt:X});return _}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:R0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function xk($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!AY)try{AY=await yk({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,_)=>{let z=_.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),B=U||(Y?"text":"");if(!B)return K;try{if(!AY.getSupportedLanguages().includes(B))return K;return(await AY.highlight(z,B,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,_,z]=K,B=await J(W,U,_,z);Q=Q.replace(W,B)}return Q}async function D2($,Z,Y="",X={}){return await vk($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!dQ.isAbsolute(K))_=dQ.resolve(dQ.dirname(Y),K);let z={};if(W)try{try{z=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let F of L){let A=F.indexOf(":");if(A>0){let N=F.substring(0,A).trim(),w=F.substring(A+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),T=w.startsWith("'")&&w.endsWith("'");if(R||T)w=w.substring(1,w.length-1);z[N]=w}}}}catch(V){if(X.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:B,data:q}=await O4(_,X),j={...Z,...q,...z},H=B,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(V,L)=>{let F=L.trim();return j[F]!==void 0?String(j[F]):V}),H}catch(_){let z=_ instanceof Error?_.message:String(_);return R0("Markdown File",`Error including markdown file: ${z}`,Y,$,U,G)}})}async function vk($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],W=J.index,U=J;X.push(Y(...U).then((_)=>({match:K,replacement:_,index:W})))}let Q=await Promise.all(X);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var NY,AY=null;var b$=D(()=>{i0();A0();NY=new Map});function wY(){return`
12258
+ </script>`}var PQ;var xQ=D(()=>{R1();N0();PQ={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var MH={};e(MH,{timingPlugin:()=>kk,pluginManager:()=>fQ,definePlugin:()=>$5,debugPlugin:()=>Dk,createVariablesPlugin:()=>Sk,createFilterPlugin:()=>Ik,createDirectivePlugin:()=>Ek,PluginManager:()=>vQ});function $5($){return $}class vQ{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 J=X[$];if(J)try{let Q=await J(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 "${X.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let J of this.sortedPlugins){let Q=J[$];if(Q)try{let G=await Q(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 "${J.name}" ${$} hook:`,G)}}return X}}function Ek($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function Ik($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Sk($){return $5({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var fQ,Dk,kk;var gQ=D(()=>{fQ=new vQ;Dk=$5({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)}}),kk=$5({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 P3={};e(P3,{validateConfig:()=>IH,loadStxConfig:()=>c0,defineStxConfig:()=>EH,defaultConfig:()=>O1,config:()=>F1});import hQ from"fs";import z1 from"path";import{loadConfigWithResult as Ck}from"bunfig";function bk($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=z1.join(process.cwd(),"resources","views"),J=z1.join(process.cwd(),"resources","layouts");if(hQ.existsSync(X)&&hQ.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=z1.join(process.cwd(),"resources","views","pages");if(hQ.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function c0($){if(!$){if(Z5)return Z5;if(FY)return FY}let Z=$?z1.resolve($):process.cwd(),Y=TH.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await Ck({name:"stx",alias:"ui",cwd:Z,defaultConfig:O1,verbose:!1})).config,G=bk(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!z1.isAbsolute(Q.partialsDir))Q.partialsDir=z1.join(K,Q.partialsDir);if(Q.componentsDir&&!z1.isAbsolute(Q.componentsDir))Q.componentsDir=z1.join(K,Q.componentsDir);if(Q.layoutsDir&&!z1.isAbsolute(Q.layoutsDir))Q.layoutsDir=z1.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (gQ(),MH)),W=[],U=[];for(let _ of Q.plugins){let z=typeof _==="string"?_:_[0],B=typeof _==="string"?{}:_[1]||{};try{let q,j;try{q=await import(z),j=z1.dirname($0.resolve(z))}catch{let O=z1.resolve(process.cwd(),z);q=await import(O),j=z1.dirname(O)}let H=q.default||q;if(K.register(H,Q),H.components){let O=z1.resolve(j,H.components);W.push(O)}if(H.pages){let O=z1.resolve(j,H.pages),V=B.path||"/";U.push({dir:O,prefix:V})}if(H.setup){let O={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=L},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:j,config:Q};await H.setup(B,O)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(q){console.warn(`[stx] Failed to load plugin ${z}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(TH.set(Z,X),!$)FY=X,X.then((J)=>{Z5=J}).catch(()=>{});return X}function EH($){return $}function IH($){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,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].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,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].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((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.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((J)=>typeof J!=="number"||J<16||J>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((Q)=>!X.includes(Q)).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 O1,Z5=null,TH,FY=null,F1;var i0=D(()=>{Y$();L3();uX();V3();oZ();FQ();CQ();FH();TZ();xQ();O1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:x2,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:yQ,hasEndTag:!1,description:"Include a web component in the template"},z3,B3,RZ,MZ,q3,H3,O3,j3,_U,lX,h7,u7,...VH],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}};TH=new Map;F1=new Proxy(O1,{get($,Z){if(Z5&&Z in Z5)return Z5[Z];if(!FY)c0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import Pk from"fs";import dQ from"path";import{createHighlighter as yk}from"ts-syntax-highlighter";async function O4($,Z={}){try{if(!await X0($))throw Error(`Markdown file not found: ${$}`);let X=(await Pk.promises.stat($)).mtime.getTime();if(Z.cache&&NY.has($)){let z=NY.get($);if(z.updatedAt>=X)return{content:z.content,data:z.data}}let J=await Bun.file($).text(),{data:Q,content:G}=qU(J),K=Z.markdown||F1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=f5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await xk(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)NY.set($,{..._,updatedAt:X});return _}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:M0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function xk($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!AY)try{AY=await yk({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,_)=>{let z=_.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),B=U||(Y?"text":"");if(!B)return K;try{if(!AY.getSupportedLanguages().includes(B))return K;return(await AY.highlight(z,B,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,_,z]=K,B=await J(W,U,_,z);Q=Q.replace(W,B)}return Q}async function D2($,Z,Y="",X={}){return await vk($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!dQ.isAbsolute(K))_=dQ.resolve(dQ.dirname(Y),K);let z={};if(W)try{try{z=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let F of L){let A=F.indexOf(":");if(A>0){let N=F.substring(0,A).trim(),w=F.substring(A+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),T=w.startsWith("'")&&w.endsWith("'");if(R||T)w=w.substring(1,w.length-1);z[N]=w}}}}catch(V){if(X.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:B,data:q}=await O4(_,X),j={...Z,...q,...z},H=B,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(V,L)=>{let F=L.trim();return j[F]!==void 0?String(j[F]):V}),H}catch(_){let z=_ instanceof Error?_.message:String(_);return M0("Markdown File",`Error including markdown file: ${z}`,Y,$,U,G)}})}async function vk($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],W=J.index,U=J;X.push(Y(...U).then((_)=>({match:K,replacement:_,index:W})))}let Q=await Promise.all(X);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var NY,AY=null;var b$=D(()=>{i0();N0();NY=new Map});function wY(){return`
12259
12259
  /* Theme selector for code blocks */
12260
12260
  .theme-selector {
12261
12261
  margin: 1rem 0;
@@ -12974,7 +12974,7 @@ ${K}
12974
12974
  `));return K=K.replace(/<body\b[^>]*>/i,""),K=K.replace(/<\/body\s*>/i,""),K.trim()}function _G($){return $.headers.get("X-STX-Router")==="true"}function _8($,Z="main"){let Y=$.trim(),X=[],J=Y.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(J){let L=J[1],F=/<style\b[^>]*>[\s\S]*?<\/style>/gi,A;while((A=F.exec(L))!==null)X.push(A[0])}let Q=Z.replace(/^[.#]/,"").toLowerCase(),G=new RegExp(`<${Q}\\b[^>]*>`,"i"),K=Y.match(G);if(!K||K.index===void 0)return N4($);let W=K.index+K[0].length,U=new RegExp(`<${Q}\\b[^>]*>`,"gi"),_=new RegExp(`</${Q}\\s*>`,"gi");U.lastIndex=W,_.lastIndex=W;let z=1,B=-1;while(z>0){let L=U.exec(Y),F=_.exec(Y);if(!F)break;if(L&&L.index<F.index)z++,_.lastIndex=L.index+L[0].length;else if(z--,B=F.index,z>0)U.lastIndex=F.index+F[0].length}if(B===-1)return N4($);let q=Y.slice(W,B).trim(),j=[],H=Y.match(/<body\b[^>]*>/i),O=Y.lastIndexOf("</body>");if(H&&H.index!==void 0&&O!==-1){let F=[[H.index+H[0].length,K.index],[B+`</${Q}>`.length,O]],A=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[N,w]of F){if(N>=w)continue;let R=Y.slice(N,w),T;A.lastIndex=0;while((T=A.exec(R))!==null)j.push(T[0])}}let V=[];if(X.length>0)V.push(X.join(`
12975
12975
  `));if(j.length>0)V.push(j.join(`
12976
12976
  `));return V.push(q),V.join(`
12977
- `)}var JC="stx-page-head:",QC,W8=null;var j5=D(()=>{KG();QC=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/});import{matchRoute as KC,Router as WC}from"stx-router";import{findErrorPage as zG,formatRoutes as BG,generateRouteManifest as _C,generateRouteTypes as zC,matchRoute as pY}from"stx-router";function w4($,Z={}){return new WC($,Z).routes}function UC($,Z){let Y=KC($,Z);return Y?Y.params:null}var B8=()=>{};import{createHash as BC}from"crypto";function qC($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function HC($){return Bun.hash($).toString(16)}function HO($,Z={}){if(!$.includes('type="stx/island"'))return{html:$,chunks:[]};let Y=new Map,X=$.replace(jC,(Q,G,K,W)=>{let U=W.trim();if(!U)return Q;if(/\bdata-stx-src=/.test(K))return Q;if(Z.minify)U=qC(U);let _=HC(U);if(!Y.has(_))Y.set(_,U);let z=Z.integrity?` data-stx-integrity="sha384-${BC("sha384").update(U).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${G}" data-stx-src="/_stx/islands/${_}.js"${z}${K}></script>`}),J=Array.from(Y,([Q,G])=>({hash:Q,code:G}));return{html:X,chunks:J}}function OO($){if(!$.includes("data-stx-src="))return $;let Z=new Map,Y=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,X;while((X=Y.exec($))!==null)Z.set(X[1],X[2]);let J=new Set,Q=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,G;while((G=Q.exec($))!==null)if(OC.has(Z.get(G[1])||""))J.add(G[2]);let K=$.lastIndexOf("</head>");if(J.size===0||K===-1)return $;let W=Array.from(J).filter((U)=>!$.includes(`rel="prefetch" href="${U}"`)).map((U)=>`<link rel="prefetch" href="${U}" as="script">`).join("");if(!W)return $;return $.slice(0,K)+W+$.slice(K)}var jC,OC;var LO=D(()=>{jC=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;OC=new Set(["visible","idle"])});var EO={};e(EO,{generateStaticSite:()=>NO,defineStaticPaths:()=>MO,default:()=>DC,createMarkdownLoader:()=>TO,createISRHandler:()=>RO});import l0 from"fs";import F0 from"path";class VO{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=F0.join(this.cacheDir,"build-cache.json");if(await Bun.file($).exists())try{let Z=JSON.parse(await Bun.file($).text());for(let[Y,X]of Object.entries(Z))this.cache.set(Y,X)}catch{}this.loaded=!0}async save(){await l0.promises.mkdir(this.cacheDir,{recursive:!0});let $=F0.join(this.cacheDir,"build-cache.json"),Z={};for(let[Y,X]of this.cache)Z[Y]=X;await Bun.write($,JSON.stringify(Z))}getHash($,Z){let Y=l0.statSync($),X=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(l0.existsSync(Q)){let G=l0.statSync(Q);X+=`:${Q}:${G.mtimeMs}`}let J=0;for(let Q=0;Q<X.length;Q++){let G=X.charCodeAt(Q);J=(J<<5)-J+G,J=J&J}return Math.abs(J).toString(36)}get($,Z){let Y=this.cache.get($);if(!Y)return null;let X=this.getHash(Z,Y.dependencies??[]);if(Y.hash!==X)return this.cache.delete($),null;return Y.html}set($,Z,Y,X){let J=this.getHash(Z,Y);this.cache.set($,{hash:J,html:X,generatedAt:Date.now(),dependencies:Y})}}class FO{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return F0.join(this.cacheDir,"isr",Z)}async get($){let Z=this.getFilePath($);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set($,Z){let Y=this.getFilePath($);await l0.promises.mkdir(F0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await l0.promises.unlink(Z)}async invalidatePattern($){let Z=F0.join(this.cacheDir,"isr");if(!l0.existsSync(Z))return;let Y=await l0.promises.readdir(Z);for(let X of Y){let J=X.replace(/_/g,"/").replace(".json","");if($.test(J))await l0.promises.unlink(F0.join(Z,X))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function LC($){try{let Y=(await Bun.file($).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return null;let X=Y[1];if(!X.includes("getStaticPaths"))return null;let J=X.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!J)return null;return await Function(`
12977
+ `)}var JC="stx-page-head:",QC,W8=null;var j5=D(()=>{KG();QC=/<!--stx-page-head:([A-Za-z0-9+/=]+)-->\n?/});import{matchRoute as KC,Router as WC}from"stx-router";import{findErrorPage as zG,formatRoutes as BG,generateRouteManifest as _C,generateRouteTypes as zC,matchRoute as pY}from"stx-router";function w4($,Z={}){return new WC($,Z).routes}function UC($,Z){let Y=KC($,Z);return Y?Y.params:null}var B8=()=>{};import{createHash as BC}from"crypto";function qC($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function HC($){return Bun.hash($).toString(16)}function HO($,Z={}){if(!$.includes('type="stx/island"'))return{html:$,chunks:[]};let Y=new Map,X=$.replace(jC,(Q,G,K,W)=>{let U=W.trim();if(!U)return Q;if(/\bdata-stx-src=/.test(K))return Q;if(Z.minify)U=qC(U);let _=HC(U);if(!Y.has(_))Y.set(_,U);let z=Z.integrity?` data-stx-integrity="sha384-${BC("sha384").update(U).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${G}" data-stx-src="/_stx/islands/${_}.js"${z}${K}></script>`}),J=Array.from(Y,([Q,G])=>({hash:Q,code:G}));return{html:X,chunks:J}}function OO($){if(!$.includes("data-stx-src="))return $;let Z=new Map,Y=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,X;while((X=Y.exec($))!==null)Z.set(X[1],X[2]);let J=new Set,Q=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,G;while((G=Q.exec($))!==null)if(OC.has(Z.get(G[1])||""))J.add(G[2]);let K=$.lastIndexOf("</head>");if(J.size===0||K===-1)return $;let W=Array.from(J).filter((U)=>!$.includes(`rel="prefetch" href="${U}"`)).map((U)=>`<link rel="prefetch" href="${U}" as="script">`).join("");if(!W)return $;return $.slice(0,K)+W+$.slice(K)}var jC,OC;var LO=D(()=>{jC=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;OC=new Set(["visible","idle"])});var EO={};e(EO,{generateStaticSite:()=>NO,defineStaticPaths:()=>MO,default:()=>DC,createMarkdownLoader:()=>TO,createISRHandler:()=>RO});import l0 from"fs";import A0 from"path";class VO{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=A0.join(this.cacheDir,"build-cache.json");if(await Bun.file($).exists())try{let Z=JSON.parse(await Bun.file($).text());for(let[Y,X]of Object.entries(Z))this.cache.set(Y,X)}catch{}this.loaded=!0}async save(){await l0.promises.mkdir(this.cacheDir,{recursive:!0});let $=A0.join(this.cacheDir,"build-cache.json"),Z={};for(let[Y,X]of this.cache)Z[Y]=X;await Bun.write($,JSON.stringify(Z))}getHash($,Z){let Y=l0.statSync($),X=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(l0.existsSync(Q)){let G=l0.statSync(Q);X+=`:${Q}:${G.mtimeMs}`}let J=0;for(let Q=0;Q<X.length;Q++){let G=X.charCodeAt(Q);J=(J<<5)-J+G,J=J&J}return Math.abs(J).toString(36)}get($,Z){let Y=this.cache.get($);if(!Y)return null;let X=this.getHash(Z,Y.dependencies??[]);if(Y.hash!==X)return this.cache.delete($),null;return Y.html}set($,Z,Y,X){let J=this.getHash(Z,Y);this.cache.set($,{hash:J,html:X,generatedAt:Date.now(),dependencies:Y})}}class FO{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return A0.join(this.cacheDir,"isr",Z)}async get($){let Z=this.getFilePath($);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set($,Z){let Y=this.getFilePath($);await l0.promises.mkdir(A0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await l0.promises.unlink(Z)}async invalidatePattern($){let Z=A0.join(this.cacheDir,"isr");if(!l0.existsSync(Z))return;let Y=await l0.promises.readdir(Z);for(let X of Y){let J=X.replace(/_/g,"/").replace(".json","");if($.test(J))await l0.promises.unlink(A0.join(Z,X))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function LC($){try{let Y=(await Bun.file($).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return null;let X=Y[1];if(!X.includes("getStaticPaths"))return null;let J=X.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!J)return null;return await Function(`
12978
12978
  return (async function getStaticPaths() {
12979
12979
  ${J[1]}
12980
12980
  })()
@@ -13014,10 +13014,10 @@ ${$.map((X)=>{let J=new URL(X.loc,Z).href,Q=` <url>
13014
13014
  ${Y.join(`
13015
13015
  `)}
13016
13016
  </channel>
13017
- </rss>`}async function NO($={}){let Z=Date.now(),Y=await c0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},W={};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&l0.existsSync(X.outputDir))await l0.promises.rm(X.outputDir,{recursive:!0});await l0.promises.mkdir(X.outputDir,{recursive:!0});let _=new VO(X.cacheDir);if(X.cache)await _.load();try{let{preloadIconCollection:F}=await Promise.resolve().then(() => (UZ(),Cz));await F("lucide")}catch{}try{let{generateCrosswindCSS:F}=await Promise.resolve().then(() => (o1(),b3));await F('<div class="bg-black"></div>')}catch{}Y8();let z=Y?.routeMiddleware?.dir||"middleware";await G8(process.cwd(),z);let B=Q8();if(B.length>0)console.log(`Loaded ${B.length} middleware: ${B.join(", ")}`);let q=Y?.routeMiddleware?.global||[],j=w4(".",{pagesDir:X.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let F of j){let A=await VC(F);for(let N of A)H.push({route:F,url:N.url,params:N.params,props:N.props,revalidate:N.revalidate??X.revalidate})}J.totalPages=H.length,console.log(`Generating ${J.totalPages} pages...`);let O=[],V=[];for(let F=0;F<H.length;F+=X.concurrency)V.push(H.slice(F,F+X.concurrency));for(let F of V)await Promise.all(F.map(async(A)=>{let{route:N,url:w,params:R,props:T,revalidate:E}=A;try{await X.hooks.onPageStart?.(w);let I=await Bun.file(N.filePath).text(),k=TC(I),S=k?.middleware?Array.isArray(k.middleware)?k.middleware:[k.middleware]:[],x=[...q,...S];if(x.length>0){let b=J8(w,R,k||{}),d=X8(b,null),l=await K8(x,d);if(l.redirect){let r=typeof l.redirect==="string"?l.redirect:l.redirect.path||l.redirect,a=EC(String(r),w),B0=IC(w,X);await l0.promises.mkdir(F0.dirname(B0),{recursive:!0}),await Bun.write(B0,a),J.successCount++,J.pages.push({route:w,outputPath:B0,size:Buffer.byteLength(a),cached:!1}),O.push({loc:w,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${w} \u2192 redirect to ${r}`);return}if(l.abort){let r=typeof l.abort==="string"?l.abort:l.abort?.error?.message||"aborted";console.warn(` \u21B3 ${w} \u2014 middleware aborted: ${r}`);return}}let P=I.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(P)try{if(!await Function("route",`
13017
+ </rss>`}async function NO($={}){let Z=Date.now(),Y=await c0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},W={};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&l0.existsSync(X.outputDir))await l0.promises.rm(X.outputDir,{recursive:!0});await l0.promises.mkdir(X.outputDir,{recursive:!0});let _=new VO(X.cacheDir);if(X.cache)await _.load();try{let{preloadIconCollection:F}=await Promise.resolve().then(() => (UZ(),Cz));await F("lucide")}catch{}try{let{generateCrosswindCSS:F}=await Promise.resolve().then(() => (o1(),b3));await F('<div class="bg-black"></div>')}catch{}Y8();let z=Y?.routeMiddleware?.dir||"middleware";await G8(process.cwd(),z);let B=Q8();if(B.length>0)console.log(`Loaded ${B.length} middleware: ${B.join(", ")}`);let q=Y?.routeMiddleware?.global||[],j=w4(".",{pagesDir:X.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let F of j){let A=await VC(F);for(let N of A)H.push({route:F,url:N.url,params:N.params,props:N.props,revalidate:N.revalidate??X.revalidate})}J.totalPages=H.length,console.log(`Generating ${J.totalPages} pages...`);let O=[],V=[];for(let F=0;F<H.length;F+=X.concurrency)V.push(H.slice(F,F+X.concurrency));for(let F of V)await Promise.all(F.map(async(A)=>{let{route:N,url:w,params:R,props:T,revalidate:E}=A;try{await X.hooks.onPageStart?.(w);let I=await Bun.file(N.filePath).text(),k=TC(I),S=k?.middleware?Array.isArray(k.middleware)?k.middleware:[k.middleware]:[],x=[...q,...S];if(x.length>0){let b=J8(w,R,k||{}),d=X8(b,null),l=await K8(x,d);if(l.redirect){let r=typeof l.redirect==="string"?l.redirect:l.redirect.path||l.redirect,a=EC(String(r),w),q0=IC(w,X);await l0.promises.mkdir(A0.dirname(q0),{recursive:!0}),await Bun.write(q0,a),J.successCount++,J.pages.push({route:w,outputPath:q0,size:Buffer.byteLength(a),cached:!1}),O.push({loc:w,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${w} \u2192 redirect to ${r}`);return}if(l.abort){let r=typeof l.abort==="string"?l.abort:l.abort?.error?.message||"aborted";console.warn(` \u21B3 ${w} \u2014 middleware aborted: ${r}`);return}}let P=I.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(P)try{if(!await Function("route",`
13018
13018
  const validate = ${P[1]};
13019
13019
  return validate(route);
13020
- `)({params:R})){console.warn(`Validation failed for ${w}, skipping...`);return}}catch{}let C=null,g=!1;if(X.cache){if(C=_.get(w,N.filePath),C)g=!0,J.cachedCount++}if(!C){let b=await AO(N,R,T,X,Y);if(C=b.html,X.cache)_.set(w,N.filePath,b.dependencies,C)}let s;if(X.trailingSlash)s=F0.join(X.outputDir,w,"index.html");else s=w==="/"?F0.join(X.outputDir,"index.html"):F0.join(X.outputDir,`${w}.html`);if(X.chunkIslands){let{html:b,chunks:d}=HO(C,{integrity:X.integrityIslands,minify:X.minify});if(d.length>0){let l=F0.join(X.outputDir,"_stx","islands");await l0.promises.mkdir(l,{recursive:!0});for(let r of d){let a=F0.join(l,`${r.hash}.js`);if(!await Bun.file(a).exists())await Bun.write(a,r.code);if(!Q.has(r.hash)){Q.add(r.hash);let B0=Buffer.byteLength(r.code,"utf8");G+=B0,K[r.hash]={bytes:B0,file:`/_stx/islands/${r.hash}.js`}}}if(W[w]=d.map((r)=>r.hash),C=b,X.prefetchIslands)C=OO(C)}}await l0.promises.mkdir(F0.dirname(s),{recursive:!0}),await Bun.write(s,C),O.push({loc:w,lastmod:new Date().toISOString().split("T")[0],priority:w==="/"?1:0.8});let m={route:w,outputPath:s,size:Buffer.byteLength(C,"utf8"),cached:g};if(E!==!1)m.revalidateAt=Date.now()+E*1000;J.pages.push(m),J.successCount++,await X.hooks.onPageEnd?.(w,C)}catch(I){J.failedCount++,J.errors.push({route:w,error:I}),await X.hooks.onError?.(I,w),console.error(`Error generating ${w}:`,I)}}));if(X.cache)await _.save();if(X.generate404){let F=F0.join(X.pagesDir,"404.stx");if(await Bun.file(F).exists()){let A=new Set,N={...Y,debug:!1,cache:!1},w=await W0(await Bun.file(F).text(),{},F,N,A);await Bun.write(F0.join(X.outputDir,"404.html"),w)}else await Bun.write(F0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
13020
+ `)({params:R})){console.warn(`Validation failed for ${w}, skipping...`);return}}catch{}let C=null,g=!1;if(X.cache){if(C=_.get(w,N.filePath),C)g=!0,J.cachedCount++}if(!C){let b=await AO(N,R,T,X,Y);if(C=b.html,X.cache)_.set(w,N.filePath,b.dependencies,C)}let s;if(X.trailingSlash)s=A0.join(X.outputDir,w,"index.html");else s=w==="/"?A0.join(X.outputDir,"index.html"):A0.join(X.outputDir,`${w}.html`);if(X.chunkIslands){let{html:b,chunks:d}=HO(C,{integrity:X.integrityIslands,minify:X.minify});if(d.length>0){let l=A0.join(X.outputDir,"_stx","islands");await l0.promises.mkdir(l,{recursive:!0});for(let r of d){let a=A0.join(l,`${r.hash}.js`);if(!await Bun.file(a).exists())await Bun.write(a,r.code);if(!Q.has(r.hash)){Q.add(r.hash);let q0=Buffer.byteLength(r.code,"utf8");G+=q0,K[r.hash]={bytes:q0,file:`/_stx/islands/${r.hash}.js`}}}if(W[w]=d.map((r)=>r.hash),C=b,X.prefetchIslands)C=OO(C)}}await l0.promises.mkdir(A0.dirname(s),{recursive:!0}),await Bun.write(s,C),O.push({loc:w,lastmod:new Date().toISOString().split("T")[0],priority:w==="/"?1:0.8});let m={route:w,outputPath:s,size:Buffer.byteLength(C,"utf8"),cached:g};if(E!==!1)m.revalidateAt=Date.now()+E*1000;J.pages.push(m),J.successCount++,await X.hooks.onPageEnd?.(w,C)}catch(I){J.failedCount++,J.errors.push({route:w,error:I}),await X.hooks.onError?.(I,w),console.error(`Error generating ${w}:`,I)}}));if(X.cache)await _.save();if(X.generate404){let F=A0.join(X.pagesDir,"404.stx");if(await Bun.file(F).exists()){let A=new Set,N={...Y,debug:!1,cache:!1},w=await W0(await Bun.file(F).text(),{},F,N,A);await Bun.write(A0.join(X.outputDir,"404.html"),w)}else await Bun.write(A0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
13021
13021
  <html lang="en">
13022
13022
  <head>
13023
13023
  <meta charset="UTF-8">
@@ -13038,7 +13038,7 @@ ${Y.join(`
13038
13038
  <a href="/">Go home</a>
13039
13039
  </div>
13040
13040
  </body>
13041
- </html>`)}for(let F of[500]){let A=F0.join(X.pagesDir,`${F}.stx`);if(await Bun.file(A).exists()){let N=new Set,w={...Y,debug:!1,cache:!1},R=await W0(await Bun.file(A).text(),{},A,w,N);await Bun.write(F0.join(X.outputDir,`${F}.html`),R)}}let L=F0.join(X.pagesDir,"error.stx");if(await Bun.file(L).exists()){let F=new Set,A={...Y,debug:!1,cache:!1},N=await W0(await Bun.file(L).text(),{},L,A,F);await Bun.write(F0.join(X.outputDir,"error.html"),N)}if(X.sitemap&&O.length>0){let F=RC(O,X.domain),A=F0.join(X.outputDir,"sitemap.xml");await Bun.write(A,F),J.sitemapPath=A,console.log(`Generated sitemap.xml with ${O.length} URLs`)}if(X.rss){let F=typeof X.rss==="object"?X.rss:{title:"Site Feed",description:"Latest updates",link:X.domain},A=[];if(F.getItems)A=await F.getItems();let N=MC(F,A),w=F0.join(X.outputDir,"rss.xml");await Bun.write(w,N),J.rssPath=w,console.log(`Generated rss.xml with ${A.length} items`)}if(X.publicDir&&l0.existsSync(X.publicDir))await wO(X.publicDir,X.outputDir),console.log(`Copied public assets from ${X.publicDir}`)}catch(_){throw await X.hooks.onError?.(_),_}if(J.buildTime=Date.now()-Z,Q.size>0){J.islandChunks={count:Q.size,totalBytes:G};let _={generatedChunks:Q.size,totalBytes:G,chunks:K,pages:W};await Bun.write(F0.join(X.outputDir,"_stx","islands-manifest.json"),JSON.stringify(_,null,2))}await X.hooks.onBuildEnd?.(J);let U=J.islandChunks?`
13041
+ </html>`)}for(let F of[500]){let A=A0.join(X.pagesDir,`${F}.stx`);if(await Bun.file(A).exists()){let N=new Set,w={...Y,debug:!1,cache:!1},R=await W0(await Bun.file(A).text(),{},A,w,N);await Bun.write(A0.join(X.outputDir,`${F}.html`),R)}}let L=A0.join(X.pagesDir,"error.stx");if(await Bun.file(L).exists()){let F=new Set,A={...Y,debug:!1,cache:!1},N=await W0(await Bun.file(L).text(),{},L,A,F);await Bun.write(A0.join(X.outputDir,"error.html"),N)}if(X.sitemap&&O.length>0){let F=RC(O,X.domain),A=A0.join(X.outputDir,"sitemap.xml");await Bun.write(A,F),J.sitemapPath=A,console.log(`Generated sitemap.xml with ${O.length} URLs`)}if(X.rss){let F=typeof X.rss==="object"?X.rss:{title:"Site Feed",description:"Latest updates",link:X.domain},A=[];if(F.getItems)A=await F.getItems();let N=MC(F,A),w=A0.join(X.outputDir,"rss.xml");await Bun.write(w,N),J.rssPath=w,console.log(`Generated rss.xml with ${A.length} items`)}if(X.publicDir&&l0.existsSync(X.publicDir))await wO(X.publicDir,X.outputDir),console.log(`Copied public assets from ${X.publicDir}`)}catch(_){throw await X.hooks.onError?.(_),_}if(J.buildTime=Date.now()-Z,Q.size>0){J.islandChunks={count:Q.size,totalBytes:G};let _={generatedChunks:Q.size,totalBytes:G,chunks:K,pages:W};await Bun.write(A0.join(X.outputDir,"_stx","islands-manifest.json"),JSON.stringify(_,null,2))}await X.hooks.onBuildEnd?.(J);let U=J.islandChunks?`
13042
13042
  Island chunks: ${J.islandChunks.count} (${(J.islandChunks.totalBytes/1024).toFixed(1)} KB lifted out of inline HTML)`:"";return console.log(`
13043
13043
  Build complete!
13044
13044
  Total: ${J.totalPages} pages
@@ -13046,7 +13046,7 @@ Build complete!
13046
13046
  Cached: ${J.cachedCount}
13047
13047
  Failed: ${J.failedCount}
13048
13048
  Time: ${J.buildTime}ms${U}
13049
- `),J}async function wO($,Z){let Y=await l0.promises.readdir($,{withFileTypes:!0});for(let X of Y){let J=F0.join($,X.name),Q=F0.join(Z,X.name);if(X.isDirectory())await l0.promises.mkdir(Q,{recursive:!0}),await wO(J,Q);else await l0.promises.copyFile(J,Q)}}function RO($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new FO(Z),X=$.revalidate||3600;return{async get(J){let Q=await Y.get(J);if(!Q)return null;if(Date.now()>Q.revalidateAfter)this.revalidate(J).catch(console.error);return{html:Q.html,headers:{"Cache-Control":`public, max-age=${X}, stale-while-revalidate=${X*2}`,ETag:Q.etag,"X-ISR-Generated":new Date(Q.generatedAt).toISOString(),...Q.headers}}},async revalidate(J){let G=w4(".",{pagesDir:$.pagesDir||"pages"}).find((z)=>{return J.match(z.regex)!==null});if(!G){console.warn(`Route not found for revalidation: ${J}`);return}let K=J.match(G.regex),W={};if(K)G.params.forEach((z,B)=>{W[z]=K[B+1]});let U=await c0(),{html:_}=await AO(G,W,{},$,U);await Y.set(J,{html:_,generatedAt:Date.now(),revalidateAfter:Date.now()+X*1000,etag:wC(_)}),console.log(`Revalidated: ${J}`)},async invalidate(J){if(typeof J==="string")await Y.invalidate(J);else await Y.invalidatePattern(J)}}}function MO($){return async()=>{return{paths:await $(),fallback:!1}}}function TO(){return{name:"markdown",extensions:[".md",".mdx"],async load($){let Z=await Bun.file($).text(),Y=Z.match(/^---\n([\s\S]*?)\n---/),X={},J=Z;if(Y){let U=Y[1];J=Z.slice(Y[0].length).trim();for(let _ of U.split(`
13049
+ `),J}async function wO($,Z){let Y=await l0.promises.readdir($,{withFileTypes:!0});for(let X of Y){let J=A0.join($,X.name),Q=A0.join(Z,X.name);if(X.isDirectory())await l0.promises.mkdir(Q,{recursive:!0}),await wO(J,Q);else await l0.promises.copyFile(J,Q)}}function RO($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new FO(Z),X=$.revalidate||3600;return{async get(J){let Q=await Y.get(J);if(!Q)return null;if(Date.now()>Q.revalidateAfter)this.revalidate(J).catch(console.error);return{html:Q.html,headers:{"Cache-Control":`public, max-age=${X}, stale-while-revalidate=${X*2}`,ETag:Q.etag,"X-ISR-Generated":new Date(Q.generatedAt).toISOString(),...Q.headers}}},async revalidate(J){let G=w4(".",{pagesDir:$.pagesDir||"pages"}).find((z)=>{return J.match(z.regex)!==null});if(!G){console.warn(`Route not found for revalidation: ${J}`);return}let K=J.match(G.regex),W={};if(K)G.params.forEach((z,B)=>{W[z]=K[B+1]});let U=await c0(),{html:_}=await AO(G,W,{},$,U);await Y.set(J,{html:_,generatedAt:Date.now(),revalidateAfter:Date.now()+X*1000,etag:wC(_)}),console.log(`Revalidated: ${J}`)},async invalidate(J){if(typeof J==="string")await Y.invalidate(J);else await Y.invalidatePattern(J)}}}function MO($){return async()=>{return{paths:await $(),fallback:!1}}}function TO(){return{name:"markdown",extensions:[".md",".mdx"],async load($){let Z=await Bun.file($).text(),Y=Z.match(/^---\n([\s\S]*?)\n---/),X={},J=Z;if(Y){let U=Y[1];J=Z.slice(Y[0].length).trim();for(let _ of U.split(`
13050
13050
  `)){let z=_.indexOf(":");if(z>0){let B=_.slice(0,z).trim(),q=_.slice(z+1).trim();if(q==="true")q=!0;else if(q==="false")q=!1;else if(/^\d+$/.test(q))q=parseInt(q,10);else if(/^\d+\.\d+$/.test(q))q=parseFloat(q);else if(q.startsWith("[")&&q.endsWith("]"))q=q.slice(1,-1).split(",").map((j)=>j.trim().replace(/^['"]|['"]$/g,""));X[B]=q}}}let Q=J.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),G=[],K=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,W;while((W=K.exec(Q))!==null){let U=parseInt(W[1],10),_=W[2],z=_.toLowerCase().replace(/[^a-z0-9]+/g,"-");G.push({id:z,text:_,level:U})}return{content:Q,data:X,toc:G}}}}function TC($){let Z=$.match(/definePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!Z)return null;try{return Function(`return ${Z[1]}`)()}catch{return null}}function EC($,Z){return`<!DOCTYPE html>
13051
13051
  <html>
13052
13052
  <head>
@@ -13059,7 +13059,7 @@ Build complete!
13059
13059
  <p>Redirecting to <a href="${$}">${$}</a>...</p>
13060
13060
  <script>window.location.replace('${$}')</script>
13061
13061
  </body>
13062
- </html>`}function IC($,Z){if($==="/"||$==="")return F0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return F0.join(Z.outputDir,Y,"index.html");return F0.join(Z.outputDir,`${Y}.html`)}var DC;var IO=D(()=>{B8();U1();LO();i0();o1();mY();DC={generateStaticSite:NO,createISRHandler:RO,defineStaticPaths:MO,createMarkdownLoader:TO}});import{createHash as kC}from"crypto";import{getRouterScript as SC}from"stx-router";function qG($){return kC("sha256").update($).digest("hex").slice(0,8)}function jG($=!1){let Z=$?C6():N7(),Y=qG(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function HG(){let $=SC(),Z=qG($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function CC($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var OG=D(()=>{R$()});import DO from"path";import{createHash as bC}from"crypto";function PC($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function LG($,Z,Y={}){let X=DO.resolve($),J=await Bun.file(X).text(),Q=bC("sha256").update(J).digest("hex").slice(0,16);aX();let G={};try{G=await c0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:_}=PC({__filename:X,__dirname:DO.dirname(X)}),z=new Set,B={...O1,...G,...Y,buildMode:"compile",strict:!1},q=await W0(J,_,X,B,z),j=N4(q),H=sX();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(z),contentHash:Q,streamTemplates:_.__streamTemplates}}var VG=D(()=>{U1();i0();u5();j5()});import FG from"fs";import kO from"path";function AG($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function NG($,Z){let Y=kO.join(Z,"manifest.json");FG.writeFileSync(Y,JSON.stringify($,null,2))}function wG($){let Z=kO.join($,"manifest.json");if(!FG.existsSync(Z))return null;try{let Y=FG.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var iY=()=>{};var CO={};e(CO,{buildForProduction:()=>SO});import Q4 from"fs";import Q1 from"path";function xC($,Z){let Y=0,X=0;if(!Q4.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=Q4.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(yC.has(W.name))continue;let U=Q1.join(Q,W.name),_=Q1.join(G,W.name);if(W.isDirectory())Q4.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(Q4.existsSync(_))continue;Q4.copyFileSync(U,_),Y++,X+=Q4.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function SO($={}){let Z=Date.now(),Y=Q1.resolve($.root||process.cwd()),X=Q1.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await c0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},_=J.router?.container||"main";if(Q4.existsSync(X))Q4.rmSync(X,{recursive:!0});let z=[Q1.join(X,"public","__stx"),Q1.join(X,"public","assets"),Q1.join(X,"server","pages"),Q1.join(X,"server","fragments")];for(let R of z)Q4.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let B=w4(Y),q=["components","layouts","partials"],j=B.filter((R)=>{return!q.some((T)=>R.pattern.startsWith(`/${T}/`)||R.pattern===`/${T}`)});console.log(`[stx build] Found ${j.length} page routes (${B.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=jG($.debug),O=HG();await Bun.write(Q1.join(X,"public","__stx",H.filename),H.content),await Bun.write(Q1.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let V=[],L=[];for(let R of j)try{let T=await LG(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(V.push(T),T.html=T.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),T.html=q7(T.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(T.html)){let x=T.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(x&&x[1]){let P=x[1];T.html=T.html.replace(" "+P,""),T.html=T.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}T.html=T.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),T.html=await C0(T.html),T.fragment=_8(T.html,_);let I=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),k=Q1.join("server","pages",`${I}.compiled.json`),S=Q1.join("server","fragments",`${I}.html`);await Bun.write(Q1.join(X,k),JSON.stringify(T,null,2)),await Bun.write(Q1.join(X,S),T.fragment),L.push({pattern:R.pattern,compiledPath:k,fragmentPath:S,isDynamic:T.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(T){console.error(`[stx build] \u2717 ${R.pattern}:`,T instanceof Error?T.message:T)}let F=Q1.resolve(Y,W);if(Q4.existsSync(F)){let{copied:R,bytes:T}=xC(F,Q1.join(X,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(T/1024).toFixed(1)}KB) from ${W}/`)}let A={runtime:H.filename,router:O.filename},N=AG(L,A,X);NG(N,X);let w=Date.now()-Z;return console.log(`
13062
+ </html>`}function IC($,Z){if($==="/"||$==="")return A0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return A0.join(Z.outputDir,Y,"index.html");return A0.join(Z.outputDir,`${Y}.html`)}var DC;var IO=D(()=>{B8();U1();LO();i0();o1();mY();DC={generateStaticSite:NO,createISRHandler:RO,defineStaticPaths:MO,createMarkdownLoader:TO}});import{createHash as kC}from"crypto";import{getRouterScript as SC}from"stx-router";function qG($){return kC("sha256").update($).digest("hex").slice(0,8)}function jG($=!1){let Z=$?C6():N7(),Y=qG(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function HG(){let $=SC(),Z=qG($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function CC($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var OG=D(()=>{R$()});import DO from"path";import{createHash as bC}from"crypto";function PC($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function LG($,Z,Y={}){let X=DO.resolve($),J=await Bun.file(X).text(),Q=bC("sha256").update(J).digest("hex").slice(0,16);aX();let G={};try{G=await c0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:_}=PC({__filename:X,__dirname:DO.dirname(X)}),z=new Set,B={...O1,...G,...Y,buildMode:"compile",strict:!1},q=await W0(J,_,X,B,z),j=N4(q),H=sX();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(z),contentHash:Q,streamTemplates:_.__streamTemplates}}var VG=D(()=>{U1();i0();u5();j5()});import FG from"fs";import kO from"path";function AG($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function NG($,Z){let Y=kO.join(Z,"manifest.json");FG.writeFileSync(Y,JSON.stringify($,null,2))}function wG($){let Z=kO.join($,"manifest.json");if(!FG.existsSync(Z))return null;try{let Y=FG.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var iY=()=>{};var CO={};e(CO,{buildForProduction:()=>SO});import Q4 from"fs";import Q1 from"path";function xC($,Z){let Y=0,X=0;if(!Q4.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=Q4.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(yC.has(W.name))continue;let U=Q1.join(Q,W.name),_=Q1.join(G,W.name);if(W.isDirectory())Q4.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(Q4.existsSync(_))continue;Q4.copyFileSync(U,_),Y++,X+=Q4.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function SO($={}){let Z=Date.now(),Y=Q1.resolve($.root||process.cwd()),X=Q1.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await c0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},_=J.router?.container||"main";if(Q4.existsSync(X))Q4.rmSync(X,{recursive:!0});let z=[Q1.join(X,"public","__stx"),Q1.join(X,"public","assets"),Q1.join(X,"server","pages"),Q1.join(X,"server","fragments")];for(let R of z)Q4.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let B=w4(Y),q=["components","layouts","partials"],j=B.filter((R)=>{return!q.some((T)=>R.pattern.startsWith(`/${T}/`)||R.pattern===`/${T}`)});console.log(`[stx build] Found ${j.length} page routes (${B.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=jG($.debug),O=HG();await Bun.write(Q1.join(X,"public","__stx",H.filename),H.content),await Bun.write(Q1.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let V=[],L=[];for(let R of j)try{let T=await LG(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(V.push(T),T.html=T.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),T.html=q7(T.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(T.html)){let x=T.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(x&&x[1]){let P=x[1];T.html=T.html.replace(" "+P,""),T.html=T.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}T.html=T.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),T.html=await C0(T.html),T.fragment=_8(T.html,_);let I=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),k=Q1.join("server","pages",`${I}.compiled.json`),S=Q1.join("server","fragments",`${I}.html`);await Bun.write(Q1.join(X,k),JSON.stringify(T,null,2)),await Bun.write(Q1.join(X,S),T.fragment),L.push({pattern:R.pattern,compiledPath:k,fragmentPath:S,isDynamic:T.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(T){console.error(`[stx build] \u2717 ${R.pattern}:`,T instanceof Error?T.message:T)}let F=Q1.resolve(Y,W);if(Q4.existsSync(F)){let{copied:R,bytes:T}=xC(F,Q1.join(X,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(T/1024).toFixed(1)}KB) from ${W}/`)}let A={runtime:H.filename,router:O.filename},N=AG(L,A,X);NG(N,X);let w=Date.now()-Z;return console.log(`
13063
13063
  [stx build] Done in ${w}ms \u2014 ${V.length} pages compiled`),{pageCount:V.length,assets:A,outputDir:X,duration:w}}var yC;var RG=D(()=>{B8();OG();VG();iY();j5();o1();i0();yC=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var PO={};e(PO,{buildApp:()=>bO});import vC from"path";async function bO($={}){let Z=performance.now(),Y=$.root||process.cwd(),X=await c0(),J=X.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${J.toUpperCase()}${X.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(J==="ssg"){let{generateStaticSite:W}=await Promise.resolve().then(() => (IO(),EO));Q=await W({pagesDir:vC.join(X.root||".",X.pagesDir||X.build?.pagesDir||"pages"),publicDir:X.publicDir||X.build?.publicDir||"public",outputDir:X.build?.outputDir||"dist",generate404:X.build?.generate404??!0,minify:X.build?.minify??!0,cleanOutput:X.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:W}=await Promise.resolve().then(() => (RG(),CO));G=await W({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-Z);return{mode:J,ssg:Q,ssr:G,duration:K}}var MG=D(()=>{i0()});import nY from"path";async function gC($){let Z=performance.now(),Y=await c0($),X=$||Y.root||process.cwd(),J=[Y.build?.pagesDir||Y.pagesDir||"pages",Y.componentsDir||"components",Y.layoutsDir||"layouts",Y.partialsDir||"partials"].map((K)=>nY.resolve(X,K)),Q=[],G=0;for(let K of J){let W=await xO(K);for(let U of W){G++;let _=await Bun.file(U).text();if(yO.test(_))Q.push(nY.relative(X,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-Z)}}async function hC($){let Z=await c0($),Y=$||Z.root||process.cwd(),X=nY.resolve(Y,Z.componentsDir||"components"),J=[],Q=await xO(X);for(let G of Q){let K=await Bun.file(G).text(),W=yO.test(K),U=fC.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let _=nY.relative(Y,G);J.push({file:_,message:`Component "${_}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return J}async function xO($){let Z=[];try{let Y=new Bun.Glob("**/*.stx");for await(let X of Y.scan({cwd:$,absolute:!0}))Z.push(X)}catch{}return Z}var yO,fC;var vO=D(()=>{i0();yO=/<script\b[^>]*\bserver\b/i,fC=/<script\b[^>]*\bclient\b/i});function TG($){let Z=new Map,Y=/@(\w+)/g,X,J=1,Q=0;while((X=Y.exec($))!==null){let G=X[1],K=$.slice(Q,X.index);J+=(K.match(/\n/g)||[]).length,Q=X.index;let W=X.index-$.lastIndexOf(`
13064
13064
  `,X.index-1);if(gO.includes(G)){let U=Z.get(G);if(U)U.count++,U.locations.push({line:J,column:W});else Z.set(G,{name:G,count:1,locations:[{line:J,column:W}]})}}return Array.from(Z.values())}function hO($,Z=[]){let Y=TG($),X=new Set(Y.map((J)=>J.name));for(let J of Z)X.add(J);for(let J of Array.from(X))if(!J.startsWith("end"))X.add(`end${J}`);return gO.filter((J)=>!X.has(J))}function dO($){let Z=[],Y={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},X=new Set;for(let Q of $)for(let[G,K]of Object.entries(Y))if(K.includes(Q)){X.add(G);break}for(let Q of X)Z.push(`import { process${uC(Q)} } from './${Q}'`);let J=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
13065
13065
  `);return`// Tree-shaken directive bundle
@@ -13074,7 +13074,7 @@ ${J}
13074
13074
  export function isDirectiveActive(name: string): boolean {
13075
13075
  return name in activeDirectives
13076
13076
  }
13077
- `}function uO($,Z={}){let Y=[],X=/@if\(([^)]+)\)[\s\S]*?@endif/g,J=$.matchAll(X);for(let U of J){let _=U[1].trim();if(rY(_,Z)===!1)Y.push({start:U.index,end:U.index+U[0].length,reason:`@if condition always false: ${_}`})}let Q=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,G=$.matchAll(Q);for(let U of G){let _=U[1].trim();if(rY(_,Z)===!0)Y.push({start:U.index,end:U.index+U[0].length,reason:`@unless condition always true: ${_}`})}let K=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(Z.__ENV__==="production"){let U=$.matchAll(K);for(let _ of U)Y.push({start:_.index,end:_.index+_[0].length,reason:"Development-only code in production build"})}let W=/@debug[\s\S]*?@enddebug/g;if(Z.__ENV__==="production"){let U=$.matchAll(W);for(let _ of U)Y.push({start:_.index,end:_.index+_[0].length,reason:"Debug code in production build"})}return Y}function mO($,Z={}){let Y=uO($,Z),X=[];Y.sort((Q,G)=>G.start-Q.start);let J=$;for(let Q of Y)J=J.slice(0,Q.start)+J.slice(Q.end),X.push(Q.reason);return{content:J,removed:X}}function rY($,Z){if($==="true")return!0;if($==="false")return!1;if($==="null")return null;if(/^\d+$/.test($))return Number.parseInt($,10);if(/^\d+\.\d+$/.test($))return Number.parseFloat($);if(/^['"].*['"]$/.test($))return $.slice(1,-1);if($ in Z)return Z[$];let Y=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Y){let[,X,J,Q]=Y,G=X in Z?Z[X]:void 0,K=rY(Q,Z);if(G!==void 0&&K!==void 0)switch(J){case"==":case"===":return G===K;case"!=":case"!==":return G!==K;case">":return G>K;case"<":return G<K;case">=":return G>=K;case"<=":return G<=K}}return}function cO($,Z){let Y=[],X=$;return X=X.replace(/\{\{\s*(\w+)\s*\}\}/g,(J,Q)=>{if(Q in Z)return Y.push(`{{ ${Q} }} -> ${Z[Q]}`),String(Z[Q]);return J}),X=X.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(J,Q,G,K)=>{let W=Number.parseInt(Q,10),U=Number.parseInt(K,10),_;switch(G){case"+":_=W+U;break;case"-":_=W-U;break;case"*":_=W*U;break;default:return J}return Y.push(`{{ ${Q} ${G} ${K} }} -> ${_}`),String(_)}),{content:X,folded:Y}}function lO($){let Z=$,Y=[],X=0;Z=Z.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(J)=>{let Q=`__PRESERVE_${X++}__`;return Y.push({marker:Q,content:J}),Q}),Z=Z.replace(/\{\{([\s\S]*?)\}\}/g,(J)=>{let Q=`__PRESERVE_${X++}__`;return Y.push({marker:Q,content:J}),Q}),Z=Z.replace(/\{\{--([\s\S]*?)--\}\}/g,""),Z=Z.replace(/<!--[\s\S]*?-->/g,""),Z=Z.replace(/>\s+</g,"><"),Z=Z.replace(/^\s+/gm,""),Z=Z.replace(/\s+$/gm,""),Z=Z.replace(/\s{2,}/g," ");for(let{marker:J,content:Q}of Y){let G=Z.indexOf(J);if(G!==-1)Z=Z.slice(0,G)+Q+Z.slice(G+J.length)}return Z.trim()}function pO($){let Z=new Map,Y=new Map,X=/(['"])([^'"]{10,})\1/g,J;while((J=X.exec($))!==null){let K=J[2];Y.set(K,(Y.get(K)||0)+1)}let Q=0,G=$;for(let[K,W]of Y)if(W>1){let U=`__STR_${Q++}__`;Z.set(U,K);let _=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=new RegExp(`(['"])${_}\\1`,"g");G=G.replace(z,U)}return{content:G,pool:Z,count:Z.size}}function iO($,Z={}){let Y={...fO,...Z},X=new Blob([$]).size,J=$,Q=[],G=[],K=[],W=[],U=0;if(Y.target==="production")Y.constants={...Y.constants,__ENV__:"production"};if(Y.deadCodeElimination){let B=mO(J,Y.constants);if(J=B.content,B.removed.length>0)Q.push("Dead code elimination"),G.push(...B.removed.map((q)=>`Removed: ${q}`))}if(Y.constantFolding&&Object.keys(Y.constants).length>0){let B=cO(J,Y.constants);if(J=B.content,W=B.folded,W.length>0)Q.push("Constant folding")}if(Y.treeShake){if(K=hO(J,Y.preserveDirectives),K.length>0)Q.push("Tree shaking")}if(Y.stringPooling){let B=pO(J);if(J=B.content,U=B.count,U>0)Q.push("String pooling")}if(Y.minifyHtml){let B=lO(J);if(B.length<J.length)J=B,Q.push("HTML minification")}let _=new Blob([J]).size,z=X>0?Math.round((1-_/X)*100):0;return{content:J,originalSize:X,optimizedSize:_,reduction:z,appliedOptimizations:Q,removedDirectives:K,foldedConstants:W,pooledStrings:U,warnings:G}}async function dC($,Z={}){let Y={...fO,...Z},X=new Map,J=[],Q=0,G=0,K=new Set;for(let[z,B]of $){let q=iO(B,Y);X.set(z,q),Q+=q.originalSize,G+=q.optimizedSize,J.push(...q.warnings.map((H)=>`${z}: ${H}`));let j=TG(B);for(let H of j)K.add(H.name)}let W;if(Y.treeShake)W=dO(Array.from(K));let U;if(Y.stringPooling)U=new Map;let _=Q>0?Math.round((1-G/Q)*100):0;return{templates:X,directiveBundle:W,stringPool:U,totalOriginalSize:Q,totalOptimizedSize:G,overallReduction:_,warnings:J}}function uC($){return $.charAt(0).toUpperCase()+$.slice(1)}var fO,gO;var nO=D(()=>{fO={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},gO=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"]});var DG={};e(DG,{toUsers:()=>$L,toUser:()=>eO,stopBroadcasting:()=>oO,startBroadcasting:()=>sO,loadChannels:()=>tO,getBroadcastServer:()=>aO,channel:()=>XL,broadcastPrivate:()=>ZL,broadcastPresence:()=>YL,broadcast:()=>IG,BroadcastServer:()=>QL,Broadcast:()=>JL});import{Broadcast as H5,BroadcastServer as mC}from"ts-broadcasting";import{channel as XL}from"ts-broadcasting";import{Broadcast as JL,BroadcastServer as QL}from"ts-broadcasting";function aO(){return S1}async function sO($){if(S1)return S1;let Z=$.driver??"bun",Y=$.host??"0.0.0.0",X=$.port??6001,J=$.scheme??"ws",Q={verbose:$.verbose??!1,driver:Z,default:Z,connections:{[Z]:{driver:Z,host:Y,port:X,scheme:J}}};return S1=new mC(Q),H5.setServer(S1),await S1.start(),S1}async function oO(){for(let $ of EG)clearInterval($);if(EG.length=0,!S1)return;await S1.stop(),S1=null}async function tO($){let Z=await import($),Y=Z.default??Z;if(typeof Y!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof Y}`);let X=0;return Y({channel(Q,G){if(X++,G.authorize&&S1)S1.channels.channel(Q,G.authorize);if(G.interval&&G.data){let K=G.event??`${Q}.updated`,W=G.data,U=setInterval(async()=>{try{let _=await W();IG(Q,K,_)}catch{}},G.interval);EG.push(U)}}}),X}function q8(){if(S1)return!0;if(!rO)rO=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function IG($,Z,Y){if(!q8())return;H5.send($,Z,Y)}function eO($,Z,Y){if(!q8())return;H5.toUser($,Z,Y)}function $L($,Z,Y){if(!q8())return;H5.toUsers($,Z,Y)}function ZL($,Z,Y){if(!q8())return;H5.send(`private-${$}`,Z,Y)}function YL($,Z,Y){if(!q8())return;H5.presence($,Z,Y)}var S1=null,EG,rO=!1;var aY=D(()=>{EG=[]});function GL($,Z){let Y={},X=$.trim();if(X.startsWith("{"))X=X.slice(1);if(X.endsWith("}"))X=X.slice(0,-1);if(X=X.trim(),!X)return Y;let J=0;while(J<X.length){while(J<X.length&&/\s/.test(X[J]))J++;if(J>=X.length)break;let Q="";if(X[J]==='"'||X[J]==="'"){let W=X[J];J++;while(J<X.length&&X[J]!==W)if(X[J]==="\\"&&J+1<X.length)Q+=X[J+1],J+=2;else Q+=X[J],J++;J++}else while(J<X.length&&/[\w$]/.test(X[J]))Q+=X[J],J++;while(J<X.length&&/\s/.test(X[J]))J++;if(X[J]===":")J++;while(J<X.length&&/\s/.test(X[J]))J++;let G,K=J;if(X[J]==='"'||X[J]==="'"){let W=X[J];J++;let U="";while(J<X.length&&X[J]!==W)if(X[J]==="\\"&&J+1<X.length)U+=X[J+1],J+=2;else U+=X[J],J++;J++,G=U}else if(X[J]==="{"){let W=1;J++;while(J<X.length&&W>0){if(X[J]==="{")W++;else if(X[J]==="}")W--;else if(X[J]==='"'||X[J]==="'"){let _=X[J];J++;while(J<X.length&&X[J]!==_){if(X[J]==="\\")J++;J++}}J++}let U=X.slice(K,J);G=GL(U,Z)}else if(X[J]==="["){let W=1;J++;while(J<X.length&&W>0){if(X[J]==="[")W++;else if(X[J]==="]")W--;else if(X[J]==='"'||X[J]==="'"){let _=X[J];J++;while(J<X.length&&X[J]!==_){if(X[J]==="\\")J++;J++}}J++}let U=X.slice(K,J);try{G=JSON.parse(U.replace(/'/g,'"'))}catch{G=U}}else{let W="";while(J<X.length&&X[J]!==","&&!/\s/.test(X[J]))W+=X[J],J++;if(W=W.trim(),W==="true")G=!0;else if(W==="false")G=!1;else if(W==="null")G=null;else if(W==="undefined")G=void 0;else if(/^-?\d+(\.\d+)?$/.test(W))G=Number(W);else if(W in Z)G=Z[W];else G=W}if(Q)Y[Q]=G;while(J<X.length&&/\s/.test(X[J]))J++;if(X[J]===",")J++}return Y}function cC($,Z,Y){let X=[];for(let[J,Q]of Object.entries(Z)){let G=$[J];if(Q.required&&(G===void 0||G===null)){X.push(`Component "${Y}": Missing required prop "${J}"`);continue}if(G===void 0||G===null)continue;let K=Array.isArray(Q.type)?Q.type:[Q.type];if(!K.includes("any")){let W=pC(G);if(!K.includes(W))X.push(`Component "${Y}": Prop "${J}" expected ${K.join(" | ")}, got ${W}`)}if(Q.validator&&!Q.validator(G))X.push(`Component "${Y}": Prop "${J}" failed custom validation`)}return X}function lC($,Z){let Y={...$};for(let[X,J]of Object.entries(Z))if(Y[X]===void 0&&J.default!==void 0)Y[X]=typeof J.default==="function"?J.default():J.default;return Y}function pC($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}function iC(){return[KL]}var KL;var WL=D(()=>{R1();p0();A0();KL={name:"component",handler:async($,Z,Y,X)=>{if(Z.length<1)return U0("Component","component directive requires at least the component name",J0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q={};if(Z.length>1)try{let _=Z.slice(1).join(",").trim();if(_.startsWith("{")){if(Q=d0(_,Y),Object.keys(Q).length===0)Q=GL(_,Y)}else{let z=_.trim(),B=Y[z];if(B&&typeof B==="object"&&!Array.isArray(B))Q=B}}catch(_){let z=_ instanceof Error?_.message:String(_);return console.error("Component props parsing error:",z),U0("Component",`Error parsing component props: ${z}`,J0.EVALUATION_ERROR)}let G=Y.__stx_options||{},K=G.componentsDir||"components",W=new Set;if(!Y.__processedComponents)Y.__processedComponents=new Set;let U=Y.__processedComponents;try{return await e1(J,Q,"",K,Y,X,G,U,W)}catch(_){console.error("Component rendering error:",_);let z=_ instanceof Error?_.message:String(_);return U0("Component",`Error rendering component: ${z}`,J0.COMPONENT_RENDER_ERROR)}},hasEndTag:!1}});import kG from"fs";import j8 from"path";async function UL($){try{let Y=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return[];let X=Y[1],J=[],Q=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,G;while((G=Q.exec(X))!==null){let K=G[1],W=G[2]||G[3]||G[4];if(!W)continue;let U={name:W},_=K.match(/@type\s+\{([^}]+)\}/i);if(_)U.type=_[1].trim();if(K.match(/@required/i))U.required=!0;let B=K.match(/@default\s+(.+?)(?:\s+|$)/i);if(B)U.default=B[1].trim();let q=K.split(`
13077
+ `}function uO($,Z={}){let Y=[],X=/@if\(([^)]+)\)[\s\S]*?@endif/g,J=$.matchAll(X);for(let U of J){let _=U[1].trim();if(rY(_,Z)===!1)Y.push({start:U.index,end:U.index+U[0].length,reason:`@if condition always false: ${_}`})}let Q=/@unless\(([^)]+)\)[\s\S]*?@endunless/g,G=$.matchAll(Q);for(let U of G){let _=U[1].trim();if(rY(_,Z)===!0)Y.push({start:U.index,end:U.index+U[0].length,reason:`@unless condition always true: ${_}`})}let K=/@env\(['"]development['"]\)[\s\S]*?@endenv/g;if(Z.__ENV__==="production"){let U=$.matchAll(K);for(let _ of U)Y.push({start:_.index,end:_.index+_[0].length,reason:"Development-only code in production build"})}let W=/@debug[\s\S]*?@enddebug/g;if(Z.__ENV__==="production"){let U=$.matchAll(W);for(let _ of U)Y.push({start:_.index,end:_.index+_[0].length,reason:"Debug code in production build"})}return Y}function mO($,Z={}){let Y=uO($,Z),X=[];Y.sort((Q,G)=>G.start-Q.start);let J=$;for(let Q of Y)J=J.slice(0,Q.start)+J.slice(Q.end),X.push(Q.reason);return{content:J,removed:X}}function rY($,Z){if($==="true")return!0;if($==="false")return!1;if($==="null")return null;if(/^\d+$/.test($))return Number.parseInt($,10);if(/^\d+\.\d+$/.test($))return Number.parseFloat($);if(/^['"].*['"]$/.test($))return $.slice(1,-1);if($ in Z)return Z[$];let Y=$.match(/^(\w+)\s*(===|!==|==|!=|>=|<=|>|<)\s*(.+)$/);if(Y){let[,X,J,Q]=Y,G=X in Z?Z[X]:void 0,K=rY(Q,Z);if(G!==void 0&&K!==void 0)switch(J){case"==":case"===":return G===K;case"!=":case"!==":return G!==K;case">":return G>K;case"<":return G<K;case">=":return G>=K;case"<=":return G<=K}}return}function cO($,Z){let Y=[],X=$;return X=X.replace(/\{\{\s*(\w+)\s*\}\}/g,(J,Q)=>{if(Q in Z)return Y.push(`{{ ${Q} }} -> ${Z[Q]}`),String(Z[Q]);return J}),X=X.replace(/\{\{\s*(\d+)\s*([+\-*])\s*(\d+)\s*\}\}/g,(J,Q,G,K)=>{let W=Number.parseInt(Q,10),U=Number.parseInt(K,10),_;switch(G){case"+":_=W+U;break;case"-":_=W-U;break;case"*":_=W*U;break;default:return J}return Y.push(`{{ ${Q} ${G} ${K} }} -> ${_}`),String(_)}),{content:X,folded:Y}}function lO($){let Z=$,Y=[],X=0;Z=Z.replace(/<(pre|code|script|style)([^>]*)>([\s\S]*?)<\/\1>/gi,(J)=>{let Q=`__PRESERVE_${X++}__`;return Y.push({marker:Q,content:J}),Q}),Z=Z.replace(/\{\{([\s\S]*?)\}\}/g,(J)=>{let Q=`__PRESERVE_${X++}__`;return Y.push({marker:Q,content:J}),Q}),Z=Z.replace(/\{\{--([\s\S]*?)--\}\}/g,""),Z=Z.replace(/<!--[\s\S]*?-->/g,""),Z=Z.replace(/>\s+</g,"><"),Z=Z.replace(/^\s+/gm,""),Z=Z.replace(/\s+$/gm,""),Z=Z.replace(/\s{2,}/g," ");for(let{marker:J,content:Q}of Y){let G=Z.indexOf(J);if(G!==-1)Z=Z.slice(0,G)+Q+Z.slice(G+J.length)}return Z.trim()}function pO($){let Z=new Map,Y=new Map,X=/(['"])([^'"]{10,})\1/g,J;while((J=X.exec($))!==null){let K=J[2];Y.set(K,(Y.get(K)||0)+1)}let Q=0,G=$;for(let[K,W]of Y)if(W>1){let U=`__STR_${Q++}__`;Z.set(U,K);let _=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=new RegExp(`(['"])${_}\\1`,"g");G=G.replace(z,U)}return{content:G,pool:Z,count:Z.size}}function iO($,Z={}){let Y={...fO,...Z},X=new Blob([$]).size,J=$,Q=[],G=[],K=[],W=[],U=0;if(Y.target==="production")Y.constants={...Y.constants,__ENV__:"production"};if(Y.deadCodeElimination){let B=mO(J,Y.constants);if(J=B.content,B.removed.length>0)Q.push("Dead code elimination"),G.push(...B.removed.map((q)=>`Removed: ${q}`))}if(Y.constantFolding&&Object.keys(Y.constants).length>0){let B=cO(J,Y.constants);if(J=B.content,W=B.folded,W.length>0)Q.push("Constant folding")}if(Y.treeShake){if(K=hO(J,Y.preserveDirectives),K.length>0)Q.push("Tree shaking")}if(Y.stringPooling){let B=pO(J);if(J=B.content,U=B.count,U>0)Q.push("String pooling")}if(Y.minifyHtml){let B=lO(J);if(B.length<J.length)J=B,Q.push("HTML minification")}let _=new Blob([J]).size,z=X>0?Math.round((1-_/X)*100):0;return{content:J,originalSize:X,optimizedSize:_,reduction:z,appliedOptimizations:Q,removedDirectives:K,foldedConstants:W,pooledStrings:U,warnings:G}}async function dC($,Z={}){let Y={...fO,...Z},X=new Map,J=[],Q=0,G=0,K=new Set;for(let[z,B]of $){let q=iO(B,Y);X.set(z,q),Q+=q.originalSize,G+=q.optimizedSize,J.push(...q.warnings.map((H)=>`${z}: ${H}`));let j=TG(B);for(let H of j)K.add(H.name)}let W;if(Y.treeShake)W=dO(Array.from(K));let U;if(Y.stringPooling)U=new Map;let _=Q>0?Math.round((1-G/Q)*100):0;return{templates:X,directiveBundle:W,stringPool:U,totalOriginalSize:Q,totalOptimizedSize:G,overallReduction:_,warnings:J}}function uC($){return $.charAt(0).toUpperCase()+$.slice(1)}var fO,gO;var nO=D(()=>{fO={treeShake:!0,deadCodeElimination:!0,constantFolding:!0,stringPooling:!1,minifyHtml:!0,removeDevCode:!0,constants:{},preserveDirectives:[],target:"production"},gO=["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty","extends","section","endsection","yield","parent","include","includeIf","includeWhen","includeFirst","once","endonce","push","endpush","prepend","endprepend","stack","component","endcomponent","slot","endslot","props","auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole","csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file","translate","lang","choice","meta","title","seo","jsonld","canonical","robots","sitemap","ts","endts","js","endjs","css","endcss","markdown","endmarkdown","verbatim","endverbatim","env","production","debug","isset","endisset","empty","endempty"]});var DG={};e(DG,{toUsers:()=>$L,toUser:()=>eO,stopBroadcasting:()=>oO,startBroadcasting:()=>sO,loadChannels:()=>tO,getBroadcastServer:()=>aO,channel:()=>XL,broadcastPrivate:()=>ZL,broadcastPresence:()=>YL,broadcast:()=>IG,BroadcastServer:()=>QL,Broadcast:()=>JL});import{Broadcast as H5,BroadcastServer as mC}from"ts-broadcasting";import{channel as XL}from"ts-broadcasting";import{Broadcast as JL,BroadcastServer as QL}from"ts-broadcasting";function aO(){return S1}async function sO($){if(S1)return S1;let Z=$.driver??"bun",Y=$.host??"0.0.0.0",X=$.port??6001,J=$.scheme??"ws",Q={verbose:$.verbose??!1,driver:Z,default:Z,connections:{[Z]:{driver:Z,host:Y,port:X,scheme:J}}};return S1=new mC(Q),H5.setServer(S1),await S1.start(),S1}async function oO(){for(let $ of EG)clearInterval($);if(EG.length=0,!S1)return;await S1.stop(),S1=null}async function tO($){let Z=await import($),Y=Z.default??Z;if(typeof Y!=="function")throw Error(`routes/channels.ts must export a default function, got ${typeof Y}`);let X=0;return Y({channel(Q,G){if(X++,G.authorize&&S1)S1.channels.channel(Q,G.authorize);if(G.interval&&G.data){let K=G.event??`${Q}.updated`,W=G.data,U=setInterval(async()=>{try{let _=await W();IG(Q,K,_)}catch{}},G.interval);EG.push(U)}}}),X}function q8(){if(S1)return!0;if(!rO)rO=!0,console.warn("[stx] broadcast() called before server started \u2014 messages will be sent once broadcasting is ready");return!1}function IG($,Z,Y){if(!q8())return;H5.send($,Z,Y)}function eO($,Z,Y){if(!q8())return;H5.toUser($,Z,Y)}function $L($,Z,Y){if(!q8())return;H5.toUsers($,Z,Y)}function ZL($,Z,Y){if(!q8())return;H5.send(`private-${$}`,Z,Y)}function YL($,Z,Y){if(!q8())return;H5.presence($,Z,Y)}var S1=null,EG,rO=!1;var aY=D(()=>{EG=[]});function GL($,Z){let Y={},X=$.trim();if(X.startsWith("{"))X=X.slice(1);if(X.endsWith("}"))X=X.slice(0,-1);if(X=X.trim(),!X)return Y;let J=0;while(J<X.length){while(J<X.length&&/\s/.test(X[J]))J++;if(J>=X.length)break;let Q="";if(X[J]==='"'||X[J]==="'"){let W=X[J];J++;while(J<X.length&&X[J]!==W)if(X[J]==="\\"&&J+1<X.length)Q+=X[J+1],J+=2;else Q+=X[J],J++;J++}else while(J<X.length&&/[\w$]/.test(X[J]))Q+=X[J],J++;while(J<X.length&&/\s/.test(X[J]))J++;if(X[J]===":")J++;while(J<X.length&&/\s/.test(X[J]))J++;let G,K=J;if(X[J]==='"'||X[J]==="'"){let W=X[J];J++;let U="";while(J<X.length&&X[J]!==W)if(X[J]==="\\"&&J+1<X.length)U+=X[J+1],J+=2;else U+=X[J],J++;J++,G=U}else if(X[J]==="{"){let W=1;J++;while(J<X.length&&W>0){if(X[J]==="{")W++;else if(X[J]==="}")W--;else if(X[J]==='"'||X[J]==="'"){let _=X[J];J++;while(J<X.length&&X[J]!==_){if(X[J]==="\\")J++;J++}}J++}let U=X.slice(K,J);G=GL(U,Z)}else if(X[J]==="["){let W=1;J++;while(J<X.length&&W>0){if(X[J]==="[")W++;else if(X[J]==="]")W--;else if(X[J]==='"'||X[J]==="'"){let _=X[J];J++;while(J<X.length&&X[J]!==_){if(X[J]==="\\")J++;J++}}J++}let U=X.slice(K,J);try{G=JSON.parse(U.replace(/'/g,'"'))}catch{G=U}}else{let W="";while(J<X.length&&X[J]!==","&&!/\s/.test(X[J]))W+=X[J],J++;if(W=W.trim(),W==="true")G=!0;else if(W==="false")G=!1;else if(W==="null")G=null;else if(W==="undefined")G=void 0;else if(/^-?\d+(\.\d+)?$/.test(W))G=Number(W);else if(W in Z)G=Z[W];else G=W}if(Q)Y[Q]=G;while(J<X.length&&/\s/.test(X[J]))J++;if(X[J]===",")J++}return Y}function cC($,Z,Y){let X=[];for(let[J,Q]of Object.entries(Z)){let G=$[J];if(Q.required&&(G===void 0||G===null)){X.push(`Component "${Y}": Missing required prop "${J}"`);continue}if(G===void 0||G===null)continue;let K=Array.isArray(Q.type)?Q.type:[Q.type];if(!K.includes("any")){let W=pC(G);if(!K.includes(W))X.push(`Component "${Y}": Prop "${J}" expected ${K.join(" | ")}, got ${W}`)}if(Q.validator&&!Q.validator(G))X.push(`Component "${Y}": Prop "${J}" failed custom validation`)}return X}function lC($,Z){let Y={...$};for(let[X,J]of Object.entries(Z))if(Y[X]===void 0&&J.default!==void 0)Y[X]=typeof J.default==="function"?J.default():J.default;return Y}function pC($){if(Array.isArray($))return"array";if($===null)return"null";return typeof $}function iC(){return[KL]}var KL;var WL=D(()=>{R1();p0();N0();KL={name:"component",handler:async($,Z,Y,X)=>{if(Z.length<1)return U0("Component","component directive requires at least the component name",J0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q={};if(Z.length>1)try{let _=Z.slice(1).join(",").trim();if(_.startsWith("{")){if(Q=d0(_,Y),Object.keys(Q).length===0)Q=GL(_,Y)}else{let z=_.trim(),B=Y[z];if(B&&typeof B==="object"&&!Array.isArray(B))Q=B}}catch(_){let z=_ instanceof Error?_.message:String(_);return console.error("Component props parsing error:",z),U0("Component",`Error parsing component props: ${z}`,J0.EVALUATION_ERROR)}let G=Y.__stx_options||{},K=G.componentsDir||"components",W=new Set;if(!Y.__processedComponents)Y.__processedComponents=new Set;let U=Y.__processedComponents;try{return await e1(J,Q,"",K,Y,X,G,U,W)}catch(_){console.error("Component rendering error:",_);let z=_ instanceof Error?_.message:String(_);return U0("Component",`Error rendering component: ${z}`,J0.COMPONENT_RENDER_ERROR)}},hasEndTag:!1}});import kG from"fs";import j8 from"path";async function UL($){try{let Y=(await Bun.file($).text()).match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return[];let X=Y[1],J=[],Q=/\/\*\*\s*([\s\S]*?)\s*\*\/\s*(?:(?:const|let|var)\s*)?(?:([\w$]+)\s*=|module\.exports\.([\w$]+)\s*=|\s*([\w$]+)\s*:)/g,G;while((G=Q.exec(X))!==null){let K=G[1],W=G[2]||G[3]||G[4];if(!W)continue;let U={name:W},_=K.match(/@type\s+\{([^}]+)\}/i);if(_)U.type=_[1].trim();if(K.match(/@required/i))U.required=!0;let B=K.match(/@default\s+(.+?)(?:\s+|$)/i);if(B)U.default=B[1].trim();let q=K.split(`
13078
13078
  `).map((j)=>j.trim().replace(/^\*\s*/,"")).filter((j)=>!j.startsWith("@")&&j.length>0);U.description=q.join(" ").trim(),J.push(U)}if(J.length===0){let K=X.match(/module\.exports\s*=\s*\{([^}]+)\}/i);if(K){let U=K[1].split(",").map((_)=>_.trim()).filter(Boolean);for(let _ of U){let[z]=_.split(":").map((B)=>B.trim());if(z)J.push({name:z})}}}return J}catch(Z){return console.error(`Error extracting props from ${$}:`,Z),[]}}async function _L($){try{let Z=await Bun.file($).text(),Y=Z.match(/^\s*<!--\s*([\s\S]*?)\s*-->/)||Z.match(/^\s*\/\*\*\s*([\s\S]*?)\s*\*\//);if(Y)return Y[1].split(`
13079
13079
  `).map((X)=>X.trim().replace(/^\*\s*/,"")).join(" ").trim();return""}catch{return""}}async function zL($,Z=!1,Y){let X=j8.basename($,".stx"),J=await UL($),Q=await _L($),G="";if(Z&&Y)G=`<${Y}></${Y}>`;else{let K=J.map((W)=>{if(W.type==="boolean")return`:${W.name}="true"`;return`${W.name}="value"`}).join(`
13080
13080
  `);G=`<${X}
@@ -13213,7 +13213,7 @@ export function isDirectiveActive(name: string): boolean {
13213
13213
  <td>@${Q.name}</td>
13214
13214
  <td>${Q.description||"-"}</td>
13215
13215
  <td>${Q.hasEndTag?"Yes":"No"}</td>
13216
- </tr>`;J+="</tbody></table>";for(let Q of Y)if(Q.example)J+=`<h3>@${Q.name}</h3>`,J+=`<p>${Q.description||""}</p>`,J+="<h4>Example</h4>",J+=`<pre><code>${Q.example.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}</code></pre>`}return J+="</body></html>",J}function LL($=[],Z=[],Y=[],X){return JSON.stringify({components:$,templates:Z,directives:Y,extraContent:X||""},null,2)}async function VL($){try{let{componentsDir:Z,templatesDir:Y,webComponentsConfig:X,customDirectives:J,config:Q}=$;if(!Q.enabled)return!1;let G=Q.outputDir||"docs";if(await kG.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),Z)console.log(`Components directory: ${Z}`);if(Y)console.log(`Templates directory: ${Y}`);console.log(`Output directory: ${G}`);let K=[];if(Q.components!==!1&&Z)console.log("Generating component documentation..."),K=await BL(Z,X),console.log(`Found ${K.length} components`);let W=[];if(Q.templates!==!1&&Y)console.log("Generating template documentation..."),W=await qL(Y),console.log(`Found ${W.length} templates`);let U=[];if(Q.directives!==!1)console.log("Generating directive documentation..."),U=await jL(J),console.log(`Found ${U.length} directives`);let _=Q.format||"markdown",z=Q.extraContent,B="",q="";switch(_){case"markdown":B=HL(K,W,U,z),q="md";break;case"html":B=OL(K,W,U,z),q="html";break;case"json":B=LL(K,W,U,z),q="json";break;default:throw Error(`Unsupported documentation format: ${_}`)}let j=j8.join(G,`stx-docs.${q}`);return await Bun.write(j,B),console.log(`Documentation generated: ${j}`),!0}catch(Z){return console.error("Error generating documentation:",Z),!1}}async function CG($){let Z={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Y=$.componentsDir||F1.componentsDir,X=$.templatesDir||".";return VL({componentsDir:Y,templatesDir:X,webComponentsConfig:F1.webComponents,customDirectives:F1.customDirectives,config:Z})}var bG=D(()=>{i0();A0()});import O5 from"process";function L5(){if(typeof globalThis<"u"&&"caches"in globalThis&&"CF"in globalThis)return{platform:"cloudflare",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","r2","d1","durable-objects","queues"]};if(typeof globalThis<"u"&&"Deno"in globalThis)return{platform:"deno",version:globalThis.Deno.version?.deno,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","deploy","ffi"]};if(typeof globalThis<"u"&&"Bun"in globalThis)return{platform:"bun",version:globalThis.Bun.version,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["sqlite","ffi","native-modules"]};if(typeof globalThis<"u"&&"EdgeRuntime"in globalThis)return{platform:"vercel",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["edge-config","blob"]};if(typeof globalThis<"u"&&"Netlify"in globalThis)return{platform:"netlify",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!1,capabilities:["blobs","edge-functions"]};if(typeof globalThis<"u"&&"fastly"in globalThis)return{platform:"fastly",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["dictionary","backend","geolocation"]};if(O5.versions?.node)return{platform:"node",version:O5.versions.node,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["fs","child-process","native-modules"]};return{platform:"unknown",supportsStreaming:!1,supportsCrypto:!1,supportsKV:!1,supportsCache:!1,capabilities:[]}}function nC(){let $=L5();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function rC(){return L5().platform!=="unknown"}function AL($){return{get(Z){if($&&Z in $){let Y=$[Z];return typeof Y==="string"?Y:void 0}if(typeof globalThis<"u"&&"Deno"in globalThis)return globalThis.Deno.env.get(Z);if(O5.env)return O5.env[Z];return},getOrThrow(Z){let Y=this.get(Z);if(Y===void 0)throw Error(`Environment variable "${Z}" is not set`);return Y},has(Z){return this.get(Z)!==void 0},all(){let Z={};if($){for(let[Y,X]of Object.entries($))if(typeof X==="string")Z[Y]=X}if(typeof globalThis<"u"&&"Deno"in globalThis){let Y=globalThis.Deno.env.toObject();Object.assign(Z,Y)}if(O5.env){for(let[Y,X]of Object.entries(O5.env))if(X!==void 0)Z[Y]=X}return Z}}}function NL($){let Z=L5();if(Z.platform==="cloudflare"&&$)return $;if(Z.platform==="deno"&&"Deno"in globalThis)return aC();if(Z.platform==="node"||Z.platform==="bun")return sC();return}function aC(){let $=null,Z=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Y){return(await(await Z()).get(["stx",Y])).value},async getWithMetadata(Y){let X=await Z(),J=await X.get(["stx",Y]),Q=await X.get(["stx-meta",Y]);return{value:J.value,metadata:Q.value}},async put(Y,X,J){let Q=await Z(),G=J?.expirationTtl?J.expirationTtl*1000:void 0;if(await Q.set(["stx",Y],X,G?{expireIn:G}:void 0),J?.metadata)await Q.set(["stx-meta",Y],J.metadata,G?{expireIn:G}:void 0)},async delete(Y){let X=await Z();await X.delete(["stx",Y]),await X.delete(["stx-meta",Y])},async list(Y){let X=await Z(),J=Y?.prefix?["stx",Y.prefix]:["stx"],Q=X.list({prefix:J,limit:Y?.limit||100}),G=[];for await(let K of Q){let U=K.key.slice(1).join("/");if(!U.startsWith("stx-meta/"))G.push({name:U})}return{keys:G,list_complete:!0}}}}function sC(){let $=new Map,Z=()=>{let Y=Date.now();for(let[X,J]of $.entries())if(J.expiration&&J.expiration<Y)$.delete(X)};return{async get(Y){Z();let X=$.get(Y);if(!X)return null;if(X.expiration&&X.expiration<Date.now())return $.delete(Y),null;return X.value},async getWithMetadata(Y){Z();let X=$.get(Y);if(!X)return{value:null,metadata:null};if(X.expiration&&X.expiration<Date.now())return $.delete(Y),{value:null,metadata:null};return{value:X.value,metadata:X.metadata||null}},async put(Y,X,J){let Q=J?.expiration?J.expiration*1000:J?.expirationTtl?Date.now()+J.expirationTtl*1000:void 0;$.set(Y,{value:X,metadata:J?.metadata,expiration:Q})},async delete(Y){$.delete(Y)},async list(Y){Z();let X=[];for(let[J,Q]of $.entries()){if(Y?.prefix&&!J.startsWith(Y.prefix))continue;if(X.push({name:J,expiration:Q.expiration,metadata:Q.metadata}),Y?.limit&&X.length>=Y.limit)break}return{keys:X,list_complete:!0}}}}function wL(){let $=L5();if($.platform==="cloudflare"&&"caches"in globalThis)return oC();if($.supportsStreaming)return tC();return}function oC(){return{async match($){return(await caches.default).match($)},async put($,Z){await(await caches.default).put($,Z.clone())},async delete($){return(await caches.default).delete($)}}}function tC(){let $=new Map,Z=60000;return{async match(Y){let X=Y.url,J=$.get(X);if(!J)return;if(Date.now()>J.expiration){$.delete(X);return}return J.response.clone()},async put(Y,X){let J=Y.url,Q=X.headers.get("Cache-Control"),G=60000;if(Q){let K=Q.match(/max-age=(\d+)/);if(K)G=Number.parseInt(K[1],10)*1000}$.set(J,{response:X.clone(),expiration:Date.now()+G})},async delete(Y){return $.delete(Y.url)}}}function eC(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function $b($,Z){if(Z.platform==="cloudflare"){let Y=$.cf;if(Y)return{city:Y.city,country:Y.country,countryCode:Y.country,region:Y.region,latitude:Y.latitude?Number.parseFloat(Y.latitude):void 0,longitude:Y.longitude?Number.parseFloat(Y.longitude):void 0,timezone:Y.timezone}}if(Z.platform==="vercel"){let Y={},X=$.headers.get("x-vercel-ip-city"),J=$.headers.get("x-vercel-ip-country"),Q=$.headers.get("x-vercel-ip-country-region"),G=$.headers.get("x-vercel-ip-latitude"),K=$.headers.get("x-vercel-ip-longitude");if(X)Y.city=decodeURIComponent(X);if(J)Y.countryCode=J;if(Q)Y.region=Q;if(G)Y.latitude=Number.parseFloat(G);if(K)Y.longitude=Number.parseFloat(K);return Object.keys(Y).length>0?Y:void 0}if(Z.platform==="netlify"){let Y={},X=$.headers.get("x-nf-geo-city"),J=$.headers.get("x-nf-geo-country");if(X)Y.city=X;if(J)Y.countryCode=J;return Object.keys(Y).length>0?Y:void 0}return}function PG($,Z,Y){let X=new Headers($.headers);if(Z.origins==="*")X.set("Access-Control-Allow-Origin","*");else if(Z.origins&&Y&&Z.origins.includes(Y))X.set("Access-Control-Allow-Origin",Y),X.set("Vary","Origin");if(Z.methods)X.set("Access-Control-Allow-Methods",Z.methods.join(", "));if(Z.headers)X.set("Access-Control-Allow-Headers",Z.headers.join(", "));if(Z.exposeHeaders)X.set("Access-Control-Expose-Headers",Z.exposeHeaders.join(", "));if(Z.credentials)X.set("Access-Control-Allow-Credentials","true");if(Z.maxAge)X.set("Access-Control-Max-Age",String(Z.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:X})}function H8($){let Z=L5();return async(Y,X)=>{let J=performance.now(),Q=eC(),G={runtime:Z,platform:X||{},requestId:Q,geo:$b(Y,Z),timing:{start:J,getElapsed:()=>performance.now()-J},kv:NL(X?.KV),cache:wL(),env:AL(X?.env)};try{if(Y.method==="OPTIONS"&&$.cors){let W=new Response(null,{status:204});return W=PG(W,$.cors,Y.headers.get("Origin")||void 0),W}if($.cache?.enabled&&Y.method==="GET"&&G.cache){if(FL(Y,$.cache)){let U=await G.cache.match(Y);if(U){let _=new Response(U.body,U);return _.headers.set("X-Cache","HIT"),_.headers.set("X-Request-Id",Q),$.cors?PG(_,$.cors,Y.headers.get("Origin")||void 0):_}}}let K;if($.middleware&&$.middleware.length>0)K=await Zb(Y,G,$.middleware,async()=>{let W=await $.render(Y,G);return typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W});else{let W=await $.render(Y,G);K=typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W}if(K.headers.set("X-Request-Id",Q),K.headers.set("X-Response-Time",`${G.timing.getElapsed().toFixed(2)}ms`),$.cache?.enabled&&Y.method==="GET"&&G.cache){if(FL(Y,$.cache)&&K.status===200){let U=$.cache.ttl||60,_=K.clone();_.headers.set("Cache-Control",`public, max-age=${U}`),await G.cache.put(Y,_),K.headers.set("X-Cache","MISS")}}if($.cors)K=PG(K,$.cors,Y.headers.get("Origin")||void 0);return K}catch(K){let W=K instanceof Error?K:Error(String(K));if($.onError)return $.onError(W,Y);return new Response(`Internal Server Error: ${W.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":Q}})}}}function FL($,Z){let X=new URL($.url).pathname;if(Z.excludePaths){for(let J of Z.excludePaths)if(J.test(X))return!1}if(Z.includePaths){for(let J of Z.includePaths)if(J.test(X))return!0;return!1}return!0}async function Zb($,Z,Y,X){let J=0,Q=async()=>{if(J>=Y.length)return X();let G=Y[J];return J++,G($,Z,Q)};return Q()}function Yb($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","text/html; charset=utf-8"),Y.set("Transfer-Encoding","chunked"),new Response($,{...Z,headers:Y})}function Xb(){let $=new TextEncoder;return new TransformStream({transform(Z,Y){Y.enqueue($.encode(Z))}})}function Jb($){let Z=new TextEncoder;return new ReadableStream({async start(Y){for await(let X of $)Y.enqueue(Z.encode(X));Y.close()}})}function Qb($){let Z=H8($);return{async fetch(Y,X,J){return Z(Y,{env:X,ctx:J,KV:X.KV})}}}function Gb($){let Z=H8($);return(Y)=>Z(Y,{})}function Kb($){let Z=H8($);return(Y)=>Z(Y,{})}function Wb($){let Z=H8($);return(Y,X)=>{return Z(Y,{netlifyContext:X})}}function Ub($){let Z=$.headers.get("Cookie");if(!Z)return{};let Y={};for(let X of Z.split(";")){let[J,Q]=X.split("=").map((G)=>G.trim());if(J&&Q)Y[J]=decodeURIComponent(Q)}return Y}function _b($,Z,Y){let X=`${encodeURIComponent($)}=${encodeURIComponent(Z)}`;if(Y?.maxAge!==void 0)X+=`; Max-Age=${Y.maxAge}`;if(Y?.expires)X+=`; Expires=${Y.expires.toUTCString()}`;if(Y?.path)X+=`; Path=${Y.path}`;if(Y?.domain)X+=`; Domain=${Y.domain}`;if(Y?.secure)X+="; Secure";if(Y?.httpOnly)X+="; HttpOnly";if(Y?.sameSite)X+=`; SameSite=${Y.sameSite}`;return X}function zb($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...Z,headers:Y})}function Bb($,Z=302){return new Response(null,{status:Z,headers:{Location:$}})}function qb($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var RL=()=>{};var SL={};e(SL,{captureScreenshots:()=>kL,captureScreenshot:()=>xG});var{WebView:jb}=globalThis.Bun;import{existsSync as EL,mkdirSync as IL,readdirSync as Hb,statSync as DL}from"fs";import V5 from"path";function Ob($){if(/^https?:\/\//.test($)||$.startsWith("file://"))return $;return`file://${V5.resolve($)}`}function ML($,Z,Y){return new Promise((X)=>{let J=!1,Q=()=>{if(!J)J=!0,X()};$.onNavigated=()=>setTimeout(Q,Z),setTimeout(Q,Y)})}async function TL($,Z,Y){let X=`!!document.querySelector(${JSON.stringify(Z)})`,J=Date.now()+Y;while(Date.now()<J){try{if(await $.evaluate(X))return}catch{}await new Promise((Q)=>setTimeout(Q,100))}}async function Lb($){try{let Z=await $.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof Z==="number"&&Number.isFinite(Z)&&Z>0?Math.min(Z,yG):0}catch{return 0}}async function xG($,Z,Y={}){let X=Math.min(Y.width??1440,yG),J=Math.min(Y.height??2200,yG),Q=Y.waitMs??800,G=Y.timeoutMs??15000,K=Y.format??"png",W=Ob($),U=(z)=>new jb({url:W,width:X,height:z,headless:!0,...Y.backend?{backend:Y.backend}:{}}),_=U(J);try{if(await ML(_,Q,G),Y.waitSelector)await TL(_,Y.waitSelector,G);if(Y.fullPage){let B=await Lb(_);if(B>J){if(_.close(),_=U(B),await ML(_,Q,G),Y.waitSelector)await TL(_,Y.waitSelector,G)}}let z=await _.screenshot({encoding:"buffer",format:K});IL(V5.dirname(V5.resolve(Z)),{recursive:!0}),await Bun.write(Z,z)}finally{_.close()}if(!EL(Z))throw Error(`Screenshot was not produced for ${$}`);return{input:$,output:Z,bytes:DL(Z).size}}async function kL($,Z,Y={}){IL(Z,{recursive:!0});let X;if(!/^https?:\/\//.test($)&&EL($)&&DL($).isDirectory())X=Hb($).filter((G)=>G.endsWith(".html")).map((G)=>V5.join($,G));else X=[$];let J=Y.format??"png",Q=[];for(let G of X){let K=/^https?:\/\//.test(G)?new URL(G).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":V5.basename(G).replace(/\.html?$/,"");Q.push(await xG(G,V5.join(Z,`${K}.${J}`),Y))}return Q}var yG=16384;var vG=()=>{};function sY($,Z={}){let Y={...bL,...Z};if($.trim()==="")return`
13216
+ </tr>`;J+="</tbody></table>";for(let Q of Y)if(Q.example)J+=`<h3>@${Q.name}</h3>`,J+=`<p>${Q.description||""}</p>`,J+="<h4>Example</h4>",J+=`<pre><code>${Q.example.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}</code></pre>`}return J+="</body></html>",J}function LL($=[],Z=[],Y=[],X){return JSON.stringify({components:$,templates:Z,directives:Y,extraContent:X||""},null,2)}async function VL($){try{let{componentsDir:Z,templatesDir:Y,webComponentsConfig:X,customDirectives:J,config:Q}=$;if(!Q.enabled)return!1;let G=Q.outputDir||"docs";if(await kG.promises.mkdir(G,{recursive:!0}),console.log("Generating documentation..."),Z)console.log(`Components directory: ${Z}`);if(Y)console.log(`Templates directory: ${Y}`);console.log(`Output directory: ${G}`);let K=[];if(Q.components!==!1&&Z)console.log("Generating component documentation..."),K=await BL(Z,X),console.log(`Found ${K.length} components`);let W=[];if(Q.templates!==!1&&Y)console.log("Generating template documentation..."),W=await qL(Y),console.log(`Found ${W.length} templates`);let U=[];if(Q.directives!==!1)console.log("Generating directive documentation..."),U=await jL(J),console.log(`Found ${U.length} directives`);let _=Q.format||"markdown",z=Q.extraContent,B="",q="";switch(_){case"markdown":B=HL(K,W,U,z),q="md";break;case"html":B=OL(K,W,U,z),q="html";break;case"json":B=LL(K,W,U,z),q="json";break;default:throw Error(`Unsupported documentation format: ${_}`)}let j=j8.join(G,`stx-docs.${q}`);return await Bun.write(j,B),console.log(`Documentation generated: ${j}`),!0}catch(Z){return console.error("Error generating documentation:",Z),!1}}async function CG($){let Z={enabled:!0,outputDir:$.output||"docs",format:$.format||"markdown",components:$.components!==!1,templates:$.templates!==!1,directives:$.directives!==!1,extraContent:$.extraContent},Y=$.componentsDir||F1.componentsDir,X=$.templatesDir||".";return VL({componentsDir:Y,templatesDir:X,webComponentsConfig:F1.webComponents,customDirectives:F1.customDirectives,config:Z})}var bG=D(()=>{i0();N0()});import O5 from"process";function L5(){if(typeof globalThis<"u"&&"caches"in globalThis&&"CF"in globalThis)return{platform:"cloudflare",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","r2","d1","durable-objects","queues"]};if(typeof globalThis<"u"&&"Deno"in globalThis)return{platform:"deno",version:globalThis.Deno.version?.deno,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["kv","deploy","ffi"]};if(typeof globalThis<"u"&&"Bun"in globalThis)return{platform:"bun",version:globalThis.Bun.version,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["sqlite","ffi","native-modules"]};if(typeof globalThis<"u"&&"EdgeRuntime"in globalThis)return{platform:"vercel",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["edge-config","blob"]};if(typeof globalThis<"u"&&"Netlify"in globalThis)return{platform:"netlify",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!1,capabilities:["blobs","edge-functions"]};if(typeof globalThis<"u"&&"fastly"in globalThis)return{platform:"fastly",supportsStreaming:!0,supportsCrypto:!0,supportsKV:!0,supportsCache:!0,capabilities:["dictionary","backend","geolocation"]};if(O5.versions?.node)return{platform:"node",version:O5.versions.node,supportsStreaming:!0,supportsCrypto:!0,supportsKV:!1,supportsCache:!1,capabilities:["fs","child-process","native-modules"]};return{platform:"unknown",supportsStreaming:!1,supportsCrypto:!1,supportsKV:!1,supportsCache:!1,capabilities:[]}}function nC(){let $=L5();return["cloudflare","deno","vercel","netlify","fastly"].includes($.platform)}function rC(){return L5().platform!=="unknown"}function AL($){return{get(Z){if($&&Z in $){let Y=$[Z];return typeof Y==="string"?Y:void 0}if(typeof globalThis<"u"&&"Deno"in globalThis)return globalThis.Deno.env.get(Z);if(O5.env)return O5.env[Z];return},getOrThrow(Z){let Y=this.get(Z);if(Y===void 0)throw Error(`Environment variable "${Z}" is not set`);return Y},has(Z){return this.get(Z)!==void 0},all(){let Z={};if($){for(let[Y,X]of Object.entries($))if(typeof X==="string")Z[Y]=X}if(typeof globalThis<"u"&&"Deno"in globalThis){let Y=globalThis.Deno.env.toObject();Object.assign(Z,Y)}if(O5.env){for(let[Y,X]of Object.entries(O5.env))if(X!==void 0)Z[Y]=X}return Z}}}function NL($){let Z=L5();if(Z.platform==="cloudflare"&&$)return $;if(Z.platform==="deno"&&"Deno"in globalThis)return aC();if(Z.platform==="node"||Z.platform==="bun")return sC();return}function aC(){let $=null,Z=async()=>{if(!$)$=await globalThis.Deno.openKv();return $};return{async get(Y){return(await(await Z()).get(["stx",Y])).value},async getWithMetadata(Y){let X=await Z(),J=await X.get(["stx",Y]),Q=await X.get(["stx-meta",Y]);return{value:J.value,metadata:Q.value}},async put(Y,X,J){let Q=await Z(),G=J?.expirationTtl?J.expirationTtl*1000:void 0;if(await Q.set(["stx",Y],X,G?{expireIn:G}:void 0),J?.metadata)await Q.set(["stx-meta",Y],J.metadata,G?{expireIn:G}:void 0)},async delete(Y){let X=await Z();await X.delete(["stx",Y]),await X.delete(["stx-meta",Y])},async list(Y){let X=await Z(),J=Y?.prefix?["stx",Y.prefix]:["stx"],Q=X.list({prefix:J,limit:Y?.limit||100}),G=[];for await(let K of Q){let U=K.key.slice(1).join("/");if(!U.startsWith("stx-meta/"))G.push({name:U})}return{keys:G,list_complete:!0}}}}function sC(){let $=new Map,Z=()=>{let Y=Date.now();for(let[X,J]of $.entries())if(J.expiration&&J.expiration<Y)$.delete(X)};return{async get(Y){Z();let X=$.get(Y);if(!X)return null;if(X.expiration&&X.expiration<Date.now())return $.delete(Y),null;return X.value},async getWithMetadata(Y){Z();let X=$.get(Y);if(!X)return{value:null,metadata:null};if(X.expiration&&X.expiration<Date.now())return $.delete(Y),{value:null,metadata:null};return{value:X.value,metadata:X.metadata||null}},async put(Y,X,J){let Q=J?.expiration?J.expiration*1000:J?.expirationTtl?Date.now()+J.expirationTtl*1000:void 0;$.set(Y,{value:X,metadata:J?.metadata,expiration:Q})},async delete(Y){$.delete(Y)},async list(Y){Z();let X=[];for(let[J,Q]of $.entries()){if(Y?.prefix&&!J.startsWith(Y.prefix))continue;if(X.push({name:J,expiration:Q.expiration,metadata:Q.metadata}),Y?.limit&&X.length>=Y.limit)break}return{keys:X,list_complete:!0}}}}function wL(){let $=L5();if($.platform==="cloudflare"&&"caches"in globalThis)return oC();if($.supportsStreaming)return tC();return}function oC(){return{async match($){return(await caches.default).match($)},async put($,Z){await(await caches.default).put($,Z.clone())},async delete($){return(await caches.default).delete($)}}}function tC(){let $=new Map,Z=60000;return{async match(Y){let X=Y.url,J=$.get(X);if(!J)return;if(Date.now()>J.expiration){$.delete(X);return}return J.response.clone()},async put(Y,X){let J=Y.url,Q=X.headers.get("Cache-Control"),G=60000;if(Q){let K=Q.match(/max-age=(\d+)/);if(K)G=Number.parseInt(K[1],10)*1000}$.set(J,{response:X.clone(),expiration:Date.now()+G})},async delete(Y){return $.delete(Y.url)}}}function eC(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,9)}`}function $b($,Z){if(Z.platform==="cloudflare"){let Y=$.cf;if(Y)return{city:Y.city,country:Y.country,countryCode:Y.country,region:Y.region,latitude:Y.latitude?Number.parseFloat(Y.latitude):void 0,longitude:Y.longitude?Number.parseFloat(Y.longitude):void 0,timezone:Y.timezone}}if(Z.platform==="vercel"){let Y={},X=$.headers.get("x-vercel-ip-city"),J=$.headers.get("x-vercel-ip-country"),Q=$.headers.get("x-vercel-ip-country-region"),G=$.headers.get("x-vercel-ip-latitude"),K=$.headers.get("x-vercel-ip-longitude");if(X)Y.city=decodeURIComponent(X);if(J)Y.countryCode=J;if(Q)Y.region=Q;if(G)Y.latitude=Number.parseFloat(G);if(K)Y.longitude=Number.parseFloat(K);return Object.keys(Y).length>0?Y:void 0}if(Z.platform==="netlify"){let Y={},X=$.headers.get("x-nf-geo-city"),J=$.headers.get("x-nf-geo-country");if(X)Y.city=X;if(J)Y.countryCode=J;return Object.keys(Y).length>0?Y:void 0}return}function PG($,Z,Y){let X=new Headers($.headers);if(Z.origins==="*")X.set("Access-Control-Allow-Origin","*");else if(Z.origins&&Y&&Z.origins.includes(Y))X.set("Access-Control-Allow-Origin",Y),X.set("Vary","Origin");if(Z.methods)X.set("Access-Control-Allow-Methods",Z.methods.join(", "));if(Z.headers)X.set("Access-Control-Allow-Headers",Z.headers.join(", "));if(Z.exposeHeaders)X.set("Access-Control-Expose-Headers",Z.exposeHeaders.join(", "));if(Z.credentials)X.set("Access-Control-Allow-Credentials","true");if(Z.maxAge)X.set("Access-Control-Max-Age",String(Z.maxAge));return new Response($.body,{status:$.status,statusText:$.statusText,headers:X})}function H8($){let Z=L5();return async(Y,X)=>{let J=performance.now(),Q=eC(),G={runtime:Z,platform:X||{},requestId:Q,geo:$b(Y,Z),timing:{start:J,getElapsed:()=>performance.now()-J},kv:NL(X?.KV),cache:wL(),env:AL(X?.env)};try{if(Y.method==="OPTIONS"&&$.cors){let W=new Response(null,{status:204});return W=PG(W,$.cors,Y.headers.get("Origin")||void 0),W}if($.cache?.enabled&&Y.method==="GET"&&G.cache){if(FL(Y,$.cache)){let U=await G.cache.match(Y);if(U){let _=new Response(U.body,U);return _.headers.set("X-Cache","HIT"),_.headers.set("X-Request-Id",Q),$.cors?PG(_,$.cors,Y.headers.get("Origin")||void 0):_}}}let K;if($.middleware&&$.middleware.length>0)K=await Zb(Y,G,$.middleware,async()=>{let W=await $.render(Y,G);return typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W});else{let W=await $.render(Y,G);K=typeof W==="string"?new Response(W,{headers:{"Content-Type":"text/html; charset=utf-8"}}):W}if(K.headers.set("X-Request-Id",Q),K.headers.set("X-Response-Time",`${G.timing.getElapsed().toFixed(2)}ms`),$.cache?.enabled&&Y.method==="GET"&&G.cache){if(FL(Y,$.cache)&&K.status===200){let U=$.cache.ttl||60,_=K.clone();_.headers.set("Cache-Control",`public, max-age=${U}`),await G.cache.put(Y,_),K.headers.set("X-Cache","MISS")}}if($.cors)K=PG(K,$.cors,Y.headers.get("Origin")||void 0);return K}catch(K){let W=K instanceof Error?K:Error(String(K));if($.onError)return $.onError(W,Y);return new Response(`Internal Server Error: ${W.message}`,{status:500,headers:{"Content-Type":"text/plain","X-Request-Id":Q}})}}}function FL($,Z){let X=new URL($.url).pathname;if(Z.excludePaths){for(let J of Z.excludePaths)if(J.test(X))return!1}if(Z.includePaths){for(let J of Z.includePaths)if(J.test(X))return!0;return!1}return!0}async function Zb($,Z,Y,X){let J=0,Q=async()=>{if(J>=Y.length)return X();let G=Y[J];return J++,G($,Z,Q)};return Q()}function Yb($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","text/html; charset=utf-8"),Y.set("Transfer-Encoding","chunked"),new Response($,{...Z,headers:Y})}function Xb(){let $=new TextEncoder;return new TransformStream({transform(Z,Y){Y.enqueue($.encode(Z))}})}function Jb($){let Z=new TextEncoder;return new ReadableStream({async start(Y){for await(let X of $)Y.enqueue(Z.encode(X));Y.close()}})}function Qb($){let Z=H8($);return{async fetch(Y,X,J){return Z(Y,{env:X,ctx:J,KV:X.KV})}}}function Gb($){let Z=H8($);return(Y)=>Z(Y,{})}function Kb($){let Z=H8($);return(Y)=>Z(Y,{})}function Wb($){let Z=H8($);return(Y,X)=>{return Z(Y,{netlifyContext:X})}}function Ub($){let Z=$.headers.get("Cookie");if(!Z)return{};let Y={};for(let X of Z.split(";")){let[J,Q]=X.split("=").map((G)=>G.trim());if(J&&Q)Y[J]=decodeURIComponent(Q)}return Y}function _b($,Z,Y){let X=`${encodeURIComponent($)}=${encodeURIComponent(Z)}`;if(Y?.maxAge!==void 0)X+=`; Max-Age=${Y.maxAge}`;if(Y?.expires)X+=`; Expires=${Y.expires.toUTCString()}`;if(Y?.path)X+=`; Path=${Y.path}`;if(Y?.domain)X+=`; Domain=${Y.domain}`;if(Y?.secure)X+="; Secure";if(Y?.httpOnly)X+="; HttpOnly";if(Y?.sameSite)X+=`; SameSite=${Y.sameSite}`;return X}function zb($,Z){let Y=new Headers(Z?.headers);return Y.set("Content-Type","application/json; charset=utf-8"),new Response(JSON.stringify($),{...Z,headers:Y})}function Bb($,Z=302){return new Response(null,{status:Z,headers:{Location:$}})}function qb($="Not Found"){return new Response($,{status:404,headers:{"Content-Type":"text/plain"}})}var RL=()=>{};var SL={};e(SL,{captureScreenshots:()=>kL,captureScreenshot:()=>xG});var{WebView:jb}=globalThis.Bun;import{existsSync as EL,mkdirSync as IL,readdirSync as Hb,statSync as DL}from"fs";import V5 from"path";function Ob($){if(/^https?:\/\//.test($)||$.startsWith("file://"))return $;return`file://${V5.resolve($)}`}function ML($,Z,Y){return new Promise((X)=>{let J=!1,Q=()=>{if(!J)J=!0,X()};$.onNavigated=()=>setTimeout(Q,Z),setTimeout(Q,Y)})}async function TL($,Z,Y){let X=`!!document.querySelector(${JSON.stringify(Z)})`,J=Date.now()+Y;while(Date.now()<J){try{if(await $.evaluate(X))return}catch{}await new Promise((Q)=>setTimeout(Q,100))}}async function Lb($){try{let Z=await $.evaluate("Math.ceil(Math.max(document.documentElement.scrollHeight, document.documentElement.offsetHeight, document.body ? document.body.scrollHeight : 0, document.body ? document.body.offsetHeight : 0))");return typeof Z==="number"&&Number.isFinite(Z)&&Z>0?Math.min(Z,yG):0}catch{return 0}}async function xG($,Z,Y={}){let X=Math.min(Y.width??1440,yG),J=Math.min(Y.height??2200,yG),Q=Y.waitMs??800,G=Y.timeoutMs??15000,K=Y.format??"png",W=Ob($),U=(z)=>new jb({url:W,width:X,height:z,headless:!0,...Y.backend?{backend:Y.backend}:{}}),_=U(J);try{if(await ML(_,Q,G),Y.waitSelector)await TL(_,Y.waitSelector,G);if(Y.fullPage){let B=await Lb(_);if(B>J){if(_.close(),_=U(B),await ML(_,Q,G),Y.waitSelector)await TL(_,Y.waitSelector,G)}}let z=await _.screenshot({encoding:"buffer",format:K});IL(V5.dirname(V5.resolve(Z)),{recursive:!0}),await Bun.write(Z,z)}finally{_.close()}if(!EL(Z))throw Error(`Screenshot was not produced for ${$}`);return{input:$,output:Z,bytes:DL(Z).size}}async function kL($,Z,Y={}){IL(Z,{recursive:!0});let X;if(!/^https?:\/\//.test($)&&EL($)&&DL($).isDirectory())X=Hb($).filter((G)=>G.endsWith(".html")).map((G)=>V5.join($,G));else X=[$];let J=Y.format??"png",Q=[];for(let G of X){let K=/^https?:\/\//.test(G)?new URL(G).pathname.replace(/\W+/g,"-").replace(/^-|-$/g,"")||"index":V5.basename(G).replace(/\.html?$/,"");Q.push(await xG(G,V5.join(Z,`${K}.${J}`),Y))}return Q}var yG=16384;var vG=()=>{};function sY($,Z={}){let Y={...bL,...Z};if($.trim()==="")return`
13217
13217
  `;let X=$;if(Y.trimTrailingWhitespace)X=X.replace(/[ \t]+$/gm,"");if(X=Fb(X,Y),X=Rb(X,Y),X=Ab(X,Y),Y.trimTrailingWhitespace)X=X.replace(/[ \t]+$/gm,""),X=X.replace(/(\S)[ \t]+(<\/[^>]+>)/g,"$1$2");if(X=X.replace(/\r\n/g,`
13218
13218
  `).replace(/\r/g,`
13219
13219
  `),!X.endsWith(`
@@ -13743,7 +13743,7 @@ ${_}`)}else this.warnings.push(`External stylesheet not found: ${U}`)}return""})
13743
13743
  </table>
13744
13744
  </body>
13745
13745
  </html>`}generateAnalysisText($){let Z=["Bundle Analysis","=".repeat(50),""];for(let Y of $.outputs)Z.push(`${Y.path}`),Z.push(` Size: ${Y.sizeFormatted}${Y.gzipSizeFormatted?` (gzip: ${Y.gzipSizeFormatted})`:""}`),Z.push("");return Z.push("=".repeat(50)),Z.push(`Total: ${this.formatSize($.totalSize)} (gzip: ${this.formatSize($.totalGzipSize)})`),Z.join(`
13746
- `)}async runPluginHook($,Z){if(!this.config.plugins)return;for(let Y of this.config.plugins){let X=Y[$];if(typeof X==="function")await X.call(Y,Z||this)}}async runPluginTransform($,Z){if(!this.config.plugins)return $;let Y=$;for(let X of this.config.plugins)if(X.transform){let J=await X.transform(Y,Z);if(J!=null)Y=J}return Y}generateHash($){return Cb("sha256").update($).digest("hex")}getOutputName($,Z,Y){let X=Z==="html"?".html":Z==="css"?".css":Z==="js"?".js":"";return`${$}.${Y.slice(0,8)}${X}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!L8($))bb($,{recursive:!0})}walkDir($,Z){if(!L8($))return;let Y=yb($,{withFileTypes:!0});for(let X of Y){let J=G4($,X.name);if(X.isDirectory())this.walkDir(J,Z);else Z(J)}}getResult(){let $=Date.now()-this.startTime,Z=this.outputs.reduce((X,J)=>X+J.size,0),Y=this.outputs.reduce((X,J)=>X+(J.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:Z,gzipSize:Y,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function fb($){return new oY($).build()}function gb($){return new oY($)}function hb($){return{...dL,...$}}var dL;var uL=D(()=>{dL={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}}});async function db($,Z={}){return(await mL($,Z)).html}async function lG($,Z={}){let{html:Y,context:X}=await mL($,Z),{extractStreamBoundaries:J}=await Promise.resolve().then(() => (p4(),D6)),Q=J(X),G=$.streamTemplates;if(G&&Object.keys(G).length>0){let{processDirectives:K}=await Promise.resolve().then(() => (U1(),sZ)),{defaultConfig:W}=await Promise.resolve().then(() => (i0(),P3)),U=X.streamBoundaries||{},_={...W,autoShell:!1},z=Object.keys(G).map((q)=>({id:q,render:async()=>{let j=typeof U[q]==="function"?await U[q]():void 0;return K(G[q],{...X,$boundary:j},$.sourceFile,_,new Set)}})),B=new Set(z.map((q)=>q.id));Q=[...(Q||[]).filter((q)=>!B.has(q.id)),...z]}return{html:Y,boundaries:Q&&Q.length>0?Q:void 0}}async function mL($,Z){let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};if(!$.hasServerScripts&&!X$($.html))return{html:$.html,context:Y};for(let J of $.serverScriptContent)try{await E0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!X$($.html))return{html:$.html,context:Y};let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=X1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?P0(String(G)):"")}catch{X.set(J,"")}return{html:M3($.html,X),context:Y}}async function ub($,Z={}){if(!$.hasServerScripts&&!X$($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await E0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!X$($.fragment))return $.fragment;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=X1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?P0(String(G)):"")}catch{X.set(J,"")}return M3($.fragment,X)}var pG=D(()=>{a4();o0();u5()});var pL={};e(pL,{startProductionServer:()=>lL});import cL from"fs";import q6 from"path";var{serve:mb}=globalThis.Bun;async function lL($={}){let Z=q6.resolve($.outputDir||".output"),Y=$.port||3000,X=wG(Z);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let J=new Map,Q=new Map,G=new Map;for(let _ of X.routes)try{let z=q6.join(Z,_.compiledPath),B=JSON.parse(await Bun.file(z).text());J.set(_.pattern,B),G.set(_.pattern,z8(B.html));let q=q6.join(Z,_.fragmentPath);if(await Bun.file(q).exists())Q.set(_.pattern,await Bun.file(q).text())}catch(z){console.warn(`[stx] Failed to load route ${_.pattern}:`,z)}let K=new Map,W=[];for(let _ of X.routes)if(_.hasParams){let z=[],B=_.pattern.replace(/:([^/]+)/g,(q,j)=>{return z.push(j),"([^/]+)"});W.push({regex:new RegExp(`^${B}$`),route:_,paramNames:z})}else K.set(_.pattern,_);let U=mb({port:Y,async fetch(_){let B=new URL(_.url).pathname;if($.onRequest){let V=await $.onRequest(_);if(V)return V}if($.apiRoutes?.[B])return $.apiRoutes[B](_);if((_.method==="GET"||_.method==="HEAD")&&B!=="/"){let V=q6.resolve(Z,"public"),L;try{L=decodeURIComponent(B)}catch{L=B}if(!L.includes("\x00")){let F=q6.resolve(V,`.${L}`);if(F===V||F.startsWith(`${V}${q6.sep}`))try{if(cL.existsSync(F)&&cL.statSync(F).isFile()){let N=q6.extname(F).toLowerCase(),w=cb[N]||"application/octet-stream",R=B.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(B);return new Response(Bun.file(F),{headers:{"Content-Type":w,"Cache-Control":R?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let q=_.headers.get("X-STX-Router")==="true",j=null,H={};if(j=K.get(B)||null,!j)for(let{regex:V,route:L,paramNames:F}of W){let A=B.match(V);if(A){j=L,F.forEach((N,w)=>{H[N]=A[w+1]});break}}if(!j){let V=K.get("/404")||null;if(V){let L=J.get(V.pattern);if(L)return new Response(L.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(q){let V=Q.get(j.pattern);if(V){let L=G.get(j.pattern);return new Response(V,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...L?{"X-STX-Layout":L.layout,"X-STX-Layout-Group":L.group}:{},"Cache-Control":"no-cache"}})}}let O=J.get(j.pattern);if(!O){let V=K.get("/500")||null;if(V){let L=J.get(V.pattern);if(L)return new Response(L.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!O.hasServerScripts&&Object.keys(O.placeholders).length===0)return new Response(O.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:V,boundaries:L}=await lG(O,{params:H,request:_});if(L&&L.length>0){let{renderStreamingPage:F,streamToResponse:A}=await Promise.resolve().then(() => (p4(),D6));return A(F(V,L,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(V){return console.error(`[stx] Hydration error for ${B}:`,V),new Response(O.html,{headers:{"Content-Type":"text/html"}})}}});return console.log(`[stx] Production server running at http://localhost:${Y}`),console.log(`[stx] Serving ${X.routes.length} routes (${J.size} pre-loaded)`),{port:Y,stop:()=>U.stop()}}var cb;var iG=D(()=>{iY();pG();j5();cb={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"}});var nG="f9c3713";import{existsSync as A8,mkdirSync as rG}from"fs";import{join as j6,dirname as lb}from"path";import{execSync as iL}from"child_process";async function ib($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.template||"default",J=j6(process.cwd(),$);if(A8(J))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{rG(J,{recursive:!0});let Q=nb(X);for(let K of Q)rG(j6(J,K),{recursive:!0});let G=rb(X,$,Z);for(let[K,W]of Object.entries(G)){let U=j6(J,K);N8(lb(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{iL("git init",{cwd:J,stdio:"ignore"}),await Bun.write(j6(J,".gitignore"),KP()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||DP();try{console.log(`
13746
+ `)}async runPluginHook($,Z){if(!this.config.plugins)return;for(let Y of this.config.plugins){let X=Y[$];if(typeof X==="function")await X.call(Y,Z||this)}}async runPluginTransform($,Z){if(!this.config.plugins)return $;let Y=$;for(let X of this.config.plugins)if(X.transform){let J=await X.transform(Y,Z);if(J!=null)Y=J}return Y}generateHash($){return Cb("sha256").update($).digest("hex")}getOutputName($,Z,Y){let X=Z==="html"?".html":Z==="css"?".css":Z==="js"?".js":"";return`${$}.${Y.slice(0,8)}${X}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!L8($))bb($,{recursive:!0})}walkDir($,Z){if(!L8($))return;let Y=yb($,{withFileTypes:!0});for(let X of Y){let J=G4($,X.name);if(X.isDirectory())this.walkDir(J,Z);else Z(J)}}getResult(){let $=Date.now()-this.startTime,Z=this.outputs.reduce((X,J)=>X+J.size,0),Y=this.outputs.reduce((X,J)=>X+(J.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:Z,gzipSize:Y,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function fb($){return new oY($).build()}function gb($){return new oY($)}function hb($){return{...dL,...$}}var dL;var uL=D(()=>{dL={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}}});async function db($,Z={}){return(await mL($,Z)).html}async function lG($,Z={}){let{html:Y,context:X}=await mL($,Z),{extractStreamBoundaries:J}=await Promise.resolve().then(() => (p4(),D6)),Q=J(X),G=$.streamTemplates;if(G&&Object.keys(G).length>0){let{processDirectives:K}=await Promise.resolve().then(() => (U1(),sZ)),{defaultConfig:W}=await Promise.resolve().then(() => (i0(),P3)),U=X.streamBoundaries||{},_={...W,autoShell:!1},z=Object.keys(G).map((q)=>({id:q,render:async()=>{let j=typeof U[q]==="function"?await U[q]():void 0;return K(G[q],{...X,$boundary:j},$.sourceFile,_,new Set)}})),B=new Set(z.map((q)=>q.id));Q=[...(Q||[]).filter((q)=>!B.has(q.id)),...z]}return{html:Y,boundaries:Q&&Q.length>0?Q:void 0}}async function mL($,Z){let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};if(!$.hasServerScripts&&!X$($.html))return{html:$.html,context:Y};for(let J of $.serverScriptContent)try{await I0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!X$($.html))return{html:$.html,context:Y};let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=X1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?P0(String(G)):"")}catch{X.set(J,"")}return{html:M3($.html,X),context:Y}}async function ub($,Z={}){if(!$.hasServerScripts&&!X$($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await I0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!X$($.fragment))return $.fragment;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=X1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?P0(String(G)):"")}catch{X.set(J,"")}return M3($.fragment,X)}var pG=D(()=>{a4();o0();u5()});var pL={};e(pL,{startProductionServer:()=>lL});import cL from"fs";import q6 from"path";var{serve:mb}=globalThis.Bun;async function lL($={}){let Z=q6.resolve($.outputDir||".output"),Y=$.port||3000,X=wG(Z);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let J=new Map,Q=new Map,G=new Map;for(let _ of X.routes)try{let z=q6.join(Z,_.compiledPath),B=JSON.parse(await Bun.file(z).text());J.set(_.pattern,B),G.set(_.pattern,z8(B.html));let q=q6.join(Z,_.fragmentPath);if(await Bun.file(q).exists())Q.set(_.pattern,await Bun.file(q).text())}catch(z){console.warn(`[stx] Failed to load route ${_.pattern}:`,z)}let K=new Map,W=[];for(let _ of X.routes)if(_.hasParams){let z=[],B=_.pattern.replace(/:([^/]+)/g,(q,j)=>{return z.push(j),"([^/]+)"});W.push({regex:new RegExp(`^${B}$`),route:_,paramNames:z})}else K.set(_.pattern,_);let U=mb({port:Y,async fetch(_){let B=new URL(_.url).pathname;if($.onRequest){let V=await $.onRequest(_);if(V)return V}if($.apiRoutes?.[B])return $.apiRoutes[B](_);if((_.method==="GET"||_.method==="HEAD")&&B!=="/"){let V=q6.resolve(Z,"public"),L;try{L=decodeURIComponent(B)}catch{L=B}if(!L.includes("\x00")){let F=q6.resolve(V,`.${L}`);if(F===V||F.startsWith(`${V}${q6.sep}`))try{if(cL.existsSync(F)&&cL.statSync(F).isFile()){let N=q6.extname(F).toLowerCase(),w=cb[N]||"application/octet-stream",R=B.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(B);return new Response(Bun.file(F),{headers:{"Content-Type":w,"Cache-Control":R?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let q=_.headers.get("X-STX-Router")==="true",j=null,H={};if(j=K.get(B)||null,!j)for(let{regex:V,route:L,paramNames:F}of W){let A=B.match(V);if(A){j=L,F.forEach((N,w)=>{H[N]=A[w+1]});break}}if(!j){let V=K.get("/404")||null;if(V){let L=J.get(V.pattern);if(L)return new Response(L.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(q){let V=Q.get(j.pattern);if(V){let L=G.get(j.pattern);return new Response(V,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...L?{"X-STX-Layout":L.layout,"X-STX-Layout-Group":L.group}:{},"Cache-Control":"no-cache"}})}}let O=J.get(j.pattern);if(!O){let V=K.get("/500")||null;if(V){let L=J.get(V.pattern);if(L)return new Response(L.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!O.hasServerScripts&&Object.keys(O.placeholders).length===0)return new Response(O.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:V,boundaries:L}=await lG(O,{params:H,request:_});if(L&&L.length>0){let{renderStreamingPage:F,streamToResponse:A}=await Promise.resolve().then(() => (p4(),D6));return A(F(V,L,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(V){return console.error(`[stx] Hydration error for ${B}:`,V),new Response(O.html,{headers:{"Content-Type":"text/html"}})}}});return console.log(`[stx] Production server running at http://localhost:${Y}`),console.log(`[stx] Serving ${X.routes.length} routes (${J.size} pre-loaded)`),{port:Y,stop:()=>U.stop()}}var cb;var iG=D(()=>{iY();pG();j5();cb={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"}});var nG="f9c3713";import{existsSync as A8,mkdirSync as rG}from"fs";import{join as j6,dirname as lb}from"path";import{execSync as iL}from"child_process";async function ib($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.template||"default",J=j6(process.cwd(),$);if(A8(J))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{rG(J,{recursive:!0});let Q=nb(X);for(let K of Q)rG(j6(J,K),{recursive:!0});let G=rb(X,$,Z);for(let[K,W]of Object.entries(G)){let U=j6(J,K);N8(lb(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{iL("git init",{cwd:J,stdio:"ignore"}),await Bun.write(j6(J,".gitignore"),KP()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||DP();try{console.log(`
13747
13747
  Installing dependencies with ${K}...`),iL(`${K} install`,{cwd:J,stdio:"inherit"})}catch{Y.errors.push("Failed to install dependencies")}}Y.message=`Created project: ${$}`,console.log(`
13748
13748
  \u2705 ${Y.message}
13749
13749
 
@@ -14217,14 +14217,14 @@ describe('Example', () => {
14217
14217
  </footer>
14218
14218
  @yield('scripts')
14219
14219
  </body>
14220
- </html>`}function MP(){return"<!-- Hero section -->"}function TP(){return"<!-- Features -->"}function EP(){return"<!-- Pricing -->"}function IP(){return"<!-- Button -->"}function N8($){if(!A8($))rG($,{recursive:!0})}function DP(){if(A8("bun.lockb"))return"bun";if(A8("pnpm-lock.yaml"))return"pnpm";if(A8("yarn.lock"))return"yarn";return"bun"}function aG($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function kP($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function i6($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var pb;var tL=D(()=>{pb={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:SP}=globalThis.Bun;import w8 from"fs";import H6 from"path";function CP($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function eL($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=H6.resolve(Y),z=new Map;async function B(L){let F=w8.statSync(L),A=`${L}:${F.mtimeMs}`,N=z.get(A);if(N)return N.content;for(let b of z.keys())if(b.startsWith(`${L}:`)&&b!==A)z.delete(b);let w=await Bun.file(L).text(),R=w,T=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(T&&T.index!==void 0){let b=T.index+T[0].length,d=1,l=b;while(l<w.length&&d>0){let r=w.indexOf("<template",l),a=w.indexOf("</template>",l);if(a===-1)break;if(r!==-1&&r<a)d++,l=r+9;else{if(d--,d===0){R=w.substring(b,a).trim();break}l=a+11}}}let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],k=[],S;while((S=E.exec(w))!==null){let b=S[1],d=S[2],l=S[0];if(b.includes("server"))k.push(d);else I.push(l)}let x=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],P=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),C={__filename:L,__dirname:H6.dirname(L)};for(let b of k)await E0(b,C,L);let m=await W0(P,C,L,X,new Set);if(x.length>0){let b=x.join(`
14220
+ </html>`}function MP(){return"<!-- Hero section -->"}function TP(){return"<!-- Features -->"}function EP(){return"<!-- Pricing -->"}function IP(){return"<!-- Button -->"}function N8($){if(!A8($))rG($,{recursive:!0})}function DP(){if(A8("bun.lockb"))return"bun";if(A8("pnpm-lock.yaml"))return"pnpm";if(A8("yarn.lock"))return"yarn";return"bun"}function aG($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function kP($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function i6($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var pb;var tL=D(()=>{pb={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:SP}=globalThis.Bun;import w8 from"fs";import H6 from"path";function CP($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function eL($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=H6.resolve(Y),z=new Map;async function B(L){let F=w8.statSync(L),A=`${L}:${F.mtimeMs}`,N=z.get(A);if(N)return N.content;for(let b of z.keys())if(b.startsWith(`${L}:`)&&b!==A)z.delete(b);let w=await Bun.file(L).text(),R=w,T=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(T&&T.index!==void 0){let b=T.index+T[0].length,d=1,l=b;while(l<w.length&&d>0){let r=w.indexOf("<template",l),a=w.indexOf("</template>",l);if(a===-1)break;if(r!==-1&&r<a)d++,l=r+9;else{if(d--,d===0){R=w.substring(b,a).trim();break}l=a+11}}}let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],k=[],S;while((S=E.exec(w))!==null){let b=S[1],d=S[2],l=S[0];if(b.includes("server"))k.push(d);else I.push(l)}let x=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],P=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),C={__filename:L,__dirname:H6.dirname(L)};for(let b of k)await I0(b,C,L);let m=await W0(P,C,L,X,new Set);if(x.length>0){let b=x.join(`
14221
14221
  `);if(m.match(/(<\/head>)/i))m=m.replace(/(<\/head>)/i,`${b}
14222
14222
  $1`)}if(I.length>0){let{interpolateScriptsInTemplate:b}=await Promise.resolve().then(() => (o0(),l5)),d=b(I.join(`
14223
14223
  `),C);if(m.match(/(<\/body>)/i))m=m.replace(/(<\/body>)/i,`${d}
14224
14224
  $1`);else m+=`
14225
14225
  ${d}`}return z.set(A,{content:m,mtime:F.mtimeMs}),m}async function q(L){let F=w8.statSync(L),A=`${L}:${F.mtimeMs}`,N=z.get(A);if(N)return N.content;let{content:w}=await O4(L,X);return z.set(A,{content:w,mtime:F.mtimeMs}),w}function j(L){let F=L.startsWith("/")?L.slice(1):L,A=[F,`${F}.stx`,`${F}.md`,`${F}.html`,H6.join(F,"index.stx"),H6.join(F,"index.md"),H6.join(F,"index.html")];for(let N of A){let w=H6.join(_,N);if(w8.existsSync(w)&&w8.statSync(w).isFile())return w}return null}async function H(L){let F=new URL(L.url),A=async()=>{if(G[F.pathname])return await G[F.pathname](L);if(Q){let w=await Q(L);if(w)return w}let N=j(F.pathname);if(!N){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let w,R="text/html";if(N.endsWith(".stx"))w=await B(N);else if(N.endsWith(".md"))w=await q(N);else if(N.endsWith(".html"))w=await Bun.file(N).text();else if(N.endsWith(".css"))w=await Bun.file(N).text(),R="text/css";else if(N.endsWith(".js"))w=await Bun.file(N).text(),R="text/javascript";else if(N.endsWith(".json"))w=await Bun.file(N).text(),R="application/json";else return new Response(Bun.file(N));return new Response(w,{headers:{"Content-Type":R}})}catch(w){if(U)return await U(w,L);let R=w instanceof Error?w.message:String(w),E=X?.debug===!0?`<h1>Error</h1><pre>${R}
14226
14226
  ${w instanceof Error?w.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(E,{status:500,headers:{"Content-Type":"text/html"}})}};for(let N=K.length-1;N>=0;N--){let w=K[N],R=A;A=async()=>await w(L,R)}return await A()}let O=SP({port:Z,fetch:H}),V=null;if(J)V=w8.watch(_,{recursive:!0},(L,F)=>{if(F&&(F.endsWith(".stx")||F.endsWith(".md")||F.endsWith(".html")))z.clear()});return{server:O,url:O.url.toString(),stop(){if(V)V.close();O.stop()}}}async function bP($,Z={}){let Y=H6.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let X=Y.endsWith(".md"),J=Y.endsWith(".stx");if(!X&&!J)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await eL({...Z,root:H6.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await O4(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let _=K.join(`
14227
- `),z=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),B={};if(_.trim())await E0(_,B,Y);let q=new Set;Q=await W0(z,B,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function PP($){return $}function yP($){return $}var $V=D(()=>{b$();U1();A0()});import{existsSync as xP,readFileSync as vP}from"fs";class sG{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...fP,...$},this.options.includeBuiltins)Object.entries(ZV).forEach(([Z,Y])=>{this.variables.set(Z,Y)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([Z,Y])=>{this.variables.set(Z,Y)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!xP($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let Z=vP($,"utf-8");return this.checkTemplate(Z,$)}checkTemplate($,Z="<inline>"){this.currentFile=Z,this.errors=[],this.warnings=[];let Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)this.analyzeScript(Y[1],$.indexOf(Y[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,Z){let Y=$.split(`
14227
+ `),z=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),B={};if(_.trim())await I0(_,B,Y);let q=new Set;Q=await W0(z,B,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function PP($){return $}function yP($){return $}var $V=D(()=>{b$();U1();N0()});import{existsSync as xP,readFileSync as vP}from"fs";class sG{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...fP,...$},this.options.includeBuiltins)Object.entries(ZV).forEach(([Z,Y])=>{this.variables.set(Z,Y)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([Z,Y])=>{this.variables.set(Z,Y)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!xP($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let Z=vP($,"utf-8");return this.checkTemplate(Z,$)}checkTemplate($,Z="<inline>"){this.currentFile=Z,this.errors=[],this.warnings=[];let Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)this.analyzeScript(Y[1],$.indexOf(Y[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,Z){let Y=$.split(`
14228
14228
  `),X=this.getLineNumber(Z);for(let J=0;J<Y.length;J++){let Q=Y[J],G=X+J;this.extractTypedVariables(Q,G),this.extractInterfaces(Q,Y,J,G),this.extractTypeAliases(Q,G)}}extractTypedVariables($,Z){let Y=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*:\s*([^=]+?)\s*=/);if(Y){let[,Q,G]=Y,K=this.parseTypeAnnotation(G.trim());this.variables.set(Q,K);return}let X=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(.+)/);if(X){let[,Q,G]=X,K=this.inferType(G.trim());this.variables.set(Q,K);return}let J=$.match(/(?:export\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*(\w+))?/);if(J){let[,Q,G,K]=J,W=this.parseParams(G),U=K?this.parseTypeAnnotation(K):{kind:"primitive",value:"any"};this.variables.set(Q,{kind:"function",params:W,returnType:U})}}extractInterfaces($,Z,Y,X){let J=$.match(/(?:export\s+)?interface\s+(\w+)\s*\{/);if(J){let[,Q]=J,G={},K=1,W=Y+1;while(W<Z.length&&K>0){let U=Z[W].trim();if(U.includes("{"))K++;if(U.includes("}"))K--;let _=U.match(/(\w+)\??\s*:\s*([^;]+)/);if(_&&K>0){let[,z,B]=_;G[z]=this.parseTypeAnnotation(B.trim())}W++}this.variables.set(Q,{kind:"object",name:Q,properties:G})}}extractTypeAliases($,Z){let Y=$.match(/(?:export\s+)?type\s+(\w+)\s*=\s*(.+)/);if(Y){let[,X,J]=Y,Q=this.parseTypeAnnotation(J.trim());Q.name=X,this.variables.set(X,Q)}}parseTypeAnnotation($){let Z=$.trim();if(Z.includes("|"))return{kind:"union",types:Z.split("|").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.includes("&"))return{kind:"intersection",types:Z.split("&").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.endsWith("[]"))return{kind:"array",elementType:this.parseTypeAnnotation(Z.slice(0,-2))};let Y=Z.match(/^Array<(.+)>$/);if(Y)return{kind:"array",elementType:this.parseTypeAnnotation(Y[1])};if(Z.startsWith("{")&&Z.endsWith("}")){let J={},Q=Z.slice(1,-1).trim();if(Q){let G=this.splitByComma(Q);for(let K of G){let W=K.match(/(\w+)\??\s*:\s*(.+)/);if(W){let[,U,_]=W;J[U]=this.parseTypeAnnotation(_.trim())}}}return{kind:"object",properties:J}}if(Z.startsWith('"')||Z.startsWith("'"))return{kind:"literal",value:Z.slice(1,-1)};if(/^\d+$/.test(Z))return{kind:"literal",value:Z};if(Z==="true"||Z==="false")return{kind:"literal",value:Z};if(["string","number","boolean","null","undefined","any","unknown","void","never"].includes(Z))return{kind:"primitive",value:Z};if(this.variables.has(Z))return this.variables.get(Z);return{kind:"primitive",value:"any"}}inferType($){let Z=$.trim().replace(/;$/,"");if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return{kind:"primitive",value:"string"};if(/^-?\d+(\.\d+)?$/.test(Z))return{kind:"primitive",value:"number"};if(Z==="true"||Z==="false")return{kind:"primitive",value:"boolean"};if(Z==="null")return{kind:"primitive",value:"null"};if(Z==="undefined")return{kind:"primitive",value:"undefined"};if(Z.startsWith("[")){let Y=Z.slice(1,-1).trim();if(Y){let X=this.splitByComma(Y)[0];if(X)return{kind:"array",elementType:this.inferType(X.trim())}}return{kind:"array",elementType:{kind:"primitive",value:"any"}}}if(Z.startsWith("{")){let Y={},X=this.extractObjectLiteral(Z);for(let[J,Q]of Object.entries(X))Y[J]=this.inferType(Q);return{kind:"object",properties:Y}}if(Z.includes("=>")){let Y=Z.match(/^\(([^)]*)\)\s*(?::\s*(\w+))?\s*=>/);if(Y){let X=this.parseParams(Y[1]),J=Y[2]?this.parseTypeAnnotation(Y[2]):{kind:"primitive",value:"any"};return{kind:"function",params:X,returnType:J}}}if(/^\w+$/.test(Z)&&this.variables.has(Z))return this.variables.get(Z);if(Z.includes("."))return this.resolvePropertyAccess(Z);if(Z.includes("(")){let Y=Z.split("(")[0],X=this.variables.get(Y);if(X?.kind==="function"&&X.returnType)return X.returnType}return{kind:"primitive",value:"any"}}parseParams($){if(!$.trim())return[];let Z=[],Y=this.splitByComma($);for(let X of Y){let J=X.trim(),Q=J.includes("?"),G=J.match(/(\w+)\??\s*(?::\s*([^=]+))?(?:\s*=)?/);if(G){let[,K,W]=G,U=W?this.parseTypeAnnotation(W.trim()):{kind:"primitive",value:"any"};Z.push({name:K,type:U,optional:Q})}}return Z}checkExpressions($){let Z=/\{\{([\s\S]*?)\}\}/g,Y;while((Y=Z.exec($))!==null){let J=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!J)continue;if(J.startsWith("!")||J.endsWith("!"))continue;this.checkExpression(J,G,K)}let X=/\{!!([\s\S]*?)!!\}/g;while((Y=X.exec($))!==null){let J=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!J)continue;this.checkExpression(J,G,K)}}checkExpression($,Z,Y){if($.includes("?")&&$.includes(":")){let Q=$.split("?");this.checkExpression(Q[0].trim(),Z,Y);let G=Q.slice(1).join("?").split(":");if(G.length>=2)this.checkExpression(G[0].trim(),Z,Y),this.checkExpression(G.slice(1).join(":").trim(),Z,Y);return}for(let Q of["&&","||","??"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}for(let Q of["===","!==","==","!=",">=","<=",">","<"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}if($.startsWith("!")){this.checkExpression($.slice(1).trim(),Z,Y);return}if(this.isLiteral($))return;let X=$.match(/^(\w+(?:\.\w+)*)\s*\(/);if(X){let Q=X[1],G=this.resolvePropertyAccess(Q);if(G.kind!=="function"&&G.value!=="any")this.addWarning(`'${Q}' is not a function`,Z,Y,$);return}if($.includes(".")){if(this.resolvePropertyAccess($).value==="undefined"&&this.options.checkPropertyAccess)this.addWarning(`Property access '${$}' may be undefined`,Z,Y,$);return}let J=$.match(/^\w+/)?.[0];if(J&&!this.variables.has(J))this.addError(`Variable '${J}' is not defined`,Z,Y,$)}checkDirectives($){let Z=/@if\s*\(([^)]+)\)/g,Y;while((Y=Z.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let X=/@foreach\s*\((\w+)\s+(?:as|in)\s+(\w+)(?:\s*,\s*(\w+))?\)/g;while((Y=X.exec($))!==null){let[,G,K,W]=Y,U=Y.index,_=this.getLineNumber(U,$),z=this.getColumn(U,$);if(!this.variables.has(G))this.addError(`Collection '${G}' is not defined`,_,z,Y[0]);else{let B=this.variables.get(G);if(B.kind==="array"&&B.elementType)this.variables.set(K,B.elementType);else this.variables.set(K,{kind:"primitive",value:"any"});if(W)this.variables.set(W,{kind:"primitive",value:"number"})}}let J=/@unless\s*\(([^)]+)\)/g;while((Y=J.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let Q=/@switch\s*\(([^)]+)\)/g;while((Y=Q.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}}resolvePropertyAccess($){let Z=$.split("."),Y=this.variables.get(Z[0])||{kind:"primitive",value:"any"};for(let X=1;X<Z.length;X++){let J=Z[X].replace(/\(\)$/,"");if(Y.kind==="object"&&Y.properties)if(Y.properties[J])Y=Y.properties[J];else if(!this.options.allowAny)return{kind:"primitive",value:"undefined"};else Y={kind:"primitive",value:"any"};else if(Y.kind==="array"&&Y.elementType)if(["length"].includes(J))Y={kind:"primitive",value:"number"};else if(["map","filter","find","forEach","some","every","reduce"].includes(J))Y={kind:"function",returnType:{kind:"primitive",value:"any"}};else if(["join"].includes(J))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else Y={kind:"primitive",value:"any"};else if(Y.kind==="primitive"&&Y.value==="string")if(["length"].includes(J))Y={kind:"primitive",value:"number"};else if(["toUpperCase","toLowerCase","trim","slice","substring"].includes(J))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else if(["split"].includes(J))Y={kind:"function",returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}};else Y={kind:"primitive",value:"any"};else Y={kind:"primitive",value:"any"}}return Y}isLiteral($){let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return!0;if(/^-?\d+(\.\d+)?$/.test(Z))return!0;if(Z==="true"||Z==="false")return!0;if(Z==="null"||Z==="undefined")return!0;return!1}extractObjectLiteral($){let Z={},Y=$.slice(1,-1).trim();if(!Y)return Z;let X=this.splitByComma(Y);for(let J of X){let Q=J.indexOf(":");if(Q>0){let G=J.slice(0,Q).trim(),K=J.slice(Q+1).trim();Z[G]=K}}return Z}splitByComma($){let Z=[],Y="",X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q],K=Q>0?$[Q-1]:"";if((G==='"'||G==="'"||G==="`")&&K!=="\\"){if(J===G)J=null;else if(!J)J=G}if(!J){if(G==="{"||G==="["||G==="(")X++;if(G==="}"||G==="]"||G===")")X--;if(G===","&&X===0){Z.push(Y.trim()),Y="";continue}}Y+=G}if(Y.trim())Z.push(Y.trim());return Z}getLineNumber($,Z){return((Z||"").slice(0,$).match(/\n/g)||[]).length+1}getColumn($,Z){let X=Z.slice(0,$).lastIndexOf(`
14229
14229
  `);return $-X}addError($,Z,Y,X,J,Q){this.errors.push({message:$,file:this.currentFile,line:Z,column:Y,expression:X,expected:J,received:Q,severity:"error"})}addWarning($,Z,Y,X,J,Q){let G={message:$,file:this.currentFile,line:Z,column:Y,expression:X,expected:J,received:Q,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,Z){this.variables.set($,Z)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(ZV).forEach(([$,Z])=>{this.variables.set($,Z)})}}function oG($){return new sG($)}function gP($,Z){return oG(Z).checkFile($)}function hP($,Z){return oG(Z).checkTemplate($)}function dP($){let Z=[];for(let Y of $.errors){if(Z.push(`\x1B[31merror\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");if(Y.expected&&Y.received)Z.push(` expected: ${Y.expected}`),Z.push(` received: ${Y.received}`);Z.push("")}for(let Y of $.warnings){if(Z.push(`\x1B[33mwarning\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");Z.push("")}if($.valid)Z.push("\x1B[32m\u2713 No type errors found\x1B[0m");else Z.push(`\x1B[31m\u2717 Found ${$.errors.length} error(s) and ${$.warnings.length} warning(s)\x1B[0m`);return Z.join(`
14230
14230
  `)}var fP,ZV;var YV=D(()=>{fP={strict:!1,allowAny:!0,checkPropertyAccess:!0,checkFunctionCalls:!0,includeBuiltins:!0},ZV={console:{kind:"object",properties:{log:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},error:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}},warn:{kind:"function",params:[{name:"message",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"void"}}}},Math:{kind:"object",properties:{abs:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},floor:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},ceil:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},round:{kind:"function",params:[{name:"x",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},max:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},min:{kind:"function",params:[{name:"values",type:{kind:"primitive",value:"number"}}],returnType:{kind:"primitive",value:"number"}},random:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},PI:{kind:"primitive",value:"number"},E:{kind:"primitive",value:"number"}}},JSON:{kind:"object",properties:{stringify:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},parse:{kind:"function",params:[{name:"text",type:{kind:"primitive",value:"string"}}],returnType:{kind:"primitive",value:"any"}}}},Date:{kind:"function",returnType:{kind:"object",properties:{getTime:{kind:"function",params:[],returnType:{kind:"primitive",value:"number"}},toISOString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}},toLocaleDateString:{kind:"function",params:[],returnType:{kind:"primitive",value:"string"}}}}},Array:{kind:"object",properties:{isArray:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},from:{kind:"function",params:[{name:"arrayLike",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},Object:{kind:"object",properties:{keys:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}},values:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}},entries:{kind:"function",params:[{name:"obj",type:{kind:"primitive",value:"any"}}],returnType:{kind:"array",elementType:{kind:"primitive",value:"any"}}}}},String:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"string"}},Number:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"number"}},Boolean:{kind:"function",params:[{name:"value",type:{kind:"primitive",value:"any"}}],returnType:{kind:"primitive",value:"boolean"}},props:{kind:"object",properties:{}},slot:{kind:"primitive",value:"string"},loop:{kind:"object",properties:{index:{kind:"primitive",value:"number"},iteration:{kind:"primitive",value:"number"},first:{kind:"primitive",value:"boolean"},last:{kind:"primitive",value:"boolean"},even:{kind:"primitive",value:"boolean"},odd:{kind:"primitive",value:"boolean"},count:{kind:"primitive",value:"number"},remaining:{kind:"primitive",value:"number"},depth:{kind:"primitive",value:"number"},parent:{kind:"object",properties:{}}}}}});async function tG($,Z,Y){if(!eG)return;try{let X=$.getAttribute("data-island-id"),J=document.querySelector(`script[data-island-props="${X}"]`),Q=J?JSON.parse(J.textContent||"{}"):{},G=await Y(),K=G.default||G.hydrate;if(typeof K!=="function"){console.error(`Island handler for "${Z}" does not export a valid hydration function`);return}await K($,Q),$.setAttribute("data-hydrated","true")}catch(X){console.error(`Failed to hydrate island "${Z}":`,X)}}function uP($){if(!eG)return;let Z=document.querySelectorAll("[data-island]"),Y=[];if(Z.forEach((X)=>{let J=X.getAttribute("data-island"),Q=X.getAttribute("data-priority")||"lazy";if(!J||!$[J]||X.getAttribute("data-hydrated")==="true")return;if(Q==="eager")tG(X,J,$[J]);else Y.push([X,J])}),Y.length>0&&"IntersectionObserver"in window){let X=new IntersectionObserver((J)=>{J.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target,K=G.getAttribute("data-island");if(K&&$[K]&&G.getAttribute("data-hydrated")!=="true")tG(G,K,$[K]),X.unobserve(G)}})},{rootMargin:"200px",threshold:0});Y.forEach(([J])=>{X.observe(J)})}else setTimeout(()=>{Y.forEach(([X,J])=>{if(X.getAttribute("data-hydrated")!=="true")tG(X,J,$[J])})},1000)}function mP($){if(!eG)return;Object.entries($).forEach(([Z,Y])=>{try{let J=Y.toString().match(/import\(['"](.+)['"]\)/);if(J&&J[1]){let Q=document.createElement("link");Q.rel="modulepreload",Q.href=J[1],Q.setAttribute("data-island-module",Z),document.head.appendChild(Q)}}catch(X){console.warn(`Failed to preload island handler for "${Z}":`,X)}})}var eG;var XV=D(()=>{eG=typeof window<"u"&&typeof document<"u"});function JV($){if(!A5)return null;let Z=document.getElementById("stx-loading-indicator");if(Z)Z.remove();let Y=document.createElement("div");Y.id="stx-loading-indicator";let X=$.initialColor?`linear-gradient(to right, ${$.initialColor}, ${$.color})`:$.color;Y.style.cssText=`
@@ -15065,7 +15065,7 @@ else {
15065
15065
  }
15066
15066
  }
15067
15067
  </style>
15068
- `}var JK=null;var jV=()=>{};import HV from"path";class OV{store=new Map;async get($){let Z=this.store.get($);if(!Z||Z.expires<=Date.now()){if(Z)this.store.delete($);return null}return{...Z.data}}async set($,Z,Y){this.store.set($,{data:{...Z},expires:Date.now()+Y*1000})}async delete($){this.store.delete($)}}async function Xy($,Z={},Y={}){let X=Y.viewsDir||"./views",J=Y.layoutsDir||"./layouts",Q=!$.includes("<")&&!$.includes("@"),G,K;if(Q){if(K=HV.resolve(X,$),!K.endsWith(".stx"))K+=".stx";if(!await Bun.file(K).exists())return new Response(`Template not found: ${$}`,{status:500});G=await Bun.file(K).text()}else G=$,K="inline-template.stx";let W={...Z,props:Z,__filename:K,__dirname:HV.dirname(K)};if(Y.ctx)W.csrf_token=Y.ctx.csrfToken,W.csrf_field=`<input type="hidden" name="_token" value="${Y.ctx.csrfToken}">`,W.old=Y.ctx.old,W.errors=Y.ctx.errors,W.session=Y.ctx.session,W.user=Y.ctx.user(),W.isAuthenticated=Y.ctx.isAuthenticated();let U=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(U){let j=U[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await E0(j,W,K)}let _={layoutsDir:J,...Y.stxOptions},B=await W0(G,W,K,_,new Set),q=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Y.ctx)Y.ctx.responseHeaders.forEach((j,H)=>{q.set(H,j)});return new Response(B,{headers:q})}var LV=D(()=>{R1();U1();A0()});function Jy($,Z){M8.stores.set($,Z)}function GK($){return M8.stores.get($)}function FV($){return M8.stores.has($)}function AV(){return Array.from(M8.stores.keys())}function VV($){if($==="memory")return{getItem:(Z)=>w5.get(Z)??null,setItem:(Z,Y)=>w5.set(Z,Y),removeItem:(Z)=>w5.delete(Z)};if(typeof window>"u")return{getItem:(Z)=>w5.get(Z)??null,setItem:(Z,Y)=>w5.set(Z,Y),removeItem:(Z)=>w5.delete(Z)};return $==="local"?window.localStorage:window.sessionStorage}function Qy($,Z){let Y={};for(let X of Z){let J=X.split("."),Q=$,G=Y,K=!0;for(let W=0;W<J.length-1;W++){let U=J[W];if(Q&&typeof Q==="object"&&U in Q){if(Q=Q[U],!(U in G))G[U]={};G=G[U]}else{K=!1;break}}if(K&&Q&&typeof Q==="object"){let W=J[J.length-1];if(W in Q)G[W]=Q[W]}}return Y}function KK($,Z={}){let{name:Y,persist:X,devtools:J=!1,middleware:Q=[],equals:G=(O,V)=>O===V}=Z,K=$,W=new Set,U=null;if(X){let O=VV(X.storage||"local"),V=X.key||`stx-store:${Y||"unnamed"}`,L=X.deserialize||JSON.parse;try{let F=O.getItem(V);if(F){let A=L(F);if(X.paths&&typeof A==="object"&&A!==null)K={...$,...A};else K=A}}catch{}}let _=(O)=>{if(!X)return;let V=VV(X.storage||"local"),L=X.key||`stx-store:${Y||"unnamed"}`,F=X.serialize||JSON.stringify,A=X.paths&&typeof O==="object"&&O!==null?Qy(O,X.paths):O;if(X.debounce){if(U)clearTimeout(U);U=setTimeout(()=>{V.setItem(L,F(A))},X.debounce)}else V.setItem(L,F(A))},z=(O,V)=>{for(let L of W)try{L(O,V)}catch(F){console.error("[stx-store] Subscriber error:",F)}},B=J?(O,V)=>{if(typeof window<"u"&&window.__STX_DEVTOOLS__)window.__STX_DEVTOOLS__.onStoreChange(Y||"unnamed",O,V)}:()=>{},q=(O)=>{let V=K;if(!G(O,V))K=O,_(O),z(O,V),B("set",O)},j=q,H={get:()=>K,set:(O)=>{if(typeof O==="function")j(O(K));else j(O)},subscribe:(O)=>{return W.add(O),()=>{W.delete(O)}},update:(O)=>{if(typeof K!=="object"||K===null)throw Error("update() can only be used with object stores");let V=typeof O==="function"?O(K):O;H.set({...K,...V})},reset:()=>{H.set($),B("reset",$)},name:Y,destroy:()=>{if(W.clear(),U)clearTimeout(U);if(Y)M8.stores.delete(Y)}};for(let O of Q.reverse())j=O(q,()=>K,H)(j);if(Y)Jy(Y,H);return H}function NV($){let Z=typeof $==="string"?GK($):$;if(!Z)throw Error(`Store "${$}" not found`);return Z.get()}function wV($,Z,Y){if(typeof Z==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,Z,Y);return Z()}let X=Z,{state:J,getters:Q={},actions:G={},persist:K,devtools:W=!0}=X,U=typeof J==="function"?J():J,_=K===!0?{storage:"local",key:`stx-store:${$}`}:K||void 0,z=KK(U,{name:$,persist:_,devtools:W}),B=new Proxy({},{get(q,j){let H=String(j);if(H==="$state")return z.get();if(H==="$subscribe")return z.subscribe;if(H==="$reset")return z.reset;if(H==="$patch")return(V)=>{if(typeof V==="function"){let F={...z.get()};V(F),z.set(F)}else z.update(V)};if(H==="_store")return z;if(H==="$id")return $;if(H in Q)return Q[H](z.get());if(H in G)return(...V)=>{return G[H].apply(B,V)};let O=z.get();if(O&&typeof O==="object"&&H in O)return O[H];return},set(q,j,H){let O=String(j);if(O.startsWith("$")||O==="_store")return!1;let V=z.get();if(V&&typeof V==="object")return z.set({...V,[O]:H}),!0;return!1},has(q,j){let H=String(j),O=z.get();return H.startsWith("$")||H==="_store"||H in Q||H in G||O&&typeof O==="object"&&H in O},ownKeys(){let q=z.get();return[...q&&typeof q==="object"?Object.keys(q):[],...Object.keys(Q),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(q,j){return{enumerable:!0,configurable:!0,get:()=>this.get(q,j,B)}}});return Gy.set($,B),B}var M8,w5,Gy;var RV=D(()=>{M8={stores:new Map,subscriptions:new Map};w5=new Map;Gy=new Map});function I0($,Z={}){let Y=[];for(let[J,Q]of Object.entries(Z)){if(Q===void 0||Q===null)continue;if(Array.isArray(Q))Y.push(`${J}=${encodeURIComponent(Q.join(","))}`);else if(typeof Q==="boolean"){if(Q)Y.push(`${J}=true`)}else Y.push(`${J}=${encodeURIComponent(String(Q))}`)}if(Y.length===0)return $;let X=$.includes("?")?"&":"?";return`${$}${X}${Y.join("&")}`}function WK($){let Z=$.indexOf("?");if(Z===-1)return{src:$,params:{}};let Y=$.slice(0,Z),X=$.slice(Z+1),J={};for(let Q of X.split("&")){let[G,K]=Q.split("="),W=K?decodeURIComponent(K):"";if(W==="true")J[G]=!0;else if(W==="false")J[G]=!1;else if(/^-?\d+$/.test(W))J[G]=Number.parseInt(W,10);else if(/^-?\d+\.\d+$/.test(W))J[G]=Number.parseFloat(W);else if(W.includes(","))J[G]=W.split(",");else J[G]=W}return{src:Y,params:J}}function eY(...$){let Z={};for(let Y of $)if(Y)Object.assign(Z,Y);return Z}function UK($,Z,Y,X){let J={w:Z};if(Y)J.h=Y;if(X)J.fit=X;return I0($,J)}function _K($,Z,Y,X="center"){return I0($,{w:Z,h:Y,fit:"crop",crop:X})}function zK($,Z,Y="center"){return I0($,{w:Z,h:Z,fit:"crop",crop:Y})}function BK($,Z,Y){return I0($,{w:Z,h:Y,fit:"max"})}function qK($,Z,Y){return I0($,{w:Z,h:Y,fit:"crop"})}function jK($,Z){return I0($,{blur:Math.min(2000,Math.max(0,Z))})}function HK($,Z){return I0($,{sharp:Math.min(100,Math.max(0,Z))})}function OK($){return I0($,{sat:-100})}function LK($,Z=100){return I0($,{sepia:Math.min(100,Math.max(0,Z))})}function VK($){return I0($,{invert:!0})}function FK($,Z){return I0($,{bri:Math.min(100,Math.max(-100,Z))})}function AK($,Z){return I0($,{con:Math.min(100,Math.max(-100,Z))})}function NK($,Z){return I0($,{sat:Math.min(100,Math.max(-100,Z))})}function wK($,Z){return I0($,{rot:(Z%360+360)%360})}function RK($){return I0($,{flip:"h"})}function MK($){return I0($,{flip:"v"})}function TK($,Z,Y){let X={fm:Z};if(Y!==void 0)X.q=Y;return I0($,X)}function EK($,Z){return I0($,{q:Math.min(100,Math.max(1,Z))})}function IK($,Z=["format","compress"]){return I0($,{auto:Z})}function DK($,Z,Y={}){return I0($,{mark:Z,markx:Y.x,marky:Y.y,markalpha:Y.alpha,markscale:Y.scale,markalign:Y.align})}function kK($,Z,Y){return I0($,eY($X[Z],Y))}function SK($,Z,Y){return Z.map((X)=>I0($,{...Y,w:X}))}function CK($,Z,Y=[1,2,3],X){return Y.map((J)=>I0($,{...X,w:Math.round(Z*J),dpr:J}))}function bK($){let Z=[];if($.w!==void 0&&($.w<1||$.w>16383))Z.push("Width must be between 1 and 16383");if($.h!==void 0&&($.h<1||$.h>16383))Z.push("Height must be between 1 and 16383");if($.q!==void 0&&($.q<1||$.q>100))Z.push("Quality must be between 1 and 100");if($.blur!==void 0&&($.blur<0||$.blur>2000))Z.push("Blur must be between 0 and 2000");if($.rot!==void 0&&($.rot<0||$.rot>359))Z.push("Rotation must be between 0 and 359");if($.dpr!==void 0&&($.dpr<1||$.dpr>5))Z.push("DPR must be between 1 and 5");return{valid:Z.length===0,errors:Z}}function PK($){let Z={...$};if(Z.w!==void 0)Z.w=Math.min(16383,Math.max(1,Z.w));if(Z.h!==void 0)Z.h=Math.min(16383,Math.max(1,Z.h));if(Z.q!==void 0)Z.q=Math.min(100,Math.max(1,Z.q));if(Z.blur!==void 0)Z.blur=Math.min(2000,Math.max(0,Z.blur));if(Z.rot!==void 0)Z.rot=(Z.rot%360+360)%360;if(Z.dpr!==void 0)Z.dpr=Math.min(5,Math.max(1,Z.dpr));return Z}var $X;var MV=D(()=>{$X={web:{fm:"webp",q:80,auto:["format","compress"]},highQuality:{q:95},thumb:{w:150,h:150,fit:"crop",crop:"center"},avatar:{w:200,h:200,fit:"crop",crop:"faces"},social:{w:1200,h:630,fit:"crop"},preview:{w:400,q:70},placeholder:{w:20,blur:200,q:20}}});var TV=D(()=>{LQ();FQ();$Y();YQ();MV()});function yK($){let{endpoint:Z,accept:Y,maxSize:X,maxFiles:J=1,fieldName:Q="file",preview:G=!1,dropzone:K=!0,multiple:W=!1,autoUpload:U=!0,showProgress:_=!0,disabled:z=!1,placeholder:B="Drop files here or click to select",label:q}=$,j=$.class||"",H=$.style||"",O=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,V=Array.isArray(Y)?Y.join(","):Y,L=`
15068
+ `}var JK=null;var jV=()=>{};import HV from"path";class OV{store=new Map;async get($){let Z=this.store.get($);if(!Z||Z.expires<=Date.now()){if(Z)this.store.delete($);return null}return{...Z.data}}async set($,Z,Y){this.store.set($,{data:{...Z},expires:Date.now()+Y*1000})}async delete($){this.store.delete($)}}async function Xy($,Z={},Y={}){let X=Y.viewsDir||"./views",J=Y.layoutsDir||"./layouts",Q=!$.includes("<")&&!$.includes("@"),G,K;if(Q){if(K=HV.resolve(X,$),!K.endsWith(".stx"))K+=".stx";if(!await Bun.file(K).exists())return new Response(`Template not found: ${$}`,{status:500});G=await Bun.file(K).text()}else G=$,K="inline-template.stx";let W={...Z,props:Z,__filename:K,__dirname:HV.dirname(K)};if(Y.ctx)W.csrf_token=Y.ctx.csrfToken,W.csrf_field=`<input type="hidden" name="_token" value="${Y.ctx.csrfToken}">`,W.old=Y.ctx.old,W.errors=Y.ctx.errors,W.session=Y.ctx.session,W.user=Y.ctx.user(),W.isAuthenticated=Y.ctx.isAuthenticated();let U=G.match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(U){let j=U[1];G=G.replace(/<script\s+server\b[^>]*>[\s\S]*?<\/script>/gi,""),await I0(j,W,K)}let _={layoutsDir:J,...Y.stxOptions},B=await W0(G,W,K,_,new Set),q=new Headers({"Content-Type":"text/html; charset=utf-8"});if(Y.ctx)Y.ctx.responseHeaders.forEach((j,H)=>{q.set(H,j)});return new Response(B,{headers:q})}var LV=D(()=>{R1();U1();N0()});function Jy($,Z){M8.stores.set($,Z)}function GK($){return M8.stores.get($)}function FV($){return M8.stores.has($)}function AV(){return Array.from(M8.stores.keys())}function VV($){if($==="memory")return{getItem:(Z)=>w5.get(Z)??null,setItem:(Z,Y)=>w5.set(Z,Y),removeItem:(Z)=>w5.delete(Z)};if(typeof window>"u")return{getItem:(Z)=>w5.get(Z)??null,setItem:(Z,Y)=>w5.set(Z,Y),removeItem:(Z)=>w5.delete(Z)};return $==="local"?window.localStorage:window.sessionStorage}function Qy($,Z){let Y={};for(let X of Z){let J=X.split("."),Q=$,G=Y,K=!0;for(let W=0;W<J.length-1;W++){let U=J[W];if(Q&&typeof Q==="object"&&U in Q){if(Q=Q[U],!(U in G))G[U]={};G=G[U]}else{K=!1;break}}if(K&&Q&&typeof Q==="object"){let W=J[J.length-1];if(W in Q)G[W]=Q[W]}}return Y}function KK($,Z={}){let{name:Y,persist:X,devtools:J=!1,middleware:Q=[],equals:G=(O,V)=>O===V}=Z,K=$,W=new Set,U=null;if(X){let O=VV(X.storage||"local"),V=X.key||`stx-store:${Y||"unnamed"}`,L=X.deserialize||JSON.parse;try{let F=O.getItem(V);if(F){let A=L(F);if(X.paths&&typeof A==="object"&&A!==null)K={...$,...A};else K=A}}catch{}}let _=(O)=>{if(!X)return;let V=VV(X.storage||"local"),L=X.key||`stx-store:${Y||"unnamed"}`,F=X.serialize||JSON.stringify,A=X.paths&&typeof O==="object"&&O!==null?Qy(O,X.paths):O;if(X.debounce){if(U)clearTimeout(U);U=setTimeout(()=>{V.setItem(L,F(A))},X.debounce)}else V.setItem(L,F(A))},z=(O,V)=>{for(let L of W)try{L(O,V)}catch(F){console.error("[stx-store] Subscriber error:",F)}},B=J?(O,V)=>{if(typeof window<"u"&&window.__STX_DEVTOOLS__)window.__STX_DEVTOOLS__.onStoreChange(Y||"unnamed",O,V)}:()=>{},q=(O)=>{let V=K;if(!G(O,V))K=O,_(O),z(O,V),B("set",O)},j=q,H={get:()=>K,set:(O)=>{if(typeof O==="function")j(O(K));else j(O)},subscribe:(O)=>{return W.add(O),()=>{W.delete(O)}},update:(O)=>{if(typeof K!=="object"||K===null)throw Error("update() can only be used with object stores");let V=typeof O==="function"?O(K):O;H.set({...K,...V})},reset:()=>{H.set($),B("reset",$)},name:Y,destroy:()=>{if(W.clear(),U)clearTimeout(U);if(Y)M8.stores.delete(Y)}};for(let O of Q.reverse())j=O(q,()=>K,H)(j);if(Y)Jy(Y,H);return H}function NV($){let Z=typeof $==="string"?GK($):$;if(!Z)throw Error(`Store "${$}" not found`);return Z.get()}function wV($,Z,Y){if(typeof Z==="function"){if(typeof window<"u"&&window.stx?.defineStore)return window.stx.defineStore($,Z,Y);return Z()}let X=Z,{state:J,getters:Q={},actions:G={},persist:K,devtools:W=!0}=X,U=typeof J==="function"?J():J,_=K===!0?{storage:"local",key:`stx-store:${$}`}:K||void 0,z=KK(U,{name:$,persist:_,devtools:W}),B=new Proxy({},{get(q,j){let H=String(j);if(H==="$state")return z.get();if(H==="$subscribe")return z.subscribe;if(H==="$reset")return z.reset;if(H==="$patch")return(V)=>{if(typeof V==="function"){let F={...z.get()};V(F),z.set(F)}else z.update(V)};if(H==="_store")return z;if(H==="$id")return $;if(H in Q)return Q[H](z.get());if(H in G)return(...V)=>{return G[H].apply(B,V)};let O=z.get();if(O&&typeof O==="object"&&H in O)return O[H];return},set(q,j,H){let O=String(j);if(O.startsWith("$")||O==="_store")return!1;let V=z.get();if(V&&typeof V==="object")return z.set({...V,[O]:H}),!0;return!1},has(q,j){let H=String(j),O=z.get();return H.startsWith("$")||H==="_store"||H in Q||H in G||O&&typeof O==="object"&&H in O},ownKeys(){let q=z.get();return[...q&&typeof q==="object"?Object.keys(q):[],...Object.keys(Q),...Object.keys(G),"$state","$subscribe","$reset","$patch","$id"]},getOwnPropertyDescriptor(q,j){return{enumerable:!0,configurable:!0,get:()=>this.get(q,j,B)}}});return Gy.set($,B),B}var M8,w5,Gy;var RV=D(()=>{M8={stores:new Map,subscriptions:new Map};w5=new Map;Gy=new Map});function D0($,Z={}){let Y=[];for(let[J,Q]of Object.entries(Z)){if(Q===void 0||Q===null)continue;if(Array.isArray(Q))Y.push(`${J}=${encodeURIComponent(Q.join(","))}`);else if(typeof Q==="boolean"){if(Q)Y.push(`${J}=true`)}else Y.push(`${J}=${encodeURIComponent(String(Q))}`)}if(Y.length===0)return $;let X=$.includes("?")?"&":"?";return`${$}${X}${Y.join("&")}`}function WK($){let Z=$.indexOf("?");if(Z===-1)return{src:$,params:{}};let Y=$.slice(0,Z),X=$.slice(Z+1),J={};for(let Q of X.split("&")){let[G,K]=Q.split("="),W=K?decodeURIComponent(K):"";if(W==="true")J[G]=!0;else if(W==="false")J[G]=!1;else if(/^-?\d+$/.test(W))J[G]=Number.parseInt(W,10);else if(/^-?\d+\.\d+$/.test(W))J[G]=Number.parseFloat(W);else if(W.includes(","))J[G]=W.split(",");else J[G]=W}return{src:Y,params:J}}function eY(...$){let Z={};for(let Y of $)if(Y)Object.assign(Z,Y);return Z}function UK($,Z,Y,X){let J={w:Z};if(Y)J.h=Y;if(X)J.fit=X;return D0($,J)}function _K($,Z,Y,X="center"){return D0($,{w:Z,h:Y,fit:"crop",crop:X})}function zK($,Z,Y="center"){return D0($,{w:Z,h:Z,fit:"crop",crop:Y})}function BK($,Z,Y){return D0($,{w:Z,h:Y,fit:"max"})}function qK($,Z,Y){return D0($,{w:Z,h:Y,fit:"crop"})}function jK($,Z){return D0($,{blur:Math.min(2000,Math.max(0,Z))})}function HK($,Z){return D0($,{sharp:Math.min(100,Math.max(0,Z))})}function OK($){return D0($,{sat:-100})}function LK($,Z=100){return D0($,{sepia:Math.min(100,Math.max(0,Z))})}function VK($){return D0($,{invert:!0})}function FK($,Z){return D0($,{bri:Math.min(100,Math.max(-100,Z))})}function AK($,Z){return D0($,{con:Math.min(100,Math.max(-100,Z))})}function NK($,Z){return D0($,{sat:Math.min(100,Math.max(-100,Z))})}function wK($,Z){return D0($,{rot:(Z%360+360)%360})}function RK($){return D0($,{flip:"h"})}function MK($){return D0($,{flip:"v"})}function TK($,Z,Y){let X={fm:Z};if(Y!==void 0)X.q=Y;return D0($,X)}function EK($,Z){return D0($,{q:Math.min(100,Math.max(1,Z))})}function IK($,Z=["format","compress"]){return D0($,{auto:Z})}function DK($,Z,Y={}){return D0($,{mark:Z,markx:Y.x,marky:Y.y,markalpha:Y.alpha,markscale:Y.scale,markalign:Y.align})}function kK($,Z,Y){return D0($,eY($X[Z],Y))}function SK($,Z,Y){return Z.map((X)=>D0($,{...Y,w:X}))}function CK($,Z,Y=[1,2,3],X){return Y.map((J)=>D0($,{...X,w:Math.round(Z*J),dpr:J}))}function bK($){let Z=[];if($.w!==void 0&&($.w<1||$.w>16383))Z.push("Width must be between 1 and 16383");if($.h!==void 0&&($.h<1||$.h>16383))Z.push("Height must be between 1 and 16383");if($.q!==void 0&&($.q<1||$.q>100))Z.push("Quality must be between 1 and 100");if($.blur!==void 0&&($.blur<0||$.blur>2000))Z.push("Blur must be between 0 and 2000");if($.rot!==void 0&&($.rot<0||$.rot>359))Z.push("Rotation must be between 0 and 359");if($.dpr!==void 0&&($.dpr<1||$.dpr>5))Z.push("DPR must be between 1 and 5");return{valid:Z.length===0,errors:Z}}function PK($){let Z={...$};if(Z.w!==void 0)Z.w=Math.min(16383,Math.max(1,Z.w));if(Z.h!==void 0)Z.h=Math.min(16383,Math.max(1,Z.h));if(Z.q!==void 0)Z.q=Math.min(100,Math.max(1,Z.q));if(Z.blur!==void 0)Z.blur=Math.min(2000,Math.max(0,Z.blur));if(Z.rot!==void 0)Z.rot=(Z.rot%360+360)%360;if(Z.dpr!==void 0)Z.dpr=Math.min(5,Math.max(1,Z.dpr));return Z}var $X;var MV=D(()=>{$X={web:{fm:"webp",q:80,auto:["format","compress"]},highQuality:{q:95},thumb:{w:150,h:150,fit:"crop",crop:"center"},avatar:{w:200,h:200,fit:"crop",crop:"faces"},social:{w:1200,h:630,fit:"crop"},preview:{w:400,q:70},placeholder:{w:20,blur:200,q:20}}});var TV=D(()=>{LQ();FQ();$Y();YQ();MV()});function yK($){let{endpoint:Z,accept:Y,maxSize:X,maxFiles:J=1,fieldName:Q="file",preview:G=!1,dropzone:K=!0,multiple:W=!1,autoUpload:U=!0,showProgress:_=!0,disabled:z=!1,placeholder:B="Drop files here or click to select",label:q}=$,j=$.class||"",H=$.style||"",O=$.id||`stx-upload-${Math.random().toString(36).slice(2,8)}`,V=Array.isArray(Y)?Y.join(","):Y,L=`
15069
15069
  <div id="${O}" class="stx-upload${K?" stx-upload-dropzone":""}${z?" stx-upload-disabled":""}${j?" "+j:""}"${H?` style="${H}"`:""}>
15070
15070
  ${q?`<label class="stx-upload-label">${EV(q)}</label>`:""}
15071
15071
  <div class="stx-upload-area" data-stx-upload-area>
@@ -15957,7 +15957,7 @@ else {
15957
15957
  })();
15958
15958
  `.trim()}var Oy;var GW=D(()=>{Oy={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1}});function KW(){return{script:[D8(),S8(),b8()].join(`
15959
15959
 
15960
- `),css:C8()}}function hV(){let{script:$,css:Z}=KW(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),X=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:X}}var dV=D(()=>{sK();YW();GW();sK();YW();GW()});var uV=D(()=>{X6();XY()});var Fy;var mV=D(()=>{TV();zQ();SQ();kQ();IV();SV();dV();uV();Fy={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}}});import zX from"fs";import r6 from"path";async function WW($,Z={},Y={}){let X=await Bun.file($).text(),J=X.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=J?X.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):X;G=G.replace(/<script\s+client\s*>/gi,"<script>");let K={__filename:$,__dirname:r6.dirname($),props:Z,...Z};if(Q)await E0(Q,K,$);let W={...O1,...Y};return await W0(G,K,$,W,new Set)}async function cV($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:X,outputDir:J,componentsDir:Q=r6.join(X,"components"),layoutsDir:G=r6.join(X,"layouts"),partialsDir:K=r6.join(X,"partials"),globalProps:W={},placeholders:U={},views:_,debug:z=!1,generateManifest:B=!0}=$;if(z)console.log("Building STX views..."),console.log(` Source: ${X}`),console.log(` Output: ${J}`);zX.mkdirSync(J,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:z},j;if(_&&_.length>0)j=_;else j=zX.readdirSync(X).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=r6.join(X,H.input),V=H.output||H.input.replace(/\.stx$/,".html"),L=r6.join(J,V);if(z)console.log(` Building ${H.input}...`);try{let F={...W,...H.props,...U},A=await WW(O,F,q);await Bun.write(L,A),Y.views.push(V)}catch(F){let A=F instanceof Error?F.message:String(F);if(Y.errors.push({file:H.input,error:A}),Y.success=!1,z)console.error(` Error: ${A}`)}}if(B){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(r6.join(J,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,z)if(Y.success)console.log(`
15960
+ `),css:C8()}}function hV(){let{script:$,css:Z}=KW(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),X=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:X}}var dV=D(()=>{sK();YW();GW();sK();YW();GW()});var uV=D(()=>{X6();XY()});var Fy;var mV=D(()=>{TV();zQ();SQ();kQ();IV();SV();dV();uV();Fy={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}}});import zX from"fs";import r6 from"path";async function WW($,Z={},Y={}){let X=await Bun.file($).text(),J=X.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=J?X.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):X;G=G.replace(/<script\s+client\s*>/gi,"<script>");let K={__filename:$,__dirname:r6.dirname($),props:Z,...Z};if(Q)await I0(Q,K,$);let W={...O1,...Y};return await W0(G,K,$,W,new Set)}async function cV($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:X,outputDir:J,componentsDir:Q=r6.join(X,"components"),layoutsDir:G=r6.join(X,"layouts"),partialsDir:K=r6.join(X,"partials"),globalProps:W={},placeholders:U={},views:_,debug:z=!1,generateManifest:B=!0}=$;if(z)console.log("Building STX views..."),console.log(` Source: ${X}`),console.log(` Output: ${J}`);zX.mkdirSync(J,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:z},j;if(_&&_.length>0)j=_;else j=zX.readdirSync(X).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=r6.join(X,H.input),V=H.output||H.input.replace(/\.stx$/,".html"),L=r6.join(J,V);if(z)console.log(` Building ${H.input}...`);try{let F={...W,...H.props,...U},A=await WW(O,F,q);await Bun.write(L,A),Y.views.push(V)}catch(F){let A=F instanceof Error?F.message:String(F);if(Y.errors.push({file:H.input,error:A}),Y.success=!1,z)console.error(` Error: ${A}`)}}if(B){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(r6.join(J,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,z)if(Y.success)console.log(`
15961
15961
  \u2705 Built ${Y.views.length} views in ${Y.duration.toFixed(0)}ms`);else console.log(`
15962
15962
  \u26A0\uFE0F Built ${Y.views.length} views with ${Y.errors.length} errors`);return Y}function Ay($,Z){let Y=zX.watch($.viewsDir,{recursive:!0},async(X,J)=>{if(!J)return;if(J.endsWith(".stx")||J.endsWith(".ts")||J.endsWith(".js")){if($.debug)console.log(`
15963
15963
  File changed: ${J}, rebuilding...`);let Q=await cV($);Z?.(Q)}});return{close:()=>Y.close()}}async function Ny($,Z={},Y={}){let X={...Y,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},J=await WW($,Z,X);J=await wy(J),J=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),J=J.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),J=J.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),J=J.replace(/\n\s*\n\s*\n/g,`
@@ -16062,7 +16062,7 @@ File changed: ${J}, rebuilding...`);let Q=await cV($);Z?.(Q)}});return{close:()=
16062
16062
  <body>
16063
16063
  ${$}
16064
16064
  </body>
16065
- </html>`}async function xy($,Z={}){let Y=VF($),X=Bun.file(Y);if(!await X.exists())throw Error(`Template file not found: ${Y}`);let J=await X.text();if(Z.layout){let Q=VF(Z.layout),G=Bun.file(Q);if(!await G.exists())throw Error(`Layout template not found: ${Q}`);let{layout:K,injectCSS:W,...U}=Z,_=await jX(J,Y,{...U,injectCSS:!1}),z=await G.text(),B={...Z.context||{},content:_},q={...U,context:B,injectCSS:W};return jX(z,Q,q)}return jX(J,Y,Z)}async function vy($,Z={},Y){return jX($,process.cwd(),{context:Z,...Y})}async function jX($,Z,Y={}){let{templateContent:X,serverScripts:J,clientScripts:Q}=Py($),G={...O1,...Y.options},K={__filename:Z,__dirname:by(Z),__stx:{},__stx_options:G,__stx_sfc_mode:!0,__stx_inject_css:Y.injectCSS!==!1,...Y.context||{}};for(let _ of J)await E0(_,K,Z);let W=new Set,U=X;if(U=await W0(U,K,Z,G,W),Y.templateOnly){if(U=U.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),U=U.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),Q.length>0)U+=`
16065
+ </html>`}async function xy($,Z={}){let Y=VF($),X=Bun.file(Y);if(!await X.exists())throw Error(`Template file not found: ${Y}`);let J=await X.text();if(Z.layout){let Q=VF(Z.layout),G=Bun.file(Q);if(!await G.exists())throw Error(`Layout template not found: ${Q}`);let{layout:K,injectCSS:W,...U}=Z,_=await jX(J,Y,{...U,injectCSS:!1}),z=await G.text(),B={...Z.context||{},content:_},q={...U,context:B,injectCSS:W};return jX(z,Q,q)}return jX(J,Y,Z)}async function vy($,Z={},Y){return jX($,process.cwd(),{context:Z,...Y})}async function jX($,Z,Y={}){let{templateContent:X,serverScripts:J,clientScripts:Q}=Py($),G={...O1,...Y.options},K={__filename:Z,__dirname:by(Z),__stx:{},__stx_options:G,__stx_sfc_mode:!0,__stx_inject_css:Y.injectCSS!==!1,...Y.context||{}};for(let _ of J)await I0(_,K,Z);let W=new Set,U=X;if(U=await W0(U,K,Z,G,W),Y.templateOnly){if(U=U.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),U=U.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),Q.length>0)U+=`
16066
16066
  ${Q.join(`
16067
16067
  `)}`}else{if(Y.processClientScripts!==!1&&Q.length>0){let _=K.__stx_event_bindings||[],z=C4(K),q=(await Promise.all(Q.map(async(H)=>{let O=H.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!O)return H;return await b4(O[1],{eventBindings:_,templateContent:U,serverData:z})}))).join(`
16068
16068
  `);if(U.match(/(<\/body>)/i))U=U.replace(/(<\/body>)/i,`${q}
@@ -16097,7 +16097,7 @@ ${Q}`}var E5=null;function v8($,Z){if(Z.theme===!1)return $;let Y=typeof Z.theme
16097
16097
  ${J.slice(K)}`;return`${$.slice(0,X)}${z}${$.slice(Y)}`}function Hx($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wW($){return $}var TF=D(()=>{o1();VW()});var EF=D(()=>{TF();VW()});function Vx($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Fx($){let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,X;while((X=Y.exec($))!==null)Z.push([X.index,X.index+X[0].length]);return Z}function Ax($,Z){for(let[Y,X]of $)if(Z>=Y&&Z<X)return!0;return!1}function m8($,Z){let Y=1,X=0;for(let J=0;J<Z&&J<$.length;J++)if($[J]===`
16098
16098
  `)Y++,X=J+1;return{line:Y,column:Z-X+1}}function Nx($,Z,Y){let X=Z.toLowerCase(),J=$.length,Q=1,G=Y;while(G<J){let K=$.indexOf("<",G);if(K===-1)return-1;if(G=K,$.startsWith("<!--",G)){let _=$.indexOf("-->",G+4);if(_===-1)return-1;G=_+3;continue}if($[G+1]==="/"){let _=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(G,G+64));if(!_){G++;continue}if(_[1].toLowerCase()===X){if(Q--,G+=_[0].length,Q===0)return G;continue}G+=_[0].length;continue}let W=/^<([a-z][\w-]*)\b/i.exec($.slice(G,G+64));if(!W){G++;continue}let U=$.indexOf(">",G);if(U===-1)return-1;if(W[1].toLowerCase()===X&&$[U-1]!=="/")Q++;G=U+1}return-1}function wx($,Z,Y){let X=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,J;while((J=X.exec($))!==null){if(Ax(Z,J.index))continue;let Q=J[1].toLowerCase().split(":")[0];if(Ox.has(Q))continue;let G=J[3].trim();if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(G)){let K=$.indexOf(J[3],J.index),{line:W,column:U}=m8($,K<0?J.index:K);Y.push({ruleId:"stx/no-bare-function-ref-in-event",message:`Event handler @${J[1]}="${G}" is a bare reference and will not fire. Call it: @${J[1]}="${G}()".`,line:W,column:U,severity:"error"})}}}function Rx($,Z,Y){if(Z!=="view")return;let X=/<script\b([^>]*)>/gi,J;while((J=X.exec($))!==null)if(/(?:^|\s)client(?=[\s/=]|$)/i.test(J[1])){let{line:Q,column:G}=m8($,J.index);Y.push({ruleId:"stx/no-view-level-script-client",message:"<script client> at the top level of a view is silently dropped \u2014 only components get client scopes. Move it into a component, or use <script> (server).",line:Q,column:G,severity:"error"})}}function IF($){let Z=$.split("/"),Y=[];for(let X of Z){if(X===""||X===".")continue;if(X==="..")Y.pop();else Y.push(X)}return Y.join("/")}function Mx($,Z,Y){let X=Z.replace(/\\/g,"/"),J=X.indexOf("resources/stores/");if(J===-1)return;let Q=X.slice(0,J+16),G=X.slice(0,X.lastIndexOf("/")),K=/\b(import|export)\s+(type\s+)?([^'"]*?)\s*from\s*['"]([^'"]+)['"]/g,W;while((W=K.exec($))!==null){if(W[2])continue;let U=W[1],_=W[4],z;if(_.startsWith("."))z=!IF(`${G}/${_}`).startsWith(IF(Q));else z=!0;if(z){let{line:B,column:q}=m8($,W.index),j=U==="export"?"Value re-export":"Value import";Y.push({ruleId:"stx/store-value-imports-must-be-local",message:`${j} from "${_}" is outside resources/stores/ and will be stripped from the store bundle. Use \`${U} type\`, or move the value into the stores dir.`,line:B,column:q,severity:"error"})}}}function Tx($){let Z=$.trim(),Y=(G)=>{let K=G.match(/[A-Za-z_$][\w$]*/g);return K?K:[]},X=/\bas\s+(.+)$/.exec(Z);if(X){let G=X[1].trim(),K=/^([A-Za-z_$][\w$]*)\s*=>\s*([A-Za-z_$][\w$]*)/.exec(G);if(K)return[K[1],K[2]];let W=/^\(([^)]*)\)/.exec(G);if(W)return Y(W[1]);let U=/^([A-Za-z_$][\w$]*)/.exec(G);return U?[U[1]]:[]}let J=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(Z);if(J)return Y(J[1]);let Q=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(Z);return Q?[Q[1]]:[]}function Ex($,Z){let Y=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,X;while((X=Y.exec($))!==null){let J=Tx(X[1]);if(J.length===0)continue;let Q=$.lastIndexOf("<",X.index);if(Q===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(Q,Q+64));if(!G)continue;let K=$.indexOf(">",X.index);if(K===-1)continue;let U=$[K-1]==="/"||Lx.has(G[1].toLowerCase())?K+1:Nx($,G[1],K+1),_=U===-1?K+1:U,z=$.indexOf(X[1],X.index),B=$.slice(Q,_);if(z>=0&&z+X[1].length<=_){let q=z-Q;B=B.slice(0,q)+" ".repeat(X[1].length)+B.slice(q+X[1].length)}for(let q of J){let j=new RegExp(`(?<![.\\w$])${Vx(q)}\\s*\\(`,"g"),H;while((H=j.exec(B))!==null){let O=Q+H.index,{line:V,column:L}=m8($,O);Z.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${q}" is a :for iteration variable, not a signal \u2014 calling it as "${q}()" leaves it as a function and silently breaks comparisons. Use "${q}" directly.`,line:V,column:L,severity:"error"})}}}}function Ix($,Z){let Y=/<!--([\s\S]*?)-->/g,X;while((X=Y.exec($))!==null){let Q=X[1].indexOf("`");if(Q!==-1){let G=X.index+4+Q,{line:K,column:W}=m8($,G);Z.push({ruleId:"stx/no-backticks-in-html-comments",message:"Backtick inside an HTML comment leaks into the merged setup function and flips the JS parser into template-literal mode. Remove it or rephrase the comment.",line:K,column:W,severity:"error"})}}}function u8($,Z){return $?.[Z]!==!1}function DF($,Z={}){let Y=[],X=Fx($),J=(Z.filePath??"").replace(/\\/g,"/"),Q=Z.fileKind??(/\/components?\//i.test(J)?"component":"view");if(u8(Z.rules,"stx/no-bare-function-ref-in-event"))wx($,X,Y);if(u8(Z.rules,"stx/no-view-level-script-client"))Rx($,Q,Y);if(J&&u8(Z.rules,"stx/store-value-imports-must-be-local"))Mx($,J,Y);if(u8(Z.rules,"stx/no-signal-call-in-for-iteration-var"))Ex($,Y);if(u8(Z.rules,"stx/no-backticks-in-html-comments"))Ix($,Y);Y.sort((K,W)=>K.line-W.line||K.column-W.column);let G=new Set;return Y.filter((K)=>{let W=`${K.ruleId}:${K.line}:${K.column}`;if(G.has(W))return!1;return G.add(W),!0})}var Ox,Lx;var kF=D(()=>{Ox=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),Lx=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});function SF($,Z){return $.kind===Z}var CF=()=>{};var bF=D(()=>{CF()});function PF($){if($===String)return"string";if($===Number)return"number";if($===Boolean)return"boolean";if($===Array)return"array";if($===Object)return"object";if($===Function)return"function";if($===Date)return"date";if($===Symbol)return"symbol";if(typeof $==="function"&&$.name)return $.name;return"unknown"}function Dx($,Z){if($===null||$===void 0)return!0;if(Z===String)return typeof $==="string";if(Z===Number)return typeof $==="number"&&!Number.isNaN($);if(Z===Boolean)return typeof $==="boolean";if(Z===Array)return Array.isArray($);if(Z===Object)return typeof $==="object"&&!Array.isArray($);if(Z===Function)return typeof $==="function";if(Z===Date)return $ instanceof Date;if(Z===Symbol)return typeof $==="symbol";if(typeof Z==="function")return $ instanceof Z;return!0}function yF($,Z,Y,X){let J=X?`[${X}]`:"";if(Y.required&&(Z===void 0||Z===null))return{prop:$,message:`${J} Missing required prop: "${$}"`,value:Z,expected:Y.type?PF(Y.type):void 0};if(Z===void 0||Z===null)return null;if(Y.type){let Q=Array.isArray(Y.type)?Y.type:[Y.type];if(!Q.some((K)=>Dx(Z,K))){let K=Q.map((W)=>PF(W)).join(" | ");return{prop:$,message:`${J} Invalid prop type for "${$}": expected ${K}, got ${typeof Z}`,value:Z,expected:K}}}if(Y.validator){if(!Y.validator(Z))return{prop:$,message:`${J} Custom validation failed for prop "${$}"`,value:Z}}return null}function xF($){let Z=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return Z;let Y={...Z};for(let[X,J]of Object.entries($)){let Q=typeof J==="function"||Array.isArray(J)?{type:J}:J||{};if(Y[X]===void 0&&Q.default!==void 0)Y[X]=typeof Q.default==="function"?Q.default():Q.default}return Y}function vF($,Z={}){let{componentName:Y,throwOnError:X=!1,logWarnings:J=!0}=Z,Q=globalThis.__STX_CURRENT_PROPS__||{},G={...Q},K={valid:!0,errors:[],warnings:[]};for(let[W,U]of Object.entries($)){let _=typeof U==="function"||Array.isArray(U)?{type:U}:U||{};if(G[W]===void 0&&_.default!==void 0)G[W]=typeof _.default==="function"?_.default():_.default;let z=yF(W,G[W],_,Y);if(z){if(K.valid=!1,K.errors.push(z),J)console.warn(z.message)}}for(let W of Object.keys(Q))if(!(W in $)){let U=`${Y?`[${Y}]`:""} Unknown prop: "${W}"`;if(K.warnings.push(U),J)console.warn(U)}if(X&&!K.valid){let W=K.errors.map((U)=>U.message).join(`
16099
16099
  `);throw Error(`Prop validation failed:
16100
- ${W}`)}return{props:G,validation:K}}function fF($,Z){let Y={...$};for(let[X,J]of Object.entries(Z))if(Y[X]===void 0)Y[X]=typeof J==="function"?J():J;return Y}function gF($){return $}function hF($){return{type:$,required:!0}}function dF($,Z){return{type:Z,default:$}}function uF($,Z={}){return{...Z,validator:$}}function mF($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function cF($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function lF($,Z={}){return{...Z,type:Object}}function pF($,Z,Y){if(!Z)return $;let X={};for(let[J,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[J];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=yF(J,K,G,Y);if(W)console.warn(W.message)}X[J]=K}for(let[J,Q]of Object.entries($))if(!(J in X))X[J]=Q;return X}var l6={};e(l6,{writeNetlifyConfig:()=>s7,writeManifest:()=>NG,writeImageManifest:()=>JG,wrapComponentForHMR:()=>sP,withDefaults:()=>fF,webComponentDirectiveHandler:()=>yQ,watermark:()=>DK,watchViews:()=>Ay,watchMultiple:()=>AS,watchEffect:()=>NS,watch:()=>FS,waitForStore:()=>mS,waitForLocale:()=>EM,videoDirective:()=>u7,validators:()=>m3,validated:()=>uF,validateValueEnhanced:()=>e_,validateTemplate:()=>Fj,validateParams:()=>bK,validateFormEnhanced:()=>HM,validateFile:()=>UX,validateFields:()=>qM,validateField:()=>o_,validateDirective:()=>Nj,validateCspDirectives:()=>sR,validateConfig:()=>IH,validateComponentScripts:()=>hC,validateComponentProps:()=>cC,validateClientScript:()=>M7,usesSignalsInScript:()=>M6,userComponentFileExists:()=>T9,useVirtualList:()=>G2,useTitle:()=>u_,useStoreOrThrow:()=>uS,useStore:()=>NV,useSlots:()=>tV,useSeoMeta:()=>X7,useRouteParams:()=>KO,useRouteParamOrThrow:()=>cS,useRouteParam:()=>WO,usePageTitle:()=>u_,useOptimistic:()=>TB,useMiddlewareValue:()=>lS,useMiddlewareState:()=>UO,useLoadingIndicator:()=>QV,useHead:()=>m4,useAttrs:()=>$F,uploadFiles:()=>XW,uploadFile:()=>_X,updateInstance:()=>kS,untrack:()=>xZ,unregisterDirective:()=>QD,unmountInstance:()=>SS,unescapeHtml:()=>I3,transpileTypeScript:()=>y4,translate:()=>VX,transitionDirective:()=>q3,toUsers:()=>$L,toUser:()=>eO,thumbnail:()=>zK,thumbHashToRGBA:()=>k8,thumbHashToDataURL:()=>tK,templateCache:()=>a9,stxClientHelpers:()=>YK,structuredDataDirective:()=>MZ,stripLocalePrefix:()=>LW,stripDocumentWrapper:()=>N4,stringToStream:()=>Jb,strictCspPreset:()=>k_,streamingSuspenseDirective:()=>aJ,streamToResponse:()=>Lz,streamTemplateSimple:()=>qz,streamTemplate:()=>Uz,stopHmrServer:()=>Q5,stopBroadcasting:()=>oO,state:()=>H7,startProductionServer:()=>lL,startInteractive:()=>fL,startBroadcasting:()=>sO,staggerDirective:()=>GU,srcsetUrls:()=>SK,springDirective:()=>KU,splitByPipe:()=>c3,smartBatchSign:()=>xK,signUrl:()=>ZX,shouldTranspileTypeScript:()=>P4,shouldReloadOnChange:()=>l7,shouldRefreshSignature:()=>QX,shouldIgnoreFile:()=>p7,shouldCacheComponent:()=>gq,sharpen:()=>HK,shape:()=>lF,setRouteParams:()=>rS,setMiddlewareState:()=>aS,setGlobalProvide:()=>qX,setErrorLocale:()=>$_,setCurrentInstance:()=>jS,setCachedVideoResult:()=>n$,setCachedImageResult:()=>l$,setCached:()=>d$,serveStxFile:()=>c8,serveMultipleStxFiles:()=>l8,serveMarkdownFile:()=>IY,serveFile:()=>bP,serveApp:()=>p8,serve:()=>eL,serializeState:()=>UV,sepia:()=>LK,scrollAnimateDirective:()=>j3,screenReaderDirective:()=>B3,scopeHTML:()=>NH,scopeCSS:()=>AH,scanForSitemapEntries:()=>lT,scanA11yIssues:()=>gX,saturation:()=>NK,sanitizeParams:()=>PK,sanitizeFilePath:()=>H_,sanitizeExpression:()=>O_,sanitizeDirectiveParams:()=>L_,sanitizeDirectiveParam:()=>e5,sanitizeComponentProps:()=>wJ,safeExecuteAsync:()=>t1,safeExecute:()=>B_,runPreProcessingMiddleware:()=>P9,runPostProcessingMiddleware:()=>y9,runMiddleware:()=>K8,runHooks:()=>c6,runDoctor:()=>OX,rotate:()=>wK,rewriteImagesWithSiblings:()=>rZ,resolveTemplatePath:()=>I7,resolveI18n:()=>f8,resize:()=>UK,resetPlaceholders:()=>aX,resetHead:()=>h_,resetHMRHandler:()=>tP,resetErrorConfig:()=>K_,required:()=>hF,replacePlaceholders:()=>M3,renderView:()=>WW,renderVideoComponent:()=>t$,renderVendorStyleTags:()=>nX,renderToString:()=>a6,renderToStream:()=>_F,renderToDOM:()=>M5,renderThumbhashToCanvas:()=>oK,renderTemplate:()=>xy,renderString:()=>vy,renderStreamingPage:()=>_z,renderSlot:()=>S2,renderSSRSuspense:()=>wq,renderProtectedVideo:()=>uK,renderProtectedImg:()=>dK,renderMediaUpload:()=>yK,renderImgComponent:()=>Q6,renderImageComponent:()=>tQ,renderHtmlAttrs:()=>c_,renderHead:()=>m_,renderEmail:()=>Ny,renderComponentWithSlot:()=>e1,renderBodyAttrs:()=>l_,render:()=>Xy,relaxedCspPreset:()=>S_,registerValidationRule:()=>BM,registerStreamingDirectives:()=>Hz,registerStore:()=>iS,registerSeoDirectives:()=>mT,registerMiddleware:()=>dS,registerFilters:()=>SU,registerFilter:()=>eX,registerErrorMessages:()=>Y_,registerEnhancedValidationRule:()=>jM,registerDirective:()=>Pj,registerCspDirectives:()=>aR,registerComponentDirectives:()=>iC,registerAnimationDirectives:()=>jw,registerA11yDirectives:()=>$w,ref:()=>LS,redirect:()=>Bb,readMarkdownFile:()=>O4,readFileCached:()=>EB,reactive:()=>JO,quality:()=>EK,pruneSignatureCache:()=>gK,pruneCache:()=>cj,provide:()=>pV,prop:()=>gF,processVueTemplate:()=>u9,processVirtualListDirectives:()=>iZ,processVirtualGridDirectives:()=>W2,processVideo:()=>OY,processValidateDirective:()=>t_,processTranslateDirective:()=>pJ,processTransitionDirectives:()=>qq,processTransitionAttributes:()=>Oq,processTitleDirective:()=>n_,processTemplateBindings:()=>_J,processTeleportDirectives:()=>Qq,processSuspenseDirectives:()=>Aq,processStructuredData:()=>f9,processStreamDirectives:()=>zz,processStaticDirectives:()=>N2,processStackReplacements:()=>wZ,processStackPushDirectives:()=>NZ,processSlots:()=>C2,processShell:()=>lY,processServerBindings:()=>EZ,processSeoDirective:()=>g9,processSectionDirectives:()=>Oz,processScopedStyles:()=>B7,processReactiveBindings:()=>dU,processProtectedMedia:()=>mK,processPartialHydrationDirectives:()=>j2,processOnceDirective:()=>R7,processMiddleware:()=>b9,processMetaDirectives:()=>v9,processMetaDirective:()=>r_,processMarkdownFileDirectives:()=>D2,processMarkdownDirectives:()=>I2,processLoops:()=>VZ,processKeepAliveDirectives:()=>vq,processJsonDirective:()=>w7,processInfiniteListDirectives:()=>K2,processIncludes:()=>AZ,processImgComponents:()=>HQ,processImageComponents:()=>eQ,processImage:()=>p1,processHeadDirective:()=>i_,processForms:()=>zM,processFormInputDirectives:()=>e3,processExpressions:()=>j1,processEventDirectives:()=>HJ,processErrorDirective:()=>$Z,processDynamicComponents:()=>c9,processDirectives:()=>W0,processDirectiveAttributes:()=>_D,processDeferDirectives:()=>Yq,processCustomDirectives:()=>vJ,processCspDirectives:()=>PJ,processComponentProps:()=>pF,processClientScript:()=>b4,processBasicFormDirectives:()=>O$,processAsyncDirectives:()=>kq,processAnimationDirectives:()=>dX,processA11yDirectives:()=>fX,preloadTranslationsBackground:()=>MM,preloadTranslations:()=>Yz,preloadIslandHandlers:()=>mP,preloadIconCollection:()=>WZ,poolStrings:()=>pO,pluginManager:()=>fQ,performLeave:()=>Bq,performEnter:()=>zq,peek:()=>A7,partialsCache:()=>s4,parseVideoDirectiveOptions:()=>HH,parseUrl:()=>WK,parseThumbhashString:()=>eK,parseSwitchBlock:()=>l3,parseSlots:()=>k2,parseSlotElement:()=>Tj,parseScriptDeclarations:()=>E_,parseSFCComponent:()=>wH,parseProtectedArgs:()=>cK,parseImgComponent:()=>UY,parseImageUrl:()=>u2,parseImageComponent:()=>PY,parseExpressionWithFilters:()=>M_,parseCookies:()=>Ub,parseConditionalBlock:()=>MJ,parseArguments:()=>TJ,parseAnimationShorthand:()=>Bw,optional:()=>dF,optimizeTemplate:()=>iO,optimizeImage:()=>gY,optimizeDirectory:()=>XG,oneOf:()=>mF,onceStore:()=>S9,onUpdated:()=>TS,onUnmounted:()=>IS,onServer:()=>oS,onMounted:()=>RS,onMount:()=>PZ,onHydrated:()=>A2,onErrorCaptured:()=>sV,onDestroy:()=>yZ,onDeactivated:()=>mq,onClient:()=>sS,onBeforeUpdate:()=>MS,onBeforeUnmount:()=>ES,onBeforeMount:()=>wS,onActivated:()=>uq,observeElement:()=>rK,notFound:()=>qb,nextTick:()=>aV,navigateTo:()=>hS,mountInstance:()=>DS,motionDirective:()=>O3,moderateCspPreset:()=>i3,minifyHtml:()=>lO,metaDirective:()=>RZ,mergeParams:()=>eY,mergeCspDirectives:()=>nR,matchRoute:()=>pY,markdownDirectiveHandler:()=>x2,markdownCache:()=>NY,localizePath:()=>E4,loadTranslationLazy:()=>K7,loadTranslation:()=>Jz,loadStxConfig:()=>c0,loadMiddlewareFromDirectory:()=>G8,loadManifest:()=>wG,loadElement:()=>T4,loadChannels:()=>tO,lintStxStrict:()=>DF,lazyLoadAll:()=>iK,lazyLoad:()=>pK,keyframeDirective:()=>QU,jsxs:()=>KF,jsxDEV:()=>WF,jsx:()=>o6,jsonResponse:()=>zb,islandDirective:()=>sJ,isTest:()=>a5,isSpaNavigation:()=>_G,isSignatureValid:()=>XX,isSignal:()=>V7,isSharpAvailable:()=>_5,isServerEnvironment:()=>rC,isServer:()=>_O,isProduction:()=>_$,isNativeLazySupported:()=>GX,isLoading:()=>wM,isLoaded:()=>RM,isJavaScriptScript:()=>Cj,isIntersectionObserverSupported:()=>KX,isImageFile:()=>z5,isImageBackendAvailable:()=>l1,isICUFormat:()=>Kz,isHydrated:()=>F2,isHydrateTrigger:()=>bj,isEdgeEnvironment:()=>nC,isDirectiveKind:()=>SF,isDevelopment:()=>f4,isDerived:()=>F7,isCssOnlyChange:()=>c7,isClient:()=>zO,isAsyncComponent:()=>Cq,invert:()=>VK,invalidateFileCacheByDir:()=>DB,invalidateFileCache:()=>IB,interpolateScriptsInTemplate:()=>bU,interpolateScriptExpressions:()=>ZJ,inlineError:()=>U0,injectThemeBootstrap:()=>v8,injectSeoTags:()=>h9,injectSeo:()=>P8,injectRouterScript:()=>q4,injectHotReload:()=>X4,injectHeatmap:()=>cX,injectCspMetaTag:()=>bJ,injectCrosswindCSS:()=>C0,injectConfigHeadTags:()=>n9,injectCloakStyle:()=>i9,injectAnalytics:()=>qJ,inject:()=>iV,initStoreRegistry:()=>pS,initNetlify:()=>vH,initLoadingIndicator:()=>iP,initLazyLoading:()=>lK,initFile:()=>dG,initBlurUp:()=>WX,initAllBlurUp:()=>ZW,imgDirective:()=>h7,imageDirective:()=>ZG,hydrateTemplateStream:()=>lG,hydrateTemplate:()=>db,hydrateIslands:()=>uP,hydrateIsland:()=>O2,hydrateFragment:()=>ub,hydrateByStrategy:()=>L2,hydrateAll:()=>V2,hydrate:()=>Zy,htmlResponse:()=>CP,heatmapDirective:()=>lX,hashString:()=>YY,hashFilePath:()=>T$,hashFile:()=>e0,hashBuffer:()=>fj,hasVueTemplateSyntax:()=>AB,hasVariables:()=>D9,hasStore:()=>FV,hasPlaceholders:()=>X$,hasNetlifyConfig:()=>o7,hasMiddleware:()=>gS,hasEventDirectives:()=>RR,hasDocumentShell:()=>kZ,hasDirectives:()=>wj,hasDOMSupport:()=>eW,handleImageRequest:()=>Z8,handleError:()=>oV,h:()=>jF,groupVariantsByFormat:()=>d6,grayscale:()=>OK,gitHash:()=>nG,getUnusedDirectives:()=>hO,getTranslationSync:()=>Xz,getTranslationCacheStats:()=>FM,getTranslationAsync:()=>TM,getTranslation:()=>ZZ,getTotalSize:()=>L4,getTimeUntilExpiry:()=>JX,getStoreNames:()=>AV,getStore:()=>GK,getSourceLineInfo:()=>y2,getScreenReaderOnlyStyle:()=>sN,getScopeAttribute:()=>Ak,getRouteParams:()=>UC,getPublicEnvDefine:()=>C1,getPublicEnv:()=>HU,getPositionInfo:()=>Aj,getPlaceholderRegistry:()=>sX,getPlaceholderCacheStats:()=>ZQ,getPageMeta:()=>a3,getNonce:()=>d4,getMimeType:()=>k1,getMiddlewareNames:()=>Q8,getMiddleware:()=>fS,getLoadingState:()=>NM,getLoadingLocales:()=>IM,getImageMetadata:()=>f6,getHydrationRuntime:()=>qV,getHydratedStoreState:()=>nS,getHmrServer:()=>i7,getHead:()=>H$,getHMRHandler:()=>oP,getFormatExtension:()=>p2,getFileMtime:()=>v7,getFallbackVariant:()=>h6,getErrorMessage:()=>VJ,getErrorLocale:()=>Z_,getErrorConfig:()=>s5,getErrorCodeName:()=>v3,getDirectives:()=>JD,getDirective:()=>XD,getCurrentInstance:()=>HS,getCspPreset:()=>iR,getCspHeaderName:()=>y_,getComponentCacheStats:()=>YD,getCachedVideoResult:()=>i$,getCachedSignature:()=>vK,getCachedSignalsRuntime:()=>CB,getCachedRouterScript:()=>bB,getCachedPlaceholder:()=>x7,getCachedImageResult:()=>c$,getCached:()=>h$,getCacheStats:()=>mj,getBroadcastServer:()=>aO,getBestVariant:()=>l2,getAllFilters:()=>$J,generateWidthSrcset:()=>Y6,generateVirtualListCSS:()=>Q2,generateVideoPreview:()=>QW,generateValidationScript:()=>OM,generateUploadRuntime:()=>b8,generateTreeShakenBundle:()=>dO,generateTransitionRuntime:()=>Hq,generateTransitionCSS:()=>jq,generateThumbnails:()=>a$,generateThumbhashPlaceholder:()=>r2,generateTemplatesDocs:()=>qL,generateSuspenseRuntime:()=>Mq,generateSuspenseCSS:()=>Rq,generateStateScript:()=>zV,generateSrcsetData:()=>m2,generateSrcset:()=>GY,generateSrcSet:()=>_6,generateSpriteSheet:()=>jY,generateSpaShell:()=>Iy,generateSourceTags:()=>c2,generateSizesFromBreakpoints:()=>h2,generateSizesAttribute:()=>y$,generateSizes:()=>g6,generateSitemapIndex:()=>cT,generateSitemap:()=>y8,generateSimpleMediaPicker:()=>PV,generateSignatureRuntime:()=>I8,generateSignalsRuntimeDev:()=>C6,generateSignalsRuntime:()=>N7,generateServerDataBridge:()=>h5,generateScopeId:()=>VY,generateSFCWebComponent:()=>RH,generateRouteTypes:()=>zC,generateRouteManifest:()=>_C,generateRobotsTxt:()=>HB,generateRobots:()=>x8,generateResponsiveVariants:()=>QY,generateReactiveWebComponentTS:()=>Rk,generateReactiveWebComponent:()=>wk,generateReactiveRuntime:()=>Tk,generateReactiveMixin:()=>Mk,generatePoster:()=>r$,generatePlaceholderStyle:()=>e2,generatePlaceholderCSS:()=>y7,generatePlaceholder:()=>P7,generatePartialHydrationCSS:()=>H2,generateNonce:()=>SJ,generateNetlifyToml:()=>kY,generateMinifiedMediaRuntime:()=>hV,generateMediaRuntime:()=>KW,generateMediaManagerEmbed:()=>bV,generateManifest:()=>AG,generateLoadingIndicatorHtml:()=>rP,generateLazyLoadRuntime:()=>D8,generateLQIP:()=>s2,generateKeepAliveRuntime:()=>dq,generateKeepAliveCSS:()=>hq,generateIslandManifest:()=>w2,generateImagePreview:()=>JW,generateImageManifest:()=>hY,generateHydrationScript:()=>$y,generateHydrationRuntime:()=>Vz,generateHydrationCSS:()=>Yy,generateHydrationBootstrap:()=>_2,generateHotReloadScript:()=>yH,generateHeatmapScript:()=>mX,generateHMRClientScript:()=>aP,generateHLSManifest:()=>s$,generateEventBindings:()=>eP,generateDprSrcsetWithVariableQuality:()=>g2,generateDprSrcset:()=>P$,generateDocumentShell:()=>MB,generateDocs:()=>VL,generateDirectivesDocs:()=>jL,generateDirectiveRuntime:()=>UD,generateDefaultRobotsTxt:()=>pT,generateDASHManifest:()=>o$,generateCspMetaTag:()=>n3,generateCspHeader:()=>CJ,generateCrosswindCSS:()=>C3,generateCompositionRuntime:()=>YF,generateComponentsDocs:()=>BL,generateComponentManifest:()=>GI,generateComponentDoc:()=>zL,generateColorPlaceholder:()=>t2,generateClientRuntime:()=>CS,generateCacheKey:()=>f$,generateBlurUpRuntime:()=>S8,generateBlurUpCSS:()=>C8,generateBindingsRuntime:()=>uU,generateAutoWidthSrcset:()=>f2,generateAsyncComponentRuntime:()=>Pq,generateAsyncComponentCSS:()=>bq,generateAnimationRuntime:()=>qw,generateAnimationCSS:()=>zw,generateAnalyticsScript:()=>BJ,formatTypeErrors:()=>dP,formatStxContent:()=>sY,formatSize:()=>U6,formatRoutes:()=>BG,formatMarkdownContent:()=>fG,formatLocalizedError:()=>J_,formatICU:()=>Qz,formatFilePath:()=>o5,formatError:()=>h3,formatDoctorReport:()=>LX,formatDocsAsMarkdown:()=>HL,formatDocsAsJson:()=>LL,formatDocsAsHtml:()=>OL,format:()=>TK,foldConstants:()=>cO,flipVertical:()=>MK,flipHorizontal:()=>RK,fingerprint:()=>qG,findPantryPackage:()=>qW,findMatchingEndTag:()=>h4,findMatchingDelimiter:()=>u0,findIfBlocks:()=>j$,findExpressions:()=>R_,findErrorPage:()=>zG,findDirectiveBlocks:()=>Z7,findDeadCode:()=>uO,findDeadBranches:()=>uO,findComponentFiles:()=>SG,findCommonDir:()=>RW,filterRequiredFiles:()=>a7,fileExists:()=>X0,extractVariables:()=>E0,extractStreamBoundaries:()=>Bz,extractState:()=>BV,extractSlotContent:()=>Ij,extractScriptFromTemplate:()=>I9,extractPlaceholders:()=>iw,extractParenthesizedExpression:()=>z4,extractLayoutMetadata:()=>z8,extractDominantColor:()=>o2,extractDirectiveParams:()=>T_,extractDirectiveNames:()=>Rj,extractContainerContent:()=>_8,extractComponentProps:()=>UL,extractComponentName:()=>z2,extractComponentDescription:()=>_L,extractClassNames:()=>S3,extractBridgeData:()=>C4,extractBoundProps:()=>B2,extractBalancedExpression:()=>RJ,extractAndStripCssImports:()=>iX,extractAndScopeStyles:()=>Nk,extractAndProcessEvents:()=>nU,evaluateExpression:()=>X1,evaluateConstant:()=>rY,evaluateAuthExpression:()=>_4,escapeHtml:()=>P0,errorRecovery:()=>d3,errorLogger:()=>J1,ensureTeleportTargets:()=>Gq,ensureDocumentShell:()=>q7,enhancedValidationRules:()=>hJ,eliminateDeadCode:()=>mO,effect:()=>L7,dprUrls:()=>CK,docsCommand:()=>CG,disconnectObserver:()=>aK,devHelpers:()=>q$,detectShell:()=>UG,detectRuntime:()=>L5,detectProjectConfig:()=>K5,detectFormat:()=>i2,detectBuildMode:()=>gC,derived:()=>O7,deploy:()=>xH,defineStxConfig:()=>EH,defineStore:()=>wV,defineSlots:()=>eV,defineSiteConfig:()=>wW,definePropsWithValidation:()=>vF,defineProps:()=>xF,definePlugin:()=>$5,definePageMeta:()=>d_,defineMiddleware:()=>vS,defineExpose:()=>rV,defineEmits:()=>nV,defineDirective:()=>v0,defineCustomElement:()=>OF,defineConfig:()=>hb,defineClientDirective:()=>GD,defineAsyncComponent:()=>Sq,defaultMediaConfig:()=>Fy,defaultImageConfig:()=>$O,defaultI18nConfig:()=>YZ,defaultHeatmapConfig:()=>zU,defaultFormClasses:()=>t3,defaultFilters:()=>J$,defaultCspConfig:()=>tR,defaultConfig:()=>O1,default:()=>kx,decodeThumbhash:()=>a2,cspNonceDirective:()=>P_,cspDirective:()=>b_,crossfadeTransition:()=>$W,crop:()=>_K,createVirtualList:()=>pZ,createVideoDirective:()=>LY,createVercelHandler:()=>Kb,createTypeChecker:()=>oG,createTranslateFilter:()=>iM,createTextEncoderStream:()=>Xb,createStxApp:()=>BW,createStreamingResponse:()=>Yb,createStreamRenderer:()=>jz,createStore:()=>KK,createStorageManager:()=>xS,createServerCookieManager:()=>yS,createScope:()=>XO,createSSRSuspense:()=>Nq,createRouter:()=>w4,createRouteLocation:()=>J8,createRoute:()=>yP,createRef:()=>LS,createReactive:()=>JO,createProvideContext:()=>ZF,createProject:()=>ib,createProductionBuild:()=>gb,createPlaceholder:()=>d5,createOptimizedBuild:()=>dC,createNetlifyHandler:()=>Wb,createNetlifyClient:()=>n7,createMiddlewareContext:()=>X8,createMiddleware:()=>PP,createLazyObserver:()=>nK,createKeepAliveCache:()=>fq,createKVNamespace:()=>NL,createIslandRegistry:()=>q2,createImgDirective:()=>_Y,createImagePlugin:()=>YG,createImageHandler:()=>bY,createImageDirective:()=>vY,createHeatmapAggregator:()=>Lw,createFileManifest:()=>r7,createEnvAccessor:()=>AL,createEnhancedError:()=>z_,createEdgeHandler:()=>H8,createEdgeCache:()=>wL,createDetailedErrorMessage:()=>R0,createDenoHandler:()=>Gb,createDefaultNetlifyConfig:()=>W5,createCspHeaders:()=>oR,createCookie:()=>_b,createComputed:()=>VS,createComponentInstance:()=>OS,createCloudflareHandler:()=>Qb,createClientCookieManager:()=>PS,createBuiltinDirectives:()=>WD,createApp:()=>BW,createAnimationTimeline:()=>_w,cover:()=>qK,convertToCommonJS:()=>qZ,contrast:()=>AK,contain:()=>BK,consoleError:()=>__,configureErrorHandling:()=>G_,config:()=>F1,computed:()=>VS,composeShellWithPage:()=>U8,componentDirective:()=>KL,compileTemplate:()=>LG,collectDeployFiles:()=>G5,clearVideoCache:()=>BY,clearTranslationCache:()=>VM,clearSignatureCache:()=>fK,clearPlaceholderCache:()=>$Q,clearOnceStore:()=>gT,clearNonce:()=>pR,clearMiddleware:()=>Y8,clearImageCache:()=>xY,clearErrorMessages:()=>X_,clearDevCaches:()=>PB,clearCustomFilters:()=>CU,clearComponentCache:()=>Z6,clearCache:()=>u$,cleanupLoadingIndicator:()=>nP,classifyScript:()=>jO,classifyAllScripts:()=>GG,checkTemplateFile:()=>gP,checkTemplate:()=>hP,checkCache:()=>hZ,checkAuthAccess:()=>R5,checkA11y:()=>_3,channel:()=>XL,captureScreenshots:()=>kL,captureScreenshot:()=>xG,cancelPendingLoads:()=>DM,calculateSha1:()=>DY,calculateOptimalWidths:()=>eZ,cacheTemplate:()=>dZ,buildWebComponents:()=>bQ,buildViews:()=>cV,buildUrl:()=>I0,buildSuspenseResolveScript:()=>JZ,buildStaticSite:()=>AW,buildRuntimeAsset:()=>jG,buildRouterAsset:()=>HG,buildLangPickerScript:()=>d8,buildImageUrl:()=>m1,buildForProduction:()=>SO,buildAuthParams:()=>E8,buildApp:()=>bO,buildAlternateLinks:()=>h8,build:()=>fb,broadcastPrivate:()=>ZL,broadcastPresence:()=>YL,broadcast:()=>IG,brightness:()=>FK,blur:()=>jK,batchSignUrls:()=>YX,batch:()=>bZ,autoFixA11yFile:()=>ZU,autoFixA11yDirectory:()=>eN,autoFixA11y:()=>$U,auto:()=>IK,assetTags:()=>CC,arrayOf:()=>cF,applyTranslations:()=>g8,applyTransformations:()=>g7,applySlots:()=>Dj,applyPropDefaults:()=>lC,applyPreset:()=>kK,applyHead:()=>p_,applyFilters:()=>YJ,apiCspPreset:()=>C_,animationGroupDirective:()=>H3,analyzeVideo:()=>d7,analyzeUsage:()=>TG,analyzeTemplate:()=>qO,analyzeProject:()=>QG,analyzeDirectiveUsage:()=>TG,analyticsDirective:()=>LR,addStore:()=>ob,addPage:()=>sb,addNonceToInlineContent:()=>rR,addLayout:()=>tb,addComponent:()=>ab,abortNavigation:()=>bS,a11yDirective:()=>z3,__setSignalsGeneratorsForTest:()=>SB,VideoProcessorCache:()=>p$,TransitionType:()=>YU,TransitionEase:()=>JU,TransitionDirection:()=>XU,Tokenizer:()=>$7,TemplateTypeChecker:()=>sG,TEMPLATE_PRESETS:()=>Mb,StxValidationError:()=>t5,StxSyntaxError:()=>FJ,StxSecurityError:()=>AJ,StxRuntimeError:()=>h1,StxFileError:()=>B$,StxError:()=>g4,Show:()=>zF,SUSPENSE_RESOLVER_RUNTIME:()=>rJ,SPRING_PRESETS:()=>hX,ProductionBuild:()=>oY,Portal:()=>qF,PROJECT_TEMPLATES:()=>pb,PRESETS:()=>$X,MemorySessionStore:()=>OV,MIME_TYPES:()=>C7,MEDIA_DEFAULT_WIDTHS:()=>Y4,MEDIA_DEFAULT_FORMATS:()=>H4,ImageProcessorCache:()=>m$,ImageProcessingError:()=>u6,HydrationRuntime:()=>QK,HotReloadServer:()=>lQ,HeatmapAggregator:()=>pX,Fragment:()=>s6,For:()=>BF,ErrorLogger:()=>u3,ErrorCodes:()=>J0,DeployError:()=>F4,DEFAULT_WIDTHS:()=>E1,DEFAULT_TRANSITION_OPTIONS:()=>s1,DEFAULT_QUALITY:()=>D1,DEFAULT_PLACEHOLDER_OPTIONS:()=>ZY,DEFAULT_FORMATS:()=>I1,DEFAULT_DPR_VALUES:()=>S7,ComponentHMRHandler:()=>XK,COMMON_SIZES:()=>d2,CLOAK_STYLE:()=>qE,BroadcastServer:()=>QL,Broadcast:()=>JL,BLUR_UP_CSS:()=>v$});var kx;var z6=D(()=>{SY();dY();A0();R9();N6();RV();d9();UW();HF();LF();gQ();o1();jW();EF();kF();QO();c4();mY();dJ();Y$();jJ();L3();b$();j5();LJ();MG();OG();vO();nO();aY();P6();WL();i0();yJ();fJ();SY();MW();k7();bG();RL();vG();R1();OJ();o0();gG();V3();iJ();N$();uG();mG();FZ();oZ();x9();Y7();iY();u5();U1();uL();RG();iG();B8();tL();KG();TZ();$V();DZ();VG();pG();p4();YV();xQ();U2();R2();XV();GV();zJ();R6();WV();jV();LV();dY();mV();lV();R$();m9();l9();FF();A0();b2();bF();kx={}});import i8 from"path";var I5;var wX=D(()=>{z6();R1();o0();x4();U1();I5={name:"bun-plugin-stx",async setup($){let Y={...await c0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${i8.relative(i8.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await bQ(Y,X);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await hZ(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await t1(()=>Bun.file(G).text(),"",(H)=>{throw new B$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new B$(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:z}=f1.time("script-extraction",()=>{let H=W,O=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(O)H=O[1].trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let N of V){let w=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=N.match(/<script\b([^>]*)>/i),T=R?R[1]:"";if(/\bserver\b/i.test(T))L=w;else F.push(N)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),B={__filename:G,__dirname:i8.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await t1(()=>E0(U,B,G),void 0,(H)=>{let O=new h1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(J1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await f1.timeAsync("directive-processing",async()=>{return await W0(_,B,G,Y,K)});if(z.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (o0(),l5)),O=H(z.join(`
16100
+ ${W}`)}return{props:G,validation:K}}function fF($,Z){let Y={...$};for(let[X,J]of Object.entries(Z))if(Y[X]===void 0)Y[X]=typeof J==="function"?J():J;return Y}function gF($){return $}function hF($){return{type:$,required:!0}}function dF($,Z){return{type:Z,default:$}}function uF($,Z={}){return{...Z,validator:$}}function mF($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function cF($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function lF($,Z={}){return{...Z,type:Object}}function pF($,Z,Y){if(!Z)return $;let X={};for(let[J,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[J];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=yF(J,K,G,Y);if(W)console.warn(W.message)}X[J]=K}for(let[J,Q]of Object.entries($))if(!(J in X))X[J]=Q;return X}var l6={};e(l6,{writeNetlifyConfig:()=>s7,writeManifest:()=>NG,writeImageManifest:()=>JG,wrapComponentForHMR:()=>sP,withDefaults:()=>fF,webComponentDirectiveHandler:()=>yQ,watermark:()=>DK,watchViews:()=>Ay,watchMultiple:()=>AS,watchEffect:()=>NS,watch:()=>FS,waitForStore:()=>mS,waitForLocale:()=>EM,videoDirective:()=>u7,validators:()=>m3,validated:()=>uF,validateValueEnhanced:()=>e_,validateTemplate:()=>Fj,validateParams:()=>bK,validateFormEnhanced:()=>HM,validateFile:()=>UX,validateFields:()=>qM,validateField:()=>o_,validateDirective:()=>Nj,validateCspDirectives:()=>sR,validateConfig:()=>IH,validateComponentScripts:()=>hC,validateComponentProps:()=>cC,validateClientScript:()=>M7,usesSignalsInScript:()=>M6,userComponentFileExists:()=>T9,useVirtualList:()=>G2,useTitle:()=>u_,useStoreOrThrow:()=>uS,useStore:()=>NV,useSlots:()=>tV,useSeoMeta:()=>X7,useRouteParams:()=>KO,useRouteParamOrThrow:()=>cS,useRouteParam:()=>WO,usePageTitle:()=>u_,useOptimistic:()=>TB,useMiddlewareValue:()=>lS,useMiddlewareState:()=>UO,useLoadingIndicator:()=>QV,useHead:()=>m4,useAttrs:()=>$F,uploadFiles:()=>XW,uploadFile:()=>_X,updateInstance:()=>kS,untrack:()=>xZ,unregisterDirective:()=>QD,unmountInstance:()=>SS,unescapeHtml:()=>I3,transpileTypeScript:()=>y4,translate:()=>VX,transitionDirective:()=>q3,toUsers:()=>$L,toUser:()=>eO,thumbnail:()=>zK,thumbHashToRGBA:()=>k8,thumbHashToDataURL:()=>tK,templateCache:()=>a9,stxClientHelpers:()=>YK,structuredDataDirective:()=>MZ,stripLocalePrefix:()=>LW,stripDocumentWrapper:()=>N4,stringToStream:()=>Jb,strictCspPreset:()=>k_,streamingSuspenseDirective:()=>aJ,streamToResponse:()=>Lz,streamTemplateSimple:()=>qz,streamTemplate:()=>Uz,stopHmrServer:()=>Q5,stopBroadcasting:()=>oO,state:()=>H7,startProductionServer:()=>lL,startInteractive:()=>fL,startBroadcasting:()=>sO,staggerDirective:()=>GU,srcsetUrls:()=>SK,springDirective:()=>KU,splitByPipe:()=>c3,smartBatchSign:()=>xK,signUrl:()=>ZX,shouldTranspileTypeScript:()=>P4,shouldReloadOnChange:()=>l7,shouldRefreshSignature:()=>QX,shouldIgnoreFile:()=>p7,shouldCacheComponent:()=>gq,sharpen:()=>HK,shape:()=>lF,setRouteParams:()=>rS,setMiddlewareState:()=>aS,setGlobalProvide:()=>qX,setErrorLocale:()=>$_,setCurrentInstance:()=>jS,setCachedVideoResult:()=>n$,setCachedImageResult:()=>l$,setCached:()=>d$,serveStxFile:()=>c8,serveMultipleStxFiles:()=>l8,serveMarkdownFile:()=>IY,serveFile:()=>bP,serveApp:()=>p8,serve:()=>eL,serializeState:()=>UV,sepia:()=>LK,scrollAnimateDirective:()=>j3,screenReaderDirective:()=>B3,scopeHTML:()=>NH,scopeCSS:()=>AH,scanForSitemapEntries:()=>lT,scanA11yIssues:()=>gX,saturation:()=>NK,sanitizeParams:()=>PK,sanitizeFilePath:()=>H_,sanitizeExpression:()=>O_,sanitizeDirectiveParams:()=>L_,sanitizeDirectiveParam:()=>e5,sanitizeComponentProps:()=>wJ,safeExecuteAsync:()=>t1,safeExecute:()=>B_,runPreProcessingMiddleware:()=>P9,runPostProcessingMiddleware:()=>y9,runMiddleware:()=>K8,runHooks:()=>c6,runDoctor:()=>OX,rotate:()=>wK,rewriteImagesWithSiblings:()=>rZ,resolveTemplatePath:()=>I7,resolveI18n:()=>f8,resize:()=>UK,resetPlaceholders:()=>aX,resetHead:()=>h_,resetHMRHandler:()=>tP,resetErrorConfig:()=>K_,required:()=>hF,replacePlaceholders:()=>M3,renderView:()=>WW,renderVideoComponent:()=>t$,renderVendorStyleTags:()=>nX,renderToString:()=>a6,renderToStream:()=>_F,renderToDOM:()=>M5,renderThumbhashToCanvas:()=>oK,renderTemplate:()=>xy,renderString:()=>vy,renderStreamingPage:()=>_z,renderSlot:()=>S2,renderSSRSuspense:()=>wq,renderProtectedVideo:()=>uK,renderProtectedImg:()=>dK,renderMediaUpload:()=>yK,renderImgComponent:()=>Q6,renderImageComponent:()=>tQ,renderHtmlAttrs:()=>c_,renderHead:()=>m_,renderEmail:()=>Ny,renderComponentWithSlot:()=>e1,renderBodyAttrs:()=>l_,render:()=>Xy,relaxedCspPreset:()=>S_,registerValidationRule:()=>BM,registerStreamingDirectives:()=>Hz,registerStore:()=>iS,registerSeoDirectives:()=>mT,registerMiddleware:()=>dS,registerFilters:()=>SU,registerFilter:()=>eX,registerErrorMessages:()=>Y_,registerEnhancedValidationRule:()=>jM,registerDirective:()=>Pj,registerCspDirectives:()=>aR,registerComponentDirectives:()=>iC,registerAnimationDirectives:()=>jw,registerA11yDirectives:()=>$w,ref:()=>LS,redirect:()=>Bb,readMarkdownFile:()=>O4,readFileCached:()=>EB,reactive:()=>JO,quality:()=>EK,pruneSignatureCache:()=>gK,pruneCache:()=>cj,provide:()=>pV,prop:()=>gF,processVueTemplate:()=>u9,processVirtualListDirectives:()=>iZ,processVirtualGridDirectives:()=>W2,processVideo:()=>OY,processValidateDirective:()=>t_,processTranslateDirective:()=>pJ,processTransitionDirectives:()=>qq,processTransitionAttributes:()=>Oq,processTitleDirective:()=>n_,processTemplateBindings:()=>_J,processTeleportDirectives:()=>Qq,processSuspenseDirectives:()=>Aq,processStructuredData:()=>f9,processStreamDirectives:()=>zz,processStaticDirectives:()=>N2,processStackReplacements:()=>wZ,processStackPushDirectives:()=>NZ,processSlots:()=>C2,processShell:()=>lY,processServerBindings:()=>EZ,processSeoDirective:()=>g9,processSectionDirectives:()=>Oz,processScopedStyles:()=>B7,processReactiveBindings:()=>dU,processProtectedMedia:()=>mK,processPartialHydrationDirectives:()=>j2,processOnceDirective:()=>R7,processMiddleware:()=>b9,processMetaDirectives:()=>v9,processMetaDirective:()=>r_,processMarkdownFileDirectives:()=>D2,processMarkdownDirectives:()=>I2,processLoops:()=>VZ,processKeepAliveDirectives:()=>vq,processJsonDirective:()=>w7,processInfiniteListDirectives:()=>K2,processIncludes:()=>AZ,processImgComponents:()=>HQ,processImageComponents:()=>eQ,processImage:()=>p1,processHeadDirective:()=>i_,processForms:()=>zM,processFormInputDirectives:()=>e3,processExpressions:()=>j1,processEventDirectives:()=>HJ,processErrorDirective:()=>$Z,processDynamicComponents:()=>c9,processDirectives:()=>W0,processDirectiveAttributes:()=>_D,processDeferDirectives:()=>Yq,processCustomDirectives:()=>vJ,processCspDirectives:()=>PJ,processComponentProps:()=>pF,processClientScript:()=>b4,processBasicFormDirectives:()=>O$,processAsyncDirectives:()=>kq,processAnimationDirectives:()=>dX,processA11yDirectives:()=>fX,preloadTranslationsBackground:()=>MM,preloadTranslations:()=>Yz,preloadIslandHandlers:()=>mP,preloadIconCollection:()=>WZ,poolStrings:()=>pO,pluginManager:()=>fQ,performLeave:()=>Bq,performEnter:()=>zq,peek:()=>A7,partialsCache:()=>s4,parseVideoDirectiveOptions:()=>HH,parseUrl:()=>WK,parseThumbhashString:()=>eK,parseSwitchBlock:()=>l3,parseSlots:()=>k2,parseSlotElement:()=>Tj,parseScriptDeclarations:()=>E_,parseSFCComponent:()=>wH,parseProtectedArgs:()=>cK,parseImgComponent:()=>UY,parseImageUrl:()=>u2,parseImageComponent:()=>PY,parseExpressionWithFilters:()=>M_,parseCookies:()=>Ub,parseConditionalBlock:()=>MJ,parseArguments:()=>TJ,parseAnimationShorthand:()=>Bw,optional:()=>dF,optimizeTemplate:()=>iO,optimizeImage:()=>gY,optimizeDirectory:()=>XG,oneOf:()=>mF,onceStore:()=>S9,onUpdated:()=>TS,onUnmounted:()=>IS,onServer:()=>oS,onMounted:()=>RS,onMount:()=>PZ,onHydrated:()=>A2,onErrorCaptured:()=>sV,onDestroy:()=>yZ,onDeactivated:()=>mq,onClient:()=>sS,onBeforeUpdate:()=>MS,onBeforeUnmount:()=>ES,onBeforeMount:()=>wS,onActivated:()=>uq,observeElement:()=>rK,notFound:()=>qb,nextTick:()=>aV,navigateTo:()=>hS,mountInstance:()=>DS,motionDirective:()=>O3,moderateCspPreset:()=>i3,minifyHtml:()=>lO,metaDirective:()=>RZ,mergeParams:()=>eY,mergeCspDirectives:()=>nR,matchRoute:()=>pY,markdownDirectiveHandler:()=>x2,markdownCache:()=>NY,localizePath:()=>E4,loadTranslationLazy:()=>K7,loadTranslation:()=>Jz,loadStxConfig:()=>c0,loadMiddlewareFromDirectory:()=>G8,loadManifest:()=>wG,loadElement:()=>T4,loadChannels:()=>tO,lintStxStrict:()=>DF,lazyLoadAll:()=>iK,lazyLoad:()=>pK,keyframeDirective:()=>QU,jsxs:()=>KF,jsxDEV:()=>WF,jsx:()=>o6,jsonResponse:()=>zb,islandDirective:()=>sJ,isTest:()=>a5,isSpaNavigation:()=>_G,isSignatureValid:()=>XX,isSignal:()=>V7,isSharpAvailable:()=>_5,isServerEnvironment:()=>rC,isServer:()=>_O,isProduction:()=>_$,isNativeLazySupported:()=>GX,isLoading:()=>wM,isLoaded:()=>RM,isJavaScriptScript:()=>Cj,isIntersectionObserverSupported:()=>KX,isImageFile:()=>z5,isImageBackendAvailable:()=>l1,isICUFormat:()=>Kz,isHydrated:()=>F2,isHydrateTrigger:()=>bj,isEdgeEnvironment:()=>nC,isDirectiveKind:()=>SF,isDevelopment:()=>f4,isDerived:()=>F7,isCssOnlyChange:()=>c7,isClient:()=>zO,isAsyncComponent:()=>Cq,invert:()=>VK,invalidateFileCacheByDir:()=>DB,invalidateFileCache:()=>IB,interpolateScriptsInTemplate:()=>bU,interpolateScriptExpressions:()=>ZJ,inlineError:()=>U0,injectThemeBootstrap:()=>v8,injectSeoTags:()=>h9,injectSeo:()=>P8,injectRouterScript:()=>q4,injectHotReload:()=>X4,injectHeatmap:()=>cX,injectCspMetaTag:()=>bJ,injectCrosswindCSS:()=>C0,injectConfigHeadTags:()=>n9,injectCloakStyle:()=>i9,injectAnalytics:()=>qJ,inject:()=>iV,initStoreRegistry:()=>pS,initNetlify:()=>vH,initLoadingIndicator:()=>iP,initLazyLoading:()=>lK,initFile:()=>dG,initBlurUp:()=>WX,initAllBlurUp:()=>ZW,imgDirective:()=>h7,imageDirective:()=>ZG,hydrateTemplateStream:()=>lG,hydrateTemplate:()=>db,hydrateIslands:()=>uP,hydrateIsland:()=>O2,hydrateFragment:()=>ub,hydrateByStrategy:()=>L2,hydrateAll:()=>V2,hydrate:()=>Zy,htmlResponse:()=>CP,heatmapDirective:()=>lX,hashString:()=>YY,hashFilePath:()=>T$,hashFile:()=>e0,hashBuffer:()=>fj,hasVueTemplateSyntax:()=>AB,hasVariables:()=>D9,hasStore:()=>FV,hasPlaceholders:()=>X$,hasNetlifyConfig:()=>o7,hasMiddleware:()=>gS,hasEventDirectives:()=>RR,hasDocumentShell:()=>kZ,hasDirectives:()=>wj,hasDOMSupport:()=>eW,handleImageRequest:()=>Z8,handleError:()=>oV,h:()=>jF,groupVariantsByFormat:()=>d6,grayscale:()=>OK,gitHash:()=>nG,getUnusedDirectives:()=>hO,getTranslationSync:()=>Xz,getTranslationCacheStats:()=>FM,getTranslationAsync:()=>TM,getTranslation:()=>ZZ,getTotalSize:()=>L4,getTimeUntilExpiry:()=>JX,getStoreNames:()=>AV,getStore:()=>GK,getSourceLineInfo:()=>y2,getScreenReaderOnlyStyle:()=>sN,getScopeAttribute:()=>Ak,getRouteParams:()=>UC,getPublicEnvDefine:()=>C1,getPublicEnv:()=>HU,getPositionInfo:()=>Aj,getPlaceholderRegistry:()=>sX,getPlaceholderCacheStats:()=>ZQ,getPageMeta:()=>a3,getNonce:()=>d4,getMimeType:()=>k1,getMiddlewareNames:()=>Q8,getMiddleware:()=>fS,getLoadingState:()=>NM,getLoadingLocales:()=>IM,getImageMetadata:()=>f6,getHydrationRuntime:()=>qV,getHydratedStoreState:()=>nS,getHmrServer:()=>i7,getHead:()=>H$,getHMRHandler:()=>oP,getFormatExtension:()=>p2,getFileMtime:()=>v7,getFallbackVariant:()=>h6,getErrorMessage:()=>VJ,getErrorLocale:()=>Z_,getErrorConfig:()=>s5,getErrorCodeName:()=>v3,getDirectives:()=>JD,getDirective:()=>XD,getCurrentInstance:()=>HS,getCspPreset:()=>iR,getCspHeaderName:()=>y_,getComponentCacheStats:()=>YD,getCachedVideoResult:()=>i$,getCachedSignature:()=>vK,getCachedSignalsRuntime:()=>CB,getCachedRouterScript:()=>bB,getCachedPlaceholder:()=>x7,getCachedImageResult:()=>c$,getCached:()=>h$,getCacheStats:()=>mj,getBroadcastServer:()=>aO,getBestVariant:()=>l2,getAllFilters:()=>$J,generateWidthSrcset:()=>Y6,generateVirtualListCSS:()=>Q2,generateVideoPreview:()=>QW,generateValidationScript:()=>OM,generateUploadRuntime:()=>b8,generateTreeShakenBundle:()=>dO,generateTransitionRuntime:()=>Hq,generateTransitionCSS:()=>jq,generateThumbnails:()=>a$,generateThumbhashPlaceholder:()=>r2,generateTemplatesDocs:()=>qL,generateSuspenseRuntime:()=>Mq,generateSuspenseCSS:()=>Rq,generateStateScript:()=>zV,generateSrcsetData:()=>m2,generateSrcset:()=>GY,generateSrcSet:()=>_6,generateSpriteSheet:()=>jY,generateSpaShell:()=>Iy,generateSourceTags:()=>c2,generateSizesFromBreakpoints:()=>h2,generateSizesAttribute:()=>y$,generateSizes:()=>g6,generateSitemapIndex:()=>cT,generateSitemap:()=>y8,generateSimpleMediaPicker:()=>PV,generateSignatureRuntime:()=>I8,generateSignalsRuntimeDev:()=>C6,generateSignalsRuntime:()=>N7,generateServerDataBridge:()=>h5,generateScopeId:()=>VY,generateSFCWebComponent:()=>RH,generateRouteTypes:()=>zC,generateRouteManifest:()=>_C,generateRobotsTxt:()=>HB,generateRobots:()=>x8,generateResponsiveVariants:()=>QY,generateReactiveWebComponentTS:()=>Rk,generateReactiveWebComponent:()=>wk,generateReactiveRuntime:()=>Tk,generateReactiveMixin:()=>Mk,generatePoster:()=>r$,generatePlaceholderStyle:()=>e2,generatePlaceholderCSS:()=>y7,generatePlaceholder:()=>P7,generatePartialHydrationCSS:()=>H2,generateNonce:()=>SJ,generateNetlifyToml:()=>kY,generateMinifiedMediaRuntime:()=>hV,generateMediaRuntime:()=>KW,generateMediaManagerEmbed:()=>bV,generateManifest:()=>AG,generateLoadingIndicatorHtml:()=>rP,generateLazyLoadRuntime:()=>D8,generateLQIP:()=>s2,generateKeepAliveRuntime:()=>dq,generateKeepAliveCSS:()=>hq,generateIslandManifest:()=>w2,generateImagePreview:()=>JW,generateImageManifest:()=>hY,generateHydrationScript:()=>$y,generateHydrationRuntime:()=>Vz,generateHydrationCSS:()=>Yy,generateHydrationBootstrap:()=>_2,generateHotReloadScript:()=>yH,generateHeatmapScript:()=>mX,generateHMRClientScript:()=>aP,generateHLSManifest:()=>s$,generateEventBindings:()=>eP,generateDprSrcsetWithVariableQuality:()=>g2,generateDprSrcset:()=>P$,generateDocumentShell:()=>MB,generateDocs:()=>VL,generateDirectivesDocs:()=>jL,generateDirectiveRuntime:()=>UD,generateDefaultRobotsTxt:()=>pT,generateDASHManifest:()=>o$,generateCspMetaTag:()=>n3,generateCspHeader:()=>CJ,generateCrosswindCSS:()=>C3,generateCompositionRuntime:()=>YF,generateComponentsDocs:()=>BL,generateComponentManifest:()=>GI,generateComponentDoc:()=>zL,generateColorPlaceholder:()=>t2,generateClientRuntime:()=>CS,generateCacheKey:()=>f$,generateBlurUpRuntime:()=>S8,generateBlurUpCSS:()=>C8,generateBindingsRuntime:()=>uU,generateAutoWidthSrcset:()=>f2,generateAsyncComponentRuntime:()=>Pq,generateAsyncComponentCSS:()=>bq,generateAnimationRuntime:()=>qw,generateAnimationCSS:()=>zw,generateAnalyticsScript:()=>BJ,formatTypeErrors:()=>dP,formatStxContent:()=>sY,formatSize:()=>U6,formatRoutes:()=>BG,formatMarkdownContent:()=>fG,formatLocalizedError:()=>J_,formatICU:()=>Qz,formatFilePath:()=>o5,formatError:()=>h3,formatDoctorReport:()=>LX,formatDocsAsMarkdown:()=>HL,formatDocsAsJson:()=>LL,formatDocsAsHtml:()=>OL,format:()=>TK,foldConstants:()=>cO,flipVertical:()=>MK,flipHorizontal:()=>RK,fingerprint:()=>qG,findPantryPackage:()=>qW,findMatchingEndTag:()=>h4,findMatchingDelimiter:()=>u0,findIfBlocks:()=>j$,findExpressions:()=>R_,findErrorPage:()=>zG,findDirectiveBlocks:()=>Z7,findDeadCode:()=>uO,findDeadBranches:()=>uO,findComponentFiles:()=>SG,findCommonDir:()=>RW,filterRequiredFiles:()=>a7,fileExists:()=>X0,extractVariables:()=>I0,extractStreamBoundaries:()=>Bz,extractState:()=>BV,extractSlotContent:()=>Ij,extractScriptFromTemplate:()=>I9,extractPlaceholders:()=>iw,extractParenthesizedExpression:()=>z4,extractLayoutMetadata:()=>z8,extractDominantColor:()=>o2,extractDirectiveParams:()=>T_,extractDirectiveNames:()=>Rj,extractContainerContent:()=>_8,extractComponentProps:()=>UL,extractComponentName:()=>z2,extractComponentDescription:()=>_L,extractClassNames:()=>S3,extractBridgeData:()=>C4,extractBoundProps:()=>B2,extractBalancedExpression:()=>RJ,extractAndStripCssImports:()=>iX,extractAndScopeStyles:()=>Nk,extractAndProcessEvents:()=>nU,evaluateExpression:()=>X1,evaluateConstant:()=>rY,evaluateAuthExpression:()=>_4,escapeHtml:()=>P0,errorRecovery:()=>d3,errorLogger:()=>J1,ensureTeleportTargets:()=>Gq,ensureDocumentShell:()=>q7,enhancedValidationRules:()=>hJ,eliminateDeadCode:()=>mO,effect:()=>L7,dprUrls:()=>CK,docsCommand:()=>CG,disconnectObserver:()=>aK,devHelpers:()=>q$,detectShell:()=>UG,detectRuntime:()=>L5,detectProjectConfig:()=>K5,detectFormat:()=>i2,detectBuildMode:()=>gC,derived:()=>O7,deploy:()=>xH,defineStxConfig:()=>EH,defineStore:()=>wV,defineSlots:()=>eV,defineSiteConfig:()=>wW,definePropsWithValidation:()=>vF,defineProps:()=>xF,definePlugin:()=>$5,definePageMeta:()=>d_,defineMiddleware:()=>vS,defineExpose:()=>rV,defineEmits:()=>nV,defineDirective:()=>v0,defineCustomElement:()=>OF,defineConfig:()=>hb,defineClientDirective:()=>GD,defineAsyncComponent:()=>Sq,defaultMediaConfig:()=>Fy,defaultImageConfig:()=>$O,defaultI18nConfig:()=>YZ,defaultHeatmapConfig:()=>zU,defaultFormClasses:()=>t3,defaultFilters:()=>J$,defaultCspConfig:()=>tR,defaultConfig:()=>O1,default:()=>kx,decodeThumbhash:()=>a2,cspNonceDirective:()=>P_,cspDirective:()=>b_,crossfadeTransition:()=>$W,crop:()=>_K,createVirtualList:()=>pZ,createVideoDirective:()=>LY,createVercelHandler:()=>Kb,createTypeChecker:()=>oG,createTranslateFilter:()=>iM,createTextEncoderStream:()=>Xb,createStxApp:()=>BW,createStreamingResponse:()=>Yb,createStreamRenderer:()=>jz,createStore:()=>KK,createStorageManager:()=>xS,createServerCookieManager:()=>yS,createScope:()=>XO,createSSRSuspense:()=>Nq,createRouter:()=>w4,createRouteLocation:()=>J8,createRoute:()=>yP,createRef:()=>LS,createReactive:()=>JO,createProvideContext:()=>ZF,createProject:()=>ib,createProductionBuild:()=>gb,createPlaceholder:()=>d5,createOptimizedBuild:()=>dC,createNetlifyHandler:()=>Wb,createNetlifyClient:()=>n7,createMiddlewareContext:()=>X8,createMiddleware:()=>PP,createLazyObserver:()=>nK,createKeepAliveCache:()=>fq,createKVNamespace:()=>NL,createIslandRegistry:()=>q2,createImgDirective:()=>_Y,createImagePlugin:()=>YG,createImageHandler:()=>bY,createImageDirective:()=>vY,createHeatmapAggregator:()=>Lw,createFileManifest:()=>r7,createEnvAccessor:()=>AL,createEnhancedError:()=>z_,createEdgeHandler:()=>H8,createEdgeCache:()=>wL,createDetailedErrorMessage:()=>M0,createDenoHandler:()=>Gb,createDefaultNetlifyConfig:()=>W5,createCspHeaders:()=>oR,createCookie:()=>_b,createComputed:()=>VS,createComponentInstance:()=>OS,createCloudflareHandler:()=>Qb,createClientCookieManager:()=>PS,createBuiltinDirectives:()=>WD,createApp:()=>BW,createAnimationTimeline:()=>_w,cover:()=>qK,convertToCommonJS:()=>qZ,contrast:()=>AK,contain:()=>BK,consoleError:()=>__,configureErrorHandling:()=>G_,config:()=>F1,computed:()=>VS,composeShellWithPage:()=>U8,componentDirective:()=>KL,compileTemplate:()=>LG,collectDeployFiles:()=>G5,clearVideoCache:()=>BY,clearTranslationCache:()=>VM,clearSignatureCache:()=>fK,clearPlaceholderCache:()=>$Q,clearOnceStore:()=>gT,clearNonce:()=>pR,clearMiddleware:()=>Y8,clearImageCache:()=>xY,clearErrorMessages:()=>X_,clearDevCaches:()=>PB,clearCustomFilters:()=>CU,clearComponentCache:()=>Z6,clearCache:()=>u$,cleanupLoadingIndicator:()=>nP,classifyScript:()=>jO,classifyAllScripts:()=>GG,checkTemplateFile:()=>gP,checkTemplate:()=>hP,checkCache:()=>hZ,checkAuthAccess:()=>R5,checkA11y:()=>_3,channel:()=>XL,captureScreenshots:()=>kL,captureScreenshot:()=>xG,cancelPendingLoads:()=>DM,calculateSha1:()=>DY,calculateOptimalWidths:()=>eZ,cacheTemplate:()=>dZ,buildWebComponents:()=>bQ,buildViews:()=>cV,buildUrl:()=>D0,buildSuspenseResolveScript:()=>JZ,buildStaticSite:()=>AW,buildRuntimeAsset:()=>jG,buildRouterAsset:()=>HG,buildLangPickerScript:()=>d8,buildImageUrl:()=>m1,buildForProduction:()=>SO,buildAuthParams:()=>E8,buildApp:()=>bO,buildAlternateLinks:()=>h8,build:()=>fb,broadcastPrivate:()=>ZL,broadcastPresence:()=>YL,broadcast:()=>IG,brightness:()=>FK,blur:()=>jK,batchSignUrls:()=>YX,batch:()=>bZ,autoFixA11yFile:()=>ZU,autoFixA11yDirectory:()=>eN,autoFixA11y:()=>$U,auto:()=>IK,assetTags:()=>CC,arrayOf:()=>cF,applyTranslations:()=>g8,applyTransformations:()=>g7,applySlots:()=>Dj,applyPropDefaults:()=>lC,applyPreset:()=>kK,applyHead:()=>p_,applyFilters:()=>YJ,apiCspPreset:()=>C_,animationGroupDirective:()=>H3,analyzeVideo:()=>d7,analyzeUsage:()=>TG,analyzeTemplate:()=>qO,analyzeProject:()=>QG,analyzeDirectiveUsage:()=>TG,analyticsDirective:()=>LR,addStore:()=>ob,addPage:()=>sb,addNonceToInlineContent:()=>rR,addLayout:()=>tb,addComponent:()=>ab,abortNavigation:()=>bS,a11yDirective:()=>z3,__setSignalsGeneratorsForTest:()=>SB,VideoProcessorCache:()=>p$,TransitionType:()=>YU,TransitionEase:()=>JU,TransitionDirection:()=>XU,Tokenizer:()=>$7,TemplateTypeChecker:()=>sG,TEMPLATE_PRESETS:()=>Mb,StxValidationError:()=>t5,StxSyntaxError:()=>FJ,StxSecurityError:()=>AJ,StxRuntimeError:()=>h1,StxFileError:()=>B$,StxError:()=>g4,Show:()=>zF,SUSPENSE_RESOLVER_RUNTIME:()=>rJ,SPRING_PRESETS:()=>hX,ProductionBuild:()=>oY,Portal:()=>qF,PROJECT_TEMPLATES:()=>pb,PRESETS:()=>$X,MemorySessionStore:()=>OV,MIME_TYPES:()=>C7,MEDIA_DEFAULT_WIDTHS:()=>Y4,MEDIA_DEFAULT_FORMATS:()=>H4,ImageProcessorCache:()=>m$,ImageProcessingError:()=>u6,HydrationRuntime:()=>QK,HotReloadServer:()=>lQ,HeatmapAggregator:()=>pX,Fragment:()=>s6,For:()=>BF,ErrorLogger:()=>u3,ErrorCodes:()=>J0,DeployError:()=>F4,DEFAULT_WIDTHS:()=>E1,DEFAULT_TRANSITION_OPTIONS:()=>s1,DEFAULT_QUALITY:()=>D1,DEFAULT_PLACEHOLDER_OPTIONS:()=>ZY,DEFAULT_FORMATS:()=>I1,DEFAULT_DPR_VALUES:()=>S7,ComponentHMRHandler:()=>XK,COMMON_SIZES:()=>d2,CLOAK_STYLE:()=>qE,BroadcastServer:()=>QL,Broadcast:()=>JL,BLUR_UP_CSS:()=>v$});var kx;var z6=D(()=>{SY();dY();N0();R9();N6();RV();d9();UW();HF();LF();gQ();o1();jW();EF();kF();QO();c4();mY();dJ();Y$();jJ();L3();b$();j5();LJ();MG();OG();vO();nO();aY();P6();WL();i0();yJ();fJ();SY();MW();k7();bG();RL();vG();R1();OJ();o0();gG();V3();iJ();N$();uG();mG();FZ();oZ();x9();Y7();iY();u5();U1();uL();RG();iG();B8();tL();KG();TZ();$V();DZ();VG();pG();p4();YV();xQ();U2();R2();XV();GV();zJ();R6();WV();jV();LV();dY();mV();lV();R$();m9();l9();FF();N0();b2();bF();kx={}});import i8 from"path";var I5;var wX=D(()=>{z6();R1();o0();x4();U1();I5={name:"bun-plugin-stx",async setup($){let Y={...await c0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${i8.relative(i8.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await bQ(Y,X);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await hZ(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await t1(()=>Bun.file(G).text(),"",(H)=>{throw new B$(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new B$(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:z}=f1.time("script-extraction",()=>{let H=W,O=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(O)H=O[1].trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let N of V){let w=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=N.match(/<script\b([^>]*)>/i),T=R?R[1]:"";if(/\bserver\b/i.test(T))L=w;else F.push(N)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),B={__filename:G,__dirname:i8.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await t1(()=>I0(U,B,G),void 0,(H)=>{let O=new h1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(J1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await f1.timeAsync("directive-processing",async()=>{return await W0(_,B,G,Y,K)});if(z.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (o0(),l5)),O=H(z.join(`
16101
16101
  `),B),V=j.search(/<\/body>/i);if(V!==-1)j=j.slice(0,V)+O+`
16102
16102
  `+j.slice(V);else j+=`
16103
16103
  ${O}`}if(j=await q4(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await dZ(G,j,K,Y),Y.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:j,loader:"html"}}catch(K){let W=K instanceof Error?K:new h1(`Plugin processing failed: ${String(K)}`,G);if(J1.log(W,{filePath:G,buildConfig:$.config}),q$.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),Y.debug)console.error("stx Plugin Error:",W);let U=W,_=U.line||null,z=U.context||null;return{contents:Y.debug||f4()?`<!DOCTYPE html>
@@ -16165,7 +16165,7 @@ ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
16165
16165
  ${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
16166
16166
  ${M.bright}\u2192 ${M.cyan}http://localhost:${q}/${M.reset}`),console.log(`
16167
16167
  ${M.yellow}Routes:${M.reset}`);let V=q1.relative(process.cwd(),K);if(console.log(` ${M.green}\u2514\u2500 /${M.reset} \u2192 ${M.bright}${V}${M.reset}`),console.log(`
16168
- Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),W6(O.url.toString(),()=>{if(X)r1.watch(q1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),F=EY(L);await Y5(q,{title:q1.basename(K,".stx"),titlebarHidden:Z.titlebarHidden===!0,nativeSidebar:!!F,sidebarConfig:F})}if(X){let L=q1.dirname(K);console.log(`${M.blue}Watching ${M.bright}${L}${M.reset} for changes...`);let F=r1.watch(L,{recursive:!0},async(A,N)=>{if(!N||p7(N))return;if(l7(N)){console.log(`${M.yellow}File ${M.bright}${N}${M.yellow} changed, rebuilding...${M.reset}`),s4.clear(),Z6();let w=await _();if(await r5(B),J&&Q)if(w)Q.reload(N);else Q.error("Build failed - check console for details")}else if(c7(N)){if(console.log(`${M.cyan}CSS ${M.bright}${N}${M.cyan} changed${M.reset}`),J&&Q)Q.updateCss(N)}});process.on("SIGINT",()=>{if(F.close(),Q)Q5();O.stop(),process.exit(0)})}return!0}var iF=D(()=>{N$();wX();A0();m7();cQ()});var{serve:Cx}=globalThis.Bun;import L6 from"fs";import G1 from"path";function RW($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split(G1.sep)),Y=[];for(let X=0;X<Z[0].length;X++){let J=Z[0][X];if(Z.every((Q)=>Q[X]===J))Y.push(J);else break}return Y.join(G1.sep)}async function l8($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=G1.resolve(j);if(!L6.existsSync(H))return console.error(`${M.red}Error: File not found: ${M.bright}${H}${M.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${M.red}Error: Unsupported file type: ${M.bright}${H}${M.reset}. Only .stx and .md files are supported.`),!1}let J=G1.join(process.cwd(),".stx/output");L6.mkdirSync(J,{recursive:!0});let Q=RW($.map((j)=>G1.dirname(G1.resolve(j))));console.log(`${M.blue}Processing ${M.bright}${$.length}${M.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=G1.resolve(j);if(H.endsWith(".md"))try{let{content:V,data:L}=await O4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:F1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),F=Z.markdown?.syntaxHighlighting||F1.markdown?.syntaxHighlighting,A=F?.defaultTheme||"github-dark",N=["github-dark"],w=F?.additionalThemes||[],T=[...new Set([...N,...w])].map((S)=>`<option value="${S}"${S===A?" selected":""}>${S}</option>`).join(`
16168
+ Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),W6(O.url.toString(),()=>{if(X)r1.watch(q1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),F=EY(L);await Y5(q,{title:q1.basename(K,".stx"),titlebarHidden:Z.titlebarHidden===!0,nativeSidebar:!!F,sidebarConfig:F})}if(X){let L=q1.dirname(K);console.log(`${M.blue}Watching ${M.bright}${L}${M.reset} for changes...`);let F=r1.watch(L,{recursive:!0},async(A,N)=>{if(!N||p7(N))return;if(l7(N)){console.log(`${M.yellow}File ${M.bright}${N}${M.yellow} changed, rebuilding...${M.reset}`),s4.clear(),Z6();let w=await _();if(await r5(B),J&&Q)if(w)Q.reload(N);else Q.error("Build failed - check console for details")}else if(c7(N)){if(console.log(`${M.cyan}CSS ${M.bright}${N}${M.cyan} changed${M.reset}`),J&&Q)Q.updateCss(N)}});process.on("SIGINT",()=>{if(F.close(),Q)Q5();O.stop(),process.exit(0)})}return!0}var iF=D(()=>{N$();wX();N0();m7();cQ()});var{serve:Cx}=globalThis.Bun;import L6 from"fs";import G1 from"path";function RW($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split(G1.sep)),Y=[];for(let X=0;X<Z[0].length;X++){let J=Z[0][X];if(Z.every((Q)=>Q[X]===J))Y.push(J);else break}return Y.join(G1.sep)}async function l8($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=G1.resolve(j);if(!L6.existsSync(H))return console.error(`${M.red}Error: File not found: ${M.bright}${H}${M.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${M.red}Error: Unsupported file type: ${M.bright}${H}${M.reset}. Only .stx and .md files are supported.`),!1}let J=G1.join(process.cwd(),".stx/output");L6.mkdirSync(J,{recursive:!0});let Q=RW($.map((j)=>G1.dirname(G1.resolve(j))));console.log(`${M.blue}Processing ${M.bright}${$.length}${M.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=G1.resolve(j);if(H.endsWith(".md"))try{let{content:V,data:L}=await O4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:F1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),F=Z.markdown?.syntaxHighlighting||F1.markdown?.syntaxHighlighting,A=F?.defaultTheme||"github-dark",N=["github-dark"],w=F?.additionalThemes||[],T=[...new Set([...N,...w])].map((S)=>`<option value="${S}"${S===A?" selected":""}>${S}</option>`).join(`
16169
16169
  `),E=`
16170
16170
  <!DOCTYPE html>
16171
16171
  <html lang="en">
@@ -16335,12 +16335,12 @@ ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),con
16335
16335
  ${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
16336
16336
  ${M.bright}\u2192 ${M.cyan}http://localhost:${_}/${M.reset}`),console.log(`
16337
16337
  ${M.yellow}Routes:${M.reset}`);let B=new Set(K.map((j)=>j.routeTemplate)),q=Object.entries(G).filter(([j])=>!B.has(j)).sort(([j],[H])=>j.localeCompare(H)).map(([j,H])=>({route:j==="/"?"/":j,filePath:G1.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let j of K){let H=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");q.push({route:H,filePath:G1.relative(process.cwd(),j.filePath),fileType:"stx"})}if(q.sort((j,H)=>j.route.localeCompare(H.route)),q.forEach((j,H)=>{let V=H===q.length-1?"\u2514\u2500 ":"\u251C\u2500 ",L=j.fileType==="md"?`${M.magenta}(markdown)${M.reset}`:"";console.log(` ${M.green}${V}${j.route}${M.reset} \u2192 ${M.bright}${j.filePath}${M.reset} ${L}`)}),console.log(`
16338
- Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),W6(z.url.toString(),()=>{if(X)L6.watch(Q,{recursive:!0}).close();z.stop()}),X){console.log(`${M.blue}Watching for changes...${M.reset}`);let j=L6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${M.yellow}File ${M.bright}${O}${M.yellow} changed, rebuilding...${M.reset}`),s4.clear(),Z6(),await W()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}var nF=D(()=>{b$();i0();N$();wX();A0();m7()});var{serve:bx}=globalThis.Bun;import N1 from"fs";import V0 from"path";function TW($){let Z=Bun.file($),Y=V0.extname($).toLowerCase(),X={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function p8($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=V0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (z6(),l6)),U=await W(K),_=U.root&&U.root!=="."?V0.join(K,U.root):K,z=U.pagesDir||"pages",B=V0.join(_,z);if(!N1.existsSync(B))return console.error(`${M.red}Error: No '${z}' directory found in ${M.bright}${_}${M.reset}`),console.log(`${M.dim}Create a ${z}/ directory with .stx files to define your routes.${M.reset}`),console.log(`${M.dim}Example: ${z}/index.stx for the homepage.${M.reset}`),!1;let q=w4(_);if(q.length===0)return console.error(`${M.red}Error: No page files found in ${M.bright}${B}${M.reset}`),!1;console.log(`${M.blue}Found ${M.bright}${q.length}${M.blue} routes${M.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:b,prefix:d}of j)if(N1.existsSync(b)){let l=w4(V0.dirname(b),{pagesDir:V0.basename(b)});for(let r of l){let a=d==="/"?r.pattern:`${d}${r.pattern==="/"?"":r.pattern}`;H.push({route:{...r,pattern:a},prefix:d})}if(l.length>0)console.log(`${M.blue}Plugin pages: ${M.bright}${l.length}${M.blue} routes at ${M.cyan}${d}${M.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await UG(K,Z.stxOptions?.shell),L){if(V=await lY(L,Z.stxOptions||{}),V)console.log(`${M.blue}Using app shell: ${M.bright}${V0.relative(K,L)}${M.reset} ${M.dim}(deprecated: use layouts/default.stx instead)${M.reset}`)}}Y8(),await G8(K);let F=Q8();if(F.length>0)console.log(`${M.blue}Loaded ${M.bright}${F.length}${M.blue} middleware: ${M.dim}${F.join(", ")}${M.reset}`);let A={},N=null;try{let{loadStxConfig:b}=await Promise.resolve().then(() => (z6(),l6)),d=await b(K);if(d?.apiRouter)N=d?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(d?.apiRoutes){A=d.apiRoutes;let l=Object.keys(A).length;if(l>0)console.log(`${M.blue}Loaded ${M.bright}${l} API route${l>1?"s":""}${M.reset}`)}if(d?.broadcasting?.enabled)try{let{startBroadcasting:l,loadChannels:r}=await Promise.resolve().then(() => (aY(),DG)),a=d.broadcasting;await l(a);let B0=a.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${B0}/ws${M.reset}`);let Q0=V0.join(process.cwd(),"channels.ts");if(N1.existsSync(Q0))try{let M0=await r(Q0);console.log(`${M.blue}Loaded ${M.bright}${M0} broadcast channel${M0!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(M0){console.warn(`${M.yellow}Failed to load channels.ts: ${M0.message}${M.reset}`)}}catch(l){console.warn(`${M.yellow}Broadcasting failed to start: ${l.message}${M.reset}`)}}catch{}let w=V0.join(K,".stx/output");N1.mkdirSync(w,{recursive:!0});let R=new Map,T=new Set,E=async(b)=>{let d=zG(B,b);if(!d)return null;try{let l=await Bun.build({entrypoints:[d],outdir:w,plugins:[I5],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!l.success)return null;let r=l.outputs.find((a)=>a.path.endsWith(".html"));if(!r)return null;return await Bun.file(r.path).text()}catch{return null}},I=async(b,d)=>{try{let{processDirectives:l,extractVariables:r,defaultConfig:a,loadStxConfig:B0,injectRouterScript:Q0}=await Promise.resolve().then(() => (z6(),l6)),{checkCache:M0,cacheTemplate:k0,readFileCached:y,templateCache:u}=await Promise.resolve().then(() => (P6(),E$)),c=await B0(K),h=(T0)=>{if(!T0)return T0;if(V0.isAbsolute(T0))return T0;return V0.resolve(K,T0)},p={...a,...c,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)p.debug=!0;p.partialsDir=h(p.partialsDir),p.componentsDir=h(p.componentsDir),p.layoutsDir=h(p.layoutsDir),p.storesDir=h(p.storesDir||"stores"),p.cachePath=h(p.cachePath||".stx/cache");let t=!d&&!Z.profile,n=p.cache!==!1;if(n&&t){let T0=u.get(b.filePath);if(T0)try{if((await N1.promises.stat(b.filePath)).mtime.getTime()<=T0.mtime){let k4=!0;for(let W1 of T0.dependencies){if(!N1.existsSync(W1)){k4=!1;break}if((await N1.promises.stat(W1)).mtime.getTime()>T0.mtime){k4=!1;break}}if(k4){let W1=T0.output;if(V)W1=N4(W1,{preserveHead:!0});return{route:b,content:W1}}}}catch{}let K1=await M0(b.filePath,p);if(K1){let v1=K1;if(V)v1=N4(v1,{preserveHead:!0});return{route:b,content:v1}}}let _0=n?await y(b.filePath):await Bun.file(b.filePath).text(),{classifyAllScripts:S0}=await Promise.resolve().then(() => (z6(),l6)),D0=S0(_0),q0=D0.server.map((T0)=>T0.content),Y1=_0;for(let T0 of D0.server)Y1=Y1.replace(T0.fullTag,"");let s0={__filename:b.filePath,__dirname:V0.dirname(b.filePath),params:d??{}},{resetHead:Z$}=await Promise.resolve().then(() => (c4(),s3));Z$();for(let T0 of q0)try{await r(T0,s0,b.filePath)}catch(K1){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",b.filePath,K1?.message||K1)}let z0=new Set,x0;if(Z.profile){let T0=performance.now();x0=await l(Y1,s0,b.filePath,p,z0);let K1=performance.now()-T0,v1=V0.relative(K,b.filePath)||b.filePath;console.log(`[stx:profile] ${v1} \u2192 ${K1.toFixed(2)}ms`)}else x0=await l(Y1,s0,b.filePath,p,z0);if(!V)x0=await Q0(x0);{let{interpolateScriptExpressions:T0}=await Promise.resolve().then(() => (o0(),l5));x0=x0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(K1,v1,k4)=>{if(!/function\s+__stx_setup_/.test(k4))return K1;return`<script${v1}>${T0(k4,s0)}</script>`})}if(V)x0=N4(x0,{preserveHead:!0});if(n&&t)await k0(b.filePath,x0,z0,p);let{extractStreamBoundaries:v5}=await Promise.resolve().then(() => (p4(),D6)),x1=v5(s0),D4=s0.__streamTemplates;if(D4&&typeof D4==="object"&&Object.keys(D4).length>0){let T0=s0.streamBoundaries||{},K1={...p,autoShell:!1},v1=Object.keys(D4).map((W1)=>({id:W1,render:async()=>{let tW=typeof T0[W1]==="function"?await T0[W1]():void 0;return l(D4[W1],{...s0,$boundary:tW},b.filePath,K1,new Set)}})),k4=new Set(v1.map((W1)=>W1.id));x1=[...(x1||[]).filter((W1)=>!k4.has(W1.id)),...v1]}if(x1&&x1.length>0)T.add(b.pattern);else x1=void 0;return{route:b,content:x0,boundaries:x1}}catch(l){return console.error(`${M.red}Error building ${M.bright}${b.pattern}${M.reset}:`,l),null}},k=8,S=async()=>{R.clear(),O.clear();for(let b=0;b<q.length;b+=k){let d=q.slice(b,b+k),l=await Promise.all(d.map((r)=>I(r)));for(let r of l)if(r)R.set(r.route.pattern,r)}for(let b=0;b<H.length;b+=k){let d=H.slice(b,b+k),l=await Promise.all(d.map(({route:r})=>I(r)));for(let r of l)if(r)O.set(r.route.pattern,r)}return R.size>0};if(console.log(`${M.blue}Building pages...${M.reset}`),!await S())return console.error(`${M.red}No pages were successfully built${M.reset}`),!1;await U$(K);let P=Y;try{if(P=await K6(Y),P!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${P} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let b=Z.hmrPort||P+1;Q=i7({wsPort:b,verbose:!1}),G=Q.start(b)}let C=(b,d)=>{let l=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(d)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(b.includes("</head>"))return b.replace("</head>",`${l}</head>`);if(b.includes("<body"))return b.replace(/<body([^>]*)>/,`<body$1>${l}`);return l+b};console.log(`${M.blue}Starting server...${M.reset}`);let g=bx({port:P,async fetch(b){let d=new URL(b.url),l=U?.publicDir||"public",r=V0.join(K,l,d.pathname),a=V0.join(K,d.pathname),B0=V0.join(w,d.pathname),[Q0,M0,k0]=await Promise.all([N1.promises.stat(r).catch(()=>null),N1.promises.stat(a).catch(()=>null),N1.promises.stat(B0).catch(()=>null)]);if(Q0?.isFile())return TW(r);if(M0?.isFile())return TW(a);if(k0?.isFile())return TW(B0);if(d.pathname.startsWith("/_stx/component/")){let h=decodeURIComponent(d.pathname.slice(16));if(h)try{let p=`<${h} />`,t={...buildConfig,autoShell:!1},n=await processDirectives(p,{},V0.join(K,"components",`${h}.stx`),t,new Set);return new Response(n,{headers:{"Content-Type":"text/html"}})}catch(p){return new Response(`<div class="stx-async-error">${p.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(d.pathname==="/_stx/img"){let{handleImageRequest:h}=await Promise.resolve().then(() => (oQ(),nH)),p=await h(b,{publicDir:V0.join(K,l),cacheDir:V0.join(K,".stx/cache/img")});if(p)return p}if(N)try{let h=await N.handleRequest(b);if(h.status!==404)return h}catch{}if(A[d.pathname])try{return await A[d.pathname](b)}catch(h){return new Response(JSON.stringify({error:h.message}),{status:500,headers:{"Content-Type":"application/json"}})}let y=pY(d.pathname,q);if(y){let h=R.get(y.route.pattern),p=T.has(y.route.pattern);if(y.route.isDynamic&&Object.keys(y.params).length>0||p){let t=await I(y.route,y.params);if(t)h=t}if(h){let t=a3();if(t.validate){if(!await t.validate({params:y.params})){let S0=await E(404);if(S0){let D0=S0;if(D0=await C0(D0,K),J)D0=X4(D0,G);return new Response(D0,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(t.middleware){let _0=J8(d.pathname,y.params,t,d.search),S0=X8(_0,null,b),D0=await K8(t.middleware,S0);if(D0.redirect){let q0=D0.redirect.path,Y1=D0.redirect.options.redirectCode||302,s0=new Headers(D0.responseHeaders);return s0.set("Location",q0),new Response(null,{status:Y1,headers:s0})}if(D0.abort){let{statusCode:q0,message:Y1}=D0.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${q0}</title></head><body><h1>Error ${q0}</h1><p>${Y1}</p></body></html>`,{status:q0,headers:{"Content-Type":"text/html"}})}if(Object.keys(D0.state).length>0){let q0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(D0.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;h.content=h.content.replace("</head>",`${q0}</head>`)}}let n=h.content;if(V&&_G(b)){let _0=z8(n);if(Object.keys(y.params).length>0)n=C(n,y.params);n=await C0(n,K);let S0=U?.router?.container||"main";return n=_8(n,S0),new Response(n,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":_0.layout,"X-STX-Layout-Group":_0.group,"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)n=U8(V,n);if(Object.keys(y.params).length>0)n=C(n,y.params);if(n=await C0(n,K),J)n=X4(n,G);if(Z.native)if(n.includes("<head>"))n=n.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else n="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+n;if(Z.titlebarHidden)if(n.includes("<head>"))n=n.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else n=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${n}`;if(h.boundaries&&h.boundaries.length>0){let{renderStreamingPage:_0,streamToResponse:S0}=await Promise.resolve().then(() => (p4(),D6));return S0(_0(n,h.boundaries,{timeoutMs:30000}),{headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(n,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let h=H.map((t)=>t.route),p=pY(d.pathname,h);if(p){let t=O.get(p.route.pattern);if(t){let n=t.content;if(V)n=U8(V,n);if(Object.keys(p.params).length>0)n=C(n,p.params);if(n=await C0(n,K),J)n=X4(n,G);return new Response(n,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:t}of j)if(t!=="/"&&d.pathname.startsWith(t)){let n=O.get(t)||O.get(t+"/");if(n){let _0=n.content;if(V)_0=U8(V,_0);if(_0=await C0(_0,K),J)_0=X4(_0,G);return new Response(_0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let u=R.get("/");if(u){let h=u.content;if(h=await C0(h,K),J)h=X4(h,G);if(Z.native)if(h.includes("<head>"))h=h.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else h="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+h;return new Response(h,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let c=await E(404);if(c){let h=c;if(h=await C0(h,K),J)h=X4(h,G);return new Response(h,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(b){let d=await E(500);if(d)return new Response(d,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${b}
16338
+ Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),W6(z.url.toString(),()=>{if(X)L6.watch(Q,{recursive:!0}).close();z.stop()}),X){console.log(`${M.blue}Watching for changes...${M.reset}`);let j=L6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${M.yellow}File ${M.bright}${O}${M.yellow} changed, rebuilding...${M.reset}`),s4.clear(),Z6(),await W()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}var nF=D(()=>{b$();i0();N$();wX();N0();m7()});var{serve:bx}=globalThis.Bun;import N1 from"fs";import V0 from"path";function TW($){let Z=Bun.file($),Y=V0.extname($).toLowerCase(),X={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function p8($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=V0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (z6(),l6)),U=await W(K),_=U.root&&U.root!=="."?V0.join(K,U.root):K,z=U.pagesDir||"pages",B=V0.join(_,z);if(!N1.existsSync(B))return console.error(`${M.red}Error: No '${z}' directory found in ${M.bright}${_}${M.reset}`),console.log(`${M.dim}Create a ${z}/ directory with .stx files to define your routes.${M.reset}`),console.log(`${M.dim}Example: ${z}/index.stx for the homepage.${M.reset}`),!1;let q=w4(_);if(q.length===0)return console.error(`${M.red}Error: No page files found in ${M.bright}${B}${M.reset}`),!1;console.log(`${M.blue}Found ${M.bright}${q.length}${M.blue} routes${M.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:b,prefix:d}of j)if(N1.existsSync(b)){let l=w4(V0.dirname(b),{pagesDir:V0.basename(b)});for(let r of l){let a=d==="/"?r.pattern:`${d}${r.pattern==="/"?"":r.pattern}`;H.push({route:{...r,pattern:a},prefix:d})}if(l.length>0)console.log(`${M.blue}Plugin pages: ${M.bright}${l.length}${M.blue} routes at ${M.cyan}${d}${M.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await UG(K,Z.stxOptions?.shell),L){if(V=await lY(L,Z.stxOptions||{}),V)console.log(`${M.blue}Using app shell: ${M.bright}${V0.relative(K,L)}${M.reset} ${M.dim}(deprecated: use layouts/default.stx instead)${M.reset}`)}}Y8(),await G8(K);let F=Q8();if(F.length>0)console.log(`${M.blue}Loaded ${M.bright}${F.length}${M.blue} middleware: ${M.dim}${F.join(", ")}${M.reset}`);let A={},N=null;try{let{loadStxConfig:b}=await Promise.resolve().then(() => (z6(),l6)),d=await b(K);if(d?.apiRouter)N=d?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(d?.apiRoutes){A=d.apiRoutes;let l=Object.keys(A).length;if(l>0)console.log(`${M.blue}Loaded ${M.bright}${l} API route${l>1?"s":""}${M.reset}`)}if(d?.broadcasting?.enabled)try{let{startBroadcasting:l,loadChannels:r}=await Promise.resolve().then(() => (aY(),DG)),a=d.broadcasting;await l(a);let q0=a.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${q0}/ws${M.reset}`);let Q0=V0.join(process.cwd(),"channels.ts");if(N1.existsSync(Q0))try{let T0=await r(Q0);console.log(`${M.blue}Loaded ${M.bright}${T0} broadcast channel${T0!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(T0){console.warn(`${M.yellow}Failed to load channels.ts: ${T0.message}${M.reset}`)}}catch(l){console.warn(`${M.yellow}Broadcasting failed to start: ${l.message}${M.reset}`)}}catch{}let w=V0.join(K,".stx/output");N1.mkdirSync(w,{recursive:!0});let R=new Map,T=new Set,E=async(b)=>{let d=zG(B,b);if(!d)return null;try{let l=await Bun.build({entrypoints:[d],outdir:w,plugins:[I5],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!l.success)return null;let r=l.outputs.find((a)=>a.path.endsWith(".html"));if(!r)return null;return await Bun.file(r.path).text()}catch{return null}},I=async(b,d)=>{try{let{processDirectives:l,extractVariables:r,defaultConfig:a,loadStxConfig:q0,injectRouterScript:Q0}=await Promise.resolve().then(() => (z6(),l6)),{checkCache:T0,cacheTemplate:S0,readFileCached:y,templateCache:u}=await Promise.resolve().then(() => (P6(),E$)),c=await q0(K),h=(E0)=>{if(!E0)return E0;if(V0.isAbsolute(E0))return E0;return V0.resolve(K,E0)},p={...a,...c,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)p.debug=!0;p.partialsDir=h(p.partialsDir),p.componentsDir=h(p.componentsDir),p.layoutsDir=h(p.layoutsDir),p.storesDir=h(p.storesDir||"stores"),p.cachePath=h(p.cachePath||".stx/cache");let t=!d&&!Z.profile,i=p.cache!==!1;if(i&&t){let E0=u.get(b.filePath);if(E0)try{if((await N1.promises.stat(b.filePath)).mtime.getTime()<=E0.mtime){let k4=!0;for(let W1 of E0.dependencies){if(!N1.existsSync(W1)){k4=!1;break}if((await N1.promises.stat(W1)).mtime.getTime()>E0.mtime){k4=!1;break}}if(k4){let W1=E0.output;if(V)W1=N4(W1,{preserveHead:!0});return{route:b,content:W1}}}}catch{}let K1=await T0(b.filePath,p);if(K1){let v1=K1;if(V)v1=N4(v1,{preserveHead:!0});return{route:b,content:v1}}}let _0=i?await y(b.filePath):await Bun.file(b.filePath).text(),{classifyAllScripts:k0}=await Promise.resolve().then(() => (z6(),l6)),F0=k0(_0),B0=F0.server.map((E0)=>E0.content),Y1=_0;for(let E0 of F0.server)Y1=Y1.replace(E0.fullTag,"");let s0={__filename:b.filePath,__dirname:V0.dirname(b.filePath),params:d??{}},{resetHead:Z$}=await Promise.resolve().then(() => (c4(),s3));Z$();for(let E0 of B0)try{await r(E0,s0,b.filePath)}catch(K1){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",b.filePath,K1?.message||K1)}let z0=new Set,x0;if(Z.profile){let E0=performance.now();x0=await l(Y1,s0,b.filePath,p,z0);let K1=performance.now()-E0,v1=V0.relative(K,b.filePath)||b.filePath;console.log(`[stx:profile] ${v1} \u2192 ${K1.toFixed(2)}ms`)}else x0=await l(Y1,s0,b.filePath,p,z0);if(!V)x0=await Q0(x0);{let{interpolateScriptExpressions:E0}=await Promise.resolve().then(() => (o0(),l5));x0=x0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(K1,v1,k4)=>{if(!/function\s+__stx_setup_/.test(k4))return K1;return`<script${v1}>${E0(k4,s0)}</script>`})}if(V)x0=N4(x0,{preserveHead:!0});if(i&&t)await S0(b.filePath,x0,z0,p);let{extractStreamBoundaries:v5}=await Promise.resolve().then(() => (p4(),D6)),x1=v5(s0),D4=s0.__streamTemplates;if(D4&&typeof D4==="object"&&Object.keys(D4).length>0){let E0=s0.streamBoundaries||{},K1={...p,autoShell:!1},v1=Object.keys(D4).map((W1)=>({id:W1,render:async()=>{let tW=typeof E0[W1]==="function"?await E0[W1]():void 0;return l(D4[W1],{...s0,$boundary:tW},b.filePath,K1,new Set)}})),k4=new Set(v1.map((W1)=>W1.id));x1=[...(x1||[]).filter((W1)=>!k4.has(W1.id)),...v1]}if(x1&&x1.length>0)T.add(b.pattern);else x1=void 0;return{route:b,content:x0,boundaries:x1}}catch(l){return console.error(`${M.red}Error building ${M.bright}${b.pattern}${M.reset}:`,l),null}},k=8,S=async()=>{R.clear(),O.clear();for(let b=0;b<q.length;b+=k){let d=q.slice(b,b+k),l=await Promise.all(d.map((r)=>I(r)));for(let r of l)if(r)R.set(r.route.pattern,r)}for(let b=0;b<H.length;b+=k){let d=H.slice(b,b+k),l=await Promise.all(d.map(({route:r})=>I(r)));for(let r of l)if(r)O.set(r.route.pattern,r)}return R.size>0};if(console.log(`${M.blue}Building pages...${M.reset}`),!await S())return console.error(`${M.red}No pages were successfully built${M.reset}`),!1;await U$(K);let P=Y;try{if(P=await K6(Y),P!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${P} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let b=Z.hmrPort||P+1;Q=i7({wsPort:b,verbose:!1}),G=Q.start(b)}let C=(b,d)=>{let l=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(d)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(b.includes("</head>"))return b.replace("</head>",`${l}</head>`);if(b.includes("<body"))return b.replace(/<body([^>]*)>/,`<body$1>${l}`);return l+b};console.log(`${M.blue}Starting server...${M.reset}`);let g=bx({port:P,async fetch(b){let d=new URL(b.url),l=U?.publicDir||"public",r=V0.join(K,l,d.pathname),a=V0.join(K,d.pathname),q0=V0.join(w,d.pathname),[Q0,T0,S0]=await Promise.all([N1.promises.stat(r).catch(()=>null),N1.promises.stat(a).catch(()=>null),N1.promises.stat(q0).catch(()=>null)]);if(Q0?.isFile())return TW(r);if(T0?.isFile())return TW(a);if(S0?.isFile())return TW(q0);if(d.pathname.startsWith("/_stx/component/")){let h=decodeURIComponent(d.pathname.slice(16));if(h)try{let p=`<${h} />`,t={...buildConfig,autoShell:!1},i=await processDirectives(p,{},V0.join(K,"components",`${h}.stx`),t,new Set);return new Response(i,{headers:{"Content-Type":"text/html"}})}catch(p){return new Response(`<div class="stx-async-error">${p.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(d.pathname==="/_stx/img"){let{handleImageRequest:h}=await Promise.resolve().then(() => (oQ(),nH)),p=await h(b,{publicDir:V0.join(K,l),cacheDir:V0.join(K,".stx/cache/img")});if(p)return p}if(N)try{let h=await N.handleRequest(b);if(h.status!==404)return h}catch{}if(A[d.pathname])try{return await A[d.pathname](b)}catch(h){return new Response(JSON.stringify({error:h.message}),{status:500,headers:{"Content-Type":"application/json"}})}let y=pY(d.pathname,q);if(y){let h=R.get(y.route.pattern),p=T.has(y.route.pattern);if(y.route.isDynamic&&Object.keys(y.params).length>0||p){let t=await I(y.route,y.params);if(t)h=t}if(h){let t=a3();if(t.validate){if(!await t.validate({params:y.params})){let k0=await E(404);if(k0){let F0=k0;if(F0=await C0(F0,K),J)F0=X4(F0,G);return new Response(F0,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(t.middleware){let _0=J8(d.pathname,y.params,t,d.search),k0=X8(_0,null,b),F0=await K8(t.middleware,k0);if(F0.redirect){let B0=F0.redirect.path,Y1=F0.redirect.options.redirectCode||302,s0=new Headers(F0.responseHeaders);return s0.set("Location",B0),new Response(null,{status:Y1,headers:s0})}if(F0.abort){let{statusCode:B0,message:Y1}=F0.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${B0}</title></head><body><h1>Error ${B0}</h1><p>${Y1}</p></body></html>`,{status:B0,headers:{"Content-Type":"text/html"}})}if(Object.keys(F0.state).length>0){let B0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(F0.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;h.content=h.content.replace("</head>",`${B0}</head>`)}}let i=h.content;if(V&&_G(b)){let _0=z8(i),k0=i.match(/<title[^>]*>([\s\S]*?)<\/title>/i),F0=k0?k0[1].trim():"";if(Object.keys(y.params).length>0)i=C(i,y.params);i=await C0(i,K);let B0=U?.router?.container||"main";return i=_8(i,B0),new Response(i,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":_0.layout,"X-STX-Layout-Group":_0.group,...F0&&{"X-STX-Title":encodeURIComponent(F0)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)i=U8(V,i);if(Object.keys(y.params).length>0)i=C(i,y.params);if(i=await C0(i,K),J)i=X4(i,G);if(Z.native)if(i.includes("<head>"))i=i.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else i="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+i;if(Z.titlebarHidden)if(i.includes("<head>"))i=i.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else i=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${i}`;if(h.boundaries&&h.boundaries.length>0){let{renderStreamingPage:_0,streamToResponse:k0}=await Promise.resolve().then(() => (p4(),D6));return k0(_0(i,h.boundaries,{timeoutMs:30000}),{headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let h=H.map((t)=>t.route),p=pY(d.pathname,h);if(p){let t=O.get(p.route.pattern);if(t){let i=t.content;if(V)i=U8(V,i);if(Object.keys(p.params).length>0)i=C(i,p.params);if(i=await C0(i,K),J)i=X4(i,G);return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:t}of j)if(t!=="/"&&d.pathname.startsWith(t)){let i=O.get(t)||O.get(t+"/");if(i){let _0=i.content;if(V)_0=U8(V,_0);if(_0=await C0(_0,K),J)_0=X4(_0,G);return new Response(_0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let u=R.get("/");if(u){let h=u.content;if(h=await C0(h,K),J)h=X4(h,G);if(Z.native)if(h.includes("<head>"))h=h.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else h="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+h;return new Response(h,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let c=await E(404);if(c){let h=c;if(h=await C0(h,K),J)h=X4(h,G);return new Response(h,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(b){let d=await E(500);if(d)return new Response(d,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${b}
16339
16339
  ${b.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
16340
16340
  ${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
16341
16341
  ${M.bright}\u2192 ${M.cyan}http://localhost:${P}/${M.reset}`),J)console.log(`${M.dim} HMR: ws://localhost:${G}${M.reset}`);console.log(`
16342
16342
  ${M.yellow}Routes:${M.reset}`);let m=[...BG(q,K)];for(let{route:b}of H)m.push(`${b.pattern}`);if(m.forEach((b,d)=>{let r=d===m.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${M.green}${r}${M.reset}${b}`)}),console.log(`
16343
- Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),W6(g.url.toString(),()=>{if(Q)Q5();g.stop()}),Z.native){let b,d=V0.join(B,"index.stx");if(N1.existsSync(d)){let r=await Bun.file(d).text();b=EY(r)}let l=U?.app?.window??{};await Y5(P,{title:U?.app?.head?.title||V0.basename(K)||"stx App",width:l.width,height:l.height,darkMode:l.darkMode,hotReload:l.hotReload,titlebarHidden:l.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!b,sidebarConfig:b})}if(X){console.log(`${M.blue}Watching for changes...${M.reset}`);let b=(r)=>{return r.startsWith("public/")||r.startsWith("public\\")},d=(r)=>{let a=r.toLowerCase();return a.endsWith(".stx")||a.endsWith(".html")||a.endsWith(".md")},l=N1.watch(K,{recursive:!0},async(r,a)=>{if(!a||p7(a))return;if(l7(a))if(b(a)){if(console.log(`${M.cyan}${a} changed${M.reset}`),J&&Q)Q.reload(a)}else if(d(a)){console.log(`${M.yellow}${a} changed, rebuilding...${M.reset}`),s4.clear(),Z6();try{let{invalidateFileCache:B0,templateCache:Q0}=await Promise.resolve().then(() => (P6(),E$));B0(V0.resolve(K,a)),Q0.delete(V0.resolve(K,a))}catch{}if(L&&a){if(V0.resolve(K,a)===L||V0.basename(L)===a){let Q0=await lY(L,Z.stxOptions||{});if(Q0)V=Q0}}if(await S(),await r5(K),J&&Q)Q.reload(a)}else{console.log(`${M.yellow}${a} changed, rebuilding...${M.reset}`),s4.clear(),Z6();try{let{invalidateFileCache:B0,templateCache:Q0}=await Promise.resolve().then(() => (P6(),E$));B0(V0.resolve(K,a)),Q0.delete(V0.resolve(K,a))}catch{}if(await S(),J&&Q)Q.reload(a)}else if(c7(a)){if(console.log(`${M.cyan}CSS ${a} changed${M.reset}`),J&&Q)Q.updateCss(a)}});process.on("SIGINT",()=>{if(l.close(),Q)Q5();g.stop(),process.exit(0)})}return!0}var rF=D(()=>{j5();N$();wX();B8();mY();c4();A0();m7()});var MW=D(()=>{cQ();iF();nF();rF()});var tF={};e(tF,{runPwaAudit:()=>Px,formatAuditResult:()=>yx,calculateAuditResult:()=>oF,auditConfig:()=>aF,auditBuildOutput:()=>sF});import t6 from"fs";import RX from"path";function aF($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let X=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:X.includes(192),message:X.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:X.includes(512),message:X.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let J=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:J.length>0,message:J.length>0?`${J.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function sF($){let Z=[],Y=RX.join($,"manifest.json"),X=t6.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:X,message:X?"manifest.json exists":"manifest.json not found in build output"}),X)try{let _=JSON.parse(t6.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(_.icons)&&_.icons.length>0,message:_.icons?.length?`${_.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let J=RX.join($,"sw.js"),Q=t6.existsSync(J);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=RX.join($,"offline.html"),K=t6.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=RX.join($,"pwa-icons");if(t6.existsSync(W)){let _=t6.readdirSync(W).filter((z)=>z.endsWith(".png")||z.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:_.length>0,message:_.length>0?`${_.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function oF($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),X=Z.filter((W)=>W.passed).length,J=Y.filter((W)=>W.passed).length,Q=Z.length>0?X/Z.length*70:70,G=Y.length>0?J/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function Px($,Z){let Y=aF($),X=Z&&t6.existsSync(Z)?sF(Z):[];return oF([...Y,...X])}function yx($){let Z=[];Z.push(`
16343
+ Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),W6(g.url.toString(),()=>{if(Q)Q5();g.stop()}),Z.native){let b,d=V0.join(B,"index.stx");if(N1.existsSync(d)){let r=await Bun.file(d).text();b=EY(r)}let l=U?.app?.window??{};await Y5(P,{title:U?.app?.head?.title||V0.basename(K)||"stx App",width:l.width,height:l.height,darkMode:l.darkMode,hotReload:l.hotReload,titlebarHidden:l.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!b,sidebarConfig:b})}if(X){console.log(`${M.blue}Watching for changes...${M.reset}`);let b=(r)=>{return r.startsWith("public/")||r.startsWith("public\\")},d=(r)=>{let a=r.toLowerCase();return a.endsWith(".stx")||a.endsWith(".html")||a.endsWith(".md")},l=N1.watch(K,{recursive:!0},async(r,a)=>{if(!a||p7(a))return;if(l7(a))if(b(a)){if(console.log(`${M.cyan}${a} changed${M.reset}`),J&&Q)Q.reload(a)}else if(d(a)){console.log(`${M.yellow}${a} changed, rebuilding...${M.reset}`),s4.clear(),Z6();try{let{invalidateFileCache:q0,templateCache:Q0}=await Promise.resolve().then(() => (P6(),E$));q0(V0.resolve(K,a)),Q0.delete(V0.resolve(K,a))}catch{}if(L&&a){if(V0.resolve(K,a)===L||V0.basename(L)===a){let Q0=await lY(L,Z.stxOptions||{});if(Q0)V=Q0}}if(await S(),await r5(K),J&&Q)Q.reload(a)}else{console.log(`${M.yellow}${a} changed, rebuilding...${M.reset}`),s4.clear(),Z6();try{let{invalidateFileCache:q0,templateCache:Q0}=await Promise.resolve().then(() => (P6(),E$));q0(V0.resolve(K,a)),Q0.delete(V0.resolve(K,a))}catch{}if(await S(),J&&Q)Q.reload(a)}else if(c7(a)){if(console.log(`${M.cyan}CSS ${a} changed${M.reset}`),J&&Q)Q.updateCss(a)}});process.on("SIGINT",()=>{if(l.close(),Q)Q5();g.stop(),process.exit(0)})}return!0}var rF=D(()=>{j5();N$();wX();B8();mY();c4();N0();m7()});var MW=D(()=>{cQ();iF();nF();rF()});var tF={};e(tF,{runPwaAudit:()=>Px,formatAuditResult:()=>yx,calculateAuditResult:()=>oF,auditConfig:()=>aF,auditBuildOutput:()=>sF});import t6 from"fs";import RX from"path";function aF($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let X=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:X.includes(192),message:X.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:X.includes(512),message:X.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let J=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:J.length>0,message:J.length>0?`${J.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function sF($){let Z=[],Y=RX.join($,"manifest.json"),X=t6.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:X,message:X?"manifest.json exists":"manifest.json not found in build output"}),X)try{let _=JSON.parse(t6.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(_.icons)&&_.icons.length>0,message:_.icons?.length?`${_.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let J=RX.join($,"sw.js"),Q=t6.existsSync(J);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=RX.join($,"offline.html"),K=t6.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=RX.join($,"pwa-icons");if(t6.existsSync(W)){let _=t6.readdirSync(W).filter((z)=>z.endsWith(".png")||z.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:_.length>0,message:_.length>0?`${_.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function oF($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),X=Z.filter((W)=>W.passed).length,J=Y.filter((W)=>W.passed).length,Q=Z.length>0?X/Z.length*70:70,G=Y.length>0?J/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function Px($,Z){let Y=aF($),X=Z&&t6.existsSync(Z)?sF(Z):[];return oF([...Y,...X])}function yx($){let Z=[];Z.push(`
16344
16344
  === PWA Audit Report ===
16345
16345
  `);let Y=$.score>=90?"32":$.score>=70?"33":"31";Z.push(`Score: \x1B[${Y}m${$.score}/100\x1B[0m`),Z.push(`Passed: ${$.passed} | Failed: ${$.failed} | Warnings: ${$.warnings}
16346
16346
  `);let X=["required","recommended","optional"];for(let J of X){let Q=$.checks.filter((G)=>G.category===J);if(Q.length===0)continue;Z.push(`
@@ -19568,9 +19568,9 @@ window.__stxPerformance = {
19568
19568
 
19569
19569
  window.clearPerformanceMetrics = () => window.__stxPerformance.clear();
19570
19570
  </script>
19571
- `}var q00;var JN=D(()=>{q00=new ZN});import cW from"fs";import QN from"path";class pW{storage;storagePath;dirty=!1;constructor($){this.storagePath=QN.join($,nv),this.storage=this.loadStorage()}loadStorage(){try{let $=cW.readFileSync(this.storagePath,"utf-8"),Z=JSON.parse($);if(Z.version!==lW)return this.migrateStorage(Z);return Z}catch{return{version:lW,presets:[],recentIds:[]}}}migrateStorage($){return{version:lW,presets:$.presets||[],recentIds:$.recentIds||[]}}async save(){if(!this.dirty)return;let $=QN.dirname(this.storagePath);await cW.promises.mkdir($,{recursive:!0}),await cW.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset($,Z,Y={}){let X={id:av(),name:$,description:Y.description,props:Z,componentId:Y.componentId,created:Date.now(),usageCount:0,tags:Y.tags};return this.storage.presets.push(X),this.dirty=!0,X}getPreset($){return this.storage.presets.find((Z)=>Z.id===$)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent($){return this.storage.presets.filter((Z)=>!Z.componentId||Z.componentId===$)}getRecentPresets(){return this.storage.recentIds.map(($)=>this.getPreset($)).filter(($)=>$!==void 0)}usePreset($){let Z=this.getPreset($);if(!Z)return;return Z.lastUsed=Date.now(),Z.usageCount++,this.storage.recentIds=[$,...this.storage.recentIds.filter((Y)=>Y!==$)].slice(0,rv),this.dirty=!0,Z}updatePreset($,Z){let Y=this.getPreset($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deletePreset($){let Z=this.storage.presets.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.presets.splice(Z,1),this.storage.recentIds=this.storage.recentIds.filter((Y)=>Y!==$),this.dirty=!0,!0}searchPresets($){let Z=$.toLowerCase();return this.storage.presets.filter((Y)=>{if(Y.name.toLowerCase().includes(Z))return!0;if(Y.description?.toLowerCase().includes(Z))return!0;if(Y.tags?.some((X)=>X.toLowerCase().includes(Z)))return!0;return!1})}getMostUsedPresets($=5){return[...this.storage.presets].sort((Z,Y)=>Y.usageCount-Z.usageCount).slice(0,$)}exportPresets($){let Z=$?this.storage.presets.filter((Y)=>$.includes(Y.id)):this.storage.presets;return JSON.stringify({presets:Z},null,2)}importPresets($,Z=!1){let Y=JSON.parse($),X=0;for(let J of Y.presets){let Q=this.storage.presets.find((G)=>G.id===J.id);if(Q&&!Z)continue;if(Q)Object.assign(Q,J);else this.storage.presets.push(J);X++}if(X>0)this.dirty=!0;return X}}function av(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var nv=".stx/story/presets.json",lW=1,rv=10;var GN=()=>{};import iW from"fs";async function xX($,Z,Y={}){let X=performance.now(),J=[];try{let Q=await iW.promises.stat(Z),G=KN.get(Z),K;if(G&&G.mtime===Q.mtimeMs)K=G.content;else K=await iW.promises.readFile(Z,"utf-8"),KN.set(Z,{content:K,mtime:Q.mtimeMs,analyzed:null});let{processDirectives:W}=await Promise.resolve().then(() => (U1(),sZ)),U={},_=K3(K);if(_)try{await E0(_,U,Z)}catch(H){J.push(`Warning: Could not extract script variables: ${H instanceof Error?H.message:String(H)}`)}if(Y.props)Object.assign(U,Y.props);let B=await W(K,U,Z,{},new Set),q=UN(K),j=K3(K);return B=_N(B),B=zN(B,U),{html:B,css:q,js:j,errors:J,duration:performance.now()-X}}catch(Q){return J.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${BN(J[0])}</div>`,css:"",js:"",errors:J,duration:performance.now()-X}}}async function sv($){try{let Z=await iW.promises.readFile($,"utf-8"),Y=K3(Z);if(!Y)return null;let X={};if(await E0(Y,X,$),Array.isArray(X.variants))return X.variants;return null}catch{return null}}async function WN($,Z,Y,X){let J=Z.story?.variants;if(!J){let K=await sv(Z.path);if(K)J=K}if(!J&&Y==="default")return xX($,Z.path,{props:X||{}});if(!J)return xX($,Z.path,{props:X||{}});let Q=J.find((K)=>K.id===Y);if(!Q&&Y==="default")return xX($,Z.path,{props:X||{}});if(!Q)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Y}' not found`],duration:0};let G={...Q.state,...X};if(Q.source)return ov($,Q.source,G);return xX($,Z.path,{props:G})}async function ov($,Z,Y={}){let X=performance.now(),J=[];try{let{processDirectives:Q}=await Promise.resolve().then(() => (U1(),sZ)),G={...Y},K=K3(Z);if(K)try{await E0(K,G,"inline-template.stx")}catch{}let U=await Q(Z,G,"inline-template.stx",{},new Set);return U=_N(U),U=zN(U,G),{html:U,css:UN(Z),js:K3(Z),errors:J,duration:performance.now()-X}}catch(Q){return J.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${BN(J[0])}</div>`,css:"",js:"",errors:J,duration:performance.now()-X}}}function UN($){let Z=[],Y=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,X=Y.exec($);while(X!==null)Z.push(X[1].trim()),X=Y.exec($);return Z.join(`
19571
+ `}var q00;var JN=D(()=>{q00=new ZN});import cW from"fs";import QN from"path";class pW{storage;storagePath;dirty=!1;constructor($){this.storagePath=QN.join($,nv),this.storage=this.loadStorage()}loadStorage(){try{let $=cW.readFileSync(this.storagePath,"utf-8"),Z=JSON.parse($);if(Z.version!==lW)return this.migrateStorage(Z);return Z}catch{return{version:lW,presets:[],recentIds:[]}}}migrateStorage($){return{version:lW,presets:$.presets||[],recentIds:$.recentIds||[]}}async save(){if(!this.dirty)return;let $=QN.dirname(this.storagePath);await cW.promises.mkdir($,{recursive:!0}),await cW.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}createPreset($,Z,Y={}){let X={id:av(),name:$,description:Y.description,props:Z,componentId:Y.componentId,created:Date.now(),usageCount:0,tags:Y.tags};return this.storage.presets.push(X),this.dirty=!0,X}getPreset($){return this.storage.presets.find((Z)=>Z.id===$)}getAllPresets(){return[...this.storage.presets]}getPresetsForComponent($){return this.storage.presets.filter((Z)=>!Z.componentId||Z.componentId===$)}getRecentPresets(){return this.storage.recentIds.map(($)=>this.getPreset($)).filter(($)=>$!==void 0)}usePreset($){let Z=this.getPreset($);if(!Z)return;return Z.lastUsed=Date.now(),Z.usageCount++,this.storage.recentIds=[$,...this.storage.recentIds.filter((Y)=>Y!==$)].slice(0,rv),this.dirty=!0,Z}updatePreset($,Z){let Y=this.getPreset($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deletePreset($){let Z=this.storage.presets.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.presets.splice(Z,1),this.storage.recentIds=this.storage.recentIds.filter((Y)=>Y!==$),this.dirty=!0,!0}searchPresets($){let Z=$.toLowerCase();return this.storage.presets.filter((Y)=>{if(Y.name.toLowerCase().includes(Z))return!0;if(Y.description?.toLowerCase().includes(Z))return!0;if(Y.tags?.some((X)=>X.toLowerCase().includes(Z)))return!0;return!1})}getMostUsedPresets($=5){return[...this.storage.presets].sort((Z,Y)=>Y.usageCount-Z.usageCount).slice(0,$)}exportPresets($){let Z=$?this.storage.presets.filter((Y)=>$.includes(Y.id)):this.storage.presets;return JSON.stringify({presets:Z},null,2)}importPresets($,Z=!1){let Y=JSON.parse($),X=0;for(let J of Y.presets){let Q=this.storage.presets.find((G)=>G.id===J.id);if(Q&&!Z)continue;if(Q)Object.assign(Q,J);else this.storage.presets.push(J);X++}if(X>0)this.dirty=!0;return X}}function av(){return`preset-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var nv=".stx/story/presets.json",lW=1,rv=10;var GN=()=>{};import iW from"fs";async function xX($,Z,Y={}){let X=performance.now(),J=[];try{let Q=await iW.promises.stat(Z),G=KN.get(Z),K;if(G&&G.mtime===Q.mtimeMs)K=G.content;else K=await iW.promises.readFile(Z,"utf-8"),KN.set(Z,{content:K,mtime:Q.mtimeMs,analyzed:null});let{processDirectives:W}=await Promise.resolve().then(() => (U1(),sZ)),U={},_=K3(K);if(_)try{await I0(_,U,Z)}catch(H){J.push(`Warning: Could not extract script variables: ${H instanceof Error?H.message:String(H)}`)}if(Y.props)Object.assign(U,Y.props);let B=await W(K,U,Z,{},new Set),q=UN(K),j=K3(K);return B=_N(B),B=zN(B,U),{html:B,css:q,js:j,errors:J,duration:performance.now()-X}}catch(Q){return J.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${BN(J[0])}</div>`,css:"",js:"",errors:J,duration:performance.now()-X}}}async function sv($){try{let Z=await iW.promises.readFile($,"utf-8"),Y=K3(Z);if(!Y)return null;let X={};if(await I0(Y,X,$),Array.isArray(X.variants))return X.variants;return null}catch{return null}}async function WN($,Z,Y,X){let J=Z.story?.variants;if(!J){let K=await sv(Z.path);if(K)J=K}if(!J&&Y==="default")return xX($,Z.path,{props:X||{}});if(!J)return xX($,Z.path,{props:X||{}});let Q=J.find((K)=>K.id===Y);if(!Q&&Y==="default")return xX($,Z.path,{props:X||{}});if(!Q)return{html:'<div class="stx-render-error">Variant not found</div>',css:"",js:"",errors:[`Variant '${Y}' not found`],duration:0};let G={...Q.state,...X};if(Q.source)return ov($,Q.source,G);return xX($,Z.path,{props:G})}async function ov($,Z,Y={}){let X=performance.now(),J=[];try{let{processDirectives:Q}=await Promise.resolve().then(() => (U1(),sZ)),G={...Y},K=K3(Z);if(K)try{await I0(K,G,"inline-template.stx")}catch{}let U=await Q(Z,G,"inline-template.stx",{},new Set);return U=_N(U),U=zN(U,G),{html:U,css:UN(Z),js:K3(Z),errors:J,duration:performance.now()-X}}catch(Q){return J.push(Q instanceof Error?Q.message:String(Q)),{html:`<div class="stx-render-error">${BN(J[0])}</div>`,css:"",js:"",errors:J,duration:performance.now()-X}}}function UN($){let Z=[],Y=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,X=Y.exec($);while(X!==null)Z.push(X[1].trim()),X=Y.exec($);return Z.join(`
19572
19572
  `)}function _N($){return $.replace(/<!--[\s\S]*?-->/g,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/^\s*\n/gm,"").trim()}function K3($){let Z=[],Y=/<script\b[^>]*>([\s\S]*?)<\/script>/gi,X=Y.exec($);while(X!==null)Z.push(X[1].trim()),X=Y.exec($);return Z.join(`
19573
- `)}function zN($,Z){let Y=`<script>window.__stxProps = ${JSON.stringify(Z)};</script>`;return $+Y}function BN($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var KN;var qN=D(()=>{A0();KN=new Map});async function jN($,Z){let Y=await Q3($);b5($,Y);let X=G3($.config,Y);P5($,X),console.log(` Found ${Y.length} story files`);let J=typeof Z.host==="string"?Z.host:Z.host===!0?"0.0.0.0":"localhost",Q=new pW($.root),G=new fW($.root),K=new xW($.root),W=cA(),U=Bun.serve({port:Z.port,hostname:J,fetch:async(B,q)=>{let H=new URL(B.url).pathname;if(H==="/__hmr"){if(q.upgrade(B,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(H.startsWith("/api/"))return tv($,H,B,{presetsManager:Q,bookmarksManager:G,analyticsTracker:K});return ev($,H,Z.port)},websocket:{open(B){W.open(B)},close(B){W.close(B)},message(B,q){W.message(B,q)}}}),_=`http://${J}:${Z.port}`,z=mA($,async(B,q)=>{console.log(` [${B}] ${q.relativePath}`);let j=await Q3($);b5($,j);let H=G3($.config,j);if(P5($,H),B==="add")pA(q.id,{fileName:q.fileName});else if(B==="unlink")iA(q.id);else lA(q.id,{fileName:q.fileName})});if(Z.open){let B=_;try{let{exec:q}=await import("child_process"),j=process.platform;q(`${j==="darwin"?"open":j==="win32"?"start":"xdg-open"} ${B}`)}catch{}}return{server:U,url:_,close:async()=>{z(),U.stop()}}}async function tv($,Z,Y,X){let{presetsManager:J,bookmarksManager:Q,analyticsTracker:G}=X;if(Z==="/api/stories")return Response.json({files:$.storyFiles.map((K)=>({id:K.id,fileName:K.fileName,relativePath:K.relativePath,treePath:K.treePath})),tree:$.tree});if(Z.startsWith("/api/story/")){let K=Z.slice(11),W=$.storyFiles.find((U)=>U.id===K);if(!W)return new Response("Story not found",{status:404});try{let U=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:U})}catch{return new Response("Error reading story",{status:500})}}if(Z==="/api/config")return Response.json({theme:$.config.theme,responsivePresets:$.config.responsivePresets,backgroundPresets:$.config.backgroundPresets});if(Z.startsWith("/api/render/")){let K=new URL(Y.url),W=Z.slice(12).split("/"),U=W[0],_=W[1]||"default",z,B=K.searchParams.get("props");if(B)try{z=JSON.parse(B)}catch{}let q=$.storyFiles.find((j)=>j.id===U);if(!q)return new Response("Story not found",{status:404});try{let j=await WN($,q,_,z);return Response.json({html:j.html,css:j.css,js:j.js,errors:j.errors,duration:j.duration})}catch(j){return Response.json({html:"",css:"",js:"",errors:[j instanceof Error?j.message:String(j)],duration:0},{status:500})}}if(Z==="/api/presets"&&Y.method==="GET")return Response.json({presets:J.getAllPresets()});if(Z==="/api/presets"&&Y.method==="POST")try{let K=await Y.json(),W=J.createPreset(K.name,K.props,{componentId:K.componentId,description:K.description});return await J.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/presets/")&&!Z.includes("/use")&&Y.method==="GET"){let K=Z.slice(13),W=J.getPreset(K);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(Z.endsWith("/use")&&Y.method==="POST"){let K=Z.slice(13,-4),W=J.usePreset(K);if(!W)return new Response("Preset not found",{status:404});return await J.save(),Response.json(W)}if(Z.startsWith("/api/presets/")&&Y.method==="DELETE"){let K=Z.slice(13);if(!J.deletePreset(K))return new Response("Preset not found",{status:404});return await J.save(),Response.json({success:!0})}if(Z==="/api/bookmarks"&&Y.method==="GET")return Response.json({bookmarks:Q.getAllBookmarks()});if(Z==="/api/bookmarks"&&Y.method==="POST")try{let K=await Y.json(),W=Q.addBookmark(K.storyId,K.variantId,K.props,{name:K.name,notes:K.notes,color:K.color});return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/bookmarks/toggle"&&Y.method==="POST")try{let K=await Y.json(),W=Q.toggleBookmark(K.storyId,K.variantId,K.props);return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/bookmarks/")&&Z!=="/api/bookmarks/toggle"&&Y.method==="GET"){let K=Z.slice(15),W=Q.getBookmark(K);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(Z.startsWith("/api/bookmarks/")&&Y.method==="DELETE"){let K=Z.slice(15);if(!Q.deleteBookmark(K))return new Response("Bookmark not found",{status:404});return await Q.save(),Response.json({success:!0})}if(Z==="/api/analytics/track"&&Y.method==="POST")try{let K=await Y.json();if(K.type==="view"&&K.componentId)G.trackView(K.componentId,K.variantId);else if(K.type==="prop_change"&&K.componentId&&K.propName)G.trackPropChange(K.componentId,K.propName,null);else if(K.type==="variant_switch"&&K.componentId&&K.variantId)G.trackVariantSwitch(K.componentId,K.variantId);else if(K.type==="search"&&K.query)G.trackSearch(K.query,0);return await G.save(),Response.json({success:!0})}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/analytics/summary"&&Y.method==="GET")return Response.json({mostViewed:G.getMostViewedComponents(10),mostChangedProps:G.getMostChangedProps(10),searchAnalytics:G.getSearchAnalytics()});if(Z.startsWith("/api/analytics/component/")&&Y.method==="GET"){let K=Z.slice(25),W=$.storyFiles.find((_)=>_.id===K),U=G.getComponentAnalytics(K,W?.fileName||K);return Response.json(U)}return new Response("Not found",{status:404})}function ev($,Z,Y){let X=$f($,Y);return new Response(X,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function $f($,Z){let{theme:Y}=$.config,X=Y.title||"STX Story",J=`ws://localhost:${Z}/__hmr`,Q=nA(J);return`<!DOCTYPE html>
19573
+ `)}function zN($,Z){let Y=`<script>window.__stxProps = ${JSON.stringify(Z)};</script>`;return $+Y}function BN($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}var KN;var qN=D(()=>{N0();KN=new Map});async function jN($,Z){let Y=await Q3($);b5($,Y);let X=G3($.config,Y);P5($,X),console.log(` Found ${Y.length} story files`);let J=typeof Z.host==="string"?Z.host:Z.host===!0?"0.0.0.0":"localhost",Q=new pW($.root),G=new fW($.root),K=new xW($.root),W=cA(),U=Bun.serve({port:Z.port,hostname:J,fetch:async(B,q)=>{let H=new URL(B.url).pathname;if(H==="/__hmr"){if(q.upgrade(B,{data:{isHmr:!0}}))return;return new Response("WebSocket upgrade failed",{status:400})}if(H.startsWith("/api/"))return tv($,H,B,{presetsManager:Q,bookmarksManager:G,analyticsTracker:K});return ev($,H,Z.port)},websocket:{open(B){W.open(B)},close(B){W.close(B)},message(B,q){W.message(B,q)}}}),_=`http://${J}:${Z.port}`,z=mA($,async(B,q)=>{console.log(` [${B}] ${q.relativePath}`);let j=await Q3($);b5($,j);let H=G3($.config,j);if(P5($,H),B==="add")pA(q.id,{fileName:q.fileName});else if(B==="unlink")iA(q.id);else lA(q.id,{fileName:q.fileName})});if(Z.open){let B=_;try{let{exec:q}=await import("child_process"),j=process.platform;q(`${j==="darwin"?"open":j==="win32"?"start":"xdg-open"} ${B}`)}catch{}}return{server:U,url:_,close:async()=>{z(),U.stop()}}}async function tv($,Z,Y,X){let{presetsManager:J,bookmarksManager:Q,analyticsTracker:G}=X;if(Z==="/api/stories")return Response.json({files:$.storyFiles.map((K)=>({id:K.id,fileName:K.fileName,relativePath:K.relativePath,treePath:K.treePath})),tree:$.tree});if(Z.startsWith("/api/story/")){let K=Z.slice(11),W=$.storyFiles.find((U)=>U.id===K);if(!W)return new Response("Story not found",{status:404});try{let U=await Bun.file(W.path).text();return Response.json({id:W.id,fileName:W.fileName,relativePath:W.relativePath,content:U})}catch{return new Response("Error reading story",{status:500})}}if(Z==="/api/config")return Response.json({theme:$.config.theme,responsivePresets:$.config.responsivePresets,backgroundPresets:$.config.backgroundPresets});if(Z.startsWith("/api/render/")){let K=new URL(Y.url),W=Z.slice(12).split("/"),U=W[0],_=W[1]||"default",z,B=K.searchParams.get("props");if(B)try{z=JSON.parse(B)}catch{}let q=$.storyFiles.find((j)=>j.id===U);if(!q)return new Response("Story not found",{status:404});try{let j=await WN($,q,_,z);return Response.json({html:j.html,css:j.css,js:j.js,errors:j.errors,duration:j.duration})}catch(j){return Response.json({html:"",css:"",js:"",errors:[j instanceof Error?j.message:String(j)],duration:0},{status:500})}}if(Z==="/api/presets"&&Y.method==="GET")return Response.json({presets:J.getAllPresets()});if(Z==="/api/presets"&&Y.method==="POST")try{let K=await Y.json(),W=J.createPreset(K.name,K.props,{componentId:K.componentId,description:K.description});return await J.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/presets/")&&!Z.includes("/use")&&Y.method==="GET"){let K=Z.slice(13),W=J.getPreset(K);if(!W)return new Response("Preset not found",{status:404});return Response.json(W)}if(Z.endsWith("/use")&&Y.method==="POST"){let K=Z.slice(13,-4),W=J.usePreset(K);if(!W)return new Response("Preset not found",{status:404});return await J.save(),Response.json(W)}if(Z.startsWith("/api/presets/")&&Y.method==="DELETE"){let K=Z.slice(13);if(!J.deletePreset(K))return new Response("Preset not found",{status:404});return await J.save(),Response.json({success:!0})}if(Z==="/api/bookmarks"&&Y.method==="GET")return Response.json({bookmarks:Q.getAllBookmarks()});if(Z==="/api/bookmarks"&&Y.method==="POST")try{let K=await Y.json(),W=Q.addBookmark(K.storyId,K.variantId,K.props,{name:K.name,notes:K.notes,color:K.color});return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/bookmarks/toggle"&&Y.method==="POST")try{let K=await Y.json(),W=Q.toggleBookmark(K.storyId,K.variantId,K.props);return await Q.save(),Response.json(W)}catch(K){return Response.json({error:String(K)},{status:400})}if(Z.startsWith("/api/bookmarks/")&&Z!=="/api/bookmarks/toggle"&&Y.method==="GET"){let K=Z.slice(15),W=Q.getBookmark(K);if(!W)return new Response("Bookmark not found",{status:404});return Response.json(W)}if(Z.startsWith("/api/bookmarks/")&&Y.method==="DELETE"){let K=Z.slice(15);if(!Q.deleteBookmark(K))return new Response("Bookmark not found",{status:404});return await Q.save(),Response.json({success:!0})}if(Z==="/api/analytics/track"&&Y.method==="POST")try{let K=await Y.json();if(K.type==="view"&&K.componentId)G.trackView(K.componentId,K.variantId);else if(K.type==="prop_change"&&K.componentId&&K.propName)G.trackPropChange(K.componentId,K.propName,null);else if(K.type==="variant_switch"&&K.componentId&&K.variantId)G.trackVariantSwitch(K.componentId,K.variantId);else if(K.type==="search"&&K.query)G.trackSearch(K.query,0);return await G.save(),Response.json({success:!0})}catch(K){return Response.json({error:String(K)},{status:400})}if(Z==="/api/analytics/summary"&&Y.method==="GET")return Response.json({mostViewed:G.getMostViewedComponents(10),mostChangedProps:G.getMostChangedProps(10),searchAnalytics:G.getSearchAnalytics()});if(Z.startsWith("/api/analytics/component/")&&Y.method==="GET"){let K=Z.slice(25),W=$.storyFiles.find((_)=>_.id===K),U=G.getComponentAnalytics(K,W?.fileName||K);return Response.json(U)}return new Response("Not found",{status:404})}function ev($,Z,Y){let X=$f($,Y);return new Response(X,{headers:{"Content-Type":"text/html; charset=utf-8"}})}function $f($,Z){let{theme:Y}=$.config,X=Y.title||"STX Story",J=`ws://localhost:${Z}/__hmr`,Q=nA(J);return`<!DOCTYPE html>
19574
19574
  <html lang="en" class="${Y.darkClass||"dark"}">
19575
19575
  <head>
19576
19576
  <meta charset="UTF-8">
@@ -20409,7 +20409,7 @@ else {
20409
20409
  `)}function fN($,Z){let Y=" ".repeat(Z),X=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);X.push(`${K}: ${U}`)}let J=X.length>0?`{ ${X.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:fN(K,Z+1)),G=Q.length>0?`,
20410
20410
  ${Y} [${Q.join(`,
20411
20411
  ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function Cf($,Z,Y){if(Z.target==="universal"){let X=[];X.push("// Universal entry point"),X.push("");for(let[J,Q]of Y)X.push(`// --- ${J.toUpperCase()} ---`),X.push(`#if ${J.toUpperCase()}`),X.push(Q),X.push("#endif"),X.push("");return X.join(`
20412
- `)}return Y.get(Z.target)||nW($,Z)}function bf($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:hN(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)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function Pf($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function gN(){return`id_${++yf}`}function hN($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function xf($){return $.charAt(0).toUpperCase()+$.slice(1)}function vf($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function ff($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function rW($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=rW(Y);return Z}function aW($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=aW(Y);return Z}function dN($){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 sW,yf=0,gf,hf;var mN=D(()=>{sW=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"}]]);gf={compileToNative:bN,createHotReloadServer:dN,NATIVE_COMPONENTS:sW},hf=gf});import{spawn as pN}from"child_process";import y0 from"fs";import df from"os";import Y0 from"path";import v from"process";import{CLI as uf}from"@stacksjs/clapp";var A6="0.2.86";Y$();MW();bG();uG();x4();gG();jW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",O0=new uf("stx");function cN($){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 lN($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.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(y0.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 oW($){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 x5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),mf=($)=>$.endsWith(".stx")||$.endsWith(".md");function y5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}async function cf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(x5(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(X.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 X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),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(df.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 J={...v.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=pN(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
20412
+ `)}return Y.get(Z.target)||nW($,Z)}function bf($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:hN(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)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function Pf($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function gN(){return`id_${++yf}`}function hN($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function xf($){return $.charAt(0).toUpperCase()+$.slice(1)}function vf($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function ff($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function rW($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=rW(Y);return Z}function aW($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=aW(Y);return Z}function dN($){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 sW,yf=0,gf,hf;var mN=D(()=>{sW=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"}]]);gf={compileToNative:bN,createHotReloadServer:dN,NATIVE_COMPONENTS:sW},hf=gf});import{spawn as pN}from"child_process";import y0 from"fs";import df from"os";import Y0 from"path";import v from"process";import{CLI as uf}from"@stacksjs/clapp";var A6="0.2.88";Y$();MW();bG();uG();x4();gG();jW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",O0=new uf("stx");function cN($){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 lN($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.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(y0.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 oW($){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 x5=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),mf=($)=>$.endsWith(".stx")||$.endsWith(".md");function y5($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}async function cf($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(x5(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(X.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 X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),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(df.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 J={...v.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=pN(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
20413
20413
  Test run interrupted`),K.kill("SIGINT"),v.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var lf=v.argv.length>=3&&(mf(v.argv[2])&&y0.existsSync(v.argv[2])||x5(v.argv[2]));if(lf){let $=v.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<v.argv.length;Y++){let X=v.argv[Y];if(X==="--port"&&Y+1<v.argv.length){let J=cN(v.argv[++Y]);if(!J.isValid)y5(J);Z.port=Number.parseInt(v.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<v.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=v.argv[++Y]}else if(X==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(X==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(X==="--no-cache")Z.cache=!1;else if(X==="--native")Z.native=!0}if(x5($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.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")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(Y0.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),v.exit(1);if(!await l8(X,Z))v.exit(1)}catch(Y){console.error("Failed to process files:",Y),v.exit(1)}else c8($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),v.exit(1)})}else{let $=function(X,J){let Q=[];for(let G=0;G<=J.length;G++)Q[G]=[G];for(let G=0;G<=X.length;G++)Q[0][G]=G;for(let G=1;G<=J.length;G++)for(let K=1;K<=X.length;K++)if(J.charAt(G-1)===X.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[J.length][X.length]};O0.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(X)=>{try{if(await CG(X))console.log("Documentation generated successfully."),v.exit(0);else console.error("Documentation generation failed."),v.exit(1)}catch(J){console.error("Error generating documentation:",J),v.exit(1)}}),O0.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(X,J)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(X==="list"){console.log(`
20414
20414
  \uD83D\uDCDA Fetching available icon collections...
20415
20415
  `);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections: