@stacksjs/stx 0.2.83 → 0.2.85

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.
Files changed (53) hide show
  1. package/dist/app-shell.js +56 -56
  2. package/dist/build-assets.js +6 -6
  3. package/dist/build-mode-detector.js +101 -101
  4. package/dist/build-views.js +155 -155
  5. package/dist/build.js +43 -43
  6. package/dist/caching.js +6 -6
  7. package/dist/cli.js +57 -57
  8. package/dist/component-processing.js +22 -22
  9. package/dist/component-renderer.js +38 -38
  10. package/dist/components.js +101 -101
  11. package/dist/dev-server/index.js +42 -42
  12. package/dist/dev-server/serve-app.js +56 -56
  13. package/dist/dev-server/serve-file.js +56 -56
  14. package/dist/dev-server/serve-markdown.js +42 -42
  15. package/dist/dev-server/serve-multi.js +55 -55
  16. package/dist/dev-server.js +56 -56
  17. package/dist/docs.js +102 -102
  18. package/dist/dynamic-components.js +38 -38
  19. package/dist/includes.js +38 -38
  20. package/dist/index.js +56 -56
  21. package/dist/interactive.js +102 -102
  22. package/dist/lazy-loader.js +101 -101
  23. package/dist/plugin.js +50 -50
  24. package/dist/process.js +37 -37
  25. package/dist/production-builder.js +37 -37
  26. package/dist/production-server.js +37 -37
  27. package/dist/pwa/index.js +101 -101
  28. package/dist/pwa/offline.js +101 -101
  29. package/dist/pwa.js +90 -90
  30. package/dist/render.js +159 -159
  31. package/dist/runtime-injection.js +6 -6
  32. package/dist/serve.js +112 -112
  33. package/dist/signal-processing.js +6 -6
  34. package/dist/signals.js +6 -6
  35. package/dist/site-builder/build.js +103 -103
  36. package/dist/site-builder/index.js +44 -44
  37. package/dist/ssg.js +19 -19
  38. package/dist/ssr.js +89 -89
  39. package/dist/story/cli.js +42 -42
  40. package/dist/story/commands/dev.js +42 -42
  41. package/dist/story/commands/index.js +42 -42
  42. package/dist/story/index.js +42 -42
  43. package/dist/story/renderer.js +102 -102
  44. package/dist/story/server.js +42 -42
  45. package/dist/story/visual-testing.js +102 -102
  46. package/dist/streaming.js +38 -38
  47. package/dist/template-compiler.js +30 -30
  48. package/dist/template-hydrator.js +116 -116
  49. package/dist/testing.js +101 -101
  50. package/dist/utils.js +38 -38
  51. package/dist/variable-extractor.js +11 -11
  52. package/dist/web-components.js +101 -101
  53. package/package.json +5 -5
@@ -778,8 +778,8 @@ ${H}
778
778
  filter: blur(0);
779
779
  transform: scale(1);
780
780
  }
