@stacksjs/stx 0.2.98 → 0.2.99
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 +135 -135
- package/dist/pwa.js +70 -70
- package/dist/ssg.js +67 -67
- package/dist/template-tag-balance.js +1 -1
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -12,7 +12,7 @@ var Zw=Object.defineProperty;var Yw=($)=>$;function Xw($,Z){this[$]=Yw.bind(null
|
|
|
12
12
|
white-space: nowrap;
|
|
13
13
|
border-width: 0;
|
|
14
14
|
}
|
|
15
|
-
`.trim()}function JU(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function Gw($,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 V=/\baria-label\s*=/i.test(O)||/\baria-labelledby\s*=/i.test(O),L=O.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!V){let F=L&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${L[1]}["']`,"i").test($),A=J.index,N=$.substring(0,A),w=$.substring(A),R=(N.match(/<label\b/gi)||[]).length,T=(N.match(/<\/label>/gi)||[]).length,E=R>T;if(!F&&!E)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 z=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=z.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=z.exec($)}let B=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=B.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=B.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(),V=J[2];if(O!=="button"&&!/\btabindex\s*=/i.test(V))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 z3($,Z){if(!JU())return Gw($,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"),z=K.closest("label")!==null;if(!U&&!_&&!z)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"),z=K.querySelector("img[alt]");if(!W&&!U&&!_&&!z)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 dX($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=_3.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(_3.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 z3(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function QU($,Z={}){let Y={...Kw,...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,z=Q,B=`<${G}${K} aria-label="${_}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:z,after:B}),B});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 GU($,Z={},Y=!1){let X=await Bun.file($).text(),J=QU(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function Ww($,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=_3.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let z of _.scan()){if(Q.some((q)=>z.includes(_3.normalize(q))))continue;try{let q=await GU(z,Z,G);if(q.fixCount>0)X[z]=q}catch(q){console.error(`Error fixing ${z}:`,q)}}return X}function Uw(){return[B3,q3]}var Kw,B3,q3;var J5=D(()=>{Kw={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};B3={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},q3={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function _w($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...t1,...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 JU(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function Gw($,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 V=/\baria-label\s*=/i.test(O)||/\baria-labelledby\s*=/i.test(O),L=O.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!V){let F=L&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${L[1]}["']`,"i").test($),A=J.index,N=$.substring(0,A),w=$.substring(A),R=(N.match(/<label\b/gi)||[]).length,T=(N.match(/<\/label>/gi)||[]).length,E=R>T;if(!F&&!E)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 z=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=z.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=z.exec($)}let B=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=B.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=B.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(),V=J[2];if(O!=="button"&&!/\btabindex\s*=/i.test(V))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 z3($,Z){if(!JU())return Gw($,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"),z=K.closest("label")!==null;if(!U&&!_&&!z)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"),z=K.querySelector("img[alt]");if(!W&&!U&&!_&&!z)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 dX($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=_3.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let W of G.scan())if(!J.some((_)=>W.includes(_3.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 z3(U,W);if(_.length>0)Y[W]=_}catch(U){console.error(`Error scanning ${W}:`,U)}return Y}function QU($,Z={}){let Y={...Kw,...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,z=Q,B=`<${G}${K} aria-label="${_}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:z,after:B}),B});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 GU($,Z={},Y=!1){let X=await Bun.file($).text(),J=QU(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function Ww($,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=_3.join($,J?`**/${W}`:W),_=new Bun.Glob(U);for await(let z of _.scan()){if(Q.some((q)=>z.includes(_3.normalize(q))))continue;try{let q=await GU(z,Z,G);if(q.fixCount>0)X[z]=q}catch(q){console.error(`Error fixing ${z}:`,q)}}return X}function Uw(){return[B3,q3]}var Kw,B3,q3;var X5=D(()=>{Kw={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};B3={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},q3={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function _w($,Z={}){let{duration:Y,delay:X,ease:J,direction:Q,custom:G}={...t1,...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; } }
|
|
@@ -810,11 +810,11 @@ ${H}
|
|
|
810
810
|
`),X)J=J.replace(/\n/g,`<br />
|
|
811
811
|
`);for(let _=0;_<Q.length;_++)J=J.replace(`\x00CODEBLOCK${_}\x00`,Q[_]);return J=J.replace(/<p>\s*<\/p>/g,""),J.trim()}function z4($){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 FU from"process";function P1($="STX_PUBLIC_"){let Z={},Y={};for(let[X,J]of Object.entries(FU.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 AU($="STX_PUBLIC_"){let Z={};for(let[Y,X]of Object.entries(FU.env))if(Y.startsWith($)&&X!==void 0)Z[Y]=X;return Z}var
|
|
813
|
+
`}),$}import FU from"process";function P1($="STX_PUBLIC_"){let Z={},Y={};for(let[X,J]of Object.entries(FU.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 AU($="STX_PUBLIC_"){let Z={};for(let[Y,X]of Object.entries(FU.env))if(Y.startsWith($)&&X!==void 0)Z[Y]=X;return Z}var w6=()=>{};var A3={};e(A3,{hasUserImports:()=>Iw,bundleClientScript:()=>kw});import g0 from"path";import y1 from"fs";function Iw($){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(!NU.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(/\.css(?:\?.*)?$/.test(G))continue;if(!NU.some((W)=>W.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function Dw($,Z,Y,X){let J=(Q,G)=>{let K=Q===Y?Z:g0.dirname(Q),W=g0.resolve(K,G),U=[W,`${W}.ts`,`${W}.tsx`,`${W}.js`,`${W}.mjs`,`${W}.jsx`,g0.join(W,"index.ts"),g0.join(W,"index.tsx"),g0.join(W,"index.js"),g0.join(W,"index.mjs")];for(let _ of U)try{if(y1.existsSync(_)&&y1.statSync(_,{throwIfNoEntry:!1})?.isFile())return _}catch{}return W};return{name:"stx-client-bundle",setup(Q){Q.onResolve({filter:/^(stx|@stacksjs\/stx|@stacksjs\/browser)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^(@stores|@composables|stx\/stores)$/},(G)=>({path:G.path,external:!0})),Q.onResolve({filter:/^\.\.?\//},(G)=>{let K=J(G.importer,G.path);return X.add(K),{path:K}}),Q.onResolve({filter:/^[@~]\//},(G)=>{let K=g0.resolve($,G.path.slice(2)),W=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,g0.join(K,"index.ts"),g0.join(K,"index.tsx"),g0.join(K,"index.js"),g0.join(K,"index.mjs")];for(let U of W)if(y1.existsSync(U)&&y1.statSync(U,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",U),X.add(U),{path:U};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}})}}}async function kw($,Z,Y={}){let X=Y.projectRoot||process.cwd(),J=Y.minify??!1,Q=Y.cacheDir||g0.join(X,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),W=g0.join(Q,`${K}.js`),U=g0.join(Q,`${K}.deps.json`),_=Bun.file(W);if(await _.exists()){let N=Bun.file(U),w=!0;if(await N.exists())try{let R=JSON.parse(await N.text());for(let T of R.files)try{if(y1.statSync(T.path).mtimeMs!==T.mtimeMs){w=!1;break}}catch{w=!1;break}}catch{w=!1}if(w)return console.log("[stx:bundler] cache hit:",K),await _.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let z=g0.join(X,".stx","bundle-tmp"),B=g0.join(z,`${K}.ts`),q=g0.join(z,"out",K);y1.mkdirSync(z,{recursive:!0}),y1.mkdirSync(q,{recursive:!0});let j=g0.dirname(Z),H=[],O=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,L;while((L=O.exec($))!==null){if(L[1])continue;if(L[2])L[2].split(",").forEach((N)=>{let w=N.split(":")[0].trim();if(w)H.push(w)});else if(L[3])H.push(L[3])}while((L=V.exec($))!==null){if(L[1])continue;H.push(L[2])}let F=H.length>0?`
|
|
814
814
|
export { ${H.join(", ")} }`:"";await Bun.write(B,$+F),console.log("[stx:bundler] bundling:",K,"from:",g0.basename(Z));let A=new Set;try{let N=await Bun.build({entrypoints:[B],outdir:q,target:"browser",format:"esm",minify:J,plugins:[Dw(X,j,B,A)],define:{"process.env.NODE_ENV":J?'"production"':'"development"',...P1()},root:X});if(!N.success){let E=N.logs.filter((I)=>I.level==="error").map((I)=>I.message).join(", ");return console.warn("[stx:bundler] build failed:",E),$}let w="";for(let E of N.outputs){w=await E.text();break}let R=[];for(let E of w.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of E[1].split(",")){let k=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k&&k[1]!==k[2])R.push([k[2],k[1]])}if(w=w.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),R.length>0){let E=R.map(([I,k])=>`${JSON.stringify(I)}: ${k}`).join(", ");w+=`
|
|
815
815
|
var __stxScopeRenames = { ${E} };`}console.log("[stx:bundler] bundled:",K,"output:",w.length,"bytes"),y1.mkdirSync(Q,{recursive:!0}),await Bun.write(W,w);let T=Array.from(A).map((E)=>{try{return{path:E,mtimeMs:y1.statSync(E).mtimeMs}}catch{return null}}).filter((E)=>E!==null);return await Bun.write(U,JSON.stringify({files:T})),w}catch(N){let w=N instanceof Error?N.message:String(N),R=N?.errors,T=Array.isArray(R)&&R.length>0?`
|
|
816
816
|
${R.map((E)=>`- ${E?.message??E}`).join(`
|
|
817
|
-
`)}`:"";return console.warn(`[stx:bundler] error: ${w}${T}`),$}finally{try{y1.rmSync(B,{force:!0}),y1.rmSync(q,{recursive:!0,force:!0})}catch{}}}var NU;var N3=D(()=>{
|
|
817
|
+
`)}`:"";return console.warn(`[stx:bundler] error: ${w}${T}`),$}finally{try{y1.rmSync(B,{force:!0}),y1.rmSync(q,{recursive:!0,force:!0})}catch{}}}var NU;var N3=D(()=>{w6();NU=[/^stx$/,/^@stacksjs\/stx$/,/^@stacksjs\/browser$/,/^@stores$/,/^stx\/stores$/,/^@composables$/]});var RU={};e(RU,{renderVendorStyleTags:()=>aX,processClientScript:()=>y4,generateServerDataBridge:()=>d$,extractBridgeData:()=>P4,extractAndStripCssImports:()=>rX});import R6 from"path";import h$ from"fs";function Cw($){if($.startsWith(".")||$.startsWith("/"))return null;if($.startsWith("@")){let Y=$.match(/^(@[^/]+\/[^/]+)(\/.*)?$/);if(!Y)return null;return{pkg:Y[1],subpath:Y[2]||""}}let Z=$.match(/^([^/]+)(\/.*)?$/);if(!Z)return null;return{pkg:Z[1],subpath:Z[2]||""}}function bw($,Z){let Y=Z;while(!0){let X=R6.join(Y,"node_modules",$,"package.json");if(h$.existsSync(X))return R6.dirname(X);let J=R6.dirname(Y);if(J===Y)return null;Y=J}}function Pw($,Z){if(!$||typeof $!=="object")return null;let Y=(J)=>{if(typeof J==="string")return J;if(J&&typeof J==="object"){if(typeof J.import==="string")return J.import;if(typeof J.default==="string")return J.default;if(typeof J.import==="object")return Y(J.import);if(typeof J.default==="object")return Y(J.default)}return null};if(Object.prototype.hasOwnProperty.call($,Z))return Y($[Z]);let X=null;for(let J of Object.keys($)){let Q=J.indexOf("*");if(Q===-1)continue;let G=J.slice(0,Q),K=J.slice(Q+1);if(!Z.startsWith(G)||!Z.endsWith(K))continue;if(Z.length<G.length+K.length)continue;if(!X||G.length>X.prefix.length)X={pattern:J,prefix:G,suffix:K}}if(X){let J=Z.slice(X.prefix.length,Z.length-X.suffix.length),Q=Y($[X.pattern]);if(Q)return Q.replace("*",J)}return null}function yw($,Z){let Y=Cw($);if(!Y||!Y.subpath)return null;let X=bw(Y.pkg,Z);if(!X)return null;let J;try{J=JSON.parse(h$.readFileSync(R6.join(X,"package.json"),"utf8"))}catch{return null}let Q=`.${Y.subpath}`,G=Pw(J.exports,Q);if(!G)return null;let K=R6.resolve(X,G);return h$.existsSync(K)?K:null}function rX($,Z){let Y=Z.filePath?R6.dirname(Z.filePath):Z.projectRoot||process.cwd(),X=Z.projectRoot||process.cwd(),J=new Set,Q=[];return{code:$.replace(Sw,(K,W)=>{let U;try{if(W.startsWith("./")||W.startsWith("../")||W.startsWith("/")){if(U=W.startsWith("/")?W:R6.resolve(Y,W),!h$.existsSync(U))throw Error(`file not found: ${U}`)}else{let _=null;try{_=Bun.resolveSync(W,X)}catch{_=yw(W,X)}if(!_)throw Error(`could not resolve ${W} (Bun.resolveSync + exports fallback both failed)`);U=_}}catch(_){return console.warn(`[stx:vendor-css] could not resolve ${JSON.stringify(W)} (from ${Z.filePath||"<unknown>"}): ${_?.message||_}`),""}if(J.has(U))return"";J.add(U);try{let _=h$.readFileSync(U,"utf8");Q.push({source:W,resolvedPath:U,contents:_})}catch(_){console.warn(`[stx:vendor-css] could not read ${U}: ${_?.message||_}`)}return""}),styles:Q}}function xw($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function aX($){if($.length===0)return"";return`${$.map((Z)=>{return`<style data-stx-vendor="${xw(Z.source)}" data-stx-layer="vendor">
|
|
818
818
|
@layer vendor {
|
|
819
819
|
${Z.contents}
|
|
820
820
|
}
|
|
@@ -880,7 +880,7 @@ ${U}${V}
|
|
|
880
880
|
'use strict';
|
|
881
881
|
${X}${Y}
|
|
882
882
|
${U}
|
|
883
|
-
})()</script>`}var Sw,vw,fw,gw,mw,iw;var
|
|
883
|
+
})()</script>`}var Sw,vw,fw,gw,mw,iw;var M6=D(()=>{w0();Sw=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;vw=["state","derived","effect","batch","untrack","peek","isSignal","isDerived","onMount","onDestroy","useRef","navigate","goBack","goForward","useRoute","setRouteParams","useSearchParams","useFetch","useQuery","useMutation","useOptimistic","useReactiveProp","useLocalStorage","useSessionStorage","useCookie","useWebSocket","useHead","useSeoMeta","definePageMeta","useEventListener","useMeta","useDebounce","useDebouncedValue","useThrottle","useInterval","useTimeout","useToggle","useCounter","useClickOutside","useFocus","useAsync","useColorMode","useDark","ref","reactive","computed","watch","watchEffect","watchMultiple","onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","defineProps","withDefaults","defineEmits","defineExpose","defineSlots","provide","inject","nextTick","getCurrentInstance","onErrorCaptured","useSlots","useAttrs","createStore","defineStore","useStore","action","createSelector","h","Fragment"],fw=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],gw=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process","Modal","Intl"]);mw={left:0,middle:1,right:2};iw=new Set(["if","else","true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","switch","case","break","continue","for","while","do","try","catch","finally","const","let","var","function","class","import","export","default","async","await","yield","with","debugger","console","window","document","Math","JSON","Date","Array","Object","String","Number","Boolean","Symbol","Map","Set","Promise","Error","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","setTimeout","setInterval","clearTimeout","clearInterval","fetch","alert","confirm","prompt","event"])});function ow($){let Z="",Y=null,X=!1;for(let J=0;J<$.length;J++){let Q=$[J];if(X){X=!1;continue}if(Q==="\\"&&Y){X=!0;continue}if(Y){if(Y==="`"&&Q==="$"&&J+1<$.length&&$[J+1]==="{"){let G=1;J+=2;while(J<$.length&&G>0){if($[J]==="{")G++;else if($[J]==="}")G--;if(G>0)Z+=$[J],J++}continue}if(Q===Y)Y=null;continue}if(Q==='"'||Q==="'"||Q==="`"){Y=Q;continue}Z+=Q}return Z}function tw($,Z){let Y=/[$A-Z_a-z][$\w]*/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=$[X.index-1];if(aw.has(J))throw Error(`Potentially unsafe expression (matched /\\b${J}\\b/; identifier ${J}): ${Z}`);if(Q==="."&&IU.has(J))throw Error(`Potentially unsafe expression (matched /.${J}/; property ${J}): ${Z}`)}}function ew($){let Z=/\[\s*(['"])(.*?)\1\s*\]/g,Y;while((Y=Z.exec($))!==null){let X=Y[2];if(!IU.has(X))continue;let J=$.slice(0,Y.index).match(/\S(?=\s*$)/)?.[0],Q=$.slice(Y.index+Y[0].length).match(/^\s*(\S)/)?.[1];if(!((J==="{"||J===",")&&Q===":"))throw Error(`Potentially unsafe expression (bracket key ${Y[2]}): ${$}`)}}function w3($){let Z=$.trim(),Y=ow(Z);tw(Y,Z),ew(Z);for(let X of EU)if(X.test(Y))throw Error(`Potentially unsafe expression (matched /${X.source}/): ${Z}`);if(!TU.allowBracketNotation&&sw.test(Z))throw Error(`Bracket notation with strings not allowed: ${Z}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return Z}function $R($){let Z={};Z.Math=Math,Z.JSON=JSON,Z.Date=Date,Z.String=String,Z.Number=Number,Z.Boolean=Boolean,Z.Array=Array,Z.parseInt=Number.parseInt,Z.parseFloat=Number.parseFloat,Z.isNaN=Number.isNaN,Z.isFinite=Number.isFinite,Z.encodeURIComponent=encodeURIComponent,Z.decodeURIComponent=decodeURIComponent;for(let[Y,X]of Object.entries($)){if(Y.startsWith("__")||EU.some((J)=>J.test(Y)))continue;if(X&&typeof X==="object"&&!Array.isArray(X))Z[Y]=sX(X);else Z[Y]=X}return Z}function sX($,Z=0){if(Z>=TU.maxSanitizeDepth)return"[Object too deep]";if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((X)=>sX(X,Z+1));if($ instanceof Date||$ instanceof RegExp||$ instanceof Map||$ instanceof Set||$ instanceof Error)return $;let Y={};for(let[X,J]of Object.entries($)){if(X.startsWith("__")||X==="constructor"||X==="prototype")continue;if(J&&typeof J==="object")Y[X]=sX(J,Z+1);else Y[X]=J}return Y}function V0($,Z){try{let Y=$R(Z),X=Object.keys(Y),J=Object.values(Y);return M0($,X)(...J)}catch{return}}function R0($){try{return w3($),!0}catch{return!1}}function h0($,Z){try{let Y=V0($,Z);if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Y;return{}}catch{return{}}}function M0($,Z){let Y=w3($),X=/^[A-Za-z_$][\w$]*$/,J=[],Q=[];for(let U=0;U<Z.length;U++){let _=Z[U];if(!X.test(_))continue;if(DU.has(_))continue;J.push(U),Q.push(_)}let G=(U)=>Function(...Q,...U,`
|
|
884
884
|
'use strict';
|
|
885
885
|
try {
|
|
886
886
|
return ${Y};
|
|
@@ -891,7 +891,7 @@ catch (e) {
|
|
|
891
891
|
}
|
|
892
892
|
throw e;
|
|
893
893
|
}
|
|
894
|
-
`),K=G([]);if(Q.length===Z.length)return MU(K,Q,G);return MU((...U)=>{let _=Array(J.length);for(let z=0;z<J.length;z++)_[z]=U[J[z]];return K(..._)},Q,G,(U)=>{K=G(U)})}function MU($,Z,Y,X){let Q=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...U)=>{for(let _=0;_<=8;_++)try{return G(...U)}catch(z){let B=z instanceof Error?z.message:"",q=Q.exec(B);if(!(z instanceof ReferenceError)||!q)return;let j=q[1];if(W.has(j)||DU.has(j))return;W.add(j),K.push(j),G=Y(K),X?.(K)}return}}function R3($){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 rw,TU,EU,aw,IU,sw,DU;var p0=D(()=>{rw={maxSanitizeDepth:10,allowBracketNotation:!1},TU={...rw},EU=[/\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/],aw=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),IU=new Set(["__proto__","constructor","prototype"]),sw=/[\w)\]]\s*\[\s*['"]/;DU=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});function oX(){kU=0,M3.clear()}function u$($,Z){let Y=kU++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return M3.set(X,{type:$,expression:Z}),X}function tX(){let $={};for(let[Z,Y]of M3)$[Z]={type:Y.type,expression:Y.expression};return $}function ZR($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=M3.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function T3($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function Q5($){return $.includes("<!--__STX_")}var kU=0,M3;var m$=D(()=>{M3=new Map});function SU($,Z,Y,X){Y.lastIndex=Z;let J=Y.exec($);if(!J||J.index!==Z)return-1;X.lastIndex=Y.lastIndex;let Q=X.exec($);if(!Q)return-1;return Q.index+Q[0].length}function E3($,Z){return SU($,Z,YR,XR)}function CU($,Z){return SU($,Z,JR,QR)}function bU($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function c$($,Z,Y){let X=[],J="",Q=0,G=$.length,K=!1,W=null;while(Q<G){let U=$[Q];if(K){if(J+=U,W){if(U===W)W=null}else if(U==='"'||U==="'")W=U;else if(U===">")K=!1;Q++;continue}if(U==="<"){let _=Z($,Q);if(_>Q){J+=Y($.slice(Q,_),X.length),X.push($.slice(Q,_)),Q=_;continue}if(/^<\/?[a-zA-Z]/.test($.slice(Q,Q+2)))K=!0;J+=U,Q++;continue}J+=U,Q++}return{output:J,tokens:X}}function eX($){let{output:Z,tokens:Y}=c$($,E3,(X,J)=>`\x00STX_SCRIPT_${J}\x00`);return{output:Z,scripts:Y}}function $J($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,X)=>Z[+X]??"")}var YR,XR,JR,QR;var I3=D(()=>{YR=/<script\b[^>]*>/iy,XR=/<\/script\s*>/ig,JR=/<style\b[^>]*>/iy,QR=/<\/style\s*>/ig});var p$={};e(p$,{usesSignalsInScript:()=>E6,unescapeHtml:()=>D3,registerFilters:()=>xU,registerFilter:()=>ZJ,processExpressions:()=>j1,interpolateScriptsInTemplate:()=>fU,interpolateScriptExpressions:()=>XJ,getAllFilters:()=>YJ,evaluateExpression:()=>X1,escapeHtml:()=>P0,defaultFilters:()=>G5,clearCustomFilters:()=>vU,applyFilters:()=>JJ});function GR($){let Z=PU.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),PU.set($,Z)}return Z.lastIndex=0,Z}function ZJ($,Z){if($ in G5)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);l$[$]=Z}function xU($){for(let[Z,Y]of Object.entries($))ZJ(Z,Y)}function YJ(){return{...G5,...l$}}function vU(){for(let $ of Object.keys(l$))delete l$[$]}function P0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function E6($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function yU($,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 XJ($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=X1(J,Z);if(Q===void 0)return X;return Q===null?"":String(Q)}catch{return X}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return X;try{let G=X1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function fU($,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=XJ(Q,Z);return`<script${J}>${G}</script>`})}function j1($,Z,Y,X){let J=$,Q=(_,z)=>{let B=CU(_,z);if(B===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(_.slice(z,B))?-1:B},G=(_,z,B,q)=>{let j=B.length,{output:H,tokens:O}=c$(_,z,(V,L)=>q(j+L));return B.push(...O),H},K=[];J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`);let W=[];J=G(J,E3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`);let U=X?.forceSignals===!0||E6($);J=J.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(_,z,B)=>{try{let q=X1(z,Z);return q!==void 0&&q!==null?String(q):""}catch(q){let j=q instanceof Error?q.message:String(q);return T0("Expression",`Error evaluating: {{{ ${z.trim()}}}}: ${j}`,Y,$,B,_)}}),J=J.replace(/\{!!([\s\S]*?)!!\}/g,(_,z,B)=>{try{let q=X1(z,Z);if(q===void 0&&Z.__stx_buildMode==="compile")return u$("raw",z.trim());return q!==void 0&&q!==null?String(q):""}catch(q){if(Z.__stx_buildMode==="compile")return u$("raw",z.trim());let j=q instanceof Error?q.message:String(q);return T0("Expression",`Error evaluating: {!! ${z.trim()} !!}: ${j}`,Y,$,B,_)}}),J=G(J,E3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`),J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`),J=J.replace(/\{\{([\s\S]*?)\}\}/g,(_,z,B)=>{let q=z.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,V=q.match(H)?.[1],L=V&&((V in Z)||j.includes(V)),F=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=q.match(F),N=A&&!j.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(q))return"";try{let w=X1(z,Z);if(w===void 0&&U&&!yU(q,Z))return _;if(w===void 0&&Z.__stx_buildMode==="compile"&&!U)return u$("expr",q);return w!==void 0&&w!==null?P0(String(w)):""}catch(w){if(U&&!yU(q,Z))return _;if(N)return _;let R=w instanceof Error?w.message:String(w);return T0("Expression",`Error evaluating: {{ ${q} }}: ${R}`,Y,$,B,_)}});for(let _=0;_<W.length;_++)J=J.replace(`<!--__STX_SCRIPT_EXPR_${_}__-->`,()=>W[_]);for(let _=0;_<K.length;_++)J=J.replace(`<!--__STX_STYLE_${_}__-->`,()=>K[_]);return J}function JJ($,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=l$[G]||G5[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(YJ()).join(", ")}`);let W=[];if(J.startsWith(":")){let U=J.match(/^:([^|\s]+)/);if(U){let _=U[1].trim();try{let z=Number(_);W=[Number.isNaN(z)?_:z]}catch{W=[_]}J=J.substring(U[0].length).trim()}}else if(J.startsWith("(")){let U=1,_=1;while(U>0&&_<J.length){if(J[_]==="(")U++;if(J[_]===")")U--;_++}if(U===0){let z=J.substring(1,_-1).trim();if(z)try{if(z.startsWith("{")&&z.endsWith("}"))W=[X1(`(${z})`,Y,!0)];else{let B=[],q="",j=null,H=0,O=0,V=0,L=!1;for(let F=0;F<z.length;F++){let A=z[F];if(L){q+=A,L=!1;continue}if(A==="\\"){q+=A,L=!0;continue}if(j){if(q+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,q+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")O++;else if(A==="]")O--;else if(A==="{")V++;else if(A==="}")V--;if(A===","&&H===0&&O===0&&V===0){B.push(q),q="";continue}q+=A}if(q)B.push(q);W=B.map((F)=>{let A=F.trim();return X1(A,Y,!0)})}}catch{W=[z]}J=J.substring(_).trim()}}try{X=K(X,Y,...W)}catch(U){let _=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${_}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function KR($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let _=1;K+=2;while(K<$.length&&_>0){if($[K]==="{")_++;else if($[K]==="}")_--;if(_>0)K++}continue}if(Z)continue;if(W==="(")X++;else if(W===")")X--;else if(W==="[")J++;else if(W==="]")J--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&X===0&&J===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function X1($,Z,Y=!1){try{let X=$.trim(),J=KR(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=X1(Q,Z,!0);return JJ(K,G,Z)}if(!R0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return V0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return M0(X,Q)(...G)}catch{return V0(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=WR(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 WR($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=UR($,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 UR($,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 D3($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var l$,PU,G5;var o0=D(()=>{p0();w0();m$();I3();l$={},PU=new Map;G5={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let X=Number($);return Number.isNaN(X)?"":X.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return X.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return P0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let X=Z.__translations,J=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=X;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(GR(W),String(U))}),K},t:($,Z,Y={})=>{return G5.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 i${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 W5($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!K5.has(Y)){if(K5.size>=_R){let X=K5.keys().next().value;if(X)K5.delete(X)}K5.set(Y,new RegExp($,Z))}return K5.get(Y)}class gU{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),X=this.pool.find((K)=>K.context.join(",")===Y);if(X)return X.func;let J=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,_=J.get(U);if(!_){if(J.size>=Q){let z=J.keys().next().value;if(z)J.delete(z)}_=Function(...Z,`
|
|
894
|
+
`),K=G([]);if(Q.length===Z.length)return MU(K,Q,G);return MU((...U)=>{let _=Array(J.length);for(let z=0;z<J.length;z++)_[z]=U[J[z]];return K(..._)},Q,G,(U)=>{K=G(U)})}function MU($,Z,Y,X){let Q=/^(\w+) is not defined$/,G=$,K=[],W=new Set(Z);return(...U)=>{for(let _=0;_<=8;_++)try{return G(...U)}catch(z){let B=z instanceof Error?z.message:"",q=Q.exec(B);if(!(z instanceof ReferenceError)||!q)return;let j=q[1];if(W.has(j)||DU.has(j))return;W.add(j),K.push(j),G=Y(K),X?.(K)}return}}function R3($){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 rw,TU,EU,aw,IU,sw,DU;var p0=D(()=>{rw={maxSanitizeDepth:10,allowBracketNotation:!1},TU={...rw},EU=[/\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/],aw=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),IU=new Set(["__proto__","constructor","prototype"]),sw=/[\w)\]]\s*\[\s*['"]/;DU=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});function oX(){kU=0,M3.clear()}function u$($,Z){let Y=kU++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return M3.set(X,{type:$,expression:Z}),X}function tX(){let $={};for(let[Z,Y]of M3)$[Z]={type:Y.type,expression:Y.expression};return $}function ZR($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=M3.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function T3($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function J5($){return $.includes("<!--__STX_")}var kU=0,M3;var m$=D(()=>{M3=new Map});function SU($,Z,Y,X){Y.lastIndex=Z;let J=Y.exec($);if(!J||J.index!==Z)return-1;X.lastIndex=Y.lastIndex;let Q=X.exec($);if(!Q)return-1;return Q.index+Q[0].length}function E3($,Z){return SU($,Z,YR,XR)}function CU($,Z){return SU($,Z,JR,QR)}function bU($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function c$($,Z,Y){let X=[],J="",Q=0,G=$.length,K=!1,W=null;while(Q<G){let U=$[Q];if(K){if(J+=U,W){if(U===W)W=null}else if(U==='"'||U==="'")W=U;else if(U===">")K=!1;Q++;continue}if(U==="<"){let _=Z($,Q);if(_>Q){J+=Y($.slice(Q,_),X.length),X.push($.slice(Q,_)),Q=_;continue}if(/^<\/?[a-zA-Z]/.test($.slice(Q,Q+2)))K=!0;J+=U,Q++;continue}J+=U,Q++}return{output:J,tokens:X}}function eX($){let{output:Z,tokens:Y}=c$($,E3,(X,J)=>`\x00STX_SCRIPT_${J}\x00`);return{output:Z,scripts:Y}}function $J($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,X)=>Z[+X]??"")}var YR,XR,JR,QR;var I3=D(()=>{YR=/<script\b[^>]*>/iy,XR=/<\/script\s*>/ig,JR=/<style\b[^>]*>/iy,QR=/<\/style\s*>/ig});var p$={};e(p$,{usesSignalsInScript:()=>T6,unescapeHtml:()=>D3,registerFilters:()=>xU,registerFilter:()=>ZJ,processExpressions:()=>j1,interpolateScriptsInTemplate:()=>fU,interpolateScriptExpressions:()=>XJ,getAllFilters:()=>YJ,evaluateExpression:()=>X1,escapeHtml:()=>P0,defaultFilters:()=>Q5,clearCustomFilters:()=>vU,applyFilters:()=>JJ});function GR($){let Z=PU.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),PU.set($,Z)}return Z.lastIndex=0,Z}function ZJ($,Z){if($ in Q5)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);l$[$]=Z}function xU($){for(let[Z,Y]of Object.entries($))ZJ(Z,Y)}function YJ(){return{...Q5,...l$}}function vU(){for(let $ of Object.keys(l$))delete l$[$]}function P0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function T6($){let Z=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,Y;while((Y=Z.exec($))!==null){let X=Y[1];if(/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/.test(X))return!0}if(/@(if|for|show)\s*=\s*["'][^"']*\(\s*\)/.test($))return!0;if(/@for\s*=\s*["'][^"']*\s+(?:in|of)\s+[^"']*\(\s*\)/.test($))return!0;if(/(?:^|[\s"'])(?::|x-)(?:for|if|else-if|else|show|text|html|model|bind)\b/.test($))return!0;return!1}function yU($,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 XJ($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=X1(J,Z);if(Q===void 0)return X;return Q===null?"":String(Q)}catch{return X}}),Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{let Q=J.trim();if(/^__[A-Z_]+__$/.test(Q))return X;try{let G=X1(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function fU($,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=XJ(Q,Z);return`<script${J}>${G}</script>`})}function j1($,Z,Y,X){let J=$,Q=(_,z)=>{let B=CU(_,z);if(B===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(_.slice(z,B))?-1:B},G=(_,z,B,q)=>{let j=B.length,{output:H,tokens:O}=c$(_,z,(V,L)=>q(j+L));return B.push(...O),H},K=[];J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`);let W=[];J=G(J,E3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`);let U=X?.forceSignals===!0||T6($);J=J.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(_,z,B)=>{try{let q=X1(z,Z);return q!==void 0&&q!==null?String(q):""}catch(q){let j=q instanceof Error?q.message:String(q);return T0("Expression",`Error evaluating: {{{ ${z.trim()}}}}: ${j}`,Y,$,B,_)}}),J=J.replace(/\{!!([\s\S]*?)!!\}/g,(_,z,B)=>{try{let q=X1(z,Z);if(q===void 0&&Z.__stx_buildMode==="compile")return u$("raw",z.trim());return q!==void 0&&q!==null?String(q):""}catch(q){if(Z.__stx_buildMode==="compile")return u$("raw",z.trim());let j=q instanceof Error?q.message:String(q);return T0("Expression",`Error evaluating: {!! ${z.trim()} !!}: ${j}`,Y,$,B,_)}}),J=G(J,E3,W,(_)=>`<!--__STX_SCRIPT_EXPR_${_}__-->`),J=G(J,Q,K,(_)=>`<!--__STX_STYLE_${_}__-->`),J=J.replace(/\{\{([\s\S]*?)\}\}/g,(_,z,B)=>{let q=z.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],H=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,V=q.match(H)?.[1],L=V&&((V in Z)||j.includes(V)),F=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=q.match(F),N=A&&!j.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(q))return"";try{let w=X1(z,Z);if(w===void 0&&U&&!yU(q,Z))return _;if(w===void 0&&Z.__stx_buildMode==="compile"&&!U)return u$("expr",q);return w!==void 0&&w!==null?P0(String(w)):""}catch(w){if(U&&!yU(q,Z))return _;if(N)return _;let R=w instanceof Error?w.message:String(w);return T0("Expression",`Error evaluating: {{ ${q} }}: ${R}`,Y,$,B,_)}});for(let _=0;_<W.length;_++)J=J.replace(`<!--__STX_SCRIPT_EXPR_${_}__-->`,()=>W[_]);for(let _=0;_<K.length;_++)J=J.replace(`<!--__STX_STYLE_${_}__-->`,()=>K[_]);return J}function JJ($,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=l$[G]||Q5[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(YJ()).join(", ")}`);let W=[];if(J.startsWith(":")){let U=J.match(/^:([^|\s]+)/);if(U){let _=U[1].trim();try{let z=Number(_);W=[Number.isNaN(z)?_:z]}catch{W=[_]}J=J.substring(U[0].length).trim()}}else if(J.startsWith("(")){let U=1,_=1;while(U>0&&_<J.length){if(J[_]==="(")U++;if(J[_]===")")U--;_++}if(U===0){let z=J.substring(1,_-1).trim();if(z)try{if(z.startsWith("{")&&z.endsWith("}"))W=[X1(`(${z})`,Y,!0)];else{let B=[],q="",j=null,H=0,O=0,V=0,L=!1;for(let F=0;F<z.length;F++){let A=z[F];if(L){q+=A,L=!1;continue}if(A==="\\"){q+=A,L=!0;continue}if(j){if(q+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,q+=A;continue}if(A==="(")H++;else if(A===")")H--;else if(A==="[")O++;else if(A==="]")O--;else if(A==="{")V++;else if(A==="}")V--;if(A===","&&H===0&&O===0&&V===0){B.push(q),q="";continue}q+=A}if(q)B.push(q);W=B.map((F)=>{let A=F.trim();return X1(A,Y,!0)})}}catch{W=[z]}J=J.substring(_).trim()}}try{X=K(X,Y,...W)}catch(U){let _=U instanceof Error?U.message:String(U);throw Error(`Error applying filter '${G}': ${_}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function KR($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let W=$[K],U=$[K+1];if(Z&&G){G=!1;continue}if(Z&&W==="\\"){G=!0;continue}if(G=!1,(W==='"'||W==="'"||W==="`")&&!G){if(!Z)Z=!0,Y=W;else if(W===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&W==="$"&&U==="{"){let _=1;K+=2;while(K<$.length&&_>0){if($[K]==="{")_++;else if($[K]==="}")_--;if(_>0)K++}continue}if(Z)continue;if(W==="(")X++;else if(W===")")X--;else if(W==="[")J++;else if(W==="]")J--;else if(W==="{")Q++;else if(W==="}")Q--;if(W==="|"&&X===0&&J===0&&Q===0){if(U==="|"){K++;continue}if(U==="="){K++;continue}return K}}return-1}function X1($,Z,Y=!1){try{let X=$.trim(),J=KR(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=X1(Q,Z,!0);return JJ(K,G,Z)}if(!R0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return V0(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return M0(X,Q)(...G)}catch{return V0(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=WR(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 WR($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=UR($,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 UR($,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 D3($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var l$,PU,Q5;var o0=D(()=>{p0();w0();m$();I3();l$={},PU=new Map;Q5={uppercase:($,Z)=>{return $!==void 0&&$!==null?String($).toUpperCase():""},lowercase:($,Z)=>{return $!==void 0&&$!==null?String($).toLowerCase():""},capitalize:($,Z)=>{if($===void 0||$===null)return"";let Y=String($);return Y.charAt(0).toUpperCase()+Y.slice(1)},number:($,Z,Y=0)=>{if($===void 0||$===null)return"";try{let X=Number($);return Number.isNaN(X)?"":X.toFixed(Number.parseInt(String(Y),10))}catch{return""}},fmt:($,Z,Y="en-US")=>{if($===void 0||$===null)return"";try{let X=Number($);if(Number.isNaN(X))return String($);return X.toLocaleString(Y)}catch{return String($)}},join:($,Z,Y=",")=>{if(!Array.isArray($))return"";return $.join(String(Y))},escape:($,Z)=>{if($===void 0||$===null)return"";return P0(String($))},translate:($,Z,Y={})=>{if(!Z||!Z.__translations)return $;let X=Z.__translations,J=Z.__i18nConfig?.fallbackToKey??!0,Q=String($).split("."),G=X;for(let W of Q){if(G===void 0||G===null)break;G=G[W]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([W,U])=>{K=K.replace(GR(W),String(U))}),K},t:($,Z,Y={})=>{return Q5.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 i${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 K5($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!G5.has(Y)){if(G5.size>=_R){let X=G5.keys().next().value;if(X)G5.delete(X)}G5.set(Y,new RegExp($,Z))}return G5.get(Y)}class gU{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator($){let Z=Array.from(new Set($)),Y=Z.sort().join(","),X=this.pool.find((K)=>K.context.join(",")===Y);if(X)return X.func;let J=this.fnCache,Q=this.fnCacheMaxSize,G=(...K)=>{return(W)=>{try{let U=`${Y}:${W}`,_=J.get(U);if(!_){if(J.size>=Q){let z=J.keys().next().value;if(z)J.delete(z)}_=Function(...Z,`
|
|
895
895
|
'use strict';
|
|
896
896
|
try {
|
|
897
897
|
return ${W};
|
|
@@ -902,14 +902,14 @@ catch (e) {
|
|
|
902
902
|
}
|
|
903
903
|
throw e;
|
|
904
904
|
}
|
|
905
|
-
`),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 hU{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 zR(){if(!QJ)QJ=new hU;return QJ}var K5,_R=500,$h,QJ=null,g1;var f4=D(()=>{K5=new Map;$h=new gU;g1=new Proxy({},{get($,Z){return zR()[Z]}})});var M;var n$=D(()=>{M={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 b3={};e(b3,{resetCssCache:()=>LR,resetCrosswindCache:()=>VR,rebuildCrosswindCSS:()=>a$,loadCrosswindConfig:()=>_J,loadCrosswind:()=>UJ,injectCrosswindCSS:()=>S0,getCachedCSS:()=>FR,generateCrosswindCSS:()=>C3,extractClassNames:()=>S3,buildCrosswindCSS:()=>z5});import O0 from"path";import{hasLocalConfig as BR}from"bunfig/discovery";function WJ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function GJ($,Z){if(B4.has($))B4.delete($);else if(B4.size>=qR)B4.delete(B4.keys().next().value);B4.set($,Z)}async function jR($){if(!g4)return null;try{let Z=Bun.file(O0.join(g4,`cw-${WJ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function HR($,Z){if(!g4)return;try{if(!fs.existsSync(g4))fs.mkdirSync(g4,{recursive:!0});await Bun.write(O0.join(g4,`cw-${WJ($)}.css`),Z)}catch{}}async function dU($){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 OR(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==O0.dirname(Y))$.push(O0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(O0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(O0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(O0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(O0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(O0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=O0.dirname(Y);if(Z){let X=[O0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),O0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),O0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),O0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),O0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),O0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(O0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(O0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function UJ(){if(KJ)return _5;KJ=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await dU(Y);if(X){if(_5=X,!process.env.STACKS_DEV_QUIET)console.log(`${M.green}[Crosswind]${M.reset} CSS engine loaded`);return _5}}let Z=OR();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await dU(Y);if(X){if(_5=X,!process.env.STACKS_DEV_QUIET)console.log(`${M.green}[Crosswind]${M.reset} CSS engine loaded from ${O0.dirname(O0.dirname(Y))}`);return _5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${M.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${M.reset}`),console.warn(`${M.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${M.reset}`),null}}function LR(){B4.clear()}function VR(){_5=null,KJ=!1,h1=null,r$="",B4.clear(),k3=null}async function _J($){try{if(!BR({name:"crosswind",cwd:$}))return null;let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=O0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${M.green}[Crosswind]${M.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${M.yellow}[Crosswind]${M.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function z5($){if(U5)return r$;U5=!0;try{let Z=await UJ();if(!Z||!Z.build)return U5=!1,"";if(!h1)h1=await _J($);if(!h1)return U5=!1,"";let Y=Z.defaultConfig?.theme||{},X=h1.theme||{},J={...Z.defaultConfig,...h1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(r$=G.css,console.log(`${M.cyan}[Crosswind]${M.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let W=O0.isAbsolute(J.output)?J.output:O0.join($,J.output),U=O0.dirname(W);if(!fs.existsSync(U))fs.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return U5=!1,G.css}catch(Z){return console.error(`${M.red}[Crosswind]${M.reset} Build error:`,Z),U5=!1,r$}}async function a$($){h1=null,await z5($)}function FR(){return r$}function S3($){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 C3($,Z){try{let Y=await UJ();if(!Y)return"";let X=S3($);if(X.size===0)return"";let J=Z?O0.resolve(Z):process.cwd();if(!g4)g4=O0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${k3||"default"}::${Q}`,K=B4.get(G);if(K!==void 0)return GJ(G,K),K;let W=await jR(G);if(W!==null)return GJ(G,W),W;if(!h1){let N=null;try{let{loadStxConfig:w}=await Promise.resolve().then(() => (i0(),P3)),R=await w(J);if(R.css)if(typeof R.css==="string"){let T=O0.isAbsolute(R.css)?R.css:O0.resolve(J,R.css);if(await Bun.file(T).exists()){let E=await import(T);N=E.default||E,console.log(`${M.green}[Crosswind]${M.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(N={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=O0.isAbsolute(R.css.config)?R.css.config:O0.resolve(J,R.css.config);if(await Bun.file(T).exists()){let E=await import(T);N={...E.default||E,...N}}}console.log(`${M.green}[Crosswind]${M.reset} Using inline CSS config from stx.config.ts`)}}catch{}h1=N||await _J(J);try{k3=WJ(JSON.stringify(h1??{}))}catch{k3="unhashable"}}let U=Y.defaultConfig||Y.config,_=h1||{},z=U.theme||{},q=(_.theme||{}).extend||{},j={...z};if(Object.keys(q).length>0)j.extend=q;let H=[...U.safelist||[],..._.safelist||[]],O={...U,..._,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},V=new Y.CSSGenerator(O);for(let N of H)V.generate(N);for(let N of X)V.generate(N);let L=V.toCSS(!0,!1),F=O.shortcuts||_.shortcuts||{};for(let[N,w]of Object.entries(F)){if(!X.has(N)&&!H.includes(N))continue;let R=w.split(/\s+/).filter(Boolean);for(let T of R)V.generate(T)}L=V.toCSS(!0,!1);let A=L.split(`
|
|
905
|
+
`),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 hU{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 zR(){if(!QJ)QJ=new hU;return QJ}var G5,_R=500,$h,QJ=null,g1;var f4=D(()=>{G5=new Map;$h=new gU;g1=new Proxy({},{get($,Z){return zR()[Z]}})});var M;var n$=D(()=>{M={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 b3={};e(b3,{resetCssCache:()=>LR,resetCrosswindCache:()=>VR,rebuildCrosswindCSS:()=>a$,loadCrosswindConfig:()=>_J,loadCrosswind:()=>UJ,injectCrosswindCSS:()=>S0,getCachedCSS:()=>FR,generateCrosswindCSS:()=>C3,extractClassNames:()=>S3,buildCrosswindCSS:()=>_5});import O0 from"path";import{hasLocalConfig as BR}from"bunfig/discovery";function WJ($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function GJ($,Z){if(B4.has($))B4.delete($);else if(B4.size>=qR)B4.delete(B4.keys().next().value);B4.set($,Z)}async function jR($){if(!g4)return null;try{let Z=Bun.file(O0.join(g4,`cw-${WJ($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function HR($,Z){if(!g4)return;try{if(!fs.existsSync(g4))fs.mkdirSync(g4,{recursive:!0});await Bun.write(O0.join(g4,`cw-${WJ($)}.css`),Z)}catch{}}async function dU($){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 OR(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==O0.dirname(Y))$.push(O0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(O0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(O0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(O0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(O0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(O0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=O0.dirname(Y);if(Z){let X=[O0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),O0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),O0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),O0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),O0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),O0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(O0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(O0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function UJ(){if(KJ)return U5;KJ=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await dU(Y);if(X){if(U5=X,!process.env.STACKS_DEV_QUIET)console.log(`${M.green}[Crosswind]${M.reset} CSS engine loaded`);return U5}}let Z=OR();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await dU(Y);if(X){if(U5=X,!process.env.STACKS_DEV_QUIET)console.log(`${M.green}[Crosswind]${M.reset} CSS engine loaded from ${O0.dirname(O0.dirname(Y))}`);return U5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${M.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${M.reset}`),console.warn(`${M.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${M.reset}`),null}}function LR(){B4.clear()}function VR(){U5=null,KJ=!1,h1=null,r$="",B4.clear(),k3=null}async function _J($){try{if(!BR({name:"crosswind",cwd:$}))return null;let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=O0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${M.green}[Crosswind]${M.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${M.yellow}[Crosswind]${M.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function _5($){if(W5)return r$;W5=!0;try{let Z=await UJ();if(!Z||!Z.build)return W5=!1,"";if(!h1)h1=await _J($);if(!h1)return W5=!1,"";let Y=Z.defaultConfig?.theme||{},X=h1.theme||{},J={...Z.defaultConfig,...h1,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(r$=G.css,console.log(`${M.cyan}[Crosswind]${M.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let W=O0.isAbsolute(J.output)?J.output:O0.join($,J.output),U=O0.dirname(W);if(!fs.existsSync(U))fs.mkdirSync(U,{recursive:!0});await Bun.write(W,G.css)}return W5=!1,G.css}catch(Z){return console.error(`${M.red}[Crosswind]${M.reset} Build error:`,Z),W5=!1,r$}}async function a$($){h1=null,await _5($)}function FR(){return r$}function S3($){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 C3($,Z){try{let Y=await UJ();if(!Y)return"";let X=S3($);if(X.size===0)return"";let J=Z?O0.resolve(Z):process.cwd();if(!g4)g4=O0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${k3||"default"}::${Q}`,K=B4.get(G);if(K!==void 0)return GJ(G,K),K;let W=await jR(G);if(W!==null)return GJ(G,W),W;if(!h1){let N=null;try{let{loadStxConfig:w}=await Promise.resolve().then(() => (i0(),P3)),R=await w(J);if(R.css)if(typeof R.css==="string"){let T=O0.isAbsolute(R.css)?R.css:O0.resolve(J,R.css);if(await Bun.file(T).exists()){let E=await import(T);N=E.default||E,console.log(`${M.green}[Crosswind]${M.reset} Loaded config from stx.config.ts \u2192 ${R.css}`)}}else{if(N={...R.css,content:R.css.content||[],preflight:R.css.preflight??!0,minify:R.css.minify??!1},R.css.config){let T=O0.isAbsolute(R.css.config)?R.css.config:O0.resolve(J,R.css.config);if(await Bun.file(T).exists()){let E=await import(T);N={...E.default||E,...N}}}console.log(`${M.green}[Crosswind]${M.reset} Using inline CSS config from stx.config.ts`)}}catch{}h1=N||await _J(J);try{k3=WJ(JSON.stringify(h1??{}))}catch{k3="unhashable"}}let U=Y.defaultConfig||Y.config,_=h1||{},z=U.theme||{},q=(_.theme||{}).extend||{},j={...z};if(Object.keys(q).length>0)j.extend=q;let H=[...U.safelist||[],..._.safelist||[]],O={...U,..._,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:H},V=new Y.CSSGenerator(O);for(let N of H)V.generate(N);for(let N of X)V.generate(N);let L=V.toCSS(!0,!1),F=O.shortcuts||_.shortcuts||{};for(let[N,w]of Object.entries(F)){if(!X.has(N)&&!H.includes(N))continue;let R=w.split(/\s+/).filter(Boolean);for(let T of R)V.generate(T)}L=V.toCSS(!0,!1);let A=L.split(`
|
|
906
906
|
`);for(let[N,w]of Object.entries(F)){if(!X.has(N)&&!H.includes(N))continue;let R=w.split(/\s+/).filter(Boolean),T=[],E=[];for(let I of R){let k=I.startsWith("dark:"),P=`.${(k?I.slice(5):I).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let b=0;b<A.length;b++){let g=A[b].trim();if(g===`${P} {`||g.startsWith(`${P} {`)){let s=b,p="";while(s<A.length){if(p+=A[s],A[s].includes("}"))break;s++}let C=p.match(/\{([^}]+)\}/);if(C)if(k)E.push(C[1].trim());else T.push(C[1].trim());break}}}if(T.length)L+=`
|
|
907
907
|
.${N} { ${T.join(" ")} }`;if(E.length)L+=`
|
|
908
908
|
@media (prefers-color-scheme: dark) { .dark .${N} { ${E.join(" ")} } }`}return GJ(G,L),HR(G,L),L}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function S0($,Z){let Y=await C3($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
|
|
909
909
|
${Y}
|
|
910
910
|
</style>`,J=/<style data-crosswind="generated">[\s\S]*?<\/style>/g;if(J.test($)){let Q=!1;return $.replace(J,()=>{if(Q)return"";return Q=!0,X})}if($.includes("</head>"))return $.replace("</head>",`${X}
|
|
911
911
|
</head>`);if($.includes("<body"))return $.replace(/<body([^>]*)>/,`<body$1>
|
|
912
|
-
${X}`);return X+$}var
|
|
912
|
+
${X}`);return X+$}var U5=null,KJ=!1,h1=null,r$="",W5=!1,qR=256,B4,g4=null,k3=null;var e1=D(()=>{n$();B4=new Map});function uU(){return`
|
|
913
913
|
// STX Lifecycle Runtime
|
|
914
914
|
(function() {
|
|
915
915
|
if (typeof window === 'undefined') return;
|
|
@@ -1795,7 +1795,7 @@ ${hR()}
|
|
|
1795
1795
|
${Y}
|
|
1796
1796
|
</script>`}function Y_($,Z,Y){if(Z_=0,!mR($))return $;let X=xR($);if(X.length===0)return $;let J=uR($,X),Q=dR(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
1797
1797
|
`+J.slice(G);else J+=Q;return J}function uR($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${y3(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${y3(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${y3(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${y3(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function mR($){return/x-data\s*=\s*["']/.test($)}var Z_=0,yR=0;var X_=D(()=>{o0()});function q4($,Z){try{let Y=$.trim();if(R0(Y))return M0(Y,Object.keys(Z))(...Object.values(Z));else return V0(Y,Z)}catch{return!1}}var FJ=D(()=>{p0()});function Q_($){J_=$}function G_(){return J_}function K_($){x3={...x3,...$}}function W_(){x3={}}function AJ($,Z={}){let Y=x3[$]||cR[$]||{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 U_($,Z={}){let{message:Y,help:X}=AJ($,Z);return X?`${Y}
|
|
1798
|
-
Help: ${X}`:Y}function v3($){for(let[Z,Y]of Object.entries(J0))if(Y===$)return Z;return}var cR,x3,J_="en",J0;var f3=D(()=>{cR={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},x3={};J0={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function
|
|
1798
|
+
Help: ${X}`:Y}function v3($){for(let[Z,Y]of Object.entries(J0))if(Y===$)return Z;return}var cR,x3,J_="en",J0;var f3=D(()=>{cR={1001:{message:"Unclosed directive: {{directive}}",help:"Make sure to close the directive with the appropriate end tag"},1002:{message:"Unclosed expression at position {{position}}",help:"Check for missing closing braces }}"},1003:{message:"Invalid directive syntax: {{directive}}",help:"Review the directive documentation for correct syntax"},1004:{message:"Malformed expression: {{expression}}",help:"Check for syntax errors in your expression"},1005:{message:"Unexpected token: {{token}}",help:"Remove or fix the unexpected token"},1101:{message:"Undefined variable: {{variable}}",help:"Make sure the variable is defined in the template context"},1102:{message:"Type error: {{details}}",help:"Check that you are using the correct types"},1103:{message:"Evaluation error: {{details}}",help:"Review the expression for errors"},1104:{message:"Infinite loop detected in {{location}}",help:"Check your loop conditions"},1105:{message:"Circular reference detected: {{path}}",help:"Remove the circular dependency"},1201:{message:"Unsafe expression blocked: {{expression}}",help:"This expression contains potentially dangerous code"},1202:{message:"Path traversal attempt blocked: {{path}}",help:"Use only relative paths within allowed directories"},1203:{message:"Potential XSS attempt blocked",help:"Sanitize user input before rendering"},1204:{message:"Code injection attempt blocked: {{code}}",help:"Avoid executing dynamic code"},1205:{message:"Prohibited DOM API usage: {{api}}",help:"Use STX.useRefs(), STX.useRef(), STX.el() and other STX helpers instead of direct DOM manipulation"},1301:{message:"File not found: {{path}}",help:"Check that the file exists and the path is correct"},1302:{message:"Error reading file: {{path}}",help:"Check file permissions and encoding"},1303:{message:"Invalid file path: {{path}}",help:"Use a valid file path"},1304:{message:"Permission denied: {{path}}",help:"Check file permissions"},1401:{message:"Invalid configuration: {{details}}",help:"Review your stx.config.ts file"},1402:{message:"Missing required configuration: {{key}}",help:"Add the required configuration option"},1403:{message:"Deprecated configuration: {{key}}",help:"Update to the new configuration format"},1501:{message:"Component not found: {{name}}",help:"Check that the component exists in your components directory"},1502:{message:"Invalid props for component {{name}}: {{details}}",help:"Check the component prop requirements"},1503:{message:"Error rendering component {{name}}: {{details}}",help:"Check the component template for errors"},1601:{message:"Filter not found: {{filter}}",help:"Register the filter or check the filter name"},1602:{message:"Invalid arguments for filter {{filter}}: {{details}}",help:"Check the filter documentation for correct arguments"},1603:{message:"Expression evaluation timed out",help:"Simplify the expression or increase the timeout"}},x3={};J0={UNCLOSED_DIRECTIVE:1001,UNCLOSED_EXPRESSION:1002,INVALID_DIRECTIVE_SYNTAX:1003,MALFORMED_EXPRESSION:1004,UNEXPECTED_TOKEN:1005,UNDEFINED_VARIABLE:1101,TYPE_ERROR:1102,EVALUATION_ERROR:1103,INFINITE_LOOP:1104,CIRCULAR_REFERENCE:1105,UNSAFE_EXPRESSION:1201,PATH_TRAVERSAL:1202,XSS_ATTEMPT:1203,CODE_INJECTION:1204,DOM_API_VIOLATION:1205,FILE_NOT_FOUND:1301,FILE_READ_ERROR:1302,INVALID_FILE_PATH:1303,PERMISSION_DENIED:1304,INVALID_CONFIG:1401,MISSING_REQUIRED_CONFIG:1402,DEPRECATED_CONFIG:1403,COMPONENT_NOT_FOUND:1501,INVALID_PROPS:1502,COMPONENT_RENDER_ERROR:1503,FILTER_NOT_FOUND:1601,INVALID_FILTER_ARGS:1602,EXPRESSION_TIMEOUT:1603}});function z5(){return!1}function h4(){return!z5()||process.env.STX_DEBUG==="true"}function s$(){return!1}import lR from"path";function z_($){B5={...B5,...$}}function o$(){return{...B5}}function B_(){B5={...__}}function t$($){if(!B5.showRelativePaths||!$)return $;let Z=B5.baseDir||process.cwd();try{let Y=lR.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var __,B5,d4,NJ,d1,wJ,q5,e$;var g3=D(()=>{f3();__={showRelativePaths:!1,enableAutoRecovery:h4(),logRecoveryWarnings:!0},B5={...__};d4=class d4 extends Error{code;filePath;line;column;context;numericCode;constructor($,Z,Y,X,J,Q,G){super($);this.code=Z;this.filePath=Y;this.line=X;this.column=J;this.context=Q;if(this.name="StxError",this.numericCode=G||J0.EVALUATION_ERROR,this.filePath)this.filePath=t$(this.filePath)}};NJ=class NJ extends d4{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||J0.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};d1=class d1 extends d4{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||J0.EVALUATION_ERROR);this.name="StxRuntimeError"}};wJ=class wJ extends d4{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||J0.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};q5=class q5 extends d4{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||J0.FILE_NOT_FOUND);this.name="StxFileError"}};e$=class e$ extends d4{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||J0.DOM_API_VIOLATION);this.name="StxValidationError"}}});function h3($){let{type:Z,message:Y,code:X,filePath:J,line:Q,column:G,template:K,offset:W,snippet:U,suggestion:_,format:z="text"}=$,B=Q,q=G;if(!B&&K&&W!==void 0){let L=j_(K,W);B=L.line,q=L.column}let j=J?t$(J):void 0,H=X?v3(X):void 0,O={type:Z,code:X,codeName:H,message:Y,filePath:j,line:B,column:q,snippet:U,suggestion:_,timestamp:new Date().toISOString()},V;switch(z){case"html":V=iR(O);break;case"json":V=JSON.stringify(O,null,2);break;case"console":V=nR(O,K,W);break;case"text":default:V=pR(O,K,W);break}return{formatted:V,data:O}}function pR($,Z,Y){let X=[],J=$.code?` [${$.codeName||$.code}]`:"";if(X.push(`[${$.type} Error${J}]`),$.filePath){let Q=$.filePath;if($.line){if(Q+=`:${$.line}`,$.column)Q+=`:${$.column}`}X.push(`at ${Q}`)}if(X.push(`
|
|
1799
1799
|
${$.message}`),Z&&$.line){let Q=rR(Z,$.line,2);if(Q)X.push(`
|
|
1800
1800
|
${Q}`)}if($.snippet)X.push(`
|
|
1801
1801
|
Snippet: ${$.snippet}`);if($.suggestion)X.push(`
|
|
@@ -1825,16 +1825,16 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
1825
1825
|
`)}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($)}
|
|
1826
1826
|
`;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(`
|
|
1827
1827
|
|
|
1828
|
-
`),"utf-8")}}async flush(){await this.writeQueue}}var d3,J1,
|
|
1829
|
-
@end${K}`;X.push(`Added ${_} missing @end${K}`)}}if(X.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),X.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:X}},createFallbackContent($,Z){if(h4())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};J1=new u3,
|
|
1828
|
+
`),"utf-8")}}async flush(){await this.writeQueue}}var d3,J1,j5;var F_=D(()=>{g3();d3={isEnabled(){return o$().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=o$();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 z=0;z<_;z++)Y+=`
|
|
1829
|
+
@end${K}`;X.push(`Added ${_} missing @end${K}`)}}if(X.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),X.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:X}},createFallbackContent($,Z){if(h4())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};J1=new u3,j5={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(`
|
|
1830
1830
|
`)}}});import RJ from"path";function sR($){let Z={"&":"&","<":"<",">":">",'"':""","'":"'"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function $7($,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=sR(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:_,replacement:z,name:B}of U)if(_.test(K))K=K.replace(_,z),W=!0,G.push(`Removed ${B} from parameter`);if(!J){let _=K;if(K=K.split("").filter((z)=>{let B=z.charCodeAt(0);return B>=32&&B!==127}).join(""),K!==_)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function A_($,Z){let Y=$.replace(/\0/g,"");Y=Y.replace(/\\/g,"/"),Y=Y.replace(/^[a-z][a-z0-9+.-]*:/i,"");while(Y.includes("../")||Y.includes("./"))Y=Y.replace(/\.\.\//g,"").replace(/\.\//g,"");if(!m3.isValidFilePath(Y,Z))return null;return Y}function N_($){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 w_($,Z={}){return $.map((Y)=>$7(Y,Z))}function MJ($){let Z={};for(let[Y,X]of Object.entries($)){if(!m3.isValidVariableName(Y))continue;if(typeof X==="string"){let J=$7(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?$7(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=MJ(X);else Z[Y]=X}return Z}var m3;var R_=D(()=>{m3={isValidFilePath($,Z){let Y=$.replace(/\\/g,"/");if(Y.includes("\x00"))return!1;if(Y.includes("../")||Y.includes("..\\")||Y===".."||Y.startsWith("../")||Y.endsWith("/..")||Y.includes("/..\\")||Y.includes("\\../"))return!1;if(/^[a-z][a-z0-9+.-]*:/i.test(Y))return!1;if(Y.startsWith("/")){if(["/etc/","/root/","/var/","/usr/","/bin/","/sbin/","/proc/","/sys/","/dev/","/boot/","/home/","/private/","/Library/","/System/"].some((Q)=>Y===Q.slice(0,-1)||Y.startsWith(Q)))return!1}if(/^[a-z]:/i.test(Y)){if(["Windows/","Windows\\","System32/","System32\\","Program Files/","Program Files\\"].some((Q)=>Y.includes(Q)))return!1}if(Z){let J=RJ.resolve(Z,$),Q=RJ.resolve(Z);if(!J.startsWith(Q+RJ.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 M_=D(()=>{f3();V_();F_();R_();g3()});var M1=D(()=>{M_()});class Z7{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,Y=this.column,X=this.source[this.pos];if(/\s/.test(X))return this.readWhitespace($,Z,Y);if(X==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(X==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(X==='"'||X==="'")return this.readString(X,$,Z,Y);if(X==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(X)||X==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(X))return this.readIdentifier($,Z,Y);if(X==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(X==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(X==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(X==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(X))return this.advance(),{type:"OPERATOR",value:X,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(X))return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
|
|
1831
1831
|
`)this.advance();return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readBlockComment($,Z,Y){this.advance(2);while(this.pos<this.source.length-1){if(this.source[this.pos]==="*"&&this.source[this.pos+1]==="/"){this.advance(2);break}this.advance()}return{type:"COMMENT",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readString($,Z,Y,X){this.advance();while(this.pos<this.source.length){let J=this.source[this.pos];if(J==="\\"){this.advance(2);continue}if(J===$){this.advance();break}this.advance()}return{type:"STRING",value:this.source.slice(Z,this.pos),start:Z,end:this.pos,line:Y,column:X}}readTemplateString($,Z,Y){this.advance();let X=0,J=256;while(this.pos<this.source.length){let Q=this.source[this.pos];if(Q==="\\"){this.advance(2);continue}if(Q==="$"&&this.peek(1)==="{"){if(X>=J){this.pos=this.source.length;break}this.advance(2),X++;continue}if(Q==="{"&&X>0){X++,this.advance();continue}if(Q==="}"&&X>0){X--,this.advance();continue}if(Q==="`"&&X===0){this.advance();break}this.advance()}return{type:"TEMPLATE_STRING",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readNumber($,Z,Y){if(this.source[this.pos]==="0"){let X=this.peek(1)?.toLowerCase();if(X==="x"||X==="o"||X==="b"){this.advance(2);while(this.pos<this.source.length&&/[\da-f_]/i.test(this.source[this.pos]))this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}}while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance();if(this.source[this.pos]==="."&&/\d/.test(this.peek(1)||"")){this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(/e/i.test(this.source[this.pos]||"")){if(this.advance(),/[+-]/.test(this.source[this.pos]||""))this.advance();while(this.pos<this.source.length&&/[\d_]/.test(this.source[this.pos]))this.advance()}if(this.source[this.pos]==="n")this.advance();return{type:"NUMBER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readIdentifier($,Z,Y){while(this.pos<this.source.length&&/[\w$]/.test(this.source[this.pos]))this.advance();return{type:"IDENTIFIER",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readDirective($,Z,Y){this.advance();while(this.pos<this.source.length&&/[a-z]/i.test(this.source[this.pos]))this.advance();return{type:"DIRECTIVE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}advance($=1){for(let Z=0;Z<$&&this.pos<this.source.length;Z++){if(this.source[this.pos]===`
|
|
1832
|
-
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function d0($,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 TJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function c3($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function j4($,Z){let Y=oR($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function oR($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=d0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function u4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,z=U?U.index:1/0;if(_<z)J++,Q=_+W[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function EJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j4($,X);if(!J)return null;let Q=J.endPos,G=u4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",z=J.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=j4(K,V);if(!L){U++;continue}_="elseif",z=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U}),_="else",z=void 0,U+=5,B=U;continue}}U++}return W.push({type:_,condition:z,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function O5($){let Z=[],Y=/@if\s*\(/g,X=Y.exec($);while(X!==null){if(Z.some((G)=>X.index>G.start&&X.index<G.end)){X=Y.exec($);continue}let Q=EJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function Y7($,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=d0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),z=U+1,B=u4($,Z,Y,z);if(B===-1){Q=J.exec($);continue}let q=$.slice(z,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function l3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j4($,X);if(!J)return null;let Q=J.endPos,G=u4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,z=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(z++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(z--,_)_.content+=j[0];U+=j[0].length;continue}if(z>0){if(_)_.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,F=j4(K,L);if(!F){U++;continue}_={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var T_=()=>{};function D_($){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,_=tR($,U,W);if(_===-1){Y=G+1;continue}let z=$.slice(U,_).trim(),B=_+W.length;Z.push({fullMatch:$.slice(G,B),expression:z,start:G,end:B,isRaw:Q}),Y=B}return Z}function tR($,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 k_($){let Z=c3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=eR(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function eR($){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=d0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=IJ(G);return{name:X,args:K}}function IJ($){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 S_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=d0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function C_($){let Z=[],X=new Z7($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,B=E_(X,J,$);J=B.nextIndex,Z.push({type:"variable",name:_,value:$.slice(z,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,z=U.value==="{"?"}":"]",B=d0($,U.value,z,_);if(B!==-1){let q=$.slice(_,B+1);if(J=I_(X,B+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=E_(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let B=d0($,"{","}",z);if(B!==-1)Z.push({type:"function",name:_,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),J=I_(X,B+1)}}}else J++}return Z}function E_($,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 I_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var b_=()=>{};var X7=D(()=>{T_();b_()});function $M($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=l3(X,G);if(!K)break;try{let W;if(R0(K.expression))W=M0(K.expression,Object.keys(Z))(...Object.values(Z));else W=V0(K.expression,Z);let U="",_=!1;for(let z of K.cases)if(z.type==="default"){if(!_)U=z.content.trim()}else try{let B;if(z.value&&R0(z.value))B=M0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)B=V0(z.value,Z);if(W===B){U=z.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=_0("Switch",`Error evaluating @switch expression: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function I6($,Z,Y){let X=$;X=$M(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=j4(X,K+7);if(!W)break;let U=W.endPos,_=u4(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,_),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(z))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(z))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(z))!==null)F.push({pos:A.index,type:"else"});F.sort((N,w)=>N.pos-w.pos);for(let N of F)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){q=N.pos;break}}let j;if(q!==-1){let H=z.slice(0,q),O=z.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${z}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=kJ(X,Z,Y),X=SJ(X,Z,Y),X=DJ(X,Z);let J=()=>{let Q=O5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let z;if(_.condition&&R0(_.condition))z=M0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)z=V0(_.condition,Z);if(z)W=_.content,U=!0}catch(z){W=_0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${z instanceof Error?z.message:String(z)}`,J0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=_0("If",`Error processing @if block: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function P_($){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 DJ($,Z){let Y=$;function X(K,W,U,_){let z=1,B=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&z>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)z++,B=V+H[0].length;else if(L<1/0){if(z--,z===0)return L;B=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,z=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=z.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+5),q=P_(B);if(q)_=q.value,z=U+5+q.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=_?q4(`auth?.check && auth?.user?.[${_}]`,Z):q4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+6),q=P_(B);if(q)_=q.value,z=U+6+q.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=_?q4(`!auth?.check || !auth?.user?.[${_}]`,Z):q4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let z=q4(U,Z);_.push(z)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let B=z.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],E;while((E=A.exec(V))!==null)T.push({pos:E.index,type:"open"});while((E=N.exec(V))!==null)T.push({pos:E.index,type:"close"});while((E=w.exec(V))!==null)T.push({pos:E.index,type:"elseDirective"});while((E=R.exec(V))!==null)T.push({pos:E.index,type:"else"});T.sort((b,g)=>b.pos-g.pos);for(let b of T){if(b.type==="open"){F++;continue}if(b.type==="close"){F--;continue}if(F===0)L.push(b)}let I=[],k=0;for(let b=0;b<L.length;b++){let g=L[b];if(I.push({content:V.slice(k,g.pos),ability:void 0}),g.type==="elseDirective"){let s=V.slice(g.pos+`@${U}`.length),p=G(s);if(p){I[I.length-1]={content:V.slice(k,g.pos)},k=g.pos+`@${U}`.length+p.paramsEnd,I.push({content:"",ability:p.ability,type:p.type,id:p.id}),I.pop();let C=L[b+1],h=C?C.pos:V.length;I.push({content:V.slice(k,h),ability:p.ability,type:p.type,id:p.id}),k=h}}else k=g.pos+5}if(k<V.length){let b=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(k),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(k)})}let S=Q(j.ability,j.type,j.id),x=K==="can"?S:!S,P="";if(x)P=I[0]?.content||"";else{let b=!1;for(let g=1;g<I.length;g++){let s=I[g];if(s.isFinalElse){P=s.content,b=!0;break}if(s.ability){let p=Q(s.ability,s.type,s.id);if(K==="can"?p:!p){P=s.content,b=!0;break}}}if(!b&&I.length>0){let g=I[I.length-1];if(g.isFinalElse)P=g.content}}Y=Y.substring(0,B)+P+Y.substring(O+`@${W}`.length),_=!0}}return Y}function kJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let z=new RegExp(`@${G}\\s*\\(`),B=Q.match(z);if(!B||B.index===void 0)break;let q=B.index,j=j4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=u4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,N=0;while(N<V.length){let w=V.indexOf("@",N);if(w===-1)break;let R=V.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=w;break}N=w+1}try{let w=W(L.trim()),R;if(F!==-1){let T=V.slice(0,F),E=V.slice(F+5);R=w?T:E}else R=w?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),_=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=_0(U,`Error processing @${G} directive: ${R}`,J0.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=q4(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=q4(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 SJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),z=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let S=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;L+=S[0].length,U=J===S[2]}let F=1,A=L,N=-1;while(F>0&&A<j.length){_.lastIndex=A,z.lastIndex=A;let S=_.exec(j),x=z.exec(j),P=S?S.index:1/0,b=x?x.index:1/0;if(P<b)F++,A=P+S[0].length;else if(b<1/0){if(F--,F===0){N=b;break}A=b+x[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,N),R=-1,T=0,E=0;while(E<w.length){let S=w.indexOf("@",E);if(S===-1)break;let x=w.substring(S);if(B.test(x)){T++,E=S+1;continue}if(q.test(x)){T--,E=S+1;continue}if(T===0&&/^@else(?![a-z])/.test(x)){R=S;break}E=S+1}let I;if(R!==-1){let S=w.slice(0,R),x=w.slice(R+5);I=U?S:x}else I=U?w:"";let k=`@${W}`.length;j=j.substring(0,V)+I+j.substring(N+k),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p3=D(()=>{FJ();M1();X7();p0()});function bJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function m4($,Z){if(!$)return Z?.nonceGenerator?.()??bJ();let Y=CJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??bJ(),CJ.set($,Y);return Y}function ZM($){CJ.delete($)}function PJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function n3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${PJ($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function YM($){return{enabled:!0,directives:{strict:y_,moderate:i3,relaxed:x_,api:v_}[$]||i3,useNonce:$==="strict",addMetaTag:!0}}function XM($,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 yJ($,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?m4(Y,Z):void 0,J=n3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1833
|
-
${J}`)}function JM($,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 xJ($,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?m4(Z,Q):void 0;return n3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return m4(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=m4(Z,Q);return J}function QM(){return[f_,g_]}function GM($){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 h_($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function KM($,Z){if(!$.enabled)return{};let Y=$.useNonce?m4(Z,$):void 0,X=PJ($.directives,Y);return{[h_($.reportOnly)]:X}}var CJ,y_,i3,x_,v_,f_,g_,WM;var vJ=D(()=>{CJ=new WeakMap;y_={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},i3={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},x_={"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'"]},v_={"default-src":["'none'"],"frame-ancestors":["'none'"]};f_={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?m4(Y,Q):void 0;return n3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},g_={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return m4(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};WM={enabled:!1,reportOnly:!1,directives:i3,useNonce:!1,addMetaTag:!0}});import UM from"crypto";function zM($=_M){let Z=UM.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return fJ=Z,Z}function BM(){if(!fJ)zM();return fJ}function qM($=d_){let Z=BM();return`<input type="hidden" name="${$}" value="${Z}">`}function u_($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return qM(X||d_)})}var _M=40,d_="_token",fJ=null;var m_=()=>{};async function gJ($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let J=$;for(let Q of X.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await jM(J,Q,Z,Y,X);else J=await HM(J,Q,Z,Y,X)}return J}async function jM($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=W5(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),z=[],B=_.exec(U);while(B!==null){let[q,j="",H=""]=B,O=B.index||0;try{let V=j?c_(j):[],L=H.trim(),F=await G(L,V,Y,X);z.push({original:q,processed:F,startIndex:O})}catch(V){let L=V instanceof Error?V.message:String(V);if(J.debug)console.error(`Error processing custom directive @${Q}:`,V);z.push({original:q,processed:_0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,J0.EVALUATION_ERROR),startIndex:O})}B=_.exec(U)}for(let q=z.length-1;q>=0;q--){let{original:j,processed:H}=z[q];U=U.replace(j,H)}return U}async function HM($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=W5(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let O=c_(j),V=await G("",O,Y,X);U.push({original:q,processed:V,startIndex:H})}catch(O){let V=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:_0("CustomDirective",`Error in @${Q}(${j}): ${V}`,J0.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let z=W5(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),B=z.exec(K);while(B!==null){let[q]=B,j=B.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:_0("CustomDirective",`Error in @${Q}: ${O}`,J0.EVALUATION_ERROR),startIndex:j})}B=z.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function c_($){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 hJ=D(()=>{M1();f4()});var s3={};e(s3,{useTitle:()=>i_,useSeoMeta:()=>J7,usePageTitle:()=>i_,useHead:()=>l4,resetHead:()=>l_,renderHtmlAttrs:()=>r_,renderHead:()=>n_,renderBodyAttrs:()=>a_,processTitleDirective:()=>t_,processMetaDirective:()=>e_,processHeadDirective:()=>o_,getPageMeta:()=>a3,getHead:()=>L5,definePageMeta:()=>p_,applyHead:()=>s_});function L5(){return c4}function a3(){return r3}function l_(){c4={},OM.length=0,r3={}}function l4($){c4=LM(c4,$)}function LM($,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 J7($){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});l4({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function p_($){if(r3={...r3,...$},$.title||$.description)J7({title:$.title,description:$.description})}function i_($){let Z=typeof $==="function"?$():$;l4({title:Z})}function n_($=c4){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${D6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${D6(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}="${D6(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}="${D6(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}="${D6(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
|
|
1834
|
-
`)}function r_($=c4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${
|
|
1835
|
-
`,""}),headContent:Z.trim()}}function t_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return l4({title:G}),""})}function e_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,z=J.includes(":")?{property:J,content:U}:{name:J,content:U};return l4({meta:[z]}),""})}var c4,OM,r3;var p4=D(()=>{c4={},OM=[],r3={}});import VM from"crypto";function t0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function FM($){return{...t3,...$.forms?.classes}}function o3($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function AM(){return VM.randomUUID()}function NM($,Z,Y,X){let J=FM(X),Q=$;return Q=Xz(Q,Z),Q=
|
|
1836
|
-
${
|
|
1837
|
-
${
|
|
1832
|
+
`)this.line++,this.column=0;else this.column++;this.pos++}}peek($){return this.source[this.pos+$]}saveState(){return{pos:this.pos,line:this.line,column:this.column}}restoreState($){this.pos=$.pos,this.line=$.line,this.column=$.column}}function d0($,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 TJ($,Z){let Y=Z,X={paren:0,bracket:0,brace:0},J=null,Q=0;while(Y<$.length){let G=$[Y];if((Y>0?$[Y-1]:"")==="\\"&&J){Y++;continue}if((G==='"'||G==="'")&&!J){J=G,Y++;continue}if(G===J&&J!=="`"){J=null,Y++;continue}if(G==="`"&&!J){J="`",Y++;continue}if(G==="`"&&J==="`"&&Q===0){J=null,Y++;continue}if(J==="`"&&G==="$"&&$[Y+1]==="{"){Q++,Y+=2;continue}if(Q>0){if(G==="{")Q++;else if(G==="}")Q--;Y++;continue}if(J){Y++;continue}if(X.paren===0&&X.bracket===0&&X.brace===0){if($.slice(Y,Y+2)==="}}"||$.slice(Y,Y+3)==="!!}")break;if(G===","||G===";")break}if(G==="(")X.paren++;else if(G===")"){if(X.paren--,X.paren<0)break}else if(G==="[")X.bracket++;else if(G==="]"){if(X.bracket--,X.bracket<0)break}else if(G==="{")X.brace++;else if(G==="}"){if(X.brace--,X.brace<0)break}Y++}return{expression:$.slice(Z,Y),endPos:Y}}function c3($){let Z=[],Y="",X={paren:0,bracket:0,brace:0},J=null,Q=0;for(let G=0;G<$.length;G++){let K=$[G];if((G>0?$[G-1]:"")==="\\"&&J){Y+=K;continue}if((K==='"'||K==="'")&&!J){J=K,Y+=K;continue}if(K===J&&J!=="`"){J=null,Y+=K;continue}if(K==="`"&&!J){J="`",Y+=K;continue}if(K==="`"&&J==="`"&&Q===0){J=null,Y+=K;continue}if(J==="`"&&K==="$"&&$[G+1]==="{"){Q++,Y+=K+$[G+1],G++;continue}if(Q>0&&K==="{"){Q++,Y+=K;continue}if(Q>0&&K==="}"){Q--,Y+=K;continue}if(J){Y+=K;continue}if(K==="(")X.paren++;else if(K===")")X.paren--;else if(K==="[")X.bracket++;else if(K==="]")X.bracket--;else if(K==="{")X.brace++;else if(K==="}")X.brace--;if(K==="|"&&$[G+1]!=="|"&&(G===0||$[G-1]!=="|")&&$[G-1]!=="\\"&&X.paren===0&&X.bracket===0&&X.brace===0){Z.push(Y.trim()),Y="";continue}if(K==="|"&&$[G-1]==="\\"&&!J){Y=Y.slice(0,-1)+K;continue}Y+=K}if(Y.trim())Z.push(Y.trim());return Z}function j4($,Z){let Y=oR($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function oR($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=d0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function u4($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),_=W?W.index:1/0,z=U?U.index:1/0;if(_<z)J++,Q=_+W[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function EJ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j4($,X);if(!J)return null;let Q=J.endPos,G=u4($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_="if",z=J.expression,B=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U});let V=U+O[0].length,L=j4(K,V);if(!L){U++;continue}_="elseif",z=L.expression,U=L.endPos,B=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:_,condition:z,content:K.substring(B,U),start:Q+B,end:Q+U}),_="else",z=void 0,U+=5,B=U;continue}}U++}return W.push({type:_,condition:z,content:K.slice(B),start:Q+B,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function H5($){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=EJ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function Y7($,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=d0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let _=$.slice(W+1,U),z=U+1,B=u4($,Z,Y,z);if(B===-1){Q=J.exec($);continue}let q=$.slice(z,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:_,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function l3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j4($,X);if(!J)return null;let Q=J.endPos,G=u4($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,_=null,z=0;while(U<K.length){let B=K.slice(U),q=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(q){if(z++,_)_.content+=q[0];U+=q[0].length;continue}if(j){if(z--,_)_.content+=j[0];U+=j[0].length;continue}if(z>0){if(_)_.content+=K[U];U++;continue}let H=B.match(/^@case\s*/),O=B.match(/^@default(?![a-z])/),V=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(_)W.push(_);let L=U+H[0].length,F=j4(K,L);if(!F){U++;continue}_={type:"case",value:F.expression,content:""},U=F.endPos}else if(O&&B.startsWith("@default")){if(_)W.push(_);_={type:"default",content:""},U+=O[0].length}else if(V&&B.startsWith("@break"))U+=V[0].length;else{if(_)_.content+=K[U];U++}}if(_)W.push(_);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var T_=()=>{};function D_($){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,_=tR($,U,W);if(_===-1){Y=G+1;continue}let z=$.slice(U,_).trim(),B=_+W.length;Z.push({fullMatch:$.slice(G,B),expression:z,start:G,end:B,isRaw:Q}),Y=B}return Z}function tR($,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 k_($){let Z=c3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=eR(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function eR($){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=d0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=IJ(G);return{name:X,args:K}}function IJ($){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 S_($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=d0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function C_($){let Z=[],X=new Z7($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,B=E_(X,J,$);J=B.nextIndex,Z.push({type:"variable",name:_,value:$.slice(z,B.endPos),exported:G,start:K.start,end:B.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let _=U.start,z=U.value==="{"?"}":"]",B=d0($,U.value,z,_);if(B!==-1){let q=$.slice(_,B+1);if(J=I_(X,B+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=E_(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let _=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let B=d0($,"{","}",z);if(B!==-1)Z.push({type:"function",name:_,value:$.slice(W,B+1).replace(/^export\s+/,""),exported:G,start:W,end:B+1}),J=I_(X,B+1)}}}else J++}return Z}function E_($,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 I_($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var b_=()=>{};var X7=D(()=>{T_();b_()});function $M($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=l3(X,G);if(!K)break;try{let W;if(R0(K.expression))W=M0(K.expression,Object.keys(Z))(...Object.values(Z));else W=V0(K.expression,Z);let U="",_=!1;for(let z of K.cases)if(z.type==="default"){if(!_)U=z.content.trim()}else try{let B;if(z.value&&R0(z.value))B=M0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)B=V0(z.value,Z);if(W===B){U=z.content.trim(),_=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),_=_0("Switch",`Error evaluating @switch expression: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,G)+_+X.substring(K.end);break}}return X}function E6($,Z,Y){let X=$;X=$M(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=j4(X,K+7);if(!W)break;let U=W.endPos,_=u4(X,"unless","endunless",U);if(_===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,_),B=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,F=[],A;while((A=O.exec(z))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(z))!==null)F.push({pos:A.index,type:"close"});while((A=L.exec(z))!==null)F.push({pos:A.index,type:"else"});F.sort((N,w)=>N.pos-w.pos);for(let N of F)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){q=N.pos;break}}let j;if(q!==-1){let H=z.slice(0,q),O=z.slice(q+5);j=`@if (${B})${O}@else ${H}@endif`}else j=`@if (!(${B}))${z}@endif`;X=X.substring(0,K)+j+X.substring(_+10),Q=!0}}X=kJ(X,Z,Y),X=SJ(X,Z,Y),X=DJ(X,Z);let J=()=>{let Q=H5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let _ of K.branches){if(U)break;if(_.type==="else")W=_.content,U=!0;else try{let z;if(_.condition&&R0(_.condition))z=M0(_.condition,Object.keys(Z))(...Object.values(Z));else if(_.condition)z=V0(_.condition,Z);if(z)W=_.content,U=!0}catch(z){W=_0(_.type==="if"?"If":"Elseif",`Error in @${_.type}(${_.condition}): ${z instanceof Error?z.message:String(z)}`,J0.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),_=_0("If",`Error processing @if block: ${U}`,J0.EVALUATION_ERROR);X=X.substring(0,K.start)+_+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function P_($){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 DJ($,Z){let Y=$;function X(K,W,U,_){let z=1,B=_,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(B<K.length&&z>0){q.lastIndex=B,j.lastIndex=B;let H=q.exec(K),O=j.exec(K),V=H?H.index:1/0,L=O?O.index:1/0;if(V<L)z++,B=V+H[0].length;else if(L<1/0){if(z--,z===0)return L;B=L+O[0].length}else break}return-1}function J(K,W,U){let _=0,z=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=z.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,V)=>O.pos-V.pos);for(let O of j)if(O.type==="open")_++;else if(O.type==="close")_--;else if(O.type==="else"&&_===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+5),q=P_(B);if(q)_=q.value,z=U+5+q.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"auth","endauth"),V;if(!Z.auth)V=!1;else V=_?q4(`auth?.check && auth?.user?.[${_}]`,Z):q4("auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,_,z,B=Y.slice(U+6),q=P_(B);if(q)_=q.value,z=U+6+q.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),O=J(H,"guest","endguest"),V;if(!Z.auth)V=!0;else V=_?q4(`!auth?.check || !auth?.user?.[${_}]`,Z):q4("!auth?.check",Z);let L;if(O!==-1){let F=H.slice(0,O),A=H.slice(O+5);L=V?F:A}else L=V?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let _=[K];if(W)_.push(W);if(U){let z=q4(U,Z);_.push(z)}return Z.permissions.check(..._)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",_=!0;while(_){_=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let B=z.index,q=Y.slice(B+`@${K}`.length),j=G(q);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${W} \u2014 the block was skipped.`);break}let V=Y.slice(H,O),L=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],E;while((E=A.exec(V))!==null)T.push({pos:E.index,type:"open"});while((E=N.exec(V))!==null)T.push({pos:E.index,type:"close"});while((E=w.exec(V))!==null)T.push({pos:E.index,type:"elseDirective"});while((E=R.exec(V))!==null)T.push({pos:E.index,type:"else"});T.sort((b,g)=>b.pos-g.pos);for(let b of T){if(b.type==="open"){F++;continue}if(b.type==="close"){F--;continue}if(F===0)L.push(b)}let I=[],k=0;for(let b=0;b<L.length;b++){let g=L[b];if(I.push({content:V.slice(k,g.pos),ability:void 0}),g.type==="elseDirective"){let s=V.slice(g.pos+`@${U}`.length),p=G(s);if(p){I[I.length-1]={content:V.slice(k,g.pos)},k=g.pos+`@${U}`.length+p.paramsEnd,I.push({content:"",ability:p.ability,type:p.type,id:p.id}),I.pop();let C=L[b+1],h=C?C.pos:V.length;I.push({content:V.slice(k,h),ability:p.ability,type:p.type,id:p.id}),k=h}}else k=g.pos+5}if(k<V.length){let b=I[I.length-1];if(L.length>0&&L[L.length-1].type==="else")I.push({content:V.slice(k),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(k)})}let S=Q(j.ability,j.type,j.id),x=K==="can"?S:!S,P="";if(x)P=I[0]?.content||"";else{let b=!1;for(let g=1;g<I.length;g++){let s=I[g];if(s.isFinalElse){P=s.content,b=!0;break}if(s.ability){let p=Q(s.ability,s.type,s.id);if(K==="can"?p:!p){P=s.content,b=!0;break}}}if(!b&&I.length>0){let g=I[I.length-1];if(g.isFinalElse)P=g.content}}Y=Y.substring(0,B)+P+Y.substring(O+`@${W}`.length),_=!0}}return Y}function kJ($,Z,Y){let X=$;function J(Q,G,K,W,U){let _=!0;while(_){_=!1;let z=new RegExp(`@${G}\\s*\\(`),B=Q.match(z);if(!B||B.index===void 0)break;let q=B.index,j=j4(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=u4(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(H,O),L=j.expression,F=-1,A=0,N=0;while(N<V.length){let w=V.indexOf("@",N);if(w===-1)break;let R=V.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){F=w;break}N=w+1}try{let w=W(L.trim()),R;if(F!==-1){let T=V.slice(0,F),E=V.slice(F+5);R=w?T:E}else R=w?V:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),_=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=_0(U,`Error processing @${G} directive: ${R}`,J0.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=q4(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=q4(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 SJ($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let _=new RegExp(`@${K}(?![a-z])`,"g"),z=new RegExp(`@${W}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,_.lastIndex=0;let O=_.exec(j);if(!O)break;let V=O.index,L=V+O[0].length;if(K==="env"){let S=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!S)break;L+=S[0].length,U=J===S[2]}let F=1,A=L,N=-1;while(F>0&&A<j.length){_.lastIndex=A,z.lastIndex=A;let S=_.exec(j),x=z.exec(j),P=S?S.index:1/0,b=x?x.index:1/0;if(P<b)F++,A=P+S[0].length;else if(b<1/0){if(F--,F===0){N=b;break}A=b+x[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,N),R=-1,T=0,E=0;while(E<w.length){let S=w.indexOf("@",E);if(S===-1)break;let x=w.substring(S);if(B.test(x)){T++,E=S+1;continue}if(q.test(x)){T--,E=S+1;continue}if(T===0&&/^@else(?![a-z])/.test(x)){R=S;break}E=S+1}let I;if(R!==-1){let S=w.slice(0,R),x=w.slice(R+5);I=U?S:x}else I=U?w:"";let k=`@${W}`.length;j=j.substring(0,V)+I+j.substring(N+k),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p3=D(()=>{FJ();M1();X7();p0()});function bJ($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function m4($,Z){if(!$)return Z?.nonceGenerator?.()??bJ();let Y=CJ.get($);if(!Y)Y=Z?.nonceGenerator?.()??bJ(),CJ.set($,Y);return Y}function ZM($){CJ.delete($)}function PJ($,Z){let Y=[];for(let[X,J]of Object.entries($)){if(J===void 0||J===null)continue;if(typeof J==="boolean"){if(J)Y.push(X);continue}if(Array.isArray(J)){let Q=[...J];if(Z&&(X==="script-src"||X==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${X} ${Q.join(" ")}`)}}return Y.join("; ")}function n3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${PJ($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function YM($){return{enabled:!0,directives:{strict:y_,moderate:i3,relaxed:x_,api:v_}[$]||i3,useNonce:$==="strict",addMetaTag:!0}}function XM($,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 yJ($,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?m4(Y,Z):void 0,J=n3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
1833
|
+
${J}`)}function JM($,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 xJ($,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?m4(Z,Q):void 0;return n3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return m4(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=m4(Z,Q);return J}function QM(){return[f_,g_]}function GM($){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 h_($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function KM($,Z){if(!$.enabled)return{};let Y=$.useNonce?m4(Z,$):void 0,X=PJ($.directives,Y);return{[h_($.reportOnly)]:X}}var CJ,y_,i3,x_,v_,f_,g_,WM;var vJ=D(()=>{CJ=new WeakMap;y_={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},i3={"default-src":["'self'"],"script-src":["'self'"],"style-src":["'self'","'unsafe-inline'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'","https:"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'self'"],"base-uri":["'self'"],"form-action":["'self'"],"upgrade-insecure-requests":!0},x_={"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'"]},v_={"default-src":["'none'"],"frame-ancestors":["'none'"]};f_={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?m4(Y,Q):void 0;return n3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},g_={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return m4(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};WM={enabled:!1,reportOnly:!1,directives:i3,useNonce:!1,addMetaTag:!0}});import UM from"crypto";function zM($=_M){let Z=UM.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return fJ=Z,Z}function BM(){if(!fJ)zM();return fJ}function qM($=d_){let Z=BM();return`<input type="hidden" name="${$}" value="${Z}">`}function u_($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return qM(X||d_)})}var _M=40,d_="_token",fJ=null;var m_=()=>{};async function gJ($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let J=$;for(let Q of X.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)J=await jM(J,Q,Z,Y,X);else J=await HM(J,Q,Z,Y,X)}return J}async function jM($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,_=K5(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),z=[],B=_.exec(U);while(B!==null){let[q,j="",H=""]=B,O=B.index||0;try{let V=j?c_(j):[],L=H.trim(),F=await G(L,V,Y,X);z.push({original:q,processed:F,startIndex:O})}catch(V){let L=V instanceof Error?V.message:String(V);if(J.debug)console.error(`Error processing custom directive @${Q}:`,V);z.push({original:q,processed:_0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,J0.EVALUATION_ERROR),startIndex:O})}B=_.exec(U)}for(let q=z.length-1;q>=0;q--){let{original:j,processed:H}=z[q];U=U.replace(j,H)}return U}async function HM($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=K5(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],_=W.exec(K);while(_!==null){let[q,j=""]=_,H=_.index||0;try{let O=c_(j),V=await G("",O,Y,X);U.push({original:q,processed:V,startIndex:H})}catch(O){let V=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:_0("CustomDirective",`Error in @${Q}(${j}): ${V}`,J0.EVALUATION_ERROR),startIndex:H})}_=W.exec(K)}let z=K5(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),B=z.exec(K);while(B!==null){let[q]=B,j=B.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:_0("CustomDirective",`Error in @${Q}: ${O}`,J0.EVALUATION_ERROR),startIndex:j})}B=z.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function c_($){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 hJ=D(()=>{M1();f4()});var s3={};e(s3,{useTitle:()=>i_,useSeoMeta:()=>J7,usePageTitle:()=>i_,useHead:()=>l4,resetHead:()=>l_,renderHtmlAttrs:()=>r_,renderHead:()=>n_,renderBodyAttrs:()=>a_,processTitleDirective:()=>t_,processMetaDirective:()=>e_,processHeadDirective:()=>o_,getPageMeta:()=>a3,getHead:()=>O5,definePageMeta:()=>p_,applyHead:()=>s_});function O5(){return c4}function a3(){return r3}function l_(){c4={},OM.length=0,r3={}}function l4($){c4=LM(c4,$)}function LM($,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 J7($){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});l4({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function p_($){if(r3={...r3,...$},$.title||$.description)J7({title:$.title,description:$.description})}function i_($){let Z=typeof $==="function"?$():$;l4({title:Z})}function n_($=c4){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${I6(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${I6(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}="${I6(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}="${I6(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}="${I6(String(K))}"`}).filter(Boolean).join(" ");if(X)Z.push(`<script ${Q}>${X}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let X=Y.type?` type="${Y.type}"`:"";Z.push(`<style${X}>${Y.content}</style>`)}return Z.join(`
|
|
1834
|
+
`)}function r_($=c4){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${I6(Y)}"`).join(" ")}function a_($=c4){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${I6(Y)}"`).join(" ")}function I6($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function s_($=c4){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 o_($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
1835
|
+
`,""}),headContent:Z.trim()}}function t_($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return l4({title:G}),""})}function e_($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,z=J.includes(":")?{property:J,content:U}:{name:J,content:U};return l4({meta:[z]}),""})}var c4,OM,r3;var p4=D(()=>{c4={},OM=[],r3={}});import VM from"crypto";function t0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function FM($){return{...t3,...$.forms?.classes}}function o3($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function AM(){return VM.randomUUID()}function NM($,Z,Y,X){let J=FM(X),Q=$;return Q=Xz(Q,Z),Q=L5(Q,Z),Q=e3(Q,Z,J),Q=$Z(Q,Z,J),Q}function L5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=AM();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${t0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,J)=>{let Q=J.toUpperCase();if(J&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${t0(Q)}">`;return X}),Y}function e3($,Z,Y=t3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"POST",z=K||W||"",B=i4(U),q=_.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${t0(j)}" action="${t0(z)}"${B?` ${B}`:""}>`;if(H+=`
|
|
1836
|
+
${L5("@csrf",Z)}`,!["GET","POST"].includes(q))H+=`
|
|
1837
|
+
${L5(`@method('${q}')`,Z)}`;return H}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,K,W,U="")=>{let _=Q||G||"",z=K||W||"",B=i4(U),q=Q7(_,Z),j=q!==void 0&&q!==null?q:z||"",H=B.match(/type=['"]([^'"]+)['"]/i),O=H?H[1]:"text",V=G7(_,Z),L=B.match(/class=['"]([^'"]+)['"]/i),F=o3(L?L[1]:"",Y.input,V,Y.inputError),A=B.replace(/class=['"][^'"]+['"]/i,"");return A=A.replace(/type=['"][^'"]+['"]/i,""),`<input type="${t0(O)}" name="${t0(_)}" value="${t0(j)}" class="${F}"${A?` ${A}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let W=i4(G),U=Q7(Q,Z)||K.trim(),_=G7(Q,Z),z=W.match(/class=['"]([^'"]+)['"]/i),B=o3(z?z[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${t0(Q)}" class="${B}"${q?` ${q}`:""}>${t0(U)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(J,Q,G="",K)=>{let W=i4(G),U=Q7(Q,Z),_=G7(Q,Z),z=W.match(/class=['"]([^'"]+)['"]/i),B=o3(z?z[1]:"",Y.input,_,Y.inputError),q=W.replace(/class=['"][^'"]+['"]/i,""),j=K;if(U!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,O,V)=>{if((Array.isArray(U)?U.some((F)=>String(F)===V):String(U)===V)&&!O.includes("selected"))return O.replace(/(<option)/,"$1 selected");return H});return`<select name="${t0(Q)}" class="${B}"${q?` ${q}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="1",K="")=>{let W=i4(K),U=Q7(Q,Z),_=U!==void 0&&(Array.isArray(U)?U.some((j)=>String(j)===G):U===!0||String(U)===G),z=W.match(/class=['"]([^'"]+)['"]/i),B=z?z[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${t0(Q)}" value="${t0(G)}" class="${B}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,K="")=>{let W=i4(K),U=Q7(Q,Z),_=U!==void 0&&U===G,z=W.match(/class=['"]([^'"]+)['"]/i),B=z?z[1]:Y.checkInput,q=W.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${t0(Q)}" value="${t0(G)}" class="${B}"${_?" checked":""}${q?` ${q}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="")=>{let K=i4(G),W=K.match(/accept=['"]([^'"]+)['"]/i),U=W?W[1]:"",_=K.includes("multiple"),z=G7(Q,Z),B=K.match(/class=['"]([^'"]+)['"]/i),q=o3(B?B[1]:"",Y.input,z,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${t0(Q)}"`,`class="${q}"`];if(U)H.push(`accept="${t0(U)}"`);if(_)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(J,Q,G="",K)=>{let W=i4(G),U=W.match(/class=['"]([^'"]+)['"]/i),_=U?U[1]:Y.label,z=W.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${t0(Q)}" class="${_}"${z?` ${z}`:""}>${K}</label>`}),X}function $Z($,Z,Y=t3){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(G7(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return $z(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 $z(J,Z)}let W=K.trim();if(R0(W)){let U=V0(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 G7($,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 $z($,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 Q7($,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 i4($){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 wM($,Z){Zz[$]=Z}function dJ($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function Yz($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=dJ(G),W=Zz[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 RM($,Z){let Y={};for(let[X,J]of Object.entries(Z)){let Q=Yz(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function Xz($,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=dJ(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 MM($){uJ[$.name]=$}function Jz($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=dJ(Q),K=uJ[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 TM($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=Jz($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function EM($,Z){let Y=JSON.stringify(Z);return`
|
|
1838
1838
|
<script>
|
|
1839
1839
|
(function() {
|
|
1840
1840
|
const form = document.getElementById('${$}');
|
|
@@ -1887,7 +1887,7 @@ catch { return 'Please enter a valid URL'; } },
|
|
|
1887
1887
|
});
|
|
1888
1888
|
})();
|
|
1889
1889
|
</script>`.trim()}var t3,Zz,uJ;var mJ=D(()=>{p0();t3={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};Zz={required:($,Z,Y)=>{if($===void 0||$===null||$===""||Array.isArray($)&&$.length===0)return`The ${Y} field is required.`;return null},email:($,Z,Y)=>{if(!$)return null;if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($)))return`The ${Y} field must be a valid email address.`;return null},min:($,Z,Y)=>{if(!$)return null;let X=Number(Z[0]);if(typeof $==="string"&&$.length<X)return`The ${Y} field must be at least ${X} characters.`;if(typeof $==="number"&&$<X)return`The ${Y} field must be at least ${X}.`;if(Array.isArray($)&&$.length<X)return`The ${Y} field must have at least ${X} items.`;return null},max:($,Z,Y)=>{if(!$)return null;let X=Number(Z[0]);if(typeof $==="string"&&$.length>X)return`The ${Y} field must not exceed ${X} characters.`;if(typeof $==="number"&&$>X)return`The ${Y} field must not exceed ${X}.`;if(Array.isArray($)&&$.length>X)return`The ${Y} field must not have more than ${X} items.`;return null},confirmed:($,Z,Y)=>{if(Z[0]!==void 0&&$!==Z[0])return`The ${Y} confirmation does not match.`;return null},numeric:($,Z,Y)=>{if(!$)return null;if(Number.isNaN(Number($)))return`The ${Y} field must be a number.`;return null},integer:($,Z,Y)=>{if(!$)return null;if(!Number.isInteger(Number($)))return`The ${Y} field must be an integer.`;return null},alpha:($,Z,Y)=>{if(!$)return null;if(!/^[a-z]+$/i.test(String($)))return`The ${Y} field must only contain letters.`;return null},alphanumeric:($,Z,Y)=>{if(!$)return null;if(!/^[a-z0-9]+$/i.test(String($)))return`The ${Y} field must only contain letters and numbers.`;return null},url:($,Z,Y)=>{if(!$)return null;try{return new URL(String($))?null:null}catch{return`The ${Y} field must be a valid URL.`}},regex:($,Z,Y)=>{if(!$)return null;try{if(!new RegExp(Z[0]).test(String($)))return`The ${Y} field format is invalid.`;return null}catch{return`The ${Y} field has an invalid validation pattern.`}},in:($,Z,Y)=>{if(!$)return null;if(!Z.includes(String($)))return`The ${Y} field must be one of: ${Z.join(", ")}.`;return null},notIn:($,Z,Y)=>{if(!$)return null;if(Z.includes(String($)))return`The ${Y} field must not be: ${Z.join(", ")}.`;return null},date:($,Z,Y)=>{if(!$)return null;let X=new Date($);if(Number.isNaN(X.getTime()))return`The ${Y} field must be a valid date.`;return null},before:($,Z,Y)=>{if(!$)return null;let X=new Date($),J=new Date(Z[0]);if(X>=J)return`The ${Y} field must be before ${Z[0]}.`;return null},after:($,Z,Y)=>{if(!$)return null;let X=new Date($),J=new Date(Z[0]);if(X<=J)return`The ${Y} field must be after ${Z[0]}.`;return null}};uJ={required:{name:"required",validate:($)=>{if($===null||$===void 0||$==="")return"This field is required";if(Array.isArray($)&&$.length===0)return"This field is required";return!0},toHtml5:()=>["required"],message:"This field is required"},email:{name:"email",validate:($)=>{if(!$)return!0;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(String($))||"Please enter a valid email address"},toHtml5:()=>['type="email"'],message:"Please enter a valid email address"},url:{name:"url",validate:($)=>{if(!$)return!0;try{return new URL(String($)).protocol.startsWith("http")||"Please enter a valid URL"}catch{return"Please enter a valid URL"}},toHtml5:()=>['type="url"'],message:"Please enter a valid URL"},numeric:{name:"numeric",validate:($)=>{if(!$)return!0;return!Number.isNaN(Number($))||"Please enter a number"},toHtml5:()=>['type="number"'],message:"Please enter a number"},integer:{name:"integer",validate:($)=>{if(!$)return!0;let Z=Number($);return Number.isInteger(Z)||"Please enter a whole number"},toHtml5:()=>['type="number"','step="1"'],message:"Please enter a whole number"},alpha:{name:"alpha",validate:($)=>{if(!$)return!0;return/^[a-z]+$/i.test(String($))||"Please enter only letters"},toHtml5:()=>['pattern="[a-zA-Z]+"'],message:"Please enter only letters"},alphanumeric:{name:"alphanumeric",validate:($)=>{if(!$)return!0;return/^[a-z0-9]+$/i.test(String($))||"Please enter only letters and numbers"},toHtml5:()=>['pattern="[a-zA-Z0-9]+"'],message:"Please enter only letters and numbers"},min:{name:"min",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length>=Y||`Must be at least ${Y} characters`;if(typeof $==="number")return $>=Y||`Must be at least ${Y}`;if(Array.isArray($))return $.length>=Y||`Must have at least ${Y} items`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`min="${$[0]}"`],message:"Must be at least {{param}} characters"},max:{name:"max",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length<=Y||`Must be no more than ${Y} characters`;if(typeof $==="number")return $<=Y||`Must be no more than ${Y}`;if(Array.isArray($))return $.length<=Y||`Must have no more than ${Y} items`;return!0},toHtml5:($)=>[`maxlength="${$[0]}"`,`max="${$[0]}"`],message:"Must be no more than {{param}} characters"},between:{name:"between",validate:($,Z)=>{if(!$)return!0;let[Y,X]=Z.map(Number);if(typeof $==="string")return $.length>=Y&&$.length<=X||`Must be between ${Y} and ${X} characters`;if(typeof $==="number")return $>=Y&&$<=X||`Must be between ${Y} and ${X}`;return!0},toHtml5:($)=>[`minlength="${$[0]}"`,`maxlength="${$[1]}"`],message:"Must be between {{min}} and {{max}}"},confirmed:{name:"confirmed",validate:($,Z,Y)=>{let X=Object.keys(Y);for(let J of X)if(J.endsWith("_confirmation")&&Y[J]===$)return!0;return"Confirmation does not match"},message:"Confirmation does not match"},in:{name:"in",validate:($,Z)=>{if(!$)return!0;return Z.includes(String($))||`Must be one of: ${Z.join(", ")}`},message:"Must be one of: {{values}}"},notIn:{name:"notIn",validate:($,Z)=>{if(!$)return!0;return!Z.includes(String($))||`Must not be: ${Z.join(", ")}`},message:"Must not be: {{values}}"},regex:{name:"regex",validate:($,Z)=>{if(!$)return!0;try{return new RegExp(Z[0]).test(String($))||"Invalid format"}catch{return"Invalid format"}},toHtml5:($)=>[`pattern="${$[0]}"`],message:"Invalid format"},date:{name:"date",validate:($)=>{if(!$)return!0;let Z=new Date(String($));return!Number.isNaN(Z.getTime())||"Please enter a valid date"},toHtml5:()=>['type="date"'],message:"Please enter a valid date"},before:{name:"before",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),X=new Date(Z[0]);return Y<X||`Must be before ${Z[0]}`},toHtml5:($)=>[`max="${$[0]}"`],message:"Must be before {{date}}"},after:{name:"after",validate:($,Z)=>{if(!$)return!0;let Y=new Date(String($)),X=new Date(Z[0]);return Y>X||`Must be after ${Z[0]}`},toHtml5:($)=>[`min="${$[0]}"`],message:"Must be after {{date}}"},size:{name:"size",validate:($,Z)=>{if(!$)return!0;let Y=Number(Z[0]);if(typeof $==="string")return $.length===Y||`Must be exactly ${Y} characters`;if(Array.isArray($))return $.length===Y||`Must have exactly ${Y} items`;return!0},message:"Must be exactly {{size}}"},phone:{name:"phone",validate:($)=>{if(!$)return!0;return/^\+?\(?\d{1,4}\)?[-\s./\d]*$/.test(String($))||"Please enter a valid phone number"},toHtml5:()=>['type="tel"','pattern="\\+?\\(?\\d{1,4}\\)?[-\\s./\\d]*"'],message:"Please enter a valid phone number"}}});import lJ from"path";async function IM(){if(K7!==void 0)return K7;try{K7=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{K7=null}return K7}function DM($){if($)delete H1[$];else for(let Z of Object.keys(H1))delete H1[Z]}function kM(){let $=Object.entries(H1).map(([Z,Y])=>({locale:Z,loadedAt:new Date(Y.loadedAt),keyCount:Gz(Y.translations)}));return{size:Object.keys(H1).length,locales:Object.keys(H1),entries:$}}function Gz($,Z=0){for(let Y of Object.values($))if(Z++,Y&&typeof Y==="object"&&!Array.isArray(Y))Z=Gz(Y,Z);return Z}function SM($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}function CM($){if(H1[$])return"loaded";return H4[$]||"idle"}function bM($){return H4[$]==="loading"}function PM($){return!!H1[$]}async function Kz($,Z){let{locales:Y,parallel:X=!0,priority:J={},onLocaleLoaded:Q,onComplete:G,onError:K}=$,W=X?Y:[...Y].sort((U,_)=>(J[_]||0)-(J[U]||0));if(X){let U=W.map(async(_)=>{try{await W7(_,Z),Q?.(_)}catch(z){K?.(_,z instanceof Error?z:Error(String(z)))}});await Promise.all(U)}else for(let U of W)try{await W7(U,Z),Q?.(U)}catch(_){K?.(U,_ instanceof Error?_:Error(String(_)))}G?.()}function yM($,Z){queueMicrotask(()=>{Kz($,Z).catch((Y)=>{if(Z.debug)console.error("Background preload error:",Y)})})}async function W7($,Z){if({...YZ,...Z.i18n}.cache&&H1[$]){let J=H1[$],Q=Z.i18n?.cacheMaxAge??0;if(!SM(J,Q))return J.translations}if(u1[$]?.state==="loading")return u1[$].promise;H4[$]="loading";let X=pJ($,Z).then((J)=>{return H4[$]="loaded",delete u1[$],J}).catch((J)=>{throw H4[$]="error",u1[$]={promise:X,state:"error",error:J instanceof Error?J:Error(String(J))},J});return u1[$]={promise:X,state:"loading"},X}function Wz($){return H1[$]?.translations}async function xM($,Z){let Y=Wz($);if(Y)return Y;return W7($,Z)}async function vM($,Z){if(H1[$])return H1[$].translations;if(u1[$]){if(Z)return Promise.race([u1[$].promise,new Promise((Y,X)=>setTimeout(()=>X(Error(`Timeout waiting for locale: ${$}`)),Z))]);return u1[$].promise}throw Error(`Locale "${$}" is not loading. Call loadTranslationLazy first.`)}function fM(){return Object.entries(H4).filter(([$,Z])=>Z==="loading").map(([$])=>$)}function gM($){if($)delete u1[$],delete H4[$];else{for(let Z of Object.keys(u1))delete u1[Z];for(let Z of Object.keys(H4))delete H4[Z]}}async function pJ($,Z){let Y={...YZ,...Z.i18n},X=lJ.isAbsolute(Y.translationsDir)?Y.translationsDir:lJ.resolve(Z.root||process.cwd(),Y.translationsDir);try{let J=await IM(),Q=J?await J($,{translationsDir:X,defaultLocale:Y.defaultLocale,sources:cM(Y.format)}):await hM($,Y,X);if(Q===void 0){if($!==Y.defaultLocale)return pJ(Y.defaultLocale,Z);return{}}let G=Q;if(Y.cache)H1[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(J){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,J);if($!==Y.defaultLocale)return pJ(Y.defaultLocale,Z);return{}}}async function hM($,Z,Y){let X=lJ.join(Y,`${$}${dM(Z.format)}`);try{let J=await import(X);return J.default||J}catch(J){try{let Q=await Bun.file(X).text();if(Z.format==="yaml"||Z.format==="yml")return uM(Q);if(Z.format==="json")return JSON.parse(Q);throw J}catch{return}}}function dM($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function uM($){let Z={},Y=$.split(`
|
|
1890
|
-
`),X=[{obj:Z,indent:-1}];for(let J of Y){let Q=J.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(X.length>1&&X[X.length-1].indent>=G)X.pop();let K=X[X.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,_]=W,z=U.trim(),B=_.trim();if(B==="")K[z]={},X.push({obj:K[z],indent:G});else K[z]=mM(B)}}return Z}function mM($){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 cM($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function Uz($,Z){return W7($,Z)}function lM($,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 _z($,Z={}){return zz($,Z)}function zz($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=pM($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=iM(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 pM($,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 iM($,Z){let Y=nM($);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 rM(J,Y.slice(2).join(","),Z);case"select":return sM(J,Y.slice(2).join(","));case"selectordinal":return oM(J,Y.slice(2).join(","));case"number":return eM(J,Y[2]?.trim());case"date":return $T(J,Y[2]?.trim());case"time":return ZT(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function nM($){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 rM($,Z,Y){let X=Number($)||0,J=iJ(Z),Q=`=${X}`;if(J[Q])return cJ(J[Q],X,Y);let G=aM(X);if(J[G])return cJ(J[G],X,Y);if(J.other)return cJ(J.other,X,Y);return String(X)}function cJ($,Z,Y){let X=$.replace(/#/g,String(Z));return zz(X,Y)}function aM($){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 sM($,Z){let Y=String($||""),X=iJ(Z);if(X[Y])return X[Y];return X.other||String($)}function oM($,Z){let Y=Number($)||0,X=iJ(Z),J=tM(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 tM($){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 iJ($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function eM($,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 $T($,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 ZT($,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 Bz($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function ZZ($,Z,Y=!0,X={}){let J=$.split("."),Q=Z;for(let K of J){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(Bz(G))return _z(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),W=G.split("|");G=lM(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 nJ($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...YZ,...X.i18n},K=await Uz(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await Qz(J,Q,async(_,z,B,q,j)=>{try{let H={};if(B)try{let V=[()=>JSON.parse(B),()=>{let L=`{"data":${B}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return h0(B,Z)}];for(let L of V)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(V){if(X.debug)console.error("Error parsing parameters for @translate directive:",V)}return ZZ(z,K,G.fallbackToKey,H)||q.trim()}catch(H){if(X.debug)console.error("Error processing @translate directive:",H);return _0("Translate",`Error in @translate('${z}'): ${H instanceof Error?H.message:String(H)}`,J0.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(X.debug){console.warn(`Processing translations in template. Sections: ${J.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let _=[...J.matchAll(W)];console.warn(`Found ${_.length} @translate matches`),_.forEach((z,B)=>console.warn(`Match ${B}: ${z[0]}, Key: ${z[1]}, Params: ${z[2]||"none"}`))}return J=await Qz(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(_,z,B,q)=>{try{let j={};if(B)try{let H=[()=>JSON.parse(B),()=>{let O=`{"data":${B}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return h0(B,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(X.debug)console.error("Error parsing parameters for @translate directive:",H)}return ZZ(z,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return _0("Translate",`Error in @translate('${z}'): ${j instanceof Error?j.message:String(j)}`,J0.EVALUATION_ERROR)}}),J}async function Qz($,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 YT($,Z=!0){return(Y,X={})=>{return ZZ(Y,$,Z,X)}}var K7,YZ,H1,u1,H4;var rJ=D(()=>{M1();p0();YZ={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},H1={},u1={},H4={}});var
|
|
1890
|
+
`),X=[{obj:Z,indent:-1}];for(let J of Y){let Q=J.replace(/#.*$/,"").trimEnd();if(!Q.trim())continue;let G=Q.search(/\S/);if(G===-1)continue;while(X.length>1&&X[X.length-1].indent>=G)X.pop();let K=X[X.length-1].obj,W=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(W){let[,,U,_]=W,z=U.trim(),B=_.trim();if(B==="")K[z]={},X.push({obj:K[z],indent:G});else K[z]=mM(B)}}return Z}function mM($){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 cM($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function Uz($,Z){return W7($,Z)}function lM($,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 _z($,Z={}){return zz($,Z)}function zz($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=pM($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=iM(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 pM($,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 iM($,Z){let Y=nM($);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 rM(J,Y.slice(2).join(","),Z);case"select":return sM(J,Y.slice(2).join(","));case"selectordinal":return oM(J,Y.slice(2).join(","));case"number":return eM(J,Y[2]?.trim());case"date":return $T(J,Y[2]?.trim());case"time":return ZT(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function nM($){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 rM($,Z,Y){let X=Number($)||0,J=iJ(Z),Q=`=${X}`;if(J[Q])return cJ(J[Q],X,Y);let G=aM(X);if(J[G])return cJ(J[G],X,Y);if(J.other)return cJ(J.other,X,Y);return String(X)}function cJ($,Z,Y){let X=$.replace(/#/g,String(Z));return zz(X,Y)}function aM($){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 sM($,Z){let Y=String($||""),X=iJ(Z);if(X[Y])return X[Y];return X.other||String($)}function oM($,Z){let Y=Number($)||0,X=iJ(Z),J=tM(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 tM($){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 iJ($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function eM($,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 $T($,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 ZT($,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 Bz($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function ZZ($,Z,Y=!0,X={}){let J=$.split("."),Q=Z;for(let K of J){if(Q===void 0||Q===null)break;Q=Q[K]}if(Q===void 0||Q===null)return Y?$:"";let G=String(Q);if(Bz(G))return _z(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),W=G.split("|");G=lM(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 nJ($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...YZ,...X.i18n},K=await Uz(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await Qz(J,Q,async(_,z,B,q,j)=>{try{let H={};if(B)try{let V=[()=>JSON.parse(B),()=>{let L=`{"data":${B}}`,F=JSON.parse(L);return typeof F.data==="object"?F.data:{}},()=>{return h0(B,Z)}];for(let L of V)try{if(H=L(),Object.keys(H).length>0)break}catch{}}catch(V){if(X.debug)console.error("Error parsing parameters for @translate directive:",V)}return ZZ(z,K,G.fallbackToKey,H)||q.trim()}catch(H){if(X.debug)console.error("Error processing @translate directive:",H);return _0("Translate",`Error in @translate('${z}'): ${H instanceof Error?H.message:String(H)}`,J0.EVALUATION_ERROR)}});let W=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]+\})\s*)?\)/g;if(X.debug){console.warn(`Processing translations in template. Sections: ${J.includes("<h2>Translation with Parameters</h2>")?"Parameters section found":"Parameters section missing"}`);let _=[...J.matchAll(W)];console.warn(`Found ${_.length} @translate matches`),_.forEach((z,B)=>console.warn(`Match ${B}: ${z[0]}, Key: ${z[1]}, Params: ${z[2]||"none"}`))}return J=await Qz(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(_,z,B,q)=>{try{let j={};if(B)try{let H=[()=>JSON.parse(B),()=>{let O=`{"data":${B}}`,V=JSON.parse(O);return typeof V.data==="object"?V.data:{}},()=>{return h0(B,Z)}];for(let O of H)try{if(j=O(),Object.keys(j).length>0)break}catch{}}catch(H){if(X.debug)console.error("Error parsing parameters for @translate directive:",H)}return ZZ(z,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return _0("Translate",`Error in @translate('${z}'): ${j instanceof Error?j.message:String(j)}`,J0.EVALUATION_ERROR)}}),J}async function Qz($,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 YT($,Z=!0){return(Y,X={})=>{return ZZ(Y,$,Z,X)}}var K7,YZ,H1,u1,H4;var rJ=D(()=>{M1();p0();YZ={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},H1={},u1={},H4={}});var k6={};e(k6,{streamingSuspenseDirective:()=>oJ,streamToResponse:()=>wz,streamTemplateSimple:()=>Vz,streamTemplate:()=>jz,renderStreamingPage:()=>Hz,registerStreamingDirectives:()=>Az,processStreamDirectives:()=>Oz,processSectionDirectives:()=>Nz,islandDirective:()=>tJ,generateHydrationRuntime:()=>Rz,extractStreamBoundaries:()=>Lz,createStreamRenderer:()=>Fz,buildSuspenseResolveScript:()=>JZ,SUSPENSE_RESOLVER_RUNTIME:()=>sJ});import XZ from"path";function XT($){let Z=[],Y=0,X;qz.lastIndex=0;while((X=qz.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 jz($,Z={},Y={}){let X={...O1,...Y,streaming:{...aJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:XZ.dirname($)};if(W.trim())await I0(W,_,$);let z=XT(U),B=new Set;if(!z.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",H=new RegExp(D6.source,"g");if(!(j!=="manual"&&H.test(U))){let V=await U0(U,_,$,X,B);for(let L=0;L<V.length;L+=J)Q.enqueue(V.slice(L,L+J)),await new Promise((F)=>setTimeout(F,0))}else{let V=[],L=new RegExp(D6.source,"g"),F;while((F=L.exec(U))!==null)V.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let A=0;for(let N of V){if(N.start>A){let R=U.slice(A,N.start);if(R.trim()){let T=await U0(R,_,$,X,B);Q.enqueue(T),await new Promise((E)=>setTimeout(E,0))}}let w=await U0(N.content,_,$,X,B);Q.enqueue(w),await new Promise((R)=>setTimeout(R,0)),A=N.end}if(A<U.length){let N=U.slice(A);if(N.trim()){let w=await U0(N,_,$,X,B);Q.enqueue(w)}}}}else{let j=new Map;for(let O of z)if(O.type==="shell"||O.type==="content"){let V=await U0(O.content,_,$,X,B);Q.enqueue(V)}else if(O.type==="suspense"&&O.name){let V=`stx-suspense-${O.name}`;Q.enqueue(`<div id="${V}" data-suspense="${O.name}" style="display:contents;">
|
|
1891
1891
|
<template data-suspense-fallback>Loading...</template>
|
|
1892
1892
|
</div>`),j.set(O.name,U0(O.content,_,$,X,B))}Q.enqueue(`
|
|
1893
1893
|
<script>
|
|
@@ -1911,7 +1911,7 @@ window.__stxSuspense.resolve('${$}', \`${X}\`);
|
|
|
1911
1911
|
</script>`}catch(Y){let X=Y instanceof Error?Y.message:String(Y);return`
|
|
1912
1912
|
<script>
|
|
1913
1913
|
window.__stxSuspense.resolve('${$}', '<div class="stx-error">Error loading content: ${P0(X)}</div>');
|
|
1914
|
-
</script>`}}function JT($,Z,Y){if(!Z||Z<=0)return $;let X,J=new Promise((Q,G)=>{X=setTimeout(()=>G(Error(`streaming boundary "${Y}" timed out after ${Z}ms`)),Z)});return Promise.race([$,J]).finally(()=>clearTimeout(X))}function Hz($,Z=[],Y={}){let X=Y.timeoutMs??0;return new ReadableStream({async start(J){try{if(J.enqueue($),Z.length>0)J.enqueue(sJ),await Promise.all(Z.map(async(Q)=>{let G=JT(Q.render(),X,Q.id);J.enqueue(await JZ(Q.id,G))}));J.close()}catch(Q){J.error(Q)}}})}function Oz($,Z){return $.replace(QT,(Y,X,J)=>{let Q=X.trim(),G=J.split(/@fallback/i),K=G[0].trim(),W=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[Q]=K,`<div data-suspense="${Q}">${W}</div>`})}function Lz($){let Z=$?.streamBoundaries;if(!Z||typeof Z!=="object")return;let Y=Object.entries(Z).filter(([,X])=>typeof X==="function");return Y.length>0?Y.map(([X,J])=>({id:X,render:J})):void 0}async function Vz($,Z={},Y={}){let X={...O1,...Y,streaming:{...aJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:XZ.dirname($)};if(W.trim())await I0(W,_,$);let z=new Set,B=X.streaming?.strategy||"auto",q=new RegExp(
|
|
1914
|
+
</script>`}}function JT($,Z,Y){if(!Z||Z<=0)return $;let X,J=new Promise((Q,G)=>{X=setTimeout(()=>G(Error(`streaming boundary "${Y}" timed out after ${Z}ms`)),Z)});return Promise.race([$,J]).finally(()=>clearTimeout(X))}function Hz($,Z=[],Y={}){let X=Y.timeoutMs??0;return new ReadableStream({async start(J){try{if(J.enqueue($),Z.length>0)J.enqueue(sJ),await Promise.all(Z.map(async(Q)=>{let G=JT(Q.render(),X,Q.id);J.enqueue(await JZ(Q.id,G))}));J.close()}catch(Q){J.error(Q)}}})}function Oz($,Z){return $.replace(QT,(Y,X,J)=>{let Q=X.trim(),G=J.split(/@fallback/i),K=G[0].trim(),W=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[Q]=K,`<div data-suspense="${Q}">${W}</div>`})}function Lz($){let Z=$?.streamBoundaries;if(!Z||typeof Z!=="object")return;let Y=Object.entries(Z).filter(([,X])=>typeof X==="function");return Y.length>0?Y.map(([X,J])=>({id:X,render:J})):void 0}async function Vz($,Z={},Y={}){let X={...O1,...Y,streaming:{...aJ,...Y.streaming}},J=X.streaming?.bufferSize||16384;return new ReadableStream({async start(Q){try{let G=await Bun.file($).text(),K=G.match(/<script\b[^>]*\bserver\b[^>]*>([\s\S]*?)<\/script>/i),W=K?K[1]:"",U=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),_={...Z,__filename:$,__dirname:XZ.dirname($)};if(W.trim())await I0(W,_,$);let z=new Set,B=X.streaming?.strategy||"auto",q=new RegExp(D6.source,"g");if(!(B!=="manual"&&q.test(U))){let H=await U0(U,_,$,X,z);for(let O=0;O<H.length;O+=J)Q.enqueue(H.slice(O,O+J))}else{let H=[],O=new RegExp(D6.source,"g"),V;while((V=O.exec(U))!==null)H.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let L=0;for(let F of H){if(F.start>L){let N=U.slice(L,F.start);if(N.trim()){let w=await U0(N,_,$,X,z);Q.enqueue(w)}}let A=await U0(F.content,_,$,X,z);Q.enqueue(A),L=F.end}if(L<U.length){let F=U.slice(L);if(F.trim()){let A=await U0(F,_,$,X,z);Q.enqueue(A)}}}Q.close()}catch(G){Q.error(G)}}})}async function Fz($,Z={}){let Y={...O1,...Z,streaming:{...aJ,...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;D6.lastIndex=0;while((U=D6.exec(G))!==null){let B=U[1],q=U[2];W[B]=q}let _=G.replace(D6,"");return{renderShell:async(B={})=>{let q={...B,__filename:$,__dirname:XZ.dirname($)};return await I0(Q,q,$),U0(_,q,$,Y,new Set)},renderSection:async(B,q={})=>{try{if(!W[B])return`<div class="error-message">Section "${P0(B)}" not found in template "${P0($)}"</div>`;let j={...q,__filename:$,__dirname:XZ.dirname($)};await I0(Q,j,$);let H=new Set;return await U0(W[B],j,$,Y,H)}catch(j){let H=j instanceof Error?j.message:String(j);return T0("Expression",H,$,W[B]||"",0,W[B]||"")}},getSections:()=>{return Object.keys(W)},getTemplate:()=>{return K}}}function Az($={}){let Z=[];if($.streaming?.enabled)Z.push(oJ);if($.hydration?.enabled)Z.push(tJ);return Z}async function Nz($,Z,Y,X={}){return $}function wz($,Z={}){let Y=new TextEncoder,X=$.pipeThrough(new TransformStream({transform(Q,G){G.enqueue(Y.encode(Q))}})),J=new Headers(Z.headers);if(!J.has("Content-Type"))J.set("Content-Type","text/html; charset=utf-8");if(!J.has("Transfer-Encoding"))J.set("Transfer-Encoding","chunked");if(!J.has("X-Content-Type-Options"))J.set("X-Content-Type-Options","nosniff");if(!J.has("X-Accel-Buffering"))J.set("X-Accel-Buffering","no");return new Response(X,{...Z,headers:J})}function Rz($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
|
|
1915
1915
|
`);if(Z==="loader")return`
|
|
1916
1916
|
(function() {
|
|
1917
1917
|
window.__stx = window.__stx || {};
|
|
@@ -2053,7 +2053,7 @@ else {
|
|
|
2053
2053
|
else {
|
|
2054
2054
|
stx.hydrate();
|
|
2055
2055
|
}
|
|
2056
|
-
})();`}var aJ,
|
|
2056
|
+
})();`}var aJ,D6,qz,sJ=`
|
|
2057
2057
|
<script>
|
|
2058
2058
|
(function(){
|
|
2059
2059
|
window.__stxSuspense = window.__stxSuspense || {
|
|
@@ -2073,18 +2073,18 @@ else {
|
|
|
2073
2073
|
}
|
|
2074
2074
|
};
|
|
2075
2075
|
})();
|
|
2076
|
-
</script>`,QT,oJ,tJ;var n4=D(()=>{i0();o0();W1();w0();aJ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},
|
|
2076
|
+
</script>`,QT,oJ,tJ;var n4=D(()=>{i0();o0();W1();w0();aJ={enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},D6=/<!-- @section:([\w-]+) -->([\s\S]*?)<!-- @endsection:\1 -->/g,qz=/<!-- @suspense:([\w-]+) -->([\s\S]*?)<!-- @endsuspense:\1 -->/g;QT=/@stream\s*\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)@endstream/gi;oJ={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} -->`}},tJ={name:"island",hasEndTag:!0,handler:($,Z,Y,X)=>{if(!Z||Z.length===0)throw Error("Island directive requires a name parameter");let J=Z[0].replace(/['"`]/g,""),Q=Z[1]?Z[1].replace(/['"`]/g,""):"lazy",G=`island-${J}-${Math.random().toString(36).substring(2,9)}`,K=$.match(/<script\s+props\s*>([\s\S]*?)<\/script>/i),W=K?K[1].trim():"",U=K?$.replace(K[0],""):$;return`<div data-island="${J}" data-island-id="${G}" data-priority="${Q}">
|
|
2077
2077
|
${U}
|
|
2078
2078
|
<script type="application/json" data-island-props="${G}">
|
|
2079
2079
|
${W?`{${W}}`:"{}"}
|
|
2080
2080
|
</script>
|
|
2081
|
-
</div>`}}});var Ez={};e(Ez,{warnUnbalancedTags:()=>eJ,findUnbalancedTags:()=>Tz});function
|
|
2082
|
-
`).length;Y.set(W,{count:1,firstLine:z})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(KT.has(K.toLowerCase()))continue;let W=Y.get(K)?.count??0,U=X.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function eJ($,Z){let Y;try{Y=Tz($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(Mz.has(X))return;Mz.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Y)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var GT,KT,Mz;var $9=D(()=>{GT=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),KT=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);Mz=new Set});import x1 from"path";import Z9 from"fs";function Iz($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function Dz($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class kz{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),Iz(J),Dz(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${Iz(J)}.stx`,`${Dz(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=x1.resolve(x1.dirname(Z),`${J}.stx`);if(await X0(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(x1.join(x1.dirname(U),"components"));if(W)K.push(W);let _=x1.join(x1.dirname(Z),"components");if(!K.includes(_))K.push(_);let z=process.cwd(),B=[x1.resolve(z,"src/components"),x1.resolve(z,"components"),x1.resolve(import.meta.dir,"components")];for(let q of B)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=x1.join(q,j);if(await X0(H))return H}try{if(!Z9.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=Z9.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let V=x1.join(q,O.name);for(let L of G){let F=x1.join(V,L);if(await X0(F))return F}}}catch{}}return null}}var L1;var Y9=D(()=>{w0();L1=new kz});function
|
|
2081
|
+
</div>`}}});var Ez={};e(Ez,{warnUnbalancedTags:()=>eJ,findUnbalancedTags:()=>Tz});function V5($){return $.replace(/[^\n]/g," ")}function Tz($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,V5).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,V5).replace(/<!--[\s\S]*?-->/g,V5).replace(/\{\{\{[\s\S]*?\}\}\}/g,V5).replace(/\{\{[\s\S]*?\}\}/g,V5).replace(/\{!![\s\S]*?!!\}/g,V5),Y=new Map,X=new Map,J=/<(\/?)([A-Za-z][\w-]*)\b(?:[^>"']|"[^"]*"|'[^']*')*?(\/?)>/g,Q;while((Q=J.exec(Z))!==null){let K=Q[1]==="/",W=Q[2],U=Q[3]==="/";if(GT.has(W.toLowerCase()))continue;if(U)continue;if(K)X.set(W,(X.get(W)??0)+1);else{let _=Y.get(W);if(_)_.count++;else{let z=Z.slice(0,Q.index).split(`
|
|
2082
|
+
`).length;Y.set(W,{count:1,firstLine:z})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(KT.has(K.toLowerCase()))continue;let W=Y.get(K)?.count??0,U=X.get(K)??0;if(W!==U)G.push({tag:K,opened:W,closed:U,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function eJ($,Z){let Y;try{Y=Tz($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(Mz.has(X))return;Mz.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:W}of Y)if(G>K){let U=W?` (first opened at line ${W})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${U} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var GT,KT,Mz;var $9=D(()=>{GT=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),KT=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);Mz=new Set});import x1 from"path";import Z9 from"fs";function Iz($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function Dz($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class kz{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,X){let J=$.endsWith(".stx")?$.slice(0,-4):$,Q=X?.__importedComponents;if(Q){let q=[J,J.toLowerCase(),Iz(J),Dz(J)];for(let j of q)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${Iz(J)}.stx`,`${Dz(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let q=x1.resolve(x1.dirname(Z),`${J}.stx`);if(await X0(q))return q;return null}let K=[],W=Y.componentsDir||"",U=X?.__originalFilePath;if(U)K.push(x1.join(x1.dirname(U),"components"));if(W)K.push(W);let _=x1.join(x1.dirname(Z),"components");if(!K.includes(_))K.push(_);let z=process.cwd(),B=[x1.resolve(z,"src/components"),x1.resolve(z,"components"),x1.resolve(import.meta.dir,"components")];for(let q of B)if(!K.includes(q))K.push(q);for(let q of K){if(!q)continue;for(let j of G){let H=x1.join(q,j);if(await X0(H))return H}try{if(!Z9.statSync(q,{throwIfNoEntry:!1})?.isDirectory())continue;let H=Z9.readdirSync(q,{withFileTypes:!0});for(let O of H)if(O.isDirectory()){let V=x1.join(q,O.name);for(let L of G){let F=x1.join(V,L);if(await X0(F))return F}}}catch{}}return null}}var L1;var Y9=D(()=>{w0();L1=new kz});function r4($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function WT($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var X9;var J9=D(()=>{X9={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=WT($),J=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,W=[];if(X.reactive)W.push(`:href="${r4(X.value)}"`);else W.push(`href="${r4(X.value)}"`);if(J)W.push(`class="${r4(J)}"`);if(W.push("data-stx-link"),W.push(`data-stx-active-class="${r4(Q)}"`),W.push(`data-stx-exact-active-class="${r4(G)}"`),K)W.push("data-stx-prefetch");let U=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[_,z]of Object.entries($.static)){if(U.has(_))continue;if(typeof z==="boolean"){if(z)W.push(r4(_))}else W.push(`${r4(_)}="${r4(z)}"`)}return`<a ${W.join(" ")}>${Z}</a>`}}});function u0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function U1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function G9($,Z,Y=!1){let X=$.serverDynamic[Z];if(X!==void 0)return X!==!1&&X!=="false";let J=$.static[Z];if(J!==void 0)return J!=="false"&&J!==!1;return Y}function Sz($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=UT[J];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(J);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(X);return Y.join(", ")}function K9($,Z,Y,X){return Z.map((J)=>`${U7($,J,void 0,Y,X)} ${J}w`).join(", ")}function _T($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${U7($,G,void 0,X,J)} ${Q}x`}).join(", ")}function U7($,Z,Y,X,J){if(!X||X==="local"||X==="static")return $;if(X==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(J)Q.push(`f_${J}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(X==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(J)Q.set("fm",J);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(X==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(J)Q.set("format",J);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function zT($,Z,Y="#e5e7eb"){let X=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(X)}`}var UT,Q9,W9;var U9=D(()=>{UT={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},Q9=[320,640,768,1024,1280,1536,1920];W9={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=U1($,"src")||"",J=U1($,"alt")||"",Q=U1($,"width"),G=U1($,"height"),K=U1($,"sizes"),W=U1($,"srcset"),U=U1($,"densities"),_=U1($,"format"),z=U1($,"placeholder"),B=U1($,"placeholderColor")||"#e5e7eb",q=U1($,"provider"),j=U1($,"class")||U1($,"className")||"",H=U1($,"style")||"",O=U1($,"quality"),V=G9($,"lazy",!0),L=G9($,"preload",!1),F=G9($,"picture",!1)||!!_,A=Q?Number.parseInt(Q):void 0,N=G?Number.parseInt(G):void 0,w=W||"",R="";if(!w&&K)w=K9(X,Q9,q,_),R=Sz(K);else if(!w&&U){let P=U.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));w=_T(X,P,A,q,_)}else if(K)R=Sz(K);let T=[];if(H)T.push(H);if(A&&N)T.push(`aspect-ratio:${A}/${N}`);if(z==="blur"||z==="color"||z==="thumbhash"){let P=zT(A||16,N||9,B);T.push(`background-image:url(${P})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(z&&z!=="empty"&&z!=="none")T.push(`background-image:url(${u0(z)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let E=U7(X,A,N,q,_),I=[];if(I.push(`src="${u0(E)}"`),I.push(`alt="${u0(J)}"`),Q)I.push(`width="${u0(Q)}"`);if(G)I.push(`height="${u0(G)}"`);if(V)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${u0(j)}"`);if(T.length>0)I.push(`style="${u0(T.join(";"))}"`);if(w)I.push(`srcset="${u0(w)}"`);if(R)I.push(`sizes="${u0(R)}"`);let k=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[P,b]of Object.entries($.static)){if(k.has(P))continue;if(typeof b==="boolean"){if(b)I.push(u0(P))}else I.push(`${u0(P)}="${u0(b)}"`)}let S=`<img ${I.join(" ")} />`,x="";if(L){let b=_==="webp"?"image/webp":_==="avif"?"image/avif":"";x=`<link rel="preload" as="image" href="${u0(E)}"${b?` type="${b}"`:""}${w?` imagesrcset="${u0(w)}"`:""}${R?` imagesizes="${u0(R)}"`:""} />
|
|
2083
2083
|
`}if(F){let P=[];if(_==="avif"||_==="auto"){let b=U7(X,A,N,q,"avif"),g=w?K9(X,Q9,q,"avif"):`${b}`;P.push(`<source type="image/avif" srcset="${u0(g)}"${R?` sizes="${u0(R)}"`:""} />`)}if(_==="webp"||_==="auto"){let b=U7(X,A,N,q,"webp"),g=w?K9(X,Q9,q,"webp"):`${b}`;P.push(`<source type="image/webp" srcset="${u0(g)}"${R?` sizes="${u0(R)}"`:""} />`)}return`${x}<picture>
|
|
2084
2084
|
${P.join(`
|
|
2085
2085
|
`)}
|
|
2086
2086
|
${S}
|
|
2087
|
-
</picture>`}return`${x}${S}`}}});function
|
|
2087
|
+
</picture>`}return`${x}${S}`}}});function a4($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function F5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var BT="<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'/images/safe-image-default.svg';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>",_9;var z9=D(()=>{_9={name:"SafeImage",aliases:["safe-image","safe-img"],render($,Z,Y){let X=F5($,"src")||"",J=F5($,"alt")||"",Q=F5($,"fallback")||"/images/safe-image-default.svg",G=F5($,"class")||F5($,"className")||"",K=F5($,"fallbackClassName")||"",W=[];if(W.push(`src="${a4(X)}"`),W.push(`alt="${a4(J)}"`),G)W.push(`class="${a4(G)}"`);if(W.push(`data-fallback="${a4(Q)}"`),K)W.push(`data-fallback-class="${a4(K)}"`);W.push('onerror="window.__stxSafeImageHandler(this)"');let U=new Set(["src","alt","fallback","class","className","fallbackClassName"]);for(let[B,q]of Object.entries($.static)){if(U.has(B))continue;if(typeof q==="boolean"){if(q)W.push(a4(B))}else W.push(`${a4(B)}="${a4(q)}"`)}let _=`<img ${W.join(" ")} />`,z=Y.context;if(!z.__safeImageHandlerEmitted)return z.__safeImageHandlerEmitted=!0,`${BT}${_}`;return _}}});function B9($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function _7($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function QZ($,Z,Y){let X=_7($,Z);if(X!==void 0){let J=Number.parseInt(X,10);if(!Number.isNaN(J))return J}return Y}var q9;var j9=D(()=>{q9={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let X=B9(_7($,"color")||"#6366f1"),J=B9(_7($,"initialColor")||_7($,"initial-color")||""),Q=B9(_7($,"height")||"3px"),G=QZ($,"duration",2000),K=QZ($,"throttle",200),W=QZ($,"zIndex",999999)||QZ($,"z-index",999999),U=J?`linear-gradient(to right, ${J}, ${X})`:X;return`
|
|
2088
2088
|
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${Q};background:${U};z-index:${W};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
2089
2089
|
<div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
|
|
2090
2090
|
</div>
|
|
@@ -2117,11 +2117,11 @@ ${S}
|
|
|
2117
2117
|
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
2118
2118
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
2119
2119
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
2120
|
-
</style>`}}});var vz={};e(vz,{preloadIconCollection:()=>WZ,IconBuiltin:()=>KZ});import{existsSync as jT,readFileSync as HT}from"fs";function xz($){try{return $0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(jT(Y))return Y;return null}function OT($){if(
|
|
2120
|
+
</style>`}}});var vz={};e(vz,{preloadIconCollection:()=>WZ,IconBuiltin:()=>KZ});import{existsSync as jT,readFileSync as HT}from"fs";function xz($){try{return $0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(jT(Y))return Y;return null}function OT($){if(S6.has($))return S6.get($);let Z=xz($);if(!Z)return null;try{let Y=JSON.parse(HT(Z,"utf8"));return S6.set($,Y.icons),Y.icons}catch{return null}}async function LT($){if(S6.has($))return S6.get($);let Z=xz($);if(!Z)return null;try{let Y=await Bun.file(Z).json();return S6.set($,Y.icons),Y.icons}catch{return null}}function N5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function WZ($="lucide"){await LT($)}var S6,KZ;var UZ=D(()=>{S6=new Map;KZ={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=N5($,"name")??N5($,"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=m1(N5($,"size")||"24"),K=m1(N5($,"color")||"currentColor"),W=m1(N5($,"class")||""),U=m1(N5($,"style")||""),_=S6.get(J)??OT(J);if(!_)return`<!-- Icon: collection "${J}" not loaded -->`;let z=_[Q];if(!z)return`<!-- Icon: "${Q}" not found in ${J} -->`;let B=z.width||24,q=z.height||24,j=`0 0 ${B} ${q}`,H=z.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let O=W?` class="${W}"`:"",V=U?` style="${U}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${O}${V}>${H}</svg>`}}});function fz($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}function gz($,Z){let Y=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),X=$.match(Y);if(!X)return{region:null,rest:$};return{region:X[2],rest:$.replace(X[0],"")}}var N9;var w9=D(()=>{N9={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=gz(Z,"fallback"),J=X.rest,Q=gz(J,"error"),G=Q.rest,K=X.region??fz($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',W=Q.region??fz($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${W}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function _Z($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let X=$.static[Y];if(typeof X==="string")return X}return}var R9;var M9=D(()=>{R9={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(_Z($,"name")||"v").replace(/["'<>]/g,""),J=(_Z($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=_Z($,"class"),G=_Z($,"id"),K=[`data-stx-transition-group="${X}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${J} ${K}>${Z}</${J}>`}}});function hz(){L1.registerBuiltin(X9),L1.registerBuiltin(W9),L1.registerBuiltin(_9),L1.registerBuiltin(q9),L1.registerBuiltin(H9),L1.registerBuiltin(L9),L1.registerBuiltin(F9),L1.registerBuiltin(KZ),L1.registerBuiltin(N9),L1.registerBuiltin(R9)}var T9=D(()=>{J9();U9();z9();j9();O9();V9();A9();UZ();w9();M9();Y9();J9();U9();z9();j9();O9();V9();A9();UZ();w9();M9()});function dz($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function uz($,Z,Y){let X=[],J=0;while(J<$.length){let Q=$.indexOf("<",J);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){J=Q+1;continue}let W=K[1];if(Y&&Y.has(W.toLowerCase())){let H=Q+1+W.length;while(H<$.length&&$[H]!==">")H++;J=H+1;continue}let U=Q+1+W.length,_=null,z=U,B=-1,q=!1;while(U<$.length){let H=$[U];if(_){if(H==="\\"&&U+1<$.length){U+=2;continue}if(H===_)_=null;U++;continue}if(H==='"'||H==="'"){_=H,U++;continue}if(H==="/"&&U+1<$.length&&$[U+1]===">"){B=U+2,q=!0;break}if(H===">"){B=U+1;break}U++}if(B===-1){J=Q+1;continue}let j=$.slice(z,q?B-2:B-1).trim();if(q)X.push({fullMatch:$.slice(Q,B),tagName:W,attributes:j,content:"",startIndex:Q,endIndex:B,isSelfClosing:!0}),J=B;else{let H=`<${W}`,O=`</${W}>`,V=1,L=B,F=-1;while(V>0&&L<$.length){let w=$.indexOf(H,L),R=$.indexOf(O,L);if(R===-1)break;if(w!==-1&&w<R){let T=$[w+H.length];if(T===" "||T===">"||T==="/"||T===`
|
|
2121
2121
|
`||T==="\t")V++;L=w+H.length}else{if(V--,V===0){F=R;break}L=R+O.length}}if(F===-1){J=B;continue}let A=$.slice(B,F),N=F+O.length;X.push({fullMatch:$.slice(Q,N),tagName:W,attributes:j,content:A,startIndex:Q,endIndex:N,isSelfClosing:!1}),J=N}}return X}function mz($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/"/g,'"').replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var cz=D(()=>{p0();w0();I3()});var az={};e(az,{processESImports:()=>rz,processComponents:()=>BZ});import zZ from"fs";import T1 from"path";function FT($,Z,Y){let X={static:{},serverDynamic:{},clientReactive:{},events:{}},J=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,W)=>W.toUpperCase())};for(let[G,K]of Object.entries($)){let W=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(W.startsWith("@")){X.events[W]=K;continue}if(W.startsWith("__stx_")){let U=Q(W.slice(6));X.serverDynamic[U]=mz(K,Y);continue}if(W.startsWith(":")){let U=Q(W.slice(1)),_=K==="true"?U:K;try{if(!R0(_)){if(Y.debug)console.error(`Unsafe expression in :${U} binding: ${_}`);X.clientReactive[U]=_;continue}let z=Object.keys(Z),q=M0(_,z)(...Object.values(Z));if(q===void 0){let j=_.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((V)=>!H.has(V)&&!z.includes(V))){X.clientReactive[U]=_;continue}}X.serverDynamic[U]=q}catch{X.clientReactive[U]=_}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let U=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(U)try{let _=U[1];if(R0(_)){let B=M0(_,Object.keys(Z))(...Object.values(Z));X.static[W]=B!=null?String(B):""}else{if(Y.debug)console.error(`Unsafe expression in ${W}: ${_}`);X.static[W]=K}}catch(_){if(Y.debug)console.error(`Error evaluating expression for ${W}:`,_);X.static[W]=K}else{let _=K,z=/\{\{\s*([\s\S]+?)\s*\}\}/g,B;while((B=z.exec(K))!==null)try{let q=B[1];if(!R0(q)){if(Y.debug)console.error(`Unsafe expression in ${W}: ${q}`);continue}let H=M0(q,Object.keys(Z))(...Object.values(Z));_=_.replace(B[0],String(H??""))}catch(q){if(Y.debug)console.error(`Error evaluating expression in ${W}:`,q)}X.static[W]=_}continue}X.static[W]=K}return X}function AT($){let Z={},Y=0,X=$.length;while(Y<X){while(Y<X&&/\s/.test($[Y]))Y++;if(Y>=X)break;let J="";while(Y<X&&!/[\s=]/.test($[Y]))J+=$[Y],Y++;if(!J)break;while(Y<X&&/\s/.test($[Y]))Y++;if(Y<X&&$[Y]==="="){Y++;while(Y<X&&/\s/.test($[Y]))Y++;let Q="";if(Y<X&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<X){let K=$[Y];if(K==="\\"&&Y+1<X){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[J]=Q}else Z[J]="true"}return Z}function pz($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function NT($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,X;while((X=Y.exec($))!==null){let J=X[1];if(L1.isBuiltin(J))Z.add(J)}return[...Z].sort()}function wT($){let Z=iz.get($);if(Z)return Z;let Y=new Map,X=[T1.join($,"src"),T1.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=zZ.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let W of K){let U=T1.join(Q,W.name);if(W.isDirectory()){if(W.name==="node_modules"||W.name.startsWith("."))continue;J(U,G+1)}else if(W.isFile()&&W.name.endsWith(".stx")){let _=W.name.slice(0,-4);if(!Y.has(_))Y.set(_,U);let z=_.toLowerCase();if(!Y.has(z))Y.set(z,U);let B=_.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(B))Y.set(B,U)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return iz.set($,Y),Y}function RT($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=T1.join(Y,"node_modules",$);try{if(zZ.statSync(X).isDirectory())return X}catch{}let J=T1.dirname(Y);if(J===Y)return null;Y=J}}async function rz($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=T1.dirname(Y),K=$,W=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(W,(U,_,z)=>{let B=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,q=z,j,H=[];while((j=B.exec(z))!==null){let[O,V,L,F]=j,A=null,N=null;if(F.startsWith(".")||F.startsWith("/")){let T=T1.resolve(G,F);if(T.endsWith(".stx"))N=T;else{let E=`${T}.stx`;try{if(zZ.statSync(E).isFile())N=E}catch{try{if(zZ.statSync(T).isDirectory())A=T}catch{}}}}else A=RT(F,G);if(!A&&!N)continue;let w=!1,R=(T,E)=>{Q.set(T,E),Q.set(T.toLowerCase(),E);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,E),J.add(E)};if(L&&N)R(L,N),w=!0;else if(V){let T=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let k=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(k)return{source:k[1],local:k[2]};return{source:I,local:I}}),E=A?wT(A):null;for(let{source:I,local:k}of T){let S=null;if(N)S=N;else if(E)S=E.get(I)??E.get(I.toLowerCase())??E.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(S)R(k,S),w=!0}}if(w)H.push({start:j.index,end:j.index+O.length})}if(H.length===0)return U;for(let O=H.length-1;O>=0;O--)q=q.slice(0,H[O].start)+q.slice(H[O].end);return`<script${_}>${q}</script>`}),K}async function MT($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,W;while((W=K.exec(Q))!==null){let[U,_]=W,z=_.split(",").map((B)=>B.trim().replace(/^['"]|['"]$/g,"")).filter((B)=>B.length>0);for(let B of z){let q=B.split("/"),H=q[q.length-1].replace(/\.stx$/,""),O=H.includes("-")?H.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),V=null,L=[T1.resolve(T1.dirname(Y),`${B}.stx`),T1.resolve(T1.dirname(Y),B),T1.resolve(X.componentsDir||"components",`${B}.stx`),T1.resolve(X.componentsDir||"components",B),B.endsWith(".stx")?B:`${B}.stx`];for(let F of L)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(O,V),G.set(H,V),G.set(H.toLowerCase(),V);let F=O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),J.add(V),X.debug)console.log(`Imported component: ${O} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${B}`)}Q=Q.replace(U,""),K.lastIndex=0}return Q}async function TT($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=/@component\s*\(/g,U;while((U=W.exec(Q))!==null){let _=U.index,z=_+U[0].length-1,B=1,q=z+1;while(q<Q.length&&B>0){if(Q[q]==="(")B++;else if(Q[q]===")"){if(B--,B===0)break}q++}if(B!==0)break;let j=Q.substring(z+1,q),H=q+1,O=j.match(/^\s*['"]([^'"]+)['"]/);if(!O){W.lastIndex=0;continue}let V=O[1],L,F=j.slice(O[0].length),A=F.match(/^\s*,\s*/);if(A)L=F.slice(A[0].length).trim();let N={};if(L)try{N=h0(L,Z)}catch(k){let S=k instanceof Error?k.message:String(k);Q=Q.replace(Q.substring(_,H),`[Error parsing component props: ${S}]`);continue}let w="",R=H,E=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(E)w=E[1].trim(),R=H+E[0].length;let I=await Z4(V,N,w,G,Z,Y,X,K,J);Q=Q.substring(0,_)+I+Q.substring(R),W.lastIndex=0}return Q}async function ET($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,W=eX(Q);return Q=W.output,Q=await B(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await B(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await B(Q,/[a-z][a-z0-9]*/,!1,VT),Q=$J(Q,W.scripts),Q;async function B(q,j,H,O){if(!q)return q;let V=q,L=uz(V,j,O);for(let F=L.length-1;F>=0;F--){let A=L[F],N=H?dz(A.tagName):A.tagName,w=AT(A.attributes),R=FT(w,Z,X),T=L1.getBuiltin(A.tagName),E=T?await I9(N,G,Z,Y,X):!1;if(T&&!E){let x={context:Z,filePath:Y,options:X,dependencies:J},P=T.render(R,A.content,x);if(Object.keys(R.clientReactive).length>0)P=nz(P,R.clientReactive);if(Object.keys(R.events).length>0){let b=Object.entries(R.events).map(([g,s])=>`${g}="${pz(s)}"`).join(" ");P=P.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}V=V.substring(0,A.startIndex)+P+V.substring(A.endIndex);continue}let I={};for(let[x,P]of Object.entries(R.static))I[x]=P;for(let[x,P]of Object.entries(R.serverDynamic))I[x]=P;let S=await Z4(N,I,A.content,G,Z,Y,X,K,J);if(Object.keys(R.clientReactive).length>0)S=nz(S,R.clientReactive);if(Object.keys(R.events).length>0){let x=S.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(x){let P=Object.entries(R.events).map(([g,s])=>`${g}="${pz(s)}"`).join(" "),b=x[1].length+x[2].length;S=S.substring(0,b)+" "+P+S.substring(b)}}V=V.substring(0,A.startIndex)+S+V.substring(A.endIndex)}return V}}function nz($,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,""")}"`).join(" "),J=Y[1].length+Y[2].length;return $.substring(0,J)+" "+X+$.substring(J)}async function BZ($,Z,Y,X,J){if(!lz)hz(),lz=!0;let Q=await rz($,Z,Y,X,J);Q=await MT(Q,Z,Y,X,J),Q=await TT(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await ET(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=NT(Q);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var lz=!1,VT,iz;var E9=D(()=>{Y9();T9();cz();w0();p0();VT=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"]);iz=new Map});var jZ={};e(jZ,{stripTypeScript:()=>$B,hasVariables:()=>S9,extractVariables:()=>I0,extractScriptFromTemplate:()=>k9,convertToCommonJS:()=>qZ});import w5 from"path";import z7 from"process";function IT($){let Z=[],Y=0,X=$.split(`
|
|
2122
2122
|
`);for(let J of X){let Q=Y,G=null,K=!1;for(let W=0;W<J.length;W++){let U=J[W];if(K){K=!1;continue}if(U==="\\"){K=!0;continue}if(G){if(U===G)G=null;continue}if(U==="'"||U==='"'||U==="`"){G=U;continue}if(U==="/"&&W+1<J.length&&J[W+1]==="/")break;if(U==="{")Y++;else if(U==="}")Y--}if(Q===0){let W=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(W)Z.push(W[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let U=J.match(/(?:const|let|var)\s+(\w+)/);if(U)Z.push(U[1])}else{let U=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(U){let z=U[1].slice(1,-1).split(",").map((B)=>{let q=B.split(":");return(q.length>1?q[1]:q[0]).trim()}).filter((B)=>/^\w+$/.test(B));Z.push(...z)}}}}return[...new Set(Z)]}function $B($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(X){if(!X.includes(":"))return X;let J=[],Q="",G=0,K=0,W=null;for(let U=0;U<X.length;U++){let _=X[U];if(W){if(Q+=_,_===W)W=null;continue}if(_==='"'||_==="'"||_==="`"){W=_,Q+=_;continue}if(_==="<")G++;else if(_===">"&&G>0)G--;else if(_==="(")K++;else if(_===")")K--;if(_===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=_}if(Q)J.push(Q);return J.map((U)=>{let _=U.trim(),z=_.startsWith("..."),B=z?_.slice(3):_,q=-1,j=0;for(let N=0;N<B.length;N++)if(B[N]==="<")j++;else if(B[N]===">")j--;else if(B[N]===":"&&j===0){q=N;break}if(q===-1)return U;let O=B.substring(0,q).trim().replace(/\?$/,""),V=B.substring(q+1),L=-1,F=0;for(let N=0;N<V.length;N++)if(V[N]==="<")F++;else if(V[N]===">")F--;else if(V[N]==="="&&F===0){L=N;break}let A=z?"...":"";if(L!==-1)return`${A}${O} = ${V.substring(L+1).trim()}`;return`${A}${O}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,W=G+1,U=0,_=null;while(W<Z.length&&K>0){let q=Z[W];if(_){if(q===_)_=null;W++;continue}if(q==='"'||q==="'"||q==="`"){_=q,W++;continue}if(q==="<")U++;else if(q===">"&&U>0)U--;else if(U===0){if(q==="(")K++;else if(q===")")K--}if(K>0)W++}if(K!==0)continue;let z=Z.substring(G+1,W);if(!z.includes(":"))continue;let B=Y(z);Q.push({start:G+1,end:W,replacement:B})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];Z=Z.substring(0,K)+U+Z.substring(W)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(X,J)=>{if(!J.includes(":"))return X;if(J.includes("{")||J.includes("}"))return X;return`(${J.split(",").map((G)=>{let[K,...W]=G.split("="),U=K.split(":")[0].trim();if(W.length>0)return`${U} = ${W.join("=").trim()}`;return U}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
|
|
2123
2123
|
|
|
2124
|
-
`),Z}async function I0($,Z,Y,X={}){if(!$.trim())return;let J;try{let u=new Bun.Transpiler({loader:"ts",target:"browser",define:P1()}),c=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");c=c.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=u.transformSync(c)}catch{J=$B($)}let Q={exports:{}},G=Q.exports,K=z7.cwd(),W={},U=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((u)=>u[1]).filter((u)=>!u.startsWith("node:")&&!u.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(u));for(let u of U)try{let c=w5.resolve(K,"node_modules",u),d=w5.join(c,"package.json"),v=JSON.parse($0("fs").readFileSync(d,"utf8")),l=v.main||"index.js";if(v.exports){let a=typeof v.exports==="string"?v.exports:v.exports["."];if(typeof a==="string")l=a;else if(a?.bun)l=a.bun;else if(a?.import)l=a.import;else if(a?.default)l=a.default}W[u]=await import(w5.resolve(c,l))}catch{}let _=(u)=>{if(W[u])return W[u];return $0(u)},z=Z.props||{},B=(u)=>{if(!u)return z;let c={};for(let[d,v]of Object.entries(u)){let l=z[d];if(l!==void 0)c[d]=l;else if(typeof v==="function")c[d]=v();else c[d]=v}return c};for(let[u,c]of Object.entries(z))Object.defineProperty(B,u,{value:c,enumerable:!0,configurable:!0,writable:!0});let q=(u)=>{if(!u)return z;let c={...z};for(let[d,v]of Object.entries(u)){let l=v&&typeof v==="object"&&!Array.isArray(v)?v:{type:v};if(c[d]===void 0&&l.default!==void 0)c[d]=typeof l.default==="function"?l.default():l.default}return c},j=()=>Z.slots||{},H=(u,c)=>{let d={...u};for(let[v,l]of Object.entries(c))if(d[v]===void 0)if(typeof l==="function")d[v]=l();else d[v]=l;return d},O=(u)=>{let c=()=>u;return c.set=(d)=>{},c.update=(d)=>{},c},V=(u)=>{let c,d=!1;return()=>{if(!d)try{c=u(),d=!0}catch{c=void 0}return c}},L=(u)=>{},F=(u)=>u(),A=(u)=>{},N=(u)=>{},w=(u)=>{},R=()=>{let u=Z.__stxServeContext,c=Z.__stxServeSearch??u?.search??"",d=u?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(c)),path:d,name:"",fullPath:d+c,hash:"",matched:[]}},T=()=>({push:(u)=>{},replace:(u)=>{},back:()=>{},forward:()=>{},go:(u)=>{}}),E=(u)=>{l4(u);let c=Z.__stx_runtime_head||{},d=u||{};Z.__stx_runtime_head={...c,...d.title&&{title:d.title},meta:[...c.meta||[],...d.meta||[]],link:[...c.link||[],...d.link||[]],script:[...c.script||[],...d.script||[]],htmlAttrs:{...c.htmlAttrs||{},...d.htmlAttrs||{}},bodyAttrs:{...c.bodyAttrs||{},...d.bodyAttrs||{}}}},I=(u)=>{J7(u);let c=
|
|
2124
|
+
`),Z}async function I0($,Z,Y,X={}){if(!$.trim())return;let J;try{let u=new Bun.Transpiler({loader:"ts",target:"browser",define:P1()}),c=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");c=c.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=u.transformSync(c)}catch{J=$B($)}let Q={exports:{}},G=Q.exports,K=z7.cwd(),W={},U=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((u)=>u[1]).filter((u)=>!u.startsWith("node:")&&!u.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(u));for(let u of U)try{let c=w5.resolve(K,"node_modules",u),d=w5.join(c,"package.json"),v=JSON.parse($0("fs").readFileSync(d,"utf8")),l=v.main||"index.js";if(v.exports){let a=typeof v.exports==="string"?v.exports:v.exports["."];if(typeof a==="string")l=a;else if(a?.bun)l=a.bun;else if(a?.import)l=a.import;else if(a?.default)l=a.default}W[u]=await import(w5.resolve(c,l))}catch{}let _=(u)=>{if(W[u])return W[u];return $0(u)},z=Z.props||{},B=(u)=>{if(!u)return z;let c={};for(let[d,v]of Object.entries(u)){let l=z[d];if(l!==void 0)c[d]=l;else if(typeof v==="function")c[d]=v();else c[d]=v}return c};for(let[u,c]of Object.entries(z))Object.defineProperty(B,u,{value:c,enumerable:!0,configurable:!0,writable:!0});let q=(u)=>{if(!u)return z;let c={...z};for(let[d,v]of Object.entries(u)){let l=v&&typeof v==="object"&&!Array.isArray(v)?v:{type:v};if(c[d]===void 0&&l.default!==void 0)c[d]=typeof l.default==="function"?l.default():l.default}return c},j=()=>Z.slots||{},H=(u,c)=>{let d={...u};for(let[v,l]of Object.entries(c))if(d[v]===void 0)if(typeof l==="function")d[v]=l();else d[v]=l;return d},O=(u)=>{let c=()=>u;return c.set=(d)=>{},c.update=(d)=>{},c},V=(u)=>{let c,d=!1;return()=>{if(!d)try{c=u(),d=!0}catch{c=void 0}return c}},L=(u)=>{},F=(u)=>u(),A=(u)=>{},N=(u)=>{},w=(u)=>{},R=()=>{let u=Z.__stxServeContext,c=Z.__stxServeSearch??u?.search??"",d=u?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(c)),path:d,name:"",fullPath:d+c,hash:"",matched:[]}},T=()=>({push:(u)=>{},replace:(u)=>{},back:()=>{},forward:()=>{},go:(u)=>{}}),E=(u)=>{l4(u);let c=Z.__stx_runtime_head||{},d=u||{};Z.__stx_runtime_head={...c,...d.title&&{title:d.title},meta:[...c.meta||[],...d.meta||[]],link:[...c.link||[],...d.link||[]],script:[...c.script||[],...d.script||[]],htmlAttrs:{...c.htmlAttrs||{},...d.htmlAttrs||{}},bodyAttrs:{...c.bodyAttrs||{},...d.bodyAttrs||{}}}},I=(u)=>{J7(u);let c=O5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...c.title&&{title:c.title},meta:c.meta?[...c.meta]:[]}},k=(u)=>({value:u}),S=(u)=>u,x=(u)=>({value:typeof u==="function"?u():u}),P=(u,c)=>{},b=(u)=>{},g=(u)=>{},s=(u)=>u?u():Promise.resolve(),p=(u)=>(c,...d)=>{},C=(u)=>{},h=(u,c)=>{},m=(u,c)=>c,r=()=>({value:"light"}),o=()=>({value:!1}),B0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},G0=new Proxy(B0,{get(u,c){if(c in u)return u[c];return},set(u,c,d){return u[c]=d,!0}}),C0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},Y1=console;try{let u=qZ(J,Y),c=new Set(Object.keys(z)),d=Object.keys(Z).filter((z0)=>!c.has(z0)&&z0!=="props"),v=d.map((z0)=>Z[z0]),l=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"]),a=[],i=[];for(let[z0,l0]of Object.entries(z)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(z0))continue;if(l.has(z0))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${z0}\\b`).test(u))continue;a.push(z0),i.push(l0)}let E0=IT(u).map((z0)=>`module.exports.${z0} = typeof ${z0} !== 'undefined' ? ${z0} : module.exports.${z0};`).join(`
|
|
2125
2125
|
`),N0=Z.params??{},k0=[],s0=[];for(let z0=0;z0<d.length;z0++){if(d[z0]==="params")continue;k0.push(d[z0]),s0.push(v[z0])}let _4=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...a,...k0,`return (async () => {
|
|
2126
2126
|
${u}
|
|
2127
2127
|
${E0}
|
|
@@ -2136,7 +2136,7 @@ ${N}`,nextIndex:L}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}l
|
|
|
2136
2136
|
${$[W]}`,W++;else break}return K=K.trim().replace(/;$/,""),{type:J,name:Q,value:K,nextIndex:W}}function D9($,Z){let Y=$[Z].trim(),X=Y.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!X)throw Error(`Failed to parse function declaration: ${Y}`);let[,J]=X,Q=Y.replace(/^export\s+/,""),G=Z;if(ST(Y)){let K=CT($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:J,functionCode:Q,nextIndex:G}}function oz($){let Z=$.trim();if(Z.startsWith("{"))return d0(Z,"{","}",0)===-1;if(Z.startsWith("["))return d0(Z,"[","]",0)===-1;return!XB(Z)}function XB($){let Z={paren:0,bracket:0,brace:0},Y=null,X=0;for(let J=0;J<$.length;J++){let Q=$[J];if((J>0?$[J-1]:"")==="\\"&&Y)continue;if((Q==='"'||Q==="'")&&!Y){Y=Q;continue}if(Q===Y&&Y!=="`"){Y=null;continue}if(Q==="`"&&!Y){Y="`";continue}if(Q==="`"&&Y==="`"&&X===0){Y=null;continue}if(Y==="`"&&Q==="$"&&$[J+1]==="{"){X++,J++;continue}if(X>0&&Q==="{"){X++;continue}if(X>0&&Q==="}"){X--;continue}if(Y)continue;if(Q==="(")Z.paren++;else if(Q===")")Z.paren--;else if(Q==="[")Z.bracket++;else if(Q==="]")Z.bracket--;else if(Q==="{")Z.brace++;else if(Q==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&Y===null}function ST($){let Z=$.indexOf("{");if(Z===-1)return!0;return d0($,"{","}",Z)===-1}function tz($,Z,Y){let X=Y,J=Z+1;while(J<$.length&&!XB(X)){let Q=$[J];X+=`
|
|
2137
2137
|
${Q}`,J++}while(J<$.length){let Q=$[J].trim();if(Q.startsWith(".")||Q.startsWith("?."))X+=`
|
|
2138
2138
|
${$[J]}`,J++;else break}return{value:X,nextIndex:J}}function CT($,Z,Y){let X=Y,J=Z+1;while(J<$.length){let Q=X.indexOf("{");if(Q!==-1){if(d0(X,"{","}",Q)!==-1)break}let G=$[J];X+=`
|
|
2139
|
-
${G}`,J++}return{functionCode:X,nextIndex:J}}function ez($,Z){let Y=V0($,Z)??V0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...z7.env}})};try{return Function(...Object.keys(X),`'use strict'; return (${$});`)(...Object.values(X))}catch{try{return Function(...Object.keys(X),`'use strict'; return ${$};`)(...Object.values(X))}catch{return}}}async function bT($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of X){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=ez(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let J=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of J){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=ez(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function k9($){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 S9($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var
|
|
2139
|
+
${G}`,J++}return{functionCode:X,nextIndex:J}}function ez($,Z){let Y=V0($,Z)??V0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...z7.env}})};try{return Function(...Object.keys(X),`'use strict'; return (${$});`)(...Object.values(X))}catch{try{return Function(...Object.keys(X),`'use strict'; return ${$};`)(...Object.values(X))}catch{return}}}async function bT($,Z,Y){let X=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of X){let[,,G,K]=Q;try{let W=K.trim().replace(/;$/,""),U=ez(W,Z);if(U!==void 0)Z[G]=U}catch(W){console.warn(`Failed to parse export ${G} in fallback:`,W)}}let J=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of J){let[,,G,K]=Q;if(!(G in Z))try{let W=K.trim().replace(/;$/,""),U=ez(W,Z);if(U!==void 0)Z[G]=U}catch{}}}function k9($){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 S9($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var s4=D(()=>{p4();w6();p0()});var _B={};e(_B,{processLoops:()=>VZ});function xT($,Z){let Y=/@component\s*\(/g,X=$,J,Q=[];while((J=Y.exec(X))!==null){let G=J.index,K=G+J[0].length-1,W=1,U=K+1;while(U<X.length&&W>0){if(X[U]==="(")W++;else if(X[U]===")"){if(W--,W===0)break}U++}if(W!==0)continue;let _=X.substring(K+1,U),z=U+1,B=_.match(/^\s*['"]([^'"]+)['"]/);if(!B)continue;let q=B[1],j=_.slice(B[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let O=j.slice(H[0].length).trim();if(!O)continue;try{let V=h0(O,Z),L=JSON.stringify(V),F=`@component('${q}', ${L})`;Q.push({start:G,end:z,replacement:F})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:W,replacement:U}=Q[G];X=X.substring(0,K)+U+X.substring(W)}return X}function HZ($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,W=1,U=K+1,_=null,z=!1;while(U<X.length&&W>0){let j=X[U];if(z){z=!1,U++;continue}if(j==="\\"&&_){z=!0,U++;continue}if(_){if(j===_)_=null;U++;continue}if(j==='"'||j==="'"||j==="`"){_=j,U++;continue}if(j==="(")W++;else if(j===")"){if(W--,W===0)break}U++}if(W!==0)break;let B=X.substring(K+1,U),q=Y(B);X=X.substring(0,G)+q+X.substring(U+1)}return X}function vT($,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);w3(Q);let U=M0(Q,G)(...K),_=JSON.stringify(U),z=Buffer.from(_,"utf8").toString("base64");return`__stx_${J}="${z}"`}catch(G){return X}}),Y}function fT($,Z){let Y=$;return Y=HZ(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(R0(Q)){let K=M0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(V0(Q,Z));return G?OZ:""}catch{return""}}),Y=HZ(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if(R0(Q)){let K=M0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(V0(Q,Z));return G?LZ:""}catch{return""}}),Y}function gT($){let Z=$;return Z=Z.replace(/@break(?!\()/g,OZ),Z=Z.replace(/@continue(?!\()/g,LZ),Z}function JB($){let Z=$.includes(OZ),Y=Z?$.substring(0,$.indexOf(OZ)):$;return{hasBreak:Z,content:Y}}function QB($){let Z=$.includes(LZ),Y=Z?$.substring(0,$.indexOf(LZ)):$;return{hasContinue:Z,content:Y}}function KB($){let Z=$;return Z=HZ(Z,"@break",(Y)=>{let X=Y.trim();if(!R3(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=HZ(Z,"@continue",(Y)=>{let X=Y.trim();if(!R3(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function hT($){let Z=/@forelse\s*\(/g,Y,X=[],J=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=J.exec($))!==null)X.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)X.push({pos:G.index,delta:-1});X.sort((_,z)=>_.pos-z.pos);let K=[],W=0;for(let _ of X)W+=_.delta,K.push({pos:_.pos,depth:W});function U(_){let z=0,B=K.length-1,q=0;while(z<=B){let j=z+B>>1;if(K[j].pos<=_)q=K[j].depth,z=j+1;else B=j-1}return q}while((Y=Z.exec($))!==null){if(U(Y.index)>0)continue;let _=Y.index,z=Y.index+Y[0].length-1,B=1,q=z+1,j=-1;while(q<$.length&&B>0){if($[q]==="(")B++;else if($[q]===")"){if(B--,B===0){j=q;break}}q++}if(j===-1)continue;let H=$.substring(z+1,j),O=H.indexOf(" as ");if(O===-1)continue;let V=H.substring(0,O).trim(),L=H.substring(O+4).trim(),F=j+1,A=1,N=F,w=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(A>0&&N<$.length){w.lastIndex=N,R.lastIndex=N;let P=w.exec($),b=R.exec($);if(!b)break;if(P&&P.index<b.index)A++,N=P.index+P[0].length;else{if(A--,A===0){T=b.index;break}N=b.index+11}}if(T===-1)continue;let E=$.substring(F,T),I=T+11,k=-1,S=0,x=0;while(x<E.length){let P=E.indexOf("@",x);if(P===-1)break;let b=E.substring(P);if(/^@forelse\s*\(/.test(b))S++,x=P+1;else if(b.startsWith("@endforelse"))S--,x=P+11;else if(S===0&&b.startsWith("@empty")){if(E.length<=P+6||!/[a-z]/i.test(E[P+6])){k=P;break}x=P+1}else x=P+1}if(k===-1)continue;return{start:_,end:I,arrayExpr:V,itemVar:L,foreachContent:E.substring(0,k),emptyContent:E.substring(k+6)}}return null}function GB($,Z){let Y=$;while(!0){let X=hT(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:W,emptyContent:U}=X;try{let _;if(R0(G))_=M0(G,Object.keys(Z))(...Object.values(Z));else _=V0(G,Z);let z;if(!Array.isArray(_)||_.length===0)z=U;else z=`@foreach (${G} as ${K})${W}@endforeach`;Y=Y.substring(0,J)+z+Y.substring(Q)}catch(_){let z=_ instanceof Error?_.message:String(_),B=_0("Forelse",`Error in @forelse(${G} as ${K}): ${z}`,J0.EVALUATION_ERROR);Y=Y.substring(0,J)+B+Y.substring(Q)}}return Y}function VZ($,Z,Y,X){let J=$;J=GB(J,Z);function Q(W){let U=/@foreach\s*\(/g,_;while((_=U.exec(W))!==null){let z=_.index,B=_.index+_[0].length-1,q=1,j=B+1,H=-1;while(j<W.length&&q>0){if(W[j]==="(")q++;else if(W[j]===")"){if(q--,q===0){H=j;break}}j++}if(H===-1)continue;let O=W.substring(B+1,H),V=O.indexOf(" as ");if(V===-1)continue;let L=z,F=O.substring(0,V),A=O.substring(V+4),N=H+1,w=1,R=N,T=/@foreach\s*\(/g,E=/@endforeach/g;while(w>0&&R<W.length){T.lastIndex=R,E.lastIndex=R;let I=T.exec(W),k=E.exec(W);if(!k)break;if(I&&I.index<k.index)w++,R=I.index+I[0].length;else{if(w--,w===0){let S=W.substring(N,k.index),x=k.index+11;return{start:L,end:x,arrayExpr:F,itemVar:A,content:S}}R=k.index+11}}}return null}function G(W,U){let _=W;while(!0){let z=Q(_);if(!z)break;let{start:B,end:q,arrayExpr:j,itemVar:H,content:O}=z;try{let V=j.trim(),L;if(R0(V))L=M0(V,Object.keys(U))(...Object.values(U));else L=V0(V,U);let F=!1;if(!Array.isArray(L))if(L instanceof Map)L=Array.from(L),F=!0;else if(L instanceof Set)L=Array.from(L);else if(typeof L==="string")L=Array.from(L);else if(L&&typeof L==="object"&&!(L instanceof Date)&&!(L instanceof RegExp))L=Object.entries(L),F=!0;else{let k=_0("Foreach",`Error in @foreach: ${V} is not iterable`,J0.TYPE_ERROR);_=_.substring(0,B)+k+_.substring(q);continue}let A=X?.loops?.useAltLoopVariable??yT,N=H.trim(),w=null,R,T=!1;if(N.includes("=>")){let k=N.split("=>").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])w=k[0],R=k[1];else R=N}else if(!N.startsWith("[")&&!N.startsWith("{")&&N.includes(",")){let k=N.split(",").map((S)=>S.trim());if(k.length===2&&k[0]&&k[1])R=k[0],w=k[1],T=!0;else R=N}else R=N;let E="",I=L;for(let k=0;k<I.length;k++){let S=I[k],x={index:k,iteration:k+1,first:k===0,last:k===I.length-1,count:I.length},P={...U,loop:x,$loop:x};if(R.startsWith("[")&&R.endsWith("]")){let p=R.slice(1,-1).split(",").map((C)=>C.trim());if(Array.isArray(S))p.forEach((C,h)=>{if(C)P[C]=S[h]});else P[R]=S}else P[R]=S;if(w)if(!T&&F&&Array.isArray(S)&&S.length===2)P[w]=S[0],P[R]=S[1];else P[w]=k;let b=fT(O,P),g=QB(b);if(g.hasContinue){E+=g.content;continue}let s=JB(b);if(s.hasBreak){E+=s.content;break}if(b=GB(b,P),b=G(b,P),b=E6(b,P,Y),b=gT(b),s=JB(b),s.hasBreak){E+=s.content;break}if(g=QB(b),g.hasContinue){E+=g.content;continue}b=j1(b,P,Y),b=vT(b,P),b=xT(b,P),E+=b}_=_.substring(0,B)+E+_.substring(q)}catch(V){let L=_0("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${V instanceof Error?V.message:String(V)}`,J0.EVALUATION_ERROR);_=_.substring(0,B)+L+_.substring(q)}}return _}J=G(J,Z),J=UB(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??PT;return J=mT(J,Z,K),J}function WB($){return R3($)}function UB($,Z,Y,X){let J=$,Q=!0;while(Q){Q=!1;let G=J.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=K+G[0].length-1,U=d0(J,"(",")",W);if(U===-1)break;let _=J.slice(W+1,U),z=U+1,B=Y7(J.slice(K),"for","endfor");if(B.length===0)break;let q=B[0].content,j=K+B[0].end;if(!WB(_)){let H=_0("For",`Unsafe expression in @for: ${_}`,J0.UNSAFE_EXPRESSION);J=J.substring(0,K)+H+J.substring(j),Q=!0;continue}try{let H=dT(_),O=/@(?:for|foreach|if|unless)\s*\(/.test(q);if(H.length>0&&O){let w=uT({forExpr:_,content:q,iterVarNames:H,context:Z,filePath:Y,options:X});J=J.substring(0,K)+w+J.substring(j),Q=!0;continue}let V=Object.keys(Z),L=Object.values(Z),F=q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,R)=>{return`\${${R}}`});F=KB(F);let N=Function(...V,`
|
|
2140
2140
|
let result = '';
|
|
2141
2141
|
for (${_}) {
|
|
2142
2142
|
result += \`${F}\`;
|
|
@@ -2146,7 +2146,7 @@ ${G}`,J++}return{functionCode:X,nextIndex:J}}function ez($,Z){let Y=V0($,Z)??V0(
|
|
|
2146
2146
|
for (${Z}) {
|
|
2147
2147
|
__pushIter([${X.join(", ")}])
|
|
2148
2148
|
}
|
|
2149
|
-
`),_=[];U(...W,(q)=>{_.push(q)});let z=Q??"inline.stx",B="";for(let q of _){let j={...J};X.forEach((O,V)=>{j[O]=q[V]});let H=UB(Y,j,Q,G);H=
|
|
2149
|
+
`),_=[];U(...W,(q)=>{_.push(q)});let z=Q??"inline.stx",B="";for(let q of _){let j={...J};X.forEach((O,V)=>{j[O]=q[V]});let H=UB(Y,j,Q,G);H=E6(H,j,z),H=j1(H,j,z),B+=H}return B}function mT($,Z,Y){let X=$,J=!0;while(J){J=!1;let Q=X.match(/@while\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=G+Q[0].length-1,W=d0(X,"(",")",K);if(W===-1)break;let U=X.slice(K+1,W),_=Y7(X.slice(G),"while","endwhile");if(_.length===0)break;let z=_[0].content,B=G+_[0].end;if(!WB(U)){let q=_0("While",`Unsafe expression in @while: ${U}`,J0.UNSAFE_EXPRESSION);X=X.substring(0,G)+q+X.substring(B),J=!0;continue}try{let q=Object.keys(Z),j=Object.values(Z),H=z.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(L,F)=>{return`\${${F}}`});H=KB(H);let V=Function(...q,`
|
|
2150
2150
|
let result = '';
|
|
2151
2151
|
let maxIterations = ${Y}; // Configurable safety limit
|
|
2152
2152
|
let counter = 0;
|
|
@@ -2193,15 +2193,15 @@ ${pT($).split(",").map((W)=>W.trim()).filter(Boolean).map((W)=>` try { __scopeR
|
|
|
2193
2193
|
} finally {
|
|
2194
2194
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
2195
2195
|
}
|
|
2196
|
-
})();`}function nT($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function rT(){b9.clear()}function aT($){if($.__onceStore instanceof Set)return $.__onceStore;return b9}async function AZ($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||b0.join(b0.dirname(Y),"partials");if(G&&!b0.isAbsolute(G))G=b0.resolve(process.cwd(),G);let K=cT($,"@partial","@include"),W=aT(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let V=H.trim(),L=`${Y}:${V}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let A=K.substring(V+1,F-1),N=A.match(/^\s*['"]([^'"]+)['"]/);if(!N){j.lastIndex=F;continue}let w=N[1],R=U(w,G,Y),T="";if(R&&await Bun.file(R).exists())J.add(R),T=`@include(${A})`;K=K.substring(0,O)+T+K.substring(F),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=O.exec(K))!==null){let L=V.index,F=L+V[0].length-1,A=1,N=F+1;while(N<K.length&&A>0){if(K[N]==="(")A++;else if(K[N]===")")A--;N++}if(A!==0)break;let w=K.substring(F+1,N-1),R=C9(w,0);if(R===-1){O.lastIndex=N;continue}let T=w.substring(0,R).trim(),E=w.substring(R+1).trim(),I=E.match(/^\s*['"]([^'"]+)['"]/);if(!I){O.lastIndex=N;continue}let k=I[1],S=E.substring(I[0].length),x,P=C9(S,0);if(P!==-1)x=S.substring(P+1).trim();try{let b=`Boolean(${T})`,g;if(R0(b)){let C=M0(b,Object.keys(Z));g=Boolean(C(...Object.values(Z)))}else g=Boolean(V0(b,Z));let s=H?!g:g,p="";if(s){let C=U(k,G,Y);if(C&&await Bun.file(C).exists())J.add(C);p=`@include('${k}'${x?`, ${x}`:""})`}K=K.substring(0,L)+p+K.substring(N),O.lastIndex=0}catch(b){let g=b instanceof Error?b.message:String(b),s=T0("Include",`Error evaluating ${j} condition: ${g}`,Y,$,L);K=K.substring(0,L)+s+K.substring(N),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let[,R,T,E,I]=w;try{let k,S=T.trim();if(R0(S))k=M0(S,Object.keys(Z))(...Object.values(Z));else k=V0(S,Z);let x="";if(Array.isArray(k)&&k.length>0)for(let P of k){let b={...Z,[E]:P},g=await z(R,b,$,O);x+=g}else if(I)x=await z(I,{},$,O);K=K.substring(0,O)+x+K.substring(F+1),j.lastIndex=0}catch(k){let S=k instanceof Error?k.message:String(k);K=K.substring(0,O)+T0("Each",`Error in @each: ${S}`,Y,$,O)+K.substring(F+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let R=w[1],T=A.slice(w[0].length),E,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let x=1,P=1;while(P<T.length&&x>0){if(T[P]==="{")x++;else if(T[P]==="}"){if(x--,x===0)break}P++}E=T.substring(0,P+1),T=T.slice(P+1)}let k,S=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(S)k=S[1];try{let x=JSON.parse(R.replace(/'/g,'"')),P={};if(E)try{P=h0(E,Z)}catch(g){let s=g instanceof Error?g.message:String(g);if(X.debug){let p=T0("Include",`Error parsing includeFirst variables: ${s}`,Y,$,O,N);K=K.replace(N,()=>p)}else K=K.replace(N,()=>k||"");continue}let b=!1;for(let g of x){let s=U(g,G,Y);if(!s)continue;if(await X0(s)){let p=await z(g,P,$,O);K=K.replace(N,()=>p),b=!0;break}}if(!b)if(k!==void 0)K=K.replace(N,()=>k);else if(X.debug){let g=T0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,N);K=K.replace(N,()=>g)}else K=K.replace(N,"")}catch(x){let P=x instanceof Error?x.message:String(x),b=T0("Include",`Error processing @includeFirst: ${P}`,Y,$,O,N);K=K.replace(N,()=>b)}j.lastIndex=0}}function U(j,H,O){try{let V=j;if(!j.endsWith(".stx"))V=`${j}.stx`;let L=b0.resolve(H),F=b0.resolve(b0.dirname(O)),A;if(!V.startsWith("./")&&!V.startsWith("../"))A=b0.resolve(H,V);else A=b0.resolve(F,V);let N=b0.normalize(A),w=N.startsWith(L+b0.sep)||N===L,R=N.startsWith(F+b0.sep)||N===F,T=!1,E=b0.dirname(F);if(N.startsWith(E+b0.sep)){if(!b0.relative(E,N).split(b0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))T=!0}if(!w&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${L}, ${F}`),null;return N}catch(V){return console.error(`Error resolving path ${j}: ${V}`),null}}let _=b0.resolve(Y);Q.add(_);async function z(j,H={},O,V){let L=U(j,G,Y);if(!L)return T0("Include",`Could not resolve path for include: ${j}`,Y,O,V);let F=b0.resolve(L);if(Q.has(F)){let A=[...Q,F].map((N)=>b0.basename(N)).join(" -> ");return T0("Include",`Circular include detected: ${A}`,Y,O,V)}try{J.add(L);let A;if(!A)try{A=await Bun.file(L).text()}catch(p){let C=p instanceof Error?p.message:String(p);return T0("Include",`Error loading include file ${j}: ${C}`,Y,O,V)}if(A&&A.includes("@stream")){let{processStreamDirectives:p}=await Promise.resolve().then(() => (n4(),
|
|
2197
|
-
`;continue}if(m)try{let{extractVariables:G0}=await Promise.resolve().then(() => (
|
|
2196
|
+
})();`}function nT($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let J=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(J)return{html:$,mergedIntoExisting:J[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function rT(){b9.clear()}function aT($){if($.__onceStore instanceof Set)return $.__onceStore;return b9}async function AZ($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||b0.join(b0.dirname(Y),"partials");if(G&&!b0.isAbsolute(G))G=b0.resolve(process.cwd(),G);let K=cT($,"@partial","@include"),W=aT(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,O)=>{let V=H.trim(),L=`${Y}:${V}`;if(W.has(L))return"";return W.add(L),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let A=K.substring(V+1,F-1),N=A.match(/^\s*['"]([^'"]+)['"]/);if(!N){j.lastIndex=F;continue}let w=N[1],R=U(w,G,Y),T="";if(R&&await Bun.file(R).exists())J.add(R),T=`@include(${A})`;K=K.substring(0,O)+T+K.substring(F),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let O=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=O.exec(K))!==null){let L=V.index,F=L+V[0].length-1,A=1,N=F+1;while(N<K.length&&A>0){if(K[N]==="(")A++;else if(K[N]===")")A--;N++}if(A!==0)break;let w=K.substring(F+1,N-1),R=C9(w,0);if(R===-1){O.lastIndex=N;continue}let T=w.substring(0,R).trim(),E=w.substring(R+1).trim(),I=E.match(/^\s*['"]([^'"]+)['"]/);if(!I){O.lastIndex=N;continue}let k=I[1],S=E.substring(I[0].length),x,P=C9(S,0);if(P!==-1)x=S.substring(P+1).trim();try{let b=`Boolean(${T})`,g;if(R0(b)){let C=M0(b,Object.keys(Z));g=Boolean(C(...Object.values(Z)))}else g=Boolean(V0(b,Z));let s=H?!g:g,p="";if(s){let C=U(k,G,Y);if(C&&await Bun.file(C).exists())J.add(C);p=`@include('${k}'${x?`, ${x}`:""})`}K=K.substring(0,L)+p+K.substring(N),O.lastIndex=0}catch(b){let g=b instanceof Error?b.message:String(b),s=T0("Include",`Error evaluating ${j} condition: ${g}`,Y,$,L);K=K.substring(0,L)+s+K.substring(N),O.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let[,R,T,E,I]=w;try{let k,S=T.trim();if(R0(S))k=M0(S,Object.keys(Z))(...Object.values(Z));else k=V0(S,Z);let x="";if(Array.isArray(k)&&k.length>0)for(let P of k){let b={...Z,[E]:P},g=await z(R,b,$,O);x+=g}else if(I)x=await z(I,{},$,O);K=K.substring(0,O)+x+K.substring(F+1),j.lastIndex=0}catch(k){let S=k instanceof Error?k.message:String(k);K=K.substring(0,O)+T0("Each",`Error in @each: ${S}`,Y,$,O)+K.substring(F+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let O=H.index,V=O+H[0].length-1,L=1,F=V+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")"){if(L--,L===0)break}F++}if(L!==0)break;let A=K.substring(V+1,F),N=K.substring(O,F+1),w=A.match(/^\s*(\[[^\]]+\])/);if(!w){j.lastIndex=0,K=K.replace(N,"");continue}let R=w[1],T=A.slice(w[0].length),E,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let x=1,P=1;while(P<T.length&&x>0){if(T[P]==="{")x++;else if(T[P]==="}"){if(x--,x===0)break}P++}E=T.substring(0,P+1),T=T.slice(P+1)}let k,S=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(S)k=S[1];try{let x=JSON.parse(R.replace(/'/g,'"')),P={};if(E)try{P=h0(E,Z)}catch(g){let s=g instanceof Error?g.message:String(g);if(X.debug){let p=T0("Include",`Error parsing includeFirst variables: ${s}`,Y,$,O,N);K=K.replace(N,()=>p)}else K=K.replace(N,()=>k||"");continue}let b=!1;for(let g of x){let s=U(g,G,Y);if(!s)continue;if(await X0(s)){let p=await z(g,P,$,O);K=K.replace(N,()=>p),b=!0;break}}if(!b)if(k!==void 0)K=K.replace(N,()=>k);else if(X.debug){let g=T0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,O,N);K=K.replace(N,()=>g)}else K=K.replace(N,"")}catch(x){let P=x instanceof Error?x.message:String(x),b=T0("Include",`Error processing @includeFirst: ${P}`,Y,$,O,N);K=K.replace(N,()=>b)}j.lastIndex=0}}function U(j,H,O){try{let V=j;if(!j.endsWith(".stx"))V=`${j}.stx`;let L=b0.resolve(H),F=b0.resolve(b0.dirname(O)),A;if(!V.startsWith("./")&&!V.startsWith("../"))A=b0.resolve(H,V);else A=b0.resolve(F,V);let N=b0.normalize(A),w=N.startsWith(L+b0.sep)||N===L,R=N.startsWith(F+b0.sep)||N===F,T=!1,E=b0.dirname(F);if(N.startsWith(E+b0.sep)){if(!b0.relative(E,N).split(b0.sep).some((x)=>x.startsWith(".")&&x!=="."&&x!==".."))T=!0}if(!w&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${L}, ${F}`),null;return N}catch(V){return console.error(`Error resolving path ${j}: ${V}`),null}}let _=b0.resolve(Y);Q.add(_);async function z(j,H={},O,V){let L=U(j,G,Y);if(!L)return T0("Include",`Could not resolve path for include: ${j}`,Y,O,V);let F=b0.resolve(L);if(Q.has(F)){let A=[...Q,F].map((N)=>b0.basename(N)).join(" -> ");return T0("Include",`Circular include detected: ${A}`,Y,O,V)}try{J.add(L);let A;if(!A)try{A=await Bun.file(L).text()}catch(p){let C=p instanceof Error?p.message:String(p);return T0("Include",`Error loading include file ${j}: ${C}`,Y,O,V)}if(A&&A.includes("@stream")){let{processStreamDirectives:p}=await Promise.resolve().then(() => (n4(),k6));A=p(A,Z)}if(A&&(X.debug||!z5()&&!s$()))try{let{warnUnbalancedTags:p}=await Promise.resolve().then(() => ($9(),Ez));p(A,L)}catch{}let N=A;try{let{processESImports:p}=await Promise.resolve().then(() => (E9(),az));await p(A,Z,L,X,J)}catch(p){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${L}:`,p instanceof Error?p.message:p)}let w=N.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(w)N=w[1].trim();let T=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),E="";if(T)E=`<style${T[1]}>${T[2]}</style>`;N=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),N=N.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[p,C]of Object.entries(H))I[p]=C;let k=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,S=[...A.matchAll(k)],x="",P=null;for(let p of S){let C=p[1]||"",h=p[2]||"",m=C.includes("server"),r=x4(C),o="";try{let{extractAndStripCssImports:G0,renderVendorStyleTags:C0}=await Promise.resolve().then(() => (M6(),RU)),Y1=G0(h,{filePath:L,projectRoot:process.cwd()});h=Y1.code,o=C0(Y1.styles)}catch(G0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${L}:`,G0 instanceof Error?G0.message:G0)}if(r&&h.trim())h=v4(h);if(!m)try{let{hasUserImports:G0,bundleClientScript:C0}=await Promise.resolve().then(() => (N3(),A3));if(G0(h))h=await C0(h,L,{projectRoot:process.cwd()})}catch(G0){if(X.debug)console.warn(`[stx] bundler skipped for ${L}:`,G0 instanceof Error?G0.message:G0)}let B0=lT(h);if(B0&&!m){P=`stx_scope_${b0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++zB}`;let G0=z4(h),C0=iT(G0,P);x+=`${o}<script data-stx-scoped>${C0}</script>
|
|
2197
|
+
`;continue}if(m)try{let{extractVariables:G0}=await Promise.resolve().then(() => (s4(),jZ));await G0(h,I,L)}catch(G0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${L}:`,G0)}if(!m&&!B0){let G0=C.replace(/\bclient\b/i,"").trim();P=`stx_scope_${b0.basename(L,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++zB}`;let C0=z4(h),Y1=`
|
|
2198
2198
|
if (!window.stx._scopes) window.stx._scopes = {};
|
|
2199
2199
|
window.stx._scopes['${P}'] = { __destroyCallbacks: __destroyHooks };
|
|
2200
2200
|
`,u=BB(C0,Y1);x+=`${o}<script data-stx-scoped${G0?` ${G0}`:""}>${u}</script>
|
|
2201
|
-
`}}if(P){let p=nT(N,P);if(N=p.html,p.mergedIntoExisting)x=x.replace(`window.stx._scopes['${P}']`,`window.stx._scopes['${p.mergedIntoExisting}']`),P=p.mergedIntoExisting}if(N.includes("@include")||N.includes("@partial"))N=await AZ(N,I,L,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (FZ(),_B)),g=b(N,I,L);g=
|
|
2201
|
+
`}}if(P){let p=nT(N,P);if(N=p.html,p.mergedIntoExisting)x=x.replace(`window.stx._scopes['${P}']`,`window.stx._scopes['${p.mergedIntoExisting}']`),P=p.mergedIntoExisting}if(N.includes("@include")||N.includes("@partial"))N=await AZ(N,I,L,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (FZ(),_B)),g=b(N,I,L);g=E6(g,I,L);let s=T6(A);if(g=j1(g,I,L,{forceSignals:s}),E)g+=`
|
|
2202
2202
|
`+E;if(x)g+=`
|
|
2203
2203
|
`+x;return g}catch(A){let N=A instanceof Error?A.message:String(A);return T0("Include",`Error processing include ${j}: ${N}`,Y,O,V)}}let B=/@include\s*\(/g,q;while((q=B.exec(K))!==null){let j=q.index,H=j+q[0].length-1,O=1,V=H+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let L=K.substring(j,V),F=K.substring(H+1,V-1),A=F.match(/^\s*['"]([^'"]+)['"]/);if(!A){B.lastIndex=V;continue}let N=A[1],w,R=F.substring(A[0].length),T=C9(R,0);if(T!==-1)w=R.substring(T+1).trim();let E={};if(w)try{E=h0(w,Z)}catch(k){let S=k instanceof Error?k.message:String(k);K=K.replace(L,T0("Include",`Error parsing include variables for ${N}: ${S}`,Y,$,j)),B.lastIndex=0;continue}let I=await z(N,E,$,j);K=K.substring(0,j)+I+K.substring(V),B.lastIndex=0}return K}function NZ($,Z){let Y=$;function X(J,Q,G,K){let W=J,U=!0;while(U){U=!1;let _=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),z=W.match(_);if(!z||z.index===void 0)break;let B=z.index,q=z[1],j=B+z[0].length,H=new RegExp(`@${Q}\\(`),O=new RegExp(`@${G}(?![a-z])`),V=1,L=j,F=-1;while(V>0&&L<W.length){let N=W.slice(L),w=N.match(H),R=N.match(O),T=w?L+w.index:1/0,E=R?L+R.index:1/0;if(T<E)V++,L=T+(w[0].length||1);else if(E<1/0){if(V--,V===0){F=E;break}L=E+G.length+1}else break}if(F===-1)break;let A=W.slice(j,F);if(!Z[q])Z[q]=[];if(K)Z[q].unshift(A);else Z[q].push(A);W=W.substring(0,B)+W.substring(F+`@${G}`.length),U=!0}return W}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function wZ($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
|
|
2204
|
-
`)})}var zB=0,
|
|
2204
|
+
`)})}var zB=0,o4,b9;var R5=D(()=>{p3();o0();f4();p0();w0();o4=new i$(500),b9=new Set});import*as P9 from"path";async function qB($,Z,Y=""){if(P9.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 HB($,Z,Y,"@js","@endjs")}async function jB($,Z,Y=""){if(P9.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 HB($,Z,Y,"@ts","@endts")}async function HB($,Z,Y,X,J){let Q=$,G=K5(`${X}([\\s\\S]*?)${J}`,"g"),K=[],W;while((W=G.exec($))!==null)K.push({fullMatch:W[0],content:W[1]||"",index:W.index});for(let{fullMatch:U,content:_,index:z}of K)try{let B=Object.keys(Z),q=Object.values(Z),j=_.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let O=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),V=O.length>0?`return { ${O.join(", ")} };`:"return {};",L=`
|
|
2205
2205
|
${j}
|
|
2206
2206
|
${V}
|
|
2207
2207
|
`,A=Function(...B,L)(...q);if(A&&typeof A==="object")Object.assign(Z,A);Q=Q.replace(U,"")}catch(B){console.error(`Error executing ${X} code block in ${Y}:`,B);let q=B instanceof Error?B.message:String(B),j=T0(`${X} Directive`,`Error executing code: ${q}`,Y,$,z,U);console.error(j),Q=Q.replace(U,"")}return Q}var OB=D(()=>{f4();w0()});function sT($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function LB($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return sT(X,Q||"_method")})}async function y9($,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=T0("Middleware",`Error in middleware '${K.name}': ${W instanceof Error?W.message:String(W)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
|
|
@@ -2252,14 +2252,14 @@ ${$.map((Q)=>{let G=Q.startsWith("http")?Q:`${Y}${Q.startsWith("/")?"":"/"}${Q}`
|
|
|
2252
2252
|
</sitemap>`}).join(`
|
|
2253
2253
|
`)}
|
|
2254
2254
|
</sitemapindex>`}async function $E($,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((B)=>{if(B.startsWith("*"))return K.includes(B.slice(1));return K.startsWith(B)||K.includes(`/${B}`)}))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}`,z;try{let B=await Bun.file(_).stat();if(B)z=new Date(B.mtime).toISOString().split("T")[0]}catch{}J.push({loc:U||"/",lastmod:z,priority:U==="/"?1:0.5})}return J.sort((K,W)=>K.loc.localeCompare(W.loc)),J}function AB($){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(`
|
|
2255
|
-
`).trim()}function ZE($){return AB({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function YE($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var RZ,MZ;var TZ=D(()=>{M1();p0();RZ={name:"meta",handler:($,Z,Y,X)=>{if(Z.length<1)return _0("Meta","meta directive requires at least the meta name",J0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${W0(J)}" content="${W0(Q)}">`},hasEndTag:!1},MZ={name:"structuredData",handler:($,Z,Y,X)=>{if($.trim()==="")return _0("StructuredData","structuredData directive requires JSON-LD content",J0.INVALID_DIRECTIVE_SYNTAX);try{let J=JSON.parse($);if(!J["@context"])J["@context"]="https://schema.org";if(!J["@type"])return _0("StructuredData","structuredData requires @type property",J0.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 _0("StructuredData",Q,J0.EVALUATION_ERROR)}},hasEndTag:!0}});async function NB($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(B7.exact[$])for(let X of B7.exact[$])await Promise.resolve(X(Z,$));if(B7.exact[Y])for(let X of B7.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of B7.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}var B7;var wB=D(()=>{B7={patterns:[],exact:{}}});function RB($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>RB(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function EZ($,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(([_,z])=>U>=_&&U<z)}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 z=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,B,q=_,j=!1;while((B=z.exec(_))!==null){let H=B[1],O=B[2];if(O.includes("()")&&!O.includes(".get(")||O.includes("$store")||O.includes("$ref"))continue;try{let V=Object.keys(Z),L=Object.values(Z),F=O.match(/^([a-zA-Z_$][\w$]*)/);if(F&&!V.includes(F[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(F[1]))continue;let N=Function(...V,`return (${O})`)(...L);if(H==="class"){let w=RB(N);if(w){let R=q.match(/\sclass="([^"]*)"/);if(R)q=q.replace(R[0],` class="${R[1]} ${w}"`);else q=q.replace(B[0],` class="${w}"`)}else q=q.replace(B[0],"");j=!0;continue}if(XE.has(H)){if(N)q=q.replace(B[0],` ${H}`);else q=q.replace(B[0],"");j=!0;continue}if(N===null||N===void 0||N===!1)q=q.replace(B[0],"");else{let w=String(N).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");q=q.replace(B[0],` ${H}="${w}"`)}j=!0}catch{continue}}if(j){let H=U.endsWith("/>")?" /":"",V=`<${Q[1]}${q}${H}>`;W.push({start:Q.index,end:Q.index+U.length,replacement:V})}}for(let U=W.length-1;U>=0;U--){let{start:_,end:z,replacement:B}=W[U];Y=Y.slice(0,_)+B+Y.slice(z)}return Y}var XE;var m9=D(()=>{XE=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function
|
|
2255
|
+
`).trim()}function ZE($){return AB({rules:[{userAgent:"*",allow:["/"]}],sitemap:$})}function YE($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var RZ,MZ;var TZ=D(()=>{M1();p0();RZ={name:"meta",handler:($,Z,Y,X)=>{if(Z.length<1)return _0("Meta","meta directive requires at least the meta name",J0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),Q=Z.length>1?Z[1].replace(/['"]/g,""):"";return`<meta name="${W0(J)}" content="${W0(Q)}">`},hasEndTag:!1},MZ={name:"structuredData",handler:($,Z,Y,X)=>{if($.trim()==="")return _0("StructuredData","structuredData directive requires JSON-LD content",J0.INVALID_DIRECTIVE_SYNTAX);try{let J=JSON.parse($);if(!J["@context"])J["@context"]="https://schema.org";if(!J["@type"])return _0("StructuredData","structuredData requires @type property",J0.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 _0("StructuredData",Q,J0.EVALUATION_ERROR)}},hasEndTag:!0}});async function NB($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(B7.exact[$])for(let X of B7.exact[$])await Promise.resolve(X(Z,$));if(B7.exact[Y])for(let X of B7.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of B7.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}var B7;var wB=D(()=>{B7={patterns:[],exact:{}}});function RB($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>RB(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function EZ($,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(([_,z])=>U>=_&&U<z)}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 z=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,B,q=_,j=!1;while((B=z.exec(_))!==null){let H=B[1],O=B[2];if(O.includes("()")&&!O.includes(".get(")||O.includes("$store")||O.includes("$ref"))continue;try{let V=Object.keys(Z),L=Object.values(Z),F=O.match(/^([a-zA-Z_$][\w$]*)/);if(F&&!V.includes(F[1])&&!["true","false","null","undefined","Math","JSON","String","Number","Array","Object","Date","parseInt","parseFloat"].includes(F[1]))continue;let N=Function(...V,`return (${O})`)(...L);if(H==="class"){let w=RB(N);if(w){let R=q.match(/\sclass="([^"]*)"/);if(R)q=q.replace(R[0],` class="${R[1]} ${w}"`);else q=q.replace(B[0],` class="${w}"`)}else q=q.replace(B[0],"");j=!0;continue}if(XE.has(H)){if(N)q=q.replace(B[0],` ${H}`);else q=q.replace(B[0],"");j=!0;continue}if(N===null||N===void 0||N===!1)q=q.replace(B[0],"");else{let w=String(N).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");q=q.replace(B[0],` ${H}="${w}"`)}j=!0}catch{continue}}if(j){let H=U.endsWith("/>")?" /":"",V=`<${Q[1]}${q}${H}>`;W.push({start:Q.index,end:Q.index+U.length,replacement:V})}}for(let U=W.length-1;U>=0;U--){let{start:_,end:z,replacement:B}=W[U];Y=Y.slice(0,_)+B+Y.slice(z)}return Y}var XE;var m9=D(()=>{XE=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function C6($,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("/")||JE.has(X[1].toLowerCase()),start:X.index,end:X.index+X[0].length}}function GE($,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 Y4($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=GE($,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 MB($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function M5($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return X?X[1]:null}function t4($,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 e4($,Z,Y){let X=Z.selfClosing?" /":"",J=`<${Z.tag}${Y}${X}>`;return $.slice(0,Z.start)+J+$.slice(Z.end)}function TB($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function KE($){let Z=$,Y=0;while(Y<Z.length){let X=C6(Z,Y);if(!X)break;let J=M5(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((F)=>F.trim()),V=O[0],L=O[1];W=`${K} as ${L} => ${V}`}else W=`${K} as ${G}`;let U=t4(X.attrs,"v-for"),_=t4(U,":key").replace(/\s*v-bind:key="[^"]*"/g,""),z=Y4(Z,X),B=Z.slice(z.outerStart,z.outerEnd),q=e4(B,{...X,start:0,end:X.end-X.start},_),j=`@foreach(${W})
|
|
2256
2256
|
`,H=`${j}${q}
|
|
2257
|
-
@endforeach`;Z=Z.slice(0,z.outerStart)+H+Z.slice(z.outerEnd),Y=z.outerStart+j.length}return Z}function WE($){let Z=$,Y=0;while(Y<Z.length){let X=
|
|
2257
|
+
@endforeach`;Z=Z.slice(0,z.outerStart)+H+Z.slice(z.outerEnd),Y=z.outerStart+j.length}return Z}function WE($){let Z=$,Y=0;while(Y<Z.length){let X=C6(Z,Y);if(!X)break;let J=M5(X.attrs,"v-if");if(J===null){Y=X.end;continue}let Q=[],G=Y4(Z,X),K=t4(X.attrs,"v-if"),W=e4(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,V=C6(Z,U+O);if(!V){_=!1;break}let L=M5(V.attrs,"v-else-if"),F=MB(V.attrs,"v-else");if(L!==null){let A=Y4(Z,V),N=t4(V.attrs,"v-else-if"),w=e4(Z.slice(A.outerStart,A.outerEnd),{...V,start:0,end:V.end-V.start},N);Q.push({type:"else-if",expr:L,outerStart:U,outerEnd:A.outerEnd,element:w,parsedTag:V}),U=A.outerEnd}else if(F){let A=Y4(Z,V),N=t4(V.attrs,"v-else"),w=e4(Z.slice(A.outerStart,A.outerEnd),{...V,start:0,end:V.end-V.start},N);Q.push({type:"else",outerStart:U,outerEnd:A.outerEnd,element:w,parsedTag:V}),_=!1}else _=!1}let z=[];for(let H of Q)if(H.type==="if")z.push(`@if(${H.expr})
|
|
2258
2258
|
${H.element}`);else if(H.type==="else-if")z.push(`@elseif(${H.expr})
|
|
2259
2259
|
${H.element}`);else z.push(`@else
|
|
2260
2260
|
${H.element}`);z.push("@endif");let B=z.join(`
|
|
2261
|
-
`),q=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,q)+B+Z.slice(j),Y=q+B.length}return Z}function UE($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function _E($){let Z=$,Y=0;while(Y<Z.length){let X=
|
|
2262
|
-
${
|
|
2261
|
+
`),q=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,q)+B+Z.slice(j),Y=q+B.length}return Z}function UE($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function _E($){let Z=$,Y=0;while(Y<Z.length){let X=C6(Z,Y);if(!X)break;let J=X.attrs,Q=!1,G=/v-model:([a-zA-Z_][a-zA-Z0-9_]*)(?:\.([a-zA-Z.]+))?\s*=\s*"([^"]*)"/,K=J.match(G);while(K){Q=!0;let _=K[1],z=K[2],B=K[3];J=J.replace(K[0],""),J+=` :${_}="${B}" @update:${_}="${B} = $event"`,K=J.match(G)}if(Q){let _=Y4(Z,X),z=Z.slice(_.outerStart,_.outerEnd),B=e4(z,{...X,start:0,end:X.end-X.start},J);Z=Z.slice(0,_.outerStart)+B+Z.slice(_.outerEnd),Y=_.outerStart+B.length;continue}let W=M5(X.attrs,"v-model");if(W===null){Y=X.end;continue}if(QE.has(X.tag.toLowerCase())){let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${W}"`,z=Y4(Z,X),B=Z.slice(z.outerStart,z.outerEnd),q=e4(B,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,z.outerStart)+q+Z.slice(z.outerEnd),Y=z.outerStart+q.length}else{let _=X.attrs.replace(/\s*v-model="[^"]*"/g,"");_+=` :modelValue="${W}" @update:modelValue="${W} = $event"`;let z=Y4(Z,X),B=Z.slice(z.outerStart,z.outerEnd),q=e4(B,{...X,start:0,end:X.end-X.start},_);Z=Z.slice(0,z.outerStart)+q+Z.slice(z.outerEnd),Y=z.outerStart+q.length}}return Z}function zE($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function BE($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function qE($){let Z=$,Y=0;while(Y<Z.length){let X=C6(Z,Y);if(!X)break;let J=M5(X.attrs,"v-html");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=Y4(Z,X),G=t4(X.attrs,"v-html"),K=X.selfClosing?" /":"",W=`<${X.tag}${G}${K}>{!! ${J} !!}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function jE($){let Z=$,Y=0;while(Y<Z.length){let X=C6(Z,Y);if(!X)break;let J=M5(X.attrs,"v-text");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=Y4(Z,X),G=t4(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 HE($){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 OE($){let Z=$,Y=0;while(Y<Z.length){let X=C6(Z,Y);if(!X)break;if(!MB(X.attrs,"v-once")){Y=X.end;continue}let J=t4(X.attrs,"v-once"),Q=Y4(Z,X),G=Z.slice(Q.outerStart,Q.outerEnd),W=`@once
|
|
2262
|
+
${e4(G,{...X,start:0,end:X.end-X.start},J)}
|
|
2263
2263
|
@endonce`;Z=Z.slice(0,Q.outerStart)+W+Z.slice(Q.outerEnd),Y=Q.outerStart+W.length}return Z}function LE($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function VE($){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 c9($){if(!TB($))return $;let Z=$;return Z=KE(Z),Z=WE(Z),Z=OE(Z),Z=zE(Z),Z=BE(Z),Z=_E(Z),Z=UE(Z),Z=VE(Z),Z=qE(Z),Z=jE(Z),Z=HE(Z),Z=LE(Z),Z}var JE,QE;var l9=D(()=>{JE=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),QE=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"])});function IZ($){return $.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}async function p9($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],slotContent:W[3],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let z=V0(_.expr,Z);if(!z||typeof z!=="string"){let L=`<!-- dynamic component: could not resolve "${IZ(_.expr)}" -->`;Q=Q.slice(0,_.index)+L+Q.slice(_.index+_.full.length);continue}let B=_.attrs.trim(),q={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,H;while((H=j.exec(B))!==null){let L=H[1]||H[2],F=H[3];if(H[1])try{q[L]=V0(F,Z)}catch{q[L]=F}else q[L]=F}let O=X.componentsDir||"components",V=await Z4(z,q,_.slotContent,O,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+V+Q.slice(_.index+_.full.length)}catch(z){let B=z instanceof Error?z.message:String(z),q=`<!-- dynamic component error: ${IZ(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q=await FE(Q,Z,Y,X,J),Q}async function FE($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,K=[],W;while((W=G.exec(Q))!==null)K.push({full:W[0],expr:W[1],attrs:W[2],index:W.index});for(let U=K.length-1;U>=0;U--){let _=K[U];try{let z=V0(_.expr,Z);if(!z||typeof z!=="string"){let j=`<!-- dynamic component: could not resolve "${IZ(_.expr)}" -->`;Q=Q.slice(0,_.index)+j+Q.slice(_.index+_.full.length);continue}let B=X.componentsDir||"components",q=await Z4(z,{},"",B,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}catch(z){let B=z instanceof Error?z.message:String(z),q=`<!-- dynamic component error: ${IZ(B)} -->`;Q=Q.slice(0,_.index)+q+Q.slice(_.index+_.full.length)}}return Q}var i9=D(()=>{w0();p0()});function EB($,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 IB($,Z,Y={}){let{prefix:X="",preserveHost:J=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=n9($),W=[],U=new Map;if(Q)for(let _ of K){let z=_.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(z){let B=z[1],q=`${Z}_${B}`;U.set(B,q)}}for(let _ of K){let z=DB(_,Z,X,J,U,G);W.push(z)}return W.join(`
|
|
2264
2264
|
|
|
2265
2265
|
`)}function n9($){let Z=[],Y=$.replace(/\/\*[\s\S]*?\*\//g,""),X=0,J="",Q=!1,G="";for(let K=0;K<Y.length;K++){let W=Y[K];if(W==="@"&&X===0)Q=!0;if(W==="{")X++;else if(W==="}"){if(X--,X===0){if(Q){G+=W;let U=G.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(U){let[,_,z,B]=U;if(_==="keyframes")Z.push({selector:`@keyframes ${z.trim()}`,declarations:B.trim()});else if(_==="media"||_==="supports"||_==="container"){let q=n9(B);Z.push({selector:`@${_} ${z.trim()}`,declarations:q.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
|
|
@@ -2282,7 +2282,7 @@ ${A.join(`
|
|
|
2282
2282
|
</body>
|
|
2283
2283
|
</html>`}function kZ($){return/<!DOCTYPE\b/i.test($)||/<html[\s>]/i.test($)}function a9($,Z={}){let Y=$.lastIndexOf("</head>");if(Y===-1)return $;let{meta:X=[],link:J=[],script:Q=[],headRaw:G=""}=Z,K=$.slice(0,Y),W=[];for(let U of X){let _=U.name?`name="${U.name}"`:U.property?`property="${U.property}"`:U.charset!=null?"charset=":U["http-equiv"]?`http-equiv="${U["http-equiv"]}"`:"";if(_&&K.includes(_))continue;W.push(` <meta ${Object.entries(U).map(([z,B])=>`${z}="${B}"`).join(" ")}>`)}for(let U of J){if(U.href&&K.includes(`href="${U.href}"`))continue;W.push(` <link ${Object.entries(U).map(([_,z])=>`${_}="${z}"`).join(" ")}>`)}for(let U of Q)if(U.src){if(K.includes(`src="${U.src}"`))continue;W.push(` <script ${Object.entries(U).filter(([_])=>_!=="content").map(([_,z])=>`${_}="${z}"`).join(" ")}></script>`)}else if(U.content){if(K.includes(U.content))continue;W.push(` <script>${U.content}</script>`)}if(G&&!K.includes(G))W.push(` ${G}`);if(W.length===0)return $;return`${$.slice(0,Y)}${W.join(`
|
|
2284
2284
|
`)}
|
|
2285
|
-
${$.slice(Y)}`}function j7($,Z={},Y={}){if(kZ($))return $;return kB($,Z,Y)}var RE="<style data-stx-cloak>[x-cloak]{display:none !important}</style>";function O7($){let Z=$,Y=new Set,X=new Set,J=()=>{if(E1)X.add(E1);return Z};return J.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),H7)X.forEach((K)=>CZ.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 L7($){let Z,Y=!0,X=new Set,J=()=>{if(!Y)if(Y=!0,H7)X.forEach((G)=>CZ.add(G));else X.forEach((G)=>G())},Q=()=>{if(E1)X.add(E1);if(Y){let G=E1;E1=J,SZ.push(J);try{Z=$()}finally{SZ.pop(),E1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Q}function V7($,Z={}){let Y,X=!1,J=()=>{if(X)return;if(Y)Y(),Y=void 0;let Q=E1;E1=J,SZ.push(J);try{Y=$()}finally{SZ.pop(),E1=Q}};if(Z.immediate!==!1)J();return()=>{if(X=!0,Y)Y()}}function bZ($){if(H7){$();return}H7=!0;try{$()}finally{H7=!1,CZ.forEach((Z)=>Z()),CZ.clear()}}function PZ($){ME.push($)}function yZ($){TE.push($)}function F7($){return typeof $==="function"&&$._isSignal===!0}function A7($){return typeof $==="function"&&$._isDerived===!0}function xZ($){if(F7($)||A7($))return $();return $}function N7($){let Z=E1;E1=null;try{return $()}finally{E1=Z}}function SB($,Z){let Y=typeof $==="function"?$:()=>$,X=O7([]),J=L7(()=>X().reduce((K,W)=>Z(K,W.action),Y())),Q=!1;return V7(()=>{if(Y(),!Q){Q=!0;return}if(N7(()=>X().length))X.set([])}),[J,(K,W)=>{let U={action:K};X.set([...X(),U]);let _=()=>{let z=X().filter((B)=>B!==U);if(z.length!==X().length)X.set(z)};if(W&&typeof W.then==="function")Promise.resolve(W).then(_,_);return _}]}var E1=null,SZ,H7=!1,CZ,ME,TE;var s9=D(()=>{SZ=[],CZ=new Set,ME=[],TE=[]});var vZ={};e(vZ,{useOptimistic:()=>SB,untrack:()=>xZ,state:()=>O7,peek:()=>N7,onMount:()=>PZ,onDestroy:()=>yZ,isSignal:()=>F7,isDerived:()=>A7,generateSignalsRuntimeDev:()=>
|
|
2285
|
+
${$.slice(Y)}`}function j7($,Z={},Y={}){if(kZ($))return $;return kB($,Z,Y)}var RE="<style data-stx-cloak>[x-cloak]{display:none !important}</style>";function O7($){let Z=$,Y=new Set,X=new Set,J=()=>{if(E1)X.add(E1);return Z};return J.set=(Q)=>{if(!Object.is(Q,Z)){let G=Z;if(Z=Q,Y.forEach((K)=>K(Z,G)),H7)X.forEach((K)=>CZ.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 L7($){let Z,Y=!0,X=new Set,J=()=>{if(!Y)if(Y=!0,H7)X.forEach((G)=>CZ.add(G));else X.forEach((G)=>G())},Q=()=>{if(E1)X.add(E1);if(Y){let G=E1;E1=J,SZ.push(J);try{Z=$()}finally{SZ.pop(),E1=G}Y=!1}return Z};return Object.defineProperty(Q,"_isDerived",{value:!0,writable:!1}),Q}function V7($,Z={}){let Y,X=!1,J=()=>{if(X)return;if(Y)Y(),Y=void 0;let Q=E1;E1=J,SZ.push(J);try{Y=$()}finally{SZ.pop(),E1=Q}};if(Z.immediate!==!1)J();return()=>{if(X=!0,Y)Y()}}function bZ($){if(H7){$();return}H7=!0;try{$()}finally{H7=!1,CZ.forEach((Z)=>Z()),CZ.clear()}}function PZ($){ME.push($)}function yZ($){TE.push($)}function F7($){return typeof $==="function"&&$._isSignal===!0}function A7($){return typeof $==="function"&&$._isDerived===!0}function xZ($){if(F7($)||A7($))return $();return $}function N7($){let Z=E1;E1=null;try{return $()}finally{E1=Z}}function SB($,Z){let Y=typeof $==="function"?$:()=>$,X=O7([]),J=L7(()=>X().reduce((K,W)=>Z(K,W.action),Y())),Q=!1;return V7(()=>{if(Y(),!Q){Q=!0;return}if(N7(()=>X().length))X.set([])}),[J,(K,W)=>{let U={action:K};X.set([...X(),U]);let _=()=>{let z=X().filter((B)=>B!==U);if(z.length!==X().length)X.set(z)};if(W&&typeof W.then==="function")Promise.resolve(W).then(_,_);return _}]}var E1=null,SZ,H7=!1,CZ,ME,TE;var s9=D(()=>{SZ=[],CZ=new Set,ME=[],TE=[]});var vZ={};e(vZ,{useOptimistic:()=>SB,untrack:()=>xZ,state:()=>O7,peek:()=>N7,onMount:()=>PZ,onDestroy:()=>yZ,isSignal:()=>F7,isDerived:()=>A7,generateSignalsRuntimeDev:()=>b6,generateSignalsRuntime:()=>w7,effect:()=>V7,derived:()=>L7,default:()=>IE,batch:()=>bZ});function w7(){try{let $=EE(b6()),Y=new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($);return Y=Y.replace(/\}(var |let |const |function )/g,"};$1"),Y}catch{return b6()}}function EE($){let Z=[],Y=0,X="console.log(";while(Y<$.length){let J=$.indexOf(X,Y);if(J===-1){Z.push($.slice(Y));break}Z.push($.slice(Y,J));let Q=1,G=J+X.length;while(G<$.length&&Q>0){let K=$[G];if(K==='"'||K==="'"||K==="`"){let W=K;G++;while(G<$.length&&$[G]!==W){if($[G]==="\\")G++;G++}G++;continue}if(K==="(")Q++;else if(K===")")Q--;G++}Z.push("0"),Y=G}return Z.join("")}function b6(){return`
|
|
2286
2286
|
// STX Signals Runtime (Development Build)
|
|
2287
2287
|
console.log('[stx] signals runtime loading');
|
|
2288
2288
|
// Pre-initialization shim: capture onMount/onDestroy calls made before the runtime IIFE runs
|
|
@@ -7503,7 +7503,7 @@ catch (e) { console.warn('[stx] mount callback error:', e); }
|
|
|
7503
7503
|
}
|
|
7504
7504
|
}
|
|
7505
7505
|
})();
|
|
7506
|
-
`}var IE;var T5=D(()=>{s9();s9();IE={state:O7,derived:L7,effect:V7,batch:bZ,onMount:PZ,onDestroy:yZ,isSignal:F7,isDerived:A7,untrack:xZ,peek:N7,generateSignalsRuntime:w7,generateSignalsRuntimeDev:
|
|
7506
|
+
`}var IE;var T5=D(()=>{s9();s9();IE={state:O7,derived:L7,effect:V7,batch:bZ,onMount:PZ,onDestroy:yZ,isSignal:F7,isDerived:A7,untrack:xZ,peek:N7,generateSignalsRuntime:w7,generateSignalsRuntimeDev:b6}});var D5={};e(D5,{templateCache:()=>o9,readFileCached:()=>CB,invalidateFileCacheByDir:()=>PB,invalidateFileCache:()=>bB,hashFilePath:()=>I5,getCachedSignalsRuntime:()=>vB,getCachedRouterScript:()=>fB,clearDevCaches:()=>gB,checkCache:()=>hZ,cacheTemplate:()=>dZ,__setSignalsGeneratorsForTest:()=>xB});import $6 from"fs";import E5 from"path";async function CB($){let Y;for(let X=0;X<3;X++)try{let Q=(await $6.promises.stat($)).mtime.getTime(),G=P6.get($);if(G&&G.mtime===Q)return G.content;let K=await Bun.file($).text(),U=(await $6.promises.stat($)).mtime.getTime();if(U!==Q)continue;return P6.set($,{content:K,mtime:U}),K}catch(J){Y=J;break}throw P6.delete($),Error(`File not found: ${$}${Y?` (${Y.message})`:""}`)}function bB($){P6.delete($)}function PB($){for(let Z of P6.keys())if(Z.startsWith($))P6.delete(Z)}function xB($){yB=$}async function vB($=!1){let Z=yB??await Promise.resolve().then(() => (T5(),vZ));if($)return Z.generateSignalsRuntimeDev();if(fZ===null)fZ=Z.generateSignalsRuntime();return fZ}async function fB(){if(gZ===null){let{getRouterScript:$}=await import("stx-router");gZ=$()}return gZ}function gB(){P6.clear(),fZ=null,DE=null,gZ=null}function hB($){let Z={debug:$.debug===!0,middleware:($.middleware??[]).map((Y)=>({name:Y.name,timing:Y.timing,handler:String(Y.handler)})),customDirectives:($.customDirectives??[]).map((Y)=>({name:Y.name,hasEndTag:Y.hasEndTag===!0,handler:String(Y.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(Z)).digest("hex")}async function hZ($,Z){try{if(!Z.cachePath)return null;let Y=E5.resolve(Z.cachePath),X=E5.join(Y,`${I5($)}.html`),J=E5.join(Y,`${I5($)}.meta.json`);if(!await X0(X)||!await X0(J))return null;let Q=await Bun.file(J).text(),G=JSON.parse(Q);if(G.cacheVersion!==Z.cacheVersion)return null;if(G.optionsSignature!==hB(Z))return null;if((await $6.promises.stat($)).mtime.getTime()>G.mtime)return null;for(let W of G.dependencies)if(await X0(W)){if((await $6.promises.stat(W)).mtime.getTime()>G.mtime)return null}else return null;return await Bun.file(X).text()}catch(Y){return console.warn(`Cache error for ${$}:`,Y),null}}async function dZ($,Z,Y,X){try{if(!X.cachePath)return;let J=E5.resolve(X.cachePath);await $6.promises.mkdir(J,{recursive:!0});let Q=E5.join(J,`${I5($)}.html`),G=E5.join(J,`${I5($)}.meta.json`),K=await $6.promises.stat($);await Bun.write(Q,Z);let W={sourcePath:$,mtime:K.mtime.getTime(),dependencies:Array.from(Y),cacheVersion:X.cacheVersion,optionsSignature:hB(X),generatedAt:Date.now()};await Bun.write(G,JSON.stringify(W,null,2)),o9.set($,{output:Z,mtime:K.mtime.getTime(),dependencies:Y})}catch(J){console.warn(`Failed to cache template ${$}:`,J)}}function I5($){return new Bun.CryptoHasher("sha1").update($).digest("hex").substring(0,kE)}var o9,P6,fZ=null,DE=null,yB=null,gZ=null,kE=16;var y6=D(()=>{w0();o9=new Map,P6=new Map});function dB($){if($.includes("window.StacksBrowser")||$.includes("StacksBrowser ="))return $;let Z=/<script\b(?![^>]*\bserver\b)[^>]*>([\s\S]*?)<\/script>/gi,Y="",X;while((X=Z.exec($))!==null)Y+=X[1]+`
|
|
7507
7507
|
`;let J=/\{\{([\s\S]*?)\}\}/g;while((X=J.exec($))!==null)Y+=X[1]+`
|
|
7508
7508
|
`;if(!Y.trim())return $;let G=["browserQuery","BrowserQueryBuilder","configureBrowser","createBrowserModel"].some((B)=>{return new RegExp(`\\b${B}\\b`).test(Y)}),K=new Set(["Promise","Object","Array","Map","Set","Date","Error","JSON","Math","Number","String","RegExp","Symbol","WeakMap","WeakSet","Proxy","Reflect","Intl","URL","URLSearchParams","FormData","Headers","Request","Response","AbortController","EventTarget","Element","Document","Node","Window","Console","Storage","Navigator","Blob","File","FileReader","HTMLElement","SVGElement","Event","CustomEvent","DOMParser","XMLSerializer","WebSocket","Worker","SharedWorker","IntersectionObserver","MutationObserver","ResizeObserver","PerformanceObserver","Notification","Bun","Buffer","Process"]),W=/\b([A-Z][a-zA-Z0-9]*)\s*\.\s*(all|find|first|get|where|orderBy|orderByDesc|limit|select|pluck|create|update|delete)\s*\(/g,U,_=!1;while((U=W.exec(Y))!==null)if(!K.has(U[1])){_=!0;break}if(!G&&!_)return $;let z=`<script type="module">
|
|
7509
7509
|
// STX: Auto-load @stacksjs/browser (auto-initializes API and loads models)
|
|
@@ -7515,13 +7515,13 @@ ${z}`);return z+`
|
|
|
7515
7515
|
`+$}async function uB($,Z){if($.includes("window.stx.state")||$.includes("STX Signals Runtime"))return $;if(Z.buildMode==="compile"){let K=$.indexOf("<script");if(K!==-1)return $.slice(0,K)+`<script src="/__stx/runtime.__STX_HASH__.js"></script>
|
|
7516
7516
|
`+$.slice(K);if($.includes("</head>")){let W=$.indexOf("</head>");return $.slice(0,W)+`<script src="/__stx/runtime.__STX_HASH__.js"></script>
|
|
7517
7517
|
`+$.slice(W)}return`<script src="/__stx/runtime.__STX_HASH__.js"></script>
|
|
7518
|
-
`+$}let{getCachedSignalsRuntime:Y}=await Promise.resolve().then(() => (
|
|
7518
|
+
`+$}let{getCachedSignalsRuntime:Y}=await Promise.resolve().then(() => (y6(),D5)),J=`<script data-stx-scoped>${await Y(Z.debug)}</script>`,Q=$.indexOf("<script");if(Q!==-1)return $.slice(0,Q)+J+`
|
|
7519
7519
|
`+$.slice(Q);if($.includes("</head>")){let G=$.indexOf("</head>");return $.slice(0,G)+J+`
|
|
7520
7520
|
`+$.slice(G)}if($.includes("<body")){let G=$.indexOf("<body"),K=$.indexOf(">",G);return $.slice(0,K+1)+`
|
|
7521
7521
|
`+J+$.slice(K+1)}return J+`
|
|
7522
7522
|
`+$}async function O4($,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.interceptAllLinks!==void 0)K.interceptAllLinks=Y.interceptAllLinks;if(Y.progress!==void 0)K.progress=Y.progress;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>
|
|
7523
|
-
`}let{getCachedRouterScript:J}=await Promise.resolve().then(() => (
|
|
7524
|
-
</body>`+$.slice(G+7)}var sB={};e(sB,{scanScriptTags:()=>iB,processSignals:()=>Y2,processScriptSetup:()=>rB,preEvalLiteralReactiveIfs:()=>$2,parseLoopExpression:()=>nB,hasSignalsSyntax:()=>cZ,extractExports:()=>aB,convertSignalLoopsToAttributes:()=>Z2,convertSignalDirectivesToAttributes:()=>e9});function iB($,Z={}){let Y=[];uZ.lastIndex=0;let X;while((X=uZ.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)){uZ.lastIndex=K;continue}Y.push({fullMatch:$.slice(X.index,K),attrs:J,body:$.slice(Q,G),start:X.index,end:K}),uZ.lastIndex=K}return Y}function nB($){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}=mB(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}=mB(J);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function mB($){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 cZ($){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 CE($){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 bE($){let Z=new Set,Y=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,X=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal)\s*(?:<[^>]*>)?\s*\(/g,J;while((J=Y.exec($))!==null){let Q=J[1],G;while((G=X.exec(Q))!==null)Z.add(G[1])}return Z}function PE($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function lB($,Z,Y){if(!$)return!1;let X=PE($),J=!1,Q=!1,G=!1,K=/([a-zA-Z_$][\w$]*)/g,W;while((W=K.exec(X))!==null){let B=W[1];if(X.slice(0,W.index).trimEnd().endsWith("."))continue;if(cB.has(B))continue;if(Z.has(B))J=!0;else if(Y&&B in Y)Q=!0}let U=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,_;while((_=U.exec(X))!==null){let B=_[1];if(X.slice(0,_.index).trimEnd().endsWith("."))continue;if(cB.has(B)||Y&&B in Y)continue;G=!0}return(J||G)&&!Q}function mZ($,Z,Y){let X=Y===void 0?` ${Z}`:` ${Z}="${Y.replace(/"/g,""")}"`,J=$.trim(),Q=J.match(pB);if(Q&&yE(Q[3],Q[1])){let[,G,K,W]=Q;return`<${G}${K}${X}>${W}</${G}>`}return`<template${X}>${J}</template>`}function yE($,Z){let Y=new RegExp(`<(/)?${Z}(?=[\\s/>])`,"gi"),X=0,J;while((J=Y.exec($))!==null)if(J[1]){if(X--,X<0)return!1}else X++;return!0}function e9($,Z){let Y=$,X=bE($),J=/@if\s*\(/g,Q,G=[];while((Q=J.exec(Y))!==null){let K=Q.index,W=K+Q[0].length,U=1,_=W;while(_<Y.length&&U>0){if(Y[_]==="(")U++;else if(Y[_]===")")U--;_++}if(U!==0)continue;let z=Y.substring(W,_-1).trim(),B=_,q=1,j=B,H=/@(if\s*\(|endif)/g;H.lastIndex=B;let O;while((O=H.exec(Y))!==null)if(O[1].startsWith("if"))q++;else if(O[1]==="endif"){if(q--,q===0){j=O.index+O[0].length;break}}if(q!==0)continue;let V=Y.substring(B,j-6).trim(),L;if(CE(V)){let F=
|
|
7523
|
+
`}let{getCachedRouterScript:J}=await Promise.resolve().then(() => (y6(),D5)),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+`
|
|
7524
|
+
</body>`+$.slice(G+7)}var sB={};e(sB,{scanScriptTags:()=>iB,processSignals:()=>Y2,processScriptSetup:()=>rB,preEvalLiteralReactiveIfs:()=>$2,parseLoopExpression:()=>nB,hasSignalsSyntax:()=>cZ,extractExports:()=>aB,convertSignalLoopsToAttributes:()=>Z2,convertSignalDirectivesToAttributes:()=>e9});function iB($,Z={}){let Y=[];uZ.lastIndex=0;let X;while((X=uZ.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)){uZ.lastIndex=K;continue}Y.push({fullMatch:$.slice(X.index,K),attrs:J,body:$.slice(Q,G),start:X.index,end:K}),uZ.lastIndex=K}return Y}function nB($){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}=mB(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}=mB(J);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function mB($){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 cZ($){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 CE($){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 bE($){let Z=new Set,Y=/<script\b(?![^>]*\bserver\b)(?![^>]*\bsrc\s*=)[^>]*>([\s\S]*?)<\/script>/gi,X=/\b(?:const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=\s*(?:state|derived|computed|ref|reactive|signal)\s*(?:<[^>]*>)?\s*\(/g,J;while((J=Y.exec($))!==null){let Q=J[1],G;while((G=X.exec(Q))!==null)Z.add(G[1])}return Z}function PE($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function lB($,Z,Y){if(!$)return!1;let X=PE($),J=!1,Q=!1,G=!1,K=/([a-zA-Z_$][\w$]*)/g,W;while((W=K.exec(X))!==null){let B=W[1];if(X.slice(0,W.index).trimEnd().endsWith("."))continue;if(cB.has(B))continue;if(Z.has(B))J=!0;else if(Y&&B in Y)Q=!0}let U=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,_;while((_=U.exec(X))!==null){let B=_[1];if(X.slice(0,_.index).trimEnd().endsWith("."))continue;if(cB.has(B)||Y&&B in Y)continue;G=!0}return(J||G)&&!Q}function mZ($,Z,Y){let X=Y===void 0?` ${Z}`:` ${Z}="${Y.replace(/"/g,""")}"`,J=$.trim(),Q=J.match(pB);if(Q&&yE(Q[3],Q[1])){let[,G,K,W]=Q;return`<${G}${K}${X}>${W}</${G}>`}return`<template${X}>${J}</template>`}function yE($,Z){let Y=new RegExp(`<(/)?${Z}(?=[\\s/>])`,"gi"),X=0,J;while((J=Y.exec($))!==null)if(J[1]){if(X--,X<0)return!1}else X++;return!0}function e9($,Z){let Y=$,X=bE($),J=/@if\s*\(/g,Q,G=[];while((Q=J.exec(Y))!==null){let K=Q.index,W=K+Q[0].length,U=1,_=W;while(_<Y.length&&U>0){if(Y[_]==="(")U++;else if(Y[_]===")")U--;_++}if(U!==0)continue;let z=Y.substring(W,_-1).trim(),B=_,q=1,j=B,H=/@(if\s*\(|endif)/g;H.lastIndex=B;let O;while((O=H.exec(Y))!==null)if(O[1].startsWith("if"))q++;else if(O[1]==="endif"){if(q--,q===0){j=O.index+O[0].length;break}}if(q!==0)continue;let V=Y.substring(B,j-6).trim(),L;if(CE(V)){let F=H5(Y.substring(K,j));if(F.length===0)continue;let A=F[0].branches.filter((R)=>R.type!=="else");if(!(A.length>0&&A.every((R)=>lB(R.condition,X,Z))))continue;L=F[0].branches.map((R)=>{if(R.type==="elseif")return mZ(R.content,"@else-if",R.condition??"");if(R.type==="else")return mZ(R.content,"@else");return mZ(R.content,"@if",R.condition??"")}).join(`
|
|
7525
7525
|
`)}else{if(!lB(z,X,Z))continue;L=mZ(V,"@if",z)}G.push({start:K,end:j,replacement:L})}for(let K=G.length-1;K>=0;K--){let{start:W,end:U,replacement:_}=G[K];Y=Y.substring(0,W)+_+Y.substring(U)}return Y}function xE($){let Z=$.trim();if(Z==="")return;if(Z==="true")return!0;if(Z==="false")return!1;if(Z==="null")return!1;if(Z==="undefined")return!1;if(Z==="NaN")return!1;if(/^-?\d+(?:\.\d+)?$/.test(Z)){let J=Number(Z);return J!==0&&!Number.isNaN(J)}let Y=Z.match(/^'((?:\\.|[^'\\])*)'$/);if(Y)return Y[1].length>0;let X=Z.match(/^"((?:\\.|[^"\\])*)"$/);if(X)return X[1].length>0;return}function vE($,Z,Y,X){if(t9.has(Y.toLowerCase()))return X;let J=Y.toLowerCase(),Q=$.toLowerCase(),G=$.length,K=1,W=X;while(W<G){let U=$.indexOf("<",W);if(U===-1)return-1;if(W=U,$.startsWith("<!--",W)){let q=$.indexOf("-->",W+4);if(q===-1)return-1;W=q+3;continue}let _=/^<(script|style)\b/i.exec($.slice(W,W+8));if(_){let q=$.indexOf(">",W);if(q===-1)return-1;if($[q-1]==="/"){W=q+1;continue}let j=Q.indexOf(`</${_[1].toLowerCase()}`,W);if(j===-1)return-1;let H=$.indexOf(">",j);if(H===-1)return-1;W=H+1;continue}if($[W+1]==="/"){let q=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(W,W+64));if(!q){W++;continue}if(q[1].toLowerCase()===J){if(K--,W+=q[0].length,K===0)return W;continue}W+=q[0].length;continue}let z=/^<([a-z][\w-]*)\b/i.exec($.slice(W,W+64));if(!z){W++;continue}let B=$.indexOf(">",W);if(B===-1)return-1;if(z[1].toLowerCase()===J){let q=$.slice(W,B+1);if(!(/\/\s*>$/.test(q)||t9.has(J)))K++}W=B+1}return-1}function gE($,Z){let Y=Z,X=$.length;for(;;){while(Y<X&&$[Y]!=="<")Y++;if(Y>=X)return!1;if($.startsWith("<!--",Y)){let G=$.indexOf("-->",Y+4);if(G===-1)return!1;Y=G+3;continue}break}if($[Y+1]==="/")return!1;let J=$.indexOf(">",Y);if(J===-1)return!1;let Q=$.slice(Y,J+1);return fE.test(Q)}function $2($){if(!$.includes(":if")&&!$.includes(":show")&&!$.includes("x-if")&&!$.includes("x-show")&&!$.includes("@if=")&&!$.includes("@show="))return $;let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,X;while((X=Y.exec($))!==null)Z.push([X.index,X.index+X[0].length]);let J=(z)=>Z.some(([B,q])=>z>=B&&z<q),Q=/<([a-zA-Z][\w-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*?)\s+(:if|:show|x-if|x-show|@if|@show)\s*=\s*"([^"]*)"((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)(\/?)>/g,G=[],K;while((K=Q.exec($))!==null){if(J(K.index))continue;let[z,B,q,j,H,O,V]=K,L=xE(H);if(L===void 0)continue;let F=K.index,A=F+z.length,R=!!V||/\/\s*>$/.test(z)||t9.has(B.toLowerCase())?A:vE($,F,B,A);if(R===-1)continue;if((j===":if"||j==="x-if"||j==="@if")&&gE($,R)){Q.lastIndex=A;continue}if(L===!0){let E=`<${B}${q}${O}${V}>`;G.push({start:F,end:A,replacement:E});continue}G.push({start:F,end:R,replacement:""}),Q.lastIndex=R}if(G.length===0)return $;G.sort((z,B)=>z.start-B.start);let W=[],U=-1;for(let z of G){if(z.start<U)continue;W.push(z),U=z.end}let _=$;for(let z=W.length-1;z>=0;z--){let{start:B,end:q,replacement:j}=W[z];_=_.substring(0,B)+j+_.substring(q)}return _}function Z2($,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 z=Y.substring(W,_-1).trim(),B=_,q=nB(z);if(q.iterable){let w=q.iterable.trim();if(w.startsWith("[")||w.startsWith("{")||w.startsWith("'")||w.startsWith('"')||w.startsWith("`")||/^-?\d/.test(w))continue;if(Z){let R=w.split(/[.[(]/)[0].trim();if(R&&R in Z)continue}}if(q.style==="as")z=q.indexVar?`(${q.itemVar}, ${q.indexVar}) in ${q.iterable}`:`${q.itemVar} in ${q.iterable}`;let j=G==="for"?"@endfor":"@endforeach",H=1,O=B,V=G==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${G}\\s*\\(|end${G})`,"g");V.lastIndex=B;let L;while((L=V.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 F=Y.substring(B,O-j.length).trim(),A=F.match(pB),N;if(A){let[,w,R,T]=A;N=`<${w}${R} @for="${z}">${T}</${w}>`}else N=`<template @for="${z}">${F}</template>`;Q.push({start:K,end:O,replacement:N})}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 hE($){let Z=new Set,Y=[],X=0,J=0,Q=$.length,G=(_)=>{let z=X+1;while(z<Q){let B=$[z];if(B==="\\"){z+=2;continue}if(B===_)return z+1;z++}return Q},K=()=>{let _=X+2;while(_<Q&&$[_]!==`
|
|
7526
7526
|
`)_++;return _},W=()=>{let _=X+2;while(_<Q-1){if($[_]==="*"&&$[_+1]==="/")return _+2;_++}return Q},U=(_)=>{let z=_,B=0;while(z<Q){let q=$[z];if(q==="/"&&$[z+1]==="/"){let j=z+2;while(j<Q&&$[j]!==`
|
|
7527
7527
|
`)j++;z=j;continue}if(q==="/"&&$[z+1]==="*"){let j=z+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;z=j+2;continue}if(q==='"'||q==="'"||q==="`"){let j=z+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===q){j++;break}j++}z=j;continue}if(q==="("||q==="["||q==="{"){B++,z++;continue}if(q===")"||q==="]"||q==="}"){B--,z++;continue}if(q===";"&&B===0)return z+1;z++}return Q};while(X<Q){let _=$[X];if(_==="/"&&$[X+1]==="/"){let z=K();Y.push($.slice(X,z)),X=z;continue}if(_==="/"&&$[X+1]==="*"){let z=W();Y.push($.slice(X,z)),X=z;continue}if(_==='"'||_==="'"||_==="`"){let z=G(_);Y.push($.slice(X,z)),X=z;continue}if(_==="{"){J++,Y.push(_),X++;continue}if(_==="}"){J--,Y.push(_),X++;continue}if(J===0){let z=X>0?$[X-1]:"";if(z===""||/\s/.test(z)||z===";"||z==="}"||z==="{"){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 rB($,Z,Y){let X=iB($,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b/}),J=/\b(?:state|derived|effect|ref|reactive|computed|watch|watchEffect|useStore|useLocalStorage|useSessionStorage|useCookie|useReactiveProp|useFetch|useRef|useEventListener|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|defineProps|withDefaults|defineEmits|defineExpose|defineSlots|useOptimistic)\s*(?:<[^>]*>)?\s*\(/,Q=[];for(let H of X){let O=H.body;if(x4(H.attrs))O=v4(O);if(J.test(O))Q.push({fullMatch:H.fullMatch,attrs:H.attrs,content:O})}if(Q.length===0)return{output:$,setupCode:null};let G=`__stx_setup_${Date.now()}_${SE++}`,{hasUserImports:K,bundleClientScript:W}=await Promise.resolve().then(() => (N3(),A3)),U=[];for(let H=0;H<Q.length;H++){let O=Q[H].content;if(K(O))console.log("[stx:bundler] bundling signal script imports"),O=await W(O,Z||"",{projectRoot:process.cwd()});O=O.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 V=z4(O);U.push(`// \u2500\u2500 merged signal script #${H+1} \u2500\u2500
|
|
@@ -7540,13 +7540,13 @@ if(window.stx)window.stx._latestSetup=${G};
|
|
|
7540
7540
|
`)Q++;return!0}if(Z[Q]==="/"&&Z[Q+1]==="*"){Q+=2;while(Q<G-1&&!(Z[Q]==="*"&&Z[Q+1]==="/"))Q++;return Q+=2,!0}return!1},q=()=>{if(J!==0)return;let j=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(j){let F=j[2];if(!X.has(F))Y.push(F),X.add(F);return}let H=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(H){H[1].split(",").forEach((F)=>{let A=F.trim();if(!A)return;let N=A.indexOf(":"),R=(N>=0?A.slice(N+1).trim():A).split(/[\s=]/)[0];if(R&&!X.has(R))Y.push(R),X.add(R)});return}let O=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(O){O[1].split(",").forEach((F)=>{let A=F.trim().replace(/^\.\.\./,"");if(!A)return;let N=A.split(/[\s=]/)[0];if(N&&!X.has(N))Y.push(N),X.add(N)});return}let V=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(V){let F=V[1];if(!X.has(F))Y.push(F),X.add(F);return}let L=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(L){let F=L[1];if(!X.has(F))Y.push(F),X.add(F)}};while(Q<G){if(B())continue;if(Z[Q]==="'"||Z[Q]==='"'){_(Z[Q]),K=Z[Q-1];continue}if(Z[Q]==="`"){z(),K="`";continue}if(Z[Q]==="/"&&Z[Q+1]!=="/"&&Z[Q+1]!=="*"&&U()){W(),K="/";continue}if(Z[Q]==="{"){J++,K="{",Q++;continue}if(Z[Q]==="}"){J--,K="}",Q++;continue}if(J===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))q();if(!/\s/.test(Z[Q]))K=Z[Q];Q++}return Y.join(", ")}async function Y2($,Z,Y,X){if(!cZ($))return $;let J=$;if(Z.skipSignalsRuntime)return J;let{output:Q,setupCode:G}=await rB(J,Y,X);if(J=Q,J=await uB(J,Z),J=dB(J),G)if(J.includes("</head>"))J=J.replace("</head>",`${G}
|
|
7541
7541
|
</head>`);else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
|
|
7542
7542
|
${G}`);else J=J+`
|
|
7543
|
-
`+G;let W=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),U=W&&/data-stx/.test(W[1]);if(!G&&!U&&W&&!/data-stx-auto/.test(W[1])){let _=/<body[^>]*>/i,z=/<(script|style)\b[\s\S]*?<\/\1>/gi,B=[],q;while((q=z.exec(J))!==null)B.push([q.index,q.index+q[0].length]);let j=0,H=-1;while(j<J.length){_.lastIndex=j;let O=_.exec(J.slice(j));if(!O)break;let V=j+O.index;if(!B.some(([F,A])=>V>=F&&V<A)){H=V;break}j=V+O[0].length}if(H!==-1){let O=J.slice(0,H),V=J.slice(H).replace(_,(L)=>L.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));J=O+V}}return J}var SE=0,uZ,pB,cB,t9,fE;var X2=D(()=>{
|
|
7543
|
+
`+G;let W=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),U=W&&/data-stx/.test(W[1]);if(!G&&!U&&W&&!/data-stx-auto/.test(W[1])){let _=/<body[^>]*>/i,z=/<(script|style)\b[\s\S]*?<\/\1>/gi,B=[],q;while((q=z.exec(J))!==null)B.push([q.index,q.index+q[0].length]);let j=0,H=-1;while(j<J.length){_.lastIndex=j;let O=_.exec(J.slice(j));if(!O)break;let V=j+O.index;if(!B.some(([F,A])=>V>=F&&V<A)){H=V;break}j=V+O[0].length}if(H!==-1){let O=J.slice(0,H),V=J.slice(H).replace(_,(L)=>L.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));J=O+V}}return J}var SE=0,uZ,pB,cB,t9,fE;var X2=D(()=>{M6();X7();w0();uZ=/<script\b([^>]*)>/gi,pB=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;cB=new Set(["true","false","null","undefined","NaN","Infinity","typeof","instanceof","in","of","new","void","delete","this","Math","JSON","Date","Number","String","Boolean","Array","Object","RegExp","Map","Set","Symbol","parseInt","parseFloat","isNaN","isFinite","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","window","document","console"]);t9=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);fE=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/});import k5 from"path";function oB($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}async function tB($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=k5.join(J,$);if(await Bun.file(G).exists())return G;J=k5.dirname(J)}X=k5.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=k5.resolve(Z,$);else X=k5.resolve(Z,$);if(await Bun.file(X).exists())return X;return null}catch{return null}}async function eB($,Z,Y){let X=$,J=k5.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[U,_,z,B]=G;if(oB(z))continue;let q=await tB(z,J,Z);if(q)try{let j=await Bun.file(q).text();if(Y.add(q),z.endsWith(".ts")||z.endsWith(".tsx")){let O=await Bun.build({entrypoints:[q],target:"browser",minify:!1,define:P1()});if(O.outputs.length>0)j=await O.outputs[0].text()}let H=`<script>
|
|
7544
7544
|
// Source: ${z}
|
|
7545
7545
|
${j}
|
|
7546
7546
|
</script>`;X=X.replace(U,H),Q.lastIndex=0}catch(j){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,W;while((W=K.exec(X))!==null){let[U,_,z,B]=W,q=_+B;if(oB(z))continue;if(/rel=["']stylesheet["']/.test(q)||z.endsWith(".css")){let H=await tB(z,J,Z);if(H)try{let O=await Bun.file(H).text();Y.add(H);let V=`<style>
|
|
7547
7547
|
/* Source: ${z} */
|
|
7548
7548
|
${O}
|
|
7549
|
-
</style>`;X=X.replace(U,V),K.lastIndex=0}catch(O){}}}return X}var $q=D(()=>{
|
|
7549
|
+
</style>`;X=X.replace(U,V),K.lastIndex=0}catch(O){}}}return X}var $q=D(()=>{w6()});function R7($,Z){let Y=$,X=/@json\s*\(/g,J;while((J=X.exec(Y))!==null){let Q=J.index,G=Q+J[0].length-1,K=1,W=G+1,U=null,_=!1;while(W<Y.length&&K>0){let F=Y[W];if(_){_=!1,W++;continue}if(F==="\\"&&U){_=!0,W++;continue}if(U){if(F===U)U=null;W++;continue}if(F==='"'||F==="'"||F==="`"){U=F,W++;continue}if(F==="(")K++;else if(F===")"){if(K--,K===0)break}W++}if(K!==0)break;let z=Y.substring(G+1,W).trim(),B=Y.substring(Q,W+1),q=-1,j=0,H=null,O=!1;for(let F=0;F<z.length;F++){let A=z[F];if(O){O=!1;continue}if(A==="\\"&&H){O=!0;continue}if(H){if(A===H)H=null;continue}if(A==='"'||A==="'"||A==="`"){H=A;continue}if(A==="("||A==="["||A==="{")j++;else if(A===")"||A==="]"||A==="}")j--;if(A===","&&j===0){q=F;break}}let V=q>=0?z.substring(0,q).trim():z,L=q>=0?z.substring(q+1).trim():void 0;try{let F=V.trim(),A;if(R0(F))A=M0(F,Object.keys(Z))(...Object.values(Z));else A=void 0;let N;if(L==="true")N=JSON.stringify(A,null,2);else N=JSON.stringify(A);let w=N.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+w+Y.substring(W+1),X.lastIndex=Q+w.length}catch(F){J1.log(F instanceof Error?F:Error(String(F)),{directive:"@json"},"error"),X.lastIndex=Q+B.length}}return Y}function M7($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function Zq($){let Z=$,Y=/@memo\s*\(/g,X,J=[];while((X=Y.exec(Z))!==null){let Q=X.index,G=Q+X[0].length,K=1,W=G;while(W<Z.length&&K>0){if(Z[W]==="(")K++;else if(Z[W]===")")K--;W++}if(K!==0)continue;let U=Z.slice(G,W-1).trim(),_=W,z=Z.slice(_),B=z.indexOf("@endmemo");if(B===-1)continue;let q=z.slice(0,B),j=_+B+8,H=q.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),O=H?H[0].length:0,V=q.slice(O),L=q.match(/(\s*)$/),F=L?L[0].length:0,A=V.slice(0,V.length-F),N=A.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),w;if(N){let[R,T,E="",I]=N,k=`<${T}${E} data-stx-memo="${U}"${I}>`;w=q.slice(0,O)+k+A.slice(R.length)+q.slice(O+A.length)}else w=`${q.slice(0,O)}<div data-stx-memo="${U}">${A}</div>${q.slice(O+A.length)}`;J.push({start:Q,end:j,replacement:w}),Y.lastIndex=j}for(let Q=J.length-1;Q>=0;Q--){let G=J[Q];Z=Z.slice(0,G.start)+G.replacement+Z.slice(G.end)}return Z.replace(/@memo="([^"]*)"/g,'data-stx-memo="$1"')}function J2($){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 Yq($){let Y=new RegExp("<(div|span|p|h[1-6]|td|th|li|a|button|label|section|article|header|footer|main|nav|aside|dd|dt|figcaption|summary|caption|blockquote|pre|code|em|strong|small|sub|sup|time|mark|abbr|cite|q|s|u|b|i)\\b","gi"),X="",J=0,Q;while((Q=Y.exec($))!==null){let G=Q.index,K=G+Q[0].length,W=!1,U=!1,_=-1;while(K<$.length){let H=$[K];if(W){if(H==="'")W=!1}else if(U){if(H==='"')U=!1}else if(H==="'")W=!0;else if(H==='"')U=!0;else if(H===">"){_=K;break}K++}if(_===-1)continue;if($.slice(G,_+1).includes("x-cloak"))continue;let B=$.slice(_+1),q=B.indexOf("</"),j=q>=0?B.slice(0,q):B.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,_)+" x-cloak>",J=_+1}return X+=$.slice(J),X}function Xq($){let Z=/<[a-z][\w-]*/gi,Y="",X=0,J;while((J=Z.exec($))!==null){let Q=J.index,G=J[0].slice(1).toLowerCase();if(G==="script"||G==="style"){let j=`</${G}>`,H=$.toLowerCase().indexOf(j,Q);if(H!==-1)Z.lastIndex=H+j.length;continue}let K=Q+J[0].length,W=!1,U=!1,_=-1;while(K<$.length){let j=$[K];if(W){if(j==="'")W=!1}else if(U){if(j==='"')U=!1}else if(j==="'")W=!0;else if(j==='"')U=!0;else if(j===">"){_=K;break}K++}if(_===-1)continue;let z=$.slice(Q+J[0].length,_);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(z))continue;if(!dE.test(z))continue;let B=$[_-1]==="/",q=B?_-1:_;Y+=`${$.slice(X,q)} x-cloak${B?" ":""}`,X=q}return Y+=$.slice(X),Y}var dE;var Q2=D(()=>{M1();p0();dE=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/});function T7($,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 uE){if(J.some((_)=>K.includes(_)||G.source.includes(_)))continue;G.lastIndex=0;let U=$.match(G);if(U&&U.length>0){let _=$.split(`
|
|
7550
7550
|
`),z=[];_.forEach((q,j)=>{if(G.lastIndex=0,G.test(q))z.push(j+1)});let B=z.length>0?` (line${z.length>1?"s":""}: ${z.join(", ")})`:"";Q.push(` \u2717 ${K}${B}
|
|
7551
7551
|
\u2192 ${W}`)}}if(Q.length>0&&X.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
|
|
7552
7552
|
${Q.join(`
|
|
@@ -7556,7 +7556,7 @@ ${z.trim()}`)}catch(z){console.warn(`[stx] Failed to load store ${_}:`,z)}if(K.l
|
|
|
7556
7556
|
${K.join(`
|
|
7557
7557
|
|
|
7558
7558
|
`)}
|
|
7559
|
-
})();`;return S5.set(Z,U),U}function cE(){S5.clear()}var S5;var Qq=D(()=>{i0();
|
|
7559
|
+
})();`;return S5.set(Z,U),U}function cE(){S5.clear()}var S5;var Qq=D(()=>{i0();w6();S5=new Map});var Wq={};e(Wq,{processDeferDirectives:()=>Kq});function lE(){return`stx-defer-${++Gq}`}function pE($){let Z=$.match(/on:\s*['"]?(\w+)(?:\((\d+)\))?['"]?/);if(Z)return{trigger:Z[1],value:Z[2]};return{trigger:"immediate"}}function iE($,Z,Y){let{trigger:X,value:J}=pE(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 z=Y.match(/@error(?:\s*\(\s*(\w+)\s*\))?\s*([\s\S]*)$/);if(z)W=z[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 nE($,Z){let{trigger:Y,triggerValue:X}=Z,J;switch(Y){case"visible":J=`
|
|
7560
7560
|
const observer = new IntersectionObserver((entries) => {
|
|
7561
7561
|
if (entries[0].isIntersecting) {
|
|
7562
7562
|
observer.disconnect();
|
|
@@ -9900,7 +9900,7 @@ else {
|
|
|
9900
9900
|
<script type="application/json" id="stx-island-manifest">
|
|
9901
9901
|
${JSON.stringify(Z)}
|
|
9902
9902
|
</script>
|
|
9903
|
-
`}var MI;var T2=D(()=>{MI={processPartialHydrationDirectives:O2,processStaticDirectives:R2,generatePartialHydrationCSS:L2,generateIslandManifest:M2,createIslandRegistry:H2,hydrateIsland:V2,hydrateByStrategy:F2,hydrateAll:A2,isHydrated:N2,onHydrated:w2}});var Kj={};e(Kj,{watchMultiple:()=>Zj,watchEffect:()=>Yj,watch:()=>$j,unref:()=>oq,toRefs:()=>tq,throttledComputed:()=>Gj,stxWatchMultiple:()=>Zj,stxWatchEffect:()=>Yj,stxWatch:()=>$j,stxUnref:()=>oq,stxToRefs:()=>tq,stxThrottledComputed:()=>Gj,stxShallowRef:()=>eq,stxRef:()=>b5,stxIsRef:()=>
|
|
9903
|
+
`}var MI;var T2=D(()=>{MI={processPartialHydrationDirectives:O2,processStaticDirectives:R2,generatePartialHydrationCSS:L2,generateIslandManifest:M2,createIslandRegistry:H2,hydrateIsland:V2,hydrateByStrategy:F2,hydrateAll:A2,isHydrated:N2,onHydrated:w2}});var Kj={};e(Kj,{watchMultiple:()=>Zj,watchEffect:()=>Yj,watch:()=>$j,unref:()=>oq,toRefs:()=>tq,throttledComputed:()=>Gj,stxWatchMultiple:()=>Zj,stxWatchEffect:()=>Yj,stxWatch:()=>$j,stxUnref:()=>oq,stxToRefs:()=>tq,stxThrottledComputed:()=>Gj,stxShallowRef:()=>eq,stxRef:()=>b5,stxIsRef:()=>Z6,stxDebouncedComputed:()=>Qj,stxComputed:()=>I7,shallowRef:()=>eq,ref:()=>b5,processWatchDirectives:()=>Jj,processComputedDirectives:()=>Xj,isRef:()=>Z6,default:()=>TI,debouncedComputed:()=>Qj,computed:()=>I7});function b5($){let Z=$,Y=new Set,X={get value(){if(X4){let J=E7.get(X);if(!J)J=new Set,E7.set(X,J);J.add(X4)}return Z},set value(J){if(!Object.is(Z,J)){Z=J,Y.forEach((G)=>G(J));let Q=E7.get(X);if(Q)Q.forEach((G)=>G())}},subscribe(J){return Y.add(J),()=>Y.delete(J)},peek(){return Z}};return X}function Z6($){return $!==null&&typeof $==="object"&&"value"in $&&"subscribe"in $&&"peek"in $}function oq($){return Z6($)?$.value:$}function tq($){let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=b5($[Y]);return Z}function eq($){return b5($)}function I7($){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 B=z.value;W.forEach((q)=>q(B))}};function _(){K.clear();let B=X4;X4=U,nZ.push(U);try{return Y()}finally{nZ.pop(),X4=B}}let z={get value(){if(X4){let B=E7.get(z);if(!B)B=new Set,E7.set(z,B);B.add(X4)}if(G){let B=_();if(!J(Q,B))Q=B;G=!1}return Q},set value(B){if(X)X(B);else console.warn("Computed property is readonly")},subscribe(B){return W.add(B),()=>W.delete(B)},peek(){if(G)Q=Y(),G=!1;return Q},invalidate(){G=!0},get dirty(){return G},get deps(){return K}};return z}function $j($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="pre",once:G=!1}=Y,K,W=!0,U=!1,_=()=>{if(Z6($))return J?x6($.value):$.value;return $()},z=()=>{if(!W||U)return;let j=_();if(K!==void 0&&Object.is(K,j)&&!J)return;let H=()=>{if(Z(j,K),K=J?x6(j):j,G)q()};if(Q==="sync")H();else if(Q==="post")queueMicrotask(H);else Promise.resolve().then(H)},B=null;if(Z6($))B=$.subscribe(()=>z());else B=I7($).subscribe(()=>z());if(X)K=void 0,z();else K=_();let q=()=>{if(W=!1,B)B(),B=null};return q.pause=()=>{U=!0},q.resume=()=>{U=!1},q}function Zj($,Z,Y={}){let{immediate:X=!1,once:J=!1}=Y,Q=$.map((z)=>Z6(z)?z.value:void 0),G=!0,K=!1,W=()=>{if(!G||K)return;let z=$.map((B)=>Z6(B)?B.value:void 0);if(Z(z,Q),Q=[...z],J)_()},U=$.map((z)=>{if(Z6(z))return z.subscribe(()=>W());return()=>{}});if(X)W();let _=()=>{G=!1,U.forEach((z)=>z())};return _.pause=()=>{K=!0},_.resume=()=>{K=!1},_}function Yj($,Z={}){let{flush:Y="pre"}=Z,X,J=!0,Q=!1,G=()=>{if(!J||Q)return;if(X)X();let W=X4;X4=G,nZ.push(G);try{X=$()}finally{nZ.pop(),X4=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 Xj($,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 Jj($,Z={},Y){let X=/@watch\s*\(\s*(\w+)\s*\)\s*([\s\S]*?)@endwatch/gi;return $.replace(X,(J,Q,G)=>{return`
|
|
9904
9904
|
<script data-watch="${`watch-${Math.random().toString(36).substring(2,9)}`}">
|
|
9905
9905
|
(function() {
|
|
9906
9906
|
// Watch implementation for ${Q}
|
|
@@ -9912,7 +9912,7 @@ else {
|
|
|
9912
9912
|
}
|
|
9913
9913
|
})();
|
|
9914
9914
|
</script>
|
|
9915
|
-
`})}function
|
|
9915
|
+
`})}function x6($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>x6(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((X,J)=>Y.set(x6(J),x6(X))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((X)=>Y.add(x6(X))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=x6($[Y]);return Z}function Qj($,Z=100){let Y=b5($()),X=null,J=()=>{if(X)clearTimeout(X);X=setTimeout(()=>{Y.value=$()},Z)};return I7($).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 Gj($,Z=100){let Y=b5($()),X=0,J=()=>{let G=Date.now();if(G-X>=Z)X=G,Y.value=$()};return I7($).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 X4=null,nZ,E7,TI;var Wj=D(()=>{nZ=[],E7=new WeakMap;TI={ref:b5,computed:I7,watch:$j,watchMultiple:Zj,watchEffect:Yj,isRef:Z6,unref:oq,toRefs:tq,shallowRef:eq,debouncedComputed:Qj,throttledComputed:Gj,processComputedDirectives:Xj,processWatchDirectives:Jj}});var Bj={};e(Bj,{v:()=>EI,processHasErrorsDirective:()=>zj,processFormValidationDirectives:()=>DI,processErrorsDirective:()=>_j,processErrorDirective:()=>Uj,defineForm:()=>II,Validator:()=>P5});class P5{rules=[];defaultValue="";addRule($){let Z=new P5;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 P5;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 P5;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 II($,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 F=await $[L].validate(X[L],X);return J[L]=F,K[L]=!1,F.length===0}async function _(){W=!0;let L=await Promise.all(Y.map(U));return W=!1,L.every(Boolean)}function z(){for(let L of Y)X[L]=Z?.[L]??$[L].getDefaultValue(),J[L]=[],Q[L]=!1,G[L]=!1}function B(L){for(let F of Y)if(F in L)X[F]=L[F],G[F]=!0}function q(L,F){X[L]=F,G[L]=!0}function j(L,F=!0){if(Q[L]=F,F)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(F)=>{F?.preventDefault?.();for(let N of Y)Q[N]=!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:z,setValues:B,setFieldValue:q,setFieldTouched:j,getFieldState:H,handleSubmit:O}}function Uj($,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(`
|
|
9916
9916
|
`)}catch{return""}})}function _j($,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(`
|
|
9917
9917
|
`)}catch{return""}})}function zj($,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 DI($,Z,Y){let X=$;return X=Uj(X,Z,Y),X=_j(X,Z,Y),X=zj(X,Z,Y),X}var EI;var qj=D(()=>{EI=new P5});var Oj={};e(Oj,{processXElementDirectives:()=>kI,hasXElementDirectives:()=>Hj,generateXElementRuntime:()=>jj});function jj(){return`<script data-stx-scoped>
|
|
9918
9918
|
(function() {
|
|
@@ -10261,17 +10261,17 @@ if ('serviceWorker' in navigator) {
|
|
|
10261
10261
|
</script>`}function hI(){return'<link rel="manifest" href="/manifest.json">'}function dI($){return`<meta name="theme-color" content="${D2($)}">`}function D2($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var Nj=D(()=>{Fj()});var sZ={};e(sZ,{validateClientScript:()=>T7,processOnceDirective:()=>M7,processJsonDirective:()=>R7,processDirectives:()=>U0,injectRouterScript:()=>O4});import V1 from"path";import{deriveLayoutGroup as uI}from"stx-router/layout-metadata";function wj($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function mI($,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(`
|
|
10262
10262
|
`,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(_===`
|
|
10263
10263
|
`){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]===`
|
|
10264
|
-
`)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 U0($,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;if((X.debug||!
|
|
10264
|
+
`)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 U0($,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;if((X.debug||!z5()&&!s$())&&Y&&Y.endsWith(".stx"))eJ($,Y);try{return await g1.timeAsync("template-processing",async()=>{let G=await cI($,Z,Y,X,J);if(Q)G=J2(G);if(Q&&X.autoShell&&X.buildMode!=="compile"){let K=X.app?.head||{},U=(Z.__stx_runtime_head||null)??O5(),_=(Z.__stx_head_raw||"").trim(),z,B=_.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(B)z=B[1].trim(),_=_.replace(B[0],"").trim();let q=Z.__sections?.title,j=U.title||z||q,H={...K,...j&&{title:j},meta:[...K.meta||[],...U.meta||[]],link:[...K.link||[],...U.link||[]],script:[...K.script||[],...U.script||[]],headRaw:[K.headRaw,_].filter(Boolean).join(`
|
|
10265
10265
|
`),...U.htmlAttrs&&{htmlAttrs:{...K.htmlAttrs||{},...U.htmlAttrs}},...U.bodyAttrs&&{bodyAttrs:{...K.bodyAttrs||{},...U.bodyAttrs}}},O=kZ(G);if(G=j7(G,H),O)G=a9(G,K);let V=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(V&&G.includes("<head")){let F=V[1],A=uI(F);G=G.replace("<head>",`<head>
|
|
10266
10266
|
<meta name="stx-layout" content="${wj(F)}">
|
|
10267
10267
|
<meta name="stx-layout-group" content="${wj(A)}">`)}let L=G.match(/function (__stx_setup_\d+_\d+)\(/);if(L&&G.includes("<body")&&!G.match(/<body[^>]*data-stx=/)){G=G.replace(/<body([^>]*)>/,`<body$1 data-stx="${L[1]}">`);let F=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${L[1]}"`,"i");G=G.replace(F,"$1")}}if(Q)G=r9(G);if(Q)try{let{getStoreScript:K}=await Promise.resolve().then(() => (Qq(),Jq)),W=X.storesDir,U=await K(W);if(U){let _=`<script data-stx-stores>${U}</script>`,z=G.indexOf("<script data-stx-scoped>");if(z!==-1){let B=G.indexOf("</script>",z+24);if(B!==-1){let q=B+9;G=G.slice(0,q)+`
|
|
10268
|
-
`+_+G.slice(q)}}}}catch{}if(Q&&Z.__stx_inject_css!==!1)G=await S0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof e$)throw G;let K=G instanceof Error?G.message:String(G),W=new d1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(J1.log(W,{filePath:Y,context:Z}),
|
|
10268
|
+
`+_+G.slice(q)}}}}catch{}if(Q&&Z.__stx_inject_css!==!1)G=await S0(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof e$)throw G;let K=G instanceof Error?G.message:String(G),W=new d1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(J1.log(W,{filePath:Y,context:Z}),j5.logDetailedError(W,{filePath:Y,template:$.substring(0,500)}),X.debug)throw W;return d3.createFallbackContent("Template Processing",W)}}async function cI($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!V1.isAbsolute(X.partialsDir)?V1.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!V1.isAbsolute(X.componentsDir)?V1.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!V1.isAbsolute(X.layoutsDir)?V1.resolve(Q,X.layoutsDir):X.layoutsDir},K=G,W=$;await iI(Y,Z),pI(Z,K),W=await $4(()=>x9(W,Z,Y,K),W,(L)=>{J1.log(L,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${L.message}`)}),W=W.replace(/\{\{--[\s\S]*?--\}\}/g,"");let U=c$(W,bU,(L,F)=>`\x00STX_HTML_COMMENT_${F}\x00`);W=U.output;let _=U.tokens,z=(L)=>_.length===0?L:L.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(F,A)=>_[Number(A)]??""),B="\x00STX_ESCAPED_AT\x00";W=W.replace(/@@/g,B),W=W.replace(/@\{\{([\s\S]*?)\}\}/g,(L,F)=>{return`{{ ${F} }}`}),W=c9(W),W=await eB(W,Y,J);let q={};W=NZ(W,q);let j={...Z.__sections||{}},H="",O=/@nolayout\b/.test(W);if(O)W=W.replace(/@nolayout\b\s*/g,"");let V=W.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(V)H=V[1],W=W.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!H&&!O&&K.defaultLayout){let L=/<!DOCTYPE\s/i.test(W),F=/@section\s*\(/.test(W);if(!L||F){let A="",N=V1.dirname(Y),w=K.layoutsDir?V1.dirname(K.layoutsDir):process.cwd();for(let R=0;R<20;R++){let T=V1.join(N,"_layout.stx");if(await X0(T)){A=T;break}let E=V1.dirname(N);if(E===N||E.length<w.length)break;N=E}if(A)H=A;else if(K.layoutsDir){let R=V1.isAbsolute(K.layoutsDir)?K.layoutsDir:V1.resolve(process.cwd(),K.layoutsDir),T=V1.join(R,`${K.defaultLayout}.stx`);if(await X0(T))H=T}if(H&&!F)W=`@section('content')
|
|
10269
10269
|
${W.trim()}
|
|
10270
|
-
@endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,F,A)=>{return j[F]=A,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,F,A)=>{if(/^(['"]).*\1$/.test(A.trim()))return L;try{let N=V0(A.trim(),Z);if(N===void 0)return L;return j[F]=String(N??""),""}catch{return L}}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,F,A)=>{if(A.includes("@parent"))j[F]=A.replace("@parent",
|
|
10270
|
+
@endsection`}}if(W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(L,F,A)=>{return j[F]=A,""}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(L,F,A)=>{if(/^(['"]).*\1$/.test(A.trim()))return L;try{let N=V0(A.trim(),Z);if(N===void 0)return L;return j[F]=String(N??""),""}catch{return L}}),W=W.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(L,F,A)=>{if(A.includes("@parent"))j[F]=A.replace("@parent",v6);else j[F]=A.trim();return""}),Z.__sections=j,W=W.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(L,F,A)=>{return j[F]||A||""}),!("slot"in Z)||Z.slot===void 0)W=W.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""});if(W=wZ(W,q),H){let L=[];if(W=W.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi,(F)=>{return L.push(F),""}),L.length>0){let F=L.join(`
|
|
10271
10271
|
`);j.content=j.content?`${j.content}
|
|
10272
|
-
${F}`:F,Z.__sections=j}}if(H)try{let L;if(V1.isAbsolute(H))L=H,J.add(H);else L=await $4(()=>D7(H,Y,G,J),null,()=>{throw new d1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!L){let T=`Layout not found: ${H} (referenced from ${Y})`;if(J1.log(Error(T),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new d1(T,Y);return W}let F=await $4(()=>Bun.file(L).text(),"",()=>{throw new d1(`Failed to read layout file: ${L}`,Y,void 0,void 0,"Layout content could not be loaded")}),A=F.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(A){if(G.debug)console.log(`Found nested layout: ${A[1]} in ${L}`);let T={},E=F.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(S,x,P)=>{return T[x]=P.trim(),""});for(let[S,x]of Object.entries(T))if(j[S]&&j[S].includes(
|
|
10273
|
-
${W}`,z(W)}catch(L){return J1.log(L instanceof Error?L:Error(String(L)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${L instanceof Error?L.message:String(L)}]`}return z(await Rj(W,Z,Y,G,J))}function lI($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,X,J)=>{let Q=Z[X];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return J||""})}function pI($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",X={};for(let[J,Q]of Object.entries(process.env))if(J.startsWith(Y)&&Q!==void 0)X[J]=Q;$.$env=X}async function iI($,Z){await $4(()=>NB($,Z),void 0,(Y)=>{J1.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function nI($,Z,Y){let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,J;while((J=X.exec($))!==null){let Q=J[1],G=J[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:W}=await Promise.resolve().then(() => (
|
|
10274
|
-
`;if(Q=E(Q,Z),Q=I(Q,Z),Q=VB(Q),Q=DJ(Q,Z),Q=u_(Q),Q=LB(Q),Q=await AZ(Q,Z,Y,G,J),Q=await BZ(Q,Z,Y,G,J),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=J2(Q),Q=
|
|
10272
|
+
${F}`:F,Z.__sections=j}}if(H)try{let L;if(V1.isAbsolute(H))L=H,J.add(H);else L=await $4(()=>D7(H,Y,G,J),null,()=>{throw new d1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!L){let T=`Layout not found: ${H} (referenced from ${Y})`;if(J1.log(Error(T),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new d1(T,Y);return W}let F=await $4(()=>Bun.file(L).text(),"",()=>{throw new d1(`Failed to read layout file: ${L}`,Y,void 0,void 0,"Layout content could not be loaded")}),A=F.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(A){if(G.debug)console.log(`Found nested layout: ${A[1]} in ${L}`);let T={},E=F.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(S,x,P)=>{return T[x]=P.trim(),""});for(let[S,x]of Object.entries(T))if(j[S]&&j[S].includes(v6)){let P=j[S].indexOf(v6);j[S]=j[S].slice(0,P)+x+j[S].slice(P+v6.length)}else if(!j[S])j[S]=x;let I={...Z,__sections:j},k=`@layout('${A[1]}')${E}`;return await U0(k,I,L,G,J)}let N=F.replace(/\{\{--[\s\S]*?--\}\}/g,""),w=NZ(N,q),R={};return w=w.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,E,I)=>{return R[E]=I.trim(),`@slot('${E}')`}),w=w.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(T,E,I)=>{if(j[E]){let k=j[E];if(k.includes(v6)){let S=R[E]||"",x=k.indexOf(v6);k=k.slice(0,x)+S+k.slice(x+v6.length)}return k}return I||""}),w=lI(w,j),w=w.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),w=wZ(w,q),Z.__originalFilePath=Y,W=await Rj(w,Z,L,G,J),W=`<!-- stx-layout: ${H} -->
|
|
10273
|
+
${W}`,z(W)}catch(L){return J1.log(L instanceof Error?L:Error(String(L)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${L instanceof Error?L.message:String(L)}]`}return z(await Rj(W,Z,Y,G,J))}function lI($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,X,J)=>{let Q=Z[X];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${X.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return J||""})}function pI($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",X={};for(let[J,Q]of Object.entries(process.env))if(J.startsWith(Y)&&Q!==void 0)X[J]=Q;$.$env=X}async function iI($,Z){await $4(()=>NB($,Z),void 0,(Y)=>{J1.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function nI($,Z,Y){let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,J;while((J=X.exec($))!==null){let Q=J[1],G=J[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:W}=await Promise.resolve().then(() => (s4(),jZ));await W(G,Z,Y,{preserveExisting:!0})}catch(W){let U=W instanceof Error?W:Error(String(W));J1.log(U,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${U.message}`)}}}async function rI($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (o0(),p$));return X($,Z,{skipServer:!0})}catch(X){let J=X instanceof Error?X:Error(String(X));return J1.log(J,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${J.message}`),$}}async function Rj($,Z,Y,X,J){let Q=$,G=X;if(await nI(Q,Z,Y),Q=await rI(Q,Z,Y),Q=await qB(Q,Z,Y),Q=await jB(Q,Z,Y),Q=await gJ(Q,Z,Y,G),T6(Q))Q=e9(Q,Z),Q=Z2(Q,Z);Q=$2(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (n4(),k6));Q=K(Q,Z),Q=VZ(Q,Z,Y,G),Q=await BZ(Q,Z,Y,G,J),Q=await p9(Q,Z,Y,G,J),Q=mX(Q,Z,Y,G);let{processDeferDirectives:W}=await Promise.resolve().then(() => Wq);Q=W(Q,Z,Y);let{processTeleportDirectives:U}=await Promise.resolve().then(() => Bq);Q=U(Q,Z,Y);let{processTransitionDirectives:_,processTransitionAttributes:z}=await Promise.resolve().then(() => wq);Q=_(Q,Z,Y),Q=z(Q);let{processErrorBoundaryDirectives:B}=await Promise.resolve().then(() => Mq);Q=B(Q,Z,Y);let{processSuspenseDirectives:q}=await Promise.resolve().then(() => Sq);Q=q(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => hq);Q=j(Q,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => rq);Q=H(Q,Z,Y);let{processVirtualListDirectives:O,processVirtualGridDirectives:V,processInfiniteListDirectives:L}=await Promise.resolve().then(() => (z2(),aq));Q=O(Q,Z,Y),Q=V(Q,Z,Y),Q=L(Q,Z,Y);let{processPartialHydrationDirectives:F,processStaticDirectives:A}=await Promise.resolve().then(() => (T2(),sq));Q=F(Q,Z,Y),Q=A(Q);let{processComputedDirectives:N,processWatchDirectives:w}=await Promise.resolve().then(() => (Wj(),Kj));Q=N(Q,Z,Y),Q=w(Q,Z,Y);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (qj(),Bj));Q=R(Q,Z,Y);let{processHeadDirective:T,processTitleDirective:E,processMetaDirective:I,resetHead:k}=await Promise.resolve().then(() => (p4(),s3));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)k();let S=T(Q);if(Q=S.content,S.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${S.headContent}
|
|
10274
|
+
`;if(Q=E(Q,Z),Q=I(Q,Z),Q=VB(Q),Q=DJ(Q,Z),Q=u_(Q),Q=LB(Q),Q=await AZ(Q,Z,Y,G,J),Q=await BZ(Q,Z,Y,G,J),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=J2(Q),Q=E6(Q,Z,Y),Q=kJ(Q,Z),Q=SJ(Q,Z),Q=L5(Q,Z),Q=e3(Q,Z),Q=$Z(Q,Z),Q=await S2(Q,Z,Y,G),Q=await k2(Q,Z,Y),Q=await nJ(Q,Z,Y,G),Q=hX(Q,Z,Y,G),Q=g9(Q,Z,Y,G),Q=h9(Q,Z,Y),Q=d9(Q,Z,Y,G),Q=xJ(Q,Z,Y,G),Q=R7(Q,Z),Q=M7(Q),Q=Zq(Q),!G.skipEventDirectives)Q=LJ(Q,Z,Y);if(Q=Y_(Q,Z,Y),G.debug){let d=/\bx-data\s*=/.test(Q),v=cZ($);if(d&&v)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
10275
10275
|
Both work on the same page, but they manage separate scopes.
|
|
10276
10276
|
Prefer signals (state/derived/effect) for new components.`)}Q=EZ(Q,Z),Q=await j1(Q,Z,Y),Q=Yq(Q),Q=Xq(Q),Q=BJ(Q);let{processXElementDirectives:x}=await Promise.resolve().then(() => Oj);Q=x(Q);let P=Z.__originalFilePath||Y,b=P4(Z);if(Q=await Y2(Q,G,P,b),Q=await v9(Q,Z,Y,G),G.media?.image?.autoSiblings){let d=G.publicDir||"public",{rewriteImagesWithSiblings:v}=await Promise.resolve().then(() => (E2(),Lj));Q=await v(Q,{publicDir:d})}if(G.seo?.enabled)Q=u9(Q,Z,G);let g=(d,v)=>{if(!v)return d;if(/<\/head>/i.test(d))return d.replace(/<\/head>/i,`${v}
|
|
10277
10277
|
</head>`);if(/<head\b[^>]*>/i.test(d))return d.replace(/(<head\b[^>]*>)/i,`$1
|
|
@@ -10284,9 +10284,9 @@ ${uU()}
|
|
|
10284
10284
|
`+E0}else Q=Q.replace("</head>",`${v}
|
|
10285
10285
|
</head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
|
|
10286
10286
|
${v}`);else Q=v+`
|
|
10287
|
-
`+Q}{let d=/<script\s+server\b[^>]*>/gi,v,l=[];while((v=d.exec(Q))!==null){let a=v.index+v[0].length,i=mI(Q,a);if(i===-1)continue;let Q0=i+9;while(Q0<Q.length&&/\s/.test(Q[Q0]))Q0++;l.push({start:v.index,end:Q0}),d.lastIndex=Q0}for(let a=l.length-1;a>=0;a--){let{start:i,end:Q0}=l[a];Q=Q.substring(0,i)+Q.substring(Q0)}}let B0=q7(Q,Y);if(B0.hasScoped)Q=B0.html;let G0=Z.__stx_event_bindings||[],C0=!1,Y1=[],u=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:c}=await Promise.resolve().then(() => (X2(),sB));for(let d of c(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))Y1.push({match:d.fullMatch,attrs:d.attrs,content:d.body});for(let{match:d,attrs:v,content:l}of Y1){C0=!0;let a=l;T7(l,Y,X.strict);let i=await y4(l,{eventBindings:G0,attrs:v,hasColonDirectives:u,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(d,()=>i)}if(C0)Z.__stx_event_bindings=[];return Q}var
|
|
10287
|
+
`+Q}{let d=/<script\s+server\b[^>]*>/gi,v,l=[];while((v=d.exec(Q))!==null){let a=v.index+v[0].length,i=mI(Q,a);if(i===-1)continue;let Q0=i+9;while(Q0<Q.length&&/\s/.test(Q[Q0]))Q0++;l.push({start:v.index,end:Q0}),d.lastIndex=Q0}for(let a=l.length-1;a>=0;a--){let{start:i,end:Q0}=l[a];Q=Q.substring(0,i)+Q.substring(Q0)}}let B0=q7(Q,Y);if(B0.hasScoped)Q=B0.html;let G0=Z.__stx_event_bindings||[],C0=!1,Y1=[],u=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:c}=await Promise.resolve().then(() => (X2(),sB));for(let d of c(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))Y1.push({match:d.fullMatch,attrs:d.attrs,content:d.body});for(let{match:d,attrs:v,content:l}of Y1){C0=!0;let a=l;T7(l,Y,X.strict);let i=await y4(l,{eventBindings:G0,attrs:v,hasColonDirectives:u,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(d,()=>i)}if(C0)Z.__stx_event_bindings=[];return Q}var v6="<!--PARENT_CONTENT_PLACEHOLDER-->";var W1=D(()=>{e1();I3();X5();mU();qJ();OJ();F3();V3();VJ();M6();X_();y5();p3();vJ();m_();hJ();M1();p4();o0();mJ();rJ();R5();OB();FZ();oZ();f9();f4();FB();TZ();w0();wB();m9();l9();i9();DZ();X2();E9();$q();Q2();G2();p0();$9();Q2();G2()});function Mj($){let Z=[],Y=[];return tI($,Z),eI($,Z,Y),$D($,Y),ZD($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function tI($,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 eI($,Z,Y){for(let X of aI){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 $D($,Z){for(let Y of sI)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function ZD($,Z){for(let Y of oI)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function Tj($,Z){let Y=$.slice(0,Z).split(`
|
|
10288
10288
|
`);return{line:Y.length,column:Y[Y.length-1].length+1}}function Ej($,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 Ij($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function Dj($){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 aI,sI,oI;var kj=D(()=>{aI=[{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"}],sI=[{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')"}],oI=[{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 y2={};e(y2,{renderSlot:()=>b2,processSlots:()=>P2,parseSlots:()=>C2,parseSlotElement:()=>Sj,extractSlotContent:()=>bj,applySlots:()=>Pj});function YD($,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 C2($){let Z={default:"",named:new Map},Y=$,X=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,J=[],Q;while((Q=X.exec($))!==null){let[_,z,B,q,j]=Q,H=z||B||q,O=Q.index+_.length,V=YD($,O);if(V!==-1){let L=$.slice(O,V-11).trim();J.push({start:Q.index,end:V,slotName:H,content:L,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:L,propsBinding:j||void 0})}}J.sort((_,z)=>z.start-_.start);for(let _ of J)Y=Y.slice(0,_.start)+Y.slice(_.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,W;while((W=K.exec(Y))!==null){let[_,z,B,q,j,H]=W,O=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=(O+V).trim(),F=`<${z}${L?" "+L:""}>${H}</${z}>`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:F})}let U=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((W=U.exec(Y))!==null){let[_,z,B,q,j]=W,H=B.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=(H+O).trim(),L=`<${z}${V?" "+V:""} />`;G.push({start:W.index,end:W.index+_.length,slotName:q,element:L})}G.sort((_,z)=>z.start-_.start);for(let _ of G){let z=Z.named.get(_.slotName);if(z)z.content+=_.element;else Z.named.set(_.slotName,{name:_.slotName,content:_.element});Y=Y.slice(0,_.start)+Y.slice(_.end)}return Z.default=Y.trim(),Z}function Sj($){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 b2($,Z,Y,X){if(!$)return Y;let J=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...X};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((W)=>W.trim()).filter(Boolean);for(let W of K){let[U,_]=W.split(":").map((B)=>B.trim()),z=_||U;if(Z[U]!==void 0)G[z]=Z[U]}}else G[Q]=Z;J=XD(J,G)}return J}function XD($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=Cj(J,Z);return P0(String(Q??""))}catch{return`{{ ${X} }}`}})}function Cj($,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(!R0($))return;return M0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function P2($,Z,Y){let X=$;X=await JD(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,W,U)=>{let _=Z.named.get(K),z=U?.trim()||"",B=W||"",q={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(B))!==null){let O=H[1],V=H[2];q[O]=Cj(V,Y)}return await b2(_,q,z,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let W=K?.trim()||"";return Z.default||W}),X}async function JD($,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 bj($){let Z=C2($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function Pj($,Z,Y,X){return await P2($,{default:Z,named:Y},X)}var tZ=D(()=>{o0();p0()});import QD from"fs";import t from"path";function yj($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function xj($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function x4($){return!xj($)}function v4($){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:P1()}).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 KD($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(_)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===_){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let _=1;while(J<Q&&_>0)if($[J]==="{")_++,J++;else if($[J]==="}")_--,J++;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},W=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
|
|
10289
|
-
`)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let z=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(z){let j=z[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}function WD($){let Z=[],Y=0,X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(J){if(G==="\\"){Q++;continue}if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,Q)),X=Q+1}if(X<$.length)Z.push($.slice(X));return Z}function UD($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let J=$[X];if(Y){if(J==="\\"){X++;continue}if(J===Y)Y=null;continue}if(J==='"'||J==="'"||J==="`"){Y=J;continue}if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J==="="&&Z===0){let Q=$[X-1],G=$[X+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function _D($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let J=X,Q=0,G=-1;for(;X>=0;X--){let W=$[X];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let W of WD(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let _=UD(U);if(_===-1)continue;let z=U.slice(0,_).trim();if(!/^[A-Z_$][\w$]*$/i.test(z))continue;if(Z[z]!==void 0)continue;let B=U.slice(_+1).trim();if(!B)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${B});`);Z[z]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function I9($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],_=typeof J.root==="string"?t.resolve(J.root):void 0,z=_??t.dirname(X),B=[],q=(O)=>{if(O&&!B.includes(O))B.push(O)},j=Y.__originalFilePath;if(j)q(t.join(t.dirname(j),"components"));q(Z),q(t.join(t.dirname(X),"components")),q(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let O of H)q(typeof O==="string"?O:null);if(_)q(t.resolve(_,"resources/views/components")),q(t.resolve(_,"resources/components")),q(t.resolve(_,"src/components")),q(t.resolve(_,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return X0(t.resolve(t.dirname(X),`${Q}.stx`));for(let O of B){let V=t.isAbsolute(O)?O:t.resolve(z,O);for(let L of U)if(await X0(t.join(V,L)))return!0}return!1}function vj($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function Z4($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (
|
|
10289
|
+
`)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},U=()=>{if(X!==0)return;let _=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(_){let j=_[2].split(",").map((H)=>{let O=H.trim().split(":");return O[O.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let z=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(z){let j=z[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let q=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(q){let j=q[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(W())continue;if($[J]==="'"||$[J]==='"'){G($[J]);continue}if($[J]==="`"){K();continue}if($[J]==="{"){X++,J++;continue}if($[J]==="}"){X--,J++;continue}if(X===0&&/[a-z]/i.test($[J])&&(J===0||/\s|[;{}()]/.test($[J-1])))U();J++}return Z}function WD($){let Z=[],Y=0,X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(J){if(G==="\\"){Q++;continue}if(G===J)J=null;continue}if(G==='"'||G==="'"||G==="`"){J=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(X,Q)),X=Q+1}if(X<$.length)Z.push($.slice(X));return Z}function UD($){let Z=0,Y=null;for(let X=0;X<$.length;X++){let J=$[X];if(Y){if(J==="\\"){X++;continue}if(J===Y)Y=null;continue}if(J==='"'||J==="'"||J==="`"){Y=J;continue}if(J==="("||J==="["||J==="{")Z++;else if(J===")"||J==="]"||J==="}")Z--;else if(J==="="&&Z===0){let Q=$[X-1],G=$[X+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return X}}return-1}function _D($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let X=Y.index-1;while(X>=0&&/\s/.test($[X]))X--;if($[X]!=="}")return;let J=X,Q=0,G=-1;for(;X>=0;X--){let W=$[X];if(W==="}")Q++;else if(W==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let W of WD(K)){let U=W.trim();if(!U||U.startsWith("..."))continue;let _=UD(U);if(_===-1)continue;let z=U.slice(0,_).trim();if(!/^[A-Z_$][\w$]*$/i.test(z))continue;if(Z[z]!==void 0)continue;let B=U.slice(_+1).trim();if(!B)continue;try{let q=Object.keys(Z),j=Function(...q,`"use strict"; return (${B});`);Z[z]=j(...q.map((H)=>Z[H]))}catch{}}}catch{}}async function I9($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(O)=>O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),K=(O)=>O.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),W=Y.__importedComponents;if(W){for(let O of[Q,Q.toLowerCase(),G(Q),K(Q)])if(W.has(O))return!0}let U=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],_=typeof J.root==="string"?t.resolve(J.root):void 0,z=_??t.dirname(X),B=[],q=(O)=>{if(O&&!B.includes(O))B.push(O)},j=Y.__originalFilePath;if(j)q(t.join(t.dirname(j),"components"));q(Z),q(t.join(t.dirname(X),"components")),q(J.componentsDir);let H=J._pluginComponentDirs;if(Array.isArray(H))for(let O of H)q(typeof O==="string"?O:null);if(_)q(t.resolve(_,"resources/views/components")),q(t.resolve(_,"resources/components")),q(t.resolve(_,"src/components")),q(t.resolve(_,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return X0(t.resolve(t.dirname(X),`${Q}.stx`));for(let O of B){let V=t.isAbsolute(O)?O:t.resolve(z,O);for(let L of U)if(await X0(t.join(V,L)))return!0}return!1}function vj($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function Z4($,Z,Y,X,J,Q,G,K=new Set,W){let{extractVariables:U}=await Promise.resolve().then(() => (s4(),jZ)),_=K??new Set;if(_.has($))return`[Circular component reference: ${$}]`;let z=new Set(_);z.add($);let B=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let q=B&&B!=="load"&&vj(B)?B:"";try{let j=(d)=>d.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(d)=>d.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),O=$.endsWith(".stx")?$.slice(0,-4):$,V=null,L=J.__importedComponents;if(L){let d=[O,O.toLowerCase(),j(O),H(O)];for(let v of d)if(L.has(v)){V=L.get(v);break}}let F=[];if(!V){let d=[`${O}.stx`,`${j(O)}.stx`,`${H(O)}.stx`],v=[...new Set(d)],l=J.__originalFilePath,a=[];if(l){let q0=t.join(t.dirname(l),"components");a.push(q0)}if(X)a.push(X);let i=t.join(t.dirname(Q),"components");if(!a.includes(i))a.push(i);if(G.componentsDir&&G.componentsDir!==X&&!a.includes(G.componentsDir))a.push(G.componentsDir);let Q0=G._pluginComponentDirs;if(Array.isArray(Q0)){for(let q0 of Q0)if(typeof q0==="string"&&!a.includes(q0))a.push(q0)}let E0=typeof G.root==="string"?t.resolve(G.root):void 0,N0=E0??t.dirname(Q),k0=[];if(E0)k0.push(t.resolve(E0,"resources/views/components")),k0.push(t.resolve(E0,"resources/components")),k0.push(t.resolve(E0,"src/components")),k0.push(t.resolve(E0,"components"));k0.push(t.resolve(import.meta.dir,"components"));for(let q0 of k0)if(!a.includes(q0))a.push(q0);let s0=[...new Set(a.map((q0)=>{if(!q0)return q0;return t.isAbsolute(q0)?q0:t.resolve(N0,q0)}))];if(a.length=0,a.push(...s0),O.startsWith("./")||O.startsWith("../"))V=t.resolve(t.dirname(Q),`${O}.stx`),F.push(V);else for(let q0 of a){if(!q0)continue;for(let _4 of v){let z0=t.join(q0,_4);if(F.push(z0),await X0(z0)){V=z0;break}}if(V)break;if(!V)try{let _4=await import("fs");if(!_4.statSync(q0,{throwIfNoEntry:!1})?.isDirectory())continue;let l0=8,Y5=[{path:q0,depth:0}];while(Y5.length>0&&!V){let f1=Y5.pop();if(f1.depth>=l0)continue;let C4;try{C4=_4.readdirSync(f1.path,{withFileTypes:!0})}catch{continue}for(let L0 of C4){if(!L0.isDirectory())continue;if(L0.name==="node_modules"||L0.name.startsWith("."))continue;let q1=t.join(f1.path,L0.name);for(let w1 of v){let b1=t.join(q1,w1);if(F.push(b1),await X0(b1)){V=b1;break}}if(V)break;Y5.push({path:q1,depth:f1.depth+1})}}}catch{}if(V)break}}if(!V||!await X0(V)){let d=F.length>0?`
|
|
10290
10290
|
Searched paths:
|
|
10291
10291
|
${F.map((v)=>` - ${v}`).join(`
|
|
10292
10292
|
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${d}`}W.add(V);let A;if(k7.has(V))A=k7.get(V);else try{A=await Bun.file(V).text(),k7.set(V,A)}catch(d){return`[Error loading component: ${d instanceof Error?d.message:String(d)}]`}let N=new Set(["__originalFilePath","__importedComponents"]),w={};for(let[d,v]of Object.entries(J))if(!d.startsWith("__")||N.has(d))w[d]=v;let{extractSlotContent:R}=await Promise.resolve().then(() => (tZ(),y2)),T=R(Y),E={};if(T.defaultSlot?.trim())E.default=T.defaultSlot;for(let[d,v]of T.namedSlots)E[d]=v.content;let I={...w,...Z,props:Z,slot:Y,$slots:E,__processedComponents:z,__sections:{}};_D(A,I);let k=A,S=k.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(S)k=S[1].trim();let x=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,P=[...A.matchAll(x)],b=[];for(let d of P){let v=d[1]||"",l=d[2]||"",a=v.includes("server");if(x4(v)&&l.trim())l=v4(l);if(a&&l)try{await U(l,I,V)}catch(Q0){}if(!a){let Q0=l.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(Q0.includes("{{")&&Q0.includes("}}"))Q0=j1(Q0,I,V);let E0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");b.push(`<script${E0}>${Q0}</script>`)}}let g=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),s=g?g[1]:"",p=g?g[2]:"",C="",h=s&&/\bscoped\b/i.test(s);if(g)C=`<style${s}>${p}</style>`;let m=k;if(m=m.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),g)m=m.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let d=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(m=m.replace(d,(l,a)=>{let i=a.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(i)v.push(`<style${i[1]}>${i[2]}</style>`);return""}),m=m.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)C=`${C}${v.join(`
|
|
@@ -10333,7 +10333,7 @@ ${j0.yellow}${j0.bold}Message:${j0.reset} ${Z}
|
|
|
10333
10333
|
`,K)_+=`
|
|
10334
10334
|
${j0.blue}${j0.bold}Context:${j0.reset}
|
|
10335
10335
|
${j0.dim}${K}${j0.reset}
|
|
10336
|
-
`;return _}function
|
|
10336
|
+
`;return _}function Y6(){k7.clear()}function BD(){return{size:k7.size,maxSize:500}}var k7,GD=0,j0;var w0=D(()=>{M6();o0();f4();W1();w6();DZ();kj();s4();k7=new i$(500);j0={reset:"\x1B[0m",bold:"\x1B[1m",dim:"\x1B[2m",red:"\x1B[31m",yellow:"\x1B[33m",blue:"\x1B[34m",cyan:"\x1B[36m",gray:"\x1B[90m",bgRed:"\x1B[41m",bgYellow:"\x1B[43m"}});async function k2($,Z,Y=""){let X=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let K=G.index,W=G[0].match(/@markdown\(([^)]*)\)/),U=W?W[1]:"",_=K+G[0].length,z=1,B=_,q=-1;while(z>0&&B<$.length){let O=$.indexOf("@markdown",B),V=$.indexOf("@endmarkdown",B);if(V===-1)break;if(O!==-1&&O<V&&O!==K){let L=$[O+9];if(L==="("||L===`
|
|
10337
10337
|
`||L==="\r"||L===" "||L===void 0)z++;B=O+9}else{if(z--,z===0){q=V;break}B=V+12}}if(q===-1)continue;let j=$.slice(_,q),H=$.slice(K,q+12);J.push({fullMatch:H,options:U,content:j,index:K}),Q.lastIndex=q+12}for(let{fullMatch:K,options:W,content:U,index:_}of J)try{let z={};if(W)W.split(",").forEach((j)=>{let H=j.trim();if(H)z[H]=!0});let B={gfm:z.gfm??!0,breaks:z.breaks??!1},q=g$(U.trim(),B);X=X.split(K).join(q)}catch(z){let B=z instanceof Error?z.message:String(z),q=T0("Markdown Directive",`Error processing markdown: ${B}`,Y,$,_,K);X=X.split(K).join(q)}return X}async function f2($,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}),g$($.trim(),J)}var oZ=D(()=>{w0()});function fj($){if(eZ.set($.name,$),$.client)g2.set($.name,$.client)}function qD($){return eZ.get($)}function jD(){return Array.from(eZ.values())}function HD($){return g2.delete($),eZ.delete($)}function x0($){return fj($),{name:$.name,hasEndTag:$.hasEndTag??!0,description:$.description,handler:async(Y,X,J,Q)=>{let G=LD(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 OD($,Z){let Y=typeof Z==="function"?{mounted:Z}:Z;return g2.set($,Y),Y}function LD($,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 VD(){return[x0({name:"uppercase",description:"Convert content to uppercase",transform:($)=>$.toUpperCase()}),x0({name:"lowercase",description:"Convert content to lowercase",transform:($)=>$.toLowerCase()}),x0({name:"capitalize",description:"Capitalize first letter of content",transform:($)=>$.charAt(0).toUpperCase()+$.slice(1)}),x0({name:"trim",description:"Remove leading and trailing whitespace",transform:($)=>$.trim()}),x0({name:"truncate",description:"Truncate content to specified length",defaults:{length:100,suffix:"..."},transform:($,{length:Z,suffix:Y})=>$.length>Z?$.slice(0,Z)+Y:$}),x0({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>`}),x0({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>`}}),x0({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>`}),x0({name:"tooltip",description:"Add a tooltip to content",defaults:{text:"",position:"top"},hasEndTag:!0,transform:($,{text:Z,position:Y})=>`<span class="stx-tooltip" data-tooltip="${Z}" data-tooltip-position="${Y}" style="position: relative; cursor: help;">${$}</span>`,css:()=>`
|
|
10338
10338
|
.stx-tooltip::after {
|
|
10339
10339
|
content: attr(data-tooltip);
|
|
@@ -10478,7 +10478,7 @@ ${j0.dim}${K}${j0.reset}
|
|
|
10478
10478
|
|
|
10479
10479
|
console.log('[stx] Directive runtime initialized');
|
|
10480
10480
|
})();
|
|
10481
|
-
`}function AD($){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 eZ,g2;var S7=D(()=>{eZ=new Map,g2=new Map});function
|
|
10481
|
+
`}function AD($){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 eZ,g2;var S7=D(()=>{eZ=new Map,g2=new Map});function X6($,Z=J4,Y={},X){return Z.sort((J,Q)=>J-Q).map((J)=>{return`${c1($,{...Y,w:J,fm:X})} ${J}w`}).join(", ")}function h2($,Z=320,Y=2560,X=0.08,J={},Q){let G=$Y(Z,Y,X);return X6($,G,J,Q)}function $Y($,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 x5($,Z,Y=C7,X={},J){return Y.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${c1($,{...X,w:G,dpr:Q,fm:J})} ${Q}x`}).join(", ")}function d2($,Z,Y=C7,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`${c1($,{...J,w:W,q:U,dpr:K,fm:Q})} ${K}x`}).join(", ")}function v5($,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 u2($,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 c1($,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 c2($){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 l2($){let{src:Z,widths:Y,dprValues:X,fixedWidth:J,formats:Q=V4,baseUrl:G="",params:K={}}=$,W=[];for(let U of Q){let _,z;if(J!==void 0&&X)_=x5(Z,J,X,K,U),z=X.map((B)=>({path:"",url:c1(Z,{...K,w:Math.round(J*B),fm:U}),width:Math.round(J*B),height:0,format:U,size:0,dpr:B}));else{let B=Y||J4;_=X6(Z,B,K,U),z=B.map((q)=>({path:"",url:c1(Z,{...K,w:q,fm:U}),width:q,height:0,format:U,size:0}))}W.push({srcset:_,format:U,mimeType:b7[U],variants:z})}return W}function p2($,Z="100vw"){return $.map(({srcset:Y,mimeType:X})=>`<source type="${X}" srcset="${Y}" sizes="${Z}" />`).join(`
|
|
10482
10482
|
`)}function i2($,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 P7($){return b7[$]||"application/octet-stream"}function n2($){return gj[$]||$}function r2($){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 J4,C7,V4,b7,gj,m2;var ZY=D(()=>{J4=[320,480,640,768,1024,1280,1536,1920,2560],C7=[1,1.5,2,3],V4=["avif","webp","jpeg"],b7={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},gj={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};m2={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 a2(){try{return await import("ts-images")}catch{return null}}async function y7($,Z={}){let Y={...YY,...Z},X=await a2();if(X)try{return await ND($,Y,X)}catch(J){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${J}`)}return hj($,Y)}async function ND($,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 hj($,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 s2($){let Z=await a2();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await hj($,{strategy:"thumbhash",width:32,height:32})).dataURL}function o2($){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,z=Math.max(3,_?G?5:7:G?5:7),B=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))),V=Math.max(0,Math.min(255,Math.round((Y-X)*255))),L=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
|
|
10483
10483
|
<rect fill="rgb(${H},${O},${V})" width="32" height="32"/>
|
|
10484
10484
|
</svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(L)}`}async function t2($,Z=20,Y=50){return y7($,{strategy:"blur",width:Z,quality:Y,blurLevel:40})}async function e2($){let Z=await a2();if(Z)try{return(await Z.generatePlaceholder($,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function $Q($,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 x7($,Z,Y={}){let X=Y.transitionDuration||300,J=Y.easing||"ease-out";return`
|
|
@@ -10527,8 +10527,8 @@ ${j0.dim}${K}${j0.reset}
|
|
|
10527
10527
|
filter: blur(0);
|
|
10528
10528
|
transform: scale(1);
|
|
10529
10529
|
}
|
|
10530
|
-
`.trim();f5=new Map});import{createHash as QQ}from"crypto";import{readFile as wD,stat as dj}from"fs/promises";async function e0($){try{let Z=await wD($);return QQ("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function uj($){return QQ("sha256").update($).digest("hex").slice(0,16)}function XY($){return QQ("sha256").update($).digest("hex").slice(0,16)}function h5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${XY($)}-${XY(Y)}`}async function f7($){try{return(await dj($)).mtimeMs}catch{return 0}}async function $1($){try{return await dj($),!0}catch{return!1}}var Q6=()=>{};import{mkdir as RD,readFile as cj,writeFile as MD,readdir as lj,rm as GQ,stat as TD}from"fs/promises";import{join as d5,dirname as ED}from"path";async function ID($){try{await RD($,{recursive:!0})}catch{}}function pj($,Z,Y){return d5($,Y,`${Z}.json`)}async function mj($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await f7(Z)!==$.srcMtime)return!1;return!0}async function u5($,Z,Y,X=g7){if(!X.enabled)return null;let J=h5($,Z),Q=G6.get(J);if(Q){if(await mj(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;G6.delete(J)}let G=pj(X.directory,J,Y);if(await $1(G))try{let K=await cj(G,"utf-8"),W=JSON.parse(K);if(await mj(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),G6.set(J,W),W.data}catch{}return null}async function m5($,Z,Y,X,J=g7){if(!J.enabled)return;let Q=h5($,Z),G=await e0($),K=await f7($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:h5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};G6.set(Q,W);let U=pj(J.directory,Q,X);try{await ID(ED(U)),await MD(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function c5($,Z=g7){if($==="all")G6.clear();else G6.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=d5(Z.directory,X);try{await GQ(J,{recursive:!0,force:!0})}catch{}}}async function ij($=g7){let Z={memoryEntries:G6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=d5($.directory,Y);try{let J=await lj(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=d5(X,Q),K=await TD(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function nj($=g7){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=d5($.directory,X);try{let Q=await lj(J);for(let G of Q){let K=d5(J,G);try{let W=await cj(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await GQ(K),G6.delete(U.key),Z++}catch{await GQ(K).catch(()=>{}),Z++}}}catch{}}return Z}var G6,g7;var JY=D(()=>{Q6();G6=new Map,g7={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class l5{config;constructor($={}){this.config={...DD,...$}}async get($,Z){return u5($,Z,"image",this.config)}async set($,Z,Y){return m5($,Z,Y,"image",this.config)}async clear(){return c5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function KQ($){if(!QY)QY=new l5($);else if($)QY.updateConfig($);return QY}async function p5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return KQ(X).get($,Z)}async function i5($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return KQ(J).set($,Z,Y)}async function WQ(){return KQ().clear()}var DD,QY=null;var UQ=D(()=>{JY();DD={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as kD,basename as SD,extname as CD,join as bD}from"path";import{mkdir as PD}from"fs/promises";async function _Q(){try{return await import("ts-images")}catch{return null}}function rj($){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 yD($,Z){let Y=Z?rj(Z):rj("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 zQ($,Z,Y){let X=await _Q();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await p5($,Z,Y);if(J)return J;try{let Q=kD($);if(!await $1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=yD(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await PD(K,{recursive:!0});let U=await e0(Q),_=SD($,CD($)),z=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await h7(Q,Z.transformations,X);for(let j of z){let H=G[j]||{},O=`${_}-${U}.${j}`,V=bD(K,O);try{let L=await X.optimizeImage({input:q||Q,output:V,format:j,quality:H.quality,progressive:H.progressive});if(L){if(B.variants.push({path:V,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!B.originalWidth&&L.width)B.originalWidth=L.width,B.originalHeight=L.height}}catch(L){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);B.placeholder=j.dataUrl}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await i5($,Z,B,Y),B}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function BQ($,Z,Y,X){let J=await _Q();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 h7($,Z,Y){let X=Y||await _Q();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 aj=D(()=>{Q6();UQ()});import{resolve as xD,basename as vD,extname as fD,join as gD}from"path";import{mkdir as hD}from"fs/promises";async function dD(){try{return await import("ts-images")}catch{return null}}async function GY($,Z,Y){let X=await dD();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=xD($);if(!await $1(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||uD,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await hD(K,{recursive:!0});let U=await e0(J),_=vD($,fD($)),z=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},B={src:$,byFormat:{},srcsets:{}};for(let j of G){B.byFormat[j]=[];let H=[];for(let O of Q){let V=`${_}-${O}w-${U}.${j}`,L=gD(K,V),F=`${W}/${V}`;try{let A=z[j]?.quality||80;if(await $1(L)){B.byFormat[j].push({path:L,url:F,width:O,height:0,format:j,size:0}),H.push(`${F} ${O}w`);continue}let N=await X.processImage({input:J,output:L,format:j,quality:A,resize:{width:O}});if(N)B.byFormat[j].push({path:L,url:F,width:O,height:N.height||Math.round(O*(N.height||1)/(N.width||1)),format:j,size:N.outputSize||0}),H.push(`${F} ${O}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${A}`)}}B.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||mD(Q),B}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function mD($){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 KY($,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 uD;var sj=D(()=>{Q6();uD=[320,480,640,768,1024,1280,1536,1920]});var oj={};e(oj,{setCachedImageResult:()=>i5,processImage:()=>zQ,optimizeImage:()=>BQ,getCachedImageResult:()=>p5,generateSrcset:()=>KY,generateResponsiveVariants:()=>GY,clearImageCache:()=>WQ,applyTransformations:()=>h7,ImageProcessorCache:()=>l5});var qQ=D(()=>{aj();sj();UQ()});async function cD(){try{return await Promise.resolve().then(() => (qQ(),oj))}catch($){if(!tj)console.warn("[stx-media] Image processor not available, some features disabled:",$),tj=!0;return null}}async function K6($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return nD(X,Y)}if(Y.processedResult?.processed)return VQ($,Y.processedResult,Z);if(Y.responsiveVariants)return YH($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=J4,dpr:_,formats:z=V4,quality:B=jQ,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:V=!1,loading:L=V?"eager":UY,decoding:F=WY,fetchpriority:A,objectFit:N,objectPosition:w,crossorigin:R,referrerpolicy:T}=$,E=$.class,I=$.style,k=$.id,S=$.data||{},{isDev:x=!1,baseUrl:P=""}=Z;if(x&&!Z.optimize)return iD($);let b,g,s=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!V)try{b=await v7(J,{strategy:j,...H}),g=x7(s,b,H)}catch{}let p=_!==void 0&&G!==void 0,C;if(p)C=pD($,s,b,Z);else C=await lD($,s,b,Z);let h;if(V){let o=z.includes("webp")?"webp":z[0],B0=J6(J,U,{...q,q:B},o),G0=typeof W==="object"?v5(W):W||"100vw";h=`<link rel="preload" as="image" imagesrcset="${B0}" imagesizes="${G0}" />`}let m=[];if(!ej&&j!=="none")m.push(g5),ej=!0;if(g)m.push(g);let r=O?ZH(s):void 0;return{html:C,preloadLink:h,css:m.length>0?m.join(`
|
|
10531
|
-
`):void 0,script:r}}async function lD($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=J4,formats:_=V4,quality:z=jQ,params:B={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":UY,decoding:O=WY,fetchpriority:V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:N}=$,w=$.class,R=$.style,T=$.data||{},E=typeof W==="object"?v5(W):W||"100vw",I=[];for(let x of _){let P=
|
|
10530
|
+
`.trim();f5=new Map});import{createHash as QQ}from"crypto";import{readFile as wD,stat as dj}from"fs/promises";async function e0($){try{let Z=await wD($);return QQ("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function uj($){return QQ("sha256").update($).digest("hex").slice(0,16)}function XY($){return QQ("sha256").update($).digest("hex").slice(0,16)}function h5($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${XY($)}-${XY(Y)}`}async function f7($){try{return(await dj($)).mtimeMs}catch{return 0}}async function $1($){try{return await dj($),!0}catch{return!1}}var J6=()=>{};import{mkdir as RD,readFile as cj,writeFile as MD,readdir as lj,rm as GQ,stat as TD}from"fs/promises";import{join as d5,dirname as ED}from"path";async function ID($){try{await RD($,{recursive:!0})}catch{}}function pj($,Z,Y){return d5($,Y,`${Z}.json`)}async function mj($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await f7(Z)!==$.srcMtime)return!1;return!0}async function u5($,Z,Y,X=g7){if(!X.enabled)return null;let J=h5($,Z),Q=Q6.get(J);if(Q){if(await mj(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;Q6.delete(J)}let G=pj(X.directory,J,Y);if(await $1(G))try{let K=await cj(G,"utf-8"),W=JSON.parse(K);if(await mj(W,$,X.maxAge))return W.lastAccessedAt=Date.now(),Q6.set(J,W),W.data}catch{}return null}async function m5($,Z,Y,X,J=g7){if(!J.enabled)return;let Q=h5($,Z),G=await e0($),K=await f7($),W={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:h5("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};Q6.set(Q,W);let U=pj(J.directory,Q,X);try{await ID(ED(U)),await MD(U,JSON.stringify(W,null,2))}catch(_){console.warn(`[stx-media] Failed to write cache: ${_}`)}}async function c5($,Z=g7){if($==="all")Q6.clear();else Q6.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=d5(Z.directory,X);try{await GQ(J,{recursive:!0,force:!0})}catch{}}}async function ij($=g7){let Z={memoryEntries:Q6.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=d5($.directory,Y);try{let J=await lj(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=d5(X,Q),K=await TD(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function nj($=g7){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=d5($.directory,X);try{let Q=await lj(J);for(let G of Q){let K=d5(J,G);try{let W=await cj(K,"utf-8"),U=JSON.parse(W);if(Date.now()-U.createdAt>Y)await GQ(K),Q6.delete(U.key),Z++}catch{await GQ(K).catch(()=>{}),Z++}}}catch{}}return Z}var Q6,g7;var JY=D(()=>{J6();Q6=new Map,g7={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class l5{config;constructor($={}){this.config={...DD,...$}}async get($,Z){return u5($,Z,"image",this.config)}async set($,Z,Y){return m5($,Z,Y,"image",this.config)}async clear(){return c5("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function KQ($){if(!QY)QY=new l5($);else if($)QY.updateConfig($);return QY}async function p5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return KQ(X).get($,Z)}async function i5($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return KQ(J).set($,Z,Y)}async function WQ(){return KQ().clear()}var DD,QY=null;var UQ=D(()=>{JY();DD={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as kD,basename as SD,extname as CD,join as bD}from"path";import{mkdir as PD}from"fs/promises";async function _Q(){try{return await import("ts-images")}catch{return null}}function rj($){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 yD($,Z){let Y=Z?rj(Z):rj("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 zQ($,Z,Y){let X=await _Q();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await p5($,Z,Y);if(J)return J;try{let Q=kD($);if(!await $1(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=yD(Y,Z.preset),K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await PD(K,{recursive:!0});let U=await e0(Q),_=SD($,CD($)),z=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],B={src:$,processed:!0,variants:[],hash:U},q=null;if(Z.transformations&&Z.transformations.length>0)q=await h7(Q,Z.transformations,X);for(let j of z){let H=G[j]||{},O=`${_}-${U}.${j}`,V=bD(K,O);try{let L=await X.optimizeImage({input:q||Q,output:V,format:j,quality:H.quality,progressive:H.progressive});if(L){if(B.variants.push({path:V,url:`${W}/${O}`,width:L.width||0,height:L.height||0,format:j,size:L.outputSize||0}),!B.originalWidth&&L.width)B.originalWidth=L.width,B.originalHeight=L.height}}catch(L){B.errors=B.errors||[],B.errors.push(`Failed to optimize ${j}: ${L}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);B.placeholder=j.dataUrl}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});B.dominantColor=j.dominantColor}catch(j){B.errors=B.errors||[],B.errors.push(`Failed to extract dominant color: ${j}`)}return await i5($,Z,B,Y),B}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function BQ($,Z,Y,X){let J=await _Q();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 h7($,Z,Y){let X=Y||await _Q();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 aj=D(()=>{J6();UQ()});import{resolve as xD,basename as vD,extname as fD,join as gD}from"path";import{mkdir as hD}from"fs/promises";async function dD(){try{return await import("ts-images")}catch{return null}}async function GY($,Z,Y){let X=await dD();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=xD($);if(!await $1(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||uD,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",W=Y.baseUrl||"/images";await hD(K,{recursive:!0});let U=await e0(J),_=vD($,fD($)),z=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},B={src:$,byFormat:{},srcsets:{}};for(let j of G){B.byFormat[j]=[];let H=[];for(let O of Q){let V=`${_}-${O}w-${U}.${j}`,L=gD(K,V),F=`${W}/${V}`;try{let A=z[j]?.quality||80;if(await $1(L)){B.byFormat[j].push({path:L,url:F,width:O,height:0,format:j,size:0}),H.push(`${F} ${O}w`);continue}let N=await X.processImage({input:J,output:L,format:j,quality:A,resize:{width:O}});if(N)B.byFormat[j].push({path:L,url:F,width:O,height:N.height||Math.round(O*(N.height||1)/(N.width||1)),format:j,size:N.outputSize||0}),H.push(`${F} ${O}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${O}w: ${A}`)}}B.srcsets[j]=H.join(", ")}let q=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(q!=="none")try{if(q==="thumbhash"){let j=await X.generateThumbHash(J);B.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:q,width:20});B.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:q}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return B.sizes=Z.sizes||mD(Q),B}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function mD($){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 KY($,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 uD;var sj=D(()=>{J6();uD=[320,480,640,768,1024,1280,1536,1920]});var oj={};e(oj,{setCachedImageResult:()=>i5,processImage:()=>zQ,optimizeImage:()=>BQ,getCachedImageResult:()=>p5,generateSrcset:()=>KY,generateResponsiveVariants:()=>GY,clearImageCache:()=>WQ,applyTransformations:()=>h7,ImageProcessorCache:()=>l5});var qQ=D(()=>{aj();sj();UQ()});async function cD(){try{return await Promise.resolve().then(() => (qQ(),oj))}catch($){if(!tj)console.warn("[stx-media] Image processor not available, some features disabled:",$),tj=!0;return null}}async function G6($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return nD(X,Y)}if(Y.processedResult?.processed)return VQ($,Y.processedResult,Z);if(Y.responsiveVariants)return YH($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=J4,dpr:_,formats:z=V4,quality:B=jQ,params:q={},placeholder:j="none",placeholderOptions:H={},lazy:O=!0,priority:V=!1,loading:L=V?"eager":UY,decoding:F=WY,fetchpriority:A,objectFit:N,objectPosition:w,crossorigin:R,referrerpolicy:T}=$,E=$.class,I=$.style,k=$.id,S=$.data||{},{isDev:x=!1,baseUrl:P=""}=Z;if(x&&!Z.optimize)return iD($);let b,g,s=k||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!V)try{b=await v7(J,{strategy:j,...H}),g=x7(s,b,H)}catch{}let p=_!==void 0&&G!==void 0,C;if(p)C=pD($,s,b,Z);else C=await lD($,s,b,Z);let h;if(V){let o=z.includes("webp")?"webp":z[0],B0=X6(J,U,{...q,q:B},o),G0=typeof W==="object"?v5(W):W||"100vw";h=`<link rel="preload" as="image" imagesrcset="${B0}" imagesizes="${G0}" />`}let m=[];if(!ej&&j!=="none")m.push(g5),ej=!0;if(g)m.push(g);let r=O?ZH(s):void 0;return{html:C,preloadLink:h,css:m.length>0?m.join(`
|
|
10531
|
+
`):void 0,script:r}}async function lD($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:W,widths:U=J4,formats:_=V4,quality:z=jQ,params:B={},lazy:q=!0,priority:j=!1,loading:H=j?"eager":UY,decoding:O=WY,fetchpriority:V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:N}=$,w=$.class,R=$.style,T=$.data||{},E=typeof W==="object"?v5(W):W||"100vw",I=[];for(let x of _){let P=X6(J,U,{...B,q:z},x),b=P7(x);if(q&&!j)I.push(` <source type="${b}" data-srcset="${P}" data-sizes="${E}" />`);else I.push(` <source type="${b}" srcset="${P}" sizes="${E}" />`)}let k=HQ({src:c1(J,{...B,q:z}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:O,fetchpriority:j?"high":V,objectFit:L,objectPosition:F,crossorigin:A,referrerpolicy:N,className:$H(w,Y),style:OQ(R,L,F,Y),lazy:q&&!j,data:T}),S;if(Y){let x=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;S=`<div id="${Z}" class="stx-img-placeholder" style="${x}">
|
|
10532
10532
|
<picture>
|
|
10533
10533
|
${I.join(`
|
|
10534
10534
|
`)}
|
|
@@ -10577,7 +10577,7 @@ ${I.join(`
|
|
|
10577
10577
|
|
|
10578
10578
|
observer.observe(container);
|
|
10579
10579
|
})();
|
|
10580
|
-
`.trim()}function _Y($){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,z=W??U??_??!0;if(G===":"&&typeof z==="string")try{X[K]=JSON.parse(z)}catch{X[K]=z}else switch(K){case"src":X.src=String(z);break;case"alt":X.alt=String(z);break;case"width":X.width=Number(z)||z;break;case"height":X.height=Number(z)||z;break;case"sizes":X.sizes=String(z);break;case"quality":X.quality=Number(z);break;case"placeholder":X.placeholder=z;break;case"lazy":X.lazy=z===!0||z==="true";break;case"priority":X.priority=z===!0||z==="true";break;case"class":X.class=String(z);break;case"style":X.style=String(z);break;case"id":X.id=String(z);break;case"loading":X.loading=z;break;case"decoding":X.decoding=z;break;case"fetchpriority":X.fetchpriority=z;break;case"objectFit":X.objectFit=z;break;case"objectPosition":X.objectPosition=String(z);break;case"crossorigin":X.crossorigin=z;break}}if(!X.src||!X.alt)return null;return X}async function LQ($,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],z=_Y(_);if(z){let B=await
|
|
10580
|
+
`.trim()}function _Y($){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,z=W??U??_??!0;if(G===":"&&typeof z==="string")try{X[K]=JSON.parse(z)}catch{X[K]=z}else switch(K){case"src":X.src=String(z);break;case"alt":X.alt=String(z);break;case"width":X.width=Number(z)||z;break;case"height":X.height=Number(z)||z;break;case"sizes":X.sizes=String(z);break;case"quality":X.quality=Number(z);break;case"placeholder":X.placeholder=z;break;case"lazy":X.lazy=z===!0||z==="true";break;case"priority":X.priority=z===!0||z==="true";break;case"class":X.class=String(z);break;case"style":X.style=String(z);break;case"id":X.id=String(z);break;case"loading":X.loading=z;break;case"decoding":X.decoding=z;break;case"fetchpriority":X.fetchpriority=z;break;case"objectFit":X.objectFit=z;break;case"objectPosition":X.objectPosition=String(z);break;case"crossorigin":X.crossorigin=z;break}}if(!X.src||!X.alt)return null;return X}async function LQ($,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],z=_Y(_);if(z){let B=await G6(z,Z);if(G=G.replace(_,B.html),B.preloadLink)X.push(B.preloadLink);if(B.css)J.push(B.css);if(B.script)Q.push(B.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function nD($,Z){let Y=await cD();if(!Y)return G6({...$,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 YH($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return VQ($,Q,Z)}return G6({...$,process:!1},Z)}async function VQ($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:W,objectPosition:U,crossorigin:_,referrerpolicy:z}=$,B=$.class,q=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,H=$.data||{},O=Z.variants||[],V=O.find((g)=>g.format==="jpeg")||O.find((g)=>g.format==="webp")||O[0],L=V?.url||$.src,F=O.filter((g)=>g.format===(V?.format||"jpeg")).map((g)=>`${g.url} ${g.width}w`).join(", "),A=new Map;for(let g of O){if(!A.has(g.format))A.set(g.format,[]);A.get(g.format).push(g)}let N=[],w=["avif","webp","jpeg","png"];for(let g of w){let s=A.get(g);if(s&&s.length>0){let p=s.map((h)=>`${h.url} ${h.width}w`).join(", "),C=P7(g);if(G&&!K)N.push(` <source type="${C}" data-srcset="${p}" />`);else N.push(` <source type="${C}" srcset="${p}" />`)}}let R=[];if(G&&!K){if(R.push(`data-src="${l1(L)}"`),R.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),F)R.push(`data-srcset="${F}"`)}else if(R.push(`src="${l1(L)}"`),F)R.push(`srcset="${F}"`);R.push(`alt="${l1(X)}"`);let T=J||Z.originalWidth,E=Q||Z.originalHeight;if(T)R.push(`width="${T}"`);if(E)R.push(`height="${E}"`);if(!K)R.push(`loading="${G?"lazy":"eager"}"`);if(R.push('decoding="async"'),K)R.push('fetchpriority="high"');if(_)R.push(`crossorigin="${_}"`);if(z)R.push(`referrerpolicy="${z}"`);let I=[];if(W)I.push(`object-fit: ${W}`);if(U)I.push(`object-position: ${U}`);if(Z.placeholder&&G)I.push("opacity: 0; transition: opacity 300ms ease-out");if(q)I.push(q);if(I.length>0)R.push(`style="${I.join("; ")}"`);let k=[];if(B)k.push(B);if(Z.placeholder)k.push("stx-img-blur");if(k.length>0)R.push(`class="${k.join(" ")}"`);if(G&&!K)R.push("data-stx-lazy");for(let[g,s]of Object.entries(H))R.push(`data-${g}="${l1(s)}"`);let S;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let g=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;S=`<div id="${j}" class="stx-img-placeholder" style="${g}">
|
|
10581
10581
|
<picture>
|
|
10582
10582
|
${N.join(`
|
|
10583
10583
|
`)}
|
|
@@ -10588,11 +10588,11 @@ ${N.join(`
|
|
|
10588
10588
|
`)}
|
|
10589
10589
|
<img ${R.join(" ")} />
|
|
10590
10590
|
</picture>`;let x=[];if(Z.placeholder)x.push(g5);let P=G?ZH(j):void 0,b;if(K&&F)b=`<link rel="preload" as="image" imagesrcset="${F}" />`;return{html:S,preloadLink:b,css:x.length>0?x.join(`
|
|
10591
|
-
`):void 0,script:P}}async function YH($,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 VQ($,X,Y)}var tj=!1,jQ=80,WY="async",UY="lazy",ej=!1;var FQ=D(()=>{ZY();JQ()});function zY(){return x0({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}=rD($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||J4,formats:G.formats||V4,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
|
|
10591
|
+
`):void 0,script:P}}async function YH($,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 VQ($,X,Y)}var tj=!1,jQ=80,WY="async",UY="lazy",ej=!1;var FQ=D(()=>{ZY();JQ()});function zY(){return x0({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}=rD($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||J4,formats:G.formats||V4,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 G6(K,{isDev:W}),_=U.html;if(U.preloadLink)_=U.preloadLink+`
|
|
10592
10592
|
`+_;if(U.css)_+=`
|
|
10593
10593
|
<style>${U.css}</style>`;if(U.script)_+=`
|
|
10594
|
-
<script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function rD($,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=aD(X),Q=AQ(J[0],Y)||"",G=AQ(J[1],Y)||"",K={};if(J[2]){let W=AQ(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 aD($){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 AQ($,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 d7;var NQ=D(()=>{S7();FQ();ZY();d7=zY()});class n5{config;constructor($={}){this.config={...sD,...$}}async get($,Z){return u5($,Z,"video",this.config)}async set($,Z,Y){return m5($,Z,Y,"video",this.config)}async clear(){return c5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function wQ($){if(!BY)BY=new n5($);else if($)BY.updateConfig($);return BY}async function r5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return wQ(X).get($,Z)}async function a5($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return wQ(J).set($,Z,Y)}async function qY(){return wQ().clear()}var sD,BY=null;var RQ=D(()=>{JY();sD={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as MQ,basename as TQ,extname as EQ,join as jY}from"path";import{mkdir as IQ}from"fs/promises";async function DQ(){try{return await import("ts-videos")}catch{return null}}async function s5($,Z,Y,X){let J=await DQ();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=MQ($);if(!await $1(Q))return null;await IQ(Y,{recursive:!0});let G=await e0(Q),K=TQ($,EQ($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,z=jY(Y,_),B=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(B&&B.length>0){let q=B[0];return{path:z,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 o5($,Z,Y,X){let J=await DQ();if(!J)return[];try{let Q=MQ($);if(!await $1(Q))return[];await IQ(Y,{recursive:!0});let G=await e0(Q),K=TQ($,EQ($)),W=Z.format||"webp",z=(await new J.Input(Q).getInfo()).duration||60,B=Z.count||10,q=Z.interval||z/B,j=[];for(let O=0;O<B&&O*q<z;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,V)=>({path:O.path||jY(Y,`${K}-thumb-${G}-${V}.${W}`),url:`${X}/${K}-thumb-${G}-${V}.${W}`,width:O.width||Z.width||320,height:O.height||180,timestamp:j[V],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function HY($,Z,Y,X){let J=await DQ();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=MQ($);if(!await $1(Q))return null;await IQ(Y,{recursive:!0});let G=await e0(Q),K=TQ($,EQ($)),_=(await new J.Input(Q).getInfo()).duration||60,z=Z.columns||10,B=Z.interval||5,q=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",O=Math.ceil(_/B),V=Math.ceil(O/z),L=`${K}-sprite-${G}.${H}`,F=jY(Y,L),A=[];for(let w=0;w<O;w++)A.push(w*B);let N=await J.extractThumbnails(Q,{timestamps:A,width:q,height:j,format:H,quality:Z.quality||70,outputDir:jY(Y,".temp")});if(!N||N.length===0)return null;try{let w=await import("ts-images"),R=z*q,T=V*j,E=await w.createSprite({images:N.map((I)=>I.path),columns:z,padding:0,outputPath:F,format:H,quality:Z.quality||70});return{url:`${X}/${L}`,path:F,columns:z,rows:V,thumbnailWidth:q,thumbnailHeight:j,interval:B,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 kQ=D(()=>{
|
|
10595
|
-
`)}async function e5($,Z,Y,X,J){let Q=await WH();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=JH($);if(!await $1(G))return null;let K=await e0(G),W=QH($,GH($)),U=
|
|
10594
|
+
<script>${U.script}</script>`;return _},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function rD($,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=aD(X),Q=AQ(J[0],Y)||"",G=AQ(J[1],Y)||"",K={};if(J[2]){let W=AQ(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 aD($){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 AQ($,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 d7;var NQ=D(()=>{S7();FQ();ZY();d7=zY()});class n5{config;constructor($={}){this.config={...sD,...$}}async get($,Z){return u5($,Z,"video",this.config)}async set($,Z,Y){return m5($,Z,Y,"video",this.config)}async clear(){return c5("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function wQ($){if(!BY)BY=new n5($);else if($)BY.updateConfig($);return BY}async function r5($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return wQ(X).get($,Z)}async function a5($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return wQ(J).set($,Z,Y)}async function qY(){return wQ().clear()}var sD,BY=null;var RQ=D(()=>{JY();sD={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as MQ,basename as TQ,extname as EQ,join as jY}from"path";import{mkdir as IQ}from"fs/promises";async function DQ(){try{return await import("ts-videos")}catch{return null}}async function s5($,Z,Y,X){let J=await DQ();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=MQ($);if(!await $1(Q))return null;await IQ(Y,{recursive:!0});let G=await e0(Q),K=TQ($,EQ($)),W=Z.format||"webp",U=Z.timestamp||0,_=`${K}-poster-${G}.${W}`,z=jY(Y,_),B=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(B&&B.length>0){let q=B[0];return{path:z,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 o5($,Z,Y,X){let J=await DQ();if(!J)return[];try{let Q=MQ($);if(!await $1(Q))return[];await IQ(Y,{recursive:!0});let G=await e0(Q),K=TQ($,EQ($)),W=Z.format||"webp",z=(await new J.Input(Q).getInfo()).duration||60,B=Z.count||10,q=Z.interval||z/B,j=[];for(let O=0;O<B&&O*q<z;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,V)=>({path:O.path||jY(Y,`${K}-thumb-${G}-${V}.${W}`),url:`${X}/${K}-thumb-${G}-${V}.${W}`,width:O.width||Z.width||320,height:O.height||180,timestamp:j[V],size:O.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function HY($,Z,Y,X){let J=await DQ();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=MQ($);if(!await $1(Q))return null;await IQ(Y,{recursive:!0});let G=await e0(Q),K=TQ($,EQ($)),_=(await new J.Input(Q).getInfo()).duration||60,z=Z.columns||10,B=Z.interval||5,q=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",O=Math.ceil(_/B),V=Math.ceil(O/z),L=`${K}-sprite-${G}.${H}`,F=jY(Y,L),A=[];for(let w=0;w<O;w++)A.push(w*B);let N=await J.extractThumbnails(Q,{timestamps:A,width:q,height:j,format:H,quality:Z.quality||70,outputDir:jY(Y,".temp")});if(!N||N.length===0)return null;try{let w=await import("ts-images"),R=z*q,T=V*j,E=await w.createSprite({images:N.map((I)=>I.path),columns:z,padding:0,outputPath:F,format:H,quality:Z.quality||70});return{url:`${X}/${L}`,path:F,columns:z,rows:V,thumbnailWidth:q,thumbnailHeight:j,interval:B,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 kQ=D(()=>{J6()});import{resolve as JH,basename as QH,extname as GH,join as f6}from"path";import{mkdir as OY,writeFile as KH}from"fs/promises";async function WH(){try{return await import("ts-videos")}catch{return null}}async function t5($,Z,Y,X,J){let Q=await WH();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=JH($);if(!await $1(G))return null;let K=await e0(G),W=QH($,GH($)),U=f6(Y,`${W}-${K}-hls`);await OY(U,{recursive:!0});let _=Z.length>0?Z:UH,z=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],O=0;for(let F of _){let A=f6(U,F.label);await OY(A,{recursive:!0});let N=`${F.label}.m3u8`,w=f6(A,N);try{let R=await Q.generateHLS(G,{outputDir:A,segmentDuration:z,width:F.width,height:F.height,videoBitrate:F.bitrate,audioBitrate:F.audioBitrate,playlistName:F.label});if(R)H.push({quality:F,url:`${X}/${W}-${K}-hls/${F.label}/${N}`,path:w}),O+=R.segmentCount||Math.ceil(j/z)}catch(R){console.warn(`[stx-media] Failed to generate HLS for ${F.label}: ${R}`)}}if(H.length===0)return null;let V=f6(U,"master.m3u8"),L=oD(H,X,W,K);return await KH(V,L),{manifestUrl:`${X}/${W}-${K}-hls/master.m3u8`,manifestPath:V,playlists:H,segmentCount:O,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function oD($,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(`
|
|
10595
|
+
`)}async function e5($,Z,Y,X,J){let Q=await WH();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=JH($);if(!await $1(G))return null;let K=await e0(G),W=QH($,GH($)),U=f6(Y,`${W}-${K}-dash`);await OY(U,{recursive:!0});let _=Z.length>0?Z:UH,z=J?.segmentDuration||4,B=J?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,O=[],V=[];for(let N of _){let w=f6(U,N.label);await OY(w,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:w,segmentDuration:z,width:N.width,height:N.height,videoBitrate:N.bitrate,audioBitrate:N.audioBitrate})){if(O.push({bandwidth:N.bitrate,width:N.width,height:N.height||Math.round(N.width*9/16),url:`${X}/${W}-${K}-dash/${N.label}/video`}),N.audioBitrate)V.push({bandwidth:N.audioBitrate,url:`${X}/${W}-${K}-dash/${N.label}/audio`})}}catch(R){console.warn(`[stx-media] Failed to generate DASH for ${N.label}: ${R}`)}}if(O.length===0)return null;let L=f6(U,"manifest.mpd"),F=tD(O,V,H,z,B);await KH(L,F);let A=[{type:"video",representations:O}];if(V.length>0)A.push({type:"audio",representations:V});return{manifestUrl:`${X}/${W}-${K}-dash/manifest.mpd`,manifestPath:L,adaptationSets:A,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function tD($,Z,Y,X,J){let Q=XH(Y),G=XH(J),K=`<?xml version="1.0" encoding="UTF-8"?>
|
|
10596
10596
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
10597
10597
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
10598
10598
|
xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
|
|
@@ -10618,7 +10618,7 @@ ${N.join(`
|
|
|
10618
10618
|
</Representation>
|
|
10619
10619
|
`}K+=` </AdaptationSet>
|
|
10620
10620
|
`}return K+=` </Period>
|
|
10621
|
-
</MPD>`,K}function XH($){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 UH;var SQ=D(()=>{
|
|
10621
|
+
</MPD>`,K}function XH($){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 UH;var SQ=D(()=>{J6();UH=[{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 _H,basename as eD,extname as $k,join as Zk}from"path";import{mkdir as Yk}from"fs/promises";async function zH(){try{return await import("ts-videos")}catch{return null}}function Xk($){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 Jk($){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 u7($){let Z=await zH();if(!Z)return null;try{let Y=_H($),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 LY($,Z,Y,X){let J=await zH();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await r5($,Z,Y);if(Q)return Q;try{let G=_H($);if(!await $1(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",W=Y.baseUrl||"/videos";await Yk(K,{recursive:!0});let U=await e0(G),_=eD($,$k($)),z={src:$,processed:!0,hash:U};X?.({percentage:5,stage:"analyzing"}),z.metadata=await u7(G)||void 0;let B={};if(Z.quality)B.bitrate=Xk(Z.quality);if(Z.platform)Object.assign(B,Jk(Z.platform));if(Z.transcode)Object.assign(B,Z.transcode);if(Object.keys(B).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let q=`${_}-${U}.mp4`,j=Zk(K,q);try{let H=await Qk(G,j,B,J,(O)=>X?.({percentage:10+O*0.5,stage:"transcoding"}));if(H)z.transcoded={path:j,url:`${W}/${q}`,duration:H.duration,size:H.size,video:{codec:B.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:B.audioCodec||"aac",bitrate:B.audioBitrate||128000,sampleRate:B.sampleRate||48000,channels:B.channels||2}:void 0}}catch(H){z.errors=z.errors||[],z.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 s5(G,q,K,W);if(j)z.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let q=await o5(G,Y.thumbnails,K,W);if(q.length>0)z.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 t5(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)z.streaming={...z.streaming,hls:j}}if(q.format==="dash"){let j=await e5(G,q.qualities||Y.streaming?.defaultQualities||[],K,W);if(j)z.streaming={...z.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await a5($,Z,z,Y),z}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function Qk($,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 BH=D(()=>{J6();RQ();kQ();SQ()});var qH={};e(qH,{setCachedVideoResult:()=>a5,processVideo:()=>LY,getCachedVideoResult:()=>r5,generateThumbnails:()=>o5,generateSpriteSheet:()=>HY,generatePoster:()=>s5,generateHLSManifest:()=>t5,generateDASHManifest:()=>e5,clearVideoCache:()=>qY,analyzeVideo:()=>u7,VideoProcessorCache:()=>n5});var CQ=D(()=>{BH();kQ();SQ();RQ()});async function HH(){try{return await Promise.resolve().then(() => (CQ(),qH))}catch($){if(!jH)console.warn("[stx-media] Video processor not available, some features disabled:",$),jH=!0;return null}}async function $$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return zk(X,Y)}if(Y.processedResult?.processed)return AH($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await Bk(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:W,controls:U=OH,autoplay:_=!1,muted:z=!1,loop:B=!1,preload:q=LH,playsinline:j=!0,lazy:H=!0,player:O="native",type:V,width:L,height:F,crossorigin:A,disablePictureInPicture:N=!1,disableRemotePlayback:w=!1}=$,R=J||K,T=$.class,E=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(O==="ts-video")return Wk($,Z);if(V&&V!=="video")return Kk(Q||"",V,$);let k=G.length>0?G:Q?[{src:Q,type:VH(Q)}]:[],S=[`id="${I}"`];if(U)S.push("controls");if(_)S.push("autoplay");if(z)S.push("muted");if(B)S.push("loop");if(j)S.push("playsinline");if(N)S.push("disablepictureinpicture");if(w)S.push("disableremoteplayback");if(A)S.push(`crossorigin="${A}"`);if(H){if(S.push(`data-preload="${q}"`),S.push('preload="none"'),R)S.push(`data-poster="${n0(R)}"`);S.push("data-stx-lazy")}else if(S.push(`preload="${q}"`),R)S.push(`poster="${n0(R)}"`);if(L)S.push(`width="${L}"`);if(F)S.push(`height="${F}"`);if(T)S.push(`class="${n0(T)}"`);if(E)S.push(`style="${n0(E)}"`);let x=k.map((g)=>{return` <source ${H?`data-src="${n0(g.src)}"`:`src="${n0(g.src)}"`} type="${g.type}"${g.media?` media="${g.media}"`:""} />`}).join(`
|
|
10622
10622
|
`),P=`<video ${S.join(" ")}>
|
|
10623
10623
|
${x}
|
|
10624
10624
|
Your browser does not support the video tag.
|
|
@@ -11176,7 +11176,7 @@ catch (error) {
|
|
|
11176
11176
|
init();
|
|
11177
11177
|
}
|
|
11178
11178
|
})();
|
|
11179
|
-
</script>`}var Fk,Ak,Nk,wk,wH;var RH=D(()=>{Fk={name:"pwa.installButton",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Hk($,J)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},Ak={name:"pwa.updatePrompt",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Ok($,J)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},Nk={name:"pwa.offlineIndicator",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Lk($,J)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},wk={name:"pwa.pushSubscribe",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Vk($,J)},hasEndTag:!0,description:"Renders a push notification subscription button"},wH=[Fk,Ak,Nk,wk]});import Rk from"fs";import
|
|
11179
|
+
</script>`}var Fk,Ak,Nk,wk,wH;var RH=D(()=>{Fk={name:"pwa.installButton",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Hk($,J)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},Ak={name:"pwa.updatePrompt",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Ok($,J)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},Nk={name:"pwa.offlineIndicator",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Lk($,J)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},wk={name:"pwa.pushSubscribe",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return Vk($,J)},hasEndTag:!0,description:"Renders a push notification subscription button"},wH=[Fk,Ak,Nk,wk]});import Rk from"fs";import K6 from"path";async function yQ($,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 Mk(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 Mk($,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(K6.isAbsolute(J)&&await X0(J))K=J;else if(Z.componentsDir){let H=K6.join(Z.componentsDir,J);if(await X0(H))K=H}if(!K)K=await D7(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",z=_?Ek({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[],attributeTypes:$.attributeTypes||{}}):Tk({name:X,tag:Q,baseElement:G,source:W,shadowDOM:$.shadowDOM??!0,template:$.template??!0,styleSource:$.styleSource,attributes:$.attributes||[]}),B=Z.webComponents?.outputDir||"dist/web-components";await Rk.promises.mkdir(B,{recursive:!0});let q=_?"ts":"js",j=K6.join(B,`${Q}.${q}`);if(await Bun.write(j,z),Z.debug)console.log(`Built web component ${X} -> ${j}`);return j}function Tk($){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`/**
|
|
11180
11180
|
* ${Z} Web Component
|
|
11181
11181
|
* Auto-generated from stx component
|
|
11182
11182
|
*/
|
|
@@ -12269,9 +12269,9 @@ ${_}
|
|
|
12269
12269
|
}
|
|
12270
12270
|
|
|
12271
12271
|
customElements.define('${Z}', ${G});
|
|
12272
|
-
`}async function vQ($,Z,Y,X){if(Z.length<1)return _0("WebComponent","@webcomponent directive requires at least the tag name parameter",J0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[
|
|
12272
|
+
`}async function vQ($,Z,Y,X){if(Z.length<1)return _0("WebComponent","@webcomponent directive requires at least the tag name parameter",J0.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[K6.join(K6.dirname(X),G,`${J}.stx`),K6.join(process.cwd(),G,`${J}.stx`),K6.join(K6.dirname(X),`${J}.stx`)],W=null;for(let z of K)if(await X0(z)){W=await Bun.file(z).text();break}if(!W)return _0("WebComponent",`Component file not found: ${J}.stx`,J0.FILE_NOT_FOUND);let U=EH(W,J);return`<script type="module">
|
|
12273
12273
|
${IH(U)}
|
|
12274
|
-
</script>`}var xQ;var fQ=D(()=>{M1();w0();xQ={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var DH={};e(DH,{timingPlugin:()=>hk,pluginManager:()=>hQ,definePlugin:()=>Y$,debugPlugin:()=>gk,createVariablesPlugin:()=>dk,createFilterPlugin:()=>fk,createDirectivePlugin:()=>vk,PluginManager:()=>gQ});function Y$($){return $}class gQ{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 vk($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function fk($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function dk($){return Y$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var hQ,gk,hk;var dQ=D(()=>{hQ=new gQ;gk=Y$({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)}}),hk=Y$({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var P3={};e(P3,{validateConfig:()=>CH,loadStxConfig:()=>m0,defineStxConfig:()=>SH,defaultConfig:()=>O1,config:()=>F1});import uQ from"fs";import _1 from"path";import{loadConfigWithResult as uk}from"bunfig";function mk($,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(uQ.existsSync(X)&&uQ.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=_1.join(process.cwd(),"resources","views","pages");if(uQ.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function m0($){if(!$){if(X$)return X$;if(AY)return AY}let Z=$?_1.resolve($):process.cwd(),Y=kH.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await uk({name:"stx",alias:"ui",cwd:Z,defaultConfig:O1,verbose:!1})).config,G=mk(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(() => (dQ(),DH)),W=[],U=[];for(let _ of Q.plugins){let z=typeof _==="string"?_:_[0],B=typeof _==="string"?{}:_[1]||{};try{let q,j;try{q=await import(z),j=_1.dirname($0.resolve(z))}catch{let O=_1.resolve(process.cwd(),z);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),V=B.path||"/";U.push({dir:O,prefix:V})}if(H.setup){let O={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=L},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:j,config:Q};await H.setup(B,O)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(q){console.warn(`[stx] Failed to load plugin ${z}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(kH.set(Z,X),!$)AY=X,X.then((J)=>{X$=J}).catch(()=>{});return X}function SH($){return $}function CH($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!X.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var O1,X$=null,kH,AY=null,F1;var i0=D(()=>{J5();V3();cX();F3();oZ();NQ();PQ();RH();TZ();fQ();O1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:f2,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:vQ,hasEndTag:!1,description:"Include a web component in the template"},B3,q3,RZ,MZ,j3,O3,L3,H3,HU,iX,d7,m7,...wH],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}};kH=new Map;F1=new Proxy(O1,{get($,Z){if(X$&&Z in X$)return X$[Z];if(!AY)m0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import ck from"fs";import mQ from"path";import{createHighlighter as lk}from"ts-syntax-highlighter";async function F4($,Z={}){try{if(!await X0($))throw Error(`Markdown file not found: ${$}`);let X=(await ck.promises.stat($)).mtime.getTime();if(Z.cache&&wY.has($)){let z=wY.get($);if(z.updatedAt>=X)return{content:z.content,data:z.data}}let J=await Bun.file($).text(),{data:Q,content:G}=VU(J),K=Z.markdown||F1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=g$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await pk(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)wY.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:T0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function pk($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!NY)try{NY=await lk({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,_)=>{let z=_.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),B=U||(Y?"text":"");if(!B)return K;try{if(!NY.getSupportedLanguages().includes(B))return K;return(await NY.highlight(z,B,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,_,z]=K,B=await J(W,U,_,z);Q=Q.replace(W,B)}return Q}async function S2($,Z,Y="",X={}){return await ik($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!mQ.isAbsolute(K))_=mQ.resolve(mQ.dirname(Y),K);let z={};if(W)try{try{z=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let F of L){let A=F.indexOf(":");if(A>0){let N=F.substring(0,A).trim(),w=F.substring(A+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),T=w.startsWith("'")&&w.endsWith("'");if(R||T)w=w.substring(1,w.length-1);z[N]=w}}}}catch(V){if(X.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:B,data:q}=await F4(_,X),j={...Z,...q,...z},H=B,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(V,L)=>{let F=L.trim();return j[F]!==void 0?String(j[F]):V}),H}catch(_){let z=_ instanceof Error?_.message:String(_);return T0("Markdown File",`Error including markdown file: ${z}`,Y,$,U,G)}})}async function ik($,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 wY,NY=null;var y5=D(()=>{i0();w0();wY=new Map});function RY(){return`
|
|
12274
|
+
</script>`}var xQ;var fQ=D(()=>{M1();w0();xQ={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var DH={};e(DH,{timingPlugin:()=>hk,pluginManager:()=>hQ,definePlugin:()=>Y$,debugPlugin:()=>gk,createVariablesPlugin:()=>dk,createFilterPlugin:()=>fk,createDirectivePlugin:()=>vk,PluginManager:()=>gQ});function Y$($){return $}class gQ{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 vk($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function fk($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function dk($){return Y$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var hQ,gk,hk;var dQ=D(()=>{hQ=new gQ;gk=Y$({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)}}),hk=Y$({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var P3={};e(P3,{validateConfig:()=>CH,loadStxConfig:()=>m0,defineStxConfig:()=>SH,defaultConfig:()=>O1,config:()=>F1});import uQ from"fs";import _1 from"path";import{loadConfigWithResult as uk}from"bunfig";function mk($,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(uQ.existsSync(X)&&uQ.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=_1.join(process.cwd(),"resources","views","pages");if(uQ.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function m0($){if(!$){if(X$)return X$;if(AY)return AY}let Z=$?_1.resolve($):process.cwd(),Y=kH.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await uk({name:"stx",alias:"ui",cwd:Z,defaultConfig:O1,verbose:!1})).config,G=mk(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(() => (dQ(),DH)),W=[],U=[];for(let _ of Q.plugins){let z=typeof _==="string"?_:_[0],B=typeof _==="string"?{}:_[1]||{};try{let q,j;try{q=await import(z),j=_1.dirname($0.resolve(z))}catch{let O=_1.resolve(process.cwd(),z);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),V=B.path||"/";U.push({dir:O,prefix:V})}if(H.setup){let O={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,L)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=L},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:j,config:Q};await H.setup(B,O)}console.log(`[stx] Plugin loaded: ${H.name||z}`)}catch(q){console.warn(`[stx] Failed to load plugin ${z}:`,q.message)}}Q._pluginComponentDirs=W,Q._pluginPageDirs=U}return Q})();if(kH.set(Z,X),!$)AY=X,X.then((J)=>{X$=J}).catch(()=>{});return X}function SH($){return $}function CH($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let X=["auto","manual","sections"];if(!X.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${X.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let X=["json","yaml","yml","js"];if(!X.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${X.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let X=["AA","AAA"];if(!X.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${X.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let X=["progressive","islands"];if(!X.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${X.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let X=["none","eager","lazy"];if(!X.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${X.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`customDirectives[${J}].name`,message:"Custom directive must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`customDirectives[${J}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((X,J)=>{if(!X.name||typeof X.name!=="string")Z.push({path:`middleware[${J}].name`,message:"Middleware must have a name string",severity:"error"});if(!X.handler||typeof X.handler!=="function")Z.push({path:`middleware[${J}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!X.timing||!["before","after"].includes(X.timing))Z.push({path:`middleware[${J}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let X=["fullscreen","standalone","minimal-ui","browser"];if(!X.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let X=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!X.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.routes){let X=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((J,Q)=>{if(!J.pattern||typeof J.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!X.includes(J.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${X.join(", ")}`,severity:"error"});if(J.maxAgeSeconds!==void 0&&(typeof J.maxAgeSeconds!=="number"||J.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(J.maxEntries!==void 0&&(typeof J.maxEntries!=="number"||J.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((J)=>typeof J!=="number"||J<16||J>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let X=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!X.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${X.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var O1,X$=null,kH,AY=null,F1;var i0=D(()=>{X5();V3();cX();F3();oZ();NQ();PQ();RH();TZ();fQ();O1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:f2,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:vQ,hasEndTag:!1,description:"Include a web component in the template"},B3,q3,RZ,MZ,j3,O3,L3,H3,HU,iX,d7,m7,...wH],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}};kH=new Map;F1=new Proxy(O1,{get($,Z){if(X$&&Z in X$)return X$[Z];if(!AY)m0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import ck from"fs";import mQ from"path";import{createHighlighter as lk}from"ts-syntax-highlighter";async function F4($,Z={}){try{if(!await X0($))throw Error(`Markdown file not found: ${$}`);let X=(await ck.promises.stat($)).mtime.getTime();if(Z.cache&&wY.has($)){let z=wY.get($);if(z.updatedAt>=X)return{content:z.content,data:z.data}}let J=await Bun.file($).text(),{data:Q,content:G}=VU(J),K=Z.markdown||F1.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=g$(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await pk(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let _={content:U,data:Q||{}};if(Z.cache)wY.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:T0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function pk($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!NY)try{NY=await lk({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,W,U,_)=>{let z=_.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),B=U||(Y?"text":"");if(!B)return K;try{if(!NY.getSupportedLanguages().includes(B))return K;return(await NY.highlight(z,B,{theme:Z})).html}catch(q){console.error(`Error highlighting code block with language ${U}:`,q)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[W,U,_,z]=K,B=await J(W,U,_,z);Q=Q.replace(W,B)}return Q}async function S2($,Z,Y="",X={}){return await ik($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,W,U)=>{try{let _=K;if(!mQ.isAbsolute(K))_=mQ.resolve(mQ.dirname(Y),K);let z={};if(W)try{try{z=JSON.parse(W)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let L=W.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let F of L){let A=F.indexOf(":");if(A>0){let N=F.substring(0,A).trim(),w=F.substring(A+1).trim(),R=w.startsWith('"')&&w.endsWith('"'),T=w.startsWith("'")&&w.endsWith("'");if(R||T)w=w.substring(1,w.length-1);z[N]=w}}}}catch(V){if(X.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:B,data:q}=await F4(_,X),j={...Z,...q,...z},H=B,O=/\{\{([^}]+)\}\}/g;return H=H.replace(O,(V,L)=>{let F=L.trim();return j[F]!==void 0?String(j[F]):V}),H}catch(_){let z=_ instanceof Error?_.message:String(_);return T0("Markdown File",`Error including markdown file: ${z}`,Y,$,U,G)}})}async function ik($,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 wY,NY=null;var y5=D(()=>{i0();w0();wY=new Map});function RY(){return`
|
|
12275
12275
|
/* Theme selector for code blocks */
|
|
12276
12276
|
.theme-selector {
|
|
12277
12277
|
margin: 1rem 0;
|
|
@@ -12351,11 +12351,11 @@ else {
|
|
|
12351
12351
|
<span class="frontmatter-label">${Z}:</span>
|
|
12352
12352
|
<span>${Array.isArray(Y)?Y.join(", "):String(Y)}</span>
|
|
12353
12353
|
</div>`).join("")}
|
|
12354
|
-
</div>`}var bH=()=>{};import PH from"net";async function nk($){return new Promise((Z)=>{let Y=PH.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"0.0.0.0")})}async function rk($){return new Promise((Z)=>{let Y=PH.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"::")})}async function ak($){if(!await nk($))return!1;return await rk($)}async function
|
|
12354
|
+
</div>`}var bH=()=>{};import PH from"net";async function nk($){return new Promise((Z)=>{let Y=PH.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"0.0.0.0")})}async function rk($){return new Promise((Z)=>{let Y=PH.createServer();Y.once("error",()=>Z(!1)),Y.once("listening",()=>{Y.close(()=>Z(!0))}),Y.listen($,"::")})}async function ak($){if(!await nk($))return!1;return await rk($)}async function W6($,Z=20){$=Number($);for(let Y=0;Y<Z;Y++){let X=$+Y;if(await ak(X))return X}throw Error(`Could not find an available port between ${$} and ${$+Z-1}`)}var yH=()=>{};async function ok(){try{let $=await import("@stacksjs/desktop");if(typeof $.openDevWindow!=="function")return null;return $}catch{return null}}async function J$($,Z={}){let Y={...sk,...Z},X=await ok();if(!X)return console.log(`${M.yellow}\u26A0${M.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,titlebarHidden:Y.titlebarHidden,nativeSidebar:Y.nativeSidebar,sidebarWidth:Y.sidebarWidth,sidebarConfig:Y.sidebarConfig});if(J&&Y.nativeSidebar)console.log(`${M.green}\u2713${M.reset} Native sidebar enabled (macOS Tahoe style)`);return J}catch(J){return console.log(`${M.red}\u2717${M.reset} Could not open native window:`,J),!1}}function IY($){if($.match(/<Sidebar[\s\S]*?variant=["'](?:tahoe|vibrancy|desktop)["'][\s\S]*?\/>/i)){let J=$.match(/<script\s+server[^>]*>([\s\S]*?)<\/script>/i);if(J){let Q=J[1];try{let G=`
|
|
12355
12355
|
${Q}
|
|
12356
12356
|
return typeof sidebarConfig !== 'undefined' ? sidebarConfig : null;
|
|
12357
12357
|
`,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 sk;var xH=D(()=>{n$();sk={title:"stx Development",width:1400,height:900,darkMode:!0,hotReload:!0,titlebarHidden:!1,nativeSidebar:!1,sidebarWidth:260,sidebarConfig:void 0}});function cQ(){console.log(`
|
|
12358
|
-
Keyboard shortcuts:`),console.log(` ${M.cyan}o${M.reset} + Enter - Open in browser`),console.log(` ${M.cyan}c${M.reset} + Enter - Clear console`),console.log(` ${M.cyan}q${M.reset} + Enter (or ${M.cyan}Ctrl+C${M.reset}) - Quit server`),console.log(` ${M.cyan}h${M.reset} + Enter - Show this help`)}function tk($){console.log(`${M.green}Server running at ${M.cyan}${$}${M.reset}`),console.log(`Press ${M.cyan}Ctrl+C${M.reset} to stop the server`),cQ()}function ek($){console.log(`${M.dim}Opening ${M.cyan}${$}${M.dim} in your browser...${M.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function
|
|
12358
|
+
Keyboard shortcuts:`),console.log(` ${M.cyan}o${M.reset} + Enter - Open in browser`),console.log(` ${M.cyan}c${M.reset} + Enter - Clear console`),console.log(` ${M.cyan}q${M.reset} + Enter (or ${M.cyan}Ctrl+C${M.reset}) - Quit server`),console.log(` ${M.cyan}h${M.reset} + Enter - Show this help`)}function tk($){console.log(`${M.green}Server running at ${M.cyan}${$}${M.reset}`),console.log(`Press ${M.cyan}Ctrl+C${M.reset} to stop the server`),cQ()}function ek($){console.log(`${M.dim}Opening ${M.cyan}${$}${M.dim} in your browser...${M.reset}`),Bun.spawn(["open",$],{stderr:"inherit"})}function U6($,Z,Y){if(!process.stdin.isTTY)return;process.stdin.setRawMode(!0),process.stdin.setEncoding("utf8"),process.stdin.resume(),cQ();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(`
|
|
12359
12359
|
`)){let Q=X.trim().toLowerCase();X="",$S(Q,$,Z,Y)}})}function $S($,Z,Y,X){switch($){case"o":if(X?.onOpen)X.onOpen();else ek(Z);break;case"c":if(X?.onClear)X.onClear();else console.clear(),tk(Z);break;case"q":if(X?.onQuit)X.onQuit();console.log(`${M.yellow}Stopping server...${M.reset}`),Y(),process.exit(0);break;case"h":if(X?.onHelp)X.onHelp();else cQ();break;default:break}}var vH=D(()=>{n$()});var fH=()=>{};var c7=D(()=>{n$();e1();bH();yH();xH();vH();fH()});var{serve:ZS}=globalThis.Bun;import lQ from"fs";import Q$ from"path";async function DY($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Q$.resolve($);if(!lQ.existsSync(J))return console.error(`${M.red}Error: File not found: ${M.bright}${J}${M.reset}`),!1;if(!J.endsWith(".md"))return console.error(`${M.red}Error: File must have .md extension: ${M.bright}${J}${M.reset}`),!1;console.log(`${M.blue}Processing${M.reset} ${M.bright}${$}${M.reset}...`);let Q=null,G=async()=>{try{let{content:z,data:B}=await F4(J,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:F1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),q=Z.markdown?.syntaxHighlighting||F1.markdown?.syntaxHighlighting,j=q?.defaultTheme||"github-dark",H=["github-dark"],O=q?.additionalThemes||[],L=[...new Set([...H,...O])].map((F)=>`<option value="${F}"${F===j?" selected":""}>${F}</option>`).join(`
|
|
12360
12360
|
`);return Q=`
|
|
12361
12361
|
<!DOCTYPE html>
|
|
@@ -12519,12 +12519,12 @@ Keyboard shortcuts:`),console.log(` ${M.cyan}o${M.reset} + Enter - Open in brow
|
|
|
12519
12519
|
</script>
|
|
12520
12520
|
</body>
|
|
12521
12521
|
</html>
|
|
12522
|
-
`,!0}catch(z){return console.error(`${M.red}Error processing Markdown file:${M.reset}`,z),!1}};if(!await G())return!1;let W=Y;try{if(W=await
|
|
12522
|
+
`,!0}catch(z){return console.error(`${M.red}Error processing Markdown file:${M.reset}`,z),!1}};if(!await G())return!1;let W=Y;try{if(W=await W6(Y),W!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${W} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}console.log(`${M.blue}Starting server on ${M.cyan}http://localhost:${W}/${M.reset}...`);let U=ZS({port:W,fetch(z){if(new URL(z.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(z){return new Response(`<pre>${z}
|
|
12523
12523
|
${z.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
12524
12524
|
${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
|
|
12525
12525
|
${M.bright}\u2192 ${M.cyan}http://localhost:${W}/${M.reset}`),console.log(`
|
|
12526
12526
|
${M.yellow}Routes:${M.reset}`);let _=Q$.relative(process.cwd(),J);if(console.log(` ${M.green}\u2514\u2500 /${M.reset} \u2192 ${M.bright}${_}${M.reset}`),console.log(`
|
|
12527
|
-
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),
|
|
12527
|
+
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),U6(U.url.toString(),()=>{if(X)lQ.watch(Q$.dirname(J),{recursive:!0}).close();U.stop()}),Z.native)await J$(W,{title:Q$.basename(J,".md")});if(X){let z=Q$.dirname(J);console.log(`${M.blue}Watching ${M.bright}${z}${M.reset} for changes...`);let B=lQ.watch(z,{recursive:!0},async(q,j)=>{if(j&&j.endsWith(".md"))console.log(`${M.yellow}File ${M.bright}${j}${M.yellow} changed, reprocessing...${M.reset}`),await G()});process.on("SIGINT",()=>{B.close(),U.stop(),process.exit(0)})}return!0}var pQ=D(()=>{y5();i0();c7()});class iQ{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 gH($,Z={}){let{showOverlay:Y=!0,reconnectInterval:X=1000,maxReconnectAttempts:J=10}=Z;return`
|
|
12528
12528
|
<script>
|
|
12529
12529
|
(function() {
|
|
12530
12530
|
// stx Hot Reload Client
|
|
@@ -12717,9 +12717,9 @@ else {
|
|
|
12717
12717
|
};
|
|
12718
12718
|
})();
|
|
12719
12719
|
</script>
|
|
12720
|
-
`}function Q4($,Z,Y={}){let X=gH(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 l7($){let Z=$.toLowerCase();return Z.endsWith(".css")||Z.endsWith(".scss")||Z.endsWith(".sass")||Z.endsWith(".less")}function p7($){let Z=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((X)=>Z.endsWith(X))}function i7($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Y)=>Y.test($))}function n7($){if(!G$)G$=new iQ($);return G$}function K$(){if(G$)G$.stop(),G$=null}var G$=null;function r7($){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 B=Error(`Netlify API error: ${_.status} ${_.statusText}`);B.status=_.status;try{let q=await _.json();B.message=q.message||B.message,B.code=q.code,B.details=q}catch{}throw B}let z=await _.text();if(!z)return{};return JSON.parse(z)}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 z=Error(`Deploy failed: ${_.error_message||"Unknown error"}`);throw z.status=500,z.details=_,z}if(Date.now()-U>G){let z=Error(`Deploy timed out after ${G}ms`);throw z.status=408,z.details=_,z}await new Promise((z)=>setTimeout(z,K))}},async lockDeploy(J){return X("POST",`/deploys/${J}/lock`)},async unlockDeploy(J){return X("POST",`/deploys/${J}/unlock`)}}}async function kY($){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 W$($,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((z)=>{if(z.includes("*"))return new RegExp(`^${z.replace(/\*/g,".*")}$`).test(Q);return Q.includes(z)}))continue;let K=`${$}/${Q}`,U=await Bun.file(K).arrayBuffer(),_=await kY(U);X.push({path:Q,content:new Uint8Array(U),sha1:_})}return X}function a7($){let Z={};for(let Y of $)Z[`/${Y.path}`]=Y.sha1;return Z}function s7($,Z){let Y=new Set(Z.map((X)=>X.startsWith("/")?X.slice(1):X));return $.filter((X)=>Y.has(X.path))}function
|
|
12720
|
+
`}function Q4($,Z,Y={}){let X=gH(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 l7($){let Z=$.toLowerCase();return Z.endsWith(".css")||Z.endsWith(".scss")||Z.endsWith(".sass")||Z.endsWith(".less")}function p7($){let Z=$.toLowerCase();return[".stx",".html",".htm",".md",".js",".ts",".jsx",".tsx",".json"].some((X)=>Z.endsWith(X))}function i7($){return[/^\./,/node_modules/,/\.stx\/output/,/\.stx\/cache/,/~$/,/\.swp$/,/\.swo$/].some((Y)=>Y.test($))}function n7($){if(!G$)G$=new iQ($);return G$}function K$(){if(G$)G$.stop(),G$=null}var G$=null;function r7($){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 B=Error(`Netlify API error: ${_.status} ${_.statusText}`);B.status=_.status;try{let q=await _.json();B.message=q.message||B.message,B.code=q.code,B.details=q}catch{}throw B}let z=await _.text();if(!z)return{};return JSON.parse(z)}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 z=Error(`Deploy failed: ${_.error_message||"Unknown error"}`);throw z.status=500,z.details=_,z}if(Date.now()-U>G){let z=Error(`Deploy timed out after ${G}ms`);throw z.status=408,z.details=_,z}await new Promise((z)=>setTimeout(z,K))}},async lockDeploy(J){return X("POST",`/deploys/${J}/lock`)},async unlockDeploy(J){return X("POST",`/deploys/${J}/unlock`)}}}async function kY($){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 W$($,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((z)=>{if(z.includes("*"))return new RegExp(`^${z.replace(/\*/g,".*")}$`).test(Q);return Q.includes(z)}))continue;let K=`${$}/${Q}`,U=await Bun.file(K).arrayBuffer(),_=await kY(U);X.push({path:Q,content:new Uint8Array(U),sha1:_})}return X}function a7($){let Z={};for(let Y of $)Z[`/${Y.path}`]=Y.sha1;return Z}function s7($,Z){let Y=new Set(Z.map((X)=>X.startsWith("/")?X.slice(1):X));return $.filter((X)=>Y.has(X.path))}function _6($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;if($<1073741824)return`${($/1048576).toFixed(1)} MB`;return`${($/1073741824).toFixed(1)} GB`}function A4($){return $.reduce((Z,Y)=>Z+Y.content.byteLength,0)}import N4 from"fs";import G4 from"path";function SY($){let Z=[];if(Z.push("[build]"),Z.push(` command = "${r0($.build.command)}"`),Z.push(` publish = "${r0($.build.publish)}"`),$.build.functions)Z.push(` functions = "${r0($.build.functions)}"`);if($.build.edge_functions)Z.push(` edge_functions = "${r0($.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} = "${r0(X)}"`)}if($.functions){if(Z.push(""),Z.push("[functions]"),$.functions.directory)Z.push(` directory = "${r0($.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 = "${r0(Y.function)}"`),Z.push(` path = "${r0(Y.path)}"`)}if($.redirects&&$.redirects.length>0){Z.push("");for(let Y of $.redirects){if(Z.push("[[redirects]]"),Z.push(` from = "${r0(Y.from)}"`),Z.push(` to = "${r0(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} = "${r0(J)}"`)}}}if($.headers&&$.headers.length>0){Z.push("");for(let Y of $.headers){Z.push("[[headers]]"),Z.push(` for = "${r0(Y.for)}"`),Z.push(" [headers.values]");for(let[X,J]of Object.entries(Y.values))Z.push(` ${X} = "${r0(J)}"`)}}if($.plugins&&$.plugins.length>0){Z.push("");for(let Y of $.plugins)if(Z.push("[[plugins]]"),Z.push(` package = "${r0(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} = "${r0(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 = "${r0(X.command)}"`);if(X.publish)Z.push(` publish = "${r0(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} = "${r0(Q)}"`)}}return Z.join(`
|
|
12721
12721
|
`)+`
|
|
12722
|
-
`}function r0($){return $.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function U$($){let Z={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},Y=G4.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=G4.join($,"stx.config.ts"),J=G4.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 _=G4.join($,U);if(N4.existsSync(_)&&N4.statSync(_).isDirectory()){Z.outputDir=U;break}}let G=["functions","netlify/functions","api"];for(let U of G){let _=G4.join($,U);if(N4.existsSync(_)&&N4.statSync(_).isDirectory()){Z.functionsDir=U;break}}let K=G4.join($,"netlify","edge-functions");if(N4.existsSync(K))Z.edgeFunctionsDir="netlify/edge-functions";let W=G4.join($,Z.outputDir||"dist");if(N4.existsSync(W)){let U=N4.existsSync(G4.join(W,"index.html")),_=N4.readdirSync(W).filter((z)=>z.endsWith(".html"));Z.isSPA=U&&_.length===1}return Z}function _$($={}){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 o7($,Z){let Y=await U$($),X=Z||_$(Y),J=SY(X),Q=G4.join($,"netlify.toml");return await Bun.write(Q,J),Q}function t7($){return N4.existsSync(G4.join($,"netlify.toml"))}var nQ=()=>{};var uH={};e(uH,{writeNetlifyConfig:()=>o7,initNetlify:()=>dH,hasNetlifyConfig:()=>t7,getTotalSize:()=>A4,generateNetlifyToml:()=>SY,formatSize:()=>
|
|
12722
|
+
`}function r0($){return $.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}async function U$($){let Z={framework:"stx",buildCommand:"bun run build",outputDir:"dist"},Y=G4.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=G4.join($,"stx.config.ts"),J=G4.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 _=G4.join($,U);if(N4.existsSync(_)&&N4.statSync(_).isDirectory()){Z.outputDir=U;break}}let G=["functions","netlify/functions","api"];for(let U of G){let _=G4.join($,U);if(N4.existsSync(_)&&N4.statSync(_).isDirectory()){Z.functionsDir=U;break}}let K=G4.join($,"netlify","edge-functions");if(N4.existsSync(K))Z.edgeFunctionsDir="netlify/edge-functions";let W=G4.join($,Z.outputDir||"dist");if(N4.existsSync(W)){let U=N4.existsSync(G4.join(W,"index.html")),_=N4.readdirSync(W).filter((z)=>z.endsWith(".html"));Z.isSPA=U&&_.length===1}return Z}function _$($={}){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 o7($,Z){let Y=await U$($),X=Z||_$(Y),J=SY(X),Q=G4.join($,"netlify.toml");return await Bun.write(Q,J),Q}function t7($){return N4.existsSync(G4.join($,"netlify.toml"))}var nQ=()=>{};var uH={};e(uH,{writeNetlifyConfig:()=>o7,initNetlify:()=>dH,hasNetlifyConfig:()=>t7,getTotalSize:()=>A4,generateNetlifyToml:()=>SY,formatSize:()=>_6,filterRequiredFiles:()=>s7,detectProjectConfig:()=>U$,deploy:()=>hH,createNetlifyClient:()=>r7,createFileManifest:()=>a7,createDefaultNetlifyConfig:()=>_$,collectDeployFiles:()=>W$,calculateSha1:()=>kY,DeployError:()=>w4});import rQ from"fs";import aQ from"path";async function hH($={}){let Z=Date.now(),Y=[],X=$.cwd||process.cwd(),J=(L)=>{Y.push(L)},Q=(L)=>{if($.onProgress)$.onProgress(L)},G=aQ.resolve(X,$.directory||"dist"),K=$.token||process.env.NETLIFY_AUTH_TOKEN,W=$.siteId||process.env.NETLIFY_SITE_ID;if(!K)throw new w4(`No Netlify auth token found.
|
|
12723
12723
|
|
|
12724
12724
|
To deploy to Netlify:
|
|
12725
12725
|
1. Create account at https://app.netlify.com
|
|
@@ -12737,14 +12737,14 @@ Find your site ID at: https://app.netlify.com/sites/YOUR_SITE/settings/general`,
|
|
|
12737
12737
|
|
|
12738
12738
|
Run \`stx build\` first or specify a different directory with --directory`,"NO_BUILD_DIR");if(!(rQ.readdirSync(G).length>0))throw new w4(`Build directory is empty: ${G}
|
|
12739
12739
|
|
|
12740
|
-
Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if($.dryRun){Q({stage:"collect",message:"Collecting files..."});let L=await W$(G),F=A4(L);return J(`Would deploy ${L.length} files (${
|
|
12740
|
+
Run \`stx build\` to generate files`,"EMPTY_BUILD_DIR");if($.dryRun){Q({stage:"collect",message:"Collecting files..."});let L=await W$(G),F=A4(L);return J(`Would deploy ${L.length} files (${_6(F)})`),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:F}}let _=r7({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 w4(`Site not found: ${W}
|
|
12741
12741
|
|
|
12742
|
-
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 z=await W$(G),B=A4(z);if(J(`Found ${z.length} files (${
|
|
12742
|
+
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 z=await W$(G),B=A4(z);if(J(`Found ${z.length} files (${_6(B)})`),z.length===0)throw new w4(`No files found in ${G}`,"NO_FILES");let q=a7(z);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=s7(z,j.required||[]);if(J(`Uploading ${H.length} files...`),H.length>0){let L=0,F=A4(H);for(let A of H){await _.uploadFile(j.id,A.path,A.content),L++;let N=Math.round(L/H.length*100);Q({stage:"upload",message:`Uploading: ${A.path}`,percent:N,details:{uploaded:L,total:H.length}})}J(`Uploaded ${_6(F)}`)}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})}}),V=Date.now()-Z;if(Q({stage:"done",message:"Deploy complete!"}),J(`Deploy complete in ${(V/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;YS(L)}return{success:!0,url:O.deploy_ssl_url,siteUrl:$.production?O.ssl_url:void 0,deployId:O.id,logs:Y,duration:V,filesUploaded:H.length,totalSize:A4(H)}}async function dH($={}){let Z=$.directory||process.cwd(),Y;if(t7(Z))Y=aQ.join(Z,"netlify.toml");else{let X=await U$(Z);Y=await o7(Z,_$(X))}if($.siteId){let X=aQ.join(Z,".env.local"),J="";if(await Bun.file(X).exists()){if(J=await Bun.file(X).text(),J=J.split(`
|
|
12743
12743
|
`).filter((Q)=>!Q.startsWith("NETLIFY_SITE_ID=")).join(`
|
|
12744
12744
|
`),J&&!J.endsWith(`
|
|
12745
12745
|
`))J+=`
|
|
12746
12746
|
`}J+=`NETLIFY_SITE_ID=${$.siteId}
|
|
12747
|
-
`,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function YS($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var w4;var CY=D(()=>{nQ();nQ();w4=class w4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});var iH={};e(iH,{resizeAndConvert:()=>pH,processImage:()=>i1,isSharpAvailable:()=>B$,isImageFile:()=>q$,isImageBackendAvailable:()=>p1,groupVariantsByFormat:()=>m6,getTotalSize:()=>e7,getMimeType:()=>S1,getImageMetadata:()=>h6,getFallbackVariant:()=>u6,generateSrcSet:()=>B6,generateSizes:()=>d6,formatSize:()=>$8,ImageProcessingError:()=>c6,DEFAULT_WIDTHS:()=>I1,DEFAULT_QUALITY:()=>k1,DEFAULT_FORMATS:()=>D1});import oQ from"fs";import z$ from"path";import cH from"os";import tQ from"crypto";import{generatePlaceholder as XS,processImage as JS}from"ts-images";async function bY(){if(mH)return sQ;mH=!0;try{let $=await import("sharp");return sQ=$.default||$,sQ}catch{return null}}async function B$(){return await bY()!==null}async function p1(){return!0}async function i1($,Z={}){let{widths:Y=I1,formats:X=D1,quality:J=k1,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 c6(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((A)=>Buffer.from(A))}else _="buffer-input",U=$;let z=tQ.createHash("sha256").update(U).digest("hex").slice(0,12),B=await h6(U),{width:q,height:j}=B,H=q/j;await oQ.promises.mkdir(K,{recursive:!0});let O=[],V=z$.basename(_,z$.extname(_)),L=Y.filter((A)=>A<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((A,N)=>A-N);for(let A of L){let N=Math.round(A/H);for(let w of X){let R=`${V}-${A}w-${z}.${w}`,T=z$.join(K,R),E=`${W}/${R}`,I=await pH(U,{width:A,height:N,format:w,quality:J,fit:Q});await Bun.write(T,I),O.push({path:T,url:E,width:A,height:N,format:w,size:I.length})}}let F;if(G!=="none")F=await KS(U,G);return{src:_,variants:O,placeholder:F,width:q,height:j,aspectRatio:H,hash:z}}async function h6($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await bY();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 GS(Z)}function GS($){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 c6("Unable to parse image dimensions","PARSE_ERROR")}async function pH($,Z){let Y=await bY();if(Y){let J=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":J=J.webp({quality:Z.quality});break;case"avif":J=J.avif({quality:Z.quality});break;case"jpeg":J=J.jpeg({quality:Z.quality});break;case"png":J=J.png({quality:Z.quality});break}return J.toBuffer()}let X=z$.join(cH.tmpdir(),`stx-img-${tQ.randomBytes(8).toString("hex")}.${Z.format}`);try{return await JS({input:$,output:X,format:Z.format,quality:Z.quality,resize:{width:Z.width,height:Z.height,fit:Z.fit}}),Buffer.from(await Bun.file(X).arrayBuffer())}finally{await oQ.promises.unlink(X).catch(()=>{})}}async function KS($,Z){let Y=await bY();if(Z==="blur"&&Y){let G=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),K=await h6($);return`data:${lH[K.format]||"image/jpeg"};base64,${G}`}if(Z==="dominant-color"&&Y){let{dominant:Q}=await Y($).resize(1,1).toBuffer().then(async(G)=>{let K=await Y(G).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${Q.r}, ${Q.g}, ${Q.b})`}let X=await h6($),J=z$.join(cH.tmpdir(),`stx-ph-${tQ.randomBytes(8).toString("hex")}.${X.format==="unknown"?"bin":X.format}`);try{await Bun.write(J,$);let Q=Z==="blur"?"blur":Z==="thumbhash"?"thumbhash":"dominant-color",K=await XS(J,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(Z==="dominant-color"&&K.dominantColor)return K.dominantColor;if(K.dataURL)return K.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await oQ.promises.unlink(J).catch(()=>{})}}function B6($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function d6($){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 u6($){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 m6($){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 q$($){let Z=z$.extname($).toLowerCase();return QS.includes(Z)}function S1($){return lH[$]||"application/octet-stream"}function e7($){return $.reduce((Z,Y)=>Z+Y.size,0)}function $8($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var I1,D1,k1=80,QS,lH,sQ=null,mH=!1,c6;var l6=D(()=>{I1=[320,640,768,1024,1280,1536,1920],D1=["webp","jpeg"],QS=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],lH={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};c6=class c6 extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});var oH={};e(oH,{handleImageRequest:()=>Y8,createImageHandler:()=>PY});import nH from"fs";import Z8 from"path";import WS from"crypto";async function Y8($,Z){let Y=Z.routePath??"/_stx/img",X=new URL($.url);if(X.pathname!==Y)return null;let J=BS(X,Z);if(!J.ok)return new Response(J.error,{status:J.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:_,fit:z}=J,B;try{B=nH.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!B.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let q=Z.cacheDir??".stx/cache/img";await nH.promises.mkdir(q,{recursive:!0});let j=`${Q}:${B.mtimeMs}:${B.size}`,H=`${K}x${W}:${U}:${_}:${z}`,O=WS.createHash("sha256").update(`${j}|${H}`).digest("hex").slice(0,16),V=Z8.join(q,`${O}.${U}`),F={"Content-Type":S1(U),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${O}"`,"X-Stx-Image-Cache":"HIT"};if($.headers.get("if-none-match")===`"${O}"`)return new Response(null,{status:304,headers:F});let A=Bun.file(V);if(await A.exists())return new Response(A,{headers:F});try{let N=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:w}=await qS(),R=await w(N,{width:K,height:W,format:U,quality:_,fit:z});return await Bun.write(V,R),F["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(R),{headers:F})}catch(N){let w=N.message;return new Response(`Image processing failed: ${w}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function PY($){return async(Z)=>{return await Y8(Z,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function BS($,Z){let Y=$.searchParams.get("src");if(!Y)return{ok:!1,error:"Missing required param: src",status:400};if(!Y.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Y.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let X=Z8.extname(Y).toLowerCase();if(!US.has(X))return{ok:!1,error:`Unsupported source extension: ${X}`,status:400};let J=Z8.resolve(Z.publicDir),Q=Z8.resolve(J,Y.slice(1));if(!Q.startsWith(`${J}${Z8.sep}`)&&Q!==J)return{ok:!1,error:"src is outside publicDir",status:400};let G=Z.maxWidth??sH,K=Z.maxHeight??sH,W=$.searchParams.get("w"),U=$.searchParams.get("h"),_=W?Number.parseInt(W,10):0,z=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(_)||_<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(z)||z<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!W&&!U)return{ok:!1,error:"At least one of w or h is required",status:400};let B=Math.min(_||G,G),q=Math.min(z||K,K),j=$.searchParams.get("f")||"webp";if(!rH.has(j))return{ok:!1,error:`Invalid f (must be one of: ${[...rH].join(", ")})`,status:400};let H=j,O=$.searchParams.get("q"),V=O?Number.parseInt(O,10):Z.defaultQuality??_S;if(!Number.isFinite(V)||V<1||V>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let L=$.searchParams.get("fit")||Z.defaultFit||zS;if(!aH.has(L))return{ok:!1,error:`Invalid fit (must be one of: ${[...aH].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Y,width:B,height:q,format:H,quality:V,fit:L}}async function qS(){return await Promise.resolve().then(() => (l6(),iH))}var rH,aH,US,sH=4096,_S=80,zS="cover";var eQ=D(()=>{l6();rH=new Set(["webp","avif","jpeg","png"]),aH=new Set(["cover","contain","fill","inside","outside"]),US=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function $G($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=k1,placeholder:_="none",formats:z=D1,widths:B=I1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,V=$.class,L=$.style,{processedImage:F,variants:A,optimize:N=!0,isDev:w=!1}=Z;if(A&&A.length>0)return jS($,A,F);if(w||!N)return HS($);return OS($)}function jS($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:_="async",fetchpriority:z,objectFit:B,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,V=m6(Z),L=u6(Z),F=typeof K==="object"?d6(K):K,A=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,N=[];if(A)N.push(`aspect-ratio: ${A}`);if(B)N.push(`object-fit: ${B}`);if(q)N.push(`object-position: ${q}`);if(O)N.push(O);let w=N.length>0?` style="${N.join("; ")}"`:"",R=H?` class="${H}"`:"",T=U?"":` loading="${W}"`,E=` decoding="${_}"`,I=z?` fetchpriority="${z}"`:U?' fetchpriority="high"':"",k=["avif","webp","jpeg","png"],S=[];for(let h of k){let m=V.get(h);if(m&&m.length>0){let r=B6(m),o=S1(h);S.push(` <source type="${o}" srcset="${r}" sizes="${F}" />`)}}let x="",P="",b;if(j!=="none"&&Y?.placeholder){let h=`img-${Math.random().toString(36).slice(2,8)}`;if(x=`<div class="stx-image-wrapper" id="${h}">`,P="</div>",j==="blur")b=`
|
|
12747
|
+
`,await Bun.write(X,J)}return{configPath:Y,siteId:$.siteId}}function YS($){let Z=process.platform,Y=Z==="darwin"?"open":Z==="win32"?"start":"xdg-open";Bun.spawn([Y,$],{stdio:["ignore","ignore","ignore"]})}var w4;var CY=D(()=>{nQ();nQ();w4=class w4 extends Error{code;constructor($,Z){super($);this.name="DeployError",this.code=Z}}});var iH={};e(iH,{resizeAndConvert:()=>pH,processImage:()=>i1,isSharpAvailable:()=>B$,isImageFile:()=>q$,isImageBackendAvailable:()=>p1,groupVariantsByFormat:()=>u6,getTotalSize:()=>e7,getMimeType:()=>S1,getImageMetadata:()=>g6,getFallbackVariant:()=>d6,generateSrcSet:()=>z6,generateSizes:()=>h6,formatSize:()=>$8,ImageProcessingError:()=>m6,DEFAULT_WIDTHS:()=>I1,DEFAULT_QUALITY:()=>k1,DEFAULT_FORMATS:()=>D1});import oQ from"fs";import z$ from"path";import cH from"os";import tQ from"crypto";import{generatePlaceholder as XS,processImage as JS}from"ts-images";async function bY(){if(mH)return sQ;mH=!0;try{let $=await import("sharp");return sQ=$.default||$,sQ}catch{return null}}async function B$(){return await bY()!==null}async function p1(){return!0}async function i1($,Z={}){let{widths:Y=I1,formats:X=D1,quality:J=k1,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 m6(`Image not found: ${$}`,"NOT_FOUND");U=await Bun.file($).arrayBuffer().then((A)=>Buffer.from(A))}else _="buffer-input",U=$;let z=tQ.createHash("sha256").update(U).digest("hex").slice(0,12),B=await g6(U),{width:q,height:j}=B,H=q/j;await oQ.promises.mkdir(K,{recursive:!0});let O=[],V=z$.basename(_,z$.extname(_)),L=Y.filter((A)=>A<=q);if(!L.includes(q)&&q<=Math.max(...Y))L.push(q);L.sort((A,N)=>A-N);for(let A of L){let N=Math.round(A/H);for(let w of X){let R=`${V}-${A}w-${z}.${w}`,T=z$.join(K,R),E=`${W}/${R}`,I=await pH(U,{width:A,height:N,format:w,quality:J,fit:Q});await Bun.write(T,I),O.push({path:T,url:E,width:A,height:N,format:w,size:I.length})}}let F;if(G!=="none")F=await KS(U,G);return{src:_,variants:O,placeholder:F,width:q,height:j,aspectRatio:H,hash:z}}async function g6($){let Z=typeof $==="string"?Buffer.from(await Bun.file($).arrayBuffer()):$,Y=await bY();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 GS(Z)}function GS($){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 m6("Unable to parse image dimensions","PARSE_ERROR")}async function pH($,Z){let Y=await bY();if(Y){let J=Y($).resize(Z.width,Z.height,{fit:Z.fit});switch(Z.format){case"webp":J=J.webp({quality:Z.quality});break;case"avif":J=J.avif({quality:Z.quality});break;case"jpeg":J=J.jpeg({quality:Z.quality});break;case"png":J=J.png({quality:Z.quality});break}return J.toBuffer()}let X=z$.join(cH.tmpdir(),`stx-img-${tQ.randomBytes(8).toString("hex")}.${Z.format}`);try{return await JS({input:$,output:X,format:Z.format,quality:Z.quality,resize:{width:Z.width,height:Z.height,fit:Z.fit}}),Buffer.from(await Bun.file(X).arrayBuffer())}finally{await oQ.promises.unlink(X).catch(()=>{})}}async function KS($,Z){let Y=await bY();if(Z==="blur"&&Y){let G=(await Y($).resize(20).blur(10).toBuffer()).toString("base64"),K=await g6($);return`data:${lH[K.format]||"image/jpeg"};base64,${G}`}if(Z==="dominant-color"&&Y){let{dominant:Q}=await Y($).resize(1,1).toBuffer().then(async(G)=>{let K=await Y(G).metadata();return{dominant:{r:128,g:128,b:128}}}).catch(()=>({dominant:{r:128,g:128,b:128}}));return`rgb(${Q.r}, ${Q.g}, ${Q.b})`}let X=await g6($),J=z$.join(cH.tmpdir(),`stx-ph-${tQ.randomBytes(8).toString("hex")}.${X.format==="unknown"?"bin":X.format}`);try{await Bun.write(J,$);let Q=Z==="blur"?"blur":Z==="thumbhash"?"thumbhash":"dominant-color",K=await XS(J,{strategy:Q,width:Q==="thumbhash"?void 0:32});if(Z==="dominant-color"&&K.dominantColor)return K.dominantColor;if(K.dataURL)return K.dataURL;return"rgb(128, 128, 128)"}catch{return"rgb(128, 128, 128)"}finally{await oQ.promises.unlink(J).catch(()=>{})}}function z6($,Z){return(Z?$.filter((X)=>X.format===Z):$).sort((X,J)=>X.width-J.width).map((X)=>`${X.url} ${X.width}w`).join(", ")}function h6($){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 d6($){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 u6($){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 q$($){let Z=z$.extname($).toLowerCase();return QS.includes(Z)}function S1($){return lH[$]||"application/octet-stream"}function e7($){return $.reduce((Z,Y)=>Z+Y.size,0)}function $8($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1048576).toFixed(2)} MB`}var I1,D1,k1=80,QS,lH,sQ=null,mH=!1,m6;var c6=D(()=>{I1=[320,640,768,1024,1280,1536,1920],D1=["webp","jpeg"],QS=[".jpg",".jpeg",".png",".webp",".avif",".gif",".svg"],lH={webp:"image/webp",avif:"image/avif",jpeg:"image/jpeg",png:"image/png"};m6=class m6 extends Error{code;constructor($,Z){super($);this.name="ImageProcessingError",this.code=Z}}});var oH={};e(oH,{handleImageRequest:()=>Y8,createImageHandler:()=>PY});import nH from"fs";import Z8 from"path";import WS from"crypto";async function Y8($,Z){let Y=Z.routePath??"/_stx/img",X=new URL($.url);if(X.pathname!==Y)return null;let J=BS(X,Z);if(!J.ok)return new Response(J.error,{status:J.status,headers:{"Content-Type":"text/plain"}});let{srcFsPath:Q,srcUrl:G,width:K,height:W,format:U,quality:_,fit:z}=J,B;try{B=nH.statSync(Q)}catch{return new Response(`Source image not found: ${G}`,{status:404,headers:{"Content-Type":"text/plain"}})}if(!B.isFile())return new Response("Not a file",{status:404,headers:{"Content-Type":"text/plain"}});let q=Z.cacheDir??".stx/cache/img";await nH.promises.mkdir(q,{recursive:!0});let j=`${Q}:${B.mtimeMs}:${B.size}`,H=`${K}x${W}:${U}:${_}:${z}`,O=WS.createHash("sha256").update(`${j}|${H}`).digest("hex").slice(0,16),V=Z8.join(q,`${O}.${U}`),F={"Content-Type":S1(U),"Cache-Control":"public, max-age=31536000, immutable",ETag:`"${O}"`,"X-Stx-Image-Cache":"HIT"};if($.headers.get("if-none-match")===`"${O}"`)return new Response(null,{status:304,headers:F});let A=Bun.file(V);if(await A.exists())return new Response(A,{headers:F});try{let N=Buffer.from(await Bun.file(Q).arrayBuffer()),{resizeAndConvert:w}=await qS(),R=await w(N,{width:K,height:W,format:U,quality:_,fit:z});return await Bun.write(V,R),F["X-Stx-Image-Cache"]="MISS",new Response(new Uint8Array(R),{headers:F})}catch(N){let w=N.message;return new Response(`Image processing failed: ${w}`,{status:500,headers:{"Content-Type":"text/plain"}})}}function PY($){return async(Z)=>{return await Y8(Z,$)??new Response("Not Found",{status:404,headers:{"Content-Type":"text/plain"}})}}function BS($,Z){let Y=$.searchParams.get("src");if(!Y)return{ok:!1,error:"Missing required param: src",status:400};if(!Y.startsWith("/"))return{ok:!1,error:"src must be an absolute URL path (start with /)",status:400};if(Y.startsWith("//"))return{ok:!1,error:"src must be a local path",status:400};let X=Z8.extname(Y).toLowerCase();if(!US.has(X))return{ok:!1,error:`Unsupported source extension: ${X}`,status:400};let J=Z8.resolve(Z.publicDir),Q=Z8.resolve(J,Y.slice(1));if(!Q.startsWith(`${J}${Z8.sep}`)&&Q!==J)return{ok:!1,error:"src is outside publicDir",status:400};let G=Z.maxWidth??sH,K=Z.maxHeight??sH,W=$.searchParams.get("w"),U=$.searchParams.get("h"),_=W?Number.parseInt(W,10):0,z=U?Number.parseInt(U,10):0;if(W&&(!Number.isFinite(_)||_<=0))return{ok:!1,error:"Invalid w (must be positive integer)",status:400};if(U&&(!Number.isFinite(z)||z<=0))return{ok:!1,error:"Invalid h (must be positive integer)",status:400};if(!W&&!U)return{ok:!1,error:"At least one of w or h is required",status:400};let B=Math.min(_||G,G),q=Math.min(z||K,K),j=$.searchParams.get("f")||"webp";if(!rH.has(j))return{ok:!1,error:`Invalid f (must be one of: ${[...rH].join(", ")})`,status:400};let H=j,O=$.searchParams.get("q"),V=O?Number.parseInt(O,10):Z.defaultQuality??_S;if(!Number.isFinite(V)||V<1||V>100)return{ok:!1,error:"Invalid q (must be 1-100)",status:400};let L=$.searchParams.get("fit")||Z.defaultFit||zS;if(!aH.has(L))return{ok:!1,error:`Invalid fit (must be one of: ${[...aH].join(", ")})`,status:400};return{ok:!0,srcFsPath:Q,srcUrl:Y,width:B,height:q,format:H,quality:V,fit:L}}async function qS(){return await Promise.resolve().then(() => (c6(),iH))}var rH,aH,US,sH=4096,_S=80,zS="cover";var eQ=D(()=>{c6();rH=new Set(["webp","avif","jpeg","png"]),aH=new Set(["cover","contain","fill","inside","outside"]),US=new Set([".jpg",".jpeg",".png",".webp",".avif",".gif"])});function $G($,Z={}){let{src:Y,alt:X,width:J,height:Q,sizes:G="100vw",loading:K="lazy",priority:W=!1,quality:U=k1,placeholder:_="none",formats:z=D1,widths:B=I1,decoding:q="async",fetchpriority:j,objectFit:H,objectPosition:O}=$,V=$.class,L=$.style,{processedImage:F,variants:A,optimize:N=!0,isDev:w=!1}=Z;if(A&&A.length>0)return jS($,A,F);if(w||!N)return HS($);return OS($)}function jS($,Z,Y){let{src:X,alt:J,width:Q,height:G,sizes:K="100vw",loading:W="lazy",priority:U=!1,decoding:_="async",fetchpriority:z,objectFit:B,objectPosition:q,placeholder:j="none"}=$,H=$.class,O=$.style,V=u6(Z),L=d6(Z),F=typeof K==="object"?h6(K):K,A=Y?Y.aspectRatio:Q&&G?Number(Q)/Number(G):void 0,N=[];if(A)N.push(`aspect-ratio: ${A}`);if(B)N.push(`object-fit: ${B}`);if(q)N.push(`object-position: ${q}`);if(O)N.push(O);let w=N.length>0?` style="${N.join("; ")}"`:"",R=H?` class="${H}"`:"",T=U?"":` loading="${W}"`,E=` decoding="${_}"`,I=z?` fetchpriority="${z}"`:U?' fetchpriority="high"':"",k=["avif","webp","jpeg","png"],S=[];for(let h of k){let m=V.get(h);if(m&&m.length>0){let r=z6(m),o=S1(h);S.push(` <source type="${o}" srcset="${r}" sizes="${F}" />`)}}let x="",P="",b;if(j!=="none"&&Y?.placeholder){let h=`img-${Math.random().toString(36).slice(2,8)}`;if(x=`<div class="stx-image-wrapper" id="${h}">`,P="</div>",j==="blur")b=`
|
|
12748
12748
|
#${h} {
|
|
12749
12749
|
position: relative;
|
|
12750
12750
|
background-image: url('${Y.placeholder}');
|
|
@@ -12768,14 +12768,14 @@ ${S.join(`
|
|
|
12768
12768
|
src="${L?.url||X}"
|
|
12769
12769
|
alt="${YG(J)}"${g}${s}${R}${w}${T}${E}${I}
|
|
12770
12770
|
/>
|
|
12771
|
-
</picture>${P}`,C;if(U&&L){let h=V.get("webp"),m=h?.[Math.floor(h.length/2)]||L,r=S1(m.format);C=`<link rel="preload" as="image" href="${m.url}" type="${r}" />`}return{html:p,preloadLink:C,placeholderCss:b}}function HS($){let{src:Z,alt:Y,width:X,height:J,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:_}=$,z=$.class,B=$.style,q=[];if(U)q.push(`object-fit: ${U}`);if(_)q.push(`object-position: ${_}`);if(B)q.push(B);let j=q.length>0?` style="${q.join("; ")}"`:"",H=z?` class="${z}"`:"",O=X?` width="${X}"`:"",V=J?` height="${J}"`:"",L=K?"":` loading="${Q}"`,F=` decoding="${G}"`,A=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${Z}" alt="${YG(Y)}"${O}${V}${H}${j}${L}${F}${A} />`}}function OS($){let{src:Z,alt:Y,width:X,height:J,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=k1,formats:U=D1,widths:_=I1,decoding:z="async",fetchpriority:B,objectFit:q,objectPosition:j}=$,H=$.class,O=$.style,V=[];if(q)V.push(`object-fit: ${q}`);if(j)V.push(`object-position: ${j}`);if(O)V.push(O);let L=V.length>0?` style="${V.join("; ")}"`:"",F=H?` class="${H}"`:"",A=X?` width="${X}"`:"",N=J?` height="${J}"`:"",w=K?"":` loading="${G}"`,R=` decoding="${z}"`,T=B?` fetchpriority="${B}"`:K?' fetchpriority="high"':"",E=typeof Q==="object"?
|
|
12771
|
+
</picture>${P}`,C;if(U&&L){let h=V.get("webp"),m=h?.[Math.floor(h.length/2)]||L,r=S1(m.format);C=`<link rel="preload" as="image" href="${m.url}" type="${r}" />`}return{html:p,preloadLink:C,placeholderCss:b}}function HS($){let{src:Z,alt:Y,width:X,height:J,loading:Q="lazy",decoding:G="async",priority:K=!1,fetchpriority:W,objectFit:U,objectPosition:_}=$,z=$.class,B=$.style,q=[];if(U)q.push(`object-fit: ${U}`);if(_)q.push(`object-position: ${_}`);if(B)q.push(B);let j=q.length>0?` style="${q.join("; ")}"`:"",H=z?` class="${z}"`:"",O=X?` width="${X}"`:"",V=J?` height="${J}"`:"",L=K?"":` loading="${Q}"`,F=` decoding="${G}"`,A=W?` fetchpriority="${W}"`:K?' fetchpriority="high"':"";return{html:`<img src="${Z}" alt="${YG(Y)}"${O}${V}${H}${j}${L}${F}${A} />`}}function OS($){let{src:Z,alt:Y,width:X,height:J,sizes:Q="100vw",loading:G="lazy",priority:K=!1,quality:W=k1,formats:U=D1,widths:_=I1,decoding:z="async",fetchpriority:B,objectFit:q,objectPosition:j}=$,H=$.class,O=$.style,V=[];if(q)V.push(`object-fit: ${q}`);if(j)V.push(`object-position: ${j}`);if(O)V.push(O);let L=V.length>0?` style="${V.join("; ")}"`:"",F=H?` class="${H}"`:"",A=X?` width="${X}"`:"",N=J?` height="${J}"`:"",w=K?"":` loading="${G}"`,R=` decoding="${z}"`,T=B?` fetchpriority="${B}"`:K?' fetchpriority="high"':"",E=typeof Q==="object"?h6(Q):Q,I=`
|
|
12772
12772
|
data-stx-image
|
|
12773
12773
|
data-src="${Z}"
|
|
12774
12774
|
data-sizes="${E}"
|
|
12775
12775
|
data-quality="${W}"
|
|
12776
12776
|
data-formats="${U.join(",")}"
|
|
12777
12777
|
data-widths="${_.join(",")}"
|
|
12778
|
-
`.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${YG(Y)}"${A}${N}${F}${L}${w}${R}${T} ${I} />`}}function yY($){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 ZG($,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],_=yY(U);if(_){let z=await Z(_);if(Q=Q.replace(U,z.html),z.preloadLink)X.push(z.preloadLink);if(z.placeholderCss)J.push(z.placeholderCss)}}return{html:Q,preloadLinks:X,styles:J}}function YG($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var tH=D(()=>{
|
|
12778
|
+
`.replace(/\s+/g," ").trim();return{html:`<img src="${Z}" alt="${YG(Y)}"${A}${N}${F}${L}${w}${R}${T} ${I} />`}}function yY($){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 ZG($,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],_=yY(U);if(_){let z=await Z(_);if(Q=Q.replace(U,z.html),z.preloadLink)X.push(z.preloadLink);if(z.placeholderCss)J.push(z.placeholderCss)}}return{html:Q,preloadLinks:X,styles:J}}function YG($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}var tH=D(()=>{c6()});function vY(){xY.clear()}async function LS($,Z){let Y=`${$}:${JSON.stringify(Z)}`;if(xY.has(Y))return xY.get(Y);try{let X=await i1($,Z);return xY.set(Y,X),X}catch{return null}}function fY(){return x0({name:"image",hasEndTag:!1,description:"Render an optimized image with responsive variants",transform:async($,Z,Y)=>{let{src:X,alt:J,options:Q}=VS($,Z,Y);if(!X)return console.warn("@image directive: missing src argument"),"<!-- @image: missing src -->";let G={widths:Q.widths||(Q.width?[Q.width]:I1),formats:Q.formats||D1,quality:Q.quality||k1,placeholder:(Q.placeholder==="color"?"dominant-color":Q.placeholder)||"none"};if(!await p1())return eH(X,J||"",Q);let W=await LS(X,G);if(!W)return eH(X,J||"",Q);return AS(W,J||"",Q)}})}function VS($,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=FS(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 FS($){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 eH($,Z,Y){let X=[`src="${R4($)}"`];if(Z)X.push(`alt="${R4(Z)}"`);if(Y.width)X.push(`width="${Y.width}"`);if(Y.height)X.push(`height="${Y.height}"`);if(Y.class)X.push(`class="${R4(Y.class)}"`);if(Y.style)X.push(`style="${R4(Y.style)}"`);if(Y.lazy!==!1)X.push('loading="lazy"');return X.push('decoding="async"'),`<img ${X.join(" ")} />`}function AS($,Z,Y){let{variants:X,placeholder:J,width:Q,height:G,aspectRatio:K}=$,W=new Map;for(let O of X){let V=W.get(O.format)||[];V.push(O),W.set(O.format,V)}let U=["avif","webp","jpeg","png"],_=[];for(let O of U){let V=W.get(O);if(V&&V.length>0){let L=z6(V),F=S1(O),A=Y.sizes||"100vw";_.push(` <source type="${F}" srcset="${R4(L)}" sizes="${R4(A)}" />`)}}let z=W.get("jpeg")||[],B=z.length>0?z[Math.floor(z.length/2)]:X[Math.floor(X.length/2)],q=[`src="${B?.url||$.src}"`,`alt="${R4(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="${R4(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>
|
|
12779
12779
|
`;if(H+=_.join(`
|
|
12780
12780
|
`)+`
|
|
12781
12781
|
`,H+=` <img ${q.join(" ")} />
|
|
@@ -12784,7 +12784,7 @@ ${H}
|
|
|
12784
12784
|
</div>`}else if(Y.placeholder==="color"){let V=J.replace(/[^a-zA-Z0-9#(),.\s%-]/g,"");H=`<div id="${O}" class="stx-image-placeholder" style="background-color: ${V};">
|
|
12785
12785
|
${H}
|
|
12786
12786
|
</div>`}}if(Y.priority&&B){let O=S1(B.format);H=`<link rel="preload" as="image" href="${R4(B.url)}" type="${O}" />
|
|
12787
|
-
`+H}return H}function R4($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var xY,XG;var $O=D(()=>{S7();l6();xY=new Map;XG=fY()});import j$ from"fs";import gY from"path";function JG($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:X="/images",formats:J=D1,widths:Q=I1,quality:G=k1,placeholder:K="none",concurrency:W=4,cache:U=!0,cacheDir:_=".stx/image-cache",referencedOnly:z=!1,verbose:B=!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 p1()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(U)await j$.promises.mkdir(_,{recursive:!0});if(B){let O=await B$();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${O?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),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=NS(j);for(let V of O)q.imageReferences.add(V)}if(j.includes("<Image")||j.includes("@image"))return await RS(j,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X,processedImages:q.processedImages});return j},async buildEnd(j){if(!await p1())return;await j$.promises.mkdir(Y,{recursive:!0});let O=[];for(let F of Z){if(!j$.existsSync(F))continue;let A=await ZO(F);O.push(...A)}let V=z?O.filter((F)=>wS(F,q.imageReferences)):O;if(q.stats.totalImages=V.length,B)console.log(`[stx-images] Processing ${V.length} images...`);let L=YO(V,W);for(let F of L)await Promise.all(F.map(async(A)=>{try{let N=await i1(A,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X});q.processedImages.set(A,N),q.stats.optimizedImages++,q.stats.variants+=N.variants.length;let w=j$.statSync(A).size,R=e7(N.variants);if(q.stats.savedBytes+=Math.max(0,w-R/N.variants.length),B)console.log(` \u2713 ${gY.basename(A)} \u2192 ${N.variants.length} variants`)}catch(N){console.error(`[stx-images] Error processing ${A}:`,N)}}));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: ~${$8(q.stats.savedBytes)}`)}}}function NS($){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 wS($,Z){let Y=gY.basename($);for(let X of Z)if(X.endsWith(Y)||X.includes(Y))return!0;return!1}async function RS($,Z){return $}async function ZO($){let Z=[];async function Y(X){let J=await j$.promises.readdir(X,{withFileTypes:!0});for(let Q of J){let G=gY.join(X,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&q$(G))Z.push(G)}}return await Y($),Z}function YO($,Z){let Y=[];for(let X=0;X<$.length;X+=Z)Y.push($.slice(X,X+Z));return Y}async function hY($,Z,Y={}){if(!await p1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return i1($,{...Y,outputDir:Z})}async function QG($,Z,Y={}){let{formats:X=D1,widths:J=I1,quality:Q=k1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await p1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await j$.promises.mkdir(Z,{recursive:!0});let _=await ZO($),z=[],B={totalImages:_.length,optimizedImages:0,savedBytes:0,variants:0},q=YO(_,K);for(let j of q){let H=await Promise.all(j.map(async(O)=>{try{let V=await i1(O,{formats:X,widths:J,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(B.optimizedImages++,B.variants+=V.variants.length,W)console.log(` \u2713 ${gY.basename(O)}`);return V}catch(V){return console.error(`Error processing ${O}:`,V),null}}));z.push(...H.filter((O)=>O!==null))}return{processed:z,stats:B}}function dY($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function GG($,Z){let Y=dY($);await Bun.write(Z,JSON.stringify(Y,null,2))}var XO=D(()=>{l6()});var QO={};e(QO,{writeImageManifest:()=>GG,rewriteImagesWithSiblings:()=>rZ,renderImageComponent:()=>$G,processImageComponents:()=>ZG,processImage:()=>i1,parseImageComponent:()=>yY,optimizeImage:()=>hY,optimizeDirectory:()=>QG,isSharpAvailable:()=>B$,isImageFile:()=>q$,isImageBackendAvailable:()=>p1,imageDirective:()=>XG,handleImageRequest:()=>Y8,groupVariantsByFormat:()=>m6,getTotalSize:()=>e7,getMimeType:()=>S1,getImageMetadata:()=>h6,getFallbackVariant:()=>u6,generateSrcSet:()=>B6,generateSizes:()=>d6,generateImageManifest:()=>dY,formatSize:()=>$8,defaultImageConfig:()=>JO,createImagePlugin:()=>JG,createImageHandler:()=>PY,createImageDirective:()=>fY,clearImageCache:()=>vY,ImageProcessingError:()=>c6,DEFAULT_WIDTHS:()=>I1,DEFAULT_QUALITY:()=>k1,DEFAULT_FORMATS:()=>D1});var JO;var uY=D(()=>{l6();E2();eQ();tH();$O();XO();JO={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 mY($,Z,Y=new WeakSet){if(Object.is($,Z))return!0;if(typeof $!=="object"||typeof Z!=="object"||$===null||Z===null)return!1;if(Y.has($))return!0;if(Y.add($),$ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if($ instanceof RegExp&&Z instanceof RegExp)return $.source===Z.source&&$.flags===Z.flags;if(Array.isArray($)){if(!Array.isArray(Z)||$.length!==Z.length)return!1;for(let Q=0;Q<$.length;Q++)if(!mY($[Q],Z[Q],Y))return!1;return!0}if(Array.isArray(Z))return!1;if($ instanceof Map){if(!(Z instanceof Map)||$.size!==Z.size)return!1;for(let[Q,G]of $)if(!Z.has(Q)||!mY(G,Z.get(Q),Y))return!1;return!0}if(Z instanceof Map)return!1;if($ instanceof Set){if(!(Z instanceof Set)||$.size!==Z.size)return!1;for(let Q of $)if(!Z.has(Q))return!1;return!0}if(Z instanceof Set)return!1;let X=Object.keys($),J=Object.keys(Z);if(X.length!==J.length)return!1;for(let Q of X){if(!Object.prototype.hasOwnProperty.call(Z,Q))return!1;if(!mY($[Q],Z[Q],Y))return!1}return!0}function MS($){v0=$}function TS(){return v0}function ES(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:KO()}}function KO(){return{refs:new Map,effects:new Set,cleanups:[]}}function IS($){let Z=new Set,Y=new Set,X=$,J=Symbol("ref"),Q={get value(){if(a0)Y.add(a0);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(v0)v0.scope.refs.set(J,Q);return Q}function WO($){let Z=GO.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(a0)J(K,a0);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let _=Object.getPrototypeOf(U);if(_===Object.prototype||_===null)return WO(U)}return U},set(G,K,W,U){let _=Reflect.get(G,K,U),z=Reflect.set(G,K,W,U);if(!Object.is(W,_))X(K);return z},deleteProperty(G,K){let W=Reflect.deleteProperty(G,K);return X(K),W}});return GO.set($,Q),Q}function DS($){let Z,Y=!0,X=new Set,J=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=a0;if(a0=Q,Z=$(),a0=U,Y=!1,!Object.is(Z,W)){for(let _ of X)_(Z,W);for(let _ of J)_()}}},K=a0;return a0=Q,Z=$(),Y=!1,a0=K,{get value(){if(a0)J.add(a0);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return X.add(W),()=>{X.delete(W)}}}}function kS($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="post"}=Y,G,K,W=!1,U=()=>{if(W)return;let j=q();if((J?!mY(j,G):!Object.is(j,G))||X)if(Z(j,G),J&&j!==null&&typeof j==="object")try{G=structuredClone(j)}catch{G=j}else G=j},_=(j)=>{if(Q==="sync")j();else if(Q==="pre")Promise.resolve().then(j);else requestAnimationFrame(()=>{requestAnimationFrame(j)})},z=!1,B=()=>{if(W||z)return;z=!0,_(()=>{z=!1,U()})},q=()=>{if(typeof $==="function"){let j=a0;a0=B;try{return $()}finally{a0=j}}return $.value};if(typeof $!=="function"){let j=$.subscribe(()=>{_(U)});K=()=>{W=!0,j()}}else K=()=>{W=!0};if(G=q(),X)_(U);if(v0)v0.scope.cleanups.push(()=>K?.());return()=>K?.()}function SS($,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 CS($){let Z,Y=!1,X=()=>{if(Y)return;if(Z)Z();let J=a0;a0=X,Z=$(),a0=J};if(X(),v0)v0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function bS($){if(v0)v0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function PS($){if(v0)v0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function yS($){if(v0)v0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function xS($){if(v0)v0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function vS($){if(v0)v0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function fS($){if(v0)v0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function p6($,Z){let Y=$.hooks[Z];for(let X of Y)await X()}async function gS($){await p6($,"beforeMount"),$.isMounted=!0,await p6($,"mounted")}async function hS($){if(!$.isMounted||$.isUnmounted)return;await p6($,"beforeUpdate"),await p6($,"updated")}async function dS($){if($.isUnmounted)return;await p6($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await p6($,"unmounted")}function uS(){return`
|
|
12787
|
+
`+H}return H}function R4($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}var xY,XG;var $O=D(()=>{S7();c6();xY=new Map;XG=fY()});import j$ from"fs";import gY from"path";function JG($={}){let{inputDirs:Z=["public","src/assets","assets"],outputDir:Y="dist/images",baseUrl:X="/images",formats:J=D1,widths:Q=I1,quality:G=k1,placeholder:K="none",concurrency:W=4,cache:U=!0,cacheDir:_=".stx/image-cache",referencedOnly:z=!1,verbose:B=!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 p1()){console.warn("[stx-images] no image backend available, optimization disabled");return}if(U)await j$.promises.mkdir(_,{recursive:!0});if(B){let O=await B$();console.log("[stx-images] Plugin initialized"),console.log(` Backend: ${O?"sharp (native fast path) + ts-images":"ts-images (pure TS)"}`),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=NS(j);for(let V of O)q.imageReferences.add(V)}if(j.includes("<Image")||j.includes("@image"))return await RS(j,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X,processedImages:q.processedImages});return j},async buildEnd(j){if(!await p1())return;await j$.promises.mkdir(Y,{recursive:!0});let O=[];for(let F of Z){if(!j$.existsSync(F))continue;let A=await ZO(F);O.push(...A)}let V=z?O.filter((F)=>wS(F,q.imageReferences)):O;if(q.stats.totalImages=V.length,B)console.log(`[stx-images] Processing ${V.length} images...`);let L=YO(V,W);for(let F of L)await Promise.all(F.map(async(A)=>{try{let N=await i1(A,{formats:J,widths:Q,quality:G,placeholder:K,outputDir:Y,baseUrl:X});q.processedImages.set(A,N),q.stats.optimizedImages++,q.stats.variants+=N.variants.length;let w=j$.statSync(A).size,R=e7(N.variants);if(q.stats.savedBytes+=Math.max(0,w-R/N.variants.length),B)console.log(` \u2713 ${gY.basename(A)} \u2192 ${N.variants.length} variants`)}catch(N){console.error(`[stx-images] Error processing ${A}:`,N)}}));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: ~${$8(q.stats.savedBytes)}`)}}}function NS($){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 wS($,Z){let Y=gY.basename($);for(let X of Z)if(X.endsWith(Y)||X.includes(Y))return!0;return!1}async function RS($,Z){return $}async function ZO($){let Z=[];async function Y(X){let J=await j$.promises.readdir(X,{withFileTypes:!0});for(let Q of J){let G=gY.join(X,Q.name);if(Q.isDirectory())await Y(G);else if(Q.isFile()&&q$(G))Z.push(G)}}return await Y($),Z}function YO($,Z){let Y=[];for(let X=0;X<$.length;X+=Z)Y.push($.slice(X,X+Z));return Y}async function hY($,Z,Y={}){if(!await p1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");return i1($,{...Y,outputDir:Z})}async function QG($,Z,Y={}){let{formats:X=D1,widths:J=I1,quality:Q=k1,placeholder:G="none",concurrency:K=4,verbose:W=!1}=Y;if(!await p1())throw Error("No image backend available \u2014 install sharp or ensure ts-images is bundled");await j$.promises.mkdir(Z,{recursive:!0});let _=await ZO($),z=[],B={totalImages:_.length,optimizedImages:0,savedBytes:0,variants:0},q=YO(_,K);for(let j of q){let H=await Promise.all(j.map(async(O)=>{try{let V=await i1(O,{formats:X,widths:J,quality:Q,placeholder:G,outputDir:Z,baseUrl:"/"});if(B.optimizedImages++,B.variants+=V.variants.length,W)console.log(` \u2713 ${gY.basename(O)}`);return V}catch(V){return console.error(`Error processing ${O}:`,V),null}}));z.push(...H.filter((O)=>O!==null))}return{processed:z,stats:B}}function dY($){let Z={};for(let Y of $)Z[Y.src]={variants:Y.variants,placeholder:Y.placeholder};return Z}async function GG($,Z){let Y=dY($);await Bun.write(Z,JSON.stringify(Y,null,2))}var XO=D(()=>{c6()});var QO={};e(QO,{writeImageManifest:()=>GG,rewriteImagesWithSiblings:()=>rZ,renderImageComponent:()=>$G,processImageComponents:()=>ZG,processImage:()=>i1,parseImageComponent:()=>yY,optimizeImage:()=>hY,optimizeDirectory:()=>QG,isSharpAvailable:()=>B$,isImageFile:()=>q$,isImageBackendAvailable:()=>p1,imageDirective:()=>XG,handleImageRequest:()=>Y8,groupVariantsByFormat:()=>u6,getTotalSize:()=>e7,getMimeType:()=>S1,getImageMetadata:()=>g6,getFallbackVariant:()=>d6,generateSrcSet:()=>z6,generateSizes:()=>h6,generateImageManifest:()=>dY,formatSize:()=>$8,defaultImageConfig:()=>JO,createImagePlugin:()=>JG,createImageHandler:()=>PY,createImageDirective:()=>fY,clearImageCache:()=>vY,ImageProcessingError:()=>m6,DEFAULT_WIDTHS:()=>I1,DEFAULT_QUALITY:()=>k1,DEFAULT_FORMATS:()=>D1});var JO;var uY=D(()=>{c6();E2();eQ();tH();$O();XO();JO={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 mY($,Z,Y=new WeakSet){if(Object.is($,Z))return!0;if(typeof $!=="object"||typeof Z!=="object"||$===null||Z===null)return!1;if(Y.has($))return!0;if(Y.add($),$ instanceof Date&&Z instanceof Date)return $.getTime()===Z.getTime();if($ instanceof RegExp&&Z instanceof RegExp)return $.source===Z.source&&$.flags===Z.flags;if(Array.isArray($)){if(!Array.isArray(Z)||$.length!==Z.length)return!1;for(let Q=0;Q<$.length;Q++)if(!mY($[Q],Z[Q],Y))return!1;return!0}if(Array.isArray(Z))return!1;if($ instanceof Map){if(!(Z instanceof Map)||$.size!==Z.size)return!1;for(let[Q,G]of $)if(!Z.has(Q)||!mY(G,Z.get(Q),Y))return!1;return!0}if(Z instanceof Map)return!1;if($ instanceof Set){if(!(Z instanceof Set)||$.size!==Z.size)return!1;for(let Q of $)if(!Z.has(Q))return!1;return!0}if(Z instanceof Set)return!1;let X=Object.keys($),J=Object.keys(Z);if(X.length!==J.length)return!1;for(let Q of X){if(!Object.prototype.hasOwnProperty.call(Z,Q))return!1;if(!mY($[Q],Z[Q],Y))return!1}return!0}function MS($){v0=$}function TS(){return v0}function ES(){return{isMounted:!1,isUnmounted:!1,hooks:{beforeMount:[],mounted:[],beforeUpdate:[],updated:[],beforeUnmount:[],unmounted:[]},effects:[],scope:KO()}}function KO(){return{refs:new Map,effects:new Set,cleanups:[]}}function IS($){let Z=new Set,Y=new Set,X=$,J=Symbol("ref"),Q={get value(){if(a0)Y.add(a0);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(v0)v0.scope.refs.set(J,Q);return Q}function WO($){let Z=GO.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(a0)J(K,a0);if(U!==null&&typeof U==="object"&&!Array.isArray(U)){let _=Object.getPrototypeOf(U);if(_===Object.prototype||_===null)return WO(U)}return U},set(G,K,W,U){let _=Reflect.get(G,K,U),z=Reflect.set(G,K,W,U);if(!Object.is(W,_))X(K);return z},deleteProperty(G,K){let W=Reflect.deleteProperty(G,K);return X(K),W}});return GO.set($,Q),Q}function DS($){let Z,Y=!0,X=new Set,J=new Set,Q=()=>{Y=!0,G()},G=()=>{if(Y){let W=Z,U=a0;if(a0=Q,Z=$(),a0=U,Y=!1,!Object.is(Z,W)){for(let _ of X)_(Z,W);for(let _ of J)_()}}},K=a0;return a0=Q,Z=$(),Y=!1,a0=K,{get value(){if(a0)J.add(a0);return G(),Z},set value(W){console.warn("[stx] Computed properties are readonly")},subscribe(W){return X.add(W),()=>{X.delete(W)}}}}function kS($,Z,Y={}){let{immediate:X=!1,deep:J=!1,flush:Q="post"}=Y,G,K,W=!1,U=()=>{if(W)return;let j=q();if((J?!mY(j,G):!Object.is(j,G))||X)if(Z(j,G),J&&j!==null&&typeof j==="object")try{G=structuredClone(j)}catch{G=j}else G=j},_=(j)=>{if(Q==="sync")j();else if(Q==="pre")Promise.resolve().then(j);else requestAnimationFrame(()=>{requestAnimationFrame(j)})},z=!1,B=()=>{if(W||z)return;z=!0,_(()=>{z=!1,U()})},q=()=>{if(typeof $==="function"){let j=a0;a0=B;try{return $()}finally{a0=j}}return $.value};if(typeof $!=="function"){let j=$.subscribe(()=>{_(U)});K=()=>{W=!0,j()}}else K=()=>{W=!0};if(G=q(),X)_(U);if(v0)v0.scope.cleanups.push(()=>K?.());return()=>K?.()}function SS($,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 CS($){let Z,Y=!1,X=()=>{if(Y)return;if(Z)Z();let J=a0;a0=X,Z=$(),a0=J};if(X(),v0)v0.scope.cleanups.push(()=>{if(Y=!0,Z)Z()});return()=>{if(Y=!0,Z)Z()}}function bS($){if(v0)v0.hooks.beforeMount.push($);else console.warn("[stx] onBeforeMount called outside of component setup")}function PS($){if(v0)v0.hooks.mounted.push($);else console.warn("[stx] onMounted called outside of component setup")}function yS($){if(v0)v0.hooks.beforeUpdate.push($);else console.warn("[stx] onBeforeUpdate called outside of component setup")}function xS($){if(v0)v0.hooks.updated.push($);else console.warn("[stx] onUpdated called outside of component setup")}function vS($){if(v0)v0.hooks.beforeUnmount.push($);else console.warn("[stx] onBeforeUnmount called outside of component setup")}function fS($){if(v0)v0.hooks.unmounted.push($);else console.warn("[stx] onUnmounted called outside of component setup")}async function l6($,Z){let Y=$.hooks[Z];for(let X of Y)await X()}async function gS($){await l6($,"beforeMount"),$.isMounted=!0,await l6($,"mounted")}async function hS($){if(!$.isMounted||$.isUnmounted)return;await l6($,"beforeUpdate"),await l6($,"updated")}async function dS($){if($.isUnmounted)return;await l6($,"beforeUnmount");for(let Z of $.scope.cleanups)Z();$.isUnmounted=!0,await l6($,"unmounted")}function uS(){return`
|
|
12788
12788
|
<script data-stx-client-runtime>
|
|
12789
12789
|
(function() {
|
|
12790
12790
|
'use strict';
|
|
@@ -12964,7 +12964,7 @@ ${H}
|
|
|
12964
12964
|
</script>`}var v0=null,a0=null,GO;var UO=D(()=>{GO=new WeakMap});import{abortNavigation as mS,clearMiddleware as X8,createClientCookieManager as cS,createMiddlewareContext as J8,createRouteLocation as Q8,createServerCookieManager as lS,createStorageManager as pS,defineMiddleware as iS,getMiddleware as nS,getMiddlewareNames as G8,hasMiddleware as rS,loadMiddlewareFromDirectory as K8,navigateTo as aS,registerMiddleware as sS,runMiddleware as W8}from"stx-router";var cY=()=>{};function H$($,Z){if(typeof window>"u")return Z;return window[$]??Z}function lY($,Z){if(typeof window>"u")return;window[$]=Z}function _O($){let Y=H$("__STX_STORES__",{})[$];if(!Y)throw Error(`Store "${$}" not found. Make sure it's defined with defineStore().`);return Y}function oS($){return _O($)}function tS($,Z=5000){return new Promise((Y,X)=>{let J=Date.now(),Q=()=>{let G=_O($);if(G)Y(G);else if(Date.now()-J>Z)X(Error(`Timeout waiting for store "${$}"`));else requestAnimationFrame(Q)};Q()})}function zO(){return H$("__STX_ROUTE_PARAMS__",{})}function BO($){return zO()[$]}function eS($){let Z=BO($);if(Z===void 0)throw Error(`Route parameter "${$}" not found`);return Z}function qO(){return H$("__STX_MIDDLEWARE_STATE__",{})}function $C($){return qO()[$]}function ZC(){if(typeof window>"u")return;if(!H$("__STX_STORES__",null))lY("__STX_STORES__",{})}function YC($,Z){let Y=H$("__STX_STORES__",{});Y[$]=Z,lY("__STX_STORES__",Y)}function XC(){return H$("__STX_STORE_STATE__",null)}function JC($){lY("__STX_ROUTE_PARAMS__",$)}function QC($){lY("__STX_MIDDLEWARE_STATE__",$)}function jO(){return typeof window>"u"}function HO(){return typeof window<"u"}function GC($){if(HO())$()}function KC($){if(jO())$()}async function LO($){try{let Z=await Bun.file($).text(),Y=WC(Z),X=UC(Z,$),J=_C(Z,Y),Q=zC(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 WC($){let Z=$.split(`
|
|
12965
12965
|
`),Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),J=(Y?Y[1]:"").split(`
|
|
12966
12966
|
`).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,z=($.match(/@(?:layout|extends)\(/g)||[]).length,B=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++,B=Math.max(B,q);else if(/@end(?:if|unless|foreach|for|while|section)\b/.test(O))q--;let j=B>=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:z,scriptLines:J,complexity:H}}function UC($,Z){let Y=[],X=OO($,"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=OO($,"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((z)=>!z.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(`
|
|
12967
|
-
`).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 _C($,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 zC($,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 OO($,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 KG($=["**/*.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 LO(Q);Y.push(G)}catch(G){console.warn(`Failed to analyze ${Q}:`,G)}let J=BC(Y);return{results:Y,summary:J}}function BC($){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 VO($,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(qC.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 WG($){let Z=[],Y=[],X=[],J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let G=VO(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 qC;var UG=D(()=>{qC=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/});import _G from"path";import{extractLayoutMetadata as B8}from"stx-router/layout-metadata";function OC(){if(U8!==null)return U8;try{let{getRouterScript:$}=$0("stx-router");U8=`<script>${$()}</script>`}catch{U8=""}return U8}async function zG($,Z){if(Z===!1)return null;if(Z&&typeof Z==="string"){let X=_G.resolve($,Z);if(await Bun.file(X).exists())return X;return null}let Y=_G.join($,"app.stx");if(await Bun.file(Y).exists())return Y;return null}async function pY($,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=WG(Y),G=[...Q.client.map((A)=>A.fullTag),...Q.signals.map((A)=>A.fullTag)],K=[],W=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,U;while((U=W.exec(Y))!==null)K.push(U[0]);let _=X;for(let A of Q.server)_=_.replace(A.fullTag,"");for(let A of Q.client)_=_.replace(A.fullTag,"");_=_.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let z="<!--__STX_PAGE_SLOT__-->";if(_=_.replace(/<slot\s*\/>/gi,z).replace(/<slot\s*>\s*<\/slot>/gi,z),!_.includes(z))return console.warn(`[stx] Shell ${$} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:B,extractVariables:q,defaultConfig:j,loadStxConfig:H}=await Promise.resolve().then(() => (
|
|
12967
|
+
`).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 _C($,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 zC($,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 OO($,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 KG($=["**/*.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 LO(Q);Y.push(G)}catch(G){console.warn(`Failed to analyze ${Q}:`,G)}let J=BC(Y);return{results:Y,summary:J}}function BC($){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 VO($,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(qC.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 WG($){let Z=[],Y=[],X=[],J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let G=VO(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 qC;var UG=D(()=>{qC=/\b(?:state|derived|effect|batch|ref|reactive|computed|watch|watchEffect)\s*(?:<[^>]*>)?\s*\(/});import _G from"path";import{extractLayoutMetadata as B8}from"stx-router/layout-metadata";function OC(){if(U8!==null)return U8;try{let{getRouterScript:$}=$0("stx-router");U8=`<script>${$()}</script>`}catch{U8=""}return U8}async function zG($,Z){if(Z===!1)return null;if(Z&&typeof Z==="string"){let X=_G.resolve($,Z);if(await Bun.file(X).exists())return X;return null}let Y=_G.join($,"app.stx");if(await Bun.file(Y).exists())return Y;return null}async function pY($,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=WG(Y),G=[...Q.client.map((A)=>A.fullTag),...Q.signals.map((A)=>A.fullTag)],K=[],W=/<style\b[^>]*>([\s\S]*?)<\/style>/gi,U;while((U=W.exec(Y))!==null)K.push(U[0]);let _=X;for(let A of Q.server)_=_.replace(A.fullTag,"");for(let A of Q.client)_=_.replace(A.fullTag,"");_=_.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let z="<!--__STX_PAGE_SLOT__-->";if(_=_.replace(/<slot\s*\/>/gi,z).replace(/<slot\s*>\s*<\/slot>/gi,z),!_.includes(z))return console.warn(`[stx] Shell ${$} has no <slot /> \u2014 pages won't be injected`),null;let{processDirectives:B,extractVariables:q,defaultConfig:j,loadStxConfig:H}=await Promise.resolve().then(() => (B6(),p6)),O=await H(),V={__filename:$,__dirname:_G.dirname($)};for(let A of G){let N=A.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(N&&!A.includes("client")&&!A.includes('type="module"'))await q(N[1],V,$)}let L=await B(_,V,$,{...j,...O,...Z},new Set),F=L.indexOf(z);if(F===-1)return console.warn("[stx] Shell slot placeholder lost during processing"),null;return{beforeSlot:L.substring(0,F),afterSlot:L.substring(F+z.length),filePath:$,shellScripts:G,shellStyles:K}}catch(Y){return console.error(`[stx] Error processing shell ${$}:`,Y),null}}function _8($,Z,Y){let X,J="",Q=Z.match(HC);if(Q){Z=Z.replace(Q[0],"");try{let _=Buffer.from(Q[1],"base64").toString("utf8"),z=_.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(z)X=z[1].trim();J=_.replace(/<title[^>]*>[\s\S]*?<\/title>/i,"").trim()}catch{}}let G=Y||X||"stx App",K=OC(),W="<script>window.__stxRouterConfig={container:'[data-stx-content]'};</script>";return`<!DOCTYPE html>
|
|
12968
12968
|
<html lang="en">
|
|
12969
12969
|
<head>
|
|
12970
12970
|
<meta charset="UTF-8">
|
|
@@ -13075,7 +13075,7 @@ Build complete!
|
|
|
13075
13075
|
<p>Redirecting to <a href="${$}">${$}</a>...</p>
|
|
13076
13076
|
<script>window.location.replace('${$}')</script>
|
|
13077
13077
|
</body>
|
|
13078
|
-
</html>`}function fC($,Z){if($==="/"||$==="")return A0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return A0.join(Z.outputDir,Y,"index.html");return A0.join(Z.outputDir,`${Y}.html`)}var gC;var CO=D(()=>{q8();W1();NO();i0();e1();cY();gC={generateStaticSite:TO,createISRHandler:IO,defineStaticPaths:DO,createMarkdownLoader:kO}});import{createHash as hC}from"crypto";import{getRouterScript as dC}from"stx-router";function HG($){return hC("sha256").update($).digest("hex").slice(0,8)}function OG($=!1){let Z=$?
|
|
13078
|
+
</html>`}function fC($,Z){if($==="/"||$==="")return A0.join(Z.outputDir,"index.html");let Y=$.replace(/^\/|\/$/g,"");if(Z.trailingSlash)return A0.join(Z.outputDir,Y,"index.html");return A0.join(Z.outputDir,`${Y}.html`)}var gC;var CO=D(()=>{q8();W1();NO();i0();e1();cY();gC={generateStaticSite:TO,createISRHandler:IO,defineStaticPaths:DO,createMarkdownLoader:kO}});import{createHash as hC}from"crypto";import{getRouterScript as dC}from"stx-router";function HG($){return hC("sha256").update($).digest("hex").slice(0,8)}function OG($=!1){let Z=$?b6():w7(),Y=HG(Z);return{content:Z,filename:`runtime.${Y}.js`,hash:Y}}function LG(){let $=dC(),Z=HG($);return{content:$,filename:`router.${Z}.js`,hash:Z}}function uC($){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 VG=D(()=>{T5()});import bO from"path";import{createHash as mC}from"crypto";function cC($={}){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 FG($,Z,Y={}){let X=bO.resolve($),J=await Bun.file(X).text(),Q=mC("sha256").update(J).digest("hex").slice(0,16);oX();let G={};try{G=await m0()}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:_}=cC({__filename:X,__dirname:bO.dirname(X)}),z=new Set,B={...O1,...G,...Y,buildMode:"compile",strict:!1},q=await U0(J,_,X,B,z),j=M4(q),H=tX();return{route:Z,sourceFile:$,html:q,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(z),contentHash:Q,streamTemplates:_.__streamTemplates}}var AG=D(()=>{W1();i0();m$();O$()});import NG from"fs";import PO from"path";function wG($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function RG($,Z){let Y=PO.join(Z,"manifest.json");NG.writeFileSync(Y,JSON.stringify($,null,2))}function MG($){let Z=PO.join($,"manifest.json");if(!NG.existsSync(Z))return null;try{let Y=NG.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 nY=()=>{};var xO={};e(xO,{buildForProduction:()=>yO});import K4 from"fs";import Q1 from"path";function pC($,Z){let Y=0,X=0;if(!K4.existsSync($))return{copied:Y,bytes:X};function J(Q,G){let K=K4.readdirSync(Q,{withFileTypes:!0});for(let W of K){if(lC.has(W.name))continue;let U=Q1.join(Q,W.name),_=Q1.join(G,W.name);if(W.isDirectory())K4.mkdirSync(_,{recursive:!0}),J(U,_);else if(W.isFile()){if(K4.existsSync(_))continue;K4.copyFileSync(U,_),Y++,X+=K4.statSync(_).size}}}return J($,Z),{copied:Y,bytes:X}}async function yO($={}){let Z=Date.now(),Y=Q1.resolve($.root||process.cwd()),X=Q1.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let J={};try{J=await m0()}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(K4.existsSync(X))K4.rmSync(X,{recursive:!0});let z=[Q1.join(X,"public","__stx"),Q1.join(X,"public","assets"),Q1.join(X,"server","pages"),Q1.join(X,"server","fragments")];for(let R of z)K4.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let B=T4(Y),q=["components","layouts","partials"],j=B.filter((R)=>{return!q.some((T)=>R.pattern.startsWith(`/${T}/`)||R.pattern===`/${T}`)});console.log(`[stx build] Found ${j.length} page routes (${B.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=OG($.debug),O=LG();await Bun.write(Q1.join(X,"public","__stx",H.filename),H.content),await Bun.write(Q1.join(X,"public","__stx",O.filename),O.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${O.filename} (${(O.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let V=[],L=[];for(let R of j)try{let T=await FG(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(V.push(T),T.html=T.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,O.filename),T.html=j7(T.html,U,{bodyScripts:[`<script src="/__stx/${O.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(T.html)){let x=T.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(x&&x[1]){let P=x[1];T.html=T.html.replace(" "+P,""),T.html=T.html.replace(/<body([^>]*)>/,`<body$1 ${P}>`)}}T.html=T.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),T.html=await S0(T.html),T.fragment=z8(T.html,_);let I=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),k=Q1.join("server","pages",`${I}.compiled.json`),S=Q1.join("server","fragments",`${I}.html`);await Bun.write(Q1.join(X,k),JSON.stringify(T,null,2)),await Bun.write(Q1.join(X,S),T.fragment),L.push({pattern:R.pattern,compiledPath:k,fragmentPath:S,isDynamic:T.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(T){console.error(`[stx build] \u2717 ${R.pattern}:`,T instanceof Error?T.message:T)}let F=Q1.resolve(Y,W);if(K4.existsSync(F)){let{copied:R,bytes:T}=pC(F,Q1.join(X,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(T/1024).toFixed(1)}KB) from ${W}/`)}let A={runtime:H.filename,router:O.filename},N=wG(L,A,X);RG(N,X);let w=Date.now()-Z;return console.log(`
|
|
13079
13079
|
[stx build] Done in ${w}ms \u2014 ${V.length} pages compiled`),{pageCount:V.length,assets:A,outputDir:X,duration:w}}var lC;var TG=D(()=>{q8();VG();AG();nY();O$();e1();i0();lC=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});var fO={};e(fO,{buildApp:()=>vO});import iC from"path";async function vO($={}){let Z=performance.now(),Y=$.root||process.cwd(),X=await m0(),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(() => (CO(),SO));Q=await W({pagesDir:iC.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(() => (TG(),xO));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 EG=D(()=>{i0()});import rY from"path";async function rC($){let Z=performance.now(),Y=await m0($),X=$||Y.root||process.cwd(),J=[Y.build?.pagesDir||Y.pagesDir||"pages",Y.componentsDir||"components",Y.layoutsDir||"layouts",Y.partialsDir||"partials"].map((K)=>rY.resolve(X,K)),Q=[],G=0;for(let K of J){let W=await hO(K);for(let U of W){G++;let _=await Bun.file(U).text();if(gO.test(_))Q.push(rY.relative(X,U))}}return{mode:Q.length>0?"ssr":"ssg",serverScriptFiles:Q,totalFilesScanned:G,scanDurationMs:Math.round(performance.now()-Z)}}async function aC($){let Z=await m0($),Y=$||Z.root||process.cwd(),X=rY.resolve(Y,Z.componentsDir||"components"),J=[],Q=await hO(X);for(let G of Q){let K=await Bun.file(G).text(),W=gO.test(K),U=nC.test(K)||/<script\b(?![^>]*\bserver\b)[^>]*>/i.test(K)&&!W;if(W&&U){let _=rY.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 hO($){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 gO,nC;var dO=D(()=>{i0();gO=/<script\b[^>]*\bserver\b/i,nC=/<script\b[^>]*\bclient\b/i});function IG($){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(`
|
|
13080
13080
|
`,X.index-1);if(mO.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 cO($,Z=[]){let Y=IG($),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 mO.filter((J)=>!X.has(J))}function lO($){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${oC(Q)} } from './${Q}'`);let J=$.filter((Q)=>!Q.startsWith("end")).map((Q)=>` '${Q}': true`).join(`,
|
|
13081
13081
|
`);return`// Tree-shaken directive bundle
|
|
@@ -14045,28 +14045,28 @@ const features = [
|
|
|
14045
14045
|
})();
|
|
14046
14046
|
</script>
|
|
14047
14047
|
</body>
|
|
14048
|
-
</html>`}var XP;var iG=D(()=>{XP={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 nL={};e(nL,{startInteractive:()=>iL});import L8 from"fs";import
|
|
14048
|
+
</html>`}var XP;var iG=D(()=>{XP={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 nL={};e(nL,{startInteractive:()=>iL});import L8 from"fs";import q6 from"path";import*as pL from"readline";function UP($,Z){let Y=$.split(" "),X=Y[0];if(Y.length===1)return Object.keys(i6).filter((J)=>J.startsWith(X));if(["render","cat","load","cd"].includes(X)){let J=Y.slice(1).join(" "),Q=q6.dirname(J)||".",G=q6.basename(J),K=q6.resolve(Z.cwd,Q);if(L8.existsSync(K)&&L8.statSync(K).isDirectory())try{return L8.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 iL($={}){let Z={context:$.context||{},cwd:$.cwd||process.cwd(),history:[],running:!0,lastResult:null},Y=pL.createInterface({input:process.stdin,output:process.stdout,completer:(J)=>{return[UP(J,Z),J]},historySize:$.maxHistory||100});console.log(`
|
|
14049
14049
|
${f.bold}${f.blue}stx Interactive Mode${f.reset}
|
|
14050
14050
|
${f.dim}Type 'help' for available commands, 'exit' to quit${f.reset}
|
|
14051
|
-
`);let X=()=>{let J=Z.cwd.replace(process.env.HOME||"","~");Y.question(`${f.cyan}stx${f.reset} ${f.dim}${J}${f.reset} ${f.green}>${f.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&&
|
|
14052
|
-
${f.dim}(Use 'exit' to quit)${f.reset}`),X()}),X()}var f,
|
|
14051
|
+
`);let X=()=>{let J=Z.cwd.replace(process.env.HOME||"","~");Y.question(`${f.cyan}stx${f.reset} ${f.dim}${J}${f.reset} ${f.green}>${f.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&&i6[W])try{await i6[W].handler(U,Z)}catch(_){console.log(`${f.red}Error:${f.reset}`,_)}else if(W)if(G.includes("{{")||G.includes("}}"))try{let _=await j1(G,Z.context,"eval");console.log(`${f.green}\u2192${f.reset} ${_}`)}catch{console.log(`${f.red}Unknown command: ${W}${f.reset}`),console.log(`${f.dim}Type 'help' for available commands${f.reset}`)}else console.log(`${f.red}Unknown command: ${W}${f.reset}`),console.log(`${f.dim}Type 'help' for available commands${f.reset}`);if(Z.running)X();else Y.close()})};Y.on("SIGINT",()=>{console.log(`
|
|
14052
|
+
${f.dim}(Use 'exit' to quit)${f.reset}`),X()}),X()}var f,i6;var nG=D(()=>{o0();W1();f={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"},i6={help:{description:"Show available commands",usage:"help [command]",handler:async($,Z)=>{if($[0]&&i6[$[0]]){let Y=i6[$[0]];console.log(`
|
|
14053
14053
|
${f.bold}${$[0]}${f.reset} - ${Y.description}`),console.log(` Usage: ${f.cyan}${Y.usage}${f.reset}
|
|
14054
14054
|
`)}else{console.log(`
|
|
14055
14055
|
${f.bold}Available Commands:${f.reset}
|
|
14056
|
-
`);for(let[Y,X]of Object.entries(
|
|
14056
|
+
`);for(let[Y,X]of Object.entries(i6))console.log(` ${f.cyan}${Y.padEnd(12)}${f.reset} ${X.description}`);console.log(`
|
|
14057
14057
|
${f.dim}Type 'help <command>' for more details${f.reset}
|
|
14058
|
-
`)}}},render:{description:"Render a template file",usage:"render <file> [--raw]",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a file to render${f.reset}`);return}let Y=
|
|
14058
|
+
`)}}},render:{description:"Render a template file",usage:"render <file> [--raw]",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a file to render${f.reset}`);return}let Y=q6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${f.red}Error: File not found: ${Y}${f.reset}`);return}try{let X=await Bun.file(Y).text(),J=$.includes("--raw");console.log(`
|
|
14059
14059
|
${f.dim}Rendering ${Y}...${f.reset}
|
|
14060
14060
|
`);let Q=await U0(X,Z.context,Y,{},new Set);if(Z.lastResult=Q,J)console.log(Q);else Q.split(`
|
|
14061
14061
|
`).forEach((K,W)=>{let U=String(W+1).padStart(3," ");console.log(`${f.dim}${U}${f.reset} ${K}`)});console.log()}catch(X){console.log(`${f.red}Error rendering template:${f.reset}`,X)}}},eval:{description:"Evaluate an expression",usage:"eval <expression>",handler:async($,Z)=>{if(!$.length){console.log(`${f.red}Error: Please provide an expression to evaluate${f.reset}`);return}let Y=$.join(" ");try{let X=`{{ ${Y} }}`,Q=(await j1(X,Z.context,"eval")).trim();Z.lastResult=Q,console.log(`${f.green}\u2192${f.reset} ${Q}`)}catch(X){console.log(`${f.red}Error:${f.reset}`,X)}}},set:{description:"Set a context variable",usage:"set <key> <value>",handler:async($,Z)=>{if($.length<2){console.log(`${f.red}Error: Usage: set <key> <value>${f.reset}`);return}let Y=$[0],X=$.slice(1).join(" "),J;try{J=JSON.parse(X)}catch{J=X}Z.context[Y]=J,console.log(`${f.green}\u2713${f.reset} ${Y} = ${JSON.stringify(J)}`)}},unset:{description:"Remove a context variable",usage:"unset <key>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a variable to remove${f.reset}`);return}if($[0]in Z.context)delete Z.context[$[0]],console.log(`${f.green}\u2713${f.reset} Removed ${$[0]}`);else console.log(`${f.yellow}Variable not found: ${$[0]}${f.reset}`)}},context:{description:"Show current context variables",usage:"context",handler:async($,Z)=>{let Y=Object.keys(Z.context);if(Y.length===0){console.log(`${f.dim}Context is empty${f.reset}`);return}console.log(`
|
|
14062
14062
|
${f.bold}Context Variables:${f.reset}
|
|
14063
|
-
`);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(` ${f.cyan}${X}${f.reset} ${f.dim}(${Q})${f.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(`${f.green}\u2713${f.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.cyan}${Z.cwd}${f.reset}`);return}let Y=
|
|
14063
|
+
`);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(` ${f.cyan}${X}${f.reset} ${f.dim}(${Q})${f.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(`${f.green}\u2713${f.reset} Context cleared`);if($[0]==="screen"||!$[0])console.clear()}},cd:{description:"Change working directory",usage:"cd <directory>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.cyan}${Z.cwd}${f.reset}`);return}let Y=q6.resolve(Z.cwd,$[0]);if(!L8.existsSync(Y)){console.log(`${f.red}Error: Directory not found: ${Y}${f.reset}`);return}if(!L8.statSync(Y).isDirectory()){console.log(`${f.red}Error: Not a directory: ${Y}${f.reset}`);return}Z.cwd=Y,console.log(`${f.green}\u2713${f.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(`${f.dim}No files found${f.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(`
|
|
14064
14064
|
${f.bold}Templates:${f.reset}`),Q.forEach((W)=>console.log(` ${f.green}${W}${f.reset}`));if(G.length>0)console.log(`
|
|
14065
14065
|
${f.bold}Markdown:${f.reset}`),G.forEach((W)=>console.log(` ${f.blue}${W}${f.reset}`));if(K.length>0)console.log(`
|
|
14066
|
-
${f.bold}Other:${f.reset}`),K.forEach((W)=>console.log(` ${f.dim}${W}${f.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a file${f.reset}`);return}let Y=
|
|
14067
|
-
`);console.log(),J.forEach((Q,G)=>{let K=String(G+1).padStart(3," ");console.log(`${f.dim}${K}${f.reset} ${Q}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a JSON file${f.reset}`);return}let Y=
|
|
14066
|
+
${f.bold}Other:${f.reset}`),K.forEach((W)=>console.log(` ${f.dim}${W}${f.reset}`));console.log()}},cat:{description:"Show file contents",usage:"cat <file>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a file${f.reset}`);return}let Y=q6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${f.red}Error: File not found: ${Y}${f.reset}`);return}let J=(await Bun.file(Y).text()).split(`
|
|
14067
|
+
`);console.log(),J.forEach((Q,G)=>{let K=String(G+1).padStart(3," ");console.log(`${f.dim}${K}${f.reset} ${Q}`)}),console.log()}},load:{description:"Load context from JSON file",usage:"load <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a JSON file${f.reset}`);return}let Y=q6.resolve(Z.cwd,$[0]);if(!await Bun.file(Y).exists()){console.log(`${f.red}Error: File not found: ${Y}${f.reset}`);return}try{let X=await Bun.file(Y).text(),J=JSON.parse(X);Z.context={...Z.context,...J},console.log(`${f.green}\u2713${f.reset} Loaded ${Object.keys(J).length} variables from ${$[0]}`)}catch(X){console.log(`${f.red}Error parsing JSON:${f.reset}`,X)}}},save:{description:"Save context to JSON file",usage:"save <file.json>",handler:async($,Z)=>{if(!$[0]){console.log(`${f.red}Error: Please specify a file name${f.reset}`);return}let Y=q6.resolve(Z.cwd,$[0]);try{await Bun.write(Y,JSON.stringify(Z.context,null,2)),console.log(`${f.green}\u2713${f.reset} Context saved to ${$[0]}`)}catch(X){console.log(`${f.red}Error saving file:${f.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(`${f.dim}No history${f.reset}`);return}console.log(),X.forEach((J,Q)=>{let G=String(Z.history.length-X.length+Q+1).padStart(3," ");console.log(`${f.dim}${G}${f.reset} ${J}`)}),console.log()}},exit:{description:"Exit interactive mode",usage:"exit",handler:async($,Z)=>{Z.running=!1,console.log(`
|
|
14068
14068
|
${f.dim}Goodbye!${f.reset}
|
|
14069
|
-
`)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async($,Z)=>
|
|
14069
|
+
`)}},quit:{description:"Exit interactive mode (alias for exit)",usage:"quit",handler:async($,Z)=>i6.exit.handler($,Z)}}});import{createHash as _P}from"crypto";import{existsSync as V8,mkdirSync as zP,readFileSync as rG,writeFileSync as BP,readdirSync as qP,statSync as jP}from"fs";import{basename as F8,dirname as E4,extname as A8,join as W4,relative as rL}from"path";import{gzipSync as HP}from"zlib";class eY{config;startTime=0;outputs=[];chunks=[];assets=[];warnings=[];errors=[];moduleGraph=new Map;assetHashes=new Map;constructor($){this.config={...aL,...$}}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=F8(Y,A8(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=A8(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=W4(this.config.outDir,K);this.ensureDir(E4(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 W4(E4($),"..",Z);return W4(E4($),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(V8(U)){let _=rG(U,"utf-8");X.push(`// Source: ${W[1]}
|
|
14070
14070
|
${_}`)}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(V8(U)){let _=rG(U,"utf-8");J.push(`/* Source: ${W[1]} */
|
|
14071
14071
|
${_}`)}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(`
|
|
14072
14072
|
|
|
@@ -14116,40 +14116,40 @@ ${_}`)}else this.warnings.push(`External stylesheet not found: ${U}`)}return""})
|
|
|
14116
14116
|
</table>
|
|
14117
14117
|
</body>
|
|
14118
14118
|
</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(`
|
|
14119
|
-
`)}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 _P("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(!V8($))zP($,{recursive:!0})}walkDir($,Z){if(!V8($))return;let Y=qP($,{withFileTypes:!0});for(let X of Y){let J=W4($,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 OP($){return new eY($).build()}function LP($){return new eY($)}function VP($){return{...aL,...$}}var aL;var sL=D(()=>{aL={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 FP($,Z={}){return(await oL($,Z)).html}async function aG($,Z={}){let{html:Y,context:X}=await oL($,Z),{extractStreamBoundaries:J}=await Promise.resolve().then(() => (n4(),
|
|
14119
|
+
`)}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 _P("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(!V8($))zP($,{recursive:!0})}walkDir($,Z){if(!V8($))return;let Y=qP($,{withFileTypes:!0});for(let X of Y){let J=W4($,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 OP($){return new eY($).build()}function LP($){return new eY($)}function VP($){return{...aL,...$}}var aL;var sL=D(()=>{aL={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 FP($,Z={}){return(await oL($,Z)).html}async function aG($,Z={}){let{html:Y,context:X}=await oL($,Z),{extractStreamBoundaries:J}=await Promise.resolve().then(() => (n4(),k6)),Q=J(X),G=$.streamTemplates;if(G&&Object.keys(G).length>0){let{processDirectives:K}=await Promise.resolve().then(() => (W1(),sZ)),{defaultConfig:W}=await Promise.resolve().then(() => (i0(),P3)),U=X.streamBoundaries||{},_={...W,autoShell:!1},z=Object.keys(G).map((q)=>({id:q,render:async()=>{let j=typeof U[q]==="function"?await U[q]():void 0;return K(G[q],{...X,$boundary:j},$.sourceFile,_,new Set)}})),B=new Set(z.map((q)=>q.id));Q=[...(Q||[]).filter((q)=>!B.has(q.id)),...z]}return{html:Y,boundaries:Q&&Q.length>0?Q:void 0}}async function oL($,Z){let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};if(!$.hasServerScripts&&!J5($.html))return{html:$.html,context:Y};for(let J of $.serverScriptContent)try{await I0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!J5($.html))return{html:$.html,context:Y};let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=X1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?P0(String(G)):"")}catch{X.set(J,"")}return{html:T3($.html,X),context:Y}}async function AP($,Z={}){if(!$.hasServerScripts&&!J5($.fragment))return $.fragment;let Y={__filename:$.sourceFile,__dirname:$.sourceFile.replace(/[/\\][^/\\]+$/,""),...Z};for(let J of $.serverScriptContent)try{await I0(J,Y,$.sourceFile)}catch(Q){console.warn(`[stx] Server script error in ${$.sourceFile}:`,Q)}if(!J5($.fragment))return $.fragment;let X=new Map;for(let[J,Q]of Object.entries($.placeholders))if(Q.expression)try{let G=X1(Q.expression,Y);if(Q.type==="raw")X.set(J,G!==void 0&&G!==null?String(G):"");else X.set(J,G!==void 0&&G!==null?P0(String(G)):"")}catch{X.set(J,"")}return T3($.fragment,X)}var sG=D(()=>{s4();o0();m$()});var $V={};e($V,{startProductionServer:()=>eL});import tL from"fs";import j6 from"path";var{serve:NP}=globalThis.Bun;async function eL($={}){let Z=j6.resolve($.outputDir||".output"),Y=$.port||3000,X=MG(Z);if(!X)console.error("[stx] No build manifest found. Run `stx build` first."),process.exit(1);console.log(`[stx] Production server loading ${X.routes.length} routes...`);let J=new Map,Q=new Map,G=new Map;for(let _ of X.routes)try{let z=j6.join(Z,_.compiledPath),B=JSON.parse(await Bun.file(z).text());J.set(_.pattern,B),G.set(_.pattern,B8(B.html));let q=j6.join(Z,_.fragmentPath);if(await Bun.file(q).exists())Q.set(_.pattern,await Bun.file(q).text())}catch(z){console.warn(`[stx] Failed to load route ${_.pattern}:`,z)}let K=new Map,W=[];for(let _ of X.routes)if(_.hasParams){let z=[],B=_.pattern.replace(/:([^/]+)/g,(q,j)=>{return z.push(j),"([^/]+)"});W.push({regex:new RegExp(`^${B}$`),route:_,paramNames:z})}else K.set(_.pattern,_);let U=NP({port:Y,async fetch(_){let B=new URL(_.url).pathname;if($.onRequest){let V=await $.onRequest(_);if(V)return V}if($.apiRoutes?.[B])return $.apiRoutes[B](_);if((_.method==="GET"||_.method==="HEAD")&&B!=="/"){let V=j6.resolve(Z,"public"),L;try{L=decodeURIComponent(B)}catch{L=B}if(!L.includes("\x00")){let F=j6.resolve(V,`.${L}`);if(F===V||F.startsWith(`${V}${j6.sep}`))try{if(tL.existsSync(F)&&tL.statSync(F).isFile()){let N=j6.extname(F).toLowerCase(),w=wP[N]||"application/octet-stream",R=B.startsWith("/__stx/")||/\.[0-9a-f]{8}\./.test(B);return new Response(Bun.file(F),{headers:{"Content-Type":w,"Cache-Control":R?"public, max-age=31536000, immutable":"public, max-age=3600"}})}}catch{}}}let q=_.headers.get("X-STX-Router")==="true",j=null,H={};if(j=K.get(B)||null,!j)for(let{regex:V,route:L,paramNames:F}of W){let A=B.match(V);if(A){j=L,F.forEach((N,w)=>{H[N]=A[w+1]});break}}if(!j){let V=K.get("/404")||null;if(V){let L=J.get(V.pattern);if(L)return new Response(L.html,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}if(q){let V=Q.get(j.pattern);if(V){let L=G.get(j.pattern);return new Response(V,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true",...L?{"X-STX-Layout":L.layout,"X-STX-Layout-Group":L.group}:{},"Cache-Control":"no-cache"}})}}let O=J.get(j.pattern);if(!O){let V=K.get("/500")||null;if(V){let L=J.get(V.pattern);if(L)return new Response(L.html,{status:500,headers:{"Content-Type":"text/html"}})}return new Response("Internal Server Error",{status:500})}if(!O.hasServerScripts&&Object.keys(O.placeholders).length===0)return new Response(O.html,{headers:{"Content-Type":"text/html","Cache-Control":"public, max-age=60"}});try{let{html:V,boundaries:L}=await aG(O,{params:H,request:_});if(L&&L.length>0){let{renderStreamingPage:F,streamToResponse:A}=await Promise.resolve().then(() => (n4(),k6));return A(F(V,L,{timeoutMs:30000}),{headers:{"Cache-Control":"no-cache"}})}return new Response(V,{headers:{"Content-Type":"text/html","Cache-Control":"no-cache"}})}catch(V){return console.error(`[stx] Hydration error for ${B}:`,V),new Response(O.html,{headers:{"Content-Type":"text/html"}})}}});return console.log(`[stx] Production server running at http://localhost:${Y}`),console.log(`[stx] Serving ${X.routes.length} routes (${J.size} pre-loaded)`),{port:Y,stop:()=>U.stop()}}var wP;var oG=D(()=>{nY();sG();O$();wP={".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 tG="f9c3713";import{existsSync as N8,mkdirSync as eG}from"fs";import{join as H6,dirname as RP}from"path";import{execSync as ZV}from"child_process";async function TP($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.template||"default",J=H6(process.cwd(),$);if(N8(J))return Y.success=!1,Y.message=`Directory ${$} already exists`,Y;try{eG(J,{recursive:!0});let Q=EP(X);for(let K of Q)eG(H6(J,K),{recursive:!0});let G=IP(X,$,Z);for(let[K,W]of Object.entries(G)){let U=H6(J,K);w8(RP(U)),await Bun.write(U,W),Y.files.push(K)}if(!Z.skipGit)try{ZV("git init",{cwd:J,stdio:"ignore"}),await Bun.write(H6(J,".gitignore"),dP()),Y.files.push(".gitignore")}catch{Y.errors.push("Failed to initialize git repository")}if(!Z.skipInstall){let K=Z.packageManager||Ky();try{console.log(`
|
|
14120
14120
|
Installing dependencies with ${K}...`),ZV(`${K} install`,{cwd:J,stdio:"inherit"})}catch{Y.errors.push("Failed to install dependencies")}}Y.message=`Created project: ${$}`,console.log(`
|
|
14121
14121
|
\u2705 ${Y.message}
|
|
14122
14122
|
|
|
14123
14123
|
Next steps:
|
|
14124
14124
|
cd ${$}
|
|
14125
14125
|
${Z.packageManager||"bun"} run dev
|
|
14126
|
-
`)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function EP($){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 IP($,Z,Y){let X={};if(X["package.json"]=vP(Z,$,Y),X["stx.config.ts"]=fP($,Y),X["README.md"]=hP(Z,$),Y.typescript!==!1)X["tsconfig.json"]=gP();switch($){case"minimal":X["src/index.stx"]=uP();break;case"blog":X["pages/index.stx"]=pP(),X["pages/[slug].stx"]=iP(),X["layouts/app.stx"]=nP(),X["components/PostCard.stx"]=rP();break;case"dashboard":X["pages/index.stx"]=aP(),X["pages/settings.stx"]=sP(),X["layouts/app.stx"]=oP(),X["components/Sidebar.stx"]=tP(),X["components/StatsCard.stx"]=eP(),X["src/stores/dashboard.ts"]=$y();break;case"landing":X["pages/index.stx"]=Zy(),X["layouts/app.stx"]=Yy(),X["src/sections/Hero.stx"]=Xy(),X["src/sections/Features.stx"]=Jy(),X["src/sections/Pricing.stx"]=Qy(),X["components/Button.stx"]=Gy();break;case"full":X["pages/index.stx"]=YV(),X["pages/about.stx"]=mP(),X["layouts/app.stx"]=XV(),X["components/Header.stx"]=JV(),X["components/Footer.stx"]=QV(),X["src/stores/app.ts"]=GV(),X["src/i18n/en.json"]=cP("en"),X["test/example.test.ts"]=lP();break;default:X["pages/index.stx"]=YV(),X["layouts/app.stx"]=XV(),X["components/Header.stx"]=JV(),X["components/Footer.stx"]=QV(),X["src/stores/app.ts"]=GV()}return X}async function DP($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"components",J=$K($),Q=
|
|
14126
|
+
`)}catch(Q){Y.success=!1,Y.message=`Failed to create project: ${Q}`}return Y}function EP($){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 IP($,Z,Y){let X={};if(X["package.json"]=vP(Z,$,Y),X["stx.config.ts"]=fP($,Y),X["README.md"]=hP(Z,$),Y.typescript!==!1)X["tsconfig.json"]=gP();switch($){case"minimal":X["src/index.stx"]=uP();break;case"blog":X["pages/index.stx"]=pP(),X["pages/[slug].stx"]=iP(),X["layouts/app.stx"]=nP(),X["components/PostCard.stx"]=rP();break;case"dashboard":X["pages/index.stx"]=aP(),X["pages/settings.stx"]=sP(),X["layouts/app.stx"]=oP(),X["components/Sidebar.stx"]=tP(),X["components/StatsCard.stx"]=eP(),X["src/stores/dashboard.ts"]=$y();break;case"landing":X["pages/index.stx"]=Zy(),X["layouts/app.stx"]=Yy(),X["src/sections/Hero.stx"]=Xy(),X["src/sections/Features.stx"]=Jy(),X["src/sections/Pricing.stx"]=Qy(),X["components/Button.stx"]=Gy();break;case"full":X["pages/index.stx"]=YV(),X["pages/about.stx"]=mP(),X["layouts/app.stx"]=XV(),X["components/Header.stx"]=JV(),X["components/Footer.stx"]=QV(),X["src/stores/app.ts"]=GV(),X["src/i18n/en.json"]=cP("en"),X["test/example.test.ts"]=lP();break;default:X["pages/index.stx"]=YV(),X["layouts/app.stx"]=XV(),X["components/Header.stx"]=JV(),X["components/Footer.stx"]=QV(),X["src/stores/app.ts"]=GV()}return X}async function DP($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"components",J=$K($),Q=H6(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{w8(X);let G=bP(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 kP($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"pages",J=$.toLowerCase().replace(/\s+/g,"-"),Q=H6(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{w8(X);let G=PP(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 SP($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"src/stores",J=Wy($),Q=H6(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{w8(X);let G=yP(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 CP($,Z={}){let Y={success:!0,message:"",files:[],errors:[]},X=Z.dir||"layouts",J=$.toLowerCase().replace(/\s+/g,"-"),Q=H6(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{w8(X);let G=xP(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 bP($,Z){let Y=[];if(Y.push(`{{-- Component: ${$} --}}`),Z.props!==!1)Y.push(`<script>
|
|
14127
14127
|
// Props
|
|
14128
14128
|
const title = props.title || '${$}'
|
|
14129
14129
|
const variant = props.variant || 'default'
|
|
14130
14130
|
</script>
|
|
14131
|
-
`);if(Y.push(`<div class="${
|
|
14131
|
+
`);if(Y.push(`<div class="${n6($)} ${n6($)}--{{ variant }}">
|
|
14132
14132
|
<h3>{{ title }}</h3>
|
|
14133
|
-
<div class="${
|
|
14133
|
+
<div class="${n6($)}__content">
|
|
14134
14134
|
{{ slot }}
|
|
14135
14135
|
</div>
|
|
14136
14136
|
</div>`),Z.styles!==!1)Y.push(`
|
|
14137
14137
|
<style scoped>
|
|
14138
|
-
.${
|
|
14138
|
+
.${n6($)} {
|
|
14139
14139
|
padding: 1rem;
|
|
14140
14140
|
border-radius: 8px;
|
|
14141
14141
|
background: #f8f9fa;
|
|
14142
14142
|
}
|
|
14143
14143
|
|
|
14144
|
-
.${
|
|
14144
|
+
.${n6($)}--primary {
|
|
14145
14145
|
border-left: 3px solid #3498db;
|
|
14146
14146
|
}
|
|
14147
14147
|
|
|
14148
|
-
.${
|
|
14148
|
+
.${n6($)}--success {
|
|
14149
14149
|
border-left: 3px solid #2ecc71;
|
|
14150
14150
|
}
|
|
14151
14151
|
|
|
14152
|
-
.${
|
|
14152
|
+
.${n6($)}__content {
|
|
14153
14153
|
margin-top: 0.5rem;
|
|
14154
14154
|
}
|
|
14155
14155
|
</style>`);return Y.join(`
|
|
@@ -14590,13 +14590,13 @@ describe('Example', () => {
|
|
|
14590
14590
|
</footer>
|
|
14591
14591
|
@yield('scripts')
|
|
14592
14592
|
</body>
|
|
14593
|
-
</html>`}function Xy(){return"<!-- Hero section -->"}function Jy(){return"<!-- Features -->"}function Qy(){return"<!-- Pricing -->"}function Gy(){return"<!-- Button -->"}function w8($){if(!N8($))eG($,{recursive:!0})}function Ky(){if(N8("bun.lockb"))return"bun";if(N8("pnpm-lock.yaml"))return"pnpm";if(N8("yarn.lock"))return"yarn";return"bun"}function $K($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function Wy($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function
|
|
14593
|
+
</html>`}function Xy(){return"<!-- Hero section -->"}function Jy(){return"<!-- Features -->"}function Qy(){return"<!-- Pricing -->"}function Gy(){return"<!-- Button -->"}function w8($){if(!N8($))eG($,{recursive:!0})}function Ky(){if(N8("bun.lockb"))return"bun";if(N8("pnpm-lock.yaml"))return"pnpm";if(N8("yarn.lock"))return"yarn";return"bun"}function $K($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toUpperCase())}function Wy($){return $.replace(/[-_\s]+(.)?/g,(Z,Y)=>Y?Y.toUpperCase():"").replace(/^./,(Z)=>Z.toLowerCase())}function n6($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}var MP;var KV=D(()=>{MP={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:Uy}=globalThis.Bun;import R8 from"fs";import O6 from"path";function _y($,Z=200,Y={}){return new Response($,{status:Z,headers:{"Content-Type":"text/html; charset=utf-8",...Y}})}async function WV($={}){let{port:Z=3000,root:Y=".",stxOptions:X={},watch:J=!0,onRequest:Q,routes:G={},middleware:K=[],on404:W,onError:U}=$,_=O6.resolve(Y),z=new Map;async function B(L){let F=R8.statSync(L),A=`${L}:${F.mtimeMs}`,N=z.get(A);if(N)return N.content;for(let C of z.keys())if(C.startsWith(`${L}:`)&&C!==A)z.delete(C);let w=await Bun.file(L).text(),R=w,T=w.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>/i);if(T&&T.index!==void 0){let C=T.index+T[0].length,h=1,m=C;while(m<w.length&&h>0){let r=w.indexOf("<template",m),o=w.indexOf("</template>",m);if(o===-1)break;if(r!==-1&&r<o)h++,m=r+9;else{if(h--,h===0){R=w.substring(C,o).trim();break}m=o+11}}}let E=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,I=[],k=[],S;while((S=E.exec(w))!==null){let C=S[1],h=S[2],m=S[0];if(C.includes("server"))k.push(h);else I.push(m)}let x=w.match(/<style\b[^>]*>[\s\S]*?<\/style>/gi)||[],P=R.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,""),b={__filename:L,__dirname:O6.dirname(L)};for(let C of k)await I0(C,b,L);let p=await U0(P,b,L,X,new Set);if(x.length>0){let C=x.join(`
|
|
14594
14594
|
`);if(p.match(/(<\/head>)/i))p=p.replace(/(<\/head>)/i,`${C}
|
|
14595
14595
|
$1`)}if(I.length>0){let{interpolateScriptsInTemplate:C}=await Promise.resolve().then(() => (o0(),p$)),h=C(I.join(`
|
|
14596
14596
|
`),b);if(p.match(/(<\/body>)/i))p=p.replace(/(<\/body>)/i,`${h}
|
|
14597
14597
|
$1`);else p+=`
|
|
14598
|
-
${h}`}return z.set(A,{content:p,mtime:F.mtimeMs}),p}async function q(L){let F=R8.statSync(L),A=`${L}:${F.mtimeMs}`,N=z.get(A);if(N)return N.content;let{content:w}=await F4(L,X);return z.set(A,{content:w,mtime:F.mtimeMs}),w}function j(L){let F=L.startsWith("/")?L.slice(1):L,A=[F,`${F}.stx`,`${F}.md`,`${F}.html`,
|
|
14599
|
-
${w instanceof Error?w.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(E,{status:500,headers:{"Content-Type":"text/html"}})}};for(let N=K.length-1;N>=0;N--){let w=K[N],R=A;A=async()=>await w(L,R)}return await A()}let O=Uy({port:Z,fetch:H}),V=null;if(J)V=R8.watch(_,{recursive:!0},(L,F)=>{if(F&&(F.endsWith(".stx")||F.endsWith(".md")||F.endsWith(".html")))z.clear()});return{server:O,url:O.url.toString(),stop(){if(V)V.close();O.stop()}}}async function zy($,Z={}){let Y=
|
|
14598
|
+
${h}`}return z.set(A,{content:p,mtime:F.mtimeMs}),p}async function q(L){let F=R8.statSync(L),A=`${L}:${F.mtimeMs}`,N=z.get(A);if(N)return N.content;let{content:w}=await F4(L,X);return z.set(A,{content:w,mtime:F.mtimeMs}),w}function j(L){let F=L.startsWith("/")?L.slice(1):L,A=[F,`${F}.stx`,`${F}.md`,`${F}.html`,O6.join(F,"index.stx"),O6.join(F,"index.md"),O6.join(F,"index.html")];for(let N of A){let w=O6.join(_,N);if(R8.existsSync(w)&&R8.statSync(w).isFile())return w}return null}async function H(L){let F=new URL(L.url),A=async()=>{if(G[F.pathname])return await G[F.pathname](L);if(Q){let w=await Q(L);if(w)return w}let N=j(F.pathname);if(!N){if(W)return await W(L);return new Response("Not Found",{status:404})}try{let w,R="text/html";if(N.endsWith(".stx"))w=await B(N);else if(N.endsWith(".md"))w=await q(N);else if(N.endsWith(".html"))w=await Bun.file(N).text();else if(N.endsWith(".css"))w=await Bun.file(N).text(),R="text/css";else if(N.endsWith(".js"))w=await Bun.file(N).text(),R="text/javascript";else if(N.endsWith(".json"))w=await Bun.file(N).text(),R="application/json";else return new Response(Bun.file(N));return new Response(w,{headers:{"Content-Type":R}})}catch(w){if(U)return await U(w,L);let R=w instanceof Error?w.message:String(w),E=X?.debug===!0?`<h1>Error</h1><pre>${R}
|
|
14599
|
+
${w instanceof Error?w.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An error occurred while processing your request.</p>";return new Response(E,{status:500,headers:{"Content-Type":"text/html"}})}};for(let N=K.length-1;N>=0;N--){let w=K[N],R=A;A=async()=>await w(L,R)}return await A()}let O=Uy({port:Z,fetch:H}),V=null;if(J)V=R8.watch(_,{recursive:!0},(L,F)=>{if(F&&(F.endsWith(".stx")||F.endsWith(".md")||F.endsWith(".html")))z.clear()});return{server:O,url:O.url.toString(),stop(){if(V)V.close();O.stop()}}}async function zy($,Z={}){let Y=O6.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 WV({...Z,root:O6.dirname(Y),routes:{"/":async()=>{let Q;if(X){let{content:G}=await F4(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(`
|
|
14600
14600
|
`),z=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),B={};if(_.trim())await I0(_,B,Y);let q=new Set;Q=await U0(z,B,Y,Z.stxOptions||{},q)}return new Response(Q,{headers:{"Content-Type":"text/html"}})},...Z.routes}})}function By($){return $}function qy($){return $}var UV=D(()=>{y5();W1();w0()});import{existsSync as jy,readFileSync as Hy}from"fs";class ZK{options;variables=new Map;errors=[];warnings=[];currentFile="";constructor($={}){if(this.options={...Oy,...$},this.options.includeBuiltins)Object.entries(_V).forEach(([Z,Y])=>{this.variables.set(Z,Y)});if(this.options.customTypes)Object.entries(this.options.customTypes).forEach(([Z,Y])=>{this.variables.set(Z,Y)})}checkFile($){if(this.currentFile=$,this.errors=[],this.warnings=[],!jy($))return this.errors.push({message:`File not found: ${$}`,file:$,line:0,column:0,expression:"",severity:"error"}),this.getResult();let Z=Hy($,"utf-8");return this.checkTemplate(Z,$)}checkTemplate($,Z="<inline>"){this.currentFile=Z,this.errors=[],this.warnings=[];let Y=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i);if(Y)this.analyzeScript(Y[1],$.indexOf(Y[0]));return this.checkDirectives($),this.checkExpressions($),this.getResult()}analyzeScript($,Z){let Y=$.split(`
|
|
14601
14601
|
`),X=this.getLineNumber(Z);for(let J=0;J<Y.length;J++){let Q=Y[J],G=X+J;this.extractTypedVariables(Q,G),this.extractInterfaces(Q,Y,J,G),this.extractTypeAliases(Q,G)}}extractTypedVariables($,Z){let Y=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*:\s*([^=]+?)\s*=/);if(Y){let[,Q,G]=Y,K=this.parseTypeAnnotation(G.trim());this.variables.set(Q,K);return}let X=$.match(/(?:export\s+)?(?:const|let|var)\s+(\w+)\s*=\s*(.+)/);if(X){let[,Q,G]=X,K=this.inferType(G.trim());this.variables.set(Q,K);return}let J=$.match(/(?:export\s+)?function\s+(\w+)\s*\(([^)]*)\)(?:\s*:\s*(\w+))?/);if(J){let[,Q,G,K]=J,W=this.parseParams(G),U=K?this.parseTypeAnnotation(K):{kind:"primitive",value:"any"};this.variables.set(Q,{kind:"function",params:W,returnType:U})}}extractInterfaces($,Z,Y,X){let J=$.match(/(?:export\s+)?interface\s+(\w+)\s*\{/);if(J){let[,Q]=J,G={},K=1,W=Y+1;while(W<Z.length&&K>0){let U=Z[W].trim();if(U.includes("{"))K++;if(U.includes("}"))K--;let _=U.match(/(\w+)\??\s*:\s*([^;]+)/);if(_&&K>0){let[,z,B]=_;G[z]=this.parseTypeAnnotation(B.trim())}W++}this.variables.set(Q,{kind:"object",name:Q,properties:G})}}extractTypeAliases($,Z){let Y=$.match(/(?:export\s+)?type\s+(\w+)\s*=\s*(.+)/);if(Y){let[,X,J]=Y,Q=this.parseTypeAnnotation(J.trim());Q.name=X,this.variables.set(X,Q)}}parseTypeAnnotation($){let Z=$.trim();if(Z.includes("|"))return{kind:"union",types:Z.split("|").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.includes("&"))return{kind:"intersection",types:Z.split("&").map((Q)=>this.parseTypeAnnotation(Q.trim()))};if(Z.endsWith("[]"))return{kind:"array",elementType:this.parseTypeAnnotation(Z.slice(0,-2))};let Y=Z.match(/^Array<(.+)>$/);if(Y)return{kind:"array",elementType:this.parseTypeAnnotation(Y[1])};if(Z.startsWith("{")&&Z.endsWith("}")){let J={},Q=Z.slice(1,-1).trim();if(Q){let G=this.splitByComma(Q);for(let K of G){let W=K.match(/(\w+)\??\s*:\s*(.+)/);if(W){let[,U,_]=W;J[U]=this.parseTypeAnnotation(_.trim())}}}return{kind:"object",properties:J}}if(Z.startsWith('"')||Z.startsWith("'"))return{kind:"literal",value:Z.slice(1,-1)};if(/^\d+$/.test(Z))return{kind:"literal",value:Z};if(Z==="true"||Z==="false")return{kind:"literal",value:Z};if(["string","number","boolean","null","undefined","any","unknown","void","never"].includes(Z))return{kind:"primitive",value:Z};if(this.variables.has(Z))return this.variables.get(Z);return{kind:"primitive",value:"any"}}inferType($){let Z=$.trim().replace(/;$/,"");if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return{kind:"primitive",value:"string"};if(/^-?\d+(\.\d+)?$/.test(Z))return{kind:"primitive",value:"number"};if(Z==="true"||Z==="false")return{kind:"primitive",value:"boolean"};if(Z==="null")return{kind:"primitive",value:"null"};if(Z==="undefined")return{kind:"primitive",value:"undefined"};if(Z.startsWith("[")){let Y=Z.slice(1,-1).trim();if(Y){let X=this.splitByComma(Y)[0];if(X)return{kind:"array",elementType:this.inferType(X.trim())}}return{kind:"array",elementType:{kind:"primitive",value:"any"}}}if(Z.startsWith("{")){let Y={},X=this.extractObjectLiteral(Z);for(let[J,Q]of Object.entries(X))Y[J]=this.inferType(Q);return{kind:"object",properties:Y}}if(Z.includes("=>")){let Y=Z.match(/^\(([^)]*)\)\s*(?::\s*(\w+))?\s*=>/);if(Y){let X=this.parseParams(Y[1]),J=Y[2]?this.parseTypeAnnotation(Y[2]):{kind:"primitive",value:"any"};return{kind:"function",params:X,returnType:J}}}if(/^\w+$/.test(Z)&&this.variables.has(Z))return this.variables.get(Z);if(Z.includes("."))return this.resolvePropertyAccess(Z);if(Z.includes("(")){let Y=Z.split("(")[0],X=this.variables.get(Y);if(X?.kind==="function"&&X.returnType)return X.returnType}return{kind:"primitive",value:"any"}}parseParams($){if(!$.trim())return[];let Z=[],Y=this.splitByComma($);for(let X of Y){let J=X.trim(),Q=J.includes("?"),G=J.match(/(\w+)\??\s*(?::\s*([^=]+))?(?:\s*=)?/);if(G){let[,K,W]=G,U=W?this.parseTypeAnnotation(W.trim()):{kind:"primitive",value:"any"};Z.push({name:K,type:U,optional:Q})}}return Z}checkExpressions($){let Z=/\{\{([\s\S]*?)\}\}/g,Y;while((Y=Z.exec($))!==null){let J=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!J)continue;if(J.startsWith("!")||J.endsWith("!"))continue;this.checkExpression(J,G,K)}let X=/\{!!([\s\S]*?)!!\}/g;while((Y=X.exec($))!==null){let J=Y[1].trim(),Q=Y.index,G=this.getLineNumber(Q,$),K=this.getColumn(Q,$);if(!J)continue;this.checkExpression(J,G,K)}}checkExpression($,Z,Y){if($.includes("?")&&$.includes(":")){let Q=$.split("?");this.checkExpression(Q[0].trim(),Z,Y);let G=Q.slice(1).join("?").split(":");if(G.length>=2)this.checkExpression(G[0].trim(),Z,Y),this.checkExpression(G.slice(1).join(":").trim(),Z,Y);return}for(let Q of["&&","||","??"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}for(let Q of["===","!==","==","!=",">=","<=",">","<"])if($.includes(Q)){$.split(Q).forEach((K)=>this.checkExpression(K.trim(),Z,Y));return}if($.startsWith("!")){this.checkExpression($.slice(1).trim(),Z,Y);return}if(this.isLiteral($))return;let X=$.match(/^(\w+(?:\.\w+)*)\s*\(/);if(X){let Q=X[1],G=this.resolvePropertyAccess(Q);if(G.kind!=="function"&&G.value!=="any")this.addWarning(`'${Q}' is not a function`,Z,Y,$);return}if($.includes(".")){if(this.resolvePropertyAccess($).value==="undefined"&&this.options.checkPropertyAccess)this.addWarning(`Property access '${$}' may be undefined`,Z,Y,$);return}let J=$.match(/^\w+/)?.[0];if(J&&!this.variables.has(J))this.addError(`Variable '${J}' is not defined`,Z,Y,$)}checkDirectives($){let Z=/@if\s*\(([^)]+)\)/g,Y;while((Y=Z.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let X=/@foreach\s*\((\w+)\s+(?:as|in)\s+(\w+)(?:\s*,\s*(\w+))?\)/g;while((Y=X.exec($))!==null){let[,G,K,W]=Y,U=Y.index,_=this.getLineNumber(U,$),z=this.getColumn(U,$);if(!this.variables.has(G))this.addError(`Collection '${G}' is not defined`,_,z,Y[0]);else{let B=this.variables.get(G);if(B.kind==="array"&&B.elementType)this.variables.set(K,B.elementType);else this.variables.set(K,{kind:"primitive",value:"any"});if(W)this.variables.set(W,{kind:"primitive",value:"number"})}}let J=/@unless\s*\(([^)]+)\)/g;while((Y=J.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}let Q=/@switch\s*\(([^)]+)\)/g;while((Y=Q.exec($))!==null){let G=Y[1].trim(),K=Y.index,W=this.getLineNumber(K,$),U=this.getColumn(K,$);this.checkExpression(G,W,U)}}resolvePropertyAccess($){let Z=$.split("."),Y=this.variables.get(Z[0])||{kind:"primitive",value:"any"};for(let X=1;X<Z.length;X++){let J=Z[X].replace(/\(\)$/,"");if(Y.kind==="object"&&Y.properties)if(Y.properties[J])Y=Y.properties[J];else if(!this.options.allowAny)return{kind:"primitive",value:"undefined"};else Y={kind:"primitive",value:"any"};else if(Y.kind==="array"&&Y.elementType)if(["length"].includes(J))Y={kind:"primitive",value:"number"};else if(["map","filter","find","forEach","some","every","reduce"].includes(J))Y={kind:"function",returnType:{kind:"primitive",value:"any"}};else if(["join"].includes(J))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else Y={kind:"primitive",value:"any"};else if(Y.kind==="primitive"&&Y.value==="string")if(["length"].includes(J))Y={kind:"primitive",value:"number"};else if(["toUpperCase","toLowerCase","trim","slice","substring"].includes(J))Y={kind:"function",returnType:{kind:"primitive",value:"string"}};else if(["split"].includes(J))Y={kind:"function",returnType:{kind:"array",elementType:{kind:"primitive",value:"string"}}};else Y={kind:"primitive",value:"any"};else Y={kind:"primitive",value:"any"}}return Y}isLiteral($){let Z=$.trim();if(Z.startsWith('"')&&Z.endsWith('"')||Z.startsWith("'")&&Z.endsWith("'")||Z.startsWith("`")&&Z.endsWith("`"))return!0;if(/^-?\d+(\.\d+)?$/.test(Z))return!0;if(Z==="true"||Z==="false")return!0;if(Z==="null"||Z==="undefined")return!0;return!1}extractObjectLiteral($){let Z={},Y=$.slice(1,-1).trim();if(!Y)return Z;let X=this.splitByComma(Y);for(let J of X){let Q=J.indexOf(":");if(Q>0){let G=J.slice(0,Q).trim(),K=J.slice(Q+1).trim();Z[G]=K}}return Z}splitByComma($){let Z=[],Y="",X=0,J=null;for(let Q=0;Q<$.length;Q++){let G=$[Q],K=Q>0?$[Q-1]:"";if((G==='"'||G==="'"||G==="`")&&K!=="\\"){if(J===G)J=null;else if(!J)J=G}if(!J){if(G==="{"||G==="["||G==="(")X++;if(G==="}"||G==="]"||G===")")X--;if(G===","&&X===0){Z.push(Y.trim()),Y="";continue}}Y+=G}if(Y.trim())Z.push(Y.trim());return Z}getLineNumber($,Z){return((Z||"").slice(0,$).match(/\n/g)||[]).length+1}getColumn($,Z){let X=Z.slice(0,$).lastIndexOf(`
|
|
14602
14602
|
`);return $-X}addError($,Z,Y,X,J,Q){this.errors.push({message:$,file:this.currentFile,line:Z,column:Y,expression:X,expected:J,received:Q,severity:"error"})}addWarning($,Z,Y,X,J,Q){let G={message:$,file:this.currentFile,line:Z,column:Y,expression:X,expected:J,received:Q,severity:"warning"};if(this.options.strict)this.errors.push(G);else this.warnings.push(G)}getResult(){return{valid:this.errors.length===0,errors:this.errors,warnings:this.warnings,variables:new Map(this.variables)}}addVariable($,Z){this.variables.set($,Z)}reset(){if(this.errors=[],this.warnings=[],this.variables.clear(),this.options.includeBuiltins)Object.entries(_V).forEach(([$,Z])=>{this.variables.set($,Z)})}}function YK($){return new ZK($)}function Ly($,Z){return YK(Z).checkFile($)}function Vy($,Z){return YK(Z).checkTemplate($)}function Fy($){let Z=[];for(let Y of $.errors){if(Z.push(`\x1B[31merror\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");if(Y.expected&&Y.received)Z.push(` expected: ${Y.expected}`),Z.push(` received: ${Y.received}`);Z.push("")}for(let Y of $.warnings){if(Z.push(`\x1B[33mwarning\x1B[0m: ${Y.message}`),Z.push(` --> ${Y.file}:${Y.line}:${Y.column}`),Y.expression)Z.push(" |"),Z.push(` | ${Y.expression}`),Z.push(" |");Z.push("")}if($.valid)Z.push("\x1B[32m\u2713 No type errors found\x1B[0m");else Z.push(`\x1B[31m\u2717 Found ${$.errors.length} error(s) and ${$.warnings.length} warning(s)\x1B[0m`);return Z.join(`
|
|
@@ -14631,7 +14631,7 @@ ${w instanceof Error?w.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An err
|
|
|
14631
14631
|
0% { transform: translateX(-100%); }
|
|
14632
14632
|
100% { transform: translateX(100%); }
|
|
14633
14633
|
}
|
|
14634
|
-
`,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function $X($,Z){if(!w$||!A1)return;if(U4=Math.min(Math.max($,0),100),QK)cancelAnimationFrame(QK);QK=requestAnimationFrame(()=>{if(!A1)return;A1.style.opacity=U4>0?"1":"0",A1.style.transform=`scaleX(${U4/100})`})}function wy($){if(!w$)return;if(M8=!0,U4=0,!A1)A1=qV($);if(N$)clearTimeout(N$);if(I4)clearInterval(I4);$X(10,$),I4=setInterval(()=>{if(!M8)return;let Z=90-U4,Y=Math.max(0.5,Z*0.1);if(U4<90)$X(U4+Y,$)},$.throttle)}function Ry($){if(!w$)return;if(M8=!1,I4)clearInterval(I4),I4=null;$X(100,$),N$=setTimeout(()=>{if(A1)A1.style.opacity="0";setTimeout(()=>{if(U4=0,A1)A1.style.transform="scaleX(0)"},300)},200)}function My(){if(!w$)return;if(M8=!1,U4=0,I4)clearInterval(I4),I4=null;if(N$)clearTimeout(N$),N$=null;if(A1)A1.style.opacity="0",A1.style.transform="scaleX(0)"}function jV($){let Z={...GK,...$};return{start:()=>wy(Z),set:(Y)=>$X(Y,Z),finish:()=>Ry(Z),clear:()=>My(),get state(){return{isLoading:M8,progress:U4,error:!1}}}}function Ty($){if(!w$)return;if(
|
|
14634
|
+
`,document.head.appendChild(Q)}return document.body.appendChild(Y),Y}function $X($,Z){if(!w$||!A1)return;if(U4=Math.min(Math.max($,0),100),QK)cancelAnimationFrame(QK);QK=requestAnimationFrame(()=>{if(!A1)return;A1.style.opacity=U4>0?"1":"0",A1.style.transform=`scaleX(${U4/100})`})}function wy($){if(!w$)return;if(M8=!0,U4=0,!A1)A1=qV($);if(N$)clearTimeout(N$);if(I4)clearInterval(I4);$X(10,$),I4=setInterval(()=>{if(!M8)return;let Z=90-U4,Y=Math.max(0.5,Z*0.1);if(U4<90)$X(U4+Y,$)},$.throttle)}function Ry($){if(!w$)return;if(M8=!1,I4)clearInterval(I4),I4=null;$X(100,$),N$=setTimeout(()=>{if(A1)A1.style.opacity="0";setTimeout(()=>{if(U4=0,A1)A1.style.transform="scaleX(0)"},300)},200)}function My(){if(!w$)return;if(M8=!1,U4=0,I4)clearInterval(I4),I4=null;if(N$)clearTimeout(N$),N$=null;if(A1)A1.style.opacity="0",A1.style.transform="scaleX(0)"}function jV($){let Z={...GK,...$};return{start:()=>wy(Z),set:(Y)=>$X(Y,Z),finish:()=>Ry(Z),clear:()=>My(),get state(){return{isLoading:M8,progress:U4,error:!1}}}}function Ty($){if(!w$)return;if(r6)r6(),r6=null;let Z={...GK,...$},Y=jV(Z);A1=qV(Z);let X=!1,J=(_)=>{let B=_.target.closest("a");if(!B)return;let q=B.getAttribute("href");if(!q)return;if(q.startsWith("http")||q.startsWith("#")||q.startsWith("mailto:")||q.startsWith("tel:")||B.target==="_blank"||B.hasAttribute("download"))return;X=!0,Y.start()},Q=()=>{if(!X)Y.start(),X=!0},G=()=>{if(X||Z.autoFinish)Y.finish(),X=!1};document.addEventListener("click",J),window.addEventListener("popstate",Q),window.addEventListener("load",G);let K=window.fetch,W=0,U=async function(..._){let z=typeof _[0]==="string"?_[0]:_[0].url,B=z.includes("/api/")||z.startsWith("/api");if(B){if(W++,W===1&&!X)Y.start()}try{return await K.apply(this,_)}finally{if(B){if(W--,W===0&&!X)Y.finish()}}};window.fetch=U,r6=()=>{if(document.removeEventListener("click",J),window.removeEventListener("popstate",Q),window.removeEventListener("load",G),window.fetch===U)window.fetch=K}}function Ey(){if(r6)r6(),r6=null}function Iy($){let Z={...GK,...$},Y=Z.initialColor?`linear-gradient(to right, ${Z.initialColor}, ${Z.color})`:Z.color;return`
|
|
14635
14635
|
<div id="stx-loading-indicator" style="
|
|
14636
14636
|
position: fixed;
|
|
14637
14637
|
top: 0;
|
|
@@ -14725,7 +14725,7 @@ ${w instanceof Error?w.stack:""}</pre>`:"<h1>Internal Server Error</h1><p>An err
|
|
|
14725
14725
|
window.addEventListener('load', function() { window.stxLoading.finish(); });
|
|
14726
14726
|
})();
|
|
14727
14727
|
</script>
|
|
14728
|
-
`}var w$,GK,A1=null,U4=0,M8=!1,QK=null,N$=null,I4=null,
|
|
14728
|
+
`}var w$,GK,A1=null,U4=0,M8=!1,QK=null,N$=null,I4=null,r6=null;var HV=D(()=>{w$=typeof window<"u"&&typeof document<"u",GK={color:"#6366f1",initialColor:"",height:"3px",duration:2000,throttle:200,autoFinish:!0,zIndex:999999}});var KK=`
|
|
14729
14729
|
<script data-stx-helpers>
|
|
14730
14730
|
(function() {
|
|
14731
14731
|
'use strict'
|
|
@@ -16330,7 +16330,7 @@ else {
|
|
|
16330
16330
|
})();
|
|
16331
16331
|
`.trim()}var ay;var zW=D(()=>{ay={method:"POST",fieldName:"file",timeout:60000,withCredentials:!1}});function BW(){return{script:[k8(),C8(),P8()].join(`
|
|
16332
16332
|
|
|
16333
|
-
`),css:b8()}}function rV(){let{script:$,css:Z}=BW(),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 aV=D(()=>{ZW();KW();zW();ZW();KW();zW()});var sV=D(()=>{
|
|
16333
|
+
`),css:b8()}}function rV(){let{script:$,css:Z}=BW(),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 aV=D(()=>{ZW();KW();zW();ZW();KW();zW()});var sV=D(()=>{J6();JY()});var ty;var oV=D(()=>{yV();qQ();bQ();CQ();vV();hV();aV();sV();ty={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 qX from"fs";import a6 from"path";async function qW($,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:a6.dirname($),props:Z,...Z};if(Q)await I0(Q,K,$);let W={...O1,...Y};return await U0(G,K,$,W,new Set)}async function tV($){let Z=performance.now(),Y={success:!0,views:[],errors:[],duration:0},{viewsDir:X,outputDir:J,componentsDir:Q=a6.join(X,"components"),layoutsDir:G=a6.join(X,"layouts"),partialsDir:K=a6.join(X,"partials"),globalProps:W={},placeholders:U={},views:_,debug:z=!1,generateManifest:B=!0}=$;if(z)console.log("Building STX views..."),console.log(` Source: ${X}`),console.log(` Output: ${J}`);qX.mkdirSync(J,{recursive:!0});let q={componentsDir:Q,layoutsDir:G,partialsDir:K,debug:z},j;if(_&&_.length>0)j=_;else j=qX.readdirSync(X).filter((O)=>O.endsWith(".stx")).map((O)=>({input:O}));for(let H of j){let O=a6.join(X,H.input),V=H.output||H.input.replace(/\.stx$/,".html"),L=a6.join(J,V);if(z)console.log(` Building ${H.input}...`);try{let F={...W,...H.props,...U},A=await qW(O,F,q);await Bun.write(L,A),Y.views.push(V)}catch(F){let A=F instanceof Error?F.message:String(F);if(Y.errors.push({file:H.input,error:A}),Y.success=!1,z)console.error(` Error: ${A}`)}}if(B){let H={buildTime:new Date().toISOString(),views:Y.views,placeholders:U,errors:Y.errors.length>0?Y.errors:void 0};await Bun.write(a6.join(J,"manifest.json"),JSON.stringify(H,null,2))}if(Y.duration=performance.now()-Z,z)if(Y.success)console.log(`
|
|
16334
16334
|
\u2705 Built ${Y.views.length} views in ${Y.duration.toFixed(0)}ms`);else console.log(`
|
|
16335
16335
|
\u26A0\uFE0F Built ${Y.views.length} views with ${Y.errors.length} errors`);return Y}function ey($,Z){let Y=qX.watch($.viewsDir,{recursive:!0},async(X,J)=>{if(!J)return;if(J.endsWith(".stx")||J.endsWith(".ts")||J.endsWith(".js")){if($.debug)console.log(`
|
|
16336
16336
|
File changed: ${J}, rebuilding...`);let Q=await tV($);Z?.(Q)}});return{close:()=>Y.close()}}async function $x($,Z={},Y={}){let X={...Y,skipDefaultSeoTags:!0,skipSignalsRuntime:!0},J=await qW($,Z,X);J=await Zx(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,`
|
|
@@ -16339,7 +16339,7 @@ File changed: ${J}, rebuilding...`);let Q=await tV($);Z?.(Q)}});return{close:()=
|
|
|
16339
16339
|
`).replace(/<\/(p|div|h[1-6]|li|tr)>/gi,`
|
|
16340
16340
|
`).replace(/<\/td>/gi,"\t").replace(/<[^>]*>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/©/g,"(c)").replace(/·/g,"-").replace(/\n\s*\n\s*\n/g,`
|
|
16341
16341
|
|
|
16342
|
-
`).trim()}var eV=D(()=>{
|
|
16342
|
+
`).trim()}var eV=D(()=>{s4();i0();W1()});function Jx($){return $.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}function Qx($){let Z={};for(let Y of Object.keys($))if(!Y.startsWith("__"))Z[Y]=$[Y];return Z}function Gx($){let{template:Z,context:Y={},title:X="stx App"}=$,J=Qx(Y),Q=Jx(JSON.stringify(J));return`<!DOCTYPE html>
|
|
16343
16343
|
<html lang="en">
|
|
16344
16344
|
<head>
|
|
16345
16345
|
<meta charset="UTF-8">
|
|
@@ -16424,7 +16424,7 @@ File changed: ${J}, rebuilding...`);let Q=await tV($);Z?.(Q)}});return{close:()=
|
|
|
16424
16424
|
return refs;
|
|
16425
16425
|
};
|
|
16426
16426
|
})();
|
|
16427
|
-
`}var a1=null,jX;var jW=D(()=>{jX=new Map});function Wx($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function HW($){return $.replace(/&/g,"&").replace(/"/g,""")}function HF($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[BF($)];return $.flat(1/0).map(BF).filter((Z)=>Z!=="")}function BF($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function
|
|
16427
|
+
`}var a1=null,jX;var jW=D(()=>{jX=new Map});function Wx($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function HW($){return $.replace(/&/g,"&").replace(/"/g,""")}function HF($){if($==null||typeof $==="boolean")return[];if(!Array.isArray($))return[BF($)];return $.flat(1/0).map(BF).filter((Z)=>Z!=="")}function BF($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return $;if(typeof $==="number")return String($);return $}function t6($,Z,Y){let{children:X,ref:J,key:Q,...G}=Z||{};return{type:$,props:Object.keys(G).length>0?G:null,children:HF(X),key:Y??Q??void 0,ref:J??void 0}}function VF($){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 OW($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map(OW).join(" ");if(typeof $==="object"&&$!==null)return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return""}function Ux($){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=jF[Y]||Y;if(J==="class"||J==="className"){let Q=OW(X);if(Q)Z.push(` class="${HW(Q)}"`);continue}if(J==="style"){let Q=typeof X==="string"?X:VF(X);if(Q)Z.push(` style="${HW(Q)}"`);continue}if(qF.has(J)){if(X)Z.push(` ${J}`);continue}if(X!=null&&X!==!1)Z.push(` ${J}="${HW(String(X))}"`)}return Z.join("")}function s6($){if($==null||typeof $==="boolean")return"";if(typeof $==="string")return Wx($);if(typeof $==="number")return String($);if(Array.isArray($))return $.map(s6).join("");if($.type===o6)return $.children.map(s6).join("");if(typeof $.type==="function"){let Q=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});return s6(Q)}let Z=$.type,Y=Ux($.props),X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)return`<${Z}${Y}>${X}</${Z}>`;if(Kx.has(Z))return`<${Z}${Y}>`;let J=$.children.map(s6).join("");return`<${Z}${Y}>${J}</${Z}>`}function FF($){return new ReadableStream({start(Z){Z.enqueue(s6($)),Z.close()}})}function _x($,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=jF[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=OW(X);if(Q)$.setAttribute("class",Q);continue}if(J==="style"){let Q=typeof X==="string"?X:VF(X);if(Q)$.setAttribute("style",Q);continue}if(qF.has(J)){if(X)$.setAttribute(J,"");continue}if(X!=null&&X!==!1)$.setAttribute(J,String(X))}}function E$($,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 $)E$(J,Z);return}if($.type===o6){for(let J of $.children)E$(J,Z);return}if(typeof $.type==="function"){let J=$.type({...$.props,children:$.children.length===1?$.children[0]:$.children.length>0?$.children:void 0});E$(J,Z);return}let Y=document.createElement($.type);_x(Y,$.props);let X=$.props?.innerHTML??$.props?.dangerouslySetInnerHTML?.__html;if(X!=null)Y.innerHTML=X;else for(let J of $.children)E$(J,Y);if($.ref){if(typeof $.ref==="function")$.ref(Y)}Z.appendChild(Y)}function AF($){if($.when)return t6(o6,{children:$.children});return $.fallback??null}function NF($){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 t6(o6,{children:X})}function wF($){return t6(o6,{children:$.children})}function RF($,Z,...Y){let{key:X,ref:J,...Q}=Z||{};return{type:$,props:Object.keys(Q).length>0?Q:{},children:HF(Y.length===1?Y[0]:Y),key:X??void 0,ref:J??void 0}}var o6,Kx,qF,jF,OF,LF;var MF=D(()=>{o6=Symbol.for("stx.Fragment"),Kx=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),qF=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"]),jF={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"};OF=t6,LF=t6});function LW($,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 HX(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 TF($){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 EF=D(()=>{jW()});import{dirname as zx,resolve as IF}from"path";function Bx($){let Z=$,Y=$.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>/i);if(Y&&Y.index!==void 0){let _=Y.index+Y[0].length,z=1,B=_;while(z>0&&B<$.length){let q=$.indexOf("<template",B),j=$.indexOf("</template>",B);if(j===-1)break;if(q!==-1&&q<j){let H=$[q+9];if(H===">"||H===" "||H===`
|
|
16428
16428
|
`||H==="\t")z++;B=q+9}else{if(z--,z===0){Z=$.slice(_,j).trim();break}B=j+11}}}let X=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,J=[],Q=[],G=[],K=(_)=>/\b(?:state|derived|effect|batch)\s*(?:<[^<>()]*>)?\s*\(/.test(_),W;while((W=X.exec($))!==null){let _=W[1],z=W[2],B=W[0],q=_.includes("server");if(K(z))G.push(B);else if(q)Q.push(z);else J.push(B)}let U=Z;{let _=/<script\b(?![^>]*\b(?:client|type\s*=\s*["']module["']|src\s*=))[^>]*>/gi,z,B=[];while((z=_.exec(U))!==null){let q=z.index+z[0].length,j=1,H=q;while(H<U.length&&j>0){let O=U.indexOf("<script",H),V=U.indexOf("</script>",H);if(V===-1)break;if(O!==-1&&O<V)j++,H=O+7;else{if(j--,j===0){B.push({start:z.index,end:V+9});break}H=V+9}}}for(let q=B.length-1;q>=0;q--)U=U.substring(0,B[q].start)+U.substring(B[q].end)}for(let _ of J)U=U.replace(_,"");return{templateContent:U,serverScripts:Q,clientScripts:J,signalsScripts:G}}function qx($,Z){return`<!DOCTYPE html>
|
|
16429
16429
|
<html lang="en">
|
|
16430
16430
|
<head>
|
|
@@ -16440,7 +16440,7 @@ ${Q.join(`
|
|
|
16440
16440
|
`)}`}else{if(Y.processClientScripts!==!1&&Q.length>0){let _=K.__stx_event_bindings||[],z=P4(K),q=(await Promise.all(Q.map(async(H)=>{let O=H.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!O)return H;return await y4(O[1],{eventBindings:_,templateContent:U,serverData:z})}))).join(`
|
|
16441
16441
|
`);if(U.match(/(<\/body>)/i))U=U.replace(/(<\/body>)/i,`${q}
|
|
16442
16442
|
$1`);else U+=`
|
|
16443
|
-
${q}`}U=await O4(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=qx(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:_}=await Promise.resolve().then(() => (e1(),b3));U=await _(U)}catch{}return U}var DF=D(()=>{i0();
|
|
16443
|
+
${q}`}U=await O4(U)}if(Y.wrapInDocument){if(!U.trim().toLowerCase().startsWith("<!doctype")&&!U.trim().toLowerCase().startsWith("<html"))U=qx(U,Y.title)}if(Y.injectCSS)try{let{injectCrosswindCSS:_}=await Promise.resolve().then(() => (e1(),b3));U=await _(U)}catch{}return U}var DF=D(()=>{i0();s4();W1();M6()});import I$ from"fs";import L6 from"path";function kF($){try{return I$.statSync($).mtimeMs}catch{return null}}function LX($,Z){let Y=Math.max(0,Math.round((Z-$)/1000));if(Y<60)return`${Y}s ago`;if(Y<3600)return`${Math.round(Y/60)}m ago`;return`${Math.round(Y/3600)}h ago`}function Ox($,Z){try{return globalThis.Bun?.resolveSync($,Z)??null}catch{return null}}function VW($,Z="stx"){let Y=L6.resolve($);for(let X=0;X<10;X++){let J=L6.join(Y,"pantry","@stacksjs",Z);if(I$.existsSync(J))return J;let Q=L6.dirname(Y);if(Q===Y)break;Y=Q}return null}async function VX($={}){let Z=$.cwd?L6.resolve($.cwd):process.cwd(),Y=$.resolve??Ox,X=Date.now(),J=[],Q=Y("@stacksjs/stx",Z);J.push(Q?{name:"@stacksjs/stx resolves to",status:"ok",detail:Q}:{name:"@stacksjs/stx resolves to",status:"info",detail:"not resolvable from here (running inside the stx repo, or not installed)"});let G=Y("bun-plugin-stx",Z);if(G)J.push({name:"bun-plugin-stx resolves to",status:"ok",detail:G});let K=VW(Z,"stx");if(!K)J.push({name:"pantry",status:"info",detail:"no pantry/@stacksjs/stx found \u2014 standard install (nothing to rebuild)"});else{let W=L6.join(K,"src/signals.ts"),U=[L6.join(K,"dist/index.js"),L6.join(K,"dist/signals.js")].find((j)=>I$.existsSync(j))||null,_=kF(W),z=U?kF(U):null;if(_==null)J.push({name:"pantry dist freshness",status:"info",detail:`found pantry at ${K} but no src/signals.ts to compare`});else if(z==null)J.push({name:"pantry dist freshness",status:"error",detail:"pantry has src but no built dist \u2014 the dev server will resolve nothing (or a stale copy elsewhere)",fix:`cd ${K} && bun build.ts`});else if(z<_){let j=Math.round((_-z)/1000);J.push({name:"pantry dist freshness",status:"error",detail:`dist (${LX(z,X)}) is OLDER than src/signals.ts (${LX(_,X)}) by ${j}s \u2014 your edit isn't built`,fix:`cd ${K} && bun build.ts`})}else J.push({name:"pantry dist freshness",status:"ok",detail:`dist rebuilt after src (src ${LX(_,X)}, dist ${LX(z,X)})`});let B=L6.join(Z,"node_modules/@stacksjs/stx"),q=null;try{q=I$.lstatSync(B)}catch{q=null}if(!q)J.push({name:"node_modules \u2192 pantry",status:"info",detail:"node_modules/@stacksjs/stx not present (not installed here)"});else if(q.isSymbolicLink()){let j=null;try{j=I$.realpathSync(B)}catch{}let H=(()=>{try{return I$.realpathSync(K)}catch{return K}})();J.push(j===H?{name:"node_modules \u2192 pantry",status:"ok",detail:"symlinked to pantry"}:{name:"node_modules \u2192 pantry",status:"warn",detail:`symlinked to ${j||"(dangling)"}, not pantry`})}else J.push({name:"node_modules \u2192 pantry",status:"warn",detail:"is a real directory, NOT symlinked to pantry \u2014 edits to pantry src/dist won't be resolved",fix:"rm -rf node_modules/@stacksjs/stx && ln -s ../../pantry/@stacksjs/stx node_modules/@stacksjs/stx"})}if(J.push({name:"dev runtime cache",status:"info",detail:"cleared automatically on source edits by the dev watcher (clearDevCaches, #1745 item C)"}),$.generateRuntime)try{let U=$.generateRuntime().length;J.push(U>1000?{name:"signals runtime",status:"ok",detail:`generated ${U.toLocaleString()} chars`}:{name:"signals runtime",status:"warn",detail:`generated only ${U} chars \u2014 suspiciously short`})}catch(W){J.push({name:"signals runtime",status:"error",detail:`failed to generate: ${W.message}`})}return{checks:J,ok:!J.some((W)=>W.status==="error")}}function FX($){let Z={ok:"\u2713",warn:"\u26A0",error:"\u2717",info:"\xB7"},Y=["stx runtime resolution:"];for(let X of $.checks)if(Y.push(` ${Z[X.status]} ${X.name}: ${X.detail}`),X.fix)Y.push(` \u2192 ${X.fix}`);return Y.push(""),Y.push($.ok?"\u2713 All framework-runtime layers are aligned.":"\u2717 A runtime layer is stale \u2014 see the fixes above."),Y.join(`
|
|
16444
16444
|
`)}var FW=()=>{};function y8($,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",z=J.locale??"en_US",B=[];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":"";B.push(`<link rel="icon"${O?` type="${O}"`:""} href="${z1(J.favicon)}">`)}if(B.push(`<title>${Lx(Q)}</title>`,`<link rel="canonical" href="${z1(W)}">`,`<meta name="description" content="${z1(G)}">`,`<meta property="og:title" content="${z1(Q)}">`,`<meta property="og:description" content="${z1(G)}">`,`<meta property="og:type" content="${z1(_)}">`,`<meta property="og:url" content="${z1(W)}">`,`<meta property="og:site_name" content="${z1(U)}">`,`<meta property="og:locale" content="${z1(z)}">`,`<meta name="twitter:card" content="${K?"summary_large_image":"summary"}">`,`<meta name="twitter:title" content="${z1(Q)}">`,`<meta name="twitter:description" content="${z1(G)}">`),K)B.push(`<meta property="og:image" content="${z1(K)}">`),B.push(`<meta name="twitter:image" content="${z1(K)}">`);if(J.twitter)B.push(`<meta name="twitter:site" content="@${z1(J.twitter.replace(/^@/,""))}">`),B.push(`<meta name="twitter:creator" content="@${z1(J.twitter.replace(/^@/,""))}">`);let q=`<!-- SEO -->
|
|
16445
16445
|
${B.join(`
|
|
16446
16446
|
`)}
|
|
@@ -16470,10 +16470,10 @@ ${Q}`}var D$=null;function f8($,Z){if(Z.theme===!1)return $;let Y=typeof Z.theme
|
|
|
16470
16470
|
${J.slice(K)}`;return`${$.slice(0,X)}${z}${$.slice(Y)}`}function rx($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function IW($){return $}var yF=D(()=>{e1();RW()});var xF=D(()=>{yF();RW()});function ox($){return $.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function tx($){let Z=[],Y=/<(script|style)\b[^>]*>[\s\S]*?<\/\1\s*>/gi,X;while((X=Y.exec($))!==null)Z.push([X.index,X.index+X[0].length]);return Z}function ex($,Z){for(let[Y,X]of $)if(Z>=Y&&Z<X)return!0;return!1}function c8($,Z){let Y=1,X=0;for(let J=0;J<Z&&J<$.length;J++)if($[J]===`
|
|
16471
16471
|
`)Y++,X=J+1;return{line:Y,column:Z-X+1}}function $v($,Z,Y){let X=Z.toLowerCase(),J=$.length,Q=1,G=Y;while(G<J){let K=$.indexOf("<",G);if(K===-1)return-1;if(G=K,$.startsWith("<!--",G)){let _=$.indexOf("-->",G+4);if(_===-1)return-1;G=_+3;continue}if($[G+1]==="/"){let _=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(G,G+64));if(!_){G++;continue}if(_[1].toLowerCase()===X){if(Q--,G+=_[0].length,Q===0)return G;continue}G+=_[0].length;continue}let W=/^<([a-z][\w-]*)\b/i.exec($.slice(G,G+64));if(!W){G++;continue}let U=$.indexOf(">",G);if(U===-1)return-1;if(W[1].toLowerCase()===X&&$[U-1]!=="/")Q++;G=U+1}return-1}function Zv($,Z,Y){let X=/@([a-z][\w:-]*)((?:\.[a-z][\w-]*)*)\s*=\s*"([^"]*)"/gi,J;while((J=X.exec($))!==null){if(ex(Z,J.index))continue;let Q=J[1].toLowerCase().split(":")[0];if(ax.has(Q))continue;let G=J[3].trim();if(/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(G)){let K=$.indexOf(J[3],J.index),{line:W,column:U}=c8($,K<0?J.index:K);Y.push({ruleId:"stx/no-bare-function-ref-in-event",message:`Event handler @${J[1]}="${G}" is a bare reference and will not fire. Call it: @${J[1]}="${G}()".`,line:W,column:U,severity:"error"})}}}function Yv($,Z,Y){if(Z!=="view")return;let X=/<script\b([^>]*)>/gi,J;while((J=X.exec($))!==null)if(/(?:^|\s)client(?=[\s/=]|$)/i.test(J[1])){let{line:Q,column:G}=c8($,J.index);Y.push({ruleId:"stx/no-view-level-script-client",message:"<script client> at the top level of a view is silently dropped \u2014 only components get client scopes. Move it into a component, or use <script> (server).",line:Q,column:G,severity:"error"})}}function vF($){let Z=$.split("/"),Y=[];for(let X of Z){if(X===""||X===".")continue;if(X==="..")Y.pop();else Y.push(X)}return Y.join("/")}function Xv($,Z,Y){let X=Z.replace(/\\/g,"/"),J=X.indexOf("resources/stores/");if(J===-1)return;let Q=X.slice(0,J+16),G=X.slice(0,X.lastIndexOf("/")),K=/\b(import|export)\s+(type\s+)?([^'"]*?)\s*from\s*['"]([^'"]+)['"]/g,W;while((W=K.exec($))!==null){if(W[2])continue;let U=W[1],_=W[4],z;if(_.startsWith("."))z=!vF(`${G}/${_}`).startsWith(vF(Q));else z=!0;if(z){let{line:B,column:q}=c8($,W.index),j=U==="export"?"Value re-export":"Value import";Y.push({ruleId:"stx/store-value-imports-must-be-local",message:`${j} from "${_}" is outside resources/stores/ and will be stripped from the store bundle. Use \`${U} type\`, or move the value into the stores dir.`,line:B,column:q,severity:"error"})}}}function Jv($){let Z=$.trim(),Y=(G)=>{let K=G.match(/[A-Za-z_$][\w$]*/g);return K?K:[]},X=/\bas\s+(.+)$/.exec(Z);if(X){let G=X[1].trim(),K=/^([A-Za-z_$][\w$]*)\s*=>\s*([A-Za-z_$][\w$]*)/.exec(G);if(K)return[K[1],K[2]];let W=/^\(([^)]*)\)/.exec(G);if(W)return Y(W[1]);let U=/^([A-Za-z_$][\w$]*)/.exec(G);return U?[U[1]]:[]}let J=/^\(([^)]*)\)\s+(?:in|of)\s+/.exec(Z);if(J)return Y(J[1]);let Q=/^([A-Za-z_$][\w$]*)\s+(?:in|of)\s+/.exec(Z);return Q?[Q[1]]:[]}function Qv($,Z){let Y=/(?::for|x-for|@for)\s*=\s*"([^"]*)"/gi,X;while((X=Y.exec($))!==null){let J=Jv(X[1]);if(J.length===0)continue;let Q=$.lastIndexOf("<",X.index);if(Q===-1)continue;let G=/^<([a-z][\w-]*)/i.exec($.slice(Q,Q+64));if(!G)continue;let K=$.indexOf(">",X.index);if(K===-1)continue;let U=$[K-1]==="/"||sx.has(G[1].toLowerCase())?K+1:$v($,G[1],K+1),_=U===-1?K+1:U,z=$.indexOf(X[1],X.index),B=$.slice(Q,_);if(z>=0&&z+X[1].length<=_){let q=z-Q;B=B.slice(0,q)+" ".repeat(X[1].length)+B.slice(q+X[1].length)}for(let q of J){let j=new RegExp(`(?<![.\\w$])${ox(q)}\\s*\\(`,"g"),H;while((H=j.exec(B))!==null){let O=Q+H.index,{line:V,column:L}=c8($,O);Z.push({ruleId:"stx/no-signal-call-in-for-iteration-var",message:`"${q}" is a :for iteration variable, not a signal \u2014 calling it as "${q}()" leaves it as a function and silently breaks comparisons. Use "${q}" directly.`,line:V,column:L,severity:"error"})}}}}function Gv($,Z){let Y=/<!--([\s\S]*?)-->/g,X;while((X=Y.exec($))!==null){let Q=X[1].indexOf("`");if(Q!==-1){let G=X.index+4+Q,{line:K,column:W}=c8($,G);Z.push({ruleId:"stx/no-backticks-in-html-comments",message:"Backtick inside an HTML comment leaks into the merged setup function and flips the JS parser into template-literal mode. Remove it or rephrase the comment.",line:K,column:W,severity:"error"})}}}function m8($,Z){return $?.[Z]!==!1}function fF($,Z={}){let Y=[],X=tx($),J=(Z.filePath??"").replace(/\\/g,"/"),Q=Z.fileKind??(/\/components?\//i.test(J)?"component":"view");if(m8(Z.rules,"stx/no-bare-function-ref-in-event"))Zv($,X,Y);if(m8(Z.rules,"stx/no-view-level-script-client"))Yv($,Q,Y);if(J&&m8(Z.rules,"stx/store-value-imports-must-be-local"))Xv($,J,Y);if(m8(Z.rules,"stx/no-signal-call-in-for-iteration-var"))Qv($,Y);if(m8(Z.rules,"stx/no-backticks-in-html-comments"))Gv($,Y);Y.sort((K,W)=>K.line-W.line||K.column-W.column);let G=new Set;return Y.filter((K)=>{let W=`${K.ruleId}:${K.line}:${K.column}`;if(G.has(W))return!1;return G.add(W),!0})}var ax,sx;var gF=D(()=>{ax=new Set(["if","else","elseif","else-if","for","foreach","show","model","html","text","bind","key","ref","once","memo","slot","teleport","cloak","pre","effect","init"]),sx=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"])});function hF($,Z){return $.kind===Z}var dF=()=>{};var uF=D(()=>{dF()});function mF($){if($===String)return"string";if($===Number)return"number";if($===Boolean)return"boolean";if($===Array)return"array";if($===Object)return"object";if($===Function)return"function";if($===Date)return"date";if($===Symbol)return"symbol";if(typeof $==="function"&&$.name)return $.name;return"unknown"}function Kv($,Z){if($===null||$===void 0)return!0;if(Z===String)return typeof $==="string";if(Z===Number)return typeof $==="number"&&!Number.isNaN($);if(Z===Boolean)return typeof $==="boolean";if(Z===Array)return Array.isArray($);if(Z===Object)return typeof $==="object"&&!Array.isArray($);if(Z===Function)return typeof $==="function";if(Z===Date)return $ instanceof Date;if(Z===Symbol)return typeof $==="symbol";if(typeof Z==="function")return $ instanceof Z;return!0}function cF($,Z,Y,X){let J=X?`[${X}]`:"";if(Y.required&&(Z===void 0||Z===null))return{prop:$,message:`${J} Missing required prop: "${$}"`,value:Z,expected:Y.type?mF(Y.type):void 0};if(Z===void 0||Z===null)return null;if(Y.type){let Q=Array.isArray(Y.type)?Y.type:[Y.type];if(!Q.some((K)=>Kv(Z,K))){let K=Q.map((W)=>mF(W)).join(" | ");return{prop:$,message:`${J} Invalid prop type for "${$}": expected ${K}, got ${typeof Z}`,value:Z,expected:K}}}if(Y.validator){if(!Y.validator(Z))return{prop:$,message:`${J} Custom validation failed for prop "${$}"`,value:Z}}return null}function lF($){let Z=globalThis.__STX_CURRENT_PROPS__||{};if(!$)return Z;let Y={...Z};for(let[X,J]of Object.entries($)){let Q=typeof J==="function"||Array.isArray(J)?{type:J}:J||{};if(Y[X]===void 0&&Q.default!==void 0)Y[X]=typeof Q.default==="function"?Q.default():Q.default}return Y}function pF($,Z={}){let{componentName:Y,throwOnError:X=!1,logWarnings:J=!0}=Z,Q=globalThis.__STX_CURRENT_PROPS__||{},G={...Q},K={valid:!0,errors:[],warnings:[]};for(let[W,U]of Object.entries($)){let _=typeof U==="function"||Array.isArray(U)?{type:U}:U||{};if(G[W]===void 0&&_.default!==void 0)G[W]=typeof _.default==="function"?_.default():_.default;let z=cF(W,G[W],_,Y);if(z){if(K.valid=!1,K.errors.push(z),J)console.warn(z.message)}}for(let W of Object.keys(Q))if(!(W in $)){let U=`${Y?`[${Y}]`:""} Unknown prop: "${W}"`;if(K.warnings.push(U),J)console.warn(U)}if(X&&!K.valid){let W=K.errors.map((U)=>U.message).join(`
|
|
16472
16472
|
`);throw Error(`Prop validation failed:
|
|
16473
|
-
${W}`)}return{props:G,validation:K}}function iF($,Z){let Y={...$};for(let[X,J]of Object.entries(Z))if(Y[X]===void 0)Y[X]=typeof J==="function"?J():J;return Y}function nF($){return $}function rF($){return{type:$,required:!0}}function aF($,Z){return{type:Z,default:$}}function sF($,Z={}){return{...Z,validator:$}}function oF($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function tF($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function eF($,Z={}){return{...Z,type:Object}}function $A($,Z,Y){if(!Z)return $;let X={};for(let[J,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[J];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=cF(J,K,G,Y);if(W)console.warn(W.message)}X[J]=K}for(let[J,Q]of Object.entries($))if(!(J in X))X[J]=Q;return X}var i6={};e(i6,{writeNetlifyConfig:()=>o7,writeManifest:()=>RG,writeImageManifest:()=>GG,wrapComponentForHMR:()=>ky,withDefaults:()=>iF,webComponentDirectiveHandler:()=>vQ,watermark:()=>PK,watchViews:()=>ey,watchMultiple:()=>SS,watchEffect:()=>CS,watch:()=>kS,waitForStore:()=>tS,waitForLocale:()=>vM,videoDirective:()=>m7,validators:()=>m3,validated:()=>sF,validateValueEnhanced:()=>Jz,validateTemplate:()=>Mj,validateParams:()=>fK,validateFormEnhanced:()=>TM,validateFile:()=>zX,validateFields:()=>RM,validateField:()=>Yz,validateDirective:()=>Ej,validateCspDirectives:()=>GM,validateConfig:()=>CH,validateComponentScripts:()=>aC,validateComponentProps:()=>eC,validateClientScript:()=>T7,usesSignalsInScript:()=>E6,userComponentFileExists:()=>I9,useVirtualList:()=>W2,useTitle:()=>i_,useStoreOrThrow:()=>oS,useStore:()=>SV,useSlots:()=>KF,useSeoMeta:()=>J7,useRouteParams:()=>zO,useRouteParamOrThrow:()=>eS,useRouteParam:()=>BO,usePageTitle:()=>i_,useOptimistic:()=>SB,useMiddlewareValue:()=>$C,useMiddlewareState:()=>qO,useLoadingIndicator:()=>jV,useHead:()=>l4,useAttrs:()=>UF,uploadFiles:()=>WW,uploadFile:()=>BX,updateInstance:()=>hS,untrack:()=>xZ,unregisterDirective:()=>HD,unmountInstance:()=>dS,unescapeHtml:()=>D3,transpileTypeScript:()=>v4,translate:()=>AX,transitionDirective:()=>j3,toUsers:()=>JL,toUser:()=>XL,thumbnail:()=>OK,thumbHashToRGBA:()=>S8,thumbHashToDataURL:()=>XW,templateCache:()=>o9,stxClientHelpers:()=>KK,structuredDataDirective:()=>MZ,stripLocalePrefix:()=>wW,stripDocumentWrapper:()=>M4,stringToStream:()=>fb,strictCspPreset:()=>y_,streamingSuspenseDirective:()=>oJ,streamToResponse:()=>wz,streamTemplateSimple:()=>Vz,streamTemplate:()=>jz,stopHmrServer:()=>K$,stopBroadcasting:()=>ZL,state:()=>O7,startProductionServer:()=>eL,startInteractive:()=>iL,startBroadcasting:()=>$L,staggerDirective:()=>zU,srcsetUrls:()=>xK,springDirective:()=>BU,splitByPipe:()=>c3,smartBatchSign:()=>dK,signUrl:()=>XX,shouldTranspileTypeScript:()=>x4,shouldReloadOnChange:()=>p7,shouldRefreshSignature:()=>KX,shouldIgnoreFile:()=>i7,shouldCacheComponent:()=>cq,sharpen:()=>AK,shape:()=>eF,setRouteParams:()=>JC,setMiddlewareState:()=>QC,setGlobalProvide:()=>HX,setErrorLocale:()=>Q_,setCurrentInstance:()=>MS,setCachedVideoResult:()=>a5,setCachedImageResult:()=>i5,setCached:()=>m5,serveStxFile:()=>l8,serveMultipleStxFiles:()=>p8,serveMarkdownFile:()=>DY,serveFile:()=>zy,serveApp:()=>i8,serve:()=>WV,serializeState:()=>VV,sepia:()=>wK,scrollAnimateDirective:()=>H3,screenReaderDirective:()=>q3,scopeHTML:()=>TH,scopeCSS:()=>MH,scanForSitemapEntries:()=>$E,scanA11yIssues:()=>dX,saturation:()=>EK,sanitizeParams:()=>gK,sanitizeFilePath:()=>A_,sanitizeExpression:()=>N_,sanitizeDirectiveParams:()=>w_,sanitizeDirectiveParam:()=>$7,sanitizeComponentProps:()=>MJ,safeExecuteAsync:()=>$4,safeExecute:()=>L_,runPreProcessingMiddleware:()=>x9,runPostProcessingMiddleware:()=>v9,runMiddleware:()=>W8,runHooks:()=>p6,runDoctor:()=>VX,rotate:()=>IK,rewriteImagesWithSiblings:()=>rZ,resolveTemplatePath:()=>D7,resolveI18n:()=>g8,resize:()=>jK,resetPlaceholders:()=>oX,resetHead:()=>l_,resetHMRHandler:()=>Cy,resetErrorConfig:()=>B_,required:()=>rF,replacePlaceholders:()=>T3,renderView:()=>qW,renderVideoComponent:()=>$$,renderVendorStyleTags:()=>aX,renderToString:()=>o6,renderToStream:()=>FF,renderToDOM:()=>E$,renderThumbhashToCanvas:()=>YW,renderTemplate:()=>jx,renderString:()=>Hx,renderStreamingPage:()=>Hz,renderSlot:()=>b2,renderSSRSuspense:()=>Iq,renderProtectedVideo:()=>iK,renderProtectedImg:()=>pK,renderMediaUpload:()=>hK,renderImgComponent:()=>K6,renderImageComponent:()=>$G,renderHtmlAttrs:()=>r_,renderHead:()=>n_,renderEmail:()=>$x,renderComponentWithSlot:()=>Z4,renderBodyAttrs:()=>a_,render:()=>vy,relaxedCspPreset:()=>x_,registerValidationRule:()=>wM,registerStreamingDirectives:()=>Az,registerStore:()=>YC,registerSeoDirectives:()=>tT,registerMiddleware:()=>sS,registerFilters:()=>xU,registerFilter:()=>ZJ,registerErrorMessages:()=>K_,registerEnhancedValidationRule:()=>MM,registerDirective:()=>fj,registerCspDirectives:()=>QM,registerComponentDirectives:()=>Yb,registerAnimationDirectives:()=>Rw,registerA11yDirectives:()=>Uw,ref:()=>IS,redirect:()=>pb,readMarkdownFile:()=>F4,readFileCached:()=>CB,reactive:()=>WO,quality:()=>CK,pruneSignatureCache:()=>cK,pruneCache:()=>nj,provide:()=>$F,prop:()=>nF,processVueTemplate:()=>c9,processVirtualListDirectives:()=>iZ,processVirtualGridDirectives:()=>_2,processVideo:()=>LY,processValidateDirective:()=>Xz,processTranslateDirective:()=>nJ,processTransitionDirectives:()=>Vq,processTransitionAttributes:()=>Nq,processTitleDirective:()=>t_,processTemplateBindings:()=>BJ,processTeleportDirectives:()=>_q,processSuspenseDirectives:()=>Tq,processStructuredData:()=>h9,processStreamDirectives:()=>Oz,processStaticDirectives:()=>R2,processStackReplacements:()=>wZ,processStackPushDirectives:()=>NZ,processSlots:()=>P2,processShell:()=>pY,processServerBindings:()=>EZ,processSeoDirective:()=>d9,processSectionDirectives:()=>Nz,processScopedStyles:()=>q7,processReactiveBindings:()=>pU,processProtectedMedia:()=>nK,processPartialHydrationDirectives:()=>O2,processOnceDirective:()=>M7,processMiddleware:()=>y9,processMetaDirectives:()=>g9,processMetaDirective:()=>e_,processMarkdownFileDirectives:()=>S2,processMarkdownDirectives:()=>k2,processLoops:()=>VZ,processKeepAliveDirectives:()=>uq,processJsonDirective:()=>R7,processInfiniteListDirectives:()=>U2,processIncludes:()=>AZ,processImgComponents:()=>LQ,processImageComponents:()=>ZG,processImage:()=>i1,processHeadDirective:()=>o_,processForms:()=>NM,processFormInputDirectives:()=>e3,processExpressions:()=>j1,processEventDirectives:()=>LJ,processErrorDirective:()=>$Z,processDynamicComponents:()=>p9,processDirectives:()=>U0,processDirectiveAttributes:()=>AD,processDeferDirectives:()=>Kq,processCustomDirectives:()=>gJ,processCspDirectives:()=>xJ,processComponentProps:()=>$A,processClientScript:()=>y4,processBasicFormDirectives:()=>V5,processAsyncDirectives:()=>yq,processAnimationDirectives:()=>mX,processA11yDirectives:()=>hX,preloadTranslationsBackground:()=>yM,preloadTranslations:()=>Kz,preloadIslandHandlers:()=>Ny,preloadIconCollection:()=>WZ,poolStrings:()=>aO,pluginManager:()=>hQ,performLeave:()=>Lq,performEnter:()=>Oq,peek:()=>N7,partialsCache:()=>t4,parseVideoDirectiveOptions:()=>FH,parseUrl:()=>qK,parseThumbhashString:()=>JW,parseSwitchBlock:()=>l3,parseSlots:()=>C2,parseSlotElement:()=>Sj,parseScriptDeclarations:()=>C_,parseSFCComponent:()=>EH,parseProtectedArgs:()=>rK,parseImgComponent:()=>_Y,parseImageUrl:()=>c2,parseImageComponent:()=>yY,parseExpressionWithFilters:()=>k_,parseCookies:()=>mb,parseConditionalBlock:()=>EJ,parseArguments:()=>IJ,parseAnimationShorthand:()=>Nw,optional:()=>aF,optimizeTemplate:()=>sO,optimizeImage:()=>hY,optimizeDirectory:()=>QG,oneOf:()=>oF,onceStore:()=>b9,onUpdated:()=>xS,onUnmounted:()=>fS,onServer:()=>KC,onMounted:()=>PS,onMount:()=>PZ,onHydrated:()=>w2,onErrorCaptured:()=>QF,onDestroy:()=>yZ,onDeactivated:()=>nq,onClient:()=>GC,onBeforeUpdate:()=>yS,onBeforeUnmount:()=>vS,onBeforeMount:()=>bS,onActivated:()=>iq,observeElement:()=>eK,notFound:()=>ib,nextTick:()=>JF,navigateTo:()=>aS,mountInstance:()=>gS,motionDirective:()=>L3,moderateCspPreset:()=>i3,minifyHtml:()=>rO,metaDirective:()=>RZ,mergeParams:()=>ZX,mergeCspDirectives:()=>XM,matchRoute:()=>iY,markdownDirectiveHandler:()=>f2,markdownCache:()=>wY,localizePath:()=>k4,loadTranslationLazy:()=>W7,loadTranslation:()=>Uz,loadStxConfig:()=>m0,loadMiddlewareFromDirectory:()=>K8,loadManifest:()=>MG,loadElement:()=>D4,loadChannels:()=>YL,lintStxStrict:()=>fF,lazyLoadAll:()=>oK,lazyLoad:()=>sK,keyframeDirective:()=>_U,jsxs:()=>OF,jsxDEV:()=>LF,jsx:()=>e6,jsonResponse:()=>lb,islandDirective:()=>tJ,isTest:()=>s$,isSpaNavigation:()=>BG,isSignatureValid:()=>QX,isSignal:()=>F7,isSharpAvailable:()=>B$,isServerEnvironment:()=>Ib,isServer:()=>jO,isProduction:()=>B5,isNativeLazySupported:()=>WX,isLoading:()=>bM,isLoaded:()=>PM,isJavaScriptScript:()=>xj,isIntersectionObserverSupported:()=>UX,isImageFile:()=>q$,isImageBackendAvailable:()=>p1,isICUFormat:()=>Bz,isHydrated:()=>N2,isHydrateTrigger:()=>vj,isEdgeEnvironment:()=>Eb,isDirectiveKind:()=>hF,isDevelopment:()=>h4,isDerived:()=>A7,isCssOnlyChange:()=>l7,isClient:()=>HO,isAsyncComponent:()=>vq,invert:()=>RK,invalidateFileCacheByDir:()=>PB,invalidateFileCache:()=>bB,interpolateScriptsInTemplate:()=>fU,interpolateScriptExpressions:()=>XJ,inlineError:()=>_0,injectThemeBootstrap:()=>f8,injectSeoTags:()=>u9,injectSeo:()=>y8,injectRouterScript:()=>O4,injectHotReload:()=>Q4,injectHeatmap:()=>pX,injectCspMetaTag:()=>yJ,injectCrosswindCSS:()=>S0,injectConfigHeadTags:()=>a9,injectCloakStyle:()=>r9,injectAnalytics:()=>HJ,inject:()=>ZF,initStoreRegistry:()=>ZC,initNetlify:()=>dH,initLoadingIndicator:()=>Ty,initLazyLoading:()=>aK,initFile:()=>pG,initBlurUp:()=>_X,initAllBlurUp:()=>GW,imgDirective:()=>d7,imageDirective:()=>XG,hydrateTemplateStream:()=>aG,hydrateTemplate:()=>FP,hydrateIslands:()=>Ay,hydrateIsland:()=>V2,hydrateFragment:()=>AP,hydrateByStrategy:()=>F2,hydrateAll:()=>A2,hydrate:()=>yy,htmlResponse:()=>_y,heatmapDirective:()=>iX,hashString:()=>XY,hashFilePath:()=>I5,hashFile:()=>e0,hashBuffer:()=>uj,hasVueTemplateSyntax:()=>TB,hasVariables:()=>S9,hasStore:()=>DV,hasPlaceholders:()=>Q5,hasNetlifyConfig:()=>t7,hasMiddleware:()=>rS,hasEventDirectives:()=>PR,hasDocumentShell:()=>kZ,hasDirectives:()=>Ij,hasDOMSupport:()=>JU,handleImageRequest:()=>Y8,handleError:()=>GF,h:()=>RF,groupVariantsByFormat:()=>m6,grayscale:()=>NK,gitHash:()=>tG,getUnusedDirectives:()=>cO,getTranslationSync:()=>Wz,getTranslationCacheStats:()=>kM,getTranslationAsync:()=>xM,getTranslation:()=>ZZ,getTotalSize:()=>A4,getTimeUntilExpiry:()=>GX,getStoreNames:()=>kV,getStore:()=>zK,getSourceLineInfo:()=>v2,getScreenReaderOnlyStyle:()=>Qw,getScopeAttribute:()=>Sk,getRouteParams:()=>FC,getPublicEnvDefine:()=>P1,getPublicEnv:()=>AU,getPositionInfo:()=>Tj,getPlaceholderRegistry:()=>tX,getPlaceholderCacheStats:()=>XQ,getPageMeta:()=>a3,getNonce:()=>m4,getMimeType:()=>S1,getMiddlewareNames:()=>G8,getMiddleware:()=>nS,getLoadingState:()=>CM,getLoadingLocales:()=>fM,getImageMetadata:()=>h6,getHydrationRuntime:()=>wV,getHydratedStoreState:()=>XC,getHmrServer:()=>n7,getHead:()=>L5,getHMRHandler:()=>Sy,getFormatExtension:()=>n2,getFileMtime:()=>f7,getFallbackVariant:()=>u6,getErrorMessage:()=>AJ,getErrorLocale:()=>G_,getErrorConfig:()=>o$,getErrorCodeName:()=>v3,getDirectives:()=>jD,getDirective:()=>qD,getCurrentInstance:()=>TS,getCspPreset:()=>YM,getCspHeaderName:()=>h_,getComponentCacheStats:()=>BD,getCachedVideoResult:()=>r5,getCachedSignature:()=>uK,getCachedSignalsRuntime:()=>vB,getCachedRouterScript:()=>fB,getCachedPlaceholder:()=>v7,getCachedImageResult:()=>p5,getCached:()=>u5,getCacheStats:()=>ij,getBroadcastServer:()=>eO,getBestVariant:()=>i2,getAllFilters:()=>YJ,generateWidthSrcset:()=>J6,generateVirtualListCSS:()=>K2,generateVideoPreview:()=>_W,generateValidationScript:()=>EM,generateUploadRuntime:()=>P8,generateTreeShakenBundle:()=>lO,generateTransitionRuntime:()=>Aq,generateTransitionCSS:()=>Fq,generateThumbnails:()=>o5,generateThumbhashPlaceholder:()=>s2,generateTemplatesDocs:()=>wL,generateSuspenseRuntime:()=>kq,generateSuspenseCSS:()=>Dq,generateStateScript:()=>AV,generateSrcsetData:()=>l2,generateSrcset:()=>KY,generateSrcSet:()=>B6,generateSpriteSheet:()=>HY,generateSpaShell:()=>Gx,generateSourceTags:()=>p2,generateSizesFromBreakpoints:()=>u2,generateSizesAttribute:()=>v5,generateSizes:()=>d6,generateSitemapIndex:()=>eT,generateSitemap:()=>x8,generateSimpleMediaPicker:()=>mV,generateSignatureRuntime:()=>D8,generateSignalsRuntimeDev:()=>P6,generateSignalsRuntime:()=>w7,generateServerDataBridge:()=>d$,generateScopeId:()=>FY,generateSFCWebComponent:()=>IH,generateRouteTypes:()=>NC,generateRouteManifest:()=>AC,generateRobotsTxt:()=>AB,generateRobots:()=>v8,generateResponsiveVariants:()=>GY,generateReactiveWebComponentTS:()=>Pk,generateReactiveWebComponent:()=>bk,generateReactiveRuntime:()=>xk,generateReactiveMixin:()=>yk,generatePoster:()=>s5,generatePlaceholderStyle:()=>ZQ,generatePlaceholderCSS:()=>x7,generatePlaceholder:()=>y7,generatePartialHydrationCSS:()=>L2,generateNonce:()=>bJ,generateNetlifyToml:()=>SY,generateMinifiedMediaRuntime:()=>rV,generateMediaRuntime:()=>BW,generateMediaManagerEmbed:()=>uV,generateManifest:()=>wG,generateLoadingIndicatorHtml:()=>Iy,generateLazyLoadRuntime:()=>k8,generateLQIP:()=>t2,generateKeepAliveRuntime:()=>pq,generateKeepAliveCSS:()=>lq,generateIslandManifest:()=>M2,generateImagePreview:()=>UW,generateImageManifest:()=>dY,generateHydrationScript:()=>Py,generateHydrationRuntime:()=>Rz,generateHydrationCSS:()=>xy,generateHydrationBootstrap:()=>B2,generateHotReloadScript:()=>gH,generateHeatmapScript:()=>lX,generateHMRClientScript:()=>Dy,generateHLSManifest:()=>t5,generateEventBindings:()=>by,generateDprSrcsetWithVariableQuality:()=>d2,generateDprSrcset:()=>x5,generateDocumentShell:()=>kB,generateDocs:()=>IL,generateDirectivesDocs:()=>RL,generateDirectiveRuntime:()=>FD,generateDefaultRobotsTxt:()=>ZE,generateDASHManifest:()=>e5,generateCspMetaTag:()=>n3,generateCspHeader:()=>PJ,generateCrosswindCSS:()=>C3,generateCompositionRuntime:()=>zF,generateComponentsDocs:()=>NL,generateComponentManifest:()=>OI,generateComponentDoc:()=>AL,generateColorPlaceholder:()=>$Q,generateClientRuntime:()=>uS,generateCacheKey:()=>h5,generateBlurUpRuntime:()=>C8,generateBlurUpCSS:()=>b8,generateBindingsRuntime:()=>iU,generateAutoWidthSrcset:()=>h2,generateAsyncComponentRuntime:()=>gq,generateAsyncComponentCSS:()=>fq,generateAnimationRuntime:()=>ww,generateAnimationCSS:()=>Aw,generateAnalyticsScript:()=>jJ,formatTypeErrors:()=>Fy,formatStxContent:()=>tY,formatSize:()=>z6,formatRoutes:()=>jG,formatMarkdownContent:()=>mG,formatLocalizedError:()=>U_,formatICU:()=>_z,formatFilePath:()=>t$,formatError:()=>h3,formatDoctorReport:()=>FX,formatDocsAsMarkdown:()=>ML,formatDocsAsJson:()=>EL,formatDocsAsHtml:()=>TL,format:()=>SK,foldConstants:()=>nO,flipVertical:()=>kK,flipHorizontal:()=>DK,fingerprint:()=>HG,findPantryPackage:()=>VW,findMatchingEndTag:()=>u4,findMatchingDelimiter:()=>d0,findIfBlocks:()=>O5,findExpressions:()=>D_,findErrorPage:()=>qG,findDirectiveBlocks:()=>Y7,findDeadCode:()=>pO,findDeadBranches:()=>pO,findComponentFiles:()=>xG,findCommonDir:()=>DW,filterRequiredFiles:()=>s7,fileExists:()=>X0,extractVariables:()=>I0,extractStreamBoundaries:()=>Lz,extractState:()=>NV,extractSlotContent:()=>bj,extractScriptFromTemplate:()=>k9,extractPlaceholders:()=>ZR,extractParenthesizedExpression:()=>j4,extractLayoutMetadata:()=>B8,extractDominantColor:()=>e2,extractDirectiveParams:()=>S_,extractDirectiveNames:()=>Dj,extractContainerContent:()=>z8,extractComponentProps:()=>VL,extractComponentName:()=>q2,extractComponentDescription:()=>FL,extractClassNames:()=>S3,extractBridgeData:()=>P4,extractBoundProps:()=>j2,extractBalancedExpression:()=>TJ,extractAndStripCssImports:()=>rX,extractAndScopeStyles:()=>Ck,extractAndProcessEvents:()=>tU,evaluateExpression:()=>X1,evaluateConstant:()=>aY,evaluateAuthExpression:()=>q4,escapeHtml:()=>P0,errorRecovery:()=>d3,errorLogger:()=>J1,ensureTeleportTargets:()=>zq,ensureDocumentShell:()=>j7,enhancedValidationRules:()=>uJ,eliminateDeadCode:()=>iO,effect:()=>V7,dprUrls:()=>vK,docsCommand:()=>vG,disconnectObserver:()=>$W,devHelpers:()=>H5,detectShell:()=>zG,detectRuntime:()=>F$,detectProjectConfig:()=>U$,detectFormat:()=>r2,detectBuildMode:()=>rC,derived:()=>L7,deploy:()=>hH,defineStxConfig:()=>SH,defineStore:()=>CV,defineSlots:()=>WF,defineSiteConfig:()=>IW,definePropsWithValidation:()=>pF,defineProps:()=>lF,definePlugin:()=>Y$,definePageMeta:()=>p_,defineMiddleware:()=>iS,defineExpose:()=>XF,defineEmits:()=>YF,defineDirective:()=>x0,defineCustomElement:()=>TF,defineConfig:()=>VP,defineClientDirective:()=>OD,defineAsyncComponent:()=>xq,defaultMediaConfig:()=>ty,defaultImageConfig:()=>JO,defaultI18nConfig:()=>YZ,defaultHeatmapConfig:()=>OU,defaultFormClasses:()=>t3,defaultFilters:()=>G5,defaultCspConfig:()=>WM,defaultConfig:()=>O1,default:()=>Wv,decodeThumbhash:()=>o2,cspNonceDirective:()=>g_,cspDirective:()=>f_,crossfadeTransition:()=>QW,crop:()=>HK,createVirtualList:()=>pZ,createVideoDirective:()=>VY,createVercelHandler:()=>db,createTypeChecker:()=>YK,createTranslateFilter:()=>YT,createTextEncoderStream:()=>vb,createStxApp:()=>LW,createStreamingResponse:()=>xb,createStreamRenderer:()=>Fz,createStore:()=>BK,createStorageManager:()=>pS,createServerCookieManager:()=>lS,createScope:()=>KO,createSSRSuspense:()=>Eq,createRouter:()=>T4,createRouteLocation:()=>Q8,createRoute:()=>qy,createRef:()=>IS,createReactive:()=>WO,createProvideContext:()=>_F,createProject:()=>TP,createProductionBuild:()=>LP,createPlaceholder:()=>u$,createOptimizedBuild:()=>sC,createNetlifyHandler:()=>ub,createNetlifyClient:()=>r7,createMiddlewareContext:()=>J8,createMiddleware:()=>By,createLazyObserver:()=>tK,createKeepAliveCache:()=>mq,createKVNamespace:()=>SL,createIslandRegistry:()=>H2,createImgDirective:()=>zY,createImagePlugin:()=>JG,createImageHandler:()=>PY,createImageDirective:()=>fY,createHeatmapAggregator:()=>Ew,createFileManifest:()=>a7,createEnvAccessor:()=>kL,createEnhancedError:()=>O_,createEdgeHandler:()=>O8,createEdgeCache:()=>CL,createDetailedErrorMessage:()=>T0,createDenoHandler:()=>hb,createDefaultNetlifyConfig:()=>_$,createCspHeaders:()=>KM,createCookie:()=>cb,createComputed:()=>DS,createComponentInstance:()=>ES,createCloudflareHandler:()=>gb,createClientCookieManager:()=>cS,createBuiltinDirectives:()=>VD,createApp:()=>LW,createAnimationTimeline:()=>Fw,cover:()=>VK,convertToCommonJS:()=>qZ,contrast:()=>TK,contain:()=>LK,consoleError:()=>H_,configureErrorHandling:()=>z_,config:()=>F1,computed:()=>DS,composeShellWithPage:()=>_8,componentDirective:()=>zL,compileTemplate:()=>FG,collectDeployFiles:()=>W$,clearVideoCache:()=>qY,clearTranslationCache:()=>DM,clearSignatureCache:()=>mK,clearPlaceholderCache:()=>YQ,clearOnceStore:()=>rT,clearNonce:()=>ZM,clearMiddleware:()=>X8,clearImageCache:()=>vY,clearErrorMessages:()=>W_,clearDevCaches:()=>gB,clearCustomFilters:()=>vU,clearComponentCache:()=>X6,clearCache:()=>c5,cleanupLoadingIndicator:()=>Ey,classifyScript:()=>VO,classifyAllScripts:()=>WG,checkTemplateFile:()=>Ly,checkTemplate:()=>Vy,checkCache:()=>hZ,checkAuthAccess:()=>T$,checkA11y:()=>z3,channel:()=>KL,captureScreenshots:()=>gL,captureScreenshot:()=>dG,cancelPendingLoads:()=>gM,calculateSha1:()=>kY,calculateOptimalWidths:()=>$Y,cacheTemplate:()=>dZ,buildWebComponents:()=>yQ,buildViews:()=>tV,buildUrl:()=>D0,buildSuspenseResolveScript:()=>JZ,buildStaticSite:()=>TW,buildRuntimeAsset:()=>OG,buildRouterAsset:()=>LG,buildLangPickerScript:()=>u8,buildImageUrl:()=>c1,buildForProduction:()=>yO,buildComponentLibrary:()=>bG,buildAuthParams:()=>I8,buildApp:()=>vO,buildAlternateLinks:()=>d8,build:()=>OP,broadcastPrivate:()=>QL,broadcastPresence:()=>GL,broadcast:()=>kG,brightness:()=>MK,blur:()=>FK,batchSignUrls:()=>JX,batch:()=>bZ,autoFixA11yFile:()=>GU,autoFixA11yDirectory:()=>Ww,autoFixA11y:()=>QU,auto:()=>bK,assetTags:()=>uC,arrayOf:()=>tF,applyTranslations:()=>h8,applyTransformations:()=>h7,applySlots:()=>Pj,applyPropDefaults:()=>$b,applyPreset:()=>yK,applyHead:()=>s_,applyFilters:()=>JJ,apiCspPreset:()=>v_,animationGroupDirective:()=>O3,analyzeVideo:()=>u7,analyzeUsage:()=>IG,analyzeTemplate:()=>LO,analyzeProject:()=>KG,analyzeDirectiveUsage:()=>IG,analyticsDirective:()=>IR,addStore:()=>SP,addPage:()=>kP,addNonceToInlineContent:()=>JM,addLayout:()=>CP,addComponent:()=>DP,abortNavigation:()=>mS,a11yDirective:()=>B3,__setSignalsGeneratorsForTest:()=>xB,VideoProcessorCache:()=>n5,TransitionType:()=>KU,TransitionEase:()=>UU,TransitionDirection:()=>WU,Tokenizer:()=>Z7,TemplateTypeChecker:()=>ZK,TEMPLATE_PRESETS:()=>XP,StxValidationError:()=>e$,StxSyntaxError:()=>NJ,StxSecurityError:()=>wJ,StxRuntimeError:()=>d1,StxFileError:()=>j5,StxError:()=>d4,Show:()=>AF,SUSPENSE_RESOLVER_RUNTIME:()=>sJ,SPRING_PRESETS:()=>uX,ProductionBuild:()=>eY,Portal:()=>wF,PROJECT_TEMPLATES:()=>MP,PRESETS:()=>YX,MemorySessionStore:()=>TV,MIME_TYPES:()=>b7,MEDIA_DEFAULT_WIDTHS:()=>J4,MEDIA_DEFAULT_FORMATS:()=>V4,ImageProcessorCache:()=>l5,ImageProcessingError:()=>c6,HydrationRuntime:()=>_K,HotReloadServer:()=>iQ,HeatmapAggregator:()=>nX,Fragment:()=>t6,For:()=>NF,ErrorLogger:()=>u3,ErrorCodes:()=>J0,DeployError:()=>w4,DEFAULT_WIDTHS:()=>I1,DEFAULT_TRANSITION_OPTIONS:()=>t1,DEFAULT_QUALITY:()=>k1,DEFAULT_PLACEHOLDER_OPTIONS:()=>YY,DEFAULT_FORMATS:()=>D1,DEFAULT_DPR_VALUES:()=>C7,ComponentHMRHandler:()=>WK,COMMON_SIZES:()=>m2,CLOAK_STYLE:()=>RE,BroadcastServer:()=>UL,Broadcast:()=>WL,BLUR_UP_CSS:()=>g5});var Wv;var q6=D(()=>{CY();uY();w0();T9();R6();bV();m9();jW();MF();EF();dQ();e1();FW();xF();gF();UO();p4();cY();mJ();J5();OJ();V3();y5();O$();FJ();EG();VG();dO();oO();sY();x6();BL();PG();i0();vJ();hJ();CY();kW();S7();fG();bL();uG();M1();VJ();o0();cG();F3();rJ();R5();iG();nG();FZ();oZ();f9();X7();nY();m$();W1();sL();TG();oG();q8();KV();UG();TZ();UV();DZ();AG();sG();n4();zV();fQ();z2();T2();BV();HV();qJ();T6();LV();RV();EV();uY();oV();eV();T5();l9();i9();DF();w0();tZ();uF();Wv={}});import n8 from"path";var k$;var MX=D(()=>{q6();M1();o0();f4();W1();k$={name:"bun-plugin-stx",async setup($){let Y={...await m0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${n8.relative(n8.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await yQ(Y,X);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await hZ(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await $4(()=>Bun.file(G).text(),"",(H)=>{throw new j5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new j5(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:z}=g1.time("script-extraction",()=>{let H=W,O=W.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(O)H=O[1].trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let N of V){let w=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=N.match(/<script\b([^>]*)>/i),T=R?R[1]:"";if(/\bserver\b/i.test(T))L=w;else F.push(N)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),B={__filename:G,__dirname:n8.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await $4(()=>I0(U,B,G),void 0,(H)=>{let O=new d1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(J1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await g1.timeAsync("directive-processing",async()=>{return await U0(_,B,G,Y,K)});if(z.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (o0(),p$)),O=H(z.join(`
|
|
16473
|
+
${W}`)}return{props:G,validation:K}}function iF($,Z){let Y={...$};for(let[X,J]of Object.entries(Z))if(Y[X]===void 0)Y[X]=typeof J==="function"?J():J;return Y}function nF($){return $}function rF($){return{type:$,required:!0}}function aF($,Z){return{type:Z,default:$}}function sF($,Z={}){return{...Z,validator:$}}function oF($,Z={}){return{...Z,validator:(Y)=>$.includes(Y)}}function tF($,Z={}){return{...Z,type:Array,validator:(Y)=>{if(!Array.isArray(Y))return!1;return!0}}}function eF($,Z={}){return{...Z,type:Object}}function $A($,Z,Y){if(!Z)return $;let X={};for(let[J,Q]of Object.entries(Z)){let G=typeof Q==="function"||Array.isArray(Q)?{type:Q}:Q||{},K=$[J];if(K===void 0&&G.default!==void 0)K=typeof G.default==="function"?G.default():G.default;{let W=cF(J,K,G,Y);if(W)console.warn(W.message)}X[J]=K}for(let[J,Q]of Object.entries($))if(!(J in X))X[J]=Q;return X}var p6={};e(p6,{writeNetlifyConfig:()=>o7,writeManifest:()=>RG,writeImageManifest:()=>GG,wrapComponentForHMR:()=>ky,withDefaults:()=>iF,webComponentDirectiveHandler:()=>vQ,watermark:()=>PK,watchViews:()=>ey,watchMultiple:()=>SS,watchEffect:()=>CS,watch:()=>kS,waitForStore:()=>tS,waitForLocale:()=>vM,videoDirective:()=>m7,validators:()=>m3,validated:()=>sF,validateValueEnhanced:()=>Jz,validateTemplate:()=>Mj,validateParams:()=>fK,validateFormEnhanced:()=>TM,validateFile:()=>zX,validateFields:()=>RM,validateField:()=>Yz,validateDirective:()=>Ej,validateCspDirectives:()=>GM,validateConfig:()=>CH,validateComponentScripts:()=>aC,validateComponentProps:()=>eC,validateClientScript:()=>T7,usesSignalsInScript:()=>T6,userComponentFileExists:()=>I9,useVirtualList:()=>W2,useTitle:()=>i_,useStoreOrThrow:()=>oS,useStore:()=>SV,useSlots:()=>KF,useSeoMeta:()=>J7,useRouteParams:()=>zO,useRouteParamOrThrow:()=>eS,useRouteParam:()=>BO,usePageTitle:()=>i_,useOptimistic:()=>SB,useMiddlewareValue:()=>$C,useMiddlewareState:()=>qO,useLoadingIndicator:()=>jV,useHead:()=>l4,useAttrs:()=>UF,uploadFiles:()=>WW,uploadFile:()=>BX,updateInstance:()=>hS,untrack:()=>xZ,unregisterDirective:()=>HD,unmountInstance:()=>dS,unescapeHtml:()=>D3,transpileTypeScript:()=>v4,translate:()=>AX,transitionDirective:()=>j3,toUsers:()=>JL,toUser:()=>XL,thumbnail:()=>OK,thumbHashToRGBA:()=>S8,thumbHashToDataURL:()=>XW,templateCache:()=>o9,stxClientHelpers:()=>KK,structuredDataDirective:()=>MZ,stripLocalePrefix:()=>wW,stripDocumentWrapper:()=>M4,stringToStream:()=>fb,strictCspPreset:()=>y_,streamingSuspenseDirective:()=>oJ,streamToResponse:()=>wz,streamTemplateSimple:()=>Vz,streamTemplate:()=>jz,stopHmrServer:()=>K$,stopBroadcasting:()=>ZL,state:()=>O7,startProductionServer:()=>eL,startInteractive:()=>iL,startBroadcasting:()=>$L,staggerDirective:()=>zU,srcsetUrls:()=>xK,springDirective:()=>BU,splitByPipe:()=>c3,smartBatchSign:()=>dK,signUrl:()=>XX,shouldTranspileTypeScript:()=>x4,shouldReloadOnChange:()=>p7,shouldRefreshSignature:()=>KX,shouldIgnoreFile:()=>i7,shouldCacheComponent:()=>cq,sharpen:()=>AK,shape:()=>eF,setRouteParams:()=>JC,setMiddlewareState:()=>QC,setGlobalProvide:()=>HX,setErrorLocale:()=>Q_,setCurrentInstance:()=>MS,setCachedVideoResult:()=>a5,setCachedImageResult:()=>i5,setCached:()=>m5,serveStxFile:()=>l8,serveMultipleStxFiles:()=>p8,serveMarkdownFile:()=>DY,serveFile:()=>zy,serveApp:()=>i8,serve:()=>WV,serializeState:()=>VV,sepia:()=>wK,scrollAnimateDirective:()=>H3,screenReaderDirective:()=>q3,scopeHTML:()=>TH,scopeCSS:()=>MH,scanForSitemapEntries:()=>$E,scanA11yIssues:()=>dX,saturation:()=>EK,sanitizeParams:()=>gK,sanitizeFilePath:()=>A_,sanitizeExpression:()=>N_,sanitizeDirectiveParams:()=>w_,sanitizeDirectiveParam:()=>$7,sanitizeComponentProps:()=>MJ,safeExecuteAsync:()=>$4,safeExecute:()=>L_,runPreProcessingMiddleware:()=>x9,runPostProcessingMiddleware:()=>v9,runMiddleware:()=>W8,runHooks:()=>l6,runDoctor:()=>VX,rotate:()=>IK,rewriteImagesWithSiblings:()=>rZ,resolveTemplatePath:()=>D7,resolveI18n:()=>g8,resize:()=>jK,resetPlaceholders:()=>oX,resetHead:()=>l_,resetHMRHandler:()=>Cy,resetErrorConfig:()=>B_,required:()=>rF,replacePlaceholders:()=>T3,renderView:()=>qW,renderVideoComponent:()=>$$,renderVendorStyleTags:()=>aX,renderToString:()=>s6,renderToStream:()=>FF,renderToDOM:()=>E$,renderThumbhashToCanvas:()=>YW,renderTemplate:()=>jx,renderString:()=>Hx,renderStreamingPage:()=>Hz,renderSlot:()=>b2,renderSSRSuspense:()=>Iq,renderProtectedVideo:()=>iK,renderProtectedImg:()=>pK,renderMediaUpload:()=>hK,renderImgComponent:()=>G6,renderImageComponent:()=>$G,renderHtmlAttrs:()=>r_,renderHead:()=>n_,renderEmail:()=>$x,renderComponentWithSlot:()=>Z4,renderBodyAttrs:()=>a_,render:()=>vy,relaxedCspPreset:()=>x_,registerValidationRule:()=>wM,registerStreamingDirectives:()=>Az,registerStore:()=>YC,registerSeoDirectives:()=>tT,registerMiddleware:()=>sS,registerFilters:()=>xU,registerFilter:()=>ZJ,registerErrorMessages:()=>K_,registerEnhancedValidationRule:()=>MM,registerDirective:()=>fj,registerCspDirectives:()=>QM,registerComponentDirectives:()=>Yb,registerAnimationDirectives:()=>Rw,registerA11yDirectives:()=>Uw,ref:()=>IS,redirect:()=>pb,readMarkdownFile:()=>F4,readFileCached:()=>CB,reactive:()=>WO,quality:()=>CK,pruneSignatureCache:()=>cK,pruneCache:()=>nj,provide:()=>$F,prop:()=>nF,processVueTemplate:()=>c9,processVirtualListDirectives:()=>iZ,processVirtualGridDirectives:()=>_2,processVideo:()=>LY,processValidateDirective:()=>Xz,processTranslateDirective:()=>nJ,processTransitionDirectives:()=>Vq,processTransitionAttributes:()=>Nq,processTitleDirective:()=>t_,processTemplateBindings:()=>BJ,processTeleportDirectives:()=>_q,processSuspenseDirectives:()=>Tq,processStructuredData:()=>h9,processStreamDirectives:()=>Oz,processStaticDirectives:()=>R2,processStackReplacements:()=>wZ,processStackPushDirectives:()=>NZ,processSlots:()=>P2,processShell:()=>pY,processServerBindings:()=>EZ,processSeoDirective:()=>d9,processSectionDirectives:()=>Nz,processScopedStyles:()=>q7,processReactiveBindings:()=>pU,processProtectedMedia:()=>nK,processPartialHydrationDirectives:()=>O2,processOnceDirective:()=>M7,processMiddleware:()=>y9,processMetaDirectives:()=>g9,processMetaDirective:()=>e_,processMarkdownFileDirectives:()=>S2,processMarkdownDirectives:()=>k2,processLoops:()=>VZ,processKeepAliveDirectives:()=>uq,processJsonDirective:()=>R7,processInfiniteListDirectives:()=>U2,processIncludes:()=>AZ,processImgComponents:()=>LQ,processImageComponents:()=>ZG,processImage:()=>i1,processHeadDirective:()=>o_,processForms:()=>NM,processFormInputDirectives:()=>e3,processExpressions:()=>j1,processEventDirectives:()=>LJ,processErrorDirective:()=>$Z,processDynamicComponents:()=>p9,processDirectives:()=>U0,processDirectiveAttributes:()=>AD,processDeferDirectives:()=>Kq,processCustomDirectives:()=>gJ,processCspDirectives:()=>xJ,processComponentProps:()=>$A,processClientScript:()=>y4,processBasicFormDirectives:()=>L5,processAsyncDirectives:()=>yq,processAnimationDirectives:()=>mX,processA11yDirectives:()=>hX,preloadTranslationsBackground:()=>yM,preloadTranslations:()=>Kz,preloadIslandHandlers:()=>Ny,preloadIconCollection:()=>WZ,poolStrings:()=>aO,pluginManager:()=>hQ,performLeave:()=>Lq,performEnter:()=>Oq,peek:()=>N7,partialsCache:()=>o4,parseVideoDirectiveOptions:()=>FH,parseUrl:()=>qK,parseThumbhashString:()=>JW,parseSwitchBlock:()=>l3,parseSlots:()=>C2,parseSlotElement:()=>Sj,parseScriptDeclarations:()=>C_,parseSFCComponent:()=>EH,parseProtectedArgs:()=>rK,parseImgComponent:()=>_Y,parseImageUrl:()=>c2,parseImageComponent:()=>yY,parseExpressionWithFilters:()=>k_,parseCookies:()=>mb,parseConditionalBlock:()=>EJ,parseArguments:()=>IJ,parseAnimationShorthand:()=>Nw,optional:()=>aF,optimizeTemplate:()=>sO,optimizeImage:()=>hY,optimizeDirectory:()=>QG,oneOf:()=>oF,onceStore:()=>b9,onUpdated:()=>xS,onUnmounted:()=>fS,onServer:()=>KC,onMounted:()=>PS,onMount:()=>PZ,onHydrated:()=>w2,onErrorCaptured:()=>QF,onDestroy:()=>yZ,onDeactivated:()=>nq,onClient:()=>GC,onBeforeUpdate:()=>yS,onBeforeUnmount:()=>vS,onBeforeMount:()=>bS,onActivated:()=>iq,observeElement:()=>eK,notFound:()=>ib,nextTick:()=>JF,navigateTo:()=>aS,mountInstance:()=>gS,motionDirective:()=>L3,moderateCspPreset:()=>i3,minifyHtml:()=>rO,metaDirective:()=>RZ,mergeParams:()=>ZX,mergeCspDirectives:()=>XM,matchRoute:()=>iY,markdownDirectiveHandler:()=>f2,markdownCache:()=>wY,localizePath:()=>k4,loadTranslationLazy:()=>W7,loadTranslation:()=>Uz,loadStxConfig:()=>m0,loadMiddlewareFromDirectory:()=>K8,loadManifest:()=>MG,loadElement:()=>D4,loadChannels:()=>YL,lintStxStrict:()=>fF,lazyLoadAll:()=>oK,lazyLoad:()=>sK,keyframeDirective:()=>_U,jsxs:()=>OF,jsxDEV:()=>LF,jsx:()=>t6,jsonResponse:()=>lb,islandDirective:()=>tJ,isTest:()=>s$,isSpaNavigation:()=>BG,isSignatureValid:()=>QX,isSignal:()=>F7,isSharpAvailable:()=>B$,isServerEnvironment:()=>Ib,isServer:()=>jO,isProduction:()=>z5,isNativeLazySupported:()=>WX,isLoading:()=>bM,isLoaded:()=>PM,isJavaScriptScript:()=>xj,isIntersectionObserverSupported:()=>UX,isImageFile:()=>q$,isImageBackendAvailable:()=>p1,isICUFormat:()=>Bz,isHydrated:()=>N2,isHydrateTrigger:()=>vj,isEdgeEnvironment:()=>Eb,isDirectiveKind:()=>hF,isDevelopment:()=>h4,isDerived:()=>A7,isCssOnlyChange:()=>l7,isClient:()=>HO,isAsyncComponent:()=>vq,invert:()=>RK,invalidateFileCacheByDir:()=>PB,invalidateFileCache:()=>bB,interpolateScriptsInTemplate:()=>fU,interpolateScriptExpressions:()=>XJ,inlineError:()=>_0,injectThemeBootstrap:()=>f8,injectSeoTags:()=>u9,injectSeo:()=>y8,injectRouterScript:()=>O4,injectHotReload:()=>Q4,injectHeatmap:()=>pX,injectCspMetaTag:()=>yJ,injectCrosswindCSS:()=>S0,injectConfigHeadTags:()=>a9,injectCloakStyle:()=>r9,injectAnalytics:()=>HJ,inject:()=>ZF,initStoreRegistry:()=>ZC,initNetlify:()=>dH,initLoadingIndicator:()=>Ty,initLazyLoading:()=>aK,initFile:()=>pG,initBlurUp:()=>_X,initAllBlurUp:()=>GW,imgDirective:()=>d7,imageDirective:()=>XG,hydrateTemplateStream:()=>aG,hydrateTemplate:()=>FP,hydrateIslands:()=>Ay,hydrateIsland:()=>V2,hydrateFragment:()=>AP,hydrateByStrategy:()=>F2,hydrateAll:()=>A2,hydrate:()=>yy,htmlResponse:()=>_y,heatmapDirective:()=>iX,hashString:()=>XY,hashFilePath:()=>I5,hashFile:()=>e0,hashBuffer:()=>uj,hasVueTemplateSyntax:()=>TB,hasVariables:()=>S9,hasStore:()=>DV,hasPlaceholders:()=>J5,hasNetlifyConfig:()=>t7,hasMiddleware:()=>rS,hasEventDirectives:()=>PR,hasDocumentShell:()=>kZ,hasDirectives:()=>Ij,hasDOMSupport:()=>JU,handleImageRequest:()=>Y8,handleError:()=>GF,h:()=>RF,groupVariantsByFormat:()=>u6,grayscale:()=>NK,gitHash:()=>tG,getUnusedDirectives:()=>cO,getTranslationSync:()=>Wz,getTranslationCacheStats:()=>kM,getTranslationAsync:()=>xM,getTranslation:()=>ZZ,getTotalSize:()=>A4,getTimeUntilExpiry:()=>GX,getStoreNames:()=>kV,getStore:()=>zK,getSourceLineInfo:()=>v2,getScreenReaderOnlyStyle:()=>Qw,getScopeAttribute:()=>Sk,getRouteParams:()=>FC,getPublicEnvDefine:()=>P1,getPublicEnv:()=>AU,getPositionInfo:()=>Tj,getPlaceholderRegistry:()=>tX,getPlaceholderCacheStats:()=>XQ,getPageMeta:()=>a3,getNonce:()=>m4,getMimeType:()=>S1,getMiddlewareNames:()=>G8,getMiddleware:()=>nS,getLoadingState:()=>CM,getLoadingLocales:()=>fM,getImageMetadata:()=>g6,getHydrationRuntime:()=>wV,getHydratedStoreState:()=>XC,getHmrServer:()=>n7,getHead:()=>O5,getHMRHandler:()=>Sy,getFormatExtension:()=>n2,getFileMtime:()=>f7,getFallbackVariant:()=>d6,getErrorMessage:()=>AJ,getErrorLocale:()=>G_,getErrorConfig:()=>o$,getErrorCodeName:()=>v3,getDirectives:()=>jD,getDirective:()=>qD,getCurrentInstance:()=>TS,getCspPreset:()=>YM,getCspHeaderName:()=>h_,getComponentCacheStats:()=>BD,getCachedVideoResult:()=>r5,getCachedSignature:()=>uK,getCachedSignalsRuntime:()=>vB,getCachedRouterScript:()=>fB,getCachedPlaceholder:()=>v7,getCachedImageResult:()=>p5,getCached:()=>u5,getCacheStats:()=>ij,getBroadcastServer:()=>eO,getBestVariant:()=>i2,getAllFilters:()=>YJ,generateWidthSrcset:()=>X6,generateVirtualListCSS:()=>K2,generateVideoPreview:()=>_W,generateValidationScript:()=>EM,generateUploadRuntime:()=>P8,generateTreeShakenBundle:()=>lO,generateTransitionRuntime:()=>Aq,generateTransitionCSS:()=>Fq,generateThumbnails:()=>o5,generateThumbhashPlaceholder:()=>s2,generateTemplatesDocs:()=>wL,generateSuspenseRuntime:()=>kq,generateSuspenseCSS:()=>Dq,generateStateScript:()=>AV,generateSrcsetData:()=>l2,generateSrcset:()=>KY,generateSrcSet:()=>z6,generateSpriteSheet:()=>HY,generateSpaShell:()=>Gx,generateSourceTags:()=>p2,generateSizesFromBreakpoints:()=>u2,generateSizesAttribute:()=>v5,generateSizes:()=>h6,generateSitemapIndex:()=>eT,generateSitemap:()=>x8,generateSimpleMediaPicker:()=>mV,generateSignatureRuntime:()=>D8,generateSignalsRuntimeDev:()=>b6,generateSignalsRuntime:()=>w7,generateServerDataBridge:()=>d$,generateScopeId:()=>FY,generateSFCWebComponent:()=>IH,generateRouteTypes:()=>NC,generateRouteManifest:()=>AC,generateRobotsTxt:()=>AB,generateRobots:()=>v8,generateResponsiveVariants:()=>GY,generateReactiveWebComponentTS:()=>Pk,generateReactiveWebComponent:()=>bk,generateReactiveRuntime:()=>xk,generateReactiveMixin:()=>yk,generatePoster:()=>s5,generatePlaceholderStyle:()=>ZQ,generatePlaceholderCSS:()=>x7,generatePlaceholder:()=>y7,generatePartialHydrationCSS:()=>L2,generateNonce:()=>bJ,generateNetlifyToml:()=>SY,generateMinifiedMediaRuntime:()=>rV,generateMediaRuntime:()=>BW,generateMediaManagerEmbed:()=>uV,generateManifest:()=>wG,generateLoadingIndicatorHtml:()=>Iy,generateLazyLoadRuntime:()=>k8,generateLQIP:()=>t2,generateKeepAliveRuntime:()=>pq,generateKeepAliveCSS:()=>lq,generateIslandManifest:()=>M2,generateImagePreview:()=>UW,generateImageManifest:()=>dY,generateHydrationScript:()=>Py,generateHydrationRuntime:()=>Rz,generateHydrationCSS:()=>xy,generateHydrationBootstrap:()=>B2,generateHotReloadScript:()=>gH,generateHeatmapScript:()=>lX,generateHMRClientScript:()=>Dy,generateHLSManifest:()=>t5,generateEventBindings:()=>by,generateDprSrcsetWithVariableQuality:()=>d2,generateDprSrcset:()=>x5,generateDocumentShell:()=>kB,generateDocs:()=>IL,generateDirectivesDocs:()=>RL,generateDirectiveRuntime:()=>FD,generateDefaultRobotsTxt:()=>ZE,generateDASHManifest:()=>e5,generateCspMetaTag:()=>n3,generateCspHeader:()=>PJ,generateCrosswindCSS:()=>C3,generateCompositionRuntime:()=>zF,generateComponentsDocs:()=>NL,generateComponentManifest:()=>OI,generateComponentDoc:()=>AL,generateColorPlaceholder:()=>$Q,generateClientRuntime:()=>uS,generateCacheKey:()=>h5,generateBlurUpRuntime:()=>C8,generateBlurUpCSS:()=>b8,generateBindingsRuntime:()=>iU,generateAutoWidthSrcset:()=>h2,generateAsyncComponentRuntime:()=>gq,generateAsyncComponentCSS:()=>fq,generateAnimationRuntime:()=>ww,generateAnimationCSS:()=>Aw,generateAnalyticsScript:()=>jJ,formatTypeErrors:()=>Fy,formatStxContent:()=>tY,formatSize:()=>_6,formatRoutes:()=>jG,formatMarkdownContent:()=>mG,formatLocalizedError:()=>U_,formatICU:()=>_z,formatFilePath:()=>t$,formatError:()=>h3,formatDoctorReport:()=>FX,formatDocsAsMarkdown:()=>ML,formatDocsAsJson:()=>EL,formatDocsAsHtml:()=>TL,format:()=>SK,foldConstants:()=>nO,flipVertical:()=>kK,flipHorizontal:()=>DK,fingerprint:()=>HG,findPantryPackage:()=>VW,findMatchingEndTag:()=>u4,findMatchingDelimiter:()=>d0,findIfBlocks:()=>H5,findExpressions:()=>D_,findErrorPage:()=>qG,findDirectiveBlocks:()=>Y7,findDeadCode:()=>pO,findDeadBranches:()=>pO,findComponentFiles:()=>xG,findCommonDir:()=>DW,filterRequiredFiles:()=>s7,fileExists:()=>X0,extractVariables:()=>I0,extractStreamBoundaries:()=>Lz,extractState:()=>NV,extractSlotContent:()=>bj,extractScriptFromTemplate:()=>k9,extractPlaceholders:()=>ZR,extractParenthesizedExpression:()=>j4,extractLayoutMetadata:()=>B8,extractDominantColor:()=>e2,extractDirectiveParams:()=>S_,extractDirectiveNames:()=>Dj,extractContainerContent:()=>z8,extractComponentProps:()=>VL,extractComponentName:()=>q2,extractComponentDescription:()=>FL,extractClassNames:()=>S3,extractBridgeData:()=>P4,extractBoundProps:()=>j2,extractBalancedExpression:()=>TJ,extractAndStripCssImports:()=>rX,extractAndScopeStyles:()=>Ck,extractAndProcessEvents:()=>tU,evaluateExpression:()=>X1,evaluateConstant:()=>aY,evaluateAuthExpression:()=>q4,escapeHtml:()=>P0,errorRecovery:()=>d3,errorLogger:()=>J1,ensureTeleportTargets:()=>zq,ensureDocumentShell:()=>j7,enhancedValidationRules:()=>uJ,eliminateDeadCode:()=>iO,effect:()=>V7,dprUrls:()=>vK,docsCommand:()=>vG,disconnectObserver:()=>$W,devHelpers:()=>j5,detectShell:()=>zG,detectRuntime:()=>F$,detectProjectConfig:()=>U$,detectFormat:()=>r2,detectBuildMode:()=>rC,derived:()=>L7,deploy:()=>hH,defineStxConfig:()=>SH,defineStore:()=>CV,defineSlots:()=>WF,defineSiteConfig:()=>IW,definePropsWithValidation:()=>pF,defineProps:()=>lF,definePlugin:()=>Y$,definePageMeta:()=>p_,defineMiddleware:()=>iS,defineExpose:()=>XF,defineEmits:()=>YF,defineDirective:()=>x0,defineCustomElement:()=>TF,defineConfig:()=>VP,defineClientDirective:()=>OD,defineAsyncComponent:()=>xq,defaultMediaConfig:()=>ty,defaultImageConfig:()=>JO,defaultI18nConfig:()=>YZ,defaultHeatmapConfig:()=>OU,defaultFormClasses:()=>t3,defaultFilters:()=>Q5,defaultCspConfig:()=>WM,defaultConfig:()=>O1,default:()=>Wv,decodeThumbhash:()=>o2,cspNonceDirective:()=>g_,cspDirective:()=>f_,crossfadeTransition:()=>QW,crop:()=>HK,createVirtualList:()=>pZ,createVideoDirective:()=>VY,createVercelHandler:()=>db,createTypeChecker:()=>YK,createTranslateFilter:()=>YT,createTextEncoderStream:()=>vb,createStxApp:()=>LW,createStreamingResponse:()=>xb,createStreamRenderer:()=>Fz,createStore:()=>BK,createStorageManager:()=>pS,createServerCookieManager:()=>lS,createScope:()=>KO,createSSRSuspense:()=>Eq,createRouter:()=>T4,createRouteLocation:()=>Q8,createRoute:()=>qy,createRef:()=>IS,createReactive:()=>WO,createProvideContext:()=>_F,createProject:()=>TP,createProductionBuild:()=>LP,createPlaceholder:()=>u$,createOptimizedBuild:()=>sC,createNetlifyHandler:()=>ub,createNetlifyClient:()=>r7,createMiddlewareContext:()=>J8,createMiddleware:()=>By,createLazyObserver:()=>tK,createKeepAliveCache:()=>mq,createKVNamespace:()=>SL,createIslandRegistry:()=>H2,createImgDirective:()=>zY,createImagePlugin:()=>JG,createImageHandler:()=>PY,createImageDirective:()=>fY,createHeatmapAggregator:()=>Ew,createFileManifest:()=>a7,createEnvAccessor:()=>kL,createEnhancedError:()=>O_,createEdgeHandler:()=>O8,createEdgeCache:()=>CL,createDetailedErrorMessage:()=>T0,createDenoHandler:()=>hb,createDefaultNetlifyConfig:()=>_$,createCspHeaders:()=>KM,createCookie:()=>cb,createComputed:()=>DS,createComponentInstance:()=>ES,createCloudflareHandler:()=>gb,createClientCookieManager:()=>cS,createBuiltinDirectives:()=>VD,createApp:()=>LW,createAnimationTimeline:()=>Fw,cover:()=>VK,convertToCommonJS:()=>qZ,contrast:()=>TK,contain:()=>LK,consoleError:()=>H_,configureErrorHandling:()=>z_,config:()=>F1,computed:()=>DS,composeShellWithPage:()=>_8,componentDirective:()=>zL,compileTemplate:()=>FG,collectDeployFiles:()=>W$,clearVideoCache:()=>qY,clearTranslationCache:()=>DM,clearSignatureCache:()=>mK,clearPlaceholderCache:()=>YQ,clearOnceStore:()=>rT,clearNonce:()=>ZM,clearMiddleware:()=>X8,clearImageCache:()=>vY,clearErrorMessages:()=>W_,clearDevCaches:()=>gB,clearCustomFilters:()=>vU,clearComponentCache:()=>Y6,clearCache:()=>c5,cleanupLoadingIndicator:()=>Ey,classifyScript:()=>VO,classifyAllScripts:()=>WG,checkTemplateFile:()=>Ly,checkTemplate:()=>Vy,checkCache:()=>hZ,checkAuthAccess:()=>T$,checkA11y:()=>z3,channel:()=>KL,captureScreenshots:()=>gL,captureScreenshot:()=>dG,cancelPendingLoads:()=>gM,calculateSha1:()=>kY,calculateOptimalWidths:()=>$Y,cacheTemplate:()=>dZ,buildWebComponents:()=>yQ,buildViews:()=>tV,buildUrl:()=>D0,buildSuspenseResolveScript:()=>JZ,buildStaticSite:()=>TW,buildRuntimeAsset:()=>OG,buildRouterAsset:()=>LG,buildLangPickerScript:()=>u8,buildImageUrl:()=>c1,buildForProduction:()=>yO,buildComponentLibrary:()=>bG,buildAuthParams:()=>I8,buildApp:()=>vO,buildAlternateLinks:()=>d8,build:()=>OP,broadcastPrivate:()=>QL,broadcastPresence:()=>GL,broadcast:()=>kG,brightness:()=>MK,blur:()=>FK,batchSignUrls:()=>JX,batch:()=>bZ,autoFixA11yFile:()=>GU,autoFixA11yDirectory:()=>Ww,autoFixA11y:()=>QU,auto:()=>bK,assetTags:()=>uC,arrayOf:()=>tF,applyTranslations:()=>h8,applyTransformations:()=>h7,applySlots:()=>Pj,applyPropDefaults:()=>$b,applyPreset:()=>yK,applyHead:()=>s_,applyFilters:()=>JJ,apiCspPreset:()=>v_,animationGroupDirective:()=>O3,analyzeVideo:()=>u7,analyzeUsage:()=>IG,analyzeTemplate:()=>LO,analyzeProject:()=>KG,analyzeDirectiveUsage:()=>IG,analyticsDirective:()=>IR,addStore:()=>SP,addPage:()=>kP,addNonceToInlineContent:()=>JM,addLayout:()=>CP,addComponent:()=>DP,abortNavigation:()=>mS,a11yDirective:()=>B3,__setSignalsGeneratorsForTest:()=>xB,VideoProcessorCache:()=>n5,TransitionType:()=>KU,TransitionEase:()=>UU,TransitionDirection:()=>WU,Tokenizer:()=>Z7,TemplateTypeChecker:()=>ZK,TEMPLATE_PRESETS:()=>XP,StxValidationError:()=>e$,StxSyntaxError:()=>NJ,StxSecurityError:()=>wJ,StxRuntimeError:()=>d1,StxFileError:()=>q5,StxError:()=>d4,Show:()=>AF,SUSPENSE_RESOLVER_RUNTIME:()=>sJ,SPRING_PRESETS:()=>uX,ProductionBuild:()=>eY,Portal:()=>wF,PROJECT_TEMPLATES:()=>MP,PRESETS:()=>YX,MemorySessionStore:()=>TV,MIME_TYPES:()=>b7,MEDIA_DEFAULT_WIDTHS:()=>J4,MEDIA_DEFAULT_FORMATS:()=>V4,ImageProcessorCache:()=>l5,ImageProcessingError:()=>m6,HydrationRuntime:()=>_K,HotReloadServer:()=>iQ,HeatmapAggregator:()=>nX,Fragment:()=>o6,For:()=>NF,ErrorLogger:()=>u3,ErrorCodes:()=>J0,DeployError:()=>w4,DEFAULT_WIDTHS:()=>I1,DEFAULT_TRANSITION_OPTIONS:()=>t1,DEFAULT_QUALITY:()=>k1,DEFAULT_PLACEHOLDER_OPTIONS:()=>YY,DEFAULT_FORMATS:()=>D1,DEFAULT_DPR_VALUES:()=>C7,ComponentHMRHandler:()=>WK,COMMON_SIZES:()=>m2,CLOAK_STYLE:()=>RE,BroadcastServer:()=>UL,Broadcast:()=>WL,BLUR_UP_CSS:()=>g5});var Wv;var B6=D(()=>{CY();uY();w0();T9();w6();bV();m9();jW();MF();EF();dQ();e1();FW();xF();gF();UO();p4();cY();mJ();X5();OJ();V3();y5();O$();FJ();EG();VG();dO();oO();sY();y6();BL();PG();i0();vJ();hJ();CY();kW();S7();fG();bL();uG();M1();VJ();o0();cG();F3();rJ();R5();iG();nG();FZ();oZ();f9();X7();nY();m$();W1();sL();TG();oG();q8();KV();UG();TZ();UV();DZ();AG();sG();n4();zV();fQ();z2();T2();BV();HV();qJ();M6();LV();RV();EV();uY();oV();eV();T5();l9();i9();DF();w0();tZ();uF();Wv={}});import n8 from"path";var k$;var MX=D(()=>{B6();M1();o0();f4();W1();k$={name:"bun-plugin-stx",async setup($){let Y={...await m0(),...$.config?.stx},X=new Set,J=Y.webComponents?.enabled?`./${n8.relative(n8.dirname($.config?.outdir||"dist"),Y.webComponents.outputDir||"dist/web-components")}`:"/web-components",Q=[];if(Y.webComponents?.enabled)try{let G=await yQ(Y,X);if(Q.push(...G),Y.debug&&G.length>0)console.log(`Successfully built ${G.length} web components`)}catch(G){console.error("Failed to build web components:",G)}$.onLoad({filter:/\.stx$/},async({path:G})=>{try{let K=new Set;if(Y.cache&&Y.cachePath){let H=await hZ(G,Y);if(H){if(Y.debug)console.log(`Using cached version of ${G}`);return{contents:H,loader:"html"}}}let W=await $4(()=>Bun.file(G).text(),"",(H)=>{throw new q5(`Failed to read stx file: ${G}`,G,void 0,void 0,`File read error: ${H.message}`)});if(!W)throw new q5(`stx file is empty: ${G}`,G);let{scriptContent:U,templateContent:_,allScripts:z}=g1.time("script-extraction",()=>{let H=W,O=W.match(/<template\b(?![^>]*(?:\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=|\s#[\w-]|\bv-slot|\bslot\s*=))[^>]*>([\s\S]*?)<\/template>/i);if(O)H=O[1].trim();let V=W.match(/<script\b[^>]*>[\s\S]*?<\/script>/gi)||[],L="",F=[];for(let N of V){let w=N.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i)?.[1]||"",R=N.match(/<script\b([^>]*)>/i),T=R?R[1]:"";if(/\bserver\b/i.test(T))L=w;else F.push(N)}let A=H.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"");return{scriptContent:L,templateContent:A,allScripts:F}}),B={__filename:G,__dirname:n8.dirname(G),__stx:{webComponentsPath:J,builtComponents:Q}};await $4(()=>I0(U,B,G),void 0,(H)=>{let O=new d1(`Script execution failed in ${G}: ${H.message}`,G,void 0,void 0,U.substring(0,100));if(J1.log(O,{filePath:G,scriptContent:U}),Y.debug)throw O});let j=await g1.timeAsync("directive-processing",async()=>{return await U0(_,B,G,Y,K)});if(z.length>0){let{interpolateScriptsInTemplate:H}=await Promise.resolve().then(() => (o0(),p$)),O=H(z.join(`
|
|
16474
16474
|
`),B),V=j.search(/<\/body>/i);if(V!==-1)j=j.slice(0,V)+O+`
|
|
16475
16475
|
`+j.slice(V);else j+=`
|
|
16476
|
-
${O}`}if(j=await O4(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await dZ(G,j,K,Y),Y.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:j,loader:"html"}}catch(K){let W=K instanceof Error?K:new d1(`Plugin processing failed: ${String(K)}`,G);if(J1.log(W,{filePath:G,buildConfig:$.config}),
|
|
16476
|
+
${O}`}if(j=await O4(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await dZ(G,j,K,Y),Y.debug)console.log(`Cached template ${G} with ${K.size} dependencies`)}return{contents:j,loader:"html"}}catch(K){let W=K instanceof Error?K:new d1(`Plugin processing failed: ${String(K)}`,G);if(J1.log(W,{filePath:G,buildConfig:$.config}),j5.logDetailedError(W,{filePath:G,plugin:"bun-plugin-stx"}),Y.debug)console.error("stx Plugin Error:",W);let U=W,_=U.line||null,z=U.context||null;return{contents:Y.debug||h4()?`<!DOCTYPE html>
|
|
16477
16477
|
<html lang="en">
|
|
16478
16478
|
<head>
|
|
16479
16479
|
<meta charset="UTF-8">
|
|
@@ -16533,12 +16533,12 @@ ${O}`}if(j=await O4(j),K.forEach((H)=>X.add(H)),Y.cache&&Y.cachePath){if(await d
|
|
|
16533
16533
|
<h1>Something went wrong</h1>
|
|
16534
16534
|
<p>An internal error occurred. Please try again later.</p>
|
|
16535
16535
|
</body>
|
|
16536
|
-
</html>`,loader:"html"}}})}}});var{serve:Uv}=globalThis.Bun;import s1 from"fs";import B1 from"path";async function l8($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=B1.resolve($);if(!s1.existsSync(K))return console.error(`${M.red}Error: File not found: ${M.bright}${K}${M.reset}`),!1;if(K.endsWith(".md"))return DY(K,Z);else if(!K.endsWith(".stx"))return console.error(`${M.red}Error: Unsupported file type: ${M.bright}${K}${M.reset}. Only .stx and .md files are supported.`),!1;let W=B1.join(process.cwd(),".stx/output");s1.mkdirSync(W,{recursive:!0}),console.log(`${M.blue}Building ${M.bright}${$}${M.reset}...`);let U=null,_=async()=>{try{let L={name:"public-assets",setup(w){w.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},F=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,k$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!F.success)return console.error(`${M.red}Build failed:${M.reset}`,F.logs),!1;let A=F.outputs.find((w)=>w.path.endsWith(".html"));if(!A)return console.error(`${M.red}No HTML output found${M.reset}`),!1;return U=await Bun.file(A.path).text(),!0}catch(L){return console.error(`${M.red}Error building stx file:${M.reset}`,L),!1}};if(!await _())return!1;let B=B1.dirname(K);await
|
|
16536
|
+
</html>`,loader:"html"}}})}}});var{serve:Uv}=globalThis.Bun;import s1 from"fs";import B1 from"path";async function l8($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=B1.resolve($);if(!s1.existsSync(K))return console.error(`${M.red}Error: File not found: ${M.bright}${K}${M.reset}`),!1;if(K.endsWith(".md"))return DY(K,Z);else if(!K.endsWith(".stx"))return console.error(`${M.red}Error: Unsupported file type: ${M.bright}${K}${M.reset}. Only .stx and .md files are supported.`),!1;let W=B1.join(process.cwd(),".stx/output");s1.mkdirSync(W,{recursive:!0}),console.log(`${M.blue}Building ${M.bright}${$}${M.reset}...`);let U=null,_=async()=>{try{let L={name:"public-assets",setup(w){w.onResolve({filter:/^\/(images|fonts|assets|public)\//},(R)=>{return{path:R.path,external:!0}})}},F=await Bun.build({entrypoints:[K],outdir:W,plugins:[L,k$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!F.success)return console.error(`${M.red}Build failed:${M.reset}`,F.logs),!1;let A=F.outputs.find((w)=>w.path.endsWith(".html"));if(!A)return console.error(`${M.red}No HTML output found${M.reset}`),!1;return U=await Bun.file(A.path).text(),!0}catch(L){return console.error(`${M.red}Error building stx file:${M.reset}`,L),!1}};if(!await _())return!1;let B=B1.dirname(K);await _5(B);let q=Y;try{if(q=await W6(Y),q!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${q} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let L=Z.hmrPort||q+1;Q=n7({wsPort:L,verbose:!1}),G=Q.start(L)}let j={},H=null;try{let{loadStxConfig:L}=await Promise.resolve().then(() => (B6(),p6)),F=await L();if(F?.apiRouter)H=F?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(F?.apiRoutes){j=F.apiRoutes;let A=Object.keys(j).length;if(A>0)console.log(`${M.blue}Loaded ${M.bright}${A} API route${A>1?"s":""}${M.reset}`)}if(F?.broadcasting?.enabled)try{let{startBroadcasting:A,loadChannels:N}=await Promise.resolve().then(() => (sY(),SG)),w=F.broadcasting;await A(w);let R=w.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${R}/ws${M.reset}`);let T=B1.join(process.cwd(),"channels.ts");if(s1.existsSync(T))try{let E=await N(T);console.log(`${M.blue}Loaded ${M.bright}${E} broadcast channel${E!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(E){console.warn(`${M.yellow}Failed to load channels.ts: ${E.message}${M.reset}`)}}catch(A){console.warn(`${M.yellow}Broadcasting failed to start: ${A.message}${M.reset}`)}}catch{}if(console.log(`${M.blue}Starting server on ${M.cyan}http://localhost:${q}/${M.reset}...`),J)console.log(`${M.magenta}Hot reload enabled on ws://localhost:${G}${M.reset}`);let O=Uv({port:q,async fetch(L){let F=new URL(L.url);if(H)try{let T=await H.handleRequest(L);if(T.status!==404)return T}catch{}if(j[F.pathname])try{return await j[F.pathname](L)}catch(T){return new Response(JSON.stringify({error:T.message}),{status:500,headers:{"Content-Type":"application/json"}})}if(F.pathname==="/")return(async()=>{let E=await S0(U||"");if(J)E=Q4(E,G);if(Z.native)if(E.includes("<head>"))E=E.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(E.includes("<html"))E=E.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 E="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+E;if(Z.titlebarHidden)if(E.includes("<head>"))E=E.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else if(E.includes("<html"))E=E.replace(/(<html[^>]*>)/,"$1<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>");else E=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${E}`;return E})().then((E)=>new Response(E,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}}));let A=B1.join(W,F.pathname);if(s1.existsSync(A)&&s1.statSync(A).isFile()){let T=Bun.file(A),E=B1.extname(A).toLowerCase(),I="text/plain";if(E===".ts"||E===".tsx"){let k=new Bun.Transpiler({loader:E===".tsx"?"tsx":"ts"}),S=await T.text(),x=k.transformSync(S);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(E){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":I}})}let N=B1.dirname(K),w=B1.join(N,F.pathname);if(s1.existsSync(w)&&s1.statSync(w).isFile()){let T=Bun.file(w),E=B1.extname(w).toLowerCase(),I="text/plain";if(E===".ts"||E===".tsx"){let k=new Bun.Transpiler({loader:E===".tsx"?"tsx":"ts"}),S=await T.text(),x=k.transformSync(S);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(E){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":I}})}let R=B1.join(process.cwd(),"public",F.pathname);if(s1.existsSync(R)&&s1.statSync(R).isFile()){let T=Bun.file(R),E=B1.extname(R).toLowerCase(),I="application/octet-stream";if(E===".ts"||E===".tsx"){let k=new Bun.Transpiler({loader:E===".tsx"?"tsx":"ts"}),S=await T.text(),x=k.transformSync(S);return new Response(x,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(E){case".html":I="text/html";break;case".css":I="text/css";break;case".js":I="text/javascript";break;case".json":I="application/json";break;case".png":I="image/png";break;case".jpg":case".jpeg":I="image/jpeg";break;case".gif":I="image/gif";break;case".svg":I="image/svg+xml";break;case".ico":I="image/x-icon";break;case".woff":I="font/woff";break;case".woff2":I="font/woff2";break;case".ttf":I="font/ttf";break;case".otf":I="font/otf";break;case".eot":I="application/vnd.ms-fontobject";break}return new Response(T,{headers:{"Content-Type":I}})}return new Response("Not Found",{status:404})},error(L){return new Response(`<pre>${L}
|
|
16537
16537
|
${L.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
16538
16538
|
${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
|
|
16539
16539
|
${M.bright}\u2192 ${M.cyan}http://localhost:${q}/${M.reset}`),console.log(`
|
|
16540
16540
|
${M.yellow}Routes:${M.reset}`);let V=B1.relative(process.cwd(),K);if(console.log(` ${M.green}\u2514\u2500 /${M.reset} \u2192 ${M.bright}${V}${M.reset}`),console.log(`
|
|
16541
|
-
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),
|
|
16541
|
+
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),U6(O.url.toString(),()=>{if(X)s1.watch(B1.dirname(K),{recursive:!0}).close();O.stop()}),Z.native){let L=await Bun.file(K).text(),F=IY(L);await J$(q,{title:B1.basename(K,".stx"),titlebarHidden:Z.titlebarHidden===!0,nativeSidebar:!!F,sidebarConfig:F})}if(X){let L=B1.dirname(K);console.log(`${M.blue}Watching ${M.bright}${L}${M.reset} for changes...`);let F=s1.watch(L,{recursive:!0},async(A,N)=>{if(!N||i7(N))return;if(p7(N)){console.log(`${M.yellow}File ${M.bright}${N}${M.yellow} changed, rebuilding...${M.reset}`),o4.clear(),Y6();let w=await _();if(await a$(B),J&&Q)if(w)Q.reload(N);else Q.error("Build failed - check console for details")}else if(l7(N)){if(console.log(`${M.cyan}CSS ${M.bright}${N}${M.cyan} changed${M.reset}`),J&&Q)Q.updateCss(N)}});process.on("SIGINT",()=>{if(F.close(),Q)K$();O.stop(),process.exit(0)})}return!0}var ZA=D(()=>{R5();MX();w0();c7();pQ()});var{serve:_v}=globalThis.Bun;import V6 from"fs";import G1 from"path";function DW($){if($.length===0)return"";if($.length===1)return $[0];let Z=$.map((X)=>X.split(G1.sep)),Y=[];for(let X=0;X<Z[0].length;X++){let J=Z[0][X];if(Z.every((Q)=>Q[X]===J))Y.push(J);else break}return Y.join(G1.sep)}async function p8($,Z={}){let Y=Z.port||3000,X=Z.watch!==!1;for(let j of $){let H=G1.resolve(j);if(!V6.existsSync(H))return console.error(`${M.red}Error: File not found: ${M.bright}${H}${M.reset}`),!1;if(!H.endsWith(".stx")&&!H.endsWith(".md"))return console.error(`${M.red}Error: Unsupported file type: ${M.bright}${H}${M.reset}. Only .stx and .md files are supported.`),!1}let J=G1.join(process.cwd(),".stx/output");V6.mkdirSync(J,{recursive:!0});let Q=DW($.map((j)=>G1.dirname(G1.resolve(j))));console.log(`${M.blue}Processing ${M.bright}${$.length}${M.reset} files...`);let G={},K=[],W=async()=>{try{for(let j of $){let H=G1.resolve(j);if(H.endsWith(".md"))try{let{content:V,data:L}=await F4(H,{markdown:{syntaxHighlighting:{serverSide:!0,enabled:!0,defaultTheme:F1.markdown?.syntaxHighlighting?.defaultTheme||"github-dark",highlightUnknownLanguages:!0}}}),F=Z.markdown?.syntaxHighlighting||F1.markdown?.syntaxHighlighting,A=F?.defaultTheme||"github-dark",N=["github-dark"],w=F?.additionalThemes||[],T=[...new Set([...N,...w])].map((S)=>`<option value="${S}"${S===A?" selected":""}>${S}</option>`).join(`
|
|
16542
16542
|
`),E=`
|
|
16543
16543
|
<!DOCTYPE html>
|
|
16544
16544
|
<html lang="en">
|
|
@@ -16701,19 +16701,19 @@ Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),_6(O.u
|
|
|
16701
16701
|
</script>
|
|
16702
16702
|
</body>
|
|
16703
16703
|
</html>
|
|
16704
|
-
`,k=`/${G1.relative(Q,H).replace(/\.md$/,"")}`;if(k.endsWith("/index"))k=k.slice(0,-6)||"/";G[k||"/"]={filePath:H,content:E,fileType:"md"}}catch(V){console.error(`${M.red}Error processing Markdown file ${M.bright}${j}${M.reset}:`,V);continue}else{let V={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(T)=>{return{path:T.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:J,plugins:[V,k$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${M.red}Build failed for ${M.bright}${j}${M.reset}:`,L.logs);continue}let F=L.outputs.find((R)=>R.path.endsWith(".html"));if(!F){console.error(`${M.red}No HTML output found for ${M.bright}${j}${M.reset}`);continue}let A=await Bun.file(F.path).text(),w=`/${G1.relative(Q,H).replace(/\.stx$/,"")}`;if(w.endsWith("/index"))w=w.slice(0,-6)||"/";if(w.includes("[")){let R=[...w.matchAll(/\[([^\]]+)\]/g)].map((E)=>E[1]),T=w.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${T}$`),paramNames:R,filePath:H,routeTemplate:w,fileType:"stx"}),G[w]={filePath:H,content:A,fileType:"stx"}}else G[w||"/"]={filePath:H,content:A,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${M.red}No files were successfully processed${M.reset}`),!1;return!0}catch(j){return console.error(`${M.red}Error processing files:${M.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await
|
|
16704
|
+
`,k=`/${G1.relative(Q,H).replace(/\.md$/,"")}`;if(k.endsWith("/index"))k=k.slice(0,-6)||"/";G[k||"/"]={filePath:H,content:E,fileType:"md"}}catch(V){console.error(`${M.red}Error processing Markdown file ${M.bright}${j}${M.reset}:`,V);continue}else{let V={name:"public-assets",setup(R){R.onResolve({filter:/^\/(images|fonts|assets|public)\//},(T)=>{return{path:T.path,external:!0}})}},L=await Bun.build({entrypoints:[H],outdir:J,plugins:[V,k$],define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!L.success){console.error(`${M.red}Build failed for ${M.bright}${j}${M.reset}:`,L.logs);continue}let F=L.outputs.find((R)=>R.path.endsWith(".html"));if(!F){console.error(`${M.red}No HTML output found for ${M.bright}${j}${M.reset}`);continue}let A=await Bun.file(F.path).text(),w=`/${G1.relative(Q,H).replace(/\.stx$/,"")}`;if(w.endsWith("/index"))w=w.slice(0,-6)||"/";if(w.includes("[")){let R=[...w.matchAll(/\[([^\]]+)\]/g)].map((E)=>E[1]),T=w.replace(/\[([^\]]+)\]/g,"([^/]+)");K.push({pattern:new RegExp(`^${T}$`),paramNames:R,filePath:H,routeTemplate:w,fileType:"stx"}),G[w]={filePath:H,content:A,fileType:"stx"}}else G[w||"/"]={filePath:H,content:A,fileType:"stx"}}}if(Object.keys(G).length===0)return console.error(`${M.red}No files were successfully processed${M.reset}`),!1;return!0}catch(j){return console.error(`${M.red}Error processing files:${M.reset}`,j),!1}};if(!await W())return!1;let _=Y;try{if(_=await W6(Y),_!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${_} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}console.log(`${M.blue}Starting server on ${M.cyan}http://localhost:${_}/${M.reset}...`);let z=_v({port:_,async fetch(j){let H=new URL(j.url),O=G1.join(process.cwd(),"public",H.pathname);if(V6.existsSync(O)&&V6.statSync(O).isFile()){let F=Bun.file(O),A=G1.extname(O).toLowerCase(),N="application/octet-stream";if(A===".ts"||A===".tsx"){let w=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),R=await F.text(),T=w.transformSync(R);return new Response(T,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":N="text/html";break;case".css":N="text/css";break;case".js":N="text/javascript";break;case".json":N="application/json";break;case".png":N="image/png";break;case".jpg":case".jpeg":N="image/jpeg";break;case".gif":N="image/gif";break;case".svg":N="image/svg+xml";break;case".ico":N="image/x-icon";break;case".woff":N="font/woff";break;case".woff2":N="font/woff2";break;case".ttf":N="font/ttf";break;case".otf":N="font/otf";break;case".eot":N="application/vnd.ms-fontobject";break}return new Response(F,{headers:{"Content-Type":N}})}let V=G[H.pathname];if(!V&&!H.pathname.endsWith("/"))V=G[`${H.pathname}/`];if(!V)for(let F of K){let A=H.pathname.match(F.pattern);if(A){let N=G[F.routeTemplate];if(N){let w={};for(let E=0;E<F.paramNames.length;E++)w[F.paramNames[E]]=decodeURIComponent(A[E+1]);let R=N.content,T=`<script>window.__routeParams = ${JSON.stringify(w)};</script>`;if(R.includes("</head>"))R=R.replace("</head>",`${T}
|
|
16705
16705
|
</head>`);else R=T+R;V={...N,content:R}}break}}if(V)return S0(V.content).then((F)=>{if(F.includes("</head>"))F=F.replace("</head>",`${KK}
|
|
16706
|
-
</head>`);return new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let L=G1.join(J,H.pathname);if(
|
|
16706
|
+
</head>`);return new Response(F,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})});let L=G1.join(J,H.pathname);if(V6.existsSync(L)&&V6.statSync(L).isFile()){let F=Bun.file(L),A=G1.extname(L).toLowerCase(),N="text/plain";if(A===".ts"||A===".tsx"){let w=new Bun.Transpiler({loader:A===".tsx"?"tsx":"ts"}),R=await F.text(),T=w.transformSync(R);return new Response(T,{headers:{"Content-Type":"application/javascript","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}switch(A){case".html":N="text/html";break;case".css":N="text/css";break;case".js":N="text/javascript";break;case".json":N="application/json";break;case".png":N="image/png";break;case".jpg":case".jpeg":N="image/jpeg";break;case".gif":N="image/gif";break;case".svg":N="image/svg+xml";break;case".ico":N="image/x-icon";break;case".woff":N="font/woff";break;case".woff2":N="font/woff2";break;case".ttf":N="font/ttf";break;case".otf":N="font/otf";break;case".eot":N="application/vnd.ms-fontobject";break}return new Response(F,{headers:{"Content-Type":N}})}if(H.pathname!=="/"&&G["/"]){let F=j.headers.get("X-STX-Router")==="true";return S0(G["/"].content).then((A)=>{if(F){let N=A.match(/<main[^>]*>([\s\S]*?)<\/main>/i);if(N){let w=A.match(/<title[^>]*>([\s\S]*?)<\/title>/i),T=`<!DOCTYPE html><html><head><title>${w?w[1]:""}</title></head><body><main>${N[1]}</main></body></html>`;return new Response(T,{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(A,{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}
|
|
16707
16707
|
${j.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});console.clear(),console.log(`
|
|
16708
16708
|
${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
|
|
16709
16709
|
${M.bright}\u2192 ${M.cyan}http://localhost:${_}/${M.reset}`),console.log(`
|
|
16710
16710
|
${M.yellow}Routes:${M.reset}`);let B=new Set(K.map((j)=>j.routeTemplate)),q=Object.entries(G).filter(([j])=>!B.has(j)).sort(([j],[H])=>j.localeCompare(H)).map(([j,H])=>({route:j==="/"?"/":j,filePath:G1.relative(process.cwd(),H.filePath),fileType:H.fileType}));for(let j of K){let H=j.routeTemplate.replace(/\[([^\]]+)\]/g,":$1");q.push({route:H,filePath:G1.relative(process.cwd(),j.filePath),fileType:"stx"})}if(q.sort((j,H)=>j.route.localeCompare(H.route)),q.forEach((j,H)=>{let V=H===q.length-1?"\u2514\u2500 ":"\u251C\u2500 ",L=j.fileType==="md"?`${M.magenta}(markdown)${M.reset}`:"";console.log(` ${M.green}${V}${j.route}${M.reset} \u2192 ${M.bright}${j.filePath}${M.reset} ${L}`)}),console.log(`
|
|
16711
|
-
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),_6(z.url.toString(),()=>{if(X)F6.watch(Q,{recursive:!0}).close();z.stop()}),X){console.log(`${M.blue}Watching for changes...${M.reset}`);let j=F6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${M.yellow}File ${M.bright}${O}${M.yellow} changed, rebuilding...${M.reset}`),t4.clear(),X6(),await W()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}var YA=D(()=>{y5();i0();R5();MX();w0();c7()});var{serve:zv}=globalThis.Bun;import N1 from"fs";import F0 from"path";function SW($){let Z=Bun.file($),Y=F0.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 i8($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=F0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (q6(),i6)),U=await W(K),_=U.root&&U.root!=="."?F0.join(K,U.root):K,z=U.pagesDir||"pages",B=F0.join(_,z);if(!N1.existsSync(B))return console.error(`${M.red}Error: No '${z}' directory found in ${M.bright}${_}${M.reset}`),console.log(`${M.dim}Create a ${z}/ directory with .stx files to define your routes.${M.reset}`),console.log(`${M.dim}Example: ${z}/index.stx for the homepage.${M.reset}`),!1;let q=T4(_);if(q.length===0)return console.error(`${M.red}Error: No page files found in ${M.bright}${B}${M.reset}`),!1;console.log(`${M.blue}Found ${M.bright}${q.length}${M.blue} routes${M.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:C,prefix:h}of j)if(N1.existsSync(C)){let m=T4(F0.dirname(C),{pagesDir:F0.basename(C)});for(let r of m){let o=h==="/"?r.pattern:`${h}${r.pattern==="/"?"":r.pattern}`;H.push({route:{...r,pattern:o},prefix:h})}if(m.length>0)console.log(`${M.blue}Plugin pages: ${M.bright}${m.length}${M.blue} routes at ${M.cyan}${h}${M.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await zG(K,Z.stxOptions?.shell),L){if(V=await pY(L,Z.stxOptions||{}),V)console.log(`${M.blue}Using app shell: ${M.bright}${F0.relative(K,L)}${M.reset} ${M.dim}(deprecated: use layouts/default.stx instead)${M.reset}`)}}X8(),await K8(K);let F=G8();if(F.length>0)console.log(`${M.blue}Loaded ${M.bright}${F.length}${M.blue} middleware: ${M.dim}${F.join(", ")}${M.reset}`);let A={},N=null;try{let{loadStxConfig:C}=await Promise.resolve().then(() => (q6(),i6)),h=await C(K);if(h?.apiRouter)N=h?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(h?.apiRoutes){A=h.apiRoutes;let m=Object.keys(A).length;if(m>0)console.log(`${M.blue}Loaded ${M.bright}${m} API route${m>1?"s":""}${M.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:m,loadChannels:r}=await Promise.resolve().then(() => (sY(),SG)),o=h.broadcasting;await m(o);let B0=o.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${B0}/ws${M.reset}`);let G0=F0.join(process.cwd(),"channels.ts");if(N1.existsSync(G0))try{let C0=await r(G0);console.log(`${M.blue}Loaded ${M.bright}${C0} broadcast channel${C0!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(C0){console.warn(`${M.yellow}Failed to load channels.ts: ${C0.message}${M.reset}`)}}catch(m){console.warn(`${M.yellow}Broadcasting failed to start: ${m.message}${M.reset}`)}}catch{}let w=F0.join(K,".stx/output");N1.mkdirSync(w,{recursive:!0});let R=new Map,T=new Set,E=async(C)=>{let h=qG(B,C);if(!h)return null;try{let m=await Bun.build({entrypoints:[h],outdir:w,plugins:[k$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!m.success)return null;let r=m.outputs.find((o)=>o.path.endsWith(".html"));if(!r)return null;return await Bun.file(r.path).text()}catch{return null}},I=async(C,h)=>{try{let{processDirectives:m,extractVariables:r,defaultConfig:o,loadStxConfig:B0,injectRouterScript:G0}=await Promise.resolve().then(() => (q6(),i6)),{checkCache:C0,cacheTemplate:Y1,readFileCached:u,templateCache:c}=await Promise.resolve().then(() => (x6(),D5)),d=await B0(K),v=(L0)=>{if(!L0)return L0;if(F0.isAbsolute(L0))return L0;return F0.resolve(K,L0)},l={...o,...d,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)l.debug=!0;l.partialsDir=v(l.partialsDir),l.componentsDir=v(l.componentsDir),l.layoutsDir=v(l.layoutsDir),l.storesDir=v(l.storesDir||"stores"),l.cachePath=v(l.cachePath||".stx/cache");let a=!h&&!Z.profile,i=l.cache!==!1;if(i&&a){let L0=c.get(C.filePath);if(L0)try{if((await N1.promises.stat(C.filePath)).mtime.getTime()<=L0.mtime){let b1=!0;for(let K1 of L0.dependencies){if(!N1.existsSync(K1)){b1=!1;break}if((await N1.promises.stat(K1)).mtime.getTime()>L0.mtime){b1=!1;break}}if(b1){let K1=L0.output;if(V)K1=M4(K1,{preserveHead:!0});return{route:C,content:K1}}}}catch{}let q1=await C0(C.filePath,l);if(q1){let w1=q1;if(V)w1=M4(w1,{preserveHead:!0});return{route:C,content:w1}}}let Q0=i?await u(C.filePath):await Bun.file(C.filePath).text(),{classifyAllScripts:E0}=await Promise.resolve().then(() => (q6(),i6)),N0=E0(Q0),k0=N0.server.map((L0)=>L0.content),s0=Q0;for(let L0 of N0.server)s0=s0.replace(L0.fullTag,"");let q0={__filename:C.filePath,__dirname:F0.dirname(C.filePath),params:h??{}},{resetHead:_4}=await Promise.resolve().then(() => (p4(),s3));_4();for(let L0 of k0)try{await r(L0,q0,C.filePath)}catch(q1){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",C.filePath,q1?.message||q1)}let z0=new Set,l0;if(Z.profile){let L0=performance.now();l0=await m(s0,q0,C.filePath,l,z0);let q1=performance.now()-L0,w1=F0.relative(K,C.filePath)||C.filePath;console.log(`[stx:profile] ${w1} \u2192 ${q1.toFixed(2)}ms`)}else l0=await m(s0,q0,C.filePath,l,z0);if(!V)l0=await G0(l0);{let{interpolateScriptExpressions:L0}=await Promise.resolve().then(() => (o0(),p$));l0=l0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(q1,w1,b1)=>{if(!/function\s+__stx_setup_/.test(b1))return q1;return`<script${w1}>${L0(b1,q0)}</script>`})}if(V)l0=M4(l0,{preserveHead:!0});if(i&&a)await Y1(C.filePath,l0,z0,l);let{extractStreamBoundaries:X5}=await Promise.resolve().then(() => (n4(),S6)),f1=X5(q0),C4=q0.__streamTemplates;if(C4&&typeof C4==="object"&&Object.keys(C4).length>0){let L0=q0.streamBoundaries||{},q1={...l,autoShell:!1},w1=Object.keys(C4).map((K1)=>({id:K1,render:async()=>{let XU=typeof L0[K1]==="function"?await L0[K1]():void 0;return m(C4[K1],{...q0,$boundary:XU},C.filePath,q1,new Set)}})),b1=new Set(w1.map((K1)=>K1.id));f1=[...(f1||[]).filter((K1)=>!b1.has(K1.id)),...w1]}if(f1&&f1.length>0)T.add(C.pattern);else f1=void 0;return{route:C,content:l0,boundaries:f1}}catch(m){return console.error(`${M.red}Error building ${M.bright}${C.pattern}${M.reset}:`,m),null}},k=8,S=async()=>{R.clear(),O.clear();for(let C=0;C<q.length;C+=k){let h=q.slice(C,C+k),m=await Promise.all(h.map((r)=>I(r)));for(let r of m)if(r)R.set(r.route.pattern,r)}for(let C=0;C<H.length;C+=k){let h=H.slice(C,C+k),m=await Promise.all(h.map(({route:r})=>I(r)));for(let r of m)if(r)O.set(r.route.pattern,r)}return R.size>0};if(console.log(`${M.blue}Building pages...${M.reset}`),!await S())return console.error(`${M.red}No pages were successfully built${M.reset}`),!1;await z5(K);let P=Y;try{if(P=await U6(Y),P!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${P} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let C=Z.hmrPort||P+1;Q=n7({wsPort:C,verbose:!1}),G=Q.start(C)}let b=(C,h)=>{let m=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(C.includes("</head>"))return C.replace("</head>",`${m}</head>`);if(C.includes("<body"))return C.replace(/<body([^>]*)>/,`<body$1>${m}`);return m+C};console.log(`${M.blue}Starting server...${M.reset}`);let g=zv({port:P,async fetch(C){let h=new URL(C.url),m=U?.publicDir||"public",r=F0.join(K,m,h.pathname),o=F0.join(K,h.pathname),B0=F0.join(w,h.pathname),[G0,C0,Y1]=await Promise.all([N1.promises.stat(r).catch(()=>null),N1.promises.stat(o).catch(()=>null),N1.promises.stat(B0).catch(()=>null)]);if(G0?.isFile())return SW(r);if(C0?.isFile())return SW(o);if(Y1?.isFile())return SW(B0);if(h.pathname.startsWith("/_stx/component/")){let v=decodeURIComponent(h.pathname.slice(16));if(v)try{let l=`<${v} />`,a={...buildConfig,autoShell:!1},i=await processDirectives(l,{},F0.join(K,"components",`${v}.stx`),a,new Set);return new Response(i,{headers:{"Content-Type":"text/html"}})}catch(l){return new Response(`<div class="stx-async-error">${l.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(h.pathname==="/_stx/img"){let{handleImageRequest:v}=await Promise.resolve().then(() => (eQ(),oH)),l=await v(C,{publicDir:F0.join(K,m),cacheDir:F0.join(K,".stx/cache/img")});if(l)return l}if(N)try{let v=await N.handleRequest(C);if(v.status!==404)return v}catch{}if(A[h.pathname])try{return await A[h.pathname](C)}catch(v){return new Response(JSON.stringify({error:v.message}),{status:500,headers:{"Content-Type":"application/json"}})}let u=iY(h.pathname,q);if(u){let v=R.get(u.route.pattern),l=T.has(u.route.pattern);if(u.route.isDynamic&&Object.keys(u.params).length>0||l){let a=await I(u.route,u.params);if(a)v=a}if(v){let a=a3();if(a.validate){if(!await a.validate({params:u.params})){let E0=await E(404);if(E0){let N0=E0;if(N0=await S0(N0,K),J)N0=Q4(N0,G);return new Response(N0,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(a.middleware){let Q0=Q8(h.pathname,u.params,a,h.search),E0=J8(Q0,null,C),N0=await W8(a.middleware,E0);if(N0.redirect){let k0=N0.redirect.path,s0=N0.redirect.options.redirectCode||302,q0=new Headers(N0.responseHeaders);return q0.set("Location",k0),new Response(null,{status:s0,headers:q0})}if(N0.abort){let{statusCode:k0,message:s0}=N0.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${k0}</title></head><body><h1>Error ${k0}</h1><p>${s0}</p></body></html>`,{status:k0,headers:{"Content-Type":"text/html"}})}if(Object.keys(N0.state).length>0){let k0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(N0.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;v.content=v.content.replace("</head>",`${k0}</head>`)}}let i=v.content;if(V&&BG(C)){let Q0=B8(i),E0=i.match(/<title[^>]*>([\s\S]*?)<\/title>/i),N0=E0?E0[1].trim():"";if(Object.keys(u.params).length>0)i=b(i,u.params);i=await S0(i,K);let k0=U?.router?.container||"main";return i=z8(i,k0),new Response(i,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Q0.layout,"X-STX-Layout-Group":Q0.group,...N0&&{"X-STX-Title":encodeURIComponent(N0)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)i=_8(V,i);if(Object.keys(u.params).length>0)i=b(i,u.params);if(i=await S0(i,K),J)i=Q4(i,G);if(Z.native)if(i.includes("<head>"))i=i.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else i="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+i;if(Z.titlebarHidden)if(i.includes("<head>"))i=i.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else i=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${i}`;if(v.boundaries&&v.boundaries.length>0){let{renderStreamingPage:Q0,streamToResponse:E0}=await Promise.resolve().then(() => (n4(),S6));return E0(Q0(i,v.boundaries,{timeoutMs:30000}),{headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let v=H.map((a)=>a.route),l=iY(h.pathname,v);if(l){let a=O.get(l.route.pattern);if(a){let i=a.content;if(V)i=_8(V,i);if(Object.keys(l.params).length>0)i=b(i,l.params);if(i=await S0(i,K),J)i=Q4(i,G);return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of j)if(a!=="/"&&h.pathname.startsWith(a)){let i=O.get(a)||O.get(a+"/");if(i){let Q0=i.content;if(V)Q0=_8(V,Q0);if(Q0=await S0(Q0,K),J)Q0=Q4(Q0,G);return new Response(Q0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let c=R.get("/");if(c){let v=c.content;if(v=await S0(v,K),J)v=Q4(v,G);if(Z.native)if(v.includes("<head>"))v=v.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 v="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+v;return new Response(v,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let d=await E(404);if(d){let v=d;if(v=await S0(v,K),J)v=Q4(v,G);return new Response(v,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(C){let h=await E(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${C}
|
|
16711
|
+
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),U6(z.url.toString(),()=>{if(X)V6.watch(Q,{recursive:!0}).close();z.stop()}),X){console.log(`${M.blue}Watching for changes...${M.reset}`);let j=V6.watch(Q,{recursive:!0},async(H,O)=>{if(!O)return;if(O.endsWith(".stx")||O.endsWith(".js")||O.endsWith(".ts")||O.endsWith(".md"))console.log(`${M.yellow}File ${M.bright}${O}${M.yellow} changed, rebuilding...${M.reset}`),o4.clear(),Y6(),await W()});process.on("SIGINT",()=>{j.close(),z.stop(),process.exit(0)})}return!0}var YA=D(()=>{y5();i0();R5();MX();w0();c7()});var{serve:zv}=globalThis.Bun;import N1 from"fs";import F0 from"path";function SW($){let Z=Bun.file($),Y=F0.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 i8($=".",Z={}){let Y=Z.port||3000,X=Z.watch!==!1,J=Z.hotReload!==!1&&X,Q=null,G=Z.hmrPort||Y+1,K=F0.resolve($),{loadStxConfig:W}=await Promise.resolve().then(() => (B6(),p6)),U=await W(K),_=U.root&&U.root!=="."?F0.join(K,U.root):K,z=U.pagesDir||"pages",B=F0.join(_,z);if(!N1.existsSync(B))return console.error(`${M.red}Error: No '${z}' directory found in ${M.bright}${_}${M.reset}`),console.log(`${M.dim}Create a ${z}/ directory with .stx files to define your routes.${M.reset}`),console.log(`${M.dim}Example: ${z}/index.stx for the homepage.${M.reset}`),!1;let q=T4(_);if(q.length===0)return console.error(`${M.red}Error: No page files found in ${M.bright}${B}${M.reset}`),!1;console.log(`${M.blue}Found ${M.bright}${q.length}${M.blue} routes${M.reset}`);let j=U?._pluginPageDirs||[],H=[];for(let{dir:C,prefix:h}of j)if(N1.existsSync(C)){let m=T4(F0.dirname(C),{pagesDir:F0.basename(C)});for(let r of m){let o=h==="/"?r.pattern:`${h}${r.pattern==="/"?"":r.pattern}`;H.push({route:{...r,pattern:o},prefix:h})}if(m.length>0)console.log(`${M.blue}Plugin pages: ${M.bright}${m.length}${M.blue} routes at ${M.cyan}${h}${M.reset}`)}let O=new Map,V=null,L=null;if(Z.stxOptions?.shell!==!1){if(L=await zG(K,Z.stxOptions?.shell),L){if(V=await pY(L,Z.stxOptions||{}),V)console.log(`${M.blue}Using app shell: ${M.bright}${F0.relative(K,L)}${M.reset} ${M.dim}(deprecated: use layouts/default.stx instead)${M.reset}`)}}X8(),await K8(K);let F=G8();if(F.length>0)console.log(`${M.blue}Loaded ${M.bright}${F.length}${M.blue} middleware: ${M.dim}${F.join(", ")}${M.reset}`);let A={},N=null;try{let{loadStxConfig:C}=await Promise.resolve().then(() => (B6(),p6)),h=await C(K);if(h?.apiRouter)N=h?.apiRouter,console.log(`${M.blue}Using custom router for API handling${M.reset}`);if(h?.apiRoutes){A=h.apiRoutes;let m=Object.keys(A).length;if(m>0)console.log(`${M.blue}Loaded ${M.bright}${m} API route${m>1?"s":""}${M.reset}`)}if(h?.broadcasting?.enabled)try{let{startBroadcasting:m,loadChannels:r}=await Promise.resolve().then(() => (sY(),SG)),o=h.broadcasting;await m(o);let B0=o.port??6001;console.log(`${M.magenta}Broadcasting on ${M.cyan}ws://localhost:${B0}/ws${M.reset}`);let G0=F0.join(process.cwd(),"channels.ts");if(N1.existsSync(G0))try{let C0=await r(G0);console.log(`${M.blue}Loaded ${M.bright}${C0} broadcast channel${C0!==1?"s":""}${M.blue} from channels.ts${M.reset}`)}catch(C0){console.warn(`${M.yellow}Failed to load channels.ts: ${C0.message}${M.reset}`)}}catch(m){console.warn(`${M.yellow}Broadcasting failed to start: ${m.message}${M.reset}`)}}catch{}let w=F0.join(K,".stx/output");N1.mkdirSync(w,{recursive:!0});let R=new Map,T=new Set,E=async(C)=>{let h=qG(B,C);if(!h)return null;try{let m=await Bun.build({entrypoints:[h],outdir:w,plugins:[k$],publicPath:"/",define:{"process.env.NODE_ENV":'"development"'},...Z.stxOptions});if(!m.success)return null;let r=m.outputs.find((o)=>o.path.endsWith(".html"));if(!r)return null;return await Bun.file(r.path).text()}catch{return null}},I=async(C,h)=>{try{let{processDirectives:m,extractVariables:r,defaultConfig:o,loadStxConfig:B0,injectRouterScript:G0}=await Promise.resolve().then(() => (B6(),p6)),{checkCache:C0,cacheTemplate:Y1,readFileCached:u,templateCache:c}=await Promise.resolve().then(() => (y6(),D5)),d=await B0(K),v=(L0)=>{if(!L0)return L0;if(F0.isAbsolute(L0))return L0;return F0.resolve(K,L0)},l={...o,...d,...Z.stxOptions,autoShell:!0};if(Z.debugDirectives)l.debug=!0;l.partialsDir=v(l.partialsDir),l.componentsDir=v(l.componentsDir),l.layoutsDir=v(l.layoutsDir),l.storesDir=v(l.storesDir||"stores"),l.cachePath=v(l.cachePath||".stx/cache");let a=!h&&!Z.profile,i=l.cache!==!1;if(i&&a){let L0=c.get(C.filePath);if(L0)try{if((await N1.promises.stat(C.filePath)).mtime.getTime()<=L0.mtime){let b1=!0;for(let K1 of L0.dependencies){if(!N1.existsSync(K1)){b1=!1;break}if((await N1.promises.stat(K1)).mtime.getTime()>L0.mtime){b1=!1;break}}if(b1){let K1=L0.output;if(V)K1=M4(K1,{preserveHead:!0});return{route:C,content:K1}}}}catch{}let q1=await C0(C.filePath,l);if(q1){let w1=q1;if(V)w1=M4(w1,{preserveHead:!0});return{route:C,content:w1}}}let Q0=i?await u(C.filePath):await Bun.file(C.filePath).text(),{classifyAllScripts:E0}=await Promise.resolve().then(() => (B6(),p6)),N0=E0(Q0),k0=N0.server.map((L0)=>L0.content),s0=Q0;for(let L0 of N0.server)s0=s0.replace(L0.fullTag,"");let q0={__filename:C.filePath,__dirname:F0.dirname(C.filePath),params:h??{}},{resetHead:_4}=await Promise.resolve().then(() => (p4(),s3));_4();for(let L0 of k0)try{await r(L0,q0,C.filePath)}catch(q1){if(Z.stxOptions?.debug)console.error("[stx] variable extraction error",C.filePath,q1?.message||q1)}let z0=new Set,l0;if(Z.profile){let L0=performance.now();l0=await m(s0,q0,C.filePath,l,z0);let q1=performance.now()-L0,w1=F0.relative(K,C.filePath)||C.filePath;console.log(`[stx:profile] ${w1} \u2192 ${q1.toFixed(2)}ms`)}else l0=await m(s0,q0,C.filePath,l,z0);if(!V)l0=await G0(l0);{let{interpolateScriptExpressions:L0}=await Promise.resolve().then(() => (o0(),p$));l0=l0.replace(/<script\b([^>]*)>([\s\S]*?)<\/script>/g,(q1,w1,b1)=>{if(!/function\s+__stx_setup_/.test(b1))return q1;return`<script${w1}>${L0(b1,q0)}</script>`})}if(V)l0=M4(l0,{preserveHead:!0});if(i&&a)await Y1(C.filePath,l0,z0,l);let{extractStreamBoundaries:Y5}=await Promise.resolve().then(() => (n4(),k6)),f1=Y5(q0),C4=q0.__streamTemplates;if(C4&&typeof C4==="object"&&Object.keys(C4).length>0){let L0=q0.streamBoundaries||{},q1={...l,autoShell:!1},w1=Object.keys(C4).map((K1)=>({id:K1,render:async()=>{let XU=typeof L0[K1]==="function"?await L0[K1]():void 0;return m(C4[K1],{...q0,$boundary:XU},C.filePath,q1,new Set)}})),b1=new Set(w1.map((K1)=>K1.id));f1=[...(f1||[]).filter((K1)=>!b1.has(K1.id)),...w1]}if(f1&&f1.length>0)T.add(C.pattern);else f1=void 0;return{route:C,content:l0,boundaries:f1}}catch(m){return console.error(`${M.red}Error building ${M.bright}${C.pattern}${M.reset}:`,m),null}},k=8,S=async()=>{R.clear(),O.clear();for(let C=0;C<q.length;C+=k){let h=q.slice(C,C+k),m=await Promise.all(h.map((r)=>I(r)));for(let r of m)if(r)R.set(r.route.pattern,r)}for(let C=0;C<H.length;C+=k){let h=H.slice(C,C+k),m=await Promise.all(h.map(({route:r})=>I(r)));for(let r of m)if(r)O.set(r.route.pattern,r)}return R.size>0};if(console.log(`${M.blue}Building pages...${M.reset}`),!await S())return console.error(`${M.red}No pages were successfully built${M.reset}`),!1;await _5(K);let P=Y;try{if(P=await W6(Y),P!==Y)console.log(`${M.yellow}Port ${Y} is busy, using port ${P} instead${M.reset}`)}catch{return console.error(`${M.red}Could not find an available port${M.reset}`),!1}if(J){let C=Z.hmrPort||P+1;Q=n7({wsPort:C,verbose:!1}),G=Q.start(C)}let b=(C,h)=>{let m=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._rp=${JSON.stringify(h)};if(s.setRouteParams)s.setRouteParams(s._rp);})()</script>`;if(C.includes("</head>"))return C.replace("</head>",`${m}</head>`);if(C.includes("<body"))return C.replace(/<body([^>]*)>/,`<body$1>${m}`);return m+C};console.log(`${M.blue}Starting server...${M.reset}`);let g=zv({port:P,async fetch(C){let h=new URL(C.url),m=U?.publicDir||"public",r=F0.join(K,m,h.pathname),o=F0.join(K,h.pathname),B0=F0.join(w,h.pathname),[G0,C0,Y1]=await Promise.all([N1.promises.stat(r).catch(()=>null),N1.promises.stat(o).catch(()=>null),N1.promises.stat(B0).catch(()=>null)]);if(G0?.isFile())return SW(r);if(C0?.isFile())return SW(o);if(Y1?.isFile())return SW(B0);if(h.pathname.startsWith("/_stx/component/")){let v=decodeURIComponent(h.pathname.slice(16));if(v)try{let l=`<${v} />`,a={...buildConfig,autoShell:!1},i=await processDirectives(l,{},F0.join(K,"components",`${v}.stx`),a,new Set);return new Response(i,{headers:{"Content-Type":"text/html"}})}catch(l){return new Response(`<div class="stx-async-error">${l.message}</div>`,{status:500,headers:{"Content-Type":"text/html"}})}}if(h.pathname==="/_stx/img"){let{handleImageRequest:v}=await Promise.resolve().then(() => (eQ(),oH)),l=await v(C,{publicDir:F0.join(K,m),cacheDir:F0.join(K,".stx/cache/img")});if(l)return l}if(N)try{let v=await N.handleRequest(C);if(v.status!==404)return v}catch{}if(A[h.pathname])try{return await A[h.pathname](C)}catch(v){return new Response(JSON.stringify({error:v.message}),{status:500,headers:{"Content-Type":"application/json"}})}let u=iY(h.pathname,q);if(u){let v=R.get(u.route.pattern),l=T.has(u.route.pattern);if(u.route.isDynamic&&Object.keys(u.params).length>0||l){let a=await I(u.route,u.params);if(a)v=a}if(v){let a=a3();if(a.validate){if(!await a.validate({params:u.params})){let E0=await E(404);if(E0){let N0=E0;if(N0=await S0(N0,K),J)N0=Q4(N0,G);return new Response(N0,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})}}if(a.middleware){let Q0=Q8(h.pathname,u.params,a,h.search),E0=J8(Q0,null,C),N0=await W8(a.middleware,E0);if(N0.redirect){let k0=N0.redirect.path,s0=N0.redirect.options.redirectCode||302,q0=new Headers(N0.responseHeaders);return q0.set("Location",k0),new Response(null,{status:s0,headers:q0})}if(N0.abort){let{statusCode:k0,message:s0}=N0.abort.error;return new Response(`<!DOCTYPE html><html><head><title>Error ${k0}</title></head><body><h1>Error ${k0}</h1><p>${s0}</p></body></html>`,{status:k0,headers:{"Content-Type":"text/html"}})}if(Object.keys(N0.state).length>0){let k0=`<script>(function(){var s=typeof stx!=='undefined'?stx:{};s._ms=${JSON.stringify(N0.state)};if(s.setMiddlewareState)s.setMiddlewareState(s._ms);})()</script>`;v.content=v.content.replace("</head>",`${k0}</head>`)}}let i=v.content;if(V&&BG(C)){let Q0=B8(i),E0=i.match(/<title[^>]*>([\s\S]*?)<\/title>/i),N0=E0?E0[1].trim():"";if(Object.keys(u.params).length>0)i=b(i,u.params);i=await S0(i,K);let k0=U?.router?.container||"main";return i=z8(i,k0),new Response(i,{headers:{"Content-Type":"text/html","X-STX-Fragment":"true","X-STX-Layout":Q0.layout,"X-STX-Layout-Group":Q0.group,...N0&&{"X-STX-Title":encodeURIComponent(N0)},"Cache-Control":"no-store, no-cache, must-revalidate"}})}if(V)i=_8(V,i);if(Object.keys(u.params).length>0)i=b(i,u.params);if(i=await S0(i,K),J)i=Q4(i,G);if(Z.native)if(i.includes("<head>"))i=i.replace("<head>","<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script>");else i="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+i;if(Z.titlebarHidden)if(i.includes("<head>"))i=i.replace("<head>","<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script>");else i=`<head><style>html.stx-titlebar-hidden .stx-traffic-lights-dot{visibility:hidden}</style><script>document.documentElement.classList.add('stx-titlebar-hidden')</script></head>${i}`;if(v.boundaries&&v.boundaries.length>0){let{renderStreamingPage:Q0,streamToResponse:E0}=await Promise.resolve().then(() => (n4(),k6));return E0(Q0(i,v.boundaries,{timeoutMs:30000}),{headers:{"Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}if(H.length>0){let v=H.map((a)=>a.route),l=iY(h.pathname,v);if(l){let a=O.get(l.route.pattern);if(a){let i=a.content;if(V)i=_8(V,i);if(Object.keys(l.params).length>0)i=b(i,l.params);if(i=await S0(i,K),J)i=Q4(i,G);return new Response(i,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}for(let{prefix:a}of j)if(a!=="/"&&h.pathname.startsWith(a)){let i=O.get(a)||O.get(a+"/");if(i){let Q0=i.content;if(V)Q0=_8(V,Q0);if(Q0=await S0(Q0,K),J)Q0=Q4(Q0,G);return new Response(Q0,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}}}let c=R.get("/");if(c){let v=c.content;if(v=await S0(v,K),J)v=Q4(v,G);if(Z.native)if(v.includes("<head>"))v=v.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 v="<head><style>[data-stx-sidebar],.stx-sidebar{display:none!important}</style><script>window.__craftNativeSidebar=true;document.documentElement.classList.add('has-native-sidebar')</script></head>"+v;return new Response(v,{headers:{"Content-Type":"text/html","Cache-Control":"no-store, no-cache, must-revalidate",Pragma:"no-cache",Expires:"0"}})}let d=await E(404);if(d){let v=d;if(v=await S0(v,K),J)v=Q4(v,G);return new Response(v,{status:404,headers:{"Content-Type":"text/html"}})}return new Response("Not Found",{status:404})},async error(C){let h=await E(500);if(h)return new Response(h,{status:500,headers:{"Content-Type":"text/html"}});return new Response(`<pre>${C}
|
|
16712
16712
|
${C.stack}</pre>`,{headers:{"Content-Type":"text/html"}})}});if(console.clear(),console.log(`
|
|
16713
16713
|
${M.blue}stx${M.reset} ${M.green}${process.env.stx_VERSION||"v0.0.10"}${M.reset} ${M.dim}ready in ${Math.random()*10+5|0}.${Math.random()*90+10|0} ms${M.reset}`),console.log(`
|
|
16714
16714
|
${M.bright}\u2192 ${M.cyan}http://localhost:${P}/${M.reset}`),J)console.log(`${M.dim} HMR: ws://localhost:${G}${M.reset}`);console.log(`
|
|
16715
16715
|
${M.yellow}Routes:${M.reset}`);let p=[...jG(q,K)];for(let{route:C}of H)p.push(`${C.pattern}`);if(p.forEach((C,h)=>{let r=h===p.length-1?"\u2514\u2500 ":"\u251C\u2500 ";console.log(` ${M.green}${r}${M.reset}${C}`)}),console.log(`
|
|
16716
|
-
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),
|
|
16716
|
+
Press ${M.cyan}h${M.reset} + ${M.cyan}Enter${M.reset} to show shortcuts`),U6(g.url.toString(),()=>{if(Q)K$();g.stop()}),Z.native){let C,h=F0.join(B,"index.stx");if(N1.existsSync(h)){let r=await Bun.file(h).text();C=IY(r)}let m=U?.app?.window??{};await J$(P,{title:U?.app?.head?.title||F0.basename(K)||"stx App",width:m.width,height:m.height,darkMode:m.darkMode,hotReload:m.hotReload,titlebarHidden:m.titlebarHidden??Z.titlebarHidden===!0,nativeSidebar:!!C,sidebarConfig:C})}if(X){console.log(`${M.blue}Watching for changes...${M.reset}`);let C=(r)=>{return r.startsWith("public/")||r.startsWith("public\\")},h=(r)=>{let o=r.toLowerCase();return o.endsWith(".stx")||o.endsWith(".html")||o.endsWith(".md")},m=N1.watch(K,{recursive:!0},async(r,o)=>{if(!o||i7(o))return;if(p7(o))if(C(o)){if(console.log(`${M.cyan}${o} changed${M.reset}`),J&&Q)Q.reload(o)}else if(h(o)){console.log(`${M.yellow}${o} changed, rebuilding...${M.reset}`),o4.clear(),Y6();try{let{invalidateFileCache:B0,templateCache:G0}=await Promise.resolve().then(() => (y6(),D5));B0(F0.resolve(K,o)),G0.delete(F0.resolve(K,o))}catch{}if(L&&o){if(F0.resolve(K,o)===L||F0.basename(L)===o){let G0=await pY(L,Z.stxOptions||{});if(G0)V=G0}}if(await S(),await a$(K),J&&Q)Q.reload(o)}else{console.log(`${M.yellow}${o} changed, rebuilding...${M.reset}`),o4.clear(),Y6();try{let{invalidateFileCache:B0,templateCache:G0}=await Promise.resolve().then(() => (y6(),D5));B0(F0.resolve(K,o)),G0.delete(F0.resolve(K,o))}catch{}if(await S(),J&&Q)Q.reload(o)}else if(l7(o)){if(console.log(`${M.cyan}CSS ${o} changed${M.reset}`),J&&Q)Q.updateCss(o)}});process.on("SIGINT",()=>{if(m.close(),Q)K$();g.stop(),process.exit(0)})}return!0}var XA=D(()=>{O$();R5();MX();q8();cY();p4();w0();c7()});var kW=D(()=>{pQ();ZA();YA();XA()});var KA={};e(KA,{runPwaAudit:()=>Bv,formatAuditResult:()=>qv,calculateAuditResult:()=>GA,auditConfig:()=>JA,auditBuildOutput:()=>QA});import e6 from"fs";import TX from"path";function JA($){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 QA($){let Z=[],Y=TX.join($,"manifest.json"),X=e6.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(e6.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=TX.join($,"sw.js"),Q=e6.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=TX.join($,"offline.html"),K=e6.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=TX.join($,"pwa-icons");if(e6.existsSync(W)){let _=e6.readdirSync(W).filter((z)=>z.endsWith(".png")||z.endsWith(".webp"));Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:_.length>0,message:_.length>0?`${_.length} icon files generated`:"No icon files found"})}else Z.push({id:"build-icons",name:"Generated Icons",category:"required",passed:!1,message:"Icons directory not found"});return Z}function GA($){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 Bv($,Z){let Y=JA($),X=Z&&e6.existsSync(Z)?QA(Z):[];return GA([...Y,...X])}function qv($){let Z=[];Z.push(`
|
|
16717
16717
|
=== PWA Audit Report ===
|
|
16718
16718
|
`);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}
|
|
16719
16719
|
`);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(`
|
|
@@ -18893,21 +18893,21 @@ ${Y}`);return Y+$}var OA=()=>{};function VA($,Z={}){let{classPrefix:Y="craft"}=Z
|
|
|
18893
18893
|
document.addEventListener('craft:nativeui:ready', initializeCraftComponents);
|
|
18894
18894
|
})();
|
|
18895
18895
|
</script>
|
|
18896
|
-
`;return $=$.replace(/<@craft-sidebar\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(X,J,Q)=>{return SX("sidebar",J,Q.trim(),Z,Y)}),$=$.replace(/<@craft-sidebar\s*([^>]*?)\/>/g,(X,J)=>{return SX("sidebar",J,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(X,J,Q)=>{return SX(J,Q,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(X,J,Q,G)=>{return SX(J,Q,G.trim(),Z,Y)}),$}function SX($,Z,Y,X,J){let Q=X.components?.[$]||fv[$];if(!Q)return console.warn(`[stx] Unknown Craft component: @craft-${$}`),`<div class="${J}-unknown" data-component="${$}">${Y}</div>`;let G=yW(Z),K=[Q.fallbackClasses||`${J}-${$}`];if(G.class)K.push(G.class),delete G.class;if(Q.render)return G.__fallbackClasses=K.join(" "),Q.render(G,Y);let W=nv(G,Q,K);if(["input","hr","br","img"].includes(Q.fallbackTag))return`<${Q.fallbackTag} ${W}>`;return`<${Q.fallbackTag} ${W}>${Y}</${Q.fallbackTag}>`}function yW($){let Z={},Y=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,X;while((X=Y.exec($))!==null){let[J,Q,G,K]=X,W=G??K;if(J.startsWith(":"))Z[Q]=W;else if(J.startsWith("@"))Z[`on${Q.charAt(0).toUpperCase()}${Q.slice(1)}`]=W;else if(W===void 0)Z[Q]=!0;else Z[Q]=W}return Z}function gv($,Z){let Y=CX(String($.id||`craft-sidebar-${pv(Z||JSON.stringify($))}`)),X=cv($.sections)||uv(Z),J=String($.selectedItem||$.selected||X[0]?.items[0]?.id||""),Q={id:Y,variant:String($.variant||"desktop"),material:String($.material||"sidebar"),backgroundEffect:String($.backgroundEffect||"shimmer"),allowsVibrancy:$.allowsVibrancy!==!1&&$.allowsVibrancy!=="false",materialOpacity:Number($.materialOpacity??0.68),materialDarkOpacity:$.materialDarkOpacity===void 0?void 0:Number($.materialDarkOpacity),minWidth:$.minWidth===void 0?240:Number($.minWidth),maxWidth:$.maxWidth===void 0?340:Number($.maxWidth),canCollapse:$.canCollapse!==!1&&$.canCollapse!=="false",searchPlaceholder:$.searchPlaceholder?String($.searchPlaceholder):void 0,selectedItem:J,sections:X},G=String($.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),K=Number($.width||$.sidebarWidth||286),W=$.native===!1||$.native==="false"?"false":"true",U=Q.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${C$(Q.searchPlaceholder)}"></div>`:"",_=X.length?X.map((z)=>lv(z,J)).join(""):Z;return`<aside class="${
|
|
18896
|
+
`;return $=$.replace(/<@craft-sidebar\s*([^>]*)>([\s\S]*?)<\/@craft-sidebar>/g,(X,J,Q)=>{return SX("sidebar",J,Q.trim(),Z,Y)}),$=$.replace(/<@craft-sidebar\s*([^>]*?)\/>/g,(X,J)=>{return SX("sidebar",J,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*?)\/>/g,(X,J,Q)=>{return SX(J,Q,"",Z,Y)}),$=$.replace(/<@craft-(\w+[-\w]*)\s*([^>]*)>([\s\S]*?)<\/@craft-\1>/g,(X,J,Q,G)=>{return SX(J,Q,G.trim(),Z,Y)}),$}function SX($,Z,Y,X,J){let Q=X.components?.[$]||fv[$];if(!Q)return console.warn(`[stx] Unknown Craft component: @craft-${$}`),`<div class="${J}-unknown" data-component="${$}">${Y}</div>`;let G=yW(Z),K=[Q.fallbackClasses||`${J}-${$}`];if(G.class)K.push(G.class),delete G.class;if(Q.render)return G.__fallbackClasses=K.join(" "),Q.render(G,Y);let W=nv(G,Q,K);if(["input","hr","br","img"].includes(Q.fallbackTag))return`<${Q.fallbackTag} ${W}>`;return`<${Q.fallbackTag} ${W}>${Y}</${Q.fallbackTag}>`}function yW($){let Z={},Y=/(?::|@)?(\w+[-\w]*)(?:=(?:"([^"]*)"|'([^']*)'))?/g,X;while((X=Y.exec($))!==null){let[J,Q,G,K]=X,W=G??K;if(J.startsWith(":"))Z[Q]=W;else if(J.startsWith("@"))Z[`on${Q.charAt(0).toUpperCase()}${Q.slice(1)}`]=W;else if(W===void 0)Z[Q]=!0;else Z[Q]=W}return Z}function gv($,Z){let Y=CX(String($.id||`craft-sidebar-${pv(Z||JSON.stringify($))}`)),X=cv($.sections)||uv(Z),J=String($.selectedItem||$.selected||X[0]?.items[0]?.id||""),Q={id:Y,variant:String($.variant||"desktop"),material:String($.material||"sidebar"),backgroundEffect:String($.backgroundEffect||"shimmer"),allowsVibrancy:$.allowsVibrancy!==!1&&$.allowsVibrancy!=="false",materialOpacity:Number($.materialOpacity??0.68),materialDarkOpacity:$.materialDarkOpacity===void 0?void 0:Number($.materialDarkOpacity),minWidth:$.minWidth===void 0?240:Number($.minWidth),maxWidth:$.maxWidth===void 0?340:Number($.maxWidth),canCollapse:$.canCollapse!==!1&&$.canCollapse!=="false",searchPlaceholder:$.searchPlaceholder?String($.searchPlaceholder):void 0,selectedItem:J,sections:X},G=String($.__fallbackClasses||"craft-sidebar craft-sidebar-tahoe"),K=Number($.width||$.sidebarWidth||286),W=$.native===!1||$.native==="false"?"false":"true",U=Q.searchPlaceholder?`<div class="craft-sidebar-search"><input type="search" placeholder="${C$(Q.searchPlaceholder)}"></div>`:"",_=X.length?X.map((z)=>lv(z,J)).join(""):Z;return`<aside class="${F6(G)}" data-craft="craft-sidebar" data-craft-native-sidebar data-craft-sidebar-id="${F6(Y)}" data-native="${W}" style="--craft-sidebar-width:${K}px">
|
|
18897
18897
|
${U}
|
|
18898
18898
|
${_}
|
|
18899
18899
|
</aside>
|
|
18900
|
-
<script type="application/json" data-craft-sidebar-config="${
|
|
18900
|
+
<script type="application/json" data-craft-sidebar-config="${F6(Y)}">${iv(Q)}</script>`}function hv($,Z){let Y=String($.header||$.title||"");return`<section class="craft-sidebar-section" data-craft="craft-sidebar-section" data-section-id="${F6(String($.id||"section"))}">
|
|
18901
18901
|
${Y?`<div class="craft-sidebar-section-title">${C$(Y)}</div>`:""}
|
|
18902
18902
|
${Z}
|
|
18903
|
-
</section>`}function dv($,Z){let Y={id:String($.id||CX(String($.label||Z||"item"))),label:String($.label||Z||""),icon:$.icon?String($.icon):void 0,badge:$.badge?String($.badge):void 0,tintColor:$.tintColor?String($.tintColor):void 0};return FA(Y,String($.selected||"")==="true")}function uv($){let Z=[],Y=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,X;while((X=Y.exec($))!==null){let J=yW(X[1]||""),Q=X[2]||"",G=String(J.id||CX(String(J.header||J.title||`section-${Z.length+1}`))),K=String(J.header||J.title||G),W=mv(Q);Z.push({id:G,header:K,title:K,items:W})}return Z}function mv($){let Z=[],Y=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,X;while((X=Y.exec($))!==null){let J=yW(X[1]||""),Q=String(J.label||(X[2]||"").replace(/<[^>]*>/g,"").trim()),G=String(J.id||CX(Q||`item-${Z.length+1}`));Z.push({id:G,label:Q,icon:J.icon?String(J.icon):void 0,badge:J.badge?String(J.badge):void 0,tintColor:J.tintColor?String(J.tintColor):void 0})}return Z}function cv($){if(!$)return;if(Array.isArray($))return $;if(typeof $!=="string")return;try{let Z=JSON.parse($);return Array.isArray(Z)?Z:void 0}catch{return}}function lv($,Z){let Y=$.header||$.title||$.id;return`<section class="craft-sidebar-section" data-section-id="${
|
|
18903
|
+
</section>`}function dv($,Z){let Y={id:String($.id||CX(String($.label||Z||"item"))),label:String($.label||Z||""),icon:$.icon?String($.icon):void 0,badge:$.badge?String($.badge):void 0,tintColor:$.tintColor?String($.tintColor):void 0};return FA(Y,String($.selected||"")==="true")}function uv($){let Z=[],Y=/<@craft-sidebar-section\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-section>)/g,X;while((X=Y.exec($))!==null){let J=yW(X[1]||""),Q=X[2]||"",G=String(J.id||CX(String(J.header||J.title||`section-${Z.length+1}`))),K=String(J.header||J.title||G),W=mv(Q);Z.push({id:G,header:K,title:K,items:W})}return Z}function mv($){let Z=[],Y=/<@craft-sidebar-item\s*([^>]*?)(?:\/>|>([\s\S]*?)<\/@craft-sidebar-item>)/g,X;while((X=Y.exec($))!==null){let J=yW(X[1]||""),Q=String(J.label||(X[2]||"").replace(/<[^>]*>/g,"").trim()),G=String(J.id||CX(Q||`item-${Z.length+1}`));Z.push({id:G,label:Q,icon:J.icon?String(J.icon):void 0,badge:J.badge?String(J.badge):void 0,tintColor:J.tintColor?String(J.tintColor):void 0})}return Z}function cv($){if(!$)return;if(Array.isArray($))return $;if(typeof $!=="string")return;try{let Z=JSON.parse($);return Array.isArray(Z)?Z:void 0}catch{return}}function lv($,Z){let Y=$.header||$.title||$.id;return`<section class="craft-sidebar-section" data-section-id="${F6($.id)}">
|
|
18904
18904
|
<div class="craft-sidebar-section-title">${C$(Y)}</div>
|
|
18905
18905
|
${$.items.map((X)=>FA(X,X.id===Z)).join("")}
|
|
18906
|
-
</section>`}function FA($,Z){let Y=$.tintColor?` style="--craft-sidebar-icon-color:${
|
|
18907
|
-
${$.icon?`<span class="craft-sidebar-item-icon" data-icon="${
|
|
18906
|
+
</section>`}function FA($,Z){let Y=$.tintColor?` style="--craft-sidebar-icon-color:${F6($.tintColor)}"`:"";return`<button class="craft-sidebar-item" type="button" data-item-id="${F6($.id)}" data-selected="${Z?"true":"false"}">
|
|
18907
|
+
${$.icon?`<span class="craft-sidebar-item-icon" data-icon="${F6($.icon)}"${Y}></span>`:""}
|
|
18908
18908
|
<span class="craft-sidebar-item-label">${C$($.label)}</span>
|
|
18909
18909
|
${$.badge?`<span class="craft-sidebar-item-badge">${C$($.badge)}</span>`:""}
|
|
18910
|
-
</button>`}function CX($){return $.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function pv($){let Z=5381;for(let Y=0;Y<$.length;Y++)Z=Z*33^$.charCodeAt(Y);return(Z>>>0).toString(36)}function C$($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function
|
|
18910
|
+
</button>`}function CX($){return $.trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-|-$/g,"")||"craft-sidebar"}function pv($){let Z=5381;for(let Y=0;Y<$.length;Y++)Z=Z*33^$.charCodeAt(Y);return(Z>>>0).toString(36)}function C$($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function F6($){return C$($).replace(/`/g,"`")}function iv($){return JSON.stringify($).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026")}function nv($,Z,Y){let X=[];X.push(`class="${Y.join(" ")}"`),X.push(`data-craft="${Z.nativeType}"`);for(let[J,Q]of Object.entries($))if(Q===!0)X.push(J);else if(Q!==!1&&Q!==void 0&&Q!==null){let G=String(Q).replace(/"/g,""");X.push(`${J}="${G}"`)}return X.join(" ")}var fv,LA=`
|
|
18911
18911
|
<style id="craft-component-styles">
|
|
18912
18912
|
/* Craft Component Base Styles */
|
|
18913
18913
|
.craft-button {
|
|
@@ -19297,7 +19297,7 @@ ${Y}`);return Y+$}var OA=()=>{};function VA($,Z={}){let{classPrefix:Y="craft"}=Z
|
|
|
19297
19297
|
</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">
|
|
19298
19298
|
${X?`<div class="craft-alert-title">${X}</div>`:""}
|
|
19299
19299
|
<div class="craft-alert-content">${Z}</div>
|
|
19300
|
-
</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"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections"],render:gv},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:hv},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:dv},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 IA={};e(IA,{getAvailableTargets:()=>TA,getAvailableFormats:()=>EA,default:()=>Uf,buildNative:()=>MA});import{existsSync as wA,mkdirSync as v1,copyFileSync as $3,chmodSync as
|
|
19300
|
+
</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"]},sidebar:{nativeType:"craft-sidebar",fallbackTag:"aside",fallbackClasses:"craft-sidebar craft-sidebar-tahoe",nativeProps:["id","variant","material","backgroundEffect","allowsVibrancy","materialOpacity","materialDarkOpacity","minWidth","maxWidth","canCollapse","searchPlaceholder","selectedItem","sections"],render:gv},"sidebar-section":{nativeType:"craft-sidebar-section",fallbackTag:"section",fallbackClasses:"craft-sidebar-section",nativeProps:["id","title","header"],render:hv},"sidebar-item":{nativeType:"craft-sidebar-item",fallbackTag:"button",fallbackClasses:"craft-sidebar-item",nativeProps:["id","label","icon","badge","tintColor"],render:dv},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 IA={};e(IA,{getAvailableTargets:()=>TA,getAvailableFormats:()=>EA,default:()=>Uf,buildNative:()=>MA});import{existsSync as wA,mkdirSync as v1,copyFileSync as $3,chmodSync as $5}from"fs";import{join as Z0,basename as rv}from"path";import{spawn as bX,execSync as av}from"child_process";import{tmpdir as RA,homedir as NA,platform as sv}from"os";async function MA($){let Z=Date.now();try{if(!await Bun.file($.input).exists())return{success:!1,target:$.target||e8(),format:$.format||"app",error:`Input file not found: ${$.input}`};let Y=$.target||e8(),X=$.format||Xf(Y),J=$.output||Z0(process.cwd(),"dist","native");if(!wA(J))v1(J,{recursive:!0});let Q=await Bun.file($.input).text();if(Q=HA(Q,{debug:$.verbose}),Q=VA(Q),!Q.includes("craft-component-styles")){if(Q.includes("</head>"))Q=Q.replace("</head>",`${LA}
|
|
19301
19301
|
</head>`)}let G=$.name||rv($.input,".stx"),K=$.version||"1.0.0",W=$.craftPath||await Yf();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 ov(Q,G,K,J,X,$,W);break;case"windows":U=await tv(Q,G,K,J,X,$,W);break;case"linux":U=await ev(Q,G,K,J,X,$,W);break;case"ios":U=await $f(Q,G,K,J,$,W);break;case"android":U=await Zf(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||e8(),format:$.format||"app",error:Y.message,duration:Date.now()-Z}}}async function ov($,Z,Y,X,J,Q,G){let K=Q.bundleId||`com.stx.${Z.toLowerCase().replace(/[^a-z0-9]/g,"")}`,W=Z0(X,`${Z}.app`),U=Z0(W,"Contents"),_=Z0(U,"MacOS"),z=Z0(U,"Resources");v1(_,{recursive:!0}),v1(z,{recursive:!0});let B=Z0(z,"index.html");await Bun.write(B,$);let q="";if(Q.sidebar?.enabled&&Q.sidebar?.config)q=Z0(z,"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
|
|
19302
19302
|
DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
19303
19303
|
RESOURCES="$DIR/../Resources"
|
|
@@ -19310,8 +19310,8 @@ RESOURCES="$DIR/../Resources"
|
|
|
19310
19310
|
${Q.window?.frameless?"--frameless":""} \\
|
|
19311
19311
|
${Q.window?.alwaysOnTop?"--always-on-top":""} \\
|
|
19312
19312
|
${j}
|
|
19313
|
-
`,O=Z0(_,Z);await Bun.write(O,H)
|
|
19314
|
-
exec "${G}" "$@"`;await Bun.write(V,F)
|
|
19313
|
+
`,O=Z0(_,Z);await Bun.write(O,H),$5(O,493);let V=Z0(_,"craft");try{$3(G,V),$5(V,493)}catch{let F=`#!/bin/bash
|
|
19314
|
+
exec "${G}" "$@"`;await Bun.write(V,F),$5(V,493)}let L=`<?xml version="1.0" encoding="UTF-8"?>
|
|
19315
19315
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
19316
19316
|
<plist version="1.0">
|
|
19317
19317
|
<dict>
|
|
@@ -19356,7 +19356,7 @@ DIR="$( cd "$( dirname "\${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
19356
19356
|
--height ${Q.window?.height||800} \\
|
|
19357
19357
|
${Q.systemTray?"--system-tray":""} \\
|
|
19358
19358
|
${Q.devTools?"--dev-tools":""}
|
|
19359
|
-
`,_=Z0(K,Z.toLowerCase());await Bun.write(_,U)
|
|
19359
|
+
`,_=Z0(K,Z.toLowerCase());await Bun.write(_,U),$5(_,493);let z=`[Desktop Entry]
|
|
19360
19360
|
Type=Application
|
|
19361
19361
|
Name=${Z}
|
|
19362
19362
|
Exec=${_}
|
|
@@ -19364,7 +19364,7 @@ Terminal=false
|
|
|
19364
19364
|
Categories=Utility;
|
|
19365
19365
|
`;if(await Bun.write(Z0(K,`${Z.toLowerCase()}.desktop`),z),J==="deb"){let B=Z0(X,`${Z.toLowerCase()}_${Y}_amd64.deb`),q=await Gf(K,B,Z,Y,Q);if(!q.success)return{success:!1,target:"linux",format:"deb",error:q.error};return{success:!0,target:"linux",format:"deb",outputPath:B}}if(J==="appimage"){let B=Z0(X,`${Z}-${Y}-x86_64.AppImage`),q=await Kf(K,B,Z,Q);if(!q.success)return{success:!1,target:"linux",format:"appimage",error:q.error};return{success:!0,target:"linux",format:"appimage",outputPath:B}}return{success:!0,target:"linux",format:"app",outputPath:K}}async function $f($,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 Zf($,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 Yf(){let $=[Z0(process.cwd(),"../../craft/packages/zig/zig-out/bin/craft-minimal"),Z0(process.cwd(),"../craft/packages/zig/zig-out/bin/craft-minimal"),Z0(NA(),"Code/craft/packages/zig/zig-out/bin/craft-minimal"),"/usr/local/bin/craft","/usr/bin/craft",Z0(NA(),".local/bin/craft"),Z0(process.env.LOCALAPPDATA||"","craft","craft.exe"),Z0(process.env.PROGRAMFILES||"","craft","craft.exe")];for(let Z of $)if(await Bun.file(Z).exists())return Z;try{let Y=av("which craft 2>/dev/null || where craft 2>nul",{encoding:"utf-8"}).trim().split(`
|
|
19366
19366
|
`)[0];if(Y&&await Bun.file(Y).exists())return Y}catch{}return null}function e8(){switch(sv()){case"darwin":return"macos";case"win32":return"windows";default:return"linux"}}function Xf($){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 Jf($,Z,Y){return new Promise((X)=>{let J=bX("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 Qf($,Z){return new Promise((Y)=>{let X=bX("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 Gf($,Z,Y,X,J){return new Promise((Q)=>{try{let G=Z0(RA(),`stx-deb-${Date.now()}`),K=Z0(G,"DEBIAN"),W=Z0(G,"usr","bin"),U=Z0(G,"usr","share","applications"),_=Z0(G,"usr","share",Y.toLowerCase());v1(K,{recursive:!0}),v1(W,{recursive:!0}),v1(U,{recursive:!0}),v1(_,{recursive:!0});let z=$0("fs").readdirSync($);for(let H of z)$3(Z0($,H),Z0(_,H));let B=`#!/bin/bash
|
|
19367
|
-
exec /usr/share/${Y.toLowerCase()}/${Y.toLowerCase()} "$@"`;$0("fs").writeFileSync(Z0(W,Y.toLowerCase()),B)
|
|
19367
|
+
exec /usr/share/${Y.toLowerCase()}/${Y.toLowerCase()} "$@"`;$0("fs").writeFileSync(Z0(W,Y.toLowerCase()),B),$5(Z0(W,Y.toLowerCase()),493);let q=`Package: ${Y.toLowerCase()}
|
|
19368
19368
|
Version: ${X}
|
|
19369
19369
|
Section: utils
|
|
19370
19370
|
Priority: optional
|
|
@@ -19377,14 +19377,14 @@ SELF=$(readlink -f "$0")
|
|
|
19377
19377
|
HERE=\${SELF%/*}
|
|
19378
19378
|
export PATH="\${HERE}/usr/bin:\${PATH}"
|
|
19379
19379
|
exec "\${HERE}/usr/share/${Y.toLowerCase()}/${Y.toLowerCase()}" "$@"
|
|
19380
|
-
`;$0("fs").writeFileSync(Z0(G,"AppRun"),B)
|
|
19380
|
+
`;$0("fs").writeFileSync(Z0(G,"AppRun"),B),$5(Z0(G,"AppRun"),493);let q=`[Desktop Entry]
|
|
19381
19381
|
Type=Application
|
|
19382
19382
|
Name=${Y}
|
|
19383
19383
|
Exec=${Y.toLowerCase()}
|
|
19384
19384
|
Terminal=false
|
|
19385
19385
|
Categories=Utility;
|
|
19386
19386
|
Icon=${Y.toLowerCase()}
|
|
19387
|
-
`;$0("fs").writeFileSync(Z0(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($0("fs").writeFileSync(Z0(G,`${Y.toLowerCase()}.png`),j),X.icon&&wA(X.icon))$3(X.icon,Z0(G,`${Y.toLowerCase()}.png`));let H=bX("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if($0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)Z5(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)=>{$0("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 TA(){return[e8()]}function EA($){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 Wf,Uf;var DA=D(()=>{OA();AA();Wf={buildNative:MA,getAvailableTargets:TA,getAvailableFormats:EA,detectPlatform:e8},Uf=Wf});function Z3($,Z){return`${_f[Z]}${$}\x1B[0m`}function SA($,Z){return`${zf[Z]}${$}\x1B[0m`}function Y3(){console.log(""),console.log(Z1(" \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(Z1(" \u2551")+o1(" \uD83D\uDCD6 STX Story ")+Z1("\u2551")),console.log(Z1(" \u2551")+yX(" Component Showcase & Testing ")+Z1("\u2551")),console.log(Z1(" \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 vW($,Z){if(console.log(o1(" Server running at:")),console.log(""),console.log(` ${yX("\u279C")} ${o1("Local:")} ${Z1($)}`),Z)console.log(` ${yX("\u279C")} ${o1("Network:")} ${Z1(Z)}`);console.log("")}function X3($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?PX:xW;console.log(` ${Y(Z)} Found ${o1(String($))} story ${$===1?"file":"files"}`)}function CA($,Z){if(console.log(""),console.log(` ${kA("\u2717")} ${o1(kA("Error:"))} ${$}`),Z)console.log(` ${yX(Z)}`);console.log("")}function b$($){console.log(` ${xW("\u26A0")} ${xW("Warning:")} ${$}`)}function bA($){console.log(` ${Bf("\u2139")} ${$}`)}function PA($,Z,Y){console.log(""),console.log(Z1(" \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(Z1(" \u2551")+o1(" Build Complete ")+Z1("\u2551")),console.log(Z1(" \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(` ${PX("\u2713")} Stories: ${o1(String($))}`),console.log(` ${PX("\u2713")} Output: ${o1(Z)}`),console.log(` ${PX("\u2713")} Time: ${o1(`${Y}ms`)}`),console.log("")}function fW(){console.log(""),console.log(o1(" Keyboard Shortcuts:")),console.log(""),console.log(` ${Z1("h")} Show this help`),console.log(` ${Z1("o")} Open in browser`),console.log(` ${Z1("r")} Restart server`),console.log(` ${Z1("c")} Clear console`),console.log(` ${Z1("q")} Quit`),console.log("")}var _f,zf,kA=($)=>Z3($,"red"),PX=($)=>Z3($,"green"),xW=($)=>Z3($,"yellow"),Bf=($)=>Z3($,"blue"),Z1=($)=>Z3($,"cyan"),o1=($)=>SA($,"bold"),yX=($)=>SA($,"dim");var xX=D(()=>{_f={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"},zf={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import yA from"fs";import gW from"path";function xA($,Z){let Y=[gW.join($.root,"stx.config.ts"),gW.join($.root,"stx.config.js"),gW.join($.root,"stx.config.mjs")],X=Z.debounceMs??300,J=null,Q=[];for(let G of Y)try{if(!yA.existsSync(G))continue;let K=yA.watch(G,(W)=>{if(W==="change"){if(J)clearTimeout(J);J=setTimeout(async()=>{bA("Config file changed, restarting...");try{await Z.onChange()}catch(U){b$(`Failed to restart: ${U}`)}},X)}});Q.push(K)}catch{}return{stop(){if(J)clearTimeout(J);for(let G of Q)G.close()}}}var vA=D(()=>{xX()});function dA($){let Z={...qf,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...hA,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??fA,backgroundPresets:Z.backgroundPresets??gA,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var fA,gA,hA,qf;var uA=D(()=>{fA=[{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}],gA=[{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"}],hA={file:"title",order:"asc",groups:[]},qf={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:hA,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:fA,backgroundPresets:gA,autoApplyContrastColor:!1,port:6006}});var mA={};e(mA,{updateContextTree:()=>x$,updateContextStoryFiles:()=>y$,createContext:()=>P$});import jf from"path";async function P$($){let Z=$.root??process.cwd(),Y;try{let G=await import(jf.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let X={...Y,...$.config},J=dA(X);return{root:Z,config:J,storyFiles:[],tree:void 0,mode:$.mode}}function y$($,Z){$.storyFiles=Z}function x$($,Z){$.tree=Z}var J3=D(()=>{uA()});import hW from"fs";import cA from"path";class dW{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=cA.join($,Hf),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=hW.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Of,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=cA.dirname(this.storagePath);if(await hW.promises.mkdir($,{recursive:!0}),this.storage.events.length>lA)this.storage.events=this.storage.events.slice(-lA);await hW.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Lf(),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((B)=>B.componentId===$),X=Y.filter((B)=>B.type==="view"&&!B.metadata?.endView),J=Y.filter((B)=>B.type==="prop_change"),Q=Y.filter((B)=>B.type==="variant_switch"),G={};for(let B of J)if(B.propName)G[B.propName]=(G[B.propName]||0)+1;let K={};for(let B of Q)if(B.variantId)K[B.variantId]=(K[B.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((B)=>B.componentViews.includes($)).map((B)=>B.id)),U=Y.filter((B)=>B.metadata?.duration).map((B)=>B.metadata.duration),_=U.length>0?U.reduce((B,q)=>B+q,0)/U.length:0,z=Object.entries(G).sort((B,q)=>q[1]-B[1]).slice(0,5).map(([B])=>B);return{componentId:$,componentName:Z,viewCount:X.length,uniqueViews:W.size,lastViewed:X[X.length-1]?.timestamp,propChanges:G,topChangedProps:z,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 Lf(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Hf=".stx/story/analytics.json",Of=1,lA=1e4;var pA=()=>{};import uW from"fs";import iA from"path";class mW{storage;storagePath;dirty=!1;constructor($){this.storagePath=iA.join($,Vf),this.storage=this.loadStorage()}loadStorage(){try{let $=uW.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Ff,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=iA.dirname(this.storagePath);await uW.promises.mkdir($,{recursive:!0}),await uW.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,X={}){let J={id:Af(),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 Af(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Vf=".stx/story/bookmarks.json",Ff=1;var nA=()=>{};import cW from"fs";import Q3 from"path";async function G3($){let{root:Z,config:Y}=$,X=[],J=await Nf(Z,Y.storyMatch,Y.storyIgnored);for(let Q of J){let G=Q3.resolve(Z,Q),K=lW(Q,G);X.push(K)}return X}async function Nf($,Z,Y){let X=[];async function J(Q,G){let K=await cW.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=Q3.join(Q,W.name),_=Q3.relative(G,U);if(rA(_,Y))continue;if(W.isDirectory())await J(U,G);else if(W.isFile()){if(aA(_,Z))X.push(_)}}}return await J($,$),X}function rA($,Z){for(let Y of Z)if(sA($,Y))return!0;return!1}function aA($,Z){for(let Y of Z)if(sA($,Y))return!0;return!1}function sA($,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 lW($,Z){let Y=Q3.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 oA($,Z){let{root:Y,config:X}=$,J=[],Q=cW.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!aA(W,X.storyMatch))return;if(rA(W,X.storyIgnored))return;let U=Q3.resolve(Y,W);try{await cW.promises.access(U);let _=lW(W,U);Z(G==="rename"?"add":"change",_)}catch{let _=lW(W,U);Z("unlink",_)}});return J.push(Q),()=>{for(let G of J)G.close()}}var pW=()=>{};function wf($,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 K3($,Z){for(let G of Z)G.treePath=wf($,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=Rf(K,Y,X);Mf(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(...iW(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:iW(G.treeObject,J)});return Q}function Rf($,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 Mf($,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 iW($,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:iW(J,Z)});return Y.sort((X,J)=>Z(X.title,J.title)),Y}function tA(){return{open($){vX.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){vX.delete($)},message($,Z){}}}function nW($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of vX)try{Y.send(Z)}catch{vX.delete(Y)}}function eA($,Z){nW({type:"story-update",data:{storyId:$,...Z}})}function $N($,Z){nW({type:"story-add",data:{storyId:$,...Z}})}function ZN($){nW({type:"story-remove",data:{storyId:$}})}function YN($){return`
|
|
19387
|
+
`;$0("fs").writeFileSync(Z0(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($0("fs").writeFileSync(Z0(G,`${Y.toLowerCase()}.png`),j),X.icon&&wA(X.icon))$3(X.icon,Z0(G,`${Y.toLowerCase()}.png`));let H=bX("appimagetool",[G,Z],{env:{...process.env,ARCH:"x86_64"}});H.on("close",(O)=>{if($0("fs").rmSync(Q,{recursive:!0,force:!0}),O===0)$5(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)=>{$0("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 TA(){return[e8()]}function EA($){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 Wf,Uf;var DA=D(()=>{OA();AA();Wf={buildNative:MA,getAvailableTargets:TA,getAvailableFormats:EA,detectPlatform:e8},Uf=Wf});function Z3($,Z){return`${_f[Z]}${$}\x1B[0m`}function SA($,Z){return`${zf[Z]}${$}\x1B[0m`}function Y3(){console.log(""),console.log(Z1(" \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(Z1(" \u2551")+o1(" \uD83D\uDCD6 STX Story ")+Z1("\u2551")),console.log(Z1(" \u2551")+yX(" Component Showcase & Testing ")+Z1("\u2551")),console.log(Z1(" \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 vW($,Z){if(console.log(o1(" Server running at:")),console.log(""),console.log(` ${yX("\u279C")} ${o1("Local:")} ${Z1($)}`),Z)console.log(` ${yX("\u279C")} ${o1("Network:")} ${Z1(Z)}`);console.log("")}function X3($){let Z=$>0?"\u2713":"\u25CB",Y=$>0?PX:xW;console.log(` ${Y(Z)} Found ${o1(String($))} story ${$===1?"file":"files"}`)}function CA($,Z){if(console.log(""),console.log(` ${kA("\u2717")} ${o1(kA("Error:"))} ${$}`),Z)console.log(` ${yX(Z)}`);console.log("")}function b$($){console.log(` ${xW("\u26A0")} ${xW("Warning:")} ${$}`)}function bA($){console.log(` ${Bf("\u2139")} ${$}`)}function PA($,Z,Y){console.log(""),console.log(Z1(" \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(Z1(" \u2551")+o1(" Build Complete ")+Z1("\u2551")),console.log(Z1(" \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(` ${PX("\u2713")} Stories: ${o1(String($))}`),console.log(` ${PX("\u2713")} Output: ${o1(Z)}`),console.log(` ${PX("\u2713")} Time: ${o1(`${Y}ms`)}`),console.log("")}function fW(){console.log(""),console.log(o1(" Keyboard Shortcuts:")),console.log(""),console.log(` ${Z1("h")} Show this help`),console.log(` ${Z1("o")} Open in browser`),console.log(` ${Z1("r")} Restart server`),console.log(` ${Z1("c")} Clear console`),console.log(` ${Z1("q")} Quit`),console.log("")}var _f,zf,kA=($)=>Z3($,"red"),PX=($)=>Z3($,"green"),xW=($)=>Z3($,"yellow"),Bf=($)=>Z3($,"blue"),Z1=($)=>Z3($,"cyan"),o1=($)=>SA($,"bold"),yX=($)=>SA($,"dim");var xX=D(()=>{_f={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"},zf={bold:"\x1B[1m",dim:"\x1B[2m",italic:"\x1B[3m",underline:"\x1B[4m",inverse:"\x1B[7m",strikethrough:"\x1B[9m"}});import yA from"fs";import gW from"path";function xA($,Z){let Y=[gW.join($.root,"stx.config.ts"),gW.join($.root,"stx.config.js"),gW.join($.root,"stx.config.mjs")],X=Z.debounceMs??300,J=null,Q=[];for(let G of Y)try{if(!yA.existsSync(G))continue;let K=yA.watch(G,(W)=>{if(W==="change"){if(J)clearTimeout(J);J=setTimeout(async()=>{bA("Config file changed, restarting...");try{await Z.onChange()}catch(U){b$(`Failed to restart: ${U}`)}},X)}});Q.push(K)}catch{}return{stop(){if(J)clearTimeout(J);for(let G of Q)G.close()}}}var vA=D(()=>{xX()});function dA($){let Z={...qf,...$};return{enabled:Z.enabled??!0,outDir:Z.outDir??".stx/dist/story",storyMatch:Z.storyMatch??["**/*.story.stx"],storyIgnored:Z.storyIgnored??["**/node_modules/**","**/dist/**","**/.stx/**"],tree:{...hA,...Z.tree},theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark",...Z.theme},responsivePresets:Z.responsivePresets??fA,backgroundPresets:Z.backgroundPresets??gA,autoApplyContrastColor:Z.autoApplyContrastColor??!1,setupFile:Z.setupFile,port:Z.port??6006}}var fA,gA,hA,qf;var uA=D(()=>{fA=[{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}],gA=[{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"}],hA={file:"title",order:"asc",groups:[]},qf={enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],tree:hA,theme:{title:"STX Components",defaultColorScheme:"auto",darkClass:"dark"},responsivePresets:fA,backgroundPresets:gA,autoApplyContrastColor:!1,port:6006}});var mA={};e(mA,{updateContextTree:()=>x$,updateContextStoryFiles:()=>y$,createContext:()=>P$});import jf from"path";async function P$($){let Z=$.root??process.cwd(),Y;try{let G=await import(jf.join(Z,"stx.config.ts"));Y=(G.default||G).story}catch{}let X={...Y,...$.config},J=dA(X);return{root:Z,config:J,storyFiles:[],tree:void 0,mode:$.mode}}function y$($,Z){$.storyFiles=Z}function x$($,Z){$.tree=Z}var J3=D(()=>{uA()});import hW from"fs";import cA from"path";class dW{storage;storagePath;currentSession=null;dirty=!1;viewStartTimes=new Map;constructor($){this.storagePath=cA.join($,Hf),this.storage=this.loadStorage(),this.startSession()}loadStorage(){try{let $=hW.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Of,events:[],sessions:[]}}}async save(){if(!this.dirty)return;let $=cA.dirname(this.storagePath);if(await hW.promises.mkdir($,{recursive:!0}),this.storage.events.length>lA)this.storage.events=this.storage.events.slice(-lA);await hW.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}startSession(){this.endSession(),this.currentSession={id:Lf(),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((B)=>B.componentId===$),X=Y.filter((B)=>B.type==="view"&&!B.metadata?.endView),J=Y.filter((B)=>B.type==="prop_change"),Q=Y.filter((B)=>B.type==="variant_switch"),G={};for(let B of J)if(B.propName)G[B.propName]=(G[B.propName]||0)+1;let K={};for(let B of Q)if(B.variantId)K[B.variantId]=(K[B.variantId]||0)+1;let W=new Set(this.storage.sessions.filter((B)=>B.componentViews.includes($)).map((B)=>B.id)),U=Y.filter((B)=>B.metadata?.duration).map((B)=>B.metadata.duration),_=U.length>0?U.reduce((B,q)=>B+q,0)/U.length:0,z=Object.entries(G).sort((B,q)=>q[1]-B[1]).slice(0,5).map(([B])=>B);return{componentId:$,componentName:Z,viewCount:X.length,uniqueViews:W.size,lastViewed:X[X.length-1]?.timestamp,propChanges:G,topChangedProps:z,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 Lf(){return`session-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Hf=".stx/story/analytics.json",Of=1,lA=1e4;var pA=()=>{};import uW from"fs";import iA from"path";class mW{storage;storagePath;dirty=!1;constructor($){this.storagePath=iA.join($,Vf),this.storage=this.loadStorage()}loadStorage(){try{let $=uW.readFileSync(this.storagePath,"utf-8");return JSON.parse($)}catch{return{version:Ff,bookmarks:[]}}}async save(){if(!this.dirty)return;let $=iA.dirname(this.storagePath);await uW.promises.mkdir($,{recursive:!0}),await uW.promises.writeFile(this.storagePath,JSON.stringify(this.storage,null,2)),this.dirty=!1}addBookmark($,Z,Y,X={}){let J={id:Af(),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 Af(){return`bm-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}var Vf=".stx/story/bookmarks.json",Ff=1;var nA=()=>{};import cW from"fs";import Q3 from"path";async function G3($){let{root:Z,config:Y}=$,X=[],J=await Nf(Z,Y.storyMatch,Y.storyIgnored);for(let Q of J){let G=Q3.resolve(Z,Q),K=lW(Q,G);X.push(K)}return X}async function Nf($,Z,Y){let X=[];async function J(Q,G){let K=await cW.promises.readdir(Q,{withFileTypes:!0});for(let W of K){let U=Q3.join(Q,W.name),_=Q3.relative(G,U);if(rA(_,Y))continue;if(W.isDirectory())await J(U,G);else if(W.isFile()){if(aA(_,Z))X.push(_)}}}return await J($,$),X}function rA($,Z){for(let Y of Z)if(sA($,Y))return!0;return!1}function aA($,Z){for(let Y of Z)if(sA($,Y))return!0;return!1}function sA($,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 lW($,Z){let Y=Q3.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 oA($,Z){let{root:Y,config:X}=$,J=[],Q=cW.watch(Y,{recursive:!0},async(G,K)=>{if(!K)return;let W=K.replace(/\\/g,"/");if(!aA(W,X.storyMatch))return;if(rA(W,X.storyIgnored))return;let U=Q3.resolve(Y,W);try{await cW.promises.access(U);let _=lW(W,U);Z(G==="rename"?"add":"change",_)}catch{let _=lW(W,U);Z("unlink",_)}});return J.push(Q),()=>{for(let G of J)G.close()}}var pW=()=>{};function wf($,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 K3($,Z){for(let G of Z)G.treePath=wf($,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=Rf(K,Y,X);Mf(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(...iW(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:iW(G.treeObject,J)});return Q}function Rf($,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 Mf($,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 iW($,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:iW(J,Z)});return Y.sort((X,J)=>Z(X.title,J.title)),Y}function tA(){return{open($){vX.add($),$.send(JSON.stringify({type:"connected",timestamp:Date.now()}))},close($){vX.delete($)},message($,Z){}}}function nW($){let Z=JSON.stringify({...$,timestamp:$.timestamp||Date.now()});for(let Y of vX)try{Y.send(Z)}catch{vX.delete(Y)}}function eA($,Z){nW({type:"story-update",data:{storyId:$,...Z}})}function $N($,Z){nW({type:"story-add",data:{storyId:$,...Z}})}function ZN($){nW({type:"story-remove",data:{storyId:$}})}function YN($){return`
|
|
19388
19388
|
<script>
|
|
19389
19389
|
(function() {
|
|
19390
19390
|
const ws = new WebSocket('${$}');
|
|
@@ -20662,7 +20662,7 @@ else {
|
|
|
20662
20662
|
${GN()}
|
|
20663
20663
|
</body>
|
|
20664
20664
|
</html>`}var MN=D(()=>{pA();nA();pW();J3();XN();UN();qN();HN();wN()});import yf from"fs";import xf from"path";async function TN($){let Z=$.config.setupFile;if(!Z)return;let Y=xf.resolve($.root,Z);try{await yf.promises.access(Y)}catch{return}let X={storyContext:$,registerComponent:(J,Q)=>{vf.set(J,Q)},addCSS:(J)=>{ff.push(J)},addScript:(J)=>{gf.push(J)},setState:(J,Q)=>{hf.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 vf,ff,gf,hf;var EN=D(()=>{vf=new Map,ff=[],gf=[],hf=new Map});var DN={};e(DN,{devCommand:()=>IN,dev:()=>df});async function IN($={}){Y3();let Z=await P$({mode:"dev"});if(!Z.config.enabled){b$("Story feature is disabled in config.");return}await TN(Z);let Y=$.port??Z.config.port,X,J=async()=>{X=await RN(Z,{port:Y,open:$.open,host:$.host}),X3(Z.storyFiles.length),vW(X.url),fW()};await J();let Q=xA(Z,{onChange:async()=>{await X.close();let K=await P$({mode:"dev"});Object.assign(Z,K),await J()}}),G=async()=>{console.log(`
|
|
20665
|
-
`),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":fW();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{CA("Failed to open browser")}break;case"r":await X.close(),await J();break;case"c":console.clear(),Y3(),X3(Z.storyFiles.length),vW(X.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var df;var kN=D(()=>{vA();J3();xX();MN();EN();df=IN});function SN($){U3=[];for(let Z of $.storyFiles)if(U3.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),U3.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)U3.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function CN(){return JSON.stringify(U3)}var U3;var bN=D(()=>{U3=[]});var yN={};e(yN,{buildCommand:()=>PN,build:()=>mf});import
|
|
20665
|
+
`),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":fW();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{CA("Failed to open browser")}break;case"r":await X.close(),await J();break;case"c":console.clear(),Y3(),X3(Z.storyFiles.length),vW(X.url);break;case"q":case"\x03":await G();break}});await new Promise(()=>{})}var df;var kN=D(()=>{vA();J3();xX();MN();EN();df=IN});function SN($){U3=[];for(let Z of $.storyFiles)if(U3.push({text:Z.fileName.toLowerCase(),original:Z.fileName,type:"story",storyId:Z.id}),U3.push({text:Z.relativePath.toLowerCase(),original:Z.relativePath,type:"story",storyId:Z.id}),Z.story)for(let Y of Z.story.variants)U3.push({text:Y.title.toLowerCase(),original:Y.title,type:"story",storyId:Z.id,variantId:Y.id})}function CN(){return JSON.stringify(U3)}var U3;var bN=D(()=>{U3=[]});var yN={};e(yN,{buildCommand:()=>PN,build:()=>mf});import A6 from"fs";import Z5 from"path";async function PN($={}){let Z=Date.now();Y3();let Y=await P$({mode:"build"});if(!Y.config.enabled){b$("Story feature is disabled in config.");return}let X=await G3(Y);y$(Y,X);let J=K3(Y.config,X);x$(Y,J),X3(X.length);let Q=$.outDir??Y.config.outDir,G=Z5.resolve(Y.root,Q);await A6.promises.mkdir(G,{recursive:!0}),console.log(` Building to ${Q}...`);let K=uf(Y);await A6.promises.writeFile(Z5.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 A6.promises.writeFile(Z5.join(G,"stories.json"),JSON.stringify(W,null,2));let U={theme:Y.config.theme,responsivePresets:Y.config.responsivePresets,backgroundPresets:Y.config.backgroundPresets};await A6.promises.writeFile(Z5.join(G,"config.json"),JSON.stringify(U,null,2));let _=Z5.join(G,"stories");await A6.promises.mkdir(_,{recursive:!0});for(let q of X){let j=await A6.promises.readFile(q.path,"utf-8");await A6.promises.writeFile(Z5.join(_,`${q.id}.stx`),j)}SN(Y);let z=CN();await A6.promises.writeFile(Z5.join(G,"search-index.json"),z);let B=Date.now()-Z;PA(X.length,Q,B)}function uf($){let{theme:Z}=$.config,Y=Z.title||"STX Story";return`<!DOCTYPE html>
|
|
20666
20666
|
<html lang="en">
|
|
20667
20667
|
<head>
|
|
20668
20668
|
<meta charset="UTF-8">
|
|
@@ -20777,12 +20777,12 @@ else {
|
|
|
20777
20777
|
</script>
|
|
20778
20778
|
</body>
|
|
20779
20779
|
</html>`}var mf;var xN=D(()=>{pW();J3();xX();bN();mf=PN});var gN={};e(gN,{updateSnapshots:()=>lf,runVisualTests:()=>fN,runA11yTests:()=>sf,formatTestResults:()=>af});import gX from"fs";import vN from"path";async function fN($,Z={}){let Y=Date.now(),X={total:0,passed:0,failed:0,new:0,failures:[],duration:0},J=Z.snapshotDir||vN.join($.root,".stx","story","snapshots");await gX.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 cf(G,J,Z,X);return X.duration=Date.now()-Y,X}async function cf($,Z,Y,X){let J=$.story;if(!J)return;for(let Q of J.variants){X.total++;let G=vN.join(Z,`${$.id}-${Q.id}.snap`),K=pf(Q.source||""),W=await rf(G);if(Y.update||!W){let U={storyId:$.id,variantId:Q.id,component:$.fileName,timestamp:Date.now(),hash:K};if(await gX.promises.writeFile(G,JSON.stringify(U,null,2)),!W)X.new++;X.passed++}else try{let U=await gX.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:nf(_.hash,K)})}catch(U){X.failed++,X.failures.push({storyId:$.id,variantId:Q.id,component:$.fileName,message:`Error reading snapshot: ${U}`})}}}async function lf($,Z={}){return(await fN($,{...Z,update:!0})).total}function pf($){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 nf($,Z){if($===Z)return 0;let Y=Math.abs(Number.parseInt($,16)-Number.parseInt(Z,16));return Math.min(Y/1e6,1)}async function rf($){try{return await gX.promises.access($),!0}catch{return!1}}function af($){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(`
|
|
20780
|
-
`)}async function sf($,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 z3(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 hN=D(()=>{
|
|
20780
|
+
`)}async function sf($,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 z3(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 hN=D(()=>{X5()});var sN={};e(sN,{default:()=>Fg,createHotReloadServer:()=>aN,compileToNative:()=>uN,NATIVE_COMPONENTS:()=>ZU});async function uN($,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||ZU},J=typeof $==="string"?of($):$,Q=ef(J.tree,X),G=Gg(Q),K=X.treeShake?Wg(Q,G):Q,W=new Map;if(X.target==="universal"){let q=["macos","windows","linux","ios","android"];for(let j of q){let H=tW(K,{...X,target:j});W.set(j,H)}}else{let q=tW(K,X);W.set(X.target,q)}let U=zg(K,X,W),_=Bg(J,K,X),z={compilationTime:performance.now()-Y,totalComponents:eW(J.tree),nativeComponents:$U(K),webComponents:eW(J.tree)-$U(K),bundleSize:U.length,treeShakenSize:X.treeShake?Ug(Q,K):U.length,warnings:[],errors:[]},B;if(X.sourceMaps)B=qg(J,K);return{code:U,platformCode:W,dependencies:G,manifest:_,sourceMaps:B,stats:z}}function of($){let Z={type:"fragment",children:[]},Y=$.match(/<body[^>]*>([\s\S]*?)<\/body>/i),X=Y?Y[1]:$;return mN(X,Z),{id:nN(),hash:rN($),tree:Z,scripts:Og($),styles:Lg($),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 mN($,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:tf(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});mN(G,W)}Z.children=Z.children??[],Z.children.push(W)}}function tf($){let Z={},Y=/([\w-:@]+)(?:=["']([^"']*)["'])?/g,X;while((X=Y.exec($))!==null){let[,J,Q]=X;Z[J]=Q??!0}return Z}function ef($,Z){return cN($,Z)}function cN($,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=$g($.tag);let J={};if($.props)for(let[W,U]of Object.entries($.props))J[W]=Zg(U);let Q=[];if($.children)for(let W of $.children)Q.push(cN(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=Xg($);return{type:Yg($,Y),zigType:X,props:J,children:Q,events:G,styles:K,id:$.hydrationKey,key:$.props?.key}}function $g($){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 Zg($){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 Yg($,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 Xg($){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=Jg(K);break;case"align-items":Y.alignItems=Qg(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 Jg($){return{"flex-start":"start","flex-end":"end",center:"center","space-between":"between","space-around":"around"}[$]||"start"}function Qg($){return{"flex-start":"start","flex-end":"end",center:"center",stretch:"stretch"}[$]||"start"}function Gg($){let Z=[],Y=new Set;function X(J,Q){let G=J.id||nN();if(Y.has(G))return;Y.add(G);let K={id:G,type:"component",path:J.zigType,dependencies:Q?[Q]:[],size:lN(J),isStatic:Kg(J)};Z.push(K);for(let W of J.children)X(W,G)}return X($),Z}function lN($){let Z=100;return Z+=Object.keys($.props).length*20,Z+=$.events.size*50,Z}function Kg($){for(let Z of Object.values($.props))if(Z.type!=="literal")return!1;return $.events.size===0}function Wg($,Z){return $}function Ug($,Z){let Y=0;function X(J){Y+=lN(J);for(let Q of J.children)X(Q)}return X(Z),Y}function tW($,Z){switch(Z.format){case"zig":return dN($,Z);case"typescript":return _g($,Z);case"json":return JSON.stringify($,null,Z.minify?0:2);default:return dN($,Z)}}function dN($,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(""),pN($,Y,0),Y.join(`
|
|
20781
20781
|
`)}function pN($,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${Hg(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 pN(G,Z,Y+1),Z.push(`${X} try ${J}.addChild(node_${Y+1});`)}if(Y===0)Z.push(` return ${J}.element();`),Z.push("}")}function _g($,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 "+iN($,1)+";"),Y.push("}"),Y.join(`
|
|
20782
20782
|
`)}function iN($,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:""}"`:iN(K,Z+1)),G=Q.length>0?`,
|
|
20783
20783
|
${Y} [${Q.join(`,
|
|
20784
20784
|
${Y} `)}]`:"";return`Craft.create("${$.zigType}", ${J}${G})`}function zg($,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(`
|
|
20785
|
-
`)}return Y.get(Z.target)||tW($,Z)}function Bg($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:rN(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 qg($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function nN(){return`id_${++jg}`}function rN($){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 Hg($){return $.charAt(0).toUpperCase()+$.slice(1)}function Og($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Lg($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function eW($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=eW(Y);return Z}function $U($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=$U(Y);return Z}function aN($){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 ZU,jg=0,Vg,Fg;var oN=D(()=>{ZU=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Vg={compileToNative:uN,createHotReloadServer:aN,NATIVE_COMPONENTS:ZU},Fg=Vg});import{spawn as $w}from"child_process";import y0 from"fs";import Ag from"os";import Y0 from"path";import y from"process";import{CLI as Ng}from"@stacksjs/clapp";var w6="0.2.98";J5();kW();fG();iG();f4();cG();PG();FW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new Ng("stx");function tN($){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 eN($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(y0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function YU($){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 f$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),wg=($)=>$.endsWith(".stx")||$.endsWith(".md");function v$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);y.exit(Z)}async function Rg($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(f$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(Ag.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...y.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=$w(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),y.on("SIGINT",()=>{console.log(`
|
|
20785
|
+
`)}return Y.get(Z.target)||tW($,Z)}function Bg($,Z,Y){let X=[];function J(Q){X.push({name:Q.zigType,hash:rN(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 qg($,Z){return JSON.stringify({version:3,file:"output.zig",sources:["input.stx"],mappings:""})}function nN(){return`id_${++jg}`}function rN($){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 Hg($){return $.charAt(0).toUpperCase()+$.slice(1)}function Og($){let Z=[],Y=/<script[^>]*>([\s\S]*?)<\/script>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function Lg($){let Z=[],Y=/<style[^>]*>([\s\S]*?)<\/style>/gi,X;while((X=Y.exec($))!==null)Z.push(X[1]);return Z}function eW($){let Z=$.type==="component"?1:0;if($.children)for(let Y of $.children)Z+=eW(Y);return Z}function $U($){let Z=$.zigType.startsWith("craft.")?1:0;for(let Y of $.children)Z+=$U(Y);return Z}function aN($){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 ZU,jg=0,Vg,Fg;var oN=D(()=>{ZU=new Map([["craft-button",{name:"Button",zigType:"craft.Button",props:[{name:"variant",type:"string",required:!1,default:"primary"},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onclick",type:"callback",required:!1}],children:"single"}],["craft-text-input",{name:"TextInput",zigType:"craft.TextInput",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-textarea",{name:"TextArea",zigType:"craft.TextArea",props:[{name:"value",type:"string",required:!1,default:""},{name:"placeholder",type:"string",required:!1},{name:"rows",type:"number",required:!1,default:3},{name:"disabled",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-checkbox",{name:"Checkbox",zigType:"craft.Checkbox",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"label",type:"string",required:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-select",{name:"Select",zigType:"craft.Select",props:[{name:"value",type:"string",required:!1},{name:"options",type:"array",required:!0},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-slider",{name:"Slider",zigType:"craft.Slider",props:[{name:"value",type:"number",required:!1,default:0},{name:"min",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"step",type:"number",required:!1,default:1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-toggle",{name:"Toggle",zigType:"craft.Toggle",props:[{name:"checked",type:"boolean",required:!1,default:!1},{name:"disabled",type:"boolean",required:!1,default:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-modal",{name:"Modal",zigType:"craft.Modal",props:[{name:"open",type:"boolean",required:!1,default:!1},{name:"title",type:"string",required:!1},{name:"closable",type:"boolean",required:!1,default:!0},{name:"onclose",type:"callback",required:!1}],children:"multiple"}],["craft-alert",{name:"Alert",zigType:"craft.Alert",props:[{name:"variant",type:"string",required:!1,default:"info"},{name:"title",type:"string",required:!1},{name:"dismissible",type:"boolean",required:!1,default:!1}],children:"single"}],["craft-progress",{name:"ProgressBar",zigType:"craft.ProgressBar",props:[{name:"value",type:"number",required:!1,default:0},{name:"max",type:"number",required:!1,default:100},{name:"indeterminate",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-spinner",{name:"Spinner",zigType:"craft.Spinner",props:[{name:"size",type:"number",required:!1,default:24}],children:"none"}],["craft-avatar",{name:"Avatar",zigType:"craft.Avatar",props:[{name:"src",type:"string",required:!1},{name:"alt",type:"string",required:!1},{name:"size",type:"number",required:!1,default:40}],children:"none"}],["craft-badge",{name:"Badge",zigType:"craft.Badge",props:[{name:"variant",type:"string",required:!1,default:"default"}],children:"single"}],["craft-card",{name:"Card",zigType:"craft.Card",props:[{name:"padding",type:"number",required:!1,default:16}],children:"multiple"}],["craft-sidebar",{name:"Sidebar",zigType:"craft.NativeSidebar",props:[{name:"id",type:"string",required:!1},{name:"variant",type:"string",required:!1,default:"desktop"},{name:"material",type:"string",required:!1,default:"sidebar"},{name:"backgroundEffect",type:"string",required:!1,default:"shimmer"},{name:"allowsVibrancy",type:"boolean",required:!1,default:!0},{name:"materialOpacity",type:"number",required:!1,default:0.68},{name:"minWidth",type:"number",required:!1,default:240},{name:"maxWidth",type:"number",required:!1,default:340},{name:"canCollapse",type:"boolean",required:!1,default:!0},{name:"selectedItem",type:"string",required:!1},{name:"sections",type:"array",required:!1}],children:"multiple",platform:["macos"],fallback:"aside"}],["craft-sidebar-section",{name:"SidebarSection",zigType:"craft.NativeSidebarSection",props:[{name:"id",type:"string",required:!0},{name:"title",type:"string",required:!1},{name:"header",type:"string",required:!1}],children:"multiple",platform:["macos"],fallback:"section"}],["craft-sidebar-item",{name:"SidebarItem",zigType:"craft.NativeSidebarItem",props:[{name:"id",type:"string",required:!0},{name:"label",type:"string",required:!0},{name:"icon",type:"string",required:!1},{name:"badge",type:"string",required:!1},{name:"tintColor",type:"color",required:!1}],children:"none",platform:["macos"],fallback:"button"}],["craft-accordion",{name:"Accordion",zigType:"craft.Accordion",props:[{name:"title",type:"string",required:!0},{name:"open",type:"boolean",required:!1,default:!1}],children:"multiple"}],["craft-tabs",{name:"TabView",zigType:"craft.TabView",props:[{name:"activeTab",type:"number",required:!1,default:0},{name:"ontabchange",type:"callback",required:!1}],children:"multiple"}],["craft-tooltip",{name:"Tooltip",zigType:"craft.Tooltip",props:[{name:"content",type:"string",required:!0},{name:"position",type:"string",required:!1,default:"top"}],children:"single"}],["craft-date-picker",{name:"DatePicker",zigType:"craft.DatePicker",props:[{name:"value",type:"string",required:!1},{name:"min",type:"string",required:!1},{name:"max",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-time-picker",{name:"TimePicker",zigType:"craft.TimePicker",props:[{name:"value",type:"string",required:!1},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-color-picker",{name:"ColorPicker",zigType:"craft.ColorPicker",props:[{name:"value",type:"color",required:!1,default:"#000000"},{name:"onchange",type:"callback",required:!1}],children:"none"}],["craft-data-table",{name:"DataTable",zigType:"craft.DataTable",props:[{name:"data",type:"array",required:!0},{name:"columns",type:"array",required:!0},{name:"sortable",type:"boolean",required:!1,default:!1},{name:"paginated",type:"boolean",required:!1,default:!1}],children:"none"}],["craft-virtual-list",{name:"VirtualList",zigType:"craft.VirtualList",props:[{name:"items",type:"array",required:!0},{name:"itemHeight",type:"number",required:!1,default:48},{name:"renderItem",type:"callback",required:!0}],children:"none"}],["craft-tree-view",{name:"TreeView",zigType:"craft.TreeView",props:[{name:"data",type:"object",required:!0},{name:"expandable",type:"boolean",required:!1,default:!0}],children:"none"}]]);Vg={compileToNative:uN,createHotReloadServer:aN,NATIVE_COMPONENTS:ZU},Fg=Vg});import{spawn as $w}from"child_process";import y0 from"fs";import Ag from"os";import Y0 from"path";import y from"process";import{CLI as Ng}from"@stacksjs/clapp";var N6="0.2.99";X5();kW();fG();iG();f4();cG();PG();FW();var __dirname="/home/runner/work/stx/stx/packages/stx/bin",H0=new Ng("stx");function tN($){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 eN($){try{if(!y0.existsSync($)){let Y=Y0.dirname($),X=Y0.basename($);if(y0.existsSync(Y)){let Q=y0.readdirSync(Y).filter((K)=>K.toLowerCase().includes(X.toLowerCase().substring(0,3))||K.endsWith(".stx")||K.endsWith(".md")),G=Q.length>0?`File not found. Similar files in ${Y}: ${Q.slice(0,3).join(", ")}`:`File not found. Directory ${Y} exists but doesn't contain the specified file.`;return{isValid:!1,error:`File does not exist: ${$}`,suggestion:G}}return{isValid:!1,error:`File does not exist: ${$}`,suggestion:"Check the file path and try again"}}if(y0.statSync($).isDirectory())return{isValid:!1,error:`Expected file but got directory: ${$}`,suggestion:"Specify a .stx or .md file path"};return{isValid:!0}}catch(Z){return{isValid:!1,error:`Cannot access file: ${$}`,suggestion:"Check file permissions and path"}}}function YU($){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 f$=($)=>$.includes("*")||$.includes("?")||$.includes("{")||$.includes("["),wg=($)=>$.endsWith(".stx")||$.endsWith(".md");function v$($,Z=1){if(console.error(`\u274C ${$.error}`),$.suggestion)console.error(`\uD83D\uDCA1 suggestion: ${$.suggestion}`);y.exit(Z)}async function Rg($,Z){try{let Y=["test"],X=[];if($&&$.length>0)for(let W of $)if(f$(W))try{let U=await Array.fromAsync(new Bun.Glob(W).scan({onlyFiles:!0,absolute:!0}));if(U.length===0)console.warn(`Warning: No files found matching pattern: ${W}`);else if(X.push(...U),Z.verbose)console.log(`Found ${U.length} file(s) matching pattern: ${W}`)}catch(U){return console.error(`Error expanding glob pattern ${W}:`,U),!1}else X.push(W);if(X.length===0)return console.error("Error: No test files found matching the provided patterns."),!1;if(Y.push(...X),Z.filter)Y.push("--pattern",Z.filter);if(Z.timeout)Y.push("--timeout",Z.timeout.toString());if(Z.reporter&&Z.reporter!=="default")if(Z.reporter==="junit"){let W=Y0.join(Ag.tmpdir(),`stx-test-report-${Date.now()}.xml`);Y.push("--reporter",Z.reporter),Y.push("--reporter-outfile",W)}else console.warn(`Warning: Reporter '${Z.reporter}' is not supported. Using default reporter.`);if(Z.coverage)Y.push("--coverage");if(Z.watch)Y.push("--watch");Y.push("--preload",Y0.join(__dirname,"../../../test-utils/happy-dom.ts"));let J={...y.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=$w(Q,Y,{stdio:"inherit",shell:!1,env:J});return new Promise((W)=>{K.on("close",(U)=>{let z=((performance.now()-G)/1000).toFixed(2);if(U===0)W(!0);else W(!1)}),y.on("SIGINT",()=>{console.log(`
|
|
20786
20786
|
Test run interrupted`),K.kill("SIGINT"),y.exit(1)})})}catch(Y){return console.error("Error running tests:",Y instanceof Error?Y.message:String(Y)),!1}}var Mg=y.argv.length>=3&&(wg(y.argv[2])&&y0.existsSync(y.argv[2])||f$(y.argv[2]));if(Mg){let $=y.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<y.argv.length;Y++){let X=y.argv[Y];if(X==="--port"&&Y+1<y.argv.length){let J=tN(y.argv[++Y]);if(!J.isValid)v$(J);Z.port=Number.parseInt(y.argv[Y],10)}else if(X==="--no-watch")Z.watch=!1;else if(X==="--highlight-theme"&&Y+1<y.argv.length){if(!Z.markdown)Z.markdown={};if(!Z.markdown.syntaxHighlighting)Z.markdown.syntaxHighlighting={};Z.markdown.syntaxHighlighting.defaultTheme=y.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(f$($))try{let Y=await Array.fromAsync(new Bun.Glob($).scan({onlyFiles:!0,absolute:!0})),X=$.endsWith(".stx")?Y.filter((K)=>K.endsWith(".stx")):$.endsWith(".md")?Y.filter((K)=>K.endsWith(".md")):Y.filter((K)=>K.endsWith(".stx")||K.endsWith(".md")),J=$.split("*")[0].replace(/\/$/,"")||".",Q=Y0.resolve(J);try{let K=new Bun.Glob("**/*.stx"),U=(await Array.fromAsync(K.scan({cwd:Q,onlyFiles:!0,absolute:!0}))).filter((_)=>/\[.+\]/.test(Y0.basename(_)));for(let _ of U)if(!X.includes(_))X.push(_)}catch{}if(X.length===0)console.error(`Error: No STX or Markdown files found matching pattern: ${$}`),y.exit(1);if(!await p8(X,Z))y.exit(1)}catch(Y){console.error("Failed to process files:",Y),y.exit(1)}else l8($,Z).catch((Y)=>{console.error("Failed to start dev server:",Y),y.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]};H0.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 vG(X))console.log("Documentation generated successfully."),y.exit(0);else console.error("Documentation generation failed."),y.exit(1)}catch(J){console.error("Error generating documentation:",J),y.exit(1)}}),H0.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(`
|
|
20787
20787
|
\uD83D\uDCDA Fetching available icon collections...
|
|
20788
20788
|
`);let K=await Q(),W=Object.entries(K).sort((U,_)=>_[1].total-U[1].total);console.log(`Available collections:
|
|
@@ -20860,7 +20860,7 @@ Total: ${W} issues in ${K} files`),J.output){let U=`
|
|
|
20860
20860
|
`),y.exit(1);console.log(" To preview locally:"),console.log(` cd ${J.out||"dist"} && npx serve
|
|
20861
20861
|
`)}}catch(Q){console.error(`
|
|
20862
20862
|
Build failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.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=Y0.resolve(X.output);if(!y0.existsSync(Y0.join(J,"manifest.json")))console.error("\n No production build found. Run `stx build --out .output` first.\n"),y.exit(1);let{startProductionServer:Q}=await Promise.resolve().then(() => (oG(),$V));await Q({outputDir:J,port:Number.parseInt(X.port,10)||3000})}catch(J){console.error(`
|
|
20863
|
-
Failed to start production server:`,J instanceof Error?J.message:String(J)),y.exit(1)}}),H0.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(() => (CY(),uH));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${
|
|
20863
|
+
Failed to start production server:`,J instanceof Error?J.message:String(J)),y.exit(1)}}),H0.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(() => (CY(),uH));if(console.log(`\x1B[1mstx deploy\x1B[0m \x1B[2mv${N6}\x1B[0m`),J.init){console.log(`
|
|
20864
20864
|
\uD83D\uDCDD Initializing Netlify configuration...
|
|
20865
20865
|
`);let U=await G({directory:X||y.cwd(),siteId:J.siteId});if(console.log(`\u2713 Created ${U.configPath}`),U.siteId)console.log("\u2713 Saved site ID to .env.local");console.log(`
|
|
20866
20866
|
You can now deploy with: stx deploy`);return}if(J.build!==!1){if(console.log(`
|
|
@@ -20872,7 +20872,7 @@ You can now deploy with: stx deploy`);return}if(J.build!==!1){if(console.log(`
|
|
|
20872
20872
|
`),console.log(` ${J.dryRun?"Would deploy":"Draft URL"}: ${W.url}`),W.siteUrl)console.log(` Site URL: ${W.siteUrl}`);if(!J.dryRun)console.log(`
|
|
20873
20873
|
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(`
|
|
20874
20874
|
\u274C ${Q.message}`),y.exit(1);console.error(`
|
|
20875
|
-
\u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.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(() => (uY(),QO)),W=await import("fs"),U=await import("path");if(console.log(`\x1B[1mstx images\x1B[0m \x1B[2mv${
|
|
20875
|
+
\u274C Deploy failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.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(() => (uY(),QO)),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(`
|
|
20876
20876
|
\u274C sharp is required for image optimization.`),console.log(`
|
|
20877
20877
|
Install sharp with:`),console.log(" bun add sharp"),y.exit(1);let z=J.widths.split(",").map((L)=>Number.parseInt(L.trim(),10)).filter((L)=>!Number.isNaN(L)),B=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(`
|
|
20878
20878
|
\u274C Input directory not found: ${H}`),y.exit(1);if(!W.statSync(H).isDirectory())console.error(`
|
|
@@ -20885,13 +20885,13 @@ Would generate ~${A} image variants`);return}console.log(`
|
|
|
20885
20885
|
`);let V=await Q(H,J.output,{widths:z,formats:B,quality:q,placeholder:j,verbose:J.verbose});if(console.log(`
|
|
20886
20886
|
\u2713 Optimization complete!
|
|
20887
20887
|
`),console.log(` Images processed: ${V.stats.optimizedImages}/${V.stats.totalImages}`),console.log(` Variants created: ${V.stats.variants}`),V.stats.savedBytes>0)console.log(` Estimated savings: ~${K(V.stats.savedBytes)}`)}catch(Q){console.error(`
|
|
20888
|
-
\u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.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(() => (jA(),qA)),W=await import("path");console.log(`\x1B[1mstx bundle\x1B[0m \x1B[2mv${
|
|
20888
|
+
\u274C Image optimization failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.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(() => (jA(),qA)),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(`
|
|
20889
20889
|
\u274C Directory not found: ${_}`),console.log("\nRun `stx build` first to generate build output."),y.exit(1);let B="html";if(J.json)B="json";else if(J.text)B="text";else if(J.markdown)B="markdown";console.log(`
|
|
20890
20890
|
\uD83D\uDCE6 Analyzing: ${_}`);let q=await Q({directory:_,output:J.output,format:B,open:J.open!==!1&&B==="html",gzip:J.gzip!==!1,threshold:J.threshold,topModules:Number.parseInt(J.top||"20",10),recommendations:!0});if(B==="html"){if(console.log(`
|
|
20891
20891
|
\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(`
|
|
20892
20892
|
\u274C Bundle size (${G(q.stats.totalSize)}) exceeds threshold (${j})`),y.exit(1)}if(B==="html"){if(console.log(`
|
|
20893
20893
|
\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(`
|
|
20894
|
-
\u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.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${
|
|
20894
|
+
\u274C Bundle analysis failed:`,Q instanceof Error?Q.message:String(Q)),y.exit(1)}}),H0.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} (${tG})\x1B[0m`),J.timeout){let K=YU(J.timeout);if(!K.isValid)v$(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 g1.timeAsync("test-execution",()=>Rg(Q,J))&&!J.watch)y.exit(1)}catch(Q){console.error("Error running tests:",Q),y.exit(1)}}),H0.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 pG(X,{force:J.force,template:J.template}))console.log(`
|
|
20895
20895
|
\u2728 Successfully created file: ${X}`),console.log(`
|
|
20896
20896
|
To view it in the development server:`),console.log(` stx dev ${X}
|
|
20897
20897
|
`);else console.error(`
|
|
@@ -20923,7 +20923,7 @@ Press Ctrl+C to stop watching...
|
|
|
20923
20923
|
\uD83D\uDCC4 Files with issues:`),z.forEach((B)=>{let q=B.issues.filter((j)=>K[j.type]>=W).length;if(q>0)console.log(` ${Y0.relative(y.cwd(),B.file)} (${q} issues)`)});if(J.saveReport){let B={summary:_,results:z,generatedAt:new Date().toISOString(),commandOptions:J};await Bun.write(J.saveReport,JSON.stringify(B,null,2)),console.log(`
|
|
20924
20924
|
\uD83D\uDCCB Analysis report saved to: ${J.saveReport}`)}console.log(`
|
|
20925
20925
|
\u2728 Analysis complete! Use --detailed for more information.`)}catch(Q){console.error("Error analyzing templates:",Q),y.exit(1)}}),H0.command("screenshot [input]","Capture PNG screenshot(s) of page(s) via Bun WebView \u2014 a file, URL, or dist directory").option("--out <dir>","Output directory",{default:"screenshots"}).option("--width <px>","Viewport width",{default:"1440"}).option("--height <px>","Viewport height",{default:"2200"}).option("--wait <ms>","Settle time after navigation before capture",{default:"800"}).option("--timeout <ms>","Hard cap on waiting for navigation",{default:"15000"}).option("--full-page","Capture the entire scrollable page, not just the viewport").option("--wait-selector <sel>","Wait until a CSS selector exists before capturing").option("--format <fmt>","Image format: png | jpeg | webp",{default:"png"}).option("--backend <name>","WebView backend: webkit (macOS, default) | chrome").action(async(X,J)=>{let{captureScreenshots:Q}=await Promise.resolve().then(() => (uG(),hL)),G=X||"dist";try{let K=await Q(G,J.out,{width:Number.parseInt(J.width,10),height:Number.parseInt(J.height,10),waitMs:Number.parseInt(J.wait,10),timeoutMs:Number.parseInt(J.timeout,10),fullPage:Boolean(J.fullPage),waitSelector:J.waitSelector,format:J.format,backend:J.backend});for(let W of K)console.log(`\uD83D\uDCF8 ${W.output} (${(W.bytes/1024).toFixed(0)} KB)`);console.log(`
|
|
20926
|
-
\u2728 Captured ${K.length} screenshot(s) to ${J.out}/ via Bun WebView`)}catch(K){console.error(`Screenshot failed: ${K.message}`),y.exit(1)}}),H0.command("version","Show the version of the CLI").action(()=>{console.log(
|
|
20926
|
+
\u2728 Captured ${K.length} screenshot(s) to ${J.out}/ via Bun WebView`)}catch(K){console.error(`Screenshot failed: ${K.message}`),y.exit(1)}}),H0.command("version","Show the version of the CLI").action(()=>{console.log(N6)}),H0.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(() => (nG(),nL)),Q={};if(X.context){let G=Y0.resolve(X.context);if(y0.existsSync(G))try{let K=y0.readFileSync(G,"utf-8");Q=JSON.parse(K)}catch(K){console.error("Error loading context file:",K),y.exit(1)}else console.error(`Context file not found: ${G}`),y.exit(1)}await J({context:Q,cwd:X.cwd?Y0.resolve(X.cwd):y.cwd(),verbose:X.verbose})}),H0.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(() => (DA(),IA)),W=Y0.resolve(X);if(!y0.existsSync(W))console.error(`\u274C Input file not found: ${X}`),y.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(", ")}`),y.exit(1);let _=J.target||U[0],z=K(_);if(J.format&&!z.includes(J.format))console.error(`\u274C Invalid format for ${_}: ${J.format}`),console.error(`\uD83D\uDCA1 Available formats: ${z.join(", ")}`),y.exit(1);console.log(`
|
|
20927
20927
|
\uD83D\uDD28 Building native app...`),console.log(` Input: ${X}`),console.log(` Target: ${_}`),console.log(` Format: ${J.format||"default"}`),console.log(` Output: ${J.output}
|
|
20928
20928
|
`);let B=await Q({input:W,output:Y0.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?Y0.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(B.success){if(console.log("\u2705 Build successful!"),console.log(` Output: ${B.outputPath}`),B.duration)console.log(` Duration: ${(B.duration/1000).toFixed(2)}s`);if(_==="macos"&&B.format==="app")console.log(`
|
|
20929
20929
|
\uD83D\uDCA1 To run: open "${B.outputPath}"`);else if(_==="linux"&&B.format==="appimage")console.log(`
|
|
@@ -20934,4 +20934,4 @@ Press Ctrl+C to stop watching...
|
|
|
20934
20934
|
\u26A0\uFE0F Warnings:`);for(let O of _.stats.warnings)console.log(` - ${O.message}`)}if(_.stats.errors.length>0){console.log(`
|
|
20935
20935
|
\u274C Errors:`);for(let O of _.stats.errors)console.log(` - ${O.message}`)}}catch(Q){console.error(`\u274C Compilation error: ${Q.message}`),y.exit(1)}});let Z=["docs","iconify","dev","a11y","build","components:build","start","build:native","compile","test","init","new","format","perf","debug","doctor","status","watch","analyze","version","deploy","interactive","i","story","story:build","story:test","screenshot"],Y=y.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"),y.exit(1);if(!Z.includes(X)){let J=$0("fs"),Q=$0("path"),G=X;if(!Q.isAbsolute(G))G=Q.resolve(y.cwd(),G);if(J.existsSync(G)){let K=J.statSync(G);if(K.isFile()||K.isDirectory())y.argv=[y.argv[0],y.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(`
|
|
20936
20936
|
Run 'stx --help' to see available commands.`),y.exit(1);console.error(`\u274C Unknown command or path: ${X}`),console.error(`
|
|
20937
|
-
Run 'stx --help' to see available commands.`),y.exit(1)}}}H0.help(),H0.version(
|
|
20937
|
+
Run 'stx --help' to see available commands.`),y.exit(1)}}}H0.help(),H0.version(N6),H0.parse(y.argv)}
|