@stacksjs/stx 0.2.15 → 0.2.16

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 (2) hide show
  1. package/dist/cli.js +153 -153
  2. package/package.json +5 -5
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ var YF=Object.defineProperty;var XF=($)=>$;function JF($,Z){this[$]=XF.bind(null
12
12
  white-space: nowrap;
13
13
  border-width: 0;
14
14
  }
15
- `.trim()}function PG(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function KF($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let L=J[1];if(!/\balt\s*=/i.test(L))Y.push({type:"missing-alt",element:J[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});J=X.exec($)}let Q=/<button([^>]*)>\s*<\/button>/gi;J=Q.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"missing-accessible-name",element:J[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});J=Q.exec($)}let G=/<a\s+([^>]*)>\s*<\/a>/gi;J=G.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"link-missing-text",element:J[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});J=G.exec($)}let K=/<(input|select|textarea)\s+([^>]*)>/gi;J=K.exec($);while(J!==null){let L=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(L)){J=K.exec($);continue}let F=/\baria-label\s*=/i.test(L)||/\baria-labelledby\s*=/i.test(L),O=L.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!F){let V=O&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${O[1]}["']`,"i").test($),N=J.index,A=$.substring(0,N),R=$.substring(N),M=(A.match(/<label\b/gi)||[]).length,E=(A.match(/<\/label>/gi)||[]).length,I=M>E;if(!V&&!I)Y.push({type:"input-missing-label",element:J[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}J=K.exec($)}let W=/<h([1-6])[^>]*>/gi,U=[];J=W.exec($);while(J!==null)U.push(Number.parseInt(J[1],10)),J=W.exec($);let _=0;for(let L of U){if(_>0&&L>_+1)Y.push({type:"heading-skip",element:`<h${L}>`,message:`Heading level skipped from h${_} to h${L}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});_=L}if(/<html\b/i.test($)&&!/<html[^>]*\slang\s*=/i.test($))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let B=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=B.exec($);while(J!==null){let L=J[1];if(!/<th\b/i.test(L))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});J=B.exec($)}let z=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=z.exec($);while(J!==null){if(!/\bmuted\b/i.test(J[0]))Y.push({type:"autoplay-audio",element:`<${J[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});J=z.exec($)}let q=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;J=q.exec($);while(J!==null)Y.push({type:"positive-tabindex",element:`tabindex="${J[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),J=q.exec($);let j=/<iframe\s+([^>]*)>/gi;J=j.exec($);while(J!==null){let L=J[1];if(!/\btitle\s*=/i.test(L)&&!/\baria-label\s*=/i.test(L))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});J=j.exec($)}let H=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;J=H.exec($);while(J!==null){let L=J[1].toLowerCase(),F=J[2];if(L!=="button"&&!/\btabindex\s*=/i.test(F))Y.push({type:"button-not-focusable",element:J[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});J=H.exec($)}return Y}async function o7($,Z){if(!PG())return KF($,Z);let Y=[];try{let X=globalThis.document.createElement("div");X.innerHTML=$,X.querySelectorAll("img").forEach((K)=>{if(!K.hasAttribute("alt"))Y.push({type:"missing-alt",element:`<${K.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),X.querySelectorAll('button, a, [role="button"]').forEach((K)=>{if(!(K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby")||K.textContent&&K.textContent.trim().length>0))Y.push({type:"missing-accessible-name",element:`<${K.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),X.querySelectorAll("input, select, textarea").forEach((K)=>{let W=K.getAttribute("id"),U=W&&X.querySelector(`label[for="${W}"]`),_=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),B=K.closest("label")!==null;if(!U&&!_&&!B)Y.push({type:"input-missing-label",element:`<${K.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let J=Array.from(X.querySelectorAll("h1, h2, h3, h4, h5, h6")),Q=0;for(let K of J){let W=Number.parseInt(K.tagName.charAt(1));if(Q>0&&W>Q+1)Y.push({type:"heading-skip",element:`<${K.outerHTML}>`,message:`Heading level skipped from h${Q} to h${W}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});Q=W}let G=X.querySelector("html");if($.includes("<html")&&G&&!G.hasAttribute("lang"))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(X.querySelectorAll("a").forEach((K)=>{let W=K.textContent&&K.textContent.trim().length>0,U=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),_=K.hasAttribute("title"),B=K.querySelector("img[alt]");if(!W&&!U&&!_&&!B)Y.push({type:"link-missing-text",element:`<${K.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),$.includes("<nav")||$.includes("<header")){if(!X.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&X.querySelectorAll("a").length>5)Y.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(X.querySelectorAll("table").forEach((K)=>{let W=K.querySelector("caption");if(!K.querySelector("th"))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!W&&!K.hasAttribute("aria-label")&&!K.hasAttribute("aria-labelledby"))Y.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),X.querySelectorAll('[style*="color"]').forEach((K)=>{let W=K.getAttribute("style")||"";if(W.includes("color:")&&!W.includes("background"))Y.push({type:"potential-contrast-issue",element:`<${K.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),X.querySelectorAll("video[autoplay], audio[autoplay]").forEach((K)=>{if(!K.hasAttribute("muted"))Y.push({type:"autoplay-audio",element:`<${K.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),X.querySelectorAll("[tabindex]").forEach((K)=>{if(Number.parseInt(K.getAttribute("tabindex")||"0")>0)Y.push({type:"positive-tabindex",element:`<${K.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),X.querySelectorAll('[role="button"]').forEach((K)=>{if(!K.hasAttribute("tabindex"))Y.push({type:"button-not-focusable",element:`<${K.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),$.includes("<body")&&!X.querySelector('main, [role="main"]'))Y.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});X.querySelectorAll("iframe").forEach((K)=>{if(!K.hasAttribute("title")&&!K.hasAttribute("aria-label"))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(X){console.error(`Error checking accessibility in ${Z}:`,X)}return Y}async function QZ($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=a7.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(a7.normalize(_))))K.push(W);for(let W of K)try{let U=await Bun.file(W).text();if(W.endsWith("good-a11y.stx"))continue;let _=await o7(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function yG($,Z={}){let Y={...WF,...Z},X=[],J=$;if(Y.fixMissingAlt)J=J.replace(/<img([^>]*?)(?<!\balt\s*=\s*["'][^"']*["'])(\s*\/?>)/gi,(Q,G,K)=>{if(/\balt\s*=/i.test(G))return Q;let W=Q,U=`<img${G} alt=""${K}`;return X.push({type:"missing-alt",description:"Added empty alt attribute to image",before:W,after:U}),U});if(Y.fixMissingLabels)J=J.replace(/<button([^>]*)>\s*<\/button>/gi,(Q,G)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;let K=Q,W=`<button${G} aria-label="Button"></button>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to empty button",before:K,after:W}),W}),J=J.replace(/<a([^>]*)>\s*(<(?:i|span|svg)[^>]*(?:class="[^"]*icon[^"]*")?[^>]*>.*?<\/(?:i|span|svg)>)?\s*<\/a>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;if(!K&&Q.replace(/<a[^>]*>|<\/a>/gi,"").trim())return Q;let W=Q,U=`<a${G} aria-label="Link">${K||""}</a>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to link without text",before:W,after:U}),U});if(Y.fixMissingFormLabels)J=J.replace(/<(input|select|textarea)([^>]*)>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(K)||/\baria-labelledby\s*=/i.test(K))return Q;if(/\btype\s*=\s*["']hidden["']/i.test(K))return Q;let W=K.match(/\bname\s*=\s*["']([^"']+)["']/i),U=K.match(/\bid\s*=\s*["']([^"']+)["']/i),_=W?.[1]||U?.[1]||G,B=Q,z=`<${G}${K} aria-label="${_}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:B,after:z}),z});if(Y.fixMissingLang)J=J.replace(/<html([^>]*)>/gi,(Q,G)=>{if(/\blang\s*=/i.test(G))return Q;let K=Q,W=`<html${G} lang="${Y.defaultLang}">`;return X.push({type:"missing-lang",description:`Added lang="${Y.defaultLang}" to html element`,before:K,after:W}),W});if(Y.fixPositiveTabindex)J=J.replace(/\btabindex\s*=\s*["']([1-9]\d*)["']/gi,(Q,G)=>{let K=Q,W='tabindex="0"';return X.push({type:"positive-tabindex",description:`Changed tabindex="${G}" to tabindex="0"`,before:K,after:'tabindex="0"'}),'tabindex="0"'});if(Y.fixButtonFocusable)J=J.replace(/<([a-z]+)(\s[^>]*role\s*=\s*["']button["'][^>]*)>/gi,(Q,G,K)=>{if(/\btabindex\s*=/i.test(K))return Q;if(G.toLowerCase()==="button")return Q;let W=Q,U=`<${G}${K} tabindex="0">`;return X.push({type:"button-not-focusable",description:'Added tabindex="0" to element with role="button"',before:W,after:U}),U});if(Y.fixTableHeaders)J=J.replace(/<th([^>]*)>/gi,(Q,G)=>{if(/\bscope\s*=/i.test(G))return Q;let K=Q,W=`<th${G} scope="col">`;return X.push({type:"table-missing-scope",description:'Added scope="col" to table header',before:K,after:W}),W});return{original:$,fixed:J,fixCount:X.length,fixes:X}}async function xG($,Z={},Y=!1){let X=await Bun.file($).text(),J=yG(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function UF($,Z={},Y={}){let X={},{recursive:J=!0,ignorePaths:Q=[],writeBack:G=!1,extensions:K=[".stx",".html",".htm"]}=Y,W=K.length===1?`*${K[0]}`:`*{${K.join(",")}}`,U=a7.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let B of _.scan()){if(Q.some((q)=>B.includes(a7.normalize(q))))continue;try{let q=await xG(B,Z,G);if(q.fixCount>0)X[B]=q}catch(q){console.error(`Error fixing ${B}:`,q)}}return X}function _F(){return[t7,e7]}var WF,t7,e7;var H6=D(()=>{WF={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};t7={name:"a11y",handler:($,Z,Y,X)=>{if(!Z.length)return $;let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"",K={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[J]||"Make this element accessible";return`<!-- a11y-hint: ${Q||K} -->${$}`},hasEndTag:!1},e7={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function BF($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...k1,...Z};if($==="custom"&&G)return G;switch($){case"fade":return`${Q==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
15
+ `.trim()}function PG(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function KF($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let L=J[1];if(!/\balt\s*=/i.test(L))Y.push({type:"missing-alt",element:J[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});J=X.exec($)}let Q=/<button([^>]*)>\s*<\/button>/gi;J=Q.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"missing-accessible-name",element:J[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});J=Q.exec($)}let G=/<a\s+([^>]*)>\s*<\/a>/gi;J=G.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"link-missing-text",element:J[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});J=G.exec($)}let K=/<(input|select|textarea)\s+([^>]*)>/gi;J=K.exec($);while(J!==null){let L=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(L)){J=K.exec($);continue}let F=/\baria-label\s*=/i.test(L)||/\baria-labelledby\s*=/i.test(L),O=L.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!F){let V=O&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${O[1]}["']`,"i").test($),N=J.index,A=$.substring(0,N),R=$.substring(N),M=(A.match(/<label\b/gi)||[]).length,E=(A.match(/<\/label>/gi)||[]).length,I=M>E;if(!V&&!I)Y.push({type:"input-missing-label",element:J[0].substring(0,100),message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})}J=K.exec($)}let W=/<h([1-6])[^>]*>/gi,U=[];J=W.exec($);while(J!==null)U.push(Number.parseInt(J[1],10)),J=W.exec($);let _=0;for(let L of U){if(_>0&&L>_+1)Y.push({type:"heading-skip",element:`<h${L}>`,message:`Heading level skipped from h${_} to h${L}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});_=L}if(/<html\b/i.test($)&&!/<html[^>]*\slang\s*=/i.test($))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let B=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=B.exec($);while(J!==null){let L=J[1];if(!/<th\b/i.test(L))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});J=B.exec($)}let z=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=z.exec($);while(J!==null){if(!/\bmuted\b/i.test(J[0]))Y.push({type:"autoplay-audio",element:`<${J[1]}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"});J=z.exec($)}let q=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;J=q.exec($);while(J!==null)Y.push({type:"positive-tabindex",element:`tabindex="${J[1]}"`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"}),J=q.exec($);let j=/<iframe\s+([^>]*)>/gi;J=j.exec($);while(J!==null){let L=J[1];if(!/\btitle\s*=/i.test(L)&&!/\baria-label\s*=/i.test(L))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});J=j.exec($)}let H=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;J=H.exec($);while(J!==null){let L=J[1].toLowerCase(),F=J[2];if(L!=="button"&&!/\btabindex\s*=/i.test(F))Y.push({type:"button-not-focusable",element:J[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});J=H.exec($)}return Y}async function o7($,Z){if(!PG())return KF($,Z);let Y=[];try{let X=globalThis.document.createElement("div");X.innerHTML=$,X.querySelectorAll("img").forEach((K)=>{if(!K.hasAttribute("alt"))Y.push({type:"missing-alt",element:`<${K.outerHTML}>`,message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"})}),X.querySelectorAll('button, a, [role="button"]').forEach((K)=>{if(!(K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby")||K.textContent&&K.textContent.trim().length>0))Y.push({type:"missing-accessible-name",element:`<${K.outerHTML}>`,message:"Interactive element missing accessible name",impact:"critical",help:"Add text content, aria-label, or aria-labelledby",helpUrl:"https://web.dev/learn/accessibility/aria-html/"})}),X.querySelectorAll("input, select, textarea").forEach((K)=>{let W=K.getAttribute("id"),U=W&&X.querySelector(`label[for="${W}"]`),_=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),B=K.closest("label")!==null;if(!U&&!_&&!B)Y.push({type:"input-missing-label",element:`<${K.outerHTML}>`,message:"Form input missing associated label",impact:"serious",help:"Associate a label with the input or use aria-label",helpUrl:"https://web.dev/learn/accessibility/forms/"})});let J=Array.from(X.querySelectorAll("h1, h2, h3, h4, h5, h6")),Q=0;for(let K of J){let W=Number.parseInt(K.tagName.charAt(1));if(Q>0&&W>Q+1)Y.push({type:"heading-skip",element:`<${K.outerHTML}>`,message:`Heading level skipped from h${Q} to h${W}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});Q=W}let G=X.querySelector("html");if($.includes("<html")&&G&&!G.hasAttribute("lang"))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});if(X.querySelectorAll("a").forEach((K)=>{let W=K.textContent&&K.textContent.trim().length>0,U=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),_=K.hasAttribute("title"),B=K.querySelector("img[alt]");if(!W&&!U&&!_&&!B)Y.push({type:"link-missing-text",element:`<${K.outerHTML}>`,message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"})}),$.includes("<nav")||$.includes("<header")){if(!X.querySelector('a[href="#main"], a[href="#content"], .skip-link, [class*="skip"]')&&X.querySelectorAll("a").length>5)Y.push({type:"missing-skip-link",element:"<nav>",message:"Consider adding a skip navigation link",impact:"minor",help:"Add a skip link to allow keyboard users to bypass navigation",helpUrl:"https://web.dev/learn/accessibility/focus/#skip-links"})}if(X.querySelectorAll("table").forEach((K)=>{let W=K.querySelector("caption");if(!K.querySelector("th"))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});if(!W&&!K.hasAttribute("aria-label")&&!K.hasAttribute("aria-labelledby"))Y.push({type:"table-missing-caption",element:"<table>",message:"Table missing caption or accessible name",impact:"minor",help:"Add a caption element or aria-label to describe the table",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"})}),X.querySelectorAll('[style*="color"]').forEach((K)=>{let W=K.getAttribute("style")||"";if(W.includes("color:")&&!W.includes("background"))Y.push({type:"potential-contrast-issue",element:`<${K.tagName.toLowerCase()}>`,message:"Element has inline color style - verify contrast ratio",impact:"minor",help:"Ensure text has sufficient contrast ratio (4.5:1 for normal text)",helpUrl:"https://web.dev/learn/accessibility/color-contrast/"})}),X.querySelectorAll("video[autoplay], audio[autoplay]").forEach((K)=>{if(!K.hasAttribute("muted"))Y.push({type:"autoplay-audio",element:`<${K.tagName.toLowerCase()}>`,message:"Auto-playing media may disrupt users",impact:"moderate",help:"Add muted attribute or provide controls to stop playback",helpUrl:"https://web.dev/learn/accessibility/more-html/#multimedia"})}),X.querySelectorAll("[tabindex]").forEach((K)=>{if(Number.parseInt(K.getAttribute("tabindex")||"0")>0)Y.push({type:"positive-tabindex",element:`<${K.tagName.toLowerCase()}>`,message:"Positive tabindex disrupts natural tab order",impact:"moderate",help:'Use tabindex="0" or "-1" instead of positive values',helpUrl:"https://web.dev/learn/accessibility/focus/#tab-index"})}),X.querySelectorAll('[role="button"]').forEach((K)=>{if(!K.hasAttribute("tabindex"))Y.push({type:"button-not-focusable",element:`<${K.outerHTML}>`,message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"})}),$.includes("<body")&&!X.querySelector('main, [role="main"]'))Y.push({type:"missing-main-landmark",element:"<body>",message:"Document missing main landmark region",impact:"moderate",help:"Add a main element to identify the primary content",helpUrl:"https://web.dev/learn/accessibility/structure/#landmarks"});X.querySelectorAll("iframe").forEach((K)=>{if(!K.hasAttribute("title")&&!K.hasAttribute("aria-label"))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"})})}catch(X){console.error(`Error checking accessibility in ${Z}:`,X)}return Y}async function QZ($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=a7.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(a7.normalize(_))))K.push(W);for(let W of K)try{let U=await Bun.file(W).text();if(W.endsWith("good-a11y.stx"))continue;let _=await o7(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function yG($,Z={}){let Y={...WF,...Z},X=[],J=$;if(Y.fixMissingAlt)J=J.replace(/<img([^>]*?)(?<!\balt\s*=\s*["'][^"']*["'])(\s*\/?>)/gi,(Q,G,K)=>{if(/\balt\s*=/i.test(G))return Q;let W=Q,U=`<img${G} alt=""${K}`;return X.push({type:"missing-alt",description:"Added empty alt attribute to image",before:W,after:U}),U});if(Y.fixMissingLabels)J=J.replace(/<button([^>]*)>\s*<\/button>/gi,(Q,G)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;let K=Q,W=`<button${G} aria-label="Button"></button>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to empty button",before:K,after:W}),W}),J=J.replace(/<a([^>]*)>\s*(<(?:i|span|svg)[^>]*(?:class="[^"]*icon[^"]*")?[^>]*>.*?<\/(?:i|span|svg)>)?\s*<\/a>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(G)||/\btitle\s*=/i.test(G))return Q;if(!K&&Q.replace(/<a[^>]*>|<\/a>/gi,"").trim())return Q;let W=Q,U=`<a${G} aria-label="Link">${K||""}</a>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to link without text",before:W,after:U}),U});if(Y.fixMissingFormLabels)J=J.replace(/<(input|select|textarea)([^>]*)>/gi,(Q,G,K)=>{if(/\baria-label\s*=/i.test(K)||/\baria-labelledby\s*=/i.test(K))return Q;if(/\btype\s*=\s*["']hidden["']/i.test(K))return Q;let W=K.match(/\bname\s*=\s*["']([^"']+)["']/i),U=K.match(/\bid\s*=\s*["']([^"']+)["']/i),_=W?.[1]||U?.[1]||G,B=Q,z=`<${G}${K} aria-label="${_}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:B,after:z}),z});if(Y.fixMissingLang)J=J.replace(/<html([^>]*)>/gi,(Q,G)=>{if(/\blang\s*=/i.test(G))return Q;let K=Q,W=`<html${G} lang="${Y.defaultLang}">`;return X.push({type:"missing-lang",description:`Added lang="${Y.defaultLang}" to html element`,before:K,after:W}),W});if(Y.fixPositiveTabindex)J=J.replace(/\btabindex\s*=\s*["']([1-9]\d*)["']/gi,(Q,G)=>{let K=Q,W='tabindex="0"';return X.push({type:"positive-tabindex",description:`Changed tabindex="${G}" to tabindex="0"`,before:K,after:'tabindex="0"'}),'tabindex="0"'});if(Y.fixButtonFocusable)J=J.replace(/<([a-z]+)(\s[^>]*role\s*=\s*["']button["'][^>]*)>/gi,(Q,G,K)=>{if(/\btabindex\s*=/i.test(K))return Q;if(G.toLowerCase()==="button")return Q;let W=Q,U=`<${G}${K} tabindex="0">`;return X.push({type:"button-not-focusable",description:'Added tabindex="0" to element with role="button"',before:W,after:U}),U});if(Y.fixTableHeaders)J=J.replace(/<th([^>]*)>/gi,(Q,G)=>{if(/\bscope\s*=/i.test(G))return Q;let K=Q,W=`<th${G} scope="col">`;return X.push({type:"table-missing-scope",description:'Added scope="col" to table header',before:K,after:W}),W});return{original:$,fixed:J,fixCount:X.length,fixes:X}}async function xG($,Z={},Y=!1){let X=await Bun.file($).text(),J=yG(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function UF($,Z={},Y={}){let X={},{recursive:J=!0,ignorePaths:Q=[],writeBack:G=!1,extensions:K=[".stx",".html",".htm"]}=Y,W=K.length===1?`*${K[0]}`:`*{${K.join(",")}}`,U=a7.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let B of _.scan()){if(Q.some((q)=>B.includes(a7.normalize(q))))continue;try{let q=await xG(B,Z,G);if(q.fixCount>0)X[B]=q}catch(q){console.error(`Error fixing ${B}:`,q)}}return X}function _F(){return[t7,e7]}var WF,t7,e7;var H4=D(()=>{WF={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};t7={name:"a11y",handler:($,Z,Y,X)=>{if(!Z.length)return $;let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"",K={"aria-label":"Ensure interactive elements have accessible labels","alt-text":"Provide alternative text for images",focus:"Ensure the element can receive keyboard focus",landmark:"Use appropriate landmark roles","heading-order":"Maintain proper heading hierarchy","color-contrast":"Ensure sufficient color contrast","keyboard-nav":"Make sure element is keyboard navigable","screen-reader":"Optimize for screen reader users"}[J]||"Make this element accessible";return`<!-- a11y-hint: ${Q||K} -->${$}`},hasEndTag:!1},e7={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function BF($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...k1,...Z};if($==="custom"&&G)return G;switch($){case"fade":return`${Q==="in"?"opacity: 0; animation: fadeIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="out"?"opacity: 1; animation: fadeOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"opacity: 1; transition: opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
16
16
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
17
17
  @keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }`;case"slide":return`${Q==="in"?"transform: translateY(20px); opacity: 0; animation: slideIn var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":Q==="out"?"transform: translateY(0); opacity: 1; animation: slideOut var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms) forwards;":"transform: translateY(0); opacity: 1; transition: transform var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms), opacity var(--stx-transition-duration, 300ms) var(--stx-transition-ease, ease) var(--stx-transition-delay, 0ms);"}
18
18
  @keyframes slideIn { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@@ -790,10 +790,10 @@ else {
790
790
  };
791
791
  })();
792
792
  </script>
793
- `}function _Z($,Z){let Y=UZ(Z);if(!Y)return $;let X=$.lastIndexOf("</body>");if(X!==-1)return $.slice(0,X)+Y+$.slice(X);return $+Y}function TF($){let Z={},Y=$.match(/(\w+)=["']?([^"'\s]+)["']?/g)||[];for(let X of Y){let[J,Q]=X.split("="),G=Q?.replace(/["']/g,"");switch(J){case"endpoint":Z.endpoint=G;break;case"samplingRate":Z.samplingRate=Number.parseInt(G,10);break;case"batchSize":Z.batchSize=Number.parseInt(G,10);break;case"trackMouse":Z.trackMouse=G==="true";break;case"trackClicks":Z.trackClicks=G==="true";break;case"trackScroll":Z.trackScroll=G==="true";break;case"honorDnt":Z.honorDnt=G==="true";break;case"debugOverlay":Z.debugOverlay=G==="true";break}}return Z}class zZ{sessions=new Map;addSession($){let Z=this.sessions.get($.sid);if(Z)Z.points.push(...$.points),Z.lastActivity=Math.max(Z.lastActivity,$.lastActivity);else this.sessions.set($.sid,$)}getPageData($){let Z=[];for(let Y of this.sessions.values())if(Y.page===$)Z.push(...Y.points);return Z}getClickData($){return this.getPageData($).filter((Z)=>Z.type==="click")}getMovementData($){return this.getPageData($).filter((Z)=>Z.type==="move")}getScrollData($){let Z=this.getPageData($).filter((X)=>X.type==="scroll"),Y=new Map;for(let X of Z)if(X.depth!==void 0)Y.set(X.depth,(Y.get(X.depth)||0)+1);return Array.from(Y.entries()).map(([X,J])=>({depth:X,count:J})).sort((X,J)=>X.depth-J.depth)}getZoneStats($){let Z=new Map,Y=this.getPageData($);for(let X of Y)if(X.zone){let J=Z.get(X.zone)||{clicks:0,hovers:0};if(X.type==="click")J.clicks++;else if(X.type==="move")J.hovers++;Z.set(X.zone,J)}return Z}generateGridData($,Z=20){let Y=this.getPageData($),X=[];for(let Q=0;Q<Z;Q++){X[Q]=[];for(let G=0;G<Z;G++)X[Q][G]=0}for(let Q of Y){let G=Math.min(Math.floor(Q.x/100*Z),Z-1),K=Math.min(Math.floor(Q.y/100*Z),Z-1);X[K][G]+=Q.type==="click"?3:1}let J=0;for(let Q of X)for(let G of Q)J=Math.max(J,G);return X.map((Q,G)=>Q.map((K,W)=>({x:W,y:G,intensity:J>0?K/J:0})))}exportJSON(){return JSON.stringify({sessions:Array.from(this.sessions.values()),exportedAt:new Date().toISOString()},null,2)}clear(){this.sessions.clear()}get sessionCount(){return this.sessions.size}get totalPoints(){let $=0;for(let Z of this.sessions.values())$+=Z.points.length;return $}}function IF(){return new zZ}var pG,BZ;var Q8=D(()=>{pG={enabled:!1,trackMouse:!0,trackClicks:!0,trackScroll:!0,samplingRate:100,honorDnt:!0,batchSize:50,maxDataPoints:1000,sessionTimeout:30,persistData:!1,storagePrefix:"stx_heatmap",captureAttributes:["data-heatmap-id","data-track"],ignoreSelectors:["[data-heatmap-ignore]",".heatmap-ignore"],debugOverlay:!1};BZ={name:"heatmap",hasEndTag:!1,description:"Inject privacy-compliant heatmap tracking script",handler:async($,Z,Y,X)=>{let J=Y.__stx_config||{};if(Z.length>0){let Q=TF(Z.join(" "));J.heatmap={...J.heatmap,...Q,enabled:!0}}return UZ(J)}}});function _4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function iG($){let Z=$.trim().toLowerCase();return!Z.startsWith("javascript:")&&!Z.startsWith("vbscript:")&&!Z.startsWith("data:text/html")}function nG($){let Z=/^---\r?\n([\s\S]*?)\r?\n---\r?\n/,Y=$.match(Z);if(!Y)return{data:{},content:$.trim()};let X=Y[1],J=$.slice(Y[0].length),Q={};for(let G of X.split(`
794
- `)){let K=G.trim();if(!K||K.startsWith("#"))continue;let W=K.indexOf(":");if(W===-1)continue;let U=K.slice(0,W).trim(),_=K.slice(W+1).trim();if(typeof _==="string"){if(_.startsWith('"')&&_.endsWith('"')||_.startsWith("'")&&_.endsWith("'"))_=_.slice(1,-1);else if(_.startsWith("[")&&_.endsWith("]"))try{_=JSON.parse(_)}catch{}else if(_==="true")_=!0;else if(_==="false")_=!1;else if(/^-?\d+(?:\.\d+)?$/.test(_))_=Number(_)}Q[U]=_}return{data:Q,content:J.trim()}}function d$($,Z={}){let{gfm:Y=!0,breaks:X=!1}=Z,J=$,Q=[];if(J=J.replace(/```(\w*)\n([\s\S]*?)```/g,(_,B,z)=>{let q=Q.length,j=B?` class="language-${_4(B)}"`:"";return Q.push(`<pre><code${j}>${_4(z.trim())}</code></pre>`),`\x00CODEBLOCK${q}\x00`}),J=J.replace(/`([^`]*)`/g,(_,B)=>`<code>${_4(B)}</code>`),J=J.replace(/^######\s+(.*)$/gm,"<h6>$1</h6>"),J=J.replace(/^#####\s+(.*)$/gm,"<h5>$1</h5>"),J=J.replace(/^####\s+(.*)$/gm,"<h4>$1</h4>"),J=J.replace(/^###\s+(.*)$/gm,"<h3>$1</h3>"),J=J.replace(/^##\s+(.*)$/gm,"<h2>$1</h2>"),J=J.replace(/^#\s+(.*)$/gm,"<h1>$1</h1>"),J=J.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),J=J.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),J=J.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),J=J.replace(/__(.+?)__/g,"<strong>$1</strong>"),J=J.replace(/\*(.+?)\*/g,"<em>$1</em>"),J=J.replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>"),Y)J=J.replace(/~~(.+?)~~/g,"<del>$1</del>");if(J=J.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(_,B,z)=>{return`<img src="${iG(z)?_4(z):""}" alt="${_4(B)}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(_,B,z)=>{return`<a href="${iG(z)?_4(z):""}">${B}</a>`}),J=J.replace(/^(?:---|\*\*\*|___)\s*$/gm,"<hr />"),J=J.replace(/^>\s+(.*)$/gm,"<blockquote>$1</blockquote>"),J=J.replace(/<\/blockquote>\n<blockquote>/g,`
795
- `),J=J.replace(/^[*\-+]\s+(.*)$/gm,"<li data-ul>$1</li>"),J=J.replace(/(<li data-ul>.*<\/li>\n?)+/g,"<ul>$&</ul>"),J=J.replace(/<\/ul>\n<ul>/g,""),J=J.replace(/^\d+\.\s+(.*)$/gm,"<li data-ol>$1</li>"),J=J.replace(/(<li data-ol>.*<\/li>\n?)+/g,"<ol>$&</ol>"),J=J.replace(/<\/ol>\n<ol>/g,""),J=J.replace(/<li data-ul>/g,"<li>"),J=J.replace(/<li data-ol>/g,"<li>"),Y)J=J.replace(/^\|(.+)\|\s*\n\|[-:\s|]+\|\s*\n((?:\|.+\|\s*\n)*)/gm,(_,B,z)=>{let j=`<tr>${B.split("|").map((L)=>L.trim()).filter(Boolean).map((L)=>`<th>${_4(L)}</th>`).join("")}</tr>`,H=z.trim().split(`
796
- `).map((L)=>{return`<tr>${L.split("|").map((O)=>O.trim()).filter(Boolean).map((O)=>`<td>${_4(O)}</td>`).join("")}</tr>`}).join(`
793
+ `}function _Z($,Z){let Y=UZ(Z);if(!Y)return $;let X=$.lastIndexOf("</body>");if(X!==-1)return $.slice(0,X)+Y+$.slice(X);return $+Y}function TF($){let Z={},Y=$.match(/(\w+)=["']?([^"'\s]+)["']?/g)||[];for(let X of Y){let[J,Q]=X.split("="),G=Q?.replace(/["']/g,"");switch(J){case"endpoint":Z.endpoint=G;break;case"samplingRate":Z.samplingRate=Number.parseInt(G,10);break;case"batchSize":Z.batchSize=Number.parseInt(G,10);break;case"trackMouse":Z.trackMouse=G==="true";break;case"trackClicks":Z.trackClicks=G==="true";break;case"trackScroll":Z.trackScroll=G==="true";break;case"honorDnt":Z.honorDnt=G==="true";break;case"debugOverlay":Z.debugOverlay=G==="true";break}}return Z}class zZ{sessions=new Map;addSession($){let Z=this.sessions.get($.sid);if(Z)Z.points.push(...$.points),Z.lastActivity=Math.max(Z.lastActivity,$.lastActivity);else this.sessions.set($.sid,$)}getPageData($){let Z=[];for(let Y of this.sessions.values())if(Y.page===$)Z.push(...Y.points);return Z}getClickData($){return this.getPageData($).filter((Z)=>Z.type==="click")}getMovementData($){return this.getPageData($).filter((Z)=>Z.type==="move")}getScrollData($){let Z=this.getPageData($).filter((X)=>X.type==="scroll"),Y=new Map;for(let X of Z)if(X.depth!==void 0)Y.set(X.depth,(Y.get(X.depth)||0)+1);return Array.from(Y.entries()).map(([X,J])=>({depth:X,count:J})).sort((X,J)=>X.depth-J.depth)}getZoneStats($){let Z=new Map,Y=this.getPageData($);for(let X of Y)if(X.zone){let J=Z.get(X.zone)||{clicks:0,hovers:0};if(X.type==="click")J.clicks++;else if(X.type==="move")J.hovers++;Z.set(X.zone,J)}return Z}generateGridData($,Z=20){let Y=this.getPageData($),X=[];for(let Q=0;Q<Z;Q++){X[Q]=[];for(let G=0;G<Z;G++)X[Q][G]=0}for(let Q of Y){let G=Math.min(Math.floor(Q.x/100*Z),Z-1),K=Math.min(Math.floor(Q.y/100*Z),Z-1);X[K][G]+=Q.type==="click"?3:1}let J=0;for(let Q of X)for(let G of Q)J=Math.max(J,G);return X.map((Q,G)=>Q.map((K,W)=>({x:W,y:G,intensity:J>0?K/J:0})))}exportJSON(){return JSON.stringify({sessions:Array.from(this.sessions.values()),exportedAt:new Date().toISOString()},null,2)}clear(){this.sessions.clear()}get sessionCount(){return this.sessions.size}get totalPoints(){let $=0;for(let Z of this.sessions.values())$+=Z.points.length;return $}}function IF(){return new zZ}var pG,BZ;var Q8=D(()=>{pG={enabled:!1,trackMouse:!0,trackClicks:!0,trackScroll:!0,samplingRate:100,honorDnt:!0,batchSize:50,maxDataPoints:1000,sessionTimeout:30,persistData:!1,storagePrefix:"stx_heatmap",captureAttributes:["data-heatmap-id","data-track"],ignoreSelectors:["[data-heatmap-ignore]",".heatmap-ignore"],debugOverlay:!1};BZ={name:"heatmap",hasEndTag:!1,description:"Inject privacy-compliant heatmap tracking script",handler:async($,Z,Y,X)=>{let J=Y.__stx_config||{};if(Z.length>0){let Q=TF(Z.join(" "));J.heatmap={...J.heatmap,...Q,enabled:!0}}return UZ(J)}}});function _6($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function iG($){let Z=$.trim().toLowerCase();return!Z.startsWith("javascript:")&&!Z.startsWith("vbscript:")&&!Z.startsWith("data:text/html")}function nG($){let Z=/^---\r?\n([\s\S]*?)\r?\n---\r?\n/,Y=$.match(Z);if(!Y)return{data:{},content:$.trim()};let X=Y[1],J=$.slice(Y[0].length),Q={};for(let G of X.split(`
794
+ `)){let K=G.trim();if(!K||K.startsWith("#"))continue;let W=K.indexOf(":");if(W===-1)continue;let U=K.slice(0,W).trim(),_=K.slice(W+1).trim();if(typeof _==="string"){if(_.startsWith('"')&&_.endsWith('"')||_.startsWith("'")&&_.endsWith("'"))_=_.slice(1,-1);else if(_.startsWith("[")&&_.endsWith("]"))try{_=JSON.parse(_)}catch{}else if(_==="true")_=!0;else if(_==="false")_=!1;else if(/^-?\d+(?:\.\d+)?$/.test(_))_=Number(_)}Q[U]=_}return{data:Q,content:J.trim()}}function d$($,Z={}){let{gfm:Y=!0,breaks:X=!1}=Z,J=$,Q=[];if(J=J.replace(/```(\w*)\n([\s\S]*?)```/g,(_,B,z)=>{let q=Q.length,j=B?` class="language-${_6(B)}"`:"";return Q.push(`<pre><code${j}>${_6(z.trim())}</code></pre>`),`\x00CODEBLOCK${q}\x00`}),J=J.replace(/`([^`]*)`/g,(_,B)=>`<code>${_6(B)}</code>`),J=J.replace(/^######\s+(.*)$/gm,"<h6>$1</h6>"),J=J.replace(/^#####\s+(.*)$/gm,"<h5>$1</h5>"),J=J.replace(/^####\s+(.*)$/gm,"<h4>$1</h4>"),J=J.replace(/^###\s+(.*)$/gm,"<h3>$1</h3>"),J=J.replace(/^##\s+(.*)$/gm,"<h2>$1</h2>"),J=J.replace(/^#\s+(.*)$/gm,"<h1>$1</h1>"),J=J.replace(/\*\*\*(.+?)\*\*\*/g,"<strong><em>$1</em></strong>"),J=J.replace(/___(.+?)___/g,"<strong><em>$1</em></strong>"),J=J.replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>"),J=J.replace(/__(.+?)__/g,"<strong>$1</strong>"),J=J.replace(/\*(.+?)\*/g,"<em>$1</em>"),J=J.replace(/(?<![a-zA-Z0-9])_(.+?)_(?![a-zA-Z0-9])/g,"<em>$1</em>"),Y)J=J.replace(/~~(.+?)~~/g,"<del>$1</del>");if(J=J.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(_,B,z)=>{return`<img src="${iG(z)?_6(z):""}" alt="${_6(B)}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(_,B,z)=>{return`<a href="${iG(z)?_6(z):""}">${B}</a>`}),J=J.replace(/^(?:---|\*\*\*|___)\s*$/gm,"<hr />"),J=J.replace(/^>\s+(.*)$/gm,"<blockquote>$1</blockquote>"),J=J.replace(/<\/blockquote>\n<blockquote>/g,`
795
+ `),J=J.replace(/^[*\-+]\s+(.*)$/gm,"<li data-ul>$1</li>"),J=J.replace(/(<li data-ul>.*<\/li>\n?)+/g,"<ul>$&</ul>"),J=J.replace(/<\/ul>\n<ul>/g,""),J=J.replace(/^\d+\.\s+(.*)$/gm,"<li data-ol>$1</li>"),J=J.replace(/(<li data-ol>.*<\/li>\n?)+/g,"<ol>$&</ol>"),J=J.replace(/<\/ol>\n<ol>/g,""),J=J.replace(/<li data-ul>/g,"<li>"),J=J.replace(/<li data-ol>/g,"<li>"),Y)J=J.replace(/^\|(.+)\|\s*\n\|[-:\s|]+\|\s*\n((?:\|.+\|\s*\n)*)/gm,(_,B,z)=>{let j=`<tr>${B.split("|").map((L)=>L.trim()).filter(Boolean).map((L)=>`<th>${_6(L)}</th>`).join("")}</tr>`,H=z.trim().split(`
796
+ `).map((L)=>{return`<tr>${L.split("|").map((O)=>O.trim()).filter(Boolean).map((O)=>`<td>${_6(O)}</td>`).join("")}</tr>`}).join(`
797
797
  `);return`<table>
798
798
  <thead>
799
799
  ${j}
@@ -808,10 +808,10 @@ ${H}
808
808
  `:`
809
809
  `)}</p>`);if(J=K.join(`
810
810
  `),X)J=J.replace(/\n/g,`<br />
811
- `);for(let _=0;_<Q.length;_++)J=J.replace(`\x00CODEBLOCK${_}\x00`,Q[_]);return J=J.replace(/<p>\s*<\/p>/g,""),J.trim()}function B4($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(X,J)=>{return`const { ${J.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
811
+ `);for(let _=0;_<Q.length;_++)J=J.replace(`\x00CODEBLOCK${_}\x00`,Q[_]);return J=J.replace(/<p>\s*<\/p>/g,""),J.trim()}function B6($){let Z=/import\s*\{([^}]+)\}\s*from\s*['"](@stores|stx\/stores)['"]\s*;?\n?/g;$=$.replace(Z,(X,J)=>{return`const { ${J.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__STX_STORES__
812
812
  `});let Y=/import\s*\{([^}]+)\}\s*from\s*['"]@composables['"]\s*;?\n?/g;return $=$.replace(Y,(X,J)=>{return`const { ${J.split(",").map((G)=>G.trim()).filter(Boolean).join(", ")} } = window.__composables
813
- `}),$}var qZ={};t(qZ,{hasUserImports:()=>DF,bundleClientScript:()=>SF});import S1 from"path";import p4 from"fs";function DF($){let Z=/^\s*import\s+(?!type\s)/gm;if(!$.match(Z))return!1;let X=/^\s*import\s+(?!type\s).*?\s+from\s+['"]([^'"]+)['"]/gm,J;while((J=X.exec($))!==null){let G=J[1];if(!rG.some((W)=>W.test(G)))return console.log("[stx:bundler] detected user import:",G),!0}let Q=/^\s*import\s+['"]([^'"]+)['"]/gm;while((J=Q.exec($))!==null){let G=J[1];if(!rG.some((W)=>W.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function kF($){return{name:"stx-client-bundle",setup(Z){Z.onResolve({filter:/^(stx|@stacksjs\/stx|@stacksjs\/browser)$/},(Y)=>({path:Y.path,external:!0})),Z.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(Y)=>({path:Y.path,external:!0})),Z.onResolve({filter:/^@\//},(Y)=>{let X=S1.resolve($,Y.path.slice(2)),J=[X,`${X}.ts`,`${X}.js`,S1.join(X,"index.ts"),S1.join(X,"index.js")];for(let Q of J)if(p4.existsSync(Q)&&p4.statSync(Q,{throwIfNoEntry:!1})?.isFile())return console.log("[stx:bundler] resolved @/ import:",Y.path,"\u2192",Q),{path:Q};return console.warn("[stx:bundler] could not resolve @/ import:",Y.path),{path:X}})}}}async function SF($,Z,Y={}){let X=Y.projectRoot||process.cwd(),J=Y.minify??!1,Q=Y.cacheDir||S1.join(X,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),W=S1.join(Q,`${K}.js`),U=Bun.file(W);if(await U.exists())return console.log("[stx:bundler] cache hit:",K),await U.text();let _=S1.join(X,".stx","bundle-tmp"),B=S1.join(_,`${K}.ts`),z=S1.join(_,"out",K);p4.mkdirSync(_,{recursive:!0}),p4.mkdirSync(z,{recursive:!0});let q=S1.dirname(Z),j=[],H=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,F;while((F=H.exec($))!==null){if(F[1])continue;if(F[2])F[2].split(",").forEach((V)=>{let N=V.split(":")[0].trim();if(N)j.push(N)});else if(F[3])j.push(F[3])}while((F=L.exec($))!==null){if(F[1])continue;j.push(F[2])}let O=j.length>0?`
814
- export { ${j.join(", ")} }`:"";await Bun.write(B,$+O),console.log("[stx:bundler] bundling:",K,"from:",S1.basename(Z));try{let V=await Bun.build({entrypoints:[B],outdir:z,target:"browser",format:"esm",minify:J,plugins:[kF(X)],define:{"process.env.NODE_ENV":J?'"production"':'"development"'},root:q});if(!V.success){let A=V.logs.filter((R)=>R.level==="error").map((R)=>R.message).join(", ");return console.warn("[stx:bundler] build failed:",A),$}let N="";for(let A of V.outputs){N=await A.text();break}return N=N.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),console.log("[stx:bundler] bundled:",K,"output:",N.length,"bytes"),p4.mkdirSync(Q,{recursive:!0}),await Bun.write(W,N),N}catch(V){return console.warn("[stx:bundler] error:",V instanceof Error?V.message:V),$}finally{try{p4.rmSync(B,{force:!0}),p4.rmSync(z,{recursive:!0,force:!0})}catch{}}}var rG;var jZ=D(()=>{rG=[/^stx$/,/^@stacksjs\/stx$/,/^@stacksjs\/browser$/,/^@stores$/,/^stx\/stores$/,/^@composables$/]});function yF($){let Z=new Set,Y=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,X;while((X=Y.exec($))!==null)if(!PF.has(X[1]))Z.add(X[1]);return Array.from(Z)}function xF($){let Z=new Set,Y=new Set,X=$;X=X.replace(/^\s*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm,"// [type import stripped]");let J=new Set,Q=/^\s*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|stx)['"]\s*;?\s*$/gm,G;while((G=Q.exec($))!==null){let W=G[1],U=G[2];if(G[0].includes("import type"))continue;W.split(",").map((B)=>B.trim().split(/\s+as\s+/)[0]).filter((B)=>B.length>0).forEach((B)=>{if(J.add(B),U==="stx")Z.add(B);else Y.add(B)}),X=X.replace(G[0],"// [auto-import processed]")}for(let W of bF){if(J.has(W))continue;if(new RegExp(`\\b${W}\\s*\\(`,"g").test(X))Z.add(W)}for(let W of CF){if(J.has(W))continue;if(new RegExp(`\\b${W}\\b`,"g").test(X))Y.add(W)}let K=yF(X);for(let W of K)if(!J.has(W))Y.add(W);return{code:X,stxImports:Array.from(Z),browserImports:Array.from(Y)}}function vF($,Z){let Y=[];if($.length>0)Y.push(` var { ${$.join(", ")} } = window.stx || window;`);if(Z.length>0)Y.push(` var { ${Z.join(", ")} } = window.StacksBrowser || {};`);if(Y.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
813
+ `}),$}var qZ={};t(qZ,{hasUserImports:()=>DF,bundleClientScript:()=>SF});import S1 from"path";import p6 from"fs";function DF($){let Z=/^\s*import\s+(?!type\s)/gm;if(!$.match(Z))return!1;let X=/^\s*import\s+(?!type\s).*?\s+from\s+['"]([^'"]+)['"]/gm,J;while((J=X.exec($))!==null){let G=J[1];if(!rG.some((W)=>W.test(G)))return console.log("[stx:bundler] detected user import:",G),!0}let Q=/^\s*import\s+['"]([^'"]+)['"]/gm;while((J=Q.exec($))!==null){let G=J[1];if(!rG.some((W)=>W.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function kF($){return{name:"stx-client-bundle",setup(Z){Z.onResolve({filter:/^(stx|@stacksjs\/stx|@stacksjs\/browser)$/},(Y)=>({path:Y.path,external:!0})),Z.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(Y)=>({path:Y.path,external:!0})),Z.onResolve({filter:/^@\//},(Y)=>{let X=S1.resolve($,Y.path.slice(2)),J=[X,`${X}.ts`,`${X}.js`,S1.join(X,"index.ts"),S1.join(X,"index.js")];for(let Q of J)if(p6.existsSync(Q)&&p6.statSync(Q,{throwIfNoEntry:!1})?.isFile())return console.log("[stx:bundler] resolved @/ import:",Y.path,"\u2192",Q),{path:Q};return console.warn("[stx:bundler] could not resolve @/ import:",Y.path),{path:X}})}}}async function SF($,Z,Y={}){let X=Y.projectRoot||process.cwd(),J=Y.minify??!1,Q=Y.cacheDir||S1.join(X,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),W=S1.join(Q,`${K}.js`),U=Bun.file(W);if(await U.exists())return console.log("[stx:bundler] cache hit:",K),await U.text();let _=S1.join(X,".stx","bundle-tmp"),B=S1.join(_,`${K}.ts`),z=S1.join(_,"out",K);p6.mkdirSync(_,{recursive:!0}),p6.mkdirSync(z,{recursive:!0});let q=S1.dirname(Z),j=[],H=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,L=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,F;while((F=H.exec($))!==null){if(F[1])continue;if(F[2])F[2].split(",").forEach((V)=>{let N=V.split(":")[0].trim();if(N)j.push(N)});else if(F[3])j.push(F[3])}while((F=L.exec($))!==null){if(F[1])continue;j.push(F[2])}let O=j.length>0?`
814
+ export { ${j.join(", ")} }`:"";await Bun.write(B,$+O),console.log("[stx:bundler] bundling:",K,"from:",S1.basename(Z));try{let V=await Bun.build({entrypoints:[B],outdir:z,target:"browser",format:"esm",minify:J,plugins:[kF(X)],define:{"process.env.NODE_ENV":J?'"production"':'"development"'},root:q});if(!V.success){let A=V.logs.filter((R)=>R.level==="error").map((R)=>R.message).join(", ");return console.warn("[stx:bundler] build failed:",A),$}let N="";for(let A of V.outputs){N=await A.text();break}return N=N.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),console.log("[stx:bundler] bundled:",K,"output:",N.length,"bytes"),p6.mkdirSync(Q,{recursive:!0}),await Bun.write(W,N),N}catch(V){return console.warn("[stx:bundler] error:",V instanceof Error?V.message:V),$}finally{try{p6.rmSync(B,{force:!0}),p6.rmSync(z,{recursive:!0,force:!0})}catch{}}}var rG;var jZ=D(()=>{rG=[/^stx$/,/^@stacksjs\/stx$/,/^@stacksjs\/browser$/,/^@stores$/,/^stx\/stores$/,/^@composables$/]});function yF($){let Z=new Set,Y=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,X;while((X=Y.exec($))!==null)if(!PF.has(X[1]))Z.add(X[1]);return Array.from(Z)}function xF($){let Z=new Set,Y=new Set,X=$;X=X.replace(/^\s*import\s+type\s+\{[^}]*\}\s+from\s+['"][^'"]+['"]\s*;?\s*$/gm,"// [type import stripped]");let J=new Set,Q=/^\s*import\s+(?:type\s+)?{\s*([^}]+)\s*}\s+from\s+['"](@stacksjs\/browser|stx)['"]\s*;?\s*$/gm,G;while((G=Q.exec($))!==null){let W=G[1],U=G[2];if(G[0].includes("import type"))continue;W.split(",").map((B)=>B.trim().split(/\s+as\s+/)[0]).filter((B)=>B.length>0).forEach((B)=>{if(J.add(B),U==="stx")Z.add(B);else Y.add(B)}),X=X.replace(G[0],"// [auto-import processed]")}for(let W of bF){if(J.has(W))continue;if(new RegExp(`\\b${W}\\s*\\(`,"g").test(X))Z.add(W)}for(let W of CF){if(J.has(W))continue;if(new RegExp(`\\b${W}\\b`,"g").test(X))Y.add(W)}let K=yF(X);for(let W of K)if(!J.has(W))Y.add(W);return{code:X,stxImports:Array.from(Z),browserImports:Array.from(Y)}}function vF($,Z){let Y=[];if($.length>0)Y.push(` var { ${$.join(", ")} } = window.stx || window;`);if(Z.length>0)Y.push(` var { ${Z.join(", ")} } = window.StacksBrowser || {};`);if(Y.length>0)return` // STX: auto-imported from stx and @stacksjs/browser
815
815
  ${Y.join(`
816
816
  `)}
817
817
  `;return""}function fF($){let Z=[];if($.self)Z.push("if ($event.target !== $el) return");for(let Y of $.systemKeys)Z.push(`if (!$event.${Y}Key) return`);if($.keys.length>0){let Y=$.keys.map((X)=>`$event.key === '${X}'`).join(" || ");Z.push(`if (!(${Y})) return`)}if($.mouse!==null){let Y=gF[$.mouse];Z.push(`if ($event.button !== ${Y}) return`)}if($.prevent)Z.push("$event.preventDefault()");if($.stop)Z.push("$event.stopPropagation()");return Z.join("; ")}function hF($,Z){let{elementId:Y,event:X,handler:J,modifiers:Q}=$,G=fF(Q),K=[];if(Q.once)K.push("once: true");if(Q.capture)K.push("capture: true");if(Q.passive)K.push("passive: true");let W=K.length>0?`, { ${K.join(", ")} }`:"",U="";if(G)U+=`${G}; `;let _=J.replace(/\\/g,"\\\\").replace(/'/g,"\\'");function B(z){return`var scope = $el.closest('[data-stx-scope]');
@@ -854,7 +854,7 @@ else {
854
854
  // STX: auto-generated event bindings
855
855
  ${$.map((Y,X)=>hF(Y,X)).join(`
856
856
  `)}`}function sG($){let Z=[],Y=new Set,X=$.replace(/^\s*import\s+.*$/gm,""),J=0,Q=X.length,G=0;while(G<Q){let K=X[G];if(K==="'"||K==='"'||K==="`"){let W=K;if(G++,W==="`"){let U=0;while(G<Q){if(X[G]==="\\"){G+=2;continue}if(X[G]==="`"&&U===0){G++;break}if(X[G]==="$"&&X[G+1]==="{"){U++,G+=2;continue}if(X[G]==="}"&&U>0){U--,G++;continue}G++}}else while(G<Q){if(X[G]==="\\"){G+=2;continue}if(X[G]===W){G++;break}G++}continue}if(K==="/"&&X[G+1]==="/"){while(G<Q&&X[G]!==`
857
- `)G++;continue}if(K==="/"&&X[G+1]==="*"){G+=2;while(G<Q-1&&!(X[G]==="*"&&X[G+1]==="/"))G++;G+=2;continue}if(K==="{"){J++,G++;continue}if(K==="}"){J--,G++;continue}if(J===0){let W=X.slice(G),U=W.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(U){let z=U[1];if(!z.startsWith("_")&&!Y.has(z))Z.push(z),Y.add(z);G+=U[0].length;continue}let _=W.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(_){_[1].split(",").forEach((z)=>{let q=z.trim(),j=q.indexOf(":"),H=j>=0?q.slice(j+1).trim().split(/[\s=]/)[0]:q.split(/[\s=]/)[0];if(H&&!H.startsWith("_")&&!Y.has(H))Z.push(H),Y.add(H)}),G+=_[0].length;continue}let B=W.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(B){let z=B[1];if(!z.startsWith("_")&&!Y.has(z))Z.push(z),Y.add(z);G+=B[0].length;continue}}G++}return Z}function uF($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function X(z){let q;while((q=Y.exec(z))!==null){let j=q[0];if(!mF.has(j))Z.add(j)}}let J=/\{\{([\s\S]*?)\}\}/g,Q;while((Q=J.exec($))!==null)X(Q[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Q=G.exec($))!==null)X(Q[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Q=K.exec($))!==null)X(Q[1]);let W=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Q=W.exec($))!==null)X(Q[1]);let U=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Q=U.exec($))!==null)X(Q[1]);let _=/@model\s*=\s*["']([^"']*)["']/gi;while((Q=_.exec($))!==null)X(Q[1]);let B=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Q=B.exec($))!==null)X(Q[1]);return Z}async function i4($,Z={}){let Y=$,X="",J=!1,{hasUserImports:Q,bundleClientScript:G}=await Promise.resolve().then(() => (jZ(),qZ));if(Q(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await G(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),J=!0;if(Z.autoImports!==!1){let j=xF(Y);Y=j.code,X=vF(j.stxImports,j.browserImports)}if(Y=B4(Y),!J&&z4(Z.attrs||""))Y=q4(Y);let K=dF(Z.eventBindings||[]),W=(Z.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(W)){let j=W.replace(/\btype\s*=\s*["']module["']/i,"").trim();return`<script ${`type="module" data-stx-scoped${j?` ${j}`:""}`}>
857
+ `)G++;continue}if(K==="/"&&X[G+1]==="*"){G+=2;while(G<Q-1&&!(X[G]==="*"&&X[G+1]==="/"))G++;G+=2;continue}if(K==="{"){J++,G++;continue}if(K==="}"){J--,G++;continue}if(J===0){let W=X.slice(G),U=W.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(U){let z=U[1];if(!z.startsWith("_")&&!Y.has(z))Z.push(z),Y.add(z);G+=U[0].length;continue}let _=W.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(_){_[1].split(",").forEach((z)=>{let q=z.trim(),j=q.indexOf(":"),H=j>=0?q.slice(j+1).trim().split(/[\s=]/)[0]:q.split(/[\s=]/)[0];if(H&&!H.startsWith("_")&&!Y.has(H))Z.push(H),Y.add(H)}),G+=_[0].length;continue}let B=W.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(B){let z=B[1];if(!z.startsWith("_")&&!Y.has(z))Z.push(z),Y.add(z);G+=B[0].length;continue}}G++}return Z}function uF($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function X(z){let q;while((q=Y.exec(z))!==null){let j=q[0];if(!mF.has(j))Z.add(j)}}let J=/\{\{([\s\S]*?)\}\}/g,Q;while((Q=J.exec($))!==null)X(Q[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Q=G.exec($))!==null)X(Q[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Q=K.exec($))!==null)X(Q[1]);let W=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Q=W.exec($))!==null)X(Q[1]);let U=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Q=U.exec($))!==null)X(Q[1]);let _=/@model\s*=\s*["']([^"']*)["']/gi;while((Q=_.exec($))!==null)X(Q[1]);let B=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Q=B.exec($))!==null)X(Q[1]);return Z}async function i6($,Z={}){let Y=$,X="",J=!1,{hasUserImports:Q,bundleClientScript:G}=await Promise.resolve().then(() => (jZ(),qZ));if(Q(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await G(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),J=!0;if(Z.autoImports!==!1){let j=xF(Y);Y=j.code,X=vF(j.stxImports,j.browserImports)}if(Y=B6(Y),!J&&z6(Z.attrs||""))Y=q6(Y);let K=dF(Z.eventBindings||[]),W=(Z.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(W)){let j=W.replace(/\btype\s*=\s*["']module["']/i,"").trim();return`<script ${`type="module" data-stx-scoped${j?` ${j}`:""}`}>
858
858
  ${X}${Y}
859
859
  ${K}
860
860
  </script>`}let _=/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useLocalStorage|useSessionStorage|useRef|useEventListener|useFetch|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|batch|untrack|peek)\s*(?:<[^>]*>)?\s*\(/.test($),B=/function __stx_setup_/.test(Y),z=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test($);function q(j){let H=j.length>0?`
@@ -890,7 +890,7 @@ catch (e) {
890
890
  }
891
891
  throw e;
892
892
  }
893
- `)}function G8($){let Z=$.trim(),Y=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let X of Y)if(X.test(Z))return!1;return!0}var cF,aG,oG,lF;var n0=D(()=>{cF={maxSanitizeDepth:10,allowBracketNotation:!1},aG={...cF},oG=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],lF=/[\w)\]]\s*\[\s*['"]/});function LZ(){tG=0,K8.clear()}function c$($,Z){let Y=tG++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return K8.set(X,{type:$,expression:Z}),X}function OZ(){let $={};for(let[Z,Y]of K8)$[Z]={type:Y.type,expression:Y.expression};return $}function nF($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=K8.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function W8($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function L6($){return $.includes("<!--__STX_")}var tG=0,K8;var l$=D(()=>{K8=new Map});var n$={};t(n$,{usesSignalsInScript:()=>i$,unescapeHtml:()=>U8,registerFilters:()=>ZK,registerFilter:()=>FZ,processExpressions:()=>A1,interpolateScriptsInTemplate:()=>XK,interpolateScriptExpressions:()=>AZ,getAllFilters:()=>VZ,evaluateExpression:()=>W1,escapeHtml:()=>I0,defaultFilters:()=>O6,clearCustomFilters:()=>YK,applyFilters:()=>NZ});function rF($){let Z=eG.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),eG.set($,Z)}return Z.lastIndex=0,Z}function FZ($,Z){if($ in O6)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);p$[$]=Z}function ZK($){for(let[Z,Y]of Object.entries($))FZ(Z,Y)}function VZ(){return{...O6,...p$}}function YK(){for(let $ of Object.keys(p$))delete p$[$]}function I0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function i$($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;return!1}function $K($,Z){let Y=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],X=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),J="",Q=!1,G=0;for(let U=0;U<X.length;U++){let _=X[U];if(!Q&&_==="`"){Q=!0,G=0;continue}if(Q){if(_==="`"&&G===0){Q=!1;continue}if(_==="$"&&X[U+1]==="{"){G++,U++;continue}if(_==="}"&&G>0){G--;continue}continue}J+=_}X=J;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,W;while((W=K.exec(X))!==null){let U=W[1];if(!X.substring(0,W.index).trimEnd().endsWith(".")){if(!Y.includes(U)&&!(U in Z))return!1}}return!0}function AZ($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=W1(J,Z);if(Q===void 0)return X;return Q===null?"":String(Q)}catch{return X}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return X;try{let G=W1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function XK($,Z,Y={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(X,J,Q)=>{if(/\bsrc\s*=/.test(J))return X;if(/\bdata-raw\b/.test(J))return X;if(/\btype\s*=\s*["']application\/json["']/.test(J))return X;if(Y.skipServer&&/\bserver\b/.test(J))return X;let G=AZ(Q,Z);return`<script${J}>${G}</script>`})}function A1($,Z,Y){let X=$,J=[];X=X.replace(/<style[^>]*>[\s\S]*?<\/style>/gi,(K)=>{if(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(K))return K;let W=J.length;return J.push(K),`<!--__STX_STYLE_${W}__-->`});let Q=[];X=X.replace(/<script[^>]*>[\s\S]*?<\/script>/gi,(K)=>{let W=Q.length;return Q.push(K),`<!--__STX_SCRIPT_EXPR_${W}__-->`});let G=i$($);X=X.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(K,W,U)=>{try{let _=W1(W,Z);return _!==void 0&&_!==null?String(_):""}catch(_){let B=_ instanceof Error?_.message:String(_);return O0("Expression",`Error evaluating: {{{ ${W.trim()}}}}: ${B}`,Y,$,U,K)}}),X=X.replace(/\{!!([\s\S]*?)!!\}/g,(K,W,U)=>{try{let _=W1(W,Z);if(_===void 0&&Z.__stx_buildMode==="compile")return c$("raw",W.trim());return _!==void 0&&_!==null?String(_):""}catch(_){if(Z.__stx_buildMode==="compile")return c$("raw",W.trim());let B=_ instanceof Error?_.message:String(_);return O0("Expression",`Error evaluating: {!! ${W.trim()} !!}: ${B}`,Y,$,U,K)}}),X=X.replace(/<script[^>]*>[\s\S]*?<\/script>/gi,(K)=>{if(K.startsWith("<!--__STX_SCRIPT_EXPR_"))return K;let W=Q.length;return Q.push(K),`<!--__STX_SCRIPT_EXPR_${W}__-->`}),X=X.replace(/<style[^>]*>[\s\S]*?<\/style>/gi,(K)=>{if(K.startsWith("<!--__STX_STYLE_"))return K;if(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(K))return K;let W=J.length;return J.push(K),`<!--__STX_STYLE_${W}__-->`}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(K,W,U)=>{let _=W.trim(),B=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],z=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,j=_.match(z)?.[1],H=j&&((j in Z)||B.includes(j)),L=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,F=_.match(L),O=F&&!B.includes(F[1])&&!(F[1]in Z);if(/^__[A-Z_]+__$/.test(_))return"";try{let V=W1(W,Z);if(V===void 0&&G&&!$K(_,Z))return K;if(V===void 0&&Z.__stx_buildMode==="compile"&&!G)return c$("expr",_);return V!==void 0&&V!==null?I0(String(V)):""}catch(V){if(G&&!$K(_,Z))return K;if(O)return K;let N=V instanceof Error?V.message:String(V);return O0("Expression",`Error evaluating: {{ ${_} }}: ${N}`,Y,$,U,K)}});for(let K=0;K<Q.length;K++)X=X.replace(`<!--__STX_SCRIPT_EXPR_${K}__-->`,()=>Q[K]);for(let K=0;K<J.length;K++)X=X.replace(`<!--__STX_STYLE_${K}__-->`,()=>J[K]);return X}function NZ($,Z,Y){if(!Z.trim())return $;let X=$,J=Z.trim();while(J.length>0){let Q=J.match(/^(\w+)/);if(!Q)break;let G=Q[1];J=J.substring(G.length).trim();let K=p$[G]||O6[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(VZ()).join(", ")}`);let W=[];if(J.startsWith(":")){let U=J.match(/^:([^|\s]+)/);if(U){let _=U[1].trim();try{let B=Number(_);W=[Number.isNaN(B)?_:B]}catch{W=[_]}J=J.substring(U[0].length).trim()}}else if(J.startsWith("(")){let U=1,_=1;while(U>0&&_<J.length){if(J[_]==="(")U++;if(J[_]===")")U--;_++}if(U===0){let B=J.substring(1,_-1).trim();if(B)try{if(B.startsWith("{")&&B.endsWith("}"))W=[W1(`(${B})`,Y,!0)];else{let z=[],q="",j=null,H=0,L=0,F=0,O=!1;for(let V=0;V<B.length;V++){let N=B[V];if(O){q+=N,O=!1;continue}if(N==="\\"){q+=N,O=!0;continue}if(j){if(q+=N,N===j)j=null;continue}if(N==='"'||N==="'"||N==="`"){j=N,q+=N;continue}if(N==="(")H++;else if(N===")")H--;else if(N==="[")L++;else if(N==="]")L--;else if(N==="{")F++;else if(N==="}")F--;if(N===","&&H===0&&L===0&&F===0){z.push(q),q="";continue}q+=N}if(q)z.push(q);W=z.map((V)=>{let N=V.trim();return W1(N,Y,!0)})}}catch{W=[B]}J=J.substring(_).trim()}}try{X=K(X,Y,...W)}catch(U){let _=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${_}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function sF($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let _=1;K+=2;while(K<$.length&&_>0){if($[K]==="{")_++;else if($[K]==="}")_--;if(_>0)K++}continue}if(Z)continue;if(W==="(")X++;else if(W===")")X--;else if(W==="[")J++;else if(W==="]")J--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&X===0&&J===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function W1($,Z,Y=!1){try{let X=$.trim(),J=sF(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=W1(Q,Z,!0);return NZ(K,G,Z)}if(!L0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return M0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return F0(X,Q)(...G)}catch{return M0(X,Z)}}catch(X){if(!Y)console.error(`Error evaluating expression: ${$}`,X);throw X}}function U8($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var p$,eG,O6;var r0=D(()=>{n0();H0();l$();p$={},eG=new Map;O6={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let X=Number($);return Number.isNaN(X)?"":X.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return X.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return I0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let X=Z.__translations,J=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=X;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(rF(W),String(U))}),K},t:($,Z,Y={})=>{return O6.translate($,Z,Y)},truncate:($,Z,Y=50,X="...")=>{if($===void 0||$===null)return"";let J=String($);if(J.length<=Y)return J;if(Y<=X.length)return X.substring(0,Y);return J.substring(0,Y-X.length)+X},date:($,Z,Y="short",X="en-US")=>{if($===void 0||$===null)return"";try{let J=$ instanceof Date?$:new Date($);if(Number.isNaN(J.getTime()))return String($);let Q={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(Y==="iso")return J.toISOString();return new Intl.DateTimeFormat(X,Q[Y]||Q.short).format(J)}catch{return String($)}},currency:($,Z,Y="USD",X="en-US")=>{if($===void 0||$===null)return"";try{let J=Number($);if(Number.isNaN(J))return String($);return new Intl.NumberFormat(X,{style:"currency",currency:Y}).format(J)}catch{return String($)}},pluralize:($,Z,Y,X)=>{let J=Number($);if(Number.isNaN(J))return Y;let Q=X||`${Y}s`;return J===1?Y:Q},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let Y=String($);return Y.charAt(Y.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,Y=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return Y?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,Y="")=>{return $===void 0||$===null||$===""?Y:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,Y=0,X)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(Y,X);return $},replace:($,Z,Y,X="")=>{if($===void 0||$===null)return"";let J=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(J,"g"),()=>X)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let Y=Number($);return Number.isNaN(Y)?0:Math.abs(Y)},round:($,Z,Y=0)=>{let X=Number($);if(Number.isNaN(X))return 0;let J=10**Y;return Math.round(X*J)/J}}});class r${cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let Y=this.cache.keys().next().value;if(Y!==void 0)this.cache.delete(Y)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function V6($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!F6.has(Y)){if(F6.size>=aF){let X=F6.keys().next().value;if(X)F6.delete(X)}F6.set(Y,new RegExp($,Z))}return F6.get(Y)}class JK{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),X=this.pool.find((K)=>K.context.join(",")===Y);if(X)return X.func;let J=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,_=J.get(U);if(!_){if(J.size>=Q){let B=J.keys().next().value;if(B)J.delete(B)}_=Function(...Z,`
893
+ `)}function G8($){let Z=$.trim(),Y=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let X of Y)if(X.test(Z))return!1;return!0}var cF,aG,oG,lF;var n0=D(()=>{cF={maxSanitizeDepth:10,allowBracketNotation:!1},aG={...cF},oG=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],lF=/[\w)\]]\s*\[\s*['"]/});function LZ(){tG=0,K8.clear()}function c$($,Z){let Y=tG++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return K8.set(X,{type:$,expression:Z}),X}function OZ(){let $={};for(let[Z,Y]of K8)$[Z]={type:Y.type,expression:Y.expression};return $}function nF($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=K8.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function W8($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function L4($){return $.includes("<!--__STX_")}var tG=0,K8;var l$=D(()=>{K8=new Map});var n$={};t(n$,{usesSignalsInScript:()=>i$,unescapeHtml:()=>U8,registerFilters:()=>ZK,registerFilter:()=>FZ,processExpressions:()=>A1,interpolateScriptsInTemplate:()=>XK,interpolateScriptExpressions:()=>AZ,getAllFilters:()=>VZ,evaluateExpression:()=>W1,escapeHtml:()=>I0,defaultFilters:()=>O4,clearCustomFilters:()=>YK,applyFilters:()=>NZ});function rF($){let Z=eG.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),eG.set($,Z)}return Z.lastIndex=0,Z}function FZ($,Z){if($ in O4)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);p$[$]=Z}function ZK($){for(let[Z,Y]of Object.entries($))FZ(Z,Y)}function VZ(){return{...O4,...p$}}function YK(){for(let $ of Object.keys(p$))delete p$[$]}function I0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function i$($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;return!1}function $K($,Z){let Y=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined","NaN","Infinity","isNaN","isFinite","window","document","console"],X=$.replace(/'[^']*'/g,"").replace(/"[^"]*"/g,""),J="",Q=!1,G=0;for(let U=0;U<X.length;U++){let _=X[U];if(!Q&&_==="`"){Q=!0,G=0;continue}if(Q){if(_==="`"&&G===0){Q=!1;continue}if(_==="$"&&X[U+1]==="{"){G++,U++;continue}if(_==="}"&&G>0){G--;continue}continue}J+=_}X=J;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,W;while((W=K.exec(X))!==null){let U=W[1];if(!X.substring(0,W.index).trimEnd().endsWith(".")){if(!Y.includes(U)&&!(U in Z))return!1}}return!0}function AZ($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=W1(J,Z);if(Q===void 0)return X;return Q===null?"":String(Q)}catch{return X}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return X;try{let G=W1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function XK($,Z,Y={}){return $.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,(X,J,Q)=>{if(/\bsrc\s*=/.test(J))return X;if(/\bdata-raw\b/.test(J))return X;if(/\btype\s*=\s*["']application\/json["']/.test(J))return X;if(Y.skipServer&&/\bserver\b/.test(J))return X;let G=AZ(Q,Z);return`<script${J}>${G}</script>`})}function A1($,Z,Y){let X=$,J=[];X=X.replace(/<style[^>]*>[\s\S]*?<\/style>/gi,(K)=>{if(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(K))return K;let W=J.length;return J.push(K),`<!--__STX_STYLE_${W}__-->`});let Q=[];X=X.replace(/<script[^>]*>[\s\S]*?<\/script>/gi,(K)=>{let W=Q.length;return Q.push(K),`<!--__STX_SCRIPT_EXPR_${W}__-->`});let G=i$($);X=X.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(K,W,U)=>{try{let _=W1(W,Z);return _!==void 0&&_!==null?String(_):""}catch(_){let B=_ instanceof Error?_.message:String(_);return O0("Expression",`Error evaluating: {{{ ${W.trim()}}}}: ${B}`,Y,$,U,K)}}),X=X.replace(/\{!!([\s\S]*?)!!\}/g,(K,W,U)=>{try{let _=W1(W,Z);if(_===void 0&&Z.__stx_buildMode==="compile")return c$("raw",W.trim());return _!==void 0&&_!==null?String(_):""}catch(_){if(Z.__stx_buildMode==="compile")return c$("raw",W.trim());let B=_ instanceof Error?_.message:String(_);return O0("Expression",`Error evaluating: {!! ${W.trim()} !!}: ${B}`,Y,$,U,K)}}),X=X.replace(/<script[^>]*>[\s\S]*?<\/script>/gi,(K)=>{if(K.startsWith("<!--__STX_SCRIPT_EXPR_"))return K;let W=Q.length;return Q.push(K),`<!--__STX_SCRIPT_EXPR_${W}__-->`}),X=X.replace(/<style[^>]*>[\s\S]*?<\/style>/gi,(K)=>{if(K.startsWith("<!--__STX_STYLE_"))return K;if(/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(K))return K;let W=J.length;return J.push(K),`<!--__STX_STYLE_${W}__-->`}),X=X.replace(/\{\{([\s\S]*?)\}\}/g,(K,W,U)=>{let _=W.trim(),B=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],z=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,j=_.match(z)?.[1],H=j&&((j in Z)||B.includes(j)),L=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,F=_.match(L),O=F&&!B.includes(F[1])&&!(F[1]in Z);if(/^__[A-Z_]+__$/.test(_))return"";try{let V=W1(W,Z);if(V===void 0&&G&&!$K(_,Z))return K;if(V===void 0&&Z.__stx_buildMode==="compile"&&!G)return c$("expr",_);return V!==void 0&&V!==null?I0(String(V)):""}catch(V){if(G&&!$K(_,Z))return K;if(O)return K;let N=V instanceof Error?V.message:String(V);return O0("Expression",`Error evaluating: {{ ${_} }}: ${N}`,Y,$,U,K)}});for(let K=0;K<Q.length;K++)X=X.replace(`<!--__STX_SCRIPT_EXPR_${K}__-->`,()=>Q[K]);for(let K=0;K<J.length;K++)X=X.replace(`<!--__STX_STYLE_${K}__-->`,()=>J[K]);return X}function NZ($,Z,Y){if(!Z.trim())return $;let X=$,J=Z.trim();while(J.length>0){let Q=J.match(/^(\w+)/);if(!Q)break;let G=Q[1];J=J.substring(G.length).trim();let K=p$[G]||O4[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(VZ()).join(", ")}`);let W=[];if(J.startsWith(":")){let U=J.match(/^:([^|\s]+)/);if(U){let _=U[1].trim();try{let B=Number(_);W=[Number.isNaN(B)?_:B]}catch{W=[_]}J=J.substring(U[0].length).trim()}}else if(J.startsWith("(")){let U=1,_=1;while(U>0&&_<J.length){if(J[_]==="(")U++;if(J[_]===")")U--;_++}if(U===0){let B=J.substring(1,_-1).trim();if(B)try{if(B.startsWith("{")&&B.endsWith("}"))W=[W1(`(${B})`,Y,!0)];else{let z=[],q="",j=null,H=0,L=0,F=0,O=!1;for(let V=0;V<B.length;V++){let N=B[V];if(O){q+=N,O=!1;continue}if(N==="\\"){q+=N,O=!0;continue}if(j){if(q+=N,N===j)j=null;continue}if(N==='"'||N==="'"||N==="`"){j=N,q+=N;continue}if(N==="(")H++;else if(N===")")H--;else if(N==="[")L++;else if(N==="]")L--;else if(N==="{")F++;else if(N==="}")F--;if(N===","&&H===0&&L===0&&F===0){z.push(q),q="";continue}q+=N}if(q)z.push(q);W=z.map((V)=>{let N=V.trim();return W1(N,Y,!0)})}}catch{W=[B]}J=J.substring(_).trim()}}try{X=K(X,Y,...W)}catch(U){let _=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${_}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function sF($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let _=1;K+=2;while(K<$.length&&_>0){if($[K]==="{")_++;else if($[K]==="}")_--;if(_>0)K++}continue}if(Z)continue;if(W==="(")X++;else if(W===")")X--;else if(W==="[")J++;else if(W==="]")J--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&X===0&&J===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function W1($,Z,Y=!1){try{let X=$.trim(),J=sF(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=W1(Q,Z,!0);return NZ(K,G,Z)}if(!L0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return M0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return F0(X,Q)(...G)}catch{return M0(X,Z)}}catch(X){if(!Y)console.error(`Error evaluating expression: ${$}`,X);throw X}}function U8($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var p$,eG,O4;var r0=D(()=>{n0();H0();l$();p$={},eG=new Map;O4={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let X=Number($);return Number.isNaN(X)?"":X.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return X.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return I0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let X=Z.__translations,J=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=X;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(rF(W),String(U))}),K},t:($,Z,Y={})=>{return O4.translate($,Z,Y)},truncate:($,Z,Y=50,X="...")=>{if($===void 0||$===null)return"";let J=String($);if(J.length<=Y)return J;if(Y<=X.length)return X.substring(0,Y);return J.substring(0,Y-X.length)+X},date:($,Z,Y="short",X="en-US")=>{if($===void 0||$===null)return"";try{let J=$ instanceof Date?$:new Date($);if(Number.isNaN(J.getTime()))return String($);let Q={short:{dateStyle:"short"},medium:{dateStyle:"medium"},long:{dateStyle:"long"},full:{dateStyle:"full"},time:{timeStyle:"short"},datetime:{dateStyle:"short",timeStyle:"short"},iso:{}};if(Y==="iso")return J.toISOString();return new Intl.DateTimeFormat(X,Q[Y]||Q.short).format(J)}catch{return String($)}},currency:($,Z,Y="USD",X="en-US")=>{if($===void 0||$===null)return"";try{let J=Number($);if(Number.isNaN(J))return String($);return new Intl.NumberFormat(X,{style:"currency",currency:Y}).format(J)}catch{return String($)}},pluralize:($,Z,Y,X)=>{let J=Number($);if(Number.isNaN(J))return Y;let Q=X||`${Y}s`;return J===1?Y:Q},first:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[0];return String($).charAt(0)},last:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return $.length===0?"":$[$.length-1];let Y=String($);return Y.charAt(Y.length-1)},length:($,Z)=>{if($===void 0||$===null)return 0;if(Array.isArray($)||typeof $==="string")return $.length;if($ instanceof Map||$ instanceof Set)return $.size;if(typeof $==="object")return Object.keys($).length;return 0},json:($,Z,Y=!1)=>{if($===void 0)return"undefined";if($===null)return"null";try{return Y?JSON.stringify($,null,2):JSON.stringify($)}catch{return String($)}},default:($,Z,Y="")=>{return $===void 0||$===null||$===""?Y:$},reverse:($,Z)=>{if($===void 0||$===null)return"";if(Array.isArray($))return[...$].reverse();return String($).split("").reverse().join("")},slice:($,Z,Y=0,X)=>{if($===void 0||$===null)return"";if(Array.isArray($)||typeof $==="string")return $.slice(Y,X);return $},replace:($,Z,Y,X="")=>{if($===void 0||$===null)return"";let J=Y.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return String($).replace(new RegExp(J,"g"),()=>X)},stripTags:($,Z)=>{if($===void 0||$===null)return"";return String($).replace(/<[^>]*>/g,"")},urlencode:($,Z)=>{if($===void 0||$===null)return"";return encodeURIComponent(String($))},abs:($,Z)=>{let Y=Number($);return Number.isNaN(Y)?0:Math.abs(Y)},round:($,Z,Y=0)=>{let X=Number($);if(Number.isNaN(X))return 0;let J=10**Y;return Math.round(X*J)/J}}});class r${cache=new Map;maxSize;constructor($=100){this.maxSize=$}get($){if(!this.cache.has($))return;let Z=this.cache.get($);return this.cache.delete($),this.cache.set($,Z),Z}set($,Z){if(this.cache.has($))this.cache.delete($);else if(this.cache.size>=this.maxSize){let Y=this.cache.keys().next().value;if(Y!==void 0)this.cache.delete(Y)}this.cache.set($,Z)}has($){return this.cache.has($)}delete($){return this.cache.delete($)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function V4($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!F4.has(Y)){if(F4.size>=aF){let X=F4.keys().next().value;if(X)F4.delete(X)}F4.set(Y,new RegExp($,Z))}return F4.get(Y)}class JK{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),X=this.pool.find((K)=>K.context.join(",")===Y);if(X)return X.func;let J=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,_=J.get(U);if(!_){if(J.size>=Q){let B=J.keys().next().value;if(B)J.delete(B)}_=Function(...Z,`
894
894
  'use strict';
895
895
  try {
896
896
  return ${W};
@@ -901,14 +901,14 @@ catch (e) {
901
901
  }
902
902
  throw e;
903
903
  }
904
- `),J.set(U,_)}return _(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class QK{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=Z(),J=performance.now()-Y;return this.recordTime($,J),this.checkBudget($,J),X}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=await Z(),J=performance.now()-Y;return this.recordTime($,J),this.checkBudget($,J),X}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let X=Z/Y.maxTime*100,J=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,Q=Z>=Y.maxTime;if(!J&&!Q)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:X,timestamp:new Date,isWarning:J};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=J?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${X.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(X-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let X=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:X?.maxTime,budgetUtilization:X?Y.totalTime/Y.count/X.maxTime*100:void 0}}let Z={};for(let[Y,X]of this.metrics.entries()){let J=this.budgets.get(Y);Z[Y]={count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:J?.maxTime,budgetUtilization:J?X.totalTime/X.count/J.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let X of this.violations)if($[X.label]=($[X.label]||0)+1,X.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function oF(){if(!RZ)RZ=new QK;return RZ}var F6,aF=500,KC,RZ=null,N1;var j4=D(()=>{F6=new Map;KC=new JK;N1=new Proxy({},{get($,Z){return oF()[Z]}})});var w;var s$=D(()=>{w={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});var z8={};t(z8,{resetCrosswindCache:()=>eF,rebuildCrosswindCSS:()=>o$,loadCrosswindConfig:()=>EZ,loadCrosswind:()=>MZ,injectCrosswindCSS:()=>D0,getCachedCSS:()=>ZV,generateCrosswindCSS:()=>B8,extractClassNames:()=>_8,buildCrosswindCSS:()=>R6});import GK from"fs";import z0 from"path";async function KK($){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 tF(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==z0.dirname(Y))$.push(z0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(z0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(z0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),Y=z0.dirname(Y);if(Z){let X=[z0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),z0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),z0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),z0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),z0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),z0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(z0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(z0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function MZ(){if(wZ)return N6;wZ=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await KK(Y);if(X)return N6=X,console.log(`${w.green}[Crosswind]${w.reset} CSS engine loaded`),N6}let Z=tF();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await KK(Y);if(X)return N6=X,console.log(`${w.green}[Crosswind]${w.reset} CSS engine loaded from ${z0.dirname(z0.dirname(Y))}`),N6}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${w.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${w.reset}`),console.warn(`${w.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${w.reset}`),null}}function eF(){N6=null,wZ=!1,b1=null,a$=""}async function EZ($){let Z=null;for(let Y of $V){let X=z0.join($,Y);if(await Bun.file(X).exists()){Z=X;break}}if(!Z)return null;try{let{loadConfigWithResult:Y}=await import("bunfig"),X=await Y({name:"crosswind",cwd:$,defaultConfig:{},verbose:!1});if(X?.config&&Object.keys(X.config).length>0){let J=X.path?z0.relative($,X.path):z0.relative($,Z);return console.log(`${w.green}[Crosswind]${w.reset} Loaded config from ${J||Z}`),X.config}}catch{}try{let Y=await import(Z),X=Y.default||Y,J=z0.relative($,Z);return console.log(`${w.green}[Crosswind]${w.reset} Loaded config from ${J||Z}`),X}catch(Y){return console.warn(`${w.yellow}[Crosswind]${w.reset} Failed to load ${z0.basename(Z)}:`,Y instanceof Error?Y.message:Y),null}}async function R6($){if(A6)return a$;A6=!0;try{let Z=await MZ();if(!Z||!Z.build)return A6=!1,"";if(!b1)b1=await EZ($);if(!b1)return A6=!1,"";let Y=Z.defaultConfig?.theme||{},X=b1.theme||{},J={...Z.defaultConfig,...b1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(a$=G.css,console.log(`${w.cyan}[Crosswind]${w.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let W=z0.isAbsolute(J.output)?J.output:z0.join($,J.output),U=z0.dirname(W);if(!GK.existsSync(U))GK.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return A6=!1,G.css}catch(Z){return console.error(`${w.red}[Crosswind]${w.reset} Build error:`,Z),A6=!1,a$}}async function o$($){b1=null,await R6($)}function ZV(){return a$}function _8($){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 J=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=J.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}Q=J.exec($)}return Z}async function B8($,Z){try{let Y=await MZ();if(!Y)return"";let X=_8($);if(X.size===0)return"";let J=Z?z0.resolve(Z):process.cwd();if(!b1){let F=null;try{let{loadStxConfig:O}=await Promise.resolve().then(() => (u0(),TZ)),V=await O(J);if(V.css)if(typeof V.css==="string"){let N=z0.isAbsolute(V.css)?V.css:z0.resolve(J,V.css);if(await Bun.file(N).exists()){let A=await import(N);F=A.default||A,console.log(`${w.green}[Crosswind]${w.reset} Loaded config from stx.config.ts \u2192 ${V.css}`)}}else{if(F={content:V.css.content||[],preflight:V.css.preflight??!0,minify:V.css.minify??!1},V.css.config){let N=z0.isAbsolute(V.css.config)?V.css.config:z0.resolve(J,V.css.config);if(await Bun.file(N).exists()){let A=await import(N);F={...A.default||A,...F}}}console.log(`${w.green}[Crosswind]${w.reset} Using inline CSS config from stx.config.ts`)}}catch{}b1=F||await EZ(J)}let Q=Y.defaultConfig||Y.config,G=b1||{},K=Q.theme||{},U=(G.theme||{}).extend||{},_={...K};if(Object.keys(U).length>0)_.extend=U;let B=[...Q.safelist||[],...G.safelist||[]],z={...Q,...G,content:[],output:"",preflight:!0,minify:!1,theme:_,safelist:B},q=new Y.CSSGenerator(z);for(let F of B)q.generate(F);for(let F of X)q.generate(F);let j=q.toCSS(!0,!1),H=z.shortcuts||G.shortcuts||{};for(let[F,O]of Object.entries(H)){if(!X.has(F)&&!B.includes(F))continue;let V=O.split(/\s+/).filter(Boolean);for(let N of V)q.generate(N)}j=q.toCSS(!0,!1);let L=j.split(`
904
+ `),J.set(U,_)}return _(...K)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:G,context:Z.slice()});return G}clear(){this.pool.length=0,this.fnCache.clear()}}class QK{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled($){this.enabled=$}isEnabled(){return this.enabled}setBudget($,Z){this.budgets.set($,{warnThreshold:0.8,action:"warn",...Z})}setBudgets($){for(let[Z,Y]of Object.entries($))this.setBudget(Z,Y)}removeBudget($){this.budgets.delete($)}getBudgets(){let $={};for(let[Z,Y]of this.budgets.entries())$[Z]=Y;return $}onViolation($){this.violationHandlers.push($)}offViolation($){let Z=this.violationHandlers.indexOf($);if(Z!==-1)this.violationHandlers.splice(Z,1)}time($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=Z(),J=performance.now()-Y;return this.recordTime($,J),this.checkBudget($,J),X}async timeAsync($,Z){if(!this.enabled)return Z();let Y=performance.now(),X=await Z(),J=performance.now()-Y;return this.recordTime($,J),this.checkBudget($,J),X}checkBudget($,Z){let Y=this.budgets.get($);if(!Y)return;let X=Z/Y.maxTime*100,J=Y.warnThreshold!==void 0?Z>=Y.maxTime*Y.warnThreshold&&Z<Y.maxTime:!1,Q=Z>=Y.maxTime;if(!J&&!Q)return;let G={label:$,actualTime:Z,budgetTime:Y.maxTime,exceedancePercent:X,timestamp:new Date,isWarning:J};this.violations.push(G);while(this.violations.length>this.maxViolations)this.violations.shift();for(let W of this.violationHandlers)try{W(G)}catch{}let K=J?`[Performance Warning] "${$}" took ${Z.toFixed(2)}ms (${X.toFixed(1)}% of ${Y.maxTime}ms budget)`:`[Performance Budget Exceeded] "${$}" took ${Z.toFixed(2)}ms (exceeded ${Y.maxTime}ms budget by ${(X-100).toFixed(1)}%)`;switch(Y.action){case"log":console.log(K);break;case"warn":console.warn(K);break;case"error":console.error(K);break;case"throw":if(Q)throw Error(K);else console.warn(K);break}}recordTime($,Z){let Y=this.metrics.get($);if(Y)Y.count++,Y.totalTime+=Z,Y.maxTime=Math.max(Y.maxTime,Z),Y.minTime=Math.min(Y.minTime,Z);else this.metrics.set($,{count:1,totalTime:Z,maxTime:Z,minTime:Z})}getStats($){if($){let Y=this.metrics.get($);if(!Y)return{};let X=this.budgets.get($);return{count:Y.count,avgTime:Y.totalTime/Y.count,totalTime:Y.totalTime,maxTime:Y.maxTime,minTime:Y.minTime,budget:X?.maxTime,budgetUtilization:X?Y.totalTime/Y.count/X.maxTime*100:void 0}}let Z={};for(let[Y,X]of this.metrics.entries()){let J=this.budgets.get(Y);Z[Y]={count:X.count,avgTime:X.totalTime/X.count,totalTime:X.totalTime,maxTime:X.maxTime,minTime:X.minTime,budget:J?.maxTime,budgetUtilization:J?X.totalTime/X.count/J.maxTime*100:void 0}}return Z}getViolations($){if($)return this.violations.filter((Z)=>Z.label===$);return[...this.violations]}getViolationStats(){let $={},Z=0,Y=0;for(let X of this.violations)if($[X.label]=($[X.label]||0)+1,X.isWarning)Z++;else Y++;return{total:this.violations.length,byLabel:$,warnings:Z,errors:Y}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function oF(){if(!RZ)RZ=new QK;return RZ}var F4,aF=500,KC,RZ=null,N1;var j6=D(()=>{F4=new Map;KC=new JK;N1=new Proxy({},{get($,Z){return oF()[Z]}})});var w;var s$=D(()=>{w={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"}});var z8={};t(z8,{resetCrosswindCache:()=>eF,rebuildCrosswindCSS:()=>o$,loadCrosswindConfig:()=>EZ,loadCrosswind:()=>MZ,injectCrosswindCSS:()=>D0,getCachedCSS:()=>ZV,generateCrosswindCSS:()=>B8,extractClassNames:()=>_8,buildCrosswindCSS:()=>R4});import GK from"fs";import z0 from"path";async function KK($){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 tF(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==z0.dirname(Y))$.push(z0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(z0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(z0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),Y=z0.dirname(Y);if(Z){let X=[z0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),z0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),z0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),z0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),z0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),z0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(z0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(z0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function MZ(){if(wZ)return N4;wZ=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await KK(Y);if(X)return N4=X,console.log(`${w.green}[Crosswind]${w.reset} CSS engine loaded`),N4}let Z=tF();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await KK(Y);if(X)return N4=X,console.log(`${w.green}[Crosswind]${w.reset} CSS engine loaded from ${z0.dirname(z0.dirname(Y))}`),N4}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${w.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${w.reset}`),console.warn(`${w.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${w.reset}`),null}}function eF(){N4=null,wZ=!1,b1=null,a$=""}async function EZ($){let Z=null;for(let Y of $V){let X=z0.join($,Y);if(await Bun.file(X).exists()){Z=X;break}}if(!Z)return null;try{let{loadConfigWithResult:Y}=await import("bunfig"),X=await Y({name:"crosswind",cwd:$,defaultConfig:{},verbose:!1});if(X?.config&&Object.keys(X.config).length>0){let J=X.path?z0.relative($,X.path):z0.relative($,Z);return console.log(`${w.green}[Crosswind]${w.reset} Loaded config from ${J||Z}`),X.config}}catch{}try{let Y=await import(Z),X=Y.default||Y,J=z0.relative($,Z);return console.log(`${w.green}[Crosswind]${w.reset} Loaded config from ${J||Z}`),X}catch(Y){return console.warn(`${w.yellow}[Crosswind]${w.reset} Failed to load ${z0.basename(Z)}:`,Y instanceof Error?Y.message:Y),null}}async function R4($){if(A4)return a$;A4=!0;try{let Z=await MZ();if(!Z||!Z.build)return A4=!1,"";if(!b1)b1=await EZ($);if(!b1)return A4=!1,"";let Y=Z.defaultConfig?.theme||{},X=b1.theme||{},J={...Z.defaultConfig,...b1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(a$=G.css,console.log(`${w.cyan}[Crosswind]${w.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let W=z0.isAbsolute(J.output)?J.output:z0.join($,J.output),U=z0.dirname(W);if(!GK.existsSync(U))GK.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return A4=!1,G.css}catch(Z){return console.error(`${w.red}[Crosswind]${w.reset} Build error:`,Z),A4=!1,a$}}async function o$($){b1=null,await R4($)}function ZV(){return a$}function _8($){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 J=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Q=J.exec($);while(Q!==null){let G=Q[1].match(/'([^']+)'/g);if(G){for(let K of G)for(let W of K.slice(1,-1).split(/\s+/))if(W.trim())Z.add(W.trim())}Q=J.exec($)}return Z}async function B8($,Z){try{let Y=await MZ();if(!Y)return"";let X=_8($);if(X.size===0)return"";let J=Z?z0.resolve(Z):process.cwd();if(!b1){let F=null;try{let{loadStxConfig:O}=await Promise.resolve().then(() => (u0(),TZ)),V=await O(J);if(V.css)if(typeof V.css==="string"){let N=z0.isAbsolute(V.css)?V.css:z0.resolve(J,V.css);if(await Bun.file(N).exists()){let A=await import(N);F=A.default||A,console.log(`${w.green}[Crosswind]${w.reset} Loaded config from stx.config.ts \u2192 ${V.css}`)}}else{if(F={content:V.css.content||[],preflight:V.css.preflight??!0,minify:V.css.minify??!1},V.css.config){let N=z0.isAbsolute(V.css.config)?V.css.config:z0.resolve(J,V.css.config);if(await Bun.file(N).exists()){let A=await import(N);F={...A.default||A,...F}}}console.log(`${w.green}[Crosswind]${w.reset} Using inline CSS config from stx.config.ts`)}}catch{}b1=F||await EZ(J)}let Q=Y.defaultConfig||Y.config,G=b1||{},K=Q.theme||{},U=(G.theme||{}).extend||{},_={...K};if(Object.keys(U).length>0)_.extend=U;let B=[...Q.safelist||[],...G.safelist||[]],z={...Q,...G,content:[],output:"",preflight:!0,minify:!1,theme:_,safelist:B},q=new Y.CSSGenerator(z);for(let F of B)q.generate(F);for(let F of X)q.generate(F);let j=q.toCSS(!0,!1),H=z.shortcuts||G.shortcuts||{};for(let[F,O]of Object.entries(H)){if(!X.has(F)&&!B.includes(F))continue;let V=O.split(/\s+/).filter(Boolean);for(let N of V)q.generate(N)}j=q.toCSS(!0,!1);let L=j.split(`
905
905
  `);for(let[F,O]of Object.entries(H)){if(!X.has(F)&&!B.includes(F))continue;let V=O.split(/\s+/).filter(Boolean),N=[],A=[];for(let R of V){let M=R.startsWith("dark:"),T=`.${(M?R.slice(5):R).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let S=0;S<L.length;S++){let k=L[S].trim();if(k===`${T} {`||k.startsWith(`${T} {`)){let C=S,x="";while(C<L.length){if(x+=L[C],L[C].includes("}"))break;C++}let g=x.match(/\{([^}]+)\}/);if(g)if(M)A.push(g[1].trim());else N.push(g[1].trim());break}}}if(N.length)j+=`
906
906
  .${F} { ${N.join(" ")} }`;if(A.length)j+=`
907
907
  @media (prefers-color-scheme: dark) { .dark .${F} { ${A.join(" ")} } }`}return j}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function D0($,Z){if($.includes('data-crosswind="generated"'))return $;let Y=await B8($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
908
908
  ${Y}
909
909
  </style>`;if($.includes("</head>"))return $.replace("</head>",`${X}
910
910
  </head>`);if($.includes("<body"))return $.replace(/<body([^>]*)>/,`<body$1>
911
- ${X}`);return X+$}var N6=null,wZ=!1,b1=null,a$="",A6=!1,$V;var r1=D(()=>{s$();$V=["crosswind.config.ts","crosswind.config.js","crosswind.config.mjs","crosswind.config.cjs"]});function WK(){return`
911
+ ${X}`);return X+$}var N4=null,wZ=!1,b1=null,a$="",A4=!1,$V;var r1=D(()=>{s$();$V=["crosswind.config.ts","crosswind.config.js","crosswind.config.mjs","crosswind.config.cjs"]});function WK(){return`
912
912
  // STX Lifecycle Runtime
913
913
  (function() {
914
914
  if (typeof window === 'undefined') return;
@@ -1739,7 +1739,7 @@ ${NV()}
1739
1739
  ${Z}
1740
1740
  </script>`}function RK($,Z,Y){if(NK=0,!MV($))return $;let X=OV($);if(X.length===0)return $;let J=wV($,X),Q=RV(X),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
1741
1741
  `+J.slice(G);else J+=Q;return J}function wV($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${q8(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${q8(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*"${q8(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*'${q8(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 MV($){return/x-data\s*=\s*["']/.test($)}var NK=0,LV=0;function s1($,Z){try{let Y=$.trim();if(L0(Y))return F0(Y,Object.keys(Z))(...Object.values(Z));else return M0(Y,Z)}catch{return!1}}var xZ=D(()=>{n0()});function MK($){wK=$}function EK(){return wK}function TK($){j8={...j8,...$}}function IK(){j8={}}function vZ($,Z={}){let Y=j8[$]||EV[$]||{message:`Unknown error (code: ${$})`},X=Y.message,J=Y.help;for(let[Q,G]of Object.entries(Z)){let K=`{{${Q}}}`;if(X=X.replace(new RegExp(K,"g"),G),J)J=J.replace(new RegExp(K,"g"),G)}return{message:X,help:J}}function DK($,Z={}){let{message:Y,help:X}=vZ($,Z);return X?`${Y}
1742
- Help: ${X}`:Y}function H8($){for(let[Z,Y]of Object.entries(e))if(Y===$)return Z;return}var EV,j8,wK="en",e;var L8=D(()=>{EV={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},j8={};e={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function kK(){return!1}function H4(){return!kK()||process.env.STX_DEBUG==="true"}function TV(){return!1}import IV from"path";function bK($){w6={...w6,...$}}function t$(){return{...w6}}function CK(){w6={...SK}}function e$($){if(!w6.showRelativePaths||!$)return $;let Z=w6.baseDir||process.cwd();try{let Y=IV.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var SK,w6,L4,gZ,R1,fZ,M6,$5;var O8=D(()=>{L8();SK={showRelativePaths:!1,enableAutoRecovery:H4(),logRecoveryWarnings:!0},w6={...SK};L4=class L4 extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,Y,X,J,Q,G){super($);this.code=Z;this.filePath=Y;this.line=X;this.column=J;this.context=Q;if(this.name="StxError",this.numericCode=G||e.EVALUATION_ERROR,this.filePath)this.filePath=e$(this.filePath)}};gZ=class gZ extends L4{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||e.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};R1=class R1 extends L4{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||e.EVALUATION_ERROR);this.name="StxRuntimeError"}};fZ=class fZ extends L4{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||e.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};M6=class M6 extends L4{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||e.FILE_NOT_FOUND);this.name="StxFileError"}};$5=class $5 extends L4{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||e.DOM_API_VIOLATION);this.name="StxValidationError"}}});function F8($){let{type:Z,message:Y,code:X,filePath:J,line:Q,column:G,template:K,offset:W,snippet:U,suggestion:_,format:B="text"}=$,z=Q,q=G;if(!z&&K&&W!==void 0){let O=yK(K,W);z=O.line,q=O.column}let j=J?e$(J):void 0,H=X?H8(X):void 0,L={type:Z,code:X,codeName:H,message:Y,filePath:j,line:z,column:q,snippet:U,suggestion:_,timestamp:new Date().toISOString()},F;switch(B){case"html":F=kV(L);break;case"json":F=JSON.stringify(L,null,2);break;case"console":F=SV(L,K,W);break;case"text":default:F=DV(L,K,W);break}return{formatted:F,data:L}}function DV($,Z,Y){let X=[],J=$.code?` [${$.codeName||$.code}]`:"";if(X.push(`[${$.type} Error${J}]`),$.filePath){let Q=$.filePath;if($.line){if(Q+=`:${$.line}`,$.column)Q+=`:${$.column}`}X.push(`at ${Q}`)}if(X.push(`
1742
+ Help: ${X}`:Y}function H8($){for(let[Z,Y]of Object.entries(e))if(Y===$)return Z;return}var EV,j8,wK="en",e;var L8=D(()=>{EV={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},j8={};e={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function kK(){return!1}function H6(){return!kK()||process.env.STX_DEBUG==="true"}function TV(){return!1}import IV from"path";function bK($){w4={...w4,...$}}function t$(){return{...w4}}function CK(){w4={...SK}}function e$($){if(!w4.showRelativePaths||!$)return $;let Z=w4.baseDir||process.cwd();try{let Y=IV.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var SK,w4,L6,gZ,R1,fZ,M4,$5;var O8=D(()=>{L8();SK={showRelativePaths:!1,enableAutoRecovery:H6(),logRecoveryWarnings:!0},w4={...SK};L6=class L6 extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,Y,X,J,Q,G){super($);this.code=Z;this.filePath=Y;this.line=X;this.column=J;this.context=Q;if(this.name="StxError",this.numericCode=G||e.EVALUATION_ERROR,this.filePath)this.filePath=e$(this.filePath)}};gZ=class gZ extends L6{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||e.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};R1=class R1 extends L6{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||e.EVALUATION_ERROR);this.name="StxRuntimeError"}};fZ=class fZ extends L6{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||e.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};M4=class M4 extends L6{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||e.FILE_NOT_FOUND);this.name="StxFileError"}};$5=class $5 extends L6{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||e.DOM_API_VIOLATION);this.name="StxValidationError"}}});function F8($){let{type:Z,message:Y,code:X,filePath:J,line:Q,column:G,template:K,offset:W,snippet:U,suggestion:_,format:B="text"}=$,z=Q,q=G;if(!z&&K&&W!==void 0){let O=yK(K,W);z=O.line,q=O.column}let j=J?e$(J):void 0,H=X?H8(X):void 0,L={type:Z,code:X,codeName:H,message:Y,filePath:j,line:z,column:q,snippet:U,suggestion:_,timestamp:new Date().toISOString()},F;switch(B){case"html":F=kV(L);break;case"json":F=JSON.stringify(L,null,2);break;case"console":F=SV(L,K,W);break;case"text":default:F=DV(L,K,W);break}return{formatted:F,data:L}}function DV($,Z,Y){let X=[],J=$.code?` [${$.codeName||$.code}]`:"";if(X.push(`[${$.type} Error${J}]`),$.filePath){let Q=$.filePath;if($.line){if(Q+=`:${$.line}`,$.column)Q+=`:${$.column}`}X.push(`at ${Q}`)}if(X.push(`
1743
1743
  ${$.message}`),Z&&$.line){let Q=bV(Z,$.line,2);if(Q)X.push(`
1744
1744
  ${Q}`)}if($.snippet)X.push(`
1745
1745
  Snippet: ${$.snippet}`);if($.suggestion)X.push(`
@@ -1769,16 +1769,16 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
1769
1769
  `)}writeToFile($){this.writeQueue=this.writeQueue.then(async()=>{try{let Z=await import("fs"),X=(await import("path")).dirname(this.logFilePath);if(!Z.existsSync(X))Z.mkdirSync(X,{recursive:!0});await this.rotateIfNeeded(Z);let J=`${this.formatEntry($)}
1770
1770
  `;Z.appendFileSync(this.logFilePath,J,"utf-8")}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to write to error log:",Z)}})}async rotateIfNeeded($){try{if(!$.existsSync(this.logFilePath))return;if($.statSync(this.logFilePath).size<this.maxFileSize)return;for(let Y=this.maxLogFiles-1;Y>=1;Y--){let X=`${this.logFilePath}.${Y}`,J=`${this.logFilePath}.${Y+1}`;if($.existsSync(X))if(Y>=this.maxLogFiles-1)$.unlinkSync(X);else $.renameSync(X,J)}if(this.maxLogFiles<=1)$.writeFileSync(this.logFilePath,"");else $.renameSync(this.logFilePath,`${this.logFilePath}.1`)}catch(Z){if(process.env.STX_DEBUG==="true")console.error("Failed to rotate error logs:",Z)}}getRecentErrors($=10){return this.errors.slice(-$)}getErrorsByType($){return this.errors.filter((Z)=>Z.error.constructor.name===$)}getErrorsByLevel($){return this.errors.filter((Z)=>Z.level===$)}clear(){this.errors.length=0}async clearLogFile(){try{let $=await import("fs");if($.existsSync(this.logFilePath))$.writeFileSync(this.logFilePath,"","utf-8")}catch($){if(process.env.STX_DEBUG==="true")console.error("Failed to clear error log:",$)}}getStats(){let $={},Z={error:0,warning:0,info:0};for(let Y of this.errors){let X=Y.error.constructor.name;$[X]=($[X]||0)+1;let J=Y.level||"error";Z[J]=(Z[J]||0)+1}return{total:this.errors.length,byType:$,byLevel:Z}}async exportToFile($,Z="json"){let Y=await import("fs"),J=(await import("path")).dirname($);if(!Y.existsSync(J))Y.mkdirSync(J,{recursive:!0});if(Z==="json"){let Q=this.errors.map((G)=>({timestamp:G.timestamp.toISOString(),level:G.level||"error",type:G.error.constructor.name,message:G.error.message,stack:G.error.stack,context:G.context}));Y.writeFileSync($,JSON.stringify(Q,null,2),"utf-8")}else{let Q=this.errors.map((G)=>this.formatEntry(G));Y.writeFileSync($,Q.join(`
1771
1771
 
1772
- `),"utf-8")}}async flush(){await this.writeQueue}}var V8,q1,E6;var hK=D(()=>{O8();V8={isEnabled(){return t$().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=t$();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let Y=$,X=[],J=(Y.match(/\{\{/g)||[]).length,Q=(Y.match(/\}\}/g)||[]).length;if(J>Q){let K=J-Q;Y+="}}".repeat(K),X.push(`Added ${K} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let K of G){let W=(Y.match(new RegExp(`@${K}\\b`,"g"))||[]).length,U=(Y.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(W>U){let _=W-U;for(let B=0;B<_;B++)Y+=`
1773
- @end${K}`;X.push(`Added ${_} missing @end${K}`)}}if(X.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),X.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:X}},createFallbackContent($,Z){if(H4())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};q1=new A8,E6={isDevelopment(){return H4()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
1772
+ `),"utf-8")}}async flush(){await this.writeQueue}}var V8,q1,E4;var hK=D(()=>{O8();V8={isEnabled(){return t$().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=t$();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let Y=$,X=[],J=(Y.match(/\{\{/g)||[]).length,Q=(Y.match(/\}\}/g)||[]).length;if(J>Q){let K=J-Q;Y+="}}".repeat(K),X.push(`Added ${K} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let K of G){let W=(Y.match(new RegExp(`@${K}\\b`,"g"))||[]).length,U=(Y.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(W>U){let _=W-U;for(let B=0;B<_;B++)Y+=`
1773
+ @end${K}`;X.push(`Added ${_} missing @end${K}`)}}if(X.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),X.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:X}},createFallbackContent($,Z){if(H6())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};q1=new A8,E4={isDevelopment(){return H6()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
1774
1774
  `)}}});import hZ from"path";function PV($){let Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function Z5($,Z={}){let{allowHtml:Y=!1,maxLength:X=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],K=$,W=!1;if(Q){let _=Q(K);if(_!==K)K=_,W=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),W=!0,G.push("Null bytes removed from parameter");if(K.length>X)K=K.substring(0,X),W=!0,G.push(`Parameter truncated to ${X} characters`);if(!Y&&/<[^>]+>/.test(K))K=PV(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:_,replacement:B,name:z}of U)if(_.test(K))K=K.replace(_,B),W=!0,G.push(`Removed ${z} from parameter`);if(!J){let _=K;if(K=K.split("").filter((B)=>{let z=B.charCodeAt(0);return z>=32&&z!==127}).join(""),K!==_)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function dK($,Z){let Y=$.replace(/\0/g,"");Y=Y.replace(/\\/g,"/"),Y=Y.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Y.includes("../")||Y.includes("./"))Y=Y.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!N8.isValidFilePath(Y,Z))return null;return Y}function mK($){let Z=[],Y=$.trim(),X=Y!==$,J=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of J)if(Q.test(Y))Z.push(`Potentially dangerous pattern detected: ${G}`);if(Y.includes("\x00"))Y=Y.replace(/\0/g,""),X=!0,Z.push("Null bytes removed from expression");return{value:Y,modified:X,warnings:Z}}function uK($,Z={}){return $.map((Y)=>Z5(Y,Z))}function dZ($){let Z={};for(let[Y,X]of Object.entries($)){if(!N8.isValidVariableName(Y))continue;if(typeof X==="string"){let J=Z5(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?Z5(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=dZ(X);else Z[Y]=X}return Z}var N8;var cK=D(()=>{N8={isValidFilePath($,Z){let Y=$.replace(/\\/g,"/");if(Y.includes("\x00"))return!1;if(Y.includes("../")||Y.includes("..\\")||Y===".."||Y.startsWith("../")||Y.endsWith("/..")||Y.includes("/..\\")||Y.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Y))return!1;if(Y.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>Y===Q.slice(0,-1)||Y.startsWith(Q)))return!1}if(/^[a-z]:/i.test(Y)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>Y.includes(Q)))return!1}if(Z){let J=hZ.resolve(Z,$),Q=hZ.resolve(Z);if(!J.startsWith(Q+hZ.sep)&&J!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Y)=>Y.test($))}}});var lK=D(()=>{L8();fK();hK();cK();O8()});var _1=D(()=>{lK()});class Y5{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,Y=this.column,X=this.source[this.pos];if(/\s/.test(X))return this.readWhitespace($,Z,Y);if(X==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(X==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(X==='"'||X==="'")return this.readString(X,$,Z,Y);if(X==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(X)||X==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(X))return this.readIdentifier($,Z,Y);if(X==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(X==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(X==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(X==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(X))return this.advance(),{type:"OPERATOR",value:X,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(X))return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
1775
1775
  `)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readBlockComment($,Z,Y){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readString($,Z,Y,X){this.advance();while(this.pos<this.source.length){let J=this.source[this.pos];if(J==="\\"){this.advance(2);continue}if(J===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:Y,column:X}}readTemplateString($,Z,Y){this.advance();let X=0,J=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(X>=J){this.pos=this.source.length;break}this.advance(2),X++;continue}if(Q==="{"&&X>0){X++,this.advance();continue}if(Q==="}"&&X>0){X--,this.advance();continue}if(Q==="`"&&X===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readNumber($,Z,Y){if(this.source[this.pos]==="0"){let X=this.peek(1)?.toLowerCase();if(X==="x"||X==="o"||X==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readIdentifier($,Z,Y){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readDirective($,Z,Y){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
1776
- `)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function v0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function mZ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function R8($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function a1($,Z){let Y=yV($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function yV($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=v0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function O4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,B=U?U.index:1/0;if(_<B)J++,Q=_+W[0].length;else if(B<1/0){if(J--,J===0)return B;Q=B+U[0].length}else break}return-1}function uZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=a1($,X);if(!J)return null;let Q=J.endPos,G=O4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",B=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let L=H.match(/^@elseif\s*/);if(L){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+L[0].length,O=a1(K,F);if(!O){U++;continue}_="elseif",B=O.expression,U=O.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U}),_="else",B=void 0,U+=5,z=U;continue}}U++}return W.push({type:_,condition:B,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function w8($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=uZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X5($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=v0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),B=U+1,z=O4($,Z,Y,B);if(z===-1){Q=J.exec($);continue}let q=$.slice(B,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function M8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=a1($,X);if(!J)return null;let Q=J.endPos,G=O4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,B=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(B++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(B--,_)_.content+=j[0];U+=j[0].length;continue}if(B>0){if(_)_.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),L=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(_)W.push(_);let O=U+H[0].length,V=a1(K,O);if(!V){U++;continue}_={type:"case",value:V.expression,content:""},U=V.endPos}else if(L&&z.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=L[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var pK=()=>{};function rK($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=xV($,U,W);if(_===-1){Y=G+1;continue}let B=$.slice(U,_).trim(),z=_+W.length;Z.push({fullMatch:$.slice(G,z),expression:B,start:G,end:z,isRaw:Q}),Y=z}return Z}function xV($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function sK($){let Z=R8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=vV(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function vV($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=v0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=cZ(G);return{name:X,args:K}}function cZ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function aK($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=v0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function oK($){let Z=[],X=new Y5($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let B=J<X.length?X[J].start:$.length,z=iK(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:_,value:$.slice(B,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,B=U.value==="{"?"}":"]",z=v0($,U.value,B,_);if(z!==-1){let q=$.slice(_,z+1);if(J=nK(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=iK(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let B=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){B=X[J].start;break}J++}if(B!==-1){let z=v0($,"{","}",B);if(z!==-1)Z.push({type:"function",name:_,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=nK(X,z+1)}}}else J++}return Z}function iK($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function nK($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var tK=()=>{};var E8=D(()=>{pK();tK()});function gV($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=M8(X,G);if(!K)break;try{let W;if(L0(K.expression))W=F0(K.expression,Object.keys(Z))(...Object.values(Z));else W=M0(K.expression,Z);let U="",_=!1;for(let B of K.cases)if(B.type==="default"){if(!_)U=B.content.trim()}else try{let z;if(B.value&&L0(B.value))z=F0(B.value,Object.keys(Z))(...Object.values(Z));else if(B.value)z=M0(B.value,Z);if(W===z){U=B.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=G0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function T6($,Z,Y){let X=$;X=gV(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=a1(X,K+7);if(!W)break;let U=W.endPos,_=O4(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let B=X.slice(U,_),z=W.expression,q=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],N;while((N=L.exec(B))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(B))!==null)V.push({pos:N.index,type:"close"});while((N=O.exec(B))!==null)V.push({pos:N.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){q=A.pos;break}}let j;if(q!==-1){let H=B.slice(0,q),L=B.slice(q+5);j=`@if (${z})${L}@else ${H}@endif`}else j=`@if (!(${z}))${B}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=pZ(X,Z,Y),X=iZ(X,Z,Y),X=lZ(X,Z);let J=()=>{let Q=w8(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let B;if(_.condition&&L0(_.condition))B=F0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)B=M0(_.condition,Z);if(B)W=_.content,U=!0}catch(B){W=G0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${B instanceof Error?B.message:String(B)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=G0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(J());return X}function eK($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function lZ($,Z){let Y=$;function X(K,W,U,_){let B=1,z=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&B>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)B++,z=F+H[0].length;else if(O<1/0){if(B--,B===0)return O;z=O+L[0].length}else break}return-1}function J(K,W,U){let _=0,B=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=B.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")_++;else if(L.type==="close")_--;else if(L.type==="else"&&_===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+5),q=eK(z);if(q)_=q.value,B=U+5+q.consumed;else B=U+5;let j=X(Y,"auth","endauth",B);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(B,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=_?s1(`auth?.check && auth?.user?.[${_}]`,Z):s1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),N=H.slice(L+5);O=F?V:N}else O=F?H:"";Y=Y.substring(0,U)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+6),q=eK(z);if(q)_=q.value,B=U+6+q.consumed;else B=U+6;let j=X(Y,"guest","endguest",B);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(B,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=_?s1(`!auth?.check || !auth?.user?.[${_}]`,Z):s1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),N=H.slice(L+5);O=F?V:N}else O=F?H:"";Y=Y.substring(0,U)+O+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let B=s1(U,Z);_.push(B)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let B=Y.match(new RegExp(`@${K}\\s*\\(`));if(!B||B.index===void 0)break;let z=B.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,L=X(Y,K,W,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),R=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,E=[],I;while((I=N.exec(F))!==null)E.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)E.push({pos:I.index,type:"close"});while((I=R.exec(F))!==null)E.push({pos:I.index,type:"elseDirective"});while((I=M.exec(F))!==null)E.push({pos:I.index,type:"else"});E.sort((g,P)=>g.pos-P.pos);for(let g of E){if(g.type==="open"){V++;continue}if(g.type==="close"){V--;continue}if(V===0)O.push(g)}let T=[],S=0;for(let g=0;g<O.length;g++){let P=O[g];if(T.push({content:F.slice(S,P.pos),ability:void 0}),P.type==="elseDirective"){let f=F.slice(P.pos+`@${U}`.length),h=G(f);if(h){T[T.length-1]={content:F.slice(S,P.pos)},S=P.pos+`@${U}`.length+h.paramsEnd,T.push({content:"",ability:h.ability,type:h.type,id:h.id}),T.pop();let u=O[g+1],l=u?u.pos:F.length;T.push({content:F.slice(S,l),ability:h.ability,type:h.type,id:h.id}),S=l}}else S=P.pos+5}if(S<F.length){let g=T[T.length-1];if(O.length>0&&O[O.length-1].type==="else")T.push({content:F.slice(S),isFinalElse:!0});else if(T.length===0)T.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),C=K==="can"?k:!k,x="";if(C)x=T[0]?.content||"";else{let g=!1;for(let P=1;P<T.length;P++){let f=T[P];if(f.isFinalElse){x=f.content,g=!0;break}if(f.ability){let h=Q(f.ability,f.type,f.id);if(K==="can"?h:!h){x=f.content,g=!0;break}}}if(!g&&T.length>0){let P=T[T.length-1];if(P.isFinalElse)x=P.content}}Y=Y.substring(0,z)+x+Y.substring(L+`@${W}`.length),_=!0}}return Y}function pZ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let B=new RegExp(`@${G}\\s*\\(`),z=Q.match(B);if(!z||z.index===void 0)break;let q=z.index,j=a1(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,L=O4(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,N=0,A=0;while(A<F.length){let R=F.indexOf("@",A);if(R===-1)break;let M=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){N++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){N--,A=R+1;continue}if(N===0&&/^@else(?![a-z])/.test(M)){V=R;break}A=R+1}try{let R=W(O.trim()),M;if(V!==-1){let E=F.slice(0,V),I=F.slice(V+5);M=R?E:I}else M=R?F:"";Q=Q.substring(0,q)+M+Q.substring(L+`@${K}`.length),_=!0}catch(R){let M=R instanceof Error?R.message:String(R),E=G0(U,`Error processing @${G} directive: ${M}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=s1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=s1(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function iZ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),B=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let L=_.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let k=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;O+=k[0].length,U=J===k[2]}let V=1,N=O,A=-1;while(V>0&&N<j.length){_.lastIndex=N,B.lastIndex=N;let k=_.exec(j),C=B.exec(j),x=k?k.index:1/0,g=C?C.index:1/0;if(x<g)V++,N=x+k[0].length;else if(g<1/0){if(V--,V===0){A=g;break}N=g+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let R=j.substring(O,A),M=-1,E=0,I=0;while(I<R.length){let k=R.indexOf("@",I);if(k===-1)break;let C=R.substring(k);if(z.test(C)){E++,I=k+1;continue}if(q.test(C)){E--,I=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(C)){M=k;break}I=k+1}let T;if(M!==-1){let k=R.slice(0,M),C=R.slice(M+5);T=U?k:C}else T=U?R:"";let S=`@${W}`.length;j=j.substring(0,F)+T+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var T8=D(()=>{xZ();_1();E8();n0()});function rZ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function F4($,Z){if(!$)return Z?.nonceGenerator?.()??rZ();let Y=nZ.get($);if(!Y)Y=Z?.nonceGenerator?.()??rZ(),nZ.set($,Y);return Y}function fV($){nZ.delete($)}function sZ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function D8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${sZ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function hV($){return{enabled:!0,directives:{strict:$W,moderate:I8,relaxed:ZW,api:YW}[$]||I8,useNonce:$==="strict",addMetaTag:!0}}function dV($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function aZ($,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?F4(Y,Z):void 0,J=D8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1777
- ${J}`)}function mV($,Z){let Y=$;return Y=Y.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<script nonce="${Z}"${J}>`}),Y=Y.replace(/<style([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<style nonce="${Z}"${J}>`}),Y}function oZ($,Z,Y,X){let J=$,Q=X.csp;if(J=J.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?F4(Z,Q):void 0;return D8(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return F4(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=F4(Z,Q);return J}function uV(){return[XW,JW]}function cV($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,X]of Object.entries($))if(Array.isArray(X)&&X.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function QW($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function lV($,Z){if(!$.enabled)return{};let Y=$.useNonce?F4(Z,$):void 0,X=sZ($.directives,Y);return{[QW($.reportOnly)]:X}}var nZ,$W,I8,ZW,YW,XW,JW,pV;var tZ=D(()=>{nZ=new WeakMap;$W={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},I8={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},ZW={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},YW={"default-src":["'none'"],"frame-ancestors":["'none'"]};XW={name:"csp",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?F4(Y,Q):void 0;return D8(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},JW={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return F4(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};pV={enabled:!1,reportOnly:!1,directives:I8,useNonce:!1,addMetaTag:!0}});import iV from"crypto";function rV($=nV){let Z=iV.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return eZ=Z,Z}function sV(){if(!eZ)rV();return eZ}function aV($=GW){let Z=sV();return`<input type="hidden" name="${$}" value="${Z}">`}function KW($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return aV(X||GW)})}var nV=40,GW="_token",eZ=null;var WW=()=>{};async function $2($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let J=$;for(let Q of X.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await oV(J,Q,Z,Y,X);else J=await tV(J,Q,Z,Y,X)}return J}async function oV($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=V6(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),B=[],z=_.exec(U);while(z!==null){let[q,j="",H=""]=z,L=z.index||0;try{let F=j?UW(j):[],O=H.trim(),V=await G(O,F,Y,X);B.push({original:q,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);B.push({original:q,processed:G0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,e.EVALUATION_ERROR),startIndex:L})}z=_.exec(U)}for(let q=B.length-1;q>=0;q--){let{original:j,processed:H}=B[q];U=U.replace(j,H)}return U}async function tV($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=V6(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let L=UW(j),F=await G("",L,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);U.push({original:q,processed:G0("CustomDirective",`Error in @${Q}(${j}): ${F}`,e.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let B=V6(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),z=B.exec(K);while(z!==null){let[q]=z,j=z.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:G0("CustomDirective",`Error in @${Q}: ${L}`,e.EVALUATION_ERROR),startIndex:j})}z=B.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function UW($){if(!$.trim())return[];let Z=[],Y="",X=!1,J="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!X)X=!0,J=G;else if(G===J)X=!1;else Y+=G;else if(G===","&&!X)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var Z2=D(()=>{_1();j4()});var b8={};t(b8,{useTitle:()=>zW,useSeoMeta:()=>J5,usePageTitle:()=>zW,useHead:()=>A4,resetHead:()=>_W,renderHtmlAttrs:()=>jW,renderHead:()=>qW,renderBodyAttrs:()=>HW,processTitleDirective:()=>FW,processMetaDirective:()=>VW,processHeadDirective:()=>OW,getPageMeta:()=>S8,getHead:()=>I6,definePageMeta:()=>BW,applyHead:()=>LW});function I6(){return V4}function S8(){return k8}function _W(){V4={},eV.length=0,k8={}}function A4($){V4=$A(V4,$)}function $A($,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 J5($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});A4({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function BW($){if(k8={...k8,...$},$.title||$.description)J5({title:$.title,description:$.description})}function zW($){let Z=typeof $==="function"?$():$;A4({title:Z})}function qW($=V4){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${n4(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${n4(J)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>{return`${J==="httpEquiv"?"http-equiv":J}="${n4(String(Q))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>`${J}="${n4(String(Q))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...J}=Y,Q=Object.entries(J).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${n4(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
1778
- `)}function jW($=V4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${n4(Y)}"`).join(" ")}function HW($=V4){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${n4(Y)}"`).join(" ")}function n4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function LW($=V4){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let X=document.querySelector(Y);if(!X){if(X=document.createElement("meta"),Z.name)X.setAttribute("name",Z.name);if(Z.property)X.setAttribute("property",Z.property);document.head.appendChild(X)}X.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,X=document.querySelector(Y);if(!X)X=document.createElement("link"),document.head.appendChild(X);for(let[J,Q]of Object.entries(Z))if(Q!==void 0)X.setAttribute(J,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function OW($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
1779
- `,""}),headContent:Z.trim()}}function FW($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return A4({title:G}),""})}function VW($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,B=J.includes(":")?{property:J,content:U}:{name:J,content:U};return A4({meta:[B]}),""})}var V4,eV,k8;var N4=D(()=>{V4={},eV=[],k8={}});import ZA from"crypto";function c0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function YA($){return{...P8,...$.forms?.classes}}function C8($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function XA(){return ZA.randomUUID()}function JA($,Z,Y,X){let J=YA(X),Q=$;return Q=wW(Q,Z),Q=D6(Q,Z),Q=y8(Q,Z,J),Q=x8(Q,Z,J),Q}function D6($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=XA();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${c0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${c0(Q)}">`;return X}),Y}function y8($,Z,Y=P8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"POST",B=K||W||"",z=R4(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${c0(j)}" action="${c0(B)}"${z?` ${z}`:""}>`;if(H+=`
1780
- ${D6("@csrf",Z)}`,!["GET","POST"].includes(q))H+=`
1781
- ${D6(`@method('${q}')`,Z)}`;return H}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"",B=K||W||"",z=R4(U),q=Q5(_,Z),j=q!==void 0&&q!==null?q:B||"",H=z.match(/type=['"]([^'"]+)['"]/i),L=H?H[1]:"text",F=G5(_,Z),O=z.match(/class=['"]([^'"]+)['"]/i),V=C8(O?O[1]:"",Y.input,F,Y.inputError),N=z.replace(/class=['"][^'"]+['"]/i,"");return N=N.replace(/type=['"][^'"]+['"]/i,""),`<input type="${c0(L)}" name="${c0(_)}" value="${c0(j)}" class="${V}"${N?` ${N}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let W=R4(G),U=Q5(Q,Z)||K.trim(),_=G5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=C8(B?B[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${c0(Q)}" class="${z}"${q?` ${q}`:""}>${c0(U)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(J,Q,G="",K)=>{let W=R4(G),U=Q5(Q,Z),_=G5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=C8(B?B[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,""),j=K;if(U!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,L,F)=>{if((Array.isArray(U)?U.some((V)=>String(V)===F):String(U)===F)&&!L.includes("selected"))return L.replace(/(<option)/,"$1 selected");return H});return`<select name="${c0(Q)}" class="${z}"${q?` ${q}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="1",K="")=>{let W=R4(K),U=Q5(Q,Z),_=U!==void 0&&(Array.isArray(U)?U.some((j)=>String(j)===G):U===!0||String(U)===G),B=W.match(/class=['"]([^'"]+)['"]/i),z=B?B[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${c0(Q)}" value="${c0(G)}" class="${z}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,K="")=>{let W=R4(K),U=Q5(Q,Z),_=U!==void 0&&U===G,B=W.match(/class=['"]([^'"]+)['"]/i),z=B?B[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${c0(Q)}" value="${c0(G)}" class="${z}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="")=>{let K=R4(G),W=K.match(/accept=['"]([^'"]+)['"]/i),U=W?W[1]:"",_=K.includes("multiple"),B=G5(Q,Z),z=K.match(/class=['"]([^'"]+)['"]/i),q=C8(z?z[1]:"",Y.input,B,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${c0(Q)}"`,`class="${q}"`];if(U)H.push(`accept="${c0(U)}"`);if(_)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(J,Q,G="",K)=>{let W=R4(G),U=W.match(/class=['"]([^'"]+)['"]/i),_=U?U[1]:Y.label,B=W.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${c0(Q)}" class="${_}"${B?` ${B}`:""}>${K}</label>`}),X}function x8($,Z,Y=P8){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(G5(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return AW(J,Z);if(K.trim().includes("errors.first")||K.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(J);return AW(J,Z)}let W=K.trim();if(L0(W)){let U=M0(W,Z);return U!==void 0?String(U):W}return W}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),X}})}function G5($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function AW($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let Y=Z.errors[$];return Array.isArray(Y)?Y[0]:String(Y)}return""}function Q5($,Z){let Y;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let X=$.slice(0,-2);if(Y=Z[X],Y!==void 0)return Y}return Z[$]}function R4($){if(!$.trim())return"";let Z=[],Y=$.trim(),X=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,J;while((J=X.exec(Y))!==null){let[,Q,,G]=J;Z.push(`${Q}="${G.trim()}"`)}return Z.join(" ")}function QA($,Z){NW[$]=Z}function Y2($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function RW($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=Y2(G),W=NW[K.name];if(!W){console.warn(`Unknown validation rule: ${K.name}`);continue}if(K.name==="confirmed"){let _=`${$}_confirmation`;K.params=[X[_]]}let U=W(Z,K.params||[],$);if(U)J.push(K.message||U)}return{field:$,valid:J.length===0,errors:J}}function GA($,Z){let Y={};for(let[X,J]of Object.entries(Z)){let Q=RW(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function wW($,Z){return $.replace(/@validate\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]*)\})?\s*\)/g,(Y,X,J,Q)=>{let G=J.split("|").map((W)=>W.trim()),K=[];for(let W of G){let U=Y2(W);switch(U.name){case"required":K.push("required");break;case"email":K.push('type="email"');break;case"url":K.push('type="url"');break;case"numeric":case"integer":if(K.push('type="number"'),U.name==="integer")K.push('step="1"');break;case"min":if(U.params?.[0])K.push(`minlength="${U.params[0]}"`);break;case"max":if(U.params?.[0])K.push(`maxlength="${U.params[0]}"`);break;case"regex":if(U.params?.[0])K.push(`pattern="${U.params[0]}"`);break}}return`<!-- @validate:${X}:${J} -->${K.length>0?`<!-- attrs:${K.join(" ")} -->`:""}`})}function KA($){X2[$.name]=$}function MW($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=Y2(Q),K=X2[G.name];if(!K){console.warn(`Unknown validation rule: ${G.name}`);continue}let W=K.validate($,G.params||[],Y);if(W!==!0)X.push(W)}return{valid:X.length===0,errors:X}}function WA($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=MW($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function UA($,Z){let Y=JSON.stringify(Z);return`
1776
+ `)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function v0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function mZ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function R8($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function a1($,Z){let Y=yV($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function yV($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=v0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function O6($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,B=U?U.index:1/0;if(_<B)J++,Q=_+W[0].length;else if(B<1/0){if(J--,J===0)return B;Q=B+U[0].length}else break}return-1}function uZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=a1($,X);if(!J)return null;let Q=J.endPos,G=O6($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",B=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let L=H.match(/^@elseif\s*/);if(L){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+L[0].length,O=a1(K,F);if(!O){U++;continue}_="elseif",B=O.expression,U=O.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U}),_="else",B=void 0,U+=5,z=U;continue}}U++}return W.push({type:_,condition:B,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function w8($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=uZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X5($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=v0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),B=U+1,z=O6($,Z,Y,B);if(z===-1){Q=J.exec($);continue}let q=$.slice(B,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function M8($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=a1($,X);if(!J)return null;let Q=J.endPos,G=O6($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,B=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(B++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(B--,_)_.content+=j[0];U+=j[0].length;continue}if(B>0){if(_)_.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),L=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(_)W.push(_);let O=U+H[0].length,V=a1(K,O);if(!V){U++;continue}_={type:"case",value:V.expression,content:""},U=V.endPos}else if(L&&z.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=L[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var pK=()=>{};function rK($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,_=xV($,U,W);if(_===-1){Y=G+1;continue}let B=$.slice(U,_).trim(),z=_+W.length;Z.push({fullMatch:$.slice(G,z),expression:B,start:G,end:z,isRaw:Q}),Y=z}return Z}function xV($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function sK($){let Z=R8($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=vV(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function vV($){let Z=$.trim();if(!Z)return null;let Y=Z.indexOf("(");if(Y===-1)return{name:Z,args:[]};let X=Z.slice(0,Y).trim(),J=Y+1,Q=v0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=cZ(G);return{name:X,args:K}}function cZ($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+="${",G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K===","&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function aK($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=v0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function oK($){let Z=[],X=new Y5($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let B=J<X.length?X[J].start:$.length,z=iK(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:_,value:$.slice(B,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,B=U.value==="{"?"}":"]",z=v0($,U.value,B,_);if(z!==-1){let q=$.slice(_,z+1);if(J=nK(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=iK(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${L}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let B=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){B=X[J].start;break}J++}if(B!==-1){let z=v0($,"{","}",B);if(z!==-1)Z.push({type:"function",name:_,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=nK(X,z+1)}}}else J++}return Z}function iK($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function nK($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var tK=()=>{};var E8=D(()=>{pK();tK()});function gV($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=M8(X,G);if(!K)break;try{let W;if(L0(K.expression))W=F0(K.expression,Object.keys(Z))(...Object.values(Z));else W=M0(K.expression,Z);let U="",_=!1;for(let B of K.cases)if(B.type==="default"){if(!_)U=B.content.trim()}else try{let z;if(B.value&&L0(B.value))z=F0(B.value,Object.keys(Z))(...Object.values(Z));else if(B.value)z=M0(B.value,Z);if(W===z){U=B.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=G0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function T4($,Z,Y){let X=$;X=gV(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=a1(X,K+7);if(!W)break;let U=W.endPos,_=O6(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let B=X.slice(U,_),z=W.expression,q=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],N;while((N=L.exec(B))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(B))!==null)V.push({pos:N.index,type:"close"});while((N=O.exec(B))!==null)V.push({pos:N.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){q=A.pos;break}}let j;if(q!==-1){let H=B.slice(0,q),L=B.slice(q+5);j=`@if (${z})${L}@else ${H}@endif`}else j=`@if (!(${z}))${B}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=pZ(X,Z,Y),X=iZ(X,Z,Y),X=lZ(X,Z);let J=()=>{let Q=w8(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let B;if(_.condition&&L0(_.condition))B=F0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)B=M0(_.condition,Z);if(B)W=_.content,U=!0}catch(B){W=G0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${B instanceof Error?B.message:String(B)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=G0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(J());return X}function eK($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function lZ($,Z){let Y=$;function X(K,W,U,_){let B=1,z=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&B>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)B++,z=F+H[0].length;else if(O<1/0){if(B--,B===0)return O;z=O+L[0].length}else break}return-1}function J(K,W,U){let _=0,B=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=B.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")_++;else if(L.type==="close")_--;else if(L.type==="else"&&_===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+5),q=eK(z);if(q)_=q.value,B=U+5+q.consumed;else B=U+5;let j=X(Y,"auth","endauth",B);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(B,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=_?s1(`auth?.check && auth?.user?.[${_}]`,Z):s1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),N=H.slice(L+5);O=F?V:N}else O=F?H:"";Y=Y.substring(0,U)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+6),q=eK(z);if(q)_=q.value,B=U+6+q.consumed;else B=U+6;let j=X(Y,"guest","endguest",B);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(B,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=_?s1(`!auth?.check || !auth?.user?.[${_}]`,Z):s1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),N=H.slice(L+5);O=F?V:N}else O=F?H:"";Y=Y.substring(0,U)+O+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let B=s1(U,Z);_.push(B)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let B=Y.match(new RegExp(`@${K}\\s*\\(`));if(!B||B.index===void 0)break;let z=B.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,L=X(Y,K,W,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),R=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,E=[],I;while((I=N.exec(F))!==null)E.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)E.push({pos:I.index,type:"close"});while((I=R.exec(F))!==null)E.push({pos:I.index,type:"elseDirective"});while((I=M.exec(F))!==null)E.push({pos:I.index,type:"else"});E.sort((g,P)=>g.pos-P.pos);for(let g of E){if(g.type==="open"){V++;continue}if(g.type==="close"){V--;continue}if(V===0)O.push(g)}let T=[],S=0;for(let g=0;g<O.length;g++){let P=O[g];if(T.push({content:F.slice(S,P.pos),ability:void 0}),P.type==="elseDirective"){let f=F.slice(P.pos+`@${U}`.length),h=G(f);if(h){T[T.length-1]={content:F.slice(S,P.pos)},S=P.pos+`@${U}`.length+h.paramsEnd,T.push({content:"",ability:h.ability,type:h.type,id:h.id}),T.pop();let u=O[g+1],l=u?u.pos:F.length;T.push({content:F.slice(S,l),ability:h.ability,type:h.type,id:h.id}),S=l}}else S=P.pos+5}if(S<F.length){let g=T[T.length-1];if(O.length>0&&O[O.length-1].type==="else")T.push({content:F.slice(S),isFinalElse:!0});else if(T.length===0)T.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),C=K==="can"?k:!k,x="";if(C)x=T[0]?.content||"";else{let g=!1;for(let P=1;P<T.length;P++){let f=T[P];if(f.isFinalElse){x=f.content,g=!0;break}if(f.ability){let h=Q(f.ability,f.type,f.id);if(K==="can"?h:!h){x=f.content,g=!0;break}}}if(!g&&T.length>0){let P=T[T.length-1];if(P.isFinalElse)x=P.content}}Y=Y.substring(0,z)+x+Y.substring(L+`@${W}`.length),_=!0}}return Y}function pZ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let B=new RegExp(`@${G}\\s*\\(`),z=Q.match(B);if(!z||z.index===void 0)break;let q=z.index,j=a1(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,L=O6(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=j.expression,V=-1,N=0,A=0;while(A<F.length){let R=F.indexOf("@",A);if(R===-1)break;let M=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){N++,A=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){N--,A=R+1;continue}if(N===0&&/^@else(?![a-z])/.test(M)){V=R;break}A=R+1}try{let R=W(O.trim()),M;if(V!==-1){let E=F.slice(0,V),I=F.slice(V+5);M=R?E:I}else M=R?F:"";Q=Q.substring(0,q)+M+Q.substring(L+`@${K}`.length),_=!0}catch(R){let M=R instanceof Error?R.message:String(R),E=G0(U,`Error processing @${G} directive: ${M}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=s1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=s1(Q,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),X}function iZ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),B=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let L=_.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let k=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;O+=k[0].length,U=J===k[2]}let V=1,N=O,A=-1;while(V>0&&N<j.length){_.lastIndex=N,B.lastIndex=N;let k=_.exec(j),C=B.exec(j),x=k?k.index:1/0,g=C?C.index:1/0;if(x<g)V++,N=x+k[0].length;else if(g<1/0){if(V--,V===0){A=g;break}N=g+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let R=j.substring(O,A),M=-1,E=0,I=0;while(I<R.length){let k=R.indexOf("@",I);if(k===-1)break;let C=R.substring(k);if(z.test(C)){E++,I=k+1;continue}if(q.test(C)){E--,I=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(C)){M=k;break}I=k+1}let T;if(M!==-1){let k=R.slice(0,M),C=R.slice(M+5);T=U?k:C}else T=U?R:"";let S=`@${W}`.length;j=j.substring(0,F)+T+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var T8=D(()=>{xZ();_1();E8();n0()});function rZ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function F6($,Z){if(!$)return Z?.nonceGenerator?.()??rZ();let Y=nZ.get($);if(!Y)Y=Z?.nonceGenerator?.()??rZ(),nZ.set($,Y);return Y}function fV($){nZ.delete($)}function sZ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function D8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${sZ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function hV($){return{enabled:!0,directives:{strict:$W,moderate:I8,relaxed:ZW,api:YW}[$]||I8,useNonce:$==="strict",addMetaTag:!0}}function dV($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function aZ($,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?F6(Y,Z):void 0,J=D8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1777
+ ${J}`)}function mV($,Z){let Y=$;return Y=Y.replace(/<script(?![^>]*\ssrc=)([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<script nonce="${Z}"${J}>`}),Y=Y.replace(/<style([^>]*)>/gi,(X,J)=>{if(J.includes("nonce="))return X;return`<style nonce="${Z}"${J}>`}),Y}function oZ($,Z,Y,X){let J=$,Q=X.csp;if(J=J.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?F6(Z,Q):void 0;return D8(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return F6(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=F6(Z,Q);return J}function uV(){return[XW,JW]}function cV($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,X]of Object.entries($))if(Array.isArray(X)&&X.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function QW($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function lV($,Z){if(!$.enabled)return{};let Y=$.useNonce?F6(Z,$):void 0,X=sZ($.directives,Y);return{[QW($.reportOnly)]:X}}var nZ,$W,I8,ZW,YW,XW,JW,pV;var tZ=D(()=>{nZ=new WeakMap;$W={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},I8={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},ZW={"default-src":["'self'"],"script-src":["'self'","'unsafe-inline'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:","http:"],"font-src":["'self'","https:","http:","data:"],"connect-src":["'self'","https:","http:","ws:","wss:"],"media-src":["'self'","https:","http:"],"object-src":["'none'"],"frame-src":["'self'","https:"],"base-uri":["'self'"]},YW={"default-src":["'none'"],"frame-ancestors":["'none'"]};XW={name:"csp",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?F6(Y,Q):void 0;return D8(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},JW={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return F6(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};pV={enabled:!1,reportOnly:!1,directives:I8,useNonce:!1,addMetaTag:!0}});import iV from"crypto";function rV($=nV){let Z=iV.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return eZ=Z,Z}function sV(){if(!eZ)rV();return eZ}function aV($=GW){let Z=sV();return`<input type="hidden" name="${$}" value="${Z}">`}function KW($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return aV(X||GW)})}var nV=40,GW="_token",eZ=null;var WW=()=>{};async function $2($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let J=$;for(let Q of X.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await oV(J,Q,Z,Y,X);else J=await tV(J,Q,Z,Y,X)}return J}async function oV($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=V4(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),B=[],z=_.exec(U);while(z!==null){let[q,j="",H=""]=z,L=z.index||0;try{let F=j?UW(j):[],O=H.trim(),V=await G(O,F,Y,X);B.push({original:q,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);B.push({original:q,processed:G0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,e.EVALUATION_ERROR),startIndex:L})}z=_.exec(U)}for(let q=B.length-1;q>=0;q--){let{original:j,processed:H}=B[q];U=U.replace(j,H)}return U}async function tV($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=V4(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let L=UW(j),F=await G("",L,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);U.push({original:q,processed:G0("CustomDirective",`Error in @${Q}(${j}): ${F}`,e.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let B=V4(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),z=B.exec(K);while(z!==null){let[q]=z,j=z.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:G0("CustomDirective",`Error in @${Q}: ${L}`,e.EVALUATION_ERROR),startIndex:j})}z=B.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function UW($){if(!$.trim())return[];let Z=[],Y="",X=!1,J="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!X)X=!0,J=G;else if(G===J)X=!1;else Y+=G;else if(G===","&&!X)Z.push(Y.trim()),Y="";else Y+=G}if(Y.trim())Z.push(Y.trim());return Z.map((Q)=>{let G=Q.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var Z2=D(()=>{_1();j6()});var b8={};t(b8,{useTitle:()=>zW,useSeoMeta:()=>J5,usePageTitle:()=>zW,useHead:()=>A6,resetHead:()=>_W,renderHtmlAttrs:()=>jW,renderHead:()=>qW,renderBodyAttrs:()=>HW,processTitleDirective:()=>FW,processMetaDirective:()=>VW,processHeadDirective:()=>OW,getPageMeta:()=>S8,getHead:()=>I4,definePageMeta:()=>BW,applyHead:()=>LW});function I4(){return V6}function S8(){return k8}function _W(){V6={},eV.length=0,k8={}}function A6($){V6=$A(V6,$)}function $A($,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 J5($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});A6({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function BW($){if(k8={...k8,...$},$.title||$.description)J5({title:$.title,description:$.description})}function zW($){let Z=typeof $==="function"?$():$;A6({title:Z})}function qW($=V6){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${n6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${n6(J)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>{return`${J==="httpEquiv"?"http-equiv":J}="${n6(String(Q))}"`}).join(" ");Z.push(`<meta ${X}>`)}for(let Y of $.link||[]){let X=Object.entries(Y).filter(([J,Q])=>Q!==void 0).map(([J,Q])=>`${J}="${n6(String(Q))}"`).join(" ");Z.push(`<link ${X}>`)}for(let Y of $.script||[]){let{content:X,...J}=Y,Q=Object.entries(J).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${n6(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
1778
+ `)}function jW($=V6){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${n6(Y)}"`).join(" ")}function HW($=V6){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${n6(Y)}"`).join(" ")}function n6($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function LW($=V6){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let X=document.querySelector(Y);if(!X){if(X=document.createElement("meta"),Z.name)X.setAttribute("name",Z.name);if(Z.property)X.setAttribute("property",Z.property);document.head.appendChild(X)}X.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,X=document.querySelector(Y);if(!X)X=document.createElement("link"),document.head.appendChild(X);for(let[J,Q]of Object.entries(Z))if(Q!==void 0)X.setAttribute(J,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function OW($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
1779
+ `,""}),headContent:Z.trim()}}function FW($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return A6({title:G}),""})}function VW($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,B=J.includes(":")?{property:J,content:U}:{name:J,content:U};return A6({meta:[B]}),""})}var V6,eV,k8;var N6=D(()=>{V6={},eV=[],k8={}});import ZA from"crypto";function c0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function YA($){return{...P8,...$.forms?.classes}}function C8($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function XA(){return ZA.randomUUID()}function JA($,Z,Y,X){let J=YA(X),Q=$;return Q=wW(Q,Z),Q=D4(Q,Z),Q=y8(Q,Z,J),Q=x8(Q,Z,J),Q}function D4($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=XA();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${c0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${c0(Q)}">`;return X}),Y}function y8($,Z,Y=P8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"POST",B=K||W||"",z=R6(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${c0(j)}" action="${c0(B)}"${z?` ${z}`:""}>`;if(H+=`
1780
+ ${D4("@csrf",Z)}`,!["GET","POST"].includes(q))H+=`
1781
+ ${D4(`@method('${q}')`,Z)}`;return H}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"",B=K||W||"",z=R6(U),q=Q5(_,Z),j=q!==void 0&&q!==null?q:B||"",H=z.match(/type=['"]([^'"]+)['"]/i),L=H?H[1]:"text",F=G5(_,Z),O=z.match(/class=['"]([^'"]+)['"]/i),V=C8(O?O[1]:"",Y.input,F,Y.inputError),N=z.replace(/class=['"][^'"]+['"]/i,"");return N=N.replace(/type=['"][^'"]+['"]/i,""),`<input type="${c0(L)}" name="${c0(_)}" value="${c0(j)}" class="${V}"${N?` ${N}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let W=R6(G),U=Q5(Q,Z)||K.trim(),_=G5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=C8(B?B[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${c0(Q)}" class="${z}"${q?` ${q}`:""}>${c0(U)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(J,Q,G="",K)=>{let W=R6(G),U=Q5(Q,Z),_=G5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=C8(B?B[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,""),j=K;if(U!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,L,F)=>{if((Array.isArray(U)?U.some((V)=>String(V)===F):String(U)===F)&&!L.includes("selected"))return L.replace(/(<option)/,"$1 selected");return H});return`<select name="${c0(Q)}" class="${z}"${q?` ${q}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="1",K="")=>{let W=R6(K),U=Q5(Q,Z),_=U!==void 0&&(Array.isArray(U)?U.some((j)=>String(j)===G):U===!0||String(U)===G),B=W.match(/class=['"]([^'"]+)['"]/i),z=B?B[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${c0(Q)}" value="${c0(G)}" class="${z}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,K="")=>{let W=R6(K),U=Q5(Q,Z),_=U!==void 0&&U===G,B=W.match(/class=['"]([^'"]+)['"]/i),z=B?B[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${c0(Q)}" value="${c0(G)}" class="${z}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="")=>{let K=R6(G),W=K.match(/accept=['"]([^'"]+)['"]/i),U=W?W[1]:"",_=K.includes("multiple"),B=G5(Q,Z),z=K.match(/class=['"]([^'"]+)['"]/i),q=C8(z?z[1]:"",Y.input,B,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${c0(Q)}"`,`class="${q}"`];if(U)H.push(`accept="${c0(U)}"`);if(_)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(J,Q,G="",K)=>{let W=R6(G),U=W.match(/class=['"]([^'"]+)['"]/i),_=U?U[1]:Y.label,B=W.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${c0(Q)}" class="${_}"${B?` ${B}`:""}>${K}</label>`}),X}function x8($,Z,Y=P8){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(G5(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return AW(J,Z);if(K.trim().includes("errors.first")||K.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(J);return AW(J,Z)}let W=K.trim();if(L0(W)){let U=M0(W,Z);return U!==void 0?String(U):W}return W}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),X}})}function G5($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function AW($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let Y=Z.errors[$];return Array.isArray(Y)?Y[0]:String(Y)}return""}function Q5($,Z){let Y;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let X=$.slice(0,-2);if(Y=Z[X],Y!==void 0)return Y}return Z[$]}function R6($){if(!$.trim())return"";let Z=[],Y=$.trim(),X=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,J;while((J=X.exec(Y))!==null){let[,Q,,G]=J;Z.push(`${Q}="${G.trim()}"`)}return Z.join(" ")}function QA($,Z){NW[$]=Z}function Y2($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function RW($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=Y2(G),W=NW[K.name];if(!W){console.warn(`Unknown validation rule: ${K.name}`);continue}if(K.name==="confirmed"){let _=`${$}_confirmation`;K.params=[X[_]]}let U=W(Z,K.params||[],$);if(U)J.push(K.message||U)}return{field:$,valid:J.length===0,errors:J}}function GA($,Z){let Y={};for(let[X,J]of Object.entries(Z)){let Q=RW(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function wW($,Z){return $.replace(/@validate\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]*)\})?\s*\)/g,(Y,X,J,Q)=>{let G=J.split("|").map((W)=>W.trim()),K=[];for(let W of G){let U=Y2(W);switch(U.name){case"required":K.push("required");break;case"email":K.push('type="email"');break;case"url":K.push('type="url"');break;case"numeric":case"integer":if(K.push('type="number"'),U.name==="integer")K.push('step="1"');break;case"min":if(U.params?.[0])K.push(`minlength="${U.params[0]}"`);break;case"max":if(U.params?.[0])K.push(`maxlength="${U.params[0]}"`);break;case"regex":if(U.params?.[0])K.push(`pattern="${U.params[0]}"`);break}}return`<!-- @validate:${X}:${J} -->${K.length>0?`<!-- attrs:${K.join(" ")} -->`:""}`})}function KA($){X2[$.name]=$}function MW($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=Y2(Q),K=X2[G.name];if(!K){console.warn(`Unknown validation rule: ${G.name}`);continue}let W=K.validate($,G.params||[],Y);if(W!==!0)X.push(W)}return{valid:X.length===0,errors:X}}function WA($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=MW($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function UA($,Z){let Y=JSON.stringify(Z);return`
1782
1782
  <script>
1783
1783
  (function() {
1784
1784
  const form = document.getElementById('${$}');
@@ -1834,12 +1834,12 @@ catch { return 'Please enter a valid URL'; } },
1834
1834
  `),X=[{obj:Z,indent:-1}];for(let J of Y){let Q=J.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(X.length>1&&X[X.length-1].indent>=G)X.pop();let K=X[X.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,_]=W,B=U.trim(),z=_.trim();if(z==="")K[B]={},X.push({obj:K[B],indent:G});else K[B]=RA(z)}}return Z}function RA($){if($.startsWith("'")&&$.endsWith("'")||$.startsWith('"')&&$.endsWith('"'))return $.slice(1,-1);let Z=$.toLowerCase();if(Z==="true"||Z==="yes")return!0;if(Z==="false"||Z==="no")return!1;if(Z==="null"||Z==="~")return null;let Y=Number($);if(!Number.isNaN(Y))return Y;return $}function wA($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"json":default:return".json"}}function MA($,Z){for(let Y of $){let X=Y.trim(),J=X.match(/^\{(\d+)\}\s*(.*)$/);if(J){let G=Number.parseInt(J[1],10);if(Z===G)return J[2];continue}let Q=X.match(/^\[(\d+),(\d+|\*)\]\s*(.*)$/);if(Q){let G=Number.parseInt(Q[1],10),K=Q[2]==="*"?Number.POSITIVE_INFINITY:Number.parseInt(Q[2],10);if(Z>=G&&Z<=K)return Q[3];continue}}if($.length===2)return Z===1?$[0].trim():$[1].trim();if(Z<$.length)return $[Z].trim();return $[$.length-1].trim()}function CW($,Z={}){return PW($,Z)}function PW($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=EA($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=TA(Q,Z),X=J+1}else if($[X]==="'"&&X+1<$.length)if($[X+1]==="'")Y+="'",X+=2;else if($[X+1]==="{"||$[X+1]==="}")Y+=$[X+1],X+=2;else Y+=$[X],X++;else Y+=$[X],X++;return Y}function EA($,Z){let Y=0;for(let X=Z;X<$.length;X++)if($[X]==="{")Y++;else if($[X]==="}"){if(Y--,Y===0)return X}return-1}function TA($,Z){let Y=IA($);if(Y.length===0)return`{${$}}`;let X=Y[0].trim(),J=Z[X];if(Y.length===1)return J!==void 0?String(J):`{${X}}`;switch(Y[1].trim().toLowerCase()){case"plural":return DA(J,Y.slice(2).join(","),Z);case"select":return SA(J,Y.slice(2).join(","));case"selectordinal":return bA(J,Y.slice(2).join(","));case"number":return PA(J,Y[2]?.trim());case"date":return yA(J,Y[2]?.trim());case"time":return xA(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function IA($){let Z=[],Y="",X=0;for(let J=0;J<$.length;J++){let Q=$[J];if(Q==="{")X++,Y+=Q;else if(Q==="}")X--,Y+=Q;else if(Q===","&&X===0)Z.push(Y),Y="";else Y+=Q}if(Y)Z.push(Y);return Z}function DA($,Z,Y){let X=Number($)||0,J=G2(Z),Q=`=${X}`;if(J[Q])return Q2(J[Q],X,Y);let G=kA(X);if(J[G])return Q2(J[G],X,Y);if(J.other)return Q2(J.other,X,Y);return String(X)}function Q2($,Z,Y){let X=$.replace(/#/g,String(Z));return PW(X,Y)}function kA($){let Z=Math.abs($),Y=Math.floor(Z),X=String($).includes(".")?String($).split(".")[1].length:0;if(Y===1&&X===0)return"one";return"other"}function SA($,Z){let Y=String($||""),X=G2(Z);if(X[Y])return X[Y];return X.other||String($)}function bA($,Z){let Y=Number($)||0,X=G2(Z),J=CA(Y);if(X[J])return X[J].replace(/#/g,String(Y));if(X.other)return X.other.replace(/#/g,String(Y));return String(Y)}function CA($){let Z=Math.abs($),Y=Z%10,X=Z%100;if(Y===1&&X!==11)return"one";if(Y===2&&X!==12)return"two";if(Y===3&&X!==13)return"few";return"other"}function G2($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function PA($,Z){let Y=Number($);if(Number.isNaN(Y))return String($);switch(Z){case"integer":return Math.floor(Y).toLocaleString();case"percent":return`${(Y*100).toFixed(0)}%`;case"currency":return Y.toLocaleString(void 0,{style:"currency",currency:"USD"});default:return Y.toLocaleString()}}function yA($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.dateStyle="short";break;case"medium":X.dateStyle="medium";break;case"long":X.dateStyle="long";break;case"full":X.dateStyle="full";break;default:X.dateStyle="medium"}return Y.toLocaleDateString(void 0,X)}function xA($,Z){let Y=$ instanceof Date?$:new Date(String($));if(Number.isNaN(Y.getTime()))return String($);let X={};switch(Z){case"short":X.timeStyle="short";break;case"medium":X.timeStyle="medium";break;case"long":X.timeStyle="long";break;case"full":X.timeStyle="full";break;default:X.timeStyle="short"}return Y.toLocaleTimeString(void 0,X)}function yW($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function v8($,Z,Y=!0,X={}){let J=$.split("."),Q=Z;for(let K of J){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(yW(G))return CW(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),W=G.split("|");G=MA(W,K)}for(let[K,W]of Object.entries(X)){let U=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${U}`,"g"),String(W))}return G}async function K2($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...g8,...X.i18n},K=await bW(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await TW(J,Q,async(_,B,z,q,j)=>{try{let H={};if(z)try{let F=[()=>JSON.parse(z),()=>{let O=`{"data":${z}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return x0(z,Z)}];for(let O of F)try{if(H=O(),Object.keys(H).length>0)break}catch{}}catch(F){if(X.debug)console.error("Error parsing parameters for @translate directive:",F)}return v8(B,K,G.fallbackToKey,H)||q.trim()}catch(H){if(X.debug)console.error("Error processing @translate directive:",H);return G0("Translate",`Error in @translate('${B}'): ${H instanceof Error?H.message:String(H)}`,e.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(X.debug){console.warn(`Processing translations in template. Sections: ${J.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let _=[...J.matchAll(W)];console.warn(`Found ${_.length} @translate matches`),_.forEach((B,z)=>console.warn(`Match ${z}: ${B[0]}, Key: ${B[1]}, Params: ${B[2]||"none"}`))}return J=await TW(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(_,B,z,q)=>{try{let j={};if(z)try{let H=[()=>JSON.parse(z),()=>{let L=`{"data":${z}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return x0(z,Z)}];for(let L of H)try{if(j=L(),Object.keys(j).length>0)break}catch{}}catch(H){if(X.debug)console.error("Error parsing parameters for @translate directive:",H)}return v8(B,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return G0("Translate",`Error in @translate('${B}'): ${j instanceof Error?j.message:String(j)}`,e.EVALUATION_ERROR)}}),J}async function TW($,Z,Y){let X=[];return $.replace(Z,(Q,...G)=>{let K=Y(Q,...G).then((W)=>({match:Q,replacement:W}));return X.push(K),Q}),(await Promise.all(X)).reduce((Q,{match:G,replacement:K})=>Q.replace(G,K),$)}function vA($,Z=!0){return(Y,X={})=>{return v8(Y,$,Z,X)}}var g8,Y1,w1,o1;var W2=D(()=>{_1();n0();g8={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},Y1={},w1={},o1={}});var h8={};t(h8,{stripTypeScript:()=>fW,hasVariables:()=>B2,extractVariables:()=>V0,extractScriptFromTemplate:()=>_2,convertToCommonJS:()=>f8});import W5 from"path";function gA($){let Z=[],Y=0,X=$.split(`
1835
1835
  `);for(let J of X){let Q=null,G=!1;for(let K=0;K<J.length;K++){let W=J[K];if(G){G=!1;continue}if(W==="\\"){G=!0;continue}if(Q){if(W===Q)Q=null;continue}if(W==="'"||W==='"'||W==="`"){Q=W;continue}if(W==="/"&&K+1<J.length&&J[K+1]==="/")break;if(W==="{")Y++;else if(W==="}")Y--}if(Y===0){let K=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(K)Z.push(K[1]);else{let W=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(W){let _=W[1].slice(1,-1).split(",").map((B)=>{let z=B.split(":");return(z.length>1?z[1]:z[0]).trim()}).filter((B)=>/^\w+$/.test(B));Z.push(..._)}}}}return[...new Set(Z)]}function fW($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(X){if(!X.includes(":"))return X;let J=[],Q="",G=0,K=0,W=null;for(let U=0;U<X.length;U++){let _=X[U];if(W){if(Q+=_,_===W)W=null;continue}if(_==='"'||_==="'"||_==="`"){W=_,Q+=_;continue}if(_==="<")G++;else if(_===">"&&G>0)G--;else if(_==="(")K++;else if(_===")")K--;if(_===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=_}if(Q)J.push(Q);return J.map((U)=>{let _=U.trim(),B=_.startsWith("..."),z=B?_.slice(3):_,q=-1,j=0;for(let A=0;A<z.length;A++)if(z[A]==="<")j++;else if(z[A]===">")j--;else if(z[A]===":"&&j===0){q=A;break}if(q===-1)return U;let L=z.substring(0,q).trim().replace(/\?$/,""),F=z.substring(q+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 N=B?"...":"";if(O!==-1)return`${N}${L} = ${F.substring(O+1).trim()}`;return`${N}${L}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,W=G+1,U=0,_=null;while(W<Z.length&&K>0){let q=Z[W];if(_){if(q===_)_=null;W++;continue}if(q==='"'||q==="'"||q==="`"){_=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let B=Z.substring(G+1,W);if(!B.includes(":"))continue;let z=Y(B);Q.push({start:G+1,end:W,replacement:z})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Z=Z.substring(0,K)+U+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,J)=>{if(!J.includes(":"))return X;if(J.includes("{")||J.includes("}"))return X;return`(${J.split(",").map((G)=>{let[K,...W]=G.split("="),U=K.split(":")[0].trim();if(W.length>0)return`${U} = ${W.join("=").trim()}`;return U}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|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,`
1836
1836
 
1837
- `),Z}async function V0($,Z,Y){if(!$.trim())return;let X;try{let b=new Bun.Transpiler({loader:"ts",target:"browser"}),d=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");d=d.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=b.transformSync(d)}catch{X=fW($)}let J={exports:{}},Q=J.exports,G=process.cwd(),K={},W=[...X.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 d=W5.resolve(G,"node_modules",b),m=W5.join(d,"package.json"),i=JSON.parse(a("fs").readFileSync(m,"utf8")),c=i.main||"index.js";if(i.exports){let r=typeof i.exports==="string"?i.exports:i.exports["."];if(typeof r==="string")c=r;else if(r?.bun)c=r.bun;else if(r?.import)c=r.import;else if(r?.default)c=r.default}K[b]=await import(W5.resolve(d,c))}catch{}let U=(b)=>{if(K[b])return K[b];return a(b)},_=Z.props||{},B=Object.assign((b)=>{if(!b)return _;let d={};for(let[m,i]of Object.entries(b)){let c=_[m];if(c!==void 0)d[m]=c;else if(typeof i==="function")d[m]=i();else d[m]=i}return d},_),z=()=>_,q=(b,d)=>{let m={...b};for(let[i,c]of Object.entries(d))if(m[i]===void 0)if(typeof c==="function")m[i]=c();else m[i]=c;return m},j=(b)=>{let d=()=>b;return d.set=(m)=>{},d.update=(m)=>{},d},H=(b)=>{let d,m=!1;return()=>{if(!m)try{d=b(),m=!0}catch{d=void 0}return d}},L=(b)=>{},F=(b)=>b(),O=(b)=>{},V=(b)=>{},N=(b)=>{},A=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),R=()=>({push:(b)=>{},replace:(b)=>{},back:()=>{},forward:()=>{},go:(b)=>{}}),M=(b)=>{A4(b);let d=Z.__stx_runtime_head||{},m=b||{};Z.__stx_runtime_head={...d,...m.title&&{title:m.title},meta:[...d.meta||[],...m.meta||[]],link:[...d.link||[],...m.link||[]],script:[...d.script||[],...m.script||[]],htmlAttrs:{...d.htmlAttrs||{},...m.htmlAttrs||{}},bodyAttrs:{...d.bodyAttrs||{},...m.bodyAttrs||{}}}},E=(b)=>{J5(b);let d=I6();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...d.title&&{title:d.title},meta:d.meta?[...d.meta]:[]}},I=(b)=>({value:b}),T=(b)=>b,S=(b)=>({value:typeof b==="function"?b():b}),k=(b,d)=>{},C=(b)=>{},x=(b)=>{},g=(b)=>b?b():Promise.resolve(),P=(b)=>(d,...m)=>{},f=(b)=>{},h=(b,d)=>{},u=(b,d)=>d,l=()=>({value:"light"}),p=()=>({value:!1}),Q0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},X0=new Proxy(Q0,{get(b,d){if(d in b)return b[d];return},set(b,d,m){return b[d]=m,!0}}),C0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},T0=console;try{let b=f8(X,Y),d=new Set(Object.keys(_)),m=Object.keys(Z).filter((j0)=>!d.has(j0)&&j0!=="props"),i=m.map((j0)=>Z[j0]),c=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"]),r=[],_0=[];for(let[j0,XZ]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if(c.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(b))continue;r.push(j0),_0.push(XZ)}let K0=gA(b).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
1838
- `),R0=Z.params??{},w0=[],o0=[];for(let j0=0;j0<m.length;j0++){if(m[j0]==="params")continue;w0.push(m[j0]),o0.push(i[j0])}let j6=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","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...r,...w0,`return (async () => {
1837
+ `),Z}async function V0($,Z,Y){if(!$.trim())return;let X;try{let b=new Bun.Transpiler({loader:"ts",target:"browser"}),d=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");d=d.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=b.transformSync(d)}catch{X=fW($)}let J={exports:{}},Q=J.exports,G=process.cwd(),K={},W=[...X.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 d=W5.resolve(G,"node_modules",b),m=W5.join(d,"package.json"),i=JSON.parse(a("fs").readFileSync(m,"utf8")),c=i.main||"index.js";if(i.exports){let r=typeof i.exports==="string"?i.exports:i.exports["."];if(typeof r==="string")c=r;else if(r?.bun)c=r.bun;else if(r?.import)c=r.import;else if(r?.default)c=r.default}K[b]=await import(W5.resolve(d,c))}catch{}let U=(b)=>{if(K[b])return K[b];return a(b)},_=Z.props||{},B=Object.assign((b)=>{if(!b)return _;let d={};for(let[m,i]of Object.entries(b)){let c=_[m];if(c!==void 0)d[m]=c;else if(typeof i==="function")d[m]=i();else d[m]=i}return d},_),z=()=>_,q=(b,d)=>{let m={...b};for(let[i,c]of Object.entries(d))if(m[i]===void 0)if(typeof c==="function")m[i]=c();else m[i]=c;return m},j=(b)=>{let d=()=>b;return d.set=(m)=>{},d.update=(m)=>{},d},H=(b)=>{let d,m=!1;return()=>{if(!m)try{d=b(),m=!0}catch{d=void 0}return d}},L=(b)=>{},F=(b)=>b(),O=(b)=>{},V=(b)=>{},N=(b)=>{},A=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),R=()=>({push:(b)=>{},replace:(b)=>{},back:()=>{},forward:()=>{},go:(b)=>{}}),M=(b)=>{A6(b);let d=Z.__stx_runtime_head||{},m=b||{};Z.__stx_runtime_head={...d,...m.title&&{title:m.title},meta:[...d.meta||[],...m.meta||[]],link:[...d.link||[],...m.link||[]],script:[...d.script||[],...m.script||[]],htmlAttrs:{...d.htmlAttrs||{},...m.htmlAttrs||{}},bodyAttrs:{...d.bodyAttrs||{},...m.bodyAttrs||{}}}},E=(b)=>{J5(b);let d=I4();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...d.title&&{title:d.title},meta:d.meta?[...d.meta]:[]}},I=(b)=>({value:b}),T=(b)=>b,S=(b)=>({value:typeof b==="function"?b():b}),k=(b,d)=>{},C=(b)=>{},x=(b)=>{},g=(b)=>b?b():Promise.resolve(),P=(b)=>(d,...m)=>{},f=(b)=>{},h=(b,d)=>{},u=(b,d)=>d,l=()=>({value:"light"}),p=()=>({value:!1}),Q0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},X0=new Proxy(Q0,{get(b,d){if(d in b)return b[d];return},set(b,d,m){return b[d]=m,!0}}),C0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},T0=console;try{let b=f8(X,Y),d=new Set(Object.keys(_)),m=Object.keys(Z).filter((j0)=>!d.has(j0)&&j0!=="props"),i=m.map((j0)=>Z[j0]),c=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"]),r=[],_0=[];for(let[j0,XZ]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if(c.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(b))continue;r.push(j0),_0.push(XZ)}let K0=gA(b).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
1838
+ `),R0=Z.params??{},w0=[],o0=[];for(let j0=0;j0<m.length;j0++){if(m[j0]==="params")continue;w0.push(m[j0]),o0.push(i[j0])}let j4=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","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...r,...w0,`return (async () => {
1839
1839
  ${b}
1840
1840
  ${K0}
1841
1841
  return module.exports
1842
- })()`)(J,Q,U,_,B,z,q,j,H,L,F,O,V,N,A,R,M,E,I,T,S,k,C,x,g,P,f,h,u,l,p,X0,C0,T0,Q0.confirm,Q0.alert,Q0.fetch,R0,..._0,...o0);Object.assign(Z,j6);for(let[j0,XZ]of Object.entries(_))if(!(j0 in Z))Z[j0]=XZ}catch{try{await dA(X,Z,Y)}catch{}}}function f8($,Z){let Y=Z?W5.dirname(Z):process.cwd(),X=$.split(`
1842
+ })()`)(J,Q,U,_,B,z,q,j,H,L,F,O,V,N,A,R,M,E,I,T,S,k,C,x,g,P,f,h,u,l,p,X0,C0,T0,Q0.confirm,Q0.alert,Q0.fetch,R0,..._0,...o0);Object.assign(Z,j4);for(let[j0,XZ]of Object.entries(_))if(!(j0 in Z))Z[j0]=XZ}catch{try{await dA(X,Z,Y)}catch{}}}function f8($,Z){let Y=Z?W5.dirname(Z):process.cwd(),X=$.split(`
1843
1843
  `),J=[],Q=0;while(Q<X.length){let G=X[Q].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;Q<X.length;Q++){for(let W of X[Q])if(W==="{")K++;else if(W==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,W=!1;for(let U=Q;U<X.length&&!W;U++){let _=null,B=!1,z=X[U];for(let q=0;q<z.length;q++){let j=z[q];if(B){B=!1;continue}if(j==="\\"){B=!0;continue}if(_){if(j===_)_=null;continue}if(j==='"'||j==="'"||j==="`"){_=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=U+1,W=!0;break}}}}if(!W)Q=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),U=G.match(/^import\s+['"](.+)['"]/),_=(B)=>{if(B.startsWith("."))return W5.resolve(Y,B);return B};if(K){let[,B,z]=K,q=_(z);J.push(`const ${B} = await import('${q}')`),J.push(`module.exports.${B} = ${B};`)}else if(W){let[,B,z]=W,q=B.trim(),j=_(z);J.push(`const { ${q} } = await import('${j}')`);for(let H of q.split(",")){let L=H.trim().split(/\s+as\s+/).pop()?.trim();if(L)J.push(`module.exports.${L} = ${L};`)}}else if(U){let B=_(U[1]);J.push(`await import('${B}')`)}else J.push(G);Q++;continue}if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=xW(X,Q),{type:W,name:U,value:_}=K;J.push(`${W} ${U} = ${_};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=U2(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=xW(X,Q),{type:W,name:U,value:_}=K;J.push(`${W} ${U} = ${_};`),J.push(`module.exports.${U} = ${U};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=U2(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=X[Q].replace(/^(\s*)export\s+default\s+/,"$1"),W=[...X];W[Q]=K;let U=U2(W,Q);if(J.push(U.functionCode),U.name)J.push(`module.exports.default = ${U.name};`);Q=U.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");J.push(`module.exports.default = ${K};`),Q++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let W=K[1],U=X[Q].replace(/^export\s+/,""),_=0,B=Q;for(;B<X.length;B++){let z=X[B];for(let q of z)if(q==="{")_++;else if(q==="}")_--;if(B>Q)U+=`
1844
1844
  `+z;if(_<=0&&B>=Q)break}J.push(U),J.push(`module.exports.${W} = ${W};`),Q=B+1}else J.push(G),Q++}else if(G.includes("module.exports"))J.push(G),Q++;else if(G.trim()&&!G.startsWith("//"))J.push(G),Q++;else Q++}return J.join(`
1845
1845
  `)}function hW($,Z){let Y=$[Z];if(Y!=="{"&&Y!=="[")return null;let J=v0($,Y,Y==="{"?"}":"]",Z);if(J===-1)return null;return{pattern:$.slice(Z,J+1),endPos:J+1}}function dW($){let Z=[],Y=$.slice(1,-1).trim();if(!Y)return Z;let X=0,J=0,Q="";while(X<Y.length){let G=Y[X];if(G==="{"||G==="["){if(J++,J===1){let K=hW(Y,X);if(K){let W=dW(K.pattern);Z.push(...W),X=K.endPos,Q="";continue}}}else if(G==="}"||G==="]")J--;if(J>0){X++;continue}if(G===","){if(Q.trim())Z.push(Q.trim());Q="",X++;continue}if(G===":"){Q="",X++;continue}if(G==="="){if(Q.trim())Z.push(Q.trim());Q="",X++;while(X<Y.length&&Y[X]!==","&&J===0){if(Y[X]==="{"||Y[X]==="[")J++;else if(Y[X]==="}"||Y[X]==="]")J--;X++}continue}if(/[\w$]/.test(G))Q+=G;X++}if(Q.trim())Z.push(Q.trim());return Z}function xW($,Z){let Y=$[Z].trim(),X=Y.match(/^(?:export\s+)?(const|let|var)\s+(\w+)\s*=\s*(.*)$/);if(!X){let U=Y.match(/^(?:export\s+)?(const|let|var)\s+/);if(U){let _=Y.slice(U[0].length),B=Z;if((_.startsWith("{")||_.startsWith("["))&&!_.includes(_.startsWith("{")?"}":"]")){let q=_.startsWith("{")?"}":"]",j=_;for(let H=Z+1;H<$.length;H++)if(j+=" "+$[H].trim(),B=H,$[H].includes(q))break;_=j}let z=hW(_,0);if(z){let q=U[1],j=z.pattern,H=_.slice(z.endPos).trim();if(H.startsWith("=")){let L=H.slice(1).trim(),F=L,O=Math.max(B,Z);if(vW(L)){let R=gW($,O,L);F=R.value,O=R.nextIndex}else O=O+1;F=F.trim().replace(/;$/,"");let V=dW(j),N=`__stx_src_${Z}`,A=V.map((R)=>`module.exports.${R} = ${R};`).join(`
@@ -1854,7 +1854,7 @@ ${G}`,J++}return{functionCode:X,nextIndex:J}}async function dA($,Z,Y){let X=$.ma
1854
1854
  ${Array.from($.matchAll(/(?:const|let|var)\s+(\w+)\s*=/g)).map((W)=>`if (typeof ${W[1]} !== 'undefined') result.${W[1]} = ${W[1]};`).join(`
1855
1855
  `)}
1856
1856
  return result;
1857
- `)();Object.entries(K).forEach(([W,U])=>{if(U!==void 0&&!(W in Z))Z[W]=U})}catch{}}function _2($){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 B2($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var w4=D(()=>{N4()});var nW={};t(nW,{processLoops:()=>c8});function cA($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let _=X.substring(K+1,U),B=U+1,z=_.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let q=z[1],j=_.slice(z[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=x0(L,Z),O=JSON.stringify(F),V=`@component('${q}', ${O})`;Q.push({start:G,end:B,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}return X}function d8($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,_=null,B=!1;while(U<X.length&&W>0){let j=X[U];if(B){B=!1,U++;continue}if(j==="\\"&&_){B=!0,U++;continue}if(_){if(j===_)_=null;U++;continue}if(j==='"'||j==="'"||j==="`"){_=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=X.substring(K+1,U),q=Y(z);X=X.substring(0,G)+q+X.substring(U+1)}return X}function lA($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,J)=>{if(J in Z)return`:${J}="${J}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,J,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);u$(Q);let U=F0(Q,G)(...K),B=JSON.stringify(U).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return`__stx_${J}="${B}"`}catch(G){return X}}),Y}function pA($,Z){let Y=$;return Y=d8(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=F0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(M0(Q,Z));return G?m8:""}catch{return""}}),Y=d8(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=F0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(M0(Q,Z));return G?u8:""}catch{return""}}),Y}function iA($){let Z=$;return Z=Z.replace(/@break(?!\()/g,m8),Z=Z.replace(/@continue(?!\()/g,u8),Z}function uW($){let Z=$.includes(m8),Y=Z?$.substring(0,$.indexOf(m8)):$;return{hasBreak:Z,content:Y}}function cW($){let Z=$.includes(u8),Y=Z?$.substring(0,$.indexOf(u8)):$;return{hasContinue:Z,content:Y}}function pW($){let Z=$;return Z=d8(Z,"@break",(Y)=>{let X=Y.trim();if(!G8(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=d8(Z,"@continue",(Y)=>{let X=Y.trim();if(!G8(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function nA($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((_,B)=>_.pos-B.pos);let K=[],W=0;for(let _ of X)W+=_.delta,K.push({pos:_.pos,depth:W});function U(_){let B=0,z=K.length-1,q=0;while(B<=z){let j=B+z>>1;if(K[j].pos<=_)q=K[j].depth,B=j+1;else z=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let _=Y.index,B=Y.index+Y[0].length-1,z=1,q=B+1,j=-1;while(q<$.length&&z>0){if($[q]==="(")z++;else if($[q]===")"){if(z--,z===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(B+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,N=1,A=V,R=/@forelse\s*\(/g,M=/@endforelse/g,E=-1;while(N>0&&A<$.length){R.lastIndex=A,M.lastIndex=A;let x=R.exec($),g=M.exec($);if(!g)break;if(x&&x.index<g.index)N++,A=x.index+x[0].length;else{if(N--,N===0){E=g.index;break}A=g.index+11}}if(E===-1)continue;let I=$.substring(V,E),T=E+11,S=-1,k=0,C=0;while(C<I.length){let x=I.indexOf("@",C);if(x===-1)break;let g=I.substring(x);if(/^@forelse\s*\(/.test(g))k++,C=x+1;else if(g.startsWith("@endforelse"))k--,C=x+11;else if(k===0&&g.startsWith("@empty")){if(I.length<=x+6||!/[a-z]/i.test(I[x+6])){S=x;break}C=x+1}else C=x+1}if(S===-1)continue;return{start:_,end:T,arrayExpr:F,itemVar:O,foreachContent:I.substring(0,S),emptyContent:I.substring(S+6)}}return null}function lW($,Z){let Y=$;while(!0){let X=nA(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(L0(G))_=F0(G,Object.keys(Z))(...Object.values(Z));else _=M0(G,Z);let B;if(!Array.isArray(_)||_.length===0)B=U;else B=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+B+Y.substring(Q)}catch(_){let B=_ instanceof Error?_.message:String(_),z=G0("Forelse",`Error in @forelse(${G} as ${K}): ${B}`,e.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function c8($,Z,Y,X){let J=$;J=lW(J,Z);function Q(W){let U=/@foreach\s*\(/g,_;while((_=U.exec(W))!==null){let B=_.index,z=_.index+_[0].length-1,q=1,j=z+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let L=W.substring(z+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=B,V=L.substring(0,F),N=L.substring(F+4),A=H+1,R=1,M=A,E=/@foreach\s*\(/g,I=/@endforeach/g;while(R>0&&M<W.length){E.lastIndex=M,I.lastIndex=M;let T=E.exec(W),S=I.exec(W);if(!S)break;if(T&&T.index<S.index)R++,M=T.index+T[0].length;else{if(R--,R===0){let k=W.substring(A,S.index),C=S.index+11;return{start:O,end:C,arrayExpr:V,itemVar:N,content:k}}M=S.index+11}}}return null}function G(W,U){let _=W;while(!0){let B=Q(_);if(!B)break;let{start:z,end:q,arrayExpr:j,itemVar:H,content:L}=B;try{let F=j.trim(),O;if(L0(F))O=F0(F,Object.keys(U))(...Object.values(U));else O=M0(F,U);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 T=G0("Foreach",`Error in @foreach: ${F} is not iterable`,e.TYPE_ERROR);_=_.substring(0,z)+T+_.substring(q);continue}let N=X?.loops?.useAltLoopVariable??uA,A=H.trim(),R=null,M;if(A.includes("=>")){let T=A.split("=>").map((S)=>S.trim());if(T.length===2)R=T[0],M=T[1];else M=A}else M=A;let E="",I=O;for(let T=0;T<I.length;T++){let S=I[T],k={index:T,iteration:T+1,first:T===0,last:T===I.length-1,count:I.length},C={...U,loop:k,$loop:k};if(M.startsWith("[")&&M.endsWith("]")){let f=M.slice(1,-1).split(",").map((h)=>h.trim());if(Array.isArray(S))f.forEach((h,u)=>{if(h)C[h]=S[u]});else C[M]=S}else C[M]=S;if(R)if(V&&Array.isArray(S)&&S.length===2)C[R]=S[0],C[M]=S[1];else C[R]=T;let x=pA(L,C),g=cW(x);if(g.hasContinue){E+=g.content;continue}let P=uW(x);if(P.hasBreak){E+=P.content;break}if(x=lW(x,C),x=G(x,C),x=T6(x,C,Y),x=iA(x),P=uW(x),P.hasBreak){E+=P.content;break}if(g=cW(x),g.hasContinue){E+=g.content;continue}x=A1(x,C,Y),x=lA(x,C),x=cA(x,C),E+=x}_=_.substring(0,z)+E+_.substring(q)}catch(F){let O=G0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,e.EVALUATION_ERROR);_=_.substring(0,z)+O+_.substring(q)}}return _}J=G(J,Z),J=rA(J,Z);let K=X?.loops?.maxWhileIterations??mA;return J=sA(J,Z,K),J}function iW($){return G8($)}function rA($,Z){let Y=$,X=!0;while(X){X=!1;let J=Y.match(/@for\s*\(/);if(!J||J.index===void 0)break;let Q=J.index,G=Q+J[0].length-1,K=v0(Y,"(",")",G);if(K===-1)break;let W=Y.slice(G+1,K),U=K+1,_=X5(Y.slice(Q),"for","endfor");if(_.length===0)break;let B=_[0].content,z=Q+_[0].end;if(!iW(W)){let q=G0("For",`Unsafe expression in @for: ${W}`,e.UNSAFE_EXPRESSION);Y=Y.substring(0,Q)+q+Y.substring(z),X=!0;continue}try{let q=Object.keys(Z),j=Object.values(Z),H=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(O,V)=>{return`\${${V}}`});H=pW(H);let F=Function(...q,`
1857
+ `)();Object.entries(K).forEach(([W,U])=>{if(U!==void 0&&!(W in Z))Z[W]=U})}catch{}}function _2($){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 B2($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var w6=D(()=>{N6()});var nW={};t(nW,{processLoops:()=>c8});function cA($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let _=X.substring(K+1,U),B=U+1,z=_.match(/^\s*['"]([^'"]+)['"]/);if(!z)continue;let q=z[1],j=_.slice(z[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=x0(L,Z),O=JSON.stringify(F),V=`@component('${q}', ${O})`;Q.push({start:G,end:B,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}return X}function d8($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,_=null,B=!1;while(U<X.length&&W>0){let j=X[U];if(B){B=!1,U++;continue}if(j==="\\"&&_){B=!0,U++;continue}if(_){if(j===_)_=null;U++;continue}if(j==='"'||j==="'"||j==="`"){_=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let z=X.substring(K+1,U),q=Y(z);X=X.substring(0,G)+q+X.substring(U+1)}return X}function lA($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(X,J)=>{if(J in Z)return`:${J}="${J}"`;return X}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(X,J,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);u$(Q);let U=F0(Q,G)(...K),B=JSON.stringify(U).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");return`__stx_${J}="${B}"`}catch(G){return X}}),Y}function pA($,Z){let Y=$;return Y=d8(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=F0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(M0(Q,Z));return G?m8:""}catch{return""}}),Y=d8(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(L0(Q)){let K=F0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(M0(Q,Z));return G?u8:""}catch{return""}}),Y}function iA($){let Z=$;return Z=Z.replace(/@break(?!\()/g,m8),Z=Z.replace(/@continue(?!\()/g,u8),Z}function uW($){let Z=$.includes(m8),Y=Z?$.substring(0,$.indexOf(m8)):$;return{hasBreak:Z,content:Y}}function cW($){let Z=$.includes(u8),Y=Z?$.substring(0,$.indexOf(u8)):$;return{hasContinue:Z,content:Y}}function pW($){let Z=$;return Z=d8(Z,"@break",(Y)=>{let X=Y.trim();if(!G8(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=d8(Z,"@continue",(Y)=>{let X=Y.trim();if(!G8(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function nA($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((_,B)=>_.pos-B.pos);let K=[],W=0;for(let _ of X)W+=_.delta,K.push({pos:_.pos,depth:W});function U(_){let B=0,z=K.length-1,q=0;while(B<=z){let j=B+z>>1;if(K[j].pos<=_)q=K[j].depth,B=j+1;else z=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let _=Y.index,B=Y.index+Y[0].length-1,z=1,q=B+1,j=-1;while(q<$.length&&z>0){if($[q]==="(")z++;else if($[q]===")"){if(z--,z===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(B+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,N=1,A=V,R=/@forelse\s*\(/g,M=/@endforelse/g,E=-1;while(N>0&&A<$.length){R.lastIndex=A,M.lastIndex=A;let x=R.exec($),g=M.exec($);if(!g)break;if(x&&x.index<g.index)N++,A=x.index+x[0].length;else{if(N--,N===0){E=g.index;break}A=g.index+11}}if(E===-1)continue;let I=$.substring(V,E),T=E+11,S=-1,k=0,C=0;while(C<I.length){let x=I.indexOf("@",C);if(x===-1)break;let g=I.substring(x);if(/^@forelse\s*\(/.test(g))k++,C=x+1;else if(g.startsWith("@endforelse"))k--,C=x+11;else if(k===0&&g.startsWith("@empty")){if(I.length<=x+6||!/[a-z]/i.test(I[x+6])){S=x;break}C=x+1}else C=x+1}if(S===-1)continue;return{start:_,end:T,arrayExpr:F,itemVar:O,foreachContent:I.substring(0,S),emptyContent:I.substring(S+6)}}return null}function lW($,Z){let Y=$;while(!0){let X=nA(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(L0(G))_=F0(G,Object.keys(Z))(...Object.values(Z));else _=M0(G,Z);let B;if(!Array.isArray(_)||_.length===0)B=U;else B=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+B+Y.substring(Q)}catch(_){let B=_ instanceof Error?_.message:String(_),z=G0("Forelse",`Error in @forelse(${G} as ${K}): ${B}`,e.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function c8($,Z,Y,X){let J=$;J=lW(J,Z);function Q(W){let U=/@foreach\s*\(/g,_;while((_=U.exec(W))!==null){let B=_.index,z=_.index+_[0].length-1,q=1,j=z+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let L=W.substring(z+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=B,V=L.substring(0,F),N=L.substring(F+4),A=H+1,R=1,M=A,E=/@foreach\s*\(/g,I=/@endforeach/g;while(R>0&&M<W.length){E.lastIndex=M,I.lastIndex=M;let T=E.exec(W),S=I.exec(W);if(!S)break;if(T&&T.index<S.index)R++,M=T.index+T[0].length;else{if(R--,R===0){let k=W.substring(A,S.index),C=S.index+11;return{start:O,end:C,arrayExpr:V,itemVar:N,content:k}}M=S.index+11}}}return null}function G(W,U){let _=W;while(!0){let B=Q(_);if(!B)break;let{start:z,end:q,arrayExpr:j,itemVar:H,content:L}=B;try{let F=j.trim(),O;if(L0(F))O=F0(F,Object.keys(U))(...Object.values(U));else O=M0(F,U);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 T=G0("Foreach",`Error in @foreach: ${F} is not iterable`,e.TYPE_ERROR);_=_.substring(0,z)+T+_.substring(q);continue}let N=X?.loops?.useAltLoopVariable??uA,A=H.trim(),R=null,M;if(A.includes("=>")){let T=A.split("=>").map((S)=>S.trim());if(T.length===2)R=T[0],M=T[1];else M=A}else M=A;let E="",I=O;for(let T=0;T<I.length;T++){let S=I[T],k={index:T,iteration:T+1,first:T===0,last:T===I.length-1,count:I.length},C={...U,loop:k,$loop:k};if(M.startsWith("[")&&M.endsWith("]")){let f=M.slice(1,-1).split(",").map((h)=>h.trim());if(Array.isArray(S))f.forEach((h,u)=>{if(h)C[h]=S[u]});else C[M]=S}else C[M]=S;if(R)if(V&&Array.isArray(S)&&S.length===2)C[R]=S[0],C[M]=S[1];else C[R]=T;let x=pA(L,C),g=cW(x);if(g.hasContinue){E+=g.content;continue}let P=uW(x);if(P.hasBreak){E+=P.content;break}if(x=lW(x,C),x=G(x,C),x=T4(x,C,Y),x=iA(x),P=uW(x),P.hasBreak){E+=P.content;break}if(g=cW(x),g.hasContinue){E+=g.content;continue}x=A1(x,C,Y),x=lA(x,C),x=cA(x,C),E+=x}_=_.substring(0,z)+E+_.substring(q)}catch(F){let O=G0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,e.EVALUATION_ERROR);_=_.substring(0,z)+O+_.substring(q)}}return _}J=G(J,Z),J=rA(J,Z);let K=X?.loops?.maxWhileIterations??mA;return J=sA(J,Z,K),J}function iW($){return G8($)}function rA($,Z){let Y=$,X=!0;while(X){X=!1;let J=Y.match(/@for\s*\(/);if(!J||J.index===void 0)break;let Q=J.index,G=Q+J[0].length-1,K=v0(Y,"(",")",G);if(K===-1)break;let W=Y.slice(G+1,K),U=K+1,_=X5(Y.slice(Q),"for","endfor");if(_.length===0)break;let B=_[0].content,z=Q+_[0].end;if(!iW(W)){let q=G0("For",`Unsafe expression in @for: ${W}`,e.UNSAFE_EXPRESSION);Y=Y.substring(0,Q)+q+Y.substring(z),X=!0;continue}try{let q=Object.keys(Z),j=Object.values(Z),H=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(O,V)=>{return`\${${V}}`});H=pW(H);let F=Function(...q,`
1858
1858
  let result = '';
1859
1859
  for (${W}) {
1860
1860
  result += \`${H}\`;
@@ -1886,15 +1886,15 @@ ${$}
1886
1886
  if (!window.stx._scopes) window.stx._scopes = {};
1887
1887
  window.stx._scopes['${Z}'] = { ${Y}, __destroyCallbacks: __destroyHooks };
1888
1888
  })();
1889
- `}function $N($,Z){let Y=$.match(/^(\s*(?:<!--[\s\S]*?-->\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function YN(){q2.clear()}function XN($){if($.__onceStore instanceof Set)return $.__onceStore;return q2}async function p8($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||E0.join(E0.dirname(Y),"partials");if(G&&!E0.isAbsolute(G)){let j=E0.resolve(__dirname,"..");G=E0.resolve(j,G)}let K=aA($,"@partial","@include"),W=XN(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(W.has(O))return"";return W.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 N=K.substring(F+1,V-1),A=N.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let R=A[1],M=U(R,G,Y),E="";if(M&&await Bun.file(M).exists())J.add(M),E=`@include(${N})`;K=K.substring(0,L)+E+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,N=1,A=V+1;while(A<K.length&&N>0){if(K[A]==="(")N++;else if(K[A]===")")N--;A++}if(N!==0)break;let R=K.substring(V+1,A-1),M=z2(R,0);if(M===-1){L.lastIndex=A;continue}let E=R.substring(0,M).trim(),I=R.substring(M+1).trim(),T=I.match(/^\s*['"]([^'"]+)['"]/);if(!T){L.lastIndex=A;continue}let S=T[1],k=I.substring(T[0].length),C,x=z2(k,0);if(x!==-1)C=k.substring(x+1).trim();try{let g=`Boolean(${E})`,P;if(L0(g)){let u=F0(g,Object.keys(Z));P=Boolean(u(...Object.values(Z)))}else P=Boolean(M0(g,Z));let f=H?!P:P,h="";if(f){let u=U(S,G,Y);if(u&&await Bun.file(u).exists())J.add(u);h=`@include('${S}'${C?`, ${C}`:""})`}K=K.substring(0,O)+h+K.substring(A),L.lastIndex=0}catch(g){let P=g instanceof Error?g.message:String(g),f=O0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+f+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 N=K.substring(F+1,V),A=K.substring(L,V+1),R=N.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let[,M,E,I,T]=R;try{let S,k=E.trim();if(L0(k))S=F0(k,Object.keys(Z))(...Object.values(Z));else S=M0(k,Z);let C="";if(Array.isArray(S)&&S.length>0)for(let x of S){let g={...Z,[I]:x},P=await B(M,g,$,L);C+=P}else if(T)C=await B(T,{},$,L);K=K.substring(0,L)+C+K.substring(V+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,L)+O0("Each",`Error in @each: ${k}`,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 N=K.substring(F+1,V),A=K.substring(L,V+1),R=N.match(/^\s*(\[[^\]]+\])/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let M=R[1],E=N.slice(R[0].length),I,T=E.match(/^\s*,\s*\{/);if(T){E=E.slice(T[0].length-1);let C=1,x=1;while(x<E.length&&C>0){if(E[x]==="{")C++;else if(E[x]==="}"){if(C--,C===0)break}x++}I=E.substring(0,x+1),E=E.slice(x+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let C=JSON.parse(M.replace(/'/g,'"')),x={};if(I)try{x=x0(I,Z)}catch(P){let f=P instanceof Error?P.message:String(P);if(X.debug){let h=O0("Include",`Error parsing includeFirst variables: ${f}`,Y,$,L,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>S||"");continue}let g=!1;for(let P of C){let f=U(P,G,Y);if(!f)continue;if(await $0(f)){let h=await B(P,x,$,L);K=K.replace(A,()=>h),g=!0;break}}if(!g)if(S!==void 0)K=K.replace(A,()=>S);else if(X.debug){let P=O0("Include",`None of the includeFirst paths exist: ${M}`,Y,$,L,A);K=K.replace(A,()=>P)}else K=K.replace(A,"")}catch(C){let x=C instanceof Error?C.message:String(C),g=O0("Include",`Error processing @includeFirst: ${x}`,Y,$,L,A);K=K.replace(A,()=>g)}j.lastIndex=0}}function U(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=E0.resolve(H),V=E0.resolve(E0.dirname(L)),N;if(!F.startsWith("./")&&!F.startsWith("../"))N=E0.resolve(H,F);else N=E0.resolve(V,F);let A=E0.normalize(N),R=A.startsWith(O+E0.sep)||A===O,M=A.startsWith(V+E0.sep)||A===V,E=!1,I=E0.dirname(V);if(A.startsWith(I+E0.sep)){if(!E0.relative(I,A).split(E0.sep).some((C)=>C.startsWith(".")&&C!=="."&&C!==".."))E=!0}if(!R&&!M&&!E)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 _=E0.resolve(Y);Q.add(_);async function B(j,H={},L,F){let O=U(j,G,Y);if(!O)return O0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=E0.resolve(O);if(Q.has(V)){let N=[...Q,V].map((A)=>E0.basename(A)).join(" -> ");return O0("Include",`Circular include detected: ${N}`,Y,L,F)}try{J.add(O);let N;if(!N)try{N=await Bun.file(O).text()}catch(P){let f=P instanceof Error?P.message:String(P);return O0("Include",`Error loading include file ${j}: ${f}`,Y,L,F)}let A=N,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 M=N.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(M)E=`<style${M[1]}>${M[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[P,f]of Object.entries(H))I[P]=f;let T=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...N.matchAll(T)],k="",C=null;for(let P of S){let f=P[1]||"",h=P[2]||"",u=f.includes("server");if(z4(f)&&h.trim())h=q4(h);let p=oA(h);if(p&&!u){C=`stx_scope_${E0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++ZN}`;let Q0=B4(h),X0=eA(Q0,C);k+=`<script data-stx-scoped>${X0}</script>
1890
- `;continue}if(u)try{let{extractVariables:Q0}=await Promise.resolve().then(() => (w4(),h8));await Q0(h,I,O)}catch(Q0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,Q0)}if(!u&&!p){let Q0=f.replace(/\bclient\b/i,"").trim();k+=`<script data-stx-scoped${Q0?` ${Q0}`:""}>${h}</script>
1891
- `}}if(C){let P=$N(A,C);if(A=P.html,P.mergedIntoExisting)k=k.replace(`window.stx._scopes['${C}']`,`window.stx._scopes['${P.mergedIntoExisting}']`),C=P.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await p8(A,I,O,X,J,Q);let{processLoops:x}=await Promise.resolve().then(() => (l8(),nW)),g=x(A,I,O);if(g=T6(g,I,O),g=A1(g,I,O),E)g+=`
1889
+ `}function $N($,Z){let Y=$.match(/^(\s*(?:<!--[\s\S]*?-->\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function YN(){q2.clear()}function XN($){if($.__onceStore instanceof Set)return $.__onceStore;return q2}async function p8($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||E0.join(E0.dirname(Y),"partials");if(G&&!E0.isAbsolute(G)){let j=E0.resolve(__dirname,"..");G=E0.resolve(j,G)}let K=aA($,"@partial","@include"),W=XN(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(W.has(O))return"";return W.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 N=K.substring(F+1,V-1),A=N.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let R=A[1],M=U(R,G,Y),E="";if(M&&await Bun.file(M).exists())J.add(M),E=`@include(${N})`;K=K.substring(0,L)+E+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,N=1,A=V+1;while(A<K.length&&N>0){if(K[A]==="(")N++;else if(K[A]===")")N--;A++}if(N!==0)break;let R=K.substring(V+1,A-1),M=z2(R,0);if(M===-1){L.lastIndex=A;continue}let E=R.substring(0,M).trim(),I=R.substring(M+1).trim(),T=I.match(/^\s*['"]([^'"]+)['"]/);if(!T){L.lastIndex=A;continue}let S=T[1],k=I.substring(T[0].length),C,x=z2(k,0);if(x!==-1)C=k.substring(x+1).trim();try{let g=`Boolean(${E})`,P;if(L0(g)){let u=F0(g,Object.keys(Z));P=Boolean(u(...Object.values(Z)))}else P=Boolean(M0(g,Z));let f=H?!P:P,h="";if(f){let u=U(S,G,Y);if(u&&await Bun.file(u).exists())J.add(u);h=`@include('${S}'${C?`, ${C}`:""})`}K=K.substring(0,O)+h+K.substring(A),L.lastIndex=0}catch(g){let P=g instanceof Error?g.message:String(g),f=O0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+f+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 N=K.substring(F+1,V),A=K.substring(L,V+1),R=N.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let[,M,E,I,T]=R;try{let S,k=E.trim();if(L0(k))S=F0(k,Object.keys(Z))(...Object.values(Z));else S=M0(k,Z);let C="";if(Array.isArray(S)&&S.length>0)for(let x of S){let g={...Z,[I]:x},P=await B(M,g,$,L);C+=P}else if(T)C=await B(T,{},$,L);K=K.substring(0,L)+C+K.substring(V+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,L)+O0("Each",`Error in @each: ${k}`,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 N=K.substring(F+1,V),A=K.substring(L,V+1),R=N.match(/^\s*(\[[^\]]+\])/);if(!R){j.lastIndex=0,K=K.replace(A,"");continue}let M=R[1],E=N.slice(R[0].length),I,T=E.match(/^\s*,\s*\{/);if(T){E=E.slice(T[0].length-1);let C=1,x=1;while(x<E.length&&C>0){if(E[x]==="{")C++;else if(E[x]==="}"){if(C--,C===0)break}x++}I=E.substring(0,x+1),E=E.slice(x+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let C=JSON.parse(M.replace(/'/g,'"')),x={};if(I)try{x=x0(I,Z)}catch(P){let f=P instanceof Error?P.message:String(P);if(X.debug){let h=O0("Include",`Error parsing includeFirst variables: ${f}`,Y,$,L,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>S||"");continue}let g=!1;for(let P of C){let f=U(P,G,Y);if(!f)continue;if(await $0(f)){let h=await B(P,x,$,L);K=K.replace(A,()=>h),g=!0;break}}if(!g)if(S!==void 0)K=K.replace(A,()=>S);else if(X.debug){let P=O0("Include",`None of the includeFirst paths exist: ${M}`,Y,$,L,A);K=K.replace(A,()=>P)}else K=K.replace(A,"")}catch(C){let x=C instanceof Error?C.message:String(C),g=O0("Include",`Error processing @includeFirst: ${x}`,Y,$,L,A);K=K.replace(A,()=>g)}j.lastIndex=0}}function U(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=E0.resolve(H),V=E0.resolve(E0.dirname(L)),N;if(!F.startsWith("./")&&!F.startsWith("../"))N=E0.resolve(H,F);else N=E0.resolve(V,F);let A=E0.normalize(N),R=A.startsWith(O+E0.sep)||A===O,M=A.startsWith(V+E0.sep)||A===V,E=!1,I=E0.dirname(V);if(A.startsWith(I+E0.sep)){if(!E0.relative(I,A).split(E0.sep).some((C)=>C.startsWith(".")&&C!=="."&&C!==".."))E=!0}if(!R&&!M&&!E)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 _=E0.resolve(Y);Q.add(_);async function B(j,H={},L,F){let O=U(j,G,Y);if(!O)return O0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=E0.resolve(O);if(Q.has(V)){let N=[...Q,V].map((A)=>E0.basename(A)).join(" -> ");return O0("Include",`Circular include detected: ${N}`,Y,L,F)}try{J.add(O);let N;if(!N)try{N=await Bun.file(O).text()}catch(P){let f=P instanceof Error?P.message:String(P);return O0("Include",`Error loading include file ${j}: ${f}`,Y,L,F)}let A=N,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 M=N.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(M)E=`<style${M[1]}>${M[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[P,f]of Object.entries(H))I[P]=f;let T=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...N.matchAll(T)],k="",C=null;for(let P of S){let f=P[1]||"",h=P[2]||"",u=f.includes("server");if(z6(f)&&h.trim())h=q6(h);let p=oA(h);if(p&&!u){C=`stx_scope_${E0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++ZN}`;let Q0=B6(h),X0=eA(Q0,C);k+=`<script data-stx-scoped>${X0}</script>
1890
+ `;continue}if(u)try{let{extractVariables:Q0}=await Promise.resolve().then(() => (w6(),h8));await Q0(h,I,O)}catch(Q0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,Q0)}if(!u&&!p){let Q0=f.replace(/\bclient\b/i,"").trim();k+=`<script data-stx-scoped${Q0?` ${Q0}`:""}>${h}</script>
1891
+ `}}if(C){let P=$N(A,C);if(A=P.html,P.mergedIntoExisting)k=k.replace(`window.stx._scopes['${C}']`,`window.stx._scopes['${P.mergedIntoExisting}']`),C=P.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await p8(A,I,O,X,J,Q);let{processLoops:x}=await Promise.resolve().then(() => (l8(),nW)),g=x(A,I,O);if(g=T4(g,I,O),g=A1(g,I,O),E)g+=`
1892
1892
  `+E;if(k)g+=`
1893
1893
  `+k;return g}catch(N){let A=N instanceof Error?N.message:String(N);return O0("Include",`Error processing include ${j}: ${A}`,Y,L,F)}}let z=/@include\s*\(/g,q;while((q=z.exec(K))!==null){let j=q.index,H=j+q[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),N=V.match(/^\s*['"]([^'"]+)['"]/);if(!N){z.lastIndex=F;continue}let A=N[1],R,M=V.substring(N[0].length),E=z2(M,0);if(E!==-1)R=M.substring(E+1).trim();let I={};if(R)try{I=x0(R,Z)}catch(S){let k=S instanceof Error?S.message:String(S);K=K.replace(O,O0("Include",`Error parsing include variables for ${A}: ${k}`,Y,$,j)),z.lastIndex=0;continue}let T=await B(A,I,$,j);K=K.substring(0,j)+T+K.substring(F),z.lastIndex=0}return K}function i8($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let _=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),B=W.match(_);if(!B||B.index===void 0)break;let z=B.index,q=B[1],j=z+B[0].length,H=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<W.length){let A=W.slice(O),R=A.match(H),M=A.match(L),E=R?O+R.index:1/0,I=M?O+M.index:1/0;if(E<I)F++,O=E+(R[0].length||1);else if(I<1/0){if(F--,F===0){V=I;break}O=I+G.length+1}else break}if(V===-1)break;let N=W.slice(j,V);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(N);else Z[q].push(N);W=W.substring(0,z)+W.substring(V+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function n8($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
1894
- `)})}var __dirname="/home/runner/work/stx/stx/packages/stx/src",ZN=0,M4,q2;var k6=D(()=>{T8();r0();j4();n0();H0();M4=new r$(500),q2=new Set});import*as j2 from"path";async function rW($,Z,Y=""){if(j2.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 aW($,Z,Y,"@js","@endjs")}async function sW($,Z,Y=""){if(j2.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return aW($,Z,Y,"@ts","@endts")}async function aW($,Z,Y,X,J){let Q=$,G=V6(`${X}([\\s\\S]*?)${J}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:_,index:B}of K)try{let z=Object.keys(Z),q=Object.values(Z),j=_.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let 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=`
1894
+ `)})}var __dirname="/home/runner/work/stx/stx/packages/stx/src",ZN=0,M6,q2;var k4=D(()=>{T8();r0();j6();n0();H0();M6=new r$(500),q2=new Set});import*as j2 from"path";async function rW($,Z,Y=""){if(j2.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 aW($,Z,Y,"@js","@endjs")}async function sW($,Z,Y=""){if(j2.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return aW($,Z,Y,"@ts","@endts")}async function aW($,Z,Y,X,J){let Q=$,G=V4(`${X}([\\s\\S]*?)${J}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:_,index:B}of K)try{let z=Object.keys(Z),q=Object.values(Z),j=_.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let 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=`
1895
1895
  ${j}
1896
1896
  ${F}
1897
- `,N=Function(...z,O)(...q);if(N&&typeof N==="object")Object.assign(Z,N);Q=Q.replace(U,"")}catch(z){console.error(`Error executing ${X} code block in ${Y}:`,z);let q=z instanceof Error?z.message:String(z),j=O0(`${X} Directive`,`Error executing code: ${q}`,Y,$,B,U);console.error(j),Q=Q.replace(U,"")}return Q}var oW=D(()=>{j4();H0()});function JN($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function tW($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return JN(X,Q||"_method")})}async function H2($,Z,Y,X,J){if(!X.middleware||X.middleware.length===0)return $;let Q=$,G=X.middleware.filter((K)=>K.timing===J);if(G.length===0)return Q;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(X.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(Q,Z,Y,X);if(typeof W==="string")Q=W;else if(X.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(X.debug)console.error(`Error in middleware ${K.name}:`,W);if(X.debug){let U=O0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
1897
+ `,N=Function(...z,O)(...q);if(N&&typeof N==="object")Object.assign(Z,N);Q=Q.replace(U,"")}catch(z){console.error(`Error executing ${X} code block in ${Y}:`,z);let q=z instanceof Error?z.message:String(z),j=O0(`${X} Directive`,`Error executing code: ${q}`,Y,$,B,U);console.error(j),Q=Q.replace(U,"")}return Q}var oW=D(()=>{j6();H0()});function JN($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function tW($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return JN(X,Q||"_method")})}async function H2($,Z,Y,X,J){if(!X.middleware||X.middleware.length===0)return $;let Q=$,G=X.middleware.filter((K)=>K.timing===J);if(G.length===0)return Q;for(let K of G){if(!K.name||typeof K.handler!=="function"){if(X.debug)console.warn("Invalid middleware:",K);continue}try{let W=await K.handler(Q,Z,Y,X);if(typeof W==="string")Q=W;else if(X.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(W){if(X.debug)console.error(`Error in middleware ${K.name}:`,W);if(X.debug){let U=O0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
1898
1898
  <div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${I0(U)}</div>
1899
1899
  `)}}}return Q}async function L2($,Z,Y,X){return H2($,Z,Y,X,"before")}async function O2($,Z,Y,X){return H2($,Z,Y,X,"after")}var F2=D(()=>{r0();H0()});import{defineRoute as nP,defineRoutes as rP,resetRoutes as sP,route as aP,setAppUrl as oP}from"stx-router";import{route as QN}from"stx-router";function eW($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,X,J,Q)=>{try{let G=J?x0(J,{}):{};return QN(X,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var $U=D(()=>{n0()});function V2($,Z,Y,X){let J=$;J=J.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,W,U)=>{if(!U&&W.includes(":")){let _=W.split(":"),B=W,z=_.length>1?_[1]:"";if(z&&Z[z])U=Z[z];else if(B.startsWith("og:")&&Z.openGraph&&Z.openGraph[_[1]])U=Z.openGraph[_[1]];else U="";return U?`<meta property="${Y0(B)}" content="${Y0(U)}">`:""}return U?`<meta name="${Y0(W)}" content="${Y0(U)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(J))!==null){let K=G.index,W=K+G[0].length-1,U=1,_=W+1;while(_<J.length&&U>0){if(J[_]==="(")U++;else if(J[_]===")"){if(U--,U===0)break}_++}if(U!==0)break;let B=J.substring(W+1,_).trim(),z=_+1,q=(()=>{try{let j=x0(B,Z);if(!j)return"";let H="<meta";if(j.name)H+=` name="${Y0(String(j.name))}"`;if(j.property)H+=` property="${Y0(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${Y0(String(j.httpEquiv))}"`;if(j.content)H+=` content="${Y0(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return G0("MetaTag",H,e.EVALUATION_ERROR)}})();J=J.substring(0,K)+q+J.substring(z),Q.lastIndex=0}return J}function A2($,Z,Y){let X=$,J=/@structuredData\s*\(/g,Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)break;let _=X.substring(K+1,U).trim(),B=U+1,z=(()=>{try{let q=x0(_,Z);if(!q)return"";if(!q["@context"])q["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(q).replace(/<\//g,"<\\/")}</script>`}catch(q){let j=q instanceof Error?q.message:String(q);return G0("StructuredData",j,e.EVALUATION_ERROR)}})();X=X.substring(0,G)+z+X.substring(B),J.lastIndex=0}return X}function N2($,Z,Y,X){let J=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(J))!==null){let K=J.indexOf("{",G.index+4),W=1,U=K+1,_=null,B=!1;while(U<J.length&&W>0){let F=J[U];if(B){B=!1,U++;continue}if(F==="\\"&&_){B=!0,U++;continue}if(_){if(F===_)_=null;U++;continue}if(F==='"'||F==="'"||F==="`"){_=F,U++;continue}if(F==="{")W++;else if(F==="}")W--;U++}if(W!==0)break;let z=J.substring(U).match(/^\s*\)/);if(!z)break;let q=U+z[0].length,j=J.substring(K,U),H=J.substring(G.index,q),L=((F)=>{try{let O=x0(F,Z);if(!O)return"";let V="";if(O.title)V+=`<title>${Y0(O.title)}</title>
1900
1900
  `,V+=`<meta name="title" content="${Y0(O.title)}">
@@ -1951,14 +1951,14 @@ ${$.map((Q)=>{let G=Q.startsWith("http")?Q:`${Y}${Q.startsWith("/")?"":"/"}${Q}`
1951
1951
  </sitemap>`}).join(`
1952
1952
  `)}
1953
1953
  </sitemapindex>`}async function UN($,Z){let{extensions:Y=[".stx",".html",".htm"],ignore:X=["_*",".*","node_modules","components","partials","layouts"]}=Z,J=[],Q=Y.length===1?`*${Y[0]}`:`*{${Y.join(",")}}`,G=new Bun.Glob(`**/${Q}`);for await(let K of G.scan($)){if(X.some((z)=>{if(z.startsWith("*"))return K.includes(z.slice(1));return K.startsWith(z)||K.includes(`/${z}`)}))continue;let U=K.replace(/\\/g,"/").replace(/index\.(stx|html|htm)$/,"").replace(/\.(stx|html|htm)$/,"");if(!U.startsWith("/"))U=`/${U}`;if(U!=="/"&&U.endsWith("/"))U=U.slice(0,-1);let _=`${$}/${K}`,B;try{let z=await Bun.file(_).stat();if(z)B=new Date(z.mtime).toISOString().split("T")[0]}catch{}J.push({loc:U||"/",lastmod:B,priority:U==="/"?1:0.5})}return J.sort((K,W)=>K.loc.localeCompare(W.loc)),J}function ZU($){let Z=[];for(let Y of $.rules){if(Z.push(`User-agent: ${Y.userAgent}`),Y.allow)for(let X of Y.allow)Z.push(`Allow: ${X}`);if(Y.disallow)for(let X of Y.disallow)Z.push(`Disallow: ${X}`);if(Y.crawlDelay!==void 0)Z.push(`Crawl-delay: ${Y.crawlDelay}`);Z.push("")}if($.sitemap){let Y=Array.isArray($.sitemap)?$.sitemap:[$.sitemap];for(let X of Y)Z.push(`Sitemap: ${X}`)}if($.host)Z.push(`Host: ${$.host}`);return Z.join(`
1954
- `).trim()}function _N($){return ZU({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function YU($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}var r8,s8;var a8=D(()=>{_1();n0();r8={name:"meta",handler:($,Z,Y,X)=>{if(Z.length<1)return G0("Meta","meta directive requires at least the meta name",e.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${Y0(J)}" content="${Y0(Q)}">`},hasEndTag:!1},s8={name:"structuredData",handler:($,Z,Y,X)=>{if($.trim()==="")return G0("StructuredData","structuredData directive requires JSON-LD content",e.INVALID_DIRECTIVE_SYNTAX);try{let J=JSON.parse($);if(!J["@context"])J["@context"]="https://schema.org";if(!J["@type"])return G0("StructuredData","structuredData requires @type property",e.INVALID_DIRECTIVE_SYNTAX);return`<script type="application/ld+json">${JSON.stringify(J)}</script>`}catch(J){let Q=J instanceof Error?J.message:String(J);return G0("StructuredData",Q,e.EVALUATION_ERROR)}},hasEndTag:!0}});async function XU($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(U5.exact[$])for(let X of U5.exact[$])await Promise.resolve(X(Z,$));if(U5.exact[Y])for(let X of U5.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of U5.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}var U5;var JU=D(()=>{U5={patterns:[],exact:{}}});function QU($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>QU(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function o8($,Z){if(!/:[\w-]+=/.test($))return $;let Y=$,X=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,J=[],Q;while((Q=X.exec($))!==null)J.push([Q.index,Q.index+Q[0].length]);function G(U){return J.some(([_,B])=>U>=_&&U<B)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,W=[];while((Q=K.exec(Y))!==null){if(G(Q.index))continue;let U=Q[0],_=Q[2];if(!_||!_.includes(":"))continue;let B=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,z,q=_,j=!1;while((z=B.exec(_))!==null){let H=z[1],L=z[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let F=Object.keys(Z),O=Object.values(Z),V=L.match(/^([a-zA-Z_$][\w$]*)/);if(V&&!F.includes(V[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(V[1]))continue;let A=Function(...F,`return (${L})`)(...O);if(H==="class"){let R=QU(A);if(R){let M=q.match(/\sclass="([^"]*)"/);if(M)q=q.replace(M[0],` class="${M[1]} ${R}"`);else q=q.replace(z[0],` class="${R}"`)}else q=q.replace(z[0],"");j=!0;continue}if(BN.has(H)){if(A)q=q.replace(z[0],` ${H}`);else q=q.replace(z[0],"");j=!0;continue}if(A===null||A===void 0||A===!1)q=q.replace(z[0],"");else{let R=String(A).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");q=q.replace(z[0],` ${H}="${R}"`)}j=!0}catch{continue}}if(j){let H=U.endsWith("/>")?" /":"",F=`<${Q[1]}${q}${H}>`;W.push({start:Q.index,end:Q.index+U.length,replacement:F})}}for(let U=W.length-1;U>=0;U--){let{start:_,end:B,replacement:z}=W[U];Y=Y.slice(0,_)+z+Y.slice(B)}return Y}var BN;var w2=D(()=>{BN=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function r4($,Z){let Y=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;Y.lastIndex=Z;let X=Y.exec($);if(!X)return null;return{full:X[0],tag:X[1],attrs:X[2],selfClosing:X[3].includes("/")||zN.has(X[1].toLowerCase()),start:X.index,end:X.index+X[0].length}}function jN($,Z,Y){let X=1,J=Y,Q=new RegExp(`<${Z}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),G=new RegExp(`</${Z}\\s*>`,"gi");while(X>0&&J<$.length){Q.lastIndex=J,G.lastIndex=J;let K=Q.exec($),W=G.exec($);if(!W)return-1;if(K&&K.index<W.index)X++,J=K.index+K[0].length;else{if(X--,X===0)return W.index+W[0].length;J=W.index+W[0].length}}return-1}function P1($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=jN($,Z.tag,Z.end);if(Y===-1)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};return{outerStart:Z.start,outerEnd:Y,innerHTML:$.slice(Z.end,Y-`</${Z.tag}>`.length)}}function GU($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function S6($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return X?X[1]:null}function E4($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return $.replace(new RegExp(`\\s*${Y}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${Y}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${Y}(?=\\s|$|>|/)`,"g"),"")}function T4($,Z,Y){let X=Z.selfClosing?" /":"",J=`<${Z.tag}${Y}${X}>`;return $.slice(0,Z.start)+J+$.slice(Z.end)}function KU($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function HN($){let Z=$,Y=0;while(Y<Z.length){let X=r4(Z,Y);if(!X)break;let J=S6(X.attrs,"v-for");if(J===null){Y=X.end;continue}let Q=J.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!Q){Y=X.end;continue}let G=Q[1].trim(),K=Q[2].trim(),W;if(G.includes(",")){let L=G.split(",").map((V)=>V.trim()),F=L[0],O=L[1];W=`${K} as ${O} => ${F}`}else W=`${K} as ${G}`;let U=E4(X.attrs,"v-for"),_=E4(U,":key").replace(/\s*v-bind:key="[^"]*"/g,""),B=P1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T4(z,{...X,start:0,end:X.end-X.start},_),j=`@foreach(${W})
1954
+ `).trim()}function _N($){return ZU({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function YU($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}var r8,s8;var a8=D(()=>{_1();n0();r8={name:"meta",handler:($,Z,Y,X)=>{if(Z.length<1)return G0("Meta","meta directive requires at least the meta name",e.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${Y0(J)}" content="${Y0(Q)}">`},hasEndTag:!1},s8={name:"structuredData",handler:($,Z,Y,X)=>{if($.trim()==="")return G0("StructuredData","structuredData directive requires JSON-LD content",e.INVALID_DIRECTIVE_SYNTAX);try{let J=JSON.parse($);if(!J["@context"])J["@context"]="https://schema.org";if(!J["@type"])return G0("StructuredData","structuredData requires @type property",e.INVALID_DIRECTIVE_SYNTAX);return`<script type="application/ld+json">${JSON.stringify(J)}</script>`}catch(J){let Q=J instanceof Error?J.message:String(J);return G0("StructuredData",Q,e.EVALUATION_ERROR)}},hasEndTag:!0}});async function XU($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(U5.exact[$])for(let X of U5.exact[$])await Promise.resolve(X(Z,$));if(U5.exact[Y])for(let X of U5.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of U5.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}var U5;var JU=D(()=>{U5={patterns:[],exact:{}}});function QU($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>QU(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function o8($,Z){if(!/:[\w-]+=/.test($))return $;let Y=$,X=/<(script|style)\b[^>]*>[\s\S]*?<\/\1>/gi,J=[],Q;while((Q=X.exec($))!==null)J.push([Q.index,Q.index+Q[0].length]);function G(U){return J.some(([_,B])=>U>=_&&U<B)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,W=[];while((Q=K.exec(Y))!==null){if(G(Q.index))continue;let U=Q[0],_=Q[2];if(!_||!_.includes(":"))continue;let B=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,z,q=_,j=!1;while((z=B.exec(_))!==null){let H=z[1],L=z[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let F=Object.keys(Z),O=Object.values(Z),V=L.match(/^([a-zA-Z_$][\w$]*)/);if(V&&!F.includes(V[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(V[1]))continue;let A=Function(...F,`return (${L})`)(...O);if(H==="class"){let R=QU(A);if(R){let M=q.match(/\sclass="([^"]*)"/);if(M)q=q.replace(M[0],` class="${M[1]} ${R}"`);else q=q.replace(z[0],` class="${R}"`)}else q=q.replace(z[0],"");j=!0;continue}if(BN.has(H)){if(A)q=q.replace(z[0],` ${H}`);else q=q.replace(z[0],"");j=!0;continue}if(A===null||A===void 0||A===!1)q=q.replace(z[0],"");else{let R=String(A).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");q=q.replace(z[0],` ${H}="${R}"`)}j=!0}catch{continue}}if(j){let H=U.endsWith("/>")?" /":"",F=`<${Q[1]}${q}${H}>`;W.push({start:Q.index,end:Q.index+U.length,replacement:F})}}for(let U=W.length-1;U>=0;U--){let{start:_,end:B,replacement:z}=W[U];Y=Y.slice(0,_)+z+Y.slice(B)}return Y}var BN;var w2=D(()=>{BN=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function r6($,Z){let Y=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*')*)?)(\s*\/?)>/g;Y.lastIndex=Z;let X=Y.exec($);if(!X)return null;return{full:X[0],tag:X[1],attrs:X[2],selfClosing:X[3].includes("/")||zN.has(X[1].toLowerCase()),start:X.index,end:X.index+X[0].length}}function jN($,Z,Y){let X=1,J=Y,Q=new RegExp(`<${Z}(?:\\s(?:[^>"']|"[^"]*"|'[^']*')*)?>`,"gi"),G=new RegExp(`</${Z}\\s*>`,"gi");while(X>0&&J<$.length){Q.lastIndex=J,G.lastIndex=J;let K=Q.exec($),W=G.exec($);if(!W)return-1;if(K&&K.index<W.index)X++,J=K.index+K[0].length;else{if(X--,X===0)return W.index+W[0].length;J=W.index+W[0].length}}return-1}function P1($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=jN($,Z.tag,Z.end);if(Y===-1)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};return{outerStart:Z.start,outerEnd:Y,innerHTML:$.slice(Z.end,Y-`</${Z.tag}>`.length)}}function GU($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function S4($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return X?X[1]:null}function E6($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return $.replace(new RegExp(`\\s*${Y}="[^"]*"`,"g"),"").replace(new RegExp(`\\s*${Y}='[^']*'`,"g"),"").replace(new RegExp(`\\s*${Y}(?=\\s|$|>|/)`,"g"),"")}function T6($,Z,Y){let X=Z.selfClosing?" /":"",J=`<${Z.tag}${Y}${X}>`;return $.slice(0,Z.start)+J+$.slice(Z.end)}function KU($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function HN($){let Z=$,Y=0;while(Y<Z.length){let X=r6(Z,Y);if(!X)break;let J=S4(X.attrs,"v-for");if(J===null){Y=X.end;continue}let Q=J.match(/^\s*\(?([^)]+)\)?\s+(?:in|of)\s+(.+)\s*$/);if(!Q){Y=X.end;continue}let G=Q[1].trim(),K=Q[2].trim(),W;if(G.includes(",")){let L=G.split(",").map((V)=>V.trim()),F=L[0],O=L[1];W=`${K} as ${O} => ${F}`}else W=`${K} as ${G}`;let U=E6(X.attrs,"v-for"),_=E6(U,":key").replace(/\s*v-bind:key="[^"]*"/g,""),B=P1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T6(z,{...X,start:0,end:X.end-X.start},_),j=`@foreach(${W})
1955
1955
  `,H=`${j}${q}
1956
- @endforeach`;Z=Z.slice(0,B.outerStart)+H+Z.slice(B.outerEnd),Y=B.outerStart+j.length}return Z}function LN($){let Z=$,Y=0;while(Y<Z.length){let X=r4(Z,Y);if(!X)break;let J=S6(X.attrs,"v-if");if(J===null){Y=X.end;continue}let Q=[],G=P1(Z,X),K=E4(X.attrs,"v-if"),W=T4(Z.slice(G.outerStart,G.outerEnd),{...X,start:0,end:X.end-X.start},K);Q.push({type:"if",expr:J,outerStart:G.outerStart,outerEnd:G.outerEnd,element:W,parsedTag:X});let U=G.outerEnd,_=!0;while(_){let H=Z.slice(U).match(/^\s*/),L=H?H[0].length:0,F=r4(Z,U+L);if(!F){_=!1;break}let O=S6(F.attrs,"v-else-if"),V=GU(F.attrs,"v-else");if(O!==null){let N=P1(Z,F),A=E4(F.attrs,"v-else-if"),R=T4(Z.slice(N.outerStart,N.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else-if",expr:O,outerStart:U,outerEnd:N.outerEnd,element:R,parsedTag:F}),U=N.outerEnd}else if(V){let N=P1(Z,F),A=E4(F.attrs,"v-else"),R=T4(Z.slice(N.outerStart,N.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else",outerStart:U,outerEnd:N.outerEnd,element:R,parsedTag:F}),_=!1}else _=!1}let B=[];for(let H of Q)if(H.type==="if")B.push(`@if(${H.expr})
1956
+ @endforeach`;Z=Z.slice(0,B.outerStart)+H+Z.slice(B.outerEnd),Y=B.outerStart+j.length}return Z}function LN($){let Z=$,Y=0;while(Y<Z.length){let X=r6(Z,Y);if(!X)break;let J=S4(X.attrs,"v-if");if(J===null){Y=X.end;continue}let Q=[],G=P1(Z,X),K=E6(X.attrs,"v-if"),W=T6(Z.slice(G.outerStart,G.outerEnd),{...X,start:0,end:X.end-X.start},K);Q.push({type:"if",expr:J,outerStart:G.outerStart,outerEnd:G.outerEnd,element:W,parsedTag:X});let U=G.outerEnd,_=!0;while(_){let H=Z.slice(U).match(/^\s*/),L=H?H[0].length:0,F=r6(Z,U+L);if(!F){_=!1;break}let O=S4(F.attrs,"v-else-if"),V=GU(F.attrs,"v-else");if(O!==null){let N=P1(Z,F),A=E6(F.attrs,"v-else-if"),R=T6(Z.slice(N.outerStart,N.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else-if",expr:O,outerStart:U,outerEnd:N.outerEnd,element:R,parsedTag:F}),U=N.outerEnd}else if(V){let N=P1(Z,F),A=E6(F.attrs,"v-else"),R=T6(Z.slice(N.outerStart,N.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else",outerStart:U,outerEnd:N.outerEnd,element:R,parsedTag:F}),_=!1}else _=!1}let B=[];for(let H of Q)if(H.type==="if")B.push(`@if(${H.expr})
1957
1957
  ${H.element}`);else if(H.type==="else-if")B.push(`@elseif(${H.expr})
1958
1958
  ${H.element}`);else B.push(`@else
1959
1959
  ${H.element}`);B.push("@endif");let z=B.join(`
1960
- `),q=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,q)+z+Z.slice(j),Y=q+z.length}return Z}function ON($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function FN($){let Z=$,Y=0;while(Y<Z.length){let X=r4(Z,Y);if(!X)break;let J=X.attrs,Q=!1,G=/v-model:([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z.]+))?\s*=\s*"([^"]*)"/,K=J.match(G);while(K){Q=!0;let _=K[1],B=K[2],z=K[3];J=J.replace(K[0],""),J+=` :${_}="${z}" @update:${_}="${z} = $event"`,K=J.match(G)}if(Q){let _=P1(Z,X),B=Z.slice(_.outerStart,_.outerEnd),z=T4(B,{...X,start:0,end:X.end-X.start},J);Z=Z.slice(0,_.outerStart)+z+Z.slice(_.outerEnd),Y=_.outerStart+z.length;continue}let W=S6(X.attrs,"v-model");if(W===null){Y=X.end;continue}if(qN.has(X.tag.toLowerCase())){let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${W}"`,B=P1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T4(z,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,B.outerStart)+q+Z.slice(B.outerEnd),Y=B.outerStart+q.length}else{let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"");_+=` :modelValue="${W}" @update:modelValue="${W} = $event"`;let B=P1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T4(z,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,B.outerStart)+q+Z.slice(B.outerEnd),Y=B.outerStart+q.length}}return Z}function VN($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function AN($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function NN($){let Z=$,Y=0;while(Y<Z.length){let X=r4(Z,Y);if(!X)break;let J=S6(X.attrs,"v-html");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=P1(Z,X),G=E4(X.attrs,"v-html"),K=X.selfClosing?" /":"",W=`<${X.tag}${G}${K}>{!! ${J} !!}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function RN($){let Z=$,Y=0;while(Y<Z.length){let X=r4(Z,Y);if(!X)break;let J=S6(X.attrs,"v-text");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=P1(Z,X),G=E4(X.attrs,"v-text"),K=X.selfClosing?" /":"",W=`<${X.tag}${G}${K}>{{ ${J} }}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function wN($){return $.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function MN($){let Z=$,Y=0;while(Y<Z.length){let X=r4(Z,Y);if(!X)break;if(!GU(X.attrs,"v-once")){Y=X.end;continue}let J=E4(X.attrs,"v-once"),Q=P1(Z,X),G=Z.slice(Q.outerStart,Q.outerEnd),W=`@once
1961
- ${T4(G,{...X,start:0,end:X.end-X.start},J)}
1960
+ `),q=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,q)+z+Z.slice(j),Y=q+z.length}return Z}function ON($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function FN($){let Z=$,Y=0;while(Y<Z.length){let X=r6(Z,Y);if(!X)break;let J=X.attrs,Q=!1,G=/v-model:([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z.]+))?\s*=\s*"([^"]*)"/,K=J.match(G);while(K){Q=!0;let _=K[1],B=K[2],z=K[3];J=J.replace(K[0],""),J+=` :${_}="${z}" @update:${_}="${z} = $event"`,K=J.match(G)}if(Q){let _=P1(Z,X),B=Z.slice(_.outerStart,_.outerEnd),z=T6(B,{...X,start:0,end:X.end-X.start},J);Z=Z.slice(0,_.outerStart)+z+Z.slice(_.outerEnd),Y=_.outerStart+z.length;continue}let W=S4(X.attrs,"v-model");if(W===null){Y=X.end;continue}if(qN.has(X.tag.toLowerCase())){let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${W}"`,B=P1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T6(z,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,B.outerStart)+q+Z.slice(B.outerEnd),Y=B.outerStart+q.length}else{let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"");_+=` :modelValue="${W}" @update:modelValue="${W} = $event"`;let B=P1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T6(z,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,B.outerStart)+q+Z.slice(B.outerEnd),Y=B.outerStart+q.length}}return Z}function VN($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function AN($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function NN($){let Z=$,Y=0;while(Y<Z.length){let X=r6(Z,Y);if(!X)break;let J=S4(X.attrs,"v-html");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=P1(Z,X),G=E6(X.attrs,"v-html"),K=X.selfClosing?" /":"",W=`<${X.tag}${G}${K}>{!! ${J} !!}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function RN($){let Z=$,Y=0;while(Y<Z.length){let X=r6(Z,Y);if(!X)break;let J=S4(X.attrs,"v-text");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=P1(Z,X),G=E6(X.attrs,"v-text"),K=X.selfClosing?" /":"",W=`<${X.tag}${G}${K}>{{ ${J} }}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function wN($){return $.replace(/(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)\s+v-pre([^>]*>)/g,"$1$2 data-stx-skip$3").replace(/(<[a-zA-Z][a-zA-Z0-9-]*)\s+v-pre(\s[^>]*>|>)/g,"$1 data-stx-skip$2")}function MN($){let Z=$,Y=0;while(Y<Z.length){let X=r6(Z,Y);if(!X)break;if(!GU(X.attrs,"v-once")){Y=X.end;continue}let J=E6(X.attrs,"v-once"),Q=P1(Z,X),G=Z.slice(Q.outerStart,Q.outerEnd),W=`@once
1961
+ ${T6(G,{...X,start:0,end:X.end-X.start},J)}
1962
1962
  @endonce`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function EN($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function TN($){return $.replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'#$1="$2"').replace(/\bv-slot:([a-zA-Z_][a-zA-Z0-9_-]*)(?=[\s>])/g,"#$1").replace(/\bv-slot\s*=\s*"([^"]*)"/g,'#default="$1"')}function M2($){if(!KU($))return $;let Z=$;return Z=HN(Z),Z=LN(Z),Z=MN(Z),Z=VN(Z),Z=AN(Z),Z=FN(Z),Z=ON(Z),Z=TN(Z),Z=NN(Z),Z=RN(Z),Z=wN(Z),Z=EN(Z),Z}var zN,qN;var E2=D(()=>{zN=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),qN=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"])});async function T2($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],slotContent:W[3],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let B=M0(_.expr,Z);if(!B||typeof B!=="string"){let O=`<!-- dynamic component: could not resolve "${_.expr}" -->`;Q=Q.slice(0,_.index)+O+Q.slice(_.index+_.full.length);continue}let z=_.attrs.trim(),q={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,H;while((H=j.exec(z))!==null){let O=H[1]||H[2],V=H[3];if(H[1])try{q[O]=M0(V,Z)}catch{q[O]=V}else q[O]=V}let L=X.componentsDir||"components",F=await y1(B,q,_.slotContent,L,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+F+Q.slice(_.index+_.full.length)}catch(B){let q=`<!-- dynamic component error: ${B instanceof Error?B.message:String(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q=await IN(Q,Z,Y,X,J),Q}async function IN($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let B=M0(_.expr,Z);if(!B||typeof B!=="string"){let j=`<!-- dynamic component: could not resolve "${_.expr}" -->`;Q=Q.slice(0,_.index)+j+Q.slice(_.index+_.full.length);continue}let z=X.componentsDir||"components",q=await y1(B,{},"",z,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}catch(B){let q=`<!-- dynamic component error: ${B instanceof Error?B.message:String(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q}var I2=D(()=>{H0();n0()});function WU($,Z=""){let Y=`${$}${Z}`,X=0;for(let J=0;J<Y.length;J++){let Q=Y.charCodeAt(J);X=(X<<5)-X+Q,X=X&X}return`stx-${Math.abs(X).toString(36)}`}function UU($,Z,Y={}){let{prefix:X="",preserveHost:J=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=D2($),W=[],U=new Map;if(Q)for(let _ of K){let B=_.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(B){let z=B[1],q=`${Z}_${z}`;U.set(z,q)}}for(let _ of K){let B=_U(_,Z,X,J,U,G);W.push(B)}return W.join(`
1963
1963
 
1964
1964
  `)}function D2($){let Z=[],Y=$.replace(/\/\*[\s\S]*?\*\//g,""),X=0,J="",Q=!1,G="";for(let K=0;K<Y.length;K++){let W=Y[K];if(W==="@"&&X===0)Q=!0;if(W==="{")X++;else if(W==="}"){if(X--,X===0){if(Q){G+=W;let U=G.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(U){let[,_,B,z]=U;if(_==="keyframes")Z.push({selector:`@keyframes ${B.trim()}`,declarations:z.trim()});else if(_==="media"||_==="supports"||_==="container"){let q=D2(z);Z.push({selector:`@${_} ${B.trim()}`,declarations:q.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
@@ -1978,7 +1978,7 @@ ${V.join(`
1978
1978
  ${N.join(`
1979
1979
  `)}
1980
1980
  </body>
1981
- </html>`}function zU($){let Z=$.trim();while(Z.startsWith("<!--")){let Y=Z.indexOf("-->");if(Y===-1)break;Z=Z.slice(Y+3).trim()}return/^<!DOCTYPE\b/i.test(Z)||/^<html[\s>]/i.test(Z)}function B5($,Z={},Y={}){if(zU($))return $;return BU($,Z,Y)}function Z9($){let Z=$,Y=new Set,X=new Set,J=()=>{if(B1)X.add(B1);return Z};return J.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),z5)X.forEach((K)=>$9.add(K));else X.forEach((K)=>K())}},J.update=(Q)=>{J.set(Q(Z))},J.subscribe=(Q)=>{return Y.add(Q),()=>Y.delete(Q)},Object.defineProperty(J,"_isSignal",{value:!0,writable:!1}),J}function Y9($){let Z,Y=!0,X=new Set,J=()=>{if(!Y)if(Y=!0,z5)X.forEach((G)=>$9.add(G));else X.forEach((G)=>G())},Q=()=>{if(B1)X.add(B1);if(Y){let G=B1;B1=J,e8.push(J);try{Z=$()}finally{e8.pop(),B1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Q}function X9($,Z={}){let Y,X=!1,J=()=>{if(X)return;if(Y)Y(),Y=void 0;let Q=B1;B1=J,e8.push(J);try{Y=$()}finally{e8.pop(),B1=Q}};if(Z.immediate!==!1)J();return()=>{if(X=!0,Y)Y()}}function J9($){if(z5){$();return}z5=!0;try{$()}finally{z5=!1,$9.forEach((Z)=>Z()),$9.clear()}}function Q9($){bN.push($)}function G9($){CN.push($)}function q5($){return typeof $==="function"&&$._isSignal===!0}function j5($){return typeof $==="function"&&$._isDerived===!0}function K9($){if(q5($)||j5($))return $();return $}function W9($){let Z=B1;B1=null;try{return $()}finally{B1=Z}}var B1=null,e8,z5=!1,$9,bN,CN;var k2=D(()=>{e8=[],$9=new Set,bN=[],CN=[]});var S2={};t(S2,{untrack:()=>K9,state:()=>Z9,peek:()=>W9,onMount:()=>Q9,onDestroy:()=>G9,isSignal:()=>q5,isDerived:()=>j5,generateSignalsRuntimeDev:()=>s4,generateSignalsRuntime:()=>H5,effect:()=>X9,derived:()=>Y9,default:()=>PN,batch:()=>J9});function H5(){try{let Z=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(s4());return Z=Z.replace(/\}(var |let |const |function )/g,"};$1"),Z}catch{return s4()}}function s4(){return`
1981
+ </html>`}function zU($){let Z=$.trim();while(Z.startsWith("<!--")){let Y=Z.indexOf("-->");if(Y===-1)break;Z=Z.slice(Y+3).trim()}return/^<!DOCTYPE\b/i.test(Z)||/^<html[\s>]/i.test(Z)}function B5($,Z={},Y={}){if(zU($))return $;return BU($,Z,Y)}function Z9($){let Z=$,Y=new Set,X=new Set,J=()=>{if(B1)X.add(B1);return Z};return J.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),z5)X.forEach((K)=>$9.add(K));else X.forEach((K)=>K())}},J.update=(Q)=>{J.set(Q(Z))},J.subscribe=(Q)=>{return Y.add(Q),()=>Y.delete(Q)},Object.defineProperty(J,"_isSignal",{value:!0,writable:!1}),J}function Y9($){let Z,Y=!0,X=new Set,J=()=>{if(!Y)if(Y=!0,z5)X.forEach((G)=>$9.add(G));else X.forEach((G)=>G())},Q=()=>{if(B1)X.add(B1);if(Y){let G=B1;B1=J,e8.push(J);try{Z=$()}finally{e8.pop(),B1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Q}function X9($,Z={}){let Y,X=!1,J=()=>{if(X)return;if(Y)Y(),Y=void 0;let Q=B1;B1=J,e8.push(J);try{Y=$()}finally{e8.pop(),B1=Q}};if(Z.immediate!==!1)J();return()=>{if(X=!0,Y)Y()}}function J9($){if(z5){$();return}z5=!0;try{$()}finally{z5=!1,$9.forEach((Z)=>Z()),$9.clear()}}function Q9($){bN.push($)}function G9($){CN.push($)}function q5($){return typeof $==="function"&&$._isSignal===!0}function j5($){return typeof $==="function"&&$._isDerived===!0}function K9($){if(q5($)||j5($))return $();return $}function W9($){let Z=B1;B1=null;try{return $()}finally{B1=Z}}var B1=null,e8,z5=!1,$9,bN,CN;var k2=D(()=>{e8=[],$9=new Set,bN=[],CN=[]});var S2={};t(S2,{untrack:()=>K9,state:()=>Z9,peek:()=>W9,onMount:()=>Q9,onDestroy:()=>G9,isSignal:()=>q5,isDerived:()=>j5,generateSignalsRuntimeDev:()=>s6,generateSignalsRuntime:()=>H5,effect:()=>X9,derived:()=>Y9,default:()=>PN,batch:()=>J9});function H5(){try{let Z=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(s6());return Z=Z.replace(/\}(var |let |const |function )/g,"};$1"),Z}catch{return s6()}}function s6(){return`
1982
1982
  // STX Signals Runtime (Development Build)
1983
1983
  console.log('[stx] signals runtime loading');
1984
1984
  // Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
@@ -5984,7 +5984,7 @@ catch (e) { console.warn('[stx] mount callback error:', e); }
5984
5984
  }
5985
5985
  }
5986
5986
  })();
5987
- `}var PN;var L5=D(()=>{k2();k2();PN={state:Z9,derived:Y9,effect:X9,batch:J9,onMount:Q9,onDestroy:G9,isSignal:q5,isDerived:j5,untrack:K9,peek:W9,generateSignalsRuntime:H5,generateSignalsRuntimeDev:s4}});var C2={};t(C2,{templateCache:()=>b2,readFileCached:()=>qU,invalidateFileCacheByDir:()=>HU,invalidateFileCache:()=>jU,hashFilePath:()=>C6,getCachedSignalsRuntime:()=>LU,getCachedRouterScript:()=>OU,clearDevCaches:()=>FU,checkCache:()=>B9,cacheTemplate:()=>z9});import a4 from"fs";import b6 from"path";async function qU($){try{let Y=(await a4.promises.stat($)).mtime.getTime(),X=o4.get($);if(X&&X.mtime===Y)return X.content;let J=await Bun.file($).text();return o4.set($,{content:J,mtime:Y}),J}catch{throw o4.delete($),Error(`File not found: ${$}`)}}function jU($){o4.delete($)}function HU($){for(let Z of o4.keys())if(Z.startsWith($))o4.delete(Z)}async function LU($=!1){if($){let{generateSignalsRuntimeDev:Z}=await Promise.resolve().then(() => (L5(),S2));return Z()}if(U9===null){let{generateSignalsRuntime:Z}=await Promise.resolve().then(() => (L5(),S2));U9=Z()}return U9}async function OU(){if(_9===null){let{getRouterScript:$}=await import("stx-router");_9=$()}return _9}function FU(){o4.clear(),U9=null,yN=null,_9=null}async function B9($,Z){try{if(!Z.cachePath)return null;let Y=b6.resolve(Z.cachePath),X=b6.join(Y,`${C6($)}.html`),J=b6.join(Y,`${C6($)}.meta.json`);if(!await $0(X)||!await $0(J))return null;let Q=await Bun.file(J).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if((await a4.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await $0(W)){if((await a4.promises.stat(W)).mtime.getTime()>G.mtime)return null}else return null;return await Bun.file(X).text()}catch(Y){return console.warn(`Cache error for ${$}:`,Y),null}}async function z9($,Z,Y,X){try{if(!X.cachePath)return;let J=b6.resolve(X.cachePath);await a4.promises.mkdir(J,{recursive:!0});let Q=b6.join(J,`${C6($)}.html`),G=b6.join(J,`${C6($)}.meta.json`),K=await a4.promises.stat($);await Bun.write(Q,Z);let W={sourcePath:$,mtime:K.mtime.getTime(),dependencies:Array.from(Y),cacheVersion:X.cacheVersion,generatedAt:Date.now()};await Bun.write(G,JSON.stringify(W,null,2)),b2.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(J){console.warn(`Failed to cache template ${$}:`,J)}}function C6($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,xN)}var b2,o4,U9=null,yN=null,_9=null,xN=16;var q9=D(()=>{H0();b2=new Map,o4=new Map});function VU($){if($.includes("window.StacksBrowser")||$.includes("StacksBrowser ="))return $;let Z=/<script\b(?![^>]*\bserver\b)[^>]*>([\s\S]*?)<\/script>/gi,Y="",X;while((X=Z.exec($))!==null)Y+=X[1]+`
5987
+ `}var PN;var L5=D(()=>{k2();k2();PN={state:Z9,derived:Y9,effect:X9,batch:J9,onMount:Q9,onDestroy:G9,isSignal:q5,isDerived:j5,untrack:K9,peek:W9,generateSignalsRuntime:H5,generateSignalsRuntimeDev:s6}});var C2={};t(C2,{templateCache:()=>b2,readFileCached:()=>qU,invalidateFileCacheByDir:()=>HU,invalidateFileCache:()=>jU,hashFilePath:()=>C4,getCachedSignalsRuntime:()=>LU,getCachedRouterScript:()=>OU,clearDevCaches:()=>FU,checkCache:()=>B9,cacheTemplate:()=>z9});import a6 from"fs";import b4 from"path";async function qU($){try{let Y=(await a6.promises.stat($)).mtime.getTime(),X=o6.get($);if(X&&X.mtime===Y)return X.content;let J=await Bun.file($).text();return o6.set($,{content:J,mtime:Y}),J}catch{throw o6.delete($),Error(`File not found: ${$}`)}}function jU($){o6.delete($)}function HU($){for(let Z of o6.keys())if(Z.startsWith($))o6.delete(Z)}async function LU($=!1){if($){let{generateSignalsRuntimeDev:Z}=await Promise.resolve().then(() => (L5(),S2));return Z()}if(U9===null){let{generateSignalsRuntime:Z}=await Promise.resolve().then(() => (L5(),S2));U9=Z()}return U9}async function OU(){if(_9===null){let{getRouterScript:$}=await import("stx-router");_9=$()}return _9}function FU(){o6.clear(),U9=null,yN=null,_9=null}async function B9($,Z){try{if(!Z.cachePath)return null;let Y=b4.resolve(Z.cachePath),X=b4.join(Y,`${C4($)}.html`),J=b4.join(Y,`${C4($)}.meta.json`);if(!await $0(X)||!await $0(J))return null;let Q=await Bun.file(J).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if((await a6.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await $0(W)){if((await a6.promises.stat(W)).mtime.getTime()>G.mtime)return null}else return null;return await Bun.file(X).text()}catch(Y){return console.warn(`Cache error for ${$}:`,Y),null}}async function z9($,Z,Y,X){try{if(!X.cachePath)return;let J=b4.resolve(X.cachePath);await a6.promises.mkdir(J,{recursive:!0});let Q=b4.join(J,`${C4($)}.html`),G=b4.join(J,`${C4($)}.meta.json`),K=await a6.promises.stat($);await Bun.write(Q,Z);let W={sourcePath:$,mtime:K.mtime.getTime(),dependencies:Array.from(Y),cacheVersion:X.cacheVersion,generatedAt:Date.now()};await Bun.write(G,JSON.stringify(W,null,2)),b2.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(J){console.warn(`Failed to cache template ${$}:`,J)}}function C4($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,xN)}var b2,o6,U9=null,yN=null,_9=null,xN=16;var q9=D(()=>{H0();b2=new Map,o6=new Map});function VU($){if($.includes("window.StacksBrowser")||$.includes("StacksBrowser ="))return $;let Z=/<script\b(?![^>]*\bserver\b)[^>]*>([\s\S]*?)<\/script>/gi,Y="",X;while((X=Z.exec($))!==null)Y+=X[1]+`
5988
5988
  `;let J=/\{\{([\s\S]*?)\}\}/g;while((X=J.exec($))!==null)Y+=X[1]+`
5989
5989
  `;if(!Y.trim())return $;let G=["browserQuery","BrowserQueryBuilder","configureBrowser","createBrowserModel"].some((z)=>{return new RegExp(`\\b${z}\\b`).test(Y)}),K=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process"]),W=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,U,_=!1;while((U=W.exec(Y))!==null)if(!K.has(U[1])){_=!0;break}if(!G&&!_)return $;let B=`<script type="module">
5990
5990
  // STX: Auto-load @stacksjs/browser (auto-initializes API and loads models)
@@ -6004,7 +6004,7 @@ ${B}`);return B+`
6004
6004
  `}let{getCachedRouterScript:J}=await Promise.resolve().then(() => (q9(),C2)),Q=Z?.buildMode==="compile"?'<script src="/__stx/router.__STX_HASH__.js"></script>':`<script>${await J()}</script>`,G=$.lastIndexOf("</body>");return $.slice(0,G)+X+Q+`
6005
6005
  </body>`+$.slice(G+7)}var TU={};t(TU,{scanScriptTags:()=>RU,processSignals:()=>x2,processScriptSetup:()=>MU,parseLoopExpression:()=>wU,hasSignalsSyntax:()=>j9,extractExports:()=>EU,convertSignalLoopsToAttributes:()=>y2,convertSignalDirectivesToAttributes:()=>P2});function RU($,Z={}){let Y=[],X=/<script\b([^>]*)>/gi,J;while((J=X.exec($))!==null){let Q=J[1],G=J.index+J[0].length,K=$.toLowerCase().indexOf("</script>",G);if(K===-1)break;let W=K+9;if(Z.skipAttrs&&Z.skipAttrs.test(Q)){X.lastIndex=W;continue}Y.push({fullMatch:$.slice(J.index,W),attrs:Q,body:$.slice(G,K),start:J.index,end:W}),X.lastIndex=W}return Y}function wU($){let Z=$.trim(),Y=Z.match(/^([\s\S]+?)\s+as\s+(.+)$/);if(Y){let J=Y[1].trim(),Q=Y[2].trim(),{itemVar:G,indexVar:K}=NU(Q);if(G)return{style:"as",iterable:J,itemVar:G,indexVar:K}}let X=Z.match(/^(\([^)]+\)|\w+(?:\s*,\s*\w+)?)\s+(?:in|of)\s+([\s\S]+)$/);if(X){let J=X[1].trim(),Q=X[2].trim(),{itemVar:G,indexVar:K}=NU(J);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function NU($){let Z=$.trim(),Y=Z.match(/^(\w+)\s*=>\s*(\w+)$/);if(Y)return{itemVar:Y[2],indexVar:Y[1]};let X=Z.match(/^\(\s*(\w+)(?:\s*,\s*(\w+))?\s*\)$/);if(X)return{itemVar:X[1],indexVar:X[2]||null};let J=Z.match(/^(\w+)\s*,\s*(\w+)$/);if(J)return{itemVar:J[1],indexVar:J[2]};let Q=Z.match(/^(\w+)$/);if(Q)return{itemVar:Q[1],indexVar:null};return{itemVar:null,indexVar:null}}function j9($){return[/@if\s*=/,/@for\s*=/,/@show\s*=/,/@model\s*=/,/@bind:/,/@class\s*=/,/@style\s*=/,/\bx-data\s*=/,/\bstate\s*(?:<[^>]*>)?\s*\(/,/\bderived\s*(?:<[^>]*>)?\s*\(/,/\beffect\s*(?:<[^>]*>)?\s*\(/,/\bref\s*(?:<[^>]*>)?\s*\(/,/\bcomputed\s*(?:<[^>]*>)?\s*\(/,/\breactive\s*(?:<[^>]*>)?\s*\(/,/\bwatch\s*(?:<[^>]*>)?\s*\(/,/\bwatchEffect\s*(?:<[^>]*>)?\s*\(/,/data-stx(?:-auto)?(?![-\w])/,/data-stx-scoped/].some((Y)=>Y.test($))}function gN($){let Z=/@(if\s*\(|endif|elseif\s*\(|else\b)/g,Y=0,X;while((X=Z.exec($))!==null){let J=X[1];if(J.startsWith("if"))Y++;else if(J==="endif")Y--;else if(Y===0)return!0}return!1}function P2($){let Z=$,Y=/@if\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.substring(G,W-1).trim(),_=W,B=1,z=_,q=/@(if\s*\(|endif)/g;q.lastIndex=_;let j;while((j=q.exec(Z))!==null)if(j[1].startsWith("if"))B++;else if(j[1]==="endif"){if(B--,B===0){z=j.index+j[0].length;break}}if(B!==0)continue;let H=Z.substring(_,z-6).trim();if(gN(H))continue;let L=H.match(/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s),F;if(L){let[,O,V,N]=L,A=U.replace(/"/g,"&quot;");F=`<${O}${V} @if="${A}">${N}</${O}>`}else F=`<template @if="${U.replace(/"/g,"&quot;")}">${H}</template>`;J.push({start:Q,end:z,replacement:F})}for(let Q=J.length-1;Q>=0;Q--){let{start:G,end:K,replacement:W}=J[Q];Z=Z.substring(0,G)+W+Z.substring(K)}return Z}function y2($,Z){let Y=$,X=/@(for|foreach)\s*\(/g,J,Q=[];while((J=X.exec(Y))!==null){let G=J[1],K=J.index,W=K+J[0].length,U=1,_=W;while(_<Y.length&&U>0){if(Y[_]==="(")U++;else if(Y[_]===")")U--;_++}if(U!==0)continue;let B=Y.substring(W,_-1).trim(),z=_,q=wU(B);if(q.iterable){let R=q.iterable.trim();if(R.startsWith("[")||R.startsWith("{")||R.startsWith("'")||R.startsWith('"')||R.startsWith("`")||/^-?\d/.test(R))continue;if(Z){let M=R.split(/[.[(]/)[0].trim();if(M&&M in Z)continue}}if(q.style==="as")B=q.indexVar?`(${q.itemVar}, ${q.indexVar}) in ${q.iterable}`:`${q.itemVar} in ${q.iterable}`;let j=G==="for"?"@endfor":"@endforeach",H=1,L=z,F=G==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${G}\\s*\\(|end${G})`,"g");F.lastIndex=z;let O;while((O=F.exec(Y))!==null)if(O[1].startsWith(G))H++;else if(H--,H===0){L=O.index+O[0].length;break}if(H!==0)continue;let V=Y.substring(z,L-j.length).trim(),N=V.match(/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s),A;if(N){let[,R,M,E]=N;A=`<${R}${M} @for="${B}">${E}</${R}>`}else A=`<template @for="${B}">${V}</template>`;Q.push({start:K,end:L,replacement:A})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Y=Y.substring(0,K)+U+Y.substring(W)}return Y}function fN($){let Z=new Set,Y=[],X=0,J=0,Q=$.length,G=(_)=>{let B=X+1;while(B<Q){let z=$[B];if(z==="\\"){B+=2;continue}if(z===_)return B+1;B++}return Q},K=()=>{let _=X+2;while(_<Q&&$[_]!==`
6006
6006
  `)_++;return _},W=()=>{let _=X+2;while(_<Q-1){if($[_]==="*"&&$[_+1]==="/")return _+2;_++}return Q},U=(_)=>{let B=_,z=0;while(B<Q){let q=$[B];if(q==="/"&&$[B+1]==="/"){let j=B+2;while(j<Q&&$[j]!==`
6007
- `)j++;B=j;continue}if(q==="/"&&$[B+1]==="*"){let j=B+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;B=j+2;continue}if(q==='"'||q==="'"||q==="`"){let j=B+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===q){j++;break}j++}B=j;continue}if(q==="("||q==="["||q==="{"){z++,B++;continue}if(q===")"||q==="]"||q==="}"){z--,B++;continue}if(q===";"&&z===0)return B+1;B++}return Q};while(X<Q){let _=$[X];if(_==="/"&&$[X+1]==="/"){let B=K();Y.push($.slice(X,B)),X=B;continue}if(_==="/"&&$[X+1]==="*"){let B=W();Y.push($.slice(X,B)),X=B;continue}if(_==='"'||_==="'"||_==="`"){let B=G(_);Y.push($.slice(X,B)),X=B;continue}if(_==="{"){J++,Y.push(_),X++;continue}if(_==="}"){J--,Y.push(_),X++;continue}if(J===0){let B=X>0?$[X-1]:"";if(B===""||/\s/.test(B)||B===";"||B==="}"||B==="{"){let q=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(q){let j=q[2],H=U(X+q[0].length);if(Z.has(j)){Y.push(`/* stx: deduped const ${j} */`),X=H;continue}Z.add(j),Y.push($.slice(X,H)),X=H;continue}}}Y.push(_),X++}return Y.join("")}async function MU($,Z){let Y=RU($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),X=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy)\s*(?:<[^>]*>)?\s*\(/,J=[];for(let q of Y){let j=q.body;if(z4(q.attrs))j=q4(j);if(X.test(j))J.push({fullMatch:q.fullMatch,attrs:q.attrs,content:j})}if(J.length===0)return{output:$,setupCode:null};let Q=`__stx_setup_${Date.now()}_${vN++}`,{hasUserImports:G,bundleClientScript:K}=await Promise.resolve().then(() => (jZ(),qZ)),W=[];for(let q=0;q<J.length;q++){let j=J[q].content;if(G(j))console.log("[stx:bundler] bundling signal script imports"),j=await K(j,Z||"",{projectRoot:process.cwd()});j=j.replace(/^\s*import\s+(?:type\s+)?\{[^}]*\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,"// [stx import stripped \u2014 resolved via window.stx in __stx_setup]");let H=B4(j);W.push(`// \u2500\u2500 merged signal script #${q+1} \u2500\u2500
6007
+ `)j++;B=j;continue}if(q==="/"&&$[B+1]==="*"){let j=B+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;B=j+2;continue}if(q==='"'||q==="'"||q==="`"){let j=B+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===q){j++;break}j++}B=j;continue}if(q==="("||q==="["||q==="{"){z++,B++;continue}if(q===")"||q==="]"||q==="}"){z--,B++;continue}if(q===";"&&z===0)return B+1;B++}return Q};while(X<Q){let _=$[X];if(_==="/"&&$[X+1]==="/"){let B=K();Y.push($.slice(X,B)),X=B;continue}if(_==="/"&&$[X+1]==="*"){let B=W();Y.push($.slice(X,B)),X=B;continue}if(_==='"'||_==="'"||_==="`"){let B=G(_);Y.push($.slice(X,B)),X=B;continue}if(_==="{"){J++,Y.push(_),X++;continue}if(_==="}"){J--,Y.push(_),X++;continue}if(J===0){let B=X>0?$[X-1]:"";if(B===""||/\s/.test(B)||B===";"||B==="}"||B==="{"){let q=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(q){let j=q[2],H=U(X+q[0].length);if(Z.has(j)){Y.push(`/* stx: deduped const ${j} */`),X=H;continue}Z.add(j),Y.push($.slice(X,H)),X=H;continue}}}Y.push(_),X++}return Y.join("")}async function MU($,Z){let Y=RU($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),X=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy)\s*(?:<[^>]*>)?\s*\(/,J=[];for(let q of Y){let j=q.body;if(z6(q.attrs))j=q6(j);if(X.test(j))J.push({fullMatch:q.fullMatch,attrs:q.attrs,content:j})}if(J.length===0)return{output:$,setupCode:null};let Q=`__stx_setup_${Date.now()}_${vN++}`,{hasUserImports:G,bundleClientScript:K}=await Promise.resolve().then(() => (jZ(),qZ)),W=[];for(let q=0;q<J.length;q++){let j=J[q].content;if(G(j))console.log("[stx:bundler] bundling signal script imports"),j=await K(j,Z||"",{projectRoot:process.cwd()});j=j.replace(/^\s*import\s+(?:type\s+)?\{[^}]*\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm,"// [stx import stripped \u2014 resolved via window.stx in __stx_setup]");let H=B6(j);W.push(`// \u2500\u2500 merged signal script #${q+1} \u2500\u2500
6008
6008
  ${H}`)}let U=W.join(`
6009
6009
 
6010
6010
  `);U=fN(U);let _=EU(U),B=`
@@ -6048,8 +6048,8 @@ ${k}
6048
6048
  @media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
6049
6049
  .stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
6050
6050
  .stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
6051
- </style>`}}});var vU={};t(vU,{preloadIconCollection:()=>xU,IconBuiltin:()=>O9});async function yU($){if(V5.has($))return V5.get($);try{let Z=a.resolve(`@iconify/json/json/${$}.json`),Y=await Bun.file(Z).json();return V5.set($,Y.icons),Y.icons}catch{try{let Y=`${process.cwd()}/node_modules/@iconify/json/json/${$}.json`,X=Bun.file(Y);if(await X.exists()){let J=await X.json();return V5.set($,J.icons),J.icons}}catch{}}return null}function P6($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function xU($="lucide"){await yU($)}var V5,O9;var F9=D(()=>{V5=new Map;O9={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=P6($,"name")??P6($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let O=X.split(":");J=O[0],Q=O[1]}let G=P6($,"size")||"24",K=P6($,"color")||"currentColor",W=P6($,"class")||"",U=P6($,"style")||"",_=V5.get(J);if(!_)return yU(J),`<!-- Icon: collection "${J}" not loaded -->`;let B=_[Q];if(!B)return`<!-- Icon: "${Q}" not found in ${J} -->`;let z=B.width||24,q=B.height||24,j=`0 0 ${z} ${q}`,H=B.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let L=W?` class="${W}"`:"",F=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${L}${F}>${H}</svg>`}}});function gU(){e1.registerBuiltin(h2),e1.registerBuiltin(l2),e1.registerBuiltin(n2),e1.registerBuiltin(s2),e1.registerBuiltin(o2),e1.registerBuiltin(O9)}var fU=D(()=>{d2();p2();r2();a2();t2();F9();f2();d2();p2();r2();a2();t2();F9()});function hU($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function dU($,Z,Y){let X=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){J=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;J=H+1;continue}let U=Q+1+W.length,_=null,B=U,z=-1,q=!1;while(U<$.length){let H=$[U];if(_){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===_)_=null;U++;continue}if(H==='"'||H==="'"){_=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){z=U+2,q=!0;break}if(H===">"){z=U+1;break}U++}if(z===-1){J=Q+1;continue}let j=$.slice(B,q?z-2:z-1).trim();if(q)X.push({fullMatch:$.slice(Q,z),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:z,isSelfClosing:!0}),J=z;else{let H=`<${W}`,L=`</${W}>`,F=1,O=z,V=-1;while(F>0&&O<$.length){let R=$.indexOf(H,O),M=$.indexOf(L,O);if(M===-1)break;if(R!==-1&&R<M){let E=$[R+H.length];if(E===" "||E===">"||E==="/"||E===`
6052
- `||E==="\t")F++;O=R+H.length}else{if(F--,F===0){V=M;break}O=M+L.length}}if(V===-1){J=z;continue}let N=$.slice(z,V),A=V+L.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:N,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}var mU=D(()=>{n0();H0()});import y6 from"path";function pN($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]);for(let[Q,G]of Object.entries($)){let K=Q.startsWith("x-")&&!J.has(Q)&&!Q.startsWith("x-bind:")&&!Q.startsWith("x-on:")?`:${Q.slice(2)}`:Q;if(K.startsWith("@")){X.events[K]=G;continue}if(K.startsWith("__stx_")){let W=K.slice(6);try{let U=G.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");X.serverDynamic[W]=JSON.parse(U)}catch(U){if(Y.debug)console.error(`Error parsing __stx_${W}:`,U);X.serverDynamic[W]=G}continue}if(K.startsWith(":")){let W=K.slice(1),U=G==="true"?W:G;try{if(!L0(U)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${U}`);X.clientReactive[W]=U;continue}let _=Object.keys(Z),z=F0(U,_)(...Object.values(Z));if(z===void 0){let q=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],j=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(q.some((L)=>!j.has(L)&&!_.includes(L))){X.clientReactive[W]=U;continue}}X.serverDynamic[W]=z}catch{X.clientReactive[W]=U}continue}if(typeof G==="string"&&G.includes("{{")&&G.includes("}}")){let W=G.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let U=W[1];if(L0(U)){let B=F0(U,Object.keys(Z))(...Object.values(Z));X.static[K]=B!=null?String(B):""}else{if(Y.debug)console.error(`Unsafe expression in ${K}: ${U}`);X.static[K]=G}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${K}:`,U);X.static[K]=G}else{let U=G,_=/\{\{\s*([\s\S]+?)\s*\}\}/g,B;while((B=_.exec(G))!==null)try{let z=B[1];if(!L0(z)){if(Y.debug)console.error(`Unsafe expression in ${K}: ${z}`);continue}let j=F0(z,Object.keys(Z))(...Object.values(Z));U=U.replace(B[0],String(j??""))}catch(z){if(Y.debug)console.error(`Error evaluating expression in ${K}:`,z)}X.static[K]=U}continue}X.static[K]=G}return X}function iN($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]="true"}return Z}async function nN($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,_]=W,B=_.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of B){let q=z.split("/"),H=q[q.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=[y6.resolve(y6.dirname(Y),`${z}.stx`),y6.resolve(y6.dirname(Y),z),y6.resolve(X.componentsDir||"components",`${z}.stx`),y6.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.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),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function rN($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let _=U.index,B=_+U[0].length-1,z=1,q=B+1;while(q<Q.length&&z>0){if(Q[q]==="(")z++;else if(Q[q]===")"){if(z--,z===0)break}q++}if(z!==0)break;let j=Q.substring(B+1,q),H=q+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){W.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),N=V.match(/^\s*,\s*/);if(N)O=V.slice(N[0].length).trim();let A={};if(O)try{A=x0(O,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(_,H),`[Error parsing component props: ${k}]`);continue}let R="",M=H,I=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)R=I[1].trim(),M=H+I[0].length;let T=await y1(F,A,R,G,Z,Y,X,K,J);Q=Q.substring(0,_)+T+Q.substring(M),W.lastIndex=0}return Q}async function sN($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents;return Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,lN),Q;async function B(z,q,j,H){if(!z)return z;let L=z,F=dU(L,q,H);for(let O=F.length-1;O>=0;O--){let V=F[O],N=j?hU(V.tagName):V.tagName,A=iN(V.attributes),R=pN(A,Z,X),M=e1.getBuiltin(V.tagName);if(M){let S={context:Z,filePath:Y,options:X,dependencies:J},k=M.render(R,V.content,S);if(Object.keys(R.clientReactive).length>0)k=cU(k,R.clientReactive);if(Object.keys(R.events).length>0){let C=Object.entries(R.events).map(([x,g])=>`${x}="${g.replace(/"/g,"&quot;")}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${C}`)}L=L.substring(0,V.startIndex)+k+L.substring(V.endIndex);continue}let E={};for(let[S,k]of Object.entries(R.static))E[S]=k;for(let[S,k]of Object.entries(R.serverDynamic))E[S]=k;let T=await y1(N,E,V.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)T=cU(T,R.clientReactive);if(Object.keys(R.events).length>0){let S=T.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(S){let k=Object.entries(R.events).map(([x,g])=>`${x}="${g}"`).join(" "),C=S[1].length+S[2].length;T=T.substring(0,C)+" "+k+T.substring(C)}}L=L.substring(0,V.startIndex)+T+L.substring(V.endIndex)}return L}}function cU($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function e2($,Z,Y,X,J){if(!uU)gU(),uU=!0;let Q=await nN($,Z,Y,X,J);Q=await rN(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await sN(Q,Z,Y,X,J),Q===K)break}return Q}var uU=!1,lN;var lU=D(()=>{f2();fU();mU();H0();n0();lN=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"])});import x6 from"path";function pU($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}function iU($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=x6.join(J,$);if(a("fs").existsSync(G))return G;J=x6.dirname(J)}X=x6.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=x6.resolve(Z,$);else X=x6.resolve(Z,$);if(a("fs").existsSync(X))return X;return null}catch{return null}}async function nU($,Z,Y){let X=$,J=x6.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,B,z]=G;if(pU(B))continue;let q=iU(B,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),B.endsWith(".ts")||B.endsWith(".tsx")){let L=await Bun.build({entrypoints:[q],target:"browser",minify:!1});if(L.outputs.length>0)j=await L.outputs[0].text()}let H=`<script>
6051
+ </style>`}}});var vU={};t(vU,{preloadIconCollection:()=>xU,IconBuiltin:()=>O9});async function yU($){if(V5.has($))return V5.get($);try{let Z=a.resolve(`@iconify/json/json/${$}.json`),Y=await Bun.file(Z).json();return V5.set($,Y.icons),Y.icons}catch{try{let Y=`${process.cwd()}/node_modules/@iconify/json/json/${$}.json`,X=Bun.file(Y);if(await X.exists()){let J=await X.json();return V5.set($,J.icons),J.icons}}catch{}}return null}function P4($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function xU($="lucide"){await yU($)}var V5,O9;var F9=D(()=>{V5=new Map;O9={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=P4($,"name")??P4($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let O=X.split(":");J=O[0],Q=O[1]}let G=P4($,"size")||"24",K=P4($,"color")||"currentColor",W=P4($,"class")||"",U=P4($,"style")||"",_=V5.get(J);if(!_)return yU(J),`<!-- Icon: collection "${J}" not loaded -->`;let B=_[Q];if(!B)return`<!-- Icon: "${Q}" not found in ${J} -->`;let z=B.width||24,q=B.height||24,j=`0 0 ${z} ${q}`,H=B.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let L=W?` class="${W}"`:"",F=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${L}${F}>${H}</svg>`}}});function gU(){e1.registerBuiltin(h2),e1.registerBuiltin(l2),e1.registerBuiltin(n2),e1.registerBuiltin(s2),e1.registerBuiltin(o2),e1.registerBuiltin(O9)}var fU=D(()=>{d2();p2();r2();a2();t2();F9();f2();d2();p2();r2();a2();t2();F9()});function hU($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function dU($,Z,Y){let X=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){J=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;J=H+1;continue}let U=Q+1+W.length,_=null,B=U,z=-1,q=!1;while(U<$.length){let H=$[U];if(_){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===_)_=null;U++;continue}if(H==='"'||H==="'"){_=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){z=U+2,q=!0;break}if(H===">"){z=U+1;break}U++}if(z===-1){J=Q+1;continue}let j=$.slice(B,q?z-2:z-1).trim();if(q)X.push({fullMatch:$.slice(Q,z),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:z,isSelfClosing:!0}),J=z;else{let H=`<${W}`,L=`</${W}>`,F=1,O=z,V=-1;while(F>0&&O<$.length){let R=$.indexOf(H,O),M=$.indexOf(L,O);if(M===-1)break;if(R!==-1&&R<M){let E=$[R+H.length];if(E===" "||E===">"||E==="/"||E===`
6052
+ `||E==="\t")F++;O=R+H.length}else{if(F--,F===0){V=M;break}O=M+L.length}}if(V===-1){J=z;continue}let N=$.slice(z,V),A=V+L.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:N,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}var mU=D(()=>{n0();H0()});import y4 from"path";function pN($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]);for(let[Q,G]of Object.entries($)){let K=Q.startsWith("x-")&&!J.has(Q)&&!Q.startsWith("x-bind:")&&!Q.startsWith("x-on:")?`:${Q.slice(2)}`:Q;if(K.startsWith("@")){X.events[K]=G;continue}if(K.startsWith("__stx_")){let W=K.slice(6);try{let U=G.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");X.serverDynamic[W]=JSON.parse(U)}catch(U){if(Y.debug)console.error(`Error parsing __stx_${W}:`,U);X.serverDynamic[W]=G}continue}if(K.startsWith(":")){let W=K.slice(1),U=G==="true"?W:G;try{if(!L0(U)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${U}`);X.clientReactive[W]=U;continue}let _=Object.keys(Z),z=F0(U,_)(...Object.values(Z));if(z===void 0){let q=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],j=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(q.some((L)=>!j.has(L)&&!_.includes(L))){X.clientReactive[W]=U;continue}}X.serverDynamic[W]=z}catch{X.clientReactive[W]=U}continue}if(typeof G==="string"&&G.includes("{{")&&G.includes("}}")){let W=G.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let U=W[1];if(L0(U)){let B=F0(U,Object.keys(Z))(...Object.values(Z));X.static[K]=B!=null?String(B):""}else{if(Y.debug)console.error(`Unsafe expression in ${K}: ${U}`);X.static[K]=G}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${K}:`,U);X.static[K]=G}else{let U=G,_=/\{\{\s*([\s\S]+?)\s*\}\}/g,B;while((B=_.exec(G))!==null)try{let z=B[1];if(!L0(z)){if(Y.debug)console.error(`Unsafe expression in ${K}: ${z}`);continue}let j=F0(z,Object.keys(Z))(...Object.values(Z));U=U.replace(B[0],String(j??""))}catch(z){if(Y.debug)console.error(`Error evaluating expression in ${K}:`,z)}X.static[K]=U}continue}X.static[K]=G}return X}function iN($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]="true"}return Z}async function nN($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,_]=W,B=_.split(",").map((z)=>z.trim().replace(/^['"]|['"]$/g,"")).filter((z)=>z.length>0);for(let z of B){let q=z.split("/"),H=q[q.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=[y4.resolve(y4.dirname(Y),`${z}.stx`),y4.resolve(y4.dirname(Y),z),y4.resolve(X.componentsDir||"components",`${z}.stx`),y4.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.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),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function rN($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let _=U.index,B=_+U[0].length-1,z=1,q=B+1;while(q<Q.length&&z>0){if(Q[q]==="(")z++;else if(Q[q]===")"){if(z--,z===0)break}q++}if(z!==0)break;let j=Q.substring(B+1,q),H=q+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){W.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),N=V.match(/^\s*,\s*/);if(N)O=V.slice(N[0].length).trim();let A={};if(O)try{A=x0(O,Z)}catch(S){let k=S instanceof Error?S.message:String(S);Q=Q.replace(Q.substring(_,H),`[Error parsing component props: ${k}]`);continue}let R="",M=H,I=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)R=I[1].trim(),M=H+I[0].length;let T=await y1(F,A,R,G,Z,Y,X,K,J);Q=Q.substring(0,_)+T+Q.substring(M),W.lastIndex=0}return Q}async function sN($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents;return Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,lN),Q;async function B(z,q,j,H){if(!z)return z;let L=z,F=dU(L,q,H);for(let O=F.length-1;O>=0;O--){let V=F[O],N=j?hU(V.tagName):V.tagName,A=iN(V.attributes),R=pN(A,Z,X),M=e1.getBuiltin(V.tagName);if(M){let S={context:Z,filePath:Y,options:X,dependencies:J},k=M.render(R,V.content,S);if(Object.keys(R.clientReactive).length>0)k=cU(k,R.clientReactive);if(Object.keys(R.events).length>0){let C=Object.entries(R.events).map(([x,g])=>`${x}="${g.replace(/"/g,"&quot;")}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${C}`)}L=L.substring(0,V.startIndex)+k+L.substring(V.endIndex);continue}let E={};for(let[S,k]of Object.entries(R.static))E[S]=k;for(let[S,k]of Object.entries(R.serverDynamic))E[S]=k;let T=await y1(N,E,V.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)T=cU(T,R.clientReactive);if(Object.keys(R.events).length>0){let S=T.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(S){let k=Object.entries(R.events).map(([x,g])=>`${x}="${g}"`).join(" "),C=S[1].length+S[2].length;T=T.substring(0,C)+" "+k+T.substring(C)}}L=L.substring(0,V.startIndex)+T+L.substring(V.endIndex)}return L}}function cU($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let X=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function e2($,Z,Y,X,J){if(!uU)gU(),uU=!0;let Q=await nN($,Z,Y,X,J);Q=await rN(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await sN(Q,Z,Y,X,J),Q===K)break}return Q}var uU=!1,lN;var lU=D(()=>{f2();fU();mU();H0();n0();lN=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"])});import x4 from"path";function pU($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}function iU($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=x4.join(J,$);if(a("fs").existsSync(G))return G;J=x4.dirname(J)}X=x4.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=x4.resolve(Z,$);else X=x4.resolve(Z,$);if(a("fs").existsSync(X))return X;return null}catch{return null}}async function nU($,Z,Y){let X=$,J=x4.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,B,z]=G;if(pU(B))continue;let q=iU(B,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),B.endsWith(".ts")||B.endsWith(".tsx")){let L=await Bun.build({entrypoints:[q],target:"browser",minify:!1});if(L.outputs.length>0)j=await L.outputs[0].text()}let H=`<script>
6053
6053
  // Source: ${B}
6054
6054
  ${j}
6055
6055
  </script>`;X=X.replace(U,H),Q.lastIndex=0}catch(j){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,W;while((W=K.exec(X))!==null){let[U,_,B,z]=W,q=_+z;if(pU(B))continue;if(/rel=["']stylesheet["']/.test(q)||B.endsWith(".css")){let H=iU(B,J,Z);if(H)try{let L=await Bun.file(H).text();Y.add(H);let F=`<style>
@@ -6060,12 +6060,12 @@ ${L}
6060
6060
  \u2192 ${W}`)}}if(Q.length>0&&X.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
6061
6061
  ${Q.join(`
6062
6062
  `)}
6063
- Tip: prefer useRef(), navigate(), and composables for component code`;if(X.failOnViolation)throw Error(K);else console.warn(K)}}var aN;var YY=D(()=>{aN=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/window\.localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}]});var oU={};t(oU,{getStoreScript:()=>oN,clearStoreCache:()=>tN});import V9 from"path";async function oN($){let Z;if($)Z=V9.resolve($);else{let _=await f0();Z=V9.resolve(_.root||process.cwd(),_.storesDir||"stores")}let Y=v6.get(Z);if(Y!==void 0)return Y||null;let X=new Bun.Glob("*.ts"),J=[];try{for await(let _ of X.scan({cwd:Z,absolute:!0})){let B=V9.basename(_,".ts");if(["index","types"].includes(B))continue;if(_.includes(".d.ts"))continue;J.push(_)}}catch{return v6.set(Z,""),null}if(J.length===0)return v6.set(Z,""),null;let Q=[];for(let _ of J){let B=await Bun.file(_).text();Q.push({file:_,hasUseStore:/useStore\s*\(/.test(B)})}Q.sort((_,B)=>{if(_.hasUseStore===B.hasUseStore)return 0;return _.hasUseStore?1:-1});let G=Q.map((_)=>_.file),K=[],W=new Bun.Transpiler({loader:"ts",target:"browser"});for(let _ of G)try{let B=await Bun.file(_).text(),z=V9.basename(_,".ts");B=B.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),B=B.replace(/^export\s+(default\s+)?/gm,""),B=W.transformSync(B),K.push(`// Store: ${z}
6064
- ${B.trim()}`)}catch(B){console.warn(`[stx] Failed to load store ${_}:`,B)}if(K.length===0)return v6.set(Z,""),null;let U=`;(function(){
6063
+ Tip: prefer useRef(), navigate(), and composables for component code`;if(X.failOnViolation)throw Error(K);else console.warn(K)}}var aN;var YY=D(()=>{aN=[{pattern:/document\.getElementById\s*\(/g,message:"document.getElementById() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelector\s*\(/g,message:"document.querySelector() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.querySelectorAll\s*\(/g,message:"document.querySelectorAll() is prohibited",suggestion:'Use useRef("name") and access children instead'},{pattern:/document\.getElementsBy\w+\s*\(/g,message:"document.getElementsBy*() is prohibited",suggestion:'Use useRef("name") instead'},{pattern:/document\.createElement\s*\(/g,message:"document.createElement() is prohibited",suggestion:"Use template directives or component composition instead"},{pattern:/document\.activeElement(?![A-Za-z])/g,message:"document.activeElement is prohibited",suggestion:"Use useRef() to track focused elements"},{pattern:/document\.title\s*=/g,message:"document.title assignment is prohibited",suggestion:"Use useTitle() from composables"},{pattern:/document\.cookie(?![A-Za-z])/g,message:"document.cookie is prohibited",suggestion:"Use useCookie() from composables"},{pattern:/document\.addEventListener\s*\(/g,message:"document.addEventListener() is prohibited",suggestion:"Use useEventListener() or template @event directives"},{pattern:/window\.location(?![A-Za-z])/g,message:"window.location is prohibited",suggestion:"Use navigate() or useRoute()"},{pattern:/window\.history(?![A-Za-z])/g,message:"window.history is prohibited",suggestion:"Use navigate(), goBack(), goForward()"},{pattern:/window\.addEventListener\s*\(/g,message:"window.addEventListener() is prohibited",suggestion:"Use useEventListener() or @click directives"},{pattern:/window\.localStorage(?![A-Za-z])/g,message:"window.localStorage is prohibited",suggestion:"Use useLocalStorage() from composables"},{pattern:/window\.sessionStorage(?![A-Za-z])/g,message:"window.sessionStorage is prohibited",suggestion:"Use useSessionStorage() from composables"},{pattern:/window\.scrollTo\s*\(/g,message:"window.scrollTo() is prohibited",suggestion:"Use useScroll().scrollTo() from composables"},{pattern:/window\.alert\s*\(/g,message:"window.alert() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.confirm\s*\(/g,message:"window.confirm() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/window\.prompt\s*\(/g,message:"window.prompt() is prohibited",suggestion:"Use stx modal/dialog APIs instead"},{pattern:/(?<!\w)setTimeout\s*\(/g,message:"setTimeout() is prohibited",suggestion:"Use useTimeout() or useDebounce() from composables"},{pattern:/(?<!\w)setInterval\s*\(/g,message:"setInterval() is prohibited",suggestion:"Use useInterval() from composables"},{pattern:/(?<!\w)clearTimeout\s*\(/g,message:"clearTimeout() is prohibited",suggestion:"Use useTimeout().stop() or useDebounce().cancel()"},{pattern:/(?<!\w)clearInterval\s*\(/g,message:"clearInterval() is prohibited",suggestion:"Use useInterval().pause()"},{pattern:/(?<!\w)location\.href\s*=/g,message:"location.href assignment is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.assign\s*\(/g,message:"location.assign() is prohibited",suggestion:"Use navigate() instead"},{pattern:/(?<!\w)location\.replace\s*\(/g,message:"location.replace() is prohibited",suggestion:"Use navigate() instead"}]});var oU={};t(oU,{getStoreScript:()=>oN,clearStoreCache:()=>tN});import V9 from"path";async function oN($){let Z;if($)Z=V9.resolve($);else{let _=await f0();Z=V9.resolve(_.root||process.cwd(),_.storesDir||"stores")}let Y=v4.get(Z);if(Y!==void 0)return Y||null;let X=new Bun.Glob("*.ts"),J=[];try{for await(let _ of X.scan({cwd:Z,absolute:!0})){let B=V9.basename(_,".ts");if(["index","types"].includes(B))continue;if(_.includes(".d.ts"))continue;J.push(_)}}catch{return v4.set(Z,""),null}if(J.length===0)return v4.set(Z,""),null;let Q=[];for(let _ of J){let B=await Bun.file(_).text();Q.push({file:_,hasUseStore:/useStore\s*\(/.test(B)})}Q.sort((_,B)=>{if(_.hasUseStore===B.hasUseStore)return 0;return _.hasUseStore?1:-1});let G=Q.map((_)=>_.file),K=[],W=new Bun.Transpiler({loader:"ts",target:"browser"});for(let _ of G)try{let B=await Bun.file(_).text(),z=V9.basename(_,".ts");B=B.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),B=B.replace(/^export\s+(default\s+)?/gm,""),B=W.transformSync(B),K.push(`// Store: ${z}
6064
+ ${B.trim()}`)}catch(B){console.warn(`[stx] Failed to load store ${_}:`,B)}if(K.length===0)return v4.set(Z,""),null;let U=`;(function(){
6065
6065
  ${K.join(`
6066
6066
 
6067
6067
  `)}
6068
- })();`;return v6.set(Z,U),U}function tN(){v6.clear()}var v6;var tU=D(()=>{u0();v6=new Map});var Z_={};t(Z_,{processDeferDirectives:()=>$_});function eN(){return`stx-defer-${++eU}`}function $R($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function ZR($,Z,Y){let{trigger:X,value:J}=$R(Z),Q=Y,G,K,W,U=Y.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(U)G=U[1].trim(),Q=Q.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let _=Y.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(_)K=_[1].trim(),Q=Q.replace(/@loading[\s\S]*?(?=@error|$)/,"");let B=Y.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(B)W=B[2].trim(),Q=Q.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return Q=Q.trim(),{trigger:X,triggerValue:J,content:Q,placeholder:G,loading:K,error:W}}function YR($,Z){let{trigger:Y,triggerValue:X}=Z,J;switch(Y){case"visible":J=`
6068
+ })();`;return v4.set(Z,U),U}function tN(){v4.clear()}var v4;var tU=D(()=>{u0();v4=new Map});var Z_={};t(Z_,{processDeferDirectives:()=>$_});function eN(){return`stx-defer-${++eU}`}function $R($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function ZR($,Z,Y){let{trigger:X,value:J}=$R(Z),Q=Y,G,K,W,U=Y.match(/@placeholder\s*([\s\S]*?)(?=@loading|@error|$)/);if(U)G=U[1].trim(),Q=Q.replace(/@placeholder[\s\S]*?(?=@loading|@error|$)/,"");let _=Y.match(/@loading\s*([\s\S]*?)(?=@error|$)/);if(_)K=_[1].trim(),Q=Q.replace(/@loading[\s\S]*?(?=@error|$)/,"");let B=Y.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(B)W=B[2].trim(),Q=Q.replace(/@error(?:\s*\(\s*\w+\s*\))?[\s\S]*$/,"");return Q=Q.trim(),{trigger:X,triggerValue:J,content:Q,placeholder:G,loading:K,error:W}}function YR($,Z){let{trigger:Y,triggerValue:X}=Z,J;switch(Y){case"visible":J=`
6069
6069
  const observer = new IntersectionObserver((entries) => {
6070
6070
  if (entries[0].isIntersecting) {
6071
6071
  observer.disconnect();
@@ -8281,8 +8281,8 @@ else {
8281
8281
  });
8282
8282
  })();
8283
8283
  </script>
8284
- `}function zY($,Z={},Y){let X=$,J=!1,Q=/@client:(load|idle|visible|media|only|hover|event)/i.test($);if(X=g6(X,"load",Z),X=g6(X,"idle",Z),X=g6(X,"visible",Z),X=g6(X,"media",Z),X=CR(X),X=g6(X,"hover",Z),X=g6(X,"event",Z),J=Q&&X!==$,J)X+=`
8285
- `+WY();return X}function g6($,Z,Y){let X=new RegExp(`@client:${Z}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return $.replace(X,(J,Q,G)=>{let K={strategy:Z};if(Q)try{let H=Q.split(",").map((L)=>L.trim());for(let L of H){let[F,O]=L.split(":").map((V)=>V.trim());if(F&&O){let V=O.replace(/^['"]|['"]$/g,"");K[F]=V}}}catch{}let W=`island-${Math.random().toString(36).substring(2,9)}`,U=UY(G.trim()),_=_Y(G.trim(),Y),B=[];if(K.rootMargin)B.push(`data-root-margin="${K.rootMargin}"`);if(K.threshold!==void 0)B.push(`data-threshold="${K.threshold}"`);if(K.media)B.push(`data-media="${K.media}"`);if(K.event)B.push(`data-event="${K.event}"`);if(U)B.push(`data-component="${U}"`);let q=Object.keys(_).length>0?`
8284
+ `}function zY($,Z={},Y){let X=$,J=!1,Q=/@client:(load|idle|visible|media|only|hover|event)/i.test($);if(X=g4(X,"load",Z),X=g4(X,"idle",Z),X=g4(X,"visible",Z),X=g4(X,"media",Z),X=CR(X),X=g4(X,"hover",Z),X=g4(X,"event",Z),J=Q&&X!==$,J)X+=`
8285
+ `+WY();return X}function g4($,Z,Y){let X=new RegExp(`@client:${Z}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return $.replace(X,(J,Q,G)=>{let K={strategy:Z};if(Q)try{let H=Q.split(",").map((L)=>L.trim());for(let L of H){let[F,O]=L.split(":").map((V)=>V.trim());if(F&&O){let V=O.replace(/^['"]|['"]$/g,"");K[F]=V}}}catch{}let W=`island-${Math.random().toString(36).substring(2,9)}`,U=UY(G.trim()),_=_Y(G.trim(),Y),B=[];if(K.rootMargin)B.push(`data-root-margin="${K.rootMargin}"`);if(K.threshold!==void 0)B.push(`data-threshold="${K.threshold}"`);if(K.media)B.push(`data-media="${K.media}"`);if(K.event)B.push(`data-event="${K.event}"`);if(U)B.push(`data-component="${U}"`);let q=Object.keys(_).length>0?`
8286
8286
  <script type="application/json" data-island-props="${W}">${JSON.stringify(_)}</script>`:"",j="";switch(Z){case"load":j=TR(W);break;case"idle":j=IR(W,K);break;case"visible":j=DR(W,K);break;case"media":j=kR(W,K);break;case"hover":j=SR(W);break;case"event":j=bR(W,K);break}return`
8287
8287
  <div data-island="${W}"
8288
8288
  data-strategy="${Z}"
@@ -8357,7 +8357,7 @@ else {
8357
8357
  <script type="application/json" id="stx-island-manifest">
8358
8358
  ${JSON.stringify(Z)}
8359
8359
  </script>
8360
- `}var PR;var NY=D(()=>{PR={processPartialHydrationDirectives:zY,processStaticDirectives:VY,generatePartialHydrationCSS:qY,generateIslandManifest:AY,createIslandRegistry:BY,hydrateIsland:jY,hydrateByStrategy:HY,hydrateAll:LY,isHydrated:OY,onHydrated:FY}});var $B={};t($B,{watchMultiple:()=>r_,watchEffect:()=>s_,watch:()=>n_,unref:()=>l_,toRefs:()=>p_,throttledComputed:()=>e_,stxWatchMultiple:()=>r_,stxWatchEffect:()=>s_,stxWatch:()=>n_,stxUnref:()=>l_,stxToRefs:()=>p_,stxThrottledComputed:()=>e_,stxShallowRef:()=>i_,stxRef:()=>f6,stxIsRef:()=>I4,stxDebouncedComputed:()=>t_,stxComputed:()=>M5,shallowRef:()=>i_,ref:()=>f6,processWatchDirectives:()=>o_,processComputedDirectives:()=>a_,isRef:()=>I4,default:()=>yR,debouncedComputed:()=>t_,computed:()=>M5});function f6($){let Z=$,Y=new Set,X={get value(){if(v1){let J=w5.get(X);if(!J)J=new Set,w5.set(X,J);J.add(v1)}return Z},set value(J){if(!Object.is(Z,J)){Z=J,Y.forEach((G)=>G(J));let Q=w5.get(X);if(Q)Q.forEach((G)=>G())}},subscribe(J){return Y.add(J),()=>Y.delete(J)},peek(){return Z}};return X}function I4($){return $!==null&&typeof $==="object"&&"value"in $&&"subscribe"in $&&"peek"in $}function l_($){return I4($)?$.value:$}function p_($){let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=f6($[Y]);return Z}function i_($){return f6($)}function M5($){let Z=typeof $==="function",Y=Z?$:$.get,X=Z?void 0:$.set,J=Z?Object.is:$.equals||Object.is,Q,G=!0,K=new Set,W=new Set,U=()=>{if(G=!0,W.size>0){let z=B.value;W.forEach((q)=>q(z))}};function _(){K.clear();let z=v1;v1=U,R9.push(U);try{return Y()}finally{R9.pop(),v1=z}}let B={get value(){if(v1){let z=w5.get(B);if(!z)z=new Set,w5.set(B,z);z.add(v1)}if(G){let z=_();if(!J(Q,z))Q=z;G=!1}return Q},set value(z){if(X)X(z);else console.warn("Computed property is readonly")},subscribe(z){return W.add(z),()=>W.delete(z)},peek(){if(G)Q=Y(),G=!1;return Q},invalidate(){G=!0},get dirty(){return G},get deps(){return K}};return B}function n_($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="pre",once:G=!1}=Y,K,W=!0,U=!1,_=()=>{if(I4($))return J?t4($.value):$.value;return $()},B=()=>{if(!W||U)return;let j=_();if(K!==void 0&&Object.is(K,j)&&!J)return;let H=()=>{if(Z(j,K),K=J?t4(j):j,G)q()};if(Q==="sync")H();else if(Q==="post")queueMicrotask(H);else Promise.resolve().then(H)},z=null;if(I4($))z=$.subscribe(()=>B());else z=M5($).subscribe(()=>B());if(X)K=void 0,B();else K=_();let q=()=>{if(W=!1,z)z(),z=null};return q.pause=()=>{U=!0},q.resume=()=>{U=!1},q}function r_($,Z,Y={}){let{immediate:X=!1,once:J=!1}=Y,Q=$.map((B)=>I4(B)?B.value:void 0),G=!0,K=!1,W=()=>{if(!G||K)return;let B=$.map((z)=>I4(z)?z.value:void 0);if(Z(B,Q),Q=[...B],J)_()},U=$.map((B)=>{if(I4(B))return B.subscribe(()=>W());return()=>{}});if(X)W();let _=()=>{G=!1,U.forEach((B)=>B())};return _.pause=()=>{K=!0},_.resume=()=>{K=!1},_}function s_($,Z={}){let{flush:Y="pre"}=Z,X,J=!0,Q=!1,G=()=>{if(!J||Q)return;if(X)X();let W=v1;v1=G,R9.push(G);try{X=$()}finally{R9.pop(),v1=W}};if(Y==="sync")G();else if(Y==="post")queueMicrotask(G);else Promise.resolve().then(G);let K=()=>{if(J=!1,X)X()};return K.pause=()=>{Q=!0},K.resume=()=>{Q=!1},K}function a_($,Z={},Y){let X=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return $.replace(X,(J,Q,G)=>{try{let W=Function(...Object.keys(Z),`return ${G}`)(...Object.values(Z));return Z[Q]=W,`<!-- computed: ${Q} = ${W} -->`}catch(K){return`<!-- computed error: ${Q} - ${K} -->`}})}function o_($,Z={},Y){let X=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return $.replace(X,(J,Q,G)=>{return`
8360
+ `}var PR;var NY=D(()=>{PR={processPartialHydrationDirectives:zY,processStaticDirectives:VY,generatePartialHydrationCSS:qY,generateIslandManifest:AY,createIslandRegistry:BY,hydrateIsland:jY,hydrateByStrategy:HY,hydrateAll:LY,isHydrated:OY,onHydrated:FY}});var $B={};t($B,{watchMultiple:()=>r_,watchEffect:()=>s_,watch:()=>n_,unref:()=>l_,toRefs:()=>p_,throttledComputed:()=>e_,stxWatchMultiple:()=>r_,stxWatchEffect:()=>s_,stxWatch:()=>n_,stxUnref:()=>l_,stxToRefs:()=>p_,stxThrottledComputed:()=>e_,stxShallowRef:()=>i_,stxRef:()=>f4,stxIsRef:()=>I6,stxDebouncedComputed:()=>t_,stxComputed:()=>M5,shallowRef:()=>i_,ref:()=>f4,processWatchDirectives:()=>o_,processComputedDirectives:()=>a_,isRef:()=>I6,default:()=>yR,debouncedComputed:()=>t_,computed:()=>M5});function f4($){let Z=$,Y=new Set,X={get value(){if(v1){let J=w5.get(X);if(!J)J=new Set,w5.set(X,J);J.add(v1)}return Z},set value(J){if(!Object.is(Z,J)){Z=J,Y.forEach((G)=>G(J));let Q=w5.get(X);if(Q)Q.forEach((G)=>G())}},subscribe(J){return Y.add(J),()=>Y.delete(J)},peek(){return Z}};return X}function I6($){return $!==null&&typeof $==="object"&&"value"in $&&"subscribe"in $&&"peek"in $}function l_($){return I6($)?$.value:$}function p_($){let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=f4($[Y]);return Z}function i_($){return f4($)}function M5($){let Z=typeof $==="function",Y=Z?$:$.get,X=Z?void 0:$.set,J=Z?Object.is:$.equals||Object.is,Q,G=!0,K=new Set,W=new Set,U=()=>{if(G=!0,W.size>0){let z=B.value;W.forEach((q)=>q(z))}};function _(){K.clear();let z=v1;v1=U,R9.push(U);try{return Y()}finally{R9.pop(),v1=z}}let B={get value(){if(v1){let z=w5.get(B);if(!z)z=new Set,w5.set(B,z);z.add(v1)}if(G){let z=_();if(!J(Q,z))Q=z;G=!1}return Q},set value(z){if(X)X(z);else console.warn("Computed property is readonly")},subscribe(z){return W.add(z),()=>W.delete(z)},peek(){if(G)Q=Y(),G=!1;return Q},invalidate(){G=!0},get dirty(){return G},get deps(){return K}};return B}function n_($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="pre",once:G=!1}=Y,K,W=!0,U=!1,_=()=>{if(I6($))return J?t6($.value):$.value;return $()},B=()=>{if(!W||U)return;let j=_();if(K!==void 0&&Object.is(K,j)&&!J)return;let H=()=>{if(Z(j,K),K=J?t6(j):j,G)q()};if(Q==="sync")H();else if(Q==="post")queueMicrotask(H);else Promise.resolve().then(H)},z=null;if(I6($))z=$.subscribe(()=>B());else z=M5($).subscribe(()=>B());if(X)K=void 0,B();else K=_();let q=()=>{if(W=!1,z)z(),z=null};return q.pause=()=>{U=!0},q.resume=()=>{U=!1},q}function r_($,Z,Y={}){let{immediate:X=!1,once:J=!1}=Y,Q=$.map((B)=>I6(B)?B.value:void 0),G=!0,K=!1,W=()=>{if(!G||K)return;let B=$.map((z)=>I6(z)?z.value:void 0);if(Z(B,Q),Q=[...B],J)_()},U=$.map((B)=>{if(I6(B))return B.subscribe(()=>W());return()=>{}});if(X)W();let _=()=>{G=!1,U.forEach((B)=>B())};return _.pause=()=>{K=!0},_.resume=()=>{K=!1},_}function s_($,Z={}){let{flush:Y="pre"}=Z,X,J=!0,Q=!1,G=()=>{if(!J||Q)return;if(X)X();let W=v1;v1=G,R9.push(G);try{X=$()}finally{R9.pop(),v1=W}};if(Y==="sync")G();else if(Y==="post")queueMicrotask(G);else Promise.resolve().then(G);let K=()=>{if(J=!1,X)X()};return K.pause=()=>{Q=!0},K.resume=()=>{Q=!1},K}function a_($,Z={},Y){let X=/@computed\s*\(\s*(\w+)\s*,\s*(.+?)\s*\)/gi;return $.replace(X,(J,Q,G)=>{try{let W=Function(...Object.keys(Z),`return ${G}`)(...Object.values(Z));return Z[Q]=W,`<!-- computed: ${Q} = ${W} -->`}catch(K){return`<!-- computed error: ${Q} - ${K} -->`}})}function o_($,Z={},Y){let X=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return $.replace(X,(J,Q,G)=>{return`
8361
8361
  <script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
8362
8362
  (function() {
8363
8363
  // Watch implementation for ${Q}
@@ -8369,9 +8369,9 @@ else {
8369
8369
  }
8370
8370
  })();
8371
8371
  </script>
8372
- `})}function t4($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>t4(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((X,J)=>Y.set(t4(J),t4(X))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((X)=>Y.add(t4(X))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=t4($[Y]);return Z}function t_($,Z=100){let Y=f6($()),X=null,J=()=>{if(X)clearTimeout(X);X=setTimeout(()=>{Y.value=$()},Z)};return M5($).subscribe(()=>J()),{get value(){return Y.value},set value(G){console.warn("Debounced computed is readonly")},subscribe:Y.subscribe,peek:Y.peek,invalidate(){J()},get dirty(){return!1},get deps(){return new Set}}}function e_($,Z=100){let Y=f6($()),X=0,J=()=>{let G=Date.now();if(G-X>=Z)X=G,Y.value=$()};return M5($).subscribe(()=>J()),{get value(){return Y.value},set value(G){console.warn("Throttled computed is readonly")},subscribe:Y.subscribe,peek:Y.peek,invalidate(){J()},get dirty(){return!1},get deps(){return new Set}}}var v1=null,R9,w5,yR;var ZB=D(()=>{R9=[],w5=new WeakMap;yR={ref:f6,computed:M5,watch:n_,watchMultiple:r_,watchEffect:s_,isRef:I4,unref:l_,toRefs:p_,shallowRef:i_,debouncedComputed:t_,throttledComputed:e_,processComputedDirectives:a_,processWatchDirectives:o_}});var QB={};t(QB,{v:()=>xR,processHasErrorsDirective:()=>JB,processFormValidationDirectives:()=>gR,processErrorsDirective:()=>XB,processErrorDirective:()=>YB,defineForm:()=>vR,Validator:()=>h6});class h6{rules=[];defaultValue="";addRule($){let Z=new h6;return Z.rules=[...this.rules,$],Z.defaultValue=this.defaultValue,Z}required($="This field is required"){return this.addRule({name:"required",message:$,validate:(Z)=>{if(Z===null||Z===void 0)return $;if(typeof Z==="string"&&Z.trim()==="")return $;if(Array.isArray(Z)&&Z.length===0)return $;return!0}})}email($="Please enter a valid email"){return this.addRule({name:"email",message:$,validate:(Z)=>{if(!Z)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(Z))||$}})}url($="Please enter a valid URL"){return this.addRule({name:"url",message:$,validate:(Z)=>{if(!Z)return!0;try{return new URL(String(Z)),!0}catch{return $}}})}min($,Z){let Y=Z||`Must be at least ${$} characters`;return this.addRule({name:"min",message:Y,validate:(X)=>{if(!X)return!0;return String(X).length>=$||Y}})}max($,Z){let Y=Z||`Must be no more than ${$} characters`;return this.addRule({name:"max",message:Y,validate:(X)=>{if(!X)return!0;return String(X).length<=$||Y}})}length($,Z,Y){let X=Y||`Must be between ${$} and ${Z} characters`;return this.addRule({name:"length",message:X,validate:(J)=>{if(!J)return!0;let Q=String(J).length;return Q>=$&&Q<=Z||X}})}pattern($,Z="Invalid format"){return this.addRule({name:"pattern",message:Z,validate:(Y)=>{if(!Y)return!0;return $.test(String(Y))||Z}})}hasUppercase($="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,$)}hasLowercase($="Must contain a lowercase letter"){return this.pattern(/[a-z]/,$)}hasNumber($="Must contain a number"){return this.pattern(/\d/,$)}hasSpecial($="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,$)}alphanumeric($="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,$)}startsWithLetter($="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,$)}noSpaces($="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:$,validate:(Z)=>{if(!Z)return!0;return!String(Z).includes(" ")||$}})}number($="Must be a number"){let Z=this.addRule({name:"number",message:$,validate:(Y)=>{if(!Y&&Y!==0)return!0;return!Number.isNaN(Number(Y))||$}});return Z.defaultValue=0,Z}integer($="Must be a whole number"){return this.addRule({name:"integer",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number.isInteger(Number(Z))||$}})}positive($="Must be a positive number"){return this.addRule({name:"positive",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number(Z)>0||$}})}negative($="Must be a negative number"){return this.addRule({name:"negative",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number(Z)<0||$}})}minValue($,Z){let Y=Z||`Must be at least ${$}`;return this.addRule({name:"minValue",message:Y,validate:(X)=>{if(!X&&X!==0)return!0;return Number(X)>=$||Y}})}maxValue($,Z){let Y=Z||`Must be no more than ${$}`;return this.addRule({name:"maxValue",message:Y,validate:(X)=>{if(!X&&X!==0)return!0;return Number(X)<=$||Y}})}between($,Z,Y){let X=Y||`Must be between ${$} and ${Z}`;return this.addRule({name:"between",message:X,validate:(J)=>{if(!J&&J!==0)return!0;let Q=Number(J);return Q>=$&&Q<=Z||X}})}matches($,Z){let Y=Z||`Must match ${$}`;return this.addRule({name:"matches",message:Y,validate:(X,J)=>{if(!J)return!0;return X===J[$]||Y}})}oneOf($,Z){let Y=Z||`Must be one of: ${$.join(", ")}`;return this.addRule({name:"oneOf",message:Y,validate:(X)=>{if(!X)return!0;return $.includes(X)||Y}})}notOneOf($,Z){let Y=Z||`Cannot be one of: ${$.join(", ")}`;return this.addRule({name:"notOneOf",message:Y,validate:(X)=>{if(!X)return!0;return!$.includes(X)||Y}})}date($="Must be a valid date"){return this.addRule({name:"date",message:$,validate:(Z)=>{if(!Z)return!0;let Y=new Date(String(Z));return!Number.isNaN(Y.getTime())||$}})}before($,Z){let Y=new Date($),X=Z||`Must be before ${Y.toLocaleDateString()}`;return this.addRule({name:"before",message:X,validate:(J)=>{if(!J)return!0;return new Date(String(J))<Y||X}})}after($,Z){let Y=new Date($),X=Z||`Must be after ${Y.toLocaleDateString()}`;return this.addRule({name:"after",message:X,validate:(J)=>{if(!J)return!0;return new Date(String(J))>Y||X}})}custom($,Z="Invalid value"){return this.addRule({name:"custom",message:Z,validate:$})}async($,Z="Invalid value"){return this.addRule({name:"async",message:Z,async:!0,validate:$})}when($,Z){let Y=new h6;Y.rules=[...this.rules],Y.defaultValue=this.defaultValue;for(let X of Z.getRules())Y.rules.push({...X,validate:(J,Q)=>{if(!$(J,Q||{}))return!0;return X.validate(J,Q)}});return Y}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default($){let Z=new h6;return Z.rules=[...this.rules],Z.defaultValue=$,Z}async validate($,Z){let Y=[];for(let X of this.rules){let J=await X.validate($,Z);if(J!==!0)Y.push(J)}return Y}validateSync($,Z){let Y=[];for(let X of this.rules){if(X.async)continue;let J=X.validate($,Z);if(J!==!0)Y.push(J)}return Y}}function vR($,Z){let Y=Object.keys($),X={},J={},Q={},G={},K={};for(let O of Y)X[O]=Z?.[O]??$[O].getDefaultValue(),J[O]=[],Q[O]=!1,G[O]=!1,K[O]=!1;let W=!1;async function U(O){K[O]=!0;let V=await $[O].validate(X[O],X);return J[O]=V,K[O]=!1,V.length===0}async function _(){W=!0;let O=await Promise.all(Y.map(U));return W=!1,O.every(Boolean)}function B(){for(let O of Y)X[O]=Z?.[O]??$[O].getDefaultValue(),J[O]=[],Q[O]=!1,G[O]=!1}function z(O){for(let V of Y)if(V in O)X[V]=O[V],G[V]=!0}function q(O,V){X[O]=V,G[O]=!0}function j(O,V=!0){if(Q[O]=V,V)U(O)}function H(O){return{value:X[O],errors:J[O],touched:Q[O],dirty:G[O],valid:J[O].length===0,validating:K[O]}}function L(O){return async(V)=>{V?.preventDefault?.();for(let A of Y)Q[A]=!0;if(await _())await O(X)}}return{values:X,errors:J,touched:Q,dirty:G,get isValid(){return Y.every((O)=>J[O].length===0)},get isValidating(){return W||Y.some((O)=>K[O])},get isDirty(){return Y.some((O)=>G[O])},validate:_,validateField:U,reset:B,setValues:z,setFieldValue:q,setFieldTouched:j,getFieldState:H,handleSubmit:L}}function YB($,Z,Y){let X=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),W=Z;for(let _ of K)if(W&&typeof W==="object"&&_ in W)W=W[_];else return"";let U=W;if(!U||!Array.isArray(U)||U.length===0)return"";return U.map((_)=>{return G.replace(/\{\{\s*message\s*\}\}/g,_)}).join(`
8372
+ `})}function t6($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>t6(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((X,J)=>Y.set(t6(J),t6(X))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((X)=>Y.add(t6(X))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=t6($[Y]);return Z}function t_($,Z=100){let Y=f4($()),X=null,J=()=>{if(X)clearTimeout(X);X=setTimeout(()=>{Y.value=$()},Z)};return M5($).subscribe(()=>J()),{get value(){return Y.value},set value(G){console.warn("Debounced computed is readonly")},subscribe:Y.subscribe,peek:Y.peek,invalidate(){J()},get dirty(){return!1},get deps(){return new Set}}}function e_($,Z=100){let Y=f4($()),X=0,J=()=>{let G=Date.now();if(G-X>=Z)X=G,Y.value=$()};return M5($).subscribe(()=>J()),{get value(){return Y.value},set value(G){console.warn("Throttled computed is readonly")},subscribe:Y.subscribe,peek:Y.peek,invalidate(){J()},get dirty(){return!1},get deps(){return new Set}}}var v1=null,R9,w5,yR;var ZB=D(()=>{R9=[],w5=new WeakMap;yR={ref:f4,computed:M5,watch:n_,watchMultiple:r_,watchEffect:s_,isRef:I6,unref:l_,toRefs:p_,shallowRef:i_,debouncedComputed:t_,throttledComputed:e_,processComputedDirectives:a_,processWatchDirectives:o_}});var QB={};t(QB,{v:()=>xR,processHasErrorsDirective:()=>JB,processFormValidationDirectives:()=>gR,processErrorsDirective:()=>XB,processErrorDirective:()=>YB,defineForm:()=>vR,Validator:()=>h4});class h4{rules=[];defaultValue="";addRule($){let Z=new h4;return Z.rules=[...this.rules,$],Z.defaultValue=this.defaultValue,Z}required($="This field is required"){return this.addRule({name:"required",message:$,validate:(Z)=>{if(Z===null||Z===void 0)return $;if(typeof Z==="string"&&Z.trim()==="")return $;if(Array.isArray(Z)&&Z.length===0)return $;return!0}})}email($="Please enter a valid email"){return this.addRule({name:"email",message:$,validate:(Z)=>{if(!Z)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String(Z))||$}})}url($="Please enter a valid URL"){return this.addRule({name:"url",message:$,validate:(Z)=>{if(!Z)return!0;try{return new URL(String(Z)),!0}catch{return $}}})}min($,Z){let Y=Z||`Must be at least ${$} characters`;return this.addRule({name:"min",message:Y,validate:(X)=>{if(!X)return!0;return String(X).length>=$||Y}})}max($,Z){let Y=Z||`Must be no more than ${$} characters`;return this.addRule({name:"max",message:Y,validate:(X)=>{if(!X)return!0;return String(X).length<=$||Y}})}length($,Z,Y){let X=Y||`Must be between ${$} and ${Z} characters`;return this.addRule({name:"length",message:X,validate:(J)=>{if(!J)return!0;let Q=String(J).length;return Q>=$&&Q<=Z||X}})}pattern($,Z="Invalid format"){return this.addRule({name:"pattern",message:Z,validate:(Y)=>{if(!Y)return!0;return $.test(String(Y))||Z}})}hasUppercase($="Must contain an uppercase letter"){return this.pattern(/[A-Z]/,$)}hasLowercase($="Must contain a lowercase letter"){return this.pattern(/[a-z]/,$)}hasNumber($="Must contain a number"){return this.pattern(/\d/,$)}hasSpecial($="Must contain a special character"){return this.pattern(/[!@#$%^&*(),.?":{}|<>]/,$)}alphanumeric($="Only letters and numbers allowed"){return this.pattern(/^[a-zA-Z0-9]+$/,$)}startsWithLetter($="Must start with a letter"){return this.pattern(/^[a-zA-Z]/,$)}noSpaces($="Spaces are not allowed"){return this.addRule({name:"noSpaces",message:$,validate:(Z)=>{if(!Z)return!0;return!String(Z).includes(" ")||$}})}number($="Must be a number"){let Z=this.addRule({name:"number",message:$,validate:(Y)=>{if(!Y&&Y!==0)return!0;return!Number.isNaN(Number(Y))||$}});return Z.defaultValue=0,Z}integer($="Must be a whole number"){return this.addRule({name:"integer",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number.isInteger(Number(Z))||$}})}positive($="Must be a positive number"){return this.addRule({name:"positive",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number(Z)>0||$}})}negative($="Must be a negative number"){return this.addRule({name:"negative",message:$,validate:(Z)=>{if(!Z&&Z!==0)return!0;return Number(Z)<0||$}})}minValue($,Z){let Y=Z||`Must be at least ${$}`;return this.addRule({name:"minValue",message:Y,validate:(X)=>{if(!X&&X!==0)return!0;return Number(X)>=$||Y}})}maxValue($,Z){let Y=Z||`Must be no more than ${$}`;return this.addRule({name:"maxValue",message:Y,validate:(X)=>{if(!X&&X!==0)return!0;return Number(X)<=$||Y}})}between($,Z,Y){let X=Y||`Must be between ${$} and ${Z}`;return this.addRule({name:"between",message:X,validate:(J)=>{if(!J&&J!==0)return!0;let Q=Number(J);return Q>=$&&Q<=Z||X}})}matches($,Z){let Y=Z||`Must match ${$}`;return this.addRule({name:"matches",message:Y,validate:(X,J)=>{if(!J)return!0;return X===J[$]||Y}})}oneOf($,Z){let Y=Z||`Must be one of: ${$.join(", ")}`;return this.addRule({name:"oneOf",message:Y,validate:(X)=>{if(!X)return!0;return $.includes(X)||Y}})}notOneOf($,Z){let Y=Z||`Cannot be one of: ${$.join(", ")}`;return this.addRule({name:"notOneOf",message:Y,validate:(X)=>{if(!X)return!0;return!$.includes(X)||Y}})}date($="Must be a valid date"){return this.addRule({name:"date",message:$,validate:(Z)=>{if(!Z)return!0;let Y=new Date(String(Z));return!Number.isNaN(Y.getTime())||$}})}before($,Z){let Y=new Date($),X=Z||`Must be before ${Y.toLocaleDateString()}`;return this.addRule({name:"before",message:X,validate:(J)=>{if(!J)return!0;return new Date(String(J))<Y||X}})}after($,Z){let Y=new Date($),X=Z||`Must be after ${Y.toLocaleDateString()}`;return this.addRule({name:"after",message:X,validate:(J)=>{if(!J)return!0;return new Date(String(J))>Y||X}})}custom($,Z="Invalid value"){return this.addRule({name:"custom",message:Z,validate:$})}async($,Z="Invalid value"){return this.addRule({name:"async",message:Z,async:!0,validate:$})}when($,Z){let Y=new h4;Y.rules=[...this.rules],Y.defaultValue=this.defaultValue;for(let X of Z.getRules())Y.rules.push({...X,validate:(J,Q)=>{if(!$(J,Q||{}))return!0;return X.validate(J,Q)}});return Y}getRules(){return this.rules}getDefaultValue(){return this.defaultValue}default($){let Z=new h4;return Z.rules=[...this.rules],Z.defaultValue=$,Z}async validate($,Z){let Y=[];for(let X of this.rules){let J=await X.validate($,Z);if(J!==!0)Y.push(J)}return Y}validateSync($,Z){let Y=[];for(let X of this.rules){if(X.async)continue;let J=X.validate($,Z);if(J!==!0)Y.push(J)}return Y}}function vR($,Z){let Y=Object.keys($),X={},J={},Q={},G={},K={};for(let O of Y)X[O]=Z?.[O]??$[O].getDefaultValue(),J[O]=[],Q[O]=!1,G[O]=!1,K[O]=!1;let W=!1;async function U(O){K[O]=!0;let V=await $[O].validate(X[O],X);return J[O]=V,K[O]=!1,V.length===0}async function _(){W=!0;let O=await Promise.all(Y.map(U));return W=!1,O.every(Boolean)}function B(){for(let O of Y)X[O]=Z?.[O]??$[O].getDefaultValue(),J[O]=[],Q[O]=!1,G[O]=!1}function z(O){for(let V of Y)if(V in O)X[V]=O[V],G[V]=!0}function q(O,V){X[O]=V,G[O]=!0}function j(O,V=!0){if(Q[O]=V,V)U(O)}function H(O){return{value:X[O],errors:J[O],touched:Q[O],dirty:G[O],valid:J[O].length===0,validating:K[O]}}function L(O){return async(V)=>{V?.preventDefault?.();for(let A of Y)Q[A]=!0;if(await _())await O(X)}}return{values:X,errors:J,touched:Q,dirty:G,get isValid(){return Y.every((O)=>J[O].length===0)},get isValidating(){return W||Y.some((O)=>K[O])},get isDirty(){return Y.some((O)=>G[O])},validate:_,validateField:U,reset:B,setValues:z,setFieldValue:q,setFieldTouched:j,getFieldState:H,handleSubmit:L}}function YB($,Z,Y){let X=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),W=Z;for(let _ of K)if(W&&typeof W==="object"&&_ in W)W=W[_];else return"";let U=W;if(!U||!Array.isArray(U)||U.length===0)return"";return U.map((_)=>{return G.replace(/\{\{\s*message\s*\}\}/g,_)}).join(`
8373
8373
  `)}catch{return""}})}function XB($,Z,Y){let X=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),W=Z;for(let _ of K)if(W&&typeof W==="object"&&_ in W)W=W[_];else return"";let U=W;if(!U||!Array.isArray(U)||U.length===0)return"";return U.map((_)=>G.replace(/\{\{\s*message\s*\}\}/g,_)).join(`
8374
- `)}catch{return""}})}function JB($,Z,Y){let X=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),W=Z;for(let _ of K)if(W&&typeof W==="object"&&_ in W)W=W[_];else return"";let U=W;if(!U||!Array.isArray(U)||U.length===0)return"";return G}catch{return""}})}function gR($,Z,Y){let X=$;return X=YB(X,Z,Y),X=XB(X,Z,Y),X=JB(X,Z,Y),X}var xR;var GB=D(()=>{xR=new h6});var UB={};t(UB,{processXElementDirectives:()=>fR,hasXElementDirectives:()=>WB,generateXElementRuntime:()=>KB});function KB(){return`<script data-stx-scoped>
8374
+ `)}catch{return""}})}function JB($,Z,Y){let X=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),W=Z;for(let _ of K)if(W&&typeof W==="object"&&_ in W)W=W[_];else return"";let U=W;if(!U||!Array.isArray(U)||U.length===0)return"";return G}catch{return""}})}function gR($,Z,Y){let X=$;return X=YB(X,Z,Y),X=XB(X,Z,Y),X=JB(X,Z,Y),X}var xR;var GB=D(()=>{xR=new h4});var UB={};t(UB,{processXElementDirectives:()=>fR,hasXElementDirectives:()=>WB,generateXElementRuntime:()=>KB});function KB(){return`<script data-stx-scoped>
8375
8375
  (function() {
8376
8376
  'use strict';
8377
8377
 
@@ -8715,14 +8715,14 @@ if ('serviceWorker' in navigator) {
8715
8715
  });
8716
8716
  });
8717
8717
  }
8718
- </script>`}function mR(){return'<link rel="manifest" href="/manifest.json">'}function uR($){return`<meta name="theme-color" content="${wY($)}">`}function wY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var qB=D(()=>{BB()});var MY={};t(MY,{validateClientScript:()=>R5,processOnceDirective:()=>N5,processJsonDirective:()=>A5,processDirectives:()=>J0,injectRouterScript:()=>t1});import X1 from"path";async function J0($,Z,Y,X,J){if(X.ssr===!1&&!X.autoShell&&X.buildMode==="spa")return $;let Q=!Z.__stxProcessingDepth;if(!Z.__stxProcessingDepth)Z.__stxProcessingDepth=0;if(Z.__stxProcessingDepth++,!Z.__onceStore)Z.__onceStore=new Set;try{return await N1.timeAsync("template-processing",async()=>{let G=await cR($,Z,Y,X,J);if(Q)G=$Y(G);if(Q&&X.autoShell&&X.buildMode!=="compile"){let K=X.app?.head||{},U=(Z.__stx_runtime_head||null)??I6(),_={...K,...U.title&&{title:U.title},meta:[...K.meta||[],...U.meta||[]],link:[...K.link||[],...U.link||[]],script:[...K.script||[],...U.script||[]],...U.htmlAttrs&&{htmlAttrs:{...K.htmlAttrs||{},...U.htmlAttrs}},...U.bodyAttrs&&{bodyAttrs:{...K.bodyAttrs||{},...U.bodyAttrs}}};G=B5(G,_);let B=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(B&&G.includes("<head")){let q=B[1];G=G.replace("<head>",`<head>
8718
+ </script>`}function mR(){return'<link rel="manifest" href="/manifest.json">'}function uR($){return`<meta name="theme-color" content="${wY($)}">`}function wY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var qB=D(()=>{BB()});var MY={};t(MY,{validateClientScript:()=>R5,processOnceDirective:()=>N5,processJsonDirective:()=>A5,processDirectives:()=>J0,injectRouterScript:()=>t1});import X1 from"path";async function J0($,Z,Y,X,J){if(X.ssr===!1&&!X.autoShell&&X.buildMode==="spa")return $;let Q=!Z.__stxProcessingDepth;if(!Z.__stxProcessingDepth)Z.__stxProcessingDepth=0;if(Z.__stxProcessingDepth++,!Z.__onceStore)Z.__onceStore=new Set;try{return await N1.timeAsync("template-processing",async()=>{let G=await cR($,Z,Y,X,J);if(Q)G=$Y(G);if(Q&&X.autoShell&&X.buildMode!=="compile"){let K=X.app?.head||{},U=(Z.__stx_runtime_head||null)??I4(),_={...K,...U.title&&{title:U.title},meta:[...K.meta||[],...U.meta||[]],link:[...K.link||[],...U.link||[]],script:[...K.script||[],...U.script||[]],...U.htmlAttrs&&{htmlAttrs:{...K.htmlAttrs||{},...U.htmlAttrs}},...U.bodyAttrs&&{bodyAttrs:{...K.bodyAttrs||{},...U.bodyAttrs}}};G=B5(G,_);let B=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(B&&G.includes("<head")){let q=B[1];G=G.replace("<head>",`<head>
8719
8719
  <meta name="stx-layout" content="${q}">`)}let z=G.match(/function (__stx_setup_\d+_\d+)\(/);if(z&&G.includes("<body")&&!G.match(/<body[^>]*data-stx=/)){G=G.replace(/<body([^>]*)>/,`<body$1 data-stx="${z[1]}">`);let q=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${z[1]}"`,"i");G=G.replace(q,"$1")}}if(Q)try{let{getStoreScript:K}=await Promise.resolve().then(() => (tU(),oU)),W=X.storesDir,U=await K(W);if(U){let _=`<script data-stx-stores>${U}</script>`,B=G.indexOf("<script data-stx-scoped>");if(B!==-1){let z=G.indexOf("</script>",B+24);if(z!==-1){let q=z+9;G=G.slice(0,q)+`
8720
- `+_+G.slice(q)}}}}catch{}if(Q)G=await D0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof $5)throw G;let K=G instanceof Error?G.message:String(G),W=new R1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(q1.log(W,{filePath:Y,context:Z}),E6.logDetailedError(W,{filePath:Y,template:$.substring(0,500)}),X.debug)throw W;return V8.createFallbackContent("Template Processing",W)}}async function cR($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!X1.isAbsolute(X.partialsDir)?X1.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!X1.isAbsolute(X.componentsDir)?X1.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!X1.isAbsolute(X.layoutsDir)?X1.resolve(Q,X.layoutsDir):X.layoutsDir},K=G,W=$;W=W.replace(/\{\{--[\s\S]*?--\}\}/g,"");let U="\x00STX_ESCAPED_AT\x00";W=W.replace(/@@/g,U),W=W.replace(/@\{\{([\s\S]*?)\}\}/g,(H,L)=>{return`{{ ${L} }}`}),W=M2(W),W=await nU(W,Y,J);let _={};W=i8(W,_);let B={...Z.__sections||{}},z="",q=/@nolayout\b/.test(W);if(q)W=W.replace(/@nolayout\b\s*/g,"");let j=W.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(j)z=j[1],W=W.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!z&&!q&&K.defaultLayout){let H=/<!DOCTYPE\s/i.test(W),L=/@section\s*\(/.test(W);if(!H||L){let F="",O=X1.dirname(Y),V=K.layoutsDir?X1.dirname(K.layoutsDir):process.cwd();for(let N=0;N<20;N++){let A=X1.join(O,"_layout.stx");if(await $0(A)){F=A;break}let R=X1.dirname(O);if(R===O||R.length<V.length)break;O=R}if(F)z=F;else if(K.layoutsDir){let N=X1.isAbsolute(K.layoutsDir)?K.layoutsDir:X1.resolve(process.cwd(),K.layoutsDir),A=X1.join(N,`${K.defaultLayout}.stx`);if(await $0(A))z=A}if(z&&!L)W=`@section('content')
8720
+ `+_+G.slice(q)}}}}catch{}if(Q)G=await D0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof $5)throw G;let K=G instanceof Error?G.message:String(G),W=new R1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(q1.log(W,{filePath:Y,context:Z}),E4.logDetailedError(W,{filePath:Y,template:$.substring(0,500)}),X.debug)throw W;return V8.createFallbackContent("Template Processing",W)}}async function cR($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!X1.isAbsolute(X.partialsDir)?X1.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!X1.isAbsolute(X.componentsDir)?X1.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!X1.isAbsolute(X.layoutsDir)?X1.resolve(Q,X.layoutsDir):X.layoutsDir},K=G,W=$;W=W.replace(/\{\{--[\s\S]*?--\}\}/g,"");let U="\x00STX_ESCAPED_AT\x00";W=W.replace(/@@/g,U),W=W.replace(/@\{\{([\s\S]*?)\}\}/g,(H,L)=>{return`{{ ${L} }}`}),W=M2(W),W=await nU(W,Y,J);let _={};W=i8(W,_);let B={...Z.__sections||{}},z="",q=/@nolayout\b/.test(W);if(q)W=W.replace(/@nolayout\b\s*/g,"");let j=W.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(j)z=j[1],W=W.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!z&&!q&&K.defaultLayout){let H=/<!DOCTYPE\s/i.test(W),L=/@section\s*\(/.test(W);if(!H||L){let F="",O=X1.dirname(Y),V=K.layoutsDir?X1.dirname(K.layoutsDir):process.cwd();for(let N=0;N<20;N++){let A=X1.join(O,"_layout.stx");if(await $0(A)){F=A;break}let R=X1.dirname(O);if(R===O||R.length<V.length)break;O=R}if(F)z=F;else if(K.layoutsDir){let N=X1.isAbsolute(K.layoutsDir)?K.layoutsDir:X1.resolve(process.cwd(),K.layoutsDir),A=X1.join(N,`${K.defaultLayout}.stx`);if(await $0(A))z=A}if(z&&!L)W=`@section('content')
8721
8721
  ${W.trim()}
8722
8722
  @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,L,F)=>{return B[L]=F,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(H,L,F)=>{if(F.includes("@parent"))B[L]=F.replace("@parent","<!--PARENT_CONTENT_PLACEHOLDER-->");else B[L]=F.trim();return""}),Z.__sections=B,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(H,L,F)=>{return B[L]||F||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""});if(W=n8(W,_),z)try{let H=X1.isAbsolute(z)?z:await C1(()=>E5(z,Y,G,J),null,()=>{throw new R1(`Failed to resolve layout path: ${z}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!H){let A=`Layout not found: ${z} (referenced from ${Y})`;if(q1.log(Error(A),{layoutPath:z,filePath:Y},"warning"),G.debug)throw new R1(A,Y);return W}let L=await C1(()=>Bun.file(H).text(),"",()=>{throw new R1(`Failed to read layout file: ${H}`,Y,void 0,void 0,"Layout content could not be loaded")}),F=L.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F){if(G.debug)console.log(`Found nested layout: ${F[1]} in ${H}`);let A={},R=L.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(I,T,S)=>{return A[T]=S.trim(),""});for(let[I,T]of Object.entries(A))if(B[I]&&B[I].includes("<!--PARENT_CONTENT_PLACEHOLDER-->")){let S=B[I].indexOf("<!--PARENT_CONTENT_PLACEHOLDER-->");B[I]=B[I].slice(0,S)+T+B[I].slice(S+33)}else if(!B[I])B[I]=T;let M={...Z,__sections:B},E=`@layout('${F[1]}')${R}`;return await J0(E,M,H,G,J)}let O=L.replace(/\{\{--[\s\S]*?--\}\}/g,""),V=i8(O,_),N={};return V=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(A,R,M)=>{return N[R]=M.trim(),`@slot('${R}')`}),V=V.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(A,R,M)=>{if(B[R]){let E=B[R];if(E.includes("<!--PARENT_CONTENT_PLACEHOLDER-->")){let I=N[R]||"",T=E.indexOf("<!--PARENT_CONTENT_PLACEHOLDER-->");E=E.slice(0,T)+I+E.slice(T+33)}return E}return M||""}),V=V.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""}),V=n8(V,_),Z.__originalFilePath=Y,W=await jB(V,Z,H,G,J),W=`<!-- stx-layout: ${z} -->
8723
- ${W}`,W}catch(H){return q1.log(H instanceof Error?H:Error(String(H)),{layoutPath:z,filePath:Y},"error"),`[Error processing layout: ${H instanceof Error?H.message:String(H)}]`}return await jB(W,Z,Y,G,J)}async function jB($,Z,Y,X,J){let Q=$;Z.__stx_sfc_mode=!0;let G=X;if(await C1(()=>XU(Y,Z),void 0,(c)=>{if(G.debug)console.warn(`View composer error for ${Y}:`,c.message)}),Z.__stx_options=G,G.buildMode)Z.__stx_buildMode=G.buildMode;let K=G.envPrefix||"STX_PUBLIC_",W={};for(let[c,r]of Object.entries(process.env))if(c.startsWith(K)&&r!==void 0)W[c]=r;Z.$env=W,Q=await C1(()=>L2(Q,Z,Y,G),Q,(c)=>{if(G.debug)console.warn("Pre-processing middleware error:",c.message)});let U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,_;while((_=U.exec(Q))!==null){let c=_[1],r=_[2];if(/\bserver\b/.test(c)&&r.trim())try{let{extractVariables:W0}=await Promise.resolve().then(() => (w4(),h8));await W0(r,Z,Y)}catch(W0){if(G.debug)console.warn("Script extraction error:",W0)}}try{let{interpolateScriptsInTemplate:c}=await Promise.resolve().then(() => (r0(),n$));Q=c(Q,Z,{skipServer:!0})}catch(c){if(G.debug)console.warn("Script expression interpolation error:",c)}if(Q=await rW(Q,Z,Y),Q=await sW(Q,Z,Y),Q=await $2(Q,Z,Y,G),i$(Q))Q=P2(Q),Q=y2(Q,Z);Q=c8(Q,Z,Y,G),Q=await e2(Q,Z,Y,G,J),Q=await T2(Q,Z,Y,G,J),Q=KZ(Q,Z,Y,G);let{processDeferDirectives:B}=await Promise.resolve().then(() => Z_);Q=B(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => Q_);Q=z(Q,Z,Y);let{processTransitionDirectives:q,processTransitionAttributes:j}=await Promise.resolve().then(() => H_);Q=q(Q,Z,Y),Q=j(Q);let{processErrorBoundaryDirectives:H}=await Promise.resolve().then(() => O_);Q=H(Q,Z,Y);let{processSuspenseDirectives:L}=await Promise.resolve().then(() => w_);Q=L(Q,Z,Y);let{processAsyncDirectives:F}=await Promise.resolve().then(() => C_);Q=F(Q,Z,Y);let{processKeepAliveDirectives:O}=await Promise.resolve().then(() => m_);Q=O(Q,Z,Y);let{processVirtualListDirectives:V,processVirtualGridDirectives:N,processInfiniteListDirectives:A}=await Promise.resolve().then(() => (KY(),u_));Q=V(Q,Z,Y),Q=N(Q,Z,Y),Q=A(Q,Z,Y);let{processPartialHydrationDirectives:R,processStaticDirectives:M}=await Promise.resolve().then(() => (NY(),c_));Q=R(Q,Z,Y),Q=M(Q);let{processComputedDirectives:E,processWatchDirectives:I}=await Promise.resolve().then(() => (ZB(),$B));Q=E(Q,Z,Y),Q=I(Q,Z,Y);let{processFormValidationDirectives:T}=await Promise.resolve().then(() => (GB(),QB));Q=T(Q,Z,Y);let{processHeadDirective:S,processTitleDirective:k,processMetaDirective:C,resetHead:x}=await Promise.resolve().then(() => (N4(),b8));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)x();let g=S(Q);if(Q=g.content,Q=k(Q,Z),Q=C(Q,Z),Q=eW(Q),Q=lZ(Q,Z),Q=KW(Q),Q=tW(Q),Q=await p8(Q,Z,Y,G,J),Q=await e2(Q,Z,Y,G,J),Q=$Y(Q),Q=T6(Q,Z,Y),Q=pZ(Q,Z),Q=iZ(Q,Z),Q=D6(Q,Z),Q=y8(Q,Z),Q=x8(Q,Z),Q=await TY(Q,Z,Y,G),Q=await EY(Q,Z,Y),Q=await K2(Q,Z,Y,G),Q=JZ(Q,Z,Y,G),Q=V2(Q,Z,Y,G),Q=A2(Q,Z,Y),Q=N2(Q,Z,Y,G),Q=oZ(Q,Z,Y,G),Q=A5(Q,Z),Q=N5(Q),Q=sU(Q),!G.skipEventDirectives)Q=PZ(Q,Z,Y);if(Q=RK(Q,Z,Y),G.debug){let c=/\bx-data\s*=/.test(Q),r=j9($);if(c&&r)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
8723
+ ${W}`,W}catch(H){return q1.log(H instanceof Error?H:Error(String(H)),{layoutPath:z,filePath:Y},"error"),`[Error processing layout: ${H instanceof Error?H.message:String(H)}]`}return await jB(W,Z,Y,G,J)}async function jB($,Z,Y,X,J){let Q=$;Z.__stx_sfc_mode=!0;let G=X;if(await C1(()=>XU(Y,Z),void 0,(c)=>{if(G.debug)console.warn(`View composer error for ${Y}:`,c.message)}),Z.__stx_options=G,G.buildMode)Z.__stx_buildMode=G.buildMode;let K=G.envPrefix||"STX_PUBLIC_",W={};for(let[c,r]of Object.entries(process.env))if(c.startsWith(K)&&r!==void 0)W[c]=r;Z.$env=W,Q=await C1(()=>L2(Q,Z,Y,G),Q,(c)=>{if(G.debug)console.warn("Pre-processing middleware error:",c.message)});let U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,_;while((_=U.exec(Q))!==null){let c=_[1],r=_[2];if(/\bserver\b/.test(c)&&r.trim())try{let{extractVariables:W0}=await Promise.resolve().then(() => (w6(),h8));await W0(r,Z,Y)}catch(W0){if(G.debug)console.warn("Script extraction error:",W0)}}try{let{interpolateScriptsInTemplate:c}=await Promise.resolve().then(() => (r0(),n$));Q=c(Q,Z,{skipServer:!0})}catch(c){if(G.debug)console.warn("Script expression interpolation error:",c)}if(Q=await rW(Q,Z,Y),Q=await sW(Q,Z,Y),Q=await $2(Q,Z,Y,G),i$(Q))Q=P2(Q),Q=y2(Q,Z);Q=c8(Q,Z,Y,G),Q=await e2(Q,Z,Y,G,J),Q=await T2(Q,Z,Y,G,J),Q=KZ(Q,Z,Y,G);let{processDeferDirectives:B}=await Promise.resolve().then(() => Z_);Q=B(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => Q_);Q=z(Q,Z,Y);let{processTransitionDirectives:q,processTransitionAttributes:j}=await Promise.resolve().then(() => H_);Q=q(Q,Z,Y),Q=j(Q);let{processErrorBoundaryDirectives:H}=await Promise.resolve().then(() => O_);Q=H(Q,Z,Y);let{processSuspenseDirectives:L}=await Promise.resolve().then(() => w_);Q=L(Q,Z,Y);let{processAsyncDirectives:F}=await Promise.resolve().then(() => C_);Q=F(Q,Z,Y);let{processKeepAliveDirectives:O}=await Promise.resolve().then(() => m_);Q=O(Q,Z,Y);let{processVirtualListDirectives:V,processVirtualGridDirectives:N,processInfiniteListDirectives:A}=await Promise.resolve().then(() => (KY(),u_));Q=V(Q,Z,Y),Q=N(Q,Z,Y),Q=A(Q,Z,Y);let{processPartialHydrationDirectives:R,processStaticDirectives:M}=await Promise.resolve().then(() => (NY(),c_));Q=R(Q,Z,Y),Q=M(Q);let{processComputedDirectives:E,processWatchDirectives:I}=await Promise.resolve().then(() => (ZB(),$B));Q=E(Q,Z,Y),Q=I(Q,Z,Y);let{processFormValidationDirectives:T}=await Promise.resolve().then(() => (GB(),QB));Q=T(Q,Z,Y);let{processHeadDirective:S,processTitleDirective:k,processMetaDirective:C,resetHead:x}=await Promise.resolve().then(() => (N6(),b8));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)x();let g=S(Q);if(Q=g.content,Q=k(Q,Z),Q=C(Q,Z),Q=eW(Q),Q=lZ(Q,Z),Q=KW(Q),Q=tW(Q),Q=await p8(Q,Z,Y,G,J),Q=await e2(Q,Z,Y,G,J),Q=$Y(Q),Q=T4(Q,Z,Y),Q=pZ(Q,Z),Q=iZ(Q,Z),Q=D4(Q,Z),Q=y8(Q,Z),Q=x8(Q,Z),Q=await TY(Q,Z,Y,G),Q=await EY(Q,Z,Y),Q=await K2(Q,Z,Y,G),Q=JZ(Q,Z,Y,G),Q=V2(Q,Z,Y,G),Q=A2(Q,Z,Y),Q=N2(Q,Z,Y,G),Q=oZ(Q,Z,Y,G),Q=A5(Q,Z),Q=N5(Q),Q=sU(Q),!G.skipEventDirectives)Q=PZ(Q,Z,Y);if(Q=RK(Q,Z,Y),G.debug){let c=/\bx-data\s*=/.test(Q),r=j9($);if(c&&r)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
8724
8724
  Both work on the same page, but they manage separate scopes.
8725
- Prefer signals (state/derived/effect) for new components.`)}Q=o8(Q,Z),Q=await A1(Q,Z,Y),Q=aU(Q),Q=DZ(Q);let{processXElementDirectives:P}=await Promise.resolve().then(() => UB);if(Q=P(Q),Q=await x2(Q,G,Y),Q=await O2(Q,Z,Y,G),G.seo?.enabled)Q=R2(Q,Z,G);let{renderHead:f,getHead:h}=await Promise.resolve().then(() => (N4(),b8)),u=Z.__stx_runtime_head,l=u&&(u.title||u.meta?.length||u.link?.length)?u:h();if(l.title||l.meta?.length||l.link?.length){let c=f(l);if(c){if(Q.includes("</head>"))Q=Q.replace("</head>",`${c}
8725
+ Prefer signals (state/derived/effect) for new components.`)}Q=o8(Q,Z),Q=await A1(Q,Z,Y),Q=aU(Q),Q=DZ(Q);let{processXElementDirectives:P}=await Promise.resolve().then(() => UB);if(Q=P(Q),Q=await x2(Q,G,Y),Q=await O2(Q,Z,Y,G),G.seo?.enabled)Q=R2(Q,Z,G);let{renderHead:f,getHead:h}=await Promise.resolve().then(() => (N6(),b8)),u=Z.__stx_runtime_head,l=u&&(u.title||u.meta?.length||u.link?.length)?u:h();if(l.title||l.meta?.length||l.link?.length){let c=f(l);if(c){if(Q.includes("</head>"))Q=Q.replace("</head>",`${c}
8726
8726
  </head>`);else if(Q.includes("<head>"))Q=Q.replace("<head>",`<head>
8727
8727
  ${c}`)}}if(g.headContent){if(Q.includes("</head>"))Q=Q.replace("</head>",`${g.headContent}
8728
8728
  </head>`);else if(Q.includes("<head>"))Q=Q.replace("<head>",`<head>
@@ -8732,12 +8732,12 @@ ${WK()}
8732
8732
  `+w0}else Q=Q.replace("</head>",`${r}
8733
8733
  </head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
8734
8734
  ${r}`);else Q=r+`
8735
- `+Q}{let c=/<script\s+server\b[^>]*>/gi,r,_0=[];while((r=c.exec(Q))!==null){let W0=r.index+r[0].length,K0=1,R0=W0;while(R0<Q.length&&K0>0){let w0=Q.indexOf("<script",R0),o0=Q.indexOf("</script>",R0);if(o0===-1)break;if(w0!==-1&&w0<o0)K0++,R0=w0+7;else{if(K0--,K0===0){let n1=o0+9;while(n1<Q.length&&/\s/.test(Q[n1]))n1++;_0.push({start:r.index,end:n1});break}R0=o0+9}}}for(let W0=_0.length-1;W0>=0;W0--){let{start:K0,end:R0}=_0[W0];Q=Q.substring(0,K0)+Q.substring(R0)}}let C0=_5(Q,Y);if(C0.hasScoped)Q=C0.html;let T0=Z.__stx_event_bindings||[],b=!1,d=[],m=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:i}=await Promise.resolve().then(() => (v2(),TU));for(let c of i(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}))d.push({match:c.fullMatch,attrs:c.attrs,content:c.body});for(let{match:c,attrs:r,content:_0}of d){b=!0;let W0=_0;R5(_0,Y,X.strict);let K0=await i4(_0,{eventBindings:T0,attrs:r,hasColonDirectives:m,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile"});Q=Q.replace(c,()=>K0)}if(b)Z.__stx_event_bindings=[];return Q}var J1=D(()=>{r1();H6();UK();kZ();CZ();Q8();J8();yZ();m$();d6();T8();tZ();WW();Z2();_1();N4();r0();J2();W2();k6();oW();l8();M9();F2();j4();$U();a8();H0();JU();w2();E2();I2();t8();v2();lU();rU();ZY();YY();ZY();YY()});function HB($){let Z=[],Y=[];return nR($,Z),rR($,Z,Y),sR($,Y),aR($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function nR($,Z){let Y=($.match(/\{\{/g)||[]).length,X=($.match(/\}\}/g)||[]).length;if(Y!==X)Z.push({type:"expression",message:`Unclosed expression brackets: found ${Y} opening '{{' and ${X} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function rR($,Z,Y){for(let X of lR){let J=new RegExp(`${X.open}(?:\\s|\\()`,"g"),Q=new RegExp(X.close,"g"),G=($.match(J)||[]).length,K=($.match(Q)||[]).length;if(X.altClose){let W=new RegExp(X.altClose,"g");K+=($.match(W)||[]).length}if(G>K)Z.push({type:"directive",message:`Unclosed @${X.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${X.close} tag(s)`});else if(K>G)Y.push({type:"directive",message:`Extra ${X.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${X.close} tags`})}}function sR($,Z){for(let Y of pR)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function aR($,Z){for(let Y of iR)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function LB($,Z){let Y=$.slice(0,Z).split(`
8736
- `);return{line:Y.length,column:Y[Y.length-1].length+1}}function OB($,Z,Y){let X=[];switch($){case"if":case"elseif":case"unless":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Y.length===0||!Y[0].includes(" as "))X.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Y.length===0)X.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Y.length===0)X.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Y.length===0)X.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return X}function FB($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function VB($){let Z=$.matchAll(/@([a-z]+)/gi),Y=new Set;for(let X of Z){let J=X[1].toLowerCase();if(!J.startsWith("end"))Y.add(J)}return Array.from(Y)}var lR,pR,iR;var AB=D(()=>{lR=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],pR=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],iR=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var EB={};t(EB,{renderSlot:()=>DY,processSlots:()=>kY,parseSlots:()=>IY,parseSlotElement:()=>NB,extractSlotContent:()=>wB,applySlots:()=>MB});function oR($,Z){let Y=1,X=Z,J="<template",Q="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(J,X)&&(X+J.length>=$.length||/[\s>\/]/.test($[X+J.length]))){Y++,X+=J.length;continue}if($.startsWith(Q,X)){let K=$.indexOf(">",X+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function IY($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,J=[],Q;while((Q=X.exec($))!==null){let[_,B,z,q,j]=Q,H=B||z||q,L=Q.index+_.length,F=oR($,L);if(F!==-1){let O=$.slice(L,F-11).trim();J.push({start:Q.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}J.sort((_,B)=>B.start-_.start);for(let _ of J)Y=Y.slice(0,_.start)+Y.slice(_.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(Y))!==null){let[_,B,z,q,j,H]=W,L=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${B}${O?" "+O:""}>${H}</${B}>`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:V})}let U=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=U.exec(Y))!==null){let[_,B,z,q,j]=W,H=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${B}${F?" "+F:""} />`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:O})}G.sort((_,B)=>B.start-_.start);for(let _ of G){let B=Z.named.get(_.slotName);if(B)B.content+=_.element;else Z.named.set(_.slotName,{name:_.slotName,content:_.element});Y=Y.slice(0,_.start)+Y.slice(_.end)}return Z.default=Y.trim(),Z}function NB($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},J=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=J.exec($))!==null)X[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function DY($,Z,Y,X){if(!$)return Y;let J=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...X};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,_]=W.split(":").map((z)=>z.trim()),B=_||U;if(Z[U]!==void 0)G[B]=Z[U]}}else G[Q]=Z;J=tR(J,G)}return J}function tR($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=RB(J,Z);return I0(String(Q??""))}catch{return`{{ ${X} }}`}})}function RB($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),J=Z;for(let Q of X)if(J&&typeof J==="object"&&Q in J)J=J[Q];else return;return J}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,J,Q]=Y,G=Z[X],K=parseInt(Q,10);if(typeof G==="number")switch(J){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!L0($))return;return F0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function kY($,Z,Y){let X=$;X=await eR(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let _=Z.named.get(K),B=U?.trim()||"",z=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(z))!==null){let L=H[1],F=H[2];q[L]=RB(F,Y)}return await DY(_,q,B,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),X}async function eR($,Z,Y){let X=[],J=[];$.replace(Z,(K,...W)=>{let U=W[W.length-2];return J.push({match:K,index:U}),X.push(Y(K,...W.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:W,index:U}=J[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function wB($){let Z=IY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function MB($,Z,Y,X){return await kY($,{default:Z,named:Y},X)}var SY=D(()=>{r0();n0()});import $w from"fs";import B0 from"path";function Yw($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function TB($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function z4($){return!TB($)}function q4($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let J=new Bun.Transpiler({loader:"ts",target:"browser"}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)J=J.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),J=J.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return J}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function Xw($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(_)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===_){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let _=1;while(J<Q&&_>0)if($[J]==="{")_++;else if($[J]==="}")_--;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},W=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
8737
- `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let 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 B=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(B){let j=B[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let z=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let j=z[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}async function y1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (w4(),h8)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let B=new Set(_);B.add($);try{let z=(b)=>b.split("-").map((d)=>d.charAt(0).toUpperCase()+d.slice(1)).join(""),q=(b)=>b.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),j=$.endsWith(".stx")?$.slice(0,-4):$,H=null,L=J.__importedComponents;if(L){let b=[j,j.toLowerCase(),z(j),q(j)];for(let d of b)if(L.has(d)){H=L.get(d);break}}let F=[];if(!H){let b=[`${j}.stx`,`${z(j)}.stx`,`${q(j)}.stx`],d=[...new Set(b)],m=J.__originalFilePath,i=[];if(m){let W0=B0.join(B0.dirname(m),"components");i.push(W0)}if(X)i.push(X);let c=B0.join(B0.dirname(Q),"components");if(!i.includes(c))i.push(c);if(G.componentsDir&&G.componentsDir!==X&&!i.includes(G.componentsDir))i.push(G.componentsDir);let r=process.cwd(),_0=[B0.resolve(r,"src/components"),B0.resolve(r,"components"),B0.resolve(import.meta.dir,"components")];for(let W0 of _0)if(!i.includes(W0))i.push(W0);if(j.startsWith("./")||j.startsWith("../"))H=B0.resolve(B0.dirname(Q),`${j}.stx`),F.push(H);else for(let W0 of i){if(!W0)continue;for(let K0 of d){let R0=B0.join(W0,K0);if(F.push(R0),await $0(R0)){H=R0;break}}if(H)break;if(!H)try{let K0=await import("fs");if(!K0.statSync(W0,{throwIfNoEntry:!1})?.isDirectory())continue;let w0=K0.readdirSync(W0,{withFileTypes:!0});for(let o0 of w0)if(o0.isDirectory()){let n1=B0.join(W0,o0.name);for(let j6 of d){let j0=B0.join(n1,j6);if(F.push(j0),await $0(j0)){H=j0;break}}if(H)break}}catch{}if(H)break}}if(!H||!await $0(H)){let b=F.length>0?`
8735
+ `+Q}{let c=/<script\s+server\b[^>]*>/gi,r,_0=[];while((r=c.exec(Q))!==null){let W0=r.index+r[0].length,K0=1,R0=W0;while(R0<Q.length&&K0>0){let w0=Q.indexOf("<script",R0),o0=Q.indexOf("</script>",R0);if(o0===-1)break;if(w0!==-1&&w0<o0)K0++,R0=w0+7;else{if(K0--,K0===0){let n1=o0+9;while(n1<Q.length&&/\s/.test(Q[n1]))n1++;_0.push({start:r.index,end:n1});break}R0=o0+9}}}for(let W0=_0.length-1;W0>=0;W0--){let{start:K0,end:R0}=_0[W0];Q=Q.substring(0,K0)+Q.substring(R0)}}let C0=_5(Q,Y);if(C0.hasScoped)Q=C0.html;let T0=Z.__stx_event_bindings||[],b=!1,d=[],m=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:i}=await Promise.resolve().then(() => (v2(),TU));for(let c of i(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}))d.push({match:c.fullMatch,attrs:c.attrs,content:c.body});for(let{match:c,attrs:r,content:_0}of d){b=!0;let W0=_0;R5(_0,Y,X.strict);let K0=await i6(_0,{eventBindings:T0,attrs:r,hasColonDirectives:m,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile"});Q=Q.replace(c,()=>K0)}if(b)Z.__stx_event_bindings=[];return Q}var J1=D(()=>{r1();H4();UK();kZ();CZ();Q8();J8();yZ();m$();d4();T8();tZ();WW();Z2();_1();N6();r0();J2();W2();k4();oW();l8();M9();F2();j6();$U();a8();H0();JU();w2();E2();I2();t8();v2();lU();rU();ZY();YY();ZY();YY()});function HB($){let Z=[],Y=[];return nR($,Z),rR($,Z,Y),sR($,Y),aR($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function nR($,Z){let Y=($.match(/\{\{/g)||[]).length,X=($.match(/\}\}/g)||[]).length;if(Y!==X)Z.push({type:"expression",message:`Unclosed expression brackets: found ${Y} opening '{{' and ${X} closing '}}'`,suggestion:"Ensure every {{ has a matching }}"})}function rR($,Z,Y){for(let X of lR){let J=new RegExp(`${X.open}(?:\\s|\\()`,"g"),Q=new RegExp(X.close,"g"),G=($.match(J)||[]).length,K=($.match(Q)||[]).length;if(X.altClose){let W=new RegExp(X.altClose,"g");K+=($.match(W)||[]).length}if(G>K)Z.push({type:"directive",message:`Unclosed @${X.name} directive: found ${G} opening and ${K} closing`,suggestion:`Add ${G-K} missing ${X.close} tag(s)`});else if(K>G)Y.push({type:"directive",message:`Extra ${X.close} found: ${K-G} more closing than opening`,suggestion:`Check for orphaned ${X.close} tags`})}}function sR($,Z){for(let Y of pR)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function aR($,Z){for(let Y of iR)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function LB($,Z){let Y=$.slice(0,Z).split(`
8736
+ `);return{line:Y.length,column:Y[Y.length-1].length+1}}function OB($,Z,Y){let X=[];switch($){case"if":case"elseif":case"unless":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a condition`,suggestion:`Use @${$}(condition)`});break;case"foreach":if(Y.length===0||!Y[0].includes(" as "))X.push({type:"syntax",message:'@foreach requires "items as item" syntax',suggestion:"Use @foreach(items as item) or @foreach(items as key => value)"});break;case"for":if(Y.length===0)X.push({type:"syntax",message:"@for requires loop parameters",suggestion:"Use @for(let i = 0; i < 10; i++)"});break;case"switch":if(Y.length===0)X.push({type:"syntax",message:"@switch requires an expression",suggestion:"Use @switch(expression)"});break;case"case":if(Y.length===0)X.push({type:"syntax",message:"@case requires a value",suggestion:"Use @case(value)"});break;case"include":case"extends":case"component":if(Y.length===0)X.push({type:"syntax",message:`@${$} requires a path`,suggestion:`Use @${$}('path/to/template')`});break}return X}function FB($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function VB($){let Z=$.matchAll(/@([a-z]+)/gi),Y=new Set;for(let X of Z){let J=X[1].toLowerCase();if(!J.startsWith("end"))Y.add(J)}return Array.from(Y)}var lR,pR,iR;var AB=D(()=>{lR=[{open:"@if",close:"@endif",name:"if"},{open:"@unless",close:"@endunless",name:"unless"},{open:"@foreach",close:"@endforeach",name:"foreach"},{open:"@for",close:"@endfor",name:"for"},{open:"@while",close:"@endwhile",name:"while"},{open:"@forelse",close:"@endforelse",name:"forelse"},{open:"@switch",close:"@endswitch",name:"switch"},{open:"@isset",close:"@endisset",name:"isset"},{open:"@empty",close:"@endempty",name:"empty"},{open:"@auth",close:"@endauth",name:"auth"},{open:"@guest",close:"@endguest",name:"guest"},{open:"@can",close:"@endcan",name:"can"},{open:"@cannot",close:"@endcannot",name:"cannot"},{open:"@section",close:"@endsection",name:"section",altClose:"@show"},{open:"@push",close:"@endpush",name:"push"},{open:"@prepend",close:"@endprepend",name:"prepend"},{open:"@once",close:"@endonce",name:"once"},{open:"@markdown",close:"@endmarkdown",name:"markdown"},{open:"@component",close:"@endcomponent",name:"component"}],pR=[{pattern:/@if\s*[^(]/,message:"@if directive missing parentheses",suggestion:"Use @if(condition)"},{pattern:/@foreach\s*[^(]/,message:"@foreach directive missing parentheses",suggestion:"Use @foreach(items as item)"},{pattern:/@foreach\([^)]*\)\s*[^@\n<]/,message:"@foreach may have content on same line",suggestion:"Put content on new line after @foreach()"},{pattern:/@include\s*[^(]/,message:"@include directive missing parentheses",suggestion:"Use @include('partial-name')"},{pattern:/@extends\s*[^(]/,message:"@extends directive missing parentheses",suggestion:"Use @extends('layout-name') or @layout('layout-name')"},{pattern:/@layout\s*[^(]/,message:"@layout directive missing parentheses",suggestion:"Use @layout('layout-name')"}],iR=[{pattern:/\{\{\s*constructor\s*\}\}/,message:"Attempting to access constructor property"},{pattern:/\{\{\s*__proto__\s*\}\}/,message:"Attempting to access __proto__ property"},{pattern:/\{\{\s*eval\s*\(/,message:"Attempting to use eval in expression"}]});var EB={};t(EB,{renderSlot:()=>DY,processSlots:()=>kY,parseSlots:()=>IY,parseSlotElement:()=>NB,extractSlotContent:()=>wB,applySlots:()=>MB});function oR($,Z){let Y=1,X=Z,J="<template",Q="</template";while(X<$.length&&Y>0){let G=$.indexOf("<",X);if(G===-1)break;if(X=G,$.startsWith(J,X)&&(X+J.length>=$.length||/[\s>\/]/.test($[X+J.length]))){Y++,X+=J.length;continue}if($.startsWith(Q,X)){let K=$.indexOf(">",X+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;X=K+1;continue}}X++}return Y===0?X:-1}function IY($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,J=[],Q;while((Q=X.exec($))!==null){let[_,B,z,q,j]=Q,H=B||z||q,L=Q.index+_.length,F=oR($,L);if(F!==-1){let O=$.slice(L,F-11).trim();J.push({start:Q.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}J.sort((_,B)=>B.start-_.start);for(let _ of J)Y=Y.slice(0,_.start)+Y.slice(_.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(Y))!==null){let[_,B,z,q,j,H]=W,L=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${B}${O?" "+O:""}>${H}</${B}>`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:V})}let U=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=U.exec(Y))!==null){let[_,B,z,q,j]=W,H=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${B}${F?" "+F:""} />`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:O})}G.sort((_,B)=>B.start-_.start);for(let _ of G){let B=Z.named.get(_.slotName);if(B)B.content+=_.element;else Z.named.set(_.slotName,{name:_.slotName,content:_.element});Y=Y.slice(0,_.start)+Y.slice(_.end)}return Z.default=Y.trim(),Z}function NB($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",X={},J=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=J.exec($))!==null)X[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:X,defaultContent:K}}async function DY($,Z,Y,X){if(!$)return Y;let J=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...X};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,_]=W.split(":").map((z)=>z.trim()),B=_||U;if(Z[U]!==void 0)G[B]=Z[U]}}else G[Q]=Z;J=tR(J,G)}return J}function tR($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=RB(J,Z);return I0(String(Q??""))}catch{return`{{ ${X} }}`}})}function RB($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),J=Z;for(let Q of X)if(J&&typeof J==="object"&&Q in J)J=J[Q];else return;return J}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,J,Q]=Y,G=Z[X],K=parseInt(Q,10);if(typeof G==="number")switch(J){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!L0($))return;return F0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function kY($,Z,Y){let X=$;X=await eR(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let _=Z.named.get(K),B=U?.trim()||"",z=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(z))!==null){let L=H[1],F=H[2];q[L]=RB(F,Y)}return await DY(_,q,B,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),X}async function eR($,Z,Y){let X=[],J=[];$.replace(Z,(K,...W)=>{let U=W[W.length-2];return J.push({match:K,index:U}),X.push(Y(K,...W.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:W,index:U}=J[K];G=G.slice(0,U)+Q[K]+G.slice(U+W.length)}return G}function wB($){let Z=IY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function MB($,Z,Y,X){return await kY($,{default:Z,named:Y},X)}var SY=D(()=>{r0();n0()});import $w from"fs";import B0 from"path";function Yw($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function TB($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function z6($){return!TB($)}function q6($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let J=new Bun.Transpiler({loader:"ts",target:"browser"}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)J=J.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),J=J.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return J}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function Xw($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(_)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===_){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let _=1;while(J<Q&&_>0)if($[J]==="{")_++;else if($[J]==="}")_--;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},W=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
8737
+ `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let 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 B=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(B){let j=B[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let z=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(z){let j=z[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}async function y1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (w6(),h8)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let B=new Set(_);B.add($);try{let z=(b)=>b.split("-").map((d)=>d.charAt(0).toUpperCase()+d.slice(1)).join(""),q=(b)=>b.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),j=$.endsWith(".stx")?$.slice(0,-4):$,H=null,L=J.__importedComponents;if(L){let b=[j,j.toLowerCase(),z(j),q(j)];for(let d of b)if(L.has(d)){H=L.get(d);break}}let F=[];if(!H){let b=[`${j}.stx`,`${z(j)}.stx`,`${q(j)}.stx`],d=[...new Set(b)],m=J.__originalFilePath,i=[];if(m){let W0=B0.join(B0.dirname(m),"components");i.push(W0)}if(X)i.push(X);let c=B0.join(B0.dirname(Q),"components");if(!i.includes(c))i.push(c);if(G.componentsDir&&G.componentsDir!==X&&!i.includes(G.componentsDir))i.push(G.componentsDir);let r=process.cwd(),_0=[B0.resolve(r,"src/components"),B0.resolve(r,"components"),B0.resolve(import.meta.dir,"components")];for(let W0 of _0)if(!i.includes(W0))i.push(W0);if(j.startsWith("./")||j.startsWith("../"))H=B0.resolve(B0.dirname(Q),`${j}.stx`),F.push(H);else for(let W0 of i){if(!W0)continue;for(let K0 of d){let R0=B0.join(W0,K0);if(F.push(R0),await $0(R0)){H=R0;break}}if(H)break;if(!H)try{let K0=await import("fs");if(!K0.statSync(W0,{throwIfNoEntry:!1})?.isDirectory())continue;let w0=K0.readdirSync(W0,{withFileTypes:!0});for(let o0 of w0)if(o0.isDirectory()){let n1=B0.join(W0,o0.name);for(let j4 of d){let j0=B0.join(n1,j4);if(F.push(j0),await $0(j0)){H=j0;break}}if(H)break}}catch{}if(H)break}}if(!H||!await $0(H)){let b=F.length>0?`
8738
8738
  Searched paths:
8739
8739
  ${F.map((d)=>` - ${d}`).join(`
8740
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${b}`}W.add(H);let O;if(T5.has(H))O=T5.get(H);else try{O=await Bun.file(H).text(),T5.set(H,O)}catch(b){return`[Error loading component: ${b instanceof Error?b.message:String(b)}]`}let V=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[b,d]of Object.entries(J))if(!b.startsWith("__")||V.has(b))N[b]=d;let A={...N,...Z,props:Z,slot:Y,__processedComponents:B,__sections:{}},R=O,M=R.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)R=M[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[...O.matchAll(E)],T=[];for(let b of I){let d=b[1]||"",m=b[2]||"",i=d.includes("server");if(z4(d)&&m.trim())m=q4(m);if(i&&m)try{await U(m,A,H)}catch(r){}if(!i){let r=m.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),_0=d.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");T.push(`<script${_0}>${r}</script>`)}}let S=O.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=S?S[1]:"",C=S?S[2]:"",x="",g=k&&/\bscoped\b/i.test(k);if(S)x=`<style${k}>${C}</style>`;let P=R;if(P=P.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S)P=P.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");if(Y&&P.includes("{{ text || slot }}"))P=P.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:f,applySlots:h}=await Promise.resolve().then(() => (SY(),EB)),{defaultSlot:u,namedSlots:l}=f(Y);P=await h(P,u||Y,l,A);for(let[b,d]of Object.entries(A))if(typeof d==="string"){if(d.includes("<")&&d.includes(">")||d.includes("&lt;")||d.includes("&quot;")){let m=U8(d);A[b]=m}}let p=T.some((b)=>/\b(state|derived|effect)\s*\(/.test(b)),Q0={...G,componentsDir:B0.dirname(H),skipSignalsRuntime:!0,skipEventDirectives:p,defaultLayout:void 0};A.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let X0=await J0(P,A,H,Q0,W),C0=`stx_${j.replace(/[^a-zA-Z0-9]/g,"_")}_${++Zw}_${Math.random().toString(36).slice(2,8)}`,T0=X0;if(p){let b="";if(Object.keys(Z).length>0)try{b=` data-stx-props="${Yw(JSON.stringify(Z))}"`}catch{}if(T0=`<div data-stx-scope="${C0}"${b}>${X0}</div>`,T0=T.map((m)=>{let i=m.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!i)return m;let[,c,r]=i,_0=B4(r),W0=`
8740
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${b}`}W.add(H);let O;if(T5.has(H))O=T5.get(H);else try{O=await Bun.file(H).text(),T5.set(H,O)}catch(b){return`[Error loading component: ${b instanceof Error?b.message:String(b)}]`}let V=new Set(["__originalFilePath","__importedComponents"]),N={};for(let[b,d]of Object.entries(J))if(!b.startsWith("__")||V.has(b))N[b]=d;let A={...N,...Z,props:Z,slot:Y,__processedComponents:B,__sections:{}},R=O,M=R.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)R=M[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[...O.matchAll(E)],T=[];for(let b of I){let d=b[1]||"",m=b[2]||"",i=d.includes("server");if(z6(d)&&m.trim())m=q6(m);if(i&&m)try{await U(m,A,H)}catch(r){}if(!i){let r=m.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),_0=d.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");T.push(`<script${_0}>${r}</script>`)}}let S=O.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=S?S[1]:"",C=S?S[2]:"",x="",g=k&&/\bscoped\b/i.test(k);if(S)x=`<style${k}>${C}</style>`;let P=R;if(P=P.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S)P=P.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");if(Y&&P.includes("{{ text || slot }}"))P=P.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:f,applySlots:h}=await Promise.resolve().then(() => (SY(),EB)),{defaultSlot:u,namedSlots:l}=f(Y);P=await h(P,u||Y,l,A);for(let[b,d]of Object.entries(A))if(typeof d==="string"){if(d.includes("<")&&d.includes(">")||d.includes("&lt;")||d.includes("&quot;")){let m=U8(d);A[b]=m}}let p=T.some((b)=>/\b(state|derived|effect)\s*\(/.test(b)),Q0={...G,componentsDir:B0.dirname(H),skipSignalsRuntime:!0,skipEventDirectives:p,defaultLayout:void 0};A.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let X0=await J0(P,A,H,Q0,W),C0=`stx_${j.replace(/[^a-zA-Z0-9]/g,"_")}_${++Zw}_${Math.random().toString(36).slice(2,8)}`,T0=X0;if(p){let b="";if(Object.keys(Z).length>0)try{b=` data-stx-props="${Yw(JSON.stringify(Z))}"`}catch{}if(T0=`<div data-stx-scope="${C0}"${b}>${X0}</div>`,T0=T.map((m)=>{let i=m.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!i)return m;let[,c,r]=i,_0=B6(r),W0=`
8741
8741
  (function() {
8742
8742
  const { state, derived, effect, batch } = window.stx;
8743
8743
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -8763,7 +8763,7 @@ catch (e) {}
8763
8763
  `)+`
8764
8764
  `+T0,x)T0+=`
8765
8765
  `+x}else{if(x)T0+=`
8766
- `+x;if(T.length>0){let b=A.__stx_event_bindings||[],d=await Promise.all(T.map(async(m)=>{let i=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!i)return m;return await i4(i[1],{eventBindings:b,templateContent:T0,filePath:H,projectRoot:process.cwd()})}));T0+=`
8766
+ `+x;if(T.length>0){let b=A.__stx_event_bindings||[],d=await Promise.all(T.map(async(m)=>{let i=m.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!i)return m;return await i6(i[1],{eventBindings:b,templateContent:T0,filePath:H,projectRoot:process.cwd()})}));T0+=`
8767
8767
  `+d.join(`
8768
8768
  `),A.__stx_event_bindings=[]}}if(g){let b=_5(T0,H);if(b.hasScoped)T0=b.html}return T0}catch(z){return`[Error processing component: ${z instanceof Error?z.message:String(z)}]`}finally{_.delete($)}}async function $0($){return Bun.file($).exists()}async function E5($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=B0.dirname(Z);if($.startsWith("/")){let B=B0.join(process.cwd(),$);if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await $0(B)&&X)X.add(B);return B}let Q=B0.join(J,$);if(await $0(Q)){if(Y.debug)console.log(`Found direct path: ${Q}`);if(X)X.add(Q);return Q}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let B of[".stx",".tsx",".jsx"]){let z=`${Q}${B}`;if(await $0(z)){if(Y.debug)console.log(`Found direct path with extension: ${z}`);if(X)X.add(z);return z}}let G="",K=B0.resolve(J),W=process.cwd();for(let B=0;B<10;B++){let z=B0.join(K,"layouts"),q=!1;try{q=$w.statSync(z,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(q){G=z;break}let j=B0.dirname(K);if(j===K||j.length<W.length)break;K=j}if(G){let B=$.startsWith("layouts/")?$.slice(8):$,z=B0.join(G,B);if(await $0(z)){if(Y.debug)console.log(`Found in current layouts dir: ${z}`);if(X)X.add(z);return z}if(!B.endsWith(".stx")){let q=`${z}.stx`;if(await $0(q)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.layoutsDir){let B=B0.isAbsolute(Y.layoutsDir)?Y.layoutsDir:B0.resolve(process.cwd(),Y.layoutsDir),z=$.startsWith("layouts/")?$.slice(8):$,q=B0.join(B,z);if(await $0(q)){if(Y.debug)console.log(`Found in options.layoutsDir: ${q}`);if(X)X.add(q);return q}if(!$.endsWith(".stx")){let j=`${q}.stx`;if(await $0(j)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${j}`);if(X)X.add(j);return j}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let B=$.split("layouts/"),z=B0.join(Y.partialsDir||J,"layouts",B[1]);if(await $0(z)){if(Y.debug)console.log(`Found in layouts path: ${z}`);if(X)X.add(z);return z}if(!z.endsWith(".stx")){let q=`${z}.stx`;if(await $0(q)){if(Y.debug)console.log(`Found in layouts path with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.partialsDir){if(G=B0.join(Y.partialsDir,"layouts"),await $0(G)){let B=B0.join(G,$);if(await $0(B)){if(Y.debug)console.log(`Found in partials layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let z=`${B}.stx`;if(await $0(z)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${z}`);if(X)X.add(z);return z}}}}let U=Y.partialsDir||B0.join(process.cwd(),"views"),_=B0.join(U,$);if(await $0(_)){if(Y.debug)console.log(`Found in views path: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await $0(B)){if(Y.debug)console.log(`Found in views path with extension: ${B}`);if(X)X.add(B);return B}}if(J.includes("temp")){let B=B0.join(B0.dirname(J),"layouts",$);if(await $0(B)){if(Y.debug)console.log(`Found in temp layouts dir: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let z=`${B}.stx`;if(await $0(z)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${z}`);if(X)X.add(z);return z}}}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 bY($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
8769
8769
  `),K=0;for(let W=0;W<G.length;W++)if(K+=G[W].length+1,K>=Z){X=W+1,J=G[W].trim();let U=Math.max(0,W-2),_=Math.min(G.length,W+3);Q=G.slice(U,_).map((B,z)=>{let q=U+z+1;return`${q===X?"> ":" "}${q}: ${B}`}).join(`
@@ -8777,7 +8777,7 @@ ${U0.yellow}${U0.bold}Message:${U0.reset} ${Z}
8777
8777
  `,K)U+=`
8778
8778
  ${U0.blue}${U0.bold}Context:${U0.reset}
8779
8779
  ${U0.dim}${K}${U0.reset}
8780
- `;return U}function D4(){T5.clear()}function Jw(){return{size:T5.size,maxSize:500}}var T5,Zw=0,U0;var H0=D(()=>{m$();r0();j4();J1();t8();AB();w4();T5=new r$(500);U0={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function EY($,Z,Y=""){let X=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let K=G.index,W=G[0].match(/@markdown\(([^)]*)\)/),U=W?W[1]:"",_=K+G[0].length,B=1,z=_,q=-1;while(B>0&&z<$.length){let L=$.indexOf("@markdown",z),F=$.indexOf("@endmarkdown",z);if(F===-1)break;if(L!==-1&&L<F&&L!==K){let O=$[L+9];if(O==="("||O===`
8780
+ `;return U}function D6(){T5.clear()}function Jw(){return{size:T5.size,maxSize:500}}var T5,Zw=0,U0;var H0=D(()=>{m$();r0();j6();J1();t8();AB();w6();T5=new r$(500);U0={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function EY($,Z,Y=""){let X=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let K=G.index,W=G[0].match(/@markdown\(([^)]*)\)/),U=W?W[1]:"",_=K+G[0].length,B=1,z=_,q=-1;while(B>0&&z<$.length){let L=$.indexOf("@markdown",z),F=$.indexOf("@endmarkdown",z);if(F===-1)break;if(L!==-1&&L<F&&L!==K){let O=$[L+9];if(O==="("||O===`
8781
8781
  `||O==="\r"||O===" "||O===void 0)B++;z=L+9}else{if(B--,B===0){q=F;break}z=F+12}}if(q===-1)continue;let j=$.slice(_,q),H=$.slice(K,q+12);J.push({fullMatch:H,options:U,content:j,index:K}),Q.lastIndex=q+12}for(let{fullMatch:K,options:W,content:U,index:_}of J)try{let B={};if(W)W.split(",").forEach((j)=>{let H=j.trim();if(H)B[H]=!0});let z={gfm:B.gfm??!0,breaks:B.breaks??!1},q=d$(U.trim(),z);X=X.split(K).join(q)}catch(B){let z=B instanceof Error?B.message:String(B),q=O0("Markdown Directive",`Error processing markdown: ${z}`,Y,$,_,K);X=X.split(K).join(q)}return X}async function CY($,Z,Y,X){let J={gfm:!0,breaks:!1};return Z.forEach((Q)=>{let G=Q.trim().replace(/['"]/g,"");if(G==="breaks")J.breaks=!0;if(G==="no-gfm")J.gfm=!1}),d$($.trim(),J)}var M9=D(()=>{H0()});function IB($){if(E9.set($.name,$),$.client)PY.set($.name,$.client)}function Qw($){return E9.get($)}function Gw(){return Array.from(E9.values())}function Kw($){return PY.delete($),E9.delete($)}function b0($){return IB($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,X,J,Q)=>{let G=Uw(X,$.defaults);if($.validate){let W=$.validate(G);if(W!==!0){let U=typeof W==="string"?W:`Invalid parameters for @${$.name}`;throw Error(U)}}let K=Y;if($.transform)K=await $.transform(Y,G,J,Q);if($.clientScript){let W=$.clientScript(G);K+=`<script>${W}</script>`}if($.css){let W=$.css(G);K+=`<style>${W}</style>`}return K}}}function Ww($,Z){let Y=typeof Z==="function"?{mounted:Z}:Z;return PY.set($,Y),Y}function Uw($,Z){let Y={...Z};for(let X of $){let J=X.indexOf(":"),Q=X.indexOf("="),G=J>=0&&(Q<0||J<Q)?J:Q;if(G>=0){let K=X.slice(0,G).trim(),W=X.slice(G+1).trim();if(W==="true")W=!0;else if(W==="false")W=!1;else if(W==="null")W=null;else if(!Number.isNaN(Number(W)))W=Number(W);else if(typeof W==="string"&&W.startsWith("{"))try{W=JSON.parse(W)}catch{}Y[K]=W}else{let K=Object.keys(Y).filter((W)=>!Z||!(W in Z)).length;Y[K===0?"value":`arg${K}`]=X}}return Y}function _w(){return[b0({name:"uppercase",description:"Convert content to uppercase",transform:($)=>$.toUpperCase()}),b0({name:"lowercase",description:"Convert content to lowercase",transform:($)=>$.toLowerCase()}),b0({name:"capitalize",description:"Capitalize first letter of content",transform:($)=>$.charAt(0).toUpperCase()+$.slice(1)}),b0({name:"trim",description:"Remove leading and trailing whitespace",transform:($)=>$.trim()}),b0({name:"truncate",description:"Truncate content to specified length",defaults:{length:100,suffix:"..."},transform:($,{length:Z,suffix:Y})=>$.length>Z?$.slice(0,Z)+Y:$}),b0({name:"highlight",description:"Highlight content with background color",defaults:{color:"yellow"},transform:($,{color:Z})=>`<mark style="background-color: ${Z}; padding: 0.1em 0.2em; border-radius: 0.2em;">${$}</mark>`}),b0({name:"badge",description:"Create a badge/tag",defaults:{variant:"default",color:""},transform:($,{variant:Z,color:Y})=>{let X={default:"background: #e5e7eb; color: #374151;",primary:"background: #3b82f6; color: white;",success:"background: #10b981; color: white;",warning:"background: #f59e0b; color: white;",danger:"background: #ef4444; color: white;",info:"background: #06b6d4; color: white;"};return`<span style="${Y?`background: ${Y}; color: white;`:X[Z]||X.default} padding: 0.25em 0.5em; border-radius: 9999px; font-size: 0.875em; font-weight: 500;">${$}</span>`}}),b0({name:"code",description:"Style content as inline code",transform:($)=>`<code style="background: #f3f4f6; padding: 0.2em 0.4em; border-radius: 0.25em; font-family: ui-monospace, monospace; font-size: 0.875em;">${$}</code>`}),b0({name:"tooltip",description:"Add a tooltip to content",defaults:{text:"",position:"top"},hasEndTag:!0,transform:($,{text:Z,position:Y})=>`<span class="stx-tooltip" data-tooltip="${Z}" data-tooltip-position="${Y}" style="position: relative; cursor: help;">${$}</span>`,css:()=>`
8782
8782
  .stx-tooltip::after {
8783
8783
  content: attr(data-tooltip);
@@ -8922,8 +8922,8 @@ ${U0.dim}${K}${U0.reset}
8922
8922
 
8923
8923
  console.log('[stx] Directive runtime initialized');
8924
8924
  })();
8925
- `}function zw($){let Z=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return $.replace(Z,(Y,X,J,Q,G)=>{let W=(Q?Q.split("."):[]).reduce((U,_)=>{return U[_]=!0,U},{});return`data-stx-directive="${X}:${G}" data-stx-directive-arg="${J||""}" data-stx-directive-modifiers='${JSON.stringify(W)}'`})}var E9,PY;var I5=D(()=>{E9=new Map,PY=new Map});function k4($,Z=g1,Y={},X){return Z.sort((J,Q)=>J-Q).map((J)=>{return`${M1($,{...Y,w:J,fm:X})} ${J}w`}).join(", ")}function yY($,Z=320,Y=2560,X=0.08,J={},Q){let G=T9(Z,Y,X);return k4($,G,J,Q)}function T9($,Z,Y=0.08){let X=[],J=$;while(J<Z)X.push(Math.round(J)),J*=1+Y*2;if(X[X.length-1]!==Z)X.push(Z);return X}function m6($,Z,Y=D5,X={},J){return Y.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${M1($,{...X,w:G,dpr:Q,fm:J})} ${Q}x`}).join(", ")}function xY($,Z,Y=D5,X=80,J={},Q){let G={1:X,1.5:Math.round(X*0.9),2:Math.round(X*0.8),3:Math.round(X*0.7),4:Math.round(X*0.6),5:Math.round(X*0.5)};return Y.sort((K,W)=>K-W).map((K)=>{let W=Math.round(Z*K),U=G[K]||Math.round(X*Math.max(0.5,1-K*0.1));return`${M1($,{...J,w:W,q:U,dpr:K,fm:Q})} ${K}x`}).join(", ")}function u6($,Z="100vw"){if(!$||Object.keys($).length===0)return Z;let X=Object.entries($).map(([J,Q])=>{let G=/^\d+$/.test(J)?`${J}px`:J;return{bp:G,size:Q,numericBp:Number.parseInt(G)||0}}).sort((J,Q)=>J.numericBp-Q.numericBp).map(({bp:J,size:Q})=>`(max-width: ${J}) ${Q}`);return X.push(Z),X.join(", ")}function vY($,Z="100vw"){if(!$||$.length===0)return Z;let X=[...$].sort((J,Q)=>(J.maxWidth||0)-(Q.maxWidth||0)).filter((J)=>J.maxWidth).map((J)=>`(max-width: ${J.maxWidth}px) ${J.imageWidth}`);return X.push(Z),X.join(", ")}function M1($,Z={}){let Y=Object.entries(Z).filter(([,Q])=>Q!==void 0&&Q!==null).map(([Q,G])=>{if(Array.isArray(G))return[Q,G.join(",")];return[Q,String(G)]});if(Y.length===0)return $;let X=Y.map(([Q,G])=>`${Q}=${encodeURIComponent(G)}`).join("&"),J=$.includes("?")?"&":"?";return`${$}${J}${X}`}function fY($){let[Z,Y]=$.split("?"),X={};if(Y)new URLSearchParams(Y).forEach((Q,G)=>{if(/^\d+$/.test(Q))X[G]=Number.parseInt(Q,10);else if(/^\d+\.\d+$/.test(Q))X[G]=Number.parseFloat(Q);else if(Q==="true")X[G]=!0;else if(Q==="false")X[G]=!1;else X[G]=Q});return{src:Z,params:X}}function hY($){let{src:Z,widths:Y,dprValues:X,fixedWidth:J,formats:Q=$4,baseUrl:G="",params:K={}}=$,W=[];for(let U of Q){let _,B;if(J!==void 0&&X)_=m6(Z,J,X,K,U),B=X.map((z)=>({path:"",url:M1(Z,{...K,w:Math.round(J*z),fm:U}),width:Math.round(J*z),height:0,format:U,size:0,dpr:z}));else{let z=Y||g1;_=k4(Z,z,K,U),B=z.map((q)=>({path:"",url:M1(Z,{...K,w:q,fm:U}),width:q,height:0,format:U,size:0}))}W.push({srcset:_,format:U,mimeType:k5[U],variants:B})}return W}function dY($,Z="100vw"){return $.map(({srcset:Y,mimeType:X})=>`<source type="${X}" srcset="${Y}" sizes="${Z}" />`).join(`
8926
- `)}function mY($,Z){if($.length===0)return;let Y=[...$].sort((J,Q)=>J.width-Q.width),X=Y.find((J)=>J.width>=Z);if(X)return X;return Y[Y.length-1]}function S5($){return k5[$]||"application/octet-stream"}function uY($){return DB[$]||$}function cY($){switch($.split(".").pop()?.toLowerCase()){case"jpg":case"jpeg":return"jpeg";case"png":return"png";case"webp":return"webp";case"avif":return"avif";case"gif":return"gif";default:return}}var g1,D5,$4,k5,DB,gY;var I9=D(()=>{g1=[320,480,640,768,1024,1280,1536,1920,2560],D5=[1,1.5,2,3],$4=["avif","webp","jpeg"],k5={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},DB={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};gY={fullWidth:"100vw",halfDesktop:"(max-width: 768px) 100vw, 50vw",thirdDesktop:"(max-width: 768px) 100vw, 33.33vw",quarterDesktop:"(max-width: 480px) 100vw, (max-width: 768px) 50vw, 25vw",contentWidth:"(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 960px"}});async function lY(){try{return await import("ts-images")}catch{return null}}async function b5($,Z={}){let Y={...D9,...Z},X=await lY();if(X)try{return await qw($,Y,X)}catch(J){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${J}`)}return kB($,Y)}async function qw($,Z,Y){let{generatePlaceholder:X,generateThumbHash:J}=Y,G={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[Z.strategy]||"blur";if(Z.strategy==="thumbhash")return{dataURL:(await J($)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let K=await X($,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:G,base64Encode:!0});return{dataURL:K.dataURL,width:K.width,height:K.height,aspectRatio:K.aspectRatio,originalWidth:K.originalWidth,originalHeight:K.originalHeight,strategy:Z.strategy,dominantColor:K.dominantColor,css:K.css}}function kB($,Z){let Y=Z.width||20,X=Z.height||Y,J="#e5e7eb",Q=`<svg xmlns="http://www.w3.org/2000/svg" width="${Y}" height="${X}" viewBox="0 0 ${Y} ${X}"><rect fill="#e5e7eb" width="${Y}" height="${X}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Q)}`,width:Y,height:X,aspectRatio:Y/X,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}async function pY($){let Z=await lY();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await kB($,{strategy:"thumbhash",width:32,height:32})).dataURL}function iY($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,X=(Z>>6&63)/31.5-1,J=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,_=K>>15!==0,B=Math.max(3,_?G?5:7:G?5:7),z=Math.max(3,_?G?5:7:G?5:7),q=32,j=32,H=Math.max(0,Math.min(255,Math.round((Y+X)*255))),L=Math.max(0,Math.min(255,Math.round(Y*255))),F=Math.max(0,Math.min(255,Math.round((Y-X)*255))),O=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
8925
+ `}function zw($){let Z=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return $.replace(Z,(Y,X,J,Q,G)=>{let W=(Q?Q.split("."):[]).reduce((U,_)=>{return U[_]=!0,U},{});return`data-stx-directive="${X}:${G}" data-stx-directive-arg="${J||""}" data-stx-directive-modifiers='${JSON.stringify(W)}'`})}var E9,PY;var I5=D(()=>{E9=new Map,PY=new Map});function k6($,Z=g1,Y={},X){return Z.sort((J,Q)=>J-Q).map((J)=>{return`${M1($,{...Y,w:J,fm:X})} ${J}w`}).join(", ")}function yY($,Z=320,Y=2560,X=0.08,J={},Q){let G=T9(Z,Y,X);return k6($,G,J,Q)}function T9($,Z,Y=0.08){let X=[],J=$;while(J<Z)X.push(Math.round(J)),J*=1+Y*2;if(X[X.length-1]!==Z)X.push(Z);return X}function m4($,Z,Y=D5,X={},J){return Y.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${M1($,{...X,w:G,dpr:Q,fm:J})} ${Q}x`}).join(", ")}function xY($,Z,Y=D5,X=80,J={},Q){let G={1:X,1.5:Math.round(X*0.9),2:Math.round(X*0.8),3:Math.round(X*0.7),4:Math.round(X*0.6),5:Math.round(X*0.5)};return Y.sort((K,W)=>K-W).map((K)=>{let W=Math.round(Z*K),U=G[K]||Math.round(X*Math.max(0.5,1-K*0.1));return`${M1($,{...J,w:W,q:U,dpr:K,fm:Q})} ${K}x`}).join(", ")}function u4($,Z="100vw"){if(!$||Object.keys($).length===0)return Z;let X=Object.entries($).map(([J,Q])=>{let G=/^\d+$/.test(J)?`${J}px`:J;return{bp:G,size:Q,numericBp:Number.parseInt(G)||0}}).sort((J,Q)=>J.numericBp-Q.numericBp).map(({bp:J,size:Q})=>`(max-width: ${J}) ${Q}`);return X.push(Z),X.join(", ")}function vY($,Z="100vw"){if(!$||$.length===0)return Z;let X=[...$].sort((J,Q)=>(J.maxWidth||0)-(Q.maxWidth||0)).filter((J)=>J.maxWidth).map((J)=>`(max-width: ${J.maxWidth}px) ${J.imageWidth}`);return X.push(Z),X.join(", ")}function M1($,Z={}){let Y=Object.entries(Z).filter(([,Q])=>Q!==void 0&&Q!==null).map(([Q,G])=>{if(Array.isArray(G))return[Q,G.join(",")];return[Q,String(G)]});if(Y.length===0)return $;let X=Y.map(([Q,G])=>`${Q}=${encodeURIComponent(G)}`).join("&"),J=$.includes("?")?"&":"?";return`${$}${J}${X}`}function fY($){let[Z,Y]=$.split("?"),X={};if(Y)new URLSearchParams(Y).forEach((Q,G)=>{if(/^\d+$/.test(Q))X[G]=Number.parseInt(Q,10);else if(/^\d+\.\d+$/.test(Q))X[G]=Number.parseFloat(Q);else if(Q==="true")X[G]=!0;else if(Q==="false")X[G]=!1;else X[G]=Q});return{src:Z,params:X}}function hY($){let{src:Z,widths:Y,dprValues:X,fixedWidth:J,formats:Q=$6,baseUrl:G="",params:K={}}=$,W=[];for(let U of Q){let _,B;if(J!==void 0&&X)_=m4(Z,J,X,K,U),B=X.map((z)=>({path:"",url:M1(Z,{...K,w:Math.round(J*z),fm:U}),width:Math.round(J*z),height:0,format:U,size:0,dpr:z}));else{let z=Y||g1;_=k6(Z,z,K,U),B=z.map((q)=>({path:"",url:M1(Z,{...K,w:q,fm:U}),width:q,height:0,format:U,size:0}))}W.push({srcset:_,format:U,mimeType:k5[U],variants:B})}return W}function dY($,Z="100vw"){return $.map(({srcset:Y,mimeType:X})=>`<source type="${X}" srcset="${Y}" sizes="${Z}" />`).join(`
8926
+ `)}function mY($,Z){if($.length===0)return;let Y=[...$].sort((J,Q)=>J.width-Q.width),X=Y.find((J)=>J.width>=Z);if(X)return X;return Y[Y.length-1]}function S5($){return k5[$]||"application/octet-stream"}function uY($){return DB[$]||$}function cY($){switch($.split(".").pop()?.toLowerCase()){case"jpg":case"jpeg":return"jpeg";case"png":return"png";case"webp":return"webp";case"avif":return"avif";case"gif":return"gif";default:return}}var g1,D5,$6,k5,DB,gY;var I9=D(()=>{g1=[320,480,640,768,1024,1280,1536,1920,2560],D5=[1,1.5,2,3],$6=["avif","webp","jpeg"],k5={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},DB={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};gY={fullWidth:"100vw",halfDesktop:"(max-width: 768px) 100vw, 50vw",thirdDesktop:"(max-width: 768px) 100vw, 33.33vw",quarterDesktop:"(max-width: 480px) 100vw, (max-width: 768px) 50vw, 25vw",contentWidth:"(max-width: 768px) 100vw, (max-width: 1200px) 80vw, 960px"}});async function lY(){try{return await import("ts-images")}catch{return null}}async function b5($,Z={}){let Y={...D9,...Z},X=await lY();if(X)try{return await qw($,Y,X)}catch(J){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${J}`)}return kB($,Y)}async function qw($,Z,Y){let{generatePlaceholder:X,generateThumbHash:J}=Y,G={blur:"blur",thumbhash:"thumbhash",blurhash:"thumbhash",pixelate:"pixelate","dominant-color":"dominant-color",none:"blur"}[Z.strategy]||"blur";if(Z.strategy==="thumbhash")return{dataURL:(await J($)).dataUrl,width:32,height:32,aspectRatio:1,originalWidth:0,originalHeight:0,strategy:"thumbhash"};let K=await X($,{width:Z.width,height:Z.height,quality:Z.quality,blurLevel:Z.blurLevel,strategy:G,base64Encode:!0});return{dataURL:K.dataURL,width:K.width,height:K.height,aspectRatio:K.aspectRatio,originalWidth:K.originalWidth,originalHeight:K.originalHeight,strategy:Z.strategy,dominantColor:K.dominantColor,css:K.css}}function kB($,Z){let Y=Z.width||20,X=Z.height||Y,J="#e5e7eb",Q=`<svg xmlns="http://www.w3.org/2000/svg" width="${Y}" height="${X}" viewBox="0 0 ${Y} ${X}"><rect fill="#e5e7eb" width="${Y}" height="${X}"/></svg>`;return{dataURL:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Q)}`,width:Y,height:X,aspectRatio:Y/X,originalWidth:0,originalHeight:0,strategy:Z.strategy,dominantColor:"#e5e7eb"}}async function pY($){let Z=await lY();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await kB($,{strategy:"thumbhash",width:32,height:32})).dataURL}function iY($){let Z=$[0]|$[1]<<8|$[2]<<16,Y=(Z&63)/63,X=(Z>>6&63)/31.5-1,J=(Z>>12&63)/31.5-1,Q=(Z>>18&31)/31,G=Z>>23!==0,K=$[3]|$[4]<<8,W=(K>>3&63)/63,U=(K>>9&63)/63,_=K>>15!==0,B=Math.max(3,_?G?5:7:G?5:7),z=Math.max(3,_?G?5:7:G?5:7),q=32,j=32,H=Math.max(0,Math.min(255,Math.round((Y+X)*255))),L=Math.max(0,Math.min(255,Math.round(Y*255))),F=Math.max(0,Math.min(255,Math.round((Y-X)*255))),O=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
8927
8927
  <rect fill="rgb(${H},${L},${F})" width="32" height="32"/>
8928
8928
  </svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(O)}`}async function nY($,Z=20,Y=50){return b5($,{strategy:"blur",width:Z,quality:Y,blurLevel:40})}async function rY($){let Z=await lY();if(Z)try{return(await Z.generatePlaceholder($,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function sY($,Z=1,Y=1){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${Z}" height="${Y}"><rect fill="${$}" width="${Z}" height="${Y}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(X)}`}function C5($,Z,Y={}){let X=Y.transitionDuration||300,J=Y.easing||"ease-out";return`
8929
8929
  #${$} {
@@ -8942,7 +8942,7 @@ ${U0.dim}${K}${U0.reset}
8942
8942
  #${$}.stx-img-loaded img {
8943
8943
  opacity: 1;
8944
8944
  }
8945
- `.trim()}function aY($){return`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`}async function P5($,Z={}){let Y=`${$}:${JSON.stringify(Z)}`;if(c6.has(Y))return c6.get(Y);let X=await b5($,Z);return c6.set(Y,X),X}function oY(){c6.clear()}function tY(){return{size:c6.size,keys:Array.from(c6.keys())}}var D9,l6,c6;var eY=D(()=>{D9={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},l6=`
8945
+ `.trim()}function aY($){return`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`}async function P5($,Z={}){let Y=`${$}:${JSON.stringify(Z)}`;if(c4.has(Y))return c4.get(Y);let X=await b5($,Z);return c4.set(Y,X),X}function oY(){c4.clear()}function tY(){return{size:c4.size,keys:Array.from(c4.keys())}}var D9,l4,c4;var eY=D(()=>{D9={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},l4=`
8946
8946
  .stx-img-placeholder {
8947
8947
  position: relative;
8948
8948
  overflow: hidden;
@@ -8971,8 +8971,8 @@ ${U0.dim}${K}${U0.reset}
8971
8971
  filter: blur(0);
8972
8972
  transform: scale(1);
8973
8973
  }
8974
- `.trim();c6=new Map});import{createHash as $X}from"crypto";import{readFile as jw,stat as SB}from"fs/promises";async function l0($){try{let Z=await jw($);return $X("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function bB($){return $X("sha256").update($).digest("hex").slice(0,16)}function k9($){return $X("sha256").update($).digest("hex").slice(0,16)}function p6($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${k9($)}-${k9(Y)}`}async function y5($){try{return(await SB($)).mtimeMs}catch{return 0}}async function p0($){try{return await SB($),!0}catch{return!1}}var S4=()=>{};import{mkdir as Hw,readFile as PB,writeFile as Lw,readdir as yB,rm as ZX,stat as Ow}from"fs/promises";import{join as i6,dirname as Fw}from"path";async function Vw($){try{await Hw($,{recursive:!0})}catch{}}function xB($,Z,Y){return i6($,Y,`${Z}.json`)}async function CB($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await y5(Z)!==$.srcMtime)return!1;return!0}async function n6($,Z,Y,X=x5){if(!X.enabled)return null;let J=p6($,Z),Q=b4.get(J);if(Q){if(await CB(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;b4.delete(J)}let G=xB(X.directory,J,Y);if(await p0(G))try{let K=await PB(G,"utf-8"),W=JSON.parse(K);if(await CB(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),b4.set(J,W),W.data}catch{}return null}async function r6($,Z,Y,X,J=x5){if(!J.enabled)return;let Q=p6($,Z),G=await l0($),K=await y5($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:p6("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};b4.set(Q,W);let U=xB(J.directory,Q,X);try{await Vw(Fw(U)),await Lw(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function s6($,Z=x5){if($==="all")b4.clear();else b4.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=i6(Z.directory,X);try{await ZX(J,{recursive:!0,force:!0})}catch{}}}async function vB($=x5){let Z={memoryEntries:b4.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=i6($.directory,Y);try{let J=await yB(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=i6(X,Q),K=await Ow(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function gB($=x5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=i6($.directory,X);try{let Q=await yB(J);for(let G of Q){let K=i6(J,G);try{let W=await PB(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await ZX(K),b4.delete(U.key),Z++}catch{await ZX(K).catch(()=>{}),Z++}}}catch{}}return Z}var b4,x5;var S9=D(()=>{S4();b4=new Map,x5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class a6{config;constructor($={}){this.config={...Aw,...$}}async get($,Z){return n6($,Z,"image",this.config)}async set($,Z,Y){return r6($,Z,Y,"image",this.config)}async clear(){return s6("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function YX($){if(!b9)b9=new a6($);else if($)b9.updateConfig($);return b9}async function o6($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return YX(X).get($,Z)}async function t6($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return YX(J).set($,Z,Y)}async function XX(){return YX().clear()}var Aw,b9=null;var JX=D(()=>{S9();Aw={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as Nw,basename as Rw,extname as ww,join as Mw}from"path";import{mkdir as Ew}from"fs/promises";async function QX(){try{return await import("ts-images")}catch{return null}}function fB($){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 Tw($,Z){let Y=Z?fB(Z):fB("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 GX($,Z,Y){let X=await QX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await o6($,Z,Y);if(J)return J;try{let Q=Nw($);if(!await p0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=Tw(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await Ew(K,{recursive:!0});let U=await l0(Q),_=Rw($,ww($)),B=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await v5(Q,Z.transformations,X);for(let j of B){let H=G[j]||{},L=`${_}-${U}.${j}`,F=Mw(K,L);try{let O=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(z.variants.push({path:F,url:`${W}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!z.originalWidth&&O.width)z.originalWidth=O.width,z.originalHeight=O.height}}catch(O){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);z.placeholder=j.dataUrl}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});z.dominantColor=j.dominantColor}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${j}`)}return await t6($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function KX($,Z,Y,X){let J=await QX();if(!J)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await J.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function v5($,Z,Y){let X=Y||await QX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let J=await X.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)J=await X.resize(J,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)J=await X.blur(J,G.sigma);break;case"sharpen":if(G.amount!==void 0)J=await X.sharpen(J,G.amount);break;case"grayscale":J=await X.grayscale(J);break;case"rotate":if(G.angle!==void 0)J=await X.rotate(J,G.angle);break;case"flip":J=await X.flip(J);break;case"flop":J=await X.flop(J);break;case"brightness":if(G.value!==void 0)J=await X.brightness(J,G.value);break;case"contrast":if(G.value!==void 0)J=await X.contrast(J,G.value);break;case"saturation":if(G.value!==void 0)J=await X.saturation(J,G.value);break}}return await X.encode(J,"png")}catch(J){return console.error(`[stx-media] Transformation failed: ${J}`),null}}var hB=D(()=>{S4();JX()});import{resolve as Iw,basename as Dw,extname as kw,join as Sw}from"path";import{mkdir as bw}from"fs/promises";async function Cw(){try{return await import("ts-images")}catch{return null}}async function C9($,Z,Y){let X=await Cw();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=Iw($);if(!await p0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||Pw,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await bw(K,{recursive:!0});let U=await l0(J),_=Dw($,kw($)),B=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let j of G){z.byFormat[j]=[];let H=[];for(let L of Q){let F=`${_}-${L}w-${U}.${j}`,O=Sw(K,F),V=`${W}/${F}`;try{let N=B[j]?.quality||80;if(await p0(O)){z.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:J,output:O,format:j,quality:N,resize:{width:L}});if(A)z.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(N){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${N}`)}}z.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);z.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});z.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return z.sizes=Z.sizes||yw(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function yw($){let Z=[...$].sort((X,J)=>X-J),Y=[];for(let X=0;X<Z.length-1;X++){let J=Z[X];Y.push(`(max-width: ${J}px) ${J}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function P9($,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 Pw;var dB=D(()=>{S4();Pw=[320,480,640,768,1024,1280,1536,1920]});var mB={};t(mB,{setCachedImageResult:()=>t6,processImage:()=>GX,optimizeImage:()=>KX,getCachedImageResult:()=>o6,generateSrcset:()=>P9,generateResponsiveVariants:()=>C9,clearImageCache:()=>XX,applyTransformations:()=>v5,ImageProcessorCache:()=>a6});var WX=D(()=>{hB();dB();JX()});async function xw(){try{return await Promise.resolve().then(() => (WX(),mB))}catch($){if(!uB)console.warn("[stx-media] Image processor not available, some features disabled:",$),uB=!0;return null}}async function C4($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return hw(X,Y)}if(Y.processedResult?.processed)return qX($,Y.processedResult,Z);if(Y.responsiveVariants)return iB($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=g1,dpr:_,formats:B=$4,quality:z=UX,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":x9,decoding:V=y9,fetchpriority:N,objectFit:A,objectPosition:R,crossorigin:M,referrerpolicy:E}=$,I=$.class,T=$.style,S=$.id,k=$.data||{},{isDev:C=!1,baseUrl:x=""}=Z;if(C&&!Z.optimize)return fw($);let g,P,f=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{g=await P5(J,{strategy:j,...H}),P=C5(f,g,H)}catch{}let h=_!==void 0&&G!==void 0,u;if(h)u=gw($,f,g,Z);else u=await vw($,f,g,Z);let l;if(F){let X0=B.includes("webp")?"webp":B[0],C0=k4(J,U,{...q,q:z},X0),T0=typeof W==="object"?u6(W):W||"100vw";l=`<link rel="preload" as="image" imagesrcset="${C0}" imagesizes="${T0}" />`}let p=[];if(!cB&&j!=="none")p.push(l6),cB=!0;if(P)p.push(P);let Q0=L?pB(f):void 0;return{html:u,preloadLink:l,css:p.length>0?p.join(`
8975
- `):void 0,script:Q0}}async function vw($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=g1,formats:_=$4,quality:B=UX,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":x9,decoding:L=y9,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:N,referrerpolicy:A}=$,R=$.class,M=$.style,E=$.data||{},I=typeof W==="object"?u6(W):W||"100vw",T=[];for(let C of _){let x=k4(J,U,{...z,q:B},C),g=S5(C);if(q&&!j)T.push(` <source type="${g}" data-srcset="${x}" data-sizes="${I}" />`);else T.push(` <source type="${g}" srcset="${x}" sizes="${I}" />`)}let S=_X({src:M1(J,{...z,q:B}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:N,referrerpolicy:A,className:lB(R,Y),style:BX(M,O,V,Y),lazy:q&&!j,data:E}),k;if(Y){let C=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${C}">
8974
+ `.trim();c4=new Map});import{createHash as $X}from"crypto";import{readFile as jw,stat as SB}from"fs/promises";async function l0($){try{let Z=await jw($);return $X("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function bB($){return $X("sha256").update($).digest("hex").slice(0,16)}function k9($){return $X("sha256").update($).digest("hex").slice(0,16)}function p4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${k9($)}-${k9(Y)}`}async function y5($){try{return(await SB($)).mtimeMs}catch{return 0}}async function p0($){try{return await SB($),!0}catch{return!1}}var S6=()=>{};import{mkdir as Hw,readFile as PB,writeFile as Lw,readdir as yB,rm as ZX,stat as Ow}from"fs/promises";import{join as i4,dirname as Fw}from"path";async function Vw($){try{await Hw($,{recursive:!0})}catch{}}function xB($,Z,Y){return i4($,Y,`${Z}.json`)}async function CB($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await y5(Z)!==$.srcMtime)return!1;return!0}async function n4($,Z,Y,X=x5){if(!X.enabled)return null;let J=p4($,Z),Q=b6.get(J);if(Q){if(await CB(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;b6.delete(J)}let G=xB(X.directory,J,Y);if(await p0(G))try{let K=await PB(G,"utf-8"),W=JSON.parse(K);if(await CB(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),b6.set(J,W),W.data}catch{}return null}async function r4($,Z,Y,X,J=x5){if(!J.enabled)return;let Q=p4($,Z),G=await l0($),K=await y5($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:p4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};b6.set(Q,W);let U=xB(J.directory,Q,X);try{await Vw(Fw(U)),await Lw(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function s4($,Z=x5){if($==="all")b6.clear();else b6.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=i4(Z.directory,X);try{await ZX(J,{recursive:!0,force:!0})}catch{}}}async function vB($=x5){let Z={memoryEntries:b6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=i4($.directory,Y);try{let J=await yB(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=i4(X,Q),K=await Ow(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function gB($=x5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=i4($.directory,X);try{let Q=await yB(J);for(let G of Q){let K=i4(J,G);try{let W=await PB(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await ZX(K),b6.delete(U.key),Z++}catch{await ZX(K).catch(()=>{}),Z++}}}catch{}}return Z}var b6,x5;var S9=D(()=>{S6();b6=new Map,x5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class a4{config;constructor($={}){this.config={...Aw,...$}}async get($,Z){return n4($,Z,"image",this.config)}async set($,Z,Y){return r4($,Z,Y,"image",this.config)}async clear(){return s4("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function YX($){if(!b9)b9=new a4($);else if($)b9.updateConfig($);return b9}async function o4($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return YX(X).get($,Z)}async function t4($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return YX(J).set($,Z,Y)}async function XX(){return YX().clear()}var Aw,b9=null;var JX=D(()=>{S9();Aw={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as Nw,basename as Rw,extname as ww,join as Mw}from"path";import{mkdir as Ew}from"fs/promises";async function QX(){try{return await import("ts-images")}catch{return null}}function fB($){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 Tw($,Z){let Y=Z?fB(Z):fB("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 GX($,Z,Y){let X=await QX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await o4($,Z,Y);if(J)return J;try{let Q=Nw($);if(!await p0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=Tw(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await Ew(K,{recursive:!0});let U=await l0(Q),_=Rw($,ww($)),B=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],z={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await v5(Q,Z.transformations,X);for(let j of B){let H=G[j]||{},L=`${_}-${U}.${j}`,F=Mw(K,L);try{let O=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(z.variants.push({path:F,url:`${W}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!z.originalWidth&&O.width)z.originalWidth=O.width,z.originalHeight=O.height}}catch(O){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);z.placeholder=j.dataUrl}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});z.dominantColor=j.dominantColor}catch(j){z.errors=z.errors||[],z.errors.push(`Failed to extract dominant color: ${j}`)}return await t4($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function KX($,Z,Y,X){let J=await QX();if(!J)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await J.optimizeImage({input:$,output:X,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function v5($,Z,Y){let X=Y||await QX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let J=await X.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)J=await X.resize(J,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)J=await X.blur(J,G.sigma);break;case"sharpen":if(G.amount!==void 0)J=await X.sharpen(J,G.amount);break;case"grayscale":J=await X.grayscale(J);break;case"rotate":if(G.angle!==void 0)J=await X.rotate(J,G.angle);break;case"flip":J=await X.flip(J);break;case"flop":J=await X.flop(J);break;case"brightness":if(G.value!==void 0)J=await X.brightness(J,G.value);break;case"contrast":if(G.value!==void 0)J=await X.contrast(J,G.value);break;case"saturation":if(G.value!==void 0)J=await X.saturation(J,G.value);break}}return await X.encode(J,"png")}catch(J){return console.error(`[stx-media] Transformation failed: ${J}`),null}}var hB=D(()=>{S6();JX()});import{resolve as Iw,basename as Dw,extname as kw,join as Sw}from"path";import{mkdir as bw}from"fs/promises";async function Cw(){try{return await import("ts-images")}catch{return null}}async function C9($,Z,Y){let X=await Cw();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=Iw($);if(!await p0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||Pw,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await bw(K,{recursive:!0});let U=await l0(J),_=Dw($,kw($)),B=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},z={src:$,byFormat:{},srcsets:{}};for(let j of G){z.byFormat[j]=[];let H=[];for(let L of Q){let F=`${_}-${L}w-${U}.${j}`,O=Sw(K,F),V=`${W}/${F}`;try{let N=B[j]?.quality||80;if(await p0(O)){z.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:J,output:O,format:j,quality:N,resize:{width:L}});if(A)z.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(N){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${N}`)}}z.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);z.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});z.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return z.sizes=Z.sizes||yw(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function yw($){let Z=[...$].sort((X,J)=>X-J),Y=[];for(let X=0;X<Z.length-1;X++){let J=Z[X];Y.push(`(max-width: ${J}px) ${J}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function P9($,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 Pw;var dB=D(()=>{S6();Pw=[320,480,640,768,1024,1280,1536,1920]});var mB={};t(mB,{setCachedImageResult:()=>t4,processImage:()=>GX,optimizeImage:()=>KX,getCachedImageResult:()=>o4,generateSrcset:()=>P9,generateResponsiveVariants:()=>C9,clearImageCache:()=>XX,applyTransformations:()=>v5,ImageProcessorCache:()=>a4});var WX=D(()=>{hB();dB();JX()});async function xw(){try{return await Promise.resolve().then(() => (WX(),mB))}catch($){if(!uB)console.warn("[stx-media] Image processor not available, some features disabled:",$),uB=!0;return null}}async function C6($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return hw(X,Y)}if(Y.processedResult?.processed)return qX($,Y.processedResult,Z);if(Y.responsiveVariants)return iB($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=g1,dpr:_,formats:B=$6,quality:z=UX,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":x9,decoding:V=y9,fetchpriority:N,objectFit:A,objectPosition:R,crossorigin:M,referrerpolicy:E}=$,I=$.class,T=$.style,S=$.id,k=$.data||{},{isDev:C=!1,baseUrl:x=""}=Z;if(C&&!Z.optimize)return fw($);let g,P,f=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{g=await P5(J,{strategy:j,...H}),P=C5(f,g,H)}catch{}let h=_!==void 0&&G!==void 0,u;if(h)u=gw($,f,g,Z);else u=await vw($,f,g,Z);let l;if(F){let X0=B.includes("webp")?"webp":B[0],C0=k6(J,U,{...q,q:z},X0),T0=typeof W==="object"?u4(W):W||"100vw";l=`<link rel="preload" as="image" imagesrcset="${C0}" imagesizes="${T0}" />`}let p=[];if(!cB&&j!=="none")p.push(l4),cB=!0;if(P)p.push(P);let Q0=L?pB(f):void 0;return{html:u,preloadLink:l,css:p.length>0?p.join(`
8975
+ `):void 0,script:Q0}}async function vw($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=g1,formats:_=$6,quality:B=UX,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":x9,decoding:L=y9,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:N,referrerpolicy:A}=$,R=$.class,M=$.style,E=$.data||{},I=typeof W==="object"?u4(W):W||"100vw",T=[];for(let C of _){let x=k6(J,U,{...z,q:B},C),g=S5(C);if(q&&!j)T.push(` <source type="${g}" data-srcset="${x}" data-sizes="${I}" />`);else T.push(` <source type="${g}" srcset="${x}" sizes="${I}" />`)}let S=_X({src:M1(J,{...z,q:B}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:N,referrerpolicy:A,className:lB(R,Y),style:BX(M,O,V,Y),lazy:q&&!j,data:E}),k;if(Y){let C=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${C}">
8976
8976
  <picture>
8977
8977
  ${T.join(`
8978
8978
  `)}
@@ -8982,7 +8982,7 @@ ${T.join(`
8982
8982
  ${T.join(`
8983
8983
  `)}
8984
8984
  <img ${S} />
8985
- </picture>`;return k}function gw($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=UX,params:_={},lazy:B=!0,priority:z=!1,loading:q=z?"eager":x9,decoding:j=y9,fetchpriority:H,objectFit:L,objectPosition:F,crossorigin:O,referrerpolicy:V}=$,N=$.class,A=$.style,R=$.data||{},M=typeof G==="number"?G:Number.parseInt(String(G),10),E=m6(J,M,W,{..._,q:U}),I=_X({src:M1(J,{..._,w:M,q:U}),alt:Q,width:G,height:K,loading:z?void 0:q,decoding:j,fetchpriority:z?"high":H,objectFit:L,objectPosition:F,crossorigin:O,referrerpolicy:V,className:lB(N,Y),style:BX(A,L,F,Y),lazy:B&&!z,data:R}),T=B&&!z?`data-srcset="${E}"`:`srcset="${E}"`;if(Y){let S=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${S}">
8985
+ </picture>`;return k}function gw($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=UX,params:_={},lazy:B=!0,priority:z=!1,loading:q=z?"eager":x9,decoding:j=y9,fetchpriority:H,objectFit:L,objectPosition:F,crossorigin:O,referrerpolicy:V}=$,N=$.class,A=$.style,R=$.data||{},M=typeof G==="number"?G:Number.parseInt(String(G),10),E=m4(J,M,W,{..._,q:U}),I=_X({src:M1(J,{..._,w:M,q:U}),alt:Q,width:G,height:K,loading:z?void 0:q,decoding:j,fetchpriority:z?"high":H,objectFit:L,objectPosition:F,crossorigin:O,referrerpolicy:V,className:lB(N,Y),style:BX(A,L,F,Y),lazy:B&&!z,data:R}),T=B&&!z?`data-srcset="${E}"`:`srcset="${E}"`;if(Y){let S=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${S}">
8986
8986
  <img ${I} ${T} />
8987
8987
  </div>`}return`<img ${Z?`id="${Z}" `:""}${I} ${T} />`}function fw($){let{src:Z,alt:Y,width:X,height:J,loading:Q=x9,decoding:G=y9,fetchpriority:K,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B,priority:z=!1}=$,q=$.class,j=$.style,H=$.id,L=$.data||{};return{html:`<img ${_X({src:Z,alt:Y,width:X,height:J,loading:z?"eager":Q,decoding:G,fetchpriority:z?"high":K,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B,className:q,style:BX(j,W,U),id:H,data:L})} />`}}function _X($){let Z=[];if($.lazy)Z.push(`data-src="${E1($.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${E1($.src)}"`);if(Z.push(`alt="${E1($.alt)}"`),$.width)Z.push(`width="${$.width}"`);if($.height)Z.push(`height="${$.height}"`);if($.loading)Z.push(`loading="${$.loading}"`);if($.decoding)Z.push(`decoding="${$.decoding}"`);if($.fetchpriority)Z.push(`fetchpriority="${$.fetchpriority}"`);if($.crossorigin)Z.push(`crossorigin="${$.crossorigin}"`);if($.referrerpolicy)Z.push(`referrerpolicy="${$.referrerpolicy}"`);if($.className)Z.push(`class="${E1($.className)}"`);if($.style)Z.push(`style="${E1($.style)}"`);if($.id)Z.push(`id="${E1($.id)}"`);if($.data)for(let[Y,X]of Object.entries($.data))Z.push(`data-${Y}="${E1(X)}"`);if($.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function lB($,Z){let Y=[];if($)Y.push($);if(Z)Y.push("stx-img-blur");return Y.join(" ")||""}function BX($,Z,Y,X){let J=[];if(Z)J.push(`object-fit: ${Z}`);if(Y)J.push(`object-position: ${Y}`);if(X)J.push("opacity: 0; transition: opacity 300ms ease-out");if($)J.push($);return J.join("; ")}function E1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function pB($){return`
8988
8988
  (function() {
@@ -9021,7 +9021,7 @@ ${T.join(`
9021
9021
 
9022
9022
  observer.observe(container);
9023
9023
  })();
9024
- `.trim()}function v9($){let Z=$.match(/<Img\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(:?)(\w+)(?:=(?:"([^"]*)"|'([^']*)'|\{([^}]+)\}))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,W,U,_]=Q,B=W??U??_??!0;if(G===":"&&typeof B==="string")try{X[K]=JSON.parse(B)}catch{X[K]=B}else switch(K){case"src":X.src=String(B);break;case"alt":X.alt=String(B);break;case"width":X.width=Number(B)||B;break;case"height":X.height=Number(B)||B;break;case"sizes":X.sizes=String(B);break;case"quality":X.quality=Number(B);break;case"placeholder":X.placeholder=B;break;case"lazy":X.lazy=B===!0||B==="true";break;case"priority":X.priority=B===!0||B==="true";break;case"class":X.class=String(B);break;case"style":X.style=String(B);break;case"id":X.id=String(B);break;case"loading":X.loading=B;break;case"decoding":X.decoding=B;break;case"fetchpriority":X.fetchpriority=B;break;case"objectFit":X.objectFit=B;break;case"objectPosition":X.objectPosition=String(B);break;case"crossorigin":X.crossorigin=B;break}}if(!X.src||!X.alt)return null;return X}async function zX($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],W;while((W=Y.exec($))!==null)K.push({match:W[0],index:W.index});for(let U=K.length-1;U>=0;U--){let{match:_}=K[U],B=v9(_);if(B){let z=await C4(B,Z);if(G=G.replace(_,z.html),z.preloadLink)X.push(z.preloadLink);if(z.css)J.push(z.css);if(z.script)Q.push(z.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function hw($,Z){let Y=await xw();if(!Y)return C4({...$,process:!1},Z);let X=Z.tsImagesConfig;if($.responsiveWidths&&$.responsiveWidths.length>0||$.widths&&$.widths.length>0||!$.width&&!$.dpr){let Q=await Y.generateResponsiveVariants($.src,$,X);if(Q)return iB($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return qX($,Q,Z)}return C4({...$,process:!1},Z)}async function qX($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B}=$,z=$.class,q=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,H=$.data||{},L=Z.variants||[],F=L.find((P)=>P.format==="jpeg")||L.find((P)=>P.format==="webp")||L[0],O=F?.url||$.src,V=L.filter((P)=>P.format===(F?.format||"jpeg")).map((P)=>`${P.url} ${P.width}w`).join(", "),N=new Map;for(let P of L){if(!N.has(P.format))N.set(P.format,[]);N.get(P.format).push(P)}let A=[],R=["avif","webp","jpeg","png"];for(let P of R){let f=N.get(P);if(f&&f.length>0){let h=f.map((l)=>`${l.url} ${l.width}w`).join(", "),u=S5(P);if(G&&!K)A.push(` <source type="${u}" data-srcset="${h}" />`);else A.push(` <source type="${u}" srcset="${h}" />`)}}let M=[];if(G&&!K){if(M.push(`data-src="${E1(O)}"`),M.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)M.push(`data-srcset="${V}"`)}else if(M.push(`src="${E1(O)}"`),V)M.push(`srcset="${V}"`);M.push(`alt="${E1(X)}"`);let E=J||Z.originalWidth,I=Q||Z.originalHeight;if(E)M.push(`width="${E}"`);if(I)M.push(`height="${I}"`);if(!K)M.push(`loading="${G?"lazy":"eager"}"`);if(M.push('decoding="async"'),K)M.push('fetchpriority="high"');if(_)M.push(`crossorigin="${_}"`);if(B)M.push(`referrerpolicy="${B}"`);let T=[];if(W)T.push(`object-fit: ${W}`);if(U)T.push(`object-position: ${U}`);if(Z.placeholder&&G)T.push("opacity: 0; transition: opacity 300ms ease-out");if(q)T.push(q);if(T.length>0)M.push(`style="${T.join("; ")}"`);let S=[];if(z)S.push(z);if(Z.placeholder)S.push("stx-img-blur");if(S.length>0)M.push(`class="${S.join(" ")}"`);if(G&&!K)M.push("data-stx-lazy");for(let[P,f]of Object.entries(H))M.push(`data-${P}="${E1(f)}"`);let k;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let P=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;k=`<div id="${j}" class="stx-img-placeholder" style="${P}">
9024
+ `.trim()}function v9($){let Z=$.match(/<Img\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(:?)(\w+)(?:=(?:"([^"]*)"|'([^']*)'|\{([^}]+)\}))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,W,U,_]=Q,B=W??U??_??!0;if(G===":"&&typeof B==="string")try{X[K]=JSON.parse(B)}catch{X[K]=B}else switch(K){case"src":X.src=String(B);break;case"alt":X.alt=String(B);break;case"width":X.width=Number(B)||B;break;case"height":X.height=Number(B)||B;break;case"sizes":X.sizes=String(B);break;case"quality":X.quality=Number(B);break;case"placeholder":X.placeholder=B;break;case"lazy":X.lazy=B===!0||B==="true";break;case"priority":X.priority=B===!0||B==="true";break;case"class":X.class=String(B);break;case"style":X.style=String(B);break;case"id":X.id=String(B);break;case"loading":X.loading=B;break;case"decoding":X.decoding=B;break;case"fetchpriority":X.fetchpriority=B;break;case"objectFit":X.objectFit=B;break;case"objectPosition":X.objectPosition=String(B);break;case"crossorigin":X.crossorigin=B;break}}if(!X.src||!X.alt)return null;return X}async function zX($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],W;while((W=Y.exec($))!==null)K.push({match:W[0],index:W.index});for(let U=K.length-1;U>=0;U--){let{match:_}=K[U],B=v9(_);if(B){let z=await C6(B,Z);if(G=G.replace(_,z.html),z.preloadLink)X.push(z.preloadLink);if(z.css)J.push(z.css);if(z.script)Q.push(z.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function hw($,Z){let Y=await xw();if(!Y)return C6({...$,process:!1},Z);let X=Z.tsImagesConfig;if($.responsiveWidths&&$.responsiveWidths.length>0||$.widths&&$.widths.length>0||!$.width&&!$.dpr){let Q=await Y.generateResponsiveVariants($.src,$,X);if(Q)return iB($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return qX($,Q,Z)}return C6({...$,process:!1},Z)}async function qX($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B}=$,z=$.class,q=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,H=$.data||{},L=Z.variants||[],F=L.find((P)=>P.format==="jpeg")||L.find((P)=>P.format==="webp")||L[0],O=F?.url||$.src,V=L.filter((P)=>P.format===(F?.format||"jpeg")).map((P)=>`${P.url} ${P.width}w`).join(", "),N=new Map;for(let P of L){if(!N.has(P.format))N.set(P.format,[]);N.get(P.format).push(P)}let A=[],R=["avif","webp","jpeg","png"];for(let P of R){let f=N.get(P);if(f&&f.length>0){let h=f.map((l)=>`${l.url} ${l.width}w`).join(", "),u=S5(P);if(G&&!K)A.push(` <source type="${u}" data-srcset="${h}" />`);else A.push(` <source type="${u}" srcset="${h}" />`)}}let M=[];if(G&&!K){if(M.push(`data-src="${E1(O)}"`),M.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)M.push(`data-srcset="${V}"`)}else if(M.push(`src="${E1(O)}"`),V)M.push(`srcset="${V}"`);M.push(`alt="${E1(X)}"`);let E=J||Z.originalWidth,I=Q||Z.originalHeight;if(E)M.push(`width="${E}"`);if(I)M.push(`height="${I}"`);if(!K)M.push(`loading="${G?"lazy":"eager"}"`);if(M.push('decoding="async"'),K)M.push('fetchpriority="high"');if(_)M.push(`crossorigin="${_}"`);if(B)M.push(`referrerpolicy="${B}"`);let T=[];if(W)T.push(`object-fit: ${W}`);if(U)T.push(`object-position: ${U}`);if(Z.placeholder&&G)T.push("opacity: 0; transition: opacity 300ms ease-out");if(q)T.push(q);if(T.length>0)M.push(`style="${T.join("; ")}"`);let S=[];if(z)S.push(z);if(Z.placeholder)S.push("stx-img-blur");if(S.length>0)M.push(`class="${S.join(" ")}"`);if(G&&!K)M.push("data-stx-lazy");for(let[P,f]of Object.entries(H))M.push(`data-${P}="${E1(f)}"`);let k;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let P=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;k=`<div id="${j}" class="stx-img-placeholder" style="${P}">
9025
9025
  <picture>
9026
9026
  ${A.join(`
9027
9027
  `)}
@@ -9031,12 +9031,12 @@ ${A.join(`
9031
9031
  ${A.join(`
9032
9032
  `)}
9033
9033
  <img ${M.join(" ")} />
9034
- </picture>`;let C=[];if(Z.placeholder)C.push(l6);let x=G?pB(j):void 0,g;if(K&&V)g=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:g,css:C.length>0?C.join(`
9035
- `):void 0,script:x}}async function iB($,Z,Y){let X={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[J,Q]of Object.entries(Z.byFormat))if(Q)X.variants.push(...Q);return qX($,X,Y)}var uB=!1,UX=80,y9="async",x9="lazy",cB=!1;var jX=D(()=>{I9();eY()});function g9(){return b0({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,X)=>{let{src:J,alt:Q,options:G}=dw($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||g1,formats:G.formats||$4,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},W=Y.__isDev||!1,U=await C4(K,{isDev:W}),_=U.html;if(U.preloadLink)_=U.preloadLink+`
9034
+ </picture>`;let C=[];if(Z.placeholder)C.push(l4);let x=G?pB(j):void 0,g;if(K&&V)g=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:g,css:C.length>0?C.join(`
9035
+ `):void 0,script:x}}async function iB($,Z,Y){let X={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[J,Q]of Object.entries(Z.byFormat))if(Q)X.variants.push(...Q);return qX($,X,Y)}var uB=!1,UX=80,y9="async",x9="lazy",cB=!1;var jX=D(()=>{I9();eY()});function g9(){return b0({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,X)=>{let{src:J,alt:Q,options:G}=dw($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||g1,formats:G.formats||$6,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},W=Y.__isDev||!1,U=await C6(K,{isDev:W}),_=U.html;if(U.preloadLink)_=U.preloadLink+`
9036
9036
  `+_;if(U.css)_+=`
9037
9037
  <style>${U.css}</style>`;if(U.script)_+=`
9038
- <script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function dw($,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 J=mw(X),Q=HX(J[0],Y)||"",G=HX(J[1],Y)||"",K={};if(J[2]){let W=HX(J[2],Y);if(typeof W==="object"&&W!==null)K=W;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function mw($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function HX($,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 g5;var LX=D(()=>{I5();jX();I9();g5=g9()});class e6{config;constructor($={}){this.config={...uw,...$}}async get($,Z){return n6($,Z,"video",this.config)}async set($,Z,Y){return r6($,Z,Y,"video",this.config)}async clear(){return s6("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function OX($){if(!f9)f9=new e6($);else if($)f9.updateConfig($);return f9}async function $$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return OX(X).get($,Z)}async function Z$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return OX(J).set($,Z,Y)}async function h9(){return OX().clear()}var uw,f9=null;var FX=D(()=>{S9();uw={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as VX,basename as AX,extname as NX,join as d9}from"path";import{mkdir as RX}from"fs/promises";async function wX(){try{return await import("ts-videos")}catch{return null}}async function Y$($,Z,Y,X){let J=await wX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=VX($);if(!await p0(Q))return null;await RX(Y,{recursive:!0});let G=await l0(Q),K=AX($,NX($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,B=d9(Y,_),z=await J.extractThumbnails(Q,{timestamps:[U],width:Z.width||1280,height:Z.height,format:W,quality:Z.quality||85,outputDir:Y,outputPattern:_.replace(`.${W}`,"")});if(z&&z.length>0){let q=z[0];return{path:B,url:`${X}/${_}`,width:q.width||Z.width||1280,height:q.height||720,timestamp:U,size:q.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function X$($,Z,Y,X){let J=await wX();if(!J)return[];try{let Q=VX($);if(!await p0(Q))return[];await RX(Y,{recursive:!0});let G=await l0(Q),K=AX($,NX($)),W=Z.format||"webp",B=(await new J.Input(Q).getInfo()).duration||60,z=Z.count||10,q=Z.interval||B/z,j=[];for(let L=0;L<z&&L*q<B;L++)j.push(L*q);let H=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:W,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||d9(Y,`${K}-thumb-${G}-${F}.${W}`),url:`${X}/${K}-thumb-${G}-${F}.${W}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function m9($,Z,Y,X){let J=await wX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=VX($);if(!await p0(Q))return null;await RX(Y,{recursive:!0});let G=await l0(Q),K=AX($,NX($)),_=(await new J.Input(Q).getInfo()).duration||60,B=Z.columns||10,z=Z.interval||5,q=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(_/z),F=Math.ceil(L/B),O=`${K}-sprite-${G}.${H}`,V=d9(Y,O),N=[];for(let R=0;R<L;R++)N.push(R*z);let A=await J.extractThumbnails(Q,{timestamps:N,width:q,height:j,format:H,quality:Z.quality||70,outputDir:d9(Y,".temp")});if(!A||A.length===0)return null;try{let R=await import("ts-images"),M=B*q,E=F*j,I=await R.createSprite({images:A.map((T)=>T.path),columns:B,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:B,rows:F,thumbnailWidth:q,thumbnailHeight:j,interval:z,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var MX=D(()=>{S4()});import{resolve as rB,basename as sB,extname as aB,join as e4}from"path";import{mkdir as u9,writeFile as oB}from"fs/promises";async function tB(){try{return await import("ts-videos")}catch{return null}}async function J$($,Z,Y,X,J){let Q=await tB();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=rB($);if(!await p0(G))return null;let K=await l0(G),W=sB($,aB($)),U=e4(Y,`${W}-${K}-hls`);await u9(U,{recursive:!0});let _=Z.length>0?Z:eB,B=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of _){let N=e4(U,V.label);await u9(N,{recursive:!0});let A=`${V.label}.m3u8`,R=e4(N,A);try{let M=await Q.generateHLS(G,{outputDir:N,segmentDuration:B,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(M)H.push({quality:V,url:`${X}/${W}-${K}-hls/${V.label}/${A}`,path:R}),L+=M.segmentCount||Math.ceil(j/B)}catch(M){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${M}`)}}if(H.length===0)return null;let F=e4(U,"master.m3u8"),O=cw(H,X,W,K);return await oB(F,O),{manifestUrl:`${X}/${W}-${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 cw($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),W=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${W},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
9039
- `)}async function Q$($,Z,Y,X,J){let Q=await tB();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=rB($);if(!await p0(G))return null;let K=await l0(G),W=sB($,aB($)),U=e4(Y,`${W}-${K}-dash`);await u9(U,{recursive:!0});let _=Z.length>0?Z:eB,B=J?.segmentDuration||4,z=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,L=[],F=[];for(let A of _){let R=e4(U,A.label);await u9(R,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:R,segmentDuration:B,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}/${W}-${K}-dash/${A.label}/video`}),A.audioBitrate)F.push({bandwidth:A.audioBitrate,url:`${X}/${W}-${K}-dash/${A.label}/audio`})}}catch(M){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${M}`)}}if(L.length===0)return null;let O=e4(U,"manifest.mpd"),V=lw(L,F,H,B,z);await oB(O,V);let N=[{type:"video",representations:L}];if(F.length>0)N.push({type:"audio",representations:F});return{manifestUrl:`${X}/${W}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:N,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function lw($,Z,Y,X,J){let Q=nB(Y),G=nB(J),K=`<?xml version="1.0" encoding="UTF-8"?>
9038
+ <script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function dw($,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 J=mw(X),Q=HX(J[0],Y)||"",G=HX(J[1],Y)||"",K={};if(J[2]){let W=HX(J[2],Y);if(typeof W==="object"&&W!==null)K=W;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function mw($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'"||W==="`")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function HX($,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 g5;var LX=D(()=>{I5();jX();I9();g5=g9()});class e4{config;constructor($={}){this.config={...uw,...$}}async get($,Z){return n4($,Z,"video",this.config)}async set($,Z,Y){return r4($,Z,Y,"video",this.config)}async clear(){return s4("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function OX($){if(!f9)f9=new e4($);else if($)f9.updateConfig($);return f9}async function $$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return OX(X).get($,Z)}async function Z$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return OX(J).set($,Z,Y)}async function h9(){return OX().clear()}var uw,f9=null;var FX=D(()=>{S9();uw={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as VX,basename as AX,extname as NX,join as d9}from"path";import{mkdir as RX}from"fs/promises";async function wX(){try{return await import("ts-videos")}catch{return null}}async function Y$($,Z,Y,X){let J=await wX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=VX($);if(!await p0(Q))return null;await RX(Y,{recursive:!0});let G=await l0(Q),K=AX($,NX($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,B=d9(Y,_),z=await J.extractThumbnails(Q,{timestamps:[U],width:Z.width||1280,height:Z.height,format:W,quality:Z.quality||85,outputDir:Y,outputPattern:_.replace(`.${W}`,"")});if(z&&z.length>0){let q=z[0];return{path:B,url:`${X}/${_}`,width:q.width||Z.width||1280,height:q.height||720,timestamp:U,size:q.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function X$($,Z,Y,X){let J=await wX();if(!J)return[];try{let Q=VX($);if(!await p0(Q))return[];await RX(Y,{recursive:!0});let G=await l0(Q),K=AX($,NX($)),W=Z.format||"webp",B=(await new J.Input(Q).getInfo()).duration||60,z=Z.count||10,q=Z.interval||B/z,j=[];for(let L=0;L<z&&L*q<B;L++)j.push(L*q);let H=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:W,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||d9(Y,`${K}-thumb-${G}-${F}.${W}`),url:`${X}/${K}-thumb-${G}-${F}.${W}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function m9($,Z,Y,X){let J=await wX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=VX($);if(!await p0(Q))return null;await RX(Y,{recursive:!0});let G=await l0(Q),K=AX($,NX($)),_=(await new J.Input(Q).getInfo()).duration||60,B=Z.columns||10,z=Z.interval||5,q=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(_/z),F=Math.ceil(L/B),O=`${K}-sprite-${G}.${H}`,V=d9(Y,O),N=[];for(let R=0;R<L;R++)N.push(R*z);let A=await J.extractThumbnails(Q,{timestamps:N,width:q,height:j,format:H,quality:Z.quality||70,outputDir:d9(Y,".temp")});if(!A||A.length===0)return null;try{let R=await import("ts-images"),M=B*q,E=F*j,I=await R.createSprite({images:A.map((T)=>T.path),columns:B,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${O}`,path:V,columns:B,rows:F,thumbnailWidth:q,thumbnailHeight:j,interval:z,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var MX=D(()=>{S6()});import{resolve as rB,basename as sB,extname as aB,join as e6}from"path";import{mkdir as u9,writeFile as oB}from"fs/promises";async function tB(){try{return await import("ts-videos")}catch{return null}}async function J$($,Z,Y,X,J){let Q=await tB();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=rB($);if(!await p0(G))return null;let K=await l0(G),W=sB($,aB($)),U=e6(Y,`${W}-${K}-hls`);await u9(U,{recursive:!0});let _=Z.length>0?Z:eB,B=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of _){let N=e6(U,V.label);await u9(N,{recursive:!0});let A=`${V.label}.m3u8`,R=e6(N,A);try{let M=await Q.generateHLS(G,{outputDir:N,segmentDuration:B,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(M)H.push({quality:V,url:`${X}/${W}-${K}-hls/${V.label}/${A}`,path:R}),L+=M.segmentCount||Math.ceil(j/B)}catch(M){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${M}`)}}if(H.length===0)return null;let F=e6(U,"master.m3u8"),O=cw(H,X,W,K);return await oB(F,O),{manifestUrl:`${X}/${W}-${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 cw($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),W=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${W},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
9039
+ `)}async function Q$($,Z,Y,X,J){let Q=await tB();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=rB($);if(!await p0(G))return null;let K=await l0(G),W=sB($,aB($)),U=e6(Y,`${W}-${K}-dash`);await u9(U,{recursive:!0});let _=Z.length>0?Z:eB,B=J?.segmentDuration||4,z=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,L=[],F=[];for(let A of _){let R=e6(U,A.label);await u9(R,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:R,segmentDuration:B,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}/${W}-${K}-dash/${A.label}/video`}),A.audioBitrate)F.push({bandwidth:A.audioBitrate,url:`${X}/${W}-${K}-dash/${A.label}/audio`})}}catch(M){console.warn(`[stx-media] Failed to generate DASH for ${A.label}: ${M}`)}}if(L.length===0)return null;let O=e6(U,"manifest.mpd"),V=lw(L,F,H,B,z);await oB(O,V);let N=[{type:"video",representations:L}];if(F.length>0)N.push({type:"audio",representations:F});return{manifestUrl:`${X}/${W}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:N,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function lw($,Z,Y,X,J){let Q=nB(Y),G=nB(J),K=`<?xml version="1.0" encoding="UTF-8"?>
9040
9040
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
9041
9041
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9042
9042
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
@@ -9062,7 +9062,7 @@ ${A.join(`
9062
9062
  </Representation>
9063
9063
  `}K+=` </AdaptationSet>
9064
9064
  `}return K+=` </Period>
9065
- </MPD>`,K}function nB($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),J="PT";if(Z>0)J+=`${Z}H`;if(Y>0)J+=`${Y}M`;return J+=`${X}S`,J}var eB;var EX=D(()=>{S4();eB=[{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 $z,basename as pw,extname as iw,join as nw}from"path";import{mkdir as rw}from"fs/promises";async function Zz(){try{return await import("ts-videos")}catch{return null}}function sw($){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 aw($){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 f5($){let Z=await Zz();if(!Z)return null;try{let Y=$z($),J=await new Z.Input(Y).getInfo();return{duration:J.duration||0,width:J.width||0,height:J.height||0,frameRate:J.frameRate||0,bitrate:J.bitrate||0,codec:J.videoCodec||"",audioCodec:J.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function c9($,Z,Y,X){let J=await Zz();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await $$($,Z,Y);if(Q)return Q;try{let G=$z($);if(!await p0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await rw(K,{recursive:!0});let U=await l0(G),_=pw($,iw($)),B={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),B.metadata=await f5(G)||void 0;let z={};if(Z.quality)z.bitrate=sw(Z.quality);if(Z.platform)Object.assign(z,aw(Z.platform));if(Z.transcode)Object.assign(z,Z.transcode);if(Object.keys(z).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let q=`${_}-${U}.mp4`,j=nw(K,q);try{let H=await ow(G,j,z,J,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)B.transcoded={path:j,url:`${W}/${q}`,duration:H.duration,size:H.size,video:{codec:z.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:z.audioCodec||"aac",bitrate:z.audioBitrate||128000,sampleRate:z.sampleRate||48000,channels:z.channels||2}:void 0}}catch(H){B.errors=B.errors||[],B.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await Y$(G,q,K,W);if(j)B.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await X$(G,Y.thumbnails,K,W);if(q.length>0)B.thumbnails=q}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await J$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,hls:j}}if(q.format==="dash"){let j=await Q$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await Z$($,Z,B,Y),B}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function ow($,Z,Y,X,J){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)=>{J?.(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(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var Yz=D(()=>{S4();FX();MX();EX()});var Xz={};t(Xz,{setCachedVideoResult:()=>Z$,processVideo:()=>c9,getCachedVideoResult:()=>$$,generateThumbnails:()=>X$,generateSpriteSheet:()=>m9,generatePoster:()=>Y$,generateHLSManifest:()=>J$,generateDASHManifest:()=>Q$,clearVideoCache:()=>h9,analyzeVideo:()=>f5,VideoProcessorCache:()=>e6});var TX=D(()=>{Yz();MX();EX();FX()});async function Qz(){try{return await Promise.resolve().then(() => (TX(),Xz))}catch($){if(!Jz)console.warn("[stx-media] Video processor not available, some features disabled:",$),Jz=!0;return null}}async function G$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return XM(X,Y)}if(Y.processedResult?.processed)return _z($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await JM(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=Gz,autoplay:_=!1,muted:B=!1,loop:z=!1,preload:q=Kz,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:N,disablePictureInPicture:A=!1,disableRemotePlayback:R=!1}=$,M=J||K,E=$.class,I=$.style,T=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return $M($,Z);if(F&&F!=="video")return ew(Q||"",F,$);let S=G.length>0?G:Q?[{src:Q,type:Wz(Q)}]:[],k=[`id="${T}"`];if(U)k.push("controls");if(_)k.push("autoplay");if(B)k.push("muted");if(z)k.push("loop");if(j)k.push("playsinline");if(A)k.push("disablepictureinpicture");if(R)k.push("disableremoteplayback");if(N)k.push(`crossorigin="${N}"`);if(H){if(k.push(`data-preload="${q}"`),k.push('preload="none"'),M)k.push(`data-poster="${h0(M)}"`);k.push("data-stx-lazy")}else if(k.push(`preload="${q}"`),M)k.push(`poster="${h0(M)}"`);if(O)k.push(`width="${O}"`);if(V)k.push(`height="${V}"`);if(E)k.push(`class="${h0(E)}"`);if(I)k.push(`style="${h0(I)}"`);let C=S.map((P)=>{return` <source ${H?`data-src="${h0(P.src)}"`:`src="${h0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
9065
+ </MPD>`,K}function nB($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),X=Math.floor($%60),J="PT";if(Z>0)J+=`${Z}H`;if(Y>0)J+=`${Y}M`;return J+=`${X}S`,J}var eB;var EX=D(()=>{S6();eB=[{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 $z,basename as pw,extname as iw,join as nw}from"path";import{mkdir as rw}from"fs/promises";async function Zz(){try{return await import("ts-videos")}catch{return null}}function sw($){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 aw($){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 f5($){let Z=await Zz();if(!Z)return null;try{let Y=$z($),J=await new Z.Input(Y).getInfo();return{duration:J.duration||0,width:J.width||0,height:J.height||0,frameRate:J.frameRate||0,bitrate:J.bitrate||0,codec:J.videoCodec||"",audioCodec:J.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function c9($,Z,Y,X){let J=await Zz();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await $$($,Z,Y);if(Q)return Q;try{let G=$z($);if(!await p0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await rw(K,{recursive:!0});let U=await l0(G),_=pw($,iw($)),B={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),B.metadata=await f5(G)||void 0;let z={};if(Z.quality)z.bitrate=sw(Z.quality);if(Z.platform)Object.assign(z,aw(Z.platform));if(Z.transcode)Object.assign(z,Z.transcode);if(Object.keys(z).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let q=`${_}-${U}.mp4`,j=nw(K,q);try{let H=await ow(G,j,z,J,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)B.transcoded={path:j,url:`${W}/${q}`,duration:H.duration,size:H.size,video:{codec:z.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:z.audioCodec||"aac",bitrate:z.audioBitrate||128000,sampleRate:z.sampleRate||48000,channels:z.channels||2}:void 0}}catch(H){B.errors=B.errors||[],B.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let q=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await Y$(G,q,K,W);if(j)B.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await X$(G,Y.thumbnails,K,W);if(q.length>0)B.thumbnails=q}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let q=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(q.format==="hls"||q.format===void 0){let j=await J$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,hls:j}}if(q.format==="dash"){let j=await Q$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await Z$($,Z,B,Y),B}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function ow($,Z,Y,X,J){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)=>{J?.(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(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var Yz=D(()=>{S6();FX();MX();EX()});var Xz={};t(Xz,{setCachedVideoResult:()=>Z$,processVideo:()=>c9,getCachedVideoResult:()=>$$,generateThumbnails:()=>X$,generateSpriteSheet:()=>m9,generatePoster:()=>Y$,generateHLSManifest:()=>J$,generateDASHManifest:()=>Q$,clearVideoCache:()=>h9,analyzeVideo:()=>f5,VideoProcessorCache:()=>e4});var TX=D(()=>{Yz();MX();EX();FX()});async function Qz(){try{return await Promise.resolve().then(() => (TX(),Xz))}catch($){if(!Jz)console.warn("[stx-media] Video processor not available, some features disabled:",$),Jz=!0;return null}}async function G$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return XM(X,Y)}if(Y.processedResult?.processed)return _z($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await JM(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=Gz,autoplay:_=!1,muted:B=!1,loop:z=!1,preload:q=Kz,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:N,disablePictureInPicture:A=!1,disableRemotePlayback:R=!1}=$,M=J||K,E=$.class,I=$.style,T=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return $M($,Z);if(F&&F!=="video")return ew(Q||"",F,$);let S=G.length>0?G:Q?[{src:Q,type:Wz(Q)}]:[],k=[`id="${T}"`];if(U)k.push("controls");if(_)k.push("autoplay");if(B)k.push("muted");if(z)k.push("loop");if(j)k.push("playsinline");if(A)k.push("disablepictureinpicture");if(R)k.push("disableremoteplayback");if(N)k.push(`crossorigin="${N}"`);if(H){if(k.push(`data-preload="${q}"`),k.push('preload="none"'),M)k.push(`data-poster="${h0(M)}"`);k.push("data-stx-lazy")}else if(k.push(`preload="${q}"`),M)k.push(`poster="${h0(M)}"`);if(O)k.push(`width="${O}"`);if(V)k.push(`height="${V}"`);if(E)k.push(`class="${h0(E)}"`);if(I)k.push(`style="${h0(I)}"`);let C=S.map((P)=>{return` <source ${H?`data-src="${h0(P.src)}"`:`src="${h0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
9066
9066
  `),x=`<video ${k.join(" ")}>
9067
9067
  ${C}
9068
9068
  Your browser does not support the video tag.
@@ -9620,7 +9620,7 @@ catch (error) {
9620
9620
  init();
9621
9621
  }
9622
9622
  })();
9623
- </script>`}var BM,zM,qM,jM,zz;var qz=D(()=>{BM={name:"pwa.installButton",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return KM($,J)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},zM={name:"pwa.updatePrompt",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return WM($,J)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},qM={name:"pwa.offlineIndicator",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return UM($,J)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},jM={name:"pwa.pushSubscribe",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return _M($,J)},hasEndTag:!0,description:"Renders a push notification subscription button"},zz=[BM,zM,qM,jM]});import HM from"fs";import P4 from"path";async function kX($,Z){if(!$.webComponents?.enabled)return[];let Y=$.webComponents.components||[],X=[];if(Y.length>0){if($.debug)console.log(`Building ${Y.length} web components...`);for(let J of Y)try{let Q=await LM(J,$,Z);if(Q)X.push(Q)}catch(Q){if(console.error(`Error building web component ${J.name}:`,Q),$.debug)throw Q}}return X}async function LM($,Z,Y){let{name:X,file:J,tag:Q,extends:G}=$;if(!X||!J||!Q)return console.error("Invalid web component configuration, missing required fields:",$),null;let K=null;if(P4.isAbsolute(J)&&await $0(J))K=J;else if(Z.componentsDir){let H=P4.join(Z.componentsDir,J);if(await $0(H))K=H}if(!K)K=await E5(J,process.cwd(),Z,Y);if(!K)return console.error(`Web component source file not found: ${J}`),null;let W=await Bun.file(K).text();Y.add(K);let _=($.outputFormat||"js")==="ts",B=_?FM({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[],attributeTypes:$.attributeTypes||{}}):OM({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[]}),z=Z.webComponents?.outputDir||"dist/web-components";await HM.promises.mkdir(z,{recursive:!0});let q=_?"ts":"js",j=P4.join(z,`${Q}.${q}`);if(await Bun.write(j,B),Z.debug)console.log(`Built web component ${X} -> ${j}`);return j}function OM($){let{name:Z,tag:Y,baseElement:X="HTMLElement",source:J,shadowDOM:Q,template:G,styleSource:K,attributes:W=[]}=$,U=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!Q)U=U.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),U=U.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),U=U.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),U=U.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let _="";if(K)_=`<link rel="stylesheet" href="${K}">`;return`/**
9623
+ </script>`}var BM,zM,qM,jM,zz;var qz=D(()=>{BM={name:"pwa.installButton",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return KM($,J)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},zM={name:"pwa.updatePrompt",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return WM($,J)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},qM={name:"pwa.offlineIndicator",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return UM($,J)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},jM={name:"pwa.pushSubscribe",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return _M($,J)},hasEndTag:!0,description:"Renders a push notification subscription button"},zz=[BM,zM,qM,jM]});import HM from"fs";import P6 from"path";async function kX($,Z){if(!$.webComponents?.enabled)return[];let Y=$.webComponents.components||[],X=[];if(Y.length>0){if($.debug)console.log(`Building ${Y.length} web components...`);for(let J of Y)try{let Q=await LM(J,$,Z);if(Q)X.push(Q)}catch(Q){if(console.error(`Error building web component ${J.name}:`,Q),$.debug)throw Q}}return X}async function LM($,Z,Y){let{name:X,file:J,tag:Q,extends:G}=$;if(!X||!J||!Q)return console.error("Invalid web component configuration, missing required fields:",$),null;let K=null;if(P6.isAbsolute(J)&&await $0(J))K=J;else if(Z.componentsDir){let H=P6.join(Z.componentsDir,J);if(await $0(H))K=H}if(!K)K=await E5(J,process.cwd(),Z,Y);if(!K)return console.error(`Web component source file not found: ${J}`),null;let W=await Bun.file(K).text();Y.add(K);let _=($.outputFormat||"js")==="ts",B=_?FM({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[],attributeTypes:$.attributeTypes||{}}):OM({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[]}),z=Z.webComponents?.outputDir||"dist/web-components";await HM.promises.mkdir(z,{recursive:!0});let q=_?"ts":"js",j=P6.join(z,`${Q}.${q}`);if(await Bun.write(j,B),Z.debug)console.log(`Built web component ${X} -> ${j}`);return j}function OM($){let{name:Z,tag:Y,baseElement:X="HTMLElement",source:J,shadowDOM:Q,template:G,styleSource:K,attributes:W=[]}=$,U=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").trim();if(!Q)U=U.replace(/<slot\s+name=["']([^"']+)["']\s*>([\s\S]*?)<\/slot>/gi,'<div data-slot="$1">$2</div>'),U=U.replace(/<slot\s+name=["']([^"']+)["']\s*\/>/gi,'<div data-slot="$1"></div>'),U=U.replace(/<slot\s*>([\s\S]*?)<\/slot>/gi,"<div data-default-slot>$1</div>"),U=U.replace(/<slot\s*\/>/gi,"<div data-default-slot></div>");let _="";if(K)_=`<link rel="stylesheet" href="${K}">`;return`/**
9624
9624
  * ${Z} Web Component
9625
9625
  * Auto-generated from stx component
9626
9626
  */
@@ -10697,9 +10697,9 @@ ${_}
10697
10697
  }
10698
10698
 
10699
10699
  customElements.define('${Z}', ${G});
10700
- `}async function bX($,Z,Y,X){if(Z.length<1)return G0("WebComponent","@webcomponent directive requires at least the tag name parameter",e.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[P4.join(P4.dirname(X),G,`${J}.stx`),P4.join(process.cwd(),G,`${J}.stx`),P4.join(P4.dirname(X),`${J}.stx`)],W=null;for(let B of K)if(await $0(B)){W=await Bun.file(B).text();break}if(!W)return G0("WebComponent",`Component file not found: ${J}.stx`,e.FILE_NOT_FOUND);let U=Lz(W,J);return`<script type="module">
10700
+ `}async function bX($,Z,Y,X){if(Z.length<1)return G0("WebComponent","@webcomponent directive requires at least the tag name parameter",e.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[P6.join(P6.dirname(X),G,`${J}.stx`),P6.join(process.cwd(),G,`${J}.stx`),P6.join(P6.dirname(X),`${J}.stx`)],W=null;for(let B of K)if(await $0(B)){W=await Bun.file(B).text();break}if(!W)return G0("WebComponent",`Component file not found: ${J}.stx`,e.FILE_NOT_FOUND);let U=Lz(W,J);return`<script type="module">
10701
10701
  ${Oz(U)}
10702
- </script>`}var SX;var CX=D(()=>{_1();H0();SX={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var Fz={};t(Fz,{timingPlugin:()=>bM,pluginManager:()=>yX,definePlugin:()=>W$,debugPlugin:()=>SM,createVariablesPlugin:()=>CM,createFilterPlugin:()=>kM,createDirectivePlugin:()=>DM,PluginManager:()=>PX});function W$($){return $}class PX{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let J=X[$];if(J)try{let Q=await J(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${X.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let J of this.sortedPlugins){let Q=J[$];if(Q)try{let G=await Q(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${J.name}" ${$} hook:`,G)}}return X}}function DM($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function kM($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function CM($){return W$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var yX,SM,bM;var xX=D(()=>{yX=new PX;SM=W$({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)}}),bM=W$({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 TZ={};t(TZ,{validateConfig:()=>Nz,loadStxConfig:()=>f0,defineStxConfig:()=>Az,defaultConfig:()=>Q1,config:()=>G1});import vX from"fs";import e0 from"path";import{loadConfigWithResult as PM}from"bunfig";function yM($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=e0.join(process.cwd(),"resources","views"),J=e0.join(process.cwd(),"resources","layouts");if(vX.existsSync(X)&&vX.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=e0.join(process.cwd(),"resources","views","pages");if(vX.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function f0($){if(!$){if(U$)return U$;if(i9)return i9}let Z=$?e0.resolve($):process.cwd(),Y=Vz.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await PM({name:"stx",alias:"ui",cwd:Z,defaultConfig:Q1,verbose:!1})).config,G=yM(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!e0.isAbsolute(Q.partialsDir))Q.partialsDir=e0.join(K,Q.partialsDir);if(Q.componentsDir&&!e0.isAbsolute(Q.componentsDir))Q.componentsDir=e0.join(K,Q.componentsDir);if(Q.layoutsDir&&!e0.isAbsolute(Q.layoutsDir))Q.layoutsDir=e0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (xX(),Fz)),W=[],U=[];for(let _ of Q.plugins){let B=typeof _==="string"?_:_[0],z=typeof _==="string"?{}:_[1]||{};try{let q,j;try{q=await import(B),j=e0.dirname(a.resolve(B))}catch{let L=e0.resolve(process.cwd(),B);q=await import(L),j=e0.dirname(L)}let H=q.default||q;if(K.register(H,Q),H.components){let L=e0.resolve(j,H.components);W.push(L)}if(H.pages){let L=e0.resolve(j,H.pages),F=z.path||"/";U.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(z,L)}console.log(`[stx] Plugin loaded: ${H.name||B}`)}catch(q){console.warn(`[stx] Failed to load plugin ${B}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(Vz.set(Z,X),!$)i9=X,X.then((J)=>{U$=J}).catch(()=>{});return X}function Az($){return $}function Nz($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!X.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var Q1,U$=null,Vz,i9=null,G1;var u0=D(()=>{H6();J8();WZ();Q8();M9();LX();DX();qz();a8();CX();Q1={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:CY,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:bX,hasEndTag:!1,description:"Include a web component in the template"},t7,e7,r8,s8,$8,Y8,X8,Z8,lG,BZ,g5,h5,...zz],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}};Vz=new Map;G1=new Proxy(Q1,{get($,Z){if(U$&&Z in U$)return U$[Z];if(!i9)f0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import xM from"fs";import gX from"path";import{createHighlighter as vM}from"ts-syntax-highlighter";async function Z4($,Z={}){try{if(!await $0($))throw Error(`Markdown file not found: ${$}`);let X=(await xM.promises.stat($)).mtime.getTime();if(Z.cache&&r9.has($)){let B=r9.get($);if(B.updatedAt>=X)return{content:B.content,data:B.data}}let J=await Bun.file($).text(),{data:Q,content:G}=nG(J),K=Z.markdown||G1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=d$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await gM(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)r9.set($,{..._,updatedAt:X});return _}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:O0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function gM($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!n9)try{n9=await vM({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,_)=>{let B=_.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),z=U||(Y?"text":"");if(!z)return K;try{if(!n9.getSupportedLanguages().includes(z))return K;return(await n9.highlight(B,z,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,_,B]=K,z=await J(W,U,_,B);Q=Q.replace(W,z)}return Q}async function TY($,Z,Y="",X={}){return await fM($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!gX.isAbsolute(K))_=gX.resolve(gX.dirname(Y),K);let B={};if(W)try{try{B=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let N=V.indexOf(":");if(N>0){let A=V.substring(0,N).trim(),R=V.substring(N+1).trim(),M=R.startsWith('"')&&R.endsWith('"'),E=R.startsWith("'")&&R.endsWith("'");if(M||E)R=R.substring(1,R.length-1);B[A]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:q}=await Z4(_,X),j={...Z,...q,...B},H=z,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(_){let B=_ instanceof Error?_.message:String(_);return O0("Markdown File",`Error including markdown file: ${B}`,Y,$,U,G)}})}async function fM($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],W=J.index,U=J;X.push(Y(...U).then((_)=>({match:K,replacement:_,index:W})))}let Q=await Promise.all(X);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var r9,n9=null;var d6=D(()=>{u0();H0();r9=new Map});function s9(){return`
10702
+ </script>`}var SX;var CX=D(()=>{_1();H0();SX={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var Fz={};t(Fz,{timingPlugin:()=>bM,pluginManager:()=>yX,definePlugin:()=>W$,debugPlugin:()=>SM,createVariablesPlugin:()=>CM,createFilterPlugin:()=>kM,createDirectivePlugin:()=>DM,PluginManager:()=>PX});function W$($){return $}class PX{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,X]of this.plugins)if(X.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let X of this.sortedPlugins){let J=X[$];if(J)try{let Q=await J(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${X.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let X={...Y};for(let J of this.sortedPlugins){let Q=J[$];if(Q)try{let G=await Q(Z,X);if(G){if(G.template!==void 0)X.template=G.template;if(G.context)X.context={...X.context,...G.context};if(G.metadata)X.metadata={...X.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${J.name}" ${$} hook:`,G)}}return X}}function DM($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function kM($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function CM($){return W$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var yX,SM,bM;var xX=D(()=>{yX=new PX;SM=W$({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)}}),bM=W$({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 TZ={};t(TZ,{validateConfig:()=>Nz,loadStxConfig:()=>f0,defineStxConfig:()=>Az,defaultConfig:()=>Q1,config:()=>G1});import vX from"fs";import e0 from"path";import{loadConfigWithResult as PM}from"bunfig";function yM($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=e0.join(process.cwd(),"resources","views"),J=e0.join(process.cwd(),"resources","layouts");if(vX.existsSync(X)&&vX.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=e0.join(process.cwd(),"resources","views","pages");if(vX.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function f0($){if(!$){if(U$)return U$;if(i9)return i9}let Z=$?e0.resolve($):process.cwd(),Y=Vz.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await PM({name:"stx",alias:"ui",cwd:Z,defaultConfig:Q1,verbose:!1})).config,G=yM(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!e0.isAbsolute(Q.partialsDir))Q.partialsDir=e0.join(K,Q.partialsDir);if(Q.componentsDir&&!e0.isAbsolute(Q.componentsDir))Q.componentsDir=e0.join(K,Q.componentsDir);if(Q.layoutsDir&&!e0.isAbsolute(Q.layoutsDir))Q.layoutsDir=e0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (xX(),Fz)),W=[],U=[];for(let _ of Q.plugins){let B=typeof _==="string"?_:_[0],z=typeof _==="string"?{}:_[1]||{};try{let q,j;try{q=await import(B),j=e0.dirname(a.resolve(B))}catch{let L=e0.resolve(process.cwd(),B);q=await import(L),j=e0.dirname(L)}let H=q.default||q;if(K.register(H,Q),H.components){let L=e0.resolve(j,H.components);W.push(L)}if(H.pages){let L=e0.resolve(j,H.pages),F=z.path||"/";U.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(z,L)}console.log(`[stx] Plugin loaded: ${H.name||B}`)}catch(q){console.warn(`[stx] Failed to load plugin ${B}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(Vz.set(Z,X),!$)i9=X,X.then((J)=>{U$=J}).catch(()=>{});return X}function Az($){return $}function Nz($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!X.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var Q1,U$=null,Vz,i9=null,G1;var u0=D(()=>{H4();J8();WZ();Q8();M9();LX();DX();qz();a8();CX();Q1={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:CY,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:bX,hasEndTag:!1,description:"Include a web component in the template"},t7,e7,r8,s8,$8,Y8,X8,Z8,lG,BZ,g5,h5,...zz],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}};Vz=new Map;G1=new Proxy(Q1,{get($,Z){if(U$&&Z in U$)return U$[Z];if(!i9)f0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import xM from"fs";import gX from"path";import{createHighlighter as vM}from"ts-syntax-highlighter";async function Z6($,Z={}){try{if(!await $0($))throw Error(`Markdown file not found: ${$}`);let X=(await xM.promises.stat($)).mtime.getTime();if(Z.cache&&r9.has($)){let B=r9.get($);if(B.updatedAt>=X)return{content:B.content,data:B.data}}let J=await Bun.file($).text(),{data:Q,content:G}=nG(J),K=Z.markdown||G1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=d$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await gM(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)r9.set($,{..._,updatedAt:X});return _}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:O0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function gM($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!n9)try{n9=await vM({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,_)=>{let B=_.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),z=U||(Y?"text":"");if(!z)return K;try{if(!n9.getSupportedLanguages().includes(z))return K;return(await n9.highlight(B,z,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,_,B]=K,z=await J(W,U,_,B);Q=Q.replace(W,z)}return Q}async function TY($,Z,Y="",X={}){return await fM($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!gX.isAbsolute(K))_=gX.resolve(gX.dirname(Y),K);let B={};if(W)try{try{B=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let N=V.indexOf(":");if(N>0){let A=V.substring(0,N).trim(),R=V.substring(N+1).trim(),M=R.startsWith('"')&&R.endsWith('"'),E=R.startsWith("'")&&R.endsWith("'");if(M||E)R=R.substring(1,R.length-1);B[A]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:q}=await Z6(_,X),j={...Z,...q,...B},H=z,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(_){let B=_ instanceof Error?_.message:String(_);return O0("Markdown File",`Error including markdown file: ${B}`,Y,$,U,G)}})}async function fM($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],W=J.index,U=J;X.push(Y(...U).then((_)=>({match:K,replacement:_,index:W})))}let Q=await Promise.all(X);Q.sort((K,W)=>W.index-K.index);let G=$;for(let{match:K,replacement:W}of Q)G=G.replace(K,()=>W);return G}var r9,n9=null;var d4=D(()=>{u0();H0();r9=new Map});function s9(){return`
10703
10703
  /* Theme selector for code blocks */
10704
10704
  .theme-selector {
10705
10705
  margin: 1rem 0;
@@ -10779,12 +10779,12 @@ else {
10779
10779
  <span class="frontmatter-label">${Z}:</span>
10780
10780
  <span>${Array.isArray(Y)?Y.join(", "):String(Y)}</span>
10781
10781
  </div>`).join("")}
10782
- </div>`}var Rz=()=>{};import wz from"net";async function hM($){return new Promise((Z)=>{let Y=wz.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"0.0.0.0")})}async function dM($){return new Promise((Z)=>{let Y=wz.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"::")})}async function mM($){if(!await hM($))return!1;return await dM($)}async function y4($,Z=20){for(let Y=0;Y<Z;Y++){let X=$+Y;if(await mM(X))return X}throw Error(`Could not find an available port between ${$} and ${$+Z-1}`)}var Mz=()=>{};async function cM(){try{let $=await import("@stacksjs/desktop");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function _$($,Z={}){let Y={...uM,...Z},X=await cM();if(!X)return console.log(`${w.yellow}\u26A0${w.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let J=await X.openDevWindow($,{title:Y.title,width:Y.width,height:Y.height,darkMode:Y.darkMode,hotReload:Y.hotReload,nativeSidebar:Y.nativeSidebar,sidebarWidth:Y.sidebarWidth,sidebarConfig:Y.sidebarConfig});if(J&&Y.nativeSidebar)console.log(`${w.green}\u2713${w.reset} Native sidebar enabled (macOS Tahoe style)`);return J}catch(J){return console.log(`${w.red}\u2717${w.reset} Could not open native window:`,J),!1}}function e9($){if($.match(/<Sidebar[\s\S]*?variant=["']tahoe["'][\s\S]*?\/>/i)){let J=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(J){let Q=J[1];try{let G=`
10782
+ </div>`}var Rz=()=>{};import wz from"net";async function hM($){return new Promise((Z)=>{let Y=wz.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"0.0.0.0")})}async function dM($){return new Promise((Z)=>{let Y=wz.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"::")})}async function mM($){if(!await hM($))return!1;return await dM($)}async function y6($,Z=20){for(let Y=0;Y<Z;Y++){let X=$+Y;if(await mM(X))return X}throw Error(`Could not find an available port between ${$} and ${$+Z-1}`)}var Mz=()=>{};async function cM(){try{let $=await import("@stacksjs/desktop");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function _$($,Z={}){let Y={...uM,...Z},X=await cM();if(!X)return console.log(`${w.yellow}\u26A0${w.reset} Native window requested, but @stacksjs/desktop is not available.`),console.log(" Install & build the desktop package to enable --native."),!1;try{let J=await X.openDevWindow($,{title:Y.title,width:Y.width,height:Y.height,darkMode:Y.darkMode,hotReload:Y.hotReload,nativeSidebar:Y.nativeSidebar,sidebarWidth:Y.sidebarWidth,sidebarConfig:Y.sidebarConfig});if(J&&Y.nativeSidebar)console.log(`${w.green}\u2713${w.reset} Native sidebar enabled (macOS Tahoe style)`);return J}catch(J){return console.log(`${w.red}\u2717${w.reset} Could not open native window:`,J),!1}}function e9($){if($.match(/<Sidebar[\s\S]*?variant=["']tahoe["'][\s\S]*?\/>/i)){let J=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(J){let Q=J[1];try{let G=`
10783
10783
  ${Q}
10784
10784
  return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
10785
10785
  `,W=Function(G)();if(W)return W}catch(G){console.warn("Invalid sidebarConfig:",G)}}return{sections:[]}}let Y=$.match(/@nativeSidebar\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(Y)try{return JSON.parse(Y[1])}catch{console.warn("Invalid @nativeSidebar configuration")}let X=$.match(/<script\s+native-sidebar[^>]*>([\s\S]*?)<\/script>/i);if(X)try{let J=X[1].match(/(?:export\s+(?:default\s+)?|const\s+\w+\s*=\s*)(\{[\s\S]*\})/m);if(J)return Function(`return ${J[1]}`)()}catch(J){console.warn("Invalid native-sidebar script configuration:",J)}return}var uM;var Ez=D(()=>{s$();uM={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0}});function fX(){console.log(`
10786
- Keyboard shortcuts:`),console.log(` ${w.cyan}o${w.reset} + Enter - Open in browser`),console.log(` ${w.cyan}c${w.reset} + Enter - Clear console`),console.log(` ${w.cyan}q${w.reset} + Enter (or ${w.cyan}Ctrl+C${w.reset}) - Quit server`),console.log(` ${w.cyan}h${w.reset} + Enter - Show this help`)}function lM($){console.log(`${w.green}Server running at ${w.cyan}${$}${w.reset}`),console.log(`Press ${w.cyan}Ctrl+C${w.reset} to stop the server`),fX()}function pM($){console.log(`${w.dim}Opening ${w.cyan}${$}${w.dim} in your browser...${w.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function x4($,Z,Y){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),fX();let X="";process.stdin.on("data",(J)=>{if(J==="\x03"){if(Y?.onQuit)Y.onQuit();Z(),process.exit(0)}if(X+=J,X.endsWith("\r")||X.endsWith(`
10787
- `)){let Q=X.trim().toLowerCase();X="",iM(Q,$,Z,Y)}})}function iM($,Z,Y,X){switch($){case"o":if(X?.onOpen)X.onOpen();else pM(Z);break;case"c":if(X?.onClear)X.onClear();else console.clear(),lM(Z);break;case"q":if(X?.onQuit)X.onQuit();console.log(`${w.yellow}Stopping server...${w.reset}`),Y(),process.exit(0);break;case"h":if(X?.onHelp)X.onHelp();else fX();break;default:break}}var Tz=D(()=>{s$()});var Iz=()=>{};var d5=D(()=>{s$();r1();Rz();Mz();Ez();Tz();Iz()});var{serve:nM}=globalThis.Bun;import hX from"fs";import B$ from"path";async function $3($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=B$.resolve($);if(!hX.existsSync(J))return console.error(`${w.red}Error: File not found: ${w.bright}${J}${w.reset}`),!1;if(!J.endsWith(".md"))return console.error(`${w.red}Error: File must have .md extension: ${w.bright}${J}${w.reset}`),!1;console.log(`${w.blue}Processing${w.reset} ${w.bright}${$}${w.reset}...`);let Q=null,G=async()=>{try{let{content:B,data:z}=await Z4(J,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:G1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),q=Z.markdown?.syntaxHighlighting||G1.markdown?.syntaxHighlighting,j=q?.defaultTheme||"github-dark",H=["github-dark"],L=q?.additionalThemes||[],O=[...new Set([...H,...L])].map((V)=>`<option value="${V}"${V===j?" selected":""}>${V}</option>`).join(`
10786
+ Keyboard shortcuts:`),console.log(` ${w.cyan}o${w.reset} + Enter - Open in browser`),console.log(` ${w.cyan}c${w.reset} + Enter - Clear console`),console.log(` ${w.cyan}q${w.reset} + Enter (or ${w.cyan}Ctrl+C${w.reset}) - Quit server`),console.log(` ${w.cyan}h${w.reset} + Enter - Show this help`)}function lM($){console.log(`${w.green}Server running at ${w.cyan}${$}${w.reset}`),console.log(`Press ${w.cyan}Ctrl+C${w.reset} to stop the server`),fX()}function pM($){console.log(`${w.dim}Opening ${w.cyan}${$}${w.dim} in your browser...${w.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function x6($,Z,Y){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),fX();let X="";process.stdin.on("data",(J)=>{if(J==="\x03"){if(Y?.onQuit)Y.onQuit();Z(),process.exit(0)}if(X+=J,X.endsWith("\r")||X.endsWith(`
10787
+ `)){let Q=X.trim().toLowerCase();X="",iM(Q,$,Z,Y)}})}function iM($,Z,Y,X){switch($){case"o":if(X?.onOpen)X.onOpen();else pM(Z);break;case"c":if(X?.onClear)X.onClear();else console.clear(),lM(Z);break;case"q":if(X?.onQuit)X.onQuit();console.log(`${w.yellow}Stopping server...${w.reset}`),Y(),process.exit(0);break;case"h":if(X?.onHelp)X.onHelp();else fX();break;default:break}}var Tz=D(()=>{s$()});var Iz=()=>{};var d5=D(()=>{s$();r1();Rz();Mz();Ez();Tz();Iz()});var{serve:nM}=globalThis.Bun;import hX from"fs";import B$ from"path";async function $3($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=B$.resolve($);if(!hX.existsSync(J))return console.error(`${w.red}Error: File not found: ${w.bright}${J}${w.reset}`),!1;if(!J.endsWith(".md"))return console.error(`${w.red}Error: File must have .md extension: ${w.bright}${J}${w.reset}`),!1;console.log(`${w.blue}Processing${w.reset} ${w.bright}${$}${w.reset}...`);let Q=null,G=async()=>{try{let{content:B,data:z}=await Z6(J,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:G1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),q=Z.markdown?.syntaxHighlighting||G1.markdown?.syntaxHighlighting,j=q?.defaultTheme||"github-dark",H=["github-dark"],L=q?.additionalThemes||[],O=[...new Set([...H,...L])].map((V)=>`<option value="${V}"${V===j?" selected":""}>${V}</option>`).join(`
10788
10788
  `);return Q=`
10789
10789
  <!DOCTYPE html>
10790
10790
  <html lang="en">
@@ -10947,12 +10947,12 @@ Keyboard shortcuts:`),console.log(` ${w.cyan}o${w.reset} + Enter - Open in brow
10947
10947
  </script>
10948
10948
  </body>
10949
10949
  </html>
10950
- `,!0}catch(B){return console.error(`${w.red}Error processing Markdown file:${w.reset}`,B),!1}};if(!await G())return!1;let W=Y;try{if(W=await y4(Y),W!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${W} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}console.log(`${w.blue}Starting server on ${w.cyan}http://localhost:${W}/${w.reset}...`);let U=nM({port:W,fetch(B){if(new URL(B.url).pathname==="/")return new Response(Q,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}});return new Response("Not Found",{status:404})},error(B){return new Response(`<pre>${B}
10950
+ `,!0}catch(B){return console.error(`${w.red}Error processing Markdown file:${w.reset}`,B),!1}};if(!await G())return!1;let W=Y;try{if(W=await y6(Y),W!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${W} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}console.log(`${w.blue}Starting server on ${w.cyan}http://localhost:${W}/${w.reset}...`);let U=nM({port:W,fetch(B){if(new URL(B.url).pathname==="/")return new Response(Q,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}});return new Response("Not Found",{status:404})},error(B){return new Response(`<pre>${B}
10951
10951
  ${B.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
10952
10952
  ${w.blue}stx${w.reset} ${w.green}${process.env.stx_VERSION||"v0.0.10"}${w.reset} ${w.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${w.reset}`),console.log(`
10953
10953
  ${w.bright}\u2192 ${w.cyan}http://localhost:${W}/${w.reset}`),console.log(`
10954
10954
  ${w.yellow}Routes:${w.reset}`);let _=B$.relative(process.cwd(),J);if(console.log(` ${w.green}\u2514\u2500 /${w.reset} \u2192 ${w.bright}${_}${w.reset}`),console.log(`
10955
- Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x4(U.url.toString(),()=>{if(X)hX.watch(B$.dirname(J),{recursive:!0}).close();U.stop()}),Z.native)await _$(W,{title:B$.basename(J,".md")});if(X){let B=B$.dirname(J);console.log(`${w.blue}Watching ${w.bright}${B}${w.reset} for changes...`);let z=hX.watch(B,{recursive:!0},async(q,j)=>{if(j&&j.endsWith(".md"))console.log(`${w.yellow}File ${w.bright}${j}${w.yellow} changed, reprocessing...${w.reset}`),await G()});process.on("SIGINT",()=>{z.close(),U.stop(),process.exit(0)})}return!0}var dX=D(()=>{d6();u0();d5()});class mX{clients=new Set;server=null;options;constructor($={}){this.options={wsPort:$.wsPort??3001,showOverlay:$.showOverlay??!0,reconnectInterval:$.reconnectInterval??1000,maxReconnectAttempts:$.maxReconnectAttempts??10,verbose:$.verbose??!1}}start($){let Z=$??this.options.wsPort,Y=20;for(let X=0;X<Y;X++)try{if(this.server=Bun.serve({port:Z,fetch(J,Q){if(Q.upgrade(J,{data:{}}))return;return new Response("stx Hot Reload Server",{headers:{"Content-Type":"text/plain"}})},websocket:{open:(J)=>{if(this.clients.add(J),this.options.verbose)console.log(`[HMR] Client connected (${this.clients.size} total)`);J.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close:(J)=>{if(this.clients.delete(J),this.options.verbose)console.log(`[HMR] Client disconnected (${this.clients.size} total)`)},message:(J,Q)=>{let G=typeof Q==="string"?Q:Q.toString();if(G==="ping")return;try{let K=JSON.parse(G);if(K.type==="console"&&Array.isArray(K.args)){let W=K.args.join(" "),_={log:"\x1B[36m",warn:"\x1B[33m",error:"\x1B[31m",info:"\x1B[34m"}[K.level]??"\x1B[36m";console.log(`${_}[browser]${K.level!=="log"?` ${K.level}`:""}\x1B[0m ${W}`)}}catch{}}}}),this.options.verbose)console.log(`[HMR] WebSocket server started on port ${Z}`);return Z}catch(J){if(J?.code==="EADDRINUSE"){Z++;continue}throw J}throw Error(`Could not find an available port after ${Y} attempts starting from ${$??this.options.wsPort}`)}stop(){for(let $ of this.clients)try{$.close()}catch{}if(this.clients.clear(),this.server)this.server.stop(),this.server=null;if(this.options.verbose)console.log("[HMR] Server stopped")}broadcast($){let Z=JSON.stringify($),Y=0;for(let X of this.clients)try{if(X.readyState===1)X.send(Z),Y++}catch{this.clients.delete(X)}if(this.options.verbose&&Y>0)console.log(`[HMR] Broadcast ${$.type} to ${Y} client(s)`)}reload($){if(this.options.verbose)console.log(`[HMR] Sending reload to ${this.clients.size} client(s) for: ${$||"all"}`);this.broadcast({type:"reload",path:$,timestamp:Date.now()})}updateCss($,Z){this.broadcast({type:"css-update",path:$,content:Z,timestamp:Date.now()})}error($){this.broadcast({type:"error",content:$,timestamp:Date.now()})}get clientCount(){return this.clients.size}get port(){return this.options.wsPort}}function Dz($,Z={}){let{showOverlay:Y=!0,reconnectInterval:X=1000,maxReconnectAttempts:J=10}=Z;return`
10955
+ Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x6(U.url.toString(),()=>{if(X)hX.watch(B$.dirname(J),{recursive:!0}).close();U.stop()}),Z.native)await _$(W,{title:B$.basename(J,".md")});if(X){let B=B$.dirname(J);console.log(`${w.blue}Watching ${w.bright}${B}${w.reset} for changes...`);let z=hX.watch(B,{recursive:!0},async(q,j)=>{if(j&&j.endsWith(".md"))console.log(`${w.yellow}File ${w.bright}${j}${w.yellow} changed, reprocessing...${w.reset}`),await G()});process.on("SIGINT",()=>{z.close(),U.stop(),process.exit(0)})}return!0}var dX=D(()=>{d4();u0();d5()});class mX{clients=new Set;server=null;options;constructor($={}){this.options={wsPort:$.wsPort??3001,showOverlay:$.showOverlay??!0,reconnectInterval:$.reconnectInterval??1000,maxReconnectAttempts:$.maxReconnectAttempts??10,verbose:$.verbose??!1}}start($){let Z=$??this.options.wsPort,Y=20;for(let X=0;X<Y;X++)try{if(this.server=Bun.serve({port:Z,fetch(J,Q){if(Q.upgrade(J,{data:{}}))return;return new Response("stx Hot Reload Server",{headers:{"Content-Type":"text/plain"}})},websocket:{open:(J)=>{if(this.clients.add(J),this.options.verbose)console.log(`[HMR] Client connected (${this.clients.size} total)`);J.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close:(J)=>{if(this.clients.delete(J),this.options.verbose)console.log(`[HMR] Client disconnected (${this.clients.size} total)`)},message:(J,Q)=>{let G=typeof Q==="string"?Q:Q.toString();if(G==="ping")return;try{let K=JSON.parse(G);if(K.type==="console"&&Array.isArray(K.args)){let W=K.args.join(" "),_={log:"\x1B[36m",warn:"\x1B[33m",error:"\x1B[31m",info:"\x1B[34m"}[K.level]??"\x1B[36m";console.log(`${_}[browser]${K.level!=="log"?` ${K.level}`:""}\x1B[0m ${W}`)}}catch{}}}}),this.options.verbose)console.log(`[HMR] WebSocket server started on port ${Z}`);return Z}catch(J){if(J?.code==="EADDRINUSE"){Z++;continue}throw J}throw Error(`Could not find an available port after ${Y} attempts starting from ${$??this.options.wsPort}`)}stop(){for(let $ of this.clients)try{$.close()}catch{}if(this.clients.clear(),this.server)this.server.stop(),this.server=null;if(this.options.verbose)console.log("[HMR] Server stopped")}broadcast($){let Z=JSON.stringify($),Y=0;for(let X of this.clients)try{if(X.readyState===1)X.send(Z),Y++}catch{this.clients.delete(X)}if(this.options.verbose&&Y>0)console.log(`[HMR] Broadcast ${$.type} to ${Y} client(s)`)}reload($){if(this.options.verbose)console.log(`[HMR] Sending reload to ${this.clients.size} client(s) for: ${$||"all"}`);this.broadcast({type:"reload",path:$,timestamp:Date.now()})}updateCss($,Z){this.broadcast({type:"css-update",path:$,content:Z,timestamp:Date.now()})}error($){this.broadcast({type:"error",content:$,timestamp:Date.now()})}get clientCount(){return this.clients.size}get port(){return this.options.wsPort}}function Dz($,Z={}){let{showOverlay:Y=!0,reconnectInterval:X=1000,maxReconnectAttempts:J=10}=Z;return`
10956
10956
  <script>
10957
10957
  (function() {
10958
10958
  // stx Hot Reload Client
@@ -11145,34 +11145,34 @@ else {
11145
11145
  };
11146
11146
  })();
11147
11147
  </script>
11148
- `}function f1($,Z,Y={}){let X=Dz(Z,Y),J=$.lastIndexOf("</body>");if(J!==-1)return $.slice(0,J)+X+$.slice(J);if($.includes("</html>"))return $.replace("</html>",`${X}</html>`);return $+X}function m5($){let Z=$.toLowerCase();return Z.endsWith(".css")||Z.endsWith(".scss")||Z.endsWith(".sass")||Z.endsWith(".less")}function u5($){let Z=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((X)=>Z.endsWith(X))}function c5($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Y)=>Y.test($))}function l5($){if(!z$)z$=new mX($);return z$}function q$(){if(z$)z$.stop(),z$=null}var z$=null;function p5($){let{token:Z,baseUrl:Y="https://api.netlify.com/api/v1"}=$;async function X(J,Q,G={}){let K=`${Y}${Q}`,W={Authorization:`Bearer ${Z}`,"User-Agent":"stx-deploy/1.0"},U;if(G.rawBody)W["Content-Type"]=G.contentType||"application/octet-stream",U=G.rawBody;else if(G.body)W["Content-Type"]="application/json",U=JSON.stringify(G.body);let _=await fetch(K,{method:J,headers:W,body:U});if(!_.ok){let z=Error(`Netlify API error: ${_.status} ${_.statusText}`);z.status=_.status;try{let q=await _.json();z.message=q.message||z.message,z.code=q.code,z.details=q}catch{}throw z}let B=await _.text();if(!B)return{};return JSON.parse(B)}return{async getSite(J){return X("GET",`/sites/${J}`)},async listSites(){return X("GET","/sites")},async createSite(J){let Q={};if(J)Q.name=J;return X("POST","/sites",{body:Q})},async createDeploy(J,Q){let G={files:Q.files,draft:Q.draft??!0,async:Q.async??!0};if(Q.title)G.title=Q.title;if(Q.branch)G.branch=Q.branch;if(Q.functions)G.functions=Q.functions;return X("POST",`/sites/${J}/deploys`,{body:G})},async uploadFile(J,Q,G){let K=Q.startsWith("/")?Q.slice(1):Q;await X("PUT",`/deploys/${J}/files/${K}`,{rawBody:G,contentType:"application/octet-stream"})},async uploadFiles(J,Q){let K=[...Q],W=async()=>{while(K.length>0){let _=K.shift();if(_)await this.uploadFile(J,_.path,_.content)}},U=Array.from({length:Math.min(5,Q.length)},()=>W());await Promise.all(U)},async getDeploy(J){return X("GET",`/deploys/${J}`)},async waitForDeploy(J,Q={}){let{timeout:G=300000,pollInterval:K=2000,onProgress:W}=Q,U=Date.now();while(!0){let _=await this.getDeploy(J);if(W)W(_);if(_.state==="ready")return _;if(_.state==="error"){let B=Error(`Deploy failed: ${_.error_message||"Unknown error"}`);throw B.status=500,B.details=_,B}if(Date.now()-U>G){let B=Error(`Deploy timed out after ${G}ms`);throw B.status=408,B.details=_,B}await new Promise((B)=>setTimeout(B,K))}},async lockDeploy(J){return X("POST",`/deploys/${J}/lock`)},async unlockDeploy(J){return X("POST",`/deploys/${J}/unlock`)}}}async function Z3($){let Z=await crypto.subtle.digest("SHA-1",$);return Array.from(new Uint8Array(Z)).map((X)=>X.toString(16).padStart(2,"0")).join("")}async function j$($,Z={}){let{ignore:Y=["node_modules",".git",".env*","*.map"]}=Z,X=[],J=new Bun.Glob("**/*");for await(let Q of J.scan({cwd:$,onlyFiles:!0,dot:!1})){if(Y.some((B)=>{if(B.includes("*"))return new RegExp(`^${B.replace(/\*/g,".*")}$`).test(Q);return Q.includes(B)}))continue;let K=`${$}/${Q}`,U=await Bun.file(K).arrayBuffer(),_=await Z3(U);X.push({path:Q,content:new Uint8Array(U),sha1:_})}return X}function i5($){let Z={};for(let Y of $)Z[`/${Y.path}`]=Y.sha1;return Z}function n5($,Z){let Y=new Set(Z.map((X)=>X.startsWith("/")?X.slice(1):X));return $.filter((X)=>Y.has(X.path))}function v4($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;if($<1073741824)return`${($/1048576).toFixed(1)} MB`;return`${($/1073741824).toFixed(1)} GB`}function Y4($){return $.reduce((Z,Y)=>Z+Y.content.byteLength,0)}import X4 from"fs";import h1 from"path";function Y3($){let Z=[];if(Z.push("[build]"),Z.push(` command = "${d0($.build.command)}"`),Z.push(` publish = "${d0($.build.publish)}"`),$.build.functions)Z.push(` functions = "${d0($.build.functions)}"`);if($.build.edge_functions)Z.push(` edge_functions = "${d0($.build.edge_functions)}"`);if($.build.environment&&Object.keys($.build.environment).length>0){Z.push(""),Z.push("[build.environment]");for(let[Y,X]of Object.entries($.build.environment))Z.push(` ${Y} = "${d0(X)}"`)}if($.functions){if(Z.push(""),Z.push("[functions]"),$.functions.directory)Z.push(` directory = "${d0($.functions.directory)}"`);if($.functions.node_bundler)Z.push(` node_bundler = "${$.functions.node_bundler}"`);if($.functions.external_node_modules&&$.functions.external_node_modules.length>0)Z.push(` external_node_modules = [${$.functions.external_node_modules.map((Y)=>`"${Y}"`).join(", ")}]`)}if($.edge_functions&&$.edge_functions.length>0){Z.push("");for(let Y of $.edge_functions)Z.push("[[edge_functions]]"),Z.push(` function = "${d0(Y.function)}"`),Z.push(` path = "${d0(Y.path)}"`)}if($.redirects&&$.redirects.length>0){Z.push("");for(let Y of $.redirects){if(Z.push("[[redirects]]"),Z.push(` from = "${d0(Y.from)}"`),Z.push(` to = "${d0(Y.to)}"`),Y.status!==void 0)Z.push(` status = ${Y.status}`);if(Y.force!==void 0)Z.push(` force = ${Y.force}`);if(Y.conditions&&Object.keys(Y.conditions).length>0){Z.push(" [redirects.conditions]");for(let[X,J]of Object.entries(Y.conditions))Z.push(` ${X} = "${d0(J)}"`)}}}if($.headers&&$.headers.length>0){Z.push("");for(let Y of $.headers){Z.push("[[headers]]"),Z.push(` for = "${d0(Y.for)}"`),Z.push(" [headers.values]");for(let[X,J]of Object.entries(Y.values))Z.push(` ${X} = "${d0(J)}"`)}}if($.plugins&&$.plugins.length>0){Z.push("");for(let Y of $.plugins)if(Z.push("[[plugins]]"),Z.push(` package = "${d0(Y.package)}"`),Y.inputs&&Object.keys(Y.inputs).length>0){Z.push(" [plugins.inputs]");for(let[X,J]of Object.entries(Y.inputs))if(typeof J==="string")Z.push(` ${X} = "${d0(J)}"`);else if(typeof J==="boolean"||typeof J==="number")Z.push(` ${X} = ${J}`)}}if($.context&&Object.keys($.context).length>0)for(let[Y,X]of Object.entries($.context)){if(Z.push(""),Z.push(`[context.${Y}]`),X.command)Z.push(` command = "${d0(X.command)}"`);if(X.publish)Z.push(` publish = "${d0(X.publish)}"`);if(X.environment&&Object.keys(X.environment).length>0){Z.push(` [context.${Y}.environment]`);for(let[J,Q]of Object.entries(X.environment))Z.push(` ${J} = "${d0(Q)}"`)}}return Z.join(`
11148
+ `}function f1($,Z,Y={}){let X=Dz(Z,Y),J=$.lastIndexOf("</body>");if(J!==-1)return $.slice(0,J)+X+$.slice(J);if($.includes("</html>"))return $.replace("</html>",`${X}</html>`);return $+X}function m5($){let Z=$.toLowerCase();return Z.endsWith(".css")||Z.endsWith(".scss")||Z.endsWith(".sass")||Z.endsWith(".less")}function u5($){let Z=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((X)=>Z.endsWith(X))}function c5($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Y)=>Y.test($))}function l5($){if(!z$)z$=new mX($);return z$}function q$(){if(z$)z$.stop(),z$=null}var z$=null;function p5($){let{token:Z,baseUrl:Y="https://api.netlify.com/api/v1"}=$;async function X(J,Q,G={}){let K=`${Y}${Q}`,W={Authorization:`Bearer ${Z}`,"User-Agent":"stx-deploy/1.0"},U;if(G.rawBody)W["Content-Type"]=G.contentType||"application/octet-stream",U=G.rawBody;else if(G.body)W["Content-Type"]="application/json",U=JSON.stringify(G.body);let _=await fetch(K,{method:J,headers:W,body:U});if(!_.ok){let z=Error(`Netlify API error: ${_.status} ${_.statusText}`);z.status=_.status;try{let q=await _.json();z.message=q.message||z.message,z.code=q.code,z.details=q}catch{}throw z}let B=await _.text();if(!B)return{};return JSON.parse(B)}return{async getSite(J){return X("GET",`/sites/${J}`)},async listSites(){return X("GET","/sites")},async createSite(J){let Q={};if(J)Q.name=J;return X("POST","/sites",{body:Q})},async createDeploy(J,Q){let G={files:Q.files,draft:Q.draft??!0,async:Q.async??!0};if(Q.title)G.title=Q.title;if(Q.branch)G.branch=Q.branch;if(Q.functions)G.functions=Q.functions;return X("POST",`/sites/${J}/deploys`,{body:G})},async uploadFile(J,Q,G){let K=Q.startsWith("/")?Q.slice(1):Q;await X("PUT",`/deploys/${J}/files/${K}`,{rawBody:G,contentType:"application/octet-stream"})},async uploadFiles(J,Q){let K=[...Q],W=async()=>{while(K.length>0){let _=K.shift();if(_)await this.uploadFile(J,_.path,_.content)}},U=Array.from({length:Math.min(5,Q.length)},()=>W());await Promise.all(U)},async getDeploy(J){return X("GET",`/deploys/${J}`)},async waitForDeploy(J,Q={}){let{timeout:G=300000,pollInterval:K=2000,onProgress:W}=Q,U=Date.now();while(!0){let _=await this.getDeploy(J);if(W)W(_);if(_.state==="ready")return _;if(_.state==="error"){let B=Error(`Deploy failed: ${_.error_message||"Unknown error"}`);throw B.status=500,B.details=_,B}if(Date.now()-U>G){let B=Error(`Deploy timed out after ${G}ms`);throw B.status=408,B.details=_,B}await new Promise((B)=>setTimeout(B,K))}},async lockDeploy(J){return X("POST",`/deploys/${J}/lock`)},async unlockDeploy(J){return X("POST",`/deploys/${J}/unlock`)}}}async function Z3($){let Z=await crypto.subtle.digest("SHA-1",$);return Array.from(new Uint8Array(Z)).map((X)=>X.toString(16).padStart(2,"0")).join("")}async function j$($,Z={}){let{ignore:Y=["node_modules",".git",".env*","*.map"]}=Z,X=[],J=new Bun.Glob("**/*");for await(let Q of J.scan({cwd:$,onlyFiles:!0,dot:!1})){if(Y.some((B)=>{if(B.includes("*"))return new RegExp(`^${B.replace(/\*/g,".*")}$`).test(Q);return Q.includes(B)}))continue;let K=`${$}/${Q}`,U=await Bun.file(K).arrayBuffer(),_=await Z3(U);X.push({path:Q,content:new Uint8Array(U),sha1:_})}return X}function i5($){let Z={};for(let Y of $)Z[`/${Y.path}`]=Y.sha1;return Z}function n5($,Z){let Y=new Set(Z.map((X)=>X.startsWith("/")?X.slice(1):X));return $.filter((X)=>Y.has(X.path))}function v6($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;if($<1073741824)return`${($/1048576).toFixed(1)} MB`;return`${($/1073741824).toFixed(1)} GB`}function Y6($){return $.reduce((Z,Y)=>Z+Y.content.byteLength,0)}import X6 from"fs";import h1 from"path";function Y3($){let Z=[];if(Z.push("[build]"),Z.push(` command = "${d0($.build.command)}"`),Z.push(` publish = "${d0($.build.publish)}"`),$.build.functions)Z.push(` functions = "${d0($.build.functions)}"`);if($.build.edge_functions)Z.push(` edge_functions = "${d0($.build.edge_functions)}"`);if($.build.environment&&Object.keys($.build.environment).length>0){Z.push(""),Z.push("[build.environment]");for(let[Y,X]of Object.entries($.build.environment))Z.push(` ${Y} = "${d0(X)}"`)}if($.functions){if(Z.push(""),Z.push("[functions]"),$.functions.directory)Z.push(` directory = "${d0($.functions.directory)}"`);if($.functions.node_bundler)Z.push(` node_bundler = "${$.functions.node_bundler}"`);if($.functions.external_node_modules&&$.functions.external_node_modules.length>0)Z.push(` external_node_modules = [${$.functions.external_node_modules.map((Y)=>`"${Y}"`).join(", ")}]`)}if($.edge_functions&&$.edge_functions.length>0){Z.push("");for(let Y of $.edge_functions)Z.push("[[edge_functions]]"),Z.push(` function = "${d0(Y.function)}"`),Z.push(` path = "${d0(Y.path)}"`)}if($.redirects&&$.redirects.length>0){Z.push("");for(let Y of $.redirects){if(Z.push("[[redirects]]"),Z.push(` from = "${d0(Y.from)}"`),Z.push(` to = "${d0(Y.to)}"`),Y.status!==void 0)Z.push(` status = ${Y.status}`);if(Y.force!==void 0)Z.push(` force = ${Y.force}`);if(Y.conditions&&Object.keys(Y.conditions).length>0){Z.push(" [redirects.conditions]");for(let[X,J]of Object.entries(Y.conditions))Z.push(` ${X} = "${d0(J)}"`)}}}if($.headers&&$.headers.length>0){Z.push("");for(let Y of $.headers){Z.push("[[headers]]"),Z.push(` for = "${d0(Y.for)}"`),Z.push(" [headers.values]");for(let[X,J]of Object.entries(Y.values))Z.push(` ${X} = "${d0(J)}"`)}}if($.plugins&&$.plugins.length>0){Z.push("");for(let Y of $.plugins)if(Z.push("[[plugins]]"),Z.push(` package = "${d0(Y.package)}"`),Y.inputs&&Object.keys(Y.inputs).length>0){Z.push(" [plugins.inputs]");for(let[X,J]of Object.entries(Y.inputs))if(typeof J==="string")Z.push(` ${X} = "${d0(J)}"`);else if(typeof J==="boolean"||typeof J==="number")Z.push(` ${X} = ${J}`)}}if($.context&&Object.keys($.context).length>0)for(let[Y,X]of Object.entries($.context)){if(Z.push(""),Z.push(`[context.${Y}]`),X.command)Z.push(` command = "${d0(X.command)}"`);if(X.publish)Z.push(` publish = "${d0(X.publish)}"`);if(X.environment&&Object.keys(X.environment).length>0){Z.push(` [context.${Y}.environment]`);for(let[J,Q]of Object.entries(X.environment))Z.push(` ${J} = "${d0(Q)}"`)}}return Z.join(`
11149
11149
  `)+`
11150
- `}function d0($){return $.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function H$($){let Z={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},Y=h1.join($,"package.json");if(await Bun.file(Y).exists())try{let U=JSON.parse(await Bun.file(Y).text());if(U.scripts?.build)Z.buildCommand="bun run build";let _={...U.dependencies,...U.devDependencies};if(_["@stacksjs/stx"]||_.stx)Z.framework="stx"}catch{}let X=h1.join($,"stx.config.ts"),J=h1.join($,".config","stx.config.ts");if(await Bun.file(X).exists()||await Bun.file(J).exists())Z.framework="stx";let Q=["dist","build","out","public",".output"];for(let U of Q){let _=h1.join($,U);if(X4.existsSync(_)&&X4.statSync(_).isDirectory()){Z.outputDir=U;break}}let G=["functions","netlify/functions","api"];for(let U of G){let _=h1.join($,U);if(X4.existsSync(_)&&X4.statSync(_).isDirectory()){Z.functionsDir=U;break}}let K=h1.join($,"netlify","edge-functions");if(X4.existsSync(K))Z.edgeFunctionsDir="netlify/edge-functions";let W=h1.join($,Z.outputDir||"dist");if(X4.existsSync(W)){let U=X4.existsSync(h1.join(W,"index.html")),_=X4.readdirSync(W).filter((B)=>B.endsWith(".html"));Z.isSPA=U&&_.length===1}return Z}function L$($={}){let Z={build:{command:$.buildCommand||"bun run build",publish:$.outputDir||"dist"}};if($.functionsDir)Z.build.functions=$.functionsDir,Z.functions={directory:$.functionsDir,node_bundler:"esbuild"};if($.edgeFunctionsDir)Z.build.edge_functions=$.edgeFunctionsDir;if(Z.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],$.isSPA!==!1)Z.redirects=[{from:"/*",to:"/index.html",status:200}];return Z.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},Z}async function r5($,Z){let Y=await H$($),X=Z||L$(Y),J=Y3(X),Q=h1.join($,"netlify.toml");return await Bun.write(Q,J),Q}function s5($){return X4.existsSync(h1.join($,"netlify.toml"))}var uX=()=>{};var bz={};t(bz,{writeNetlifyConfig:()=>r5,initNetlify:()=>Sz,hasNetlifyConfig:()=>s5,getTotalSize:()=>Y4,generateNetlifyToml:()=>Y3,formatSize:()=>v4,filterRequiredFiles:()=>n5,detectProjectConfig:()=>H$,deploy:()=>kz,createNetlifyClient:()=>p5,createFileManifest:()=>i5,createDefaultNetlifyConfig:()=>L$,collectDeployFiles:()=>j$,calculateSha1:()=>Z3,DeployError:()=>J4});import cX from"fs";import lX from"path";async function kz($={}){let Z=Date.now(),Y=[],X=$.cwd||process.cwd(),J=(O)=>{Y.push(O)},Q=(O)=>{if($.onProgress)$.onProgress(O)},G=lX.resolve(X,$.directory||"dist"),K=$.token||process.env.NETLIFY_AUTH_TOKEN,W=$.siteId||process.env.NETLIFY_SITE_ID;if(!K)throw new J4(`No Netlify auth token found.
11150
+ `}function d0($){return $.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function H$($){let Z={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},Y=h1.join($,"package.json");if(await Bun.file(Y).exists())try{let U=JSON.parse(await Bun.file(Y).text());if(U.scripts?.build)Z.buildCommand="bun run build";let _={...U.dependencies,...U.devDependencies};if(_["@stacksjs/stx"]||_.stx)Z.framework="stx"}catch{}let X=h1.join($,"stx.config.ts"),J=h1.join($,".config","stx.config.ts");if(await Bun.file(X).exists()||await Bun.file(J).exists())Z.framework="stx";let Q=["dist","build","out","public",".output"];for(let U of Q){let _=h1.join($,U);if(X6.existsSync(_)&&X6.statSync(_).isDirectory()){Z.outputDir=U;break}}let G=["functions","netlify/functions","api"];for(let U of G){let _=h1.join($,U);if(X6.existsSync(_)&&X6.statSync(_).isDirectory()){Z.functionsDir=U;break}}let K=h1.join($,"netlify","edge-functions");if(X6.existsSync(K))Z.edgeFunctionsDir="netlify/edge-functions";let W=h1.join($,Z.outputDir||"dist");if(X6.existsSync(W)){let U=X6.existsSync(h1.join(W,"index.html")),_=X6.readdirSync(W).filter((B)=>B.endsWith(".html"));Z.isSPA=U&&_.length===1}return Z}function L$($={}){let Z={build:{command:$.buildCommand||"bun run build",publish:$.outputDir||"dist"}};if($.functionsDir)Z.build.functions=$.functionsDir,Z.functions={directory:$.functionsDir,node_bundler:"esbuild"};if($.edgeFunctionsDir)Z.build.edge_functions=$.edgeFunctionsDir;if(Z.headers=[{for:"/*",values:{"X-Frame-Options":"DENY","X-Content-Type-Options":"nosniff","X-XSS-Protection":"1; mode=block","Referrer-Policy":"strict-origin-when-cross-origin"}},{for:"/assets/*",values:{"Cache-Control":"public, max-age=31536000, immutable"}}],$.isSPA!==!1)Z.redirects=[{from:"/*",to:"/index.html",status:200}];return Z.context={production:{environment:{NODE_ENV:"production"}},"deploy-preview":{environment:{NODE_ENV:"development"}}},Z}async function r5($,Z){let Y=await H$($),X=Z||L$(Y),J=Y3(X),Q=h1.join($,"netlify.toml");return await Bun.write(Q,J),Q}function s5($){return X6.existsSync(h1.join($,"netlify.toml"))}var uX=()=>{};var bz={};t(bz,{writeNetlifyConfig:()=>r5,initNetlify:()=>Sz,hasNetlifyConfig:()=>s5,getTotalSize:()=>Y6,generateNetlifyToml:()=>Y3,formatSize:()=>v6,filterRequiredFiles:()=>n5,detectProjectConfig:()=>H$,deploy:()=>kz,createNetlifyClient:()=>p5,createFileManifest:()=>i5,createDefaultNetlifyConfig:()=>L$,collectDeployFiles:()=>j$,calculateSha1:()=>Z3,DeployError:()=>J6});import cX from"fs";import lX from"path";async function kz($={}){let Z=Date.now(),Y=[],X=$.cwd||process.cwd(),J=(O)=>{Y.push(O)},Q=(O)=>{if($.onProgress)$.onProgress(O)},G=lX.resolve(X,$.directory||"dist"),K=$.token||process.env.NETLIFY_AUTH_TOKEN,W=$.siteId||process.env.NETLIFY_SITE_ID;if(!K)throw new J6(`No Netlify auth token found.
11151
11151
 
11152
11152
  To deploy to Netlify:
11153
11153
  1. Create account at https://app.netlify.com
11154
11154
  2. Get token at https://app.netlify.com/user/applications#personal-access-tokens
11155
11155
  3. Set NETLIFY_AUTH_TOKEN environment variable
11156
11156
 
11157
- export NETLIFY_AUTH_TOKEN=your_token_here`,"NO_TOKEN");if(!W)throw new J4(`No Netlify site ID found.
11157
+ export NETLIFY_AUTH_TOKEN=your_token_here`,"NO_TOKEN");if(!W)throw new J6(`No Netlify site ID found.
11158
11158
 
11159
11159
  Either:
11160
11160
  1. Set NETLIFY_SITE_ID environment variable
11161
11161
  2. Pass --site-id option
11162
11162
  3. Run \`stx deploy --init\` to set up
11163
11163
 
11164
- Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,"NO_SITE_ID");if(!cX.existsSync(G))throw new J4(`Build directory not found: ${G}
11164
+ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,"NO_SITE_ID");if(!cX.existsSync(G))throw new J6(`Build directory not found: ${G}
11165
11165
 
11166
- Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(cX.readdirSync(G).length>0))throw new J4(`Build directory is empty: ${G}
11166
+ Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(cX.readdirSync(G).length>0))throw new J6(`Build directory is empty: ${G}
11167
11167
 
11168
- Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if($.dryRun){Q({stage:"collect",message:"Collecting files..."});let O=await j$(G),V=Y4(O);return J(`Would deploy ${O.length} files (${v4(V)})`),J(`From: ${G}`),J(`To: Site ${W}`),J(`Mode: ${$.production?"production":"draft"}`),{success:!0,url:`https://${W}.netlify.app (dry-run)`,deployId:"dry-run",logs:Y,duration:Date.now()-Z,filesUploaded:O.length,totalSize:V}}let _=p5({token:K});Q({stage:"collect",message:"Verifying site..."});try{let O=await _.getSite(W);J(`Deploying to: ${O.name} (${O.url})`)}catch(O){if(O.status===404)throw new J4(`Site not found: ${W}
11168
+ Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if($.dryRun){Q({stage:"collect",message:"Collecting files..."});let O=await j$(G),V=Y6(O);return J(`Would deploy ${O.length} files (${v6(V)})`),J(`From: ${G}`),J(`To: Site ${W}`),J(`Mode: ${$.production?"production":"draft"}`),{success:!0,url:`https://${W}.netlify.app (dry-run)`,deployId:"dry-run",logs:Y,duration:Date.now()-Z,filesUploaded:O.length,totalSize:V}}let _=p5({token:K});Q({stage:"collect",message:"Verifying site..."});try{let O=await _.getSite(W);J(`Deploying to: ${O.name} (${O.url})`)}catch(O){if(O.status===404)throw new J6(`Site not found: ${W}
11169
11169
 
11170
- Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw O}Q({stage:"collect",message:"Collecting files..."});let B=await j$(G),z=Y4(B);if(J(`Found ${B.length} files (${v4(z)})`),B.length===0)throw new J4(`No files found in ${G}`,"NO_FILES");let q=i5(B);Q({stage:"upload",message:"Creating deploy...",percent:0});let j=await _.createDeploy(W,{title:$.message||"Deploy from stx CLI",draft:!$.production,files:q});J(`Created deploy: ${j.id}`);let H=n5(B,j.required||[]);if(J(`Uploading ${H.length} files...`),H.length>0){let O=0,V=Y4(H);for(let N of H){await _.uploadFile(j.id,N.path,N.content),O++;let A=Math.round(O/H.length*100);Q({stage:"upload",message:`Uploading: ${N.path}`,percent:A,details:{uploaded:O,total:H.length}})}J(`Uploaded ${v4(V)}`)}else J("All files already on CDN (no upload needed)");Q({stage:"process",message:"Processing deploy..."});let L=await _.waitForDeploy(j.id,{onProgress:(O)=>{Q({stage:"process",message:`Status: ${O.state}`,details:O})}}),F=Date.now()-Z;if(Q({stage:"done",message:"Deploy complete!"}),J(`Deploy complete in ${(F/1000).toFixed(1)}s`),J(`URL: ${L.deploy_ssl_url}`),$.production)J(`Site: ${L.ssl_url}`);if($.open){let O=$.production?L.ssl_url:L.deploy_ssl_url;rM(O)}return{success:!0,url:L.deploy_ssl_url,siteUrl:$.production?L.ssl_url:void 0,deployId:L.id,logs:Y,duration:F,filesUploaded:H.length,totalSize:Y4(H)}}async function Sz($={}){let Z=$.directory||process.cwd(),Y;if(s5(Z))Y=lX.join(Z,"netlify.toml");else{let X=await H$(Z);Y=await r5(Z,L$(X))}if($.siteId){let X=lX.join(Z,".env.local"),J="";if(await Bun.file(X).exists()){if(J=await Bun.file(X).text(),J=J.split(`
11170
+ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw O}Q({stage:"collect",message:"Collecting files..."});let B=await j$(G),z=Y6(B);if(J(`Found ${B.length} files (${v6(z)})`),B.length===0)throw new J6(`No files found in ${G}`,"NO_FILES");let q=i5(B);Q({stage:"upload",message:"Creating deploy...",percent:0});let j=await _.createDeploy(W,{title:$.message||"Deploy from stx CLI",draft:!$.production,files:q});J(`Created deploy: ${j.id}`);let H=n5(B,j.required||[]);if(J(`Uploading ${H.length} files...`),H.length>0){let O=0,V=Y6(H);for(let N of H){await _.uploadFile(j.id,N.path,N.content),O++;let A=Math.round(O/H.length*100);Q({stage:"upload",message:`Uploading: ${N.path}`,percent:A,details:{uploaded:O,total:H.length}})}J(`Uploaded ${v6(V)}`)}else J("All files already on CDN (no upload needed)");Q({stage:"process",message:"Processing deploy..."});let L=await _.waitForDeploy(j.id,{onProgress:(O)=>{Q({stage:"process",message:`Status: ${O.state}`,details:O})}}),F=Date.now()-Z;if(Q({stage:"done",message:"Deploy complete!"}),J(`Deploy complete in ${(F/1000).toFixed(1)}s`),J(`URL: ${L.deploy_ssl_url}`),$.production)J(`Site: ${L.ssl_url}`);if($.open){let O=$.production?L.ssl_url:L.deploy_ssl_url;rM(O)}return{success:!0,url:L.deploy_ssl_url,siteUrl:$.production?L.ssl_url:void 0,deployId:L.id,logs:Y,duration:F,filesUploaded:H.length,totalSize:Y6(H)}}async function Sz($={}){let Z=$.directory||process.cwd(),Y;if(s5(Z))Y=lX.join(Z,"netlify.toml");else{let X=await H$(Z);Y=await r5(Z,L$(X))}if($.siteId){let X=lX.join(Z,".env.local"),J="";if(await Bun.file(X).exists()){if(J=await Bun.file(X).text(),J=J.split(`
11171
11171
  `).filter((Q)=>!Q.startsWith("NETLIFY_SITE_ID=")).join(`
11172
11172
  `),J&&!J.endsWith(`
11173
11173
  `))J+=`
11174
11174
  `}J+=`NETLIFY_SITE_ID=${$.siteId}
11175
- `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function rM($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var J4;var X3=D(()=>{uX();uX();J4=class J4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});import sM from"fs";import J3 from"path";import aM from"crypto";async function Q3(){if(Cz)return pX;Cz=!0;try{let $=await import("sharp");return pX=$.default||$,pX}catch{return null}}async function d1(){return await Q3()!==null}async function m1($,Z={}){let{widths:Y=H1,formats:X=L1,quality:J=O1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,_;if(typeof $==="string"){if(_=$,!await Bun.file($).exists())throw new A$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((N)=>Buffer.from(N))}else _="buffer-input",U=$;let B=aM.createHash("sha256").update(U).digest("hex").slice(0,12),z=await a5(U),{width:q,height:j}=z,H=q/j;await sM.promises.mkdir(K,{recursive:!0});let L=[],F=J3.basename(_,J3.extname(_)),O=Y.filter((N)=>N<=q);if(!O.includes(q)&&q<=Math.max(...Y))O.push(q);O.sort((N,A)=>N-A);for(let N of O){let A=Math.round(N/H);for(let R of X){let M=`${F}-${N}w-${B}.${R}`,E=J3.join(K,M),I=`${W}/${M}`,T=await eM(U,{width:N,height:A,format:R,quality:J,fit:Q});await Bun.write(E,T),L.push({path:E,url:I,width:N,height:A,format:R,size:T.length})}}let V;if(G!=="none")V=await $E(U,G);return{src:_,variants:L,placeholder:V,width:q,height:j,aspectRatio:H,hash:B}}async function a5($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await Q3();if(Y){let J=await Y(Z).metadata();return{width:J.width||0,height:J.height||0,format:J.format||"unknown",hasAlpha:J.hasAlpha}}return tM(Z)}function tM($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let J=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:J,format:"jpeg",hasAlpha:!1}}let X=$.readUInt16BE(Z+2);Z+=2+X}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,X=$.readUInt16LE(28)&16383;return{width:Y,height:X,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),X=(Y&16383)+1,J=(Y>>14&16383)+1;return{width:X,height:J,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new A$("Unable to parse image dimensions","PARSE_ERROR")}async function eM($,Z){let Y=await Q3();if(Y){let X=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":X=X.webp({quality:Z.quality});break;case"avif":X=X.avif({quality:Z.quality});break;case"jpeg":X=X.jpeg({quality:Z.quality});break;case"png":X=X.png({quality:Z.quality});break}return X.toBuffer()}return console.warn("sharp not available, returning original image without optimization"),$}async function $E($,Z){let Y=await Q3();if(Z==="blur"&&Y){let J=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),Q=await a5($);return`data:${Pz[Q.format]||"image/jpeg"};base64,${J}`}if(Y){let{dominant:X}=await Y($).resize(1,1).toBuffer().then(async(J)=>{let Q=await Y(J).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${X.r}, ${X.g}, ${X.b})`}return"rgb(128, 128, 128)"}function $6($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function O$($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,X)=>{let J=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(X[0].replace(/\D/g,""))||0)-J}).map(([Y,X])=>`(max-width: ${Y}) ${X}`).join(", ")+", 100vw"}function F$($){let Z=$.filter((X)=>X.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((X,J)=>X.width-J.width);return Y[Math.floor(Y.length/2)]}function V$($){let Z=new Map;for(let Y of $){let X=Z.get(Y.format)||[];X.push(Y),Z.set(Y.format,X)}return Z}function o5($){let Z=J3.extname($).toLowerCase();return oM.includes(Z)}function u1($){return Pz[$]||"application/octet-stream"}function G3($){return $.reduce((Z,Y)=>Z+Y.size,0)}function K3($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var H1,L1,O1=80,oM,Pz,pX=null,Cz=!1,A$;var t5=D(()=>{H1=[320,640,768,1024,1280,1536,1920],L1=["webp","jpeg"],oM=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],Pz={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};A$=class A$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});function iX($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=O1,placeholder:_="none",formats:B=L1,widths:z=H1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:L}=$,F=$.class,O=$.style,{processedImage:V,variants:N,optimize:A=!0,isDev:R=!1}=Z;if(N&&N.length>0)return ZE($,N,V);if(R||!A)return YE($);return XE($)}function ZE($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:_="async",fetchpriority:B,objectFit:z,objectPosition:q,placeholder:j="none"}=$,H=$.class,L=$.style,F=V$(Z),O=F$(Z),V=typeof K==="object"?O$(K):K,N=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(N)A.push(`aspect-ratio: ${N}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(L)A.push(L);let R=A.length>0?` style="${A.join("; ")}"`:"",M=H?` class="${H}"`:"",E=U?"":` loading="${W}"`,I=` decoding="${_}"`,T=B?` fetchpriority="${B}"`:U?' fetchpriority="high"':"",S=["avif","webp","jpeg","png"],k=[];for(let l of S){let p=F.get(l);if(p&&p.length>0){let Q0=$6(p),X0=u1(l);k.push(` <source type="${X0}" srcset="${Q0}" sizes="${V}" />`)}}let C="",x="",g;if(j!=="none"&&Y?.placeholder){let l=`img-${Math.random().toString(36).slice(2,8)}`;if(C=`<div class="stx-image-wrapper" id="${l}">`,x="</div>",j==="blur")g=`
11175
+ `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function rM($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var J6;var X3=D(()=>{uX();uX();J6=class J6 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});import sM from"fs";import J3 from"path";import aM from"crypto";async function Q3(){if(Cz)return pX;Cz=!0;try{let $=await import("sharp");return pX=$.default||$,pX}catch{return null}}async function d1(){return await Q3()!==null}async function m1($,Z={}){let{widths:Y=H1,formats:X=L1,quality:J=O1,fit:Q="cover",placeholder:G="none",outputDir:K=".stx/images",baseUrl:W="/images"}=Z,U,_;if(typeof $==="string"){if(_=$,!await Bun.file($).exists())throw new A$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((N)=>Buffer.from(N))}else _="buffer-input",U=$;let B=aM.createHash("sha256").update(U).digest("hex").slice(0,12),z=await a5(U),{width:q,height:j}=z,H=q/j;await sM.promises.mkdir(K,{recursive:!0});let L=[],F=J3.basename(_,J3.extname(_)),O=Y.filter((N)=>N<=q);if(!O.includes(q)&&q<=Math.max(...Y))O.push(q);O.sort((N,A)=>N-A);for(let N of O){let A=Math.round(N/H);for(let R of X){let M=`${F}-${N}w-${B}.${R}`,E=J3.join(K,M),I=`${W}/${M}`,T=await eM(U,{width:N,height:A,format:R,quality:J,fit:Q});await Bun.write(E,T),L.push({path:E,url:I,width:N,height:A,format:R,size:T.length})}}let V;if(G!=="none")V=await $E(U,G);return{src:_,variants:L,placeholder:V,width:q,height:j,aspectRatio:H,hash:B}}async function a5($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await Q3();if(Y){let J=await Y(Z).metadata();return{width:J.width||0,height:J.height||0,format:J.format||"unknown",hasAlpha:J.hasAlpha}}return tM(Z)}function tM($){if($[0]===137&&$[1]===80&&$[2]===78&&$[3]===71){let Z=$.readUInt32BE(16),Y=$.readUInt32BE(20);return{width:Z,height:Y,format:"png",hasAlpha:!0}}if($[0]===255&&$[1]===216){let Z=2;while(Z<$.length){if($[Z]!==255)break;let Y=$[Z+1];if(Y>=192&&Y<=207&&Y!==196&&Y!==200&&Y!==204){let J=$.readUInt16BE(Z+5);return{width:$.readUInt16BE(Z+7),height:J,format:"jpeg",hasAlpha:!1}}let X=$.readUInt16BE(Z+2);Z+=2+X}}if($.toString("utf8",0,4)==="RIFF"&&$.toString("utf8",8,12)==="WEBP"){let Z=$.toString("utf8",12,16);if(Z==="VP8 "){let Y=$.readUInt16LE(26)&16383,X=$.readUInt16LE(28)&16383;return{width:Y,height:X,format:"webp",hasAlpha:!1}}if(Z==="VP8L"){let Y=$.readUInt32LE(21),X=(Y&16383)+1,J=(Y>>14&16383)+1;return{width:X,height:J,format:"webp",hasAlpha:!0}}}if($.toString("utf8",0,3)==="GIF"){let Z=$.readUInt16LE(6),Y=$.readUInt16LE(8);return{width:Z,height:Y,format:"gif",hasAlpha:!0}}throw new A$("Unable to parse image dimensions","PARSE_ERROR")}async function eM($,Z){let Y=await Q3();if(Y){let X=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":X=X.webp({quality:Z.quality});break;case"avif":X=X.avif({quality:Z.quality});break;case"jpeg":X=X.jpeg({quality:Z.quality});break;case"png":X=X.png({quality:Z.quality});break}return X.toBuffer()}return console.warn("sharp not available, returning original image without optimization"),$}async function $E($,Z){let Y=await Q3();if(Z==="blur"&&Y){let J=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),Q=await a5($);return`data:${Pz[Q.format]||"image/jpeg"};base64,${J}`}if(Y){let{dominant:X}=await Y($).resize(1,1).toBuffer().then(async(J)=>{let Q=await Y(J).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${X.r}, ${X.g}, ${X.b})`}return"rgb(128, 128, 128)"}function $4($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function O$($){if(!$||Object.keys($).length===0)return"100vw";return Object.entries($).sort((Y,X)=>{let J=Number.parseInt(Y[0].replace(/\D/g,""))||0;return(Number.parseInt(X[0].replace(/\D/g,""))||0)-J}).map(([Y,X])=>`(max-width: ${Y}) ${X}`).join(", ")+", 100vw"}function F$($){let Z=$.filter((X)=>X.format==="jpeg");if(Z.length===0)return $[Math.floor($.length/2)];let Y=Z.sort((X,J)=>X.width-J.width);return Y[Math.floor(Y.length/2)]}function V$($){let Z=new Map;for(let Y of $){let X=Z.get(Y.format)||[];X.push(Y),Z.set(Y.format,X)}return Z}function o5($){let Z=J3.extname($).toLowerCase();return oM.includes(Z)}function u1($){return Pz[$]||"application/octet-stream"}function G3($){return $.reduce((Z,Y)=>Z+Y.size,0)}function K3($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var H1,L1,O1=80,oM,Pz,pX=null,Cz=!1,A$;var t5=D(()=>{H1=[320,640,768,1024,1280,1536,1920],L1=["webp","jpeg"],oM=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],Pz={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};A$=class A$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});function iX($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=O1,placeholder:_="none",formats:B=L1,widths:z=H1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:L}=$,F=$.class,O=$.style,{processedImage:V,variants:N,optimize:A=!0,isDev:R=!1}=Z;if(N&&N.length>0)return ZE($,N,V);if(R||!A)return YE($);return XE($)}function ZE($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:_="async",fetchpriority:B,objectFit:z,objectPosition:q,placeholder:j="none"}=$,H=$.class,L=$.style,F=V$(Z),O=F$(Z),V=typeof K==="object"?O$(K):K,N=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(N)A.push(`aspect-ratio: ${N}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(L)A.push(L);let R=A.length>0?` style="${A.join("; ")}"`:"",M=H?` class="${H}"`:"",E=U?"":` loading="${W}"`,I=` decoding="${_}"`,T=B?` fetchpriority="${B}"`:U?' fetchpriority="high"':"",S=["avif","webp","jpeg","png"],k=[];for(let l of S){let p=F.get(l);if(p&&p.length>0){let Q0=$4(p),X0=u1(l);k.push(` <source type="${X0}" srcset="${Q0}" sizes="${V}" />`)}}let C="",x="",g;if(j!=="none"&&Y?.placeholder){let l=`img-${Math.random().toString(36).slice(2,8)}`;if(C=`<div class="stx-image-wrapper" id="${l}">`,x="</div>",j==="blur")g=`
11176
11176
  #${l} {
11177
11177
  position: relative;
11178
11178
  background-image: url('${Y.placeholder}');
@@ -11203,7 +11203,7 @@ ${k.join(`
11203
11203
  data-quality="${W}"
11204
11204
  data-formats="${U.join(",")}"
11205
11205
  data-widths="${_.join(",")}"
11206
- `.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${rX(Y)}"${N}${A}${V}${O}${R}${M}${E} ${T} />`}}function W3($){let Z=$.match(/<Image\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,W,U]=Q,_=K??W??U??!0;switch(G){case"src":X.src=String(_);break;case"alt":X.alt=String(_);break;case"width":X.width=Number(_)||_;break;case"height":X.height=Number(_)||_;break;case"sizes":X.sizes=String(_);break;case"loading":X.loading=_;break;case"priority":X.priority=_===!0||_==="true";break;case"quality":X.quality=Number(_);break;case"placeholder":X.placeholder=_;break;case"class":X.class=String(_);break;case"style":X.style=String(_);break;case"decoding":X.decoding=_;break;case"fetchpriority":X.fetchpriority=_;break;case"objectFit":X.objectFit=_;break;case"objectPosition":X.objectPosition=String(_);break}}if(!X.src||!X.alt)return null;return X}async function nX($,Z){let Y=/<Image\s+[^>]*?\/?>/g,X=[],J=[],Q=$,G,K=[];while((G=Y.exec($))!==null)K.push({match:G[0],index:G.index});for(let W=K.length-1;W>=0;W--){let{match:U}=K[W],_=W3(U);if(_){let B=await Z(_);if(Q=Q.replace(U,B.html),B.preloadLink)X.push(B.preloadLink);if(B.placeholderCss)J.push(B.placeholderCss)}}return{html:Q,preloadLinks:X,styles:J}}function rX($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var yz=D(()=>{t5()});function _3(){U3.clear()}async function JE($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(U3.has(Y))return U3.get(Y);try{let X=await m1($,Z);return U3.set(Y,X),X}catch{return null}}function B3(){return b0({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async($,Z,Y)=>{let{src:X,alt:J,options:Q}=QE($,Z,Y);if(!X)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:H1),formats:Q.formats||L1,quality:Q.quality||O1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await d1())return xz(X,J||"",Q);let W=await JE(X,G);if(!W)return xz(X,J||"",Q);return KE(W,J||"",Q)}})}function QE($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@image(")||J.startsWith("("))J=J.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=GE(J),G=Q[0]||"",K=Q[1]||"",W={};if(G&&!G.startsWith("/")&&!G.startsWith(".")&&!G.startsWith("http")){let U=Y[G];if(typeof U==="string")G=U}if(Q[2])try{if(typeof Q[2]==="string")W=JSON.parse(Q[2]);else W=Q[2]}catch{}return{src:G,alt:K,options:W}}function GE($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function xz($,Z,Y){let X=[`src="${Q4($)}"`];if(Z)X.push(`alt="${Q4(Z)}"`);if(Y.width)X.push(`width="${Y.width}"`);if(Y.height)X.push(`height="${Y.height}"`);if(Y.class)X.push(`class="${Q4(Y.class)}"`);if(Y.style)X.push(`style="${Q4(Y.style)}"`);if(Y.lazy!==!1)X.push('loading="lazy"');return X.push('decoding="async"'),`<img ${X.join(" ")} />`}function KE($,Z,Y){let{variants:X,placeholder:J,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let L of X){let F=W.get(L.format)||[];F.push(L),W.set(L.format,F)}let U=["avif","webp","jpeg","png"],_=[];for(let L of U){let F=W.get(L);if(F&&F.length>0){let O=$6(F),V=u1(L),N=Y.sizes||"100vw";_.push(` <source type="${V}" srcset="${Q4(O)}" sizes="${Q4(N)}" />`)}}let B=W.get("jpeg")||[],z=B.length>0?B[Math.floor(B.length/2)]:X[Math.floor(X.length/2)],q=[`src="${z?.url||$.src}"`,`alt="${Q4(Z)}"`];if(Y.width||Q)q.push(`width="${Y.width||Q}"`);if(Y.height||G)q.push(`height="${Y.height||G}"`);if(Y.class)q.push(`class="${Q4(Y.class)}"`);let j=[];if(K)j.push(`aspect-ratio: ${K.toFixed(4)}`);if(Y.style)j.push(Y.style);if(j.length>0)q.push(`style="${j.join("; ")}"`);if(Y.lazy!==!1&&!Y.priority)q.push('loading="lazy"');if(q.push('decoding="async"'),Y.priority)q.push('fetchpriority="high"');let H=`<picture>
11206
+ `.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${rX(Y)}"${N}${A}${V}${O}${R}${M}${E} ${T} />`}}function W3($){let Z=$.match(/<Image\s+([^>]*?)\/?>/);if(!Z)return null;let Y=Z[1],X={},J=/(\w+)(?:=(?:"([^"]*)"|'([^']*)'|(\{[^}]+\})))?/g,Q;while((Q=J.exec(Y))!==null){let[,G,K,W,U]=Q,_=K??W??U??!0;switch(G){case"src":X.src=String(_);break;case"alt":X.alt=String(_);break;case"width":X.width=Number(_)||_;break;case"height":X.height=Number(_)||_;break;case"sizes":X.sizes=String(_);break;case"loading":X.loading=_;break;case"priority":X.priority=_===!0||_==="true";break;case"quality":X.quality=Number(_);break;case"placeholder":X.placeholder=_;break;case"class":X.class=String(_);break;case"style":X.style=String(_);break;case"decoding":X.decoding=_;break;case"fetchpriority":X.fetchpriority=_;break;case"objectFit":X.objectFit=_;break;case"objectPosition":X.objectPosition=String(_);break}}if(!X.src||!X.alt)return null;return X}async function nX($,Z){let Y=/<Image\s+[^>]*?\/?>/g,X=[],J=[],Q=$,G,K=[];while((G=Y.exec($))!==null)K.push({match:G[0],index:G.index});for(let W=K.length-1;W>=0;W--){let{match:U}=K[W],_=W3(U);if(_){let B=await Z(_);if(Q=Q.replace(U,B.html),B.preloadLink)X.push(B.preloadLink);if(B.placeholderCss)J.push(B.placeholderCss)}}return{html:Q,preloadLinks:X,styles:J}}function rX($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var yz=D(()=>{t5()});function _3(){U3.clear()}async function JE($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(U3.has(Y))return U3.get(Y);try{let X=await m1($,Z);return U3.set(Y,X),X}catch{return null}}function B3(){return b0({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async($,Z,Y)=>{let{src:X,alt:J,options:Q}=QE($,Z,Y);if(!X)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:H1),formats:Q.formats||L1,quality:Q.quality||O1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await d1())return xz(X,J||"",Q);let W=await JE(X,G);if(!W)return xz(X,J||"",Q);return KE(W,J||"",Q)}})}function QE($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@image(")||J.startsWith("("))J=J.replace(/^@image\(/,"").replace(/^\(/,"").replace(/\)$/,"");let Q=GE(J),G=Q[0]||"",K=Q[1]||"",W={};if(G&&!G.startsWith("/")&&!G.startsWith(".")&&!G.startsWith("http")){let U=Y[G];if(typeof U==="string")G=U}if(Q[2])try{if(typeof Q[2]==="string")W=JSON.parse(Q[2]);else W=Q[2]}catch{}return{src:G,alt:K,options:W}}function GE($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let W=$[K],U=K>0?$[K-1]:"";if((W==='"'||W==="'")&&U!=="\\"){if(!X)X=!0,J=W;else if(W===J)X=!1,J="";else Y+=W;continue}if(!X){if(W==="{")Q++;if(W==="}")Q--;if(W==="[")G++;if(W==="]")G--;if(W===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=W}if(Y.trim())Z.push(Y.trim());return Z}function xz($,Z,Y){let X=[`src="${Q6($)}"`];if(Z)X.push(`alt="${Q6(Z)}"`);if(Y.width)X.push(`width="${Y.width}"`);if(Y.height)X.push(`height="${Y.height}"`);if(Y.class)X.push(`class="${Q6(Y.class)}"`);if(Y.style)X.push(`style="${Q6(Y.style)}"`);if(Y.lazy!==!1)X.push('loading="lazy"');return X.push('decoding="async"'),`<img ${X.join(" ")} />`}function KE($,Z,Y){let{variants:X,placeholder:J,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let L of X){let F=W.get(L.format)||[];F.push(L),W.set(L.format,F)}let U=["avif","webp","jpeg","png"],_=[];for(let L of U){let F=W.get(L);if(F&&F.length>0){let O=$4(F),V=u1(L),N=Y.sizes||"100vw";_.push(` <source type="${V}" srcset="${Q6(O)}" sizes="${Q6(N)}" />`)}}let B=W.get("jpeg")||[],z=B.length>0?B[Math.floor(B.length/2)]:X[Math.floor(X.length/2)],q=[`src="${z?.url||$.src}"`,`alt="${Q6(Z)}"`];if(Y.width||Q)q.push(`width="${Y.width||Q}"`);if(Y.height||G)q.push(`height="${Y.height||G}"`);if(Y.class)q.push(`class="${Q6(Y.class)}"`);let j=[];if(K)j.push(`aspect-ratio: ${K.toFixed(4)}`);if(Y.style)j.push(Y.style);if(j.length>0)q.push(`style="${j.join("; ")}"`);if(Y.lazy!==!1&&!Y.priority)q.push('loading="lazy"');if(q.push('decoding="async"'),Y.priority)q.push('fetchpriority="high"');let H=`<picture>
11207
11207
  `;if(H+=_.join(`
11208
11208
  `)+`
11209
11209
  `,H+=` <img ${q.join(" ")} />
@@ -11211,8 +11211,8 @@ ${k.join(`
11211
11211
  ${H}
11212
11212
  </div>`}else if(Y.placeholder==="color"){let F=J.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");H=`<div id="${L}" class="stx-image-placeholder" style="background-color: ${F};">
11213
11213
  ${H}
11214
- </div>`}}if(Y.priority&&z){let L=u1(z.format);H=`<link rel="preload" as="image" href="${Q4(z.url)}" type="${L}" />
11215
- `+H}return H}function Q4($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var U3,sX;var vz=D(()=>{I5();t5();U3=new Map;sX=B3()});import N$ from"fs";import z3 from"path";function aX($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:X="/images",formats:J=L1,widths:Q=H1,quality:G=O1,placeholder:K="none",concurrency:W=4,cache:U=!0,cacheDir:_=".stx/image-cache",referencedOnly:B=!1,verbose:z=!1}=$,q={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(j){if(!await d1()){console.warn("[stx-images] sharp not available, image optimization disabled");return}if(U)await N$.promises.mkdir(_,{recursive:!0});if(z)console.log("[stx-images] Plugin initialized"),console.log(` Input dirs: ${Z.join(", ")}`),console.log(` Output dir: ${Y}`),console.log(` Formats: ${J.join(", ")}`),console.log(` Widths: ${Q.join(", ")}`)},async buildStart(){q.imageReferences.clear(),q.processedImages.clear(),q.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(j,H){if(H.endsWith(".html")||H.endsWith(".stx")){let L=WE(j);for(let F of L)q.imageReferences.add(F)}if(j.includes("<Image")||j.includes("@image"))return await _E(j,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X,processedImages:q.processedImages});return j},async buildEnd(j){if(!await d1())return;await N$.promises.mkdir(Y,{recursive:!0});let L=[];for(let V of Z){if(!N$.existsSync(V))continue;let N=await gz(V);L.push(...N)}let F=B?L.filter((V)=>UE(V,q.imageReferences)):L;if(q.stats.totalImages=F.length,z)console.log(`[stx-images] Processing ${F.length} images...`);let O=fz(F,W);for(let V of O)await Promise.all(V.map(async(N)=>{try{let A=await m1(N,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X});q.processedImages.set(N,A),q.stats.optimizedImages++,q.stats.variants+=A.variants.length;let R=N$.statSync(N).size,M=G3(A.variants);if(q.stats.savedBytes+=Math.max(0,R-M/A.variants.length),z)console.log(` \u2713 ${z3.basename(N)} \u2192 ${A.variants.length} variants`)}catch(A){console.error(`[stx-images] Error processing ${N}:`,A)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${q.stats.optimizedImages}/${q.stats.totalImages}`),console.log(` Variants: ${q.stats.variants}`),q.stats.savedBytes>0)console.log(` Saved: ~${K3(q.stats.savedBytes)}`)}}}function WE($){let Z=[],Y=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);let J=/<Image[^>]+src=["']([^"']+)["']/gi;while((X=J.exec($))!==null)Z.push(X[1]);let Q=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((X=Q.exec($))!==null)Z.push(X[1]);let G=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((X=G.exec($))!==null)Z.push(X[1]);return Z}function UE($,Z){let Y=z3.basename($);for(let X of Z)if(X.endsWith(Y)||X.includes(Y))return!0;return!1}async function _E($,Z){return $}async function gz($){let Z=[];async function Y(X){let J=await N$.promises.readdir(X,{withFileTypes:!0});for(let Q of J){let G=z3.join(X,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&o5(G))Z.push(G)}}return await Y($),Z}function fz($,Z){let Y=[];for(let X=0;X<$.length;X+=Z)Y.push($.slice(X,X+Z));return Y}async function q3($,Z,Y={}){if(!await d1())throw Error("sharp is required for image optimization");return m1($,{...Y,outputDir:Z})}async function oX($,Z,Y={}){let{formats:X=L1,widths:J=H1,quality:Q=O1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await d1())throw Error("sharp is required for image optimization");await N$.promises.mkdir(Z,{recursive:!0});let _=await gz($),B=[],z={totalImages:_.length,optimizedImages:0,savedBytes:0,variants:0},q=fz(_,K);for(let j of q){let H=await Promise.all(j.map(async(L)=>{try{let F=await m1(L,{formats:X,widths:J,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(z.optimizedImages++,z.variants+=F.variants.length,W)console.log(` \u2713 ${z3.basename(L)}`);return F}catch(F){return console.error(`Error processing ${L}:`,F),null}}));B.push(...H.filter((L)=>L!==null))}return{processed:B,stats:z}}function j3($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function tX($,Z){let Y=j3($);await Bun.write(Z,JSON.stringify(Y,null,2))}var hz=D(()=>{t5()});var mz={};t(mz,{writeImageManifest:()=>tX,renderImageComponent:()=>iX,processImageComponents:()=>nX,processImage:()=>m1,parseImageComponent:()=>W3,optimizeImage:()=>q3,optimizeDirectory:()=>oX,isSharpAvailable:()=>d1,isImageFile:()=>o5,imageDirective:()=>sX,groupVariantsByFormat:()=>V$,getTotalSize:()=>G3,getMimeType:()=>u1,getImageMetadata:()=>a5,getFallbackVariant:()=>F$,generateSrcSet:()=>$6,generateSizes:()=>O$,generateImageManifest:()=>j3,formatSize:()=>K3,defaultImageConfig:()=>dz,createImagePlugin:()=>aX,createImageDirective:()=>B3,clearImageCache:()=>_3,ImageProcessingError:()=>A$,DEFAULT_WIDTHS:()=>H1,DEFAULT_QUALITY:()=>O1,DEFAULT_FORMATS:()=>L1});var dz;var H3=D(()=>{t5();yz();vz();hz();dz={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"}});function BE($){P0=$}function zE(){return P0}function qE(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:cz()}}function cz(){return{refs:new Map,effects:new Set,cleanups:[]}}function jE($){let Z=new Set,Y=new Set,X=$,J=Symbol("ref"),Q={get value(){if($1)Y.add($1);return X},set value(G){if(!Object.is(G,X)){let K=X;X=G;for(let W of Z)W(G,K);for(let W of Y)W()}},subscribe(G){return Z.add(G),()=>{Z.delete(G)}}};if(P0)P0.scope.refs.set(J,Q);return Q}function lz($){let Z=uz.get($);if(Z)return Z;let Y=new Map,X=(G)=>{let K=Y.get(G);if(K)for(let W of[...K])W()},J=(G,K)=>{if(!Y.has(G))Y.set(G,new Set);return Y.get(G).add(K),()=>{Y.get(G)?.delete(K)}},Q=new Proxy($,{get(G,K,W){let U=Reflect.get(G,K,W);if($1)J(K,$1);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let _=Object.getPrototypeOf(U);if(_===Object.prototype||_===null)return lz(U)}return U},set(G,K,W,U){let _=Reflect.get(G,K,U),B=Reflect.set(G,K,W,U);if(!Object.is(W,_))X(K);return B},deleteProperty(G,K){let W=Reflect.deleteProperty(G,K);return X(K),W}});return uz.set($,Q),Q}function HE($){let Z,Y=!0,X=new Set,J=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=$1;if($1=Q,Z=$(),$1=U,Y=!1,!Object.is(Z,W)){for(let _ of X)_(Z,W);for(let _ of J)_()}}},K=$1;return $1=Q,Z=$(),Y=!1,$1=K,{get value(){if($1)J.add($1);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return X.add(W),()=>{X.delete(W)}}}}function LE($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="post"}=Y,G,K,W=()=>{if(typeof $==="function")return $();return $.value},U=()=>{let B=W();if((J?JSON.stringify(B)!==JSON.stringify(G):!Object.is(B,G))||X)Z(B,G),G=J&&typeof B==="object"?JSON.parse(JSON.stringify(B)):B},_=(B)=>{if(Q==="sync")B();else if(Q==="pre")Promise.resolve().then(B);else requestAnimationFrame(()=>{requestAnimationFrame(B)})};if(typeof $==="function"){let B=setInterval(()=>{_(U)},16);K=()=>clearInterval(B)}else K=$.subscribe(()=>{_(U)});if(G=W(),X)_(U);if(P0)P0.scope.cleanups.push(()=>K?.());return()=>K?.()}function OE($,Z,Y={}){let X=[],J=$.map((Q)=>Q.value);for(let Q of $){let G=Q.subscribe(()=>{let K=$.map((W)=>W.value);Z(K,J),J=[...K]});X.push(G)}if(Y.immediate){let Q=$.map((G)=>G.value);Z(Q,J)}return()=>{for(let Q of X)Q()}}function FE($){let Z,Y=!1,X=()=>{if(Y)return;if(Z)Z();let J=$1;$1=X,Z=$(),$1=J};if(X(),P0)P0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function VE($){if(P0)P0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function AE($){if(P0)P0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function NE($){if(P0)P0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function RE($){if(P0)P0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function wE($){if(P0)P0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function ME($){if(P0)P0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function Z6($,Z){let Y=$.hooks[Z];for(let X of Y)await X()}async function EE($){await Z6($,"beforeMount"),$.isMounted=!0,await Z6($,"mounted")}async function TE($){if(!$.isMounted||$.isUnmounted)return;await Z6($,"beforeUpdate"),await Z6($,"updated")}async function IE($){if($.isUnmounted)return;await Z6($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await Z6($,"unmounted")}function DE(){return`
11214
+ </div>`}}if(Y.priority&&z){let L=u1(z.format);H=`<link rel="preload" as="image" href="${Q6(z.url)}" type="${L}" />
11215
+ `+H}return H}function Q6($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var U3,sX;var vz=D(()=>{I5();t5();U3=new Map;sX=B3()});import N$ from"fs";import z3 from"path";function aX($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:X="/images",formats:J=L1,widths:Q=H1,quality:G=O1,placeholder:K="none",concurrency:W=4,cache:U=!0,cacheDir:_=".stx/image-cache",referencedOnly:B=!1,verbose:z=!1}=$,q={imageReferences:new Set,processedImages:new Map,stats:{totalImages:0,optimizedImages:0,savedBytes:0,variants:0}};return{name:"stx-image-optimization",async setup(j){if(!await d1()){console.warn("[stx-images] sharp not available, image optimization disabled");return}if(U)await N$.promises.mkdir(_,{recursive:!0});if(z)console.log("[stx-images] Plugin initialized"),console.log(` Input dirs: ${Z.join(", ")}`),console.log(` Output dir: ${Y}`),console.log(` Formats: ${J.join(", ")}`),console.log(` Widths: ${Q.join(", ")}`)},async buildStart(){q.imageReferences.clear(),q.processedImages.clear(),q.stats={totalImages:0,optimizedImages:0,savedBytes:0,variants:0}},async transform(j,H){if(H.endsWith(".html")||H.endsWith(".stx")){let L=WE(j);for(let F of L)q.imageReferences.add(F)}if(j.includes("<Image")||j.includes("@image"))return await _E(j,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X,processedImages:q.processedImages});return j},async buildEnd(j){if(!await d1())return;await N$.promises.mkdir(Y,{recursive:!0});let L=[];for(let V of Z){if(!N$.existsSync(V))continue;let N=await gz(V);L.push(...N)}let F=B?L.filter((V)=>UE(V,q.imageReferences)):L;if(q.stats.totalImages=F.length,z)console.log(`[stx-images] Processing ${F.length} images...`);let O=fz(F,W);for(let V of O)await Promise.all(V.map(async(N)=>{try{let A=await m1(N,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X});q.processedImages.set(N,A),q.stats.optimizedImages++,q.stats.variants+=A.variants.length;let R=N$.statSync(N).size,M=G3(A.variants);if(q.stats.savedBytes+=Math.max(0,R-M/A.variants.length),z)console.log(` \u2713 ${z3.basename(N)} \u2192 ${A.variants.length} variants`)}catch(A){console.error(`[stx-images] Error processing ${N}:`,A)}}));if(console.log("[stx-images] Optimization complete:"),console.log(` Images: ${q.stats.optimizedImages}/${q.stats.totalImages}`),console.log(` Variants: ${q.stats.variants}`),q.stats.savedBytes>0)console.log(` Saved: ~${K3(q.stats.savedBytes)}`)}}}function WE($){let Z=[],Y=/src=["']([^"']+\.(jpg|jpeg|png|webp|avif|gif))["']/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);let J=/<Image[^>]+src=["']([^"']+)["']/gi;while((X=J.exec($))!==null)Z.push(X[1]);let Q=/@image\s*\(\s*['"]([^'"]+)['"]/gi;while((X=Q.exec($))!==null)Z.push(X[1]);let G=/background(?:-image)?:\s*url\(["']?([^"')]+\.(jpg|jpeg|png|webp|avif|gif))["']?\)/gi;while((X=G.exec($))!==null)Z.push(X[1]);return Z}function UE($,Z){let Y=z3.basename($);for(let X of Z)if(X.endsWith(Y)||X.includes(Y))return!0;return!1}async function _E($,Z){return $}async function gz($){let Z=[];async function Y(X){let J=await N$.promises.readdir(X,{withFileTypes:!0});for(let Q of J){let G=z3.join(X,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&o5(G))Z.push(G)}}return await Y($),Z}function fz($,Z){let Y=[];for(let X=0;X<$.length;X+=Z)Y.push($.slice(X,X+Z));return Y}async function q3($,Z,Y={}){if(!await d1())throw Error("sharp is required for image optimization");return m1($,{...Y,outputDir:Z})}async function oX($,Z,Y={}){let{formats:X=L1,widths:J=H1,quality:Q=O1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await d1())throw Error("sharp is required for image optimization");await N$.promises.mkdir(Z,{recursive:!0});let _=await gz($),B=[],z={totalImages:_.length,optimizedImages:0,savedBytes:0,variants:0},q=fz(_,K);for(let j of q){let H=await Promise.all(j.map(async(L)=>{try{let F=await m1(L,{formats:X,widths:J,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(z.optimizedImages++,z.variants+=F.variants.length,W)console.log(` \u2713 ${z3.basename(L)}`);return F}catch(F){return console.error(`Error processing ${L}:`,F),null}}));B.push(...H.filter((L)=>L!==null))}return{processed:B,stats:z}}function j3($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function tX($,Z){let Y=j3($);await Bun.write(Z,JSON.stringify(Y,null,2))}var hz=D(()=>{t5()});var mz={};t(mz,{writeImageManifest:()=>tX,renderImageComponent:()=>iX,processImageComponents:()=>nX,processImage:()=>m1,parseImageComponent:()=>W3,optimizeImage:()=>q3,optimizeDirectory:()=>oX,isSharpAvailable:()=>d1,isImageFile:()=>o5,imageDirective:()=>sX,groupVariantsByFormat:()=>V$,getTotalSize:()=>G3,getMimeType:()=>u1,getImageMetadata:()=>a5,getFallbackVariant:()=>F$,generateSrcSet:()=>$4,generateSizes:()=>O$,generateImageManifest:()=>j3,formatSize:()=>K3,defaultImageConfig:()=>dz,createImagePlugin:()=>aX,createImageDirective:()=>B3,clearImageCache:()=>_3,ImageProcessingError:()=>A$,DEFAULT_WIDTHS:()=>H1,DEFAULT_QUALITY:()=>O1,DEFAULT_FORMATS:()=>L1});var dz;var H3=D(()=>{t5();yz();vz();hz();dz={enabled:!0,widths:[320,640,768,1024,1280,1536,1920],formats:["webp","jpeg"],quality:80,devOptimize:!1,cacheDir:".stx/image-cache",placeholder:"none",inputDirs:["public","src/assets","assets"],outputDir:"dist/images",baseUrl:"/images"}});function BE($){P0=$}function zE(){return P0}function qE(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:cz()}}function cz(){return{refs:new Map,effects:new Set,cleanups:[]}}function jE($){let Z=new Set,Y=new Set,X=$,J=Symbol("ref"),Q={get value(){if($1)Y.add($1);return X},set value(G){if(!Object.is(G,X)){let K=X;X=G;for(let W of Z)W(G,K);for(let W of Y)W()}},subscribe(G){return Z.add(G),()=>{Z.delete(G)}}};if(P0)P0.scope.refs.set(J,Q);return Q}function lz($){let Z=uz.get($);if(Z)return Z;let Y=new Map,X=(G)=>{let K=Y.get(G);if(K)for(let W of[...K])W()},J=(G,K)=>{if(!Y.has(G))Y.set(G,new Set);return Y.get(G).add(K),()=>{Y.get(G)?.delete(K)}},Q=new Proxy($,{get(G,K,W){let U=Reflect.get(G,K,W);if($1)J(K,$1);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let _=Object.getPrototypeOf(U);if(_===Object.prototype||_===null)return lz(U)}return U},set(G,K,W,U){let _=Reflect.get(G,K,U),B=Reflect.set(G,K,W,U);if(!Object.is(W,_))X(K);return B},deleteProperty(G,K){let W=Reflect.deleteProperty(G,K);return X(K),W}});return uz.set($,Q),Q}function HE($){let Z,Y=!0,X=new Set,J=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=$1;if($1=Q,Z=$(),$1=U,Y=!1,!Object.is(Z,W)){for(let _ of X)_(Z,W);for(let _ of J)_()}}},K=$1;return $1=Q,Z=$(),Y=!1,$1=K,{get value(){if($1)J.add($1);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return X.add(W),()=>{X.delete(W)}}}}function LE($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="post"}=Y,G,K,W=()=>{if(typeof $==="function")return $();return $.value},U=()=>{let B=W();if((J?JSON.stringify(B)!==JSON.stringify(G):!Object.is(B,G))||X)Z(B,G),G=J&&typeof B==="object"?JSON.parse(JSON.stringify(B)):B},_=(B)=>{if(Q==="sync")B();else if(Q==="pre")Promise.resolve().then(B);else requestAnimationFrame(()=>{requestAnimationFrame(B)})};if(typeof $==="function"){let B=setInterval(()=>{_(U)},16);K=()=>clearInterval(B)}else K=$.subscribe(()=>{_(U)});if(G=W(),X)_(U);if(P0)P0.scope.cleanups.push(()=>K?.());return()=>K?.()}function OE($,Z,Y={}){let X=[],J=$.map((Q)=>Q.value);for(let Q of $){let G=Q.subscribe(()=>{let K=$.map((W)=>W.value);Z(K,J),J=[...K]});X.push(G)}if(Y.immediate){let Q=$.map((G)=>G.value);Z(Q,J)}return()=>{for(let Q of X)Q()}}function FE($){let Z,Y=!1,X=()=>{if(Y)return;if(Z)Z();let J=$1;$1=X,Z=$(),$1=J};if(X(),P0)P0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function VE($){if(P0)P0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function AE($){if(P0)P0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function NE($){if(P0)P0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function RE($){if(P0)P0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function wE($){if(P0)P0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function ME($){if(P0)P0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function Z4($,Z){let Y=$.hooks[Z];for(let X of Y)await X()}async function EE($){await Z4($,"beforeMount"),$.isMounted=!0,await Z4($,"mounted")}async function TE($){if(!$.isMounted||$.isUnmounted)return;await Z4($,"beforeUpdate"),await Z4($,"updated")}async function IE($){if($.isUnmounted)return;await Z4($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await Z4($,"unmounted")}function DE(){return`
11216
11216
  <script data-stx-client-runtime>
11217
11217
  (function() {
11218
11218
  'use strict';
@@ -11392,7 +11392,7 @@ ${H}
11392
11392
  </script>`}var P0=null,$1=null,uz;var pz=D(()=>{uz=new WeakMap});import{abortNavigation as kE,clearMiddleware as e5,createClientCookieManager as SE,createMiddlewareContext as $7,createRouteLocation as Z7,createServerCookieManager as bE,createStorageManager as CE,defineMiddleware as PE,getMiddleware as yE,getMiddlewareNames as Y7,hasMiddleware as xE,loadMiddlewareFromDirectory as X7,navigateTo as vE,registerMiddleware as gE,runMiddleware as J7}from"stx-router";var L3=()=>{};function R$($,Z){if(typeof window>"u")return Z;return window[$]??Z}function O3($,Z){if(typeof window>"u")return;window[$]=Z}function iz($){let Y=R$("__STX_STORES__",{})[$];if(!Y)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Y}function fE($){return iz($)}function hE($,Z=5000){return new Promise((Y,X)=>{let J=Date.now(),Q=()=>{let G=iz($);if(G)Y(G);else if(Date.now()-J>Z)X(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(Q)};Q()})}function nz(){return R$("__STX_ROUTE_PARAMS__",{})}function rz($){return nz()[$]}function dE($){let Z=rz($);if(Z===void 0)throw Error(`Route parameter "${$}" not found`);return Z}function sz(){return R$("__STX_MIDDLEWARE_STATE__",{})}function mE($){return sz()[$]}function uE(){if(typeof window>"u")return;if(!R$("__STX_STORES__",null))O3("__STX_STORES__",{})}function cE($,Z){let Y=R$("__STX_STORES__",{});Y[$]=Z,O3("__STX_STORES__",Y)}function lE(){return R$("__STX_STORE_STATE__",null)}function pE($){O3("__STX_ROUTE_PARAMS__",$)}function iE($){O3("__STX_MIDDLEWARE_STATE__",$)}function az(){return typeof window>"u"}function oz(){return typeof window<"u"}function nE($){if(oz())$()}function rE($){if(az())$()}async function ez($){try{let Z=await Bun.file($).text(),Y=sE(Z),X=aE(Z,$),J=oE(Z,Y),Q=tE(Z,Y);return{file:$,metrics:Y,issues:X,suggestions:J,performance:Q}}catch(Z){throw Error(`Failed to analyze template ${$}: ${Z instanceof Error?Z.message:String(Z)}`)}}function sE($){let Z=$.split(`
11393
11393
  `),Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),J=(Y?Y[1]:"").split(`
11394
11394
  `).length,Q={conditionals:($.match(/@(if|unless|elseif|else|endif|endunless)\b/g)||[]).length,loops:($.match(/@(foreach|for|endforeach|endfor|while|endwhile)\b/g)||[]).length,includes:($.match(/@(include|component|extends|section|yield)\b/g)||[]).length,custom:0,total:0};Q.total=Q.conditionals+Q.loops+Q.includes+Q.custom;let G=($.match(/\{\{[\s\S]*?\}\}/g)||[]).length,K=($.match(/\{!![\s\S]*?!!\}/g)||[]).length,W=($.match(/@(?:if|unless|elseif|foreach|for|while)\s*\([^)]+\)/g)||[]).length,U=G+K+W,_=($.match(/<[A-Z][^>]*>/g)||[]).length,B=($.match(/@(?:layout|extends)\(/g)||[]).length,z=0,q=0;for(let L of Z)if(/@(?:if|unless|foreach|for|while|section)\b/.test(L)&&!/@end/.test(L)&&!/@else/.test(L))q++,z=Math.max(z,q);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(L))q--;let j=z>=4?3:0,H=Math.min(10,Math.ceil(Q.total*0.5+U*0.1+_*0.3+(J>10?J*0.05:0)+j));return{lines:Z.length,characters:$.length,directives:Q,expressions:U,components:_,layouts:B,scriptLines:J,complexity:H}}function aE($,Z){let Y=[],X=tz($,"if","endif");if(X>0)Y.push({type:"error",category:"syntax",message:`Found ${X} unmatched @if directive(s)`,suggestion:"Ensure every @if has a corresponding @endif"});let J=tz($,"foreach","endforeach");if(J>0)Y.push({type:"error",category:"syntax",message:`Found ${J} unmatched @foreach directive(s)`,suggestion:"Ensure every @foreach has a corresponding @endforeach"});let Q=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(Q&&Q.length>0)Y.push({type:"warning",category:"performance",message:"Nested loops detected which may impact performance",suggestion:"Consider preprocessing data or using more efficient data structures"});let G=($.match(/\{!![\s\S]*?!!\}/g)||[]).length;if(G>0)Y.push({type:"warning",category:"security",message:`Found ${G} raw output expression(s) {!! !!}`,suggestion:"Ensure raw outputs are properly sanitized to prevent XSS"});let K=$.match(/<img[^>]*>/g);if(K){let _=K.filter((B)=>!B.includes("alt="));if(_.length>0)Y.push({type:"warning",category:"accessibility",message:`Found ${_.length} image(s) without alt attributes`,suggestion:"Add alt attributes to all images for screen reader accessibility"})}let W=$.split(`
11395
- `).filter((_)=>_.length>120);if(W.length>0)Y.push({type:"info",category:"maintainability",message:`Found ${W.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let U=($.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(U>3)Y.push({type:"info",category:"maintainability",message:`Found ${U} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Y}function oE($,Z){let Y=[];if(Z.complexity>7)Y.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(Z.complexity>5&&Z.directives.total>8)Y.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(Z.lines>100&&Z.components===0)Y.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(Z.expressions>20)Y.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let X=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(X&&X.length>0)Y.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(Z.directives.total===0&&Z.expressions<5)Y.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(Z.scriptLines>50)Y.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Y}function tE($,Z){let Y=1;if(Y+=Z.directives.conditionals*0.1,Y+=Z.directives.loops*0.5,Y+=Z.directives.includes*2,Y+=Z.expressions*0.05,Y+=Z.components*1,Z.scriptLines>10)Y+=Z.scriptLines*0.1;let X;if(Z.expressions===0&&Z.directives.total===0)X="high";else if(Z.expressions<5&&Z.directives.total<3)X="medium";else X="low";let J=[];if(Y>10)J.push("Consider optimizing template complexity");if(X==="low"&&Z.directives.total>5)J.push("Reduce dynamic content for better caching");if(Z.components===0&&Z.lines>40)J.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(Y*100)/100,complexityScore:Z.complexity,cacheability:X,recommendations:J}}function tz($,Z,Y){let X=$.replace(/<!--[\s\S]*?-->/g,""),J=(X.match(new RegExp(`@${Z}\\b`,"g"))||[]).length,Q=(X.match(new RegExp(`@${Y}\\b`,"g"))||[]).length;return Math.abs(J-Q)}async function eX($=["**/*.stx"],Z){let Y=[],X=[];for(let Q of $){let G=await Array.fromAsync(new Bun.Glob(Q).scan({cwd:Z||process.cwd(),onlyFiles:!0,absolute:!0}));X.push(...G.filter((K)=>K.endsWith(".stx")))}for(let Q of X)try{let G=await ez(Q);Y.push(G)}catch(G){console.warn(`Failed to analyze ${Q}:`,G)}let J=eE(Y);return{results:Y,summary:J}}function eE($){let Z=$.length,Y=$.reduce((U,_)=>U+_.metrics.lines,0),X=Z>0?$.reduce((U,_)=>U+_.metrics.complexity,0)/Z:0,J=$.reduce((U,_)=>U+_.issues.length,0),Q={};$.forEach((U)=>{U.issues.forEach((_)=>{Q[_.category]=(Q[_.category]||0)+1})});let G=Z>0?$.reduce((U,_)=>U+_.performance.estimatedRenderTime,0)/Z:0,K=Math.max(1,Math.min(10,Math.round(10-G/2-X/2))),W=[];if(X>6)W.push("Project has high average complexity. Consider refactoring complex templates.");if(J>Z*2)W.push("High number of issues detected. Run detailed analysis on individual files.");if(Q.security>0)W.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:Z,totalLines:Y,avgComplexity:Math.round(X*100)/100,totalIssues:J,issuesByCategory:Q,performanceScore:K,recommendations:W}}function $q($,Z,Y){let X={fullTag:Y,content:Z,attrs:$};if(/\bserver\b/.test($))return{...X,type:"server"};if(/\bdata-stx-scoped\b/.test($))return{...X,type:"client"};if($T.test(Z))return{...X,type:"signals"};if(/\bclient\b/.test($)||/\btype\s*=\s*["']module["']/.test($)||/\bsrc\s*=/.test($))return{...X,type:"client"};return{...X,type:"server"}}function $J($){let Z=[],Y=[],X=[],J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let G=$q(Q[1],Q[2],Q[0]);switch(G.type){case"signals":Z.push(G);break;case"client":Y.push(G);break;case"server":X.push(G);break}}return{signals:Z,client:Y,server:X}}var $T;var ZJ=D(()=>{$T=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/});import Zq from"fs";import YJ from"path";function ZT(){if(Q7!==null)return Q7;try{let{getRouterScript:$}=a("stx-router");Q7=`<script>${$()}</script>`}catch{Q7=""}return Q7}function XJ($,Z){if(Z===!1)return null;if(Z&&typeof Z==="string"){let X=YJ.resolve($,Z);if(Zq.existsSync(X))return X;return null}let Y=YJ.join($,"app.stx");if(Zq.existsSync(Y))return Y;return null}async function F3($,Z){try{let Y=await Bun.file($).text(),X=Y,J=Y.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(J)X=J[1].trim();let Q=$J(Y),G=[...Q.client.map((N)=>N.fullTag),...Q.signals.map((N)=>N.fullTag)],K=[],W=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,U;while((U=W.exec(Y))!==null)K.push(U[0]);let _=X;for(let N of Q.server)_=_.replace(N.fullTag,"");for(let N of Q.client)_=_.replace(N.fullTag,"");_=_.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let B="<!--__STX_PAGE_SLOT__-->";if(_=_.replace(/<slot\s*\/>/gi,B).replace(/<slot\s*>\s*<\/slot>/gi,B),!_.includes(B))return console.warn(`[stx] Shell ${$} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:z,extractVariables:q,defaultConfig:j,loadStxConfig:H}=await Promise.resolve().then(() => (g4(),X6)),L=await H(),F={__filename:$,__dirname:YJ.dirname($)};for(let N of G){let A=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!N.includes("client")&&!N.includes('type="module"'))await q(A[1],F,$)}let O=await z(_,F,$,{...j,...L,...Z},new Set),V=O.indexOf(B);if(V===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:O.substring(0,V),afterSlot:O.substring(V+B.length),filePath:$,shellScripts:G,shellStyles:K}}catch(Y){return console.error(`[stx] Error processing shell ${$}:`,Y),null}}function G7($,Z,Y){let X=Y||"stx App",J=ZT(),Q="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
11395
+ `).filter((_)=>_.length>120);if(W.length>0)Y.push({type:"info",category:"maintainability",message:`Found ${W.length} line(s) longer than 120 characters`,suggestion:"Consider breaking long lines for better readability"});let U=($.match(/style\s*=\s*["'][^"']*["']/g)||[]).length;if(U>3)Y.push({type:"info",category:"maintainability",message:`Found ${U} inline style attributes`,suggestion:"Consider moving styles to CSS classes for better maintainability"});return Y}function oE($,Z){let Y=[];if(Z.complexity>7)Y.push({type:"refactor",message:"Template complexity is high. Consider breaking into smaller components.",impact:"high",effort:"medium"});else if(Z.complexity>5&&Z.directives.total>8)Y.push({type:"optimization",message:"Template has moderate complexity. Consider component extraction for reusability.",impact:"medium",effort:"low"});if(Z.lines>100&&Z.components===0)Y.push({type:"refactor",message:"Large template with no components. Consider extracting reusable parts into components.",impact:"medium",effort:"medium"});if(Z.expressions>20)Y.push({type:"optimization",message:"Many template expressions detected. Consider preprocessing some data in the script section.",impact:"medium",effort:"low"});let X=$.match(/@foreach[\s\S]*?@foreach[\s\S]*?@endforeach[\s\S]*?@endforeach/g);if(X&&X.length>0)Y.push({type:"optimization",message:"Nested loops detected. Consider preprocessing data or optimizing data structures.",impact:"high",effort:"medium"});if(Z.directives.total===0&&Z.expressions<5)Y.push({type:"optimization",message:"Template appears static. Consider enabling aggressive caching.",impact:"high",effort:"low"});if(Z.scriptLines>50)Y.push({type:"refactor",message:"Large script section. Consider moving complex logic to external modules.",impact:"medium",effort:"medium"});return Y}function tE($,Z){let Y=1;if(Y+=Z.directives.conditionals*0.1,Y+=Z.directives.loops*0.5,Y+=Z.directives.includes*2,Y+=Z.expressions*0.05,Y+=Z.components*1,Z.scriptLines>10)Y+=Z.scriptLines*0.1;let X;if(Z.expressions===0&&Z.directives.total===0)X="high";else if(Z.expressions<5&&Z.directives.total<3)X="medium";else X="low";let J=[];if(Y>10)J.push("Consider optimizing template complexity");if(X==="low"&&Z.directives.total>5)J.push("Reduce dynamic content for better caching");if(Z.components===0&&Z.lines>40)J.push("Extract components to improve reusability and performance");return{estimatedRenderTime:Math.round(Y*100)/100,complexityScore:Z.complexity,cacheability:X,recommendations:J}}function tz($,Z,Y){let X=$.replace(/<!--[\s\S]*?-->/g,""),J=(X.match(new RegExp(`@${Z}\\b`,"g"))||[]).length,Q=(X.match(new RegExp(`@${Y}\\b`,"g"))||[]).length;return Math.abs(J-Q)}async function eX($=["**/*.stx"],Z){let Y=[],X=[];for(let Q of $){let G=await Array.fromAsync(new Bun.Glob(Q).scan({cwd:Z||process.cwd(),onlyFiles:!0,absolute:!0}));X.push(...G.filter((K)=>K.endsWith(".stx")))}for(let Q of X)try{let G=await ez(Q);Y.push(G)}catch(G){console.warn(`Failed to analyze ${Q}:`,G)}let J=eE(Y);return{results:Y,summary:J}}function eE($){let Z=$.length,Y=$.reduce((U,_)=>U+_.metrics.lines,0),X=Z>0?$.reduce((U,_)=>U+_.metrics.complexity,0)/Z:0,J=$.reduce((U,_)=>U+_.issues.length,0),Q={};$.forEach((U)=>{U.issues.forEach((_)=>{Q[_.category]=(Q[_.category]||0)+1})});let G=Z>0?$.reduce((U,_)=>U+_.performance.estimatedRenderTime,0)/Z:0,K=Math.max(1,Math.min(10,Math.round(10-G/2-X/2))),W=[];if(X>6)W.push("Project has high average complexity. Consider refactoring complex templates.");if(J>Z*2)W.push("High number of issues detected. Run detailed analysis on individual files.");if(Q.security>0)W.push("Security issues found. Review raw output usage and input sanitization.");return{totalFiles:Z,totalLines:Y,avgComplexity:Math.round(X*100)/100,totalIssues:J,issuesByCategory:Q,performanceScore:K,recommendations:W}}function $q($,Z,Y){let X={fullTag:Y,content:Z,attrs:$};if(/\bserver\b/.test($))return{...X,type:"server"};if(/\bdata-stx-scoped\b/.test($))return{...X,type:"client"};if($T.test(Z))return{...X,type:"signals"};if(/\bclient\b/.test($)||/\btype\s*=\s*["']module["']/.test($)||/\bsrc\s*=/.test($))return{...X,type:"client"};return{...X,type:"server"}}function $J($){let Z=[],Y=[],X=[],J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let G=$q(Q[1],Q[2],Q[0]);switch(G.type){case"signals":Z.push(G);break;case"client":Y.push(G);break;case"server":X.push(G);break}}return{signals:Z,client:Y,server:X}}var $T;var ZJ=D(()=>{$T=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/});import Zq from"fs";import YJ from"path";function ZT(){if(Q7!==null)return Q7;try{let{getRouterScript:$}=a("stx-router");Q7=`<script>${$()}</script>`}catch{Q7=""}return Q7}function XJ($,Z){if(Z===!1)return null;if(Z&&typeof Z==="string"){let X=YJ.resolve($,Z);if(Zq.existsSync(X))return X;return null}let Y=YJ.join($,"app.stx");if(Zq.existsSync(Y))return Y;return null}async function F3($,Z){try{let Y=await Bun.file($).text(),X=Y,J=Y.match(/<template\b[^>]*>([\s\S]*?)<\/template>/i);if(J)X=J[1].trim();let Q=$J(Y),G=[...Q.client.map((N)=>N.fullTag),...Q.signals.map((N)=>N.fullTag)],K=[],W=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,U;while((U=W.exec(Y))!==null)K.push(U[0]);let _=X;for(let N of Q.server)_=_.replace(N.fullTag,"");for(let N of Q.client)_=_.replace(N.fullTag,"");_=_.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let B="<!--__STX_PAGE_SLOT__-->";if(_=_.replace(/<slot\s*\/>/gi,B).replace(/<slot\s*>\s*<\/slot>/gi,B),!_.includes(B))return console.warn(`[stx] Shell ${$} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:z,extractVariables:q,defaultConfig:j,loadStxConfig:H}=await Promise.resolve().then(() => (g6(),X4)),L=await H(),F={__filename:$,__dirname:YJ.dirname($)};for(let N of G){let A=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!N.includes("client")&&!N.includes('type="module"'))await q(A[1],F,$)}let O=await z(_,F,$,{...j,...L,...Z},new Set),V=O.indexOf(B);if(V===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:O.substring(0,V),afterSlot:O.substring(V+B.length),filePath:$,shellScripts:G,shellStyles:K}}catch(Y){return console.error(`[stx] Error processing shell ${$}:`,Y),null}}function G7($,Z,Y){let X=Y||"stx App",J=ZT(),Q="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
11396
11396
  <html lang="en">
11397
11397
  <head>
11398
11398
  <meta charset="UTF-8">
@@ -11410,13 +11410,13 @@ ${$.shellScripts.filter((K)=>!K.includes("server")).join(`
11410
11410
  <script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>
11411
11411
  ${J}
11412
11412
  </body>
11413
- </html>`}function Y6($){let Z=$.trim();if(!/<!DOCTYPE\b/i.test(Z)&&!/^<html[\s>]/i.test(Z))return $;let Y=[],X=Z.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(X){let K=X[1],W=/<style\b[^>]*>[\s\S]*?<\/style>/gi,U;while((U=W.exec(K))!==null)Y.push(U[0])}let J=Z.match(/<body\b[^>]*>/i),Q=Z.lastIndexOf("</body>");if(J&&Q!==-1){let K=J.index+J[0].length,W=Z.slice(K,Q).trim();if(Y.length>0)return Y.join(`
11413
+ </html>`}function Y4($){let Z=$.trim();if(!/<!DOCTYPE\b/i.test(Z)&&!/^<html[\s>]/i.test(Z))return $;let Y=[],X=Z.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(X){let K=X[1],W=/<style\b[^>]*>[\s\S]*?<\/style>/gi,U;while((U=W.exec(K))!==null)Y.push(U[0])}let J=Z.match(/<body\b[^>]*>/i),Q=Z.lastIndexOf("</body>");if(J&&Q!==-1){let K=J.index+J[0].length,W=Z.slice(K,Q).trim();if(Y.length>0)return Y.join(`
11414
11414
  `)+`
11415
11415
  `+W;return W}let G=Z;if(G=G.replace(/<!DOCTYPE\b[^>]*>/i,""),G=G.replace(/<html\b[^>]*>/i,""),G=G.replace(/<\/html\s*>/i,""),X)G=G.replace(/<head\b[^>]*>[\s\S]*?<\/head>/i,Y.join(`
11416
- `));return G=G.replace(/<body\b[^>]*>/i,""),G=G.replace(/<\/body\s*>/i,""),G.trim()}function JJ($){return $.headers.get("X-STX-Router")==="true"}function K7($,Z="main"){let Y=$.trim(),X=[],J=Y.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(J){let O=J[1],V=/<style\b[^>]*>[\s\S]*?<\/style>/gi,N;while((N=V.exec(O))!==null)X.push(N[0])}let Q=Z.replace(/^[.#]/,"").toLowerCase(),G=new RegExp(`<${Q}\\b[^>]*>`,"i"),K=Y.match(G);if(!K||K.index===void 0)return Y6($);let W=K.index+K[0].length,U=new RegExp(`<${Q}\\b[^>]*>`,"gi"),_=new RegExp(`</${Q}\\s*>`,"gi");U.lastIndex=W,_.lastIndex=W;let B=1,z=-1;while(B>0){let O=U.exec(Y),V=_.exec(Y);if(!V)break;if(O&&O.index<V.index)B++,_.lastIndex=O.index+O[0].length;else if(B--,z=V.index,B>0)U.lastIndex=V.index+V[0].length}if(z===-1)return Y6($);let q=Y.slice(W,z).trim(),j=[],H=Y.match(/<body\b[^>]*>/i),L=Y.lastIndexOf("</body>");if(H&&H.index!==void 0&&L!==-1){let V=[[H.index+H[0].length,K.index],[z+`</${Q}>`.length,L]],N=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[A,R]of V){if(A>=R)continue;let M=Y.slice(A,R),E;N.lastIndex=0;while((E=N.exec(M))!==null)j.push(E[0])}}let F=[];if(X.length>0)F.push(X.join(`
11416
+ `));return G=G.replace(/<body\b[^>]*>/i,""),G=G.replace(/<\/body\s*>/i,""),G.trim()}function JJ($){return $.headers.get("X-STX-Router")==="true"}function K7($,Z="main"){let Y=$.trim(),X=[],J=Y.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(J){let O=J[1],V=/<style\b[^>]*>[\s\S]*?<\/style>/gi,N;while((N=V.exec(O))!==null)X.push(N[0])}let Q=Z.replace(/^[.#]/,"").toLowerCase(),G=new RegExp(`<${Q}\\b[^>]*>`,"i"),K=Y.match(G);if(!K||K.index===void 0)return Y4($);let W=K.index+K[0].length,U=new RegExp(`<${Q}\\b[^>]*>`,"gi"),_=new RegExp(`</${Q}\\s*>`,"gi");U.lastIndex=W,_.lastIndex=W;let B=1,z=-1;while(B>0){let O=U.exec(Y),V=_.exec(Y);if(!V)break;if(O&&O.index<V.index)B++,_.lastIndex=O.index+O[0].length;else if(B--,z=V.index,B>0)U.lastIndex=V.index+V[0].length}if(z===-1)return Y4($);let q=Y.slice(W,z).trim(),j=[],H=Y.match(/<body\b[^>]*>/i),L=Y.lastIndexOf("</body>");if(H&&H.index!==void 0&&L!==-1){let V=[[H.index+H[0].length,K.index],[z+`</${Q}>`.length,L]],N=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[A,R]of V){if(A>=R)continue;let M=Y.slice(A,R),E;N.lastIndex=0;while((E=N.exec(M))!==null)j.push(E[0])}}let F=[];if(X.length>0)F.push(X.join(`
11417
11417
  `));if(j.length>0)F.push(j.join(`
11418
11418
  `));return F.push(q),F.join(`
11419
- `)}var Q7=null;var W7=D(()=>{ZJ()});import{matchRoute as YT,Router as XT}from"stx-router";import{findErrorPage as QJ,formatRoutes as GJ,generateRouteManifest as QT,generateRouteTypes as GT,matchRoute as V3}from"stx-router";function G4($,Z={}){return new XT($,Z).routes}function JT($,Z){let Y=YT($,Z);return Y?Y.params:null}var U7=()=>{};var _q={};t(_q,{generateStaticSite:()=>Qq,defineStaticPaths:()=>Wq,default:()=>FT,createMarkdownLoader:()=>Uq,createISRHandler:()=>Kq});import m0 from"fs";import N0 from"path";class Yq{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=N0.join(this.cacheDir,"build-cache.json");if(await Bun.file($).exists())try{let Z=JSON.parse(await Bun.file($).text());for(let[Y,X]of Object.entries(Z))this.cache.set(Y,X)}catch{}this.loaded=!0}async save(){await m0.promises.mkdir(this.cacheDir,{recursive:!0});let $=N0.join(this.cacheDir,"build-cache.json"),Z={};for(let[Y,X]of this.cache)Z[Y]=X;await Bun.write($,JSON.stringify(Z))}getHash($,Z){let Y=m0.statSync($),X=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(m0.existsSync(Q)){let G=m0.statSync(Q);X+=`:${Q}:${G.mtimeMs}`}let J=0;for(let Q=0;Q<X.length;Q++){let G=X.charCodeAt(Q);J=(J<<5)-J+G,J=J&J}return Math.abs(J).toString(36)}get($,Z,Y){let X=this.cache.get($);if(!X)return null;let J=this.getHash(Z,Y);if(X.hash!==J)return this.cache.delete($),null;return X.html}set($,Z,Y,X){let J=this.getHash(Z,Y);this.cache.set($,{hash:J,html:X,generatedAt:Date.now(),dependencies:Y})}}class Xq{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return N0.join(this.cacheDir,"isr",Z)}async get($){let Z=this.getFilePath($);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set($,Z){let Y=this.getFilePath($);await m0.promises.mkdir(N0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await m0.promises.unlink(Z)}async invalidatePattern($){let Z=N0.join(this.cacheDir,"isr");if(!m0.existsSync(Z))return;let Y=await m0.promises.readdir(Z);for(let X of Y){let J=X.replace(/_/g,"/").replace(".json","");if($.test(J))await m0.promises.unlink(N0.join(Z,X))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function KT($){try{let Y=(await Bun.file($).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return null;let X=Y[1];if(!X.includes("getStaticPaths"))return null;let J=X.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!J)return null;return await Function(`
11419
+ `)}var Q7=null;var W7=D(()=>{ZJ()});import{matchRoute as YT,Router as XT}from"stx-router";import{findErrorPage as QJ,formatRoutes as GJ,generateRouteManifest as QT,generateRouteTypes as GT,matchRoute as V3}from"stx-router";function G6($,Z={}){return new XT($,Z).routes}function JT($,Z){let Y=YT($,Z);return Y?Y.params:null}var U7=()=>{};var _q={};t(_q,{generateStaticSite:()=>Qq,defineStaticPaths:()=>Wq,default:()=>FT,createMarkdownLoader:()=>Uq,createISRHandler:()=>Kq});import m0 from"fs";import N0 from"path";class Yq{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=N0.join(this.cacheDir,"build-cache.json");if(await Bun.file($).exists())try{let Z=JSON.parse(await Bun.file($).text());for(let[Y,X]of Object.entries(Z))this.cache.set(Y,X)}catch{}this.loaded=!0}async save(){await m0.promises.mkdir(this.cacheDir,{recursive:!0});let $=N0.join(this.cacheDir,"build-cache.json"),Z={};for(let[Y,X]of this.cache)Z[Y]=X;await Bun.write($,JSON.stringify(Z))}getHash($,Z){let Y=m0.statSync($),X=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(m0.existsSync(Q)){let G=m0.statSync(Q);X+=`:${Q}:${G.mtimeMs}`}let J=0;for(let Q=0;Q<X.length;Q++){let G=X.charCodeAt(Q);J=(J<<5)-J+G,J=J&J}return Math.abs(J).toString(36)}get($,Z,Y){let X=this.cache.get($);if(!X)return null;let J=this.getHash(Z,Y);if(X.hash!==J)return this.cache.delete($),null;return X.html}set($,Z,Y,X){let J=this.getHash(Z,Y);this.cache.set($,{hash:J,html:X,generatedAt:Date.now(),dependencies:Y})}}class Xq{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return N0.join(this.cacheDir,"isr",Z)}async get($){let Z=this.getFilePath($);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set($,Z){let Y=this.getFilePath($);await m0.promises.mkdir(N0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await m0.promises.unlink(Z)}async invalidatePattern($){let Z=N0.join(this.cacheDir,"isr");if(!m0.existsSync(Z))return;let Y=await m0.promises.readdir(Z);for(let X of Y){let J=X.replace(/_/g,"/").replace(".json","");if($.test(J))await m0.promises.unlink(N0.join(Z,X))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function KT($){try{let Y=(await Bun.file($).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return null;let X=Y[1];if(!X.includes("getStaticPaths"))return null;let J=X.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!J)return null;return await Function(`
11420
11420
  return (async function getStaticPaths() {
11421
11421
  ${J[1]}
11422
11422
  })()
@@ -11456,7 +11456,7 @@ ${$.map((X)=>{let J=new URL(X.loc,Z).href,Q=` <url>
11456
11456
  ${Y.join(`
11457
11457
  `)}
11458
11458
  </channel>
11459
- </rss>`}async function Qq($={}){let Z=Date.now(),Y=await f0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&m0.existsSync(X.outputDir))await m0.promises.rm(X.outputDir,{recursive:!0});await m0.promises.mkdir(X.outputDir,{recursive:!0});let Q=new Yq(X.cacheDir);if(X.cache)await Q.load();try{let{preloadIconCollection:j}=await Promise.resolve().then(() => (F9(),vU));await j("lucide")}catch{}try{let{generateCrosswindCSS:j}=await Promise.resolve().then(() => (r1(),z8));await j('<div class="bg-black"></div>')}catch{}e5();let G=Y?.routeMiddleware?.dir||"middleware";await X7(process.cwd(),G);let K=Y7();if(K.length>0)console.log(`Loaded ${K.length} middleware: ${K.join(", ")}`);let W=Y?.routeMiddleware?.global||[],U=G4(".",{pagesDir:X.pagesDir});console.log(`Found ${U.length} routes`);let _=[];for(let j of U){let H=await WT(j);for(let L of H)_.push({route:j,url:L.url,params:L.params,props:L.props,revalidate:L.revalidate??X.revalidate})}J.totalPages=_.length,console.log(`Generating ${J.totalPages} pages...`);let B=[],z=[];for(let j=0;j<_.length;j+=X.concurrency)z.push(_.slice(j,j+X.concurrency));for(let j of z)await Promise.all(j.map(async(H)=>{let{route:L,url:F,params:O,props:V,revalidate:N}=H;try{await X.hooks.onPageStart?.(F);let A=await Bun.file(L.filePath).text(),R=HT(A),M=R?.middleware?Array.isArray(R.middleware)?R.middleware:[R.middleware]:[],E=[...W,...M];if(E.length>0){let x=Z7(F,O,R||{}),g=$7(x,null),P=await J7(E,g);if(P.redirect){let f=typeof P.redirect==="string"?P.redirect:P.redirect.path||P.redirect,h=LT(String(f),F),u=OT(F,X);await m0.promises.mkdir(N0.dirname(u),{recursive:!0}),await Bun.write(u,h),J.successCount++,J.pages.push({route:F,outputPath:u,size:Buffer.byteLength(h),cached:!1}),B.push({loc:F,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${F} \u2192 redirect to ${f}`);return}if(P.abort){let f=typeof P.abort==="string"?P.abort:P.abort?.error?.message||"aborted";console.warn(` \u21B3 ${F} \u2014 middleware aborted: ${f}`);return}}let I=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(I)try{if(!await Function("route",`
11459
+ </rss>`}async function Qq($={}){let Z=Date.now(),Y=await f0(),X={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0},J={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]};await X.hooks.onBuildStart?.();try{if(X.cleanOutput&&m0.existsSync(X.outputDir))await m0.promises.rm(X.outputDir,{recursive:!0});await m0.promises.mkdir(X.outputDir,{recursive:!0});let Q=new Yq(X.cacheDir);if(X.cache)await Q.load();try{let{preloadIconCollection:j}=await Promise.resolve().then(() => (F9(),vU));await j("lucide")}catch{}try{let{generateCrosswindCSS:j}=await Promise.resolve().then(() => (r1(),z8));await j('<div class="bg-black"></div>')}catch{}e5();let G=Y?.routeMiddleware?.dir||"middleware";await X7(process.cwd(),G);let K=Y7();if(K.length>0)console.log(`Loaded ${K.length} middleware: ${K.join(", ")}`);let W=Y?.routeMiddleware?.global||[],U=G6(".",{pagesDir:X.pagesDir});console.log(`Found ${U.length} routes`);let _=[];for(let j of U){let H=await WT(j);for(let L of H)_.push({route:j,url:L.url,params:L.params,props:L.props,revalidate:L.revalidate??X.revalidate})}J.totalPages=_.length,console.log(`Generating ${J.totalPages} pages...`);let B=[],z=[];for(let j=0;j<_.length;j+=X.concurrency)z.push(_.slice(j,j+X.concurrency));for(let j of z)await Promise.all(j.map(async(H)=>{let{route:L,url:F,params:O,props:V,revalidate:N}=H;try{await X.hooks.onPageStart?.(F);let A=await Bun.file(L.filePath).text(),R=HT(A),M=R?.middleware?Array.isArray(R.middleware)?R.middleware:[R.middleware]:[],E=[...W,...M];if(E.length>0){let x=Z7(F,O,R||{}),g=$7(x,null),P=await J7(E,g);if(P.redirect){let f=typeof P.redirect==="string"?P.redirect:P.redirect.path||P.redirect,h=LT(String(f),F),u=OT(F,X);await m0.promises.mkdir(N0.dirname(u),{recursive:!0}),await Bun.write(u,h),J.successCount++,J.pages.push({route:F,outputPath:u,size:Buffer.byteLength(h),cached:!1}),B.push({loc:F,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${F} \u2192 redirect to ${f}`);return}if(P.abort){let f=typeof P.abort==="string"?P.abort:P.abort?.error?.message||"aborted";console.warn(` \u21B3 ${F} \u2014 middleware aborted: ${f}`);return}}let I=A.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(I)try{if(!await Function("route",`
11460
11460
  const validate = ${I[1]};
11461
11461
  return validate(route);
11462
11462
  `)({params:O})){console.warn(`Validation failed for ${F}, skipping...`);return}}catch{}let T=null,S=!1;if(X.cache){if(T=Q.get(F,L.filePath,[]),T)S=!0,J.cachedCount++}if(!T){if(T=await Jq(L,O,V,X,Y),X.cache)Q.set(F,L.filePath,[],T)}let k;if(X.trailingSlash)k=N0.join(X.outputDir,F,"index.html");else k=F==="/"?N0.join(X.outputDir,"index.html"):N0.join(X.outputDir,`${F}.html`);await m0.promises.mkdir(N0.dirname(k),{recursive:!0}),await Bun.write(k,T),B.push({loc:F,lastmod:new Date().toISOString().split("T")[0],priority:F==="/"?1:0.8});let C={route:F,outputPath:k,size:Buffer.byteLength(T,"utf8"),cached:S};if(N!==!1)C.revalidateAt=Date.now()+N*1000;J.pages.push(C),J.successCount++,await X.hooks.onPageEnd?.(F,T)}catch(A){J.failedCount++,J.errors.push({route:F,error:A}),await X.hooks.onError?.(A,F),console.error(`Error generating ${F}:`,A)}}));if(X.cache)await Q.save();if(X.generate404){let j=N0.join(X.pagesDir,"404.stx");if(await Bun.file(j).exists()){let H=new Set,L={...Y,debug:!1,cache:!1},F=await J0(await Bun.file(j).text(),{},j,L,H);await Bun.write(N0.join(X.outputDir,"404.html"),F)}else await Bun.write(N0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
@@ -11487,7 +11487,7 @@ Build complete!
11487
11487
  Cached: ${J.cachedCount}
11488
11488
  Failed: ${J.failedCount}
11489
11489
  Time: ${J.buildTime}ms
11490
- `),J}async function Gq($,Z){let Y=await m0.promises.readdir($,{withFileTypes:!0});for(let X of Y){let J=N0.join($,X.name),Q=N0.join(Z,X.name);if(X.isDirectory())await m0.promises.mkdir(Q,{recursive:!0}),await Gq(J,Q);else await m0.promises.copyFile(J,Q)}}function Kq($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new Xq(Z),X=$.revalidate||3600;return{async get(J){let Q=await Y.get(J);if(!Q)return null;if(Date.now()>Q.revalidateAfter)this.revalidate(J).catch(console.error);return{html:Q.html,headers:{"Cache-Control":`public, max-age=${X}, stale-while-revalidate=${X*2}`,ETag:Q.etag,"X-ISR-Generated":new Date(Q.generatedAt).toISOString(),...Q.headers}}},async revalidate(J){let G=G4(".",{pagesDir:$.pagesDir||"pages"}).find((B)=>{return J.match(B.regex)!==null});if(!G){console.warn(`Route not found for revalidation: ${J}`);return}let K=J.match(G.regex),W={};if(K)G.params.forEach((B,z)=>{W[B]=K[z+1]});let U=await f0(),_=await Jq(G,W,{},$,U);await Y.set(J,{html:_,generatedAt:Date.now(),revalidateAfter:Date.now()+X*1000,etag:zT(_)}),console.log(`Revalidated: ${J}`)},async invalidate(J){if(typeof J==="string")await Y.invalidate(J);else await Y.invalidatePattern(J)}}}function Wq($){return async()=>{return{paths:await $(),fallback:!1}}}function Uq(){return{name:"markdown",extensions:[".md",".mdx"],async load($){let Z=await Bun.file($).text(),Y=Z.match(/^---\n([\s\S]*?)\n---/),X={},J=Z;if(Y){let U=Y[1];J=Z.slice(Y[0].length).trim();for(let _ of U.split(`
11490
+ `),J}async function Gq($,Z){let Y=await m0.promises.readdir($,{withFileTypes:!0});for(let X of Y){let J=N0.join($,X.name),Q=N0.join(Z,X.name);if(X.isDirectory())await m0.promises.mkdir(Q,{recursive:!0}),await Gq(J,Q);else await m0.promises.copyFile(J,Q)}}function Kq($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new Xq(Z),X=$.revalidate||3600;return{async get(J){let Q=await Y.get(J);if(!Q)return null;if(Date.now()>Q.revalidateAfter)this.revalidate(J).catch(console.error);return{html:Q.html,headers:{"Cache-Control":`public, max-age=${X}, stale-while-revalidate=${X*2}`,ETag:Q.etag,"X-ISR-Generated":new Date(Q.generatedAt).toISOString(),...Q.headers}}},async revalidate(J){let G=G6(".",{pagesDir:$.pagesDir||"pages"}).find((B)=>{return J.match(B.regex)!==null});if(!G){console.warn(`Route not found for revalidation: ${J}`);return}let K=J.match(G.regex),W={};if(K)G.params.forEach((B,z)=>{W[B]=K[z+1]});let U=await f0(),_=await Jq(G,W,{},$,U);await Y.set(J,{html:_,generatedAt:Date.now(),revalidateAfter:Date.now()+X*1000,etag:zT(_)}),console.log(`Revalidated: ${J}`)},async invalidate(J){if(typeof J==="string")await Y.invalidate(J);else await Y.invalidatePattern(J)}}}function Wq($){return async()=>{return{paths:await $(),fallback:!1}}}function Uq(){return{name:"markdown",extensions:[".md",".mdx"],async load($){let Z=await Bun.file($).text(),Y=Z.match(/^---\n([\s\S]*?)\n---/),X={},J=Z;if(Y){let U=Y[1];J=Z.slice(Y[0].length).trim();for(let _ of U.split(`
11491
11491
  `)){let B=_.indexOf(":");if(B>0){let z=_.slice(0,B).trim(),q=_.slice(B+1).trim();if(q==="true")q=!0;else if(q==="false")q=!1;else if(/^\d+$/.test(q))q=parseInt(q,10);else if(/^\d+\.\d+$/.test(q))q=parseFloat(q);else if(q.startsWith("[")&&q.endsWith("]"))q=q.slice(1,-1).split(",").map((j)=>j.trim().replace(/^['"]|['"]$/g,""));X[z]=q}}}let Q=J.replace(/^### (.*$)/gim,"<h3>$1</h3>").replace(/^## (.*$)/gim,"<h2>$1</h2>").replace(/^# (.*$)/gim,"<h1>$1</h1>").replace(/\*\*(.*)\*\*/gim,"<strong>$1</strong>").replace(/\*(.*)\*/gim,"<em>$1</em>").replace(/`([^`]+)`/gim,"<code>$1</code>").replace(/\[([^\]]+)\]\(([^)]+)\)/gim,'<a href="$2">$1</a>').replace(/\n/gim,"<br>"),G=[],K=/<h([1-6])>([^<]+)<\/h[1-6]>/gi,W;while((W=K.exec(Q))!==null){let U=parseInt(W[1],10),_=W[2],B=_.toLowerCase().replace(/[^a-z0-9]+/g,"-");G.push({id:B,text:_,level:U})}return{content:Q,data:X,toc:G}}}}function HT($){let Z=$.match(/definePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!Z)return null;try{return Function(`return ${Z[1]}`)()}catch{return null}}function LT($,Z){return`<!DOCTYPE html>
11492
11492
  <html>
11493
11493
  <head>
@@ -11500,7 +11500,7 @@ Build complete!
11500
11500
  <p>Redirecting to <a href="${$}">${$}</a>...</p>
11501
11501
  <script>window.location.replace('${$}')</script>
11502
11502
  </body>
11503
- </html>`}function OT($,Z){if($==="/"||$==="")return N0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return N0.join(Z.outputDir,Y,"index.html");return N0.join(Z.outputDir,`${Y}.html`)}var FT;var Bq=D(()=>{U7();J1();u0();r1();L3();FT={generateStaticSite:Qq,createISRHandler:Kq,defineStaticPaths:Wq,createMarkdownLoader:Uq}});import{createHash as VT}from"crypto";import{getRouterScript as AT}from"stx-router";function KJ($){return VT("sha256").update($).digest("hex").slice(0,8)}function WJ($=!1){let Z=$?s4():H5(),Y=KJ(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function UJ(){let $=AT(),Z=KJ($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function NT($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var _J=D(()=>{L5()});import zq from"path";import{createHash as RT}from"crypto";function wT($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function BJ($,Z,Y={}){let X=zq.resolve($),J=await Bun.file(X).text(),Q=RT("sha256").update(J).digest("hex").slice(0,16);LZ();let G={};try{G=await f0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let L=U[1];if(/\bserver\b/.test(L))K.push(U[2])}let{context:_}=wT({__filename:X,__dirname:zq.dirname(X)}),B=new Set,z={...Q1,...G,...Y,buildMode:"compile",strict:!1},q=await J0(J,_,X,z,B),j=Y6(q),H=OZ();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(B),contentHash:Q}}var zJ=D(()=>{J1();u0();l$();W7()});import qJ from"fs";import qq from"path";function jJ($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function HJ($,Z){let Y=qq.join(Z,"manifest.json");qJ.writeFileSync(Y,JSON.stringify($,null,2))}function LJ($){let Z=qq.join($,"manifest.json");if(!qJ.existsSync(Z))return null;try{let Y=qJ.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var A3=()=>{};var Hq={};t(Hq,{buildForProduction:()=>jq});import c1 from"fs";import s0 from"path";function ET($,Z){let Y=0,X=0;if(!c1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=c1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(MT.has(W.name))continue;let U=s0.join(Q,W.name),_=s0.join(G,W.name);if(W.isDirectory())c1.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(c1.existsSync(_))continue;c1.copyFileSync(U,_),Y++,X+=c1.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function jq($={}){let Z=Date.now(),Y=s0.resolve($.root||process.cwd()),X=s0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await f0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},_=J.router?.container||"main";if(c1.existsSync(X))c1.rmSync(X,{recursive:!0});let B=[s0.join(X,"public","__stx"),s0.join(X,"public","assets"),s0.join(X,"server","pages"),s0.join(X,"server","fragments")];for(let M of B)c1.mkdirSync(M,{recursive:!0});console.log("[stx build] Discovering routes...");let z=G4(Y),q=["components","layouts","partials"],j=z.filter((M)=>{return!q.some((E)=>M.pattern.startsWith(`/${E}/`)||M.pattern===`/${E}`)});console.log(`[stx build] Found ${j.length} page routes (${z.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=WJ($.debug),L=UJ();await Bun.write(s0.join(X,"public","__stx",H.filename),H.content),await Bun.write(s0.join(X,"public","__stx",L.filename),L.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],O=[];for(let M of j)try{let E=await BJ(M.filePath,M.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(E),E.html=E.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,L.filename),E.html=B5(E.html,U,{bodyScripts:[`<script src="/__stx/${L.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(E.html)){let C=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(C&&C[1]){let x=C[1];E.html=E.html.replace(" "+x,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${x}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await D0(E.html),E.fragment=K7(E.html,_);let T=M.pattern==="/"?"index":M.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),S=s0.join("server","pages",`${T}.compiled.json`),k=s0.join("server","fragments",`${T}.html`);await Bun.write(s0.join(X,S),JSON.stringify(E,null,2)),await Bun.write(s0.join(X,k),E.fragment),O.push({pattern:M.pattern,compiledPath:S,fragmentPath:k,isDynamic:E.hasServerScripts,hasParams:M.pattern.includes(":")||M.pattern.includes("[")}),console.log(`[stx build] \u2713 ${M.pattern}`)}catch(E){console.error(`[stx build] \u2717 ${M.pattern}:`,E instanceof Error?E.message:E)}let V=s0.resolve(Y,W);if(c1.existsSync(V)){let{copied:M,bytes:E}=ET(V,s0.join(X,"public"));if(M>0)console.log(`[stx build] Copied ${M} public asset${M===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${W}/`)}let N={runtime:H.filename,router:L.filename},A=jJ(O,N,X);HJ(A,X);let R=Date.now()-Z;return console.log(`
11503
+ </html>`}function OT($,Z){if($==="/"||$==="")return N0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return N0.join(Z.outputDir,Y,"index.html");return N0.join(Z.outputDir,`${Y}.html`)}var FT;var Bq=D(()=>{U7();J1();u0();r1();L3();FT={generateStaticSite:Qq,createISRHandler:Kq,defineStaticPaths:Wq,createMarkdownLoader:Uq}});import{createHash as VT}from"crypto";import{getRouterScript as AT}from"stx-router";function KJ($){return VT("sha256").update($).digest("hex").slice(0,8)}function WJ($=!1){let Z=$?s6():H5(),Y=KJ(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function UJ(){let $=AT(),Z=KJ($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function NT($){return{runtimeTag:$.runtime?`<script src="/__stx/${$.runtime.filename}"></script>`:"",routerTag:$.router?`<script src="/__stx/${$.router.filename}"></script>`:"",cssTag:$.css?`<link rel="stylesheet" href="/__stx/${$.css.filename}">`:""}}var _J=D(()=>{L5()});import zq from"path";import{createHash as RT}from"crypto";function wT($={}){let Z=new Set;return{context:new Proxy($,{get(X,J){if(J in X)return X[J];if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return},has(X,J){if(J in X)return!0;if(typeof J==="string"&&!J.startsWith("__"))Z.add(J);return!1}}),accessedKeys:Z}}async function BJ($,Z,Y={}){let X=zq.resolve($),J=await Bun.file(X).text(),Q=RT("sha256").update(J).digest("hex").slice(0,16);LZ();let G={};try{G=await f0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let L=U[1];if(/\bserver\b/.test(L))K.push(U[2])}let{context:_}=wT({__filename:X,__dirname:zq.dirname(X)}),B=new Set,z={...Q1,...G,...Y,buildMode:"compile",strict:!1},q=await J0(J,_,X,z,B),j=Y4(q),H=OZ();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(B),contentHash:Q}}var zJ=D(()=>{J1();u0();l$();W7()});import qJ from"fs";import qq from"path";function jJ($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function HJ($,Z){let Y=qq.join(Z,"manifest.json");qJ.writeFileSync(Y,JSON.stringify($,null,2))}function LJ($){let Z=qq.join($,"manifest.json");if(!qJ.existsSync(Z))return null;try{let Y=qJ.readFileSync(Z,"utf-8"),X=JSON.parse(Y);if(X.version!==1)return console.warn(`[stx] Manifest version mismatch: expected 1, got ${X.version}`),null;return X}catch(Y){return console.warn("[stx] Failed to load manifest:",Y),null}}var A3=()=>{};var Hq={};t(Hq,{buildForProduction:()=>jq});import c1 from"fs";import s0 from"path";function ET($,Z){let Y=0,X=0;if(!c1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=c1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(MT.has(W.name))continue;let U=s0.join(Q,W.name),_=s0.join(G,W.name);if(W.isDirectory())c1.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(c1.existsSync(_))continue;c1.copyFileSync(U,_),Y++,X+=c1.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function jq($={}){let Z=Date.now(),Y=s0.resolve($.root||process.cwd()),X=s0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await f0()}catch{}let Q=$.componentsDir??J.componentsDir??"components",G=$.partialsDir??J.partialsDir??"partials",K=$.layoutsDir??J.layoutsDir??"layouts",W=$.publicDir??J.publicDir??"public",U=J.app?.head||{},_=J.router?.container||"main";if(c1.existsSync(X))c1.rmSync(X,{recursive:!0});let B=[s0.join(X,"public","__stx"),s0.join(X,"public","assets"),s0.join(X,"server","pages"),s0.join(X,"server","fragments")];for(let M of B)c1.mkdirSync(M,{recursive:!0});console.log("[stx build] Discovering routes...");let z=G6(Y),q=["components","layouts","partials"],j=z.filter((M)=>{return!q.some((E)=>M.pattern.startsWith(`/${E}/`)||M.pattern===`/${E}`)});console.log(`[stx build] Found ${j.length} page routes (${z.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=WJ($.debug),L=UJ();await Bun.write(s0.join(X,"public","__stx",H.filename),H.content),await Bun.write(s0.join(X,"public","__stx",L.filename),L.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],O=[];for(let M of j)try{let E=await BJ(M.filePath,M.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(E),E.html=E.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,L.filename),E.html=B5(E.html,U,{bodyScripts:[`<script src="/__stx/${L.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(E.html)){let C=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(C&&C[1]){let x=C[1];E.html=E.html.replace(" "+x,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${x}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await D0(E.html),E.fragment=K7(E.html,_);let T=M.pattern==="/"?"index":M.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),S=s0.join("server","pages",`${T}.compiled.json`),k=s0.join("server","fragments",`${T}.html`);await Bun.write(s0.join(X,S),JSON.stringify(E,null,2)),await Bun.write(s0.join(X,k),E.fragment),O.push({pattern:M.pattern,compiledPath:S,fragmentPath:k,isDynamic:E.hasServerScripts,hasParams:M.pattern.includes(":")||M.pattern.includes("[")}),console.log(`[stx build] \u2713 ${M.pattern}`)}catch(E){console.error(`[stx build] \u2717 ${M.pattern}:`,E instanceof Error?E.message:E)}let V=s0.resolve(Y,W);if(c1.existsSync(V)){let{copied:M,bytes:E}=ET(V,s0.join(X,"public"));if(M>0)console.log(`[stx build] Copied ${M} public asset${M===1?"":"s"} (${(E/1024).toFixed(1)}KB) from ${W}/`)}let N={runtime:H.filename,router:L.filename},A=jJ(O,N,X);HJ(A,X);let R=Date.now()-Z;return console.log(`
11504
11504
  [stx build] Done in ${R}ms \u2014 ${F.length} pages compiled`),{pageCount:F.length,assets:N,outputDir:X,duration:R}}var MT;var OJ=D(()=>{U7();_J();zJ();A3();W7();r1();u0();MT=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var Oq={};t(Oq,{buildApp:()=>Lq});import TT from"path";async function Lq($={}){let Z=performance.now(),Y=$.root||process.cwd(),X=await f0(),J=X.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${J.toUpperCase()}${X.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(J==="ssg"){let{generateStaticSite:W}=await Promise.resolve().then(() => (Bq(),_q));Q=await W({pagesDir:TT.join(X.root||".",X.pagesDir||X.build?.pagesDir||"pages"),publicDir:X.publicDir||X.build?.publicDir||"public",outputDir:X.build?.outputDir||"dist",generate404:X.build?.generate404??!0,minify:X.build?.minify??!0,cleanOutput:X.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:W}=await Promise.resolve().then(() => (OJ(),Hq));G=await W({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-Z);return{mode:J,ssg:Q,ssr:G,duration:K}}var FJ=D(()=>{u0()});import N3 from"path";async function DT($){let Z=performance.now(),Y=await f0(),X=$||Y.root||process.cwd(),J=[Y.build?.pagesDir||Y.pagesDir||"pages",Y.componentsDir||"components",Y.layoutsDir||"layouts",Y.partialsDir||"partials"].map((K)=>N3.resolve(X,K)),Q=[],G=0;for(let K of J){let W=await Vq(K);for(let U of W){G++;let _=await Bun.file(U).text();if(Fq.test(_))Q.push(N3.relative(X,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-Z)}}async function kT($){let Z=await f0(),Y=$||Z.root||process.cwd(),X=N3.resolve(Y,Z.componentsDir||"components"),J=[],Q=await Vq(X);for(let G of Q){let K=await Bun.file(G).text(),W=Fq.test(K),U=IT.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let _=N3.relative(Y,G);J.push({file:_,message:`Component "${_}" has both <script server> and <script client>. `+"Components should be server OR client \u2014 compose them via props/slots."})}}return J}async function Vq($){let Z=[];try{let Y=new Bun.Glob("**/*.stx");for await(let X of Y.scan({cwd:$,absolute:!0}))Z.push(X)}catch{}return Z}var Fq,IT;var Aq=D(()=>{u0();Fq=/<script\b[^>]*\bserver\b/i,IT=/<script\b[^>]*\bclient\b/i});function VJ($){let Z=new Map,Y=/@(\w+)/g,X,J=1,Q=0;while((X=Y.exec($))!==null){let G=X[1],K=$.slice(Q,X.index);J+=(K.match(/\n/g)||[]).length,Q=X.index;let W=X.index-$.lastIndexOf(`
11505
11505
  `,X.index-1);if(Rq.includes(G)){let U=Z.get(G);if(U)U.count++,U.locations.push({line:J,column:W});else Z.set(G,{name:G,count:1,locations:[{line:J,column:W}]})}}return Array.from(Z.values())}function wq($,Z=[]){let Y=VJ($),X=new Set(Y.map((J)=>J.name));for(let J of Z)X.add(J);for(let J of Array.from(X))if(!J.startsWith("end"))X.add(`end${J}`);return Rq.filter((J)=>!X.has(J))}function Mq($){let Z=[],Y={conditionals:["if","else","elseif","endif","unless","endunless","switch","case","default","endswitch","isset","endisset"],loops:["for","endfor","foreach","endforeach","forelse","endforelse","while","endwhile","break","continue","empty"],includes:["include","includeIf","includeWhen","includeFirst","once","endonce","extends","section","endsection","yield","parent","push","endpush","prepend","endprepend","stack"],components:["component","endcomponent","slot","endslot","props"],auth:["auth","endauth","guest","endguest","can","endcan","cannot","endcannot","role","endrole","hasRole","endhasRole","hasAnyRole","endhasAnyRole"],forms:["csrf","method","error","enderror","old","input","textarea","select","checkbox","radio","file"],i18n:["translate","lang","choice"],seo:["meta","title","seo","jsonld","canonical","robots","sitemap"]},X=new Set;for(let Q of $)for(let[G,K]of Object.entries(Y))if(K.includes(Q)){X.add(G);break}for(let Q of X)Z.push(`import { process${bT(Q)} } from './${Q}'`);let J=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
11506
11506
  `);return`// Tree-shaken directive bundle
@@ -12113,39 +12113,39 @@ const features = [
12113
12113
  })();
12114
12114
  </script>
12115
12115
  </body>
12116
- </html>`}var _I;var CJ=D(()=>{_I={basic:{description:"Simple page with script, style, and template sections"},component:{description:"Reusable component with props and slots"},layout:{description:"Layout template with sections and yields"},blog:{description:"Blog post with frontmatter-style variables"},api:{description:"API endpoint template with JSON response"},app:{description:"Full app with stores and components"}}});var Hj={};t(Hj,{startInteractive:()=>jj});import q7 from"fs";import f4 from"path";import*as qj from"readline";function LI($,Z){let Y=$.split(" "),X=Y[0];if(Y.length===1)return Object.keys(J6).filter((J)=>J.startsWith(X));if(["render","cat","load","cd"].includes(X)){let J=Y.slice(1).join(" "),Q=f4.dirname(J)||".",G=f4.basename(J),K=f4.resolve(Z.cwd,Q);if(q7.existsSync(K)&&q7.statSync(K).isDirectory())try{return q7.readdirSync(K).filter((U)=>U.startsWith(G)).map((U)=>`${X} ${Q==="."?"":`${Q}/`}${U}`)}catch{return[]}}if(["unset","eval","set"].includes(X)){let J=Y[1]||"";return Object.keys(Z.context).filter((Q)=>Q.startsWith(J)).map((Q)=>`${X} ${Q}`)}return[]}async function jj($={}){let Z={context:$.context||{},cwd:$.cwd||process.cwd(),history:[],running:!0,lastResult:null},Y=qj.createInterface({input:process.stdin,output:process.stdout,completer:(J)=>{return[LI(J,Z),J]},historySize:$.maxHistory||100});console.log(`
12116
+ </html>`}var _I;var CJ=D(()=>{_I={basic:{description:"Simple page with script, style, and template sections"},component:{description:"Reusable component with props and slots"},layout:{description:"Layout template with sections and yields"},blog:{description:"Blog post with frontmatter-style variables"},api:{description:"API endpoint template with JSON response"},app:{description:"Full app with stores and components"}}});var Hj={};t(Hj,{startInteractive:()=>jj});import q7 from"fs";import f6 from"path";import*as qj from"readline";function LI($,Z){let Y=$.split(" "),X=Y[0];if(Y.length===1)return Object.keys(J4).filter((J)=>J.startsWith(X));if(["render","cat","load","cd"].includes(X)){let J=Y.slice(1).join(" "),Q=f6.dirname(J)||".",G=f6.basename(J),K=f6.resolve(Z.cwd,Q);if(q7.existsSync(K)&&q7.statSync(K).isDirectory())try{return q7.readdirSync(K).filter((U)=>U.startsWith(G)).map((U)=>`${X} ${Q==="."?"":`${Q}/`}${U}`)}catch{return[]}}if(["unset","eval","set"].includes(X)){let J=Y[1]||"";return Object.keys(Z.context).filter((Q)=>Q.startsWith(J)).map((Q)=>`${X} ${Q}`)}return[]}async function jj($={}){let Z={context:$.context||{},cwd:$.cwd||process.cwd(),history:[],running:!0,lastResult:null},Y=qj.createInterface({input:process.stdin,output:process.stdout,completer:(J)=>{return[LI(J,Z),J]},historySize:$.maxHistory||100});console.log(`
12117
12117
  ${y.bold}${y.blue}stx Interactive Mode${y.reset}
12118
12118
  ${y.dim}Type 'help' for available commands, 'exit' to quit${y.reset}
12119
- `);let X=()=>{let J=Z.cwd.replace(process.env.HOME||"","~");Y.question(`${y.cyan}stx${y.reset} ${y.dim}${J}${y.reset} ${y.green}>${y.reset} `,async(Q)=>{let G=Q.trim();if(!G){if(Z.running)X();return}Z.history.push(G);let K=G.match(/(?:[^\s"]|"[^"]*")+/g)||[],W=K[0]?.toLowerCase(),U=K.slice(1).map((_)=>_.replace(/^"|"$/g,""));if(W&&J6[W])try{await J6[W].handler(U,Z)}catch(_){console.log(`${y.red}Error:${y.reset}`,_)}else if(W)if(G.includes("{{")||G.includes("}}"))try{let _=await A1(G,Z.context,"eval");console.log(`${y.green}\u2192${y.reset} ${_}`)}catch{console.log(`${y.red}Unknown command: ${W}${y.reset}`),console.log(`${y.dim}Type 'help' for available commands${y.reset}`)}else console.log(`${y.red}Unknown command: ${W}${y.reset}`),console.log(`${y.dim}Type 'help' for available commands${y.reset}`);if(Z.running)X();else Y.close()})};Y.on("SIGINT",()=>{console.log(`
12120
- ${y.dim}(Use 'exit' to quit)${y.reset}`),X()}),X()}var y,J6;var PJ=D(()=>{r0();J1();y={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},J6={help:{description:"Show available commands",usage:"help [command]",handler:async($,Z)=>{if($[0]&&J6[$[0]]){let Y=J6[$[0]];console.log(`
12119
+ `);let X=()=>{let J=Z.cwd.replace(process.env.HOME||"","~");Y.question(`${y.cyan}stx${y.reset} ${y.dim}${J}${y.reset} ${y.green}>${y.reset} `,async(Q)=>{let G=Q.trim();if(!G){if(Z.running)X();return}Z.history.push(G);let K=G.match(/(?:[^\s"]|"[^"]*")+/g)||[],W=K[0]?.toLowerCase(),U=K.slice(1).map((_)=>_.replace(/^"|"$/g,""));if(W&&J4[W])try{await J4[W].handler(U,Z)}catch(_){console.log(`${y.red}Error:${y.reset}`,_)}else if(W)if(G.includes("{{")||G.includes("}}"))try{let _=await A1(G,Z.context,"eval");console.log(`${y.green}\u2192${y.reset} ${_}`)}catch{console.log(`${y.red}Unknown command: ${W}${y.reset}`),console.log(`${y.dim}Type 'help' for available commands${y.reset}`)}else console.log(`${y.red}Unknown command: ${W}${y.reset}`),console.log(`${y.dim}Type 'help' for available commands${y.reset}`);if(Z.running)X();else Y.close()})};Y.on("SIGINT",()=>{console.log(`
12120
+ ${y.dim}(Use 'exit' to quit)${y.reset}`),X()}),X()}var y,J4;var PJ=D(()=>{r0();J1();y={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m"},J4={help:{description:"Show available commands",usage:"help [command]",handler:async($,Z)=>{if($[0]&&J4[$[0]]){let Y=J4[$[0]];console.log(`
12121
12121
  ${y.bold}${$[0]}${y.reset} - ${Y.description}`),console.log(` Usage: ${y.cyan}${Y.usage}${y.reset}
12122
12122
  `)}else{console.log(`
12123
12123
  ${y.bold}Available Commands:${y.reset}
12124
- `);for(let[Y,X]of Object.entries(J6))console.log(` ${y.cyan}${Y.padEnd(12)}${y.reset} ${X.description}`);console.log(`
12124
+ `);for(let[Y,X]of Object.entries(J4))console.log(` ${y.cyan}${Y.padEnd(12)}${y.reset} ${X.description}`);console.log(`
12125
12125
  ${y.dim}Type 'help <command>' for more details${y.reset}
12126
- `)}}},render:{description:"Render a template file",usage:"render <file> [--raw]",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a file to render${y.reset}`);return}let Y=f4.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${y.red}Error: File not found: ${Y}${y.reset}`);return}try{let X=await Bun.file(Y).text(),J=$.includes("--raw");console.log(`
12126
+ `)}}},render:{description:"Render a template file",usage:"render <file> [--raw]",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a file to render${y.reset}`);return}let Y=f6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${y.red}Error: File not found: ${Y}${y.reset}`);return}try{let X=await Bun.file(Y).text(),J=$.includes("--raw");console.log(`
12127
12127
  ${y.dim}Rendering ${Y}...${y.reset}
12128
12128
  `);let Q=await J0(X,Z.context,Y,{},new Set);if(Z.lastResult=Q,J)console.log(Q);else Q.split(`
12129
12129
  `).forEach((K,W)=>{let U=String(W+1).padStart(3," ");console.log(`${y.dim}${U}${y.reset} ${K}`)});console.log()}catch(X){console.log(`${y.red}Error rendering template:${y.reset}`,X)}}},eval:{description:"Evaluate an expression",usage:"eval <expression>",handler:async($,Z)=>{if(!$.length){console.log(`${y.red}Error: Please provide an expression to evaluate${y.reset}`);return}let Y=$.join(" ");try{let X=`{{ ${Y} }}`,Q=(await A1(X,Z.context,"eval")).trim();Z.lastResult=Q,console.log(`${y.green}\u2192${y.reset} ${Q}`)}catch(X){console.log(`${y.red}Error:${y.reset}`,X)}}},set:{description:"Set a context variable",usage:"set <key> <value>",handler:async($,Z)=>{if($.length<2){console.log(`${y.red}Error: Usage: set <key> <value>${y.reset}`);return}let Y=$[0],X=$.slice(1).join(" "),J;try{J=JSON.parse(X)}catch{J=X}Z.context[Y]=J,console.log(`${y.green}\u2713${y.reset} ${Y} = ${JSON.stringify(J)}`)}},unset:{description:"Remove a context variable",usage:"unset <key>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a variable to remove${y.reset}`);return}if($[0]in Z.context)delete Z.context[$[0]],console.log(`${y.green}\u2713${y.reset} Removed ${$[0]}`);else console.log(`${y.yellow}Variable not found: ${$[0]}${y.reset}`)}},context:{description:"Show current context variables",usage:"context",handler:async($,Z)=>{let Y=Object.keys(Z.context);if(Y.length===0){console.log(`${y.dim}Context is empty${y.reset}`);return}console.log(`
12130
12130
  ${y.bold}Context Variables:${y.reset}
12131
- `);for(let X of Y){let J=Z.context[X],Q=Array.isArray(J)?"array":typeof J,G=JSON.stringify(J).slice(0,50);console.log(` ${y.cyan}${X}${y.reset} ${y.dim}(${Q})${y.reset}: ${G}${G.length>=50?"...":""}`)}console.log()}},clear:{description:"Clear context or screen",usage:"clear [context|screen]",handler:async($,Z)=>{if($[0]==="context"||!$[0])Z.context={},console.log(`${y.green}\u2713${y.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.cyan}${Z.cwd}${y.reset}`);return}let Y=f4.resolve(Z.cwd,$[0]);if(!q7.existsSync(Y)){console.log(`${y.red}Error: Directory not found: ${Y}${y.reset}`);return}if(!q7.statSync(Y).isDirectory()){console.log(`${y.red}Error: Not a directory: ${Y}${y.reset}`);return}Z.cwd=Y,console.log(`${y.green}\u2713${y.reset} ${Y}`)}},ls:{description:"List files in current directory",usage:"ls [pattern]",handler:async($,Z)=>{let Y=$[0]||"*",X=new Bun.Glob(Y),J=[];for await(let W of X.scan({cwd:Z.cwd,onlyFiles:!1}))J.push(W);if(J.length===0){console.log(`${y.dim}No files found${y.reset}`);return}J.sort();let Q=J.filter((W)=>W.endsWith(".stx")),G=J.filter((W)=>W.endsWith(".md")),K=J.filter((W)=>!W.endsWith(".stx")&&!W.endsWith(".md"));if(Q.length>0)console.log(`
12131
+ `);for(let X of Y){let J=Z.context[X],Q=Array.isArray(J)?"array":typeof J,G=JSON.stringify(J).slice(0,50);console.log(` ${y.cyan}${X}${y.reset} ${y.dim}(${Q})${y.reset}: ${G}${G.length>=50?"...":""}`)}console.log()}},clear:{description:"Clear context or screen",usage:"clear [context|screen]",handler:async($,Z)=>{if($[0]==="context"||!$[0])Z.context={},console.log(`${y.green}\u2713${y.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.cyan}${Z.cwd}${y.reset}`);return}let Y=f6.resolve(Z.cwd,$[0]);if(!q7.existsSync(Y)){console.log(`${y.red}Error: Directory not found: ${Y}${y.reset}`);return}if(!q7.statSync(Y).isDirectory()){console.log(`${y.red}Error: Not a directory: ${Y}${y.reset}`);return}Z.cwd=Y,console.log(`${y.green}\u2713${y.reset} ${Y}`)}},ls:{description:"List files in current directory",usage:"ls [pattern]",handler:async($,Z)=>{let Y=$[0]||"*",X=new Bun.Glob(Y),J=[];for await(let W of X.scan({cwd:Z.cwd,onlyFiles:!1}))J.push(W);if(J.length===0){console.log(`${y.dim}No files found${y.reset}`);return}J.sort();let Q=J.filter((W)=>W.endsWith(".stx")),G=J.filter((W)=>W.endsWith(".md")),K=J.filter((W)=>!W.endsWith(".stx")&&!W.endsWith(".md"));if(Q.length>0)console.log(`
12132
12132
  ${y.bold}Templates:${y.reset}`),Q.forEach((W)=>console.log(` ${y.green}${W}${y.reset}`));if(G.length>0)console.log(`
12133
12133
  ${y.bold}Markdown:${y.reset}`),G.forEach((W)=>console.log(` ${y.blue}${W}${y.reset}`));if(K.length>0)console.log(`
12134
- ${y.bold}Other:${y.reset}`),K.forEach((W)=>console.log(` ${y.dim}${W}${y.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a file${y.reset}`);return}let Y=f4.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${y.red}Error: File not found: ${Y}${y.reset}`);return}let J=(await Bun.file(Y).text()).split(`
12135
- `);console.log(),J.forEach((Q,G)=>{let K=String(G+1).padStart(3," ");console.log(`${y.dim}${K}${y.reset} ${Q}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a JSON file${y.reset}`);return}let Y=f4.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${y.red}Error: File not found: ${Y}${y.reset}`);return}try{let X=await Bun.file(Y).text(),J=JSON.parse(X);Z.context={...Z.context,...J},console.log(`${y.green}\u2713${y.reset} Loaded ${Object.keys(J).length} variables from ${$[0]}`)}catch(X){console.log(`${y.red}Error parsing JSON:${y.reset}`,X)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a file name${y.reset}`);return}let Y=f4.resolve(Z.cwd,$[0]);try{await Bun.write(Y,JSON.stringify(Z.context,null,2)),console.log(`${y.green}\u2713${y.reset} Context saved to ${$[0]}`)}catch(X){console.log(`${y.red}Error saving file:${y.reset}`,X)}}},history:{description:"Show command history",usage:"history [count]",handler:async($,Z)=>{let Y=$[0]?Number.parseInt($[0],10):20,X=Z.history.slice(-Y);if(X.length===0){console.log(`${y.dim}No history${y.reset}`);return}console.log(),X.forEach((J,Q)=>{let G=String(Z.history.length-X.length+Q+1).padStart(3," ");console.log(`${y.dim}${G}${y.reset} ${J}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async($,Z)=>{Z.running=!1,console.log(`
12134
+ ${y.bold}Other:${y.reset}`),K.forEach((W)=>console.log(` ${y.dim}${W}${y.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a file${y.reset}`);return}let Y=f6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${y.red}Error: File not found: ${Y}${y.reset}`);return}let J=(await Bun.file(Y).text()).split(`
12135
+ `);console.log(),J.forEach((Q,G)=>{let K=String(G+1).padStart(3," ");console.log(`${y.dim}${K}${y.reset} ${Q}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a JSON file${y.reset}`);return}let Y=f6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${y.red}Error: File not found: ${Y}${y.reset}`);return}try{let X=await Bun.file(Y).text(),J=JSON.parse(X);Z.context={...Z.context,...J},console.log(`${y.green}\u2713${y.reset} Loaded ${Object.keys(J).length} variables from ${$[0]}`)}catch(X){console.log(`${y.red}Error parsing JSON:${y.reset}`,X)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${y.red}Error: Please specify a file name${y.reset}`);return}let Y=f6.resolve(Z.cwd,$[0]);try{await Bun.write(Y,JSON.stringify(Z.context,null,2)),console.log(`${y.green}\u2713${y.reset} Context saved to ${$[0]}`)}catch(X){console.log(`${y.red}Error saving file:${y.reset}`,X)}}},history:{description:"Show command history",usage:"history [count]",handler:async($,Z)=>{let Y=$[0]?Number.parseInt($[0],10):20,X=Z.history.slice(-Y);if(X.length===0){console.log(`${y.dim}No history${y.reset}`);return}console.log(),X.forEach((J,Q)=>{let G=String(Z.history.length-X.length+Q+1).padStart(3," ");console.log(`${y.dim}${G}${y.reset} ${J}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async($,Z)=>{Z.running=!1,console.log(`
12136
12136
  ${y.dim}Goodbye!${y.reset}
12137
- `)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async($,Z)=>J6.exit.handler($,Z)}}});import{createHash as OI}from"crypto";import{existsSync as j7,mkdirSync as FI,readFileSync as yJ,writeFileSync as VI,readdirSync as AI,statSync as NI}from"fs";import{basename as H7,dirname as K4,extname as L7,join as l1,relative as Lj}from"path";import{gzipSync as RI}from"zlib";class E3{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...Oj,...$}}async build(){this.startTime=Date.now(),this.outputs=[],this.chunks=[],this.assets=[],this.warnings=[],this.errors=[];try{this.ensureDir(this.config.outDir),await this.runPluginHook("setup"),await this.runPluginHook("buildStart");let $=this.collectEntries();for(let[Y,X]of $)await this.buildEntry(Y,X);if(this.config.css?.extract)await this.extractCss();if(await this.processAssets(),this.config.splitting)await this.performCodeSplitting();if(this.config.minify)await this.minifyOutputs();if(this.config.sourcemaps)await this.generateSourceMaps();if(await this.fingerprintAssets(),this.config.compression)await this.compressOutputs();if(this.config.analyze)await this.analyzeBundle();let Z=this.getResult();return await this.runPluginHook("buildEnd",Z),Z}catch($){return this.errors.push(String($)),this.getResult()}}collectEntries(){let $=new Map,{entry:Z}=this.config;if(typeof Z==="string")$.set("main",Z);else if(Array.isArray(Z))Z.forEach((Y,X)=>{let J=H7(Y,L7(Y));$.set(J,Y)});else if(typeof Z==="object")Object.entries(Z).forEach(([Y,X])=>{$.set(Y,X)});return $}async buildEntry($,Z){if(!await Bun.file(Z).exists()){this.errors.push(`Entry point not found: ${Z}`);return}let Y=await Bun.file(Z).text(),X=L7(Z),J=Y,Q="js";if(X===".stx"||X===".html")Q="html",J=await this.processTemplate(Y,Z);else if(X===".css")Q="css",J=await this.processCss(Y,Z);else if(X===".js"||X===".ts")Q="js",J=await this.processScript(Y,Z);J=await this.runPluginTransform(J,Z);let G=this.generateHash(J),K=this.getOutputName($,Q,G),W=l1(this.config.outDir,K);this.ensureDir(K4(W)),await Bun.write(W,J),this.outputs.push({path:W,type:Q,size:Buffer.byteLength(J),hash:G,sources:[Z],isEntry:!0})}resolveRelativePath($,Z){if(Z.startsWith("/"))return l1(K4($),"..",Z);return l1(K4($),Z)}async processTemplate($,Z){let Y=$,X=[],J=[];if(Y=Y.replace(/<script\b([^>]*)\bstx-inline\b([^>]*)(?:><\/script>|><\/script>|\/>)/gi,(Q,G,K)=>{let W=(G+K).match(/src=["']([^"']+)["']/);if(W){let U=this.resolveRelativePath(Z,W[1]);if(j7(U)){let _=yJ(U,"utf-8");X.push(`// Source: ${W[1]}
12137
+ `)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async($,Z)=>J4.exit.handler($,Z)}}});import{createHash as OI}from"crypto";import{existsSync as j7,mkdirSync as FI,readFileSync as yJ,writeFileSync as VI,readdirSync as AI,statSync as NI}from"fs";import{basename as H7,dirname as K6,extname as L7,join as l1,relative as Lj}from"path";import{gzipSync as RI}from"zlib";class E3{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...Oj,...$}}async build(){this.startTime=Date.now(),this.outputs=[],this.chunks=[],this.assets=[],this.warnings=[],this.errors=[];try{this.ensureDir(this.config.outDir),await this.runPluginHook("setup"),await this.runPluginHook("buildStart");let $=this.collectEntries();for(let[Y,X]of $)await this.buildEntry(Y,X);if(this.config.css?.extract)await this.extractCss();if(await this.processAssets(),this.config.splitting)await this.performCodeSplitting();if(this.config.minify)await this.minifyOutputs();if(this.config.sourcemaps)await this.generateSourceMaps();if(await this.fingerprintAssets(),this.config.compression)await this.compressOutputs();if(this.config.analyze)await this.analyzeBundle();let Z=this.getResult();return await this.runPluginHook("buildEnd",Z),Z}catch($){return this.errors.push(String($)),this.getResult()}}collectEntries(){let $=new Map,{entry:Z}=this.config;if(typeof Z==="string")$.set("main",Z);else if(Array.isArray(Z))Z.forEach((Y,X)=>{let J=H7(Y,L7(Y));$.set(J,Y)});else if(typeof Z==="object")Object.entries(Z).forEach(([Y,X])=>{$.set(Y,X)});return $}async buildEntry($,Z){if(!await Bun.file(Z).exists()){this.errors.push(`Entry point not found: ${Z}`);return}let Y=await Bun.file(Z).text(),X=L7(Z),J=Y,Q="js";if(X===".stx"||X===".html")Q="html",J=await this.processTemplate(Y,Z);else if(X===".css")Q="css",J=await this.processCss(Y,Z);else if(X===".js"||X===".ts")Q="js",J=await this.processScript(Y,Z);J=await this.runPluginTransform(J,Z);let G=this.generateHash(J),K=this.getOutputName($,Q,G),W=l1(this.config.outDir,K);this.ensureDir(K6(W)),await Bun.write(W,J),this.outputs.push({path:W,type:Q,size:Buffer.byteLength(J),hash:G,sources:[Z],isEntry:!0})}resolveRelativePath($,Z){if(Z.startsWith("/"))return l1(K6($),"..",Z);return l1(K6($),Z)}async processTemplate($,Z){let Y=$,X=[],J=[];if(Y=Y.replace(/<script\b([^>]*)\bstx-inline\b([^>]*)(?:><\/script>|><\/script>|\/>)/gi,(Q,G,K)=>{let W=(G+K).match(/src=["']([^"']+)["']/);if(W){let U=this.resolveRelativePath(Z,W[1]);if(j7(U)){let _=yJ(U,"utf-8");X.push(`// Source: ${W[1]}
12138
12138
  ${_}`)}else this.warnings.push(`External script not found: ${U}`)}return""}),Y=Y.replace(/<link\b([^>]*)\bstx-inline\b([^>]*)(?:\/>|>)/gi,(Q,G,K)=>{let W=(G+K).match(/href=["']([^"']+)["']/);if(W){let U=this.resolveRelativePath(Z,W[1]);if(j7(U)){let _=yJ(U,"utf-8");J.push(`/* Source: ${W[1]} */
12139
12139
  ${_}`)}else this.warnings.push(`External stylesheet not found: ${U}`)}return""}),Y=Y.replace(/<script\b(?![^>]*\bstx-inline\b)([^>]*)>([\s\S]*?)<\/script>/gi,(Q,G,K)=>{if(/\bsrc=/.test(G))return Q;if(K.trim())X.push(K);return""}),Y=Y.replace(/<style\b[^>]*>([\s\S]*?)<\/style>/gi,(Q,G)=>{if(G.trim())J.push(G);return""}),X.length>0){let Q=X.join(`
12140
12140
 
12141
- `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.js`,W=l1(this.config.outDir,K);this.ensureDir(K4(W)),await Bun.write(W,Q),this.outputs.push({path:W,type:"js",size:Buffer.byteLength(Q),hash:G,sources:[Z]});let U=Y.lastIndexOf("</body>");if(U!==-1)Y=Y.slice(0,U)+`<script src="${this.config.publicPath}${K}"></script>
12141
+ `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.js`,W=l1(this.config.outDir,K);this.ensureDir(K6(W)),await Bun.write(W,Q),this.outputs.push({path:W,type:"js",size:Buffer.byteLength(Q),hash:G,sources:[Z]});let U=Y.lastIndexOf("</body>");if(U!==-1)Y=Y.slice(0,U)+`<script src="${this.config.publicPath}${K}"></script>
12142
12142
  `+Y.slice(U)}if(J.length>0){let Q=J.join(`
12143
12143
 
12144
- `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.css`,W=l1(this.config.outDir,K);this.ensureDir(K4(W)),await Bun.write(W,Q),this.outputs.push({path:W,type:"css",size:Buffer.byteLength(Q),hash:G,sources:[Z]}),Y=Y.replace("</head>",`<link rel="stylesheet" href="${this.config.publicPath}${K}">
12144
+ `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.css`,W=l1(this.config.outDir,K);this.ensureDir(K6(W)),await Bun.write(W,Q),this.outputs.push({path:W,type:"css",size:Buffer.byteLength(Q),hash:G,sources:[Z]}),Y=Y.replace("</head>",`<link rel="stylesheet" href="${this.config.publicPath}${K}">
12145
12145
  </head>`)}return Y}async processCss($,Z){let Y=$;if(typeof this.config.minify==="object"&&this.config.minify.css)Y=this.minifyCss(Y);return Y}async processScript($,Z){let Y=$;if(this.config.define)for(let[X,J]of Object.entries(this.config.define))Y=Y.replace(new RegExp(X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),J);return Y}async extractCss(){let $=[];for(let Q of this.outputs)if(Q.type==="css"){let G=await Bun.file(Q.path).text();$.push(G)}if($.length===0)return;let Z=$.join(`
12146
- `),Y=this.generateHash(Z).slice(0,8),X=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Y),J=l1(this.config.outDir,X);this.ensureDir(K4(J)),await Bun.write(J,Z),this.outputs.push({path:J,type:"css",size:Buffer.byteLength(Z),hash:Y})}async processAssets(){let $=l1(K4(this.config.outDir),"public");if(!j7($))return;let Z=this.config.assets||{},Y=Z.include||[];this.walkDir($,(X)=>{let J=L7(X).slice(1).toLowerCase();if(!Y.includes(J))return;let Q=yJ(X),G=Q.length;if(Z.inlineLimit&&G<Z.inlineLimit)return;let K=Z.hash?this.generateHash(Q).slice(0,Z.hashLength||8):"",W=(Z.filename||"assets/[name].[hash][ext]").replace("[name]",H7(X,L7(X))).replace("[hash]",K).replace("[ext]",L7(X)),U=l1(this.config.outDir,W);this.ensureDir(K4(U)),VI(U,Q),this.assetHashes.set(X,W),this.assets.push({name:H7(X),file:W,size:G,source:X}),this.outputs.push({path:U,type:"asset",size:G,hash:K,sources:[X]})})}async performCodeSplitting(){if((typeof this.config.splitting==="object"?this.config.splitting:{}).vendor){let Z=[];this.chunks.push({name:"vendor",file:"assets/vendor.js",size:0,modules:Z,isVendor:!0,imports:[],dynamicImports:[]})}}async minifyOutputs(){let $=typeof this.config.minify==="object"?this.config.minify:{};for(let Z of this.outputs){let Y=await Bun.file(Z.path).text(),X=Y;if(Z.type==="js"&&$.js)X=this.minifyJs(Y);else if(Z.type==="css"&&$.css)X=this.minifyCss(Y);else if(Z.type==="html"&&$.html)X=this.minifyHtml(Y);if(X!==Y)await Bun.write(Z.path,X),Z.size=Buffer.byteLength(X)}}minifyJs($){let Z=typeof this.config.minify==="object"?this.config.minify:{},Y=$;if(Y=Y.replace(/\/\*[\s\S]*?\*\//g,""),Y=Y.replace(/\/\/.*$/gm,""),Z.dropConsole)Y=Y.replace(/console\.(log|debug|info|warn)\([^)]*\);?/g,"");if(Z.dropDebugger)Y=Y.replace(/debugger;?/g,"");return Y=Y.replace(/\s+/g," "),Y=Y.replace(/\s*([{};,:])\s*/g,"$1"),Y=Y.replace(/;\}/g,"}"),Y.trim()}minifyCss($){let Z=$;return Z=Z.replace(/\/\*[\s\S]*?\*\//g,""),Z=Z.replace(/\s+/g," "),Z=Z.replace(/\s*([{};:,>+~])\s*/g,"$1"),Z=Z.replace(/;}/g,"}"),Z=Z.replace(/[^{}]+\{\s*\}/g,""),Z.trim()}minifyHtml($){let Z=$;return Z=Z.replace(/<!--(?!\[if)[\s\S]*?-->/g,""),Z=Z.replace(/>\s+</g,"><"),Z=Z.replace(/\s+>/g,">"),Z=Z.replace(/<\s+/g,"<"),Z=Z.replace(/\s{2,}/g," "),Z.trim()}async generateSourceMaps(){if(!this.config.sourcemaps)return;for(let $ of this.outputs)if($.type==="js"||$.type==="css"){let Z=await Bun.file($.path).text(),Y=[];for(let G of $.sources||[])if(await Bun.file(G).exists())Y.push(await Bun.file(G).text());else Y.push(null);let X={version:3,file:H7($.path),sources:$.sources||[],sourcesContent:Y,mappings:"",names:[]},J=`${$.path}.map`;await Bun.write(J,JSON.stringify(X));let Q=this.config.sourcemaps==="inline"?`
12146
+ `),Y=this.generateHash(Z).slice(0,8),X=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Y),J=l1(this.config.outDir,X);this.ensureDir(K6(J)),await Bun.write(J,Z),this.outputs.push({path:J,type:"css",size:Buffer.byteLength(Z),hash:Y})}async processAssets(){let $=l1(K6(this.config.outDir),"public");if(!j7($))return;let Z=this.config.assets||{},Y=Z.include||[];this.walkDir($,(X)=>{let J=L7(X).slice(1).toLowerCase();if(!Y.includes(J))return;let Q=yJ(X),G=Q.length;if(Z.inlineLimit&&G<Z.inlineLimit)return;let K=Z.hash?this.generateHash(Q).slice(0,Z.hashLength||8):"",W=(Z.filename||"assets/[name].[hash][ext]").replace("[name]",H7(X,L7(X))).replace("[hash]",K).replace("[ext]",L7(X)),U=l1(this.config.outDir,W);this.ensureDir(K6(U)),VI(U,Q),this.assetHashes.set(X,W),this.assets.push({name:H7(X),file:W,size:G,source:X}),this.outputs.push({path:U,type:"asset",size:G,hash:K,sources:[X]})})}async performCodeSplitting(){if((typeof this.config.splitting==="object"?this.config.splitting:{}).vendor){let Z=[];this.chunks.push({name:"vendor",file:"assets/vendor.js",size:0,modules:Z,isVendor:!0,imports:[],dynamicImports:[]})}}async minifyOutputs(){let $=typeof this.config.minify==="object"?this.config.minify:{};for(let Z of this.outputs){let Y=await Bun.file(Z.path).text(),X=Y;if(Z.type==="js"&&$.js)X=this.minifyJs(Y);else if(Z.type==="css"&&$.css)X=this.minifyCss(Y);else if(Z.type==="html"&&$.html)X=this.minifyHtml(Y);if(X!==Y)await Bun.write(Z.path,X),Z.size=Buffer.byteLength(X)}}minifyJs($){let Z=typeof this.config.minify==="object"?this.config.minify:{},Y=$;if(Y=Y.replace(/\/\*[\s\S]*?\*\//g,""),Y=Y.replace(/\/\/.*$/gm,""),Z.dropConsole)Y=Y.replace(/console\.(log|debug|info|warn)\([^)]*\);?/g,"");if(Z.dropDebugger)Y=Y.replace(/debugger;?/g,"");return Y=Y.replace(/\s+/g," "),Y=Y.replace(/\s*([{};,:])\s*/g,"$1"),Y=Y.replace(/;\}/g,"}"),Y.trim()}minifyCss($){let Z=$;return Z=Z.replace(/\/\*[\s\S]*?\*\//g,""),Z=Z.replace(/\s+/g," "),Z=Z.replace(/\s*([{};:,>+~])\s*/g,"$1"),Z=Z.replace(/;}/g,"}"),Z=Z.replace(/[^{}]+\{\s*\}/g,""),Z.trim()}minifyHtml($){let Z=$;return Z=Z.replace(/<!--(?!\[if)[\s\S]*?-->/g,""),Z=Z.replace(/>\s+</g,"><"),Z=Z.replace(/\s+>/g,">"),Z=Z.replace(/<\s+/g,"<"),Z=Z.replace(/\s{2,}/g," "),Z.trim()}async generateSourceMaps(){if(!this.config.sourcemaps)return;for(let $ of this.outputs)if($.type==="js"||$.type==="css"){let Z=await Bun.file($.path).text(),Y=[];for(let G of $.sources||[])if(await Bun.file(G).exists())Y.push(await Bun.file(G).text());else Y.push(null);let X={version:3,file:H7($.path),sources:$.sources||[],sourcesContent:Y,mappings:"",names:[]},J=`${$.path}.map`;await Bun.write(J,JSON.stringify(X));let Q=this.config.sourcemaps==="inline"?`
12147
12147
  //# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(X)).toString("base64")}`:`
12148
- //# sourceMappingURL=${H7(J)}`;if(this.config.sourcemaps!=="hidden")await Bun.write($.path,Z+Q);this.outputs.push({path:J,type:"map",size:NI(J).size})}}async fingerprintAssets(){for(let $ of this.outputs)if($.type==="html"){let Z=await Bun.file($.path).text();for(let[Y,X]of this.assetHashes){let J=Lj(K4($.path),Y);Z=Z.replace(new RegExp(J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),`${this.config.publicPath}${X}`)}await Bun.write($.path,Z)}}async compressOutputs(){let $=this.config.compression||{},Z=$.threshold||1024;for(let Y of this.outputs){if(Y.type==="map")continue;if(Y.size<Z)continue;let X=Buffer.from(await Bun.file(Y.path).arrayBuffer());if($.gzip){let J=RI(X,{level:9}),Q=`${Y.path}.gz`;await Bun.write(Q,J),Y.gzipSize=J.length}if($.brotli)try{let{brotliCompressSync:J}=await import("zlib"),Q=J(X);await Bun.write(`${Y.path}.br`,Q)}catch{}}}async analyzeBundle(){let $=typeof this.config.analyze==="object"?this.config.analyze:{},Z=$.format||"text",Y={outputs:this.outputs.map((G)=>({path:Lj(this.config.outDir,G.path),type:G.type,size:G.size,gzipSize:G.gzipSize,sizeFormatted:this.formatSize(G.size),gzipSizeFormatted:G.gzipSize?this.formatSize(G.gzipSize):void 0})),chunks:this.chunks,assets:this.assets,totalSize:this.outputs.reduce((G,K)=>G+K.size,0),totalGzipSize:this.outputs.reduce((G,K)=>G+(K.gzipSize||0),0)},X;if(Z==="json")X=JSON.stringify(Y,null,2);else if(Z==="html")X=this.generateAnalysisHtml(Y);else X=this.generateAnalysisText(Y);let J=$.filename||`bundle-analysis.${Z==="html"?"html":Z==="json"?"json":"txt"}`,Q=l1(this.config.outDir,J);await Bun.write(Q,X),console.log(`
12148
+ //# sourceMappingURL=${H7(J)}`;if(this.config.sourcemaps!=="hidden")await Bun.write($.path,Z+Q);this.outputs.push({path:J,type:"map",size:NI(J).size})}}async fingerprintAssets(){for(let $ of this.outputs)if($.type==="html"){let Z=await Bun.file($.path).text();for(let[Y,X]of this.assetHashes){let J=Lj(K6($.path),Y);Z=Z.replace(new RegExp(J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g"),`${this.config.publicPath}${X}`)}await Bun.write($.path,Z)}}async compressOutputs(){let $=this.config.compression||{},Z=$.threshold||1024;for(let Y of this.outputs){if(Y.type==="map")continue;if(Y.size<Z)continue;let X=Buffer.from(await Bun.file(Y.path).arrayBuffer());if($.gzip){let J=RI(X,{level:9}),Q=`${Y.path}.gz`;await Bun.write(Q,J),Y.gzipSize=J.length}if($.brotli)try{let{brotliCompressSync:J}=await import("zlib"),Q=J(X);await Bun.write(`${Y.path}.br`,Q)}catch{}}}async analyzeBundle(){let $=typeof this.config.analyze==="object"?this.config.analyze:{},Z=$.format||"text",Y={outputs:this.outputs.map((G)=>({path:Lj(this.config.outDir,G.path),type:G.type,size:G.size,gzipSize:G.gzipSize,sizeFormatted:this.formatSize(G.size),gzipSizeFormatted:G.gzipSize?this.formatSize(G.gzipSize):void 0})),chunks:this.chunks,assets:this.assets,totalSize:this.outputs.reduce((G,K)=>G+K.size,0),totalGzipSize:this.outputs.reduce((G,K)=>G+(K.gzipSize||0),0)},X;if(Z==="json")X=JSON.stringify(Y,null,2);else if(Z==="html")X=this.generateAnalysisHtml(Y);else X=this.generateAnalysisText(Y);let J=$.filename||`bundle-analysis.${Z==="html"?"html":Z==="json"?"json":"txt"}`,Q=l1(this.config.outDir,J);await Bun.write(Q,X),console.log(`
12149
12149
  \uD83D\uDCCA Bundle Analysis`),console.log("\u2500".repeat(50));for(let G of Y.outputs){let K=G.gzipSizeFormatted?` (gzip: ${G.gzipSizeFormatted})`:"";console.log(` ${G.path}: ${G.sizeFormatted}${K}`)}console.log("\u2500".repeat(50)),console.log(` Total: ${this.formatSize(Y.totalSize)} (gzip: ${this.formatSize(Y.totalGzipSize)})`),console.log("")}generateAnalysisHtml($){return`<!DOCTYPE html>
12150
12150
  <html>
12151
12151
  <head>
@@ -12186,40 +12186,40 @@ ${_}`)}else this.warnings.push(`External stylesheet not found: ${U}`)}return""})
12186
12186
  </table>
12187
12187
  </body>
12188
12188
  </html>`}generateAnalysisText($){let Z=["Bundle Analysis","=".repeat(50),""];for(let Y of $.outputs)Z.push(`${Y.path}`),Z.push(` Size: ${Y.sizeFormatted}${Y.gzipSizeFormatted?` (gzip: ${Y.gzipSizeFormatted})`:""}`),Z.push("");return Z.push("=".repeat(50)),Z.push(`Total: ${this.formatSize($.totalSize)} (gzip: ${this.formatSize($.totalGzipSize)})`),Z.join(`
12189
- `)}async runPluginHook($,Z){if(!this.config.plugins)return;for(let Y of this.config.plugins){let X=Y[$];if(typeof X==="function")await X.call(Y,Z||this)}}async runPluginTransform($,Z){if(!this.config.plugins)return $;let Y=$;for(let X of this.config.plugins)if(X.transform){let J=await X.transform(Y,Z);if(J!=null)Y=J}return Y}generateHash($){return OI("sha256").update($).digest("hex")}getOutputName($,Z,Y){let X=Z==="html"?".html":Z==="css"?".css":Z==="js"?".js":"";return`${$}.${Y.slice(0,8)}${X}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!j7($))FI($,{recursive:!0})}walkDir($,Z){if(!j7($))return;let Y=AI($,{withFileTypes:!0});for(let X of Y){let J=l1($,X.name);if(X.isDirectory())this.walkDir(J,Z);else Z(J)}}getResult(){let $=Date.now()-this.startTime,Z=this.outputs.reduce((X,J)=>X+J.size,0),Y=this.outputs.reduce((X,J)=>X+(J.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:Z,gzipSize:Y,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function wI($){return new E3($).build()}function MI($){return new E3($)}function EI($){return{...Oj,...$}}var Oj;var Fj=D(()=>{Oj={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}}});async function xJ($,Z={}){if(!$.hasServerScripts&&!L6($.html))return $.html;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await V0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!L6($.html))return $.html;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=W1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?I0(String(G)):"")}catch{X.set(J,"")}return W8($.html,X)}async function TI($,Z={}){if(!$.hasServerScripts&&!L6($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await V0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!L6($.fragment))return $.fragment;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=W1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?I0(String(G)):"")}catch{X.set(J,"")}return W8($.fragment,X)}var vJ=D(()=>{w4();r0();l$()});var Nj={};t(Nj,{startProductionServer:()=>Aj});import Vj from"fs";import h4 from"path";var{serve:II}=globalThis.Bun;async function Aj($={}){let Z=h4.resolve($.outputDir||".output"),Y=$.port||3000,X=LJ(Z);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let J=new Map,Q=new Map;for(let U of X.routes)try{let _=h4.join(Z,U.compiledPath),B=JSON.parse(await Bun.file(_).text());J.set(U.pattern,B);let z=h4.join(Z,U.fragmentPath);if(await Bun.file(z).exists())Q.set(U.pattern,await Bun.file(z).text())}catch(_){console.warn(`[stx] Failed to load route ${U.pattern}:`,_)}let G=new Map,K=[];for(let U of X.routes)if(U.hasParams){let _=[],B=U.pattern.replace(/:([^/]+)/g,(z,q)=>{return _.push(q),"([^/]+)"});K.push({regex:new RegExp(`^${B}$`),route:U,paramNames:_})}else G.set(U.pattern,U);let W=II({port:Y,async fetch(U){let B=new URL(U.url).pathname;if($.onRequest){let L=await $.onRequest(U);if(L)return L}if($.apiRoutes?.[B])return $.apiRoutes[B](U);if((U.method==="GET"||U.method==="HEAD")&&B!=="/"){let L=h4.resolve(Z,"public"),F;try{F=decodeURIComponent(B)}catch{F=B}if(!F.includes("\x00")){let O=h4.resolve(L,`.${F}`);if(O===L||O.startsWith(`${L}${h4.sep}`))try{if(Vj.existsSync(O)&&Vj.statSync(O).isFile()){let N=h4.extname(O).toLowerCase(),A=DI[N]||"application/octet-stream",R=B.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(B);return new Response(Bun.file(O),{headers:{"Content-Type":A,"Cache-Control":R?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let z=U.headers.get("X-STX-Router")==="true",q=null,j={};if(q=G.get(B)||null,!q)for(let{regex:L,route:F,paramNames:O}of K){let V=B.match(L);if(V){q=F,O.forEach((N,A)=>{j[N]=V[A+1]});break}}if(!q){let L=G.get("/404")||null;if(L){let F=J.get(L.compiledPath);if(F)return new Response(F.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(z){let L=Q.get(q.pattern);if(L)return new Response(L,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-cache"}})}let H=J.get(q.pattern);if(!H)return new Response("Internal Server Error",{status:500});if(!H.hasServerScripts&&Object.keys(H.placeholders).length===0)return new Response(H.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let L=await xJ(H,{params:j,request:U});return new Response(L,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(L){return console.error(`[stx] Hydration error for ${B}:`,L),new Response(H.html,{headers:{"Content-Type":"text/html"}})}}});return console.log(`[stx] Production server running at http://localhost:${Y}`),console.log(`[stx] Serving ${X.routes.length} routes (${J.size} pre-loaded)`),{port:Y,stop:()=>W.stop()}}var DI;var gJ=D(()=>{A3();vJ();DI={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"}});var fJ="f9c3713";import{existsSync as O7,mkdirSync as hJ}from"fs";import{join as d4,dirname as kI}from"path";import{execSync as Rj}from"child_process";async function bI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.template||"default",J=d4(process.cwd(),$);if(O7(J))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{hJ(J,{recursive:!0});let Q=CI(X);for(let K of Q)hJ(d4(J,K),{recursive:!0});let G=PI(X,$,Z);for(let[K,W]of Object.entries(G)){let U=d4(J,K);F7(kI(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{Rj("git init",{cwd:J,stdio:"ignore"}),await Bun.write(d4(J,".gitignore"),iI()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||qD();try{console.log(`
12189
+ `)}async runPluginHook($,Z){if(!this.config.plugins)return;for(let Y of this.config.plugins){let X=Y[$];if(typeof X==="function")await X.call(Y,Z||this)}}async runPluginTransform($,Z){if(!this.config.plugins)return $;let Y=$;for(let X of this.config.plugins)if(X.transform){let J=await X.transform(Y,Z);if(J!=null)Y=J}return Y}generateHash($){return OI("sha256").update($).digest("hex")}getOutputName($,Z,Y){let X=Z==="html"?".html":Z==="css"?".css":Z==="js"?".js":"";return`${$}.${Y.slice(0,8)}${X}`}formatSize($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(2)} KB`;return`${($/1048576).toFixed(2)} MB`}ensureDir($){if(!j7($))FI($,{recursive:!0})}walkDir($,Z){if(!j7($))return;let Y=AI($,{withFileTypes:!0});for(let X of Y){let J=l1($,X.name);if(X.isDirectory())this.walkDir(J,Z);else Z(J)}}getResult(){let $=Date.now()-this.startTime,Z=this.outputs.reduce((X,J)=>X+J.size,0),Y=this.outputs.reduce((X,J)=>X+(J.gzipSize||0),0);return{outputs:this.outputs,duration:$,totalSize:Z,gzipSize:Y,chunks:this.chunks,assets:this.assets,warnings:this.warnings,errors:this.errors}}}async function wI($){return new E3($).build()}function MI($){return new E3($)}function EI($){return{...Oj,...$}}var Oj;var Fj=D(()=>{Oj={outDir:"dist",publicPath:"/",sourcemaps:!0,minify:{js:!0,css:!0,html:!0,dropConsole:!0,dropDebugger:!0,mangle:!0},splitting:{vendor:!0,minSize:20000,maxSize:250000,chunkNames:"deterministic"},css:{extract:!0,minify:!0,filename:"assets/[name].[hash].css"},assets:{inlineLimit:4096,filename:"assets/[name].[hash][ext]",hash:!0,hashLength:8,include:["png","jpg","jpeg","gif","svg","webp","woff","woff2","ttf","eot"]},compression:{gzip:!0,brotli:!0,threshold:1024,deleteOriginal:!1}}});async function xJ($,Z={}){if(!$.hasServerScripts&&!L4($.html))return $.html;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await V0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!L4($.html))return $.html;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=W1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?I0(String(G)):"")}catch{X.set(J,"")}return W8($.html,X)}async function TI($,Z={}){if(!$.hasServerScripts&&!L4($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await V0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!L4($.fragment))return $.fragment;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=W1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?I0(String(G)):"")}catch{X.set(J,"")}return W8($.fragment,X)}var vJ=D(()=>{w6();r0();l$()});var Nj={};t(Nj,{startProductionServer:()=>Aj});import Vj from"fs";import h6 from"path";var{serve:II}=globalThis.Bun;async function Aj($={}){let Z=h6.resolve($.outputDir||".output"),Y=$.port||3000,X=LJ(Z);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let J=new Map,Q=new Map;for(let U of X.routes)try{let _=h6.join(Z,U.compiledPath),B=JSON.parse(await Bun.file(_).text());J.set(U.pattern,B);let z=h6.join(Z,U.fragmentPath);if(await Bun.file(z).exists())Q.set(U.pattern,await Bun.file(z).text())}catch(_){console.warn(`[stx] Failed to load route ${U.pattern}:`,_)}let G=new Map,K=[];for(let U of X.routes)if(U.hasParams){let _=[],B=U.pattern.replace(/:([^/]+)/g,(z,q)=>{return _.push(q),"([^/]+)"});K.push({regex:new RegExp(`^${B}$`),route:U,paramNames:_})}else G.set(U.pattern,U);let W=II({port:Y,async fetch(U){let B=new URL(U.url).pathname;if($.onRequest){let L=await $.onRequest(U);if(L)return L}if($.apiRoutes?.[B])return $.apiRoutes[B](U);if((U.method==="GET"||U.method==="HEAD")&&B!=="/"){let L=h6.resolve(Z,"public"),F;try{F=decodeURIComponent(B)}catch{F=B}if(!F.includes("\x00")){let O=h6.resolve(L,`.${F}`);if(O===L||O.startsWith(`${L}${h6.sep}`))try{if(Vj.existsSync(O)&&Vj.statSync(O).isFile()){let N=h6.extname(O).toLowerCase(),A=DI[N]||"application/octet-stream",R=B.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(B);return new Response(Bun.file(O),{headers:{"Content-Type":A,"Cache-Control":R?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let z=U.headers.get("X-STX-Router")==="true",q=null,j={};if(q=G.get(B)||null,!q)for(let{regex:L,route:F,paramNames:O}of K){let V=B.match(L);if(V){q=F,O.forEach((N,A)=>{j[N]=V[A+1]});break}}if(!q){let L=G.get("/404")||null;if(L){let F=J.get(L.compiledPath);if(F)return new Response(F.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(z){let L=Q.get(q.pattern);if(L)return new Response(L,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-cache"}})}let H=J.get(q.pattern);if(!H)return new Response("Internal Server Error",{status:500});if(!H.hasServerScripts&&Object.keys(H.placeholders).length===0)return new Response(H.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let L=await xJ(H,{params:j,request:U});return new Response(L,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(L){return console.error(`[stx] Hydration error for ${B}:`,L),new Response(H.html,{headers:{"Content-Type":"text/html"}})}}});return console.log(`[stx] Production server running at http://localhost:${Y}`),console.log(`[stx] Serving ${X.routes.length} routes (${J.size} pre-loaded)`),{port:Y,stop:()=>W.stop()}}var DI;var gJ=D(()=>{A3();vJ();DI={".js":"application/javascript",".mjs":"application/javascript",".css":"text/css",".json":"application/json",".html":"text/html",".txt":"text/plain",".xml":"application/xml",".pdf":"application/pdf",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml",".ico":"image/x-icon",".bmp":"image/bmp",".mp4":"video/mp4",".webm":"video/webm",".ogg":"audio/ogg",".mp3":"audio/mpeg",".wav":"audio/wav",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"}});var fJ="f9c3713";import{existsSync as O7,mkdirSync as hJ}from"fs";import{join as d6,dirname as kI}from"path";import{execSync as Rj}from"child_process";async function bI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.template||"default",J=d6(process.cwd(),$);if(O7(J))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{hJ(J,{recursive:!0});let Q=CI(X);for(let K of Q)hJ(d6(J,K),{recursive:!0});let G=PI(X,$,Z);for(let[K,W]of Object.entries(G)){let U=d6(J,K);F7(kI(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{Rj("git init",{cwd:J,stdio:"ignore"}),await Bun.write(d6(J,".gitignore"),iI()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||qD();try{console.log(`
12190
12190
  Installing dependencies with ${K}...`),Rj(`${K} install`,{cwd:J,stdio:"inherit"})}catch{Y.errors.push("Failed to install dependencies")}}Y.message=`Created project: ${$}`,console.log(`
12191
12191
  \u2705 ${Y.message}
12192
12192
 
12193
12193
  Next steps:
12194
12194
  cd ${$}
12195
12195
  ${Z.packageManager||"bun"} run dev
12196
- `)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function CI($){let Z=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...Z,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...Z,"src/posts","src/utils"];case"dashboard":return[...Z,"src/stores","src/api","src/utils"];case"landing":return[...Z,"src/sections"];default:return[...Z,"src/stores"]}}function PI($,Z,Y){let X={};if(X["package.json"]=uI(Z,$,Y),X["stx.config.ts"]=cI($,Y),X["README.md"]=pI(Z,$),Y.typescript!==!1)X["tsconfig.json"]=lI();switch($){case"minimal":X["src/index.stx"]=nI();break;case"blog":X["pages/index.stx"]=oI(),X["pages/[slug].stx"]=tI(),X["layouts/app.stx"]=eI(),X["components/PostCard.stx"]=$D();break;case"dashboard":X["pages/index.stx"]=ZD(),X["pages/settings.stx"]=YD(),X["layouts/app.stx"]=XD(),X["components/Sidebar.stx"]=JD(),X["components/StatsCard.stx"]=QD(),X["src/stores/dashboard.ts"]=GD();break;case"landing":X["pages/index.stx"]=KD(),X["layouts/app.stx"]=WD(),X["src/sections/Hero.stx"]=UD(),X["src/sections/Features.stx"]=_D(),X["src/sections/Pricing.stx"]=BD(),X["components/Button.stx"]=zD();break;case"full":X["pages/index.stx"]=wj(),X["pages/about.stx"]=rI(),X["layouts/app.stx"]=Mj(),X["components/Header.stx"]=Ej(),X["components/Footer.stx"]=Tj(),X["src/stores/app.ts"]=Ij(),X["src/i18n/en.json"]=sI("en"),X["test/example.test.ts"]=aI();break;default:X["pages/index.stx"]=wj(),X["layouts/app.stx"]=Mj(),X["components/Header.stx"]=Ej(),X["components/Footer.stx"]=Tj(),X["src/stores/app.ts"]=Ij()}return X}async function yI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"components",J=dJ($),Q=d4(X,`${J}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Component ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=fI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created component: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create component: ${G}`}return Y}async function xI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"pages",J=$.toLowerCase().replace(/\s+/g,"-"),Q=d4(X,`${J}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Page ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=hI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created page: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create page: ${G}`}return Y}async function vI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"src/stores",J=jD($),Q=d4(X,`${J}.ts`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Store ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=dI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created store: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create store: ${G}`}return Y}async function gI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"layouts",J=$.toLowerCase().replace(/\s+/g,"-"),Q=d4(X,`${J}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Layout ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=mI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created layout: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create layout: ${G}`}return Y}function fI($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
12196
+ `)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function CI($){let Z=["pages","components","layouts","partials","public"];switch($){case"minimal":return["src","public"];case"full":return[...Z,"src/stores","src/api","src/i18n","src/utils","test"];case"blog":return[...Z,"src/posts","src/utils"];case"dashboard":return[...Z,"src/stores","src/api","src/utils"];case"landing":return[...Z,"src/sections"];default:return[...Z,"src/stores"]}}function PI($,Z,Y){let X={};if(X["package.json"]=uI(Z,$,Y),X["stx.config.ts"]=cI($,Y),X["README.md"]=pI(Z,$),Y.typescript!==!1)X["tsconfig.json"]=lI();switch($){case"minimal":X["src/index.stx"]=nI();break;case"blog":X["pages/index.stx"]=oI(),X["pages/[slug].stx"]=tI(),X["layouts/app.stx"]=eI(),X["components/PostCard.stx"]=$D();break;case"dashboard":X["pages/index.stx"]=ZD(),X["pages/settings.stx"]=YD(),X["layouts/app.stx"]=XD(),X["components/Sidebar.stx"]=JD(),X["components/StatsCard.stx"]=QD(),X["src/stores/dashboard.ts"]=GD();break;case"landing":X["pages/index.stx"]=KD(),X["layouts/app.stx"]=WD(),X["src/sections/Hero.stx"]=UD(),X["src/sections/Features.stx"]=_D(),X["src/sections/Pricing.stx"]=BD(),X["components/Button.stx"]=zD();break;case"full":X["pages/index.stx"]=wj(),X["pages/about.stx"]=rI(),X["layouts/app.stx"]=Mj(),X["components/Header.stx"]=Ej(),X["components/Footer.stx"]=Tj(),X["src/stores/app.ts"]=Ij(),X["src/i18n/en.json"]=sI("en"),X["test/example.test.ts"]=aI();break;default:X["pages/index.stx"]=wj(),X["layouts/app.stx"]=Mj(),X["components/Header.stx"]=Ej(),X["components/Footer.stx"]=Tj(),X["src/stores/app.ts"]=Ij()}return X}async function yI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"components",J=dJ($),Q=d6(X,`${J}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Component ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=fI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created component: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create component: ${G}`}return Y}async function xI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"pages",J=$.toLowerCase().replace(/\s+/g,"-"),Q=d6(X,`${J}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Page ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=hI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created page: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create page: ${G}`}return Y}async function vI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"src/stores",J=jD($),Q=d6(X,`${J}.ts`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Store ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=dI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created store: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create store: ${G}`}return Y}async function gI($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"layouts",J=$.toLowerCase().replace(/\s+/g,"-"),Q=d6(X,`${J}.stx`);if(await Bun.file(Q).exists()&&!Z.force)return Y.success=!1,Y.message=`Layout ${J} already exists. Use --force to overwrite.`,Y;try{F7(X);let G=mI(J,Z);await Bun.write(Q,G),Y.files.push(Q),Y.message=`Created layout: ${Q}`,console.log(`\u2705 ${Y.message}`)}catch(G){Y.success=!1,Y.message=`Failed to create layout: ${G}`}return Y}function fI($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
12197
12197
  // Props
12198
12198
  const title = props.title || '${$}'
12199
12199
  const variant = props.variant || 'default'
12200
12200
  </script>
12201
- `);if(Y.push(`<div class="${Q6($)} ${Q6($)}--{{ variant }}">
12201
+ `);if(Y.push(`<div class="${Q4($)} ${Q4($)}--{{ variant }}">
12202
12202
  <h3>{{ title }}</h3>
12203
- <div class="${Q6($)}__content">
12203
+ <div class="${Q4($)}__content">
12204
12204
  {{ slot }}
12205
12205
  </div>
12206
12206
  </div>`),Z.styles!==!1)Y.push(`
12207
12207
  <style scoped>
12208
- .${Q6($)} {
12208
+ .${Q4($)} {
12209
12209
  padding: 1rem;
12210
12210
  border-radius: 8px;
12211
12211
  background: #f8f9fa;
12212
12212
  }
12213
12213
 
12214
- .${Q6($)}--primary {
12214
+ .${Q4($)}--primary {
12215
12215
  border-left: 3px solid #3498db;
12216
12216
  }
12217
12217
 
12218
- .${Q6($)}--success {
12218
+ .${Q4($)}--success {
12219
12219
  border-left: 3px solid #2ecc71;
12220
12220
  }
12221
12221
 
12222
- .${Q6($)}__content {
12222
+ .${Q4($)}__content {
12223
12223
  margin-top: 0.5rem;
12224
12224
  }
12225
12225
  </style>`);return Y.join(`
@@ -12660,14 +12660,14 @@ describe('Example', () => {
12660
12660
  </footer>
12661
12661
  @yield('scripts')
12662
12662
  </body>
12663
- </html>`}function UD(){return"<!-- Hero section -->"}function _D(){return"<!-- Features -->"}function BD(){return"<!-- Pricing -->"}function zD(){return"<!-- Button -->"}function F7($){if(!O7($))hJ($,{recursive:!0})}function qD(){if(O7("bun.lockb"))return"bun";if(O7("pnpm-lock.yaml"))return"pnpm";if(O7("yarn.lock"))return"yarn";return"bun"}function dJ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function jD($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function Q6($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var SI;var Dj=D(()=>{SI={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:HD}=globalThis.Bun;import V7 from"fs";import m4 from"path";function LD($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function kj($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=m4.resolve(Y),B=new Map;async function z(O){let V=V7.statSync(O),N=`${O}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;for(let u of B.keys())if(u.startsWith(`${O}:`)&&u!==N)B.delete(u);let R=await Bun.file(O).text(),M=R,E=R.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(E&&E.index!==void 0){let u=E.index+E[0].length,l=1,p=u;while(p<R.length&&l>0){let Q0=R.indexOf("<template",p),X0=R.indexOf("</template>",p);if(X0===-1)break;if(Q0!==-1&&Q0<X0)l++,p=Q0+9;else{if(l--,l===0){M=R.substring(u,X0).trim();break}p=X0+11}}}let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,T=[],S=[],k;while((k=I.exec(R))!==null){let u=k[1],l=k[2],p=k[0];if(u.includes("server"))S.push(l);else T.push(p)}let C=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],x=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),g={__filename:O,__dirname:m4.dirname(O)};for(let u of S)await V0(u,g,O);let h=await J0(x,g,O,X,new Set);if(C.length>0){let u=C.join(`
12663
+ </html>`}function UD(){return"<!-- Hero section -->"}function _D(){return"<!-- Features -->"}function BD(){return"<!-- Pricing -->"}function zD(){return"<!-- Button -->"}function F7($){if(!O7($))hJ($,{recursive:!0})}function qD(){if(O7("bun.lockb"))return"bun";if(O7("pnpm-lock.yaml"))return"pnpm";if(O7("yarn.lock"))return"yarn";return"bun"}function dJ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function jD($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function Q4($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var SI;var Dj=D(()=>{SI={default:{description:"Standard stx project with pages, components, and stores",features:["Pages","Components","Layouts","Stores","Dev server"]},minimal:{description:"Minimal setup with just the essentials",features:["Single page","Basic styles"]},full:{description:"Full-featured project with all stx capabilities",features:["Pages","Components","Layouts","Stores","API routes","PWA","i18n","Testing"]},blog:{description:"Blog template with markdown support",features:["Blog layout","Post pages","Tags","RSS feed","Markdown"]},dashboard:{description:"Admin dashboard template",features:["Sidebar","Charts","Tables","Forms","Auth pages"]},landing:{description:"Marketing landing page template",features:["Hero section","Features","Pricing","CTA","Contact form"]}}});var{serve:HD}=globalThis.Bun;import V7 from"fs";import m6 from"path";function LD($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function kj($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=m6.resolve(Y),B=new Map;async function z(O){let V=V7.statSync(O),N=`${O}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;for(let u of B.keys())if(u.startsWith(`${O}:`)&&u!==N)B.delete(u);let R=await Bun.file(O).text(),M=R,E=R.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(E&&E.index!==void 0){let u=E.index+E[0].length,l=1,p=u;while(p<R.length&&l>0){let Q0=R.indexOf("<template",p),X0=R.indexOf("</template>",p);if(X0===-1)break;if(Q0!==-1&&Q0<X0)l++,p=Q0+9;else{if(l--,l===0){M=R.substring(u,X0).trim();break}p=X0+11}}}let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,T=[],S=[],k;while((k=I.exec(R))!==null){let u=k[1],l=k[2],p=k[0];if(u.includes("server"))S.push(l);else T.push(p)}let C=R.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],x=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),g={__filename:O,__dirname:m6.dirname(O)};for(let u of S)await V0(u,g,O);let h=await J0(x,g,O,X,new Set);if(C.length>0){let u=C.join(`
12664
12664
  `);if(h.match(/(<\/head>)/i))h=h.replace(/(<\/head>)/i,`${u}
12665
12665
  $1`)}if(T.length>0){let{interpolateScriptsInTemplate:u}=await Promise.resolve().then(() => (r0(),n$)),l=u(T.join(`
12666
12666
  `),g);if(h.match(/(<\/body>)/i))h=h.replace(/(<\/body>)/i,`${l}
12667
12667
  $1`);else h+=`
12668
- ${l}`}return B.set(N,{content:h,mtime:V.mtimeMs}),h}async function q(O){let V=V7.statSync(O),N=`${O}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;let{content:R}=await Z4(O,X);return B.set(N,{content:R,mtime:V.mtimeMs}),R}function j(O){let V=O.startsWith("/")?O.slice(1):O,N=[V,`${V}.stx`,`${V}.md`,`${V}.html`,m4.join(V,"index.stx"),m4.join(V,"index.md"),m4.join(V,"index.html")];for(let A of N){let R=m4.join(_,A);if(V7.existsSync(R)&&V7.statSync(R).isFile())return R}return null}async function H(O){let V=new URL(O.url),N=async()=>{if(G[V.pathname])return await G[V.pathname](O);if(Q){let R=await Q(O);if(R)return R}let A=j(V.pathname);if(!A){if(W)return await W(O);return new Response("Not Found",{status:404})}try{let R,M="text/html";if(A.endsWith(".stx"))R=await z(A);else if(A.endsWith(".md"))R=await q(A);else if(A.endsWith(".html"))R=await Bun.file(A).text();else if(A.endsWith(".css"))R=await Bun.file(A).text(),M="text/css";else if(A.endsWith(".js"))R=await Bun.file(A).text(),M="text/javascript";else if(A.endsWith(".json"))R=await Bun.file(A).text(),M="application/json";else return new Response(Bun.file(A));return new Response(R,{headers:{"Content-Type":M}})}catch(R){if(U)return await U(R,O);let M=R instanceof Error?R.message:String(R),I=X?.debug===!0?`<h1>Error</h1><pre>${M}
12669
- ${R instanceof Error?R.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(I,{status:500,headers:{"Content-Type":"text/html"}})}};for(let A=K.length-1;A>=0;A--){let R=K[A],M=N;N=async()=>await R(O,M)}return await N()}let L=HD({port:Z,fetch:H}),F=null;if(J)F=V7.watch(_,{recursive:!0},(O,V)=>{if(V&&(V.endsWith(".stx")||V.endsWith(".md")||V.endsWith(".html")))B.clear()});return{server:L,url:L.url.toString(),stop(){if(F)F.close();L.stop()}}}async function OD($,Z={}){let Y=m4.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let X=Y.endsWith(".md"),J=Y.endsWith(".stx");if(!X&&!J)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await kj({...Z,root:m4.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await Z4(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let _=K.join(`
12670
- `),B=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={};if(_.trim())await V0(_,z,Y);let q=new Set;Q=await J0(B,z,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function FD($){return $}function VD($){return $}var Sj=D(()=>{d6();J1();H0()});import T3 from"path";function AD($){let Z=[],Y=0,X;bj.lastIndex=0;while((X=bj.exec($))!==null){if(X.index>Y){let G=$.slice(Y,X.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let J=X[1],Q=X[2];Z.push({type:"suspense",name:J,content:Q}),Y=X.index+X[0].length}if(Y<$.length){let J=$.slice(Y);if(J.trim())Z.push({type:Z.length===0?"shell":"content",content:J})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function ND($,Z={},Y={}){let X={...Q1,...Y,streaming:{...mJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:T3.dirname($)};if(W.trim())await V0(W,_,$);let B=AD(U),z=new Set;if(!B.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(G6.source,"g");if(!(j!=="manual"&&H.test(U))){let F=await J0(U,_,$,X,z);for(let O=0;O<F.length;O+=J)Q.enqueue(F.slice(O,O+J)),await new Promise((V)=>setTimeout(V,0))}else{let F=[],O=new RegExp(G6.source,"g"),V;while((V=O.exec(U))!==null)F.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let N=0;for(let A of F){if(A.start>N){let M=U.slice(N,A.start);if(M.trim()){let E=await J0(M,_,$,X,z);Q.enqueue(E),await new Promise((I)=>setTimeout(I,0))}}let R=await J0(A.content,_,$,X,z);Q.enqueue(R),await new Promise((M)=>setTimeout(M,0)),N=A.end}if(N<U.length){let A=U.slice(N);if(A.trim()){let R=await J0(A,_,$,X,z);Q.enqueue(R)}}}}else{let j=new Map;for(let L of B)if(L.type==="shell"||L.type==="content"){let F=await J0(L.content,_,$,X,z);Q.enqueue(F)}else if(L.type==="suspense"&&L.name){let F=`stx-suspense-${L.name}`;Q.enqueue(`<div id="${F}" data-suspense="${L.name}" style="display:contents;">
12668
+ ${l}`}return B.set(N,{content:h,mtime:V.mtimeMs}),h}async function q(O){let V=V7.statSync(O),N=`${O}:${V.mtimeMs}`,A=B.get(N);if(A)return A.content;let{content:R}=await Z6(O,X);return B.set(N,{content:R,mtime:V.mtimeMs}),R}function j(O){let V=O.startsWith("/")?O.slice(1):O,N=[V,`${V}.stx`,`${V}.md`,`${V}.html`,m6.join(V,"index.stx"),m6.join(V,"index.md"),m6.join(V,"index.html")];for(let A of N){let R=m6.join(_,A);if(V7.existsSync(R)&&V7.statSync(R).isFile())return R}return null}async function H(O){let V=new URL(O.url),N=async()=>{if(G[V.pathname])return await G[V.pathname](O);if(Q){let R=await Q(O);if(R)return R}let A=j(V.pathname);if(!A){if(W)return await W(O);return new Response("Not Found",{status:404})}try{let R,M="text/html";if(A.endsWith(".stx"))R=await z(A);else if(A.endsWith(".md"))R=await q(A);else if(A.endsWith(".html"))R=await Bun.file(A).text();else if(A.endsWith(".css"))R=await Bun.file(A).text(),M="text/css";else if(A.endsWith(".js"))R=await Bun.file(A).text(),M="text/javascript";else if(A.endsWith(".json"))R=await Bun.file(A).text(),M="application/json";else return new Response(Bun.file(A));return new Response(R,{headers:{"Content-Type":M}})}catch(R){if(U)return await U(R,O);let M=R instanceof Error?R.message:String(R),I=X?.debug===!0?`<h1>Error</h1><pre>${M}
12669
+ ${R instanceof Error?R.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(I,{status:500,headers:{"Content-Type":"text/html"}})}};for(let A=K.length-1;A>=0;A--){let R=K[A],M=N;N=async()=>await R(O,M)}return await N()}let L=HD({port:Z,fetch:H}),F=null;if(J)F=V7.watch(_,{recursive:!0},(O,V)=>{if(V&&(V.endsWith(".stx")||V.endsWith(".md")||V.endsWith(".html")))B.clear()});return{server:L,url:L.url.toString(),stop(){if(F)F.close();L.stop()}}}async function OD($,Z={}){let Y=m6.resolve($);if(!await Bun.file(Y).exists())throw Error(`File not found: ${Y}`);let X=Y.endsWith(".md"),J=Y.endsWith(".stx");if(!X&&!J)throw Error(`Unsupported file type: ${Y}. Only .stx and .md files are supported.`);return await kj({...Z,root:m6.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await Z6(Y,Z.stxOptions);Q=G}else{let G=await Bun.file(Y).text(),K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(G))!==null)if(U[1].includes("server"))K.push(U[2]);let _=K.join(`
12670
+ `),B=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={};if(_.trim())await V0(_,z,Y);let q=new Set;Q=await J0(B,z,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function FD($){return $}function VD($){return $}var Sj=D(()=>{d4();J1();H0()});import T3 from"path";function AD($){let Z=[],Y=0,X;bj.lastIndex=0;while((X=bj.exec($))!==null){if(X.index>Y){let G=$.slice(Y,X.index);if(G.trim())Z.push({type:Z.length===0?"shell":"content",content:G})}let J=X[1],Q=X[2];Z.push({type:"suspense",name:J,content:Q}),Y=X.index+X[0].length}if(Y<$.length){let J=$.slice(Y);if(J.trim())Z.push({type:Z.length===0?"shell":"content",content:J})}if(Z.length===0)Z.push({type:"shell",content:$});return Z}async function ND($,Z={},Y={}){let X={...Q1,...Y,streaming:{...mJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:T3.dirname($)};if(W.trim())await V0(W,_,$);let B=AD(U),z=new Set;if(!B.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(G4.source,"g");if(!(j!=="manual"&&H.test(U))){let F=await J0(U,_,$,X,z);for(let O=0;O<F.length;O+=J)Q.enqueue(F.slice(O,O+J)),await new Promise((V)=>setTimeout(V,0))}else{let F=[],O=new RegExp(G4.source,"g"),V;while((V=O.exec(U))!==null)F.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let N=0;for(let A of F){if(A.start>N){let M=U.slice(N,A.start);if(M.trim()){let E=await J0(M,_,$,X,z);Q.enqueue(E),await new Promise((I)=>setTimeout(I,0))}}let R=await J0(A.content,_,$,X,z);Q.enqueue(R),await new Promise((M)=>setTimeout(M,0)),N=A.end}if(N<U.length){let A=U.slice(N);if(A.trim()){let R=await J0(A,_,$,X,z);Q.enqueue(R)}}}}else{let j=new Map;for(let L of B)if(L.type==="shell"||L.type==="content"){let F=await J0(L.content,_,$,X,z);Q.enqueue(F)}else if(L.type==="suspense"&&L.name){let F=`stx-suspense-${L.name}`;Q.enqueue(`<div id="${F}" data-suspense="${L.name}" style="display:contents;">
12671
12671
  <template data-suspense-fallback>Loading...</template>
12672
12672
  </div>`),j.set(L.name,J0(L.content,_,$,X,z))}Q.enqueue(`
12673
12673
  <script>
@@ -12691,7 +12691,7 @@ window.__stxSuspense.resolve('${L}', \`${V}\`);
12691
12691
  </script>`)}catch(O){let V=O instanceof Error?O.message:String(O);Q.enqueue(`
12692
12692
  <script>
12693
12693
  window.__stxSuspense.resolve('${L}', '<div class="stx-error">Error loading content: ${I0(V)}</div>');
12694
- </script>`)}});await Promise.all(H)}Q.close()}catch(G){Q.error(G)}}})}async function RD($,Z={},Y={}){let X={...Q1,...Y,streaming:{...mJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:T3.dirname($)};if(W.trim())await V0(W,_,$);let B=new Set,z=X.streaming?.strategy||"auto",q=new RegExp(G6.source,"g");if(!(z!=="manual"&&q.test(U))){let H=await J0(U,_,$,X,B);for(let L=0;L<H.length;L+=J)Q.enqueue(H.slice(L,L+J))}else{let H=[],L=new RegExp(G6.source,"g"),F;while((F=L.exec(U))!==null)H.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let O=0;for(let V of H){if(V.start>O){let A=U.slice(O,V.start);if(A.trim()){let R=await J0(A,_,$,X,B);Q.enqueue(R)}}let N=await J0(V.content,_,$,X,B);Q.enqueue(N),O=V.end}if(O<U.length){let V=U.slice(O);if(V.trim()){let N=await J0(V,_,$,X,B);Q.enqueue(N)}}}Q.close()}catch(G){Q.error(G)}}})}async function wD($,Z={}){let Y={...Q1,...Z,streaming:{...mJ,...Z.streaming}},X=await Bun.file($).text(),J=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),K=G,W={},U;G6.lastIndex=0;while((U=G6.exec(G))!==null){let z=U[1],q=U[2];W[z]=q}let _=G.replace(G6,"");return{renderShell:async(z={})=>{let q={...z,__filename:$,__dirname:T3.dirname($)};return await V0(Q,q,$),J0(_,q,$,Y,new Set)},renderSection:async(z,q={})=>{try{if(!W[z])return`<div class="error-message">Section "${I0(z)}" not found in template "${I0($)}"</div>`;let j={...q,__filename:$,__dirname:T3.dirname($)};await V0(Q,j,$);let H=new Set;return await J0(W[z],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return O0("Expression",H,$,W[z]||"",0,W[z]||"")}},getSections:()=>{return Object.keys(W)},getTemplate:()=>{return K}}}function MD($={}){let Z=[];if($.streaming?.enabled)Z.push(Cj);if($.hydration?.enabled)Z.push(Pj);return Z}async function ED($,Z,Y,X={}){return $}function TD($,Z={}){let Y=new TextEncoder,X=$.pipeThrough(new TransformStream({transform(Q,G){G.enqueue(Y.encode(Q))}})),J=new Headers(Z.headers);if(!J.has("Content-Type"))J.set("Content-Type","text/html; charset=utf-8");if(!J.has("Transfer-Encoding"))J.set("Transfer-Encoding","chunked");if(!J.has("X-Content-Type-Options"))J.set("X-Content-Type-Options","nosniff");return new Response(X,{...Z,headers:J})}function ID($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
12694
+ </script>`)}});await Promise.all(H)}Q.close()}catch(G){Q.error(G)}}})}async function RD($,Z={},Y={}){let X={...Q1,...Y,streaming:{...mJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:T3.dirname($)};if(W.trim())await V0(W,_,$);let B=new Set,z=X.streaming?.strategy||"auto",q=new RegExp(G4.source,"g");if(!(z!=="manual"&&q.test(U))){let H=await J0(U,_,$,X,B);for(let L=0;L<H.length;L+=J)Q.enqueue(H.slice(L,L+J))}else{let H=[],L=new RegExp(G4.source,"g"),F;while((F=L.exec(U))!==null)H.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let O=0;for(let V of H){if(V.start>O){let A=U.slice(O,V.start);if(A.trim()){let R=await J0(A,_,$,X,B);Q.enqueue(R)}}let N=await J0(V.content,_,$,X,B);Q.enqueue(N),O=V.end}if(O<U.length){let V=U.slice(O);if(V.trim()){let N=await J0(V,_,$,X,B);Q.enqueue(N)}}}Q.close()}catch(G){Q.error(G)}}})}async function wD($,Z={}){let Y={...Q1,...Z,streaming:{...mJ,...Z.streaming}},X=await Bun.file($).text(),J=X.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=X.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),K=G,W={},U;G4.lastIndex=0;while((U=G4.exec(G))!==null){let z=U[1],q=U[2];W[z]=q}let _=G.replace(G4,"");return{renderShell:async(z={})=>{let q={...z,__filename:$,__dirname:T3.dirname($)};return await V0(Q,q,$),J0(_,q,$,Y,new Set)},renderSection:async(z,q={})=>{try{if(!W[z])return`<div class="error-message">Section "${I0(z)}" not found in template "${I0($)}"</div>`;let j={...q,__filename:$,__dirname:T3.dirname($)};await V0(Q,j,$);let H=new Set;return await J0(W[z],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return O0("Expression",H,$,W[z]||"",0,W[z]||"")}},getSections:()=>{return Object.keys(W)},getTemplate:()=>{return K}}}function MD($={}){let Z=[];if($.streaming?.enabled)Z.push(Cj);if($.hydration?.enabled)Z.push(Pj);return Z}async function ED($,Z,Y,X={}){return $}function TD($,Z={}){let Y=new TextEncoder,X=$.pipeThrough(new TransformStream({transform(Q,G){G.enqueue(Y.encode(Q))}})),J=new Headers(Z.headers);if(!J.has("Content-Type"))J.set("Content-Type","text/html; charset=utf-8");if(!J.has("Transfer-Encoding"))J.set("Transfer-Encoding","chunked");if(!J.has("X-Content-Type-Options"))J.set("X-Content-Type-Options","nosniff");return new Response(X,{...Z,headers:J})}function ID($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
12695
12695
  `);if(Z==="loader")return`
12696
12696
  (function() {
12697
12697
  window.__stx = window.__stx || {};
@@ -12833,7 +12833,7 @@ else {
12833
12833
  else {
12834
12834
  stx.hydrate();
12835
12835
  }
12836
- })();`}var mJ,G6,bj,Cj,Pj;var yj=D(()=>{u0();r0();J1();H0();mJ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},G6=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,bj=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;Cj={name:"suspense",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Suspense directive requires a name parameter");let J=Z[0].replace(/['"`]/g,"");return`<!-- @suspense:${J} -->${$}<!-- @endsuspense:${J} -->`}},Pj={name:"island",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let J=Z[0].replace(/['"`]/g,""),Q=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${J}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),W=K?K[1].trim():"",U=K?$.replace(K[0],""):$;return`<div data-island="${J}" data-island-id="${G}" data-priority="${Q}">
12836
+ })();`}var mJ,G4,bj,Cj,Pj;var yj=D(()=>{u0();r0();J1();H0();mJ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},G4=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,bj=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;Cj={name:"suspense",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Suspense directive requires a name parameter");let J=Z[0].replace(/['"`]/g,"");return`<!-- @suspense:${J} -->${$}<!-- @endsuspense:${J} -->`}},Pj={name:"island",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let J=Z[0].replace(/['"`]/g,""),Q=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${J}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),W=K?K[1].trim():"",U=K?$.replace(K[0],""):$;return`<div data-island="${J}" data-island-id="${G}" data-priority="${Q}">
12837
12837
  ${U}
12838
12838
  <script type="application/json" data-island-props="${G}">
12839
12839
  ${W?`{${W}}`:"{}"}
@@ -12872,7 +12872,7 @@ else {
12872
12872
  0% { transform: translateX(-100%); }
12873
12873
  100% { transform: translateX(100%); }
12874
12874
  }
12875
- `,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function I3($,Z){if(!I$||!K1)return;if(p1=Math.min(Math.max($,0),100),iJ)cancelAnimationFrame(iJ);iJ=requestAnimationFrame(()=>{if(!K1)return;K1.style.opacity=p1>0?"1":"0",K1.style.transform=`scaleX(${p1/100})`})}function vD($){if(!I$)return;if(A7=!0,p1=0,!K1)K1=fj($);if(T$)clearTimeout(T$);if(W4)clearInterval(W4);I3(10,$),W4=setInterval(()=>{if(!A7)return;let Z=90-p1,Y=Math.max(0.5,Z*0.1);if(p1<90)I3(p1+Y,$)},$.throttle)}function gD($){if(!I$)return;if(A7=!1,W4)clearInterval(W4),W4=null;I3(100,$),T$=setTimeout(()=>{if(K1)K1.style.opacity="0";setTimeout(()=>{if(p1=0,K1)K1.style.transform="scaleX(0)"},300)},200)}function fD(){if(!I$)return;if(A7=!1,p1=0,W4)clearInterval(W4),W4=null;if(T$)clearTimeout(T$),T$=null;if(K1)K1.style.opacity="0",K1.style.transform="scaleX(0)"}function hj($){let Z={...nJ,...$};return{start:()=>vD(Z),set:(Y)=>I3(Y,Z),finish:()=>gD(Z),clear:()=>fD(),get state(){return{isLoading:A7,progress:p1,error:!1}}}}function hD($){if(!I$)return;let Z={...nJ,...$},Y=hj(Z);K1=fj(Z);let X=!1;document.addEventListener("click",(G)=>{let W=G.target.closest("a");if(!W)return;let U=W.getAttribute("href");if(!U)return;if(U.startsWith("http")||U.startsWith("#")||U.startsWith("mailto:")||U.startsWith("tel:")||W.target==="_blank"||W.hasAttribute("download"))return;X=!0,Y.start()}),window.addEventListener("popstate",()=>{if(!X)Y.start(),X=!0}),window.addEventListener("load",()=>{if(X||Z.autoFinish)Y.finish(),X=!1});let J=window.fetch,Q=0;window.fetch=async function(...G){let K=typeof G[0]==="string"?G[0]:G[0].url,W=K.includes("/api/")||K.startsWith("/api");if(W){if(Q++,Q===1&&!X)Y.start()}try{return await J.apply(this,G)}finally{if(W){if(Q--,Q===0&&!X)Y.finish()}}}}function dD($){let Z={...nJ,...$},Y=Z.initialColor?`linear-gradient(to right, ${Z.initialColor}, ${Z.color})`:Z.color;return`
12875
+ `,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function I3($,Z){if(!I$||!K1)return;if(p1=Math.min(Math.max($,0),100),iJ)cancelAnimationFrame(iJ);iJ=requestAnimationFrame(()=>{if(!K1)return;K1.style.opacity=p1>0?"1":"0",K1.style.transform=`scaleX(${p1/100})`})}function vD($){if(!I$)return;if(A7=!0,p1=0,!K1)K1=fj($);if(T$)clearTimeout(T$);if(W6)clearInterval(W6);I3(10,$),W6=setInterval(()=>{if(!A7)return;let Z=90-p1,Y=Math.max(0.5,Z*0.1);if(p1<90)I3(p1+Y,$)},$.throttle)}function gD($){if(!I$)return;if(A7=!1,W6)clearInterval(W6),W6=null;I3(100,$),T$=setTimeout(()=>{if(K1)K1.style.opacity="0";setTimeout(()=>{if(p1=0,K1)K1.style.transform="scaleX(0)"},300)},200)}function fD(){if(!I$)return;if(A7=!1,p1=0,W6)clearInterval(W6),W6=null;if(T$)clearTimeout(T$),T$=null;if(K1)K1.style.opacity="0",K1.style.transform="scaleX(0)"}function hj($){let Z={...nJ,...$};return{start:()=>vD(Z),set:(Y)=>I3(Y,Z),finish:()=>gD(Z),clear:()=>fD(),get state(){return{isLoading:A7,progress:p1,error:!1}}}}function hD($){if(!I$)return;let Z={...nJ,...$},Y=hj(Z);K1=fj(Z);let X=!1;document.addEventListener("click",(G)=>{let W=G.target.closest("a");if(!W)return;let U=W.getAttribute("href");if(!U)return;if(U.startsWith("http")||U.startsWith("#")||U.startsWith("mailto:")||U.startsWith("tel:")||W.target==="_blank"||W.hasAttribute("download"))return;X=!0,Y.start()}),window.addEventListener("popstate",()=>{if(!X)Y.start(),X=!0}),window.addEventListener("load",()=>{if(X||Z.autoFinish)Y.finish(),X=!1});let J=window.fetch,Q=0;window.fetch=async function(...G){let K=typeof G[0]==="string"?G[0]:G[0].url,W=K.includes("/api/")||K.startsWith("/api");if(W){if(Q++,Q===1&&!X)Y.start()}try{return await J.apply(this,G)}finally{if(W){if(Q--,Q===0&&!X)Y.finish()}}}}function dD($){let Z={...nJ,...$},Y=Z.initialColor?`linear-gradient(to right, ${Z.initialColor}, ${Z.color})`:Z.color;return`
12876
12876
  <div id="stx-loading-indicator" style="
12877
12877
  position: fixed;
12878
12878
  top: 0;
@@ -12966,7 +12966,7 @@ else {
12966
12966
  window.addEventListener('load', function() { window.stxLoading.finish(); });
12967
12967
  })();
12968
12968
  </script>
12969
- `}var I$,nJ,K1=null,p1=0,A7=!1,iJ=null,T$=null,W4=null;var dj=D(()=>{I$=typeof window<"u"&&typeof document<"u",nJ={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999}});var rJ=`
12969
+ `}var I$,nJ,K1=null,p1=0,A7=!1,iJ=null,T$=null,W6=null;var dj=D(()=>{I$=typeof window<"u"&&typeof document<"u",nJ={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999}});var rJ=`
12970
12970
  <script data-stx-helpers>
12971
12971
  (function() {
12972
12972
  'use strict'
@@ -14312,7 +14312,7 @@ else {
14312
14312
  border: none;
14313
14313
  color: white;
14314
14314
  }
14315
- `.trim();return{html:Q,script:G,css:K}}function BH($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function x3(){return"loading"in HTMLImageElement.prototype}function v3(){return"IntersectionObserver"in window}function vQ($={}){let Z={...LH,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&x3())return Y.forEach((J)=>{if(J.tagName==="IMG"||J.tagName==="IFRAME")U4(J,Z)}),()=>{};if(!v3())return Y.forEach((J)=>U4(J,Z)),()=>{};let X=new IntersectionObserver((J)=>{J.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;U4(G,Z),X.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((J)=>X.observe(J)),()=>{X.disconnect()}}function U4($,Z={}){let{onLoad:Y,onLoaded:X,onError:J}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)jH($,X,J);else if(G)HH($,X,J);else if(K)Jk($,X,J);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)jH(W,()=>{if(X)X($)},(B)=>{if(J)J($,B)});else if(U)HH(U,()=>{if(X)X($)},(B)=>{if(J)J($,B)});$.querySelectorAll("source[data-srcset]").forEach((B)=>{let z=B;if(z.dataset.srcset)z.srcset=z.dataset.srcset,delete z.dataset.srcset;if(z.dataset.sizes)z.sizes=z.dataset.sizes,delete z.dataset.sizes})}}function jH($,Z,Y){let X=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let Q=$.closest(".stx-img-placeholder");if(Q)Q.classList.add("stx-img-loaded");if(Z)Z($)},J=()=>{if($.classList.add("stx-img-error"),Y)Y($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",X,{once:!0}),$.addEventListener("error",J,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function HH($,Z,Y){let X=()=>{if($.classList.add("stx-video-loaded"),Z)Z($)},J=()=>{if($.classList.add("stx-video-error"),Y)Y($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",X,{once:!0}),$.addEventListener("error",J,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let K=G;if(K.dataset.src)K.src=K.dataset.src,delete K.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function Jk($,Z,Y){let X=()=>{if($.classList.add("stx-iframe-loaded"),Z)Z($)},J=()=>{if($.classList.add("stx-iframe-error"),Y)Y($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",X,{once:!0}),$.addEventListener("error",J,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function gQ($){U4($,{})}function fQ($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>U4(Y,{}))}function hQ($={}){let Z={...LH,...$};return new IntersectionObserver((Y,X)=>{Y.forEach((J)=>{if(J.isIntersecting)U4(J.target,Z),X.unobserve(J.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function dQ($,Z){$.observe(Z)}function mQ($){$.disconnect()}function E7(){return`
14315
+ `.trim();return{html:Q,script:G,css:K}}function BH($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function x3(){return"loading"in HTMLImageElement.prototype}function v3(){return"IntersectionObserver"in window}function vQ($={}){let Z={...LH,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&x3())return Y.forEach((J)=>{if(J.tagName==="IMG"||J.tagName==="IFRAME")U6(J,Z)}),()=>{};if(!v3())return Y.forEach((J)=>U6(J,Z)),()=>{};let X=new IntersectionObserver((J)=>{J.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;U6(G,Z),X.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((J)=>X.observe(J)),()=>{X.disconnect()}}function U6($,Z={}){let{onLoad:Y,onLoaded:X,onError:J}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)jH($,X,J);else if(G)HH($,X,J);else if(K)Jk($,X,J);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)jH(W,()=>{if(X)X($)},(B)=>{if(J)J($,B)});else if(U)HH(U,()=>{if(X)X($)},(B)=>{if(J)J($,B)});$.querySelectorAll("source[data-srcset]").forEach((B)=>{let z=B;if(z.dataset.srcset)z.srcset=z.dataset.srcset,delete z.dataset.srcset;if(z.dataset.sizes)z.sizes=z.dataset.sizes,delete z.dataset.sizes})}}function jH($,Z,Y){let X=()=>{$.classList.add("stx-img-loaded"),$.style.opacity="1";let Q=$.closest(".stx-img-placeholder");if(Q)Q.classList.add("stx-img-loaded");if(Z)Z($)},J=()=>{if($.classList.add("stx-img-error"),Y)Y($,Error(`Failed to load image: ${$.src}`))};if($.addEventListener("load",X,{once:!0}),$.addEventListener("error",J,{once:!0}),$.dataset.srcset)$.srcset=$.dataset.srcset,delete $.dataset.srcset;if($.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.sizes)$.sizes=$.dataset.sizes,delete $.dataset.sizes}function HH($,Z,Y){let X=()=>{if($.classList.add("stx-video-loaded"),Z)Z($)},J=()=>{if($.classList.add("stx-video-error"),Y)Y($,Error(`Failed to load video: ${$.src}`))};if($.addEventListener("loadeddata",X,{once:!0}),$.addEventListener("error",J,{once:!0}),$.querySelectorAll("source[data-src]").forEach((G)=>{let K=G;if(K.dataset.src)K.src=K.dataset.src,delete K.dataset.src}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src;if($.dataset.poster)$.poster=$.dataset.poster,delete $.dataset.poster;$.load()}function Jk($,Z,Y){let X=()=>{if($.classList.add("stx-iframe-loaded"),Z)Z($)},J=()=>{if($.classList.add("stx-iframe-error"),Y)Y($,Error(`Failed to load iframe: ${$.src}`))};if($.addEventListener("load",X,{once:!0}),$.addEventListener("error",J,{once:!0}),$.dataset.src)$.src=$.dataset.src,delete $.dataset.src}function gQ($){U6($,{})}function fQ($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>U6(Y,{}))}function hQ($={}){let Z={...LH,...$};return new IntersectionObserver((Y,X)=>{Y.forEach((J)=>{if(J.isIntersecting)U6(J.target,Z),X.unobserve(J.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function dQ($,Z){$.observe(Z)}function mQ($){$.disconnect()}function E7(){return`
14316
14316
  (function() {
14317
14317
  'use strict';
14318
14318
 
@@ -14571,7 +14571,7 @@ else {
14571
14571
  })();
14572
14572
  `.trim()}var Wk;var tQ=D(()=>{Wk={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1}});function eQ(){return{script:[E7(),I7(),k7()].join(`
14573
14573
 
14574
- `),css:D7()}}function VH(){let{script:$,css:Z}=eQ(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),X=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:X}}var AH=D(()=>{uQ();rQ();tQ();uQ();rQ();tQ()});var NH=D(()=>{S4();S9()});var Bk;var RH=D(()=>{QH();WX();IX();TX();KH();_H();AH();NH();Bk={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}}});import d3 from"fs";import K6 from"path";async function $G($,Z={},Y={}){let X=await Bun.file($).text(),J=X.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=J?X.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):X;G=G.replace(/<script\s+client\s*>/gi,"<script>");let K={__filename:$,__dirname:K6.dirname($),props:Z,...Z};if(Q)await V0(Q,K,$);let W={...Q1,...Y};return await J0(G,K,$,W,new Set)}async function wH($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:X,outputDir:J,componentsDir:Q=K6.join(X,"components"),layoutsDir:G=K6.join(X,"layouts"),partialsDir:K=K6.join(X,"partials"),globalProps:W={},placeholders:U={},views:_,debug:B=!1,generateManifest:z=!0}=$;if(B)console.log("Building STX views..."),console.log(` Source: ${X}`),console.log(` Output: ${J}`);d3.mkdirSync(J,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:B},j;if(_&&_.length>0)j=_;else j=d3.readdirSync(X).filter((L)=>L.endsWith(".stx")).map((L)=>({input:L}));for(let H of j){let L=K6.join(X,H.input),F=H.output||H.input.replace(/\.stx$/,".html"),O=K6.join(J,F);if(B)console.log(` Building ${H.input}...`);try{let V={...W,...H.props,...U},N=await $G(L,V,q);await Bun.write(O,N),Y.views.push(F)}catch(V){let N=V instanceof Error?V.message:String(V);if(Y.errors.push({file:H.input,error:N}),Y.success=!1,B)console.error(` Error: ${N}`)}}if(z){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(K6.join(J,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,B)if(Y.success)console.log(`
14574
+ `),css:D7()}}function VH(){let{script:$,css:Z}=eQ(),Y=$.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim(),X=Z.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s+/g," ").replace(/\s*([{};,:])\s*/g,"$1").trim();return{script:Y,css:X}}var AH=D(()=>{uQ();rQ();tQ();uQ();rQ();tQ()});var NH=D(()=>{S6();S9()});var Bk;var RH=D(()=>{QH();WX();IX();TX();KH();_H();AH();NH();Bk={enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3]},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}}});import d3 from"fs";import K4 from"path";async function $G($,Z={},Y={}){let X=await Bun.file($).text(),J=X.match(/<script\s+server\s*>([\s\S]*?)<\/script>/i),Q=J?J[1]:"",G=J?X.replace(/<script\s+server\s*>[\s\S]*?<\/script>/i,""):X;G=G.replace(/<script\s+client\s*>/gi,"<script>");let K={__filename:$,__dirname:K4.dirname($),props:Z,...Z};if(Q)await V0(Q,K,$);let W={...Q1,...Y};return await J0(G,K,$,W,new Set)}async function wH($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:X,outputDir:J,componentsDir:Q=K4.join(X,"components"),layoutsDir:G=K4.join(X,"layouts"),partialsDir:K=K4.join(X,"partials"),globalProps:W={},placeholders:U={},views:_,debug:B=!1,generateManifest:z=!0}=$;if(B)console.log("Building STX views..."),console.log(` Source: ${X}`),console.log(` Output: ${J}`);d3.mkdirSync(J,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:B},j;if(_&&_.length>0)j=_;else j=d3.readdirSync(X).filter((L)=>L.endsWith(".stx")).map((L)=>({input:L}));for(let H of j){let L=K4.join(X,H.input),F=H.output||H.input.replace(/\.stx$/,".html"),O=K4.join(J,F);if(B)console.log(` Building ${H.input}...`);try{let V={...W,...H.props,...U},N=await $G(L,V,q);await Bun.write(O,N),Y.views.push(F)}catch(V){let N=V instanceof Error?V.message:String(V);if(Y.errors.push({file:H.input,error:N}),Y.success=!1,B)console.error(` Error: ${N}`)}}if(z){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(K4.join(J,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,B)if(Y.success)console.log(`
14575
14575
  \u2705 Built ${Y.views.length} views in ${Y.duration.toFixed(0)}ms`);else console.log(`
14576
14576
  \u26A0\uFE0F Built ${Y.views.length} views with ${Y.errors.length} errors`);return Y}function zk($,Z){let Y=d3.watch($.viewsDir,{recursive:!0},async(X,J)=>{if(!J)return;if(J.endsWith(".stx")||J.endsWith(".ts")||J.endsWith(".js")){if($.debug)console.log(`
14577
14577
  File changed: ${J}, rebuilding...`);let Q=await wH($);Z?.(Q)}});return{close:()=>Y.close()}}async function qk($,Z={},Y={}){let X={...Y,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},J=await $G($,Z,X);J=await jk(J),J=J.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),J=J.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),J=J.replace(/<!--\s*stx SEO Tags\s*-->/gi,""),J=J.replace(/\n\s*\n\s*\n/g,`
@@ -14580,7 +14580,7 @@ File changed: ${J}, rebuilding...`);let Q=await wH($);Z?.(Q)}});return{close:()=
14580
14580
  `).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
14581
14581
  `).replace(/<\/td>/gi,"\t").replace(/<[^>]*>/g,"").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#39;/g,"'").replace(/&copy;/g,"(c)").replace(/&middot;/g,"-").replace(/\n\s*\n\s*\n/g,`
14582
14582
 
14583
- `).trim()}var MH=D(()=>{w4();u0();J1()});function Ok($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Fk($){let Z={};for(let Y of Object.keys($))if(!Y.startsWith("__"))Z[Y]=$[Y];return Z}function Vk($){let{template:Z,context:Y={},title:X="stx App"}=$,J=Fk(Y),Q=Ok(JSON.stringify(J));return`<!DOCTYPE html>
14583
+ `).trim()}var MH=D(()=>{w6();u0();J1()});function Ok($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Fk($){let Z={};for(let Y of Object.keys($))if(!Y.startsWith("__"))Z[Y]=$[Y];return Z}function Vk($){let{template:Z,context:Y={},title:X="stx App"}=$,J=Fk(Y),Q=Ok(JSON.stringify(J));return`<!DOCTYPE html>
14584
14584
  <html lang="en">
14585
14585
  <head>
14586
14586
  <meta charset="UTF-8">
@@ -14665,7 +14665,7 @@ File changed: ${J}, rebuilding...`);let Q=await wH($);Z?.(Q)}});return{close:()=
14665
14665
  return refs;
14666
14666
  };
14667
14667
  })();
14668
- `}var i1=null,m3;var ZG=D(()=>{m3=new Map});function Nk($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function YG($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function hH($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[vH($)];return $.flat(1/0).map(vH).filter((Z)=>Z!=="")}function vH($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function _6($,Z,Y){let{children:X,ref:J,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:hH(X),key:Y??Q??void 0,ref:J??void 0}}function uH($){return Object.entries($).filter(([,Z])=>Z!=null&&Z!==!1).map(([Z,Y])=>{let X=Z.replace(/[A-Z]/g,(Q)=>`-${Q.toLowerCase()}`),J=typeof Y==="number"&&!X.startsWith("--")&&X!=="opacity"&&X!=="z-index"&&X!=="flex-grow"&&X!=="flex-shrink"&&X!=="order"&&X!=="font-weight"&&X!=="line-height"?`${Y}px`:String(Y);return`${X}: ${J}`}).join("; ")}function XG($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(XG).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function Rk($){if(!$)return"";let Z=[];for(let[Y,X]of Object.entries($)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;if(Y.startsWith("on")&&typeof X==="function")continue;let J=fH[Y]||Y;if(J==="class"||J==="className"){let Q=XG(X);if(Q)Z.push(` class="${YG(Q)}"`);continue}if(J==="style"){let Q=typeof X==="string"?X:uH(X);if(Q)Z.push(` style="${YG(Q)}"`);continue}if(gH.has(J)){if(X)Z.push(` ${J}`);continue}if(X!=null&&X!==!1)Z.push(` ${J}="${YG(String(X))}"`)}return Z.join("")}function W6($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return Nk($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(W6).join("");if($.type===U6)return $.children.map(W6).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return W6(Q)}let Z=$.type,Y=Rk($.props),X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)return`<${Z}${Y}>${X}</${Z}>`;if(Ak.has(Z))return`<${Z}${Y}>`;let J=$.children.map(W6).join("");return`<${Z}${Y}>${J}</${Z}>`}function cH($){return new ReadableStream({start(Z){Z.enqueue(W6($)),Z.close()}})}function wk($,Z){if(!Z)return;for(let[Y,X]of Object.entries(Z)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;let J=fH[Y]||Y;if(Y.startsWith("on")&&typeof X==="function"){let Q=Y.slice(2).toLowerCase();$.addEventListener(Q,X);continue}if(J==="class"||J==="className"){let Q=XG(X);if(Q)$.setAttribute("class",Q);continue}if(J==="style"){let Q=typeof X==="string"?X:uH(X);if(Q)$.setAttribute("style",Q);continue}if(gH.has(J)){if(X)$.setAttribute(J,"");continue}if(X!=null&&X!==!1)$.setAttribute(J,String(X))}}function b$($,Z){if($==null||typeof $==="boolean")return;if(typeof $==="string"){Z.appendChild(document.createTextNode($));return}if(typeof $==="number"){Z.appendChild(document.createTextNode(String($)));return}if(Array.isArray($)){for(let J of $)b$(J,Z);return}if($.type===U6){for(let J of $.children)b$(J,Z);return}if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});b$(J,Z);return}let Y=document.createElement($.type);wk(Y,$.props);let X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)Y.innerHTML=X;else for(let J of $.children)b$(J,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function lH($){if($.when)return _6(U6,{children:$.children});return $.fallback??null}function pH($){let Z=$.each;if(!Z||Z.length===0)return $.fallback??null;let Y=Array.isArray($.children)?$.children[0]:$.children,X=Z.map((J,Q)=>Y(J,Q));return _6(U6,{children:X})}function iH($){return _6(U6,{children:$.children})}function nH($,Z,...Y){let{key:X,ref:J,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:hH(Y.length===1?Y[0]:Y),key:X??void 0,ref:J??void 0}}var U6,Ak,gH,fH,dH,mH;var rH=D(()=>{U6=Symbol.for("stx.Fragment"),Ak=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),gH=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),fH={className:"class",htmlFor:"for",tabIndex:"tabindex",autoFocus:"autofocus",autoPlay:"autoplay",crossOrigin:"crossorigin",dateTime:"datetime",encType:"enctype",formAction:"formaction",formEncType:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",frameBorder:"frameborder",hrefLang:"hreflang",httpEquiv:"http-equiv",inputMode:"inputmode",maxLength:"maxlength",mediaGroup:"mediagroup",minLength:"minlength",noModule:"nomodule",noValidate:"novalidate",playsInline:"playsinline",readOnly:"readonly",rowSpan:"rowspan",colSpan:"colspan",srcDoc:"srcdoc",srcLang:"srclang",srcSet:"srcset",useMap:"usemap"};dH=_6,mH=_6});function JG($,Z){let Y=new Set,X=new Map,J=new Map,Q={globalProperties:{},performance:!1,compilerOptions:{}},G={config:Q,_components:X,_directives:J,_installedPlugins:Y,use(K,...W){if(Y.has(K))return G;if(Y.add(K),typeof K==="function")K(G,...W);else if(typeof K.install==="function")K.install(G,...W);return G},provide(K,W){return u3(K,W),G},component(K,W){if(!W)return X.get(K);return X.set(K,W),G},directive(K,W){if(!W)return J.get(K);return J.set(K,W),G},mount(K){if(typeof document<"u"){let W=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(W,Q.globalProperties),document.querySelectorAll("[v-cloak]").forEach((U)=>{U.removeAttribute("v-cloak")})}return G},unmount(){X.clear(),J.clear(),Y.clear()}};return G}function sH($){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=$}connectedCallback(){if(this._component?.render){let Z=this._component.render();if(typeof Z==="string")this._shadow.innerHTML=Z}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}var aH=D(()=>{ZG()});import{dirname as Mk,resolve as oH}from"path";function Ek($){let Z=$,Y=$.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(Y&&Y.index!==void 0){let _=Y.index+Y[0].length,B=1,z=_;while(B>0&&z<$.length){let q=$.indexOf("<template",z),j=$.indexOf("</template>",z);if(j===-1)break;if(q!==-1&&q<j){let H=$[q+9];if(H===">"||H===" "||H===`
14668
+ `}var i1=null,m3;var ZG=D(()=>{m3=new Map});function Nk($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function YG($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function hH($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[vH($)];return $.flat(1/0).map(vH).filter((Z)=>Z!=="")}function vH($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function _4($,Z,Y){let{children:X,ref:J,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:hH(X),key:Y??Q??void 0,ref:J??void 0}}function uH($){return Object.entries($).filter(([,Z])=>Z!=null&&Z!==!1).map(([Z,Y])=>{let X=Z.replace(/[A-Z]/g,(Q)=>`-${Q.toLowerCase()}`),J=typeof Y==="number"&&!X.startsWith("--")&&X!=="opacity"&&X!=="z-index"&&X!=="flex-grow"&&X!=="flex-shrink"&&X!=="order"&&X!=="font-weight"&&X!=="line-height"?`${Y}px`:String(Y);return`${X}: ${J}`}).join("; ")}function XG($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(XG).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function Rk($){if(!$)return"";let Z=[];for(let[Y,X]of Object.entries($)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;if(Y.startsWith("on")&&typeof X==="function")continue;let J=fH[Y]||Y;if(J==="class"||J==="className"){let Q=XG(X);if(Q)Z.push(` class="${YG(Q)}"`);continue}if(J==="style"){let Q=typeof X==="string"?X:uH(X);if(Q)Z.push(` style="${YG(Q)}"`);continue}if(gH.has(J)){if(X)Z.push(` ${J}`);continue}if(X!=null&&X!==!1)Z.push(` ${J}="${YG(String(X))}"`)}return Z.join("")}function W4($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return Nk($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(W4).join("");if($.type===U4)return $.children.map(W4).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return W4(Q)}let Z=$.type,Y=Rk($.props),X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)return`<${Z}${Y}>${X}</${Z}>`;if(Ak.has(Z))return`<${Z}${Y}>`;let J=$.children.map(W4).join("");return`<${Z}${Y}>${J}</${Z}>`}function cH($){return new ReadableStream({start(Z){Z.enqueue(W4($)),Z.close()}})}function wk($,Z){if(!Z)return;for(let[Y,X]of Object.entries(Z)){if(Y==="key"||Y==="ref"||Y==="children"||Y==="innerHTML"||Y==="dangerouslySetInnerHTML")continue;let J=fH[Y]||Y;if(Y.startsWith("on")&&typeof X==="function"){let Q=Y.slice(2).toLowerCase();$.addEventListener(Q,X);continue}if(J==="class"||J==="className"){let Q=XG(X);if(Q)$.setAttribute("class",Q);continue}if(J==="style"){let Q=typeof X==="string"?X:uH(X);if(Q)$.setAttribute("style",Q);continue}if(gH.has(J)){if(X)$.setAttribute(J,"");continue}if(X!=null&&X!==!1)$.setAttribute(J,String(X))}}function b$($,Z){if($==null||typeof $==="boolean")return;if(typeof $==="string"){Z.appendChild(document.createTextNode($));return}if(typeof $==="number"){Z.appendChild(document.createTextNode(String($)));return}if(Array.isArray($)){for(let J of $)b$(J,Z);return}if($.type===U4){for(let J of $.children)b$(J,Z);return}if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});b$(J,Z);return}let Y=document.createElement($.type);wk(Y,$.props);let X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)Y.innerHTML=X;else for(let J of $.children)b$(J,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function lH($){if($.when)return _4(U4,{children:$.children});return $.fallback??null}function pH($){let Z=$.each;if(!Z||Z.length===0)return $.fallback??null;let Y=Array.isArray($.children)?$.children[0]:$.children,X=Z.map((J,Q)=>Y(J,Q));return _4(U4,{children:X})}function iH($){return _4(U4,{children:$.children})}function nH($,Z,...Y){let{key:X,ref:J,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:hH(Y.length===1?Y[0]:Y),key:X??void 0,ref:J??void 0}}var U4,Ak,gH,fH,dH,mH;var rH=D(()=>{U4=Symbol.for("stx.Fragment"),Ak=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),gH=new Set(["allowfullscreen","async","autofocus","autoplay","checked","controls","default","defer","disabled","formnovalidate","hidden","inert","ismap","itemscope","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","selected"]),fH={className:"class",htmlFor:"for",tabIndex:"tabindex",autoFocus:"autofocus",autoPlay:"autoplay",crossOrigin:"crossorigin",dateTime:"datetime",encType:"enctype",formAction:"formaction",formEncType:"formenctype",formMethod:"formmethod",formNoValidate:"formnovalidate",formTarget:"formtarget",frameBorder:"frameborder",hrefLang:"hreflang",httpEquiv:"http-equiv",inputMode:"inputmode",maxLength:"maxlength",mediaGroup:"mediagroup",minLength:"minlength",noModule:"nomodule",noValidate:"novalidate",playsInline:"playsinline",readOnly:"readonly",rowSpan:"rowspan",colSpan:"colspan",srcDoc:"srcdoc",srcLang:"srclang",srcSet:"srcset",useMap:"usemap"};dH=_4,mH=_4});function JG($,Z){let Y=new Set,X=new Map,J=new Map,Q={globalProperties:{},performance:!1,compilerOptions:{}},G={config:Q,_components:X,_directives:J,_installedPlugins:Y,use(K,...W){if(Y.has(K))return G;if(Y.add(K),typeof K==="function")K(G,...W);else if(typeof K.install==="function")K.install(G,...W);return G},provide(K,W){return u3(K,W),G},component(K,W){if(!W)return X.get(K);return X.set(K,W),G},directive(K,W){if(!W)return J.get(K);return J.set(K,W),G},mount(K){if(typeof document<"u"){let W=globalThis.__stx_globals||(globalThis.__stx_globals={});Object.assign(W,Q.globalProperties),document.querySelectorAll("[v-cloak]").forEach((U)=>{U.removeAttribute("v-cloak")})}return G},unmount(){X.clear(),J.clear(),Y.clear()}};return G}function sH($){return class extends HTMLElement{_component;_shadow;constructor(){super();this._shadow=this.attachShadow({mode:"open"}),this._component=$}connectedCallback(){if(this._component?.render){let Z=this._component.render();if(typeof Z==="string")this._shadow.innerHTML=Z}else if(this._component?.template)this._shadow.innerHTML=this._component.template;else if(typeof this._component==="string")this._shadow.innerHTML=this._component}disconnectedCallback(){this._shadow.innerHTML=""}}}var aH=D(()=>{ZG()});import{dirname as Mk,resolve as oH}from"path";function Ek($){let Z=$,Y=$.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(Y&&Y.index!==void 0){let _=Y.index+Y[0].length,B=1,z=_;while(B>0&&z<$.length){let q=$.indexOf("<template",z),j=$.indexOf("</template>",z);if(j===-1)break;if(q!==-1&&q<j){let H=$[q+9];if(H===">"||H===" "||H===`
14669
14669
  `||H==="\t")B++;z=q+9}else{if(B--,B===0){Z=$.slice(_,j).trim();break}z=j+11}}}let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,J=[],Q=[],G=[],K=(_)=>/\b(?:state|derived|effect|batch)\s*\(/.test(_),W;while((W=X.exec($))!==null){let _=W[1],B=W[2],z=W[0],q=_.includes("server");if(K(B))G.push(z);else if(q)Q.push(B);else J.push(z)}let U=Z;{let _=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,B,z=[];while((B=_.exec(U))!==null){let q=B.index+B[0].length,j=1,H=q;while(H<U.length&&j>0){let L=U.indexOf("<script",H),F=U.indexOf("</script>",H);if(F===-1)break;if(L!==-1&&L<F)j++,H=L+7;else{if(j--,j===0){z.push({start:B.index,end:F+9});break}H=F+9}}}for(let q=z.length-1;q>=0;q--)U=U.substring(0,z[q].start)+U.substring(z[q].end)}for(let _ of J)U=U.replace(_,"");return{templateContent:U,serverScripts:Q,clientScripts:J,signalsScripts:G}}function Tk($,Z){return`<!DOCTYPE html>
14670
14670
  <html lang="en">
14671
14671
  <head>
@@ -14678,13 +14678,13 @@ ${$}
14678
14678
  </body>
14679
14679
  </html>`}async function Ik($,Z={}){let Y=oH($),X=Bun.file(Y);if(!await X.exists())throw Error(`Template file not found: ${Y}`);let J=await X.text();if(Z.layout){let Q=oH(Z.layout),G=Bun.file(Q);if(!await G.exists())throw Error(`Layout template not found: ${Q}`);let{layout:K,injectCSS:W,...U}=Z,_=await c3(J,Y,{...U,injectCSS:!1}),B=await G.text(),z={...Z.context||{},content:_},q={...U,context:z,injectCSS:W};return c3(B,Q,q)}return c3(J,Y,Z)}async function Dk($,Z={},Y){return c3($,process.cwd(),{context:Z,...Y})}async function c3($,Z,Y={}){let{templateContent:X,serverScripts:J,clientScripts:Q}=Ek($),G={...Q1,...Y.options},K={__filename:Z,__dirname:Mk(Z),__stx:{},__stx_options:G,__stx_sfc_mode:!0,...Y.context||{}};for(let _ of J)await V0(_,K,Z);let W=new Set,U=X;if(U=await J0(U,K,Z,G,W),Y.templateOnly){if(U=U.replace(/<script data-stx-scoped>[\s\S]*?<\/script>\s*/gi,""),U=U.replace(/<!-- stx SEO Tags -->[\s\S]*?(?=<)/i,""),Q.length>0)U+=`
14680
14680
  ${Q.join(`
14681
- `)}`}else{if(Y.processClientScripts!==!1&&Q.length>0){let _=K.__stx_event_bindings||[],z=(await Promise.all(Q.map(async(j)=>{let H=j.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!H)return j;return await i4(H[1],{eventBindings:_,templateContent:U})}))).join(`
14681
+ `)}`}else{if(Y.processClientScripts!==!1&&Q.length>0){let _=K.__stx_event_bindings||[],z=(await Promise.all(Q.map(async(j)=>{let H=j.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!H)return j;return await i6(H[1],{eventBindings:_,templateContent:U})}))).join(`
14682
14682
  `);if(U.match(/(<\/body>)/i))U=U.replace(/(<\/body>)/i,`${z}
14683
14683
  $1`);else U+=`
14684
- ${z}`}U=await t1(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=Tk(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:_}=await Promise.resolve().then(() => (r1(),z8));U=await _(U)}catch{}return U}var tH=D(()=>{u0();w4();J1();m$()});function eH($,Z){return $.kind===Z}var $L=()=>{};var ZL=D(()=>{$L()});var X6={};t(X6,{writeNetlifyConfig:()=>r5,writeManifest:()=>HJ,writeImageManifest:()=>tX,wrapComponentForHMR:()=>uD,webComponentDirectiveHandler:()=>bX,watermark:()=>AQ,watchViews:()=>zk,watchMultiple:()=>OE,watchEffect:()=>FE,watch:()=>LE,waitForStore:()=>hE,waitForLocale:()=>FA,videoDirective:()=>h5,validators:()=>N8,validateValueEnhanced:()=>MW,validateTemplate:()=>HB,validateParams:()=>MQ,validateFormEnhanced:()=>WA,validateFile:()=>f3,validateFields:()=>GA,validateField:()=>RW,validateDirective:()=>OB,validateCspDirectives:()=>cV,validateConfig:()=>Nz,validateComponentScripts:()=>kT,validateComponentProps:()=>PT,validateClientScript:()=>R5,usesSignalsInScript:()=>i$,useVirtualList:()=>JY,useTitle:()=>zW,useStoreOrThrow:()=>fE,useStore:()=>ZH,useSlots:()=>CH,useSeoMeta:()=>J5,useRouteParams:()=>nz,useRouteParamOrThrow:()=>dE,useRouteParam:()=>rz,usePageTitle:()=>zW,useMiddlewareValue:()=>mE,useMiddlewareState:()=>sz,useLoadingIndicator:()=>hj,useHead:()=>A4,useAttrs:()=>PH,uploadFiles:()=>sQ,uploadFile:()=>h3,updateInstance:()=>TE,untrack:()=>K9,unregisterDirective:()=>Kw,unmountInstance:()=>IE,unescapeHtml:()=>U8,transpileTypeScript:()=>q4,transitionDirective:()=>$8,toUsers:()=>fq,toUser:()=>gq,thumbnail:()=>XQ,thumbHashToRGBA:()=>T7,thumbHashToDataURL:()=>lQ,templateCache:()=>b2,stxClientHelpers:()=>rJ,structuredDataDirective:()=>s8,stripDocumentWrapper:()=>Y6,stringToStream:()=>rT,strictCspPreset:()=>$W,streamingSuspenseDirective:()=>Cj,streamToResponse:()=>TD,streamTemplateSimple:()=>RD,streamTemplate:()=>ND,stopHmrServer:()=>q$,stopBroadcasting:()=>xq,state:()=>Z9,startProductionServer:()=>Aj,startInteractive:()=>jj,startBroadcasting:()=>yq,staggerDirective:()=>dG,srcsetUrls:()=>RQ,springDirective:()=>mG,splitByPipe:()=>R8,smartBatchSign:()=>IQ,signUrl:()=>S3,shouldTranspileTypeScript:()=>z4,shouldReloadOnChange:()=>u5,shouldRefreshSignature:()=>y3,shouldIgnoreFile:()=>c5,shouldCacheComponent:()=>v_,sharpen:()=>KQ,setRouteParams:()=>pE,setMiddlewareState:()=>iE,setGlobalProvide:()=>u3,setErrorLocale:()=>MK,setCurrentInstance:()=>BE,setCachedVideoResult:()=>Z$,setCachedImageResult:()=>t6,setCached:()=>r6,serveStxFile:()=>S7,serveMultipleStxFiles:()=>b7,serveMarkdownFile:()=>$3,serveFile:()=>OD,serveApp:()=>C7,serve:()=>kj,serializeState:()=>cj,sepia:()=>UQ,scrollAnimateDirective:()=>Z8,screenReaderDirective:()=>e7,scopeHTML:()=>Hz,scopeCSS:()=>jz,scanForSitemapEntries:()=>UN,scanA11yIssues:()=>QZ,saturation:()=>qQ,sanitizeParams:()=>EQ,sanitizeFilePath:()=>dK,sanitizeExpression:()=>mK,sanitizeDirectiveParams:()=>uK,sanitizeDirectiveParam:()=>Z5,sanitizeComponentProps:()=>dZ,safeExecuteAsync:()=>C1,safeExecute:()=>gK,runPreProcessingMiddleware:()=>L2,runPostProcessingMiddleware:()=>O2,runMiddleware:()=>J7,runHooks:()=>Z6,rotate:()=>jQ,resolveTemplatePath:()=>E5,resize:()=>ZQ,resetPlaceholders:()=>LZ,resetHead:()=>_W,resetHMRHandler:()=>lD,resetErrorConfig:()=>CK,replacePlaceholders:()=>W8,renderView:()=>$G,renderVideoComponent:()=>G$,renderToString:()=>W6,renderToStream:()=>cH,renderToDOM:()=>b$,renderThumbhashToCanvas:()=>cQ,renderTemplate:()=>Ik,renderString:()=>Dk,renderSlot:()=>DY,renderSSRSuspense:()=>A_,renderProtectedVideo:()=>PQ,renderProtectedImg:()=>CQ,renderMediaUpload:()=>TQ,renderImgComponent:()=>C4,renderImageComponent:()=>iX,renderHtmlAttrs:()=>jW,renderHead:()=>qW,renderEmail:()=>qk,renderComponentWithSlot:()=>y1,renderBodyAttrs:()=>HW,render:()=>sD,relaxedCspPreset:()=>ZW,registerValidationRule:()=>QA,registerStreamingDirectives:()=>MD,registerStore:()=>cE,registerSeoDirectives:()=>GN,registerMiddleware:()=>gE,registerFilters:()=>ZK,registerFilter:()=>FZ,registerErrorMessages:()=>TK,registerEnhancedValidationRule:()=>KA,registerDirective:()=>IB,registerCspDirectives:()=>uV,registerComponentDirectives:()=>vT,registerAnimationDirectives:()=>MF,registerA11yDirectives:()=>_F,ref:()=>jE,redirect:()=>YI,readMarkdownFile:()=>Z4,readFileCached:()=>qU,reactive:()=>lz,quality:()=>FQ,pruneSignatureCache:()=>SQ,pruneCache:()=>gB,provide:()=>EH,processVueTemplate:()=>M2,processVirtualListDirectives:()=>N9,processVirtualGridDirectives:()=>GY,processVideo:()=>c9,processValidateDirective:()=>wW,processTranslateDirective:()=>K2,processTransitionDirectives:()=>B_,processTransitionAttributes:()=>j_,processTitleDirective:()=>FW,processTemplateBindings:()=>DZ,processTeleportDirectives:()=>X_,processSuspenseDirectives:()=>F_,processStructuredData:()=>A2,processStaticDirectives:()=>VY,processStackReplacements:()=>n8,processStackPushDirectives:()=>i8,processSlots:()=>kY,processShell:()=>F3,processServerBindings:()=>o8,processSeoDirective:()=>N2,processSectionDirectives:()=>ED,processScopedStyles:()=>_5,processReactiveBindings:()=>zK,processProtectedMedia:()=>yQ,processPartialHydrationDirectives:()=>zY,processOnceDirective:()=>N5,processMiddleware:()=>H2,processMetaDirectives:()=>V2,processMetaDirective:()=>VW,processMarkdownFileDirectives:()=>TY,processMarkdownDirectives:()=>EY,processLoops:()=>c8,processKeepAliveDirectives:()=>y_,processJsonDirective:()=>A5,processInfiniteListDirectives:()=>QY,processIncludes:()=>p8,processImgComponents:()=>zX,processImageComponents:()=>nX,processImage:()=>m1,processHeadDirective:()=>OW,processForms:()=>JA,processFormInputDirectives:()=>y8,processExpressions:()=>A1,processEventDirectives:()=>PZ,processErrorDirective:()=>x8,processDynamicComponents:()=>T2,processDirectives:()=>J0,processDirectiveAttributes:()=>zw,processDeferDirectives:()=>$_,processCustomDirectives:()=>$2,processCspDirectives:()=>oZ,processClientScript:()=>i4,processBasicFormDirectives:()=>D6,processAsyncDirectives:()=>I_,processAnimationDirectives:()=>KZ,processA11yDirectives:()=>JZ,preloadTranslationsBackground:()=>LA,preloadTranslations:()=>DW,preloadIslandHandlers:()=>xD,poolStrings:()=>kq,pluginManager:()=>yX,performLeave:()=>__,performEnter:()=>U_,peek:()=>W9,partialsCache:()=>M4,parseVideoDirectiveOptions:()=>Uz,parseUrl:()=>$Q,parseThumbhashString:()=>pQ,parseSwitchBlock:()=>M8,parseSlots:()=>IY,parseSlotElement:()=>NB,parseScriptDeclarations:()=>oK,parseSFCComponent:()=>Lz,parseProtectedArgs:()=>xQ,parseImgComponent:()=>v9,parseImageUrl:()=>fY,parseImageComponent:()=>W3,parseExpressionWithFilters:()=>sK,parseCookies:()=>eT,parseConditionalBlock:()=>uZ,parseArguments:()=>cZ,parseAnimationShorthand:()=>RF,optimizeTemplate:()=>Sq,optimizeImage:()=>q3,optimizeDirectory:()=>oX,onceStore:()=>q2,onUpdated:()=>RE,onUnmounted:()=>ME,onServer:()=>rE,onMounted:()=>AE,onMount:()=>Q9,onHydrated:()=>FY,onErrorCaptured:()=>SH,onDestroy:()=>G9,onDeactivated:()=>d_,onClient:()=>nE,onBeforeUpdate:()=>NE,onBeforeUnmount:()=>wE,onBeforeMount:()=>VE,onActivated:()=>h_,observeElement:()=>dQ,notFound:()=>XI,nextTick:()=>kH,navigateTo:()=>vE,mountInstance:()=>EE,motionDirective:()=>X8,moderateCspPreset:()=>I8,minifyHtml:()=>Dq,metaDirective:()=>r8,mergeParams:()=>D3,mergeCspDirectives:()=>dV,matchRoute:()=>V3,markdownDirectiveHandler:()=>CY,markdownCache:()=>r9,loadTranslationLazy:()=>K5,loadTranslation:()=>bW,loadStxConfig:()=>f0,loadMiddlewareFromDirectory:()=>X7,loadManifest:()=>LJ,loadElement:()=>U4,loadChannels:()=>vq,lazyLoadAll:()=>fQ,lazyLoad:()=>gQ,keyframeDirective:()=>hG,jsxs:()=>dH,jsxDEV:()=>mH,jsx:()=>_6,jsonResponse:()=>ZI,islandDirective:()=>Pj,isTest:()=>TV,isSpaNavigation:()=>JJ,isSignatureValid:()=>C3,isSignal:()=>q5,isSharpAvailable:()=>d1,isServerEnvironment:()=>fT,isServer:()=>az,isProduction:()=>kK,isNativeLazySupported:()=>x3,isLoading:()=>jA,isLoaded:()=>HA,isJavaScriptScript:()=>TB,isIntersectionObserverSupported:()=>v3,isImageFile:()=>o5,isICUFormat:()=>yW,isHydrated:()=>OY,isEdgeEnvironment:()=>gT,isDirectiveKind:()=>eH,isDevelopment:()=>H4,isDerived:()=>j5,isCssOnlyChange:()=>m5,isClient:()=>oz,isAsyncComponent:()=>k_,invert:()=>_Q,invalidateFileCacheByDir:()=>HU,invalidateFileCache:()=>jU,interpolateScriptsInTemplate:()=>XK,interpolateScriptExpressions:()=>AZ,inlineError:()=>G0,injectSeoTags:()=>R2,injectRouterScript:()=>t1,injectHotReload:()=>f1,injectHeatmap:()=>_Z,injectCspMetaTag:()=>aZ,injectCrosswindCSS:()=>D0,injectAnalytics:()=>bZ,inject:()=>TH,initStoreRegistry:()=>uE,initNetlify:()=>Sz,initLoadingIndicator:()=>hD,initLazyLoading:()=>vQ,initFile:()=>bJ,initBlurUp:()=>g3,initAllBlurUp:()=>nQ,imgDirective:()=>g5,imageDirective:()=>sX,hydrateTemplate:()=>xJ,hydrateIslands:()=>yD,hydrateIsland:()=>jY,hydrateFragment:()=>TI,hydrateByStrategy:()=>HY,hydrateAll:()=>LY,hydrate:()=>nD,htmlResponse:()=>LD,heatmapDirective:()=>BZ,hashString:()=>k9,hashFilePath:()=>C6,hashFile:()=>l0,hashBuffer:()=>bB,hasVueTemplateSyntax:()=>KU,hasVariables:()=>B2,hasStore:()=>ej,hasPlaceholders:()=>L6,hasNetlifyConfig:()=>s5,hasMiddleware:()=>xE,hasEventDirectives:()=>HV,hasDocumentShell:()=>zU,hasDirectives:()=>FB,hasDOMSupport:()=>PG,handleError:()=>bH,h:()=>nH,groupVariantsByFormat:()=>V$,grayscale:()=>WQ,gitHash:()=>fJ,getUnusedDirectives:()=>wq,getTranslationSync:()=>kW,getTranslationCacheStats:()=>BA,getTranslationAsync:()=>OA,getTranslation:()=>v8,getTotalSize:()=>Y4,getTimeUntilExpiry:()=>P3,getStoreNames:()=>$H,getStore:()=>tJ,getSourceLineInfo:()=>bY,getScreenReaderOnlyStyle:()=>GF,getScopeAttribute:()=>RM,getRouteParams:()=>JT,getPositionInfo:()=>LB,getPlaceholderRegistry:()=>OZ,getPlaceholderCacheStats:()=>tY,getPageMeta:()=>S8,getNonce:()=>F4,getMimeType:()=>u1,getMiddlewareNames:()=>Y7,getMiddleware:()=>yE,getLoadingState:()=>qA,getLoadingLocales:()=>VA,getImageMetadata:()=>a5,getHydrationRuntime:()=>nj,getHydratedStoreState:()=>lE,getHmrServer:()=>l5,getHead:()=>I6,getHMRHandler:()=>cD,getFormatExtension:()=>uY,getFileMtime:()=>y5,getFallbackVariant:()=>F$,getErrorMessage:()=>vZ,getErrorLocale:()=>EK,getErrorConfig:()=>t$,getErrorCodeName:()=>H8,getDirectives:()=>Gw,getDirective:()=>Qw,getCurrentInstance:()=>zE,getCspPreset:()=>hV,getCspHeaderName:()=>QW,getComponentCacheStats:()=>Jw,getCachedVideoResult:()=>$$,getCachedSignature:()=>DQ,getCachedSignalsRuntime:()=>LU,getCachedRouterScript:()=>OU,getCachedPlaceholder:()=>P5,getCachedImageResult:()=>o6,getCached:()=>n6,getCacheStats:()=>vB,getBroadcastServer:()=>Pq,getBestVariant:()=>mY,getAllFilters:()=>VZ,generateWidthSrcset:()=>k4,generateVirtualListCSS:()=>XY,generateVideoPreview:()=>oQ,generateValidationScript:()=>UA,generateUploadRuntime:()=>k7,generateTreeShakenBundle:()=>Mq,generateTransitionRuntime:()=>q_,generateTransitionCSS:()=>z_,generateThumbnails:()=>X$,generateThumbhashPlaceholder:()=>pY,generateTemplatesDocs:()=>oq,generateSuspenseRuntime:()=>R_,generateSuspenseCSS:()=>N_,generateStateScript:()=>pj,generateSrcsetData:()=>hY,generateSrcset:()=>P9,generateSrcSet:()=>$6,generateSpriteSheet:()=>m9,generateSpaShell:()=>Vk,generateSourceTags:()=>dY,generateSizesFromBreakpoints:()=>vY,generateSizesAttribute:()=>u6,generateSizes:()=>O$,generateSitemapIndex:()=>WN,generateSitemap:()=>KN,generateSimpleMediaPicker:()=>qH,generateSignatureRuntime:()=>M7,generateSignalsRuntimeDev:()=>s4,generateSignalsRuntime:()=>H5,generateScopeId:()=>p9,generateSFCWebComponent:()=>Oz,generateRouteTypes:()=>GT,generateRouteManifest:()=>QT,generateRobotsTxt:()=>ZU,generateResponsiveVariants:()=>C9,generateReactiveWebComponentTS:()=>EM,generateReactiveWebComponent:()=>MM,generateReactiveRuntime:()=>IM,generateReactiveMixin:()=>TM,generatePoster:()=>Y$,generatePlaceholderStyle:()=>aY,generatePlaceholderCSS:()=>C5,generatePlaceholder:()=>b5,generatePartialHydrationCSS:()=>qY,generateNonce:()=>rZ,generateNetlifyToml:()=>Y3,generateMinifiedMediaRuntime:()=>VH,generateMediaRuntime:()=>eQ,generateMediaManagerEmbed:()=>zH,generateManifest:()=>jJ,generateLoadingIndicatorHtml:()=>dD,generateLazyLoadRuntime:()=>E7,generateLQIP:()=>nY,generateKeepAliveRuntime:()=>f_,generateKeepAliveCSS:()=>g_,generateIslandManifest:()=>AY,generateImagePreview:()=>aQ,generateImageManifest:()=>j3,generateHydrationScript:()=>iD,generateHydrationRuntime:()=>ID,generateHydrationCSS:()=>rD,generateHydrationBootstrap:()=>WY,generateHotReloadScript:()=>Dz,generateHeatmapScript:()=>UZ,generateHMRClientScript:()=>mD,generateHLSManifest:()=>J$,generateEventBindings:()=>pD,generateDprSrcsetWithVariableQuality:()=>xY,generateDprSrcset:()=>m6,generateDocumentShell:()=>BU,generateDocs:()=>Yj,generateDirectivesDocs:()=>tq,generateDirectiveRuntime:()=>Bw,generateDefaultRobotsTxt:()=>_N,generateDASHManifest:()=>Q$,generateCspMetaTag:()=>D8,generateCspHeader:()=>sZ,generateCrosswindCSS:()=>B8,generateCompositionRuntime:()=>xH,generateComponentsDocs:()=>aq,generateComponentManifest:()=>ER,generateComponentDoc:()=>sq,generateColorPlaceholder:()=>sY,generateClientRuntime:()=>DE,generateCacheKey:()=>p6,generateBlurUpRuntime:()=>I7,generateBlurUpCSS:()=>D7,generateBindingsRuntime:()=>qK,generateAutoWidthSrcset:()=>yY,generateAsyncComponentRuntime:()=>b_,generateAsyncComponentCSS:()=>S_,generateAnimationRuntime:()=>wF,generateAnimationCSS:()=>NF,generateAnalyticsScript:()=>SZ,formatTypeErrors:()=>PD,formatStxContent:()=>M3,formatSize:()=>v4,formatRoutes:()=>GJ,formatMarkdownContent:()=>DJ,formatLocalizedError:()=>DK,formatICU:()=>CW,formatFilePath:()=>e$,formatError:()=>F8,formatDocsAsMarkdown:()=>eq,formatDocsAsJson:()=>Zj,formatDocsAsHtml:()=>$j,format:()=>OQ,foldConstants:()=>Iq,flipVertical:()=>LQ,flipHorizontal:()=>HQ,fingerprint:()=>KJ,findMatchingEndTag:()=>O4,findMatchingDelimiter:()=>v0,findIfBlocks:()=>w8,findExpressions:()=>rK,findErrorPage:()=>QJ,findDirectiveBlocks:()=>X5,findDeadCode:()=>Eq,findDeadBranches:()=>Eq,findComponentFiles:()=>MJ,findCommonDir:()=>QG,filterRequiredFiles:()=>n5,fileExists:()=>$0,extractVariables:()=>V0,extractState:()=>ij,extractSlotContent:()=>wB,extractScriptFromTemplate:()=>_2,extractPlaceholders:()=>nF,extractParenthesizedExpression:()=>a1,extractDominantColor:()=>rY,extractDirectiveParams:()=>aK,extractDirectiveNames:()=>VB,extractContainerContent:()=>K7,extractComponentProps:()=>nq,extractComponentName:()=>UY,extractComponentDescription:()=>rq,extractClassNames:()=>_8,extractBoundProps:()=>_Y,extractBalancedExpression:()=>mZ,extractAndScopeStyles:()=>wM,extractAndProcessEvents:()=>VK,evaluateExpression:()=>W1,evaluateConstant:()=>R3,evaluateAuthExpression:()=>s1,escapeHtml:()=>I0,errorRecovery:()=>V8,errorLogger:()=>q1,ensureTeleportTargets:()=>J_,ensureDocumentShell:()=>B5,enhancedValidationRules:()=>X2,eliminateDeadCode:()=>Tq,effect:()=>X9,dprUrls:()=>wQ,docsCommand:()=>EJ,disconnectObserver:()=>mQ,devHelpers:()=>E6,detectShell:()=>XJ,detectRuntime:()=>E$,detectProjectConfig:()=>H$,detectFormat:()=>cY,detectBuildMode:()=>DT,derived:()=>Y9,deploy:()=>kz,defineStxConfig:()=>Az,defineStore:()=>YH,definePlugin:()=>W$,definePageMeta:()=>BW,defineMiddleware:()=>PE,defineExpose:()=>DH,defineEmits:()=>IH,defineDirective:()=>b0,defineCustomElement:()=>sH,defineConfig:()=>EI,defineClientDirective:()=>Ww,defineAsyncComponent:()=>D_,defaultMediaConfig:()=>Bk,defaultImageConfig:()=>dz,defaultI18nConfig:()=>g8,defaultHeatmapConfig:()=>pG,defaultFormClasses:()=>P8,defaultFilters:()=>O6,defaultCspConfig:()=>pV,defaultConfig:()=>Q1,default:()=>kk,decodeThumbhash:()=>iY,cspNonceDirective:()=>JW,cspDirective:()=>XW,crossfadeTransition:()=>iQ,crop:()=>YQ,createVirtualList:()=>A9,createVideoDirective:()=>l9,createVercelHandler:()=>oT,createTypeChecker:()=>cJ,createTranslateFilter:()=>vA,createTextEncoderStream:()=>nT,createStxApp:()=>JG,createStreamingResponse:()=>iT,createStreamRenderer:()=>wD,createStore:()=>eJ,createStorageManager:()=>CE,createServerCookieManager:()=>bE,createScope:()=>cz,createSSRSuspense:()=>V_,createRouter:()=>G4,createRouteLocation:()=>Z7,createRoute:()=>VD,createRef:()=>jE,createReactive:()=>lz,createProvideContext:()=>yH,createProject:()=>bI,createProductionBuild:()=>MI,createPlaceholder:()=>c$,createOptimizedBuild:()=>ST,createNetlifyHandler:()=>tT,createNetlifyClient:()=>p5,createMiddlewareContext:()=>$7,createMiddleware:()=>FD,createLazyObserver:()=>hQ,createKeepAliveCache:()=>x_,createKVNamespace:()=>Qj,createIslandRegistry:()=>BY,createImgDirective:()=>g9,createImagePlugin:()=>aX,createImageDirective:()=>B3,createHeatmapAggregator:()=>IF,createFileManifest:()=>i5,createEnvAccessor:()=>Jj,createEnhancedError:()=>vK,createEdgeHandler:()=>z7,createEdgeCache:()=>Gj,createDetailedErrorMessage:()=>O0,createDenoHandler:()=>aT,createDefaultNetlifyConfig:()=>L$,createCspHeaders:()=>lV,createCookie:()=>$I,createComputed:()=>HE,createComponentInstance:()=>qE,createCloudflareHandler:()=>sT,createClientCookieManager:()=>SE,createBuiltinDirectives:()=>_w,createApp:()=>JG,createAnimationTimeline:()=>AF,cover:()=>QQ,convertToCommonJS:()=>f8,contrast:()=>zQ,contain:()=>JQ,consoleError:()=>xK,configureErrorHandling:()=>bK,config:()=>G1,computed:()=>HE,composeShellWithPage:()=>G7,componentDirective:()=>pq,compileTemplate:()=>BJ,collectDeployFiles:()=>j$,clearVideoCache:()=>h9,clearTranslationCache:()=>_A,clearSignatureCache:()=>kQ,clearPlaceholderCache:()=>oY,clearOnceStore:()=>YN,clearNonce:()=>fV,clearMiddleware:()=>e5,clearImageCache:()=>_3,clearErrorMessages:()=>IK,clearDevCaches:()=>FU,clearCustomFilters:()=>YK,clearComponentCache:()=>D4,clearCache:()=>s6,classifyScript:()=>$q,classifyAllScripts:()=>$J,checkTemplateFile:()=>bD,checkTemplate:()=>CD,checkCache:()=>B9,checkAuthAccess:()=>S$,checkA11y:()=>o7,channel:()=>mq,cancelPendingLoads:()=>AA,calculateSha1:()=>Z3,calculateOptimalWidths:()=>T9,cacheTemplate:()=>z9,buildWebComponents:()=>kX,buildViews:()=>wH,buildUrl:()=>A0,buildRuntimeAsset:()=>WJ,buildRouterAsset:()=>UJ,buildImageUrl:()=>M1,buildForProduction:()=>jq,buildAuthParams:()=>w7,buildApp:()=>Lq,build:()=>wI,broadcastPrivate:()=>hq,broadcastPresence:()=>dq,broadcast:()=>NJ,brightness:()=>BQ,blur:()=>GQ,batchSignUrls:()=>b3,batch:()=>J9,autoFixA11yFile:()=>xG,autoFixA11yDirectory:()=>UF,autoFixA11y:()=>yG,auto:()=>VQ,assetTags:()=>NT,applyTransformations:()=>v5,applySlots:()=>MB,applyPropDefaults:()=>yT,applyPreset:()=>NQ,applyHead:()=>LW,applyFilters:()=>NZ,apiCspPreset:()=>YW,animationGroupDirective:()=>Y8,analyzeVideo:()=>f5,analyzeUsage:()=>VJ,analyzeTemplate:()=>ez,analyzeProject:()=>eX,analyzeDirectiveUsage:()=>VJ,analyticsDirective:()=>UV,addStore:()=>vI,addPage:()=>xI,addNonceToInlineContent:()=>mV,addLayout:()=>gI,addComponent:()=>yI,abortNavigation:()=>kE,a11yDirective:()=>t7,VideoProcessorCache:()=>e6,TransitionType:()=>vG,TransitionEase:()=>fG,TransitionDirection:()=>gG,Tokenizer:()=>Y5,TemplateTypeChecker:()=>uJ,TEMPLATE_PRESETS:()=>_I,StxValidationError:()=>$5,StxSyntaxError:()=>gZ,StxSecurityError:()=>fZ,StxRuntimeError:()=>R1,StxFileError:()=>M6,StxError:()=>L4,Show:()=>lH,SPRING_PRESETS:()=>GZ,ProductionBuild:()=>E3,Portal:()=>iH,PROJECT_TEMPLATES:()=>SI,PRESETS:()=>k3,MemorySessionStore:()=>aj,MIME_TYPES:()=>k5,MEDIA_DEFAULT_WIDTHS:()=>g1,MEDIA_DEFAULT_FORMATS:()=>$4,ImageProcessorCache:()=>a6,ImageProcessingError:()=>A$,HydrationRuntime:()=>oJ,HotReloadServer:()=>mX,HeatmapAggregator:()=>zZ,Fragment:()=>U6,For:()=>pH,ErrorLogger:()=>A8,ErrorCodes:()=>e,DeployError:()=>J4,DEFAULT_WIDTHS:()=>H1,DEFAULT_TRANSITION_OPTIONS:()=>k1,DEFAULT_QUALITY:()=>O1,DEFAULT_PLACEHOLDER_OPTIONS:()=>D9,DEFAULT_FORMATS:()=>L1,DEFAULT_DPR_VALUES:()=>D5,ComponentHMRHandler:()=>sJ,COMMON_SIZES:()=>gY,BroadcastServer:()=>cq,Broadcast:()=>uq,BLUR_UP_CSS:()=>l6});var kk;var g4=D(()=>{X3();H3();H0();XH();w2();ZG();rH();aH();xX();r1();pz();N4();L3();J2();H6();CZ();J8();d6();W7();xZ();FJ();_J();Aq();bq();w3();q9();iq();u0();tZ();Z2();X3();GG();I5();TJ();Kj();_1();yZ();r0();kJ();Q8();W2();k6();CJ();PJ();l8();M9();F2();E8();A3();l$();J1();Fj();OJ();gJ();U7();Dj();ZJ();a8();Sj();t8();zJ();vJ();yj();vj();CX();KY();NY();gj();dj();kZ();m$();uj();rj();oj();H3();RH();MH();L5();E2();I2();tH();H0();SY();ZL();kk={}});import P7 from"path";var C$;var l3=D(()=>{g4();_1();r0();j4();J1();C$={name:"bun-plugin-stx",async setup($){let Y={...await f0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${P7.relative(P7.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await kX(Y,X);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await B9(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await C1(()=>Bun.file(G).text(),"",(H)=>{throw new M6(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new M6(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:B}=N1.time("script-extraction",()=>{let H=W,L=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(L)H=L[1].trim();let F=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",V=[];for(let A of F){let R=A.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",M=A.match(/<script\b([^>]*)>/i),E=M?M[1]:"";if(/\bserver\b/i.test(E))O=R;else V.push(A)}let N=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:N,allScripts:V}}),z={__filename:G,__dirname:P7.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await C1(()=>V0(U,z,G),void 0,(H)=>{let L=new R1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(q1.log(L,{filePath:G,scriptContent:U}),Y.debug)throw L});let j=await N1.timeAsync("directive-processing",async()=>{return await J0(_,z,G,Y,K)});if(B.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (r0(),n$)),L=H(B.join(`
14684
+ ${z}`}U=await t1(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=Tk(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:_}=await Promise.resolve().then(() => (r1(),z8));U=await _(U)}catch{}return U}var tH=D(()=>{u0();w6();J1();m$()});function eH($,Z){return $.kind===Z}var $L=()=>{};var ZL=D(()=>{$L()});var X4={};t(X4,{writeNetlifyConfig:()=>r5,writeManifest:()=>HJ,writeImageManifest:()=>tX,wrapComponentForHMR:()=>uD,webComponentDirectiveHandler:()=>bX,watermark:()=>AQ,watchViews:()=>zk,watchMultiple:()=>OE,watchEffect:()=>FE,watch:()=>LE,waitForStore:()=>hE,waitForLocale:()=>FA,videoDirective:()=>h5,validators:()=>N8,validateValueEnhanced:()=>MW,validateTemplate:()=>HB,validateParams:()=>MQ,validateFormEnhanced:()=>WA,validateFile:()=>f3,validateFields:()=>GA,validateField:()=>RW,validateDirective:()=>OB,validateCspDirectives:()=>cV,validateConfig:()=>Nz,validateComponentScripts:()=>kT,validateComponentProps:()=>PT,validateClientScript:()=>R5,usesSignalsInScript:()=>i$,useVirtualList:()=>JY,useTitle:()=>zW,useStoreOrThrow:()=>fE,useStore:()=>ZH,useSlots:()=>CH,useSeoMeta:()=>J5,useRouteParams:()=>nz,useRouteParamOrThrow:()=>dE,useRouteParam:()=>rz,usePageTitle:()=>zW,useMiddlewareValue:()=>mE,useMiddlewareState:()=>sz,useLoadingIndicator:()=>hj,useHead:()=>A6,useAttrs:()=>PH,uploadFiles:()=>sQ,uploadFile:()=>h3,updateInstance:()=>TE,untrack:()=>K9,unregisterDirective:()=>Kw,unmountInstance:()=>IE,unescapeHtml:()=>U8,transpileTypeScript:()=>q6,transitionDirective:()=>$8,toUsers:()=>fq,toUser:()=>gq,thumbnail:()=>XQ,thumbHashToRGBA:()=>T7,thumbHashToDataURL:()=>lQ,templateCache:()=>b2,stxClientHelpers:()=>rJ,structuredDataDirective:()=>s8,stripDocumentWrapper:()=>Y4,stringToStream:()=>rT,strictCspPreset:()=>$W,streamingSuspenseDirective:()=>Cj,streamToResponse:()=>TD,streamTemplateSimple:()=>RD,streamTemplate:()=>ND,stopHmrServer:()=>q$,stopBroadcasting:()=>xq,state:()=>Z9,startProductionServer:()=>Aj,startInteractive:()=>jj,startBroadcasting:()=>yq,staggerDirective:()=>dG,srcsetUrls:()=>RQ,springDirective:()=>mG,splitByPipe:()=>R8,smartBatchSign:()=>IQ,signUrl:()=>S3,shouldTranspileTypeScript:()=>z6,shouldReloadOnChange:()=>u5,shouldRefreshSignature:()=>y3,shouldIgnoreFile:()=>c5,shouldCacheComponent:()=>v_,sharpen:()=>KQ,setRouteParams:()=>pE,setMiddlewareState:()=>iE,setGlobalProvide:()=>u3,setErrorLocale:()=>MK,setCurrentInstance:()=>BE,setCachedVideoResult:()=>Z$,setCachedImageResult:()=>t4,setCached:()=>r4,serveStxFile:()=>S7,serveMultipleStxFiles:()=>b7,serveMarkdownFile:()=>$3,serveFile:()=>OD,serveApp:()=>C7,serve:()=>kj,serializeState:()=>cj,sepia:()=>UQ,scrollAnimateDirective:()=>Z8,screenReaderDirective:()=>e7,scopeHTML:()=>Hz,scopeCSS:()=>jz,scanForSitemapEntries:()=>UN,scanA11yIssues:()=>QZ,saturation:()=>qQ,sanitizeParams:()=>EQ,sanitizeFilePath:()=>dK,sanitizeExpression:()=>mK,sanitizeDirectiveParams:()=>uK,sanitizeDirectiveParam:()=>Z5,sanitizeComponentProps:()=>dZ,safeExecuteAsync:()=>C1,safeExecute:()=>gK,runPreProcessingMiddleware:()=>L2,runPostProcessingMiddleware:()=>O2,runMiddleware:()=>J7,runHooks:()=>Z4,rotate:()=>jQ,resolveTemplatePath:()=>E5,resize:()=>ZQ,resetPlaceholders:()=>LZ,resetHead:()=>_W,resetHMRHandler:()=>lD,resetErrorConfig:()=>CK,replacePlaceholders:()=>W8,renderView:()=>$G,renderVideoComponent:()=>G$,renderToString:()=>W4,renderToStream:()=>cH,renderToDOM:()=>b$,renderThumbhashToCanvas:()=>cQ,renderTemplate:()=>Ik,renderString:()=>Dk,renderSlot:()=>DY,renderSSRSuspense:()=>A_,renderProtectedVideo:()=>PQ,renderProtectedImg:()=>CQ,renderMediaUpload:()=>TQ,renderImgComponent:()=>C6,renderImageComponent:()=>iX,renderHtmlAttrs:()=>jW,renderHead:()=>qW,renderEmail:()=>qk,renderComponentWithSlot:()=>y1,renderBodyAttrs:()=>HW,render:()=>sD,relaxedCspPreset:()=>ZW,registerValidationRule:()=>QA,registerStreamingDirectives:()=>MD,registerStore:()=>cE,registerSeoDirectives:()=>GN,registerMiddleware:()=>gE,registerFilters:()=>ZK,registerFilter:()=>FZ,registerErrorMessages:()=>TK,registerEnhancedValidationRule:()=>KA,registerDirective:()=>IB,registerCspDirectives:()=>uV,registerComponentDirectives:()=>vT,registerAnimationDirectives:()=>MF,registerA11yDirectives:()=>_F,ref:()=>jE,redirect:()=>YI,readMarkdownFile:()=>Z6,readFileCached:()=>qU,reactive:()=>lz,quality:()=>FQ,pruneSignatureCache:()=>SQ,pruneCache:()=>gB,provide:()=>EH,processVueTemplate:()=>M2,processVirtualListDirectives:()=>N9,processVirtualGridDirectives:()=>GY,processVideo:()=>c9,processValidateDirective:()=>wW,processTranslateDirective:()=>K2,processTransitionDirectives:()=>B_,processTransitionAttributes:()=>j_,processTitleDirective:()=>FW,processTemplateBindings:()=>DZ,processTeleportDirectives:()=>X_,processSuspenseDirectives:()=>F_,processStructuredData:()=>A2,processStaticDirectives:()=>VY,processStackReplacements:()=>n8,processStackPushDirectives:()=>i8,processSlots:()=>kY,processShell:()=>F3,processServerBindings:()=>o8,processSeoDirective:()=>N2,processSectionDirectives:()=>ED,processScopedStyles:()=>_5,processReactiveBindings:()=>zK,processProtectedMedia:()=>yQ,processPartialHydrationDirectives:()=>zY,processOnceDirective:()=>N5,processMiddleware:()=>H2,processMetaDirectives:()=>V2,processMetaDirective:()=>VW,processMarkdownFileDirectives:()=>TY,processMarkdownDirectives:()=>EY,processLoops:()=>c8,processKeepAliveDirectives:()=>y_,processJsonDirective:()=>A5,processInfiniteListDirectives:()=>QY,processIncludes:()=>p8,processImgComponents:()=>zX,processImageComponents:()=>nX,processImage:()=>m1,processHeadDirective:()=>OW,processForms:()=>JA,processFormInputDirectives:()=>y8,processExpressions:()=>A1,processEventDirectives:()=>PZ,processErrorDirective:()=>x8,processDynamicComponents:()=>T2,processDirectives:()=>J0,processDirectiveAttributes:()=>zw,processDeferDirectives:()=>$_,processCustomDirectives:()=>$2,processCspDirectives:()=>oZ,processClientScript:()=>i6,processBasicFormDirectives:()=>D4,processAsyncDirectives:()=>I_,processAnimationDirectives:()=>KZ,processA11yDirectives:()=>JZ,preloadTranslationsBackground:()=>LA,preloadTranslations:()=>DW,preloadIslandHandlers:()=>xD,poolStrings:()=>kq,pluginManager:()=>yX,performLeave:()=>__,performEnter:()=>U_,peek:()=>W9,partialsCache:()=>M6,parseVideoDirectiveOptions:()=>Uz,parseUrl:()=>$Q,parseThumbhashString:()=>pQ,parseSwitchBlock:()=>M8,parseSlots:()=>IY,parseSlotElement:()=>NB,parseScriptDeclarations:()=>oK,parseSFCComponent:()=>Lz,parseProtectedArgs:()=>xQ,parseImgComponent:()=>v9,parseImageUrl:()=>fY,parseImageComponent:()=>W3,parseExpressionWithFilters:()=>sK,parseCookies:()=>eT,parseConditionalBlock:()=>uZ,parseArguments:()=>cZ,parseAnimationShorthand:()=>RF,optimizeTemplate:()=>Sq,optimizeImage:()=>q3,optimizeDirectory:()=>oX,onceStore:()=>q2,onUpdated:()=>RE,onUnmounted:()=>ME,onServer:()=>rE,onMounted:()=>AE,onMount:()=>Q9,onHydrated:()=>FY,onErrorCaptured:()=>SH,onDestroy:()=>G9,onDeactivated:()=>d_,onClient:()=>nE,onBeforeUpdate:()=>NE,onBeforeUnmount:()=>wE,onBeforeMount:()=>VE,onActivated:()=>h_,observeElement:()=>dQ,notFound:()=>XI,nextTick:()=>kH,navigateTo:()=>vE,mountInstance:()=>EE,motionDirective:()=>X8,moderateCspPreset:()=>I8,minifyHtml:()=>Dq,metaDirective:()=>r8,mergeParams:()=>D3,mergeCspDirectives:()=>dV,matchRoute:()=>V3,markdownDirectiveHandler:()=>CY,markdownCache:()=>r9,loadTranslationLazy:()=>K5,loadTranslation:()=>bW,loadStxConfig:()=>f0,loadMiddlewareFromDirectory:()=>X7,loadManifest:()=>LJ,loadElement:()=>U6,loadChannels:()=>vq,lazyLoadAll:()=>fQ,lazyLoad:()=>gQ,keyframeDirective:()=>hG,jsxs:()=>dH,jsxDEV:()=>mH,jsx:()=>_4,jsonResponse:()=>ZI,islandDirective:()=>Pj,isTest:()=>TV,isSpaNavigation:()=>JJ,isSignatureValid:()=>C3,isSignal:()=>q5,isSharpAvailable:()=>d1,isServerEnvironment:()=>fT,isServer:()=>az,isProduction:()=>kK,isNativeLazySupported:()=>x3,isLoading:()=>jA,isLoaded:()=>HA,isJavaScriptScript:()=>TB,isIntersectionObserverSupported:()=>v3,isImageFile:()=>o5,isICUFormat:()=>yW,isHydrated:()=>OY,isEdgeEnvironment:()=>gT,isDirectiveKind:()=>eH,isDevelopment:()=>H6,isDerived:()=>j5,isCssOnlyChange:()=>m5,isClient:()=>oz,isAsyncComponent:()=>k_,invert:()=>_Q,invalidateFileCacheByDir:()=>HU,invalidateFileCache:()=>jU,interpolateScriptsInTemplate:()=>XK,interpolateScriptExpressions:()=>AZ,inlineError:()=>G0,injectSeoTags:()=>R2,injectRouterScript:()=>t1,injectHotReload:()=>f1,injectHeatmap:()=>_Z,injectCspMetaTag:()=>aZ,injectCrosswindCSS:()=>D0,injectAnalytics:()=>bZ,inject:()=>TH,initStoreRegistry:()=>uE,initNetlify:()=>Sz,initLoadingIndicator:()=>hD,initLazyLoading:()=>vQ,initFile:()=>bJ,initBlurUp:()=>g3,initAllBlurUp:()=>nQ,imgDirective:()=>g5,imageDirective:()=>sX,hydrateTemplate:()=>xJ,hydrateIslands:()=>yD,hydrateIsland:()=>jY,hydrateFragment:()=>TI,hydrateByStrategy:()=>HY,hydrateAll:()=>LY,hydrate:()=>nD,htmlResponse:()=>LD,heatmapDirective:()=>BZ,hashString:()=>k9,hashFilePath:()=>C4,hashFile:()=>l0,hashBuffer:()=>bB,hasVueTemplateSyntax:()=>KU,hasVariables:()=>B2,hasStore:()=>ej,hasPlaceholders:()=>L4,hasNetlifyConfig:()=>s5,hasMiddleware:()=>xE,hasEventDirectives:()=>HV,hasDocumentShell:()=>zU,hasDirectives:()=>FB,hasDOMSupport:()=>PG,handleError:()=>bH,h:()=>nH,groupVariantsByFormat:()=>V$,grayscale:()=>WQ,gitHash:()=>fJ,getUnusedDirectives:()=>wq,getTranslationSync:()=>kW,getTranslationCacheStats:()=>BA,getTranslationAsync:()=>OA,getTranslation:()=>v8,getTotalSize:()=>Y6,getTimeUntilExpiry:()=>P3,getStoreNames:()=>$H,getStore:()=>tJ,getSourceLineInfo:()=>bY,getScreenReaderOnlyStyle:()=>GF,getScopeAttribute:()=>RM,getRouteParams:()=>JT,getPositionInfo:()=>LB,getPlaceholderRegistry:()=>OZ,getPlaceholderCacheStats:()=>tY,getPageMeta:()=>S8,getNonce:()=>F6,getMimeType:()=>u1,getMiddlewareNames:()=>Y7,getMiddleware:()=>yE,getLoadingState:()=>qA,getLoadingLocales:()=>VA,getImageMetadata:()=>a5,getHydrationRuntime:()=>nj,getHydratedStoreState:()=>lE,getHmrServer:()=>l5,getHead:()=>I4,getHMRHandler:()=>cD,getFormatExtension:()=>uY,getFileMtime:()=>y5,getFallbackVariant:()=>F$,getErrorMessage:()=>vZ,getErrorLocale:()=>EK,getErrorConfig:()=>t$,getErrorCodeName:()=>H8,getDirectives:()=>Gw,getDirective:()=>Qw,getCurrentInstance:()=>zE,getCspPreset:()=>hV,getCspHeaderName:()=>QW,getComponentCacheStats:()=>Jw,getCachedVideoResult:()=>$$,getCachedSignature:()=>DQ,getCachedSignalsRuntime:()=>LU,getCachedRouterScript:()=>OU,getCachedPlaceholder:()=>P5,getCachedImageResult:()=>o4,getCached:()=>n4,getCacheStats:()=>vB,getBroadcastServer:()=>Pq,getBestVariant:()=>mY,getAllFilters:()=>VZ,generateWidthSrcset:()=>k6,generateVirtualListCSS:()=>XY,generateVideoPreview:()=>oQ,generateValidationScript:()=>UA,generateUploadRuntime:()=>k7,generateTreeShakenBundle:()=>Mq,generateTransitionRuntime:()=>q_,generateTransitionCSS:()=>z_,generateThumbnails:()=>X$,generateThumbhashPlaceholder:()=>pY,generateTemplatesDocs:()=>oq,generateSuspenseRuntime:()=>R_,generateSuspenseCSS:()=>N_,generateStateScript:()=>pj,generateSrcsetData:()=>hY,generateSrcset:()=>P9,generateSrcSet:()=>$4,generateSpriteSheet:()=>m9,generateSpaShell:()=>Vk,generateSourceTags:()=>dY,generateSizesFromBreakpoints:()=>vY,generateSizesAttribute:()=>u4,generateSizes:()=>O$,generateSitemapIndex:()=>WN,generateSitemap:()=>KN,generateSimpleMediaPicker:()=>qH,generateSignatureRuntime:()=>M7,generateSignalsRuntimeDev:()=>s6,generateSignalsRuntime:()=>H5,generateScopeId:()=>p9,generateSFCWebComponent:()=>Oz,generateRouteTypes:()=>GT,generateRouteManifest:()=>QT,generateRobotsTxt:()=>ZU,generateResponsiveVariants:()=>C9,generateReactiveWebComponentTS:()=>EM,generateReactiveWebComponent:()=>MM,generateReactiveRuntime:()=>IM,generateReactiveMixin:()=>TM,generatePoster:()=>Y$,generatePlaceholderStyle:()=>aY,generatePlaceholderCSS:()=>C5,generatePlaceholder:()=>b5,generatePartialHydrationCSS:()=>qY,generateNonce:()=>rZ,generateNetlifyToml:()=>Y3,generateMinifiedMediaRuntime:()=>VH,generateMediaRuntime:()=>eQ,generateMediaManagerEmbed:()=>zH,generateManifest:()=>jJ,generateLoadingIndicatorHtml:()=>dD,generateLazyLoadRuntime:()=>E7,generateLQIP:()=>nY,generateKeepAliveRuntime:()=>f_,generateKeepAliveCSS:()=>g_,generateIslandManifest:()=>AY,generateImagePreview:()=>aQ,generateImageManifest:()=>j3,generateHydrationScript:()=>iD,generateHydrationRuntime:()=>ID,generateHydrationCSS:()=>rD,generateHydrationBootstrap:()=>WY,generateHotReloadScript:()=>Dz,generateHeatmapScript:()=>UZ,generateHMRClientScript:()=>mD,generateHLSManifest:()=>J$,generateEventBindings:()=>pD,generateDprSrcsetWithVariableQuality:()=>xY,generateDprSrcset:()=>m4,generateDocumentShell:()=>BU,generateDocs:()=>Yj,generateDirectivesDocs:()=>tq,generateDirectiveRuntime:()=>Bw,generateDefaultRobotsTxt:()=>_N,generateDASHManifest:()=>Q$,generateCspMetaTag:()=>D8,generateCspHeader:()=>sZ,generateCrosswindCSS:()=>B8,generateCompositionRuntime:()=>xH,generateComponentsDocs:()=>aq,generateComponentManifest:()=>ER,generateComponentDoc:()=>sq,generateColorPlaceholder:()=>sY,generateClientRuntime:()=>DE,generateCacheKey:()=>p4,generateBlurUpRuntime:()=>I7,generateBlurUpCSS:()=>D7,generateBindingsRuntime:()=>qK,generateAutoWidthSrcset:()=>yY,generateAsyncComponentRuntime:()=>b_,generateAsyncComponentCSS:()=>S_,generateAnimationRuntime:()=>wF,generateAnimationCSS:()=>NF,generateAnalyticsScript:()=>SZ,formatTypeErrors:()=>PD,formatStxContent:()=>M3,formatSize:()=>v6,formatRoutes:()=>GJ,formatMarkdownContent:()=>DJ,formatLocalizedError:()=>DK,formatICU:()=>CW,formatFilePath:()=>e$,formatError:()=>F8,formatDocsAsMarkdown:()=>eq,formatDocsAsJson:()=>Zj,formatDocsAsHtml:()=>$j,format:()=>OQ,foldConstants:()=>Iq,flipVertical:()=>LQ,flipHorizontal:()=>HQ,fingerprint:()=>KJ,findMatchingEndTag:()=>O6,findMatchingDelimiter:()=>v0,findIfBlocks:()=>w8,findExpressions:()=>rK,findErrorPage:()=>QJ,findDirectiveBlocks:()=>X5,findDeadCode:()=>Eq,findDeadBranches:()=>Eq,findComponentFiles:()=>MJ,findCommonDir:()=>QG,filterRequiredFiles:()=>n5,fileExists:()=>$0,extractVariables:()=>V0,extractState:()=>ij,extractSlotContent:()=>wB,extractScriptFromTemplate:()=>_2,extractPlaceholders:()=>nF,extractParenthesizedExpression:()=>a1,extractDominantColor:()=>rY,extractDirectiveParams:()=>aK,extractDirectiveNames:()=>VB,extractContainerContent:()=>K7,extractComponentProps:()=>nq,extractComponentName:()=>UY,extractComponentDescription:()=>rq,extractClassNames:()=>_8,extractBoundProps:()=>_Y,extractBalancedExpression:()=>mZ,extractAndScopeStyles:()=>wM,extractAndProcessEvents:()=>VK,evaluateExpression:()=>W1,evaluateConstant:()=>R3,evaluateAuthExpression:()=>s1,escapeHtml:()=>I0,errorRecovery:()=>V8,errorLogger:()=>q1,ensureTeleportTargets:()=>J_,ensureDocumentShell:()=>B5,enhancedValidationRules:()=>X2,eliminateDeadCode:()=>Tq,effect:()=>X9,dprUrls:()=>wQ,docsCommand:()=>EJ,disconnectObserver:()=>mQ,devHelpers:()=>E4,detectShell:()=>XJ,detectRuntime:()=>E$,detectProjectConfig:()=>H$,detectFormat:()=>cY,detectBuildMode:()=>DT,derived:()=>Y9,deploy:()=>kz,defineStxConfig:()=>Az,defineStore:()=>YH,definePlugin:()=>W$,definePageMeta:()=>BW,defineMiddleware:()=>PE,defineExpose:()=>DH,defineEmits:()=>IH,defineDirective:()=>b0,defineCustomElement:()=>sH,defineConfig:()=>EI,defineClientDirective:()=>Ww,defineAsyncComponent:()=>D_,defaultMediaConfig:()=>Bk,defaultImageConfig:()=>dz,defaultI18nConfig:()=>g8,defaultHeatmapConfig:()=>pG,defaultFormClasses:()=>P8,defaultFilters:()=>O4,defaultCspConfig:()=>pV,defaultConfig:()=>Q1,default:()=>kk,decodeThumbhash:()=>iY,cspNonceDirective:()=>JW,cspDirective:()=>XW,crossfadeTransition:()=>iQ,crop:()=>YQ,createVirtualList:()=>A9,createVideoDirective:()=>l9,createVercelHandler:()=>oT,createTypeChecker:()=>cJ,createTranslateFilter:()=>vA,createTextEncoderStream:()=>nT,createStxApp:()=>JG,createStreamingResponse:()=>iT,createStreamRenderer:()=>wD,createStore:()=>eJ,createStorageManager:()=>CE,createServerCookieManager:()=>bE,createScope:()=>cz,createSSRSuspense:()=>V_,createRouter:()=>G6,createRouteLocation:()=>Z7,createRoute:()=>VD,createRef:()=>jE,createReactive:()=>lz,createProvideContext:()=>yH,createProject:()=>bI,createProductionBuild:()=>MI,createPlaceholder:()=>c$,createOptimizedBuild:()=>ST,createNetlifyHandler:()=>tT,createNetlifyClient:()=>p5,createMiddlewareContext:()=>$7,createMiddleware:()=>FD,createLazyObserver:()=>hQ,createKeepAliveCache:()=>x_,createKVNamespace:()=>Qj,createIslandRegistry:()=>BY,createImgDirective:()=>g9,createImagePlugin:()=>aX,createImageDirective:()=>B3,createHeatmapAggregator:()=>IF,createFileManifest:()=>i5,createEnvAccessor:()=>Jj,createEnhancedError:()=>vK,createEdgeHandler:()=>z7,createEdgeCache:()=>Gj,createDetailedErrorMessage:()=>O0,createDenoHandler:()=>aT,createDefaultNetlifyConfig:()=>L$,createCspHeaders:()=>lV,createCookie:()=>$I,createComputed:()=>HE,createComponentInstance:()=>qE,createCloudflareHandler:()=>sT,createClientCookieManager:()=>SE,createBuiltinDirectives:()=>_w,createApp:()=>JG,createAnimationTimeline:()=>AF,cover:()=>QQ,convertToCommonJS:()=>f8,contrast:()=>zQ,contain:()=>JQ,consoleError:()=>xK,configureErrorHandling:()=>bK,config:()=>G1,computed:()=>HE,composeShellWithPage:()=>G7,componentDirective:()=>pq,compileTemplate:()=>BJ,collectDeployFiles:()=>j$,clearVideoCache:()=>h9,clearTranslationCache:()=>_A,clearSignatureCache:()=>kQ,clearPlaceholderCache:()=>oY,clearOnceStore:()=>YN,clearNonce:()=>fV,clearMiddleware:()=>e5,clearImageCache:()=>_3,clearErrorMessages:()=>IK,clearDevCaches:()=>FU,clearCustomFilters:()=>YK,clearComponentCache:()=>D6,clearCache:()=>s4,classifyScript:()=>$q,classifyAllScripts:()=>$J,checkTemplateFile:()=>bD,checkTemplate:()=>CD,checkCache:()=>B9,checkAuthAccess:()=>S$,checkA11y:()=>o7,channel:()=>mq,cancelPendingLoads:()=>AA,calculateSha1:()=>Z3,calculateOptimalWidths:()=>T9,cacheTemplate:()=>z9,buildWebComponents:()=>kX,buildViews:()=>wH,buildUrl:()=>A0,buildRuntimeAsset:()=>WJ,buildRouterAsset:()=>UJ,buildImageUrl:()=>M1,buildForProduction:()=>jq,buildAuthParams:()=>w7,buildApp:()=>Lq,build:()=>wI,broadcastPrivate:()=>hq,broadcastPresence:()=>dq,broadcast:()=>NJ,brightness:()=>BQ,blur:()=>GQ,batchSignUrls:()=>b3,batch:()=>J9,autoFixA11yFile:()=>xG,autoFixA11yDirectory:()=>UF,autoFixA11y:()=>yG,auto:()=>VQ,assetTags:()=>NT,applyTransformations:()=>v5,applySlots:()=>MB,applyPropDefaults:()=>yT,applyPreset:()=>NQ,applyHead:()=>LW,applyFilters:()=>NZ,apiCspPreset:()=>YW,animationGroupDirective:()=>Y8,analyzeVideo:()=>f5,analyzeUsage:()=>VJ,analyzeTemplate:()=>ez,analyzeProject:()=>eX,analyzeDirectiveUsage:()=>VJ,analyticsDirective:()=>UV,addStore:()=>vI,addPage:()=>xI,addNonceToInlineContent:()=>mV,addLayout:()=>gI,addComponent:()=>yI,abortNavigation:()=>kE,a11yDirective:()=>t7,VideoProcessorCache:()=>e4,TransitionType:()=>vG,TransitionEase:()=>fG,TransitionDirection:()=>gG,Tokenizer:()=>Y5,TemplateTypeChecker:()=>uJ,TEMPLATE_PRESETS:()=>_I,StxValidationError:()=>$5,StxSyntaxError:()=>gZ,StxSecurityError:()=>fZ,StxRuntimeError:()=>R1,StxFileError:()=>M4,StxError:()=>L6,Show:()=>lH,SPRING_PRESETS:()=>GZ,ProductionBuild:()=>E3,Portal:()=>iH,PROJECT_TEMPLATES:()=>SI,PRESETS:()=>k3,MemorySessionStore:()=>aj,MIME_TYPES:()=>k5,MEDIA_DEFAULT_WIDTHS:()=>g1,MEDIA_DEFAULT_FORMATS:()=>$6,ImageProcessorCache:()=>a4,ImageProcessingError:()=>A$,HydrationRuntime:()=>oJ,HotReloadServer:()=>mX,HeatmapAggregator:()=>zZ,Fragment:()=>U4,For:()=>pH,ErrorLogger:()=>A8,ErrorCodes:()=>e,DeployError:()=>J6,DEFAULT_WIDTHS:()=>H1,DEFAULT_TRANSITION_OPTIONS:()=>k1,DEFAULT_QUALITY:()=>O1,DEFAULT_PLACEHOLDER_OPTIONS:()=>D9,DEFAULT_FORMATS:()=>L1,DEFAULT_DPR_VALUES:()=>D5,ComponentHMRHandler:()=>sJ,COMMON_SIZES:()=>gY,BroadcastServer:()=>cq,Broadcast:()=>uq,BLUR_UP_CSS:()=>l4});var kk;var g6=D(()=>{X3();H3();H0();XH();w2();ZG();rH();aH();xX();r1();pz();N6();L3();J2();H4();CZ();J8();d4();W7();xZ();FJ();_J();Aq();bq();w3();q9();iq();u0();tZ();Z2();X3();GG();I5();TJ();Kj();_1();yZ();r0();kJ();Q8();W2();k4();CJ();PJ();l8();M9();F2();E8();A3();l$();J1();Fj();OJ();gJ();U7();Dj();ZJ();a8();Sj();t8();zJ();vJ();yj();vj();CX();KY();NY();gj();dj();kZ();m$();uj();rj();oj();H3();RH();MH();L5();E2();I2();tH();H0();SY();ZL();kk={}});import P7 from"path";var C$;var l3=D(()=>{g6();_1();r0();j6();J1();C$={name:"bun-plugin-stx",async setup($){let Y={...await f0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${P7.relative(P7.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await kX(Y,X);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await B9(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await C1(()=>Bun.file(G).text(),"",(H)=>{throw new M4(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new M4(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:B}=N1.time("script-extraction",()=>{let H=W,L=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(L)H=L[1].trim();let F=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],O="",V=[];for(let A of F){let R=A.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",M=A.match(/<script\b([^>]*)>/i),E=M?M[1]:"";if(/\bserver\b/i.test(E))O=R;else V.push(A)}let N=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:O,templateContent:N,allScripts:V}}),z={__filename:G,__dirname:P7.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await C1(()=>V0(U,z,G),void 0,(H)=>{let L=new R1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(q1.log(L,{filePath:G,scriptContent:U}),Y.debug)throw L});let j=await N1.timeAsync("directive-processing",async()=>{return await J0(_,z,G,Y,K)});if(B.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (r0(),n$)),L=H(B.join(`
14685
14685
  `),z),F=j.search(/<\/body>/i);if(F!==-1)j=j.slice(0,F)+L+`
14686
14686
  `+j.slice(F);else j+=`
14687
- ${L}`}if(j=await t1(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await z9(G,j,K,Y),Y.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:j,loader:"html"}}catch(K){let W=K instanceof Error?K:new R1(`Plugin processing failed: ${String(K)}`,G);if(q1.log(W,{filePath:G,buildConfig:$.config}),E6.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),Y.debug)console.error("stx Plugin Error:",W);let U=W,_=U.line||null,B=U.context||null;return{contents:Y.debug||H4()?`<!DOCTYPE html>
14687
+ ${L}`}if(j=await t1(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await z9(G,j,K,Y),Y.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:j,loader:"html"}}catch(K){let W=K instanceof Error?K:new R1(`Plugin processing failed: ${String(K)}`,G);if(q1.log(W,{filePath:G,buildConfig:$.config}),E4.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),Y.debug)console.error("stx Plugin Error:",W);let U=W,_=U.line||null,B=U.context||null;return{contents:Y.debug||H6()?`<!DOCTYPE html>
14688
14688
  <html lang="en">
14689
14689
  <head>
14690
14690
  <meta charset="UTF-8">
@@ -14744,12 +14744,12 @@ ${L}`}if(j=await t1(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await z
14744
14744
  <h1>Something went wrong</h1>
14745
14745
  <p>An internal error occurred. Please try again later.</p>
14746
14746
  </body>
14747
- </html>`,loader:"html"}}})}}});var{serve:Sk}=globalThis.Bun;import I1 from"fs";import Z1 from"path";async function S7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=Z1.resolve($);if(!I1.existsSync(K))return console.error(`${w.red}Error: File not found: ${w.bright}${K}${w.reset}`),!1;if(K.endsWith(".md"))return $3(K,Z);else if(!K.endsWith(".stx"))return console.error(`${w.red}Error: Unsupported file type: ${w.bright}${K}${w.reset}. Only .stx and .md files are supported.`),!1;let W=Z1.join(process.cwd(),".stx/output");I1.mkdirSync(W,{recursive:!0}),console.log(`${w.blue}Building ${w.bright}${$}${w.reset}...`);let U=null,_=async()=>{try{let O={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[O,C$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${w.red}Build failed:${w.reset}`,V.logs),!1;let N=V.outputs.find((R)=>R.path.endsWith(".html"));if(!N)return console.error(`${w.red}No HTML output found${w.reset}`),!1;return U=await Bun.file(N.path).text(),!0}catch(O){return console.error(`${w.red}Error building stx file:${w.reset}`,O),!1}};if(!await _())return!1;let z=Z1.dirname(K);await R6(z);let q=Y;try{if(q=await y4(Y),q!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${q} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}if(J){let O=Z.hmrPort||q+1;Q=l5({wsPort:O,verbose:!1}),G=Q.start(O)}let j={},H=null;try{let{loadStxConfig:O}=await Promise.resolve().then(() => (g4(),X6)),V=await O();if(V?.apiRouter)H=V?.apiRouter,console.log(`${w.blue}Using custom router for API handling${w.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let N=Object.keys(j).length;if(N>0)console.log(`${w.blue}Loaded ${w.bright}${N} API route${N>1?"s":""}${w.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:A}=await Promise.resolve().then(() => (w3(),RJ)),R=V.broadcasting;await N(R);let M=R.port??6001;console.log(`${w.magenta}Broadcasting on ${w.cyan}ws://localhost:${M}/ws${w.reset}`);let E=Z1.join(process.cwd(),"channels.ts");if(I1.existsSync(E))try{let I=await A(E);console.log(`${w.blue}Loaded ${w.bright}${I} broadcast channel${I!==1?"s":""}${w.blue} from channels.ts${w.reset}`)}catch(I){console.warn(`${w.yellow}Failed to load channels.ts: ${I.message}${w.reset}`)}}catch(N){console.warn(`${w.yellow}Broadcasting failed to start: ${N.message}${w.reset}`)}}catch{}if(console.log(`${w.blue}Starting server on ${w.cyan}http://localhost:${q}/${w.reset}...`),J)console.log(`${w.magenta}Hot reload enabled on ws://localhost:${G}${w.reset}`);let L=Sk({port:q,async fetch(O){let V=new URL(O.url);if(H)try{let E=await H.handleRequest(O);if(E.status!==404)return E}catch{}if(j[V.pathname])try{return await j[V.pathname](O)}catch(E){return new Response(JSON.stringify({error:E.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let I=await D0(U||"");if(J)I=f1(I,G);if(Z.native)if(I.includes("<head>"))I=I.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(I.includes("<html"))I=I.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let N=Z1.join(W,V.pathname);if(I1.existsSync(N)&&I1.statSync(N).isFile()){let E=Bun.file(N),I=Z1.extname(N).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),C=S.transformSync(k);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}let A=Z1.dirname(K),R=Z1.join(A,V.pathname);if(I1.existsSync(R)&&I1.statSync(R).isFile()){let E=Bun.file(R),I=Z1.extname(R).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),C=S.transformSync(k);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".svg":T="image/svg+xml";break;case".ico":T="image/x-icon";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}let M=Z1.join(process.cwd(),"public",V.pathname);if(I1.existsSync(M)&&I1.statSync(M).isFile()){let E=Bun.file(M),I=Z1.extname(M).toLowerCase(),T="application/octet-stream";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),C=S.transformSync(k);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".svg":T="image/svg+xml";break;case".ico":T="image/x-icon";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}return new Response("Not Found",{status:404})},error(O){return new Response(`<pre>${O}
14747
+ </html>`,loader:"html"}}})}}});var{serve:Sk}=globalThis.Bun;import I1 from"fs";import Z1 from"path";async function S7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=Z1.resolve($);if(!I1.existsSync(K))return console.error(`${w.red}Error: File not found: ${w.bright}${K}${w.reset}`),!1;if(K.endsWith(".md"))return $3(K,Z);else if(!K.endsWith(".stx"))return console.error(`${w.red}Error: Unsupported file type: ${w.bright}${K}${w.reset}. Only .stx and .md files are supported.`),!1;let W=Z1.join(process.cwd(),".stx/output");I1.mkdirSync(W,{recursive:!0}),console.log(`${w.blue}Building ${w.bright}${$}${w.reset}...`);let U=null,_=async()=>{try{let O={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[O,C$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${w.red}Build failed:${w.reset}`,V.logs),!1;let N=V.outputs.find((R)=>R.path.endsWith(".html"));if(!N)return console.error(`${w.red}No HTML output found${w.reset}`),!1;return U=await Bun.file(N.path).text(),!0}catch(O){return console.error(`${w.red}Error building stx file:${w.reset}`,O),!1}};if(!await _())return!1;let z=Z1.dirname(K);await R4(z);let q=Y;try{if(q=await y6(Y),q!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${q} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}if(J){let O=Z.hmrPort||q+1;Q=l5({wsPort:O,verbose:!1}),G=Q.start(O)}let j={},H=null;try{let{loadStxConfig:O}=await Promise.resolve().then(() => (g6(),X4)),V=await O();if(V?.apiRouter)H=V?.apiRouter,console.log(`${w.blue}Using custom router for API handling${w.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let N=Object.keys(j).length;if(N>0)console.log(`${w.blue}Loaded ${w.bright}${N} API route${N>1?"s":""}${w.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:N,loadChannels:A}=await Promise.resolve().then(() => (w3(),RJ)),R=V.broadcasting;await N(R);let M=R.port??6001;console.log(`${w.magenta}Broadcasting on ${w.cyan}ws://localhost:${M}/ws${w.reset}`);let E=Z1.join(process.cwd(),"channels.ts");if(I1.existsSync(E))try{let I=await A(E);console.log(`${w.blue}Loaded ${w.bright}${I} broadcast channel${I!==1?"s":""}${w.blue} from channels.ts${w.reset}`)}catch(I){console.warn(`${w.yellow}Failed to load channels.ts: ${I.message}${w.reset}`)}}catch(N){console.warn(`${w.yellow}Broadcasting failed to start: ${N.message}${w.reset}`)}}catch{}if(console.log(`${w.blue}Starting server on ${w.cyan}http://localhost:${q}/${w.reset}...`),J)console.log(`${w.magenta}Hot reload enabled on ws://localhost:${G}${w.reset}`);let L=Sk({port:q,async fetch(O){let V=new URL(O.url);if(H)try{let E=await H.handleRequest(O);if(E.status!==404)return E}catch{}if(j[V.pathname])try{return await j[V.pathname](O)}catch(E){return new Response(JSON.stringify({error:E.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(V.pathname==="/")return(async()=>{let I=await D0(U||"");if(J)I=f1(I,G);if(Z.native)if(I.includes("<head>"))I=I.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else if(I.includes("<html"))I=I.replace(/(<html[^>]*>)/,"$1<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>");else I="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+I;return I})().then((I)=>new Response(I,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let N=Z1.join(W,V.pathname);if(I1.existsSync(N)&&I1.statSync(N).isFile()){let E=Bun.file(N),I=Z1.extname(N).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),C=S.transformSync(k);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}let A=Z1.dirname(K),R=Z1.join(A,V.pathname);if(I1.existsSync(R)&&I1.statSync(R).isFile()){let E=Bun.file(R),I=Z1.extname(R).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),C=S.transformSync(k);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".svg":T="image/svg+xml";break;case".ico":T="image/x-icon";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}let M=Z1.join(process.cwd(),"public",V.pathname);if(I1.existsSync(M)&&I1.statSync(M).isFile()){let E=Bun.file(M),I=Z1.extname(M).toLowerCase(),T="application/octet-stream";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),C=S.transformSync(k);return new Response(C,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(I){case".html":T="text/html";break;case".css":T="text/css";break;case".js":T="text/javascript";break;case".json":T="application/json";break;case".png":T="image/png";break;case".jpg":case".jpeg":T="image/jpeg";break;case".gif":T="image/gif";break;case".svg":T="image/svg+xml";break;case".ico":T="image/x-icon";break;case".woff":T="font/woff";break;case".woff2":T="font/woff2";break;case".ttf":T="font/ttf";break;case".otf":T="font/otf";break;case".eot":T="application/vnd.ms-fontobject";break}return new Response(E,{headers:{"Content-Type":T}})}return new Response("Not Found",{status:404})},error(O){return new Response(`<pre>${O}
14748
14748
  ${O.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
14749
14749
  ${w.blue}stx${w.reset} ${w.green}${process.env.stx_VERSION||"v0.0.10"}${w.reset} ${w.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${w.reset}`),console.log(`
14750
14750
  ${w.bright}\u2192 ${w.cyan}http://localhost:${q}/${w.reset}`),console.log(`
14751
14751
  ${w.yellow}Routes:${w.reset}`);let F=Z1.relative(process.cwd(),K);if(console.log(` ${w.green}\u2514\u2500 /${w.reset} \u2192 ${w.bright}${F}${w.reset}`),console.log(`
14752
- Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x4(L.url.toString(),()=>{if(X)I1.watch(Z1.dirname(K),{recursive:!0}).close();L.stop()}),Z.native){let O=await Bun.file(K).text(),V=e9(O);await _$(q,{title:Z1.basename(K,".stx"),nativeSidebar:!!V,sidebarConfig:V})}if(X){let O=Z1.dirname(K);console.log(`${w.blue}Watching ${w.bright}${O}${w.reset} for changes...`);let V=I1.watch(O,{recursive:!0},async(N,A)=>{if(!A||c5(A))return;if(u5(A)){console.log(`${w.yellow}File ${w.bright}${A}${w.yellow} changed, rebuilding...${w.reset}`),M4.clear(),D4();let R=await _();if(await o$(z),J&&Q)if(R)Q.reload(A);else Q.error("Build failed - check console for details")}else if(m5(A)){if(console.log(`${w.cyan}CSS ${w.bright}${A}${w.cyan} changed${w.reset}`),J&&Q)Q.updateCss(A)}});process.on("SIGINT",()=>{if(V.close(),Q)q$();L.stop(),process.exit(0)})}return!0}var YL=D(()=>{k6();l3();H0();d5();dX()});var{serve:bk}=globalThis.Bun;import u4 from"fs";import a0 from"path";function QG($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split(a0.sep)),Y=[];for(let X=0;X<Z[0].length;X++){let J=Z[0][X];if(Z.every((Q)=>Q[X]===J))Y.push(J);else break}return Y.join(a0.sep)}async function b7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=a0.resolve(j);if(!u4.existsSync(H))return console.error(`${w.red}Error: File not found: ${w.bright}${H}${w.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${w.red}Error: Unsupported file type: ${w.bright}${H}${w.reset}. Only .stx and .md files are supported.`),!1}let J=a0.join(process.cwd(),".stx/output");u4.mkdirSync(J,{recursive:!0});let Q=QG($.map((j)=>a0.dirname(a0.resolve(j))));console.log(`${w.blue}Processing ${w.bright}${$.length}${w.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=a0.resolve(j);if(H.endsWith(".md"))try{let{content:F,data:O}=await Z4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:G1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),V=Z.markdown?.syntaxHighlighting||G1.markdown?.syntaxHighlighting,N=V?.defaultTheme||"github-dark",A=["github-dark"],R=V?.additionalThemes||[],E=[...new Set([...A,...R])].map((k)=>`<option value="${k}"${k===N?" selected":""}>${k}</option>`).join(`
14752
+ Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x6(L.url.toString(),()=>{if(X)I1.watch(Z1.dirname(K),{recursive:!0}).close();L.stop()}),Z.native){let O=await Bun.file(K).text(),V=e9(O);await _$(q,{title:Z1.basename(K,".stx"),nativeSidebar:!!V,sidebarConfig:V})}if(X){let O=Z1.dirname(K);console.log(`${w.blue}Watching ${w.bright}${O}${w.reset} for changes...`);let V=I1.watch(O,{recursive:!0},async(N,A)=>{if(!A||c5(A))return;if(u5(A)){console.log(`${w.yellow}File ${w.bright}${A}${w.yellow} changed, rebuilding...${w.reset}`),M6.clear(),D6();let R=await _();if(await o$(z),J&&Q)if(R)Q.reload(A);else Q.error("Build failed - check console for details")}else if(m5(A)){if(console.log(`${w.cyan}CSS ${w.bright}${A}${w.cyan} changed${w.reset}`),J&&Q)Q.updateCss(A)}});process.on("SIGINT",()=>{if(V.close(),Q)q$();L.stop(),process.exit(0)})}return!0}var YL=D(()=>{k4();l3();H0();d5();dX()});var{serve:bk}=globalThis.Bun;import u6 from"fs";import a0 from"path";function QG($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split(a0.sep)),Y=[];for(let X=0;X<Z[0].length;X++){let J=Z[0][X];if(Z.every((Q)=>Q[X]===J))Y.push(J);else break}return Y.join(a0.sep)}async function b7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=a0.resolve(j);if(!u6.existsSync(H))return console.error(`${w.red}Error: File not found: ${w.bright}${H}${w.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${w.red}Error: Unsupported file type: ${w.bright}${H}${w.reset}. Only .stx and .md files are supported.`),!1}let J=a0.join(process.cwd(),".stx/output");u6.mkdirSync(J,{recursive:!0});let Q=QG($.map((j)=>a0.dirname(a0.resolve(j))));console.log(`${w.blue}Processing ${w.bright}${$.length}${w.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=a0.resolve(j);if(H.endsWith(".md"))try{let{content:F,data:O}=await Z6(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:G1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),V=Z.markdown?.syntaxHighlighting||G1.markdown?.syntaxHighlighting,N=V?.defaultTheme||"github-dark",A=["github-dark"],R=V?.additionalThemes||[],E=[...new Set([...A,...R])].map((k)=>`<option value="${k}"${k===N?" selected":""}>${k}</option>`).join(`
14753
14753
  `),I=`
14754
14754
  <!DOCTYPE html>
14755
14755
  <html lang="en">
@@ -14912,19 +14912,19 @@ Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x4(L.u
14912
14912
  </script>
14913
14913
  </body>
14914
14914
  </html>
14915
- `,S=`/${a0.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:I,fileType:"md"}}catch(F){console.error(`${w.red}Error processing Markdown file ${w.bright}${j}${w.reset}:`,F);continue}else{let F={name:"public-assets",setup(M){M.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},O=await Bun.build({entrypoints:[H],outdir:J,plugins:[F,C$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!O.success){console.error(`${w.red}Build failed for ${w.bright}${j}${w.reset}:`,O.logs);continue}let V=O.outputs.find((M)=>M.path.endsWith(".html"));if(!V){console.error(`${w.red}No HTML output found for ${w.bright}${j}${w.reset}`);continue}let N=await Bun.file(V.path).text(),R=`/${a0.relative(Q,H).replace(/\.stx$/,"")}`;if(R.endsWith("/index"))R=R.slice(0,-6)||"/";if(R.includes("[")){let M=[...R.matchAll(/\[([^\]]+)\]/g)].map((I)=>I[1]),E=R.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:M,filePath:H,routeTemplate:R,fileType:"stx"}),G[R]={filePath:H,content:N,fileType:"stx"}}else G[R||"/"]={filePath:H,content:N,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${w.red}No files were successfully processed${w.reset}`),!1;return!0}catch(j){return console.error(`${w.red}Error processing files:${w.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await y4(Y),_!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${_} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}console.log(`${w.blue}Starting server on ${w.cyan}http://localhost:${_}/${w.reset}...`);let B=bk({port:_,async fetch(j){let H=new URL(j.url),L=a0.join(process.cwd(),"public",H.pathname);if(u4.existsSync(L)&&u4.statSync(L).isFile()){let V=Bun.file(L),N=a0.extname(L).toLowerCase(),A="application/octet-stream";if(N===".ts"||N===".tsx"){let R=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),M=await V.text(),E=R.transformSync(M);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(V,{headers:{"Content-Type":A}})}let F=G[H.pathname];if(!F&&!H.pathname.endsWith("/"))F=G[`${H.pathname}/`];if(!F)for(let V of K){let N=H.pathname.match(V.pattern);if(N){let A=G[V.routeTemplate];if(A){let R={};for(let I=0;I<V.paramNames.length;I++)R[V.paramNames[I]]=decodeURIComponent(N[I+1]);let M=A.content,E=`<script>window.__routeParams = ${JSON.stringify(R)};</script>`;if(M.includes("</head>"))M=M.replace("</head>",`${E}
14915
+ `,S=`/${a0.relative(Q,H).replace(/\.md$/,"")}`;if(S.endsWith("/index"))S=S.slice(0,-6)||"/";G[S||"/"]={filePath:H,content:I,fileType:"md"}}catch(F){console.error(`${w.red}Error processing Markdown file ${w.bright}${j}${w.reset}:`,F);continue}else{let F={name:"public-assets",setup(M){M.onResolve({filter:/^\/(images|fonts|assets|public)\//},(E)=>{return{path:E.path,external:!0}})}},O=await Bun.build({entrypoints:[H],outdir:J,plugins:[F,C$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!O.success){console.error(`${w.red}Build failed for ${w.bright}${j}${w.reset}:`,O.logs);continue}let V=O.outputs.find((M)=>M.path.endsWith(".html"));if(!V){console.error(`${w.red}No HTML output found for ${w.bright}${j}${w.reset}`);continue}let N=await Bun.file(V.path).text(),R=`/${a0.relative(Q,H).replace(/\.stx$/,"")}`;if(R.endsWith("/index"))R=R.slice(0,-6)||"/";if(R.includes("[")){let M=[...R.matchAll(/\[([^\]]+)\]/g)].map((I)=>I[1]),E=R.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:M,filePath:H,routeTemplate:R,fileType:"stx"}),G[R]={filePath:H,content:N,fileType:"stx"}}else G[R||"/"]={filePath:H,content:N,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${w.red}No files were successfully processed${w.reset}`),!1;return!0}catch(j){return console.error(`${w.red}Error processing files:${w.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await y6(Y),_!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${_} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}console.log(`${w.blue}Starting server on ${w.cyan}http://localhost:${_}/${w.reset}...`);let B=bk({port:_,async fetch(j){let H=new URL(j.url),L=a0.join(process.cwd(),"public",H.pathname);if(u6.existsSync(L)&&u6.statSync(L).isFile()){let V=Bun.file(L),N=a0.extname(L).toLowerCase(),A="application/octet-stream";if(N===".ts"||N===".tsx"){let R=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),M=await V.text(),E=R.transformSync(M);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(V,{headers:{"Content-Type":A}})}let F=G[H.pathname];if(!F&&!H.pathname.endsWith("/"))F=G[`${H.pathname}/`];if(!F)for(let V of K){let N=H.pathname.match(V.pattern);if(N){let A=G[V.routeTemplate];if(A){let R={};for(let I=0;I<V.paramNames.length;I++)R[V.paramNames[I]]=decodeURIComponent(N[I+1]);let M=A.content,E=`<script>window.__routeParams = ${JSON.stringify(R)};</script>`;if(M.includes("</head>"))M=M.replace("</head>",`${E}
14916
14916
  </head>`);else M=E+M;F={...A,content:M}}break}}if(F)return D0(F.content).then((V)=>{if(V.includes("</head>"))V=V.replace("</head>",`${rJ}
14917
- </head>`);return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let O=a0.join(J,H.pathname);if(u4.existsSync(O)&&u4.statSync(O).isFile()){let V=Bun.file(O),N=a0.extname(O).toLowerCase(),A="text/plain";if(N===".ts"||N===".tsx"){let R=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),M=await V.text(),E=R.transformSync(M);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(V,{headers:{"Content-Type":A}})}if(H.pathname!=="/"&&G["/"]){let V=j.headers.get("X-STX-Router")==="true";return D0(G["/"].content).then((N)=>{if(V){let A=N.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(A){let R=N.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=`<!DOCTYPE html><html><head><title>${R?R[1]:""}</title></head><body><main>${A[1]}</main></body></html>`;return new Response(E,{headers:{"Content-Type":"text/html","X-STX-Partial":"true","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}return new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(j){return new Response(`<pre>${j}
14917
+ </head>`);return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let O=a0.join(J,H.pathname);if(u6.existsSync(O)&&u6.statSync(O).isFile()){let V=Bun.file(O),N=a0.extname(O).toLowerCase(),A="text/plain";if(N===".ts"||N===".tsx"){let R=new Bun.Transpiler({loader:N===".tsx"?"tsx":"ts"}),M=await V.text(),E=R.transformSync(M);return new Response(E,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(N){case".html":A="text/html";break;case".css":A="text/css";break;case".js":A="text/javascript";break;case".json":A="application/json";break;case".png":A="image/png";break;case".jpg":case".jpeg":A="image/jpeg";break;case".gif":A="image/gif";break;case".svg":A="image/svg+xml";break;case".ico":A="image/x-icon";break;case".woff":A="font/woff";break;case".woff2":A="font/woff2";break;case".ttf":A="font/ttf";break;case".otf":A="font/otf";break;case".eot":A="application/vnd.ms-fontobject";break}return new Response(V,{headers:{"Content-Type":A}})}if(H.pathname!=="/"&&G["/"]){let V=j.headers.get("X-STX-Router")==="true";return D0(G["/"].content).then((N)=>{if(V){let A=N.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(A){let R=N.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=`<!DOCTYPE html><html><head><title>${R?R[1]:""}</title></head><body><main>${A[1]}</main></body></html>`;return new Response(E,{headers:{"Content-Type":"text/html","X-STX-Partial":"true","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}return new Response(N,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})})}return new Response("Not Found",{status:404})},error(j){return new Response(`<pre>${j}
14918
14918
  ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
14919
14919
  ${w.blue}stx${w.reset} ${w.green}${process.env.stx_VERSION||"v0.0.10"}${w.reset} ${w.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${w.reset}`),console.log(`
14920
14920
  ${w.bright}\u2192 ${w.cyan}http://localhost:${_}/${w.reset}`),console.log(`
14921
14921
  ${w.yellow}Routes:${w.reset}`);let z=new Set(K.map((j)=>j.routeTemplate)),q=Object.entries(G).filter(([j])=>!z.has(j)).sort(([j],[H])=>j.localeCompare(H)).map(([j,H])=>({route:j==="/"?"/":j,filePath:a0.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let j of K){let H=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");q.push({route:H,filePath:a0.relative(process.cwd(),j.filePath),fileType:"stx"})}if(q.sort((j,H)=>j.route.localeCompare(H.route)),q.forEach((j,H)=>{let F=H===q.length-1?"\u2514\u2500 ":"\u251C\u2500 ",O=j.fileType==="md"?`${w.magenta}(markdown)${w.reset}`:"";console.log(` ${w.green}${F}${j.route}${w.reset} \u2192 ${w.bright}${j.filePath}${w.reset} ${O}`)}),console.log(`
14922
- Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x4(B.url.toString(),()=>{if(X)u4.watch(Q,{recursive:!0}).close();B.stop()}),X){console.log(`${w.blue}Watching for changes...${w.reset}`);let j=u4.watch(Q,{recursive:!0},async(H,L)=>{if(!L)return;if(L.endsWith(".stx")||L.endsWith(".js")||L.endsWith(".ts")||L.endsWith(".md"))console.log(`${w.yellow}File ${w.bright}${L}${w.yellow} changed, rebuilding...${w.reset}`),M4.clear(),D4(),await W()});process.on("SIGINT",()=>{j.close(),B.stop(),process.exit(0)})}return!0}var XL=D(()=>{d6();u0();k6();l3();H0();d5()});var{serve:Ck}=globalThis.Bun;import F1 from"fs";import k0 from"path";function KG($){let Z=Bun.file($),Y=k0.extname($).toLowerCase(),X={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function C7($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=k0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (g4(),X6)),U=await W(K),_=U.root&&U.root!=="."?k0.join(K,U.root):K,B=U.pagesDir||"pages",z=k0.join(_,B);if(!F1.existsSync(z))return console.error(`${w.red}Error: No '${B}' directory found in ${w.bright}${_}${w.reset}`),console.log(`${w.dim}Create a ${B}/ directory with .stx files to define your routes.${w.reset}`),console.log(`${w.dim}Example: ${B}/index.stx for the homepage.${w.reset}`),!1;let q=G4(_);if(q.length===0)return console.error(`${w.red}Error: No page files found in ${w.bright}${z}${w.reset}`),!1;console.log(`${w.blue}Found ${w.bright}${q.length}${w.blue} routes${w.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:f,prefix:h}of j)if(F1.existsSync(f)){let u=G4(k0.dirname(f),{pagesDir:k0.basename(f)});for(let l of u){let p=h==="/"?l.pattern:`${h}${l.pattern==="/"?"":l.pattern}`;H.push({route:{...l,pattern:p},prefix:h})}if(u.length>0)console.log(`${w.blue}Plugin pages: ${w.bright}${u.length}${w.blue} routes at ${w.cyan}${h}${w.reset}`)}let L=new Map,F=null,O=null;if(Z.stxOptions?.shell!==!1){if(O=XJ(K,Z.stxOptions?.shell),O){if(F=await F3(O,Z.stxOptions||{}),F)console.log(`${w.blue}Using app shell: ${w.bright}${k0.relative(K,O)}${w.reset} ${w.dim}(deprecated: use layouts/default.stx instead)${w.reset}`)}}e5(),await X7(K);let V=Y7();if(V.length>0)console.log(`${w.blue}Loaded ${w.bright}${V.length}${w.blue} middleware: ${w.dim}${V.join(", ")}${w.reset}`);let N={},A=null;try{let{loadStxConfig:f}=await Promise.resolve().then(() => (g4(),X6)),h=await f(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${w.blue}Using custom router for API handling${w.reset}`);if(h?.apiRoutes){N=h.apiRoutes;let u=Object.keys(N).length;if(u>0)console.log(`${w.blue}Loaded ${w.bright}${u} API route${u>1?"s":""}${w.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:u,loadChannels:l}=await Promise.resolve().then(() => (w3(),RJ)),p=h.broadcasting;await u(p);let Q0=p.port??6001;console.log(`${w.magenta}Broadcasting on ${w.cyan}ws://localhost:${Q0}/ws${w.reset}`);let X0=k0.join(process.cwd(),"channels.ts");if(F1.existsSync(X0))try{let C0=await l(X0);console.log(`${w.blue}Loaded ${w.bright}${C0} broadcast channel${C0!==1?"s":""}${w.blue} from channels.ts${w.reset}`)}catch(C0){console.warn(`${w.yellow}Failed to load channels.ts: ${C0.message}${w.reset}`)}}catch(u){console.warn(`${w.yellow}Broadcasting failed to start: ${u.message}${w.reset}`)}}catch{}let R=k0.join(K,".stx/output");F1.mkdirSync(R,{recursive:!0});let M=new Map,E=async(f)=>{let h=QJ(z,f);if(!h)return null;try{let u=await Bun.build({entrypoints:[h],outdir:R,plugins:[C$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!u.success)return null;let l=u.outputs.find((p)=>p.path.endsWith(".html"));if(!l)return null;return await Bun.file(l.path).text()}catch{return null}},I=async(f,h)=>{try{let{processDirectives:u,extractVariables:l,defaultConfig:p,loadStxConfig:Q0,injectRouterScript:X0}=await Promise.resolve().then(() => (g4(),X6)),C0=await Q0(K),T0=await Bun.file(f.filePath).text(),{classifyAllScripts:b}=await Promise.resolve().then(() => (g4(),X6)),d=b(T0),m=d.server.map((w0)=>w0.content),i=T0;for(let w0 of d.server)i=i.replace(w0.fullTag,"");let c={__filename:f.filePath,__dirname:k0.dirname(f.filePath),params:h??{}},{resetHead:r}=await Promise.resolve().then(() => (N4(),b8));r();for(let w0 of m)try{await l(w0,c,f.filePath)}catch(o0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",f.filePath,o0?.message||o0)}let _0=new Set,W0=(w0)=>{if(!w0)return w0;if(k0.isAbsolute(w0))return w0;return k0.resolve(K,w0)},K0={...p,...C0,...Z.stxOptions,autoShell:!0};K0.partialsDir=W0(K0.partialsDir),K0.componentsDir=W0(K0.componentsDir),K0.layoutsDir=W0(K0.layoutsDir),K0.storesDir=W0(K0.storesDir||"stores");let R0=await u(i,c,f.filePath,K0,_0);if(!F)R0=await X0(R0);{let{interpolateScriptExpressions:w0}=await Promise.resolve().then(() => (r0(),n$));R0=R0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(o0,n1,j6)=>{if(!/function\s+__stx_setup_/.test(j6))return o0;return`<script${n1}>${w0(j6,c)}</script>`})}if(F)R0=Y6(R0);return{route:f,content:R0}}catch(u){return console.error(`${w.red}Error building ${w.bright}${f.pattern}${w.reset}:`,u),null}},T=async()=>{M.clear(),L.clear();for(let f of q){let h=await I(f);if(h)M.set(f.pattern,h)}for(let{route:f}of H){let h=await I(f);if(h)L.set(f.pattern,h)}return M.size>0};if(console.log(`${w.blue}Building pages...${w.reset}`),!await T())return console.error(`${w.red}No pages were successfully built${w.reset}`),!1;await R6(K);let k=Y;try{if(k=await y4(Y),k!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${k} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}if(J){let f=Z.hmrPort||k+1;Q=l5({wsPort:f,verbose:!1}),G=Q.start(f)}let C=(f,h)=>{let u=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(f.includes("</head>"))return f.replace("</head>",`${u}</head>`);if(f.includes("<body"))return f.replace(/<body([^>]*)>/,`<body$1>${u}`);return u+f};console.log(`${w.blue}Starting server...${w.reset}`);let x=Ck({port:k,async fetch(f){let h=new URL(f.url),u=U?.publicDir||"public",l=k0.join(K,u,h.pathname);if(F1.existsSync(l)&&F1.statSync(l).isFile())return KG(l);let p=k0.join(K,h.pathname);if(F1.existsSync(p)&&F1.statSync(p).isFile())return KG(p);let Q0=k0.join(R,h.pathname);if(F1.existsSync(Q0)&&F1.statSync(Q0).isFile())return KG(Q0);if(h.pathname.startsWith("/_stx/component/")){let b=decodeURIComponent(h.pathname.slice(16));if(b)try{let d=`<${b} />`,m={...buildConfig,autoShell:!1},i=await processDirectives(d,{},k0.join(K,"components",`${b}.stx`),m,new Set);return new Response(i,{headers:{"Content-Type":"text/html"}})}catch(d){return new Response(`<div class="stx-async-error">${d.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(A)try{let b=await A.handleRequest(f);if(b.status!==404)return b}catch{}if(N[h.pathname])try{return await N[h.pathname](f)}catch(b){return new Response(JSON.stringify({error:b.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X0=V3(h.pathname,q);if(X0){let b=M.get(X0.route.pattern);if(X0.route.isDynamic&&Object.keys(X0.params).length>0){let d=await I(X0.route,X0.params);if(d)b=d}if(b){let d=S8();if(d.validate){if(!await d.validate({params:X0.params})){let c=await E(404);if(c){let r=c;if(r=await D0(r,K),J)r=f1(r,G);return new Response(r,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(d.middleware){let i=Z7(h.pathname,X0.params,d,h.search),c=$7(i,null,f),r=await J7(d.middleware,c);if(r.redirect){let _0=r.redirect.path,W0=r.redirect.options.redirectCode||302,K0=new Headers(r.responseHeaders);return K0.set("Location",_0),new Response(null,{status:W0,headers:K0})}if(r.abort){let{statusCode:_0,message:W0}=r.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${_0}</title></head><body><h1>Error ${_0}</h1><p>${W0}</p></body></html>`,{status:_0,headers:{"Content-Type":"text/html"}})}if(Object.keys(r.state).length>0){let _0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(r.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;b.content=b.content.replace("</head>",`${_0}</head>`)}}let m=b.content;if(F&&JJ(f)){if(Object.keys(X0.params).length>0)m=C(m,X0.params);m=await D0(m,K);let i=U?.router?.container||"main";return m=K7(m,i),new Response(m,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)m=G7(F,m);if(Object.keys(X0.params).length>0)m=C(m,X0.params);if(m=await D0(m,K),J)m=f1(m,G);if(Z.native)if(m.includes("<head>"))m=m.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else m="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+m;return new Response(m,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let b=H.map((m)=>m.route),d=V3(h.pathname,b);if(d){let m=L.get(d.route.pattern);if(m){let i=m.content;if(F)i=G7(F,i);if(Object.keys(d.params).length>0)i=C(i,d.params);if(i=await D0(i,K),J)i=f1(i,G);return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:m}of j)if(m!=="/"&&h.pathname.startsWith(m)){let i=L.get(m)||L.get(m+"/");if(i){let c=i.content;if(F)c=G7(F,c);if(c=await D0(c,K),J)c=f1(c,G);return new Response(c,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let C0=M.get("/");if(C0){let b=C0.content;if(b=await D0(b,K),J)b=f1(b,G);if(Z.native)if(b.includes("<head>"))b=b.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else b="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+b;return new Response(b,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let T0=await E(404);if(T0){let b=T0;if(b=await D0(b,K),J)b=f1(b,G);return new Response(b,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(f){let h=await E(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${f}
14922
+ Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x6(B.url.toString(),()=>{if(X)u6.watch(Q,{recursive:!0}).close();B.stop()}),X){console.log(`${w.blue}Watching for changes...${w.reset}`);let j=u6.watch(Q,{recursive:!0},async(H,L)=>{if(!L)return;if(L.endsWith(".stx")||L.endsWith(".js")||L.endsWith(".ts")||L.endsWith(".md"))console.log(`${w.yellow}File ${w.bright}${L}${w.yellow} changed, rebuilding...${w.reset}`),M6.clear(),D6(),await W()});process.on("SIGINT",()=>{j.close(),B.stop(),process.exit(0)})}return!0}var XL=D(()=>{d4();u0();k4();l3();H0();d5()});var{serve:Ck}=globalThis.Bun;import F1 from"fs";import k0 from"path";function KG($){let Z=Bun.file($),Y=k0.extname($).toLowerCase(),X={".html":"text/html",".css":"text/css",".js":"text/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".otf":"font/otf",".eot":"application/vnd.ms-fontobject"},Q=[".js",".css",".json"].includes(Y)?{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}:{};return new Response(Z,{headers:{"Content-Type":X[Y]||"application/octet-stream",...Q}})}async function C7($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=k0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (g6(),X4)),U=await W(K),_=U.root&&U.root!=="."?k0.join(K,U.root):K,B=U.pagesDir||"pages",z=k0.join(_,B);if(!F1.existsSync(z))return console.error(`${w.red}Error: No '${B}' directory found in ${w.bright}${_}${w.reset}`),console.log(`${w.dim}Create a ${B}/ directory with .stx files to define your routes.${w.reset}`),console.log(`${w.dim}Example: ${B}/index.stx for the homepage.${w.reset}`),!1;let q=G6(_);if(q.length===0)return console.error(`${w.red}Error: No page files found in ${w.bright}${z}${w.reset}`),!1;console.log(`${w.blue}Found ${w.bright}${q.length}${w.blue} routes${w.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:f,prefix:h}of j)if(F1.existsSync(f)){let u=G6(k0.dirname(f),{pagesDir:k0.basename(f)});for(let l of u){let p=h==="/"?l.pattern:`${h}${l.pattern==="/"?"":l.pattern}`;H.push({route:{...l,pattern:p},prefix:h})}if(u.length>0)console.log(`${w.blue}Plugin pages: ${w.bright}${u.length}${w.blue} routes at ${w.cyan}${h}${w.reset}`)}let L=new Map,F=null,O=null;if(Z.stxOptions?.shell!==!1){if(O=XJ(K,Z.stxOptions?.shell),O){if(F=await F3(O,Z.stxOptions||{}),F)console.log(`${w.blue}Using app shell: ${w.bright}${k0.relative(K,O)}${w.reset} ${w.dim}(deprecated: use layouts/default.stx instead)${w.reset}`)}}e5(),await X7(K);let V=Y7();if(V.length>0)console.log(`${w.blue}Loaded ${w.bright}${V.length}${w.blue} middleware: ${w.dim}${V.join(", ")}${w.reset}`);let N={},A=null;try{let{loadStxConfig:f}=await Promise.resolve().then(() => (g6(),X4)),h=await f(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${w.blue}Using custom router for API handling${w.reset}`);if(h?.apiRoutes){N=h.apiRoutes;let u=Object.keys(N).length;if(u>0)console.log(`${w.blue}Loaded ${w.bright}${u} API route${u>1?"s":""}${w.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:u,loadChannels:l}=await Promise.resolve().then(() => (w3(),RJ)),p=h.broadcasting;await u(p);let Q0=p.port??6001;console.log(`${w.magenta}Broadcasting on ${w.cyan}ws://localhost:${Q0}/ws${w.reset}`);let X0=k0.join(process.cwd(),"channels.ts");if(F1.existsSync(X0))try{let C0=await l(X0);console.log(`${w.blue}Loaded ${w.bright}${C0} broadcast channel${C0!==1?"s":""}${w.blue} from channels.ts${w.reset}`)}catch(C0){console.warn(`${w.yellow}Failed to load channels.ts: ${C0.message}${w.reset}`)}}catch(u){console.warn(`${w.yellow}Broadcasting failed to start: ${u.message}${w.reset}`)}}catch{}let R=k0.join(K,".stx/output");F1.mkdirSync(R,{recursive:!0});let M=new Map,E=async(f)=>{let h=QJ(z,f);if(!h)return null;try{let u=await Bun.build({entrypoints:[h],outdir:R,plugins:[C$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!u.success)return null;let l=u.outputs.find((p)=>p.path.endsWith(".html"));if(!l)return null;return await Bun.file(l.path).text()}catch{return null}},I=async(f,h)=>{try{let{processDirectives:u,extractVariables:l,defaultConfig:p,loadStxConfig:Q0,injectRouterScript:X0}=await Promise.resolve().then(() => (g6(),X4)),C0=await Q0(K),T0=await Bun.file(f.filePath).text(),{classifyAllScripts:b}=await Promise.resolve().then(() => (g6(),X4)),d=b(T0),m=d.server.map((w0)=>w0.content),i=T0;for(let w0 of d.server)i=i.replace(w0.fullTag,"");let c={__filename:f.filePath,__dirname:k0.dirname(f.filePath),params:h??{}},{resetHead:r}=await Promise.resolve().then(() => (N6(),b8));r();for(let w0 of m)try{await l(w0,c,f.filePath)}catch(o0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",f.filePath,o0?.message||o0)}let _0=new Set,W0=(w0)=>{if(!w0)return w0;if(k0.isAbsolute(w0))return w0;return k0.resolve(K,w0)},K0={...p,...C0,...Z.stxOptions,autoShell:!0};K0.partialsDir=W0(K0.partialsDir),K0.componentsDir=W0(K0.componentsDir),K0.layoutsDir=W0(K0.layoutsDir),K0.storesDir=W0(K0.storesDir||"stores");let R0=await u(i,c,f.filePath,K0,_0);if(!F)R0=await X0(R0);{let{interpolateScriptExpressions:w0}=await Promise.resolve().then(() => (r0(),n$));R0=R0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(o0,n1,j4)=>{if(!/function\s+__stx_setup_/.test(j4))return o0;return`<script${n1}>${w0(j4,c)}</script>`})}if(F)R0=Y4(R0);return{route:f,content:R0}}catch(u){return console.error(`${w.red}Error building ${w.bright}${f.pattern}${w.reset}:`,u),null}},T=async()=>{M.clear(),L.clear();for(let f of q){let h=await I(f);if(h)M.set(f.pattern,h)}for(let{route:f}of H){let h=await I(f);if(h)L.set(f.pattern,h)}return M.size>0};if(console.log(`${w.blue}Building pages...${w.reset}`),!await T())return console.error(`${w.red}No pages were successfully built${w.reset}`),!1;await R4(K);let k=Y;try{if(k=await y6(Y),k!==Y)console.log(`${w.yellow}Port ${Y} is busy, using port ${k} instead${w.reset}`)}catch{return console.error(`${w.red}Could not find an available port${w.reset}`),!1}if(J){let f=Z.hmrPort||k+1;Q=l5({wsPort:f,verbose:!1}),G=Q.start(f)}let C=(f,h)=>{let u=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(f.includes("</head>"))return f.replace("</head>",`${u}</head>`);if(f.includes("<body"))return f.replace(/<body([^>]*)>/,`<body$1>${u}`);return u+f};console.log(`${w.blue}Starting server...${w.reset}`);let x=Ck({port:k,async fetch(f){let h=new URL(f.url),u=U?.publicDir||"public",l=k0.join(K,u,h.pathname);if(F1.existsSync(l)&&F1.statSync(l).isFile())return KG(l);let p=k0.join(K,h.pathname);if(F1.existsSync(p)&&F1.statSync(p).isFile())return KG(p);let Q0=k0.join(R,h.pathname);if(F1.existsSync(Q0)&&F1.statSync(Q0).isFile())return KG(Q0);if(h.pathname.startsWith("/_stx/component/")){let b=decodeURIComponent(h.pathname.slice(16));if(b)try{let d=`<${b} />`,m={...buildConfig,autoShell:!1},i=await processDirectives(d,{},k0.join(K,"components",`${b}.stx`),m,new Set);return new Response(i,{headers:{"Content-Type":"text/html"}})}catch(d){return new Response(`<div class="stx-async-error">${d.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(A)try{let b=await A.handleRequest(f);if(b.status!==404)return b}catch{}if(N[h.pathname])try{return await N[h.pathname](f)}catch(b){return new Response(JSON.stringify({error:b.message}),{status:500,headers:{"Content-Type":"application/json"}})}let X0=V3(h.pathname,q);if(X0){let b=M.get(X0.route.pattern);if(X0.route.isDynamic&&Object.keys(X0.params).length>0){let d=await I(X0.route,X0.params);if(d)b=d}if(b){let d=S8();if(d.validate){if(!await d.validate({params:X0.params})){let c=await E(404);if(c){let r=c;if(r=await D0(r,K),J)r=f1(r,G);return new Response(r,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(d.middleware){let i=Z7(h.pathname,X0.params,d,h.search),c=$7(i,null,f),r=await J7(d.middleware,c);if(r.redirect){let _0=r.redirect.path,W0=r.redirect.options.redirectCode||302,K0=new Headers(r.responseHeaders);return K0.set("Location",_0),new Response(null,{status:W0,headers:K0})}if(r.abort){let{statusCode:_0,message:W0}=r.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${_0}</title></head><body><h1>Error ${_0}</h1><p>${W0}</p></body></html>`,{status:_0,headers:{"Content-Type":"text/html"}})}if(Object.keys(r.state).length>0){let _0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(r.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;b.content=b.content.replace("</head>",`${_0}</head>`)}}let m=b.content;if(F&&JJ(f)){if(Object.keys(X0.params).length>0)m=C(m,X0.params);m=await D0(m,K);let i=U?.router?.container||"main";return m=K7(m,i),new Response(m,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)m=G7(F,m);if(Object.keys(X0.params).length>0)m=C(m,X0.params);if(m=await D0(m,K),J)m=f1(m,G);if(Z.native)if(m.includes("<head>"))m=m.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else m="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+m;return new Response(m,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let b=H.map((m)=>m.route),d=V3(h.pathname,b);if(d){let m=L.get(d.route.pattern);if(m){let i=m.content;if(F)i=G7(F,i);if(Object.keys(d.params).length>0)i=C(i,d.params);if(i=await D0(i,K),J)i=f1(i,G);return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:m}of j)if(m!=="/"&&h.pathname.startsWith(m)){let i=L.get(m)||L.get(m+"/");if(i){let c=i.content;if(F)c=G7(F,c);if(c=await D0(c,K),J)c=f1(c,G);return new Response(c,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let C0=M.get("/");if(C0){let b=C0.content;if(b=await D0(b,K),J)b=f1(b,G);if(Z.native)if(b.includes("<head>"))b=b.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else b="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+b;return new Response(b,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let T0=await E(404);if(T0){let b=T0;if(b=await D0(b,K),J)b=f1(b,G);return new Response(b,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(f){let h=await E(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${f}
14923
14923
  ${f.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
14924
14924
  ${w.blue}stx${w.reset} ${w.green}${process.env.stx_VERSION||"v0.0.10"}${w.reset} ${w.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${w.reset}`),console.log(`
14925
14925
  ${w.bright}\u2192 ${w.cyan}http://localhost:${k}/${w.reset}`),J)console.log(`${w.dim} HMR: ws://localhost:${G}${w.reset}`);console.log(`
14926
14926
  ${w.yellow}Routes:${w.reset}`);let P=[...GJ(q,K)];for(let{route:f}of H)P.push(`${f.pattern}`);if(P.forEach((f,h)=>{let l=h===P.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${w.green}${l}${w.reset}${f}`)}),console.log(`
14927
- Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x4(x.url.toString(),()=>{if(Q)q$();x.stop()}),Z.native){let f,h=k0.join(z,"index.stx");if(F1.existsSync(h)){let u=await Bun.file(h).text();f=e9(u)}await _$(k,{title:k0.basename(K)||"stx App",nativeSidebar:!!f,sidebarConfig:f})}if(X){console.log(`${w.blue}Watching for changes...${w.reset}`);let f=(l)=>{return l.startsWith("public/")||l.startsWith("public\\")},h=(l)=>{let p=l.toLowerCase();return p.endsWith(".stx")||p.endsWith(".html")||p.endsWith(".md")},u=F1.watch(K,{recursive:!0},async(l,p)=>{if(!p||c5(p))return;if(u5(p)){if(f(p)){if(console.log(`${w.cyan}${p} changed${w.reset}`),J&&Q)Q.reload(p)}else if(h(p)){if(console.log(`${w.yellow}${p} changed, rebuilding...${w.reset}`),M4.clear(),D4(),O&&p){if(k0.resolve(K,p)===O||k0.basename(O)===p){let X0=await F3(O,Z.stxOptions||{});if(X0)F=X0}}if(await T(),await o$(K),J&&Q)Q.reload(p)}else if(console.log(`${w.yellow}${p} changed, rebuilding...${w.reset}`),M4.clear(),D4(),await T(),J&&Q)Q.reload(p)}else if(m5(p)){if(console.log(`${w.cyan}CSS ${p} changed${w.reset}`),J&&Q)Q.updateCss(p)}});process.on("SIGINT",()=>{if(u.close(),Q)q$();x.stop(),process.exit(0)})}return!0}var JL=D(()=>{W7();k6();l3();U7();L3();N4();H0();d5()});var GG=D(()=>{dX();YL();XL();JL()});var WL={};t(WL,{runPwaAudit:()=>Pk,formatAuditResult:()=>yk,calculateAuditResult:()=>KL,auditConfig:()=>QL,auditBuildOutput:()=>GL});import B6 from"fs";import p3 from"path";function QL($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let X=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:X.includes(192),message:X.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:X.includes(512),message:X.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let J=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:J.length>0,message:J.length>0?`${J.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function GL($){let Z=[],Y=p3.join($,"manifest.json"),X=B6.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:X,message:X?"manifest.json exists":"manifest.json not found in build output"}),X)try{let _=JSON.parse(B6.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(_.icons)&&_.icons.length>0,message:_.icons?.length?`${_.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let J=p3.join($,"sw.js"),Q=B6.existsSync(J);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=p3.join($,"offline.html"),K=B6.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=p3.join($,"pwa-icons");if(B6.existsSync(W)){let _=B6.readdirSync(W).filter((B)=>B.endsWith(".png")||B.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:_.length>0,message:_.length>0?`${_.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function KL($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),X=Z.filter((W)=>W.passed).length,J=Y.filter((W)=>W.passed).length,Q=Z.length>0?X/Z.length*70:70,G=Y.length>0?J/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function Pk($,Z){let Y=QL($),X=Z&&B6.existsSync(Z)?GL(Z):[];return KL([...Y,...X])}function yk($){let Z=[];Z.push(`
14927
+ Press ${w.cyan}h${w.reset} + ${w.cyan}Enter${w.reset} to show shortcuts`),x6(x.url.toString(),()=>{if(Q)q$();x.stop()}),Z.native){let f,h=k0.join(z,"index.stx");if(F1.existsSync(h)){let u=await Bun.file(h).text();f=e9(u)}await _$(k,{title:k0.basename(K)||"stx App",nativeSidebar:!!f,sidebarConfig:f})}if(X){console.log(`${w.blue}Watching for changes...${w.reset}`);let f=(l)=>{return l.startsWith("public/")||l.startsWith("public\\")},h=(l)=>{let p=l.toLowerCase();return p.endsWith(".stx")||p.endsWith(".html")||p.endsWith(".md")},u=F1.watch(K,{recursive:!0},async(l,p)=>{if(!p||c5(p))return;if(u5(p)){if(f(p)){if(console.log(`${w.cyan}${p} changed${w.reset}`),J&&Q)Q.reload(p)}else if(h(p)){if(console.log(`${w.yellow}${p} changed, rebuilding...${w.reset}`),M6.clear(),D6(),O&&p){if(k0.resolve(K,p)===O||k0.basename(O)===p){let X0=await F3(O,Z.stxOptions||{});if(X0)F=X0}}if(await T(),await o$(K),J&&Q)Q.reload(p)}else if(console.log(`${w.yellow}${p} changed, rebuilding...${w.reset}`),M6.clear(),D6(),await T(),J&&Q)Q.reload(p)}else if(m5(p)){if(console.log(`${w.cyan}CSS ${p} changed${w.reset}`),J&&Q)Q.updateCss(p)}});process.on("SIGINT",()=>{if(u.close(),Q)q$();x.stop(),process.exit(0)})}return!0}var JL=D(()=>{W7();k4();l3();U7();L3();N6();H0();d5()});var GG=D(()=>{dX();YL();XL();JL()});var WL={};t(WL,{runPwaAudit:()=>Pk,formatAuditResult:()=>yk,calculateAuditResult:()=>KL,auditConfig:()=>QL,auditBuildOutput:()=>GL});import B4 from"fs";import p3 from"path";function QL($){let Z=[],Y=$.pwa;if(Z.push({id:"pwa-enabled",name:"PWA Enabled",category:"required",passed:Y?.enabled===!0,message:Y?.enabled?"PWA is enabled":"PWA is not enabled in config"}),!Y?.enabled)return Z;Z.push({id:"manifest-name",name:"App Name",category:"required",passed:Boolean(Y.manifest?.name),message:Y.manifest?.name?`App name: "${Y.manifest.name}"`:"Missing required manifest name"}),Z.push({id:"manifest-short-name",name:"Short Name",category:"recommended",passed:Boolean(Y.manifest?.shortName),message:Y.manifest?.shortName?`Short name: "${Y.manifest.shortName}"`:"Short name not set (will use full name)"}),Z.push({id:"manifest-description",name:"App Description",category:"recommended",passed:Boolean(Y.manifest?.description),message:Y.manifest?.description?"Description is set":"App description not provided"}),Z.push({id:"manifest-theme-color",name:"Theme Color",category:"required",passed:Boolean(Y.manifest?.themeColor),message:Y.manifest?.themeColor?`Theme color: ${Y.manifest.themeColor}`:"Theme color not set"}),Z.push({id:"manifest-background-color",name:"Background Color",category:"required",passed:Boolean(Y.manifest?.backgroundColor),message:Y.manifest?.backgroundColor?`Background color: ${Y.manifest.backgroundColor}`:"Background color not set"}),Z.push({id:"manifest-display",name:"Display Mode",category:"required",passed:["standalone","fullscreen","minimal-ui"].includes(Y.manifest?.display||""),message:Y.manifest?.display?`Display mode: ${Y.manifest.display}`:"Display mode should be standalone, fullscreen, or minimal-ui"}),Z.push({id:"manifest-start-url",name:"Start URL",category:"required",passed:Boolean(Y.manifest?.startUrl),message:Y.manifest?.startUrl?`Start URL: ${Y.manifest.startUrl}`:"Start URL not set"}),Z.push({id:"icons-source",name:"Icon Source",category:"required",passed:Boolean(Y.icons?.src),message:Y.icons?.src?`Icon source: ${Y.icons.src}`:"No icon source configured"});let X=Y.icons?.sizes||[];Z.push({id:"icons-192",name:"192x192 Icon",category:"required",passed:X.includes(192),message:X.includes(192)?"192x192 icon will be generated":"Missing 192x192 icon (required for Android)"}),Z.push({id:"icons-512",name:"512x512 Icon",category:"required",passed:X.includes(512),message:X.includes(512)?"512x512 icon will be generated":"Missing 512x512 icon (required for splash screen)"}),Z.push({id:"icons-maskable",name:"Maskable Icon",category:"recommended",passed:Y.icons?.purpose?.includes("maskable")||!1,message:Y.icons?.purpose?.includes("maskable")?"Maskable icon purpose is set":"Consider adding maskable icon purpose for adaptive icons"}),Z.push({id:"sw-configured",name:"Service Worker",category:"required",passed:Boolean(Y.serviceWorker),message:Y.serviceWorker?"Service worker is configured":"Service worker configuration missing"}),Z.push({id:"sw-cache-version",name:"Cache Version",category:"recommended",passed:Boolean(Y.serviceWorker?.cacheVersion),message:Y.serviceWorker?.cacheVersion?`Cache version: ${Y.serviceWorker.cacheVersion}`:"Set cache version for proper cache busting"}),Z.push({id:"offline-enabled",name:"Offline Support",category:"required",passed:Y.offline?.enabled===!0,message:Y.offline?.enabled?"Offline support is enabled":"Offline support is disabled"});let J=Y.routes||[];return Z.push({id:"caching-strategies",name:"Caching Strategies",category:"recommended",passed:J.length>0,message:J.length>0?`${J.length} route caching strategies configured`:"No custom caching strategies defined"}),Z.push({id:"push-config",name:"Push Notifications",category:"optional",passed:!Y.push?.enabled||Boolean(Y.push?.vapidPublicKey),message:Y.push?.enabled?Y.push?.vapidPublicKey?"Push notifications configured with VAPID key":"Push enabled but missing VAPID key":"Push notifications not enabled"}),Z.push({id:"share-target",name:"Share Target",category:"optional",passed:!0,message:Y.shareTarget?.enabled?`Share target enabled at ${Y.shareTarget.action}`:"Share target not enabled"}),Z.push({id:"auto-inject",name:"Auto-injection",category:"recommended",passed:Y.autoInject!==!1,message:Y.autoInject!==!1?"PWA tags will be auto-injected":"Auto-injection disabled - manual tag insertion required"}),Z}function GL($){let Z=[],Y=p3.join($,"manifest.json"),X=B4.existsSync(Y);if(Z.push({id:"build-manifest",name:"Manifest File",category:"required",passed:X,message:X?"manifest.json exists":"manifest.json not found in build output"}),X)try{let _=JSON.parse(B4.readFileSync(Y,"utf-8"));Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!0,message:"Manifest is valid JSON"}),Z.push({id:"build-manifest-icons",name:"Manifest Icons",category:"required",passed:Array.isArray(_.icons)&&_.icons.length>0,message:_.icons?.length?`${_.icons.length} icons defined in manifest`:"No icons defined in manifest"})}catch{Z.push({id:"build-manifest-valid",name:"Valid Manifest JSON",category:"required",passed:!1,message:"Manifest is not valid JSON"})}let J=p3.join($,"sw.js"),Q=B4.existsSync(J);Z.push({id:"build-sw",name:"Service Worker File",category:"required",passed:Q,message:Q?"Service worker (sw.js) exists":"Service worker not found in build output"});let G=p3.join($,"offline.html"),K=B4.existsSync(G);Z.push({id:"build-offline",name:"Offline Page",category:"recommended",passed:K,message:K?"Offline page exists":"No offline.html found"});let W=p3.join($,"pwa-icons");if(B4.existsSync(W)){let _=B4.readdirSync(W).filter((B)=>B.endsWith(".png")||B.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:_.length>0,message:_.length>0?`${_.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function KL($){let Z=$.filter((W)=>W.category==="required"),Y=$.filter((W)=>W.category==="recommended"),X=Z.filter((W)=>W.passed).length,J=Y.filter((W)=>W.passed).length,Q=Z.length>0?X/Z.length*70:70,G=Y.length>0?J/Y.length*30:30;return{score:Math.round(Q+G),passed:$.filter((W)=>W.passed).length,failed:$.filter((W)=>!W.passed&&W.category==="required").length,warnings:$.filter((W)=>!W.passed&&W.category!=="required").length,checks:$}}function Pk($,Z){let Y=QL($),X=Z&&B4.existsSync(Z)?GL(Z):[];return KL([...Y,...X])}function yk($){let Z=[];Z.push(`
14928
14928
  === PWA Audit Report ===
14929
14929
  `);let Y=$.score>=90?"32":$.score>=70?"33":"31";Z.push(`Score: \x1B[${Y}m${$.score}/100\x1B[0m`),Z.push(`Passed: ${$.passed} | Failed: ${$.failed} | Warnings: ${$.warnings}
14930
14930
  `);let X=["required","recommended","optional"];for(let J of X){let Q=$.checks.filter((G)=>G.category===J);if(Q.length===0)continue;Z.push(`
@@ -16614,7 +16614,7 @@ ${Y}`);return Y+$}var OL=()=>{};function AL($,Z={}){let{classPrefix:Y="craft"}=Z
16614
16614
  </details>`}},divider:{nativeType:"craft-divider",fallbackTag:"hr",fallbackClasses:"craft-divider",nativeProps:["orientation","variant"]},table:{nativeType:"craft-table",fallbackTag:"table",fallbackClasses:"craft-table",nativeProps:["columns","rows","sortable","selectable"]},list:{nativeType:"craft-list",fallbackTag:"ul",fallbackClasses:"craft-list",nativeProps:["items","selectable"]},tree:{nativeType:"craft-tree",fallbackTag:"div",fallbackClasses:"craft-tree",nativeProps:["nodes","expandable","selectable"]},alert:{nativeType:"craft-alert",fallbackTag:"div",fallbackClasses:"craft-alert",nativeProps:["variant","title","dismissible"],render:($,Z)=>{let Y=$.variant||"info",X=$.title||"";return`<div class="craft-alert craft-alert-${Y}" role="alert">
16615
16615
  ${X?`<div class="craft-alert-title">${X}</div>`:""}
16616
16616
  <div class="craft-alert-content">${Z}</div>
16617
- </div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:($,Z)=>{let Y=$.content||"",X=$.position||"top";return`<span class="craft-tooltip" data-tooltip="${Y}" data-position="${X}">${Z}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:($,Z)=>{return`<input type="color" class="craft-color-picker" value="${$.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:($,Z)=>{let Y=$.value||"",X=$.min||"",J=$.max||"";return`<input type="date" class="craft-date-picker" value="${Y}" min="${X}" max="${J}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:($,Z)=>{return`<input type="time" class="craft-time-picker" value="${$.value||""}">`}}}});var DL={};t(DL,{getAvailableTargets:()=>TL,getAvailableFormats:()=>IL,default:()=>RS,buildNative:()=>EL});import{existsSync as wL,mkdirSync as V1,copyFileSync as d7,chmodSync as z6}from"fs";import{join as s,basename as KS}from"path";import{spawn as a3,execSync as WS}from"child_process";import{tmpdir as ML,homedir as RL,platform as US}from"os";async function EL($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||h7(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||h7(),X=$.format||LS(Y),J=$.output||s(process.cwd(),"dist","native");if(!wL(J))V1(J,{recursive:!0});let Q=await Bun.file($.input).text();if(Q=LL(Q,{debug:$.verbose}),Q=AL(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${VL}
16617
+ </div>`}},toast:{nativeType:"craft-toast",fallbackTag:"div",fallbackClasses:"craft-toast",nativeProps:["variant","duration","position"]},tooltip:{nativeType:"craft-tooltip",fallbackTag:"span",fallbackClasses:"craft-tooltip",nativeProps:["content","position"],render:($,Z)=>{let Y=$.content||"",X=$.position||"top";return`<span class="craft-tooltip" data-tooltip="${Y}" data-position="${X}">${Z}</span>`}},menu:{nativeType:"craft-menu",fallbackTag:"nav",fallbackClasses:"craft-menu",nativeProps:["items","orientation"]},breadcrumb:{nativeType:"craft-breadcrumb",fallbackTag:"nav",fallbackClasses:"craft-breadcrumb",nativeProps:["items","separator"]},pagination:{nativeType:"craft-pagination",fallbackTag:"nav",fallbackClasses:"craft-pagination",nativeProps:["total","page","pageSize"]},"code-editor":{nativeType:"craft-code-editor",fallbackTag:"textarea",fallbackClasses:"craft-code-editor",nativeProps:["value","language","theme","readonly","lineNumbers"]},"file-browser":{nativeType:"craft-file-browser",fallbackTag:"div",fallbackClasses:"craft-file-browser",nativeProps:["path","showHidden","selectable"]},"color-picker":{nativeType:"craft-color-picker",fallbackTag:"input",fallbackClasses:"craft-color-picker",nativeProps:["value","format"],render:($,Z)=>{return`<input type="color" class="craft-color-picker" value="${$.value||"#000000"}">`}},"date-picker":{nativeType:"craft-date-picker",fallbackTag:"input",fallbackClasses:"craft-date-picker",nativeProps:["value","min","max","format"],render:($,Z)=>{let Y=$.value||"",X=$.min||"",J=$.max||"";return`<input type="date" class="craft-date-picker" value="${Y}" min="${X}" max="${J}">`}},"time-picker":{nativeType:"craft-time-picker",fallbackTag:"input",fallbackClasses:"craft-time-picker",nativeProps:["value","min","max","step"],render:($,Z)=>{return`<input type="time" class="craft-time-picker" value="${$.value||""}">`}}}});var DL={};t(DL,{getAvailableTargets:()=>TL,getAvailableFormats:()=>IL,default:()=>RS,buildNative:()=>EL});import{existsSync as wL,mkdirSync as V1,copyFileSync as d7,chmodSync as z4}from"fs";import{join as s,basename as KS}from"path";import{spawn as a3,execSync as WS}from"child_process";import{tmpdir as ML,homedir as RL,platform as US}from"os";async function EL($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||h7(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||h7(),X=$.format||LS(Y),J=$.output||s(process.cwd(),"dist","native");if(!wL(J))V1(J,{recursive:!0});let Q=await Bun.file($.input).text();if(Q=LL(Q,{debug:$.verbose}),Q=AL(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${VL}
16618
16618
  </head>`)}let G=$.name||KS($.input,".stx"),K=$.version||"1.0.0",W=$.craftPath||await HS();if(!W)return{success:!1,target:Y,format:X,error:"Craft binary not found. Please install Craft or specify craftPath."};if($.verbose)console.log(`\uD83D\uDCE6 Building native app for ${Y}...`),console.log(` Input: ${$.input}`),console.log(` Output: ${J}`),console.log(` Craft: ${W}`);let U;switch(Y){case"macos":U=await _S(Q,G,K,J,X,$,W);break;case"windows":U=await BS(Q,G,K,J,X,$,W);break;case"linux":U=await zS(Q,G,K,J,X,$,W);break;case"ios":U=await qS(Q,G,K,J,$,W);break;case"android":U=await jS(Q,G,K,J,$,W);break;default:U={success:!1,target:Y,format:X,error:`Unsupported target: ${Y}`}}return U.duration=Date.now()-Z,U}catch(Y){return{success:!1,target:$.target||h7(),format:$.format||"app",error:Y.message,duration:Date.now()-Z}}}async function _S($,Z,Y,X,J,Q,G){let K=Q.bundleId||`com.stx.${Z.toLowerCase().replace(/[^a-z0-9]/g,"")}`,W=s(X,`${Z}.app`),U=s(W,"Contents"),_=s(U,"MacOS"),B=s(U,"Resources");V1(_,{recursive:!0}),V1(B,{recursive:!0});let z=s(B,"index.html");await Bun.write(z,$);let q="";if(Q.sidebar?.enabled&&Q.sidebar?.config)q=s(B,"sidebar-config.json"),await Bun.write(q,JSON.stringify(Q.sidebar.config));let j=Q.sidebar?.enabled?`--native-sidebar --sidebar-width ${Q.sidebar?.width||240} --sidebar-config "$(cat "$RESOURCES/sidebar-config.json")"`:"",H=`#!/bin/bash
16619
16619
  DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
16620
16620
  RESOURCES="$DIR/../Resources"
@@ -16627,8 +16627,8 @@ RESOURCES="$DIR/../Resources"
16627
16627
  ${Q.window?.frameless?"--frameless":""} \\
16628
16628
  ${Q.window?.alwaysOnTop?"--always-on-top":""} \\
16629
16629
  ${j}
16630
- `,L=s(_,Z);await Bun.write(L,H),z6(L,493);let F=s(_,"craft");try{d7(G,F),z6(F,493)}catch{let V=`#!/bin/bash
16631
- exec "${G}" "$@"`;await Bun.write(F,V),z6(F,493)}let O=`<?xml version="1.0" encoding="UTF-8"?>
16630
+ `,L=s(_,Z);await Bun.write(L,H),z4(L,493);let F=s(_,"craft");try{d7(G,F),z4(F,493)}catch{let V=`#!/bin/bash
16631
+ exec "${G}" "$@"`;await Bun.write(F,V),z4(F,493)}let O=`<?xml version="1.0" encoding="UTF-8"?>
16632
16632
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
16633
16633
  <plist version="1.0">
16634
16634
  <dict>
@@ -16673,7 +16673,7 @@ DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
16673
16673
  --height ${Q.window?.height||800} \\
16674
16674
  ${Q.systemTray?"--system-tray":""} \\
16675
16675
  ${Q.devTools?"--dev-tools":""}
16676
- `,_=s(K,Z.toLowerCase());await Bun.write(_,U),z6(_,493);let B=`[Desktop Entry]
16676
+ `,_=s(K,Z.toLowerCase());await Bun.write(_,U),z4(_,493);let B=`[Desktop Entry]
16677
16677
  Type=Application
16678
16678
  Name=${Z}
16679
16679
  Exec=${_}
@@ -16681,7 +16681,7 @@ Terminal=false
16681
16681
  Categories=Utility;
16682
16682
  `;if(await Bun.write(s(K,`${Z.toLowerCase()}.desktop`),B),J==="deb"){let z=s(X,`${Z.toLowerCase()}_${Y}_amd64.deb`),q=await VS(K,z,Z,Y,Q);if(!q.success)return{success:!1,target:"linux",format:"deb",error:q.error};return{success:!0,target:"linux",format:"deb",outputPath:z}}if(J==="appimage"){let z=s(X,`${Z}-${Y}-x86_64.AppImage`),q=await AS(K,z,Z,Q);if(!q.success)return{success:!1,target:"linux",format:"appimage",error:q.error};return{success:!0,target:"linux",format:"appimage",outputPath:z}}return{success:!0,target:"linux",format:"app",outputPath:K}}async function qS($,Z,Y,X,J,Q){return{success:!1,target:"ios",format:"ipa",error:`iOS build requires Xcode and additional setup. Use 'stx init:ios ${Z}' to create an iOS project.`}}async function jS($,Z,Y,X,J,Q){return{success:!1,target:"android",format:"apk",error:`Android build requires Android SDK and additional setup. Use 'stx init:android ${Z}' to create an Android project.`}}async function HS(){let $=[s(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft-minimal"),s(process.cwd(),"../craft/packages/zig/zig-out/bin/craft-minimal"),s(RL(),"Code/craft/packages/zig/zig-out/bin/craft-minimal"),"/usr/local/bin/craft","/usr/bin/craft",s(RL(),".local/bin/craft"),s(process.env.LOCALAPPDATA||"","craft","craft.exe"),s(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let Z of $)if(await Bun.file(Z).exists())return Z;try{let Y=WS("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
16683
16683
  `)[0];if(Y&&await Bun.file(Y).exists())return Y}catch{}return null}function h7(){switch(US()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function LS($){switch($){case"macos":return"app";case"windows":return"zip";case"linux":return"appimage";case"ios":return"ipa";case"android":return"apk";default:return"app"}}async function OS($,Z,Y){return new Promise((X)=>{let J=a3("hdiutil",["create","-volname",Y,"-srcfolder",$,"-ov","-format","UDZO",Z]);J.on("close",(Q)=>{if(Q===0)X({success:!0});else X({success:!1,error:`hdiutil exited with code ${Q}`})}),J.on("error",(Q)=>{X({success:!1,error:Q.message})})})}async function FS($,Z){return new Promise((Y)=>{let X=a3("zip",["-r",Z,"."],{cwd:$});X.on("close",(J)=>{if(J===0)Y({success:!0});else Y({success:!1,error:`zip exited with code ${J}`})}),X.on("error",(J)=>{Y({success:!1,error:J.message})})})}async function VS($,Z,Y,X,J){return new Promise((Q)=>{try{let G=s(ML(),`stx-deb-${Date.now()}`),K=s(G,"DEBIAN"),W=s(G,"usr","bin"),U=s(G,"usr","share","applications"),_=s(G,"usr","share",Y.toLowerCase());V1(K,{recursive:!0}),V1(W,{recursive:!0}),V1(U,{recursive:!0}),V1(_,{recursive:!0});let B=a("fs").readdirSync($);for(let H of B)d7(s($,H),s(_,H));let z=`#!/bin/bash
16684
- exec /usr/share/${Y.toLowerCase()}/${Y.toLowerCase()} "$@"`;a("fs").writeFileSync(s(W,Y.toLowerCase()),z),z6(s(W,Y.toLowerCase()),493);let q=`Package: ${Y.toLowerCase()}
16684
+ exec /usr/share/${Y.toLowerCase()}/${Y.toLowerCase()} "$@"`;a("fs").writeFileSync(s(W,Y.toLowerCase()),z),z4(s(W,Y.toLowerCase()),493);let q=`Package: ${Y.toLowerCase()}
16685
16685
  Version: ${X}
16686
16686
  Section: utils
16687
16687
  Priority: optional
@@ -16694,14 +16694,14 @@ SELF=$(readlink -f "$0")
16694
16694
  HERE=\${SELF%/*}
16695
16695
  export PATH="\${HERE}/usr/bin:\${PATH}"
16696
16696
  exec "\${HERE}/usr/share/${Y.toLowerCase()}/${Y.toLowerCase()}" "$@"
16697
- `;a("fs").writeFileSync(s(G,"AppRun"),z),z6(s(G,"AppRun"),493);let q=`[Desktop Entry]
16697
+ `;a("fs").writeFileSync(s(G,"AppRun"),z),z4(s(G,"AppRun"),493);let q=`[Desktop Entry]
16698
16698
  Type=Application
16699
16699
  Name=${Y}
16700
16700
  Exec=${Y.toLowerCase()}
16701
16701
  Terminal=false
16702
16702
  Categories=Utility;
16703
16703
  Icon=${Y.toLowerCase()}
16704
- `;a("fs").writeFileSync(s(G,`${Y.toLowerCase()}.desktop`),q);let j=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(a("fs").writeFileSync(s(G,`${Y.toLowerCase()}.png`),j),X.icon&&wL(X.icon))d7(X.icon,s(G,`${Y.toLowerCase()}.png`));let H=a3("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(L)=>{if(a("fs").rmSync(Q,{recursive:!0,force:!0}),L===0)z6(Z,493),J({success:!0});else J({success:!1,error:`appimagetool exited with code ${L}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(L)=>{a("fs").rmSync(Q,{recursive:!0,force:!0}),J({success:!1,error:`appimagetool not found: ${L.message}`})})}catch(Q){J({success:!1,error:Q.message})}})}function TL(){return[h7()]}function IL($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var NS,RS;var kL=D(()=>{OL();NL();NS={buildNative:EL,getAvailableTargets:TL,getAvailableFormats:IL,detectPlatform:h7},RS=NS});function m7($,Z){return`${wS[Z]}${$}\x1B[0m`}function bL($,Z){return`${MS[Z]}${$}\x1B[0m`}function u7(){console.log(""),console.log(i0(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(i0(" \u2551")+D1(" \uD83D\uDCD6 STX Story ")+i0("\u2551")),console.log(i0(" \u2551")+t3(" Component Showcase & Testing ")+i0("\u2551")),console.log(i0(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function zG($,Z){if(console.log(D1(" Server running at:")),console.log(""),console.log(` ${t3("\u279C")} ${D1("Local:")} ${i0($)}`),Z)console.log(` ${t3("\u279C")} ${D1("Network:")} ${i0(Z)}`);console.log("")}function c7($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?o3:BG;console.log(` ${Y(Z)} Found ${D1(String($))} story ${$===1?"file":"files"}`)}function CL($,Z){if(console.log(""),console.log(` ${SL("\u2717")} ${D1(SL("Error:"))} ${$}`),Z)console.log(` ${t3(Z)}`);console.log("")}function y$($){console.log(` ${BG("\u26A0")} ${BG("Warning:")} ${$}`)}function PL($){console.log(` ${ES("\u2139")} ${$}`)}function yL($,Z,Y){console.log(""),console.log(i0(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(i0(" \u2551")+D1(" Build Complete ")+i0("\u2551")),console.log(i0(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${o3("\u2713")} Stories: ${D1(String($))}`),console.log(` ${o3("\u2713")} Output: ${D1(Z)}`),console.log(` ${o3("\u2713")} Time: ${D1(`${Y}ms`)}`),console.log("")}function qG(){console.log(""),console.log(D1(" Keyboard Shortcuts:")),console.log(""),console.log(` ${i0("h")} Show this help`),console.log(` ${i0("o")} Open in browser`),console.log(` ${i0("r")} Restart server`),console.log(` ${i0("c")} Clear console`),console.log(` ${i0("q")} Quit`),console.log("")}var wS,MS,SL=($)=>m7($,"red"),o3=($)=>m7($,"green"),BG=($)=>m7($,"yellow"),ES=($)=>m7($,"blue"),i0=($)=>m7($,"cyan"),D1=($)=>bL($,"bold"),t3=($)=>bL($,"dim");var e3=D(()=>{wS={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},MS={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import xL from"fs";import jG from"path";function vL($,Z){let Y=[jG.join($.root,"stx.config.ts"),jG.join($.root,"stx.config.js"),jG.join($.root,"stx.config.mjs")],X=Z.debounceMs??300,J=null,Q=[];for(let G of Y)try{if(!xL.existsSync(G))continue;let K=xL.watch(G,(W)=>{if(W==="change"){if(J)clearTimeout(J);J=setTimeout(async()=>{PL("Config file changed, restarting...");try{await Z.onChange()}catch(U){y$(`Failed to restart: ${U}`)}},X)}});Q.push(K)}catch{}return{stop(){if(J)clearTimeout(J);for(let G of Q)G.close()}}}var gL=D(()=>{e3()});function mL($){let Z={...TS,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...dL,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??fL,backgroundPresets:Z.backgroundPresets??hL,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var fL,hL,dL,TS;var uL=D(()=>{fL=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],hL=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],dL={file:"title",order:"asc",groups:[]},TS={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:dL,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:fL,backgroundPresets:hL,autoApplyContrastColor:!1,port:6006}});var cL={};t(cL,{updateContextTree:()=>g$,updateContextStoryFiles:()=>v$,createContext:()=>x$});import IS from"path";async function x$($){let Z=$.root??process.cwd(),Y;try{let G=await import(IS.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let X={...Y,...$.config},J=mL(X);return{root:Z,config:J,storyFiles:[],tree:void 0,mode:$.mode}}function v$($,Z){$.storyFiles=Z}function g$($,Z){$.tree=Z}var l7=D(()=>{uL()});import HG from"fs";import lL from"path";class LG{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=lL.join($,DS),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=HG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:kS,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=lL.dirname(this.storagePath);if(await HG.promises.mkdir($,{recursive:!0}),this.storage.events.length>pL)this.storage.events=this.storage.events.slice(-pL);await HG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:SS(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,Z){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:Z}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let Z=this.viewStartTimes.get($);if(Z){let Y=Date.now()-Z;this.track({type:"view",componentId:$,metadata:{duration:Y,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,Z,Y){this.track({type:"prop_change",componentId:$,propName:Z,metadata:{value:Y}})}trackVariantSwitch($,Z){this.track({type:"variant_switch",componentId:$,variantId:Z})}trackSearch($,Z){this.track({type:"search",query:$,metadata:{resultCount:Z}})}getComponentAnalytics($,Z){let Y=this.storage.events.filter((z)=>z.componentId===$),X=Y.filter((z)=>z.type==="view"&&!z.metadata?.endView),J=Y.filter((z)=>z.type==="prop_change"),Q=Y.filter((z)=>z.type==="variant_switch"),G={};for(let z of J)if(z.propName)G[z.propName]=(G[z.propName]||0)+1;let K={};for(let z of Q)if(z.variantId)K[z.variantId]=(K[z.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((z)=>z.componentViews.includes($)).map((z)=>z.id)),U=Y.filter((z)=>z.metadata?.duration).map((z)=>z.metadata.duration),_=U.length>0?U.reduce((z,q)=>z+q,0)/U.length:0,B=Object.entries(G).sort((z,q)=>q[1]-z[1]).slice(0,5).map(([z])=>z);return{componentId:$,componentName:Z,viewCount:X.length,uniqueViews:W.size,lastViewed:X[X.length-1]?.timestamp,propChanges:G,topChangedProps:B,variantViews:K,avgTimeSpent:_}}getMostViewedComponents($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="view"&&Y.componentId&&!Y.metadata?.endView)Z.set(Y.componentId,(Z.get(Y.componentId)||0)+1);return Array.from(Z.entries()).map(([Y,X])=>({componentId:Y,viewCount:X})).sort((Y,X)=>X.viewCount-Y.viewCount).slice(0,$)}getMostChangedProps($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="prop_change"&&Y.propName)Z.set(Y.propName,(Z.get(Y.propName)||0)+1);return Array.from(Z.entries()).map(([Y,X])=>({propName:Y,changeCount:X})).sort((Y,X)=>X.changeCount-Y.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((J)=>J.type==="search"),Z=new Map,Y=0;for(let J of $){if(J.query)Z.set(J.query,(Z.get(J.query)||0)+1);if(J.metadata?.resultCount!==void 0)Y+=J.metadata.resultCount}let X=Array.from(Z.entries()).map(([J,Q])=>({query:J,count:Q})).sort((J,Q)=>Q.count-J.count).slice(0,10);return{totalSearches:$.length,topQueries:X,avgResultCount:$.length>0?Y/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function SS(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var DS=".stx/story/analytics.json",kS=1,pL=1e4;var iL=()=>{};import OG from"fs";import nL from"path";class FG{storage;storagePath;dirty=!1;constructor($){this.storagePath=nL.join($,bS),this.storage=this.loadStorage()}loadStorage(){try{let $=OG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:CS,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=nL.dirname(this.storagePath);await OG.promises.mkdir($,{recursive:!0}),await OG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,X={}){let J={id:PS(),name:X.name||`${$}/${Z}`,storyId:$,variantId:Z,props:Y,created:Date.now(),notes:X.notes,color:X.color};return this.storage.bookmarks.push(J),this.dirty=!0,J}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((Z)=>Z.storyId===$)}getBookmark($){return this.storage.bookmarks.find((Z)=>Z.id===$)}isBookmarked($,Z){return this.storage.bookmarks.some((Y)=>Y.storyId===$&&Y.variantId===Z)}updateBookmark($,Z){let Y=this.getBookmark($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deleteBookmark($){let Z=this.storage.bookmarks.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.bookmarks.splice(Z,1),this.dirty=!0,!0}toggleBookmark($,Z,Y){let X=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===Z);if(X)return this.deleteBookmark(X.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,Z,Y)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,Z=!0){let Y=JSON.parse($),X=0;for(let J of Y.bookmarks){if(Z){let Q=this.storage.bookmarks.find((G)=>G.id===J.id);if(Q)Object.assign(Q,J);else this.storage.bookmarks.push(J)}else this.storage.bookmarks.push(J);X++}if(X>0)this.dirty=!0;return X}}function PS(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var bS=".stx/story/bookmarks.json",CS=1;var rL=()=>{};import VG from"fs";import p7 from"path";async function i7($){let{root:Z,config:Y}=$,X=[],J=await yS(Z,Y.storyMatch,Y.storyIgnored);for(let Q of J){let G=p7.resolve(Z,Q),K=AG(Q,G);X.push(K)}return X}async function yS($,Z,Y){let X=[];async function J(Q,G){let K=await VG.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=p7.join(Q,W.name),_=p7.relative(G,U);if(sL(_,Y))continue;if(W.isDirectory())await J(U,G);else if(W.isFile()){if(aL(_,Z))X.push(_)}}}return await J($,$),X}function sL($,Z){for(let Y of Z)if(oL($,Y))return!0;return!1}function aL($,Z){for(let Y of Z)if(oL($,Y))return!0;return!1}function oL($,Z){let Y=$.replace(/\\/g,"/"),J=Z.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return J=`^${J}$`,new RegExp(J).test(Y)}function AG($,Z){let Y=p7.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:Z,relativePath:$,fileName:Y,treeFile:{title:Y,path:$}}}function tL($,Z){let{root:Y,config:X}=$,J=[],Q=VG.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!aL(W,X.storyMatch))return;if(sL(W,X.storyIgnored))return;let U=p7.resolve(Y,W);try{await VG.promises.access(U);let _=AG(W,U);Z(G==="rename"?"add":"change",_)}catch{let _=AG(W,U);Z("unlink",_)}});return J.push(Q),()=>{for(let G of J)G.close()}}var NG=()=>{};function xS($,Z){let Y=Z.treeFile||{title:Z.fileName,path:Z.relativePath};if($.tree.file==="title")return Y.title.split("/");if($.tree.file==="path")return[...Z.relativePath.split("/").slice(0,-1),Y.title];if(typeof $.tree.file==="function")return $.tree.file(Y);return[Y.title]}function n7($,Z){for(let G of Z)G.treePath=xS($,G);let Y=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),X={treeObject:{}};Y.push(X);for(let G=0;G<Z.length;G++){let K=Z[G],W=vS(K,Y,X);gS(K.treePath,G,W.treeObject)}let J=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Y)if(G===X)Q.push(...RG(G.treeObject,J));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:RG(G.treeObject,J)});return Q}function vS($,Z,Y){let X=$.treeFile||{title:$.fileName,path:$.relativePath};for(let J of Z)if(J.groupConfig?.include&&J.groupConfig.include(X))return J;return Y}function gS($,Z,Y){let X=Y;for(let J=0;J<$.length;J++){let Q=$[J];if(J===$.length-1)if(X[Q]!==void 0){let K=1;while(X[`${Q}-${K}`]!==void 0)K++;X[`${Q}-${K}`]=Z}else X[Q]=Z;else{if(X[Q]===void 0)X[Q]={};else if(typeof X[Q]==="number"){let K=X[Q];X[Q]={"":K}}X=X[Q]}}}function RG($,Z){let Y=[];for(let[X,J]of Object.entries($))if(typeof J==="number")Y.push({title:X,index:J});else Y.push({title:X,children:RG(J,Z)});return Y.sort((X,J)=>Z(X.title,J.title)),Y}function eL(){return{open($){$Z.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){$Z.delete($)},message($,Z){}}}function wG($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of $Z)try{Y.send(Z)}catch{$Z.delete(Y)}}function $O($,Z){wG({type:"story-update",data:{storyId:$,...Z}})}function ZO($,Z){wG({type:"story-add",data:{storyId:$,...Z}})}function YO($){wG({type:"story-remove",data:{storyId:$}})}function XO($){return`
16704
+ `;a("fs").writeFileSync(s(G,`${Y.toLowerCase()}.desktop`),q);let j=Buffer.from([137,80,78,71,13,10,26,10,0,0,0,13,73,72,68,82,0,0,0,1,0,0,0,1,8,2,0,0,0,144,119,83,222,0,0,0,12,73,68,65,84,8,215,99,248,255,255,63,0,5,254,2,254,220,204,89,231,0,0,0,0,73,69,78,68,174,66,96,130]);if(a("fs").writeFileSync(s(G,`${Y.toLowerCase()}.png`),j),X.icon&&wL(X.icon))d7(X.icon,s(G,`${Y.toLowerCase()}.png`));let H=a3("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(L)=>{if(a("fs").rmSync(Q,{recursive:!0,force:!0}),L===0)z4(Z,493),J({success:!0});else J({success:!1,error:`appimagetool exited with code ${L}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(L)=>{a("fs").rmSync(Q,{recursive:!0,force:!0}),J({success:!1,error:`appimagetool not found: ${L.message}`})})}catch(Q){J({success:!1,error:Q.message})}})}function TL(){return[h7()]}function IL($){switch($){case"macos":return["app","dmg","pkg"];case"windows":return["app","zip","msi"];case"linux":return["app","deb","rpm","appimage"];case"ios":return["ipa"];case"android":return["apk"];default:return["app"]}}var NS,RS;var kL=D(()=>{OL();NL();NS={buildNative:EL,getAvailableTargets:TL,getAvailableFormats:IL,detectPlatform:h7},RS=NS});function m7($,Z){return`${wS[Z]}${$}\x1B[0m`}function bL($,Z){return`${MS[Z]}${$}\x1B[0m`}function u7(){console.log(""),console.log(i0(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(i0(" \u2551")+D1(" \uD83D\uDCD6 STX Story ")+i0("\u2551")),console.log(i0(" \u2551")+t3(" Component Showcase & Testing ")+i0("\u2551")),console.log(i0(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log("")}function zG($,Z){if(console.log(D1(" Server running at:")),console.log(""),console.log(` ${t3("\u279C")} ${D1("Local:")} ${i0($)}`),Z)console.log(` ${t3("\u279C")} ${D1("Network:")} ${i0(Z)}`);console.log("")}function c7($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?o3:BG;console.log(` ${Y(Z)} Found ${D1(String($))} story ${$===1?"file":"files"}`)}function CL($,Z){if(console.log(""),console.log(` ${SL("\u2717")} ${D1(SL("Error:"))} ${$}`),Z)console.log(` ${t3(Z)}`);console.log("")}function y$($){console.log(` ${BG("\u26A0")} ${BG("Warning:")} ${$}`)}function PL($){console.log(` ${ES("\u2139")} ${$}`)}function yL($,Z,Y){console.log(""),console.log(i0(" \u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557")),console.log(i0(" \u2551")+D1(" Build Complete ")+i0("\u2551")),console.log(i0(" \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D")),console.log(""),console.log(` ${o3("\u2713")} Stories: ${D1(String($))}`),console.log(` ${o3("\u2713")} Output: ${D1(Z)}`),console.log(` ${o3("\u2713")} Time: ${D1(`${Y}ms`)}`),console.log("")}function qG(){console.log(""),console.log(D1(" Keyboard Shortcuts:")),console.log(""),console.log(` ${i0("h")} Show this help`),console.log(` ${i0("o")} Open in browser`),console.log(` ${i0("r")} Restart server`),console.log(` ${i0("c")} Clear console`),console.log(` ${i0("q")} Quit`),console.log("")}var wS,MS,SL=($)=>m7($,"red"),o3=($)=>m7($,"green"),BG=($)=>m7($,"yellow"),ES=($)=>m7($,"blue"),i0=($)=>m7($,"cyan"),D1=($)=>bL($,"bold"),t3=($)=>bL($,"dim");var e3=D(()=>{wS={black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",brightRed:"\x1B[91m",brightGreen:"\x1B[92m",brightYellow:"\x1B[93m",brightBlue:"\x1B[94m",brightMagenta:"\x1B[95m",brightCyan:"\x1B[96m",brightWhite:"\x1B[97m"},MS={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import xL from"fs";import jG from"path";function vL($,Z){let Y=[jG.join($.root,"stx.config.ts"),jG.join($.root,"stx.config.js"),jG.join($.root,"stx.config.mjs")],X=Z.debounceMs??300,J=null,Q=[];for(let G of Y)try{if(!xL.existsSync(G))continue;let K=xL.watch(G,(W)=>{if(W==="change"){if(J)clearTimeout(J);J=setTimeout(async()=>{PL("Config file changed, restarting...");try{await Z.onChange()}catch(U){y$(`Failed to restart: ${U}`)}},X)}});Q.push(K)}catch{}return{stop(){if(J)clearTimeout(J);for(let G of Q)G.close()}}}var gL=D(()=>{e3()});function mL($){let Z={...TS,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...dL,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??fL,backgroundPresets:Z.backgroundPresets??hL,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var fL,hL,dL,TS;var uL=D(()=>{fL=[{label:"Mobile (Small)",width:320,height:568},{label:"Mobile (Medium)",width:375,height:667},{label:"Mobile (Large)",width:414,height:896},{label:"Tablet",width:768,height:1024},{label:"Laptop",width:1024},{label:"Desktop",width:1280},{label:"Desktop (Large)",width:1920}],hL=[{label:"Transparent",color:"transparent",contrastColor:"#333"},{label:"White",color:"#ffffff",contrastColor:"#333"},{label:"Light Gray",color:"#f5f5f5",contrastColor:"#333"},{label:"Dark Gray",color:"#333333",contrastColor:"#fff"},{label:"Black",color:"#000000",contrastColor:"#fff"}],dL={file:"title",order:"asc",groups:[]},TS={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:dL,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:fL,backgroundPresets:hL,autoApplyContrastColor:!1,port:6006}});var cL={};t(cL,{updateContextTree:()=>g$,updateContextStoryFiles:()=>v$,createContext:()=>x$});import IS from"path";async function x$($){let Z=$.root??process.cwd(),Y;try{let G=await import(IS.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let X={...Y,...$.config},J=mL(X);return{root:Z,config:J,storyFiles:[],tree:void 0,mode:$.mode}}function v$($,Z){$.storyFiles=Z}function g$($,Z){$.tree=Z}var l7=D(()=>{uL()});import HG from"fs";import lL from"path";class LG{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=lL.join($,DS),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=HG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:kS,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=lL.dirname(this.storagePath);if(await HG.promises.mkdir($,{recursive:!0}),this.storage.events.length>pL)this.storage.events=this.storage.events.slice(-pL);await HG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:SS(),startTime:Date.now(),componentViews:[]},this.storage.sessions.push(this.currentSession),this.dirty=!0}endSession(){if(this.currentSession)this.currentSession.endTime=Date.now(),this.currentSession=null}track($){this.storage.events.push({...$,timestamp:Date.now()}),this.dirty=!0}trackView($,Z){if(this.endViewTiming($),this.viewStartTimes.set($,Date.now()),this.track({type:"view",componentId:$,variantId:Z}),this.currentSession&&!this.currentSession.componentViews.includes($))this.currentSession.componentViews.push($)}endViewTiming($){let Z=this.viewStartTimes.get($);if(Z){let Y=Date.now()-Z;this.track({type:"view",componentId:$,metadata:{duration:Y,endView:!0}}),this.viewStartTimes.delete($)}}trackPropChange($,Z,Y){this.track({type:"prop_change",componentId:$,propName:Z,metadata:{value:Y}})}trackVariantSwitch($,Z){this.track({type:"variant_switch",componentId:$,variantId:Z})}trackSearch($,Z){this.track({type:"search",query:$,metadata:{resultCount:Z}})}getComponentAnalytics($,Z){let Y=this.storage.events.filter((z)=>z.componentId===$),X=Y.filter((z)=>z.type==="view"&&!z.metadata?.endView),J=Y.filter((z)=>z.type==="prop_change"),Q=Y.filter((z)=>z.type==="variant_switch"),G={};for(let z of J)if(z.propName)G[z.propName]=(G[z.propName]||0)+1;let K={};for(let z of Q)if(z.variantId)K[z.variantId]=(K[z.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((z)=>z.componentViews.includes($)).map((z)=>z.id)),U=Y.filter((z)=>z.metadata?.duration).map((z)=>z.metadata.duration),_=U.length>0?U.reduce((z,q)=>z+q,0)/U.length:0,B=Object.entries(G).sort((z,q)=>q[1]-z[1]).slice(0,5).map(([z])=>z);return{componentId:$,componentName:Z,viewCount:X.length,uniqueViews:W.size,lastViewed:X[X.length-1]?.timestamp,propChanges:G,topChangedProps:B,variantViews:K,avgTimeSpent:_}}getMostViewedComponents($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="view"&&Y.componentId&&!Y.metadata?.endView)Z.set(Y.componentId,(Z.get(Y.componentId)||0)+1);return Array.from(Z.entries()).map(([Y,X])=>({componentId:Y,viewCount:X})).sort((Y,X)=>X.viewCount-Y.viewCount).slice(0,$)}getMostChangedProps($=10){let Z=new Map;for(let Y of this.storage.events)if(Y.type==="prop_change"&&Y.propName)Z.set(Y.propName,(Z.get(Y.propName)||0)+1);return Array.from(Z.entries()).map(([Y,X])=>({propName:Y,changeCount:X})).sort((Y,X)=>X.changeCount-Y.changeCount).slice(0,$)}getSearchAnalytics(){let $=this.storage.events.filter((J)=>J.type==="search"),Z=new Map,Y=0;for(let J of $){if(J.query)Z.set(J.query,(Z.get(J.query)||0)+1);if(J.metadata?.resultCount!==void 0)Y+=J.metadata.resultCount}let X=Array.from(Z.entries()).map(([J,Q])=>({query:J,count:Q})).sort((J,Q)=>Q.count-J.count).slice(0,10);return{totalSearches:$.length,topQueries:X,avgResultCount:$.length>0?Y/$.length:0}}clear(){this.storage.events=[],this.storage.sessions=[],this.dirty=!0,this.startSession()}exportAnalytics(){return JSON.stringify({exportedAt:Date.now(),...this.storage},null,2)}}function SS(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var DS=".stx/story/analytics.json",kS=1,pL=1e4;var iL=()=>{};import OG from"fs";import nL from"path";class FG{storage;storagePath;dirty=!1;constructor($){this.storagePath=nL.join($,bS),this.storage=this.loadStorage()}loadStorage(){try{let $=OG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:CS,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=nL.dirname(this.storagePath);await OG.promises.mkdir($,{recursive:!0}),await OG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,X={}){let J={id:PS(),name:X.name||`${$}/${Z}`,storyId:$,variantId:Z,props:Y,created:Date.now(),notes:X.notes,color:X.color};return this.storage.bookmarks.push(J),this.dirty=!0,J}getAllBookmarks(){return[...this.storage.bookmarks]}getBookmarksForStory($){return this.storage.bookmarks.filter((Z)=>Z.storyId===$)}getBookmark($){return this.storage.bookmarks.find((Z)=>Z.id===$)}isBookmarked($,Z){return this.storage.bookmarks.some((Y)=>Y.storyId===$&&Y.variantId===Z)}updateBookmark($,Z){let Y=this.getBookmark($);if(!Y)return;return Object.assign(Y,Z),this.dirty=!0,Y}deleteBookmark($){let Z=this.storage.bookmarks.findIndex((Y)=>Y.id===$);if(Z===-1)return!1;return this.storage.bookmarks.splice(Z,1),this.dirty=!0,!0}toggleBookmark($,Z,Y){let X=this.storage.bookmarks.find((Q)=>Q.storyId===$&&Q.variantId===Z);if(X)return this.deleteBookmark(X.id),{added:!1};return{added:!0,bookmark:this.addBookmark($,Z,Y)}}exportBookmarks(){return JSON.stringify(this.storage,null,2)}importBookmarks($,Z=!0){let Y=JSON.parse($),X=0;for(let J of Y.bookmarks){if(Z){let Q=this.storage.bookmarks.find((G)=>G.id===J.id);if(Q)Object.assign(Q,J);else this.storage.bookmarks.push(J)}else this.storage.bookmarks.push(J);X++}if(X>0)this.dirty=!0;return X}}function PS(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var bS=".stx/story/bookmarks.json",CS=1;var rL=()=>{};import VG from"fs";import p7 from"path";async function i7($){let{root:Z,config:Y}=$,X=[],J=await yS(Z,Y.storyMatch,Y.storyIgnored);for(let Q of J){let G=p7.resolve(Z,Q),K=AG(Q,G);X.push(K)}return X}async function yS($,Z,Y){let X=[];async function J(Q,G){let K=await VG.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=p7.join(Q,W.name),_=p7.relative(G,U);if(sL(_,Y))continue;if(W.isDirectory())await J(U,G);else if(W.isFile()){if(aL(_,Z))X.push(_)}}}return await J($,$),X}function sL($,Z){for(let Y of Z)if(oL($,Y))return!0;return!1}function aL($,Z){for(let Y of Z)if(oL($,Y))return!0;return!1}function oL($,Z){let Y=$.replace(/\\/g,"/"),J=Z.replace(/\\/g,"/").replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"{{GLOBSTAR}}").replace(/\*/g,"[^/]*").replace(/\?/g,".").replace(/\{\{GLOBSTAR\}\}/g,".*");return J=`^${J}$`,new RegExp(J).test(Y)}function AG($,Z){let Y=p7.basename($,".story.stx");return{id:$.toLowerCase().replace(/\.story\.stx$/,"").replace(/[/\\]/g,"-").replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),path:Z,relativePath:$,fileName:Y,treeFile:{title:Y,path:$}}}function tL($,Z){let{root:Y,config:X}=$,J=[],Q=VG.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!aL(W,X.storyMatch))return;if(sL(W,X.storyIgnored))return;let U=p7.resolve(Y,W);try{await VG.promises.access(U);let _=AG(W,U);Z(G==="rename"?"add":"change",_)}catch{let _=AG(W,U);Z("unlink",_)}});return J.push(Q),()=>{for(let G of J)G.close()}}var NG=()=>{};function xS($,Z){let Y=Z.treeFile||{title:Z.fileName,path:Z.relativePath};if($.tree.file==="title")return Y.title.split("/");if($.tree.file==="path")return[...Z.relativePath.split("/").slice(0,-1),Y.title];if(typeof $.tree.file==="function")return $.tree.file(Y);return[Y.title]}function n7($,Z){for(let G of Z)G.treePath=xS($,G);let Y=($.tree.groups||[]).map((G)=>({groupConfig:{id:G.id||G.title,title:G.title,include:G.include},treeObject:{}})),X={treeObject:{}};Y.push(X);for(let G=0;G<Z.length;G++){let K=Z[G],W=vS(K,Y,X);gS(K.treePath,G,W.treeObject)}let J=$.tree.order==="asc"?(G,K)=>G.localeCompare(K):$.tree.order,Q=[];for(let G of Y)if(G===X)Q.push(...RG(G.treeObject,J));else if(G.groupConfig&&Object.keys(G.treeObject).length>0)Q.push({group:!0,id:G.groupConfig.id,title:G.groupConfig.title,children:RG(G.treeObject,J)});return Q}function vS($,Z,Y){let X=$.treeFile||{title:$.fileName,path:$.relativePath};for(let J of Z)if(J.groupConfig?.include&&J.groupConfig.include(X))return J;return Y}function gS($,Z,Y){let X=Y;for(let J=0;J<$.length;J++){let Q=$[J];if(J===$.length-1)if(X[Q]!==void 0){let K=1;while(X[`${Q}-${K}`]!==void 0)K++;X[`${Q}-${K}`]=Z}else X[Q]=Z;else{if(X[Q]===void 0)X[Q]={};else if(typeof X[Q]==="number"){let K=X[Q];X[Q]={"":K}}X=X[Q]}}}function RG($,Z){let Y=[];for(let[X,J]of Object.entries($))if(typeof J==="number")Y.push({title:X,index:J});else Y.push({title:X,children:RG(J,Z)});return Y.sort((X,J)=>Z(X.title,J.title)),Y}function eL(){return{open($){$Z.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){$Z.delete($)},message($,Z){}}}function wG($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of $Z)try{Y.send(Z)}catch{$Z.delete(Y)}}function $O($,Z){wG({type:"story-update",data:{storyId:$,...Z}})}function ZO($,Z){wG({type:"story-add",data:{storyId:$,...Z}})}function YO($){wG({type:"story-remove",data:{storyId:$}})}function XO($){return`
16705
16705
  <script>
16706
16706
  (function() {
16707
16707
  const ws = new WebSocket('${$}');
@@ -17979,7 +17979,7 @@ else {
17979
17979
  ${KO()}
17980
17980
  </body>
17981
17981
  </html>`}var EO=D(()=>{iL();rL();NG();l7();JO();_O();jO();LO();wO()});import nS from"fs";import rS from"path";async function TO($){let Z=$.config.setupFile;if(!Z)return;let Y=rS.resolve($.root,Z);try{await nS.promises.access(Y)}catch{return}let X={storyContext:$,registerComponent:(J,Q)=>{sS.set(J,Q)},addCSS:(J)=>{aS.push(J)},addScript:(J)=>{oS.push(J)},setState:(J,Q)=>{tS.set(J,Q)}};try{let J=await import(Y);if(typeof J.default==="function")await J.default(X);else if(typeof J.setupStory==="function")await J.setupStory(X)}catch(J){console.warn(`Warning: Failed to load setup file: ${J}`)}}var sS,aS,oS,tS;var IO=D(()=>{sS=new Map,aS=[],oS=[],tS=new Map});var kO={};t(kO,{devCommand:()=>DO,dev:()=>eS});async function DO($={}){u7();let Z=await x$({mode:"dev"});if(!Z.config.enabled){y$("Story feature is disabled in config.");return}await TO(Z);let Y=$.port??Z.config.port,X,J=async()=>{X=await MO(Z,{port:Y,open:$.open,host:$.host}),c7(Z.storyFiles.length),zG(X.url),qG()};await J();let Q=vL(Z,{onChange:async()=>{await X.close();let K=await x$({mode:"dev"});Object.assign(Z,K),await J()}}),G=async()=>{console.log(`
17982
- `),Q.stop(),await X.close(),process.exit(0)};if(process.on("SIGINT",G),process.on("SIGTERM",G),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(K)=>{switch(K.toString()){case"h":qG();break;case"o":try{let{exec:U}=await import("child_process"),_=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";U(`${_} ${X.url}`)}catch{CL("Failed to open browser")}break;case"r":await X.close(),await J();break;case"c":console.clear(),u7(),c7(Z.storyFiles.length),zG(X.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var eS;var SO=D(()=>{gL();l7();e3();EO();IO();eS=DO});function bO($){s7=[];for(let Z of $.storyFiles)if(s7.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),s7.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)s7.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function CO(){return JSON.stringify(s7)}var s7;var PO=D(()=>{s7=[]});var xO={};t(xO,{buildCommand:()=>yO,build:()=>Zb});import c4 from"fs";import q6 from"path";async function yO($={}){let Z=Date.now();u7();let Y=await x$({mode:"build"});if(!Y.config.enabled){y$("Story feature is disabled in config.");return}let X=await i7(Y);v$(Y,X);let J=n7(Y.config,X);g$(Y,J),c7(X.length);let Q=$.outDir??Y.config.outDir,G=q6.resolve(Y.root,Q);await c4.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=$b(Y);await c4.promises.writeFile(q6.join(G,"index.html"),K);let W={files:X.map((q)=>({id:q.id,fileName:q.fileName,relativePath:q.relativePath,treePath:q.treePath})),tree:J};await c4.promises.writeFile(q6.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await c4.promises.writeFile(q6.join(G,"config.json"),JSON.stringify(U,null,2));let _=q6.join(G,"stories");await c4.promises.mkdir(_,{recursive:!0});for(let q of X){let j=await c4.promises.readFile(q.path,"utf-8");await c4.promises.writeFile(q6.join(_,`${q.id}.stx`),j)}bO(Y);let B=CO();await c4.promises.writeFile(q6.join(G,"search-index.json"),B);let z=Date.now()-Z;yL(X.length,Q,z)}function $b($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
17982
+ `),Q.stop(),await X.close(),process.exit(0)};if(process.on("SIGINT",G),process.on("SIGTERM",G),process.stdin.isTTY)process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",async(K)=>{switch(K.toString()){case"h":qG();break;case"o":try{let{exec:U}=await import("child_process"),_=process.platform==="darwin"?"open":process.platform==="win32"?"start":"xdg-open";U(`${_} ${X.url}`)}catch{CL("Failed to open browser")}break;case"r":await X.close(),await J();break;case"c":console.clear(),u7(),c7(Z.storyFiles.length),zG(X.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var eS;var SO=D(()=>{gL();l7();e3();EO();IO();eS=DO});function bO($){s7=[];for(let Z of $.storyFiles)if(s7.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),s7.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)s7.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function CO(){return JSON.stringify(s7)}var s7;var PO=D(()=>{s7=[]});var xO={};t(xO,{buildCommand:()=>yO,build:()=>Zb});import c6 from"fs";import q4 from"path";async function yO($={}){let Z=Date.now();u7();let Y=await x$({mode:"build"});if(!Y.config.enabled){y$("Story feature is disabled in config.");return}let X=await i7(Y);v$(Y,X);let J=n7(Y.config,X);g$(Y,J),c7(X.length);let Q=$.outDir??Y.config.outDir,G=q4.resolve(Y.root,Q);await c6.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=$b(Y);await c6.promises.writeFile(q4.join(G,"index.html"),K);let W={files:X.map((q)=>({id:q.id,fileName:q.fileName,relativePath:q.relativePath,treePath:q.treePath})),tree:J};await c6.promises.writeFile(q4.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await c6.promises.writeFile(q4.join(G,"config.json"),JSON.stringify(U,null,2));let _=q4.join(G,"stories");await c6.promises.mkdir(_,{recursive:!0});for(let q of X){let j=await c6.promises.readFile(q.path,"utf-8");await c6.promises.writeFile(q4.join(_,`${q.id}.stx`),j)}bO(Y);let B=CO();await c6.promises.writeFile(q4.join(G,"search-index.json"),B);let z=Date.now()-Z;yL(X.length,Q,z)}function $b($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
17983
17983
  <html lang="en">
17984
17984
  <head>
17985
17985
  <meta charset="UTF-8">
@@ -18094,12 +18094,12 @@ else {
18094
18094
  </script>
18095
18095
  </body>
18096
18096
  </html>`}var Zb;var vO=D(()=>{NG();l7();e3();PO();Zb=yO});var hO={};t(hO,{updateSnapshots:()=>Xb,runVisualTests:()=>fO,runA11yTests:()=>Wb,formatTestResults:()=>Kb});import YZ from"fs";import gO from"path";async function fO($,Z={}){let Y=Date.now(),X={total:0,passed:0,failed:0,new:0,failures:[],duration:0},J=Z.snapshotDir||gO.join($.root,".stx","story","snapshots");await YZ.promises.mkdir(J,{recursive:!0});let Q=$.storyFiles;if(Z.filter&&Z.filter.length>0)Q=Q.filter((G)=>Z.filter.some((K)=>G.fileName.toLowerCase().includes(K.toLowerCase())));for(let G of Q)await Yb(G,J,Z,X);return X.duration=Date.now()-Y,X}async function Yb($,Z,Y,X){let J=$.story;if(!J)return;for(let Q of J.variants){X.total++;let G=gO.join(Z,`${$.id}-${Q.id}.snap`),K=Jb(Q.source||""),W=await Gb(G);if(Y.update||!W){let U={storyId:$.id,variantId:Q.id,component:$.fileName,timestamp:Date.now(),hash:K};if(await YZ.promises.writeFile(G,JSON.stringify(U,null,2)),!W)X.new++;X.passed++}else try{let U=await YZ.promises.readFile(G,"utf-8"),_=JSON.parse(U);if(_.hash===K)X.passed++;else X.failed++,X.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:"Snapshot mismatch",difference:Qb(_.hash,K)})}catch(U){X.failed++,X.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:`Error reading snapshot: ${U}`})}}}async function Xb($,Z={}){return(await fO($,{...Z,update:!0})).total}function Jb($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Z.toString(16)}function Qb($,Z){if($===Z)return 0;let Y=Math.abs(Number.parseInt($,16)-Number.parseInt(Z,16));return Math.min(Y/1e6,1)}async function Gb($){try{return await YZ.promises.access($),!0}catch{return!1}}function Kb($){let Z=[];if(Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(" STX Story Visual Regression Tests"),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),$.failures.length>0){Z.push(" \u274C Failures:"),Z.push("");for(let Y of $.failures){if(Z.push(` \u2022 ${Y.component} / ${Y.variantId}`),Z.push(` ${Y.message}`),Y.difference!==void 0)Z.push(` Difference: ${(Y.difference*100).toFixed(2)}%`);Z.push("")}}if(Z.push(" Summary:"),Z.push(` Total: ${$.total}`),Z.push(` Passed: ${$.passed} \u2713`),Z.push(` Failed: ${$.failed} \u2717`),$.new>0)Z.push(` New: ${$.new} \u26A1`);return Z.push(` Time: ${$.duration}ms`),Z.push(""),Z.push("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"),Z.push(""),Z.join(`
18097
- `)}async function Wb($,Z={}){let Y=performance.now(),X=[],J=0,Q=0;for(let K of $.storyFiles)try{let W=await Bun.file(K.path).text(),U=await o7(W,K.path);if(U.length>0){for(let _ of U)X.push({storyId:K.id,variantId:"default",component:K.component,message:`A11y: ${_.message}`,expected:"No accessibility violations",actual:`${_.type}: ${_.message} (impact: ${_.impact})`});Q++}else J++}catch(W){X.push({storyId:K.id,variantId:"default",component:K.component,message:`Failed to check a11y: ${W instanceof Error?W.message:String(W)}`,expected:"File readable for a11y check",actual:"File read error"}),Q++}let G=performance.now()-Y;return{total:$.storyFiles.length,passed:J,failed:Q,new:0,failures:X,duration:G}}var dO=D(()=>{H6()});var oO={};t(oO,{default:()=>bb,createHotReloadServer:()=>aO,compileToNative:()=>uO,NATIVE_COMPONENTS:()=>bG});async function uO($,Z={}){let Y=performance.now(),X={target:Z.target||"universal",format:Z.format||"zig",optimize:Z.optimize??!0,treeShake:Z.treeShake??!0,hotReload:Z.hotReload??!1,debug:Z.debug??!1,sourceMaps:Z.sourceMaps??!1,bundle:Z.bundle??!0,minify:Z.minify??!1,components:Z.components||bG},J=typeof $==="string"?Ub($):$,Q=Bb(J.tree,X),G=Fb(Q),K=X.treeShake?Ab(Q,G):Q,W=new Map;if(X.target==="universal"){let q=["macos","windows","linux","ios","android"];for(let j of q){let H=DG(K,{...X,target:j});W.set(j,H)}}else{let q=DG(K,X);W.set(X.target,q)}let U=wb(K,X,W),_=Mb(J,K,X),B={compilationTime:performance.now()-Y,totalComponents:kG(J.tree),nativeComponents:SG(K),webComponents:kG(J.tree)-SG(K),bundleSize:U.length,treeShakenSize:X.treeShake?Nb(Q,K):U.length,warnings:[],errors:[]},z;if(X.sourceMaps)z=Eb(J,K);return{code:U,platformCode:W,dependencies:G,manifest:_,sourceMaps:z,stats:B}}function Ub($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),X=Y?Y[1]:$;return cO(X,Z),{id:rO(),hash:sO($),tree:Z,scripts:Db($),styles:kb($),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:$.includes("{{"),hasEventHandlers:$.includes("onclick")||$.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:$.length}}}function cO($,Z){let Y=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,X;while((X=Y.exec($))!==null){let[,J,Q,G]=X,K=J.startsWith("@craft-"),W={type:K?"component":"element",tag:K?J.slice(1):J,props:_b(Q),children:[],componentName:K?J.slice(1):void 0};if(G){let U=G.replace(/<[^>]+>/g,"").trim();if(U)W.children=W.children??[],W.children.push({type:"text",text:U});cO(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function _b($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,X;while((X=Y.exec($))!==null){let[,J,Q]=X;Z[J]=Q??!0}return Z}function Bb($,Z){return lO($,Z)}function lO($,Z){let Y=$.componentName?Z.components?.get($.componentName):void 0,X="craft.View";if(Y)X=Y.zigType;else if($.type==="text")X="craft.Text";else if($.tag)X=zb($.tag);let J={};if($.props)for(let[W,U]of Object.entries($.props))J[W]=qb(U);let Q=[];if($.children)for(let W of $.children)Q.push(lO(W,Z));let G=new Map;if($.props){for(let[W,U]of Object.entries($.props))if(W.startsWith("on")&&typeof U==="string")G.set(W.slice(2).toLowerCase(),U)}let K=Hb($);return{type:jb($,Y),zigType:X,props:J,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function zb($){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[$.toLowerCase()]||"craft.View"}function qb($){if(typeof $==="string"){if($.startsWith("{{")&&$.endsWith("}}"))return{type:"binding",path:$.slice(2,-2).trim()};if($.includes("(")&&$.includes(")"))return{type:"callback",handler:$};return{type:"literal",value:$}}if(typeof $==="number"||typeof $==="boolean")return{type:"literal",value:$};return{type:"literal",value:String($)}}function jb($,Z){if(Z){let X=Z.name.toLowerCase();if(X.includes("button"))return"button";if(X.includes("input")||X.includes("text"))return"input";if(X.includes("image")||X.includes("avatar"))return"image";if(X.includes("list")||X.includes("table"))return"list";if(X.includes("scroll"))return"scroll";return"custom"}if($.type==="text")return"text";let Y=$.tag?.toLowerCase();if(Y==="button")return"button";if(Y==="input"||Y==="textarea")return"input";if(Y==="img")return"image";if(Y==="ul"||Y==="ol")return"list";return"view"}function Hb($){let Z=$.props?.style,Y={},X={};if(Z){let J=Z.split(";").filter(Boolean);for(let Q of J){let[G,K]=Q.split(":").map((W)=>W.trim());if(!G||!K)continue;switch(G){case"display":Y.display=K;break;case"flex-direction":Y.flexDirection=K;break;case"justify-content":Y.justifyContent=Lb(K);break;case"align-items":Y.alignItems=Ob(K);break;case"gap":Y.gap=Number.parseInt(K,10);break;case"padding":Y.padding=Number.parseInt(K,10);break;case"margin":Y.margin=Number.parseInt(K,10);break;case"width":Y.width=K==="auto"?"auto":Number.parseInt(K,10);break;case"height":Y.height=K==="auto"?"auto":Number.parseInt(K,10);break;case"background-color":case"background":X.backgroundColor=K;break;case"border-color":X.borderColor=K;break;case"border-width":X.borderWidth=Number.parseInt(K,10);break;case"border-radius":X.borderRadius=Number.parseInt(K,10);break;case"opacity":X.opacity=Number.parseFloat(K);break}}}return{layout:Y,appearance:X}}function Lb($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function Ob($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function Fb($){let Z=[],Y=new Set;function X(J,Q){let G=J.id||rO();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:J.zigType,dependencies:Q?[Q]:[],size:pO(J),isStatic:Vb(J)};Z.push(K);for(let W of J.children)X(W,G)}return X($),Z}function pO($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function Vb($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function Ab($,Z){return $}function Nb($,Z){let Y=0;function X(J){Y+=pO(J);for(let Q of J.children)X(Q)}return X(Z),Y}function DG($,Z){switch(Z.format){case"zig":return mO($,Z);case"typescript":return Rb($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return mO($,Z)}}function mO($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('const std = @import("std");'),Y.push('const craft = @import("craft");'),Y.push(""),Y.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),Y.push(" return try build(allocator);"),Y.push("}"),Y.push(""),iO($,Y,0),Y.join(`
18097
+ `)}async function Wb($,Z={}){let Y=performance.now(),X=[],J=0,Q=0;for(let K of $.storyFiles)try{let W=await Bun.file(K.path).text(),U=await o7(W,K.path);if(U.length>0){for(let _ of U)X.push({storyId:K.id,variantId:"default",component:K.component,message:`A11y: ${_.message}`,expected:"No accessibility violations",actual:`${_.type}: ${_.message} (impact: ${_.impact})`});Q++}else J++}catch(W){X.push({storyId:K.id,variantId:"default",component:K.component,message:`Failed to check a11y: ${W instanceof Error?W.message:String(W)}`,expected:"File readable for a11y check",actual:"File read error"}),Q++}let G=performance.now()-Y;return{total:$.storyFiles.length,passed:J,failed:Q,new:0,failures:X,duration:G}}var dO=D(()=>{H4()});var oO={};t(oO,{default:()=>bb,createHotReloadServer:()=>aO,compileToNative:()=>uO,NATIVE_COMPONENTS:()=>bG});async function uO($,Z={}){let Y=performance.now(),X={target:Z.target||"universal",format:Z.format||"zig",optimize:Z.optimize??!0,treeShake:Z.treeShake??!0,hotReload:Z.hotReload??!1,debug:Z.debug??!1,sourceMaps:Z.sourceMaps??!1,bundle:Z.bundle??!0,minify:Z.minify??!1,components:Z.components||bG},J=typeof $==="string"?Ub($):$,Q=Bb(J.tree,X),G=Fb(Q),K=X.treeShake?Ab(Q,G):Q,W=new Map;if(X.target==="universal"){let q=["macos","windows","linux","ios","android"];for(let j of q){let H=DG(K,{...X,target:j});W.set(j,H)}}else{let q=DG(K,X);W.set(X.target,q)}let U=wb(K,X,W),_=Mb(J,K,X),B={compilationTime:performance.now()-Y,totalComponents:kG(J.tree),nativeComponents:SG(K),webComponents:kG(J.tree)-SG(K),bundleSize:U.length,treeShakenSize:X.treeShake?Nb(Q,K):U.length,warnings:[],errors:[]},z;if(X.sourceMaps)z=Eb(J,K);return{code:U,platformCode:W,dependencies:G,manifest:_,sourceMaps:z,stats:B}}function Ub($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),X=Y?Y[1]:$;return cO(X,Z),{id:rO(),hash:sO($),tree:Z,scripts:Db($),styles:kb($),staticParts:new Map,dynamicParts:new Map,dependencies:[],metadata:{hasSlots:!1,hasDynamicContent:$.includes("{{"),hasEventHandlers:$.includes("onclick")||$.includes("onchange"),hasAsyncContent:!1,componentCount:0,maxDepth:0,estimatedSize:$.length}}}function cO($,Z){let Y=/<(@?[\w-]+)([^>]*)(?:\/>|>([\s\S]*?)<\/\1>)/g,X;while((X=Y.exec($))!==null){let[,J,Q,G]=X,K=J.startsWith("@craft-"),W={type:K?"component":"element",tag:K?J.slice(1):J,props:_b(Q),children:[],componentName:K?J.slice(1):void 0};if(G){let U=G.replace(/<[^>]+>/g,"").trim();if(U)W.children=W.children??[],W.children.push({type:"text",text:U});cO(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function _b($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,X;while((X=Y.exec($))!==null){let[,J,Q]=X;Z[J]=Q??!0}return Z}function Bb($,Z){return lO($,Z)}function lO($,Z){let Y=$.componentName?Z.components?.get($.componentName):void 0,X="craft.View";if(Y)X=Y.zigType;else if($.type==="text")X="craft.Text";else if($.tag)X=zb($.tag);let J={};if($.props)for(let[W,U]of Object.entries($.props))J[W]=qb(U);let Q=[];if($.children)for(let W of $.children)Q.push(lO(W,Z));let G=new Map;if($.props){for(let[W,U]of Object.entries($.props))if(W.startsWith("on")&&typeof U==="string")G.set(W.slice(2).toLowerCase(),U)}let K=Hb($);return{type:jb($,Y),zigType:X,props:J,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function zb($){return{div:"craft.View",span:"craft.Text",p:"craft.Text",h1:"craft.Text",h2:"craft.Text",h3:"craft.Text",h4:"craft.Text",h5:"craft.Text",h6:"craft.Text",button:"craft.Button",input:"craft.TextInput",textarea:"craft.TextArea",select:"craft.Select",img:"craft.Image",a:"craft.Link",ul:"craft.List",ol:"craft.List",li:"craft.ListItem",form:"craft.Form",label:"craft.Label",nav:"craft.View",header:"craft.View",footer:"craft.View",main:"craft.View",section:"craft.View",article:"craft.View",aside:"craft.View"}[$.toLowerCase()]||"craft.View"}function qb($){if(typeof $==="string"){if($.startsWith("{{")&&$.endsWith("}}"))return{type:"binding",path:$.slice(2,-2).trim()};if($.includes("(")&&$.includes(")"))return{type:"callback",handler:$};return{type:"literal",value:$}}if(typeof $==="number"||typeof $==="boolean")return{type:"literal",value:$};return{type:"literal",value:String($)}}function jb($,Z){if(Z){let X=Z.name.toLowerCase();if(X.includes("button"))return"button";if(X.includes("input")||X.includes("text"))return"input";if(X.includes("image")||X.includes("avatar"))return"image";if(X.includes("list")||X.includes("table"))return"list";if(X.includes("scroll"))return"scroll";return"custom"}if($.type==="text")return"text";let Y=$.tag?.toLowerCase();if(Y==="button")return"button";if(Y==="input"||Y==="textarea")return"input";if(Y==="img")return"image";if(Y==="ul"||Y==="ol")return"list";return"view"}function Hb($){let Z=$.props?.style,Y={},X={};if(Z){let J=Z.split(";").filter(Boolean);for(let Q of J){let[G,K]=Q.split(":").map((W)=>W.trim());if(!G||!K)continue;switch(G){case"display":Y.display=K;break;case"flex-direction":Y.flexDirection=K;break;case"justify-content":Y.justifyContent=Lb(K);break;case"align-items":Y.alignItems=Ob(K);break;case"gap":Y.gap=Number.parseInt(K,10);break;case"padding":Y.padding=Number.parseInt(K,10);break;case"margin":Y.margin=Number.parseInt(K,10);break;case"width":Y.width=K==="auto"?"auto":Number.parseInt(K,10);break;case"height":Y.height=K==="auto"?"auto":Number.parseInt(K,10);break;case"background-color":case"background":X.backgroundColor=K;break;case"border-color":X.borderColor=K;break;case"border-width":X.borderWidth=Number.parseInt(K,10);break;case"border-radius":X.borderRadius=Number.parseInt(K,10);break;case"opacity":X.opacity=Number.parseFloat(K);break}}}return{layout:Y,appearance:X}}function Lb($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function Ob($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function Fb($){let Z=[],Y=new Set;function X(J,Q){let G=J.id||rO();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:J.zigType,dependencies:Q?[Q]:[],size:pO(J),isStatic:Vb(J)};Z.push(K);for(let W of J.children)X(W,G)}return X($),Z}function pO($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function Vb($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function Ab($,Z){return $}function Nb($,Z){let Y=0;function X(J){Y+=pO(J);for(let Q of J.children)X(Q)}return X(Z),Y}function DG($,Z){switch(Z.format){case"zig":return mO($,Z);case"typescript":return Rb($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return mO($,Z)}}function mO($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('const std = @import("std");'),Y.push('const craft = @import("craft");'),Y.push(""),Y.push("pub fn render(allocator: std.mem.Allocator) !craft.Element {"),Y.push(" return try build(allocator);"),Y.push("}"),Y.push(""),iO($,Y,0),Y.join(`
18098
18098
  `)}function iO($,Z,Y){let X=" ".repeat(Y);if(Y===0)Z.push("fn build(allocator: std.mem.Allocator) !craft.Element {");let J=`node_${Y}`;Z.push(`${X} var ${J} = try ${$.zigType}.init(allocator);`);for(let[Q,G]of Object.entries($.props))if(G.type==="literal"){let K=typeof G.value==="string"?`"${G.value}"`:String(G.value);Z.push(`${X} ${J}.set${Ib(Q)}(${K});`)}for(let Q=0;Q<$.children.length;Q++){let G=$.children[Q];if(G.type==="text"){let K=G.props.text?.type==="literal"?String(G.props.text.value):"";Z.push(`${X} try ${J}.addChild(try craft.Text.init(allocator, "${K}"));`)}else iO(G,Z,Y+1),Z.push(`${X} try ${J}.addChild(node_${Y+1});`)}if(Y===0)Z.push(` return ${J}.element();`),Z.push("}")}function Rb($,Z){let Y=[];return Y.push("// Auto-generated by stx compiler"),Y.push("// Target: "+Z.target),Y.push(""),Y.push('import { Craft } from "@stacksjs/craft";'),Y.push(""),Y.push("export function render(): Craft.Element {"),Y.push(" return "+nO($,1)+";"),Y.push("}"),Y.join(`
18099
18099
  `)}function nO($,Z){let Y=" ".repeat(Z),X=[];for(let[K,W]of Object.entries($.props))if(W.type==="literal"){let U=typeof W.value==="string"?`"${W.value}"`:String(W.value);X.push(`${K}: ${U}`)}let J=X.length>0?`{ ${X.join(", ")} }`:"{}",Q=$.children.map((K)=>K.type==="text"?`"${K.props.text?.type==="literal"?K.props.text.value:""}"`:nO(K,Z+1)),G=Q.length>0?`,
18100
18100
  ${Y} [${Q.join(`,
18101
18101
  ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function wb($,Z,Y){if(Z.target==="universal"){let X=[];X.push("// Universal entry point"),X.push("");for(let[J,Q]of Y)X.push(`// --- ${J.toUpperCase()} ---`),X.push(`#if ${J.toUpperCase()}`),X.push(Q),X.push("#endif"),X.push("");return X.join(`
18102
- `)}return Y.get(Z.target)||DG($,Z)}function Mb($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:sO(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function Eb($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function rO(){return`id_${++Tb}`}function sO($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function Ib($){return $.charAt(0).toUpperCase()+$.slice(1)}function Db($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function kb($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function kG($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=kG(Y);return Z}function SG($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=SG(Y);return Z}function aO($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var bG,Tb=0,Sb,bb;var tO=D(()=>{bG=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Sb={compileToNative:uO,createHotReloadServer:aO,NATIVE_COMPONENTS:bG},bb=Sb});import{spawn as ZF}from"child_process";import S0 from"fs";import Cb from"os";import o from"path";import v from"process";import{CLI as Pb}from"@stacksjs/clapp";var l4="0.2.15";H6();GG();TJ();CJ();j4();kJ();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",q0=new Pb("stx");function eO($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function $F($){try{if(!S0.existsSync($)){let Y=o.dirname($),X=o.basename($);if(S0.existsSync(Y)){let Q=S0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(S0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function CG($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var h$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),yb=($)=>$.endsWith(".stx")||$.endsWith(".md");function f$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}async function xb($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(h$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=o.join(Cb.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",o.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...v.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=ZF(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let B=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
18102
+ `)}return Y.get(Z.target)||DG($,Z)}function Mb($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:sO(JSON.stringify(Q.props)),props:Object.keys(Q.props),events:Array.from(Q.events.keys()),slots:[],isNative:Q.zigType.startsWith("craft.")});for(let G of Q.children)J(G)}return J(Z),{version:"1.0.0",components:X,entry:$.id,assets:[],styles:$.styles}}function Eb($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function rO(){return`id_${++Tb}`}function sO($){let Z=0;for(let Y=0;Y<$.length;Y++){let X=$.charCodeAt(Y);Z=(Z<<5)-Z+X,Z=Z&Z}return Math.abs(Z).toString(36)}function Ib($){return $.charAt(0).toUpperCase()+$.slice(1)}function Db($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function kb($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function kG($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=kG(Y);return Z}function SG($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=SG(Y);return Z}function aO($){return{start:async()=>{console.log("[craft-compiler] Hot reload server started")},stop:async()=>{console.log("[craft-compiler] Hot reload server stopped")},notifyChange:(Z)=>{console.log(`[craft-compiler] File changed: ${Z}`)}}}var bG,Tb=0,Sb,bb;var tO=D(()=>{bG=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Sb={compileToNative:uO,createHotReloadServer:aO,NATIVE_COMPONENTS:bG},bb=Sb});import{spawn as ZF}from"child_process";import S0 from"fs";import Cb from"os";import o from"path";import v from"process";import{CLI as Pb}from"@stacksjs/clapp";var l6="0.2.16";H4();GG();TJ();CJ();j6();kJ();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",q0=new Pb("stx");function eO($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Port must be a valid number",suggestion:"Try using a number between 1024 and 65535"};if(Z<1024||Z>65535)return{isValid:!1,error:"Port must be between 1024 and 65535",suggestion:"Try using a port between 1024 and 65535"};return{isValid:!0}}function $F($){try{if(!S0.existsSync($)){let Y=o.dirname($),X=o.basename($);if(S0.existsSync(Y)){let Q=S0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(S0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function CG($){let Z=typeof $==="string"?Number.parseInt($,10):$;if(Number.isNaN(Z))return{isValid:!1,error:"Timeout must be a valid number",suggestion:"Specify timeout in milliseconds (e.g., 5000 for 5 seconds)"};if(Z<100)return{isValid:!1,error:"Timeout too short (minimum 100ms)",suggestion:"Use a timeout of at least 100ms"};if(Z>300000)return{isValid:!1,error:"Timeout too long (maximum 5 minutes)",suggestion:"Use a timeout of less than 300000ms (5 minutes)"};return{isValid:!0}}var h$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),yb=($)=>$.endsWith(".stx")||$.endsWith(".md");function f$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);v.exit(Z)}async function xb($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(h$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=o.join(Cb.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",o.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...v.env,STX_TEST_MODE:"true",STX_TEST_UI:Z.ui?"true":"false",STX_TEST_VERBOSE:Z.verbose?"true":"false"},Q="bun";if(Z.verbose)console.log(`Running: ${Q} ${Y.join(" ")}`);let G=performance.now(),K=ZF(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let B=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),v.on("SIGINT",()=>{console.log(`
18103
18103
  Test run interrupted`),K.kill("SIGINT"),v.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var vb=v.argv.length>=3&&(yb(v.argv[2])&&S0.existsSync(v.argv[2])||h$(v.argv[2]));if(vb){let $=v.argv[2],Z={port:3000,watch:!0,cache:!0,markdown:{syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}}};for(let Y=3;Y<v.argv.length;Y++){let X=v.argv[Y];if(X==="--port"&&Y+1<v.argv.length){let J=eO(v.argv[++Y]);if(!J.isValid)f$(J);Z.port=Number.parseInt(v.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<v.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=v.argv[++Y]}else if(X==="--no-highlight"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.enabled=!1}else if(X==="--no-highlight-unknown"){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.highlightUnknownLanguages=!1}else if(X==="--no-cache")Z.cache=!1;else if(X==="--native")Z.native=!0}if(h$($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=o.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(o.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),v.exit(1);if(!await b7(X,Z))v.exit(1)}catch(Y){console.error("Failed to process files:",Y),v.exit(1)}else S7($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),v.exit(1)})}else{let $=function(X,J){let Q=[];for(let G=0;G<=J.length;G++)Q[G]=[G];for(let G=0;G<=X.length;G++)Q[0][G]=G;for(let G=1;G<=J.length;G++)for(let K=1;K<=X.length;K++)if(J.charAt(G-1)===X.charAt(K-1))Q[G][K]=Q[G-1][K-1];else Q[G][K]=Math.min(Q[G-1][K-1]+1,Q[G][K-1]+1,Q[G-1][K]+1);return Q[J.length][X.length]};q0.command("docs","Generate documentation for components, templates, and directives").option("--output <dir>","Output directory for documentation",{default:"docs"}).option("--format <format>","Documentation format (markdown, html, json)",{default:"markdown"}).option("--components-dir <dir>","Components directory",{default:"components"}).option("--templates-dir <dir>","Templates directory",{default:"."}).option("--no-components","Disable components documentation").option("--no-templates","Disable templates documentation").option("--no-directives","Disable directives documentation").option("--extra-content <content>","Extra content to include in documentation").example("stx docs --output docs --format html").action(async(X)=>{try{if(await EJ(X))console.log("Documentation generated successfully."),v.exit(0);else console.error("Documentation generation failed."),v.exit(1)}catch(J){console.error("Error generating documentation:",J),v.exit(1)}}),q0.command("iconify <command>","Generate Iconify icon packages").option("--output <dir>","Output directory for generated packages",{default:"packages"}).option("--icons <icons>","Comma-separated list of specific icons to generate").example("stx iconify list").example("stx iconify generate mdi").example("stx iconify generate lucide --icons home,settings,user").action(async(X,J)=>{try{let{fetchCollections:Q,generatePackage:G}=await import("@stacksjs/iconify-generator");if(X==="list"){console.log(`
18104
18104
  \uD83D\uDCDA Fetching available icon collections...
18105
18105
  `);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections:
@@ -18177,7 +18177,7 @@ Total: ${W} issues in ${K} files`),J.output){let U=`
18177
18177
  `),v.exit(1);console.log(" To preview locally:"),console.log(` cd ${J.out||"dist"} && npx serve
18178
18178
  `)}}catch(Q){console.error(`
18179
18179
  Build failed:`,Q instanceof Error?Q.message:String(Q)),v.exit(1)}}),q0.command("start","Start the production server (serves pre-built .output/)").option("--port <number>","Server port",{default:"3000"}).option("--output <dir>","Output directory from stx build",{default:".output"}).example("stx start").example("stx start --port 8080").action(async(X)=>{try{let J=o.resolve(X.output);if(!S0.existsSync(o.join(J,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),v.exit(1);let{startProductionServer:Q}=await Promise.resolve().then(() => (gJ(),Nj));await Q({outputDir:J,port:Number.parseInt(X.port,10)||3000})}catch(J){console.error(`
18180
- Failed to start production server:`,J instanceof Error?J.message:String(J)),v.exit(1)}}),q0.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(X,J)=>{try{let{deploy:Q,initNetlify:G,DeployError:K}=await Promise.resolve().then(() => (X3(),bz));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${l4}\x1B[0m`),J.init){console.log(`
18180
+ Failed to start production server:`,J instanceof Error?J.message:String(J)),v.exit(1)}}),q0.command("deploy [directory]","Deploy built site to Netlify").option("--site-id <id>","Netlify site ID (or set NETLIFY_SITE_ID env var)").option("--token <token>","Auth token (or set NETLIFY_AUTH_TOKEN env var)").option("--production","Deploy to production (default: draft preview)").option("--message <msg>","Deploy message/title").option("--no-build","Skip build step before deploy").option("--open","Open deployed URL in browser").option("--dry-run","Preview deployment without uploading").option("--init","Initialize Netlify configuration for this project").example("stx deploy").example("stx deploy --production").example("stx deploy dist --site-id my-site-abc123").example("stx deploy --init").example("stx deploy --dry-run").action(async(X,J)=>{try{let{deploy:Q,initNetlify:G,DeployError:K}=await Promise.resolve().then(() => (X3(),bz));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${l6}\x1B[0m`),J.init){console.log(`
18181
18181
  \uD83D\uDCDD Initializing Netlify configuration...
18182
18182
  `);let U=await G({directory:X||v.cwd(),siteId:J.siteId});if(console.log(`\u2713 Created ${U.configPath}`),U.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
18183
18183
  You can now deploy with: stx deploy`);return}if(J.build!==!1){if(console.log(`
@@ -18189,7 +18189,7 @@ You can now deploy with: stx deploy`);return}if(J.build!==!1){if(console.log(`
18189
18189
  `),console.log(` ${J.dryRun?"Would deploy":"Draft URL"}: ${W.url}`),W.siteUrl)console.log(` Site URL: ${W.siteUrl}`);if(!J.dryRun)console.log(`
18190
18190
  Deploy ID: ${W.deployId}`),console.log(` Duration: ${(W.duration/1000).toFixed(1)}s`),console.log(` Files: ${W.filesUploaded}`)}}catch(Q){if(Q instanceof Error&&Q.name==="DeployError")console.error(`
18191
18191
  \u274C ${Q.message}`),v.exit(1);console.error(`
18192
- \u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),v.exit(1)}}),q0.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(X,J)=>{try{let{optimizeDirectory:Q,isSharpAvailable:G,formatSize:K}=await Promise.resolve().then(() => (H3(),mz)),W=await import("fs"),U=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${l4}\x1B[0m`),!await G())console.error(`
18192
+ \u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),v.exit(1)}}),q0.command("images <input>","Optimize images for production").option("-o, --output <dir>","Output directory",{default:"dist/images"}).option("-w, --widths <sizes>","Output widths (comma-separated)",{default:"320,640,768,1024,1280,1536,1920"}).option("-f, --formats <types>","Output formats (comma-separated)",{default:"webp,jpeg"}).option("-q, --quality <n>","Output quality (1-100)",{default:"80"}).option("--placeholder <type>","Placeholder type: blur, dominant-color, none",{default:"none"}).option("--dry-run","Preview without processing").option("--verbose","Show detailed output").example("stx images public/images").example("stx images public/images -o dist/images").example("stx images public/images --widths 640,1024,1920").example("stx images public/images --formats webp,avif").example("stx images public/images --quality 85").example("stx images public/images --dry-run").action(async(X,J)=>{try{let{optimizeDirectory:Q,isSharpAvailable:G,formatSize:K}=await Promise.resolve().then(() => (H3(),mz)),W=await import("fs"),U=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${l6}\x1B[0m`),!await G())console.error(`
18193
18193
  \u274C sharp is required for image optimization.`),console.log(`
18194
18194
  Install sharp with:`),console.log(" bun add sharp"),v.exit(1);let B=J.widths.split(",").map((O)=>Number.parseInt(O.trim(),10)).filter((O)=>!Number.isNaN(O)),z=J.formats.split(",").map((O)=>O.trim().toLowerCase()),q=Number.parseInt(J.quality,10)||80,j=J.placeholder,H=U.resolve(X);if(!W.existsSync(H))console.error(`
18195
18195
  \u274C Input directory not found: ${H}`),v.exit(1);if(!W.statSync(H).isDirectory())console.error(`
@@ -18202,13 +18202,13 @@ Would generate ~${N} image variants`);return}console.log(`
18202
18202
  `);let F=await Q(H,J.output,{widths:B,formats:z,quality:q,placeholder:j,verbose:J.verbose});if(console.log(`
18203
18203
  \u2713 Optimization complete!
18204
18204
  `),console.log(` Images processed: ${F.stats.optimizedImages}/${F.stats.totalImages}`),console.log(` Variants created: ${F.stats.variants}`),F.stats.savedBytes>0)console.log(` Estimated savings: ~${K(F.stats.savedBytes)}`)}catch(Q){console.error(`
18205
- \u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),v.exit(1)}}),q0.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(X,J)=>{try{let{analyze:Q,formatBytes:G,parseSize:K}=await Promise.resolve().then(() => (HL(),jL)),W=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${l4}\x1B[0m`);let U=X||"dist",_=W.resolve(U);if(!(await import("fs")).existsSync(_))console.error(`
18205
+ \u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),v.exit(1)}}),q0.command("bundle [directory]","Analyze bundle size and composition").option("-o, --output <file>","Output file path").option("--json","Output as JSON").option("--text","Output as text summary").option("--markdown","Output as Markdown").option("--no-open","Do not open HTML report in browser").option("--no-gzip","Do not show gzip sizes").option("--threshold <size>","Fail if total size exceeds threshold (e.g., 500KB, 1MB)").option("--top <n>","Number of top modules to show",{default:"20"}).example("stx bundle").example("stx bundle dist/").example("stx bundle dist/ --json").example("stx bundle dist/ --text").example("stx bundle dist/ --threshold 500KB").example("stx bundle dist/ --no-open").action(async(X,J)=>{try{let{analyze:Q,formatBytes:G,parseSize:K}=await Promise.resolve().then(() => (HL(),jL)),W=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${l6}\x1B[0m`);let U=X||"dist",_=W.resolve(U);if(!(await import("fs")).existsSync(_))console.error(`
18206
18206
  \u274C Directory not found: ${_}`),console.log("\nRun `stx build` first to generate build output."),v.exit(1);let z="html";if(J.json)z="json";else if(J.text)z="text";else if(J.markdown)z="markdown";console.log(`
18207
18207
  \uD83D\uDCE6 Analyzing: ${_}`);let q=await Q({directory:_,output:J.output,format:z,open:J.open!==!1&&z==="html",gzip:J.gzip!==!1,threshold:J.threshold,topModules:Number.parseInt(J.top||"20",10),recommendations:!0});if(z==="html"){if(console.log(`
18208
18208
  \u2713 Report generated: ${q.outputPath}`),J.open!==!1)console.log(" Opening in browser...")}else console.log(q.report);if(q.exceedsThreshold){let j=J.threshold;console.error(`
18209
18209
  \u274C Bundle size (${G(q.stats.totalSize)}) exceeds threshold (${j})`),v.exit(1)}if(z==="html"){if(console.log(`
18210
18210
  \uD83D\uDCCA Summary:`),console.log(` Total Size: ${G(q.stats.totalSize)}`),console.log(` Gzip Size: ${G(q.stats.totalGzipSize)}`),console.log(` Modules: ${q.stats.moduleCount}`),console.log(` Chunks: ${q.stats.chunks.length}`),q.stats.duplicates.length>0)console.log(` Duplicates: ${q.stats.duplicates.length}`)}}catch(Q){console.error(`
18211
- \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),v.exit(1)}}),q0.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(X,J)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${l4} (${fJ})\x1B[0m`),J.timeout){let K=CG(J.timeout);if(!K.isValid)f$(K)}let Q=typeof X==="string"?[X]:X||[];if(Q.length===0)Q.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(J.verbose)console.log("Test patterns:",Q),console.log("Options:",JSON.stringify({watch:J.watch||!1,filter:J.filter||"none",reporter:J.reporter||"default",timeout:J.timeout||5000,coverage:J.coverage||!1,ui:J.ui||!1},null,2));if(!await N1.timeAsync("test-execution",()=>xb(Q,J))&&!J.watch)v.exit(1)}catch(Q){console.error("Error running tests:",Q),v.exit(1)}}),q0.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(X="index.stx",J)=>{try{if(await bJ(X,{force:J.force,template:J.template}))console.log(`
18211
+ \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),v.exit(1)}}),q0.command("test [patterns...]","Run tests with Bun test runner and browser environment").option("--watch","Watch for changes and rerun tests").option("--filter <pattern>","Only run tests matching the given pattern").option("--reporter <reporter>","Test reporter to use: default or junit (junit requires Bun v1.0+)",{default:"default"}).option("--timeout <ms>","Test timeout in milliseconds",{default:5000}).option("--coverage","Enable code coverage").option("--ui","Coming soon").option("--verbose","Show verbose output including test command").example("stx test").example("stx test packages/stx/test/").example("stx test **/*.test.ts --verbose").example('stx test --filter "should process"').example("stx test --watch --verbose").example("stx test --reporter junit").action(async(X,J)=>{try{if(console.log(`\x1B[1mstx test\x1B[0m \x1B[2mv${l6} (${fJ})\x1B[0m`),J.timeout){let K=CG(J.timeout);if(!K.isValid)f$(K)}let Q=typeof X==="string"?[X]:X||[];if(Q.length===0)Q.push("**/*.test.ts","**/*.test.js","**/*.spec.ts","**/*.spec.js");if(J.verbose)console.log("Test patterns:",Q),console.log("Options:",JSON.stringify({watch:J.watch||!1,filter:J.filter||"none",reporter:J.reporter||"default",timeout:J.timeout||5000,coverage:J.coverage||!1,ui:J.ui||!1},null,2));if(!await N1.timeAsync("test-execution",()=>xb(Q,J))&&!J.watch)v.exit(1)}catch(Q){console.error("Error running tests:",Q),v.exit(1)}}),q0.command("init [file]","Create a new STX file").alias("new").option("--force","Overwrite existing file").option("--template <file>","Path to a template file to use as a base").example("stx init").example("stx init page.stx").example("stx new contact.stx").example("stx new components/button.stx --template examples/components/button.stx").action(async(X="index.stx",J)=>{try{if(await bJ(X,{force:J.force,template:J.template}))console.log(`
18212
18212
  \u2728 Successfully created file: ${X}`),console.log(`
18213
18213
  To view it in the development server:`),console.log(` stx dev ${X}
18214
18214
  `);else console.error(`
@@ -18239,7 +18239,7 @@ Press Ctrl+C to stop watching...
18239
18239
  \uD83D\uDCDD ${o.relative(v.cwd(),z.file)}`),console.log(` Lines: ${z.metrics.lines} | Complexity: ${z.metrics.complexity}/10 | Estimated render: ${z.performance.estimatedRenderTime}ms`),z.issues.length>0){let q=z.issues.filter((j)=>K[j.type]>=W);if(q.length>0)console.log(` Issues (${q.length}):`),q.forEach((j)=>{let H=j.type==="error"?"\u274C":j.type==="warning"?"\u26A0\uFE0F":"\u2139\uFE0F";if(console.log(` ${H} ${j.message}`),j.suggestion)console.log(` \uD83D\uDCA1 ${j.suggestion}`)})}if(z.suggestions.length>0)console.log(` Suggestions (${z.suggestions.length}):`),z.suggestions.forEach((q)=>{let j=q.impact==="high"?"\uD83D\uDD25":q.impact==="medium"?"\u26A1":"\uD83D\uDCAB";console.log(` ${j} ${q.message} (${q.impact} impact, ${q.effort} effort)`)})}}else if(B.length>0&&!J.onlyIssues)console.log(`
18240
18240
  \uD83D\uDCC4 Files with issues:`),B.forEach((z)=>{let q=z.issues.filter((j)=>K[j.type]>=W).length;if(q>0)console.log(` ${o.relative(v.cwd(),z.file)} (${q} issues)`)});if(J.saveReport){let z={summary:_,results:B,generatedAt:new Date().toISOString(),commandOptions:J};await Bun.write(J.saveReport,JSON.stringify(z,null,2)),console.log(`
18241
18241
  \uD83D\uDCCB Analysis report saved to: ${J.saveReport}`)}console.log(`
18242
- \u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),v.exit(1)}}),q0.command("version","Show the version of the CLI").action(()=>{console.log(l4)}),q0.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(X)=>{let{startInteractive:J}=await Promise.resolve().then(() => (PJ(),Hj)),Q={};if(X.context){let G=o.resolve(X.context);if(S0.existsSync(G))try{let K=S0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),v.exit(1)}else console.error(`Context file not found: ${G}`),v.exit(1)}await J({context:Q,cwd:X.cwd?o.resolve(X.cwd):v.cwd(),verbose:X.verbose})}),q0.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(X,J)=>{try{let{buildNative:Q,getAvailableTargets:G,getAvailableFormats:K}=await Promise.resolve().then(() => (kL(),DL)),W=o.resolve(X);if(!S0.existsSync(W))console.error(`\u274C Input file not found: ${X}`),v.exit(1);let U=G();if(J.target&&!["macos","windows","linux","ios","android"].includes(J.target))console.error(`\u274C Invalid target: ${J.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${U.join(", ")}`),v.exit(1);let _=J.target||U[0],B=K(_);if(J.format&&!B.includes(J.format))console.error(`\u274C Invalid format for ${_}: ${J.format}`),console.error(`\uD83D\uDCA1 Available formats: ${B.join(", ")}`),v.exit(1);console.log(`
18242
+ \u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),v.exit(1)}}),q0.command("version","Show the version of the CLI").action(()=>{console.log(l6)}),q0.command("interactive","Start interactive REPL mode for template development").alias("i").option("--context <file>","Load initial context from JSON file").option("--cwd <directory>","Set working directory").option("--verbose","Show verbose output").action(async(X)=>{let{startInteractive:J}=await Promise.resolve().then(() => (PJ(),Hj)),Q={};if(X.context){let G=o.resolve(X.context);if(S0.existsSync(G))try{let K=S0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),v.exit(1)}else console.error(`Context file not found: ${G}`),v.exit(1)}await J({context:Q,cwd:X.cwd?o.resolve(X.cwd):v.cwd(),verbose:X.verbose})}),q0.command("build:native <input>","Build stx template into a native desktop/mobile app").option("--output <dir>","Output directory",{default:"dist/native"}).option("--target <platform>","Target platform: macos, windows, linux, ios, android").option("--format <format>","Output format: app, dmg, pkg, msi, zip, deb, rpm, appimage, ipa, apk").option("--name <name>","Application name (defaults to filename)").option("--version <version>","Application version",{default:"1.0.0"}).option("--description <desc>","Application description").option("--author <author>","Author/Maintainer name").option("--bundle-id <id>","Bundle identifier (macOS/iOS)").option("--icon <path>","Path to application icon").option("--width <width>","Window width",{default:"1200"}).option("--height <height>","Window height",{default:"800"}).option("--title <title>","Window title").option("--system-tray","Enable system tray/menubar mode").option("--dev-tools","Enable developer tools").option("--frameless","Create frameless window").option("--always-on-top","Keep window always on top").option("--craft-path <path>","Path to Craft binary").option("--verbose","Show verbose output").example("stx build:native app.stx --target macos").example("stx build:native app.stx --target macos --format dmg").example("stx build:native app.stx --target linux --format appimage").example('stx build:native app.stx --name "My App" --icon icon.png').action(async(X,J)=>{try{let{buildNative:Q,getAvailableTargets:G,getAvailableFormats:K}=await Promise.resolve().then(() => (kL(),DL)),W=o.resolve(X);if(!S0.existsSync(W))console.error(`\u274C Input file not found: ${X}`),v.exit(1);let U=G();if(J.target&&!["macos","windows","linux","ios","android"].includes(J.target))console.error(`\u274C Invalid target: ${J.target}`),console.error("\uD83D\uDCA1 Available targets: macos, windows, linux, ios, android"),console.error(`\uD83D\uDCA1 Targets available on this machine: ${U.join(", ")}`),v.exit(1);let _=J.target||U[0],B=K(_);if(J.format&&!B.includes(J.format))console.error(`\u274C Invalid format for ${_}: ${J.format}`),console.error(`\uD83D\uDCA1 Available formats: ${B.join(", ")}`),v.exit(1);console.log(`
18243
18243
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${X}`),console.log(` Target: ${_}`),console.log(` Format: ${J.format||"default"}`),console.log(` Output: ${J.output}
18244
18244
  `);let z=await Q({input:W,output:o.resolve(J.output),target:_,format:J.format,name:J.name,version:J.version,description:J.description,author:J.author,bundleId:J.bundleId,icon:J.icon?o.resolve(J.icon):void 0,window:{title:J.title,width:Number.parseInt(J.width,10),height:Number.parseInt(J.height,10),frameless:J.frameless,alwaysOnTop:J.alwaysOnTop},systemTray:J.systemTray,devTools:J.devTools,craftPath:J.craftPath,verbose:J.verbose});if(z.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${z.outputPath}`),z.duration)console.log(` Duration: ${(z.duration/1000).toFixed(2)}s`);if(_==="macos"&&z.format==="app")console.log(`
18245
18245
  \uD83D\uDCA1 To run: open "${z.outputPath}"`);else if(_==="linux"&&z.format==="appimage")console.log(`
@@ -18250,4 +18250,4 @@ Press Ctrl+C to stop watching...
18250
18250
  \u26A0\uFE0F Warnings:`);for(let L of _.stats.warnings)console.log(` - ${L.message}`)}if(_.stats.errors.length>0){console.log(`
18251
18251
  \u274C Errors:`);for(let L of _.stats.errors)console.log(` - ${L.message}`)}}catch(Q){console.error(`\u274C Compilation error: ${Q.message}`),v.exit(1)}});let Z=["docs","iconify","dev","a11y","build","start","build:native","compile","test","init","new","format","perf","debug","status","watch","analyze","version","deploy","interactive","i","story","story:build","story:test"],Y=v.argv.slice(2);if(Y.length>0&&!Y[0].startsWith("-")){let X=Y[0];if(X==="")console.error("\u274C No command provided"),console.error("\uD83D\uDCA1 Use --help to see available commands"),v.exit(1);if(!Z.includes(X)){let J=a("fs"),Q=a("path"),G=X;if(!Q.isAbsolute(G))G=Q.resolve(v.cwd(),G);if(J.existsSync(G)){let K=J.statSync(G);if(K.isFile()||K.isDirectory())v.argv=[v.argv[0],v.argv[1],"dev",...Y]}else{let K=Z.map((U)=>({command:U,distance:$(X,U)}));K.sort((U,_)=>U.distance-_.distance);let W=K[0];if(W.distance<=3)console.error(`\u274C Unknown command: ${X}`),console.error(`\uD83D\uDCA1 Did you mean: ${W.command}?`),console.error(`
18252
18252
  Run 'stx --help' to see available commands.`),v.exit(1);console.error(`\u274C Unknown command or path: ${X}`),console.error(`
18253
- Run 'stx --help' to see available commands.`),v.exit(1)}}}q0.help(),q0.version(l4),q0.parse(v.argv)}
18253
+ Run 'stx --help' to see available commands.`),v.exit(1)}}}q0.help(),q0.version(l6),q0.parse(v.argv)}