@stacksjs/stx 0.2.78 → 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
@@ -2455,7 +2455,7 @@ window.__stx_reactive = (function() {
2455
2455
  ${pG()}
2456
2456
  ${Y}
2457
2457
  </script>`}function R8($,Z,Y){if(N8=0,!iG($))return $;let X=hG($);if(X.length===0)return $;let Q=lG($,X),J=cG(X,Z),G=Q.lastIndexOf("</body>");if(G!==-1)Q=Q.slice(0,G)+J+`
2458
- `+Q.slice(G);else Q+=J;return Q}function lG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${T$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${T$(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*"${T$(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*'${T$(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 iG($){return/x-data\s*=\s*["']/.test($)}var N8=0,gG=0;var T8=k(()=>{u0()});import nG from"fs";import F7 from"path";import{createHighlighter as oG}from"ts-syntax-highlighter";async function sG($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await nG.promises.stat($)).mtime.getTime();if(Z.cache&&V7.has($)){let U=V7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=S6(Q),K=Z.markdown||q7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},q=q5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)q=await rG(q,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let W={content:q,data:J||{}};if(Z.cache)V7.set($,{...W,updatedAt:X});return W}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function rG($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!M$)try{M$=await oG({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,z,q,W)=>{let U=W.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),B=q||(Y?"text":"");if(!B)return K;try{if(!M$.getSupportedLanguages().includes(B))return K;return(await M$.highlight(U,B,{theme:Z})).html}catch(_){console.error(`Error highlighting code block with language ${q}:`,_)}return K},J=$,G=$.matchAll(X);for(let K of G){let[z,q,W,U]=K,B=await Q(z,q,W,U);J=J.replace(z,B)}return J}async function M8($,Z,Y="",X={}){return await aG($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,q)=>{try{let W=K;if(!F7.isAbsolute(K))W=F7.resolve(F7.dirname(Y),K);let U={};if(z)try{try{U=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),T=N.startsWith("'")&&N.endsWith("'");if(R||T)N=N.substring(1,N.length-1);U[A]=N}}}}catch(L){if(X.debug)console.error("Error parsing context in @markdown-file directive:",L)}let{content:B,data:_}=await sG(W,X),j={...Z,..._,...U},H=B,F=/\{\{([^}]+)\}\}/g;return H=H.replace(F,(L,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):L}),H}catch(W){let U=W instanceof Error?W.message:String(W);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,q,G)}})}async function aG($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],z=Q.index,q=Q;X.push(Y(...q).then((W)=>({match:K,replacement:W,index:z})))}let J=await Promise.all(X);J.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of J)G=G.replace(K,()=>z);return G}var V7,M$=null;var I8=k(()=>{p1();O0();V7=new Map});function X1($,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 D8=k(()=>{H0()});function J1($,Z){let Y=tG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function tG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function M1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let z=G.exec($),q=K.exec($),W=z?z.index:1/0,U=q?q.index:1/0;if(W<U)Q++,J=W+z[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+q[0].length}else break}return-1}function E8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=M1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W="if",U=Q.expression,B=0,_=0;while(q<K.length){let j=K.indexOf("@",q);if(j===-1)break;q=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){_++,q++;continue}if(/^@endif(?![a-z])/.test(H)){_--,q+=6;continue}if(_===0){let F=H.match(/^@elseif\s*/);if(F){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q});let L=q+F[0].length,O=J1(K,L);if(!O){q++;continue}W="elseif",U=O.expression,q=O.endPos,B=q;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q}),W="else",U=void 0,q+=5,B=q;continue}}q++}return z.push({type:W,condition:U,content:K.slice(B),start:J+B,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function L5($){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 J=E8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function I$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,z=K+J[0].length-1,q=D0($,"(",")",z);if(q===-1){J=Q.exec($);continue}let W=$.slice(z+1,q),U=q+1,B=M1($,Z,Y,U);if(B===-1){J=Q.exec($);continue}let _=$.slice(U,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:_,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function w7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=M1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W=null,U=0;while(q<K.length){let B=K.slice(q),_=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(_){if(U++,W)W.content+=_[0];q+=_[0].length;continue}if(j){if(U--,W)W.content+=j[0];q+=j[0].length;continue}if(U>0){if(W)W.content+=K[q];q++;continue}let H=B.match(/^@case\s*/),F=B.match(/^@default(?![a-z])/),L=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(W)z.push(W);let O=q+H[0].length,V=J1(K,O);if(!V){q++;continue}W={type:"case",value:V.expression,content:""},q=V.endPos}else if(F&&B.startsWith("@default")){if(W)z.push(W);W={type:"default",content:""},q+=F[0].length}else if(L&&B.startsWith("@break"))q+=L[0].length;else{if(W)W.content+=K[q];q++}}if(W)z.push(W);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:z,start:Z,end:G+10}}var k8=()=>{};var b8=()=>{};var D$=k(()=>{k8();b8()});function YK($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=w7(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let q="",W=!1;for(let U of K.cases)if(U.type==="default"){if(!W)q=U.content.trim()}else try{let B;if(U.value&&Z0(U.value))B=Y0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)B=$0(U.value,Z);if(z===B){q=U.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+q+X.substring(K.end),Q=!0}catch(z){let q=z instanceof Error?z.message:String(z),W=r("Switch",`Error evaluating @switch expression: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function I1($,Z,Y){let X=$;X=YK(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=J1(X,K+7);if(!z)break;let q=z.endPos,W=M1(X,"unless","endunless",q);if(W===-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 U=X.slice(q,W),B=z.expression,_=-1;{let H=0,F=/@(?:if|unless)\s*\(/g,L=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=F.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=L.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){_=A.pos;break}}let j;if(_!==-1){let H=U.slice(0,_),F=U.slice(_+5);j=`@if (${B})${F}@else ${H}@endif`}else j=`@if (!(${B}))${U}@endif`;X=X.substring(0,K)+j+X.substring(W+10),J=!0}}X=N7(X,Z,Y),X=R7(X,Z,Y),X=A7(X,Z);let Q=()=>{let J=L5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let z="",q=!1;for(let W of K.branches){if(q)break;if(W.type==="else")z=W.content,q=!0;else try{let U;if(W.condition&&Z0(W.condition))U=Y0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)U=$0(W.condition,Z);if(U)z=W.content,q=!0}catch(U){z=r(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),q=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let q=z instanceof Error?z.message:String(z),W=r("If",`Error processing @if block: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(Q());return X}function S8($){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 Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function A7($,Z){let Y=$;function X(K,z,q,W){let U=1,B=W,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${q}(?![a-z])`,"g");while(B<K.length&&U>0){_.lastIndex=B,j.lastIndex=B;let H=_.exec(K),F=j.exec(K),L=H?H.index:1/0,O=F?F.index:1/0;if(L<O)U++,B=L+H[0].length;else if(O<1/0){if(U--,U===0)return O;B=O+F[0].length}else break}return-1}function Q(K,z,q){let W=0,U=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${q}(?![a-z])`,"g"),_=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((F,L)=>F.pos-L.pos);for(let F of j)if(F.type==="open")W++;else if(F.type==="close")W--;else if(F.type==="else"&&W===0)return F.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+5),_=S8(B);if(_)W=_.value,U=q+5+_.consumed;else U=q+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${q} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"auth","endauth"),L;if(!Z.auth)L=!1;else L=W?X1(`auth?.check && auth?.user?.[${W}]`,Z):X1("auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+6),_=S8(B);if(_)W=_.value,U=q+6+_.consumed;else U=q+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${q} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"guest","endguest"),L;if(!Z.auth)L=!0;else L=W?X1(`!auth?.check || !auth?.user?.[${W}]`,Z):X1("!auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+9),K=!0}}function J(K,z,q){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(z)W.push(z);if(q){let U=X1(q,Z);W.push(U)}return Z.permissions.check(...W)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,q=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let B=U.index,_=Y.slice(B+`@${K}`.length),j=G(_);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,F=X(Y,K,z,H);if(F===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${z} \u2014 the block was skipped.`);break}let L=Y.slice(H,F),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${z}(?![a-z])`,"g"),N=new RegExp(`@${q}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(L))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(L))!==null)T.push({pos:M.index,type:"close"});while((M=N.exec(L))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(L))!==null)T.push({pos:M.index,type:"else"});T.sort((S,P)=>S.pos-P.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let P=O[S];if(I.push({content:L.slice(E,P.pos),ability:void 0}),P.type==="elseDirective"){let d=L.slice(P.pos+`@${q}`.length),f=G(d);if(f){I[I.length-1]={content:L.slice(E,P.pos)},E=P.pos+`@${q}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let u=O[S+1],n=u?u.pos:L.length;I.push({content:L.slice(E,n),ability:f.ability,type:f.type,id:f.id}),E=n}}else E=P.pos+5}if(E<L.length){let S=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:L.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:L.slice(E)})}let D=J(j.ability,j.type,j.id),C=K==="can"?D:!D,b="";if(C)b=I[0]?.content||"";else{let S=!1;for(let P=1;P<I.length;P++){let d=I[P];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)b=P.content}}Y=Y.substring(0,B)+b+Y.substring(F+`@${z}`.length),W=!0}}return Y}function N7($,Z,Y){let X=$;function Q(J,G,K,z,q){let W=!0;while(W){W=!1;let U=new RegExp(`@${G}\\s*\\(`),B=J.match(U);if(!B||B.index===void 0)break;let _=B.index,j=J1(J,_+`@${G}`.length);if(!j)break;let H=j.endPos,F=M1(J,G,K,H);if(F===-1){console.warn(`[stx] @${G} directive at position ${_} has no matching @${K} \u2014 the block was skipped.`);break}let L=J.slice(H,F),O=j.expression,V=-1,w=0,A=0;while(A<L.length){let N=L.indexOf("@",A);if(N===-1)break;let R=L.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=N;break}A=N+1}try{let N=z(O.trim()),R;if(V!==-1){let T=L.slice(0,V),M=L.slice(V+5);R=N?T:M}else R=N?L:"";J=J.substring(0,_)+R+J.substring(F+`@${K}`.length),W=!0}catch(N){let R=N instanceof Error?N.message:String(N),T=r(q,`Error processing @${G} directive: ${R}`,i.EVALUATION_ERROR);J=J.substring(0,_)+T+J.substring(F+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=X1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=X1(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"),X}function R7($,Z,Y){let X=$,Q="development";function J(G,K,z,q){let W=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${z}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),_=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,W.lastIndex=0;let F=W.exec(j);if(!F)break;let L=F.index,O=L+F[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,q=Q===D[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){W.lastIndex=w,U.lastIndex=w;let D=W.exec(j),C=U.exec(j),b=D?D.index:1/0,S=C?C.index:1/0;if(b<S)V++,w=b+D[0].length;else if(S<1/0){if(V--,V===0){A=S;break}w=S+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${L} has no matching @${z} \u2014 the block was skipped.`);break}let N=j.substring(O,A),R=-1,T=0,M=0;while(M<N.length){let D=N.indexOf("@",M);if(D===-1)break;let C=N.substring(D);if(B.test(C)){T++,M=D+1;continue}if(_.test(C)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(C)){R=D;break}M=D+1}let I;if(R!==-1){let D=N.slice(0,R),C=N.slice(R+5);I=q?D:C}else I=q?N:"";let E=`@${z}`.length;j=j.substring(0,L)+I+j.substring(A+E),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var E$=k(()=>{D8();t0();D$();H0()});function C8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function k$($,Z){if(!$)return Z?.nonceGenerator?.()??C8();let Y=y8.get($);if(!Y)Y=Z?.nonceGenerator?.()??C8(),y8.set($,Y);return Y}function XK($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function P8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${XK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function v8($,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?k$(Y,Z):void 0,Q=P8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
2458
+ `+Q.slice(G);else Q+=J;return Q}function lG($,Z){let Y=$;for(let X of Z){let J=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${T$(X.stateExpr)}["']`,"gi").exec(Y);if(J)X.id=J[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${T$(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*"${T$(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*'${T$(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 iG($){return/x-data\s*=\s*["']/.test($)}var N8=0,gG=0;var T8=k(()=>{u0()});import nG from"fs";import F7 from"path";import{createHighlighter as oG}from"ts-syntax-highlighter";async function sG($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await nG.promises.stat($)).mtime.getTime();if(Z.cache&&V7.has($)){let U=V7.get($);if(U.updatedAt>=X)return{content:U.content,data:U.data}}let Q=await Bun.file($).text(),{data:J,content:G}=S6(Q),K=Z.markdown||q7.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},q=q5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)q=await rG(q,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let W={content:q,data:J||{}};if(Z.cache)V7.set($,{...W,updatedAt:X});return W}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function rG($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!M$)try{M$=await oG({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let Q=async(K,z,q,W)=>{let U=W.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),B=q||(Y?"text":"");if(!B)return K;try{if(!M$.getSupportedLanguages().includes(B))return K;return(await M$.highlight(U,B,{theme:Z})).html}catch(_){console.error(`Error highlighting code block with language ${q}:`,_)}return K},J=$,G=$.matchAll(X);for(let K of G){let[z,q,W,U]=K,B=await Q(z,q,W,U);J=J.replace(z,B)}return J}async function M8($,Z,Y="",X={}){return await aG($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,z,q)=>{try{let W=K;if(!F7.isAbsolute(K))W=F7.resolve(F7.dirname(Y),K);let U={};if(z)try{try{U=JSON.parse(z)}catch{if(X.debug)console.warn("Using safer alternative for parsing JS object literal");let O=z.replace(/^\s*\{|\}\s*$/g,"").trim().split(/,(?=\s*\w+\s*:)/);for(let V of O){let w=V.indexOf(":");if(w>0){let A=V.substring(0,w).trim(),N=V.substring(w+1).trim(),R=N.startsWith('"')&&N.endsWith('"'),T=N.startsWith("'")&&N.endsWith("'");if(R||T)N=N.substring(1,N.length-1);U[A]=N}}}}catch(L){if(X.debug)console.error("Error parsing context in @markdown-file directive:",L)}let{content:B,data:_}=await sG(W,X),j={...Z,..._,...U},H=B,F=/\{\{([^}]+)\}\}/g;return H=H.replace(F,(L,O)=>{let V=O.trim();return j[V]!==void 0?String(j[V]):L}),H}catch(W){let U=W instanceof Error?W.message:String(W);return J0("Markdown File",`Error including markdown file: ${U}`,Y,$,q,G)}})}async function aG($,Z,Y){let X=[],Q;while((Q=Z.exec($))!==null){let K=Q[0],z=Q.index,q=Q;X.push(Y(...q).then((W)=>({match:K,replacement:W,index:z})))}let J=await Promise.all(X);J.sort((K,z)=>z.index-K.index);let G=$;for(let{match:K,replacement:z}of J)G=G.replace(K,()=>z);return G}var V7,M$=null;var I8=k(()=>{p1();O0();V7=new Map});function X1($,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 D8=k(()=>{H0()});function J1($,Z){let Y=tG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function tG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let X=D0($,"(",")",Y);if(X===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,X),endPos:X+1}}function M1($,Z,Y,X){let Q=1,J=X,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(J<$.length&&Q>0){G.lastIndex=J,K.lastIndex=J;let z=G.exec($),q=K.exec($),W=z?z.index:1/0,U=q?q.index:1/0;if(W<U)Q++,J=W+z[0].length;else if(U<1/0){if(Q--,Q===0)return U;J=U+q[0].length}else break}return-1}function E8($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=M1($,"if","endif",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W="if",U=Q.expression,B=0,_=0;while(q<K.length){let j=K.indexOf("@",q);if(j===-1)break;q=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){_++,q++;continue}if(/^@endif(?![a-z])/.test(H)){_--,q+=6;continue}if(_===0){let F=H.match(/^@elseif\s*/);if(F){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q});let L=q+F[0].length,O=J1(K,L);if(!O){q++;continue}W="elseif",U=O.expression,q=O.endPos,B=q;continue}else if(/^@else(?![a-z])/.test(H)){z.push({type:W,condition:U,content:K.substring(B,q),start:J+B,end:J+q}),W="else",U=void 0,q+=5,B=q;continue}}q++}return z.push({type:W,condition:U,content:K.slice(B),start:J+B,end:J+K.length}),{fullMatch:$.slice(Z,G+6),branches:z,start:Z,end:G+6}}function L5($){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 J=E8($,X.index);if(J)Z.push(J),Y.lastIndex=J.end;X=Y.exec($)}return Z}function I$($,Z,Y){let X=[],Q=new RegExp(`@${Z}\\s*\\(`,"g"),J=Q.exec($);while(J!==null){if(X.some((H)=>J.index>H.start&&J.index<H.end)){J=Q.exec($);continue}let K=J.index,z=K+J[0].length-1,q=D0($,"(",")",z);if(q===-1){J=Q.exec($);continue}let W=$.slice(z+1,q),U=q+1,B=M1($,Z,Y,U);if(B===-1){J=Q.exec($);continue}let _=$.slice(U,B),j=B+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:_,start:K,end:j}),Q.lastIndex=j,J=Q.exec($)}return X}function w7($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,Q=J1($,X);if(!Q)return null;let J=Q.endPos,G=M1($,"switch","endswitch",J);if(G===-1)return null;let K=$.slice(J,G),z=[],q=0,W=null,U=0;while(q<K.length){let B=K.slice(q),_=B.match(/^@switch\s*\(/),j=B.match(/^@endswitch(?![a-z])/);if(_){if(U++,W)W.content+=_[0];q+=_[0].length;continue}if(j){if(U--,W)W.content+=j[0];q+=j[0].length;continue}if(U>0){if(W)W.content+=K[q];q++;continue}let H=B.match(/^@case\s*/),F=B.match(/^@default(?![a-z])/),L=B.match(/^@break(?![a-z])/);if(H&&B.startsWith("@case")){if(W)z.push(W);let O=q+H[0].length,V=J1(K,O);if(!V){q++;continue}W={type:"case",value:V.expression,content:""},q=V.endPos}else if(F&&B.startsWith("@default")){if(W)z.push(W);W={type:"default",content:""},q+=F[0].length}else if(L&&B.startsWith("@break"))q+=L[0].length;else{if(W)W.content+=K[q];q++}}if(W)z.push(W);return{fullMatch:$.slice(Z,G+10),expression:Q.expression,cases:z,start:Z,end:G+10}}var k8=()=>{};var b8=()=>{};var D$=k(()=>{k8();b8()});function YK($,Z,Y){let X=$,Q=!0;while(Q){Q=!1;let J=X.match(/@switch\s*\(/);if(!J||J.index===void 0)break;let G=J.index,K=w7(X,G);if(!K)break;try{let z;if(Z0(K.expression))z=Y0(K.expression,Object.keys(Z))(...Object.values(Z));else z=$0(K.expression,Z);let q="",W=!1;for(let U of K.cases)if(U.type==="default"){if(!W)q=U.content.trim()}else try{let B;if(U.value&&Z0(U.value))B=Y0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)B=$0(U.value,Z);if(z===B){q=U.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+q+X.substring(K.end),Q=!0}catch(z){let q=z instanceof Error?z.message:String(z),W=r("Switch",`Error evaluating @switch expression: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function I1($,Z,Y){let X=$;X=YK(X,Z,Y);{let J=!0;while(J){J=!1;let G=X.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,z=J1(X,K+7);if(!z)break;let q=z.endPos,W=M1(X,"unless","endunless",q);if(W===-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 U=X.slice(q,W),B=z.expression,_=-1;{let H=0,F=/@(?:if|unless)\s*\(/g,L=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=F.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=L.exec(U))!==null)V.push({pos:w.index,type:"close"});while((w=O.exec(U))!==null)V.push({pos:w.index,type:"else"});V.sort((A,N)=>A.pos-N.pos);for(let A of V)if(A.type==="open")H++;else if(A.type==="close")H--;else if(A.type==="else"&&H===0){_=A.pos;break}}let j;if(_!==-1){let H=U.slice(0,_),F=U.slice(_+5);j=`@if (${B})${F}@else ${H}@endif`}else j=`@if (!(${B}))${U}@endif`;X=X.substring(0,K)+j+X.substring(W+10),J=!0}}X=N7(X,Z,Y),X=R7(X,Z,Y),X=A7(X,Z);let Q=()=>{let J=L5(X);if(J.length===0)return!1;for(let G=J.length-1;G>=0;G--){let K=J[G];try{let z="",q=!1;for(let W of K.branches){if(q)break;if(W.type==="else")z=W.content,q=!0;else try{let U;if(W.condition&&Z0(W.condition))U=Y0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)U=$0(W.condition,Z);if(U)z=W.content,q=!0}catch(U){z=r(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${U instanceof Error?U.message:String(U)}`,i.EVALUATION_ERROR),q=!0}}X=X.substring(0,K.start)+z+X.substring(K.end)}catch(z){let q=z instanceof Error?z.message:String(z),W=r("If",`Error processing @if block: ${q}`,i.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(!0){let J=X;if(!Q())break;if(X===J)break}return X}function S8($){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 Q=$[Z];if(Q==="\\"&&Z+1<$.length){X.push($[Z+1]),Z+=2;continue}if(Q===Y){Z++;break}X.push(Q),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:X.join(""),consumed:Z}}function A7($,Z){let Y=$;function X(K,z,q,W){let U=1,B=W,_=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${q}(?![a-z])`,"g");while(B<K.length&&U>0){_.lastIndex=B,j.lastIndex=B;let H=_.exec(K),F=j.exec(K),L=H?H.index:1/0,O=F?F.index:1/0;if(L<O)U++,B=L+H[0].length;else if(O<1/0){if(U--,U===0)return O;B=O+F[0].length}else break}return-1}function Q(K,z,q){let W=0,U=new RegExp(`@${z}(?:\\s*\\(|\\s|$)`,"g"),B=new RegExp(`@${q}(?![a-z])`,"g"),_=/@else(?![a-z])/g,j=[],H;while((H=U.exec(K))!==null)j.push({pos:H.index,type:"open"});while((H=B.exec(K))!==null)j.push({pos:H.index,type:"close"});while((H=_.exec(K))!==null)j.push({pos:H.index,type:"else"});j.sort((F,L)=>F.pos-L.pos);for(let F of j)if(F.type==="open")W++;else if(F.type==="close")W--;else if(F.type==="else"&&W===0)return F.pos;return-1}{let K=!0;while(K){K=!1;let z=Y.match(/@auth(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+5),_=S8(B);if(_)W=_.value,U=q+5+_.consumed;else U=q+5;let j=X(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${q} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"auth","endauth"),L;if(!Z.auth)L=!1;else L=W?X1(`auth?.check && auth?.user?.[${W}]`,Z):X1("auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+8),K=!0}}{let K=!0;while(K){K=!1;let z=Y.match(/@guest(?:\s*\(|\s|(?=\n))/);if(!z||z.index===void 0)break;let q=z.index,W,U,B=Y.slice(q+6),_=S8(B);if(_)W=_.value,U=q+6+_.consumed;else U=q+6;let j=X(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${q} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),F=Q(H,"guest","endguest"),L;if(!Z.auth)L=!0;else L=W?X1(`!auth?.check || !auth?.user?.[${W}]`,Z):X1("!auth?.check",Z);let O;if(F!==-1){let V=H.slice(0,F),w=H.slice(F+5);O=L?V:w}else O=L?H:"";Y=Y.substring(0,q)+O+Y.substring(j+9),K=!0}}function J(K,z,q){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(z)W.push(z);if(q){let U=X1(q,Z);W.push(U)}return Z.permissions.check(...W)}catch{return!1}return!1}function G(K){let z=K.match(/^\s*\(\s*'([^']*)'(?:,\s*'([^']*)')?(?:,\s*([^)]*))?\)/);if(!z)return null;return{ability:z[1],type:z[2],id:z[3]?.trim(),paramsEnd:z[0].length}}for(let K of["can","cannot"]){let z=`end${K}`,q=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let B=U.index,_=Y.slice(B+`@${K}`.length),j=G(_);if(!j)break;let H=B+`@${K}`.length+j.paramsEnd,F=X(Y,K,z,H);if(F===-1){console.warn(`[stx] @${K} directive at position ${B} has no matching @${z} \u2014 the block was skipped.`);break}let L=Y.slice(H,F),O=[],V=0,w=new RegExp(`@${K}\\s*\\(`,"g"),A=new RegExp(`@${z}(?![a-z])`,"g"),N=new RegExp(`@${q}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(L))!==null)T.push({pos:M.index,type:"open"});while((M=A.exec(L))!==null)T.push({pos:M.index,type:"close"});while((M=N.exec(L))!==null)T.push({pos:M.index,type:"elseDirective"});while((M=R.exec(L))!==null)T.push({pos:M.index,type:"else"});T.sort((S,P)=>S.pos-P.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let P=O[S];if(I.push({content:L.slice(E,P.pos),ability:void 0}),P.type==="elseDirective"){let d=L.slice(P.pos+`@${q}`.length),f=G(d);if(f){I[I.length-1]={content:L.slice(E,P.pos)},E=P.pos+`@${q}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let u=O[S+1],n=u?u.pos:L.length;I.push({content:L.slice(E,n),ability:f.ability,type:f.type,id:f.id}),E=n}}else E=P.pos+5}if(E<L.length){let S=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:L.slice(E),isFinalElse:!0});else if(I.length===0)I.push({content:L.slice(E)})}let D=J(j.ability,j.type,j.id),C=K==="can"?D:!D,b="";if(C)b=I[0]?.content||"";else{let S=!1;for(let P=1;P<I.length;P++){let d=I[P];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=J(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)b=P.content}}Y=Y.substring(0,B)+b+Y.substring(F+`@${z}`.length),W=!0}}return Y}function N7($,Z,Y){let X=$;function Q(J,G,K,z,q){let W=!0;while(W){W=!1;let U=new RegExp(`@${G}\\s*\\(`),B=J.match(U);if(!B||B.index===void 0)break;let _=B.index,j=J1(J,_+`@${G}`.length);if(!j)break;let H=j.endPos,F=M1(J,G,K,H);if(F===-1){console.warn(`[stx] @${G} directive at position ${_} has no matching @${K} \u2014 the block was skipped.`);break}let L=J.slice(H,F),O=j.expression,V=-1,w=0,A=0;while(A<L.length){let N=L.indexOf("@",A);if(N===-1)break;let R=L.substring(N);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,A=N+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,A=N+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=N;break}A=N+1}try{let N=z(O.trim()),R;if(V!==-1){let T=L.slice(0,V),M=L.slice(V+5);R=N?T:M}else R=N?L:"";J=J.substring(0,_)+R+J.substring(F+`@${K}`.length),W=!0}catch(N){let R=N instanceof Error?N.message:String(N),T=r(q,`Error processing @${G} directive: ${R}`,i.EVALUATION_ERROR);J=J.substring(0,_)+T+J.substring(F+`@${K}`.length);break}}return J}return X=Q(X,"isset","endisset",(J)=>{let G=X1(J,Z);return G!==void 0&&G!==null},"Isset"),X=Q(X,"empty","endempty",(J)=>{let G=X1(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"),X}function R7($,Z,Y){let X=$,Q="development";function J(G,K,z,q){let W=new RegExp(`@${K}(?![a-z])`,"g"),U=new RegExp(`@${z}(?![a-z])`,"g"),B=new RegExp(`^@${K}(?![a-z])`),_=new RegExp(`^@${z}(?![a-z])`),j=G,H=!0;while(H){H=!1,W.lastIndex=0;let F=W.exec(j);if(!F)break;let L=F.index,O=L+F[0].length;if(K==="env"){let D=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!D)break;O+=D[0].length,q=Q===D[2]}let V=1,w=O,A=-1;while(V>0&&w<j.length){W.lastIndex=w,U.lastIndex=w;let D=W.exec(j),C=U.exec(j),b=D?D.index:1/0,S=C?C.index:1/0;if(b<S)V++,w=b+D[0].length;else if(S<1/0){if(V--,V===0){A=S;break}w=S+C[0].length}else break}if(A===-1){console.warn(`[stx] @${K} directive at position ${L} has no matching @${z} \u2014 the block was skipped.`);break}let N=j.substring(O,A),R=-1,T=0,M=0;while(M<N.length){let D=N.indexOf("@",M);if(D===-1)break;let C=N.substring(D);if(B.test(C)){T++,M=D+1;continue}if(_.test(C)){T--,M=D+1;continue}if(T===0&&/^@else(?![a-z])/.test(C)){R=D;break}M=D+1}let I;if(R!==-1){let D=N.slice(0,R),C=N.slice(R+5);I=q?D:C}else I=q?N:"";let E=`@${z}`.length;j=j.substring(0,L)+I+j.substring(A+E),H=!0}return j}return X=J(X,"env","endenv",!1),X=J(X,"production","endproduction",Q==="production"),X=J(X,"development","enddevelopment",Q==="development"),X=J(X,"staging","endstaging",Q==="staging"),X=J(X,"testing","endtesting",Q==="testing"),X}var E$=k(()=>{D8();t0();D$();H0()});function C8($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function k$($,Z){if(!$)return Z?.nonceGenerator?.()??C8();let Y=y8.get($);if(!Y)Y=Z?.nonceGenerator?.()??C8(),y8.set($,Y);return Y}function XK($,Z){let Y=[];for(let[X,Q]of Object.entries($)){if(Q===void 0||Q===null)continue;if(typeof Q==="boolean"){if(Q)Y.push(X);continue}if(Array.isArray(Q)){let J=[...Q];if(Z&&(X==="script-src"||X==="style-src"))J=J.filter((G)=>!G.startsWith("'nonce-")),J.push(`'nonce-${Z}'`);if(J.length>0)Y.push(`${X} ${J.join(" ")}`)}}return Y.join("; ")}function P8($,Z){return`<meta http-equiv="Content-Security-Policy" content="${XK($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function v8($,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?k$(Y,Z):void 0,Q=P8(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
2459
2459
  ${Q}`)}function x8($,Z,Y,X){let Q=$,J=X.csp;if(Q=Q.replace(/@csp\b/g,()=>{if(!J?.enabled||!J.directives)return"<!-- CSP not configured -->";let G=J.useNonce?k$(Z,J):void 0;return P8(J.directives,G)}),Q=Q.replace(/@cspNonce\b/g,()=>{if(!J?.enabled||!J.useNonce)return"";return k$(Z,J)}),J?.enabled&&J.useNonce)Z.cspNonce=k$(Z,J);return Q}var y8;var f8=k(()=>{y8=new WeakMap});import JK from"crypto";function GK($=QK){let Z=JK.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return T7=Z,Z}function KK(){if(!T7)GK();return T7}function zK($=g8){let Z=KK();return`<input type="hidden" name="${$}" value="${Z}">`}function h8($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return zK(X||g8)})}var QK=40,g8="_token",T7=null;var d8=()=>{};async function u8($,Z,Y,X){if(!X.customDirectives||X.customDirectives.length===0)return $;let Q=$;for(let J of X.customDirectives){if(!J.name||typeof J.handler!=="function"){if(X.debug)console.warn("Invalid custom directive:",J);continue}if(J.hasEndTag)Q=await WK(Q,J,Z,Y,X);else Q=await qK(Q,J,Z,Y,X)}return Q}async function WK($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=`@${J}`,z=`@end${J}`,q=$,W=f1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${z}`,"g"),U=[],B=W.exec(q);while(B!==null){let[_,j="",H=""]=B,F=B.index||0;try{let L=j?m8(j):[],O=H.trim(),V=await G(O,L,Y,X);U.push({original:_,processed:V,startIndex:F})}catch(L){let O=L instanceof Error?L.message:String(L);if(Q.debug)console.error(`Error processing custom directive @${J}:`,L);U.push({original:_,processed:r("CustomDirective",`Error in @${J}${j?`(${j})`:""}: ${O}`,i.EVALUATION_ERROR),startIndex:F})}B=W.exec(q)}for(let _=U.length-1;_>=0;_--){let{original:j,processed:H}=U[_];q=q.replace(j,H)}return q}async function qK($,Z,Y,X,Q){let{name:J,handler:G}=Z,K=$,z=f1(`@${J}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),q=[],W=z.exec(K);while(W!==null){let[_,j=""]=W,H=W.index||0;try{let F=m8(j),L=await G("",F,Y,X);q.push({original:_,processed:L,startIndex:H})}catch(F){let L=F instanceof Error?F.message:String(F);if(Q.debug)console.error(`Error processing custom directive @${J}:`,F);q.push({original:_,processed:r("CustomDirective",`Error in @${J}(${j}): ${L}`,i.EVALUATION_ERROR),startIndex:H})}W=z.exec(K)}let U=f1(`@${J}(?!\\w)(?!\\s*\\()`,"g"),B=U.exec(K);while(B!==null){let[_]=B,j=B.index||0;try{let H=await G("",[],Y,X);q.push({original:_,processed:H,startIndex:j})}catch(H){let F=H instanceof Error?H.message:String(H);if(Q.debug)console.error(`Error processing custom directive @${J}:`,H);q.push({original:_,processed:r("CustomDirective",`Error in @${J}: ${F}`,i.EVALUATION_ERROR),startIndex:j})}B=U.exec(K)}for(let _=q.length-1;_>=0;_--){let{original:j,processed:H}=q[_];K=K.replace(j,H)}return K}function m8($){if(!$.trim())return[];let Z=[],Y="",X=!1,Q="";for(let J=0;J<$.length;J++){let G=$[J];if((G==='"'||G==="'")&&(J===0||$[J-1]!=="\\"))if(!X)X=!0,Q=G;else if(G===Q)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((J)=>{let G=J.trim();if(G.startsWith('"')&&G.endsWith('"')||G.startsWith("'")&&G.endsWith("'"))return G.substring(1,G.length-1);return G})}var p8=k(()=>{t0();g1()});import UK from"crypto";function F0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function b$($,Z,Y,X){let Q=$||Z;return Y?`${Q} ${X}`:Q}function BK(){return UK.randomUUID()}function S$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=BK();Z.csrf={token:X}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${F0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(X,Q)=>{let J=Q.toUpperCase();if(Q&&!["GET","POST"].includes(J))return`<input type="hidden" name="_method" value="${F0(J)}">`;return X}),Y}function i8($,Z,Y=l8){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(Q,J,G,K,z,q="")=>{let W=J||G||"POST",U=K||z||"",B=Q1(q),_=W.toUpperCase(),j=["GET","POST"].includes(_)?_:"POST",H=`<form method="${F0(j)}" action="${F0(U)}"${B?` ${B}`:""}>`;if(H+=`
2460
2460
  ${S$("@csrf",Z)}`,!["GET","POST"].includes(_))H+=`
2461
2461
  ${S$(`@method('${_}')`,Z)}`;return H}),X=X.replace(/@endform/g,"</form>"),X=X.replace(/@input\(\s*(?:'([^']+)'|"([^"]+)")\s*(?:,\s*(?:(?:'([^']*)'|"([^"]*)")\s*)?)?(?:,\s*\{([^}]+)\})?\s*\)/g,(Q,J,G,K,z,q="")=>{let W=J||G||"",U=K||z||"",B=Q1(q),_=F5(W,Z),j=_!==void 0&&_!==null?_:U||"",H=B.match(/type=['"]([^'"]+)['"]/i),F=H?H[1]:"text",L=V5(W,Z),O=B.match(/class=['"]([^'"]+)['"]/i),V=b$(O?O[1]:"",Y.input,L,Y.inputError),w=B.replace(/class=['"][^'"]+['"]/i,"");return w=w.replace(/type=['"][^'"]+['"]/i,""),`<input type="${F0(F)}" name="${F0(W)}" value="${F0(j)}" class="${V}"${w?` ${w}`:""}>`}),X=X.replace(/@textarea\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endtextarea/g,(Q,J,G="",K="")=>{let z=Q1(G),q=F5(J,Z)||K.trim(),W=V5(J,Z),U=z.match(/class=['"]([^'"]+)['"]/i),B=b$(U?U[1]:"",Y.input,W,Y.inputError),_=z.replace(/class=['"][^'"]+['"]/i,"");return`<textarea name="${F0(J)}" class="${B}"${_?` ${_}`:""}>${F0(q)}</textarea>`}),X=X.replace(/@select\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endselect/g,(Q,J,G="",K)=>{let z=Q1(G),q=F5(J,Z),W=V5(J,Z),U=z.match(/class=['"]([^'"]+)['"]/i),B=b$(U?U[1]:"",Y.input,W,Y.inputError),_=z.replace(/class=['"][^'"]+['"]/i,""),j=K;if(q!==void 0)j=K.replace(/(<option[^>]*value=['"]([^'"]+)['"][^>]*>)/gi,(H,F,L)=>{if((Array.isArray(q)?q.some((V)=>String(V)===L):String(q)===L)&&!F.includes("selected"))return F.replace(/(<option)/,"$1 selected");return H});return`<select name="${F0(J)}" class="${B}"${_?` ${_}`:""}>${j}</select>`}),X=X.replace(/@checkbox\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?(?:,\s*\{([^}]+)\})?\)/g,(Q,J,G="1",K="")=>{let z=Q1(K),q=F5(J,Z),W=q!==void 0&&(Array.isArray(q)?q.some((j)=>String(j)===G):q===!0||String(q)===G),U=z.match(/class=['"]([^'"]+)['"]/i),B=U?U[1]:Y.checkInput,_=z.replace(/class=['"][^'"]+['"]/i,"");return`<input type="checkbox" name="${F0(J)}" value="${F0(G)}" class="${B}"${W?" checked":""}${_?` ${_}`:""}>`}),X=X.replace(/@radio\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(Q,J,G,K="")=>{let z=Q1(K),q=F5(J,Z),W=q!==void 0&&q===G,U=z.match(/class=['"]([^'"]+)['"]/i),B=U?U[1]:Y.checkInput,_=z.replace(/class=['"][^'"]+['"]/i,"");return`<input type="radio" name="${F0(J)}" value="${F0(G)}" class="${B}"${W?" checked":""}${_?` ${_}`:""}>`}),X=X.replace(/@file\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)/g,(Q,J,G="")=>{let K=Q1(G),z=K.match(/accept=['"]([^'"]+)['"]/i),q=z?z[1]:"",W=K.includes("multiple"),U=V5(J,Z),B=K.match(/class=['"]([^'"]+)['"]/i),_=b$(B?B[1]:"",Y.input,U,Y.inputError),j=K.replace(/class=['"][^'"]+['"]/gi,"").replace(/accept=['"][^'"]+['"]/gi,"").replace(/\bmultiple\b/gi,"").trim(),H=[`<input type="file" name="${F0(J)}"`,`class="${_}"`];if(q)H.push(`accept="${F0(q)}"`);if(W)H.push("multiple");if(j)H.push(j);return`${H.join(" ")}>`}),X=X.replace(/@label\(\s*['"]([^'"]+)['"]\s*(?:,\s*\{([^}]+)\})?\)([\s\S]*?)@endlabel/g,(Q,J,G="",K)=>{let z=Q1(G),q=z.match(/class=['"]([^'"]+)['"]/i),W=q?q[1]:Y.label,U=z.replace(/class=['"][^'"]+['"]/i,"");return`<label for="${F0(J)}" class="${W}"${U?` ${U}`:""}>${K}</label>`}),X}function n8($,Z,Y=l8){return $.replace(/@error\(['"]([^'"]+)['"]\)([\s\S]*?)@enderror/g,(X,Q,J)=>{try{if(V5(Q,Z))return J.replace(/\{\{([^}]+)\}\}/g,(G,K)=>{try{if(K.trim()==="$message"||K.trim()==="message")return c8(Q,Z);if(K.trim().includes("errors.first")||K.trim().includes("$errors.first")){if(typeof Z.errors?.first==="function")return Z.errors.first(Q);return c8(Q,Z)}let z=K.trim();if(Z0(z)){let q=$0(z,Z);return q!==void 0?String(q):z}return z}catch{return K}});return""}catch(G){return console.error("Error processing @error directive:",G),X}})}function V5($,Z){if(!Z.errors)return!1;if(typeof Z.errors.has==="function")return Z.errors.has($);if(typeof Z.errors==="object")return Object.prototype.hasOwnProperty.call(Z.errors,$);return!1}function c8($,Z){if(!Z.errors)return"";if(typeof Z.errors.get==="function")return Z.errors.get($);if(typeof Z.errors==="object"&&Object.prototype.hasOwnProperty.call(Z.errors,$)){let Y=Z.errors[$];return Array.isArray(Y)?Y[0]:String(Y)}return""}function F5($,Z){let Y;if(Z.old&&typeof Z.old==="function")return Z.old($);if(Z.old&&typeof Z.old==="object")return Z.old[$];if($.endsWith("[]")){let X=$.slice(0,-2);if(Y=Z[X],Y!==void 0)return Y}return Z[$]}function Q1($){if(!$.trim())return"";let Z=[],Y=$.trim(),X=/([\w-]+)\s*:\s*(['"]?)([^,'"]*)\2(?:\s*,\s*|\s*$)/g,Q;while((Q=X.exec(Y))!==null){let[,J,,G]=Q;Z.push(`${J}="${G.trim()}"`)}return Z.join(" ")}var l8;var o8=k(()=>{H0();l8={input:"form-control",inputError:"is-invalid",checkInput:"form-check-input",label:"form-label",errorFeedback:"invalid-feedback"}});import D7 from"path";async function _K(){if(w5!==void 0)return w5;try{w5=(await import("@stacksjs/ts-i18n")).loadLocale??null}catch{w5=null}return w5}function jK($,Z=0){if(Z<=0)return!1;return Date.now()-$.loadedAt>Z}async function HK($,Z){if({...b7,...Z.i18n}.cache&&E7[$]){let Q=E7[$],J=Z.i18n?.cacheMaxAge??0;if(!jK(Q,J))return Q.translations}if(A5[$]?.state==="loading")return A5[$].promise;M7[$]="loading";let X=k7($,Z).then((Q)=>{return M7[$]="loaded",delete A5[$],Q}).catch((Q)=>{throw M7[$]="error",A5[$]={promise:X,state:"error",error:Q instanceof Error?Q:Error(String(Q))},Q});return A5[$]={promise:X,state:"loading"},X}async function k7($,Z){let Y={...b7,...Z.i18n},X=D7.isAbsolute(Y.translationsDir)?Y.translationsDir:D7.resolve(Z.root||process.cwd(),Y.translationsDir);try{let Q=await _K(),J=Q?await Q($,{translationsDir:X,defaultLocale:Y.defaultLocale,sources:wK(Y.format)}):await OK($,Y,X);if(J===void 0){if($!==Y.defaultLocale)return k7(Y.defaultLocale,Z);return{}}let G=J;if(Y.cache)E7[$]={translations:G,loadedAt:Date.now(),locale:$};return G}catch(Q){if(Z.debug)console.error(`Error loading translation file for locale "${$}":`,Q);if($!==Y.defaultLocale)return k7(Y.defaultLocale,Z);return{}}}async function OK($,Z,Y){let X=D7.join(Y,`${$}${LK(Z.format)}`);try{let Q=await import(X);return Q.default||Q}catch(Q){try{let J=await Bun.file(X).text();if(Z.format==="yaml"||Z.format==="yml")return FK(J);if(Z.format==="json")return JSON.parse(J);throw Q}catch{return}}}function LK($){switch($){case"yaml":return".yaml";case"yml":return".yml";case"js":return".js";case"ts":return".ts";case"json":default:return".json"}}function FK($){let Z={},Y=$.split(`
package/dist/pwa/index.js CHANGED
@@ -3769,7 +3769,7 @@ ${Y}
3769
3769
  </script>`}function Z2($,Z,Y){if($2=0,!_U($))return $;let X=QU($);if(X.length===0)return $;let J=zU($,X),Q=WU(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 zU($,Z){let Y=$;for(let X of Z){let Q=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*data-stx-scope="([^"]*)"[^>]*x-data\\s*=\\s*["']${Q4(X.stateExpr)}["']`,"gi").exec(Y);if(Q)X.id=Q[1],X.selector=`[data-stx-scope="${X.id}"]`;else{let K=new RegExp(`<[a-z][a-z0-9-]*\\s+[^>]*x-data\\s*=\\s*["']${Q4(X.stateExpr)}["'][^>]*data-stx-scope="([^"]*)"`,"gi").exec(Y);if(K)X.id=K[1],X.selector=`[data-stx-scope="${X.id}"]`;else Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*"${Q4(X.stateExpr)}")([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`),Y=Y.replace(new RegExp(`(<[a-z][a-z0-9-]*\\s+)([^>]*)(x-data\\s*=\\s*'${Q4(X.stateExpr)}')([^>]*>)`,"gi"),`$1data-stx-scope="${X.id}" $2$3$4`)}}return Y=Y.replace(/\s*x-data\s*=\s*"([^"]*)"/g,' data-stx-xdata="$1"'),Y=Y.replace(/\s*x-data\s*=\s*'([^']*)'/g," data-stx-xdata='$1'"),Y=Y.replace(/\s*x-init\s*=\s*"[^"]*"/g,""),Y=Y.replace(/\s*x-init\s*=\s*'[^']*'/g,""),Y}function _U($){return/x-data\s*=\s*["']/.test($)}var $2=0,JU=0;var Y2=C(()=>{r0()});import BU from"fs";import D3 from"path";import{createHighlighter as jU}from"ts-syntax-highlighter";async function HU($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await BU.promises.stat($)).mtime.getTime();if(Z.cache&&E3.has($)){let z=E3.get($);if(z.updatedAt>=X)return{content:z.content,data:z.data}}let J=await Bun.file($).text(),{data:Q,content:G}=K8(J),K=Z.markdown||L3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},U=y5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)U=await OU(U,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let W={content:U,data:Q||{}};if(Z.cache)E3.set($,{...W,updatedAt:X});return W}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 OU($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!G4)try{G4=await jU({theme:Z||"github-dark",cache:!0})}catch(K){return console.error("Failed to initialize ts-syntax-highlighter:",K),$}let J=async(K,q,U,W)=>{let z=W.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&#39;/g,"'"),_=U||(Y?"text":"");if(!_)return K;try{if(!G4.getSupportedLanguages().includes(_))return K;return(await G4.highlight(z,_,{theme:Z})).html}catch(B){console.error(`Error highlighting code block with language ${U}:`,B)}return K},Q=$,G=$.matchAll(X);for(let K of G){let[q,U,W,z]=K,_=await J(q,U,W,z);Q=Q.replace(q,_)}return Q}async function X2($,Z,Y="",X={}){return await LU($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,U)=>{try{let W=K;if(!D3.isAbsolute(K))W=D3.resolve(D3.dirname(Y),K);let z={};if(q)try{try{z=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 R=V.indexOf(":");if(R>0){let w=V.substring(0,R).trim(),A=V.substring(R+1).trim(),N=A.startsWith('"')&&A.endsWith('"'),T=A.startsWith("'")&&A.endsWith("'");if(N||T)A=A.substring(1,A.length-1);z[w]=A}}}}catch(F){if(X.debug)console.error("Error parsing context in @markdown-file directive:",F)}let{content:_,data:B}=await HU(W,X),j={...Z,...B,...z},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(W){let z=W instanceof Error?W.message:String(W);return Q0("Markdown File",`Error including markdown file: ${z}`,Y,$,U,G)}})}async function LU($,Z,Y){let X=[],J;while((J=Z.exec($))!==null){let K=J[0],q=J.index,U=J;X.push(Y(...U).then((W)=>({match:K,replacement:W,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 E3,G4=null;var J2=C(()=>{x5();V0();E3=new Map});function j1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var Q2=C(()=>{F0()});class K4{source;pos=0;line=1;column=0;tokens=[];constructor($){this.source=$}tokenize(){this.tokens=[],this.pos=0,this.line=1,this.column=0;while(this.pos<this.source.length){let $=this.nextToken();if($)this.tokens.push($)}return this.tokens.push({type:"EOF",value:"",start:this.pos,end:this.pos,line:this.line,column:this.column}),this.tokens}nextToken(){if(this.pos>=this.source.length)return null;let $=this.pos,Z=this.line,Y=this.column,X=this.source[this.pos];if(/\s/.test(X))return this.readWhitespace($,Z,Y);if(X==="/"&&this.peek(1)==="/")return this.readLineComment($,Z,Y);if(X==="/"&&this.peek(1)==="*")return this.readBlockComment($,Z,Y);if(X==='"'||X==="'")return this.readString(X,$,Z,Y);if(X==="`")return this.readTemplateString($,Z,Y);if(/\d/.test(X)||X==="."&&/\d/.test(this.peek(1)||""))return this.readNumber($,Z,Y);if(/[a-z_$]/i.test(X))return this.readIdentifier($,Z,Y);if(X==="{"){if(this.peek(1)==="{"&&this.peek(2)==="{")return this.advance(3),{type:"RAW_START",value:"{{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="{")return this.advance(2),{type:"EXPRESSION_START",value:"{{",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="!"&&this.peek(2)==="!")return this.advance(3),{type:"RAW_START",value:"{!!",start:$,end:this.pos,line:Z,column:Y}}if(X==="}"){if(this.peek(1)==="}"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"}}}",start:$,end:this.pos,line:Z,column:Y};if(this.peek(1)==="}")return this.advance(2),{type:"EXPRESSION_END",value:"}}",start:$,end:this.pos,line:Z,column:Y}}if(X==="!"&&this.peek(1)==="!"&&this.peek(2)==="}")return this.advance(3),{type:"RAW_END",value:"!!}",start:$,end:this.pos,line:Z,column:Y};if(X==="@"&&/[a-z]/i.test(this.peek(1)||""))return this.readDirective($,Z,Y);let J=["===","!==","==","!=","<=",">=","&&","||","??","++","--","+=","-=","*=","/=","%=","**","=>","?.","...","<<",">>",">>>","&=","|=","^="];for(let Q of J)if(this.source.slice(this.pos,this.pos+Q.length)===Q)return this.advance(Q.length),{type:"OPERATOR",value:Q,start:$,end:this.pos,line:Z,column:Y};if(/[+\-*/%<>=!&|^~?:]/.test(X))return this.advance(),{type:"OPERATOR",value:X,start:$,end:this.pos,line:Z,column:Y};if(/[()[\]{},;.]/.test(X))return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y};return this.advance(),{type:"PUNCTUATION",value:X,start:$,end:this.pos,line:Z,column:Y}}readWhitespace($,Z,Y){while(this.pos<this.source.length&&/\s/.test(this.source[this.pos]))this.advance();return{type:"WHITESPACE",value:this.source.slice($,this.pos),start:$,end:this.pos,line:Z,column:Y}}readLineComment($,Z,Y){this.advance(2);while(this.pos<this.source.length&&this.source[this.pos]!==`
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 U=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&U==="\\"){q=!0,Q++;continue}if(q=!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 G2($,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 k3($){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 H1($,Z){let Y=FU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function FU($,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($),U=K.exec($),W=q?q.index:1/0,z=U?U.index:1/0;if(W<z)J++,Q=W+q[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function K2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,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=[],U=0,W="if",z=J.expression,_=0,B=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)){B++,U++;continue}if(/^@endif(?![a-z])/.test(H)){B--,U+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:W,condition:z,content:K.substring(_,U),start:Q+_,end:Q+U});let F=U+L[0].length,O=H1(K,F);if(!O){U++;continue}W="elseif",z=O.expression,U=O.endPos,_=U;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:W,condition:z,content:K.substring(_,U),start:Q+_,end:Q+U}),W="else",z=void 0,U+=5,_=U;continue}}U++}return q.push({type:W,condition:z,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=K2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function q4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,q=K+Q[0].length-1,U=O0($,"(",")",q);if(U===-1){Q=J.exec($);continue}let W=$.slice(q+1,U),z=U+1,_=C1($,Z,Y,z);if(_===-1){Q=J.exec($);continue}let B=$.slice(z,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function b3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,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=[],U=0,W=null,z=0;while(U<K.length){let _=K.slice(U),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(z++,W)W.content+=B[0];U+=B[0].length;continue}if(j){if(z--,W)W.content+=j[0];U+=j[0].length;continue}if(z>0){if(W)W.content+=K[U];U++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(W)q.push(W);let O=U+H[0].length,V=H1(K,O);if(!V){U++;continue}W={type:"case",value:V.expression,content:""},U=V.endPos}else if(L&&_.startsWith("@default")){if(W)q.push(W);W={type:"default",content:""},U+=L[0].length}else if(F&&_.startsWith("@break"))U+=F[0].length;else{if(W)W.content+=K[U];U++}}if(W)q.push(W);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var q2=()=>{};function VU($){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==="{{{"?"}}}":"!!}":"}}",U=G+K.length,W=wU($,U,q);if(W===-1){Y=G+1;continue}let z=$.slice(U,W).trim(),_=W+q.length;Z.push({fullMatch:$.slice(G,_),expression:z,start:G,end:_,isRaw:Q}),Y=_}return Z}function wU($,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 RU($){let Z=k3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=AU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function AU($){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=z2(G);return{name:X,args:K}}function z2($){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 NU($,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 TU($){let Z=[],X=new K4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let q=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,_=U2(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:W,value:$.slice(z,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let W=U.start,z=U.value==="{"?"}":"]",_=O0($,U.value,z,W);if(_!==-1){let B=$.slice(W,_+1);if(J=W2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=U2(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 U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let _=O0($,"{","}",z);if(_!==-1)Z.push({type:"function",name:W,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=W2(X,_+1)}}}else J++}return Z}function U2($,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 W2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var _2=()=>{};var U4=C(()=>{q2();_2()});function MU($,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=b3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let U="",W=!1;for(let z of K.cases)if(z.type==="default"){if(!W)U=z.content.trim()}else try{let _;if(z.value&&$0(z.value))_=Z0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)_=e(z.value,Z);if(q===_){U=z.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(q){let U=q instanceof Error?q.message:String(q),W=r("Switch",`Error evaluating @switch expression: ${U}`,l.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function v1($,Z,Y){let X=$;X=MU(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=H1(X,K+7);if(!q)break;let U=q.endPos,W=C1(X,"unless","endunless",U);if(W===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,W),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],R;while((R=L.exec(z))!==null)V.push({pos:R.index,type:"open"});while((R=F.exec(z))!==null)V.push({pos:R.index,type:"close"});while((R=O.exec(z))!==null)V.push({pos:R.index,type:"else"});V.sort((w,A)=>w.pos-A.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=z.slice(0,B),L=z.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${z}@endif`;X=X.substring(0,K)+j+X.substring(W+10),Q=!0}}X=y3(X,Z,Y),X=P3(X,Z,Y),X=S3(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="",U=!1;for(let W of K.branches){if(U)break;if(W.type==="else")q=W.content,U=!0;else try{let z;if(W.condition&&$0(W.condition))z=Z0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)z=e(W.condition,Z);if(z)q=W.content,U=!0}catch(z){q=r(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${z instanceof Error?z.message:String(z)}`,l.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let U=q instanceof Error?q.message:String(q),W=r("If",`Error processing @if block: ${U}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(J());return X}function B2($){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 S3($,Z){let Y=$;function X(K,q,U,W){let z=1,_=W,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(_<K.length&&z>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)z++,_=F+H[0].length;else if(O<1/0){if(z--,z===0)return O;_=O+L[0].length}else break}return-1}function J(K,q,U){let W=0,z=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${U}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=z.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")W++;else if(L.type==="close")W--;else if(L.type==="else"&&W===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 U=q.index,W,z,_=Y.slice(U+5),B=B2(_);if(B)W=B.value,z=U+5+B.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=W?j1(`auth?.check && auth?.user?.[${W}]`,Z):j1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),R=H.slice(L+5);O=F?V:R}else O=F?H:"";Y=Y.substring(0,U)+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 U=q.index,W,z,_=Y.slice(U+6),B=B2(_);if(B)W=B.value,z=U+6+B.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=W?j1(`!auth?.check || !auth?.user?.[${W}]`,Z):j1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),R=H.slice(L+5);O=F?V:R}else O=F?H:"";Y=Y.substring(0,U)+O+Y.substring(j+9),K=!0}}function Q(K,q,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(q)W.push(q);if(U){let z=j1(U,Z);W.push(z)}return Z.permissions.check(...W)}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}`,U=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let _=z.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,R=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${U}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=R.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=A.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((S,y)=>S.pos-y.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let y=O[S];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${U}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${U}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+1],o=m?m.pos:F.length;I.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=y.pos+5}if(E<F.length){let S=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,b="";if(k)b=I[0]?.content||"";else{let S=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),W=!0}}return Y}function y3($,Z,Y){let X=$;function J(Q,G,K,q,U){let W=!0;while(W){W=!1;let z=new RegExp(`@${G}\\s*\\(`),_=Q.match(z);if(!_||_.index===void 0)break;let B=_.index,j=H1(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,R=0,w=0;while(w<F.length){let A=F.indexOf("@",w);if(A===-1)break;let N=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){R++,w=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){R--,w=A+1;continue}if(R===0&&/^@else(?![a-z])/.test(N)){V=A;break}w=A+1}try{let A=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=A?T:M}else N=A?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),W=!0}catch(A){let N=A instanceof Error?A.message:String(A),T=r(U,`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=j1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=j1(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 P3($,Z,Y){let X=$,J="development";function Q(G,K,q,U){let W=new RegExp(`@${K}(?![a-z])`,"g"),z=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,W.lastIndex=0;let L=W.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,U=J===D[2]}let V=1,R=O,w=-1;while(V>0&&R<j.length){W.lastIndex=R,z.lastIndex=R;let D=W.exec(j),k=z.exec(j),b=D?D.index:1/0,S=k?k.index:1/0;if(b<S)V++,R=b+D[0].length;else if(S<1/0){if(V--,V===0){w=S;break}R=S+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 A=j.substring(O,w),N=-1,T=0,M=0;while(M<A.length){let D=A.indexOf("@",M);if(D===-1)break;let k=A.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=A.slice(0,N),k=A.slice(N+5);I=U?D:k}else I=U?A:"";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 W4=C(()=>{Q2();J1();U4();F0()});function j2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function x1($,Z){if(!$)return Z?.nonceGenerator?.()??j2();let Y=C3.get($);if(!Y)Y=Z?.nonceGenerator?.()??j2(),C3.set($,Y);return Y}function Fw($){C3.delete($)}function H2($,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 x3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${H2($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Vw($){return{enabled:!0,directives:{strict:IU,moderate:v3,relaxed:DU,api:EU}[$]||v3,useNonce:$==="strict",addMetaTag:!0}}function ww($,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 O2($,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?x1(Y,Z):void 0,J=x3(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 U=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&U==="\\"){q=!0,Q++;continue}if(q=!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 G2($,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 k3($){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 H1($,Z){let Y=FU($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function FU($,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($),U=K.exec($),W=q?q.index:1/0,z=U?U.index:1/0;if(W<z)J++,Q=W+q[0].length;else if(z<1/0){if(J--,J===0)return z;Q=z+U[0].length}else break}return-1}function K2($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,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=[],U=0,W="if",z=J.expression,_=0,B=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)){B++,U++;continue}if(/^@endif(?![a-z])/.test(H)){B--,U+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:W,condition:z,content:K.substring(_,U),start:Q+_,end:Q+U});let F=U+L[0].length,O=H1(K,F);if(!O){U++;continue}W="elseif",z=O.expression,U=O.endPos,_=U;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:W,condition:z,content:K.substring(_,U),start:Q+_,end:Q+U}),W="else",z=void 0,U+=5,_=U;continue}}U++}return q.push({type:W,condition:z,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=K2($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function q4($,Z,Y){let X=[],J=new RegExp(`@${Z}\\s*\\(`,"g"),Q=J.exec($);while(Q!==null){if(X.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=J.exec($);continue}let K=Q.index,q=K+Q[0].length-1,U=O0($,"(",")",q);if(U===-1){Q=J.exec($);continue}let W=$.slice(q+1,U),z=U+1,_=C1($,Z,Y,z);if(_===-1){Q=J.exec($);continue}let B=$.slice(z,_),j=_+`@${Y}`.length;X.push({fullMatch:$.slice(K,j),name:Z,params:W,content:B,start:K,end:j}),J.lastIndex=j,Q=J.exec($)}return X}function b3($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let X=Z+Y[0].length,J=H1($,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=[],U=0,W=null,z=0;while(U<K.length){let _=K.slice(U),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(z++,W)W.content+=B[0];U+=B[0].length;continue}if(j){if(z--,W)W.content+=j[0];U+=j[0].length;continue}if(z>0){if(W)W.content+=K[U];U++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(W)q.push(W);let O=U+H[0].length,V=H1(K,O);if(!V){U++;continue}W={type:"case",value:V.expression,content:""},U=V.endPos}else if(L&&_.startsWith("@default")){if(W)q.push(W);W={type:"default",content:""},U+=L[0].length}else if(F&&_.startsWith("@break"))U+=F[0].length;else{if(W)W.content+=K[U];U++}}if(W)q.push(W);return{fullMatch:$.slice(Z,G+10),expression:J.expression,cases:q,start:Z,end:G+10}}var q2=()=>{};function VU($){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==="{{{"?"}}}":"!!}":"}}",U=G+K.length,W=wU($,U,q);if(W===-1){Y=G+1;continue}let z=$.slice(U,W).trim(),_=W+q.length;Z.push({fullMatch:$.slice(G,_),expression:z,start:G,end:_,isRaw:Q}),Y=_}return Z}function wU($,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 RU($){let Z=k3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=AU(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function AU($){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=z2(G);return{name:X,args:K}}function z2($){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 NU($,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 TU($){let Z=[],X=new K4($).tokenize().filter((Q)=>Q.type!=="WHITESPACE"&&Q.type!=="COMMENT"),J=0;while(J<X.length){let Q=X[J],G=!1;if(Q.type==="IDENTIFIER"&&Q.value==="export"){if(G=!0,J++,J>=X.length)break}let K=X[J];if(K.type==="IDENTIFIER"&&(K.value==="const"||K.value==="let"||K.value==="var")){let q=K.value;if(J++,J>=X.length)break;let U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;if(J++,J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let z=J<X.length?X[J].start:$.length,_=U2(X,J,$);J=_.nextIndex,Z.push({type:"variable",name:W,value:$.slice(z,_.endPos),exported:G,start:K.start,end:_.endPos})}}else if(U.type==="PUNCTUATION"&&(U.value==="{"||U.value==="[")){let W=U.start,z=U.value==="{"?"}":"]",_=O0($,U.value,z,W);if(_!==-1){let B=$.slice(W,_+1);if(J=W2(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=U2(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 U=X[J];if(U.type==="IDENTIFIER"){let W=U.value;J++;let z=-1;while(J<X.length){if(X[J].type==="PUNCTUATION"&&X[J].value==="{"){z=X[J].start;break}J++}if(z!==-1){let _=O0($,"{","}",z);if(_!==-1)Z.push({type:"function",name:W,value:$.slice(q,_+1).replace(/^export\s+/,""),exported:G,start:q,end:_+1}),J=W2(X,_+1)}}}else J++}return Z}function U2($,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 W2($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var _2=()=>{};var U4=C(()=>{q2();_2()});function MU($,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=b3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let U="",W=!1;for(let z of K.cases)if(z.type==="default"){if(!W)U=z.content.trim()}else try{let _;if(z.value&&$0(z.value))_=Z0(z.value,Object.keys(Z))(...Object.values(Z));else if(z.value)_=e(z.value,Z);if(q===_){U=z.content.trim(),W=!0;break}}catch{continue}X=X.substring(0,G)+U+X.substring(K.end),J=!0}catch(q){let U=q instanceof Error?q.message:String(q),W=r("Switch",`Error evaluating @switch expression: ${U}`,l.EVALUATION_ERROR);X=X.substring(0,G)+W+X.substring(K.end);break}}return X}function v1($,Z,Y){let X=$;X=MU(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=H1(X,K+7);if(!q)break;let U=q.endPos,W=C1(X,"unless","endunless",U);if(W===-1){console.warn(`[stx] @unless directive at position ${K} has no matching @endunless \u2014 the block was skipped. Check for typos or missing closers.`);break}let z=X.slice(U,W),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],R;while((R=L.exec(z))!==null)V.push({pos:R.index,type:"open"});while((R=F.exec(z))!==null)V.push({pos:R.index,type:"close"});while((R=O.exec(z))!==null)V.push({pos:R.index,type:"else"});V.sort((w,A)=>w.pos-A.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=z.slice(0,B),L=z.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${z}@endif`;X=X.substring(0,K)+j+X.substring(W+10),Q=!0}}X=y3(X,Z,Y),X=P3(X,Z,Y),X=S3(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="",U=!1;for(let W of K.branches){if(U)break;if(W.type==="else")q=W.content,U=!0;else try{let z;if(W.condition&&$0(W.condition))z=Z0(W.condition,Object.keys(Z))(...Object.values(Z));else if(W.condition)z=e(W.condition,Z);if(z)q=W.content,U=!0}catch(z){q=r(W.type==="if"?"If":"Elseif",`Error in @${W.type}(${W.condition}): ${z instanceof Error?z.message:String(z)}`,l.EVALUATION_ERROR),U=!0}}X=X.substring(0,K.start)+q+X.substring(K.end)}catch(q){let U=q instanceof Error?q.message:String(q),W=r("If",`Error processing @if block: ${U}`,l.EVALUATION_ERROR);X=X.substring(0,K.start)+W+X.substring(K.end)}}return!0};while(!0){let Q=X;if(!J())break;if(X===Q)break}return X}function B2($){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 S3($,Z){let Y=$;function X(K,q,U,W){let z=1,_=W,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${U}(?![a-z])`,"g");while(_<K.length&&z>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)z++,_=F+H[0].length;else if(O<1/0){if(z--,z===0)return O;_=O+L[0].length}else break}return-1}function J(K,q,U){let W=0,z=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${U}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=z.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")W++;else if(L.type==="close")W--;else if(L.type==="else"&&W===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 U=q.index,W,z,_=Y.slice(U+5),B=B2(_);if(B)W=B.value,z=U+5+B.consumed;else z=U+5;let j=X(Y,"auth","endauth",z);if(j===-1){console.warn(`[stx] @auth directive at position ${U} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(z,j),L=J(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=W?j1(`auth?.check && auth?.user?.[${W}]`,Z):j1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),R=H.slice(L+5);O=F?V:R}else O=F?H:"";Y=Y.substring(0,U)+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 U=q.index,W,z,_=Y.slice(U+6),B=B2(_);if(B)W=B.value,z=U+6+B.consumed;else z=U+6;let j=X(Y,"guest","endguest",z);if(j===-1){console.warn(`[stx] @guest directive at position ${U} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(z,j),L=J(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=W?j1(`!auth?.check || !auth?.user?.[${W}]`,Z):j1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),R=H.slice(L+5);O=F?V:R}else O=F?H:"";Y=Y.substring(0,U)+O+Y.substring(j+9),K=!0}}function Q(K,q,U){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let W=[K];if(q)W.push(q);if(U){let z=j1(U,Z);W.push(z)}return Z.permissions.check(...W)}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}`,U=K==="can"?"elsecan":"elsecannot",W=!0;while(W){W=!1;let z=Y.match(new RegExp(`@${K}\\s*\\(`));if(!z||z.index===void 0)break;let _=z.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,R=new RegExp(`@${K}\\s*\\(`,"g"),w=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${U}\\s*\\(`,"g"),N=/@else(?![a-z])/g,T=[],M;while((M=R.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=A.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((S,y)=>S.pos-y.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let y=O[S];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${U}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${U}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+1],o=m?m.pos:F.length;I.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=y.pos+5}if(E<F.length){let S=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,b="";if(k)b=I[0]?.content||"";else{let S=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),W=!0}}return Y}function y3($,Z,Y){let X=$;function J(Q,G,K,q,U){let W=!0;while(W){W=!1;let z=new RegExp(`@${G}\\s*\\(`),_=Q.match(z);if(!_||_.index===void 0)break;let B=_.index,j=H1(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,R=0,w=0;while(w<F.length){let A=F.indexOf("@",w);if(A===-1)break;let N=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(N)){R++,w=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(N)){R--,w=A+1;continue}if(R===0&&/^@else(?![a-z])/.test(N)){V=A;break}w=A+1}try{let A=q(O.trim()),N;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);N=A?T:M}else N=A?F:"";Q=Q.substring(0,B)+N+Q.substring(L+`@${K}`.length),W=!0}catch(A){let N=A instanceof Error?A.message:String(A),T=r(U,`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=j1(Q,Z);return G!==void 0&&G!==null},"Isset"),X=J(X,"empty","endempty",(Q)=>{let G=j1(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 P3($,Z,Y){let X=$,J="development";function Q(G,K,q,U){let W=new RegExp(`@${K}(?![a-z])`,"g"),z=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,W.lastIndex=0;let L=W.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,U=J===D[2]}let V=1,R=O,w=-1;while(V>0&&R<j.length){W.lastIndex=R,z.lastIndex=R;let D=W.exec(j),k=z.exec(j),b=D?D.index:1/0,S=k?k.index:1/0;if(b<S)V++,R=b+D[0].length;else if(S<1/0){if(V--,V===0){w=S;break}R=S+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 A=j.substring(O,w),N=-1,T=0,M=0;while(M<A.length){let D=A.indexOf("@",M);if(D===-1)break;let k=A.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=A.slice(0,N),k=A.slice(N+5);I=U?D:k}else I=U?A:"";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 W4=C(()=>{Q2();J1();U4();F0()});function j2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function x1($,Z){if(!$)return Z?.nonceGenerator?.()??j2();let Y=C3.get($);if(!Y)Y=Z?.nonceGenerator?.()??j2(),C3.set($,Y);return Y}function Fw($){C3.delete($)}function H2($,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 x3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${H2($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function Vw($){return{enabled:!0,directives:{strict:IU,moderate:v3,relaxed:DU,api:EU}[$]||v3,useNonce:$==="strict",addMetaTag:!0}}function ww($,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 O2($,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?x1(Y,Z):void 0,J=x3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3773
3773
  ${J}`)}function Rw($,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 L2($,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?x1(Z,Q):void 0;return x3(Q.directives,G)}),J=J.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return x1(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=x1(Z,Q);return J}function Aw(){return[kU,bU]}function Nw($){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 SU($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Tw($,Z){if(!$.enabled)return{};let Y=$.useNonce?x1(Z,$):void 0,X=H2($.directives,Y);return{[SU($.reportOnly)]:X}}var C3,IU,v3,DU,EU,kU,bU,Mw;var F2=C(()=>{C3=new WeakMap;IU={"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},v3={"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},DU={"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'"]},EU={"default-src":["'none'"],"frame-ancestors":["'none'"]};kU={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?x1(Y,Q):void 0;return x3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},bU={name:"cspNonce",handler:($,Z,Y,X)=>{let Q=Y.__stx_options?.csp;if(!Q?.enabled||!Q.useNonce)return"";return x1(Y,Q)},hasEndTag:!1,description:"Output the current CSP nonce value"};Mw={enabled:!1,reportOnly:!1,directives:v3,useNonce:!1,addMetaTag:!0}});import{Buffer as V2}from"buffer";import w2 from"crypto";function PU($=yU){let Z=w2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return W5=Z,Z}function CU(){if(!W5)PU();return W5}function kw(){W5=null}function bw($){W5=$}function vU($=R2){let Z=CU();return`<input type="hidden" name="${$}" value="${Z}">`}function A2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return vU(X||R2)})}function Sw($,Z){let Y=Z??W5;if(!Y)return!1;let X=V2.from($),J=V2.from(Y);if(X.length!==J.length)return!1;return w2.timingSafeEqual(X,J)}var yU=40,R2="_token",W5=null;var N2=()=>{};async function T2($,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 xU(J,Q,Z,Y,X);else J=await fU(J,Q,Z,Y,X)}return J}async function xU($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,U=$,W=D1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),z=[],_=W.exec(U);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?M2(j):[],O=H.trim(),V=await G(O,F,Y,X);z.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);z.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,l.EVALUATION_ERROR),startIndex:L})}_=W.exec(U)}for(let B=z.length-1;B>=0;B--){let{original:j,processed:H}=z[B];U=U.replace(j,H)}return U}async function fU($,Z,Y,X,J){let{name:Q,handler:G}=Z,K=$,q=D1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),U=[],W=q.exec(K);while(W!==null){let[B,j=""]=W,H=W.index||0;try{let L=M2(j),F=await G("",L,Y,X);U.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);U.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,l.EVALUATION_ERROR),startIndex:H})}W=q.exec(K)}let z=D1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=z.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,X);U.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);U.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,l.EVALUATION_ERROR),startIndex:j})}_=z.exec(K)}for(let B=U.length-1;B>=0;B--){let{original:j,processed:H}=U[B];K=K.replace(j,H)}return K}function M2($){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 I2=C(()=>{J1();e1()});var f3={};i(f3,{useTitle:()=>lU,useSeoMeta:()=>_4,usePageTitle:()=>lU,useHead:()=>g1,resetHead:()=>dU,renderHtmlAttrs:()=>cU,renderHead:()=>pU,renderBodyAttrs:()=>iU,processTitleDirective:()=>sU,processMetaDirective:()=>rU,processHeadDirective:()=>oU,getPageMeta:()=>hU,getHead:()=>h5,definePageMeta:()=>uU,applyHead:()=>nU});function h5(){return O1}function hU(){return z4}function dU(){O1={},gU.length=0,z4={}}function g1($){O1=mU(O1,$)}function mU($,Z){return{title:Z.title??$.title,titleTemplate:Z.titleTemplate??$.titleTemplate,base:Z.base??$.base,meta:[...$.meta||[],...Z.meta||[]],link:[...$.link||[],...Z.link||[]],script:[...$.script||[],...Z.script||[]],style:[...$.style||[],...Z.style||[]],htmlAttrs:{...$.htmlAttrs,...Z.htmlAttrs},bodyAttrs:{...$.bodyAttrs,...Z.bodyAttrs}}}function _4($){let Z=[];if($.description)Z.push({name:"description",content:$.description});if($.keywords){let q=Array.isArray($.keywords)?$.keywords.join(", "):$.keywords;Z.push({name:"keywords",content:q})}if($.author)Z.push({name:"author",content:$.author});if($.robots)Z.push({name:"robots",content:$.robots});let Y=$.ogTitle??$.title,X=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(X)Z.push({property:"og:description",content:X});if($.ogImage)Z.push({property:"og:image",content:$.ogImage});if($.ogUrl)Z.push({property:"og:url",content:$.ogUrl});if($.ogType)Z.push({property:"og:type",content:$.ogType});if($.ogSiteName)Z.push({property:"og:site_name",content:$.ogSiteName});if($.ogLocale)Z.push({property:"og:locale",content:$.ogLocale});let J=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(J)Z.push({name:"twitter:title",content:J});if(Q)Z.push({name:"twitter:description",content:Q});if(G)Z.push({name:"twitter:image",content:G});if($.twitterSite)Z.push({name:"twitter:site",content:$.twitterSite});if($.twitterCreator)Z.push({name:"twitter:creator",content:$.twitterCreator});if($.articleAuthor)Z.push({property:"article:author",content:$.articleAuthor});if($.articlePublishedTime)Z.push({property:"article:published_time",content:$.articlePublishedTime});if($.articleModifiedTime)Z.push({property:"article:modified_time",content:$.articleModifiedTime});if($.articleSection)Z.push({property:"article:section",content:$.articleSection});if($.articleTags)for(let q of $.articleTags)Z.push({property:"article:tag",content:q});let K=[];if($.canonical)K.push({rel:"canonical",href:$.canonical});g1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function uU($){if(z4={...z4,...$},$.title||$.description)_4({title:$.title,description:$.description})}function lU($){let Z=typeof $==="function"?$():$;g1({title:Z})}function pU($=O1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${f1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([X,J])=>`${X}="${f1(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}="${f1(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}="${f1(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}="${f1(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 cU($=O1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${f1(Y)}"`).join(" ")}function iU($=O1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${f1(Y)}"`).join(" ")}function f1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function nU($=O1){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 oU($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
3775
3775
  `,""}),headContent:Z.trim()}}function sU($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,X,J,Q)=>{let G=X?J:Z[(Q||"").trim()]??Q;return g1({title:G}),""})}function rU($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,X,J,Q,G,K)=>{let q=Q?G:K,U=Q?q:Z[(q||"").trim()]??q,z=J.includes(":")?{property:J,content:U}:{name:J,content:U};return g1({meta:[z]}),""})}var O1,gU,z4;var d5=C(()=>{O1={},gU=[],z4={}});import aU from"crypto";function w0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function tU($){return{...g3,...$.forms?.classes}}function B4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function eU(){return aU.randomUUID()}function gw($,Z,Y,X){let J=tU(X),Q=$;return Q=ZW(Q,Z),Q=l5(Q,Z),Q=h3(Q,Z,J),Q=d3(Q,Z,J),Q}function l5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=eU();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 h3($,Z,Y=g3){let X=$;return X=X.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(J,Q,G,K,q,U="")=>{let W=Q||G||"POST",z=K||q||"",_=L1(U),B=W.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${w0(j)}" action="${w0(z)}"${_?` ${_}`:""}>`;if(H+=`
@@ -3769,7 +3769,7 @@ ${Y}
3769
3769
  </script>`}function uZ($,Z,Y){if(mZ=0,!aq($))return $;let X=pq($);if(X.length===0)return $;let J=rq($,X),Q=sq(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 rq($,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*["']${$4(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*["']${$4(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*"${$4(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*'${$4(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 aq($){return/x-data\s*=\s*["']/.test($)}var mZ=0,lq=0;var lZ=C(()=>{r0()});import tq from"fs";import w3 from"path";import{createHighlighter as eq}from"ts-syntax-highlighter";async function $z($,Z={}){try{if(!await c($))throw Error(`Markdown file not found: ${$}`);let X=(await tq.promises.stat($)).mtime.getTime();if(Z.cache&&A3.has($)){let W=A3.get($);if(W.updatedAt>=X)return{content:W.content,data:W.data}}let J=await Bun.file($).text(),{data:Q,content:G}=n9(J),K=Z.markdown||U3.markdown||{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0}},z=k5(G,{gfm:!0});if(K.syntaxHighlighting?.enabled&&K.syntaxHighlighting?.serverSide)z=await Zz(z,K.syntaxHighlighting?.defaultTheme||"github-dark",K.syntaxHighlighting?.highlightUnknownLanguages||!1);let U={content:z,data:Q||{}};if(Z.cache)A3.set($,{...U,updatedAt:X});return U}catch(Y){if(Z.debug)console.error(`Error reading/parsing markdown file ${$}:`,Y);let X=Y instanceof Error?Y.message:String(Y);return{content:J0("Markdown File",`Error reading/parsing markdown file: ${X}`,$,"",0,""),data:{}}}}async function Zz($,Z,Y){let X=/<pre><code( class="language-([^"]+)")?>([^<]+)<\/code><\/pre>/g;if(!Z4)try{Z4=await eq({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(!Z4.getSupportedLanguages().includes(_))return K;return(await Z4.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 pZ($,Z,Y="",X={}){return await Yz($,/@markdown-file\(\s*['"]([^'"]+)['"]\s*(?:,\s*(\{[^}]*\}))?\)/g,async(G,K,q,z)=>{try{let U=K;if(!w3.isAbsolute(K))U=w3.resolve(w3.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 $z(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 J0("Markdown File",`Error including markdown file: ${W}`,Y,$,z,G)}})}async function Yz($,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 A3,Z4=null;var cZ=C(()=>{P5();V0();A3=new Map});function B1($,Z){try{let Y=$.trim();if($0(Y))return Z0(Y,Object.keys(Z))(...Object.values(Z));else return e(Y,Z)}catch{return!1}}var iZ=C(()=>{F0()});class Y4{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 nZ($,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 R3($){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=Xz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Xz($,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 P1($,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 oZ($,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=P1($,"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 v5($){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=oZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X4($,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,_=P1($,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 N3($,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=P1($,"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 sZ=()=>{};function Jz($){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=Qz($,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 Qz($,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 Gz($){let Z=R3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Kz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Kz($){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=tZ(G);return{name:X,args:K}}function tZ($){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 qz($,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 zz($){let Z=[],X=new Y4($).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,_=rZ(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=aZ(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=rZ(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=aZ(X,_+1)}}}else J++}return Z}function rZ($,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 aZ($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var eZ=()=>{};var J4=C(()=>{sZ();eZ()});function Uz($,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=N3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function C1($,Z,Y){let X=$;X=Uz(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=P1(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=M3(X,Z,Y),X=I3(X,Z,Y),X=T3(X,Z);let J=()=>{let Q=v5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,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=r("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 $2($){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 T3($,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=$2(_);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=$2(_);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((S,y)=>S.pos-y.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let y=O[S];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+1],o=m?m.pos:F.length;I.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=y.pos+5}if(E<F.length){let S=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,b="";if(k)b=I[0]?.content||"";else{let S=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),U=!0}}return Y}function M3($,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=P1(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=r(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 I3($,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),b=D?D.index:1/0,S=k?k.index:1/0;if(b<S)V++,A=b+D[0].length;else if(S<1/0){if(V--,V===0){w=S;break}A=S+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=C(()=>{iZ();J1();J4();F0()});function Z2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function v1($,Z){if(!$)return Z?.nonceGenerator?.()??Z2();let Y=D3.get($);if(!Y)Y=Z?.nonceGenerator?.()??Z2(),D3.set($,Y);return Y}function aV($){D3.delete($)}function Y2($,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 k3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${Y2($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function tV($){return{enabled:!0,directives:{strict:Wz,moderate:E3,relaxed:_z,api:Bz}[$]||E3,useNonce:$==="strict",addMetaTag:!0}}function eV($,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 X2($,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=k3(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 nZ($,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 R3($){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=Xz($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function Xz($,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 P1($,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 oZ($,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=P1($,"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 v5($){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=oZ($,X.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;X=Y.exec($)}return Z}function X4($,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,_=P1($,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 N3($,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=P1($,"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 sZ=()=>{};function Jz($){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=Qz($,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 Qz($,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 Gz($){let Z=R3($);if(Z.length===0)return{baseExpression:"",filters:[]};let Y=Z[0],X=[];for(let J=1;J<Z.length;J++){let Q=Kz(Z[J]);if(Q)X.push(Q)}return{baseExpression:Y,filters:X}}function Kz($){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=tZ(G);return{name:X,args:K}}function tZ($){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 qz($,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 zz($){let Z=[],X=new Y4($).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,_=rZ(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=aZ(X,_+1),J<X.length&&X[J].type==="OPERATOR"&&X[J].value==="="){J++;let j=J<X.length?X[J].start:$.length,H=rZ(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=aZ(X,_+1)}}}else J++}return Z}function rZ($,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 aZ($,Z){for(let Y=0;Y<$.length;Y++)if($[Y].start>=Z)return Y;return $.length}var eZ=()=>{};var J4=C(()=>{sZ();eZ()});function Uz($,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=N3(X,G);if(!K)break;try{let q;if($0(K.expression))q=Z0(K.expression,Object.keys(Z))(...Object.values(Z));else q=e(K.expression,Z);let z="",U=!1;for(let W of K.cases)if(W.type==="default"){if(!U)z=W.content.trim()}else try{let _;if(W.value&&$0(W.value))_=Z0(W.value,Object.keys(Z))(...Object.values(Z));else if(W.value)_=e(W.value,Z);if(q===_){z=W.content.trim(),U=!0;break}}catch{continue}X=X.substring(0,G)+z+X.substring(K.end),J=!0}catch(q){let z=q instanceof Error?q.message:String(q),U=r("Switch",`Error evaluating @switch expression: ${z}`,l.EVALUATION_ERROR);X=X.substring(0,G)+U+X.substring(K.end);break}}return X}function C1($,Z,Y){let X=$;X=Uz(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=P1(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=M3(X,Z,Y),X=I3(X,Z,Y),X=T3(X,Z);let J=()=>{let Q=v5(X);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",z=!1;for(let U of K.branches){if(z)break;if(U.type==="else")q=U.content,z=!0;else try{let W;if(U.condition&&$0(U.condition))W=Z0(U.condition,Object.keys(Z))(...Object.values(Z));else if(U.condition)W=e(U.condition,Z);if(W)q=U.content,z=!0}catch(W){q=r(U.type==="if"?"If":"Elseif",`Error in @${U.type}(${U.condition}): ${W instanceof Error?W.message:String(W)}`,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=r("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 $2($){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 T3($,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=$2(_);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=$2(_);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((S,y)=>S.pos-y.pos);for(let S of T){if(S.type==="open"){V++;continue}if(S.type==="close"){V--;continue}if(V===0)O.push(S)}let I=[],E=0;for(let S=0;S<O.length;S++){let y=O[S];if(I.push({content:F.slice(E,y.pos),ability:void 0}),y.type==="elseDirective"){let d=F.slice(y.pos+`@${z}`.length),f=G(d);if(f){I[I.length-1]={content:F.slice(E,y.pos)},E=y.pos+`@${z}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[S+1],o=m?m.pos:F.length;I.push({content:F.slice(E,o),ability:f.ability,type:f.type,id:f.id}),E=o}}else E=y.pos+5}if(E<F.length){let S=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,b="";if(k)b=I[0]?.content||"";else{let S=!1;for(let y=1;y<I.length;y++){let d=I[y];if(d.isFinalElse){b=d.content,S=!0;break}if(d.ability){let f=Q(d.ability,d.type,d.id);if(K==="can"?f:!f){b=d.content,S=!0;break}}}if(!S&&I.length>0){let y=I[I.length-1];if(y.isFinalElse)b=y.content}}Y=Y.substring(0,_)+b+Y.substring(L+`@${q}`.length),U=!0}}return Y}function M3($,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=P1(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=r(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 I3($,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),b=D?D.index:1/0,S=k?k.index:1/0;if(b<S)V++,A=b+D[0].length;else if(S<1/0){if(V--,V===0){w=S;break}A=S+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=C(()=>{iZ();J1();J4();F0()});function Z2($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function v1($,Z){if(!$)return Z?.nonceGenerator?.()??Z2();let Y=D3.get($);if(!Y)Y=Z?.nonceGenerator?.()??Z2(),D3.set($,Y);return Y}function aV($){D3.delete($)}function Y2($,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 k3($,Z){return`<meta http-equiv="Content-Security-Policy" content="${Y2($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function tV($){return{enabled:!0,directives:{strict:Wz,moderate:E3,relaxed:_z,api:Bz}[$]||E3,useNonce:$==="strict",addMetaTag:!0}}function eV($,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 X2($,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=k3(Z.directives,X);return $.replace(/<head([^>]*)>/,`<head$1>
3773
3773
  ${J}`)}function $w($,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 J2($,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 k3(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 Zw(){return[jz,Hz]}function Yw($){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 Oz($=!1){return $?"Content-Security-Policy-Report-Only":"Content-Security-Policy"}function Xw($,Z){if(!$.enabled)return{};let Y=$.useNonce?v1(Z,$):void 0,X=Y2($.directives,Y);return{[Oz($.reportOnly)]:X}}var D3,Wz,E3,_z,Bz,jz,Hz,Jw;var Q2=C(()=>{D3=new WeakMap;Wz={"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},E3={"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},_z={"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'"]},Bz={"default-src":["'none'"],"frame-ancestors":["'none'"]};jz={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 k3(Q.directives,G)},hasEndTag:!1,description:"Insert Content-Security-Policy meta tag"},Hz={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"};Jw={enabled:!1,reportOnly:!1,directives:E3,useNonce:!1,addMetaTag:!0}});import{Buffer as G2}from"buffer";import K2 from"crypto";function Fz($=Lz){let Z=K2.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return q5=Z,Z}function Vz(){if(!q5)Fz();return q5}function qw(){q5=null}function zw($){q5=$}function wz($=q2){let Z=Vz();return`<input type="hidden" name="${$}" value="${Z}">`}function z2($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,X)=>{return wz(X||q2)})}function Uw($,Z){let Y=Z??q5;if(!Y)return!1;let X=G2.from($),J=G2.from(Y);if(X.length!==J.length)return!1;return K2.timingSafeEqual(X,J)}var Lz=40,q2="_token",q5=null;var U2=()=>{};async function W2($,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 Az(J,Q,Z,Y,X);else J=await Rz(J,Q,Z,Y,X)}return J}async function Az($,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?_2(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:r("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 Rz($,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=_2(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:r("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:r("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 _2($){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 B2=C(()=>{J1();a1()});var b3={};i(b3,{useTitle:()=>Ez,useSeoMeta:()=>K4,usePageTitle:()=>Ez,useHead:()=>f1,resetHead:()=>Mz,renderHtmlAttrs:()=>bz,renderHead:()=>kz,renderBodyAttrs:()=>Sz,processTitleDirective:()=>Cz,processMetaDirective:()=>vz,processHeadDirective:()=>Pz,getPageMeta:()=>Tz,getHead:()=>x5,definePageMeta:()=>Dz,applyHead:()=>yz});function x5(){return H1}function Tz(){return G4}function Mz(){H1={},Nz.length=0,G4={}}function f1($){H1=Iz(H1,$)}function Iz($,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 K4($){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 Dz($){if(G4={...G4,...$},$.title||$.description)K4({title:$.title,description:$.description})}function Ez($){let Z=typeof $==="function"?$():$;f1({title:Z})}function kz($=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 bz($=H1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${x1(Y)}"`).join(" ")}function Sz($=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 yz($=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 Pz($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(X,J)=>{return Z+=J.trim()+`
3775
3775
  `,""}),headContent:Z.trim()}}function Cz($,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 vz($,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,Nz,G4;var f5=C(()=>{H1={},Nz=[],G4={}});import xz from"crypto";function w0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function fz($){return{...S3,...$.forms?.classes}}function q4($,Z,Y,X){let J=$||Z;return Y?`${J} ${X}`:J}function gz(){return xz.randomUUID()}function Lw($,Z,Y,X){let J=fz(X),Q=$;return Q=dz(Q,Z),Q=d5(Q,Z),Q=y3(Q,Z,J),Q=P3(Q,Z,J),Q}function d5($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let X=gz();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 y3($,Z,Y=S3){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+=`