@stacksjs/stx 0.2.82 → 0.2.84
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/app-shell.js +21 -11
- package/dist/build-assets.js +19 -9
- package/dist/build-mode-detector.js +22 -12
- package/dist/build-views.js +22 -12
- package/dist/build.js +21 -11
- package/dist/caching.js +19 -9
- package/dist/cli.js +22 -12
- package/dist/component-processing.js +21 -11
- package/dist/component-renderer.js +21 -11
- package/dist/components.js +22 -12
- package/dist/conditionals.js +1 -1
- package/dist/custom-directives.js +1 -1
- package/dist/dev-server/index.js +22 -12
- package/dist/dev-server/serve-app.js +21 -11
- package/dist/dev-server/serve-file.js +21 -11
- package/dist/dev-server/serve-markdown.js +22 -12
- package/dist/dev-server/serve-multi.js +21 -11
- package/dist/dev-server.js +21 -11
- package/dist/docs.js +22 -12
- package/dist/dynamic-components.js +21 -11
- package/dist/error-handling.js +1 -1
- package/dist/errors/formatter.js +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/i18n.js +1 -1
- package/dist/includes.js +21 -11
- package/dist/index.js +21 -11
- package/dist/interactive.js +22 -12
- package/dist/lazy-loader.js +98 -88
- package/dist/misc-directives.js +1 -1
- package/dist/plugin.js +21 -11
- package/dist/process.js +21 -11
- package/dist/production-builder.js +21 -11
- package/dist/production-server.js +21 -11
- package/dist/pwa/index.js +22 -12
- package/dist/pwa/offline.js +22 -12
- package/dist/pwa.js +21 -11
- package/dist/reactive.js +1 -1
- package/dist/render.js +22 -12
- package/dist/runtime-injection.js +19 -9
- package/dist/seo.js +1 -1
- package/dist/serve.js +22 -12
- package/dist/signal-processing.js +41 -31
- package/dist/signals.js +19 -9
- package/dist/site-builder/build.js +22 -12
- package/dist/site-builder/index.js +22 -12
- package/dist/ssg.js +21 -11
- package/dist/ssr.js +22 -12
- package/dist/store-loader.js +18 -18
- package/dist/story/cli.js +22 -12
- package/dist/story/commands/dev.js +22 -12
- package/dist/story/commands/index.js +22 -12
- package/dist/story/index.js +22 -12
- package/dist/story/renderer.js +22 -12
- package/dist/story/server.js +22 -12
- package/dist/story/visual-testing.js +22 -12
- package/dist/streaming.js +21 -11
- package/dist/template-compiler.js +22 -12
- package/dist/template-hydrator.js +22 -12
- package/dist/testing.js +147 -137
- package/dist/utils.js +21 -11
- package/dist/web-components.js +22 -12
- package/package.json +5 -5
package/dist/testing.js
CHANGED
|
@@ -11,7 +11,7 @@ var{defineProperty:X7,getOwnPropertyNames:UQ,getOwnPropertyDescriptor:WQ}=Object
|
|
|
11
11
|
white-space: nowrap;
|
|
12
12
|
border-width: 0;
|
|
13
13
|
}
|
|
14
|
-
`.trim()}function z9(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function LQ($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let L=J[1];if(!/\balt\s*=/i.test(L))Y.push({type:"missing-alt",element:J[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});J=X.exec($)}let Q=/<button([^>]*)>\s*<\/button>/gi;J=Q.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"missing-accessible-name",element:J[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});J=Q.exec($)}let G=/<a\s+([^>]*)>\s*<\/a>/gi;J=G.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"link-missing-text",element:J[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});J=G.exec($)}let K=/<(input|select|textarea)\s+([^>]*)>/gi;J=K.exec($);while(J!==null){let L=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(L)){J=K.exec($);continue}let F=/\baria-label\s*=/i.test(L)||/\baria-labelledby\s*=/i.test(L),H=L.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!F){let V=H&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${H[1]}["']`,"i").test($),A=J.index,w=$.substring(0,A),R=$.substring(A),N=(w.match(/<label\b/gi)||[]).length,M=(w.match(/<\/label>/gi)||[]).length,T=N>M;if(!V&&!T)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 q=/<h([1-6])[^>]*>/gi,z=[];J=q.exec($);while(J!==null)z.push(Number.parseInt(J[1],10)),J=q.exec($);let U=0;for(let L of z){if(U>0&&L>U+1)Y.push({type:"heading-skip",element:`<h${L}>`,message:`Heading level skipped from h${U} to h${L}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});U=L}if(/<html\b/i.test($)&&!/<html[^>]*\slang\s*=/i.test($))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let W=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=W.exec($);while(J!==null){let L=J[1];if(!/<th\b/i.test(L))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});J=W.exec($)}let _=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=_.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=_.exec($)}let B=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;J=B.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=B.exec($);let j=/<iframe\s+([^>]*)>/gi;J=j.exec($);while(J!==null){let L=J[1];if(!/\btitle\s*=/i.test(L)&&!/\baria-label\s*=/i.test(L))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});J=j.exec($)}let O=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;J=O.exec($);while(J!==null){let L=J[1].toLowerCase(),F=J[2];if(L!=="button"&&!/\btabindex\s*=/i.test(F))Y.push({type:"button-not-focusable",element:J[0].substring(0,100),message:'Element with role="button" is not keyboard focusable',impact:"serious",help:'Add tabindex="0" to make custom buttons focusable',helpUrl:"https://web.dev/learn/accessibility/focus/"});J=O.exec($)}return Y}async function U9($,Z){if(!z9())return LQ($,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 q=K.getAttribute("id"),z=q&&X.querySelector(`label[for="${q}"]`),U=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),W=K.closest("label")!==null;if(!z&&!U&&!W)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 q=Number.parseInt(K.tagName.charAt(1));if(Q>0&&q>Q+1)Y.push({type:"heading-skip",element:`<${K.outerHTML}>`,message:`Heading level skipped from h${Q} to h${q}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});Q=q}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 q=K.textContent&&K.textContent.trim().length>0,z=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),U=K.hasAttribute("title"),W=K.querySelector("img[alt]");if(!q&&!z&&!U&&!W)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 q=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(!q&&!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 q=K.getAttribute("style")||"";if(q.includes("color:")&&!q.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 FQ($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=z$.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let q of G.scan())if(!J.some((U)=>q.includes(z$.normalize(U))))K.push(q);for(let q of K)try{let z=await Bun.file(q).text();if(q.endsWith("good-a11y.stx"))continue;let U=await U9(z,q);if(U.length>0)Y[q]=U}catch(z){console.error(`Error scanning ${q}:`,z)}return Y}function W9($,Z={}){let Y={...VQ,...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 q=Q,z=`<img${G} alt=""${K}`;return X.push({type:"missing-alt",description:"Added empty alt attribute to image",before:q,after:z}),z});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,q=`<button${G} aria-label="Button"></button>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to empty button",before:K,after:q}),q}),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 q=Q,z=`<a${G} aria-label="Link">${K||""}</a>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to link without text",before:q,after:z}),z});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 q=K.match(/\bname\s*=\s*["']([^"']+)["']/i),z=K.match(/\bid\s*=\s*["']([^"']+)["']/i),U=q?.[1]||z?.[1]||G,W=Q,_=`<${G}${K} aria-label="${U}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:W,after:_}),_});if(Y.fixMissingLang)J=J.replace(/<html([^>]*)>/gi,(Q,G)=>{if(/\blang\s*=/i.test(G))return Q;let K=Q,q=`<html${G} lang="${Y.defaultLang}">`;return X.push({type:"missing-lang",description:`Added lang="${Y.defaultLang}" to html element`,before:K,after:q}),q});if(Y.fixPositiveTabindex)J=J.replace(/\btabindex\s*=\s*["']([1-9]\d*)["']/gi,(Q,G)=>{let K=Q,q='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 q=Q,z=`<${G}${K} tabindex="0">`;return X.push({type:"button-not-focusable",description:'Added tabindex="0" to element with role="button"',before:q,after:z}),z});if(Y.fixTableHeaders)J=J.replace(/<th([^>]*)>/gi,(Q,G)=>{if(/\bscope\s*=/i.test(G))return Q;let K=Q,q=`<th${G} scope="col">`;return X.push({type:"table-missing-scope",description:'Added scope="col" to table header',before:K,after:q}),q});return{original:$,fixed:J,fixCount:X.length,fixes:X}}async function _9($,Z={},Y=!1){let X=await Bun.file($).text(),J=W9(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function wQ($,Z={},Y={}){let X={},{recursive:J=!0,ignorePaths:Q=[],writeBack:G=!1,extensions:K=[".stx",".html",".htm"]}=Y,q=K.length===1?`*${K[0]}`:`*{${K.join(",")}}`,z=z$.join($,J?`**/${q}`:q),U=new Bun.Glob(z);for await(let W of U.scan()){if(Q.some((B)=>W.includes(z$.normalize(B))))continue;try{let B=await _9(W,Z,G);if(B.fixCount>0)X[W]=B}catch(B){console.error(`Error fixing ${W}:`,B)}}return X}function AQ(){return[U$,W$]}var VQ,U$,W$;var Q7=C(()=>{VQ={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};U$={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},W$={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function B9($){let Z=$.analytics;if(!Z?.enabled)return"";switch(Z.driver){case"fathom":return NQ(Z);case"google-analytics":return TQ(Z);case"plausible":return MQ(Z);case"self-hosted":return IQ(Z);case"custom":return DQ(Z);default:return""}}function NQ($){let Z=$.fathom;if(!Z?.siteId)return"";let Y=Z.scriptUrl||"https://cdn.usefathom.com/script.js",X=Z.defer!==!1?" defer":"",J=[`data-site="${v0(Z.siteId)}"`];if(Z.honorDnt)J.push('data-honor-dnt="true"');if(Z.spa)J.push('data-spa="auto"');if(Z.canonical)J.push(`data-canonical="${v0(Z.canonical)}"`);if(Z.auto===!1)J.push('data-auto="false"');return`
|
|
14
|
+
`.trim()}function z9(){return typeof globalThis.document<"u"&&typeof globalThis.document.createElement==="function"}function LQ($,Z){let Y=[],X=/<img\s+([^>]*)>/gi,J;J=X.exec($);while(J!==null){let L=J[1];if(!/\balt\s*=/i.test(L))Y.push({type:"missing-alt",element:J[0].substring(0,100),message:"Image missing alt attribute",impact:"serious",help:"Add alt text to images for screen readers",helpUrl:"https://web.dev/learn/accessibility/images/"});J=X.exec($)}let Q=/<button([^>]*)>\s*<\/button>/gi;J=Q.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"missing-accessible-name",element:J[0].substring(0,100),message:"Empty button missing accessible name",impact:"critical",help:"Add text content, aria-label, or title",helpUrl:"https://web.dev/learn/accessibility/aria-html/"});J=Q.exec($)}let G=/<a\s+([^>]*)>\s*<\/a>/gi;J=G.exec($);while(J!==null){let L=J[1];if(!/\baria-label\s*=/i.test(L)&&!/\btitle\s*=/i.test(L))Y.push({type:"link-missing-text",element:J[0].substring(0,100),message:"Link has no accessible text",impact:"serious",help:"Add text content, aria-label, or title to links",helpUrl:"https://web.dev/learn/accessibility/more-html/#links"});J=G.exec($)}let K=/<(input|select|textarea)\s+([^>]*)>/gi;J=K.exec($);while(J!==null){let L=J[2];if(/\btype\s*=\s*["']hidden["']/i.test(L)){J=K.exec($);continue}let V=/\baria-label\s*=/i.test(L)||/\baria-labelledby\s*=/i.test(L),H=L.match(/\bid\s*=\s*["']([^"']+)["']/i);if(!V){let F=H&&new RegExp(`<label[^>]*\\bfor\\s*=\\s*["']${H[1]}["']`,"i").test($),A=J.index,w=$.substring(0,A),R=$.substring(A),N=(w.match(/<label\b/gi)||[]).length,M=(w.match(/<\/label>/gi)||[]).length,T=N>M;if(!F&&!T)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 q=/<h([1-6])[^>]*>/gi,z=[];J=q.exec($);while(J!==null)z.push(Number.parseInt(J[1],10)),J=q.exec($);let U=0;for(let L of z){if(U>0&&L>U+1)Y.push({type:"heading-skip",element:`<h${L}>`,message:`Heading level skipped from h${U} to h${L}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});U=L}if(/<html\b/i.test($)&&!/<html[^>]*\slang\s*=/i.test($))Y.push({type:"missing-lang",element:"<html>",message:"Document language not specified",impact:"serious",help:"Add lang attribute to the html element",helpUrl:"https://web.dev/learn/accessibility/more-html/#language"});let W=/<table[^>]*>([\s\S]*?)<\/table>/gi;J=W.exec($);while(J!==null){let L=J[1];if(!/<th\b/i.test(L))Y.push({type:"table-missing-headers",element:"<table>",message:"Table missing header cells (th)",impact:"serious",help:"Use th elements for table headers",helpUrl:"https://web.dev/learn/accessibility/more-html/#tables"});J=W.exec($)}let _=/<(video|audio)[^>]*\sautoplay\s[^>]*>/gi;J=_.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=_.exec($)}let B=/\btabindex\s*=\s*["']([1-9]\d*)["']/gi;J=B.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=B.exec($);let j=/<iframe\s+([^>]*)>/gi;J=j.exec($);while(J!==null){let L=J[1];if(!/\btitle\s*=/i.test(L)&&!/\baria-label\s*=/i.test(L))Y.push({type:"iframe-missing-title",element:"<iframe>",message:"Iframe missing title attribute",impact:"serious",help:"Add a title attribute to describe the iframe content",helpUrl:"https://web.dev/learn/accessibility/more-html/#frames"});J=j.exec($)}let O=/<([a-z]+)\s+([^>]*role\s*=\s*["']button["'][^>]*)>/gi;J=O.exec($);while(J!==null){let L=J[1].toLowerCase(),V=J[2];if(L!=="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=O.exec($)}return Y}async function U9($,Z){if(!z9())return LQ($,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 q=K.getAttribute("id"),z=q&&X.querySelector(`label[for="${q}"]`),U=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),W=K.closest("label")!==null;if(!z&&!U&&!W)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 q=Number.parseInt(K.tagName.charAt(1));if(Q>0&&q>Q+1)Y.push({type:"heading-skip",element:`<${K.outerHTML}>`,message:`Heading level skipped from h${Q} to h${q}`,impact:"moderate",help:"Maintain proper heading hierarchy without skipping levels",helpUrl:"https://web.dev/learn/accessibility/structure/"});Q=q}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 q=K.textContent&&K.textContent.trim().length>0,z=K.hasAttribute("aria-label")||K.hasAttribute("aria-labelledby"),U=K.hasAttribute("title"),W=K.querySelector("img[alt]");if(!q&&!z&&!U&&!W)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 q=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(!q&&!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 q=K.getAttribute("style")||"";if(q.includes("color:")&&!q.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 FQ($,Z={}){let Y={},{recursive:X=!0,ignorePaths:J=[]}=Z,Q=z$.join($,X?"**/*.stx":"*.stx"),G=new Bun.Glob(Q),K=[];for await(let q of G.scan())if(!J.some((U)=>q.includes(z$.normalize(U))))K.push(q);for(let q of K)try{let z=await Bun.file(q).text();if(q.endsWith("good-a11y.stx"))continue;let U=await U9(z,q);if(U.length>0)Y[q]=U}catch(z){console.error(`Error scanning ${q}:`,z)}return Y}function W9($,Z={}){let Y={...VQ,...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 q=Q,z=`<img${G} alt=""${K}`;return X.push({type:"missing-alt",description:"Added empty alt attribute to image",before:q,after:z}),z});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,q=`<button${G} aria-label="Button"></button>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to empty button",before:K,after:q}),q}),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 q=Q,z=`<a${G} aria-label="Link">${K||""}</a>`;return X.push({type:"missing-accessible-name",description:"Added aria-label to link without text",before:q,after:z}),z});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 q=K.match(/\bname\s*=\s*["']([^"']+)["']/i),z=K.match(/\bid\s*=\s*["']([^"']+)["']/i),U=q?.[1]||z?.[1]||G,W=Q,_=`<${G}${K} aria-label="${U}">`;return X.push({type:"input-missing-label",description:`Added aria-label to ${G} element`,before:W,after:_}),_});if(Y.fixMissingLang)J=J.replace(/<html([^>]*)>/gi,(Q,G)=>{if(/\blang\s*=/i.test(G))return Q;let K=Q,q=`<html${G} lang="${Y.defaultLang}">`;return X.push({type:"missing-lang",description:`Added lang="${Y.defaultLang}" to html element`,before:K,after:q}),q});if(Y.fixPositiveTabindex)J=J.replace(/\btabindex\s*=\s*["']([1-9]\d*)["']/gi,(Q,G)=>{let K=Q,q='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 q=Q,z=`<${G}${K} tabindex="0">`;return X.push({type:"button-not-focusable",description:'Added tabindex="0" to element with role="button"',before:q,after:z}),z});if(Y.fixTableHeaders)J=J.replace(/<th([^>]*)>/gi,(Q,G)=>{if(/\bscope\s*=/i.test(G))return Q;let K=Q,q=`<th${G} scope="col">`;return X.push({type:"table-missing-scope",description:'Added scope="col" to table header',before:K,after:q}),q});return{original:$,fixed:J,fixCount:X.length,fixes:X}}async function _9($,Z={},Y=!1){let X=await Bun.file($).text(),J=W9(X,Z);if(Y&&J.fixCount>0)await Bun.write($,J.fixed);return J}async function wQ($,Z={},Y={}){let X={},{recursive:J=!0,ignorePaths:Q=[],writeBack:G=!1,extensions:K=[".stx",".html",".htm"]}=Y,q=K.length===1?`*${K[0]}`:`*{${K.join(",")}}`,z=z$.join($,J?`**/${q}`:q),U=new Bun.Glob(z);for await(let W of U.scan()){if(Q.some((B)=>W.includes(z$.normalize(B))))continue;try{let B=await _9(W,Z,G);if(B.fixCount>0)X[W]=B}catch(B){console.error(`Error fixing ${W}:`,B)}}return X}function AQ(){return[U$,W$]}var VQ,U$,W$;var Q7=C(()=>{VQ={fixMissingAlt:!0,fixMissingLabels:!0,fixMissingFormLabels:!0,fixTableHeaders:!0,fixMissingLang:!0,fixPositiveTabindex:!0,fixButtonFocusable:!0,defaultLang:"en"};U$={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},W$={name:"screenReader",handler:($)=>{return`<span class="sr-only">${$}</span>`},hasEndTag:!0}});function B9($){let Z=$.analytics;if(!Z?.enabled)return"";switch(Z.driver){case"fathom":return NQ(Z);case"google-analytics":return TQ(Z);case"plausible":return MQ(Z);case"self-hosted":return IQ(Z);case"custom":return DQ(Z);default:return""}}function NQ($){let Z=$.fathom;if(!Z?.siteId)return"";let Y=Z.scriptUrl||"https://cdn.usefathom.com/script.js",X=Z.defer!==!1?" defer":"",J=[`data-site="${v0(Z.siteId)}"`];if(Z.honorDnt)J.push('data-honor-dnt="true"');if(Z.spa)J.push('data-spa="auto"');if(Z.canonical)J.push(`data-canonical="${v0(Z.canonical)}"`);if(Z.auto===!1)J.push('data-auto="false"');return`
|
|
15
15
|
<!-- Fathom Analytics -->
|
|
16
16
|
<script src="${v0(Y)}" ${J.join(" ")}${X}></script>
|
|
17
17
|
`}function TQ($){let Z=$.googleAnalytics;if(!Z?.measurementId)return"";let Y=v0(Z.measurementId),X=Z.debug?`gtag('config', '${Y}', { 'debug_mode': true });`:"";return`
|
|
@@ -609,8 +609,8 @@ ${q}`},hasEndTag:!1,description:"Coordinates multiple animations together as a g
|
|
|
609
609
|
})();
|
|
610
610
|
`}function bH($){let Z=/v-(\w+)(?::(\w+))?(?:\.([\w.]+))?="([^"]*)"/g;return $.replace(Z,(Y,X,J,Q,G)=>{let q=(Q?Q.split("."):[]).reduce((z,U)=>{return z[U]=!0,z},{});return`data-stx-directive="${X}:${G}" data-stx-directive-arg="${J||""}" data-stx-directive-modifiers='${JSON.stringify(q)}'`})}var _$,W7;var _7=C(()=>{_$=new Map,W7=new Map});function G1($){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__
|
|
611
611
|
`});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
|
|
612
|
-
`}),$}import w9 from"process";function r0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,J]of Object.entries(w9.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 vH($="STX_PUBLIC_"){let Z={};for(let[Y,X]of Object.entries(w9.env))if(Y.startsWith($)&&X!==void 0)Z[Y]=X;return Z}var a1=()=>{};var B$={};p(B$,{hasUserImports:()=>eQ,bundleClientScript:()=>ZG});import _0 from"path";import g0 from"fs";function eQ($){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(!A9.some((q)=>q.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(!A9.some((q)=>q.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function $G($,Z,Y,X){let J=(Q,G)=>{let K=Q===Y?Z:_0.dirname(Q),q=_0.resolve(K,G),z=[q,`${q}.ts`,`${q}.tsx`,`${q}.js`,`${q}.mjs`,`${q}.jsx`,_0.join(q,"index.ts"),_0.join(q,"index.tsx"),_0.join(q,"index.js"),_0.join(q,"index.mjs")];for(let U of z)try{if(g0.existsSync(U)&&g0.statSync(U,{throwIfNoEntry:!1})?.isFile())return U}catch{}return q};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=_0.resolve($,G.path.slice(2)),q=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,_0.join(K,"index.ts"),_0.join(K,"index.tsx"),_0.join(K,"index.js"),_0.join(K,"index.mjs")];for(let z of q)if(g0.existsSync(z)&&g0.statSync(z,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",z),X.add(z),{path:z};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}})}}}async function ZG($,Z,Y={}){let X=Y.projectRoot||process.cwd(),J=Y.minify??!1,Q=Y.cacheDir||_0.join(X,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),q=_0.join(Q,`${K}.js`),z=_0.join(Q,`${K}.deps.json`),U=Bun.file(q);if(await U.exists()){let w=Bun.file(z),R=!0;if(await w.exists())try{let N=JSON.parse(await w.text());for(let M of N.files)try{if(g0.statSync(M.path).mtimeMs!==M.mtimeMs){R=!1;break}}catch{R=!1;break}}catch{R=!1}if(R)return console.log("[stx:bundler] cache hit:",K),await U.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let W=_0.join(X,".stx","bundle-tmp"),_=_0.join(W,`${K}.ts`),B=_0.join(W,"out",K);g0.mkdirSync(W,{recursive:!0}),g0.mkdirSync(B,{recursive:!0});let j=_0.dirname(Z),O=[],L=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,
|
|
613
|
-
export { ${O.join(", ")} }`:"";await Bun.write(_,$+
|
|
612
|
+
`}),$}import w9 from"process";function r0($="STX_PUBLIC_"){let Z={},Y={};for(let[X,J]of Object.entries(w9.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 vH($="STX_PUBLIC_"){let Z={};for(let[Y,X]of Object.entries(w9.env))if(Y.startsWith($)&&X!==void 0)Z[Y]=X;return Z}var a1=()=>{};var B$={};p(B$,{hasUserImports:()=>eQ,bundleClientScript:()=>ZG});import _0 from"path";import g0 from"fs";function eQ($){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(!A9.some((q)=>q.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(!A9.some((q)=>q.test(G)))return console.log("[stx:bundler] detected side-effect import:",G),!0}return!1}function $G($,Z,Y,X){let J=(Q,G)=>{let K=Q===Y?Z:_0.dirname(Q),q=_0.resolve(K,G),z=[q,`${q}.ts`,`${q}.tsx`,`${q}.js`,`${q}.mjs`,`${q}.jsx`,_0.join(q,"index.ts"),_0.join(q,"index.tsx"),_0.join(q,"index.js"),_0.join(q,"index.mjs")];for(let U of z)try{if(g0.existsSync(U)&&g0.statSync(U,{throwIfNoEntry:!1})?.isFile())return U}catch{}return q};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=_0.resolve($,G.path.slice(2)),q=[K,`${K}.ts`,`${K}.tsx`,`${K}.js`,`${K}.mjs`,`${K}.jsx`,_0.join(K,"index.ts"),_0.join(K,"index.tsx"),_0.join(K,"index.js"),_0.join(K,"index.mjs")];for(let z of q)if(g0.existsSync(z)&&g0.statSync(z,{throwIfNoEntry:!1})?.isFile())return console.log(`[stx:bundler] resolved ${G.path[0]}/ import:`,G.path,"\u2192",z),X.add(z),{path:z};return console.warn(`[stx:bundler] could not resolve ${G.path[0]}/ import:`,G.path),{path:K}})}}}async function ZG($,Z,Y={}){let X=Y.projectRoot||process.cwd(),J=Y.minify??!1,Q=Y.cacheDir||_0.join(X,".stx","bundle-cache"),G=new Bun.CryptoHasher("md5");G.update($+Z);let K=G.digest("hex").slice(0,12),q=_0.join(Q,`${K}.js`),z=_0.join(Q,`${K}.deps.json`),U=Bun.file(q);if(await U.exists()){let w=Bun.file(z),R=!0;if(await w.exists())try{let N=JSON.parse(await w.text());for(let M of N.files)try{if(g0.statSync(M.path).mtimeMs!==M.mtimeMs){R=!1;break}}catch{R=!1;break}}catch{R=!1}if(R)return console.log("[stx:bundler] cache hit:",K),await U.text();console.log("[stx:bundler] cache invalidated by dep change:",K)}let W=_0.join(X,".stx","bundle-tmp"),_=_0.join(W,`${K}.ts`),B=_0.join(W,"out",K);g0.mkdirSync(W,{recursive:!0}),g0.mkdirSync(B,{recursive:!0});let j=_0.dirname(Z),O=[],L=/^(export\s+)?(?:const|let|var)\s+(?:\{([^}]+)\}|(\w+))/gm,V=/^(export\s+)?(?:async\s+)?function\s+(\w+)/gm,H;while((H=L.exec($))!==null){if(H[1])continue;if(H[2])H[2].split(",").forEach((w)=>{let R=w.split(":")[0].trim();if(R)O.push(R)});else if(H[3])O.push(H[3])}while((H=V.exec($))!==null){if(H[1])continue;O.push(H[2])}let F=O.length>0?`
|
|
613
|
+
export { ${O.join(", ")} }`:"";await Bun.write(_,$+F),console.log("[stx:bundler] bundling:",K,"from:",_0.basename(Z));let A=new Set;try{let w=await Bun.build({entrypoints:[_],outdir:B,target:"browser",format:"esm",minify:J,plugins:[$G(X,j,_,A)],define:{"process.env.NODE_ENV":J?'"production"':'"development"',...r0()},root:X});if(!w.success){let T=w.logs.filter((I)=>I.level==="error").map((I)=>I.message).join(", ");return console.warn("[stx:bundler] build failed:",T),$}let R="";for(let T of w.outputs){R=await T.text();break}let N=[];for(let T of R.matchAll(/^\s*export\s*\{([^}]*)\}\s*;?\s*$/gm))for(let I of T[1].split(",")){let D=I.trim().match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D&&D[1]!==D[2])N.push([D[2],D[1]])}if(R=R.replace(/^\s*export\s*\{[^}]*\}\s*;?\s*$/gm,"").replace(/^\s*export\s+default\s+.*$/gm,"").trim(),N.length>0){let T=N.map(([I,D])=>`${JSON.stringify(I)}: ${D}`).join(", ");R+=`
|
|
614
614
|
var __stxScopeRenames = { ${T} };`}console.log("[stx:bundler] bundled:",K,"output:",R.length,"bytes"),g0.mkdirSync(Q,{recursive:!0}),await Bun.write(q,R);let M=Array.from(A).map((T)=>{try{return{path:T,mtimeMs:g0.statSync(T).mtimeMs}}catch{return null}}).filter((T)=>T!==null);return await Bun.write(z,JSON.stringify({files:M})),R}catch(w){let R=w instanceof Error?w.message:String(w),N=w?.errors,M=Array.isArray(N)&&N.length>0?`
|
|
615
615
|
${N.map((T)=>`- ${T?.message??T}`).join(`
|
|
616
616
|
`)}`:"";return console.warn(`[stx:bundler] error: ${R}${M}`),$}finally{try{g0.rmSync(_,{force:!0}),g0.rmSync(B,{recursive:!0,force:!0})}catch{}}}var A9;var j$=C(()=>{a1();A9=[/^stx$/,/^@stacksjs\/stx$/,/^@stacksjs\/browser$/,/^@stores$/,/^stx\/stores$/,/^@composables$/]});function dH($){t1={...t1,...$}}function mH(){t1={...T9}}function uH(){return{...t1}}function JG($){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 QG($,Z){let Y=/[$A-Z_a-z][$\w]*/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=$[X.index-1];if(YG.has(J))throw Error(`Potentially unsafe expression (matched /\\b${J}\\b/; identifier ${J}): ${Z}`);if(Q==="."&&M9.has(J))throw Error(`Potentially unsafe expression (matched /.${J}/; property ${J}): ${Z}`)}}function GG($){let Z=/\[\s*(['"])(.*?)\1\s*\]/g,Y;while((Y=Z.exec($))!==null){let X=Y[2];if(!M9.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 I5($){let Z=$.trim(),Y=JG(Z);QG(Y,Z),GG(Z);for(let X of j7)if(X.test(Y))throw Error(`Potentially unsafe expression (matched /${X.source}/): ${Z}`);if(!t1.allowBracketNotation&&XG.test(Z))throw Error(`Bracket notation with strings not allowed: ${Z}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return Z}function I9($){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("__")||j7.some((J)=>J.test(Y)))continue;if(X&&typeof X==="object"&&!Array.isArray(X))Z[Y]=B7(X);else Z[Y]=X}return Z}function B7($,Z=0){if(Z>=t1.maxSanitizeDepth)return"[Object too deep]";if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((X)=>B7(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]=B7(J,Z+1);else Y[X]=J}return Y}function e($,Z){try{let Y=I9(Z),X=Object.keys(Y),J=Object.values(Y);return Z0($,X)(...J)}catch{return}}function $0($){try{return I5($),!0}catch{return!1}}function pH($){try{return I5($),null}catch(Z){return Z instanceof Error?Z.message:String(Z)}}function cH($,Z){try{let Y=e($,Z);return Boolean(Y)}catch{return!1}}function lH($,Z){try{let Y=e($,Z);if(Array.isArray(Y))return Y;if(Y&&typeof Y==="object"&&"length"in Y){let X=Y.length;if(typeof X==="number"&&Number.isFinite(X)&&X>=0&&Number.isInteger(X))return Array.from(Y)}return[]}catch{return[]}}function H0($,Z){try{let Y=e($,Z);if(Y&&typeof Y==="object"&&!Array.isArray(Y))return Y;return{}}catch{return{}}}function Z0($,Z){let Y=I5($),X=/^[A-Za-z_$][\w$]*$/,J=[],Q=[];for(let z=0;z<Z.length;z++){let U=Z[z];if(!X.test(U))continue;if(D9.has(U))continue;J.push(z),Q.push(U)}let G=(z)=>Function(...Q,...z,`
|
|
@@ -655,7 +655,7 @@ catch (e) {
|
|
|
655
655
|
}
|
|
656
656
|
return result;
|
|
657
657
|
// eslint-disable-next-line pickier/no-unused-vars
|
|
658
|
-
`)}var T9,t1,j7,YG,M9,XG,D9,N9=65536;var V0=C(()=>{T9={maxSanitizeDepth:10,allowBracketNotation:!1},t1={...T9};j7=[/\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/],YG=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"]),M9=new Set(["__proto__","constructor","prototype"]),XG=/[\w)\]]\s*\[\s*['"]/;D9=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 sH(){E9=0,H$.clear()}function O$($,Z){let Y=E9++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return H$.set(X,{type:$,expression:Z}),X}function rH(){let $={};for(let[Z,Y]of H$)$[Z]={type:Y.type,expression:Y.expression};return $}function aH($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=H$.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function tH($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function eH($){return $.includes("<!--__STX_")}var E9=0,H$;var k9=C(()=>{H$=new Map});function S9($,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 L$($,Z){return S9($,Z,KG,qG)}function b9($,Z){return S9($,Z,zG,UG)}function y9($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function E5($,Z,Y){let X=[],J="",Q=0,G=$.length,K=!1,q=null;while(Q<G){let z=$[Q];if(K){if(J+=z,q){if(z===q)q=null}else if(z==='"'||z==="'")q=z;else if(z===">")K=!1;Q++;continue}if(z==="<"){let U=Z($,Q);if(U>Q){J+=Y($.slice(Q,U),X.length),X.push($.slice(Q,U)),Q=U;continue}if(/^<\/?[a-zA-Z]/.test($.slice(Q,Q+2)))K=!0;J+=z,Q++;continue}J+=z,Q++}return{output:J,tokens:X}}function F$($){let{output:Z,tokens:Y}=E5($,L$,(X,J)=>`\x00STX_SCRIPT_${J}\x00`);return{output:Z,scripts:Y}}function V$($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,X)=>Z[+X]??"")}var KG,qG,zG,UG;var w$=C(()=>{KG=/<script\b[^>]*>/iy,qG=/<\/script\s*>/ig,zG=/<style\b[^>]*>/iy,UG=/<\/style\s*>/ig});var h9={};p(h9,{usesSignalsInScript:()=>e1,unescapeHtml:()=>H7,registerFilters:()=>_G,registerFilter:()=>v9,processExpressions:()=>a0,interpolateScriptsInTemplate:()=>jG,interpolateScriptExpressions:()=>f9,getAllFilters:()=>x9,evaluateExpression:()=>h0,escapeHtml:()=>m0,defaultFilters:()=>S5,clearCustomFilters:()=>BG,applyFilters:()=>g9});function WG($){let Z=C9.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),C9.set($,Z)}return Z.lastIndex=0,Z}function v9($,Z){if($ in S5)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);k5[$]=Z}function _G($){for(let[Z,Y]of Object.entries($))v9(Z,Y)}function x9(){return{...S5,...k5}}function BG(){for(let $ of Object.keys(k5))delete k5[$]}function m0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function e1($){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 P9($,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 z=0;z<X.length;z++){let U=X[z];if(!Q&&U==="`"){Q=!0,G=0;continue}if(Q){if(U==="`"&&G===0){Q=!1;continue}if(U==="$"&&X[z+1]==="{"){G++,z++;continue}if(U==="}"&&G>0){G--;continue}continue}J+=U}X=J;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,q;while((q=K.exec(X))!==null){let z=q[1];if(!X.substring(0,q.index).trimEnd().endsWith(".")){if(!Y.includes(z)&&!(z in Z))return!1}}return!0}function f9($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=h0(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=h0(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function jG($,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=f9(Q,Z);return`<script${J}>${G}</script>`})}function a0($,Z,Y,X){let J=$,Q=(U,W)=>{let _=b9(U,W);if(_===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(U.slice(W,_))?-1:_},G=(U,W,_,B)=>{let j=_.length,{output:O,tokens:L}=E5(U,W,(F,H)=>B(j+H));return _.push(...L),O},K=[];J=G(J,Q,K,(U)=>`<!--__STX_STYLE_${U}__-->`);let q=[];J=G(J,L$,q,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`);let z=X?.forceSignals===!0||e1($);J=J.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(U,W,_)=>{try{let B=h0(W,Z);return B!==void 0&&B!==null?String(B):""}catch(B){let j=B instanceof Error?B.message:String(B);return J0("Expression",`Error evaluating: {{{ ${W.trim()}}}}: ${j}`,Y,$,_,U)}}),J=J.replace(/\{!!([\s\S]*?)!!\}/g,(U,W,_)=>{try{let B=h0(W,Z);if(B===void 0&&Z.__stx_buildMode==="compile")return O$("raw",W.trim());return B!==void 0&&B!==null?String(B):""}catch(B){if(Z.__stx_buildMode==="compile")return O$("raw",W.trim());let j=B instanceof Error?B.message:String(B);return J0("Expression",`Error evaluating: {!! ${W.trim()} !!}: ${j}`,Y,$,_,U)}}),J=G(J,L$,q,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`),J=G(J,Q,K,(U)=>`<!--__STX_STYLE_${U}__-->`),J=J.replace(/\{\{([\s\S]*?)\}\}/g,(U,W,_)=>{let B=W.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],O=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,F=B.match(O)?.[1],H=F&&((F in Z)||j.includes(F)),V=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=B.match(V),w=A&&!j.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(B))return"";try{let R=h0(W,Z);if(R===void 0&&z&&!P9(B,Z))return U;if(R===void 0&&Z.__stx_buildMode==="compile"&&!z)return O$("expr",B);return R!==void 0&&R!==null?m0(String(R)):""}catch(R){if(z&&!P9(B,Z))return U;if(w)return U;let N=R instanceof Error?R.message:String(R);return J0("Expression",`Error evaluating: {{ ${B} }}: ${N}`,Y,$,_,U)}});for(let U=0;U<q.length;U++)J=J.replace(`<!--__STX_SCRIPT_EXPR_${U}__-->`,()=>q[U]);for(let U=0;U<K.length;U++)J=J.replace(`<!--__STX_STYLE_${U}__-->`,()=>K[U]);return J}function g9($,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=k5[G]||S5[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(x9()).join(", ")}`);let q=[];if(J.startsWith(":")){let z=J.match(/^:([^|\s]+)/);if(z){let U=z[1].trim();try{let W=Number(U);q=[Number.isNaN(W)?U:W]}catch{q=[U]}J=J.substring(z[0].length).trim()}}else if(J.startsWith("(")){let z=1,U=1;while(z>0&&U<J.length){if(J[U]==="(")z++;if(J[U]===")")z--;U++}if(z===0){let W=J.substring(1,U-1).trim();if(W)try{if(W.startsWith("{")&&W.endsWith("}"))q=[h0(`(${W})`,Y,!0)];else{let _=[],B="",j=null,O=0,L=0,F=0,H=!1;for(let V=0;V<W.length;V++){let A=W[V];if(H){B+=A,H=!1;continue}if(A==="\\"){B+=A,H=!0;continue}if(j){if(B+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,B+=A;continue}if(A==="(")O++;else if(A===")")O--;else if(A==="[")L++;else if(A==="]")L--;else if(A==="{")F++;else if(A==="}")F--;if(A===","&&O===0&&L===0&&F===0){_.push(B),B="";continue}B+=A}if(B)_.push(B);q=_.map((V)=>{let A=V.trim();return h0(A,Y,!0)})}}catch{q=[W]}J=J.substring(U).trim()}}try{X=K(X,Y,...q)}catch(z){let U=z instanceof Error?z.message:String(z);throw Error(`Error applying filter '${G}': ${U}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function HG($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let q=$[K],z=$[K+1];if(Z&&G){G=!1;continue}if(Z&&q==="\\"){G=!0;continue}if(G=!1,(q==='"'||q==="'"||q==="`")&&!G){if(!Z)Z=!0,Y=q;else if(q===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&q==="$"&&z==="{"){let U=1;K+=2;while(K<$.length&&U>0){if($[K]==="{")U++;else if($[K]==="}")U--;if(U>0)K++}continue}if(Z)continue;if(q==="(")X++;else if(q===")")X--;else if(q==="[")J++;else if(q==="]")J--;else if(q==="{")Q++;else if(q==="}")Q--;if(q==="|"&&X===0&&J===0&&Q===0){if(z==="|"){K++;continue}if(z==="="){K++;continue}return K}}return-1}function h0($,Z,Y=!1){try{let X=$.trim(),J=HG(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=h0(Q,Z,!0);return g9(K,G,Z)}if(!$0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return e(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return Z0(X,Q)(...G)}catch{return e(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=OG(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 OG($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=LG($,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 LG($,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 q=Y[K-1]===X[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,J[K]+1,J[K-1]+q)}for(let K=0;K<=Y.length;K++)J[K]=Q[K]}return J[Y.length]}function H7($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var k5,C9,S5;var t0=C(()=>{V0();w0();k9();w$();k5={},C9=new Map;S5={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 m0(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 q of Q){if(G===void 0||G===null)break;G=G[q]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([q,z])=>{K=K.replace(WG(q),String(z))}),K},t:($,Z,Y={})=>{return S5.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 b5{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 S1($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!k1.has(Y)){if(k1.size>=FG){let X=k1.keys().next().value;if(X)k1.delete(X)}k1.set(Y,new RegExp($,Z))}return k1.get(Y)}function GO(){k1.clear()}class VG{cache=new Map;maxSize;ttl;constructor($=1000,Z=300000){this.maxSize=$,this.ttl=Z}get($){let Z=this.cache.get($);if(!Z)return null;if(Date.now()-Z.timestamp>this.ttl)return this.cache.delete($),null;return Z.result}set($,Z,Y=new Set){if(this.cache.size>=this.maxSize){let X=this.cache.keys().next().value;if(X)this.cache.delete(X)}this.cache.set($,{result:Z,timestamp:Date.now(),dependencies:Y})}invalidateDependency($){let Z=0;for(let[Y,X]of this.cache.entries())if(X.dependencies.has($))this.cache.delete(Y),Z++;return Z}clear(){this.cache.clear()}getStats(){return{size:this.cache.size,maxSize:this.maxSize}}}function KO($,Z){let Y;return(...X)=>{if(Y)clearTimeout(Y);Y=setTimeout(()=>{$(...X)},Z)}}function qO($,Z){let Y=0,X;return(...J)=>{let Q=Date.now();if(Q-Y>=Z)Y=Q,X=$(...J);return X}}function zO($,Z=100){let Y=new Map;return(...X)=>{let J;try{J=JSON.stringify(X)}catch{return $(...X)}if(Y.has(J))return Y.get(J);if(Y.size>=Z){let G=Y.keys().next().value;if(G)Y.delete(G)}let Q=$(...X);return Y.set(J,Q),Q}}function UO($,Z,Y,X){if(typeof Z==="string"){let J=S1(Z,X);if(typeof Y==="string"&&X?.includes("i")){let Q=Y;return $.replace(J,(G)=>{if(G===G.toUpperCase()&&G!==G.toLowerCase())return Q.toUpperCase();else if(G[0]===G[0].toUpperCase()&&G[0]!==G[0].toLowerCase())return Q[0].toUpperCase()+Q.slice(1).toLowerCase();else return Q.toLowerCase()})}return $.replace(J,Y)}return $.replace(Z,Y)}class d9{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(q)=>{try{let z=`${Y}:${q}`,U=J.get(z);if(!U){if(J.size>=Q){let W=J.keys().next().value;if(W)J.delete(W)}U=Function(...Z,`
|
|
658
|
+
`)}var T9,t1,j7,YG,M9,XG,D9,N9=65536;var V0=C(()=>{T9={maxSanitizeDepth:10,allowBracketNotation:!1},t1={...T9};j7=[/\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/],YG=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"]),M9=new Set(["__proto__","constructor","prototype"]),XG=/[\w)\]]\s*\[\s*['"]/;D9=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 sH(){E9=0,H$.clear()}function O$($,Z){let Y=E9++,X=`<!--__STX_${$.toUpperCase()}_${Y}__-->`;return H$.set(X,{type:$,expression:Z}),X}function rH(){let $={};for(let[Z,Y]of H$)$[Z]={type:Y.type,expression:Y.expression};return $}function aH($){let Z={},Y=/<!--__STX_(EXPR|COND|RAW)_(\d+)__-->/g,X;while((X=Y.exec($))!==null){let J=X[0],Q=X[1].toLowerCase(),G=H$.get(J);Z[J]={type:Q,expression:G?.expression||""}}return Z}function tH($,Z){let Y=$;for(let[X,J]of Z)Y=Y.split(X).join(J);return Y}function eH($){return $.includes("<!--__STX_")}var E9=0,H$;var k9=C(()=>{H$=new Map});function S9($,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 L$($,Z){return S9($,Z,KG,qG)}function b9($,Z){return S9($,Z,zG,UG)}function y9($,Z){if(!$.startsWith("<!--",Z))return-1;let Y=$.indexOf("-->",Z+4);if(Y===-1)return-1;return Y+3}function E5($,Z,Y){let X=[],J="",Q=0,G=$.length,K=!1,q=null;while(Q<G){let z=$[Q];if(K){if(J+=z,q){if(z===q)q=null}else if(z==='"'||z==="'")q=z;else if(z===">")K=!1;Q++;continue}if(z==="<"){let U=Z($,Q);if(U>Q){J+=Y($.slice(Q,U),X.length),X.push($.slice(Q,U)),Q=U;continue}if(/^<\/?[a-zA-Z]/.test($.slice(Q,Q+2)))K=!0;J+=z,Q++;continue}J+=z,Q++}return{output:J,tokens:X}}function F$($){let{output:Z,tokens:Y}=E5($,L$,(X,J)=>`\x00STX_SCRIPT_${J}\x00`);return{output:Z,scripts:Y}}function V$($,Z){if(Z.length===0)return $;return $.replace(/\x00STX_SCRIPT_(\d+)\x00/g,(Y,X)=>Z[+X]??"")}var KG,qG,zG,UG;var w$=C(()=>{KG=/<script\b[^>]*>/iy,qG=/<\/script\s*>/ig,zG=/<style\b[^>]*>/iy,UG=/<\/style\s*>/ig});var h9={};p(h9,{usesSignalsInScript:()=>e1,unescapeHtml:()=>H7,registerFilters:()=>_G,registerFilter:()=>v9,processExpressions:()=>a0,interpolateScriptsInTemplate:()=>jG,interpolateScriptExpressions:()=>f9,getAllFilters:()=>x9,evaluateExpression:()=>h0,escapeHtml:()=>m0,defaultFilters:()=>S5,clearCustomFilters:()=>BG,applyFilters:()=>g9});function WG($){let Z=C9.get($);if(!Z){let Y=$.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");Z=new RegExp(`:${Y}(?!\\w)`,"g"),C9.set($,Z)}return Z.lastIndex=0,Z}function v9($,Z){if($ in S5)console.warn(`Filter "${$}" already exists as a built-in filter. Custom filter will take precedence.`);k5[$]=Z}function _G($){for(let[Z,Y]of Object.entries($))v9(Z,Y)}function x9(){return{...S5,...k5}}function BG(){for(let $ of Object.keys(k5))delete k5[$]}function m0($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function e1($){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 P9($,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 z=0;z<X.length;z++){let U=X[z];if(!Q&&U==="`"){Q=!0,G=0;continue}if(Q){if(U==="`"&&G===0){Q=!1;continue}if(U==="$"&&X[z+1]==="{"){G++,z++;continue}if(U==="}"&&G>0){G--;continue}continue}J+=U}X=J;let K=/\b([a-zA-Z_$][a-zA-Z0-9_$]*)\b/g,q;while((q=K.exec(X))!==null){let z=q[1];if(!X.substring(0,q.index).trimEnd().endsWith(".")){if(!Y.includes(z)&&!(z in Z))return!1}}return!0}function f9($,Z){let Y=$;return Y=Y.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=h0(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=h0(J,Z);if(G===void 0)return X;return JSON.stringify(G)}catch{return X}}),Y}function jG($,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=f9(Q,Z);return`<script${J}>${G}</script>`})}function a0($,Z,Y,X){let J=$,Q=(U,W)=>{let _=b9(U,W);if(_===-1)return-1;return/\{\{[\s\S]*?\}\}|\{!![\s\S]*?!!\}/.test(U.slice(W,_))?-1:_},G=(U,W,_,B)=>{let j=_.length,{output:O,tokens:L}=E5(U,W,(V,H)=>B(j+H));return _.push(...L),O},K=[];J=G(J,Q,K,(U)=>`<!--__STX_STYLE_${U}__-->`);let q=[];J=G(J,L$,q,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`);let z=X?.forceSignals===!0||e1($);J=J.replace(/\{\{\{([\s\S]*?)\}\}\}/g,(U,W,_)=>{try{let B=h0(W,Z);return B!==void 0&&B!==null?String(B):""}catch(B){let j=B instanceof Error?B.message:String(B);return J0("Expression",`Error evaluating: {{{ ${W.trim()}}}}: ${j}`,Y,$,_,U)}}),J=J.replace(/\{!!([\s\S]*?)!!\}/g,(U,W,_)=>{try{let B=h0(W,Z);if(B===void 0&&Z.__stx_buildMode==="compile")return O$("raw",W.trim());return B!==void 0&&B!==null?String(B):""}catch(B){if(Z.__stx_buildMode==="compile")return O$("raw",W.trim());let j=B instanceof Error?B.message:String(B);return J0("Expression",`Error evaluating: {!! ${W.trim()} !!}: ${j}`,Y,$,_,U)}}),J=G(J,L$,q,(U)=>`<!--__STX_SCRIPT_EXPR_${U}__-->`),J=G(J,Q,K,(U)=>`<!--__STX_STYLE_${U}__-->`),J=J.replace(/\{\{([\s\S]*?)\}\}/g,(U,W,_)=>{let B=W.trim(),j=["parseInt","parseFloat","String","Number","Boolean","Array","Object","JSON","Math","Date","encodeURIComponent","decodeURIComponent","encodeURI","decodeURI","true","false","null","undefined"],O=/^([a-zA-Z_$][a-zA-Z0-9_$]*)/,V=B.match(O)?.[1],H=V&&((V in Z)||j.includes(V)),F=/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/,A=B.match(F),w=A&&!j.includes(A[1])&&!(A[1]in Z);if(/^__[A-Z_]+__$/.test(B))return"";try{let R=h0(W,Z);if(R===void 0&&z&&!P9(B,Z))return U;if(R===void 0&&Z.__stx_buildMode==="compile"&&!z)return O$("expr",B);return R!==void 0&&R!==null?m0(String(R)):""}catch(R){if(z&&!P9(B,Z))return U;if(w)return U;let N=R instanceof Error?R.message:String(R);return J0("Expression",`Error evaluating: {{ ${B} }}: ${N}`,Y,$,_,U)}});for(let U=0;U<q.length;U++)J=J.replace(`<!--__STX_SCRIPT_EXPR_${U}__-->`,()=>q[U]);for(let U=0;U<K.length;U++)J=J.replace(`<!--__STX_STYLE_${U}__-->`,()=>K[U]);return J}function g9($,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=k5[G]||S5[G];if(!K)throw Error(`Filter not found: ${G}. Available filters: ${Object.keys(x9()).join(", ")}`);let q=[];if(J.startsWith(":")){let z=J.match(/^:([^|\s]+)/);if(z){let U=z[1].trim();try{let W=Number(U);q=[Number.isNaN(W)?U:W]}catch{q=[U]}J=J.substring(z[0].length).trim()}}else if(J.startsWith("(")){let z=1,U=1;while(z>0&&U<J.length){if(J[U]==="(")z++;if(J[U]===")")z--;U++}if(z===0){let W=J.substring(1,U-1).trim();if(W)try{if(W.startsWith("{")&&W.endsWith("}"))q=[h0(`(${W})`,Y,!0)];else{let _=[],B="",j=null,O=0,L=0,V=0,H=!1;for(let F=0;F<W.length;F++){let A=W[F];if(H){B+=A,H=!1;continue}if(A==="\\"){B+=A,H=!0;continue}if(j){if(B+=A,A===j)j=null;continue}if(A==='"'||A==="'"||A==="`"){j=A,B+=A;continue}if(A==="(")O++;else if(A===")")O--;else if(A==="[")L++;else if(A==="]")L--;else if(A==="{")V++;else if(A==="}")V--;if(A===","&&O===0&&L===0&&V===0){_.push(B),B="";continue}B+=A}if(B)_.push(B);q=_.map((F)=>{let A=F.trim();return h0(A,Y,!0)})}}catch{q=[W]}J=J.substring(U).trim()}}try{X=K(X,Y,...q)}catch(z){let U=z instanceof Error?z.message:String(z);throw Error(`Error applying filter '${G}': ${U}`)}if(J.startsWith("|"))J=J.substring(1).trim();else break}return X}function HG($){let Z=!1,Y="",X=0,J=0,Q=0,G=!1;for(let K=0;K<$.length;K++){let q=$[K],z=$[K+1];if(Z&&G){G=!1;continue}if(Z&&q==="\\"){G=!0;continue}if(G=!1,(q==='"'||q==="'"||q==="`")&&!G){if(!Z)Z=!0,Y=q;else if(q===Y)Z=!1,Y="";continue}if(Z&&Y==="`"&&q==="$"&&z==="{"){let U=1;K+=2;while(K<$.length&&U>0){if($[K]==="{")U++;else if($[K]==="}")U--;if(U>0)K++}continue}if(Z)continue;if(q==="(")X++;else if(q===")")X--;else if(q==="[")J++;else if(q==="]")J--;else if(q==="{")Q++;else if(q==="}")Q--;if(q==="|"&&X===0&&J===0&&Q===0){if(z==="|"){K++;continue}if(z==="="){K++;continue}return K}}return-1}function h0($,Z,Y=!1){try{let X=$.trim(),J=HG(X);if(J>0){let Q=X.substring(0,J).trim(),G=X.substring(J+1).trim(),K=h0(Q,Z,!0);return g9(K,G,Z)}if(!$0(X)){if(!Y)console.warn(`Potentially unsafe expression detected, using safe evaluator: ${X}`);return e(X,Z)}try{let Q=Object.keys(Z),G=Object.values(Z);return Z0(X,Q)(...G)}catch{return e(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=OG(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 OG($,Z){let Y=null;for(let J of Z){if(J===$)continue;let Q=LG($,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 LG($,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 q=Y[K-1]===X[G-1]?0:1;Q[K]=Math.min(Q[K-1]+1,J[K]+1,J[K-1]+q)}for(let K=0;K<=Y.length;K++)J[K]=Q[K]}return J[Y.length]}function H7($){if(!$)return"";return $.replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(/&/g,"&")}var k5,C9,S5;var t0=C(()=>{V0();w0();k9();w$();k5={},C9=new Map;S5={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 m0(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 q of Q){if(G===void 0||G===null)break;G=G[q]}if(G===void 0||G===null)return J?$:"";let K=String(G);return Object.entries(Y).forEach(([q,z])=>{K=K.replace(WG(q),String(z))}),K},t:($,Z,Y={})=>{return S5.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 b5{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 S1($,Z){if(Z?.includes("g"))return new RegExp($,Z);let Y=`${$}:${Z||""}`;if(!k1.has(Y)){if(k1.size>=FG){let X=k1.keys().next().value;if(X)k1.delete(X)}k1.set(Y,new RegExp($,Z))}return k1.get(Y)}function GO(){k1.clear()}class VG{cache=new Map;maxSize;ttl;constructor($=1000,Z=300000){this.maxSize=$,this.ttl=Z}get($){let Z=this.cache.get($);if(!Z)return null;if(Date.now()-Z.timestamp>this.ttl)return this.cache.delete($),null;return Z.result}set($,Z,Y=new Set){if(this.cache.size>=this.maxSize){let X=this.cache.keys().next().value;if(X)this.cache.delete(X)}this.cache.set($,{result:Z,timestamp:Date.now(),dependencies:Y})}invalidateDependency($){let Z=0;for(let[Y,X]of this.cache.entries())if(X.dependencies.has($))this.cache.delete(Y),Z++;return Z}clear(){this.cache.clear()}getStats(){return{size:this.cache.size,maxSize:this.maxSize}}}function KO($,Z){let Y;return(...X)=>{if(Y)clearTimeout(Y);Y=setTimeout(()=>{$(...X)},Z)}}function qO($,Z){let Y=0,X;return(...J)=>{let Q=Date.now();if(Q-Y>=Z)Y=Q,X=$(...J);return X}}function zO($,Z=100){let Y=new Map;return(...X)=>{let J;try{J=JSON.stringify(X)}catch{return $(...X)}if(Y.has(J))return Y.get(J);if(Y.size>=Z){let G=Y.keys().next().value;if(G)Y.delete(G)}let Q=$(...X);return Y.set(J,Q),Q}}function UO($,Z,Y,X){if(typeof Z==="string"){let J=S1(Z,X);if(typeof Y==="string"&&X?.includes("i")){let Q=Y;return $.replace(J,(G)=>{if(G===G.toUpperCase()&&G!==G.toLowerCase())return Q.toUpperCase();else if(G[0]===G[0].toUpperCase()&&G[0]!==G[0].toLowerCase())return Q[0].toUpperCase()+Q.slice(1).toLowerCase();else return Q.toLowerCase()})}return $.replace(J,Y)}return $.replace(Z,Y)}class d9{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(q)=>{try{let z=`${Y}:${q}`,U=J.get(z);if(!U){if(J.size>=Q){let W=J.keys().next().value;if(W)J.delete(W)}U=Function(...Z,`
|
|
659
659
|
'use strict';
|
|
660
660
|
try {
|
|
661
661
|
return ${q};
|
|
@@ -1067,10 +1067,10 @@ ${O}
|
|
|
1067
1067
|
`:`
|
|
1068
1068
|
`)}</p>`);if(J=K.join(`
|
|
1069
1069
|
`),X)J=J.replace(/\n/g,`<br />
|
|
1070
|
-
`);for(let U=0;U<Q.length;U++)J=J.replace(`\x00CODEBLOCK${U}\x00`,Q[U]);return J=J.replace(/<p>\s*<\/p>/g,""),J.trim()}var TG={};p(TG,{processMarkdownDirectives:()=>F7,markdownDirectiveHandler:()=>V7});async function F7($,Z,Y=""){let X=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let K=G.index,q=G[0].match(/@markdown\(([^)]*)\)/),z=q?q[1]:"",U=K+G[0].length,W=1,_=U,B=-1;while(W>0&&_<$.length){let L=$.indexOf("@markdown",_),
|
|
1071
|
-
`||H==="\r"||H===" "||H===void 0)W++;_=L+9}else{if(W--,W===0){B=
|
|
1072
|
-
`)}function gO($,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 hO($,Z){let Y=Z?$.filter((J)=>J.format===Z):$;if(Y.length===0){let J=$.filter((G)=>G.format==="jpeg"),Q=J.length>0?J:$;return Q[Math.floor(Q.length/2)]}let X=Y.sort((J,Q)=>J.width-Q.width);return X[Math.floor(X.length/2)]}function dO($){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 N7($){return Z8[$]||"application/octet-stream"}function mO($){return MG[$]||$}function uO($){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 b1,$8,Z5,Z8,MG,PO;var T7=C(()=>{b1=[320,480,640,768,1024,1280,1536,1920,2560],$8=[1,1.5,2,3],Z5=["avif","webp","jpeg"],Z8={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},MG={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};PO={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 I7(){try{return await import("ts-images")}catch{return null}}async function Y8($,Z={}){let Y={...DG,...Z},X=await I7();if(X)try{return await EG($,Y,X)}catch(J){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${J}`)}return X8($,Y)}async function EG($,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 X8($,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 cO($){let Z=await I7();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await X8($,{strategy:"thumbhash",width:32,height:32})).dataURL}function lO($){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,q=(K>>3&63)/63,z=(K>>9&63)/63,U=K>>15!==0,W=Math.max(3,U?G?5:7:G?5:7),_=Math.max(3,U?G?5:7:G?5:7),B=32,j=32,O=Math.max(0,Math.min(255,Math.round((Y+X)*255))),L=Math.max(0,Math.min(255,Math.round(Y*255))),
|
|
1073
|
-
<rect fill="rgb(${O},${L},${
|
|
1070
|
+
`);for(let U=0;U<Q.length;U++)J=J.replace(`\x00CODEBLOCK${U}\x00`,Q[U]);return J=J.replace(/<p>\s*<\/p>/g,""),J.trim()}var TG={};p(TG,{processMarkdownDirectives:()=>F7,markdownDirectiveHandler:()=>V7});async function F7($,Z,Y=""){let X=$,J=[],Q=/@markdown(?:\([^)]*\))?/g,G;while((G=Q.exec($))!==null){let K=G.index,q=G[0].match(/@markdown\(([^)]*)\)/),z=q?q[1]:"",U=K+G[0].length,W=1,_=U,B=-1;while(W>0&&_<$.length){let L=$.indexOf("@markdown",_),V=$.indexOf("@endmarkdown",_);if(V===-1)break;if(L!==-1&&L<V&&L!==K){let H=$[L+9];if(H==="("||H===`
|
|
1071
|
+
`||H==="\r"||H===" "||H===void 0)W++;_=L+9}else{if(W--,W===0){B=V;break}_=V+12}}if(B===-1)continue;let j=$.slice(U,B),O=$.slice(K,B+12);J.push({fullMatch:O,options:z,content:j,index:K}),Q.lastIndex=B+12}for(let{fullMatch:K,options:q,content:z,index:U}of J)try{let W={};if(q)q.split(",").forEach((j)=>{let O=j.trim();if(O)W[O]=!0});let _={gfm:W.gfm??!0,breaks:W.breaks??!1},B=C5(z.trim(),_);X=X.split(K).join(B)}catch(W){let _=W instanceof Error?W.message:String(W),B=J0("Markdown Directive",`Error processing markdown: ${_}`,Y,$,U,K);X=X.split(K).join(B)}return X}async function V7($,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}),C5($.trim(),J)}var w7=C(()=>{w0()});function P5($,Z=b1,Y={},X){return Z.sort((J,Q)=>J-Q).map((J)=>{return`${_1($,{...Y,w:J,fm:X})} ${J}w`}).join(", ")}function bO($,Z=320,Y=2560,X=0.08,J={},Q){let G=IG(Z,Y,X);return P5($,G,J,Q)}function IG($,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 A7($,Z,Y=$8,X={},J){return Y.sort((Q,G)=>Q-G).map((Q)=>{let G=Math.round(Z*Q);return`${_1($,{...X,w:G,dpr:Q,fm:J})} ${Q}x`}).join(", ")}function yO($,Z,Y=$8,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,q)=>K-q).map((K)=>{let q=Math.round(Z*K),z=G[K]||Math.round(X*Math.max(0.5,1-K*0.1));return`${_1($,{...J,w:q,q:z,dpr:K,fm:Q})} ${K}x`}).join(", ")}function R7($,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 CO($,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 _1($,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 vO($){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 xO($){let{src:Z,widths:Y,dprValues:X,fixedWidth:J,formats:Q=Z5,baseUrl:G="",params:K={}}=$,q=[];for(let z of Q){let U,W;if(J!==void 0&&X)U=A7(Z,J,X,K,z),W=X.map((_)=>({path:"",url:_1(Z,{...K,w:Math.round(J*_),fm:z}),width:Math.round(J*_),height:0,format:z,size:0,dpr:_}));else{let _=Y||b1;U=P5(Z,_,K,z),W=_.map((B)=>({path:"",url:_1(Z,{...K,w:B,fm:z}),width:B,height:0,format:z,size:0}))}q.push({srcset:U,format:z,mimeType:Z8[z],variants:W})}return q}function fO($,Z="100vw"){return $.map(({srcset:Y,mimeType:X})=>`<source type="${X}" srcset="${Y}" sizes="${Z}" />`).join(`
|
|
1072
|
+
`)}function gO($,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 hO($,Z){let Y=Z?$.filter((J)=>J.format===Z):$;if(Y.length===0){let J=$.filter((G)=>G.format==="jpeg"),Q=J.length>0?J:$;return Q[Math.floor(Q.length/2)]}let X=Y.sort((J,Q)=>J.width-Q.width);return X[Math.floor(X.length/2)]}function dO($){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 N7($){return Z8[$]||"application/octet-stream"}function mO($){return MG[$]||$}function uO($){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 b1,$8,Z5,Z8,MG,PO;var T7=C(()=>{b1=[320,480,640,768,1024,1280,1536,1920,2560],$8=[1,1.5,2,3],Z5=["avif","webp","jpeg"],Z8={avif:"image/avif",webp:"image/webp",jpeg:"image/jpeg",png:"image/png",gif:"image/gif"},MG={avif:"avif",webp:"webp",jpeg:"jpg",png:"png",gif:"gif"};PO={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 I7(){try{return await import("ts-images")}catch{return null}}async function Y8($,Z={}){let Y={...DG,...Z},X=await I7();if(X)try{return await EG($,Y,X)}catch(J){console.warn(`[stx-media] ts-images placeholder generation failed, using fallback: ${J}`)}return X8($,Y)}async function EG($,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 X8($,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 cO($){let Z=await I7();if(Z)try{return(await Z.generateThumbHash($)).dataUrl}catch{}return(await X8($,{strategy:"thumbhash",width:32,height:32})).dataURL}function lO($){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,q=(K>>3&63)/63,z=(K>>9&63)/63,U=K>>15!==0,W=Math.max(3,U?G?5:7:G?5:7),_=Math.max(3,U?G?5:7:G?5:7),B=32,j=32,O=Math.max(0,Math.min(255,Math.round((Y+X)*255))),L=Math.max(0,Math.min(255,Math.round(Y*255))),V=Math.max(0,Math.min(255,Math.round((Y-X)*255))),H=`<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">
|
|
1073
|
+
<rect fill="rgb(${O},${L},${V})" width="32" height="32"/>
|
|
1074
1074
|
</svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(H)}`}async function iO($,Z=20,Y=50){return Y8($,{strategy:"blur",width:Z,quality:Y,blurLevel:40})}async function nO($){let Z=await I7();if(Z)try{return(await Z.generatePlaceholder($,{strategy:"dominant-color"})).dominantColor||"#e5e7eb"}catch{}return"#e5e7eb"}function oO($,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 J8($,Z,Y={}){let X=Y.transitionDuration||300,J=Y.easing||"ease-out";return`
|
|
1075
1075
|
#${$} {
|
|
1076
1076
|
--stx-img-transition-duration: ${X}ms;
|
|
@@ -1117,8 +1117,8 @@ ${O}
|
|
|
1117
1117
|
filter: blur(0);
|
|
1118
1118
|
transform: scale(1);
|
|
1119
1119
|
}
|
|
1120
|
-
`.trim();Y5=new Map});import{createHash as D7}from"crypto";import{readFile as kG,stat as q8}from"fs/promises";async function T0($){try{let Z=await kG($);return D7("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function ZL($){return D7("sha256").update($).digest("hex").slice(0,16)}function K8($){return D7("sha256").update($).digest("hex").slice(0,16)}function R$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${K8($)}-${K8(Y)}`}async function E7($){try{return(await q8($)).mtimeMs}catch{return 0}}async function R0($){try{return await q8($),!0}catch{return!1}}var y1=()=>{};import{mkdir as SG,readFile as U8,writeFile as bG,readdir as W8,rm as k7,stat as yG}from"fs/promises";import{join as X5,dirname as CG}from"path";async function PG($){try{await SG($,{recursive:!0})}catch{}}function _8($,Z,Y){return X5($,Y,`${Z}.json`)}async function z8($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await E7(Z)!==$.srcMtime)return!1;return!0}async function N$($,Z,Y,X=J5){if(!X.enabled)return null;let J=R$($,Z),Q=e0.get(J);if(Q){if(await z8(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;e0.delete(J)}let G=_8(X.directory,J,Y);if(await R0(G))try{let K=await U8(G,"utf-8"),q=JSON.parse(K);if(await z8(q,$,X.maxAge))return q.lastAccessedAt=Date.now(),e0.set(J,q),q.data}catch{}return null}async function T$($,Z,Y,X,J=J5){if(!J.enabled)return;let Q=R$($,Z),G=await T0($),K=await E7($),q={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:R$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};e0.set(Q,q);let z=_8(J.directory,Q,X);try{await PG(CG(z)),await bG(z,JSON.stringify(q,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function GL($,Z,Y=J5){for(let[X,J]of e0.entries())if(J.src===$)e0.delete(X)}async function M$($,Z=J5){if($==="all")e0.clear();else e0.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=X5(Z.directory,X);try{await k7(J,{recursive:!0,force:!0})}catch{}}}async function KL($=J5){let Z={memoryEntries:e0.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=X5($.directory,Y);try{let J=await W8(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=X5(X,Q),K=await yG(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function qL($=J5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=X5($.directory,X);try{let Q=await W8(J);for(let G of Q){let K=X5(J,G);try{let q=await U8(K,"utf-8"),z=JSON.parse(q);if(Date.now()-z.createdAt>Y)await k7(K),e0.delete(z.key),Z++}catch{await k7(K).catch(()=>{}),Z++}}}catch{}}return Z}var e0,J5;var S7=C(()=>{y1();e0=new Map,J5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class D${config;constructor($={}){this.config={...vG,...$}}async get($,Z){return N$($,Z,"image",this.config)}async set($,Z,Y){return T$($,Z,Y,"image",this.config)}async clear(){return M$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function b7($){if(!I$)I$=new D$($);else if($)I$.updateConfig($);return I$}async function E$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return b7(X).get($,Z)}async function k$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return b7(J).set($,Z,Y)}async function B8(){return b7().clear()}var vG,I$=null;var y7=C(()=>{S7();vG={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as xG,basename as fG,extname as gG,join as hG}from"path";import{mkdir as dG}from"fs/promises";async function C7(){try{return await import("ts-images")}catch{return null}}function j8($){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 mG($,Z){let Y=Z?j8(Z):j8("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 H8($,Z,Y){let X=await C7();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await E$($,Z,Y);if(J)return J;try{let Q=xG($);if(!await R0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=mG(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await dG(K,{recursive:!0});let z=await T0(Q),U=fG($,gG($)),W=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:z},B=null;if(Z.transformations&&Z.transformations.length>0)B=await P7(Q,Z.transformations,X);for(let j of W){let O=G[j]||{},L=`${U}-${z}.${j}`,F=hG(K,L);try{let H=await X.optimizeImage({input:B||Q,output:F,format:j,quality:O.quality,progressive:O.progressive});if(H){if(_.variants.push({path:F,url:`${q}/${L}`,width:H.width||0,height:H.height||0,format:j,size:H.outputSize||0}),!_.originalWidth&&H.width)_.originalWidth=H.width,_.originalHeight=H.height}}catch(H){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${H}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await k$($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function O8($,Z,Y,X){let J=await C7();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 P7($,Z,Y){let X=Y||await C7();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 L8=C(()=>{y1();y7()});import{resolve as uG,basename as pG,extname as cG,join as lG}from"path";import{mkdir as iG}from"fs/promises";async function nG(){try{return await import("ts-images")}catch{return null}}async function v7($,Z,Y){let X=await nG();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=uG($);if(!await R0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||oG,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await iG(K,{recursive:!0});let z=await T0(J),U=pG($,cG($)),W=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let O=[];for(let L of Q){let F=`${U}-${L}w-${z}.${j}`,H=lG(K,F),V=`${q}/${F}`;try{let A=W[j]?.quality||80;if(await R0(H)){_.byFormat[j].push({path:H,url:V,width:L,height:0,format:j,size:0}),O.push(`${V} ${L}w`);continue}let w=await X.processImage({input:J,output:H,format:j,quality:A,resize:{width:L}});if(w)_.byFormat[j].push({path:H,url:V,width:L,height:w.height||Math.round(L*(w.height||1)/(w.width||1)),format:j,size:w.outputSize||0}),O.push(`${V} ${L}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${A}`)}}_.srcsets[j]=O.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await X.generateThumbHash(J);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||sG(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function sG($){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 F8($,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(", ")}async function RL($,Z,Y){let X=[];for(let J of Z){let Q=await v7(J.src,{responsiveWidths:J.widths},Y);if(Q){for(let[G,K]of Object.entries(Q.srcsets))if(K)X.push({media:J.media,srcset:K,type:rG(G)})}}return X}function rG($){switch($){case"avif":return"image/avif";case"webp":return"image/webp";case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";default:return"image/jpeg"}}var oG;var V8=C(()=>{y1();oG=[320,480,640,768,1024,1280,1536,1920]});var w8={};p(w8,{setCachedImageResult:()=>k$,processImage:()=>H8,optimizeImage:()=>O8,getCachedImageResult:()=>E$,generateSrcset:()=>F8,generateResponsiveVariants:()=>v7,clearImageCache:()=>B8,applyTransformations:()=>P7,ImageProcessorCache:()=>D$});var A8=C(()=>{L8();V8();y7()});async function aG(){try{return await Promise.resolve().then(() => (A8(),w8))}catch($){if(!R8)console.warn("[stx-media] Image processor not available, some features disabled:",$),R8=!0;return null}}async function v5($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return YK(X,Y)}if(Y.processedResult?.processed)return h7($,Y.processedResult,Z);if(Y.responsiveVariants)return I8($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:q,widths:z=b1,dpr:U,formats:W=Z5,quality:_=x7,params:B={},placeholder:j="none",placeholderOptions:O={},lazy:L=!0,priority:F=!1,loading:H=F?"eager":b$,decoding:V=S$,fetchpriority:A,objectFit:w,objectPosition:R,crossorigin:N,referrerpolicy:M}=$,T=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:k=!1,baseUrl:S=""}=Z;if(k&&!Z.optimize)return $K($);let b,y,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{b=await Q8(J,{strategy:j,...O}),y=J8(d,b,O)}catch{}let f=U!==void 0&&G!==void 0,m;if(f)m=eG($,d,b,Z);else m=await tG($,d,b,Z);let o;if(F){let C0=W.includes("webp")?"webp":W[0],E0=P5(J,z,{...B,q:_},C0),X0=typeof q==="object"?R7(q):q||"100vw";o=`<link rel="preload" as="image" imagesrcset="${E0}" imagesizes="${X0}" />`}let N0=[];if(!N8&&j!=="none")N0.push(M7),N8=!0;if(y)N0.push(y);let X1=L?M8(d):void 0;return{html:m,preloadLink:o,css:N0.length>0?N0.join(`
|
|
1121
|
-
`):void 0,script:X1}}async function tG($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:q,widths:z=b1,formats:U=Z5,quality:W=x7,params:_={},lazy:B=!0,priority:j=!1,loading:O=j?"eager":b$,decoding:L=S$,fetchpriority:
|
|
1120
|
+
`.trim();Y5=new Map});import{createHash as D7}from"crypto";import{readFile as kG,stat as q8}from"fs/promises";async function T0($){try{let Z=await kG($);return D7("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function ZL($){return D7("sha256").update($).digest("hex").slice(0,16)}function K8($){return D7("sha256").update($).digest("hex").slice(0,16)}function R$($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${K8($)}-${K8(Y)}`}async function E7($){try{return(await q8($)).mtimeMs}catch{return 0}}async function R0($){try{return await q8($),!0}catch{return!1}}var y1=()=>{};import{mkdir as SG,readFile as U8,writeFile as bG,readdir as W8,rm as k7,stat as yG}from"fs/promises";import{join as X5,dirname as CG}from"path";async function PG($){try{await SG($,{recursive:!0})}catch{}}function _8($,Z,Y){return X5($,Y,`${Z}.json`)}async function z8($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await E7(Z)!==$.srcMtime)return!1;return!0}async function N$($,Z,Y,X=J5){if(!X.enabled)return null;let J=R$($,Z),Q=e0.get(J);if(Q){if(await z8(Q,$,X.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;e0.delete(J)}let G=_8(X.directory,J,Y);if(await R0(G))try{let K=await U8(G,"utf-8"),q=JSON.parse(K);if(await z8(q,$,X.maxAge))return q.lastAccessedAt=Date.now(),e0.set(J,q),q.data}catch{}return null}async function T$($,Z,Y,X,J=J5){if(!J.enabled)return;let Q=R$($,Z),G=await T0($),K=await E7($),q={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:R$("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};e0.set(Q,q);let z=_8(J.directory,Q,X);try{await PG(CG(z)),await bG(z,JSON.stringify(q,null,2))}catch(U){console.warn(`[stx-media] Failed to write cache: ${U}`)}}async function GL($,Z,Y=J5){for(let[X,J]of e0.entries())if(J.src===$)e0.delete(X)}async function M$($,Z=J5){if($==="all")e0.clear();else e0.clear();let Y=$==="all"?["image","video"]:[$];for(let X of Y){let J=X5(Z.directory,X);try{await k7(J,{recursive:!0,force:!0})}catch{}}}async function KL($=J5){let Z={memoryEntries:e0.size,diskEntries:{image:0,video:0},totalSizeMB:0};for(let Y of["image","video"]){let X=X5($.directory,Y);try{let J=await W8(X);Z.diskEntries[Y]=J.length;for(let Q of J){let G=X5(X,Q),K=await yG(G);Z.totalSizeMB+=K.size/1048576}}catch{}}return Z}async function qL($=J5){let Z=0,Y=$.maxAge*24*60*60*1000;for(let X of["image","video"]){let J=X5($.directory,X);try{let Q=await W8(J);for(let G of Q){let K=X5(J,G);try{let q=await U8(K,"utf-8"),z=JSON.parse(q);if(Date.now()-z.createdAt>Y)await k7(K),e0.delete(z.key),Z++}catch{await k7(K).catch(()=>{}),Z++}}}catch{}}return Z}var e0,J5;var S7=C(()=>{y1();e0=new Map,J5={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class D${config;constructor($={}){this.config={...vG,...$}}async get($,Z){return N$($,Z,"image",this.config)}async set($,Z,Y){return T$($,Z,Y,"image",this.config)}async clear(){return M$("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function b7($){if(!I$)I$=new D$($);else if($)I$.updateConfig($);return I$}async function E$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return b7(X).get($,Z)}async function k$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return b7(J).set($,Z,Y)}async function B8(){return b7().clear()}var vG,I$=null;var y7=C(()=>{S7();vG={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as xG,basename as fG,extname as gG,join as hG}from"path";import{mkdir as dG}from"fs/promises";async function C7(){try{return await import("ts-images")}catch{return null}}function j8($){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 mG($,Z){let Y=Z?j8(Z):j8("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 H8($,Z,Y){let X=await C7();if(!X)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let J=await E$($,Z,Y);if(J)return J;try{let Q=xG($);if(!await R0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=mG(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await dG(K,{recursive:!0});let z=await T0(Q),U=fG($,gG($)),W=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:z},B=null;if(Z.transformations&&Z.transformations.length>0)B=await P7(Q,Z.transformations,X);for(let j of W){let O=G[j]||{},L=`${U}-${z}.${j}`,V=hG(K,L);try{let H=await X.optimizeImage({input:B||Q,output:V,format:j,quality:O.quality,progressive:O.progressive});if(H){if(_.variants.push({path:V,url:`${q}/${L}`,width:H.width||0,height:H.height||0,format:j,size:H.outputSize||0}),!_.originalWidth&&H.width)_.originalWidth=H.width,_.originalHeight=H.height}}catch(H){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${H}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await X.generateThumbHash(Q);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await X.generatePlaceholder(Q,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await k$($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function O8($,Z,Y,X){let J=await C7();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 P7($,Z,Y){let X=Y||await C7();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 L8=C(()=>{y1();y7()});import{resolve as uG,basename as pG,extname as cG,join as lG}from"path";import{mkdir as iG}from"fs/promises";async function nG(){try{return await import("ts-images")}catch{return null}}async function v7($,Z,Y){let X=await nG();if(!X)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let J=uG($);if(!await R0(J))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||oG,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await iG(K,{recursive:!0});let z=await T0(J),U=pG($,cG($)),W=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let O=[];for(let L of Q){let V=`${U}-${L}w-${z}.${j}`,H=lG(K,V),F=`${q}/${V}`;try{let A=W[j]?.quality||80;if(await R0(H)){_.byFormat[j].push({path:H,url:F,width:L,height:0,format:j,size:0}),O.push(`${F} ${L}w`);continue}let w=await X.processImage({input:J,output:H,format:j,quality:A,resize:{width:L}});if(w)_.byFormat[j].push({path:H,url:F,width:L,height:w.height||Math.round(L*(w.height||1)/(w.width||1)),format:j,size:w.outputSize||0}),O.push(`${F} ${L}w`)}catch(A){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${A}`)}}_.srcsets[j]=O.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await X.generateThumbHash(J);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await X.generatePlaceholder(J,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||sG(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function sG($){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 F8($,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(", ")}async function RL($,Z,Y){let X=[];for(let J of Z){let Q=await v7(J.src,{responsiveWidths:J.widths},Y);if(Q){for(let[G,K]of Object.entries(Q.srcsets))if(K)X.push({media:J.media,srcset:K,type:rG(G)})}}return X}function rG($){switch($){case"avif":return"image/avif";case"webp":return"image/webp";case"jpeg":return"image/jpeg";case"png":return"image/png";case"gif":return"image/gif";default:return"image/jpeg"}}var oG;var V8=C(()=>{y1();oG=[320,480,640,768,1024,1280,1536,1920]});var w8={};p(w8,{setCachedImageResult:()=>k$,processImage:()=>H8,optimizeImage:()=>O8,getCachedImageResult:()=>E$,generateSrcset:()=>F8,generateResponsiveVariants:()=>v7,clearImageCache:()=>B8,applyTransformations:()=>P7,ImageProcessorCache:()=>D$});var A8=C(()=>{L8();V8();y7()});async function aG(){try{return await Promise.resolve().then(() => (A8(),w8))}catch($){if(!R8)console.warn("[stx-media] Image processor not available, some features disabled:",$),R8=!0;return null}}async function v5($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return YK(X,Y)}if(Y.processedResult?.processed)return h7($,Y.processedResult,Z);if(Y.responsiveVariants)return I8($,Y.responsiveVariants,Z);let{src:J,alt:Q,width:G,height:K,sizes:q,widths:z=b1,dpr:U,formats:W=Z5,quality:_=x7,params:B={},placeholder:j="none",placeholderOptions:O={},lazy:L=!0,priority:V=!1,loading:H=V?"eager":b$,decoding:F=S$,fetchpriority:A,objectFit:w,objectPosition:R,crossorigin:N,referrerpolicy:M}=$,T=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:k=!1,baseUrl:S=""}=Z;if(k&&!Z.optimize)return $K($);let b,y,d=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!V)try{b=await Q8(J,{strategy:j,...O}),y=J8(d,b,O)}catch{}let f=U!==void 0&&G!==void 0,m;if(f)m=eG($,d,b,Z);else m=await tG($,d,b,Z);let o;if(V){let C0=W.includes("webp")?"webp":W[0],E0=P5(J,z,{...B,q:_},C0),X0=typeof q==="object"?R7(q):q||"100vw";o=`<link rel="preload" as="image" imagesrcset="${E0}" imagesizes="${X0}" />`}let N0=[];if(!N8&&j!=="none")N0.push(M7),N8=!0;if(y)N0.push(y);let X1=L?M8(d):void 0;return{html:m,preloadLink:o,css:N0.length>0?N0.join(`
|
|
1121
|
+
`):void 0,script:X1}}async function tG($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,sizes:q,widths:z=b1,formats:U=Z5,quality:W=x7,params:_={},lazy:B=!0,priority:j=!1,loading:O=j?"eager":b$,decoding:L=S$,fetchpriority:V,objectFit:H,objectPosition:F,crossorigin:A,referrerpolicy:w}=$,R=$.class,N=$.style,M=$.data||{},T=typeof q==="object"?R7(q):q||"100vw",I=[];for(let k of U){let S=P5(J,z,{..._,q:W},k),b=N7(k);if(B&&!j)I.push(` <source type="${b}" data-srcset="${S}" data-sizes="${T}" />`);else I.push(` <source type="${b}" srcset="${S}" sizes="${T}" />`)}let D=f7({src:_1(J,{..._,q:W}),alt:Q,width:G,height:K,loading:j?void 0:O,decoding:L,fetchpriority:j?"high":V,objectFit:H,objectPosition:F,crossorigin:A,referrerpolicy:w,className:T8(R,Y),style:g7(N,H,F,Y),lazy:B&&!j,data:M}),E;if(Y){let k=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${k}">
|
|
1122
1122
|
<picture>
|
|
1123
1123
|
${I.join(`
|
|
1124
1124
|
`)}
|
|
@@ -1128,7 +1128,7 @@ ${I.join(`
|
|
|
1128
1128
|
${I.join(`
|
|
1129
1129
|
`)}
|
|
1130
1130
|
<img ${D} />
|
|
1131
|
-
</picture>`;return E}function eG($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:q=[1,2,3],quality:z=x7,params:U={},lazy:W=!0,priority:_=!1,loading:B=_?"eager":b$,decoding:j=S$,fetchpriority:O,objectFit:L,objectPosition:
|
|
1131
|
+
</picture>`;return E}function eG($,Z,Y,X){let{src:J,alt:Q,width:G,height:K,dpr:q=[1,2,3],quality:z=x7,params:U={},lazy:W=!0,priority:_=!1,loading:B=_?"eager":b$,decoding:j=S$,fetchpriority:O,objectFit:L,objectPosition:V,crossorigin:H,referrerpolicy:F}=$,A=$.class,w=$.style,R=$.data||{},N=typeof G==="number"?G:Number.parseInt(String(G),10),M=A7(J,N,q,{...U,q:z}),T=f7({src:_1(J,{...U,w:N,q:z}),alt:Q,width:G,height:K,loading:_?void 0:B,decoding:j,fetchpriority:_?"high":O,objectFit:L,objectPosition:V,crossorigin:H,referrerpolicy:F,className:T8(A,Y),style:g7(w,L,V,Y),lazy:W&&!_,data:R}),I=W&&!_?`data-srcset="${M}"`:`srcset="${M}"`;if(Y){let D=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;return`<div id="${Z}" class="stx-img-placeholder" style="${D}">
|
|
1132
1132
|
<img ${T} ${I} />
|
|
1133
1133
|
</div>`}return`<img ${Z?`id="${Z}" `:""}${T} ${I} />`}function $K($){let{src:Z,alt:Y,width:X,height:J,loading:Q=b$,decoding:G=S$,fetchpriority:K,objectFit:q,objectPosition:z,crossorigin:U,referrerpolicy:W,priority:_=!1}=$,B=$.class,j=$.style,O=$.id,L=$.data||{};return{html:`<img ${f7({src:Z,alt:Y,width:X,height:J,loading:_?"eager":Q,decoding:G,fetchpriority:_?"high":K,objectFit:q,objectPosition:z,crossorigin:U,referrerpolicy:W,className:B,style:g7(j,q,z),id:O,data:L})} />`}}function f7($){let Z=[];if($.lazy)Z.push(`data-src="${u0($.src)}"`),Z.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"');else Z.push(`src="${u0($.src)}"`);if(Z.push(`alt="${u0($.alt)}"`),$.width)Z.push(`width="${$.width}"`);if($.height)Z.push(`height="${$.height}"`);if($.loading)Z.push(`loading="${$.loading}"`);if($.decoding)Z.push(`decoding="${$.decoding}"`);if($.fetchpriority)Z.push(`fetchpriority="${$.fetchpriority}"`);if($.crossorigin)Z.push(`crossorigin="${$.crossorigin}"`);if($.referrerpolicy)Z.push(`referrerpolicy="${$.referrerpolicy}"`);if($.className)Z.push(`class="${u0($.className)}"`);if($.style)Z.push(`style="${u0($.style)}"`);if($.id)Z.push(`id="${u0($.id)}"`);if($.data)for(let[Y,X]of Object.entries($.data))Z.push(`data-${Y}="${u0(X)}"`);if($.lazy)Z.push("data-stx-lazy");return Z.join(" ")}function T8($,Z){let Y=[];if($)Y.push($);if(Z)Y.push("stx-img-blur");return Y.join(" ")||""}function g7($,Z,Y,X){let J=[];if(Z)J.push(`object-fit: ${Z}`);if(Y)J.push(`object-position: ${Y}`);if(X)J.push("opacity: 0; transition: opacity 300ms ease-out");if($)J.push($);return J.join("; ")}function u0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">")}function M8($){return`
|
|
1134
1134
|
(function() {
|
|
@@ -1167,7 +1167,7 @@ ${I.join(`
|
|
|
1167
1167
|
|
|
1168
1168
|
observer.observe(container);
|
|
1169
1169
|
})();
|
|
1170
|
-
`.trim()}function ZK($){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,q,z,U]=Q,W=q??z??U??!0;if(G===":"&&typeof W==="string")try{X[K]=JSON.parse(W)}catch{X[K]=W}else switch(K){case"src":X.src=String(W);break;case"alt":X.alt=String(W);break;case"width":X.width=Number(W)||W;break;case"height":X.height=Number(W)||W;break;case"sizes":X.sizes=String(W);break;case"quality":X.quality=Number(W);break;case"placeholder":X.placeholder=W;break;case"lazy":X.lazy=W===!0||W==="true";break;case"priority":X.priority=W===!0||W==="true";break;case"class":X.class=String(W);break;case"style":X.style=String(W);break;case"id":X.id=String(W);break;case"loading":X.loading=W;break;case"decoding":X.decoding=W;break;case"fetchpriority":X.fetchpriority=W;break;case"objectFit":X.objectFit=W;break;case"objectPosition":X.objectPosition=String(W);break;case"crossorigin":X.crossorigin=W;break}}if(!X.src||!X.alt)return null;return X}async function kL($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],q;while((q=Y.exec($))!==null)K.push({match:q[0],index:q.index});for(let z=K.length-1;z>=0;z--){let{match:U}=K[z],W=ZK(U);if(W){let _=await v5(W,Z);if(G=G.replace(U,_.html),_.preloadLink)X.push(_.preloadLink);if(_.css)J.push(_.css);if(_.script)Q.push(_.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function YK($,Z){let Y=await aG();if(!Y)return v5({...$,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 I8($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return h7($,Q,Z)}return v5({...$,process:!1},Z)}async function h7($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:q,objectPosition:z,crossorigin:U,referrerpolicy:W}=$,_=$.class,B=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,O=$.data||{},L=Z.variants||[],
|
|
1170
|
+
`.trim()}function ZK($){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,q,z,U]=Q,W=q??z??U??!0;if(G===":"&&typeof W==="string")try{X[K]=JSON.parse(W)}catch{X[K]=W}else switch(K){case"src":X.src=String(W);break;case"alt":X.alt=String(W);break;case"width":X.width=Number(W)||W;break;case"height":X.height=Number(W)||W;break;case"sizes":X.sizes=String(W);break;case"quality":X.quality=Number(W);break;case"placeholder":X.placeholder=W;break;case"lazy":X.lazy=W===!0||W==="true";break;case"priority":X.priority=W===!0||W==="true";break;case"class":X.class=String(W);break;case"style":X.style=String(W);break;case"id":X.id=String(W);break;case"loading":X.loading=W;break;case"decoding":X.decoding=W;break;case"fetchpriority":X.fetchpriority=W;break;case"objectFit":X.objectFit=W;break;case"objectPosition":X.objectPosition=String(W);break;case"crossorigin":X.crossorigin=W;break}}if(!X.src||!X.alt)return null;return X}async function kL($,Z={}){let Y=/<Img\s+[^>]*?\/?>/g,X=[],J=[],Q=[],G=$,K=[],q;while((q=Y.exec($))!==null)K.push({match:q[0],index:q.index});for(let z=K.length-1;z>=0;z--){let{match:U}=K[z],W=ZK(U);if(W){let _=await v5(W,Z);if(G=G.replace(U,_.html),_.preloadLink)X.push(_.preloadLink);if(_.css)J.push(_.css);if(_.script)Q.push(_.script)}}return{html:G,preloadLinks:X,styles:J,scripts:Q}}async function YK($,Z){let Y=await aG();if(!Y)return v5({...$,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 I8($,Q,Z)}else{let Q=await Y.processImage($.src,$,X);if(Q.processed)return h7($,Q,Z)}return v5({...$,process:!1},Z)}async function h7($,Z,Y){let{alt:X,width:J,height:Q,lazy:G=!0,priority:K=!1,objectFit:q,objectPosition:z,crossorigin:U,referrerpolicy:W}=$,_=$.class,B=$.style,j=$.id||`stx-img-${Math.random().toString(36).slice(2,8)}`,O=$.data||{},L=Z.variants||[],V=L.find((y)=>y.format==="jpeg")||L.find((y)=>y.format==="webp")||L[0],H=V?.url||$.src,F=L.filter((y)=>y.format===(V?.format||"jpeg")).map((y)=>`${y.url} ${y.width}w`).join(", "),A=new Map;for(let y of L){if(!A.has(y.format))A.set(y.format,[]);A.get(y.format).push(y)}let w=[],R=["avif","webp","jpeg","png"];for(let y of R){let d=A.get(y);if(d&&d.length>0){let f=d.map((o)=>`${o.url} ${o.width}w`).join(", "),m=N7(y);if(G&&!K)w.push(` <source type="${m}" data-srcset="${f}" />`);else w.push(` <source type="${m}" srcset="${f}" />`)}}let N=[];if(G&&!K){if(N.push(`data-src="${u0(H)}"`),N.push('src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"'),F)N.push(`data-srcset="${F}"`)}else if(N.push(`src="${u0(H)}"`),F)N.push(`srcset="${F}"`);N.push(`alt="${u0(X)}"`);let M=J||Z.originalWidth,T=Q||Z.originalHeight;if(M)N.push(`width="${M}"`);if(T)N.push(`height="${T}"`);if(!K)N.push(`loading="${G?"lazy":"eager"}"`);if(N.push('decoding="async"'),K)N.push('fetchpriority="high"');if(U)N.push(`crossorigin="${U}"`);if(W)N.push(`referrerpolicy="${W}"`);let I=[];if(q)I.push(`object-fit: ${q}`);if(z)I.push(`object-position: ${z}`);if(Z.placeholder&&G)I.push("opacity: 0; transition: opacity 300ms ease-out");if(B)I.push(B);if(I.length>0)N.push(`style="${I.join("; ")}"`);let D=[];if(_)D.push(_);if(Z.placeholder)D.push("stx-img-blur");if(D.length>0)N.push(`class="${D.join(" ")}"`);if(G&&!K)N.push("data-stx-lazy");for(let[y,d]of Object.entries(O))N.push(`data-${y}="${u0(d)}"`);let E;if(Z.placeholder||Z.dominantColor&&$.useDominantColor){let y=Z.placeholder?`background-image: url('${Z.placeholder}'); background-size: cover; background-position: center;`:`background-color: ${Z.dominantColor};`;E=`<div id="${j}" class="stx-img-placeholder" style="${y}">
|
|
1171
1171
|
<picture>
|
|
1172
1172
|
${w.join(`
|
|
1173
1173
|
`)}
|
|
@@ -1177,12 +1177,12 @@ ${w.join(`
|
|
|
1177
1177
|
${w.join(`
|
|
1178
1178
|
`)}
|
|
1179
1179
|
<img ${N.join(" ")} />
|
|
1180
|
-
</picture>`;let k=[];if(Z.placeholder)k.push(M7);let S=G?M8(j):void 0,b;if(K&&
|
|
1180
|
+
</picture>`;let k=[];if(Z.placeholder)k.push(M7);let S=G?M8(j):void 0,b;if(K&&F)b=`<link rel="preload" as="image" imagesrcset="${F}" />`;return{html:E,preloadLink:b,css:k.length>0?k.join(`
|
|
1181
1181
|
`):void 0,script:S}}async function I8($,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 h7($,X,Y)}var R8=!1,x7=80,S$="async",b$="lazy",N8=!1;var D8=C(()=>{T7();G8()});function XK(){return j0({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}=JK($,Z,Y);if(!J)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:J,alt:Q||"",widths:G.widths||b1,formats:G.formats||Z5,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},q=Y.__isDev||!1,z=await v5(K,{isDev:q}),U=z.html;if(z.preloadLink)U=z.preloadLink+`
|
|
1182
1182
|
`+U;if(z.css)U+=`
|
|
1183
1183
|
<style>${z.css}</style>`;if(z.script)U+=`
|
|
1184
|
-
<script>${z.script}</script>`;return U},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function JK($,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=QK(X),Q=d7(J[0],Y)||"",G=d7(J[1],Y)||"",K={};if(J[2]){let q=d7(J[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function QK($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],z=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&z!=="\\"){if(!X)X=!0,J=q;else if(q===J)X=!1,J="";else Y+=q;continue}if(!X){if(q==="{")Q++;if(q==="}")Q--;if(q==="[")G++;if(q==="]")G--;if(q===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function d7($,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 E8;var k8=C(()=>{_7();D8();T7();E8=XK()});class C${config;constructor($={}){this.config={...GK,...$}}async get($,Z){return N$($,Z,"video",this.config)}async set($,Z,Y){return T$($,Z,Y,"video",this.config)}async clear(){return M$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function m7($){if(!y$)y$=new C$($);else if($)y$.updateConfig($);return y$}async function P$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return m7(X).get($,Z)}async function v$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return m7(J).set($,Z,Y)}async function S8(){return m7().clear()}var GK,y$=null;var u7=C(()=>{S7();GK={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as p7,basename as c7,extname as l7,join as x$}from"path";import{mkdir as i7}from"fs/promises";async function n7(){try{return await import("ts-videos")}catch{return null}}async function f$($,Z,Y,X){let J=await n7();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=p7($);if(!await R0(Q))return null;await i7(Y,{recursive:!0});let G=await T0(Q),K=c7($,l7($)),q=Z.format||"webp",z=Z.timestamp||0,U=`${K}-poster-${G}.${q}`,W=x$(Y,U),_=await J.extractThumbnails(Q,{timestamps:[z],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:U.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:W,url:`${X}/${U}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:z,size:B.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function g$($,Z,Y,X){let J=await n7();if(!J)return[];try{let Q=p7($);if(!await R0(Q))return[];await i7(Y,{recursive:!0});let G=await T0(Q),K=c7($,l7($)),q=Z.format||"webp",W=(await new J.Input(Q).getInfo()).duration||60,_=Z.count||10,B=Z.interval||W/_,j=[];for(let L=0;L<_&&L*B<W;L++)j.push(L*B);let O=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(O&&O.length>0)return O.map((L,
|
|
1185
|
-
`)}async function m$($,Z,Y,X,J){let Q=await f8();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=C8($);if(!await R0(G))return null;let K=await T0(G),q=P8($,v8($)),z=C1(Y,`${q}-${K}-dash`);await h$(z,{recursive:!0});let U=Z.length>0?Z:g8,W=J?.segmentDuration||4,_=J?.minBufferTime||2,O=(await new Q.Input(G).getInfo()).duration||0,L=[],
|
|
1184
|
+
<script>${z.script}</script>`;return U},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function JK($,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=QK(X),Q=d7(J[0],Y)||"",G=d7(J[1],Y)||"",K={};if(J[2]){let q=d7(J[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof J[2]==="string")try{K=JSON.parse(J[2])}catch{}}return{src:Q,alt:G,options:K}}function QK($){let Z=[],Y="",X=!1,J="",Q=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],z=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&z!=="\\"){if(!X)X=!0,J=q;else if(q===J)X=!1,J="";else Y+=q;continue}if(!X){if(q==="{")Q++;if(q==="}")Q--;if(q==="[")G++;if(q==="]")G--;if(q===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function d7($,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 E8;var k8=C(()=>{_7();D8();T7();E8=XK()});class C${config;constructor($={}){this.config={...GK,...$}}async get($,Z){return N$($,Z,"video",this.config)}async set($,Z,Y){return T$($,Z,Y,"video",this.config)}async clear(){return M$("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function m7($){if(!y$)y$=new C$($);else if($)y$.updateConfig($);return y$}async function P$($,Z,Y){let X=Y?{directory:`${Y.outputDir}/../.cache`}:{};return m7(X).get($,Z)}async function v$($,Z,Y,X){let J=X?{directory:`${X.outputDir}/../.cache`}:{};return m7(J).set($,Z,Y)}async function S8(){return m7().clear()}var GK,y$=null;var u7=C(()=>{S7();GK={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as p7,basename as c7,extname as l7,join as x$}from"path";import{mkdir as i7}from"fs/promises";async function n7(){try{return await import("ts-videos")}catch{return null}}async function f$($,Z,Y,X){let J=await n7();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=p7($);if(!await R0(Q))return null;await i7(Y,{recursive:!0});let G=await T0(Q),K=c7($,l7($)),q=Z.format||"webp",z=Z.timestamp||0,U=`${K}-poster-${G}.${q}`,W=x$(Y,U),_=await J.extractThumbnails(Q,{timestamps:[z],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:U.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:W,url:`${X}/${U}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:z,size:B.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function g$($,Z,Y,X){let J=await n7();if(!J)return[];try{let Q=p7($);if(!await R0(Q))return[];await i7(Y,{recursive:!0});let G=await T0(Q),K=c7($,l7($)),q=Z.format||"webp",W=(await new J.Input(Q).getInfo()).duration||60,_=Z.count||10,B=Z.interval||W/_,j=[];for(let L=0;L<_&&L*B<W;L++)j.push(L*B);let O=await J.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(O&&O.length>0)return O.map((L,V)=>({path:L.path||x$(Y,`${K}-thumb-${G}-${V}.${q}`),url:`${X}/${K}-thumb-${G}-${V}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[V],size:L.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function b8($,Z,Y,X){let J=await n7();if(!J)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=p7($);if(!await R0(Q))return null;await i7(Y,{recursive:!0});let G=await T0(Q),K=c7($,l7($)),U=(await new J.Input(Q).getInfo()).duration||60,W=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,O=Z.format||"jpeg",L=Math.ceil(U/_),V=Math.ceil(L/W),H=`${K}-sprite-${G}.${O}`,F=x$(Y,H),A=[];for(let R=0;R<L;R++)A.push(R*_);let w=await J.extractThumbnails(Q,{timestamps:A,width:B,height:j,format:O,quality:Z.quality||70,outputDir:x$(Y,".temp")});if(!w||w.length===0)return null;try{let R=await import("ts-images"),N=W*B,M=V*j,T=await R.createSprite({images:w.map((I)=>I.path),columns:W,padding:0,outputPath:F,format:O,quality:Z.quality||70});return{url:`${X}/${H}`,path:F,columns:W,rows:V,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var o7=C(()=>{y1()});import{resolve as C8,basename as P8,extname as v8,join as C1}from"path";import{mkdir as h$,writeFile as x8}from"fs/promises";async function f8(){try{return await import("ts-videos")}catch{return null}}async function d$($,Z,Y,X,J){let Q=await f8();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=C8($);if(!await R0(G))return null;let K=await T0(G),q=P8($,v8($)),z=C1(Y,`${q}-${K}-hls`);await h$(z,{recursive:!0});let U=Z.length>0?Z:g8,W=J?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,O=[],L=0;for(let F of U){let A=C1(z,F.label);await h$(A,{recursive:!0});let w=`${F.label}.m3u8`,R=C1(A,w);try{let N=await Q.generateHLS(G,{outputDir:A,segmentDuration:W,width:F.width,height:F.height,videoBitrate:F.bitrate,audioBitrate:F.audioBitrate,playlistName:F.label});if(N)O.push({quality:F,url:`${X}/${q}-${K}-hls/${F.label}/${w}`,path:R}),L+=N.segmentCount||Math.ceil(j/W)}catch(N){console.warn(`[stx-media] Failed to generate HLS for ${F.label}: ${N}`)}}if(O.length===0)return null;let V=C1(z,"master.m3u8"),H=KK(O,X,q,K);return await x8(V,H),{manifestUrl:`${X}/${q}-${K}-hls/master.m3u8`,manifestPath:V,playlists:O,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function KK($,Z,Y,X){let J=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;J.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return J.join(`
|
|
1185
|
+
`)}async function m$($,Z,Y,X,J){let Q=await f8();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=C8($);if(!await R0(G))return null;let K=await T0(G),q=P8($,v8($)),z=C1(Y,`${q}-${K}-dash`);await h$(z,{recursive:!0});let U=Z.length>0?Z:g8,W=J?.segmentDuration||4,_=J?.minBufferTime||2,O=(await new Q.Input(G).getInfo()).duration||0,L=[],V=[];for(let w of U){let R=C1(z,w.label);await h$(R,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:R,segmentDuration:W,width:w.width,height:w.height,videoBitrate:w.bitrate,audioBitrate:w.audioBitrate})){if(L.push({bandwidth:w.bitrate,width:w.width,height:w.height||Math.round(w.width*9/16),url:`${X}/${q}-${K}-dash/${w.label}/video`}),w.audioBitrate)V.push({bandwidth:w.audioBitrate,url:`${X}/${q}-${K}-dash/${w.label}/audio`})}}catch(N){console.warn(`[stx-media] Failed to generate DASH for ${w.label}: ${N}`)}}if(L.length===0)return null;let H=C1(z,"manifest.mpd"),F=qK(L,V,O,W,_);await x8(H,F);let A=[{type:"video",representations:L}];if(V.length>0)A.push({type:"audio",representations:V});return{manifestUrl:`${X}/${q}-${K}-dash/manifest.mpd`,manifestPath:H,adaptationSets:A,duration:O}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function qK($,Z,Y,X,J){let Q=y8(Y),G=y8(J),K=`<?xml version="1.0" encoding="UTF-8"?>
|
|
1186
1186
|
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
|
|
1187
1187
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
1188
1188
|
xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
|
|
@@ -1208,7 +1208,7 @@ ${w.join(`
|
|
|
1208
1208
|
</Representation>
|
|
1209
1209
|
`}K+=` </AdaptationSet>
|
|
1210
1210
|
`}return K+=` </Period>
|
|
1211
|
-
</MPD>`,K}function y8($){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 g8;var s7=C(()=>{y1();g8=[{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 h8,basename as zK,extname as UK,join as WK}from"path";import{mkdir as _K}from"fs/promises";async function d8(){try{return await import("ts-videos")}catch{return null}}function BK($){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 r7($){let Z=await d8();if(!Z)return null;try{let Y=h8($),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 m8($,Z,Y,X){let J=await d8();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await P$($,Z,Y);if(Q)return Q;try{let G=h8($);if(!await R0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await _K(K,{recursive:!0});let z=await T0(G),U=zK($,UK($)),W={src:$,processed:!0,hash:z};X?.({percentage:5,stage:"analyzing"}),W.metadata=await r7(G)||void 0;let _={};if(Z.quality)_.bitrate=BK(Z.quality);if(Z.platform)Object.assign(_,jK(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let B=`${U}-${z}.mp4`,j=WK(K,B);try{let O=await HK(G,j,_,J,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(O)W.transcoded={path:j,url:`${q}/${B}`,duration:O.duration,size:O.size,video:{codec:_.codec||"h264",width:O.width,height:O.height,bitrate:O.bitrate,frameRate:O.frameRate},audio:O.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(O){W.errors=W.errors||[],W.errors.push(`Transcoding failed: ${O}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await f$(G,B,K,q);if(j)W.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let B=await g$(G,Y.thumbnails,K,q);if(B.length>0)W.thumbnails=B}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await d$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,hls:j}}if(B.format==="dash"){let j=await m$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await v$($,Z,W,Y),W}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function HK($,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 u8=C(()=>{y1();u7();o7();s7()});var p8={};p(p8,{setCachedVideoResult:()=>v$,processVideo:()=>m8,getCachedVideoResult:()=>P$,generateThumbnails:()=>g$,generateSpriteSheet:()=>b8,generatePoster:()=>f$,generateHLSManifest:()=>d$,generateDASHManifest:()=>m$,clearVideoCache:()=>S8,analyzeVideo:()=>r7,VideoProcessorCache:()=>C$});var c8=C(()=>{u8();o7();s7();u7()});async function i8(){try{return await Promise.resolve().then(() => (c8(),p8))}catch($){if(!l8)console.warn("[stx-media] Video processor not available, some features disabled:",$),l8=!0;return null}}async function u$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return AK(X,Y)}if(Y.processedResult?.processed)return r8($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await RK(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:q,controls:z=n8,autoplay:U=!1,muted:W=!1,loop:_=!1,preload:B=o8,playsinline:j=!0,lazy:O=!0,player:L="native",type:
|
|
1211
|
+
</MPD>`,K}function y8($){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 g8;var s7=C(()=>{y1();g8=[{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 h8,basename as zK,extname as UK,join as WK}from"path";import{mkdir as _K}from"fs/promises";async function d8(){try{return await import("ts-videos")}catch{return null}}function BK($){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 r7($){let Z=await d8();if(!Z)return null;try{let Y=h8($),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 m8($,Z,Y,X){let J=await d8();if(!J)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await P$($,Z,Y);if(Q)return Q;try{let G=h8($);if(!await R0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await _K(K,{recursive:!0});let z=await T0(G),U=zK($,UK($)),W={src:$,processed:!0,hash:z};X?.({percentage:5,stage:"analyzing"}),W.metadata=await r7(G)||void 0;let _={};if(Z.quality)_.bitrate=BK(Z.quality);if(Z.platform)Object.assign(_,jK(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){X?.({percentage:10,stage:"transcoding"});let B=`${U}-${z}.mp4`,j=WK(K,B);try{let O=await HK(G,j,_,J,(L)=>X?.({percentage:10+L*0.5,stage:"transcoding"}));if(O)W.transcoded={path:j,url:`${q}/${B}`,duration:O.duration,size:O.size,video:{codec:_.codec||"h264",width:O.width,height:O.height,bitrate:O.bitrate,frameRate:O.frameRate},audio:O.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(O){W.errors=W.errors||[],W.errors.push(`Transcoding failed: ${O}`)}}if(Z.generatePoster){X?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await f$(G,B,K,q);if(j)W.poster=j}if(Y.thumbnails?.enabled){X?.({percentage:70,stage:"generating-thumbnails"});let B=await g$(G,Y.thumbnails,K,q);if(B.length>0)W.thumbnails=B}if(Z.streaming){X?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await d$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,hls:j}}if(B.format==="dash"){let j=await m$(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)W.streaming={...W.streaming,dash:j}}}if(Z.spriteSheet)X?.({percentage:90,stage:"generating-sprite-sheet"});return X?.({percentage:100,stage:"complete"}),await v$($,Z,W,Y),W}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function HK($,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 u8=C(()=>{y1();u7();o7();s7()});var p8={};p(p8,{setCachedVideoResult:()=>v$,processVideo:()=>m8,getCachedVideoResult:()=>P$,generateThumbnails:()=>g$,generateSpriteSheet:()=>b8,generatePoster:()=>f$,generateHLSManifest:()=>d$,generateDASHManifest:()=>m$,clearVideoCache:()=>S8,analyzeVideo:()=>r7,VideoProcessorCache:()=>C$});var c8=C(()=>{u8();o7();s7();u7()});async function i8(){try{return await Promise.resolve().then(() => (c8(),p8))}catch($){if(!l8)console.warn("[stx-media] Video processor not available, some features disabled:",$),l8=!0;return null}}async function u$($,Z={}){let Y=Z,X=$;if(X.process&&!X.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return AK(X,Y)}if(Y.processedResult?.processed)return r8($,Y.processedResult,Z);let J;if(X.generatePoster&&X.src&&!$.poster)J=await RK(X,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:q,controls:z=n8,autoplay:U=!1,muted:W=!1,loop:_=!1,preload:B=o8,playsinline:j=!0,lazy:O=!0,player:L="native",type:V,width:H,height:F,crossorigin:A,disablePictureInPicture:w=!1,disableRemotePlayback:R=!1}=$,N=J||K,M=$.class,T=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return FK($,Z);if(V&&V!=="video")return LK(Q||"",V,$);let D=G.length>0?G:Q?[{src:Q,type:s8(Q)}]:[],E=[`id="${I}"`];if(z)E.push("controls");if(U)E.push("autoplay");if(W)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(w)E.push("disablepictureinpicture");if(R)E.push("disableremoteplayback");if(A)E.push(`crossorigin="${A}"`);if(O){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),N)E.push(`data-poster="${O0(N)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),N)E.push(`poster="${O0(N)}"`);if(H)E.push(`width="${H}"`);if(F)E.push(`height="${F}"`);if(M)E.push(`class="${O0(M)}"`);if(T)E.push(`style="${O0(T)}"`);let k=D.map((y)=>{return` <source ${O?`data-src="${O0(y.src)}"`:`src="${O0(y.src)}"`} type="${y.type}"${y.media?` media="${y.media}"`:""} />`}).join(`
|
|
1212
1212
|
`),S=`<video ${E.join(" ")}>
|
|
1213
1213
|
${k}
|
|
1214
1214
|
Your browser does not support the video tag.
|
|
@@ -1249,13 +1249,13 @@ ${k}
|
|
|
1249
1249
|
})();
|
|
1250
1250
|
`.trim();return{html:S,script:b}}function LK($,Z,Y){let{width:X=640,height:J=360}=Y,Q=Y.class,G=Y.style,K=Y.id||`stx-embed-${Math.random().toString(36).slice(2,8)}`,q,z=null;switch(Z){case"youtube":z=VK($),q=z?`https://www.youtube-nocookie.com/embed/${z}`:$;break;case"vimeo":z=wK($),q=z?`https://player.vimeo.com/video/${z}`:$;break;case"dailymotion":z=$.split("/").pop()||"",q=`https://www.dailymotion.com/embed/video/${z}`;break;case"twitch":z=$.split("/").pop()||"",q=`https://player.twitch.tv/?video=${z}&parent=${typeof window<"u"?window.location.hostname:"localhost"}`;break;default:q=$}let U=[`id="${K}"`,`src="${O0(q)}"`,`width="${X}"`,`height="${J}"`,'frameborder="0"',"allowfullscreen",'allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"'];if(Q)U.push(`class="${O0(Q)}"`);if(G)U.push(`style="${O0(G)}"`);if(Y.lazy)U.push('loading="lazy"');return{html:`<div class="stx-video-embed" style="position:relative;padding-bottom:56.25%;height:0;overflow:hidden;">
|
|
1251
1251
|
<iframe ${U.join(" ")} style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
|
|
1252
|
-
</div>`}}function FK($,Z={}){let{src:Y,sources:X=[],poster:J,controls:Q=!0,autoplay:G=!1,muted:K=!1,loop:q=!1,preload:z="metadata",playsinline:U=!0,lazy:W=!0,width:_,height:B}=$,j=$.class,O=$.style,L=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,
|
|
1252
|
+
</div>`}}function FK($,Z={}){let{src:Y,sources:X=[],poster:J,controls:Q=!0,autoplay:G=!1,muted:K=!1,loop:q=!1,preload:z="metadata",playsinline:U=!0,lazy:W=!0,width:_,height:B}=$,j=$.class,O=$.style,L=$.id||`ts-video-${Math.random().toString(36).slice(2,8)}`,V={src:X.length>0?X:Y,autoplay:G,loop:q,muted:K,playsinline:U,preload:z,poster:J,controls:Q,title:$.title},H=["position: relative",_?`width: ${typeof _==="number"?_+"px":_}`:"width: 100%",B?`height: ${typeof B==="number"?B+"px":B}`:"",O||""].filter(Boolean).join("; "),F=`
|
|
1253
1253
|
<div
|
|
1254
1254
|
id="${L}"
|
|
1255
1255
|
class="ts-video-player${j?" "+O0(j):""}"
|
|
1256
1256
|
style="${H}"
|
|
1257
1257
|
data-ts-video-player
|
|
1258
|
-
data-config='${JSON.stringify(
|
|
1258
|
+
data-config='${JSON.stringify(V)}'
|
|
1259
1259
|
${W?"data-lazy":""}
|
|
1260
1260
|
>
|
|
1261
1261
|
<div class="ts-video-player__container">
|
|
@@ -1416,14 +1416,14 @@ else {
|
|
|
1416
1416
|
.ts-video-player__play-button svg {
|
|
1417
1417
|
margin-left: 4px;
|
|
1418
1418
|
}
|
|
1419
|
-
`.trim();return{html:
|
|
1419
|
+
`.trim();return{html:F,script:A,css:w}}function s8($){switch($.split(".").pop()?.toLowerCase()){case"mp4":return"video/mp4";case"webm":return"video/webm";case"ogg":case"ogv":return"video/ogg";case"mov":return"video/quicktime";case"avi":return"video/x-msvideo";case"mkv":return"video/x-matroska";case"m3u8":return"application/x-mpegURL";default:return"video/mp4"}}function VK($){let Z=[/youtube\.com\/watch\?v=([^&]+)/,/youtube\.com\/embed\/([^?]+)/,/youtu\.be\/([^?]+)/,/youtube\.com\/v\/([^?]+)/];for(let Y of Z){let X=$.match(Y);if(X)return X[1]}return null}function wK($){let Z=$.match(/vimeo\.com\/(\d+)/);return Z?Z[1]:null}function O0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'")}function YF($,Z,Y){if(Z.src)return{src:String(Z.src),...Z};let X=$.trim();if(X.startsWith("@video(")||X.startsWith("("))X=X.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let J=X.indexOf(",");if(J===-1)return{src:X.replace(/^['"]|['"]$/g,"")};let Q=X.slice(0,J).trim().replace(/^['"]|['"]$/g,""),G=X.slice(J+1).trim();try{let K=JSON.parse(G);return{src:Q,...K}}catch{return{src:Q}}}async function AK($,Z){let Y=await i8();if(!Y)return u$({...$,process:!1},Z);let X=Z.tsVideosConfig,J=await Y.processVideo($.src,$,X,$.onProcessProgress);if(J.processed)return r8($,J,Z);return u$({...$,process:!1},Z)}async function RK($,Z){let Y=await i8();if(!Y||!$.src)return;let X=typeof $.generatePoster==="object"?$.generatePoster:{timestamp:0},J=Z.tsVideosConfig||{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos"};return(await Y.generatePoster($.src,X,J.outputDir,J.baseUrl||"/videos"))?.url}function r8($,Z,Y){let{controls:X=n8,autoplay:J=!1,muted:Q=!1,loop:G=!1,preload:K=o8,playsinline:q=!0,lazy:z=!0,width:U,height:W,crossorigin:_,disablePictureInPicture:B=!1,disableRemotePlayback:j=!1}=$,O=$.class,L=$.style,V=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`,H=$.src,F=s8(H);if(Z.transcoded)H=Z.transcoded.url,F="video/mp4";let A=Z.streaming?.hls||Z.streaming?.dash;if(A){if(Z.streaming?.hls)H=Z.streaming.hls.manifestUrl,F="application/x-mpegURL";else if(Z.streaming?.dash)H=Z.streaming.dash.manifestUrl,F="application/dash+xml"}let w=Z.poster?.url||$.poster,R=[`id="${V}"`];if(X)R.push("controls");if(J)R.push("autoplay");if(Q)R.push("muted");if(G)R.push("loop");if(q)R.push("playsinline");if(B)R.push("disablepictureinpicture");if(j)R.push("disableremoteplayback");if(_)R.push(`crossorigin="${_}"`);if(z){if(R.push(`data-preload="${K}"`),R.push('preload="none"'),w)R.push(`data-poster="${O0(w)}"`);R.push("data-stx-lazy")}else if(R.push(`preload="${K}"`),w)R.push(`poster="${O0(w)}"`);let N=U||Z.metadata?.width,M=W||Z.metadata?.height;if(N)R.push(`width="${N}"`);if(M)R.push(`height="${M}"`);if(O)R.push(`class="${O0(O)}"`);if(L)R.push(`style="${O0(L)}"`);let I=` <source ${z?`data-src="${O0(H)}"`:`src="${O0(H)}"`} type="${F}" />`,D=`<video ${R.join(" ")}>
|
|
1420
1420
|
${I}
|
|
1421
1421
|
Your browser does not support the video tag.
|
|
1422
1422
|
</video>`;if(Z.spriteSheet)D=`<div class="stx-video-wrapper" data-sprite-sheet="${O0(Z.spriteSheet.url)}" data-sprite-cols="${Z.spriteSheet.columns}" data-sprite-interval="${Z.spriteSheet.interval}">
|
|
1423
1423
|
${D}
|
|
1424
1424
|
</div>`;let E;if(z)E=`
|
|
1425
1425
|
(function() {
|
|
1426
|
-
var video = document.getElementById('${
|
|
1426
|
+
var video = document.getElementById('${V}');
|
|
1427
1427
|
if (!video) return;
|
|
1428
1428
|
|
|
1429
1429
|
var observer = new IntersectionObserver(function(entries) {
|
|
@@ -1767,7 +1767,7 @@ catch (error) {
|
|
|
1767
1767
|
}
|
|
1768
1768
|
})();
|
|
1769
1769
|
</script>`}function qF($){return[...$,...e7]}var kK,SK,bK,yK,e7;var $Z=C(()=>{kK={name:"pwa.installButton",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return MK($,J)},hasEndTag:!0,description:"Renders a PWA install prompt button that appears when the app can be installed"},SK={name:"pwa.updatePrompt",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return IK($,J)},hasEndTag:!0,description:"Renders a PWA update notification UI when a new version is available"},bK={name:"pwa.offlineIndicator",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return DK($,J)},hasEndTag:!0,description:"Renders an offline status indicator that shows when the user loses connection"},yK={name:"pwa.pushSubscribe",handler:($,Z,Y,X)=>{let J=Y.__stx_options||{};return EK($,J)},hasEndTag:!0,description:"Renders a push notification subscription button"},e7=[kK,SK,bK,yK]});function PK($){ZZ=$}function vK(){return ZZ}function xK($){p$={...p$,...$}}function fK(){p$={}}function YZ($,Z={}){let Y=p$[$]||CK[$]||{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 gK($,Z={}){let{message:Y,help:X}=YZ($,Z);return X?`${Y}
|
|
1770
|
-
Help: ${X}`:Y}function $3($){for(let[Z,Y]of Object.entries(c))if(Y===$)return Z;return}var CK,p$,ZZ="en",c;var c$=C(()=>{CK={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"}},p$={};c={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 x5(){return!1}function f5(){return!x5()||process.env.STX_DEBUG==="true"}function l$(){return!1}import hK from"path";function dK($){Q5={...Q5,...$}}function i$(){return{...Q5}}function mK(){Q5={...XZ}}function n$($){if(!Q5.showRelativePaths||!$)return $;let Z=Q5.baseDir||process.cwd();try{let Y=hK.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var XZ,Q5,P1,JZ,v1,QZ,GZ,o$;var s$=C(()=>{c$();XZ={showRelativePaths:!1,enableAutoRecovery:f5(),logRecoveryWarnings:!0},Q5={...XZ};P1=class P1 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||c.EVALUATION_ERROR,this.filePath)this.filePath=n$(this.filePath)}};JZ=class JZ extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||c.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};v1=class v1 extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||c.EVALUATION_ERROR);this.name="StxRuntimeError"}};QZ=class QZ extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||c.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};GZ=class GZ extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||c.FILE_NOT_FOUND);this.name="StxFileError"}};o$=class o$ extends P1{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||c.DOM_API_VIOLATION);this.name="StxValidationError"}}});function Z3($){let{type:Z,message:Y,code:X,filePath:J,line:Q,column:G,template:K,offset:q,snippet:z,suggestion:U,format:W="text"}=$,_=Q,B=G;if(!_&&K&&q!==void 0){let H=qZ(K,q);_=H.line,B=H.column}let j=J?n$(J):void 0,O=X?$3(X):void 0,L={type:Z,code:X,codeName:O,message:Y,filePath:j,line:_,column:B,snippet:z,suggestion:U,timestamp:new Date().toISOString()},
|
|
1770
|
+
Help: ${X}`:Y}function $3($){for(let[Z,Y]of Object.entries(c))if(Y===$)return Z;return}var CK,p$,ZZ="en",c;var c$=C(()=>{CK={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"}},p$={};c={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 x5(){return!1}function f5(){return!x5()||process.env.STX_DEBUG==="true"}function l$(){return!1}import hK from"path";function dK($){Q5={...Q5,...$}}function i$(){return{...Q5}}function mK(){Q5={...XZ}}function n$($){if(!Q5.showRelativePaths||!$)return $;let Z=Q5.baseDir||process.cwd();try{let Y=hK.relative(Z,$);return Y.startsWith("..")?$:Y}catch{return $}}var XZ,Q5,P1,JZ,v1,QZ,GZ,o$;var s$=C(()=>{c$();XZ={showRelativePaths:!1,enableAutoRecovery:f5(),logRecoveryWarnings:!0},Q5={...XZ};P1=class P1 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||c.EVALUATION_ERROR,this.filePath)this.filePath=n$(this.filePath)}};JZ=class JZ extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_SYNTAX_ERROR",Z,Y,X,J,Q||c.INVALID_DIRECTIVE_SYNTAX);this.name="StxSyntaxError"}};v1=class v1 extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_RUNTIME_ERROR",Z,Y,X,J,Q||c.EVALUATION_ERROR);this.name="StxRuntimeError"}};QZ=class QZ extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_SECURITY_ERROR",Z,Y,X,J,Q||c.UNSAFE_EXPRESSION);this.name="StxSecurityError"}};GZ=class GZ extends P1{constructor($,Z,Y,X,J,Q){super($,"stx_FILE_ERROR",Z,Y,X,J,Q||c.FILE_NOT_FOUND);this.name="StxFileError"}};o$=class o$ extends P1{isFatal=!0;constructor($,Z,Y,X,J,Q){super($,"stx_VALIDATION_ERROR",Z,Y,X,J,Q||c.DOM_API_VIOLATION);this.name="StxValidationError"}}});function Z3($){let{type:Z,message:Y,code:X,filePath:J,line:Q,column:G,template:K,offset:q,snippet:z,suggestion:U,format:W="text"}=$,_=Q,B=G;if(!_&&K&&q!==void 0){let H=qZ(K,q);_=H.line,B=H.column}let j=J?n$(J):void 0,O=X?$3(X):void 0,L={type:Z,code:X,codeName:O,message:Y,filePath:j,line:_,column:B,snippet:z,suggestion:U,timestamp:new Date().toISOString()},V;switch(W){case"html":V=pK(L);break;case"json":V=JSON.stringify(L,null,2);break;case"console":V=cK(L,K,q);break;case"text":default:V=uK(L,K,q);break}return{formatted:V,data:L}}function uK($,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(`
|
|
1771
1771
|
${$.message}`),Z&&$.line){let Q=lK(Z,$.line,2);if(Q)X.push(`
|
|
1772
1772
|
${Q}`)}if($.snippet)X.push(`
|
|
1773
1773
|
Snippet: ${$.snippet}`);if($.suggestion)X.push(`
|
|
@@ -1783,7 +1783,7 @@ ${W}`)}if($.suggestion)z.push(`
|
|
|
1783
1783
|
${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501${"\x1B[0m"}`),z.join("")}function lK($,Z,Y){let X=$.split(`
|
|
1784
1784
|
`),J=Math.max(0,Z-Y-1),Q=Math.min(X.length-1,Z+Y-1),G=[];for(let K=J;K<=Q;K++){let q=(K+1).toString().padStart(4),z=K===Z-1?">":" ";G.push(`${z}${q} | ${X[K]}`)}return G.join(`
|
|
1785
1785
|
`)}function iK($,Z,Y){let X=$.split(`
|
|
1786
|
-
`),J=Math.max(0,Z-Y-1),Q=Math.min(X.length-1,Z+Y-1),G="\x1B[90m",K="\x1B[31m",q="\x1B[0m",z=[];for(let U=J;U<=Q;U++){let W=(U+1).toString().padStart(4),_=U===Z-1,B=_?"\x1B[31m>\x1B[0m":" ",j=_?`\x1B[31m${X[U]}\x1B[0m`:`\x1B[90m${X[U]}`;z.push(`${B}\x1B[90m${W}\x1B[0m | ${j}`)}return z.join(`
|
|
1786
|
+
`),J=Math.max(0,Z-Y-1),Q=Math.min(X.length-1,Z+Y-1),G="\x1B[90m",K="\x1B[31m",q="\x1B[0m",z=[];for(let U=J;U<=Q;U++){let W=(U+1).toString().padStart(4),_=U===Z-1,B=_?"\x1B[31m>\x1B[0m":" ",j=_?`\x1B[31m${X[U]}\x1B[0m`:`\x1B[90m${X[U]}\x1B[0m`;z.push(`${B}\x1B[90m${W}\x1B[0m | ${j}`)}return z.join(`
|
|
1787
1787
|
`)}function KZ($){return $.replace(/--/g,"- -").replace(/>/g,">")}function qZ($,Z){let X=$.substring(0,Z).split(`
|
|
1788
1788
|
`);return{line:X.length,column:X[X.length-1].length}}function r($,Z,Y){return Z3({type:$,message:Z,code:Y,format:"html"}).formatted}function nK($,Z,Y,X,J){return Z3({type:$,message:Z,code:J,filePath:Y,line:X,format:"console"}).formatted}function oK($,Z,Y){let X=Y.template.split(`
|
|
1789
1789
|
`),J=qZ(Y.template,Y.offset),Q=`[${$} Error at line ${J.line} in ${Y.filePath}]: ${Z}
|
|
@@ -1799,29 +1799,29 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
|
|
|
1799
1799
|
|
|
1800
1800
|
`),"utf-8")}}async flush(){await this.writeQueue}}var Y3,p0,J3;var UZ=C(()=>{s$();Y3={isEnabled(){return i$().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=i$();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 q=(Y.match(new RegExp(`@${K}\\b`,"g"))||[]).length,z=(Y.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(q>z){let U=q-z;for(let W=0;W<U;W++)Y+=`
|
|
1801
1801
|
@end${K}`;X.push(`Added ${U} 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(f5())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};p0=new X3,J3={isDevelopment(){return f5()},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(`
|
|
1802
|
-
`)}}});import Q3 from"path";function rK($){let Z={"&":"&","<":"<",">":">",'"':""","'":"'"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function r$($,Z={}){let{allowHtml:Y=!1,maxLength:X=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],K=$,q=!1;if(Q){let U=Q(K);if(U!==K)K=U,q=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),q=!0,G.push("Null bytes removed from parameter");if(K.length>X)K=K.substring(0,X),q=!0,G.push(`Parameter truncated to ${X} characters`);if(!Y&&/<[^>]+>/.test(K))K=rK(K),q=!0,G.push("HTML content was escaped");let z=[{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:U,replacement:W,name:_}of z)if(U.test(K))K=K.replace(U,W),q=!0,G.push(`Removed ${_} from parameter`);if(!J){let U=K;if(K=K.split("").filter((W)=>{let _=W.charCodeAt(0);return _>=32&&_!==127}).join(""),K!==U)q=!0,G.push("Control characters removed")}return{value:K,modified:q,warnings:G}}function aK($,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(!G3.isValidFilePath(Y,Z))return null;return Y}function tK($){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 eK($,Z={}){return $.map((Y)=>r$(Y,Z))}function WZ($){let Z={};for(let[Y,X]of Object.entries($)){if(!G3.isValidVariableName(Y))continue;if(typeof X==="string"){let J=r$(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?r$(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=WZ(X);else Z[Y]=X}return Z}var G3;var _Z=C(()=>{G3={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=Q3.resolve(Z,$),Q=Q3.resolve(Z);if(!J.startsWith(Q+Q3.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 BZ=C(()=>{c$();zZ();UZ();_Z();s$()});var K1=C(()=>{BZ()});function jZ($,Z,Y,X){let J=$;J=J.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,q,z)=>{if(!z&&q.includes(":")){let U=q.split(":"),W=q,_=U.length>1?U[1]:"";if(_&&Z[_])z=Z[_];else if(W.startsWith("og:")&&Z.openGraph&&Z.openGraph[U[1]])z=Z.openGraph[U[1]];else z="";return z?`<meta property="${l(W)}" content="${l(z)}">`:""}return z?`<meta name="${l(q)}" content="${l(z)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(J))!==null){let K=G.index,q=K+G[0].length-1,z=1,U=q+1;while(U<J.length&&z>0){if(J[U]==="(")z++;else if(J[U]===")"){if(z--,z===0)break}U++}if(z!==0)break;let W=J.substring(q+1,U).trim(),_=U+1,B=(()=>{try{let j=H0(W,Z);if(!j)return"";let O="<meta";if(j.name)O+=` name="${l(String(j.name))}"`;if(j.property)O+=` property="${l(String(j.property))}"`;if(j.httpEquiv)O+=` http-equiv="${l(String(j.httpEquiv))}"`;if(j.content)O+=` content="${l(String(j.content))}"`;return O+=">",O}catch(j){let O=j instanceof Error?j.message:String(j);return r("MetaTag",O,c.EVALUATION_ERROR)}})();J=J.substring(0,K)+B+J.substring(_),Q.lastIndex=0}return J}function HZ($,Z,Y){let X=$,J=/@structuredData\s*\(/g,Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,z=K+1;while(z<X.length&&q>0){if(X[z]==="(")q++;else if(X[z]===")"){if(q--,q===0)break}z++}if(q!==0)break;let U=X.substring(K+1,z).trim(),W=z+1,_=(()=>{try{let B=H0(U,Z);if(!B)return"";if(!B["@context"])B["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(B).replace(/<\//g,"<\\/")}</script>`}catch(B){let j=B instanceof Error?B.message:String(B);return r("StructuredData",j,c.EVALUATION_ERROR)}})();X=X.substring(0,G)+_+X.substring(W),J.lastIndex=0}return X}function OZ($,Z,Y,X){let J=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(J))!==null){let K=J.indexOf("{",G.index+4),q=1,z=K+1,U=null,W=!1;while(z<J.length&&q>0){let
|
|
1803
|
-
`,
|
|
1804
|
-
`;if(H.description)
|
|
1805
|
-
`;if(H.keywords){let A=Array.isArray(H.keywords)?H.keywords.join(", "):H.keywords;
|
|
1806
|
-
`}if(H.robots)
|
|
1807
|
-
`;if(H.canonical)
|
|
1808
|
-
`;if(H.openGraph){let A=H.openGraph;if(
|
|
1809
|
-
`,A.title||H.title){let w=A.title||H.title||"";
|
|
1810
|
-
`}if(A.description||H.description){let w=A.description||H.description||"";
|
|
1811
|
-
`}if(A.url||H.canonical){let w=A.url||H.canonical||"";
|
|
1812
|
-
`}if(A.image){if(
|
|
1813
|
-
`,A.imageAlt)
|
|
1814
|
-
`;if(A.imageWidth)
|
|
1815
|
-
`;if(A.imageHeight)
|
|
1816
|
-
`}if(A.siteName)
|
|
1817
|
-
`}if(H.twitter){let A=H.twitter;if(
|
|
1818
|
-
`,A.title||H.title){let w=A.title||H.title||"";
|
|
1819
|
-
`}if(A.description||H.description){let w=A.description||H.description||"";
|
|
1820
|
-
`}if(A.image||H.openGraph&&H.openGraph.image){let w=A.image||(H.openGraph?H.openGraph.image:"")||"";
|
|
1821
|
-
`}if(A.site)
|
|
1822
|
-
`;if(A.creator)
|
|
1823
|
-
`}if(H.structuredData){let A=JSON.stringify(H.structuredData).replace(/<\//g,"<\\/");
|
|
1824
|
-
`}return
|
|
1802
|
+
`)}}});import Q3 from"path";function rK($){let Z={"&":"&","<":"<",">":">",'"':""","'":"'"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function r$($,Z={}){let{allowHtml:Y=!1,maxLength:X=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],K=$,q=!1;if(Q){let U=Q(K);if(U!==K)K=U,q=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),q=!0,G.push("Null bytes removed from parameter");if(K.length>X)K=K.substring(0,X),q=!0,G.push(`Parameter truncated to ${X} characters`);if(!Y&&/<[^>]+>/.test(K))K=rK(K),q=!0,G.push("HTML content was escaped");let z=[{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:U,replacement:W,name:_}of z)if(U.test(K))K=K.replace(U,W),q=!0,G.push(`Removed ${_} from parameter`);if(!J){let U=K;if(K=K.split("").filter((W)=>{let _=W.charCodeAt(0);return _>=32&&_!==127}).join(""),K!==U)q=!0,G.push("Control characters removed")}return{value:K,modified:q,warnings:G}}function aK($,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(!G3.isValidFilePath(Y,Z))return null;return Y}function tK($){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 eK($,Z={}){return $.map((Y)=>r$(Y,Z))}function WZ($){let Z={};for(let[Y,X]of Object.entries($)){if(!G3.isValidVariableName(Y))continue;if(typeof X==="string"){let J=r$(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?r$(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=WZ(X);else Z[Y]=X}return Z}var G3;var _Z=C(()=>{G3={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=Q3.resolve(Z,$),Q=Q3.resolve(Z);if(!J.startsWith(Q+Q3.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 BZ=C(()=>{c$();zZ();UZ();_Z();s$()});var K1=C(()=>{BZ()});function jZ($,Z,Y,X){let J=$;J=J.replace(/@meta\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(K,q,z)=>{if(!z&&q.includes(":")){let U=q.split(":"),W=q,_=U.length>1?U[1]:"";if(_&&Z[_])z=Z[_];else if(W.startsWith("og:")&&Z.openGraph&&Z.openGraph[U[1]])z=Z.openGraph[U[1]];else z="";return z?`<meta property="${l(W)}" content="${l(z)}">`:""}return z?`<meta name="${l(q)}" content="${l(z)}">`:""});let Q=/@metaTag\s*\(/g,G;while((G=Q.exec(J))!==null){let K=G.index,q=K+G[0].length-1,z=1,U=q+1;while(U<J.length&&z>0){if(J[U]==="(")z++;else if(J[U]===")"){if(z--,z===0)break}U++}if(z!==0)break;let W=J.substring(q+1,U).trim(),_=U+1,B=(()=>{try{let j=H0(W,Z);if(!j)return"";let O="<meta";if(j.name)O+=` name="${l(String(j.name))}"`;if(j.property)O+=` property="${l(String(j.property))}"`;if(j.httpEquiv)O+=` http-equiv="${l(String(j.httpEquiv))}"`;if(j.content)O+=` content="${l(String(j.content))}"`;return O+=">",O}catch(j){let O=j instanceof Error?j.message:String(j);return r("MetaTag",O,c.EVALUATION_ERROR)}})();J=J.substring(0,K)+B+J.substring(_),Q.lastIndex=0}return J}function HZ($,Z,Y){let X=$,J=/@structuredData\s*\(/g,Q;while((Q=J.exec(X))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,z=K+1;while(z<X.length&&q>0){if(X[z]==="(")q++;else if(X[z]===")"){if(q--,q===0)break}z++}if(q!==0)break;let U=X.substring(K+1,z).trim(),W=z+1,_=(()=>{try{let B=H0(U,Z);if(!B)return"";if(!B["@context"])B["@context"]="https://schema.org";return`<script type="application/ld+json">${JSON.stringify(B).replace(/<\//g,"<\\/")}</script>`}catch(B){let j=B instanceof Error?B.message:String(B);return r("StructuredData",j,c.EVALUATION_ERROR)}})();X=X.substring(0,G)+_+X.substring(W),J.lastIndex=0}return X}function OZ($,Z,Y,X){let J=$,Q=/@seo\s*\(\s*\{/g,G;while((G=Q.exec(J))!==null){let K=J.indexOf("{",G.index+4),q=1,z=K+1,U=null,W=!1;while(z<J.length&&q>0){let V=J[z];if(W){W=!1,z++;continue}if(V==="\\"&&U){W=!0,z++;continue}if(U){if(V===U)U=null;z++;continue}if(V==='"'||V==="'"||V==="`"){U=V,z++;continue}if(V==="{")q++;else if(V==="}")q--;z++}if(q!==0)break;let _=J.substring(z).match(/^\s*\)/);if(!_)break;let B=z+_[0].length,j=J.substring(K,z),O=J.substring(G.index,B),L=((V)=>{try{let H=H0(V,Z);if(!H)return"";let F="";if(H.title)F+=`<title>${l(H.title)}</title>
|
|
1803
|
+
`,F+=`<meta name="title" content="${l(H.title)}">
|
|
1804
|
+
`;if(H.description)F+=`<meta name="description" content="${l(H.description)}">
|
|
1805
|
+
`;if(H.keywords){let A=Array.isArray(H.keywords)?H.keywords.join(", "):H.keywords;F+=`<meta name="keywords" content="${l(A)}">
|
|
1806
|
+
`}if(H.robots)F+=`<meta name="robots" content="${l(H.robots)}">
|
|
1807
|
+
`;if(H.canonical)F+=`<link rel="canonical" href="${l(H.canonical)}">
|
|
1808
|
+
`;if(H.openGraph){let A=H.openGraph;if(F+=`<meta property="og:type" content="${l(A.type||"website")}">
|
|
1809
|
+
`,A.title||H.title){let w=A.title||H.title||"";F+=`<meta property="og:title" content="${l(w)}">
|
|
1810
|
+
`}if(A.description||H.description){let w=A.description||H.description||"";F+=`<meta property="og:description" content="${l(w)}">
|
|
1811
|
+
`}if(A.url||H.canonical){let w=A.url||H.canonical||"";F+=`<meta property="og:url" content="${l(w)}">
|
|
1812
|
+
`}if(A.image){if(F+=`<meta property="og:image" content="${l(A.image)}">
|
|
1813
|
+
`,A.imageAlt)F+=`<meta property="og:image:alt" content="${l(A.imageAlt)}">
|
|
1814
|
+
`;if(A.imageWidth)F+=`<meta property="og:image:width" content="${l(String(A.imageWidth))}">
|
|
1815
|
+
`;if(A.imageHeight)F+=`<meta property="og:image:height" content="${l(String(A.imageHeight))}">
|
|
1816
|
+
`}if(A.siteName)F+=`<meta property="og:site_name" content="${l(A.siteName)}">
|
|
1817
|
+
`}if(H.twitter){let A=H.twitter;if(F+=`<meta name="twitter:card" content="${l(A.card||"summary_large_image")}">
|
|
1818
|
+
`,A.title||H.title){let w=A.title||H.title||"";F+=`<meta name="twitter:title" content="${l(w)}">
|
|
1819
|
+
`}if(A.description||H.description){let w=A.description||H.description||"";F+=`<meta name="twitter:description" content="${l(w)}">
|
|
1820
|
+
`}if(A.image||H.openGraph&&H.openGraph.image){let w=A.image||(H.openGraph?H.openGraph.image:"")||"";F+=`<meta name="twitter:image" content="${l(w)}">
|
|
1821
|
+
`}if(A.site)F+=`<meta name="twitter:site" content="${l(A.site)}">
|
|
1822
|
+
`;if(A.creator)F+=`<meta name="twitter:creator" content="${l(A.creator)}">
|
|
1823
|
+
`}if(H.structuredData){let A=JSON.stringify(H.structuredData).replace(/<\//g,"<\\/");F+=`<script type="application/ld+json">${A}</script>
|
|
1824
|
+
`}return F.trim()}catch(H){let F=H instanceof Error?H.message:String(H);return r("SEO",`Error processing @seo directive: ${F}`,c.EVALUATION_ERROR)}})(j);J=J.substring(0,G.index)+L+J.substring(B),Q.lastIndex=G.index+L.length}return J}function LZ($,Z,Y){if(Y.seo?.enabled===!1)return $;if($.includes("<!-- stx SEO Tags -->")||Y.skipDefaultSeoTags===!0)return $;let X=Z.__stx_runtime_head;if(!!(X?.title||X?.meta?.some((W)=>W.property==="og:title"||W.name==="og:title"||W.name==="twitter:title"||W.name==="description")))return $;if(/<meta\s+(?:[^>]*\s)?property=["']og:title["']/i.test($)||/<meta\s+(?:[^>]*\s)?name=["']og:title["']/i.test($)||/<meta\s+(?:[^>]*\s)?name=["']twitter:title["']/i.test($))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let Q=$.includes("<title>")||$.includes("</title>"),G="";if(Z.title)G=Z.title;else if(Z.meta&&Z.meta.title)G=Z.meta.title;else if(Y.seo?.defaultConfig?.title)G=Y.seo.defaultConfig.title;else G=Y.defaultTitle||"stx Project";let K="";if(Z.description)K=Z.description;else if(Z.meta&&Z.meta.description)K=Z.meta.description;else if(Y.seo?.defaultConfig?.description)K=Y.seo.defaultConfig.description;else K=Y.defaultDescription||"A website built with stx templating engine";let q="";if(Z.image)q=Z.image;else if(Z.meta&&Z.meta.image)q=Z.meta.image;else if(Z.openGraph&&Z.openGraph.image)q=Z.openGraph.image;else if(Y.seo?.defaultImage)q=Y.seo.defaultImage;else if(Y.defaultImage)q=Y.defaultImage;let z=`
|
|
1825
1825
|
<!-- stx SEO Tags -->
|
|
1826
1826
|
<meta name="title" content="${l(G)}">
|
|
1827
1827
|
<meta name="description" content="${l(K)}">
|
|
@@ -1961,7 +1961,7 @@ else {
|
|
|
1961
1961
|
this.removeAttribute('${w}');
|
|
1962
1962
|
}
|
|
1963
1963
|
}`}).join(`
|
|
1964
|
-
`),
|
|
1964
|
+
`),V=q.length>0?`/**
|
|
1965
1965
|
* Props interface for ${Z}
|
|
1966
1966
|
*/
|
|
1967
1967
|
export interface ${U}Props {
|
|
@@ -1993,7 +1993,7 @@ catch { return value; }
|
|
|
1993
1993
|
default: return value;
|
|
1994
1994
|
}
|
|
1995
1995
|
}
|
|
1996
|
-
`:"",
|
|
1996
|
+
`:"",F=G?`
|
|
1997
1997
|
private _createTemplate(): void {
|
|
1998
1998
|
const template = document.createElement('template');
|
|
1999
1999
|
template.innerHTML = \`${_}${W}\`;
|
|
@@ -2021,7 +2021,7 @@ interface SlotChangeDetail {
|
|
|
2021
2021
|
assignedNodes: Node[];
|
|
2022
2022
|
}
|
|
2023
2023
|
|
|
2024
|
-
${
|
|
2024
|
+
${V}
|
|
2025
2025
|
/**
|
|
2026
2026
|
* ${Z} custom element class
|
|
2027
2027
|
* @customElement ${Y}
|
|
@@ -2034,7 +2034,7 @@ ${O}
|
|
|
2034
2034
|
${Q?'this.attachShadow({ mode: "open" });':""}
|
|
2035
2035
|
${G?"this._createTemplate();":"this._render();"}
|
|
2036
2036
|
}
|
|
2037
|
-
${
|
|
2037
|
+
${F}
|
|
2038
2038
|
${Q?`
|
|
2039
2039
|
private _processSlots(): void {
|
|
2040
2040
|
const slots = this.shadowRoot!.querySelectorAll('slot');
|
|
@@ -2111,7 +2111,7 @@ else {
|
|
|
2111
2111
|
bubbles: true
|
|
2112
2112
|
}));
|
|
2113
2113
|
}`}).join(`
|
|
2114
|
-
`),
|
|
2114
|
+
`),V=j.length>0?`
|
|
2115
2115
|
static get observedAttributes() {
|
|
2116
2116
|
return [${j.map((M)=>`'${M}'`).join(", ")}];
|
|
2117
2117
|
}
|
|
@@ -2125,7 +2125,7 @@ else {
|
|
|
2125
2125
|
}
|
|
2126
2126
|
${q.attributeChanged||""}
|
|
2127
2127
|
}`:"",H=Object.entries(z).map(([M,T])=>{return`this._root.addEventListener('${M}', (e) => { ${T} });`}).join(`
|
|
2128
|
-
`),
|
|
2128
|
+
`),F=Object.entries(U).map(([M,T])=>{return`
|
|
2129
2129
|
${M}() {
|
|
2130
2130
|
${T}
|
|
2131
2131
|
}`}).join(`
|
|
@@ -2257,7 +2257,7 @@ ${L}
|
|
|
2257
2257
|
}
|
|
2258
2258
|
}
|
|
2259
2259
|
|
|
2260
|
-
${
|
|
2260
|
+
${V}
|
|
2261
2261
|
|
|
2262
2262
|
// =========================================================================
|
|
2263
2263
|
// Lifecycle
|
|
@@ -2280,7 +2280,7 @@ ${F}
|
|
|
2280
2280
|
// =========================================================================
|
|
2281
2281
|
// Custom Methods
|
|
2282
2282
|
// =========================================================================
|
|
2283
|
-
${
|
|
2283
|
+
${F}
|
|
2284
2284
|
}
|
|
2285
2285
|
|
|
2286
2286
|
// Register the custom element
|
|
@@ -2297,7 +2297,7 @@ export interface ${_}Props {
|
|
|
2297
2297
|
${B.map((T)=>` ${T}?: ${O(K[T].type)};`).join(`
|
|
2298
2298
|
`)}
|
|
2299
2299
|
}
|
|
2300
|
-
`:"",
|
|
2300
|
+
`:"",V=Object.keys(W).length>0?`
|
|
2301
2301
|
/**
|
|
2302
2302
|
* State interface for ${Z}
|
|
2303
2303
|
*/
|
|
@@ -2310,7 +2310,7 @@ export interface ${_}State {
|
|
|
2310
2310
|
[key: string]: unknown;
|
|
2311
2311
|
}
|
|
2312
2312
|
`,H=B.map((T)=>{let I=K[T],D=O(I.type);return` private _${T}: ${D};`}).join(`
|
|
2313
|
-
`),
|
|
2313
|
+
`),F=B.map((T)=>{let I=K[T],D=O(I.type),E=I.attribute!==!1?I.attribute||K5(T):null,k=I.default!==void 0?JSON.stringify(I.default):I.type==="string"?'""':I.type==="number"?"0":I.type==="boolean"?"false":I.type==="array"?"[]":"{}",S=I.reflect&&E?`
|
|
2314
2314
|
if (value !== null && value !== undefined) {
|
|
2315
2315
|
${I.type==="boolean"?`if (value) { this.setAttribute('${E}', ''); }
|
|
2316
2316
|
else { this.removeAttribute('${E}'); }`:`this.setAttribute('${E}', ${I.type==="object"||I.type==="array"?"JSON.stringify(value)":"String(value)"});`}
|
|
@@ -2361,7 +2361,7 @@ else {
|
|
|
2361
2361
|
*/
|
|
2362
2362
|
|
|
2363
2363
|
${L}
|
|
2364
|
-
${
|
|
2364
|
+
${V}
|
|
2365
2365
|
|
|
2366
2366
|
/**
|
|
2367
2367
|
* Property definition type
|
|
@@ -2408,7 +2408,7 @@ ${B.map((T)=>{let I=K[T],D=I.default!==void 0?JSON.stringify(I.default):I.type==
|
|
|
2408
2408
|
// =========================================================================
|
|
2409
2409
|
// Reactive Properties
|
|
2410
2410
|
// =========================================================================
|
|
2411
|
-
${
|
|
2411
|
+
${F}
|
|
2412
2412
|
|
|
2413
2413
|
// =========================================================================
|
|
2414
2414
|
// State Management
|
|
@@ -2933,8 +2933,8 @@ ${U}
|
|
|
2933
2933
|
customElements.define('${Z}', ${G});
|
|
2934
2934
|
`}async function VZ($,Z,Y,X){if(Z.length<1)return r("WebComponent","@webcomponent directive requires at least the tag name parameter",c.INVALID_DIRECTIVE_SYNTAX);let J=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[B1.join(B1.dirname(X),G,`${J}.stx`),B1.join(process.cwd(),G,`${J}.stx`),B1.join(B1.dirname(X),`${J}.stx`)],q=null;for(let W of K)if(await i(W)){q=await Bun.file(W).text();break}if(!q)return r("WebComponent",`Component file not found: ${J}.stx`,c.FILE_NOT_FOUND);let z=Uq(q,J);return`<script type="module">
|
|
2935
2935
|
${Wq(z)}
|
|
2936
|
-
</script>`}var U3;var wZ=C(()=>{K1();w0();U3={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var AZ={};p(AZ,{timingPlugin:()=>Oq,pluginManager:()=>_q,definePlugin:()=>t$,debugPlugin:()=>Hq,createVariablesPlugin:()=>Lq,createFilterPlugin:()=>jq,createDirectivePlugin:()=>Bq,PluginManager:()=>_3});function t$($){return $}class _3{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 Bq($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function jq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Lq($){return t$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var _q,Hq,Oq;var RZ=C(()=>{_q=new _3;Hq=t$({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)}}),Oq=t$({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var TZ={};p(TZ,{validateConfig:()=>Aq,loadStxConfig:()=>$4,defineStxConfig:()=>wq,defaultConfig:()=>x1,config:()=>j3});import B3 from"fs";import M0 from"path";import{loadConfigWithResult as Fq}from"bunfig";function Vq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=M0.join(process.cwd(),"resources","views"),J=M0.join(process.cwd(),"resources","layouts");if(B3.existsSync(X)&&B3.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=M0.join(process.cwd(),"resources","views","pages");if(B3.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function $4($){if(!$){if(q5)return q5;if(e$)return e$}let Z=$?M0.resolve($):process.cwd(),Y=NZ.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await Fq({name:"stx",alias:"ui",cwd:Z,defaultConfig:x1,verbose:!1})).config,G=Vq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!M0.isAbsolute(Q.partialsDir))Q.partialsDir=M0.join(K,Q.partialsDir);if(Q.componentsDir&&!M0.isAbsolute(Q.componentsDir))Q.componentsDir=M0.join(K,Q.componentsDir);if(Q.layoutsDir&&!M0.isAbsolute(Q.layoutsDir))Q.layoutsDir=M0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (RZ(),AZ)),q=[],z=[];for(let U of Q.plugins){let W=typeof U==="string"?U:U[0],_=typeof U==="string"?{}:U[1]||{};try{let B,j;try{B=await import(W),j=M0.dirname(G0.resolve(W))}catch{let L=M0.resolve(process.cwd(),W);B=await import(L),j=M0.dirname(L)}let O=B.default||B;if(K.register(O,Q),O.components){let L=M0.resolve(j,O.components);q.push(L)}if(O.pages){let L=M0.resolve(j,O.pages),F=_.path||"/";z.push({dir:L,prefix:F})}if(O.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,H)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=H},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await O.setup(_,L)}console.log(`[stx] Plugin loaded: ${O.name||W}`)}catch(B){console.warn(`[stx] Failed to load plugin ${W}:`,B.message)}}Q._pluginComponentDirs=q,Q._pluginPageDirs=z}return Q})();if(NZ.set(Z,X),!$)e$=X,X.then((J)=>{q5=J}).catch(()=>{});return X}function wq($){return $}function Aq($){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 x1,q5=null,NZ,e$=null,j3;var g5=C(()=>{Q7();U7();O7();L7();w7();k8();t7();$Z();z3();wZ();x1={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:V7,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:VZ,hasEndTag:!1,description:"Include a web component in the template"},U$,W$,K3,q3,G7,q7,z7,K7,n9,r9,E8,a7,...e7],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}};NZ=new Map;j3=new Proxy(x1,{get($,Z){if(q5&&Z in q5)return q5[Z];if(!e$)$4().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var Sq={};p(Sq,{resetCssCache:()=>Iq,resetCrosswindCache:()=>Dq,rebuildCrosswindCSS:()=>Eq,loadCrosswindConfig:()=>V3,loadCrosswind:()=>F3,injectCrosswindCSS:()=>w3,getCachedCSS:()=>kq,generateCrosswindCSS:()=>EZ,extractClassNames:()=>DZ,buildCrosswindCSS:()=>IZ});import Y4 from"fs";import Y0 from"path";function L3($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function H3($,Z){if(q1.has($))q1.delete($);else if(q1.size>=Rq)q1.delete(q1.keys().next().value);q1.set($,Z)}async function Nq($){if(!j1)return null;try{let Z=Bun.file(Y0.join(j1,`cw-${L3($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function Tq($,Z){if(!j1)return;try{if(!Y4.existsSync(j1))Y4.mkdirSync(j1,{recursive:!0});await Bun.write(Y0.join(j1,`cw-${L3($)}.css`),Z)}catch{}}async function MZ($){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 Mq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==Y0.dirname(Y))$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=Y0.dirname(Y);if(Z){let X=[Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function F3(){if(O3)return U5;O3=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await MZ(Y);if(X){if(U5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded`);return U5}}let Z=Mq();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await MZ(Y);if(X){if(U5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded from ${Y0.dirname(Y0.dirname(Y))}`);return U5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${K0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${K0.reset}`),console.warn(`${K0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${K0.reset}`),null}}function Iq(){q1.clear()}function Dq(){U5=null,O3=!1,c0=null,h5="",q1.clear(),Z4=null}async function V3($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=Y0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${K0.yellow}[Crosswind]${K0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function IZ($){if(z5)return h5;z5=!0;try{let Z=await F3();if(!Z||!Z.build)return z5=!1,"";if(!c0)c0=await V3($);if(!c0)return z5=!1,"";let Y=Z.defaultConfig?.theme||{},X=c0.theme||{},J={...Z.defaultConfig,...c0,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(h5=G.css,console.log(`${K0.cyan}[Crosswind]${K0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let q=Y0.isAbsolute(J.output)?J.output:Y0.join($,J.output),z=Y0.dirname(q);if(!Y4.existsSync(z))Y4.mkdirSync(z,{recursive:!0});await Bun.write(q,G.css)}return z5=!1,G.css}catch(Z){return console.error(`${K0.red}[Crosswind]${K0.reset} Build error:`,Z),z5=!1,h5}}async function Eq($){c0=null,await IZ($)}function kq(){return h5}function DZ($){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 q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}Q=J.exec($)}return Z}async function EZ($,Z){try{let Y=await F3();if(!Y)return"";let X=DZ($);if(X.size===0)return"";let J=Z?Y0.resolve(Z):process.cwd();if(!j1)j1=Y0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${Z4||"default"}::${Q}`,K=q1.get(G);if(K!==void 0)return H3(G,K),K;let q=await Nq(G);if(q!==null)return H3(G,q),q;if(!c0){let w=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (g5(),TZ)),N=await R(J);if(N.css)if(typeof N.css==="string"){let M=Y0.isAbsolute(N.css)?N.css:Y0.resolve(J,N.css);if(await Bun.file(M).exists()){let T=await import(M);w=T.default||T,console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(w={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=Y0.isAbsolute(N.css.config)?N.css.config:Y0.resolve(J,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);w={...T.default||T,...w}}}console.log(`${K0.green}[Crosswind]${K0.reset} Using inline CSS config from stx.config.ts`)}}catch{}c0=w||await V3(J);try{Z4=L3(JSON.stringify(c0??{}))}catch{Z4="unhashable"}}let z=Y.defaultConfig||Y.config,U=c0||{},W=z.theme||{},B=(U.theme||{}).extend||{},j={...W};if(Object.keys(B).length>0)j.extend=B;let O=[...z.safelist||[],...U.safelist||[]],L={...z,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:O},F=new Y.CSSGenerator(L);for(let w of O)F.generate(w);for(let w of X)F.generate(w);let H=F.toCSS(!0,!1),V=L.shortcuts||U.shortcuts||{};for(let[w,R]of Object.entries(V)){if(!X.has(w)&&!O.includes(w))continue;let N=R.split(/\s+/).filter(Boolean);for(let M of N)F.generate(M)}H=F.toCSS(!0,!1);let A=H.split(`
|
|
2937
|
-
`);for(let[w,R]of Object.entries(
|
|
2936
|
+
</script>`}var U3;var wZ=C(()=>{K1();w0();U3={strategy:"attribute",attributeName:"data-v",preserveOriginal:!0}});var AZ={};p(AZ,{timingPlugin:()=>Oq,pluginManager:()=>_q,definePlugin:()=>t$,debugPlugin:()=>Hq,createVariablesPlugin:()=>Lq,createFilterPlugin:()=>jq,createDirectivePlugin:()=>Bq,PluginManager:()=>_3});function t$($){return $}class _3{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 Bq($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function jq($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function Lq($){return t$({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var _q,Hq,Oq;var RZ=C(()=>{_q=new _3;Hq=t$({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)}}),Oq=t$({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var TZ={};p(TZ,{validateConfig:()=>Aq,loadStxConfig:()=>$4,defineStxConfig:()=>wq,defaultConfig:()=>x1,config:()=>j3});import B3 from"fs";import M0 from"path";import{loadConfigWithResult as Fq}from"bunfig";function Vq($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let X=M0.join(process.cwd(),"resources","views"),J=M0.join(process.cwd(),"resources","layouts");if(B3.existsSync(X)&&B3.existsSync(J))return{root:"resources",pagesDir:"views"};let Q=M0.join(process.cwd(),"resources","views","pages");if(B3.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function $4($){if(!$){if(q5)return q5;if(e$)return e$}let Z=$?M0.resolve($):process.cwd(),Y=NZ.get(Z);if(Y)return Y;let X=(async()=>{let Q=(await Fq({name:"stx",alias:"ui",cwd:Z,defaultConfig:x1,verbose:!1})).config,G=Vq(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!M0.isAbsolute(Q.partialsDir))Q.partialsDir=M0.join(K,Q.partialsDir);if(Q.componentsDir&&!M0.isAbsolute(Q.componentsDir))Q.componentsDir=M0.join(K,Q.componentsDir);if(Q.layoutsDir&&!M0.isAbsolute(Q.layoutsDir))Q.layoutsDir=M0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (RZ(),AZ)),q=[],z=[];for(let U of Q.plugins){let W=typeof U==="string"?U:U[0],_=typeof U==="string"?{}:U[1]||{};try{let B,j;try{B=await import(W),j=M0.dirname(G0.resolve(W))}catch{let L=M0.resolve(process.cwd(),W);B=await import(L),j=M0.dirname(L)}let O=B.default||B;if(K.register(O,Q),O.components){let L=M0.resolve(j,O.components);q.push(L)}if(O.pages){let L=M0.resolve(j,O.pages),V=_.path||"/";z.push({dir:L,prefix:V})}if(O.setup){let L={addDirective:(V)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(V)},addRoute:(V,H)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[V]=H},addMiddleware:(V)=>{Q.middleware=Q.middleware||[],Q.middleware.push(V)},pluginDir:j,config:Q};await O.setup(_,L)}console.log(`[stx] Plugin loaded: ${O.name||W}`)}catch(B){console.warn(`[stx] Failed to load plugin ${W}:`,B.message)}}Q._pluginComponentDirs=q,Q._pluginPageDirs=z}return Q})();if(NZ.set(Z,X),!$)e$=X,X.then((J)=>{q5=J}).catch(()=>{});return X}function wq($){return $}function Aq($){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 x1,q5=null,NZ,e$=null,j3;var g5=C(()=>{Q7();U7();O7();L7();w7();k8();t7();$Z();z3();wZ();x1={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:V7,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:VZ,hasEndTag:!1,description:"Include a web component in the template"},U$,W$,K3,q3,G7,q7,z7,K7,n9,r9,E8,a7,...e7],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}};NZ=new Map;j3=new Proxy(x1,{get($,Z){if(q5&&Z in q5)return q5[Z];if(!e$)$4().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});var Sq={};p(Sq,{resetCssCache:()=>Iq,resetCrosswindCache:()=>Dq,rebuildCrosswindCSS:()=>Eq,loadCrosswindConfig:()=>V3,loadCrosswind:()=>F3,injectCrosswindCSS:()=>w3,getCachedCSS:()=>kq,generateCrosswindCSS:()=>EZ,extractClassNames:()=>DZ,buildCrosswindCSS:()=>IZ});import Y4 from"fs";import Y0 from"path";function L3($){return Bun.hash($).toString(16).padStart(16,"0").slice(0,16)}function H3($,Z){if(q1.has($))q1.delete($);else if(q1.size>=Rq)q1.delete(q1.keys().next().value);q1.set($,Z)}async function Nq($){if(!j1)return null;try{let Z=Bun.file(Y0.join(j1,`cw-${L3($)}.css`));if(!await Z.exists())return null;return await Z.text()}catch{return null}}async function Tq($,Z){if(!j1)return;try{if(!Y4.existsSync(j1))Y4.mkdirSync(j1,{recursive:!0});await Bun.write(Y0.join(j1,`cw-${L3($)}.css`),Z)}catch{}}async function MZ($){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 Mq(){let $=[],Z=process.env.HOME||process.env.USERPROFILE||"",Y=process.cwd();while(Y!==Y0.dirname(Y))$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"node_modules","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@cwcss","crosswind","src","index.ts")),$.push(Y0.join(Y,"node_modules","@stacksjs","crosswind","dist","index.js")),$.push(Y0.join(Y,"pantry","@stacksjs","crosswind","dist","index.js")),Y=Y0.dirname(Y);if(Z){let X=[Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),Y0.join(Z,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),Y0.join(Z,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];$.push(...X)}return $.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),$.push(Y0.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),$}async function F3(){if(O3)return U5;O3=!0;try{let $=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of $){let X=await MZ(Y);if(X){if(U5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded`);return U5}}let Z=Mq();for(let Y of Z)if(await Bun.file(Y).exists()){let X=await MZ(Y);if(X){if(U5=X,!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} CSS engine loaded from ${Y0.dirname(Y0.dirname(Y))}`);return U5}}throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${K0.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${K0.reset}`),console.warn(`${K0.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${K0.reset}`),null}}function Iq(){q1.clear()}function Dq(){U5=null,O3=!1,c0=null,h5="",q1.clear(),Z4=null}async function V3($){try{let{loadConfigWithResult:Z}=await import("bunfig"),Y=await Z({name:"crosswind",cwd:$,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Y?.path||!Y.config||Object.keys(Y.config).length===0)return null;let X=Y0.relative($,Y.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from ${X||Y.path}`);return Y.config}catch(Z){if(Z instanceof Error&&Z.name==="ConfigNotFoundError")return null;return console.warn(`${K0.yellow}[Crosswind]${K0.reset} Failed to load crosswind config:`,Z instanceof Error?Z.message:Z),null}}async function IZ($){if(z5)return h5;z5=!0;try{let Z=await F3();if(!Z||!Z.build)return z5=!1,"";if(!c0)c0=await V3($);if(!c0)return z5=!1,"";let Y=Z.defaultConfig?.theme||{},X=c0.theme||{},J={...Z.defaultConfig,...c0,theme:{...Y,...X,extend:{...Y.extend||{},...X.extend||{}}}},Q=performance.now(),G=await Z.build(J),K=performance.now()-Q;if(h5=G.css,console.log(`${K0.cyan}[Crosswind]${K0.reset} Built ${G.classes.size} classes in ${K.toFixed(1)}ms`),J.output){let q=Y0.isAbsolute(J.output)?J.output:Y0.join($,J.output),z=Y0.dirname(q);if(!Y4.existsSync(z))Y4.mkdirSync(z,{recursive:!0});await Bun.write(q,G.css)}return z5=!1,G.css}catch(Z){return console.error(`${K0.red}[Crosswind]${K0.reset} Build error:`,Z),z5=!1,h5}}async function Eq($){c0=null,await IZ($)}function kq(){return h5}function DZ($){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 q of K.slice(1,-1).split(/\s+/))if(q.trim())Z.add(q.trim())}Q=J.exec($)}return Z}async function EZ($,Z){try{let Y=await F3();if(!Y)return"";let X=DZ($);if(X.size===0)return"";let J=Z?Y0.resolve(Z):process.cwd();if(!j1)j1=Y0.join(J,".stx/cache");let Q=[...X].sort().join(" "),G=`${Z4||"default"}::${Q}`,K=q1.get(G);if(K!==void 0)return H3(G,K),K;let q=await Nq(G);if(q!==null)return H3(G,q),q;if(!c0){let w=null;try{let{loadStxConfig:R}=await Promise.resolve().then(() => (g5(),TZ)),N=await R(J);if(N.css)if(typeof N.css==="string"){let M=Y0.isAbsolute(N.css)?N.css:Y0.resolve(J,N.css);if(await Bun.file(M).exists()){let T=await import(M);w=T.default||T,console.log(`${K0.green}[Crosswind]${K0.reset} Loaded config from stx.config.ts \u2192 ${N.css}`)}}else{if(w={...N.css,content:N.css.content||[],preflight:N.css.preflight??!0,minify:N.css.minify??!1},N.css.config){let M=Y0.isAbsolute(N.css.config)?N.css.config:Y0.resolve(J,N.css.config);if(await Bun.file(M).exists()){let T=await import(M);w={...T.default||T,...w}}}console.log(`${K0.green}[Crosswind]${K0.reset} Using inline CSS config from stx.config.ts`)}}catch{}c0=w||await V3(J);try{Z4=L3(JSON.stringify(c0??{}))}catch{Z4="unhashable"}}let z=Y.defaultConfig||Y.config,U=c0||{},W=z.theme||{},B=(U.theme||{}).extend||{},j={...W};if(Object.keys(B).length>0)j.extend=B;let O=[...z.safelist||[],...U.safelist||[]],L={...z,...U,content:[],output:"",preflight:!0,minify:!1,theme:j,safelist:O},V=new Y.CSSGenerator(L);for(let w of O)V.generate(w);for(let w of X)V.generate(w);let H=V.toCSS(!0,!1),F=L.shortcuts||U.shortcuts||{};for(let[w,R]of Object.entries(F)){if(!X.has(w)&&!O.includes(w))continue;let N=R.split(/\s+/).filter(Boolean);for(let M of N)V.generate(M)}H=V.toCSS(!0,!1);let A=H.split(`
|
|
2937
|
+
`);for(let[w,R]of Object.entries(F)){if(!X.has(w)&&!O.includes(w))continue;let N=R.split(/\s+/).filter(Boolean),M=[],T=[];for(let I of N){let D=I.startsWith("dark:"),S=`.${(D?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 y=A[b].trim();if(y===`${S} {`||y.startsWith(`${S} {`)){let d=b,f="";while(d<A.length){if(f+=A[d],A[d].includes("}"))break;d++}let m=f.match(/\{([^}]+)\}/);if(m)if(D)T.push(m[1].trim());else M.push(m[1].trim());break}}}if(M.length)H+=`
|
|
2938
2938
|
.${w} { ${M.join(" ")} }`;if(T.length)H+=`
|
|
2939
2939
|
@media (prefers-color-scheme: dark) { .dark .${w} { ${T.join(" ")} } }`}return H3(G,H),Tq(G,H),H}catch(Y){return console.warn("Failed to generate Crosswind CSS:",Y),""}}async function w3($,Z){let Y=await EZ($,Z);if(!Y)return $;let X=`<style data-crosswind="generated">
|
|
2940
2940
|
${Y}
|
|
@@ -3285,7 +3285,7 @@ else {
|
|
|
3285
3285
|
|
|
3286
3286
|
console.log('[stx] Lifecycle runtime initialized');
|
|
3287
3287
|
})();
|
|
3288
|
-
`}function N3($){return Symbol($)}function MV($,Z){(H1.length>0?H1[H1.length-1]:J4).set($,Z)}function IV($,Z){for(let Y=H1.length-1;Y>=0;Y--){let X=H1[Y];if(X.has($))return X.get($)}if(J4.has($))return J4.get($);if(arguments.length>1)return Z;console.warn(`[stx] Injection "${String($)}" not found.`);return}function gq(){H1.push(new Map)}function hq(){H1.pop()}async function DV($){gq();try{return await $()}finally{hq()}}function EV(){J4.clear(),H1.length=0}var X4=null,bZ,bq=0,HV,OV,LV,J4,H1,kV,SV,bV;var CZ=C(()=>{bZ=new Map;HV=Pq,OV=vq,LV=xq;J4=new Map,H1=[];kV=N3("theme"),SV=N3("router"),bV=N3("i18n")});import*as vZ from"crypto";function PZ($){let Z=/\$(\w+)\./g,Y=[],X;while((X=Z.exec($))!==null)if(!Y.includes(X[1]))Y.push(X[1]);return Y}function dq(){return`stx-${vZ.randomBytes(4).toString("hex")}`}function mq($){return/\$\w+\./.test($)}function uq($){let Z=[],Y=new Set,X=/<(\w+)([^>]*?)(\s*\/?>)/g,J=$;return J=J.replace(X,(Q,G,K,q)=>{if(["script","style","template"].includes(G.toLowerCase()))return Q;let z=[],U=!1,W=K,_=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,B=[...K.matchAll(_)];for(let L of B){let
|
|
3288
|
+
`}function N3($){return Symbol($)}function MV($,Z){(H1.length>0?H1[H1.length-1]:J4).set($,Z)}function IV($,Z){for(let Y=H1.length-1;Y>=0;Y--){let X=H1[Y];if(X.has($))return X.get($)}if(J4.has($))return J4.get($);if(arguments.length>1)return Z;console.warn(`[stx] Injection "${String($)}" not found.`);return}function gq(){H1.push(new Map)}function hq(){H1.pop()}async function DV($){gq();try{return await $()}finally{hq()}}function EV(){J4.clear(),H1.length=0}var X4=null,bZ,bq=0,HV,OV,LV,J4,H1,kV,SV,bV;var CZ=C(()=>{bZ=new Map;HV=Pq,OV=vq,LV=xq;J4=new Map,H1=[];kV=N3("theme"),SV=N3("router"),bV=N3("i18n")});import*as vZ from"crypto";function PZ($){let Z=/\$(\w+)\./g,Y=[],X;while((X=Z.exec($))!==null)if(!Y.includes(X[1]))Y.push(X[1]);return Y}function dq(){return`stx-${vZ.randomBytes(4).toString("hex")}`}function mq($){return/\$\w+\./.test($)}function uq($){let Z=[],Y=new Set,X=/<(\w+)([^>]*?)(\s*\/?>)/g,J=$;return J=J.replace(X,(Q,G,K,q)=>{if(["script","style","template"].includes(G.toLowerCase()))return Q;let z=[],U=!1,W=K,_=/(\w+(?:-\w+)*)\s*=\s*"([^"]*\{\{[^}]*\$\w+[^}]*\}\}[^"]*)"/g,B=[...K.matchAll(_)];for(let L of B){let V=L[0],H=L[1],F=L[2];if(mq(F)){U=!0;let A=F.match(/\{\{\s*([\s\S]+?)\s*\}\}/);if(A){let w=A[1];if(z.push({attr:H,expr:w,fullMatch:V,originalAttr:H}),PZ(w).forEach((N)=>Y.add(N)),H==="text")W=W.replace(V,"");else if(H==="class")W=W.replace(V,'class=""');else if(H==="disabled"||H==="hidden")W=W.replace(V,"");else W=W.replace(V,`${H}=""`)}}}if(!U)return Q;let j=W.match(/\bid\s*=\s*"([^"]+)"/),O;if(j)O=j[1];else O=dq(),W=` id="${O}"${W}`;for(let L of z)Z.push({elementId:O,attribute:L.attr,expression:L.expr,stores:PZ(L.expr)});return`<${G}${W}${q}`}),{html:J,bindings:Z,stores:Y}}function pq($,Z){if($.length===0)return"";let Y=Array.from(Z),X=`
|
|
3289
3289
|
<script>
|
|
3290
3290
|
(function() {
|
|
3291
3291
|
'use strict';
|
|
@@ -3443,7 +3443,7 @@ else {
|
|
|
3443
3443
|
}
|
|
3444
3444
|
})();
|
|
3445
3445
|
</script>
|
|
3446
|
-
`,X}function xZ($){let{html:Z,bindings:Y,stores:X}=uq($);if(Y.length===0)return $;let J=pq(Y,X),Q=Z.lastIndexOf("</body>");if(Q!==-1)return Z.slice(0,Q)+J+Z.slice(Q);return Z+J}var fZ=()=>{};function dZ($){let Z={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let Y of $){let X=Y.toLowerCase();if(X==="prevent")Z.prevent=!0;else if(X==="stop")Z.stop=!0;else if(X==="once")Z.once=!0;else if(X==="capture")Z.capture=!0;else if(X==="self")Z.self=!0;else if(X==="passive")Z.passive=!0;else if(cq.has(X))Z.systemKeys.push(X);else if(X in mZ)Z.mouse=X;else if(X in hZ||/^[a-z]$/.test(X))Z.keys.push(hZ[X]||X.toUpperCase());else if(X.startsWith("debounce")){let J=X.match(/debounce(?:\.(\d+))?/);Z.debounce=J?.[1]?Number.parseInt(J[1],10):300}else if(X.startsWith("throttle")){let J=X.match(/throttle(?:\.(\d+))?/);Z.throttle=J?.[1]?Number.parseInt(J[1],10):300}}return Z}function uZ($){let Z=[],Y=0,X=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,J;while((J=X.exec($))!==null){let[Q,G,K]=J,q=J.index,z=q+Q.length,U=`__stx_evt_${Y++}`,W=[],_=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,B;while((B=_.exec(K))!==null){let[,O,L]=B,
|
|
3446
|
+
`,X}function xZ($){let{html:Z,bindings:Y,stores:X}=uq($);if(Y.length===0)return $;let J=pq(Y,X),Q=Z.lastIndexOf("</body>");if(Q!==-1)return Z.slice(0,Q)+J+Z.slice(Q);return Z+J}var fZ=()=>{};function dZ($){let Z={prevent:!1,stop:!1,once:!1,capture:!1,self:!1,passive:!1,keys:[],systemKeys:[],mouse:null,debounce:null,throttle:null};for(let Y of $){let X=Y.toLowerCase();if(X==="prevent")Z.prevent=!0;else if(X==="stop")Z.stop=!0;else if(X==="once")Z.once=!0;else if(X==="capture")Z.capture=!0;else if(X==="self")Z.self=!0;else if(X==="passive")Z.passive=!0;else if(cq.has(X))Z.systemKeys.push(X);else if(X in mZ)Z.mouse=X;else if(X in hZ||/^[a-z]$/.test(X))Z.keys.push(hZ[X]||X.toUpperCase());else if(X.startsWith("debounce")){let J=X.match(/debounce(?:\.(\d+))?/);Z.debounce=J?.[1]?Number.parseInt(J[1],10):300}else if(X.startsWith("throttle")){let J=X.match(/throttle(?:\.(\d+))?/);Z.throttle=J?.[1]?Number.parseInt(J[1],10):300}}return Z}function uZ($){let Z=[],Y=0,X=/<([a-z][a-z0-9-]*)\s+([^>]*@[a-z][^>]*)>/gi,J;while((J=X.exec($))!==null){let[Q,G,K]=J,q=J.index,z=q+Q.length,U=`__stx_evt_${Y++}`,W=[],_=/@([a-z][a-z0-9.]*)\s*=\s*"([^"]*)"/gi,B;while((B=_.exec(K))!==null){let[,O,L]=B,V=O.split("."),H=V[0];if(!gZ.has(H))continue;W.push({attribute:`@${O}`,event:H,handler:L,modifiers:dZ(V.slice(1)),elementId:U})}let j=/@([a-z][a-z0-9.]*)\s*=\s*'([^']*)'/gi;while((B=j.exec(K))!==null){let[,O,L]=B,V=O.split("."),H=V[0];if(!gZ.has(H))continue;W.push({attribute:`@${O}`,event:H,handler:L,modifiers:dZ(V.slice(1)),elementId:U})}if(W.length>0)Z.push({originalTag:Q,elementId:U,events:W,startIndex:q,endIndex:z})}return Z}function lq($){let Z=[],{modifiers:Y}=$;if(Y.self)Z.push("if ($event.target !== $el) return");for(let X of Y.systemKeys)Z.push(`if (!$event.${X}Key) return`);if(Y.keys.length>0){let X=Y.keys.map((J)=>`$event.key === '${J}'`).join(" || ");Z.push(`if (!(${X})) return`)}if(Y.mouse!==null){let X=mZ[Y.mouse];Z.push(`if ($event.button !== ${X}) return`)}if(Y.prevent)Z.push("$event.preventDefault()");if(Y.stop)Z.push("$event.stopPropagation()");return Z.join("; ")}function iq($,Z){let Y=$;if(Z.debounce!==null)Y=`__stx_debounce(() => { ${Y} }, ${Z.debounce})`;else if(Z.throttle!==null)Y=`__stx_throttle(() => { ${Y} }, ${Z.throttle})`;return Y}function nq($){let{modifiers:Z}=$,Y=$.elementId.replace(/\\/g,"\\\\").replace(/'/g,"\\'"),X=lq($),J=iq($.handler,Z),Q=[];if(Z.once)Q.push("once: true");if(Z.capture)Q.push("capture: true");if(Z.passive)Q.push("passive: true");let G=Q.length>0?`, { ${Q.join(", ")} }`:"",K=J.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");if($.event==="mounted")return`
|
|
3447
3447
|
(function() {
|
|
3448
3448
|
var $el = document.getElementById('${Y}');
|
|
3449
3449
|
if (!$el) return;
|
|
@@ -3756,7 +3756,7 @@ window.__stx_reactive = (function() {
|
|
|
3756
3756
|
|
|
3757
3757
|
return { initScope: initScope, reactive: reactive };
|
|
3758
3758
|
})();
|
|
3759
|
-
`}function iZ($,Z){let Y=$.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=h0(J,Z,!0);if(Q===void 0)return X;return String(Q)}catch{return X}});return Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{try{let Q=h0(J,Z,!0);if(Q===void 0)return X;return JSON.stringify(Q)}catch{return X}}),Y}function Yz($,Z){if($.length===0)return"";let Y=$.map((X)=>{let J=JSON.stringify(Object.fromEntries(X.refs)),Q=iZ(X.stateExpr,Z),G=X.initExpr?iZ(X.initExpr,Z):null,K=JSON.stringify(Q),q=G?JSON.stringify(G):"null";return`
|
|
3759
|
+
`}function iZ($,Z){let Y=$.replace(/\{!!([\s\S]*?)!!\}/g,(X,J)=>{try{let Q=h0(J,Z,!0);if(Q===void 0)return X;return String(Q)}catch{return X}});return Y=Y.replace(/\{\{([\s\S]*?)\}\}/g,(X,J)=>{try{let Q=h0(J,Z,!0);if(Q===void 0)return X;if(typeof Q==="string"){let G=Q.trim();if(G.startsWith("{")&&G.endsWith("}")||G.startsWith("[")&&G.endsWith("]"))try{return JSON.parse(G),G}catch{}}return JSON.stringify(Q)}catch{return X}}),Y}function Yz($,Z){if($.length===0)return"";let Y=$.map((X)=>{let J=JSON.stringify(Object.fromEntries(X.refs)),Q=iZ(X.stateExpr,Z),G=X.initExpr?iZ(X.initExpr,Z):null,K=JSON.stringify(Q),q=G?JSON.stringify(G):"null";return`
|
|
3760
3760
|
(function() {
|
|
3761
3761
|
var scopeEl = document.querySelector('${X.selector}');
|
|
3762
3762
|
if (!scopeEl) return;
|
|
@@ -3768,14 +3768,14 @@ window.__stx_reactive = (function() {
|
|
|
3768
3768
|
${Zz()}
|
|
3769
3769
|
${Y}
|
|
3770
3770
|
</script>`}function oZ($,Z,Y){if(nZ=0,!Jz($))return $;let X=aq($);if(X.length===0)return $;let J=Xz($,X),Q=Yz(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
|
|
3771
|
-
`+J.slice(G);else J+=Q;return J}function Xz($,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*["']${Q4(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*["']${Q4(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*"${Q4(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*'${Q4(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 Jz($){return/x-data\s*=\s*["']/.test($)}var nZ=0,rq=0;var sZ=C(()=>{t0()});import Qz from"fs";import T3 from"path";import{createHighlighter as Gz}from"ts-syntax-highlighter";async function Kz($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await Qz.promises.stat($)).mtime.getTime();if(Z.cache&&M3.has($)){let W=M3.get($);if(W.updatedAt>=X)return{content:W.content,data:W.data}}let J=await Bun.file($).text(),{data:Q,content:G}=e9(J),K=Z.markdown||j3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},z=C5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)z=await qz(z,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:z,data:Q||{}};if(Z.cache)M3.set($,{...U,updatedAt:X});return U}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function qz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!G4)try{G4=await Gz({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,q,z,U)=>{let W=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=z||(Y?"text":"");if(!_)return K;try{if(!G4.getSupportedLanguages().includes(_))return K;return(await G4.highlight(W,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${z}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[q,z,U,W]=K,_=await J(q,z,U,W);Q=Q.replace(q,_)}return Q}async function rZ($,Z,Y="",X={}){return await zz($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,z)=>{try{let U=K;if(!T3.isAbsolute(K))U=T3.resolve(T3.dirname(Y),K);let W={};if(q)try{try{W=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let H=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let
|
|
3771
|
+
`+J.slice(G);else J+=Q;return J}function Xz($,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*["']${Q4(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*["']${Q4(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*"${Q4(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*'${Q4(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 Jz($){return/x-data\s*=\s*["']/.test($)}var nZ=0,rq=0;var sZ=C(()=>{t0()});import Qz from"fs";import T3 from"path";import{createHighlighter as Gz}from"ts-syntax-highlighter";async function Kz($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await Qz.promises.stat($)).mtime.getTime();if(Z.cache&&M3.has($)){let W=M3.get($);if(W.updatedAt>=X)return{content:W.content,data:W.data}}let J=await Bun.file($).text(),{data:Q,content:G}=e9(J),K=Z.markdown||j3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},z=C5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)z=await qz(z,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:z,data:Q||{}};if(Z.cache)M3.set($,{...U,updatedAt:X});return U}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function qz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!G4)try{G4=await Gz({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,q,z,U)=>{let W=U.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'"),_=z||(Y?"text":"");if(!_)return K;try{if(!G4.getSupportedLanguages().includes(_))return K;return(await G4.highlight(W,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${z}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[q,z,U,W]=K,_=await J(q,z,U,W);Q=Q.replace(q,_)}return Q}async function rZ($,Z,Y="",X={}){return await zz($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,z)=>{try{let U=K;if(!T3.isAbsolute(K))U=T3.resolve(T3.dirname(Y),K);let W={};if(q)try{try{W=JSON.parse(q)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let H=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let F of H){let A=F.indexOf(":");if(A>0){let w=F.substring(0,A).trim(),R=F.substring(A+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),M=R.startsWith("'")&&R.endsWith("'");if(N||M)R=R.substring(1,R.length-1);W[w]=R}}}}catch(V){if(X.debug)console.error("Error parsing context in @markdown-file directive:",V)}let{content:_,data:B}=await Kz(U,X),j={...Z,...B,...W},O=_,L=/\{\{([^}]+)\}\}/g;return O=O.replace(L,(V,H)=>{let F=H.trim();return j[F]!==void 0?String(j[F]):V}),O}catch(U){let W=U instanceof Error?U.message:String(U);return J0("Markdown File",`Error including markdown file: ${W}`,Y,$,z,G)}})}async function zz($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],q=J.index,z=J;X.push(Y(...z).then((U)=>({match:K,replacement:U,index:q})))}let Q=await Promise.all(X);Q.sort((K,q)=>q.index-K.index);let G=$;for(let{match:K,replacement:q}of Q)G=G.replace(K,()=>q);return G}var M3,G4=null;var aZ=C(()=>{g5();w0();M3=new Map});function O1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var tZ=C(()=>{V0()});class K4{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]!==`
|
|
3772
3772
|
`)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]===`
|
|
3773
|
-
`)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 L0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function eZ($,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 I3($){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 L1($,Z){let Y=Uz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Uz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=L0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function f1($,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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function $2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=L1($,X);if(!J)return null;let Q=J.endPos,G=f1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let O=K.substring(j);if(/^@if\s*\(/.test(O)){B++,z++;continue}if(/^@endif(?![a-z])/.test(O)){B--,z+=6;continue}if(B===0){let L=O.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let F=z+L[0].length,H=L1(K,F);if(!H){z++;continue}U="elseif",W=H.expression,z=H.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(O)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function d5($){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=$2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function q4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((O)=>Q.index>O.start&&Q.index<O.end)){Q=J.exec($);continue}let K=Q.index,q=K+Q[0].length-1,z=L0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=f1($,Z,Y,W);if(_===-1){Q=J.exec($);continue}let B=$.slice(W,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function D3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=L1($,X);if(!J)return null;let Q=J.endPos,G=f1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let O=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(O&&_.startsWith("@case")){if(U)q.push(U);let H=z+O[0].length,V=L1(K,H);if(!V){z++;continue}U={type:"case",value:V.expression,content:""},z=V.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(F&&_.startsWith("@break"))z+=F[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var Z2=()=>{};function Wz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=_z($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function _z($,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 Bz($){let Z=I3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=jz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function jz($){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=L0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=J2(G);return{name:X,args:K}}function J2($){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 Hz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=L0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Oz($){let Z=[],X=new K4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=Y2(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=L0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=X2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,O=Y2(X,J,$);J=O.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,O.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:O.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;J++;let W=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){W=X[J].start;break}J++}if(W!==-1){let _=L0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=X2(X,_+1)}}}else J++}return Z}function Y2($,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 X2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var Q2=()=>{};var z4=C(()=>{Z2();Q2()});function Lz($,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=D3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,c.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function g1($,Z,Y){let X=$;X=Lz(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,q=L1(X,K+7);if(!q)break;let z=q.endPos,U=f1(X,"unless","endunless",z);if(U===-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 W=X.slice(z,U),_=q.expression,B=-1;{let O=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,H=/@else(?![a-z])/g,V=[],A;while((A=L.exec(W))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(W))!==null)V.push({pos:A.index,type:"close"});while((A=H.exec(W))!==null)V.push({pos:A.index,type:"else"});V.sort((w,R)=>w.pos-R.pos);for(let w of V)if(w.type==="open")O++;else if(w.type==="close")O--;else if(w.type==="else"&&O===0){B=w.pos;break}}let j;if(B!==-1){let O=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${O}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=k3(X,Z,Y),X=S3(X,Z,Y),X=E3(X,Z);let J=()=>{let Q=d5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,c.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=r("If",`Error processing @if block: ${z}`,c.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function G2($){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 E3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![a-z])`,"g");while(_<K.length&&W>0){B.lastIndex=_,j.lastIndex=_;let O=B.exec(K),L=j.exec(K),F=O?O.index:1/0,H=L?L.index:1/0;if(F<H)W++,_=F+O[0].length;else if(H<1/0){if(W--,W===0)return H;_=H+L[0].length}else break}return-1}function J(K,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],O;while((O=W.exec(K))!==null)j.push({pos:O.index,type:"open"});while((O=_.exec(K))!==null)j.push({pos:O.index,type:"close"});while((O=B.exec(K))!==null)j.push({pos:O.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=G2(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} has no matching @endauth \u2014 the block was skipped.`);break}let O=Y.slice(W,j),L=J(O,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?O1(`auth?.check && auth?.user?.[${U}]`,Z):O1("auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,z)+H+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=G2(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} has no matching @endguest \u2014 the block was skipped.`);break}let O=Y.slice(W,j),L=J(O,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?O1(`!auth?.check || !auth?.user?.[${U}]`,Z):O1("!auth?.check",Z);let H;if(L!==-1){let V=O.slice(0,L),A=O.slice(L+5);H=F?V:A}else H=F?O:"";Y=Y.substring(0,z)+H+Y.substring(j+9),K=!0}}function Q(K,q,z){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(q)U.push(q);if(z){let W=O1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let W=Y.match(new RegExp(`@${K}\\s*\\(`));if(!W||W.index===void 0)break;let _=W.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let O=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,O);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(O,L),H=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\s*\\(`,"g"),N=/@else(?![a-z])/g,M=[],T;while((T=A.exec(F))!==null)M.push({pos:T.index,type:"open"});while((T=w.exec(F))!==null)M.push({pos:T.index,type:"close"});while((T=R.exec(F))!==null)M.push({pos:T.index,type:"elseDirective"});while((T=N.exec(F))!==null)M.push({pos:T.index,type:"else"});M.sort((b,y)=>b.pos-y.pos);for(let b of M){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)H.push(b)}let I=[],D=0;for(let b=0;b<H.length;b++){let y=H[b];if(I.push({content:F.slice(D,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(D,y.pos)},D=y.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=H[b+1],o=m?m.pos:F.length;I.push({content:F.slice(D,o),ability:f.ability,type:f.type,id:f.id}),D=o}}else D=y.pos+5}if(D<F.length){let b=I[I.length-1];if(H.length>0&&H[H.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=I[0]?.content||"";else{let b=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)S=y.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),U=!0}}return Y}function k3($,Z,Y){let X=$;function J(Q,G,K,q,z){let U=!0;while(U){U=!1;let W=new RegExp(`@${G}\\s*\\(`),_=Q.match(W);if(!_||_.index===void 0)break;let B=_.index,j=L1(Q,B+`@${G}`.length);if(!j)break;let O=j.endPos,L=f1(Q,G,K,O);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(O,L),H=j.expression,V=-1,A=0,w=0;while(w<F.length){let R=F.indexOf("@",w);if(R===-1)break;let N=F.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){V=R;break}w=R+1}try{let R=q(H.trim()),N;if(V!==-1){let M=F.slice(0,V),T=F.slice(V+5);N=R?M:T}else N=R?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),M=r(z,`Error processing @${G} directive: ${N}`,c.EVALUATION_ERROR);Q=Q.substring(0,B)+M+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=O1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=O1(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 S3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,O=!0;while(O){O=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,H=F+L[0].length;if(K==="env"){let E=j.substring(H).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;H+=E[0].length,z=J===E[2]}let V=1,A=H,w=-1;while(V>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let E=U.exec(j),k=W.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)V++,A=S+E[0].length;else if(b<1/0){if(V--,V===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(H,w),N=-1,M=0,T=0;while(T<R.length){let E=R.indexOf("@",T);if(E===-1)break;let k=R.substring(E);if(_.test(k)){M++,T=E+1;continue}if(B.test(k)){M--,T=E+1;continue}if(M===0&&/^@else(?![a-z])/.test(k)){N=E;break}T=E+1}let I;if(N!==-1){let E=R.slice(0,N),k=R.slice(N+5);I=z?E:k}else I=z?R:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(w+D),O=!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 U4=C(()=>{tZ();K1();z4();V0()});function K2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function h1($,Z){if(!$)return Z?.nonceGenerator?.()??K2();let Y=b3.get($);if(!Y)Y=Z?.nonceGenerator?.()??K2(),b3.set($,Y);return Y}function qw($){b3.delete($)}function q2($,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 C3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${q2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function zw($){return{enabled:!0,directives:{strict:Fz,moderate:y3,relaxed:Vz,api:wz}[$]||y3,useNonce:$==="strict",addMetaTag:!0}}function Uw($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function z2($,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?h1(Y,Z):void 0,J=C3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3774
|
-
${J}`)}function Ww($,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 U2($,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?h1(Z,Q):void 0;return C3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return h1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=h1(Z,Q);return J}function _w(){return[Az,Rz]}function Bw($){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 Nz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function jw($,Z){if(!$.enabled)return{};let Y=$.useNonce?h1(Z,$):void 0,X=q2($.directives,Y);return{[Nz($.reportOnly)]:X}}var b3,Fz,y3,Vz,wz,Az,Rz,Hw;var W2=C(()=>{b3=new WeakMap;Fz={"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},y3={"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},Vz={"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'"]},wz={"default-src":["'none'"],"frame-ancestors":["'none'"]};Az={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?h1(Y,Q):void 0;return C3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Rz={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return h1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};Hw={enabled:!1,reportOnly:!1,directives:y3,useNonce:!1,addMetaTag:!0}});import{Buffer as _2}from"buffer";import B2 from"crypto";function Mz($=Tz){let Z=B2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return W5=Z,Z}function Iz(){if(!W5)Mz();return W5}function Vw(){W5=null}function ww($){W5=$}function Dz($=j2){let Z=Iz();return`<input type="hidden" name="${$}" value="${Z}">`}function H2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Dz(X||j2)})}function Aw($,Z){let Y=Z??W5;if(!Y)return!1;let X=_2.from($),J=_2.from(Y);if(X.length!==J.length)return!1;return B2.timingSafeEqual(X,J)}var Tz=40,j2="_token",W5=null;var O2=()=>{};async function L2($,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 Ez(J,Q,Z,Y,X);else J=await kz(J,Q,Z,Y,X)}return J}async function Ez($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,z=$,U=S1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),W=[],_=U.exec(z);while(_!==null){let[B,j="",O=""]=_,L=_.index||0;try{let F=j?F2(j):[],H=O.trim(),V=await G(H,F,Y,X);W.push({original:B,processed:V,startIndex:L})}catch(F){let H=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${H}`,c.EVALUATION_ERROR),startIndex:L})}_=U.exec(z)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:O}=W[B];z=z.replace(j,O)}return z}async function kz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=S1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),z=[],U=q.exec(K);while(U!==null){let[B,j=""]=U,O=U.index||0;try{let L=F2(j),F=await G("",L,Y,X);z.push({original:B,processed:F,startIndex:O})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,c.EVALUATION_ERROR),startIndex:O})}U=q.exec(K)}let W=S1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let O=await G("",[],Y,X);z.push({original:B,processed:O,startIndex:j})}catch(O){let L=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,c.EVALUATION_ERROR),startIndex:j})}_=W.exec(K)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:O}=z[B];K=K.replace(j,O)}return K}function F2($){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 V2=C(()=>{K1();$5()});var P3={};p(P3,{useTitle:()=>vz,useSeoMeta:()=>_4,usePageTitle:()=>vz,useHead:()=>m1,resetHead:()=>yz,renderHtmlAttrs:()=>fz,renderHead:()=>xz,renderBodyAttrs:()=>gz,processTitleDirective:()=>mz,processMetaDirective:()=>uz,processHeadDirective:()=>dz,getPageMeta:()=>bz,getHead:()=>m5,definePageMeta:()=>Pz,applyHead:()=>hz});function m5(){return F1}function bz(){return W4}function yz(){F1={},Sz.length=0,W4={}}function m1($){F1=Cz(F1,$)}function Cz($,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 _4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let 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 q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});m1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function Pz($){if(W4={...W4,...$},$.title||$.description)_4({title:$.title,description:$.description})}function vz($){let Z=typeof $==="function"?$():$;m1({title:Z})}function xz($=F1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${d1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${d1(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}="${d1(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}="${d1(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}="${d1(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(`
|
|
3773
|
+
`)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 L0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,q=!1;while(Q<$.length){let z=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&z==="\\"){q=!0,Q++;continue}if(q=!1,(z==='"'||z==="'"||z==="`")&&!G){G=z,Q++;continue}if(z===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&z==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&z==="}"){K--,Q++;continue}if(z==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(z===Z)J++;else if(z===Y){if(J--,J===0)return Q}Q++}return-1}function eZ($,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 I3($){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 L1($,Z){let Y=Uz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Uz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=L0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function f1($,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 q=G.exec($),z=K.exec($),U=q?q.index:1/0,W=z?z.index:1/0;if(U<W)J++,Q=U+q[0].length;else if(W<1/0){if(J--,J===0)return W;Q=W+z[0].length}else break}return-1}function $2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=L1($,X);if(!J)return null;let Q=J.endPos,G=f1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U="if",W=J.expression,_=0,B=0;while(z<K.length){let j=K.indexOf("@",z);if(j===-1)break;z=j;let O=K.substring(j);if(/^@if\s*\(/.test(O)){B++,z++;continue}if(/^@endif(?![a-z])/.test(O)){B--,z+=6;continue}if(B===0){let L=O.match(/^@elseif\s*/);if(L){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z});let V=z+L[0].length,H=L1(K,V);if(!H){z++;continue}U="elseif",W=H.expression,z=H.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(O)){q.push({type:U,condition:W,content:K.substring(_,z),start:Q+_,end:Q+z}),U="else",W=void 0,z+=5,_=z;continue}}z++}return q.push({type:U,condition:W,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function d5($){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=$2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function q4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((O)=>Q.index>O.start&&Q.index<O.end)){Q=J.exec($);continue}let K=Q.index,q=K+Q[0].length-1,z=L0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=f1($,Z,Y,W);if(_===-1){Q=J.exec($);continue}let B=$.slice(W,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:U,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function D3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=L1($,X);if(!J)return null;let Q=J.endPos,G=f1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],z=0,U=null,W=0;while(z<K.length){let _=K.slice(z),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(W++,U)U.content+=B[0];z+=B[0].length;continue}if(j){if(W--,U)U.content+=j[0];z+=j[0].length;continue}if(W>0){if(U)U.content+=K[z];z++;continue}let O=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),V=_.match(/^@break(?![a-z])/);if(O&&_.startsWith("@case")){if(U)q.push(U);let H=z+O[0].length,F=L1(K,H);if(!F){z++;continue}U={type:"case",value:F.expression,content:""},z=F.endPos}else if(L&&_.startsWith("@default")){if(U)q.push(U);U={type:"default",content:""},z+=L[0].length}else if(V&&_.startsWith("@break"))z+=V[0].length;else{if(U)U.content+=K[z];z++}}if(U)q.push(U);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var Z2=()=>{};function Wz($){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)==="{{{"?"{{{":"{!!":"{{",q=Q?K==="{{{"?"}}}":"!!}":"}}",z=G+K.length,U=_z($,z,q);if(U===-1){Y=G+1;continue}let W=$.slice(z,U).trim(),_=U+q.length;Z.push({fullMatch:$.slice(G,_),expression:W,start:G,end:_,isRaw:Q}),Y=_}return Z}function _z($,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 Bz($){let Z=I3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=jz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function jz($){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=L0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=J2(G);return{name:X,args:K}}function J2($){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 Hz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=L0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Oz($){let Z=[],X=new K4($).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 q=K.value;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let W=J<X.length?X[J].start:$.length,_=Y2(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:U,value:$.slice(W,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(z.type==="PUNCTUATION"&&(z.value==="{"||z.value==="[")){let U=z.start,W=z.value==="{"?"}":"]",_=L0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=X2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,O=Y2(X,J,$);J=O.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,O.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:O.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let q=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let z=X[J];if(z.type==="IDENTIFIER"){let U=z.value;J++;let W=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){W=X[J].start;break}J++}if(W!==-1){let _=L0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=X2(X,_+1)}}}else J++}return Z}function Y2($,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 X2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var Q2=()=>{};var z4=C(()=>{Z2();Q2()});function Lz($,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=D3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,c.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function g1($,Z,Y){let X=$;X=Lz(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,q=L1(X,K+7);if(!q)break;let z=q.endPos,U=f1(X,"unless","endunless",z);if(U===-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 W=X.slice(z,U),_=q.expression,B=-1;{let O=0,L=/@(?:if|unless)\s*\(/g,V=/@(?:endif|endunless)(?![a-z])/g,H=/@else(?![a-z])/g,F=[],A;while((A=L.exec(W))!==null)F.push({pos:A.index,type:"open"});while((A=V.exec(W))!==null)F.push({pos:A.index,type:"close"});while((A=H.exec(W))!==null)F.push({pos:A.index,type:"else"});F.sort((w,R)=>w.pos-R.pos);for(let w of F)if(w.type==="open")O++;else if(w.type==="close")O--;else if(w.type==="else"&&O===0){B=w.pos;break}}let j;if(B!==-1){let O=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${O}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=k3(X,Z,Y),X=S3(X,Z,Y),X=E3(X,Z);let J=()=>{let Q=d5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,c.EVALUATION_ERROR),z=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let z=q instanceof Error?q.message:String(q),U=r("If",`Error processing @if block: ${z}`,c.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function G2($){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 E3($,Z){let Y=$;function X(K,q,z,U){let W=1,_=U,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${z}(?![a-z])`,"g");while(_<K.length&&W>0){B.lastIndex=_,j.lastIndex=_;let O=B.exec(K),L=j.exec(K),V=O?O.index:1/0,H=L?L.index:1/0;if(V<H)W++,_=V+O[0].length;else if(H<1/0){if(W--,W===0)return H;_=H+L[0].length}else break}return-1}function J(K,q,z){let U=0,W=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${z}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],O;while((O=W.exec(K))!==null)j.push({pos:O.index,type:"open"});while((O=_.exec(K))!==null)j.push({pos:O.index,type:"close"});while((O=B.exec(K))!==null)j.push({pos:O.index,type:"else"});j.sort((L,V)=>L.pos-V.pos);for(let L of j)if(L.type==="open")U++;else if(L.type==="close")U--;else if(L.type==="else"&&U===0)return L.pos;return-1}{let K=!0;while(K){K=!1;let q=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+5),B=G2(_);if(B)U=B.value,W=z+5+B.consumed;else W=z+5;let j=X(Y,"auth","endauth",W);if(j===-1){console.warn(`[stx] @auth directive at position ${z} has no matching @endauth \u2014 the block was skipped.`);break}let O=Y.slice(W,j),L=J(O,"auth","endauth"),V;if(!Z.auth)V=!1;else V=U?O1(`auth?.check && auth?.user?.[${U}]`,Z):O1("auth?.check",Z);let H;if(L!==-1){let F=O.slice(0,L),A=O.slice(L+5);H=V?F:A}else H=V?O:"";Y=Y.substring(0,z)+H+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=G2(_);if(B)U=B.value,W=z+6+B.consumed;else W=z+6;let j=X(Y,"guest","endguest",W);if(j===-1){console.warn(`[stx] @guest directive at position ${z} has no matching @endguest \u2014 the block was skipped.`);break}let O=Y.slice(W,j),L=J(O,"guest","endguest"),V;if(!Z.auth)V=!0;else V=U?O1(`!auth?.check || !auth?.user?.[${U}]`,Z):O1("!auth?.check",Z);let H;if(L!==-1){let F=O.slice(0,L),A=O.slice(L+5);H=V?F:A}else H=V?O:"";Y=Y.substring(0,z)+H+Y.substring(j+9),K=!0}}function Q(K,q,z){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let U=[K];if(q)U.push(q);if(z){let W=O1(z,Z);U.push(W)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let q=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!q)return null;return{ability:q[1],type:q[2],id:q[3]?.trim(),paramsEnd:q[0].length}}for(let K of["can","cannot"]){let q=`end${K}`,z=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let W=Y.match(new RegExp(`@${K}\\s*\\(`));if(!W||W.index===void 0)break;let _=W.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let O=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,O);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let V=Y.slice(O,L),H=[],F=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\s*\\(`,"g"),N=/@else(?![a-z])/g,M=[],T;while((T=A.exec(V))!==null)M.push({pos:T.index,type:"open"});while((T=w.exec(V))!==null)M.push({pos:T.index,type:"close"});while((T=R.exec(V))!==null)M.push({pos:T.index,type:"elseDirective"});while((T=N.exec(V))!==null)M.push({pos:T.index,type:"else"});M.sort((b,y)=>b.pos-y.pos);for(let b of M){if(b.type==="open"){F++;continue}if(b.type==="close"){F--;continue}if(F===0)H.push(b)}let I=[],D=0;for(let b=0;b<H.length;b++){let y=H[b];if(I.push({content:V.slice(D,y.pos),ability:void 0}),y.type==="elseDirective"){let d=V.slice(y.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:V.slice(D,y.pos)},D=y.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=H[b+1],o=m?m.pos:V.length;I.push({content:V.slice(D,o),ability:f.ability,type:f.type,id:f.id}),D=o}}else D=y.pos+5}if(D<V.length){let b=I[I.length-1];if(H.length>0&&H[H.length-1].type==="else")I.push({content:V.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:V.slice(D)})}let E=Q(j.ability,j.type,j.id),k=K==="can"?E:!E,S="";if(k)S=I[0]?.content||"";else{let b=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){S=d.content,b=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){S=d.content,b=!0;break}}}if(!b&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)S=y.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),U=!0}}return Y}function k3($,Z,Y){let X=$;function J(Q,G,K,q,z){let U=!0;while(U){U=!1;let W=new RegExp(`@${G}\\s*\\(`),_=Q.match(W);if(!_||_.index===void 0)break;let B=_.index,j=L1(Q,B+`@${G}`.length);if(!j)break;let O=j.endPos,L=f1(Q,G,K,O);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let V=Q.slice(O,L),H=j.expression,F=-1,A=0,w=0;while(w<V.length){let R=V.indexOf("@",w);if(R===-1)break;let N=V.substring(R);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){A++,w=R+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){A--,w=R+1;continue}if(A===0&&/^@else(?![a-z])/.test(N)){F=R;break}w=R+1}try{let R=q(H.trim()),N;if(F!==-1){let M=V.slice(0,F),T=V.slice(F+5);N=R?M:T}else N=R?V:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),M=r(z,`Error processing @${G} directive: ${N}`,c.EVALUATION_ERROR);Q=Q.substring(0,B)+M+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=O1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=O1(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 S3($,Z,Y){let X=$,J="development";function Q(G,K,q,z){let U=new RegExp(`@${K}(?![a-z])`,"g"),W=new RegExp(`@${q}(?![a-z])`,"g"),_=new RegExp(`^@${K}(?![a-z])`),B=new RegExp(`^@${q}(?![a-z])`),j=G,O=!0;while(O){O=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let V=L.index,H=V+L[0].length;if(K==="env"){let E=j.substring(H).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;H+=E[0].length,z=J===E[2]}let F=1,A=H,w=-1;while(F>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let E=U.exec(j),k=W.exec(j),S=E?E.index:1/0,b=k?k.index:1/0;if(S<b)F++,A=S+E[0].length;else if(b<1/0){if(F--,F===0){w=b;break}A=b+k[0].length}else break}if(w===-1){console.warn(`[stx] @${K} directive at position ${V} has no matching @${q} \u2014 the block was skipped.`);break}let R=j.substring(H,w),N=-1,M=0,T=0;while(T<R.length){let E=R.indexOf("@",T);if(E===-1)break;let k=R.substring(E);if(_.test(k)){M++,T=E+1;continue}if(B.test(k)){M--,T=E+1;continue}if(M===0&&/^@else(?![a-z])/.test(k)){N=E;break}T=E+1}let I;if(N!==-1){let E=R.slice(0,N),k=R.slice(N+5);I=z?E:k}else I=z?R:"";let D=`@${q}`.length;j=j.substring(0,V)+I+j.substring(w+D),O=!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 U4=C(()=>{tZ();K1();z4();V0()});function K2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function h1($,Z){if(!$)return Z?.nonceGenerator?.()??K2();let Y=b3.get($);if(!Y)Y=Z?.nonceGenerator?.()??K2(),b3.set($,Y);return Y}function qw($){b3.delete($)}function q2($,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 C3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${q2($,Z).replace(/&/g,"&").replace(/"/g,""")}">`}function zw($){return{enabled:!0,directives:{strict:Fz,moderate:y3,relaxed:Vz,api:wz}[$]||y3,useNonce:$==="strict",addMetaTag:!0}}function Uw($,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:[],q=[...new Set([...K,...J])];Y[Q]=q}}return Y}function z2($,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?h1(Y,Z):void 0,J=C3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
|
|
3774
|
+
${J}`)}function Ww($,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 U2($,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?h1(Z,Q):void 0;return C3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return h1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=h1(Z,Q);return J}function _w(){return[Az,Rz]}function Bw($){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 Nz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function jw($,Z){if(!$.enabled)return{};let Y=$.useNonce?h1(Z,$):void 0,X=q2($.directives,Y);return{[Nz($.reportOnly)]:X}}var b3,Fz,y3,Vz,wz,Az,Rz,Hw;var W2=C(()=>{b3=new WeakMap;Fz={"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},y3={"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},Vz={"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'"]},wz={"default-src":["'none'"],"frame-ancestors":["'none'"]};Az={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?h1(Y,Q):void 0;return C3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Rz={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return h1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};Hw={enabled:!1,reportOnly:!1,directives:y3,useNonce:!1,addMetaTag:!0}});import{Buffer as _2}from"buffer";import B2 from"crypto";function Mz($=Tz){let Z=B2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return W5=Z,Z}function Iz(){if(!W5)Mz();return W5}function Vw(){W5=null}function ww($){W5=$}function Dz($=j2){let Z=Iz();return`<input type="hidden" name="${$}" value="${Z}">`}function H2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return Dz(X||j2)})}function Aw($,Z){let Y=Z??W5;if(!Y)return!1;let X=_2.from($),J=_2.from(Y);if(X.length!==J.length)return!1;return B2.timingSafeEqual(X,J)}var Tz=40,j2="_token",W5=null;var O2=()=>{};async function L2($,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 Ez(J,Q,Z,Y,X);else J=await kz(J,Q,Z,Y,X)}return J}async function Ez($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,z=$,U=S1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),W=[],_=U.exec(z);while(_!==null){let[B,j="",O=""]=_,L=_.index||0;try{let V=j?F2(j):[],H=O.trim(),F=await G(H,V,Y,X);W.push({original:B,processed:F,startIndex:L})}catch(V){let H=V instanceof Error?V.message:String(V);if(J.debug)console.error(`Error processing custom directive @${Q}:`,V);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${H}`,c.EVALUATION_ERROR),startIndex:L})}_=U.exec(z)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:O}=W[B];z=z.replace(j,O)}return z}async function kz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=S1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),z=[],U=q.exec(K);while(U!==null){let[B,j=""]=U,O=U.index||0;try{let L=F2(j),V=await G("",L,Y,X);z.push({original:B,processed:V,startIndex:O})}catch(L){let V=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${V}`,c.EVALUATION_ERROR),startIndex:O})}U=q.exec(K)}let W=S1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let O=await G("",[],Y,X);z.push({original:B,processed:O,startIndex:j})}catch(O){let L=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,c.EVALUATION_ERROR),startIndex:j})}_=W.exec(K)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:O}=z[B];K=K.replace(j,O)}return K}function F2($){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 V2=C(()=>{K1();$5()});var P3={};p(P3,{useTitle:()=>vz,useSeoMeta:()=>_4,usePageTitle:()=>vz,useHead:()=>m1,resetHead:()=>yz,renderHtmlAttrs:()=>fz,renderHead:()=>xz,renderBodyAttrs:()=>gz,processTitleDirective:()=>mz,processMetaDirective:()=>uz,processHeadDirective:()=>dz,getPageMeta:()=>bz,getHead:()=>m5,definePageMeta:()=>Pz,applyHead:()=>hz});function m5(){return F1}function bz(){return W4}function yz(){F1={},Sz.length=0,W4={}}function m1($){F1=Cz(F1,$)}function Cz($,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 _4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let 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 q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});m1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function Pz($){if(W4={...W4,...$},$.title||$.description)_4({title:$.title,description:$.description})}function vz($){let Z=typeof $==="function"?$():$;m1({title:Z})}function xz($=F1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${d1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${d1(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}="${d1(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}="${d1(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}="${d1(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(`
|
|
3775
3775
|
`)}function fz($=F1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${d1(Y)}"`).join(" ")}function gz($=F1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${d1(Y)}"`).join(" ")}function d1($){return $.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function hz($=F1){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 dz($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
|
|
3776
3776
|
`,""}),headContent:Z.trim()}}function mz($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return m1({title:G}),""})}function uz($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let q=Q?G:K,z=Q?q:Z[(q||"").trim()]??q,W=J.includes(":")?{property:J,content:z}:{name:J,content:z};return m1({meta:[W]}),""})}var F1,Sz,W4;var u5=C(()=>{F1={},Sz=[],W4={}});import pz from"crypto";function A0($){return String($??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function cz($){return{...v3,...$.forms?.classes}}function B4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function lz(){return pz.randomUUID()}function Ew($,Z,Y,X){let J=cz(X),Q=$;return Q=nz(Q,Z),Q=l5(Q,Z),Q=x3(Q,Z,J),Q=f3(Q,Z,J),Q}function l5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=lz();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${A0(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="${A0(Q)}">`;return X}),Y}function x3($,Z,Y=v3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,q,z="")=>{let U=Q||G||"POST",W=K||q||"",_=V1(z),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",O=`<form method="${A0(j)}" action="${A0(W)}"${_?` ${_}`:""}>`;if(O+=`
|
|
3777
3777
|
${l5("@csrf",Z)}`,!["GET","POST"].includes(B))O+=`
|
|
3778
|
-
${l5(`@method('${B}')`,Z)}`;return O}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,K,q,z="")=>{let U=Q||G||"",W=K||q||"",_=V1(z),B=p5(U,Z),j=B!==void 0&&B!==null?B:W||"",O=_.match(/type=['"]([^'"]+)['"]/i),L=O?O[1]:"text",
|
|
3778
|
+
${l5(`@method('${B}')`,Z)}`;return O}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(J,Q,G,K,q,z="")=>{let U=Q||G||"",W=K||q||"",_=V1(z),B=p5(U,Z),j=B!==void 0&&B!==null?B:W||"",O=_.match(/type=['"]([^'"]+)['"]/i),L=O?O[1]:"text",V=c5(U,Z),H=_.match(/class=['"]([^'"]+)['"]/i),F=B4(H?H[1]:"",Y.input,V,Y.inputError),A=_.replace(/class=['"][^'"]+['"]/i,"");return A=A.replace(/type=['"][^'"]+['"]/i,""),`<input type="${A0(L)}" name="${A0(U)}" value="${A0(j)}" class="${F}"${A?` ${A}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(J,Q,G="",K="")=>{let q=V1(G),z=p5(Q,Z)||K.trim(),U=c5(Q,Z),W=q.match(/class=['"]([^'"]+)['"]/i),_=B4(W?W[1]:"",Y.input,U,Y.inputError),B=q.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${A0(Q)}" class="${_}"${B?` ${B}`:""}>${A0(z)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(J,Q,G="",K)=>{let q=V1(G),z=p5(Q,Z),U=c5(Q,Z),W=q.match(/class=['"]([^'"]+)['"]/i),_=B4(W?W[1]:"",Y.input,U,Y.inputError),B=q.replace(/class=['"][^'"]+['"]/i,""),j=K;if(z!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(O,L,V)=>{if((Array.isArray(z)?z.some((F)=>String(F)===V):String(z)===V)&&!L.includes("selected"))return L.replace(/(<option)/,"$1 selected");return O});return`<select name="${A0(Q)}" class="${_}"${B?` ${B}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="1",K="")=>{let q=V1(K),z=p5(Q,Z),U=z!==void 0&&(Array.isArray(z)?z.some((j)=>String(j)===G):z===!0||String(z)===G),W=q.match(/class=['"]([^'"]+)['"]/i),_=W?W[1]:Y.checkInput,B=q.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${A0(Q)}" value="${A0(G)}" class="${_}"${U?" checked":""}${B?` ${B}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G,K="")=>{let q=V1(K),z=p5(Q,Z),U=z!==void 0&&z===G,W=q.match(/class=['"]([^'"]+)['"]/i),_=W?W[1]:Y.checkInput,B=q.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${A0(Q)}" value="${A0(G)}" class="${_}"${U?" checked":""}${B?` ${B}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(J,Q,G="")=>{let K=V1(G),q=K.match(/accept=['"]([^'"]+)['"]/i),z=q?q[1]:"",U=K.includes("multiple"),W=c5(Q,Z),_=K.match(/class=['"]([^'"]+)['"]/i),B=B4(_?_[1]:"",Y.input,W,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),O=[`<input type="file" name="${A0(Q)}"`,`class="${B}"`];if(z)O.push(`accept="${A0(z)}"`);if(U)O.push("multiple");if(j)O.push(j);return`${O.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(J,Q,G="",K)=>{let q=V1(G),z=q.match(/class=['"]([^'"]+)['"]/i),U=z?z[1]:Y.label,W=q.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${A0(Q)}" class="${U}"${W?` ${W}`:""}>${K}</label>`}),X}function f3($,Z,Y=v3){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,J,Q)=>{try{if(c5(J,Z))return Q.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return w2(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 w2(J,Z)}let q=K.trim();if($0(q)){let z=e(q,Z);return z!==void 0?String(z):q}return q}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),X}})}function c5($,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 w2($,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 p5($,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 V1($){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 kw($,Z){A2[$]=Z}function g3($){let[Z,...Y]=$.split(":"),X=Y.length>0?Y.join(":").split(","):[];return{name:Z.trim(),params:X}}function iz($,Z,Y,X={}){let J=[],Q=Y.split("|").map((G)=>G.trim()).filter(Boolean);for(let G of Q){let K=g3(G),q=A2[K.name];if(!q){console.warn(`Unknown validation rule: ${K.name}`);continue}if(K.name==="confirmed"){let U=`${$}_confirmation`;K.params=[X[U]]}let z=q(Z,K.params||[],$);if(z)J.push(K.message||z)}return{field:$,valid:J.length===0,errors:J}}function Sw($,Z){let Y={};for(let[X,J]of Object.entries(Z)){let Q=iz(X,$[X],J,$);if(!Q.valid)Y[X]=Q.errors}return Y}function nz($,Z){return $.replace(/@validate\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]*)\})?\s*\)/g,(Y,X,J,Q)=>{let G=J.split("|").map((q)=>q.trim()),K=[];for(let q of G){let z=g3(q);switch(z.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"'),z.name==="integer")K.push('step="1"');break;case"min":if(z.params?.[0])K.push(`minlength="${z.params[0]}"`);break;case"max":if(z.params?.[0])K.push(`maxlength="${z.params[0]}"`);break;case"regex":if(z.params?.[0])K.push(`pattern="${z.params[0]}"`);break}}return`<!-- @validate:${X}:${J} -->${K.length>0?`<!-- attrs:${K.join(" ")} -->`:""}`})}function bw($){R2[$.name]=$}function oz($,Z,Y={}){let X=[],J=Z.split("|").map((Q)=>Q.trim());for(let Q of J){let G=g3(Q),K=R2[G.name];if(!K){console.warn(`Unknown validation rule: ${G.name}`);continue}let q=K.validate($,G.params||[],Y);if(q!==!0)X.push(q)}return{valid:X.length===0,errors:X}}function yw($,Z){let Y={},X=!0;for(let[J,Q]of Object.entries(Z)){let G=oz($[J],Q,$);if(!G.valid)X=!1,Y[J]=G.errors}return{valid:X,errors:Y}}function Cw($,Z){let Y=JSON.stringify(Z);return`
|
|
3779
3779
|
<script>
|
|
3780
3780
|
(function() {
|
|
3781
3781
|
const form = document.getElementById('${$}');
|
|
@@ -3828,7 +3828,7 @@ catch { return 'Please enter a valid URL'; } },
|
|
|
3828
3828
|
});
|
|
3829
3829
|
})();
|
|
3830
3830
|
</script>`.trim()}var v3,A2,R2;var N2=C(()=>{V0();v3={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"};A2={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}};R2={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"}}});var MU={};p(MU,{waitForLocale:()=>JU,processTranslateDirective:()=>p3,preloadTranslationsBackground:()=>YU,preloadTranslations:()=>I2,loadTranslationLazy:()=>n5,loadTranslation:()=>E2,isLoading:()=>$U,isLoaded:()=>ZU,isICUFormat:()=>b2,getTranslationSync:()=>D2,getTranslationCacheStats:()=>az,getTranslationAsync:()=>XU,getTranslation:()=>j4,getLoadingState:()=>ez,getLoadingLocales:()=>QU,formatICU:()=>k2,defaultI18nConfig:()=>H4,createTranslateFilter:()=>TU,clearTranslationCache:()=>rz,cancelPendingLoads:()=>GU});import d3 from"path";async function sz(){if(i5!==void 0)return i5;try{i5=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{i5=null}return i5}function rz($){if($)delete S0[$];else for(let Z of Object.keys(S0))delete S0[Z]}function az(){let $=Object.entries(S0).map(([Z,Y])=>({locale:Z,loadedAt:new Date(Y.loadedAt),keyCount:M2(Y.translations)}));return{size:Object.keys(S0).length,locales:Object.keys(S0),entries:$}}function M2($,Z=0){for(let Y of Object.values($))if(Z++,Y&&typeof Y==="object"&&!Array.isArray(Y))Z=M2(Y,Z);return Z}function tz($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}function ez($){if(S0[$])return"loaded";return z1[$]||"idle"}function $U($){return z1[$]==="loading"}function ZU($){return!!S0[$]}async function I2($,Z){let{locales:Y,parallel:X=!0,priority:J={},onLocaleLoaded:Q,onComplete:G,onError:K}=$,q=X?Y:[...Y].sort((z,U)=>(J[U]||0)-(J[z]||0));if(X){let z=q.map(async(U)=>{try{await n5(U,Z),Q?.(U)}catch(W){K?.(U,W instanceof Error?W:Error(String(W)))}});await Promise.all(z)}else for(let z of q)try{await n5(z,Z),Q?.(z)}catch(U){K?.(z,U instanceof Error?U:Error(String(U)))}G?.()}function YU($,Z){queueMicrotask(()=>{I2($,Z).catch((Y)=>{if(Z.debug)console.error("Background preload error:",Y)})})}async function n5($,Z){if({...H4,...Z.i18n}.cache&&S0[$]){let J=S0[$],Q=Z.i18n?.cacheMaxAge??0;if(!tz(J,Q))return J.translations}if(l0[$]?.state==="loading")return l0[$].promise;z1[$]="loading";let X=m3($,Z).then((J)=>{return z1[$]="loaded",delete l0[$],J}).catch((J)=>{throw z1[$]="error",l0[$]={promise:X,state:"error",error:J instanceof Error?J:Error(String(J))},J});return l0[$]={promise:X,state:"loading"},X}function D2($){return S0[$]?.translations}async function XU($,Z){let Y=D2($);if(Y)return Y;return n5($,Z)}async function JU($,Z){if(S0[$])return S0[$].translations;if(l0[$]){if(Z)return Promise.race([l0[$].promise,new Promise((Y,X)=>setTimeout(()=>X(Error(`Timeout waiting for locale: ${$}`)),Z))]);return l0[$].promise}throw Error(`Locale "${$}" is not loading. Call loadTranslationLazy first.`)}function QU(){return Object.entries(z1).filter(([$,Z])=>Z==="loading").map(([$])=>$)}function GU($){if($)delete l0[$],delete z1[$];else{for(let Z of Object.keys(l0))delete l0[Z];for(let Z of Object.keys(z1))delete z1[Z]}}async function m3($,Z){let Y={...H4,...Z.i18n},X=d3.isAbsolute(Y.translationsDir)?Y.translationsDir:d3.resolve(Z.root||process.cwd(),Y.translationsDir);try{let J=await sz(),Q=J?await J($,{translationsDir:X,defaultLocale:Y.defaultLocale,sources:WU(Y.format)}):await KU($,Y,X);if(Q===void 0){if($!==Y.defaultLocale)return m3(Y.defaultLocale,Z);return{}}let G=Q;if(Y.cache)S0[$]={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 m3(Y.defaultLocale,Z);return{}}}async function KU($,Z,Y){let X=d3.join(Y,`${$}${qU(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 zU(Q);if(Z.format==="json")return JSON.parse(Q);throw J}catch{return}}}function qU($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function zU($){let Z={},Y=$.split(`
|
|
3831
|
-
`),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,q=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(q){let[,,z,U]=q,W=z.trim(),_=U.trim();if(_==="")K[W]={},X.push({obj:K[W],indent:G});else K[W]=UU(_)}}return Z}function UU($){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 WU($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function E2($,Z){return n5($,Z)}function _U($,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 k2($,Z={}){return S2($,Z)}function S2($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=BU($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=jU(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 BU($,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 jU($,Z){let Y=HU($);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 OU(J,Y.slice(2).join(","),Z);case"select":return FU(J,Y.slice(2).join(","));case"selectordinal":return VU(J,Y.slice(2).join(","));case"number":return AU(J,Y[2]?.trim());case"date":return RU(J,Y[2]?.trim());case"time":return NU(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function HU($){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 OU($,Z,Y){let X=Number($)||0,J=u3(Z),Q=`=${X}`;if(J[Q])return h3(J[Q],X,Y);let G=LU(X);if(J[G])return h3(J[G],X,Y);if(J.other)return h3(J.other,X,Y);return String(X)}function h3($,Z,Y){let X=$.replace(/#/g,String(Z));return S2(X,Y)}function LU($){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 FU($,Z){let Y=String($||""),X=u3(Z);if(X[Y])return X[Y];return X.other||String($)}function VU($,Z){let Y=Number($)||0,X=u3(Z),J=wU(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 wU($){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 u3($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function AU($,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 RU($,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 NU($,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 b2($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function j4($,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(b2(G))return k2(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),q=G.split("|");G=_U(q,K)}for(let[K,q]of Object.entries(X)){let z=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${z}`,"g"),String(q))}return G}async function p3($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...H4,...X.i18n},K=await E2(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await T2(J,Q,async(U,W,_,B,j)=>{try{let O={};if(_)try{let
|
|
3831
|
+
`),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,q=Q.match(/^(\s*)(\S[^:]*):\s*(.*)$/);if(q){let[,,z,U]=q,W=z.trim(),_=U.trim();if(_==="")K[W]={},X.push({obj:K[W],indent:G});else K[W]=UU(_)}}return Z}function UU($){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 WU($){switch($){case"yaml":case"yml":return["yaml"];case"js":case"ts":return["ts"];case"json":default:return["json"]}}async function E2($,Z){return n5($,Z)}function _U($,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 k2($,Z={}){return S2($,Z)}function S2($,Z){let Y="",X=0;while(X<$.length)if($[X]==="{"){let J=BU($,X);if(J===-1){Y+=$[X],X++;continue}let Q=$.slice(X+1,J);Y+=jU(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 BU($,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 jU($,Z){let Y=HU($);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 OU(J,Y.slice(2).join(","),Z);case"select":return FU(J,Y.slice(2).join(","));case"selectordinal":return VU(J,Y.slice(2).join(","));case"number":return AU(J,Y[2]?.trim());case"date":return RU(J,Y[2]?.trim());case"time":return NU(J,Y[2]?.trim());default:return J!==void 0?String(J):`{${$}}`}}function HU($){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 OU($,Z,Y){let X=Number($)||0,J=u3(Z),Q=`=${X}`;if(J[Q])return h3(J[Q],X,Y);let G=LU(X);if(J[G])return h3(J[G],X,Y);if(J.other)return h3(J.other,X,Y);return String(X)}function h3($,Z,Y){let X=$.replace(/#/g,String(Z));return S2(X,Y)}function LU($){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 FU($,Z){let Y=String($||""),X=u3(Z);if(X[Y])return X[Y];return X.other||String($)}function VU($,Z){let Y=Number($)||0,X=u3(Z),J=wU(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 wU($){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 u3($){let Z={},Y=/(\w+|=\d+)\s*\{([^{}]*(?:\{[^{}]*\}[^{}]*)*)\}/g,X=Y.exec($);while(X!==null)Z[X[1]]=X[2],X=Y.exec($);return Z}function AU($,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 RU($,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 NU($,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 b2($){return/\{[^}]+,\s*(?:plural|select|selectordinal|number|date|time)\s*,/.test($)}function j4($,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(b2(G))return k2(G,X);if(G.includes("|")&&"count"in X){let K=Number(X.count),q=G.split("|");G=_U(q,K)}for(let[K,q]of Object.entries(X)){let z=K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");G=G.replace(new RegExp(`:${z}`,"g"),String(q))}return G}async function p3($,Z,Y,X){let J=$,Q=/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)([\s\S]*?)@endtranslate/g,G={...H4,...X.i18n},K=await E2(G.locale,X);Z.__translations=K,Z.__locale=G.locale,Z.__i18nConfig=G,J=await T2(J,Q,async(U,W,_,B,j)=>{try{let O={};if(_)try{let V=[()=>JSON.parse(_),()=>{let H=`{"data":${_}}`,F=JSON.parse(H);return typeof F.data==="object"?F.data:{}},()=>{return H0(_,Z)}];for(let H of V)try{if(O=H(),Object.keys(O).length>0)break}catch{}}catch(V){if(X.debug)console.error("Error parsing parameters for @translate directive:",V)}return j4(W,K,G.fallbackToKey,O)||B.trim()}catch(O){if(X.debug)console.error("Error processing @translate directive:",O);return r("Translate",`Error in @translate('${W}'): ${O instanceof Error?O.message:String(O)}`,c.EVALUATION_ERROR)}});let q=/@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 U=[...J.matchAll(q)];console.warn(`Found ${U.length} @translate matches`),U.forEach((W,_)=>console.warn(`Match ${_}: ${W[0]}, Key: ${W[1]}, Params: ${W[2]||"none"}`))}return J=await T2(J,/@translate\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\})\s*)?\)/g,async(U,W,_,B)=>{try{let j={};if(_)try{let O=[()=>JSON.parse(_),()=>{let L=`{"data":${_}}`,V=JSON.parse(L);return typeof V.data==="object"?V.data:{}},()=>{return H0(_,Z)}];for(let L of O)try{if(j=L(),Object.keys(j).length>0)break}catch{}}catch(O){if(X.debug)console.error("Error parsing parameters for @translate directive:",O)}return j4(W,K,G.fallbackToKey,j)}catch(j){if(X.debug)console.error("Error processing @translate directive:",j);return r("Translate",`Error in @translate('${W}'): ${j instanceof Error?j.message:String(j)}`,c.EVALUATION_ERROR)}}),J}async function T2($,Z,Y){let X=[];return $.replace(Z,(Q,...G)=>{let K=Y(Q,...G).then((q)=>({match:Q,replacement:q}));return X.push(K),Q}),(await Promise.all(X)).reduce((Q,{match:G,replacement:K})=>Q.replace(G,K),$)}function TU($,Z=!0){return(Y,X={})=>{return j4(Y,$,Z,X)}}var i5,H4,S0,l0,z1;var y2=C(()=>{K1();V0();H4={defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},S0={},l0={},z1={}});var i3={};p(i3,{streamingSuspenseDirective:()=>v2,streamToResponse:()=>fU,streamTemplateSimple:()=>CU,streamTemplate:()=>DU,renderStreamingPage:()=>kU,registerStreamingDirectives:()=>vU,processStreamDirectives:()=>bU,processSectionDirectives:()=>xU,islandDirective:()=>x2,generateHydrationRuntime:()=>gU,extractStreamBoundaries:()=>yU,createStreamRenderer:()=>PU,buildSuspenseResolveScript:()=>l3,SUSPENSE_RESOLVER_RUNTIME:()=>P2});import O4 from"path";function IU($){let Z=[],Y=0,X;C2.lastIndex=0;while((X=C2.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 DU($,Z={},Y={}){let X={...x1,...Y,streaming:{...c3,...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),q=K?K[1]:"",z=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),U={...Z,__filename:$,__dirname:O4.dirname($)};if(q.trim())await i0(q,U,$);let W=IU(z),_=new Set;if(!W.some((j)=>j.type==="suspense")){let j=X.streaming?.strategy||"auto",O=new RegExp(u1.source,"g");if(!(j!=="manual"&&O.test(z))){let V=await U0(z,U,$,X,_);for(let H=0;H<V.length;H+=J)Q.enqueue(V.slice(H,H+J)),await new Promise((F)=>setTimeout(F,0))}else{let V=[],H=new RegExp(u1.source,"g"),F;while((F=H.exec(z))!==null)V.push({name:F[1],content:F[2],start:F.index,end:F.index+F[0].length});let A=0;for(let w of V){if(w.start>A){let N=z.slice(A,w.start);if(N.trim()){let M=await U0(N,U,$,X,_);Q.enqueue(M),await new Promise((T)=>setTimeout(T,0))}}let R=await U0(w.content,U,$,X,_);Q.enqueue(R),await new Promise((N)=>setTimeout(N,0)),A=w.end}if(A<z.length){let w=z.slice(A);if(w.trim()){let R=await U0(w,U,$,X,_);Q.enqueue(R)}}}}else{let j=new Map;for(let L of W)if(L.type==="shell"||L.type==="content"){let V=await U0(L.content,U,$,X,_);Q.enqueue(V)}else if(L.type==="suspense"&&L.name){let V=`stx-suspense-${L.name}`;Q.enqueue(`<div id="${V}" data-suspense="${L.name}" style="display:contents;">
|
|
3832
3832
|
<template data-suspense-fallback>Loading...</template>
|
|
3833
3833
|
</div>`),j.set(L.name,U0(L.content,U,$,X,_))}Q.enqueue(`
|
|
3834
3834
|
<script>
|
|
@@ -3846,13 +3846,13 @@ catch { return 'Please enter a valid URL'; } },
|
|
|
3846
3846
|
}
|
|
3847
3847
|
};
|
|
3848
3848
|
})();
|
|
3849
|
-
</script>`);let O=Array.from(j.entries()).map(async([L,
|
|
3849
|
+
</script>`);let O=Array.from(j.entries()).map(async([L,V])=>{Q.enqueue(await l3(L,V))});await Promise.all(O)}Q.close()}catch(G){Q.error(G)}}})}async function l3($,Z){try{let X=(await Z).replace(/`/g,"\\`").replace(/<\/script>/gi,"<\\/script>");return`
|
|
3850
3850
|
<script>
|
|
3851
3851
|
window.__stxSuspense.resolve('${$}', \`${X}\`);
|
|
3852
3852
|
</script>`}catch(Y){let X=Y instanceof Error?Y.message:String(Y);return`
|
|
3853
3853
|
<script>
|
|
3854
3854
|
window.__stxSuspense.resolve('${$}', '<div class="stx-error">Error loading content: ${m0(X)}</div>');
|
|
3855
|
-
</script>`}}function EU($,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 kU($,Z=[],Y={}){let X=Y.timeoutMs??0;return new ReadableStream({async start(J){try{if(J.enqueue($),Z.length>0)J.enqueue(P2),await Promise.all(Z.map(async(Q)=>{let G=EU(Q.render(),X,Q.id);J.enqueue(await l3(Q.id,G))}));J.close()}catch(Q){J.error(Q)}}})}function bU($,Z){return $.replace(SU,(Y,X,J)=>{let Q=X.trim(),G=J.split(/@fallback/i),K=G[0].trim(),q=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[Q]=K,`<div data-suspense="${Q}">${q}</div>`})}function yU($){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 CU($,Z={},Y={}){let X={...x1,...Y,streaming:{...c3,...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),q=K?K[1]:"",z=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),U={...Z,__filename:$,__dirname:O4.dirname($)};if(q.trim())await i0(q,U,$);let W=new Set,_=X.streaming?.strategy||"auto",B=new RegExp(u1.source,"g");if(!(_!=="manual"&&B.test(z))){let O=await U0(z,U,$,X,W);for(let L=0;L<O.length;L+=J)Q.enqueue(O.slice(L,L+J))}else{let O=[],L=new RegExp(u1.source,"g"),
|
|
3855
|
+
</script>`}}function EU($,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 kU($,Z=[],Y={}){let X=Y.timeoutMs??0;return new ReadableStream({async start(J){try{if(J.enqueue($),Z.length>0)J.enqueue(P2),await Promise.all(Z.map(async(Q)=>{let G=EU(Q.render(),X,Q.id);J.enqueue(await l3(Q.id,G))}));J.close()}catch(Q){J.error(Q)}}})}function bU($,Z){return $.replace(SU,(Y,X,J)=>{let Q=X.trim(),G=J.split(/@fallback/i),K=G[0].trim(),q=G.length>1?G.slice(1).join("@fallback").trim():"";if(!Z.__streamTemplates)Z.__streamTemplates={};return Z.__streamTemplates[Q]=K,`<div data-suspense="${Q}">${q}</div>`})}function yU($){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 CU($,Z={},Y={}){let X={...x1,...Y,streaming:{...c3,...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),q=K?K[1]:"",z=G.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),U={...Z,__filename:$,__dirname:O4.dirname($)};if(q.trim())await i0(q,U,$);let W=new Set,_=X.streaming?.strategy||"auto",B=new RegExp(u1.source,"g");if(!(_!=="manual"&&B.test(z))){let O=await U0(z,U,$,X,W);for(let L=0;L<O.length;L+=J)Q.enqueue(O.slice(L,L+J))}else{let O=[],L=new RegExp(u1.source,"g"),V;while((V=L.exec(z))!==null)O.push({name:V[1],content:V[2],start:V.index,end:V.index+V[0].length});let H=0;for(let F of O){if(F.start>H){let w=z.slice(H,F.start);if(w.trim()){let R=await U0(w,U,$,X,W);Q.enqueue(R)}}let A=await U0(F.content,U,$,X,W);Q.enqueue(A),H=F.end}if(H<z.length){let F=z.slice(H);if(F.trim()){let A=await U0(F,U,$,X,W);Q.enqueue(A)}}}Q.close()}catch(G){Q.error(G)}}})}async function PU($,Z={}){let Y={...x1,...Z,streaming:{...c3,...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,q={},z;u1.lastIndex=0;while((z=u1.exec(G))!==null){let _=z[1],B=z[2];q[_]=B}let U=G.replace(u1,"");return{renderShell:async(_={})=>{let B={..._,__filename:$,__dirname:O4.dirname($)};return await i0(Q,B,$),U0(U,B,$,Y,new Set)},renderSection:async(_,B={})=>{try{if(!q[_])return`<div class="error-message">Section "${m0(_)}" not found in template "${m0($)}"</div>`;let j={...B,__filename:$,__dirname:O4.dirname($)};await i0(Q,j,$);let O=new Set;return await U0(q[_],j,$,Y,O)}catch(j){let O=j instanceof Error?j.message:String(j);return J0("Expression",O,$,q[_]||"",0,q[_]||"")}},getSections:()=>{return Object.keys(q)},getTemplate:()=>{return K}}}function vU($={}){let Z=[];if($.streaming?.enabled)Z.push(v2);if($.hydration?.enabled)Z.push(x2);return Z}async function xU($,Z,Y,X={}){return $}function fU($,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 gU($={mode:"full"}){let{mode:Z,components:Y={},dynamicImports:X=!0}=$,J=Object.entries(Y).map(([Q,G])=>`'${Q}': ${X?`() => import('${G}')`:`require('${G}')`}`).join(`,
|
|
3856
3856
|
`);if(Z==="loader")return`
|
|
3857
3857
|
(function() {
|
|
3858
3858
|
window.__stx = window.__stx || {};
|
|
@@ -4020,8 +4020,8 @@ else {
|
|
|
4020
4020
|
${q?`{${q}}`:"{}"}
|
|
4021
4021
|
</script>
|
|
4022
4022
|
</div>`}}});var h2={};p(h2,{warnUnbalancedTags:()=>o3,findUnbalancedTags:()=>g2});function w1($){return $.replace(/[^\n]/g," ")}function g2($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,w1).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,w1).replace(/<!--[\s\S]*?-->/g,w1).replace(/\{\{\{[\s\S]*?\}\}\}/g,w1).replace(/\{\{[\s\S]*?\}\}/g,w1).replace(/\{!![\s\S]*?!!\}/g,w1).replace(/"[^"]*"/g,w1).replace(/'[^']*'/g,w1),Y=new Map,X=new Map,J=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,Q;while((Q=J.exec(Z))!==null){let K=Q[1]==="/",q=Q[2],z=Q[3]==="/";if(hU.has(q.toLowerCase()))continue;if(z)continue;if(K)X.set(q,(X.get(q)??0)+1);else{let U=Y.get(q);if(U)U.count++;else{let W=Z.slice(0,Q.index).split(`
|
|
4023
|
-
`).length;Y.set(q,{count:1,firstLine:W})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(dU.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,z=X.get(K)??0;if(q!==z)G.push({tag:K,opened:q,closed:z,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function o3($,Z){let Y;try{Y=g2($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(f2.has(X))return;f2.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let z=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${z} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var hU,dU,f2;var s3=C(()=>{hU=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),dU=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);f2=new Set});import d0 from"path";import r3 from"fs";function d2($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function m2($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class u2{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 B=[J,J.toLowerCase(),d2(J),m2(J)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${d2(J)}.stx`,`${m2(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let B=d0.resolve(d0.dirname(Z),`${J}.stx`);if(await i(B))return B;return null}let K=[],q=Y.componentsDir||"",z=X?.__originalFilePath;if(z)K.push(d0.join(d0.dirname(z),"components"));if(q)K.push(q);let U=d0.join(d0.dirname(Z),"components");if(!K.includes(U))K.push(U);let W=process.cwd(),_=[d0.resolve(W,"src/components"),d0.resolve(W,"components"),d0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let O=d0.join(B,j);if(await i(O))return O}try{if(!r3.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let O=r3.readdirSync(B,{withFileTypes:!0});for(let L of O)if(L.isDirectory()){let
|
|
4024
|
-
`}if(
|
|
4023
|
+
`).length;Y.set(q,{count:1,firstLine:W})}}}let G=[];for(let K of new Set([...Y.keys(),...X.keys()])){if(dU.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,z=X.get(K)??0;if(q!==z)G.push({tag:K,opened:q,closed:z,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function o3($,Z){let Y;try{Y=g2($)}catch{return}if(Y.length===0)return;let X=`${Z}:${$.length}`;if(f2.has(X))return;f2.add(X);let J=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let z=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${z} may swallow the content that follows it.`)}else console.warn(`[stx] ${J}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var hU,dU,f2;var s3=C(()=>{hU=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),dU=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);f2=new Set});import d0 from"path";import r3 from"fs";function d2($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function m2($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class u2{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 B=[J,J.toLowerCase(),d2(J),m2(J)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${J}.stx`,`${d2(J)}.stx`,`${m2(J)}.stx`])];if(J.startsWith("./")||J.startsWith("../")){let B=d0.resolve(d0.dirname(Z),`${J}.stx`);if(await i(B))return B;return null}let K=[],q=Y.componentsDir||"",z=X?.__originalFilePath;if(z)K.push(d0.join(d0.dirname(z),"components"));if(q)K.push(q);let U=d0.join(d0.dirname(Z),"components");if(!K.includes(U))K.push(U);let W=process.cwd(),_=[d0.resolve(W,"src/components"),d0.resolve(W,"components"),d0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let O=d0.join(B,j);if(await i(O))return O}try{if(!r3.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let O=r3.readdirSync(B,{withFileTypes:!0});for(let L of O)if(L.isDirectory()){let V=d0.join(B,L.name);for(let H of G){let F=d0.join(V,H);if(await i(F))return F}}}catch{}}return null}}var b0;var a3=C(()=>{w0();b0=new u2});function A1($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function mU($){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 t3;var e3=C(()=>{t3={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let X=mU($),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,q=[];if(X.reactive)q.push(`:href="${A1(X.value)}"`);else q.push(`href="${A1(X.value)}"`);if(J)q.push(`class="${A1(J)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${A1(Q)}"`),q.push(`data-stx-exact-active-class="${A1(G)}"`),K)q.push("data-stx-prefetch");let z=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[U,W]of Object.entries($.static)){if(z.has(U))continue;if(typeof W==="boolean"){if(W)q.push(A1(U))}else q.push(`${A1(U)}="${A1(W)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function B0($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function I0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function Z6($,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 p2($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let X of Z)if(X.includes(":")){let[J,Q]=X.split(":"),G=uU[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 Y6($,Z,Y,X){return Z.map((J)=>`${o5($,J,void 0,Y,X)} ${J}w`).join(", ")}function pU($,Z,Y,X,J){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${o5($,G,void 0,X,J)} ${Q}x`}).join(", ")}function o5($,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 cU($,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 uU,$6,X6;var J6=C(()=>{uU={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},$6=[320,640,768,1024,1280,1536,1920];X6={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let X=I0($,"src")||"",J=I0($,"alt")||"",Q=I0($,"width"),G=I0($,"height"),K=I0($,"sizes"),q=I0($,"srcset"),z=I0($,"densities"),U=I0($,"format"),W=I0($,"placeholder"),_=I0($,"placeholderColor")||"#e5e7eb",B=I0($,"provider"),j=I0($,"class")||I0($,"className")||"",O=I0($,"style")||"",L=I0($,"quality"),V=Z6($,"lazy",!0),H=Z6($,"preload",!1),F=Z6($,"picture",!1)||!!U,A=Q?Number.parseInt(Q):void 0,w=G?Number.parseInt(G):void 0,R=q||"",N="";if(!R&&K)R=Y6(X,$6,B,U),N=p2(K);else if(!R&&z){let S=z.split(/\s+/).map((b)=>Number.parseFloat(b.replace("x","")));R=pU(X,S,A,B,U)}else if(K)N=p2(K);let M=[];if(O)M.push(O);if(A&&w)M.push(`aspect-ratio:${A}/${w}`);if(W==="blur"||W==="color"||W==="thumbhash"){let S=cU(A||16,w||9,_);M.push(`background-image:url(${S})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat")}else if(W&&W!=="empty"&&W!=="none")M.push(`background-image:url(${B0(W)})`),M.push("background-size:cover"),M.push("background-repeat:no-repeat");let T=o5(X,A,w,B,U),I=[];if(I.push(`src="${B0(T)}"`),I.push(`alt="${B0(J)}"`),Q)I.push(`width="${B0(Q)}"`);if(G)I.push(`height="${B0(G)}"`);if(V)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${B0(j)}"`);if(M.length>0)I.push(`style="${B0(M.join(";"))}"`);if(R)I.push(`srcset="${B0(R)}"`);if(N)I.push(`sizes="${B0(N)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,b]of Object.entries($.static)){if(D.has(S))continue;if(typeof b==="boolean"){if(b)I.push(B0(S))}else I.push(`${B0(S)}="${B0(b)}"`)}let E=`<img ${I.join(" ")} />`,k="";if(H){let b=U==="webp"?"image/webp":U==="avif"?"image/avif":"";k=`<link rel="preload" as="image" href="${B0(T)}"${b?` type="${b}"`:""}${R?` imagesrcset="${B0(R)}"`:""}${N?` imagesizes="${B0(N)}"`:""} />
|
|
4024
|
+
`}if(F){let S=[];if(U==="avif"||U==="auto"){let b=o5(X,A,w,B,"avif"),y=R?Y6(X,$6,B,"avif"):`${b}`;S.push(`<source type="image/avif" srcset="${B0(y)}"${N?` sizes="${B0(N)}"`:""} />`)}if(U==="webp"||U==="auto"){let b=o5(X,A,w,B,"webp"),y=R?Y6(X,$6,B,"webp"):`${b}`;S.push(`<source type="image/webp" srcset="${B0(y)}"${N?` sizes="${B0(N)}"`:""} />`)}return`${k}<picture>
|
|
4025
4025
|
${S.join(`
|
|
4026
4026
|
`)}
|
|
4027
4027
|
${E}
|
|
@@ -4058,7 +4058,7 @@ ${E}
|
|
|
4058
4058
|
@media(prefers-color-scheme:dark){[data-stx-drawer]{--stx-drawer-bg:#1f2937;--stx-drawer-text:#f3f4f6}}
|
|
4059
4059
|
.stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
|
|
4060
4060
|
.stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
|
|
4061
|
-
</style>`}}});var aU={};p(aU,{preloadIconCollection:()=>s2,IconBuiltin:()=>w4});import{existsSync as nU,readFileSync as oU}from"fs";function o2($){try{return G0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(nU(Y))return Y;return null}function sU($){if(p1.has($))return p1.get($);let Z=o2($);if(!Z)return null;try{let Y=JSON.parse(oU(Z,"utf8"));return p1.set($,Y.icons),Y.icons}catch{return null}}async function rU($){if(p1.has($))return p1.get($);let Z=o2($);if(!Z)return null;try{let Y=await Bun.file(Z).json();return p1.set($,Y.icons),Y.icons}catch{return null}}function j5($,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 s2($="lucide"){await rU($)}var p1,w4;var O6=C(()=>{p1=new Map;w4={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=j5($,"name")??j5($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let H=X.split(":");J=H[0],Q=H[1]}let G=n0(j5($,"size")||"24"),K=n0(j5($,"color")||"currentColor"),q=n0(j5($,"class")||""),z=n0(j5($,"style")||""),U=p1.get(J)??sU(J);if(!U)return`<!-- Icon: collection "${J}" not loaded -->`;let W=U[Q];if(!W)return`<!-- Icon: "${Q}" not found in ${J} -->`;let _=W.width||24,B=W.height||24,j=`0 0 ${_} ${B}`,O=W.body;if(K!=="currentColor")O=O.replace(/currentColor/g,K);let L=q?` class="${q}"`:"",
|
|
4061
|
+
</style>`}}});var aU={};p(aU,{preloadIconCollection:()=>s2,IconBuiltin:()=>w4});import{existsSync as nU,readFileSync as oU}from"fs";function o2($){try{return G0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(nU(Y))return Y;return null}function sU($){if(p1.has($))return p1.get($);let Z=o2($);if(!Z)return null;try{let Y=JSON.parse(oU(Z,"utf8"));return p1.set($,Y.icons),Y.icons}catch{return null}}async function rU($){if(p1.has($))return p1.get($);let Z=o2($);if(!Z)return null;try{let Y=await Bun.file(Z).json();return p1.set($,Y.icons),Y.icons}catch{return null}}function j5($,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 s2($="lucide"){await rU($)}var p1,w4;var O6=C(()=>{p1=new Map;w4={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let X=j5($,"name")??j5($,"icon");if(!X)return"<!-- Icon: missing name/icon prop -->";let J="lucide",Q=X;if(X.includes(":")){let H=X.split(":");J=H[0],Q=H[1]}let G=n0(j5($,"size")||"24"),K=n0(j5($,"color")||"currentColor"),q=n0(j5($,"class")||""),z=n0(j5($,"style")||""),U=p1.get(J)??sU(J);if(!U)return`<!-- Icon: collection "${J}" not loaded -->`;let W=U[Q];if(!W)return`<!-- Icon: "${Q}" not found in ${J} -->`;let _=W.width||24,B=W.height||24,j=`0 0 ${_} ${B}`,O=W.body;if(K!=="currentColor")O=O.replace(/currentColor/g,K);let L=q?` class="${q}"`:"",V=z?` style="${z}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${L}${V}>${O}</svg>`}}});function tU(){return`
|
|
4062
4062
|
(function(){
|
|
4063
4063
|
var tip=null,hideTimer=null,currentEl=null;
|
|
4064
4064
|
|
|
@@ -4161,43 +4161,43 @@ document.addEventListener("focusout",function(e){
|
|
|
4161
4161
|
if(el) hideTip();
|
|
4162
4162
|
});
|
|
4163
4163
|
})();
|
|
4164
|
-
`}function r2($,...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 a2($,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 L6;var F6=C(()=>{L6={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=a2(Z,"fallback"),J=X.rest,Q=a2(J,"error"),G=Q.rest,K=X.region??r2($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',q=Q.region??r2($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${q}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function A4($,...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 V6;var w6=C(()=>{V6={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(A4($,"name")||"v").replace(/["'<>]/g,""),J=(A4($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=A4($,"class"),G=A4($,"id"),K=[`data-stx-transition-group="${X}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${J} ${K}>${Z}</${J}>`}}});function t2(){b0.registerBuiltin(t3),b0.registerBuiltin(X6),b0.registerBuiltin(Q6),b0.registerBuiltin(q6),b0.registerBuiltin(U6),b0.registerBuiltin(_6),b0.registerBuiltin(j6),b0.registerBuiltin(w4),b0.registerBuiltin(L6),b0.registerBuiltin(V6)}var e2=C(()=>{e3();J6();G6();z6();W6();B6();H6();O6();F6();w6();a3();e3();J6();G6();z6();W6();B6();H6();O6();F6();w6()});import H5 from"path";function A6($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function R6($,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 q=K[1];if(Y&&Y.has(q.toLowerCase())){let O=Q+1+q.length;while(O<$.length&&$[O]!==">")O++;J=O+1;continue}let z=Q+1+q.length,U=null,W=z,_=-1,B=!1;while(z<$.length){let O=$[z];if(U){if(O==="\\"&&z+1<$.length){z+=2;continue}if(O===U)U=null;z++;continue}if(O==='"'||O==="'"){U=O,z++;continue}if(O==="/"&&z+1<$.length&&$[z+1]===">"){_=z+2,B=!0;break}if(O===">"){_=z+1;break}z++}if(_===-1){J=Q+1;continue}let j=$.slice(W,B?_-2:_-1).trim();if(B)X.push({fullMatch:$.slice(Q,_),tagName:q,attributes:j,content:"",startIndex:Q,endIndex:_,isSelfClosing:!0}),J=_;else{let O=`<${q}`,L=`</${q}>`,
|
|
4165
|
-
`||M==="\t")
|
|
4164
|
+
`}function r2($,...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 a2($,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 L6;var F6=C(()=>{L6={name:"Suspense",aliases:["suspense"],render($,Z,Y){let X=a2(Z,"fallback"),J=X.rest,Q=a2(J,"error"),G=Q.rest,K=X.region??r2($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',q=Q.region??r2($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${q}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function A4($,...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 V6;var w6=C(()=>{V6={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let X=(A4($,"name")||"v").replace(/["'<>]/g,""),J=(A4($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=A4($,"class"),G=A4($,"id"),K=[`data-stx-transition-group="${X}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${J} ${K}>${Z}</${J}>`}}});function t2(){b0.registerBuiltin(t3),b0.registerBuiltin(X6),b0.registerBuiltin(Q6),b0.registerBuiltin(q6),b0.registerBuiltin(U6),b0.registerBuiltin(_6),b0.registerBuiltin(j6),b0.registerBuiltin(w4),b0.registerBuiltin(L6),b0.registerBuiltin(V6)}var e2=C(()=>{e3();J6();G6();z6();W6();B6();H6();O6();F6();w6();a3();e3();J6();G6();z6();W6();B6();H6();O6();F6();w6()});import H5 from"path";function A6($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function R6($,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 q=K[1];if(Y&&Y.has(q.toLowerCase())){let O=Q+1+q.length;while(O<$.length&&$[O]!==">")O++;J=O+1;continue}let z=Q+1+q.length,U=null,W=z,_=-1,B=!1;while(z<$.length){let O=$[z];if(U){if(O==="\\"&&z+1<$.length){z+=2;continue}if(O===U)U=null;z++;continue}if(O==='"'||O==="'"){U=O,z++;continue}if(O==="/"&&z+1<$.length&&$[z+1]===">"){_=z+2,B=!0;break}if(O===">"){_=z+1;break}z++}if(_===-1){J=Q+1;continue}let j=$.slice(W,B?_-2:_-1).trim();if(B)X.push({fullMatch:$.slice(Q,_),tagName:q,attributes:j,content:"",startIndex:Q,endIndex:_,isSelfClosing:!0}),J=_;else{let O=`<${q}`,L=`</${q}>`,V=1,H=_,F=-1;while(V>0&&H<$.length){let R=$.indexOf(O,H),N=$.indexOf(L,H);if(N===-1)break;if(R!==-1&&R<N){let M=$[R+O.length];if(M===" "||M===">"||M==="/"||M===`
|
|
4165
|
+
`||M==="\t")V++;H=R+O.length}else{if(V--,V===0){F=N;break}H=N+L.length}}if(F===-1){J=_;continue}let A=$.slice(_,F),w=F+L.length;X.push({fullMatch:$.slice(Q,w),tagName:q,attributes:j,content:A,startIndex:Q,endIndex:w,isSelfClosing:!1}),J=w}}return X}function N6($,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 $}}function eU($){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;if(J.startsWith("@")||J.startsWith(":")){while(Y<X&&$[Y]!=='"'&&$[Y]!=="'")Y++;if(Y<X){let Q=$[Y];Y++;while(Y<X&&$[Y]!==Q){if($[Y]==="\\")Y++;Y++}Y++}continue}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 fA($){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&&$[Y]!==G){if($[Y]==="\\"&&Y+1<X)Y++,Q+=$[Y];else Q+=$[Y];Y++}if(Y<X)Y++}else while(Y<X&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z.push({name:J,value:Q})}else Z.push({name:J,value:!0})}return Z}async function gA($,Z,Y,X){let J=$;return J=J.replace(/<stx-loading-indicator([^>]*?)(?:\s*\/>|><\/stx-loading-indicator>)/gi,(Q,G)=>{let K=G.match(/color=["']([^"']+)["']/i),q=G.match(/initial-color=["']([^"']+)["']/i),z=G.match(/height=["']([^"']+)["']/i),U=G.match(/duration=["']([^"']+)["']/i),W=G.match(/throttle=["']([^"']+)["']/i),_=G.match(/z-index=["']([^"']+)["']/i),B=(L)=>L.replace(/[;{}()]/g,"").replace(/url/gi,""),j={color:B(K?.[1]||"#6366f1"),initialColor:B(q?.[1]||""),height:B(z?.[1]||"3px"),duration:U?Number.parseInt(U[1]):2000,throttle:W?Number.parseInt(W[1]):200,zIndex:_?Number.parseInt(_[1]):999999},O=j.initialColor?`linear-gradient(to right, ${j.initialColor}, ${j.color})`:j.color;return`
|
|
4166
4166
|
<div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${j.height};background:${O};z-index:${j.zIndex};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
|
|
4167
4167
|
<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>
|
|
4168
4168
|
</div>
|
|
4169
4169
|
<style>@keyframes stx-shimmer{0%{transform:translateX(-100%)}100%{transform:translateX(100%)}}</style>
|
|
4170
4170
|
<script>
|
|
4171
4171
|
(function(){var el=document.getElementById('stx-loading-indicator'),p=0,l=!1,i=null;function u(v){p=Math.min(Math.max(v,0),100);if(el){el.style.opacity=p>0?'1':'0';el.style.transform='scaleX('+(p/100)+')'}}window.stxLoading={start:function(){l=!0;p=0;u(10);if(i)clearInterval(i);i=setInterval(function(){if(!l)return;var r=90-p,inc=Math.max(0.5,r*0.1);if(p<90)u(p+inc)},${j.throttle})},finish:function(){l=!1;if(i){clearInterval(i);i=null}u(100);setTimeout(function(){if(el)el.style.opacity='0';setTimeout(function(){p=0;if(el)el.style.transform='scaleX(0)'},300)},200)},set:function(v){u(v)},clear:function(){l=!1;p=0;if(i){clearInterval(i);i=null}if(el){el.style.opacity='0';el.style.transform='scaleX(0)'}}};document.addEventListener('click',function(e){var a=e.target.closest&&e.target.closest('a');if(!a)return;var h=a.getAttribute('href');if(!h||h.startsWith('http')||h.startsWith('#')||h.startsWith('mailto:')||h.startsWith('tel:')||a.target==='_blank')return;window.stxLoading.start()});window.addEventListener('popstate',function(){window.stxLoading.start()});window.addEventListener('load',function(){window.stxLoading.finish()})})();
|
|
4172
|
-
</script>`}),J}async function hA($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),F=null,H=[H5.resolve(H5.dirname(Y),`${_}.stx`),H5.resolve(H5.dirname(Y),_),H5.resolve(X.componentsDir||"components",`${_}.stx`),H5.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of H)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(O,F),G.set(O.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function dA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(G))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<G.length&&_>0){if(G[B]==="(")_++;else if(G[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=G.substring(W+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],H,V=j.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)H=V.slice(A[0].length).trim();let w={};if(H)try{w=H0(H,Z)}catch(E){let k=E instanceof Error?E.message:String(E);G=G.replace(G.substring(U,O),`[Error parsing component props: ${k}]`);continue}let R="",N=O,T=G.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let I=G.substring(U,N),D=await U1(F,w,R,X,Z,Y,J,K,Q);G=G.substring(0,U)+D+G.substring(N),q.lastIndex=0}return G}async function mA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=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"]),z=F$(G);return G=z.output,G=await B(G,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),G=await B(G,/[A-Z][a-zA-Z0-9]*/,!0),G=await B(G,/[a-z][a-z0-9]*/,!1,q),G=V$(G,z.scripts),G;async function B(j,O,L,F){let H=j,V=R6(H,O,F);for(let A=V.length-1;A>=0;A--){let w=V[A],R=L?A6(w.tagName):w.tagName,N=eU(w.attributes),M={};for(let[I,D]of Object.entries(N)){if(I.startsWith("@"))continue;if(I.startsWith("__stx_")){let E=I.slice(6);M[E]=N6(D,J);continue}if(I.startsWith(":")){let E=I.slice(1),k=D==="true"?E:D;try{if(!$0(k)){if(J.debug)console.error(`Unsafe expression in :${E} binding: ${k}`);M[E]=D}else{let S=Z0(k,Object.keys(Z));M[E]=S(...Object.values(Z))}}catch(S){if(J.debug)console.error(`Error evaluating :${E} binding:`,S);M[E]=D}continue}if(typeof D==="string"&&D.includes("{{")&&D.includes("}}")){let E=D.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(E)try{let k=E[1];if(!$0(k)){if(J.debug)console.error(`Unsafe expression in ${I}: ${k}`);M[I]=D}else{let S=Z0(k,Object.keys(Z));M[I]=S(...Object.values(Z))}}catch(k){if(J.debug)console.error(`Error evaluating expression for ${I}:`,k);M[I]=D}else{let k=D,S=/\{\{\s*([\s\S]+?)\s*\}\}/g,b;while((b=S.exec(D))!==null)try{let y=b[1];if(!$0(y)){if(J.debug)console.error(`Unsafe expression in ${I}: ${y}`);continue}let f=Z0(y,Object.keys(Z))(...Object.values(Z));k=k.replace(b[0],String(f??""))}catch(y){if(J.debug)console.error(`Error evaluating expression in ${I}:`,y)}M[I]=k}}else M[I]=D}let T=await U1(R,M,w.content,X,Z,Y,J,K,Q);H=H.substring(0,w.startIndex)+T+H.substring(w.endIndex)}return H}}var $Y=C(()=>{V0();w0();w$()});var GY={};p(GY,{processESImports:()=>QY,processComponents:()=>N4});import R4 from"fs";import x0 from"path";function ZW($,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,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){X.events[q]=K;continue}if(q.startsWith("__stx_")){let z=Q(q.slice(6));X.serverDynamic[z]=N6(K,Y);continue}if(q.startsWith(":")){let z=Q(q.slice(1)),U=K==="true"?z:K;try{if(!$0(U)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${U}`);X.clientReactive[z]=U;continue}let W=Object.keys(Z),B=Z0(U,W)(...Object.values(Z));if(B===void 0){let j=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!O.has(F)&&!W.includes(F))){X.clientReactive[z]=U;continue}}X.serverDynamic[z]=B}catch{X.clientReactive[z]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let z=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let U=z[1];if($0(U)){let _=Z0(U,Object.keys(Z))(...Object.values(Z));X.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${U}`);X.static[q]=K}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,U);X.static[q]=K}else{let U=K,W=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=W.exec(K))!==null)try{let B=_[1];if(!$0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let O=Z0(B,Object.keys(Z))(...Object.values(Z));U=U.replace(_[0],String(O??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}X.static[q]=U}continue}X.static[q]=K}return X}function YW($){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 YY($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function XW($){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(b0.isBuiltin(J))Z.add(J)}return[...Z].sort()}function JW($){let Z=XY.get($);if(Z)return Z;let Y=new Map,X=[x0.join($,"src"),x0.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=R4.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let q of K){let z=x0.join(Q,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;J(z,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let U=q.name.slice(0,-4);if(!Y.has(U))Y.set(U,z);let W=U.toLowerCase();if(!Y.has(W))Y.set(W,z);let _=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,z)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return XY.set($,Y),Y}function QW($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=x0.join(Y,"node_modules",$);try{if(R4.statSync(X).isDirectory())return X}catch{}let J=x0.dirname(Y);if(J===Y)return null;Y=J}}async function QY($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=x0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(z,U,W)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=W,j,O=[];while((j=_.exec(W))!==null){let[L,F,H,V]=j,A=null,w=null;if(V.startsWith(".")||V.startsWith("/")){let M=x0.resolve(G,V);if(M.endsWith(".stx"))w=M;else{let T=`${M}.stx`;try{if(R4.statSync(T).isFile())w=T}catch{try{if(R4.statSync(M).isDirectory())A=M}catch{}}}}else A=QW(V,G);if(!A&&!w)continue;let R=!1,N=(M,T)=>{Q.set(M,T),Q.set(M.toLowerCase(),T);let I=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,T),J.add(T)};if(H&&w)N(H,w),R=!0;else if(F){let M=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),T=A?JW(A):null;for(let{source:I,local:D}of M){let E=null;if(w)E=w;else if(T)E=T.get(I)??T.get(I.toLowerCase())??T.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)N(D,E),R=!0}}if(R)O.push({start:j.index,end:j.index+L.length})}if(O.length===0)return z;for(let L=O.length-1;L>=0;L--)B=B.slice(0,O[L].start)+B.slice(O[L].end);return`<script${U}>${B}</script>`}),K}async function GW($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),F=null,H=[x0.resolve(x0.dirname(Y),`${_}.stx`),x0.resolve(x0.dirname(Y),_),x0.resolve(X.componentsDir||"components",`${_}.stx`),x0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of H)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(O,F),G.set(O.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),J.add(F),X.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function KW($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(Q))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(W+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],H,V=j.slice(L[0].length),A=V.match(/^\s*,\s*/);if(A)H=V.slice(A[0].length).trim();let w={};if(H)try{w=H0(H,Z)}catch(D){let E=D instanceof Error?D.message:String(D);Q=Q.replace(Q.substring(U,O),`[Error parsing component props: ${E}]`);continue}let R="",N=O,T=Q.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let I=await U1(F,w,R,G,Z,Y,X,K,J);Q=Q.substring(0,U)+I+Q.substring(N),q.lastIndex=0}return Q}async function qW($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=F$(Q);return Q=q.output,Q=await _(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await _(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await _(Q,/[a-z][a-z0-9]*/,!1,$W),Q=V$(Q,q.scripts),Q;async function _(B,j,O,L){if(!B)return B;let F=B,H=R6(F,j,L);for(let V=H.length-1;V>=0;V--){let A=H[V],w=O?A6(A.tagName):A.tagName,R=YW(A.attributes),N=ZW(R,Z,X),M=b0.getBuiltin(A.tagName),T=M?await KY(w,G,Z,Y,X):!1;if(M&&!T){let k={context:Z,filePath:Y,options:X,dependencies:J},S=M.render(N,A.content,k);if(Object.keys(N.clientReactive).length>0)S=JY(S,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([y,d])=>`${y}="${YY(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}F=F.substring(0,A.startIndex)+S+F.substring(A.endIndex);continue}let I={};for(let[k,S]of Object.entries(N.static))I[k]=S;for(let[k,S]of Object.entries(N.serverDynamic))I[k]=S;let E=await U1(w,I,A.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)E=JY(E,N.clientReactive);if(Object.keys(N.events).length>0){let k=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(k){let S=Object.entries(N.events).map(([y,d])=>`${y}="${YY(d)}"`).join(" "),b=k[1].length+k[2].length;E=E.substring(0,b)+" "+S+E.substring(b)}}F=F.substring(0,A.startIndex)+E+F.substring(A.endIndex)}return F}}function JY($,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 N4($,Z,Y,X,J){if(!ZY)t2(),ZY=!0;let Q=await QY($,Z,Y,X,J);Q=await GW(Q,Z,Y,X,J),Q=await KW(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await qW(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=XW(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 ZY=!1,$W,XY;var T6=C(()=>{a3();e2();$Y();w0();V0();$W=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"]);XY=new Map});var T4={};p(T4,{stripTypeScript:()=>_Y,hasVariables:()=>LY,extractVariables:()=>i0,extractScriptFromTemplate:()=>OY,convertToCommonJS:()=>I6});import O5 from"path";import r5 from"process";function zW($){let Z=[],Y=0,X=$.split(`
|
|
4173
|
-
`);for(let J of X){let Q=Y,G=null,K=!1;for(let q=0;q<J.length;q++){let z=J[q];if(K){K=!1;continue}if(z==="\\"){K=!0;continue}if(G){if(z===G)G=null;continue}if(z==="'"||z==='"'||z==="`"){G=z;continue}if(z==="/"&&q+1<J.length&&J[q+1]==="/")break;if(z==="{")Y++;else if(z==="}")Y--}if(Q===0){let q=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(q)Z.push(q[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let z=J.match(/(?:const|let|var)\s+(\w+)/);if(z)Z.push(z[1])}else{let z=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(z){let W=z[1].slice(1,-1).split(",").map((_)=>{let B=_.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((_)=>/^\w+$/.test(_));Z.push(...W)}}}}return[...new Set(Z)]}function _Y($){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,q=null;for(let z=0;z<X.length;z++){let U=X[z];if(q){if(Q+=U,U===q)q=null;continue}if(U==='"'||U==="'"||U==="`"){q=U,Q+=U;continue}if(U==="<")G++;else if(U===">"&&G>0)G--;else if(U==="(")K++;else if(U===")")K--;if(U===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=U}if(Q)J.push(Q);return J.map((z)=>{let U=z.trim(),W=U.startsWith("..."),_=W?U.slice(3):U,B=-1,j=0;for(let w=0;w<_.length;w++)if(_[w]==="<")j++;else if(_[w]===">")j--;else if(_[w]===":"&&j===0){B=w;break}if(B===-1)return z;let L=_.substring(0,B).trim().replace(/\?$/,""),
|
|
4172
|
+
</script>`}),J}async function hA($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),V=null,H=[H5.resolve(H5.dirname(Y),`${_}.stx`),H5.resolve(H5.dirname(Y),_),H5.resolve(X.componentsDir||"components",`${_}.stx`),H5.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let F of H)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(L,V),G.set(O,V),G.set(O.toLowerCase(),V);let F=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),J.add(V),X.debug)console.log(`Imported component: ${L} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function dA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(G))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<G.length&&_>0){if(G[B]==="(")_++;else if(G[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=G.substring(W+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let V=L[1],H,F=j.slice(L[0].length),A=F.match(/^\s*,\s*/);if(A)H=F.slice(A[0].length).trim();let w={};if(H)try{w=H0(H,Z)}catch(E){let k=E instanceof Error?E.message:String(E);G=G.replace(G.substring(U,O),`[Error parsing component props: ${k}]`);continue}let R="",N=O,T=G.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let I=G.substring(U,N),D=await U1(V,w,R,X,Z,Y,J,K,Q);G=G.substring(0,U)+D+G.substring(N),q.lastIndex=0}return G}async function mA($,Z,Y,X,J,Q){let G=$;if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=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"]),z=F$(G);return G=z.output,G=await B(G,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),G=await B(G,/[A-Z][a-zA-Z0-9]*/,!0),G=await B(G,/[a-z][a-z0-9]*/,!1,q),G=V$(G,z.scripts),G;async function B(j,O,L,V){let H=j,F=R6(H,O,V);for(let A=F.length-1;A>=0;A--){let w=F[A],R=L?A6(w.tagName):w.tagName,N=eU(w.attributes),M={};for(let[I,D]of Object.entries(N)){if(I.startsWith("@"))continue;if(I.startsWith("__stx_")){let E=I.slice(6);M[E]=N6(D,J);continue}if(I.startsWith(":")){let E=I.slice(1),k=D==="true"?E:D;try{if(!$0(k)){if(J.debug)console.error(`Unsafe expression in :${E} binding: ${k}`);M[E]=D}else{let S=Z0(k,Object.keys(Z));M[E]=S(...Object.values(Z))}}catch(S){if(J.debug)console.error(`Error evaluating :${E} binding:`,S);M[E]=D}continue}if(typeof D==="string"&&D.includes("{{")&&D.includes("}}")){let E=D.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(E)try{let k=E[1];if(!$0(k)){if(J.debug)console.error(`Unsafe expression in ${I}: ${k}`);M[I]=D}else{let S=Z0(k,Object.keys(Z));M[I]=S(...Object.values(Z))}}catch(k){if(J.debug)console.error(`Error evaluating expression for ${I}:`,k);M[I]=D}else{let k=D,S=/\{\{\s*([\s\S]+?)\s*\}\}/g,b;while((b=S.exec(D))!==null)try{let y=b[1];if(!$0(y)){if(J.debug)console.error(`Unsafe expression in ${I}: ${y}`);continue}let f=Z0(y,Object.keys(Z))(...Object.values(Z));k=k.replace(b[0],String(f??""))}catch(y){if(J.debug)console.error(`Error evaluating expression in ${I}:`,y)}M[I]=k}}else M[I]=D}let T=await U1(R,M,w.content,X,Z,Y,J,K,Q);H=H.substring(0,w.startIndex)+T+H.substring(w.endIndex)}return H}}var $Y=C(()=>{V0();w0();w$()});var GY={};p(GY,{processESImports:()=>QY,processComponents:()=>N4});import R4 from"fs";import x0 from"path";function ZW($,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,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!J.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){X.events[q]=K;continue}if(q.startsWith("__stx_")){let z=Q(q.slice(6));X.serverDynamic[z]=N6(K,Y);continue}if(q.startsWith(":")){let z=Q(q.slice(1)),U=K==="true"?z:K;try{if(!$0(U)){if(Y.debug)console.error(`Unsafe expression in :${z} binding: ${U}`);X.clientReactive[z]=U;continue}let W=Object.keys(Z),B=Z0(U,W)(...Object.values(Z));if(B===void 0){let j=U.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],O=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((V)=>!O.has(V)&&!W.includes(V))){X.clientReactive[z]=U;continue}}X.serverDynamic[z]=B}catch{X.clientReactive[z]=U}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let z=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(z)try{let U=z[1];if($0(U)){let _=Z0(U,Object.keys(Z))(...Object.values(Z));X.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${U}`);X.static[q]=K}}catch(U){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,U);X.static[q]=K}else{let U=K,W=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=W.exec(K))!==null)try{let B=_[1];if(!$0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let O=Z0(B,Object.keys(Z))(...Object.values(Z));U=U.replace(_[0],String(O??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}X.static[q]=U}continue}X.static[q]=K}return X}function YW($){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 YY($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function XW($){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(b0.isBuiltin(J))Z.add(J)}return[...Z].sort()}function JW($){let Z=XY.get($);if(Z)return Z;let Y=new Map,X=[x0.join($,"src"),x0.join($,"dist"),$];function J(Q,G){if(G>6)return;let K;try{K=R4.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let q of K){let z=x0.join(Q,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;J(z,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let U=q.name.slice(0,-4);if(!Y.has(U))Y.set(U,z);let W=U.toLowerCase();if(!Y.has(W))Y.set(W,z);let _=U.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,z)}}}for(let Q of X)if(J(Q,0),Y.size>0)break;return XY.set($,Y),Y}function QW($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let X=x0.join(Y,"node_modules",$);try{if(R4.statSync(X).isDirectory())return X}catch{}let J=x0.dirname(Y);if(J===Y)return null;Y=J}}async function QY($,Z,Y,X,J){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=x0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(z,U,W)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=W,j,O=[];while((j=_.exec(W))!==null){let[L,V,H,F]=j,A=null,w=null;if(F.startsWith(".")||F.startsWith("/")){let M=x0.resolve(G,F);if(M.endsWith(".stx"))w=M;else{let T=`${M}.stx`;try{if(R4.statSync(T).isFile())w=T}catch{try{if(R4.statSync(M).isDirectory())A=M}catch{}}}}else A=QW(F,G);if(!A&&!w)continue;let R=!1,N=(M,T)=>{Q.set(M,T),Q.set(M.toLowerCase(),T);let I=M.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,T),J.add(T)};if(H&&w)N(H,w),R=!0;else if(V){let M=V.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),T=A?JW(A):null;for(let{source:I,local:D}of M){let E=null;if(w)E=w;else if(T)E=T.get(I)??T.get(I.toLowerCase())??T.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)N(D,E),R=!0}}if(R)O.push({start:j.index,end:j.index+L.length})}if(O.length===0)return z;for(let L=O.length-1;L>=0;L--)B=B.slice(0,O[L].start)+B.slice(O[L].end);return`<script${U}>${B}</script>`}),K}async function GW($,Z,Y,X,J){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[z,U]=q,W=U.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of W){let B=_.split("/"),O=B[B.length-1].replace(/\.stx$/,""),L=O.includes("-")?O.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""):O.charAt(0).toUpperCase()+O.slice(1),V=null,H=[x0.resolve(x0.dirname(Y),`${_}.stx`),x0.resolve(x0.dirname(Y),_),x0.resolve(X.componentsDir||"components",`${_}.stx`),x0.resolve(X.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let F of H)try{if(await Bun.file(F).exists()){V=F;break}}catch{}if(V){G.set(L,V),G.set(O,V),G.set(O.toLowerCase(),V);let F=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(F,V),J.add(V),X.debug)console.log(`Imported component: ${L} -> ${V}`)}else if(X.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(z,""),K.lastIndex=0}return Q}async function KW($,Z,Y,X,J){let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,z;while((z=q.exec(Q))!==null){let U=z.index,W=U+z[0].length-1,_=1,B=W+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(W+1,B),O=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let V=L[1],H,F=j.slice(L[0].length),A=F.match(/^\s*,\s*/);if(A)H=F.slice(A[0].length).trim();let w={};if(H)try{w=H0(H,Z)}catch(D){let E=D instanceof Error?D.message:String(D);Q=Q.replace(Q.substring(U,O),`[Error parsing component props: ${E}]`);continue}let R="",N=O,T=Q.substring(O).match(/^([\s\S]*?)@endcomponent/);if(T)R=T[1].trim(),N=O+T[0].length;let I=await U1(V,w,R,G,Z,Y,X,K,J);Q=Q.substring(0,U)+I+Q.substring(N),q.lastIndex=0}return Q}async function qW($,Z,Y,X,J){if(!$)return $;let Q=$,G=X.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=F$(Q);return Q=q.output,Q=await _(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await _(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await _(Q,/[a-z][a-z0-9]*/,!1,$W),Q=V$(Q,q.scripts),Q;async function _(B,j,O,L){if(!B)return B;let V=B,H=R6(V,j,L);for(let F=H.length-1;F>=0;F--){let A=H[F],w=O?A6(A.tagName):A.tagName,R=YW(A.attributes),N=ZW(R,Z,X),M=b0.getBuiltin(A.tagName),T=M?await KY(w,G,Z,Y,X):!1;if(M&&!T){let k={context:Z,filePath:Y,options:X,dependencies:J},S=M.render(N,A.content,k);if(Object.keys(N.clientReactive).length>0)S=JY(S,N.clientReactive);if(Object.keys(N.events).length>0){let b=Object.entries(N.events).map(([y,d])=>`${y}="${YY(d)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${b}`)}V=V.substring(0,A.startIndex)+S+V.substring(A.endIndex);continue}let I={};for(let[k,S]of Object.entries(N.static))I[k]=S;for(let[k,S]of Object.entries(N.serverDynamic))I[k]=S;let E=await U1(w,I,A.content,G,Z,Y,X,K,J);if(Object.keys(N.clientReactive).length>0)E=JY(E,N.clientReactive);if(Object.keys(N.events).length>0){let k=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(k){let S=Object.entries(N.events).map(([y,d])=>`${y}="${YY(d)}"`).join(" "),b=k[1].length+k[2].length;E=E.substring(0,b)+" "+S+E.substring(b)}}V=V.substring(0,A.startIndex)+E+V.substring(A.endIndex)}return V}}function JY($,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 N4($,Z,Y,X,J){if(!ZY)t2(),ZY=!0;let Q=await QY($,Z,Y,X,J);Q=await GW(Q,Z,Y,X,J),Q=await KW(Q,Z,Y,X,J);for(let G=0;G<3;G++){let K=Q;if(Q=await qW(Q,Z,Y,X,J),Q===K)break}if(X.debug){let G=XW(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 ZY=!1,$W,XY;var T6=C(()=>{a3();e2();$Y();w0();V0();$W=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"]);XY=new Map});var T4={};p(T4,{stripTypeScript:()=>_Y,hasVariables:()=>LY,extractVariables:()=>i0,extractScriptFromTemplate:()=>OY,convertToCommonJS:()=>I6});import O5 from"path";import r5 from"process";function zW($){let Z=[],Y=0,X=$.split(`
|
|
4173
|
+
`);for(let J of X){let Q=Y,G=null,K=!1;for(let q=0;q<J.length;q++){let z=J[q];if(K){K=!1;continue}if(z==="\\"){K=!0;continue}if(G){if(z===G)G=null;continue}if(z==="'"||z==='"'||z==="`"){G=z;continue}if(z==="/"&&q+1<J.length&&J[q+1]==="/")break;if(z==="{")Y++;else if(z==="}")Y--}if(Q===0){let q=J.match(/(?:const|let|var)\s+(\w+)\s*=/);if(q)Z.push(q[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(J)){let z=J.match(/(?:const|let|var)\s+(\w+)/);if(z)Z.push(z[1])}else{let z=J.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(z){let W=z[1].slice(1,-1).split(",").map((_)=>{let B=_.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((_)=>/^\w+$/.test(_));Z.push(...W)}}}}return[...new Set(Z)]}function _Y($){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,q=null;for(let z=0;z<X.length;z++){let U=X[z];if(q){if(Q+=U,U===q)q=null;continue}if(U==='"'||U==="'"||U==="`"){q=U,Q+=U;continue}if(U==="<")G++;else if(U===">"&&G>0)G--;else if(U==="(")K++;else if(U===")")K--;if(U===","&&G===0&&K===0){J.push(Q),Q="";continue}Q+=U}if(Q)J.push(Q);return J.map((z)=>{let U=z.trim(),W=U.startsWith("..."),_=W?U.slice(3):U,B=-1,j=0;for(let w=0;w<_.length;w++)if(_[w]==="<")j++;else if(_[w]===">")j--;else if(_[w]===":"&&j===0){B=w;break}if(B===-1)return z;let L=_.substring(0,B).trim().replace(/\?$/,""),V=_.substring(B+1),H=-1,F=0;for(let w=0;w<V.length;w++)if(V[w]==="<")F++;else if(V[w]===">")F--;else if(V[w]==="="&&F===0){H=w;break}let A=W?"...":"";if(H!==-1)return`${A}${L} = ${V.substring(H+1).trim()}`;return`${A}${L}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(X,J,Q)=>{if(!Q.includes(":"))return X;return`${J}(${Y(Q)})`});{let X=/\b(function\s+\w*\s*)\(/g,J,Q=[];while((J=X.exec(Z))!==null){let G=J.index+J[0].length-1,K=1,q=G+1,z=0,U=null;while(q<Z.length&&K>0){let B=Z[q];if(U){if(B===U)U=null;q++;continue}if(B==='"'||B==="'"||B==="`"){U=B,q++;continue}if(B==="<")z++;else if(B===">"&&z>0)z--;else if(z===0){if(B==="(")K++;else if(B===")")K--}if(K>0)q++}if(K!==0)continue;let W=Z.substring(G+1,q);if(!W.includes(":"))continue;let _=Y(W);Q.push({start:G+1,end:q,replacement:_})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:z}=Q[G];Z=Z.substring(0,K)+z+Z.substring(q)}}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,...q]=G.split("="),z=K.split(":")[0].trim();if(q.length>0)return`${z} = ${q.join("=").trim()}`;return z}).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,`
|
|
4174
4174
|
|
|
4175
|
-
`),Z}async function i0($,Z,Y,X={}){if(!$.trim())return;let J;try{let P=new Bun.Transpiler({loader:"ts",target:"browser",define:r0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=P.transformSync(v)}catch{J=_Y($)}let Q={exports:{}},G=Q.exports,K=r5.cwd(),q={},z=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((P)=>P[1]).filter((P)=>!P.startsWith("node:")&&!P.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(P));for(let P of z)try{let v=O5.resolve(K,"node_modules",P),x=O5.join(v,"package.json"),g=JSON.parse(G0("fs").readFileSync(x,"utf8")),u=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")u=s;else if(s?.bun)u=s.bun;else if(s?.import)u=s.import;else if(s?.default)u=s.default}q[P]=await import(O5.resolve(v,u))}catch{}let U=(P)=>{if(q[P])return q[P];return G0(P)},W=Z.props||{},_=Object.assign((P)=>{if(!P)return W;let v={};for(let[x,g]of Object.entries(P)){let u=W[x];if(u!==void 0)v[x]=u;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},W),B=(P)=>{if(!P)return W;let v={...W};for(let[x,g]of Object.entries(P)){let u=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&u.default!==void 0)v[x]=typeof u.default==="function"?u.default():u.default}return v},j=()=>Z.slots||{},O=(P,v)=>{let x={...P};for(let[g,u]of Object.entries(v))if(x[g]===void 0)if(typeof u==="function")x[g]=u();else x[g]=u;return x},L=(P)=>{let v=()=>P;return v.set=(x)=>{},v.update=(x)=>{},v},
|
|
4175
|
+
`),Z}async function i0($,Z,Y,X={}){if(!$.trim())return;let J;try{let P=new Bun.Transpiler({loader:"ts",target:"browser",define:r0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),J=P.transformSync(v)}catch{J=_Y($)}let Q={exports:{}},G=Q.exports,K=r5.cwd(),q={},z=[...J.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((P)=>P[1]).filter((P)=>!P.startsWith("node:")&&!P.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(P));for(let P of z)try{let v=O5.resolve(K,"node_modules",P),x=O5.join(v,"package.json"),g=JSON.parse(G0("fs").readFileSync(x,"utf8")),u=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")u=s;else if(s?.bun)u=s.bun;else if(s?.import)u=s.import;else if(s?.default)u=s.default}q[P]=await import(O5.resolve(v,u))}catch{}let U=(P)=>{if(q[P])return q[P];return G0(P)},W=Z.props||{},_=Object.assign((P)=>{if(!P)return W;let v={};for(let[x,g]of Object.entries(P)){let u=W[x];if(u!==void 0)v[x]=u;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},W),B=(P)=>{if(!P)return W;let v={...W};for(let[x,g]of Object.entries(P)){let u=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&u.default!==void 0)v[x]=typeof u.default==="function"?u.default():u.default}return v},j=()=>Z.slots||{},O=(P,v)=>{let x={...P};for(let[g,u]of Object.entries(v))if(x[g]===void 0)if(typeof u==="function")x[g]=u();else x[g]=u;return x},L=(P)=>{let v=()=>P;return v.set=(x)=>{},v.update=(x)=>{},v},V=(P)=>{let v,x=!1;return()=>{if(!x)try{v=P(),x=!0}catch{v=void 0}return v}},H=(P)=>{},F=(P)=>P(),A=(P)=>{},w=(P)=>{},R=(P)=>{},N=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),M=()=>({push:(P)=>{},replace:(P)=>{},back:()=>{},forward:()=>{},go:(P)=>{}}),T=(P)=>{m1(P);let v=Z.__stx_runtime_head||{},x=P||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(P)=>{_4(P);let v=m5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(P)=>({value:P}),E=(P)=>P,k=(P)=>({value:typeof P==="function"?P():P}),S=(P,v)=>{},b=(P)=>{},y=(P)=>{},d=(P)=>P?P():Promise.resolve(),f=(P)=>(v,...x)=>{},m=(P)=>{},o=(P,v)=>{},N0=(P,v)=>v,X1=()=>({value:"light"}),C0=()=>({value:!1}),E0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},X0=new Proxy(E0,{get(P,v){if(v in P)return P[v];return},set(P,v,x){return P[v]=x,!0}}),F0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},W0=console;try{let P=I6(J,Y),v=new Set(Object.keys(W)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),u=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),s=[],Q0=[];for(let[t,s0]of Object.entries(W)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(u.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(P))continue;s.push(t),Q0.push(s0)}let P0=zW(P).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
|
|
4176
4176
|
`),D1=Z.params??{},z0=[],E1=[];for(let t=0;t<x.length;t++){if(x[t]==="params")continue;z0.push(x[t]),E1.push(g[t])}let K$=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",...s,...z0,`return (async () => {
|
|
4177
4177
|
${P}
|
|
4178
4178
|
${P0}
|
|
4179
4179
|
return module.exports
|
|
4180
|
-
})()`)(Q,G,U,W,_,B,O,L,
|
|
4180
|
+
})()`)(Q,G,U,W,_,B,O,L,V,H,F,A,w,R,N,M,T,I,D,E,k,S,b,y,d,f,m,j,o,N0,X1,C0,X0,F0,W0,E0.confirm,E0.alert,E0.fetch,D1,...Q0,...E1);if(X.preserveExisting){for(let[t,s0]of Object.entries(K$))if(!(t in Z)||Z[t]===void 0)Z[t]=s0}else Object.assign(Z,K$);for(let[t,s0]of Object.entries(W))if(!(t in Z))Z[t]=s0}catch(P){if(r5.env.STX_DEBUG){let v=P instanceof Error?P.message:String(P);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await jW(J,Z,Y)}catch(v){if(r5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function I6($,Z){let Y=Z?O5.dirname(Z):r5.cwd(),X=$.split(`
|
|
4181
4181
|
`),J=[],Q=0;while(Q<X.length){let G=X[Q].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;Q<X.length;Q++){for(let q of X[Q])if(q==="{")K++;else if(q==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,q=!1;for(let z=Q;z<X.length&&!q;z++){let U=null,W=!1,_=X[z];for(let B=0;B<_.length;B++){let j=_[B];if(W){W=!1;continue}if(j==="\\"){W=!0;continue}if(U){if(j===U)U=null;continue}if(j==='"'||j==="'"||j==="`"){U=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=z+1,q=!0;break}}}}if(!q)Q=X.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),q=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),z=G.match(/^import\s+['"](.+)['"]/),U=(W)=>{if(W.startsWith("."))return O5.resolve(Y,W);return W};if(K){let[,W,_]=K,B=U(_);J.push(`const ${W} = await import('${B}')`),J.push(`module.exports.${W} = ${W};`)}else if(q){let[,W,_]=q,B=W.trim(),j=U(_);J.push(`const { ${B} } = await import('${j}')`);for(let O of B.split(",")){let L=O.trim().split(/\s+as\s+/).pop()?.trim();if(L)J.push(`module.exports.${L} = ${L};`)}}else if(z){let W=U(z[1]);J.push(`await import('${W}')`)}else J.push(G);Q++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))J.push(X[Q]),Q++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=qY(X,Q),{type:q,name:z,value:U}=K;J.push(`${q} ${z} = ${U};`),J.push(`module.exports.${z} = ${z};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=M6(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=qY(X,Q),{type:q,name:z,value:U}=K;J.push(`${q} ${z} = ${U};`),J.push(`module.exports.${z} = ${z};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=M6(X,Q);J.push(K.functionCode),J.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=X[Q].replace(/^(\s*)export\s+default\s+/,"$1"),q=[...X];q[Q]=K;let z=M6(q,Q);if(J.push(z.functionCode),z.name)J.push(`module.exports.default = ${z.name};`);Q=z.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");J.push(`module.exports.default = ${K};`),Q++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let q=K[1],z=X[Q].replace(/^export\s+/,""),U=0,W=Q;for(;W<X.length;W++){let _=X[W];for(let B of _)if(B==="{")U++;else if(B==="}")U--;if(W>Q)z+=`
|
|
4182
4182
|
`+_;if(U<=0&&W>=Q)break}J.push(z),J.push(`module.exports.${q} = ${q};`),Q=W+1}else J.push(G),Q++}else if(G.includes("module.exports"))J.push(G),Q++;else if(G.trim()&&!G.startsWith("//"))J.push(G),Q++;else Q++}return UW(J.join(`
|
|
4183
4183
|
`),Y)}function UW($,Z){let Y=$.length,X="",J=0,Q=null,G=!1,K=!1,q=0;while(J<Y){let z=$[J],U=$[J+1];if(G){if(X+=z,z===`
|
|
4184
|
-
`)G=!1;J++;continue}if(K){if(X+=z,z==="*"&&U==="/"){X+=U,J+=2,K=!1;continue}J++;continue}if(!Q&&z==="/"&&U==="/"){G=!0,X+=z,J++;continue}if(!Q&&z==="/"&&U==="*"){K=!0,X+=z,J++;continue}if(Q){if(X+=z,z==="\\"){X+=U,J+=2;continue}if(z===Q&&Q!=="`"){Q=null,J++;continue}if(Q==="`"){if(z==="$"&&U==="{"){q++,X+=U,J+=2;continue}if(z==="`"){Q=null,J++;continue}}J++;continue}if(q>0){if(z==="{")q++;else if(z==="}")q--}if(z==='"'||z==="'"||z==="`"){Q=z,X+=z,J++;continue}if(z==="a"&&$.startsWith("await",J)){let W=WW($,J);if(W){let{quote:_,path:B,end:j}=W;if(B.startsWith(".")){let O=O5.resolve(Z,B);X+=`await import(${_}${O}${_})`,J=j;continue}}}X+=z,J++}return X}function WW($,Z){let Y=Z+5;if(Y>=$.length)return null;if(!/\s/.test($[Y]))return null;while(Y<$.length&&/\s/.test($[Y]))Y++;if(!$.startsWith("import",Y))return null;Y+=6;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;let X=$[Y];if(X!=="'"&&X!=='"')return null;Y++;let J=Y;while(Y<$.length&&$[Y]!==X)if($[Y]==="\\")Y+=2;else Y++;if(Y>=$.length)return null;let Q=$.slice(J,Y);Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!==")")return null;return{quote:X,path:Q,end:Y+1}}function BY($,Z){let Y=$[Z];if(Y!=="{"&&Y!=="[")return null;let J=L0($,Y,Y==="{"?"}":"]",Z);if(J===-1)return null;return{pattern:$.slice(Z,J+1),endPos:J+1}}function jY($){let Z=[],Y=$.slice(1,-1).trim();if(!Y)return Z;let X=0,J=0,Q="";while(X<Y.length){let G=Y[X];if(G==="{"||G==="["){if(J++,J===1){let K=BY(Y,X);if(K){let q=jY(K.pattern);Z.push(...q),X=K.endPos,Q="";continue}}}else if(G==="}"||G==="]")J--;if(J>0){X++;continue}if(G===","){if(Q.trim())Z.push(Q.trim());Q="",X++;continue}if(G===":"){Q="",X++;continue}if(G==="="){if(Q.trim())Z.push(Q.trim());Q="",X++;while(X<Y.length&&Y[X]!==","&&J===0){if(Y[X]==="{"||Y[X]==="[")J++;else if(Y[X]==="}"||Y[X]==="]")J--;X++}continue}if(/[\w$]/.test(G))Q+=G;X++}if(Q.trim())Z.push(Q.trim());return Z}function qY($,Z){let Y=$[Z].trim(),X=Y.match(/^(?:export\s+)?(const|let|var)\s+(\w+)\s*=\s*(.*)$/);if(!X){let z=Y.match(/^(?:export\s+)?(const|let|var)\s+/);if(z){let U=Y.slice(z[0].length),W=Z;if((U.startsWith("{")||U.startsWith("["))&&!U.includes(U.startsWith("{")?"}":"]")){let B=U.startsWith("{")?"}":"]",j=U;for(let O=Z+1;O<$.length;O++)if(j+=" "+$[O].trim(),W=O,$[O].includes(B))break;U=j}let _=BY(U,0);if(_){let B=z[1],j=_.pattern,O=U.slice(_.endPos).trim();if(O.startsWith("=")){let L=O.slice(1).trim(),
|
|
4185
|
-
`);return{type:B,name:A,value:`${
|
|
4184
|
+
`)G=!1;J++;continue}if(K){if(X+=z,z==="*"&&U==="/"){X+=U,J+=2,K=!1;continue}J++;continue}if(!Q&&z==="/"&&U==="/"){G=!0,X+=z,J++;continue}if(!Q&&z==="/"&&U==="*"){K=!0,X+=z,J++;continue}if(Q){if(X+=z,z==="\\"){X+=U,J+=2;continue}if(z===Q&&Q!=="`"){Q=null,J++;continue}if(Q==="`"){if(z==="$"&&U==="{"){q++,X+=U,J+=2;continue}if(z==="`"){Q=null,J++;continue}}J++;continue}if(q>0){if(z==="{")q++;else if(z==="}")q--}if(z==='"'||z==="'"||z==="`"){Q=z,X+=z,J++;continue}if(z==="a"&&$.startsWith("await",J)){let W=WW($,J);if(W){let{quote:_,path:B,end:j}=W;if(B.startsWith(".")){let O=O5.resolve(Z,B);X+=`await import(${_}${O}${_})`,J=j;continue}}}X+=z,J++}return X}function WW($,Z){let Y=Z+5;if(Y>=$.length)return null;if(!/\s/.test($[Y]))return null;while(Y<$.length&&/\s/.test($[Y]))Y++;if(!$.startsWith("import",Y))return null;Y+=6;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;let X=$[Y];if(X!=="'"&&X!=='"')return null;Y++;let J=Y;while(Y<$.length&&$[Y]!==X)if($[Y]==="\\")Y+=2;else Y++;if(Y>=$.length)return null;let Q=$.slice(J,Y);Y++;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!==")")return null;return{quote:X,path:Q,end:Y+1}}function BY($,Z){let Y=$[Z];if(Y!=="{"&&Y!=="[")return null;let J=L0($,Y,Y==="{"?"}":"]",Z);if(J===-1)return null;return{pattern:$.slice(Z,J+1),endPos:J+1}}function jY($){let Z=[],Y=$.slice(1,-1).trim();if(!Y)return Z;let X=0,J=0,Q="";while(X<Y.length){let G=Y[X];if(G==="{"||G==="["){if(J++,J===1){let K=BY(Y,X);if(K){let q=jY(K.pattern);Z.push(...q),X=K.endPos,Q="";continue}}}else if(G==="}"||G==="]")J--;if(J>0){X++;continue}if(G===","){if(Q.trim())Z.push(Q.trim());Q="",X++;continue}if(G===":"){Q="",X++;continue}if(G==="="){if(Q.trim())Z.push(Q.trim());Q="",X++;while(X<Y.length&&Y[X]!==","&&J===0){if(Y[X]==="{"||Y[X]==="[")J++;else if(Y[X]==="}"||Y[X]==="]")J--;X++}continue}if(/[\w$]/.test(G))Q+=G;X++}if(Q.trim())Z.push(Q.trim());return Z}function qY($,Z){let Y=$[Z].trim(),X=Y.match(/^(?:export\s+)?(const|let|var)\s+(\w+)\s*=\s*(.*)$/);if(!X){let z=Y.match(/^(?:export\s+)?(const|let|var)\s+/);if(z){let U=Y.slice(z[0].length),W=Z;if((U.startsWith("{")||U.startsWith("["))&&!U.includes(U.startsWith("{")?"}":"]")){let B=U.startsWith("{")?"}":"]",j=U;for(let O=Z+1;O<$.length;O++)if(j+=" "+$[O].trim(),W=O,$[O].includes(B))break;U=j}let _=BY(U,0);if(_){let B=z[1],j=_.pattern,O=U.slice(_.endPos).trim();if(O.startsWith("=")){let L=O.slice(1).trim(),V=L,H=Math.max(W,Z);if(zY(L)){let R=UY($,H,L);V=R.value,H=R.nextIndex}else H=H+1;V=V.trim().replace(/;$/,"");let F=jY(j),A=`__stx_src_${Z}`,w=F.map((R)=>`module.exports.${R} = ${R};`).join(`
|
|
4185
|
+
`);return{type:B,name:A,value:`${V}; ${B} ${j} = ${A};
|
|
4186
4186
|
${w}`,nextIndex:H}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}let[,J,Q,G]=X,K=G,q=Z;if(zY(G)){let z=UY($,Z,G);K=z.value,q=z.nextIndex}else q=Z+1;while(q<$.length){let z=$[q].trim();if(z.startsWith(".")||z.startsWith("?."))K+=`
|
|
4187
4187
|
${$[q]}`,q++;else break}return K=K.trim().replace(/;$/,""),{type:J,name:Q,value:K,nextIndex:q}}function M6($,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(_W(Y)){let K=BW($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:J,functionCode:Q,nextIndex:G}}function zY($){let Z=$.trim();if(Z.startsWith("{"))return L0(Z,"{","}",0)===-1;if(Z.startsWith("["))return L0(Z,"[","]",0)===-1;return!HY(Z)}function HY($){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 _W($){let Z=$.indexOf("{");if(Z===-1)return!0;return L0($,"{","}",Z)===-1}function UY($,Z,Y){let X=Y,J=Z+1;while(J<$.length&&!HY(X)){let Q=$[J];X+=`
|
|
4188
4188
|
${Q}`,J++}while(J<$.length){let Q=$[J].trim();if(Q.startsWith(".")||Q.startsWith("?."))X+=`
|
|
4189
4189
|
${$[J]}`,J++;else break}return{value:X,nextIndex:J}}function BW($,Z,Y){let X=Y,J=Z+1;while(J<$.length){let Q=X.indexOf("{");if(Q!==-1){if(L0(X,"{","}",Q)!==-1)break}let G=$[J];X+=`
|
|
4190
|
-
${G}`,J++}return{functionCode:X,nextIndex:J}}function WY($,Z){let Y=e($,Z)??e(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...r5.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 jW($,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 q=K.trim().replace(/;$/,""),z=WY(q,Z);if(z!==void 0)Z[G]=z}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}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 q=K.trim().replace(/;$/,""),z=WY(q,Z);if(z!==void 0)Z[G]=z}catch{}}}function OY($){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 LY($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var L5=C(()=>{u5();a1();V0()});var TY={};p(TY,{processLoops:()=>D6});function LW($,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,q=1,z=K+1;while(z<X.length&&q>0){if(X[z]==="(")q++;else if(X[z]===")"){if(q--,q===0)break}z++}if(q!==0)continue;let U=X.substring(K+1,z),W=z+1,_=U.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=U.slice(_[0].length),O=j.match(/^\s*,\s*/);if(!O)continue;let L=j.slice(O[0].length).trim();if(!L)continue;try{let
|
|
4190
|
+
${G}`,J++}return{functionCode:X,nextIndex:J}}function WY($,Z){let Y=e($,Z)??e(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let X={...Z,process:Object.freeze({env:{...r5.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 jW($,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 q=K.trim().replace(/;$/,""),z=WY(q,Z);if(z!==void 0)Z[G]=z}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}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 q=K.trim().replace(/;$/,""),z=WY(q,Z);if(z!==void 0)Z[G]=z}catch{}}}function OY($){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 LY($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var L5=C(()=>{u5();a1();V0()});var TY={};p(TY,{processLoops:()=>D6});function LW($,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,q=1,z=K+1;while(z<X.length&&q>0){if(X[z]==="(")q++;else if(X[z]===")"){if(q--,q===0)break}z++}if(q!==0)continue;let U=X.substring(K+1,z),W=z+1,_=U.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=U.slice(_[0].length),O=j.match(/^\s*,\s*/);if(!O)continue;let L=j.slice(O[0].length).trim();if(!L)continue;try{let V=H0(L,Z),H=JSON.stringify(V),F=`@component('${B}', ${H})`;Q.push({start:G,end:W,replacement:F})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:z}=Q[G];X=X.substring(0,K)+z+X.substring(q)}return X}function M4($,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,q=1,z=K+1,U=null,W=!1;while(z<X.length&&q>0){let j=X[z];if(W){W=!1,z++;continue}if(j==="\\"&&U){W=!0,z++;continue}if(U){if(j===U)U=null;z++;continue}if(j==='"'||j==="'"||j==="`"){U=j,z++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}z++}if(q!==0)break;let _=X.substring(K+1,z),B=Y(_);X=X.substring(0,G)+B+X.substring(z+1)}return X}function FW($,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);I5(Q);let z=Z0(Q,G)(...K),U=JSON.stringify(z),W=Buffer.from(U,"utf8").toString("base64");return`__stx_${J}="${W}"`}catch(G){return X}}),Y}function VW($,Z){let Y=$;return Y=M4(Y,"@break",(X)=>{try{let Q=`!!(${X.trim()})`,G;if($0(Q)){let K=Z0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(e(Q,Z));return G?I4:""}catch{return""}}),Y=M4(Y,"@continue",(X)=>{try{let Q=`!!(${X.trim()})`,G;if($0(Q)){let K=Z0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(e(Q,Z));return G?D4:""}catch{return""}}),Y}function wW($){let Z=$;return Z=Z.replace(/@break(?!\()/g,I4),Z=Z.replace(/@continue(?!\()/g,D4),Z}function FY($){let Z=$.includes(I4),Y=Z?$.substring(0,$.indexOf(I4)):$;return{hasBreak:Z,content:Y}}function VY($){let Z=$.includes(D4),Y=Z?$.substring(0,$.indexOf(D4)):$;return{hasContinue:Z,content:Y}}function AY($){let Z=$;return Z=M4(Z,"@break",(Y)=>{let X=Y.trim();if(!D5(X))return"";return`\`; if (${X}) { break; } result += \``}),Z=M4(Z,"@continue",(Y)=>{let X=Y.trim();if(!D5(X))return"";return`\`; if (${X}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function AW($){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((U,W)=>U.pos-W.pos);let K=[],q=0;for(let U of X)q+=U.delta,K.push({pos:U.pos,depth:q});function z(U){let W=0,_=K.length-1,B=0;while(W<=_){let j=W+_>>1;if(K[j].pos<=U)B=K[j].depth,W=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(z(Y.index)>0)continue;let U=Y.index,W=Y.index+Y[0].length-1,_=1,B=W+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let O=$.substring(W+1,j),L=O.indexOf(" as ");if(L===-1)continue;let V=O.substring(0,L).trim(),H=O.substring(L+4).trim(),F=j+1,A=1,w=F,R=/@forelse\s*\(/g,N=/@endforelse/g,M=-1;while(A>0&&w<$.length){R.lastIndex=w,N.lastIndex=w;let S=R.exec($),b=N.exec($);if(!b)break;if(S&&S.index<b.index)A++,w=S.index+S[0].length;else{if(A--,A===0){M=b.index;break}w=b.index+11}}if(M===-1)continue;let T=$.substring(F,M),I=M+11,D=-1,E=0,k=0;while(k<T.length){let S=T.indexOf("@",k);if(S===-1)break;let b=T.substring(S);if(/^@forelse\s*\(/.test(b))E++,k=S+1;else if(b.startsWith("@endforelse"))E--,k=S+11;else if(E===0&&b.startsWith("@empty")){if(T.length<=S+6||!/[a-z]/i.test(T[S+6])){D=S;break}k=S+1}else k=S+1}if(D===-1)continue;return{start:U,end:I,arrayExpr:V,itemVar:H,foreachContent:T.substring(0,D),emptyContent:T.substring(D+6)}}return null}function wY($,Z){let Y=$;while(!0){let X=AW(Y);if(!X)break;let{start:J,end:Q,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:z}=X;try{let U;if($0(G))U=Z0(G,Object.keys(Z))(...Object.values(Z));else U=e(G,Z);let W;if(!Array.isArray(U)||U.length===0)W=z;else W=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,J)+W+Y.substring(Q)}catch(U){let W=U instanceof Error?U.message:String(U),_=r("Forelse",`Error in @forelse(${G} as ${K}): ${W}`,c.EVALUATION_ERROR);Y=Y.substring(0,J)+_+Y.substring(Q)}}return Y}function D6($,Z,Y,X){let J=$;J=wY(J,Z);function Q(q){let z=/@foreach\s*\(/g,U;while((U=z.exec(q))!==null){let W=U.index,_=U.index+U[0].length-1,B=1,j=_+1,O=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){O=j;break}}j++}if(O===-1)continue;let L=q.substring(_+1,O),V=L.indexOf(" as ");if(V===-1)continue;let H=W,F=L.substring(0,V),A=L.substring(V+4),w=O+1,R=1,N=w,M=/@foreach\s*\(/g,T=/@endforeach/g;while(R>0&&N<q.length){M.lastIndex=N,T.lastIndex=N;let I=M.exec(q),D=T.exec(q);if(!D)break;if(I&&I.index<D.index)R++,N=I.index+I[0].length;else{if(R--,R===0){let E=q.substring(w,D.index),k=D.index+11;return{start:H,end:k,arrayExpr:F,itemVar:A,content:E}}N=D.index+11}}}return null}function G(q,z){let U=q;while(!0){let W=Q(U);if(!W)break;let{start:_,end:B,arrayExpr:j,itemVar:O,content:L}=W;try{let V=j.trim(),H;if($0(V))H=Z0(V,Object.keys(z))(...Object.values(z));else H=e(V,z);let F=!1;if(!Array.isArray(H))if(H instanceof Map)H=Array.from(H),F=!0;else if(H instanceof Set)H=Array.from(H);else if(typeof H==="string")H=Array.from(H);else if(H&&typeof H==="object"&&!(H instanceof Date)&&!(H instanceof RegExp))H=Object.entries(H),F=!0;else{let D=r("Foreach",`Error in @foreach: ${V} is not iterable`,c.TYPE_ERROR);U=U.substring(0,_)+D+U.substring(B);continue}let A=X?.loops?.useAltLoopVariable??OW,w=O.trim(),R=null,N,M=!1;if(w.includes("=>")){let D=w.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],N=D[1];else N=w}else if(!w.startsWith("[")&&!w.startsWith("{")&&w.includes(",")){let D=w.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])N=D[0],R=D[1],M=!0;else N=w}else N=w;let T="",I=H;for(let D=0;D<I.length;D++){let E=I[D],k={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},S={...z,loop:k,$loop:k};if(N.startsWith("[")&&N.endsWith("]")){let f=N.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))f.forEach((m,o)=>{if(m)S[m]=E[o]});else S[N]=E}else S[N]=E;if(R)if(!M&&F&&Array.isArray(E)&&E.length===2)S[R]=E[0],S[N]=E[1];else S[R]=D;let b=VW(L,S),y=VY(b);if(y.hasContinue){T+=y.content;continue}let d=FY(b);if(d.hasBreak){T+=d.content;break}if(b=wY(b,S),b=G(b,S),b=g1(b,S,Y),b=wW(b),d=FY(b),d.hasBreak){T+=d.content;break}if(y=VY(b),y.hasContinue){T+=y.content;continue}b=a0(b,S,Y),b=FW(b,S),b=LW(b,S),T+=b}U=U.substring(0,_)+T+U.substring(B)}catch(V){let H=r("Foreach",`Error in @foreach(${j.trim()} as ${O.trim()}): ${V instanceof Error?V.message:String(V)}`,c.EVALUATION_ERROR);U=U.substring(0,_)+H+U.substring(B)}}return U}J=G(J,Z),J=NY(J,Z,Y,X);let K=X?.loops?.maxWhileIterations??HW;return J=TW(J,Z,K),J}function RY($){return D5($)}function NY($,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,q=K+G[0].length-1,z=L0(J,"(",")",q);if(z===-1)break;let U=J.slice(q+1,z),W=z+1,_=q4(J.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!RY(U)){let O=r("For",`Unsafe expression in @for: ${U}`,c.UNSAFE_EXPRESSION);J=J.substring(0,K)+O+J.substring(j),Q=!0;continue}try{let O=RW(U),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(O.length>0&&L){let R=NW({forExpr:U,content:B,iterVarNames:O,context:Z,filePath:Y,options:X});J=J.substring(0,K)+R+J.substring(j),Q=!0;continue}let V=Object.keys(Z),H=Object.values(Z),F=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(R,N)=>{return`\${${N}}`});F=AY(F);let w=Function(...V,`
|
|
4191
4191
|
let result = '';
|
|
4192
4192
|
for (${U}) {
|
|
4193
|
-
result += \`${
|
|
4193
|
+
result += \`${F}\`;
|
|
4194
4194
|
}
|
|
4195
4195
|
return result;
|
|
4196
4196
|
`)(...H);J=J.substring(0,K)+w+J.substring(j),Q=!0}catch(O){let L=r("For",`Error in @for(${U}): ${O instanceof Error?O.message:String(O)}`,c.EVALUATION_ERROR);J=J.substring(0,K)+L+J.substring(j),Q=!0}}return J}function RW($){let Z=$.trim(),Y=Z.match(/^(?:const|let|var)\s+(\[[^\]]+\]|\{[^}]+\})\s+(?:of|in)\s+/);if(Y){let Q=Y[1];return Q.slice(1,-1).split(",").map((K)=>{let q=K.trim();if(!q)return"";let z=q.indexOf(":");if(z>=0&&Q.startsWith("{")){let _=q.slice(z+1).trim(),B=_.indexOf("=");return(B>=0?_.slice(0,B):_).trim()}let U=q.indexOf("="),W=(U>=0?q.slice(0,U):q).trim();return/^[A-Za-z_$][\w$]*$/.test(W)?W:""}).filter(Boolean)}let X=Z.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s+(?:of|in)\s+/);if(X)return[X[1]];let J=Z.match(/^(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=[^;]*;/);if(J)return[J[1]];return[]}function NW($){let{forExpr:Z,content:Y,iterVarNames:X,context:J,filePath:Q,options:G}=$,K=Object.keys(J),q=Object.values(J),z=Function(...K,"__pushIter",`
|
|
4197
4197
|
for (${Z}) {
|
|
4198
4198
|
__pushIter([${X.join(", ")}])
|
|
4199
4199
|
}
|
|
4200
|
-
`),U=[];z(...q,(B)=>{U.push(B)});let W=Q??"inline.stx",_="";for(let B of U){let j={...J};X.forEach((L,
|
|
4200
|
+
`),U=[];z(...q,(B)=>{U.push(B)});let W=Q??"inline.stx",_="";for(let B of U){let j={...J};X.forEach((L,V)=>{j[L]=B[V]});let O=NY(Y,j,Q,G);O=g1(O,j,W),O=a0(O,j,W),_+=O}return _}function TW($,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,q=L0(X,"(",")",K);if(q===-1)break;let z=X.slice(K+1,q),U=q4(X.slice(G),"while","endwhile");if(U.length===0)break;let W=U[0].content,_=G+U[0].end;if(!RY(z)){let B=r("While",`Unsafe expression in @while: ${z}`,c.UNSAFE_EXPRESSION);X=X.substring(0,G)+B+X.substring(_),J=!0;continue}try{let B=Object.keys(Z),j=Object.values(Z),O=W.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(H,F)=>{return`\${${F}}`});O=AY(O);let V=Function(...B,`
|
|
4201
4201
|
let result = '';
|
|
4202
4202
|
let maxIterations = ${Y}; // Configurable safety limit
|
|
4203
4203
|
let counter = 0;
|
|
@@ -4209,7 +4209,7 @@ ${G}`,J++}return{functionCode:X,nextIndex:J}}function WY($,Z){let Y=e($,Z)??e(`(
|
|
|
4209
4209
|
result += '<!-- [While Error [1104]]: Maximum iterations (${Y}) exceeded in while loop. Configure via options.loops.maxWhileIterations -->';
|
|
4210
4210
|
}
|
|
4211
4211
|
return result;
|
|
4212
|
-
`)(...j);X=X.substring(0,G)+
|
|
4212
|
+
`)(...j);X=X.substring(0,G)+V+X.substring(_),J=!0}catch(B){let j=r("While",`Error in @while(${z}): ${B instanceof Error?B.message:String(B)}`,c.EVALUATION_ERROR);X=X.substring(0,G)+j+X.substring(_),J=!0}}return X}var HW=1000,OW=!1,I4="<!--__STX_BREAK__-->",D4="<!--__STX_CONTINUE__-->";var E6=C(()=>{U4();K1();t0();z4();V0()});import q0 from"path";function k6($,Z){let Y=0;for(let X=Z;X<$.length;X++){let J=$[X];if(J==="("||J==="["||J==="{")Y++;else if(J===")"||J==="]"||J==="}")Y--;else if(J===","&&Y===0)return X}return-1}function MW($,Z,Y){let X=$,J=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),Q=J.exec(X);while(Q){let G=Q.index,K=G+Q[0].length-1,q=1,z=K+1;while(z<X.length&&q>0){if(X[z]==="(")q++;else if(X[z]===")")q--;z++}if(q!==0)break;let U=X.substring(K+1,z-1),W=`${Y}(${U})`;X=X.substring(0,G)+W+X.substring(z),J.lastIndex=G+W.length,Q=J.exec(X)}return X}function IW($){return/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test($)}function DW($){let Z=$,Y=[],X=new Set,J=0,Q=0,G=Z.length,K=(W)=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]===W){Q++;return}Q++}},q=()=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]==="`"){Q++;return}if(Z[Q]==="$"&&Z[Q+1]==="{"){Q+=2;let W=1;while(Q<G&&W>0)if(Z[Q]==="{")W++,Q++;else if(Z[Q]==="}")W--,Q++;else if(Z[Q]==="'"||Z[Q]==='"')K(Z[Q]);else if(Z[Q]==="`")q();else Q++;continue}Q++}},z=()=>{if(Z[Q]==="/"&&Z[Q+1]==="/"){while(Q<G&&Z[Q]!==`
|
|
4213
4213
|
`)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},U=()=>{if(J!==0)return;let W=Z.slice(Q).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(W){let j=W[2];if(!X.has(j))Y.push(j),X.add(j);return}let _=Z.slice(Q).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!X.has(j))Y.push(j),X.add(j);return}let B=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!X.has(j))Y.push(j),X.add(j)}};while(Q<G){if(z())continue;if(Z[Q]==="'"||Z[Q]==='"'){K(Z[Q]);continue}if(Z[Q]==="`"){q();continue}if(Z[Q]==="{"){J++,Q++;continue}if(Z[Q]==="}"){J--,Q++;continue}if(J===0&&/[a-z]/i.test(Z[Q])&&(Q===0||/\s|[;{}()]/.test(Z[Q-1])))U();Q++}return Y.join(", ")}function DY($,Z=""){return`
|
|
4214
4214
|
(function() {
|
|
4215
4215
|
var { state, derived, effect, batch, onMount, onDestroy, defineStore, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, ref, reactive, computed, watch, watchEffect, defineProps, withDefaults, defineEmits, defineExpose, defineSlots } = window.stx;
|
|
@@ -4244,28 +4244,28 @@ ${DW($).split(",").map((q)=>q.trim()).filter(Boolean).map((q)=>` try { __scopeR
|
|
|
4244
4244
|
} finally {
|
|
4245
4245
|
if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
|
|
4246
4246
|
}
|
|
4247
|
-
})();`}function kW($,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 FR(){EY.clear()}function SW($){if($.__onceStore instanceof Set)return $.__onceStore;return EY}async function S6($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||q0.join(q0.dirname(Y),"partials");if(G&&!q0.isAbsolute(G))G=q0.resolve(process.cwd(),G);let K=MW($,"@partial","@include"),q=SW(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,O,L)=>{let
|
|
4247
|
+
})();`}function kW($,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 FR(){EY.clear()}function SW($){if($.__onceStore instanceof Set)return $.__onceStore;return EY}async function S6($,Z,Y,X,J,Q=new Set){let G=X.partialsDir||q0.join(q0.dirname(Y),"partials");if(G&&!q0.isAbsolute(G))G=q0.resolve(process.cwd(),G);let K=MW($,"@partial","@include"),q=SW(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,O,L)=>{let V=O.trim(),H=`${Y}:${V}`;if(q.has(H))return"";return q.add(H),O});{let j=/@includeIf\s*\(/g,O;while((O=j.exec(K))!==null){let L=O.index,V=L+O[0].length-1,H=1,F=V+1;while(F<K.length&&H>0){if(K[F]==="(")H++;else if(K[F]===")")H--;F++}if(H!==0)break;let A=K.substring(V+1,F-1),w=A.match(/^\s*['"]([^'"]+)['"]/);if(!w){j.lastIndex=F;continue}let R=w[1],N=z(R,G,Y),M="";if(N&&await Bun.file(N).exists())J.add(N),M=`@include(${A})`;K=K.substring(0,L)+M+K.substring(F),j.lastIndex=0}}for(let[j,O]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),V;while((V=L.exec(K))!==null){let H=V.index,F=H+V[0].length-1,A=1,w=F+1;while(w<K.length&&A>0){if(K[w]==="(")A++;else if(K[w]===")")A--;w++}if(A!==0)break;let R=K.substring(F+1,w-1),N=k6(R,0);if(N===-1){L.lastIndex=w;continue}let M=R.substring(0,N).trim(),T=R.substring(N+1).trim(),I=T.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=w;continue}let D=I[1],E=T.substring(I[0].length),k,S=k6(E,0);if(S!==-1)k=E.substring(S+1).trim();try{let b=`Boolean(${M})`,y;if($0(b)){let m=Z0(b,Object.keys(Z));y=Boolean(m(...Object.values(Z)))}else y=Boolean(e(b,Z));let d=O?!y:y,f="";if(d){let m=z(D,G,Y);if(m&&await Bun.file(m).exists())J.add(m);f=`@include('${D}'${k?`, ${k}`:""})`}K=K.substring(0,H)+f+K.substring(w),L.lastIndex=0}catch(b){let y=b instanceof Error?b.message:String(b),d=J0("Include",`Error evaluating ${j} condition: ${y}`,Y,$,H);K=K.substring(0,H)+d+K.substring(w),L.lastIndex=0}}}{let j=/@each\s*\(/g,O;while((O=j.exec(K))!==null){let L=O.index,V=L+O[0].length-1,H=1,F=V+1;while(F<K.length&&H>0){if(K[F]==="(")H++;else if(K[F]===")"){if(H--,H===0)break}F++}if(H!==0)break;let A=K.substring(V+1,F),w=K.substring(L,F+1),R=A.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!R){j.lastIndex=0,K=K.replace(w,"");continue}let[,N,M,T,I]=R;try{let D,E=M.trim();if($0(E))D=Z0(E,Object.keys(Z))(...Object.values(Z));else D=e(E,Z);let k="";if(Array.isArray(D)&&D.length>0)for(let S of D){let b={...Z,[T]:S},y=await W(N,b,$,L);k+=y}else if(I)k=await W(I,{},$,L);K=K.substring(0,L)+k+K.substring(F+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+J0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(F+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,O;while((O=j.exec(K))!==null){let L=O.index,V=L+O[0].length-1,H=1,F=V+1;while(F<K.length&&H>0){if(K[F]==="(")H++;else if(K[F]===")"){if(H--,H===0)break}F++}if(H!==0)break;let A=K.substring(V+1,F),w=K.substring(L,F+1),R=A.match(/^\s*(\[[^\]]+\])/);if(!R){j.lastIndex=0,K=K.replace(w,"");continue}let N=R[1],M=A.slice(R[0].length),T,I=M.match(/^\s*,\s*\{/);if(I){M=M.slice(I[0].length-1);let k=1,S=1;while(S<M.length&&k>0){if(M[S]==="{")k++;else if(M[S]==="}"){if(k--,k===0)break}S++}T=M.substring(0,S+1),M=M.slice(S+1)}let D,E=M.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let k=JSON.parse(N.replace(/'/g,'"')),S={};if(T)try{S=H0(T,Z)}catch(y){let d=y instanceof Error?y.message:String(y);if(X.debug){let f=J0("Include",`Error parsing includeFirst variables: ${d}`,Y,$,L,w);K=K.replace(w,()=>f)}else K=K.replace(w,()=>D||"");continue}let b=!1;for(let y of k){let d=z(y,G,Y);if(!d)continue;if(await i(d)){let f=await W(y,S,$,L);K=K.replace(w,()=>f),b=!0;break}}if(!b)if(D!==void 0)K=K.replace(w,()=>D);else if(X.debug){let y=J0("Include",`None of the includeFirst paths exist: ${N}`,Y,$,L,w);K=K.replace(w,()=>y)}else K=K.replace(w,"")}catch(k){let S=k instanceof Error?k.message:String(k),b=J0("Include",`Error processing @includeFirst: ${S}`,Y,$,L,w);K=K.replace(w,()=>b)}j.lastIndex=0}}function z(j,O,L){try{let V=j;if(!j.endsWith(".stx"))V=`${j}.stx`;let H=q0.resolve(O),F=q0.resolve(q0.dirname(L)),A;if(!V.startsWith("./")&&!V.startsWith("../"))A=q0.resolve(O,V);else A=q0.resolve(F,V);let w=q0.normalize(A),R=w.startsWith(H+q0.sep)||w===H,N=w.startsWith(F+q0.sep)||w===F,M=!1,T=q0.dirname(F);if(w.startsWith(T+q0.sep)){if(!q0.relative(T,w).split(q0.sep).some((k)=>k.startsWith(".")&&k!=="."&&k!==".."))M=!0}if(!R&&!N&&!M)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${w}`),console.error(` Allowed dirs: ${H}, ${F}`),null;return w}catch(V){return console.error(`Error resolving path ${j}: ${V}`),null}}let U=q0.resolve(Y);Q.add(U);async function W(j,O={},L,V){let H=z(j,G,Y);if(!H)return J0("Include",`Could not resolve path for include: ${j}`,Y,L,V);let F=q0.resolve(H);if(Q.has(F)){let A=[...Q,F].map((w)=>q0.basename(w)).join(" -> ");return J0("Include",`Circular include detected: ${A}`,Y,L,V)}try{J.add(H);let A;if(!A)try{A=await Bun.file(H).text()}catch(f){let m=f instanceof Error?f.message:String(f);return J0("Include",`Error loading include file ${j}: ${m}`,Y,L,V)}if(A&&A.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (n3(),i3));A=f(A,Z)}if(A&&(X.debug||!x5()&&!l$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (s3(),h2));f(A,H)}catch{}let w=A;try{let{processESImports:f}=await Promise.resolve().then(() => (T6(),GY));await f(A,Z,H,X,J)}catch(f){if(X.debug)console.warn(`[stx] partial ES import extraction skipped for ${H}:`,f instanceof Error?f.message:f)}let R=w.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(R)w=R[1].trim();let M=A.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),T="";if(M)T=`<style${M[1]}>${M[2]}</style>`;w=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),w=w.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,m]of Object.entries(O))I[f]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...A.matchAll(D)],k="",S=null;for(let f of E){let m=f[1]||"",o=f[2]||"",N0=m.includes("server"),X1=c1(m),C0="";try{let{extractAndStripCssImports:X0,renderVendorStyleTags:F0}=await Promise.resolve().then(() => (a5(),IY)),W0=X0(o,{filePath:H,projectRoot:process.cwd()});o=W0.code,C0=F0(W0.styles)}catch(X0){if(X.debug)console.warn(`[stx] vendor-css extractor skipped for ${H}:`,X0 instanceof Error?X0.message:X0)}if(X1&&o.trim())o=l1(o);if(!N0)try{let{hasUserImports:X0,bundleClientScript:F0}=await Promise.resolve().then(() => (j$(),B$));if(X0(o))o=await F0(o,H,{projectRoot:process.cwd()})}catch(X0){if(X.debug)console.warn(`[stx] bundler skipped for ${H}:`,X0 instanceof Error?X0.message:X0)}let E0=IW(o);if(E0&&!N0){S=`stx_scope_${q0.basename(H,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++MY}`;let X0=G1(o),F0=EW(X0,S);k+=`${C0}<script data-stx-scoped>${F0}</script>
|
|
4248
4248
|
`;continue}if(N0)try{let{extractVariables:X0}=await Promise.resolve().then(() => (L5(),T4));await X0(o,I,H)}catch(X0){if(X.debug)console.warn(`Warning: Could not extract variables from server script in ${H}:`,X0)}if(!N0&&!E0){let X0=m.replace(/\bclient\b/i,"").trim();S=`stx_scope_${q0.basename(H,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++MY}`;let F0=G1(o),W0=`
|
|
4249
4249
|
if (!window.stx._scopes) window.stx._scopes = {};
|
|
4250
4250
|
window.stx._scopes['${S}'] = { __destroyCallbacks: __destroyHooks };
|
|
4251
4251
|
`,P=DY(F0,W0);k+=`${C0}<script data-stx-scoped${X0?` ${X0}`:""}>${P}</script>
|
|
4252
4252
|
`}}if(S){let f=kW(w,S);if(w=f.html,f.mergedIntoExisting)k=k.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(w.includes("@include")||w.includes("@partial"))w=await S6(w,I,H,X,J,Q);let{processLoops:b}=await Promise.resolve().then(() => (E6(),TY)),y=b(w,I,H);y=g1(y,I,H);let d=e1(A);if(y=a0(y,I,H,{forceSignals:d}),T)y+=`
|
|
4253
4253
|
`+T;if(k)y+=`
|
|
4254
|
-
`+k;return y}catch(A){let w=A instanceof Error?A.message:String(A);return J0("Include",`Error processing include ${j}: ${w}`,Y,L,
|
|
4255
|
-
`)})}var MY=0,LR,EY;var kY=C(()=>{U4();t0();$5();V0();w0();LR=new b5(500),EY=new Set});import*as C6 from"path";async function SY($,Z,Y=""){if(C6.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 yY($,Z,Y,"@js","@endjs")}async function bY($,Z,Y=""){if(C6.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 yY($,Z,Y,"@ts","@endts")}async function yY($,Z,Y,X,J){let Q=$,G=S1(`${X}([\\s\\S]*?)${J}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:z,content:U,index:W}of K)try{let _=Object.keys(Z),B=Object.values(Z),j=U.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let L=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((w)=>w.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),
|
|
4254
|
+
`+k;return y}catch(A){let w=A instanceof Error?A.message:String(A);return J0("Include",`Error processing include ${j}: ${w}`,Y,L,V)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,O=j+B[0].length-1,L=1,V=O+1;while(V<K.length&&L>0){if(K[V]==="(")L++;else if(K[V]===")")L--;V++}if(L!==0)break;let H=K.substring(j,V),F=K.substring(O+1,V-1),A=F.match(/^\s*['"]([^'"]+)['"]/);if(!A){_.lastIndex=V;continue}let w=A[1],R,N=F.substring(A[0].length),M=k6(N,0);if(M!==-1)R=N.substring(M+1).trim();let T={};if(R)try{T=H0(R,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(H,J0("Include",`Error parsing include variables for ${w}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await W(w,T,$,j);K=K.substring(0,j)+I+K.substring(V),_.lastIndex=0}return K}function b6($,Z){let Y=$;function X(J,Q,G,K){let q=J,z=!0;while(z){z=!1;let U=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),W=q.match(U);if(!W||W.index===void 0)break;let _=W.index,B=W[1],j=_+W[0].length,O=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),V=1,H=j,F=-1;while(V>0&&H<q.length){let w=q.slice(H),R=w.match(O),N=w.match(L),M=R?H+R.index:1/0,T=N?H+N.index:1/0;if(M<T)V++,H=M+(R[0].length||1);else if(T<1/0){if(V--,V===0){F=T;break}H=T+G.length+1}else break}if(F===-1)break;let A=q.slice(j,F);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(A);else Z[B].push(A);q=q.substring(0,_)+q.substring(F+`@${G}`.length),z=!0}return q}return Y=X(Y,"push","endpush",!1),Y=X(Y,"prepend","endprepend",!0),Y}function y6($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,X)=>{if(!Z[X]||Z[X].length===0)return"";return Z[X].join(`
|
|
4255
|
+
`)})}var MY=0,LR,EY;var kY=C(()=>{U4();t0();$5();V0();w0();LR=new b5(500),EY=new Set});import*as C6 from"path";async function SY($,Z,Y=""){if(C6.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 yY($,Z,Y,"@js","@endjs")}async function bY($,Z,Y=""){if(C6.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 yY($,Z,Y,"@ts","@endts")}async function yY($,Z,Y,X,J){let Q=$,G=S1(`${X}([\\s\\S]*?)${J}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:z,content:U,index:W}of K)try{let _=Object.keys(Z),B=Object.values(Z),j=U.trim();if(X==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let L=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((w)=>w.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),V=L.length>0?`return { ${L.join(", ")} };`:"return {};",H=`
|
|
4256
4256
|
${j}
|
|
4257
|
-
${
|
|
4257
|
+
${V}
|
|
4258
4258
|
`,A=Function(..._,H)(...B);if(A&&typeof A==="object")Object.assign(Z,A);Q=Q.replace(z,"")}catch(_){console.error(`Error executing ${X} code block in ${Y}:`,_);let B=_ instanceof Error?_.message:String(_),j=J0(`${X} Directive`,`Error executing code: ${B}`,Y,$,W,z);console.error(j),Q=Q.replace(z,"")}return Q}var CY=C(()=>{$5();w0()});function bW($,Z="_method"){let Y=$.toUpperCase();if(Y==="GET"||Y==="POST")return"";return`<input type="hidden" name="${Z}" value="${Y}">`}function PY($){return $.replace(/@method\(\s*(['"])([^'"]+)\1\s*(?:,\s*(['"])([^'"]+)\3\s*)?\)/g,(Z,Y,X,J,Q)=>{return bW(X,Q||"_method")})}function NR($,Z="_method"){if($&&typeof $[Z]==="string")return $[Z].toUpperCase();return null}async function vY($,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 q=await K.handler(Q,Z,Y,X);if(typeof q==="string")Q=q;else if(X.debug)console.warn(`Middleware ${K.name} did not return a string`)}catch(q){if(X.debug)console.error(`Error in middleware ${K.name}:`,q);if(X.debug){let z=J0("Middleware",`Error in middleware '${K.name}': ${q instanceof Error?q.message:String(q)}`,Y,$);Q=Q.replace(/<body[^>]*>/,`$&
|
|
4259
4259
|
<div style="color:red;background:#ffeeee;padding:10px;border:1px solid #ff0000;margin:10px 0;font-family:monospace;white-space:pre-wrap;">${m0(z)}</div>
|
|
4260
|
-
`)}}}return Q}async function xY($,Z,Y,X){return vY($,Z,Y,X,"before")}async function fY($,Z,Y,X){return vY($,Z,Y,X,"after")}var gY=C(()=>{t0();w0()});import{defineRoute as yR,defineRoutes as CR,resetRoutes as PR,route as vR,setAppUrl as xR}from"stx-router";import{route as yW}from"stx-router";function hY($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,X,J,Q)=>{try{let G=J?H0(J,{}):{};return yW(X,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var dY=C(()=>{V0()});function fR($,Z){if(!o0.exact[$])o0.exact[$]=[];o0.exact[$].push(Z)}function gR($,Z){let Y=typeof $==="string"?new RegExp($):$;o0.patterns.push({pattern:Y,callback:Z})}async function mY($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(o0.exact[$])for(let X of o0.exact[$])await Promise.resolve(X(Z,$));if(o0.exact[Y])for(let X of o0.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of o0.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}function hR(){o0.patterns=[],o0.exact={}}var o0;var uY=C(()=>{o0={patterns:[],exact:{}}});function pY($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>pY(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function cY($,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(z){return J.some(([U,W])=>z>=U&&z<W)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,q=[];while((Q=K.exec(Y))!==null){if(G(Q.index))continue;let z=Q[0],U=Q[2];if(!U||!U.includes(":"))continue;let W=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,_,B=U,j=!1;while((_=W.exec(U))!==null){let O=_[1],L=_[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let
|
|
4260
|
+
`)}}}return Q}async function xY($,Z,Y,X){return vY($,Z,Y,X,"before")}async function fY($,Z,Y,X){return vY($,Z,Y,X,"after")}var gY=C(()=>{t0();w0()});import{defineRoute as yR,defineRoutes as CR,resetRoutes as PR,route as vR,setAppUrl as xR}from"stx-router";import{route as yW}from"stx-router";function hY($){return $.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Z,Y,X,J,Q)=>{try{let G=J?H0(J,{}):{};return yW(X,G,Q==="true")}catch(G){return console.error(`Error processing @route directive: ${G}`),"#route-error"}})}var dY=C(()=>{V0()});function fR($,Z){if(!o0.exact[$])o0.exact[$]=[];o0.exact[$].push(Z)}function gR($,Z){let Y=typeof $==="string"?new RegExp($):$;o0.patterns.push({pattern:Y,callback:Z})}async function mY($,Z){let Y=$.split("/").pop()?.split(".")[0]||"";if(o0.exact[$])for(let X of o0.exact[$])await Promise.resolve(X(Z,$));if(o0.exact[Y])for(let X of o0.exact[Y])await Promise.resolve(X(Z,$));for(let{pattern:X,callback:J}of o0.patterns)if(X.test($)||X.test(Y))await Promise.resolve(J(Z,$))}function hR(){o0.patterns=[],o0.exact={}}var o0;var uY=C(()=>{o0={patterns:[],exact:{}}});function pY($){if(typeof $==="string")return $;if(Array.isArray($))return $.filter(Boolean).map((Z)=>pY(Z)).join(" ");if($&&typeof $==="object")return Object.entries($).filter(([,Z])=>Z).map(([Z])=>Z).join(" ");return $?String($):""}function cY($,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(z){return J.some(([U,W])=>z>=U&&z<W)}let K=/<([a-zA-Z][a-zA-Z0-9-]*)((?:\s+(?:[^>"']|"[^"]*"|'[^']*'))*)\s*\/?>/g,q=[];while((Q=K.exec(Y))!==null){if(G(Q.index))continue;let z=Q[0],U=Q[2];if(!U||!U.includes(":"))continue;let W=/\s:([a-zA-Z_][\w-]*)\s*=\s*"([^"]*)"/g,_,B=U,j=!1;while((_=W.exec(U))!==null){let O=_[1],L=_[2];if(L.includes("()")&&!L.includes(".get(")||L.includes("$store")||L.includes("$ref"))continue;try{let V=Object.keys(Z),H=Object.values(Z),F=L.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 w=Function(...V,`return (${L})`)(...H);if(O==="class"){let R=pY(w);if(R){let N=B.match(/\sclass="([^"]*)"/);if(N)B=B.replace(N[0],` class="${N[1]} ${R}"`);else B=B.replace(_[0],` class="${R}"`)}else B=B.replace(_[0],"");j=!0;continue}if(CW.has(O)){if(w)B=B.replace(_[0],` ${O}`);else B=B.replace(_[0],"");j=!0;continue}if(w===null||w===void 0||w===!1)B=B.replace(_[0],"");else{let R=String(w).replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">");B=B.replace(_[0],` ${O}="${R}"`)}j=!0}catch{continue}}if(j){let O=z.endsWith("/>")?" /":"",V=`<${Q[1]}${B}${O}>`;q.push({start:Q.index,end:Q.index+z.length,replacement:V})}}for(let z=q.length-1;z>=0;z--){let{start:U,end:W,replacement:_}=q[z];Y=Y.slice(0,U)+_+Y.slice(W)}return Y}var CW;var lY=C(()=>{CW=new Set(["disabled","checked","readonly","required","autofocus","autoplay","controls","default","defer","formnovalidate","hidden","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","reversed","selected"])});function i1($,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("/")||PW.has(X[1].toLowerCase()),start:X.index,end:X.index+X[0].length}}function xW($,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($),q=G.exec($);if(!q)return-1;if(K&&K.index<q.index)X++,J=K.index+K[0].length;else{if(X--,X===0)return q.index+q[0].length;J=q.index+q[0].length}}return-1}function $1($,Z){if(Z.selfClosing)return{outerStart:Z.start,outerEnd:Z.end,innerHTML:""};let Y=xW($,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 iY($,Z){return new RegExp(`(?:^|\\s)${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?:=|\\s|$|>|/)`).test($)||$.includes(` ${Z}=`)||$.includes(` ${Z} `)||$.trimEnd().endsWith(` ${Z}`)}function F5($,Z){let Y=Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),X=$.match(new RegExp(`${Y}="([^"]*)"`,"s"))||$.match(new RegExp(`${Y}='([^']*)'`,"s"));return X?X[1]:null}function N1($,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 T1($,Z,Y){let X=Z.selfClosing?" /":"",J=`<${Z.tag}${Y}${X}>`;return $.slice(0,Z.start)+J+$.slice(Z.end)}function fW($){return/\bv-(?:if|else-if|else|for|show|model|html|text|pre|once|cloak|memo|bind|on|slot)\b/.test($)}function gW($){let Z=$,Y=0;while(Y<Z.length){let X=i1(Z,Y);if(!X)break;let J=F5(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(),q;if(G.includes(",")){let L=G.split(",").map((F)=>F.trim()),V=L[0],H=L[1];q=`${K} as ${H} => ${V}`}else q=`${K} as ${G}`;let z=N1(X.attrs,"v-for"),U=N1(z,":key").replace(/\s*v-bind:key="[^"]*"/g,""),W=$1(Z,X),_=Z.slice(W.outerStart,W.outerEnd),B=T1(_,{...X,start:0,end:X.end-X.start},U),j=`@foreach(${q})
|
|
4261
4261
|
`,O=`${j}${B}
|
|
4262
|
-
@endforeach`;Z=Z.slice(0,W.outerStart)+O+Z.slice(W.outerEnd),Y=W.outerStart+j.length}return Z}function hW($){let Z=$,Y=0;while(Y<Z.length){let X=i1(Z,Y);if(!X)break;let J=F5(X.attrs,"v-if");if(J===null){Y=X.end;continue}let Q=[],G=$1(Z,X),K=N1(X.attrs,"v-if"),q=T1(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:q,parsedTag:X});let z=G.outerEnd,U=!0;while(U){let O=Z.slice(z).match(/^\s*/),L=O?O[0].length:0,
|
|
4262
|
+
@endforeach`;Z=Z.slice(0,W.outerStart)+O+Z.slice(W.outerEnd),Y=W.outerStart+j.length}return Z}function hW($){let Z=$,Y=0;while(Y<Z.length){let X=i1(Z,Y);if(!X)break;let J=F5(X.attrs,"v-if");if(J===null){Y=X.end;continue}let Q=[],G=$1(Z,X),K=N1(X.attrs,"v-if"),q=T1(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:q,parsedTag:X});let z=G.outerEnd,U=!0;while(U){let O=Z.slice(z).match(/^\s*/),L=O?O[0].length:0,V=i1(Z,z+L);if(!V){U=!1;break}let H=F5(V.attrs,"v-else-if"),F=iY(V.attrs,"v-else");if(H!==null){let A=$1(Z,V),w=N1(V.attrs,"v-else-if"),R=T1(Z.slice(A.outerStart,A.outerEnd),{...V,start:0,end:V.end-V.start},w);Q.push({type:"else-if",expr:H,outerStart:z,outerEnd:A.outerEnd,element:R,parsedTag:V}),z=A.outerEnd}else if(F){let A=$1(Z,V),w=N1(V.attrs,"v-else"),R=T1(Z.slice(A.outerStart,A.outerEnd),{...V,start:0,end:V.end-V.start},w);Q.push({type:"else",outerStart:z,outerEnd:A.outerEnd,element:R,parsedTag:V}),U=!1}else U=!1}let W=[];for(let O of Q)if(O.type==="if")W.push(`@if(${O.expr})
|
|
4263
4263
|
${O.element}`);else if(O.type==="else-if")W.push(`@elseif(${O.expr})
|
|
4264
4264
|
${O.element}`);else W.push(`@else
|
|
4265
4265
|
${O.element}`);W.push("@endif");let _=W.join(`
|
|
4266
4266
|
`),B=Q[0].outerStart,j=Q[Q.length-1].outerEnd;Z=Z.slice(0,B)+_+Z.slice(j),Y=B+_.length}return Z}function dW($){return $.replace(/\bv-show="([^"]*)"/g,'@show="$1"')}function mW($){let Z=$,Y=0;while(Y<Z.length){let X=i1(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 U=K[1],W=K[2],_=K[3];J=J.replace(K[0],""),J+=` :${U}="${_}" @update:${U}="${_} = $event"`,K=J.match(G)}if(Q){let U=$1(Z,X),W=Z.slice(U.outerStart,U.outerEnd),_=T1(W,{...X,start:0,end:X.end-X.start},J);Z=Z.slice(0,U.outerStart)+_+Z.slice(U.outerEnd),Y=U.outerStart+_.length;continue}let q=F5(X.attrs,"v-model");if(q===null){Y=X.end;continue}if(vW.has(X.tag.toLowerCase())){let U=X.attrs.replace(/\s*v-model="[^"]*"/g,"")+` @model="${q}"`,W=$1(Z,X),_=Z.slice(W.outerStart,W.outerEnd),B=T1(_,{...X,start:0,end:X.end-X.start},U);Z=Z.slice(0,W.outerStart)+B+Z.slice(W.outerEnd),Y=W.outerStart+B.length}else{let U=X.attrs.replace(/\s*v-model="[^"]*"/g,"");U+=` :modelValue="${q}" @update:modelValue="${q} = $event"`;let W=$1(Z,X),_=Z.slice(W.outerStart,W.outerEnd),B=T1(_,{...X,start:0,end:X.end-X.start},U);Z=Z.slice(0,W.outerStart)+B+Z.slice(W.outerEnd),Y=W.outerStart+B.length}}return Z}function uW($){return $.replace(/\bv-bind:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,'@bind:$1="$2"')}function pW($){return $.replace(/\bv-on:([a-zA-Z_][a-zA-Z0-9_.-]*)\s*=\s*"([^"]*)"/g,'@$1="$2"')}function cW($){let Z=$,Y=0;while(Y<Z.length){let X=i1(Z,Y);if(!X)break;let J=F5(X.attrs,"v-html");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=$1(Z,X),G=N1(X.attrs,"v-html"),K=X.selfClosing?" /":"",q=`<${X.tag}${G}${K}>{!! ${J} !!}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+q+Z.slice(Q.outerEnd),Y=Q.outerStart+q.length}return Z}function lW($){let Z=$,Y=0;while(Y<Z.length){let X=i1(Z,Y);if(!X)break;let J=F5(X.attrs,"v-text");if(J===null){Y=X.end;continue}if(X.selfClosing){Y=X.end;continue}let Q=$1(Z,X),G=N1(X.attrs,"v-text"),K=X.selfClosing?" /":"",q=`<${X.tag}${G}${K}>{{ ${J} }}</${X.tag}>`;Z=Z.slice(0,Q.outerStart)+q+Z.slice(Q.outerEnd),Y=Q.outerStart+q.length}return Z}function iW($){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 nW($){let Z=$,Y=0;while(Y<Z.length){let X=i1(Z,Y);if(!X)break;if(!iY(X.attrs,"v-once")){Y=X.end;continue}let J=N1(X.attrs,"v-once"),Q=$1(Z,X),G=Z.slice(Q.outerStart,Q.outerEnd),q=`@once
|
|
4267
4267
|
${T1(G,{...X,start:0,end:X.end-X.start},J)}
|
|
4268
|
-
@endonce`;Z=Z.slice(0,Q.outerStart)+q+Z.slice(Q.outerEnd),Y=Q.outerStart+q.length}return Z}function oW($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function sW($){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 nY($){if(!fW($))return $;let Z=$;return Z=gW(Z),Z=hW(Z),Z=nW(Z),Z=uW(Z),Z=pW(Z),Z=mW(Z),Z=dW(Z),Z=sW(Z),Z=cW(Z),Z=lW(Z),Z=iW(Z),Z=oW(Z),Z}var PW,vW;var oY=C(()=>{PW=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),vW=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 E4($){return $.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}async function sY($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],q;while((q=G.exec(Q))!==null)K.push({full:q[0],expr:q[1],attrs:q[2],slotContent:q[3],index:q.index});for(let z=K.length-1;z>=0;z--){let U=K[z];try{let W=e(U.expr,Z);if(!W||typeof W!=="string"){let H=`<!-- dynamic component: could not resolve "${E4(U.expr)}" -->`;Q=Q.slice(0,U.index)+H+Q.slice(U.index+U.full.length);continue}let _=U.attrs.trim(),B={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,O;while((O=j.exec(_))!==null){let H=O[1]||O[2],
|
|
4268
|
+
@endonce`;Z=Z.slice(0,Q.outerStart)+q+Z.slice(Q.outerEnd),Y=Q.outerStart+q.length}return Z}function oW($){return $.replace(/\bv-memo="([^"]*)"/g,'data-stx-memo="$1"')}function sW($){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 nY($){if(!fW($))return $;let Z=$;return Z=gW(Z),Z=hW(Z),Z=nW(Z),Z=uW(Z),Z=pW(Z),Z=mW(Z),Z=dW(Z),Z=sW(Z),Z=cW(Z),Z=lW(Z),Z=iW(Z),Z=oW(Z),Z}var PW,vW;var oY=C(()=>{PW=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),vW=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 E4($){return $.replace(/--/g,"- -").replace(/</g,"<").replace(/>/g,">")}async function sY($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*)>([\s\S]*?)<\/component>/gi,K=[],q;while((q=G.exec(Q))!==null)K.push({full:q[0],expr:q[1],attrs:q[2],slotContent:q[3],index:q.index});for(let z=K.length-1;z>=0;z--){let U=K[z];try{let W=e(U.expr,Z);if(!W||typeof W!=="string"){let H=`<!-- dynamic component: could not resolve "${E4(U.expr)}" -->`;Q=Q.slice(0,U.index)+H+Q.slice(U.index+U.full.length);continue}let _=U.attrs.trim(),B={},j=/(?::([a-zA-Z_][a-zA-Z0-9_-]*)|([a-zA-Z_][a-zA-Z0-9_-]*))\s*=\s*"([^"]*)"/g,O;while((O=j.exec(_))!==null){let H=O[1]||O[2],F=O[3];if(O[1])try{B[H]=e(F,Z)}catch{B[H]=F}else B[H]=F}let L=X.componentsDir||"components",V=await U1(W,B,U.slotContent,L,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,U.index)+V+Q.slice(U.index+U.full.length)}catch(W){let _=W instanceof Error?W.message:String(W),B=`<!-- dynamic component error: ${E4(_)} -->`;Q=Q.slice(0,U.index)+B+Q.slice(U.index+U.full.length)}}return Q=await rW(Q,Z,Y,X,J),Q}async function rW($,Z,Y,X,J){let Q=$,G=/<component\s+(?::is|v-bind:is)\s*=\s*"([^"]*)"([^>]*?)\/>/gi,K=[],q;while((q=G.exec(Q))!==null)K.push({full:q[0],expr:q[1],attrs:q[2],index:q.index});for(let z=K.length-1;z>=0;z--){let U=K[z];try{let W=e(U.expr,Z);if(!W||typeof W!=="string"){let j=`<!-- dynamic component: could not resolve "${E4(U.expr)}" -->`;Q=Q.slice(0,U.index)+j+Q.slice(U.index+U.full.length);continue}let _=X.componentsDir||"components",B=await U1(W,{},"",_,Z,Y,X,new Set,J??new Set);Q=Q.slice(0,U.index)+B+Q.slice(U.index+U.full.length)}catch(W){let _=W instanceof Error?W.message:String(W),B=`<!-- dynamic component error: ${E4(_)} -->`;Q=Q.slice(0,U.index)+B+Q.slice(U.index+U.full.length)}}return Q}var rY=C(()=>{w0();V0()});function aY($,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 tY($,Z,Y={}){let{prefix:X="",preserveHost:J=!0,scopeKeyframes:Q=!0,scopeCustomProperties:G=!1}=Y;if(!$.trim())return"";let K=P6($),q=[],z=new Map;if(Q)for(let U of K){let W=U.selector.match(/@keyframes\s+([a-z_-][a-z0-9_-]*)/i);if(W){let _=W[1],B=`${Z}_${_}`;z.set(_,B)}}for(let U of K){let W=eY(U,Z,X,J,z,G);q.push(W)}return q.join(`
|
|
4269
4269
|
|
|
4270
4270
|
`)}function P6($){let Z=[],Y=$.replace(/\/\*[\s\S]*?\*\//g,""),X=0,J="",Q=!1,G="";for(let K=0;K<Y.length;K++){let q=Y[K];if(q==="@"&&X===0)Q=!0;if(q==="{")X++;else if(q==="}"){if(X--,X===0){if(Q){G+=q;let z=G.match(/@([a-z-]+)\s*([^{]*)\{([\s\S]*)\}/i);if(z){let[,U,W,_]=z;if(U==="keyframes")Z.push({selector:`@keyframes ${W.trim()}`,declarations:_.trim()});else if(U==="media"||U==="supports"||U==="container"){let B=P6(_);Z.push({selector:`@${U} ${W.trim()}`,declarations:B.map((j)=>`${j.selector} { ${j.declarations} }`).join(`
|
|
4271
4271
|
`)})}else Z.push({selector:`@${U} ${W.trim()}`,declarations:_.trim()})}G="",Q=!1}else if(J.trim()){J+=q;let z=J.match(/([^{]+)\{([^}]*)\}/);if(z)Z.push({selector:z[1].trim(),declarations:z[2].trim()});J=""}continue}}if(Q)G+=q;else J+=q}return Z}function eY($,Z,Y,X,J,Q){let{selector:G,declarations:K}=$;if(G.startsWith("@")){if(G.startsWith("@keyframes")){let U=G.replace("@keyframes ","").trim();return`@keyframes ${J.get(U)||U} { ${K} }`}if(G.startsWith("@media")||G.startsWith("@supports")||G.startsWith("@container")){let W=P6(`x { ${K} }`.replace(/x \{ /,"").replace(/ \}$/,"")).map((_)=>eY(_,Z,Y,X,J,Q)).join(`
|
|
@@ -4280,13 +4280,13 @@ ${X}`);return X+$;case"body-end":{let J=$.lastIndexOf("</body>");if(J!==-1)retur
|
|
|
4280
4280
|
${$.slice(Z)}`}function $_($,Z={},Y={}){let{title:X="stx App",lang:J="en",meta:Q=[],link:G=[],script:K=[],headRaw:q="",bodyClass:z="",bodyAttrs:U={}}=Z,W=Y.title||X,j=[...[{charset:"UTF-8"},{name:"viewport",content:"width=device-width, initial-scale=1.0"}],...Q].map((w)=>{return` <meta ${Object.entries(w).map(([N,M])=>`${N}="${M}"`).join(" ")}>`}).join(`
|
|
4281
4281
|
`),O=G.map((w)=>{return` <link ${Object.entries(w).map(([N,M])=>`${N}="${M}"`).join(" ")}>`}).join(`
|
|
4282
4282
|
`),L=K.map((w)=>{if(w.src)return` <script ${Object.entries(w).filter(([N])=>N!=="content").map(([N,M])=>`${N}="${M}"`).join(" ")}></script>`;if(w.content)return` <script>${w.content}</script>`;return""}).filter(Boolean).join(`
|
|
4283
|
-
`),
|
|
4283
|
+
`),V=Object.entries(U).map(([w,R])=>` ${w}="${R}"`).join(""),H=z?` class="${z}"`:"",F=[j,` <title>${W}</title>`," <style data-stx-cloak>[x-cloak]{display:none !important}</style>",O,L,q?` ${q}`:"",...(Y.styles||[]).map((w)=>` ${w}`),...(Y.headScripts||[]).map((w)=>` ${w}`),Y.headStack||""].filter(Boolean),A=[$,...(Y.bodyScripts||[]).map((w)=>w),Y.bodyStack||""].filter(Boolean);return`<!DOCTYPE html>
|
|
4284
4284
|
<html lang="${J}">
|
|
4285
4285
|
<head>
|
|
4286
|
-
${
|
|
4286
|
+
${F.join(`
|
|
4287
4287
|
`)}
|
|
4288
4288
|
</head>
|
|
4289
|
-
<body${H}${
|
|
4289
|
+
<body${H}${V}>
|
|
4290
4290
|
${A.join(`
|
|
4291
4291
|
`)}
|
|
4292
4292
|
</body>
|
|
@@ -5996,6 +5996,13 @@ catch (e2) {
|
|
|
5996
5996
|
|
|
5997
5997
|
// Known directive names to exclude from generic :attr binding
|
|
5998
5998
|
var DIRECTIVE_NAMES = {class:1, style:1, text:1, html:1, show:1, model:1, 'if':1, 'for':1, ref:1};
|
|
5999
|
+
// SVG attributes are case-sensitive, but the HTML parser lowercases
|
|
6000
|
+
// prefixed attribute names \u2014 ':viewBox' arrives as ':viewbox' because
|
|
6001
|
+
// the spec's "adjust SVG attributes" step only covers unprefixed names.
|
|
6002
|
+
// Without restoring the canonical casing, setAttribute('viewbox') creates
|
|
6003
|
+
// a dead duplicate attribute and the real viewBox never updates.
|
|
6004
|
+
var SVG_ATTR_CASE = {attributename:'attributeName', attributetype:'attributeType', basefrequency:'baseFrequency', baseprofile:'baseProfile', calcmode:'calcMode', clippathunits:'clipPathUnits', diffuseconstant:'diffuseConstant', edgemode:'edgeMode', filterunits:'filterUnits', glyphref:'glyphRef', gradienttransform:'gradientTransform', gradientunits:'gradientUnits', kernelmatrix:'kernelMatrix', kernelunitlength:'kernelUnitLength', keypoints:'keyPoints', keysplines:'keySplines', keytimes:'keyTimes', lengthadjust:'lengthAdjust', limitingconeangle:'limitingConeAngle', markerheight:'markerHeight', markerunits:'markerUnits', markerwidth:'markerWidth', maskcontentunits:'maskContentUnits', maskunits:'maskUnits', numoctaves:'numOctaves', pathlength:'pathLength', patterncontentunits:'patternContentUnits', patterntransform:'patternTransform', patternunits:'patternUnits', pointsatx:'pointsAtX', pointsaty:'pointsAtY', pointsatz:'pointsAtZ', preservealpha:'preserveAlpha', preserveaspectratio:'preserveAspectRatio', primitiveunits:'primitiveUnits', refx:'refX', refy:'refY', repeatcount:'repeatCount', repeatdur:'repeatDur', requiredextensions:'requiredExtensions', requiredfeatures:'requiredFeatures', specularconstant:'specularConstant', specularexponent:'specularExponent', spreadmethod:'spreadMethod', startoffset:'startOffset', stddeviation:'stdDeviation', stitchtiles:'stitchTiles', surfacescale:'surfaceScale', systemlanguage:'systemLanguage', tablevalues:'tableValues', targetx:'targetX', targety:'targetY', textlength:'textLength', viewbox:'viewBox', viewtarget:'viewTarget', xchannelselector:'xChannelSelector', ychannelselector:'yChannelSelector', zoomandpan:'zoomAndPan'};
|
|
6005
|
+
var SVG_NS = 'http://www.w3.org/2000/svg';
|
|
5999
6006
|
var EVENT_RE = /^(click|dblclick|mousedown|mouseup|mousemove|mouseenter|mouseleave|keydown|keyup|keypress|input|change|submit|focus|blur|scroll|resize|touchstart|touchend|touchmove|contextmenu|wheel|pointerdown|pointerup|pointermove)/;
|
|
6000
6007
|
var KEY_MAP = {enter:'Enter', tab:'Tab', escape:'Escape', space:' ', up:'ArrowUp', down:'ArrowDown', left:'ArrowLeft', right:'ArrowRight', 'delete':'Delete', backspace:'Backspace'};
|
|
6001
6008
|
|
|
@@ -6020,7 +6027,8 @@ catch (e2) {
|
|
|
6020
6027
|
if (name.startsWith('@bind:') || name.startsWith('x-bind:')
|
|
6021
6028
|
|| (name.startsWith(':') && !name.startsWith('::') && !DIRECTIVE_NAMES[name.slice(1).split('.')[0]] && !EVENT_RE.test(name.slice(1)))
|
|
6022
6029
|
|| (name.startsWith('x-') && !X_HANDLED[name.split('.')[0]] && !X_HANDLED[name])) {
|
|
6023
|
-
|
|
6030
|
+
let attrName = name.startsWith('@bind:') ? name.slice(6) : name.startsWith('x-bind:') ? name.slice(7) : name.startsWith('x-') ? name.slice(2) : name.slice(1);
|
|
6031
|
+
if (el.namespaceURI === SVG_NS && SVG_ATTR_CASE[attrName]) attrName = SVG_ATTR_CASE[attrName];
|
|
6024
6032
|
effect(() => {
|
|
6025
6033
|
const v = evalAttrExpr(value);
|
|
6026
6034
|
if (v === false || v === null || v === undefined) {
|
|
@@ -6399,10 +6407,12 @@ else {
|
|
|
6399
6407
|
});
|
|
6400
6408
|
}
|
|
6401
6409
|
else if (Array.isArray(value)) {
|
|
6402
|
-
|
|
6410
|
+
var _clsArr = originalClasses + ' ' + value.filter(Boolean).join(' ');
|
|
6411
|
+
if (typeof el.className === 'string') el.className = _clsArr; else el.setAttribute('class', _clsArr);
|
|
6403
6412
|
}
|
|
6404
6413
|
else {
|
|
6405
|
-
|
|
6414
|
+
var _clsStr = originalClasses + (value ? ' ' + value : '');
|
|
6415
|
+
if (typeof el.className === 'string') el.className = _clsStr; else el.setAttribute('class', _clsStr);
|
|
6406
6416
|
}
|
|
6407
6417
|
});
|
|
6408
6418
|
}
|
|
@@ -8726,10 +8736,10 @@ else {
|
|
|
8726
8736
|
var root = scriptEl ? scriptEl.nextElementSibling : null;
|
|
8727
8737
|
if (!root && scriptEl) root = scriptEl.previousElementSibling || scriptEl.parentElement;
|
|
8728
8738
|
|
|
8729
|
-
// SPA fallback: during router navigation, script is appended to
|
|
8739
|
+
// SPA fallback: during router navigation, script is appended to body>
|
|
8730
8740
|
// (not inside the content container), so nextElementSibling won't find the page content.
|
|
8731
8741
|
// Only use fallback when we genuinely couldn't find a suitable root element.
|
|
8732
|
-
// Do NOT fallback just because the script is in
|
|
8742
|
+
// Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
|
|
8733
8743
|
// with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
|
|
8734
8744
|
var needsFallback = !root || root === document.body
|
|
8735
8745
|
|| (root && root.tagName === 'SCRIPT');
|
|
@@ -9048,7 +9058,7 @@ else {
|
|
|
9048
9058
|
mountCallbacks.forEach(fn => fn());
|
|
9049
9059
|
});
|
|
9050
9060
|
|
|
9051
|
-
// Multi-root fragment fix: a no
|
|
9061
|
+
// Multi-root fragment fix: a no-body> setup page tags only the FIRST
|
|
9052
9062
|
// top-level element with data-stx (signal-processing.ts marks one element),
|
|
9053
9063
|
// so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text
|
|
9054
9064
|
// never hydrated, which read as "{{ }} doesn't work under :if/:for". The
|
|
@@ -9145,7 +9155,7 @@ else {
|
|
|
9145
9155
|
el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
|
|
9146
9156
|
});
|
|
9147
9157
|
|
|
9148
|
-
// Process
|
|
9158
|
+
// Process head> elements (title, meta) that may contain {{ }} expressions
|
|
9149
9159
|
// Use componentScope which now contains variables from processed components
|
|
9150
9160
|
const headElements = document.querySelectorAll('head title, head meta[content]');
|
|
9151
9161
|
headElements.forEach(el => {
|
|
@@ -9341,7 +9351,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
|
|
|
9341
9351
|
|
|
9342
9352
|
// Apply new page's SFC setup function. During SPA navigation, re-executed page
|
|
9343
9353
|
// scripts set window.stx._latestSetup to the new setup function. This takes priority
|
|
9344
|
-
// over the stale data-stx attribute on
|
|
9354
|
+
// over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).
|
|
9345
9355
|
var usedLatestSetup = false;
|
|
9346
9356
|
if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {
|
|
9347
9357
|
try {
|
|
@@ -9425,7 +9435,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
|
|
|
9425
9435
|
|
|
9426
9436
|
// Process the container content \u2014 bind {{ }}, :attr, @event directives.
|
|
9427
9437
|
// Run synchronously (not in setTimeout) so componentScope is captured correctly.
|
|
9428
|
-
// The DOMContentLoaded path processes
|
|
9438
|
+
// The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.
|
|
9429
9439
|
console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));
|
|
9430
9440
|
if (!container.__stx_scope) {
|
|
9431
9441
|
// Dispose previous effects on the container (from prior navigation)
|
|
@@ -9521,11 +9531,11 @@ ${W}`);return W+`
|
|
|
9521
9531
|
`+J+$.slice(K+1)}return J+`
|
|
9522
9532
|
`+$}async function WX($,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>
|
|
9523
9533
|
`}let{getCachedRouterScript:J}=await Promise.resolve().then(() => (p6(),u6)),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+`
|
|
9524
|
-
</body>`+$.slice(G+7)}var wX={};p(wX,{scanScriptTags:()=>OX,processSignals:()=>o6,processScriptSetup:()=>FX,preEvalLiteralReactiveIfs:()=>i6,parseLoopExpression:()=>LX,hasSignalsSyntax:()=>c4,extractExports:()=>VX,convertSignalLoopsToAttributes:()=>n6,convertSignalDirectivesToAttributes:()=>l6});function OX($,Z={}){let Y=[];m4.lastIndex=0;let X;while((X=m4.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)){m4.lastIndex=K;continue}Y.push({fullMatch:$.slice(X.index,K),attrs:J,body:$.slice(Q,G),start:X.index,end:K}),m4.lastIndex=K}return Y}function LX($){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}=_X(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}=_X(J);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function _X($){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 c4($){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 F_($){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 V_($){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 w_($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function jX($,Z,Y){if(!$)return!1;let X=w_($),J=!1,Q=!1,G=!1,K=/([a-zA-Z_$][\w$]*)/g,q;while((q=K.exec(X))!==null){let _=q[1];if(X.slice(0,q.index).trimEnd().endsWith("."))continue;if(BX.has(_))continue;if(Z.has(_))J=!0;else if(Y&&_ in Y)Q=!0}let z=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,U;while((U=z.exec(X))!==null){let _=U[1];if(X.slice(0,U.index).trimEnd().endsWith("."))continue;if(BX.has(_)||Y&&_ in Y)continue;G=!0}return(J||G)&&!Q}function u4($,Z,Y){let X=Y===void 0?` ${Z}`:` ${Z}="${Y.replace(/"/g,""")}"`,J=$.trim(),Q=J.match(HX);if(Q&&A_(Q[3],Q[1])){let[,G,K,q]=Q;return`<${G}${K}${X}>${q}</${G}>`}return`<template${X}>${J}</template>`}function A_($,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 l6($,Z){let Y=$,X=V_($),J=/@if\s*\(/g,Q,G=[];while((Q=J.exec(Y))!==null){let K=Q.index,q=K+Q[0].length,z=1,U=q;while(U<Y.length&&z>0){if(Y[U]==="(")z++;else if(Y[U]===")")z--;U++}if(z!==0)continue;let W=Y.substring(q,U-1).trim(),_=U,B=1,j=_,O=/@(if\s*\(|endif)/g;O.lastIndex=_;let L;while((L=O.exec(Y))!==null)if(L[1].startsWith("if"))B++;else if(L[1]==="endif"){if(B--,B===0){j=L.index+L[0].length;break}}if(B!==0)continue;let
|
|
9525
|
-
`)}else{if(!jX(W,X,Z))continue;H=u4(
|
|
9534
|
+
</body>`+$.slice(G+7)}var wX={};p(wX,{scanScriptTags:()=>OX,processSignals:()=>o6,processScriptSetup:()=>FX,preEvalLiteralReactiveIfs:()=>i6,parseLoopExpression:()=>LX,hasSignalsSyntax:()=>c4,extractExports:()=>VX,convertSignalLoopsToAttributes:()=>n6,convertSignalDirectivesToAttributes:()=>l6});function OX($,Z={}){let Y=[];m4.lastIndex=0;let X;while((X=m4.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)){m4.lastIndex=K;continue}Y.push({fullMatch:$.slice(X.index,K),attrs:J,body:$.slice(Q,G),start:X.index,end:K}),m4.lastIndex=K}return Y}function LX($){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}=_X(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}=_X(J);if(G)return{style:"in",iterable:Q,itemVar:G,indexVar:K}}return{style:"unknown",iterable:null,itemVar:null,indexVar:null}}function _X($){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 c4($){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 F_($){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 V_($){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 w_($){return $.replace(/'(?:\\.|[^'\\])*'/g,"''").replace(/"(?:\\.|[^"\\])*"/g,'""').replace(/`(?:\\.|[^`\\])*`/g,"``")}function jX($,Z,Y){if(!$)return!1;let X=w_($),J=!1,Q=!1,G=!1,K=/([a-zA-Z_$][\w$]*)/g,q;while((q=K.exec(X))!==null){let _=q[1];if(X.slice(0,q.index).trimEnd().endsWith("."))continue;if(BX.has(_))continue;if(Z.has(_))J=!0;else if(Y&&_ in Y)Q=!0}let z=/([a-zA-Z_$][\w$]*)(?:\.[a-zA-Z_$][\w$]*)*\s*\(\s*\)/g,U;while((U=z.exec(X))!==null){let _=U[1];if(X.slice(0,U.index).trimEnd().endsWith("."))continue;if(BX.has(_)||Y&&_ in Y)continue;G=!0}return(J||G)&&!Q}function u4($,Z,Y){let X=Y===void 0?` ${Z}`:` ${Z}="${Y.replace(/"/g,""")}"`,J=$.trim(),Q=J.match(HX);if(Q&&A_(Q[3],Q[1])){let[,G,K,q]=Q;return`<${G}${K}${X}>${q}</${G}>`}return`<template${X}>${J}</template>`}function A_($,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 l6($,Z){let Y=$,X=V_($),J=/@if\s*\(/g,Q,G=[];while((Q=J.exec(Y))!==null){let K=Q.index,q=K+Q[0].length,z=1,U=q;while(U<Y.length&&z>0){if(Y[U]==="(")z++;else if(Y[U]===")")z--;U++}if(z!==0)continue;let W=Y.substring(q,U-1).trim(),_=U,B=1,j=_,O=/@(if\s*\(|endif)/g;O.lastIndex=_;let L;while((L=O.exec(Y))!==null)if(L[1].startsWith("if"))B++;else if(L[1]==="endif"){if(B--,B===0){j=L.index+L[0].length;break}}if(B!==0)continue;let V=Y.substring(_,j-6).trim(),H;if(F_(V)){let F=d5(Y.substring(K,j));if(F.length===0)continue;let A=F[0].branches.filter((N)=>N.type!=="else");if(!(A.length>0&&A.every((N)=>jX(N.condition,X,Z))))continue;H=F[0].branches.map((N)=>{if(N.type==="elseif")return u4(N.content,"@else-if",N.condition??"");if(N.type==="else")return u4(N.content,"@else");return u4(N.content,"@if",N.condition??"")}).join(`
|
|
9535
|
+
`)}else{if(!jX(W,X,Z))continue;H=u4(V,"@if",W)}G.push({start:K,end:j,replacement:H})}for(let K=G.length-1;K>=0;K--){let{start:q,end:z,replacement:U}=G[K];Y=Y.substring(0,q)+U+Y.substring(z)}return Y}function R_($){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 N_($,Z,Y,X){if(c6.has(Y.toLowerCase()))return X;let J=Y.toLowerCase(),Q=$.toLowerCase(),G=$.length,K=1,q=X;while(q<G){let z=$.indexOf("<",q);if(z===-1)return-1;if(q=z,$.startsWith("<!--",q)){let B=$.indexOf("-->",q+4);if(B===-1)return-1;q=B+3;continue}let U=/^<(script|style)\b/i.exec($.slice(q,q+8));if(U){let B=$.indexOf(">",q);if(B===-1)return-1;if($[B-1]==="/"){q=B+1;continue}let j=Q.indexOf(`</${U[1].toLowerCase()}`,q);if(j===-1)return-1;let O=$.indexOf(">",j);if(O===-1)return-1;q=O+1;continue}if($[q+1]==="/"){let B=/^<\/([a-z][\w-]*)\s*>/i.exec($.slice(q,q+64));if(!B){q++;continue}if(B[1].toLowerCase()===J){if(K--,q+=B[0].length,K===0)return q;continue}q+=B[0].length;continue}let W=/^<([a-z][\w-]*)\b/i.exec($.slice(q,q+64));if(!W){q++;continue}let _=$.indexOf(">",q);if(_===-1)return-1;if(W[1].toLowerCase()===J){let B=$.slice(q,_+1);if(!(/\/\s*>$/.test(B)||c6.has(J)))K++}q=_+1}return-1}function M_($,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 T_.test(Q)}function i6($){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=(W)=>Z.some(([_,B])=>W>=_&&W<B),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[W,_,B,j,O,L,V]=K,H=R_(O);if(H===void 0)continue;let F=K.index,A=F+W.length,N=!!V||/\/\s*>$/.test(W)||c6.has(_.toLowerCase())?A:N_($,F,_,A);if(N===-1)continue;if((j===":if"||j==="x-if"||j==="@if")&&M_($,N)){Q.lastIndex=A;continue}if(H===!0){let T=`<${_}${B}${L}${V}>`;G.push({start:F,end:A,replacement:T});continue}G.push({start:F,end:N,replacement:""}),Q.lastIndex=N}if(G.length===0)return $;G.sort((W,_)=>W.start-_.start);let q=[],z=-1;for(let W of G){if(W.start<z)continue;q.push(W),z=W.end}let U=$;for(let W=q.length-1;W>=0;W--){let{start:_,end:B,replacement:j}=q[W];U=U.substring(0,_)+j+U.substring(B)}return U}function n6($,Z){let Y=$,X=/@(for|foreach)\s*\(/g,J,Q=[];while((J=X.exec(Y))!==null){let G=J[1],K=J.index,q=K+J[0].length,z=1,U=q;while(U<Y.length&&z>0){if(Y[U]==="(")z++;else if(Y[U]===")")z--;U++}if(z!==0)continue;let W=Y.substring(q,U-1).trim(),_=U,B=LX(W);if(B.iterable){let R=B.iterable.trim();if(R.startsWith("[")||R.startsWith("{")||R.startsWith("'")||R.startsWith('"')||R.startsWith("`")||/^-?\d/.test(R))continue;if(Z){let N=R.split(/[.[(]/)[0].trim();if(N&&N in Z)continue}}if(B.style==="as")W=B.indexVar?`(${B.itemVar}, ${B.indexVar}) in ${B.iterable}`:`${B.itemVar} in ${B.iterable}`;let j=G==="for"?"@endfor":"@endforeach",O=1,L=_,V=G==="for"?new RegExp("@(for(?!each)\\s*\\(|endfor(?!each))","g"):new RegExp(`@(${G}\\s*\\(|end${G})`,"g");V.lastIndex=_;let H;while((H=V.exec(Y))!==null)if(H[1].startsWith(G))O++;else if(O--,O===0){L=H.index+H[0].length;break}if(O!==0)continue;let F=Y.substring(_,L-j.length).trim(),A=F.match(HX),w;if(A){let[,R,N,M]=A;w=`<${R}${N} @for="${W}">${M}</${R}>`}else w=`<template @for="${W}">${F}</template>`;Q.push({start:K,end:L,replacement:w})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:z}=Q[G];Y=Y.substring(0,K)+z+Y.substring(q)}return Y}function I_($){let Z=new Set,Y=[],X=0,J=0,Q=$.length,G=(U)=>{let W=X+1;while(W<Q){let _=$[W];if(_==="\\"){W+=2;continue}if(_===U)return W+1;W++}return Q},K=()=>{let U=X+2;while(U<Q&&$[U]!==`
|
|
9526
9536
|
`)U++;return U},q=()=>{let U=X+2;while(U<Q-1){if($[U]==="*"&&$[U+1]==="/")return U+2;U++}return Q},z=(U)=>{let W=U,_=0;while(W<Q){let B=$[W];if(B==="/"&&$[W+1]==="/"){let j=W+2;while(j<Q&&$[j]!==`
|
|
9527
|
-
`)j++;W=j;continue}if(B==="/"&&$[W+1]==="*"){let j=W+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;W=j+2;continue}if(B==='"'||B==="'"||B==="`"){let j=W+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===B){j++;break}j++}W=j;continue}if(B==="("||B==="["||B==="{"){_++,W++;continue}if(B===")"||B==="]"||B==="}"){_--,W++;continue}if(B===";"&&_===0)return W+1;W++}return Q};while(X<Q){let U=$[X];if(U==="/"&&$[X+1]==="/"){let W=K();Y.push($.slice(X,W)),X=W;continue}if(U==="/"&&$[X+1]==="*"){let W=q();Y.push($.slice(X,W)),X=W;continue}if(U==='"'||U==="'"||U==="`"){let W=G(U);Y.push($.slice(X,W)),X=W;continue}if(U==="{"){J++,Y.push(U),X++;continue}if(U==="}"){J--,Y.push(U),X++;continue}if(J===0){let W=X>0?$[X-1]:"";if(W===""||/\s/.test(W)||W===";"||W==="}"||W==="{"){let B=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(B){let j=B[2],O=z(X+B[0].length);if(Z.has(j)){Y.push(`/* stx: deduped const ${j} */`),X=O;continue}Z.add(j),Y.push($.slice(X,O)),X=O;continue}}}Y.push(U),X++}return Y.join("")}async function FX($,Z,Y){let X=OX($,{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 O of X){let L=O.body;if(c1(O.attrs))L=l1(L);if(J.test(L))Q.push({fullMatch:O.fullMatch,attrs:O.attrs,content:L})}if(Q.length===0)return{output:$,setupCode:null};let G=`__stx_setup_${Date.now()}_${L_++}`,{hasUserImports:K,bundleClientScript:q}=await Promise.resolve().then(() => (j$(),B$)),z=[];for(let O=0;O<Q.length;O++){let L=Q[O].content;if(K(L))console.log("[stx:bundler] bundling signal script imports"),L=await q(L,Z||"",{projectRoot:process.cwd()});L=L.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
|
|
9528
|
-
${
|
|
9537
|
+
`)j++;W=j;continue}if(B==="/"&&$[W+1]==="*"){let j=W+2;while(j<Q-1&&!($[j]==="*"&&$[j+1]==="/"))j++;W=j+2;continue}if(B==='"'||B==="'"||B==="`"){let j=W+1;while(j<Q){if($[j]==="\\"){j+=2;continue}if($[j]===B){j++;break}j++}W=j;continue}if(B==="("||B==="["||B==="{"){_++,W++;continue}if(B===")"||B==="]"||B==="}"){_--,W++;continue}if(B===";"&&_===0)return W+1;W++}return Q};while(X<Q){let U=$[X];if(U==="/"&&$[X+1]==="/"){let W=K();Y.push($.slice(X,W)),X=W;continue}if(U==="/"&&$[X+1]==="*"){let W=q();Y.push($.slice(X,W)),X=W;continue}if(U==='"'||U==="'"||U==="`"){let W=G(U);Y.push($.slice(X,W)),X=W;continue}if(U==="{"){J++,Y.push(U),X++;continue}if(U==="}"){J--,Y.push(U),X++;continue}if(J===0){let W=X>0?$[X-1]:"";if(W===""||/\s/.test(W)||W===";"||W==="}"||W==="{"){let B=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][\w$]*)\s*=/);if(B){let j=B[2],O=z(X+B[0].length);if(Z.has(j)){Y.push(`/* stx: deduped const ${j} */`),X=O;continue}Z.add(j),Y.push($.slice(X,O)),X=O;continue}}}Y.push(U),X++}return Y.join("")}async function FX($,Z,Y){let X=OX($,{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 O of X){let L=O.body;if(c1(O.attrs))L=l1(L);if(J.test(L))Q.push({fullMatch:O.fullMatch,attrs:O.attrs,content:L})}if(Q.length===0)return{output:$,setupCode:null};let G=`__stx_setup_${Date.now()}_${L_++}`,{hasUserImports:K,bundleClientScript:q}=await Promise.resolve().then(() => (j$(),B$)),z=[];for(let O=0;O<Q.length;O++){let L=Q[O].content;if(K(L))console.log("[stx:bundler] bundling signal script imports"),L=await q(L,Z||"",{projectRoot:process.cwd()});L=L.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=G1(L);z.push(`// \u2500\u2500 merged signal script #${O+1} \u2500\u2500
|
|
9538
|
+
${V}`)}let U=z.join(`
|
|
9529
9539
|
|
|
9530
9540
|
`);U=I_(U);let W=VX(U),_=p4(U,Y),B=`
|
|
9531
9541
|
<script data-stx-scoped>
|
|
@@ -9535,18 +9545,18 @@ ${_}${U}
|
|
|
9535
9545
|
return { ${W} };
|
|
9536
9546
|
}
|
|
9537
9547
|
if(window.stx)window.stx._latestSetup=${G};
|
|
9538
|
-
</script>`,j=$;for(let O of Q)j=j.split(O.fullMatch).join("");if(j.includes("<body"))j=j.replace(/<body([^>]*)>/,`<body$1 data-stx="${G}">`);else{let O=["script","style","html","head","meta","link","title","!doctype"];j=j.replace(/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*)>/
|
|
9548
|
+
</script>`,j=$;for(let O of Q)j=j.split(O.fullMatch).join("");if(j.includes("<body"))j=j.replace(/<body([^>]*)>/,`<body$1 data-stx="${G}">`);else{let O=["script","style","html","head","meta","link","title","!doctype"],L=!1;j=j.replace(/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*)>/gi,(V,H,F)=>{if(L||O.includes(H.toLowerCase()))return V;return L=!0,`<${H}${F} data-stx="${G}">`})}return{output:j,setupCode:B}}function VX($){let Z=$,Y=[],X=new Set,J=0,Q=0,G=Z.length,K="",q=()=>{Q++;let j=!1;while(Q<G){let O=Z[Q];if(O==="\\"){Q+=2;continue}if(O==="["&&!j){j=!0,Q++;continue}if(O==="]"&&j){j=!1,Q++;continue}if(O==="/"&&!j){Q++;while(Q<G&&/[gimsuyd]/.test(Z[Q]))Q++;return}if(O===`
|
|
9539
9549
|
`)return;Q++}},z=()=>{if(!K)return!0;if(/[\w)\]]/.test(K))return!1;return!0},U=(j)=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]===j){Q++;return}Q++}},W=()=>{Q++;while(Q<G){if(Z[Q]==="\\"){Q+=2;continue}if(Z[Q]==="`"){Q++;return}if(Z[Q]==="$"&&Z[Q+1]==="{"){Q+=2;let j=1;while(Q<G&&j>0)if(Z[Q]==="{")j++,Q++;else if(Z[Q]==="}")j--,Q++;else if(Z[Q]==="'"||Z[Q]==='"')U(Z[Q]);else if(Z[Q]==="`")W();else Q++;continue}Q++}},_=()=>{if(Z[Q]==="/"&&Z[Q+1]==="/"){while(Q<G&&Z[Q]!==`
|
|
9540
|
-
`)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},B=()=>{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
|
|
9550
|
+
`)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},B=()=>{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 O=Z.slice(Q).match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(O){O[1].split(",").forEach((F)=>{let A=F.trim();if(!A)return;let w=A.indexOf(":"),N=(w>=0?A.slice(w+1).trim():A).split(/[\s=]/)[0];if(N&&!X.has(N))Y.push(N),X.add(N)});return}let L=Z.slice(Q).match(/^(?:const|let|var)\s+\[([^\]]+)\]\s*=/);if(L){L[1].split(",").forEach((F)=>{let A=F.trim().replace(/^\.\.\./,"");if(!A)return;let w=A.split(/[\s=]/)[0];if(w&&!X.has(w))Y.push(w),X.add(w)});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 H=Z.slice(Q).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(H){let F=H[1];if(!X.has(F))Y.push(F),X.add(F)}};while(Q<G){if(_())continue;if(Z[Q]==="'"||Z[Q]==='"'){U(Z[Q]),K=Z[Q-1];continue}if(Z[Q]==="`"){W(),K="`";continue}if(Z[Q]==="/"&&Z[Q+1]!=="/"&&Z[Q+1]!=="*"&&z()){q(),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])))B();if(!/\s/.test(Z[Q]))K=Z[Q];Q++}return Y.join(", ")}async function o6($,Z,Y,X){if(!c4($))return $;let J=$;if(Z.skipSignalsRuntime)return J;let{output:Q,setupCode:G}=await FX(J,Y,X);if(J=Q,J=await UX(J,Z),J=zX(J),G)if(J.includes("</head>"))J=J.replace("</head>",`${G}
|
|
9541
9551
|
</head>`);else if(J.includes("<body"))J=J.replace(/<body([^>]*)>/,`<body$1>
|
|
9542
9552
|
${G}`);else J=J+`
|
|
9543
|
-
`+G;let q=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),z=q&&/data-stx/.test(q[1]);if(!G&&!z&&q&&!/data-stx-auto/.test(q[1])){let U=/<body[^>]*>/i,W=/<(script|style)\b[\s\S]*?<\/\1>/gi,_=[],B;while((B=W.exec(J))!==null)_.push([B.index,B.index+B[0].length]);let j=0,O=-1;while(j<J.length){U.lastIndex=j;let L=U.exec(J.slice(j));if(!L)break;let
|
|
9553
|
+
`+G;let q=J.replace(/<script\b[\s\S]*?<\/script>/gi,"").replace(/<style\b[\s\S]*?<\/style>/gi,"").match(/<body([^>]*)>/i),z=q&&/data-stx/.test(q[1]);if(!G&&!z&&q&&!/data-stx-auto/.test(q[1])){let U=/<body[^>]*>/i,W=/<(script|style)\b[\s\S]*?<\/\1>/gi,_=[],B;while((B=W.exec(J))!==null)_.push([B.index,B.index+B[0].length]);let j=0,O=-1;while(j<J.length){U.lastIndex=j;let L=U.exec(J.slice(j));if(!L)break;let V=j+L.index;if(!_.some(([F,A])=>V>=F&&V<A)){O=V;break}j=V+L[0].length}if(O!==-1){let L=J.slice(0,O),V=J.slice(O).replace(U,(H)=>H.replace(/^<body([^>]*)>$/i,"<body$1 data-stx-auto>"));J=L+V}}return J}var L_=0,m4,HX,BX,c6,T_;var s6=C(()=>{a5();z4();w0();m4=/<script\b([^>]*)>/gi,HX=/^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;BX=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"]);c6=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]);T_=/\s(?::else-if|x-else-if|@else-if|:else|x-else|@else)(?=[=\s/>])/});import w5 from"path";function AX($){return $.startsWith("http://")||$.startsWith("https://")||$.startsWith("//")}async function RX($,Z,Y){try{let X;if($.startsWith("/")){let J=Z;for(let Q=0;Q<5;Q++){let G=w5.join(J,$);if(await Bun.file(G).exists())return G;J=w5.dirname(J)}X=w5.join(Z,$)}else if($.startsWith("./")||$.startsWith("../"))X=w5.resolve(Z,$);else X=w5.resolve(Z,$);if(await Bun.file(X).exists())return X;return null}catch{return null}}async function NX($,Z,Y){let X=$,J=w5.dirname(Z),Q=/<script\b([^>]*)src=["']([^"']+)["']([^>]*)><\/script>/gi,G;while((G=Q.exec(X))!==null){let[z,U,W,_]=G;if(AX(W))continue;let B=await RX(W,J,Z);if(B)try{let j=await Bun.file(B).text();if(Y.add(B),W.endsWith(".ts")||W.endsWith(".tsx")){let L=await Bun.build({entrypoints:[B],target:"browser",minify:!1,define:r0()});if(L.outputs.length>0)j=await L.outputs[0].text()}let O=`<script>
|
|
9544
9554
|
// Source: ${W}
|
|
9545
9555
|
${j}
|
|
9546
|
-
</script>`;X=X.replace(z,O),Q.lastIndex=0}catch(j){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,q;while((q=K.exec(X))!==null){let[z,U,W,_]=q,B=U+_;if(AX(W))continue;if(/rel=["']stylesheet["']/.test(B)||W.endsWith(".css")){let O=await RX(W,J,Z);if(O)try{let L=await Bun.file(O).text();Y.add(O);let
|
|
9556
|
+
</script>`;X=X.replace(z,O),Q.lastIndex=0}catch(j){}}let K=/<link\b([^>]*)href=["']([^"']+)["']([^>]*)(?:\/?>)/gi,q;while((q=K.exec(X))!==null){let[z,U,W,_]=q,B=U+_;if(AX(W))continue;if(/rel=["']stylesheet["']/.test(B)||W.endsWith(".css")){let O=await RX(W,J,Z);if(O)try{let L=await Bun.file(O).text();Y.add(O);let V=`<style>
|
|
9547
9557
|
/* Source: ${W} */
|
|
9548
9558
|
${L}
|
|
9549
|
-
</style>`;X=X.replace(z,
|
|
9559
|
+
</style>`;X=X.replace(z,V),K.lastIndex=0}catch(L){}}}return X}var TX=C(()=>{a1()});function l4($,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,q=G+1,z=null,U=!1;while(q<Y.length&&K>0){let F=Y[q];if(U){U=!1,q++;continue}if(F==="\\"&&z){U=!0,q++;continue}if(z){if(F===z)z=null;q++;continue}if(F==='"'||F==="'"||F==="`"){z=F,q++;continue}if(F==="(")K++;else if(F===")"){if(K--,K===0)break}q++}if(K!==0)break;let W=Y.substring(G+1,q).trim(),_=Y.substring(Q,q+1),B=-1,j=0,O=null,L=!1;for(let F=0;F<W.length;F++){let A=W[F];if(L){L=!1;continue}if(A==="\\"&&O){L=!0;continue}if(O){if(A===O)O=null;continue}if(A==='"'||A==="'"||A==="`"){O=A;continue}if(A==="("||A==="["||A==="{")j++;else if(A===")"||A==="]"||A==="}")j--;if(A===","&&j===0){B=F;break}}let V=B>=0?W.substring(0,B).trim():W,H=B>=0?W.substring(B+1).trim():void 0;try{let F=V.trim(),A;if($0(F))A=Z0(F,Object.keys(Z))(...Object.values(Z));else A=void 0;let w;if(H==="true")w=JSON.stringify(A,null,2);else w=JSON.stringify(A);let R=w.replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029");Y=Y.substring(0,Q)+R+Y.substring(q+1),X.lastIndex=Q+R.length}catch(F){p0.log(F instanceof Error?F:Error(String(F)),{directive:"@json"},"error"),X.lastIndex=Q+_.length}}return Y}function i4($){return $.replace(/@once\s*([\s\S]*?)@endonce/g,"$1")}function MX($){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,q=G;while(q<Z.length&&K>0){if(Z[q]==="(")K++;else if(Z[q]===")")K--;q++}if(K!==0)continue;let z=Z.slice(G,q-1).trim(),U=q,W=Z.slice(U),_=W.indexOf("@endmemo");if(_===-1)continue;let B=W.slice(0,_),j=U+_+8,O=B.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)/),L=O?O[0].length:0,V=B.slice(L),H=B.match(/(\s*)$/),F=H?H[0].length:0,A=V.slice(0,V.length-F),w=A.match(/^<([a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*?)?(\/?)>/),R;if(w){let[N,M,T="",I]=w,D=`<${M}${T} data-stx-memo="${z}"${I}>`;R=B.slice(0,L)+D+A.slice(N.length)+B.slice(L+A.length)}else R=`${B.slice(0,L)}<div data-stx-memo="${z}">${A}</div>${B.slice(L+A.length)}`;J.push({start:Q,end:j,replacement:R}),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 r6($){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 IX($){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,q=!1,z=!1,U=-1;while(K<$.length){let O=$[K];if(q){if(O==="'")q=!1}else if(z){if(O==='"')z=!1}else if(O==="'")q=!0;else if(O==='"')z=!0;else if(O===">"){U=K;break}K++}if(U===-1)continue;if($.slice(G,U+1).includes("x-cloak"))continue;let _=$.slice(U+1),B=_.indexOf("</"),j=B>=0?_.slice(0,B):_.slice(0,200);if(/\{\{[\s\S]*?\}\}/.test(j))X+=$.slice(J,U)+" x-cloak>",J=U+1}return X+=$.slice(J),X}function DX($){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}>`,O=$.toLowerCase().indexOf(j,Q);if(O!==-1)Z.lastIndex=O+j.length;continue}let K=Q+J[0].length,q=!1,z=!1,U=-1;while(K<$.length){let j=$[K];if(q){if(j==="'")q=!1}else if(z){if(j==='"')z=!1}else if(j==="'")q=!0;else if(j==='"')z=!0;else if(j===">"){U=K;break}K++}if(U===-1)continue;let W=$.slice(Q+J[0].length,U);if(/(?:^|\s)x-cloak(?:=|\s|\/|>|$)/.test(W))continue;if(!D_.test(W))continue;let _=$[U-1]==="/",B=_?U-1:U;Y+=`${$.slice(X,B)} x-cloak${_?" ":""}`,X=B}return Y+=$.slice(X),Y}var D_;var a6=C(()=>{K1();V0();D_=/(?:^|\s)(?::else-if|:if|:else|:show|x-else-if|x-if|x-else|x-show|@if|@show)(?:=|\s|\/|>|$)/});function n4($,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:q}of E_){if(J.some((U)=>K.includes(U)||G.source.includes(U)))continue;G.lastIndex=0;let z=$.match(G);if(z&&z.length>0){let U=$.split(`
|
|
9550
9560
|
`),W=[];U.forEach((B,j)=>{if(G.lastIndex=0,G.test(B))W.push(j+1)});let _=W.length>0?` (line${W.length>1?"s":""}: ${W.join(", ")})`:"";Q.push(` \u2717 ${K}${_}
|
|
9551
9561
|
\u2192 ${q}`)}}if(Q.length>0&&X.enabled){let K=`[STX] DOM API violation in ${Z.split("/").pop()||Z}:
|
|
9552
9562
|
${Q.join(`
|
|
@@ -11293,12 +11303,12 @@ else {
|
|
|
11293
11303
|
|
|
11294
11304
|
console.log('[stx] Keep-alive runtime initialized');
|
|
11295
11305
|
})();
|
|
11296
|
-
`}function IB($){if(typeof document<"u")document.addEventListener("stx:activated",(Z)=>{$(Z.detail)})}function DB($){if(typeof document<"u")document.addEventListener("stx:deactivated",(Z)=>{$(Z.detail)})}var FB=0;var aX={};p(aX,{useVirtualList:()=>oX,processVirtualListDirectives:()=>$9,processVirtualGridDirectives:()=>rX,processInfiniteListDirectives:()=>sX,generateVirtualListCSS:()=>nX,default:()=>EB,createVirtualList:()=>e6});function e6($,Z){let{itemHeight:Y,containerHeight:X,overscan:J=3,keyProperty:Q="id",dynamicHeight:G=!1,estimatedItemHeight:K=Y,direction:q="vertical"}=Z,z=[...$],U=0,W=new Map;function _(){if(G)return B();let R=Math.max(0,Math.floor(U/Y)-J),N=Math.ceil(X/Y),M=Math.min(z.length-1,R+N+J*2);return{startIndex:R,endIndex:M}}function B(){let R=0,N=0,M=z.length-1;for(let T=0;T<z.length;T++){let I=W.get(T)||K;if(R+I>U){N=Math.max(0,T-J);break}R+=I}R=0;for(let T=0;T<z.length;T++){let I=W.get(T)||K;if(R+=I,R>U+X){M=Math.min(z.length-1,T+J);break}}return{startIndex:N,endIndex:M}}function j(){if(G){let R=0;for(let N=0;N<z.length;N++)R+=W.get(N)||K;return R}return z.length*Y}function O(R){if(G){let N=0;for(let M=0;M<R;M++)N+=W.get(M)||K;return N}return R*Y}function L(){let{startIndex:R,endIndex:N}=_();return{startIndex:R,endIndex:N,scrollTop:U,totalHeight:j(),visibleItems:z.slice(R,N+1),itemHeights:new Map(W)}}function
|
|
11306
|
+
`}function IB($){if(typeof document<"u")document.addEventListener("stx:activated",(Z)=>{$(Z.detail)})}function DB($){if(typeof document<"u")document.addEventListener("stx:deactivated",(Z)=>{$(Z.detail)})}var FB=0;var aX={};p(aX,{useVirtualList:()=>oX,processVirtualListDirectives:()=>$9,processVirtualGridDirectives:()=>rX,processInfiniteListDirectives:()=>sX,generateVirtualListCSS:()=>nX,default:()=>EB,createVirtualList:()=>e6});function e6($,Z){let{itemHeight:Y,containerHeight:X,overscan:J=3,keyProperty:Q="id",dynamicHeight:G=!1,estimatedItemHeight:K=Y,direction:q="vertical"}=Z,z=[...$],U=0,W=new Map;function _(){if(G)return B();let R=Math.max(0,Math.floor(U/Y)-J),N=Math.ceil(X/Y),M=Math.min(z.length-1,R+N+J*2);return{startIndex:R,endIndex:M}}function B(){let R=0,N=0,M=z.length-1;for(let T=0;T<z.length;T++){let I=W.get(T)||K;if(R+I>U){N=Math.max(0,T-J);break}R+=I}R=0;for(let T=0;T<z.length;T++){let I=W.get(T)||K;if(R+=I,R>U+X){M=Math.min(z.length-1,T+J);break}}return{startIndex:N,endIndex:M}}function j(){if(G){let R=0;for(let N=0;N<z.length;N++)R+=W.get(N)||K;return R}return z.length*Y}function O(R){if(G){let N=0;for(let M=0;M<R;M++)N+=W.get(M)||K;return N}return R*Y}function L(){let{startIndex:R,endIndex:N}=_();return{startIndex:R,endIndex:N,scrollTop:U,totalHeight:j(),visibleItems:z.slice(R,N+1),itemHeights:new Map(W)}}function V(R,N="auto"){let M=O(R);H(M,N)}function H(R,N="auto"){U=Math.max(0,Math.min(R,j()-X))}function F(){_()}function A(R){z=[...R],W.clear(),F()}function w(){z=[],W.clear()}return{scrollToIndex:V,scrollToOffset:H,getState:L,refresh:F,setItems:A,destroy:w}}function $9($,Z={},Y){let X=/@virtualList\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualList/gi;return $.replace(X,(J,Q,G,K)=>{let q=Q.trim(),z=Z[q];if(!z||!Array.isArray(z))return`<!-- virtualList: items "${q}" not found or not an array -->`;let U={itemHeight:50,containerHeight:400,overscan:3};if(G)try{let H=G.trim(),F=Function(`return ${H}`)();U={...U,...F}}catch{}let W=`vlist-${Math.random().toString(36).substring(2,9)}`,_=Math.ceil(U.containerHeight/U.itemHeight),B=U.overscan||3,j=0,O=Math.min(z.length-1,_+B),L="";for(let H=j;H<=O&&H<z.length;H++){let F=z[H],A=K.replace(/\{\{\s*item\s*\}\}/g,typeof F==="object"?JSON.stringify(F):String(F)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(w,R)=>{if(typeof F==="object"&&F!==null)return String(F[R]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(H));L+=`
|
|
11297
11307
|
<div class="virtual-item ${U.itemClass||""}"
|
|
11298
11308
|
style="position: absolute; top: ${H*U.itemHeight}px; height: ${U.itemHeight}px; width: 100%;"
|
|
11299
11309
|
data-index="${H}">
|
|
11300
11310
|
${A}
|
|
11301
|
-
</div>`}let
|
|
11311
|
+
</div>`}let V=z.length*U.itemHeight;return`
|
|
11302
11312
|
<div id="${W}"
|
|
11303
11313
|
class="virtual-list-container ${U.containerClass||""}"
|
|
11304
11314
|
style="position: relative; height: ${U.containerHeight}px; overflow-y: auto;"
|
|
@@ -11306,7 +11316,7 @@ else {
|
|
|
11306
11316
|
data-total-items="${z.length}"
|
|
11307
11317
|
data-overscan="${B}">
|
|
11308
11318
|
<div class="virtual-list-viewport ${U.viewportClass||""}"
|
|
11309
|
-
style="position: relative; height: ${
|
|
11319
|
+
style="position: relative; height: ${V}px; width: 100%;">
|
|
11310
11320
|
${L}
|
|
11311
11321
|
</div>
|
|
11312
11322
|
</div>
|
|
@@ -11436,7 +11446,7 @@ else {
|
|
|
11436
11446
|
${q}
|
|
11437
11447
|
</div>
|
|
11438
11448
|
</div>
|
|
11439
|
-
`})}function rX($,Z={},Y){let X=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return $.replace(X,(J,Q,G,K)=>{let q=Q.trim(),z=Z[q];if(!z||!Array.isArray(z))return`<!-- virtualGrid: items "${q}" not found or not an array -->`;let U={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(G)try{let
|
|
11449
|
+
`})}function rX($,Z={},Y){let X=/@virtualGrid\s*\(\s*([^,]+)\s*(?:,\s*(\{[^}]*\}))?\s*\)\s*([\s\S]*?)@endvirtualGrid/gi;return $.replace(X,(J,Q,G,K)=>{let q=Q.trim(),z=Z[q];if(!z||!Array.isArray(z))return`<!-- virtualGrid: items "${q}" not found or not an array -->`;let U={columns:3,rowHeight:100,containerHeight:400,gap:10,overscan:2};if(G)try{let F=Function(`return ${G.trim()}`)();U={...U,...F}}catch{}let W=`vgrid-${Math.random().toString(36).substring(2,9)}`,_=Math.ceil(z.length/U.columns),B=_*(U.rowHeight+(U.gap||0)),j=Math.ceil(U.containerHeight/(U.rowHeight+(U.gap||0))),O=U.overscan||2,L=0,V=Math.min(_-1,j+O),H="";for(let F=L;F<=V;F++)for(let A=0;A<U.columns;A++){let w=F*U.columns+A;if(w>=z.length)break;let R=z[w],N=A*(100/U.columns),M=F*(U.rowHeight+(U.gap||0)),T=K.replace(/\{\{\s*item\s*\}\}/g,typeof R==="object"?JSON.stringify(R):String(R)).replace(/\{\{\s*item\.(\w+)\s*\}\}/g,(I,D)=>{if(typeof R==="object"&&R!==null)return String(R[D]??"");return""}).replace(/\{\{\s*index\s*\}\}/g,String(w));H+=`
|
|
11440
11450
|
<div class="virtual-grid-item"
|
|
11441
11451
|
style="position: absolute; top: ${M}px; left: ${N}%; width: calc(${100/U.columns}% - ${U.gap||0}px); height: ${U.rowHeight}px;"
|
|
11442
11452
|
data-index="${w}">
|
|
@@ -11825,7 +11835,7 @@ else {
|
|
|
11825
11835
|
})();
|
|
11826
11836
|
</script>
|
|
11827
11837
|
`}function XJ($,Z={},Y){let X=$,J=!1,Q=/@client:(load|idle|visible|media|only|hover|event)/i.test($);if(X=R5(X,"load",Z),X=R5(X,"idle",Z),X=R5(X,"visible",Z),X=R5(X,"media",Z),X=vB(X),X=R5(X,"hover",Z),X=R5(X,"event",Z),J=Q&&X!==$,J)X+=`
|
|
11828
|
-
`+eX();return X}function R5($,Z,Y){let X=new RegExp(`@client:${Z}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return $.replace(X,(J,Q,G)=>{let K={strategy:Z};if(Q)try{let O=Q.split(",").map((L)=>L.trim());for(let L of O){let[
|
|
11838
|
+
`+eX();return X}function R5($,Z,Y){let X=new RegExp(`@client:${Z}(?:\\s*\\(([^)]*)\\))?\\s*([\\s\\S]*?)@endclient`,"gi");return $.replace(X,(J,Q,G)=>{let K={strategy:Z};if(Q)try{let O=Q.split(",").map((L)=>L.trim());for(let L of O){let[V,H]=L.split(":").map((F)=>F.trim());if(V&&H){let F=H.replace(/^['"]|['"]$/g,"");K[V]=F}}}catch{}let q=`island-${Math.random().toString(36).substring(2,9)}`,z=$J(G.trim()),U=ZJ(G.trim(),Y),W=[];if(K.rootMargin)W.push(`data-root-margin="${K.rootMargin}"`);if(K.threshold!==void 0)W.push(`data-threshold="${K.threshold}"`);if(K.media)W.push(`data-media="${K.media}"`);if(K.event)W.push(`data-event="${K.event}"`);if(z)W.push(`data-component="${z}"`);let B=Object.keys(U).length>0?`
|
|
11829
11839
|
<script type="application/json" data-island-props="${q}">${JSON.stringify(U)}</script>`:"",j="";switch(Z){case"load":j=kB(q);break;case"idle":j=SB(q,K);break;case"visible":j=bB(q,K);break;case"media":j=yB(q,K);break;case"hover":j=CB(q);break;case"event":j=PB(q,K);break}return`
|
|
11830
11840
|
<div data-island="${q}"
|
|
11831
11841
|
data-strategy="${Z}"
|
|
@@ -11912,7 +11922,7 @@ else {
|
|
|
11912
11922
|
}
|
|
11913
11923
|
})();
|
|
11914
11924
|
</script>
|
|
11915
|
-
`})}function o1($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>o1(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((X,J)=>Y.set(o1(J),o1(X))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((X)=>Y.add(o1(X))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=o1($[Y]);return Z}function RJ($,Z=100){let Y=N5($()),X=null,J=()=>{if(X)clearTimeout(X);X=setTimeout(()=>{Y.value=$()},Z)};return Z$($).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 NJ($,Z=100){let Y=N5($()),X=0,J=()=>{let G=Date.now();if(G-X>=Z)X=G,Y.value=$()};return Z$($).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 Z1=null,s4,$$,fB;var MJ=C(()=>{s4=[],$$=new WeakMap;fB={ref:N5,computed:Z$,watch:LJ,watchMultiple:FJ,watchEffect:VJ,isRef:I1,unref:jJ,toRefs:HJ,shallowRef:OJ,debouncedComputed:RJ,throttledComputed:NJ,processComputedDirectives:wJ,processWatchDirectives:AJ}});var kJ={};p(kJ,{v:()=>gB,processHasErrorsDirective:()=>EJ,processFormValidationDirectives:()=>dB,processErrorsDirective:()=>DJ,processErrorDirective:()=>IJ,defineForm:()=>hB,Validator:()=>T5});class T5{rules=[];defaultValue="";addRule($){let Z=new T5;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 T5;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 T5;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 hB($,Z){let Y=Object.keys($),X={},J={},Q={},G={},K={};for(let H of Y)X[H]=Z?.[H]??$[H].getDefaultValue(),J[H]=[],Q[H]=!1,G[H]=!1,K[H]=!1;let q=!1;async function z(H){K[H]=!0;let
|
|
11925
|
+
`})}function o1($){if($===null||typeof $!=="object")return $;if(Array.isArray($))return $.map((Y)=>o1(Y));if($ instanceof Date)return new Date($.getTime());if($ instanceof Map){let Y=new Map;return $.forEach((X,J)=>Y.set(o1(J),o1(X))),Y}if($ instanceof Set){let Y=new Set;return $.forEach((X)=>Y.add(o1(X))),Y}let Z={};for(let Y in $)if(Object.prototype.hasOwnProperty.call($,Y))Z[Y]=o1($[Y]);return Z}function RJ($,Z=100){let Y=N5($()),X=null,J=()=>{if(X)clearTimeout(X);X=setTimeout(()=>{Y.value=$()},Z)};return Z$($).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 NJ($,Z=100){let Y=N5($()),X=0,J=()=>{let G=Date.now();if(G-X>=Z)X=G,Y.value=$()};return Z$($).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 Z1=null,s4,$$,fB;var MJ=C(()=>{s4=[],$$=new WeakMap;fB={ref:N5,computed:Z$,watch:LJ,watchMultiple:FJ,watchEffect:VJ,isRef:I1,unref:jJ,toRefs:HJ,shallowRef:OJ,debouncedComputed:RJ,throttledComputed:NJ,processComputedDirectives:wJ,processWatchDirectives:AJ}});var kJ={};p(kJ,{v:()=>gB,processHasErrorsDirective:()=>EJ,processFormValidationDirectives:()=>dB,processErrorsDirective:()=>DJ,processErrorDirective:()=>IJ,defineForm:()=>hB,Validator:()=>T5});class T5{rules=[];defaultValue="";addRule($){let Z=new T5;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 T5;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 T5;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 hB($,Z){let Y=Object.keys($),X={},J={},Q={},G={},K={};for(let H of Y)X[H]=Z?.[H]??$[H].getDefaultValue(),J[H]=[],Q[H]=!1,G[H]=!1,K[H]=!1;let q=!1;async function z(H){K[H]=!0;let F=await $[H].validate(X[H],X);return J[H]=F,K[H]=!1,F.length===0}async function U(){q=!0;let H=await Promise.all(Y.map(z));return q=!1,H.every(Boolean)}function W(){for(let H of Y)X[H]=Z?.[H]??$[H].getDefaultValue(),J[H]=[],Q[H]=!1,G[H]=!1}function _(H){for(let F of Y)if(F in H)X[F]=H[F],G[F]=!0}function B(H,F){X[H]=F,G[H]=!0}function j(H,F=!0){if(Q[H]=F,F)z(H)}function O(H){return{value:X[H],errors:J[H],touched:Q[H],dirty:G[H],valid:J[H].length===0,validating:K[H]}}function L(H){return async(F)=>{F?.preventDefault?.();for(let w of Y)Q[w]=!0;if(await U())await H(X)}}return{values:X,errors:J,touched:Q,dirty:G,get isValid(){return Y.every((H)=>J[H].length===0)},get isValidating(){return q||Y.some((H)=>K[H])},get isDirty(){return Y.some((H)=>G[H])},validate:U,validateField:z,reset:W,setValues:_,setFieldValue:B,setFieldTouched:j,getFieldState:O,handleSubmit:L}}function IJ($,Z,Y){let X=/@error\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderror/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),q=Z;for(let U of K)if(q&&typeof q==="object"&&U in q)q=q[U];else return"";let z=q;if(!z||!Array.isArray(z)||z.length===0)return"";return z.map((U)=>{return G.replace(/\{\{\s*message\s*\}\}/g,U)}).join(`
|
|
11916
11926
|
`)}catch{return""}})}function DJ($,Z,Y){let X=/@errors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@enderrors/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),q=Z;for(let U of K)if(q&&typeof q==="object"&&U in q)q=q[U];else return"";let z=q;if(!z||!Array.isArray(z)||z.length===0)return"";return z.map((U)=>G.replace(/\{\{\s*message\s*\}\}/g,U)).join(`
|
|
11917
11927
|
`)}catch{return""}})}function EJ($,Z,Y){let X=/@hasErrors\s*\(\s*([^)]+)\s*\)([\s\S]*?)@endhasErrors/g;return $.replace(X,(J,Q,G)=>{try{let K=Q.trim().split("."),q=Z;for(let U of K)if(q&&typeof q==="object"&&U in q)q=q[U];else return"";let z=q;if(!z||!Array.isArray(z)||z.length===0)return"";return G}catch{return""}})}function dB($,Z,Y){let X=$;return X=IJ(X,Z,Y),X=DJ(X,Z,Y),X=EJ(X,Z,Y),X}var gB;var SJ=C(()=>{gB=new T5});var CJ={};p(CJ,{processXElementDirectives:()=>mB,hasXElementDirectives:()=>yJ,generateXElementRuntime:()=>bJ});function bJ(){return`<script data-stx-scoped>
|
|
11918
11928
|
(function() {
|
|
@@ -13395,15 +13405,15 @@ if ('serviceWorker' in navigator) {
|
|
|
13395
13405
|
`,X+2),X===-1)return-1;X+=1,J=!0;continue}if(K==="/"&&$[X+1]==="*"){let q=$.indexOf("*/",X+2);if(q===-1)return-1;X=q+2,J=!0;continue}if(K==="/"&&J){let q=X+1,z=!1;while(q<Y){let U=$[q];if(U==="\\"){q+=2;continue}if(U==="[")z=!0;else if(U==="]")z=!1;else if(U==="/"&&!z){q++;break}else if(U===`
|
|
13396
13406
|
`){q=-1;break}q++}if(q===-1){X++,J=!1;continue}while(q<Y&&/[a-z]/.test($[q]))q++;X=q,J=!1;continue}if(K==="'"||K==='"'){let q=K;X++;while(X<Y){if($[X]==="\\"){X+=2;continue}if($[X]===q){X++;break}if($[X]===`
|
|
13397
13407
|
`)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||!x5()&&!l$())&&Y&&Y.endsWith(".stx"))o3($,Y);try{return await p9.timeAsync("template-processing",async()=>{let G=await Bj($,Z,Y,X,J);if(Q)G=r6(G);if(Q&&X.autoShell&&X.buildMode!=="compile"){let K=X.app?.head||{},z=(Z.__stx_runtime_head||null)??m5(),U=(Z.__stx_head_raw||"").trim(),W,_=U.match(/<title[^>]*>([\s\S]*?)<\/title>/i);if(_)W=_[1].trim(),U=U.replace(_[0],"").trim();let B=Z.__sections?.title,j=z.title||W||B,O={...K,...j&&{title:j},meta:[...K.meta||[],...z.meta||[]],link:[...K.link||[],...z.link||[]],script:[...K.script||[],...z.script||[]],headRaw:[K.headRaw,U].filter(Boolean).join(`
|
|
13398
|
-
`),...z.htmlAttrs&&{htmlAttrs:{...K.htmlAttrs||{},...z.htmlAttrs}},...z.bodyAttrs&&{bodyAttrs:{...K.bodyAttrs||{},...z.bodyAttrs}}},L=x6(G);if(G=YX(G,O),L)G=ZX(G,K);let
|
|
13399
|
-
<meta name="stx-layout" content="${oJ(
|
|
13400
|
-
<meta name="stx-layout-group" content="${oJ(A)}">`)}let H=G.match(/function (__stx_setup_\d+_\d+)\(/);if(H&&G.includes("<body")&&!G.match(/<body[^>]*data-stx=/)){G=G.replace(/<body([^>]*)>/,`<body$1 data-stx="${H[1]}">`);let
|
|
13401
|
-
`+U+G.slice(B)}}}}catch{}if(Q&&Z.__stx_inject_css!==!1)G=await w3(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof o$)throw G;let K=G instanceof Error?G.message:String(G),q=new v1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(p0.log(q,{filePath:Y,context:Z}),J3.logDetailedError(q,{filePath:Y,template:$.substring(0,500)}),X.debug)throw q;return Y3.createFallbackContent("Template Processing",q)}}async function Bj($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!y0.isAbsolute(X.partialsDir)?y0.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!y0.isAbsolute(X.componentsDir)?y0.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!y0.isAbsolute(X.layoutsDir)?y0.resolve(Q,X.layoutsDir):X.layoutsDir},K=G,q=$;await Oj(Y,Z),Hj(Z,K),q=await G5(()=>xY(q,Z,Y,K),q,(H)=>{p0.log(H,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${H.message}`)}),q=q.replace(/\{\{--[\s\S]*?--\}\}/g,"");let z=E5(q,y9,(H,
|
|
13408
|
+
`),...z.htmlAttrs&&{htmlAttrs:{...K.htmlAttrs||{},...z.htmlAttrs}},...z.bodyAttrs&&{bodyAttrs:{...K.bodyAttrs||{},...z.bodyAttrs}}},L=x6(G);if(G=YX(G,O),L)G=ZX(G,K);let V=G.match(/<!-- stx-layout: ([^ ]+) -->/);if(V&&G.includes("<head")){let F=V[1],A=Wj(F);G=G.replace("<head>",`<head>
|
|
13409
|
+
<meta name="stx-layout" content="${oJ(F)}">
|
|
13410
|
+
<meta name="stx-layout-group" content="${oJ(A)}">`)}let H=G.match(/function (__stx_setup_\d+_\d+)\(/);if(H&&G.includes("<body")&&!G.match(/<body[^>]*data-stx=/)){G=G.replace(/<body([^>]*)>/,`<body$1 data-stx="${H[1]}">`);let F=new RegExp(`(<(?!body)[a-zA-Z][^>]*) data-stx="${H[1]}"`,"i");G=G.replace(F,"$1")}}if(Q)G=$X(G);if(Q)try{let{getStoreScript:K}=await Promise.resolve().then(() => (kX(),EX)),q=X.storesDir,z=await K(q);if(z){let U=`<script data-stx-stores>${z}</script>`,W=G.indexOf("<script data-stx-scoped>");if(W!==-1){let _=G.indexOf("</script>",W+24);if(_!==-1){let B=_+9;G=G.slice(0,B)+`
|
|
13411
|
+
`+U+G.slice(B)}}}}catch{}if(Q&&Z.__stx_inject_css!==!1)G=await w3(G);return G=G.replace(/\x00STX_ESCAPED_AT\x00/g,"@"),G})}catch(G){if(G instanceof o$)throw G;let K=G instanceof Error?G.message:String(G),q=new v1(`Template processing failed: ${K}`,Y,void 0,void 0,$.substring(0,200)+($.length>200?"...":""));if(p0.log(q,{filePath:Y,context:Z}),J3.logDetailedError(q,{filePath:Y,template:$.substring(0,500)}),X.debug)throw q;return Y3.createFallbackContent("Template Processing",q)}}async function Bj($,Z,Y,X,J){let Q=process.cwd(),G={...X,partialsDir:X.partialsDir&&!y0.isAbsolute(X.partialsDir)?y0.resolve(Q,X.partialsDir):X.partialsDir,componentsDir:X.componentsDir&&!y0.isAbsolute(X.componentsDir)?y0.resolve(Q,X.componentsDir):X.componentsDir,layoutsDir:X.layoutsDir&&!y0.isAbsolute(X.layoutsDir)?y0.resolve(Q,X.layoutsDir):X.layoutsDir},K=G,q=$;await Oj(Y,Z),Hj(Z,K),q=await G5(()=>xY(q,Z,Y,K),q,(H)=>{p0.log(H,{filePath:Y,phase:"pre-processing-middleware"},"warning"),console.warn(`[stx] pre-processing middleware failed for ${Y}: ${H.message}`)}),q=q.replace(/\{\{--[\s\S]*?--\}\}/g,"");let z=E5(q,y9,(H,F)=>`\x00STX_HTML_COMMENT_${F}\x00`);q=z.output;let U=z.tokens,W=(H)=>U.length===0?H:H.replace(/\x00STX_HTML_COMMENT_(\d+)\x00/g,(F,A)=>U[Number(A)]??""),_="\x00STX_ESCAPED_AT\x00";q=q.replace(/@@/g,_),q=q.replace(/@\{\{([\s\S]*?)\}\}/g,(H,F)=>{return`{{ ${F} }}`}),q=nY(q),q=await NX(q,Y,J);let B={};q=b6(q,B);let j={...Z.__sections||{}},O="",L=/@nolayout\b/.test(q);if(L)q=q.replace(/@nolayout\b\s*/g,"");let V=q.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(V)O=V[1],q=q.replace(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/g,"");if(!O&&!L&&K.defaultLayout){let H=/<!DOCTYPE\s/i.test(q),F=/@section\s*\(/.test(q);if(!H||F){let A="",w=y0.dirname(Y),R=K.layoutsDir?y0.dirname(K.layoutsDir):process.cwd();for(let N=0;N<20;N++){let M=y0.join(w,"_layout.stx");if(await i(M)){A=M;break}let T=y0.dirname(w);if(T===w||T.length<R.length)break;w=T}if(A)O=A;else if(K.layoutsDir){let N=y0.isAbsolute(K.layoutsDir)?K.layoutsDir:y0.resolve(process.cwd(),K.layoutsDir),M=y0.join(N,`${K.defaultLayout}.stx`);if(await i(M))O=M}if(O&&!F)q=`@section('content')
|
|
13402
13412
|
${q.trim()}
|
|
13403
|
-
@endsection`}}if(q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,
|
|
13413
|
+
@endsection`}}if(q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(H,F,A)=>{return j[F]=A,""}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(H,F,A)=>{if(/^(['"]).*\1$/.test(A.trim()))return H;try{let w=e(A.trim(),Z);if(w===void 0)return H;return j[F]=String(w??""),""}catch{return H}}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(H,F,A)=>{if(A.includes("@parent"))j[F]=A.replace("@parent",s1);else j[F]=A.trim();return""}),Z.__sections=j,q=q.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(H,F,A)=>{return j[F]||A||""}),!("slot"in Z)||Z.slot===void 0)q=q.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""});if(q=y6(q,B),O){let H=[];if(q=q.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi,(F)=>{return H.push(F),""}),H.length>0){let F=H.join(`
|
|
13404
13414
|
`);j.content=j.content?`${j.content}
|
|
13405
|
-
${
|
|
13406
|
-
${q}`,W(q)}catch(H){return p0.log(H instanceof Error?H:Error(String(H)),{layoutPath:O,filePath:Y},"error"),`[Error processing layout: ${H instanceof Error?H.message:String(H)}]`}return W(await sJ(q,Z,Y,G,J))}function jj($,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 Hj($,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 Oj($,Z){await G5(()=>mY($,Z),void 0,(Y)=>{p0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function Lj($,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:q}=await Promise.resolve().then(() => (L5(),T4));await q(G,Z,Y,{preserveExisting:!0})}catch(q){let z=q instanceof Error?q:Error(String(q));p0.log(z,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${z.message}`)}}}async function Fj($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (t0(),h9));return X($,Z,{skipServer:!0})}catch(X){let J=X instanceof Error?X:Error(String(X));return p0.log(J,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${J.message}`),$}}async function sJ($,Z,Y,X,J){let Q=$,G=X;if(await Lj(Q,Z,Y),Q=await Fj(Q,Z,Y),Q=await SY(Q,Z,Y),Q=await bY(Q,Z,Y),Q=await L2(Q,Z,Y,G),e1(Q))Q=l6(Q,Z),Q=n6(Q,Z);Q=i6(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (n3(),i3));Q=K(Q,Z),Q=D6(Q,Z,Y,G),Q=await N4(Q,Z,Y,G,J),Q=await sY(Q,Z,Y,G,J),Q=L9(Q,Z,Y,G);let{processDeferDirectives:q}=await Promise.resolve().then(() => bX);Q=q(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => CX);Q=z(Q,Z,Y);let{processTransitionDirectives:U,processTransitionAttributes:W}=await Promise.resolve().then(() => fX);Q=U(Q,Z,Y),Q=W(Q);let{processErrorBoundaryDirectives:_}=await Promise.resolve().then(() => hX);Q=_(Q,Z,Y);let{processSuspenseDirectives:B}=await Promise.resolve().then(() => dX);Q=B(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => cX);Q=j(Q,Z,Y);let{processKeepAliveDirectives:O}=await Promise.resolve().then(() => iX);Q=O(Q,Z,Y);let{processVirtualListDirectives:L,processVirtualGridDirectives:
|
|
13415
|
+
${F}`:F,Z.__sections=j}}if(O)try{let H;if(y0.isAbsolute(O))H=O,J.add(O);else H=await G5(()=>a$(O,Y,G,J),null,()=>{throw new v1(`Failed to resolve layout path: ${O}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!H){let M=`Layout not found: ${O} (referenced from ${Y})`;if(p0.log(Error(M),{layoutPath:O,filePath:Y},"warning"),G.debug)throw new v1(M,Y);return q}let F=await G5(()=>Bun.file(H).text(),"",()=>{throw new v1(`Failed to read layout file: ${H}`,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 ${H}`);let M={},T=F.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(E,k,S)=>{return M[k]=S.trim(),""});for(let[E,k]of Object.entries(M))if(j[E]&&j[E].includes(s1)){let S=j[E].indexOf(s1);j[E]=j[E].slice(0,S)+k+j[E].slice(S+s1.length)}else if(!j[E])j[E]=k;let I={...Z,__sections:j},D=`@layout('${A[1]}')${T}`;return await U0(D,I,H,G,J)}let w=F.replace(/\{\{--[\s\S]*?--\}\}/g,""),R=b6(w,B),N={};return R=R.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(M,T,I)=>{return N[T]=I.trim(),`@slot('${T}')`}),R=R.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(M,T,I)=>{if(j[T]){let D=j[T];if(D.includes(s1)){let E=N[T]||"",k=D.indexOf(s1);D=D.slice(0,k)+E+D.slice(k+s1.length)}return D}return I||""}),R=jj(R,j),R=R.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),R=y6(R,B),Z.__originalFilePath=Y,q=await sJ(R,Z,H,G,J),q=`<!-- stx-layout: ${O} -->
|
|
13416
|
+
${q}`,W(q)}catch(H){return p0.log(H instanceof Error?H:Error(String(H)),{layoutPath:O,filePath:Y},"error"),`[Error processing layout: ${H instanceof Error?H.message:String(H)}]`}return W(await sJ(q,Z,Y,G,J))}function jj($,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 Hj($,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 Oj($,Z){await G5(()=>mY($,Z),void 0,(Y)=>{p0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function Lj($,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:q}=await Promise.resolve().then(() => (L5(),T4));await q(G,Z,Y,{preserveExisting:!0})}catch(q){let z=q instanceof Error?q:Error(String(q));p0.log(z,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${z.message}`)}}}async function Fj($,Z,Y){try{let{interpolateScriptsInTemplate:X}=await Promise.resolve().then(() => (t0(),h9));return X($,Z,{skipServer:!0})}catch(X){let J=X instanceof Error?X:Error(String(X));return p0.log(J,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${J.message}`),$}}async function sJ($,Z,Y,X,J){let Q=$,G=X;if(await Lj(Q,Z,Y),Q=await Fj(Q,Z,Y),Q=await SY(Q,Z,Y),Q=await bY(Q,Z,Y),Q=await L2(Q,Z,Y,G),e1(Q))Q=l6(Q,Z),Q=n6(Q,Z);Q=i6(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (n3(),i3));Q=K(Q,Z),Q=D6(Q,Z,Y,G),Q=await N4(Q,Z,Y,G,J),Q=await sY(Q,Z,Y,G,J),Q=L9(Q,Z,Y,G);let{processDeferDirectives:q}=await Promise.resolve().then(() => bX);Q=q(Q,Z,Y);let{processTeleportDirectives:z}=await Promise.resolve().then(() => CX);Q=z(Q,Z,Y);let{processTransitionDirectives:U,processTransitionAttributes:W}=await Promise.resolve().then(() => fX);Q=U(Q,Z,Y),Q=W(Q);let{processErrorBoundaryDirectives:_}=await Promise.resolve().then(() => hX);Q=_(Q,Z,Y);let{processSuspenseDirectives:B}=await Promise.resolve().then(() => dX);Q=B(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => cX);Q=j(Q,Z,Y);let{processKeepAliveDirectives:O}=await Promise.resolve().then(() => iX);Q=O(Q,Z,Y);let{processVirtualListDirectives:L,processVirtualGridDirectives:V,processInfiniteListDirectives:H}=await Promise.resolve().then(() => (tX(),aX));Q=L(Q,Z,Y),Q=V(Q,Z,Y),Q=H(Q,Z,Y);let{processPartialHydrationDirectives:F,processStaticDirectives:A}=await Promise.resolve().then(() => (BJ(),_J));Q=F(Q,Z,Y),Q=A(Q);let{processComputedDirectives:w,processWatchDirectives:R}=await Promise.resolve().then(() => (MJ(),TJ));Q=w(Q,Z,Y),Q=R(Q,Z,Y);let{processFormValidationDirectives:N}=await Promise.resolve().then(() => (SJ(),kJ));Q=N(Q,Z,Y);let{processHeadDirective:M,processTitleDirective:T,processMetaDirective:I,resetHead:D}=await Promise.resolve().then(() => (u5(),P3));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let E=M(Q);if(Q=E.content,E.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${E.headContent}
|
|
13407
13417
|
`;if(Q=T(Q,Z),Q=I(Q,Z),Q=hY(Q),Q=E3(Q,Z),Q=H2(Q),Q=PY(Q),Q=await S6(Q,Z,Y,G,J),Q=await N4(Q,Z,Y,G,J),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=r6(Q),Q=g1(Q,Z,Y),Q=k3(Q,Z),Q=S3(Q,Z),Q=l5(Q,Z),Q=x3(Q,Z),Q=f3(Q,Z),Q=await rZ(Q,Z,Y,G),Q=await F7(Q,Z,Y),Q=await p3(Q,Z,Y,G),Q=J7(Q,Z,Y,G),Q=jZ(Q,Z,Y,G),Q=HZ(Q,Z,Y),Q=OZ(Q,Z,Y,G),Q=U2(Q,Z,Y,G),Q=l4(Q,Z),Q=i4(Q),Q=MX(Q),!G.skipEventDirectives)Q=pZ(Q,Z,Y);if(Q=oZ(Q,Z,Y),G.debug){let x=/\bx-data\s*=/.test(Q),g=c4($);if(x&&g)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
|
|
13408
13418
|
Both work on the same page, but they manage separate scopes.
|
|
13409
13419
|
Prefer signals (state/derived/effect) for new components.`)}Q=cY(Q,Z),Q=await a0(Q,Z,Y),Q=IX(Q),Q=DX(Q),Q=xZ(Q);let{processXElementDirectives:k}=await Promise.resolve().then(() => CJ);Q=k(Q);let S=Z.__originalFilePath||Y,b=X$(Z);if(Q=await o6(Q,G,S,b),Q=await fY(Q,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (V9(),F9));Q=await g(Q,{publicDir:x})}if(G.seo?.enabled)Q=LZ(Q,Z,G);let y=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
|
|
@@ -13418,12 +13428,12 @@ ${yZ()}
|
|
|
13418
13428
|
</head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
|
|
13419
13429
|
${g}`);else Q=g+`
|
|
13420
13430
|
`+Q}{let x=/<script\s+server\b[^>]*>/gi,g,u=[];while((g=x.exec(Q))!==null){let s=g.index+g[0].length,Q0=_j(Q,s);if(Q0===-1)continue;let k0=Q0+9;while(k0<Q.length&&/\s/.test(Q[k0]))k0++;u.push({start:g.index,end:k0})}for(let s=u.length-1;s>=0;s--){let{start:Q0,end:k0}=u[s];Q=Q.substring(0,Q0)+Q.substring(k0)}}let E0=k4(Q,Y);if(E0.hasScoped)Q=E0.html;let X0=Z.__stx_event_bindings||[],F0=!1,W0=[],P=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:v}=await Promise.resolve().then(() => (s6(),wX));for(let x of v(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))W0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:u}of W0){F0=!0;let s=u;n4(u,Y,X.strict);let Q0=await J$(u,{eventBindings:X0,attrs:g,hasColonDirectives:P,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:X.buildMode==="compile",serverData:b});Q=Q.replace(x,()=>Q0)}if(F0)Z.__stx_event_bindings=[];return Q}var s1="<!--PARENT_CONTENT_PLACEHOLDER-->";var L4=C(()=>{kZ();w$();Q7();CZ();fZ();H9();L7();U7();cZ();a5();sZ();aZ();U4();W2();O2();V2();K1();u5();t0();N2();y2();kY();CY();E6();w7();gY();$5();dY();z3();w0();uY();lY();oY();rY();v6();s6();T6();TX();a6();t6();V0();s3();a6();t6()});function Nj($){let Z=[],Y=[];return Tj($,Z),Mj($,Z,Y),Ij($,Y),Dj($,Z),{valid:Z.length===0,errors:Z,warnings:Y}}function Tj($,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 Mj($,Z,Y){for(let X of wj){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 q=new RegExp(X.altClose,"g");K+=($.match(q)||[]).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 Ij($,Z){for(let Y of Aj)if(Y.pattern.test($))Z.push({type:"syntax",message:Y.message,suggestion:Y.suggestion})}function Dj($,Z){for(let Y of Rj)if(Y.pattern.test($))Z.push({type:"expression",message:`Security warning: ${Y.message}`,suggestion:"Remove dangerous code from template expressions"})}function Ej($,Z){let Y=$.slice(0,Z).split(`
|
|
13421
|
-
`);return{line:Y.length,column:Y[Y.length-1].length+1}}function kj($,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 Sj($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function bj($){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 wj,Aj,Rj;var rJ=C(()=>{wj=[{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"}],Aj=[{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')"}],Rj=[{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 ZQ={};p(ZQ,{renderSlot:()=>tJ,processSlots:()=>$Q,parseSlots:()=>aJ,parseSlotElement:()=>Cj,extractSlotContent:()=>xj,applySlots:()=>fj});function yj($,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 aJ($){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[U,W,_,B,j]=Q,O=W||_||B,L=Q.index+U.length,
|
|
13422
|
-
`)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},z=()=>{if(X!==0)return;let U=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let j=U[2].split(",").map((O)=>{let L=O.trim().split(":");return L[L.length-1].trim()});for(let O of j)if(O&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(O)&&!Y.has(O))Z.push(O),Y.add(O);return}let W=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(W){let j=W[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(q())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])))z();J++}return Z}function uj($){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 pj($){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 cj($,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 q=$[X];if(q==="}")Q++;else if(q==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let q of uj(K)){let z=q.trim();if(!z||z.startsWith("..."))continue;let U=pj(z);if(U===-1)continue;let W=z.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(W))continue;if(Z[W]!==void 0)continue;let _=z.slice(U+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[W]=j(...B.map((O)=>Z[O]))}catch{}}}catch{}}async function KY($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((
|
|
13431
|
+
`);return{line:Y.length,column:Y[Y.length-1].length+1}}function kj($,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 Sj($){return/@[a-z]+/i.test($)||/\{\{/.test($)}function bj($){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 wj,Aj,Rj;var rJ=C(()=>{wj=[{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"}],Aj=[{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')"}],Rj=[{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 ZQ={};p(ZQ,{renderSlot:()=>tJ,processSlots:()=>$Q,parseSlots:()=>aJ,parseSlotElement:()=>Cj,extractSlotContent:()=>xj,applySlots:()=>fj});function yj($,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 aJ($){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[U,W,_,B,j]=Q,O=W||_||B,L=Q.index+U.length,V=yj($,L);if(V!==-1){let H=$.slice(L,V-11).trim();J.push({start:Q.index,end:V,slotName:O,content:H,propsBinding:j||void 0}),Z.named.set(O,{name:O,content:H,propsBinding:j||void 0})}}J.sort((U,W)=>W.start-U.start);for(let U of J)Y=Y.slice(0,U.start)+Y.slice(U.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,q;while((q=K.exec(Y))!==null){let[U,W,_,B,j,O]=q,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),H=(L+V).trim(),F=`<${W}${H?" "+H:""}>${O}</${W}>`;G.push({start:q.index,end:q.index+U.length,slotName:B,element:F})}let z=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((q=z.exec(Y))!==null){let[U,W,_,B,j]=q,O=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),V=(O+L).trim(),H=`<${W}${V?" "+V:""} />`;G.push({start:q.index,end:q.index+U.length,slotName:B,element:H})}G.sort((U,W)=>W.start-U.start);for(let U of G){let W=Z.named.get(U.slotName);if(W)W.content+=U.element;else Z.named.set(U.slotName,{name:U.slotName,content:U.element});Y=Y.slice(0,U.start)+Y.slice(U.end)}return Z.default=Y.trim(),Z}function Cj($){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 tJ($,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((q)=>q.trim()).filter(Boolean);for(let q of K){let[z,U]=q.split(":").map((_)=>_.trim()),W=U||z;if(Z[z]!==void 0)G[W]=Z[z]}}else G[Q]=Z;J=Pj(J,G)}return J}function Pj($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,X)=>{try{let J=X.trim(),Q=eJ(J,Z);return m0(String(Q??""))}catch{return`{{ ${X} }}`}})}function eJ($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let X=$.split("."),J=Z;for(let Q of X)if(J&&typeof J==="object"&&Q in J)J=J[Q];else return;return J}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,X,J,Q]=Y,G=Z[X],K=parseInt(Q,10);if(typeof G==="number")switch(J){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!$0($))return;return Z0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function $Q($,Z,Y){let X=$;X=await vj(X,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,q,z)=>{let U=Z.named.get(K),W=z?.trim()||"",_=q||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,O;while((O=j.exec(_))!==null){let L=O[1],V=O[2];B[L]=eJ(V,Y)}return await tJ(U,B,W,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return X=X.replace(Q,(G,K)=>{if(G.includes("name="))return G;let q=K?.trim()||"";return Z.default||q}),X}async function vj($,Z,Y){let X=[],J=[];$.replace(Z,(K,...q)=>{let z=q[q.length-2];return J.push({match:K,index:z}),X.push(Y(K,...q.slice(0,-2))),K});let Q=await Promise.all(X),G=$;for(let K=J.length-1;K>=0;K--){let{match:q,index:z}=J[K];G=G.slice(0,z)+Q[K]+G.slice(z+q.length)}return G}function xj($){let Z=aJ($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function fj($,Z,Y,X){return await $Q($,{default:Z,named:Y},X)}var YQ=C(()=>{t0();V0()});import gj from"fs";import h from"path";function XQ($){return $.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function dj($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function c1($){return!dj($)}function l1($){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:r0()}).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 mj($){let Z=[],Y=new Set,X=0,J=0,Q=$.length,G=(U)=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]===U){J++;return}J++}},K=()=>{J++;while(J<Q){if($[J]==="\\"){J+=2;continue}if($[J]==="`"){J++;return}if($[J]==="$"&&$[J+1]==="{"){J+=2;let U=1;while(J<Q&&U>0)if($[J]==="{")U++,J++;else if($[J]==="}")U--,J++;else if($[J]==="'"||$[J]==='"')G($[J]);else if($[J]==="`")K();else J++;continue}J++}},q=()=>{if($[J]==="/"&&$[J+1]==="/"){while(J<Q&&$[J]!==`
|
|
13432
|
+
`)J++;return!0}if($[J]==="/"&&$[J+1]==="*"){J+=2;while(J<Q-1&&!($[J]==="*"&&$[J+1]==="/"))J++;return J+=2,!0}return!1},z=()=>{if(X!==0)return;let U=$.slice(J).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(U){let j=U[2].split(",").map((O)=>{let L=O.trim().split(":");return L[L.length-1].trim()});for(let O of j)if(O&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(O)&&!Y.has(O))Z.push(O),Y.add(O);return}let W=$.slice(J).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(W){let j=W[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(J).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(J).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(J<Q){if(q())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])))z();J++}return Z}function uj($){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 pj($){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 cj($,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 q=$[X];if(q==="}")Q++;else if(q==="{"){if(Q--,Q===0){G=X;break}}}if(G===-1)return;let K=$.slice(G+1,J);for(let q of uj(K)){let z=q.trim();if(!z||z.startsWith("..."))continue;let U=pj(z);if(U===-1)continue;let W=z.slice(0,U).trim();if(!/^[A-Z_$][\w$]*$/i.test(W))continue;if(Z[W]!==void 0)continue;let _=z.slice(U+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[W]=j(...B.map((O)=>Z[O]))}catch{}}}catch{}}async function KY($,Z,Y,X,J){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[Q,Q.toLowerCase(),G(Q),K(Q)])if(q.has(L))return!0}let z=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],U=typeof J.root==="string"?h.resolve(J.root):void 0,W=U??h.dirname(X),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(h.join(h.dirname(j),"components"));B(Z),B(h.join(h.dirname(X),"components")),B(J.componentsDir);let O=J._pluginComponentDirs;if(Array.isArray(O))for(let L of O)B(typeof L==="string"?L:null);if(U)B(h.resolve(U,"resources/views/components")),B(h.resolve(U,"resources/components")),B(h.resolve(U,"src/components")),B(h.resolve(U,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return i(h.resolve(h.dirname(X),`${Q}.stx`));for(let L of _){let V=h.isAbsolute(L)?L:h.resolve(W,L);for(let H of z)if(await i(h.join(V,H)))return!0}return!1}function lj($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function U1($,Z,Y,X,J,Q,G,K=new Set,q){let{extractVariables:z}=await Promise.resolve().then(() => (L5(),T4)),U=K??new Set;if(U.has($))return`[Circular component reference: ${$}]`;let W=new Set(U);W.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&lj(_)?_:"";try{let j=(P)=>P.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),O=(P)=>P.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,V=null,H=J.__importedComponents;if(H){let P=[L,L.toLowerCase(),j(L),O(L)];for(let v of P)if(H.has(v)){V=H.get(v);break}}let F=[];if(!V){let P=[`${L}.stx`,`${j(L)}.stx`,`${O(L)}.stx`],v=[...new Set(P)],x=J.__originalFilePath,g=[];if(x){let z0=h.join(h.dirname(x),"components");g.push(z0)}if(X)g.push(X);let u=h.join(h.dirname(Q),"components");if(!g.includes(u))g.push(u);if(G.componentsDir&&G.componentsDir!==X&&!g.includes(G.componentsDir))g.push(G.componentsDir);let s=G._pluginComponentDirs;if(Array.isArray(s)){for(let z0 of s)if(typeof z0==="string"&&!g.includes(z0))g.push(z0)}let Q0=typeof G.root==="string"?h.resolve(G.root):void 0,k0=Q0??h.dirname(Q),P0=[];if(Q0)P0.push(h.resolve(Q0,"resources/views/components")),P0.push(h.resolve(Q0,"resources/components")),P0.push(h.resolve(Q0,"src/components")),P0.push(h.resolve(Q0,"components"));P0.push(h.resolve(import.meta.dir,"components"));for(let z0 of P0)if(!g.includes(z0))g.push(z0);let D1=[...new Set(g.map((z0)=>{if(!z0)return z0;return h.isAbsolute(z0)?z0:h.resolve(k0,z0)}))];if(g.length=0,g.push(...D1),L.startsWith("./")||L.startsWith("../"))V=h.resolve(h.dirname(Q),`${L}.stx`),F.push(V);else for(let z0 of g){if(!z0)continue;for(let E1 of v){let M5=h.join(z0,E1);if(F.push(M5),await i(M5)){V=M5;break}}if(V)break;if(!V)try{let E1=await import("fs");if(!E1.statSync(z0,{throwIfNoEntry:!1})?.isDirectory())continue;let K$=8,t=[{path:z0,depth:0}];while(t.length>0&&!V){let s0=t.pop();if(s0.depth>=K$)continue;let Z7;try{Z7=E1.readdirSync(s0.path,{withFileTypes:!0})}catch{continue}for(let q$ of Z7){if(!q$.isDirectory())continue;if(q$.name==="node_modules"||q$.name.startsWith("."))continue;let G9=h.join(s0.path,q$.name);for(let zQ of v){let Y7=h.join(G9,zQ);if(F.push(Y7),await i(Y7)){V=Y7;break}}if(V)break;t.push({path:G9,depth:s0.depth+1})}}}catch{}if(V)break}}if(!V||!await i(V)){let P=F.length>0?`
|
|
13423
13433
|
Searched paths:
|
|
13424
|
-
${
|
|
13425
|
-
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${P}`}q.add(
|
|
13426
|
-
`)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:o}=await Promise.resolve().then(() => (YQ(),ZQ)),{defaultSlot:N0,namedSlots:X1}=m(Y);f=await o(f,N0||Y,X1,N);for(let[P,v]of Object.entries(N))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("<")||v.includes(""")){let x=H7(v);N[P]=x}}let C0=E.some((P)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(P)),E0={...G,componentsDir:h.dirname(
|
|
13434
|
+
${F.map((v)=>` - ${v}`).join(`
|
|
13435
|
+
`)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${P}`}q.add(V);let A;if(Q$.has(V))A=Q$.get(V);else try{A=await Bun.file(V).text(),Q$.set(V,A)}catch(P){return`[Error loading component: ${P instanceof Error?P.message:String(P)}]`}let w=new Set(["__originalFilePath","__importedComponents"]),R={};for(let[P,v]of Object.entries(J))if(!P.startsWith("__")||w.has(P))R[P]=v;let N={...R,...Z,props:Z,slot:Y,__processedComponents:W,__sections:{}};cj(A,N);let M=A,T=M.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(T)M=T[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...A.matchAll(I)],E=[];for(let P of D){let v=P[1]||"",x=P[2]||"",g=v.includes("server");if(c1(v)&&x.trim())x=l1(x);if(g&&x)try{await z(x,N,V)}catch(s){}if(!g){let s=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(s.includes("{{")&&s.includes("}}"))s=a0(s,N,V);let Q0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${Q0}>${s}</script>`)}}let k=A.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=k?k[1]:"",b=k?k[2]:"",y="",d=S&&/\bscoped\b/i.test(S);if(k)y=`<style${S}>${b}</style>`;let f=M;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),k)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let P=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(P,(x,g)=>{let u=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(u)v.push(`<style${u[1]}>${u[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)y=`${y}${v.join(`
|
|
13436
|
+
`)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:o}=await Promise.resolve().then(() => (YQ(),ZQ)),{defaultSlot:N0,namedSlots:X1}=m(Y);f=await o(f,N0||Y,X1,N);for(let[P,v]of Object.entries(N))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("<")||v.includes(""")){let x=H7(v);N[P]=x}}let C0=E.some((P)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(P)),E0={...G,componentsDir:h.dirname(V),skipSignalsRuntime:!0,skipEventDirectives:C0,defaultLayout:void 0};N.__stxProcessingDepth=(J.__stxProcessingDepth||0)+1;let X0=await U0(f,N,V,E0,q),F0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++hj}_${Math.random().toString(36).slice(2,8)}`,W0=X0;if(C0){let P="";if(Object.keys(Z).length>0)try{P=` data-stx-props="${XQ(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${XQ(B)}"`:"";if(W0=`<div data-stx-scope="${F0}"${P}${v}>${X0}</div>`,W0=E.map((g)=>{let u=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!u)return g;let[,s,Q0]=u,k0=G1(Q0),P0=`
|
|
13427
13437
|
(function() {
|
|
13428
13438
|
const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
|
|
13429
13439
|
const __scope = window.stx._scopes = window.stx._scopes || {};
|
|
@@ -13449,9 +13459,9 @@ catch (e) {}
|
|
|
13449
13459
|
`)+`
|
|
13450
13460
|
`+W0,y)W0+=`
|
|
13451
13461
|
`+y}else{if(y)W0+=`
|
|
13452
|
-
`+y;if(E.length>0){let P=N.__stx_event_bindings||[],v=X$(N),x=await Promise.all(E.map(async(g)=>{let u=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!u)return g;return await J$(u[1],{eventBindings:P,templateContent:W0,filePath:
|
|
13462
|
+
`+y;if(E.length>0){let P=N.__stx_event_bindings||[],v=X$(N),x=await Promise.all(E.map(async(g)=>{let u=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!u)return g;return await J$(u[1],{eventBindings:P,templateContent:W0,filePath:V,projectRoot:process.cwd(),serverData:v})}));W0+=`
|
|
13453
13463
|
`+x.join(`
|
|
13454
|
-
`),N.__stx_event_bindings=[]}}if(d){let P=k4(W0,
|
|
13464
|
+
`),N.__stx_event_bindings=[]}}if(d){let P=k4(W0,V);if(P.hasScoped)W0=P.html}return W0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{U.delete($)}}async function i($){return Bun.file($).exists()}function Q9($,Z){let Y=h.resolve(Z),X=h.resolve($),J=Y.endsWith(h.sep)?Y:Y+h.sep;if(X===Y||X.startsWith(J))return X;return null}async function a$($,Z,Y,X){let J=await ij($,Z,Y,X);if(J===null)return null;let Q=Q9(J,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let q=h.isAbsolute(K)?K:h.resolve(process.cwd(),K);if(Q9(J,q))return h.resolve(J)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${J} (template: ${$}, from: ${Z})`),null}async function ij($,Z,Y,X){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let J=h.dirname(Z),Q=process.cwd();if($.startsWith("/")){let _=h.join(Q,$),B=Q9(_,Q);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await i(B)&&X)X.add(B);return B}let G=h.join(J,$);if(await i(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(X)X.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let _ of[".stx",".tsx",".jsx"]){let B=`${G}${_}`;if(await i(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(X)X.add(B);return B}}let K="",q=h.resolve(J),z=process.cwd();for(let _=0;_<10;_++){let B=h.join(q,"layouts"),j=!1;try{j=gj.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let O=h.dirname(q);if(O===q||O.length<z.length)break;q=O}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=h.join(K,_);if(await i(B)){if(Y.debug)console.log(`Found in current layouts dir: ${B}`);if(X)X.add(B);return B}if(!_.endsWith(".stx")){let j=`${B}.stx`;if(await i(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.layoutsDir){let _=h.isAbsolute(Y.layoutsDir)?Y.layoutsDir:h.resolve(process.cwd(),Y.layoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=h.join(_,B);if(await i(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(X)X.add(j);return j}if(!$.endsWith(".stx")){let O=`${j}.stx`;if(await i(O)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${O}`);if(X)X.add(O);return O}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let _=$.split("layouts/"),B=h.join(Y.partialsDir||J,"layouts",_[1]);if(await i(B)){if(Y.debug)console.log(`Found in layouts path: ${B}`);if(X)X.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await i(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(X)X.add(j);return j}}}if(Y.partialsDir){if(K=h.join(Y.partialsDir,"layouts"),await i(K)){let _=h.join(K,$);if(await i(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await i(B)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}}let U=Y.partialsDir||h.join(process.cwd(),"views"),W=h.join(U,$);if(await i(W)){if(Y.debug)console.log(`Found in views path: ${W}`);if(X)X.add(W);return W}if(!$.endsWith(".stx")){let _=`${W}.stx`;if(await i(_)){if(Y.debug)console.log(`Found in views path with extension: ${_}`);if(X)X.add(_);return _}}if(J.includes("temp")){let _=h.join(h.dirname(J),"layouts",$);if(await i(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(X)X.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await i(B)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(X)X.add(B);return B}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function JQ($,Z,Y){let X=0,J="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
|
|
13455
13465
|
`),K=0;for(let q=0;q<G.length;q++)if(K+=G[q].length+1,K>=Z){X=q+1,J=G[q].trim();let z=Math.max(0,q-2),U=Math.min(G.length,q+3);Q=G.slice(z,U).map((W,_)=>{let B=z+_+1;return`${B===X?"> ":" "}${B}: ${W}`}).join(`
|
|
13456
13466
|
`);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return JQ($,G)}}catch{}return{lineNumber:X,lineContent:J,context:Q}}function J0($,Z,Y,X,J,Q){let{lineNumber:G,context:K}=JQ(X,J,Q),q=Y.split("/").pop(),z=0;if(typeof J==="number"&&J>=0&&X){let W=X.lastIndexOf(`
|
|
13457
13467
|
`,Math.max(0,J-1));z=J-(W+1)+1}let U="";if(G>0)U+=`
|
|
@@ -13518,18 +13528,18 @@ else {
|
|
|
13518
13528
|
// STX: auto-generated event bindings
|
|
13519
13529
|
${$.map((Y,X)=>KH(Y,X)).join(`
|
|
13520
13530
|
`)}`}function QQ($){let Z=[],Y=new Set,X=$.replace(/^\s*import\s+.*$/gm,""),J=0,Q=X.length,G=0;while(G<Q){let K=X[G];if(K==="'"||K==='"'||K==="`"){let q=K;if(G++,q==="`"){let z=0;while(G<Q){if(X[G]==="\\"){G+=2;continue}if(X[G]==="`"&&z===0){G++;break}if(X[G]==="$"&&X[G+1]==="{"){z++,G+=2;continue}if(X[G]==="}"&&z>0){z--,G++;continue}G++}}else while(G<Q){if(X[G]==="\\"){G+=2;continue}if(X[G]===q){G++;break}G++}continue}if(K==="/"&&X[G+1]==="/"){while(G<Q&&X[G]!==`
|
|
13521
|
-
`)G++;continue}if(K==="/"&&X[G+1]==="*"){G+=2;while(G<Q-1&&!(X[G]==="*"&&X[G+1]==="/"))G++;G+=2;continue}if(K==="{"){J++,G++;continue}if(K==="}"){J--,G++;continue}if(J===0){let q=X.slice(G),z=q.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(z){let _=z[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=z[0].length;continue}let U=q.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(U){U[1].split(",").forEach((_)=>{let B=_.trim(),j=B.indexOf(":"),O=j>=0?B.slice(j+1).trim().split(/[\s=]/)[0]:B.split(/[\s=]/)[0];if(O&&!O.startsWith("_")&&!Y.has(O))Z.push(O),Y.add(O)}),G+=U[0].length;continue}let W=q.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(W){let _=W[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=W[0].length;continue}}G++}return Z}function UH($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function X(_){let B;while((B=Y.exec(_))!==null){let j=B[0];if(!zH.has(j))Z.add(j)}}let J=/\{\{([\s\S]*?)\}\}/g,Q;while((Q=J.exec($))!==null)X(Q[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Q=G.exec($))!==null)X(Q[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Q=K.exec($))!==null)X(Q[1]);let q=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Q=q.exec($))!==null)X(Q[1]);let z=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Q=z.exec($))!==null)X(Q[1]);let U=/@model\s*=\s*["']([^"']*)["']/gi;while((Q=U.exec($))!==null)X(Q[1]);let W=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Q=W.exec($))!==null)X(Q[1]);return Z}async function J$($,Z={}){let Y=$,X="",J=!1,Q=GQ(Y,{filePath:Z.filePath,projectRoot:Z.projectRoot});Y=Q.code;let G=KQ(Q.styles),{hasUserImports:K,bundleClientScript:q}=await Promise.resolve().then(() => (j$(),B$));if(K(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await q(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),J=!0;if(Z.autoImports!==!1){let L=XH(Y);Y=L.code,X=JH(L.stxImports,L.browserImports)}if(X=`${p4(Y,Z.serverData)}${X}`,Y=G1(Y),!J&&c1(Z.attrs||""))Y=l1(Y);let z=qH(Z.eventBindings||[]),U=(Z.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(U)){let L=U.replace(/\btype\s*=\s*["']module["']/i,"").trim(),
|
|
13531
|
+
`)G++;continue}if(K==="/"&&X[G+1]==="*"){G+=2;while(G<Q-1&&!(X[G]==="*"&&X[G+1]==="/"))G++;G+=2;continue}if(K==="{"){J++,G++;continue}if(K==="}"){J--,G++;continue}if(J===0){let q=X.slice(G),z=q.match(/^(?:const|let|var)\s+([a-zA-Z_$]\w*)\s*(?::[^=]*)?=/);if(z){let _=z[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=z[0].length;continue}let U=q.match(/^(?:const|let|var)\s+\{([^}]+)\}\s*=/);if(U){U[1].split(",").forEach((_)=>{let B=_.trim(),j=B.indexOf(":"),O=j>=0?B.slice(j+1).trim().split(/[\s=]/)[0]:B.split(/[\s=]/)[0];if(O&&!O.startsWith("_")&&!Y.has(O))Z.push(O),Y.add(O)}),G+=U[0].length;continue}let W=q.match(/^(?:async\s+)?function\s+([a-zA-Z_$]\w*)/);if(W){let _=W[1];if(!_.startsWith("_")&&!Y.has(_))Z.push(_),Y.add(_);G+=W[0].length;continue}}G++}return Z}function UH($){let Z=new Set,Y=/[a-zA-Z_$][a-zA-Z0-9_$]*/g;function X(_){let B;while((B=Y.exec(_))!==null){let j=B[0];if(!zH.has(j))Z.add(j)}}let J=/\{\{([\s\S]*?)\}\}/g,Q;while((Q=J.exec($))!==null)X(Q[1]);let G=/:[a-z][\w.-]*\s*=\s*"([^"]*)"/gi;while((Q=G.exec($))!==null)X(Q[1]);let K=/:[a-z][\w.-]*\s*=\s*'([^']*)'/gi;while((Q=K.exec($))!==null)X(Q[1]);let q=/@[a-z]+(?:\.[a-z]+)*\s*=\s*"([^"]*)"/gi;while((Q=q.exec($))!==null)X(Q[1]);let z=/@[a-z]+(?:\.[a-z]+)*\s*=\s*'([^']*)'/gi;while((Q=z.exec($))!==null)X(Q[1]);let U=/@model\s*=\s*["']([^"']*)["']/gi;while((Q=U.exec($))!==null)X(Q[1]);let W=/@for\s*=\s*["'][^"']*\bin\s+([^"']+)["']/gi;while((Q=W.exec($))!==null)X(Q[1]);return Z}async function J$($,Z={}){let Y=$,X="",J=!1,Q=GQ(Y,{filePath:Z.filePath,projectRoot:Z.projectRoot});Y=Q.code;let G=KQ(Q.styles),{hasUserImports:K,bundleClientScript:q}=await Promise.resolve().then(() => (j$(),B$));if(K(Y))console.log("[stx:bundler] user imports detected, bundling..."),Y=await q(Y,Z.filePath||"",{projectRoot:Z.projectRoot,minify:Z.production}),J=!0;if(Z.autoImports!==!1){let L=XH(Y);Y=L.code,X=JH(L.stxImports,L.browserImports)}if(X=`${p4(Y,Z.serverData)}${X}`,Y=G1(Y),!J&&c1(Z.attrs||""))Y=l1(Y);let z=qH(Z.eventBindings||[]),U=(Z.attrs||"").trim();if(/\btype\s*=\s*["']module["']/i.test(U)){let L=U.replace(/\btype\s*=\s*["']module["']/i,"").trim(),V=`type="module" data-stx-scoped${L?` ${L}`:""}`;return`${G}<script ${V}>
|
|
13522
13532
|
${X}${Y}
|
|
13523
13533
|
${z}
|
|
13524
|
-
</script>`}let _=/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useLocalStorage|useSessionStorage|useRef|useEventListener|useFetch|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|batch|untrack|peek)\s*(?:<[^>]*>)?\s*\(/.test($),B=/function __stx_setup_/.test(Y),j=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test($);function O(L){let
|
|
13534
|
+
</script>`}let _=/\b(state|derived|effect|ref|reactive|computed|watch|watchEffect|useLocalStorage|useSessionStorage|useRef|useEventListener|useFetch|useDebounce|useDebouncedValue|useThrottle|useInterval|useTimeout|useToggle|useCounter|useClickOutside|useFocus|useAsync|useColorMode|useDark|useWebSocket|useRoute|useSearchParams|onMount|onDestroy|batch|untrack|peek)\s*(?:<[^>]*>)?\s*\(/.test($),B=/function __stx_setup_/.test(Y),j=/\bstx\.mount\s*\(|\bstx\.mountEl\s*\(/.test($);function O(L){let V=L.length>0?`
|
|
13525
13535
|
return { ${L.join(", ")} };`:"";return`${G}<script data-stx-scoped>
|
|
13526
13536
|
window.stx.mount(function() {
|
|
13527
13537
|
'use strict';
|
|
13528
13538
|
${X}${Y}
|
|
13529
|
-
${z}${
|
|
13530
|
-
})</script>`}if(!j&&!B){if(_)return O(QQ($));if(Z.templateContent){let L=QQ($);if(L.length>0){let
|
|
13539
|
+
${z}${V}
|
|
13540
|
+
})</script>`}if(!j&&!B){if(_)return O(QQ($));if(Z.templateContent){let L=QQ($);if(L.length>0){let V=UH(Z.templateContent);if(L.some((F)=>V.has(F)))return O(L)}}}return`${G}<script data-stx-scoped>
|
|
13531
13541
|
;(function() {
|
|
13532
13542
|
'use strict';
|
|
13533
13543
|
${X}${Y}
|
|
13534
13544
|
${z}
|
|
13535
|
-
})()</script>`}var nj,ej,$H,ZH,QH,zH;var a5=C(()=>{w0();nj=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;ej=["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"],$H=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],ZH=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"]);QH={left:0,middle:1,right:2};zH=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"])});L4();L5();function WH(){let $=globalThis.Node||(globalThis.Node={});if($.ELEMENT_NODE==null)$.ELEMENT_NODE=1;if($.TEXT_NODE==null)$.TEXT_NODE=3;if($.COMMENT_NODE==null)$.COMMENT_NODE=8;if($.DOCUMENT_NODE==null)$.DOCUMENT_NODE=9;if($.DOCUMENT_FRAGMENT_NODE==null)$.DOCUMENT_FRAGMENT_NODE=11}function ZM($){if(!$)return;let Z=[$,...$.querySelectorAll?Array.from($.querySelectorAll("*")):[]];for(let Y of Z){if(!Y||Y.nodeType!==1||Y.__attrShimmed)continue;let X=Y.attributes;if(!(X instanceof Map))continue;Y.__attrMap=X,Object.defineProperty(Y,"attributes",{configurable:!0,get(){let J=Y.__attrMap,Q=[],G=0;for(let[K,q]of J)Q[G++]={name:K,value:q};return Q.length=G,Q.get=(K)=>J.get(K),Q.set=(K,q)=>J.set(K,q),Q.delete=(K)=>J.delete(K),Q.has=(K)=>J.has(K),Q.keys=()=>J.keys(),Q.values=()=>J.values(),Q.entries=()=>J.entries(),Q.forEach=(K)=>J.forEach(K),Object.defineProperty(Q,"size",{get:()=>J.size}),Q.item=(K)=>Q[K]||null,Q.getNamedItem=(K)=>J.has(K)?{name:K,value:J.get(K)}:null,Q}}),Y.__attrShimmed=!0}}function YM(){if(WH(),typeof globalThis.requestAnimationFrame>"u")globalThis.requestAnimationFrame=($)=>setTimeout($,0)}function XM($=30){return new Promise((Z)=>setTimeout(Z,$))}async function JM($,Z={}){let Y={...Z.context,props:Z.props||{}};if(Z.mocks)Object.assign(Y,Z.mocks);if(Z.slots)Y.__slots__=Z.slots;let X=$,J=/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let z=Q[1];await i0(z,Y,"test.stx"),X=X.replace(Q[0],"")}X=X.replace(/<template\b[^>]*>/gi,"").replace(/<\/template>/gi,"");let G=new Set,K={debug:!1,...Z.stxOptions};return await U0(X,Y,"test.stx",K,G)}async function QM($,Z={}){let Y={},X={...Z.props},J={},Q=(H,V)=>{if(!Y[H])Y[H]=[];Y[H].push([V])},G={...Z.context,props:X,$emit:Q},K=$,q=/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi,z;while((z=q.exec($))!==null){let H=z[1];await i0(H,G,"test.stx"),K=K.replace(z[0],"")}let U=/<script\b(?!\s+(?:server|client|src))[^>]*>([\s\S]*?)<\/script>/gi;while((z=U.exec(K))!==null){let H=z[1];await i0(H,G,"test.stx"),K=K.replace(z[0],"")}K=K.replace(/<template\b[^>]*>/gi,"").replace(/<\/template>/gi,"");let W=new Set,_={debug:!1,...Z.stxOptions},B=await U0(K,G,"test.stx",_,W),j;if(Z.attachTo)j=typeof Z.attachTo==="string"?document.querySelector(Z.attachTo)||document.createElement("div"):Z.attachTo;else j=document.createElement("div"),j.id=`stx-test-${Date.now()}`;j.innerHTML=B;let O=async()=>{G.props=X,Object.assign(G,J),B=await U0($,G,"test.stx",_,W),j.innerHTML=B},L=(H)=>({element:H,html:()=>H.innerHTML,text:()=>H.textContent||"",find:(V)=>{let A=H.querySelector(V);return A?L(A):null},findAll:(V)=>{return Array.from(H.querySelectorAll(V)).map(L)},exists:()=>document.body.contains(H),isVisible:()=>{let V=window.getComputedStyle(H);return V.display!=="none"&&V.visibility!=="hidden"&&V.opacity!=="0"},attributes:(V)=>{if(V)return H.getAttribute(V);let A={};for(let w of H.attributes)A[w.name]=w.value;return A},classes:(V)=>{if(V)return H.classList.contains(V);return Array.from(H.classList)},trigger:async(V,A)=>{let w=new CustomEvent(V,{bubbles:!0,cancelable:!0,detail:A});H.dispatchEvent(w),Q(V,A),await D0()},getValue:()=>{if(H instanceof HTMLInputElement){if(H.type==="checkbox")return H.checked;if(H.type==="radio")return H.checked;return H.value}if(H instanceof HTMLSelectElement){if(H.multiple)return Array.from(H.selectedOptions).map((V)=>V.value);return H.value}if(H instanceof HTMLTextAreaElement)return H.value;return""},setValue:async(V)=>{if(H instanceof HTMLInputElement){if(H.type==="checkbox"||H.type==="radio")H.checked=V;else H.value=V;H.dispatchEvent(new Event("input",{bubbles:!0})),H.dispatchEvent(new Event("change",{bubbles:!0}))}else if(H instanceof HTMLSelectElement||H instanceof HTMLTextAreaElement)H.value=V,H.dispatchEvent(new Event("input",{bubbles:!0})),H.dispatchEvent(new Event("change",{bubbles:!0}));await D0()}}),F={element:j.firstElementChild||j,html:()=>j.innerHTML,text:()=>j.textContent||"",find:(H)=>{let V=j.querySelector(H);return V?L(V):null},findAll:(H)=>{return Array.from(j.querySelectorAll(H)).map(L)},findComponent:(H)=>{if(j.querySelector(`[data-component="${H}"], ${H.toLowerCase()}, ${qQ(H)}`))return F;return null},findAllComponents:(H)=>{let V=j.querySelectorAll(`[data-component="${H}"], ${H.toLowerCase()}, ${qQ(H)}`);return Array.from(V).map(()=>F)},exists:(H)=>{if(H)return j.querySelector(H)!==null;return j.children.length>0},isVisible:()=>{let H=j.firstElementChild;if(!H)return!1;let V=window.getComputedStyle(H);return V.display!=="none"&&V.visibility!=="hidden"},attributes:(H)=>{if(!H){let w=j.firstElementChild;if(!w)return{};let R={};for(let N of w.attributes)R[N.name]=N.value;return R}let V=j.querySelector(H);if(V){let w={};for(let R of V.attributes)w[R.name]=R.value;return w}let A=j.firstElementChild;return A?A.getAttribute(H):null},classes:(H)=>{let V=(R)=>(R.className||"").split(/\s+/).filter(Boolean);if(!H){let R=j.firstElementChild;if(!R)return[];return V(R)}let A=j.querySelector(H);if(A)return V(A);let w=j.firstElementChild;if(w)return V(w).includes(H);return!1},props:(H)=>{if(H)return X[H];return{...X}},emitted:(H)=>{if(H)return Y[H];return{...Y}},setProps:async(H)=>{X={...X,...H},await O()},setData:async(H)=>{J={...J,...H},await O()},trigger:async(H,V)=>{let A=j.firstElementChild;if(A){let w=new CustomEvent(H,{bubbles:!0,cancelable:!0,detail:V});A.dispatchEvent(w),Q(H,V)}await D0()},getValue:()=>{let H=j.querySelector("input, select, textarea");if(H)return L(H).getValue();return""},setValue:async(H)=>{let V=j.querySelector("input, select, textarea");if(V)await L(V).setValue(H)},unmount:()=>{if(j.innerHTML="",j.parentElement)j.parentElement.removeChild(j)},vm:{$nextTick:D0}};return F}var GM={async click($,Z){let Y=Y1($);if(!Y)return;let X=new MouseEvent("click",{bubbles:!0,cancelable:!0,...Z});Y.dispatchEvent(X),await D0()},async dblClick($,Z){let Y=Y1($);if(!Y)return;let X=new MouseEvent("dblclick",{bubbles:!0,cancelable:!0,...Z});Y.dispatchEvent(X),await D0()},async input($,Z){let Y=Y1($);if(!Y)return;Y.value=Z,Y.dispatchEvent(new Event("input",{bubbles:!0})),await D0()},async change($,Z){let Y=Y1($);if(!Y)return;if(Z!==void 0)Y.value=Z;Y.dispatchEvent(new Event("change",{bubbles:!0})),await D0()},async submit($){let Z=Y1($);if(!Z)return;let Y=new Event("submit",{bubbles:!0,cancelable:!0});Z.dispatchEvent(Y),await D0()},async focus($){let Z=Y1($);if(!Z)return;Z.focus(),Z.dispatchEvent(new FocusEvent("focus",{bubbles:!0})),await D0()},async blur($){let Z=Y1($);if(!Z)return;Z.blur(),Z.dispatchEvent(new FocusEvent("blur",{bubbles:!0})),await D0()},async keyDown($,Z,Y){let X=Y1($);if(!X)return;let J=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,key:Z,...Y});X.dispatchEvent(J),await D0()},async keyUp($,Z,Y){let X=Y1($);if(!X)return;let J=new KeyboardEvent("keyup",{bubbles:!0,cancelable:!0,key:Z,...Y});X.dispatchEvent(J),await D0()},async custom($,Z,Y){let X=Y1($);if(!X)return;let J=new CustomEvent(Z,{bubbles:Y?.bubbles??!0,cancelable:Y?.cancelable??!0,detail:Y?.detail});X.dispatchEvent(J),await D0()}},KM={toContainText($,Z){return $.text().includes(Z)},toHaveClass($,Z){return $.classes(Z)},toHaveAttribute($,Z,Y){let X=$.attributes(Z);if(Y!==void 0)return X===Y;return X!==null},toBeVisible($){return $.isVisible()},toExist($){return $!==null&&$.exists()},toHaveEmitted($,Z,Y){let X=$.emitted(Z);if(!X)return!1;if(Y!==void 0)return X.length===Y;return X.length>0},toHaveEmittedWith($,Z,Y){let X=$.emitted(Z);if(!X)return!1;return X.some((J)=>JSON.stringify(J[0])===JSON.stringify(Y))}};function D0(){return new Promise(($)=>{if(typeof requestAnimationFrame<"u")requestAnimationFrame(()=>$());else setTimeout($,0)})}async function _H($,Z={}){let{timeout:Y=1000,interval:X=50}=Z,J=Date.now();while(Date.now()-J<Y){if(await $())return;await new Promise((Q)=>setTimeout(Q,X))}throw Error(`waitFor timed out after ${Y}ms`)}async function qM($,Z,Y={}){let{timeout:X=1000}=Y;return await _H(()=>$.find(Z)!==null,{timeout:X}),$.find(Z)}async function zM(){await new Promise(($)=>setTimeout($,0)),await D0()}function BH($){let Z=[],Y=[],X=$,J=(...Q)=>{if(Z.push(Q),X){let G=X(...Q);return Y.push(G),G}return};return J.mock={calls:Z,results:Y},J.calls=Z,J.reset=()=>{return Z.length=0,Y.length=0,X=$,J},J.mockImplementation=(Q)=>{return X=Q,J},J.mockReturnValue=(Q)=>{return X=()=>Q,J},J.mockClear=()=>{return Z.length=0,Y.length=0,J},J.mockReset=()=>{return Z.length=0,Y.length=0,X=void 0,J},J}function UM($){let Z={...$},Y={...$},X=[{...Y}],J=new Set,Q=()=>{for(let G of J)G({...Y})};return{getState(){return{...Y}},setState(G){Y={...Y,...G},X.push({...Y}),Q()},reset(){Y={...Z},X.length=0,X.push({...Y}),Q()},getHistory(){return X.map((G)=>({...G}))},subscribe(G){return J.add(G),()=>J.delete(G)}}}function Y1($){if(!$)return null;if($ instanceof HTMLElement)return $;return $.element}function qQ($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function WM($={}){return{props:$.props||{},context:$.context||{},mocks:Object.entries($.mocks||{}).reduce((Z,[Y,X])=>{return Z[Y]=typeof X==="function"?BH():X,Z},{})}}function _M(){document.querySelectorAll('[id^="stx-test-"]').forEach(($)=>$.remove())}export{qM as waitForElement,_H as waitFor,ZM as shimAttributes,YM as setupStxTestDom,JM as render,D0 as nextTick,QM as mount,KM as matchers,WH as installNodeConstants,zM as flushPromises,XM as flushEffects,GM as fireEvent,WM as createTestContext,UM as createMockStore,BH as createMockFn,_M as cleanup};
|
|
13545
|
+
})()</script>`}var nj,ej,$H,ZH,QH,zH;var a5=C(()=>{w0();nj=/^[ \t]*import\s+['"]([^'"]+?\.css)(\?[^'"]*)?['"]\s*;?\s*$/gm;ej=["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"],$H=["browserQuery","BrowserQueryBuilder","BrowserQueryError","browserAuth","configureBrowser","getBrowserConfig","createBrowserDb","createBrowserModel","isBrowser"],ZH=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"]);QH={left:0,middle:1,right:2};zH=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"])});L4();L5();function WH(){let $=globalThis.Node||(globalThis.Node={});if($.ELEMENT_NODE==null)$.ELEMENT_NODE=1;if($.TEXT_NODE==null)$.TEXT_NODE=3;if($.COMMENT_NODE==null)$.COMMENT_NODE=8;if($.DOCUMENT_NODE==null)$.DOCUMENT_NODE=9;if($.DOCUMENT_FRAGMENT_NODE==null)$.DOCUMENT_FRAGMENT_NODE=11}function ZM($){if(!$)return;let Z=[$,...$.querySelectorAll?Array.from($.querySelectorAll("*")):[]];for(let Y of Z){if(!Y||Y.nodeType!==1||Y.__attrShimmed)continue;let X=Y.attributes;if(!(X instanceof Map))continue;Y.__attrMap=X,Object.defineProperty(Y,"attributes",{configurable:!0,get(){let J=Y.__attrMap,Q=[],G=0;for(let[K,q]of J)Q[G++]={name:K,value:q};return Q.length=G,Q.get=(K)=>J.get(K),Q.set=(K,q)=>J.set(K,q),Q.delete=(K)=>J.delete(K),Q.has=(K)=>J.has(K),Q.keys=()=>J.keys(),Q.values=()=>J.values(),Q.entries=()=>J.entries(),Q.forEach=(K)=>J.forEach(K),Object.defineProperty(Q,"size",{get:()=>J.size}),Q.item=(K)=>Q[K]||null,Q.getNamedItem=(K)=>J.has(K)?{name:K,value:J.get(K)}:null,Q}}),Y.__attrShimmed=!0}}function YM(){if(WH(),typeof globalThis.requestAnimationFrame>"u")globalThis.requestAnimationFrame=($)=>setTimeout($,0)}function XM($=30){return new Promise((Z)=>setTimeout(Z,$))}async function JM($,Z={}){let Y={...Z.context,props:Z.props||{}};if(Z.mocks)Object.assign(Y,Z.mocks);if(Z.slots)Y.__slots__=Z.slots;let X=$,J=/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi,Q;while((Q=J.exec($))!==null){let z=Q[1];await i0(z,Y,"test.stx"),X=X.replace(Q[0],"")}X=X.replace(/<template\b[^>]*>/gi,"").replace(/<\/template>/gi,"");let G=new Set,K={debug:!1,...Z.stxOptions};return await U0(X,Y,"test.stx",K,G)}async function QM($,Z={}){let Y={},X={...Z.props},J={},Q=(H,F)=>{if(!Y[H])Y[H]=[];Y[H].push([F])},G={...Z.context,props:X,$emit:Q},K=$,q=/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/gi,z;while((z=q.exec($))!==null){let H=z[1];await i0(H,G,"test.stx"),K=K.replace(z[0],"")}let U=/<script\b(?!\s+(?:server|client|src))[^>]*>([\s\S]*?)<\/script>/gi;while((z=U.exec(K))!==null){let H=z[1];await i0(H,G,"test.stx"),K=K.replace(z[0],"")}K=K.replace(/<template\b[^>]*>/gi,"").replace(/<\/template>/gi,"");let W=new Set,_={debug:!1,...Z.stxOptions},B=await U0(K,G,"test.stx",_,W),j;if(Z.attachTo)j=typeof Z.attachTo==="string"?document.querySelector(Z.attachTo)||document.createElement("div"):Z.attachTo;else j=document.createElement("div"),j.id=`stx-test-${Date.now()}`;j.innerHTML=B;let O=async()=>{G.props=X,Object.assign(G,J),B=await U0($,G,"test.stx",_,W),j.innerHTML=B},L=(H)=>({element:H,html:()=>H.innerHTML,text:()=>H.textContent||"",find:(F)=>{let A=H.querySelector(F);return A?L(A):null},findAll:(F)=>{return Array.from(H.querySelectorAll(F)).map(L)},exists:()=>document.body.contains(H),isVisible:()=>{let F=window.getComputedStyle(H);return F.display!=="none"&&F.visibility!=="hidden"&&F.opacity!=="0"},attributes:(F)=>{if(F)return H.getAttribute(F);let A={};for(let w of H.attributes)A[w.name]=w.value;return A},classes:(F)=>{if(F)return H.classList.contains(F);return Array.from(H.classList)},trigger:async(F,A)=>{let w=new CustomEvent(F,{bubbles:!0,cancelable:!0,detail:A});H.dispatchEvent(w),Q(F,A),await D0()},getValue:()=>{if(H instanceof HTMLInputElement){if(H.type==="checkbox")return H.checked;if(H.type==="radio")return H.checked;return H.value}if(H instanceof HTMLSelectElement){if(H.multiple)return Array.from(H.selectedOptions).map((F)=>F.value);return H.value}if(H instanceof HTMLTextAreaElement)return H.value;return""},setValue:async(F)=>{if(H instanceof HTMLInputElement){if(H.type==="checkbox"||H.type==="radio")H.checked=F;else H.value=F;H.dispatchEvent(new Event("input",{bubbles:!0})),H.dispatchEvent(new Event("change",{bubbles:!0}))}else if(H instanceof HTMLSelectElement||H instanceof HTMLTextAreaElement)H.value=F,H.dispatchEvent(new Event("input",{bubbles:!0})),H.dispatchEvent(new Event("change",{bubbles:!0}));await D0()}}),V={element:j.firstElementChild||j,html:()=>j.innerHTML,text:()=>j.textContent||"",find:(H)=>{let F=j.querySelector(H);return F?L(F):null},findAll:(H)=>{return Array.from(j.querySelectorAll(H)).map(L)},findComponent:(H)=>{if(j.querySelector(`[data-component="${H}"], ${H.toLowerCase()}, ${qQ(H)}`))return V;return null},findAllComponents:(H)=>{let F=j.querySelectorAll(`[data-component="${H}"], ${H.toLowerCase()}, ${qQ(H)}`);return Array.from(F).map(()=>V)},exists:(H)=>{if(H)return j.querySelector(H)!==null;return j.children.length>0},isVisible:()=>{let H=j.firstElementChild;if(!H)return!1;let F=window.getComputedStyle(H);return F.display!=="none"&&F.visibility!=="hidden"},attributes:(H)=>{if(!H){let w=j.firstElementChild;if(!w)return{};let R={};for(let N of w.attributes)R[N.name]=N.value;return R}let F=j.querySelector(H);if(F){let w={};for(let R of F.attributes)w[R.name]=R.value;return w}let A=j.firstElementChild;return A?A.getAttribute(H):null},classes:(H)=>{let F=(R)=>(R.className||"").split(/\s+/).filter(Boolean);if(!H){let R=j.firstElementChild;if(!R)return[];return F(R)}let A=j.querySelector(H);if(A)return F(A);let w=j.firstElementChild;if(w)return F(w).includes(H);return!1},props:(H)=>{if(H)return X[H];return{...X}},emitted:(H)=>{if(H)return Y[H];return{...Y}},setProps:async(H)=>{X={...X,...H},await O()},setData:async(H)=>{J={...J,...H},await O()},trigger:async(H,F)=>{let A=j.firstElementChild;if(A){let w=new CustomEvent(H,{bubbles:!0,cancelable:!0,detail:F});A.dispatchEvent(w),Q(H,F)}await D0()},getValue:()=>{let H=j.querySelector("input, select, textarea");if(H)return L(H).getValue();return""},setValue:async(H)=>{let F=j.querySelector("input, select, textarea");if(F)await L(F).setValue(H)},unmount:()=>{if(j.innerHTML="",j.parentElement)j.parentElement.removeChild(j)},vm:{$nextTick:D0}};return V}var GM={async click($,Z){let Y=Y1($);if(!Y)return;let X=new MouseEvent("click",{bubbles:!0,cancelable:!0,...Z});Y.dispatchEvent(X),await D0()},async dblClick($,Z){let Y=Y1($);if(!Y)return;let X=new MouseEvent("dblclick",{bubbles:!0,cancelable:!0,...Z});Y.dispatchEvent(X),await D0()},async input($,Z){let Y=Y1($);if(!Y)return;Y.value=Z,Y.dispatchEvent(new Event("input",{bubbles:!0})),await D0()},async change($,Z){let Y=Y1($);if(!Y)return;if(Z!==void 0)Y.value=Z;Y.dispatchEvent(new Event("change",{bubbles:!0})),await D0()},async submit($){let Z=Y1($);if(!Z)return;let Y=new Event("submit",{bubbles:!0,cancelable:!0});Z.dispatchEvent(Y),await D0()},async focus($){let Z=Y1($);if(!Z)return;Z.focus(),Z.dispatchEvent(new FocusEvent("focus",{bubbles:!0})),await D0()},async blur($){let Z=Y1($);if(!Z)return;Z.blur(),Z.dispatchEvent(new FocusEvent("blur",{bubbles:!0})),await D0()},async keyDown($,Z,Y){let X=Y1($);if(!X)return;let J=new KeyboardEvent("keydown",{bubbles:!0,cancelable:!0,key:Z,...Y});X.dispatchEvent(J),await D0()},async keyUp($,Z,Y){let X=Y1($);if(!X)return;let J=new KeyboardEvent("keyup",{bubbles:!0,cancelable:!0,key:Z,...Y});X.dispatchEvent(J),await D0()},async custom($,Z,Y){let X=Y1($);if(!X)return;let J=new CustomEvent(Z,{bubbles:Y?.bubbles??!0,cancelable:Y?.cancelable??!0,detail:Y?.detail});X.dispatchEvent(J),await D0()}},KM={toContainText($,Z){return $.text().includes(Z)},toHaveClass($,Z){return $.classes(Z)},toHaveAttribute($,Z,Y){let X=$.attributes(Z);if(Y!==void 0)return X===Y;return X!==null},toBeVisible($){return $.isVisible()},toExist($){return $!==null&&$.exists()},toHaveEmitted($,Z,Y){let X=$.emitted(Z);if(!X)return!1;if(Y!==void 0)return X.length===Y;return X.length>0},toHaveEmittedWith($,Z,Y){let X=$.emitted(Z);if(!X)return!1;return X.some((J)=>JSON.stringify(J[0])===JSON.stringify(Y))}};function D0(){return new Promise(($)=>{if(typeof requestAnimationFrame<"u")requestAnimationFrame(()=>$());else setTimeout($,0)})}async function _H($,Z={}){let{timeout:Y=1000,interval:X=50}=Z,J=Date.now();while(Date.now()-J<Y){if(await $())return;await new Promise((Q)=>setTimeout(Q,X))}throw Error(`waitFor timed out after ${Y}ms`)}async function qM($,Z,Y={}){let{timeout:X=1000}=Y;return await _H(()=>$.find(Z)!==null,{timeout:X}),$.find(Z)}async function zM(){await new Promise(($)=>setTimeout($,0)),await D0()}function BH($){let Z=[],Y=[],X=$,J=(...Q)=>{if(Z.push(Q),X){let G=X(...Q);return Y.push(G),G}return};return J.mock={calls:Z,results:Y},J.calls=Z,J.reset=()=>{return Z.length=0,Y.length=0,X=$,J},J.mockImplementation=(Q)=>{return X=Q,J},J.mockReturnValue=(Q)=>{return X=()=>Q,J},J.mockClear=()=>{return Z.length=0,Y.length=0,J},J.mockReset=()=>{return Z.length=0,Y.length=0,X=void 0,J},J}function UM($){let Z={...$},Y={...$},X=[{...Y}],J=new Set,Q=()=>{for(let G of J)G({...Y})};return{getState(){return{...Y}},setState(G){Y={...Y,...G},X.push({...Y}),Q()},reset(){Y={...Z},X.length=0,X.push({...Y}),Q()},getHistory(){return X.map((G)=>({...G}))},subscribe(G){return J.add(G),()=>J.delete(G)}}}function Y1($){if(!$)return null;if($ instanceof HTMLElement)return $;return $.element}function qQ($){return $.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function WM($={}){return{props:$.props||{},context:$.context||{},mocks:Object.entries($.mocks||{}).reduce((Z,[Y,X])=>{return Z[Y]=typeof X==="function"?BH():X,Z},{})}}function _M(){document.querySelectorAll('[id^="stx-test-"]').forEach(($)=>$.remove())}export{qM as waitForElement,_H as waitFor,ZM as shimAttributes,YM as setupStxTestDom,JM as render,D0 as nextTick,QM as mount,KM as matchers,WH as installNodeConstants,zM as flushPromises,XM as flushEffects,GM as fireEvent,WM as createTestContext,UM as createMockStore,BH as createMockFn,_M as cleanup};
|