781
- `.trim();M4=new Map});import{createHash as x6}from"crypto";import{readFile as DJ,stat as f6}from"fs/promises";async function R0($){try{let Z=await DJ($);return x6("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function v6($){return x6("sha256").update($).digest("hex").slice(0,16)}function p5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${v6($)}-${v6(Y)}`}async function D4($){try{return(await f6($)).mtimeMs}catch{return 0}}async function V0($){try{return await f6($),!0}catch{return!1}}var L1=()=>{};import{mkdir as EJ,readFile as kJ,writeFile as SJ,readdir as __,rm as bJ,stat as B_}from"fs/promises";import{join as h6,dirname as yJ}from"path";async function CJ($){try{await EJ($,{recursive:!0})}catch{}}function d6($,Z,Y){return h6($,Y,`${Z}.json`)}async function g6($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await D4(Z)!==$.srcMtime)return!1;return!0}async function l5($,Z,Y,X=E4){if(!X.enabled)return null;let Q=p5($,Z),J=h1.get(Q);if(J){if(await g6(J,$,X.maxAge))return J.lastAccessedAt=Date.now(),J.data;h1.delete(Q)}let G=d6(X.directory,Q,Y);if(await V0(G))try{let K=await kJ(G,"utf-8"),q=JSON.parse(K);if(await g6(q,$,X.maxAge))return q.lastAccessedAt=Date.now(),h1.set(Q,q),q.data}catch{}return null}async function c5($,Z,Y,X,Q=E4){if(!Q.enabled)return;let J=p5($,Z),G=await R0($),K=await D4($),q={key:J,src:$,srcHash:G,srcMtime:K,optionsHash:p5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};h1.set(J,q);let W=d6(Q.directory,J,X);try{await CJ(yJ(W)),await SJ(W,JSON.stringify(q,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function i5($,Z=E4){if($==="all")h1.clear();else h1.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let Q=h6(Z.directory,X);try{await bJ(Q,{recursive:!0,force:!0})}catch{}}}var h1,E4;var k4=y(()=>{L1();h1=new Map,E4={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class o5{config;constructor($={}){this.config={...PJ,...$}}async get($,Z){return l5($,Z,"image",this.config)}async set($,Z,Y){return c5($,Z,Y,"image",this.config)}async clear(){return i5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function S4($){if(!n5)n5=new o5($);else if($)n5.updateConfig($);return n5}async function s5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return S4(X).get($,Z)}async function r5($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return S4(Q).set($,Z,Y)}async function m6(){return S4().clear()}var PJ,n5=null;var b4=y(()=>{k4();PJ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as vJ,basename as xJ,extname as fJ,join as gJ}from"path";import{mkdir as hJ}from"fs/promises";async function y4(){try{return await import("ts-images")}catch{return null}}function u6($){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 dJ($,Z){let Y=Z?u6(Z):u6("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 p6($,Z,Y){let X=await y4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await s5($,Z,Y);if(Q)return Q;try{let J=vJ($);if(!await V0(J))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=dJ(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await hJ(K,{recursive:!0});let W=await R0(J),z=xJ($,fJ($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await C4(J,Z.transformations,X);for(let j of U){let H=G[j]||{},L=`${z}-${W}.${j}`,F=gJ(K,L);try{let O=await X.optimizeImage({input:B||J,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(J);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(J,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await r5($,Z,_,Y),_}catch(J){return{src:$,processed:!1,errors:[`Processing failed: ${J}`]}}}async function l6($,Z,Y,X){let Q=await y4();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(J){return{success:!1,error:String(J)}}}async function C4($,Z,Y){let X=Y||await y4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await X.decode($);for(let J of Z){let G=J.options||{};switch(J.type){case"resize":if(G.width||G.height)Q=await X.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await X.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await X.sharpen(Q,G.amount);break;case"grayscale":Q=await X.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await X.rotate(Q,G.angle);break;case"flip":Q=await X.flip(Q);break;case"flop":Q=await X.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await X.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await X.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await X.saturation(Q,G.value);break}}return await X.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var c6=y(()=>{L1();b4()});import{resolve as mJ,basename as uJ,extname as pJ,join as lJ}from"path";import{mkdir as cJ}from"fs/promises";async function iJ(){try{return await import("ts-images")}catch{return null}}async function i6($,Z,Y){let X=await iJ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=mJ($);if(!await V0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let J=Z.responsiveWidths||Y.breakpoints||nJ,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await cJ(K,{recursive:!0});let W=await R0(Q),z=uJ($,pJ($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of J){let F=`${z}-${L}w-${W}.${j}`,O=lJ(K,F),V=`${q}/${F}`;try{let w=U[j]?.quality||80;if(await V0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let A=await X.processImage({input:Q,output:O,format:j,quality:w,resize:{width:L}});if(A)_.byFormat[j].push({path:O,url:V,width:L,height:A.height||Math.round(L*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await X.generateThumbHash(Q);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(Q,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||oJ(J),_}catch(J){return console.error(`[stx-media] Responsive generation failed: ${J}`),null}}function oJ($){let Z=[...$].sort((X,Q)=>X-Q),Y=[];for(let X=0;X<Z.length-1;X++){let Q=Z[X];Y.push(`(max-width: ${Q}px) ${Q}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function n6($,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 nJ;var o6=y(()=>{L1();nJ=[320,480,640,768,1024,1280,1536,1920]});var s6={};s(s6,{setCachedImageResult:()=>r5,processImage:()=>p6,optimizeImage:()=>l6,getCachedImageResult:()=>s5,generateSrcset:()=>n6,generateResponsiveVariants:()=>i6,clearImageCache:()=>m6,applyTransformations:()=>C4,ImageProcessorCache:()=>o5});var r6=y(()=>{c6();o6();b4()});async function sJ(){try{return await Promise.resolve().then(() => (r6(),s6))}catch($){if(!a6)console.warn("[stx-media] Image processor not available, some features disabled:",$),a6=!0;return null}}async function a5($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return eJ(X,Y)}if(Y.processedResult?.processed)return f4($,Y.processedResult,Z);if(Y.responsiveVariants)return Z9($,Y.responsiveVariants,Z);let{src:Q,alt:J,width:G,height:K,sizes:q,widths:W=g1,dpr:z,formats:U=z5,quality:_=P4,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":e5,decoding:V=t5,fetchpriority:w,objectFit:A,objectPosition:R,crossorigin:N,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:C=!1,baseUrl:k=""}=Z;if(C&&!Z.optimize)return tJ($);let S,P,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{S=await C6(Q,{strategy:j,...H}),P=y6(d,S,H)}catch{}let f=z!==void 0&&G!==void 0,m;if(f)m=aJ($,d,S,Z);else m=await rJ($,d,S,Z);let n;if(F){let S0=U.includes("webp")?"webp":U[0],M0=A4(Q,W,{...B,q:_},S0),e=typeof q==="object"?R4(q):q||"100vw";n=`<link rel="preload" as="image" imagesrcset="${M0}" imagesizes="${e}" />`}let A0=[];if(!t6&&j!=="none")A0.push(I4),t6=!0;if(P)A0.push(P);let o0=L?$9(d):void 0;return{html:m,preloadLink:n,css:A0.length>0?A0.join(`
782
- `):void 0,script:o0}}async function rJ($,Z,Y,X){let{src:Q,alt:J,width:G,height:K,sizes:q,widths:W=g1,formats:z=z5,quality:U=P4,params:_={},lazy:B=!0,priority:j=!1,loading:H=j?"eager":e5,decoding:L=t5,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,R=$.class,N=$.style,T=$.data||{},M=typeof q==="object"?R4(q):q||"100vw",I=[];for(let C of z){let k=A4(Q,W,{..._,q:U},C),S=N4(C);if(B&&!j)I.push(` <source type="${S}" data-srcset="${k}" data-sizes="${M}" />`);else I.push(` <source type="${S}" srcset="${k}" sizes="${M}" />`)}let D=v4({src:W5(Q,{..._,q:U}),alt:J,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A,className:e6(R,Y),style:x4(N,O,V,Y),lazy:B&&!j,data:T}),E;if(Y){let C=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${C}">
781
+ `.trim();M4=new Map});import{createHash as x6}from"crypto";import{readFile as DJ,stat as f6}from"fs/promises";async function N0($){try{let Z=await DJ($);return x6("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function v6($){return x6("sha256").update($).digest("hex").slice(0,16)}function p5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${v6($)}-${v6(Y)}`}async function D4($){try{return(await f6($)).mtimeMs}catch{return 0}}async function V0($){try{return await f6($),!0}catch{return!1}}var L1=()=>{};import{mkdir as EJ,readFile as kJ,writeFile as SJ,readdir as __,rm as bJ,stat as B_}from"fs/promises";import{join as h6,dirname as yJ}from"path";async function CJ($){try{await EJ($,{recursive:!0})}catch{}}function d6($,Z,Y){return h6($,Y,`${Z}.json`)}async function g6($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await D4(Z)!==$.srcMtime)return!1;return!0}async function l5($,Z,Y,X=E4){if(!X.enabled)return null;let Q=p5($,Z),J=h1.get(Q);if(J){if(await g6(J,$,X.maxAge))return J.lastAccessedAt=Date.now(),J.data;h1.delete(Q)}let G=d6(X.directory,Q,Y);if(await V0(G))try{let K=await kJ(G,"utf-8"),q=JSON.parse(K);if(await g6(q,$,X.maxAge))return q.lastAccessedAt=Date.now(),h1.set(Q,q),q.data}catch{}return null}async function c5($,Z,Y,X,Q=E4){if(!Q.enabled)return;let J=p5($,Z),G=await N0($),K=await D4($),q={key:J,src:$,srcHash:G,srcMtime:K,optionsHash:p5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};h1.set(J,q);let W=d6(Q.directory,J,X);try{await CJ(yJ(W)),await SJ(W,JSON.stringify(q,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function i5($,Z=E4){if($==="all")h1.clear();else h1.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let Q=h6(Z.directory,X);try{await bJ(Q,{recursive:!0,force:!0})}catch{}}}var h1,E4;var k4=y(()=>{L1();h1=new Map,E4={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class o5{config;constructor($={}){this.config={...PJ,...$}}async get($,Z){return l5($,Z,"image",this.config)}async set($,Z,Y){return c5($,Z,Y,"image",this.config)}async clear(){return i5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function S4($){if(!n5)n5=new o5($);else if($)n5.updateConfig($);return n5}async function s5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return S4(X).get($,Z)}async function r5($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return S4(Q).set($,Z,Y)}async function m6(){return S4().clear()}var PJ,n5=null;var b4=y(()=>{k4();PJ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as vJ,basename as xJ,extname as fJ,join as gJ}from"path";import{mkdir as hJ}from"fs/promises";async function y4(){try{return await import("ts-images")}catch{return null}}function u6($){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 dJ($,Z){let Y=Z?u6(Z):u6("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 p6($,Z,Y){let X=await y4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let Q=await s5($,Z,Y);if(Q)return Q;try{let J=vJ($);if(!await V0(J))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=dJ(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await hJ(K,{recursive:!0});let W=await N0(J),z=xJ($,fJ($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await C4(J,Z.transformations,X);for(let j of U){let H=G[j]||{},L=`${z}-${W}.${j}`,F=gJ(K,L);try{let O=await X.optimizeImage({input:B||J,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(J);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(J,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await r5($,Z,_,Y),_}catch(J){return{src:$,processed:!1,errors:[`Processing failed: ${J}`]}}}async function l6($,Z,Y,X){let Q=await y4();if(!Q)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await Q.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(J){return{success:!1,error:String(J)}}}async function C4($,Z,Y){let X=Y||await y4();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let Q=await X.decode($);for(let J of Z){let G=J.options||{};switch(J.type){case"resize":if(G.width||G.height)Q=await X.resize(Q,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)Q=await X.blur(Q,G.sigma);break;case"sharpen":if(G.amount!==void 0)Q=await X.sharpen(Q,G.amount);break;case"grayscale":Q=await X.grayscale(Q);break;case"rotate":if(G.angle!==void 0)Q=await X.rotate(Q,G.angle);break;case"flip":Q=await X.flip(Q);break;case"flop":Q=await X.flop(Q);break;case"brightness":if(G.value!==void 0)Q=await X.brightness(Q,G.value);break;case"contrast":if(G.value!==void 0)Q=await X.contrast(Q,G.value);break;case"saturation":if(G.value!==void 0)Q=await X.saturation(Q,G.value);break}}return await X.encode(Q,"png")}catch(Q){return console.error(`[stx-media] Transformation failed: ${Q}`),null}}var c6=y(()=>{L1();b4()});import{resolve as mJ,basename as uJ,extname as pJ,join as lJ}from"path";import{mkdir as cJ}from"fs/promises";async function iJ(){try{return await import("ts-images")}catch{return null}}async function i6($,Z,Y){let X=await iJ();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let Q=mJ($);if(!await V0(Q))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let J=Z.responsiveWidths||Y.breakpoints||nJ,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await cJ(K,{recursive:!0});let W=await N0(Q),z=uJ($,pJ($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of J){let F=`${z}-${L}w-${W}.${j}`,O=lJ(K,F),V=`${q}/${F}`;try{let w=U[j]?.quality||80;if(await V0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let A=await X.processImage({input:Q,output:O,format:j,quality:w,resize:{width:L}});if(A)_.byFormat[j].push({path:O,url:V,width:L,height:A.height||Math.round(L*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await X.generateThumbHash(Q);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(Q,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||oJ(J),_}catch(J){return console.error(`[stx-media] Responsive generation failed: ${J}`),null}}function oJ($){let Z=[...$].sort((X,Q)=>X-Q),Y=[];for(let X=0;X<Z.length-1;X++){let Q=Z[X];Y.push(`(max-width: ${Q}px) ${Q}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function n6($,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 nJ;var o6=y(()=>{L1();nJ=[320,480,640,768,1024,1280,1536,1920]});var s6={};s(s6,{setCachedImageResult:()=>r5,processImage:()=>p6,optimizeImage:()=>l6,getCachedImageResult:()=>s5,generateSrcset:()=>n6,generateResponsiveVariants:()=>i6,clearImageCache:()=>m6,applyTransformations:()=>C4,ImageProcessorCache:()=>o5});var r6=y(()=>{c6();o6();b4()});async function sJ(){try{return await Promise.resolve().then(() => (r6(),s6))}catch($){if(!a6)console.warn("[stx-media] Image processor not available, some features disabled:",$),a6=!0;return null}}async function a5($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return eJ(X,Y)}if(Y.processedResult?.processed)return f4($,Y.processedResult,Z);if(Y.responsiveVariants)return Z9($,Y.responsiveVariants,Z);let{src:Q,alt:J,width:G,height:K,sizes:q,widths:W=g1,dpr:z,formats:U=z5,quality:_=P4,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":e5,decoding:V=t5,fetchpriority:w,objectFit:A,objectPosition:R,crossorigin:N,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:C=!1,baseUrl:k=""}=Z;if(C&&!Z.optimize)return tJ($);let b,P,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await C6(Q,{strategy:j,...H}),P=y6(d,b,H)}catch{}let f=z!==void 0&&G!==void 0,m;if(f)m=aJ($,d,b,Z);else m=await rJ($,d,b,Z);let n;if(F){let S0=U.includes("webp")?"webp":U[0],I0=A4(Q,W,{...B,q:_},S0),e=typeof q==="object"?R4(q):q||"100vw";n=`<link rel="preload" as="image" imagesrcset="${I0}" imagesizes="${e}" />`}let A0=[];if(!t6&&j!=="none")A0.push(I4),t6=!0;if(P)A0.push(P);let o0=L?$9(d):void 0;return{html:m,preloadLink:n,css:A0.length>0?A0.join(`
782
+ `):void 0,script:o0}}async function rJ($,Z,Y,X){let{src:Q,alt:J,width:G,height:K,sizes:q,widths:W=g1,formats:z=z5,quality:U=P4,params:_={},lazy:B=!0,priority:j=!1,loading:H=j?"eager":e5,decoding:L=t5,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,R=$.class,N=$.style,T=$.data||{},M=typeof q==="object"?R4(q):q||"100vw",I=[];for(let C of z){let k=A4(Q,W,{..._,q:U},C),b=N4(C);if(B&&!j)I.push(` <source type="${b}" data-srcset="${k}" data-sizes="${M}" />`);else I.push(` <source type="${b}" srcset="${k}" sizes="${M}" />`)}let D=v4({src:W5(Q,{..._,q:U}),alt:J,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:A,className:e6(R,Y),style:x4(N,O,V,Y),lazy:B&&!j,data:T}),E;if(Y){let C=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${C}">
783
783
  <picture>
784
784
  ${I.join(`
785
785
  `)}
@@ -838,12 +838,12 @@ ${A.join(`
838
838
  ${A.join(`
839
839
  `)}
840
840
  <img ${N.join(" ")} />
841
- </picture>`;let C=[];if(Z.placeholder)C.push(I4);let k=G?$9(j):void 0,S;if(K&&V)S=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:E,preloadLink:S,css:C.length>0?C.join(`
841
+ </picture>`;let C=[];if(Z.placeholder)C.push(I4);let k=G?$9(j):void 0,b;if(K&&V)b=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:E,preloadLink:b,css:C.length>0?C.join(`
842
842
  `):void 0,script:k}}async function Z9($,Z,Y){let X={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[Q,J]of Object.entries(Z.byFormat))if(J)X.variants.push(...J);return f4($,X,Y)}var a6=!1,P4=80,t5="async",e5="lazy",t6=!1;var Y9=y(()=>{T4();P6()});function $Q(){return u5({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,X)=>{let{src:Q,alt:J,options:G}=ZQ($,Z,Y);if(!Q)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:Q,alt:J||"",widths:G.widths||g1,formats:G.formats||z5,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},q=Y.__isDev||!1,W=await a5(K,{isDev:q}),z=W.html;if(W.preloadLink)z=W.preloadLink+`
843
843
  `+z;if(W.css)z+=`
844
844
  <style>${W.css}</style>`;if(W.script)z+=`
845
- <script>${W.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function ZQ($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=$.trim();if(X.startsWith("@img(")||X.startsWith("("))X=X.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=YQ(X),J=g4(Q[0],Y)||"",G=g4(Q[1],Y)||"",K={};if(Q[2]){let q=g4(Q[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof Q[2]==="string")try{K=JSON.parse(Q[2])}catch{}}return{src:J,alt:G,options:K}}function YQ($){let Z=[],Y="",X=!1,Q="",J=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],W=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&W!=="\\"){if(!X)X=!0,Q=q;else if(q===Q)X=!1,Q="";else Y+=q;continue}if(!X){if(q==="{")J++;if(q==="}")J--;if(q==="[")G++;if(q==="]")G--;if(q===","&&J===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function g4($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let X=Z[Y];if(X!==void 0)return X}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var X9;var J9=y(()=>{w4();Y9();T4();X9=$Q()});class Z${config;constructor($={}){this.config={...XQ,...$}}async get($,Z){return l5($,Z,"video",this.config)}async set($,Z,Y){return c5($,Z,Y,"video",this.config)}async clear(){return i5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function h4($){if(!$$)$$=new Z$($);else if($)$$.updateConfig($);return $$}async function Y$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return h4(X).get($,Z)}async function X$($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return h4(Q).set($,Z,Y)}async function Q9(){return h4().clear()}var XQ,$$=null;var d4=y(()=>{k4();XQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as m4,basename as u4,extname as p4,join as J$}from"path";import{mkdir as l4}from"fs/promises";async function c4(){try{return await import("ts-videos")}catch{return null}}async function Q$($,Z,Y,X){let Q=await c4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let J=m4($);if(!await V0(J))return null;await l4(Y,{recursive:!0});let G=await R0(J),K=u4($,p4($)),q=Z.format||"webp",W=Z.timestamp||0,z=`${K}-poster-${G}.${q}`,U=J$(Y,z),_=await Q.extractThumbnails(J,{timestamps:[W],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:z.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:U,url:`${X}/${z}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:W,size:B.size||0}}return null}catch(J){return console.warn(`[stx-media] Failed to generate poster: ${J}`),null}}async function G$($,Z,Y,X){let Q=await c4();if(!Q)return[];try{let J=m4($);if(!await V0(J))return[];await l4(Y,{recursive:!0});let G=await R0(J),K=u4($,p4($)),q=Z.format||"webp",U=(await new Q.Input(J).getInfo()).duration||60,_=Z.count||10,B=Z.interval||U/_,j=[];for(let L=0;L<_&&L*B<U;L++)j.push(L*B);let H=await Q.extractThumbnails(J,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||J$(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${X}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(J){return console.warn(`[stx-media] Failed to generate thumbnails: ${J}`),[]}}async function G9($,Z,Y,X){let Q=await c4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let J=m4($);if(!await V0(J))return null;await l4(Y,{recursive:!0});let G=await R0(J),K=u4($,p4($)),z=(await new Q.Input(J).getInfo()).duration||60,U=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(z/_),F=Math.ceil(L/U),O=`${K}-sprite-${G}.${H}`,V=J$(Y,O),w=[];for(let R=0;R<L;R++)w.push(R*_);let A=await Q.extractThumbnails(J,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:J$(Y,".temp")});if(!A||A.length===0)return null;try{let R=await import("ts-images"),N=U*B,T=F*j,M=await R.createSprite({images:A.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:U,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(J){return console.warn(`[stx-media] Failed to generate sprite sheet: ${J}`),null}}var i4=y(()=>{L1()});import{resolve as q9,basename as z9,extname as W9,join as F1}from"path";import{mkdir as K$,writeFile as U9}from"fs/promises";async function _9(){try{return await import("ts-videos")}catch{return null}}async function q$($,Z,Y,X,Q){let J=await _9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=q9($);if(!await V0(G))return null;let K=await R0(G),q=z9($,W9($)),W=F1(Y,`${q}-${K}-hls`);await K$(W,{recursive:!0});let z=Z.length>0?Z:B9,U=Q?.segmentDuration||6,j=(await new J.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of z){let w=F1(W,V.label);await K$(w,{recursive:!0});let A=`${V.label}.m3u8`,R=F1(w,A);try{let N=await J.generateHLS(G,{outputDir:w,segmentDuration:U,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(N)H.push({quality:V,url:`${X}/${q}-${K}-hls/${V.label}/${A}`,path:R}),L+=N.segmentCount||Math.ceil(j/U)}catch(N){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${N}`)}}if(H.length===0)return null;let F=F1(W,"master.m3u8"),O=JQ(H,X,q,K);return await U9(F,O),{manifestUrl:`${X}/${q}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function JQ($,Z,Y,X){let Q=["#EXTM3U","#EXT-X-VERSION:3"];for(let J of $){let{quality:G}=J,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;Q.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return Q.join(`
846
- `)}async function z$($,Z,Y,X,Q){let J=await _9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=q9($);if(!await V0(G))return null;let K=await R0(G),q=z9($,W9($)),W=F1(Y,`${q}-${K}-dash`);await K$(W,{recursive:!0});let z=Z.length>0?Z:B9,U=Q?.segmentDuration||4,_=Q?.minBufferTime||2,H=(await new J.Input(G).getInfo()).duration||0,L=[],F=[];for(let A of z){let R=F1(W,A.label);await K$(R,{recursive:!0});try{if(await J.generateDASH(G,{outputDir:R,segmentDuration:U,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(L.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${X}/${q}-${K}-dash/${A.label}/video`}),A.audioBitrate)F.push({bandwidth:A.audioBitrate,url:`${X}/${q}-${K}-dash/${A.label}/audio`})}}catch(N){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${N}`)}}if(L.length===0)return null;let O=F1(W,"manifest.mpd"),V=QQ(L,F,H,U,_);await U9(O,V);let w=[{type:"video",representations:L}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${X}/${q}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function QQ($,Z,Y,X,Q){let J=K9(Y),G=K9(Q),K=`<?xml version="1.0" encoding="UTF-8"?>
845
+ <script>${W.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function ZQ($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let X=$.trim();if(X.startsWith("@img(")||X.startsWith("("))X=X.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=YQ(X),J=g4(Q[0],Y)||"",G=g4(Q[1],Y)||"",K={};if(Q[2]){let q=g4(Q[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof Q[2]==="string")try{K=JSON.parse(Q[2])}catch{}}return{src:J,alt:G,options:K}}function YQ($){let Z=[],Y="",X=!1,Q="",J=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],W=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&W!=="\\"){if(!X)X=!0,Q=q;else if(q===Q)X=!1,Q="";else Y+=q;continue}if(!X){if(q==="{")J++;if(q==="}")J--;if(q==="[")G++;if(q==="]")G--;if(q===","&&J===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function g4($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let X=Z[Y];if(X!==void 0)return X}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var X9;var J9=y(()=>{w4();Y9();T4();X9=$Q()});class Z${config;constructor($={}){this.config={...XQ,...$}}async get($,Z){return l5($,Z,"video",this.config)}async set($,Z,Y){return c5($,Z,Y,"video",this.config)}async clear(){return i5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function h4($){if(!$$)$$=new Z$($);else if($)$$.updateConfig($);return $$}async function Y$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return h4(X).get($,Z)}async function X$($,Z,Y,X){let Q=X?{directory:`${X.outputDir}/../.cache`}:{};return h4(Q).set($,Z,Y)}async function Q9(){return h4().clear()}var XQ,$$=null;var d4=y(()=>{k4();XQ={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as m4,basename as u4,extname as p4,join as J$}from"path";import{mkdir as l4}from"fs/promises";async function c4(){try{return await import("ts-videos")}catch{return null}}async function Q$($,Z,Y,X){let Q=await c4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let J=m4($);if(!await V0(J))return null;await l4(Y,{recursive:!0});let G=await N0(J),K=u4($,p4($)),q=Z.format||"webp",W=Z.timestamp||0,z=`${K}-poster-${G}.${q}`,U=J$(Y,z),_=await Q.extractThumbnails(J,{timestamps:[W],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:z.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:U,url:`${X}/${z}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:W,size:B.size||0}}return null}catch(J){return console.warn(`[stx-media] Failed to generate poster: ${J}`),null}}async function G$($,Z,Y,X){let Q=await c4();if(!Q)return[];try{let J=m4($);if(!await V0(J))return[];await l4(Y,{recursive:!0});let G=await N0(J),K=u4($,p4($)),q=Z.format||"webp",U=(await new Q.Input(J).getInfo()).duration||60,_=Z.count||10,B=Z.interval||U/_,j=[];for(let L=0;L<_&&L*B<U;L++)j.push(L*B);let H=await Q.extractThumbnails(J,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||J$(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${X}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(J){return console.warn(`[stx-media] Failed to generate thumbnails: ${J}`),[]}}async function G9($,Z,Y,X){let Q=await c4();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let J=m4($);if(!await V0(J))return null;await l4(Y,{recursive:!0});let G=await N0(J),K=u4($,p4($)),z=(await new Q.Input(J).getInfo()).duration||60,U=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(z/_),F=Math.ceil(L/U),O=`${K}-sprite-${G}.${H}`,V=J$(Y,O),w=[];for(let R=0;R<L;R++)w.push(R*_);let A=await Q.extractThumbnails(J,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:J$(Y,".temp")});if(!A||A.length===0)return null;try{let R=await import("ts-images"),N=U*B,T=F*j,M=await R.createSprite({images:A.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:U,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(J){return console.warn(`[stx-media] Failed to generate sprite sheet: ${J}`),null}}var i4=y(()=>{L1()});import{resolve as q9,basename as z9,extname as W9,join as F1}from"path";import{mkdir as K$,writeFile as U9}from"fs/promises";async function _9(){try{return await import("ts-videos")}catch{return null}}async function q$($,Z,Y,X,Q){let J=await _9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=q9($);if(!await V0(G))return null;let K=await N0(G),q=z9($,W9($)),W=F1(Y,`${q}-${K}-hls`);await K$(W,{recursive:!0});let z=Z.length>0?Z:B9,U=Q?.segmentDuration||6,j=(await new J.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of z){let w=F1(W,V.label);await K$(w,{recursive:!0});let A=`${V.label}.m3u8`,R=F1(w,A);try{let N=await J.generateHLS(G,{outputDir:w,segmentDuration:U,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(N)H.push({quality:V,url:`${X}/${q}-${K}-hls/${V.label}/${A}`,path:R}),L+=N.segmentCount||Math.ceil(j/U)}catch(N){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${N}`)}}if(H.length===0)return null;let F=F1(W,"master.m3u8"),O=JQ(H,X,q,K);return await U9(F,O),{manifestUrl:`${X}/${q}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function JQ($,Z,Y,X){let Q=["#EXTM3U","#EXT-X-VERSION:3"];for(let J of $){let{quality:G}=J,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;Q.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return Q.join(`
846
+ `)}async function z$($,Z,Y,X,Q){let J=await _9();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=q9($);if(!await V0(G))return null;let K=await N0(G),q=z9($,W9($)),W=F1(Y,`${q}-${K}-dash`);await K$(W,{recursive:!0});let z=Z.length>0?Z:B9,U=Q?.segmentDuration||4,_=Q?.minBufferTime||2,H=(await new J.Input(G).getInfo()).duration||0,L=[],F=[];for(let A of z){let R=F1(W,A.label);await K$(R,{recursive:!0});try{if(await J.generateDASH(G,{outputDir:R,segmentDuration:U,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(L.push({bandwidth:A.bitrate,width:A.width,height:A.height||Math.round(A.width*9/16),url:`${X}/${q}-${K}-dash/${A.label}/video`}),A.audioBitrate)F.push({bandwidth:A.audioBitrate,url:`${X}/${q}-${K}-dash/${A.label}/audio`})}}catch(N){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${N}`)}}if(L.length===0)return null;let O=F1(W,"manifest.mpd"),V=QQ(L,F,H,U,_);await U9(O,V);let w=[{type:"video",representations:L}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${X}/${q}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function QQ($,Z,Y,X,Q){let J=K9(Y),G=K9(Q),K=`<?xml version="1.0" encoding="UTF-8"?>
847
847
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
848
848
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
849
849
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
@@ -869,11 +869,11 @@ ${A.join(`
869
869
  </Representation>
870
870
  `}K+=` </AdaptationSet>
871
871
  `}return K+=` </Period>
872
- </MPD>`,K}function K9($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),Q="PT";if(Z>0)Q+=`${Z}H`;if(Y>0)Q+=`${Y}M`;return Q+=`${X}S`,Q}var B9;var n4=y(()=>{L1();B9=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as j9,basename as GQ,extname as KQ,join as qQ}from"path";import{mkdir as zQ}from"fs/promises";async function H9(){try{return await import("ts-videos")}catch{return null}}function WQ($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function UQ($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function o4($){let Z=await H9();if(!Z)return null;try{let Y=j9($),Q=await new Z.Input(Y).getInfo();return{duration:Q.duration||0,width:Q.width||0,height:Q.height||0,frameRate:Q.frameRate||0,bitrate:Q.bitrate||0,codec:Q.videoCodec||"",audioCodec:Q.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function O9($,Z,Y,X){let Q=await H9();if(!Q)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let J=await Y$($,Z,Y);if(J)return J;try{let G=j9($);if(!await V0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await zQ(K,{recursive:!0});let W=await R0(G),z=GQ($,KQ($)),U={src:$,processed:!0,hash:W};X?.({percentage:5,stage:"analyzing"}),U.metadata=await o4(G)||void 0;let _={};if(Z.quality)_.bitrate=WQ(Z.quality);if(Z.platform)Object.assign(_,UQ(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let B=`${z}-${W}.mp4`,j=qQ(K,B);try{let H=await _Q(G,j,_,Q,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)U.transcoded={path:j,url:`${q}/${B}`,duration:H.duration,size:H.size,video:{codec:_.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(H){U.errors=U.errors||[],U.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await Q$(G,B,K,q);if(j)U.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let B=await G$(G,Y.thumbnails,K,q);if(B.length>0)U.thumbnails=B}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await q$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,hls:j}}if(B.format==="dash"){let j=await z$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await X$($,Z,U,Y),U}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function _Q($,Z,Y,X,Q){try{let G=await new X.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{Q?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(J){return console.error(`[stx-media] Transcoding failed: ${J}`),null}}var L9=y(()=>{L1();d4();i4();n4()});var F9={};s(F9,{setCachedVideoResult:()=>X$,processVideo:()=>O9,getCachedVideoResult:()=>Y$,generateThumbnails:()=>G$,generateSpriteSheet:()=>G9,generatePoster:()=>Q$,generateHLSManifest:()=>q$,generateDASHManifest:()=>z$,clearVideoCache:()=>Q9,analyzeVideo:()=>o4,VideoProcessorCache:()=>Z$});var V9=y(()=>{L9();i4();n4();d4()});async function A9(){try{return await Promise.resolve().then(() => (V9(),F9))}catch($){if(!w9)console.warn("[stx-media] Video processor not available, some features disabled:",$),w9=!0;return null}}async function W$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return FQ(X,Y)}if(Y.processedResult?.processed)return M9($,Y.processedResult,Z);let Q;if(X.generatePoster&&X.src&&!$.poster)Q=await VQ(X,Y);let{src:J,sources:G=[],poster:K,posterPlaceholder:q,controls:W=R9,autoplay:z=!1,muted:U=!1,loop:_=!1,preload:B=N9,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:R=!1}=$,N=Q||K,T=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return HQ($,Z);if(F&&F!=="video")return jQ(J||"",F,$);let D=G.length>0?G:J?[{src:J,type:T9(J)}]:[],E=[`id="${I}"`];if(W)E.push("controls");if(z)E.push("autoplay");if(U)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(A)E.push("disablepictureinpicture");if(R)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),N)E.push(`data-poster="${_0(N)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),N)E.push(`poster="${_0(N)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(T)E.push(`class="${_0(T)}"`);if(M)E.push(`style="${_0(M)}"`);let C=D.map((P)=>{return` <source ${H?`data-src="${_0(P.src)}"`:`src="${_0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
872
+ </MPD>`,K}function K9($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),Q="PT";if(Z>0)Q+=`${Z}H`;if(Y>0)Q+=`${Y}M`;return Q+=`${X}S`,Q}var B9;var n4=y(()=>{L1();B9=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as j9,basename as GQ,extname as KQ,join as qQ}from"path";import{mkdir as zQ}from"fs/promises";async function H9(){try{return await import("ts-videos")}catch{return null}}function WQ($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function UQ($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function o4($){let Z=await H9();if(!Z)return null;try{let Y=j9($),Q=await new Z.Input(Y).getInfo();return{duration:Q.duration||0,width:Q.width||0,height:Q.height||0,frameRate:Q.frameRate||0,bitrate:Q.bitrate||0,codec:Q.videoCodec||"",audioCodec:Q.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function O9($,Z,Y,X){let Q=await H9();if(!Q)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let J=await Y$($,Z,Y);if(J)return J;try{let G=j9($);if(!await V0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await zQ(K,{recursive:!0});let W=await N0(G),z=GQ($,KQ($)),U={src:$,processed:!0,hash:W};X?.({percentage:5,stage:"analyzing"}),U.metadata=await o4(G)||void 0;let _={};if(Z.quality)_.bitrate=WQ(Z.quality);if(Z.platform)Object.assign(_,UQ(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let B=`${z}-${W}.mp4`,j=qQ(K,B);try{let H=await _Q(G,j,_,Q,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)U.transcoded={path:j,url:`${q}/${B}`,duration:H.duration,size:H.size,video:{codec:_.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(H){U.errors=U.errors||[],U.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await Q$(G,B,K,q);if(j)U.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let B=await G$(G,Y.thumbnails,K,q);if(B.length>0)U.thumbnails=B}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await q$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,hls:j}}if(B.format==="dash"){let j=await z$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await X$($,Z,U,Y),U}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function _Q($,Z,Y,X,Q){try{let G=await new X.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{Q?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(J){return console.error(`[stx-media] Transcoding failed: ${J}`),null}}var L9=y(()=>{L1();d4();i4();n4()});var F9={};s(F9,{setCachedVideoResult:()=>X$,processVideo:()=>O9,getCachedVideoResult:()=>Y$,generateThumbnails:()=>G$,generateSpriteSheet:()=>G9,generatePoster:()=>Q$,generateHLSManifest:()=>q$,generateDASHManifest:()=>z$,clearVideoCache:()=>Q9,analyzeVideo:()=>o4,VideoProcessorCache:()=>Z$});var V9=y(()=>{L9();i4();n4();d4()});async function A9(){try{return await Promise.resolve().then(() => (V9(),F9))}catch($){if(!w9)console.warn("[stx-media] Video processor not available, some features disabled:",$),w9=!0;return null}}async function W$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return FQ(X,Y)}if(Y.processedResult?.processed)return M9($,Y.processedResult,Z);let Q;if(X.generatePoster&&X.src&&!$.poster)Q=await VQ(X,Y);let{src:J,sources:G=[],poster:K,posterPlaceholder:q,controls:W=R9,autoplay:z=!1,muted:U=!1,loop:_=!1,preload:B=N9,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:R=!1}=$,N=Q||K,T=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return HQ($,Z);if(F&&F!=="video")return jQ(J||"",F,$);let D=G.length>0?G:J?[{src:J,type:T9(J)}]:[],E=[`id="${I}"`];if(W)E.push("controls");if(z)E.push("autoplay");if(U)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(A)E.push("disablepictureinpicture");if(R)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),N)E.push(`data-poster="${_0(N)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),N)E.push(`poster="${_0(N)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(T)E.push(`class="${_0(T)}"`);if(M)E.push(`style="${_0(M)}"`);let C=D.map((P)=>{return` <source ${H?`data-src="${_0(P.src)}"`:`src="${_0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
873
873
  `),k=`<video ${E.join(" ")}>
874
874
  ${C}
875
875
  Your browser does not support the video tag.
876
- </video>`,S;if(H)S=`
876
+ </video>`,b;if(H)b=`
877
877
  (function() {
878
878
  var video = document.getElementById('${I}');
879
879
  if (!video) return;
@@ -908,7 +908,7 @@ ${C}
908
908
 
909
909
  observer.observe(video);
910
910
  })();
911
- `.trim();return{html:k,script:S}}function jQ($,Z,Y){let{width:X=640,height:Q=360}=Y,J=Y.class,G=Y.style,K=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,q,W=null;switch(Z){case"youtube":W=OQ($),q=W?`https://www.youtube-nocookie.com/embed/${W}`:$;break;case"vimeo":W=LQ($),q=W?`https://player.vimeo.com/video/${W}`:$;break;case"dailymotion":W=$.split("/").pop()||"",q=`https://www.dailymotion.com/embed/video/${W}`;break;case"twitch":W=$.split("/").pop()||"",q=`https://player.twitch.tv/?video=${W}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:q=$}let z=[`id="${K}"`,`src="${_0(q)}"`,`width="${X}"`,`height="${Q}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(J)z.push(`class="${_0(J)}"`);if(G)z.push(`style="${_0(G)}"`);if(Y.lazy)z.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
911
+ `.trim();return{html:k,script:b}}function jQ($,Z,Y){let{width:X=640,height:Q=360}=Y,J=Y.class,G=Y.style,K=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,q,W=null;switch(Z){case"youtube":W=OQ($),q=W?`https://www.youtube-nocookie.com/embed/${W}`:$;break;case"vimeo":W=LQ($),q=W?`https://player.vimeo.com/video/${W}`:$;break;case"dailymotion":W=$.split("/").pop()||"",q=`https://www.dailymotion.com/embed/video/${W}`;break;case"twitch":W=$.split("/").pop()||"",q=`https://player.twitch.tv/?video=${W}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:q=$}let z=[`id="${K}"`,`src="${_0(q)}"`,`width="${X}"`,`height="${Q}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(J)z.push(`class="${_0(J)}"`);if(G)z.push(`style="${_0(G)}"`);if(Y.lazy)z.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
912
912
  <iframe ${z.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
913
913
  </div>`}}function HQ($,Z={}){let{src:Y,sources:X=[],poster:Q,controls:J=!0,autoplay:G=!1,muted:K=!1,loop:q=!1,preload:W="metadata",playsinline:z=!0,lazy:U=!0,width:_,height:B}=$,j=$.class,H=$.style,L=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,F={src:X.length>0?X:Y,autoplay:G,loop:q,muted:K,playsinline:z,preload:W,poster:Q,controls:J,title:$.title},O=["position: relative",_?`width: ${typeof _==="number"?_+"px":_}`:"width: 100%",B?`height: ${typeof B==="number"?B+"px":B}`:"",H||""].filter(Boolean).join("; "),V=`
914
914
  <div
@@ -1544,8 +1544,8 @@ ${z}
1544
1544
  customElements.define('${Z}', ${G});
1545
1545
  `}async function p9($,Z,Y,X){if(Z.length<1)return r("WebComponent","@webcomponent directive requires at least the tag name parameter",i.INVALID_DIRECTIVE_SYNTAX);let Q=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[B5.join(B5.dirname(X),G,`${Q}.stx`),B5.join(process.cwd(),G,`${Q}.stx`),B5.join(B5.dirname(X),`${Q}.stx`)],q=null;for(let U of K)if(await l(U)){q=await Bun.file(U).text();break}if(!q)return r("WebComponent",`Component file not found: ${Q}.stx`,i.FILE_NOT_FOUND);let W=gQ(q,Q);return`<script type="module">
1546
1546
  ${hQ(W)}
1547
- </script>`}var l9=y(()=>{a0();j0()});var c9={};s(c9,{timingPlugin:()=>lQ,pluginManager:()=>dQ,definePlugin:()=>F$,debugPlugin:()=>pQ,createVariablesPlugin:()=>cQ,createFilterPlugin:()=>uQ,createDirectivePlugin:()=>mQ,PluginManager:()=>J7});function F$($){return $}class J7{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let J=await Q(Y);if(J){if(J.template!==void 0)Y.template=J.template;if(J.context)Y.context={...Y.context,...J.context};if(J.metadata)Y.metadata={...Y.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${X.name}" ${$} hook:`,J)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return X}}function mQ($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function uQ($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function cQ($){return F$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var dQ,pQ,lQ;var i9=y(()=>{dQ=new J7;pQ=F$({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)}}),lQ=F$({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 o9={};s(o9,{validateConfig:()=>sQ,loadStxConfig:()=>w$,defineStxConfig:()=>oQ,defaultConfig:()=>w1,config:()=>G7});import Q7 from"fs";import N0 from"path";import{loadConfigWithResult as iQ}from"bunfig";function nQ($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=N0.join(process.cwd(),"resources","views"),Q=N0.join(process.cwd(),"resources","layouts");if(Q7.existsSync(X)&&Q7.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=N0.join(process.cwd(),"resources","views","pages");if(Q7.existsSync(J))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function w$($){if(!$){if(m1)return m1;if(V$)return V$}let Z=$?N0.resolve($):process.cwd(),Y=n9.get(Z);if(Y)return Y;let X=(async()=>{let J=(await iQ({name:"stx",alias:"ui",cwd:Z,defaultConfig:w1,verbose:!1})).config,G=nQ(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!N0.isAbsolute(J.partialsDir))J.partialsDir=N0.join(K,J.partialsDir);if(J.componentsDir&&!N0.isAbsolute(J.componentsDir))J.componentsDir=N0.join(K,J.componentsDir);if(J.layoutsDir&&!N0.isAbsolute(J.layoutsDir))J.layoutsDir=N0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (i9(),c9)),q=[],W=[];for(let z of J.plugins){let U=typeof z==="string"?z:z[0],_=typeof z==="string"?{}:z[1]||{};try{let B,j;try{B=await import(U),j=N0.dirname(G0.resolve(U))}catch{let L=N0.resolve(process.cwd(),U);B=await import(L),j=N0.dirname(L)}let H=B.default||B;if(K.register(H,J),H.components){let L=N0.resolve(j,H.components);q.push(L)}if(H.pages){let L=N0.resolve(j,H.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(F)},addRoute:(F,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[F]=O},addMiddleware:(F)=>{J.middleware=J.middleware||[],J.middleware.push(F)},pluginDir:j,config:J};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(B){console.warn(`[stx] Failed to load plugin ${U}:`,B.message)}}J._pluginComponentDirs=q,J._pluginPageDirs=W}return J})();if(n9.set(Z,X),!$)V$=X,X.then((Q)=>{m1=Q}).catch(()=>{});return X}function oQ($){return $}function sQ($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!X.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var w1,m1=null,n9,V$=null,G7;var j5=y(()=>{H4();O4();L4();F4();V4();J9();r4();S9();Y7();l9();w1={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:S6,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:p9,hasEndTag:!1,description:"Include a web component in the template"},j6,H6,m9,u9,O6,F6,V6,L6,N6,I6,X9,s4,...k9],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}};n9=new Map;G7=new Proxy(w1,{get($,Z){if(m1&&Z in m1)return m1[Z];if(!V$)w$().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import s9 from"fs";import X0 from"path";function z7($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function q7($,Z){if(A1.has($))A1.delete($);else if(A1.size>=rQ)A1.delete(A1.keys().next().value);A1.set($,Z)}async function aQ($){if(!$1)return null;try{let Z=Bun.file(X0.join($1,`cw-${z7($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function tQ($,Z){if(!$1)return;try{if(!s9.existsSync($1))s9.mkdirSync($1,{recursive:!0});await Bun.write(X0.join($1,`cw-${z7($)}.css`),Z)}catch{}}async function a9($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function eQ(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==X0.dirname(Y))$.push(X0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=X0.dirname(Y);if(Z){let X=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function $G(){if(r9)return H5;r9=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await a9(Y);if(X){if(H5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded`);return H5}}let Z=eQ();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await a9(Y);if(X){if(H5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(Y))}`);return H5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${L0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${L0.reset}`),console.warn(`${L0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${L0.reset}`),null}}async function ZG($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=X0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${L0.yellow}[Crosswind]${L0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function YG($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}J=Q.exec($)}return Z}async function XG($,Z){try{let Y=await $G();if(!Y)return"";let X=YG($);if(X.size===0)return"";let Q=Z?X0.resolve(Z):process.cwd();if(!$1)$1=X0.join(Q,".stx/cache");let J=[...X].sort().join(" "),G=`${K7||"default"}::${J}`,K=A1.get(G);if(K!==void 0)return q7(G,K),K;let q=await aQ(G);if(q!==null)return q7(G,q),q;if(!A$){let A=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (j5(),o9)),N=await R(Q);if(N.css)if(typeof N.css==="string"){let T=X0.isAbsolute(N.css)?N.css:X0.resolve(Q,N.css);if(await Bun.file(T).exists()){let M=await import(T);A=M.default||M,console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(A={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let T=X0.isAbsolute(N.css.config)?N.css.config:X0.resolve(Q,N.css.config);if(await Bun.file(T).exists()){let M=await import(T);A={...M.default||M,...A}}}console.log(`${L0.green}[Crosswind]${L0.reset} Using inline CSS config from stx.config.ts`)}}catch{}A$=A||await ZG(Q);try{K7=z7(JSON.stringify(A$??{}))}catch{K7="unhashable"}}let W=Y.defaultConfig||Y.config,z=A$||{},U=W.theme||{},B=(z.theme||{}).extend||{},j={...U};if(Object.keys(B).length>0)j.extend=B;let H=[...W.safelist||[],...z.safelist||[]],L={...W,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of X)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||z.shortcuts||{};for(let[A,R]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let N=R.split(/\s+/).filter(Boolean);for(let T of N)F.generate(T)}O=F.toCSS(!0,!1);let w=O.split(`
1548
- `);for(let[A,R]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let N=R.split(/\s+/).filter(Boolean),T=[],M=[];for(let I of N){let D=I.startsWith("dark:"),k=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let S=0;S<w.length;S++){let P=w[S].trim();if(P===`${k} {`||P.startsWith(`${k} {`)){let d=S,f="";while(d<w.length){if(f+=w[d],w[d].includes("}"))break;d++}let m=f.match(/\{([^}]+)\}/);if(m)if(D)M.push(m[1].trim());else T.push(m[1].trim());break}}}if(T.length)O+=`
1547
+ </script>`}var l9=y(()=>{a0();j0()});var c9={};s(c9,{timingPlugin:()=>lQ,pluginManager:()=>dQ,definePlugin:()=>F$,debugPlugin:()=>pQ,createVariablesPlugin:()=>cQ,createFilterPlugin:()=>uQ,createDirectivePlugin:()=>mQ,PluginManager:()=>J7});function F$($){return $}class J7{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let J=await Q(Y);if(J){if(J.template!==void 0)Y.template=J.template;if(J.context)Y.context={...Y.context,...J.context};if(J.metadata)Y.metadata={...Y.metadata,...J.metadata};if(J.skip)break}}catch(J){console.error(`Error in plugin "${X.name}" ${$} hook:`,J)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let Q of this.sortedPlugins){let J=Q[$];if(J)try{let G=await J(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${Q.name}" ${$} hook:`,G)}}return X}}function mQ($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function uQ($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function cQ($){return F$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var dQ,pQ,lQ;var i9=y(()=>{dQ=new J7;pQ=F$({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)}}),lQ=F$({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 o9={};s(o9,{validateConfig:()=>sQ,loadStxConfig:()=>w$,defineStxConfig:()=>oQ,defaultConfig:()=>w1,config:()=>G7});import Q7 from"fs";import T0 from"path";import{loadConfigWithResult as iQ}from"bunfig";function nQ($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=T0.join(process.cwd(),"resources","views"),Q=T0.join(process.cwd(),"resources","layouts");if(Q7.existsSync(X)&&Q7.existsSync(Q))return{root:"resources",pagesDir:"views"};let J=T0.join(process.cwd(),"resources","views","pages");if(Q7.existsSync(J))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function w$($){if(!$){if(m1)return m1;if(V$)return V$}let Z=$?T0.resolve($):process.cwd(),Y=n9.get(Z);if(Y)return Y;let X=(async()=>{let J=(await iQ({name:"stx",alias:"ui",cwd:Z,defaultConfig:w1,verbose:!1})).config,G=nQ(J.root,J.pagesDir);if(J.root=G.root,J.pagesDir=G.pagesDir,J.root&&J.root!=="."){let K=J.root;if(J.partialsDir&&!T0.isAbsolute(J.partialsDir))J.partialsDir=T0.join(K,J.partialsDir);if(J.componentsDir&&!T0.isAbsolute(J.componentsDir))J.componentsDir=T0.join(K,J.componentsDir);if(J.layoutsDir&&!T0.isAbsolute(J.layoutsDir))J.layoutsDir=T0.join(K,J.layoutsDir)}if(J.plugins&&J.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (i9(),c9)),q=[],W=[];for(let z of J.plugins){let U=typeof z==="string"?z:z[0],_=typeof z==="string"?{}:z[1]||{};try{let B,j;try{B=await import(U),j=T0.dirname(G0.resolve(U))}catch{let L=T0.resolve(process.cwd(),U);B=await import(L),j=T0.dirname(L)}let H=B.default||B;if(K.register(H,J),H.components){let L=T0.resolve(j,H.components);q.push(L)}if(H.pages){let L=T0.resolve(j,H.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{J.customDirectives=J.customDirectives||[],J.customDirectives.push(F)},addRoute:(F,O)=>{J.apiRoutes=J.apiRoutes||{},J.apiRoutes[F]=O},addMiddleware:(F)=>{J.middleware=J.middleware||[],J.middleware.push(F)},pluginDir:j,config:J};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(B){console.warn(`[stx] Failed to load plugin ${U}:`,B.message)}}J._pluginComponentDirs=q,J._pluginPageDirs=W}return J})();if(n9.set(Z,X),!$)V$=X,X.then((Q)=>{m1=Q}).catch(()=>{});return X}function oQ($){return $}function sQ($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${Q}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${Q}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,Q)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${Q}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${Q}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${Q}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((Q,J)=>{if(!Q.pattern||typeof Q.pattern!=="string")Z.push({path:`pwa.routes[${J}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(Q.strategy))Z.push({path:`pwa.routes[${J}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(Q.maxAgeSeconds!==void 0&&(typeof Q.maxAgeSeconds!=="number"||Q.maxAgeSeconds<0))Z.push({path:`pwa.routes[${J}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(Q.maxEntries!==void 0&&(typeof Q.maxEntries!=="number"||Q.maxEntries<1))Z.push({path:`pwa.routes[${J}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((Q)=>typeof Q!=="number"||Q<16||Q>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((J)=>!X.includes(J)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var w1,m1=null,n9,V$=null,G7;var j5=y(()=>{H4();O4();L4();F4();V4();J9();r4();S9();Y7();l9();w1={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:S6,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:p9,hasEndTag:!1,description:"Include a web component in the template"},j6,H6,m9,u9,O6,F6,V6,L6,N6,I6,X9,s4,...k9],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}};n9=new Map;G7=new Proxy(w1,{get($,Z){if(m1&&Z in m1)return m1[Z];if(!V$)w$().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import s9 from"fs";import X0 from"path";function z7($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function q7($,Z){if(A1.has($))A1.delete($);else if(A1.size>=rQ)A1.delete(A1.keys().next().value);A1.set($,Z)}async function aQ($){if(!$1)return null;try{let Z=Bun.file(X0.join($1,`cw-${z7($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function tQ($,Z){if(!$1)return;try{if(!s9.existsSync($1))s9.mkdirSync($1,{recursive:!0});await Bun.write(X0.join($1,`cw-${z7($)}.css`),Z)}catch{}}async function a9($){try{let Z=await import($);if(Z&&Z.CSSGenerator)return{CSSGenerator:Z.CSSGenerator,config:Z.config,build:Z.build,defaultConfig:Z.defaultConfig}}catch{}return null}function eQ(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==X0.dirname(Y))$.push(X0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(X0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(X0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=X0.dirname(Y);if(Z){let X=[X0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),X0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),X0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(X0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function $G(){if(r9)return H5;r9=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await a9(Y);if(X){if(H5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded`);return H5}}let Z=eQ();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await a9(Y);if(X){if(H5=X,!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} CSS engine loaded from ${X0.dirname(X0.dirname(Y))}`);return H5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${L0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${L0.reset}`),console.warn(`${L0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${L0.reset}`),null}}async function ZG($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=X0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${L0.yellow}[Crosswind]${L0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}function YG($){let Z=new Set,Y=/class\s*=\s*["']([^"']+)["']/gi,X=Y.exec($);while(X!==null){for(let G of X[1].split(/\s+/))if(G.trim())Z.add(G.trim());X=Y.exec($)}let Q=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,J=Q.exec($);while(J!==null){let G=J[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}J=Q.exec($)}return Z}async function XG($,Z){try{let Y=await $G();if(!Y)return"";let X=YG($);if(X.size===0)return"";let Q=Z?X0.resolve(Z):process.cwd();if(!$1)$1=X0.join(Q,".stx/cache");let J=[...X].sort().join(" "),G=`${K7||"default"}::${J}`,K=A1.get(G);if(K!==void 0)return q7(G,K),K;let q=await aQ(G);if(q!==null)return q7(G,q),q;if(!A$){let A=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (j5(),o9)),N=await R(Q);if(N.css)if(typeof N.css==="string"){let T=X0.isAbsolute(N.css)?N.css:X0.resolve(Q,N.css);if(await Bun.file(T).exists()){let M=await import(T);A=M.default||M,console.log(`${L0.green}[Crosswind]${L0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(A={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let T=X0.isAbsolute(N.css.config)?N.css.config:X0.resolve(Q,N.css.config);if(await Bun.file(T).exists()){let M=await import(T);A={...M.default||M,...A}}}console.log(`${L0.green}[Crosswind]${L0.reset} Using inline CSS config from stx.config.ts`)}}catch{}A$=A||await ZG(Q);try{K7=z7(JSON.stringify(A$??{}))}catch{K7="unhashable"}}let W=Y.defaultConfig||Y.config,z=A$||{},U=W.theme||{},B=(z.theme||{}).extend||{},j={...U};if(Object.keys(B).length>0)j.extend=B;let H=[...W.safelist||[],...z.safelist||[]],L={...W,...z,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},F=new Y.CSSGenerator(L);for(let A of H)F.generate(A);for(let A of X)F.generate(A);let O=F.toCSS(!0,!1),V=L.shortcuts||z.shortcuts||{};for(let[A,R]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let N=R.split(/\s+/).filter(Boolean);for(let T of N)F.generate(T)}O=F.toCSS(!0,!1);let w=O.split(`
1548
+ `);for(let[A,R]of Object.entries(V)){if(!X.has(A)&&!H.includes(A))continue;let N=R.split(/\s+/).filter(Boolean),T=[],M=[];for(let I of N){let D=I.startsWith("dark:"),k=`.${(D?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<w.length;b++){let P=w[b].trim();if(P===`${k} {`||P.startsWith(`${k} {`)){let d=b,f="";while(d<w.length){if(f+=w[d],w[d].includes("}"))break;d++}let m=f.match(/\{([^}]+)\}/);if(m)if(D)M.push(m[1].trim());else T.push(m[1].trim());break}}}if(T.length)O+=`
1549
1549
  .${A} { ${T.join(" ")} }`;if(M.length)O+=`
1550
1550
  @media (prefers-color-scheme: dark) { .dark .${A} { ${M.join(" ")} } }`}return q7(G,O),tQ(G,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function t9($,Z){let Y=await XG($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
1551
1551
  ${Y}
@@ -2436,7 +2436,7 @@ window.__stx_reactive = (function() {
2436
2436
  ${MG()}
2437
2437
  ${Y}
2438
2438
  </script>`}function F8($,Z,Y){if(L8=0,!EG($))return $;let X=AG($);if(X.length===0)return $;let Q=DG($,X),J=IG(X,Z),G=Q.lastIndexOf("</body>");if(G!==-1)Q=Q.slice(0,G)+J+`
2439
- `+Q.slice(G);else Q+=J;return Q}function DG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${R$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${R$(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*"${R$(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*'${R$(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 EG($){return/x-data\s*=\s*["']/.test($)}var L8=0,wG=0;var V8=y(()=>{c0()});import kG from"fs";import U7 from"path";import{createHighlighter as SG}from"ts-syntax-highlighter";async function bG($,Z={}){try{if(!await l($))throw Error(`Markdown file not found: ${$}`);let X=(await kG.promises.stat($)).mtime.getTime();if(Z.cache&&_7.has($)){let U=_7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=E6(Q),K=Z.markdown||G7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=q5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await yG(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:W,data:J||{}};if(Z.cache)_7.set($,{...z,updatedAt:X});return z}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function yG($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!N$)try{N$=await SG({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,q,W,z)=>{let U=z.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!N$.getSupportedLanguages().includes(_))return K;return(await N$.highlight(U,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},J=$,G=$.matchAll(X);for(let K of G){let[q,W,z,U]=K,_=await Q(q,W,z,U);J=J.replace(q,_)}return J}async function w8($,Z,Y="",X={}){return await CG($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,W)=>{try{let z=K;if(!U7.isAbsolute(K))z=U7.resolve(U7.dirname(Y),K);let U={};if(q)try{try{U=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),R=V.substring(w+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);U[A]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await bG(z,X),j={...Z,...B,...U},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(z){let U=z instanceof Error?z.message:String(z);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,W,G)}})}async function CG($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],q=Q.index,W=Q;X.push(Y(...W).then((z)=>({match:K,replacement:z,index:q})))}let J=await Promise.all(X);J.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of J)G=G.replace(K,()=>q);return G}var _7,N$=null;var A8=y(()=>{j5();j0();_7=new Map});function Z1($,Z){try{let Y=$.trim();if(Z0(Y))return Y0(Y,Object.keys(Z))(...Object.values(Z));else return $0(Y,Z)}catch{return!1}}var R8=y(()=>{O0()});function D0($,Z,Y,X=0){let Q=0,J=X,G=null,K=0,q=!1;while(J<$.length){let W=$[J];if(G&&q){q=!1,J++;continue}if(G&&W==="\\"){q=!0,J++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,J++;continue}if(W===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&W==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&W==="}"){K--,J++;continue}if(W==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(W===Z)Q++;else if(W===Y){if(Q--,Q===0)return J}J++}return-1}function Y1($,Z){let Y=PG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function PG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function R1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)Q++,J=z+q[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+W[0].length}else break}return-1}function N8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=Y1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z="if",U=Q.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W});let F=W+L[0].length,O=Y1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:J+_,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function O5($){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 J=N8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function T$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,q=K+J[0].length-1,W=D0($,"(",")",q);if(W===-1){J=Q.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=R1($,Z,Y,U);if(_===-1){J=Q.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function B7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=Y1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=Y1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:q,start:Z,end:G+10}}var T8=()=>{};var M8=()=>{};var M$=y(()=>{T8();M8()});function gG($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=B7(X,G);if(!K)break;try{let q;if(Z0(K.expression))q=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else q=$0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&Z0(U.value))_=Y0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=$0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),Q=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=r("Switch",`Error evaluating @switch expression: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,G)+z+X.substring(K.end);break}}return X}function N1($,Z,Y){let X=$;X=gG(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=Y1(X,K+7);if(!q)break;let W=q.endPos,z=R1(X,"unless","endunless",W);if(z===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=X.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,R)=>A.pos-R.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){B=A.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;X=X.substring(0,K)+j+X.substring(z+10),J=!0}}X=H7(X,Z,Y),X=O7(X,Z,Y),X=j7(X,Z);let Q=()=>{let J=O5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&Z0(z.condition))U=Y0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=$0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=r(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=r("If",`Error processing @if block: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+z+X.substring(K.end)}}return!0};while(!0){let J=X;if(!Q())break;if(X===J)break}return X}function I8($){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 Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function j7($,Z){let Y=$;function X(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function Q(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=I8(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?Z1(`auth?.check && auth?.user?.[${z}]`,Z):Z1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=I8(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?Z1(`!auth?.check || !auth?.user?.[${z}]`,Z):Z1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function J(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=Z1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((S,P)=>S.pos-P.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],D=0;for(let S=0;S<O.length;S++){let P=O[S];if(I.push({content:F.slice(D,P.pos),ability:void 0}),P.type==="elseDirective"){let d=F.slice(P.pos+`@${W}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(D,P.pos)},D=P.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+1],n=m?m.pos:F.length;I.push({content:F.slice(D,n),ability:f.ability,type:f.type,id:f.id}),D=n}}else D=P.pos+5}if(D<F.length){let S=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=J(j.ability,j.type,j.id),C=K==="can"?E:!E,k="";if(C)k=I[0]?.content||"";else{let S=!1;for(let P=1;P<I.length;P++){let d=I[P];if(d.isFinalElse){k=d.content,S=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){k=d.content,S=!0;break}}}if(!S&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)k=P.content}}Y=Y.substring(0,_)+k+Y.substring(L+`@${q}`.length),z=!0}}return Y}function H7($,Z,Y){let X=$;function Q(J,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=J.match(U);if(!_||_.index===void 0)break;let B=_.index,j=Y1(J,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=R1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=j.expression,V=-1,w=0,A=0;while(A<F.length){let R=F.indexOf("@",A);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){w++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){w--,A=R+1;continue}if(w===0&&/^@else(?![a-z])/.test(N)){V=R;break}A=R+1}try{let R=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";J=J.substring(0,B)+N+J.substring(L+`@${K}`.length),z=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,i.EVALUATION_ERROR);J=J.substring(0,B)+T+J.substring(L+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=Z1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=Z1(J,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 O7($,Z,Y){let X=$,Q="development";function J(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=Q===E[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let E=z.exec(j),C=U.exec(j),k=E?E.index:1/0,S=C?C.index:1/0;if(k<S)V++,w=k+E[0].length;else if(S<1/0){if(V--,V===0){A=S;break}w=S+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,A),N=-1,T=0,M=0;while(M<R.length){let E=R.indexOf("@",M);if(E===-1)break;let C=R.substring(E);if(_.test(C)){T++,M=E+1;continue}if(B.test(C)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(C)){N=E;break}M=E+1}let I;if(N!==-1){let E=R.slice(0,N),C=R.slice(N+5);I=W?E:C}else I=W?R:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(A+D),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var I$=y(()=>{R8();a0();M$();O0()});function E8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function D$($,Z){if(!$)return Z?.nonceGenerator?.()??E8();let Y=D8.get($);if(!Y)Y=Z?.nonceGenerator?.()??E8(),D8.set($,Y);return Y}function hG($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function k8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${hG($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function S8($,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?D$(Y,Z):void 0,Q=k8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
2439
+ `+Q.slice(G);else Q+=J;return Q}function DG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${R$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${R$(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*"${R$(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*'${R$(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 EG($){return/x-data\s*=\s*["']/.test($)}var L8=0,wG=0;var V8=y(()=>{c0()});import kG from"fs";import U7 from"path";import{createHighlighter as SG}from"ts-syntax-highlighter";async function bG($,Z={}){try{if(!await l($))throw Error(`Markdown file not found: ${$}`);let X=(await kG.promises.stat($)).mtime.getTime();if(Z.cache&&_7.has($)){let U=_7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=E6(Q),K=Z.markdown||G7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},W=q5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)W=await yG(W,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let z={content:W,data:J||{}};if(Z.cache)_7.set($,{...z,updatedAt:X});return z}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function yG($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!N$)try{N$=await SG({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,q,W,z)=>{let U=z.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),_=W||(Y?"text":"");if(!_)return K;try{if(!N$.getSupportedLanguages().includes(_))return K;return(await N$.highlight(U,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${W}:`,B)}return K},J=$,G=$.matchAll(X);for(let K of G){let[q,W,z,U]=K,_=await Q(q,W,z,U);J=J.replace(q,_)}return J}async function w8($,Z,Y="",X={}){return await CG($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,W)=>{try{let z=K;if(!U7.isAbsolute(K))z=U7.resolve(U7.dirname(Y),K);let U={};if(q)try{try{U=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),R=V.substring(w+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);U[A]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await bG(z,X),j={...Z,...B,...U},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(z){let U=z instanceof Error?z.message:String(z);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,W,G)}})}async function CG($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],q=Q.index,W=Q;X.push(Y(...W).then((z)=>({match:K,replacement:z,index:q})))}let J=await Promise.all(X);J.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of J)G=G.replace(K,()=>q);return G}var _7,N$=null;var A8=y(()=>{j5();j0();_7=new Map});function Z1($,Z){try{let Y=$.trim();if(Z0(Y))return Y0(Y,Object.keys(Z))(...Object.values(Z));else return $0(Y,Z)}catch{return!1}}var R8=y(()=>{O0()});function D0($,Z,Y,X=0){let Q=0,J=X,G=null,K=0,q=!1;while(J<$.length){let W=$[J];if(G&&q){q=!1,J++;continue}if(G&&W==="\\"){q=!0,J++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,J++;continue}if(W===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&W==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&W==="}"){K--,J++;continue}if(W==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(W===Z)Q++;else if(W===Y){if(Q--,Q===0)return J}J++}return-1}function Y1($,Z){let Y=PG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function PG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function R1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)Q++,J=z+q[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+W[0].length}else break}return-1}function N8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=Y1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z="if",U=Q.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W});let F=W+L[0].length,O=Y1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:J+_,end:J+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:J+_,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function O5($){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 J=N8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function T$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,q=K+J[0].length-1,W=D0($,"(",")",q);if(W===-1){J=Q.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=R1($,Z,Y,U);if(_===-1){J=Q.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function B7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=Y1($,X);if(!Q)return null;let J=Q.endPos,G=R1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=Y1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:q,start:Z,end:G+10}}var T8=()=>{};var M8=()=>{};var M$=y(()=>{T8();M8()});function gG($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=B7(X,G);if(!K)break;try{let q;if(Z0(K.expression))q=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else q=$0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&Z0(U.value))_=Y0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=$0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}X=X.substring(0,G)+W+X.substring(K.end),Q=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=r("Switch",`Error evaluating @switch expression: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,G)+z+X.substring(K.end);break}}return X}function N1($,Z,Y){let X=$;X=gG(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=Y1(X,K+7);if(!q)break;let W=q.endPos,z=R1(X,"unless","endunless",W);if(z===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let U=X.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,R)=>A.pos-R.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){B=A.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;X=X.substring(0,K)+j+X.substring(z+10),J=!0}}X=H7(X,Z,Y),X=O7(X,Z,Y),X=j7(X,Z);let Q=()=>{let J=O5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&Z0(z.condition))U=Y0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=$0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=r(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),W=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=r("If",`Error processing @if block: ${W}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+z+X.substring(K.end)}}return!0};while(!0){let J=X;if(!Q())break;if(X===J)break}return X}function I8($){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 Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function j7($,Z){let Y=$;function X(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>0){B.lastIndex=_,j.lastIndex=_;let H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function Q(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+5),B=I8(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?Z1(`auth?.check && auth?.user?.[${z}]`,Z):Z1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let W=q.index,z,U,_=Y.slice(W+6),B=I8(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?Z1(`!auth?.check || !auth?.user?.[${z}]`,Z):Z1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function J(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=Z1(W,Z);z.push(U)}return Z.permissions.check(...z)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${W}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((b,P)=>b.pos-P.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)O.push(b)}let I=[],D=0;for(let b=0;b<O.length;b++){let P=O[b];if(I.push({content:F.slice(D,P.pos),ability:void 0}),P.type==="elseDirective"){let d=F.slice(P.pos+`@${W}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(D,P.pos)},D=P.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[b+1],n=m?m.pos:F.length;I.push({content:F.slice(D,n),ability:f.ability,type:f.type,id:f.id}),D=n}}else D=P.pos+5}if(D<F.length){let b=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=J(j.ability,j.type,j.id),C=K==="can"?E:!E,k="";if(C)k=I[0]?.content||"";else{let b=!1;for(let P=1;P<I.length;P++){let d=I[P];if(d.isFinalElse){k=d.content,b=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){k=d.content,b=!0;break}}}if(!b&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)k=P.content}}Y=Y.substring(0,_)+k+Y.substring(L+`@${q}`.length),z=!0}}return Y}function H7($,Z,Y){let X=$;function Q(J,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=J.match(U);if(!_||_.index===void 0)break;let B=_.index,j=Y1(J,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=R1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=j.expression,V=-1,w=0,A=0;while(A<F.length){let R=F.indexOf("@",A);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){w++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){w--,A=R+1;continue}if(w===0&&/^@else(?![a-z])/.test(N)){V=R;break}A=R+1}try{let R=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";J=J.substring(0,B)+N+J.substring(L+`@${K}`.length),z=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=r(W,`Error processing @${G} directive: ${N}`,i.EVALUATION_ERROR);J=J.substring(0,B)+T+J.substring(L+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=Z1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=Z1(J,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 O7($,Z,Y){let X=$,Q="development";function J(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,H=!0;while(H){H=!1,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=Q===E[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let E=z.exec(j),C=U.exec(j),k=E?E.index:1/0,b=C?C.index:1/0;if(k<b)V++,w=k+E[0].length;else if(b<1/0){if(V--,V===0){A=b;break}w=b+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(O,A),N=-1,T=0,M=0;while(M<R.length){let E=R.indexOf("@",M);if(E===-1)break;let C=R.substring(E);if(_.test(C)){T++,M=E+1;continue}if(B.test(C)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(C)){N=E;break}M=E+1}let I;if(N!==-1){let E=R.slice(0,N),C=R.slice(N+5);I=W?E:C}else I=W?R:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(A+D),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var I$=y(()=>{R8();a0();M$();O0()});function E8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function D$($,Z){if(!$)return Z?.nonceGenerator?.()??E8();let Y=D8.get($);if(!Y)Y=Z?.nonceGenerator?.()??E8(),D8.set($,Y);return Y}function hG($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function k8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${hG($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function S8($,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?D$(Y,Z):void 0,Q=k8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
2440
2440
  ${Q}`)}function b8($,Z,Y,X){let Q=$,J=X.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!J?.enabled||!J.directives)return"<!-- CSP not configured -->";let G=J.useNonce?D$(Z,J):void 0;return k8(J.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!J?.enabled||!J.useNonce)return"";return D$(Z,J)}),J?.enabled&&J.useNonce)Z.cspNonce=D$(Z,J);return Q}var D8;var y8=y(()=>{D8=new WeakMap});import dG from"crypto";function uG($=mG){let Z=dG.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return L7=Z,Z}function pG(){if(!L7)uG();return L7}function lG($=C8){let Z=pG();return`<input type="hidden" name="${$}" value="${Z}">`}function P8($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return lG(X||C8)})}var mG=40,C8="_token",L7=null;var v8=()=>{};async function x8($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let Q=$;for(let J of X.customDirectives){if(!J.name||typeof J.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",J);continue}if(J.hasEndTag)Q=await cG(Q,J,Z,Y,X);else Q=await iG(Q,J,Z,Y,X)}return Q}async function cG($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=`@${J}`,q=`@end${J}`,W=$,z=x1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),U=[],_=z.exec(W);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?f8(j):[],O=H.trim(),V=await G(O,F,Y,X);U.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(Q.debug)console.error(`Error processing custom directive @${J}:`,F);U.push({original:B,processed:r("CustomDirective",`Error in @${J}${j?`(${j})`:""}: ${O}`,i.EVALUATION_ERROR),startIndex:L})}_=z.exec(W)}for(let B=U.length-1;B>=0;B--){let{original:j,processed:H}=U[B];W=W.replace(j,H)}return W}async function iG($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=$,q=x1(`@${J}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],z=q.exec(K);while(z!==null){let[B,j=""]=z,H=z.index||0;try{let L=f8(j),F=await G("",L,Y,X);W.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(Q.debug)console.error(`Error processing custom directive @${J}:`,L);W.push({original:B,processed:r("CustomDirective",`Error in @${J}(${j}): ${F}`,i.EVALUATION_ERROR),startIndex:H})}z=q.exec(K)}let U=x1(`@${J}(?!\\w)(?!\\s*\\()`,"g"),_=U.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);W.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(Q.debug)console.error(`Error processing custom directive @${J}:`,H);W.push({original:B,processed:r("CustomDirective",`Error in @${J}: ${L}`,i.EVALUATION_ERROR),startIndex:j})}_=U.exec(K)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];K=K.replace(j,H)}return K}function f8($){if(!$.trim())return[];let Z=[],Y="",X=!1,Q="";for(let J=0;J<$.length;J++){let G=$[J];if((G==='"'||G==="'")&&(J===0||$[J-1]!=="\\"))if(!X)X=!0,Q=G;else if(G===Q)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((J)=>{let G=J.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var g8=y(()=>{a0();f1()});var F7={};s(F7,{useTitle:()=>tG,useSeoMeta:()=>k$,usePageTitle:()=>tG,useHead:()=>M1,resetHead:()=>sG,renderHtmlAttrs:()=>$K,renderHead:()=>eG,renderBodyAttrs:()=>ZK,processTitleDirective:()=>JK,processMetaDirective:()=>QK,processHeadDirective:()=>XK,getPageMeta:()=>oG,getHead:()=>L5,definePageMeta:()=>aG,applyHead:()=>YK});function L5(){return X1}function oG(){return E$}function sG(){X1={},nG.length=0,E$={}}function M1($){X1=rG(X1,$)}function rG($,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 k$($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,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 Q=$.twitterTitle??$.title,J=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(Q)Z.push({name:"twitter:title",content:Q});if(J)Z.push({name:"twitter:description",content:J});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});M1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function aG($){if(E$={...E$,...$},$.title||$.description)k$({title:$.title,description:$.description})}function tG($){let Z=typeof $==="function"?$():$;M1({title:Z})}function eG($=X1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${T1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,Q])=>`${X}="${T1(Q)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([Q,J])=>J!==void 0).map(([Q,J])=>{return`${Q==="httpEquiv"?"http-equiv":Q}="${T1(String(J))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([Q,J])=>J!==void 0).map(([Q,J])=>`${Q}="${T1(String(J))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...Q}=Y,J=Object.entries(Q).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${T1(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${J}>${X}</script>`);else Z.push(`<script ${J}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
2441
2441
  `)}function $K($=X1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${T1(Y)}"`).join(" ")}function ZK($=X1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${T1(Y)}"`).join(" ")}function T1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function YK($=X1){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[Q,J]of Object.entries(Z))if(J!==void 0)X.setAttribute(Q,String(J))}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 XK($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,Q)=>{return Z+=Q.trim()+`
2442
2442
  `,""}),headContent:Z.trim()}}function JK($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,Q,J)=>{let G=X?Q:Z[(J||"").trim()]??J;return M1({title:G}),""})}function QK($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,Q,J,G,K)=>{let q=J?G:K,W=J?q:Z[(q||"").trim()]??q,U=Q.includes(":")?{property:Q,content:W}:{name:Q,content:W};return M1({meta:[U]}),""})}var X1,nG,E$;var F5=y(()=>{X1={},nG=[],E$={}});import GK from"crypto";function F0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function S$($,Z,Y,X){let Q=$||Z;return Y?`${Q} ${X}`:Q}function KK(){return GK.randomUUID()}function b$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=KK();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${F0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,Q)=>{let J=Q.toUpperCase();if(Q&&!["GET","POST"].includes(J))return`<input type="hidden" name="_method" value="${F0(J)}">`;return X}),Y}function m8($,Z,Y=d8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Q,J,G,K,q,W="")=>{let z=J||G||"POST",U=K||q||"",_=J1(W),B=z.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${F0(j)}" action="${F0(U)}"${_?` ${_}`:""}>`;if(H+=`
@@ -2637,12 +2637,12 @@ else {
2637
2637
  `).length;Y.set(q,{count:1,firstLine:U})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(cK.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,W=X.get(K)??0;if(q!==W)G.push({tag:K,opened:q,closed:W,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function b7($,Z){let Y;try{Y=$Z($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(e8.has(X))return;e8.add(X);let Q=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:J,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let W=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 an unclosed <${J}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${Q}: <${J}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${J}>.`)}var lK,cK,e8;var y7=y(()=>{lK=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),cK=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);e8=new Set});var C$={};s(C$,{stripTypeScript:()=>GZ,hasVariables:()=>UZ,extractVariables:()=>D1,extractScriptFromTemplate:()=>WZ,convertToCommonJS:()=>P7});import u1 from"path";import N5 from"process";function iK($){let Z=[],Y=0,X=$.split(`
2638
2638
  `);for(let Q of X){let J=Y,G=null,K=!1;for(let q=0;q<Q.length;q++){let W=Q[q];if(K){K=!1;continue}if(W==="\\"){K=!0;continue}if(G){if(W===G)G=null;continue}if(W==="'"||W==='"'||W==="`"){G=W;continue}if(W==="/"&&q+1<Q.length&&Q[q+1]==="/")break;if(W==="{")Y++;else if(W==="}")Y--}if(J===0){let q=Q.match(/(?:const|let|var)\s+(\w+)\s*=/);if(q)Z.push(q[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(Q)){let W=Q.match(/(?:const|let|var)\s+(\w+)/);if(W)Z.push(W[1])}else{let W=Q.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(W){let U=W[1].slice(1,-1).split(",").map((_)=>{let B=_.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((_)=>/^\w+$/.test(_));Z.push(...U)}}}}return[...new Set(Z)]}function GZ($){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 Q=[],J="",G=0,K=0,q=null;for(let W=0;W<X.length;W++){let z=X[W];if(q){if(J+=z,z===q)q=null;continue}if(z==='"'||z==="'"||z==="`"){q=z,J+=z;continue}if(z==="<")G++;else if(z===">"&&G>0)G--;else if(z==="(")K++;else if(z===")")K--;if(z===","&&G===0&&K===0){Q.push(J),J="";continue}J+=z}if(J)Q.push(J);return Q.map((W)=>{let z=W.trim(),U=z.startsWith("..."),_=U?z.slice(3):z,B=-1,j=0;for(let A=0;A<_.length;A++)if(_[A]==="<")j++;else if(_[A]===">")j--;else if(_[A]===":"&&j===0){B=A;break}if(B===-1)return W;let L=_.substring(0,B).trim().replace(/\?$/,""),F=_.substring(B+1),O=-1,V=0;for(let A=0;A<F.length;A++)if(F[A]==="<")V++;else if(F[A]===">")V--;else if(F[A]==="="&&V===0){O=A;break}let w=U?"...":"";if(O!==-1)return`${w}${L} = ${F.substring(O+1).trim()}`;return`${w}${L}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,Q,J)=>{if(!J.includes(":"))return X;return`${Q}(${Y(J)})`});{let X=/\b(function\s+\w*\s*)\(/g,Q,J=[];while((Q=X.exec(Z))!==null){let G=Q.index+Q[0].length-1,K=1,q=G+1,W=0,z=null;while(q<Z.length&&K>0){let B=Z[q];if(z){if(B===z)z=null;q++;continue}if(B==='"'||B==="'"||B==="`"){z=B,q++;continue}if(B==="<")W++;else if(B===">"&&W>0)W--;else if(W===0){if(B==="(")K++;else if(B===")")K--}if(K>0)q++}if(K!==0)continue;let U=Z.substring(G+1,q);if(!U.includes(":"))continue;let _=Y(U);J.push({start:G+1,end:q,replacement:_})}for(let G=J.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=J[G];Z=Z.substring(0,K)+W+Z.substring(q)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,Q)=>{if(!Q.includes(":"))return X;if(Q.includes("{")||Q.includes("}"))return X;return`(${Q.split(",").map((G)=>{let[K,...q]=G.split("="),W=K.split(":")[0].trim();if(q.length>0)return`${W} = ${q.join("=").trim()}`;return W}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
2639
2639
 
2640
- `),Z}async function D1($,Z,Y,X={}){if(!$.trim())return;let Q;try{let b=new Bun.Transpiler({loader:"ts",target:"browser",define:p0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Q=b.transformSync(v)}catch{Q=GZ($)}let J={exports:{}},G=J.exports,K=N5.cwd(),q={},W=[...Q.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((b)=>b[1]).filter((b)=>!b.startsWith("node:")&&!b.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(b));for(let b of W)try{let v=u1.resolve(K,"node_modules",b),x=u1.join(v,"package.json"),g=JSON.parse(G0("fs").readFileSync(x,"utf8")),u=g.main||"index.js";if(g.exports){let o=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof o==="string")u=o;else if(o?.bun)u=o.bun;else if(o?.import)u=o.import;else if(o?.default)u=o.default}q[b]=await import(u1.resolve(v,u))}catch{}let z=(b)=>{if(q[b])return q[b];return G0(b)},U=Z.props||{},_=Object.assign((b)=>{if(!b)return U;let v={};for(let[x,g]of Object.entries(b)){let u=U[x];if(u!==void 0)v[x]=u;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},U),B=(b)=>{if(!b)return U;let v={...U};for(let[x,g]of Object.entries(b)){let u=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&u.default!==void 0)v[x]=typeof u.default==="function"?u.default():u.default}return v},j=()=>Z.slots||{},H=(b,v)=>{let x={...b};for(let[g,u]of Object.entries(v))if(x[g]===void 0)if(typeof u==="function")x[g]=u();else x[g]=u;return x},L=(b)=>{let v=()=>b;return v.set=(x)=>{},v.update=(x)=>{},v},F=(b)=>{let v,x=!1;return()=>{if(!x)try{v=b(),x=!0}catch{v=void 0}return v}},O=(b)=>{},V=(b)=>b(),w=(b)=>{},A=(b)=>{},R=(b)=>{},N=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),T=()=>({push:(b)=>{},replace:(b)=>{},back:()=>{},forward:()=>{},go:(b)=>{}}),M=(b)=>{M1(b);let v=Z.__stx_runtime_head||{},x=b||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(b)=>{k$(b);let v=L5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(b)=>({value:b}),E=(b)=>b,C=(b)=>({value:typeof b==="function"?b():b}),k=(b,v)=>{},S=(b)=>{},P=(b)=>{},d=(b)=>b?b():Promise.resolve(),f=(b)=>(v,...x)=>{},m=(b)=>{},n=(b,v)=>{},A0=(b,v)=>v,o0=()=>({value:"light"}),S0=()=>({value:!1}),M0={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:{}},e=new Proxy(M0,{get(b,v){if(v in b)return b[v];return},set(b,v,x){return b[v]=x,!0}}),B0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},z0=console;try{let b=P7(Q,Y),v=new Set(Object.keys(U)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),u=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),o=[],Q0=[];for(let[t,u0]of Object.entries(U)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(u.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(b))continue;o.push(t),Q0.push(u0)}let b0=iK(b).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
2640
+ `),Z}async function D1($,Z,Y,X={}){if(!$.trim())return;let Q;try{let S=new Bun.Transpiler({loader:"ts",target:"browser",define:p0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),Q=S.transformSync(v)}catch{Q=GZ($)}let J={exports:{}},G=J.exports,K=N5.cwd(),q={},W=[...Q.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((S)=>S[1]).filter((S)=>!S.startsWith("node:")&&!S.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(S));for(let S of W)try{let v=u1.resolve(K,"node_modules",S),x=u1.join(v,"package.json"),g=JSON.parse(G0("fs").readFileSync(x,"utf8")),u=g.main||"index.js";if(g.exports){let o=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof o==="string")u=o;else if(o?.bun)u=o.bun;else if(o?.import)u=o.import;else if(o?.default)u=o.default}q[S]=await import(u1.resolve(v,u))}catch{}let z=(S)=>{if(q[S])return q[S];return G0(S)},U=Z.props||{},_=Object.assign((S)=>{if(!S)return U;let v={};for(let[x,g]of Object.entries(S)){let u=U[x];if(u!==void 0)v[x]=u;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},U),B=(S)=>{if(!S)return U;let v={...U};for(let[x,g]of Object.entries(S)){let u=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&u.default!==void 0)v[x]=typeof u.default==="function"?u.default():u.default}return v},j=()=>Z.slots||{},H=(S,v)=>{let x={...S};for(let[g,u]of Object.entries(v))if(x[g]===void 0)if(typeof u==="function")x[g]=u();else x[g]=u;return x},L=(S)=>{let v=()=>S;return v.set=(x)=>{},v.update=(x)=>{},v},F=(S)=>{let v,x=!1;return()=>{if(!x)try{v=S(),x=!0}catch{v=void 0}return v}},O=(S)=>{},V=(S)=>S(),w=(S)=>{},A=(S)=>{},R=(S)=>{},N=()=>{let S=Z.__stxServeContext,v=Z.__stxServeSearch??S?.search??"",x=S?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(v)),path:x,name:"",fullPath:x+v,hash:"",matched:[]}},T=()=>({push:(S)=>{},replace:(S)=>{},back:()=>{},forward:()=>{},go:(S)=>{}}),M=(S)=>{M1(S);let v=Z.__stx_runtime_head||{},x=S||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(S)=>{k$(S);let v=L5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(S)=>({value:S}),E=(S)=>S,C=(S)=>({value:typeof S==="function"?S():S}),k=(S,v)=>{},b=(S)=>{},P=(S)=>{},d=(S)=>S?S():Promise.resolve(),f=(S)=>(v,...x)=>{},m=(S)=>{},n=(S,v)=>{},A0=(S,v)=>v,o0=()=>({value:"light"}),S0=()=>({value:!1}),I0={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:{}},e=new Proxy(I0,{get(S,v){if(v in S)return S[v];return},set(S,v,x){return S[v]=x,!0}}),B0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},z0=console;try{let S=P7(Q,Y),v=new Set(Object.keys(U)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),u=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),o=[],Q0=[];for(let[t,u0]of Object.entries(U)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(u.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(S))continue;o.push(t),Q0.push(u0)}let b0=iK(S).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
2641
2641
  `),_1=Z.params??{},q0=[],B1=[];for(let t=0;t<x.length;t++){if(x[t]==="params")continue;q0.push(x[t]),B1.push(g[t])}let y5=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",...o,...q0,`return (async () => {
2642
- ${b}
2642
+ ${S}
2643
2643
  ${b0}
2644
2644
  return module.exports
2645
- })()`)(J,G,z,U,_,B,H,L,F,O,V,w,A,R,N,T,M,I,D,E,C,k,S,P,d,f,m,j,n,A0,o0,S0,e,B0,z0,M0.confirm,M0.alert,M0.fetch,_1,...Q0,...B1);if(X.preserveExisting){for(let[t,u0]of Object.entries(y5))if(!(t in Z)||Z[t]===void 0)Z[t]=u0}else Object.assign(Z,y5);for(let[t,u0]of Object.entries(U))if(!(t in Z))Z[t]=u0}catch(b){if(N5.env.STX_DEBUG){let v=b instanceof Error?b.message:String(b);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await aK(Q,Z,Y)}catch(v){if(N5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function P7($,Z){let Y=Z?u1.dirname(Z):N5.cwd(),X=$.split(`
2645
+ })()`)(J,G,z,U,_,B,H,L,F,O,V,w,A,R,N,T,M,I,D,E,C,k,b,P,d,f,m,j,n,A0,o0,S0,e,B0,z0,I0.confirm,I0.alert,I0.fetch,_1,...Q0,...B1);if(X.preserveExisting){for(let[t,u0]of Object.entries(y5))if(!(t in Z)||Z[t]===void 0)Z[t]=u0}else Object.assign(Z,y5);for(let[t,u0]of Object.entries(U))if(!(t in Z))Z[t]=u0}catch(S){if(N5.env.STX_DEBUG){let v=S instanceof Error?S.message:String(S);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await aK(Q,Z,Y)}catch(v){if(N5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function P7($,Z){let Y=Z?u1.dirname(Z):N5.cwd(),X=$.split(`
2646
2646
  `),Q=[],J=0;while(J<X.length){let G=X[J].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(;J<X.length;J++){for(let q of X[J])if(q==="{")K++;else if(q==="}")K--;if(K<=0)break}}J++;continue}if(G.startsWith("definePageMeta(")){let K=0,q=!1;for(let W=J;W<X.length&&!q;W++){let z=null,U=!1,_=X[W];for(let B=0;B<_.length;B++){let j=_[B];if(U){U=!1;continue}if(j==="\\"){U=!0;continue}if(z){if(j===z)z=null;continue}if(j==='"'||j==="'"||j==="`"){z=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){J=W+1,q=!0;break}}}}if(!q)J=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),q=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+['"](.+)['"]/),z=(U)=>{if(U.startsWith("."))return u1.resolve(Y,U);return U};if(K){let[,U,_]=K,B=z(_);Q.push(`const ${U} = await import('${B}')`),Q.push(`module.exports.${U} = ${U};`)}else if(q){let[,U,_]=q,B=U.trim(),j=z(_);Q.push(`const { ${B} } = await import('${j}')`);for(let H of B.split(",")){let L=H.trim().split(/\s+as\s+/).pop()?.trim();if(L)Q.push(`module.exports.${L} = ${L};`)}}else if(W){let U=z(W[1]);Q.push(`await import('${U}')`)}else Q.push(G);J++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))Q.push(X[J]),J++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=YZ(X,J),{type:q,name:W,value:z}=K;Q.push(`${q} ${W} = ${z};`),Q.push(`module.exports.${W} = ${W};`),J=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=C7(X,J);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),J=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=YZ(X,J),{type:q,name:W,value:z}=K;Q.push(`${q} ${W} = ${z};`),Q.push(`module.exports.${W} = ${W};`),J=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=C7(X,J);Q.push(K.functionCode),Q.push(`module.exports.${K.name} = ${K.name};`),J=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=X[J].replace(/^(\s*)export\s+default\s+/,"$1"),q=[...X];q[J]=K;let W=C7(q,J);if(Q.push(W.functionCode),W.name)Q.push(`module.exports.default = ${W.name};`);J=W.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");Q.push(`module.exports.default = ${K};`),J++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let q=K[1],W=X[J].replace(/^export\s+/,""),z=0,U=J;for(;U<X.length;U++){let _=X[U];for(let B of _)if(B==="{")z++;else if(B==="}")z--;if(U>J)W+=`
2647
2647
  `+_;if(z<=0&&U>=J)break}Q.push(W),Q.push(`module.exports.${q} = ${q};`),J=U+1}else Q.push(G),J++}else if(G.includes("module.exports"))Q.push(G),J++;else if(G.trim()&&!G.startsWith("//"))Q.push(G),J++;else J++}return nK(Q.join(`
2648
2648
  `),Y)}function nK($,Z){let Y=$.length,X="",Q=0,J=null,G=!1,K=!1,q=0;while(Q<Y){let W=$[Q],z=$[Q+1];if(G){if(X+=W,W===`
@@ -2652,7 +2652,7 @@ ${A}`,nextIndex:O}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}l
2652
2652
  ${$[q]}`,q++;else break}return K=K.trim().replace(/;$/,""),{type:Q,name:J,value:K,nextIndex:q}}function C7($,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[,Q]=X,J=Y.replace(/^export\s+/,""),G=Z;if(sK(Y)){let K=rK($,Z,J);J=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:Q,functionCode:J,nextIndex:G}}function XZ($){let Z=$.trim();if(Z.startsWith("{"))return D0(Z,"{","}",0)===-1;if(Z.startsWith("["))return D0(Z,"[","]",0)===-1;return!zZ(Z)}function zZ($){let Z={paren:0,bracket:0,brace:0},Y=null,X=0;for(let Q=0;Q<$.length;Q++){let J=$[Q];if((Q>0?$[Q-1]:"")==="\\"&&Y)continue;if((J==='"'||J==="'")&&!Y){Y=J;continue}if(J===Y&&Y!=="`"){Y=null;continue}if(J==="`"&&!Y){Y="`";continue}if(J==="`"&&Y==="`"&&X===0){Y=null;continue}if(Y==="`"&&J==="$"&&$[Q+1]==="{"){X++,Q++;continue}if(X>0&&J==="{"){X++;continue}if(X>0&&J==="}"){X--;continue}if(Y)continue;if(J==="(")Z.paren++;else if(J===")")Z.paren--;else if(J==="[")Z.bracket++;else if(J==="]")Z.bracket--;else if(J==="{")Z.brace++;else if(J==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&Y===null}function sK($){let Z=$.indexOf("{");if(Z===-1)return!0;return D0($,"{","}",Z)===-1}function JZ($,Z,Y){let X=Y,Q=Z+1;while(Q<$.length&&!zZ(X)){let J=$[Q];X+=`
2653
2653
  ${J}`,Q++}while(Q<$.length){let J=$[Q].trim();if(J.startsWith(".")||J.startsWith("?."))X+=`
2654
2654
  ${$[Q]}`,Q++;else break}return{value:X,nextIndex:Q}}function rK($,Z,Y){let X=Y,Q=Z+1;while(Q<$.length){let J=X.indexOf("{");if(J!==-1){if(D0(X,"{","}",J)!==-1)break}let G=$[Q];X+=`
2655
- ${G}`,Q++}return{functionCode:X,nextIndex:Q}}function QZ($,Z){let Y=$0($,Z)??$0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...N5.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 aK($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let J of X){let[,,G,K]=J;try{let q=K.trim().replace(/;$/,""),W=QZ(q,Z);if(W!==void 0)Z[G]=W}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}let Q=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let J of Q){let[,,G,K]=J;if(!(G in Z))try{let q=K.trim().replace(/;$/,""),W=QZ(q,Z);if(W!==void 0)Z[G]=W}catch{}}}function WZ($){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 UZ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var T5=y(()=>{F5();C1();O0()});var FZ={};s(FZ,{processLoops:()=>v7});function $q($,Z){let Y=/@component\s*\(/g,X=$,Q,J=[];while((Q=Y.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,W=K+1;while(W<X.length&&q>0){if(X[W]==="(")q++;else if(X[W]===")"){if(q--,q===0)break}W++}if(q!==0)continue;let z=X.substring(K+1,W),U=W+1,_=z.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=z.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=H0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;J.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=J.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=J[G];X=X.substring(0,K)+W+X.substring(q)}return X}function P$($,Z,Y){let X=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),J;while((J=Q.exec(X))!==null){let G=J.index,K=G+J[0].length-1,q=1,W=K+1,z=null,U=!1;while(W<X.length&&q>0){let j=X[W];if(U){U=!1,W++;continue}if(j==="\\"&&z){U=!0,W++;continue}if(z){if(j===z)z=null;W++;continue}if(j==='"'||j==="'"||j==="`"){z=j,W++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}W++}if(q!==0)break;let _=X.substring(K+1,W),B=Y(_);X=X.substring(0,G)+B+X.substring(W+1)}return X}function Zq($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,Q,J)=>{try{let G=Object.keys(Z),K=Object.values(Z);f5(J);let W=Y0(J,G)(...K),z=JSON.stringify(W),U=Buffer.from(z,"utf8").toString("base64");return`__stx_${Q}="${U}"`}catch(G){return X}}),Y}function Yq($,Z){let Y=$;return Y=P$(Y,"@break",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?v$:""}catch{return""}}),Y=P$(Y,"@continue",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?x$:""}catch{return""}}),Y}function Xq($){let Z=$;return Z=Z.replace(/@break(?!\()/g,v$),Z=Z.replace(/@continue(?!\()/g,x$),Z}function _Z($){let Z=$.includes(v$),Y=Z?$.substring(0,$.indexOf(v$)):$;return{hasBreak:Z,content:Y}}function BZ($){let Z=$.includes(x$),Y=Z?$.substring(0,$.indexOf(x$)):$;return{hasContinue:Z,content:Y}}function HZ($){let Z=$;return Z=P$(Z,"@break",(Y)=>{let X=Y.trim();if(!g5(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=P$(Z,"@continue",(Y)=>{let X=Y.trim();if(!g5(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Jq($){let Z=/@forelse\s*\(/g,Y,X=[],Q=/@foreach\s*\(/g,J=/@endforeach/g,G;while((G=Q.exec($))!==null)X.push({pos:G.index,delta:1});while((G=J.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((z,U)=>z.pos-U.pos);let K=[],q=0;for(let z of X)q+=z.delta,K.push({pos:z.pos,depth:q});function W(z){let U=0,_=K.length-1,B=0;while(U<=_){let j=U+_>>1;if(K[j].pos<=z)B=K[j].depth,U=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let z=Y.index,U=Y.index+Y[0].length-1,_=1,B=U+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(U+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,A=V,R=/@forelse\s*\(/g,N=/@endforelse/g,T=-1;while(w>0&&A<$.length){R.lastIndex=A,N.lastIndex=A;let k=R.exec($),S=N.exec($);if(!S)break;if(k&&k.index<S.index)w++,A=k.index+k[0].length;else{if(w--,w===0){T=S.index;break}A=S.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,C=0;while(C<M.length){let k=M.indexOf("@",C);if(k===-1)break;let S=M.substring(k);if(/^@forelse\s*\(/.test(S))E++,C=k+1;else if(S.startsWith("@endforelse"))E--,C=k+11;else if(E===0&&S.startsWith("@empty")){if(M.length<=k+6||!/[a-z]/i.test(M[k+6])){D=k;break}C=k+1}else C=k+1}if(D===-1)continue;return{start:z,end:I,arrayExpr:F,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function jZ($,Z){let Y=$;while(!0){let X=Jq(Y);if(!X)break;let{start:Q,end:J,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:W}=X;try{let z;if(Z0(G))z=Y0(G,Object.keys(Z))(...Object.values(Z));else z=$0(G,Z);let U;if(!Array.isArray(z)||z.length===0)U=W;else U=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,Q)+U+Y.substring(J)}catch(z){let U=z instanceof Error?z.message:String(z),_=r("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,i.EVALUATION_ERROR);Y=Y.substring(0,Q)+_+Y.substring(J)}}return Y}function v7($,Z,Y,X){let Q=$;Q=jZ(Q,Z);function J(q){let W=/@foreach\s*\(/g,z;while((z=W.exec(q))!==null){let U=z.index,_=z.index+z[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=U,V=L.substring(0,F),w=L.substring(F+4),A=H+1,R=1,N=A,T=/@foreach\s*\(/g,M=/@endforeach/g;while(R>0&&N<q.length){T.lastIndex=N,M.lastIndex=N;let I=T.exec(q),D=M.exec(q);if(!D)break;if(I&&I.index<D.index)R++,N=I.index+I[0].length;else{if(R--,R===0){let E=q.substring(A,D.index),C=D.index+11;return{start:O,end:C,arrayExpr:V,itemVar:w,content:E}}N=D.index+11}}}return null}function G(q,W){let z=q;while(!0){let U=J(z);if(!U)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=U;try{let F=j.trim(),O;if(Z0(F))O=Y0(F,Object.keys(W))(...Object.values(W));else O=$0(F,W);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,i.TYPE_ERROR);z=z.substring(0,_)+D+z.substring(B);continue}let w=X?.loops?.useAltLoopVariable??eK,A=H.trim(),R=null,N,T=!1;if(A.includes("=>")){let D=A.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],N=D[1];else N=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let D=A.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],R=D[1],T=!0;else N=A}else N=A;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],C={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},k={...W,loop:C,$loop:C};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))f.forEach((m,n)=>{if(m)k[m]=E[n]});else k[N]=E}else k[N]=E;if(R)if(!T&&V&&Array.isArray(E)&&E.length===2)k[R]=E[0],k[N]=E[1];else k[R]=D;let S=Yq(L,k),P=BZ(S);if(P.hasContinue){M+=P.content;continue}let d=_Z(S);if(d.hasBreak){M+=d.content;break}if(S=jZ(S,k),S=G(S,k),S=N1(S,k,Y),S=Xq(S),d=_Z(S),d.hasBreak){M+=d.content;break}if(P=BZ(S),P.hasContinue){M+=P.content;continue}S=l0(S,k,Y),S=Zq(S,k),S=$q(S,k),M+=S}z=z.substring(0,_)+M+z.substring(B)}catch(F){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,i.EVALUATION_ERROR);z=z.substring(0,_)+O+z.substring(B)}}return z}Q=G(Q,Z),Q=LZ(Q,Z,Y,X);let K=X?.loops?.maxWhileIterations??tK;return Q=Kq(Q,Z,K),Q}function OZ($){return g5($)}function LZ($,Z,Y,X){let Q=$,J=!0;while(J){J=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=K+G[0].length-1,W=D0(Q,"(",")",q);if(W===-1)break;let z=Q.slice(q+1,W),U=W+1,_=T$(Q.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!OZ(z)){let H=r("For",`Unsafe expression in @for: ${z}`,i.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(j),J=!0;continue}try{let H=Qq(z),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let R=Gq({forExpr:z,content:B,iterVarNames:H,context:Z,filePath:Y,options:X});Q=Q.substring(0,K)+R+Q.substring(j),J=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(R,N)=>{return`\${${N}}`});V=HZ(V);let A=Function(...F,`
2655
+ ${G}`,Q++}return{functionCode:X,nextIndex:Q}}function QZ($,Z){let Y=$0($,Z)??$0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...N5.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 aK($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let J of X){let[,,G,K]=J;try{let q=K.trim().replace(/;$/,""),W=QZ(q,Z);if(W!==void 0)Z[G]=W}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}let Q=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let J of Q){let[,,G,K]=J;if(!(G in Z))try{let q=K.trim().replace(/;$/,""),W=QZ(q,Z);if(W!==void 0)Z[G]=W}catch{}}}function WZ($){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 UZ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var T5=y(()=>{F5();C1();O0()});var FZ={};s(FZ,{processLoops:()=>v7});function $q($,Z){let Y=/@component\s*\(/g,X=$,Q,J=[];while((Q=Y.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,W=K+1;while(W<X.length&&q>0){if(X[W]==="(")q++;else if(X[W]===")"){if(q--,q===0)break}W++}if(q!==0)continue;let z=X.substring(K+1,W),U=W+1,_=z.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=z.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=H0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;J.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=J.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=J[G];X=X.substring(0,K)+W+X.substring(q)}return X}function P$($,Z,Y){let X=$,Q=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),J;while((J=Q.exec(X))!==null){let G=J.index,K=G+J[0].length-1,q=1,W=K+1,z=null,U=!1;while(W<X.length&&q>0){let j=X[W];if(U){U=!1,W++;continue}if(j==="\\"&&z){U=!0,W++;continue}if(z){if(j===z)z=null;W++;continue}if(j==='"'||j==="'"||j==="`"){z=j,W++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}W++}if(q!==0)break;let _=X.substring(K+1,W),B=Y(_);X=X.substring(0,G)+B+X.substring(W+1)}return X}function Zq($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,Q)=>{if(Q in Z)return`:${Q}="${Q}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,Q,J)=>{try{let G=Object.keys(Z),K=Object.values(Z);f5(J);let W=Y0(J,G)(...K),z=JSON.stringify(W),U=Buffer.from(z,"utf8").toString("base64");return`__stx_${Q}="${U}"`}catch(G){return X}}),Y}function Yq($,Z){let Y=$;return Y=P$(Y,"@break",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?v$:""}catch{return""}}),Y=P$(Y,"@continue",(X)=>{try{let J=`!!(${X.trim()})`,G;if(Z0(J)){let K=Y0(J,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean($0(J,Z));return G?x$:""}catch{return""}}),Y}function Xq($){let Z=$;return Z=Z.replace(/@break(?!\()/g,v$),Z=Z.replace(/@continue(?!\()/g,x$),Z}function _Z($){let Z=$.includes(v$),Y=Z?$.substring(0,$.indexOf(v$)):$;return{hasBreak:Z,content:Y}}function BZ($){let Z=$.includes(x$),Y=Z?$.substring(0,$.indexOf(x$)):$;return{hasContinue:Z,content:Y}}function HZ($){let Z=$;return Z=P$(Z,"@break",(Y)=>{let X=Y.trim();if(!g5(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=P$(Z,"@continue",(Y)=>{let X=Y.trim();if(!g5(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Jq($){let Z=/@forelse\s*\(/g,Y,X=[],Q=/@foreach\s*\(/g,J=/@endforeach/g,G;while((G=Q.exec($))!==null)X.push({pos:G.index,delta:1});while((G=J.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((z,U)=>z.pos-U.pos);let K=[],q=0;for(let z of X)q+=z.delta,K.push({pos:z.pos,depth:q});function W(z){let U=0,_=K.length-1,B=0;while(U<=_){let j=U+_>>1;if(K[j].pos<=z)B=K[j].depth,U=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let z=Y.index,U=Y.index+Y[0].length-1,_=1,B=U+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(U+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,A=V,R=/@forelse\s*\(/g,N=/@endforelse/g,T=-1;while(w>0&&A<$.length){R.lastIndex=A,N.lastIndex=A;let k=R.exec($),b=N.exec($);if(!b)break;if(k&&k.index<b.index)w++,A=k.index+k[0].length;else{if(w--,w===0){T=b.index;break}A=b.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,C=0;while(C<M.length){let k=M.indexOf("@",C);if(k===-1)break;let b=M.substring(k);if(/^@forelse\s*\(/.test(b))E++,C=k+1;else if(b.startsWith("@endforelse"))E--,C=k+11;else if(E===0&&b.startsWith("@empty")){if(M.length<=k+6||!/[a-z]/i.test(M[k+6])){D=k;break}C=k+1}else C=k+1}if(D===-1)continue;return{start:z,end:I,arrayExpr:F,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function jZ($,Z){let Y=$;while(!0){let X=Jq(Y);if(!X)break;let{start:Q,end:J,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:W}=X;try{let z;if(Z0(G))z=Y0(G,Object.keys(Z))(...Object.values(Z));else z=$0(G,Z);let U;if(!Array.isArray(z)||z.length===0)U=W;else U=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,Q)+U+Y.substring(J)}catch(z){let U=z instanceof Error?z.message:String(z),_=r("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,i.EVALUATION_ERROR);Y=Y.substring(0,Q)+_+Y.substring(J)}}return Y}function v7($,Z,Y,X){let Q=$;Q=jZ(Q,Z);function J(q){let W=/@foreach\s*\(/g,z;while((z=W.exec(q))!==null){let U=z.index,_=z.index+z[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=U,V=L.substring(0,F),w=L.substring(F+4),A=H+1,R=1,N=A,T=/@foreach\s*\(/g,M=/@endforeach/g;while(R>0&&N<q.length){T.lastIndex=N,M.lastIndex=N;let I=T.exec(q),D=M.exec(q);if(!D)break;if(I&&I.index<D.index)R++,N=I.index+I[0].length;else{if(R--,R===0){let E=q.substring(A,D.index),C=D.index+11;return{start:O,end:C,arrayExpr:V,itemVar:w,content:E}}N=D.index+11}}}return null}function G(q,W){let z=q;while(!0){let U=J(z);if(!U)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=U;try{let F=j.trim(),O;if(Z0(F))O=Y0(F,Object.keys(W))(...Object.values(W));else O=$0(F,W);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,i.TYPE_ERROR);z=z.substring(0,_)+D+z.substring(B);continue}let w=X?.loops?.useAltLoopVariable??eK,A=H.trim(),R=null,N,T=!1;if(A.includes("=>")){let D=A.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],N=D[1];else N=A}else if(!A.startsWith("[")&&!A.startsWith("{")&&A.includes(",")){let D=A.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],R=D[1],T=!0;else N=A}else N=A;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],C={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},k={...W,loop:C,$loop:C};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))f.forEach((m,n)=>{if(m)k[m]=E[n]});else k[N]=E}else k[N]=E;if(R)if(!T&&V&&Array.isArray(E)&&E.length===2)k[R]=E[0],k[N]=E[1];else k[R]=D;let b=Yq(L,k),P=BZ(b);if(P.hasContinue){M+=P.content;continue}let d=_Z(b);if(d.hasBreak){M+=d.content;break}if(b=jZ(b,k),b=G(b,k),b=N1(b,k,Y),b=Xq(b),d=_Z(b),d.hasBreak){M+=d.content;break}if(P=BZ(b),P.hasContinue){M+=P.content;continue}b=l0(b,k,Y),b=Zq(b,k),b=$q(b,k),M+=b}z=z.substring(0,_)+M+z.substring(B)}catch(F){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,i.EVALUATION_ERROR);z=z.substring(0,_)+O+z.substring(B)}}return z}Q=G(Q,Z),Q=LZ(Q,Z,Y,X);let K=X?.loops?.maxWhileIterations??tK;return Q=Kq(Q,Z,K),Q}function OZ($){return g5($)}function LZ($,Z,Y,X){let Q=$,J=!0;while(J){J=!1;let G=Q.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=K+G[0].length-1,W=D0(Q,"(",")",q);if(W===-1)break;let z=Q.slice(q+1,W),U=W+1,_=T$(Q.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!OZ(z)){let H=r("For",`Unsafe expression in @for: ${z}`,i.UNSAFE_EXPRESSION);Q=Q.substring(0,K)+H+Q.substring(j),J=!0;continue}try{let H=Qq(z),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let R=Gq({forExpr:z,content:B,iterVarNames:H,context:Z,filePath:Y,options:X});Q=Q.substring(0,K)+R+Q.substring(j),J=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(R,N)=>{return`\${${N}}`});V=HZ(V);let A=Function(...F,`
2656
2656
  let result = '';
2657
2657
  for (${z}) {
2658
2658
  result += \`${V}\`;
@@ -2709,12 +2709,12 @@ ${Wq($).split(",").map((q)=>q.trim()).filter(Boolean).map((q)=>` try { __scopeR
2709
2709
  } finally {
2710
2710
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
2711
2711
  }
2712
- })();`}function _q($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let Q=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let J=Y[1],G=Y[2],K=Y[3];return{html:`${J}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function jq($){if($.__onceStore instanceof Set)return $.__onceStore;return Bq}async function g7($,Z,Y,X,Q,J=new Set){let G=X.partialsDir||K0.join(K0.dirname(Y),"partials");if(G&&!K0.isAbsolute(G))G=K0.resolve(process.cwd(),G);let K=qq($,"@partial","@include"),q=jq(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let R=A[1],N=W(R,G,Y),T="";if(N&&await Bun.file(N).exists())Q.add(N),T=`@include(${w})`;K=K.substring(0,L)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let R=K.substring(V+1,A-1),N=f7(R,0);if(N===-1){L.lastIndex=A;continue}let T=R.substring(0,N).trim(),M=R.substring(N+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=A;continue}let D=I[1],E=M.substring(I[0].length),C,k=f7(E,0);if(k!==-1)C=E.substring(k+1).trim();try{let S=`Boolean(${T})`,P;if(Z0(S)){let m=Y0(S,Object.keys(Z));P=Boolean(m(...Object.values(Z)))}else P=Boolean($0(S,Z));let d=H?!P:P,f="";if(d){let m=W(D,G,Y);if(m&&await Bun.file(m).exists())Q.add(m);f=`@include('${D}'${C?`, ${C}`:""})`}K=K.substring(0,O)+f+K.substring(A),L.lastIndex=0}catch(S){let P=S instanceof Error?S.message:String(S),d=J0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+d+K.substring(A),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),R=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let[,N,T,M,I]=R;try{let D,E=T.trim();if(Z0(E))D=Y0(E,Object.keys(Z))(...Object.values(Z));else D=$0(E,Z);let C="";if(Array.isArray(D)&&D.length>0)for(let k of D){let S={...Z,[M]:k},P=await U(N,S,$,L);C+=P}else if(I)C=await U(I,{},$,L);K=K.substring(0,L)+C+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+J0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),R=w.match(/^\s*(\[[^\]]+\])/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let N=R[1],T=w.slice(R[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let C=1,k=1;while(k<T.length&&C>0){if(T[k]==="{")C++;else if(T[k]==="}"){if(C--,C===0)break}k++}M=T.substring(0,k+1),T=T.slice(k+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let C=JSON.parse(N.replace(/'/g,'"')),k={};if(M)try{k=H0(M,Z)}catch(P){let d=P instanceof Error?P.message:String(P);if(X.debug){let f=J0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,L,A);K=K.replace(A,()=>f)}else K=K.replace(A,()=>D||"");continue}let S=!1;for(let P of C){let d=W(P,G,Y);if(!d)continue;if(await l(d)){let f=await U(P,k,$,L);K=K.replace(A,()=>f),S=!0;break}}if(!S)if(D!==void 0)K=K.replace(A,()=>D);else if(X.debug){let P=J0("Include",`None of the includeFirst paths exist: ${N}`,Y,$,L,A);K=K.replace(A,()=>P)}else K=K.replace(A,"")}catch(C){let k=C instanceof Error?C.message:String(C),S=J0("Include",`Error processing @includeFirst: ${k}`,Y,$,L,A);K=K.replace(A,()=>S)}j.lastIndex=0}}function W(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=K0.resolve(H),V=K0.resolve(K0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=K0.resolve(H,F);else w=K0.resolve(V,F);let A=K0.normalize(w),R=A.startsWith(O+K0.sep)||A===O,N=A.startsWith(V+K0.sep)||A===V,T=!1,M=K0.dirname(V);if(A.startsWith(M+K0.sep)){if(!K0.relative(M,A).split(K0.sep).some((C)=>C.startsWith(".")&&C!=="."&&C!==".."))T=!0}if(!R&&!N&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let z=K0.resolve(Y);J.add(z);async function U(j,H={},L,F){let O=W(j,G,Y);if(!O)return J0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=K0.resolve(O);if(J.has(V)){let w=[...J,V].map((A)=>K0.basename(A)).join(" -> ");return J0("Include",`Circular include detected: ${w}`,Y,L,F)}try{Q.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let m=f instanceof Error?f.message:String(f);return J0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (k7(),E7));w=f(w,Z)}if(w&&(X.debug||!U5()&&!_$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (y7(),ZZ));f(w,O)}catch{}let A=w;try{let{processESImports:f}=await Promise.resolve().then(() => (m7(),RZ));await f(w,Z,O,X,Q)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let R=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(R)A=R[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,m]of Object.entries(H))I[f]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],C="",k=null;for(let f of E){let m=f[1]||"",n=f[2]||"",A0=m.includes("server"),o0=H1(m),S0="";try{let{extractAndStripCssImports:e,renderVendorStyleTags:B0}=await Promise.resolve().then(() => (X5(),i3)),z0=e(n,{filePath:O,projectRoot:process.cwd()});n=z0.code,S0=B0(z0.styles)}catch(e){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,e instanceof Error?e.message:e)}if(o0&&n.trim())n=O1(n);if(!A0)try{let{hasUserImports:e,bundleClientScript:B0}=await Promise.resolve().then(() => (v5(),P5));if(e(n))n=await B0(n,O,{projectRoot:process.cwd()})}catch(e){if(X.debug)console.warn(`[stx] bundler skipped for ${O}:`,e instanceof Error?e.message:e)}let M0=zq(n);if(M0&&!A0){k=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++VZ}`;let e=s0(n),B0=Uq(e,k);C+=`${S0}<script data-stx-scoped>${B0}</script>
2713
- `;continue}if(A0)try{let{extractVariables:e}=await Promise.resolve().then(() => (T5(),C$));await e(n,I,O)}catch(e){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,e)}if(!A0&&!M0){let e=m.replace(/\bclient\b/i,"").trim();k=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++VZ}`;let B0=s0(n),z0=`
2712
+ })();`}function _q($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let Q=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(Q)return{html:$,mergedIntoExisting:Q[1]};let J=Y[1],G=Y[2],K=Y[3];return{html:`${J}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function jq($){if($.__onceStore instanceof Set)return $.__onceStore;return Bq}async function g7($,Z,Y,X,Q,J=new Set){let G=X.partialsDir||K0.join(K0.dirname(Y),"partials");if(G&&!K0.isAbsolute(G))G=K0.resolve(process.cwd(),G);let K=qq($,"@partial","@include"),q=jq(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let R=A[1],N=W(R,G,Y),T="";if(N&&await Bun.file(N).exists())Q.add(N),T=`@include(${w})`;K=K.substring(0,L)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let R=K.substring(V+1,A-1),N=f7(R,0);if(N===-1){L.lastIndex=A;continue}let T=R.substring(0,N).trim(),M=R.substring(N+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=A;continue}let D=I[1],E=M.substring(I[0].length),C,k=f7(E,0);if(k!==-1)C=E.substring(k+1).trim();try{let b=`Boolean(${T})`,P;if(Z0(b)){let m=Y0(b,Object.keys(Z));P=Boolean(m(...Object.values(Z)))}else P=Boolean($0(b,Z));let d=H?!P:P,f="";if(d){let m=W(D,G,Y);if(m&&await Bun.file(m).exists())Q.add(m);f=`@include('${D}'${C?`, ${C}`:""})`}K=K.substring(0,O)+f+K.substring(A),L.lastIndex=0}catch(b){let P=b instanceof Error?b.message:String(b),d=J0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+d+K.substring(A),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),R=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let[,N,T,M,I]=R;try{let D,E=T.trim();if(Z0(E))D=Y0(E,Object.keys(Z))(...Object.values(Z));else D=$0(E,Z);let C="";if(Array.isArray(D)&&D.length>0)for(let k of D){let b={...Z,[M]:k},P=await U(N,b,$,L);C+=P}else if(I)C=await U(I,{},$,L);K=K.substring(0,L)+C+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+J0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),A=K.substring(L,V+1),R=w.match(/^\s*(\[[^\]]+\])/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let N=R[1],T=w.slice(R[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let C=1,k=1;while(k<T.length&&C>0){if(T[k]==="{")C++;else if(T[k]==="}"){if(C--,C===0)break}k++}M=T.substring(0,k+1),T=T.slice(k+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let C=JSON.parse(N.replace(/'/g,'"')),k={};if(M)try{k=H0(M,Z)}catch(P){let d=P instanceof Error?P.message:String(P);if(X.debug){let f=J0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,L,A);K=K.replace(A,()=>f)}else K=K.replace(A,()=>D||"");continue}let b=!1;for(let P of C){let d=W(P,G,Y);if(!d)continue;if(await l(d)){let f=await U(P,k,$,L);K=K.replace(A,()=>f),b=!0;break}}if(!b)if(D!==void 0)K=K.replace(A,()=>D);else if(X.debug){let P=J0("Include",`None of the includeFirst paths exist: ${N}`,Y,$,L,A);K=K.replace(A,()=>P)}else K=K.replace(A,"")}catch(C){let k=C instanceof Error?C.message:String(C),b=J0("Include",`Error processing @includeFirst: ${k}`,Y,$,L,A);K=K.replace(A,()=>b)}j.lastIndex=0}}function W(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=K0.resolve(H),V=K0.resolve(K0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=K0.resolve(H,F);else w=K0.resolve(V,F);let A=K0.normalize(w),R=A.startsWith(O+K0.sep)||A===O,N=A.startsWith(V+K0.sep)||A===V,T=!1,M=K0.dirname(V);if(A.startsWith(M+K0.sep)){if(!K0.relative(M,A).split(K0.sep).some((C)=>C.startsWith(".")&&C!=="."&&C!==".."))T=!0}if(!R&&!N&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let z=K0.resolve(Y);J.add(z);async function U(j,H={},L,F){let O=W(j,G,Y);if(!O)return J0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=K0.resolve(O);if(J.has(V)){let w=[...J,V].map((A)=>K0.basename(A)).join(" -> ");return J0("Include",`Circular include detected: ${w}`,Y,L,F)}try{Q.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let m=f instanceof Error?f.message:String(f);return J0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (k7(),E7));w=f(w,Z)}if(w&&(X.debug||!U5()&&!_$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (y7(),ZZ));f(w,O)}catch{}let A=w;try{let{processESImports:f}=await Promise.resolve().then(() => (m7(),RZ));await f(w,Z,O,X,Q)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let R=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(R)A=R[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;A=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),A=A.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,m]of Object.entries(H))I[f]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],C="",k=null;for(let f of E){let m=f[1]||"",n=f[2]||"",A0=m.includes("server"),o0=H1(m),S0="";try{let{extractAndStripCssImports:e,renderVendorStyleTags:B0}=await Promise.resolve().then(() => (X5(),i3)),z0=e(n,{filePath:O,projectRoot:process.cwd()});n=z0.code,S0=B0(z0.styles)}catch(e){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,e instanceof Error?e.message:e)}if(o0&&n.trim())n=O1(n);if(!A0)try{let{hasUserImports:e,bundleClientScript:B0}=await Promise.resolve().then(() => (v5(),P5));if(e(n))n=await B0(n,O,{projectRoot:process.cwd()})}catch(e){if(X.debug)console.warn(`[stx] bundler skipped for ${O}:`,e instanceof Error?e.message:e)}let I0=zq(n);if(I0&&!A0){k=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++VZ}`;let e=s0(n),B0=Uq(e,k);C+=`${S0}<script data-stx-scoped>${B0}</script>
2713
+ `;continue}if(A0)try{let{extractVariables:e}=await Promise.resolve().then(() => (T5(),C$));await e(n,I,O)}catch(e){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,e)}if(!A0&&!I0){let e=m.replace(/\bclient\b/i,"").trim();k=`stx_scope_${K0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++VZ}`;let B0=s0(n),z0=`
2714
2714
  if (!window.stx._scopes) window.stx._scopes = {};
2715
2715
  window.stx._scopes['${k}'] = { __destroyCallbacks: __destroyHooks };
2716
- `,b=wZ(B0,z0);C+=`${S0}<script data-stx-scoped${e?` ${e}`:""}>${b}</script>
2717
- `}}if(k){let f=_q(A,k);if(A=f.html,f.mergedIntoExisting)C=C.replace(`window.stx._scopes['${k}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),k=f.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await g7(A,I,O,X,Q,J);let{processLoops:S}=await Promise.resolve().then(() => (x7(),FZ)),P=S(A,I,O);P=N1(P,I,O);let d=P1(w);if(P=l0(P,I,O,{forceSignals:d}),M)P+=`
2716
+ `,S=wZ(B0,z0);C+=`${S0}<script data-stx-scoped${e?` ${e}`:""}>${S}</script>
2717
+ `}}if(k){let f=_q(A,k);if(A=f.html,f.mergedIntoExisting)C=C.replace(`window.stx._scopes['${k}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),k=f.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await g7(A,I,O,X,Q,J);let{processLoops:b}=await Promise.resolve().then(() => (x7(),FZ)),P=b(A,I,O);P=N1(P,I,O);let d=P1(w);if(P=l0(P,I,O,{forceSignals:d}),M)P+=`
2718
2718
  `+M;if(C)P+=`
2719
2719
  `+C;return P}catch(w){let A=w instanceof Error?w.message:String(w);return J0("Include",`Error processing include ${j}: ${A}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,H=j+B[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){_.lastIndex=F;continue}let A=w[1],R,N=V.substring(w[0].length),T=f7(N,0);if(T!==-1)R=N.substring(T+1).trim();let M={};if(R)try{M=H0(R,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,J0("Include",`Error parsing include variables for ${A}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await U(A,M,$,j);K=K.substring(0,j)+I+K.substring(F),_.lastIndex=0}return K}function h7($,Z){let Y=$;function X(Q,J,G,K){let q=Q,W=!0;while(W){W=!1;let z=new RegExp(`@${J}\\(['"]([^'"]+)['"]\\)`),U=q.match(z);if(!U||U.index===void 0)break;let _=U.index,B=U[1],j=_+U[0].length,H=new RegExp(`@${J}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<q.length){let A=q.slice(O),R=A.match(H),N=A.match(L),T=R?O+R.index:1/0,M=N?O+N.index:1/0;if(T<M)F++,O=T+(R[0].length||1);else if(M<1/0){if(F--,F===0){V=M;break}O=M+G.length+1}else break}if(V===-1)break;let w=q.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(w);else Z[B].push(w);q=q.substring(0,_)+q.substring(V+`@${G}`.length),W=!0}return q}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function d7($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
2720
2720
  `)})}var VZ=0,nH,Bq;var AZ=y(()=>{I$();c0();f1();O0();j0();nH=new K5(500),Bq=new Set});import*as u7 from"path";async function NZ($,Z,Y=""){if(u7.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 MZ($,Z,Y,"@js","@endjs")}async function TZ($,Z,Y=""){if(u7.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((J)=>({...J,displayName:`User ${J.id}: ${J.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return MZ($,Z,Y,"@ts","@endts")}async function MZ($,Z,Y,X,Q){let J=$,G=x1(`${X}([\\s\\S]*?)${Q}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:W,content:z,index:U}of K)try{let _=Object.keys(Z),B=Object.values(Z),j=z.trim();if(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 L=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((A)=>A.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=L.length>0?`return { ${L.join(", ")} };`:"return {};",O=`
@@ -7196,10 +7196,10 @@ else {
7196
7196
  var root = scriptEl ? scriptEl.nextElementSibling : null;
7197
7197
  if (!root && scriptEl) root = scriptEl.previousElementSibling || scriptEl.parentElement;
7198
7198
 
7199
- // SPA fallback: during router navigation, script is appended to <body>
7199
+ // SPA fallback: during router navigation, script is appended to body>
7200
7200
  // (not inside the content container), so nextElementSibling won't find the page content.
7201
7201
  // Only use fallback when we genuinely couldn't find a suitable root element.
7202
- // Do NOT fallback just because the script is in <body> \u2014 layout scripts in <body>
7202
+ // Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
7203
7203
  // with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
7204
7204
  var needsFallback = !root || root === document.body
7205
7205
  || (root && root.tagName === 'SCRIPT');
@@ -7518,7 +7518,7 @@ else {
7518
7518
  mountCallbacks.forEach(fn => fn());
7519
7519
  });
7520
7520
 
7521
- // Multi-root fragment fix: a no-<body> setup page tags only the FIRST
7521
+ // Multi-root fragment fix: a no-body> setup page tags only the FIRST
7522
7522
  // top-level element with data-stx (signal-processing.ts marks one element),
7523
7523
  // so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text
7524
7524
  // never hydrated, which read as "{{ }} doesn't work under :if/:for". The
@@ -7615,7 +7615,7 @@ else {
7615
7615
  el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
7616
7616
  });
7617
7617
 
7618
- // Process <head> elements (title, meta) that may contain {{ }} expressions
7618
+ // Process head> elements (title, meta) that may contain {{ }} expressions
7619
7619
  // Use componentScope which now contains variables from processed components
7620
7620
  const headElements = document.querySelectorAll('head title, head meta[content]');
7621
7621
  headElements.forEach(el => {
@@ -7811,7 +7811,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
7811
7811
 
7812
7812
  // Apply new page's SFC setup function. During SPA navigation, re-executed page
7813
7813
  // scripts set window.stx._latestSetup to the new setup function. This takes priority
7814
- // over the stale data-stx attribute on <body> (which has the PREVIOUS page's function name).
7814
+ // over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).
7815
7815
  var usedLatestSetup = false;
7816
7816
  if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {
7817
7817
  try {
@@ -7895,7 +7895,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
7895
7895
 
7896
7896
  // Process the container content \u2014 bind {{ }}, :attr, @event directives.
7897
7897
  // Run synchronously (not in setTimeout) so componentScope is captured correctly.
7898
- // The DOMContentLoaded path processes <body> synchronously \u2014 the SPA path must match.
7898
+ // The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.
7899
7899
  console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));
7900
7900
  if (!container.__stx_scope) {
7901
7901
  // Dispose previous effects on the container (from prior navigation)
@@ -10735,23 +10735,23 @@ ${V}`:V,Z.__sections=j}}if(H)try{let O;if(E0.isAbsolute(H))O=H,Q.add(H);else O=a
10735
10735
  ${q}`,U(q)}catch(O){return d0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return U(await vY(q,Z,Y,G,Q))}function mW($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,X,Q)=>{let J=Z[X];if(J!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(J))return J}return Q||""})}function uW($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",X={};for(let[Q,J]of Object.entries(process.env))if(Q.startsWith(Y)&&J!==void 0)X[Q]=J;$.$env=X}async function pW($,Z){await d1(()=>PZ($,Z),void 0,(Y)=>{d0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function lW($,Z,Y){let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=X.exec($))!==null){let J=Q[1],G=Q[2];if(!/\bserver\b/.test(J)||!G.trim())continue;try{let{extractVariables:q}=await Promise.resolve().then(() => (T5(),C$));await q(G,Z,Y,{preserveExisting:!0})}catch(q){let W=q instanceof Error?q:Error(String(q));d0.log(W,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${W.message}`)}}}async function cW($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (c0(),q6));return X($,Z,{skipServer:!0})}catch(X){let Q=X instanceof Error?X:Error(String(X));return d0.log(Q,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${Q.message}`),$}}async function vY($,Z,Y,X,Q){let J=$,G=X;if(await lW(J,Z,Y),J=await cW(J,Z,Y),J=await NZ(J,Z,Y),J=await TZ(J,Z,Y),J=await x8(J,Z,Y,G),P1(J))J=t7(J,Z),J=$3(J,Z);J=e7(J);let{processStreamDirectives:K}=await Promise.resolve().then(() => (k7(),E7));J=K(J,Z),J=v7(J,Z,Y,G),J=await Y4(J,Z,Y,G,Q),J=await uZ(J,Z,Y,G,Q),J=w6(J,Z,Y,G);let{processDeferDirectives:q}=await Promise.resolve().then(() => M2);J=q(J,Z,Y);let{processTeleportDirectives:W}=await Promise.resolve().then(() => D2);J=W(J,Z,Y);let{processTransitionDirectives:z,processTransitionAttributes:U}=await Promise.resolve().then(() => b2);J=z(J,Z,Y),J=U(J);let{processErrorBoundaryDirectives:_}=await Promise.resolve().then(() => C2);J=_(J,Z,Y);let{processSuspenseDirectives:B}=await Promise.resolve().then(() => P2);J=B(J,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => g2);J=j(J,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => d2);J=H(J,Z,Y);let{processVirtualListDirectives:L,processVirtualGridDirectives:F,processInfiniteListDirectives:O}=await Promise.resolve().then(() => (i2(),c2));J=L(J,Z,Y),J=F(J,Z,Y),J=O(J,Z,Y);let{processPartialHydrationDirectives:V,processStaticDirectives:w}=await Promise.resolve().then(() => (KY(),GY));J=V(J,Z,Y),J=w(J);let{processComputedDirectives:A,processWatchDirectives:R}=await Promise.resolve().then(() => (VY(),FY));J=A(J,Z,Y),J=R(J,Z,Y);let{processFormValidationDirectives:N}=await Promise.resolve().then(() => (TY(),NY));J=N(J,Z,Y);let{processHeadDirective:T,processTitleDirective:M,processMetaDirective:I,resetHead:D}=await Promise.resolve().then(() => (F5(),F7));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let E=T(J);if(J=E.content,E.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${E.headContent}
10736
10736
  `;if(J=M(J,Z),J=I(J,Z),J=yZ(J),J=j7(J,Z),J=P8(J),J=DZ(J),J=await g7(J,Z,Y,G,Q),J=await Y4(J,Z,Y,G,Q),J=J.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),J=Q3(J),J=N1(J,Z,Y),J=H7(J,Z),J=O7(J,Z),J=b$(J,Z),J=m8(J,Z),J=u8(J,Z),J=await w8(J,Z,Y,G),J=await k6(J,Z,Y),J=await n8(J,Z,Y,G),J=B6(J,Z,Y,G),J=f9(J,Z,Y,G),J=g9(J,Z,Y),J=h9(J,Z,Y,G),J=b8(J,Z,Y,G),J=X3(J,Z),J=J3(J),J=V2(J),!G.skipEventDirectives)J=B8(J,Z,Y);if(J=F8(J,Z,Y),G.debug){let x=/\bx-data\s*=/.test(J),g=t$($);if(x&&g)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
10737
10737
  Both work on the same page, but they manage separate scopes.
10738
- Prefer signals (state/derived/effect) for new components.`)}J=fZ(J,Z),J=await l0(J,Z,Y),J=w2(J),J=A2(J),J=J8(J);let{processXElementDirectives:C}=await Promise.resolve().then(() => DY);J=C(J);let k=Z.__originalFilePath||Y,S=Z5(Z);if(J=await Z3(J,G,k,S),J=await SZ(J,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (kY(),EY));J=await g(J,{publicDir:x})}if(G.seo?.enabled)J=d9(J,Z,G);let P=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
10738
+ Prefer signals (state/derived/effect) for new components.`)}J=fZ(J,Z),J=await l0(J,Z,Y),J=w2(J),J=A2(J),J=J8(J);let{processXElementDirectives:C}=await Promise.resolve().then(() => DY);J=C(J);let k=Z.__originalFilePath||Y,b=Z5(Z);if(J=await Z3(J,G,k,b),J=await SZ(J,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (kY(),EY));J=await g(J,{publicDir:x})}if(G.seo?.enabled)J=d9(J,Z,G);let P=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
10739
10739
  </head>`);if(/<head\b[^>]*>/i.test(x))return x.replace(/(<head\b[^>]*>)/i,`$1
10740
10740
  ${g}`);if(/<html\b[^>]*>/i.test(x))return x.replace(/(<html\b[^>]*>)/i,`$1
10741
10741
  <head>
10742
10742
  ${g}
10743
10743
  </head>`);return x},{renderHead:d,getHead:f}=await Promise.resolve().then(() => (F5(),F7)),m=Z.__stx_runtime_head,n=m&&(m.title||m.meta?.length||m.link?.length)?m:f();if(n.title||n.meta?.length||n.link?.length){let x=d(n);if(x)J=P(J,x)}if(E.headContent)J=P(J,E.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)J=S8(J,G.csp,Z);if(G.analytics?.enabled)J=G8(J,G);if(G.heatmap?.enabled)J=M6(J,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:x}=await Promise.resolve().then(() => (CY(),yY));J=x(J,G)}let A0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(J),o0=/\bSTX\.\w+/.test(J),S0=/window\.STX\s*=/.test(J);if(A0&&o0&&!S0){let g=`<script data-stx-scoped>
10744
10744
  ${$8()}
10745
- </script>`;if(J.includes("</head>")){let u=J.indexOf("</head>"),Q0=J.slice(0,u).indexOf("<script");if(Q0!==-1){let I0=J.slice(0,Q0),b0=J.slice(Q0);J=I0+g+`
10745
+ </script>`;if(J.includes("</head>")){let u=J.indexOf("</head>"),Q0=J.slice(0,u).indexOf("<script");if(Q0!==-1){let R0=J.slice(0,Q0),b0=J.slice(Q0);J=R0+g+`
10746
10746
  `+b0}else J=J.replace("</head>",`${g}
10747
10747
  </head>`)}else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
10748
10748
  ${g}`);else J=g+`
10749
- `+J}{let x=/<script\s+server\b[^>]*>/gi,g,u=[];while((g=x.exec(J))!==null){let o=g.index+g[0].length,Q0=hW(J,o);if(Q0===-1)continue;let I0=Q0+9;while(I0<J.length&&/\s/.test(J[I0]))I0++;u.push({start:g.index,end:I0})}for(let o=u.length-1;o>=0;o--){let{start:Q0,end:I0}=u[o];J=J.substring(0,Q0)+J.substring(I0)}}let M0=g$(J,Y);if(M0.hasScoped)J=M0.html;let e=Z.__stx_event_bindings||[],B0=!1,z0=[],b=/\s:[a-z][\w.-]*\s*=/.test(J),{scanScriptTags:v}=await Promise.resolve().then(() => (Y3(),j2));for(let x of v(J,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))z0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:u}of z0){B0=!0;let o=u;K3(u,Y,X.strict);let Q0=await Y5(u,{eventBindings:e,attrs:g,hasColonDirectives:b,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:S});J=J.replace(x,()=>Q0)}if(B0)Z.__stx_event_bindings=[];return J}var y1="<!--PARENT_CONTENT_PLACEHOLDER-->";var S7=y(()=>{e9();m5();H4();Z8();Q8();K8();F4();O4();j8();X5();V8();A8();I$();y8();v8();g8();a0();F5();c0();p8();o8();AZ();IZ();x7();V4();bZ();f1();CZ();Y7();j0();vZ();gZ();mZ();pZ();l7();Y3();m7();F2();G3();q3();O0();y7();G3();q3()});var xY=()=>{};var mY={};s(mY,{renderSlot:()=>gY,processSlots:()=>dY,parseSlots:()=>fY,parseSlotElement:()=>nW,extractSlotContent:()=>rW,applySlots:()=>aW});function iW($,Z){let Y=1,X=Z,Q="<template",J="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(Q,X)&&(X+Q.length>=$.length||/[\s>\/]/.test($[X+Q.length]))){Y++,X+=Q.length;continue}if($.startsWith(J,X)){let K=$.indexOf(">",X+J.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function fY($){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,Q=[],J;while((J=X.exec($))!==null){let[z,U,_,B,j]=J,H=U||_||B,L=J.index+z.length,F=iW($,L);if(F!==-1){let O=$.slice(L,F-11).trim();Q.push({start:J.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}Q.sort((z,U)=>U.start-z.start);for(let z of Q)Y=Y.slice(0,z.start)+Y.slice(z.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,q;while((q=K.exec(Y))!==null){let[z,U,_,B,j,H]=q,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${U}${O?" "+O:""}>${H}</${U}>`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:V})}let W=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((q=W.exec(Y))!==null){let[z,U,_,B,j]=q,H=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${U}${F?" "+F:""} />`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:O})}G.sort((z,U)=>U.start-z.start);for(let z of G){let U=Z.named.get(z.slotName);if(U)U.content+=z.element;else Z.named.set(z.slotName,{name:z.slotName,content:z.element});Y=Y.slice(0,z.start)+Y.slice(z.end)}return Z.default=Y.trim(),Z}function nW($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},Q=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,J;while((J=Q.exec($))!==null)X[J[1]]=J[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function gY($,Z,Y,X){if(!$)return Y;let Q=$.content;if($.propsBinding&&Object.keys(Z).length>0){let J=$.propsBinding.trim(),G={...X};if(J.startsWith("{")&&J.endsWith("}")){let K=J.slice(1,-1).split(",").map((q)=>q.trim()).filter(Boolean);for(let q of K){let[W,z]=q.split(":").map((_)=>_.trim()),U=z||W;if(Z[W]!==void 0)G[U]=Z[W]}}else G[J]=Z;Q=oW(Q,G)}return Q}function oW($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let Q=X.trim(),J=hY(Q,Z);return g0(String(J??""))}catch{return`{{ ${X} }}`}})}function hY($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),Q=Z;for(let J of X)if(Q&&typeof Q==="object"&&J in Q)Q=Q[J];else return;return Q}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,Q,J]=Y,G=Z[X],K=parseInt(J,10);if(typeof G==="number")switch(Q){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!Z0($))return;return Y0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function dY($,Z,Y){let X=$;X=await sW(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,q,W)=>{let z=Z.named.get(K),U=W?.trim()||"",_=q||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(_))!==null){let L=H[1],F=H[2];B[L]=hY(F,Y)}return await gY(z,B,U,Y)});let J=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(J,(G,K)=>{if(G.includes("name="))return G;let q=K?.trim()||"";return Z.default||q}),X}async function sW($,Z,Y){let X=[],Q=[];$.replace(Z,(K,...q)=>{let W=q[q.length-2];return Q.push({match:K,index:W}),X.push(Y(K,...q.slice(0,-2))),K});let J=await Promise.all(X),G=$;for(let K=Q.length-1;K>=0;K--){let{match:q,index:W}=Q[K];G=G.slice(0,W)+J[K]+G.slice(W+q.length)}return G}function rW($){let Z=fY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function aW($,Z,Y,X){return await dY($,{default:Z,named:Y},X)}var uY=y(()=>{c0();O0()});import tW from"fs";import h from"path";function pY($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function $U($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function H1($){return!$U($)}function O1($){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,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`});let Q=new Bun.Transpiler({loader:"ts",target:"browser",define:p0()}).transformSync(Z);for(let J=0;J<Y.length;J++)Q=Q.replace(`"__STX_EXPR_${J}__"`,Y[J]),Q=Q.replace(`'__STX_EXPR_${J}__'`,Y[J]);return Q}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function ZU($){let Z=[],Y=new Set,X=0,Q=0,J=$.length,G=(z)=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]===z){Q++;return}Q++}},K=()=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]==="`"){Q++;return}if($[Q]==="$"&&$[Q+1]==="{"){Q+=2;let z=1;while(Q<J&&z>0)if($[Q]==="{")z++,Q++;else if($[Q]==="}")z--,Q++;else if($[Q]==="'"||$[Q]==='"')G($[Q]);else if($[Q]==="`")K();else Q++;continue}Q++}},q=()=>{if($[Q]==="/"&&$[Q+1]==="/"){while(Q<J&&$[Q]!==`
10750
- `)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<J-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},W=()=>{if(X!==0)return;let z=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(Q<J){if(q())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){X++,Q++;continue}if($[Q]==="}"){X--,Q++;continue}if(X===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))W();Q++}return Z}function YU($){let Z=[],Y=0,X=0,Q=null;for(let J=0;J<$.length;J++){let G=$[J];if(Q){if(G==="\\"){J++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,J)),X=J+1}if(X<$.length)Z.push($.slice(X));return Z}function XU($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let Q=$[X];if(Y){if(Q==="\\"){X++;continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let J=$[X-1],G=$[X+1];if(J==="!"||J==="<"||J===">"||J==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function JU($,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 Q=X,J=0,G=-1;for(;X>=0;X--){let q=$[X];if(q==="}")J++;else if(q==="{"){if(J--,J===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let q of YU(K)){let W=q.trim();if(!W||W.startsWith("..."))continue;let z=XU(W);if(z===-1)continue;let U=W.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let _=W.slice(z+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[U]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function lY($,Z,Y,X,Q){let J=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[J,J.toLowerCase(),G(J),K(J)])if(q.has(L))return!0}let W=[...new Set([`${J}.stx`,`${G(J)}.stx`,`${K(J)}.stx`])],z=typeof Q.root==="string"?h.resolve(Q.root):void 0,U=z??h.dirname(X),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(h.join(h.dirname(j),"components"));B(Z),B(h.join(h.dirname(X),"components")),B(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(z)B(h.resolve(z,"resources/views/components")),B(h.resolve(z,"resources/components")),B(h.resolve(z,"src/components")),B(h.resolve(z,"components"));if(J.startsWith("./")||J.startsWith("../"))return l(h.resolve(h.dirname(X),`${J}.stx`));for(let L of _){let F=h.isAbsolute(L)?L:h.resolve(U,L);for(let O of W)if(await l(h.join(F,O)))return!0}return!1}function QU($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function k1($,Z,Y,X,Q,J,G,K=new Set,q){let{extractVariables:W}=await Promise.resolve().then(() => (T5(),C$)),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let U=new Set(z);U.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&QU(_)?_:"";try{let j=(b)=>b.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(b)=>b.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=Q.__importedComponents;if(O){let b=[L,L.toLowerCase(),j(L),H(L)];for(let v of b)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let b=[`${L}.stx`,`${j(L)}.stx`,`${H(L)}.stx`],v=[...new Set(b)],x=Q.__originalFilePath,g=[];if(x){let q0=h.join(h.dirname(x),"components");g.push(q0)}if(X)g.push(X);let u=h.join(h.dirname(J),"components");if(!g.includes(u))g.push(u);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let o=G._pluginComponentDirs;if(Array.isArray(o)){for(let q0 of o)if(typeof q0==="string"&&!g.includes(q0))g.push(q0)}let Q0=typeof G.root==="string"?h.resolve(G.root):void 0,I0=Q0??h.dirname(J),b0=[];if(Q0)b0.push(h.resolve(Q0,"resources/views/components")),b0.push(h.resolve(Q0,"resources/components")),b0.push(h.resolve(Q0,"src/components")),b0.push(h.resolve(Q0,"components"));b0.push(h.resolve(import.meta.dir,"components"));for(let q0 of b0)if(!g.includes(q0))g.push(q0);let _1=[...new Set(g.map((q0)=>{if(!q0)return q0;return h.isAbsolute(q0)?q0:h.resolve(I0,q0)}))];if(g.length=0,g.push(..._1),L.startsWith("./")||L.startsWith("../"))F=h.resolve(h.dirname(J),`${L}.stx`),V.push(F);else for(let q0 of g){if(!q0)continue;for(let B1 of v){let e1=h.join(q0,B1);if(V.push(e1),await l(e1)){F=e1;break}}if(F)break;if(!F)try{let B1=await import("fs");if(!B1.statSync(q0,{throwIfNoEntry:!1})?.isDirectory())continue;let y5=8,t=[{path:q0,depth:0}];while(t.length>0&&!F){let u0=t.pop();if(u0.depth>=y5)continue;let q4;try{q4=B1.readdirSync(u0.path,{withFileTypes:!0})}catch{continue}for(let C5 of q4){if(!C5.isDirectory())continue;if(C5.name==="node_modules"||C5.name.startsWith("."))continue;let m3=h.join(u0.path,C5.name);for(let BX of v){let z4=h.join(m3,BX);if(V.push(z4),await l(z4)){F=z4;break}}if(F)break;t.push({path:m3,depth:u0.depth+1})}}}catch{}if(F)break}}if(!F||!await l(F)){let b=V.length>0?`
10749
+ `+J}{let x=/<script\s+server\b[^>]*>/gi,g,u=[];while((g=x.exec(J))!==null){let o=g.index+g[0].length,Q0=hW(J,o);if(Q0===-1)continue;let R0=Q0+9;while(R0<J.length&&/\s/.test(J[R0]))R0++;u.push({start:g.index,end:R0}),x.lastIndex=R0}for(let o=u.length-1;o>=0;o--){let{start:Q0,end:R0}=u[o];J=J.substring(0,Q0)+J.substring(R0)}}let I0=g$(J,Y);if(I0.hasScoped)J=I0.html;let e=Z.__stx_event_bindings||[],B0=!1,z0=[],S=/\s:[a-z][\w.-]*\s*=/.test(J),{scanScriptTags:v}=await Promise.resolve().then(() => (Y3(),j2));for(let x of v(J,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))z0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:u}of z0){B0=!0;let o=u;K3(u,Y,X.strict);let Q0=await Y5(u,{eventBindings:e,attrs:g,hasColonDirectives:S,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});J=J.replace(x,()=>Q0)}if(B0)Z.__stx_event_bindings=[];return J}var y1="<!--PARENT_CONTENT_PLACEHOLDER-->";var S7=y(()=>{e9();m5();H4();Z8();Q8();K8();F4();O4();j8();X5();V8();A8();I$();y8();v8();g8();a0();F5();c0();p8();o8();AZ();IZ();x7();V4();bZ();f1();CZ();Y7();j0();vZ();gZ();mZ();pZ();l7();Y3();m7();F2();G3();q3();O0();y7();G3();q3()});var xY=()=>{};var mY={};s(mY,{renderSlot:()=>gY,processSlots:()=>dY,parseSlots:()=>fY,parseSlotElement:()=>nW,extractSlotContent:()=>rW,applySlots:()=>aW});function iW($,Z){let Y=1,X=Z,Q="<template",J="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(Q,X)&&(X+Q.length>=$.length||/[\s>\/]/.test($[X+Q.length]))){Y++,X+=Q.length;continue}if($.startsWith(J,X)){let K=$.indexOf(">",X+J.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function fY($){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,Q=[],J;while((J=X.exec($))!==null){let[z,U,_,B,j]=J,H=U||_||B,L=J.index+z.length,F=iW($,L);if(F!==-1){let O=$.slice(L,F-11).trim();Q.push({start:J.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}Q.sort((z,U)=>U.start-z.start);for(let z of Q)Y=Y.slice(0,z.start)+Y.slice(z.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,q;while((q=K.exec(Y))!==null){let[z,U,_,B,j,H]=q,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${U}${O?" "+O:""}>${H}</${U}>`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:V})}let W=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((q=W.exec(Y))!==null){let[z,U,_,B,j]=q,H=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${U}${F?" "+F:""} />`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:O})}G.sort((z,U)=>U.start-z.start);for(let z of G){let U=Z.named.get(z.slotName);if(U)U.content+=z.element;else Z.named.set(z.slotName,{name:z.slotName,content:z.element});Y=Y.slice(0,z.start)+Y.slice(z.end)}return Z.default=Y.trim(),Z}function nW($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},Q=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,J;while((J=Q.exec($))!==null)X[J[1]]=J[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function gY($,Z,Y,X){if(!$)return Y;let Q=$.content;if($.propsBinding&&Object.keys(Z).length>0){let J=$.propsBinding.trim(),G={...X};if(J.startsWith("{")&&J.endsWith("}")){let K=J.slice(1,-1).split(",").map((q)=>q.trim()).filter(Boolean);for(let q of K){let[W,z]=q.split(":").map((_)=>_.trim()),U=z||W;if(Z[W]!==void 0)G[U]=Z[W]}}else G[J]=Z;Q=oW(Q,G)}return Q}function oW($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let Q=X.trim(),J=hY(Q,Z);return g0(String(J??""))}catch{return`{{ ${X} }}`}})}function hY($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),Q=Z;for(let J of X)if(Q&&typeof Q==="object"&&J in Q)Q=Q[J];else return;return Q}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,Q,J]=Y,G=Z[X],K=parseInt(J,10);if(typeof G==="number")switch(Q){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!Z0($))return;return Y0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function dY($,Z,Y){let X=$;X=await sW(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,q,W)=>{let z=Z.named.get(K),U=W?.trim()||"",_=q||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(_))!==null){let L=H[1],F=H[2];B[L]=hY(F,Y)}return await gY(z,B,U,Y)});let J=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(J,(G,K)=>{if(G.includes("name="))return G;let q=K?.trim()||"";return Z.default||q}),X}async function sW($,Z,Y){let X=[],Q=[];$.replace(Z,(K,...q)=>{let W=q[q.length-2];return Q.push({match:K,index:W}),X.push(Y(K,...q.slice(0,-2))),K});let J=await Promise.all(X),G=$;for(let K=Q.length-1;K>=0;K--){let{match:q,index:W}=Q[K];G=G.slice(0,W)+J[K]+G.slice(W+q.length)}return G}function rW($){let Z=fY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function aW($,Z,Y,X){return await dY($,{default:Z,named:Y},X)}var uY=y(()=>{c0();O0()});import tW from"fs";import h from"path";function pY($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function $U($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function H1($){return!$U($)}function O1($){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,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(J)=>{let G=Y.length;return Y.push(J),`"__STX_EXPR_${G}__"`});let Q=new Bun.Transpiler({loader:"ts",target:"browser",define:p0()}).transformSync(Z);for(let J=0;J<Y.length;J++)Q=Q.replace(`"__STX_EXPR_${J}__"`,Y[J]),Q=Q.replace(`'__STX_EXPR_${J}__'`,Y[J]);return Q}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function ZU($){let Z=[],Y=new Set,X=0,Q=0,J=$.length,G=(z)=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]===z){Q++;return}Q++}},K=()=>{Q++;while(Q<J){if($[Q]==="\\"){Q+=2;continue}if($[Q]==="`"){Q++;return}if($[Q]==="$"&&$[Q+1]==="{"){Q+=2;let z=1;while(Q<J&&z>0)if($[Q]==="{")z++,Q++;else if($[Q]==="}")z--,Q++;else if($[Q]==="'"||$[Q]==='"')G($[Q]);else if($[Q]==="`")K();else Q++;continue}Q++}},q=()=>{if($[Q]==="/"&&$[Q+1]==="/"){while(Q<J&&$[Q]!==`
10750
+ `)Q++;return!0}if($[Q]==="/"&&$[Q+1]==="*"){Q+=2;while(Q<J-1&&!($[Q]==="*"&&$[Q+1]==="/"))Q++;return Q+=2,!0}return!1},W=()=>{if(X!==0)return;let z=$.slice(Q).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(Q<J){if(q())continue;if($[Q]==="'"||$[Q]==='"'){G($[Q]);continue}if($[Q]==="`"){K();continue}if($[Q]==="{"){X++,Q++;continue}if($[Q]==="}"){X--,Q++;continue}if(X===0&&/[a-z]/i.test($[Q])&&(Q===0||/\s|[;{}()]/.test($[Q-1])))W();Q++}return Z}function YU($){let Z=[],Y=0,X=0,Q=null;for(let J=0;J<$.length;J++){let G=$[J];if(Q){if(G==="\\"){J++;continue}if(G===Q)Q=null;continue}if(G==='"'||G==="'"||G==="`"){Q=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,J)),X=J+1}if(X<$.length)Z.push($.slice(X));return Z}function XU($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let Q=$[X];if(Y){if(Q==="\\"){X++;continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}if(Q==="("||Q==="["||Q==="{")Z++;else if(Q===")"||Q==="]"||Q==="}")Z--;else if(Q==="="&&Z===0){let J=$[X-1],G=$[X+1];if(J==="!"||J==="<"||J===">"||J==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function JU($,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 Q=X,J=0,G=-1;for(;X>=0;X--){let q=$[X];if(q==="}")J++;else if(q==="{"){if(J--,J===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,Q);for(let q of YU(K)){let W=q.trim();if(!W||W.startsWith("..."))continue;let z=XU(W);if(z===-1)continue;let U=W.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let _=W.slice(z+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[U]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function lY($,Z,Y,X,Q){let J=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[J,J.toLowerCase(),G(J),K(J)])if(q.has(L))return!0}let W=[...new Set([`${J}.stx`,`${G(J)}.stx`,`${K(J)}.stx`])],z=typeof Q.root==="string"?h.resolve(Q.root):void 0,U=z??h.dirname(X),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(h.join(h.dirname(j),"components"));B(Z),B(h.join(h.dirname(X),"components")),B(Q.componentsDir);let H=Q._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(z)B(h.resolve(z,"resources/views/components")),B(h.resolve(z,"resources/components")),B(h.resolve(z,"src/components")),B(h.resolve(z,"components"));if(J.startsWith("./")||J.startsWith("../"))return l(h.resolve(h.dirname(X),`${J}.stx`));for(let L of _){let F=h.isAbsolute(L)?L:h.resolve(U,L);for(let O of W)if(await l(h.join(F,O)))return!0}return!1}function QU($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function k1($,Z,Y,X,Q,J,G,K=new Set,q){let{extractVariables:W}=await Promise.resolve().then(() => (T5(),C$)),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let U=new Set(z);U.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&QU(_)?_:"";try{let j=(S)=>S.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(S)=>S.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=Q.__importedComponents;if(O){let S=[L,L.toLowerCase(),j(L),H(L)];for(let v of S)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let S=[`${L}.stx`,`${j(L)}.stx`,`${H(L)}.stx`],v=[...new Set(S)],x=Q.__originalFilePath,g=[];if(x){let q0=h.join(h.dirname(x),"components");g.push(q0)}if(X)g.push(X);let u=h.join(h.dirname(J),"components");if(!g.includes(u))g.push(u);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let o=G._pluginComponentDirs;if(Array.isArray(o)){for(let q0 of o)if(typeof q0==="string"&&!g.includes(q0))g.push(q0)}let Q0=typeof G.root==="string"?h.resolve(G.root):void 0,R0=Q0??h.dirname(J),b0=[];if(Q0)b0.push(h.resolve(Q0,"resources/views/components")),b0.push(h.resolve(Q0,"resources/components")),b0.push(h.resolve(Q0,"src/components")),b0.push(h.resolve(Q0,"components"));b0.push(h.resolve(import.meta.dir,"components"));for(let q0 of b0)if(!g.includes(q0))g.push(q0);let _1=[...new Set(g.map((q0)=>{if(!q0)return q0;return h.isAbsolute(q0)?q0:h.resolve(R0,q0)}))];if(g.length=0,g.push(..._1),L.startsWith("./")||L.startsWith("../"))F=h.resolve(h.dirname(J),`${L}.stx`),V.push(F);else for(let q0 of g){if(!q0)continue;for(let B1 of v){let e1=h.join(q0,B1);if(V.push(e1),await l(e1)){F=e1;break}}if(F)break;if(!F)try{let B1=await import("fs");if(!B1.statSync(q0,{throwIfNoEntry:!1})?.isDirectory())continue;let y5=8,t=[{path:q0,depth:0}];while(t.length>0&&!F){let u0=t.pop();if(u0.depth>=y5)continue;let q4;try{q4=B1.readdirSync(u0.path,{withFileTypes:!0})}catch{continue}for(let C5 of q4){if(!C5.isDirectory())continue;if(C5.name==="node_modules"||C5.name.startsWith("."))continue;let m3=h.join(u0.path,C5.name);for(let BX of v){let z4=h.join(m3,BX);if(V.push(z4),await l(z4)){F=z4;break}}if(F)break;t.push({path:m3,depth:u0.depth+1})}}}catch{}if(F)break}}if(!F||!await l(F)){let S=V.length>0?`
10751
10751
  Searched paths:
10752
10752
  ${V.map((v)=>` - ${v}`).join(`
10753
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${b}`}q.add(F);let w;if(B3.has(F))w=B3.get(F);else try{w=await Bun.file(F).text(),B3.set(F,w)}catch(b){return`[Error loading component: ${b instanceof Error?b.message:String(b)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),R={};for(let[b,v]of Object.entries(Q))if(!b.startsWith("__")||A.has(b))R[b]=v;let N={...R,...Z,props:Z,slot:Y,__processedComponents:U,__sections:{}};JU(w,N);let T=w,M=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)T=M[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let b of D){let v=b[1]||"",x=b[2]||"",g=v.includes("server");if(H1(v)&&x.trim())x=O1(x);if(g&&x)try{await W(x,N,F)}catch(o){}if(!g){let o=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(o.includes("{{")&&o.includes("}}"))o=l0(o,N,F);let Q0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${Q0}>${o}</script>`)}}let C=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=C?C[1]:"",S=C?C[2]:"",P="",d=k&&/\bscoped\b/i.test(k);if(C)P=`<style${k}>${S}</style>`;let f=T;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),C)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let b=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(b,(x,g)=>{let u=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(u)v.push(`<style${u[1]}>${u[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)P=`${P}${v.join(`
10754
- `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:n}=await Promise.resolve().then(() => (uY(),mY)),{defaultSlot:A0,namedSlots:o0}=m(Y);f=await n(f,A0||Y,o0,N);for(let[b,v]of Object.entries(N))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=B4(v);N[b]=x}}let S0=E.some((b)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(b)),M0={...G,componentsDir:h.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:S0,defaultLayout:void 0};N.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let e=await w0(f,N,F,M0,q),B0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++eW}_${Math.random().toString(36).slice(2,8)}`,z0=e;if(S0){let b="";if(Object.keys(Z).length>0)try{b=` data-stx-props="${pY(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${pY(B)}"`:"";if(z0=`<div data-stx-scope="${B0}"${b}${v}>${e}</div>`,z0=E.map((g)=>{let u=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!u)return g;let[,o,Q0]=u,I0=s0(Q0),b0=`
10753
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${S}`}q.add(F);let w;if(B3.has(F))w=B3.get(F);else try{w=await Bun.file(F).text(),B3.set(F,w)}catch(S){return`[Error loading component: ${S instanceof Error?S.message:String(S)}]`}let A=new Set(["__originalFilePath","__importedComponents"]),R={};for(let[S,v]of Object.entries(Q))if(!S.startsWith("__")||A.has(S))R[S]=v;let N={...R,...Z,props:Z,slot:Y,__processedComponents:U,__sections:{}};JU(w,N);let T=w,M=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)T=M[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let S of D){let v=S[1]||"",x=S[2]||"",g=v.includes("server");if(H1(v)&&x.trim())x=O1(x);if(g&&x)try{await W(x,N,F)}catch(o){}if(!g){let o=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(o.includes("{{")&&o.includes("}}"))o=l0(o,N,F);let Q0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${Q0}>${o}</script>`)}}let C=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=C?C[1]:"",b=C?C[2]:"",P="",d=k&&/\bscoped\b/i.test(k);if(C)P=`<style${k}>${b}</style>`;let f=T;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),C)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let S=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(S,(x,g)=>{let u=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(u)v.push(`<style${u[1]}>${u[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)P=`${P}${v.join(`
10754
+ `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:n}=await Promise.resolve().then(() => (uY(),mY)),{defaultSlot:A0,namedSlots:o0}=m(Y);f=await n(f,A0||Y,o0,N);for(let[S,v]of Object.entries(N))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=B4(v);N[S]=x}}let S0=E.some((S)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(S)),I0={...G,componentsDir:h.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:S0,defaultLayout:void 0};N.__stxProcessingDepth=(Q.__stxProcessingDepth||0)+1;let e=await w0(f,N,F,I0,q),B0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++eW}_${Math.random().toString(36).slice(2,8)}`,z0=e;if(S0){let S="";if(Object.keys(Z).length>0)try{S=` data-stx-props="${pY(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${pY(B)}"`:"";if(z0=`<div data-stx-scope="${B0}"${S}${v}>${e}</div>`,z0=E.map((g)=>{let u=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!u)return g;let[,o,Q0]=u,R0=s0(Q0),b0=`
10755
10755
  (function() {
10756
10756
  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;
10757
10757
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -10763,12 +10763,12 @@ ${V.map((v)=>` - ${v}`).join(`
10763
10763
  const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
10764
10764
  const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
10765
10765
 
10766
- ${I0}
10766
+ ${R0}
10767
10767
 
10768
10768
  // Register all defined signals and functions in this scope
10769
10769
  const __localVars = {};
10770
10770
  try {
10771
- ${ZU(I0).map((_1)=>`if (typeof ${_1} !== 'undefined') __localVars['${_1}'] = ${_1};`).join(`
10771
+ ${ZU(R0).map((_1)=>`if (typeof ${_1} !== 'undefined') __localVars['${_1}'] = ${_1};`).join(`
10772
10772
  `)}
10773
10773
  }
10774
10774
  catch (e) {}
@@ -10777,9 +10777,9 @@ catch (e) {}
10777
10777
  `)+`
10778
10778
  `+z0,P)z0+=`
10779
10779
  `+P}else{if(P)z0+=`
10780
- `+P;if(E.length>0){let b=N.__stx_event_bindings||[],v=Z5(N),x=await Promise.all(E.map(async(g)=>{let u=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!u)return g;return await Y5(u[1],{eventBindings:b,templateContent:z0,filePath:F,projectRoot:process.cwd(),serverData:v})}));z0+=`
10780
+ `+P;if(E.length>0){let S=N.__stx_event_bindings||[],v=Z5(N),x=await Promise.all(E.map(async(g)=>{let u=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!u)return g;return await Y5(u[1],{eventBindings:S,templateContent:z0,filePath:F,projectRoot:process.cwd(),serverData:v})}));z0+=`
10781
10781
  `+x.join(`
10782
- `),N.__stx_event_bindings=[]}}if(d){let b=g$(z0,F);if(b.hasScoped)z0=b.html}return z0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{z.delete($)}}async function l($){return Bun.file($).exists()}function j3($,Z){let Y=h.resolve(Z),X=h.resolve($),Q=Y.endsWith(h.sep)?Y:Y+h.sep;if(X===Y||X.startsWith(Q))return X;return null}async function X7($,Z,Y,X){let Q=await GU($,Z,Y,X);if(Q===null)return null;let J=j3(Q,process.cwd());if(J)return J;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 q=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(j3(Q,q))return h.resolve(Q)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Q} (template: ${$}, from: ${Z})`),null}async function GU($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let Q=h.dirname(Z),J=process.cwd();if($.startsWith("/")){let _=h.join(J,$),B=j3(_,J);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await l(B)&&X)X.add(B);return B}let G=h.join(Q,$);if(await l(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 _ of[".stx",".tsx",".jsx"]){let B=`${G}${_}`;if(await l(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(X)X.add(B);return B}}let K="",q=h.resolve(Q),W=process.cwd();for(let _=0;_<10;_++){let B=h.join(q,"layouts"),j=!1;try{j=tW.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let H=h.dirname(q);if(H===q||H.length<W.length)break;q=H}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=h.join(K,_);if(await l(B)){if(Y.debug)console.log(`Found in current layouts dir: ${B}`);if(X)X.add(B);return B}if(!_.endsWith(".stx")){let j=`${B}.stx`;if(await l(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 _=h.isAbsolute(Y.layoutsDir)?Y.layoutsDir:h.resolve(process.cwd(),Y.layoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=h.join(_,B);if(await l(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 l(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 _=$.split("layouts/"),B=h.join(Y.partialsDir||Q,"layouts",_[1]);if(await l(B)){if(Y.debug)console.log(`Found in layouts path: ${B}`);if(X)X.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await l(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=h.join(Y.partialsDir,"layouts"),await l(K)){let _=h.join(K,$);if(await l(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}}let z=Y.partialsDir||h.join(process.cwd(),"views"),U=h.join(z,$);if(await l(U)){if(Y.debug)console.log(`Found in views path: ${U}`);if(X)X.add(U);return U}if(!$.endsWith(".stx")){let _=`${U}.stx`;if(await l(_)){if(Y.debug)console.log(`Found in views path with extension: ${_}`);if(X)X.add(_);return _}}if(Q.includes("temp")){let _=h.join(h.dirname(Q),"layouts",$);if(await l(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}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 cY($,Z,Y){let X=0,Q="",J="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10782
+ `),N.__stx_event_bindings=[]}}if(d){let S=g$(z0,F);if(S.hasScoped)z0=S.html}return z0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{z.delete($)}}async function l($){return Bun.file($).exists()}function j3($,Z){let Y=h.resolve(Z),X=h.resolve($),Q=Y.endsWith(h.sep)?Y:Y+h.sep;if(X===Y||X.startsWith(Q))return X;return null}async function X7($,Z,Y,X){let Q=await GU($,Z,Y,X);if(Q===null)return null;let J=j3(Q,process.cwd());if(J)return J;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 q=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(j3(Q,q))return h.resolve(Q)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${Q} (template: ${$}, from: ${Z})`),null}async function GU($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let Q=h.dirname(Z),J=process.cwd();if($.startsWith("/")){let _=h.join(J,$),B=j3(_,J);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await l(B)&&X)X.add(B);return B}let G=h.join(Q,$);if(await l(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 _ of[".stx",".tsx",".jsx"]){let B=`${G}${_}`;if(await l(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(X)X.add(B);return B}}let K="",q=h.resolve(Q),W=process.cwd();for(let _=0;_<10;_++){let B=h.join(q,"layouts"),j=!1;try{j=tW.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let H=h.dirname(q);if(H===q||H.length<W.length)break;q=H}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=h.join(K,_);if(await l(B)){if(Y.debug)console.log(`Found in current layouts dir: ${B}`);if(X)X.add(B);return B}if(!_.endsWith(".stx")){let j=`${B}.stx`;if(await l(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 _=h.isAbsolute(Y.layoutsDir)?Y.layoutsDir:h.resolve(process.cwd(),Y.layoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=h.join(_,B);if(await l(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 l(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 _=$.split("layouts/"),B=h.join(Y.partialsDir||Q,"layouts",_[1]);if(await l(B)){if(Y.debug)console.log(`Found in layouts path: ${B}`);if(X)X.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await l(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=h.join(Y.partialsDir,"layouts"),await l(K)){let _=h.join(K,$);if(await l(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}}let z=Y.partialsDir||h.join(process.cwd(),"views"),U=h.join(z,$);if(await l(U)){if(Y.debug)console.log(`Found in views path: ${U}`);if(X)X.add(U);return U}if(!$.endsWith(".stx")){let _=`${U}.stx`;if(await l(_)){if(Y.debug)console.log(`Found in views path with extension: ${_}`);if(X)X.add(_);return _}}if(Q.includes("temp")){let _=h.join(h.dirname(Q),"layouts",$);if(await l(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}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 cY($,Z,Y){let X=0,Q="",J="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10783
10783
  `),K=0;for(let q=0;q<G.length;q++)if(K+=G[q].length+1,K>=Z){X=q+1,Q=G[q].trim();let W=Math.max(0,q-2),z=Math.min(G.length,q+3);J=G.slice(W,z).map((U,_)=>{let B=W+_+1;return`${B===X?"> ":" "}${B}: ${U}`}).join(`
10784
10784
  `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return cY($,G)}}catch{}return{lineNumber:X,lineContent:Q,context:J}}function J0($,Z,Y,X,Q,J){let{lineNumber:G,context:K}=cY(X,Q,J),q=Y.split("/").pop(),W=0;if(typeof Q==="number"&&Q>=0&&X){let U=X.lastIndexOf(`
10785
10785
  `,Math.max(0,Q-1));W=Q-(U+1)+1}let z="";if(G>0)z+=`
@@ -10794,8 +10794,8 @@ ${a.yellow}${a.bold}Message:${a.reset} ${Z}
10794
10794
  `,K)z+=`
10795
10795
  ${a.blue}${a.bold}Context:${a.reset}
10796
10796
  ${a.dim}${K}${a.reset}
10797
- `;return z}var B3,eW=0,a;var j0=y(()=>{X5();c0();f1();S7();C1();l7();xY();T5();B3=new K5(500);a={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"}});import f0 from"path";import H3 from"fs";function iY($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function nY($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class oY{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 Q=$.endsWith(".stx")?$.slice(0,-4):$,J=X?.__importedComponents;if(J){let B=[Q,Q.toLowerCase(),iY(Q),nY(Q)];for(let j of B)if(J.has(j))return J.get(j)}let G=[...new Set([`${Q}.stx`,`${iY(Q)}.stx`,`${nY(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let B=f0.resolve(f0.dirname(Z),`${Q}.stx`);if(await l(B))return B;return null}let K=[],q=Y.componentsDir||"",W=X?.__originalFilePath;if(W)K.push(f0.join(f0.dirname(W),"components"));if(q)K.push(q);let z=f0.join(f0.dirname(Z),"components");if(!K.includes(z))K.push(z);let U=process.cwd(),_=[f0.resolve(U,"src/components"),f0.resolve(U,"components"),f0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=f0.join(B,j);if(await l(H))return H}try{if(!H3.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=H3.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=f0.join(B,L.name);for(let O of G){let V=f0.join(F,O);if(await l(V))return V}}}catch{}}return null}}var k0;var O3=y(()=>{j0();k0=new oY});function W1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function KU($){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 L3;var F3=y(()=>{L3={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=KU($),Q=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),J=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,q=[];if(X.reactive)q.push(`:href="${W1(X.value)}"`);else q.push(`href="${W1(X.value)}"`);if(Q)q.push(`class="${W1(Q)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${W1(J)}"`),q.push(`data-stx-exact-active-class="${W1(G)}"`),K)q.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[z,U]of Object.entries($.static)){if(W.has(z))continue;if(typeof U==="boolean"){if(U)q.push(W1(z))}else q.push(`${W1(z)}="${W1(U)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function U0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function T0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function w3($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let Q=$.static[Z];if(Q!==void 0)return Q!=="false"&&Q!==!1;return Y}function sY($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[Q,J]=X.split(":"),G=qU[Q];if(G)Y.push(`(max-width: ${G}px) ${J}`);else{let K=Number.parseInt(Q);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${J}`)}}else Y.push(X);return Y.join(", ")}function A3($,Z,Y,X){return Z.map((Q)=>`${S5($,Q,void 0,Y,X)} ${Q}w`).join(", ")}function zU($,Z,Y,X,Q){return Z.map((J)=>{let G=Y?Y*J:void 0;return`${S5($,G,void 0,X,Q)} ${J}x`}).join(", ")}function S5($,Z,Y,X,Q){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let J=[];if(Z)J.push(`w_${Z}`);if(Y)J.push(`h_${Y}`);if(Q)J.push(`f_${Q}`);J.push("q_auto");let G=J.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let J=new URLSearchParams;if(Z)J.set("w",String(Z));if(Y)J.set("h",String(Y));if(Q)J.set("fm",Q);J.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}if(X==="bunny"){let J=new URLSearchParams;if(Z)J.set("width",String(Z));if(Y)J.set("height",String(Y));if(Q)J.set("format",Q);let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}return $}function WU($,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 qU,V3,R3;var N3=y(()=>{qU={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},V3=[320,640,768,1024,1280,1536,1920];R3={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=T0($,"src")||"",Q=T0($,"alt")||"",J=T0($,"width"),G=T0($,"height"),K=T0($,"sizes"),q=T0($,"srcset"),W=T0($,"densities"),z=T0($,"format"),U=T0($,"placeholder"),_=T0($,"placeholderColor")||"#e5e7eb",B=T0($,"provider"),j=T0($,"class")||T0($,"className")||"",H=T0($,"style")||"",L=T0($,"quality"),F=w3($,"lazy",!0),O=w3($,"preload",!1),V=w3($,"picture",!1)||!!z,w=J?Number.parseInt(J):void 0,A=G?Number.parseInt(G):void 0,R=q||"",N="";if(!R&&K)R=A3(X,V3,B,z),N=sY(K);else if(!R&&W){let k=W.split(/\s+/).map((S)=>Number.parseFloat(S.replace("x","")));R=zU(X,k,w,B,z)}else if(K)N=sY(K);let T=[];if(H)T.push(H);if(w&&A)T.push(`aspect-ratio:${w}/${A}`);if(U==="blur"||U==="color"||U==="thumbhash"){let k=WU(w||16,A||9,_);T.push(`background-image:url(${k})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(U&&U!=="empty"&&U!=="none")T.push(`background-image:url(${U0(U)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let M=S5(X,w,A,B,z),I=[];if(I.push(`src="${U0(M)}"`),I.push(`alt="${U0(Q)}"`),J)I.push(`width="${U0(J)}"`);if(G)I.push(`height="${U0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${U0(j)}"`);if(T.length>0)I.push(`style="${U0(T.join(";"))}"`);if(R)I.push(`srcset="${U0(R)}"`);if(N)I.push(`sizes="${U0(N)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[k,S]of Object.entries($.static)){if(D.has(k))continue;if(typeof S==="boolean"){if(S)I.push(U0(k))}else I.push(`${U0(k)}="${U0(S)}"`)}let E=`<img ${I.join(" ")} />`,C="";if(O){let S=z==="webp"?"image/webp":z==="avif"?"image/avif":"";C=`<link rel="preload" as="image" href="${U0(M)}"${S?` type="${S}"`:""}${R?` imagesrcset="${U0(R)}"`:""}${N?` imagesizes="${U0(N)}"`:""} />
10798
- `}if(V){let k=[];if(z==="avif"||z==="auto"){let S=S5(X,w,A,B,"avif"),P=R?A3(X,V3,B,"avif"):`${S}`;k.push(`<source type="image/avif" srcset="${U0(P)}"${N?` sizes="${U0(N)}"`:""} />`)}if(z==="webp"||z==="auto"){let S=S5(X,w,A,B,"webp"),P=R?A3(X,V3,B,"webp"):`${S}`;k.push(`<source type="image/webp" srcset="${U0(P)}"${N?` sizes="${U0(N)}"`:""} />`)}return`${C}<picture>
10797
+ `;return z}var B3,eW=0,a;var j0=y(()=>{X5();c0();f1();S7();C1();l7();xY();T5();B3=new K5(500);a={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"}});import f0 from"path";import H3 from"fs";function iY($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function nY($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class oY{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 Q=$.endsWith(".stx")?$.slice(0,-4):$,J=X?.__importedComponents;if(J){let B=[Q,Q.toLowerCase(),iY(Q),nY(Q)];for(let j of B)if(J.has(j))return J.get(j)}let G=[...new Set([`${Q}.stx`,`${iY(Q)}.stx`,`${nY(Q)}.stx`])];if(Q.startsWith("./")||Q.startsWith("../")){let B=f0.resolve(f0.dirname(Z),`${Q}.stx`);if(await l(B))return B;return null}let K=[],q=Y.componentsDir||"",W=X?.__originalFilePath;if(W)K.push(f0.join(f0.dirname(W),"components"));if(q)K.push(q);let z=f0.join(f0.dirname(Z),"components");if(!K.includes(z))K.push(z);let U=process.cwd(),_=[f0.resolve(U,"src/components"),f0.resolve(U,"components"),f0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=f0.join(B,j);if(await l(H))return H}try{if(!H3.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=H3.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=f0.join(B,L.name);for(let O of G){let V=f0.join(F,O);if(await l(V))return V}}}catch{}}return null}}var k0;var O3=y(()=>{j0();k0=new oY});function W1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function KU($){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 L3;var F3=y(()=>{L3={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=KU($),Q=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),J=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,q=[];if(X.reactive)q.push(`:href="${W1(X.value)}"`);else q.push(`href="${W1(X.value)}"`);if(Q)q.push(`class="${W1(Q)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${W1(J)}"`),q.push(`data-stx-exact-active-class="${W1(G)}"`),K)q.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[z,U]of Object.entries($.static)){if(W.has(z))continue;if(typeof U==="boolean"){if(U)q.push(W1(z))}else q.push(`${W1(z)}="${W1(U)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function U0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function M0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function w3($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let Q=$.static[Z];if(Q!==void 0)return Q!=="false"&&Q!==!1;return Y}function sY($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[Q,J]=X.split(":"),G=qU[Q];if(G)Y.push(`(max-width: ${G}px) ${J}`);else{let K=Number.parseInt(Q);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${J}`)}}else Y.push(X);return Y.join(", ")}function A3($,Z,Y,X){return Z.map((Q)=>`${S5($,Q,void 0,Y,X)} ${Q}w`).join(", ")}function zU($,Z,Y,X,Q){return Z.map((J)=>{let G=Y?Y*J:void 0;return`${S5($,G,void 0,X,Q)} ${J}x`}).join(", ")}function S5($,Z,Y,X,Q){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let J=[];if(Z)J.push(`w_${Z}`);if(Y)J.push(`h_${Y}`);if(Q)J.push(`f_${Q}`);J.push("q_auto");let G=J.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let J=new URLSearchParams;if(Z)J.set("w",String(Z));if(Y)J.set("h",String(Y));if(Q)J.set("fm",Q);J.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}if(X==="bunny"){let J=new URLSearchParams;if(Z)J.set("width",String(Z));if(Y)J.set("height",String(Y));if(Q)J.set("format",Q);let G=$.includes("?")?"&":"?";return`${$}${G}${J.toString()}`}return $}function WU($,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 qU,V3,R3;var N3=y(()=>{qU={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},V3=[320,640,768,1024,1280,1536,1920];R3={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=M0($,"src")||"",Q=M0($,"alt")||"",J=M0($,"width"),G=M0($,"height"),K=M0($,"sizes"),q=M0($,"srcset"),W=M0($,"densities"),z=M0($,"format"),U=M0($,"placeholder"),_=M0($,"placeholderColor")||"#e5e7eb",B=M0($,"provider"),j=M0($,"class")||M0($,"className")||"",H=M0($,"style")||"",L=M0($,"quality"),F=w3($,"lazy",!0),O=w3($,"preload",!1),V=w3($,"picture",!1)||!!z,w=J?Number.parseInt(J):void 0,A=G?Number.parseInt(G):void 0,R=q||"",N="";if(!R&&K)R=A3(X,V3,B,z),N=sY(K);else if(!R&&W){let k=W.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));R=zU(X,k,w,B,z)}else if(K)N=sY(K);let T=[];if(H)T.push(H);if(w&&A)T.push(`aspect-ratio:${w}/${A}`);if(U==="blur"||U==="color"||U==="thumbhash"){let k=WU(w||16,A||9,_);T.push(`background-image:url(${k})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(U&&U!=="empty"&&U!=="none")T.push(`background-image:url(${U0(U)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let M=S5(X,w,A,B,z),I=[];if(I.push(`src="${U0(M)}"`),I.push(`alt="${U0(Q)}"`),J)I.push(`width="${U0(J)}"`);if(G)I.push(`height="${U0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${U0(j)}"`);if(T.length>0)I.push(`style="${U0(T.join(";"))}"`);if(R)I.push(`srcset="${U0(R)}"`);if(N)I.push(`sizes="${U0(N)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[k,b]of Object.entries($.static)){if(D.has(k))continue;if(typeof b==="boolean"){if(b)I.push(U0(k))}else I.push(`${U0(k)}="${U0(b)}"`)}let E=`<img ${I.join(" ")} />`,C="";if(O){let b=z==="webp"?"image/webp":z==="avif"?"image/avif":"";C=`<link rel="preload" as="image" href="${U0(M)}"${b?` type="${b}"`:""}${R?` imagesrcset="${U0(R)}"`:""}${N?` imagesizes="${U0(N)}"`:""} />
10798
+ `}if(V){let k=[];if(z==="avif"||z==="auto"){let b=S5(X,w,A,B,"avif"),P=R?A3(X,V3,B,"avif"):`${b}`;k.push(`<source type="image/avif" srcset="${U0(P)}"${N?` sizes="${U0(N)}"`:""} />`)}if(z==="webp"||z==="auto"){let b=S5(X,w,A,B,"webp"),P=R?A3(X,V3,B,"webp"):`${b}`;k.push(`<source type="image/webp" srcset="${U0(P)}"${N?` sizes="${U0(N)}"`:""} />`)}return`${C}<picture>
10799
10799
  ${k.join(`
10800
10800
  `)}
10801
10801
  ${E}
@@ -10833,4 +10833,4 @@ ${E}
10833
10833
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
10834
10834
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
10835
10835
  </style>`}}});import{existsSync as BU,readFileSync as jU}from"fs";function HU($){try{return G0.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(BU(Y))return Y;return null}function OU($){if(Q4.has($))return Q4.get($);let Z=HU($);if(!Z)return null;try{let Y=JSON.parse(jU(Z,"utf8"));return Q4.set($,Y.icons),Y.icons}catch{return null}}function t1($,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}var Q4,v3;var x3=y(()=>{Q4=new Map;v3={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=t1($,"name")??t1($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let Q="lucide",J=X;if(X.includes(":")){let O=X.split(":");Q=O[0],J=O[1]}let G=m0(t1($,"size")||"24"),K=m0(t1($,"color")||"currentColor"),q=m0(t1($,"class")||""),W=m0(t1($,"style")||""),z=Q4.get(Q)??OU(Q);if(!z)return`<!-- Icon: collection "${Q}" not loaded -->`;let U=z[J];if(!U)return`<!-- Icon: "${J}" not found in ${Q} -->`;let _=U.width||24,B=U.height||24,j=`0 0 ${_} ${B}`,H=U.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let L=q?` class="${q}"`:"",F=W?` style="${W}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${L}${F}>${H}</svg>`}}});function $X($,...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 ZX($,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 f3;var g3=y(()=>{f3={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=ZX(Z,"fallback"),Q=X.rest,J=ZX(Q,"error"),G=J.rest,K=X.region??$X($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',q=J.region??$X($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${q}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function G4($,...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 h3;var d3=y(()=>{h3={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(G4($,"name")||"v").replace(/["'<>]/g,""),Q=(G4($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",J=G4($,"class"),G=G4($,"id"),K=[`data-stx-transition-group="${X}"`,J?`class="${J}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${Q} ${K}>${Z}</${Q}>`}}});function YX(){k0.registerBuiltin(L3),k0.registerBuiltin(R3),k0.registerBuiltin(T3),k0.registerBuiltin(D3),k0.registerBuiltin(k3),k0.registerBuiltin(b3),k0.registerBuiltin(C3),k0.registerBuiltin(v3),k0.registerBuiltin(f3),k0.registerBuiltin(h3)}var XX=y(()=>{F3();N3();M3();E3();S3();y3();P3();x3();g3();d3();O3();F3();N3();M3();E3();S3();y3();P3();x3();g3();d3()});function JX($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function QX($,Z,Y){let X=[],Q=0;while(Q<$.length){let J=$.indexOf("<",Q);if(J===-1)break;let K=$.slice(J+1).match(new RegExp(`^(${Z.source})`));if(!K){Q=J+1;continue}let q=K[1];if(Y&&Y.has(q.toLowerCase())){let H=J+1+q.length;while(H<$.length&&$[H]!==">")H++;Q=H+1;continue}let W=J+1+q.length,z=null,U=W,_=-1,B=!1;while(W<$.length){let H=$[W];if(z){if(H==="\\"&&W+1<$.length){W+=2;continue}if(H===z)z=null;W++;continue}if(H==='"'||H==="'"){z=H,W++;continue}if(H==="/"&&W+1<$.length&&$[W+1]===">"){_=W+2,B=!0;break}if(H===">"){_=W+1;break}W++}if(_===-1){Q=J+1;continue}let j=$.slice(U,B?_-2:_-1).trim();if(B)X.push({fullMatch:$.slice(J,_),tagName:q,attributes:j,content:"",startIndex:J,endIndex:_,isSelfClosing:!0}),Q=_;else{let H=`<${q}`,L=`</${q}>`,F=1,O=_,V=-1;while(F>0&&O<$.length){let R=$.indexOf(H,O),N=$.indexOf(L,O);if(N===-1)break;if(R!==-1&&R<N){let T=$[R+H.length];if(T===" "||T===">"||T==="/"||T===`
10836
- `||T==="\t")F++;O=R+H.length}else{if(F--,F===0){V=N;break}O=N+L.length}}if(V===-1){Q=_;continue}let w=$.slice(_,V),A=V+L.length;X.push({fullMatch:$.slice(J,A),tagName:q,attributes:j,content:w,startIndex:J,endIndex:A,isSelfClosing:!1}),Q=A}}return X}function GX($,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 KX=y(()=>{O0();j0();m5()});var RZ={};s(RZ,{processESImports:()=>_X,processComponents:()=>Y4});import K4 from"fs";import P0 from"path";function FU($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),J=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){X.events[q]=K;continue}if(q.startsWith("__stx_")){let W=J(q.slice(6));X.serverDynamic[W]=GX(K,Y);continue}if(q.startsWith(":")){let W=J(q.slice(1)),z=K==="true"?W:K;try{if(!Z0(z)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${z}`);X.clientReactive[W]=z;continue}let U=Object.keys(Z),B=Y0(z,U)(...Object.values(Z));if(B===void 0){let j=z.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!U.includes(F))){X.clientReactive[W]=z;continue}}X.serverDynamic[W]=B}catch{X.clientReactive[W]=z}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let z=W[1];if(Z0(z)){let _=Y0(z,Object.keys(Z))(...Object.values(Z));X.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${z}`);X.static[q]=K}}catch(z){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,z);X.static[q]=K}else{let z=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=U.exec(K))!==null)try{let B=_[1];if(!Z0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=Y0(B,Object.keys(Z))(...Object.values(Z));z=z.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}X.static[q]=z}continue}X.static[q]=K}return X}function VU($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let Q="";while(Y<X&&!/[\s=]/.test($[Y]))Q+=$[Y],Y++;if(!Q)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let J="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,J+=$[Y],Y++;continue}if(K===G){Y++;break}J+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))J+=$[Y],Y++;Z[Q]=J}else Z[Q]="true"}return Z}function zX($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wU($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let Q=X[1];if(k0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function AU($){let Z=WX.get($);if(Z)return Z;let Y=new Map,X=[P0.join($,"src"),P0.join($,"dist"),$];function Q(J,G){if(G>6)return;let K;try{K=K4.readdirSync(J,{withFileTypes:!0})}catch{return}for(let q of K){let W=P0.join(J,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;Q(W,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let z=q.name.slice(0,-4);if(!Y.has(z))Y.set(z,W);let U=z.toLowerCase();if(!Y.has(U))Y.set(U,W);let _=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let J of X)if(Q(J,0),Y.size>0)break;return WX.set($,Y),Y}function RU($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=P0.join(Y,"node_modules",$);try{if(K4.statSync(X).isDirectory())return X}catch{}let Q=P0.dirname(Y);if(Q===Y)return null;Y=Q}}async function _X($,Z,Y,X,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let J=Z.__importedComponents,G=P0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(W,z,U)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=U,j,H=[];while((j=_.exec(U))!==null){let[L,F,O,V]=j,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=P0.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let M=`${T}.stx`;try{if(K4.statSync(M).isFile())A=M}catch{try{if(K4.statSync(T).isDirectory())w=T}catch{}}}}else w=RU(V,G);if(!w&&!A)continue;let R=!1,N=(T,M)=>{J.set(T,M),J.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();J.set(I,M),Q.add(M)};if(O&&A)N(O,A),R=!0;else if(F){let T=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?AU(w):null;for(let{source:I,local:D}of T){let E=null;if(A)E=A;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)N(D,E),R=!0}}if(R)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return W;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${z}>${B}</script>`}),K}async function NU($,Z,Y,X,Q){let J=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(J))!==null){let[W,z]=q,U=z.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of U){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[P0.resolve(P0.dirname(Y),`${_}.stx`),P0.resolve(P0.dirname(Y),_),P0.resolve(X.componentsDir||"components",`${_}.stx`),P0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),Q.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}J=J.replace(W,""),K.lastIndex=0}return J}async function TU($,Z,Y,X,Q){let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,W;while((W=q.exec(J))!==null){let z=W.index,U=z+W[0].length-1,_=1,B=U+1;while(B<J.length&&_>0){if(J[B]==="(")_++;else if(J[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=J.substring(U+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let A={};if(O)try{A=H0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);J=J.replace(J.substring(z,H),`[Error parsing component props: ${E}]`);continue}let R="",N=H,M=J.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)R=M[1].trim(),N=H+M[0].length;let I=await k1(F,A,R,G,Z,Y,X,K,Q);J=J.substring(0,z)+I+J.substring(N),q.lastIndex=0}return J}async function MU($,Z,Y,X,Q){if(!$)return $;let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=U4(J);return J=q.output,J=await _(J,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),J=await _(J,/[A-Z][a-zA-Z0-9]*/,!0),J=await _(J,/[a-z][a-z0-9]*/,!1,LU),J=_4(J,q.scripts),J;async function _(B,j,H,L){if(!B)return B;let F=B,O=QX(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],A=H?JX(w.tagName):w.tagName,R=VU(w.attributes),N=FU(R,Z,X),T=k0.getBuiltin(w.tagName),M=T?await lY(A,G,Z,Y,X):!1;if(T&&!M){let C={context:Z,filePath:Y,options:X,dependencies:Q},k=T.render(N,w.content,C);if(Object.keys(N.clientReactive).length>0)k=UX(k,N.clientReactive);if(Object.keys(N.events).length>0){let S=Object.entries(N.events).map(([P,d])=>`${P}="${zX(d)}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${S}`)}F=F.substring(0,w.startIndex)+k+F.substring(w.endIndex);continue}let I={};for(let[C,k]of Object.entries(N.static))I[C]=k;for(let[C,k]of Object.entries(N.serverDynamic))I[C]=k;let E=await k1(A,I,w.content,G,Z,Y,X,K,Q);if(Object.keys(N.clientReactive).length>0)E=UX(E,N.clientReactive);if(Object.keys(N.events).length>0){let C=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(C){let k=Object.entries(N.events).map(([P,d])=>`${P}="${zX(d)}"`).join(" "),S=C[1].length+C[2].length;E=E.substring(0,S)+" "+k+E.substring(S)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function UX($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([J,G])=>`:${J}="${G.replace(/"/g,"&quot;")}"`).join(" "),Q=Y[1].length+Y[2].length;return $.substring(0,Q)+" "+X+$.substring(Q)}async function Y4($,Z,Y,X,Q){if(!qX)YX(),qX=!0;let J=await _X($,Z,Y,X,Q);J=await NU(J,Z,Y,X,Q),J=await TU(J,Z,Y,X,Q);for(let G=0;G<3;G++){let K=J;if(J=await MU(J,Z,Y,X,Q),J===K)break}if(X.debug){let G=wU(J);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 J}var qX=!1,LU,WX;var m7=y(()=>{O3();XX();KX();j0();O0();LU=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"]);WX=new Map});m7();export{_X as processESImports,Y4 as processComponents};
10836
+ `||T==="\t")F++;O=R+H.length}else{if(F--,F===0){V=N;break}O=N+L.length}}if(V===-1){Q=_;continue}let w=$.slice(_,V),A=V+L.length;X.push({fullMatch:$.slice(J,A),tagName:q,attributes:j,content:w,startIndex:J,endIndex:A,isSelfClosing:!1}),Q=A}}return X}function GX($,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 KX=y(()=>{O0();j0();m5()});var RZ={};s(RZ,{processESImports:()=>_X,processComponents:()=>Y4});import K4 from"fs";import P0 from"path";function FU($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},Q=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),J=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!Q.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){X.events[q]=K;continue}if(q.startsWith("__stx_")){let W=J(q.slice(6));X.serverDynamic[W]=GX(K,Y);continue}if(q.startsWith(":")){let W=J(q.slice(1)),z=K==="true"?W:K;try{if(!Z0(z)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${z}`);X.clientReactive[W]=z;continue}let U=Object.keys(Z),B=Y0(z,U)(...Object.values(Z));if(B===void 0){let j=z.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!U.includes(F))){X.clientReactive[W]=z;continue}}X.serverDynamic[W]=B}catch{X.clientReactive[W]=z}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let z=W[1];if(Z0(z)){let _=Y0(z,Object.keys(Z))(...Object.values(Z));X.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${z}`);X.static[q]=K}}catch(z){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,z);X.static[q]=K}else{let z=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=U.exec(K))!==null)try{let B=_[1];if(!Z0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=Y0(B,Object.keys(Z))(...Object.values(Z));z=z.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}X.static[q]=z}continue}X.static[q]=K}return X}function VU($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let Q="";while(Y<X&&!/[\s=]/.test($[Y]))Q+=$[Y],Y++;if(!Q)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let J="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,J+=$[Y],Y++;continue}if(K===G){Y++;break}J+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))J+=$[Y],Y++;Z[Q]=J}else Z[Q]="true"}return Z}function zX($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wU($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let Q=X[1];if(k0.isBuiltin(Q))Z.add(Q)}return[...Z].sort()}function AU($){let Z=WX.get($);if(Z)return Z;let Y=new Map,X=[P0.join($,"src"),P0.join($,"dist"),$];function Q(J,G){if(G>6)return;let K;try{K=K4.readdirSync(J,{withFileTypes:!0})}catch{return}for(let q of K){let W=P0.join(J,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;Q(W,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let z=q.name.slice(0,-4);if(!Y.has(z))Y.set(z,W);let U=z.toLowerCase();if(!Y.has(U))Y.set(U,W);let _=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let J of X)if(Q(J,0),Y.size>0)break;return WX.set($,Y),Y}function RU($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=P0.join(Y,"node_modules",$);try{if(K4.statSync(X).isDirectory())return X}catch{}let Q=P0.dirname(Y);if(Q===Y)return null;Y=Q}}async function _X($,Z,Y,X,Q){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let J=Z.__importedComponents,G=P0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(W,z,U)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=U,j,H=[];while((j=_.exec(U))!==null){let[L,F,O,V]=j,w=null,A=null;if(V.startsWith(".")||V.startsWith("/")){let T=P0.resolve(G,V);if(T.endsWith(".stx"))A=T;else{let M=`${T}.stx`;try{if(K4.statSync(M).isFile())A=M}catch{try{if(K4.statSync(T).isDirectory())w=T}catch{}}}}else w=RU(V,G);if(!w&&!A)continue;let R=!1,N=(T,M)=>{J.set(T,M),J.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();J.set(I,M),Q.add(M)};if(O&&A)N(O,A),R=!0;else if(F){let T=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?AU(w):null;for(let{source:I,local:D}of T){let E=null;if(A)E=A;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)N(D,E),R=!0}}if(R)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return W;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${z}>${B}</script>`}),K}async function NU($,Z,Y,X,Q){let J=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(J))!==null){let[W,z]=q,U=z.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of U){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[P0.resolve(P0.dirname(Y),`${_}.stx`),P0.resolve(P0.dirname(Y),_),P0.resolve(X.componentsDir||"components",`${_}.stx`),P0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),Q.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}J=J.replace(W,""),K.lastIndex=0}return J}async function TU($,Z,Y,X,Q){let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,W;while((W=q.exec(J))!==null){let z=W.index,U=z+W[0].length-1,_=1,B=U+1;while(B<J.length&&_>0){if(J[B]==="(")_++;else if(J[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=J.substring(U+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let A={};if(O)try{A=H0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);J=J.replace(J.substring(z,H),`[Error parsing component props: ${E}]`);continue}let R="",N=H,M=J.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)R=M[1].trim(),N=H+M[0].length;let I=await k1(F,A,R,G,Z,Y,X,K,Q);J=J.substring(0,z)+I+J.substring(N),q.lastIndex=0}return J}async function MU($,Z,Y,X,Q){if(!$)return $;let J=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=U4(J);return J=q.output,J=await _(J,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),J=await _(J,/[A-Z][a-zA-Z0-9]*/,!0),J=await _(J,/[a-z][a-z0-9]*/,!1,LU),J=_4(J,q.scripts),J;async function _(B,j,H,L){if(!B)return B;let F=B,O=QX(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],A=H?JX(w.tagName):w.tagName,R=VU(w.attributes),N=FU(R,Z,X),T=k0.getBuiltin(w.tagName),M=T?await lY(A,G,Z,Y,X):!1;if(T&&!M){let C={context:Z,filePath:Y,options:X,dependencies:Q},k=T.render(N,w.content,C);if(Object.keys(N.clientReactive).length>0)k=UX(k,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([P,d])=>`${P}="${zX(d)}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,w.startIndex)+k+F.substring(w.endIndex);continue}let I={};for(let[C,k]of Object.entries(N.static))I[C]=k;for(let[C,k]of Object.entries(N.serverDynamic))I[C]=k;let E=await k1(A,I,w.content,G,Z,Y,X,K,Q);if(Object.keys(N.clientReactive).length>0)E=UX(E,N.clientReactive);if(Object.keys(N.events).length>0){let C=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(C){let k=Object.entries(N.events).map(([P,d])=>`${P}="${zX(d)}"`).join(" "),b=C[1].length+C[2].length;E=E.substring(0,b)+" "+k+E.substring(b)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function UX($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([J,G])=>`:${J}="${G.replace(/"/g,"&quot;")}"`).join(" "),Q=Y[1].length+Y[2].length;return $.substring(0,Q)+" "+X+$.substring(Q)}async function Y4($,Z,Y,X,Q){if(!qX)YX(),qX=!0;let J=await _X($,Z,Y,X,Q);J=await NU(J,Z,Y,X,Q),J=await TU(J,Z,Y,X,Q);for(let G=0;G<3;G++){let K=J;if(J=await MU(J,Z,Y,X,Q),J===K)break}if(X.debug){let G=wU(J);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 J}var qX=!1,LU,WX;var m7=y(()=>{O3();XX();KX();j0();O0();LU=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"]);WX=new Map});m7();export{_X as processESImports,Y4 as processComponents};