@stacksjs/stx 0.2.77 → 0.2.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/dist/app-shell.js +1 -1
  2. package/dist/build-mode-detector.js +1 -1
  3. package/dist/build-views.js +1 -1
  4. package/dist/build.js +1 -1
  5. package/dist/cli.js +2 -2
  6. package/dist/component-processing.js +1 -1
  7. package/dist/component-renderer.js +1 -1
  8. package/dist/components.js +1 -1
  9. package/dist/conditionals.js +1 -1
  10. package/dist/dev-server/index.js +1 -1
  11. package/dist/dev-server/serve-app.js +1 -1
  12. package/dist/dev-server/serve-file.js +1 -1
  13. package/dist/dev-server/serve-markdown.js +1 -1
  14. package/dist/dev-server/serve-multi.js +1 -1
  15. package/dist/dev-server.js +1 -1
  16. package/dist/docs.js +1 -1
  17. package/dist/dynamic-components.js +1 -1
  18. package/dist/includes.js +1 -1
  19. package/dist/index.js +1 -1
  20. package/dist/interactive.js +1 -1
  21. package/dist/lazy-loader.js +1 -1
  22. package/dist/loops.js +1 -1
  23. package/dist/plugin.js +1 -1
  24. package/dist/process.js +1 -1
  25. package/dist/production-builder.js +1 -1
  26. package/dist/production-server.js +1 -1
  27. package/dist/pwa/index.js +1 -1
  28. package/dist/pwa/offline.js +1 -1
  29. package/dist/pwa.js +1 -1
  30. package/dist/render.js +1 -1
  31. package/dist/serve.js +1 -1
  32. package/dist/site-builder/build.js +1 -1
  33. package/dist/site-builder/index.js +1 -1
  34. package/dist/ssg.js +1 -1
  35. package/dist/ssr.js +1 -1
  36. package/dist/story/cli.js +1 -1
  37. package/dist/story/commands/dev.js +1 -1
  38. package/dist/story/commands/index.js +1 -1
  39. package/dist/story/index.js +1 -1
  40. package/dist/story/renderer.js +1 -1
  41. package/dist/story/server.js +1 -1
  42. package/dist/story/visual-testing.js +1 -1
  43. package/dist/streaming.js +1 -1
  44. package/dist/template-compiler.js +1 -1
  45. package/dist/template-hydrator.js +1 -1
  46. package/dist/testing.js +1 -1
  47. package/dist/utils.js +1 -1
  48. package/dist/web-components.js +1 -1
  49. package/package.json +5 -5
@@ -3769,7 +3769,7 @@ ${Y}
3769
3769
  </script>`}function nZ($,Z,Y){if(iZ=0,!Bz($))return $;let X=Gz($);if(X.length===0)return $;let J=_z($,X),Q=Wz(X,Z),G=J.lastIndexOf("</body>");if(G!==-1)J=J.slice(0,G)+Q+`
3770
3770
  `+J.slice(G);else J+=Q;return J}function _z($,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*["']${X4(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*["']${X4(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*"${X4(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*'${X4(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 Bz($){return/x-data\s*=\s*["']/.test($)}var iZ=0,Qz=0;var oZ=b(()=>{r0()});import jz from"fs";import A7 from"path";import{createHighlighter as Hz}from"ts-syntax-highlighter";async function N7($,Z={}){try{if(!await i($))throw Error(`Markdown file not found: ${$}`);let X=(await jz.promises.stat($)).mtime.getTime();if(Z.cache&&R7.has($)){let W=R7.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||G5.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 Oz(z,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:z,data:Q||{}};if(Z.cache)R7.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:Q0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function Oz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!J4)try{J4=await Hz({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(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),_=z||(Y?"text":"");if(!_)return K;try{if(!J4.getSupportedLanguages().includes(_))return K;return(await J4.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 sZ($,Z,Y="",X={}){return await Lz($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,z)=>{try{let U=K;if(!A7.isAbsolute(K))U=A7.resolve(A7.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 O=q.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let A=V.indexOf(":");if(A>0){let w=V.substring(0,A).trim(),R=V.substring(A+1).trim(),N=R.startsWith('"')&&R.endsWith('"'),T=R.startsWith("'")&&R.endsWith("'");if(N||T)R=R.substring(1,R.length-1);W[w]=R}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await N7(U,X),j={...Z,...B,...W},H=_,L=/\{\{([^}]+)\}\}/g;return H=H.replace(L,(F,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):F}),H}catch(U){let W=U instanceof Error?U.message:String(U);return Q0("Markdown File",`Error including markdown file: ${W}`,Y,$,z,G)}})}async function Lz($,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 R7,J4=null;var T7=b(()=>{K5();V0();R7=new Map});function B1($,Z){try{let Y=$.trim();if(Z0(Y))return Y0(Y,Object.keys(Z))(...Object.values(Z));else return $0(Y,Z)}catch{return!1}}var rZ=b(()=>{F0()});class Q4{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]!==`
3771
3771
  `)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]===`
