@stacksjs/stx 0.2.31 → 0.2.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ var bF=Object.defineProperty;var CF=($)=>$;function PF($,Z){this[$]=CF.bind(null
12
12
  white-space: nowrap;
13
13
  border-width: 0;
14
14
  }
15
- `.trim()}function ZK(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function vF($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let O=J[1];if(!/\balt\s*=/i.test(O))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 O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))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 O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))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 O=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(O)){J=K.exec($);continue}let F=/\baria-label\s*=/i.test(O)||/\baria-labelledby\s*=/i.test(O),L=O.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!F){let V=L&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${L[1]}["']`,"i").test($),w=J.index,A=$.substring(0,w),N=$.substring(w),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 O of U){if(_>0&&O>_+1)Y.push({type:"heading-skip",element:`<h${O}>`,message:`Heading level skipped from h${_} to h${O}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});_=O}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 O=J[1];if(!/<th\b/i.test(O))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 O=J[1];if(!/\btitle\s*=/i.test(O)&&!/\baria-label\s*=/i.test(O))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 O=J[1].toLowerCase(),F=J[2];if(O!=="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 _9($,Z){if(!ZK())return vF($,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 N8($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=U9.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(U9.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 _9(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function YK($,Z={}){let Y={...gF,...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 XK($,Z={},Y=!1){let X=await Bun.file($).text(),J=YK(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function fF($,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=U9.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let B of _.scan()){if(Q.some((q)=>B.includes(U9.normalize(q))))continue;try{let q=await XK(B,Z,G);if(q.fixCount>0)X[B]=q}catch(q){console.error(`Error fixing ${B}:`,q)}}return X}function hF(){return[B9,z9]}var gF,B9,z9;var A6=D(()=>{gF={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};B9={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},z9={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function dF($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...S1,...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 ZK(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function vF($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let O=J[1];if(!/\balt\s*=/i.test(O))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 O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))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 O=J[1];if(!/\baria-label\s*=/i.test(O)&&!/\btitle\s*=/i.test(O))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 O=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(O)){J=K.exec($);continue}let F=/\baria-label\s*=/i.test(O)||/\baria-labelledby\s*=/i.test(O),L=O.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!F){let V=L&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${L[1]}["']`,"i").test($),w=J.index,A=$.substring(0,w),N=$.substring(w),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 O of U){if(_>0&&O>_+1)Y.push({type:"heading-skip",element:`<h${O}>`,message:`Heading level skipped from h${_} to h${O}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});_=O}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 O=J[1];if(!/<th\b/i.test(O))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 O=J[1];if(!/\btitle\s*=/i.test(O)&&!/\baria-label\s*=/i.test(O))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 O=J[1].toLowerCase(),F=J[2];if(O!=="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 _9($,Z){if(!ZK())return vF($,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 N8($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=U9.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(U9.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 _9(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function YK($,Z={}){let Y={...gF,...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 XK($,Z={},Y=!1){let X=await Bun.file($).text(),J=YK(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function fF($,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=U9.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let B of _.scan()){if(Q.some((q)=>B.includes(U9.normalize(q))))continue;try{let q=await XK(B,Z,G);if(q.fixCount>0)X[B]=q}catch(q){console.error(`Error fixing ${B}:`,q)}}return X}function hF(){return[B9,z9]}var gF,B9,z9;var A4=D(()=>{gF={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};B9={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},z9={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function dF($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...S1,...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 I8($,Z){let Y=T8(Z);if(!Y)return $;let X=$.lastIndexOf("</body>");if(X!==-1)return $.slice(0,X)+Y+$.slice(X);return $+Y}function ZV($){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 k8{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 YV(){return new k8}var qK,D8;var F9=D(()=>{qK={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};D8={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=ZV(Z.join(" "));J.heatmap={...J.heatmap,...Q,enabled:!0}}return T8(J)}}});function _4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function jK($){let Z=$.trim().toLowerCase();return!Z.startsWith("javascript:")&&!Z.startsWith("vbscript:")&&!Z.startsWith("data:text/html")}function HK($){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 n$($,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="${jK(z)?_4(z):""}" alt="${_4(B)}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(_,B,z)=>{return`<a href="${jK(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((O)=>O.trim()).filter(Boolean).map((O)=>`<th>${_4(O)}</th>`).join("")}</tr>`,H=z.trim().split(`
796
- `).map((O)=>{return`<tr>${O.split("|").map((L)=>L.trim()).filter(Boolean).map((L)=>`<td>${_4(L)}</td>`).join("")}</tr>`}).join(`
793
+ `}function I8($,Z){let Y=T8(Z);if(!Y)return $;let X=$.lastIndexOf("</body>");if(X!==-1)return $.slice(0,X)+Y+$.slice(X);return $+Y}function ZV($){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 k8{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 YV(){return new k8}var qK,D8;var F9=D(()=>{qK={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};D8={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=ZV(Z.join(" "));J.heatmap={...J.heatmap,...Q,enabled:!0}}return T8(J)}}});function _6($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function jK($){let Z=$.trim().toLowerCase();return!Z.startsWith("javascript:")&&!Z.startsWith("vbscript:")&&!Z.startsWith("data:text/html")}function HK($){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 n$($,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="${jK(z)?_6(z):""}" alt="${_6(B)}" />`}),J=J.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(_,B,z)=>{return`<a href="${jK(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((O)=>O.trim()).filter(Boolean).map((O)=>`<th>${_6(O)}</th>`).join("")}</tr>`,H=z.trim().split(`
796
+ `).map((O)=>{return`<tr>${O.split("|").map((L)=>L.trim()).filter(Boolean).map((L)=>`<td>${_6(L)}</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
- `}),$}import OK from"process";function H1($="STX_PUBLIC_"){let Z={},Y={};for(let[X,J]of Object.entries(OK.env)){if(!X.startsWith($)||J===void 0)continue;Z[`import.meta.env.${X}`]=JSON.stringify(J),Y[X]=J}return Z["import.meta.env"]=JSON.stringify(Y),Z}function LK($="STX_PUBLIC_"){let Z={};for(let[Y,X]of Object.entries(OK.env))if(Y.startsWith($)&&X!==void 0)Z[Y]=X;return Z}var r4=()=>{};var S8={};e(S8,{hasUserImports:()=>XV,bundleClientScript:()=>QV});import b1 from"path";import a4 from"fs";function XV($){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(!FK.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(!FK.some((W)=>W.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function JV($){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=b1.resolve($,Y.path.slice(2)),J=[X,`${X}.ts`,`${X}.js`,b1.join(X,"index.ts"),b1.join(X,"index.js")];for(let Q of J)if(a4.existsSync(Q)&&a4.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 QV($,Z,Y={}){let X=Y.projectRoot||process.cwd(),J=Y.minify??!1,Q=Y.cacheDir||b1.join(X,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),W=b1.join(Q,`${K}.js`),U=Bun.file(W);if(await U.exists())return console.log("[stx:bundler] cache hit:",K),await U.text();let _=b1.join(X,".stx","bundle-tmp"),B=b1.join(_,`${K}.ts`),z=b1.join(_,"out",K);a4.mkdirSync(_,{recursive:!0}),a4.mkdirSync(z,{recursive:!0});let q=b1.dirname(Z),j=[],H=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,O=/^(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 w=V.split(":")[0].trim();if(w)j.push(w)});else if(F[3])j.push(F[3])}while((F=O.exec($))!==null){if(F[1])continue;j.push(F[2])}let L=j.length>0?`
814
- export { ${j.join(", ")} }`:"";await Bun.write(B,$+L),console.log("[stx:bundler] bundling:",K,"from:",b1.basename(Z));try{let V=await Bun.build({entrypoints:[B],outdir:z,target:"browser",format:"esm",minify:J,plugins:[JV(X)],define:{"process.env.NODE_ENV":J?'"production"':'"development"',...H1()},root:q});if(!V.success){let A=V.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ");return console.warn("[stx:bundler] build failed:",A),$}let w="";for(let A of V.outputs){w=await A.text();break}return w=w.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),console.log("[stx:bundler] bundled:",K,"output:",w.length,"bytes"),a4.mkdirSync(Q,{recursive:!0}),await Bun.write(W,w),w}catch(V){return console.warn("[stx:bundler] error:",V instanceof Error?V.message:V),$}finally{try{a4.rmSync(B,{force:!0}),a4.rmSync(z,{recursive:!0,force:!0})}catch{}}}var FK;var b8=D(()=>{r4();FK=[/^stx$/,/^@stacksjs\/stx$/,/^@stacksjs\/browser$/,/^@stores$/,/^stx\/stores$/,/^@composables$/]});function UV($){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(!WV.has(X[1]))Z.add(X[1]);return Array.from(Z)}function _V($){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 GV){if(J.has(W))continue;if(new RegExp(`\\b${W}\\s*\\(`,"g").test(X))Z.add(W)}for(let W of KV){if(J.has(W))continue;if(new RegExp(`\\b${W}\\b`,"g").test(X))Y.add(W)}let K=UV(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 BV($,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
+ `}),$}import OK from"process";function H1($="STX_PUBLIC_"){let Z={},Y={};for(let[X,J]of Object.entries(OK.env)){if(!X.startsWith($)||J===void 0)continue;Z[`import.meta.env.${X}`]=JSON.stringify(J),Y[X]=J}return Z["import.meta.env"]=JSON.stringify(Y),Z}function LK($="STX_PUBLIC_"){let Z={};for(let[Y,X]of Object.entries(OK.env))if(Y.startsWith($)&&X!==void 0)Z[Y]=X;return Z}var r6=()=>{};var S8={};e(S8,{hasUserImports:()=>XV,bundleClientScript:()=>QV});import b1 from"path";import a6 from"fs";function XV($){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(!FK.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(!FK.some((W)=>W.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function JV($){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=b1.resolve($,Y.path.slice(2)),J=[X,`${X}.ts`,`${X}.js`,b1.join(X,"index.ts"),b1.join(X,"index.js")];for(let Q of J)if(a6.existsSync(Q)&&a6.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 QV($,Z,Y={}){let X=Y.projectRoot||process.cwd(),J=Y.minify??!1,Q=Y.cacheDir||b1.join(X,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),W=b1.join(Q,`${K}.js`),U=Bun.file(W);if(await U.exists())return console.log("[stx:bundler] cache hit:",K),await U.text();let _=b1.join(X,".stx","bundle-tmp"),B=b1.join(_,`${K}.ts`),z=b1.join(_,"out",K);a6.mkdirSync(_,{recursive:!0}),a6.mkdirSync(z,{recursive:!0});let q=b1.dirname(Z),j=[],H=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,O=/^(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 w=V.split(":")[0].trim();if(w)j.push(w)});else if(F[3])j.push(F[3])}while((F=O.exec($))!==null){if(F[1])continue;j.push(F[2])}let L=j.length>0?`
814
+ export { ${j.join(", ")} }`:"";await Bun.write(B,$+L),console.log("[stx:bundler] bundling:",K,"from:",b1.basename(Z));try{let V=await Bun.build({entrypoints:[B],outdir:z,target:"browser",format:"esm",minify:J,plugins:[JV(X)],define:{"process.env.NODE_ENV":J?'"production"':'"development"',...H1()},root:q});if(!V.success){let A=V.logs.filter((N)=>N.level==="error").map((N)=>N.message).join(", ");return console.warn("[stx:bundler] build failed:",A),$}let w="";for(let A of V.outputs){w=await A.text();break}return w=w.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),console.log("[stx:bundler] bundled:",K,"output:",w.length,"bytes"),a6.mkdirSync(Q,{recursive:!0}),await Bun.write(W,w),w}catch(V){return console.warn("[stx:bundler] error:",V instanceof Error?V.message:V),$}finally{try{a6.rmSync(B,{force:!0}),a6.rmSync(z,{recursive:!0,force:!0})}catch{}}}var FK;var b8=D(()=>{r6();FK=[/^stx$/,/^@stacksjs\/stx$/,/^@stacksjs\/browser$/,/^@stores$/,/^stx\/stores$/,/^@composables$/]});function UV($){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(!WV.has(X[1]))Z.add(X[1]);return Array.from(Z)}function _V($){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 GV){if(J.has(W))continue;if(new RegExp(`\\b${W}\\s*\\(`,"g").test(X))Z.add(W)}for(let W of KV){if(J.has(W))continue;if(new RegExp(`\\b${W}\\b`,"g").test(X))Y.add(W)}let K=UV(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 BV($,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 qV($){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=zV[$.mouse];Z.push(`if ($event.button !== ${Y}) return`)}if($.prevent)Z.push("$event.preventDefault()");if($.stop)Z.push("$event.stopPropagation()");return Z.join("; ")}function jV($,Z){let{elementId:Y,event:X,handler:J,modifiers:Q}=$,G=qV(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)=>jV(Y,X)).join(`
856
856
  `)}`}function VK($){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 LV($){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(!OV.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 s4($,Z={}){let Y=$,X="",J=!1,{hasUserImports:Q,bundleClientScript:G}=await Promise.resolve().then(() => (b8(),S8));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=_V(Y);Y=j.code,X=BV(j.stxImports,j.browserImports)}if(Y=B4(Y),!J&&z4(Z.attrs||""))Y=q4(Y);let K=HV(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 LV($){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(!OV.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 s6($,Z={}){let Y=$,X="",J=!1,{hasUserImports:Q,bundleClientScript:G}=await Promise.resolve().then(() => (b8(),S8));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=_V(Y);Y=j.code,X=BV(j.stxImports,j.browserImports)}if(Y=B6(Y),!J&&z6(Z.attrs||""))Y=q6(Y);let K=HV(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 V9($){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 FV,AK,wK,VV;var n0=D(()=>{FV={maxSanitizeDepth:10,allowBracketNotation:!1},AK={...FV},wK=[/\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/],VV=/[\w)\]]\s*\[\s*['"]/});function P8(){NK=0,A9.clear()}function s$($,Z){let Y=NK++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return A9.set(X,{type:$,expression:Z}),X}function y8(){let $={};for(let[Z,Y]of A9)$[Z]={type:Y.type,expression:Y.expression};return $}function NV($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=A9.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function w9($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function w6($){return $.includes("<!--__STX_")}var NK=0,A9;var o$=D(()=>{A9=new Map});var $5={};e($5,{usesSignalsInScript:()=>e$,unescapeHtml:()=>N9,registerFilters:()=>EK,registerFilter:()=>x8,processExpressions:()=>w1,interpolateScriptsInTemplate:()=>IK,interpolateScriptExpressions:()=>g8,getAllFilters:()=>v8,evaluateExpression:()=>_1,escapeHtml:()=>D0,defaultFilters:()=>N6,clearCustomFilters:()=>TK,applyFilters:()=>f8});function RV($){let Z=RK.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),RK.set($,Z)}return Z.lastIndex=0,Z}function x8($,Z){if($ in N6)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);t$[$]=Z}function EK($){for(let[Z,Y]of Object.entries($))x8(Z,Y)}function v8(){return{...N6,...t$}}function TK(){for(let $ of Object.keys(t$))delete t$[$]}function D0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function e$($){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 MK($,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 g8($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=_1(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=_1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function IK($,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=g8(Q,Z);return`<script${J}>${G}</script>`})}function w1($,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=e$($);X=X.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(K,W,U)=>{try{let _=_1(W,Z);return _!==void 0&&_!==null?String(_):""}catch(_){let B=_ instanceof Error?_.message:String(_);return L0("Expression",`Error evaluating: {{{ ${W.trim()}}}}: ${B}`,Y,$,U,K)}}),X=X.replace(/\{!!([\s\S]*?)!!\}/g,(K,W,U)=>{try{let _=_1(W,Z);if(_===void 0&&Z.__stx_buildMode==="compile")return s$("raw",W.trim());return _!==void 0&&_!==null?String(_):""}catch(_){if(Z.__stx_buildMode==="compile")return s$("raw",W.trim());let B=_ instanceof Error?_.message:String(_);return L0("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)),O=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,F=_.match(O),L=F&&!B.includes(F[1])&&!(F[1]in Z);if(/^__[A-Z_]+__$/.test(_))return"";try{let V=_1(W,Z);if(V===void 0&&G&&!MK(_,Z))return K;if(V===void 0&&Z.__stx_buildMode==="compile"&&!G)return s$("expr",_);return V!==void 0&&V!==null?D0(String(V)):""}catch(V){if(G&&!MK(_,Z))return K;if(L)return K;let w=V instanceof Error?V.message:String(V);return L0("Expression",`Error evaluating: {{ ${_} }}: ${w}`,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 f8($,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=t$[G]||N6[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(v8()).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=[_1(`(${B})`,Y,!0)];else{let z=[],q="",j=null,H=0,O=0,F=0,L=!1;for(let V=0;V<B.length;V++){let w=B[V];if(L){q+=w,L=!1;continue}if(w==="\\"){q+=w,L=!0;continue}if(j){if(q+=w,w===j)j=null;continue}if(w==='"'||w==="'"||w==="`"){j=w,q+=w;continue}if(w==="(")H++;else if(w===")")H--;else if(w==="[")O++;else if(w==="]")O--;else if(w==="{")F++;else if(w==="}")F--;if(w===","&&H===0&&O===0&&F===0){z.push(q),q="";continue}q+=w}if(q)z.push(q);W=z.map((V)=>{let w=V.trim();return _1(w,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 MV($){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 _1($,Z,Y=!1){try{let X=$.trim(),J=MV(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=_1(Q,Z,!0);return f8(K,G,Z)}if(!O0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return R0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return V0(X,Q)(...G)}catch{return R0(X,Z)}}catch(X){if(X instanceof ReferenceError){let J=/(\b\w+)\s+is not defined/.exec(X.message);if(J){let Q=J[1],G=EV(Q,Object.keys(Z));if(G&&G!==Q)X.message=`${X.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,X);throw X}}function EV($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=TV($,J);if(Y===null||Q<Y.dist)Y={key:J,dist:Q}}if(!Y)return null;let X=Math.max($.length,Y.key.length);if(Y.dist<=2||Y.dist/X<=0.35)return Y.key;return null}function TV($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[Y,X]=$.length<Z.length?[$,Z]:[Z,$],J=Array(Y.length+1),Q=Array(Y.length+1);for(let G=0;G<=Y.length;G++)J[G]=G;for(let G=1;G<=X.length;G++){Q[0]=G;for(let K=1;K<=Y.length;K++){let W=Y[K-1]===X[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,J[K]+1,J[K-1]+W)}for(let K=0;K<=Y.length;K++)J[K]=Q[K]}return J[Y.length]}function N9($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var t$,RK,N6;var r0=D(()=>{n0();H0();o$();t$={},RK=new Map;N6={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 D0(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(RV(W),String(U))}),K},t:($,Z,Y={})=>{return N6.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 Z5{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 M6($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!R6.has(Y)){if(R6.size>=IV){let X=R6.keys().next().value;if(X)R6.delete(X)}R6.set(Y,new RegExp($,Z))}return R6.get(Y)}class DK{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 V9($){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 FV,AK,wK,VV;var n0=D(()=>{FV={maxSanitizeDepth:10,allowBracketNotation:!1},AK={...FV},wK=[/\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/],VV=/[\w)\]]\s*\[\s*['"]/});function P8(){NK=0,A9.clear()}function s$($,Z){let Y=NK++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return A9.set(X,{type:$,expression:Z}),X}function y8(){let $={};for(let[Z,Y]of A9)$[Z]={type:Y.type,expression:Y.expression};return $}function NV($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=A9.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function w9($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function w4($){return $.includes("<!--__STX_")}var NK=0,A9;var o$=D(()=>{A9=new Map});var $5={};e($5,{usesSignalsInScript:()=>e$,unescapeHtml:()=>N9,registerFilters:()=>EK,registerFilter:()=>x8,processExpressions:()=>w1,interpolateScriptsInTemplate:()=>IK,interpolateScriptExpressions:()=>g8,getAllFilters:()=>v8,evaluateExpression:()=>_1,escapeHtml:()=>D0,defaultFilters:()=>N4,clearCustomFilters:()=>TK,applyFilters:()=>f8});function RV($){let Z=RK.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),RK.set($,Z)}return Z.lastIndex=0,Z}function x8($,Z){if($ in N4)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);t$[$]=Z}function EK($){for(let[Z,Y]of Object.entries($))x8(Z,Y)}function v8(){return{...N4,...t$}}function TK(){for(let $ of Object.keys(t$))delete t$[$]}function D0($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function e$($){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 MK($,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 g8($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=_1(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=_1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function IK($,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=g8(Q,Z);return`<script${J}>${G}</script>`})}function w1($,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=e$($);X=X.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(K,W,U)=>{try{let _=_1(W,Z);return _!==void 0&&_!==null?String(_):""}catch(_){let B=_ instanceof Error?_.message:String(_);return L0("Expression",`Error evaluating: {{{ ${W.trim()}}}}: ${B}`,Y,$,U,K)}}),X=X.replace(/\{!!([\s\S]*?)!!\}/g,(K,W,U)=>{try{let _=_1(W,Z);if(_===void 0&&Z.__stx_buildMode==="compile")return s$("raw",W.trim());return _!==void 0&&_!==null?String(_):""}catch(_){if(Z.__stx_buildMode==="compile")return s$("raw",W.trim());let B=_ instanceof Error?_.message:String(_);return L0("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)),O=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,F=_.match(O),L=F&&!B.includes(F[1])&&!(F[1]in Z);if(/^__[A-Z_]+__$/.test(_))return"";try{let V=_1(W,Z);if(V===void 0&&G&&!MK(_,Z))return K;if(V===void 0&&Z.__stx_buildMode==="compile"&&!G)return s$("expr",_);return V!==void 0&&V!==null?D0(String(V)):""}catch(V){if(G&&!MK(_,Z))return K;if(L)return K;let w=V instanceof Error?V.message:String(V);return L0("Expression",`Error evaluating: {{ ${_} }}: ${w}`,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 f8($,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=t$[G]||N4[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(v8()).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=[_1(`(${B})`,Y,!0)];else{let z=[],q="",j=null,H=0,O=0,F=0,L=!1;for(let V=0;V<B.length;V++){let w=B[V];if(L){q+=w,L=!1;continue}if(w==="\\"){q+=w,L=!0;continue}if(j){if(q+=w,w===j)j=null;continue}if(w==='"'||w==="'"||w==="`"){j=w,q+=w;continue}if(w==="(")H++;else if(w===")")H--;else if(w==="[")O++;else if(w==="]")O--;else if(w==="{")F++;else if(w==="}")F--;if(w===","&&H===0&&O===0&&F===0){z.push(q),q="";continue}q+=w}if(q)z.push(q);W=z.map((V)=>{let w=V.trim();return _1(w,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 MV($){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 _1($,Z,Y=!1){try{let X=$.trim(),J=MV(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=_1(Q,Z,!0);return f8(K,G,Z)}if(!O0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return R0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return V0(X,Q)(...G)}catch{return R0(X,Z)}}catch(X){if(X instanceof ReferenceError){let J=/(\b\w+)\s+is not defined/.exec(X.message);if(J){let Q=J[1],G=EV(Q,Object.keys(Z));if(G&&G!==Q)X.message=`${X.message} \u2014 did you mean '${G}'?`}}if(!Y)console.error(`Error evaluating expression: ${$}`,X);throw X}}function EV($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=TV($,J);if(Y===null||Q<Y.dist)Y={key:J,dist:Q}}if(!Y)return null;let X=Math.max($.length,Y.key.length);if(Y.dist<=2||Y.dist/X<=0.35)return Y.key;return null}function TV($,Z){if($===Z)return 0;if($.length===0)return Z.length;if(Z.length===0)return $.length;let[Y,X]=$.length<Z.length?[$,Z]:[Z,$],J=Array(Y.length+1),Q=Array(Y.length+1);for(let G=0;G<=Y.length;G++)J[G]=G;for(let G=1;G<=X.length;G++){Q[0]=G;for(let K=1;K<=Y.length;K++){let W=Y[K-1]===X[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,J[K]+1,J[K-1]+W)}for(let K=0;K<=Y.length;K++)J[K]=Q[K]}return J[Y.length]}function N9($){if(!$)return"";return $.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&#039;/g,"'").replace(/&#39;/g,"'").replace(/&amp;/g,"&")}var t$,RK,N4;var r0=D(()=>{n0();H0();o$();t$={},RK=new Map;N4={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 D0(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(RV(W),String(U))}),K},t:($,Z,Y={})=>{return N4.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 Z5{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 M4($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!R4.has(Y)){if(R4.size>=IV){let X=R4.keys().next().value;if(X)R4.delete(X)}R4.set(Y,new RegExp($,Z))}return R4.get(Y)}class DK{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 kK{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 DV(){if(!h8)h8=new kK;return h8}var R6,IV=500,GP,h8=null,N1;var j4=D(()=>{R6=new Map;GP=new DK;N1=new Proxy({},{get($,Z){return DV()[Z]}})});var R;var Y5=D(()=>{R={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 T9={};e(T9,{resetCssCache:()=>SV,resetCrosswindCache:()=>bV,rebuildCrosswindCSS:()=>J5,loadCrosswindConfig:()=>m8,loadCrosswind:()=>u8,injectCrosswindCSS:()=>E0,getCachedCSS:()=>CV,generateCrosswindCSS:()=>E9,extractClassNames:()=>M9,buildCrosswindCSS:()=>I6});import SK from"fs";import M0 from"path";async function bK($){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 kV(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==M0.dirname(Y))$.push(M0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(M0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(M0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),Y=M0.dirname(Y);if(Z){let X=[M0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),M0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),M0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),M0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),M0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),M0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(M0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(M0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function u8(){if(d8)return T6;d8=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await bK(Y);if(X)return T6=X,console.log(`${R.green}[Crosswind]${R.reset} CSS engine loaded`),T6}let Z=kV();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await bK(Y);if(X)return T6=X,console.log(`${R.green}[Crosswind]${R.reset} CSS engine loaded from ${M0.dirname(M0.dirname(Y))}`),T6}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${R.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${R.reset}`),console.warn(`${R.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${R.reset}`),null}}function SV(){R9.clear()}function bV(){T6=null,d8=!1,C1=null,X5="",R9.clear()}async function m8($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=M0.relative($,Y.path);return console.log(`${R.green}[Crosswind]${R.reset} Loaded config from ${X||Y.path}`),Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${R.yellow}[Crosswind]${R.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function I6($){if(E6)return X5;E6=!0;try{let Z=await u8();if(!Z||!Z.build)return E6=!1,"";if(!C1)C1=await m8($);if(!C1)return E6=!1,"";let Y=Z.defaultConfig?.theme||{},X=C1.theme||{},J={...Z.defaultConfig,...C1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(X5=G.css,console.log(`${R.cyan}[Crosswind]${R.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let W=M0.isAbsolute(J.output)?J.output:M0.join($,J.output),U=M0.dirname(W);if(!SK.existsSync(U))SK.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return E6=!1,G.css}catch(Z){return console.error(`${R.red}[Crosswind]${R.reset} Build error:`,Z),E6=!1,X5}}async function J5($){C1=null,await I6($)}function CV(){return X5}function M9($){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 E9($,Z){try{let Y=await u8();if(!Y)return"";let X=M9($);if(X.size===0)return"";let J=[...X].sort().join(" "),Q=R9.get(J);if(Q!==void 0)return Q;let G=Z?M0.resolve(Z):process.cwd();if(!C1){let V=null;try{let{loadStxConfig:w}=await Promise.resolve().then(() => (m0(),c8)),A=await w(G);if(A.css)if(typeof A.css==="string"){let N=M0.isAbsolute(A.css)?A.css:M0.resolve(G,A.css);if(await Bun.file(N).exists()){let M=await import(N);V=M.default||M,console.log(`${R.green}[Crosswind]${R.reset} Loaded config from stx.config.ts \u2192 ${A.css}`)}}else{if(V={content:A.css.content||[],preflight:A.css.preflight??!0,minify:A.css.minify??!1},A.css.config){let N=M0.isAbsolute(A.css.config)?A.css.config:M0.resolve(G,A.css.config);if(await Bun.file(N).exists()){let M=await import(N);V={...M.default||M,...V}}}console.log(`${R.green}[Crosswind]${R.reset} Using inline CSS config from stx.config.ts`)}}catch{}C1=V||await m8(G)}let K=Y.defaultConfig||Y.config,W=C1||{},U=K.theme||{},B=(W.theme||{}).extend||{},z={...U};if(Object.keys(B).length>0)z.extend=B;let q=[...K.safelist||[],...W.safelist||[]],j={...K,...W,content:[],output:"",preflight:!0,minify:!1,theme:z,safelist:q},H=new Y.CSSGenerator(j);for(let V of q)H.generate(V);for(let V of X)H.generate(V);let O=H.toCSS(!0,!1),F=j.shortcuts||W.shortcuts||{};for(let[V,w]of Object.entries(F)){if(!X.has(V)&&!q.includes(V))continue;let A=w.split(/\s+/).filter(Boolean);for(let N of A)H.generate(N)}O=H.toCSS(!0,!1);let L=O.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 kK{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 DV(){if(!h8)h8=new kK;return h8}var R4,IV=500,GP,h8=null,N1;var j6=D(()=>{R4=new Map;GP=new DK;N1=new Proxy({},{get($,Z){return DV()[Z]}})});var R;var Y5=D(()=>{R={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 T9={};e(T9,{resetCssCache:()=>SV,resetCrosswindCache:()=>bV,rebuildCrosswindCSS:()=>J5,loadCrosswindConfig:()=>m8,loadCrosswind:()=>u8,injectCrosswindCSS:()=>E0,getCachedCSS:()=>CV,generateCrosswindCSS:()=>E9,extractClassNames:()=>M9,buildCrosswindCSS:()=>I4});import SK from"fs";import M0 from"path";async function bK($){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 kV(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==M0.dirname(Y))$.push(M0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(M0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(M0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),Y=M0.dirname(Y);if(Z){let X=[M0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),M0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),M0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),M0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),M0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),M0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(M0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(M0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function u8(){if(d8)return T4;d8=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await bK(Y);if(X)return T4=X,console.log(`${R.green}[Crosswind]${R.reset} CSS engine loaded`),T4}let Z=kV();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await bK(Y);if(X)return T4=X,console.log(`${R.green}[Crosswind]${R.reset} CSS engine loaded from ${M0.dirname(M0.dirname(Y))}`),T4}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${R.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${R.reset}`),console.warn(`${R.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${R.reset}`),null}}function SV(){R9.clear()}function bV(){T4=null,d8=!1,C1=null,X5="",R9.clear()}async function m8($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=M0.relative($,Y.path);return console.log(`${R.green}[Crosswind]${R.reset} Loaded config from ${X||Y.path}`),Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${R.yellow}[Crosswind]${R.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function I4($){if(E4)return X5;E4=!0;try{let Z=await u8();if(!Z||!Z.build)return E4=!1,"";if(!C1)C1=await m8($);if(!C1)return E4=!1,"";let Y=Z.defaultConfig?.theme||{},X=C1.theme||{},J={...Z.defaultConfig,...C1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(X5=G.css,console.log(`${R.cyan}[Crosswind]${R.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let W=M0.isAbsolute(J.output)?J.output:M0.join($,J.output),U=M0.dirname(W);if(!SK.existsSync(U))SK.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return E4=!1,G.css}catch(Z){return console.error(`${R.red}[Crosswind]${R.reset} Build error:`,Z),E4=!1,X5}}async function J5($){C1=null,await I4($)}function CV(){return X5}function M9($){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 E9($,Z){try{let Y=await u8();if(!Y)return"";let X=M9($);if(X.size===0)return"";let J=[...X].sort().join(" "),Q=R9.get(J);if(Q!==void 0)return Q;let G=Z?M0.resolve(Z):process.cwd();if(!C1){let V=null;try{let{loadStxConfig:w}=await Promise.resolve().then(() => (m0(),c8)),A=await w(G);if(A.css)if(typeof A.css==="string"){let N=M0.isAbsolute(A.css)?A.css:M0.resolve(G,A.css);if(await Bun.file(N).exists()){let M=await import(N);V=M.default||M,console.log(`${R.green}[Crosswind]${R.reset} Loaded config from stx.config.ts \u2192 ${A.css}`)}}else{if(V={content:A.css.content||[],preflight:A.css.preflight??!0,minify:A.css.minify??!1},A.css.config){let N=M0.isAbsolute(A.css.config)?A.css.config:M0.resolve(G,A.css.config);if(await Bun.file(N).exists()){let M=await import(N);V={...M.default||M,...V}}}console.log(`${R.green}[Crosswind]${R.reset} Using inline CSS config from stx.config.ts`)}}catch{}C1=V||await m8(G)}let K=Y.defaultConfig||Y.config,W=C1||{},U=K.theme||{},B=(W.theme||{}).extend||{},z={...U};if(Object.keys(B).length>0)z.extend=B;let q=[...K.safelist||[],...W.safelist||[]],j={...K,...W,content:[],output:"",preflight:!0,minify:!1,theme:z,safelist:q},H=new Y.CSSGenerator(j);for(let V of q)H.generate(V);for(let V of X)H.generate(V);let O=H.toCSS(!0,!1),F=j.shortcuts||W.shortcuts||{};for(let[V,w]of Object.entries(F)){if(!X.has(V)&&!q.includes(V))continue;let A=w.split(/\s+/).filter(Boolean);for(let N of A)H.generate(N)}O=H.toCSS(!0,!1);let L=O.split(`
905
905
  `);for(let[V,w]of Object.entries(F)){if(!X.has(V)&&!q.includes(V))continue;let A=w.split(/\s+/).filter(Boolean),N=[],M=[];for(let E of A){let I=E.startsWith("dark:"),k=`.${(I?E.slice(5):E).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<L.length;b++){let y=L[b].trim();if(y===`${k} {`||y.startsWith(`${k} {`)){let v=b,C="";while(v<L.length){if(C+=L[v],L[v].includes("}"))break;v++}let f=C.match(/\{([^}]+)\}/);if(f)if(I)M.push(f[1].trim());else N.push(f[1].trim());break}}}if(N.length)O+=`
906
906
  .${V} { ${N.join(" ")} }`;if(M.length)O+=`
907
907
  @media (prefers-color-scheme: dark) { .dark .${V} { ${M.join(" ")} } }`}return R9.set(J,O),O}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function E0($,Z){if($.includes('data-crosswind="generated"'))return $;let Y=await E9($,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 T6=null,d8=!1,C1=null,X5="",E6=!1,R9;var P1=D(()=>{Y5();R9=new Map});function CK(){return`
911
+ ${X}`);return X+$}var T4=null,d8=!1,C1=null,X5="",E4=!1,R9;var P1=D(()=>{Y5();R9=new Map});function CK(){return`
912
912
  // STX Lifecycle Runtime
913
913
  (function() {
914
914
  if (typeof window === 'undefined') return;
@@ -1739,7 +1739,7 @@ ${tV()}
1739
1739
  ${Z}
1740
1740
  </script>`}function iK($,Z,Y){if(pK=0,!ZA($))return $;let X=rV($);if(X.length===0)return $;let J=$A($,X),Q=eV(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 $A($,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*["']${I9(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*["']${I9(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*"${I9(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*'${I9(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 ZA($){return/x-data\s*=\s*["']/.test($)}var pK=0,nV=0;function s1($,Z){try{let Y=$.trim();if(O0(Y))return V0(Y,Object.keys(Z))(...Object.values(Z));else return R0(Y,Z)}catch{return!1}}var t8=D(()=>{n0()});function rK($){nK=$}function aK(){return nK}function sK($){D9={...D9,...$}}function oK(){D9={}}function e8($,Z={}){let Y=D9[$]||YA[$]||{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 tK($,Z={}){let{message:Y,help:X}=e8($,Z);return X?`${Y}
1742
- Help: ${X}`:Y}function k9($){for(let[Z,Y]of Object.entries(Z0))if(Y===$)return Z;return}var YA,D9,nK="en",Z0;var S9=D(()=>{YA={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"}},D9={};Z0={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 eK(){return!1}function H4(){return!eK()||process.env.STX_DEBUG==="true"}function XA(){return!1}import JA from"path";function ZW($){D6={...D6,...$}}function Q5(){return{...D6}}function YW(){D6={...$W}}function G5($){if(!D6.showRelativePaths||!$)return $;let Z=D6.baseDir||process.cwd();try{let Y=JA.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var $W,D6,O4,$Z,R1,ZZ,k6,K5;var b9=D(()=>{S9();$W={showRelativePaths:!1,enableAutoRecovery:H4(),logRecoveryWarnings:!0},D6={...$W};O4=class O4 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||Z0.EVALUATION_ERROR,this.filePath)this.filePath=G5(this.filePath)}};$Z=class $Z extends O4{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||Z0.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};R1=class R1 extends O4{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||Z0.EVALUATION_ERROR);this.name="StxRuntimeError"}};ZZ=class ZZ extends O4{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||Z0.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};k6=class k6 extends O4{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||Z0.FILE_NOT_FOUND);this.name="StxFileError"}};K5=class K5 extends O4{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||Z0.DOM_API_VIOLATION);this.name="StxValidationError"}}});function C9($){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 L=JW(K,W);z=L.line,q=L.column}let j=J?G5(J):void 0,H=X?k9(X):void 0,O={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=GA(O);break;case"json":F=JSON.stringify(O,null,2);break;case"console":F=KA(O,K,W);break;case"text":default:F=QA(O,K,W);break}return{formatted:F,data:O}}function QA($,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 k9($){for(let[Z,Y]of Object.entries(Z0))if(Y===$)return Z;return}var YA,D9,nK="en",Z0;var S9=D(()=>{YA={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"}},D9={};Z0={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 eK(){return!1}function H6(){return!eK()||process.env.STX_DEBUG==="true"}function XA(){return!1}import JA from"path";function ZW($){D4={...D4,...$}}function Q5(){return{...D4}}function YW(){D4={...$W}}function G5($){if(!D4.showRelativePaths||!$)return $;let Z=D4.baseDir||process.cwd();try{let Y=JA.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var $W,D4,O6,$Z,R1,ZZ,k4,K5;var b9=D(()=>{S9();$W={showRelativePaths:!1,enableAutoRecovery:H6(),logRecoveryWarnings:!0},D4={...$W};O6=class O6 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||Z0.EVALUATION_ERROR,this.filePath)this.filePath=G5(this.filePath)}};$Z=class $Z extends O6{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||Z0.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};R1=class R1 extends O6{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||Z0.EVALUATION_ERROR);this.name="StxRuntimeError"}};ZZ=class ZZ extends O6{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||Z0.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};k4=class k4 extends O6{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||Z0.FILE_NOT_FOUND);this.name="StxFileError"}};K5=class K5 extends O6{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||Z0.DOM_API_VIOLATION);this.name="StxValidationError"}}});function C9($){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 L=JW(K,W);z=L.line,q=L.column}let j=J?G5(J):void 0,H=X?k9(X):void 0,O={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=GA(O);break;case"json":F=JSON.stringify(O,null,2);break;case"console":F=KA(O,K,W);break;case"text":default:F=QA(O,K,W);break}return{formatted:F,data:O}}function QA($,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=WA(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 P9,a0,S6;var UW=D(()=>{b9();P9={isEnabled(){return Q5().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=Q5();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 -->"}};a0=new y9,S6={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 P9,a0,S4;var UW=D(()=>{b9();P9={isEnabled(){return Q5().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=Q5();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 -->"}};a0=new y9,S4={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 YZ from"path";function _A($){let Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function W5($,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=_A(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 _W($,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(!x9.isValidFilePath(Y,Z))return null;return Y}function BW($){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 zW($,Z={}){return $.map((Y)=>W5(Y,Z))}function XZ($){let Z={};for(let[Y,X]of Object.entries($)){if(!x9.isValidVariableName(Y))continue;if(typeof X==="string"){let J=W5(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?W5(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=XZ(X);else Z[Y]=X}return Z}var x9;var qW=D(()=>{x9={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=YZ.resolve(Z,$),Q=YZ.resolve(Z);if(!J.startsWith(Q+YZ.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 jW=D(()=>{S9();WW();UW();qW();b9()});var z1=D(()=>{jW()});class U5{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 JZ($,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 v9($){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 o1($,Z){let Y=BA($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function BA($,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 L4($,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 QZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=o1($,X);if(!J)return null;let Q=J.endPos,G=L4($,"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 O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=o1(K,F);if(!L){U++;continue}_="elseif",B=L.expression,U=L.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 g9($){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=QZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function _5($,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=L4($,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 f9($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=o1($,X);if(!J)return null;let Q=J.endPos,G=L4($,"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*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,V=o1(K,L);if(!V){U++;continue}_={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[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 HW=()=>{};function FW($){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,_=zA($,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 zA($,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 VW($){let Z=v9($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=qA(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function qA($){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=GZ(G);return{name:X,args:K}}function GZ($){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 AW($,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 wW($){let Z=[],X=new U5($).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=OW(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=LW(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=OW(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let 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=LW(X,z+1)}}}else J++}return Z}function OW($,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 LW($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var NW=()=>{};var h9=D(()=>{HW();NW()});function jA($,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=f9(X,G);if(!K)break;try{let W;if(O0(K.expression))W=V0(K.expression,Object.keys(Z))(...Object.values(Z));else W=R0(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&&O0(B.value))z=V0(B.value,Object.keys(Z))(...Object.values(Z));else if(B.value)z=R0(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),_=K0("Switch",`Error evaluating @switch expression: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function b6($,Z,Y){let X=$;X=jA(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=o1(X,K+7);if(!W)break;let U=W.endPos,_=L4(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,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],w;while((w=O.exec(B))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(B))!==null)V.push({pos:w.index,type:"close"});while((w=L.exec(B))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.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),O=B.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${B}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=WZ(X,Z,Y),X=UZ(X,Z,Y),X=KZ(X,Z);let J=()=>{let Q=g9(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&&O0(_.condition))B=V0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)B=R0(_.condition,Z);if(B)W=_.content,U=!0}catch(B){W=K0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${B instanceof Error?B.message:String(B)}`,Z0.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),_=K0("If",`Error processing @if block: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(J());return X}function RW($){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 KZ($,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),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)B++,z=F+H[0].length;else if(L<1/0){if(B--,B===0)return L;z=L+O[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((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+5),q=RW(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),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=_?s1(`auth?.check && auth?.user?.[${_}]`,Z):s1("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),w=H.slice(O+5);L=F?V:w}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+6),q=RW(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),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=_?s1(`!auth?.check || !auth?.user?.[${_}]`,Z):s1("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),w=H.slice(O+5);L=F?V:w}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let 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,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),N=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,E=[],I;while((I=w.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=N.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((v,C)=>v.pos-C.pos);for(let v of E){if(v.type==="open"){V++;continue}if(v.type==="close"){V--;continue}if(V===0)L.push(v)}let T=[],S=0;for(let v=0;v<L.length;v++){let C=L[v];if(T.push({content:F.slice(S,C.pos),ability:void 0}),C.type==="elseDirective"){let f=F.slice(C.pos+`@${U}`.length),h=G(f);if(h){T[T.length-1]={content:F.slice(S,C.pos)},S=C.pos+`@${U}`.length+h.paramsEnd,T.push({content:"",ability:h.ability,type:h.type,id:h.id}),T.pop();let d=L[v+1],i=d?d.pos:F.length;T.push({content:F.slice(S,i),ability:h.ability,type:h.type,id:h.id}),S=i}}else S=C.pos+5}if(S<F.length){let v=T[T.length-1];if(L.length>0&&L[L.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),b=K==="can"?k:!k,y="";if(b)y=T[0]?.content||"";else{let v=!1;for(let C=1;C<T.length;C++){let f=T[C];if(f.isFinalElse){y=f.content,v=!0;break}if(f.ability){let h=Q(f.ability,f.type,f.id);if(K==="can"?h:!h){y=f.content,v=!0;break}}}if(!v&&T.length>0){let C=T[T.length-1];if(C.isFinalElse)y=C.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),_=!0}}return Y}function WZ($,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=o1(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=L4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,w=0,A=0;while(A<F.length){let N=F.indexOf("@",A);if(N===-1)break;let M=F.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(M)){V=N;break}A=N+1}try{let N=W(L.trim()),M;if(V!==-1){let E=F.slice(0,V),I=F.slice(V+5);M=N?E:I}else M=N?F:"";Q=Q.substring(0,q)+M+Q.substring(O+`@${K}`.length),_=!0}catch(N){let M=N instanceof Error?N.message:String(N),E=K0(U,`Error processing @${G} directive: ${M}`,Z0.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(O+`@${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 UZ($,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 O=_.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,w=L,A=-1;while(V>0&&w<j.length){_.lastIndex=w,B.lastIndex=w;let k=_.exec(j),b=B.exec(j),y=k?k.index:1/0,v=b?b.index:1/0;if(y<v)V++,w=y+k[0].length;else if(v<1/0){if(V--,V===0){A=v;break}w=v+b[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 N=j.substring(L,A),M=-1,E=0,I=0;while(I<N.length){let k=N.indexOf("@",I);if(k===-1)break;let b=N.substring(k);if(z.test(b)){E++,I=k+1;continue}if(q.test(b)){E--,I=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(b)){M=k;break}I=k+1}let T;if(M!==-1){let k=N.slice(0,M),b=N.slice(M+5);T=U?k:b}else T=U?N:"";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 d9=D(()=>{t8();z1();h9();n0()});function BZ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function F4($,Z){if(!$)return Z?.nonceGenerator?.()??BZ();let Y=_Z.get($);if(!Y)Y=Z?.nonceGenerator?.()??BZ(),_Z.set($,Y);return Y}function HA($){_Z.delete($)}function zZ($,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 m9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${zZ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function OA($){return{enabled:!0,directives:{strict:MW,moderate:u9,relaxed:EW,api:TW}[$]||u9,useNonce:$==="strict",addMetaTag:!0}}function LA($,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 qZ($,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=m9(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1777
- ${J}`)}function FA($,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 jZ($,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 m9(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 VA(){return[IW,DW]}function AA($){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 kW($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function wA($,Z){if(!$.enabled)return{};let Y=$.useNonce?F4(Z,$):void 0,X=zZ($.directives,Y);return{[kW($.reportOnly)]:X}}var _Z,MW,u9,EW,TW,IW,DW,NA;var HZ=D(()=>{_Z=new WeakMap;MW={"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},u9={"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},EW={"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'"]},TW={"default-src":["'none'"],"frame-ancestors":["'none'"]};IW={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 m9(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},DW={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"};NA={enabled:!1,reportOnly:!1,directives:u9,useNonce:!1,addMetaTag:!0}});import RA from"crypto";function EA($=MA){let Z=RA.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return OZ=Z,Z}function TA(){if(!OZ)EA();return OZ}function IA($=SW){let Z=TA();return`<input type="hidden" name="${$}" value="${Z}">`}function bW($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return IA(X||SW)})}var MA=40,SW="_token",OZ=null;var CW=()=>{};async function LZ($,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 DA(J,Q,Z,Y,X);else J=await kA(J,Q,Z,Y,X)}return J}async function DA($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=M6(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),B=[],z=_.exec(U);while(z!==null){let[q,j="",H=""]=z,O=z.index||0;try{let F=j?PW(j):[],L=H.trim(),V=await G(L,F,Y,X);B.push({original:q,processed:V,startIndex:O})}catch(F){let L=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);B.push({original:q,processed:K0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,Z0.EVALUATION_ERROR),startIndex:O})}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 kA($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=M6(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let O=PW(j),F=await G("",O,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(O){let F=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:K0("CustomDirective",`Error in @${Q}(${j}): ${F}`,Z0.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let B=M6(`@${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 O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:K0("CustomDirective",`Error in @${Q}: ${O}`,Z0.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 PW($){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 FZ=D(()=>{z1();j4()});var p9={};e(p9,{useTitle:()=>vW,useSeoMeta:()=>B5,usePageTitle:()=>vW,useHead:()=>A4,resetHead:()=>yW,renderHtmlAttrs:()=>fW,renderHead:()=>gW,renderBodyAttrs:()=>hW,processTitleDirective:()=>mW,processMetaDirective:()=>cW,processHeadDirective:()=>uW,getPageMeta:()=>l9,getHead:()=>C6,definePageMeta:()=>xW,applyHead:()=>dW});function C6(){return V4}function l9(){return c9}function yW(){V4={},SA.length=0,c9={}}function A4($){V4=bA(V4,$)}function bA($,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 B5($){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 xW($){if(c9={...c9,...$},$.title||$.description)B5({title:$.title,description:$.description})}function vW($){let Z=typeof $==="function"?$():$;A4({title:Z})}function gW($=V4){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${o4(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${o4(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}="${o4(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}="${o4(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}="${o4(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 fW($=V4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${o4(Y)}"`).join(" ")}function hW($=V4){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${o4(Y)}"`).join(" ")}function o4($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function dW($=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 uW($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
1779
- `,""}),headContent:Z.trim()}}function mW($,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 cW($,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,SA,c9;var w4=D(()=>{V4={},SA=[],c9={}});import CA from"crypto";function c0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function PA($){return{...n9,...$.forms?.classes}}function i9($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function yA(){return CA.randomUUID()}function xA($,Z,Y,X){let J=PA(X),Q=$;return Q=nW(Q,Z),Q=P6(Q,Z),Q=r9(Q,Z,J),Q=a9(Q,Z,J),Q}function P6($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=yA();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 r9($,Z,Y=n9){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=N4(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${c0(j)}" action="${c0(B)}"${z?` ${z}`:""}>`;if(H+=`
1780
- ${P6("@csrf",Z)}`,!["GET","POST"].includes(q))H+=`
1781
- ${P6(`@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=N4(U),q=z5(_,Z),j=q!==void 0&&q!==null?q:B||"",H=z.match(/type=['"]([^'"]+)['"]/i),O=H?H[1]:"text",F=q5(_,Z),L=z.match(/class=['"]([^'"]+)['"]/i),V=i9(L?L[1]:"",Y.input,F,Y.inputError),w=z.replace(/class=['"][^'"]+['"]/i,"");return w=w.replace(/type=['"][^'"]+['"]/i,""),`<input type="${c0(O)}" name="${c0(_)}" value="${c0(j)}" class="${V}"${w?` ${w}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let W=N4(G),U=z5(Q,Z)||K.trim(),_=q5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=i9(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=N4(G),U=z5(Q,Z),_=q5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=i9(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,O,F)=>{if((Array.isArray(U)?U.some((V)=>String(V)===F):String(U)===F)&&!O.includes("selected"))return O.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=N4(K),U=z5(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=N4(K),U=z5(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=N4(G),W=K.match(/accept=['"]([^'"]+)['"]/i),U=W?W[1]:"",_=K.includes("multiple"),B=q5(Q,Z),z=K.match(/class=['"]([^'"]+)['"]/i),q=i9(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=N4(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 a9($,Z,Y=n9){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(q5(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return lW(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 lW(J,Z)}let W=K.trim();if(O0(W)){let U=R0(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 q5($,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 lW($,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 z5($,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 N4($){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 vA($,Z){pW[$]=Z}function VZ($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function iW($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=VZ(G),W=pW[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=iW(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function nW($,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=VZ(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 fA($){AZ[$.name]=$}function rW($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=VZ(Q),K=AZ[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 hA($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=rW($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function dA($,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 JZ($,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 v9($){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 o1($,Z){let Y=BA($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function BA($,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 L6($,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 QZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=o1($,X);if(!J)return null;let Q=J.endPos,G=L6($,"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 O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:B,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=o1(K,F);if(!L){U++;continue}_="elseif",B=L.expression,U=L.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 g9($){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=QZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function _5($,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=L6($,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 f9($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=o1($,X);if(!J)return null;let Q=J.endPos,G=L6($,"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*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,V=o1(K,L);if(!V){U++;continue}_={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[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 HW=()=>{};function FW($){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,_=zA($,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 zA($,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 VW($){let Z=v9($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=qA(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function qA($){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=GZ(G);return{name:X,args:K}}function GZ($){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 AW($,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 wW($){let Z=[],X=new U5($).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=OW(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=LW(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=OW(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let 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=LW(X,z+1)}}}else J++}return Z}function OW($,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 LW($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var NW=()=>{};var h9=D(()=>{HW();NW()});function jA($,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=f9(X,G);if(!K)break;try{let W;if(O0(K.expression))W=V0(K.expression,Object.keys(Z))(...Object.values(Z));else W=R0(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&&O0(B.value))z=V0(B.value,Object.keys(Z))(...Object.values(Z));else if(B.value)z=R0(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),_=K0("Switch",`Error evaluating @switch expression: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function b4($,Z,Y){let X=$;X=jA(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=o1(X,K+7);if(!W)break;let U=W.endPos,_=L6(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,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],w;while((w=O.exec(B))!==null)V.push({pos:w.index,type:"open"});while((w=F.exec(B))!==null)V.push({pos:w.index,type:"close"});while((w=L.exec(B))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.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),O=B.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${B}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=WZ(X,Z,Y),X=UZ(X,Z,Y),X=KZ(X,Z);let J=()=>{let Q=g9(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&&O0(_.condition))B=V0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)B=R0(_.condition,Z);if(B)W=_.content,U=!0}catch(B){W=K0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${B instanceof Error?B.message:String(B)}`,Z0.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),_=K0("If",`Error processing @if block: ${U}`,Z0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(J());return X}function RW($){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 KZ($,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),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)B++,z=F+H[0].length;else if(L<1/0){if(B--,B===0)return L;z=L+O[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((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+5),q=RW(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),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=_?s1(`auth?.check && auth?.user?.[${_}]`,Z):s1("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),w=H.slice(O+5);L=F?V:w}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,B,z=Y.slice(U+6),q=RW(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),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=_?s1(`!auth?.check || !auth?.user?.[${_}]`,Z):s1("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),w=H.slice(O+5);L=F?V:w}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let 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,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),N=new RegExp(`@${U}\\s*\\(`,"g"),M=/@else(?![a-z])/g,E=[],I;while((I=w.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=N.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((v,C)=>v.pos-C.pos);for(let v of E){if(v.type==="open"){V++;continue}if(v.type==="close"){V--;continue}if(V===0)L.push(v)}let T=[],S=0;for(let v=0;v<L.length;v++){let C=L[v];if(T.push({content:F.slice(S,C.pos),ability:void 0}),C.type==="elseDirective"){let f=F.slice(C.pos+`@${U}`.length),h=G(f);if(h){T[T.length-1]={content:F.slice(S,C.pos)},S=C.pos+`@${U}`.length+h.paramsEnd,T.push({content:"",ability:h.ability,type:h.type,id:h.id}),T.pop();let d=L[v+1],i=d?d.pos:F.length;T.push({content:F.slice(S,i),ability:h.ability,type:h.type,id:h.id}),S=i}}else S=C.pos+5}if(S<F.length){let v=T[T.length-1];if(L.length>0&&L[L.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),b=K==="can"?k:!k,y="";if(b)y=T[0]?.content||"";else{let v=!1;for(let C=1;C<T.length;C++){let f=T[C];if(f.isFinalElse){y=f.content,v=!0;break}if(f.ability){let h=Q(f.ability,f.type,f.id);if(K==="can"?h:!h){y=f.content,v=!0;break}}}if(!v&&T.length>0){let C=T[T.length-1];if(C.isFinalElse)y=C.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),_=!0}}return Y}function WZ($,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=o1(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=L6(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,w=0,A=0;while(A<F.length){let N=F.indexOf("@",A);if(N===-1)break;let M=F.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(M)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(M)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(M)){V=N;break}A=N+1}try{let N=W(L.trim()),M;if(V!==-1){let E=F.slice(0,V),I=F.slice(V+5);M=N?E:I}else M=N?F:"";Q=Q.substring(0,q)+M+Q.substring(O+`@${K}`.length),_=!0}catch(N){let M=N instanceof Error?N.message:String(N),E=K0(U,`Error processing @${G} directive: ${M}`,Z0.EVALUATION_ERROR);Q=Q.substring(0,q)+E+Q.substring(O+`@${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 UZ($,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 O=_.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,w=L,A=-1;while(V>0&&w<j.length){_.lastIndex=w,B.lastIndex=w;let k=_.exec(j),b=B.exec(j),y=k?k.index:1/0,v=b?b.index:1/0;if(y<v)V++,w=y+k[0].length;else if(v<1/0){if(V--,V===0){A=v;break}w=v+b[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 N=j.substring(L,A),M=-1,E=0,I=0;while(I<N.length){let k=N.indexOf("@",I);if(k===-1)break;let b=N.substring(k);if(z.test(b)){E++,I=k+1;continue}if(q.test(b)){E--,I=k+1;continue}if(E===0&&/^@else(?![a-z])/.test(b)){M=k;break}I=k+1}let T;if(M!==-1){let k=N.slice(0,M),b=N.slice(M+5);T=U?k:b}else T=U?N:"";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 d9=D(()=>{t8();z1();h9();n0()});function BZ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function F6($,Z){if(!$)return Z?.nonceGenerator?.()??BZ();let Y=_Z.get($);if(!Y)Y=Z?.nonceGenerator?.()??BZ(),_Z.set($,Y);return Y}function HA($){_Z.delete($)}function zZ($,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 m9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${zZ($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function OA($){return{enabled:!0,directives:{strict:MW,moderate:u9,relaxed:EW,api:TW}[$]||u9,useNonce:$==="strict",addMetaTag:!0}}function LA($,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 qZ($,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=m9(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1777
+ ${J}`)}function FA($,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 jZ($,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 m9(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 VA(){return[IW,DW]}function AA($){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 kW($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function wA($,Z){if(!$.enabled)return{};let Y=$.useNonce?F6(Z,$):void 0,X=zZ($.directives,Y);return{[kW($.reportOnly)]:X}}var _Z,MW,u9,EW,TW,IW,DW,NA;var HZ=D(()=>{_Z=new WeakMap;MW={"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},u9={"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},EW={"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'"]},TW={"default-src":["'none'"],"frame-ancestors":["'none'"]};IW={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 m9(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},DW={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"};NA={enabled:!1,reportOnly:!1,directives:u9,useNonce:!1,addMetaTag:!0}});import RA from"crypto";function EA($=MA){let Z=RA.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return OZ=Z,Z}function TA(){if(!OZ)EA();return OZ}function IA($=SW){let Z=TA();return`<input type="hidden" name="${$}" value="${Z}">`}function bW($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return IA(X||SW)})}var MA=40,SW="_token",OZ=null;var CW=()=>{};async function LZ($,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 DA(J,Q,Z,Y,X);else J=await kA(J,Q,Z,Y,X)}return J}async function DA($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=M4(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),B=[],z=_.exec(U);while(z!==null){let[q,j="",H=""]=z,O=z.index||0;try{let F=j?PW(j):[],L=H.trim(),V=await G(L,F,Y,X);B.push({original:q,processed:V,startIndex:O})}catch(F){let L=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);B.push({original:q,processed:K0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,Z0.EVALUATION_ERROR),startIndex:O})}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 kA($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=M4(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let O=PW(j),F=await G("",O,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(O){let F=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:K0("CustomDirective",`Error in @${Q}(${j}): ${F}`,Z0.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let B=M4(`@${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 O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:K0("CustomDirective",`Error in @${Q}: ${O}`,Z0.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 PW($){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 FZ=D(()=>{z1();j6()});var p9={};e(p9,{useTitle:()=>vW,useSeoMeta:()=>B5,usePageTitle:()=>vW,useHead:()=>A6,resetHead:()=>yW,renderHtmlAttrs:()=>fW,renderHead:()=>gW,renderBodyAttrs:()=>hW,processTitleDirective:()=>mW,processMetaDirective:()=>cW,processHeadDirective:()=>uW,getPageMeta:()=>l9,getHead:()=>C4,definePageMeta:()=>xW,applyHead:()=>dW});function C4(){return V6}function l9(){return c9}function yW(){V6={},SA.length=0,c9={}}function A6($){V6=bA(V6,$)}function bA($,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 B5($){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 xW($){if(c9={...c9,...$},$.title||$.description)B5({title:$.title,description:$.description})}function vW($){let Z=typeof $==="function"?$():$;A6({title:Z})}function gW($=V6){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${o6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${o6(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}="${o6(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}="${o6(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}="${o6(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 fW($=V6){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${o6(Y)}"`).join(" ")}function hW($=V6){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${o6(Y)}"`).join(" ")}function o6($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function dW($=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 uW($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
1779
+ `,""}),headContent:Z.trim()}}function mW($,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 cW($,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,SA,c9;var w6=D(()=>{V6={},SA=[],c9={}});import CA from"crypto";function c0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function PA($){return{...n9,...$.forms?.classes}}function i9($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function yA(){return CA.randomUUID()}function xA($,Z,Y,X){let J=PA(X),Q=$;return Q=nW(Q,Z),Q=P4(Q,Z),Q=r9(Q,Z,J),Q=a9(Q,Z,J),Q}function P4($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=yA();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 r9($,Z,Y=n9){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=N6(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${c0(j)}" action="${c0(B)}"${z?` ${z}`:""}>`;if(H+=`
1780
+ ${P4("@csrf",Z)}`,!["GET","POST"].includes(q))H+=`
1781
+ ${P4(`@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=N6(U),q=z5(_,Z),j=q!==void 0&&q!==null?q:B||"",H=z.match(/type=['"]([^'"]+)['"]/i),O=H?H[1]:"text",F=q5(_,Z),L=z.match(/class=['"]([^'"]+)['"]/i),V=i9(L?L[1]:"",Y.input,F,Y.inputError),w=z.replace(/class=['"][^'"]+['"]/i,"");return w=w.replace(/type=['"][^'"]+['"]/i,""),`<input type="${c0(O)}" name="${c0(_)}" value="${c0(j)}" class="${V}"${w?` ${w}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let W=N6(G),U=z5(Q,Z)||K.trim(),_=q5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=i9(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=N6(G),U=z5(Q,Z),_=q5(Q,Z),B=W.match(/class=['"]([^'"]+)['"]/i),z=i9(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,O,F)=>{if((Array.isArray(U)?U.some((V)=>String(V)===F):String(U)===F)&&!O.includes("selected"))return O.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=N6(K),U=z5(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=N6(K),U=z5(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=N6(G),W=K.match(/accept=['"]([^'"]+)['"]/i),U=W?W[1]:"",_=K.includes("multiple"),B=q5(Q,Z),z=K.match(/class=['"]([^'"]+)['"]/i),q=i9(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=N6(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 a9($,Z,Y=n9){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(q5(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return lW(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 lW(J,Z)}let W=K.trim();if(O0(W)){let U=R0(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 q5($,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 lW($,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 z5($,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 N6($){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 vA($,Z){pW[$]=Z}function VZ($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function iW($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=VZ(G),W=pW[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=iW(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function nW($,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=VZ(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 fA($){AZ[$.name]=$}function rW($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=VZ(Q),K=AZ[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 hA($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=rW($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function dA($,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]=eA(z)}}return Z}function eA($){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 $w($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"json":default:return".json"}}function Zw($,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 YU($,Z={}){return XU($,Z)}function XU($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=Yw($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=Xw(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 Yw($,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 Xw($,Z){let Y=Jw($);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 Qw(J,Y.slice(2).join(","),Z);case"select":return Kw(J,Y.slice(2).join(","));case"selectordinal":return Ww(J,Y.slice(2).join(","));case"number":return _w(J,Y[2]?.trim());case"date":return Bw(J,Y[2]?.trim());case"time":return zw(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function Jw($){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 Qw($,Z,Y){let X=Number($)||0,J=RZ(Z),Q=`=${X}`;if(J[Q])return NZ(J[Q],X,Y);let G=Gw(X);if(J[G])return NZ(J[G],X,Y);if(J.other)return NZ(J.other,X,Y);return String(X)}function NZ($,Z,Y){let X=$.replace(/#/g,String(Z));return XU(X,Y)}function Gw($){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 Kw($,Z){let Y=String($||""),X=RZ(Z);if(X[Y])return X[Y];return X.other||String($)}function Ww($,Z){let Y=Number($)||0,X=RZ(Z),J=Uw(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 Uw($){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 RZ($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function _w($,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 Bw($,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 zw($,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 JU($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function s9($,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(JU(G))return YU(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),W=G.split("|");G=Zw(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 MZ($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...o9,...X.i18n},K=await ZU(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await sW(J,Q,async(_,B,z,q,j)=>{try{let H={};if(z)try{let F=[()=>JSON.parse(z),()=>{let L=`{"data":${z}}`,V=JSON.parse(L);return typeof V.data==="object"?V.data:{}},()=>{return x0(z,Z)}];for(let L of F)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(F){if(X.debug)console.error("Error parsing parameters for @translate directive:",F)}return s9(B,K,G.fallbackToKey,H)||q.trim()}catch(H){if(X.debug)console.error("Error processing @translate directive:",H);return K0("Translate",`Error in @translate('${B}'): ${H instanceof Error?H.message:String(H)}`,Z0.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 sW(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(_,B,z,q)=>{try{let j={};if(z)try{let H=[()=>JSON.parse(z),()=>{let O=`{"data":${z}}`,F=JSON.parse(O);return typeof F.data==="object"?F.data:{}},()=>{return x0(z,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(X.debug)console.error("Error parsing parameters for @translate directive:",H)}return s9(B,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return K0("Translate",`Error in @translate('${B}'): ${j instanceof Error?j.message:String(j)}`,Z0.EVALUATION_ERROR)}}),J}async function sW($,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 qw($,Z=!0){return(Y,X={})=>{return s9(Y,$,Z,X)}}var o9,J1,M1,t1;var EZ=D(()=>{z1();n0();o9={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},J1={},M1={},t1={}});var e9={};e(e9,{stripTypeScript:()=>WU,hasVariables:()=>DZ,extractVariables:()=>A0,extractScriptFromTemplate:()=>IZ,convertToCommonJS:()=>t9});import H5 from"path";function jw($){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 WU($){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 O=z.substring(0,q).trim().replace(/\?$/,""),F=z.substring(q+1),L=-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){L=A;break}let w=B?"...":"";if(L!==-1)return`${w}${O} = ${F.substring(L+1).trim()}`;return`${w}${O}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,W=G+1,U=0,_=null;while(W<Z.length&&K>0){let q=Z[W];if(_){if(q===_)_=null;W++;continue}if(q==='"'||q==="'"||q==="`"){_=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let 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 A0($,Z,Y){if(!$.trim())return;let X;try{let g=new Bun.Transpiler({loader:"ts",target:"browser",define:H1()}),u=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");u=u.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=g.transformSync(u)}catch{X=WU($)}let J={exports:{}},Q=J.exports,G=process.cwd(),K={},W=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((g)=>g[1]).filter((g)=>!g.startsWith("node:")&&!g.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(g));for(let g of W)try{let u=H5.resolve(G,"node_modules",g),r=H5.join(u,"package.json"),l=JSON.parse(s("fs").readFileSync(r,"utf8")),m=l.main||"index.js";if(l.exports){let c=typeof l.exports==="string"?l.exports:l.exports["."];if(typeof c==="string")m=c;else if(c?.bun)m=c.bun;else if(c?.import)m=c.import;else if(c?.default)m=c.default}K[g]=await import(H5.resolve(u,m))}catch{}let U=(g)=>{if(K[g])return K[g];return s(g)},_=Z.props||{},B=Object.assign((g)=>{if(!g)return _;let u={};for(let[r,l]of Object.entries(g)){let m=_[r];if(m!==void 0)u[r]=m;else if(typeof l==="function")u[r]=l();else u[r]=l}return u},_),z=()=>_,q=(g,u)=>{let r={...g};for(let[l,m]of Object.entries(u))if(r[l]===void 0)if(typeof m==="function")r[l]=m();else r[l]=m;return r},j=(g)=>{let u=()=>g;return u.set=(r)=>{},u.update=(r)=>{},u},H=(g)=>{let u,r=!1;return()=>{if(!r)try{u=g(),r=!0}catch{u=void 0}return u}},O=(g)=>{},F=(g)=>g(),L=(g)=>{},V=(g)=>{},w=(g)=>{},A=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),N=()=>({push:(g)=>{},replace:(g)=>{},back:()=>{},forward:()=>{},go:(g)=>{}}),M=(g)=>{A4(g);let u=Z.__stx_runtime_head||{},r=g||{};Z.__stx_runtime_head={...u,...r.title&&{title:r.title},meta:[...u.meta||[],...r.meta||[]],link:[...u.link||[],...r.link||[]],script:[...u.script||[],...r.script||[]],htmlAttrs:{...u.htmlAttrs||{},...r.htmlAttrs||{}},bodyAttrs:{...u.bodyAttrs||{},...r.bodyAttrs||{}}}},E=(g)=>{B5(g);let u=C6();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...u.title&&{title:u.title},meta:u.meta?[...u.meta]:[]}},I=(g)=>({value:g}),T=(g)=>g,S=(g)=>({value:typeof g==="function"?g():g}),k=(g,u)=>{},b=(g)=>{},y=(g)=>{},v=(g)=>g?g():Promise.resolve(),C=(g)=>(u,...r)=>{},f=(g)=>{},h=(g,u)=>{},d=(g,u)=>u,i=()=>({value:"light"}),n=()=>({value:!1}),W0={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:{}},z0=new Proxy(W0,{get(g,u){if(u in g)return g[u];return},set(g,u,r){return g[u]=r,!0}}),y0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},S0=console;try{let g=t9(X,Y),u=new Set(Object.keys(_)),r=Object.keys(Z).filter((j0)=>!u.has(j0)&&j0!=="props"),l=r.map((j0)=>Z[j0]),m=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"]),c=[],Y0=[];for(let[j0,A8]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if(m.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(g))continue;c.push(j0),Y0.push(A8)}let a=jw(g).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
1838
- `),_0=Z.params??{},F0=[],t0=[];for(let j0=0;j0<r.length;j0++){if(r[j0]==="params")continue;F0.push(r[j0]),t0.push(l[j0])}let V6=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",...c,...F0,`return (async () => {
1837
+ `),Z}async function A0($,Z,Y){if(!$.trim())return;let X;try{let g=new Bun.Transpiler({loader:"ts",target:"browser",define:H1()}),u=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");u=u.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=g.transformSync(u)}catch{X=WU($)}let J={exports:{}},Q=J.exports,G=process.cwd(),K={},W=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((g)=>g[1]).filter((g)=>!g.startsWith("node:")&&!g.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(g));for(let g of W)try{let u=H5.resolve(G,"node_modules",g),r=H5.join(u,"package.json"),l=JSON.parse(s("fs").readFileSync(r,"utf8")),m=l.main||"index.js";if(l.exports){let c=typeof l.exports==="string"?l.exports:l.exports["."];if(typeof c==="string")m=c;else if(c?.bun)m=c.bun;else if(c?.import)m=c.import;else if(c?.default)m=c.default}K[g]=await import(H5.resolve(u,m))}catch{}let U=(g)=>{if(K[g])return K[g];return s(g)},_=Z.props||{},B=Object.assign((g)=>{if(!g)return _;let u={};for(let[r,l]of Object.entries(g)){let m=_[r];if(m!==void 0)u[r]=m;else if(typeof l==="function")u[r]=l();else u[r]=l}return u},_),z=()=>_,q=(g,u)=>{let r={...g};for(let[l,m]of Object.entries(u))if(r[l]===void 0)if(typeof m==="function")r[l]=m();else r[l]=m;return r},j=(g)=>{let u=()=>g;return u.set=(r)=>{},u.update=(r)=>{},u},H=(g)=>{let u,r=!1;return()=>{if(!r)try{u=g(),r=!0}catch{u=void 0}return u}},O=(g)=>{},F=(g)=>g(),L=(g)=>{},V=(g)=>{},w=(g)=>{},A=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),N=()=>({push:(g)=>{},replace:(g)=>{},back:()=>{},forward:()=>{},go:(g)=>{}}),M=(g)=>{A6(g);let u=Z.__stx_runtime_head||{},r=g||{};Z.__stx_runtime_head={...u,...r.title&&{title:r.title},meta:[...u.meta||[],...r.meta||[]],link:[...u.link||[],...r.link||[]],script:[...u.script||[],...r.script||[]],htmlAttrs:{...u.htmlAttrs||{},...r.htmlAttrs||{}},bodyAttrs:{...u.bodyAttrs||{},...r.bodyAttrs||{}}}},E=(g)=>{B5(g);let u=C4();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...u.title&&{title:u.title},meta:u.meta?[...u.meta]:[]}},I=(g)=>({value:g}),T=(g)=>g,S=(g)=>({value:typeof g==="function"?g():g}),k=(g,u)=>{},b=(g)=>{},y=(g)=>{},v=(g)=>g?g():Promise.resolve(),C=(g)=>(u,...r)=>{},f=(g)=>{},h=(g,u)=>{},d=(g,u)=>u,i=()=>({value:"light"}),n=()=>({value:!1}),W0={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:{}},z0=new Proxy(W0,{get(g,u){if(u in g)return g[u];return},set(g,u,r){return g[u]=r,!0}}),y0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},S0=console;try{let g=t9(X,Y),u=new Set(Object.keys(_)),r=Object.keys(Z).filter((j0)=>!u.has(j0)&&j0!=="props"),l=r.map((j0)=>Z[j0]),m=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"]),c=[],Y0=[];for(let[j0,A8]of Object.entries(_)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(j0))continue;if(m.has(j0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${j0}\\b`).test(g))continue;c.push(j0),Y0.push(A8)}let a=jw(g).map((j0)=>`module.exports.${j0} = typeof ${j0} !== 'undefined' ? ${j0} : module.exports.${j0};`).join(`
1838
+ `),_0=Z.params??{},F0=[],t0=[];for(let j0=0;j0<r.length;j0++){if(r[j0]==="params")continue;F0.push(r[j0]),t0.push(l[j0])}let V4=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",...c,...F0,`return (async () => {
1839
1839
  ${g}
1840
1840
  ${a}
1841
1841
  return module.exports
1842
- })()`)(J,Q,U,_,B,z,q,j,H,O,F,L,V,w,A,N,M,E,I,T,S,k,b,y,v,C,f,h,d,i,n,z0,y0,S0,W0.confirm,W0.alert,W0.fetch,_0,...Y0,...t0);Object.assign(Z,V6);for(let[j0,A8]of Object.entries(_))if(!(j0 in Z))Z[j0]=A8}catch{try{await Lw(X,Z,Y)}catch{}}}function t9($,Z){let Y=Z?H5.dirname(Z):process.cwd(),X=$.split(`
1842
+ })()`)(J,Q,U,_,B,z,q,j,H,O,F,L,V,w,A,N,M,E,I,T,S,k,b,y,v,C,f,h,d,i,n,z0,y0,S0,W0.confirm,W0.alert,W0.fetch,_0,...Y0,...t0);Object.assign(Z,V4);for(let[j0,A8]of Object.entries(_))if(!(j0 in Z))Z[j0]=A8}catch{try{await Lw(X,Z,Y)}catch{}}}function t9($,Z){let Y=Z?H5.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 H5.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 O=H.trim().split(/\s+as\s+/).pop()?.trim();if(O)J.push(`module.exports.${O} = ${O};`)}}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=QU(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=TZ(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=QU(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=TZ(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=TZ(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 UU($,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 _U($){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=UU(Y,X);if(K){let W=_U(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 QU($,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=UU(_,0);if(z){let q=U[1],j=z.pattern,H=_.slice(z.endPos).trim();if(H.startsWith("=")){let O=H.slice(1).trim(),F=O,L=Math.max(B,Z);if(GU(O)){let N=KU($,L,O);F=N.value,L=N.nextIndex}else L=L+1;F=F.trim().replace(/;$/,"");let V=_U(j),w=`__stx_src_${Z}`,A=V.map((N)=>`module.exports.${N} = ${N};`).join(`
@@ -1854,7 +1854,7 @@ ${G}`,J++}return{functionCode:X,nextIndex:J}}async function Lw($,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 IZ($){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 DZ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var R4=D(()=>{w4();r4()});var LU={};e(LU,{processLoops:()=>X2});function Aw($,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 O=j.slice(H[0].length).trim();if(!O)continue;try{let F=x0(O,Z),L=JSON.stringify(F),V=`@component('${q}', ${L})`;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 $2($,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 ww($,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);a$(Q);let U=V0(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 Nw($,Z){let Y=$;return Y=$2(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(O0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?Z2:""}catch{return""}}),Y=$2(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(O0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?Y2:""}catch{return""}}),Y}function Rw($){let Z=$;return Z=Z.replace(/@break(?!\()/g,Z2),Z=Z.replace(/@continue(?!\()/g,Y2),Z}function zU($){let Z=$.includes(Z2),Y=Z?$.substring(0,$.indexOf(Z2)):$;return{hasBreak:Z,content:Y}}function qU($){let Z=$.includes(Y2),Y=Z?$.substring(0,$.indexOf(Y2)):$;return{hasContinue:Z,content:Y}}function HU($){let Z=$;return Z=$2(Z,"@break",(Y)=>{let X=Y.trim();if(!V9(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=$2(Z,"@continue",(Y)=>{let X=Y.trim();if(!V9(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Mw($){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),O=H.indexOf(" as ");if(O===-1)continue;let F=H.substring(0,O).trim(),L=H.substring(O+4).trim(),V=j+1,w=1,A=V,N=/@forelse\s*\(/g,M=/@endforelse/g,E=-1;while(w>0&&A<$.length){N.lastIndex=A,M.lastIndex=A;let y=N.exec($),v=M.exec($);if(!v)break;if(y&&y.index<v.index)w++,A=y.index+y[0].length;else{if(w--,w===0){E=v.index;break}A=v.index+11}}if(E===-1)continue;let I=$.substring(V,E),T=E+11,S=-1,k=0,b=0;while(b<I.length){let y=I.indexOf("@",b);if(y===-1)break;let v=I.substring(y);if(/^@forelse\s*\(/.test(v))k++,b=y+1;else if(v.startsWith("@endforelse"))k--,b=y+11;else if(k===0&&v.startsWith("@empty")){if(I.length<=y+6||!/[a-z]/i.test(I[y+6])){S=y;break}b=y+1}else b=y+1}if(S===-1)continue;return{start:_,end:T,arrayExpr:F,itemVar:L,foreachContent:I.substring(0,S),emptyContent:I.substring(S+6)}}return null}function jU($,Z){let Y=$;while(!0){let X=Mw(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(O0(G))_=V0(G,Object.keys(Z))(...Object.values(Z));else _=R0(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=K0("Forelse",`Error in @forelse(${G} as ${K}): ${B}`,Z0.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function X2($,Z,Y,X){let J=$;J=jU(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 O=W.substring(z+1,H),F=O.indexOf(" as ");if(F===-1)continue;let L=B,V=O.substring(0,F),w=O.substring(F+4),A=H+1,N=1,M=A,E=/@foreach\s*\(/g,I=/@endforeach/g;while(N>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)N++,M=T.index+T[0].length;else{if(N--,N===0){let k=W.substring(A,S.index),b=S.index+11;return{start:L,end:b,arrayExpr:V,itemVar:w,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:O}=B;try{let F=j.trim(),L;if(O0(F))L=V0(F,Object.keys(U))(...Object.values(U));else L=R0(F,U);let V=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),V=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),V=!0;else{let T=K0("Foreach",`Error in @foreach: ${F} is not iterable`,Z0.TYPE_ERROR);_=_.substring(0,z)+T+_.substring(q);continue}let w=X?.loops?.useAltLoopVariable??Vw,A=H.trim(),N=null,M;if(A.includes("=>")){let T=A.split("=>").map((S)=>S.trim());if(T.length===2)N=T[0],M=T[1];else M=A}else M=A;let E="",I=L;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},b={...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,d)=>{if(h)b[h]=S[d]});else b[M]=S}else b[M]=S;if(N)if(V&&Array.isArray(S)&&S.length===2)b[N]=S[0],b[M]=S[1];else b[N]=T;let y=Nw(O,b),v=qU(y);if(v.hasContinue){E+=v.content;continue}let C=zU(y);if(C.hasBreak){E+=C.content;break}if(y=jU(y,b),y=G(y,b),y=b6(y,b,Y),y=Rw(y),C=zU(y),C.hasBreak){E+=C.content;break}if(v=qU(y),v.hasContinue){E+=v.content;continue}y=w1(y,b,Y),y=ww(y,b),y=Aw(y,b),E+=y}_=_.substring(0,z)+E+_.substring(q)}catch(F){let L=K0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,Z0.EVALUATION_ERROR);_=_.substring(0,z)+L+_.substring(q)}}return _}J=G(J,Z),J=Ew(J,Z);let K=X?.loops?.maxWhileIterations??Fw;return J=Tw(J,Z,K),J}function OU($){return V9($)}function Ew($,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,_=_5(Y.slice(Q),"for","endfor");if(_.length===0)break;let B=_[0].content,z=Q+_[0].end;if(!OU(W)){let q=K0("For",`Unsafe expression in @for: ${W}`,Z0.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,(L,V)=>{return`\${${V}}`});H=HU(H);let F=Function(...q,`
1857
+ `)();Object.entries(K).forEach(([W,U])=>{if(U!==void 0&&!(W in Z))Z[W]=U})}catch{}}function IZ($){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 DZ($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var R6=D(()=>{w6();r6()});var LU={};e(LU,{processLoops:()=>X2});function Aw($,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 O=j.slice(H[0].length).trim();if(!O)continue;try{let F=x0(O,Z),L=JSON.stringify(F),V=`@component('${q}', ${L})`;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 $2($,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 ww($,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);a$(Q);let U=V0(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 Nw($,Z){let Y=$;return Y=$2(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(O0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?Z2:""}catch{return""}}),Y=$2(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(O0(Q)){let K=V0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(R0(Q,Z));return G?Y2:""}catch{return""}}),Y}function Rw($){let Z=$;return Z=Z.replace(/@break(?!\()/g,Z2),Z=Z.replace(/@continue(?!\()/g,Y2),Z}function zU($){let Z=$.includes(Z2),Y=Z?$.substring(0,$.indexOf(Z2)):$;return{hasBreak:Z,content:Y}}function qU($){let Z=$.includes(Y2),Y=Z?$.substring(0,$.indexOf(Y2)):$;return{hasContinue:Z,content:Y}}function HU($){let Z=$;return Z=$2(Z,"@break",(Y)=>{let X=Y.trim();if(!V9(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=$2(Z,"@continue",(Y)=>{let X=Y.trim();if(!V9(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function Mw($){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),O=H.indexOf(" as ");if(O===-1)continue;let F=H.substring(0,O).trim(),L=H.substring(O+4).trim(),V=j+1,w=1,A=V,N=/@forelse\s*\(/g,M=/@endforelse/g,E=-1;while(w>0&&A<$.length){N.lastIndex=A,M.lastIndex=A;let y=N.exec($),v=M.exec($);if(!v)break;if(y&&y.index<v.index)w++,A=y.index+y[0].length;else{if(w--,w===0){E=v.index;break}A=v.index+11}}if(E===-1)continue;let I=$.substring(V,E),T=E+11,S=-1,k=0,b=0;while(b<I.length){let y=I.indexOf("@",b);if(y===-1)break;let v=I.substring(y);if(/^@forelse\s*\(/.test(v))k++,b=y+1;else if(v.startsWith("@endforelse"))k--,b=y+11;else if(k===0&&v.startsWith("@empty")){if(I.length<=y+6||!/[a-z]/i.test(I[y+6])){S=y;break}b=y+1}else b=y+1}if(S===-1)continue;return{start:_,end:T,arrayExpr:F,itemVar:L,foreachContent:I.substring(0,S),emptyContent:I.substring(S+6)}}return null}function jU($,Z){let Y=$;while(!0){let X=Mw(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(O0(G))_=V0(G,Object.keys(Z))(...Object.values(Z));else _=R0(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=K0("Forelse",`Error in @forelse(${G} as ${K}): ${B}`,Z0.EVALUATION_ERROR);Y=Y.substring(0,J)+z+Y.substring(Q)}}return Y}function X2($,Z,Y,X){let J=$;J=jU(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 O=W.substring(z+1,H),F=O.indexOf(" as ");if(F===-1)continue;let L=B,V=O.substring(0,F),w=O.substring(F+4),A=H+1,N=1,M=A,E=/@foreach\s*\(/g,I=/@endforeach/g;while(N>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)N++,M=T.index+T[0].length;else{if(N--,N===0){let k=W.substring(A,S.index),b=S.index+11;return{start:L,end:b,arrayExpr:V,itemVar:w,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:O}=B;try{let F=j.trim(),L;if(O0(F))L=V0(F,Object.keys(U))(...Object.values(U));else L=R0(F,U);let V=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),V=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),V=!0;else{let T=K0("Foreach",`Error in @foreach: ${F} is not iterable`,Z0.TYPE_ERROR);_=_.substring(0,z)+T+_.substring(q);continue}let w=X?.loops?.useAltLoopVariable??Vw,A=H.trim(),N=null,M;if(A.includes("=>")){let T=A.split("=>").map((S)=>S.trim());if(T.length===2)N=T[0],M=T[1];else M=A}else M=A;let E="",I=L;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},b={...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,d)=>{if(h)b[h]=S[d]});else b[M]=S}else b[M]=S;if(N)if(V&&Array.isArray(S)&&S.length===2)b[N]=S[0],b[M]=S[1];else b[N]=T;let y=Nw(O,b),v=qU(y);if(v.hasContinue){E+=v.content;continue}let C=zU(y);if(C.hasBreak){E+=C.content;break}if(y=jU(y,b),y=G(y,b),y=b4(y,b,Y),y=Rw(y),C=zU(y),C.hasBreak){E+=C.content;break}if(v=qU(y),v.hasContinue){E+=v.content;continue}y=w1(y,b,Y),y=ww(y,b),y=Aw(y,b),E+=y}_=_.substring(0,z)+E+_.substring(q)}catch(F){let L=K0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,Z0.EVALUATION_ERROR);_=_.substring(0,z)+L+_.substring(q)}}return _}J=G(J,Z),J=Ew(J,Z);let K=X?.loops?.maxWhileIterations??Fw;return J=Tw(J,Z,K),J}function OU($){return V9($)}function Ew($,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,_=_5(Y.slice(Q),"for","endfor");if(_.length===0)break;let B=_[0].content,z=Q+_[0].end;if(!OU(W)){let q=K0("For",`Unsafe expression in @for: ${W}`,Z0.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,(L,V)=>{return`\${${V}}`});H=HU(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 bw($,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 Pw(){SZ.clear()}function yw($){if($.__onceStore instanceof Set)return $.__onceStore;return SZ}async function Q2($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||T0.join(T0.dirname(Y),"partials");if(G&&!T0.isAbsolute(G)){let j=T0.resolve(__dirname,"..");G=T0.resolve(j,G)}let K=Iw($,"@partial","@include"),W=yw(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let F=H.trim(),L=`${Y}:${F}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let w=K.substring(F+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let N=A[1],M=U(N,G,Y),E="";if(M&&await Bun.file(M).exists())J.add(M),E=`@include(${w})`;K=K.substring(0,O)+E+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=O.exec(K))!==null){let L=F.index,V=L+F[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let N=K.substring(V+1,A-1),M=kZ(N,0);if(M===-1){O.lastIndex=A;continue}let E=N.substring(0,M).trim(),I=N.substring(M+1).trim(),T=I.match(/^\s*['"]([^'"]+)['"]/);if(!T){O.lastIndex=A;continue}let S=T[1],k=I.substring(T[0].length),b,y=kZ(k,0);if(y!==-1)b=k.substring(y+1).trim();try{let v=`Boolean(${E})`,C;if(O0(v)){let d=V0(v,Object.keys(Z));C=Boolean(d(...Object.values(Z)))}else C=Boolean(R0(v,Z));let f=H?!C:C,h="";if(f){let d=U(S,G,Y);if(d&&await Bun.file(d).exists())J.add(d);h=`@include('${S}'${b?`, ${b}`:""})`}K=K.substring(0,L)+h+K.substring(A),O.lastIndex=0}catch(v){let C=v instanceof Error?v.message:String(v),f=L0("Include",`Error evaluating ${j} condition: ${C}`,Y,$,L);K=K.substring(0,L)+f+K.substring(A),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let w=K.substring(F+1,V),A=K.substring(O,V+1),N=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let[,M,E,I,T]=N;try{let S,k=E.trim();if(O0(k))S=V0(k,Object.keys(Z))(...Object.values(Z));else S=R0(k,Z);let b="";if(Array.isArray(S)&&S.length>0)for(let y of S){let v={...Z,[I]:y},C=await B(M,v,$,O);b+=C}else if(T)b=await B(T,{},$,O);K=K.substring(0,O)+b+K.substring(V+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,O)+L0("Each",`Error in @each: ${k}`,Y,$,O)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let w=K.substring(F+1,V),A=K.substring(O,V+1),N=w.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let M=N[1],E=w.slice(N[0].length),I,T=E.match(/^\s*,\s*\{/);if(T){E=E.slice(T[0].length-1);let b=1,y=1;while(y<E.length&&b>0){if(E[y]==="{")b++;else if(E[y]==="}"){if(b--,b===0)break}y++}I=E.substring(0,y+1),E=E.slice(y+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let b=JSON.parse(M.replace(/'/g,'"')),y={};if(I)try{y=x0(I,Z)}catch(C){let f=C instanceof Error?C.message:String(C);if(X.debug){let h=L0("Include",`Error parsing includeFirst variables: ${f}`,Y,$,O,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>S||"");continue}let v=!1;for(let C of b){let f=U(C,G,Y);if(!f)continue;if(await X0(f)){let h=await B(C,y,$,O);K=K.replace(A,()=>h),v=!0;break}}if(!v)if(S!==void 0)K=K.replace(A,()=>S);else if(X.debug){let C=L0("Include",`None of the includeFirst paths exist: ${M}`,Y,$,O,A);K=K.replace(A,()=>C)}else K=K.replace(A,"")}catch(b){let y=b instanceof Error?b.message:String(b),v=L0("Include",`Error processing @includeFirst: ${y}`,Y,$,O,A);K=K.replace(A,()=>v)}j.lastIndex=0}}function U(j,H,O){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let L=T0.resolve(H),V=T0.resolve(T0.dirname(O)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=T0.resolve(H,F);else w=T0.resolve(V,F);let A=T0.normalize(w),N=A.startsWith(L+T0.sep)||A===L,M=A.startsWith(V+T0.sep)||A===V,E=!1,I=T0.dirname(V);if(A.startsWith(I+T0.sep)){if(!T0.relative(I,A).split(T0.sep).some((b)=>b.startsWith(".")&&b!=="."&&b!==".."))E=!0}if(!N&&!M&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${L}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let _=T0.resolve(Y);Q.add(_);async function B(j,H={},O,F){let L=U(j,G,Y);if(!L)return L0("Include",`Could not resolve path for include: ${j}`,Y,O,F);let V=T0.resolve(L);if(Q.has(V)){let w=[...Q,V].map((A)=>T0.basename(A)).join(" -> ");return L0("Include",`Circular include detected: ${w}`,Y,O,F)}try{J.add(L);let w;if(!w)try{w=await Bun.file(L).text()}catch(C){let f=C instanceof Error?C.message:String(C);return L0("Include",`Error loading include file ${j}: ${f}`,Y,O,F)}let A=w,N=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(N)A=N[1].trim();let M=w.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[C,f]of Object.entries(H))I[C]=f;let T=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...w.matchAll(T)],k="",b=null;for(let C of S){let f=C[1]||"",h=C[2]||"",d=f.includes("server");if(z4(f)&&h.trim())h=q4(h);let n=Dw(h);if(n&&!d){b=`stx_scope_${T0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++Cw}`;let W0=B4(h),z0=Sw(W0,b);k+=`<script data-stx-scoped>${z0}</script>
1890
- `;continue}if(d)try{let{extractVariables:W0}=await Promise.resolve().then(() => (R4(),e9));await W0(h,I,L)}catch(W0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,W0)}if(!d&&!n){let W0=f.replace(/\bclient\b/i,"").trim();k+=`<script data-stx-scoped${W0?` ${W0}`:""}>${h}</script>
1891
- `}}if(b){let C=bw(A,b);if(A=C.html,C.mergedIntoExisting)k=k.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${C.mergedIntoExisting}']`),b=C.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await Q2(A,I,L,X,J,Q);let{processLoops:y}=await Promise.resolve().then(() => (J2(),LU)),v=y(A,I,L);if(v=b6(v,I,L),v=w1(v,I,L),E)v+=`
1889
+ `}function bw($,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 Pw(){SZ.clear()}function yw($){if($.__onceStore instanceof Set)return $.__onceStore;return SZ}async function Q2($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||T0.join(T0.dirname(Y),"partials");if(G&&!T0.isAbsolute(G)){let j=T0.resolve(__dirname,"..");G=T0.resolve(j,G)}let K=Iw($,"@partial","@include"),W=yw(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let F=H.trim(),L=`${Y}:${F}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let w=K.substring(F+1,V-1),A=w.match(/^\s*['"]([^'"]+)['"]/);if(!A){j.lastIndex=V;continue}let N=A[1],M=U(N,G,Y),E="";if(M&&await Bun.file(M).exists())J.add(M),E=`@include(${w})`;K=K.substring(0,O)+E+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=O.exec(K))!==null){let L=F.index,V=L+F[0].length-1,w=1,A=V+1;while(A<K.length&&w>0){if(K[A]==="(")w++;else if(K[A]===")")w--;A++}if(w!==0)break;let N=K.substring(V+1,A-1),M=kZ(N,0);if(M===-1){O.lastIndex=A;continue}let E=N.substring(0,M).trim(),I=N.substring(M+1).trim(),T=I.match(/^\s*['"]([^'"]+)['"]/);if(!T){O.lastIndex=A;continue}let S=T[1],k=I.substring(T[0].length),b,y=kZ(k,0);if(y!==-1)b=k.substring(y+1).trim();try{let v=`Boolean(${E})`,C;if(O0(v)){let d=V0(v,Object.keys(Z));C=Boolean(d(...Object.values(Z)))}else C=Boolean(R0(v,Z));let f=H?!C:C,h="";if(f){let d=U(S,G,Y);if(d&&await Bun.file(d).exists())J.add(d);h=`@include('${S}'${b?`, ${b}`:""})`}K=K.substring(0,L)+h+K.substring(A),O.lastIndex=0}catch(v){let C=v instanceof Error?v.message:String(v),f=L0("Include",`Error evaluating ${j} condition: ${C}`,Y,$,L);K=K.substring(0,L)+f+K.substring(A),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let w=K.substring(F+1,V),A=K.substring(O,V+1),N=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let[,M,E,I,T]=N;try{let S,k=E.trim();if(O0(k))S=V0(k,Object.keys(Z))(...Object.values(Z));else S=R0(k,Z);let b="";if(Array.isArray(S)&&S.length>0)for(let y of S){let v={...Z,[I]:y},C=await B(M,v,$,O);b+=C}else if(T)b=await B(T,{},$,O);K=K.substring(0,O)+b+K.substring(V+1),j.lastIndex=0}catch(S){let k=S instanceof Error?S.message:String(S);K=K.substring(0,O)+L0("Each",`Error in @each: ${k}`,Y,$,O)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,F=O+H[0].length-1,L=1,V=F+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")"){if(L--,L===0)break}V++}if(L!==0)break;let w=K.substring(F+1,V),A=K.substring(O,V+1),N=w.match(/^\s*(\[[^\]]+\])/);if(!N){j.lastIndex=0,K=K.replace(A,"");continue}let M=N[1],E=w.slice(N[0].length),I,T=E.match(/^\s*,\s*\{/);if(T){E=E.slice(T[0].length-1);let b=1,y=1;while(y<E.length&&b>0){if(E[y]==="{")b++;else if(E[y]==="}"){if(b--,b===0)break}y++}I=E.substring(0,y+1),E=E.slice(y+1)}let S,k=E.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(k)S=k[1];try{let b=JSON.parse(M.replace(/'/g,'"')),y={};if(I)try{y=x0(I,Z)}catch(C){let f=C instanceof Error?C.message:String(C);if(X.debug){let h=L0("Include",`Error parsing includeFirst variables: ${f}`,Y,$,O,A);K=K.replace(A,()=>h)}else K=K.replace(A,()=>S||"");continue}let v=!1;for(let C of b){let f=U(C,G,Y);if(!f)continue;if(await X0(f)){let h=await B(C,y,$,O);K=K.replace(A,()=>h),v=!0;break}}if(!v)if(S!==void 0)K=K.replace(A,()=>S);else if(X.debug){let C=L0("Include",`None of the includeFirst paths exist: ${M}`,Y,$,O,A);K=K.replace(A,()=>C)}else K=K.replace(A,"")}catch(b){let y=b instanceof Error?b.message:String(b),v=L0("Include",`Error processing @includeFirst: ${y}`,Y,$,O,A);K=K.replace(A,()=>v)}j.lastIndex=0}}function U(j,H,O){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let L=T0.resolve(H),V=T0.resolve(T0.dirname(O)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=T0.resolve(H,F);else w=T0.resolve(V,F);let A=T0.normalize(w),N=A.startsWith(L+T0.sep)||A===L,M=A.startsWith(V+T0.sep)||A===V,E=!1,I=T0.dirname(V);if(A.startsWith(I+T0.sep)){if(!T0.relative(I,A).split(T0.sep).some((b)=>b.startsWith(".")&&b!=="."&&b!==".."))E=!0}if(!N&&!M&&!E)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${A}`),console.error(` Allowed dirs: ${L}, ${V}`),null;return A}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let _=T0.resolve(Y);Q.add(_);async function B(j,H={},O,F){let L=U(j,G,Y);if(!L)return L0("Include",`Could not resolve path for include: ${j}`,Y,O,F);let V=T0.resolve(L);if(Q.has(V)){let w=[...Q,V].map((A)=>T0.basename(A)).join(" -> ");return L0("Include",`Circular include detected: ${w}`,Y,O,F)}try{J.add(L);let w;if(!w)try{w=await Bun.file(L).text()}catch(C){let f=C instanceof Error?C.message:String(C);return L0("Include",`Error loading include file ${j}: ${f}`,Y,O,F)}let A=w,N=A.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(N)A=N[1].trim();let M=w.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[C,f]of Object.entries(H))I[C]=f;let T=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...w.matchAll(T)],k="",b=null;for(let C of S){let f=C[1]||"",h=C[2]||"",d=f.includes("server");if(z6(f)&&h.trim())h=q6(h);let n=Dw(h);if(n&&!d){b=`stx_scope_${T0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++Cw}`;let W0=B6(h),z0=Sw(W0,b);k+=`<script data-stx-scoped>${z0}</script>
1890
+ `;continue}if(d)try{let{extractVariables:W0}=await Promise.resolve().then(() => (R6(),e9));await W0(h,I,L)}catch(W0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,W0)}if(!d&&!n){let W0=f.replace(/\bclient\b/i,"").trim();k+=`<script data-stx-scoped${W0?` ${W0}`:""}>${h}</script>
1891
+ `}}if(b){let C=bw(A,b);if(A=C.html,C.mergedIntoExisting)k=k.replace(`window.stx._scopes['${b}']`,`window.stx._scopes['${C.mergedIntoExisting}']`),b=C.mergedIntoExisting}if(A.includes("@include")||A.includes("@partial"))A=await Q2(A,I,L,X,J,Q);let{processLoops:y}=await Promise.resolve().then(() => (J2(),LU)),v=y(A,I,L);if(v=b4(v,I,L),v=w1(v,I,L),E)v+=`
1892
1892
  `+E;if(k)v+=`
1893
1893
  `+k;return v}catch(w){let A=w instanceof Error?w.message:String(w);return L0("Include",`Error processing include ${j}: ${A}`,Y,O,F)}}let z=/@include\s*\(/g,q;while((q=z.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,F=H+1;while(F<K.length&&O>0){if(K[F]==="(")O++;else if(K[F]===")")O--;F++}if(O!==0)break;let L=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){z.lastIndex=F;continue}let A=w[1],N,M=V.substring(w[0].length),E=kZ(M,0);if(E!==-1)N=M.substring(E+1).trim();let I={};if(N)try{I=x0(N,Z)}catch(S){let k=S instanceof Error?S.message:String(S);K=K.replace(L,L0("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 G2($,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}\\(`),O=new RegExp(`@${G}(?![a-z])`),F=1,L=j,V=-1;while(F>0&&L<W.length){let A=W.slice(L),N=A.match(H),M=A.match(O),E=N?L+N.index:1/0,I=M?L+M.index:1/0;if(E<I)F++,L=E+(N[0].length||1);else if(I<1/0){if(F--,F===0){V=I;break}L=I+G.length+1}else break}if(V===-1)break;let w=W.slice(j,V);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(w);else Z[q].push(w);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 K2($,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",Cw=0,M4,SZ;var y6=D(()=>{d9();r0();j4();n0();H0();M4=new Z5(500),SZ=new Set});import*as bZ from"path";async function FU($,Z,Y=""){if(bZ.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 AU($,Z,Y,"@js","@endjs")}async function VU($,Z,Y=""){if(bZ.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 AU($,Z,Y,"@ts","@endts")}async function AU($,Z,Y,X,J){let Q=$,G=M6(`${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 O=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((A)=>A.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
1894
+ `)})}var __dirname="/home/runner/work/stx/stx/packages/stx/src",Cw=0,M6,SZ;var y4=D(()=>{d9();r0();j6();n0();H0();M6=new Z5(500),SZ=new Set});import*as bZ from"path";async function FU($,Z,Y=""){if(bZ.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 AU($,Z,Y,"@js","@endjs")}async function VU($,Z,Y=""){if(bZ.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 AU($,Z,Y,"@ts","@endts")}async function AU($,Z,Y,X,J){let Q=$,G=M4(`${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 O=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((A)=>A.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
1895
1895
  ${j}
1896
1896
  ${F}
1897
- `,w=Function(...z,L)(...q);if(w&&typeof w==="object")Object.assign(Z,w);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=L0(`${X} Directive`,`Error executing code: ${q}`,Y,$,B,U);console.error(j),Q=Q.replace(U,"")}return Q}var wU=D(()=>{j4();H0()});function xw($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function NU($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return xw(X,Q||"_method")})}async function CZ($,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=L0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
1897
+ `,w=Function(...z,L)(...q);if(w&&typeof w==="object")Object.assign(Z,w);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=L0(`${X} Directive`,`Error executing code: ${q}`,Y,$,B,U);console.error(j),Q=Q.replace(U,"")}return Q}var wU=D(()=>{j6();H0()});function xw($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function NU($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return xw(X,Q||"_method")})}async function CZ($,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=L0("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;">${D0(U)}</div>
1899
1899
  `)}}}return Q}async function PZ($,Z,Y,X){return CZ($,Z,Y,X,"before")}async function yZ($,Z,Y,X){return CZ($,Z,Y,X,"after")}var xZ=D(()=>{r0();H0()});import{defineRoute as ny,defineRoutes as ry,resetRoutes as ay,route as sy,setAppUrl as oy}from"stx-router";import{route as vw}from"stx-router";function RU($){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 vw(X,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var MU=D(()=>{n0()});function vZ($,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="${Q0(B)}" content="${Q0(U)}">`:""}return U?`<meta name="${Q0(W)}" content="${Q0(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="${Q0(String(j.name))}"`;if(j.property)H+=` property="${Q0(String(j.property))}"`;if(j.httpEquiv)H+=` http-equiv="${Q0(String(j.httpEquiv))}"`;if(j.content)H+=` content="${Q0(String(j.content))}"`;return H+=">",H}catch(j){let H=j instanceof Error?j.message:String(j);return K0("MetaTag",H,Z0.EVALUATION_ERROR)}})();J=J.substring(0,K)+q+J.substring(z),Q.lastIndex=0}return J}function gZ($,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 K0("StructuredData",j,Z0.EVALUATION_ERROR)}})();X=X.substring(0,G)+z+X.substring(B),J.lastIndex=0}return X}function fZ($,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),O=((F)=>{try{let L=x0(F,Z);if(!L)return"";let V="";if(L.title)V+=`<title>${Q0(L.title)}</title>
1900
1900
  `,V+=`<meta name="title" content="${Q0(L.title)}">
@@ -1942,14 +1942,14 @@ ${$.map((Q)=>{let G=Q.startsWith("http")?Q:`${Y}${Q.startsWith("/")?"":"/"}${Q}`
1942
1942
  </sitemap>`}).join(`
1943
1943
  `)}
1944
1944
  </sitemapindex>`}async function hw($,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 EU($){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(`
1945
- `).trim()}function dw($){return EU({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function uw($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}var W2,U2;var _2=D(()=>{z1();n0();W2={name:"meta",handler:($,Z,Y,X)=>{if(Z.length<1)return K0("Meta","meta directive requires at least the meta name",Z0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${Q0(J)}" content="${Q0(Q)}">`},hasEndTag:!1},U2={name:"structuredData",handler:($,Z,Y,X)=>{if($.trim()==="")return K0("StructuredData","structuredData directive requires JSON-LD content",Z0.INVALID_DIRECTIVE_SYNTAX);try{let J=JSON.parse($);if(!J["@context"])J["@context"]="https://schema.org";if(!J["@type"])return K0("StructuredData","structuredData requires @type property",Z0.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 K0("StructuredData",Q,Z0.EVALUATION_ERROR)}},hasEndTag:!0}});async function TU($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(O5.exact[$])for(let X of O5.exact[$])await Promise.resolve(X(Z,$));if(O5.exact[Y])for(let X of O5.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of O5.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}var O5;var IU=D(()=>{O5={patterns:[],exact:{}}});function DU($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>DU(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function B2($,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],O=z[2];if(O.includes("()")&&!O.includes(".get(")||O.includes("$store")||O.includes("$ref"))continue;try{let F=Object.keys(Z),L=Object.values(Z),V=O.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 (${O})`)(...L);if(H==="class"){let N=DU(A);if(N){let M=q.match(/\sclass="([^"]*)"/);if(M)q=q.replace(M[0],` class="${M[1]} ${N}"`);else q=q.replace(z[0],` class="${N}"`)}else q=q.replace(z[0],"");j=!0;continue}if(mw.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 N=String(A).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");q=q.replace(z[0],` ${H}="${N}"`)}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 mw;var dZ=D(()=>{mw=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function t4($,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("/")||cw.has(X[1].toLowerCase()),start:X.index,end:X.index+X[0].length}}function pw($,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 x1($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=pw($,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 kU($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function x6($,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 SU($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function iw($){let Z=$,Y=0;while(Y<Z.length){let X=t4(Z,Y);if(!X)break;let J=x6(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 O=G.split(",").map((V)=>V.trim()),F=O[0],L=O[1];W=`${K} as ${L} => ${F}`}else W=`${K} as ${G}`;let U=E4(X.attrs,"v-for"),_=E4(U,":key").replace(/\s*v-bind:key="[^"]*"/g,""),B=x1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T4(z,{...X,start:0,end:X.end-X.start},_),j=`@foreach(${W})
1945
+ `).trim()}function dw($){return EU({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function uw($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}var W2,U2;var _2=D(()=>{z1();n0();W2={name:"meta",handler:($,Z,Y,X)=>{if(Z.length<1)return K0("Meta","meta directive requires at least the meta name",Z0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${Q0(J)}" content="${Q0(Q)}">`},hasEndTag:!1},U2={name:"structuredData",handler:($,Z,Y,X)=>{if($.trim()==="")return K0("StructuredData","structuredData directive requires JSON-LD content",Z0.INVALID_DIRECTIVE_SYNTAX);try{let J=JSON.parse($);if(!J["@context"])J["@context"]="https://schema.org";if(!J["@type"])return K0("StructuredData","structuredData requires @type property",Z0.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 K0("StructuredData",Q,Z0.EVALUATION_ERROR)}},hasEndTag:!0}});async function TU($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(O5.exact[$])for(let X of O5.exact[$])await Promise.resolve(X(Z,$));if(O5.exact[Y])for(let X of O5.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of O5.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}var O5;var IU=D(()=>{O5={patterns:[],exact:{}}});function DU($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>DU(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function B2($,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],O=z[2];if(O.includes("()")&&!O.includes(".get(")||O.includes("$store")||O.includes("$ref"))continue;try{let F=Object.keys(Z),L=Object.values(Z),V=O.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 (${O})`)(...L);if(H==="class"){let N=DU(A);if(N){let M=q.match(/\sclass="([^"]*)"/);if(M)q=q.replace(M[0],` class="${M[1]} ${N}"`);else q=q.replace(z[0],` class="${N}"`)}else q=q.replace(z[0],"");j=!0;continue}if(mw.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 N=String(A).replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;");q=q.replace(z[0],` ${H}="${N}"`)}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 mw;var dZ=D(()=>{mw=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function t6($,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("/")||cw.has(X[1].toLowerCase()),start:X.index,end:X.index+X[0].length}}function pw($,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 x1($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=pw($,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 kU($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function x4($,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 SU($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function iw($){let Z=$,Y=0;while(Y<Z.length){let X=t6(Z,Y);if(!X)break;let J=x4(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 O=G.split(",").map((V)=>V.trim()),F=O[0],L=O[1];W=`${K} as ${L} => ${F}`}else W=`${K} as ${G}`;let U=E6(X.attrs,"v-for"),_=E6(U,":key").replace(/\s*v-bind:key="[^"]*"/g,""),B=x1(Z,X),z=Z.slice(B.outerStart,B.outerEnd),q=T6(z,{...X,start:0,end:X.end-X.start},_),j=`@foreach(${W})
1946
1946
  `,H=`${j}${q}
1947
- @endforeach`;Z=Z.slice(0,B.outerStart)+H+Z.slice(B.outerEnd),Y=B.outerStart+j.length}return Z}function nw($){let Z=$,Y=0;while(Y<Z.length){let X=t4(Z,Y);if(!X)break;let J=x6(X.attrs,"v-if");if(J===null){Y=X.end;continue}let Q=[],G=x1(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*/),O=H?H[0].length:0,F=t4(Z,U+O);if(!F){_=!1;break}let L=x6(F.attrs,"v-else-if"),V=kU(F.attrs,"v-else");if(L!==null){let w=x1(Z,F),A=E4(F.attrs,"v-else-if"),N=T4(Z.slice(w.outerStart,w.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else-if",expr:L,outerStart:U,outerEnd:w.outerEnd,element:N,parsedTag:F}),U=w.outerEnd}else if(V){let w=x1(Z,F),A=E4(F.attrs,"v-else"),N=T4(Z.slice(w.outerStart,w.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else",outerStart:U,outerEnd:w.outerEnd,element:N,parsedTag:F}),_=!1}else _=!1}let B=[];for(let H of Q)if(H.type==="if")B.push(`@if(${H.expr})
1947
+ @endforeach`;Z=Z.slice(0,B.outerStart)+H+Z.slice(B.outerEnd),Y=B.outerStart+j.length}return Z}function nw($){let Z=$,Y=0;while(Y<Z.length){let X=t6(Z,Y);if(!X)break;let J=x4(X.attrs,"v-if");if(J===null){Y=X.end;continue}let Q=[],G=x1(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*/),O=H?H[0].length:0,F=t6(Z,U+O);if(!F){_=!1;break}let L=x4(F.attrs,"v-else-if"),V=kU(F.attrs,"v-else");if(L!==null){let w=x1(Z,F),A=E6(F.attrs,"v-else-if"),N=T6(Z.slice(w.outerStart,w.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else-if",expr:L,outerStart:U,outerEnd:w.outerEnd,element:N,parsedTag:F}),U=w.outerEnd}else if(V){let w=x1(Z,F),A=E6(F.attrs,"v-else"),N=T6(Z.slice(w.outerStart,w.outerEnd),{...F,start:0,end:F.end-F.start},A);Q.push({type:"else",outerStart:U,outerEnd:w.outerEnd,element:N,parsedTag:F}),_=!1}else _=!1}let B=[];for(let H of Q)if(H.type==="if")B.push(`@if(${H.expr})
1948
1948
  ${H.element}`);else if(H.type==="else-if")B.push(`@elseif(${H.expr})
1949
1949
  ${H.element}`);else B.push(`@else
1950
1950
  ${H.element}`);B.push("@endif");let z=B.join(`
1951
- `),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 rw($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function aw($){let Z=$,Y=0;while(Y<Z.length){let X=t4(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 _=x1(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=x6(X.attrs,"v-model");if(W===null){Y=X.end;continue}if(lw.has(X.tag.toLowerCase())){let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${W}"`,B=x1(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=x1(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 sw($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function ow($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function tw($){let Z=$,Y=0;while(Y<Z.length){let X=t4(Z,Y);if(!X)break;let J=x6(X.attrs,"v-html");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=x1(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 ew($){let Z=$,Y=0;while(Y<Z.length){let X=t4(Z,Y);if(!X)break;let J=x6(X.attrs,"v-text");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=x1(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 $N($){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 ZN($){let Z=$,Y=0;while(Y<Z.length){let X=t4(Z,Y);if(!X)break;if(!kU(X.attrs,"v-once")){Y=X.end;continue}let J=E4(X.attrs,"v-once"),Q=x1(Z,X),G=Z.slice(Q.outerStart,Q.outerEnd),W=`@once
1952
- ${T4(G,{...X,start:0,end:X.end-X.start},J)}
1951
+ `),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 rw($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function aw($){let Z=$,Y=0;while(Y<Z.length){let X=t6(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 _=x1(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=x4(X.attrs,"v-model");if(W===null){Y=X.end;continue}if(lw.has(X.tag.toLowerCase())){let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${W}"`,B=x1(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=x1(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 sw($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function ow($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function tw($){let Z=$,Y=0;while(Y<Z.length){let X=t6(Z,Y);if(!X)break;let J=x4(X.attrs,"v-html");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=x1(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 ew($){let Z=$,Y=0;while(Y<Z.length){let X=t6(Z,Y);if(!X)break;let J=x4(X.attrs,"v-text");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=x1(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 $N($){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 ZN($){let Z=$,Y=0;while(Y<Z.length){let X=t6(Z,Y);if(!X)break;if(!kU(X.attrs,"v-once")){Y=X.end;continue}let J=E6(X.attrs,"v-once"),Q=x1(Z,X),G=Z.slice(Q.outerStart,Q.outerEnd),W=`@once
1952
+ ${T6(G,{...X,start:0,end:X.end-X.start},J)}
1953
1953
  @endonce`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function YN($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function XN($){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 uZ($){if(!SU($))return $;let Z=$;return Z=iw(Z),Z=nw(Z),Z=ZN(Z),Z=sw(Z),Z=ow(Z),Z=aw(Z),Z=rw(Z),Z=XN(Z),Z=tw(Z),Z=ew(Z),Z=$N(Z),Z=YN(Z),Z}var cw,lw;var mZ=D(()=>{cw=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),lw=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 cZ($,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=R0(_.expr,Z);if(!B||typeof B!=="string"){let L=`<!-- dynamic component: could not resolve "${_.expr}" -->`;Q=Q.slice(0,_.index)+L+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 L=H[1]||H[2],V=H[3];if(H[1])try{q[L]=R0(V,Z)}catch{q[L]=V}else q[L]=V}let O=X.componentsDir||"components",F=await v1(B,q,_.slotContent,O,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 JN(Q,Z,Y,X,J),Q}async function JN($,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=R0(_.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 v1(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 lZ=D(()=>{H0();n0()});function bU($,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 CU($,Z,Y={}){let{prefix:X="",preserveHost:J=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=pZ($),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=PU(_,Z,X,J,U,G);W.push(B)}return W.join(`
1954
1954
 
1955
1955
  `)}function pZ($){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=pZ(z);Z.push({selector:`@${_} ${B.trim()}`,declarations:q.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
@@ -1969,7 +1969,7 @@ ${V.join(`
1969
1969
  ${w.join(`
1970
1970
  `)}
1971
1971
  </body>
1972
- </html>`}function xU($){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 F5($,Z={},Y={}){if(xU($))return $;return yU($,Z,Y)}function H2($){let Z=$,Y=new Set,X=new Set,J=()=>{if(q1)X.add(q1);return Z};return J.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),V5)X.forEach((K)=>j2.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 O2($){let Z,Y=!0,X=new Set,J=()=>{if(!Y)if(Y=!0,V5)X.forEach((G)=>j2.add(G));else X.forEach((G)=>G())},Q=()=>{if(q1)X.add(q1);if(Y){let G=q1;q1=J,q2.push(J);try{Z=$()}finally{q2.pop(),q1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Q}function L2($,Z={}){let Y,X=!1,J=()=>{if(X)return;if(Y)Y(),Y=void 0;let Q=q1;q1=J,q2.push(J);try{Y=$()}finally{q2.pop(),q1=Q}};if(Z.immediate!==!1)J();return()=>{if(X=!0,Y)Y()}}function F2($){if(V5){$();return}V5=!0;try{$()}finally{V5=!1,j2.forEach((Z)=>Z()),j2.clear()}}function V2($){WN.push($)}function A2($){UN.push($)}function A5($){return typeof $==="function"&&$._isSignal===!0}function w5($){return typeof $==="function"&&$._isDerived===!0}function w2($){if(A5($)||w5($))return $();return $}function N2($){let Z=q1;q1=null;try{return $()}finally{q1=Z}}var q1=null,q2,V5=!1,j2,WN,UN;var iZ=D(()=>{q2=[],j2=new Set,WN=[],UN=[]});var nZ={};e(nZ,{untrack:()=>w2,state:()=>H2,peek:()=>N2,onMount:()=>V2,onDestroy:()=>A2,isSignal:()=>A5,isDerived:()=>w5,generateSignalsRuntimeDev:()=>e4,generateSignalsRuntime:()=>N5,effect:()=>L2,derived:()=>O2,default:()=>_N,batch:()=>F2});function N5(){try{let Z=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e4());return Z=Z.replace(/\}(var |let |const |function )/g,"};$1"),Z}catch{return e4()}}function e4(){return`
1972
+ </html>`}function xU($){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 F5($,Z={},Y={}){if(xU($))return $;return yU($,Z,Y)}function H2($){let Z=$,Y=new Set,X=new Set,J=()=>{if(q1)X.add(q1);return Z};return J.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),V5)X.forEach((K)=>j2.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 O2($){let Z,Y=!0,X=new Set,J=()=>{if(!Y)if(Y=!0,V5)X.forEach((G)=>j2.add(G));else X.forEach((G)=>G())},Q=()=>{if(q1)X.add(q1);if(Y){let G=q1;q1=J,q2.push(J);try{Z=$()}finally{q2.pop(),q1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Q}function L2($,Z={}){let Y,X=!1,J=()=>{if(X)return;if(Y)Y(),Y=void 0;let Q=q1;q1=J,q2.push(J);try{Y=$()}finally{q2.pop(),q1=Q}};if(Z.immediate!==!1)J();return()=>{if(X=!0,Y)Y()}}function F2($){if(V5){$();return}V5=!0;try{$()}finally{V5=!1,j2.forEach((Z)=>Z()),j2.clear()}}function V2($){WN.push($)}function A2($){UN.push($)}function A5($){return typeof $==="function"&&$._isSignal===!0}function w5($){return typeof $==="function"&&$._isDerived===!0}function w2($){if(A5($)||w5($))return $();return $}function N2($){let Z=q1;q1=null;try{return $()}finally{q1=Z}}var q1=null,q2,V5=!1,j2,WN,UN;var iZ=D(()=>{q2=[],j2=new Set,WN=[],UN=[]});var nZ={};e(nZ,{untrack:()=>w2,state:()=>H2,peek:()=>N2,onMount:()=>V2,onDestroy:()=>A2,isSignal:()=>A5,isDerived:()=>w5,generateSignalsRuntimeDev:()=>e6,generateSignalsRuntime:()=>N5,effect:()=>L2,derived:()=>O2,default:()=>_N,batch:()=>F2});function N5(){try{let Z=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync(e6());return Z=Z.replace(/\}(var |let |const |function )/g,"};$1"),Z}catch{return e6()}}function e6(){return`
1973
1973
  // STX Signals Runtime (Development Build)
1974
1974
  console.log('[stx] signals runtime loading');
1975
1975
  // Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
@@ -6062,7 +6062,7 @@ catch (e) { console.warn('[stx] mount callback error:', e); }
6062
6062
  }
6063
6063
  }
6064
6064
  })();
6065
- `}var _N;var R5=D(()=>{iZ();iZ();_N={state:H2,derived:O2,effect:L2,batch:F2,onMount:V2,onDestroy:A2,isSignal:A5,isDerived:w5,untrack:w2,peek:N2,generateSignalsRuntime:N5,generateSignalsRuntimeDev:e4}});var aZ={};e(aZ,{templateCache:()=>rZ,readFileCached:()=>vU,invalidateFileCacheByDir:()=>fU,invalidateFileCache:()=>gU,hashFilePath:()=>g6,getCachedSignalsRuntime:()=>hU,getCachedRouterScript:()=>dU,clearDevCaches:()=>uU,checkCache:()=>E2,cacheTemplate:()=>T2});import I4 from"fs";import v6 from"path";async function vU($){let Y;for(let X=0;X<3;X++)try{let Q=(await I4.promises.stat($)).mtime.getTime(),G=$6.get($);if(G&&G.mtime===Q)return G.content;let K=await Bun.file($).text(),U=(await I4.promises.stat($)).mtime.getTime();if(U!==Q)continue;return $6.set($,{content:K,mtime:U}),K}catch(J){Y=J;break}throw $6.delete($),Error(`File not found: ${$}${Y?` (${Y.message})`:""}`)}function gU($){$6.delete($)}function fU($){for(let Z of $6.keys())if(Z.startsWith($))$6.delete(Z)}async function hU($=!1){if($){let{generateSignalsRuntimeDev:Z}=await Promise.resolve().then(() => (R5(),nZ));return Z()}if(R2===null){let{generateSignalsRuntime:Z}=await Promise.resolve().then(() => (R5(),nZ));R2=Z()}return R2}async function dU(){if(M2===null){let{getRouterScript:$}=await import("stx-router");M2=$()}return M2}function uU(){$6.clear(),R2=null,BN=null,M2=null}async function E2($,Z){try{if(!Z.cachePath)return null;let Y=v6.resolve(Z.cachePath),X=v6.join(Y,`${g6($)}.html`),J=v6.join(Y,`${g6($)}.meta.json`);if(!await X0(X)||!await X0(J))return null;let Q=await Bun.file(J).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if((await I4.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await X0(W)){if((await I4.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 T2($,Z,Y,X){try{if(!X.cachePath)return;let J=v6.resolve(X.cachePath);await I4.promises.mkdir(J,{recursive:!0});let Q=v6.join(J,`${g6($)}.html`),G=v6.join(J,`${g6($)}.meta.json`),K=await I4.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)),rZ.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(J){console.warn(`Failed to cache template ${$}:`,J)}}function g6($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,zN)}var rZ,$6,R2=null,BN=null,M2=null,zN=16;var I2=D(()=>{H0();rZ=new Map,$6=new Map});function mU($){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]+`
6065
+ `}var _N;var R5=D(()=>{iZ();iZ();_N={state:H2,derived:O2,effect:L2,batch:F2,onMount:V2,onDestroy:A2,isSignal:A5,isDerived:w5,untrack:w2,peek:N2,generateSignalsRuntime:N5,generateSignalsRuntimeDev:e6}});var aZ={};e(aZ,{templateCache:()=>rZ,readFileCached:()=>vU,invalidateFileCacheByDir:()=>fU,invalidateFileCache:()=>gU,hashFilePath:()=>g4,getCachedSignalsRuntime:()=>hU,getCachedRouterScript:()=>dU,clearDevCaches:()=>uU,checkCache:()=>E2,cacheTemplate:()=>T2});import I6 from"fs";import v4 from"path";async function vU($){let Y;for(let X=0;X<3;X++)try{let Q=(await I6.promises.stat($)).mtime.getTime(),G=$4.get($);if(G&&G.mtime===Q)return G.content;let K=await Bun.file($).text(),U=(await I6.promises.stat($)).mtime.getTime();if(U!==Q)continue;return $4.set($,{content:K,mtime:U}),K}catch(J){Y=J;break}throw $4.delete($),Error(`File not found: ${$}${Y?` (${Y.message})`:""}`)}function gU($){$4.delete($)}function fU($){for(let Z of $4.keys())if(Z.startsWith($))$4.delete(Z)}async function hU($=!1){if($){let{generateSignalsRuntimeDev:Z}=await Promise.resolve().then(() => (R5(),nZ));return Z()}if(R2===null){let{generateSignalsRuntime:Z}=await Promise.resolve().then(() => (R5(),nZ));R2=Z()}return R2}async function dU(){if(M2===null){let{getRouterScript:$}=await import("stx-router");M2=$()}return M2}function uU(){$4.clear(),R2=null,BN=null,M2=null}async function E2($,Z){try{if(!Z.cachePath)return null;let Y=v4.resolve(Z.cachePath),X=v4.join(Y,`${g4($)}.html`),J=v4.join(Y,`${g4($)}.meta.json`);if(!await X0(X)||!await X0(J))return null;let Q=await Bun.file(J).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if((await I6.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await X0(W)){if((await I6.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 T2($,Z,Y,X){try{if(!X.cachePath)return;let J=v4.resolve(X.cachePath);await I6.promises.mkdir(J,{recursive:!0});let Q=v4.join(J,`${g4($)}.html`),G=v4.join(J,`${g4($)}.meta.json`),K=await I6.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)),rZ.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(J){console.warn(`Failed to cache template ${$}:`,J)}}function g4($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,zN)}var rZ,$4,R2=null,BN=null,M2=null,zN=16;var I2=D(()=>{H0();rZ=new Map,$4=new Map});function mU($){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]+`
6066
6066
  `;let J=/\{\{([\s\S]*?)\}\}/g;while((X=J.exec($))!==null)Y+=X[1]+`
6067
6067
  `;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">
6068
6068
  // STX: Auto-load @stacksjs/browser (auto-initializes API and loads models)
@@ -6078,11 +6078,11 @@ ${B}`);return B+`
6078
6078
  `+$.slice(Q);if($.includes("</head>")){let G=$.indexOf("</head>");return $.slice(0,G)+J+`
6079
6079
  `+$.slice(G)}if($.includes("<body")){let G=$.indexOf("<body"),K=$.indexOf(">",G);return $.slice(0,K+1)+`
6080
6080
  `+J+$.slice(K+1)}return J+`
6081
- `+$}async function D4($,Z){if(!$.includes("</body>"))return $;if($.includes("__stxRouter)return")||$.includes("__stxRouter=true"))return $;let Y=Z?.router,X="";if(Y){let K={};if(Y.container)K.container=Y.container;if(Y.viewTransitions!==void 0)K.viewTransitions=Y.viewTransitions;if(Y.viewTransitionDuration!==void 0)K.viewTransitionDuration=Y.viewTransitionDuration;if(Y.viewTransitionEasing!==void 0)K.viewTransitionEasing=Y.viewTransitionEasing;if(Y.scrollToTop!==void 0)K.scrollToTop=Y.scrollToTop;if(Y.prefetch!==void 0)K.prefetch=Y.prefetch;if(Y.cache!==void 0)K.cache=Y.cache;if(Y.progressColor!==void 0)K.progressColor=Y.progressColor;if(Y.progressHeight!==void 0)K.progressHeight=Y.progressHeight;if(Object.keys(K).length>0)X=`<script>window.__stxRouterConfig=${JSON.stringify(K)};</script>
6081
+ `+$}async function D6($,Z){if(!$.includes("</body>"))return $;if($.includes("__stxRouter)return")||$.includes("__stxRouter=true"))return $;let Y=Z?.router,X="";if(Y){let K={};if(Y.container)K.container=Y.container;if(Y.viewTransitions!==void 0)K.viewTransitions=Y.viewTransitions;if(Y.viewTransitionDuration!==void 0)K.viewTransitionDuration=Y.viewTransitionDuration;if(Y.viewTransitionEasing!==void 0)K.viewTransitionEasing=Y.viewTransitionEasing;if(Y.scrollToTop!==void 0)K.scrollToTop=Y.scrollToTop;if(Y.prefetch!==void 0)K.prefetch=Y.prefetch;if(Y.cache!==void 0)K.cache=Y.cache;if(Y.progressColor!==void 0)K.progressColor=Y.progressColor;if(Y.progressHeight!==void 0)K.progressHeight=Y.progressHeight;if(Object.keys(K).length>0)X=`<script>window.__stxRouterConfig=${JSON.stringify(K)};</script>
6082
6082
  `}let{getCachedRouterScript:J}=await Promise.resolve().then(() => (I2(),aZ)),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+`
6083
6083
  </body>`+$.slice(G+7)}var sU={};e(sU,{scanScriptTags:()=>iU,processSignals:()=>tZ,processScriptSetup:()=>rU,parseLoopExpression:()=>nU,hasSignalsSyntax:()=>k2,extractExports:()=>aU,convertSignalLoopsToAttributes:()=>oZ,convertSignalDirectivesToAttributes:()=>sZ});function iU($,Z={}){let Y=[];D2.lastIndex=0;let X;while((X=D2.exec($))!==null){let J=X[1],Q=X.index+X[0].length,G=$.toLowerCase().indexOf("</script>",Q);if(G===-1)break;let K=G+9;if(Z.skipAttrs&&Z.skipAttrs.test(J)){D2.lastIndex=K;continue}Y.push({fullMatch:$.slice(X.index,K),attrs:J,body:$.slice(Q,G),start:X.index,end:K}),D2.lastIndex=K}return Y}function nU($){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}=lU(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}=lU(J);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function lU($){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 k2($){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 jN($){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 sZ($){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(jN(H))continue;let O=H.match(pU),F;if(O){let[,L,V,w]=O,A=U.replace(/"/g,"&quot;");F=`<${L}${V} @if="${A}">${w}</${L}>`}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 oZ($,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=nU(B);if(q.iterable){let N=q.iterable.trim();if(N.startsWith("[")||N.startsWith("{")||N.startsWith("'")||N.startsWith('"')||N.startsWith("`")||/^-?\d/.test(N))continue;if(Z){let M=N.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,O=z,F=G==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${G}\\s*\\(|end${G})`,"g");F.lastIndex=z;let L;while((L=F.exec(Y))!==null)if(L[1].startsWith(G))H++;else if(H--,H===0){O=L.index+L[0].length;break}if(H!==0)continue;let V=Y.substring(z,O-j.length).trim(),w=V.match(pU),A;if(w){let[,N,M,E]=w;A=`<${N}${M} @for="${B}">${E}</${N}>`}else A=`<template @for="${B}">${V}</template>`;Q.push({start:K,end:O,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 HN($){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&&$[_]!==`
6084
6084
  `)_++;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]!==`
6085
- `)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 rU($,Z){let Y=iU($,{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()}_${qN++}`,{hasUserImports:G,bundleClientScript:K}=await Promise.resolve().then(() => (b8(),S8)),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
6085
+ `)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 rU($,Z){let Y=iU($,{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()}_${qN++}`,{hasUserImports:G,bundleClientScript:K}=await Promise.resolve().then(() => (b8(),S8)),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
6086
6086
  ${H}`)}let U=W.join(`
6087
6087
 
6088
6088
  `);U=HN(U);let _=aU(U),B=`
@@ -6126,7 +6126,7 @@ ${k}
6126
6126
  @media(prefers-color-scheme:dark){[data-stx-modal]{--stx-modal-bg:#1f2937;--stx-modal-text:#f3f4f6}}
6127
6127
  .stx-modal-backdrop[data-stx-modal-open]{display:flex!important;opacity:1}
6128
6128
  .stx-modal-backdrop[data-stx-modal-open] .stx-modal-panel{transform:scale(1) translateY(0);opacity:1}
6129
- </style>`}}});function f6($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var J_,OY;var LY=D(()=>{J_={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},OY={name:"StxDrawer",aliases:["stx-drawer"],render($,Z,Y){let X=f6($,"id");if(!X)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let J=f6($,"side")||"right",Q=f6($,"size")||"md",G=f6($,"closeOnBackdrop")!=="false",K=f6($,"closeOnEscape")!=="false",W=f6($,"overlay")!=="false",U=J_[Q]||J_.md,_=J==="left",B=_?"left:0":"right:0",z=_?"translateX(-100%)":"translateX(100%)",q=_?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${X}" class="stx-drawer-backdrop" data-stx-drawer="${X}" data-close-backdrop="${G}" data-close-escape="${K}" style="display:none;position:fixed;inset:0;z-index:99999;${W?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
6129
+ </style>`}}});function f4($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var J_,OY;var LY=D(()=>{J_={sm:"16rem",md:"24rem",lg:"32rem",xl:"40rem"},OY={name:"StxDrawer",aliases:["stx-drawer"],render($,Z,Y){let X=f4($,"id");if(!X)return console.warn('[stx] <StxDrawer> requires an "id" prop'),"<!-- StxDrawer: missing id prop -->";let J=f4($,"side")||"right",Q=f4($,"size")||"md",G=f4($,"closeOnBackdrop")!=="false",K=f4($,"closeOnEscape")!=="false",W=f4($,"overlay")!=="false",U=J_[Q]||J_.md,_=J==="left",B=_?"left:0":"right:0",z=_?"translateX(-100%)":"translateX(100%)",q=_?"stx-drawer-slide-left":"stx-drawer-slide-right";return`<div id="stx-drawer-${X}" class="stx-drawer-backdrop" data-stx-drawer="${X}" data-close-backdrop="${G}" data-close-escape="${K}" style="display:none;position:fixed;inset:0;z-index:99999;${W?"background:rgba(0,0,0,0.5);backdrop-filter:blur(2px)":"background:transparent;pointer-events:none"};opacity:0;transition:opacity 0.2s ease" role="dialog" aria-modal="true">
6130
6130
  <div class="stx-drawer-panel" style="position:fixed;top:0;bottom:0;${B};width:${U};max-width:100vw;transform:${z};transition:transform 0.3s cubic-bezier(0.4,0,0.2,1);background:var(--stx-drawer-bg,#fff);color:var(--stx-drawer-text,#1f2937);box-shadow:0 20px 60px rgba(0,0,0,0.3);overflow-y:auto;pointer-events:auto">
6131
6131
  <div style="padding:1.5rem">${Z}</div>
6132
6132
  </div>
@@ -6135,24 +6135,24 @@ ${k}
6135
6135
  @media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
6136
6136
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
6137
6137
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
6138
- </style>`}}});var K_={};e(K_,{preloadIconCollection:()=>G_,IconBuiltin:()=>C2});async function Q_($){if(T5.has($))return T5.get($);try{let Z=s.resolve(`@iconify/json/json/${$}.json`),Y=await Bun.file(Z).json();return T5.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 T5.set($,J.icons),J.icons}}catch{}}return null}function h6($,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 G_($="lucide"){await Q_($)}var T5,C2;var P2=D(()=>{T5=new Map;C2={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=h6($,"name")??h6($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let L=X.split(":");J=L[0],Q=L[1]}let G=h6($,"size")||"24",K=h6($,"color")||"currentColor",W=h6($,"class")||"",U=h6($,"style")||"",_=T5.get(J);if(!_)return Q_(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 O=W?` class="${W}"`:"",F=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${F}>${H}</svg>`}}});function W_(){g1.registerBuiltin(YY),g1.registerBuiltin(KY),g1.registerBuiltin(_Y),g1.registerBuiltin(zY),g1.registerBuiltin(jY),g1.registerBuiltin(OY),g1.registerBuiltin(C2)}var U_=D(()=>{XY();WY();BY();qY();HY();LY();P2();ZY();XY();WY();BY();qY();HY();LY();P2()});function __($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function B_($,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}`,O=`</${W}>`,F=1,L=z,V=-1;while(F>0&&L<$.length){let N=$.indexOf(H,L),M=$.indexOf(O,L);if(M===-1)break;if(N!==-1&&N<M){let E=$[N+H.length];if(E===" "||E===">"||E==="/"||E===`
6139
- `||E==="\t")F++;L=N+H.length}else{if(F--,F===0){V=M;break}L=M+O.length}}if(V===-1){J=z;continue}let w=$.slice(z,V),A=V+O.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:w,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}var z_=D(()=>{n0();H0()});import d6 from"path";function NN($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));try{let _=K.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");X.serverDynamic[U]=JSON.parse(_)}catch(_){if(Y.debug)console.error(`Error parsing __stx_${U}:`,_);X.serverDynamic[U]=K}continue}if(W.startsWith(":")){let U=Q(W.slice(1)),_=K==="true"?U:K;try{if(!O0(_)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${_}`);X.clientReactive[U]=_;continue}let B=Object.keys(Z),q=V0(_,B)(...Object.values(Z));if(q===void 0){let j=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!B.includes(F))){X.clientReactive[U]=_;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=_}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let _=U[1];if(O0(_)){let z=V0(_,Object.keys(Z))(...Object.values(Z));X.static[W]=z!=null?String(z):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${_}`);X.static[W]=K}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,_);X.static[W]=K}else{let _=K,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=B.exec(K))!==null)try{let q=z[1];if(!O0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=V0(q,Object.keys(Z))(...Object.values(Z));_=_.replace(z[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=_}continue}X.static[W]=K}return X}function RN($){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 MN($,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$/,""),O=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,L=[d6.resolve(d6.dirname(Y),`${z}.stx`),d6.resolve(d6.dirname(Y),z),d6.resolve(X.componentsDir||"components",`${z}.stx`),d6.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of L)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(O,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${O} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function EN($,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,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let F=O[1],L,V=j.slice(O[0].length),w=V.match(/^\s*,\s*/);if(w)L=V.slice(w[0].length).trim();let A={};if(L)try{A=x0(L,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 N="",M=H,I=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)N=I[1].trim(),M=H+I[0].length;let T=await v1(F,A,N,G,Z,Y,X,K,J);Q=Q.substring(0,_)+T+Q.substring(M),W.lastIndex=0}return Q}async function TN($,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,wN),Q;async function B(z,q,j,H){if(!z)return z;let O=z,F=B_(O,q,H);for(let L=F.length-1;L>=0;L--){let V=F[L],w=j?__(V.tagName):V.tagName,A=RN(V.attributes),N=NN(A,Z,X),M=g1.getBuiltin(V.tagName);if(M){let S={context:Z,filePath:Y,options:X,dependencies:J},k=M.render(N,V.content,S);if(Object.keys(N.clientReactive).length>0)k=j_(k,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([y,v])=>`${y}="${v.replace(/"/g,"&quot;")}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}O=O.substring(0,V.startIndex)+k+O.substring(V.endIndex);continue}let E={};for(let[S,k]of Object.entries(N.static))E[S]=k;for(let[S,k]of Object.entries(N.serverDynamic))E[S]=k;let T=await v1(w,E,V.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)T=j_(T,N.clientReactive);if(Object.keys(N.events).length>0){let S=T.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(S){let k=Object.entries(N.events).map(([y,v])=>`${y}="${v}"`).join(" "),b=S[1].length+S[2].length;T=T.substring(0,b)+" "+k+T.substring(b)}}O=O.substring(0,V.startIndex)+T+O.substring(V.endIndex)}return O}}function j_($,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 FY($,Z,Y,X,J){if(!q_)W_(),q_=!0;let Q=await MN($,Z,Y,X,J);Q=await EN(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await TN(Q,Z,Y,X,J),Q===K)break}return Q}var q_=!1,wN;var H_=D(()=>{ZY();U_();z_();H0();n0();wN=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 u6 from"path";function O_($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}function L_($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=u6.join(J,$);if(s("fs").existsSync(G))return G;J=u6.dirname(J)}X=u6.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=u6.resolve(Z,$);else X=u6.resolve(Z,$);if(s("fs").existsSync(X))return X;return null}catch{return null}}async function F_($,Z,Y){let X=$,J=u6.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,B,z]=G;if(O_(B))continue;let q=L_(B,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),B.endsWith(".ts")||B.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:H1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
6138
+ </style>`}}});var K_={};e(K_,{preloadIconCollection:()=>G_,IconBuiltin:()=>C2});async function Q_($){if(T5.has($))return T5.get($);try{let Z=s.resolve(`@iconify/json/json/${$}.json`),Y=await Bun.file(Z).json();return T5.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 T5.set($,J.icons),J.icons}}catch{}}return null}function h4($,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 G_($="lucide"){await Q_($)}var T5,C2;var P2=D(()=>{T5=new Map;C2={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=h4($,"name")??h4($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let L=X.split(":");J=L[0],Q=L[1]}let G=h4($,"size")||"24",K=h4($,"color")||"currentColor",W=h4($,"class")||"",U=h4($,"style")||"",_=T5.get(J);if(!_)return Q_(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 O=W?` class="${W}"`:"",F=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${F}>${H}</svg>`}}});function W_(){g1.registerBuiltin(YY),g1.registerBuiltin(KY),g1.registerBuiltin(_Y),g1.registerBuiltin(zY),g1.registerBuiltin(jY),g1.registerBuiltin(OY),g1.registerBuiltin(C2)}var U_=D(()=>{XY();WY();BY();qY();HY();LY();P2();ZY();XY();WY();BY();qY();HY();LY();P2()});function __($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function B_($,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}`,O=`</${W}>`,F=1,L=z,V=-1;while(F>0&&L<$.length){let N=$.indexOf(H,L),M=$.indexOf(O,L);if(M===-1)break;if(N!==-1&&N<M){let E=$[N+H.length];if(E===" "||E===">"||E==="/"||E===`
6139
+ `||E==="\t")F++;L=N+H.length}else{if(F--,F===0){V=M;break}L=M+O.length}}if(V===-1){J=z;continue}let w=$.slice(z,V),A=V+O.length;X.push({fullMatch:$.slice(Q,A),tagName:W,attributes:j,content:w,startIndex:Q,endIndex:A,isSelfClosing:!1}),J=A}}return X}var z_=D(()=>{n0();H0()});import d4 from"path";function NN($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));try{let _=K.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");X.serverDynamic[U]=JSON.parse(_)}catch(_){if(Y.debug)console.error(`Error parsing __stx_${U}:`,_);X.serverDynamic[U]=K}continue}if(W.startsWith(":")){let U=Q(W.slice(1)),_=K==="true"?U:K;try{if(!O0(_)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${_}`);X.clientReactive[U]=_;continue}let B=Object.keys(Z),q=V0(_,B)(...Object.values(Z));if(q===void 0){let j=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!B.includes(F))){X.clientReactive[U]=_;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=_}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let _=U[1];if(O0(_)){let z=V0(_,Object.keys(Z))(...Object.values(Z));X.static[W]=z!=null?String(z):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${_}`);X.static[W]=K}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,_);X.static[W]=K}else{let _=K,B=/\{\{\s*([\s\S]+?)\s*\}\}/g,z;while((z=B.exec(K))!==null)try{let q=z[1];if(!O0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=V0(q,Object.keys(Z))(...Object.values(Z));_=_.replace(z[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=_}continue}X.static[W]=K}return X}function RN($){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 MN($,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$/,""),O=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,L=[d4.resolve(d4.dirname(Y),`${z}.stx`),d4.resolve(d4.dirname(Y),z),d4.resolve(X.componentsDir||"components",`${z}.stx`),d4.resolve(X.componentsDir||"components",z),z.endsWith(".stx")?z:`${z}.stx`];for(let V of L)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(O,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${O} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${z}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function EN($,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,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let F=O[1],L,V=j.slice(O[0].length),w=V.match(/^\s*,\s*/);if(w)L=V.slice(w[0].length).trim();let A={};if(L)try{A=x0(L,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 N="",M=H,I=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(I)N=I[1].trim(),M=H+I[0].length;let T=await v1(F,A,N,G,Z,Y,X,K,J);Q=Q.substring(0,_)+T+Q.substring(M),W.lastIndex=0}return Q}async function TN($,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,wN),Q;async function B(z,q,j,H){if(!z)return z;let O=z,F=B_(O,q,H);for(let L=F.length-1;L>=0;L--){let V=F[L],w=j?__(V.tagName):V.tagName,A=RN(V.attributes),N=NN(A,Z,X),M=g1.getBuiltin(V.tagName);if(M){let S={context:Z,filePath:Y,options:X,dependencies:J},k=M.render(N,V.content,S);if(Object.keys(N.clientReactive).length>0)k=j_(k,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([y,v])=>`${y}="${v.replace(/"/g,"&quot;")}"`).join(" ");k=k.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}O=O.substring(0,V.startIndex)+k+O.substring(V.endIndex);continue}let E={};for(let[S,k]of Object.entries(N.static))E[S]=k;for(let[S,k]of Object.entries(N.serverDynamic))E[S]=k;let T=await v1(w,E,V.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)T=j_(T,N.clientReactive);if(Object.keys(N.events).length>0){let S=T.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(S){let k=Object.entries(N.events).map(([y,v])=>`${y}="${v}"`).join(" "),b=S[1].length+S[2].length;T=T.substring(0,b)+" "+k+T.substring(b)}}O=O.substring(0,V.startIndex)+T+O.substring(V.endIndex)}return O}}function j_($,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 FY($,Z,Y,X,J){if(!q_)W_(),q_=!0;let Q=await MN($,Z,Y,X,J);Q=await EN(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await TN(Q,Z,Y,X,J),Q===K)break}return Q}var q_=!1,wN;var H_=D(()=>{ZY();U_();z_();H0();n0();wN=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 u4 from"path";function O_($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}function L_($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=u4.join(J,$);if(s("fs").existsSync(G))return G;J=u4.dirname(J)}X=u4.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=u4.resolve(Z,$);else X=u4.resolve(Z,$);if(s("fs").existsSync(X))return X;return null}catch{return null}}async function F_($,Z,Y){let X=$,J=u4.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,B,z]=G;if(O_(B))continue;let q=L_(B,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),B.endsWith(".ts")||B.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:H1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
6140
6140
  // Source: ${B}
6141
6141
  ${j}
6142
6142
  </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(O_(B))continue;if(/rel=["']stylesheet["']/.test(q)||B.endsWith(".css")){let H=L_(B,J,Z);if(H)try{let O=await Bun.file(H).text();Y.add(H);let F=`<style>
6143
6143
  /* Source: ${B} */
6144
6144
  ${O}
6145
- </style>`;X=X.replace(U,F),K.lastIndex=0}catch(O){}}}return X}var V_=D(()=>{r4()});function I5($,Z){let Y=$,X=/@json\s*\(/g,J;while((J=X.exec(Y))!==null){let Q=J.index,G=Q+J[0].length-1,K=1,W=G+1,U=null,_=!1;while(W<Y.length&&K>0){let V=Y[W];if(_){_=!1,W++;continue}if(V==="\\"&&U){_=!0,W++;continue}if(U){if(V===U)U=null;W++;continue}if(V==='"'||V==="'"||V==="`"){U=V,W++;continue}if(V==="(")K++;else if(V===")"){if(K--,K===0)break}W++}if(K!==0)break;let B=Y.substring(G+1,W).trim(),z=Y.substring(Q,W+1),q=-1,j=0,H=null,O=!1;for(let V=0;V<B.length;V++){let w=B[V];if(O){O=!1;continue}if(w==="\\"&&H){O=!0;continue}if(H){if(w===H)H=null;continue}if(w==='"'||w==="'"||w==="`"){H=w;continue}if(w==="("||w==="["||w==="{")j++;else if(w===")"||w==="]"||w==="}")j--;if(w===","&&j===0){q=V;break}}let F=q>=0?B.substring(0,q).trim():B,L=q>=0?B.substring(q+1).trim():void 0;try{let V=F.trim(),w;if(O0(V))w=V0(V,Object.keys(Z))(...Object.values(Z));else w=void 0;let A;if(L==="true")A=JSON.stringify(w,null,2);else A=JSON.stringify(w);let N=A.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+N+Y.substring(W+1),X.lastIndex=Q+N.length}catch(V){a0.log(V instanceof Error?V:Error(String(V)),{directive:"@json"},"error"),X.lastIndex=Q+z.length}}return Y}function D5($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function A_($){let Z=$,Y=/@memo\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.slice(G,W-1).trim(),_=W,B=Z.slice(_),z=B.indexOf("@endmemo");if(z===-1)continue;let q=B.slice(0,z),j=_+z+8,H=q.match(/^(\s*(?:<!--[\s\S]*?-->\s*)*)/),O=H?H[0].length:0,F=q.slice(O),L=q.match(/(\s*)$/),V=L?L[0].length:0,w=F.slice(0,F.length-V),A=w.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),N;if(A){let[M,E,I="",T]=A,S=`<${E}${I} data-stx-memo="${U}"${T}>`;N=q.slice(0,O)+S+w.slice(M.length)+q.slice(O+w.length)}else N=`${q.slice(0,O)}<div data-stx-memo="${U}">${w}</div>${q.slice(O+w.length)}`;J.push({start:Q,end:j,replacement:N}),Y.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function VY($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function w_($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),X="",J=0,Q;while((Q=Y.exec($))!==null){let G=Q.index,K=G+Q[0].length,W=!1,U=!1,_=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(U){if(H==='"')U=!1}else if(H==="'")W=!0;else if(H==='"')U=!0;else if(H===">"){_=K;break}K++}if(_===-1)continue;if($.slice(G,_+1).includes("x-cloak"))continue;let z=$.slice(_+1),q=z.indexOf("</"),j=q>=0?z.slice(0,q):z.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,_)+" x-cloak>",J=_+1}return X+=$.slice(J),X}var AY=D(()=>{z1();n0()});function k5($,Z,Y){let X=typeof Y==="boolean"?{enabled:Y,failOnViolation:Y}:Y??{enabled:!1},J=X.allowPatterns??[],Q=[];for(let{pattern:G,message:K,suggestion:W}of IN){if(J.some((_)=>K.includes(_)||G.source.includes(_)))continue;G.lastIndex=0;let U=$.match(G);if(U&&U.length>0){let _=$.split(`
6145
+ </style>`;X=X.replace(U,F),K.lastIndex=0}catch(O){}}}return X}var V_=D(()=>{r6()});function I5($,Z){let Y=$,X=/@json\s*\(/g,J;while((J=X.exec(Y))!==null){let Q=J.index,G=Q+J[0].length-1,K=1,W=G+1,U=null,_=!1;while(W<Y.length&&K>0){let V=Y[W];if(_){_=!1,W++;continue}if(V==="\\"&&U){_=!0,W++;continue}if(U){if(V===U)U=null;W++;continue}if(V==='"'||V==="'"||V==="`"){U=V,W++;continue}if(V==="(")K++;else if(V===")"){if(K--,K===0)break}W++}if(K!==0)break;let B=Y.substring(G+1,W).trim(),z=Y.substring(Q,W+1),q=-1,j=0,H=null,O=!1;for(let V=0;V<B.length;V++){let w=B[V];if(O){O=!1;continue}if(w==="\\"&&H){O=!0;continue}if(H){if(w===H)H=null;continue}if(w==='"'||w==="'"||w==="`"){H=w;continue}if(w==="("||w==="["||w==="{")j++;else if(w===")"||w==="]"||w==="}")j--;if(w===","&&j===0){q=V;break}}let F=q>=0?B.substring(0,q).trim():B,L=q>=0?B.substring(q+1).trim():void 0;try{let V=F.trim(),w;if(O0(V))w=V0(V,Object.keys(Z))(...Object.values(Z));else w=void 0;let A;if(L==="true")A=JSON.stringify(w,null,2);else A=JSON.stringify(w);let N=A.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+N+Y.substring(W+1),X.lastIndex=Q+N.length}catch(V){a0.log(V instanceof Error?V:Error(String(V)),{directive:"@json"},"error"),X.lastIndex=Q+z.length}}return Y}function D5($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function A_($){let Z=$,Y=/@memo\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.slice(G,W-1).trim(),_=W,B=Z.slice(_),z=B.indexOf("@endmemo");if(z===-1)continue;let q=B.slice(0,z),j=_+z+8,H=q.match(/^(\s*(?:<!--[\s\S]*?-->\s*)*)/),O=H?H[0].length:0,F=q.slice(O),L=q.match(/(\s*)$/),V=L?L[0].length:0,w=F.slice(0,F.length-V),A=w.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),N;if(A){let[M,E,I="",T]=A,S=`<${E}${I} data-stx-memo="${U}"${T}>`;N=q.slice(0,O)+S+w.slice(M.length)+q.slice(O+w.length)}else N=`${q.slice(0,O)}<div data-stx-memo="${U}">${w}</div>${q.slice(O+w.length)}`;J.push({start:Q,end:j,replacement:N}),Y.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function VY($){let Z=$.replace(/@ref="([^"]+)"/g,'data-stx-ref="$1"');return Z=Z.replace(/(<[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?)\sref="([^"]+)"/g,'$1 data-stx-ref="$2"'),Z}function w_($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),X="",J=0,Q;while((Q=Y.exec($))!==null){let G=Q.index,K=G+Q[0].length,W=!1,U=!1,_=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(U){if(H==='"')U=!1}else if(H==="'")W=!0;else if(H==='"')U=!0;else if(H===">"){_=K;break}K++}if(_===-1)continue;if($.slice(G,_+1).includes("x-cloak"))continue;let z=$.slice(_+1),q=z.indexOf("</"),j=q>=0?z.slice(0,q):z.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,_)+" x-cloak>",J=_+1}return X+=$.slice(J),X}var AY=D(()=>{z1();n0()});function k5($,Z,Y){let X=typeof Y==="boolean"?{enabled:Y,failOnViolation:Y}:Y??{enabled:!1},J=X.allowPatterns??[],Q=[];for(let{pattern:G,message:K,suggestion:W}of IN){if(J.some((_)=>K.includes(_)||G.source.includes(_)))continue;G.lastIndex=0;let U=$.match(G);if(U&&U.length>0){let _=$.split(`
6146
6146
  `),B=[];_.forEach((q,j)=>{if(G.lastIndex=0,G.test(q))B.push(j+1)});let z=B.length>0?` (line${B.length>1?"s":""}: ${B.join(", ")})`:"";Q.push(` \u2717 ${K}${z}
6147
6147
  \u2192 ${W}`)}}if(Q.length>0&&X.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
6148
6148
  ${Q.join(`
6149
6149
  `)}
6150
- Tip: prefer useRef(), navigate(), and composables for component code`;if(X.failOnViolation)throw Error(K);else console.warn(K)}}var IN;var wY=D(()=>{IN=[{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 N_={};e(N_,{getStoreScript:()=>DN,clearStoreCache:()=>kN});import y2 from"path";async function DN($){let Z;if($)Z=y2.resolve($);else{let _=await f0();Z=y2.resolve(_.root||process.cwd(),_.storesDir||"stores")}let Y=m6.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=y2.basename(_,".ts");if(["index","types"].includes(B))continue;if(_.includes(".d.ts"))continue;J.push(_)}}catch{return m6.set(Z,""),null}if(J.length===0)return m6.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",define:H1()});for(let _ of G)try{let B=await Bun.file(_).text(),z=y2.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}
6151
- ${B.trim()}`)}catch(B){console.warn(`[stx] Failed to load store ${_}:`,B)}if(K.length===0)return m6.set(Z,""),null;let U=`;(function(){
6150
+ Tip: prefer useRef(), navigate(), and composables for component code`;if(X.failOnViolation)throw Error(K);else console.warn(K)}}var IN;var wY=D(()=>{IN=[{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 N_={};e(N_,{getStoreScript:()=>DN,clearStoreCache:()=>kN});import y2 from"path";async function DN($){let Z;if($)Z=y2.resolve($);else{let _=await f0();Z=y2.resolve(_.root||process.cwd(),_.storesDir||"stores")}let Y=m4.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=y2.basename(_,".ts");if(["index","types"].includes(B))continue;if(_.includes(".d.ts"))continue;J.push(_)}}catch{return m4.set(Z,""),null}if(J.length===0)return m4.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",define:H1()});for(let _ of G)try{let B=await Bun.file(_).text(),z=y2.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}
6151
+ ${B.trim()}`)}catch(B){console.warn(`[stx] Failed to load store ${_}:`,B)}if(K.length===0)return m4.set(Z,""),null;let U=`;(function(){
6152
6152
  ${K.join(`
6153
6153
 
6154
6154
  `)}
6155
- })();`;return m6.set(Z,U),U}function kN(){m6.clear()}var m6;var R_=D(()=>{m0();r4();m6=new Map});var T_={};e(T_,{processDeferDirectives:()=>E_});function SN(){return`stx-defer-${++M_}`}function bN($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function CN($,Z,Y){let{trigger:X,value:J}=bN(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 PN($,Z){let{trigger:Y,triggerValue:X}=Z,J;switch(Y){case"visible":J=`
6155
+ })();`;return m4.set(Z,U),U}function kN(){m4.clear()}var m4;var R_=D(()=>{m0();r6();m4=new Map});var T_={};e(T_,{processDeferDirectives:()=>E_});function SN(){return`stx-defer-${++M_}`}function bN($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function CN($,Z,Y){let{trigger:X,value:J}=bN(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 PN($,Z){let{trigger:Y,triggerValue:X}=Z,J;switch(Y){case"visible":J=`
6156
6156
  const observer = new IntersectionObserver((entries) => {
6157
6157
  if (entries[0].isIntersecting) {
6158
6158
  observer.disconnect();
@@ -8368,8 +8368,8 @@ else {
8368
8368
  });
8369
8369
  })();
8370
8370
  </script>
8371
- `}function bY($,Z={},Y){let X=$,J=!1,Q=/@client:(load|idle|visible|media|only|hover|event)/i.test($);if(X=c6(X,"load",Z),X=c6(X,"idle",Z),X=c6(X,"visible",Z),X=c6(X,"media",Z),X=UR(X),X=c6(X,"hover",Z),X=c6(X,"event",Z),J=Q&&X!==$,J)X+=`
8372
- `+IY();return X}function c6($,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((O)=>O.trim());for(let O of H){let[F,L]=O.split(":").map((V)=>V.trim());if(F&&L){let V=L.replace(/^['"]|['"]$/g,"");K[F]=V}}}catch{}let W=`island-${Math.random().toString(36).substring(2,9)}`,U=DY(G.trim()),_=kY(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?`
8371
+ `}function bY($,Z={},Y){let X=$,J=!1,Q=/@client:(load|idle|visible|media|only|hover|event)/i.test($);if(X=c4(X,"load",Z),X=c4(X,"idle",Z),X=c4(X,"visible",Z),X=c4(X,"media",Z),X=UR(X),X=c4(X,"hover",Z),X=c4(X,"event",Z),J=Q&&X!==$,J)X+=`
8372
+ `+IY();return X}function c4($,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((O)=>O.trim());for(let O of H){let[F,L]=O.split(":").map((V)=>V.trim());if(F&&L){let V=L.replace(/^['"]|['"]$/g,"");K[F]=V}}}catch{}let W=`island-${Math.random().toString(36).substring(2,9)}`,U=DY(G.trim()),_=kY(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?`
8373
8373
  <script type="application/json" data-island-props="${W}">${JSON.stringify(_)}</script>`:"",j="";switch(Z){case"load":j=XR(W);break;case"idle":j=JR(W,K);break;case"visible":j=QR(W,K);break;case"media":j=GR(W,K);break;case"hover":j=KR(W);break;case"event":j=WR(W,K);break}return`
8374
8374
  <div data-island="${W}"
8375
8375
  data-strategy="${Z}"
@@ -8444,7 +8444,7 @@ else {
8444
8444
  <script type="application/json" id="stx-island-manifest">
8445
8445
  ${JSON.stringify(Z)}
8446
8446
  </script>
8447
- `}var _R;var dY=D(()=>{_R={processPartialHydrationDirectives:bY,processStaticDirectives:fY,generatePartialHydrationCSS:CY,generateIslandManifest:hY,createIslandRegistry:SY,hydrateIsland:PY,hydrateByStrategy:yY,hydrateAll:xY,isHydrated:vY,onHydrated:gY}});var EB={};e(EB,{watchMultiple:()=>VB,watchEffect:()=>AB,watch:()=>FB,unref:()=>HB,toRefs:()=>OB,throttledComputed:()=>MB,stxWatchMultiple:()=>VB,stxWatchEffect:()=>AB,stxWatch:()=>FB,stxUnref:()=>HB,stxToRefs:()=>OB,stxThrottledComputed:()=>MB,stxShallowRef:()=>LB,stxRef:()=>l6,stxIsRef:()=>k4,stxDebouncedComputed:()=>RB,stxComputed:()=>b5,shallowRef:()=>LB,ref:()=>l6,processWatchDirectives:()=>NB,processComputedDirectives:()=>wB,isRef:()=>k4,default:()=>BR,debouncedComputed:()=>RB,computed:()=>b5});function l6($){let Z=$,Y=new Set,X={get value(){if(h1){let J=S5.get(X);if(!J)J=new Set,S5.set(X,J);J.add(h1)}return Z},set value(J){if(!Object.is(Z,J)){Z=J,Y.forEach((G)=>G(J));let Q=S5.get(X);if(Q)Q.forEach((G)=>G())}},subscribe(J){return Y.add(J),()=>Y.delete(J)},peek(){return Z}};return X}function k4($){return $!==null&&typeof $==="object"&&"value"in $&&"subscribe"in $&&"peek"in $}function HB($){return k4($)?$.value:$}function OB($){let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=l6($[Y]);return Z}function LB($){return l6($)}function b5($){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=h1;h1=U,g2.push(U);try{return Y()}finally{g2.pop(),h1=z}}let B={get value(){if(h1){let z=S5.get(B);if(!z)z=new Set,S5.set(B,z);z.add(h1)}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 FB($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="pre",once:G=!1}=Y,K,W=!0,U=!1,_=()=>{if(k4($))return J?Z6($.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?Z6(j):j,G)q()};if(Q==="sync")H();else if(Q==="post")queueMicrotask(H);else Promise.resolve().then(H)},z=null;if(k4($))z=$.subscribe(()=>B());else z=b5($).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 VB($,Z,Y={}){let{immediate:X=!1,once:J=!1}=Y,Q=$.map((B)=>k4(B)?B.value:void 0),G=!0,K=!1,W=()=>{if(!G||K)return;let B=$.map((z)=>k4(z)?z.value:void 0);if(Z(B,Q),Q=[...B],J)_()},U=$.map((B)=>{if(k4(B))return B.subscribe(()=>W());return()=>{}});if(X)W();let _=()=>{G=!1,U.forEach((B)=>B())};return _.pause=()=>{K=!0},_.resume=()=>{K=!1},_}function AB($,Z={}){let{flush:Y="pre"}=Z,X,J=!0,Q=!1,G=()=>{if(!J||Q)return;if(X)X();let W=h1;h1=G,g2.push(G);try{X=$()}finally{g2.pop(),h1=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 wB($,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 NB($,Z={},Y){let X=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return $.replace(X,(J,Q,G)=>{return`
8447
+ `}var _R;var dY=D(()=>{_R={processPartialHydrationDirectives:bY,processStaticDirectives:fY,generatePartialHydrationCSS:CY,generateIslandManifest:hY,createIslandRegistry:SY,hydrateIsland:PY,hydrateByStrategy:yY,hydrateAll:xY,isHydrated:vY,onHydrated:gY}});var EB={};e(EB,{watchMultiple:()=>VB,watchEffect:()=>AB,watch:()=>FB,unref:()=>HB,toRefs:()=>OB,throttledComputed:()=>MB,stxWatchMultiple:()=>VB,stxWatchEffect:()=>AB,stxWatch:()=>FB,stxUnref:()=>HB,stxToRefs:()=>OB,stxThrottledComputed:()=>MB,stxShallowRef:()=>LB,stxRef:()=>l4,stxIsRef:()=>k6,stxDebouncedComputed:()=>RB,stxComputed:()=>b5,shallowRef:()=>LB,ref:()=>l4,processWatchDirectives:()=>NB,processComputedDirectives:()=>wB,isRef:()=>k6,default:()=>BR,debouncedComputed:()=>RB,computed:()=>b5});function l4($){let Z=$,Y=new Set,X={get value(){if(h1){let J=S5.get(X);if(!J)J=new Set,S5.set(X,J);J.add(h1)}return Z},set value(J){if(!Object.is(Z,J)){Z=J,Y.forEach((G)=>G(J));let Q=S5.get(X);if(Q)Q.forEach((G)=>G())}},subscribe(J){return Y.add(J),()=>Y.delete(J)},peek(){return Z}};return X}function k6($){return $!==null&&typeof $==="object"&&"value"in $&&"subscribe"in $&&"peek"in $}function HB($){return k6($)?$.value:$}function OB($){let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=l4($[Y]);return Z}function LB($){return l4($)}function b5($){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=h1;h1=U,g2.push(U);try{return Y()}finally{g2.pop(),h1=z}}let B={get value(){if(h1){let z=S5.get(B);if(!z)z=new Set,S5.set(B,z);z.add(h1)}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 FB($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="pre",once:G=!1}=Y,K,W=!0,U=!1,_=()=>{if(k6($))return J?Z4($.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?Z4(j):j,G)q()};if(Q==="sync")H();else if(Q==="post")queueMicrotask(H);else Promise.resolve().then(H)},z=null;if(k6($))z=$.subscribe(()=>B());else z=b5($).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 VB($,Z,Y={}){let{immediate:X=!1,once:J=!1}=Y,Q=$.map((B)=>k6(B)?B.value:void 0),G=!0,K=!1,W=()=>{if(!G||K)return;let B=$.map((z)=>k6(z)?z.value:void 0);if(Z(B,Q),Q=[...B],J)_()},U=$.map((B)=>{if(k6(B))return B.subscribe(()=>W());return()=>{}});if(X)W();let _=()=>{G=!1,U.forEach((B)=>B())};return _.pause=()=>{K=!0},_.resume=()=>{K=!1},_}function AB($,Z={}){let{flush:Y="pre"}=Z,X,J=!0,Q=!1,G=()=>{if(!J||Q)return;if(X)X();let W=h1;h1=G,g2.push(G);try{X=$()}finally{g2.pop(),h1=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 wB($,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 NB($,Z={},Y){let X=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return $.replace(X,(J,Q,G)=>{return`
8448
8448
  <script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
8449
8449
  (function() {
8450
8450
  // Watch implementation for ${Q}
@@ -8456,9 +8456,9 @@ else {
8456
8456
  }
8457
8457
  })();
8458
8458
  </script>
8459
- `})}function Z6($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>Z6(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((X,J)=>Y.set(Z6(J),Z6(X))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((X)=>Y.add(Z6(X))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=Z6($[Y]);return Z}function RB($,Z=100){let Y=l6($()),X=null,J=()=>{if(X)clearTimeout(X);X=setTimeout(()=>{Y.value=$()},Z)};return b5($).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 MB($,Z=100){let Y=l6($()),X=0,J=()=>{let G=Date.now();if(G-X>=Z)X=G,Y.value=$()};return b5($).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 h1=null,g2,S5,BR;var TB=D(()=>{g2=[],S5=new WeakMap;BR={ref:l6,computed:b5,watch:FB,watchMultiple:VB,watchEffect:AB,isRef:k4,unref:HB,toRefs:OB,shallowRef:LB,debouncedComputed:RB,throttledComputed:MB,processComputedDirectives:wB,processWatchDirectives:NB}});var SB={};e(SB,{v:()=>zR,processHasErrorsDirective:()=>kB,processFormValidationDirectives:()=>jR,processErrorsDirective:()=>DB,processErrorDirective:()=>IB,defineForm:()=>qR,Validator:()=>p6});class p6{rules=[];defaultValue="";addRule($){let Z=new p6;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 p6;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 p6;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 qR($,Z){let Y=Object.keys($),X={},J={},Q={},G={},K={};for(let L of Y)X[L]=Z?.[L]??$[L].getDefaultValue(),J[L]=[],Q[L]=!1,G[L]=!1,K[L]=!1;let W=!1;async function U(L){K[L]=!0;let V=await $[L].validate(X[L],X);return J[L]=V,K[L]=!1,V.length===0}async function _(){W=!0;let L=await Promise.all(Y.map(U));return W=!1,L.every(Boolean)}function B(){for(let L of Y)X[L]=Z?.[L]??$[L].getDefaultValue(),J[L]=[],Q[L]=!1,G[L]=!1}function z(L){for(let V of Y)if(V in L)X[V]=L[V],G[V]=!0}function q(L,V){X[L]=V,G[L]=!0}function j(L,V=!0){if(Q[L]=V,V)U(L)}function H(L){return{value:X[L],errors:J[L],touched:Q[L],dirty:G[L],valid:J[L].length===0,validating:K[L]}}function O(L){return async(V)=>{V?.preventDefault?.();for(let A of Y)Q[A]=!0;if(await _())await L(X)}}return{values:X,errors:J,touched:Q,dirty:G,get isValid(){return Y.every((L)=>J[L].length===0)},get isValidating(){return W||Y.some((L)=>K[L])},get isDirty(){return Y.some((L)=>G[L])},validate:_,validateField:U,reset:B,setValues:z,setFieldValue:q,setFieldTouched:j,getFieldState:H,handleSubmit:O}}function IB($,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(`
8459
+ `})}function Z4($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>Z4(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((X,J)=>Y.set(Z4(J),Z4(X))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((X)=>Y.add(Z4(X))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=Z4($[Y]);return Z}function RB($,Z=100){let Y=l4($()),X=null,J=()=>{if(X)clearTimeout(X);X=setTimeout(()=>{Y.value=$()},Z)};return b5($).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 MB($,Z=100){let Y=l4($()),X=0,J=()=>{let G=Date.now();if(G-X>=Z)X=G,Y.value=$()};return b5($).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 h1=null,g2,S5,BR;var TB=D(()=>{g2=[],S5=new WeakMap;BR={ref:l4,computed:b5,watch:FB,watchMultiple:VB,watchEffect:AB,isRef:k6,unref:HB,toRefs:OB,shallowRef:LB,debouncedComputed:RB,throttledComputed:MB,processComputedDirectives:wB,processWatchDirectives:NB}});var SB={};e(SB,{v:()=>zR,processHasErrorsDirective:()=>kB,processFormValidationDirectives:()=>jR,processErrorsDirective:()=>DB,processErrorDirective:()=>IB,defineForm:()=>qR,Validator:()=>p4});class p4{rules=[];defaultValue="";addRule($){let Z=new p4;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 p4;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 p4;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 qR($,Z){let Y=Object.keys($),X={},J={},Q={},G={},K={};for(let L of Y)X[L]=Z?.[L]??$[L].getDefaultValue(),J[L]=[],Q[L]=!1,G[L]=!1,K[L]=!1;let W=!1;async function U(L){K[L]=!0;let V=await $[L].validate(X[L],X);return J[L]=V,K[L]=!1,V.length===0}async function _(){W=!0;let L=await Promise.all(Y.map(U));return W=!1,L.every(Boolean)}function B(){for(let L of Y)X[L]=Z?.[L]??$[L].getDefaultValue(),J[L]=[],Q[L]=!1,G[L]=!1}function z(L){for(let V of Y)if(V in L)X[V]=L[V],G[V]=!0}function q(L,V){X[L]=V,G[L]=!0}function j(L,V=!0){if(Q[L]=V,V)U(L)}function H(L){return{value:X[L],errors:J[L],touched:Q[L],dirty:G[L],valid:J[L].length===0,validating:K[L]}}function O(L){return async(V)=>{V?.preventDefault?.();for(let A of Y)Q[A]=!0;if(await _())await L(X)}}return{values:X,errors:J,touched:Q,dirty:G,get isValid(){return Y.every((L)=>J[L].length===0)},get isValidating(){return W||Y.some((L)=>K[L])},get isDirty(){return Y.some((L)=>G[L])},validate:_,validateField:U,reset:B,setValues:z,setFieldValue:q,setFieldTouched:j,getFieldState:H,handleSubmit:O}}function IB($,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(`
8460
8460
  `)}catch{return""}})}function DB($,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(`
8461
- `)}catch{return""}})}function kB($,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 jR($,Z,Y){let X=$;return X=IB(X,Z,Y),X=DB(X,Z,Y),X=kB(X,Z,Y),X}var zR;var bB=D(()=>{zR=new p6});var yB={};e(yB,{processXElementDirectives:()=>HR,hasXElementDirectives:()=>PB,generateXElementRuntime:()=>CB});function CB(){return`<script data-stx-scoped>
8461
+ `)}catch{return""}})}function kB($,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 jR($,Z,Y){let X=$;return X=IB(X,Z,Y),X=DB(X,Z,Y),X=kB(X,Z,Y),X}var zR;var bB=D(()=>{zR=new p4});var yB={};e(yB,{processXElementDirectives:()=>HR,hasXElementDirectives:()=>PB,generateXElementRuntime:()=>CB});function CB(){return`<script data-stx-scoped>
8462
8462
  (function() {
8463
8463
  'use strict';
8464
8464
 
@@ -8802,17 +8802,17 @@ if ('serviceWorker' in navigator) {
8802
8802
  });
8803
8803
  });
8804
8804
  }
8805
- </script>`}function FR(){return'<link rel="manifest" href="/manifest.json">'}function VR($){return`<meta name="theme-color" content="${mY($)}">`}function mY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var fB=D(()=>{vB()});var cY={};e(cY,{validateClientScript:()=>k5,processOnceDirective:()=>D5,processJsonDirective:()=>I5,processDirectives:()=>G0,injectRouterScript:()=>D4});import Q1 from"path";function AR($,Z){let Y=$.length,X=Z,J=!0,Q=[],G=(K)=>K+9<=Y&&$[K]==="<"&&$[K+1]==="/"&&($[K+2]==="s"||$[K+2]==="S")&&($[K+3]==="c"||$[K+3]==="C")&&($[K+4]==="r"||$[K+4]==="R")&&($[K+5]==="i"||$[K+5]==="I")&&($[K+6]==="p"||$[K+6]==="P")&&($[K+7]==="t"||$[K+7]==="T")&&($[K+8]===">"||/\s/.test($[K+8]));while(X<Y){let K=$[X];if(G(X))return X;if(K==="/"&&$[X+1]==="/"){if(X=$.indexOf(`
8805
+ </script>`}function FR(){return'<link rel="manifest" href="/manifest.json">'}function VR($){return`<meta name="theme-color" content="${mY($)}">`}function mY($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}var fB=D(()=>{vB()});var cY={};e(cY,{validateClientScript:()=>k5,processOnceDirective:()=>D5,processJsonDirective:()=>I5,processDirectives:()=>G0,injectRouterScript:()=>D6});import Q1 from"path";function AR($,Z){let Y=$.length,X=Z,J=!0,Q=[],G=(K)=>K+9<=Y&&$[K]==="<"&&$[K+1]==="/"&&($[K+2]==="s"||$[K+2]==="S")&&($[K+3]==="c"||$[K+3]==="C")&&($[K+4]==="r"||$[K+4]==="R")&&($[K+5]==="i"||$[K+5]==="I")&&($[K+6]==="p"||$[K+6]==="P")&&($[K+7]==="t"||$[K+7]==="T")&&($[K+8]===">"||/\s/.test($[K+8]));while(X<Y){let K=$[X];if(G(X))return X;if(K==="/"&&$[X+1]==="/"){if(X=$.indexOf(`
8806
8806
  `,X+2),X===-1)return-1;X+=1,J=!0;continue}if(K==="/"&&$[X+1]==="*"){let W=$.indexOf("*/",X+2);if(W===-1)return-1;X=W+2,J=!0;continue}if(K==="/"&&J){let W=X+1,U=!1;while(W<Y){let _=$[W];if(_==="\\"){W+=2;continue}if(_==="[")U=!0;else if(_==="]")U=!1;else if(_==="/"&&!U){W++;break}else if(_===`
8807
8807
  `){W=-1;break}W++}if(W===-1){X++,J=!1;continue}while(W<Y&&/[a-z]/.test($[W]))W++;X=W,J=!1;continue}if(K==="'"||K==='"'){let W=K;X++;while(X<Y){if($[X]==="\\"){X+=2;continue}if($[X]===W){X++;break}if($[X]===`
8808
- `)break;X++}J=!1;continue}if(K==="`"){X++;while(X<Y){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++;break}if($[X]==="$"&&$[X+1]==="{"){Q.push(!0),X+=2,J=!0;break}X++}if(Q.length===0)J=!1;continue}if(K==="}"&&Q.length>0){Q.pop(),X++;while(X<Y){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++,J=!1;break}if($[X]==="$"&&$[X+1]==="{"){Q.push(!0),X+=2,J=!0;break}X++}continue}if(/\s/.test(K));else if(/[)\].\w$]/.test(K))J=!1;else J=!0;X++}return-1}async function G0($,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 wR($,Z,Y,X,J);if(Q)G=VY(G);if(Q&&X.autoShell&&X.buildMode!=="compile"){let K=X.app?.head||{},U=(Z.__stx_runtime_head||null)??C6(),_={...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=F5(G,_);let B=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(B&&G.includes("<head")){let q=B[1];G=G.replace("<head>",`<head>
8808
+ `)break;X++}J=!1;continue}if(K==="`"){X++;while(X<Y){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++;break}if($[X]==="$"&&$[X+1]==="{"){Q.push(!0),X+=2,J=!0;break}X++}if(Q.length===0)J=!1;continue}if(K==="}"&&Q.length>0){Q.pop(),X++;while(X<Y){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++,J=!1;break}if($[X]==="$"&&$[X+1]==="{"){Q.push(!0),X+=2,J=!0;break}X++}continue}if(/\s/.test(K));else if(/[)\].\w$]/.test(K))J=!1;else J=!0;X++}return-1}async function G0($,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 wR($,Z,Y,X,J);if(Q)G=VY(G);if(Q&&X.autoShell&&X.buildMode!=="compile"){let K=X.app?.head||{},U=(Z.__stx_runtime_head||null)??C4(),_={...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=F5(G,_);let B=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(B&&G.includes("<head")){let q=B[1];G=G.replace("<head>",`<head>
8809
8809
  <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(() => (R_(),N_)),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)+`
8810
- `+_+G.slice(q)}}}}catch{}if(Q&&Z.__stx_inject_css!==!1)G=await E0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof K5)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(a0.log(W,{filePath:Y,context:Z}),S6.logDetailedError(W,{filePath:Y,template:$.substring(0,500)}),X.debug)throw W;return P9.createFallbackContent("Template Processing",W)}}async function wR($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!Q1.isAbsolute(X.partialsDir)?Q1.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!Q1.isAbsolute(X.componentsDir)?Q1.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!Q1.isAbsolute(X.layoutsDir)?Q1.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,O)=>{return`{{ ${O} }}`}),W=uZ(W),W=await F_(W,Y,J);let _={};W=G2(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),O=/@section\s*\(/.test(W);if(!H||O){let F="",L=Q1.dirname(Y),V=K.layoutsDir?Q1.dirname(K.layoutsDir):process.cwd();for(let w=0;w<20;w++){let A=Q1.join(L,"_layout.stx");if(await X0(A)){F=A;break}let N=Q1.dirname(L);if(N===L||N.length<V.length)break;L=N}if(F)z=F;else if(K.layoutsDir){let w=Q1.isAbsolute(K.layoutsDir)?K.layoutsDir:Q1.resolve(process.cwd(),K.layoutsDir),A=Q1.join(w,`${K.defaultLayout}.stx`);if(await X0(A))z=A}if(z&&!O)W=`@section('content')
8810
+ `+_+G.slice(q)}}}}catch{}if(Q&&Z.__stx_inject_css!==!1)G=await E0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof K5)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(a0.log(W,{filePath:Y,context:Z}),S4.logDetailedError(W,{filePath:Y,template:$.substring(0,500)}),X.debug)throw W;return P9.createFallbackContent("Template Processing",W)}}async function wR($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!Q1.isAbsolute(X.partialsDir)?Q1.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!Q1.isAbsolute(X.componentsDir)?Q1.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!Q1.isAbsolute(X.layoutsDir)?Q1.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,O)=>{return`{{ ${O} }}`}),W=uZ(W),W=await F_(W,Y,J);let _={};W=G2(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),O=/@section\s*\(/.test(W);if(!H||O){let F="",L=Q1.dirname(Y),V=K.layoutsDir?Q1.dirname(K.layoutsDir):process.cwd();for(let w=0;w<20;w++){let A=Q1.join(L,"_layout.stx");if(await X0(A)){F=A;break}let N=Q1.dirname(L);if(N===L||N.length<V.length)break;L=N}if(F)z=F;else if(K.layoutsDir){let w=Q1.isAbsolute(K.layoutsDir)?K.layoutsDir:Q1.resolve(process.cwd(),K.layoutsDir),A=Q1.join(w,`${K.defaultLayout}.stx`);if(await X0(A))z=A}if(z&&!O)W=`@section('content')
8811
8811
  ${W.trim()}
8812
- @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,O,F)=>{return B[O]=F,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(H,O,F)=>{if(F.includes("@parent"))B[O]=F.replace("@parent",Y6);else B[O]=F.trim();return""}),Z.__sections=B,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(H,O,F)=>{return B[O]||F||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""});if(W=K2(W,_),z)try{let H=Q1.isAbsolute(z)?z:await y1(()=>C5(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(a0.log(Error(A),{layoutPath:z,filePath:Y},"warning"),G.debug)throw new R1(A,Y);return W}let O=await y1(()=>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=O.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F){if(G.debug)console.log(`Found nested layout: ${F[1]} in ${H}`);let A={},N=O.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(Y6)){let S=B[I].indexOf(Y6);B[I]=B[I].slice(0,S)+T+B[I].slice(S+Y6.length)}else if(!B[I])B[I]=T;let M={...Z,__sections:B},E=`@layout('${F[1]}')${N}`;return await G0(E,M,H,G,J)}let L=O.replace(/\{\{--[\s\S]*?--\}\}/g,""),V=G2(L,_),w={};return V=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(A,N,M)=>{return w[N]=M.trim(),`@slot('${N}')`}),V=V.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(A,N,M)=>{if(B[N]){let E=B[N];if(E.includes(Y6)){let I=w[N]||"",T=E.indexOf(Y6);E=E.slice(0,T)+I+E.slice(T+Y6.length)}return E}return M||""}),V=V.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""}),V=K2(V,_),Z.__originalFilePath=Y,W=await hB(V,Z,H,G,J),W=`<!-- stx-layout: ${z} -->
8813
- ${W}`,W}catch(H){return a0.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 hB(W,Z,Y,G,J)}async function hB($,Z,Y,X,J){let Q=$;Z.__stx_sfc_mode=!0;let G=X;if(await y1(()=>TU(Y,Z),void 0,(m)=>{a0.log(m,{filePath:Y,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${Y}: ${m.message}`)}),Z.__stx_options=G,G.buildMode)Z.__stx_buildMode=G.buildMode;let K=G.envPrefix||"STX_PUBLIC_",W={};for(let[m,c]of Object.entries(process.env))if(m.startsWith(K)&&c!==void 0)W[m]=c;Z.$env=W,Q=await y1(()=>PZ(Q,Z,Y,G),Q,(m)=>{a0.log(m,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${m.message}`)});let U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,_;while((_=U.exec(Q))!==null){let m=_[1],c=_[2];if(/\bserver\b/.test(m)&&c.trim())try{let{extractVariables:$0}=await Promise.resolve().then(() => (R4(),e9));await $0(c,Z,Y)}catch($0){let a=$0 instanceof Error?$0:Error(String($0));a0.log(a,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${a.message}`)}}try{let{interpolateScriptsInTemplate:m}=await Promise.resolve().then(() => (r0(),$5));Q=m(Q,Z,{skipServer:!0})}catch(m){let c=m instanceof Error?m:Error(String(m));a0.log(c,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${c.message}`)}if(Q=await FU(Q,Z,Y),Q=await VU(Q,Z,Y),Q=await LZ(Q,Z,Y,G),e$(Q))Q=sZ(Q),Q=oZ(Q,Z);Q=X2(Q,Z,Y,G),Q=await FY(Q,Z,Y,G,J),Q=await cZ(Q,Z,Y,G,J),Q=M8(Q,Z,Y,G);let{processDeferDirectives:B}=await Promise.resolve().then(() => T_);Q=B(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => S_);Q=z(Q,Z,Y);let{processTransitionDirectives:q,processTransitionAttributes:j}=await Promise.resolve().then(() => d_);Q=q(Q,Z,Y),Q=j(Q);let{processErrorBoundaryDirectives:H}=await Promise.resolve().then(() => m_);Q=H(Q,Z,Y);let{processSuspenseDirectives:O}=await Promise.resolve().then(() => r_);Q=O(Q,Z,Y);let{processAsyncDirectives:F}=await Promise.resolve().then(() => XB);Q=F(Q,Z,Y);let{processKeepAliveDirectives:L}=await Promise.resolve().then(() => zB);Q=L(Q,Z,Y);let{processVirtualListDirectives:V,processVirtualGridDirectives:w,processInfiniteListDirectives:A}=await Promise.resolve().then(() => (TY(),qB));Q=V(Q,Z,Y),Q=w(Q,Z,Y),Q=A(Q,Z,Y);let{processPartialHydrationDirectives:N,processStaticDirectives:M}=await Promise.resolve().then(() => (dY(),jB));Q=N(Q,Z,Y),Q=M(Q);let{processComputedDirectives:E,processWatchDirectives:I}=await Promise.resolve().then(() => (TB(),EB));Q=E(Q,Z,Y),Q=I(Q,Z,Y);let{processFormValidationDirectives:T}=await Promise.resolve().then(() => (bB(),SB));Q=T(Q,Z,Y);let{processHeadDirective:S,processTitleDirective:k,processMetaDirective:b,resetHead:y}=await Promise.resolve().then(() => (w4(),p9));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)y();let v=S(Q);if(Q=v.content,Q=k(Q,Z),Q=b(Q,Z),Q=RU(Q),Q=KZ(Q,Z),Q=bW(Q),Q=NU(Q),Q=await Q2(Q,Z,Y,G,J),Q=await FY(Q,Z,Y,G,J),Q=VY(Q),Q=b6(Q,Z,Y),Q=WZ(Q,Z),Q=UZ(Q,Z),Q=P6(Q,Z),Q=r9(Q,Z),Q=a9(Q,Z),Q=await pY(Q,Z,Y,G),Q=await lY(Q,Z,Y),Q=await MZ(Q,Z,Y,G),Q=w8(Q,Z,Y,G),Q=vZ(Q,Z,Y,G),Q=gZ(Q,Z,Y),Q=fZ(Q,Z,Y,G),Q=jZ(Q,Z,Y,G),Q=I5(Q,Z),Q=D5(Q),Q=A_(Q),!G.skipEventDirectives)Q=s8(Q,Z,Y);if(Q=iK(Q,Z,Y),G.debug){let m=/\bx-data\s*=/.test(Q),c=k2($);if(m&&c)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
8812
+ @endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,O,F)=>{return B[O]=F,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(H,O,F)=>{if(F.includes("@parent"))B[O]=F.replace("@parent",Y4);else B[O]=F.trim();return""}),Z.__sections=B,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(H,O,F)=>{return B[O]||F||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""});if(W=K2(W,_),z)try{let H=Q1.isAbsolute(z)?z:await y1(()=>C5(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(a0.log(Error(A),{layoutPath:z,filePath:Y},"warning"),G.debug)throw new R1(A,Y);return W}let O=await y1(()=>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=O.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(F){if(G.debug)console.log(`Found nested layout: ${F[1]} in ${H}`);let A={},N=O.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(Y4)){let S=B[I].indexOf(Y4);B[I]=B[I].slice(0,S)+T+B[I].slice(S+Y4.length)}else if(!B[I])B[I]=T;let M={...Z,__sections:B},E=`@layout('${F[1]}')${N}`;return await G0(E,M,H,G,J)}let L=O.replace(/\{\{--[\s\S]*?--\}\}/g,""),V=G2(L,_),w={};return V=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(A,N,M)=>{return w[N]=M.trim(),`@slot('${N}')`}),V=V.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(A,N,M)=>{if(B[N]){let E=B[N];if(E.includes(Y4)){let I=w[N]||"",T=E.indexOf(Y4);E=E.slice(0,T)+I+E.slice(T+Y4.length)}return E}return M||""}),V=V.replace(/\{\{\s*slot\s*\}\}/g,()=>{return B.content||""}),V=K2(V,_),Z.__originalFilePath=Y,W=await hB(V,Z,H,G,J),W=`<!-- stx-layout: ${z} -->
8813
+ ${W}`,W}catch(H){return a0.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 hB(W,Z,Y,G,J)}async function hB($,Z,Y,X,J){let Q=$;Z.__stx_sfc_mode=!0;let G=X;if(await y1(()=>TU(Y,Z),void 0,(m)=>{a0.log(m,{filePath:Y,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${Y}: ${m.message}`)}),Z.__stx_options=G,G.buildMode)Z.__stx_buildMode=G.buildMode;let K=G.envPrefix||"STX_PUBLIC_",W={};for(let[m,c]of Object.entries(process.env))if(m.startsWith(K)&&c!==void 0)W[m]=c;Z.$env=W,Q=await y1(()=>PZ(Q,Z,Y,G),Q,(m)=>{a0.log(m,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${m.message}`)});let U=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,_;while((_=U.exec(Q))!==null){let m=_[1],c=_[2];if(/\bserver\b/.test(m)&&c.trim())try{let{extractVariables:$0}=await Promise.resolve().then(() => (R6(),e9));await $0(c,Z,Y)}catch($0){let a=$0 instanceof Error?$0:Error(String($0));a0.log(a,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${a.message}`)}}try{let{interpolateScriptsInTemplate:m}=await Promise.resolve().then(() => (r0(),$5));Q=m(Q,Z,{skipServer:!0})}catch(m){let c=m instanceof Error?m:Error(String(m));a0.log(c,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${c.message}`)}if(Q=await FU(Q,Z,Y),Q=await VU(Q,Z,Y),Q=await LZ(Q,Z,Y,G),e$(Q))Q=sZ(Q),Q=oZ(Q,Z);Q=X2(Q,Z,Y,G),Q=await FY(Q,Z,Y,G,J),Q=await cZ(Q,Z,Y,G,J),Q=M8(Q,Z,Y,G);let{processDeferDirectives:B}=await Promise.resolve().then(() => T_);Q=B(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => S_);Q=z(Q,Z,Y);let{processTransitionDirectives:q,processTransitionAttributes:j}=await Promise.resolve().then(() => d_);Q=q(Q,Z,Y),Q=j(Q);let{processErrorBoundaryDirectives:H}=await Promise.resolve().then(() => m_);Q=H(Q,Z,Y);let{processSuspenseDirectives:O}=await Promise.resolve().then(() => r_);Q=O(Q,Z,Y);let{processAsyncDirectives:F}=await Promise.resolve().then(() => XB);Q=F(Q,Z,Y);let{processKeepAliveDirectives:L}=await Promise.resolve().then(() => zB);Q=L(Q,Z,Y);let{processVirtualListDirectives:V,processVirtualGridDirectives:w,processInfiniteListDirectives:A}=await Promise.resolve().then(() => (TY(),qB));Q=V(Q,Z,Y),Q=w(Q,Z,Y),Q=A(Q,Z,Y);let{processPartialHydrationDirectives:N,processStaticDirectives:M}=await Promise.resolve().then(() => (dY(),jB));Q=N(Q,Z,Y),Q=M(Q);let{processComputedDirectives:E,processWatchDirectives:I}=await Promise.resolve().then(() => (TB(),EB));Q=E(Q,Z,Y),Q=I(Q,Z,Y);let{processFormValidationDirectives:T}=await Promise.resolve().then(() => (bB(),SB));Q=T(Q,Z,Y);let{processHeadDirective:S,processTitleDirective:k,processMetaDirective:b,resetHead:y}=await Promise.resolve().then(() => (w6(),p9));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)y();let v=S(Q);if(Q=v.content,Q=k(Q,Z),Q=b(Q,Z),Q=RU(Q),Q=KZ(Q,Z),Q=bW(Q),Q=NU(Q),Q=await Q2(Q,Z,Y,G,J),Q=await FY(Q,Z,Y,G,J),Q=VY(Q),Q=b4(Q,Z,Y),Q=WZ(Q,Z),Q=UZ(Q,Z),Q=P4(Q,Z),Q=r9(Q,Z),Q=a9(Q,Z),Q=await pY(Q,Z,Y,G),Q=await lY(Q,Z,Y),Q=await MZ(Q,Z,Y,G),Q=w8(Q,Z,Y,G),Q=vZ(Q,Z,Y,G),Q=gZ(Q,Z,Y),Q=fZ(Q,Z,Y,G),Q=jZ(Q,Z,Y,G),Q=I5(Q,Z),Q=D5(Q),Q=A_(Q),!G.skipEventDirectives)Q=s8(Q,Z,Y);if(Q=iK(Q,Z,Y),G.debug){let m=/\bx-data\s*=/.test(Q),c=k2($);if(m&&c)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
8814
8814
  Both work on the same page, but they manage separate scopes.
8815
- Prefer signals (state/derived/effect) for new components.`)}Q=B2(Q,Z),Q=await w1(Q,Z,Y),Q=w_(Q),Q=p8(Q);let{processXElementDirectives:C}=await Promise.resolve().then(() => yB);if(Q=C(Q),Q=await tZ(Q,G,Y),Q=await yZ(Q,Z,Y,G),G.seo?.enabled)Q=hZ(Q,Z,G);let{renderHead:f,getHead:h}=await Promise.resolve().then(() => (w4(),p9)),d=Z.__stx_runtime_head,i=d&&(d.title||d.meta?.length||d.link?.length)?d:h();if(i.title||i.meta?.length||i.link?.length){let m=f(i);if(m){if(Q.includes("</head>"))Q=Q.replace("</head>",`${m}
8815
+ Prefer signals (state/derived/effect) for new components.`)}Q=B2(Q,Z),Q=await w1(Q,Z,Y),Q=w_(Q),Q=p8(Q);let{processXElementDirectives:C}=await Promise.resolve().then(() => yB);if(Q=C(Q),Q=await tZ(Q,G,Y),Q=await yZ(Q,Z,Y,G),G.seo?.enabled)Q=hZ(Q,Z,G);let{renderHead:f,getHead:h}=await Promise.resolve().then(() => (w6(),p9)),d=Z.__stx_runtime_head,i=d&&(d.title||d.meta?.length||d.link?.length)?d:h();if(i.title||i.meta?.length||i.link?.length){let m=f(i);if(m){if(Q.includes("</head>"))Q=Q.replace("</head>",`${m}
8816
8816
  </head>`);else if(Q.includes("<head>"))Q=Q.replace("<head>",`<head>
8817
8817
  ${m}`)}}if(v.headContent){if(Q.includes("</head>"))Q=Q.replace("</head>",`${v.headContent}
8818
8818
  </head>`);else if(Q.includes("<head>"))Q=Q.replace("<head>",`<head>
@@ -8822,12 +8822,12 @@ ${CK()}
8822
8822
  `+F0}else Q=Q.replace("</head>",`${c}
8823
8823
  </head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
8824
8824
  ${c}`);else Q=c+`
8825
- `+Q}{let m=/<script\s+server\b[^>]*>/gi,c,Y0=[];while((c=m.exec(Q))!==null){let $0=c.index+c[0].length,a=AR(Q,$0);if(a===-1)continue;let _0=a+9;while(_0<Q.length&&/\s/.test(Q[_0]))_0++;Y0.push({start:c.index,end:_0})}for(let $0=Y0.length-1;$0>=0;$0--){let{start:a,end:_0}=Y0[$0];Q=Q.substring(0,a)+Q.substring(_0)}}let y0=L5(Q,Y);if(y0.hasScoped)Q=y0.html;let S0=Z.__stx_event_bindings||[],g=!1,u=[],r=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:l}=await Promise.resolve().then(() => (eZ(),sU));for(let m of l(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}))u.push({match:m.fullMatch,attrs:m.attrs,content:m.body});for(let{match:m,attrs:c,content:Y0}of u){g=!0;let $0=Y0;k5(Y0,Y,X.strict);let a=await s4(Y0,{eventBindings:S0,attrs:c,hasColonDirectives:r,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile"});Q=Q.replace(m,()=>a)}if(g)Z.__stx_event_bindings=[];return Q}var Y6="<!--PARENT_CONTENT_PLACEHOLDER-->";var G1=D(()=>{P1();A6();PK();i8();a8();F9();L9();o8();r$();i6();d9();HZ();CW();FZ();z1();w4();r0();wZ();EZ();y6();wU();J2();h2();xZ();j4();MU();_2();H0();IU();dZ();mZ();lZ();z2();eZ();H_();V_();AY();wY();AY();wY()});function dB($){let Z=[],Y=[];return ER($,Z),TR($,Z,Y),IR($,Y),DR($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function ER($,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 TR($,Z,Y){for(let X of NR){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 IR($,Z){for(let Y of RR)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function DR($,Z){for(let Y of MR)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function uB($,Z){let Y=$.slice(0,Z).split(`
8826
- `);return{line:Y.length,column:Y[Y.length-1].length+1}}function mB($,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 cB($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function lB($){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 NR,RR,MR;var pB=D(()=>{NR=[{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"}],RR=[{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')"}],MR=[{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 sB={};e(sB,{renderSlot:()=>nY,processSlots:()=>rY,parseSlots:()=>iY,parseSlotElement:()=>iB,extractSlotContent:()=>rB,applySlots:()=>aB});function kR($,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,O=Q.index+_.length,F=kR($,O);if(F!==-1){let L=$.slice(O,F-11).trim();J.push({start:Q.index,end:F,slotName:H,content:L,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:L,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,O=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(O+F).trim(),V=`<${B}${L?" "+L:""}>${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(),O=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+O).trim(),L=`<${B}${F?" "+F:""} />`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:L})}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 iB($){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 nY($,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=SR(J,G)}return J}function SR($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=nB(J,Z);return D0(String(Q??""))}catch{return`{{ ${X} }}`}})}function nB($,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(!O0($))return;return V0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function rY($,Z,Y){let X=$;X=await bR(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 O=H[1],F=H[2];q[O]=nB(F,Y)}return await nY(_,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 bR($,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 rB($){let Z=iY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function aB($,Z,Y,X){return await rY($,{default:Z,named:Y},X)}var aY=D(()=>{r0();n0()});import CR from"fs";import U0 from"path";function yR($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function oB($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function z4($){return!oB($)}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",define:H1()}).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 xR($){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]!==`
8827
- `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let 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 v1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (R4(),e9)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let B=new Set(_);B.add($);try{let z=(g)=>g.split("-").map((u)=>u.charAt(0).toUpperCase()+u.slice(1)).join(""),q=(g)=>g.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),j=$.endsWith(".stx")?$.slice(0,-4):$,H=null,O=J.__importedComponents;if(O){let g=[j,j.toLowerCase(),z(j),q(j)];for(let u of g)if(O.has(u)){H=O.get(u);break}}let F=[];if(!H){let g=[`${j}.stx`,`${z(j)}.stx`,`${q(j)}.stx`],u=[...new Set(g)],r=J.__originalFilePath,l=[];if(r){let $0=U0.join(U0.dirname(r),"components");l.push($0)}if(X)l.push(X);let m=U0.join(U0.dirname(Q),"components");if(!l.includes(m))l.push(m);if(G.componentsDir&&G.componentsDir!==X&&!l.includes(G.componentsDir))l.push(G.componentsDir);let c=process.cwd(),Y0=[U0.resolve(c,"src/components"),U0.resolve(c,"components"),U0.resolve(import.meta.dir,"components")];for(let $0 of Y0)if(!l.includes($0))l.push($0);if(j.startsWith("./")||j.startsWith("../"))H=U0.resolve(U0.dirname(Q),`${j}.stx`),F.push(H);else for(let $0 of l){if(!$0)continue;for(let a of u){let _0=U0.join($0,a);if(F.push(_0),await X0(_0)){H=_0;break}}if(H)break;if(!H)try{let a=await import("fs");if(!a.statSync($0,{throwIfNoEntry:!1})?.isDirectory())continue;let F0=a.readdirSync($0,{withFileTypes:!0});for(let t0 of F0)if(t0.isDirectory()){let F6=U0.join($0,t0.name);for(let V6 of u){let j0=U0.join(F6,V6);if(F.push(j0),await X0(j0)){H=j0;break}}if(H)break}}catch{}if(H)break}}if(!H||!await X0(H)){let g=F.length>0?`
8825
+ `+Q}{let m=/<script\s+server\b[^>]*>/gi,c,Y0=[];while((c=m.exec(Q))!==null){let $0=c.index+c[0].length,a=AR(Q,$0);if(a===-1)continue;let _0=a+9;while(_0<Q.length&&/\s/.test(Q[_0]))_0++;Y0.push({start:c.index,end:_0})}for(let $0=Y0.length-1;$0>=0;$0--){let{start:a,end:_0}=Y0[$0];Q=Q.substring(0,a)+Q.substring(_0)}}let y0=L5(Q,Y);if(y0.hasScoped)Q=y0.html;let S0=Z.__stx_event_bindings||[],g=!1,u=[],r=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:l}=await Promise.resolve().then(() => (eZ(),sU));for(let m of l(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}))u.push({match:m.fullMatch,attrs:m.attrs,content:m.body});for(let{match:m,attrs:c,content:Y0}of u){g=!0;let $0=Y0;k5(Y0,Y,X.strict);let a=await s6(Y0,{eventBindings:S0,attrs:c,hasColonDirectives:r,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile"});Q=Q.replace(m,()=>a)}if(g)Z.__stx_event_bindings=[];return Q}var Y4="<!--PARENT_CONTENT_PLACEHOLDER-->";var G1=D(()=>{P1();A4();PK();i8();a8();F9();L9();o8();r$();i4();d9();HZ();CW();FZ();z1();w6();r0();wZ();EZ();y4();wU();J2();h2();xZ();j6();MU();_2();H0();IU();dZ();mZ();lZ();z2();eZ();H_();V_();AY();wY();AY();wY()});function dB($){let Z=[],Y=[];return ER($,Z),TR($,Z,Y),IR($,Y),DR($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function ER($,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 TR($,Z,Y){for(let X of NR){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 IR($,Z){for(let Y of RR)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function DR($,Z){for(let Y of MR)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function uB($,Z){let Y=$.slice(0,Z).split(`
8826
+ `);return{line:Y.length,column:Y[Y.length-1].length+1}}function mB($,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 cB($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function lB($){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 NR,RR,MR;var pB=D(()=>{NR=[{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"}],RR=[{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')"}],MR=[{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 sB={};e(sB,{renderSlot:()=>nY,processSlots:()=>rY,parseSlots:()=>iY,parseSlotElement:()=>iB,extractSlotContent:()=>rB,applySlots:()=>aB});function kR($,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,O=Q.index+_.length,F=kR($,O);if(F!==-1){let L=$.slice(O,F-11).trim();J.push({start:Q.index,end:F,slotName:H,content:L,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:L,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,O=z.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(O+F).trim(),V=`<${B}${L?" "+L:""}>${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(),O=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+O).trim(),L=`<${B}${F?" "+F:""} />`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:L})}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 iB($){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 nY($,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=SR(J,G)}return J}function SR($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=nB(J,Z);return D0(String(Q??""))}catch{return`{{ ${X} }}`}})}function nB($,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(!O0($))return;return V0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function rY($,Z,Y){let X=$;X=await bR(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 O=H[1],F=H[2];q[O]=nB(F,Y)}return await nY(_,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 bR($,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 rB($){let Z=iY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function aB($,Z,Y,X){return await rY($,{default:Z,named:Y},X)}var aY=D(()=>{r0();n0()});import CR from"fs";import U0 from"path";function yR($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function oB($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function z6($){return!oB($)}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",define:H1()}).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 xR($){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]!==`
8827
+ `)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let 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 v1($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (R6(),e9)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let B=new Set(_);B.add($);try{let z=(g)=>g.split("-").map((u)=>u.charAt(0).toUpperCase()+u.slice(1)).join(""),q=(g)=>g.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),j=$.endsWith(".stx")?$.slice(0,-4):$,H=null,O=J.__importedComponents;if(O){let g=[j,j.toLowerCase(),z(j),q(j)];for(let u of g)if(O.has(u)){H=O.get(u);break}}let F=[];if(!H){let g=[`${j}.stx`,`${z(j)}.stx`,`${q(j)}.stx`],u=[...new Set(g)],r=J.__originalFilePath,l=[];if(r){let $0=U0.join(U0.dirname(r),"components");l.push($0)}if(X)l.push(X);let m=U0.join(U0.dirname(Q),"components");if(!l.includes(m))l.push(m);if(G.componentsDir&&G.componentsDir!==X&&!l.includes(G.componentsDir))l.push(G.componentsDir);let c=process.cwd(),Y0=[U0.resolve(c,"src/components"),U0.resolve(c,"components"),U0.resolve(import.meta.dir,"components")];for(let $0 of Y0)if(!l.includes($0))l.push($0);if(j.startsWith("./")||j.startsWith("../"))H=U0.resolve(U0.dirname(Q),`${j}.stx`),F.push(H);else for(let $0 of l){if(!$0)continue;for(let a of u){let _0=U0.join($0,a);if(F.push(_0),await X0(_0)){H=_0;break}}if(H)break;if(!H)try{let a=await import("fs");if(!a.statSync($0,{throwIfNoEntry:!1})?.isDirectory())continue;let F0=a.readdirSync($0,{withFileTypes:!0});for(let t0 of F0)if(t0.isDirectory()){let F4=U0.join($0,t0.name);for(let V4 of u){let j0=U0.join(F4,V4);if(F.push(j0),await X0(j0)){H=j0;break}}if(H)break}}catch{}if(H)break}}if(!H||!await X0(H)){let g=F.length>0?`
8828
8828
  Searched paths:
8829
8829
  ${F.map((u)=>` - ${u}`).join(`
8830
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${g}`}W.add(H);let L;if(P5.has(H))L=P5.get(H);else try{L=await Bun.file(H).text(),P5.set(H,L)}catch(g){return`[Error loading component: ${g instanceof Error?g.message:String(g)}]`}let V=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[g,u]of Object.entries(J))if(!g.startsWith("__")||V.has(g))w[g]=u;let A={...w,...Z,props:Z,slot:Y,__processedComponents:B,__sections:{}},N=L,M=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)N=M[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[...L.matchAll(E)],T=[];for(let g of I){let u=g[1]||"",r=g[2]||"",l=u.includes("server");if(z4(u)&&r.trim())r=q4(r);if(l&&r)try{await U(r,A,H)}catch(c){}if(!l){let c=r.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),Y0=u.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");T.push(`<script${Y0}>${c}</script>`)}}let S=L.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=S?S[1]:"",b=S?S[2]:"",y="",v=k&&/\bscoped\b/i.test(k);if(S)y=`<style${k}>${b}</style>`;let C=N;if(C=C.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S)C=C.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");if(Y&&C.includes("{{ text || slot }}"))C=C.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:f,applySlots:h}=await Promise.resolve().then(() => (aY(),sB)),{defaultSlot:d,namedSlots:i}=f(Y);C=await h(C,d||Y,i,A);for(let[g,u]of Object.entries(A))if(typeof u==="string"){if(u.includes("<")&&u.includes(">")||u.includes("&lt;")||u.includes("&quot;")){let r=N9(u);A[g]=r}}let n=T.some((g)=>/\b(state|derived|effect)\s*\(/.test(g)),W0={...G,componentsDir:U0.dirname(H),skipSignalsRuntime:!0,skipEventDirectives:n,defaultLayout:void 0};A.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let z0=await G0(C,A,H,W0,W),y0=`stx_${j.replace(/[^a-zA-Z0-9]/g,"_")}_${++PR}_${Math.random().toString(36).slice(2,8)}`,S0=z0;if(n){let g="";if(Object.keys(Z).length>0)try{g=` data-stx-props="${yR(JSON.stringify(Z))}"`}catch{}if(S0=`<div data-stx-scope="${y0}"${g}>${z0}</div>`,S0=T.map((r)=>{let l=r.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!l)return r;let[,m,c]=l,Y0=B4(c),$0=`
8830
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${g}`}W.add(H);let L;if(P5.has(H))L=P5.get(H);else try{L=await Bun.file(H).text(),P5.set(H,L)}catch(g){return`[Error loading component: ${g instanceof Error?g.message:String(g)}]`}let V=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[g,u]of Object.entries(J))if(!g.startsWith("__")||V.has(g))w[g]=u;let A={...w,...Z,props:Z,slot:Y,__processedComponents:B,__sections:{}},N=L,M=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)N=M[1].trim();let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[...L.matchAll(E)],T=[];for(let g of I){let u=g[1]||"",r=g[2]||"",l=u.includes("server");if(z6(u)&&r.trim())r=q6(r);if(l&&r)try{await U(r,A,H)}catch(c){}if(!l){let c=r.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,""),Y0=u.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");T.push(`<script${Y0}>${c}</script>`)}}let S=L.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),k=S?S[1]:"",b=S?S[2]:"",y="",v=k&&/\bscoped\b/i.test(k);if(S)y=`<style${k}>${b}</style>`;let C=N;if(C=C.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),S)C=C.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");if(Y&&C.includes("{{ text || slot }}"))C=C.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:f,applySlots:h}=await Promise.resolve().then(() => (aY(),sB)),{defaultSlot:d,namedSlots:i}=f(Y);C=await h(C,d||Y,i,A);for(let[g,u]of Object.entries(A))if(typeof u==="string"){if(u.includes("<")&&u.includes(">")||u.includes("&lt;")||u.includes("&quot;")){let r=N9(u);A[g]=r}}let n=T.some((g)=>/\b(state|derived|effect)\s*\(/.test(g)),W0={...G,componentsDir:U0.dirname(H),skipSignalsRuntime:!0,skipEventDirectives:n,defaultLayout:void 0};A.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let z0=await G0(C,A,H,W0,W),y0=`stx_${j.replace(/[^a-zA-Z0-9]/g,"_")}_${++PR}_${Math.random().toString(36).slice(2,8)}`,S0=z0;if(n){let g="";if(Object.keys(Z).length>0)try{g=` data-stx-props="${yR(JSON.stringify(Z))}"`}catch{}if(S0=`<div data-stx-scope="${y0}"${g}>${z0}</div>`,S0=T.map((r)=>{let l=r.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!l)return r;let[,m,c]=l,Y0=B6(c),$0=`
8831
8831
  (function() {
8832
8832
  const { state, derived, effect, batch } = window.stx;
8833
8833
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -8853,7 +8853,7 @@ catch (e) {}
8853
8853
  `)+`
8854
8854
  `+S0,y)S0+=`
8855
8855
  `+y}else{if(y)S0+=`
8856
- `+y;if(T.length>0){let g=A.__stx_event_bindings||[],u=await Promise.all(T.map(async(r)=>{let l=r.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!l)return r;return await s4(l[1],{eventBindings:g,templateContent:S0,filePath:H,projectRoot:process.cwd()})}));S0+=`
8856
+ `+y;if(T.length>0){let g=A.__stx_event_bindings||[],u=await Promise.all(T.map(async(r)=>{let l=r.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!l)return r;return await s6(l[1],{eventBindings:g,templateContent:S0,filePath:H,projectRoot:process.cwd()})}));S0+=`
8857
8857
  `+u.join(`
8858
8858
  `),A.__stx_event_bindings=[]}}if(v){let g=L5(S0,H);if(g.hasScoped)S0=g.html}return S0}catch(z){return`[Error processing component: ${z instanceof Error?z.message:String(z)}]`}finally{_.delete($)}}async function X0($){return Bun.file($).exists()}function tB($,Z){let Y=U0.resolve(Z),X=U0.resolve($),J=Y.endsWith(U0.sep)?Y:Y+U0.sep;if(X===Y||X.startsWith(J))return X;return null}async function C5($,Z,Y,X){let J=await vR($,Z,Y,X);if(J===null)return null;let Q=tB(J,process.cwd());if(!Q)return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null;return Q}async function vR($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=U0.dirname(Z),Q=process.cwd();if($.startsWith("/")){let z=U0.join(Q,$),q=tB(z,Q);if(!q)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${q}`);if(await X0(q)&&X)X.add(q);return q}let G=U0.join(J,$);if(await X0(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let z of[".stx",".tsx",".jsx"]){let q=`${G}${z}`;if(await X0(q)){if(Y.debug)console.log(`Found direct path with extension: ${q}`);if(X)X.add(q);return q}}let K="",W=U0.resolve(J),U=process.cwd();for(let z=0;z<10;z++){let q=U0.join(W,"layouts"),j=!1;try{j=CR.statSync(q,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=q;break}let H=U0.dirname(W);if(H===W||H.length<U.length)break;W=H}if(K){let z=$.startsWith("layouts/")?$.slice(8):$,q=U0.join(K,z);if(await X0(q)){if(Y.debug)console.log(`Found in current layouts dir: ${q}`);if(X)X.add(q);return q}if(!z.endsWith(".stx")){let j=`${q}.stx`;if(await X0(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let z=U0.isAbsolute(Y.layoutsDir)?Y.layoutsDir:U0.resolve(process.cwd(),Y.layoutsDir),q=$.startsWith("layouts/")?$.slice(8):$,j=U0.join(z,q);if(await X0(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await X0(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(X)X.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let z=$.split("layouts/"),q=U0.join(Y.partialsDir||J,"layouts",z[1]);if(await X0(q)){if(Y.debug)console.log(`Found in layouts path: ${q}`);if(X)X.add(q);return q}if(!q.endsWith(".stx")){let j=`${q}.stx`;if(await X0(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=U0.join(Y.partialsDir,"layouts"),await X0(K)){let z=U0.join(K,$);if(await X0(z)){if(Y.debug)console.log(`Found in partials layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await X0(q)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}}let _=Y.partialsDir||U0.join(process.cwd(),"views"),B=U0.join(_,$);if(await X0(B)){if(Y.debug)console.log(`Found in views path: ${B}`);if(X)X.add(B);return B}if(!$.endsWith(".stx")){let z=`${B}.stx`;if(await X0(z)){if(Y.debug)console.log(`Found in views path with extension: ${z}`);if(X)X.add(z);return z}}if(J.includes("temp")){let z=U0.join(U0.dirname(J),"layouts",$);if(await X0(z)){if(Y.debug)console.log(`Found in temp layouts dir: ${z}`);if(X)X.add(z);return z}if(!$.endsWith(".stx")){let q=`${z}.stx`;if(await X0(q)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${q}`);if(X)X.add(q);return q}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function sY($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
8859
8859
  `),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(`
@@ -8870,7 +8870,7 @@ ${B0.yellow}${B0.bold}Message:${B0.reset} ${Z}
8870
8870
  `,K)_+=`
8871
8871
  ${B0.blue}${B0.bold}Context:${B0.reset}
8872
8872
  ${B0.dim}${K}${B0.reset}
8873
- `;return _}function S4(){P5.clear()}function gR(){return{size:P5.size,maxSize:500}}var P5,PR=0,B0;var H0=D(()=>{r$();r0();j4();G1();r4();z2();pB();R4();P5=new Z5(500);B0={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 lY($,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 O=$.indexOf("@markdown",z),F=$.indexOf("@endmarkdown",z);if(F===-1)break;if(O!==-1&&O<F&&O!==K){let L=$[O+9];if(L==="("||L===`
8873
+ `;return _}function S6(){P5.clear()}function gR(){return{size:P5.size,maxSize:500}}var P5,PR=0,B0;var H0=D(()=>{r$();r0();j6();G1();r6();z2();pB();R6();P5=new Z5(500);B0={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 lY($,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 O=$.indexOf("@markdown",z),F=$.indexOf("@endmarkdown",z);if(F===-1)break;if(O!==-1&&O<F&&O!==K){let L=$[O+9];if(L==="("||L===`
8874
8874
  `||L==="\r"||L===" "||L===void 0)B++;z=O+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=n$(U.trim(),z);X=X.split(K).join(q)}catch(B){let z=B instanceof Error?B.message:String(B),q=L0("Markdown Directive",`Error processing markdown: ${z}`,Y,$,_,K);X=X.split(K).join(q)}return X}async function oY($,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}),n$($.trim(),J)}var h2=D(()=>{H0()});function eB($){if(d2.set($.name,$),$.client)tY.set($.name,$.client)}function fR($){return d2.get($)}function hR(){return Array.from(d2.values())}function dR($){return tY.delete($),d2.delete($)}function b0($){return eB($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,X,J,Q)=>{let G=mR(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 uR($,Z){let Y=typeof Z==="function"?{mounted:Z}:Z;return tY.set($,Y),Y}function mR($,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 cR(){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:()=>`
8875
8875
  .stx-tooltip::after {
8876
8876
  content: attr(data-tooltip);
@@ -9015,7 +9015,7 @@ ${B0.dim}${K}${B0.reset}
9015
9015
 
9016
9016
  console.log('[stx] Directive runtime initialized');
9017
9017
  })();
9018
- `}function pR($){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 d2,tY;var y5=D(()=>{d2=new Map,tY=new Map});function b4($,Z=d1,Y={},X){return Z.sort((J,Q)=>J-Q).map((J)=>{return`${E1($,{...Y,w:J,fm:X})} ${J}w`}).join(", ")}function eY($,Z=320,Y=2560,X=0.08,J={},Q){let G=u2(Z,Y,X);return b4($,G,J,Q)}function u2($,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 n6($,Z,Y=x5,X={},J){return Y.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${E1($,{...X,w:G,dpr:Q,fm:J})} ${Q}x`}).join(", ")}function $X($,Z,Y=x5,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`${E1($,{...J,w:W,q:U,dpr:K,fm:Q})} ${K}x`}).join(", ")}function r6($,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 ZX($,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 E1($,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 XX($){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 JX($){let{src:Z,widths:Y,dprValues:X,fixedWidth:J,formats:Q=e1,baseUrl:G="",params:K={}}=$,W=[];for(let U of Q){let _,B;if(J!==void 0&&X)_=n6(Z,J,X,K,U),B=X.map((z)=>({path:"",url:E1(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||d1;_=b4(Z,z,K,U),B=z.map((q)=>({path:"",url:E1(Z,{...K,w:q,fm:U}),width:q,height:0,format:U,size:0}))}W.push({srcset:_,format:U,mimeType:v5[U],variants:B})}return W}function QX($,Z="100vw"){return $.map(({srcset:Y,mimeType:X})=>`<source type="${X}" srcset="${Y}" sizes="${Z}" />`).join(`
9018
+ `}function pR($){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 d2,tY;var y5=D(()=>{d2=new Map,tY=new Map});function b6($,Z=d1,Y={},X){return Z.sort((J,Q)=>J-Q).map((J)=>{return`${E1($,{...Y,w:J,fm:X})} ${J}w`}).join(", ")}function eY($,Z=320,Y=2560,X=0.08,J={},Q){let G=u2(Z,Y,X);return b6($,G,J,Q)}function u2($,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 n4($,Z,Y=x5,X={},J){return Y.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${E1($,{...X,w:G,dpr:Q,fm:J})} ${Q}x`}).join(", ")}function $X($,Z,Y=x5,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`${E1($,{...J,w:W,q:U,dpr:K,fm:Q})} ${K}x`}).join(", ")}function r4($,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 ZX($,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 E1($,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 XX($){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 JX($){let{src:Z,widths:Y,dprValues:X,fixedWidth:J,formats:Q=e1,baseUrl:G="",params:K={}}=$,W=[];for(let U of Q){let _,B;if(J!==void 0&&X)_=n4(Z,J,X,K,U),B=X.map((z)=>({path:"",url:E1(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||d1;_=b6(Z,z,K,U),B=z.map((q)=>({path:"",url:E1(Z,{...K,w:q,fm:U}),width:q,height:0,format:U,size:0}))}W.push({srcset:_,format:U,mimeType:v5[U],variants:B})}return W}function QX($,Z="100vw"){return $.map(({srcset:Y,mimeType:X})=>`<source type="${X}" srcset="${Y}" sizes="${Z}" />`).join(`
9019
9019
  `)}function GX($,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 g5($){return v5[$]||"application/octet-stream"}function KX($){return $z[$]||$}function WX($){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 d1,x5,e1,v5,$z,YX;var m2=D(()=>{d1=[320,480,640,768,1024,1280,1536,1920,2560],x5=[1,1.5,2,3],e1=["avif","webp","jpeg"],v5={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},$z={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};YX={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 UX(){try{return await import("ts-images")}catch{return null}}async function f5($,Z={}){let Y={...c2,...Z},X=await UX();if(X)try{return await iR($,Y,X)}catch(J){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${J}`)}return Zz($,Y)}async function iR($,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 Zz($,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 _X($){let Z=await UX();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await Zz($,{strategy:"thumbhash",width:32,height:32})).dataURL}function BX($){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))),O=Math.max(0,Math.min(255,Math.round(Y*255))),F=Math.max(0,Math.min(255,Math.round((Y-X)*255))),L=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
9020
9020
  <rect fill="rgb(${H},${O},${F})" width="32" height="32"/>
9021
9021
  </svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(L)}`}async function zX($,Z=20,Y=50){return f5($,{strategy:"blur",width:Z,quality:Y,blurLevel:40})}async function qX($){let Z=await UX();if(Z)try{return(await Z.generatePlaceholder($,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function jX($,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 h5($,Z,Y={}){let X=Y.transitionDuration||300,J=Y.easing||"ease-out";return`
@@ -9035,7 +9035,7 @@ ${B0.dim}${K}${B0.reset}
9035
9035
  #${$}.stx-img-loaded img {
9036
9036
  opacity: 1;
9037
9037
  }
9038
- `.trim()}function HX($){return`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`}async function d5($,Z={}){let Y=`${$}:${JSON.stringify(Z)}`;if(a6.has(Y))return a6.get(Y);let X=await f5($,Z);return a6.set(Y,X),X}function OX(){a6.clear()}function LX(){return{size:a6.size,keys:Array.from(a6.keys())}}var c2,s6,a6;var FX=D(()=>{c2={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},s6=`
9038
+ `.trim()}function HX($){return`background-image: url('${$.dataURL}'); background-size: cover; background-position: center;`}async function d5($,Z={}){let Y=`${$}:${JSON.stringify(Z)}`;if(a4.has(Y))return a4.get(Y);let X=await f5($,Z);return a4.set(Y,X),X}function OX(){a4.clear()}function LX(){return{size:a4.size,keys:Array.from(a4.keys())}}var c2,s4,a4;var FX=D(()=>{c2={strategy:"thumbhash",width:20,quality:50,blurLevel:40,transitionDuration:300,easing:"ease-out"},s4=`
9039
9039
  .stx-img-placeholder {
9040
9040
  position: relative;
9041
9041
  overflow: hidden;
@@ -9064,8 +9064,8 @@ ${B0.dim}${K}${B0.reset}
9064
9064
  filter: blur(0);
9065
9065
  transform: scale(1);
9066
9066
  }
9067
- `.trim();a6=new Map});import{createHash as VX}from"crypto";import{readFile as nR,stat as Yz}from"fs/promises";async function l0($){try{let Z=await nR($);return VX("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function Xz($){return VX("sha256").update($).digest("hex").slice(0,16)}function l2($){return VX("sha256").update($).digest("hex").slice(0,16)}function o6($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${l2($)}-${l2(Y)}`}async function u5($){try{return(await Yz($)).mtimeMs}catch{return 0}}async function p0($){try{return await Yz($),!0}catch{return!1}}var C4=()=>{};import{mkdir as rR,readFile as Qz,writeFile as aR,readdir as Gz,rm as AX,stat as sR}from"fs/promises";import{join as t6,dirname as oR}from"path";async function tR($){try{await rR($,{recursive:!0})}catch{}}function Kz($,Z,Y){return t6($,Y,`${Z}.json`)}async function Jz($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await u5(Z)!==$.srcMtime)return!1;return!0}async function e6($,Z,Y,X=m5){if(!X.enabled)return null;let J=o6($,Z),Q=P4.get(J);if(Q){if(await Jz(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;P4.delete(J)}let G=Kz(X.directory,J,Y);if(await p0(G))try{let K=await Qz(G,"utf-8"),W=JSON.parse(K);if(await Jz(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),P4.set(J,W),W.data}catch{}return null}async function $$($,Z,Y,X,J=m5){if(!J.enabled)return;let Q=o6($,Z),G=await l0($),K=await u5($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:o6("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};P4.set(Q,W);let U=Kz(J.directory,Q,X);try{await tR(oR(U)),await aR(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function Z$($,Z=m5){if($==="all")P4.clear();else P4.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=t6(Z.directory,X);try{await AX(J,{recursive:!0,force:!0})}catch{}}}async function Wz($=m5){let Z={memoryEntries:P4.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=t6($.directory,Y);try{let J=await Gz(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=t6(X,Q),K=await sR(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function Uz($=m5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=t6($.directory,X);try{let Q=await Gz(J);for(let G of Q){let K=t6(J,G);try{let W=await Qz(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await AX(K),P4.delete(U.key),Z++}catch{await AX(K).catch(()=>{}),Z++}}}catch{}}return Z}var P4,m5;var p2=D(()=>{C4();P4=new Map,m5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class Y${config;constructor($={}){this.config={...eR,...$}}async get($,Z){return e6($,Z,"image",this.config)}async set($,Z,Y){return $$($,Z,Y,"image",this.config)}async clear(){return Z$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function wX($){if(!i2)i2=new Y$($);else if($)i2.updateConfig($);return i2}async function X$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return wX(X).get($,Z)}async function J$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return wX(J).set($,Z,Y)}async function NX(){return wX().clear()}var eR,i2=null;var RX=D(()=>{p2();eR={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as $M,basename as ZM,extname as YM,join as XM}from"path";import{mkdir as JM}from"fs/promises";async function MX(){try{return await import("ts-images")}catch{return null}}function _z($){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 QM($,Z){let Y=Z?_z(Z):_z("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 EX($,Z,Y){let X=await MX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await X$($,Z,Y);if(J)return J;try{let Q=$M($);if(!await p0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=QM(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await JM(K,{recursive:!0});let U=await l0(Q),_=ZM($,YM($)),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 c5(Q,Z.transformations,X);for(let j of B){let H=G[j]||{},O=`${_}-${U}.${j}`,F=XM(K,O);try{let L=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(L){if(z.variants.push({path:F,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!z.originalWidth&&L.width)z.originalWidth=L.width,z.originalHeight=L.height}}catch(L){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${L}`)}}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 J$($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function TX($,Z,Y,X){let J=await MX();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 c5($,Z,Y){let X=Y||await MX();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 Bz=D(()=>{C4();RX()});import{resolve as GM,basename as KM,extname as WM,join as UM}from"path";import{mkdir as _M}from"fs/promises";async function BM(){try{return await import("ts-images")}catch{return null}}async function n2($,Z,Y){let X=await BM();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=GM($);if(!await p0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||zM,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await _M(K,{recursive:!0});let U=await l0(J),_=KM($,WM($)),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 O of Q){let F=`${_}-${O}w-${U}.${j}`,L=UM(K,F),V=`${W}/${F}`;try{let w=B[j]?.quality||80;if(await p0(L)){z.byFormat[j].push({path:L,url:V,width:O,height:0,format:j,size:0}),H.push(`${V} ${O}w`);continue}let A=await X.processImage({input:J,output:L,format:j,quality:w,resize:{width:O}});if(A)z.byFormat[j].push({path:L,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${O}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${w}`)}}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||qM(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function qM($){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 r2($,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 zM;var zz=D(()=>{C4();zM=[320,480,640,768,1024,1280,1536,1920]});var qz={};e(qz,{setCachedImageResult:()=>J$,processImage:()=>EX,optimizeImage:()=>TX,getCachedImageResult:()=>X$,generateSrcset:()=>r2,generateResponsiveVariants:()=>n2,clearImageCache:()=>NX,applyTransformations:()=>c5,ImageProcessorCache:()=>Y$});var IX=D(()=>{Bz();zz();RX()});async function jM(){try{return await Promise.resolve().then(() => (IX(),qz))}catch($){if(!jz)console.warn("[stx-media] Image processor not available, some features disabled:",$),jz=!0;return null}}async function y4($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return FM(X,Y)}if(Y.processedResult?.processed)return CX($,Y.processedResult,Z);if(Y.responsiveVariants)return Fz($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,dpr:_,formats:B=e1,quality:z=DX,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:F=!1,loading:L=F?"eager":s2,decoding:V=a2,fetchpriority:w,objectFit:A,objectPosition:N,crossorigin:M,referrerpolicy:E}=$,I=$.class,T=$.style,S=$.id,k=$.data||{},{isDev:b=!1,baseUrl:y=""}=Z;if(b&&!Z.optimize)return LM($);let v,C,f=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{v=await d5(J,{strategy:j,...H}),C=h5(f,v,H)}catch{}let h=_!==void 0&&G!==void 0,d;if(h)d=OM($,f,v,Z);else d=await HM($,f,v,Z);let i;if(F){let z0=B.includes("webp")?"webp":B[0],y0=b4(J,U,{...q,q:z},z0),S0=typeof W==="object"?r6(W):W||"100vw";i=`<link rel="preload" as="image" imagesrcset="${y0}" imagesizes="${S0}" />`}let n=[];if(!Hz&&j!=="none")n.push(s6),Hz=!0;if(C)n.push(C);let W0=O?Lz(f):void 0;return{html:d,preloadLink:i,css:n.length>0?n.join(`
9068
- `):void 0,script:W0}}async function HM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,formats:_=e1,quality:B=DX,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":s2,decoding:O=a2,fetchpriority:F,objectFit:L,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,N=$.class,M=$.style,E=$.data||{},I=typeof W==="object"?r6(W):W||"100vw",T=[];for(let b of _){let y=b4(J,U,{...z,q:B},b),v=g5(b);if(q&&!j)T.push(` <source type="${v}" data-srcset="${y}" data-sizes="${I}" />`);else T.push(` <source type="${v}" srcset="${y}" sizes="${I}" />`)}let S=kX({src:E1(J,{...z,q:B}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":F,objectFit:L,objectPosition:V,crossorigin:w,referrerpolicy:A,className:Oz(N,Y),style:SX(M,L,V,Y),lazy:q&&!j,data:E}),k;if(Y){let b=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${b}">
9067
+ `.trim();a4=new Map});import{createHash as VX}from"crypto";import{readFile as nR,stat as Yz}from"fs/promises";async function l0($){try{let Z=await nR($);return VX("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function Xz($){return VX("sha256").update($).digest("hex").slice(0,16)}function l2($){return VX("sha256").update($).digest("hex").slice(0,16)}function o4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${l2($)}-${l2(Y)}`}async function u5($){try{return(await Yz($)).mtimeMs}catch{return 0}}async function p0($){try{return await Yz($),!0}catch{return!1}}var C6=()=>{};import{mkdir as rR,readFile as Qz,writeFile as aR,readdir as Gz,rm as AX,stat as sR}from"fs/promises";import{join as t4,dirname as oR}from"path";async function tR($){try{await rR($,{recursive:!0})}catch{}}function Kz($,Z,Y){return t4($,Y,`${Z}.json`)}async function Jz($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await u5(Z)!==$.srcMtime)return!1;return!0}async function e4($,Z,Y,X=m5){if(!X.enabled)return null;let J=o4($,Z),Q=P6.get(J);if(Q){if(await Jz(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;P6.delete(J)}let G=Kz(X.directory,J,Y);if(await p0(G))try{let K=await Qz(G,"utf-8"),W=JSON.parse(K);if(await Jz(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),P6.set(J,W),W.data}catch{}return null}async function $$($,Z,Y,X,J=m5){if(!J.enabled)return;let Q=o4($,Z),G=await l0($),K=await u5($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:o4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};P6.set(Q,W);let U=Kz(J.directory,Q,X);try{await tR(oR(U)),await aR(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function Z$($,Z=m5){if($==="all")P6.clear();else P6.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=t4(Z.directory,X);try{await AX(J,{recursive:!0,force:!0})}catch{}}}async function Wz($=m5){let Z={memoryEntries:P6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=t4($.directory,Y);try{let J=await Gz(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=t4(X,Q),K=await sR(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function Uz($=m5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=t4($.directory,X);try{let Q=await Gz(J);for(let G of Q){let K=t4(J,G);try{let W=await Qz(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await AX(K),P6.delete(U.key),Z++}catch{await AX(K).catch(()=>{}),Z++}}}catch{}}return Z}var P6,m5;var p2=D(()=>{C6();P6=new Map,m5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class Y${config;constructor($={}){this.config={...eR,...$}}async get($,Z){return e4($,Z,"image",this.config)}async set($,Z,Y){return $$($,Z,Y,"image",this.config)}async clear(){return Z$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function wX($){if(!i2)i2=new Y$($);else if($)i2.updateConfig($);return i2}async function X$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return wX(X).get($,Z)}async function J$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return wX(J).set($,Z,Y)}async function NX(){return wX().clear()}var eR,i2=null;var RX=D(()=>{p2();eR={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as $M,basename as ZM,extname as YM,join as XM}from"path";import{mkdir as JM}from"fs/promises";async function MX(){try{return await import("ts-images")}catch{return null}}function _z($){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 QM($,Z){let Y=Z?_z(Z):_z("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 EX($,Z,Y){let X=await MX();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await X$($,Z,Y);if(J)return J;try{let Q=$M($);if(!await p0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=QM(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await JM(K,{recursive:!0});let U=await l0(Q),_=ZM($,YM($)),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 c5(Q,Z.transformations,X);for(let j of B){let H=G[j]||{},O=`${_}-${U}.${j}`,F=XM(K,O);try{let L=await X.optimizeImage({input:q||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(L){if(z.variants.push({path:F,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!z.originalWidth&&L.width)z.originalWidth=L.width,z.originalHeight=L.height}}catch(L){z.errors=z.errors||[],z.errors.push(`Failed to optimize ${j}: ${L}`)}}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 J$($,Z,z,Y),z}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function TX($,Z,Y,X){let J=await MX();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 c5($,Z,Y){let X=Y||await MX();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 Bz=D(()=>{C6();RX()});import{resolve as GM,basename as KM,extname as WM,join as UM}from"path";import{mkdir as _M}from"fs/promises";async function BM(){try{return await import("ts-images")}catch{return null}}async function n2($,Z,Y){let X=await BM();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=GM($);if(!await p0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||zM,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await _M(K,{recursive:!0});let U=await l0(J),_=KM($,WM($)),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 O of Q){let F=`${_}-${O}w-${U}.${j}`,L=UM(K,F),V=`${W}/${F}`;try{let w=B[j]?.quality||80;if(await p0(L)){z.byFormat[j].push({path:L,url:V,width:O,height:0,format:j,size:0}),H.push(`${V} ${O}w`);continue}let A=await X.processImage({input:J,output:L,format:j,quality:w,resize:{width:O}});if(A)z.byFormat[j].push({path:L,url:V,width:O,height:A.height||Math.round(O*(A.height||1)/(A.width||1)),format:j,size:A.outputSize||0}),H.push(`${V} ${O}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${w}`)}}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||qM(Q),z}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function qM($){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 r2($,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 zM;var zz=D(()=>{C6();zM=[320,480,640,768,1024,1280,1536,1920]});var qz={};e(qz,{setCachedImageResult:()=>J$,processImage:()=>EX,optimizeImage:()=>TX,getCachedImageResult:()=>X$,generateSrcset:()=>r2,generateResponsiveVariants:()=>n2,clearImageCache:()=>NX,applyTransformations:()=>c5,ImageProcessorCache:()=>Y$});var IX=D(()=>{Bz();zz();RX()});async function jM(){try{return await Promise.resolve().then(() => (IX(),qz))}catch($){if(!jz)console.warn("[stx-media] Image processor not available, some features disabled:",$),jz=!0;return null}}async function y6($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return FM(X,Y)}if(Y.processedResult?.processed)return CX($,Y.processedResult,Z);if(Y.responsiveVariants)return Fz($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,dpr:_,formats:B=e1,quality:z=DX,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:F=!1,loading:L=F?"eager":s2,decoding:V=a2,fetchpriority:w,objectFit:A,objectPosition:N,crossorigin:M,referrerpolicy:E}=$,I=$.class,T=$.style,S=$.id,k=$.data||{},{isDev:b=!1,baseUrl:y=""}=Z;if(b&&!Z.optimize)return LM($);let v,C,f=S||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{v=await d5(J,{strategy:j,...H}),C=h5(f,v,H)}catch{}let h=_!==void 0&&G!==void 0,d;if(h)d=OM($,f,v,Z);else d=await HM($,f,v,Z);let i;if(F){let z0=B.includes("webp")?"webp":B[0],y0=b6(J,U,{...q,q:z},z0),S0=typeof W==="object"?r4(W):W||"100vw";i=`<link rel="preload" as="image" imagesrcset="${y0}" imagesizes="${S0}" />`}let n=[];if(!Hz&&j!=="none")n.push(s4),Hz=!0;if(C)n.push(C);let W0=O?Lz(f):void 0;return{html:d,preloadLink:i,css:n.length>0?n.join(`
9068
+ `):void 0,script:W0}}async function HM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=d1,formats:_=e1,quality:B=DX,params:z={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":s2,decoding:O=a2,fetchpriority:F,objectFit:L,objectPosition:V,crossorigin:w,referrerpolicy:A}=$,N=$.class,M=$.style,E=$.data||{},I=typeof W==="object"?r4(W):W||"100vw",T=[];for(let b of _){let y=b6(J,U,{...z,q:B},b),v=g5(b);if(q&&!j)T.push(` <source type="${v}" data-srcset="${y}" data-sizes="${I}" />`);else T.push(` <source type="${v}" srcset="${y}" sizes="${I}" />`)}let S=kX({src:E1(J,{...z,q:B}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":F,objectFit:L,objectPosition:V,crossorigin:w,referrerpolicy:A,className:Oz(N,Y),style:SX(M,L,V,Y),lazy:q&&!j,data:E}),k;if(Y){let b=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;k=`<div id="${Z}" class="stx-img-placeholder" style="${b}">
9069
9069
  <picture>
9070
9070
  ${T.join(`
9071
9071
  `)}
@@ -9075,7 +9075,7 @@ ${T.join(`
9075
9075
  ${T.join(`
9076
9076
  `)}
9077
9077
  <img ${S} />
9078
- </picture>`;return k}function OM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=DX,params:_={},lazy:B=!0,priority:z=!1,loading:q=z?"eager":s2,decoding:j=a2,fetchpriority:H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V}=$,w=$.class,A=$.style,N=$.data||{},M=typeof G==="number"?G:Number.parseInt(String(G),10),E=n6(J,M,W,{..._,q:U}),I=kX({src:E1(J,{..._,w:M,q:U}),alt:Q,width:G,height:K,loading:z?void 0:q,decoding:j,fetchpriority:z?"high":H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V,className:Oz(w,Y),style:SX(A,O,F,Y),lazy:B&&!z,data:N}),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}">
9078
+ </picture>`;return k}function OM($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:W=[1,2,3],quality:U=DX,params:_={},lazy:B=!0,priority:z=!1,loading:q=z?"eager":s2,decoding:j=a2,fetchpriority:H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V}=$,w=$.class,A=$.style,N=$.data||{},M=typeof G==="number"?G:Number.parseInt(String(G),10),E=n4(J,M,W,{..._,q:U}),I=kX({src:E1(J,{..._,w:M,q:U}),alt:Q,width:G,height:K,loading:z?void 0:q,decoding:j,fetchpriority:z?"high":H,objectFit:O,objectPosition:F,crossorigin:L,referrerpolicy:V,className:Oz(w,Y),style:SX(A,O,F,Y),lazy:B&&!z,data:N}),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}">
9079
9079
  <img ${I} ${T} />
9080
9080
  </div>`}return`<img ${Z?`id="${Z}" `:""}${I} ${T} />`}function LM($){let{src:Z,alt:Y,width:X,height:J,loading:Q=s2,decoding:G=a2,fetchpriority:K,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:B,priority:z=!1}=$,q=$.class,j=$.style,H=$.id,O=$.data||{};return{html:`<img ${kX({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:SX(j,W,U),id:H,data:O})} />`}}function kX($){let Z=[];if($.lazy)Z.push(`data-src="${T1($.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${T1($.src)}"`);if(Z.push(`alt="${T1($.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="${T1($.className)}"`);if($.style)Z.push(`style="${T1($.style)}"`);if($.id)Z.push(`id="${T1($.id)}"`);if($.data)for(let[Y,X]of Object.entries($.data))Z.push(`data-${Y}="${T1(X)}"`);if($.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function Oz($,Z){let Y=[];if($)Y.push($);if(Z)Y.push("stx-img-blur");return Y.join(" ")||""}function SX($,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 T1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Lz($){return`
9081
9081
  (function() {
@@ -9114,7 +9114,7 @@ ${T.join(`
9114
9114
 
9115
9115
  observer.observe(container);
9116
9116
  })();
9117
- `.trim()}function o2($){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 bX($,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=o2(_);if(B){let z=await y4(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 FM($,Z){let Y=await jM();if(!Y)return y4({...$,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 Fz($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return CX($,Q,Z)}return y4({...$,process:!1},Z)}async function CX($,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||{},O=Z.variants||[],F=O.find((C)=>C.format==="jpeg")||O.find((C)=>C.format==="webp")||O[0],L=F?.url||$.src,V=O.filter((C)=>C.format===(F?.format||"jpeg")).map((C)=>`${C.url} ${C.width}w`).join(", "),w=new Map;for(let C of O){if(!w.has(C.format))w.set(C.format,[]);w.get(C.format).push(C)}let A=[],N=["avif","webp","jpeg","png"];for(let C of N){let f=w.get(C);if(f&&f.length>0){let h=f.map((i)=>`${i.url} ${i.width}w`).join(", "),d=g5(C);if(G&&!K)A.push(` <source type="${d}" data-srcset="${h}" />`);else A.push(` <source type="${d}" srcset="${h}" />`)}}let M=[];if(G&&!K){if(M.push(`data-src="${T1(L)}"`),M.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)M.push(`data-srcset="${V}"`)}else if(M.push(`src="${T1(L)}"`),V)M.push(`srcset="${V}"`);M.push(`alt="${T1(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[C,f]of Object.entries(H))M.push(`data-${C}="${T1(f)}"`);let k;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let C=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="${C}">
9117
+ `.trim()}function o2($){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 bX($,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=o2(_);if(B){let z=await y6(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 FM($,Z){let Y=await jM();if(!Y)return y6({...$,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 Fz($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return CX($,Q,Z)}return y6({...$,process:!1},Z)}async function CX($,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||{},O=Z.variants||[],F=O.find((C)=>C.format==="jpeg")||O.find((C)=>C.format==="webp")||O[0],L=F?.url||$.src,V=O.filter((C)=>C.format===(F?.format||"jpeg")).map((C)=>`${C.url} ${C.width}w`).join(", "),w=new Map;for(let C of O){if(!w.has(C.format))w.set(C.format,[]);w.get(C.format).push(C)}let A=[],N=["avif","webp","jpeg","png"];for(let C of N){let f=w.get(C);if(f&&f.length>0){let h=f.map((i)=>`${i.url} ${i.width}w`).join(", "),d=g5(C);if(G&&!K)A.push(` <source type="${d}" data-srcset="${h}" />`);else A.push(` <source type="${d}" srcset="${h}" />`)}}let M=[];if(G&&!K){if(M.push(`data-src="${T1(L)}"`),M.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),V)M.push(`data-srcset="${V}"`)}else if(M.push(`src="${T1(L)}"`),V)M.push(`srcset="${V}"`);M.push(`alt="${T1(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[C,f]of Object.entries(H))M.push(`data-${C}="${T1(f)}"`);let k;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let C=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="${C}">
9118
9118
  <picture>
9119
9119
  ${A.join(`
9120
9120
  `)}
@@ -9124,12 +9124,12 @@ ${A.join(`
9124
9124
  ${A.join(`
9125
9125
  `)}
9126
9126
  <img ${M.join(" ")} />
9127
- </picture>`;let b=[];if(Z.placeholder)b.push(s6);let y=G?Lz(j):void 0,v;if(K&&V)v=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:v,css:b.length>0?b.join(`
9128
- `):void 0,script:y}}async function Fz($,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 CX($,X,Y)}var jz=!1,DX=80,a2="async",s2="lazy",Hz=!1;var PX=D(()=>{m2();FX()});function t2(){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}=VM($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||d1,formats:G.formats||e1,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 y4(K,{isDev:W}),_=U.html;if(U.preloadLink)_=U.preloadLink+`
9127
+ </picture>`;let b=[];if(Z.placeholder)b.push(s4);let y=G?Lz(j):void 0,v;if(K&&V)v=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:k,preloadLink:v,css:b.length>0?b.join(`
9128
+ `):void 0,script:y}}async function Fz($,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 CX($,X,Y)}var jz=!1,DX=80,a2="async",s2="lazy",Hz=!1;var PX=D(()=>{m2();FX()});function t2(){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}=VM($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||d1,formats:G.formats||e1,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 y6(K,{isDev:W}),_=U.html;if(U.preloadLink)_=U.preloadLink+`
9129
9129
  `+_;if(U.css)_+=`
9130
9130
  <style>${U.css}</style>`;if(U.script)_+=`
9131
- <script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function VM($,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=AM(X),Q=yX(J[0],Y)||"",G=yX(J[1],Y)||"",K={};if(J[2]){let W=yX(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 AM($){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 yX($,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 l5;var xX=D(()=>{y5();PX();m2();l5=t2()});class Q${config;constructor($={}){this.config={...wM,...$}}async get($,Z){return e6($,Z,"video",this.config)}async set($,Z,Y){return $$($,Z,Y,"video",this.config)}async clear(){return Z$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function vX($){if(!e2)e2=new Q$($);else if($)e2.updateConfig($);return e2}async function G$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return vX(X).get($,Z)}async function K$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return vX(J).set($,Z,Y)}async function $3(){return vX().clear()}var wM,e2=null;var gX=D(()=>{p2();wM={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as fX,basename as hX,extname as dX,join as Z3}from"path";import{mkdir as uX}from"fs/promises";async function mX(){try{return await import("ts-videos")}catch{return null}}async function W$($,Z,Y,X){let J=await mX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=fX($);if(!await p0(Q))return null;await uX(Y,{recursive:!0});let G=await l0(Q),K=hX($,dX($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,B=Z3(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 U$($,Z,Y,X){let J=await mX();if(!J)return[];try{let Q=fX($);if(!await p0(Q))return[];await uX(Y,{recursive:!0});let G=await l0(Q),K=hX($,dX($)),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 O=0;O<z&&O*q<B;O++)j.push(O*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((O,F)=>({path:O.path||Z3(Y,`${K}-thumb-${G}-${F}.${W}`),url:`${X}/${K}-thumb-${G}-${F}.${W}`,width:O.width||Z.width||320,height:O.height||180,timestamp:j[F],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function Y3($,Z,Y,X){let J=await mX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=fX($);if(!await p0(Q))return null;await uX(Y,{recursive:!0});let G=await l0(Q),K=hX($,dX($)),_=(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",O=Math.ceil(_/z),F=Math.ceil(O/B),L=`${K}-sprite-${G}.${H}`,V=Z3(Y,L),w=[];for(let N=0;N<O;N++)w.push(N*z);let A=await J.extractThumbnails(Q,{timestamps:w,width:q,height:j,format:H,quality:Z.quality||70,outputDir:Z3(Y,".temp")});if(!A||A.length===0)return null;try{let N=await import("ts-images"),M=B*q,E=F*j,I=await N.createSprite({images:A.map((T)=>T.path),columns:B,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${L}`,path:V,columns:B,rows:F,thumbnailWidth:q,thumbnailHeight:j,interval:z,totalFrames:O}}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 cX=D(()=>{C4()});import{resolve as Az,basename as wz,extname as Nz,join as X6}from"path";import{mkdir as X3,writeFile as Rz}from"fs/promises";async function Mz(){try{return await import("ts-videos")}catch{return null}}async function _$($,Z,Y,X,J){let Q=await Mz();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=Az($);if(!await p0(G))return null;let K=await l0(G),W=wz($,Nz($)),U=X6(Y,`${W}-${K}-hls`);await X3(U,{recursive:!0});let _=Z.length>0?Z:Ez,B=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],O=0;for(let V of _){let w=X6(U,V.label);await X3(w,{recursive:!0});let A=`${V.label}.m3u8`,N=X6(w,A);try{let M=await Q.generateHLS(G,{outputDir:w,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:N}),O+=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=X6(U,"master.m3u8"),L=NM(H,X,W,K);return await Rz(F,L),{manifestUrl:`${X}/${W}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:O,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function NM($,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(`
9132
- `)}async function B$($,Z,Y,X,J){let Q=await Mz();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=Az($);if(!await p0(G))return null;let K=await l0(G),W=wz($,Nz($)),U=X6(Y,`${W}-${K}-dash`);await X3(U,{recursive:!0});let _=Z.length>0?Z:Ez,B=J?.segmentDuration||4,z=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,O=[],F=[];for(let A of _){let N=X6(U,A.label);await X3(N,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:N,segmentDuration:B,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(O.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(O.length===0)return null;let L=X6(U,"manifest.mpd"),V=RM(O,F,H,B,z);await Rz(L,V);let w=[{type:"video",representations:O}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${X}/${W}-${K}-dash/manifest.mpd`,manifestPath:L,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function RM($,Z,Y,X,J){let Q=Vz(Y),G=Vz(J),K=`<?xml version="1.0" encoding="UTF-8"?>
9131
+ <script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function VM($,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=AM(X),Q=yX(J[0],Y)||"",G=yX(J[1],Y)||"",K={};if(J[2]){let W=yX(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 AM($){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 yX($,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 l5;var xX=D(()=>{y5();PX();m2();l5=t2()});class Q${config;constructor($={}){this.config={...wM,...$}}async get($,Z){return e4($,Z,"video",this.config)}async set($,Z,Y){return $$($,Z,Y,"video",this.config)}async clear(){return Z$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function vX($){if(!e2)e2=new Q$($);else if($)e2.updateConfig($);return e2}async function G$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return vX(X).get($,Z)}async function K$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return vX(J).set($,Z,Y)}async function $3(){return vX().clear()}var wM,e2=null;var gX=D(()=>{p2();wM={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as fX,basename as hX,extname as dX,join as Z3}from"path";import{mkdir as uX}from"fs/promises";async function mX(){try{return await import("ts-videos")}catch{return null}}async function W$($,Z,Y,X){let J=await mX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=fX($);if(!await p0(Q))return null;await uX(Y,{recursive:!0});let G=await l0(Q),K=hX($,dX($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,B=Z3(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 U$($,Z,Y,X){let J=await mX();if(!J)return[];try{let Q=fX($);if(!await p0(Q))return[];await uX(Y,{recursive:!0});let G=await l0(Q),K=hX($,dX($)),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 O=0;O<z&&O*q<B;O++)j.push(O*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((O,F)=>({path:O.path||Z3(Y,`${K}-thumb-${G}-${F}.${W}`),url:`${X}/${K}-thumb-${G}-${F}.${W}`,width:O.width||Z.width||320,height:O.height||180,timestamp:j[F],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function Y3($,Z,Y,X){let J=await mX();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=fX($);if(!await p0(Q))return null;await uX(Y,{recursive:!0});let G=await l0(Q),K=hX($,dX($)),_=(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",O=Math.ceil(_/z),F=Math.ceil(O/B),L=`${K}-sprite-${G}.${H}`,V=Z3(Y,L),w=[];for(let N=0;N<O;N++)w.push(N*z);let A=await J.extractThumbnails(Q,{timestamps:w,width:q,height:j,format:H,quality:Z.quality||70,outputDir:Z3(Y,".temp")});if(!A||A.length===0)return null;try{let N=await import("ts-images"),M=B*q,E=F*j,I=await N.createSprite({images:A.map((T)=>T.path),columns:B,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${X}/${L}`,path:V,columns:B,rows:F,thumbnailWidth:q,thumbnailHeight:j,interval:z,totalFrames:O}}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 cX=D(()=>{C6()});import{resolve as Az,basename as wz,extname as Nz,join as X4}from"path";import{mkdir as X3,writeFile as Rz}from"fs/promises";async function Mz(){try{return await import("ts-videos")}catch{return null}}async function _$($,Z,Y,X,J){let Q=await Mz();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=Az($);if(!await p0(G))return null;let K=await l0(G),W=wz($,Nz($)),U=X4(Y,`${W}-${K}-hls`);await X3(U,{recursive:!0});let _=Z.length>0?Z:Ez,B=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],O=0;for(let V of _){let w=X4(U,V.label);await X3(w,{recursive:!0});let A=`${V.label}.m3u8`,N=X4(w,A);try{let M=await Q.generateHLS(G,{outputDir:w,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:N}),O+=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=X4(U,"master.m3u8"),L=NM(H,X,W,K);return await Rz(F,L),{manifestUrl:`${X}/${W}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:O,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function NM($,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(`
9132
+ `)}async function B$($,Z,Y,X,J){let Q=await Mz();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=Az($);if(!await p0(G))return null;let K=await l0(G),W=wz($,Nz($)),U=X4(Y,`${W}-${K}-dash`);await X3(U,{recursive:!0});let _=Z.length>0?Z:Ez,B=J?.segmentDuration||4,z=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,O=[],F=[];for(let A of _){let N=X4(U,A.label);await X3(N,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:N,segmentDuration:B,width:A.width,height:A.height,videoBitrate:A.bitrate,audioBitrate:A.audioBitrate})){if(O.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(O.length===0)return null;let L=X4(U,"manifest.mpd"),V=RM(O,F,H,B,z);await Rz(L,V);let w=[{type:"video",representations:O}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${X}/${W}-${K}-dash/manifest.mpd`,manifestPath:L,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function RM($,Z,Y,X,J){let Q=Vz(Y),G=Vz(J),K=`<?xml version="1.0" encoding="UTF-8"?>
9133
9133
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
9134
9134
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9135
9135
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
@@ -9155,7 +9155,7 @@ ${A.join(`
9155
9155
  </Representation>
9156
9156
  `}K+=` </AdaptationSet>
9157
9157
  `}return K+=` </Period>
9158
- </MPD>`,K}function Vz($){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 Ez;var lX=D(()=>{C4();Ez=[{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 Tz,basename as MM,extname as EM,join as TM}from"path";import{mkdir as IM}from"fs/promises";async function Iz(){try{return await import("ts-videos")}catch{return null}}function DM($){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 kM($){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 p5($){let Z=await Iz();if(!Z)return null;try{let Y=Tz($),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 J3($,Z,Y,X){let J=await Iz();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await G$($,Z,Y);if(Q)return Q;try{let G=Tz($);if(!await p0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await IM(K,{recursive:!0});let U=await l0(G),_=MM($,EM($)),B={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),B.metadata=await p5(G)||void 0;let z={};if(Z.quality)z.bitrate=DM(Z.quality);if(Z.platform)Object.assign(z,kM(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=TM(K,q);try{let H=await SM(G,j,z,J,(O)=>X?.({percentage:10+O*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 W$(G,q,K,W);if(j)B.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await U$(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 _$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,hls:j}}if(q.format==="dash"){let j=await B$(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 K$($,Z,B,Y),B}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function SM($,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 Dz=D(()=>{C4();gX();cX();lX()});var kz={};e(kz,{setCachedVideoResult:()=>K$,processVideo:()=>J3,getCachedVideoResult:()=>G$,generateThumbnails:()=>U$,generateSpriteSheet:()=>Y3,generatePoster:()=>W$,generateHLSManifest:()=>_$,generateDASHManifest:()=>B$,clearVideoCache:()=>$3,analyzeVideo:()=>p5,VideoProcessorCache:()=>Q$});var pX=D(()=>{Dz();cX();lX();gX()});async function bz(){try{return await Promise.resolve().then(() => (pX(),kz))}catch($){if(!Sz)console.warn("[stx-media] Video processor not available, some features disabled:",$),Sz=!0;return null}}async function z$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return vM(X,Y)}if(Y.processedResult?.processed)return vz($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await gM(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=Cz,autoplay:_=!1,muted:B=!1,loop:z=!1,preload:q=Pz,playsinline:j=!0,lazy:H=!0,player:O="native",type:F,width:L,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:N=!1}=$,M=J||K,E=$.class,I=$.style,T=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return PM($,Z);if(F&&F!=="video")return CM(Q||"",F,$);let S=G.length>0?G:Q?[{src:Q,type:yz(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(N)k.push("disableremoteplayback");if(w)k.push(`crossorigin="${w}"`);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(L)k.push(`width="${L}"`);if(V)k.push(`height="${V}"`);if(E)k.push(`class="${h0(E)}"`);if(I)k.push(`style="${h0(I)}"`);let b=S.map((C)=>{return` <source ${H?`data-src="${h0(C.src)}"`:`src="${h0(C.src)}"`} type="${C.type}"${C.media?` media="${C.media}"`:""} />`}).join(`
9158
+ </MPD>`,K}function Vz($){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 Ez;var lX=D(()=>{C6();Ez=[{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 Tz,basename as MM,extname as EM,join as TM}from"path";import{mkdir as IM}from"fs/promises";async function Iz(){try{return await import("ts-videos")}catch{return null}}function DM($){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 kM($){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 p5($){let Z=await Iz();if(!Z)return null;try{let Y=Tz($),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 J3($,Z,Y,X){let J=await Iz();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await G$($,Z,Y);if(Q)return Q;try{let G=Tz($);if(!await p0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await IM(K,{recursive:!0});let U=await l0(G),_=MM($,EM($)),B={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),B.metadata=await p5(G)||void 0;let z={};if(Z.quality)z.bitrate=DM(Z.quality);if(Z.platform)Object.assign(z,kM(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=TM(K,q);try{let H=await SM(G,j,z,J,(O)=>X?.({percentage:10+O*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 W$(G,q,K,W);if(j)B.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await U$(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 _$(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)B.streaming={...B.streaming,hls:j}}if(q.format==="dash"){let j=await B$(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 K$($,Z,B,Y),B}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function SM($,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 Dz=D(()=>{C6();gX();cX();lX()});var kz={};e(kz,{setCachedVideoResult:()=>K$,processVideo:()=>J3,getCachedVideoResult:()=>G$,generateThumbnails:()=>U$,generateSpriteSheet:()=>Y3,generatePoster:()=>W$,generateHLSManifest:()=>_$,generateDASHManifest:()=>B$,clearVideoCache:()=>$3,analyzeVideo:()=>p5,VideoProcessorCache:()=>Q$});var pX=D(()=>{Dz();cX();lX();gX()});async function bz(){try{return await Promise.resolve().then(() => (pX(),kz))}catch($){if(!Sz)console.warn("[stx-media] Video processor not available, some features disabled:",$),Sz=!0;return null}}async function z$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return vM(X,Y)}if(Y.processedResult?.processed)return vz($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await gM(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=Cz,autoplay:_=!1,muted:B=!1,loop:z=!1,preload:q=Pz,playsinline:j=!0,lazy:H=!0,player:O="native",type:F,width:L,height:V,crossorigin:w,disablePictureInPicture:A=!1,disableRemotePlayback:N=!1}=$,M=J||K,E=$.class,I=$.style,T=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return PM($,Z);if(F&&F!=="video")return CM(Q||"",F,$);let S=G.length>0?G:Q?[{src:Q,type:yz(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(N)k.push("disableremoteplayback");if(w)k.push(`crossorigin="${w}"`);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(L)k.push(`width="${L}"`);if(V)k.push(`height="${V}"`);if(E)k.push(`class="${h0(E)}"`);if(I)k.push(`style="${h0(I)}"`);let b=S.map((C)=>{return` <source ${H?`data-src="${h0(C.src)}"`:`src="${h0(C.src)}"`} type="${C.type}"${C.media?` media="${C.media}"`:""} />`}).join(`
9159
9159
  `),y=`<video ${k.join(" ")}>
9160
9160
  ${b}
9161
9161
  Your browser does not support the video tag.
@@ -9713,7 +9713,7 @@ catch (error) {
9713
9713
  init();
9714
9714
  }
9715
9715
  })();
9716
- </script>`}var lM,pM,iM,nM,fz;var hz=D(()=>{lM={name:"pwa.installButton",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return dM($,J)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},pM={name:"pwa.updatePrompt",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return uM($,J)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},iM={name:"pwa.offlineIndicator",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return mM($,J)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},nM={name:"pwa.pushSubscribe",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return cM($,J)},hasEndTag:!0,description:"Renders a push notification subscription button"},fz=[lM,pM,iM,nM]});import rM from"fs";import x4 from"path";async function rX($,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 aM(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 aM($,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(x4.isAbsolute(J)&&await X0(J))K=J;else if(Z.componentsDir){let H=x4.join(Z.componentsDir,J);if(await X0(H))K=H}if(!K)K=await C5(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=_?oM({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[],attributeTypes:$.attributeTypes||{}}):sM({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 rM.promises.mkdir(z,{recursive:!0});let q=_?"ts":"js",j=x4.join(z,`${Q}.${q}`);if(await Bun.write(j,B),Z.debug)console.log(`Built web component ${X} -> ${j}`);return j}function sM($){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`/**
9716
+ </script>`}var lM,pM,iM,nM,fz;var hz=D(()=>{lM={name:"pwa.installButton",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return dM($,J)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},pM={name:"pwa.updatePrompt",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return uM($,J)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},iM={name:"pwa.offlineIndicator",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return mM($,J)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},nM={name:"pwa.pushSubscribe",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return cM($,J)},hasEndTag:!0,description:"Renders a push notification subscription button"},fz=[lM,pM,iM,nM]});import rM from"fs";import x6 from"path";async function rX($,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 aM(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 aM($,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(x6.isAbsolute(J)&&await X0(J))K=J;else if(Z.componentsDir){let H=x6.join(Z.componentsDir,J);if(await X0(H))K=H}if(!K)K=await C5(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=_?oM({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[],attributeTypes:$.attributeTypes||{}}):sM({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 rM.promises.mkdir(z,{recursive:!0});let q=_?"ts":"js",j=x6.join(z,`${Q}.${q}`);if(await Bun.write(j,B),Z.debug)console.log(`Built web component ${X} -> ${j}`);return j}function sM($){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`/**
9717
9717
  * ${Z} Web Component
9718
9718
  * Auto-generated from stx component
9719
9719
  */
@@ -10790,9 +10790,9 @@ ${_}
10790
10790
  }
10791
10791
 
10792
10792
  customElements.define('${Z}', ${G});
10793
- `}async function sX($,Z,Y,X){if(Z.length<1)return K0("WebComponent","@webcomponent directive requires at least the tag name parameter",Z0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[x4.join(x4.dirname(X),G,`${J}.stx`),x4.join(process.cwd(),G,`${J}.stx`),x4.join(x4.dirname(X),`${J}.stx`)],W=null;for(let B of K)if(await X0(B)){W=await Bun.file(B).text();break}if(!W)return K0("WebComponent",`Component file not found: ${J}.stx`,Z0.FILE_NOT_FOUND);let U=mz(W,J);return`<script type="module">
10793
+ `}async function sX($,Z,Y,X){if(Z.length<1)return K0("WebComponent","@webcomponent directive requires at least the tag name parameter",Z0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[x6.join(x6.dirname(X),G,`${J}.stx`),x6.join(process.cwd(),G,`${J}.stx`),x6.join(x6.dirname(X),`${J}.stx`)],W=null;for(let B of K)if(await X0(B)){W=await Bun.file(B).text();break}if(!W)return K0("WebComponent",`Component file not found: ${J}.stx`,Z0.FILE_NOT_FOUND);let U=mz(W,J);return`<script type="module">
10794
10794
  ${cz(U)}
10795
- </script>`}var aX;var oX=D(()=>{z1();H0();aX={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var lz={};e(lz,{timingPlugin:()=>_E,pluginManager:()=>eX,definePlugin:()=>j$,debugPlugin:()=>UE,createVariablesPlugin:()=>BE,createFilterPlugin:()=>WE,createDirectivePlugin:()=>KE,PluginManager:()=>tX});function j$($){return $}class tX{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 KE($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function WE($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function BE($){return j$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var eX,UE,_E;var $J=D(()=>{eX=new tX;UE=j$({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)}}),_E=j$({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 c8={};e(c8,{validateConfig:()=>nz,loadStxConfig:()=>f0,defineStxConfig:()=>iz,defaultConfig:()=>K1,config:()=>W1});import ZJ from"fs";import $1 from"path";import{loadConfigWithResult as zE}from"bunfig";function qE($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=$1.join(process.cwd(),"resources","views"),J=$1.join(process.cwd(),"resources","layouts");if(ZJ.existsSync(X)&&ZJ.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=$1.join(process.cwd(),"resources","views","pages");if(ZJ.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function f0($){if(!$){if(H$)return H$;if(K3)return K3}let Z=$?$1.resolve($):process.cwd(),Y=pz.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await zE({name:"stx",alias:"ui",cwd:Z,defaultConfig:K1,verbose:!1})).config,G=qE(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!$1.isAbsolute(Q.partialsDir))Q.partialsDir=$1.join(K,Q.partialsDir);if(Q.componentsDir&&!$1.isAbsolute(Q.componentsDir))Q.componentsDir=$1.join(K,Q.componentsDir);if(Q.layoutsDir&&!$1.isAbsolute(Q.layoutsDir))Q.layoutsDir=$1.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => ($J(),lz)),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=$1.dirname(s.resolve(B))}catch{let O=$1.resolve(process.cwd(),B);q=await import(O),j=$1.dirname(O)}let H=q.default||q;if(K.register(H,Q),H.components){let O=$1.resolve(j,H.components);W.push(O)}if(H.pages){let O=$1.resolve(j,H.pages),F=z.path||"/";U.push({dir:O,prefix:F})}if(H.setup){let O={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=L},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(z,O)}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(pz.set(Z,X),!$)K3=X,X.then((J)=>{H$=J}).catch(()=>{});return X}function iz($){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 K1,H$=null,pz,K3=null,W1;var m0=D(()=>{A6();L9();E8();F9();h2();xX();nX();hz();_2();oX();K1={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:oY,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:sX,hasEndTag:!1,description:"Include a web component in the template"},B9,z9,W2,U2,q9,H9,O9,j9,zK,D8,l5,i5,...fz],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}};pz=new Map;W1=new Proxy(K1,{get($,Z){if(H$&&Z in H$)return H$[Z];if(!K3)f0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import jE from"fs";import YJ from"path";import{createHighlighter as HE}from"ts-syntax-highlighter";async function $4($,Z={}){try{if(!await X0($))throw Error(`Markdown file not found: ${$}`);let X=(await jE.promises.stat($)).mtime.getTime();if(Z.cache&&U3.has($)){let B=U3.get($);if(B.updatedAt>=X)return{content:B.content,data:B.data}}let J=await Bun.file($).text(),{data:Q,content:G}=HK(J),K=Z.markdown||W1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=n$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await OE(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)U3.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:L0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function OE($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!W3)try{W3=await HE({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(!W3.getSupportedLanguages().includes(z))return K;return(await W3.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 pY($,Z,Y="",X={}){return await LE($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!YJ.isAbsolute(K))_=YJ.resolve(YJ.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 L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of L){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),M=N.startsWith('"')&&N.endsWith('"'),E=N.startsWith("'")&&N.endsWith("'");if(M||E)N=N.substring(1,N.length-1);B[A]=N}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:q}=await $4(_,X),j={...Z,...q,...B},H=z,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(F,L)=>{let V=L.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(_){let B=_ instanceof Error?_.message:String(_);return L0("Markdown File",`Error including markdown file: ${B}`,Y,$,U,G)}})}async function LE($,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 U3,W3=null;var i6=D(()=>{m0();H0();U3=new Map});function _3(){return`
10795
+ </script>`}var aX;var oX=D(()=>{z1();H0();aX={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var lz={};e(lz,{timingPlugin:()=>_E,pluginManager:()=>eX,definePlugin:()=>j$,debugPlugin:()=>UE,createVariablesPlugin:()=>BE,createFilterPlugin:()=>WE,createDirectivePlugin:()=>KE,PluginManager:()=>tX});function j$($){return $}class tX{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 KE($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function WE($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function BE($){return j$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var eX,UE,_E;var $J=D(()=>{eX=new tX;UE=j$({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)}}),_E=j$({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 c8={};e(c8,{validateConfig:()=>nz,loadStxConfig:()=>f0,defineStxConfig:()=>iz,defaultConfig:()=>K1,config:()=>W1});import ZJ from"fs";import $1 from"path";import{loadConfigWithResult as zE}from"bunfig";function qE($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=$1.join(process.cwd(),"resources","views"),J=$1.join(process.cwd(),"resources","layouts");if(ZJ.existsSync(X)&&ZJ.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=$1.join(process.cwd(),"resources","views","pages");if(ZJ.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function f0($){if(!$){if(H$)return H$;if(K3)return K3}let Z=$?$1.resolve($):process.cwd(),Y=pz.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await zE({name:"stx",alias:"ui",cwd:Z,defaultConfig:K1,verbose:!1})).config,G=qE(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!$1.isAbsolute(Q.partialsDir))Q.partialsDir=$1.join(K,Q.partialsDir);if(Q.componentsDir&&!$1.isAbsolute(Q.componentsDir))Q.componentsDir=$1.join(K,Q.componentsDir);if(Q.layoutsDir&&!$1.isAbsolute(Q.layoutsDir))Q.layoutsDir=$1.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => ($J(),lz)),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=$1.dirname(s.resolve(B))}catch{let O=$1.resolve(process.cwd(),B);q=await import(O),j=$1.dirname(O)}let H=q.default||q;if(K.register(H,Q),H.components){let O=$1.resolve(j,H.components);W.push(O)}if(H.pages){let O=$1.resolve(j,H.pages),F=z.path||"/";U.push({dir:O,prefix:F})}if(H.setup){let O={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=L},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(z,O)}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(pz.set(Z,X),!$)K3=X,X.then((J)=>{H$=J}).catch(()=>{});return X}function iz($){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 K1,H$=null,pz,K3=null,W1;var m0=D(()=>{A4();L9();E8();F9();h2();xX();nX();hz();_2();oX();K1={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:oY,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:sX,hasEndTag:!1,description:"Include a web component in the template"},B9,z9,W2,U2,q9,H9,O9,j9,zK,D8,l5,i5,...fz],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}};pz=new Map;W1=new Proxy(K1,{get($,Z){if(H$&&Z in H$)return H$[Z];if(!K3)f0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import jE from"fs";import YJ from"path";import{createHighlighter as HE}from"ts-syntax-highlighter";async function $6($,Z={}){try{if(!await X0($))throw Error(`Markdown file not found: ${$}`);let X=(await jE.promises.stat($)).mtime.getTime();if(Z.cache&&U3.has($)){let B=U3.get($);if(B.updatedAt>=X)return{content:B.content,data:B.data}}let J=await Bun.file($).text(),{data:Q,content:G}=HK(J),K=Z.markdown||W1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=n$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await OE(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)U3.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:L0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function OE($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!W3)try{W3=await HE({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(!W3.getSupportedLanguages().includes(z))return K;return(await W3.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 pY($,Z,Y="",X={}){return await LE($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!YJ.isAbsolute(K))_=YJ.resolve(YJ.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 L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of L){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),M=N.startsWith('"')&&N.endsWith('"'),E=N.startsWith("'")&&N.endsWith("'");if(M||E)N=N.substring(1,N.length-1);B[A]=N}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:z,data:q}=await $6(_,X),j={...Z,...q,...B},H=z,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(F,L)=>{let V=L.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(_){let B=_ instanceof Error?_.message:String(_);return L0("Markdown File",`Error including markdown file: ${B}`,Y,$,U,G)}})}async function LE($,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 U3,W3=null;var i4=D(()=>{m0();H0();U3=new Map});function _3(){return`
10796
10796
  /* Theme selector for code blocks */
10797
10797
  .theme-selector {
10798
10798
  margin: 1rem 0;
@@ -10872,12 +10872,12 @@ else {
10872
10872
  <span class="frontmatter-label">${Z}:</span>
10873
10873
  <span>${Array.isArray(Y)?Y.join(", "):String(Y)}</span>
10874
10874
  </div>`).join("")}
10875
- </div>`}var rz=()=>{};import az from"net";async function FE($){return new Promise((Z)=>{let Y=az.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"0.0.0.0")})}async function VE($){return new Promise((Z)=>{let Y=az.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"::")})}async function AE($){if(!await FE($))return!1;return await VE($)}async function v4($,Z=20){for(let Y=0;Y<Z;Y++){let X=$+Y;if(await AE(X))return X}throw Error(`Could not find an available port between ${$} and ${$+Z-1}`)}var sz=()=>{};async function NE(){try{let $=await import("@stacksjs/desktop");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function O$($,Z={}){let Y={...wE,...Z},X=await NE();if(!X)return console.log(`${R.yellow}\u26A0${R.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(`${R.green}\u2713${R.reset} Native sidebar enabled (macOS Tahoe style)`);return J}catch(J){return console.log(`${R.red}\u2717${R.reset} Could not open native window:`,J),!1}}function j3($){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=`
10875
+ </div>`}var rz=()=>{};import az from"net";async function FE($){return new Promise((Z)=>{let Y=az.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"0.0.0.0")})}async function VE($){return new Promise((Z)=>{let Y=az.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"::")})}async function AE($){if(!await FE($))return!1;return await VE($)}async function v6($,Z=20){for(let Y=0;Y<Z;Y++){let X=$+Y;if(await AE(X))return X}throw Error(`Could not find an available port between ${$} and ${$+Z-1}`)}var sz=()=>{};async function NE(){try{let $=await import("@stacksjs/desktop");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function O$($,Z={}){let Y={...wE,...Z},X=await NE();if(!X)return console.log(`${R.yellow}\u26A0${R.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(`${R.green}\u2713${R.reset} Native sidebar enabled (macOS Tahoe style)`);return J}catch(J){return console.log(`${R.red}\u2717${R.reset} Could not open native window:`,J),!1}}function j3($){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=`
10876
10876
  ${Q}
10877
10877
  return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
10878
10878
  `,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 wE;var oz=D(()=>{Y5();wE={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0}});function XJ(){console.log(`
10879
- Keyboard shortcuts:`),console.log(` ${R.cyan}o${R.reset} + Enter - Open in browser`),console.log(` ${R.cyan}c${R.reset} + Enter - Clear console`),console.log(` ${R.cyan}q${R.reset} + Enter (or ${R.cyan}Ctrl+C${R.reset}) - Quit server`),console.log(` ${R.cyan}h${R.reset} + Enter - Show this help`)}function RE($){console.log(`${R.green}Server running at ${R.cyan}${$}${R.reset}`),console.log(`Press ${R.cyan}Ctrl+C${R.reset} to stop the server`),XJ()}function ME($){console.log(`${R.dim}Opening ${R.cyan}${$}${R.dim} in your browser...${R.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function g4($,Z,Y){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),XJ();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(`
10880
- `)){let Q=X.trim().toLowerCase();X="",EE(Q,$,Z,Y)}})}function EE($,Z,Y,X){switch($){case"o":if(X?.onOpen)X.onOpen();else ME(Z);break;case"c":if(X?.onClear)X.onClear();else console.clear(),RE(Z);break;case"q":if(X?.onQuit)X.onQuit();console.log(`${R.yellow}Stopping server...${R.reset}`),Y(),process.exit(0);break;case"h":if(X?.onHelp)X.onHelp();else XJ();break;default:break}}var tz=D(()=>{Y5()});var ez=()=>{};var n5=D(()=>{Y5();P1();rz();sz();oz();tz();ez()});var{serve:TE}=globalThis.Bun;import JJ from"fs";import L$ from"path";async function H3($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=L$.resolve($);if(!JJ.existsSync(J))return console.error(`${R.red}Error: File not found: ${R.bright}${J}${R.reset}`),!1;if(!J.endsWith(".md"))return console.error(`${R.red}Error: File must have .md extension: ${R.bright}${J}${R.reset}`),!1;console.log(`${R.blue}Processing${R.reset} ${R.bright}${$}${R.reset}...`);let Q=null,G=async()=>{try{let{content:B,data:z}=await $4(J,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:W1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),q=Z.markdown?.syntaxHighlighting||W1.markdown?.syntaxHighlighting,j=q?.defaultTheme||"github-dark",H=["github-dark"],O=q?.additionalThemes||[],L=[...new Set([...H,...O])].map((V)=>`<option value="${V}"${V===j?" selected":""}>${V}</option>`).join(`
10879
+ Keyboard shortcuts:`),console.log(` ${R.cyan}o${R.reset} + Enter - Open in browser`),console.log(` ${R.cyan}c${R.reset} + Enter - Clear console`),console.log(` ${R.cyan}q${R.reset} + Enter (or ${R.cyan}Ctrl+C${R.reset}) - Quit server`),console.log(` ${R.cyan}h${R.reset} + Enter - Show this help`)}function RE($){console.log(`${R.green}Server running at ${R.cyan}${$}${R.reset}`),console.log(`Press ${R.cyan}Ctrl+C${R.reset} to stop the server`),XJ()}function ME($){console.log(`${R.dim}Opening ${R.cyan}${$}${R.dim} in your browser...${R.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function g6($,Z,Y){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),XJ();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(`
10880
+ `)){let Q=X.trim().toLowerCase();X="",EE(Q,$,Z,Y)}})}function EE($,Z,Y,X){switch($){case"o":if(X?.onOpen)X.onOpen();else ME(Z);break;case"c":if(X?.onClear)X.onClear();else console.clear(),RE(Z);break;case"q":if(X?.onQuit)X.onQuit();console.log(`${R.yellow}Stopping server...${R.reset}`),Y(),process.exit(0);break;case"h":if(X?.onHelp)X.onHelp();else XJ();break;default:break}}var tz=D(()=>{Y5()});var ez=()=>{};var n5=D(()=>{Y5();P1();rz();sz();oz();tz();ez()});var{serve:TE}=globalThis.Bun;import JJ from"fs";import L$ from"path";async function H3($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=L$.resolve($);if(!JJ.existsSync(J))return console.error(`${R.red}Error: File not found: ${R.bright}${J}${R.reset}`),!1;if(!J.endsWith(".md"))return console.error(`${R.red}Error: File must have .md extension: ${R.bright}${J}${R.reset}`),!1;console.log(`${R.blue}Processing${R.reset} ${R.bright}${$}${R.reset}...`);let Q=null,G=async()=>{try{let{content:B,data:z}=await $6(J,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:W1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),q=Z.markdown?.syntaxHighlighting||W1.markdown?.syntaxHighlighting,j=q?.defaultTheme||"github-dark",H=["github-dark"],O=q?.additionalThemes||[],L=[...new Set([...H,...O])].map((V)=>`<option value="${V}"${V===j?" selected":""}>${V}</option>`).join(`
10881
10881
  `);return Q=`
10882
10882
  <!DOCTYPE html>
10883
10883
  <html lang="en">
@@ -11040,12 +11040,12 @@ Keyboard shortcuts:`),console.log(` ${R.cyan}o${R.reset} + Enter - Open in brow
11040
11040
  </script>
11041
11041
  </body>
11042
11042
  </html>
11043
- `,!0}catch(B){return console.error(`${R.red}Error processing Markdown file:${R.reset}`,B),!1}};if(!await G())return!1;let W=Y;try{if(W=await v4(Y),W!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${W} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${W}/${R.reset}...`);let U=TE({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}
11043
+ `,!0}catch(B){return console.error(`${R.red}Error processing Markdown file:${R.reset}`,B),!1}};if(!await G())return!1;let W=Y;try{if(W=await v6(Y),W!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${W} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${W}/${R.reset}...`);let U=TE({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}
11044
11044
  ${B.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
11045
11045
  ${R.blue}stx${R.reset} ${R.green}${process.env.stx_VERSION||"v0.0.10"}${R.reset} ${R.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${R.reset}`),console.log(`
11046
11046
  ${R.bright}\u2192 ${R.cyan}http://localhost:${W}/${R.reset}`),console.log(`
11047
11047
  ${R.yellow}Routes:${R.reset}`);let _=L$.relative(process.cwd(),J);if(console.log(` ${R.green}\u2514\u2500 /${R.reset} \u2192 ${R.bright}${_}${R.reset}`),console.log(`
11048
- Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g4(U.url.toString(),()=>{if(X)JJ.watch(L$.dirname(J),{recursive:!0}).close();U.stop()}),Z.native)await O$(W,{title:L$.basename(J,".md")});if(X){let B=L$.dirname(J);console.log(`${R.blue}Watching ${R.bright}${B}${R.reset} for changes...`);let z=JJ.watch(B,{recursive:!0},async(q,j)=>{if(j&&j.endsWith(".md"))console.log(`${R.yellow}File ${R.bright}${j}${R.yellow} changed, reprocessing...${R.reset}`),await G()});process.on("SIGINT",()=>{z.close(),U.stop(),process.exit(0)})}return!0}var QJ=D(()=>{i6();m0();n5()});class GJ{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 $q($,Z={}){let{showOverlay:Y=!0,reconnectInterval:X=1000,maxReconnectAttempts:J=10}=Z;return`
11048
+ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g6(U.url.toString(),()=>{if(X)JJ.watch(L$.dirname(J),{recursive:!0}).close();U.stop()}),Z.native)await O$(W,{title:L$.basename(J,".md")});if(X){let B=L$.dirname(J);console.log(`${R.blue}Watching ${R.bright}${B}${R.reset} for changes...`);let z=JJ.watch(B,{recursive:!0},async(q,j)=>{if(j&&j.endsWith(".md"))console.log(`${R.yellow}File ${R.bright}${j}${R.yellow} changed, reprocessing...${R.reset}`),await G()});process.on("SIGINT",()=>{z.close(),U.stop(),process.exit(0)})}return!0}var QJ=D(()=>{i4();m0();n5()});class GJ{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 $q($,Z={}){let{showOverlay:Y=!0,reconnectInterval:X=1000,maxReconnectAttempts:J=10}=Z;return`
11049
11049
  <script>
11050
11050
  (function() {
11051
11051
  // stx Hot Reload Client
@@ -11238,34 +11238,34 @@ else {
11238
11238
  };
11239
11239
  })();
11240
11240
  </script>
11241
- `}function u1($,Z,Y={}){let X=$q(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 r5($){let Z=$.toLowerCase();return Z.endsWith(".css")||Z.endsWith(".scss")||Z.endsWith(".sass")||Z.endsWith(".less")}function a5($){let Z=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((X)=>Z.endsWith(X))}function s5($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Y)=>Y.test($))}function o5($){if(!F$)F$=new GJ($);return F$}function V$(){if(F$)F$.stop(),F$=null}var F$=null;function t5($){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 O3($){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 A$($,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 O3(U);X.push({path:Q,content:new Uint8Array(U),sha1:_})}return X}function e5($){let Z={};for(let Y of $)Z[`/${Y.path}`]=Y.sha1;return Z}function $7($,Z){let Y=new Set(Z.map((X)=>X.startsWith("/")?X.slice(1):X));return $.filter((X)=>Y.has(X.path))}function f4($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;if($<1073741824)return`${($/1048576).toFixed(1)} MB`;return`${($/1073741824).toFixed(1)} GB`}function Z4($){return $.reduce((Z,Y)=>Z+Y.content.byteLength,0)}import Y4 from"fs";import m1 from"path";function L3($){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(`
11241
+ `}function u1($,Z,Y={}){let X=$q(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 r5($){let Z=$.toLowerCase();return Z.endsWith(".css")||Z.endsWith(".scss")||Z.endsWith(".sass")||Z.endsWith(".less")}function a5($){let Z=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((X)=>Z.endsWith(X))}function s5($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Y)=>Y.test($))}function o5($){if(!F$)F$=new GJ($);return F$}function V$(){if(F$)F$.stop(),F$=null}var F$=null;function t5($){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 O3($){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 A$($,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 O3(U);X.push({path:Q,content:new Uint8Array(U),sha1:_})}return X}function e5($){let Z={};for(let Y of $)Z[`/${Y.path}`]=Y.sha1;return Z}function $7($,Z){let Y=new Set(Z.map((X)=>X.startsWith("/")?X.slice(1):X));return $.filter((X)=>Y.has(X.path))}function f6($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;if($<1073741824)return`${($/1048576).toFixed(1)} MB`;return`${($/1073741824).toFixed(1)} GB`}function Z6($){return $.reduce((Z,Y)=>Z+Y.content.byteLength,0)}import Y6 from"fs";import m1 from"path";function L3($){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(`
11242
11242
  `)+`
11243
- `}function d0($){return $.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function w$($){let Z={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},Y=m1.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=m1.join($,"stx.config.ts"),J=m1.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 _=m1.join($,U);if(Y4.existsSync(_)&&Y4.statSync(_).isDirectory()){Z.outputDir=U;break}}let G=["functions","netlify/functions","api"];for(let U of G){let _=m1.join($,U);if(Y4.existsSync(_)&&Y4.statSync(_).isDirectory()){Z.functionsDir=U;break}}let K=m1.join($,"netlify","edge-functions");if(Y4.existsSync(K))Z.edgeFunctionsDir="netlify/edge-functions";let W=m1.join($,Z.outputDir||"dist");if(Y4.existsSync(W)){let U=Y4.existsSync(m1.join(W,"index.html")),_=Y4.readdirSync(W).filter((B)=>B.endsWith(".html"));Z.isSPA=U&&_.length===1}return Z}function N$($={}){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 Z7($,Z){let Y=await w$($),X=Z||N$(Y),J=L3(X),Q=m1.join($,"netlify.toml");return await Bun.write(Q,J),Q}function Y7($){return Y4.existsSync(m1.join($,"netlify.toml"))}var KJ=()=>{};var Xq={};e(Xq,{writeNetlifyConfig:()=>Z7,initNetlify:()=>Yq,hasNetlifyConfig:()=>Y7,getTotalSize:()=>Z4,generateNetlifyToml:()=>L3,formatSize:()=>f4,filterRequiredFiles:()=>$7,detectProjectConfig:()=>w$,deploy:()=>Zq,createNetlifyClient:()=>t5,createFileManifest:()=>e5,createDefaultNetlifyConfig:()=>N$,collectDeployFiles:()=>A$,calculateSha1:()=>O3,DeployError:()=>X4});import WJ from"fs";import UJ from"path";async function Zq($={}){let Z=Date.now(),Y=[],X=$.cwd||process.cwd(),J=(L)=>{Y.push(L)},Q=(L)=>{if($.onProgress)$.onProgress(L)},G=UJ.resolve(X,$.directory||"dist"),K=$.token||process.env.NETLIFY_AUTH_TOKEN,W=$.siteId||process.env.NETLIFY_SITE_ID;if(!K)throw new X4(`No Netlify auth token found.
11243
+ `}function d0($){return $.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function w$($){let Z={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},Y=m1.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=m1.join($,"stx.config.ts"),J=m1.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 _=m1.join($,U);if(Y6.existsSync(_)&&Y6.statSync(_).isDirectory()){Z.outputDir=U;break}}let G=["functions","netlify/functions","api"];for(let U of G){let _=m1.join($,U);if(Y6.existsSync(_)&&Y6.statSync(_).isDirectory()){Z.functionsDir=U;break}}let K=m1.join($,"netlify","edge-functions");if(Y6.existsSync(K))Z.edgeFunctionsDir="netlify/edge-functions";let W=m1.join($,Z.outputDir||"dist");if(Y6.existsSync(W)){let U=Y6.existsSync(m1.join(W,"index.html")),_=Y6.readdirSync(W).filter((B)=>B.endsWith(".html"));Z.isSPA=U&&_.length===1}return Z}function N$($={}){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 Z7($,Z){let Y=await w$($),X=Z||N$(Y),J=L3(X),Q=m1.join($,"netlify.toml");return await Bun.write(Q,J),Q}function Y7($){return Y6.existsSync(m1.join($,"netlify.toml"))}var KJ=()=>{};var Xq={};e(Xq,{writeNetlifyConfig:()=>Z7,initNetlify:()=>Yq,hasNetlifyConfig:()=>Y7,getTotalSize:()=>Z6,generateNetlifyToml:()=>L3,formatSize:()=>f6,filterRequiredFiles:()=>$7,detectProjectConfig:()=>w$,deploy:()=>Zq,createNetlifyClient:()=>t5,createFileManifest:()=>e5,createDefaultNetlifyConfig:()=>N$,collectDeployFiles:()=>A$,calculateSha1:()=>O3,DeployError:()=>X6});import WJ from"fs";import UJ from"path";async function Zq($={}){let Z=Date.now(),Y=[],X=$.cwd||process.cwd(),J=(L)=>{Y.push(L)},Q=(L)=>{if($.onProgress)$.onProgress(L)},G=UJ.resolve(X,$.directory||"dist"),K=$.token||process.env.NETLIFY_AUTH_TOKEN,W=$.siteId||process.env.NETLIFY_SITE_ID;if(!K)throw new X6(`No Netlify auth token found.
11244
11244
 
11245
11245
  To deploy to Netlify:
11246
11246
  1. Create account at https://app.netlify.com
11247
11247
  2. Get token at https://app.netlify.com/user/applications#personal-access-tokens
11248
11248
  3. Set NETLIFY_AUTH_TOKEN environment variable
11249
11249
 
11250
- export NETLIFY_AUTH_TOKEN=your_token_here`,"NO_TOKEN");if(!W)throw new X4(`No Netlify site ID found.
11250
+ export NETLIFY_AUTH_TOKEN=your_token_here`,"NO_TOKEN");if(!W)throw new X6(`No Netlify site ID found.
11251
11251
 
11252
11252
  Either:
11253
11253
  1. Set NETLIFY_SITE_ID environment variable
11254
11254
  2. Pass --site-id option
11255
11255
  3. Run \`stx deploy --init\` to set up
11256
11256
 
11257
- Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,"NO_SITE_ID");if(!WJ.existsSync(G))throw new X4(`Build directory not found: ${G}
11257
+ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,"NO_SITE_ID");if(!WJ.existsSync(G))throw new X6(`Build directory not found: ${G}
11258
11258
 
11259
- Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(WJ.readdirSync(G).length>0))throw new X4(`Build directory is empty: ${G}
11259
+ Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(WJ.readdirSync(G).length>0))throw new X6(`Build directory is empty: ${G}
11260
11260
 
11261
- Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if($.dryRun){Q({stage:"collect",message:"Collecting files..."});let L=await A$(G),V=Z4(L);return J(`Would deploy ${L.length} files (${f4(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:L.length,totalSize:V}}let _=t5({token:K});Q({stage:"collect",message:"Verifying site..."});try{let L=await _.getSite(W);J(`Deploying to: ${L.name} (${L.url})`)}catch(L){if(L.status===404)throw new X4(`Site not found: ${W}
11261
+ Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if($.dryRun){Q({stage:"collect",message:"Collecting files..."});let L=await A$(G),V=Z6(L);return J(`Would deploy ${L.length} files (${f6(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:L.length,totalSize:V}}let _=t5({token:K});Q({stage:"collect",message:"Verifying site..."});try{let L=await _.getSite(W);J(`Deploying to: ${L.name} (${L.url})`)}catch(L){if(L.status===404)throw new X6(`Site not found: ${W}
11262
11262
 
11263
- Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw L}Q({stage:"collect",message:"Collecting files..."});let B=await A$(G),z=Z4(B);if(J(`Found ${B.length} files (${f4(z)})`),B.length===0)throw new X4(`No files found in ${G}`,"NO_FILES");let q=e5(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=$7(B,j.required||[]);if(J(`Uploading ${H.length} files...`),H.length>0){let L=0,V=Z4(H);for(let w of H){await _.uploadFile(j.id,w.path,w.content),L++;let A=Math.round(L/H.length*100);Q({stage:"upload",message:`Uploading: ${w.path}`,percent:A,details:{uploaded:L,total:H.length}})}J(`Uploaded ${f4(V)}`)}else J("All files already on CDN (no upload needed)");Q({stage:"process",message:"Processing deploy..."});let O=await _.waitForDeploy(j.id,{onProgress:(L)=>{Q({stage:"process",message:`Status: ${L.state}`,details:L})}}),F=Date.now()-Z;if(Q({stage:"done",message:"Deploy complete!"}),J(`Deploy complete in ${(F/1000).toFixed(1)}s`),J(`URL: ${O.deploy_ssl_url}`),$.production)J(`Site: ${O.ssl_url}`);if($.open){let L=$.production?O.ssl_url:O.deploy_ssl_url;IE(L)}return{success:!0,url:O.deploy_ssl_url,siteUrl:$.production?O.ssl_url:void 0,deployId:O.id,logs:Y,duration:F,filesUploaded:H.length,totalSize:Z4(H)}}async function Yq($={}){let Z=$.directory||process.cwd(),Y;if(Y7(Z))Y=UJ.join(Z,"netlify.toml");else{let X=await w$(Z);Y=await Z7(Z,N$(X))}if($.siteId){let X=UJ.join(Z,".env.local"),J="";if(await Bun.file(X).exists()){if(J=await Bun.file(X).text(),J=J.split(`
11263
+ Check your site ID or create a new site at https://app.netlify.com`,"SITE_NOT_FOUND");throw L}Q({stage:"collect",message:"Collecting files..."});let B=await A$(G),z=Z6(B);if(J(`Found ${B.length} files (${f6(z)})`),B.length===0)throw new X6(`No files found in ${G}`,"NO_FILES");let q=e5(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=$7(B,j.required||[]);if(J(`Uploading ${H.length} files...`),H.length>0){let L=0,V=Z6(H);for(let w of H){await _.uploadFile(j.id,w.path,w.content),L++;let A=Math.round(L/H.length*100);Q({stage:"upload",message:`Uploading: ${w.path}`,percent:A,details:{uploaded:L,total:H.length}})}J(`Uploaded ${f6(V)}`)}else J("All files already on CDN (no upload needed)");Q({stage:"process",message:"Processing deploy..."});let O=await _.waitForDeploy(j.id,{onProgress:(L)=>{Q({stage:"process",message:`Status: ${L.state}`,details:L})}}),F=Date.now()-Z;if(Q({stage:"done",message:"Deploy complete!"}),J(`Deploy complete in ${(F/1000).toFixed(1)}s`),J(`URL: ${O.deploy_ssl_url}`),$.production)J(`Site: ${O.ssl_url}`);if($.open){let L=$.production?O.ssl_url:O.deploy_ssl_url;IE(L)}return{success:!0,url:O.deploy_ssl_url,siteUrl:$.production?O.ssl_url:void 0,deployId:O.id,logs:Y,duration:F,filesUploaded:H.length,totalSize:Z6(H)}}async function Yq($={}){let Z=$.directory||process.cwd(),Y;if(Y7(Z))Y=UJ.join(Z,"netlify.toml");else{let X=await w$(Z);Y=await Z7(Z,N$(X))}if($.siteId){let X=UJ.join(Z,".env.local"),J="";if(await Bun.file(X).exists()){if(J=await Bun.file(X).text(),J=J.split(`
11264
11264
  `).filter((Q)=>!Q.startsWith("NETLIFY_SITE_ID=")).join(`
11265
11265
  `),J&&!J.endsWith(`
11266
11266
  `))J+=`
11267
11267
  `}J+=`NETLIFY_SITE_ID=${$.siteId}
11268
- `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function IE($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var X4;var F3=D(()=>{KJ();KJ();X4=class X4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});import DE from"fs";import V3 from"path";import kE from"crypto";async function A3(){if(Jq)return _J;Jq=!0;try{let $=await import("sharp");return _J=$.default||$,_J}catch{return null}}async function c1(){return await A3()!==null}async function l1($,Z={}){let{widths:Y=L1,formats:X=F1,quality:J=V1,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 T$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((w)=>Buffer.from(w))}else _="buffer-input",U=$;let B=kE.createHash("sha256").update(U).digest("hex").slice(0,12),z=await X7(U),{width:q,height:j}=z,H=q/j;await DE.promises.mkdir(K,{recursive:!0});let O=[],F=V3.basename(_,V3.extname(_)),L=Y.filter((w)=>w<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((w,A)=>w-A);for(let w of L){let A=Math.round(w/H);for(let N of X){let M=`${F}-${w}w-${B}.${N}`,E=V3.join(K,M),I=`${W}/${M}`,T=await CE(U,{width:w,height:A,format:N,quality:J,fit:Q});await Bun.write(E,T),O.push({path:E,url:I,width:w,height:A,format:N,size:T.length})}}let V;if(G!=="none")V=await PE(U,G);return{src:_,variants:O,placeholder:V,width:q,height:j,aspectRatio:H,hash:B}}async function X7($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await A3();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 bE(Z)}function bE($){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 T$("Unable to parse image dimensions","PARSE_ERROR")}async function CE($,Z){let Y=await A3();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 PE($,Z){let Y=await A3();if(Z==="blur"&&Y){let J=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),Q=await X7($);return`data:${Qq[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 J6($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function R$($){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 M$($){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 E$($){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 J7($){let Z=V3.extname($).toLowerCase();return SE.includes(Z)}function p1($){return Qq[$]||"application/octet-stream"}function w3($){return $.reduce((Z,Y)=>Z+Y.size,0)}function N3($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var L1,F1,V1=80,SE,Qq,_J=null,Jq=!1,T$;var Q7=D(()=>{L1=[320,640,768,1024,1280,1536,1920],F1=["webp","jpeg"],SE=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],Qq={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};T$=class T$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});function BJ($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=V1,placeholder:_="none",formats:B=F1,widths:z=L1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,F=$.class,L=$.style,{processedImage:V,variants:w,optimize:A=!0,isDev:N=!1}=Z;if(w&&w.length>0)return yE($,w,V);if(N||!A)return xE($);return vE($)}function yE($,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,O=$.style,F=E$(Z),L=M$(Z),V=typeof K==="object"?R$(K):K,w=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(w)A.push(`aspect-ratio: ${w}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(O)A.push(O);let N=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 i of S){let n=F.get(i);if(n&&n.length>0){let W0=J6(n),z0=p1(i);k.push(` <source type="${z0}" srcset="${W0}" sizes="${V}" />`)}}let b="",y="",v;if(j!=="none"&&Y?.placeholder){let i=`img-${Math.random().toString(36).slice(2,8)}`;if(b=`<div class="stx-image-wrapper" id="${i}">`,y="</div>",j==="blur")v=`
11268
+ `,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function IE($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var X6;var F3=D(()=>{KJ();KJ();X6=class X6 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});import DE from"fs";import V3 from"path";import kE from"crypto";async function A3(){if(Jq)return _J;Jq=!0;try{let $=await import("sharp");return _J=$.default||$,_J}catch{return null}}async function c1(){return await A3()!==null}async function l1($,Z={}){let{widths:Y=L1,formats:X=F1,quality:J=V1,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 T$(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((w)=>Buffer.from(w))}else _="buffer-input",U=$;let B=kE.createHash("sha256").update(U).digest("hex").slice(0,12),z=await X7(U),{width:q,height:j}=z,H=q/j;await DE.promises.mkdir(K,{recursive:!0});let O=[],F=V3.basename(_,V3.extname(_)),L=Y.filter((w)=>w<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((w,A)=>w-A);for(let w of L){let A=Math.round(w/H);for(let N of X){let M=`${F}-${w}w-${B}.${N}`,E=V3.join(K,M),I=`${W}/${M}`,T=await CE(U,{width:w,height:A,format:N,quality:J,fit:Q});await Bun.write(E,T),O.push({path:E,url:I,width:w,height:A,format:N,size:T.length})}}let V;if(G!=="none")V=await PE(U,G);return{src:_,variants:O,placeholder:V,width:q,height:j,aspectRatio:H,hash:B}}async function X7($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await A3();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 bE(Z)}function bE($){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 T$("Unable to parse image dimensions","PARSE_ERROR")}async function CE($,Z){let Y=await A3();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 PE($,Z){let Y=await A3();if(Z==="blur"&&Y){let J=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),Q=await X7($);return`data:${Qq[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 J4($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function R$($){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 M$($){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 E$($){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 J7($){let Z=V3.extname($).toLowerCase();return SE.includes(Z)}function p1($){return Qq[$]||"application/octet-stream"}function w3($){return $.reduce((Z,Y)=>Z+Y.size,0)}function N3($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var L1,F1,V1=80,SE,Qq,_J=null,Jq=!1,T$;var Q7=D(()=>{L1=[320,640,768,1024,1280,1536,1920],F1=["webp","jpeg"],SE=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],Qq={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};T$=class T$ extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});function BJ($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=V1,placeholder:_="none",formats:B=F1,widths:z=L1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,F=$.class,L=$.style,{processedImage:V,variants:w,optimize:A=!0,isDev:N=!1}=Z;if(w&&w.length>0)return yE($,w,V);if(N||!A)return xE($);return vE($)}function yE($,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,O=$.style,F=E$(Z),L=M$(Z),V=typeof K==="object"?R$(K):K,w=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,A=[];if(w)A.push(`aspect-ratio: ${w}`);if(z)A.push(`object-fit: ${z}`);if(q)A.push(`object-position: ${q}`);if(O)A.push(O);let N=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 i of S){let n=F.get(i);if(n&&n.length>0){let W0=J4(n),z0=p1(i);k.push(` <source type="${z0}" srcset="${W0}" sizes="${V}" />`)}}let b="",y="",v;if(j!=="none"&&Y?.placeholder){let i=`img-${Math.random().toString(36).slice(2,8)}`;if(b=`<div class="stx-image-wrapper" id="${i}">`,y="</div>",j==="blur")v=`
11269
11269
  #${i} {
11270
11270
  position: relative;
11271
11271
  background-image: url('${Y.placeholder}');
@@ -11296,7 +11296,7 @@ ${k.join(`
11296
11296
  data-quality="${W}"
11297
11297
  data-formats="${U.join(",")}"
11298
11298
  data-widths="${_.join(",")}"
11299
- `.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${qJ(Y)}"${w}${A}${V}${L}${N}${M}${E} ${T} />`}}function R3($){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 zJ($,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],_=R3(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 qJ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var Gq=D(()=>{Q7()});function E3(){M3.clear()}async function gE($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(M3.has(Y))return M3.get(Y);try{let X=await l1($,Z);return M3.set(Y,X),X}catch{return null}}function T3(){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}=fE($,Z,Y);if(!X)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:L1),formats:Q.formats||F1,quality:Q.quality||V1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await c1())return Kq(X,J||"",Q);let W=await gE(X,G);if(!W)return Kq(X,J||"",Q);return dE(W,J||"",Q)}})}function fE($,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=hE(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 hE($){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 Kq($,Z,Y){let X=[`src="${J4($)}"`];if(Z)X.push(`alt="${J4(Z)}"`);if(Y.width)X.push(`width="${Y.width}"`);if(Y.height)X.push(`height="${Y.height}"`);if(Y.class)X.push(`class="${J4(Y.class)}"`);if(Y.style)X.push(`style="${J4(Y.style)}"`);if(Y.lazy!==!1)X.push('loading="lazy"');return X.push('decoding="async"'),`<img ${X.join(" ")} />`}function dE($,Z,Y){let{variants:X,placeholder:J,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let O of X){let F=W.get(O.format)||[];F.push(O),W.set(O.format,F)}let U=["avif","webp","jpeg","png"],_=[];for(let O of U){let F=W.get(O);if(F&&F.length>0){let L=J6(F),V=p1(O),w=Y.sizes||"100vw";_.push(` <source type="${V}" srcset="${J4(L)}" sizes="${J4(w)}" />`)}}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="${J4(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="${J4(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>
11299
+ `.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${qJ(Y)}"${w}${A}${V}${L}${N}${M}${E} ${T} />`}}function R3($){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 zJ($,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],_=R3(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 qJ($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}var Gq=D(()=>{Q7()});function E3(){M3.clear()}async function gE($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(M3.has(Y))return M3.get(Y);try{let X=await l1($,Z);return M3.set(Y,X),X}catch{return null}}function T3(){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}=fE($,Z,Y);if(!X)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:L1),formats:Q.formats||F1,quality:Q.quality||V1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await c1())return Kq(X,J||"",Q);let W=await gE(X,G);if(!W)return Kq(X,J||"",Q);return dE(W,J||"",Q)}})}function fE($,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=hE(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 hE($){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 Kq($,Z,Y){let X=[`src="${J6($)}"`];if(Z)X.push(`alt="${J6(Z)}"`);if(Y.width)X.push(`width="${Y.width}"`);if(Y.height)X.push(`height="${Y.height}"`);if(Y.class)X.push(`class="${J6(Y.class)}"`);if(Y.style)X.push(`style="${J6(Y.style)}"`);if(Y.lazy!==!1)X.push('loading="lazy"');return X.push('decoding="async"'),`<img ${X.join(" ")} />`}function dE($,Z,Y){let{variants:X,placeholder:J,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let O of X){let F=W.get(O.format)||[];F.push(O),W.set(O.format,F)}let U=["avif","webp","jpeg","png"],_=[];for(let O of U){let F=W.get(O);if(F&&F.length>0){let L=J4(F),V=p1(O),w=Y.sizes||"100vw";_.push(` <source type="${V}" srcset="${J6(L)}" sizes="${J6(w)}" />`)}}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="${J6(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="${J6(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>
11300
11300
  `;if(H+=_.join(`
11301
11301
  `)+`
11302
11302
  `,H+=` <img ${q.join(" ")} />
@@ -11304,8 +11304,8 @@ ${k.join(`
11304
11304
  ${H}
11305
11305
  </div>`}else if(Y.placeholder==="color"){let F=J.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");H=`<div id="${O}" class="stx-image-placeholder" style="background-color: ${F};">
11306
11306
  ${H}
11307
- </div>`}}if(Y.priority&&z){let O=p1(z.format);H=`<link rel="preload" as="image" href="${J4(z.url)}" type="${O}" />
11308
- `+H}return H}function J4($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var M3,jJ;var Wq=D(()=>{y5();Q7();M3=new Map;jJ=T3()});import I$ from"fs";import I3 from"path";function HJ($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:X="/images",formats:J=F1,widths:Q=L1,quality:G=V1,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 c1()){console.warn("[stx-images] sharp not available, image optimization disabled");return}if(U)await I$.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 O=uE(j);for(let F of O)q.imageReferences.add(F)}if(j.includes("<Image")||j.includes("@image"))return await cE(j,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X,processedImages:q.processedImages});return j},async buildEnd(j){if(!await c1())return;await I$.promises.mkdir(Y,{recursive:!0});let O=[];for(let V of Z){if(!I$.existsSync(V))continue;let w=await Uq(V);O.push(...w)}let F=B?O.filter((V)=>mE(V,q.imageReferences)):O;if(q.stats.totalImages=F.length,z)console.log(`[stx-images] Processing ${F.length} images...`);let L=_q(F,W);for(let V of L)await Promise.all(V.map(async(w)=>{try{let A=await l1(w,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X});q.processedImages.set(w,A),q.stats.optimizedImages++,q.stats.variants+=A.variants.length;let N=I$.statSync(w).size,M=w3(A.variants);if(q.stats.savedBytes+=Math.max(0,N-M/A.variants.length),z)console.log(` \u2713 ${I3.basename(w)} \u2192 ${A.variants.length} variants`)}catch(A){console.error(`[stx-images] Error processing ${w}:`,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: ~${N3(q.stats.savedBytes)}`)}}}function uE($){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 mE($,Z){let Y=I3.basename($);for(let X of Z)if(X.endsWith(Y)||X.includes(Y))return!0;return!1}async function cE($,Z){return $}async function Uq($){let Z=[];async function Y(X){let J=await I$.promises.readdir(X,{withFileTypes:!0});for(let Q of J){let G=I3.join(X,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&J7(G))Z.push(G)}}return await Y($),Z}function _q($,Z){let Y=[];for(let X=0;X<$.length;X+=Z)Y.push($.slice(X,X+Z));return Y}async function D3($,Z,Y={}){if(!await c1())throw Error("sharp is required for image optimization");return l1($,{...Y,outputDir:Z})}async function OJ($,Z,Y={}){let{formats:X=F1,widths:J=L1,quality:Q=V1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await c1())throw Error("sharp is required for image optimization");await I$.promises.mkdir(Z,{recursive:!0});let _=await Uq($),B=[],z={totalImages:_.length,optimizedImages:0,savedBytes:0,variants:0},q=_q(_,K);for(let j of q){let H=await Promise.all(j.map(async(O)=>{try{let F=await l1(O,{formats:X,widths:J,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(z.optimizedImages++,z.variants+=F.variants.length,W)console.log(` \u2713 ${I3.basename(O)}`);return F}catch(F){return console.error(`Error processing ${O}:`,F),null}}));B.push(...H.filter((O)=>O!==null))}return{processed:B,stats:z}}function k3($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function LJ($,Z){let Y=k3($);await Bun.write(Z,JSON.stringify(Y,null,2))}var Bq=D(()=>{Q7()});var qq={};e(qq,{writeImageManifest:()=>LJ,renderImageComponent:()=>BJ,processImageComponents:()=>zJ,processImage:()=>l1,parseImageComponent:()=>R3,optimizeImage:()=>D3,optimizeDirectory:()=>OJ,isSharpAvailable:()=>c1,isImageFile:()=>J7,imageDirective:()=>jJ,groupVariantsByFormat:()=>E$,getTotalSize:()=>w3,getMimeType:()=>p1,getImageMetadata:()=>X7,getFallbackVariant:()=>M$,generateSrcSet:()=>J6,generateSizes:()=>R$,generateImageManifest:()=>k3,formatSize:()=>N3,defaultImageConfig:()=>zq,createImagePlugin:()=>HJ,createImageDirective:()=>T3,clearImageCache:()=>E3,ImageProcessingError:()=>T$,DEFAULT_WIDTHS:()=>L1,DEFAULT_QUALITY:()=>V1,DEFAULT_FORMATS:()=>F1});var zq;var S3=D(()=>{Q7();Gq();Wq();Bq();zq={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 lE($){C0=$}function pE(){return C0}function iE(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:Hq()}}function Hq(){return{refs:new Map,effects:new Set,cleanups:[]}}function nE($){let Z=new Set,Y=new Set,X=$,J=Symbol("ref"),Q={get value(){if(Z1)Y.add(Z1);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(C0)C0.scope.refs.set(J,Q);return Q}function Oq($){let Z=jq.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(Z1)J(K,Z1);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let _=Object.getPrototypeOf(U);if(_===Object.prototype||_===null)return Oq(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 jq.set($,Q),Q}function rE($){let Z,Y=!0,X=new Set,J=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=Z1;if(Z1=Q,Z=$(),Z1=U,Y=!1,!Object.is(Z,W)){for(let _ of X)_(Z,W);for(let _ of J)_()}}},K=Z1;return Z1=Q,Z=$(),Y=!1,Z1=K,{get value(){if(Z1)J.add(Z1);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return X.add(W),()=>{X.delete(W)}}}}function aE($,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(C0)C0.scope.cleanups.push(()=>K?.());return()=>K?.()}function sE($,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 oE($){let Z,Y=!1,X=()=>{if(Y)return;if(Z)Z();let J=Z1;Z1=X,Z=$(),Z1=J};if(X(),C0)C0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function tE($){if(C0)C0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function eE($){if(C0)C0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function $T($){if(C0)C0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function ZT($){if(C0)C0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function YT($){if(C0)C0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function XT($){if(C0)C0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function Q6($,Z){let Y=$.hooks[Z];for(let X of Y)await X()}async function JT($){await Q6($,"beforeMount"),$.isMounted=!0,await Q6($,"mounted")}async function QT($){if(!$.isMounted||$.isUnmounted)return;await Q6($,"beforeUpdate"),await Q6($,"updated")}async function GT($){if($.isUnmounted)return;await Q6($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await Q6($,"unmounted")}function KT(){return`
11307
+ </div>`}}if(Y.priority&&z){let O=p1(z.format);H=`<link rel="preload" as="image" href="${J6(z.url)}" type="${O}" />
11308
+ `+H}return H}function J6($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}var M3,jJ;var Wq=D(()=>{y5();Q7();M3=new Map;jJ=T3()});import I$ from"fs";import I3 from"path";function HJ($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:X="/images",formats:J=F1,widths:Q=L1,quality:G=V1,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 c1()){console.warn("[stx-images] sharp not available, image optimization disabled");return}if(U)await I$.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 O=uE(j);for(let F of O)q.imageReferences.add(F)}if(j.includes("<Image")||j.includes("@image"))return await cE(j,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X,processedImages:q.processedImages});return j},async buildEnd(j){if(!await c1())return;await I$.promises.mkdir(Y,{recursive:!0});let O=[];for(let V of Z){if(!I$.existsSync(V))continue;let w=await Uq(V);O.push(...w)}let F=B?O.filter((V)=>mE(V,q.imageReferences)):O;if(q.stats.totalImages=F.length,z)console.log(`[stx-images] Processing ${F.length} images...`);let L=_q(F,W);for(let V of L)await Promise.all(V.map(async(w)=>{try{let A=await l1(w,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X});q.processedImages.set(w,A),q.stats.optimizedImages++,q.stats.variants+=A.variants.length;let N=I$.statSync(w).size,M=w3(A.variants);if(q.stats.savedBytes+=Math.max(0,N-M/A.variants.length),z)console.log(` \u2713 ${I3.basename(w)} \u2192 ${A.variants.length} variants`)}catch(A){console.error(`[stx-images] Error processing ${w}:`,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: ~${N3(q.stats.savedBytes)}`)}}}function uE($){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 mE($,Z){let Y=I3.basename($);for(let X of Z)if(X.endsWith(Y)||X.includes(Y))return!0;return!1}async function cE($,Z){return $}async function Uq($){let Z=[];async function Y(X){let J=await I$.promises.readdir(X,{withFileTypes:!0});for(let Q of J){let G=I3.join(X,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&J7(G))Z.push(G)}}return await Y($),Z}function _q($,Z){let Y=[];for(let X=0;X<$.length;X+=Z)Y.push($.slice(X,X+Z));return Y}async function D3($,Z,Y={}){if(!await c1())throw Error("sharp is required for image optimization");return l1($,{...Y,outputDir:Z})}async function OJ($,Z,Y={}){let{formats:X=F1,widths:J=L1,quality:Q=V1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await c1())throw Error("sharp is required for image optimization");await I$.promises.mkdir(Z,{recursive:!0});let _=await Uq($),B=[],z={totalImages:_.length,optimizedImages:0,savedBytes:0,variants:0},q=_q(_,K);for(let j of q){let H=await Promise.all(j.map(async(O)=>{try{let F=await l1(O,{formats:X,widths:J,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(z.optimizedImages++,z.variants+=F.variants.length,W)console.log(` \u2713 ${I3.basename(O)}`);return F}catch(F){return console.error(`Error processing ${O}:`,F),null}}));B.push(...H.filter((O)=>O!==null))}return{processed:B,stats:z}}function k3($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function LJ($,Z){let Y=k3($);await Bun.write(Z,JSON.stringify(Y,null,2))}var Bq=D(()=>{Q7()});var qq={};e(qq,{writeImageManifest:()=>LJ,renderImageComponent:()=>BJ,processImageComponents:()=>zJ,processImage:()=>l1,parseImageComponent:()=>R3,optimizeImage:()=>D3,optimizeDirectory:()=>OJ,isSharpAvailable:()=>c1,isImageFile:()=>J7,imageDirective:()=>jJ,groupVariantsByFormat:()=>E$,getTotalSize:()=>w3,getMimeType:()=>p1,getImageMetadata:()=>X7,getFallbackVariant:()=>M$,generateSrcSet:()=>J4,generateSizes:()=>R$,generateImageManifest:()=>k3,formatSize:()=>N3,defaultImageConfig:()=>zq,createImagePlugin:()=>HJ,createImageDirective:()=>T3,clearImageCache:()=>E3,ImageProcessingError:()=>T$,DEFAULT_WIDTHS:()=>L1,DEFAULT_QUALITY:()=>V1,DEFAULT_FORMATS:()=>F1});var zq;var S3=D(()=>{Q7();Gq();Wq();Bq();zq={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 lE($){C0=$}function pE(){return C0}function iE(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:Hq()}}function Hq(){return{refs:new Map,effects:new Set,cleanups:[]}}function nE($){let Z=new Set,Y=new Set,X=$,J=Symbol("ref"),Q={get value(){if(Z1)Y.add(Z1);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(C0)C0.scope.refs.set(J,Q);return Q}function Oq($){let Z=jq.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(Z1)J(K,Z1);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let _=Object.getPrototypeOf(U);if(_===Object.prototype||_===null)return Oq(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 jq.set($,Q),Q}function rE($){let Z,Y=!0,X=new Set,J=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=Z1;if(Z1=Q,Z=$(),Z1=U,Y=!1,!Object.is(Z,W)){for(let _ of X)_(Z,W);for(let _ of J)_()}}},K=Z1;return Z1=Q,Z=$(),Y=!1,Z1=K,{get value(){if(Z1)J.add(Z1);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return X.add(W),()=>{X.delete(W)}}}}function aE($,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(C0)C0.scope.cleanups.push(()=>K?.());return()=>K?.()}function sE($,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 oE($){let Z,Y=!1,X=()=>{if(Y)return;if(Z)Z();let J=Z1;Z1=X,Z=$(),Z1=J};if(X(),C0)C0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function tE($){if(C0)C0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function eE($){if(C0)C0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function $T($){if(C0)C0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function ZT($){if(C0)C0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function YT($){if(C0)C0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function XT($){if(C0)C0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function Q4($,Z){let Y=$.hooks[Z];for(let X of Y)await X()}async function JT($){await Q4($,"beforeMount"),$.isMounted=!0,await Q4($,"mounted")}async function QT($){if(!$.isMounted||$.isUnmounted)return;await Q4($,"beforeUpdate"),await Q4($,"updated")}async function GT($){if($.isUnmounted)return;await Q4($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await Q4($,"unmounted")}function KT(){return`
11309
11309
  <script data-stx-client-runtime>
11310
11310
  (function() {
11311
11311
  'use strict';
@@ -11485,7 +11485,7 @@ ${H}
11485
11485
  </script>`}var C0=null,Z1=null,jq;var Lq=D(()=>{jq=new WeakMap});import{abortNavigation as WT,clearMiddleware as G7,createClientCookieManager as UT,createMiddlewareContext as K7,createRouteLocation as W7,createServerCookieManager as _T,createStorageManager as BT,defineMiddleware as zT,getMiddleware as qT,getMiddlewareNames as U7,hasMiddleware as jT,loadMiddlewareFromDirectory as _7,navigateTo as HT,registerMiddleware as OT,runMiddleware as B7}from"stx-router";var b3=()=>{};function D$($,Z){if(typeof window>"u")return Z;return window[$]??Z}function C3($,Z){if(typeof window>"u")return;window[$]=Z}function Fq($){let Y=D$("__STX_STORES__",{})[$];if(!Y)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Y}function LT($){return Fq($)}function FT($,Z=5000){return new Promise((Y,X)=>{let J=Date.now(),Q=()=>{let G=Fq($);if(G)Y(G);else if(Date.now()-J>Z)X(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(Q)};Q()})}function Vq(){return D$("__STX_ROUTE_PARAMS__",{})}function Aq($){return Vq()[$]}function VT($){let Z=Aq($);if(Z===void 0)throw Error(`Route parameter "${$}" not found`);return Z}function wq(){return D$("__STX_MIDDLEWARE_STATE__",{})}function AT($){return wq()[$]}function wT(){if(typeof window>"u")return;if(!D$("__STX_STORES__",null))C3("__STX_STORES__",{})}function NT($,Z){let Y=D$("__STX_STORES__",{});Y[$]=Z,C3("__STX_STORES__",Y)}function RT(){return D$("__STX_STORE_STATE__",null)}function MT($){C3("__STX_ROUTE_PARAMS__",$)}function ET($){C3("__STX_MIDDLEWARE_STATE__",$)}function Nq(){return typeof window>"u"}function Rq(){return typeof window<"u"}function TT($){if(Rq())$()}function IT($){if(Nq())$()}async function Eq($){try{let Z=await Bun.file($).text(),Y=DT(Z),X=kT(Z,$),J=ST(Z,Y),Q=bT(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 DT($){let Z=$.split(`
11486
11486
  `),Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),J=(Y?Y[1]:"").split(`
11487
11487
  `).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 O of Z)if(/@(?:if|unless|foreach|for|while|section)\b/.test(O)&&!/@end/.test(O)&&!/@else/.test(O))q++,z=Math.max(z,q);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(O))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 kT($,Z){let Y=[],X=Mq($,"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=Mq($,"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(`
11488
- `).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 ST($,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 bT($,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 Mq($,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 FJ($=["**/*.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 Eq(Q);Y.push(G)}catch(G){console.warn(`Failed to analyze ${Q}:`,G)}let J=CT(Y);return{results:Y,summary:J}}function CT($){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 Tq($,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(PT.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 VJ($){let Z=[],Y=[],X=[],J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let G=Tq(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 PT;var AJ=D(()=>{PT=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/});import Iq from"fs";import wJ from"path";function yT(){if(z7!==null)return z7;try{let{getRouterScript:$}=s("stx-router");z7=`<script>${$()}</script>`}catch{z7=""}return z7}function NJ($,Z){if(Z===!1)return null;if(Z&&typeof Z==="string"){let X=wJ.resolve($,Z);if(Iq.existsSync(X))return X;return null}let Y=wJ.join($,"app.stx");if(Iq.existsSync(Y))return Y;return null}async function P3($,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=VJ(Y),G=[...Q.client.map((w)=>w.fullTag),...Q.signals.map((w)=>w.fullTag)],K=[],W=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,U;while((U=W.exec(Y))!==null)K.push(U[0]);let _=X;for(let w of Q.server)_=_.replace(w.fullTag,"");for(let w of Q.client)_=_.replace(w.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(() => (h4(),K6)),O=await H(),F={__filename:$,__dirname:wJ.dirname($)};for(let w of G){let A=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!w.includes("client")&&!w.includes('type="module"'))await q(A[1],F,$)}let L=await z(_,F,$,{...j,...O,...Z},new Set),V=L.indexOf(B);if(V===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:L.substring(0,V),afterSlot:L.substring(V+B.length),filePath:$,shellScripts:G,shellStyles:K}}catch(Y){return console.error(`[stx] Error processing shell ${$}:`,Y),null}}function q7($,Z,Y){let X=Y||"stx App",J=yT(),Q="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
11488
+ `).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 ST($,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 bT($,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 Mq($,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 FJ($=["**/*.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 Eq(Q);Y.push(G)}catch(G){console.warn(`Failed to analyze ${Q}:`,G)}let J=CT(Y);return{results:Y,summary:J}}function CT($){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 Tq($,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(PT.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 VJ($){let Z=[],Y=[],X=[],J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let G=Tq(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 PT;var AJ=D(()=>{PT=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/});import Iq from"fs";import wJ from"path";function yT(){if(z7!==null)return z7;try{let{getRouterScript:$}=s("stx-router");z7=`<script>${$()}</script>`}catch{z7=""}return z7}function NJ($,Z){if(Z===!1)return null;if(Z&&typeof Z==="string"){let X=wJ.resolve($,Z);if(Iq.existsSync(X))return X;return null}let Y=wJ.join($,"app.stx");if(Iq.existsSync(Y))return Y;return null}async function P3($,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=VJ(Y),G=[...Q.client.map((w)=>w.fullTag),...Q.signals.map((w)=>w.fullTag)],K=[],W=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,U;while((U=W.exec(Y))!==null)K.push(U[0]);let _=X;for(let w of Q.server)_=_.replace(w.fullTag,"");for(let w of Q.client)_=_.replace(w.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(() => (h6(),K4)),O=await H(),F={__filename:$,__dirname:wJ.dirname($)};for(let w of G){let A=w.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(A&&!w.includes("client")&&!w.includes('type="module"'))await q(A[1],F,$)}let L=await z(_,F,$,{...j,...O,...Z},new Set),V=L.indexOf(B);if(V===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:L.substring(0,V),afterSlot:L.substring(V+B.length),filePath:$,shellScripts:G,shellStyles:K}}catch(Y){return console.error(`[stx] Error processing shell ${$}:`,Y),null}}function q7($,Z,Y){let X=Y||"stx App",J=yT(),Q="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
11489
11489
  <html lang="en">
11490
11490
  <head>
11491
11491
  <meta charset="UTF-8">
@@ -11503,13 +11503,13 @@ ${$.shellScripts.filter((K)=>!K.includes("server")).join(`
11503
11503
  <script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>
11504
11504
  ${J}
11505
11505
  </body>
11506
- </html>`}function G6($){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(`
11506
+ </html>`}function G4($){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(`
11507
11507
  `)+`
11508
11508
  `+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(`
11509
- `));return G=G.replace(/<body\b[^>]*>/i,""),G=G.replace(/<\/body\s*>/i,""),G.trim()}function RJ($){return $.headers.get("X-STX-Router")==="true"}function j7($,Z="main"){let Y=$.trim(),X=[],J=Y.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(J){let L=J[1],V=/<style\b[^>]*>[\s\S]*?<\/style>/gi,w;while((w=V.exec(L))!==null)X.push(w[0])}let Q=Z.replace(/^[.#]/,"").toLowerCase(),G=new RegExp(`<${Q}\\b[^>]*>`,"i"),K=Y.match(G);if(!K||K.index===void 0)return G6($);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 L=U.exec(Y),V=_.exec(Y);if(!V)break;if(L&&L.index<V.index)B++,_.lastIndex=L.index+L[0].length;else if(B--,z=V.index,B>0)U.lastIndex=V.index+V[0].length}if(z===-1)return G6($);let q=Y.slice(W,z).trim(),j=[],H=Y.match(/<body\b[^>]*>/i),O=Y.lastIndexOf("</body>");if(H&&H.index!==void 0&&O!==-1){let V=[[H.index+H[0].length,K.index],[z+`</${Q}>`.length,O]],w=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[A,N]of V){if(A>=N)continue;let M=Y.slice(A,N),E;w.lastIndex=0;while((E=w.exec(M))!==null)j.push(E[0])}}let F=[];if(X.length>0)F.push(X.join(`
11509
+ `));return G=G.replace(/<body\b[^>]*>/i,""),G=G.replace(/<\/body\s*>/i,""),G.trim()}function RJ($){return $.headers.get("X-STX-Router")==="true"}function j7($,Z="main"){let Y=$.trim(),X=[],J=Y.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(J){let L=J[1],V=/<style\b[^>]*>[\s\S]*?<\/style>/gi,w;while((w=V.exec(L))!==null)X.push(w[0])}let Q=Z.replace(/^[.#]/,"").toLowerCase(),G=new RegExp(`<${Q}\\b[^>]*>`,"i"),K=Y.match(G);if(!K||K.index===void 0)return G4($);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 L=U.exec(Y),V=_.exec(Y);if(!V)break;if(L&&L.index<V.index)B++,_.lastIndex=L.index+L[0].length;else if(B--,z=V.index,B>0)U.lastIndex=V.index+V[0].length}if(z===-1)return G4($);let q=Y.slice(W,z).trim(),j=[],H=Y.match(/<body\b[^>]*>/i),O=Y.lastIndexOf("</body>");if(H&&H.index!==void 0&&O!==-1){let V=[[H.index+H[0].length,K.index],[z+`</${Q}>`.length,O]],w=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[A,N]of V){if(A>=N)continue;let M=Y.slice(A,N),E;w.lastIndex=0;while((E=w.exec(M))!==null)j.push(E[0])}}let F=[];if(X.length>0)F.push(X.join(`
11510
11510
  `));if(j.length>0)F.push(j.join(`
11511
11511
  `));return F.push(q),F.join(`
11512
- `)}var z7=null;var H7=D(()=>{AJ()});import{matchRoute as xT,Router as vT}from"stx-router";import{findErrorPage as MJ,formatRoutes as EJ,generateRouteManifest as fT,generateRouteTypes as hT,matchRoute as y3}from"stx-router";function Q4($,Z={}){return new vT($,Z).routes}function gT($,Z){let Y=xT($,Z);return Y?Y.params:null}var O7=()=>{};var vq={};e(vq,{generateStaticSite:()=>bq,defineStaticPaths:()=>yq,default:()=>oT,createMarkdownLoader:()=>xq,createISRHandler:()=>Pq});import u0 from"fs";import N0 from"path";class Dq{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 u0.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=u0.statSync($),X=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(u0.existsSync(Q)){let G=u0.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 kq{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 u0.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 u0.promises.unlink(Z)}async invalidatePattern($){let Z=N0.join(this.cacheDir,"isr");if(!u0.existsSync(Z))return;let Y=await u0.promises.readdir(Z);for(let X of Y){let J=X.replace(/_/g,"/").replace(".json","");if($.test(J))await u0.promises.unlink(N0.join(Z,X))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function dT($){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(`
11512
+ `)}var z7=null;var H7=D(()=>{AJ()});import{matchRoute as xT,Router as vT}from"stx-router";import{findErrorPage as MJ,formatRoutes as EJ,generateRouteManifest as fT,generateRouteTypes as hT,matchRoute as y3}from"stx-router";function Q6($,Z={}){return new vT($,Z).routes}function gT($,Z){let Y=xT($,Z);return Y?Y.params:null}var O7=()=>{};var vq={};e(vq,{generateStaticSite:()=>bq,defineStaticPaths:()=>yq,default:()=>oT,createMarkdownLoader:()=>xq,createISRHandler:()=>Pq});import u0 from"fs";import N0 from"path";class Dq{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 u0.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=u0.statSync($),X=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(u0.existsSync(Q)){let G=u0.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 kq{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 u0.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 u0.promises.unlink(Z)}async invalidatePattern($){let Z=N0.join(this.cacheDir,"isr");if(!u0.existsSync(Z))return;let Y=await u0.promises.readdir(Z);for(let X of Y){let J=X.replace(/_/g,"/").replace(".json","");if($.test(J))await u0.promises.unlink(N0.join(Z,X))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function dT($){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(`
11513
11513
  return (async function getStaticPaths() {
11514
11514
  ${J[1]}
11515
11515
  })()
@@ -11519,7 +11519,7 @@ ${J}
11519
11519
  })()
11520
11520
  `)(Z)}catch(Q){return console.error(`Error executing getStaticProps in ${Y}:`,Q),null}}async function Sq($,Z,Y={},X,J){let Q=await Bun.file($.filePath).text(),G=await mT($.filePath),K=await cT(Q,Z,$.filePath),W={...G||{},...K||{},...Y,params:Z,$route:{path:$.pattern,params:Z}},U=new Set,_={...J,debug:!1,cache:!1,autoShell:!0},B=await G0(Q,W,$.filePath,_,U);if(Object.keys(Z).length>0){let z=`<script>if(window.stx)window.stx._rp=${JSON.stringify(Z)};else window.__stx_rp=${JSON.stringify(Z)};</script>`;if(B.includes("</head>"))B=B.replace("</head>",`${z}
11521
11521
  </head>`);else B=`${z}
11522
- ${B}`}if(B=await D4(B),B=await E0(B),X.minify!==!1)return lT(B);return B}function lT($){let Z=[],Y=0,X=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,J;while((J=X.exec($))!==null){let G=$.slice(Y,J.index);Z.push(G.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let K=J[1],W=J[2],U=J[3];W=W.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),Z.push(K+W+U),Y=J.index+J[0].length}let Q=$.slice(Y);return Z.push(Q.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),Z.join("").trim()}function pT($){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 iT($,Z){return`<?xml version="1.0" encoding="UTF-8"?>
11522
+ ${B}`}if(B=await D6(B),B=await E0(B),X.minify!==!1)return lT(B);return B}function lT($){let Z=[],Y=0,X=/(<script[^>]*>)([\s\S]*?)(<\/script>)/gi,J;while((J=X.exec($))!==null){let G=$.slice(Y,J.index);Z.push(G.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><"));let K=J[1],W=J[2],U=J[3];W=W.replace(/([^:"\\'`])\/\/(?!\/)(?![*!])([^\n]*)/g,"$1"),Z.push(K+W+U),Y=J.index+J[0].length}let Q=$.slice(Y);return Z.push(Q.replace(/<!--(?!\[if)[\s\S]*?-->/g,"").replace(/\s+/g," ").replace(/>\s+</g,"><")),Z.join("").trim()}function pT($){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 iT($,Z){return`<?xml version="1.0" encoding="UTF-8"?>
11523
11523
  <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
11524
11524
  ${$.map((X)=>{let J=new URL(X.loc,Z).href,Q=` <url>
11525
11525
  <loc>${I1(J)}</loc>`;if(X.lastmod)Q+=`
@@ -11549,7 +11549,7 @@ ${$.map((X)=>{let J=new URL(X.loc,Z).href,Q=` <url>
11549
11549
  ${Y.join(`
11550
11550
  `)}
11551
11551
  </channel>
11552
- </rss>`}async function bq($={}){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&&u0.existsSync(X.outputDir))await u0.promises.rm(X.outputDir,{recursive:!0});await u0.promises.mkdir(X.outputDir,{recursive:!0});let Q=new Dq(X.cacheDir);if(X.cache)await Q.load();try{let{preloadIconCollection:j}=await Promise.resolve().then(() => (P2(),K_));await j("lucide")}catch{}try{let{generateCrosswindCSS:j}=await Promise.resolve().then(() => (P1(),T9));await j('<div class="bg-black"></div>')}catch{}G7();let G=Y?.routeMiddleware?.dir||"middleware";await _7(process.cwd(),G);let K=U7();if(K.length>0)console.log(`Loaded ${K.length} middleware: ${K.join(", ")}`);let W=Y?.routeMiddleware?.global||[],U=Q4(".",{pagesDir:X.pagesDir});console.log(`Found ${U.length} routes`);let _=[];for(let j of U){let H=await uT(j);for(let O of H)_.push({route:j,url:O.url,params:O.params,props:O.props,revalidate:O.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:O,url:F,params:L,props:V,revalidate:w}=H;try{await X.hooks.onPageStart?.(F);let A=await Bun.file(O.filePath).text(),N=rT(A),M=N?.middleware?Array.isArray(N.middleware)?N.middleware:[N.middleware]:[],E=[...W,...M];if(E.length>0){let y=W7(F,L,N||{}),v=K7(y,null),C=await B7(E,v);if(C.redirect){let f=typeof C.redirect==="string"?C.redirect:C.redirect.path||C.redirect,h=aT(String(f),F),d=sT(F,X);await u0.promises.mkdir(N0.dirname(d),{recursive:!0}),await Bun.write(d,h),J.successCount++,J.pages.push({route:F,outputPath:d,size:Buffer.byteLength(h),cached:!1}),B.push({loc:F,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${F} \u2192 redirect to ${f}`);return}if(C.abort){let f=typeof C.abort==="string"?C.abort:C.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",`
11552
+ </rss>`}async function bq($={}){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&&u0.existsSync(X.outputDir))await u0.promises.rm(X.outputDir,{recursive:!0});await u0.promises.mkdir(X.outputDir,{recursive:!0});let Q=new Dq(X.cacheDir);if(X.cache)await Q.load();try{let{preloadIconCollection:j}=await Promise.resolve().then(() => (P2(),K_));await j("lucide")}catch{}try{let{generateCrosswindCSS:j}=await Promise.resolve().then(() => (P1(),T9));await j('<div class="bg-black"></div>')}catch{}G7();let G=Y?.routeMiddleware?.dir||"middleware";await _7(process.cwd(),G);let K=U7();if(K.length>0)console.log(`Loaded ${K.length} middleware: ${K.join(", ")}`);let W=Y?.routeMiddleware?.global||[],U=Q6(".",{pagesDir:X.pagesDir});console.log(`Found ${U.length} routes`);let _=[];for(let j of U){let H=await uT(j);for(let O of H)_.push({route:j,url:O.url,params:O.params,props:O.props,revalidate:O.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:O,url:F,params:L,props:V,revalidate:w}=H;try{await X.hooks.onPageStart?.(F);let A=await Bun.file(O.filePath).text(),N=rT(A),M=N?.middleware?Array.isArray(N.middleware)?N.middleware:[N.middleware]:[],E=[...W,...M];if(E.length>0){let y=W7(F,L,N||{}),v=K7(y,null),C=await B7(E,v);if(C.redirect){let f=typeof C.redirect==="string"?C.redirect:C.redirect.path||C.redirect,h=aT(String(f),F),d=sT(F,X);await u0.promises.mkdir(N0.dirname(d),{recursive:!0}),await Bun.write(d,h),J.successCount++,J.pages.push({route:F,outputPath:d,size:Buffer.byteLength(h),cached:!1}),B.push({loc:F,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${F} \u2192 redirect to ${f}`);return}if(C.abort){let f=typeof C.abort==="string"?C.abort:C.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",`
11553
11553
  const validate = ${I[1]};
11554
11554
  return validate(route);
11555
11555
  `)({params:L})){console.warn(`Validation failed for ${F}, skipping...`);return}}catch{}let T=null,S=!1;if(X.cache){if(T=Q.get(F,O.filePath,[]),T)S=!0,J.cachedCount++}if(!T){if(T=await Sq(O,L,V,X,Y),X.cache)Q.set(F,O.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 u0.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 b={route:F,outputPath:k,size:Buffer.byteLength(T,"utf8"),cached:S};if(w!==!1)b.revalidateAt=Date.now()+w*1000;J.pages.push(b),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,O={...Y,debug:!1,cache:!1},F=await G0(await Bun.file(j).text(),{},j,O,H);await Bun.write(N0.join(X.outputDir,"404.html"),F)}else await Bun.write(N0.join(X.outputDir,"404.html"),`<!DOCTYPE html>
@@ -11580,7 +11580,7 @@ Build complete!
11580
11580
  Cached: ${J.cachedCount}
11581
11581
  Failed: ${J.failedCount}
11582
11582
  Time: ${J.buildTime}ms
11583
- `),J}async function Cq($,Z){let Y=await u0.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 u0.promises.mkdir(Q,{recursive:!0}),await Cq(J,Q);else await u0.promises.copyFile(J,Q)}}function Pq($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new kq(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=Q4(".",{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 Sq(G,W,{},$,U);await Y.set(J,{html:_,generatedAt:Date.now(),revalidateAfter:Date.now()+X*1000,etag:pT(_)}),console.log(`Revalidated: ${J}`)},async invalidate(J){if(typeof J==="string")await Y.invalidate(J);else await Y.invalidatePattern(J)}}}function yq($){return async()=>{return{paths:await $(),fallback:!1}}}function xq(){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(`
11583
+ `),J}async function Cq($,Z){let Y=await u0.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 u0.promises.mkdir(Q,{recursive:!0}),await Cq(J,Q);else await u0.promises.copyFile(J,Q)}}function Pq($={}){let Z=$.cacheDir||".stx/ssg-cache",Y=new kq(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=Q6(".",{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 Sq(G,W,{},$,U);await Y.set(J,{html:_,generatedAt:Date.now(),revalidateAfter:Date.now()+X*1000,etag:pT(_)}),console.log(`Revalidated: ${J}`)},async invalidate(J){if(typeof J==="string")await Y.invalidate(J);else await Y.invalidatePattern(J)}}}function yq($){return async()=>{return{paths:await $(),fallback:!1}}}function xq(){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(`
11584
11584
  `)){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 rT($){let Z=$.match(/definePageMeta\s*\(\s*(\{[\s\S]*?\})\s*\)/m);if(!Z)return null;try{return Function(`return ${Z[1]}`)()}catch{return null}}function aT($,Z){return`<!DOCTYPE html>
11585
11585
  <html>
11586
11586
  <head>
@@ -11593,7 +11593,7 @@ Build complete!
11593
11593
  <p>Redirecting to <a href="${$}">${$}</a>...</p>
11594
11594
  <script>window.location.replace('${$}')</script>
11595
11595
  </body>
11596
- </html>`}function sT($,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 oT;var gq=D(()=>{O7();G1();m0();P1();b3();oT={generateStaticSite:bq,createISRHandler:Pq,defineStaticPaths:yq,createMarkdownLoader:xq}});import{createHash as tT}from"crypto";import{getRouterScript as eT}from"stx-router";function TJ($){return tT("sha256").update($).digest("hex").slice(0,8)}function IJ($=!1){let Z=$?e4():N5(),Y=TJ(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function DJ(){let $=eT(),Z=TJ($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function $I($){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 kJ=D(()=>{R5()});import fq from"path";import{createHash as ZI}from"crypto";function YI($={}){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 SJ($,Z,Y={}){let X=fq.resolve($),J=await Bun.file(X).text(),Q=ZI("sha256").update(J).digest("hex").slice(0,16);P8();let G={};try{G=await f0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:_}=YI({__filename:X,__dirname:fq.dirname(X)}),B=new Set,z={...K1,...G,...Y,buildMode:"compile",strict:!1},q=await G0(J,_,X,z,B),j=G6(q),H=y8();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(B),contentHash:Q}}var bJ=D(()=>{G1();m0();o$();H7()});import CJ from"fs";import hq from"path";function PJ($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function yJ($,Z){let Y=hq.join(Z,"manifest.json");CJ.writeFileSync(Y,JSON.stringify($,null,2))}function xJ($){let Z=hq.join($,"manifest.json");if(!CJ.existsSync(Z))return null;try{let Y=CJ.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 x3=()=>{};var uq={};e(uq,{buildForProduction:()=>dq});import i1 from"fs";import s0 from"path";function JI($,Z){let Y=0,X=0;if(!i1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=i1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(XI.has(W.name))continue;let U=s0.join(Q,W.name),_=s0.join(G,W.name);if(W.isDirectory())i1.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(i1.existsSync(_))continue;i1.copyFileSync(U,_),Y++,X+=i1.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function dq($={}){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(i1.existsSync(X))i1.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)i1.mkdirSync(M,{recursive:!0});console.log("[stx build] Discovering routes...");let z=Q4(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=IJ($.debug),O=DJ();await Bun.write(s0.join(X,"public","__stx",H.filename),H.content),await Bun.write(s0.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],L=[];for(let M of j)try{let E=await SJ(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,O.filename),E.html=F5(E.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(E.html)){let b=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(b&&b[1]){let y=b[1];E.html=E.html.replace(" "+y,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${y}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await E0(E.html),E.fragment=j7(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),L.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(i1.existsSync(V)){let{copied:M,bytes:E}=JI(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 w={runtime:H.filename,router:O.filename},A=PJ(L,w,X);yJ(A,X);let N=Date.now()-Z;return console.log(`
11596
+ </html>`}function sT($,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 oT;var gq=D(()=>{O7();G1();m0();P1();b3();oT={generateStaticSite:bq,createISRHandler:Pq,defineStaticPaths:yq,createMarkdownLoader:xq}});import{createHash as tT}from"crypto";import{getRouterScript as eT}from"stx-router";function TJ($){return tT("sha256").update($).digest("hex").slice(0,8)}function IJ($=!1){let Z=$?e6():N5(),Y=TJ(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function DJ(){let $=eT(),Z=TJ($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function $I($){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 kJ=D(()=>{R5()});import fq from"path";import{createHash as ZI}from"crypto";function YI($={}){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 SJ($,Z,Y={}){let X=fq.resolve($),J=await Bun.file(X).text(),Q=ZI("sha256").update(J).digest("hex").slice(0,16);P8();let G={};try{G=await f0()}catch{}let K=[],W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,U;while((U=W.exec(J))!==null){let O=U[1];if(/\bserver\b/.test(O))K.push(U[2])}let{context:_}=YI({__filename:X,__dirname:fq.dirname(X)}),B=new Set,z={...K1,...G,...Y,buildMode:"compile",strict:!1},q=await G0(J,_,X,z,B),j=G4(q),H=y8();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(B),contentHash:Q}}var bJ=D(()=>{G1();m0();o$();H7()});import CJ from"fs";import hq from"path";function PJ($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function yJ($,Z){let Y=hq.join(Z,"manifest.json");CJ.writeFileSync(Y,JSON.stringify($,null,2))}function xJ($){let Z=hq.join($,"manifest.json");if(!CJ.existsSync(Z))return null;try{let Y=CJ.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 x3=()=>{};var uq={};e(uq,{buildForProduction:()=>dq});import i1 from"fs";import s0 from"path";function JI($,Z){let Y=0,X=0;if(!i1.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=i1.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(XI.has(W.name))continue;let U=s0.join(Q,W.name),_=s0.join(G,W.name);if(W.isDirectory())i1.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(i1.existsSync(_))continue;i1.copyFileSync(U,_),Y++,X+=i1.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function dq($={}){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(i1.existsSync(X))i1.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)i1.mkdirSync(M,{recursive:!0});console.log("[stx build] Discovering routes...");let z=Q6(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=IJ($.debug),O=DJ();await Bun.write(s0.join(X,"public","__stx",H.filename),H.content),await Bun.write(s0.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],L=[];for(let M of j)try{let E=await SJ(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,O.filename),E.html=F5(E.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(E.html)){let b=E.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(b&&b[1]){let y=b[1];E.html=E.html.replace(" "+y,""),E.html=E.html.replace(/<body([^>]*)>/,`<body$1 ${y}>`)}}E.html=E.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),E.html=await E0(E.html),E.fragment=j7(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),L.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(i1.existsSync(V)){let{copied:M,bytes:E}=JI(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 w={runtime:H.filename,router:O.filename},A=PJ(L,w,X);yJ(A,X);let N=Date.now()-Z;return console.log(`
11597
11597
  [stx build] Done in ${N}ms \u2014 ${F.length} pages compiled`),{pageCount:F.length,assets:w,outputDir:X,duration:N}}var XI;var vJ=D(()=>{O7();kJ();bJ();x3();H7();P1();m0();XI=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var cq={};e(cq,{buildApp:()=>mq});import QI from"path";async function mq($={}){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(() => (gq(),vq));Q=await W({pagesDir:QI.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(() => (vJ(),uq));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 gJ=D(()=>{m0()});import v3 from"path";async function KI($){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)=>v3.resolve(X,K)),Q=[],G=0;for(let K of J){let W=await pq(K);for(let U of W){G++;let _=await Bun.file(U).text();if(lq.test(_))Q.push(v3.relative(X,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-Z)}}async function WI($){let Z=await f0(),Y=$||Z.root||process.cwd(),X=v3.resolve(Y,Z.componentsDir||"components"),J=[],Q=await pq(X);for(let G of Q){let K=await Bun.file(G).text(),W=lq.test(K),U=GI.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let _=v3.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 pq($){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 lq,GI;var iq=D(()=>{m0();lq=/<script\b[^>]*\bserver\b/i,GI=/<script\b[^>]*\bclient\b/i});function fJ($){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(`
11598
11598
  `,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 aq($,Z=[]){let Y=fJ($),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 sq($){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${_I(Q)} } from './${Q}'`);let J=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
11599
11599
  `);return`// Tree-shaken directive bundle
@@ -12206,39 +12206,39 @@ const features = [
12206
12206
  })();
12207
12207
  </script>
12208
12208
  </body>
12209
- </html>`}var cI;var oJ=D(()=>{cI={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 uj={};e(uj,{startInteractive:()=>dj});import A7 from"fs";import d4 from"path";import*as hj from"readline";function aI($,Z){let Y=$.split(" "),X=Y[0];if(Y.length===1)return Object.keys(W6).filter((J)=>J.startsWith(X));if(["render","cat","load","cd"].includes(X)){let J=Y.slice(1).join(" "),Q=d4.dirname(J)||".",G=d4.basename(J),K=d4.resolve(Z.cwd,Q);if(A7.existsSync(K)&&A7.statSync(K).isDirectory())try{return A7.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 dj($={}){let Z={context:$.context||{},cwd:$.cwd||process.cwd(),history:[],running:!0,lastResult:null},Y=hj.createInterface({input:process.stdin,output:process.stdout,completer:(J)=>{return[aI(J,Z),J]},historySize:$.maxHistory||100});console.log(`
12209
+ </html>`}var cI;var oJ=D(()=>{cI={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 uj={};e(uj,{startInteractive:()=>dj});import A7 from"fs";import d6 from"path";import*as hj from"readline";function aI($,Z){let Y=$.split(" "),X=Y[0];if(Y.length===1)return Object.keys(W4).filter((J)=>J.startsWith(X));if(["render","cat","load","cd"].includes(X)){let J=Y.slice(1).join(" "),Q=d6.dirname(J)||".",G=d6.basename(J),K=d6.resolve(Z.cwd,Q);if(A7.existsSync(K)&&A7.statSync(K).isDirectory())try{return A7.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 dj($={}){let Z={context:$.context||{},cwd:$.cwd||process.cwd(),history:[],running:!0,lastResult:null},Y=hj.createInterface({input:process.stdin,output:process.stdout,completer:(J)=>{return[aI(J,Z),J]},historySize:$.maxHistory||100});console.log(`
12210
12210
  ${P.bold}${P.blue}stx Interactive Mode${P.reset}
12211
12211
  ${P.dim}Type 'help' for available commands, 'exit' to quit${P.reset}
12212
- `);let X=()=>{let J=Z.cwd.replace(process.env.HOME||"","~");Y.question(`${P.cyan}stx${P.reset} ${P.dim}${J}${P.reset} ${P.green}>${P.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&&W6[W])try{await W6[W].handler(U,Z)}catch(_){console.log(`${P.red}Error:${P.reset}`,_)}else if(W)if(G.includes("{{")||G.includes("}}"))try{let _=await w1(G,Z.context,"eval");console.log(`${P.green}\u2192${P.reset} ${_}`)}catch{console.log(`${P.red}Unknown command: ${W}${P.reset}`),console.log(`${P.dim}Type 'help' for available commands${P.reset}`)}else console.log(`${P.red}Unknown command: ${W}${P.reset}`),console.log(`${P.dim}Type 'help' for available commands${P.reset}`);if(Z.running)X();else Y.close()})};Y.on("SIGINT",()=>{console.log(`
12213
- ${P.dim}(Use 'exit' to quit)${P.reset}`),X()}),X()}var P,W6;var tJ=D(()=>{r0();G1();P={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"},W6={help:{description:"Show available commands",usage:"help [command]",handler:async($,Z)=>{if($[0]&&W6[$[0]]){let Y=W6[$[0]];console.log(`
12212
+ `);let X=()=>{let J=Z.cwd.replace(process.env.HOME||"","~");Y.question(`${P.cyan}stx${P.reset} ${P.dim}${J}${P.reset} ${P.green}>${P.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&&W4[W])try{await W4[W].handler(U,Z)}catch(_){console.log(`${P.red}Error:${P.reset}`,_)}else if(W)if(G.includes("{{")||G.includes("}}"))try{let _=await w1(G,Z.context,"eval");console.log(`${P.green}\u2192${P.reset} ${_}`)}catch{console.log(`${P.red}Unknown command: ${W}${P.reset}`),console.log(`${P.dim}Type 'help' for available commands${P.reset}`)}else console.log(`${P.red}Unknown command: ${W}${P.reset}`),console.log(`${P.dim}Type 'help' for available commands${P.reset}`);if(Z.running)X();else Y.close()})};Y.on("SIGINT",()=>{console.log(`
12213
+ ${P.dim}(Use 'exit' to quit)${P.reset}`),X()}),X()}var P,W4;var tJ=D(()=>{r0();G1();P={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"},W4={help:{description:"Show available commands",usage:"help [command]",handler:async($,Z)=>{if($[0]&&W4[$[0]]){let Y=W4[$[0]];console.log(`
12214
12214
  ${P.bold}${$[0]}${P.reset} - ${Y.description}`),console.log(` Usage: ${P.cyan}${Y.usage}${P.reset}
12215
12215
  `)}else{console.log(`
12216
12216
  ${P.bold}Available Commands:${P.reset}
12217
- `);for(let[Y,X]of Object.entries(W6))console.log(` ${P.cyan}${Y.padEnd(12)}${P.reset} ${X.description}`);console.log(`
12217
+ `);for(let[Y,X]of Object.entries(W4))console.log(` ${P.cyan}${Y.padEnd(12)}${P.reset} ${X.description}`);console.log(`
12218
12218
  ${P.dim}Type 'help <command>' for more details${P.reset}
12219
- `)}}},render:{description:"Render a template file",usage:"render <file> [--raw]",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a file to render${P.reset}`);return}let Y=d4.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${P.red}Error: File not found: ${Y}${P.reset}`);return}try{let X=await Bun.file(Y).text(),J=$.includes("--raw");console.log(`
12219
+ `)}}},render:{description:"Render a template file",usage:"render <file> [--raw]",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a file to render${P.reset}`);return}let Y=d6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${P.red}Error: File not found: ${Y}${P.reset}`);return}try{let X=await Bun.file(Y).text(),J=$.includes("--raw");console.log(`
12220
12220
  ${P.dim}Rendering ${Y}...${P.reset}
12221
12221
  `);let Q=await G0(X,Z.context,Y,{},new Set);if(Z.lastResult=Q,J)console.log(Q);else Q.split(`
12222
12222
  `).forEach((K,W)=>{let U=String(W+1).padStart(3," ");console.log(`${P.dim}${U}${P.reset} ${K}`)});console.log()}catch(X){console.log(`${P.red}Error rendering template:${P.reset}`,X)}}},eval:{description:"Evaluate an expression",usage:"eval <expression>",handler:async($,Z)=>{if(!$.length){console.log(`${P.red}Error: Please provide an expression to evaluate${P.reset}`);return}let Y=$.join(" ");try{let X=`{{ ${Y} }}`,Q=(await w1(X,Z.context,"eval")).trim();Z.lastResult=Q,console.log(`${P.green}\u2192${P.reset} ${Q}`)}catch(X){console.log(`${P.red}Error:${P.reset}`,X)}}},set:{description:"Set a context variable",usage:"set <key> <value>",handler:async($,Z)=>{if($.length<2){console.log(`${P.red}Error: Usage: set <key> <value>${P.reset}`);return}let Y=$[0],X=$.slice(1).join(" "),J;try{J=JSON.parse(X)}catch{J=X}Z.context[Y]=J,console.log(`${P.green}\u2713${P.reset} ${Y} = ${JSON.stringify(J)}`)}},unset:{description:"Remove a context variable",usage:"unset <key>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a variable to remove${P.reset}`);return}if($[0]in Z.context)delete Z.context[$[0]],console.log(`${P.green}\u2713${P.reset} Removed ${$[0]}`);else console.log(`${P.yellow}Variable not found: ${$[0]}${P.reset}`)}},context:{description:"Show current context variables",usage:"context",handler:async($,Z)=>{let Y=Object.keys(Z.context);if(Y.length===0){console.log(`${P.dim}Context is empty${P.reset}`);return}console.log(`
12223
12223
  ${P.bold}Context Variables:${P.reset}
12224
- `);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(` ${P.cyan}${X}${P.reset} ${P.dim}(${Q})${P.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(`${P.green}\u2713${P.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.cyan}${Z.cwd}${P.reset}`);return}let Y=d4.resolve(Z.cwd,$[0]);if(!A7.existsSync(Y)){console.log(`${P.red}Error: Directory not found: ${Y}${P.reset}`);return}if(!A7.statSync(Y).isDirectory()){console.log(`${P.red}Error: Not a directory: ${Y}${P.reset}`);return}Z.cwd=Y,console.log(`${P.green}\u2713${P.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(`${P.dim}No files found${P.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(`
12224
+ `);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(` ${P.cyan}${X}${P.reset} ${P.dim}(${Q})${P.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(`${P.green}\u2713${P.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.cyan}${Z.cwd}${P.reset}`);return}let Y=d6.resolve(Z.cwd,$[0]);if(!A7.existsSync(Y)){console.log(`${P.red}Error: Directory not found: ${Y}${P.reset}`);return}if(!A7.statSync(Y).isDirectory()){console.log(`${P.red}Error: Not a directory: ${Y}${P.reset}`);return}Z.cwd=Y,console.log(`${P.green}\u2713${P.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(`${P.dim}No files found${P.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(`
12225
12225
  ${P.bold}Templates:${P.reset}`),Q.forEach((W)=>console.log(` ${P.green}${W}${P.reset}`));if(G.length>0)console.log(`
12226
12226
  ${P.bold}Markdown:${P.reset}`),G.forEach((W)=>console.log(` ${P.blue}${W}${P.reset}`));if(K.length>0)console.log(`
12227
- ${P.bold}Other:${P.reset}`),K.forEach((W)=>console.log(` ${P.dim}${W}${P.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a file${P.reset}`);return}let Y=d4.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${P.red}Error: File not found: ${Y}${P.reset}`);return}let J=(await Bun.file(Y).text()).split(`
12228
- `);console.log(),J.forEach((Q,G)=>{let K=String(G+1).padStart(3," ");console.log(`${P.dim}${K}${P.reset} ${Q}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a JSON file${P.reset}`);return}let Y=d4.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${P.red}Error: File not found: ${Y}${P.reset}`);return}try{let X=await Bun.file(Y).text(),J=JSON.parse(X);Z.context={...Z.context,...J},console.log(`${P.green}\u2713${P.reset} Loaded ${Object.keys(J).length} variables from ${$[0]}`)}catch(X){console.log(`${P.red}Error parsing JSON:${P.reset}`,X)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a file name${P.reset}`);return}let Y=d4.resolve(Z.cwd,$[0]);try{await Bun.write(Y,JSON.stringify(Z.context,null,2)),console.log(`${P.green}\u2713${P.reset} Context saved to ${$[0]}`)}catch(X){console.log(`${P.red}Error saving file:${P.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(`${P.dim}No history${P.reset}`);return}console.log(),X.forEach((J,Q)=>{let G=String(Z.history.length-X.length+Q+1).padStart(3," ");console.log(`${P.dim}${G}${P.reset} ${J}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async($,Z)=>{Z.running=!1,console.log(`
12227
+ ${P.bold}Other:${P.reset}`),K.forEach((W)=>console.log(` ${P.dim}${W}${P.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a file${P.reset}`);return}let Y=d6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${P.red}Error: File not found: ${Y}${P.reset}`);return}let J=(await Bun.file(Y).text()).split(`
12228
+ `);console.log(),J.forEach((Q,G)=>{let K=String(G+1).padStart(3," ");console.log(`${P.dim}${K}${P.reset} ${Q}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a JSON file${P.reset}`);return}let Y=d6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${P.red}Error: File not found: ${Y}${P.reset}`);return}try{let X=await Bun.file(Y).text(),J=JSON.parse(X);Z.context={...Z.context,...J},console.log(`${P.green}\u2713${P.reset} Loaded ${Object.keys(J).length} variables from ${$[0]}`)}catch(X){console.log(`${P.red}Error parsing JSON:${P.reset}`,X)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${P.red}Error: Please specify a file name${P.reset}`);return}let Y=d6.resolve(Z.cwd,$[0]);try{await Bun.write(Y,JSON.stringify(Z.context,null,2)),console.log(`${P.green}\u2713${P.reset} Context saved to ${$[0]}`)}catch(X){console.log(`${P.red}Error saving file:${P.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(`${P.dim}No history${P.reset}`);return}console.log(),X.forEach((J,Q)=>{let G=String(Z.history.length-X.length+Q+1).padStart(3," ");console.log(`${P.dim}${G}${P.reset} ${J}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async($,Z)=>{Z.running=!1,console.log(`
12229
12229
  ${P.dim}Goodbye!${P.reset}
12230
- `)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async($,Z)=>W6.exit.handler($,Z)}}});import{createHash as sI}from"crypto";import{existsSync as w7,mkdirSync as oI,readFileSync as eJ,writeFileSync as tI,readdirSync as eI,statSync as $D}from"fs";import{basename as N7,dirname as G4,extname as R7,join as n1,relative as mj}from"path";import{gzipSync as ZD}from"zlib";class d3{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...cj,...$}}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=N7(Y,R7(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=R7(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=n1(this.config.outDir,K);this.ensureDir(G4(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 n1(G4($),"..",Z);return n1(G4($),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(w7(U)){let _=eJ(U,"utf-8");X.push(`// Source: ${W[1]}
12230
+ `)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async($,Z)=>W4.exit.handler($,Z)}}});import{createHash as sI}from"crypto";import{existsSync as w7,mkdirSync as oI,readFileSync as eJ,writeFileSync as tI,readdirSync as eI,statSync as $D}from"fs";import{basename as N7,dirname as G6,extname as R7,join as n1,relative as mj}from"path";import{gzipSync as ZD}from"zlib";class d3{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...cj,...$}}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=N7(Y,R7(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=R7(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=n1(this.config.outDir,K);this.ensureDir(G6(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 n1(G6($),"..",Z);return n1(G6($),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(w7(U)){let _=eJ(U,"utf-8");X.push(`// Source: ${W[1]}
12231
12231
  ${_}`)}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(w7(U)){let _=eJ(U,"utf-8");J.push(`/* Source: ${W[1]} */
12232
12232
  ${_}`)}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(`
12233
12233
 
12234
- `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.js`,W=n1(this.config.outDir,K);this.ensureDir(G4(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>
12234
+ `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.js`,W=n1(this.config.outDir,K);this.ensureDir(G6(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>
12235
12235
  `+Y.slice(U)}if(J.length>0){let Q=J.join(`
12236
12236
 
12237
- `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.css`,W=n1(this.config.outDir,K);this.ensureDir(G4(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}">
12237
+ `),G=this.generateHash(Q).slice(0,8),K=`assets/app.${G}.css`,W=n1(this.config.outDir,K);this.ensureDir(G6(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}">
12238
12238
  </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(`
12239
- `),Y=this.generateHash(Z).slice(0,8),X=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Y),J=n1(this.config.outDir,X);this.ensureDir(G4(J)),await Bun.write(J,Z),this.outputs.push({path:J,type:"css",size:Buffer.byteLength(Z),hash:Y})}async processAssets(){let $=n1(G4(this.config.outDir),"public");if(!w7($))return;let Z=this.config.assets||{},Y=Z.include||[];this.walkDir($,(X)=>{let J=R7(X).slice(1).toLowerCase();if(!Y.includes(J))return;let Q=eJ(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]",N7(X,R7(X))).replace("[hash]",K).replace("[ext]",R7(X)),U=n1(this.config.outDir,W);this.ensureDir(G4(U)),tI(U,Q),this.assetHashes.set(X,W),this.assets.push({name:N7(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:N7($.path),sources:$.sources||[],sourcesContent:Y,mappings:"",names:[]},J=`${$.path}.map`;await Bun.write(J,JSON.stringify(X));let Q=this.config.sourcemaps==="inline"?`
12239
+ `),Y=this.generateHash(Z).slice(0,8),X=(this.config.css?.filename||"assets/[name].[hash].css").replace("[name]","styles").replace("[hash]",Y),J=n1(this.config.outDir,X);this.ensureDir(G6(J)),await Bun.write(J,Z),this.outputs.push({path:J,type:"css",size:Buffer.byteLength(Z),hash:Y})}async processAssets(){let $=n1(G6(this.config.outDir),"public");if(!w7($))return;let Z=this.config.assets||{},Y=Z.include||[];this.walkDir($,(X)=>{let J=R7(X).slice(1).toLowerCase();if(!Y.includes(J))return;let Q=eJ(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]",N7(X,R7(X))).replace("[hash]",K).replace("[ext]",R7(X)),U=n1(this.config.outDir,W);this.ensureDir(G6(U)),tI(U,Q),this.assetHashes.set(X,W),this.assets.push({name:N7(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:N7($.path),sources:$.sources||[],sourcesContent:Y,mappings:"",names:[]},J=`${$.path}.map`;await Bun.write(J,JSON.stringify(X));let Q=this.config.sourcemaps==="inline"?`
12240
12240
  //# sourceMappingURL=data:application/json;base64,${Buffer.from(JSON.stringify(X)).toString("base64")}`:`
12241
- //# sourceMappingURL=${N7(J)}`;if(this.config.sourcemaps!=="hidden")await Bun.write($.path,Z+Q);this.outputs.push({path:J,type:"map",size:$D(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=mj(G4($.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=ZD(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:mj(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=n1(this.config.outDir,J);await Bun.write(Q,X),console.log(`
12241
+ //# sourceMappingURL=${N7(J)}`;if(this.config.sourcemaps!=="hidden")await Bun.write($.path,Z+Q);this.outputs.push({path:J,type:"map",size:$D(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=mj(G6($.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=ZD(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:mj(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=n1(this.config.outDir,J);await Bun.write(Q,X),console.log(`
12242
12242
  \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>
12243
12243
  <html>
12244
12244
  <head>
@@ -12279,40 +12279,40 @@ ${_}`)}else this.warnings.push(`External stylesheet not found: ${U}`)}return""})
12279
12279
  </table>
12280
12280
  </body>
12281
12281
  </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(`
12282
- `)}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 sI("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(!w7($))oI($,{recursive:!0})}walkDir($,Z){if(!w7($))return;let Y=eI($,{withFileTypes:!0});for(let X of Y){let J=n1($,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 YD($){return new d3($).build()}function XD($){return new d3($)}function JD($){return{...cj,...$}}var cj;var lj=D(()=>{cj={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 $Q($,Z={}){if(!$.hasServerScripts&&!w6($.html))return $.html;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await A0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!w6($.html))return $.html;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=_1(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?D0(String(G)):"")}catch{X.set(J,"")}return w9($.html,X)}async function QD($,Z={}){if(!$.hasServerScripts&&!w6($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await A0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!w6($.fragment))return $.fragment;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=_1(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?D0(String(G)):"")}catch{X.set(J,"")}return w9($.fragment,X)}var ZQ=D(()=>{R4();r0();o$()});var nj={};e(nj,{startProductionServer:()=>ij});import pj from"fs";import u4 from"path";var{serve:GD}=globalThis.Bun;async function ij($={}){let Z=u4.resolve($.outputDir||".output"),Y=$.port||3000,X=xJ(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 _=u4.join(Z,U.compiledPath),B=JSON.parse(await Bun.file(_).text());J.set(U.pattern,B);let z=u4.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=GD({port:Y,async fetch(U){let B=new URL(U.url).pathname;if($.onRequest){let O=await $.onRequest(U);if(O)return O}if($.apiRoutes?.[B])return $.apiRoutes[B](U);if((U.method==="GET"||U.method==="HEAD")&&B!=="/"){let O=u4.resolve(Z,"public"),F;try{F=decodeURIComponent(B)}catch{F=B}if(!F.includes("\x00")){let L=u4.resolve(O,`.${F}`);if(L===O||L.startsWith(`${O}${u4.sep}`))try{if(pj.existsSync(L)&&pj.statSync(L).isFile()){let w=u4.extname(L).toLowerCase(),A=KD[w]||"application/octet-stream",N=B.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(B);return new Response(Bun.file(L),{headers:{"Content-Type":A,"Cache-Control":N?"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:O,route:F,paramNames:L}of K){let V=B.match(O);if(V){q=F,L.forEach((w,A)=>{j[w]=V[A+1]});break}}if(!q){let O=G.get("/404")||null;if(O){let F=J.get(O.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 O=Q.get(q.pattern);if(O)return new Response(O,{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 O=await $Q(H,{params:j,request:U});return new Response(O,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(O){return console.error(`[stx] Hydration error for ${B}:`,O),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 KD;var YQ=D(()=>{x3();ZQ();KD={".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 XQ="f9c3713";import{existsSync as M7,mkdirSync as JQ}from"fs";import{join as m4,dirname as WD}from"path";import{execSync as rj}from"child_process";async function _D($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.template||"default",J=m4(process.cwd(),$);if(M7(J))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{JQ(J,{recursive:!0});let Q=BD(X);for(let K of Q)JQ(m4(J,K),{recursive:!0});let G=zD(X,$,Z);for(let[K,W]of Object.entries(G)){let U=m4(J,K);E7(WD(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{rj("git init",{cwd:J,stdio:"ignore"}),await Bun.write(m4(J,".gitignore"),ED()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||iD();try{console.log(`
12282
+ `)}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 sI("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(!w7($))oI($,{recursive:!0})}walkDir($,Z){if(!w7($))return;let Y=eI($,{withFileTypes:!0});for(let X of Y){let J=n1($,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 YD($){return new d3($).build()}function XD($){return new d3($)}function JD($){return{...cj,...$}}var cj;var lj=D(()=>{cj={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 $Q($,Z={}){if(!$.hasServerScripts&&!w4($.html))return $.html;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await A0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!w4($.html))return $.html;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=_1(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?D0(String(G)):"")}catch{X.set(J,"")}return w9($.html,X)}async function QD($,Z={}){if(!$.hasServerScripts&&!w4($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await A0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!w4($.fragment))return $.fragment;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=_1(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?D0(String(G)):"")}catch{X.set(J,"")}return w9($.fragment,X)}var ZQ=D(()=>{R6();r0();o$()});var nj={};e(nj,{startProductionServer:()=>ij});import pj from"fs";import u6 from"path";var{serve:GD}=globalThis.Bun;async function ij($={}){let Z=u6.resolve($.outputDir||".output"),Y=$.port||3000,X=xJ(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 _=u6.join(Z,U.compiledPath),B=JSON.parse(await Bun.file(_).text());J.set(U.pattern,B);let z=u6.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=GD({port:Y,async fetch(U){let B=new URL(U.url).pathname;if($.onRequest){let O=await $.onRequest(U);if(O)return O}if($.apiRoutes?.[B])return $.apiRoutes[B](U);if((U.method==="GET"||U.method==="HEAD")&&B!=="/"){let O=u6.resolve(Z,"public"),F;try{F=decodeURIComponent(B)}catch{F=B}if(!F.includes("\x00")){let L=u6.resolve(O,`.${F}`);if(L===O||L.startsWith(`${O}${u6.sep}`))try{if(pj.existsSync(L)&&pj.statSync(L).isFile()){let w=u6.extname(L).toLowerCase(),A=KD[w]||"application/octet-stream",N=B.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(B);return new Response(Bun.file(L),{headers:{"Content-Type":A,"Cache-Control":N?"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:O,route:F,paramNames:L}of K){let V=B.match(O);if(V){q=F,L.forEach((w,A)=>{j[w]=V[A+1]});break}}if(!q){let O=G.get("/404")||null;if(O){let F=J.get(O.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 O=Q.get(q.pattern);if(O)return new Response(O,{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 O=await $Q(H,{params:j,request:U});return new Response(O,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(O){return console.error(`[stx] Hydration error for ${B}:`,O),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 KD;var YQ=D(()=>{x3();ZQ();KD={".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 XQ="f9c3713";import{existsSync as M7,mkdirSync as JQ}from"fs";import{join as m6,dirname as WD}from"path";import{execSync as rj}from"child_process";async function _D($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.template||"default",J=m6(process.cwd(),$);if(M7(J))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{JQ(J,{recursive:!0});let Q=BD(X);for(let K of Q)JQ(m6(J,K),{recursive:!0});let G=zD(X,$,Z);for(let[K,W]of Object.entries(G)){let U=m6(J,K);E7(WD(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{rj("git init",{cwd:J,stdio:"ignore"}),await Bun.write(m6(J,".gitignore"),ED()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||iD();try{console.log(`
12283
12283
  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(`
12284
12284
  \u2705 ${Y.message}
12285
12285
 
12286
12286
  Next steps:
12287
12287
  cd ${$}
12288
12288
  ${Z.packageManager||"bun"} run dev
12289
- `)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function BD($){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 zD($,Z,Y){let X={};if(X["package.json"]=wD(Z,$,Y),X["stx.config.ts"]=ND($,Y),X["README.md"]=MD(Z,$),Y.typescript!==!1)X["tsconfig.json"]=RD();switch($){case"minimal":X["src/index.stx"]=TD();break;case"blog":X["pages/index.stx"]=SD(),X["pages/[slug].stx"]=bD(),X["layouts/app.stx"]=CD(),X["components/PostCard.stx"]=PD();break;case"dashboard":X["pages/index.stx"]=yD(),X["pages/settings.stx"]=xD(),X["layouts/app.stx"]=vD(),X["components/Sidebar.stx"]=gD(),X["components/StatsCard.stx"]=fD(),X["src/stores/dashboard.ts"]=hD();break;case"landing":X["pages/index.stx"]=dD(),X["layouts/app.stx"]=uD(),X["src/sections/Hero.stx"]=mD(),X["src/sections/Features.stx"]=cD(),X["src/sections/Pricing.stx"]=lD(),X["components/Button.stx"]=pD();break;case"full":X["pages/index.stx"]=aj(),X["pages/about.stx"]=ID(),X["layouts/app.stx"]=sj(),X["components/Header.stx"]=oj(),X["components/Footer.stx"]=tj(),X["src/stores/app.ts"]=ej(),X["src/i18n/en.json"]=DD("en"),X["test/example.test.ts"]=kD();break;default:X["pages/index.stx"]=aj(),X["layouts/app.stx"]=sj(),X["components/Header.stx"]=oj(),X["components/Footer.stx"]=tj(),X["src/stores/app.ts"]=ej()}return X}async function qD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"components",J=QQ($),Q=m4(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{E7(X);let G=LD(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 jD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"pages",J=$.toLowerCase().replace(/\s+/g,"-"),Q=m4(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{E7(X);let G=FD(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 HD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"src/stores",J=nD($),Q=m4(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{E7(X);let G=VD(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 OD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"layouts",J=$.toLowerCase().replace(/\s+/g,"-"),Q=m4(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{E7(X);let G=AD(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 LD($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
12289
+ `)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function BD($){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 zD($,Z,Y){let X={};if(X["package.json"]=wD(Z,$,Y),X["stx.config.ts"]=ND($,Y),X["README.md"]=MD(Z,$),Y.typescript!==!1)X["tsconfig.json"]=RD();switch($){case"minimal":X["src/index.stx"]=TD();break;case"blog":X["pages/index.stx"]=SD(),X["pages/[slug].stx"]=bD(),X["layouts/app.stx"]=CD(),X["components/PostCard.stx"]=PD();break;case"dashboard":X["pages/index.stx"]=yD(),X["pages/settings.stx"]=xD(),X["layouts/app.stx"]=vD(),X["components/Sidebar.stx"]=gD(),X["components/StatsCard.stx"]=fD(),X["src/stores/dashboard.ts"]=hD();break;case"landing":X["pages/index.stx"]=dD(),X["layouts/app.stx"]=uD(),X["src/sections/Hero.stx"]=mD(),X["src/sections/Features.stx"]=cD(),X["src/sections/Pricing.stx"]=lD(),X["components/Button.stx"]=pD();break;case"full":X["pages/index.stx"]=aj(),X["pages/about.stx"]=ID(),X["layouts/app.stx"]=sj(),X["components/Header.stx"]=oj(),X["components/Footer.stx"]=tj(),X["src/stores/app.ts"]=ej(),X["src/i18n/en.json"]=DD("en"),X["test/example.test.ts"]=kD();break;default:X["pages/index.stx"]=aj(),X["layouts/app.stx"]=sj(),X["components/Header.stx"]=oj(),X["components/Footer.stx"]=tj(),X["src/stores/app.ts"]=ej()}return X}async function qD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"components",J=QQ($),Q=m6(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{E7(X);let G=LD(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 jD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"pages",J=$.toLowerCase().replace(/\s+/g,"-"),Q=m6(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{E7(X);let G=FD(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 HD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"src/stores",J=nD($),Q=m6(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{E7(X);let G=VD(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 OD($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"layouts",J=$.toLowerCase().replace(/\s+/g,"-"),Q=m6(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{E7(X);let G=AD(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 LD($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
12290
12290
  // Props
12291
12291
  const title = props.title || '${$}'
12292
12292
  const variant = props.variant || 'default'
12293
12293
  </script>
12294
- `);if(Y.push(`<div class="${U6($)} ${U6($)}--{{ variant }}">
12294
+ `);if(Y.push(`<div class="${U4($)} ${U4($)}--{{ variant }}">
12295
12295
  <h3>{{ title }}</h3>
12296
- <div class="${U6($)}__content">
12296
+ <div class="${U4($)}__content">
12297
12297
  {{ slot }}
12298
12298
  </div>
12299
12299
  </div>`),Z.styles!==!1)Y.push(`
12300
12300
  <style scoped>
12301
- .${U6($)} {
12301
+ .${U4($)} {
12302
12302
  padding: 1rem;
12303
12303
  border-radius: 8px;
12304
12304
  background: #f8f9fa;
12305
12305
  }
12306
12306
 
12307
- .${U6($)}--primary {
12307
+ .${U4($)}--primary {
12308
12308
  border-left: 3px solid #3498db;
12309
12309
  }
12310
12310
 
12311
- .${U6($)}--success {
12311
+ .${U4($)}--success {
12312
12312
  border-left: 3px solid #2ecc71;
12313
12313
  }
12314
12314
 
12315
- .${U6($)}__content {
12315
+ .${U4($)}__content {
12316
12316
  margin-top: 0.5rem;
12317
12317
  }
12318
12318
  </style>`);return Y.join(`
@@ -12753,14 +12753,14 @@ describe('Example', () => {
12753
12753
  </footer>
12754
12754
  @yield('scripts')
12755
12755
  </body>
12756
- </html>`}function mD(){return"<!-- Hero section -->"}function cD(){return"<!-- Features -->"}function lD(){return"<!-- Pricing -->"}function pD(){return"<!-- Button -->"}function E7($){if(!M7($))JQ($,{recursive:!0})}function iD(){if(M7("bun.lockb"))return"bun";if(M7("pnpm-lock.yaml"))return"pnpm";if(M7("yarn.lock"))return"yarn";return"bun"}function QQ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function nD($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function U6($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var UD;var $H=D(()=>{UD={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:rD}=globalThis.Bun;import T7 from"fs";import c4 from"path";function aD($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function ZH($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=c4.resolve(Y),B=new Map;async function z(L){let V=T7.statSync(L),w=`${L}:${V.mtimeMs}`,A=B.get(w);if(A)return A.content;for(let d of B.keys())if(d.startsWith(`${L}:`)&&d!==w)B.delete(d);let N=await Bun.file(L).text(),M=N,E=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(E&&E.index!==void 0){let d=E.index+E[0].length,i=1,n=d;while(n<N.length&&i>0){let W0=N.indexOf("<template",n),z0=N.indexOf("</template>",n);if(z0===-1)break;if(W0!==-1&&W0<z0)i++,n=W0+9;else{if(i--,i===0){M=N.substring(d,z0).trim();break}n=z0+11}}}let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,T=[],S=[],k;while((k=I.exec(N))!==null){let d=k[1],i=k[2],n=k[0];if(d.includes("server"))S.push(i);else T.push(n)}let b=N.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),v={__filename:L,__dirname:c4.dirname(L)};for(let d of S)await A0(d,v,L);let h=await G0(y,v,L,X,new Set);if(b.length>0){let d=b.join(`
12756
+ </html>`}function mD(){return"<!-- Hero section -->"}function cD(){return"<!-- Features -->"}function lD(){return"<!-- Pricing -->"}function pD(){return"<!-- Button -->"}function E7($){if(!M7($))JQ($,{recursive:!0})}function iD(){if(M7("bun.lockb"))return"bun";if(M7("pnpm-lock.yaml"))return"pnpm";if(M7("yarn.lock"))return"yarn";return"bun"}function QQ($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function nD($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function U4($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var UD;var $H=D(()=>{UD={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:rD}=globalThis.Bun;import T7 from"fs";import c6 from"path";function aD($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function ZH($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=c6.resolve(Y),B=new Map;async function z(L){let V=T7.statSync(L),w=`${L}:${V.mtimeMs}`,A=B.get(w);if(A)return A.content;for(let d of B.keys())if(d.startsWith(`${L}:`)&&d!==w)B.delete(d);let N=await Bun.file(L).text(),M=N,E=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>/i);if(E&&E.index!==void 0){let d=E.index+E[0].length,i=1,n=d;while(n<N.length&&i>0){let W0=N.indexOf("<template",n),z0=N.indexOf("</template>",n);if(z0===-1)break;if(W0!==-1&&W0<z0)i++,n=W0+9;else{if(i--,i===0){M=N.substring(d,z0).trim();break}n=z0+11}}}let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,T=[],S=[],k;while((k=I.exec(N))!==null){let d=k[1],i=k[2],n=k[0];if(d.includes("server"))S.push(i);else T.push(n)}let b=N.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],y=M.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),v={__filename:L,__dirname:c6.dirname(L)};for(let d of S)await A0(d,v,L);let h=await G0(y,v,L,X,new Set);if(b.length>0){let d=b.join(`
12757
12757
  `);if(h.match(/(<\/head>)/i))h=h.replace(/(<\/head>)/i,`${d}
12758
12758
  $1`)}if(T.length>0){let{interpolateScriptsInTemplate:d}=await Promise.resolve().then(() => (r0(),$5)),i=d(T.join(`
12759
12759
  `),v);if(h.match(/(<\/body>)/i))h=h.replace(/(<\/body>)/i,`${i}
12760
12760
  $1`);else h+=`
12761
- ${i}`}return B.set(w,{content:h,mtime:V.mtimeMs}),h}async function q(L){let V=T7.statSync(L),w=`${L}:${V.mtimeMs}`,A=B.get(w);if(A)return A.content;let{content:N}=await $4(L,X);return B.set(w,{content:N,mtime:V.mtimeMs}),N}function j(L){let V=L.startsWith("/")?L.slice(1):L,w=[V,`${V}.stx`,`${V}.md`,`${V}.html`,c4.join(V,"index.stx"),c4.join(V,"index.md"),c4.join(V,"index.html")];for(let A of w){let N=c4.join(_,A);if(T7.existsSync(N)&&T7.statSync(N).isFile())return N}return null}async function H(L){let V=new URL(L.url),w=async()=>{if(G[V.pathname])return await G[V.pathname](L);if(Q){let N=await Q(L);if(N)return N}let A=j(V.pathname);if(!A){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let N,M="text/html";if(A.endsWith(".stx"))N=await z(A);else if(A.endsWith(".md"))N=await q(A);else if(A.endsWith(".html"))N=await Bun.file(A).text();else if(A.endsWith(".css"))N=await Bun.file(A).text(),M="text/css";else if(A.endsWith(".js"))N=await Bun.file(A).text(),M="text/javascript";else if(A.endsWith(".json"))N=await Bun.file(A).text(),M="application/json";else return new Response(Bun.file(A));return new Response(N,{headers:{"Content-Type":M}})}catch(N){if(U)return await U(N,L);let M=N instanceof Error?N.message:String(N),I=X?.debug===!0?`<h1>Error</h1><pre>${M}
12762
- ${N instanceof Error?N.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 N=K[A],M=w;w=async()=>await N(L,M)}return await w()}let O=rD({port:Z,fetch:H}),F=null;if(J)F=T7.watch(_,{recursive:!0},(L,V)=>{if(V&&(V.endsWith(".stx")||V.endsWith(".md")||V.endsWith(".html")))B.clear()});return{server:O,url:O.url.toString(),stop(){if(F)F.close();O.stop()}}}async function sD($,Z={}){let Y=c4.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 ZH({...Z,root:c4.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await $4(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(`
12763
- `),B=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={};if(_.trim())await A0(_,z,Y);let q=new Set;Q=await G0(B,z,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function oD($){return $}function tD($){return $}var YH=D(()=>{i6();G1();H0()});import u3 from"path";function eD($){let Z=[],Y=0,X;XH.lastIndex=0;while((X=XH.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 $k($,Z={},Y={}){let X={...K1,...Y,streaming:{...GQ,...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:u3.dirname($)};if(W.trim())await A0(W,_,$);let B=eD(U),z=new Set;if(!B.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(_6.source,"g");if(!(j!=="manual"&&H.test(U))){let F=await G0(U,_,$,X,z);for(let L=0;L<F.length;L+=J)Q.enqueue(F.slice(L,L+J)),await new Promise((V)=>setTimeout(V,0))}else{let F=[],L=new RegExp(_6.source,"g"),V;while((V=L.exec(U))!==null)F.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let w=0;for(let A of F){if(A.start>w){let M=U.slice(w,A.start);if(M.trim()){let E=await G0(M,_,$,X,z);Q.enqueue(E),await new Promise((I)=>setTimeout(I,0))}}let N=await G0(A.content,_,$,X,z);Q.enqueue(N),await new Promise((M)=>setTimeout(M,0)),w=A.end}if(w<U.length){let A=U.slice(w);if(A.trim()){let N=await G0(A,_,$,X,z);Q.enqueue(N)}}}}else{let j=new Map;for(let O of B)if(O.type==="shell"||O.type==="content"){let F=await G0(O.content,_,$,X,z);Q.enqueue(F)}else if(O.type==="suspense"&&O.name){let F=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${F}" data-suspense="${O.name}" style="display:contents;">
12761
+ ${i}`}return B.set(w,{content:h,mtime:V.mtimeMs}),h}async function q(L){let V=T7.statSync(L),w=`${L}:${V.mtimeMs}`,A=B.get(w);if(A)return A.content;let{content:N}=await $6(L,X);return B.set(w,{content:N,mtime:V.mtimeMs}),N}function j(L){let V=L.startsWith("/")?L.slice(1):L,w=[V,`${V}.stx`,`${V}.md`,`${V}.html`,c6.join(V,"index.stx"),c6.join(V,"index.md"),c6.join(V,"index.html")];for(let A of w){let N=c6.join(_,A);if(T7.existsSync(N)&&T7.statSync(N).isFile())return N}return null}async function H(L){let V=new URL(L.url),w=async()=>{if(G[V.pathname])return await G[V.pathname](L);if(Q){let N=await Q(L);if(N)return N}let A=j(V.pathname);if(!A){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let N,M="text/html";if(A.endsWith(".stx"))N=await z(A);else if(A.endsWith(".md"))N=await q(A);else if(A.endsWith(".html"))N=await Bun.file(A).text();else if(A.endsWith(".css"))N=await Bun.file(A).text(),M="text/css";else if(A.endsWith(".js"))N=await Bun.file(A).text(),M="text/javascript";else if(A.endsWith(".json"))N=await Bun.file(A).text(),M="application/json";else return new Response(Bun.file(A));return new Response(N,{headers:{"Content-Type":M}})}catch(N){if(U)return await U(N,L);let M=N instanceof Error?N.message:String(N),I=X?.debug===!0?`<h1>Error</h1><pre>${M}
12762
+ ${N instanceof Error?N.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 N=K[A],M=w;w=async()=>await N(L,M)}return await w()}let O=rD({port:Z,fetch:H}),F=null;if(J)F=T7.watch(_,{recursive:!0},(L,V)=>{if(V&&(V.endsWith(".stx")||V.endsWith(".md")||V.endsWith(".html")))B.clear()});return{server:O,url:O.url.toString(),stop(){if(F)F.close();O.stop()}}}async function sD($,Z={}){let Y=c6.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 ZH({...Z,root:c6.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await $6(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(`
12763
+ `),B=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),z={};if(_.trim())await A0(_,z,Y);let q=new Set;Q=await G0(B,z,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function oD($){return $}function tD($){return $}var YH=D(()=>{i4();G1();H0()});import u3 from"path";function eD($){let Z=[],Y=0,X;XH.lastIndex=0;while((X=XH.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 $k($,Z={},Y={}){let X={...K1,...Y,streaming:{...GQ,...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:u3.dirname($)};if(W.trim())await A0(W,_,$);let B=eD(U),z=new Set;if(!B.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(_4.source,"g");if(!(j!=="manual"&&H.test(U))){let F=await G0(U,_,$,X,z);for(let L=0;L<F.length;L+=J)Q.enqueue(F.slice(L,L+J)),await new Promise((V)=>setTimeout(V,0))}else{let F=[],L=new RegExp(_4.source,"g"),V;while((V=L.exec(U))!==null)F.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let w=0;for(let A of F){if(A.start>w){let M=U.slice(w,A.start);if(M.trim()){let E=await G0(M,_,$,X,z);Q.enqueue(E),await new Promise((I)=>setTimeout(I,0))}}let N=await G0(A.content,_,$,X,z);Q.enqueue(N),await new Promise((M)=>setTimeout(M,0)),w=A.end}if(w<U.length){let A=U.slice(w);if(A.trim()){let N=await G0(A,_,$,X,z);Q.enqueue(N)}}}}else{let j=new Map;for(let O of B)if(O.type==="shell"||O.type==="content"){let F=await G0(O.content,_,$,X,z);Q.enqueue(F)}else if(O.type==="suspense"&&O.name){let F=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${F}" data-suspense="${O.name}" style="display:contents;">
12764
12764
  <template data-suspense-fallback>Loading...</template>
12765
12765
  </div>`),j.set(O.name,G0(O.content,_,$,X,z))}Q.enqueue(`
12766
12766
  <script>
@@ -12784,7 +12784,7 @@ window.__stxSuspense.resolve('${O}', \`${V}\`);
12784
12784
  </script>`)}catch(L){let V=L instanceof Error?L.message:String(L);Q.enqueue(`
12785
12785
  <script>
12786
12786
  window.__stxSuspense.resolve('${O}', '<div class="stx-error">Error loading content: ${D0(V)}</div>');
12787
- </script>`)}});await Promise.all(H)}Q.close()}catch(G){Q.error(G)}}})}async function Zk($,Z={},Y={}){let X={...K1,...Y,streaming:{...GQ,...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:u3.dirname($)};if(W.trim())await A0(W,_,$);let B=new Set,z=X.streaming?.strategy||"auto",q=new RegExp(_6.source,"g");if(!(z!=="manual"&&q.test(U))){let H=await G0(U,_,$,X,B);for(let O=0;O<H.length;O+=J)Q.enqueue(H.slice(O,O+J))}else{let H=[],O=new RegExp(_6.source,"g"),F;while((F=O.exec(U))!==null)H.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let L=0;for(let V of H){if(V.start>L){let A=U.slice(L,V.start);if(A.trim()){let N=await G0(A,_,$,X,B);Q.enqueue(N)}}let w=await G0(V.content,_,$,X,B);Q.enqueue(w),L=V.end}if(L<U.length){let V=U.slice(L);if(V.trim()){let w=await G0(V,_,$,X,B);Q.enqueue(w)}}}Q.close()}catch(G){Q.error(G)}}})}async function Yk($,Z={}){let Y={...K1,...Z,streaming:{...GQ,...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;_6.lastIndex=0;while((U=_6.exec(G))!==null){let z=U[1],q=U[2];W[z]=q}let _=G.replace(_6,"");return{renderShell:async(z={})=>{let q={...z,__filename:$,__dirname:u3.dirname($)};return await A0(Q,q,$),G0(_,q,$,Y,new Set)},renderSection:async(z,q={})=>{try{if(!W[z])return`<div class="error-message">Section "${D0(z)}" not found in template "${D0($)}"</div>`;let j={...q,__filename:$,__dirname:u3.dirname($)};await A0(Q,j,$);let H=new Set;return await G0(W[z],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return L0("Expression",H,$,W[z]||"",0,W[z]||"")}},getSections:()=>{return Object.keys(W)},getTemplate:()=>{return K}}}function Xk($={}){let Z=[];if($.streaming?.enabled)Z.push(JH);if($.hydration?.enabled)Z.push(QH);return Z}async function Jk($,Z,Y,X={}){return $}function Qk($,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 Gk($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
12787
+ </script>`)}});await Promise.all(H)}Q.close()}catch(G){Q.error(G)}}})}async function Zk($,Z={},Y={}){let X={...K1,...Y,streaming:{...GQ,...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:u3.dirname($)};if(W.trim())await A0(W,_,$);let B=new Set,z=X.streaming?.strategy||"auto",q=new RegExp(_4.source,"g");if(!(z!=="manual"&&q.test(U))){let H=await G0(U,_,$,X,B);for(let O=0;O<H.length;O+=J)Q.enqueue(H.slice(O,O+J))}else{let H=[],O=new RegExp(_4.source,"g"),F;while((F=O.exec(U))!==null)H.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let L=0;for(let V of H){if(V.start>L){let A=U.slice(L,V.start);if(A.trim()){let N=await G0(A,_,$,X,B);Q.enqueue(N)}}let w=await G0(V.content,_,$,X,B);Q.enqueue(w),L=V.end}if(L<U.length){let V=U.slice(L);if(V.trim()){let w=await G0(V,_,$,X,B);Q.enqueue(w)}}}Q.close()}catch(G){Q.error(G)}}})}async function Yk($,Z={}){let Y={...K1,...Z,streaming:{...GQ,...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;_4.lastIndex=0;while((U=_4.exec(G))!==null){let z=U[1],q=U[2];W[z]=q}let _=G.replace(_4,"");return{renderShell:async(z={})=>{let q={...z,__filename:$,__dirname:u3.dirname($)};return await A0(Q,q,$),G0(_,q,$,Y,new Set)},renderSection:async(z,q={})=>{try{if(!W[z])return`<div class="error-message">Section "${D0(z)}" not found in template "${D0($)}"</div>`;let j={...q,__filename:$,__dirname:u3.dirname($)};await A0(Q,j,$);let H=new Set;return await G0(W[z],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return L0("Expression",H,$,W[z]||"",0,W[z]||"")}},getSections:()=>{return Object.keys(W)},getTemplate:()=>{return K}}}function Xk($={}){let Z=[];if($.streaming?.enabled)Z.push(JH);if($.hydration?.enabled)Z.push(QH);return Z}async function Jk($,Z,Y,X={}){return $}function Qk($,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 Gk($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
12788
12788
  `);if(Z==="loader")return`
12789
12789
  (function() {
12790
12790
  window.__stx = window.__stx || {};
@@ -12926,7 +12926,7 @@ else {
12926
12926
  else {
12927
12927
  stx.hydrate();
12928
12928
  }
12929
- })();`}var GQ,_6,XH,JH,QH;var GH=D(()=>{m0();r0();G1();H0();GQ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},_6=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,XH=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;JH={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} -->`}},QH={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}">
12929
+ })();`}var GQ,_4,XH,JH,QH;var GH=D(()=>{m0();r0();G1();H0();GQ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},_4=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,XH=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;JH={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} -->`}},QH={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}">
12930
12930
  ${U}
12931
12931
  <script type="application/json" data-island-props="${G}">
12932
12932
  ${W?`{${W}}`:"{}"}
@@ -12965,7 +12965,7 @@ else {
12965
12965
  0% { transform: translateX(-100%); }
12966
12966
  100% { transform: translateX(100%); }
12967
12967
  }
12968
- `,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function m3($,Z){if(!P$||!U1)return;if(r1=Math.min(Math.max($,0),100),BQ)cancelAnimationFrame(BQ);BQ=requestAnimationFrame(()=>{if(!U1)return;U1.style.opacity=r1>0?"1":"0",U1.style.transform=`scaleX(${r1/100})`})}function Hk($){if(!P$)return;if(I7=!0,r1=0,!U1)U1=_H($);if(C$)clearTimeout(C$);if(K4)clearInterval(K4);m3(10,$),K4=setInterval(()=>{if(!I7)return;let Z=90-r1,Y=Math.max(0.5,Z*0.1);if(r1<90)m3(r1+Y,$)},$.throttle)}function Ok($){if(!P$)return;if(I7=!1,K4)clearInterval(K4),K4=null;m3(100,$),C$=setTimeout(()=>{if(U1)U1.style.opacity="0";setTimeout(()=>{if(r1=0,U1)U1.style.transform="scaleX(0)"},300)},200)}function Lk(){if(!P$)return;if(I7=!1,r1=0,K4)clearInterval(K4),K4=null;if(C$)clearTimeout(C$),C$=null;if(U1)U1.style.opacity="0",U1.style.transform="scaleX(0)"}function BH($){let Z={...zQ,...$};return{start:()=>Hk(Z),set:(Y)=>m3(Y,Z),finish:()=>Ok(Z),clear:()=>Lk(),get state(){return{isLoading:I7,progress:r1,error:!1}}}}function Fk($){if(!P$)return;let Z={...zQ,...$},Y=BH(Z);U1=_H(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 Vk($){let Z={...zQ,...$},Y=Z.initialColor?`linear-gradient(to right, ${Z.initialColor}, ${Z.color})`:Z.color;return`
12968
+ `,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function m3($,Z){if(!P$||!U1)return;if(r1=Math.min(Math.max($,0),100),BQ)cancelAnimationFrame(BQ);BQ=requestAnimationFrame(()=>{if(!U1)return;U1.style.opacity=r1>0?"1":"0",U1.style.transform=`scaleX(${r1/100})`})}function Hk($){if(!P$)return;if(I7=!0,r1=0,!U1)U1=_H($);if(C$)clearTimeout(C$);if(K6)clearInterval(K6);m3(10,$),K6=setInterval(()=>{if(!I7)return;let Z=90-r1,Y=Math.max(0.5,Z*0.1);if(r1<90)m3(r1+Y,$)},$.throttle)}function Ok($){if(!P$)return;if(I7=!1,K6)clearInterval(K6),K6=null;m3(100,$),C$=setTimeout(()=>{if(U1)U1.style.opacity="0";setTimeout(()=>{if(r1=0,U1)U1.style.transform="scaleX(0)"},300)},200)}function Lk(){if(!P$)return;if(I7=!1,r1=0,K6)clearInterval(K6),K6=null;if(C$)clearTimeout(C$),C$=null;if(U1)U1.style.opacity="0",U1.style.transform="scaleX(0)"}function BH($){let Z={...zQ,...$};return{start:()=>Hk(Z),set:(Y)=>m3(Y,Z),finish:()=>Ok(Z),clear:()=>Lk(),get state(){return{isLoading:I7,progress:r1,error:!1}}}}function Fk($){if(!P$)return;let Z={...zQ,...$},Y=BH(Z);U1=_H(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 Vk($){let Z={...zQ,...$},Y=Z.initialColor?`linear-gradient(to right, ${Z.initialColor}, ${Z.color})`:Z.color;return`
12969
12969
  <div id="stx-loading-indicator" style="
12970
12970
  position: fixed;
12971
12971
  top: 0;
@@ -13059,7 +13059,7 @@ else {
13059
13059
  window.addEventListener('load', function() { window.stxLoading.finish(); });
13060
13060
  })();
13061
13061
  </script>
13062
- `}var P$,zQ,U1=null,r1=0,I7=!1,BQ=null,C$=null,K4=null;var zH=D(()=>{P$=typeof window<"u"&&typeof document<"u",zQ={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999}});var qQ=`
13062
+ `}var P$,zQ,U1=null,r1=0,I7=!1,BQ=null,C$=null,K6=null;var zH=D(()=>{P$=typeof window<"u"&&typeof document<"u",zQ={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999}});var qQ=`
13063
13063
  <script data-stx-helpers>
13064
13064
  (function() {
13065
13065
  'use strict'
@@ -14405,7 +14405,7 @@ else {
14405
14405
  border: none;
14406
14406
  color: white;
14407
14407
  }
14408
- `.trim();return{html:Q,script:G,css:K}}function gH($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function s3(){return"loading"in HTMLImageElement.prototype}function o3(){return"IntersectionObserver"in window}function ZG($={}){let Z={...mH,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&s3())return Y.forEach((J)=>{if(J.tagName==="IMG"||J.tagName==="IFRAME")W4(J,Z)}),()=>{};if(!o3())return Y.forEach((J)=>W4(J,Z)),()=>{};let X=new IntersectionObserver((J)=>{J.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;W4(G,Z),X.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((J)=>X.observe(J)),()=>{X.disconnect()}}function W4($,Z={}){let{onLoad:Y,onLoaded:X,onError:J}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)dH($,X,J);else if(G)uH($,X,J);else if(K)gk($,X,J);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)dH(W,()=>{if(X)X($)},(B)=>{if(J)J($,B)});else if(U)uH(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 dH($,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 uH($,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 gk($,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 YG($){W4($,{})}function XG($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>W4(Y,{}))}function JG($={}){let Z={...mH,...$};return new IntersectionObserver((Y,X)=>{Y.forEach((J)=>{if(J.isIntersecting)W4(J.target,Z),X.unobserve(J.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function QG($,Z){$.observe(Z)}function GG($){$.disconnect()}function C7(){return`
14408
+ `.trim();return{html:Q,script:G,css:K}}function gH($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#039;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function s3(){return"loading"in HTMLImageElement.prototype}function o3(){return"IntersectionObserver"in window}function ZG($={}){let Z={...mH,...$},Y=document.querySelectorAll(Z.selector);if(Y.length===0)return()=>{};if(Z.useNative&&s3())return Y.forEach((J)=>{if(J.tagName==="IMG"||J.tagName==="IFRAME")W6(J,Z)}),()=>{};if(!o3())return Y.forEach((J)=>W6(J,Z)),()=>{};let X=new IntersectionObserver((J)=>{J.forEach((Q)=>{if(Q.isIntersecting){let G=Q.target;W6(G,Z),X.unobserve(G)}})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold});return Y.forEach((J)=>X.observe(J)),()=>{X.disconnect()}}function W6($,Z={}){let{onLoad:Y,onLoaded:X,onError:J}=Z;if(Y)Y($);let Q=$.tagName==="IMG",G=$.tagName==="VIDEO",K=$.tagName==="IFRAME";if(Q)dH($,X,J);else if(G)uH($,X,J);else if(K)gk($,X,J);else{let W=$.querySelector("img[data-src], img[data-srcset]"),U=$.querySelector("video[data-src]");if(W)dH(W,()=>{if(X)X($)},(B)=>{if(J)J($,B)});else if(U)uH(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 dH($,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 uH($,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 gk($,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 YG($){W6($,{})}function XG($="[data-stx-lazy]"){document.querySelectorAll($).forEach((Y)=>W6(Y,{}))}function JG($={}){let Z={...mH,...$};return new IntersectionObserver((Y,X)=>{Y.forEach((J)=>{if(J.isIntersecting)W6(J.target,Z),X.unobserve(J.target)})},{root:Z.root,rootMargin:Z.rootMargin,threshold:Z.threshold})}function QG($,Z){$.observe(Z)}function GG($){$.disconnect()}function C7(){return`
14409
14409
  (function() {
14410
14410
  'use strict';
14411
14411
 
@@ -14664,7 +14664,7 @@ else {
14664
14664
  })();
14665
14665
  `.trim()}var uk;var LG=D(()=>{uk={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1}});function FG(){return{script:[C7(),y7(),v7()].join(`
14666
14666
 
14667
- `),css:x7()}}function pH(){let{script:$,css:Z}=FG(),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 iH=D(()=>{KG();qG();LG();KG();qG();LG()});var nH=D(()=>{C4();p2()});var lk;var rH=D(()=>{bH();IX();iX();pX();PH();vH();iH();nH();lk={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 Z8 from"fs";import B6 from"path";async function VG($,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:B6.dirname($),props:Z,...Z};if(Q)await A0(Q,K,$);let W={...K1,...Y};return await G0(G,K,$,W,new Set)}async function aH($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:X,outputDir:J,componentsDir:Q=B6.join(X,"components"),layoutsDir:G=B6.join(X,"layouts"),partialsDir:K=B6.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}`);Z8.mkdirSync(J,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:B},j;if(_&&_.length>0)j=_;else j=Z8.readdirSync(X).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=B6.join(X,H.input),F=H.output||H.input.replace(/\.stx$/,".html"),L=B6.join(J,F);if(B)console.log(` Building ${H.input}...`);try{let V={...W,...H.props,...U},w=await VG(O,V,q);await Bun.write(L,w),Y.views.push(F)}catch(V){let w=V instanceof Error?V.message:String(V);if(Y.errors.push({file:H.input,error:w}),Y.success=!1,B)console.error(` Error: ${w}`)}}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(B6.join(J,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,B)if(Y.success)console.log(`
14667
+ `),css:x7()}}function pH(){let{script:$,css:Z}=FG(),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 iH=D(()=>{KG();qG();LG();KG();qG();LG()});var nH=D(()=>{C6();p2()});var lk;var rH=D(()=>{bH();IX();iX();pX();PH();vH();iH();nH();lk={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 Z8 from"fs";import B4 from"path";async function VG($,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:B4.dirname($),props:Z,...Z};if(Q)await A0(Q,K,$);let W={...K1,...Y};return await G0(G,K,$,W,new Set)}async function aH($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:X,outputDir:J,componentsDir:Q=B4.join(X,"components"),layoutsDir:G=B4.join(X,"layouts"),partialsDir:K=B4.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}`);Z8.mkdirSync(J,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:B},j;if(_&&_.length>0)j=_;else j=Z8.readdirSync(X).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=B4.join(X,H.input),F=H.output||H.input.replace(/\.stx$/,".html"),L=B4.join(J,F);if(B)console.log(` Building ${H.input}...`);try{let V={...W,...H.props,...U},w=await VG(O,V,q);await Bun.write(L,w),Y.views.push(F)}catch(V){let w=V instanceof Error?V.message:String(V);if(Y.errors.push({file:H.input,error:w}),Y.success=!1,B)console.error(` Error: ${w}`)}}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(B4.join(J,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,B)if(Y.success)console.log(`
14668
14668
  \u2705 Built ${Y.views.length} views in ${Y.duration.toFixed(0)}ms`);else console.log(`
14669
14669
  \u26A0\uFE0F Built ${Y.views.length} views with ${Y.errors.length} errors`);return Y}function pk($,Z){let Y=Z8.watch($.viewsDir,{recursive:!0},async(X,J)=>{if(!J)return;if(J.endsWith(".stx")||J.endsWith(".ts")||J.endsWith(".js")){if($.debug)console.log(`
14670
14670
  File changed: ${J}, rebuilding...`);let Q=await aH($);Z?.(Q)}});return{close:()=>Y.close()}}async function ik($,Z={},Y={}){let X={...Y,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},J=await VG($,Z,X);J=await nk(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,`
@@ -14673,7 +14673,7 @@ File changed: ${J}, rebuilding...`);let Q=await aH($);Z?.(Q)}});return{close:()=
14673
14673
  `).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
14674
14674
  `).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,`
14675
14675
 
14676
- `).trim()}var sH=D(()=>{R4();m0();G1()});function sk($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ok($){let Z={};for(let Y of Object.keys($))if(!Y.startsWith("__"))Z[Y]=$[Y];return Z}function tk($){let{template:Z,context:Y={},title:X="stx App"}=$,J=ok(Y),Q=sk(JSON.stringify(J));return`<!DOCTYPE html>
14676
+ `).trim()}var sH=D(()=>{R6();m0();G1()});function sk($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function ok($){let Z={};for(let Y of Object.keys($))if(!Y.startsWith("__"))Z[Y]=$[Y];return Z}function tk($){let{template:Z,context:Y={},title:X="stx App"}=$,J=ok(Y),Q=sk(JSON.stringify(J));return`<!DOCTYPE html>
14677
14677
  <html lang="en">
14678
14678
  <head>
14679
14679
  <meta charset="UTF-8">
@@ -14758,7 +14758,7 @@ File changed: ${J}, rebuilding...`);let Q=await aH($);Z?.(Q)}});return{close:()=
14758
14758
  return refs;
14759
14759
  };
14760
14760
  })();
14761
- `}var a1=null,Y8;var AG=D(()=>{Y8=new Map});function $S($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function wG($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function BO($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[WO($)];return $.flat(1/0).map(WO).filter((Z)=>Z!=="")}function WO($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function j6($,Z,Y){let{children:X,ref:J,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:BO(X),key:Y??Q??void 0,ref:J??void 0}}function jO($){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 NG($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(NG).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function ZS($){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=_O[Y]||Y;if(J==="class"||J==="className"){let Q=NG(X);if(Q)Z.push(` class="${wG(Q)}"`);continue}if(J==="style"){let Q=typeof X==="string"?X:jO(X);if(Q)Z.push(` style="${wG(Q)}"`);continue}if(UO.has(J)){if(X)Z.push(` ${J}`);continue}if(X!=null&&X!==!1)Z.push(` ${J}="${wG(String(X))}"`)}return Z.join("")}function z6($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $S($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(z6).join("");if($.type===q6)return $.children.map(z6).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return z6(Q)}let Z=$.type,Y=ZS($.props),X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)return`<${Z}${Y}>${X}</${Z}>`;if(ek.has(Z))return`<${Z}${Y}>`;let J=$.children.map(z6).join("");return`<${Z}${Y}>${J}</${Z}>`}function HO($){return new ReadableStream({start(Z){Z.enqueue(z6($)),Z.close()}})}function YS($,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=_O[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=NG(X);if(Q)$.setAttribute("class",Q);continue}if(J==="style"){let Q=typeof X==="string"?X:jO(X);if(Q)$.setAttribute("style",Q);continue}if(UO.has(J)){if(X)$.setAttribute(J,"");continue}if(X!=null&&X!==!1)$.setAttribute(J,String(X))}}function g$($,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 $)g$(J,Z);return}if($.type===q6){for(let J of $.children)g$(J,Z);return}if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});g$(J,Z);return}let Y=document.createElement($.type);YS(Y,$.props);let X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)Y.innerHTML=X;else for(let J of $.children)g$(J,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function OO($){if($.when)return j6(q6,{children:$.children});return $.fallback??null}function LO($){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 j6(q6,{children:X})}function FO($){return j6(q6,{children:$.children})}function VO($,Z,...Y){let{key:X,ref:J,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:BO(Y.length===1?Y[0]:Y),key:X??void 0,ref:J??void 0}}var q6,ek,UO,_O,zO,qO;var AO=D(()=>{q6=Symbol.for("stx.Fragment"),ek=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),UO=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"]),_O={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"};zO=j6,qO=j6});function RG($,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 X8(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 wO($){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 NO=D(()=>{AG()});import{dirname as XS,resolve as RO}from"path";function JS($){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===`
14761
+ `}var a1=null,Y8;var AG=D(()=>{Y8=new Map});function $S($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function wG($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function BO($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[WO($)];return $.flat(1/0).map(WO).filter((Z)=>Z!=="")}function WO($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function j4($,Z,Y){let{children:X,ref:J,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:BO(X),key:Y??Q??void 0,ref:J??void 0}}function jO($){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 NG($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(NG).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function ZS($){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=_O[Y]||Y;if(J==="class"||J==="className"){let Q=NG(X);if(Q)Z.push(` class="${wG(Q)}"`);continue}if(J==="style"){let Q=typeof X==="string"?X:jO(X);if(Q)Z.push(` style="${wG(Q)}"`);continue}if(UO.has(J)){if(X)Z.push(` ${J}`);continue}if(X!=null&&X!==!1)Z.push(` ${J}="${wG(String(X))}"`)}return Z.join("")}function z4($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $S($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(z4).join("");if($.type===q4)return $.children.map(z4).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return z4(Q)}let Z=$.type,Y=ZS($.props),X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)return`<${Z}${Y}>${X}</${Z}>`;if(ek.has(Z))return`<${Z}${Y}>`;let J=$.children.map(z4).join("");return`<${Z}${Y}>${J}</${Z}>`}function HO($){return new ReadableStream({start(Z){Z.enqueue(z4($)),Z.close()}})}function YS($,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=_O[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=NG(X);if(Q)$.setAttribute("class",Q);continue}if(J==="style"){let Q=typeof X==="string"?X:jO(X);if(Q)$.setAttribute("style",Q);continue}if(UO.has(J)){if(X)$.setAttribute(J,"");continue}if(X!=null&&X!==!1)$.setAttribute(J,String(X))}}function g$($,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 $)g$(J,Z);return}if($.type===q4){for(let J of $.children)g$(J,Z);return}if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});g$(J,Z);return}let Y=document.createElement($.type);YS(Y,$.props);let X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)Y.innerHTML=X;else for(let J of $.children)g$(J,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function OO($){if($.when)return j4(q4,{children:$.children});return $.fallback??null}function LO($){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 j4(q4,{children:X})}function FO($){return j4(q4,{children:$.children})}function VO($,Z,...Y){let{key:X,ref:J,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:BO(Y.length===1?Y[0]:Y),key:X??void 0,ref:J??void 0}}var q4,ek,UO,_O,zO,qO;var AO=D(()=>{q4=Symbol.for("stx.Fragment"),ek=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),UO=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"]),_O={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"};zO=j4,qO=j4});function RG($,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 X8(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 wO($){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 NO=D(()=>{AG()});import{dirname as XS,resolve as RO}from"path";function JS($){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===`
14762
14762
  `||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 O=U.indexOf("<script",H),F=U.indexOf("</script>",H);if(F===-1)break;if(O!==-1&&O<F)j++,H=O+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 QS($,Z){return`<!DOCTYPE html>
14763
14763
  <html lang="en">
14764
14764
  <head>
@@ -14771,10 +14771,10 @@ ${$}
14771
14771
  </body>
14772
14772
  </html>`}async function GS($,Z={}){let Y=RO($),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=RO(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 J8(J,Y,{...U,injectCSS:!1}),B=await G.text(),z={...Z.context||{},content:_},q={...U,context:z,injectCSS:W};return J8(B,Q,q)}return J8(J,Y,Z)}async function KS($,Z={},Y){return J8($,process.cwd(),{context:Z,...Y})}async function J8($,Z,Y={}){let{templateContent:X,serverScripts:J,clientScripts:Q}=JS($),G={...K1,...Y.options},K={__filename:Z,__dirname:XS(Z),__stx:{},__stx_options:G,__stx_sfc_mode:!0,__stx_inject_css:Y.injectCSS!==!1,...Y.context||{}};for(let _ of J)await A0(_,K,Z);let W=new Set,U=X;if(U=await G0(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+=`
14773
14773
  ${Q.join(`
14774
- `)}`}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 s4(H[1],{eventBindings:_,templateContent:U})}))).join(`
14774
+ `)}`}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 s6(H[1],{eventBindings:_,templateContent:U})}))).join(`
14775
14775
  `);if(U.match(/(<\/body>)/i))U=U.replace(/(<\/body>)/i,`${z}
14776
14776
  $1`);else U+=`
14777
- ${z}`}U=await D4(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=QS(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:_}=await Promise.resolve().then(() => (P1(),T9));U=await _(U)}catch{}return U}var MO=D(()=>{m0();R4();G1();r$()});function g7($,Z,Y={},X="/"){let J=Z.seo??{},Q=Y.title??J.title??Z.name,G=Y.description??J.description??Z.description??"",K=Y.image??J.image,W=`${Z.url.replace(/\/$/,"")}${X}`,U=J.siteName??Z.name,_=J.type??"website",B=J.locale??"en_US",z=[];if(J.favicon){let H=J.favicon.toLowerCase().split(".").pop(),O=H==="svg"?"image/svg+xml":H==="ico"?"image/x-icon":H==="png"?"image/png":H==="jpg"||H==="jpeg"?"image/jpeg":"";z.push(`<link rel="icon"${O?` type="${O}"`:""} href="${Y1(J.favicon)}">`)}if(z.push(`<link rel="canonical" href="${Y1(W)}">`,`<meta name="description" content="${Y1(G)}">`,`<meta property="og:title" content="${Y1(Q)}">`,`<meta property="og:description" content="${Y1(G)}">`,`<meta property="og:type" content="${Y1(_)}">`,`<meta property="og:url" content="${Y1(W)}">`,`<meta property="og:site_name" content="${Y1(U)}">`,`<meta property="og:locale" content="${Y1(B)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${Y1(Q)}">`,`<meta name="twitter:description" content="${Y1(G)}">`),K)z.push(`<meta property="og:image" content="${Y1(K)}">`),z.push(`<meta name="twitter:image" content="${Y1(K)}">`);if(J.twitter)z.push(`<meta name="twitter:site" content="@${Y1(J.twitter.replace(/^@/,""))}">`),z.push(`<meta name="twitter:creator" content="@${Y1(J.twitter.replace(/^@/,""))}">`);let q=`<!-- SEO -->
14777
+ ${z}`}U=await D6(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=QS(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:_}=await Promise.resolve().then(() => (P1(),T9));U=await _(U)}catch{}return U}var MO=D(()=>{m0();R6();G1();r$()});function g7($,Z,Y={},X="/"){let J=Z.seo??{},Q=Y.title??J.title??Z.name,G=Y.description??J.description??Z.description??"",K=Y.image??J.image,W=`${Z.url.replace(/\/$/,"")}${X}`,U=J.siteName??Z.name,_=J.type??"website",B=J.locale??"en_US",z=[];if(J.favicon){let H=J.favicon.toLowerCase().split(".").pop(),O=H==="svg"?"image/svg+xml":H==="ico"?"image/x-icon":H==="png"?"image/png":H==="jpg"||H==="jpeg"?"image/jpeg":"";z.push(`<link rel="icon"${O?` type="${O}"`:""} href="${Y1(J.favicon)}">`)}if(z.push(`<link rel="canonical" href="${Y1(W)}">`,`<meta name="description" content="${Y1(G)}">`,`<meta property="og:title" content="${Y1(Q)}">`,`<meta property="og:description" content="${Y1(G)}">`,`<meta property="og:type" content="${Y1(_)}">`,`<meta property="og:url" content="${Y1(W)}">`,`<meta property="og:site_name" content="${Y1(U)}">`,`<meta property="og:locale" content="${Y1(B)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${Y1(Q)}">`,`<meta name="twitter:description" content="${Y1(G)}">`),K)z.push(`<meta property="og:image" content="${Y1(K)}">`),z.push(`<meta name="twitter:image" content="${Y1(K)}">`);if(J.twitter)z.push(`<meta name="twitter:site" content="@${Y1(J.twitter.replace(/^@/,""))}">`),z.push(`<meta name="twitter:creator" content="@${Y1(J.twitter.replace(/^@/,""))}">`);let q=`<!-- SEO -->
14778
14778
  ${z.join(`
14779
14779
  `)}
14780
14780
  <!-- /SEO -->`,j=/<!--\s*stx SEO Tags\s*-->[\s\S]*?<meta\s+name="twitter:description"[^>]*>\s*/i;if(j.test($))$=$.replace(j,"");if($=$.replace(/<!--\s*SEO\s*-->[\s\S]*?<!--\s*\/SEO\s*-->\s*/g,""),$=$.replace(/<meta\s+name="title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+property="og:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,"").replace(/<meta\s+property="og:type"\s+content="website"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:card"\s+content="summary_large_image"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:title"\s+content="stx Project"[^>]*>\s*/g,"").replace(/<meta\s+name="twitter:description"\s+content="A website built with stx[^"]*"[^>]*>\s*/g,""),/<head[^>]*>/i.test($))return $.replace(/<head([^>]*)>/i,`<head$1>
@@ -14787,15 +14787,17 @@ ${$}`}function Y1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").repla
14787
14787
  `;let Y=$.sitemap!==!1?`Sitemap: ${$.url.replace(/\/$/,"")}/sitemap.xml
14788
14788
  `:"";if(Z==="disallow")return["User-agent: *","Disallow: /","",Y].filter(Boolean).join(`
14789
14789
  `);return["User-agent: *","Allow: /","",Y].filter(Boolean).join(`
14790
- `)}async function US(){if(f$!==null)return f$;try{let $=await import("stx-router");if(typeof $.getRouterScript==="function")f$=$.getRouterScript();else f$=""}catch{f$=""}return f$}async function d7($,Z){let Y=await US();if(!Y)return $;let J=`${Z?`<script>window.__stxRouterConfig=${JSON.stringify(Z)};</script>
14791
- `:""}<script>${Y}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${J}
14790
+ `)}async function US(){if(f$!==null)return f$;try{let $=await import("stx-router");if(typeof $.getRouterScript==="function")f$=$.getRouterScript();else f$=""}catch{f$=""}return f$}async function d7($,Z){let Y=await US();if(!Y)return $;let X={interceptAllLinks:!0,container:"body",...Z},Q=`${`<script>window.__stxRouterConfig=${JSON.stringify(X)};</script>
14791
+ `}<script>${Y}</script>`;if(/<\/body>/i.test($))return $.replace(/<\/body>/i,`${Q}
14792
14792
  </body>`);return`${$}
14793
- ${J}`}var f$=null;function u7($,Z){if(Z.theme===!1)return $;let Y=typeof Z.theme==="object"&&Z.theme!==null?Z.theme:{},X=Y.default??"dark",J=Y.storageKey??"theme";if(X==="dark"){if(!/<html\b[^>]*\bclass=/.test($))$=$.replace(/<html\b([^>]*)>/i,'<html$1 class="dark">');else if(!/<html\b[^>]*\bclass="[^"]*\bdark\b/.test($))$=$.replace(/<html\b([^>]*\bclass=")([^"]*)(")/i,"<html$1$2 dark$3")}if(!$.includes("__stxThemeGuard")&&/<head\b[^>]*>/i.test($)){let Q=`<script data-stx-theme-guard="1">${_S(X,J)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
14794
- ${Q}`)}if(!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let Q=`<script data-stx-theme-toggle="1">${BS(J)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${Q}
14795
- </body>`)}return $}var _S=($,Z)=>`(function(){try{var k=${JSON.stringify(Z)};var t=localStorage.getItem(k);var html=document.documentElement;var isDark=t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark';html.classList[isDark?'add':'remove']('dark')}catch(e){}})();`,BS=($)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}});`;var{Glob:zS}=globalThis.Bun;import{cpSync as qS,existsSync as G8,mkdirSync as jS,readFileSync as EO,readdirSync as HS,rmSync as OS,statSync as LS,unlinkSync as FS,writeFileSync as Q8}from"fs";import{join as l4,relative as VS}from"path";import AS from"process";import wS from"bun-plugin-stx";async function MG($){let Z=Date.now(),Y=$.pagesDir??"pages",X=$.outDir??"dist",J=$.publicDir??"public";if(!$.noClean)OS(X,{recursive:!0,force:!0});jS(X,{recursive:!0});let Q=new zS(`${Y}/**/*.stx`),G=await Array.fromAsync(Q.scan("."));if(G.length===0)throw Error(`No .stx files found in ${Y}/`);let K=await Bun.build({entrypoints:G,outdir:X,plugins:[wS()],naming:{entry:"[name].[ext]"}});if(!K.success)throw console.error(K.logs),Error("Build failed");NS(X);let W=EG(X).filter((z)=>z.endsWith(".html"));for(let z of W){let q=l4(X,z),j=EO(q,"utf8");if(j=RS(j),j=await E0(j,AS.cwd()),j=g7(j,$,$.pages?.[m7(z)],m7(z)),j=u7(j,$),$.spa!==!1)j=await d7(j,$.router);Q8(q,j)}if(G8(J))qS(J,X,{recursive:!0});let U=l4(X,"404.html");if(!G8(U)&&G8(l4(X,"index.html"))){let z=EO(l4(X,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${MS($.name)}</title>`);Q8(U,z)}if($.sitemap!==!1){let z=W.filter((q)=>q!=="404.html").map((q)=>({path:m7(q),page:$.pages?.[m7(q)]}));Q8(l4(X,"sitemap.xml"),f7($,z))}let _=h7($);if(_!==null)Q8(l4(X,"robots.txt"),_);let B=W.map(m7);return{outDir:X,pages:B,durationMs:Date.now()-Z}}function m7($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function EG($,Z=$){let Y=[];if(!G8($))return Y;for(let X of HS($,{withFileTypes:!0})){let J=l4($,X.name);if(X.isDirectory())Y.push(...EG(J,Z));else Y.push(VS(Z,J))}return Y}function NS($){for(let Z of EG($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(Z))continue;let Y=l4($,Z);try{if(LS(Y).size===0)FS(Y)}catch{}}}function RS($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function MS($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function TG($){return $}var TO=D(()=>{P1()});var IO=D(()=>{TO()});function DO($,Z){return $.kind===Z}var kO=()=>{};var SO=D(()=>{kO()});var K6={};e(K6,{writeNetlifyConfig:()=>Z7,writeManifest:()=>yJ,writeImageManifest:()=>LJ,wrapComponentForHMR:()=>wk,webComponentDirectiveHandler:()=>sX,watermark:()=>hQ,watchViews:()=>pk,watchMultiple:()=>sE,watchEffect:()=>oE,watch:()=>aE,waitForStore:()=>FT,waitForLocale:()=>aA,videoDirective:()=>i5,validators:()=>x9,validateValueEnhanced:()=>rW,validateTemplate:()=>dB,validateParams:()=>cQ,validateFormEnhanced:()=>hA,validateFile:()=>e3,validateFields:()=>gA,validateField:()=>iW,validateDirective:()=>mB,validateCspDirectives:()=>AA,validateConfig:()=>nz,validateComponentScripts:()=>WI,validateComponentProps:()=>zI,validateClientScript:()=>k5,usesSignalsInScript:()=>e$,useVirtualList:()=>RY,useTitle:()=>vW,useStoreOrThrow:()=>LT,useStore:()=>IH,useSlots:()=>JO,useSeoMeta:()=>B5,useRouteParams:()=>Vq,useRouteParamOrThrow:()=>VT,useRouteParam:()=>Aq,usePageTitle:()=>vW,useMiddlewareValue:()=>AT,useMiddlewareState:()=>wq,useLoadingIndicator:()=>BH,useHead:()=>A4,useAttrs:()=>QO,uploadFiles:()=>jG,uploadFile:()=>$8,updateInstance:()=>QT,untrack:()=>w2,unregisterDirective:()=>dR,unmountInstance:()=>GT,unescapeHtml:()=>N9,transpileTypeScript:()=>q4,transitionDirective:()=>q9,toUsers:()=>_j,toUser:()=>Uj,thumbnail:()=>NQ,thumbHashToRGBA:()=>P7,thumbHashToDataURL:()=>UG,templateCache:()=>rZ,stxClientHelpers:()=>qQ,structuredDataDirective:()=>U2,stripDocumentWrapper:()=>G6,stringToStream:()=>II,strictCspPreset:()=>MW,streamingSuspenseDirective:()=>JH,streamToResponse:()=>Qk,streamTemplateSimple:()=>Zk,streamTemplate:()=>$k,stopHmrServer:()=>V$,stopBroadcasting:()=>Kj,state:()=>H2,startProductionServer:()=>ij,startInteractive:()=>dj,startBroadcasting:()=>Gj,staggerDirective:()=>WK,srcsetUrls:()=>uQ,springDirective:()=>UK,splitByPipe:()=>v9,smartBatchSign:()=>iQ,signUrl:()=>p3,shouldTranspileTypeScript:()=>z4,shouldReloadOnChange:()=>a5,shouldRefreshSignature:()=>a3,shouldIgnoreFile:()=>s5,shouldCacheComponent:()=>KB,sharpen:()=>TQ,setRouteParams:()=>MT,setMiddlewareState:()=>ET,setGlobalProvide:()=>X8,setErrorLocale:()=>rK,setCurrentInstance:()=>lE,setCachedVideoResult:()=>K$,setCachedImageResult:()=>J$,setCached:()=>$$,serveStxFile:()=>c7,serveMultipleStxFiles:()=>l7,serveMarkdownFile:()=>H3,serveFile:()=>sD,serveApp:()=>p7,serve:()=>ZH,serializeState:()=>HH,sepia:()=>DQ,scrollAnimateDirective:()=>j9,screenReaderDirective:()=>z9,scopeHTML:()=>uz,scopeCSS:()=>dz,scanForSitemapEntries:()=>hw,scanA11yIssues:()=>N8,saturation:()=>CQ,sanitizeParams:()=>lQ,sanitizeFilePath:()=>_W,sanitizeExpression:()=>BW,sanitizeDirectiveParams:()=>zW,sanitizeDirectiveParam:()=>W5,sanitizeComponentProps:()=>XZ,safeExecuteAsync:()=>y1,safeExecute:()=>KW,runPreProcessingMiddleware:()=>PZ,runPostProcessingMiddleware:()=>yZ,runMiddleware:()=>B7,runHooks:()=>Q6,rotate:()=>PQ,resolveTemplatePath:()=>C5,resize:()=>AQ,resetPlaceholders:()=>P8,resetHead:()=>yW,resetHMRHandler:()=>Rk,resetErrorConfig:()=>YW,replacePlaceholders:()=>w9,renderView:()=>VG,renderVideoComponent:()=>z$,renderToString:()=>z6,renderToStream:()=>HO,renderToDOM:()=>g$,renderThumbhashToCanvas:()=>WG,renderTemplate:()=>GS,renderString:()=>KS,renderSlot:()=>nY,renderSSRSuspense:()=>p_,renderProtectedVideo:()=>tQ,renderProtectedImg:()=>oQ,renderMediaUpload:()=>pQ,renderImgComponent:()=>y4,renderImageComponent:()=>BJ,renderHtmlAttrs:()=>fW,renderHead:()=>gW,renderEmail:()=>ik,renderComponentWithSlot:()=>v1,renderBodyAttrs:()=>hW,render:()=>Dk,relaxedCspPreset:()=>EW,registerValidationRule:()=>vA,registerStreamingDirectives:()=>Xk,registerStore:()=>NT,registerSeoDirectives:()=>gw,registerMiddleware:()=>OT,registerFilters:()=>EK,registerFilter:()=>x8,registerErrorMessages:()=>sK,registerEnhancedValidationRule:()=>fA,registerDirective:()=>eB,registerCspDirectives:()=>VA,registerComponentDirectives:()=>HI,registerAnimationDirectives:()=>eF,registerA11yDirectives:()=>hF,ref:()=>nE,redirect:()=>xI,readMarkdownFile:()=>$4,readFileCached:()=>vU,reactive:()=>Oq,quality:()=>gQ,pruneSignatureCache:()=>aQ,pruneCache:()=>Uz,provide:()=>oH,processVueTemplate:()=>uZ,processVirtualListDirectives:()=>v2,processVirtualGridDirectives:()=>EY,processVideo:()=>J3,processValidateDirective:()=>nW,processTranslateDirective:()=>MZ,processTransitionDirectives:()=>v_,processTransitionAttributes:()=>h_,processTitleDirective:()=>mW,processTemplateBindings:()=>p8,processTeleportDirectives:()=>D_,processSuspenseDirectives:()=>c_,processStructuredData:()=>gZ,processStaticDirectives:()=>fY,processStackReplacements:()=>K2,processStackPushDirectives:()=>G2,processSlots:()=>rY,processShell:()=>P3,processServerBindings:()=>B2,processSeoDirective:()=>fZ,processSectionDirectives:()=>Jk,processScopedStyles:()=>L5,processReactiveBindings:()=>vK,processProtectedMedia:()=>eQ,processPartialHydrationDirectives:()=>bY,processOnceDirective:()=>D5,processMiddleware:()=>CZ,processMetaDirectives:()=>vZ,processMetaDirective:()=>cW,processMarkdownFileDirectives:()=>pY,processMarkdownDirectives:()=>lY,processLoops:()=>X2,processKeepAliveDirectives:()=>QB,processJsonDirective:()=>I5,processInfiniteListDirectives:()=>MY,processIncludes:()=>Q2,processImgComponents:()=>bX,processImageComponents:()=>zJ,processImage:()=>l1,processHeadDirective:()=>uW,processForms:()=>xA,processFormInputDirectives:()=>r9,processExpressions:()=>w1,processEventDirectives:()=>s8,processErrorDirective:()=>a9,processDynamicComponents:()=>cZ,processDirectives:()=>G0,processDirectiveAttributes:()=>pR,processDeferDirectives:()=>E_,processCustomDirectives:()=>LZ,processCspDirectives:()=>jZ,processClientScript:()=>s4,processBasicFormDirectives:()=>P6,processAsyncDirectives:()=>t_,processAnimationDirectives:()=>M8,processA11yDirectives:()=>w8,preloadTranslationsBackground:()=>nA,preloadTranslations:()=>tW,preloadIslandHandlers:()=>jk,poolStrings:()=>Zj,pluginManager:()=>eX,performLeave:()=>x_,performEnter:()=>y_,peek:()=>N2,partialsCache:()=>M4,parseVideoDirectiveOptions:()=>xz,parseUrl:()=>VQ,parseThumbhashString:()=>_G,parseSwitchBlock:()=>f9,parseSlots:()=>iY,parseSlotElement:()=>iB,parseScriptDeclarations:()=>wW,parseSFCComponent:()=>mz,parseProtectedArgs:()=>$G,parseImgComponent:()=>o2,parseImageUrl:()=>XX,parseImageComponent:()=>R3,parseExpressionWithFilters:()=>VW,parseCookies:()=>CI,parseConditionalBlock:()=>QZ,parseArguments:()=>GZ,parseAnimationShorthand:()=>oF,optimizeTemplate:()=>Yj,optimizeImage:()=>D3,optimizeDirectory:()=>OJ,onceStore:()=>SZ,onUpdated:()=>ZT,onUnmounted:()=>XT,onServer:()=>IT,onMounted:()=>eE,onMount:()=>V2,onHydrated:()=>gY,onErrorCaptured:()=>YO,onDestroy:()=>A2,onDeactivated:()=>BB,onClient:()=>TT,onBeforeUpdate:()=>$T,onBeforeUnmount:()=>YT,onBeforeMount:()=>tE,onActivated:()=>_B,observeElement:()=>QG,notFound:()=>vI,nextTick:()=>ZO,navigateTo:()=>HT,mountInstance:()=>JT,motionDirective:()=>O9,moderateCspPreset:()=>u9,minifyHtml:()=>$j,metaDirective:()=>W2,mergeParams:()=>c3,mergeCspDirectives:()=>LA,matchRoute:()=>y3,markdownDirectiveHandler:()=>oY,markdownCache:()=>U3,loadTranslationLazy:()=>j5,loadTranslation:()=>ZU,loadStxConfig:()=>f0,loadMiddlewareFromDirectory:()=>_7,loadManifest:()=>xJ,loadElement:()=>W4,loadChannels:()=>Wj,lazyLoadAll:()=>XG,lazyLoad:()=>YG,keyframeDirective:()=>KK,jsxs:()=>zO,jsxDEV:()=>qO,jsx:()=>j6,jsonResponse:()=>yI,islandDirective:()=>QH,isTest:()=>XA,isSpaNavigation:()=>RJ,isSignatureValid:()=>n3,isSignal:()=>A5,isSharpAvailable:()=>c1,isServerEnvironment:()=>LI,isServer:()=>Nq,isProduction:()=>eK,isNativeLazySupported:()=>s3,isLoading:()=>pA,isLoaded:()=>iA,isJavaScriptScript:()=>oB,isIntersectionObserverSupported:()=>o3,isImageFile:()=>J7,isICUFormat:()=>JU,isHydrated:()=>vY,isEdgeEnvironment:()=>OI,isDirectiveKind:()=>DO,isDevelopment:()=>H4,isDerived:()=>w5,isCssOnlyChange:()=>r5,isClient:()=>Rq,isAsyncComponent:()=>$B,invert:()=>kQ,invalidateFileCacheByDir:()=>fU,invalidateFileCache:()=>gU,interpolateScriptsInTemplate:()=>IK,interpolateScriptExpressions:()=>g8,inlineError:()=>K0,injectThemeBootstrap:()=>u7,injectSeoTags:()=>hZ,injectSeo:()=>g7,injectRouterScript:()=>d7,injectHotReload:()=>u1,injectHeatmap:()=>I8,injectCspMetaTag:()=>qZ,injectCrosswindCSS:()=>E0,injectAnalytics:()=>r8,inject:()=>tH,initStoreRegistry:()=>wT,initNetlify:()=>Yq,initLoadingIndicator:()=>Fk,initLazyLoading:()=>ZG,initFile:()=>sJ,initBlurUp:()=>t3,initAllBlurUp:()=>zG,imgDirective:()=>l5,imageDirective:()=>jJ,hydrateTemplate:()=>$Q,hydrateIslands:()=>qk,hydrateIsland:()=>PY,hydrateFragment:()=>QD,hydrateByStrategy:()=>yY,hydrateAll:()=>xY,hydrate:()=>Tk,htmlResponse:()=>aD,heatmapDirective:()=>D8,hashString:()=>l2,hashFilePath:()=>g6,hashFile:()=>l0,hashBuffer:()=>Xz,hasVueTemplateSyntax:()=>SU,hasVariables:()=>DZ,hasStore:()=>EH,hasPlaceholders:()=>w6,hasNetlifyConfig:()=>Y7,hasMiddleware:()=>jT,hasEventDirectives:()=>iV,hasDocumentShell:()=>xU,hasDirectives:()=>cB,hasDOMSupport:()=>ZK,handleError:()=>XO,h:()=>VO,groupVariantsByFormat:()=>E$,grayscale:()=>IQ,gitHash:()=>XQ,getUnusedDirectives:()=>aq,getTranslationSync:()=>eW,getTranslationCacheStats:()=>mA,getTranslationAsync:()=>rA,getTranslation:()=>s9,getTotalSize:()=>Z4,getTimeUntilExpiry:()=>r3,getStoreNames:()=>TH,getStore:()=>LQ,getSourceLineInfo:()=>sY,getScreenReaderOnlyStyle:()=>xF,getScopeAttribute:()=>ZE,getRouteParams:()=>gT,getPublicEnvDefine:()=>H1,getPublicEnv:()=>LK,getPositionInfo:()=>uB,getPlaceholderRegistry:()=>y8,getPlaceholderCacheStats:()=>LX,getPageMeta:()=>l9,getNonce:()=>F4,getMimeType:()=>p1,getMiddlewareNames:()=>U7,getMiddleware:()=>qT,getLoadingState:()=>lA,getLoadingLocales:()=>sA,getImageMetadata:()=>X7,getHydrationRuntime:()=>VH,getHydratedStoreState:()=>RT,getHmrServer:()=>o5,getHead:()=>C6,getHMRHandler:()=>Nk,getFormatExtension:()=>KX,getFileMtime:()=>u5,getFallbackVariant:()=>M$,getErrorMessage:()=>e8,getErrorLocale:()=>aK,getErrorConfig:()=>Q5,getErrorCodeName:()=>k9,getDirectives:()=>hR,getDirective:()=>fR,getCurrentInstance:()=>pE,getCspPreset:()=>OA,getCspHeaderName:()=>kW,getComponentCacheStats:()=>gR,getCachedVideoResult:()=>G$,getCachedSignature:()=>nQ,getCachedSignalsRuntime:()=>hU,getCachedRouterScript:()=>dU,getCachedPlaceholder:()=>d5,getCachedImageResult:()=>X$,getCached:()=>e6,getCacheStats:()=>Wz,getBroadcastServer:()=>Qj,getBestVariant:()=>GX,getAllFilters:()=>v8,generateWidthSrcset:()=>b4,generateVirtualListCSS:()=>NY,generateVideoPreview:()=>OG,generateValidationScript:()=>dA,generateUploadRuntime:()=>v7,generateTreeShakenBundle:()=>sq,generateTransitionRuntime:()=>f_,generateTransitionCSS:()=>g_,generateThumbnails:()=>U$,generateThumbhashPlaceholder:()=>_X,generateTemplatesDocs:()=>Rj,generateSuspenseRuntime:()=>n_,generateSuspenseCSS:()=>i_,generateStateScript:()=>LH,generateSrcsetData:()=>JX,generateSrcset:()=>r2,generateSrcSet:()=>J6,generateSpriteSheet:()=>Y3,generateSpaShell:()=>tk,generateSourceTags:()=>QX,generateSizesFromBreakpoints:()=>ZX,generateSizesAttribute:()=>r6,generateSizes:()=>R$,generateSitemapIndex:()=>fw,generateSitemap:()=>f7,generateSimpleMediaPicker:()=>hH,generateSignatureRuntime:()=>b7,generateSignalsRuntimeDev:()=>e4,generateSignalsRuntime:()=>N5,generateScopeId:()=>G3,generateSFCWebComponent:()=>cz,generateRouteTypes:()=>hT,generateRouteManifest:()=>fT,generateRobotsTxt:()=>EU,generateRobots:()=>h7,generateResponsiveVariants:()=>n2,generateReactiveWebComponentTS:()=>JE,generateReactiveWebComponent:()=>XE,generateReactiveRuntime:()=>GE,generateReactiveMixin:()=>QE,generatePoster:()=>W$,generatePlaceholderStyle:()=>HX,generatePlaceholderCSS:()=>h5,generatePlaceholder:()=>f5,generatePartialHydrationCSS:()=>CY,generateNonce:()=>BZ,generateNetlifyToml:()=>L3,generateMinifiedMediaRuntime:()=>pH,generateMediaRuntime:()=>FG,generateMediaManagerEmbed:()=>fH,generateManifest:()=>PJ,generateLoadingIndicatorHtml:()=>Vk,generateLazyLoadRuntime:()=>C7,generateLQIP:()=>zX,generateKeepAliveRuntime:()=>UB,generateKeepAliveCSS:()=>WB,generateIslandManifest:()=>hY,generateImagePreview:()=>HG,generateImageManifest:()=>k3,generateHydrationScript:()=>Ek,generateHydrationRuntime:()=>Gk,generateHydrationCSS:()=>Ik,generateHydrationBootstrap:()=>IY,generateHotReloadScript:()=>$q,generateHeatmapScript:()=>T8,generateHMRClientScript:()=>Ak,generateHLSManifest:()=>_$,generateEventBindings:()=>Mk,generateDprSrcsetWithVariableQuality:()=>$X,generateDprSrcset:()=>n6,generateDocumentShell:()=>yU,generateDocs:()=>Dj,generateDirectivesDocs:()=>Mj,generateDirectiveRuntime:()=>lR,generateDefaultRobotsTxt:()=>dw,generateDASHManifest:()=>B$,generateCspMetaTag:()=>m9,generateCspHeader:()=>zZ,generateCrosswindCSS:()=>E9,generateCompositionRuntime:()=>KO,generateComponentsDocs:()=>Nj,generateComponentManifest:()=>YR,generateComponentDoc:()=>wj,generateColorPlaceholder:()=>jX,generateClientRuntime:()=>KT,generateCacheKey:()=>o6,generateBlurUpRuntime:()=>y7,generateBlurUpCSS:()=>x7,generateBindingsRuntime:()=>gK,generateAutoWidthSrcset:()=>eY,generateAsyncComponentRuntime:()=>YB,generateAsyncComponentCSS:()=>ZB,generateAnimationRuntime:()=>tF,generateAnimationCSS:()=>sF,generateAnalyticsScript:()=>n8,formatTypeErrors:()=>zk,formatStxContent:()=>h3,formatSize:()=>f4,formatRoutes:()=>EJ,formatMarkdownContent:()=>nJ,formatLocalizedError:()=>tK,formatICU:()=>YU,formatFilePath:()=>G5,formatError:()=>C9,formatDocsAsMarkdown:()=>Ej,formatDocsAsJson:()=>Ij,formatDocsAsHtml:()=>Tj,format:()=>vQ,foldConstants:()=>eq,flipVertical:()=>xQ,flipHorizontal:()=>yQ,fingerprint:()=>TJ,findMatchingEndTag:()=>L4,findMatchingDelimiter:()=>v0,findIfBlocks:()=>g9,findExpressions:()=>FW,findErrorPage:()=>MJ,findDirectiveBlocks:()=>_5,findDeadCode:()=>oq,findDeadBranches:()=>oq,findComponentFiles:()=>cJ,findCommonDir:()=>IG,filterRequiredFiles:()=>$7,fileExists:()=>X0,extractVariables:()=>A0,extractState:()=>FH,extractSlotContent:()=>rB,extractScriptFromTemplate:()=>IZ,extractPlaceholders:()=>NV,extractParenthesizedExpression:()=>o1,extractDominantColor:()=>qX,extractDirectiveParams:()=>AW,extractDirectiveNames:()=>lB,extractContainerContent:()=>j7,extractComponentProps:()=>Vj,extractComponentName:()=>DY,extractComponentDescription:()=>Aj,extractClassNames:()=>M9,extractBoundProps:()=>kY,extractBalancedExpression:()=>JZ,extractAndScopeStyles:()=>YE,extractAndProcessEvents:()=>cK,evaluateExpression:()=>_1,evaluateConstant:()=>g3,evaluateAuthExpression:()=>s1,escapeHtml:()=>D0,errorRecovery:()=>P9,errorLogger:()=>a0,ensureTeleportTargets:()=>k_,ensureDocumentShell:()=>F5,enhancedValidationRules:()=>AZ,eliminateDeadCode:()=>tq,effect:()=>L2,dprUrls:()=>mQ,docsCommand:()=>lJ,disconnectObserver:()=>GG,devHelpers:()=>S6,detectShell:()=>NJ,detectRuntime:()=>b$,detectProjectConfig:()=>w$,detectFormat:()=>WX,detectBuildMode:()=>KI,derived:()=>O2,deploy:()=>Zq,defineStxConfig:()=>iz,defineStore:()=>DH,defineSiteConfig:()=>TG,definePlugin:()=>j$,definePageMeta:()=>xW,defineMiddleware:()=>zT,defineExpose:()=>$O,defineEmits:()=>eH,defineDirective:()=>b0,defineCustomElement:()=>wO,defineConfig:()=>JD,defineClientDirective:()=>uR,defineAsyncComponent:()=>e_,defaultMediaConfig:()=>lk,defaultImageConfig:()=>zq,defaultI18nConfig:()=>o9,defaultHeatmapConfig:()=>qK,defaultFormClasses:()=>n9,defaultFilters:()=>N6,defaultCspConfig:()=>NA,defaultConfig:()=>K1,default:()=>ES,decodeThumbhash:()=>BX,cspNonceDirective:()=>DW,cspDirective:()=>IW,crossfadeTransition:()=>BG,crop:()=>wQ,createVirtualList:()=>x2,createVideoDirective:()=>Q3,createVercelHandler:()=>SI,createTypeChecker:()=>WQ,createTranslateFilter:()=>qw,createTextEncoderStream:()=>TI,createStxApp:()=>RG,createStreamingResponse:()=>EI,createStreamRenderer:()=>Yk,createStore:()=>FQ,createStorageManager:()=>BT,createServerCookieManager:()=>_T,createScope:()=>Hq,createSSRSuspense:()=>l_,createRouter:()=>Q4,createRouteLocation:()=>W7,createRoute:()=>tD,createRef:()=>nE,createReactive:()=>Oq,createProvideContext:()=>GO,createProject:()=>_D,createProductionBuild:()=>XD,createPlaceholder:()=>s$,createOptimizedBuild:()=>UI,createNetlifyHandler:()=>bI,createNetlifyClient:()=>t5,createMiddlewareContext:()=>K7,createMiddleware:()=>oD,createLazyObserver:()=>JG,createKeepAliveCache:()=>GB,createKVNamespace:()=>bj,createIslandRegistry:()=>SY,createImgDirective:()=>t2,createImagePlugin:()=>HJ,createImageDirective:()=>T3,createHeatmapAggregator:()=>YV,createFileManifest:()=>e5,createEnvAccessor:()=>Sj,createEnhancedError:()=>GW,createEdgeHandler:()=>V7,createEdgeCache:()=>Cj,createDetailedErrorMessage:()=>L0,createDenoHandler:()=>kI,createDefaultNetlifyConfig:()=>N$,createCspHeaders:()=>wA,createCookie:()=>PI,createComputed:()=>rE,createComponentInstance:()=>iE,createCloudflareHandler:()=>DI,createClientCookieManager:()=>UT,createBuiltinDirectives:()=>cR,createApp:()=>RG,createAnimationTimeline:()=>aF,cover:()=>MQ,convertToCommonJS:()=>t9,contrast:()=>bQ,contain:()=>RQ,consoleError:()=>QW,configureErrorHandling:()=>ZW,config:()=>W1,computed:()=>rE,composeShellWithPage:()=>q7,componentDirective:()=>Lj,compileTemplate:()=>SJ,collectDeployFiles:()=>A$,clearVideoCache:()=>$3,clearTranslationCache:()=>uA,clearSignatureCache:()=>rQ,clearPlaceholderCache:()=>OX,clearOnceStore:()=>Pw,clearNonce:()=>HA,clearMiddleware:()=>G7,clearImageCache:()=>E3,clearErrorMessages:()=>oK,clearDevCaches:()=>uU,clearCustomFilters:()=>TK,clearComponentCache:()=>S4,clearCache:()=>Z$,classifyScript:()=>Tq,classifyAllScripts:()=>VJ,checkTemplateFile:()=>_k,checkTemplate:()=>Bk,checkCache:()=>E2,checkAuthAccess:()=>v$,checkA11y:()=>_9,channel:()=>qj,cancelPendingLoads:()=>oA,calculateSha1:()=>O3,calculateOptimalWidths:()=>u2,cacheTemplate:()=>T2,buildWebComponents:()=>rX,buildViews:()=>aH,buildUrl:()=>w0,buildStaticSite:()=>MG,buildRuntimeAsset:()=>IJ,buildRouterAsset:()=>DJ,buildImageUrl:()=>E1,buildForProduction:()=>dq,buildAuthParams:()=>S7,buildApp:()=>mq,build:()=>YD,broadcastPrivate:()=>Bj,broadcastPresence:()=>zj,broadcast:()=>dJ,brightness:()=>SQ,blur:()=>EQ,batchSignUrls:()=>i3,batch:()=>F2,autoFixA11yFile:()=>XK,autoFixA11yDirectory:()=>fF,autoFixA11y:()=>YK,auto:()=>fQ,assetTags:()=>$I,applyTransformations:()=>c5,applySlots:()=>aB,applyPropDefaults:()=>qI,applyPreset:()=>dQ,applyHead:()=>dW,applyFilters:()=>f8,apiCspPreset:()=>TW,animationGroupDirective:()=>H9,analyzeVideo:()=>p5,analyzeUsage:()=>fJ,analyzeTemplate:()=>Eq,analyzeProject:()=>FJ,analyzeDirectiveUsage:()=>fJ,analyticsDirective:()=>dV,addStore:()=>HD,addPage:()=>jD,addNonceToInlineContent:()=>FA,addLayout:()=>OD,addComponent:()=>qD,abortNavigation:()=>WT,a11yDirective:()=>B9,VideoProcessorCache:()=>Q$,TransitionType:()=>JK,TransitionEase:()=>GK,TransitionDirection:()=>QK,Tokenizer:()=>U5,TemplateTypeChecker:()=>KQ,TEMPLATE_PRESETS:()=>cI,StxValidationError:()=>K5,StxSyntaxError:()=>$Z,StxSecurityError:()=>ZZ,StxRuntimeError:()=>R1,StxFileError:()=>k6,StxError:()=>O4,Show:()=>OO,SPRING_PRESETS:()=>R8,ProductionBuild:()=>d3,Portal:()=>FO,PROJECT_TEMPLATES:()=>UD,PRESETS:()=>l3,MemorySessionStore:()=>NH,MIME_TYPES:()=>v5,MEDIA_DEFAULT_WIDTHS:()=>d1,MEDIA_DEFAULT_FORMATS:()=>e1,ImageProcessorCache:()=>Y$,ImageProcessingError:()=>T$,HydrationRuntime:()=>OQ,HotReloadServer:()=>GJ,HeatmapAggregator:()=>k8,Fragment:()=>q6,For:()=>LO,ErrorLogger:()=>y9,ErrorCodes:()=>Z0,DeployError:()=>X4,DEFAULT_WIDTHS:()=>L1,DEFAULT_TRANSITION_OPTIONS:()=>S1,DEFAULT_QUALITY:()=>V1,DEFAULT_PLACEHOLDER_OPTIONS:()=>c2,DEFAULT_FORMATS:()=>F1,DEFAULT_DPR_VALUES:()=>x5,ComponentHMRHandler:()=>jQ,COMMON_SIZES:()=>YX,BroadcastServer:()=>Hj,Broadcast:()=>jj,BLUR_UP_CSS:()=>s6});var ES;var h4=D(()=>{F3();S3();H0();r4();kH();dZ();AG();AO();NO();$J();P1();IO();Lq();w4();b3();wZ();A6();a8();L9();i6();H7();t8();gJ();kJ();iq();Xj();f3();I2();Fj();m0();HZ();FZ();F3();DG();y5();pJ();Pj();z1();o8();r0();rJ();F9();EZ();y6();oJ();tJ();J2();h2();xZ();h9();x3();o$();G1();lj();vJ();YQ();O7();$H();AJ();_2();YH();z2();bJ();ZQ();GH();WH();oX();TY();dY();UH();zH();i8();r$();jH();AH();RH();S3();rH();sH();R5();mZ();lZ();MO();H0();aY();SO();ES={}});import i7 from"path";var h$;var K8=D(()=>{h4();z1();r0();j4();G1();h$={name:"bun-plugin-stx",async setup($){let Y={...await f0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${i7.relative(i7.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await rX(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 E2(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await y1(()=>Bun.file(G).text(),"",(H)=>{throw new k6(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new k6(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:B}=N1.time("script-extraction",()=>{let H=W,O=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(O)H=O[1].trim();let F=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",V=[];for(let A of F){let N=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))L=N;else V.push(A)}let w=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:w,allScripts:V}}),z={__filename:G,__dirname:i7.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await y1(()=>A0(U,z,G),void 0,(H)=>{let O=new R1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(a0.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await N1.timeAsync("directive-processing",async()=>{return await G0(_,z,G,Y,K)});if(B.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (r0(),$5)),O=H(B.join(`
14793
+ ${Q}`}var f$=null;function u7($,Z){if(Z.theme===!1)return $;let Y=typeof Z.theme==="object"&&Z.theme!==null?Z.theme:{},X=Y.default??"dark",J=Y.storageKey??"theme",Q=Y.colors?.light??"#ffffff",G=Y.colors?.dark??"#000000";if(X==="dark"){if(!/<html\b[^>]*\bclass=/.test($))$=$.replace(/<html\b([^>]*)>/i,'<html$1 class="dark">');else if(!/<html\b[^>]*\bclass="[^"]*\bdark\b/.test($))$=$.replace(/<html\b([^>]*\bclass=")([^"]*)(")/i,"<html$1$2 dark$3")}if(!$.includes("data-stx-theme-meta")&&/<head\b[^>]*>/i.test($)){let W=['<meta name="color-scheme" content="dark light" data-stx-theme-meta="1">',`<meta name="theme-color" content="${X==="dark"?G:Q}" data-stx-theme-meta="1">`,`<meta name="theme-color" media="(prefers-color-scheme: light)" content="${Q}" data-stx-theme-meta="1">`,`<meta name="theme-color" media="(prefers-color-scheme: dark)" content="${G}" data-stx-theme-meta="1">`].join(`
14794
+ `);$=$.replace(/<head\b([^>]*)>/i,`<head$1>
14795
+ ${W}`)}if(!$.includes("__stxThemeGuard")&&/<head\b[^>]*>/i.test($)){let K=`<script data-stx-theme-guard="1">${_S(X,J,Q,G)};window.__stxThemeGuard=1;</script>`;$=$.replace(/<head\b([^>]*)>/i,`<head$1>
14796
+ ${K}`)}if(!$.includes("__stxThemeToggle")&&/<\/body>/i.test($)){let K=`<script data-stx-theme-toggle="1">${BS(J,Q,G)};window.__stxThemeToggle=1;</script>`;$=$.replace(/<\/body>/i,`${K}
14797
+ </body>`)}return $}var _S=($,Z,Y,X)=>`(function(){try{var k=${JSON.stringify(Z)};var t=localStorage.getItem(k);var html=document.documentElement;var isDark=t===null?(${JSON.stringify($)}==='dark'||(${JSON.stringify($)}==='auto'&&window.matchMedia('(prefers-color-scheme: dark)').matches)):t==='dark';html.classList[isDark?'add':'remove']('dark');var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(X)}:${JSON.stringify(Y)})}catch(e){}})();`,BS=($,Z,Y)=>`document.addEventListener('click',function(e){var t=e.target&&e.target.closest&&e.target.closest('#theme-toggle');if(!t)return;var html=document.documentElement;var isDark=html.classList.toggle('dark');try{localStorage.setItem(${JSON.stringify($)},isDark?'dark':'light')}catch(e){}var tc=document.querySelector('meta[name="theme-color"]:not([media])');if(tc)tc.setAttribute('content',isDark?${JSON.stringify(Y)}:${JSON.stringify(Z)})});`;var{Glob:zS}=globalThis.Bun;import{cpSync as qS,existsSync as G8,mkdirSync as jS,readFileSync as EO,readdirSync as HS,rmSync as OS,statSync as LS,unlinkSync as FS,writeFileSync as Q8}from"fs";import{join as l6,relative as VS}from"path";import AS from"process";import wS from"bun-plugin-stx";async function MG($){let Z=Date.now(),Y=$.pagesDir??"pages",X=$.outDir??"dist",J=$.publicDir??"public";if(!$.noClean)OS(X,{recursive:!0,force:!0});jS(X,{recursive:!0});let Q=new zS(`${Y}/**/*.stx`),G=await Array.fromAsync(Q.scan("."));if(G.length===0)throw Error(`No .stx files found in ${Y}/`);let K=await Bun.build({entrypoints:G,outdir:X,plugins:[wS()],naming:{entry:"[name].[ext]"}});if(!K.success)throw console.error(K.logs),Error("Build failed");NS(X);let W=EG(X).filter((z)=>z.endsWith(".html"));for(let z of W){let q=l6(X,z),j=EO(q,"utf8");if(j=RS(j),j=await E0(j,AS.cwd()),j=g7(j,$,$.pages?.[m7(z)],m7(z)),j=u7(j,$),$.spa!==!1)j=await d7(j,$.router);Q8(q,j)}if(G8(J))qS(J,X,{recursive:!0});let U=l6(X,"404.html");if(!G8(U)&&G8(l6(X,"index.html"))){let z=EO(l6(X,"index.html"),"utf8").replace(/<title>[^<]*<\/title>/i,`<title>404 \u2014 ${MS($.name)}</title>`);Q8(U,z)}if($.sitemap!==!1){let z=W.filter((q)=>q!=="404.html").map((q)=>({path:m7(q),page:$.pages?.[m7(q)]}));Q8(l6(X,"sitemap.xml"),f7($,z))}let _=h7($);if(_!==null)Q8(l6(X,"robots.txt"),_);let B=W.map(m7);return{outDir:X,pages:B,durationMs:Date.now()-Z}}function m7($){if($==="index.html")return"/";return`/${$.replace(/\.html$/,"").replace(/\/index$/,"")}`}function EG($,Z=$){let Y=[];if(!G8($))return Y;for(let X of HS($,{withFileTypes:!0})){let J=l6($,X.name);if(X.isDirectory())Y.push(...EG(J,Z));else Y.push(VS(Z,J))}return Y}function NS($){for(let Z of EG($)){if(!/^chunk-.*\.js(?:\.map)?$/.test(Z))continue;let Y=l6($,Z);try{if(LS(Y).size===0)FS(Y)}catch{}}}function RS($){return $.replace(/<script[^>]*src=["']\.\/chunk-[^"']*\.js["'][^>]*><\/script>\s*/g,"")}function MS($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function TG($){return $}var TO=D(()=>{P1()});var IO=D(()=>{TO()});function DO($,Z){return $.kind===Z}var kO=()=>{};var SO=D(()=>{kO()});var K4={};e(K4,{writeNetlifyConfig:()=>Z7,writeManifest:()=>yJ,writeImageManifest:()=>LJ,wrapComponentForHMR:()=>wk,webComponentDirectiveHandler:()=>sX,watermark:()=>hQ,watchViews:()=>pk,watchMultiple:()=>sE,watchEffect:()=>oE,watch:()=>aE,waitForStore:()=>FT,waitForLocale:()=>aA,videoDirective:()=>i5,validators:()=>x9,validateValueEnhanced:()=>rW,validateTemplate:()=>dB,validateParams:()=>cQ,validateFormEnhanced:()=>hA,validateFile:()=>e3,validateFields:()=>gA,validateField:()=>iW,validateDirective:()=>mB,validateCspDirectives:()=>AA,validateConfig:()=>nz,validateComponentScripts:()=>WI,validateComponentProps:()=>zI,validateClientScript:()=>k5,usesSignalsInScript:()=>e$,useVirtualList:()=>RY,useTitle:()=>vW,useStoreOrThrow:()=>LT,useStore:()=>IH,useSlots:()=>JO,useSeoMeta:()=>B5,useRouteParams:()=>Vq,useRouteParamOrThrow:()=>VT,useRouteParam:()=>Aq,usePageTitle:()=>vW,useMiddlewareValue:()=>AT,useMiddlewareState:()=>wq,useLoadingIndicator:()=>BH,useHead:()=>A6,useAttrs:()=>QO,uploadFiles:()=>jG,uploadFile:()=>$8,updateInstance:()=>QT,untrack:()=>w2,unregisterDirective:()=>dR,unmountInstance:()=>GT,unescapeHtml:()=>N9,transpileTypeScript:()=>q6,transitionDirective:()=>q9,toUsers:()=>_j,toUser:()=>Uj,thumbnail:()=>NQ,thumbHashToRGBA:()=>P7,thumbHashToDataURL:()=>UG,templateCache:()=>rZ,stxClientHelpers:()=>qQ,structuredDataDirective:()=>U2,stripDocumentWrapper:()=>G4,stringToStream:()=>II,strictCspPreset:()=>MW,streamingSuspenseDirective:()=>JH,streamToResponse:()=>Qk,streamTemplateSimple:()=>Zk,streamTemplate:()=>$k,stopHmrServer:()=>V$,stopBroadcasting:()=>Kj,state:()=>H2,startProductionServer:()=>ij,startInteractive:()=>dj,startBroadcasting:()=>Gj,staggerDirective:()=>WK,srcsetUrls:()=>uQ,springDirective:()=>UK,splitByPipe:()=>v9,smartBatchSign:()=>iQ,signUrl:()=>p3,shouldTranspileTypeScript:()=>z6,shouldReloadOnChange:()=>a5,shouldRefreshSignature:()=>a3,shouldIgnoreFile:()=>s5,shouldCacheComponent:()=>KB,sharpen:()=>TQ,setRouteParams:()=>MT,setMiddlewareState:()=>ET,setGlobalProvide:()=>X8,setErrorLocale:()=>rK,setCurrentInstance:()=>lE,setCachedVideoResult:()=>K$,setCachedImageResult:()=>J$,setCached:()=>$$,serveStxFile:()=>c7,serveMultipleStxFiles:()=>l7,serveMarkdownFile:()=>H3,serveFile:()=>sD,serveApp:()=>p7,serve:()=>ZH,serializeState:()=>HH,sepia:()=>DQ,scrollAnimateDirective:()=>j9,screenReaderDirective:()=>z9,scopeHTML:()=>uz,scopeCSS:()=>dz,scanForSitemapEntries:()=>hw,scanA11yIssues:()=>N8,saturation:()=>CQ,sanitizeParams:()=>lQ,sanitizeFilePath:()=>_W,sanitizeExpression:()=>BW,sanitizeDirectiveParams:()=>zW,sanitizeDirectiveParam:()=>W5,sanitizeComponentProps:()=>XZ,safeExecuteAsync:()=>y1,safeExecute:()=>KW,runPreProcessingMiddleware:()=>PZ,runPostProcessingMiddleware:()=>yZ,runMiddleware:()=>B7,runHooks:()=>Q4,rotate:()=>PQ,resolveTemplatePath:()=>C5,resize:()=>AQ,resetPlaceholders:()=>P8,resetHead:()=>yW,resetHMRHandler:()=>Rk,resetErrorConfig:()=>YW,replacePlaceholders:()=>w9,renderView:()=>VG,renderVideoComponent:()=>z$,renderToString:()=>z4,renderToStream:()=>HO,renderToDOM:()=>g$,renderThumbhashToCanvas:()=>WG,renderTemplate:()=>GS,renderString:()=>KS,renderSlot:()=>nY,renderSSRSuspense:()=>p_,renderProtectedVideo:()=>tQ,renderProtectedImg:()=>oQ,renderMediaUpload:()=>pQ,renderImgComponent:()=>y6,renderImageComponent:()=>BJ,renderHtmlAttrs:()=>fW,renderHead:()=>gW,renderEmail:()=>ik,renderComponentWithSlot:()=>v1,renderBodyAttrs:()=>hW,render:()=>Dk,relaxedCspPreset:()=>EW,registerValidationRule:()=>vA,registerStreamingDirectives:()=>Xk,registerStore:()=>NT,registerSeoDirectives:()=>gw,registerMiddleware:()=>OT,registerFilters:()=>EK,registerFilter:()=>x8,registerErrorMessages:()=>sK,registerEnhancedValidationRule:()=>fA,registerDirective:()=>eB,registerCspDirectives:()=>VA,registerComponentDirectives:()=>HI,registerAnimationDirectives:()=>eF,registerA11yDirectives:()=>hF,ref:()=>nE,redirect:()=>xI,readMarkdownFile:()=>$6,readFileCached:()=>vU,reactive:()=>Oq,quality:()=>gQ,pruneSignatureCache:()=>aQ,pruneCache:()=>Uz,provide:()=>oH,processVueTemplate:()=>uZ,processVirtualListDirectives:()=>v2,processVirtualGridDirectives:()=>EY,processVideo:()=>J3,processValidateDirective:()=>nW,processTranslateDirective:()=>MZ,processTransitionDirectives:()=>v_,processTransitionAttributes:()=>h_,processTitleDirective:()=>mW,processTemplateBindings:()=>p8,processTeleportDirectives:()=>D_,processSuspenseDirectives:()=>c_,processStructuredData:()=>gZ,processStaticDirectives:()=>fY,processStackReplacements:()=>K2,processStackPushDirectives:()=>G2,processSlots:()=>rY,processShell:()=>P3,processServerBindings:()=>B2,processSeoDirective:()=>fZ,processSectionDirectives:()=>Jk,processScopedStyles:()=>L5,processReactiveBindings:()=>vK,processProtectedMedia:()=>eQ,processPartialHydrationDirectives:()=>bY,processOnceDirective:()=>D5,processMiddleware:()=>CZ,processMetaDirectives:()=>vZ,processMetaDirective:()=>cW,processMarkdownFileDirectives:()=>pY,processMarkdownDirectives:()=>lY,processLoops:()=>X2,processKeepAliveDirectives:()=>QB,processJsonDirective:()=>I5,processInfiniteListDirectives:()=>MY,processIncludes:()=>Q2,processImgComponents:()=>bX,processImageComponents:()=>zJ,processImage:()=>l1,processHeadDirective:()=>uW,processForms:()=>xA,processFormInputDirectives:()=>r9,processExpressions:()=>w1,processEventDirectives:()=>s8,processErrorDirective:()=>a9,processDynamicComponents:()=>cZ,processDirectives:()=>G0,processDirectiveAttributes:()=>pR,processDeferDirectives:()=>E_,processCustomDirectives:()=>LZ,processCspDirectives:()=>jZ,processClientScript:()=>s6,processBasicFormDirectives:()=>P4,processAsyncDirectives:()=>t_,processAnimationDirectives:()=>M8,processA11yDirectives:()=>w8,preloadTranslationsBackground:()=>nA,preloadTranslations:()=>tW,preloadIslandHandlers:()=>jk,poolStrings:()=>Zj,pluginManager:()=>eX,performLeave:()=>x_,performEnter:()=>y_,peek:()=>N2,partialsCache:()=>M6,parseVideoDirectiveOptions:()=>xz,parseUrl:()=>VQ,parseThumbhashString:()=>_G,parseSwitchBlock:()=>f9,parseSlots:()=>iY,parseSlotElement:()=>iB,parseScriptDeclarations:()=>wW,parseSFCComponent:()=>mz,parseProtectedArgs:()=>$G,parseImgComponent:()=>o2,parseImageUrl:()=>XX,parseImageComponent:()=>R3,parseExpressionWithFilters:()=>VW,parseCookies:()=>CI,parseConditionalBlock:()=>QZ,parseArguments:()=>GZ,parseAnimationShorthand:()=>oF,optimizeTemplate:()=>Yj,optimizeImage:()=>D3,optimizeDirectory:()=>OJ,onceStore:()=>SZ,onUpdated:()=>ZT,onUnmounted:()=>XT,onServer:()=>IT,onMounted:()=>eE,onMount:()=>V2,onHydrated:()=>gY,onErrorCaptured:()=>YO,onDestroy:()=>A2,onDeactivated:()=>BB,onClient:()=>TT,onBeforeUpdate:()=>$T,onBeforeUnmount:()=>YT,onBeforeMount:()=>tE,onActivated:()=>_B,observeElement:()=>QG,notFound:()=>vI,nextTick:()=>ZO,navigateTo:()=>HT,mountInstance:()=>JT,motionDirective:()=>O9,moderateCspPreset:()=>u9,minifyHtml:()=>$j,metaDirective:()=>W2,mergeParams:()=>c3,mergeCspDirectives:()=>LA,matchRoute:()=>y3,markdownDirectiveHandler:()=>oY,markdownCache:()=>U3,loadTranslationLazy:()=>j5,loadTranslation:()=>ZU,loadStxConfig:()=>f0,loadMiddlewareFromDirectory:()=>_7,loadManifest:()=>xJ,loadElement:()=>W6,loadChannels:()=>Wj,lazyLoadAll:()=>XG,lazyLoad:()=>YG,keyframeDirective:()=>KK,jsxs:()=>zO,jsxDEV:()=>qO,jsx:()=>j4,jsonResponse:()=>yI,islandDirective:()=>QH,isTest:()=>XA,isSpaNavigation:()=>RJ,isSignatureValid:()=>n3,isSignal:()=>A5,isSharpAvailable:()=>c1,isServerEnvironment:()=>LI,isServer:()=>Nq,isProduction:()=>eK,isNativeLazySupported:()=>s3,isLoading:()=>pA,isLoaded:()=>iA,isJavaScriptScript:()=>oB,isIntersectionObserverSupported:()=>o3,isImageFile:()=>J7,isICUFormat:()=>JU,isHydrated:()=>vY,isEdgeEnvironment:()=>OI,isDirectiveKind:()=>DO,isDevelopment:()=>H6,isDerived:()=>w5,isCssOnlyChange:()=>r5,isClient:()=>Rq,isAsyncComponent:()=>$B,invert:()=>kQ,invalidateFileCacheByDir:()=>fU,invalidateFileCache:()=>gU,interpolateScriptsInTemplate:()=>IK,interpolateScriptExpressions:()=>g8,inlineError:()=>K0,injectThemeBootstrap:()=>u7,injectSeoTags:()=>hZ,injectSeo:()=>g7,injectRouterScript:()=>d7,injectHotReload:()=>u1,injectHeatmap:()=>I8,injectCspMetaTag:()=>qZ,injectCrosswindCSS:()=>E0,injectAnalytics:()=>r8,inject:()=>tH,initStoreRegistry:()=>wT,initNetlify:()=>Yq,initLoadingIndicator:()=>Fk,initLazyLoading:()=>ZG,initFile:()=>sJ,initBlurUp:()=>t3,initAllBlurUp:()=>zG,imgDirective:()=>l5,imageDirective:()=>jJ,hydrateTemplate:()=>$Q,hydrateIslands:()=>qk,hydrateIsland:()=>PY,hydrateFragment:()=>QD,hydrateByStrategy:()=>yY,hydrateAll:()=>xY,hydrate:()=>Tk,htmlResponse:()=>aD,heatmapDirective:()=>D8,hashString:()=>l2,hashFilePath:()=>g4,hashFile:()=>l0,hashBuffer:()=>Xz,hasVueTemplateSyntax:()=>SU,hasVariables:()=>DZ,hasStore:()=>EH,hasPlaceholders:()=>w4,hasNetlifyConfig:()=>Y7,hasMiddleware:()=>jT,hasEventDirectives:()=>iV,hasDocumentShell:()=>xU,hasDirectives:()=>cB,hasDOMSupport:()=>ZK,handleError:()=>XO,h:()=>VO,groupVariantsByFormat:()=>E$,grayscale:()=>IQ,gitHash:()=>XQ,getUnusedDirectives:()=>aq,getTranslationSync:()=>eW,getTranslationCacheStats:()=>mA,getTranslationAsync:()=>rA,getTranslation:()=>s9,getTotalSize:()=>Z6,getTimeUntilExpiry:()=>r3,getStoreNames:()=>TH,getStore:()=>LQ,getSourceLineInfo:()=>sY,getScreenReaderOnlyStyle:()=>xF,getScopeAttribute:()=>ZE,getRouteParams:()=>gT,getPublicEnvDefine:()=>H1,getPublicEnv:()=>LK,getPositionInfo:()=>uB,getPlaceholderRegistry:()=>y8,getPlaceholderCacheStats:()=>LX,getPageMeta:()=>l9,getNonce:()=>F6,getMimeType:()=>p1,getMiddlewareNames:()=>U7,getMiddleware:()=>qT,getLoadingState:()=>lA,getLoadingLocales:()=>sA,getImageMetadata:()=>X7,getHydrationRuntime:()=>VH,getHydratedStoreState:()=>RT,getHmrServer:()=>o5,getHead:()=>C4,getHMRHandler:()=>Nk,getFormatExtension:()=>KX,getFileMtime:()=>u5,getFallbackVariant:()=>M$,getErrorMessage:()=>e8,getErrorLocale:()=>aK,getErrorConfig:()=>Q5,getErrorCodeName:()=>k9,getDirectives:()=>hR,getDirective:()=>fR,getCurrentInstance:()=>pE,getCspPreset:()=>OA,getCspHeaderName:()=>kW,getComponentCacheStats:()=>gR,getCachedVideoResult:()=>G$,getCachedSignature:()=>nQ,getCachedSignalsRuntime:()=>hU,getCachedRouterScript:()=>dU,getCachedPlaceholder:()=>d5,getCachedImageResult:()=>X$,getCached:()=>e4,getCacheStats:()=>Wz,getBroadcastServer:()=>Qj,getBestVariant:()=>GX,getAllFilters:()=>v8,generateWidthSrcset:()=>b6,generateVirtualListCSS:()=>NY,generateVideoPreview:()=>OG,generateValidationScript:()=>dA,generateUploadRuntime:()=>v7,generateTreeShakenBundle:()=>sq,generateTransitionRuntime:()=>f_,generateTransitionCSS:()=>g_,generateThumbnails:()=>U$,generateThumbhashPlaceholder:()=>_X,generateTemplatesDocs:()=>Rj,generateSuspenseRuntime:()=>n_,generateSuspenseCSS:()=>i_,generateStateScript:()=>LH,generateSrcsetData:()=>JX,generateSrcset:()=>r2,generateSrcSet:()=>J4,generateSpriteSheet:()=>Y3,generateSpaShell:()=>tk,generateSourceTags:()=>QX,generateSizesFromBreakpoints:()=>ZX,generateSizesAttribute:()=>r4,generateSizes:()=>R$,generateSitemapIndex:()=>fw,generateSitemap:()=>f7,generateSimpleMediaPicker:()=>hH,generateSignatureRuntime:()=>b7,generateSignalsRuntimeDev:()=>e6,generateSignalsRuntime:()=>N5,generateScopeId:()=>G3,generateSFCWebComponent:()=>cz,generateRouteTypes:()=>hT,generateRouteManifest:()=>fT,generateRobotsTxt:()=>EU,generateRobots:()=>h7,generateResponsiveVariants:()=>n2,generateReactiveWebComponentTS:()=>JE,generateReactiveWebComponent:()=>XE,generateReactiveRuntime:()=>GE,generateReactiveMixin:()=>QE,generatePoster:()=>W$,generatePlaceholderStyle:()=>HX,generatePlaceholderCSS:()=>h5,generatePlaceholder:()=>f5,generatePartialHydrationCSS:()=>CY,generateNonce:()=>BZ,generateNetlifyToml:()=>L3,generateMinifiedMediaRuntime:()=>pH,generateMediaRuntime:()=>FG,generateMediaManagerEmbed:()=>fH,generateManifest:()=>PJ,generateLoadingIndicatorHtml:()=>Vk,generateLazyLoadRuntime:()=>C7,generateLQIP:()=>zX,generateKeepAliveRuntime:()=>UB,generateKeepAliveCSS:()=>WB,generateIslandManifest:()=>hY,generateImagePreview:()=>HG,generateImageManifest:()=>k3,generateHydrationScript:()=>Ek,generateHydrationRuntime:()=>Gk,generateHydrationCSS:()=>Ik,generateHydrationBootstrap:()=>IY,generateHotReloadScript:()=>$q,generateHeatmapScript:()=>T8,generateHMRClientScript:()=>Ak,generateHLSManifest:()=>_$,generateEventBindings:()=>Mk,generateDprSrcsetWithVariableQuality:()=>$X,generateDprSrcset:()=>n4,generateDocumentShell:()=>yU,generateDocs:()=>Dj,generateDirectivesDocs:()=>Mj,generateDirectiveRuntime:()=>lR,generateDefaultRobotsTxt:()=>dw,generateDASHManifest:()=>B$,generateCspMetaTag:()=>m9,generateCspHeader:()=>zZ,generateCrosswindCSS:()=>E9,generateCompositionRuntime:()=>KO,generateComponentsDocs:()=>Nj,generateComponentManifest:()=>YR,generateComponentDoc:()=>wj,generateColorPlaceholder:()=>jX,generateClientRuntime:()=>KT,generateCacheKey:()=>o4,generateBlurUpRuntime:()=>y7,generateBlurUpCSS:()=>x7,generateBindingsRuntime:()=>gK,generateAutoWidthSrcset:()=>eY,generateAsyncComponentRuntime:()=>YB,generateAsyncComponentCSS:()=>ZB,generateAnimationRuntime:()=>tF,generateAnimationCSS:()=>sF,generateAnalyticsScript:()=>n8,formatTypeErrors:()=>zk,formatStxContent:()=>h3,formatSize:()=>f6,formatRoutes:()=>EJ,formatMarkdownContent:()=>nJ,formatLocalizedError:()=>tK,formatICU:()=>YU,formatFilePath:()=>G5,formatError:()=>C9,formatDocsAsMarkdown:()=>Ej,formatDocsAsJson:()=>Ij,formatDocsAsHtml:()=>Tj,format:()=>vQ,foldConstants:()=>eq,flipVertical:()=>xQ,flipHorizontal:()=>yQ,fingerprint:()=>TJ,findMatchingEndTag:()=>L6,findMatchingDelimiter:()=>v0,findIfBlocks:()=>g9,findExpressions:()=>FW,findErrorPage:()=>MJ,findDirectiveBlocks:()=>_5,findDeadCode:()=>oq,findDeadBranches:()=>oq,findComponentFiles:()=>cJ,findCommonDir:()=>IG,filterRequiredFiles:()=>$7,fileExists:()=>X0,extractVariables:()=>A0,extractState:()=>FH,extractSlotContent:()=>rB,extractScriptFromTemplate:()=>IZ,extractPlaceholders:()=>NV,extractParenthesizedExpression:()=>o1,extractDominantColor:()=>qX,extractDirectiveParams:()=>AW,extractDirectiveNames:()=>lB,extractContainerContent:()=>j7,extractComponentProps:()=>Vj,extractComponentName:()=>DY,extractComponentDescription:()=>Aj,extractClassNames:()=>M9,extractBoundProps:()=>kY,extractBalancedExpression:()=>JZ,extractAndScopeStyles:()=>YE,extractAndProcessEvents:()=>cK,evaluateExpression:()=>_1,evaluateConstant:()=>g3,evaluateAuthExpression:()=>s1,escapeHtml:()=>D0,errorRecovery:()=>P9,errorLogger:()=>a0,ensureTeleportTargets:()=>k_,ensureDocumentShell:()=>F5,enhancedValidationRules:()=>AZ,eliminateDeadCode:()=>tq,effect:()=>L2,dprUrls:()=>mQ,docsCommand:()=>lJ,disconnectObserver:()=>GG,devHelpers:()=>S4,detectShell:()=>NJ,detectRuntime:()=>b$,detectProjectConfig:()=>w$,detectFormat:()=>WX,detectBuildMode:()=>KI,derived:()=>O2,deploy:()=>Zq,defineStxConfig:()=>iz,defineStore:()=>DH,defineSiteConfig:()=>TG,definePlugin:()=>j$,definePageMeta:()=>xW,defineMiddleware:()=>zT,defineExpose:()=>$O,defineEmits:()=>eH,defineDirective:()=>b0,defineCustomElement:()=>wO,defineConfig:()=>JD,defineClientDirective:()=>uR,defineAsyncComponent:()=>e_,defaultMediaConfig:()=>lk,defaultImageConfig:()=>zq,defaultI18nConfig:()=>o9,defaultHeatmapConfig:()=>qK,defaultFormClasses:()=>n9,defaultFilters:()=>N4,defaultCspConfig:()=>NA,defaultConfig:()=>K1,default:()=>ES,decodeThumbhash:()=>BX,cspNonceDirective:()=>DW,cspDirective:()=>IW,crossfadeTransition:()=>BG,crop:()=>wQ,createVirtualList:()=>x2,createVideoDirective:()=>Q3,createVercelHandler:()=>SI,createTypeChecker:()=>WQ,createTranslateFilter:()=>qw,createTextEncoderStream:()=>TI,createStxApp:()=>RG,createStreamingResponse:()=>EI,createStreamRenderer:()=>Yk,createStore:()=>FQ,createStorageManager:()=>BT,createServerCookieManager:()=>_T,createScope:()=>Hq,createSSRSuspense:()=>l_,createRouter:()=>Q6,createRouteLocation:()=>W7,createRoute:()=>tD,createRef:()=>nE,createReactive:()=>Oq,createProvideContext:()=>GO,createProject:()=>_D,createProductionBuild:()=>XD,createPlaceholder:()=>s$,createOptimizedBuild:()=>UI,createNetlifyHandler:()=>bI,createNetlifyClient:()=>t5,createMiddlewareContext:()=>K7,createMiddleware:()=>oD,createLazyObserver:()=>JG,createKeepAliveCache:()=>GB,createKVNamespace:()=>bj,createIslandRegistry:()=>SY,createImgDirective:()=>t2,createImagePlugin:()=>HJ,createImageDirective:()=>T3,createHeatmapAggregator:()=>YV,createFileManifest:()=>e5,createEnvAccessor:()=>Sj,createEnhancedError:()=>GW,createEdgeHandler:()=>V7,createEdgeCache:()=>Cj,createDetailedErrorMessage:()=>L0,createDenoHandler:()=>kI,createDefaultNetlifyConfig:()=>N$,createCspHeaders:()=>wA,createCookie:()=>PI,createComputed:()=>rE,createComponentInstance:()=>iE,createCloudflareHandler:()=>DI,createClientCookieManager:()=>UT,createBuiltinDirectives:()=>cR,createApp:()=>RG,createAnimationTimeline:()=>aF,cover:()=>MQ,convertToCommonJS:()=>t9,contrast:()=>bQ,contain:()=>RQ,consoleError:()=>QW,configureErrorHandling:()=>ZW,config:()=>W1,computed:()=>rE,composeShellWithPage:()=>q7,componentDirective:()=>Lj,compileTemplate:()=>SJ,collectDeployFiles:()=>A$,clearVideoCache:()=>$3,clearTranslationCache:()=>uA,clearSignatureCache:()=>rQ,clearPlaceholderCache:()=>OX,clearOnceStore:()=>Pw,clearNonce:()=>HA,clearMiddleware:()=>G7,clearImageCache:()=>E3,clearErrorMessages:()=>oK,clearDevCaches:()=>uU,clearCustomFilters:()=>TK,clearComponentCache:()=>S6,clearCache:()=>Z$,classifyScript:()=>Tq,classifyAllScripts:()=>VJ,checkTemplateFile:()=>_k,checkTemplate:()=>Bk,checkCache:()=>E2,checkAuthAccess:()=>v$,checkA11y:()=>_9,channel:()=>qj,cancelPendingLoads:()=>oA,calculateSha1:()=>O3,calculateOptimalWidths:()=>u2,cacheTemplate:()=>T2,buildWebComponents:()=>rX,buildViews:()=>aH,buildUrl:()=>w0,buildStaticSite:()=>MG,buildRuntimeAsset:()=>IJ,buildRouterAsset:()=>DJ,buildImageUrl:()=>E1,buildForProduction:()=>dq,buildAuthParams:()=>S7,buildApp:()=>mq,build:()=>YD,broadcastPrivate:()=>Bj,broadcastPresence:()=>zj,broadcast:()=>dJ,brightness:()=>SQ,blur:()=>EQ,batchSignUrls:()=>i3,batch:()=>F2,autoFixA11yFile:()=>XK,autoFixA11yDirectory:()=>fF,autoFixA11y:()=>YK,auto:()=>fQ,assetTags:()=>$I,applyTransformations:()=>c5,applySlots:()=>aB,applyPropDefaults:()=>qI,applyPreset:()=>dQ,applyHead:()=>dW,applyFilters:()=>f8,apiCspPreset:()=>TW,animationGroupDirective:()=>H9,analyzeVideo:()=>p5,analyzeUsage:()=>fJ,analyzeTemplate:()=>Eq,analyzeProject:()=>FJ,analyzeDirectiveUsage:()=>fJ,analyticsDirective:()=>dV,addStore:()=>HD,addPage:()=>jD,addNonceToInlineContent:()=>FA,addLayout:()=>OD,addComponent:()=>qD,abortNavigation:()=>WT,a11yDirective:()=>B9,VideoProcessorCache:()=>Q$,TransitionType:()=>JK,TransitionEase:()=>GK,TransitionDirection:()=>QK,Tokenizer:()=>U5,TemplateTypeChecker:()=>KQ,TEMPLATE_PRESETS:()=>cI,StxValidationError:()=>K5,StxSyntaxError:()=>$Z,StxSecurityError:()=>ZZ,StxRuntimeError:()=>R1,StxFileError:()=>k4,StxError:()=>O6,Show:()=>OO,SPRING_PRESETS:()=>R8,ProductionBuild:()=>d3,Portal:()=>FO,PROJECT_TEMPLATES:()=>UD,PRESETS:()=>l3,MemorySessionStore:()=>NH,MIME_TYPES:()=>v5,MEDIA_DEFAULT_WIDTHS:()=>d1,MEDIA_DEFAULT_FORMATS:()=>e1,ImageProcessorCache:()=>Y$,ImageProcessingError:()=>T$,HydrationRuntime:()=>OQ,HotReloadServer:()=>GJ,HeatmapAggregator:()=>k8,Fragment:()=>q4,For:()=>LO,ErrorLogger:()=>y9,ErrorCodes:()=>Z0,DeployError:()=>X6,DEFAULT_WIDTHS:()=>L1,DEFAULT_TRANSITION_OPTIONS:()=>S1,DEFAULT_QUALITY:()=>V1,DEFAULT_PLACEHOLDER_OPTIONS:()=>c2,DEFAULT_FORMATS:()=>F1,DEFAULT_DPR_VALUES:()=>x5,ComponentHMRHandler:()=>jQ,COMMON_SIZES:()=>YX,BroadcastServer:()=>Hj,Broadcast:()=>jj,BLUR_UP_CSS:()=>s4});var ES;var h6=D(()=>{F3();S3();H0();r6();kH();dZ();AG();AO();NO();$J();P1();IO();Lq();w6();b3();wZ();A4();a8();L9();i4();H7();t8();gJ();kJ();iq();Xj();f3();I2();Fj();m0();HZ();FZ();F3();DG();y5();pJ();Pj();z1();o8();r0();rJ();F9();EZ();y4();oJ();tJ();J2();h2();xZ();h9();x3();o$();G1();lj();vJ();YQ();O7();$H();AJ();_2();YH();z2();bJ();ZQ();GH();WH();oX();TY();dY();UH();zH();i8();r$();jH();AH();RH();S3();rH();sH();R5();mZ();lZ();MO();H0();aY();SO();ES={}});import i7 from"path";var h$;var K8=D(()=>{h6();z1();r0();j6();G1();h$={name:"bun-plugin-stx",async setup($){let Y={...await f0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${i7.relative(i7.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await rX(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 E2(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await y1(()=>Bun.file(G).text(),"",(H)=>{throw new k4(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new k4(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:B}=N1.time("script-extraction",()=>{let H=W,O=W.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(O)H=O[1].trim();let F=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",V=[];for(let A of F){let N=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))L=N;else V.push(A)}let w=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:w,allScripts:V}}),z={__filename:G,__dirname:i7.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await y1(()=>A0(U,z,G),void 0,(H)=>{let O=new R1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(a0.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await N1.timeAsync("directive-processing",async()=>{return await G0(_,z,G,Y,K)});if(B.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (r0(),$5)),O=H(B.join(`
14796
14798
  `),z),F=j.search(/<\/body>/i);if(F!==-1)j=j.slice(0,F)+O+`
14797
14799
  `+j.slice(F);else j+=`
14798
- ${O}`}if(j=await D4(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await T2(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(a0.log(W,{filePath:G,buildConfig:$.config}),S6.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>
14800
+ ${O}`}if(j=await D6(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await T2(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(a0.log(W,{filePath:G,buildConfig:$.config}),S4.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>
14799
14801
  <html lang="en">
14800
14802
  <head>
14801
14803
  <meta charset="UTF-8">
@@ -14855,12 +14857,12 @@ ${O}`}if(j=await D4(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await T
14855
14857
  <h1>Something went wrong</h1>
14856
14858
  <p>An internal error occurred. Please try again later.</p>
14857
14859
  </body>
14858
- </html>`,loader:"html"}}})}}});var{serve:TS}=globalThis.Bun;import D1 from"fs";import X1 from"path";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=X1.resolve($);if(!D1.existsSync(K))return console.error(`${R.red}Error: File not found: ${R.bright}${K}${R.reset}`),!1;if(K.endsWith(".md"))return H3(K,Z);else if(!K.endsWith(".stx"))return console.error(`${R.red}Error: Unsupported file type: ${R.bright}${K}${R.reset}. Only .stx and .md files are supported.`),!1;let W=X1.join(process.cwd(),".stx/output");D1.mkdirSync(W,{recursive:!0}),console.log(`${R.blue}Building ${R.bright}${$}${R.reset}...`);let U=null,_=async()=>{try{let L={name:"public-assets",setup(N){N.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,h$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${R.red}Build failed:${R.reset}`,V.logs),!1;let w=V.outputs.find((N)=>N.path.endsWith(".html"));if(!w)return console.error(`${R.red}No HTML output found${R.reset}`),!1;return U=await Bun.file(w.path).text(),!0}catch(L){return console.error(`${R.red}Error building stx file:${R.reset}`,L),!1}};if(!await _())return!1;let z=X1.dirname(K);await I6(z);let q=Y;try{if(q=await v4(Y),q!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${q} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let L=Z.hmrPort||q+1;Q=o5({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (h4(),K6)),V=await L();if(V?.apiRouter)H=V?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let w=Object.keys(j).length;if(w>0)console.log(`${R.blue}Loaded ${R.bright}${w} API route${w>1?"s":""}${R.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:A}=await Promise.resolve().then(() => (f3(),uJ)),N=V.broadcasting;await w(N);let M=N.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${M}/ws${R.reset}`);let E=X1.join(process.cwd(),"channels.ts");if(D1.existsSync(E))try{let I=await A(E);console.log(`${R.blue}Loaded ${R.bright}${I} broadcast channel${I!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(I){console.warn(`${R.yellow}Failed to load channels.ts: ${I.message}${R.reset}`)}}catch(w){console.warn(`${R.yellow}Broadcasting failed to start: ${w.message}${R.reset}`)}}catch{}if(console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${q}/${R.reset}...`),J)console.log(`${R.magenta}Hot reload enabled on ws://localhost:${G}${R.reset}`);let O=TS({port:q,async fetch(L){let V=new URL(L.url);if(H)try{let E=await H.handleRequest(L);if(E.status!==404)return E}catch{}if(j[V.pathname])try{return await j[V.pathname](L)}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 E0(U||"");if(J)I=u1(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 w=X1.join(W,V.pathname);if(D1.existsSync(w)&&D1.statSync(w).isFile()){let E=Bun.file(w),I=X1.extname(w).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),b=S.transformSync(k);return new Response(b,{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=X1.dirname(K),N=X1.join(A,V.pathname);if(D1.existsSync(N)&&D1.statSync(N).isFile()){let E=Bun.file(N),I=X1.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(),b=S.transformSync(k);return new Response(b,{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=X1.join(process.cwd(),"public",V.pathname);if(D1.existsSync(M)&&D1.statSync(M).isFile()){let E=Bun.file(M),I=X1.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(),b=S.transformSync(k);return new Response(b,{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(L){return new Response(`<pre>${L}
14860
+ </html>`,loader:"html"}}})}}});var{serve:TS}=globalThis.Bun;import D1 from"fs";import X1 from"path";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=X1.resolve($);if(!D1.existsSync(K))return console.error(`${R.red}Error: File not found: ${R.bright}${K}${R.reset}`),!1;if(K.endsWith(".md"))return H3(K,Z);else if(!K.endsWith(".stx"))return console.error(`${R.red}Error: Unsupported file type: ${R.bright}${K}${R.reset}. Only .stx and .md files are supported.`),!1;let W=X1.join(process.cwd(),".stx/output");D1.mkdirSync(W,{recursive:!0}),console.log(`${R.blue}Building ${R.bright}${$}${R.reset}...`);let U=null,_=async()=>{try{let L={name:"public-assets",setup(N){N.onResolve({filter:/^\/(images|fonts|assets|public)\//},(M)=>{return{path:M.path,external:!0}})}},V=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,h$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!V.success)return console.error(`${R.red}Build failed:${R.reset}`,V.logs),!1;let w=V.outputs.find((N)=>N.path.endsWith(".html"));if(!w)return console.error(`${R.red}No HTML output found${R.reset}`),!1;return U=await Bun.file(w.path).text(),!0}catch(L){return console.error(`${R.red}Error building stx file:${R.reset}`,L),!1}};if(!await _())return!1;let z=X1.dirname(K);await I4(z);let q=Y;try{if(q=await v6(Y),q!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${q} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let L=Z.hmrPort||q+1;Q=o5({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (h6(),K4)),V=await L();if(V?.apiRouter)H=V?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(V?.apiRoutes){j=V.apiRoutes;let w=Object.keys(j).length;if(w>0)console.log(`${R.blue}Loaded ${R.bright}${w} API route${w>1?"s":""}${R.reset}`)}if(V?.broadcasting?.enabled)try{let{startBroadcasting:w,loadChannels:A}=await Promise.resolve().then(() => (f3(),uJ)),N=V.broadcasting;await w(N);let M=N.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${M}/ws${R.reset}`);let E=X1.join(process.cwd(),"channels.ts");if(D1.existsSync(E))try{let I=await A(E);console.log(`${R.blue}Loaded ${R.bright}${I} broadcast channel${I!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(I){console.warn(`${R.yellow}Failed to load channels.ts: ${I.message}${R.reset}`)}}catch(w){console.warn(`${R.yellow}Broadcasting failed to start: ${w.message}${R.reset}`)}}catch{}if(console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${q}/${R.reset}...`),J)console.log(`${R.magenta}Hot reload enabled on ws://localhost:${G}${R.reset}`);let O=TS({port:q,async fetch(L){let V=new URL(L.url);if(H)try{let E=await H.handleRequest(L);if(E.status!==404)return E}catch{}if(j[V.pathname])try{return await j[V.pathname](L)}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 E0(U||"");if(J)I=u1(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 w=X1.join(W,V.pathname);if(D1.existsSync(w)&&D1.statSync(w).isFile()){let E=Bun.file(w),I=X1.extname(w).toLowerCase(),T="text/plain";if(I===".ts"||I===".tsx"){let S=new Bun.Transpiler({loader:I===".tsx"?"tsx":"ts"}),k=await E.text(),b=S.transformSync(k);return new Response(b,{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=X1.dirname(K),N=X1.join(A,V.pathname);if(D1.existsSync(N)&&D1.statSync(N).isFile()){let E=Bun.file(N),I=X1.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(),b=S.transformSync(k);return new Response(b,{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=X1.join(process.cwd(),"public",V.pathname);if(D1.existsSync(M)&&D1.statSync(M).isFile()){let E=Bun.file(M),I=X1.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(),b=S.transformSync(k);return new Response(b,{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(L){return new Response(`<pre>${L}
14859
14861
  ${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
14860
14862
  ${R.blue}stx${R.reset} ${R.green}${process.env.stx_VERSION||"v0.0.10"}${R.reset} ${R.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${R.reset}`),console.log(`
14861
14863
  ${R.bright}\u2192 ${R.cyan}http://localhost:${q}/${R.reset}`),console.log(`
14862
14864
  ${R.yellow}Routes:${R.reset}`);let F=X1.relative(process.cwd(),K);if(console.log(` ${R.green}\u2514\u2500 /${R.reset} \u2192 ${R.bright}${F}${R.reset}`),console.log(`
14863
- Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g4(O.url.toString(),()=>{if(X)D1.watch(X1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),V=j3(L);await O$(q,{title:X1.basename(K,".stx"),nativeSidebar:!!V,sidebarConfig:V})}if(X){let L=X1.dirname(K);console.log(`${R.blue}Watching ${R.bright}${L}${R.reset} for changes...`);let V=D1.watch(L,{recursive:!0},async(w,A)=>{if(!A||s5(A))return;if(a5(A)){console.log(`${R.yellow}File ${R.bright}${A}${R.yellow} changed, rebuilding...${R.reset}`),M4.clear(),S4();let N=await _();if(await J5(z),J&&Q)if(N)Q.reload(A);else Q.error("Build failed - check console for details")}else if(r5(A)){if(console.log(`${R.cyan}CSS ${R.bright}${A}${R.cyan} changed${R.reset}`),J&&Q)Q.updateCss(A)}});process.on("SIGINT",()=>{if(V.close(),Q)V$();O.stop(),process.exit(0)})}return!0}var bO=D(()=>{y6();K8();H0();n5();QJ()});var{serve:IS}=globalThis.Bun;import p4 from"fs";import o0 from"path";function IG($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split(o0.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(o0.sep)}async function l7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=o0.resolve(j);if(!p4.existsSync(H))return console.error(`${R.red}Error: File not found: ${R.bright}${H}${R.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${R.red}Error: Unsupported file type: ${R.bright}${H}${R.reset}. Only .stx and .md files are supported.`),!1}let J=o0.join(process.cwd(),".stx/output");p4.mkdirSync(J,{recursive:!0});let Q=IG($.map((j)=>o0.dirname(o0.resolve(j))));console.log(`${R.blue}Processing ${R.bright}${$.length}${R.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=o0.resolve(j);if(H.endsWith(".md"))try{let{content:F,data:L}=await $4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:W1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),V=Z.markdown?.syntaxHighlighting||W1.markdown?.syntaxHighlighting,w=V?.defaultTheme||"github-dark",A=["github-dark"],N=V?.additionalThemes||[],E=[...new Set([...A,...N])].map((k)=>`<option value="${k}"${k===w?" selected":""}>${k}</option>`).join(`
14865
+ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g6(O.url.toString(),()=>{if(X)D1.watch(X1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),V=j3(L);await O$(q,{title:X1.basename(K,".stx"),nativeSidebar:!!V,sidebarConfig:V})}if(X){let L=X1.dirname(K);console.log(`${R.blue}Watching ${R.bright}${L}${R.reset} for changes...`);let V=D1.watch(L,{recursive:!0},async(w,A)=>{if(!A||s5(A))return;if(a5(A)){console.log(`${R.yellow}File ${R.bright}${A}${R.yellow} changed, rebuilding...${R.reset}`),M6.clear(),S6();let N=await _();if(await J5(z),J&&Q)if(N)Q.reload(A);else Q.error("Build failed - check console for details")}else if(r5(A)){if(console.log(`${R.cyan}CSS ${R.bright}${A}${R.cyan} changed${R.reset}`),J&&Q)Q.updateCss(A)}});process.on("SIGINT",()=>{if(V.close(),Q)V$();O.stop(),process.exit(0)})}return!0}var bO=D(()=>{y4();K8();H0();n5();QJ()});var{serve:IS}=globalThis.Bun;import p6 from"fs";import o0 from"path";function IG($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split(o0.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(o0.sep)}async function l7($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=o0.resolve(j);if(!p6.existsSync(H))return console.error(`${R.red}Error: File not found: ${R.bright}${H}${R.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${R.red}Error: Unsupported file type: ${R.bright}${H}${R.reset}. Only .stx and .md files are supported.`),!1}let J=o0.join(process.cwd(),".stx/output");p6.mkdirSync(J,{recursive:!0});let Q=IG($.map((j)=>o0.dirname(o0.resolve(j))));console.log(`${R.blue}Processing ${R.bright}${$.length}${R.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=o0.resolve(j);if(H.endsWith(".md"))try{let{content:F,data:L}=await $6(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:W1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),V=Z.markdown?.syntaxHighlighting||W1.markdown?.syntaxHighlighting,w=V?.defaultTheme||"github-dark",A=["github-dark"],N=V?.additionalThemes||[],E=[...new Set([...A,...N])].map((k)=>`<option value="${k}"${k===w?" selected":""}>${k}</option>`).join(`
14864
14866
  `),I=`
14865
14867
  <!DOCTYPE html>
14866
14868
  <html lang="en">
@@ -15023,19 +15025,19 @@ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g4(O.u
15023
15025
  </script>
15024
15026
  </body>
15025
15027
  </html>
15026
- `,S=`/${o0.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(`${R.red}Error processing Markdown file ${R.bright}${j}${R.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}})}},L=await Bun.build({entrypoints:[H],outdir:J,plugins:[F,h$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${R.red}Build failed for ${R.bright}${j}${R.reset}:`,L.logs);continue}let V=L.outputs.find((M)=>M.path.endsWith(".html"));if(!V){console.error(`${R.red}No HTML output found for ${R.bright}${j}${R.reset}`);continue}let w=await Bun.file(V.path).text(),N=`/${o0.relative(Q,H).replace(/\.stx$/,"")}`;if(N.endsWith("/index"))N=N.slice(0,-6)||"/";if(N.includes("[")){let M=[...N.matchAll(/\[([^\]]+)\]/g)].map((I)=>I[1]),E=N.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:M,filePath:H,routeTemplate:N,fileType:"stx"}),G[N]={filePath:H,content:w,fileType:"stx"}}else G[N||"/"]={filePath:H,content:w,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${R.red}No files were successfully processed${R.reset}`),!1;return!0}catch(j){return console.error(`${R.red}Error processing files:${R.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await v4(Y),_!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${_} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${_}/${R.reset}...`);let B=IS({port:_,async fetch(j){let H=new URL(j.url),O=o0.join(process.cwd(),"public",H.pathname);if(p4.existsSync(O)&&p4.statSync(O).isFile()){let V=Bun.file(O),w=o0.extname(O).toLowerCase(),A="application/octet-stream";if(w===".ts"||w===".tsx"){let N=new Bun.Transpiler({loader:w===".tsx"?"tsx":"ts"}),M=await V.text(),E=N.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(w){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 w=H.pathname.match(V.pattern);if(w){let A=G[V.routeTemplate];if(A){let N={};for(let I=0;I<V.paramNames.length;I++)N[V.paramNames[I]]=decodeURIComponent(w[I+1]);let M=A.content,E=`<script>window.__routeParams = ${JSON.stringify(N)};</script>`;if(M.includes("</head>"))M=M.replace("</head>",`${E}
15028
+ `,S=`/${o0.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(`${R.red}Error processing Markdown file ${R.bright}${j}${R.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}})}},L=await Bun.build({entrypoints:[H],outdir:J,plugins:[F,h$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${R.red}Build failed for ${R.bright}${j}${R.reset}:`,L.logs);continue}let V=L.outputs.find((M)=>M.path.endsWith(".html"));if(!V){console.error(`${R.red}No HTML output found for ${R.bright}${j}${R.reset}`);continue}let w=await Bun.file(V.path).text(),N=`/${o0.relative(Q,H).replace(/\.stx$/,"")}`;if(N.endsWith("/index"))N=N.slice(0,-6)||"/";if(N.includes("[")){let M=[...N.matchAll(/\[([^\]]+)\]/g)].map((I)=>I[1]),E=N.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${E}$`),paramNames:M,filePath:H,routeTemplate:N,fileType:"stx"}),G[N]={filePath:H,content:w,fileType:"stx"}}else G[N||"/"]={filePath:H,content:w,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${R.red}No files were successfully processed${R.reset}`),!1;return!0}catch(j){return console.error(`${R.red}Error processing files:${R.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await v6(Y),_!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${_} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}console.log(`${R.blue}Starting server on ${R.cyan}http://localhost:${_}/${R.reset}...`);let B=IS({port:_,async fetch(j){let H=new URL(j.url),O=o0.join(process.cwd(),"public",H.pathname);if(p6.existsSync(O)&&p6.statSync(O).isFile()){let V=Bun.file(O),w=o0.extname(O).toLowerCase(),A="application/octet-stream";if(w===".ts"||w===".tsx"){let N=new Bun.Transpiler({loader:w===".tsx"?"tsx":"ts"}),M=await V.text(),E=N.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(w){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 w=H.pathname.match(V.pattern);if(w){let A=G[V.routeTemplate];if(A){let N={};for(let I=0;I<V.paramNames.length;I++)N[V.paramNames[I]]=decodeURIComponent(w[I+1]);let M=A.content,E=`<script>window.__routeParams = ${JSON.stringify(N)};</script>`;if(M.includes("</head>"))M=M.replace("</head>",`${E}
15027
15029
  </head>`);else M=E+M;F={...A,content:M}}break}}if(F)return E0(F.content).then((V)=>{if(V.includes("</head>"))V=V.replace("</head>",`${qQ}
15028
- </head>`);return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let L=o0.join(J,H.pathname);if(p4.existsSync(L)&&p4.statSync(L).isFile()){let V=Bun.file(L),w=o0.extname(L).toLowerCase(),A="text/plain";if(w===".ts"||w===".tsx"){let N=new Bun.Transpiler({loader:w===".tsx"?"tsx":"ts"}),M=await V.text(),E=N.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(w){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 E0(G["/"].content).then((w)=>{if(V){let A=w.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(A){let N=w.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=`<!DOCTYPE html><html><head><title>${N?N[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(w,{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}
15030
+ </head>`);return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let L=o0.join(J,H.pathname);if(p6.existsSync(L)&&p6.statSync(L).isFile()){let V=Bun.file(L),w=o0.extname(L).toLowerCase(),A="text/plain";if(w===".ts"||w===".tsx"){let N=new Bun.Transpiler({loader:w===".tsx"?"tsx":"ts"}),M=await V.text(),E=N.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(w){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 E0(G["/"].content).then((w)=>{if(V){let A=w.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(A){let N=w.match(/<title[^>]*>([\s\S]*?)<\/title>/i),E=`<!DOCTYPE html><html><head><title>${N?N[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(w,{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}
15029
15031
  ${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
15030
15032
  ${R.blue}stx${R.reset} ${R.green}${process.env.stx_VERSION||"v0.0.10"}${R.reset} ${R.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${R.reset}`),console.log(`
15031
15033
  ${R.bright}\u2192 ${R.cyan}http://localhost:${_}/${R.reset}`),console.log(`
15032
15034
  ${R.yellow}Routes:${R.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:o0.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:o0.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 ",L=j.fileType==="md"?`${R.magenta}(markdown)${R.reset}`:"";console.log(` ${R.green}${F}${j.route}${R.reset} \u2192 ${R.bright}${j.filePath}${R.reset} ${L}`)}),console.log(`
15033
- Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g4(B.url.toString(),()=>{if(X)p4.watch(Q,{recursive:!0}).close();B.stop()}),X){console.log(`${R.blue}Watching for changes...${R.reset}`);let j=p4.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${R.yellow}File ${R.bright}${O}${R.yellow} changed, rebuilding...${R.reset}`),M4.clear(),S4(),await W()});process.on("SIGINT",()=>{j.close(),B.stop(),process.exit(0)})}return!0}var CO=D(()=>{i6();m0();y6();K8();H0();n5()});var{serve:DS}=globalThis.Bun;import U4 from"fs";import I0 from"path";function kG($){let Z=Bun.file($),Y=I0.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 p7($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=I0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (h4(),K6)),U=await W(K),_=U.root&&U.root!=="."?I0.join(K,U.root):K,B=U.pagesDir||"pages",z=I0.join(_,B);if(!U4.existsSync(z))return console.error(`${R.red}Error: No '${B}' directory found in ${R.bright}${_}${R.reset}`),console.log(`${R.dim}Create a ${B}/ directory with .stx files to define your routes.${R.reset}`),console.log(`${R.dim}Example: ${B}/index.stx for the homepage.${R.reset}`),!1;let q=Q4(_);if(q.length===0)return console.error(`${R.red}Error: No page files found in ${R.bright}${z}${R.reset}`),!1;console.log(`${R.blue}Found ${R.bright}${q.length}${R.blue} routes${R.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:f,prefix:h}of j)if(U4.existsSync(f)){let d=Q4(I0.dirname(f),{pagesDir:I0.basename(f)});for(let i of d){let n=h==="/"?i.pattern:`${h}${i.pattern==="/"?"":i.pattern}`;H.push({route:{...i,pattern:n},prefix:h})}if(d.length>0)console.log(`${R.blue}Plugin pages: ${R.bright}${d.length}${R.blue} routes at ${R.cyan}${h}${R.reset}`)}let O=new Map,F=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=NJ(K,Z.stxOptions?.shell),L){if(F=await P3(L,Z.stxOptions||{}),F)console.log(`${R.blue}Using app shell: ${R.bright}${I0.relative(K,L)}${R.reset} ${R.dim}(deprecated: use layouts/default.stx instead)${R.reset}`)}}G7(),await _7(K);let V=U7();if(V.length>0)console.log(`${R.blue}Loaded ${R.bright}${V.length}${R.blue} middleware: ${R.dim}${V.join(", ")}${R.reset}`);let w={},A=null;try{let{loadStxConfig:f}=await Promise.resolve().then(() => (h4(),K6)),h=await f(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(h?.apiRoutes){w=h.apiRoutes;let d=Object.keys(w).length;if(d>0)console.log(`${R.blue}Loaded ${R.bright}${d} API route${d>1?"s":""}${R.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:d,loadChannels:i}=await Promise.resolve().then(() => (f3(),uJ)),n=h.broadcasting;await d(n);let W0=n.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${W0}/ws${R.reset}`);let z0=I0.join(process.cwd(),"channels.ts");if(U4.existsSync(z0))try{let y0=await i(z0);console.log(`${R.blue}Loaded ${R.bright}${y0} broadcast channel${y0!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(y0){console.warn(`${R.yellow}Failed to load channels.ts: ${y0.message}${R.reset}`)}}catch(d){console.warn(`${R.yellow}Broadcasting failed to start: ${d.message}${R.reset}`)}}catch{}let N=I0.join(K,".stx/output");U4.mkdirSync(N,{recursive:!0});let M=new Map,E=async(f)=>{let h=MJ(z,f);if(!h)return null;try{let d=await Bun.build({entrypoints:[h],outdir:N,plugins:[h$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!d.success)return null;let i=d.outputs.find((n)=>n.path.endsWith(".html"));if(!i)return null;return await Bun.file(i.path).text()}catch{return null}},I=async(f,h)=>{try{let{processDirectives:d,extractVariables:i,defaultConfig:n,loadStxConfig:W0,injectRouterScript:z0}=await Promise.resolve().then(() => (h4(),K6)),y0=await W0(K),S0=await Bun.file(f.filePath).text(),{classifyAllScripts:g}=await Promise.resolve().then(() => (h4(),K6)),u=g(S0),r=u.server.map((F0)=>F0.content),l=S0;for(let F0 of u.server)l=l.replace(F0.fullTag,"");let m={__filename:f.filePath,__dirname:I0.dirname(f.filePath),params:h??{}},{resetHead:c}=await Promise.resolve().then(() => (w4(),p9));c();for(let F0 of r)try{await i(F0,m,f.filePath)}catch(t0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",f.filePath,t0?.message||t0)}let Y0=new Set,$0=(F0)=>{if(!F0)return F0;if(I0.isAbsolute(F0))return F0;return I0.resolve(K,F0)},a={...n,...y0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)a.debug=!0;a.partialsDir=$0(a.partialsDir),a.componentsDir=$0(a.componentsDir),a.layoutsDir=$0(a.layoutsDir),a.storesDir=$0(a.storesDir||"stores");let _0;if(Z.profile){let F0=performance.now();_0=await d(l,m,f.filePath,a,Y0);let t0=performance.now()-F0,F6=I0.relative(K,f.filePath)||f.filePath;console.log(`[stx:profile] ${F6} \u2192 ${t0.toFixed(2)}ms`)}else _0=await d(l,m,f.filePath,a,Y0);if(!F)_0=await z0(_0);{let{interpolateScriptExpressions:F0}=await Promise.resolve().then(() => (r0(),$5));_0=_0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(t0,F6,V6)=>{if(!/function\s+__stx_setup_/.test(V6))return t0;return`<script${F6}>${F0(V6,m)}</script>`})}if(F)_0=G6(_0);return{route:f,content:_0}}catch(d){return console.error(`${R.red}Error building ${R.bright}${f.pattern}${R.reset}:`,d),null}},T=async()=>{M.clear(),O.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)O.set(f.pattern,h)}return M.size>0};if(console.log(`${R.blue}Building pages...${R.reset}`),!await T())return console.error(`${R.red}No pages were successfully built${R.reset}`),!1;await I6(K);let k=Y;try{if(k=await v4(Y),k!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${k} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let f=Z.hmrPort||k+1;Q=o5({wsPort:f,verbose:!1}),G=Q.start(f)}let b=(f,h)=>{let d=`<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>",`${d}</head>`);if(f.includes("<body"))return f.replace(/<body([^>]*)>/,`<body$1>${d}`);return d+f};console.log(`${R.blue}Starting server...${R.reset}`);let y=DS({port:k,async fetch(f){let h=new URL(f.url),d=U?.publicDir||"public",i=I0.join(K,d,h.pathname),n=I0.join(K,h.pathname),W0=I0.join(N,h.pathname),[z0,y0,S0]=await Promise.all([U4.promises.stat(i).catch(()=>null),U4.promises.stat(n).catch(()=>null),U4.promises.stat(W0).catch(()=>null)]);if(z0?.isFile())return kG(i);if(y0?.isFile())return kG(n);if(S0?.isFile())return kG(W0);if(h.pathname.startsWith("/_stx/component/")){let l=decodeURIComponent(h.pathname.slice(16));if(l)try{let m=`<${l} />`,c={...buildConfig,autoShell:!1},Y0=await processDirectives(m,{},I0.join(K,"components",`${l}.stx`),c,new Set);return new Response(Y0,{headers:{"Content-Type":"text/html"}})}catch(m){return new Response(`<div class="stx-async-error">${m.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(A)try{let l=await A.handleRequest(f);if(l.status!==404)return l}catch{}if(w[h.pathname])try{return await w[h.pathname](f)}catch(l){return new Response(JSON.stringify({error:l.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=y3(h.pathname,q);if(g){let l=M.get(g.route.pattern);if(g.route.isDynamic&&Object.keys(g.params).length>0){let m=await I(g.route,g.params);if(m)l=m}if(l){let m=l9();if(m.validate){if(!await m.validate({params:g.params})){let $0=await E(404);if($0){let a=$0;if(a=await E0(a,K),J)a=u1(a,G);return new Response(a,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(m.middleware){let Y0=W7(h.pathname,g.params,m,h.search),$0=K7(Y0,null,f),a=await B7(m.middleware,$0);if(a.redirect){let _0=a.redirect.path,F0=a.redirect.options.redirectCode||302,t0=new Headers(a.responseHeaders);return t0.set("Location",_0),new Response(null,{status:F0,headers:t0})}if(a.abort){let{statusCode:_0,message:F0}=a.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${_0}</title></head><body><h1>Error ${_0}</h1><p>${F0}</p></body></html>`,{status:_0,headers:{"Content-Type":"text/html"}})}if(Object.keys(a.state).length>0){let _0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(a.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;l.content=l.content.replace("</head>",`${_0}</head>`)}}let c=l.content;if(F&&RJ(f)){if(Object.keys(g.params).length>0)c=b(c,g.params);c=await E0(c,K);let Y0=U?.router?.container||"main";return c=j7(c,Y0),new Response(c,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)c=q7(F,c);if(Object.keys(g.params).length>0)c=b(c,g.params);if(c=await E0(c,K),J)c=u1(c,G);if(Z.native)if(c.includes("<head>"))c=c.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else c="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+c;return new Response(c,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let l=H.map((c)=>c.route),m=y3(h.pathname,l);if(m){let c=O.get(m.route.pattern);if(c){let Y0=c.content;if(F)Y0=q7(F,Y0);if(Object.keys(m.params).length>0)Y0=b(Y0,m.params);if(Y0=await E0(Y0,K),J)Y0=u1(Y0,G);return new Response(Y0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:c}of j)if(c!=="/"&&h.pathname.startsWith(c)){let Y0=O.get(c)||O.get(c+"/");if(Y0){let $0=Y0.content;if(F)$0=q7(F,$0);if($0=await E0($0,K),J)$0=u1($0,G);return new Response($0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let u=M.get("/");if(u){let l=u.content;if(l=await E0(l,K),J)l=u1(l,G);if(Z.native)if(l.includes("<head>"))l=l.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 l="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+l;return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let r=await E(404);if(r){let l=r;if(l=await E0(l,K),J)l=u1(l,G);return new Response(l,{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}
15035
+ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g6(B.url.toString(),()=>{if(X)p6.watch(Q,{recursive:!0}).close();B.stop()}),X){console.log(`${R.blue}Watching for changes...${R.reset}`);let j=p6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${R.yellow}File ${R.bright}${O}${R.yellow} changed, rebuilding...${R.reset}`),M6.clear(),S6(),await W()});process.on("SIGINT",()=>{j.close(),B.stop(),process.exit(0)})}return!0}var CO=D(()=>{i4();m0();y4();K8();H0();n5()});var{serve:DS}=globalThis.Bun;import U6 from"fs";import I0 from"path";function kG($){let Z=Bun.file($),Y=I0.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 p7($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=I0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (h6(),K4)),U=await W(K),_=U.root&&U.root!=="."?I0.join(K,U.root):K,B=U.pagesDir||"pages",z=I0.join(_,B);if(!U6.existsSync(z))return console.error(`${R.red}Error: No '${B}' directory found in ${R.bright}${_}${R.reset}`),console.log(`${R.dim}Create a ${B}/ directory with .stx files to define your routes.${R.reset}`),console.log(`${R.dim}Example: ${B}/index.stx for the homepage.${R.reset}`),!1;let q=Q6(_);if(q.length===0)return console.error(`${R.red}Error: No page files found in ${R.bright}${z}${R.reset}`),!1;console.log(`${R.blue}Found ${R.bright}${q.length}${R.blue} routes${R.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:f,prefix:h}of j)if(U6.existsSync(f)){let d=Q6(I0.dirname(f),{pagesDir:I0.basename(f)});for(let i of d){let n=h==="/"?i.pattern:`${h}${i.pattern==="/"?"":i.pattern}`;H.push({route:{...i,pattern:n},prefix:h})}if(d.length>0)console.log(`${R.blue}Plugin pages: ${R.bright}${d.length}${R.blue} routes at ${R.cyan}${h}${R.reset}`)}let O=new Map,F=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=NJ(K,Z.stxOptions?.shell),L){if(F=await P3(L,Z.stxOptions||{}),F)console.log(`${R.blue}Using app shell: ${R.bright}${I0.relative(K,L)}${R.reset} ${R.dim}(deprecated: use layouts/default.stx instead)${R.reset}`)}}G7(),await _7(K);let V=U7();if(V.length>0)console.log(`${R.blue}Loaded ${R.bright}${V.length}${R.blue} middleware: ${R.dim}${V.join(", ")}${R.reset}`);let w={},A=null;try{let{loadStxConfig:f}=await Promise.resolve().then(() => (h6(),K4)),h=await f(K);if(h?.apiRouter)A=h?.apiRouter,console.log(`${R.blue}Using custom router for API handling${R.reset}`);if(h?.apiRoutes){w=h.apiRoutes;let d=Object.keys(w).length;if(d>0)console.log(`${R.blue}Loaded ${R.bright}${d} API route${d>1?"s":""}${R.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:d,loadChannels:i}=await Promise.resolve().then(() => (f3(),uJ)),n=h.broadcasting;await d(n);let W0=n.port??6001;console.log(`${R.magenta}Broadcasting on ${R.cyan}ws://localhost:${W0}/ws${R.reset}`);let z0=I0.join(process.cwd(),"channels.ts");if(U6.existsSync(z0))try{let y0=await i(z0);console.log(`${R.blue}Loaded ${R.bright}${y0} broadcast channel${y0!==1?"s":""}${R.blue} from channels.ts${R.reset}`)}catch(y0){console.warn(`${R.yellow}Failed to load channels.ts: ${y0.message}${R.reset}`)}}catch(d){console.warn(`${R.yellow}Broadcasting failed to start: ${d.message}${R.reset}`)}}catch{}let N=I0.join(K,".stx/output");U6.mkdirSync(N,{recursive:!0});let M=new Map,E=async(f)=>{let h=MJ(z,f);if(!h)return null;try{let d=await Bun.build({entrypoints:[h],outdir:N,plugins:[h$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!d.success)return null;let i=d.outputs.find((n)=>n.path.endsWith(".html"));if(!i)return null;return await Bun.file(i.path).text()}catch{return null}},I=async(f,h)=>{try{let{processDirectives:d,extractVariables:i,defaultConfig:n,loadStxConfig:W0,injectRouterScript:z0}=await Promise.resolve().then(() => (h6(),K4)),y0=await W0(K),S0=await Bun.file(f.filePath).text(),{classifyAllScripts:g}=await Promise.resolve().then(() => (h6(),K4)),u=g(S0),r=u.server.map((F0)=>F0.content),l=S0;for(let F0 of u.server)l=l.replace(F0.fullTag,"");let m={__filename:f.filePath,__dirname:I0.dirname(f.filePath),params:h??{}},{resetHead:c}=await Promise.resolve().then(() => (w6(),p9));c();for(let F0 of r)try{await i(F0,m,f.filePath)}catch(t0){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",f.filePath,t0?.message||t0)}let Y0=new Set,$0=(F0)=>{if(!F0)return F0;if(I0.isAbsolute(F0))return F0;return I0.resolve(K,F0)},a={...n,...y0,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)a.debug=!0;a.partialsDir=$0(a.partialsDir),a.componentsDir=$0(a.componentsDir),a.layoutsDir=$0(a.layoutsDir),a.storesDir=$0(a.storesDir||"stores");let _0;if(Z.profile){let F0=performance.now();_0=await d(l,m,f.filePath,a,Y0);let t0=performance.now()-F0,F4=I0.relative(K,f.filePath)||f.filePath;console.log(`[stx:profile] ${F4} \u2192 ${t0.toFixed(2)}ms`)}else _0=await d(l,m,f.filePath,a,Y0);if(!F)_0=await z0(_0);{let{interpolateScriptExpressions:F0}=await Promise.resolve().then(() => (r0(),$5));_0=_0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(t0,F4,V4)=>{if(!/function\s+__stx_setup_/.test(V4))return t0;return`<script${F4}>${F0(V4,m)}</script>`})}if(F)_0=G4(_0);return{route:f,content:_0}}catch(d){return console.error(`${R.red}Error building ${R.bright}${f.pattern}${R.reset}:`,d),null}},T=async()=>{M.clear(),O.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)O.set(f.pattern,h)}return M.size>0};if(console.log(`${R.blue}Building pages...${R.reset}`),!await T())return console.error(`${R.red}No pages were successfully built${R.reset}`),!1;await I4(K);let k=Y;try{if(k=await v6(Y),k!==Y)console.log(`${R.yellow}Port ${Y} is busy, using port ${k} instead${R.reset}`)}catch{return console.error(`${R.red}Could not find an available port${R.reset}`),!1}if(J){let f=Z.hmrPort||k+1;Q=o5({wsPort:f,verbose:!1}),G=Q.start(f)}let b=(f,h)=>{let d=`<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>",`${d}</head>`);if(f.includes("<body"))return f.replace(/<body([^>]*)>/,`<body$1>${d}`);return d+f};console.log(`${R.blue}Starting server...${R.reset}`);let y=DS({port:k,async fetch(f){let h=new URL(f.url),d=U?.publicDir||"public",i=I0.join(K,d,h.pathname),n=I0.join(K,h.pathname),W0=I0.join(N,h.pathname),[z0,y0,S0]=await Promise.all([U6.promises.stat(i).catch(()=>null),U6.promises.stat(n).catch(()=>null),U6.promises.stat(W0).catch(()=>null)]);if(z0?.isFile())return kG(i);if(y0?.isFile())return kG(n);if(S0?.isFile())return kG(W0);if(h.pathname.startsWith("/_stx/component/")){let l=decodeURIComponent(h.pathname.slice(16));if(l)try{let m=`<${l} />`,c={...buildConfig,autoShell:!1},Y0=await processDirectives(m,{},I0.join(K,"components",`${l}.stx`),c,new Set);return new Response(Y0,{headers:{"Content-Type":"text/html"}})}catch(m){return new Response(`<div class="stx-async-error">${m.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(A)try{let l=await A.handleRequest(f);if(l.status!==404)return l}catch{}if(w[h.pathname])try{return await w[h.pathname](f)}catch(l){return new Response(JSON.stringify({error:l.message}),{status:500,headers:{"Content-Type":"application/json"}})}let g=y3(h.pathname,q);if(g){let l=M.get(g.route.pattern);if(g.route.isDynamic&&Object.keys(g.params).length>0){let m=await I(g.route,g.params);if(m)l=m}if(l){let m=l9();if(m.validate){if(!await m.validate({params:g.params})){let $0=await E(404);if($0){let a=$0;if(a=await E0(a,K),J)a=u1(a,G);return new Response(a,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(m.middleware){let Y0=W7(h.pathname,g.params,m,h.search),$0=K7(Y0,null,f),a=await B7(m.middleware,$0);if(a.redirect){let _0=a.redirect.path,F0=a.redirect.options.redirectCode||302,t0=new Headers(a.responseHeaders);return t0.set("Location",_0),new Response(null,{status:F0,headers:t0})}if(a.abort){let{statusCode:_0,message:F0}=a.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${_0}</title></head><body><h1>Error ${_0}</h1><p>${F0}</p></body></html>`,{status:_0,headers:{"Content-Type":"text/html"}})}if(Object.keys(a.state).length>0){let _0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(a.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;l.content=l.content.replace("</head>",`${_0}</head>`)}}let c=l.content;if(F&&RJ(f)){if(Object.keys(g.params).length>0)c=b(c,g.params);c=await E0(c,K);let Y0=U?.router?.container||"main";return c=j7(c,Y0),new Response(c,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","Cache-Control":"no-store, no-cache, must-revalidate"}})}if(F)c=q7(F,c);if(Object.keys(g.params).length>0)c=b(c,g.params);if(c=await E0(c,K),J)c=u1(c,G);if(Z.native)if(c.includes("<head>"))c=c.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else c="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+c;return new Response(c,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let l=H.map((c)=>c.route),m=y3(h.pathname,l);if(m){let c=O.get(m.route.pattern);if(c){let Y0=c.content;if(F)Y0=q7(F,Y0);if(Object.keys(m.params).length>0)Y0=b(Y0,m.params);if(Y0=await E0(Y0,K),J)Y0=u1(Y0,G);return new Response(Y0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:c}of j)if(c!=="/"&&h.pathname.startsWith(c)){let Y0=O.get(c)||O.get(c+"/");if(Y0){let $0=Y0.content;if(F)$0=q7(F,$0);if($0=await E0($0,K),J)$0=u1($0,G);return new Response($0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let u=M.get("/");if(u){let l=u.content;if(l=await E0(l,K),J)l=u1(l,G);if(Z.native)if(l.includes("<head>"))l=l.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 l="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+l;return new Response(l,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let r=await E(404);if(r){let l=r;if(l=await E0(l,K),J)l=u1(l,G);return new Response(l,{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}
15034
15036
  ${f.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
15035
15037
  ${R.blue}stx${R.reset} ${R.green}${process.env.stx_VERSION||"v0.0.10"}${R.reset} ${R.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${R.reset}`),console.log(`
15036
15038
  ${R.bright}\u2192 ${R.cyan}http://localhost:${k}/${R.reset}`),J)console.log(`${R.dim} HMR: ws://localhost:${G}${R.reset}`);console.log(`
15037
15039
  ${R.yellow}Routes:${R.reset}`);let C=[...EJ(q,K)];for(let{route:f}of H)C.push(`${f.pattern}`);if(C.forEach((f,h)=>{let i=h===C.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${R.green}${i}${R.reset}${f}`)}),console.log(`
15038
- Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g4(y.url.toString(),()=>{if(Q)V$();y.stop()}),Z.native){let f,h=I0.join(z,"index.stx");if(U4.existsSync(h)){let i=await Bun.file(h).text();f=j3(i)}let d=U?.app?.window??{};await O$(k,{title:U?.app?.head?.title||I0.basename(K)||"stx App",width:d.width,height:d.height,darkMode:d.darkMode,hotReload:d.hotReload,nativeSidebar:!!f,sidebarConfig:f})}if(X){console.log(`${R.blue}Watching for changes...${R.reset}`);let f=(i)=>{return i.startsWith("public/")||i.startsWith("public\\")},h=(i)=>{let n=i.toLowerCase();return n.endsWith(".stx")||n.endsWith(".html")||n.endsWith(".md")},d=U4.watch(K,{recursive:!0},async(i,n)=>{if(!n||s5(n))return;if(a5(n)){if(f(n)){if(console.log(`${R.cyan}${n} changed${R.reset}`),J&&Q)Q.reload(n)}else if(h(n)){if(console.log(`${R.yellow}${n} changed, rebuilding...${R.reset}`),M4.clear(),S4(),L&&n){if(I0.resolve(K,n)===L||I0.basename(L)===n){let z0=await P3(L,Z.stxOptions||{});if(z0)F=z0}}if(await T(),await J5(K),J&&Q)Q.reload(n)}else if(console.log(`${R.yellow}${n} changed, rebuilding...${R.reset}`),M4.clear(),S4(),await T(),J&&Q)Q.reload(n)}else if(r5(n)){if(console.log(`${R.cyan}CSS ${n} changed${R.reset}`),J&&Q)Q.updateCss(n)}});process.on("SIGINT",()=>{if(d.close(),Q)V$();y.stop(),process.exit(0)})}return!0}var PO=D(()=>{H7();y6();K8();O7();b3();w4();H0();n5()});var DG=D(()=>{QJ();bO();CO();PO()});var gO={};e(gO,{runPwaAudit:()=>kS,formatAuditResult:()=>SS,calculateAuditResult:()=>vO,auditConfig:()=>yO,auditBuildOutput:()=>xO});import H6 from"fs";import W8 from"path";function yO($){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 xO($){let Z=[],Y=W8.join($,"manifest.json"),X=H6.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(H6.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=W8.join($,"sw.js"),Q=H6.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=W8.join($,"offline.html"),K=H6.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=W8.join($,"pwa-icons");if(H6.existsSync(W)){let _=H6.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 vO($){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 kS($,Z){let Y=yO($),X=Z&&H6.existsSync(Z)?xO(Z):[];return vO([...Y,...X])}function SS($){let Z=[];Z.push(`
15040
+ Press ${R.cyan}h${R.reset} + ${R.cyan}Enter${R.reset} to show shortcuts`),g6(y.url.toString(),()=>{if(Q)V$();y.stop()}),Z.native){let f,h=I0.join(z,"index.stx");if(U6.existsSync(h)){let i=await Bun.file(h).text();f=j3(i)}let d=U?.app?.window??{};await O$(k,{title:U?.app?.head?.title||I0.basename(K)||"stx App",width:d.width,height:d.height,darkMode:d.darkMode,hotReload:d.hotReload,nativeSidebar:!!f,sidebarConfig:f})}if(X){console.log(`${R.blue}Watching for changes...${R.reset}`);let f=(i)=>{return i.startsWith("public/")||i.startsWith("public\\")},h=(i)=>{let n=i.toLowerCase();return n.endsWith(".stx")||n.endsWith(".html")||n.endsWith(".md")},d=U6.watch(K,{recursive:!0},async(i,n)=>{if(!n||s5(n))return;if(a5(n)){if(f(n)){if(console.log(`${R.cyan}${n} changed${R.reset}`),J&&Q)Q.reload(n)}else if(h(n)){if(console.log(`${R.yellow}${n} changed, rebuilding...${R.reset}`),M6.clear(),S6(),L&&n){if(I0.resolve(K,n)===L||I0.basename(L)===n){let z0=await P3(L,Z.stxOptions||{});if(z0)F=z0}}if(await T(),await J5(K),J&&Q)Q.reload(n)}else if(console.log(`${R.yellow}${n} changed, rebuilding...${R.reset}`),M6.clear(),S6(),await T(),J&&Q)Q.reload(n)}else if(r5(n)){if(console.log(`${R.cyan}CSS ${n} changed${R.reset}`),J&&Q)Q.updateCss(n)}});process.on("SIGINT",()=>{if(d.close(),Q)V$();y.stop(),process.exit(0)})}return!0}var PO=D(()=>{H7();y4();K8();O7();b3();w6();H0();n5()});var DG=D(()=>{QJ();bO();CO();PO()});var gO={};e(gO,{runPwaAudit:()=>kS,formatAuditResult:()=>SS,calculateAuditResult:()=>vO,auditConfig:()=>yO,auditBuildOutput:()=>xO});import H4 from"fs";import W8 from"path";function yO($){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 xO($){let Z=[],Y=W8.join($,"manifest.json"),X=H4.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(H4.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=W8.join($,"sw.js"),Q=H4.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=W8.join($,"offline.html"),K=H4.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=W8.join($,"pwa-icons");if(H4.existsSync(W)){let _=H4.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 vO($){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 kS($,Z){let Y=yO($),X=Z&&H4.existsSync(Z)?xO(Z):[];return vO([...Y,...X])}function SS($){let Z=[];Z.push(`
15039
15041
  === PWA Audit Report ===
15040
15042
  `);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}
15041
15043
  `);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(`
@@ -16725,7 +16727,7 @@ ${Y}`);return Y+$}var iO=()=>{};function aO($,Z={}){let{classPrefix:Y="craft"}=Z
16725
16727
  </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">
16726
16728
  ${X?`<div class="craft-alert-title">${X}</div>`:""}
16727
16729
  <div class="craft-alert-content">${Z}</div>
16728
- </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 XL={};e(XL,{getAvailableTargets:()=>ZL,getAvailableFormats:()=>YL,default:()=>Fb,buildNative:()=>$L});import{existsSync as tO,mkdirSync as A1,copyFileSync as e7,chmodSync as O6}from"fs";import{join as o,basename as Xb}from"path";import{spawn as q8,execSync as Jb}from"child_process";import{tmpdir as eO,homedir as oO,platform as Qb}from"os";async function $L($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||t7(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||t7(),X=$.format||zb(Y),J=$.output||o(process.cwd(),"dist","native");if(!tO(J))A1(J,{recursive:!0});let Q=await Bun.file($.input).text();if(Q=pO(Q,{debug:$.verbose}),Q=aO(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${rO}
16730
+ </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 XL={};e(XL,{getAvailableTargets:()=>ZL,getAvailableFormats:()=>YL,default:()=>Fb,buildNative:()=>$L});import{existsSync as tO,mkdirSync as A1,copyFileSync as e7,chmodSync as O4}from"fs";import{join as o,basename as Xb}from"path";import{spawn as q8,execSync as Jb}from"child_process";import{tmpdir as eO,homedir as oO,platform as Qb}from"os";async function $L($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||t7(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||t7(),X=$.format||zb(Y),J=$.output||o(process.cwd(),"dist","native");if(!tO(J))A1(J,{recursive:!0});let Q=await Bun.file($.input).text();if(Q=pO(Q,{debug:$.verbose}),Q=aO(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${rO}
16729
16731
  </head>`)}let G=$.name||Xb($.input,".stx"),K=$.version||"1.0.0",W=$.craftPath||await Bb();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 Gb(Q,G,K,J,X,$,W);break;case"windows":U=await Kb(Q,G,K,J,X,$,W);break;case"linux":U=await Wb(Q,G,K,J,X,$,W);break;case"ios":U=await Ub(Q,G,K,J,$,W);break;case"android":U=await _b(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||t7(),format:$.format||"app",error:Y.message,duration:Date.now()-Z}}}async function Gb($,Z,Y,X,J,Q,G){let K=Q.bundleId||`com.stx.${Z.toLowerCase().replace(/[^a-z0-9]/g,"")}`,W=o(X,`${Z}.app`),U=o(W,"Contents"),_=o(U,"MacOS"),B=o(U,"Resources");A1(_,{recursive:!0}),A1(B,{recursive:!0});let z=o(B,"index.html");await Bun.write(z,$);let q="";if(Q.sidebar?.enabled&&Q.sidebar?.config)q=o(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
16730
16732
  DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
16731
16733
  RESOURCES="$DIR/../Resources"
@@ -16738,8 +16740,8 @@ RESOURCES="$DIR/../Resources"
16738
16740
  ${Q.window?.frameless?"--frameless":""} \\
16739
16741
  ${Q.window?.alwaysOnTop?"--always-on-top":""} \\
16740
16742
  ${j}
16741
- `,O=o(_,Z);await Bun.write(O,H),O6(O,493);let F=o(_,"craft");try{e7(G,F),O6(F,493)}catch{let V=`#!/bin/bash
16742
- exec "${G}" "$@"`;await Bun.write(F,V),O6(F,493)}let L=`<?xml version="1.0" encoding="UTF-8"?>
16743
+ `,O=o(_,Z);await Bun.write(O,H),O4(O,493);let F=o(_,"craft");try{e7(G,F),O4(F,493)}catch{let V=`#!/bin/bash
16744
+ exec "${G}" "$@"`;await Bun.write(F,V),O4(F,493)}let L=`<?xml version="1.0" encoding="UTF-8"?>
16743
16745
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
16744
16746
  <plist version="1.0">
16745
16747
  <dict>
@@ -16784,7 +16786,7 @@ DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
16784
16786
  --height ${Q.window?.height||800} \\
16785
16787
  ${Q.systemTray?"--system-tray":""} \\
16786
16788
  ${Q.devTools?"--dev-tools":""}
16787
- `,_=o(K,Z.toLowerCase());await Bun.write(_,U),O6(_,493);let B=`[Desktop Entry]
16789
+ `,_=o(K,Z.toLowerCase());await Bun.write(_,U),O4(_,493);let B=`[Desktop Entry]
16788
16790
  Type=Application
16789
16791
  Name=${Z}
16790
16792
  Exec=${_}
@@ -16792,7 +16794,7 @@ Terminal=false
16792
16794
  Categories=Utility;
16793
16795
  `;if(await Bun.write(o(K,`${Z.toLowerCase()}.desktop`),B),J==="deb"){let z=o(X,`${Z.toLowerCase()}_${Y}_amd64.deb`),q=await Hb(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=o(X,`${Z}-${Y}-x86_64.AppImage`),q=await Ob(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 Ub($,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 _b($,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 Bb(){let $=[o(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft-minimal"),o(process.cwd(),"../craft/packages/zig/zig-out/bin/craft-minimal"),o(oO(),"Code/craft/packages/zig/zig-out/bin/craft-minimal"),"/usr/local/bin/craft","/usr/bin/craft",o(oO(),".local/bin/craft"),o(process.env.LOCALAPPDATA||"","craft","craft.exe"),o(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let Z of $)if(await Bun.file(Z).exists())return Z;try{let Y=Jb("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
16794
16796
  `)[0];if(Y&&await Bun.file(Y).exists())return Y}catch{}return null}function t7(){switch(Qb()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function zb($){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 qb($,Z,Y){return new Promise((X)=>{let J=q8("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 jb($,Z){return new Promise((Y)=>{let X=q8("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 Hb($,Z,Y,X,J){return new Promise((Q)=>{try{let G=o(eO(),`stx-deb-${Date.now()}`),K=o(G,"DEBIAN"),W=o(G,"usr","bin"),U=o(G,"usr","share","applications"),_=o(G,"usr","share",Y.toLowerCase());A1(K,{recursive:!0}),A1(W,{recursive:!0}),A1(U,{recursive:!0}),A1(_,{recursive:!0});let B=s("fs").readdirSync($);for(let H of B)e7(o($,H),o(_,H));let z=`#!/bin/bash
16795
- exec /usr/share/${Y.toLowerCase()}/${Y.toLowerCase()} "$@"`;s("fs").writeFileSync(o(W,Y.toLowerCase()),z),O6(o(W,Y.toLowerCase()),493);let q=`Package: ${Y.toLowerCase()}
16797
+ exec /usr/share/${Y.toLowerCase()}/${Y.toLowerCase()} "$@"`;s("fs").writeFileSync(o(W,Y.toLowerCase()),z),O4(o(W,Y.toLowerCase()),493);let q=`Package: ${Y.toLowerCase()}
16796
16798
  Version: ${X}
16797
16799
  Section: utils
16798
16800
  Priority: optional
@@ -16805,14 +16807,14 @@ SELF=$(readlink -f "$0")
16805
16807
  HERE=\${SELF%/*}
16806
16808
  export PATH="\${HERE}/usr/bin:\${PATH}"
16807
16809
  exec "\${HERE}/usr/share/${Y.toLowerCase()}/${Y.toLowerCase()}" "$@"
16808
- `;s("fs").writeFileSync(o(G,"AppRun"),z),O6(o(G,"AppRun"),493);let q=`[Desktop Entry]
16810
+ `;s("fs").writeFileSync(o(G,"AppRun"),z),O4(o(G,"AppRun"),493);let q=`[Desktop Entry]
16809
16811
  Type=Application
16810
16812
  Name=${Y}
16811
16813
  Exec=${Y.toLowerCase()}
16812
16814
  Terminal=false
16813
16815
  Categories=Utility;
16814
16816
  Icon=${Y.toLowerCase()}
16815
- `;s("fs").writeFileSync(o(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(s("fs").writeFileSync(o(G,`${Y.toLowerCase()}.png`),j),X.icon&&tO(X.icon))e7(X.icon,o(G,`${Y.toLowerCase()}.png`));let H=q8("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if(s("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)O6(Z,493),J({success:!0});else J({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(O)=>{s("fs").rmSync(Q,{recursive:!0,force:!0}),J({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){J({success:!1,error:Q.message})}})}function ZL(){return[t7()]}function YL($){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 Lb,Fb;var JL=D(()=>{iO();sO();Lb={buildNative:$L,getAvailableTargets:ZL,getAvailableFormats:YL,detectPlatform:t7},Fb=Lb});function $9($,Z){return`${Vb[Z]}${$}\x1B[0m`}function GL($,Z){return`${Ab[Z]}${$}\x1B[0m`}function Z9(){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")+k1(" \uD83D\uDCD6 STX Story ")+i0("\u2551")),console.log(i0(" \u2551")+H8(" 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 yG($,Z){if(console.log(k1(" Server running at:")),console.log(""),console.log(` ${H8("\u279C")} ${k1("Local:")} ${i0($)}`),Z)console.log(` ${H8("\u279C")} ${k1("Network:")} ${i0(Z)}`);console.log("")}function Y9($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?j8:PG;console.log(` ${Y(Z)} Found ${k1(String($))} story ${$===1?"file":"files"}`)}function KL($,Z){if(console.log(""),console.log(` ${QL("\u2717")} ${k1(QL("Error:"))} ${$}`),Z)console.log(` ${H8(Z)}`);console.log("")}function u$($){console.log(` ${PG("\u26A0")} ${PG("Warning:")} ${$}`)}function WL($){console.log(` ${wb("\u2139")} ${$}`)}function UL($,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")+k1(" 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(` ${j8("\u2713")} Stories: ${k1(String($))}`),console.log(` ${j8("\u2713")} Output: ${k1(Z)}`),console.log(` ${j8("\u2713")} Time: ${k1(`${Y}ms`)}`),console.log("")}function xG(){console.log(""),console.log(k1(" 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 Vb,Ab,QL=($)=>$9($,"red"),j8=($)=>$9($,"green"),PG=($)=>$9($,"yellow"),wb=($)=>$9($,"blue"),i0=($)=>$9($,"cyan"),k1=($)=>GL($,"bold"),H8=($)=>GL($,"dim");var O8=D(()=>{Vb={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"},Ab={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import _L from"fs";import vG from"path";function BL($,Z){let Y=[vG.join($.root,"stx.config.ts"),vG.join($.root,"stx.config.js"),vG.join($.root,"stx.config.mjs")],X=Z.debounceMs??300,J=null,Q=[];for(let G of Y)try{if(!_L.existsSync(G))continue;let K=_L.watch(G,(W)=>{if(W==="change"){if(J)clearTimeout(J);J=setTimeout(async()=>{WL("Config file changed, restarting...");try{await Z.onChange()}catch(U){u$(`Failed to restart: ${U}`)}},X)}});Q.push(K)}catch{}return{stop(){if(J)clearTimeout(J);for(let G of Q)G.close()}}}var zL=D(()=>{O8()});function OL($){let Z={...Nb,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...HL,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??qL,backgroundPresets:Z.backgroundPresets??jL,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var qL,jL,HL,Nb;var LL=D(()=>{qL=[{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}],jL=[{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"}],HL={file:"title",order:"asc",groups:[]},Nb={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:HL,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:qL,backgroundPresets:jL,autoApplyContrastColor:!1,port:6006}});var FL={};e(FL,{updateContextTree:()=>l$,updateContextStoryFiles:()=>c$,createContext:()=>m$});import Rb from"path";async function m$($){let Z=$.root??process.cwd(),Y;try{let G=await import(Rb.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let X={...Y,...$.config},J=OL(X);return{root:Z,config:J,storyFiles:[],tree:void 0,mode:$.mode}}function c$($,Z){$.storyFiles=Z}function l$($,Z){$.tree=Z}var X9=D(()=>{LL()});import gG from"fs";import VL from"path";class fG{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=VL.join($,Mb),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=gG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Eb,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=VL.dirname(this.storagePath);if(await gG.promises.mkdir($,{recursive:!0}),this.storage.events.length>AL)this.storage.events=this.storage.events.slice(-AL);await gG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Tb(),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 Tb(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Mb=".stx/story/analytics.json",Eb=1,AL=1e4;var wL=()=>{};import hG from"fs";import NL from"path";class dG{storage;storagePath;dirty=!1;constructor($){this.storagePath=NL.join($,Ib),this.storage=this.loadStorage()}loadStorage(){try{let $=hG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Db,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=NL.dirname(this.storagePath);await hG.promises.mkdir($,{recursive:!0}),await hG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,X={}){let J={id:kb(),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 kb(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Ib=".stx/story/bookmarks.json",Db=1;var RL=()=>{};import uG from"fs";import J9 from"path";async function Q9($){let{root:Z,config:Y}=$,X=[],J=await Sb(Z,Y.storyMatch,Y.storyIgnored);for(let Q of J){let G=J9.resolve(Z,Q),K=mG(Q,G);X.push(K)}return X}async function Sb($,Z,Y){let X=[];async function J(Q,G){let K=await uG.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=J9.join(Q,W.name),_=J9.relative(G,U);if(ML(_,Y))continue;if(W.isDirectory())await J(U,G);else if(W.isFile()){if(EL(_,Z))X.push(_)}}}return await J($,$),X}function ML($,Z){for(let Y of Z)if(TL($,Y))return!0;return!1}function EL($,Z){for(let Y of Z)if(TL($,Y))return!0;return!1}function TL($,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 mG($,Z){let Y=J9.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 IL($,Z){let{root:Y,config:X}=$,J=[],Q=uG.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!EL(W,X.storyMatch))return;if(ML(W,X.storyIgnored))return;let U=J9.resolve(Y,W);try{await uG.promises.access(U);let _=mG(W,U);Z(G==="rename"?"add":"change",_)}catch{let _=mG(W,U);Z("unlink",_)}});return J.push(Q),()=>{for(let G of J)G.close()}}var cG=()=>{};function bb($,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 G9($,Z){for(let G of Z)G.treePath=bb($,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=Cb(K,Y,X);Pb(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(...lG(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:lG(G.treeObject,J)});return Q}function Cb($,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 Pb($,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 lG($,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:lG(J,Z)});return Y.sort((X,J)=>Z(X.title,J.title)),Y}function DL(){return{open($){L8.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){L8.delete($)},message($,Z){}}}function pG($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of L8)try{Y.send(Z)}catch{L8.delete(Y)}}function kL($,Z){pG({type:"story-update",data:{storyId:$,...Z}})}function SL($,Z){pG({type:"story-add",data:{storyId:$,...Z}})}function bL($){pG({type:"story-remove",data:{storyId:$}})}function CL($){return`
16817
+ `;s("fs").writeFileSync(o(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(s("fs").writeFileSync(o(G,`${Y.toLowerCase()}.png`),j),X.icon&&tO(X.icon))e7(X.icon,o(G,`${Y.toLowerCase()}.png`));let H=q8("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if(s("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)O4(Z,493),J({success:!0});else J({success:!1,error:`appimagetool exited with code ${O}. Install from https://appimage.github.io/appimagetool/`})}),H.on("error",(O)=>{s("fs").rmSync(Q,{recursive:!0,force:!0}),J({success:!1,error:`appimagetool not found: ${O.message}`})})}catch(Q){J({success:!1,error:Q.message})}})}function ZL(){return[t7()]}function YL($){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 Lb,Fb;var JL=D(()=>{iO();sO();Lb={buildNative:$L,getAvailableTargets:ZL,getAvailableFormats:YL,detectPlatform:t7},Fb=Lb});function $9($,Z){return`${Vb[Z]}${$}\x1B[0m`}function GL($,Z){return`${Ab[Z]}${$}\x1B[0m`}function Z9(){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")+k1(" \uD83D\uDCD6 STX Story ")+i0("\u2551")),console.log(i0(" \u2551")+H8(" 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 yG($,Z){if(console.log(k1(" Server running at:")),console.log(""),console.log(` ${H8("\u279C")} ${k1("Local:")} ${i0($)}`),Z)console.log(` ${H8("\u279C")} ${k1("Network:")} ${i0(Z)}`);console.log("")}function Y9($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?j8:PG;console.log(` ${Y(Z)} Found ${k1(String($))} story ${$===1?"file":"files"}`)}function KL($,Z){if(console.log(""),console.log(` ${QL("\u2717")} ${k1(QL("Error:"))} ${$}`),Z)console.log(` ${H8(Z)}`);console.log("")}function u$($){console.log(` ${PG("\u26A0")} ${PG("Warning:")} ${$}`)}function WL($){console.log(` ${wb("\u2139")} ${$}`)}function UL($,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")+k1(" 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(` ${j8("\u2713")} Stories: ${k1(String($))}`),console.log(` ${j8("\u2713")} Output: ${k1(Z)}`),console.log(` ${j8("\u2713")} Time: ${k1(`${Y}ms`)}`),console.log("")}function xG(){console.log(""),console.log(k1(" 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 Vb,Ab,QL=($)=>$9($,"red"),j8=($)=>$9($,"green"),PG=($)=>$9($,"yellow"),wb=($)=>$9($,"blue"),i0=($)=>$9($,"cyan"),k1=($)=>GL($,"bold"),H8=($)=>GL($,"dim");var O8=D(()=>{Vb={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"},Ab={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import _L from"fs";import vG from"path";function BL($,Z){let Y=[vG.join($.root,"stx.config.ts"),vG.join($.root,"stx.config.js"),vG.join($.root,"stx.config.mjs")],X=Z.debounceMs??300,J=null,Q=[];for(let G of Y)try{if(!_L.existsSync(G))continue;let K=_L.watch(G,(W)=>{if(W==="change"){if(J)clearTimeout(J);J=setTimeout(async()=>{WL("Config file changed, restarting...");try{await Z.onChange()}catch(U){u$(`Failed to restart: ${U}`)}},X)}});Q.push(K)}catch{}return{stop(){if(J)clearTimeout(J);for(let G of Q)G.close()}}}var zL=D(()=>{O8()});function OL($){let Z={...Nb,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...HL,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??qL,backgroundPresets:Z.backgroundPresets??jL,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var qL,jL,HL,Nb;var LL=D(()=>{qL=[{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}],jL=[{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"}],HL={file:"title",order:"asc",groups:[]},Nb={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:HL,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:qL,backgroundPresets:jL,autoApplyContrastColor:!1,port:6006}});var FL={};e(FL,{updateContextTree:()=>l$,updateContextStoryFiles:()=>c$,createContext:()=>m$});import Rb from"path";async function m$($){let Z=$.root??process.cwd(),Y;try{let G=await import(Rb.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let X={...Y,...$.config},J=OL(X);return{root:Z,config:J,storyFiles:[],tree:void 0,mode:$.mode}}function c$($,Z){$.storyFiles=Z}function l$($,Z){$.tree=Z}var X9=D(()=>{LL()});import gG from"fs";import VL from"path";class fG{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=VL.join($,Mb),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=gG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Eb,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=VL.dirname(this.storagePath);if(await gG.promises.mkdir($,{recursive:!0}),this.storage.events.length>AL)this.storage.events=this.storage.events.slice(-AL);await gG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Tb(),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 Tb(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Mb=".stx/story/analytics.json",Eb=1,AL=1e4;var wL=()=>{};import hG from"fs";import NL from"path";class dG{storage;storagePath;dirty=!1;constructor($){this.storagePath=NL.join($,Ib),this.storage=this.loadStorage()}loadStorage(){try{let $=hG.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Db,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=NL.dirname(this.storagePath);await hG.promises.mkdir($,{recursive:!0}),await hG.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,X={}){let J={id:kb(),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 kb(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Ib=".stx/story/bookmarks.json",Db=1;var RL=()=>{};import uG from"fs";import J9 from"path";async function Q9($){let{root:Z,config:Y}=$,X=[],J=await Sb(Z,Y.storyMatch,Y.storyIgnored);for(let Q of J){let G=J9.resolve(Z,Q),K=mG(Q,G);X.push(K)}return X}async function Sb($,Z,Y){let X=[];async function J(Q,G){let K=await uG.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=J9.join(Q,W.name),_=J9.relative(G,U);if(ML(_,Y))continue;if(W.isDirectory())await J(U,G);else if(W.isFile()){if(EL(_,Z))X.push(_)}}}return await J($,$),X}function ML($,Z){for(let Y of Z)if(TL($,Y))return!0;return!1}function EL($,Z){for(let Y of Z)if(TL($,Y))return!0;return!1}function TL($,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 mG($,Z){let Y=J9.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 IL($,Z){let{root:Y,config:X}=$,J=[],Q=uG.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!EL(W,X.storyMatch))return;if(ML(W,X.storyIgnored))return;let U=J9.resolve(Y,W);try{await uG.promises.access(U);let _=mG(W,U);Z(G==="rename"?"add":"change",_)}catch{let _=mG(W,U);Z("unlink",_)}});return J.push(Q),()=>{for(let G of J)G.close()}}var cG=()=>{};function bb($,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 G9($,Z){for(let G of Z)G.treePath=bb($,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=Cb(K,Y,X);Pb(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(...lG(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:lG(G.treeObject,J)});return Q}function Cb($,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 Pb($,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 lG($,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:lG(J,Z)});return Y.sort((X,J)=>Z(X.title,J.title)),Y}function DL(){return{open($){L8.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){L8.delete($)},message($,Z){}}}function pG($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of L8)try{Y.send(Z)}catch{L8.delete(Y)}}function kL($,Z){pG({type:"story-update",data:{storyId:$,...Z}})}function SL($,Z){pG({type:"story-add",data:{storyId:$,...Z}})}function bL($){pG({type:"story-remove",data:{storyId:$}})}function CL($){return`
16816
16818
  <script>
16817
16819
  (function() {
16818
16820
  const ws = new WebSocket('${$}');
@@ -18090,7 +18092,7 @@ else {
18090
18092
  ${vL()}
18091
18093
  </body>
18092
18094
  </html>`}var $F=D(()=>{wL();RL();cG();X9();PL();hL();cL();pL();tL()});import cb from"fs";import lb from"path";async function ZF($){let Z=$.config.setupFile;if(!Z)return;let Y=lb.resolve($.root,Z);try{await cb.promises.access(Y)}catch{return}let X={storyContext:$,registerComponent:(J,Q)=>{pb.set(J,Q)},addCSS:(J)=>{ib.push(J)},addScript:(J)=>{nb.push(J)},setState:(J,Q)=>{rb.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 pb,ib,nb,rb;var YF=D(()=>{pb=new Map,ib=[],nb=[],rb=new Map});var JF={};e(JF,{devCommand:()=>XF,dev:()=>ab});async function XF($={}){Z9();let Z=await m$({mode:"dev"});if(!Z.config.enabled){u$("Story feature is disabled in config.");return}await ZF(Z);let Y=$.port??Z.config.port,X,J=async()=>{X=await eL(Z,{port:Y,open:$.open,host:$.host}),Y9(Z.storyFiles.length),yG(X.url),xG()};await J();let Q=BL(Z,{onChange:async()=>{await X.close();let K=await m$({mode:"dev"});Object.assign(Z,K),await J()}}),G=async()=>{console.log(`
18093
- `),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":xG();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{KL("Failed to open browser")}break;case"r":await X.close(),await J();break;case"c":console.clear(),Z9(),Y9(Z.storyFiles.length),yG(X.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var ab;var QF=D(()=>{zL();X9();O8();$F();YF();ab=XF});function GF($){W9=[];for(let Z of $.storyFiles)if(W9.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),W9.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)W9.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function KF(){return JSON.stringify(W9)}var W9;var WF=D(()=>{W9=[]});var _F={};e(_F,{buildCommand:()=>UF,build:()=>ob});import i4 from"fs";import L6 from"path";async function UF($={}){let Z=Date.now();Z9();let Y=await m$({mode:"build"});if(!Y.config.enabled){u$("Story feature is disabled in config.");return}let X=await Q9(Y);c$(Y,X);let J=G9(Y.config,X);l$(Y,J),Y9(X.length);let Q=$.outDir??Y.config.outDir,G=L6.resolve(Y.root,Q);await i4.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=sb(Y);await i4.promises.writeFile(L6.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 i4.promises.writeFile(L6.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await i4.promises.writeFile(L6.join(G,"config.json"),JSON.stringify(U,null,2));let _=L6.join(G,"stories");await i4.promises.mkdir(_,{recursive:!0});for(let q of X){let j=await i4.promises.readFile(q.path,"utf-8");await i4.promises.writeFile(L6.join(_,`${q.id}.stx`),j)}GF(Y);let B=KF();await i4.promises.writeFile(L6.join(G,"search-index.json"),B);let z=Date.now()-Z;UL(X.length,Q,z)}function sb($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
18095
+ `),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":xG();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{KL("Failed to open browser")}break;case"r":await X.close(),await J();break;case"c":console.clear(),Z9(),Y9(Z.storyFiles.length),yG(X.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var ab;var QF=D(()=>{zL();X9();O8();$F();YF();ab=XF});function GF($){W9=[];for(let Z of $.storyFiles)if(W9.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),W9.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)W9.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function KF(){return JSON.stringify(W9)}var W9;var WF=D(()=>{W9=[]});var _F={};e(_F,{buildCommand:()=>UF,build:()=>ob});import i6 from"fs";import L4 from"path";async function UF($={}){let Z=Date.now();Z9();let Y=await m$({mode:"build"});if(!Y.config.enabled){u$("Story feature is disabled in config.");return}let X=await Q9(Y);c$(Y,X);let J=G9(Y.config,X);l$(Y,J),Y9(X.length);let Q=$.outDir??Y.config.outDir,G=L4.resolve(Y.root,Q);await i6.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=sb(Y);await i6.promises.writeFile(L4.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 i6.promises.writeFile(L4.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await i6.promises.writeFile(L4.join(G,"config.json"),JSON.stringify(U,null,2));let _=L4.join(G,"stories");await i6.promises.mkdir(_,{recursive:!0});for(let q of X){let j=await i6.promises.readFile(q.path,"utf-8");await i6.promises.writeFile(L4.join(_,`${q.id}.stx`),j)}GF(Y);let B=KF();await i6.promises.writeFile(L4.join(G,"search-index.json"),B);let z=Date.now()-Z;UL(X.length,Q,z)}function sb($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
18094
18096
  <html lang="en">
18095
18097
  <head>
18096
18098
  <meta charset="UTF-8">
@@ -18205,12 +18207,12 @@ else {
18205
18207
  </script>
18206
18208
  </body>
18207
18209
  </html>`}var ob;var BF=D(()=>{cG();X9();O8();WF();ob=UF});var jF={};e(jF,{updateSnapshots:()=>eb,runVisualTests:()=>qF,runA11yTests:()=>JC,formatTestResults:()=>XC});import V8 from"fs";import zF from"path";async function qF($,Z={}){let Y=Date.now(),X={total:0,passed:0,failed:0,new:0,failures:[],duration:0},J=Z.snapshotDir||zF.join($.root,".stx","story","snapshots");await V8.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 tb(G,J,Z,X);return X.duration=Date.now()-Y,X}async function tb($,Z,Y,X){let J=$.story;if(!J)return;for(let Q of J.variants){X.total++;let G=zF.join(Z,`${$.id}-${Q.id}.snap`),K=$C(Q.source||""),W=await YC(G);if(Y.update||!W){let U={storyId:$.id,variantId:Q.id,component:$.fileName,timestamp:Date.now(),hash:K};if(await V8.promises.writeFile(G,JSON.stringify(U,null,2)),!W)X.new++;X.passed++}else try{let U=await V8.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:ZC(_.hash,K)})}catch(U){X.failed++,X.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:`Error reading snapshot: ${U}`})}}}async function eb($,Z={}){return(await qF($,{...Z,update:!0})).total}function $C($){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 ZC($,Z){if($===Z)return 0;let Y=Math.abs(Number.parseInt($,16)-Number.parseInt(Z,16));return Math.min(Y/1e6,1)}async function YC($){try{return await V8.promises.access($),!0}catch{return!1}}function XC($){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(`
18208
- `)}async function JC($,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 _9(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 HF=D(()=>{A6()});var TF={};e(TF,{default:()=>IC,createHotReloadServer:()=>EF,compileToNative:()=>LF,NATIVE_COMPONENTS:()=>eG});async function LF($,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||eG},J=typeof $==="string"?QC($):$,Q=KC(J.tree,X),G=jC(Q),K=X.treeShake?OC(Q,G):Q,W=new Map;if(X.target==="universal"){let q=["macos","windows","linux","ios","android"];for(let j of q){let H=sG(K,{...X,target:j});W.set(j,H)}}else{let q=sG(K,X);W.set(X.target,q)}let U=VC(K,X,W),_=AC(J,K,X),B={compilationTime:performance.now()-Y,totalComponents:oG(J.tree),nativeComponents:tG(K),webComponents:oG(J.tree)-tG(K),bundleSize:U.length,treeShakenSize:X.treeShake?LC(Q,K):U.length,warnings:[],errors:[]},z;if(X.sourceMaps)z=wC(J,K);return{code:U,platformCode:W,dependencies:G,manifest:_,sourceMaps:z,stats:B}}function QC($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),X=Y?Y[1]:$;return FF(X,Z),{id:RF(),hash:MF($),tree:Z,scripts:MC($),styles:EC($),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 FF($,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:GC(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});FF(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function GC($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,X;while((X=Y.exec($))!==null){let[,J,Q]=X;Z[J]=Q??!0}return Z}function KC($,Z){return VF($,Z)}function VF($,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=WC($.tag);let J={};if($.props)for(let[W,U]of Object.entries($.props))J[W]=UC(U);let Q=[];if($.children)for(let W of $.children)Q.push(VF(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=BC($);return{type:_C($,Y),zigType:X,props:J,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function WC($){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 UC($){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 _C($,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 BC($){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=zC(K);break;case"align-items":Y.alignItems=qC(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 zC($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function qC($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function jC($){let Z=[],Y=new Set;function X(J,Q){let G=J.id||RF();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:J.zigType,dependencies:Q?[Q]:[],size:AF(J),isStatic:HC(J)};Z.push(K);for(let W of J.children)X(W,G)}return X($),Z}function AF($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function HC($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function OC($,Z){return $}function LC($,Z){let Y=0;function X(J){Y+=AF(J);for(let Q of J.children)X(Q)}return X(Z),Y}function sG($,Z){switch(Z.format){case"zig":return OF($,Z);case"typescript":return FC($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return OF($,Z)}}function OF($,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(""),wF($,Y,0),Y.join(`
18210
+ `)}async function JC($,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 _9(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 HF=D(()=>{A4()});var TF={};e(TF,{default:()=>IC,createHotReloadServer:()=>EF,compileToNative:()=>LF,NATIVE_COMPONENTS:()=>eG});async function LF($,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||eG},J=typeof $==="string"?QC($):$,Q=KC(J.tree,X),G=jC(Q),K=X.treeShake?OC(Q,G):Q,W=new Map;if(X.target==="universal"){let q=["macos","windows","linux","ios","android"];for(let j of q){let H=sG(K,{...X,target:j});W.set(j,H)}}else{let q=sG(K,X);W.set(X.target,q)}let U=VC(K,X,W),_=AC(J,K,X),B={compilationTime:performance.now()-Y,totalComponents:oG(J.tree),nativeComponents:tG(K),webComponents:oG(J.tree)-tG(K),bundleSize:U.length,treeShakenSize:X.treeShake?LC(Q,K):U.length,warnings:[],errors:[]},z;if(X.sourceMaps)z=wC(J,K);return{code:U,platformCode:W,dependencies:G,manifest:_,sourceMaps:z,stats:B}}function QC($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),X=Y?Y[1]:$;return FF(X,Z),{id:RF(),hash:MF($),tree:Z,scripts:MC($),styles:EC($),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 FF($,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:GC(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});FF(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function GC($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,X;while((X=Y.exec($))!==null){let[,J,Q]=X;Z[J]=Q??!0}return Z}function KC($,Z){return VF($,Z)}function VF($,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=WC($.tag);let J={};if($.props)for(let[W,U]of Object.entries($.props))J[W]=UC(U);let Q=[];if($.children)for(let W of $.children)Q.push(VF(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=BC($);return{type:_C($,Y),zigType:X,props:J,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function WC($){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 UC($){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 _C($,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 BC($){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=zC(K);break;case"align-items":Y.alignItems=qC(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 zC($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function qC($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function jC($){let Z=[],Y=new Set;function X(J,Q){let G=J.id||RF();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:J.zigType,dependencies:Q?[Q]:[],size:AF(J),isStatic:HC(J)};Z.push(K);for(let W of J.children)X(W,G)}return X($),Z}function AF($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function HC($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function OC($,Z){return $}function LC($,Z){let Y=0;function X(J){Y+=AF(J);for(let Q of J.children)X(Q)}return X(Z),Y}function sG($,Z){switch(Z.format){case"zig":return OF($,Z);case"typescript":return FC($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return OF($,Z)}}function OF($,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(""),wF($,Y,0),Y.join(`
18209
18211
  `)}function wF($,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${RC(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 wF(G,Z,Y+1),Z.push(`${X} try ${J}.addChild(node_${Y+1});`)}if(Y===0)Z.push(` return ${J}.element();`),Z.push("}")}function FC($,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 "+NF($,1)+";"),Y.push("}"),Y.join(`
18210
18212
  `)}function NF($,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:""}"`:NF(K,Z+1)),G=Q.length>0?`,
18211
18213
  ${Y} [${Q.join(`,
18212
18214
  ${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function VC($,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(`
18213
- `)}return Y.get(Z.target)||sG($,Z)}function AC($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:MF(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 wC($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function RF(){return`id_${++NC}`}function MF($){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 RC($){return $.charAt(0).toUpperCase()+$.slice(1)}function MC($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function EC($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function oG($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=oG(Y);return Z}function tG($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=tG(Y);return Z}function EF($){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 eG,NC=0,TC,IC;var IF=D(()=>{eG=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"}]]);TC={compileToNative:LF,createHotReloadServer:EF,NATIVE_COMPONENTS:eG},IC=TC});import{spawn as SF}from"child_process";import k0 from"fs";import DC from"os";import t from"path";import x from"process";import{CLI as kC}from"@stacksjs/clapp";var n4="0.2.31";A6();DG();pJ();oJ();j4();rJ();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",q0=new kC("stx");function DF($){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 kF($){try{if(!k0.existsSync($)){let Y=t.dirname($),X=t.basename($);if(k0.existsSync(Y)){let Q=k0.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(k0.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 $K($){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 i$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),SC=($)=>$.endsWith(".stx")||$.endsWith(".md");function p$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);x.exit(Z)}async function bC($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(i$(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=t.join(DC.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",t.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...x.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=SF(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)}),x.on("SIGINT",()=>{console.log(`
18215
+ `)}return Y.get(Z.target)||sG($,Z)}function AC($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:MF(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 wC($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function RF(){return`id_${++NC}`}function MF($){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 RC($){return $.charAt(0).toUpperCase()+$.slice(1)}function MC($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function EC($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function oG($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=oG(Y);return Z}function tG($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=tG(Y);return Z}function EF($){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 eG,NC=0,TC,IC;var IF=D(()=>{eG=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"}]]);TC={compileToNative:LF,createHotReloadServer:EF,NATIVE_COMPONENTS:eG},IC=TC});import{spawn as SF}from"child_process";import k0 from"fs";import DC from"os";import t from"path";import x from"process";import{CLI as kC}from"@stacksjs/clapp";var n6="0.2.33";A4();DG();pJ();oJ();j6();rJ();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",q0=new kC("stx");function DF($){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 kF($){try{if(!k0.existsSync($)){let Y=t.dirname($),X=t.basename($);if(k0.existsSync(Y)){let Q=k0.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(k0.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 $K($){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 i$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),SC=($)=>$.endsWith(".stx")||$.endsWith(".md");function p$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);x.exit(Z)}async function bC($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(i$(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=t.join(DC.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",t.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...x.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=SF(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)}),x.on("SIGINT",()=>{console.log(`
18214
18216
  Test run interrupted`),K.kill("SIGINT"),x.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var CC=x.argv.length>=3&&(SC(x.argv[2])&&k0.existsSync(x.argv[2])||i$(x.argv[2]));if(CC){let $=x.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<x.argv.length;Y++){let X=x.argv[Y];if(X==="--port"&&Y+1<x.argv.length){let J=DF(x.argv[++Y]);if(!J.isValid)p$(J);Z.port=Number.parseInt(x.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<x.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=x.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(i$($))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=t.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(t.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: ${$}`),x.exit(1);if(!await l7(X,Z))x.exit(1)}catch(Y){console.error("Failed to process files:",Y),x.exit(1)}else c7($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),x.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 lJ(X))console.log("Documentation generated successfully."),x.exit(0);else console.error("Documentation generation failed."),x.exit(1)}catch(J){console.error("Error generating documentation:",J),x.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(`
18215
18217
  \uD83D\uDCDA Fetching available icon collections...
18216
18218
  `);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections:
@@ -18288,7 +18290,7 @@ Total: ${W} issues in ${K} files`),J.output){let U=`
18288
18290
  `),x.exit(1);console.log(" To preview locally:"),console.log(` cd ${J.out||"dist"} && npx serve
18289
18291
  `)}}catch(Q){console.error(`
18290
18292
  Build failed:`,Q instanceof Error?Q.message:String(Q)),x.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=t.resolve(X.output);if(!k0.existsSync(t.join(J,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),x.exit(1);let{startProductionServer:Q}=await Promise.resolve().then(() => (YQ(),nj));await Q({outputDir:J,port:Number.parseInt(X.port,10)||3000})}catch(J){console.error(`
18291
- Failed to start production server:`,J instanceof Error?J.message:String(J)),x.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(() => (F3(),Xq));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${n4}\x1B[0m`),J.init){console.log(`
18293
+ Failed to start production server:`,J instanceof Error?J.message:String(J)),x.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(() => (F3(),Xq));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${n6}\x1B[0m`),J.init){console.log(`
18292
18294
  \uD83D\uDCDD Initializing Netlify configuration...
18293
18295
  `);let U=await G({directory:X||x.cwd(),siteId:J.siteId});if(console.log(`\u2713 Created ${U.configPath}`),U.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
18294
18296
  You can now deploy with: stx deploy`);return}if(J.build!==!1){if(console.log(`
@@ -18300,7 +18302,7 @@ You can now deploy with: stx deploy`);return}if(J.build!==!1){if(console.log(`
18300
18302
  `),console.log(` ${J.dryRun?"Would deploy":"Draft URL"}: ${W.url}`),W.siteUrl)console.log(` Site URL: ${W.siteUrl}`);if(!J.dryRun)console.log(`
18301
18303
  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(`
18302
18304
  \u274C ${Q.message}`),x.exit(1);console.error(`
18303
- \u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),x.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(() => (S3(),qq)),W=await import("fs"),U=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${n4}\x1B[0m`),!await G())console.error(`
18305
+ \u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),x.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(() => (S3(),qq)),W=await import("fs"),U=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${n6}\x1B[0m`),!await G())console.error(`
18304
18306
  \u274C sharp is required for image optimization.`),console.log(`
18305
18307
  Install sharp with:`),console.log(" bun add sharp"),x.exit(1);let B=J.widths.split(",").map((L)=>Number.parseInt(L.trim(),10)).filter((L)=>!Number.isNaN(L)),z=J.formats.split(",").map((L)=>L.trim().toLowerCase()),q=Number.parseInt(J.quality,10)||80,j=J.placeholder,H=U.resolve(X);if(!W.existsSync(H))console.error(`
18306
18308
  \u274C Input directory not found: ${H}`),x.exit(1);if(!W.statSync(H).isDirectory())console.error(`
@@ -18313,13 +18315,13 @@ Would generate ~${w} image variants`);return}console.log(`
18313
18315
  `);let F=await Q(H,J.output,{widths:B,formats:z,quality:q,placeholder:j,verbose:J.verbose});if(console.log(`
18314
18316
  \u2713 Optimization complete!
18315
18317
  `),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(`
18316
- \u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),x.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(() => (lO(),cO)),W=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${n4}\x1B[0m`);let U=X||"dist",_=W.resolve(U);if(!(await import("fs")).existsSync(_))console.error(`
18318
+ \u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),x.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(() => (lO(),cO)),W=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${n6}\x1B[0m`);let U=X||"dist",_=W.resolve(U);if(!(await import("fs")).existsSync(_))console.error(`
18317
18319
  \u274C Directory not found: ${_}`),console.log("\nRun `stx build` first to generate build output."),x.exit(1);let z="html";if(J.json)z="json";else if(J.text)z="text";else if(J.markdown)z="markdown";console.log(`
18318
18320
  \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(`
18319
18321
  \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(`
18320
18322
  \u274C Bundle size (${G(q.stats.totalSize)}) exceeds threshold (${j})`),x.exit(1)}if(z==="html"){if(console.log(`
18321
18323
  \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(`
18322
- \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),x.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${n4} (${XQ})\x1B[0m`),J.timeout){let K=$K(J.timeout);if(!K.isValid)p$(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",()=>bC(Q,J))&&!J.watch)x.exit(1)}catch(Q){console.error("Error running tests:",Q),x.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 sJ(X,{force:J.force,template:J.template}))console.log(`
18324
+ \u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),x.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${n6} (${XQ})\x1B[0m`),J.timeout){let K=$K(J.timeout);if(!K.isValid)p$(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",()=>bC(Q,J))&&!J.watch)x.exit(1)}catch(Q){console.error("Error running tests:",Q),x.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 sJ(X,{force:J.force,template:J.template}))console.log(`
18323
18325
  \u2728 Successfully created file: ${X}`),console.log(`
18324
18326
  To view it in the development server:`),console.log(` stx dev ${X}
18325
18327
  `);else console.error(`
@@ -18350,7 +18352,7 @@ Press Ctrl+C to stop watching...
18350
18352
  \uD83D\uDCDD ${t.relative(x.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(`
18351
18353
  \uD83D\uDCC4 Files with issues:`),B.forEach((z)=>{let q=z.issues.filter((j)=>K[j.type]>=W).length;if(q>0)console.log(` ${t.relative(x.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(`
18352
18354
  \uD83D\uDCCB Analysis report saved to: ${J.saveReport}`)}console.log(`
18353
- \u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),x.exit(1)}}),q0.command("version","Show the version of the CLI").action(()=>{console.log(n4)}),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(() => (tJ(),uj)),Q={};if(X.context){let G=t.resolve(X.context);if(k0.existsSync(G))try{let K=k0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),x.exit(1)}else console.error(`Context file not found: ${G}`),x.exit(1)}await J({context:Q,cwd:X.cwd?t.resolve(X.cwd):x.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(() => (JL(),XL)),W=t.resolve(X);if(!k0.existsSync(W))console.error(`\u274C Input file not found: ${X}`),x.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(", ")}`),x.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(", ")}`),x.exit(1);console.log(`
18355
+ \u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),x.exit(1)}}),q0.command("version","Show the version of the CLI").action(()=>{console.log(n6)}),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(() => (tJ(),uj)),Q={};if(X.context){let G=t.resolve(X.context);if(k0.existsSync(G))try{let K=k0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),x.exit(1)}else console.error(`Context file not found: ${G}`),x.exit(1)}await J({context:Q,cwd:X.cwd?t.resolve(X.cwd):x.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(() => (JL(),XL)),W=t.resolve(X);if(!k0.existsSync(W))console.error(`\u274C Input file not found: ${X}`),x.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(", ")}`),x.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(", ")}`),x.exit(1);console.log(`
18354
18356
  \uD83D\uDD28 Building native app...`),console.log(` Input: ${X}`),console.log(` Target: ${_}`),console.log(` Format: ${J.format||"default"}`),console.log(` Output: ${J.output}
18355
18357
  `);let z=await Q({input:W,output:t.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?t.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(`
18356
18358
  \uD83D\uDCA1 To run: open "${z.outputPath}"`);else if(_==="linux"&&z.format==="appimage")console.log(`
@@ -18361,4 +18363,4 @@ Press Ctrl+C to stop watching...
18361
18363
  \u26A0\uFE0F Warnings:`);for(let O of _.stats.warnings)console.log(` - ${O.message}`)}if(_.stats.errors.length>0){console.log(`
18362
18364
  \u274C Errors:`);for(let O of _.stats.errors)console.log(` - ${O.message}`)}}catch(Q){console.error(`\u274C Compilation error: ${Q.message}`),x.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=x.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"),x.exit(1);if(!Z.includes(X)){let J=s("fs"),Q=s("path"),G=X;if(!Q.isAbsolute(G))G=Q.resolve(x.cwd(),G);if(J.existsSync(G)){let K=J.statSync(G);if(K.isFile()||K.isDirectory())x.argv=[x.argv[0],x.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(`
18363
18365
  Run 'stx --help' to see available commands.`),x.exit(1);console.error(`\u274C Unknown command or path: ${X}`),console.error(`
18364
- Run 'stx --help' to see available commands.`),x.exit(1)}}}q0.help(),q0.version(n4),q0.parse(x.argv)}
18366
+ Run 'stx --help' to see available commands.`),x.exit(1)}}}q0.help(),q0.version(n6),q0.parse(x.argv)}