3772
- `)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 O0($,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 aZ($,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 M7($){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 j1($,Z){let Y=Fz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Fz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=O0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function C1($,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 tZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"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 H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.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,O=j1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){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 g5($){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=tZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function G4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,q=K+Q[0].length-1,z=O0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=C1($,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 I7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"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 H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=j1(K,O);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 eZ=()=>{};function Vz($){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=wz($,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 wz($,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 Az($){let Z=M7($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Rz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Rz($){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=O0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=Y2(G);return{name:X,args:K}}function Y2($){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 Nz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=O0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Tz($){let Z=[],X=new Q4($).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,_=$2(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==="{"?"}":"]",_=O0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=Z2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=$2(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.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 _=O0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=Z2(X,_+1)}}}else J++}return Z}function $2($,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 Z2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var X2=()=>{};var K4=b(()=>{eZ();X2()});function Mz($,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=I7(X,G);if(!K)break;try{let q;if(Z0(K.expression))q=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else q=$0(K.expression,Z);let 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&&Z0(W.value))_=Y0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=$0(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=a("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function P1($,Z,Y){let X=$;X=Mz(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=j1(X,K+7);if(!q)break;let z=q.endPos,U=C1(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 H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@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=O.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")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=E7(X,Z,Y),X=k7(X,Z,Y),X=D7(X,Z);let J=()=>{let Q=g5(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&&Z0(U.condition))W=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=$0(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=a(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.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=a("If",`Error processing @if block: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+U+X.substring(K.end)}}return!0};while(J());return X}function J2($){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 D7($,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 H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)W++,_=F+H[0].length;else if(O<1/0){if(W--,W===0)return O;_=O+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=[],H;while((H=W.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")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=J2(_);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 H=Y.slice(W,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?B1(`auth?.check && auth?.user?.[${U}]`,Z):B1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=J2(_);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 H=Y.slice(W,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?B1(`!auth?.check || !auth?.user?.[${U}]`,Z):B1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+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=B1(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 H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((y,C)=>y.pos-C.pos);for(let y of T){if(y.type==="open"){V++;continue}if(y.type==="close"){V--;continue}if(V===0)O.push(y)}let I=[],E=0;for(let y=0;y<O.length;y++){let C=O[y];if(I.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let m=F.slice(C.pos+`@${z}`.length),g=G(m);if(g){I[I.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${z}`.length+g.paramsEnd,I.push({content:"",ability:g.ability,type:g.type,id:g.id}),I.pop();let u=O[y+1],s=u?u.pos:F.length;I.push({content:F.slice(E,s),ability:g.ability,type:g.type,id:g.id}),E=s}}else E=C.pos+5}if(E<F.length){let y=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=Q(j.ability,j.type,j.id),k=K==="can"?D:!D,S="";if(k)S=I[0]?.content||"";else{let y=!1;for(let C=1;C<I.length;C++){let m=I[C];if(m.isFinalElse){S=m.content,y=!0;break}if(m.ability){let g=Q(m.ability,m.type,m.id);if(K==="can"?g:!g){S=m.content,y=!0;break}}}if(!y&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),U=!0}}return Y}function E7($,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=j1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=C1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=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(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=a(z,`Error processing @${G} directive: ${N}`,l.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=B1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=B1(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 k7($,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,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,z=J===D[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let D=U.exec(j),k=W.exec(j),S=D?D.index:1/0,y=k?k.index:1/0;if(S<y)V++,A=S+D[0].length;else if(y<1/0){if(V--,V===0){w=y;break}A=y+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(O,w),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let k=R.substring(D);if(_.test(k)){T++,M=D+1;continue}if(B.test(k)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),k=R.slice(N+5);I=z?D:k}else I=z?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+j.substring(w+E),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var q4=b(()=>{rZ();J1();K4();F0()});function Q2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function v1($,Z){if(!$)return Z?.nonceGenerator?.()??Q2();let Y=S7.get($);if(!Y)Y=Z?.nonceGenerator?.()??Q2(),S7.set($,Y);return Y}function Nw($){S7.delete($)}function G2($,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 y7($,Z){return`<meta http-equiv="Content-Security-Policy" content="${G2($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Tw($){return{enabled:!0,directives:{strict:Iz,moderate:b7,relaxed:Dz,api:Ez}[$]||b7,useNonce:$==="strict",addMetaTag:!0}}function Mw($,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 K2($,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?v1(Y,Z):void 0,J=y7(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3772
+ `)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 O0($,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 aZ($,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 M7($){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 j1($,Z){let Y=Fz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Fz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=O0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function C1($,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 tZ($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"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 H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,z++;continue}if(/^@endif(?![a-z])/.test(H)){B--,z+=6;continue}if(B===0){let L=H.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,O=j1(K,F);if(!O){z++;continue}U="elseif",W=O.expression,z=O.endPos,_=z;continue}else if(/^@else(?![a-z])/.test(H)){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 g5($){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=tZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function G4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,q=K+Q[0].length-1,z=O0($,"(",")",q);if(z===-1){Q=J.exec($);continue}let U=$.slice(q+1,z),W=z+1,_=C1($,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 I7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=j1($,X);if(!J)return null;let Q=J.endPos,G=C1($,"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 H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(U)q.push(U);let O=z+H[0].length,V=j1(K,O);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 eZ=()=>{};function Vz($){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=wz($,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 wz($,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 Az($){let Z=M7($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Rz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Rz($){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=O0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=Y2(G);return{name:X,args:K}}function Y2($){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 Nz($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=O0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function Tz($){let Z=[],X=new Q4($).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,_=$2(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==="{"?"}":"]",_=O0($,z.value,W,U);if(_!==-1){let B=$.slice(U,_+1);if(J=Z2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=$2(X,J,$);J=H.nextIndex;let L=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:L,value:`${$.slice(j,H.endPos)}; ${q} ${B} = ${L}`,exported:G,start:K.start,end:H.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 _=O0($,"{","}",W);if(_!==-1)Z.push({type:"function",name:U,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=Z2(X,_+1)}}}else J++}return Z}function $2($,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 Z2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var X2=()=>{};var K4=b(()=>{eZ();X2()});function Mz($,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=I7(X,G);if(!K)break;try{let q;if(Z0(K.expression))q=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else q=$0(K.expression,Z);let 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&&Z0(W.value))_=Y0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=$0(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=a("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function P1($,Z,Y){let X=$;X=Mz(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=j1(X,K+7);if(!q)break;let z=q.endPos,U=C1(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 H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@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=O.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")H++;else if(w.type==="close")H--;else if(w.type==="else"&&H===0){B=w.pos;break}}let j;if(B!==-1){let H=W.slice(0,B),L=W.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${W}@endif`;X=X.substring(0,K)+j+X.substring(U+10),Q=!0}}X=E7(X,Z,Y),X=k7(X,Z,Y),X=D7(X,Z);let J=()=>{let Q=g5(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&&Z0(U.condition))W=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=$0(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=a(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,l.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=a("If",`Error processing @if block: ${z}`,l.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 J2($){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 D7($,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 H=B.exec(K),L=j.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)W++,_=F+H[0].length;else if(O<1/0){if(W--,W===0)return O;_=O+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=[],H;while((H=W.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((L,F)=>L.pos-F.pos);for(let L of j)if(L.type==="open")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=J2(_);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 H=Y.slice(W,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?B1(`auth?.check && auth?.user?.[${U}]`,Z):B1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let q=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!q||q.index===void 0)break;let z=q.index,U,W,_=Y.slice(z+6),B=J2(_);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 H=Y.slice(W,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?B1(`!auth?.check || !auth?.user?.[${U}]`,Z):B1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";Y=Y.substring(0,z)+O+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=B1(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 H=_+`@${K}`.length+j.paramsEnd,L=X(Y,K,q,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${_} has no matching @${q} \u2014 the block was skipped.`);break}let F=Y.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),R=new RegExp(`@${z}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=A.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=w.exec(F))!==null)T.push({pos:M.index,type:"close"});while((M=R.exec(F))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=N.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((y,C)=>y.pos-C.pos);for(let y of T){if(y.type==="open"){V++;continue}if(y.type==="close"){V--;continue}if(V===0)O.push(y)}let I=[],E=0;for(let y=0;y<O.length;y++){let C=O[y];if(I.push({content:F.slice(E,C.pos),ability:void 0}),C.type==="elseDirective"){let m=F.slice(C.pos+`@${z}`.length),g=G(m);if(g){I[I.length-1]={content:F.slice(E,C.pos)},E=C.pos+`@${z}`.length+g.paramsEnd,I.push({content:"",ability:g.ability,type:g.type,id:g.id}),I.pop();let u=O[y+1],s=u?u.pos:F.length;I.push({content:F.slice(E,s),ability:g.ability,type:g.type,id:g.id}),E=s}}else E=C.pos+5}if(E<F.length){let y=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(E)})}let D=Q(j.ability,j.type,j.id),k=K==="can"?D:!D,S="";if(k)S=I[0]?.content||"";else{let y=!1;for(let C=1;C<I.length;C++){let m=I[C];if(m.isFinalElse){S=m.content,y=!0;break}if(m.ability){let g=Q(m.ability,m.type,m.id);if(K==="can"?g:!g){S=m.content,y=!0;break}}}if(!y&&I.length>0){let C=I[I.length-1];if(C.isFinalElse)S=C.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),U=!0}}return Y}function E7($,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=j1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=C1(Q,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${B} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,L),O=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(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=R?T:M}else N=R?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),U=!0}catch(R){let N=R instanceof Error?R.message:String(R),T=a(z,`Error processing @${G} directive: ${N}`,l.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=B1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=B1(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 k7($,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,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,z=J===D[2]}let V=1,A=O,w=-1;while(V>0&&A<j.length){U.lastIndex=A,W.lastIndex=A;let D=U.exec(j),k=W.exec(j),S=D?D.index:1/0,y=k?k.index:1/0;if(S<y)V++,A=S+D[0].length;else if(y<1/0){if(V--,V===0){w=y;break}A=y+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(O,w),N=-1,T=0,M=0;while(M<R.length){let D=R.indexOf("@",M);if(D===-1)break;let k=R.substring(D);if(_.test(k)){T++,M=D+1;continue}if(B.test(k)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(k)){N=D;break}M=D+1}let I;if(N!==-1){let D=R.slice(0,N),k=R.slice(N+5);I=z?D:k}else I=z?R:"";let E=`@${q}`.length;j=j.substring(0,F)+I+j.substring(w+E),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var q4=b(()=>{rZ();J1();K4();F0()});function Q2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function v1($,Z){if(!$)return Z?.nonceGenerator?.()??Q2();let Y=S7.get($);if(!Y)Y=Z?.nonceGenerator?.()??Q2(),S7.set($,Y);return Y}function Nw($){S7.delete($)}function G2($,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 y7($,Z){return`<meta http-equiv="Content-Security-Policy" content="${G2($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Tw($){return{enabled:!0,directives:{strict:Iz,moderate:b7,relaxed:Dz,api:Ez}[$]||b7,useNonce:$==="strict",addMetaTag:!0}}function Mw($,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 K2($,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?v1(Y,Z):void 0,J=y7(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3773
3773
  ${J}`)}function Iw($,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 q2($,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?v1(Z,Q):void 0;return y7(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return v1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=v1(Z,Q);return J}function Dw(){return[kz,Sz]}function Ew($){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 bz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function kw($,Z){if(!$.enabled)return{};let Y=$.useNonce?v1(Z,$):void 0,X=G2($.directives,Y);return{[bz($.reportOnly)]:X}}var S7,Iz,b7,Dz,Ez,kz,Sz,Sw;var z2=b(()=>{S7=new WeakMap;Iz={"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},b7={"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},Dz={"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'"]},Ez={"default-src":["'none'"],"frame-ancestors":["'none'"]};kz={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?v1(Y,Q):void 0;return y7(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Sz={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return v1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};Sw={enabled:!1,reportOnly:!1,directives:b7,useNonce:!1,addMetaTag:!0}});import{Buffer as U2}from"buffer";import W2 from"crypto";function Cz($=yz){let Z=W2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return U5=Z,Z}function Pz(){if(!U5)Cz();return U5}function Pw(){U5=null}function vw($){U5=$}function vz($=_2){let Z=Pz();return`<input type="hidden" name="${$}" value="${Z}">`}function B2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return vz(X||_2)})}function xw($,Z){let Y=Z??U5;if(!Y)return!1;let X=U2.from($),J=U2.from(Y);if(X.length!==J.length)return!1;return W2.timingSafeEqual(X,J)}var yz=40,_2="_token",U5=null;var j2=()=>{};async function H2($,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 xz(J,Q,Z,Y,X);else J=await fz(J,Q,Z,Y,X)}return J}async function xz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,z=$,U=I1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),W=[],_=U.exec(z);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?O2(j):[],O=H.trim(),V=await G(O,F,Y,X);W.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);W.push({original:B,processed:a("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,l.EVALUATION_ERROR),startIndex:L})}_=U.exec(z)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];z=z.replace(j,H)}return z}async function fz($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=I1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),z=[],U=q.exec(K);while(U!==null){let[B,j=""]=U,H=U.index||0;try{let L=O2(j),F=await G("",L,Y,X);z.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(J.debug)console.error(`Error processing custom directive @${Q}:`,L);z.push({original:B,processed:a("CustomDirective",`Error in @${Q}(${j}): ${F}`,l.EVALUATION_ERROR),startIndex:H})}U=q.exec(K)}let W=I1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=W.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);z.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);z.push({original:B,processed:a("CustomDirective",`Error in @${Q}: ${L}`,l.EVALUATION_ERROR),startIndex:j})}_=W.exec(K)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:H}=z[B];K=K.replace(j,H)}return K}function O2($){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 L2=b(()=>{J1();a1()});var C7={};n(C7,{useTitle:()=>pz,useSeoMeta:()=>U4,usePageTitle:()=>pz,useHead:()=>f1,resetHead:()=>dz,renderHtmlAttrs:()=>cz,renderHead:()=>lz,renderBodyAttrs:()=>iz,processTitleDirective:()=>sz,processMetaDirective:()=>rz,processHeadDirective:()=>oz,getPageMeta:()=>hz,getHead:()=>h5,definePageMeta:()=>uz,applyHead:()=>nz});function h5(){return H1}function hz(){return z4}function dz(){H1={},gz.length=0,z4={}}function f1($){H1=mz(H1,$)}function mz($,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 U4($){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});f1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function uz($){if(z4={...z4,...$},$.title||$.description)U4({title:$.title,description:$.description})}function pz($){let Z=typeof $==="function"?$():$;f1({title:Z})}function lz($=H1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${x1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${x1(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}="${x1(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}="${x1(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}="${x1(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(`
3774
3774
  `)}function cz($=H1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${x1(Y)}"`).join(" ")}function iz($=H1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${x1(Y)}"`).join(" ")}function x1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function nz($=H1){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 oz($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
3775
3775
  `,""}),headContent:Z.trim()}}function sz($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return f1({title:G}),""})}function rz($,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 f1({meta:[W]}),""})}var H1,gz,z4;var d5=b(()=>{H1={},gz=[],z4={}});import az from"crypto";function w0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function tz($){return{...P7,...$.forms?.classes}}function W4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function ez(){return az.randomUUID()}function pw($,Z,Y,X){let J=tz(X),Q=$;return Q=ZU(Q,Z),Q=p5(Q,Z),Q=v7(Q,Z,J),Q=x7(Q,Z,J),Q}function p5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=ez();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${w0(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="${w0(Q)}">`;return X}),Y}function v7($,Z,Y=P7){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||"",_=O1(z),B=U.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${w0(j)}" action="${w0(W)}"${_?` ${_}`:""}>`;if(H+=`
@@ -1648,7 +1648,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
1648
1648
 
1649
1649
  `),"utf-8")}}async flush(){await this.writeQueue}}var x4,E0,h$;var aZ=T(()=>{r5();x4={isEnabled(){return i5().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=i5();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let X=$,Y=[],Q=(X.match(/\{\{/g)||[]).length,J=(X.match(/\}\}/g)||[]).length;if(Q>J){let K=Q-J;X+="}}".repeat(K),Y.push(`Added ${K} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let K of G){let W=(X.match(new RegExp(`@${K}\\b`,"g"))||[]).length,B=(X.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(W>B){let U=W-B;for(let _=0;_<U;_++)X+=`
1650
1650
  @end${K}`;Y.push(`Added ${U} missing @end${K}`)}}if(Y.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),Y.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:X,fixes:Y}},createFallbackContent($,Z){if(f1())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};E0=new v4,h$={isDevelopment(){return f1()},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 X=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)X.push(`Context: ${JSON.stringify(Z,null,2)}`);return X.push("========================"),X.join(`
1651
- `)}}});var tZ=()=>{};var eZ=T(()=>{l5();oZ();aZ();tZ();r5()});var d0=T(()=>{eZ()});function b0($,Z,X,Y=0){let Q=0,J=Y,G=null,K=0,W=!1;while(J<$.length){let B=$[J];if(G&&W){W=!1,J++;continue}if(G&&B==="\\"){W=!0,J++;continue}if(W=!1,(B==='"'||B==="'"||B==="`")&&!G){G=B,J++;continue}if(B===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&B==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&B==="}"){K--,J++;continue}if(B==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(B===Z)Q++;else if(B===X){if(Q--,Q===0)return J}J++}return-1}function z1($,Z){let X=hK($,Z);return X.ok?{expression:X.expression,endPos:X.endPos}:null}function hK($,Z){let X=Z;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return{ok:!1,reason:"missing-open-paren",pos:X};let Y=b0($,"(",")",X);if(Y===-1)return{ok:!1,reason:"unclosed-paren",pos:X};return{ok:!0,expression:$.slice(X+1,Y),endPos:Y+1}}function g1($,Z,X,Y){let Q=1,J=Y,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${X}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let W=G.exec($),B=K.exec($),U=W?W.index:1/0,_=B?B.index:1/0;if(U<_)Q++,J=U+W[0].length;else if(_<1/0){if(Q--,Q===0)return _;J=_+B[0].length}else break}return-1}function $X($,Z){let X=$.slice(Z).match(/^@if\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=g1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U="if",_=Q.expression,z=0,j=0;while(B<K.length){let q=K.indexOf("@",B);if(q===-1)break;B=q;let H=K.substring(q);if(/^@if\s*\(/.test(H)){j++,B++;continue}if(/^@endif(?![a-z])/.test(H)){j--,B+=6;continue}if(j===0){let L=H.match(/^@elseif\s*/);if(L){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B});let F=B+L[0].length,O=z1(K,F);if(!O){B++;continue}U="elseif",_=O.expression,B=O.endPos,z=B;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B}),U="else",_=void 0,B+=5,z=B;continue}}B++}return W.push({type:U,condition:_,content:K.slice(z),start:J+z,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function d$($){let Z=[],X=/@if\s*\(/g,Y=X.exec($);while(Y!==null){if(Z.some((G)=>Y.index>G.start&&Y.index<G.end)){Y=X.exec($);continue}let J=$X($,Y.index);if(J)Z.push(J),X.lastIndex=J.end;Y=X.exec($)}return Z}function o5($,Z,X){let Y=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(Y.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,W=K+J[0].length-1,B=b0($,"(",")",W);if(B===-1){J=Q.exec($);continue}let U=$.slice(W+1,B),_=B+1,z=g1($,Z,X,_);if(z===-1){J=Q.exec($);continue}let j=$.slice(_,z),q=z+`@${X}`.length;Y.push({fullMatch:$.slice(K,q),name:Z,params:U,content:j,start:K,end:q}),Q.lastIndex=q,J=Q.exec($)}return Y}function f4($,Z){let X=$.slice(Z).match(/^@switch\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=g1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U=null,_=0;while(B<K.length){let z=K.slice(B),j=z.match(/^@switch\s*\(/),q=z.match(/^@endswitch(?![a-z])/);if(j){if(_++,U)U.content+=j[0];B+=j[0].length;continue}if(q){if(_--,U)U.content+=q[0];B+=q[0].length;continue}if(_>0){if(U)U.content+=K[B];B++;continue}let H=z.match(/^@case\s*/),L=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(U)W.push(U);let O=B+H[0].length,V=z1(K,O);if(!V){B++;continue}U={type:"case",value:V.expression,content:""},B=V.endPos}else if(L&&z.startsWith("@default")){if(U)W.push(U);U={type:"default",content:""},B+=L[0].length}else if(F&&z.startsWith("@break"))B+=F[0].length;else{if(U)U.content+=K[B];B++}}if(U)W.push(U);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:W,start:Z,end:G+10}}var ZX=()=>{};var XX=()=>{};var u$=T(()=>{ZX();XX()});function pK($,Z,X){let Y=$,Q=!0;while(Q){Q=!1;let J=Y.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=f4(Y,G);if(!K)break;try{let W;if(X0(K.expression))W=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else W=Z0(K.expression,Z);let B="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)B=_.content.trim()}else try{let z;if(_.value&&X0(_.value))z=Y0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=Z0(_.value,Z);if(W===z){B=_.content.trim(),U=!0;break}}catch{continue}Y=Y.substring(0,G)+B+Y.substring(K.end),Q=!0}catch(W){let B=W instanceof Error?W.message:String(W),U=s("Switch",`Error evaluating @switch expression: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,G)+U+Y.substring(K.end);break}}return Y}function h1($,Z,X){let Y=$;Y=pK(Y,Z,X);{let J=!0;while(J){J=!1;let G=Y.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z1(Y,K+7);if(!W)break;let B=W.endPos,U=g1(Y,"unless","endunless",B);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 _=Y.slice(B,U),z=W.expression,j=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((N,w)=>N.pos-w.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){j=N.pos;break}}let q;if(j!==-1){let H=_.slice(0,j),L=_.slice(j+5);q=`@if (${z})${L}@else ${H}@endif`}else q=`@if (!(${z}))${_}@endif`;Y=Y.substring(0,K)+q+Y.substring(U+10),J=!0}}Y=h4(Y,Z,X),Y=d4(Y,Z,X),Y=g4(Y,Z);let Q=()=>{let J=d$(Y);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let W="",B=!1;for(let U of K.branches){if(B)break;if(U.type==="else")W=U.content,B=!0;else try{let _;if(U.condition&&X0(U.condition))_=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=Z0(U.condition,Z);if(_)W=U.content,B=!0}catch(_){W=s(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,n.EVALUATION_ERROR),B=!0}}Y=Y.substring(0,K.start)+W+Y.substring(K.end)}catch(W){let B=W instanceof Error?W.message:String(W),U=s("If",`Error processing @if block: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,K.start)+U+Y.substring(K.end)}}return!0};while(Q());return Y}function YX($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let X=$[Z];if(X!=="'"&&X!=='"')return null;Z++;let Y=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){Y.push($[Z+1]),Z+=2;continue}if(Q===X){Z++;break}Y.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:Y.join(""),consumed:Z}}function g4($,Z){let X=$;function Y(K,W,B,U){let _=1,z=U,j=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${B}(?![a-z])`,"g");while(z<K.length&&_>0){j.lastIndex=z,q.lastIndex=z;let H=j.exec(K),L=q.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,z=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;z=O+L[0].length}else break}return-1}function Q(K,W,B){let U=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${B}(?![a-z])`,"g"),j=/@else(?![a-z])/g,q=[],H;while((H=_.exec(K))!==null)q.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)q.push({pos:H.index,type:"close"});while((H=j.exec(K))!==null)q.push({pos:H.index,type:"else"});q.sort((L,F)=>L.pos-F.pos);for(let L of q)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 W=X.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+5),j=YX(z);if(j)U=j.value,_=B+5+j.consumed;else _=B+5;let q=Y(X,"auth","endauth",_);if(q===-1){console.warn(`[stx] @auth directive at position ${B} has no matching @endauth \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?_1(`auth?.check && auth?.user?.[${U}]`,Z):_1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+8),K=!0}}{let K=!0;while(K){K=!1;let W=X.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+6),j=YX(z);if(j)U=j.value,_=B+6+j.consumed;else _=B+6;let q=Y(X,"guest","endguest",_);if(q===-1){console.warn(`[stx] @guest directive at position ${B} has no matching @endguest \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?_1(`!auth?.check || !auth?.user?.[${U}]`,Z):_1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+9),K=!0}}function J(K,W,B){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(W)U.push(W);if(B){let _=_1(B,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,B=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=X.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,j=X.slice(z+`@${K}`.length),q=G(j);if(!q)break;let H=z+`@${K}`.length+q.paramsEnd,L=Y(X,K,W,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=X.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${B}\\s*\\(`,"g"),R=/@else(?![a-z])/g,M=[],I;while((I=A.exec(F))!==null)M.push({pos:I.index,type:"open"});while((I=N.exec(F))!==null)M.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)M.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)M.push({pos:I.index,type:"else"});M.sort((C,y)=>C.pos-y.pos);for(let C of M){if(C.type==="open"){V++;continue}if(C.type==="close"){V--;continue}if(V===0)O.push(C)}let E=[],k=0;for(let C=0;C<O.length;C++){let y=O[C];if(E.push({content:F.slice(k,y.pos),ability:void 0}),y.type==="elseDirective"){let m=F.slice(y.pos+`@${B}`.length),g=G(m);if(g){E[E.length-1]={content:F.slice(k,y.pos)},k=y.pos+`@${B}`.length+g.paramsEnd,E.push({content:"",ability:g.ability,type:g.type,id:g.id}),E.pop();let p=O[C+1],r=p?p.pos:F.length;E.push({content:F.slice(k,r),ability:g.ability,type:g.type,id:g.id}),k=r}}else k=y.pos+5}if(k<F.length){let C=E[E.length-1];if(O.length>0&&O[O.length-1].type==="else")E.push({content:F.slice(k),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(k)})}let D=J(q.ability,q.type,q.id),P=K==="can"?D:!D,S="";if(P)S=E[0]?.content||"";else{let C=!1;for(let y=1;y<E.length;y++){let m=E[y];if(m.isFinalElse){S=m.content,C=!0;break}if(m.ability){let g=J(m.ability,m.type,m.id);if(K==="can"?g:!g){S=m.content,C=!0;break}}}if(!C&&E.length>0){let y=E[E.length-1];if(y.isFinalElse)S=y.content}}X=X.substring(0,z)+S+X.substring(L+`@${W}`.length),U=!0}}return X}function h4($,Z,X){let Y=$;function Q(J,G,K,W,B){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),z=J.match(_);if(!z||z.index===void 0)break;let j=z.index,q=z1(J,j+`@${G}`.length);if(!q)break;let H=q.endPos,L=g1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${j} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=q.expression,V=-1,A=0,N=0;while(N<F.length){let w=F.indexOf("@",N);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){V=w;break}N=w+1}try{let w=W(O.trim()),R;if(V!==-1){let M=F.slice(0,V),I=F.slice(V+5);R=w?M:I}else R=w?F:"";J=J.substring(0,j)+R+J.substring(L+`@${K}`.length),U=!0}catch(w){let R=w instanceof Error?w.message:String(w),M=s(B,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);J=J.substring(0,j)+M+J.substring(L+`@${K}`.length);break}}return J}return Y=Q(Y,"isset","endisset",(J)=>{let G=_1(J,Z);return G!==void 0&&G!==null},"Isset"),Y=Q(Y,"empty","endempty",(J)=>{let G=_1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),Y}function d4($,Z,X){let Y=$,Q="development";function J(G,K,W,B){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),j=new RegExp(`^@${W}(?![a-z])`),q=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(q);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=q.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,B=Q===D[2]}let V=1,A=O,N=-1;while(V>0&&A<q.length){U.lastIndex=A,_.lastIndex=A;let D=U.exec(q),P=_.exec(q),S=D?D.index:1/0,C=P?P.index:1/0;if(S<C)V++,A=S+D[0].length;else if(C<1/0){if(V--,V===0){N=C;break}A=C+P[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=q.substring(O,N),R=-1,M=0,I=0;while(I<w.length){let D=w.indexOf("@",I);if(D===-1)break;let P=w.substring(D);if(z.test(P)){M++,I=D+1;continue}if(j.test(P)){M--,I=D+1;continue}if(M===0&&/^@else(?![a-z])/.test(P)){R=D;break}I=D+1}let E;if(R!==-1){let D=w.slice(0,R),P=w.slice(R+5);E=B?D:P}else E=B?w:"";let k=`@${W}`.length;q=q.substring(0,F)+E+q.substring(N+k),H=!0}return q}return Y=J(Y,"env","endenv",!1),Y=J(Y,"production","endproduction",Q==="production"),Y=J(Y,"development","enddevelopment",Q==="development"),Y=J(Y,"staging","endstaging",Q==="staging"),Y=J(Y,"testing","endtesting",Q==="testing"),Y}var a5=T(()=>{b4();d0();u$();L0()});function QX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function t5($,Z){if(!$)return Z?.nonceGenerator?.()??QX();let X=JX.get($);if(!X)X=Z?.nonceGenerator?.()??QX(),JX.set($,X);return X}function cK($,Z){let X=[];for(let[Y,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)X.push(Y);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(Y==="script-src"||Y==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)X.push(`${Y} ${J.join(" ")}`)}}return X.join("; ")}function GX($,Z){return`<meta http-equiv="Content-Security-Policy" content="${cK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function KX($,Z,X){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let Y=Z.useNonce?t5(X,Z):void 0,Q=GX(Z.directives,Y);return $.replace(/<head([^>]*)>/,`<head$1>
1651
+ `)}}});var tZ=()=>{};var eZ=T(()=>{l5();oZ();aZ();tZ();r5()});var d0=T(()=>{eZ()});function b0($,Z,X,Y=0){let Q=0,J=Y,G=null,K=0,W=!1;while(J<$.length){let B=$[J];if(G&&W){W=!1,J++;continue}if(G&&B==="\\"){W=!0,J++;continue}if(W=!1,(B==='"'||B==="'"||B==="`")&&!G){G=B,J++;continue}if(B===G&&G!=="`"){G=null,J++;continue}if(G==="`"&&B==="$"&&$[J+1]==="{"){K++,J+=2;continue}if(K>0&&B==="}"){K--,J++;continue}if(B==="`"&&G==="`"&&K===0){G=null,J++;continue}if(G){J++;continue}if(B===Z)Q++;else if(B===X){if(Q--,Q===0)return J}J++}return-1}function z1($,Z){let X=hK($,Z);return X.ok?{expression:X.expression,endPos:X.endPos}:null}function hK($,Z){let X=Z;while(X<$.length&&/\s/.test($[X]))X++;if($[X]!=="(")return{ok:!1,reason:"missing-open-paren",pos:X};let Y=b0($,"(",")",X);if(Y===-1)return{ok:!1,reason:"unclosed-paren",pos:X};return{ok:!0,expression:$.slice(X+1,Y),endPos:Y+1}}function g1($,Z,X,Y){let Q=1,J=Y,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${X}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let W=G.exec($),B=K.exec($),U=W?W.index:1/0,_=B?B.index:1/0;if(U<_)Q++,J=U+W[0].length;else if(_<1/0){if(Q--,Q===0)return _;J=_+B[0].length}else break}return-1}function $X($,Z){let X=$.slice(Z).match(/^@if\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=g1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U="if",_=Q.expression,z=0,j=0;while(B<K.length){let q=K.indexOf("@",B);if(q===-1)break;B=q;let H=K.substring(q);if(/^@if\s*\(/.test(H)){j++,B++;continue}if(/^@endif(?![a-z])/.test(H)){j--,B+=6;continue}if(j===0){let L=H.match(/^@elseif\s*/);if(L){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B});let F=B+L[0].length,O=z1(K,F);if(!O){B++;continue}U="elseif",_=O.expression,B=O.endPos,z=B;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:U,condition:_,content:K.substring(z,B),start:J+z,end:J+B}),U="else",_=void 0,B+=5,z=B;continue}}B++}return W.push({type:U,condition:_,content:K.slice(z),start:J+z,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function d$($){let Z=[],X=/@if\s*\(/g,Y=X.exec($);while(Y!==null){if(Z.some((G)=>Y.index>G.start&&Y.index<G.end)){Y=X.exec($);continue}let J=$X($,Y.index);if(J)Z.push(J),X.lastIndex=J.end;Y=X.exec($)}return Z}function o5($,Z,X){let Y=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(Y.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,W=K+J[0].length-1,B=b0($,"(",")",W);if(B===-1){J=Q.exec($);continue}let U=$.slice(W+1,B),_=B+1,z=g1($,Z,X,_);if(z===-1){J=Q.exec($);continue}let j=$.slice(_,z),q=z+`@${X}`.length;Y.push({fullMatch:$.slice(K,q),name:Z,params:U,content:j,start:K,end:q}),Q.lastIndex=q,J=Q.exec($)}return Y}function f4($,Z){let X=$.slice(Z).match(/^@switch\s*/);if(!X)return null;let Y=Z+X[0].length,Q=z1($,Y);if(!Q)return null;let J=Q.endPos,G=g1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),W=[],B=0,U=null,_=0;while(B<K.length){let z=K.slice(B),j=z.match(/^@switch\s*\(/),q=z.match(/^@endswitch(?![a-z])/);if(j){if(_++,U)U.content+=j[0];B+=j[0].length;continue}if(q){if(_--,U)U.content+=q[0];B+=q[0].length;continue}if(_>0){if(U)U.content+=K[B];B++;continue}let H=z.match(/^@case\s*/),L=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(U)W.push(U);let O=B+H[0].length,V=z1(K,O);if(!V){B++;continue}U={type:"case",value:V.expression,content:""},B=V.endPos}else if(L&&z.startsWith("@default")){if(U)W.push(U);U={type:"default",content:""},B+=L[0].length}else if(F&&z.startsWith("@break"))B+=F[0].length;else{if(U)U.content+=K[B];B++}}if(U)W.push(U);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:W,start:Z,end:G+10}}var ZX=()=>{};var XX=()=>{};var u$=T(()=>{ZX();XX()});function pK($,Z,X){let Y=$,Q=!0;while(Q){Q=!1;let J=Y.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=f4(Y,G);if(!K)break;try{let W;if(X0(K.expression))W=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else W=Z0(K.expression,Z);let B="",U=!1;for(let _ of K.cases)if(_.type==="default"){if(!U)B=_.content.trim()}else try{let z;if(_.value&&X0(_.value))z=Y0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=Z0(_.value,Z);if(W===z){B=_.content.trim(),U=!0;break}}catch{continue}Y=Y.substring(0,G)+B+Y.substring(K.end),Q=!0}catch(W){let B=W instanceof Error?W.message:String(W),U=s("Switch",`Error evaluating @switch expression: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,G)+U+Y.substring(K.end);break}}return Y}function h1($,Z,X){let Y=$;Y=pK(Y,Z,X);{let J=!0;while(J){J=!1;let G=Y.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=z1(Y,K+7);if(!W)break;let B=W.endPos,U=g1(Y,"unless","endunless",B);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 _=Y.slice(B,U),z=W.expression,j=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],A;while((A=L.exec(_))!==null)V.push({pos:A.index,type:"open"});while((A=F.exec(_))!==null)V.push({pos:A.index,type:"close"});while((A=O.exec(_))!==null)V.push({pos:A.index,type:"else"});V.sort((N,w)=>N.pos-w.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){j=N.pos;break}}let q;if(j!==-1){let H=_.slice(0,j),L=_.slice(j+5);q=`@if (${z})${L}@else ${H}@endif`}else q=`@if (!(${z}))${_}@endif`;Y=Y.substring(0,K)+q+Y.substring(U+10),J=!0}}Y=h4(Y,Z,X),Y=d4(Y,Z,X),Y=g4(Y,Z);let Q=()=>{let J=d$(Y);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let W="",B=!1;for(let U of K.branches){if(B)break;if(U.type==="else")W=U.content,B=!0;else try{let _;if(U.condition&&X0(U.condition))_=Y0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)_=Z0(U.condition,Z);if(_)W=U.content,B=!0}catch(_){W=s(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${_ instanceof Error?_.message:String(_)}`,n.EVALUATION_ERROR),B=!0}}Y=Y.substring(0,K.start)+W+Y.substring(K.end)}catch(W){let B=W instanceof Error?W.message:String(W),U=s("If",`Error processing @if block: ${B}`,n.EVALUATION_ERROR);Y=Y.substring(0,K.start)+U+Y.substring(K.end)}}return!0};while(!0){let J=Y;if(!Q())break;if(Y===J)break}return Y}function YX($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let X=$[Z];if(X!=="'"&&X!=='"')return null;Z++;let Y=[];while(Z<$.length){let Q=$[Z];if(Q==="\\"&&Z+1<$.length){Y.push($[Z+1]),Z+=2;continue}if(Q===X){Z++;break}Y.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:Y.join(""),consumed:Z}}function g4($,Z){let X=$;function Y(K,W,B,U){let _=1,z=U,j=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),q=new RegExp(`@${B}(?![a-z])`,"g");while(z<K.length&&_>0){j.lastIndex=z,q.lastIndex=z;let H=j.exec(K),L=q.exec(K),F=H?H.index:1/0,O=L?L.index:1/0;if(F<O)_++,z=F+H[0].length;else if(O<1/0){if(_--,_===0)return O;z=O+L[0].length}else break}return-1}function Q(K,W,B){let U=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${B}(?![a-z])`,"g"),j=/@else(?![a-z])/g,q=[],H;while((H=_.exec(K))!==null)q.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)q.push({pos:H.index,type:"close"});while((H=j.exec(K))!==null)q.push({pos:H.index,type:"else"});q.sort((L,F)=>L.pos-F.pos);for(let L of q)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 W=X.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+5),j=YX(z);if(j)U=j.value,_=B+5+j.consumed;else _=B+5;let q=Y(X,"auth","endauth",_);if(q===-1){console.warn(`[stx] @auth directive at position ${B} has no matching @endauth \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=U?_1(`auth?.check && auth?.user?.[${U}]`,Z):_1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+8),K=!0}}{let K=!0;while(K){K=!1;let W=X.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let B=W.index,U,_,z=X.slice(B+6),j=YX(z);if(j)U=j.value,_=B+6+j.consumed;else _=B+6;let q=Y(X,"guest","endguest",_);if(q===-1){console.warn(`[stx] @guest directive at position ${B} has no matching @endguest \u2014 the block was skipped.`);break}let H=X.slice(_,q),L=Q(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=U?_1(`!auth?.check || !auth?.user?.[${U}]`,Z):_1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),A=H.slice(L+5);O=F?V:A}else O=F?H:"";X=X.substring(0,B)+O+X.substring(q+9),K=!0}}function J(K,W,B){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(W)U.push(W);if(B){let _=_1(B,Z);U.push(_)}return Z.permissions.check(...U)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,B=K==="can"?"elsecan":"elsecannot",U=!0;while(U){U=!1;let _=X.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,j=X.slice(z+`@${K}`.length),q=G(j);if(!q)break;let H=z+`@${K}`.length+q.paramsEnd,L=Y(X,K,W,H);if(L===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=X.slice(H,L),O=[],V=0,A=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${B}\\s*\\(`,"g"),R=/@else(?![a-z])/g,M=[],I;while((I=A.exec(F))!==null)M.push({pos:I.index,type:"open"});while((I=N.exec(F))!==null)M.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)M.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)M.push({pos:I.index,type:"else"});M.sort((C,y)=>C.pos-y.pos);for(let C of M){if(C.type==="open"){V++;continue}if(C.type==="close"){V--;continue}if(V===0)O.push(C)}let E=[],k=0;for(let C=0;C<O.length;C++){let y=O[C];if(E.push({content:F.slice(k,y.pos),ability:void 0}),y.type==="elseDirective"){let m=F.slice(y.pos+`@${B}`.length),g=G(m);if(g){E[E.length-1]={content:F.slice(k,y.pos)},k=y.pos+`@${B}`.length+g.paramsEnd,E.push({content:"",ability:g.ability,type:g.type,id:g.id}),E.pop();let p=O[C+1],r=p?p.pos:F.length;E.push({content:F.slice(k,r),ability:g.ability,type:g.type,id:g.id}),k=r}}else k=y.pos+5}if(k<F.length){let C=E[E.length-1];if(O.length>0&&O[O.length-1].type==="else")E.push({content:F.slice(k),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(k)})}let D=J(q.ability,q.type,q.id),P=K==="can"?D:!D,S="";if(P)S=E[0]?.content||"";else{let C=!1;for(let y=1;y<E.length;y++){let m=E[y];if(m.isFinalElse){S=m.content,C=!0;break}if(m.ability){let g=J(m.ability,m.type,m.id);if(K==="can"?g:!g){S=m.content,C=!0;break}}}if(!C&&E.length>0){let y=E[E.length-1];if(y.isFinalElse)S=y.content}}X=X.substring(0,z)+S+X.substring(L+`@${W}`.length),U=!0}}return X}function h4($,Z,X){let Y=$;function Q(J,G,K,W,B){let U=!0;while(U){U=!1;let _=new RegExp(`@${G}\\s*\\(`),z=J.match(_);if(!z||z.index===void 0)break;let j=z.index,q=z1(J,j+`@${G}`.length);if(!q)break;let H=q.endPos,L=g1(J,G,K,H);if(L===-1){console.warn(`[stx] @${G} directive at position ${j} has no matching @${K} \u2014 the block was skipped.`);break}let F=J.slice(H,L),O=q.expression,V=-1,A=0,N=0;while(N<F.length){let w=F.indexOf("@",N);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){A++,N=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){A--,N=w+1;continue}if(A===0&&/^@else(?![a-z])/.test(R)){V=w;break}N=w+1}try{let w=W(O.trim()),R;if(V!==-1){let M=F.slice(0,V),I=F.slice(V+5);R=w?M:I}else R=w?F:"";J=J.substring(0,j)+R+J.substring(L+`@${K}`.length),U=!0}catch(w){let R=w instanceof Error?w.message:String(w),M=s(B,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);J=J.substring(0,j)+M+J.substring(L+`@${K}`.length);break}}return J}return Y=Q(Y,"isset","endisset",(J)=>{let G=_1(J,Z);return G!==void 0&&G!==null},"Isset"),Y=Q(Y,"empty","endempty",(J)=>{let G=_1(J,Z);return G===void 0||G===null||G===""||G===0||G===!1||Array.isArray(G)&&G.length===0||typeof G==="object"&&G!==null&&Object.keys(G).length===0},"Empty"),Y}function d4($,Z,X){let Y=$,Q="development";function J(G,K,W,B){let U=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),j=new RegExp(`^@${W}(?![a-z])`),q=G,H=!0;while(H){H=!1,U.lastIndex=0;let L=U.exec(q);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let D=q.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,B=Q===D[2]}let V=1,A=O,N=-1;while(V>0&&A<q.length){U.lastIndex=A,_.lastIndex=A;let D=U.exec(q),P=_.exec(q),S=D?D.index:1/0,C=P?P.index:1/0;if(S<C)V++,A=S+D[0].length;else if(C<1/0){if(V--,V===0){N=C;break}A=C+P[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=q.substring(O,N),R=-1,M=0,I=0;while(I<w.length){let D=w.indexOf("@",I);if(D===-1)break;let P=w.substring(D);if(z.test(P)){M++,I=D+1;continue}if(j.test(P)){M--,I=D+1;continue}if(M===0&&/^@else(?![a-z])/.test(P)){R=D;break}I=D+1}let E;if(R!==-1){let D=w.slice(0,R),P=w.slice(R+5);E=B?D:P}else E=B?w:"";let k=`@${W}`.length;q=q.substring(0,F)+E+q.substring(N+k),H=!0}return q}return Y=J(Y,"env","endenv",!1),Y=J(Y,"production","endproduction",Q==="production"),Y=J(Y,"development","enddevelopment",Q==="development"),Y=J(Y,"staging","endstaging",Q==="staging"),Y=J(Y,"testing","endtesting",Q==="testing"),Y}var a5=T(()=>{b4();d0();u$();L0()});function QX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function t5($,Z){if(!$)return Z?.nonceGenerator?.()??QX();let X=JX.get($);if(!X)X=Z?.nonceGenerator?.()??QX(),JX.set($,X);return X}function cK($,Z){let X=[];for(let[Y,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)X.push(Y);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(Y==="script-src"||Y==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)X.push(`${Y} ${J.join(" ")}`)}}return X.join("; ")}function GX($,Z){return`<meta http-equiv="Content-Security-Policy" content="${cK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function KX($,Z,X){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let Y=Z.useNonce?t5(X,Z):void 0,Q=GX(Z.directives,Y);return $.replace(/<head([^>]*)>/,`<head$1>
1652
1652
  ${Q}`)}function WX($,Z,X,Y){let Q=$,J=Y.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!J?.enabled||!J.directives)return"<!-- CSP not configured -->";let G=J.useNonce?t5(Z,J):void 0;return GX(J.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!J?.enabled||!J.useNonce)return"";return t5(Z,J)}),J?.enabled&&J.useNonce)Z.cspNonce=t5(Z,J);return Q}var JX;var u4=T(()=>{JX=new WeakMap});import lK from"crypto";function nK($=iK){let Z=lK.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return m4=Z,Z}function sK(){if(!m4)nK();return m4}function rK($=UX){let Z=sK();return`<input type="hidden" name="${$}" value="${Z}">`}function BX($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,X,Y)=>{return rK(Y||UX)})}var iK=40,UX="_token",m4=null;var _X=()=>{};async function zX($,Z,X,Y){if(!Y.customDirectives||Y.customDirectives.length===0)return $;let Q=$;for(let J of Y.customDirectives){if(!J.name||typeof J.handler!=="function"){if(Y.debug)console.warn("Invalid custom directive:",J);continue}if(J.hasEndTag)Q=await oK(Q,J,Z,X,Y);else Q=await aK(Q,J,Z,X,Y)}return Q}async function oK($,Z,X,Y,Q){let{name:J,handler:G}=Z,K=`@${J}`,W=`@end${J}`,B=$,U=X$(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),_=[],z=U.exec(B);while(z!==null){let[j,q="",H=""]=z,L=z.index||0;try{let F=q?qX(q):[],O=H.trim(),V=await G(O,F,X,Y);_.push({original:j,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(Q.debug)console.error(`Error processing custom directive @${J}:`,F);_.push({original:j,processed:s("CustomDirective",`Error in @${J}${q?`(${q})`:""}: ${O}`,n.EVALUATION_ERROR),startIndex:L})}z=U.exec(B)}for(let j=_.length-1;j>=0;j--){let{original:q,processed:H}=_[j];B=B.replace(q,H)}return B}async function aK($,Z,X,Y,Q){let{name:J,handler:G}=Z,K=$,W=X$(`@${J}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),B=[],U=W.exec(K);while(U!==null){let[j,q=""]=U,H=U.index||0;try{let L=qX(q),F=await G("",L,X,Y);B.push({original:j,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(Q.debug)console.error(`Error processing custom directive @${J}:`,L);B.push({original:j,processed:s("CustomDirective",`Error in @${J}(${q}): ${F}`,n.EVALUATION_ERROR),startIndex:H})}U=W.exec(K)}let _=X$(`@${J}(?!\\w)(?!\\s*\\()`,"g"),z=_.exec(K);while(z!==null){let[j]=z,q=z.index||0;try{let H=await G("",[],X,Y);B.push({original:j,processed:H,startIndex:q})}catch(H){let L=H instanceof Error?H.message:String(H);if(Q.debug)console.error(`Error processing custom directive @${J}:`,H);B.push({original:j,processed:s("CustomDirective",`Error in @${J}: ${L}`,n.EVALUATION_ERROR),startIndex:q})}z=_.exec(K)}for(let j=B.length-1;j>=0;j--){let{original:q,processed:H}=B[j];K=K.replace(q,H)}return K}function qX($){if(!$.trim())return[];let Z=[],X="",Y=!1,Q="";for(let J=0;J<$.length;J++){let G=$[J];if((G==='"'||G==="'")&&(J===0||$[J-1]!=="\\"))if(!Y)Y=!0,Q=G;else if(G===Q)Y=!1;else X+=G;else if(G===","&&!Y)Z.push(X.trim()),X="";else X+=G}if(X.trim())Z.push(X.trim());return Z.map((J)=>{let G=J.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var p4=T(()=>{d0();x1()});var c4={};e(c4,{useTitle:()=>XW,useSeoMeta:()=>$7,usePageTitle:()=>XW,useHead:()=>u1,resetHead:()=>eK,renderHtmlAttrs:()=>JW,renderHead:()=>YW,renderBodyAttrs:()=>QW,processTitleDirective:()=>WW,processMetaDirective:()=>UW,processHeadDirective:()=>KW,getPageMeta:()=>jX,getHead:()=>m$,definePageMeta:()=>ZW,applyHead:()=>GW});function m$(){return q1}function jX(){return e5}function eK(){q1={},tK.length=0,e5={}}function u1($){q1=$W(q1,$)}function $W($,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 $7($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let X=$.ogTitle??$.title,Y=$.ogDescription??$.description;if(X)Z.push({property:"og:title",content:X});if(Y)Z.push({property:"og:description",content:Y});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let Q=$.twitterTitle??$.title,J=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(Q)Z.push({name:"twitter:title",content:Q});if(J)Z.push({name:"twitter:description",content:J});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});u1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function ZW($){if(e5={...e5,...$},$.title||$.description)$7({title:$.title,description:$.description})}function XW($){let Z=typeof $==="function"?$():$;u1({title:Z})}function YW($=q1){let Z=[];if($.title){let X=$.title;if($.titleTemplate)X=typeof $.titleTemplate==="function"?$.titleTemplate(X):$.titleTemplate.replace("%s",X);Z.push(`<title>${d1(X)}</title>`)}if($.base){let X=Object.entries($.base).map(([Y,Q])=>`${Y}="${d1(Q)}"`).join(" ");Z.push(`<base ${X}>`)}for(let X of $.meta||[]){let Y=Object.entries(X).filter(([Q,J])=>J!==void 0).map(([Q,J])=>{return`${Q==="httpEquiv"?"http-equiv":Q}="${d1(String(J))}"`}).join(" ");Z.push(`<meta ${Y}>`)}for(let X of $.link||[]){let Y=Object.entries(X).filter(([Q,J])=>J!==void 0).map(([Q,J])=>`${Q}="${d1(String(J))}"`).join(" ");Z.push(`<link ${Y}>`)}for(let X of $.script||[]){let{content:Y,...Q}=X,J=Object.entries(Q).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(Y)Z.push(`<script ${J}>${Y}</script>`);else Z.push(`<script ${J}></script>`)}for(let X of $.style||[]){let Y=X.type?` type="${X.type}"`:"";Z.push(`<style${Y}>${X.content}</style>`)}return Z.join(`
1653
1653
  `)}function JW($=q1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,X])=>`${Z}="${d1(X)}"`).join(" ")}function QW($=q1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,X])=>`${Z}="${d1(X)}"`).join(" ")}function d1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function GW($=q1){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 X=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(X){let Y=document.querySelector(X);if(!Y){if(Y=document.createElement("meta"),Z.name)Y.setAttribute("name",Z.name);if(Z.property)Y.setAttribute("property",Z.property);document.head.appendChild(Y)}Y.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let X=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,Y=document.querySelector(X);if(!Y)Y=document.createElement("link"),document.head.appendChild(Y);for(let[Q,J]of Object.entries(Z))if(J!==void 0)Y.setAttribute(Q,String(J))}if($.htmlAttrs)for(let[Z,X]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,X);if($.bodyAttrs)for(let[Z,X]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,X)}function KW($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(Y,Q)=>{return Z+=Q.trim()+`
1654
1654
  `,""}),headContent:Z.trim()}}function WW($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(X,Y,Q,J)=>{let G=Y?Q:Z[(J||"").trim()]??J;return u1({title:G}),""})}function UW($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(X,Y,Q,J,G,K)=>{let W=J?G:K,B=J?W:Z[(W||"").trim()]??W,_=Q.includes(":")?{property:Q,content:B}:{name:Q,content:B};return u1({meta:[_]}),""})}var q1,tK,e5;var m1=T(()=>{q1={},tK=[],e5={}});import BW from"crypto";function N0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Z7($,Z,X,Y){let Q=$||Z;return X?`${Q} ${Y}`:Q}function _W(){return BW.randomUUID()}function X7($,Z){let X=$;return X=X.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let Y=_W();Z.csrf={token:Y}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${N0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),X=X.replace(/@method\(['"]([^'"]+)['"]\)/g,(Y,Q)=>{let J=Q.toUpperCase();if(Q&&!["GET","POST"].includes(J))return`<input type="hidden" name="_method" value="${N0(J)}">`;return Y}),X}function LX($,Z,X=OX){let Y=$;return Y=Y.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Q,J,G,K,W,B="")=>{let U=J||G||"POST",_=K||W||"",z=j1(B),j=U.toUpperCase(),q=["GET","POST"].includes(j)?j:"POST",H=`<form method="${N0(q)}" action="${N0(_)}"${z?` ${z}`:""}>`;if(H+=`
@@ -1827,7 +1827,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
1827
1827
  @end${K}`;X.push(`Added ${B} 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(M$())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};a0=new h3,p5={isDevelopment(){return M$()},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(`
1828
1828
  `)}}});import tY from"path";function nV($){let Z={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};return $.replace(/[&<>"']/g,(Y)=>Z[Y]||Y)}function N4($,Z={}){let{allowHtml:Y=!1,maxLength:X=1e4,allowSpecialChars:J=!0,customSanitizer:Q}=Z,G=[],K=$,W=!1;if(Q){let B=Q(K);if(B!==K)K=B,W=!0}if(K.includes("\x00"))K=K.replace(/\0/g,""),W=!0,G.push("Null bytes removed from parameter");if(K.length>X)K=K.substring(0,X),W=!0,G.push(`Parameter truncated to ${X} characters`);if(!Y&&/<[^>]+>/.test(K))K=nV(K),W=!0,G.push("HTML content was escaped");let U=[{pattern:/javascript:/gi,replacement:"",name:"javascript: URI"},{pattern:/vbscript:/gi,replacement:"",name:"vbscript: URI"},{pattern:/data:text\/html/gi,replacement:"",name:"data:text/html URI"}];for(let{pattern:B,replacement:_,name:z}of U)if(B.test(K))K=K.replace(B,_),W=!0,G.push(`Removed ${z} from parameter`);if(!J){let B=K;if(K=K.split("").filter((_)=>{let z=_.charCodeAt(0);return z>=32&&z!==127}).join(""),K!==B)W=!0,G.push("Control characters removed")}return{value:K,modified:W,warnings:G}}function BW($,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(!d3.isValidFilePath(Y,Z))return null;return Y}function _W($){let Z=[],Y=$.trim(),X=Y!==$,J=[{pattern:/\beval\s*\(/gi,name:"eval()"},{pattern:/\bFunction\s*\(/gi,name:"Function()"},{pattern:/\bsetTimeout\s*\(/gi,name:"setTimeout()"},{pattern:/\bsetInterval\s*\(/gi,name:"setInterval()"},{pattern:/\bimport\s*\(/gi,name:"dynamic import()"},{pattern:/\brequire\s*\(/gi,name:"require()"},{pattern:/\b__proto__\b/gi,name:"__proto__"},{pattern:/\bconstructor\b/gi,name:"constructor"},{pattern:/\bprototype\b/gi,name:"prototype"}];for(let{pattern:Q,name:G}of J)if(Q.test(Y))Z.push(`Potentially dangerous pattern detected: ${G}`);if(Y.includes("\x00"))Y=Y.replace(/\0/g,""),X=!0,Z.push("Null bytes removed from expression");return{value:Y,modified:X,warnings:Z}}function zW($,Z={}){return $.map((Y)=>N4(Y,Z))}function eY($){let Z={};for(let[Y,X]of Object.entries($)){if(!d3.isValidVariableName(Y))continue;if(typeof X==="string"){let J=N4(X);Z[Y]=J.value}else if(Array.isArray(X))Z[Y]=X.map((J)=>typeof J==="string"?N4(J).value:J);else if(typeof X==="object"&&X!==null)Z[Y]=eY(X);else Z[Y]=X}return Z}var d3;var qW=D(()=>{d3={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=tY.resolve(Z,$),Q=tY.resolve(Z);if(!J.startsWith(Q+tY.sep)&&J!==Q)return!1}return!0},isValidVariableName($){return/^[a-z_$]\w*$/i.test($)},isValidDirectiveName($){return/^[a-z][\w-]*$/i.test($)},isSafeContent($){return![/<script[^>]*>[\s\S]*?<\/script>/i,/javascript:/i,/data:text\/html/i,/vbscript:/i,/on\w+\s*=/i].some((Y)=>Y.test($))}}});var jW=D(()=>{x3();WW();UW();qW();v3()});var H1=D(()=>{jW()});class A4{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]!==`
1829
1829
  `)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]===`
1830
- `)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 x0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function $X($,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 u3($){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 Z$($,Z){let Y=sV($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function sV($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=x0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function I$($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),B=W?W.index:1/0,_=U?U.index:1/0;if(B<_)J++,Q=B+W[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+U[0].length}else break}return-1}function ZX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=Z$($,X);if(!J)return null;let Q=J.endPos,G=I$($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B="if",_=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=Z$(K,F);if(!L){U++;continue}B="elseif",_=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U}),B="else",_=void 0,U+=5,z=U;continue}}U++}return W.push({type:B,condition:_,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function c5($){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=ZX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function w4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=x0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let B=$.slice(W+1,U),_=U+1,z=I$($,Z,Y,_);if(z===-1){Q=J.exec($);continue}let q=$.slice(_,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:B,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function m3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=Z$($,X);if(!J)return null;let Q=J.endPos,G=I$($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B=null,_=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(_++,B)B.content+=q[0];U+=q[0].length;continue}if(j){if(_--,B)B.content+=j[0];U+=j[0].length;continue}if(_>0){if(B)B.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(B)W.push(B);let L=U+H[0].length,V=Z$(K,L);if(!V){U++;continue}B={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(B)W.push(B);B={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(B)B.content+=K[U];U++}}if(B)W.push(B);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var HW=()=>{};function FW($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,B=rV($,U,W);if(B===-1){Y=G+1;continue}let _=$.slice(U,B).trim(),z=B+W.length;Z.push({fullMatch:$.slice(G,z),expression:_,start:G,end:z,isRaw:Q}),Y=z}return Z}function rV($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function VW($){let Z=u3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=oV(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function oV($){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=x0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=YX(G);return{name:X,args:K}}function YX($){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 NW($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=x0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function AW($){let Z=[],X=new A4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,z=OW(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:B,value:$.slice(_,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let B=U.start,_=U.value==="{"?"}":"]",z=x0($,U.value,_,B);if(z!==-1){let q=$.slice(B,z+1);if(J=LW(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=OW(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let z=x0($,"{","}",_);if(z!==-1)Z.push({type:"function",name:B,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=LW(X,z+1)}}}else J++}return Z}function OW($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function LW($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var wW=()=>{};var R4=D(()=>{HW();wW()});function aV($,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=m3(X,G);if(!K)break;try{let W;if(H0(K.expression))W=O0(K.expression,Object.keys(Z))(...Object.values(Z));else W=z0(K.expression,Z);let U="",B=!1;for(let _ of K.cases)if(_.type==="default"){if(!B)U=_.content.trim()}else try{let z;if(_.value&&H0(_.value))z=O0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=z0(_.value,Z);if(W===z){U=_.content.trim(),B=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+B+X.substring(K.end);break}}return X}function U5($,Z,Y){let X=$;X=aV(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=Z$(X,K+7);if(!W)break;let U=W.endPos,B=I$(X,"unless","endunless",U);if(B===-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 _=X.slice(U,B),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(_))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(_))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(_))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${_}@endif`;X=X.substring(0,K)+j+X.substring(B+10),Q=!0}}X=JX(X,Z,Y),X=QX(X,Z,Y),X=XX(X,Z);let J=()=>{let Q=c5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let B of K.branches){if(U)break;if(B.type==="else")W=B.content,U=!0;else try{let _;if(B.condition&&H0(B.condition))_=O0(B.condition,Object.keys(Z))(...Object.values(Z));else if(B.condition)_=z0(B.condition,Z);if(_)W=B.content,U=!0}catch(_){W=J0(B.type==="if"?"If":"Elseif",`Error in @${B.type}(${B.condition}): ${_ instanceof Error?_.message:String(_)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+B+X.substring(K.end)}}return!0};while(J());return X}function RW($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function XX($,Z){let Y=$;function X(K,W,U,B){let _=1,z=B,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&_>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)_++,z=F+H[0].length;else if(L<1/0){if(_--,_===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let B=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")B++;else if(O.type==="close")B--;else if(O.type==="else"&&B===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+5),q=RW(z);if(q)B=q.value,_=U+5+q.consumed;else _=U+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=B?$$(`auth?.check && auth?.user?.[${B}]`,Z):$$("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+6),q=RW(z);if(q)B=q.value,_=U+6+q.consumed;else _=U+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=B?$$(`!auth?.check || !auth?.user?.[${B}]`,Z):$$("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let B=[K];if(W)B.push(W);if(U){let _=$$(U,Z);B.push(_)}return Z.permissions.check(...B)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",B=!0;while(B){B=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],I;while((I=N.exec(F))!==null)T.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)T.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)T.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)T.push({pos:I.index,type:"else"});T.sort((b,f)=>b.pos-f.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)L.push(b)}let E=[],S=0;for(let b=0;b<L.length;b++){let f=L[b];if(E.push({content:F.slice(S,f.pos),ability:void 0}),f.type==="elseDirective"){let r=F.slice(f.pos+`@${U}`.length),u=G(r);if(u){E[E.length-1]={content:F.slice(S,f.pos)},S=f.pos+`@${U}`.length+u.paramsEnd,E.push({content:"",ability:u.ability,type:u.type,id:u.id}),E.pop();let C=L[b+1],h=C?C.pos:F.length;E.push({content:F.slice(S,h),ability:u.ability,type:u.type,id:u.id}),S=h}}else S=f.pos+5}if(S<F.length){let b=E[E.length-1];if(L.length>0&&L[L.length-1].type==="else")E.push({content:F.slice(S),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),P=K==="can"?k:!k,y="";if(P)y=E[0]?.content||"";else{let b=!1;for(let f=1;f<E.length;f++){let r=E[f];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let u=Q(r.ability,r.type,r.id);if(K==="can"?u:!u){y=r.content,b=!0;break}}}if(!b&&E.length>0){let f=E[E.length-1];if(f.isFinalElse)y=f.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),B=!0}}return Y}function JX($,Z,Y){let X=$;function J(Q,G,K,W,U){let B=!0;while(B){B=!1;let _=new RegExp(`@${G}\\s*\\(`),z=Q.match(_);if(!z||z.index===void 0)break;let q=z.index,j=Z$(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=I$(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(R)){V=w;break}A=w+1}try{let w=W(L.trim()),R;if(V!==-1){let T=F.slice(0,V),I=F.slice(V+5);R=w?T:I}else R=w?F:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),B=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=J0(U,`Error processing @${G} directive: ${R}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=$$(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=$$(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 QX($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let B=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,B.lastIndex=0;let O=B.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){B.lastIndex=N,_.lastIndex=N;let k=B.exec(j),P=_.exec(j),y=k?k.index:1/0,b=P?P.index:1/0;if(y<b)V++,N=y+k[0].length;else if(b<1/0){if(V--,V===0){A=b;break}N=b+P[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),R=-1,T=0,I=0;while(I<w.length){let k=w.indexOf("@",I);if(k===-1)break;let P=w.substring(k);if(z.test(P)){T++,I=k+1;continue}if(q.test(P)){T--,I=k+1;continue}if(T===0&&/^@else(?![a-z])/.test(P)){R=k;break}I=k+1}let E;if(R!==-1){let k=w.slice(0,R),P=w.slice(R+5);E=U?k:P}else E=U?w:"";let S=`@${W}`.length;j=j.substring(0,F)+E+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p3=D(()=>{sY();H1();R4();h0()});function KX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function E$($,Z){if(!$)return Z?.nonceGenerator?.()??KX();let Y=GX.get($);if(!Y)Y=Z?.nonceGenerator?.()??KX(),GX.set($,Y);return Y}function tV($){GX.delete($)}function WX($,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 l3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${WX($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function eV($){return{enabled:!0,directives:{strict:MW,moderate:c3,relaxed:TW,api:IW}[$]||c3,useNonce:$==="strict",addMetaTag:!0}}function $N($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function UX($,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?E$(Y,Z):void 0,J=l3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1830
+ `)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 x0($,Z,Y,X=0){let J=0,Q=X,G=null,K=0,W=!1;while(Q<$.length){let U=$[Q];if(G&&W){W=!1,Q++;continue}if(G&&U==="\\"){W=!0,Q++;continue}if(W=!1,(U==='"'||U==="'"||U==="`")&&!G){G=U,Q++;continue}if(U===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&U==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&U==="}"){K--,Q++;continue}if(U==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(U===Z)J++;else if(U===Y){if(J--,J===0)return Q}Q++}return-1}function $X($,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 u3($){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 Z$($,Z){let Y=sV($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function sV($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=x0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function I$($,Z,Y,X){let J=1,Q=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&J>0){G.lastIndex=Q,K.lastIndex=Q;let W=G.exec($),U=K.exec($),B=W?W.index:1/0,_=U?U.index:1/0;if(B<_)J++,Q=B+W[0].length;else if(_<1/0){if(J--,J===0)return _;Q=_+U[0].length}else break}return-1}function ZX($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=Z$($,X);if(!J)return null;let Q=J.endPos,G=I$($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B="if",_=J.expression,z=0,q=0;while(U<K.length){let j=K.indexOf("@",U);if(j===-1)break;U=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){q++,U++;continue}if(/^@endif(?![a-z])/.test(H)){q--,U+=6;continue}if(q===0){let O=H.match(/^@elseif\s*/);if(O){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U});let F=U+O[0].length,L=Z$(K,F);if(!L){U++;continue}B="elseif",_=L.expression,U=L.endPos,z=U;continue}else if(/^@else(?![a-z])/.test(H)){W.push({type:B,condition:_,content:K.substring(z,U),start:Q+z,end:Q+U}),B="else",_=void 0,U+=5,z=U;continue}}U++}return W.push({type:B,condition:_,content:K.slice(z),start:Q+z,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:W,start:Z,end:G+6}}function c5($){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=ZX($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function w4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,W=K+Q[0].length-1,U=x0($,"(",")",W);if(U===-1){Q=J.exec($);continue}let B=$.slice(W+1,U),_=U+1,z=I$($,Z,Y,_);if(z===-1){Q=J.exec($);continue}let q=$.slice(_,z),j=z+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:B,content:q,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function m3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=Z$($,X);if(!J)return null;let Q=J.endPos,G=I$($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),W=[],U=0,B=null,_=0;while(U<K.length){let z=K.slice(U),q=z.match(/^@switch\s*\(/),j=z.match(/^@endswitch(?![a-z])/);if(q){if(_++,B)B.content+=q[0];U+=q[0].length;continue}if(j){if(_--,B)B.content+=j[0];U+=j[0].length;continue}if(_>0){if(B)B.content+=K[U];U++;continue}let H=z.match(/^@case\s*/),O=z.match(/^@default(?![a-z])/),F=z.match(/^@break(?![a-z])/);if(H&&z.startsWith("@case")){if(B)W.push(B);let L=U+H[0].length,V=Z$(K,L);if(!V){U++;continue}B={type:"case",value:V.expression,content:""},U=V.endPos}else if(O&&z.startsWith("@default")){if(B)W.push(B);B={type:"default",content:""},U+=O[0].length}else if(F&&z.startsWith("@break"))U+=F[0].length;else{if(B)B.content+=K[U];U++}}if(B)W.push(B);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:W,start:Z,end:G+10}}var HW=()=>{};function FW($){let Z=[],Y=0;while(Y<$.length){let X=$.indexOf("{{",Y),J=$.indexOf("{!!",Y),Q=!1,G;if(X===-1&&J===-1)break;else if(X===-1)G=J,Q=!0;else if(J===-1)G=X,Q=!1;else if(J<X)G=J,Q=!0;else G=X,Q=!1;if(!Q&&$.slice(G,G+3)==="{{{")Q=!0;let K=Q?$.slice(G,G+3)==="{{{"?"{{{":"{!!":"{{",W=Q?K==="{{{"?"}}}":"!!}":"}}",U=G+K.length,B=rV($,U,W);if(B===-1){Y=G+1;continue}let _=$.slice(U,B).trim(),z=B+W.length;Z.push({fullMatch:$.slice(G,z),expression:_,start:G,end:z,isRaw:Q}),Y=z}return Z}function rV($,Z,Y){let X=Z,J=null,Q={paren:0,bracket:0,brace:0},G=0;while(X<$.length){let K=$[X];if((X>0?$[X-1]:"")==="\\"&&J){X++;continue}if((K==='"'||K==="'")&&!J){J=K,X++;continue}if(K===J&&J!=="`"){J=null,X++;continue}if(K==="`"&&!J){J="`",X++;continue}if(K==="`"&&J==="`"&&G===0){J=null,X++;continue}if(J==="`"&&K==="$"&&$[X+1]==="{"){G++,X+=2;continue}if(G>0){if(K==="{")G++;else if(K==="}")G--;X++;continue}if(J){X++;continue}if(K==="(")Q.paren++;else if(K===")")Q.paren--;else if(K==="[")Q.bracket++;else if(K==="]")Q.bracket--;else if(K==="{")Q.brace++;else if(K==="}")Q.brace--;if(Q.paren===0&&Q.bracket===0&&Q.brace<=0){if($.slice(X,X+Y.length)===Y)return X}X++}return-1}function VW($){let Z=u3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=oV(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function oV($){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=x0(Z,"(",")",Y);if(Q===-1)return{name:X,args:[]};let G=Z.slice(J,Q),K=YX(G);return{name:X,args:K}}function YX($){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 NW($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return null;let X=x0($,"(",")",Y);if(X===-1)return null;return{params:$.slice(Y+1,X),endPos:X+1}}function AW($){let Z=[],X=new A4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let W=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let _=J<X.length?X[J].start:$.length,z=OW(X,J,$);J=z.nextIndex,Z.push({type:"variable",name:B,value:$.slice(_,z.endPos),exported:G,start:K.start,end:z.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let B=U.start,_=U.value==="{"?"}":"]",z=x0($,U.value,_,B);if(z!==-1){let q=$.slice(B,z+1);if(J=LW(X,z+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=OW(X,J,$);J=H.nextIndex;let O=`__stx_destructured_${Z.length}`;Z.push({type:"variable",name:O,value:`${$.slice(j,H.endPos)}; ${W} ${q} = ${O}`,exported:G,start:K.start,end:H.endPos})}}}}else if(K.type==="IDENTIFIER"&&K.value==="function"){let W=G?X[J-1].start:K.start;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let B=U.value;J++;let _=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){_=X[J].start;break}J++}if(_!==-1){let z=x0($,"{","}",_);if(z!==-1)Z.push({type:"function",name:B,value:$.slice(W,z+1).replace(/^export\s+/,""),exported:G,start:W,end:z+1}),J=LW(X,z+1)}}}else J++}return Z}function OW($,Z,Y){let X=Z,J={paren:0,bracket:0,brace:0},Q=Z<$.length?$[Z].start:Y.length;while(X<$.length){let G=$[X];if(G.type==="PUNCTUATION"){if(G.value==="(")J.paren++;else if(G.value===")")J.paren--;else if(G.value==="[")J.bracket++;else if(G.value==="]")J.bracket--;else if(G.value==="{")J.brace++;else if(G.value==="}")J.brace--;if(G.value===";"&&J.paren===0&&J.bracket===0&&J.brace===0){Q=G.start,X++;break}}if(G.type==="IDENTIFIER"&&(G.value==="const"||G.value==="let"||G.value==="var"||G.value==="function"||G.value==="export")){if(J.paren===0&&J.bracket===0&&J.brace===0){Q=$[X-1]?.end??G.start;break}}Q=G.end,X++}return{nextIndex:X,endPos:Q}}function LW($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var wW=()=>{};var R4=D(()=>{HW();wW()});function aV($,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=m3(X,G);if(!K)break;try{let W;if(H0(K.expression))W=O0(K.expression,Object.keys(Z))(...Object.values(Z));else W=z0(K.expression,Z);let U="",B=!1;for(let _ of K.cases)if(_.type==="default"){if(!B)U=_.content.trim()}else try{let z;if(_.value&&H0(_.value))z=O0(_.value,Object.keys(Z))(...Object.values(Z));else if(_.value)z=z0(_.value,Z);if(W===z){U=_.content.trim(),B=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("Switch",`Error evaluating @switch expression: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,G)+B+X.substring(K.end);break}}return X}function U5($,Z,Y){let X=$;X=aV(X,Z,Y);{let Q=!0;while(Q){Q=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,W=Z$(X,K+7);if(!W)break;let U=W.endPos,B=I$(X,"unless","endunless",U);if(B===-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 _=X.slice(U,B),z=W.expression,q=-1;{let H=0,O=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,L=/@else(?![a-z])/g,V=[],N;while((N=O.exec(_))!==null)V.push({pos:N.index,type:"open"});while((N=F.exec(_))!==null)V.push({pos:N.index,type:"close"});while((N=L.exec(_))!==null)V.push({pos:N.index,type:"else"});V.sort((A,w)=>A.pos-w.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){q=A.pos;break}}let j;if(q!==-1){let H=_.slice(0,q),O=_.slice(q+5);j=`@if (${z})${O}@else ${H}@endif`}else j=`@if (!(${z}))${_}@endif`;X=X.substring(0,K)+j+X.substring(B+10),Q=!0}}X=JX(X,Z,Y),X=QX(X,Z,Y),X=XX(X,Z);let J=()=>{let Q=c5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let W="",U=!1;for(let B of K.branches){if(U)break;if(B.type==="else")W=B.content,U=!0;else try{let _;if(B.condition&&H0(B.condition))_=O0(B.condition,Object.keys(Z))(...Object.values(Z));else if(B.condition)_=z0(B.condition,Z);if(_)W=B.content,U=!0}catch(_){W=J0(B.type==="if"?"If":"Elseif",`Error in @${B.type}(${B.condition}): ${_ instanceof Error?_.message:String(_)}`,e.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+W+X.substring(K.end)}catch(W){let U=W instanceof Error?W.message:String(W),B=J0("If",`Error processing @if block: ${U}`,e.EVALUATION_ERROR);X=X.substring(0,K.start)+B+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function RW($){let Z=0;while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!=="(")return null;Z++;while(Z<$.length&&/\s/.test($[Z]))Z++;let Y=$[Z];if(Y!=="'"&&Y!=='"')return null;Z++;let X=[];while(Z<$.length){let J=$[Z];if(J==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(J===Y){Z++;break}X.push(J),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function XX($,Z){let Y=$;function X(K,W,U,B){let _=1,z=B,q=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(z<K.length&&_>0){q.lastIndex=z,j.lastIndex=z;let H=q.exec(K),O=j.exec(K),F=H?H.index:1/0,L=O?O.index:1/0;if(F<L)_++,z=F+H[0].length;else if(L<1/0){if(_--,_===0)return L;z=L+O[0].length}else break}return-1}function J(K,W,U){let B=0,_=new RegExp(`@${W}(?:\\s*\\(|\\s|$)`,"g"),z=new RegExp(`@${U}(?![a-z])`,"g"),q=/@else(?![a-z])/g,j=[],H;while((H=_.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=z.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=q.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((O,F)=>O.pos-F.pos);for(let O of j)if(O.type==="open")B++;else if(O.type==="close")B--;else if(O.type==="else"&&B===0)return O.pos;return-1}{let K=!0;while(K){K=!1;let W=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+5),q=RW(z);if(q)B=q.value,_=U+5+q.consumed;else _=U+5;let j=X(Y,"auth","endauth",_);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=B?$$(`auth?.check && auth?.user?.[${B}]`,Z):$$("auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let W=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!W||W.index===void 0)break;let U=W.index,B,_,z=Y.slice(U+6),q=RW(z);if(q)B=q.value,_=U+6+q.consumed;else _=U+6;let j=X(Y,"guest","endguest",_);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(_,j),O=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=B?$$(`!auth?.check || !auth?.user?.[${B}]`,Z):$$("!auth?.check",Z);let L;if(O!==-1){let V=H.slice(0,O),N=H.slice(O+5);L=F?V:N}else L=F?H:"";Y=Y.substring(0,U)+L+Y.substring(j+9),K=!0}}function Q(K,W,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let B=[K];if(W)B.push(W);if(U){let _=$$(U,Z);B.push(_)}return Z.permissions.check(...B)}catch{return!1}return!1}function G(K){let W=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!W)return null;return{ability:W[1],type:W[2],id:W[3]?.trim(),paramsEnd:W[0].length}}for(let K of["can","cannot"]){let W=`end${K}`,U=K==="can"?"elsecan":"elsecannot",B=!0;while(B){B=!1;let _=Y.match(new RegExp(`@${K}\\s*\\(`));if(!_||_.index===void 0)break;let z=_.index,q=Y.slice(z+`@${K}`.length),j=G(q);if(!j)break;let H=z+`@${K}`.length+j.paramsEnd,O=X(Y,K,W,H);if(O===-1){console.warn(`[stx] @${K} directive at position ${z} has no matching @${W} \u2014 the block was skipped.`);break}let F=Y.slice(H,O),L=[],V=0,N=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${W}(?![a-z])`,"g"),w=new RegExp(`@${U}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],I;while((I=N.exec(F))!==null)T.push({pos:I.index,type:"open"});while((I=A.exec(F))!==null)T.push({pos:I.index,type:"close"});while((I=w.exec(F))!==null)T.push({pos:I.index,type:"elseDirective"});while((I=R.exec(F))!==null)T.push({pos:I.index,type:"else"});T.sort((b,f)=>b.pos-f.pos);for(let b of T){if(b.type==="open"){V++;continue}if(b.type==="close"){V--;continue}if(V===0)L.push(b)}let E=[],S=0;for(let b=0;b<L.length;b++){let f=L[b];if(E.push({content:F.slice(S,f.pos),ability:void 0}),f.type==="elseDirective"){let r=F.slice(f.pos+`@${U}`.length),u=G(r);if(u){E[E.length-1]={content:F.slice(S,f.pos)},S=f.pos+`@${U}`.length+u.paramsEnd,E.push({content:"",ability:u.ability,type:u.type,id:u.id}),E.pop();let C=L[b+1],h=C?C.pos:F.length;E.push({content:F.slice(S,h),ability:u.ability,type:u.type,id:u.id}),S=h}}else S=f.pos+5}if(S<F.length){let b=E[E.length-1];if(L.length>0&&L[L.length-1].type==="else")E.push({content:F.slice(S),isFinalElse:!0});else if(E.length===0)E.push({content:F.slice(S)})}let k=Q(j.ability,j.type,j.id),P=K==="can"?k:!k,y="";if(P)y=E[0]?.content||"";else{let b=!1;for(let f=1;f<E.length;f++){let r=E[f];if(r.isFinalElse){y=r.content,b=!0;break}if(r.ability){let u=Q(r.ability,r.type,r.id);if(K==="can"?u:!u){y=r.content,b=!0;break}}}if(!b&&E.length>0){let f=E[E.length-1];if(f.isFinalElse)y=f.content}}Y=Y.substring(0,z)+y+Y.substring(O+`@${W}`.length),B=!0}}return Y}function JX($,Z,Y){let X=$;function J(Q,G,K,W,U){let B=!0;while(B){B=!1;let _=new RegExp(`@${G}\\s*\\(`),z=Q.match(_);if(!z||z.index===void 0)break;let q=z.index,j=Z$(Q,q+`@${G}`.length);if(!j)break;let H=j.endPos,O=I$(Q,G,K,H);if(O===-1){console.warn(`[stx] @${G} directive at position ${q} has no matching @${K} \u2014 the block was skipped.`);break}let F=Q.slice(H,O),L=j.expression,V=-1,N=0,A=0;while(A<F.length){let w=F.indexOf("@",A);if(w===-1)break;let R=F.substring(w);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){N++,A=w+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){N--,A=w+1;continue}if(N===0&&/^@else(?![a-z])/.test(R)){V=w;break}A=w+1}try{let w=W(L.trim()),R;if(V!==-1){let T=F.slice(0,V),I=F.slice(V+5);R=w?T:I}else R=w?F:"";Q=Q.substring(0,q)+R+Q.substring(O+`@${K}`.length),B=!0}catch(w){let R=w instanceof Error?w.message:String(w),T=J0(U,`Error processing @${G} directive: ${R}`,e.EVALUATION_ERROR);Q=Q.substring(0,q)+T+Q.substring(O+`@${K}`.length);break}}return Q}return X=J(X,"isset","endisset",(Q)=>{let G=$$(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=$$(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 QX($,Z,Y){let X=$,J="development";function Q(G,K,W,U){let B=new RegExp(`@${K}(?![a-z])`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),z=new RegExp(`^@${K}(?![a-z])`),q=new RegExp(`^@${W}(?![a-z])`),j=G,H=!0;while(H){H=!1,B.lastIndex=0;let O=B.exec(j);if(!O)break;let F=O.index,L=F+O[0].length;if(K==="env"){let k=j.substring(L).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!k)break;L+=k[0].length,U=J===k[2]}let V=1,N=L,A=-1;while(V>0&&N<j.length){B.lastIndex=N,_.lastIndex=N;let k=B.exec(j),P=_.exec(j),y=k?k.index:1/0,b=P?P.index:1/0;if(y<b)V++,N=y+k[0].length;else if(b<1/0){if(V--,V===0){A=b;break}N=b+P[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${W} \u2014 the block was skipped.`);break}let w=j.substring(L,A),R=-1,T=0,I=0;while(I<w.length){let k=w.indexOf("@",I);if(k===-1)break;let P=w.substring(k);if(z.test(P)){T++,I=k+1;continue}if(q.test(P)){T--,I=k+1;continue}if(T===0&&/^@else(?![a-z])/.test(P)){R=k;break}I=k+1}let E;if(R!==-1){let k=w.slice(0,R),P=w.slice(R+5);E=U?k:P}else E=U?w:"";let S=`@${W}`.length;j=j.substring(0,F)+E+j.substring(A+S),H=!0}return j}return X=Q(X,"env","endenv",!1),X=Q(X,"production","endproduction",J==="production"),X=Q(X,"development","enddevelopment",J==="development"),X=Q(X,"staging","endstaging",J==="staging"),X=Q(X,"testing","endtesting",J==="testing"),X}var p3=D(()=>{sY();H1();R4();h0()});function KX($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function E$($,Z){if(!$)return Z?.nonceGenerator?.()??KX();let Y=GX.get($);if(!Y)Y=Z?.nonceGenerator?.()??KX(),GX.set($,Y);return Y}function tV($){GX.delete($)}function WX($,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 l3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${WX($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function eV($){return{enabled:!0,directives:{strict:MW,moderate:c3,relaxed:TW,api:IW}[$]||c3,useNonce:$==="strict",addMetaTag:!0}}function $N($,Z){let Y={...$};for(let[X,J]of Object.entries(Z)){let Q=X,G=Y[Q];if(J===void 0||J===null)continue;if(typeof J==="boolean")Y[Q]=G||J;else if(Array.isArray(J)){let K=Array.isArray(G)?G:[],W=[...new Set([...K,...J])];Y[Q]=W}}return Y}function UX($,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?E$(Y,Z):void 0,J=l3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
1831
1831
  ${J}`)}function ZN($,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 BX($,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?E$(Z,Q):void 0;return l3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return E$(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=E$(Z,Q);return J}function YN(){return[EW,DW]}function XN($){let Z=[];if($["script-src"]?.includes("'unsafe-inline'"))Z.push("CSP: Using unsafe-inline in script-src significantly reduces XSS protection");if($["script-src"]?.includes("'unsafe-eval'"))Z.push("CSP: Using unsafe-eval in script-src allows eval() and related functions");if(!$["default-src"])Z.push("CSP: No default-src specified. Recommend adding default-src as a fallback");if($["default-src"]?.includes("*"))Z.push("CSP: Using * in default-src provides minimal protection");if(!$["object-src"]&&!$["default-src"]?.includes("'none'"))Z.push("CSP: Consider adding object-src: none to block plugins");if(!$["base-uri"])Z.push("CSP: Consider adding base-uri to prevent base tag injection attacks");for(let[Y,X]of Object.entries($))if(Array.isArray(X)&&X.includes("http:"))Z.push(`CSP: Using http: in ${Y} allows insecure resources`);return Z}function kW($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function JN($,Z){if(!$.enabled)return{};let Y=$.useNonce?E$(Z,$):void 0,X=WX($.directives,Y);return{[kW($.reportOnly)]:X}}var GX,MW,c3,TW,IW,EW,DW,QN;var _X=D(()=>{GX=new WeakMap;MW={"default-src":["'self'"],"script-src":["'self'","'strict-dynamic'"],"style-src":["'self'"],"img-src":["'self'","data:","https:"],"font-src":["'self'","https:","data:"],"connect-src":["'self'"],"media-src":["'self'"],"object-src":["'none'"],"frame-src":["'none'"],"base-uri":["'self'"],"form-action":["'self'"],"frame-ancestors":["'self'"],"upgrade-insecure-requests":!0},c3={"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},TW={"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'"]},IW={"default-src":["'none'"],"frame-ancestors":["'none'"]};EW={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?E$(Y,Q):void 0;return l3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},DW={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return E$(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};QN={enabled:!1,reportOnly:!1,directives:c3,useNonce:!1,addMetaTag:!0}});import GN from"crypto";function WN($=KN){let Z=GN.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return zX=Z,Z}function UN(){if(!zX)WN();return zX}function BN($=SW){let Z=UN();return`<input type="hidden" name="${$}" value="${Z}">`}function bW($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return BN(X||SW)})}var KN=40,SW="_token",zX=null;var CW=()=>{};async function qX($,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 _N(J,Q,Z,Y,X);else J=await zN(J,Q,Z,Y,X)}return J}async function _N($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,W=`@end${Q}`,U=$,B=f5(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${W}`,"g"),_=[],z=B.exec(U);while(z!==null){let[q,j="",H=""]=z,O=z.index||0;try{let F=j?yW(j):[],L=H.trim(),V=await G(L,F,Y,X);_.push({original:q,processed:V,startIndex:O})}catch(F){let L=F instanceof Error?F.message:String(F);if(J.debug)console.error(`Error processing custom directive @${Q}:`,F);_.push({original:q,processed:J0("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${L}`,e.EVALUATION_ERROR),startIndex:O})}z=B.exec(U)}for(let q=_.length-1;q>=0;q--){let{original:j,processed:H}=_[q];U=U.replace(j,H)}return U}async function zN($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,W=f5(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],B=W.exec(K);while(B!==null){let[q,j=""]=B,H=B.index||0;try{let O=yW(j),F=await G("",O,Y,X);U.push({original:q,processed:F,startIndex:H})}catch(O){let F=O instanceof Error?O.message:String(O);if(J.debug)console.error(`Error processing custom directive @${Q}:`,O);U.push({original:q,processed:J0("CustomDirective",`Error in @${Q}(${j}): ${F}`,e.EVALUATION_ERROR),startIndex:H})}B=W.exec(K)}let _=f5(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),z=_.exec(K);while(z!==null){let[q]=z,j=z.index||0;try{let H=await G("",[],Y,X);U.push({original:q,processed:H,startIndex:j})}catch(H){let O=H instanceof Error?H.message:String(H);if(J.debug)console.error(`Error processing custom directive @${Q}:`,H);U.push({original:q,processed:J0("CustomDirective",`Error in @${Q}: ${O}`,e.EVALUATION_ERROR),startIndex:j})}z=_.exec(K)}for(let q=U.length-1;q>=0;q--){let{original:j,processed:H}=U[q];K=K.replace(j,H)}return K}function yW($){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 jX=D(()=>{H1();W5()});var s3={};Z0(s3,{useTitle:()=>vW,useSeoMeta:()=>M4,usePageTitle:()=>vW,useHead:()=>k$,resetHead:()=>PW,renderHtmlAttrs:()=>gW,renderHead:()=>fW,renderBodyAttrs:()=>hW,processTitleDirective:()=>mW,processMetaDirective:()=>pW,processHeadDirective:()=>uW,getPageMeta:()=>n3,getHead:()=>l5,definePageMeta:()=>xW,applyHead:()=>dW});function l5(){return D$}function n3(){return i3}function PW(){D$={},qN.length=0,i3={}}function k$($){D$=jN(D$,$)}function jN($,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 M4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let W=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:W})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let W of $.articleTags)Z.push({property:"article:tag",content:W});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});k$({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function xW($){if(i3={...i3,...$},$.title||$.description)M4({title:$.title,description:$.description})}function vW($){let Z=typeof $==="function"?$():$;k$({title:Z})}function fW($=D$){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${B5(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${B5(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}="${B5(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}="${B5(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}="${B5(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(`
1832
1832
  `)}function gW($=D$){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${B5(Y)}"`).join(" ")}function hW($=D$){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${B5(Y)}"`).join(" ")}function B5($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function dW($=D$){if(typeof document>"u")return;if($.title){let Z=$.title;if($.titleTemplate)Z=typeof $.titleTemplate==="function"?$.titleTemplate(Z):$.titleTemplate.replace("%s",Z);document.title=Z}for(let Z of $.meta||[]){let Y=Z.name?`meta[name="${Z.name}"]`:Z.property?`meta[property="${Z.property}"]`:null;if(Y){let X=document.querySelector(Y);if(!X){if(X=document.createElement("meta"),Z.name)X.setAttribute("name",Z.name);if(Z.property)X.setAttribute("property",Z.property);document.head.appendChild(X)}X.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,X=document.querySelector(Y);if(!X)X=document.createElement("link"),document.head.appendChild(X);for(let[J,Q]of Object.entries(Z))if(Q!==void 0)X.setAttribute(J,String(Q))}if($.htmlAttrs)for(let[Z,Y]of Object.entries($.htmlAttrs))document.documentElement.setAttribute(Z,Y);if($.bodyAttrs)for(let[Z,Y]of Object.entries($.bodyAttrs))document.body.setAttribute(Z,Y)}function uW($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
1833
1833
  `,""}),headContent:Z.trim()}}function mW($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return k$({title:G}),""})}function pW($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let W=Q?G:K,U=Q?W:Z[(W||"").trim()]??W,_=J.includes(":")?{property:J,content:U}:{name:J,content:U};return k$({meta:[_]}),""})}var D$,qN,i3;var S$=D(()=>{D$={},qN=[],i3={}});import HN from"crypto";function i0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ON($){return{...o3,...$.forms?.classes}}function r3($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function LN(){return HN.randomUUID()}function FN($,Z,Y,X){let J=ON(X),Q=$;return Q=nW(Q,Z),Q=i5(Q,Z),Q=a3(Q,Z,J),Q=t3(Q,Z,J),Q}function i5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=LN();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${i0(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="${i0(Q)}">`;return X}),Y}function a3($,Z,Y=o3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,W,U="")=>{let B=Q||G||"POST",_=K||W||"",z=b$(U),q=B.toUpperCase(),j=["GET","POST"].includes(q)?q:"POST",H=`<form method="${i0(j)}" action="${i0(_)}"${z?` ${z}`:""}>`;if(H+=`