@stacksjs/stx 0.2.83 → 0.2.85

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 (53) hide show
  1. package/dist/app-shell.js +56 -56
  2. package/dist/build-assets.js +6 -6
  3. package/dist/build-mode-detector.js +101 -101
  4. package/dist/build-views.js +155 -155
  5. package/dist/build.js +43 -43
  6. package/dist/caching.js +6 -6
  7. package/dist/cli.js +57 -57
  8. package/dist/component-processing.js +22 -22
  9. package/dist/component-renderer.js +38 -38
  10. package/dist/components.js +101 -101
  11. package/dist/dev-server/index.js +42 -42
  12. package/dist/dev-server/serve-app.js +56 -56
  13. package/dist/dev-server/serve-file.js +56 -56
  14. package/dist/dev-server/serve-markdown.js +42 -42
  15. package/dist/dev-server/serve-multi.js +55 -55
  16. package/dist/dev-server.js +56 -56
  17. package/dist/docs.js +102 -102
  18. package/dist/dynamic-components.js +38 -38
  19. package/dist/includes.js +38 -38
  20. package/dist/index.js +56 -56
  21. package/dist/interactive.js +102 -102
  22. package/dist/lazy-loader.js +101 -101
  23. package/dist/plugin.js +50 -50
  24. package/dist/process.js +37 -37
  25. package/dist/production-builder.js +37 -37
  26. package/dist/production-server.js +37 -37
  27. package/dist/pwa/index.js +101 -101
  28. package/dist/pwa/offline.js +101 -101
  29. package/dist/pwa.js +90 -90
  30. package/dist/render.js +159 -159
  31. package/dist/runtime-injection.js +6 -6
  32. package/dist/serve.js +112 -112
  33. package/dist/signal-processing.js +6 -6
  34. package/dist/signals.js +6 -6
  35. package/dist/site-builder/build.js +103 -103
  36. package/dist/site-builder/index.js +44 -44
  37. package/dist/ssg.js +19 -19
  38. package/dist/ssr.js +89 -89
  39. package/dist/story/cli.js +42 -42
  40. package/dist/story/commands/dev.js +42 -42
  41. package/dist/story/commands/index.js +42 -42
  42. package/dist/story/index.js +42 -42
  43. package/dist/story/renderer.js +102 -102
  44. package/dist/story/server.js +42 -42
  45. package/dist/story/visual-testing.js +102 -102
  46. package/dist/streaming.js +38 -38
  47. package/dist/template-compiler.js +30 -30
  48. package/dist/template-hydrator.js +116 -116
  49. package/dist/testing.js +101 -101
  50. package/dist/utils.js +38 -38
  51. package/dist/variable-extractor.js +11 -11
  52. package/dist/web-components.js +101 -101
  53. package/package.json +5 -5
package/dist/build.js CHANGED
@@ -1649,7 +1649,7 @@ ${"\x1B[31m"}\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\
1649
1649
 
1650
1650
  `),"utf-8")}}async flush(){await this.writeQueue}}var r4,l0,t4;var P9=b(()=>{B$();r4={isEnabled(){return z$().enableAutoRecovery},fixCommonSyntaxErrors($){let Z=z$();if(!Z.enableAutoRecovery)return{fixed:$,fixes:[]};let Y=$,J=[],X=(Y.match(/\{\{/g)||[]).length,Q=(Y.match(/\}\}/g)||[]).length;if(X>Q){let K=X-Q;Y+="}}".repeat(K),J.push(`Added ${K} missing closing braces '}}'`)}let G=["if","foreach","for","switch","section"];for(let K of G){let q=(Y.match(new RegExp(`@${K}\\b`,"g"))||[]).length,W=(Y.match(new RegExp(`@end${K}\\b`,"g"))||[]).length;if(q>W){let z=q-W;for(let U=0;U<z;U++)Y+=`
1651
1651
  @end${K}`;J.push(`Added ${z} missing @end${K}`)}}if(J.length>0&&Z.logRecoveryWarnings)console.warn("[stx] Auto-recovery applied fixes:"),J.forEach((K)=>console.warn(` - ${K}`)),console.warn(" Consider fixing these issues in your template.");return{fixed:Y,fixes:J}},createFallbackContent($,Z){if(M5())return`<!-- ${$} failed: ${Z.message} -->`;return"<!-- stx rendering error -->"}};l0=new a4,t4={isDevelopment(){return M5()},logDetailedError($,Z){if(!this.isDevelopment())return;if(console.error("=== stx Detailed Error ==="),console.error("Error:",$.message),console.error("Stack:",$.stack),Z)console.error("Context:",Z);console.error("========================")},createErrorReport($,Z){let Y=["=== stx Error Report ===",`Time: ${new Date().toISOString()}`,`Error: ${$.message}`,`Type: ${$.constructor.name}`,`Stack: ${$.stack}`];if(Z)Y.push(`Context: ${JSON.stringify(Z,null,2)}`);return Y.push("========================"),Y.join(`
1652
- `)}}});var v9=()=>{};var x9=b(()=>{K$();C9();P9();v9();B$()});var G1=b(()=>{x9()});function y0($,Z,Y,J=0){let X=0,Q=J,G=null,K=0,q=!1;while(Q<$.length){let W=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&W==="\\"){q=!0,Q++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)X++;else if(W===Y){if(X--,X===0)return Q}Q++}return-1}function _1($,Z){let Y=UG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function UG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let J=y0($,"(",")",Y);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,J),endPos:J+1}}function k1($,Z,Y,J){let X=1,Q=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&X>0){G.lastIndex=Q,K.lastIndex=Q;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)X++,Q=z+q[0].length;else if(U<1/0){if(X--,X===0)return U;Q=U+W[0].length}else break}return-1}function f9($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=k1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z="if",U=X.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,O=_1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function I5($){let Z=[],Y=/@if\s*\(/g,J=Y.exec($);while(J!==null){if(Z.some((G)=>J.index>G.start&&J.index<G.end)){J=Y.exec($);continue}let Q=f9($,J.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;J=Y.exec($)}return Z}function j$($,Z,Y){let J=[],X=new RegExp(`@${Z}\\s*\\(`,"g"),Q=X.exec($);while(Q!==null){if(J.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=X.exec($);continue}let K=Q.index,q=K+Q[0].length-1,W=y0($,"(",")",q);if(W===-1){Q=X.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=k1($,Z,Y,U);if(_===-1){Q=X.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),X.lastIndex=j,Q=X.exec($)}return J}function e4($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=k1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=_1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:X.expression,cases:q,start:Z,end:G+10}}var g9=()=>{};var h9=()=>{};var H$=b(()=>{g9();h9()});function HG($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=e4(J,G);if(!K)break;try{let q;if(X0(K.expression))q=Q0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Z0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&X0(U.value))_=Q0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Z0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+W+J.substring(K.end),X=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=r("Switch",`Error evaluating @switch expression: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function b1($,Z,Y){let J=$;J=HG(J,Z,Y);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=_1(J,K+7);if(!q)break;let W=q.endPos,z=k1(J,"unless","endunless",W);if(z===-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=J.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.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((N,A)=>N.pos-A.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){B=N.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;J=J.substring(0,K)+j+J.substring(z+10),Q=!0}}J=Z7(J,Z,Y),J=Y7(J,Z,Y),J=$7(J,Z);let X=()=>{let Q=I5(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&X0(z.condition))U=Q0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Z0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=r(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,n.EVALUATION_ERROR),W=!0}}J=J.substring(0,K.start)+q+J.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=r("If",`Error processing @if block: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let Q=J;if(!X())break;if(J===Q)break}return J}function d9($){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 J=[];while(Z<$.length){let X=$[Z];if(X==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(X===Y){Z++;break}J.push(X),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function $7($,Z){let Y=$;function J(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>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)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function X(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.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")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===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 W=q.index,z,U,_=Y.slice(W+5),B=d9(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=J(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?U1(`auth?.check && auth?.user?.[${z}]`,Z):U1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+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 W=q.index,z,U,_=Y.slice(W+6),B=d9(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=J(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?U1(`!auth?.check || !auth?.user?.[${z}]`,Z):U1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=U1(W,Z);z.push(U)}return Z.permissions.check(...z)}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}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=J(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,w=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${W}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=N.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=R.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((k,P)=>k.pos-P.pos);for(let k of T){if(k.type==="open"){V++;continue}if(k.type==="close"){V--;continue}if(V===0)O.push(k)}let I=[],D=0;for(let k=0;k<O.length;k++){let P=O[k];if(I.push({content:F.slice(D,P.pos),ability:void 0}),P.type==="elseDirective"){let h=F.slice(P.pos+`@${W}`.length),f=G(h);if(f){I[I.length-1]={content:F.slice(D,P.pos)},D=P.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[k+1],c=m?m.pos:F.length;I.push({content:F.slice(D,c),ability:f.ability,type:f.type,id:f.id}),D=c}}else D=P.pos+5}if(D<F.length){let k=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=Q(j.ability,j.type,j.id),y=K==="can"?E:!E,S="";if(y)S=I[0]?.content||"";else{let k=!1;for(let P=1;P<I.length;P++){let h=I[P];if(h.isFinalElse){S=h.content,k=!0;break}if(h.ability){let f=Q(h.ability,h.type,h.id);if(K==="can"?f:!f){S=h.content,k=!0;break}}}if(!k&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),z=!0}}return Y}function Z7($,Z,Y){let J=$;function X(Q,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=Q.match(U);if(!_||_.index===void 0)break;let B=_.index,j=_1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=k1(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,w=0,N=0;while(N<F.length){let A=F.indexOf("@",N);if(A===-1)break;let R=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,N=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,N=A+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=A;break}N=A+1}try{let A=q(O.trim()),R;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);R=A?T:M}else R=A?F:"";Q=Q.substring(0,B)+R+Q.substring(L+`@${K}`.length),z=!0}catch(A){let R=A instanceof Error?A.message:String(A),T=r(W,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return J=X(J,"isset","endisset",(Q)=>{let G=U1(Q,Z);return G!==void 0&&G!==null},"Isset"),J=X(J,"empty","endempty",(Q)=>{let G=U1(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"),J}function Y7($,Z,Y){let J=$,X="development";function Q(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=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,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=X===E[2]}let V=1,w=O,N=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let E=z.exec(j),y=U.exec(j),S=E?E.index:1/0,k=y?y.index:1/0;if(S<k)V++,w=S+E[0].length;else if(k<1/0){if(V--,V===0){N=k;break}w=k+y[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let A=j.substring(O,N),R=-1,T=0,M=0;while(M<A.length){let E=A.indexOf("@",M);if(E===-1)break;let y=A.substring(E);if(_.test(y)){T++,M=E+1;continue}if(B.test(y)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(y)){R=E;break}M=E+1}let I;if(R!==-1){let E=A.slice(0,R),y=A.slice(R+5);I=W?E:y}else I=W?A:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(N+D),H=!0}return j}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",X==="production"),J=Q(J,"development","enddevelopment",X==="development"),J=Q(J,"staging","endstaging",X==="staging"),J=Q(J,"testing","endtesting",X==="testing"),J}var O$=b(()=>{b9();G1();H$();T0()});function u9($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function L$($,Z){if(!$)return Z?.nonceGenerator?.()??u9();let Y=m9.get($);if(!Y)Y=Z?.nonceGenerator?.()??u9(),m9.set($,Y);return Y}function OG($,Z){let Y=[];for(let[J,X]of Object.entries($)){if(X===void 0||X===null)continue;if(typeof X==="boolean"){if(X)Y.push(J);continue}if(Array.isArray(X)){let Q=[...X];if(Z&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${J} ${Q.join(" ")}`)}}return Y.join("; ")}function p9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${OG($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function c9($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=Z.useNonce?L$(Y,Z):void 0,X=p9(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
1652
+ `)}}});var v9=()=>{};var x9=b(()=>{K$();C9();P9();v9();B$()});var G1=b(()=>{x9()});function y0($,Z,Y,J=0){let X=0,Q=J,G=null,K=0,q=!1;while(Q<$.length){let W=$[Q];if(G&&q){q=!1,Q++;continue}if(G&&W==="\\"){q=!0,Q++;continue}if(q=!1,(W==='"'||W==="'"||W==="`")&&!G){G=W,Q++;continue}if(W===G&&G!=="`"){G=null,Q++;continue}if(G==="`"&&W==="$"&&$[Q+1]==="{"){K++,Q+=2;continue}if(K>0&&W==="}"){K--,Q++;continue}if(W==="`"&&G==="`"&&K===0){G=null,Q++;continue}if(G){Q++;continue}if(W===Z)X++;else if(W===Y){if(X--,X===0)return Q}Q++}return-1}function _1($,Z){let Y=UG($,Z);return Y.ok?{expression:Y.expression,endPos:Y.endPos}:null}function UG($,Z){let Y=Z;while(Y<$.length&&/\s/.test($[Y]))Y++;if($[Y]!=="(")return{ok:!1,reason:"missing-open-paren",pos:Y};let J=y0($,"(",")",Y);if(J===-1)return{ok:!1,reason:"unclosed-paren",pos:Y};return{ok:!0,expression:$.slice(Y+1,J),endPos:J+1}}function k1($,Z,Y,J){let X=1,Q=J,G=new RegExp(`@${Z}\\s*\\(`,"g"),K=new RegExp(`@${Y}(?![a-z])`,"g");while(Q<$.length&&X>0){G.lastIndex=Q,K.lastIndex=Q;let q=G.exec($),W=K.exec($),z=q?q.index:1/0,U=W?W.index:1/0;if(z<U)X++,Q=z+q[0].length;else if(U<1/0){if(X--,X===0)return U;Q=U+W[0].length}else break}return-1}function f9($,Z){let Y=$.slice(Z).match(/^@if\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=k1($,"if","endif",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z="if",U=X.expression,_=0,B=0;while(W<K.length){let j=K.indexOf("@",W);if(j===-1)break;W=j;let H=K.substring(j);if(/^@if\s*\(/.test(H)){B++,W++;continue}if(/^@endif(?![a-z])/.test(H)){B--,W+=6;continue}if(B===0){let L=H.match(/^@elseif\s*/);if(L){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W});let F=W+L[0].length,O=_1(K,F);if(!O){W++;continue}z="elseif",U=O.expression,W=O.endPos,_=W;continue}else if(/^@else(?![a-z])/.test(H)){q.push({type:z,condition:U,content:K.substring(_,W),start:Q+_,end:Q+W}),z="else",U=void 0,W+=5,_=W;continue}}W++}return q.push({type:z,condition:U,content:K.slice(_),start:Q+_,end:Q+K.length}),{fullMatch:$.slice(Z,G+6),branches:q,start:Z,end:G+6}}function I5($){let Z=[],Y=/@if\s*\(/g,J=Y.exec($);while(J!==null){if(Z.some((G)=>J.index>G.start&&J.index<G.end)){J=Y.exec($);continue}let Q=f9($,J.index);if(Q)Z.push(Q),Y.lastIndex=Q.end;J=Y.exec($)}return Z}function j$($,Z,Y){let J=[],X=new RegExp(`@${Z}\\s*\\(`,"g"),Q=X.exec($);while(Q!==null){if(J.some((H)=>Q.index>H.start&&Q.index<H.end)){Q=X.exec($);continue}let K=Q.index,q=K+Q[0].length-1,W=y0($,"(",")",q);if(W===-1){Q=X.exec($);continue}let z=$.slice(q+1,W),U=W+1,_=k1($,Z,Y,U);if(_===-1){Q=X.exec($);continue}let B=$.slice(U,_),j=_+`@${Y}`.length;J.push({fullMatch:$.slice(K,j),name:Z,params:z,content:B,start:K,end:j}),X.lastIndex=j,Q=X.exec($)}return J}function e4($,Z){let Y=$.slice(Z).match(/^@switch\s*/);if(!Y)return null;let J=Z+Y[0].length,X=_1($,J);if(!X)return null;let Q=X.endPos,G=k1($,"switch","endswitch",Q);if(G===-1)return null;let K=$.slice(Q,G),q=[],W=0,z=null,U=0;while(W<K.length){let _=K.slice(W),B=_.match(/^@switch\s*\(/),j=_.match(/^@endswitch(?![a-z])/);if(B){if(U++,z)z.content+=B[0];W+=B[0].length;continue}if(j){if(U--,z)z.content+=j[0];W+=j[0].length;continue}if(U>0){if(z)z.content+=K[W];W++;continue}let H=_.match(/^@case\s*/),L=_.match(/^@default(?![a-z])/),F=_.match(/^@break(?![a-z])/);if(H&&_.startsWith("@case")){if(z)q.push(z);let O=W+H[0].length,V=_1(K,O);if(!V){W++;continue}z={type:"case",value:V.expression,content:""},W=V.endPos}else if(L&&_.startsWith("@default")){if(z)q.push(z);z={type:"default",content:""},W+=L[0].length}else if(F&&_.startsWith("@break"))W+=F[0].length;else{if(z)z.content+=K[W];W++}}if(z)q.push(z);return{fullMatch:$.slice(Z,G+10),expression:X.expression,cases:q,start:Z,end:G+10}}var g9=()=>{};var h9=()=>{};var H$=b(()=>{g9();h9()});function HG($,Z,Y){let J=$,X=!0;while(X){X=!1;let Q=J.match(/@switch\s*\(/);if(!Q||Q.index===void 0)break;let G=Q.index,K=e4(J,G);if(!K)break;try{let q;if(X0(K.expression))q=Q0(K.expression,Object.keys(Z))(...Object.values(Z));else q=Z0(K.expression,Z);let W="",z=!1;for(let U of K.cases)if(U.type==="default"){if(!z)W=U.content.trim()}else try{let _;if(U.value&&X0(U.value))_=Q0(U.value,Object.keys(Z))(...Object.values(Z));else if(U.value)_=Z0(U.value,Z);if(q===_){W=U.content.trim(),z=!0;break}}catch{continue}J=J.substring(0,G)+W+J.substring(K.end),X=!0}catch(q){let W=q instanceof Error?q.message:String(q),z=r("Switch",`Error evaluating @switch expression: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,G)+z+J.substring(K.end);break}}return J}function b1($,Z,Y){let J=$;J=HG(J,Z,Y);{let Q=!0;while(Q){Q=!1;let G=J.match(/@unless\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=_1(J,K+7);if(!q)break;let W=q.endPos,z=k1(J,"unless","endunless",W);if(z===-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=J.slice(W,z),_=q.expression,B=-1;{let H=0,L=/@(?:if|unless)\s*\(/g,F=/@(?:endif|endunless)(?![a-z])/g,O=/@else(?![a-z])/g,V=[],w;while((w=L.exec(U))!==null)V.push({pos:w.index,type:"open"});while((w=F.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((N,A)=>N.pos-A.pos);for(let N of V)if(N.type==="open")H++;else if(N.type==="close")H--;else if(N.type==="else"&&H===0){B=N.pos;break}}let j;if(B!==-1){let H=U.slice(0,B),L=U.slice(B+5);j=`@if (${_})${L}@else ${H}@endif`}else j=`@if (!(${_}))${U}@endif`;J=J.substring(0,K)+j+J.substring(z+10),Q=!0}}J=Z7(J,Z,Y),J=Y7(J,Z,Y),J=$7(J,Z);let X=()=>{let Q=I5(J);if(Q.length===0)return!1;for(let G=Q.length-1;G>=0;G--){let K=Q[G];try{let q="",W=!1;for(let z of K.branches){if(W)break;if(z.type==="else")q=z.content,W=!0;else try{let U;if(z.condition&&X0(z.condition))U=Q0(z.condition,Object.keys(Z))(...Object.values(Z));else if(z.condition)U=Z0(z.condition,Z);if(U)q=z.content,W=!0}catch(U){q=r(z.type==="if"?"If":"Elseif",`Error in @${z.type}(${z.condition}): ${U instanceof Error?U.message:String(U)}`,n.EVALUATION_ERROR),W=!0}}J=J.substring(0,K.start)+q+J.substring(K.end)}catch(q){let W=q instanceof Error?q.message:String(q),z=r("If",`Error processing @if block: ${W}`,n.EVALUATION_ERROR);J=J.substring(0,K.start)+z+J.substring(K.end)}}return!0};while(!0){let Q=J;if(!X())break;if(J===Q)break}return J}function d9($){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 J=[];while(Z<$.length){let X=$[Z];if(X==="\\"&&Z+1<$.length){J.push($[Z+1]),Z+=2;continue}if(X===Y){Z++;break}J.push(X),Z++}while(Z<$.length&&/\s/.test($[Z]))Z++;if($[Z]!==")")return null;return Z++,{value:J.join(""),consumed:Z}}function $7($,Z){let Y=$;function J(K,q,W,z){let U=1,_=z,B=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),j=new RegExp(`@${W}(?![a-z])`,"g");while(_<K.length&&U>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)U++,_=F+H[0].length;else if(O<1/0){if(U--,U===0)return O;_=O+L[0].length}else break}return-1}function X(K,q,W){let z=0,U=new RegExp(`@${q}(?:\\s*\\(|\\s|$)`,"g"),_=new RegExp(`@${W}(?![a-z])`,"g"),B=/@else(?![a-z])/g,j=[],H;while((H=U.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")z++;else if(L.type==="close")z--;else if(L.type==="else"&&z===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 W=q.index,z,U,_=Y.slice(W+5),B=d9(_);if(B)z=B.value,U=W+5+B.consumed;else U=W+5;let j=J(Y,"auth","endauth",U);if(j===-1){console.warn(`[stx] @auth directive at position ${W} has no matching @endauth \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"auth","endauth"),F;if(!Z.auth)F=!1;else F=z?U1(`auth?.check && auth?.user?.[${z}]`,Z):U1("auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+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 W=q.index,z,U,_=Y.slice(W+6),B=d9(_);if(B)z=B.value,U=W+6+B.consumed;else U=W+6;let j=J(Y,"guest","endguest",U);if(j===-1){console.warn(`[stx] @guest directive at position ${W} has no matching @endguest \u2014 the block was skipped.`);break}let H=Y.slice(U,j),L=X(H,"guest","endguest"),F;if(!Z.auth)F=!0;else F=z?U1(`!auth?.check || !auth?.user?.[${z}]`,Z):U1("!auth?.check",Z);let O;if(L!==-1){let V=H.slice(0,L),w=H.slice(L+5);O=F?V:w}else O=F?H:"";Y=Y.substring(0,W)+O+Y.substring(j+9),K=!0}}function Q(K,q,W){if(Z.userCan&&typeof Z.userCan[K]==="boolean")return Z.userCan[K];if(Z.permissions?.check&&typeof Z.permissions.check==="function")try{let z=[K];if(q)z.push(q);if(W){let U=U1(W,Z);z.push(U)}return Z.permissions.check(...z)}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}`,W=K==="can"?"elsecan":"elsecannot",z=!0;while(z){z=!1;let U=Y.match(new RegExp(`@${K}\\s*\\(`));if(!U||U.index===void 0)break;let _=U.index,B=Y.slice(_+`@${K}`.length),j=G(B);if(!j)break;let H=_+`@${K}`.length+j.paramsEnd,L=J(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,w=new RegExp(`@${K}\\s*\\(`,"g"),N=new RegExp(`@${q}(?![a-z])`,"g"),A=new RegExp(`@${W}\\s*\\(`,"g"),R=/@else(?![a-z])/g,T=[],M;while((M=w.exec(F))!==null)T.push({pos:M.index,type:"open"});while((M=N.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=R.exec(F))!==null)T.push({pos:M.index,type:"else"});T.sort((k,P)=>k.pos-P.pos);for(let k of T){if(k.type==="open"){V++;continue}if(k.type==="close"){V--;continue}if(V===0)O.push(k)}let I=[],D=0;for(let k=0;k<O.length;k++){let P=O[k];if(I.push({content:F.slice(D,P.pos),ability:void 0}),P.type==="elseDirective"){let h=F.slice(P.pos+`@${W}`.length),f=G(h);if(f){I[I.length-1]={content:F.slice(D,P.pos)},D=P.pos+`@${W}`.length+f.paramsEnd,I.push({content:"",ability:f.ability,type:f.type,id:f.id}),I.pop();let m=O[k+1],c=m?m.pos:F.length;I.push({content:F.slice(D,c),ability:f.ability,type:f.type,id:f.id}),D=c}}else D=P.pos+5}if(D<F.length){let k=I[I.length-1];if(O.length>0&&O[O.length-1].type==="else")I.push({content:F.slice(D),isFinalElse:!0});else if(I.length===0)I.push({content:F.slice(D)})}let E=Q(j.ability,j.type,j.id),C=K==="can"?E:!E,S="";if(C)S=I[0]?.content||"";else{let k=!1;for(let P=1;P<I.length;P++){let h=I[P];if(h.isFinalElse){S=h.content,k=!0;break}if(h.ability){let f=Q(h.ability,h.type,h.id);if(K==="can"?f:!f){S=h.content,k=!0;break}}}if(!k&&I.length>0){let P=I[I.length-1];if(P.isFinalElse)S=P.content}}Y=Y.substring(0,_)+S+Y.substring(L+`@${q}`.length),z=!0}}return Y}function Z7($,Z,Y){let J=$;function X(Q,G,K,q,W){let z=!0;while(z){z=!1;let U=new RegExp(`@${G}\\s*\\(`),_=Q.match(U);if(!_||_.index===void 0)break;let B=_.index,j=_1(Q,B+`@${G}`.length);if(!j)break;let H=j.endPos,L=k1(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,w=0,N=0;while(N<F.length){let A=F.indexOf("@",N);if(A===-1)break;let R=F.substring(A);if(/^@(?:if|unless|isset|empty)\s*\(/.test(R)){w++,N=A+1;continue}if(/^@(?:endif|endunless|endisset|endempty)(?![a-z])/.test(R)){w--,N=A+1;continue}if(w===0&&/^@else(?![a-z])/.test(R)){V=A;break}N=A+1}try{let A=q(O.trim()),R;if(V!==-1){let T=F.slice(0,V),M=F.slice(V+5);R=A?T:M}else R=A?F:"";Q=Q.substring(0,B)+R+Q.substring(L+`@${K}`.length),z=!0}catch(A){let R=A instanceof Error?A.message:String(A),T=r(W,`Error processing @${G} directive: ${R}`,n.EVALUATION_ERROR);Q=Q.substring(0,B)+T+Q.substring(L+`@${K}`.length);break}}return Q}return J=X(J,"isset","endisset",(Q)=>{let G=U1(Q,Z);return G!==void 0&&G!==null},"Isset"),J=X(J,"empty","endempty",(Q)=>{let G=U1(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"),J}function Y7($,Z,Y){let J=$,X="development";function Q(G,K,q,W){let z=new RegExp(`@${K}(?![a-z])`,"g"),U=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,z.lastIndex=0;let L=z.exec(j);if(!L)break;let F=L.index,O=F+L[0].length;if(K==="env"){let E=j.substring(O).match(/^\s*\(\s*(['"])([^'"]+)\1\s*\)/);if(!E)break;O+=E[0].length,W=X===E[2]}let V=1,w=O,N=-1;while(V>0&&w<j.length){z.lastIndex=w,U.lastIndex=w;let E=z.exec(j),C=U.exec(j),S=E?E.index:1/0,k=C?C.index:1/0;if(S<k)V++,w=S+E[0].length;else if(k<1/0){if(V--,V===0){N=k;break}w=k+C[0].length}else break}if(N===-1){console.warn(`[stx] @${K} directive at position ${F} has no matching @${q} \u2014 the block was skipped.`);break}let A=j.substring(O,N),R=-1,T=0,M=0;while(M<A.length){let E=A.indexOf("@",M);if(E===-1)break;let C=A.substring(E);if(_.test(C)){T++,M=E+1;continue}if(B.test(C)){T--,M=E+1;continue}if(T===0&&/^@else(?![a-z])/.test(C)){R=E;break}M=E+1}let I;if(R!==-1){let E=A.slice(0,R),C=A.slice(R+5);I=W?E:C}else I=W?A:"";let D=`@${q}`.length;j=j.substring(0,F)+I+j.substring(N+D),H=!0}return j}return J=Q(J,"env","endenv",!1),J=Q(J,"production","endproduction",X==="production"),J=Q(J,"development","enddevelopment",X==="development"),J=Q(J,"staging","endstaging",X==="staging"),J=Q(J,"testing","endtesting",X==="testing"),J}var O$=b(()=>{b9();G1();H$();T0()});function u9($=16){let Z=new Uint8Array($);return crypto.getRandomValues(Z),btoa(String.fromCharCode(...Z))}function L$($,Z){if(!$)return Z?.nonceGenerator?.()??u9();let Y=m9.get($);if(!Y)Y=Z?.nonceGenerator?.()??u9(),m9.set($,Y);return Y}function OG($,Z){let Y=[];for(let[J,X]of Object.entries($)){if(X===void 0||X===null)continue;if(typeof X==="boolean"){if(X)Y.push(J);continue}if(Array.isArray(X)){let Q=[...X];if(Z&&(J==="script-src"||J==="style-src"))Q=Q.filter((G)=>!G.startsWith("'nonce-")),Q.push(`'nonce-${Z}'`);if(Q.length>0)Y.push(`${J} ${Q.join(" ")}`)}}return Y.join("; ")}function p9($,Z){return`<meta http-equiv="Content-Security-Policy" content="${OG($,Z).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}">`}function c9($,Z,Y){if(!Z.enabled||!Z.addMetaTag)return $;if($.includes('http-equiv="Content-Security-Policy"'))return $;if(!$.includes("<head>")&&!$.includes("<head "))return $;let J=Z.useNonce?L$(Y,Z):void 0,X=p9(Z.directives,J);return $.replace(/<head([^>]*)>/,`<head$1>
1653
1653
  ${X}`)}function l9($,Z,Y,J){let X=$,Q=J.csp;if(X=X.replace(/@csp\b/g,()=>{if(!Q?.enabled||!Q.directives)return"<!-- CSP not configured -->";let G=Q.useNonce?L$(Z,Q):void 0;return p9(Q.directives,G)}),X=X.replace(/@cspNonce\b/g,()=>{if(!Q?.enabled||!Q.useNonce)return"";return L$(Z,Q)}),Q?.enabled&&Q.useNonce)Z.cspNonce=L$(Z,Q);return X}var m9;var i9=b(()=>{m9=new WeakMap});import LG from"crypto";function VG($=FG){let Z=LG.randomBytes(Math.ceil($/2)).toString("hex").slice(0,$);return J7=Z,Z}function wG(){if(!J7)VG();return J7}function NG($=n9){let Z=wG();return`<input type="hidden" name="${$}" value="${Z}">`}function o9($){return $.replace(/@csrf(?:\((['"])([^'"]*)\1\))?/g,(Z,Y,J)=>{return NG(J||n9)})}var FG=40,n9="_token",J7=null;var s9=()=>{};async function r9($,Z,Y,J){if(!J.customDirectives||J.customDirectives.length===0)return $;let X=$;for(let Q of J.customDirectives){if(!Q.name||typeof Q.handler!=="function"){if(J.debug)console.warn("Invalid custom directive:",Q);continue}if(Q.hasEndTag)X=await AG(X,Q,Z,Y,J);else X=await RG(X,Q,Z,Y,J)}return X}async function AG($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=`@${Q}`,q=`@end${Q}`,W=$,z=i1(`${K}(?:\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\))?([\\s\\S]*?)${q}`,"g"),U=[],_=z.exec(W);while(_!==null){let[B,j="",H=""]=_,L=_.index||0;try{let F=j?a9(j):[],O=H.trim(),V=await G(O,F,Y,J);U.push({original:B,processed:V,startIndex:L})}catch(F){let O=F instanceof Error?F.message:String(F);if(X.debug)console.error(`Error processing custom directive @${Q}:`,F);U.push({original:B,processed:r("CustomDirective",`Error in @${Q}${j?`(${j})`:""}: ${O}`,n.EVALUATION_ERROR),startIndex:L})}_=z.exec(W)}for(let B=U.length-1;B>=0;B--){let{original:j,processed:H}=U[B];W=W.replace(j,H)}return W}async function RG($,Z,Y,J,X){let{name:Q,handler:G}=Z,K=$,q=i1(`@${Q}\\s*\\(([^()]*(?:\\([^)]*\\)[^()]*)*)\\)`,"g"),W=[],z=q.exec(K);while(z!==null){let[B,j=""]=z,H=z.index||0;try{let L=a9(j),F=await G("",L,Y,J);W.push({original:B,processed:F,startIndex:H})}catch(L){let F=L instanceof Error?L.message:String(L);if(X.debug)console.error(`Error processing custom directive @${Q}:`,L);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}(${j}): ${F}`,n.EVALUATION_ERROR),startIndex:H})}z=q.exec(K)}let U=i1(`@${Q}(?!\\w)(?!\\s*\\()`,"g"),_=U.exec(K);while(_!==null){let[B]=_,j=_.index||0;try{let H=await G("",[],Y,J);W.push({original:B,processed:H,startIndex:j})}catch(H){let L=H instanceof Error?H.message:String(H);if(X.debug)console.error(`Error processing custom directive @${Q}:`,H);W.push({original:B,processed:r("CustomDirective",`Error in @${Q}: ${L}`,n.EVALUATION_ERROR),startIndex:j})}_=U.exec(K)}for(let B=W.length-1;B>=0;B--){let{original:j,processed:H}=W[B];K=K.replace(j,H)}return K}function a9($){if(!$.trim())return[];let Z=[],Y="",J=!1,X="";for(let Q=0;Q<$.length;Q++){let G=$[Q];if((G==='"'||G==="'")&&(Q===0||$[Q-1]!=="\\"))if(!J)J=!0,X=G;else if(G===X)J=!1;else Y+=G;else if(G===","&&!J)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 t9=b(()=>{G1();n1()});var X7={};o(X7,{useTitle:()=>kG,useSeoMeta:()=>V$,usePageTitle:()=>kG,useHead:()=>y1,resetHead:()=>IG,renderHtmlAttrs:()=>SG,renderHead:()=>bG,renderBodyAttrs:()=>yG,processTitleDirective:()=>vG,processMetaDirective:()=>xG,processHeadDirective:()=>PG,getPageMeta:()=>MG,getHead:()=>D5,definePageMeta:()=>EG,applyHead:()=>CG});function D5(){return B1}function MG(){return F$}function IG(){B1={},TG.length=0,F$={}}function y1($){B1=DG(B1,$)}function DG($,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 V$($){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,J=$.ogDescription??$.description;if(Y)Z.push({property:"og:title",content:Y});if(J)Z.push({property:"og:description",content:J});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 X=$.twitterTitle??$.title,Q=$.twitterDescription??$.description,G=$.twitterImage??$.ogImage;if($.twitterCard)Z.push({name:"twitter:card",content:$.twitterCard});if(X)Z.push({name:"twitter:title",content:X});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});y1({title:$.title,titleTemplate:$.titleTemplate,meta:Z,link:K})}function EG($){if(F$={...F$,...$},$.title||$.description)V$({title:$.title,description:$.description})}function kG($){let Z=typeof $==="function"?$():$;y1({title:Z})}function bG($=B1){let Z=[];if($.title){let Y=$.title;if($.titleTemplate)Y=typeof $.titleTemplate==="function"?$.titleTemplate(Y):$.titleTemplate.replace("%s",Y);Z.push(`<title>${S1(Y)}</title>`)}if($.base){let Y=Object.entries($.base).map(([J,X])=>`${J}="${S1(X)}"`).join(" ");Z.push(`<base ${Y}>`)}for(let Y of $.meta||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>{return`${X==="httpEquiv"?"http-equiv":X}="${S1(String(Q))}"`}).join(" ");Z.push(`<meta ${J}>`)}for(let Y of $.link||[]){let J=Object.entries(Y).filter(([X,Q])=>Q!==void 0).map(([X,Q])=>`${X}="${S1(String(Q))}"`).join(" ");Z.push(`<link ${J}>`)}for(let Y of $.script||[]){let{content:J,...X}=Y,Q=Object.entries(X).filter(([G,K])=>K!==void 0).map(([G,K])=>{if(typeof K==="boolean")return K?G:"";return`${G}="${S1(String(K))}"`}).filter(Boolean).join(" ");if(J)Z.push(`<script ${Q}>${J}</script>`);else Z.push(`<script ${Q}></script>`)}for(let Y of $.style||[]){let J=Y.type?` type="${Y.type}"`:"";Z.push(`<style${J}>${Y.content}</style>`)}return Z.join(`
1654
1654
  `)}function SG($=B1){if(!$.htmlAttrs)return"";return Object.entries($.htmlAttrs).map(([Z,Y])=>`${Z}="${S1(Y)}"`).join(" ")}function yG($=B1){if(!$.bodyAttrs)return"";return Object.entries($.bodyAttrs).map(([Z,Y])=>`${Z}="${S1(Y)}"`).join(" ")}function S1($){return $.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function CG($=B1){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 J=document.querySelector(Y);if(!J){if(J=document.createElement("meta"),Z.name)J.setAttribute("name",Z.name);if(Z.property)J.setAttribute("property",Z.property);document.head.appendChild(J)}J.setAttribute("content",Z.content)}}for(let Z of $.link||[]){let Y=`link[rel="${Z.rel}"]${Z.href?`[href="${Z.href}"]`:""}`,J=document.querySelector(Y);if(!J)J=document.createElement("link"),document.head.appendChild(J);for(let[X,Q]of Object.entries(Z))if(Q!==void 0)J.setAttribute(X,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 PG($){let Z="";return{content:$.replace(/@head\s*([\s\S]*?)@endhead/g,(J,X)=>{return Z+=X.trim()+`
1655
1655
  `,""}),headContent:Z.trim()}}function vG($,Z){return $.replace(/@title\s*\(\s*(?:(['"`])(.+?)\1|([^)]+))\s*\)/g,(Y,J,X,Q)=>{let G=J?X:Z[(Q||"").trim()]??Q;return y1({title:G}),""})}function xG($,Z){return $.replace(/@meta\s*\(\s*(['"`])(.+?)\1\s*,\s*(?:(['"`])(.+?)\3|([^)]+))\s*\)/g,(Y,J,X,Q,G,K)=>{let q=Q?G:K,W=Q?q:Z[(q||"").trim()]??q,U=X.includes(":")?{property:X,content:W}:{name:X,content:W};return y1({meta:[U]}),""})}var B1,TG,F$;var E5=b(()=>{B1={},TG=[],F$={}});import fG from"crypto";function M0($){return String($??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function w$($,Z,Y,J){let X=$||Z;return Y?`${X} ${J}`:X}function gG(){return fG.randomUUID()}function N$($,Z){let Y=$;return Y=Y.replace(/@csrf/g,()=>{if(!Z.csrf||typeof Z.csrf!=="object"){let J=gG();Z.csrf={token:J}}if(Z.csrf.field)return Z.csrf.field;if(Z.csrf.token)return`<input type="hidden" name="_token" value="${M0(Z.csrf.token)}">`;return'<input type="hidden" name="_token" value="">'}),Y=Y.replace(/@method\(['"]([^'"]+)['"]\)/g,(J,X)=>{let Q=X.toUpperCase();if(X&&!["GET","POST"].includes(Q))return`<input type="hidden" name="_method" value="${M0(Q)}">`;return J}),Y}function Z8($,Z,Y=$8){let J=$;return J=J.replace(/@form\(\s*(?:(?:'([^']+)'|"([^"]+)")\s*)?(?:,\s*(?:'([^']+)'|"([^"]+)")?)?\s*(?:,\s*\{([^}]+)\}\s*)?\)/g,(X,Q,G,K,q,W="")=>{let z=Q||G||"POST",U=K||q||"",_=j1(W),B=z.toUpperCase(),j=["GET","POST"].includes(B)?B:"POST",H=`<form method="${M0(j)}" action="${M0(U)}"${_?` ${_}`:""}>`;if(H+=`
@@ -1847,12 +1847,12 @@ else {
1847
1847
  ${q?`{${q}}`:"{}"}
1848
1848
  </script>
1849
1849
  </div>`}}});var H8={};o(H8,{warnUnbalancedTags:()=>O7,findUnbalancedTags:()=>j8});function H1($){return $.replace(/[^\n]/g," ")}function j8($){let Z=$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,H1).replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,H1).replace(/<!--[\s\S]*?-->/g,H1).replace(/\{\{\{[\s\S]*?\}\}\}/g,H1).replace(/\{\{[\s\S]*?\}\}/g,H1).replace(/\{!![\s\S]*?!!\}/g,H1).replace(/"[^"]*"/g,H1).replace(/'[^']*'/g,H1),Y=new Map,J=new Map,X=/<(\/?)([A-Za-z][\w-]*)\b[^>]*?(\/?)>/g,Q;while((Q=X.exec(Z))!==null){let K=Q[1]==="/",q=Q[2],W=Q[3]==="/";if(NK.has(q.toLowerCase()))continue;if(W)continue;if(K)J.set(q,(J.get(q)??0)+1);else{let z=Y.get(q);if(z)z.count++;else{let U=Z.slice(0,Q.index).split(`
1850
- `).length;Y.set(q,{count:1,firstLine:U})}}}let G=[];for(let K of new Set([...Y.keys(),...J.keys()])){if(AK.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,W=J.get(K)??0;if(q!==W)G.push({tag:K,opened:q,closed:W,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function O7($,Z){let Y;try{Y=j8($)}catch{return}if(Y.length===0)return;let J=`${Z}:${$.length}`;if(B8.has(J))return;B8.add(J);let X=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let W=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${X}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${X}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var NK,AK,B8;var L7=b(()=>{NK=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),AK=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);B8=new Set});import u0 from"path";import F7 from"fs";function O8($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function L8($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class F8{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,J){let X=$.endsWith(".stx")?$.slice(0,-4):$,Q=J?.__importedComponents;if(Q){let B=[X,X.toLowerCase(),O8(X),L8(X)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${X}.stx`,`${O8(X)}.stx`,`${L8(X)}.stx`])];if(X.startsWith("./")||X.startsWith("../")){let B=u0.resolve(u0.dirname(Z),`${X}.stx`);if(await l(B))return B;return null}let K=[],q=Y.componentsDir||"",W=J?.__originalFilePath;if(W)K.push(u0.join(u0.dirname(W),"components"));if(q)K.push(q);let z=u0.join(u0.dirname(Z),"components");if(!K.includes(z))K.push(z);let U=process.cwd(),_=[u0.resolve(U,"src/components"),u0.resolve(U,"components"),u0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=u0.join(B,j);if(await l(H))return H}try{if(!F7.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=F7.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=u0.join(B,L.name);for(let O of G){let V=u0.join(F,O);if(await l(V))return V}}}catch{}}return null}}var C0;var V7=b(()=>{A0();C0=new F8});function O1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function RK($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var w7;var N7=b(()=>{w7={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let J=RK($),X=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,q=[];if(J.reactive)q.push(`:href="${O1(J.value)}"`);else q.push(`href="${O1(J.value)}"`);if(X)q.push(`class="${O1(X)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${O1(Q)}"`),q.push(`data-stx-exact-active-class="${O1(G)}"`),K)q.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[z,U]of Object.entries($.static)){if(W.has(z))continue;if(typeof U==="boolean"){if(U)q.push(O1(z))}else q.push(`${O1(z)}="${O1(U)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function F0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function E0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function R7($,Z,Y=!1){let J=$.serverDynamic[Z];if(J!==void 0)return J!==!1&&J!=="false";let X=$.static[Z];if(X!==void 0)return X!=="false"&&X!==!1;return Y}function V8($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let J of Z)if(J.includes(":")){let[X,Q]=J.split(":"),G=TK[X];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(X);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(J);return Y.join(", ")}function T7($,Z,Y,J){return Z.map((X)=>`${P5($,X,void 0,Y,J)} ${X}w`).join(", ")}function MK($,Z,Y,J,X){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${P5($,G,void 0,J,X)} ${Q}x`}).join(", ")}function P5($,Z,Y,J,X){if(!J||J==="local"||J==="static")return $;if(J==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(X)Q.push(`f_${X}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(J==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(X)Q.set("fm",X);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(J==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(X)Q.set("format",X);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function IK($,Z,Y="#e5e7eb"){let J=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(J)}`}var TK,A7,M7;var I7=b(()=>{TK={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},A7=[320,640,768,1024,1280,1536,1920];M7={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let J=E0($,"src")||"",X=E0($,"alt")||"",Q=E0($,"width"),G=E0($,"height"),K=E0($,"sizes"),q=E0($,"srcset"),W=E0($,"densities"),z=E0($,"format"),U=E0($,"placeholder"),_=E0($,"placeholderColor")||"#e5e7eb",B=E0($,"provider"),j=E0($,"class")||E0($,"className")||"",H=E0($,"style")||"",L=E0($,"quality"),F=R7($,"lazy",!0),O=R7($,"preload",!1),V=R7($,"picture",!1)||!!z,w=Q?Number.parseInt(Q):void 0,N=G?Number.parseInt(G):void 0,A=q||"",R="";if(!A&&K)A=T7(J,A7,B,z),R=V8(K);else if(!A&&W){let S=W.split(/\s+/).map((k)=>Number.parseFloat(k.replace("x","")));A=MK(J,S,w,B,z)}else if(K)R=V8(K);let T=[];if(H)T.push(H);if(w&&N)T.push(`aspect-ratio:${w}/${N}`);if(U==="blur"||U==="color"||U==="thumbhash"){let S=IK(w||16,N||9,_);T.push(`background-image:url(${S})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(U&&U!=="empty"&&U!=="none")T.push(`background-image:url(${F0(U)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let M=P5(J,w,N,B,z),I=[];if(I.push(`src="${F0(M)}"`),I.push(`alt="${F0(X)}"`),Q)I.push(`width="${F0(Q)}"`);if(G)I.push(`height="${F0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${F0(j)}"`);if(T.length>0)I.push(`style="${F0(T.join(";"))}"`);if(A)I.push(`srcset="${F0(A)}"`);if(R)I.push(`sizes="${F0(R)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,k]of Object.entries($.static)){if(D.has(S))continue;if(typeof k==="boolean"){if(k)I.push(F0(S))}else I.push(`${F0(S)}="${F0(k)}"`)}let E=`<img ${I.join(" ")} />`,y="";if(O){let k=z==="webp"?"image/webp":z==="avif"?"image/avif":"";y=`<link rel="preload" as="image" href="${F0(M)}"${k?` type="${k}"`:""}${A?` imagesrcset="${F0(A)}"`:""}${R?` imagesizes="${F0(R)}"`:""} />
1851
- `}if(V){let S=[];if(z==="avif"||z==="auto"){let k=P5(J,w,N,B,"avif"),P=A?T7(J,A7,B,"avif"):`${k}`;S.push(`<source type="image/avif" srcset="${F0(P)}"${R?` sizes="${F0(R)}"`:""} />`)}if(z==="webp"||z==="auto"){let k=P5(J,w,N,B,"webp"),P=A?T7(J,A7,B,"webp"):`${k}`;S.push(`<source type="image/webp" srcset="${F0(P)}"${R?` sizes="${F0(R)}"`:""} />`)}return`${y}<picture>
1850
+ `).length;Y.set(q,{count:1,firstLine:U})}}}let G=[];for(let K of new Set([...Y.keys(),...J.keys()])){if(AK.has(K.toLowerCase()))continue;let q=Y.get(K)?.count??0,W=J.get(K)??0;if(q!==W)G.push({tag:K,opened:q,closed:W,firstOpenLine:Y.get(K)?.firstLine??0})}return G}function O7($,Z){let Y;try{Y=j8($)}catch{return}if(Y.length===0)return;let J=`${Z}:${$.length}`;if(B8.has(J))return;B8.add(J);let X=Z?Z.split(/[/\\]/).pop()||Z:"template";for(let{tag:Q,opened:G,closed:K,firstOpenLine:q}of Y)if(G>K){let W=q?` (first opened at line ${q})`:"";console.warn(`[stx] ${X}: <${Q}> ${G} opened, ${K} closed \u2014 an unclosed <${Q}>${W} may swallow the content that follows it.`)}else console.warn(`[stx] ${X}: <${Q}> ${G} opened, ${K} closed \u2014 ${K-G} stray </${Q}>.`)}var NK,AK,B8;var L7=b(()=>{NK=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),AK=new Set(["html","head","body","p","li","dt","dd","rt","rp","option","optgroup","thead","tbody","tfoot","tr","td","th","colgroup","caption"]);B8=new Set});import u0 from"path";import F7 from"fs";function O8($){return $.split("-").map((Z)=>Z.charAt(0).toUpperCase()+Z.slice(1)).join("")}function L8($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}class F8{builtins=new Map;registerBuiltin($){this.builtins.set($.name.toLowerCase(),$);for(let Z of $.aliases)this.builtins.set(Z.toLowerCase(),$)}isBuiltin($){return this.builtins.has($.toLowerCase())}getBuiltin($){return this.builtins.get($.toLowerCase())??null}async resolveFile($,Z,Y,J){let X=$.endsWith(".stx")?$.slice(0,-4):$,Q=J?.__importedComponents;if(Q){let B=[X,X.toLowerCase(),O8(X),L8(X)];for(let j of B)if(Q.has(j))return Q.get(j)}let G=[...new Set([`${X}.stx`,`${O8(X)}.stx`,`${L8(X)}.stx`])];if(X.startsWith("./")||X.startsWith("../")){let B=u0.resolve(u0.dirname(Z),`${X}.stx`);if(await l(B))return B;return null}let K=[],q=Y.componentsDir||"",W=J?.__originalFilePath;if(W)K.push(u0.join(u0.dirname(W),"components"));if(q)K.push(q);let z=u0.join(u0.dirname(Z),"components");if(!K.includes(z))K.push(z);let U=process.cwd(),_=[u0.resolve(U,"src/components"),u0.resolve(U,"components"),u0.resolve(import.meta.dir,"components")];for(let B of _)if(!K.includes(B))K.push(B);for(let B of K){if(!B)continue;for(let j of G){let H=u0.join(B,j);if(await l(H))return H}try{if(!F7.statSync(B,{throwIfNoEntry:!1})?.isDirectory())continue;let H=F7.readdirSync(B,{withFileTypes:!0});for(let L of H)if(L.isDirectory()){let F=u0.join(B,L.name);for(let O of G){let V=u0.join(F,O);if(await l(V))return V}}}catch{}}return null}}var C0;var V7=b(()=>{A0();C0=new F8});function O1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function RK($){if($.clientReactive.to)return{value:$.clientReactive.to,reactive:!0};if($.serverDynamic.to!==void 0)return{value:String($.serverDynamic.to),reactive:!1};if(typeof $.static.to==="string")return{value:$.static.to,reactive:!1};return{value:"#",reactive:!1}}var w7;var N7=b(()=>{w7={name:"StxLink",aliases:["stx-link"],render($,Z,Y){let J=RK($),X=(typeof $.static.class==="string"?$.static.class:"")||(typeof $.static.className==="string"?$.static.className:""),Q=typeof $.static.activeClass==="string"?$.static.activeClass:"active",G=typeof $.static.exactActiveClass==="string"?$.static.exactActiveClass:"exact-active",K=$.static.prefetch===!0||$.static.prefetch==="true"||$.serverDynamic.prefetch===!0,q=[];if(J.reactive)q.push(`:href="${O1(J.value)}"`);else q.push(`href="${O1(J.value)}"`);if(X)q.push(`class="${O1(X)}"`);if(q.push("data-stx-link"),q.push(`data-stx-active-class="${O1(Q)}"`),q.push(`data-stx-exact-active-class="${O1(G)}"`),K)q.push("data-stx-prefetch");let W=new Set(["to","class","className","activeClass","exactActiveClass","prefetch"]);for(let[z,U]of Object.entries($.static)){if(W.has(z))continue;if(typeof U==="boolean"){if(U)q.push(O1(z))}else q.push(`${O1(z)}="${O1(U)}"`)}return`<a ${q.join(" ")}>${Z}</a>`}}});function F0($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function k0($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function R7($,Z,Y=!1){let J=$.serverDynamic[Z];if(J!==void 0)return J!==!1&&J!=="false";let X=$.static[Z];if(X!==void 0)return X!=="false"&&X!==!1;return Y}function V8($){if($.includes("(")||$.includes(","))return $;let Z=$.trim().split(/\s+/),Y=[];for(let J of Z)if(J.includes(":")){let[X,Q]=J.split(":"),G=TK[X];if(G)Y.push(`(max-width: ${G}px) ${Q}`);else{let K=Number.parseInt(X);if(!Number.isNaN(K))Y.push(`(max-width: ${K}px) ${Q}`)}}else Y.push(J);return Y.join(", ")}function T7($,Z,Y,J){return Z.map((X)=>`${P5($,X,void 0,Y,J)} ${X}w`).join(", ")}function MK($,Z,Y,J,X){return Z.map((Q)=>{let G=Y?Y*Q:void 0;return`${P5($,G,void 0,J,X)} ${Q}x`}).join(", ")}function P5($,Z,Y,J,X){if(!J||J==="local"||J==="static")return $;if(J==="cloudinary"){let Q=[];if(Z)Q.push(`w_${Z}`);if(Y)Q.push(`h_${Y}`);if(X)Q.push(`f_${X}`);Q.push("q_auto");let G=Q.join(",");return $.replace("/upload/",`/upload/${G}/`)}if(J==="imgix"){let Q=new URLSearchParams;if(Z)Q.set("w",String(Z));if(Y)Q.set("h",String(Y));if(X)Q.set("fm",X);Q.set("auto","format");let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}if(J==="bunny"){let Q=new URLSearchParams;if(Z)Q.set("width",String(Z));if(Y)Q.set("height",String(Y));if(X)Q.set("format",X);let G=$.includes("?")?"&":"?";return`${$}${G}${Q.toString()}`}return $}function IK($,Z,Y="#e5e7eb"){let J=`<svg xmlns="http://www.w3.org/2000/svg" width="${$}" height="${Z}"><rect width="100%" height="100%" fill="${Y}"/></svg>`;return`data:image/svg+xml;base64,${btoa(J)}`}var TK,A7,M7;var I7=b(()=>{TK={sm:640,md:768,lg:1024,xl:1280,"2xl":1536},A7=[320,640,768,1024,1280,1536,1920];M7={name:"StxImage",aliases:["stx-image","stx-img"],render($,Z,Y){let J=k0($,"src")||"",X=k0($,"alt")||"",Q=k0($,"width"),G=k0($,"height"),K=k0($,"sizes"),q=k0($,"srcset"),W=k0($,"densities"),z=k0($,"format"),U=k0($,"placeholder"),_=k0($,"placeholderColor")||"#e5e7eb",B=k0($,"provider"),j=k0($,"class")||k0($,"className")||"",H=k0($,"style")||"",L=k0($,"quality"),F=R7($,"lazy",!0),O=R7($,"preload",!1),V=R7($,"picture",!1)||!!z,w=Q?Number.parseInt(Q):void 0,N=G?Number.parseInt(G):void 0,A=q||"",R="";if(!A&&K)A=T7(J,A7,B,z),R=V8(K);else if(!A&&W){let S=W.split(/\s+/).map((k)=>Number.parseFloat(k.replace("x","")));A=MK(J,S,w,B,z)}else if(K)R=V8(K);let T=[];if(H)T.push(H);if(w&&N)T.push(`aspect-ratio:${w}/${N}`);if(U==="blur"||U==="color"||U==="thumbhash"){let S=IK(w||16,N||9,_);T.push(`background-image:url(${S})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat")}else if(U&&U!=="empty"&&U!=="none")T.push(`background-image:url(${F0(U)})`),T.push("background-size:cover"),T.push("background-repeat:no-repeat");let M=P5(J,w,N,B,z),I=[];if(I.push(`src="${F0(M)}"`),I.push(`alt="${F0(X)}"`),Q)I.push(`width="${F0(Q)}"`);if(G)I.push(`height="${F0(G)}"`);if(F)I.push('loading="lazy"');if(I.push('decoding="async"'),j)I.push(`class="${F0(j)}"`);if(T.length>0)I.push(`style="${F0(T.join(";"))}"`);if(A)I.push(`srcset="${F0(A)}"`);if(R)I.push(`sizes="${F0(R)}"`);let D=new Set(["src","alt","width","height","lazy","sizes","srcset","placeholder","placeholderColor","class","className","style","format","provider","quality","densities","preload","picture"]);for(let[S,k]of Object.entries($.static)){if(D.has(S))continue;if(typeof k==="boolean"){if(k)I.push(F0(S))}else I.push(`${F0(S)}="${F0(k)}"`)}let E=`<img ${I.join(" ")} />`,C="";if(O){let k=z==="webp"?"image/webp":z==="avif"?"image/avif":"";C=`<link rel="preload" as="image" href="${F0(M)}"${k?` type="${k}"`:""}${A?` imagesrcset="${F0(A)}"`:""}${R?` imagesizes="${F0(R)}"`:""} />
1851
+ `}if(V){let S=[];if(z==="avif"||z==="auto"){let k=P5(J,w,N,B,"avif"),P=A?T7(J,A7,B,"avif"):`${k}`;S.push(`<source type="image/avif" srcset="${F0(P)}"${R?` sizes="${F0(R)}"`:""} />`)}if(z==="webp"||z==="auto"){let k=P5(J,w,N,B,"webp"),P=A?T7(J,A7,B,"webp"):`${k}`;S.push(`<source type="image/webp" srcset="${F0(P)}"${R?` sizes="${F0(R)}"`:""} />`)}return`${C}<picture>
1852
1852
  ${S.join(`
1853
1853
  `)}
1854
1854
  ${E}
1855
- </picture>`}return`${y}${E}`}}});function L1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function a1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var DK="<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'/images/safe-image-default.svg';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>",D7;var E7=b(()=>{D7={name:"SafeImage",aliases:["safe-image","safe-img"],render($,Z,Y){let J=a1($,"src")||"",X=a1($,"alt")||"",Q=a1($,"fallback")||"/images/safe-image-default.svg",G=a1($,"class")||a1($,"className")||"",K=a1($,"fallbackClassName")||"",q=[];if(q.push(`src="${L1(J)}"`),q.push(`alt="${L1(X)}"`),G)q.push(`class="${L1(G)}"`);if(q.push(`data-fallback="${L1(Q)}"`),K)q.push(`data-fallback-class="${L1(K)}"`);q.push('onerror="window.__stxSafeImageHandler(this)"');let W=new Set(["src","alt","fallback","class","className","fallbackClassName"]);for(let[_,B]of Object.entries($.static)){if(W.has(_))continue;if(typeof B==="boolean"){if(B)q.push(L1(_))}else q.push(`${L1(_)}="${L1(B)}"`)}let z=`<img ${q.join(" ")} />`,U=Y.context;if(!U.__safeImageHandlerEmitted)return U.__safeImageHandlerEmitted=!0,`${DK}${z}`;return z}}});function k7($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function v5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function R$($,Z,Y){let J=v5($,Z);if(J!==void 0){let X=Number.parseInt(J,10);if(!Number.isNaN(X))return X}return Y}var b7;var S7=b(()=>{b7={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let J=k7(v5($,"color")||"#6366f1"),X=k7(v5($,"initialColor")||v5($,"initial-color")||""),Q=k7(v5($,"height")||"3px"),G=R$($,"duration",2000),K=R$($,"throttle",200),q=R$($,"zIndex",999999)||R$($,"z-index",999999),W=X?`linear-gradient(to right, ${X}, ${J})`:J;return`
1855
+ </picture>`}return`${C}${E}`}}});function L1($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function a1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}var DK="<script>window.__stxSafeImageHandler||(window.__stxSafeImageHandler=function(i){if(i.__stx_fb)return;i.__stx_fb=1;var f=i.getAttribute('data-fallback')||'/images/safe-image-default.svg';var c=i.getAttribute('data-fallback-class');i.src=f;if(c)i.className=c;});</script>",D7;var E7=b(()=>{D7={name:"SafeImage",aliases:["safe-image","safe-img"],render($,Z,Y){let J=a1($,"src")||"",X=a1($,"alt")||"",Q=a1($,"fallback")||"/images/safe-image-default.svg",G=a1($,"class")||a1($,"className")||"",K=a1($,"fallbackClassName")||"",q=[];if(q.push(`src="${L1(J)}"`),q.push(`alt="${L1(X)}"`),G)q.push(`class="${L1(G)}"`);if(q.push(`data-fallback="${L1(Q)}"`),K)q.push(`data-fallback-class="${L1(K)}"`);q.push('onerror="window.__stxSafeImageHandler(this)"');let W=new Set(["src","alt","fallback","class","className","fallbackClassName"]);for(let[_,B]of Object.entries($.static)){if(W.has(_))continue;if(typeof B==="boolean"){if(B)q.push(L1(_))}else q.push(`${L1(_)}="${L1(B)}"`)}let z=`<img ${q.join(" ")} />`,U=Y.context;if(!U.__safeImageHandlerEmitted)return U.__safeImageHandlerEmitted=!0,`${DK}${z}`;return z}}});function k7($){return $.replace(/[;{}()]/g,"").replace(/url/gi,"")}function v5($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);let Y=$.static[Z];if(typeof Y==="string")return Y;return}function R$($,Z,Y){let J=v5($,Z);if(J!==void 0){let X=Number.parseInt(J,10);if(!Number.isNaN(X))return X}return Y}var b7;var S7=b(()=>{b7={name:"StxLoadingIndicator",aliases:["stx-loading-indicator"],render($,Z,Y){let J=k7(v5($,"color")||"#6366f1"),X=k7(v5($,"initialColor")||v5($,"initial-color")||""),Q=k7(v5($,"height")||"3px"),G=R$($,"duration",2000),K=R$($,"throttle",200),q=R$($,"zIndex",999999)||R$($,"z-index",999999),W=X?`linear-gradient(to right, ${X}, ${J})`:J;return`
1856
1856
  <div id="stx-loading-indicator" style="position:fixed;top:0;left:0;right:0;height:${Q};background:${W};z-index:${q};transform:scaleX(0);transform-origin:left;transition:transform 0.1s ease-out,opacity 0.3s ease;opacity:0;pointer-events:none">
1857
1857
  <div style="position:absolute;top:0;left:0;right:0;bottom:0;background:linear-gradient(90deg,transparent 0%,rgba(255,255,255,0.4) 50%,transparent 100%);animation:stx-shimmer 1.5s infinite"></div>
1858
1858
  </div>
@@ -1886,15 +1886,15 @@ ${E}
1886
1886
  .stx-drawer-backdrop[data-stx-drawer-open]{display:block!important;opacity:1}
1887
1887
  .stx-drawer-backdrop[data-stx-drawer-open] .stx-drawer-panel{transform:translateX(0)}
1888
1888
  </style>`}}});var I8={};o(I8,{preloadIconCollection:()=>M8,IconBuiltin:()=>M$});import{existsSync as kK,readFileSync as bK}from"fs";function T8($){try{return z0.resolve(`@iconify/json/json/${$}.json`)}catch{}let Z=process.cwd();for(let Y of[`${Z}/node_modules/@iconify/json/json/${$}.json`,`${Z}/pantry/@iconify/json/json/${$}.json`])if(kK(Y))return Y;return null}function SK($){if(v1.has($))return v1.get($);let Z=T8($);if(!Z)return null;try{let Y=JSON.parse(bK(Z,"utf8"));return v1.set($,Y.icons),Y.icons}catch{return null}}async function yK($){if(v1.has($))return v1.get($);let Z=T8($);if(!Z)return null;try{let Y=await Bun.file(Z).json();return v1.set($,Y.icons),Y.icons}catch{return null}}function e1($,Z){if($.serverDynamic[Z]!==void 0)return String($.serverDynamic[Z]);if($.static[Z]!==void 0)return String($.static[Z]);if($.clientReactive[Z]!==void 0)return $.clientReactive[Z];return}async function M8($="lucide"){await yK($)}var v1,M$;var I$=b(()=>{v1=new Map;M$={name:"Icon",aliases:["icon","stx-icon"],render($,Z,Y){let J=e1($,"name")??e1($,"icon");if(!J)return"<!-- Icon: missing name/icon prop -->";let X="lucide",Q=J;if(J.includes(":")){let O=J.split(":");X=O[0],Q=O[1]}let G=i0(e1($,"size")||"24"),K=i0(e1($,"color")||"currentColor"),q=i0(e1($,"class")||""),W=i0(e1($,"style")||""),z=v1.get(X)??SK(X);if(!z)return`<!-- Icon: collection "${X}" not loaded -->`;let U=z[Q];if(!U)return`<!-- Icon: "${Q}" not found in ${X} -->`;let _=U.width||24,B=U.height||24,j=`0 0 ${_} ${B}`,H=U.body;if(K!=="currentColor")H=H.replace(/currentColor/g,K);let L=q?` class="${q}"`:"",F=W?` style="${W}"`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${G}" height="${G}" viewBox="${j}" fill="none"${L}${F}>${H}</svg>`}}});function D8($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let J=$.static[Y];if(typeof J==="string")return J}return}function E8($,Z){let Y=new RegExp(`<(template|div|span)[^>]*\\bslot=["']${Z}["'][^>]*>([\\s\\S]*?)<\\/\\1>`,"i"),J=$.match(Y);if(!J)return{region:null,rest:$};return{region:J[2],rest:$.replace(J[0],"")}}var g7;var h7=b(()=>{g7={name:"Suspense",aliases:["suspense"],render($,Z,Y){let J=E8(Z,"fallback"),X=J.rest,Q=E8(X,"error"),G=Q.rest,K=J.region??D8($,"fallback")??'<div class="stx-suspense-loading">Loading\u2026</div>',q=Q.region??D8($,"errorFallback","error-fallback")??'<div class="stx-suspense-error">Something went wrong.</div>';return`<div data-stx-suspense><div data-stx-suspense-fallback>${K}</div><div data-stx-suspense-error hidden>${q}</div><div data-stx-suspense-content hidden>${G}</div></div>`}}});function D$($,...Z){for(let Y of Z){if($.serverDynamic[Y]!==void 0)return String($.serverDynamic[Y]);let J=$.static[Y];if(typeof J==="string")return J}return}var d7;var m7=b(()=>{d7={name:"TransitionGroup",aliases:["transition-group"],render($,Z,Y){let J=(D$($,"name")||"v").replace(/["'<>]/g,""),X=(D$($,"tag")||"div").replace(/[^a-z0-9-]/gi,"")||"div",Q=D$($,"class"),G=D$($,"id"),K=[`data-stx-transition-group="${J}"`,Q?`class="${Q}"`:"",G?`id="${G}"`:""].filter(Boolean).join(" ");return`<${X} ${K}>${Z}</${X}>`}}});function k8(){C0.registerBuiltin(w7),C0.registerBuiltin(M7),C0.registerBuiltin(D7),C0.registerBuiltin(b7),C0.registerBuiltin(y7),C0.registerBuiltin(P7),C0.registerBuiltin(x7),C0.registerBuiltin(M$),C0.registerBuiltin(g7),C0.registerBuiltin(d7)}var b8=b(()=>{N7();I7();E7();S7();C7();v7();f7();I$();h7();m7();V7();N7();I7();E7();S7();C7();v7();f7();I$();h7();m7()});function S8($){return $.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1-$2").toLowerCase()}function y8($,Z,Y){let J=[],X=0;while(X<$.length){let Q=$.indexOf("<",X);if(Q===-1)break;let K=$.slice(Q+1).match(new RegExp(`^(${Z.source})`));if(!K){X=Q+1;continue}let q=K[1];if(Y&&Y.has(q.toLowerCase())){let H=Q+1+q.length;while(H<$.length&&$[H]!==">")H++;X=H+1;continue}let W=Q+1+q.length,z=null,U=W,_=-1,B=!1;while(W<$.length){let H=$[W];if(z){if(H==="\\"&&W+1<$.length){W+=2;continue}if(H===z)z=null;W++;continue}if(H==='"'||H==="'"){z=H,W++;continue}if(H==="/"&&W+1<$.length&&$[W+1]===">"){_=W+2,B=!0;break}if(H===">"){_=W+1;break}W++}if(_===-1){X=Q+1;continue}let j=$.slice(U,B?_-2:_-1).trim();if(B)J.push({fullMatch:$.slice(Q,_),tagName:q,attributes:j,content:"",startIndex:Q,endIndex:_,isSelfClosing:!0}),X=_;else{let H=`<${q}`,L=`</${q}>`,F=1,O=_,V=-1;while(F>0&&O<$.length){let A=$.indexOf(H,O),R=$.indexOf(L,O);if(R===-1)break;if(A!==-1&&A<R){let T=$[A+H.length];if(T===" "||T===">"||T==="/"||T===`
1889
- `||T==="\t")F++;O=A+H.length}else{if(F--,F===0){V=R;break}O=R+L.length}}if(V===-1){X=_;continue}let w=$.slice(_,V),N=V+L.length;J.push({fullMatch:$.slice(Q,N),tagName:q,attributes:j,content:w,startIndex:Q,endIndex:N,isSelfClosing:!1}),X=N}}return J}function C8($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var P8=b(()=>{T0();A0();Y$()});var d8={};o(d8,{processESImports:()=>h8,processComponents:()=>k$});import E$ from"fs";import f0 from"path";function PK($,Z,Y){let J={static:{},serverDynamic:{},clientReactive:{},events:{}},X=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!X.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){J.events[q]=K;continue}if(q.startsWith("__stx_")){let W=Q(q.slice(6));J.serverDynamic[W]=C8(K,Y);continue}if(q.startsWith(":")){let W=Q(q.slice(1)),z=K==="true"?W:K;try{if(!X0(z)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${z}`);J.clientReactive[W]=z;continue}let U=Object.keys(Z),B=Q0(z,U)(...Object.values(Z));if(B===void 0){let j=z.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!U.includes(F))){J.clientReactive[W]=z;continue}}J.serverDynamic[W]=B}catch{J.clientReactive[W]=z}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let z=W[1];if(X0(z)){let _=Q0(z,Object.keys(Z))(...Object.values(Z));J.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${z}`);J.static[q]=K}}catch(z){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,z);J.static[q]=K}else{let z=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=U.exec(K))!==null)try{let B=_[1];if(!X0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=Q0(B,Object.keys(Z))(...Object.values(Z));z=z.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}J.static[q]=z}continue}J.static[q]=K}return J}function vK($){let Z={},Y=0,J=$.length;while(Y<J){while(Y<J&&/\s/.test($[Y]))Y++;if(Y>=J)break;let X="";while(Y<J&&!/[\s=]/.test($[Y]))X+=$[Y],Y++;if(!X)break;while(Y<J&&/\s/.test($[Y]))Y++;if(Y<J&&$[Y]==="="){Y++;while(Y<J&&/\s/.test($[Y]))Y++;let Q="";if(Y<J&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<J){let K=$[Y];if(K==="\\"&&Y+1<J){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<J&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[X]=Q}else Z[X]="true"}return Z}function x8($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xK($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Y.exec($))!==null){let X=J[1];if(C0.isBuiltin(X))Z.add(X)}return[...Z].sort()}function fK($){let Z=f8.get($);if(Z)return Z;let Y=new Map,J=[f0.join($,"src"),f0.join($,"dist"),$];function X(Q,G){if(G>6)return;let K;try{K=E$.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let q of K){let W=f0.join(Q,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;X(W,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let z=q.name.slice(0,-4);if(!Y.has(z))Y.set(z,W);let U=z.toLowerCase();if(!Y.has(U))Y.set(U,W);let _=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let Q of J)if(X(Q,0),Y.size>0)break;return f8.set($,Y),Y}function gK($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let J=f0.join(Y,"node_modules",$);try{if(E$.statSync(J).isDirectory())return J}catch{}let X=f0.dirname(Y);if(X===Y)return null;Y=X}}async function h8($,Z,Y,J,X){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=f0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(W,z,U)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=U,j,H=[];while((j=_.exec(U))!==null){let[L,F,O,V]=j,w=null,N=null;if(V.startsWith(".")||V.startsWith("/")){let T=f0.resolve(G,V);if(T.endsWith(".stx"))N=T;else{let M=`${T}.stx`;try{if(E$.statSync(M).isFile())N=M}catch{try{if(E$.statSync(T).isDirectory())w=T}catch{}}}}else w=gK(V,G);if(!w&&!N)continue;let A=!1,R=(T,M)=>{Q.set(T,M),Q.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,M),X.add(M)};if(O&&N)R(O,N),A=!0;else if(F){let T=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?fK(w):null;for(let{source:I,local:D}of T){let E=null;if(N)E=N;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)R(D,E),A=!0}}if(A)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return W;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${z}>${B}</script>`}),K}async function hK($,Z,Y,J,X){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[W,z]=q,U=z.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of U){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[f0.resolve(f0.dirname(Y),`${_}.stx`),f0.resolve(f0.dirname(Y),_),f0.resolve(J.componentsDir||"components",`${_}.stx`),f0.resolve(J.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),X.add(F),J.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(W,""),K.lastIndex=0}return Q}async function dK($,Z,Y,J,X){let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,W;while((W=q.exec(Q))!==null){let z=W.index,U=z+W[0].length-1,_=1,B=U+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(U+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let N={};if(O)try{N=R0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);Q=Q.replace(Q.substring(z,H),`[Error parsing component props: ${E}]`);continue}let A="",R=H,M=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)A=M[1].trim(),R=H+M[0].length;let I=await x1(F,N,A,G,Z,Y,J,K,X);Q=Q.substring(0,z)+I+Q.substring(R),q.lastIndex=0}return Q}async function mK($,Z,Y,J,X){if(!$)return $;let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=v4(Q);return Q=q.output,Q=await _(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await _(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await _(Q,/[a-z][a-z0-9]*/,!1,CK),Q=x4(Q,q.scripts),Q;async function _(B,j,H,L){if(!B)return B;let F=B,O=y8(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],N=H?S8(w.tagName):w.tagName,A=vK(w.attributes),R=PK(A,Z,J),T=C0.getBuiltin(w.tagName),M=T?await m8(N,G,Z,Y,J):!1;if(T&&!M){let y={context:Z,filePath:Y,options:J,dependencies:X},S=T.render(R,w.content,y);if(Object.keys(R.clientReactive).length>0)S=g8(S,R.clientReactive);if(Object.keys(R.events).length>0){let k=Object.entries(R.events).map(([P,h])=>`${P}="${x8(h)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${k}`)}F=F.substring(0,w.startIndex)+S+F.substring(w.endIndex);continue}let I={};for(let[y,S]of Object.entries(R.static))I[y]=S;for(let[y,S]of Object.entries(R.serverDynamic))I[y]=S;let E=await x1(N,I,w.content,G,Z,Y,J,K,X);if(Object.keys(R.clientReactive).length>0)E=g8(E,R.clientReactive);if(Object.keys(R.events).length>0){let y=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(y){let S=Object.entries(R.events).map(([P,h])=>`${P}="${x8(h)}"`).join(" "),k=y[1].length+y[2].length;E=E.substring(0,k)+" "+S+E.substring(k)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function g8($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let J=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),X=Y[1].length+Y[2].length;return $.substring(0,X)+" "+J+$.substring(X)}async function k$($,Z,Y,J,X){if(!v8)k8(),v8=!0;let Q=await h8($,Z,Y,J,X);Q=await hK(Q,Z,Y,J,X),Q=await dK(Q,Z,Y,J,X);for(let G=0;G<3;G++){let K=Q;if(Q=await mK(Q,Z,Y,J,X),Q===K)break}if(J.debug){let G=xK(Q);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var v8=!1,CK,f8;var u7=b(()=>{V7();b8();P8();A0();T0();CK=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);f8=new Map});var b$={};o(b$,{stripTypeScript:()=>i8,hasVariables:()=>a8,extractVariables:()=>P1,extractScriptFromTemplate:()=>r8,convertToCommonJS:()=>c7});import $5 from"path";import x5 from"process";function uK($){let Z=[],Y=0,J=$.split(`
1889
+ `||T==="\t")F++;O=A+H.length}else{if(F--,F===0){V=R;break}O=R+L.length}}if(V===-1){X=_;continue}let w=$.slice(_,V),N=V+L.length;J.push({fullMatch:$.slice(Q,N),tagName:q,attributes:j,content:w,startIndex:Q,endIndex:N,isSelfClosing:!1}),X=N}}return J}function C8($,Z){try{let Y=Buffer.from($,"base64").toString("utf8");return JSON.parse(Y)}catch{}try{let Y=$.replace(/&quot;/g,'"').replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&");return JSON.parse(Y)}catch(Y){if(Z?.debug)console.error("Error decoding __stx_ prop:",Y);return $}}var P8=b(()=>{T0();A0();Y$()});var d8={};o(d8,{processESImports:()=>h8,processComponents:()=>k$});import E$ from"fs";import f0 from"path";function PK($,Z,Y){let J={static:{},serverDynamic:{},clientReactive:{},events:{}},X=new Set(["x-cloak","x-show","x-if","x-for","x-data","x-init","x-transition","x-ref","x-effect","x-model","x-text","x-html","x-class","x-style","x-on","x-bind"]),Q=(G)=>{if(!G.includes("-")||G.startsWith("@")||G.startsWith(":")||G.startsWith("x-")||G.startsWith("__"))return G;return G.replace(/-([a-z0-9])/g,(K,q)=>q.toUpperCase())};for(let[G,K]of Object.entries($)){let q=G.startsWith("x-")&&!X.has(G)&&!G.startsWith("x-bind:")&&!G.startsWith("x-on:")?`:${G.slice(2)}`:G;if(q.startsWith("@")){J.events[q]=K;continue}if(q.startsWith("__stx_")){let W=Q(q.slice(6));J.serverDynamic[W]=C8(K,Y);continue}if(q.startsWith(":")){let W=Q(q.slice(1)),z=K==="true"?W:K;try{if(!X0(z)){if(Y.debug)console.error(`Unsafe expression in :${W} binding: ${z}`);J.clientReactive[W]=z;continue}let U=Object.keys(Z),B=Q0(z,U)(...Object.values(Z));if(B===void 0){let j=z.match(/\b[a-zA-Z_$][a-zA-Z0-9_$]*\b/g)||[],H=new Set(["true","false","null","undefined","typeof","instanceof","in","of","new","this","return","void","delete","throw","if","else"]);if(j.some((F)=>!H.has(F)&&!U.includes(F))){J.clientReactive[W]=z;continue}}J.serverDynamic[W]=B}catch{J.clientReactive[W]=z}continue}if(typeof K==="string"&&K.includes("{{")&&K.includes("}}")){let W=K.match(/^\{\{\s*([\s\S]+?)\s*\}\}$/);if(W)try{let z=W[1];if(X0(z)){let _=Q0(z,Object.keys(Z))(...Object.values(Z));J.static[q]=_!=null?String(_):""}else{if(Y.debug)console.error(`Unsafe expression in ${q}: ${z}`);J.static[q]=K}}catch(z){if(Y.debug)console.error(`Error evaluating expression for ${q}:`,z);J.static[q]=K}else{let z=K,U=/\{\{\s*([\s\S]+?)\s*\}\}/g,_;while((_=U.exec(K))!==null)try{let B=_[1];if(!X0(B)){if(Y.debug)console.error(`Unsafe expression in ${q}: ${B}`);continue}let H=Q0(B,Object.keys(Z))(...Object.values(Z));z=z.replace(_[0],String(H??""))}catch(B){if(Y.debug)console.error(`Error evaluating expression in ${q}:`,B)}J.static[q]=z}continue}J.static[q]=K}return J}function vK($){let Z={},Y=0,J=$.length;while(Y<J){while(Y<J&&/\s/.test($[Y]))Y++;if(Y>=J)break;let X="";while(Y<J&&!/[\s=]/.test($[Y]))X+=$[Y],Y++;if(!X)break;while(Y<J&&/\s/.test($[Y]))Y++;if(Y<J&&$[Y]==="="){Y++;while(Y<J&&/\s/.test($[Y]))Y++;let Q="";if(Y<J&&($[Y]==='"'||$[Y]==="'")){let G=$[Y];Y++;while(Y<J){let K=$[Y];if(K==="\\"&&Y+1<J){Y++,Q+=$[Y],Y++;continue}if(K===G){Y++;break}Q+=K,Y++}}else while(Y<J&&!/\s/.test($[Y]))Q+=$[Y],Y++;Z[X]=Q}else Z[X]="true"}return Z}function x8($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xK($){let Z=new Set,Y=/<([A-Z][A-Za-z0-9]*|stx-[a-z0-9-]+)\b[^>]*>/g,J;while((J=Y.exec($))!==null){let X=J[1];if(C0.isBuiltin(X))Z.add(X)}return[...Z].sort()}function fK($){let Z=f8.get($);if(Z)return Z;let Y=new Map,J=[f0.join($,"src"),f0.join($,"dist"),$];function X(Q,G){if(G>6)return;let K;try{K=E$.readdirSync(Q,{withFileTypes:!0})}catch{return}for(let q of K){let W=f0.join(Q,q.name);if(q.isDirectory()){if(q.name==="node_modules"||q.name.startsWith("."))continue;X(W,G+1)}else if(q.isFile()&&q.name.endsWith(".stx")){let z=q.name.slice(0,-4);if(!Y.has(z))Y.set(z,W);let U=z.toLowerCase();if(!Y.has(U))Y.set(U,W);let _=z.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(!Y.has(_))Y.set(_,W)}}}for(let Q of J)if(X(Q,0),Y.size>0)break;return f8.set($,Y),Y}function gK($,Z){if($.startsWith(".")||$.startsWith("/"))return null;let Y=Z;while(!0){let J=f0.join(Y,"node_modules",$);try{if(E$.statSync(J).isDirectory())return J}catch{}let X=f0.dirname(Y);if(X===Y)return null;Y=X}}async function h8($,Z,Y,J,X){if(!$.includes("import"))return $;if(!Z.__importedComponents)Z.__importedComponents=new Map;let Q=Z.__importedComponents,G=f0.dirname(Y),K=$,q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi;return K=K.replace(q,(W,z,U)=>{let _=/import\s+(?:(\{[^}]*\})|([A-Za-z_$][\w$]*))\s+from\s+['"]([^'"]+)['"]\s*;?\s*\n?/g,B=U,j,H=[];while((j=_.exec(U))!==null){let[L,F,O,V]=j,w=null,N=null;if(V.startsWith(".")||V.startsWith("/")){let T=f0.resolve(G,V);if(T.endsWith(".stx"))N=T;else{let M=`${T}.stx`;try{if(E$.statSync(M).isFile())N=M}catch{try{if(E$.statSync(T).isDirectory())w=T}catch{}}}}else w=gK(V,G);if(!w&&!N)continue;let A=!1,R=(T,M)=>{Q.set(T,M),Q.set(T.toLowerCase(),M);let I=T.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();Q.set(I,M),X.add(M)};if(O&&N)R(O,N),A=!0;else if(F){let T=F.slice(1,-1).split(",").map((I)=>I.trim()).filter(Boolean).map((I)=>{let D=I.match(/^([A-Za-z_$][\w$]*)\s+as\s+([A-Za-z_$][\w$]*)$/);if(D)return{source:D[1],local:D[2]};return{source:I,local:I}}),M=w?fK(w):null;for(let{source:I,local:D}of T){let E=null;if(N)E=N;else if(M)E=M.get(I)??M.get(I.toLowerCase())??M.get(I.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase())??null;if(E)R(D,E),A=!0}}if(A)H.push({start:j.index,end:j.index+L.length})}if(H.length===0)return W;for(let L=H.length-1;L>=0;L--)B=B.slice(0,H[L].start)+B.slice(H[L].end);return`<script${z}>${B}</script>`}),K}async function hK($,Z,Y,J,X){let Q=$;if(!Z.__importedComponents)Z.__importedComponents=new Map;let G=Z.__importedComponents,K=/@import\s*\(\s*([^)]+)\s*\)/g,q;while((q=K.exec(Q))!==null){let[W,z]=q,U=z.split(",").map((_)=>_.trim().replace(/^['"]|['"]$/g,"")).filter((_)=>_.length>0);for(let _ of U){let B=_.split("/"),H=B[B.length-1].replace(/\.stx$/,""),L=H.includes("-")?H.split("-").map((V)=>V.charAt(0).toUpperCase()+V.slice(1)).join(""):H.charAt(0).toUpperCase()+H.slice(1),F=null,O=[f0.resolve(f0.dirname(Y),`${_}.stx`),f0.resolve(f0.dirname(Y),_),f0.resolve(J.componentsDir||"components",`${_}.stx`),f0.resolve(J.componentsDir||"components",_),_.endsWith(".stx")?_:`${_}.stx`];for(let V of O)try{if(await Bun.file(V).exists()){F=V;break}}catch{}if(F){G.set(L,F),G.set(H,F),G.set(H.toLowerCase(),F);let V=L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();if(G.set(V,F),X.add(F),J.debug)console.log(`Imported component: ${L} -> ${F}`)}else if(J.debug)console.warn(`Could not resolve imported component: ${_}`)}Q=Q.replace(W,""),K.lastIndex=0}return Q}async function dK($,Z,Y,J,X){let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=/@component\s*\(/g,W;while((W=q.exec(Q))!==null){let z=W.index,U=z+W[0].length-1,_=1,B=U+1;while(B<Q.length&&_>0){if(Q[B]==="(")_++;else if(Q[B]===")"){if(_--,_===0)break}B++}if(_!==0)break;let j=Q.substring(U+1,B),H=B+1,L=j.match(/^\s*['"]([^'"]+)['"]/);if(!L){q.lastIndex=0;continue}let F=L[1],O,V=j.slice(L[0].length),w=V.match(/^\s*,\s*/);if(w)O=V.slice(w[0].length).trim();let N={};if(O)try{N=R0(O,Z)}catch(D){let E=D instanceof Error?D.message:String(D);Q=Q.replace(Q.substring(z,H),`[Error parsing component props: ${E}]`);continue}let A="",R=H,M=Q.substring(H).match(/^([\s\S]*?)@endcomponent/);if(M)A=M[1].trim(),R=H+M[0].length;let I=await x1(F,N,A,G,Z,Y,J,K,X);Q=Q.substring(0,z)+I+Q.substring(R),q.lastIndex=0}return Q}async function mK($,Z,Y,J,X){if(!$)return $;let Q=$,G=J.componentsDir||"components";if(!Z.__processedComponents)Z.__processedComponents=new Set;let K=Z.__processedComponents,q=v4(Q);return Q=q.output,Q=await _(Q,/[a-z][a-z0-9]*-[a-z0-9-]*/,!1),Q=await _(Q,/[A-Z][a-zA-Z0-9]*/,!0),Q=await _(Q,/[a-z][a-z0-9]*/,!1,CK),Q=x4(Q,q.scripts),Q;async function _(B,j,H,L){if(!B)return B;let F=B,O=y8(F,j,L);for(let V=O.length-1;V>=0;V--){let w=O[V],N=H?S8(w.tagName):w.tagName,A=vK(w.attributes),R=PK(A,Z,J),T=C0.getBuiltin(w.tagName),M=T?await m8(N,G,Z,Y,J):!1;if(T&&!M){let C={context:Z,filePath:Y,options:J,dependencies:X},S=T.render(R,w.content,C);if(Object.keys(R.clientReactive).length>0)S=g8(S,R.clientReactive);if(Object.keys(R.events).length>0){let k=Object.entries(R.events).map(([P,h])=>`${P}="${x8(h)}"`).join(" ");S=S.replace(/^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/,`$1 ${k}`)}F=F.substring(0,w.startIndex)+S+F.substring(w.endIndex);continue}let I={};for(let[C,S]of Object.entries(R.static))I[C]=S;for(let[C,S]of Object.entries(R.serverDynamic))I[C]=S;let E=await x1(N,I,w.content,G,Z,Y,J,K,X);if(Object.keys(R.clientReactive).length>0)E=g8(E,R.clientReactive);if(Object.keys(R.events).length>0){let C=E.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(C){let S=Object.entries(R.events).map(([P,h])=>`${P}="${x8(h)}"`).join(" "),k=C[1].length+C[2].length;E=E.substring(0,k)+" "+S+E.substring(k)}}F=F.substring(0,w.startIndex)+E+F.substring(w.endIndex)}return F}}function g8($,Z){let Y=$.match(/^(\s*<)([a-zA-Z][a-zA-Z0-9-]*)(\s|>|\/)/s);if(!Y)return $;let J=Object.entries(Z).map(([Q,G])=>`:${Q}="${G.replace(/"/g,"&quot;")}"`).join(" "),X=Y[1].length+Y[2].length;return $.substring(0,X)+" "+J+$.substring(X)}async function k$($,Z,Y,J,X){if(!v8)k8(),v8=!0;let Q=await h8($,Z,Y,J,X);Q=await hK(Q,Z,Y,J,X),Q=await dK(Q,Z,Y,J,X);for(let G=0;G<3;G++){let K=Q;if(Q=await mK(Q,Z,Y,J,X),Q===K)break}if(J.debug){let G=xK(Q);if(G.length>0)console.warn(`[stx] ${Y}: unresolved component tag(s) after render passes: ${G.join(", ")}. Check nested component output for malformed root tags or recursive component markup.`)}return Q}var v8=!1,CK,f8;var u7=b(()=>{V7();b8();P8();A0();T0();CK=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","path","circle","rect","line","polygon","polyline","ellipse","text","tspan","textPath","g","defs","use","symbol","image","clipPath","mask","pattern","marker","linearGradient","radialGradient","stop","filter","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","foreignObject","animate","animateMotion","animateTransform","set","mpath","desc","metadata","switch","view"]);f8=new Map});var b$={};o(b$,{stripTypeScript:()=>i8,hasVariables:()=>a8,extractVariables:()=>P1,extractScriptFromTemplate:()=>r8,convertToCommonJS:()=>c7});import $5 from"path";import x5 from"process";function uK($){let Z=[],Y=0,J=$.split(`
1890
1890
  `);for(let X of J){let Q=Y,G=null,K=!1;for(let q=0;q<X.length;q++){let W=X[q];if(K){K=!1;continue}if(W==="\\"){K=!0;continue}if(G){if(W===G)G=null;continue}if(W==="'"||W==='"'||W==="`"){G=W;continue}if(W==="/"&&q+1<X.length&&X[q+1]==="/")break;if(W==="{")Y++;else if(W==="}")Y--}if(Q===0){let q=X.match(/(?:const|let|var)\s+(\w+)\s*=/);if(q)Z.push(q[1]);else if(/^\s*(?:const|let|var)\s+\w+\s*;?\s*$/.test(X)){let W=X.match(/(?:const|let|var)\s+(\w+)/);if(W)Z.push(W[1])}else{let W=X.match(/(?:const|let|var)\s+(\{[^}]+\}|\[[^\]]+\])\s*=/);if(W){let U=W[1].slice(1,-1).split(",").map((_)=>{let B=_.split(":");return(B.length>1?B[1]:B[0]).trim()}).filter((_)=>/^\w+$/.test(_));Z.push(...U)}}}}return[...new Set(Z)]}function i8($){let Z=$;Z=Z.replace(/^\s*import\s+.*?from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*import\s+['"][^'"]+['"]\s*;?\s*$/gm,""),Z=Z.replace(/^\s*interface\s+\w+\s*\{[\s\S]*?\n\}\s*$/gm,""),Z=Z.replace(/^\s*type\s+\w+\s*=[\s\S]*?(?=\n(?:const|let|var|function|export|interface|type|$))/gm,""),Z=Z.replace(/^(\s*(?:export\s+)?(?:const|let|var)\s+)(\w+|\{[^}]+\}|\[[^\]]+\])\s*:\s*[^=]+(\s*=)/gm,"$1$2$3");function Y(J){if(!J.includes(":"))return J;let X=[],Q="",G=0,K=0,q=null;for(let W=0;W<J.length;W++){let z=J[W];if(q){if(Q+=z,z===q)q=null;continue}if(z==='"'||z==="'"||z==="`"){q=z,Q+=z;continue}if(z==="<")G++;else if(z===">"&&G>0)G--;else if(z==="(")K++;else if(z===")")K--;if(z===","&&G===0&&K===0){X.push(Q),Q="";continue}Q+=z}if(Q)X.push(Q);return X.map((W)=>{let z=W.trim(),U=z.startsWith("..."),_=U?z.slice(3):z,B=-1,j=0;for(let N=0;N<_.length;N++)if(_[N]==="<")j++;else if(_[N]===">")j--;else if(_[N]===":"&&j===0){B=N;break}if(B===-1)return W;let L=_.substring(0,B).trim().replace(/\?$/,""),F=_.substring(B+1),O=-1,V=0;for(let N=0;N<F.length;N++)if(F[N]==="<")V++;else if(F[N]===">")V--;else if(F[N]==="="&&V===0){O=N;break}let w=U?"...":"";if(O!==-1)return`${w}${L} = ${F.substring(O+1).trim()}`;return`${w}${L}`}).join(", ")}Z=Z.replace(/\b(function\s+\w*\s*)\(([^)]*)\)/g,(J,X,Q)=>{if(!Q.includes(":"))return J;return`${X}(${Y(Q)})`});{let J=/\b(function\s+\w*\s*)\(/g,X,Q=[];while((X=J.exec(Z))!==null){let G=X.index+X[0].length-1,K=1,q=G+1,W=0,z=null;while(q<Z.length&&K>0){let B=Z[q];if(z){if(B===z)z=null;q++;continue}if(B==='"'||B==="'"||B==="`"){z=B,q++;continue}if(B==="<")W++;else if(B===">"&&W>0)W--;else if(W===0){if(B==="(")K++;else if(B===")")K--}if(K>0)q++}if(K!==0)continue;let U=Z.substring(G+1,q);if(!U.includes(":"))continue;let _=Y(U);Q.push({start:G+1,end:q,replacement:_})}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=Q[G];Z=Z.substring(0,K)+W+Z.substring(q)}}return Z=Z.replace(/\(([^)]*)\)\s*(?::\s*[^=]+)?\s*=>/g,(J,X)=>{if(!X.includes(":"))return J;if(X.includes("{")||X.includes("}"))return J;return`(${X.split(",").map((G)=>{let[K,...q]=G.split("="),W=K.split(":")[0].trim();if(q.length>0)return`${W} = ${q.join("=").trim()}`;return W}).join(", ")}) =>`}),Z=Z.replace(/(\))\s*:\s*([A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined)(?:<[^>]+>)?(?:\s*\|\s*(?:[A-Z]\w*|void|string|number|boolean|any|unknown|never|null|undefined))*\s*(\{)/g,"$1$3"),Z=Z.replace(/(\b(?:function|class|interface|type|extends|implements)\s+\w+)\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\b(?:defineProps|withDefaults|defineEmits|defineSlots|Array|Promise|Map|Set|Record|Partial|Required|Readonly|Pick|Omit|Exclude|Extract))\s*<[^<>()]*>/g,"$1"),Z=Z.replace(/(\w+)\s*<[A-Z][^<>()]*>\s*(?=\()/g,"$1"),Z=Z.replace(/\s+as\s+(?:const|[A-Za-z]\w*(?:\[\])?(?:\s*\|\s*\w+(?:\[\])?)*)/g,""),Z=Z.replace(/\s+satisfies\s+\w+(?:<[^>]*>)?/g,""),Z=Z.replace(/(\w|\)|\])\s*!(?!=)/g,"$1"),Z=Z.replace(/^\s*(?:export\s+)?(?:const\s+)?enum\s+\w+\s*\{[^}]*\}\s*$/gm,""),Z=Z.replace(/(?<=[\s=,(])<[A-Z]\w*(?:\[\])?>/g,""),Z=Z.replace(/\n\s*\n\s*\n/g,`
1891
1891
 
1892
- `),Z}async function P1($,Z,Y,J={}){if(!$.trim())return;let X;try{let C=new Bun.Transpiler({loader:"ts",target:"browser",define:r0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=C.transformSync(v)}catch{X=i8($)}let Q={exports:{}},G=Q.exports,K=x5.cwd(),q={},W=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((C)=>C[1]).filter((C)=>!C.startsWith("node:")&&!C.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(C));for(let C of W)try{let v=$5.resolve(K,"node_modules",C),x=$5.join(v,"package.json"),g=JSON.parse(z0("fs").readFileSync(x,"utf8")),u=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")u=s;else if(s?.bun)u=s.bun;else if(s?.import)u=s.import;else if(s?.default)u=s.default}q[C]=await import($5.resolve(v,u))}catch{}let z=(C)=>{if(q[C])return q[C];return z0(C)},U=Z.props||{},_=Object.assign((C)=>{if(!C)return U;let v={};for(let[x,g]of Object.entries(C)){let u=U[x];if(u!==void 0)v[x]=u;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},U),B=(C)=>{if(!C)return U;let v={...U};for(let[x,g]of Object.entries(C)){let u=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&u.default!==void 0)v[x]=typeof u.default==="function"?u.default():u.default}return v},j=()=>Z.slots||{},H=(C,v)=>{let x={...C};for(let[g,u]of Object.entries(v))if(x[g]===void 0)if(typeof u==="function")x[g]=u();else x[g]=u;return x},L=(C)=>{let v=()=>C;return v.set=(x)=>{},v.update=(x)=>{},v},F=(C)=>{let v,x=!1;return()=>{if(!x)try{v=C(),x=!0}catch{v=void 0}return v}},O=(C)=>{},V=(C)=>C(),w=(C)=>{},N=(C)=>{},A=(C)=>{},R=()=>({params:{},query:{},path:"",name:"",fullPath:"",hash:"",matched:[]}),T=()=>({push:(C)=>{},replace:(C)=>{},back:()=>{},forward:()=>{},go:(C)=>{}}),M=(C)=>{y1(C);let v=Z.__stx_runtime_head||{},x=C||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(C)=>{V$(C);let v=D5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(C)=>({value:C}),E=(C)=>C,y=(C)=>({value:typeof C==="function"?C():C}),S=(C,v)=>{},k=(C)=>{},P=(C)=>{},h=(C)=>C?C():Promise.resolve(),f=(C)=>(v,...x)=>{},m=(C)=>{},c=(C,v)=>{},Y0=(C,v)=>v,K0=()=>({value:"light"}),O0=()=>({value:!1}),B0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},$0=new Proxy(B0,{get(C,v){if(v in C)return C[v];return},set(C,v,x){return C[v]=x,!0}}),N0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},H0=console;try{let C=c7(X,Y),v=new Set(Object.keys(U)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),u=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),s=[],q0=[];for(let[t,s0]of Object.entries(U)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(u.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(C))continue;s.push(t),q0.push(s0)}let v0=uK(C).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
1892
+ `),Z}async function P1($,Z,Y,J={}){if(!$.trim())return;let X;try{let y=new Bun.Transpiler({loader:"ts",target:"browser",define:r0()}),v=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");v=v.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,""),X=y.transformSync(v)}catch{X=i8($)}let Q={exports:{}},G=Q.exports,K=x5.cwd(),q={},W=[...X.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g)||[]].map((y)=>y[1]).filter((y)=>!y.startsWith("node:")&&!y.startsWith(".")&&!["fs","path","os","child_process","crypto","http","https","url","util","stream","events","buffer","net","querystring","zlib","tls"].includes(y));for(let y of W)try{let v=$5.resolve(K,"node_modules",y),x=$5.join(v,"package.json"),g=JSON.parse(z0("fs").readFileSync(x,"utf8")),u=g.main||"index.js";if(g.exports){let s=typeof g.exports==="string"?g.exports:g.exports["."];if(typeof s==="string")u=s;else if(s?.bun)u=s.bun;else if(s?.import)u=s.import;else if(s?.default)u=s.default}q[y]=await import($5.resolve(v,u))}catch{}let z=(y)=>{if(q[y])return q[y];return z0(y)},U=Z.props||{},_=Object.assign((y)=>{if(!y)return U;let v={};for(let[x,g]of Object.entries(y)){let u=U[x];if(u!==void 0)v[x]=u;else if(typeof g==="function")v[x]=g();else v[x]=g}return v},U),B=(y)=>{if(!y)return U;let v={...U};for(let[x,g]of Object.entries(y)){let u=g&&typeof g==="object"&&!Array.isArray(g)?g:{type:g};if(v[x]===void 0&&u.default!==void 0)v[x]=typeof u.default==="function"?u.default():u.default}return v},j=()=>Z.slots||{},H=(y,v)=>{let x={...y};for(let[g,u]of Object.entries(v))if(x[g]===void 0)if(typeof u==="function")x[g]=u();else x[g]=u;return x},L=(y)=>{let v=()=>y;return v.set=(x)=>{},v.update=(x)=>{},v},F=(y)=>{let v,x=!1;return()=>{if(!x)try{v=y(),x=!0}catch{v=void 0}return v}},O=(y)=>{},V=(y)=>y(),w=(y)=>{},N=(y)=>{},A=(y)=>{},R=()=>{let y=Z.__stxServeContext,v=Z.__stxServeSearch??y?.search??"",x=y?.path??"";return{params:Z.params??{},query:Object.fromEntries(new URLSearchParams(v)),path:x,name:"",fullPath:x+v,hash:"",matched:[]}},T=()=>({push:(y)=>{},replace:(y)=>{},back:()=>{},forward:()=>{},go:(y)=>{}}),M=(y)=>{y1(y);let v=Z.__stx_runtime_head||{},x=y||{};Z.__stx_runtime_head={...v,...x.title&&{title:x.title},meta:[...v.meta||[],...x.meta||[]],link:[...v.link||[],...x.link||[]],script:[...v.script||[],...x.script||[]],htmlAttrs:{...v.htmlAttrs||{},...x.htmlAttrs||{}},bodyAttrs:{...v.bodyAttrs||{},...x.bodyAttrs||{}}}},I=(y)=>{V$(y);let v=D5();Z.__stx_runtime_head={...Z.__stx_runtime_head||{},...v.title&&{title:v.title},meta:v.meta?[...v.meta]:[]}},D=(y)=>({value:y}),E=(y)=>y,C=(y)=>({value:typeof y==="function"?y():y}),S=(y,v)=>{},k=(y)=>{},P=(y)=>{},h=(y)=>y?y():Promise.resolve(),f=(y)=>(v,...x)=>{},m=(y)=>{},c=(y,v)=>{},Y0=(y,v)=>v,K0=()=>({value:"light"}),O0=()=>({value:!1}),B0={siteId:void 0,API_ENDPOINT:"",ANALYTICS_SITE_ID:void 0,location:{href:"",pathname:"",search:"",hash:"",origin:"",host:"",hostname:"",protocol:"https:",assign:()=>{},replace:()=>{},reload:()=>{}},localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},sessionStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{},clear:()=>{}},fetch:globalThis.fetch,addEventListener:()=>{},removeEventListener:()=>{},setTimeout:()=>0,clearTimeout:()=>{},setInterval:()=>0,clearInterval:()=>{},requestAnimationFrame:()=>0,cancelAnimationFrame:()=>{},alert:()=>{},confirm:()=>!1,prompt:()=>null,getComputedStyle:()=>({}),matchMedia:()=>({matches:!1,addListener:()=>{},removeListener:()=>{}}),getDateRangeParams:()=>"",stx:{}},$0=new Proxy(B0,{get(y,v){if(v in y)return y[v];return},set(y,v,x){return y[v]=x,!0}}),N0={getElementById:()=>null,querySelector:()=>null,querySelectorAll:()=>[],createElement:()=>({}),createTextNode:()=>({}),body:{},head:{},documentElement:{},addEventListener:()=>{},removeEventListener:()=>{}},H0=console;try{let y=c7(X,Y),v=new Set(Object.keys(U)),x=Object.keys(Z).filter((t)=>!v.has(t)&&t!=="props"),g=x.map((t)=>Z[t]),u=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","let","new","return","super","switch","this","throw","try","typeof","var","void","while","with","yield","enum","await","async","module","exports","require","params","window","document","console","state","derived","effect"]),s=[],q0=[];for(let[t,s0]of Object.entries(U)){if(!/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(t))continue;if(u.has(t))continue;if(new RegExp(`(?:^|[\\s;{])(?:const|let|var|function)\\s+${t}\\b`).test(y))continue;s.push(t),q0.push(s0)}let v0=uK(y).map((t)=>`module.exports.${t} = typeof ${t} !== 'undefined' ? ${t} : module.exports.${t};`).join(`
1893
1893
  `),A1=Z.params??{},_0=[],R1=[];for(let t=0;t<x.length;t++){if(x[t]==="params")continue;_0.push(x[t]),R1.push(g[t])}let n5=await Function("module","exports","require","props","$props","defineProps","withDefaults","state","derived","effect","batch","onMount","onDestroy","definePageMeta","useRoute","useRouter","useHead","useSeoMeta","ref","reactive","computed","watch","onMounted","onUnmounted","nextTick","defineEmits","defineExpose","defineSlots","provide","inject","useColorMode","useDark","window","document","console","confirm","alert","fetch","params",...s,..._0,`return (async () => {
1894
- ${C}
1894
+ ${y}
1895
1895
  ${v0}
1896
1896
  return module.exports
1897
- })()`)(Q,G,z,U,_,B,H,L,F,O,V,w,N,A,R,T,M,I,D,E,y,S,k,P,h,f,m,j,c,Y0,K0,O0,$0,N0,H0,B0.confirm,B0.alert,B0.fetch,A1,...q0,...R1);if(J.preserveExisting){for(let[t,s0]of Object.entries(n5))if(!(t in Z)||Z[t]===void 0)Z[t]=s0}else Object.assign(Z,n5);for(let[t,s0]of Object.entries(U))if(!(t in Z))Z[t]=s0}catch(C){if(x5.env.STX_DEBUG){let v=C instanceof Error?C.message:String(C);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await nK(X,Z,Y)}catch(v){if(x5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function c7($,Z){let Y=Z?$5.dirname(Z):x5.cwd(),J=$.split(`
1897
+ })()`)(Q,G,z,U,_,B,H,L,F,O,V,w,N,A,R,T,M,I,D,E,C,S,k,P,h,f,m,j,c,Y0,K0,O0,$0,N0,H0,B0.confirm,B0.alert,B0.fetch,A1,...q0,...R1);if(J.preserveExisting){for(let[t,s0]of Object.entries(n5))if(!(t in Z)||Z[t]===void 0)Z[t]=s0}else Object.assign(Z,n5);for(let[t,s0]of Object.entries(U))if(!(t in Z))Z[t]=s0}catch(y){if(x5.env.STX_DEBUG){let v=y instanceof Error?y.message:String(y);console.warn(`[stx] server <script> did not execute in ${Y??"<unknown>"} \u2014 falling back to static extraction. Cause: ${v}`)}try{await nK(X,Z,Y)}catch(v){if(x5.env.STX_DEBUG){let x=v instanceof Error?v.message:String(v);console.warn(`[stx] fallback extraction also failed in ${Y??"<unknown>"}: ${x}`)}}}}function c7($,Z){let Y=Z?$5.dirname(Z):x5.cwd(),J=$.split(`
1898
1898
  `),X=[],Q=0;while(Q<J.length){let G=J[Q].trim();if(G.startsWith("interface ")||G.startsWith("export interface ")||G.startsWith("type ")||G.startsWith("export type ")){if(G.includes("{")&&!G.includes("}")){let K=0;for(;Q<J.length;Q++){for(let q of J[Q])if(q==="{")K++;else if(q==="}")K--;if(K<=0)break}}Q++;continue}if(G.startsWith("definePageMeta(")){let K=0,q=!1;for(let W=Q;W<J.length&&!q;W++){let z=null,U=!1,_=J[W];for(let B=0;B<_.length;B++){let j=_[B];if(U){U=!1;continue}if(j==="\\"){U=!0;continue}if(z){if(j===z)z=null;continue}if(j==='"'||j==="'"||j==="`"){z=j;continue}if(j==="(")K++;else if(j===")"){if(K--,K===0){Q=W+1,q=!0;break}}}}if(!q)Q=J.length;continue}if(G.startsWith("import ")){let K=G.match(/^import\s+(\w+)\s+from\s+['"](.+)['"]/),q=G.match(/^import\s+\{([^}]+)\}\s+from\s+['"](.+)['"]/),W=G.match(/^import\s+['"](.+)['"]/),z=(U)=>{if(U.startsWith("."))return $5.resolve(Y,U);return U};if(K){let[,U,_]=K,B=z(_);X.push(`const ${U} = await import('${B}')`),X.push(`module.exports.${U} = ${U};`)}else if(q){let[,U,_]=q,B=U.trim(),j=z(_);X.push(`const { ${B} } = await import('${j}')`);for(let H of B.split(",")){let L=H.trim().split(/\s+as\s+/).pop()?.trim();if(L)X.push(`module.exports.${L} = ${L};`)}}else if(W){let U=z(W[1]);X.push(`await import('${U}')`)}else X.push(G);Q++;continue}if((G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")||G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var "))&&!G.includes("="))X.push(J[Q]),Q++;else if(G.startsWith("export const ")||G.startsWith("export let ")||G.startsWith("export var ")){let K=u8(J,Q),{type:q,name:W,value:z}=K;X.push(`${q} ${W} = ${z};`),X.push(`module.exports.${W} = ${W};`),Q=K.nextIndex}else if(G.startsWith("export function ")||G.startsWith("export async function ")){let K=p7(J,Q);X.push(K.functionCode),X.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("const ")||G.startsWith("let ")||G.startsWith("var ")){let K=u8(J,Q),{type:q,name:W,value:z}=K;X.push(`${q} ${W} = ${z};`),X.push(`module.exports.${W} = ${W};`),Q=K.nextIndex}else if(G.startsWith("function ")||G.startsWith("async function ")){let K=p7(J,Q);X.push(K.functionCode),X.push(`module.exports.${K.name} = ${K.name};`),Q=K.nextIndex}else if(G.startsWith("export default function ")||G.startsWith("export default async function ")){let K=J[Q].replace(/^(\s*)export\s+default\s+/,"$1"),q=[...J];q[Q]=K;let W=p7(q,Q);if(X.push(W.functionCode),W.name)X.push(`module.exports.default = ${W.name};`);Q=W.nextIndex}else if(G.startsWith("export default ")){let K=G.replace(/^export\s+default\s+/,"").replace(/;$/,"");X.push(`module.exports.default = ${K};`),Q++}else if(G.startsWith("class ")||G.startsWith("export class ")){let K=G.match(/(?:export\s+)?class\s+(\w+)/);if(K){let q=K[1],W=J[Q].replace(/^export\s+/,""),z=0,U=Q;for(;U<J.length;U++){let _=J[U];for(let B of _)if(B==="{")z++;else if(B==="}")z--;if(U>Q)W+=`
1899
1899
  `+_;if(z<=0&&U>=Q)break}X.push(W),X.push(`module.exports.${q} = ${q};`),Q=U+1}else X.push(G),Q++}else if(G.includes("module.exports"))X.push(G),Q++;else if(G.trim()&&!G.startsWith("//"))X.push(G),Q++;else Q++}return pK(X.join(`
1900
1900
  `),Y)}function pK($,Z){let Y=$.length,J="",X=0,Q=null,G=!1,K=!1,q=0;while(X<Y){let W=$[X],z=$[X+1];if(G){if(J+=W,W===`
@@ -1904,7 +1904,7 @@ ${N}`,nextIndex:O}}}}throw Error(`Failed to parse variable declaration: ${Y}`)}l
1904
1904
  ${$[q]}`,q++;else break}return K=K.trim().replace(/;$/,""),{type:X,name:Q,value:K,nextIndex:q}}function p7($,Z){let Y=$[Z].trim(),J=Y.match(/^(?:export\s+)?(?:async\s+)?function\s+(\w+)/);if(!J)throw Error(`Failed to parse function declaration: ${Y}`);let[,X]=J,Q=Y.replace(/^export\s+/,""),G=Z;if(lK(Y)){let K=iK($,Z,Q);Q=K.functionCode,G=K.nextIndex}else G=Z+1;return{name:X,functionCode:Q,nextIndex:G}}function p8($){let Z=$.trim();if(Z.startsWith("{"))return y0(Z,"{","}",0)===-1;if(Z.startsWith("["))return y0(Z,"[","]",0)===-1;return!s8(Z)}function s8($){let Z={paren:0,bracket:0,brace:0},Y=null,J=0;for(let X=0;X<$.length;X++){let Q=$[X];if((X>0?$[X-1]:"")==="\\"&&Y)continue;if((Q==='"'||Q==="'")&&!Y){Y=Q;continue}if(Q===Y&&Y!=="`"){Y=null;continue}if(Q==="`"&&!Y){Y="`";continue}if(Q==="`"&&Y==="`"&&J===0){Y=null;continue}if(Y==="`"&&Q==="$"&&$[X+1]==="{"){J++,X++;continue}if(J>0&&Q==="{"){J++;continue}if(J>0&&Q==="}"){J--;continue}if(Y)continue;if(Q==="(")Z.paren++;else if(Q===")")Z.paren--;else if(Q==="[")Z.bracket++;else if(Q==="]")Z.bracket--;else if(Q==="{")Z.brace++;else if(Q==="}")Z.brace--}return Z.paren===0&&Z.bracket===0&&Z.brace===0&&Y===null}function lK($){let Z=$.indexOf("{");if(Z===-1)return!0;return y0($,"{","}",Z)===-1}function c8($,Z,Y){let J=Y,X=Z+1;while(X<$.length&&!s8(J)){let Q=$[X];J+=`
1905
1905
  ${Q}`,X++}while(X<$.length){let Q=$[X].trim();if(Q.startsWith(".")||Q.startsWith("?."))J+=`
1906
1906
  ${$[X]}`,X++;else break}return{value:J,nextIndex:X}}function iK($,Z,Y){let J=Y,X=Z+1;while(X<$.length){let Q=J.indexOf("{");if(Q!==-1){if(y0(J,"{","}",Q)!==-1)break}let G=$[X];J+=`
1907
- ${G}`,X++}return{functionCode:J,nextIndex:X}}function l8($,Z){let Y=Z0($,Z)??Z0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let J={...Z,process:Object.freeze({env:{...x5.env}})};try{return Function(...Object.keys(J),`'use strict'; return (${$});`)(...Object.values(J))}catch{try{return Function(...Object.keys(J),`'use strict'; return ${$};`)(...Object.values(J))}catch{return}}}async function nK($,Z,Y){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of J){let[,,G,K]=Q;try{let q=K.trim().replace(/;$/,""),W=l8(q,Z);if(W!==void 0)Z[G]=W}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}let X=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of X){let[,,G,K]=Q;if(!(G in Z))try{let q=K.trim().replace(/;$/,""),W=l8(q,Z);if(W!==void 0)Z[G]=W}catch{}}}function r8($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",J=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:J}}function a8($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var f5=b(()=>{E5();p1();T0()});var XZ={};o(XZ,{processLoops:()=>l7});function rK($,Z){let Y=/@component\s*\(/g,J=$,X,Q=[];while((X=Y.exec(J))!==null){let G=X.index,K=G+X[0].length-1,q=1,W=K+1;while(W<J.length&&q>0){if(J[W]==="(")q++;else if(J[W]===")"){if(q--,q===0)break}W++}if(q!==0)continue;let z=J.substring(K+1,W),U=W+1,_=z.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=z.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=R0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;Q.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=Q[G];J=J.substring(0,K)+W+J.substring(q)}return J}function S$($,Z,Y){let J=$,X=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=X.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,W=K+1,z=null,U=!1;while(W<J.length&&q>0){let j=J[W];if(U){U=!1,W++;continue}if(j==="\\"&&z){U=!0,W++;continue}if(z){if(j===z)z=null;W++;continue}if(j==='"'||j==="'"||j==="`"){z=j,W++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}W++}if(q!==0)break;let _=J.substring(K+1,W),B=Y(_);J=J.substring(0,G)+B+J.substring(W+1)}return J}function aK($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(J,X)=>{if(X in Z)return`:${X}="${X}"`;return J}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(J,X,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);t5(Q);let W=Q0(Q,G)(...K),z=JSON.stringify(W),U=Buffer.from(z,"utf8").toString("base64");return`__stx_${X}="${U}"`}catch(G){return J}}),Y}function tK($,Z){let Y=$;return Y=S$(Y,"@break",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(X0(Q)){let K=Q0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(Q,Z));return G?y$:""}catch{return""}}),Y=S$(Y,"@continue",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(X0(Q)){let K=Q0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(Q,Z));return G?C$:""}catch{return""}}),Y}function eK($){let Z=$;return Z=Z.replace(/@break(?!\()/g,y$),Z=Z.replace(/@continue(?!\()/g,C$),Z}function t8($){let Z=$.includes(y$),Y=Z?$.substring(0,$.indexOf(y$)):$;return{hasBreak:Z,content:Y}}function e8($){let Z=$.includes(C$),Y=Z?$.substring(0,$.indexOf(C$)):$;return{hasContinue:Z,content:Y}}function ZZ($){let Z=$;return Z=S$(Z,"@break",(Y)=>{let J=Y.trim();if(!e5(J))return"";return`\`; if (${J}) { break; } result += \``}),Z=S$(Z,"@continue",(Y)=>{let J=Y.trim();if(!e5(J))return"";return`\`; if (${J}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function $q($){let Z=/@forelse\s*\(/g,Y,J=[],X=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=X.exec($))!==null)J.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)J.push({pos:G.index,delta:-1});J.sort((z,U)=>z.pos-U.pos);let K=[],q=0;for(let z of J)q+=z.delta,K.push({pos:z.pos,depth:q});function W(z){let U=0,_=K.length-1,B=0;while(U<=_){let j=U+_>>1;if(K[j].pos<=z)B=K[j].depth,U=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let z=Y.index,U=Y.index+Y[0].length-1,_=1,B=U+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(U+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,N=V,A=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(w>0&&N<$.length){A.lastIndex=N,R.lastIndex=N;let S=A.exec($),k=R.exec($);if(!k)break;if(S&&S.index<k.index)w++,N=S.index+S[0].length;else{if(w--,w===0){T=k.index;break}N=k.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,y=0;while(y<M.length){let S=M.indexOf("@",y);if(S===-1)break;let k=M.substring(S);if(/^@forelse\s*\(/.test(k))E++,y=S+1;else if(k.startsWith("@endforelse"))E--,y=S+11;else if(E===0&&k.startsWith("@empty")){if(M.length<=S+6||!/[a-z]/i.test(M[S+6])){D=S;break}y=S+1}else y=S+1}if(D===-1)continue;return{start:z,end:I,arrayExpr:F,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function $Z($,Z){let Y=$;while(!0){let J=$q(Y);if(!J)break;let{start:X,end:Q,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:W}=J;try{let z;if(X0(G))z=Q0(G,Object.keys(Z))(...Object.values(Z));else z=Z0(G,Z);let U;if(!Array.isArray(z)||z.length===0)U=W;else U=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,X)+U+Y.substring(Q)}catch(z){let U=z instanceof Error?z.message:String(z),_=r("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,n.EVALUATION_ERROR);Y=Y.substring(0,X)+_+Y.substring(Q)}}return Y}function l7($,Z,Y,J){let X=$;X=$Z(X,Z);function Q(q){let W=/@foreach\s*\(/g,z;while((z=W.exec(q))!==null){let U=z.index,_=z.index+z[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=U,V=L.substring(0,F),w=L.substring(F+4),N=H+1,A=1,R=N,T=/@foreach\s*\(/g,M=/@endforeach/g;while(A>0&&R<q.length){T.lastIndex=R,M.lastIndex=R;let I=T.exec(q),D=M.exec(q);if(!D)break;if(I&&I.index<D.index)A++,R=I.index+I[0].length;else{if(A--,A===0){let E=q.substring(N,D.index),y=D.index+11;return{start:O,end:y,arrayExpr:V,itemVar:w,content:E}}R=D.index+11}}}return null}function G(q,W){let z=q;while(!0){let U=Q(z);if(!U)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=U;try{let F=j.trim(),O;if(X0(F))O=Q0(F,Object.keys(W))(...Object.values(W));else O=Z0(F,W);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,n.TYPE_ERROR);z=z.substring(0,_)+D+z.substring(B);continue}let w=J?.loops?.useAltLoopVariable??sK,N=H.trim(),A=null,R,T=!1;if(N.includes("=>")){let D=N.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])A=D[0],R=D[1];else R=N}else if(!N.startsWith("[")&&!N.startsWith("{")&&N.includes(",")){let D=N.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],A=D[1],T=!0;else R=N}else R=N;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],y={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},S={...W,loop:y,$loop:y};if(R.startsWith("[")&&R.endsWith("]")){let f=R.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))f.forEach((m,c)=>{if(m)S[m]=E[c]});else S[R]=E}else S[R]=E;if(A)if(!T&&V&&Array.isArray(E)&&E.length===2)S[A]=E[0],S[R]=E[1];else S[A]=D;let k=tK(L,S),P=e8(k);if(P.hasContinue){M+=P.content;continue}let h=t8(k);if(h.hasBreak){M+=h.content;break}if(k=$Z(k,S),k=G(k,S),k=b1(k,S,Y),k=eK(k),h=t8(k),h.hasBreak){M+=h.content;break}if(P=e8(k),P.hasContinue){M+=P.content;continue}k=a0(k,S,Y),k=aK(k,S),k=rK(k,S),M+=k}z=z.substring(0,_)+M+z.substring(B)}catch(F){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,n.EVALUATION_ERROR);z=z.substring(0,_)+O+z.substring(B)}}return z}X=G(X,Z),X=JZ(X,Z,Y,J);let K=J?.loops?.maxWhileIterations??oK;return X=Jq(X,Z,K),X}function YZ($){return e5($)}function JZ($,Z,Y,J){let X=$,Q=!0;while(Q){Q=!1;let G=X.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=K+G[0].length-1,W=y0(X,"(",")",q);if(W===-1)break;let z=X.slice(q+1,W),U=W+1,_=j$(X.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!YZ(z)){let H=r("For",`Unsafe expression in @for: ${z}`,n.UNSAFE_EXPRESSION);X=X.substring(0,K)+H+X.substring(j),Q=!0;continue}try{let H=Zq(z),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let A=Yq({forExpr:z,content:B,iterVarNames:H,context:Z,filePath:Y,options:J});X=X.substring(0,K)+A+X.substring(j),Q=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(A,R)=>{return`\${${R}}`});V=ZZ(V);let N=Function(...F,`
1907
+ ${G}`,X++}return{functionCode:J,nextIndex:X}}function l8($,Z){let Y=Z0($,Z)??Z0(`(${$})`,Z);if(Y!==void 0)return Y;if(!/\bprocess\b/.test($))return;let J={...Z,process:Object.freeze({env:{...x5.env}})};try{return Function(...Object.keys(J),`'use strict'; return (${$});`)(...Object.values(J))}catch{try{return Function(...Object.keys(J),`'use strict'; return ${$};`)(...Object.values(J))}catch{return}}}async function nK($,Z,Y){let J=$.matchAll(/export\s+(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:export\s+|$))/g);for(let Q of J){let[,,G,K]=Q;try{let q=K.trim().replace(/;$/,""),W=l8(q,Z);if(W!==void 0)Z[G]=W}catch(q){console.warn(`Failed to parse export ${G} in fallback:`,q)}}let X=$.matchAll(/(?:^|\n)\s*(const|let|var)\s+(\w+)\s*=\s*([\s\S]*?)(?=\s*(?:(?:const|let|var|function|export)\s+|$))/g);for(let Q of X){let[,,G,K]=Q;if(!(G in Z))try{let q=K.trim().replace(/;$/,""),W=l8(q,Z);if(W!==void 0)Z[G]=W}catch{}}}function r8($){let Z=$.match(/<script\b[^>]*>([\s\S]*?)<\/script>/i),Y=Z?Z[1]:"",J=Z?$.replace(/<script\b[^>]*>[\s\S]*?<\/script>/i,""):$;return{scriptContent:Y,templateWithoutScript:J}}function a8($){let Z=$.trim();if(!Z)return!1;return/(?:const|let|var|function)\s+\w+/.test(Z)}var f5=b(()=>{E5();p1();T0()});var XZ={};o(XZ,{processLoops:()=>l7});function rK($,Z){let Y=/@component\s*\(/g,J=$,X,Q=[];while((X=Y.exec(J))!==null){let G=X.index,K=G+X[0].length-1,q=1,W=K+1;while(W<J.length&&q>0){if(J[W]==="(")q++;else if(J[W]===")"){if(q--,q===0)break}W++}if(q!==0)continue;let z=J.substring(K+1,W),U=W+1,_=z.match(/^\s*['"]([^'"]+)['"]/);if(!_)continue;let B=_[1],j=z.slice(_[0].length),H=j.match(/^\s*,\s*/);if(!H)continue;let L=j.slice(H[0].length).trim();if(!L)continue;try{let F=R0(L,Z),O=JSON.stringify(F),V=`@component('${B}', ${O})`;Q.push({start:G,end:U,replacement:V})}catch{continue}}for(let G=Q.length-1;G>=0;G--){let{start:K,end:q,replacement:W}=Q[G];J=J.substring(0,K)+W+J.substring(q)}return J}function S$($,Z,Y){let J=$,X=new RegExp(`${Z.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\(`),Q;while((Q=X.exec(J))!==null){let G=Q.index,K=G+Q[0].length-1,q=1,W=K+1,z=null,U=!1;while(W<J.length&&q>0){let j=J[W];if(U){U=!1,W++;continue}if(j==="\\"&&z){U=!0,W++;continue}if(z){if(j===z)z=null;W++;continue}if(j==='"'||j==="'"||j==="`"){z=j,W++;continue}if(j==="(")q++;else if(j===")"){if(q--,q===0)break}W++}if(q!==0)break;let _=J.substring(K+1,W),B=Y(_);J=J.substring(0,G)+B+J.substring(W+1)}return J}function aK($,Z){let Y=$;return Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)(?=\s+[^=]|\s*\/?>|\s*$)/g,(J,X)=>{if(X in Z)return`:${X}="${X}"`;return J}),Y=Y.replace(/:([a-zA-Z_][a-zA-Z0-9_-]*)\s*=\s*"([^"]*)"/g,(J,X,Q)=>{try{let G=Object.keys(Z),K=Object.values(Z);t5(Q);let W=Q0(Q,G)(...K),z=JSON.stringify(W),U=Buffer.from(z,"utf8").toString("base64");return`__stx_${X}="${U}"`}catch(G){return J}}),Y}function tK($,Z){let Y=$;return Y=S$(Y,"@break",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(X0(Q)){let K=Q0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(Q,Z));return G?y$:""}catch{return""}}),Y=S$(Y,"@continue",(J)=>{try{let Q=`!!(${J.trim()})`,G;if(X0(Q)){let K=Q0(Q,Object.keys(Z));G=Boolean(K(...Object.values(Z)))}else G=Boolean(Z0(Q,Z));return G?C$:""}catch{return""}}),Y}function eK($){let Z=$;return Z=Z.replace(/@break(?!\()/g,y$),Z=Z.replace(/@continue(?!\()/g,C$),Z}function t8($){let Z=$.includes(y$),Y=Z?$.substring(0,$.indexOf(y$)):$;return{hasBreak:Z,content:Y}}function e8($){let Z=$.includes(C$),Y=Z?$.substring(0,$.indexOf(C$)):$;return{hasContinue:Z,content:Y}}function ZZ($){let Z=$;return Z=S$(Z,"@break",(Y)=>{let J=Y.trim();if(!e5(J))return"";return`\`; if (${J}) { break; } result += \``}),Z=S$(Z,"@continue",(Y)=>{let J=Y.trim();if(!e5(J))return"";return`\`; if (${J}) { continue; } result += \``}),Z=Z.replace(/@break(?!\()/g,"`; break; result += `"),Z=Z.replace(/@continue(?!\()/g,"`; continue; result += `"),Z}function $q($){let Z=/@forelse\s*\(/g,Y,J=[],X=/@foreach\s*\(/g,Q=/@endforeach/g,G;while((G=X.exec($))!==null)J.push({pos:G.index,delta:1});while((G=Q.exec($))!==null)J.push({pos:G.index,delta:-1});J.sort((z,U)=>z.pos-U.pos);let K=[],q=0;for(let z of J)q+=z.delta,K.push({pos:z.pos,depth:q});function W(z){let U=0,_=K.length-1,B=0;while(U<=_){let j=U+_>>1;if(K[j].pos<=z)B=K[j].depth,U=j+1;else _=j-1}return B}while((Y=Z.exec($))!==null){if(W(Y.index)>0)continue;let z=Y.index,U=Y.index+Y[0].length-1,_=1,B=U+1,j=-1;while(B<$.length&&_>0){if($[B]==="(")_++;else if($[B]===")"){if(_--,_===0){j=B;break}}B++}if(j===-1)continue;let H=$.substring(U+1,j),L=H.indexOf(" as ");if(L===-1)continue;let F=H.substring(0,L).trim(),O=H.substring(L+4).trim(),V=j+1,w=1,N=V,A=/@forelse\s*\(/g,R=/@endforelse/g,T=-1;while(w>0&&N<$.length){A.lastIndex=N,R.lastIndex=N;let S=A.exec($),k=R.exec($);if(!k)break;if(S&&S.index<k.index)w++,N=S.index+S[0].length;else{if(w--,w===0){T=k.index;break}N=k.index+11}}if(T===-1)continue;let M=$.substring(V,T),I=T+11,D=-1,E=0,C=0;while(C<M.length){let S=M.indexOf("@",C);if(S===-1)break;let k=M.substring(S);if(/^@forelse\s*\(/.test(k))E++,C=S+1;else if(k.startsWith("@endforelse"))E--,C=S+11;else if(E===0&&k.startsWith("@empty")){if(M.length<=S+6||!/[a-z]/i.test(M[S+6])){D=S;break}C=S+1}else C=S+1}if(D===-1)continue;return{start:z,end:I,arrayExpr:F,itemVar:O,foreachContent:M.substring(0,D),emptyContent:M.substring(D+6)}}return null}function $Z($,Z){let Y=$;while(!0){let J=$q(Y);if(!J)break;let{start:X,end:Q,arrayExpr:G,itemVar:K,foreachContent:q,emptyContent:W}=J;try{let z;if(X0(G))z=Q0(G,Object.keys(Z))(...Object.values(Z));else z=Z0(G,Z);let U;if(!Array.isArray(z)||z.length===0)U=W;else U=`@foreach (${G} as ${K})${q}@endforeach`;Y=Y.substring(0,X)+U+Y.substring(Q)}catch(z){let U=z instanceof Error?z.message:String(z),_=r("Forelse",`Error in @forelse(${G} as ${K}): ${U}`,n.EVALUATION_ERROR);Y=Y.substring(0,X)+_+Y.substring(Q)}}return Y}function l7($,Z,Y,J){let X=$;X=$Z(X,Z);function Q(q){let W=/@foreach\s*\(/g,z;while((z=W.exec(q))!==null){let U=z.index,_=z.index+z[0].length-1,B=1,j=_+1,H=-1;while(j<q.length&&B>0){if(q[j]==="(")B++;else if(q[j]===")"){if(B--,B===0){H=j;break}}j++}if(H===-1)continue;let L=q.substring(_+1,H),F=L.indexOf(" as ");if(F===-1)continue;let O=U,V=L.substring(0,F),w=L.substring(F+4),N=H+1,A=1,R=N,T=/@foreach\s*\(/g,M=/@endforeach/g;while(A>0&&R<q.length){T.lastIndex=R,M.lastIndex=R;let I=T.exec(q),D=M.exec(q);if(!D)break;if(I&&I.index<D.index)A++,R=I.index+I[0].length;else{if(A--,A===0){let E=q.substring(N,D.index),C=D.index+11;return{start:O,end:C,arrayExpr:V,itemVar:w,content:E}}R=D.index+11}}}return null}function G(q,W){let z=q;while(!0){let U=Q(z);if(!U)break;let{start:_,end:B,arrayExpr:j,itemVar:H,content:L}=U;try{let F=j.trim(),O;if(X0(F))O=Q0(F,Object.keys(W))(...Object.values(W));else O=Z0(F,W);let V=!1;if(!Array.isArray(O))if(O instanceof Map)O=Array.from(O),V=!0;else if(O instanceof Set)O=Array.from(O);else if(typeof O==="string")O=Array.from(O);else if(O&&typeof O==="object"&&!(O instanceof Date)&&!(O instanceof RegExp))O=Object.entries(O),V=!0;else{let D=r("Foreach",`Error in @foreach: ${F} is not iterable`,n.TYPE_ERROR);z=z.substring(0,_)+D+z.substring(B);continue}let w=J?.loops?.useAltLoopVariable??sK,N=H.trim(),A=null,R,T=!1;if(N.includes("=>")){let D=N.split("=>").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])A=D[0],R=D[1];else R=N}else if(!N.startsWith("[")&&!N.startsWith("{")&&N.includes(",")){let D=N.split(",").map((E)=>E.trim());if(D.length===2&&D[0]&&D[1])R=D[0],A=D[1],T=!0;else R=N}else R=N;let M="",I=O;for(let D=0;D<I.length;D++){let E=I[D],C={index:D,iteration:D+1,first:D===0,last:D===I.length-1,count:I.length},S={...W,loop:C,$loop:C};if(R.startsWith("[")&&R.endsWith("]")){let f=R.slice(1,-1).split(",").map((m)=>m.trim());if(Array.isArray(E))f.forEach((m,c)=>{if(m)S[m]=E[c]});else S[R]=E}else S[R]=E;if(A)if(!T&&V&&Array.isArray(E)&&E.length===2)S[A]=E[0],S[R]=E[1];else S[A]=D;let k=tK(L,S),P=e8(k);if(P.hasContinue){M+=P.content;continue}let h=t8(k);if(h.hasBreak){M+=h.content;break}if(k=$Z(k,S),k=G(k,S),k=b1(k,S,Y),k=eK(k),h=t8(k),h.hasBreak){M+=h.content;break}if(P=e8(k),P.hasContinue){M+=P.content;continue}k=a0(k,S,Y),k=aK(k,S),k=rK(k,S),M+=k}z=z.substring(0,_)+M+z.substring(B)}catch(F){let O=r("Foreach",`Error in @foreach(${j.trim()} as ${H.trim()}): ${F instanceof Error?F.message:String(F)}`,n.EVALUATION_ERROR);z=z.substring(0,_)+O+z.substring(B)}}return z}X=G(X,Z),X=JZ(X,Z,Y,J);let K=J?.loops?.maxWhileIterations??oK;return X=Jq(X,Z,K),X}function YZ($){return e5($)}function JZ($,Z,Y,J){let X=$,Q=!0;while(Q){Q=!1;let G=X.match(/@for\s*\(/);if(!G||G.index===void 0)break;let K=G.index,q=K+G[0].length-1,W=y0(X,"(",")",q);if(W===-1)break;let z=X.slice(q+1,W),U=W+1,_=j$(X.slice(K),"for","endfor");if(_.length===0)break;let B=_[0].content,j=K+_[0].end;if(!YZ(z)){let H=r("For",`Unsafe expression in @for: ${z}`,n.UNSAFE_EXPRESSION);X=X.substring(0,K)+H+X.substring(j),Q=!0;continue}try{let H=Zq(z),L=/@(?:for|foreach|if|unless)\s*\(/.test(B);if(H.length>0&&L){let A=Yq({forExpr:z,content:B,iterVarNames:H,context:Z,filePath:Y,options:J});X=X.substring(0,K)+A+X.substring(j),Q=!0;continue}let F=Object.keys(Z),O=Object.values(Z),V=B.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(A,R)=>{return`\${${R}}`});V=ZZ(V);let N=Function(...F,`
1908
1908
  let result = '';
1909
1909
  for (${z}) {
1910
1910
  result += \`${V}\`;
@@ -1961,14 +1961,14 @@ ${Gq($).split(",").map((q)=>q.trim()).filter(Boolean).map((q)=>` try { __scopeR
1961
1961
  } finally {
1962
1962
  if (typeof window !== 'undefined') window.__STX_CURRENT_ELEMENT__ = __stxPrevEl;
1963
1963
  }
1964
- })();`}function qq($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let X=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(X)return{html:$,mergedIntoExisting:X[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function Wq($){if($.__onceStore instanceof Set)return $.__onceStore;return zq}async function o7($,Z,Y,J,X,Q=new Set){let G=J.partialsDir||U0.join(U0.dirname(Y),"partials");if(G&&!U0.isAbsolute(G))G=U0.resolve(process.cwd(),G);let K=Xq($,"@partial","@include"),q=Wq(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),N=w.match(/^\s*['"]([^'"]+)['"]/);if(!N){j.lastIndex=V;continue}let A=N[1],R=W(A,G,Y),T="";if(R&&await Bun.file(R).exists())X.add(R),T=`@include(${w})`;K=K.substring(0,L)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,N=V+1;while(N<K.length&&w>0){if(K[N]==="(")w++;else if(K[N]===")")w--;N++}if(w!==0)break;let A=K.substring(V+1,N-1),R=n7(A,0);if(R===-1){L.lastIndex=N;continue}let T=A.substring(0,R).trim(),M=A.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=N;continue}let D=I[1],E=M.substring(I[0].length),y,S=n7(E,0);if(S!==-1)y=E.substring(S+1).trim();try{let k=`Boolean(${T})`,P;if(X0(k)){let m=Q0(k,Object.keys(Z));P=Boolean(m(...Object.values(Z)))}else P=Boolean(Z0(k,Z));let h=H?!P:P,f="";if(h){let m=W(D,G,Y);if(m&&await Bun.file(m).exists())X.add(m);f=`@include('${D}'${y?`, ${y}`:""})`}K=K.substring(0,O)+f+K.substring(N),L.lastIndex=0}catch(k){let P=k instanceof Error?k.message:String(k),h=G0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+h+K.substring(N),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),N=K.substring(L,V+1),A=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!A){j.lastIndex=0,K=K.replace(N,"");continue}let[,R,T,M,I]=A;try{let D,E=T.trim();if(X0(E))D=Q0(E,Object.keys(Z))(...Object.values(Z));else D=Z0(E,Z);let y="";if(Array.isArray(D)&&D.length>0)for(let S of D){let k={...Z,[M]:S},P=await U(R,k,$,L);y+=P}else if(I)y=await U(I,{},$,L);K=K.substring(0,L)+y+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+G0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),N=K.substring(L,V+1),A=w.match(/^\s*(\[[^\]]+\])/);if(!A){j.lastIndex=0,K=K.replace(N,"");continue}let R=A[1],T=w.slice(A[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let y=1,S=1;while(S<T.length&&y>0){if(T[S]==="{")y++;else if(T[S]==="}"){if(y--,y===0)break}S++}M=T.substring(0,S+1),T=T.slice(S+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let y=JSON.parse(R.replace(/'/g,'"')),S={};if(M)try{S=R0(M,Z)}catch(P){let h=P instanceof Error?P.message:String(P);if(J.debug){let f=G0("Include",`Error parsing includeFirst variables: ${h}`,Y,$,L,N);K=K.replace(N,()=>f)}else K=K.replace(N,()=>D||"");continue}let k=!1;for(let P of y){let h=W(P,G,Y);if(!h)continue;if(await l(h)){let f=await U(P,S,$,L);K=K.replace(N,()=>f),k=!0;break}}if(!k)if(D!==void 0)K=K.replace(N,()=>D);else if(J.debug){let P=G0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,L,N);K=K.replace(N,()=>P)}else K=K.replace(N,"")}catch(y){let S=y instanceof Error?y.message:String(y),k=G0("Include",`Error processing @includeFirst: ${S}`,Y,$,L,N);K=K.replace(N,()=>k)}j.lastIndex=0}}function W(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=U0.resolve(H),V=U0.resolve(U0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=U0.resolve(H,F);else w=U0.resolve(V,F);let N=U0.normalize(w),A=N.startsWith(O+U0.sep)||N===O,R=N.startsWith(V+U0.sep)||N===V,T=!1,M=U0.dirname(V);if(N.startsWith(M+U0.sep)){if(!U0.relative(M,N).split(U0.sep).some((y)=>y.startsWith(".")&&y!=="."&&y!==".."))T=!0}if(!A&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return N}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let z=U0.resolve(Y);Q.add(z);async function U(j,H={},L,F){let O=W(j,G,Y);if(!O)return G0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=U0.resolve(O);if(Q.has(V)){let w=[...Q,V].map((N)=>U0.basename(N)).join(" -> ");return G0("Include",`Circular include detected: ${w}`,Y,L,F)}try{X.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let m=f instanceof Error?f.message:String(f);return G0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (H7(),j7));w=f(w,Z)}if(w&&(J.debug||!T5()&&!q$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (L7(),H8));f(w,O)}catch{}let N=w;try{let{processESImports:f}=await Promise.resolve().then(() => (u7(),d8));await f(w,Z,O,J,X)}catch(f){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let A=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(A)N=A[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;N=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),N=N.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,m]of Object.entries(H))I[f]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],y="",S=null;for(let f of E){let m=f[1]||"",c=f[2]||"",Y0=m.includes("server"),K0=M1(m),O0="";try{let{extractAndStripCssImports:$0,renderVendorStyleTags:N0}=await Promise.resolve().then(() => (L5(),C6)),H0=$0(c,{filePath:O,projectRoot:process.cwd()});c=H0.code,O0=N0(H0.styles)}catch($0){if(J.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}if(K0&&c.trim())c=I1(c);if(!Y0)try{let{hasUserImports:$0,bundleClientScript:N0}=await Promise.resolve().then(() => (r5(),s5));if($0(c))c=await N0(c,O,{projectRoot:process.cwd()})}catch($0){if(J.debug)console.warn(`[stx] bundler skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}let B0=Qq(c);if(B0&&!Y0){S=`stx_scope_${U0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++QZ}`;let $0=J1(c),N0=Kq($0,S);y+=`${O0}<script data-stx-scoped>${N0}</script>
1964
+ })();`}function qq($,Z){let Y=$.match(/^(\s*(?:(?:<!--[\s\S]*?-->|\x00STX_HTML_COMMENT_\d+\x00)\s*)*)(<[a-zA-Z][a-zA-Z0-9-]*)(\s[^>]*>|>)/s);if(Y){let X=(Y[2]+Y[3]).match(/data-stx-scope="([^"]*)"/);if(X)return{html:$,mergedIntoExisting:X[1]};let Q=Y[1],G=Y[2],K=Y[3];return{html:`${Q}${G} data-stx-scope="${Z}"${K}${$.slice(Y[0].length)}`,mergedIntoExisting:null}}return{html:$,mergedIntoExisting:null}}function Wq($){if($.__onceStore instanceof Set)return $.__onceStore;return zq}async function o7($,Z,Y,J,X,Q=new Set){let G=J.partialsDir||U0.join(U0.dirname(Y),"partials");if(G&&!U0.isAbsolute(G))G=U0.resolve(process.cwd(),G);let K=Xq($,"@partial","@include"),q=Wq(Z);K=K.replace(/@once([\s\S]*?)@endonce/g,(j,H,L)=>{let F=H.trim(),O=`${Y}:${F}`;if(q.has(O))return"";return q.add(O),H});{let j=/@includeIf\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")")O--;V++}if(O!==0)break;let w=K.substring(F+1,V-1),N=w.match(/^\s*['"]([^'"]+)['"]/);if(!N){j.lastIndex=V;continue}let A=N[1],R=W(A,G,Y),T="";if(R&&await Bun.file(R).exists())X.add(R),T=`@include(${w})`;K=K.substring(0,L)+T+K.substring(V),j.lastIndex=0}}for(let[j,H]of[["@includeWhen",!1],["@includeUnless",!0]]){let L=new RegExp(`${j.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\s*\\(`,"g"),F;while((F=L.exec(K))!==null){let O=F.index,V=O+F[0].length-1,w=1,N=V+1;while(N<K.length&&w>0){if(K[N]==="(")w++;else if(K[N]===")")w--;N++}if(w!==0)break;let A=K.substring(V+1,N-1),R=n7(A,0);if(R===-1){L.lastIndex=N;continue}let T=A.substring(0,R).trim(),M=A.substring(R+1).trim(),I=M.match(/^\s*['"]([^'"]+)['"]/);if(!I){L.lastIndex=N;continue}let D=I[1],E=M.substring(I[0].length),C,S=n7(E,0);if(S!==-1)C=E.substring(S+1).trim();try{let k=`Boolean(${T})`,P;if(X0(k)){let m=Q0(k,Object.keys(Z));P=Boolean(m(...Object.values(Z)))}else P=Boolean(Z0(k,Z));let h=H?!P:P,f="";if(h){let m=W(D,G,Y);if(m&&await Bun.file(m).exists())X.add(m);f=`@include('${D}'${C?`, ${C}`:""})`}K=K.substring(0,O)+f+K.substring(N),L.lastIndex=0}catch(k){let P=k instanceof Error?k.message:String(k),h=G0("Include",`Error evaluating ${j} condition: ${P}`,Y,$,O);K=K.substring(0,O)+h+K.substring(N),L.lastIndex=0}}}{let j=/@each\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),N=K.substring(L,V+1),A=w.match(/^\s*['"]([^'"]+)['"]\s*,\s*([^,]+)\s*,\s*['"]([^'"]+)['"](?:\s*,\s*['"]([^'"]+)['"])?\s*$/);if(!A){j.lastIndex=0,K=K.replace(N,"");continue}let[,R,T,M,I]=A;try{let D,E=T.trim();if(X0(E))D=Q0(E,Object.keys(Z))(...Object.values(Z));else D=Z0(E,Z);let C="";if(Array.isArray(D)&&D.length>0)for(let S of D){let k={...Z,[M]:S},P=await U(R,k,$,L);C+=P}else if(I)C=await U(I,{},$,L);K=K.substring(0,L)+C+K.substring(V+1),j.lastIndex=0}catch(D){let E=D instanceof Error?D.message:String(D);K=K.substring(0,L)+G0("Each",`Error in @each: ${E}`,Y,$,L)+K.substring(V+1),j.lastIndex=0}}}{let j=/@includeFirst\s*\(/g,H;while((H=j.exec(K))!==null){let L=H.index,F=L+H[0].length-1,O=1,V=F+1;while(V<K.length&&O>0){if(K[V]==="(")O++;else if(K[V]===")"){if(O--,O===0)break}V++}if(O!==0)break;let w=K.substring(F+1,V),N=K.substring(L,V+1),A=w.match(/^\s*(\[[^\]]+\])/);if(!A){j.lastIndex=0,K=K.replace(N,"");continue}let R=A[1],T=w.slice(A[0].length),M,I=T.match(/^\s*,\s*\{/);if(I){T=T.slice(I[0].length-1);let C=1,S=1;while(S<T.length&&C>0){if(T[S]==="{")C++;else if(T[S]==="}"){if(C--,C===0)break}S++}M=T.substring(0,S+1),T=T.slice(S+1)}let D,E=T.match(/^\s*,\s*['"]([^'"]*)['"]\s*$/);if(E)D=E[1];try{let C=JSON.parse(R.replace(/'/g,'"')),S={};if(M)try{S=R0(M,Z)}catch(P){let h=P instanceof Error?P.message:String(P);if(J.debug){let f=G0("Include",`Error parsing includeFirst variables: ${h}`,Y,$,L,N);K=K.replace(N,()=>f)}else K=K.replace(N,()=>D||"");continue}let k=!1;for(let P of C){let h=W(P,G,Y);if(!h)continue;if(await l(h)){let f=await U(P,S,$,L);K=K.replace(N,()=>f),k=!0;break}}if(!k)if(D!==void 0)K=K.replace(N,()=>D);else if(J.debug){let P=G0("Include",`None of the includeFirst paths exist: ${R}`,Y,$,L,N);K=K.replace(N,()=>P)}else K=K.replace(N,"")}catch(C){let S=C instanceof Error?C.message:String(C),k=G0("Include",`Error processing @includeFirst: ${S}`,Y,$,L,N);K=K.replace(N,()=>k)}j.lastIndex=0}}function W(j,H,L){try{let F=j;if(!j.endsWith(".stx"))F=`${j}.stx`;let O=U0.resolve(H),V=U0.resolve(U0.dirname(L)),w;if(!F.startsWith("./")&&!F.startsWith("../"))w=U0.resolve(H,F);else w=U0.resolve(V,F);let N=U0.normalize(w),A=N.startsWith(O+U0.sep)||N===O,R=N.startsWith(V+U0.sep)||N===V,T=!1,M=U0.dirname(V);if(N.startsWith(M+U0.sep)){if(!U0.relative(M,N).split(U0.sep).some((C)=>C.startsWith(".")&&C!=="."&&C!==".."))T=!0}if(!A&&!R&&!T)return console.error(`Security: Path traversal attempt blocked for include path: ${j}`),console.error(` Resolved to: ${N}`),console.error(` Allowed dirs: ${O}, ${V}`),null;return N}catch(F){return console.error(`Error resolving path ${j}: ${F}`),null}}let z=U0.resolve(Y);Q.add(z);async function U(j,H={},L,F){let O=W(j,G,Y);if(!O)return G0("Include",`Could not resolve path for include: ${j}`,Y,L,F);let V=U0.resolve(O);if(Q.has(V)){let w=[...Q,V].map((N)=>U0.basename(N)).join(" -> ");return G0("Include",`Circular include detected: ${w}`,Y,L,F)}try{X.add(O);let w;if(!w)try{w=await Bun.file(O).text()}catch(f){let m=f instanceof Error?f.message:String(f);return G0("Include",`Error loading include file ${j}: ${m}`,Y,L,F)}if(w&&w.includes("@stream")){let{processStreamDirectives:f}=await Promise.resolve().then(() => (H7(),j7));w=f(w,Z)}if(w&&(J.debug||!T5()&&!q$()))try{let{warnUnbalancedTags:f}=await Promise.resolve().then(() => (L7(),H8));f(w,O)}catch{}let N=w;try{let{processESImports:f}=await Promise.resolve().then(() => (u7(),d8));await f(w,Z,O,J,X)}catch(f){if(J.debug)console.warn(`[stx] partial ES import extraction skipped for ${O}:`,f instanceof Error?f.message:f)}let A=N.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(A)N=A[1].trim();let T=w.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,"").match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),M="";if(T)M=`<style${T[1]}>${T[2]}</style>`;N=N.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),N=N.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");let I={...Z};for(let[f,m]of Object.entries(H))I[f]=m;let D=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,E=[...w.matchAll(D)],C="",S=null;for(let f of E){let m=f[1]||"",c=f[2]||"",Y0=m.includes("server"),K0=M1(m),O0="";try{let{extractAndStripCssImports:$0,renderVendorStyleTags:N0}=await Promise.resolve().then(() => (L5(),C6)),H0=$0(c,{filePath:O,projectRoot:process.cwd()});c=H0.code,O0=N0(H0.styles)}catch($0){if(J.debug)console.warn(`[stx] vendor-css extractor skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}if(K0&&c.trim())c=I1(c);if(!Y0)try{let{hasUserImports:$0,bundleClientScript:N0}=await Promise.resolve().then(() => (r5(),s5));if($0(c))c=await N0(c,O,{projectRoot:process.cwd()})}catch($0){if(J.debug)console.warn(`[stx] bundler skipped for ${O}:`,$0 instanceof Error?$0.message:$0)}let B0=Qq(c);if(B0&&!Y0){S=`stx_scope_${U0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++QZ}`;let $0=J1(c),N0=Kq($0,S);C+=`${O0}<script data-stx-scoped>${N0}</script>
1965
1965
  `;continue}if(Y0)try{let{extractVariables:$0}=await Promise.resolve().then(() => (f5(),b$));await $0(c,I,O)}catch($0){if(J.debug)console.warn(`Warning: Could not extract variables from server script in ${O}:`,$0)}if(!Y0&&!B0){let $0=m.replace(/\bclient\b/i,"").trim();S=`stx_scope_${U0.basename(O,".stx").replace(/[^a-zA-Z0-9]/g,"_")}_${++QZ}`;let N0=J1(c),H0=`
1966
1966
  if (!window.stx._scopes) window.stx._scopes = {};
1967
1967
  window.stx._scopes['${S}'] = { __destroyCallbacks: __destroyHooks };
1968
- `,C=GZ(N0,H0);y+=`${O0}<script data-stx-scoped${$0?` ${$0}`:""}>${C}</script>
1969
- `}}if(S){let f=qq(N,S);if(N=f.html,f.mergedIntoExisting)y=y.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(N.includes("@include")||N.includes("@partial"))N=await o7(N,I,O,J,X,Q);let{processLoops:k}=await Promise.resolve().then(() => (i7(),XZ)),P=k(N,I,O);P=b1(P,I,O);let h=c1(w);if(P=a0(P,I,O,{forceSignals:h}),M)P+=`
1970
- `+M;if(y)P+=`
1971
- `+y;return P}catch(w){let N=w instanceof Error?w.message:String(w);return G0("Include",`Error processing include ${j}: ${N}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,H=j+B[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){_.lastIndex=F;continue}let N=w[1],A,R=V.substring(w[0].length),T=n7(R,0);if(T!==-1)A=R.substring(T+1).trim();let M={};if(A)try{M=R0(A,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,G0("Include",`Error parsing include variables for ${N}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await U(N,M,$,j);K=K.substring(0,j)+I+K.substring(F),_.lastIndex=0}return K}function s7($,Z){let Y=$;function J(X,Q,G,K){let q=X,W=!0;while(W){W=!1;let z=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),U=q.match(z);if(!U||U.index===void 0)break;let _=U.index,B=U[1],j=_+U[0].length,H=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<q.length){let N=q.slice(O),A=N.match(H),R=N.match(L),T=A?O+A.index:1/0,M=R?O+R.index:1/0;if(T<M)F++,O=T+(A[0].length||1);else if(M<1/0){if(F--,F===0){V=M;break}O=M+G.length+1}else break}if(V===-1)break;let w=q.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(w);else Z[B].push(w);q=q.substring(0,_)+q.substring(V+`@${G}`.length),W=!0}return q}return Y=J(Y,"push","endpush",!1),Y=J(Y,"prepend","endprepend",!0),Y}function r7($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,J)=>{if(!Z[J]||Z[J].length===0)return"";return Z[J].join(`
1968
+ `,y=GZ(N0,H0);C+=`${O0}<script data-stx-scoped${$0?` ${$0}`:""}>${y}</script>
1969
+ `}}if(S){let f=qq(N,S);if(N=f.html,f.mergedIntoExisting)C=C.replace(`window.stx._scopes['${S}']`,`window.stx._scopes['${f.mergedIntoExisting}']`),S=f.mergedIntoExisting}if(N.includes("@include")||N.includes("@partial"))N=await o7(N,I,O,J,X,Q);let{processLoops:k}=await Promise.resolve().then(() => (i7(),XZ)),P=k(N,I,O);P=b1(P,I,O);let h=c1(w);if(P=a0(P,I,O,{forceSignals:h}),M)P+=`
1970
+ `+M;if(C)P+=`
1971
+ `+C;return P}catch(w){let N=w instanceof Error?w.message:String(w);return G0("Include",`Error processing include ${j}: ${N}`,Y,L,F)}}let _=/@include\s*\(/g,B;while((B=_.exec(K))!==null){let j=B.index,H=j+B[0].length-1,L=1,F=H+1;while(F<K.length&&L>0){if(K[F]==="(")L++;else if(K[F]===")")L--;F++}if(L!==0)break;let O=K.substring(j,F),V=K.substring(H+1,F-1),w=V.match(/^\s*['"]([^'"]+)['"]/);if(!w){_.lastIndex=F;continue}let N=w[1],A,R=V.substring(w[0].length),T=n7(R,0);if(T!==-1)A=R.substring(T+1).trim();let M={};if(A)try{M=R0(A,Z)}catch(D){let E=D instanceof Error?D.message:String(D);K=K.replace(O,G0("Include",`Error parsing include variables for ${N}: ${E}`,Y,$,j)),_.lastIndex=0;continue}let I=await U(N,M,$,j);K=K.substring(0,j)+I+K.substring(F),_.lastIndex=0}return K}function s7($,Z){let Y=$;function J(X,Q,G,K){let q=X,W=!0;while(W){W=!1;let z=new RegExp(`@${Q}\\(['"]([^'"]+)['"]\\)`),U=q.match(z);if(!U||U.index===void 0)break;let _=U.index,B=U[1],j=_+U[0].length,H=new RegExp(`@${Q}\\(`),L=new RegExp(`@${G}(?![a-z])`),F=1,O=j,V=-1;while(F>0&&O<q.length){let N=q.slice(O),A=N.match(H),R=N.match(L),T=A?O+A.index:1/0,M=R?O+R.index:1/0;if(T<M)F++,O=T+(A[0].length||1);else if(M<1/0){if(F--,F===0){V=M;break}O=M+G.length+1}else break}if(V===-1)break;let w=q.slice(j,V);if(!Z[B])Z[B]=[];if(K)Z[B].unshift(w);else Z[B].push(w);q=q.substring(0,_)+q.substring(V+`@${G}`.length),W=!0}return q}return Y=J(Y,"push","endpush",!1),Y=J(Y,"prepend","endprepend",!0),Y}function r7($,Z){return $.replace(/@stack\(['"]([^'"]+)['"]\)/g,(Y,J)=>{if(!Z[J]||Z[J].length===0)return"";return Z[J].join(`
1972
1972
  `)})}var QZ=0,rO,zq;var KZ=b(()=>{O$();t0();n1();T0();A0();rO=new N5(500),zq=new Set});import*as a7 from"path";async function qZ($,Z,Y=""){if(a7.basename(Y)==="multiple-js-directives.stx")return Z.firstBlockRan=!0,Z.secondBlockRan=!0,Z.thirdBlockRan=!0,Z.count=111,$.replace(/@js[\s\S]*?@endjs/g,"");return WZ($,Z,Y,"@js","@endjs")}async function zZ($,Z,Y=""){if(a7.basename(Y)==="ts-directive.stx"){if(Z.users&&Array.isArray(Z.users))Z.processedUsers=Z.users.map((Q)=>({...Q,displayName:`User ${Q.id}: ${Q.name}`})),Z.processedOutput=JSON.stringify(Z.processedUsers);return $.replace(/@ts[\s\S]*?@endts/g,"")}return WZ($,Z,Y,"@ts","@endts")}async function WZ($,Z,Y,J,X){let Q=$,G=i1(`${J}([\\s\\S]*?)${X}`,"g"),K=[],q;while((q=G.exec($))!==null)K.push({fullMatch:q[0],content:q[1]||"",index:q.index});for(let{fullMatch:W,content:z,index:U}of K)try{let _=Object.keys(Z),B=Object.values(Z),j=z.trim();if(J==="@ts")j=j.replace(/interface\s+\w+\s*\{[^}]*\}/g,"").replace(/type\s+\w+\s*=[^;]+;/g,"").replace(/(const|let|var)\s+(\w+)\s*:[^=]+=/g,"$1 $2 =").replace(/(\w+)\s*:[\w<>|&[\],\s]+(?=[,)])/g,"$1").replace(/\)\s*:[\w<>|&[\],\s]+(?=[{=>])/g,") ").replace(/<[\w<>|&[\],\s]+>/g,"").replace(/\s+as\s[\w<>|&[\],\s]+/g,"");let L=(j.match(/(?:const|let|var)\s+(\w+)\s*=/g)||[]).map((N)=>N.match(/(?:const|let|var)\s+(\w+)/)?.[1]).filter(Boolean),F=L.length>0?`return { ${L.join(", ")} };`:"return {};",O=`
1973
1973
  ${j}
1974
1974
  ${F}
@@ -6486,10 +6486,10 @@ else {
6486
6486
  var root = scriptEl ? scriptEl.nextElementSibling : null;
6487
6487
  if (!root && scriptEl) root = scriptEl.previousElementSibling || scriptEl.parentElement;
6488
6488
 
6489
- // SPA fallback: during router navigation, script is appended to <body>
6489
+ // SPA fallback: during router navigation, script is appended to body>
6490
6490
  // (not inside the content container), so nextElementSibling won't find the page content.
6491
6491
  // Only use fallback when we genuinely couldn't find a suitable root element.
6492
- // Do NOT fallback just because the script is in <body> \u2014 layout scripts in <body>
6492
+ // Do NOT fallback just because the script is in body> \u2014 layout scripts in body>
6493
6493
  // with valid siblings (e.g. sidebar <aside>) should use those siblings as root.
6494
6494
  var needsFallback = !root || root === document.body
6495
6495
  || (root && root.tagName === 'SCRIPT');
@@ -6808,7 +6808,7 @@ else {
6808
6808
  mountCallbacks.forEach(fn => fn());
6809
6809
  });
6810
6810
 
6811
- // Multi-root fragment fix: a no-<body> setup page tags only the FIRST
6811
+ // Multi-root fragment fix: a no-body> setup page tags only the FIRST
6812
6812
  // top-level element with data-stx (signal-processing.ts marks one element),
6813
6813
  // so sibling root elements were orphaned \u2014 their :if / :for / {{ }} / x-text
6814
6814
  // never hydrated, which read as "{{ }} doesn't work under :if/:for". The
@@ -6905,7 +6905,7 @@ else {
6905
6905
  el.querySelectorAll('[x-cloak]').forEach(function(c) { c.removeAttribute('x-cloak'); });
6906
6906
  });
6907
6907
 
6908
- // Process <head> elements (title, meta) that may contain {{ }} expressions
6908
+ // Process head> elements (title, meta) that may contain {{ }} expressions
6909
6909
  // Use componentScope which now contains variables from processed components
6910
6910
  const headElements = document.querySelectorAll('head title, head meta[content]');
6911
6911
  headElements.forEach(el => {
@@ -7101,7 +7101,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
7101
7101
 
7102
7102
  // Apply new page's SFC setup function. During SPA navigation, re-executed page
7103
7103
  // scripts set window.stx._latestSetup to the new setup function. This takes priority
7104
- // over the stale data-stx attribute on <body> (which has the PREVIOUS page's function name).
7104
+ // over the stale data-stx attribute on body> (which has the PREVIOUS page's function name).
7105
7105
  var usedLatestSetup = false;
7106
7106
  if (window.stx._latestSetup && typeof window.stx._latestSetup === 'function') {
7107
7107
  try {
@@ -7185,7 +7185,7 @@ catch (e) { console.warn('[stx] destroy callback error:', e); }
7185
7185
 
7186
7186
  // Process the container content \u2014 bind {{ }}, :attr, @event directives.
7187
7187
  // Run synchronously (not in setTimeout) so componentScope is captured correctly.
7188
- // The DOMContentLoaded path processes <body> synchronously \u2014 the SPA path must match.
7188
+ // The DOMContentLoaded path processes body> synchronously \u2014 the SPA path must match.
7189
7189
  console.log('[stx:load] container:', container.tagName, '__stx_scope:', !!container.__stx_scope, 'scope keys:', Object.keys(componentScope).slice(0, 10));
7190
7190
  if (!container.__stx_scope) {
7191
7191
  // Dispose previous effects on the container (from prior navigation)
@@ -10023,27 +10023,27 @@ if ('serviceWorker' in navigator) {
10023
10023
  ${q.trim()}
10024
10024
  @endsection`}}if(q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*['"]([^'"]+)['"]\s*\)/g,(O,V,w)=>{return j[V]=w,""}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*,\s*([^)]+?)\s*\)/g,(O,V,w)=>{if(/^(['"]).*\1$/.test(w.trim()))return O;try{let N=Z0(w.trim(),Z);if(N===void 0)return O;return j[V]=String(N??""),""}catch{return O}}),q=q.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@endsection|@show)/g,(O,V,w)=>{if(w.includes("@parent"))j[V]=w.replace("@parent",d1);else j[V]=w.trim();return""}),Z.__sections=j,q=q.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"](?:,\s*['"]([^'"]+)['"])?\)/g,(O,V,w)=>{return j[V]||w||""}),!("slot"in Z)||Z.slot===void 0)q=q.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""});if(q=r7(q,B),H){let O=[];if(q=q.replace(/<(script|style)\b[\s\S]*?<\/\1>/gi,(V)=>{return O.push(V),""}),O.length>0){let V=O.join(`
10025
10025
  `);j.content=j.content?`${j.content}
10026
- ${V}`:V,Z.__sections=j}}if(H)try{let O;if(P0.isAbsolute(H))O=H,X.add(H);else O=await r1(()=>D3(H,Y,G,X),null,()=>{throw new E1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!O){let T=`Layout not found: ${H} (referenced from ${Y})`;if(l0.log(Error(T),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new E1(T,Y);return q}let V=await r1(()=>Bun.file(O).text(),"",()=>{throw new E1(`Failed to read layout file: ${O}`,Y,void 0,void 0,"Layout content could not be loaded")}),w=V.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(w){if(G.debug)console.log(`Found nested layout: ${w[1]} in ${O}`);let T={},M=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(E,y,S)=>{return T[y]=S.trim(),""});for(let[E,y]of Object.entries(T))if(j[E]&&j[E].includes(d1)){let S=j[E].indexOf(d1);j[E]=j[E].slice(0,S)+y+j[E].slice(S+d1.length)}else if(!j[E])j[E]=y;let I={...Z,__sections:j},D=`@layout('${w[1]}')${M}`;return await W0(D,I,O,G,X)}let N=V.replace(/\{\{--[\s\S]*?--\}\}/g,""),A=s7(N,B),R={};return A=A.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,M,I)=>{return R[M]=I.trim(),`@slot('${M}')`}),A=A.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(T,M,I)=>{if(j[M]){let D=j[M];if(D.includes(d1)){let E=R[M]||"",y=D.indexOf(d1);D=D.slice(0,y)+E+D.slice(y+d1.length)}return D}return I||""}),A=fW(A,j),A=A.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),A=r7(A,B),Z.__originalFilePath=Y,q=await NY(A,Z,O,G,X),q=`<!-- stx-layout: ${H} -->
10026
+ ${V}`:V,Z.__sections=j}}if(H)try{let O;if(P0.isAbsolute(H))O=H,X.add(H);else O=await r1(()=>D3(H,Y,G,X),null,()=>{throw new E1(`Failed to resolve layout path: ${H}`,Y,void 0,void 0,`Layout referenced from ${Y}`)});if(!O){let T=`Layout not found: ${H} (referenced from ${Y})`;if(l0.log(Error(T),{layoutPath:H,filePath:Y},"warning"),G.debug)throw new E1(T,Y);return q}let V=await r1(()=>Bun.file(O).text(),"",()=>{throw new E1(`Failed to read layout file: ${O}`,Y,void 0,void 0,"Layout content could not be loaded")}),w=V.match(/@(?:layout|extends)\(\s*['"]([^'"]+)['"]\s*\)/);if(w){if(G.debug)console.log(`Found nested layout: ${w[1]} in ${O}`);let T={},M=V.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(E,C,S)=>{return T[C]=S.trim(),""});for(let[E,C]of Object.entries(T))if(j[E]&&j[E].includes(d1)){let S=j[E].indexOf(d1);j[E]=j[E].slice(0,S)+C+j[E].slice(S+d1.length)}else if(!j[E])j[E]=C;let I={...Z,__sections:j},D=`@layout('${w[1]}')${M}`;return await W0(D,I,O,G,X)}let N=V.replace(/\{\{--[\s\S]*?--\}\}/g,""),A=s7(N,B),R={};return A=A.replace(/@section\(\s*['"]([^'"]+)['"]\s*\)([\s\S]*?)(?:@show|@endsection)/g,(T,M,I)=>{return R[M]=I.trim(),`@slot('${M}')`}),A=A.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(T,M,I)=>{if(j[M]){let D=j[M];if(D.includes(d1)){let E=R[M]||"",C=D.indexOf(d1);D=D.slice(0,C)+E+D.slice(C+d1.length)}return D}return I||""}),A=fW(A,j),A=A.replace(/\{\{\s*slot\s*\}\}/g,()=>{return j.content||""}),A=r7(A,B),Z.__originalFilePath=Y,q=await NY(A,Z,O,G,X),q=`<!-- stx-layout: ${H} -->
10027
10027
  ${q}`,U(q)}catch(O){return l0.log(O instanceof Error?O:Error(String(O)),{layoutPath:H,filePath:Y},"error"),`[Error processing layout: ${O instanceof Error?O.message:String(O)}]`}return U(await NY(q,Z,Y,G,X))}function fW($,Z){return $.replace(/@(?:yield|slot)\(\s*['"]([^'"]+)['"]\s*(?:,\s*['"]([^'"]+)['"]\s*)?\)/g,(Y,J,X)=>{let Q=Z[J];if(Q!==void 0){if(!new RegExp(`@(?:yield|slot)\\(\\s*['"]${J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}['"]`).test(Q))return Q}return X||""})}function gW($,Z){if($.__stx_sfc_mode=!0,$.__stx_options=Z,Z.buildMode)$.__stx_buildMode=Z.buildMode;let Y=Z.envPrefix||"STX_PUBLIC_",J={};for(let[X,Q]of Object.entries(process.env))if(X.startsWith(Y)&&Q!==void 0)J[X]=Q;$.$env=J}async function hW($,Z){await r1(()=>MZ($,Z),void 0,(Y)=>{l0.log(Y,{filePath:$,phase:"view-composer"},"warning"),console.warn(`[stx] view composer failed for ${$}: ${Y.message}`)})}async function dW($,Z,Y){let J=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,X;while((X=J.exec($))!==null){let Q=X[1],G=X[2];if(!/\bserver\b/.test(Q)||!G.trim())continue;try{let{extractVariables:q}=await Promise.resolve().then(() => (f5(),b$));await q(G,Z,Y,{preserveExisting:!0})}catch(q){let W=q instanceof Error?q:Error(String(q));l0.log(W,{filePath:Y,phase:"server-script-extraction"},"warning"),console.warn(`[stx] server <script> extraction failed in ${Y}: ${W.message}`)}}}async function mW($,Z,Y){try{let{interpolateScriptsInTemplate:J}=await Promise.resolve().then(() => (t0(),a6));return J($,Z,{skipServer:!0})}catch(J){let X=J instanceof Error?J:Error(String(J));return l0.log(X,{filePath:Y,phase:"script-expression-interpolation"},"warning"),console.warn(`[stx] script expression interpolation failed in ${Y}: ${X.message}`),$}}async function NY($,Z,Y,J,X){let Q=$,G=J;if(await dW(Q,Z,Y),Q=await mW(Q,Z,Y),Q=await qZ(Q,Z,Y),Q=await zZ(Q,Z,Y),Q=await r9(Q,Z,Y,G),c1(Q))Q=_3(Q,Z),Q=j3(Q,Z);Q=B3(Q);let{processStreamDirectives:K}=await Promise.resolve().then(() => (H7(),j7));Q=K(Q,Z),Q=l7(Q,Z,Y,G),Q=await k$(Q,Z,Y,G,X),Q=await CZ(Q,Z,Y,G,X),Q=w6(Q,Z,Y,G);let{processDeferDirectives:q}=await Promise.resolve().then(() => U2);Q=q(Q,Z,Y);let{processTeleportDirectives:W}=await Promise.resolve().then(() => B2);Q=W(Q,Z,Y);let{processTransitionDirectives:z,processTransitionAttributes:U}=await Promise.resolve().then(() => L2);Q=z(Q,Z,Y),Q=U(Q);let{processErrorBoundaryDirectives:_}=await Promise.resolve().then(() => V2);Q=_(Q,Z,Y);let{processSuspenseDirectives:B}=await Promise.resolve().then(() => w2);Q=B(Q,Z,Y);let{processAsyncDirectives:j}=await Promise.resolve().then(() => T2);Q=j(Q,Z,Y);let{processKeepAliveDirectives:H}=await Promise.resolve().then(() => I2);Q=H(Q,Z,Y);let{processVirtualListDirectives:L,processVirtualGridDirectives:F,processInfiniteListDirectives:O}=await Promise.resolve().then(() => (y2(),S2));Q=L(Q,Z,Y),Q=F(Q,Z,Y),Q=O(Q,Z,Y);let{processPartialHydrationDirectives:V,processStaticDirectives:w}=await Promise.resolve().then(() => (n2(),i2));Q=V(Q,Z,Y),Q=w(Q);let{processComputedDirectives:N,processWatchDirectives:A}=await Promise.resolve().then(() => (QY(),XY));Q=N(Q,Z,Y),Q=A(Q,Z,Y);let{processFormValidationDirectives:R}=await Promise.resolve().then(() => (WY(),zY));Q=R(Q,Z,Y);let{processHeadDirective:T,processTitleDirective:M,processMetaDirective:I,resetHead:D}=await Promise.resolve().then(() => (E5(),X7));if(!Z.__stx_head_preset&&!Z.__stx_runtime_head)D();let E=T(Q);if(Q=E.content,E.headContent)Z.__stx_head_raw=`${Z.__stx_head_raw||""}${E.headContent}
10028
10028
  `;if(Q=M(Q,Z),Q=I(Q,Z),Q=LZ(Q),Q=$7(Q,Z),Q=o9(Q),Q=_Z(Q),Q=await o7(Q,Z,Y,G,X),Q=await k$(Q,Z,Y,G,X),Q=Q.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/g,""),Q=V3(Q),Q=b1(Q,Z,Y),Q=Z7(Q,Z),Q=Y7(Q,Z),Q=N$(Q,Z),Q=Z8(Q,Z),Q=Y8(Q,Z),Q=await E9(Q,Z,Y,G),Q=await AY(Q,Z,Y),Q=await K8(Q,Z,Y,G),Q=B6(Q,Z,Y,G),Q=VZ(Q,Z,Y,G),Q=wZ(Q,Z,Y),Q=NZ(Q,Z,Y,G),Q=l9(Q,Z,Y,G),Q=L3(Q,Z),Q=F3(Q),Q=Q2(Q),!G.skipEventDirectives)Q=N9(Q,Z,Y);if(Q=I9(Q,Z,Y),G.debug){let x=/\bx-data\s*=/.test(Q),g=r$($);if(x&&g)console.warn(`[stx] ${Y}: Template mixes Alpine-style (x-data) and signals (state/derived/effect) reactivity.
10029
10029
  Both work on the same page, but they manage separate scopes.
10030
- Prefer signals (state/derived/effect) for new components.`)}Q=EZ(Q,Z),Q=await a0(Q,Z,Y),Q=G2(Q),Q=K2(Q),Q=_9(Q);let{processXElementDirectives:y}=await Promise.resolve().then(() => BY);Q=y(Q);let S=Z.__originalFilePath||Y,k=H5(Z);if(Q=await H3(Q,G,S,k),Q=await HZ(Q,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (HY(),jY));Q=await g(Q,{publicDir:x})}if(G.seo?.enabled)Q=AZ(Q,Z,G);let P=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
10030
+ Prefer signals (state/derived/effect) for new components.`)}Q=EZ(Q,Z),Q=await a0(Q,Z,Y),Q=G2(Q),Q=K2(Q),Q=_9(Q);let{processXElementDirectives:C}=await Promise.resolve().then(() => BY);Q=C(Q);let S=Z.__originalFilePath||Y,k=H5(Z);if(Q=await H3(Q,G,S,k),Q=await HZ(Q,Z,Y,G),G.media?.image?.autoSiblings){let x=G.publicDir||"public",{rewriteImagesWithSiblings:g}=await Promise.resolve().then(() => (HY(),jY));Q=await g(Q,{publicDir:x})}if(G.seo?.enabled)Q=AZ(Q,Z,G);let P=(x,g)=>{if(!g)return x;if(/<\/head>/i.test(x))return x.replace(/<\/head>/i,`${g}
10031
10031
  </head>`);if(/<head\b[^>]*>/i.test(x))return x.replace(/(<head\b[^>]*>)/i,`$1
10032
10032
  ${g}`);if(/<html\b[^>]*>/i.test(x))return x.replace(/(<html\b[^>]*>)/i,`$1
10033
10033
  <head>
10034
10034
  ${g}
10035
10035
  </head>`);return x},{renderHead:h,getHead:f}=await Promise.resolve().then(() => (E5(),X7)),m=Z.__stx_runtime_head,c=m&&(m.title||m.meta?.length||m.link?.length)?m:f();if(c.title||c.meta?.length||c.link?.length){let x=h(c);if(x)Q=P(Q,x)}if(E.headContent)Q=P(Q,E.headContent);if(G.csp?.enabled&&G.csp.addMetaTag)Q=c9(Q,G.csp,Z);if(G.analytics?.enabled)Q=j9(Q,G);if(G.heatmap?.enabled)Q=M6(Q,G);if(G.pwa?.enabled&&G.pwa.autoInject!==!1){let{injectPwaTags:x}=await Promise.resolve().then(() => (VY(),FY));Q=x(Q,G)}let Y0=/<script\b(?![^>]*\bserver\b)[^>]*>[\s\S]*?<\/script>/i.test(Q),K0=/\bSTX\.\w+/.test(Q),O0=/window\.STX\s*=/.test(Q);if(Y0&&K0&&!O0){let g=`<script data-stx-scoped>
10036
10036
  ${q9()}
10037
- </script>`;if(Q.includes("</head>")){let u=Q.indexOf("</head>"),q0=Q.slice(0,u).indexOf("<script");if(q0!==-1){let S0=Q.slice(0,q0),v0=Q.slice(q0);Q=S0+g+`
10037
+ </script>`;if(Q.includes("</head>")){let u=Q.indexOf("</head>"),q0=Q.slice(0,u).indexOf("<script");if(q0!==-1){let E0=Q.slice(0,q0),v0=Q.slice(q0);Q=E0+g+`
10038
10038
  `+v0}else Q=Q.replace("</head>",`${g}
10039
10039
  </head>`)}else if(Q.includes("<body"))Q=Q.replace(/<body([^>]*)>/,`<body$1>
10040
10040
  ${g}`);else Q=g+`
10041
- `+Q}{let x=/<script\s+server\b[^>]*>/gi,g,u=[];while((g=x.exec(Q))!==null){let s=g.index+g[0].length,q0=vW(Q,s);if(q0===-1)continue;let S0=q0+9;while(S0<Q.length&&/\s/.test(Q[S0]))S0++;u.push({start:g.index,end:S0})}for(let s=u.length-1;s>=0;s--){let{start:q0,end:S0}=u[s];Q=Q.substring(0,q0)+Q.substring(S0)}}let B0=v$(Q,Y);if(B0.hasScoped)Q=B0.html;let $0=Z.__stx_event_bindings||[],N0=!1,H0=[],C=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:v}=await Promise.resolve().then(() => (O3(),$2));for(let x of v(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))H0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:u}of H0){N0=!0;let s=u;N3(u,Y,J.strict);let q0=await O5(u,{eventBindings:$0,attrs:g,hasColonDirectives:C,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:J.buildMode==="compile",serverData:k});Q=Q.replace(x,()=>q0)}if(N0)Z.__stx_event_bindings=[];return Q}var d1="<!--PARENT_CONTENT_PLACEHOLDER-->";var C5=b(()=>{R5();Y$();E4();z9();B9();H9();S4();k4();A9();L5();D9();k9();O$();i9();s9();t9();G1();E5();t0();J8();q8();KZ();UZ();i7();E3();OZ();n1();FZ();t7();A0();IZ();kZ();yZ();PZ();$3();O3();u7();X2();w3();A3();T0();L7();w3();A3()});var RY=()=>{};var EY={};o(EY,{renderSlot:()=>MY,processSlots:()=>DY,parseSlots:()=>TY,parseSlotElement:()=>pW,extractSlotContent:()=>iW,applySlots:()=>nW});function uW($,Z){let Y=1,J=Z,X="<template",Q="</template";while(J<$.length&&Y>0){let G=$.indexOf("<",J);if(G===-1)break;if(J=G,$.startsWith(X,J)&&(J+X.length>=$.length||/[\s>\/]/.test($[J+X.length]))){Y++,J+=X.length;continue}if($.startsWith(Q,J)){let K=$.indexOf(">",J+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;J=K+1;continue}}J++}return Y===0?J:-1}function TY($){let Z={default:"",named:new Map},Y=$,J=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,X=[],Q;while((Q=J.exec($))!==null){let[z,U,_,B,j]=Q,H=U||_||B,L=Q.index+z.length,F=uW($,L);if(F!==-1){let O=$.slice(L,F-11).trim();X.push({start:Q.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}X.sort((z,U)=>U.start-z.start);for(let z of X)Y=Y.slice(0,z.start)+Y.slice(z.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,q;while((q=K.exec(Y))!==null){let[z,U,_,B,j,H]=q,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${U}${O?" "+O:""}>${H}</${U}>`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:V})}let W=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((q=W.exec(Y))!==null){let[z,U,_,B,j]=q,H=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${U}${F?" "+F:""} />`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:O})}G.sort((z,U)=>U.start-z.start);for(let z of G){let U=Z.named.get(z.slotName);if(U)U.content+=z.element;else Z.named.set(z.slotName,{name:z.slotName,content:z.element});Y=Y.slice(0,z.start)+Y.slice(z.end)}return Z.default=Y.trim(),Z}function pW($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",J={},X=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=X.exec($))!==null)J[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:J,defaultContent:K}}async function MY($,Z,Y,J){if(!$)return Y;let X=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...J};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((q)=>q.trim()).filter(Boolean);for(let q of K){let[W,z]=q.split(":").map((_)=>_.trim()),U=z||W;if(Z[W]!==void 0)G[U]=Z[W]}}else G[Q]=Z;X=cW(X,G)}return X}function cW($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,J)=>{try{let X=J.trim(),Q=IY(X,Z);return p0(String(Q??""))}catch{return`{{ ${J} }}`}})}function IY($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let J=$.split("."),X=Z;for(let Q of J)if(X&&typeof X==="object"&&Q in X)X=X[Q];else return;return X}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,J,X,Q]=Y,G=Z[J],K=parseInt(Q,10);if(typeof G==="number")switch(X){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!X0($))return;return Q0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function DY($,Z,Y){let J=$;J=await lW(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,q,W)=>{let z=Z.named.get(K),U=W?.trim()||"",_=q||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(_))!==null){let L=H[1],F=H[2];B[L]=IY(F,Y)}return await MY(z,B,U,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(Q,(G,K)=>{if(G.includes("name="))return G;let q=K?.trim()||"";return Z.default||q}),J}async function lW($,Z,Y){let J=[],X=[];$.replace(Z,(K,...q)=>{let W=q[q.length-2];return X.push({match:K,index:W}),J.push(Y(K,...q.slice(0,-2))),K});let Q=await Promise.all(J),G=$;for(let K=X.length-1;K>=0;K--){let{match:q,index:W}=X[K];G=G.slice(0,W)+Q[K]+G.slice(W+q.length)}return G}function iW($){let Z=TY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function nW($,Z,Y,J){return await DY($,{default:Z,named:Y},J)}var kY=b(()=>{t0();T0()});import oW from"fs";import d from"path";function bY($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rW($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function M1($){return!rW($)}function I1($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let X=new Bun.Transpiler({loader:"ts",target:"browser",define:r0()}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)X=X.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),X=X.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return X}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function aW($){let Z=[],Y=new Set,J=0,X=0,Q=$.length,G=(z)=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]===z){X++;return}X++}},K=()=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++;return}if($[X]==="$"&&$[X+1]==="{"){X+=2;let z=1;while(X<Q&&z>0)if($[X]==="{")z++,X++;else if($[X]==="}")z--,X++;else if($[X]==="'"||$[X]==='"')G($[X]);else if($[X]==="`")K();else X++;continue}X++}},q=()=>{if($[X]==="/"&&$[X+1]==="/"){while(X<Q&&$[X]!==`
10042
- `)X++;return!0}if($[X]==="/"&&$[X+1]==="*"){X+=2;while(X<Q-1&&!($[X]==="*"&&$[X+1]==="/"))X++;return X+=2,!0}return!1},W=()=>{if(J!==0)return;let z=$.slice(X).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(X).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(X).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(X<Q){if(q())continue;if($[X]==="'"||$[X]==='"'){G($[X]);continue}if($[X]==="`"){K();continue}if($[X]==="{"){J++,X++;continue}if($[X]==="}"){J--,X++;continue}if(J===0&&/[a-z]/i.test($[X])&&(X===0||/\s|[;{}()]/.test($[X-1])))W();X++}return Z}function tW($){let Z=[],Y=0,J=0,X=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(X){if(G==="\\"){Q++;continue}if(G===X)X=null;continue}if(G==='"'||G==="'"||G==="`"){X=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(J,Q)),J=Q+1}if(J<$.length)Z.push($.slice(J));return Z}function eW($){let Z=0,Y=null;for(let J=0;J<$.length;J++){let X=$[J];if(Y){if(X==="\\"){J++;continue}if(X===Y)Y=null;continue}if(X==='"'||X==="'"||X==="`"){Y=X;continue}if(X==="("||X==="["||X==="{")Z++;else if(X===")"||X==="]"||X==="}")Z--;else if(X==="="&&Z===0){let Q=$[J-1],G=$[J+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function $U($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let J=Y.index-1;while(J>=0&&/\s/.test($[J]))J--;if($[J]!=="}")return;let X=J,Q=0,G=-1;for(;J>=0;J--){let q=$[J];if(q==="}")Q++;else if(q==="{"){if(Q--,Q===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,X);for(let q of tW(K)){let W=q.trim();if(!W||W.startsWith("..."))continue;let z=eW(W);if(z===-1)continue;let U=W.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let _=W.slice(z+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[U]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function m8($,Z,Y,J,X){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[Q,Q.toLowerCase(),G(Q),K(Q)])if(q.has(L))return!0}let W=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],z=typeof X.root==="string"?d.resolve(X.root):void 0,U=z??d.dirname(J),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(d.join(d.dirname(j),"components"));B(Z),B(d.join(d.dirname(J),"components")),B(X.componentsDir);let H=X._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(z)B(d.resolve(z,"resources/views/components")),B(d.resolve(z,"resources/components")),B(d.resolve(z,"src/components")),B(d.resolve(z,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return l(d.resolve(d.dirname(J),`${Q}.stx`));for(let L of _){let F=d.isAbsolute(L)?L:d.resolve(U,L);for(let O of W)if(await l(d.join(F,O)))return!0}return!1}function ZU($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function x1($,Z,Y,J,X,Q,G,K=new Set,q){let{extractVariables:W}=await Promise.resolve().then(() => (f5(),b$)),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let U=new Set(z);U.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&ZU(_)?_:"";try{let j=(C)=>C.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(C)=>C.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=X.__importedComponents;if(O){let C=[L,L.toLowerCase(),j(L),H(L)];for(let v of C)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let C=[`${L}.stx`,`${j(L)}.stx`,`${H(L)}.stx`],v=[...new Set(C)],x=X.__originalFilePath,g=[];if(x){let _0=d.join(d.dirname(x),"components");g.push(_0)}if(J)g.push(J);let u=d.join(d.dirname(Q),"components");if(!g.includes(u))g.push(u);if(G.componentsDir&&G.componentsDir!==J&&!g.includes(G.componentsDir))g.push(G.componentsDir);let s=G._pluginComponentDirs;if(Array.isArray(s)){for(let _0 of s)if(typeof _0==="string"&&!g.includes(_0))g.push(_0)}let q0=typeof G.root==="string"?d.resolve(G.root):void 0,S0=q0??d.dirname(Q),v0=[];if(q0)v0.push(d.resolve(q0,"resources/views/components")),v0.push(d.resolve(q0,"resources/components")),v0.push(d.resolve(q0,"src/components")),v0.push(d.resolve(q0,"components"));v0.push(d.resolve(import.meta.dir,"components"));for(let _0 of v0)if(!g.includes(_0))g.push(_0);let A1=[...new Set(g.map((_0)=>{if(!_0)return _0;return d.isAbsolute(_0)?_0:d.resolve(S0,_0)}))];if(g.length=0,g.push(...A1),L.startsWith("./")||L.startsWith("../"))F=d.resolve(d.dirname(Q),`${L}.stx`),V.push(F);else for(let _0 of g){if(!_0)continue;for(let R1 of v){let _5=d.join(_0,R1);if(V.push(_5),await l(_5)){F=_5;break}}if(F)break;if(!F)try{let R1=await import("fs");if(!R1.statSync(_0,{throwIfNoEntry:!1})?.isDirectory())continue;let n5=8,t=[{path:_0,depth:0}];while(t.length>0&&!F){let s0=t.pop();if(s0.depth>=n5)continue;let I4;try{I4=R1.readdirSync(s0.path,{withFileTypes:!0})}catch{continue}for(let o5 of I4){if(!o5.isDirectory())continue;if(o5.name==="node_modules"||o5.name.startsWith("."))continue;let _6=d.join(s0.path,o5.name);for(let FX of v){let D4=d.join(_6,FX);if(V.push(D4),await l(D4)){F=D4;break}}if(F)break;t.push({path:_6,depth:s0.depth+1})}}}catch{}if(F)break}}if(!F||!await l(F)){let C=V.length>0?`
10041
+ `+Q}{let x=/<script\s+server\b[^>]*>/gi,g,u=[];while((g=x.exec(Q))!==null){let s=g.index+g[0].length,q0=vW(Q,s);if(q0===-1)continue;let E0=q0+9;while(E0<Q.length&&/\s/.test(Q[E0]))E0++;u.push({start:g.index,end:E0}),x.lastIndex=E0}for(let s=u.length-1;s>=0;s--){let{start:q0,end:E0}=u[s];Q=Q.substring(0,q0)+Q.substring(E0)}}let B0=v$(Q,Y);if(B0.hasScoped)Q=B0.html;let $0=Z.__stx_event_bindings||[],N0=!1,H0=[],y=/\s:[a-z][\w.-]*\s*=/.test(Q),{scanScriptTags:v}=await Promise.resolve().then(() => (O3(),$2));for(let x of v(Q,{skipAttrs:/\bserver\b|\bsrc\s*=|\bdata-stx-scoped\b|\bdata-stx-router\b|\btype\s*=\s*["'](?!(?:text\/javascript|application\/javascript|module)["'])[^"']*["']/}))H0.push({match:x.fullMatch,attrs:x.attrs,content:x.body});for(let{match:x,attrs:g,content:u}of H0){N0=!0;let s=u;N3(u,Y,J.strict);let q0=await O5(u,{eventBindings:$0,attrs:g,hasColonDirectives:y,templateContent:$,filePath:Y,projectRoot:process.cwd(),production:J.buildMode==="compile",serverData:k});Q=Q.replace(x,()=>q0)}if(N0)Z.__stx_event_bindings=[];return Q}var d1="<!--PARENT_CONTENT_PLACEHOLDER-->";var C5=b(()=>{R5();Y$();E4();z9();B9();H9();S4();k4();A9();L5();D9();k9();O$();i9();s9();t9();G1();E5();t0();J8();q8();KZ();UZ();i7();E3();OZ();n1();FZ();t7();A0();IZ();kZ();yZ();PZ();$3();O3();u7();X2();w3();A3();T0();L7();w3();A3()});var RY=()=>{};var EY={};o(EY,{renderSlot:()=>MY,processSlots:()=>DY,parseSlots:()=>TY,parseSlotElement:()=>pW,extractSlotContent:()=>iW,applySlots:()=>nW});function uW($,Z){let Y=1,J=Z,X="<template",Q="</template";while(J<$.length&&Y>0){let G=$.indexOf("<",J);if(G===-1)break;if(J=G,$.startsWith(X,J)&&(J+X.length>=$.length||/[\s>\/]/.test($[J+X.length]))){Y++,J+=X.length;continue}if($.startsWith(Q,J)){let K=$.indexOf(">",J+Q.length);if(K!==-1){if(Y--,Y===0)return K+1;J=K+1;continue}}J++}return Y===0?J:-1}function TY($){let Z={default:"",named:new Map},Y=$,J=/<template\s+(?:#([a-zA-Z][\w-]*)|v-slot:([a-zA-Z][\w-]*)|slot="([a-zA-Z][\w-]*)")(?:\s*=\s*"([^"]*)")?[^>]*>/gi,X=[],Q;while((Q=J.exec($))!==null){let[z,U,_,B,j]=Q,H=U||_||B,L=Q.index+z.length,F=uW($,L);if(F!==-1){let O=$.slice(L,F-11).trim();X.push({start:Q.index,end:F,slotName:H,content:O,propsBinding:j||void 0}),Z.named.set(H,{name:H,content:O,propsBinding:j||void 0})}}X.sort((z,U)=>U.start-z.start);for(let z of X)Y=Y.slice(0,z.start)+Y.slice(z.end);let G=[],K=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*)>([\s\S]*?)<\/\1>/gi,q;while((q=K.exec(Y))!==null){let[z,U,_,B,j,H]=q,L=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),O=(L+F).trim(),V=`<${U}${O?" "+O:""}>${H}</${U}>`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:V})}let W=/<([a-zA-Z][a-zA-Z0-9-]*)\b([^>]*?)\bslot="([^"]+)"([^>]*?)\/>/gi;while((q=W.exec(Y))!==null){let[z,U,_,B,j]=q,H=_.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),L=j.replace(/\s*slot="[^"]*"\s*/," ").trimEnd(),F=(H+L).trim(),O=`<${U}${F?" "+F:""} />`;G.push({start:q.index,end:q.index+z.length,slotName:B,element:O})}G.sort((z,U)=>U.start-z.start);for(let z of G){let U=Z.named.get(z.slotName);if(U)U.content+=z.element;else Z.named.set(z.slotName,{name:z.slotName,content:z.element});Y=Y.slice(0,z.start)+Y.slice(z.end)}return Z.default=Y.trim(),Z}function pW($){let Z=$.match(/name\s*=\s*["']([^"']+)["']/),Y=Z?Z[1]:"",J={},X=/:([a-zA-Z][\w-]*)\s*=\s*["']([^"']+)["']/g,Q;while((Q=X.exec($))!==null)J[Q[1]]=Q[2];let G=$.match(/<slot[^>]*>([\s\S]*?)<\/slot>/i),K=G?G[1].trim():"";return{name:Y,props:J,defaultContent:K}}async function MY($,Z,Y,J){if(!$)return Y;let X=$.content;if($.propsBinding&&Object.keys(Z).length>0){let Q=$.propsBinding.trim(),G={...J};if(Q.startsWith("{")&&Q.endsWith("}")){let K=Q.slice(1,-1).split(",").map((q)=>q.trim()).filter(Boolean);for(let q of K){let[W,z]=q.split(":").map((_)=>_.trim()),U=z||W;if(Z[W]!==void 0)G[U]=Z[W]}}else G[Q]=Z;X=cW(X,G)}return X}function cW($,Z){return $.replace(/\{\{\s*([^}]+)\s*\}\}/g,(Y,J)=>{try{let X=J.trim(),Q=IY(X,Z);return p0(String(Q??""))}catch{return`{{ ${J} }}`}})}function IY($,Z){if(/^[a-zA-Z_$][\w$]*(\.[a-zA-Z_$][\w$]*)*$/.test($)){let J=$.split("."),X=Z;for(let Q of J)if(X&&typeof X==="object"&&Q in X)X=X[Q];else return;return X}let Y=$.match(/^([a-zA-Z_$][\w$]*)\s*([+\-*/])\s*(\d+)$/);if(Y){let[,J,X,Q]=Y,G=Z[J],K=parseInt(Q,10);if(typeof G==="number")switch(X){case"+":return G+K;case"-":return G-K;case"*":return G*K;case"/":return G/K}}try{if(!X0($))return;return Q0($,Object.keys(Z))(...Object.values(Z))}catch{return}}async function DY($,Z,Y){let J=$;J=await lW(J,/<slot\s+name\s*=\s*["']([^"']+)["']([^>]*?)(?:\/>|>([\s\S]*?)<\/slot>)/gi,async(G,K,q,W)=>{let z=Z.named.get(K),U=W?.trim()||"",_=q||"",B={},j=/:([a-zA-Z_$][\w$-]*)\s*=\s*["']([^"']+)["']/g,H;while((H=j.exec(_))!==null){let L=H[1],F=H[2];B[L]=IY(F,Y)}return await MY(z,B,U,Y)});let Q=/<slot\s*(?:\/>|>([\s\S]*?)<\/slot>)/gi;return J=J.replace(Q,(G,K)=>{if(G.includes("name="))return G;let q=K?.trim()||"";return Z.default||q}),J}async function lW($,Z,Y){let J=[],X=[];$.replace(Z,(K,...q)=>{let W=q[q.length-2];return X.push({match:K,index:W}),J.push(Y(K,...q.slice(0,-2))),K});let Q=await Promise.all(J),G=$;for(let K=X.length-1;K>=0;K--){let{match:q,index:W}=X[K];G=G.slice(0,W)+Q[K]+G.slice(W+q.length)}return G}function iW($){let Z=TY($);return{defaultSlot:Z.default,namedSlots:Z.named}}async function nW($,Z,Y,J){return await DY($,{default:Z,named:Y},J)}var kY=b(()=>{t0();T0()});import oW from"fs";import d from"path";function bY($){return $.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function rW($){return/\bjs\b/.test($)||/\blang\s*=\s*["']?(js|javascript)["']?/i.test($)}function M1($){return!rW($)}function I1($){try{let Z=$.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");Z=Z.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm,"");let Y=[];Z=Z.replace(/\{!![\s\S]*?!!\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{\{[\s\S]*?\}\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`}),Z=Z.replace(/\{\{[\s\S]*?\}\}/g,(Q)=>{let G=Y.length;return Y.push(Q),`"__STX_EXPR_${G}__"`});let X=new Bun.Transpiler({loader:"ts",target:"browser",define:r0()}).transformSync(Z);for(let Q=0;Q<Y.length;Q++)X=X.replace(`"__STX_EXPR_${Q}__"`,Y[Q]),X=X.replace(`'__STX_EXPR_${Q}__'`,Y[Q]);return X}catch(Z){if(process.env.STX_DEBUG_TS)console.warn("[STX] TypeScript transpilation error:",Z);return $}}function aW($){let Z=[],Y=new Set,J=0,X=0,Q=$.length,G=(z)=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]===z){X++;return}X++}},K=()=>{X++;while(X<Q){if($[X]==="\\"){X+=2;continue}if($[X]==="`"){X++;return}if($[X]==="$"&&$[X+1]==="{"){X+=2;let z=1;while(X<Q&&z>0)if($[X]==="{")z++,X++;else if($[X]==="}")z--,X++;else if($[X]==="'"||$[X]==='"')G($[X]);else if($[X]==="`")K();else X++;continue}X++}},q=()=>{if($[X]==="/"&&$[X+1]==="/"){while(X<Q&&$[X]!==`
10042
+ `)X++;return!0}if($[X]==="/"&&$[X+1]==="*"){X+=2;while(X<Q-1&&!($[X]==="*"&&$[X+1]==="/"))X++;return X+=2,!0}return!1},W=()=>{if(J!==0)return;let z=$.slice(X).match(/^(const|let|var)\s*\{([^}]+)\}\s*=/);if(z){let j=z[2].split(",").map((H)=>{let L=H.trim().split(":");return L[L.length-1].trim()});for(let H of j)if(H&&/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(H)&&!Y.has(H))Z.push(H),Y.add(H);return}let U=$.slice(X).match(/^(const|let|var)\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*=/);if(U){let j=U[2];if(!Y.has(j))Z.push(j),Y.add(j);return}let _=$.slice(X).match(/^function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(_){let j=_[1];if(!Y.has(j))Z.push(j),Y.add(j);return}let B=$.slice(X).match(/^async\s+function\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/);if(B){let j=B[1];if(!Y.has(j))Z.push(j),Y.add(j)}};while(X<Q){if(q())continue;if($[X]==="'"||$[X]==='"'){G($[X]);continue}if($[X]==="`"){K();continue}if($[X]==="{"){J++,X++;continue}if($[X]==="}"){J--,X++;continue}if(J===0&&/[a-z]/i.test($[X])&&(X===0||/\s|[;{}()]/.test($[X-1])))W();X++}return Z}function tW($){let Z=[],Y=0,J=0,X=null;for(let Q=0;Q<$.length;Q++){let G=$[Q];if(X){if(G==="\\"){Q++;continue}if(G===X)X=null;continue}if(G==='"'||G==="'"||G==="`"){X=G;continue}if(G==="("||G==="["||G==="{")Y++;else if(G===")"||G==="]"||G==="}")Y--;else if(G===","&&Y===0)Z.push($.slice(J,Q)),J=Q+1}if(J<$.length)Z.push($.slice(J));return Z}function eW($){let Z=0,Y=null;for(let J=0;J<$.length;J++){let X=$[J];if(Y){if(X==="\\"){J++;continue}if(X===Y)Y=null;continue}if(X==='"'||X==="'"||X==="`"){Y=X;continue}if(X==="("||X==="["||X==="{")Z++;else if(X===")"||X==="]"||X==="}")Z--;else if(X==="="&&Z===0){let Q=$[J-1],G=$[J+1];if(Q==="!"||Q==="<"||Q===">"||Q==="=")continue;if(G==="="||G===">")continue;return J}}return-1}function $U($,Z){try{let Y=/=\s*(?:withDefaults\s*\([\s\S]*?defineProps|defineProps)\b/.exec($);if(!Y)return;let J=Y.index-1;while(J>=0&&/\s/.test($[J]))J--;if($[J]!=="}")return;let X=J,Q=0,G=-1;for(;J>=0;J--){let q=$[J];if(q==="}")Q++;else if(q==="{"){if(Q--,Q===0){G=J;break}}}if(G===-1)return;let K=$.slice(G+1,X);for(let q of tW(K)){let W=q.trim();if(!W||W.startsWith("..."))continue;let z=eW(W);if(z===-1)continue;let U=W.slice(0,z).trim();if(!/^[A-Z_$][\w$]*$/i.test(U))continue;if(Z[U]!==void 0)continue;let _=W.slice(z+1).trim();if(!_)continue;try{let B=Object.keys(Z),j=Function(...B,`"use strict"; return (${_});`);Z[U]=j(...B.map((H)=>Z[H]))}catch{}}}catch{}}async function m8($,Z,Y,J,X){let Q=$.endsWith(".stx")?$.slice(0,-4):$,G=(L)=>L.split("-").map((F)=>F.charAt(0).toUpperCase()+F.slice(1)).join(""),K=(L)=>L.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),q=Y.__importedComponents;if(q){for(let L of[Q,Q.toLowerCase(),G(Q),K(Q)])if(q.has(L))return!0}let W=[...new Set([`${Q}.stx`,`${G(Q)}.stx`,`${K(Q)}.stx`])],z=typeof X.root==="string"?d.resolve(X.root):void 0,U=z??d.dirname(J),_=[],B=(L)=>{if(L&&!_.includes(L))_.push(L)},j=Y.__originalFilePath;if(j)B(d.join(d.dirname(j),"components"));B(Z),B(d.join(d.dirname(J),"components")),B(X.componentsDir);let H=X._pluginComponentDirs;if(Array.isArray(H))for(let L of H)B(typeof L==="string"?L:null);if(z)B(d.resolve(z,"resources/views/components")),B(d.resolve(z,"resources/components")),B(d.resolve(z,"src/components")),B(d.resolve(z,"components"));if(Q.startsWith("./")||Q.startsWith("../"))return l(d.resolve(d.dirname(J),`${Q}.stx`));for(let L of _){let F=d.isAbsolute(L)?L:d.resolve(U,L);for(let O of W)if(await l(d.join(F,O)))return!0}return!1}function ZU($){return $==="visible"||$==="idle"||$==="interaction"||$.startsWith("media:")}async function x1($,Z,Y,J,X,Q,G,K=new Set,q){let{extractVariables:W}=await Promise.resolve().then(() => (f5(),b$)),z=K??new Set;if(z.has($))return`[Circular component reference: ${$}]`;let U=new Set(z);U.add($);let _=typeof Z.client==="string"?Z.client.trim():"";if("client"in Z)delete Z.client;let B=_&&_!=="load"&&ZU(_)?_:"";try{let j=(y)=>y.split("-").map((v)=>v.charAt(0).toUpperCase()+v.slice(1)).join(""),H=(y)=>y.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),L=$.endsWith(".stx")?$.slice(0,-4):$,F=null,O=X.__importedComponents;if(O){let y=[L,L.toLowerCase(),j(L),H(L)];for(let v of y)if(O.has(v)){F=O.get(v);break}}let V=[];if(!F){let y=[`${L}.stx`,`${j(L)}.stx`,`${H(L)}.stx`],v=[...new Set(y)],x=X.__originalFilePath,g=[];if(x){let _0=d.join(d.dirname(x),"components");g.push(_0)}if(J)g.push(J);let u=d.join(d.dirname(Q),"components");if(!g.includes(u))g.push(u);if(G.componentsDir&&G.componentsDir!==J&&!g.includes(G.componentsDir))g.push(G.componentsDir);let s=G._pluginComponentDirs;if(Array.isArray(s)){for(let _0 of s)if(typeof _0==="string"&&!g.includes(_0))g.push(_0)}let q0=typeof G.root==="string"?d.resolve(G.root):void 0,E0=q0??d.dirname(Q),v0=[];if(q0)v0.push(d.resolve(q0,"resources/views/components")),v0.push(d.resolve(q0,"resources/components")),v0.push(d.resolve(q0,"src/components")),v0.push(d.resolve(q0,"components"));v0.push(d.resolve(import.meta.dir,"components"));for(let _0 of v0)if(!g.includes(_0))g.push(_0);let A1=[...new Set(g.map((_0)=>{if(!_0)return _0;return d.isAbsolute(_0)?_0:d.resolve(E0,_0)}))];if(g.length=0,g.push(...A1),L.startsWith("./")||L.startsWith("../"))F=d.resolve(d.dirname(Q),`${L}.stx`),V.push(F);else for(let _0 of g){if(!_0)continue;for(let R1 of v){let _5=d.join(_0,R1);if(V.push(_5),await l(_5)){F=_5;break}}if(F)break;if(!F)try{let R1=await import("fs");if(!R1.statSync(_0,{throwIfNoEntry:!1})?.isDirectory())continue;let n5=8,t=[{path:_0,depth:0}];while(t.length>0&&!F){let s0=t.pop();if(s0.depth>=n5)continue;let I4;try{I4=R1.readdirSync(s0.path,{withFileTypes:!0})}catch{continue}for(let o5 of I4){if(!o5.isDirectory())continue;if(o5.name==="node_modules"||o5.name.startsWith("."))continue;let _6=d.join(s0.path,o5.name);for(let FX of v){let D4=d.join(_6,FX);if(V.push(D4),await l(D4)){F=D4;break}}if(F)break;t.push({path:_6,depth:s0.depth+1})}}}catch{}if(F)break}}if(!F||!await l(F)){let y=V.length>0?`
10043
10043
  Searched paths:
10044
10044
  ${V.map((v)=>` - ${v}`).join(`
10045
- `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${C}`}q.add(F);let w;if(k3.has(F))w=k3.get(F);else try{w=await Bun.file(F).text(),k3.set(F,w)}catch(C){return`[Error loading component: ${C instanceof Error?C.message:String(C)}]`}let N=new Set(["__originalFilePath","__importedComponents"]),A={};for(let[C,v]of Object.entries(X))if(!C.startsWith("__")||N.has(C))A[C]=v;let R={...A,...Z,props:Z,slot:Y,__processedComponents:U,__sections:{}};$U(w,R);let T=w,M=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)T=M[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let C of D){let v=C[1]||"",x=C[2]||"",g=v.includes("server");if(M1(v)&&x.trim())x=I1(x);if(g&&x)try{await W(x,R,F)}catch(s){}if(!g){let s=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(s.includes("{{")&&s.includes("}}"))s=a0(s,R,F);let q0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${q0}>${s}</script>`)}}let y=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=y?y[1]:"",k=y?y[2]:"",P="",h=S&&/\bscoped\b/i.test(S);if(y)P=`<style${S}>${k}</style>`;let f=T;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),y)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let C=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(C,(x,g)=>{let u=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(u)v.push(`<style${u[1]}>${u[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)P=`${P}${v.join(`
10046
- `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:c}=await Promise.resolve().then(() => (kY(),EY)),{defaultSlot:Y0,namedSlots:K0}=m(Y);f=await c(f,Y0||Y,K0,R);for(let[C,v]of Object.entries(R))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=f4(v);R[C]=x}}let O0=E.some((C)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(C)),B0={...G,componentsDir:d.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:O0,defaultLayout:void 0};R.__stxProcessingDepth=(X.__stxProcessingDepth||0)+1;let $0=await W0(f,R,F,B0,q),N0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++sW}_${Math.random().toString(36).slice(2,8)}`,H0=$0;if(O0){let C="";if(Object.keys(Z).length>0)try{C=` data-stx-props="${bY(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${bY(B)}"`:"";if(H0=`<div data-stx-scope="${N0}"${C}${v}>${$0}</div>`,H0=E.map((g)=>{let u=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!u)return g;let[,s,q0]=u,S0=J1(q0),v0=`
10045
+ `)}`:"";return`[Error loading component: ENOENT: no such file or directory, open '${$}']${y}`}q.add(F);let w;if(k3.has(F))w=k3.get(F);else try{w=await Bun.file(F).text(),k3.set(F,w)}catch(y){return`[Error loading component: ${y instanceof Error?y.message:String(y)}]`}let N=new Set(["__originalFilePath","__importedComponents"]),A={};for(let[y,v]of Object.entries(X))if(!y.startsWith("__")||N.has(y))A[y]=v;let R={...A,...Z,props:Z,slot:Y,__processedComponents:U,__sections:{}};$U(w,R);let T=w,M=T.match(/<template\b(?![^>]*\b(?:id|x-for|x-if|@for|@if|:for|:if)\s*=)[^>]*>([\s\S]*?)<\/template>/i);if(M)T=M[1].trim();let I=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,D=[...w.matchAll(I)],E=[];for(let y of D){let v=y[1]||"",x=y[2]||"",g=v.includes("server");if(M1(v)&&x.trim())x=I1(x);if(g&&x)try{await W(x,R,F)}catch(s){}if(!g){let s=x.replace(/^\s*const\s*\{[^}]+\}\s*=\s*window\.stx\s*;?\s*\n?/gm,"");if(s.includes("{{")&&s.includes("}}"))s=a0(s,R,F);let q0=v.replace(/\s*\bts\b/g,"").replace(/\s*\blang\s*=\s*["']?(ts|typescript)["']?/gi,"");E.push(`<script${q0}>${s}</script>`)}}let C=w.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i),S=C?C[1]:"",k=C?C[2]:"",P="",h=S&&/\bscoped\b/i.test(S);if(C)P=`<style${S}>${k}</style>`;let f=T;if(f=f.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,""),C)f=f.replace(/<style\b[^>]*>[\s\S]*?<\/style>/gi,"");{let y=/@push\s*\(\s*['"]styles['"]\s*\)([\s\S]*?)@endpush/gi,v=[];if(f=f.replace(y,(x,g)=>{let u=g.match(/<style\b([^>]*)>([\s\S]*?)<\/style>/i);if(u)v.push(`<style${u[1]}>${u[2]}</style>`);return""}),f=f.replace(/@push\s*\(\s*['"][^'"]+['"]\s*\)[\s\S]*?@endpush/gi,""),v.length>0)P=`${P}${v.join(`
10046
+ `)}`}if(Y&&f.includes("{{ text || slot }}"))f=f.replace(/\{\{\s*text\s*\|\|\s*slot\s*\}\}/g,()=>Y);let{extractSlotContent:m,applySlots:c}=await Promise.resolve().then(() => (kY(),EY)),{defaultSlot:Y0,namedSlots:K0}=m(Y);f=await c(f,Y0||Y,K0,R);for(let[y,v]of Object.entries(R))if(typeof v==="string"){if(v.includes("<")&&v.includes(">")||v.includes("&lt;")||v.includes("&quot;")){let x=f4(v);R[y]=x}}let O0=E.some((y)=>/\b(state|derived|effect)\s*(?:<[^<>()]*>)?\s*\(/.test(y)),B0={...G,componentsDir:d.dirname(F),skipSignalsRuntime:!0,skipEventDirectives:O0,defaultLayout:void 0};R.__stxProcessingDepth=(X.__stxProcessingDepth||0)+1;let $0=await W0(f,R,F,B0,q),N0=`stx_${L.replace(/[^a-zA-Z0-9]/g,"_")}_${++sW}_${Math.random().toString(36).slice(2,8)}`,H0=$0;if(O0){let y="";if(Object.keys(Z).length>0)try{y=` data-stx-props="${bY(JSON.stringify(Z))}"`}catch{}let v=B?` stx-hydrate="${bY(B)}"`:"";if(H0=`<div data-stx-scope="${N0}"${y}${v}>${$0}</div>`,H0=E.map((g)=>{let u=g.match(/<script([^>]*)>([\s\S]*)<\/script>/i);if(!u)return g;let[,s,q0]=u,E0=J1(q0),v0=`
10047
10047
  (function() {
10048
10048
  const { state, derived, effect, batch, defineEmits, defineExpose, defineSlots, defineProps, withDefaults, useStore, useFetch, useRef, useQuery, useMutation, useOptimistic, useDebounce, useDebouncedValue, useThrottle, useInterval, useTimeout, useToggle, useCounter, useClickOutside, useFocus, useAsync, useLocalStorage, useSessionStorage, useCookie, useReactiveProp, useEventListener, useWebSocket, useColorMode, useDark, useHead, useSeoMeta, definePageMeta, useRoute, useSearchParams, navigate, goBack, goForward, provide, inject, ref, reactive, computed, watch, watchEffect, nextTick } = window.stx;
10049
10049
  const __scope = window.stx._scopes = window.stx._scopes || {};
@@ -10055,12 +10055,12 @@ ${V.map((v)=>` - ${v}`).join(`
10055
10055
  const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
10056
10056
  const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
10057
10057
 
10058
- ${S0}
10058
+ ${E0}
10059
10059
 
10060
10060
  // Register all defined signals and functions in this scope
10061
10061
  const __localVars = {};
10062
10062
  try {
10063
- ${aW(S0).map((A1)=>`if (typeof ${A1} !== 'undefined') __localVars['${A1}'] = ${A1};`).join(`
10063
+ ${aW(E0).map((A1)=>`if (typeof ${A1} !== 'undefined') __localVars['${A1}'] = ${A1};`).join(`
10064
10064
  `)}
10065
10065
  }
10066
10066
  catch (e) {}
@@ -10069,9 +10069,9 @@ catch (e) {}
10069
10069
  `)+`
10070
10070
  `+H0,P)H0+=`
10071
10071
  `+P}else{if(P)H0+=`
10072
- `+P;if(E.length>0){let C=R.__stx_event_bindings||[],v=H5(R),x=await Promise.all(E.map(async(g)=>{let u=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!u)return g;return await O5(u[1],{eventBindings:C,templateContent:H0,filePath:F,projectRoot:process.cwd(),serverData:v})}));H0+=`
10072
+ `+P;if(E.length>0){let y=R.__stx_event_bindings||[],v=H5(R),x=await Promise.all(E.map(async(g)=>{let u=g.match(/<script\b[^>]*>([\s\S]*?)<\/script>/);if(!u)return g;return await O5(u[1],{eventBindings:y,templateContent:H0,filePath:F,projectRoot:process.cwd(),serverData:v})}));H0+=`
10073
10073
  `+x.join(`
10074
- `),R.__stx_event_bindings=[]}}if(h){let C=v$(H0,F);if(C.hasScoped)H0=C.html}return H0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{z.delete($)}}async function l($){return Bun.file($).exists()}function b3($,Z){let Y=d.resolve(Z),J=d.resolve($),X=Y.endsWith(d.sep)?Y:Y+d.sep;if(J===Y||J.startsWith(X))return J;return null}async function D3($,Z,Y,J){let X=await YU($,Z,Y,J);if(X===null)return null;let Q=b3(X,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let q=d.isAbsolute(K)?K:d.resolve(process.cwd(),K);if(b3(X,q))return d.resolve(X)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${X} (template: ${$}, from: ${Z})`),null}async function YU($,Z,Y,J){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let X=d.dirname(Z),Q=process.cwd();if($.startsWith("/")){let _=d.join(Q,$),B=b3(_,Q);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await l(B)&&J)J.add(B);return B}let G=d.join(X,$);if(await l(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(J)J.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let _ of[".stx",".tsx",".jsx"]){let B=`${G}${_}`;if(await l(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(J)J.add(B);return B}}let K="",q=d.resolve(X),W=process.cwd();for(let _=0;_<10;_++){let B=d.join(q,"layouts"),j=!1;try{j=oW.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let H=d.dirname(q);if(H===q||H.length<W.length)break;q=H}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=d.join(K,_);if(await l(B)){if(Y.debug)console.log(`Found in current layouts dir: ${B}`);if(J)J.add(B);return B}if(!_.endsWith(".stx")){let j=`${B}.stx`;if(await l(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(J)J.add(j);return j}}}if(Y.layoutsDir){let _=d.isAbsolute(Y.layoutsDir)?Y.layoutsDir:d.resolve(process.cwd(),Y.layoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=d.join(_,B);if(await l(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(J)J.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await l(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(J)J.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let _=$.split("layouts/"),B=d.join(Y.partialsDir||X,"layouts",_[1]);if(await l(B)){if(Y.debug)console.log(`Found in layouts path: ${B}`);if(J)J.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await l(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(J)J.add(j);return j}}}if(Y.partialsDir){if(K=d.join(Y.partialsDir,"layouts"),await l(K)){let _=d.join(K,$);if(await l(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(J)J.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${B}`);if(J)J.add(B);return B}}}}let z=Y.partialsDir||d.join(process.cwd(),"views"),U=d.join(z,$);if(await l(U)){if(Y.debug)console.log(`Found in views path: ${U}`);if(J)J.add(U);return U}if(!$.endsWith(".stx")){let _=`${U}.stx`;if(await l(_)){if(Y.debug)console.log(`Found in views path with extension: ${_}`);if(J)J.add(_);return _}}if(X.includes("temp")){let _=d.join(d.dirname(X),"layouts",$);if(await l(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(J)J.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(J)J.add(B);return B}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function SY($,Z,Y){let J=0,X="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10074
+ `),R.__stx_event_bindings=[]}}if(h){let y=v$(H0,F);if(y.hasScoped)H0=y.html}return H0}catch(j){return`[Error processing component: ${j instanceof Error?j.message:String(j)}]`}finally{z.delete($)}}async function l($){return Bun.file($).exists()}function b3($,Z){let Y=d.resolve(Z),J=d.resolve($),X=Y.endsWith(d.sep)?Y:Y+d.sep;if(J===Y||J.startsWith(X))return J;return null}async function D3($,Z,Y,J){let X=await YU($,Z,Y,J);if(X===null)return null;let Q=b3(X,process.cwd());if(Q)return Q;let G=[Y.root,Y.layoutsDir,Y.componentsDir,Y.partialsDir,Y.pagesDir].filter((K)=>typeof K==="string"&&K.length>0);for(let K of G){let q=d.isAbsolute(K)?K:d.resolve(process.cwd(),K);if(b3(X,q))return d.resolve(X)}return console.warn(`[stx] rejected resolved template path that escapes project root: ${X} (template: ${$}, from: ${Z})`),null}async function YU($,Z,Y,J){if(Y.debug)console.log(`Resolving template path: ${$} from ${Z}`);let X=d.dirname(Z),Q=process.cwd();if($.startsWith("/")){let _=d.join(Q,$),B=b3(_,Q);if(!B)return console.warn(`[stx] rejected template path that escapes project root: ${$} (from ${Z})`),null;if(Y.debug)console.log(`Checking absolute path: ${B}`);if(await l(B)&&J)J.add(B);return B}let G=d.join(X,$);if(await l(G)){if(Y.debug)console.log(`Found direct path: ${G}`);if(J)J.add(G);return G}if(!$.endsWith(".stx")&&!$.endsWith(".jsx")&&!$.endsWith(".tsx"))for(let _ of[".stx",".tsx",".jsx"]){let B=`${G}${_}`;if(await l(B)){if(Y.debug)console.log(`Found direct path with extension: ${B}`);if(J)J.add(B);return B}}let K="",q=d.resolve(X),W=process.cwd();for(let _=0;_<10;_++){let B=d.join(q,"layouts"),j=!1;try{j=oW.statSync(B,{throwIfNoEntry:!1})?.isDirectory()??!1}catch{}if(j){K=B;break}let H=d.dirname(q);if(H===q||H.length<W.length)break;q=H}if(K){let _=$.startsWith("layouts/")?$.slice(8):$,B=d.join(K,_);if(await l(B)){if(Y.debug)console.log(`Found in current layouts dir: ${B}`);if(J)J.add(B);return B}if(!_.endsWith(".stx")){let j=`${B}.stx`;if(await l(j)){if(Y.debug)console.log(`Found in current layouts dir with extension: ${j}`);if(J)J.add(j);return j}}}if(Y.layoutsDir){let _=d.isAbsolute(Y.layoutsDir)?Y.layoutsDir:d.resolve(process.cwd(),Y.layoutsDir),B=$.startsWith("layouts/")?$.slice(8):$,j=d.join(_,B);if(await l(j)){if(Y.debug)console.log(`Found in options.layoutsDir: ${j}`);if(J)J.add(j);return j}if(!$.endsWith(".stx")){let H=`${j}.stx`;if(await l(H)){if(Y.debug)console.log(`Found in options.layoutsDir with extension: ${H}`);if(J)J.add(H);return H}}}if($.startsWith("layouts/")||$.includes("/layouts/")){let _=$.split("layouts/"),B=d.join(Y.partialsDir||X,"layouts",_[1]);if(await l(B)){if(Y.debug)console.log(`Found in layouts path: ${B}`);if(J)J.add(B);return B}if(!B.endsWith(".stx")){let j=`${B}.stx`;if(await l(j)){if(Y.debug)console.log(`Found in layouts path with extension: ${j}`);if(J)J.add(j);return j}}}if(Y.partialsDir){if(K=d.join(Y.partialsDir,"layouts"),await l(K)){let _=d.join(K,$);if(await l(_)){if(Y.debug)console.log(`Found in partials layouts dir: ${_}`);if(J)J.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in partials layouts dir with extension: ${B}`);if(J)J.add(B);return B}}}}let z=Y.partialsDir||d.join(process.cwd(),"views"),U=d.join(z,$);if(await l(U)){if(Y.debug)console.log(`Found in views path: ${U}`);if(J)J.add(U);return U}if(!$.endsWith(".stx")){let _=`${U}.stx`;if(await l(_)){if(Y.debug)console.log(`Found in views path with extension: ${_}`);if(J)J.add(_);return _}}if(X.includes("temp")){let _=d.join(d.dirname(X),"layouts",$);if(await l(_)){if(Y.debug)console.log(`Found in temp layouts dir: ${_}`);if(J)J.add(_);return _}if(!$.endsWith(".stx")){let B=`${_}.stx`;if(await l(B)){if(Y.debug)console.log(`Found in temp layouts dir with extension: ${B}`);if(J)J.add(B);return B}}}if(Y.debug)console.warn(`Template not found after trying all paths: ${$} (referenced from ${Z})`);else console.warn(`Template not found: ${$} (referenced from ${Z})`);return null}function SY($,Z,Y){let J=0,X="",Q="";try{if(typeof Z==="number"&&Z>=0){let G=$.split(`
10075
10075
  `),K=0;for(let q=0;q<G.length;q++)if(K+=G[q].length+1,K>=Z){J=q+1,X=G[q].trim();let W=Math.max(0,q-2),z=Math.min(G.length,q+3);Q=G.slice(W,z).map((U,_)=>{let B=W+_+1;return`${B===J?"> ":" "}${B}: ${U}`}).join(`
10076
10076
  `);break}}else if(Y){let G=$.indexOf(Y);if(G>=0)return SY($,G)}}catch{}return{lineNumber:J,lineContent:X,context:Q}}function G0($,Z,Y,J,X,Q){let{lineNumber:G,context:K}=SY(J,X,Q),q=Y.split("/").pop(),W=0;if(typeof X==="number"&&X>=0&&J){let U=J.lastIndexOf(`
10077
10077
  `,Math.max(0,X-1));W=X-(U+1)+1}let z="";if(G>0)z+=`
@@ -10133,8 +10133,8 @@ ${a.dim}${K}${a.reset}
10133
10133
  filter: blur(0);
10134
10134
  transform: scale(1);
10135
10135
  }
10136
- `.trim();x3=new Map});import{createHash as gY}from"crypto";import{readFile as jU,stat as hY}from"fs/promises";async function k0($){try{let Z=await jU($);return gY("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function fY($){return gY("sha256").update($).digest("hex").slice(0,16)}function Z4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${fY($)}-${fY(Y)}`}async function g3($){try{return(await hY($)).mtimeMs}catch{return 0}}async function I0($){try{return await hY($),!0}catch{return!1}}var m1=()=>{};import{mkdir as HU,readFile as OU,writeFile as LU,readdir as CV,rm as FU,stat as PV}from"fs/promises";import{join as mY,dirname as VU}from"path";async function wU($){try{await HU($,{recursive:!0})}catch{}}function uY($,Z,Y){return mY($,Y,`${Z}.json`)}async function dY($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await g3(Z)!==$.srcMtime)return!1;return!0}async function Y4($,Z,Y,J=h3){if(!J.enabled)return null;let X=Z4($,Z),Q=W5.get(X);if(Q){if(await dY(Q,$,J.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;W5.delete(X)}let G=uY(J.directory,X,Y);if(await I0(G))try{let K=await OU(G,"utf-8"),q=JSON.parse(K);if(await dY(q,$,J.maxAge))return q.lastAccessedAt=Date.now(),W5.set(X,q),q.data}catch{}return null}async function J4($,Z,Y,J,X=h3){if(!X.enabled)return;let Q=Z4($,Z),G=await k0($),K=await g3($),q={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:Z4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};W5.set(Q,q);let W=uY(X.directory,Q,J);try{await wU(VU(W)),await LU(W,JSON.stringify(q,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function X4($,Z=h3){if($==="all")W5.clear();else W5.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let X=mY(Z.directory,J);try{await FU(X,{recursive:!0,force:!0})}catch{}}}var W5,h3;var d3=b(()=>{m1();W5=new Map,h3={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class G4{config;constructor($={}){this.config={...NU,...$}}async get($,Z){return Y4($,Z,"image",this.config)}async set($,Z,Y){return J4($,Z,Y,"image",this.config)}async clear(){return X4("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function m3($){if(!Q4)Q4=new G4($);else if($)Q4.updateConfig($);return Q4}async function K4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return m3(J).get($,Z)}async function q4($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return m3(X).set($,Z,Y)}async function pY(){return m3().clear()}var NU,Q4=null;var u3=b(()=>{d3();NU={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as AU,basename as RU,extname as TU,join as MU}from"path";import{mkdir as IU}from"fs/promises";async function p3(){try{return await import("ts-images")}catch{return null}}function cY($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function DU($,Z){let Y=Z?cY(Z):cY("web"),J=$.formatQuality||{};return{jpeg:{...Y.jpeg,...J.jpeg},png:{...Y.png,...J.png},webp:{...Y.webp,...J.webp},avif:{...Y.avif,...J.avif}}}async function lY($,Z,Y){let J=await p3();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let X=await K4($,Z,Y);if(X)return X;try{let Q=AU($);if(!await I0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=DU(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await IU(K,{recursive:!0});let W=await k0(Q),z=RU($,TU($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await c3(Q,Z.transformations,J);for(let j of U){let H=G[j]||{},L=`${z}-${W}.${j}`,F=MU(K,L);try{let O=await J.optimizeImage({input:B||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await J.generateThumbHash(Q);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await J.generatePlaceholder(Q,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await q4($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function iY($,Z,Y,J){let X=await p3();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function c3($,Z,Y){let J=Y||await p3();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await J.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)X=await J.resize(X,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)X=await J.blur(X,G.sigma);break;case"sharpen":if(G.amount!==void 0)X=await J.sharpen(X,G.amount);break;case"grayscale":X=await J.grayscale(X);break;case"rotate":if(G.angle!==void 0)X=await J.rotate(X,G.angle);break;case"flip":X=await J.flip(X);break;case"flop":X=await J.flop(X);break;case"brightness":if(G.value!==void 0)X=await J.brightness(X,G.value);break;case"contrast":if(G.value!==void 0)X=await J.contrast(X,G.value);break;case"saturation":if(G.value!==void 0)X=await J.saturation(X,G.value);break}}return await J.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}var nY=b(()=>{m1();u3()});import{resolve as EU,basename as kU,extname as bU,join as SU}from"path";import{mkdir as yU}from"fs/promises";async function CU(){try{return await import("ts-images")}catch{return null}}async function oY($,Z,Y){let J=await CU();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=EU($);if(!await I0(X))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||PU,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await yU(K,{recursive:!0});let W=await k0(X),z=kU($,bU($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of Q){let F=`${z}-${L}w-${W}.${j}`,O=SU(K,F),V=`${q}/${F}`;try{let w=U[j]?.quality||80;if(await I0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let N=await J.processImage({input:X,output:O,format:j,quality:w,resize:{width:L}});if(N)_.byFormat[j].push({path:O,url:V,width:L,height:N.height||Math.round(L*(N.height||1)/(N.width||1)),format:j,size:N.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await J.generateThumbHash(X);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await J.generatePlaceholder(X,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||vU(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function vU($){let Z=[...$].sort((J,X)=>J-X),Y=[];for(let J=0;J<Z.length-1;J++){let X=Z[J];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function sY($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var PU;var rY=b(()=>{m1();PU=[320,480,640,768,1024,1280,1536,1920]});var aY={};o(aY,{setCachedImageResult:()=>q4,processImage:()=>lY,optimizeImage:()=>iY,getCachedImageResult:()=>K4,generateSrcset:()=>sY,generateResponsiveVariants:()=>oY,clearImageCache:()=>pY,applyTransformations:()=>c3,ImageProcessorCache:()=>G4});var tY=b(()=>{nY();rY();u3()});async function xU(){try{return await Promise.resolve().then(() => (tY(),aY))}catch($){if(!eY)console.warn("[stx-media] Image processor not available, some features disabled:",$),eY=!0;return null}}async function z4($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return dU(J,Y)}if(Y.processedResult?.processed)return o3($,Y.processedResult,Z);if(Y.responsiveVariants)return JJ($,Y.responsiveVariants,Z);let{src:X,alt:Q,width:G,height:K,sizes:q,widths:W=z5,dpr:z,formats:U=p5,quality:_=l3,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":U4,decoding:V=W4,fetchpriority:w,objectFit:N,objectPosition:A,crossorigin:R,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:y=!1,baseUrl:S=""}=Z;if(y&&!Z.optimize)return hU($);let k,P,h=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{k=await vY(X,{strategy:j,...H}),P=PY(h,k,H)}catch{}let f=z!==void 0&&G!==void 0,m;if(f)m=gU($,h,k,Z);else m=await fU($,h,k,Z);let c;if(F){let O0=U.includes("webp")?"webp":U[0],B0=y3(X,W,{...B,q:_},O0),$0=typeof q==="object"?C3(q):q||"100vw";c=`<link rel="preload" as="image" imagesrcset="${B0}" imagesizes="${$0}" />`}let Y0=[];if(!$J&&j!=="none")Y0.push(f3),$J=!0;if(P)Y0.push(P);let K0=L?YJ(h):void 0;return{html:m,preloadLink:c,css:Y0.length>0?Y0.join(`
10137
- `):void 0,script:K0}}async function fU($,Z,Y,J){let{src:X,alt:Q,width:G,height:K,sizes:q,widths:W=z5,formats:z=p5,quality:U=l3,params:_={},lazy:B=!0,priority:j=!1,loading:H=j?"eager":U4,decoding:L=W4,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:N}=$,A=$.class,R=$.style,T=$.data||{},M=typeof q==="object"?C3(q):q||"100vw",I=[];for(let y of z){let S=y3(X,W,{..._,q:U},y),k=P3(y);if(B&&!j)I.push(` <source type="${k}" data-srcset="${S}" data-sizes="${M}" />`);else I.push(` <source type="${k}" srcset="${S}" sizes="${M}" />`)}let D=i3({src:c5(X,{..._,q:U}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:N,className:ZJ(A,Y),style:n3(R,O,V,Y),lazy:B&&!j,data:T}),E;if(Y){let y=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${y}">
10136
+ `.trim();x3=new Map});import{createHash as gY}from"crypto";import{readFile as jU,stat as hY}from"fs/promises";async function b0($){try{let Z=await jU($);return gY("sha256").update(Z).digest("hex").slice(0,16)}catch{return""}}function fY($){return gY("sha256").update($).digest("hex").slice(0,16)}function Z4($,Z){let Y=JSON.stringify(Z,Object.keys(Z).sort());return`${fY($)}-${fY(Y)}`}async function g3($){try{return(await hY($)).mtimeMs}catch{return 0}}async function I0($){try{return await hY($),!0}catch{return!1}}var m1=()=>{};import{mkdir as HU,readFile as OU,writeFile as LU,readdir as CV,rm as FU,stat as PV}from"fs/promises";import{join as mY,dirname as VU}from"path";async function wU($){try{await HU($,{recursive:!0})}catch{}}function uY($,Z,Y){return mY($,Y,`${Z}.json`)}async function dY($,Z,Y){if((Date.now()-$.createdAt)/86400000>Y)return!1;if(await g3(Z)!==$.srcMtime)return!1;return!0}async function Y4($,Z,Y,J=h3){if(!J.enabled)return null;let X=Z4($,Z),Q=W5.get(X);if(Q){if(await dY(Q,$,J.maxAge))return Q.lastAccessedAt=Date.now(),Q.data;W5.delete(X)}let G=uY(J.directory,X,Y);if(await I0(G))try{let K=await OU(G,"utf-8"),q=JSON.parse(K);if(await dY(q,$,J.maxAge))return q.lastAccessedAt=Date.now(),W5.set(X,q),q.data}catch{}return null}async function J4($,Z,Y,J,X=h3){if(!X.enabled)return;let Q=Z4($,Z),G=await b0($),K=await g3($),q={key:Q,src:$,srcHash:G,srcMtime:K,optionsHash:Z4("",Z),data:Y,createdAt:Date.now(),lastAccessedAt:Date.now()};W5.set(Q,q);let W=uY(X.directory,Q,J);try{await wU(VU(W)),await LU(W,JSON.stringify(q,null,2))}catch(z){console.warn(`[stx-media] Failed to write cache: ${z}`)}}async function X4($,Z=h3){if($==="all")W5.clear();else W5.clear();let Y=$==="all"?["image","video"]:[$];for(let J of Y){let X=mY(Z.directory,J);try{await FU(X,{recursive:!0,force:!0})}catch{}}}var W5,h3;var d3=b(()=>{m1();W5=new Map,h3={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}});class G4{config;constructor($={}){this.config={...NU,...$}}async get($,Z){return Y4($,Z,"image",this.config)}async set($,Z,Y){return J4($,Z,Y,"image",this.config)}async clear(){return X4("image",this.config)}updateConfig($){this.config={...this.config,...$}}}function m3($){if(!Q4)Q4=new G4($);else if($)Q4.updateConfig($);return Q4}async function K4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return m3(J).get($,Z)}async function q4($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return m3(X).set($,Z,Y)}async function pY(){return m3().clear()}var NU,Q4=null;var u3=b(()=>{d3();NU={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500,cacheVariants:!0,cachePlaceholders:!0}});import{resolve as AU,basename as RU,extname as TU,join as MU}from"path";import{mkdir as IU}from"fs/promises";async function p3(){try{return await import("ts-images")}catch{return null}}function cY($){switch($){case"quality":return{jpeg:{quality:90,mozjpeg:!0,progressive:!0},png:{compressionLevel:6,palette:!1},webp:{quality:90,effort:6,smartSubsample:!0},avif:{quality:85,effort:6}};case"performance":return{jpeg:{quality:70,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!0},webp:{quality:70,effort:4,smartSubsample:!0},avif:{quality:60,effort:2}};case"web":default:return{jpeg:{quality:82,mozjpeg:!0,progressive:!0},png:{compressionLevel:8,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4}}}}function DU($,Z){let Y=Z?cY(Z):cY("web"),J=$.formatQuality||{};return{jpeg:{...Y.jpeg,...J.jpeg},png:{...Y.png,...J.png},webp:{...Y.webp,...J.webp},avif:{...Y.avif,...J.avif}}}async function lY($,Z,Y){let J=await p3();if(!J)return console.warn("[stx-media] ts-images not installed, skipping optimization"),{src:$,processed:!1};let X=await K4($,Z,Y);if(X)return X;try{let Q=AU($);if(!await I0(Q))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let G=DU(Y,Z.preset),K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await IU(K,{recursive:!0});let W=await b0(Q),z=RU($,TU($)),U=Z.outputFormat?[Z.outputFormat]:Y.defaultFormats||["avif","webp","jpeg"],_={src:$,processed:!0,variants:[],hash:W},B=null;if(Z.transformations&&Z.transformations.length>0)B=await c3(Q,Z.transformations,J);for(let j of U){let H=G[j]||{},L=`${z}-${W}.${j}`,F=MU(K,L);try{let O=await J.optimizeImage({input:B||Q,output:F,format:j,quality:H.quality,progressive:H.progressive});if(O){if(_.variants.push({path:F,url:`${q}/${L}`,width:O.width||0,height:O.height||0,format:j,size:O.outputSize||0}),!_.originalWidth&&O.width)_.originalWidth=O.width,_.originalHeight=O.height}}catch(O){_.errors=_.errors||[],_.errors.push(`Failed to optimize ${j}: ${O}`)}}if(Z.embedThumbhash||Z.placeholder==="thumbhash")try{let j=await J.generateThumbHash(Q);_.placeholder=j.dataUrl}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to generate thumbhash: ${j}`)}if(Z.useDominantColor)try{let j=await J.generatePlaceholder(Q,{strategy:"dominant-color"});_.dominantColor=j.dominantColor}catch(j){_.errors=_.errors||[],_.errors.push(`Failed to extract dominant color: ${j}`)}return await q4($,Z,_,Y),_}catch(Q){return{src:$,processed:!1,errors:[`Processing failed: ${Q}`]}}}async function iY($,Z,Y,J){let X=await p3();if(!X)return{success:!1,error:"ts-images not installed"};try{return{success:!0,size:(await X.optimizeImage({input:$,output:J,format:Z,quality:Y}))?.outputSize}}catch(Q){return{success:!1,error:String(Q)}}}async function c3($,Z,Y){let J=Y||await p3();if(!J)return console.warn("[stx-media] ts-images not installed, skipping transformations"),null;try{let X=await J.decode($);for(let Q of Z){let G=Q.options||{};switch(Q.type){case"resize":if(G.width||G.height)X=await J.resize(X,{width:G.width,height:G.height,fit:G.fit});break;case"blur":if(G.sigma!==void 0)X=await J.blur(X,G.sigma);break;case"sharpen":if(G.amount!==void 0)X=await J.sharpen(X,G.amount);break;case"grayscale":X=await J.grayscale(X);break;case"rotate":if(G.angle!==void 0)X=await J.rotate(X,G.angle);break;case"flip":X=await J.flip(X);break;case"flop":X=await J.flop(X);break;case"brightness":if(G.value!==void 0)X=await J.brightness(X,G.value);break;case"contrast":if(G.value!==void 0)X=await J.contrast(X,G.value);break;case"saturation":if(G.value!==void 0)X=await J.saturation(X,G.value);break}}return await J.encode(X,"png")}catch(X){return console.error(`[stx-media] Transformation failed: ${X}`),null}}var nY=b(()=>{m1();u3()});import{resolve as EU,basename as kU,extname as bU,join as SU}from"path";import{mkdir as yU}from"fs/promises";async function CU(){try{return await import("ts-images")}catch{return null}}async function oY($,Z,Y){let J=await CU();if(!J)return console.warn("[stx-media] ts-images not installed, skipping responsive generation"),null;let X=EU($);if(!await I0(X))return console.warn(`[stx-media] Source file not found: ${$}`),null;try{let Q=Z.responsiveWidths||Y.breakpoints||PU,G=Z.formats||Y.defaultFormats||["avif","webp","jpeg"],K=Y.outputDir||"dist/images",q=Y.baseUrl||"/images";await yU(K,{recursive:!0});let W=await b0(X),z=kU($,bU($)),U=Y.formatQuality||{jpeg:{quality:82},png:{quality:80},webp:{quality:82},avif:{quality:75}},_={src:$,byFormat:{},srcsets:{}};for(let j of G){_.byFormat[j]=[];let H=[];for(let L of Q){let F=`${z}-${L}w-${W}.${j}`,O=SU(K,F),V=`${q}/${F}`;try{let w=U[j]?.quality||80;if(await I0(O)){_.byFormat[j].push({path:O,url:V,width:L,height:0,format:j,size:0}),H.push(`${V} ${L}w`);continue}let N=await J.processImage({input:X,output:O,format:j,quality:w,resize:{width:L}});if(N)_.byFormat[j].push({path:O,url:V,width:L,height:N.height||Math.round(L*(N.height||1)/(N.width||1)),format:j,size:N.outputSize||0}),H.push(`${V} ${L}w`)}catch(w){console.warn(`[stx-media] Failed to generate ${j} at ${L}w: ${w}`)}}_.srcsets[j]=H.join(", ")}let B=Z.placeholder||Y.placeholderStrategy||"thumbhash";if(B!=="none")try{if(B==="thumbhash"){let j=await J.generateThumbHash(X);_.placeholder={dataURL:j.dataUrl,width:j.width||32,height:j.height||32,strategy:"thumbhash"}}else{let j=await J.generatePlaceholder(X,{strategy:B,width:20});_.placeholder={dataURL:j.dataURL,width:j.width,height:j.height,strategy:B}}}catch(j){console.warn(`[stx-media] Failed to generate placeholder: ${j}`)}return _.sizes=Z.sizes||vU(Q),_}catch(Q){return console.error(`[stx-media] Responsive generation failed: ${Q}`),null}}function vU($){let Z=[...$].sort((J,X)=>J-X),Y=[];for(let J=0;J<Z.length-1;J++){let X=Z[J];Y.push(`(max-width: ${X}px) ${X}px`)}return Y.push(`${Z[Z.length-1]}px`),Y.join(", ")}function sY($,Z="width"){if(!$||$.length===0)return"";if(Z==="dpr")return $.filter((Y)=>Y.dpr).map((Y)=>`${Y.url} ${Y.dpr}x`).join(", ");return $.map((Y)=>`${Y.url} ${Y.width}w`).join(", ")}var PU;var rY=b(()=>{m1();PU=[320,480,640,768,1024,1280,1536,1920]});var aY={};o(aY,{setCachedImageResult:()=>q4,processImage:()=>lY,optimizeImage:()=>iY,getCachedImageResult:()=>K4,generateSrcset:()=>sY,generateResponsiveVariants:()=>oY,clearImageCache:()=>pY,applyTransformations:()=>c3,ImageProcessorCache:()=>G4});var tY=b(()=>{nY();rY();u3()});async function xU(){try{return await Promise.resolve().then(() => (tY(),aY))}catch($){if(!eY)console.warn("[stx-media] Image processor not available, some features disabled:",$),eY=!0;return null}}async function z4($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipOptimization){if(Y.tsImagesConfig?.enabled&&!Y.isDev)return dU(J,Y)}if(Y.processedResult?.processed)return o3($,Y.processedResult,Z);if(Y.responsiveVariants)return JJ($,Y.responsiveVariants,Z);let{src:X,alt:Q,width:G,height:K,sizes:q,widths:W=z5,dpr:z,formats:U=p5,quality:_=l3,params:B={},placeholder:j="none",placeholderOptions:H={},lazy:L=!0,priority:F=!1,loading:O=F?"eager":U4,decoding:V=W4,fetchpriority:w,objectFit:N,objectPosition:A,crossorigin:R,referrerpolicy:T}=$,M=$.class,I=$.style,D=$.id,E=$.data||{},{isDev:C=!1,baseUrl:S=""}=Z;if(C&&!Z.optimize)return hU($);let k,P,h=D||`stx-img-${Math.random().toString(36).slice(2,8)}`;if(j!=="none"&&!F)try{k=await vY(X,{strategy:j,...H}),P=PY(h,k,H)}catch{}let f=z!==void 0&&G!==void 0,m;if(f)m=gU($,h,k,Z);else m=await fU($,h,k,Z);let c;if(F){let O0=U.includes("webp")?"webp":U[0],B0=y3(X,W,{...B,q:_},O0),$0=typeof q==="object"?C3(q):q||"100vw";c=`<link rel="preload" as="image" imagesrcset="${B0}" imagesizes="${$0}" />`}let Y0=[];if(!$J&&j!=="none")Y0.push(f3),$J=!0;if(P)Y0.push(P);let K0=L?YJ(h):void 0;return{html:m,preloadLink:c,css:Y0.length>0?Y0.join(`
10137
+ `):void 0,script:K0}}async function fU($,Z,Y,J){let{src:X,alt:Q,width:G,height:K,sizes:q,widths:W=z5,formats:z=p5,quality:U=l3,params:_={},lazy:B=!0,priority:j=!1,loading:H=j?"eager":U4,decoding:L=W4,fetchpriority:F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:N}=$,A=$.class,R=$.style,T=$.data||{},M=typeof q==="object"?C3(q):q||"100vw",I=[];for(let C of z){let S=y3(X,W,{..._,q:U},C),k=P3(C);if(B&&!j)I.push(` <source type="${k}" data-srcset="${S}" data-sizes="${M}" />`);else I.push(` <source type="${k}" srcset="${S}" sizes="${M}" />`)}let D=i3({src:c5(X,{..._,q:U}),alt:Q,width:G,height:K,loading:j?void 0:H,decoding:L,fetchpriority:j?"high":F,objectFit:O,objectPosition:V,crossorigin:w,referrerpolicy:N,className:ZJ(A,Y),style:n3(R,O,V,Y),lazy:B&&!j,data:T}),E;if(Y){let C=`background-image: url('${Y.dataURL}'); background-size: cover; background-position: center;`;E=`<div id="${Z}" class="stx-img-placeholder" style="${C}">
10138
10138
  <picture>
10139
10139
  ${I.join(`
10140
10140
  `)}
@@ -10193,12 +10193,12 @@ ${N.join(`
10193
10193
  ${N.join(`
10194
10194
  `)}
10195
10195
  <img ${R.join(" ")} />
10196
- </picture>`;let y=[];if(Z.placeholder)y.push(f3);let S=G?YJ(j):void 0,k;if(K&&V)k=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:E,preloadLink:k,css:y.length>0?y.join(`
10196
+ </picture>`;let C=[];if(Z.placeholder)C.push(f3);let S=G?YJ(j):void 0,k;if(K&&V)k=`<link rel="preload" as="image" imagesrcset="${V}" />`;return{html:E,preloadLink:k,css:C.length>0?C.join(`
10197
10197
  `):void 0,script:S}}async function JJ($,Z,Y){let J={src:Z.src,processed:!0,variants:[],placeholder:Z.placeholder?.dataURL,originalWidth:Z.placeholder?.width,originalHeight:Z.placeholder?.height};for(let[X,Q]of Object.entries(Z.byFormat))if(Q)J.variants.push(...Q);return o3($,J,Y)}var eY=!1,l3=80,W4="async",U4="lazy",$J=!1;var XJ=b(()=>{v3();xY()});function mU(){return $4({name:"img",hasEndTag:!1,description:"Render an optimized responsive image with srcset and lazy loading",transform:async($,Z,Y,J)=>{let{src:X,alt:Q,options:G}=uU($,Z,Y);if(!X)return console.warn("@img directive: missing src argument"),"<!-- @img: missing src -->";let K={src:X,alt:Q||"",widths:G.widths||z5,formats:G.formats||p5,quality:G.quality,sizes:G.sizes,dpr:G.dpr,params:G.params,placeholder:G.placeholder,placeholderOptions:G.placeholderOptions,lazy:G.lazy!==!1,priority:G.priority||!1,loading:G.loading,decoding:G.decoding,fetchpriority:G.fetchpriority,objectFit:G.objectFit,objectPosition:G.objectPosition,class:G.class,style:G.style,id:G.id,width:G.width,height:G.height},q=Y.__isDev||!1,W=await z4(K,{isDev:q}),z=W.html;if(W.preloadLink)z=W.preloadLink+`
10198
10198
  `+z;if(W.css)z+=`
10199
10199
  <style>${W.css}</style>`;if(W.script)z+=`
10200
- <script>${W.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function uU($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@img(")||J.startsWith("("))J=J.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=pU(J),Q=s3(X[0],Y)||"",G=s3(X[1],Y)||"",K={};if(X[2]){let q=s3(X[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof X[2]==="string")try{K=JSON.parse(X[2])}catch{}}return{src:Q,alt:G,options:K}}function pU($){let Z=[],Y="",J=!1,X="",Q=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],W=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&W!=="\\"){if(!J)J=!0,X=q;else if(q===X)J=!1,X="";else Y+=q;continue}if(!J){if(q==="{")Q++;if(q==="}")Q--;if(q==="[")G++;if(q==="]")G--;if(q===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function s3($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var QJ;var GJ=b(()=>{S3();XJ();v3();QJ=mU()});class B4{config;constructor($={}){this.config={...cU,...$}}async get($,Z){return Y4($,Z,"video",this.config)}async set($,Z,Y){return J4($,Z,Y,"video",this.config)}async clear(){return X4("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function r3($){if(!_4)_4=new B4($);else if($)_4.updateConfig($);return _4}async function j4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return r3(J).get($,Z)}async function H4($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return r3(X).set($,Z,Y)}async function KJ(){return r3().clear()}var cU,_4=null;var a3=b(()=>{d3();cU={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as t3,basename as e3,extname as $6,join as O4}from"path";import{mkdir as Z6}from"fs/promises";async function Y6(){try{return await import("ts-videos")}catch{return null}}async function L4($,Z,Y,J){let X=await Y6();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=t3($);if(!await I0(Q))return null;await Z6(Y,{recursive:!0});let G=await k0(Q),K=e3($,$6($)),q=Z.format||"webp",W=Z.timestamp||0,z=`${K}-poster-${G}.${q}`,U=O4(Y,z),_=await X.extractThumbnails(Q,{timestamps:[W],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:z.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:U,url:`${J}/${z}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:W,size:B.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function F4($,Z,Y,J){let X=await Y6();if(!X)return[];try{let Q=t3($);if(!await I0(Q))return[];await Z6(Y,{recursive:!0});let G=await k0(Q),K=e3($,$6($)),q=Z.format||"webp",U=(await new X.Input(Q).getInfo()).duration||60,_=Z.count||10,B=Z.interval||U/_,j=[];for(let L=0;L<_&&L*B<U;L++)j.push(L*B);let H=await X.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||O4(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${J}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function qJ($,Z,Y,J){let X=await Y6();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=t3($);if(!await I0(Q))return null;await Z6(Y,{recursive:!0});let G=await k0(Q),K=e3($,$6($)),z=(await new X.Input(Q).getInfo()).duration||60,U=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(z/_),F=Math.ceil(L/U),O=`${K}-sprite-${G}.${H}`,V=O4(Y,O),w=[];for(let A=0;A<L;A++)w.push(A*_);let N=await X.extractThumbnails(Q,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:O4(Y,".temp")});if(!N||N.length===0)return null;try{let A=await import("ts-images"),R=U*B,T=F*j,M=await A.createSprite({images:N.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${J}/${O}`,path:V,columns:U,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var J6=b(()=>{m1()});import{resolve as WJ,basename as UJ,extname as _J,join as u1}from"path";import{mkdir as V4,writeFile as BJ}from"fs/promises";async function jJ(){try{return await import("ts-videos")}catch{return null}}async function w4($,Z,Y,J,X){let Q=await jJ();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=WJ($);if(!await I0(G))return null;let K=await k0(G),q=UJ($,_J($)),W=u1(Y,`${q}-${K}-hls`);await V4(W,{recursive:!0});let z=Z.length>0?Z:HJ,U=X?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of z){let w=u1(W,V.label);await V4(w,{recursive:!0});let N=`${V.label}.m3u8`,A=u1(w,N);try{let R=await Q.generateHLS(G,{outputDir:w,segmentDuration:U,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(R)H.push({quality:V,url:`${J}/${q}-${K}-hls/${V.label}/${N}`,path:A}),L+=R.segmentCount||Math.ceil(j/U)}catch(R){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${R}`)}}if(H.length===0)return null;let F=u1(W,"master.m3u8"),O=lU(H,J,q,K);return await BJ(F,O),{manifestUrl:`${J}/${q}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function lU($,Z,Y,J){let X=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;X.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return X.join(`
10201
- `)}async function N4($,Z,Y,J,X){let Q=await jJ();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=WJ($);if(!await I0(G))return null;let K=await k0(G),q=UJ($,_J($)),W=u1(Y,`${q}-${K}-dash`);await V4(W,{recursive:!0});let z=Z.length>0?Z:HJ,U=X?.segmentDuration||4,_=X?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,L=[],F=[];for(let N of z){let A=u1(W,N.label);await V4(A,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:A,segmentDuration:U,width:N.width,height:N.height,videoBitrate:N.bitrate,audioBitrate:N.audioBitrate})){if(L.push({bandwidth:N.bitrate,width:N.width,height:N.height||Math.round(N.width*9/16),url:`${J}/${q}-${K}-dash/${N.label}/video`}),N.audioBitrate)F.push({bandwidth:N.audioBitrate,url:`${J}/${q}-${K}-dash/${N.label}/audio`})}}catch(R){console.warn(`[stx-media] Failed to generate DASH for ${N.label}: ${R}`)}}if(L.length===0)return null;let O=u1(W,"manifest.mpd"),V=iU(L,F,H,U,_);await BJ(O,V);let w=[{type:"video",representations:L}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${J}/${q}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function iU($,Z,Y,J,X){let Q=zJ(Y),G=zJ(X),K=`<?xml version="1.0" encoding="UTF-8"?>
10200
+ <script>${W.script}</script>`;return z},defaults:{src:"",alt:"",options:{lazy:!0,placeholder:"none"}}})}function uU($,Z,Y){if(Z.src)return{src:String(Z.src),alt:String(Z.alt||""),options:Z.options||{}};let J=$.trim();if(J.startsWith("@img(")||J.startsWith("("))J=J.replace(/^@img\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=pU(J),Q=s3(X[0],Y)||"",G=s3(X[1],Y)||"",K={};if(X[2]){let q=s3(X[2],Y);if(typeof q==="object"&&q!==null)K=q;else if(typeof X[2]==="string")try{K=JSON.parse(X[2])}catch{}}return{src:Q,alt:G,options:K}}function pU($){let Z=[],Y="",J=!1,X="",Q=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],W=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&W!=="\\"){if(!J)J=!0,X=q;else if(q===X)J=!1,X="";else Y+=q;continue}if(!J){if(q==="{")Q++;if(q==="}")Q--;if(q==="[")G++;if(q==="]")G--;if(q===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function s3($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var QJ;var GJ=b(()=>{S3();XJ();v3();QJ=mU()});class B4{config;constructor($={}){this.config={...cU,...$}}async get($,Z){return Y4($,Z,"video",this.config)}async set($,Z,Y){return J4($,Z,Y,"video",this.config)}async clear(){return X4("video",this.config)}updateConfig($){this.config={...this.config,...$}}}function r3($){if(!_4)_4=new B4($);else if($)_4.updateConfig($);return _4}async function j4($,Z,Y){let J=Y?{directory:`${Y.outputDir}/../.cache`}:{};return r3(J).get($,Z)}async function H4($,Z,Y,J){let X=J?{directory:`${J.outputDir}/../.cache`}:{};return r3(X).set($,Z,Y)}async function KJ(){return r3().clear()}var cU,_4=null;var a3=b(()=>{d3();cU={enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:2000,cacheTranscoded:!0,cacheThumbnails:!0,cacheManifests:!0}});import{resolve as t3,basename as e3,extname as $6,join as O4}from"path";import{mkdir as Z6}from"fs/promises";async function Y6(){try{return await import("ts-videos")}catch{return null}}async function L4($,Z,Y,J){let X=await Y6();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate poster"),null;try{let Q=t3($);if(!await I0(Q))return null;await Z6(Y,{recursive:!0});let G=await b0(Q),K=e3($,$6($)),q=Z.format||"webp",W=Z.timestamp||0,z=`${K}-poster-${G}.${q}`,U=O4(Y,z),_=await X.extractThumbnails(Q,{timestamps:[W],width:Z.width||1280,height:Z.height,format:q,quality:Z.quality||85,outputDir:Y,outputPattern:z.replace(`.${q}`,"")});if(_&&_.length>0){let B=_[0];return{path:U,url:`${J}/${z}`,width:B.width||Z.width||1280,height:B.height||720,timestamp:W,size:B.size||0}}return null}catch(Q){return console.warn(`[stx-media] Failed to generate poster: ${Q}`),null}}async function F4($,Z,Y,J){let X=await Y6();if(!X)return[];try{let Q=t3($);if(!await I0(Q))return[];await Z6(Y,{recursive:!0});let G=await b0(Q),K=e3($,$6($)),q=Z.format||"webp",U=(await new X.Input(Q).getInfo()).duration||60,_=Z.count||10,B=Z.interval||U/_,j=[];for(let L=0;L<_&&L*B<U;L++)j.push(L*B);let H=await X.extractThumbnails(Q,{timestamps:j,width:Z.width||320,format:q,quality:Z.quality||80,outputDir:Y,outputPattern:`${K}-thumb-${G}`});if(H&&H.length>0)return H.map((L,F)=>({path:L.path||O4(Y,`${K}-thumb-${G}-${F}.${q}`),url:`${J}/${K}-thumb-${G}-${F}.${q}`,width:L.width||Z.width||320,height:L.height||180,timestamp:j[F],size:L.size||0}));return[]}catch(Q){return console.warn(`[stx-media] Failed to generate thumbnails: ${Q}`),[]}}async function qJ($,Z,Y,J){let X=await Y6();if(!X)return console.warn("[stx-media] ts-videos not installed, cannot generate sprite sheet"),null;try{let Q=t3($);if(!await I0(Q))return null;await Z6(Y,{recursive:!0});let G=await b0(Q),K=e3($,$6($)),z=(await new X.Input(Q).getInfo()).duration||60,U=Z.columns||10,_=Z.interval||5,B=Z.thumbnailWidth||160,j=Z.thumbnailHeight||90,H=Z.format||"jpeg",L=Math.ceil(z/_),F=Math.ceil(L/U),O=`${K}-sprite-${G}.${H}`,V=O4(Y,O),w=[];for(let A=0;A<L;A++)w.push(A*_);let N=await X.extractThumbnails(Q,{timestamps:w,width:B,height:j,format:H,quality:Z.quality||70,outputDir:O4(Y,".temp")});if(!N||N.length===0)return null;try{let A=await import("ts-images"),R=U*B,T=F*j,M=await A.createSprite({images:N.map((I)=>I.path),columns:U,padding:0,outputPath:V,format:H,quality:Z.quality||70});return{url:`${J}/${O}`,path:V,columns:U,rows:F,thumbnailWidth:B,thumbnailHeight:j,interval:_,totalFrames:L}}catch{return console.warn("[stx-media] ts-images not installed, sprite sheet generation skipped"),null}}catch(Q){return console.warn(`[stx-media] Failed to generate sprite sheet: ${Q}`),null}}var J6=b(()=>{m1()});import{resolve as WJ,basename as UJ,extname as _J,join as u1}from"path";import{mkdir as V4,writeFile as BJ}from"fs/promises";async function jJ(){try{return await import("ts-videos")}catch{return null}}async function w4($,Z,Y,J,X){let Q=await jJ();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate HLS manifest"),null;try{let G=WJ($);if(!await I0(G))return null;let K=await b0(G),q=UJ($,_J($)),W=u1(Y,`${q}-${K}-hls`);await V4(W,{recursive:!0});let z=Z.length>0?Z:HJ,U=X?.segmentDuration||6,j=(await new Q.Input(G).getInfo()).duration||0,H=[],L=0;for(let V of z){let w=u1(W,V.label);await V4(w,{recursive:!0});let N=`${V.label}.m3u8`,A=u1(w,N);try{let R=await Q.generateHLS(G,{outputDir:w,segmentDuration:U,width:V.width,height:V.height,videoBitrate:V.bitrate,audioBitrate:V.audioBitrate,playlistName:V.label});if(R)H.push({quality:V,url:`${J}/${q}-${K}-hls/${V.label}/${N}`,path:A}),L+=R.segmentCount||Math.ceil(j/U)}catch(R){console.warn(`[stx-media] Failed to generate HLS for ${V.label}: ${R}`)}}if(H.length===0)return null;let F=u1(W,"master.m3u8"),O=lU(H,J,q,K);return await BJ(F,O),{manifestUrl:`${J}/${q}-${K}-hls/master.m3u8`,manifestPath:F,playlists:H,segmentCount:L,duration:j}}catch(G){return console.warn(`[stx-media] Failed to generate HLS manifest: ${G}`),null}}function lU($,Z,Y,J){let X=["#EXTM3U","#EXT-X-VERSION:3"];for(let Q of $){let{quality:G}=Q,K=G.bitrate+(G.audioBitrate||128000),q=`${G.width}x${G.height||Math.round(G.width*9/16)}`;X.push(`#EXT-X-STREAM-INF:BANDWIDTH=${K},RESOLUTION=${q},NAME="${G.label}"`,`${G.label}/${G.label}.m3u8`)}return X.join(`
10201
+ `)}async function N4($,Z,Y,J,X){let Q=await jJ();if(!Q)return console.warn("[stx-media] ts-videos not installed, cannot generate DASH manifest"),null;try{let G=WJ($);if(!await I0(G))return null;let K=await b0(G),q=UJ($,_J($)),W=u1(Y,`${q}-${K}-dash`);await V4(W,{recursive:!0});let z=Z.length>0?Z:HJ,U=X?.segmentDuration||4,_=X?.minBufferTime||2,H=(await new Q.Input(G).getInfo()).duration||0,L=[],F=[];for(let N of z){let A=u1(W,N.label);await V4(A,{recursive:!0});try{if(await Q.generateDASH(G,{outputDir:A,segmentDuration:U,width:N.width,height:N.height,videoBitrate:N.bitrate,audioBitrate:N.audioBitrate})){if(L.push({bandwidth:N.bitrate,width:N.width,height:N.height||Math.round(N.width*9/16),url:`${J}/${q}-${K}-dash/${N.label}/video`}),N.audioBitrate)F.push({bandwidth:N.audioBitrate,url:`${J}/${q}-${K}-dash/${N.label}/audio`})}}catch(R){console.warn(`[stx-media] Failed to generate DASH for ${N.label}: ${R}`)}}if(L.length===0)return null;let O=u1(W,"manifest.mpd"),V=iU(L,F,H,U,_);await BJ(O,V);let w=[{type:"video",representations:L}];if(F.length>0)w.push({type:"audio",representations:F});return{manifestUrl:`${J}/${q}-${K}-dash/manifest.mpd`,manifestPath:O,adaptationSets:w,duration:H}}catch(G){return console.warn(`[stx-media] Failed to generate DASH manifest: ${G}`),null}}function iU($,Z,Y,J,X){let Q=zJ(Y),G=zJ(X),K=`<?xml version="1.0" encoding="UTF-8"?>
10202
10202
  <MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
10203
10203
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10204
10204
  xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
@@ -10224,9 +10224,9 @@ ${N.join(`
10224
10224
  </Representation>
10225
10225
  `}K+=` </AdaptationSet>
10226
10226
  `}return K+=` </Period>
10227
- </MPD>`,K}function zJ($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),X="PT";if(Z>0)X+=`${Z}H`;if(Y>0)X+=`${Y}M`;return X+=`${J}S`,X}var HJ;var X6=b(()=>{m1();HJ=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as OJ,basename as nU,extname as oU,join as sU}from"path";import{mkdir as rU}from"fs/promises";async function LJ(){try{return await import("ts-videos")}catch{return null}}function aU($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function tU($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function Q6($){let Z=await LJ();if(!Z)return null;try{let Y=OJ($),X=await new Z.Input(Y).getInfo();return{duration:X.duration||0,width:X.width||0,height:X.height||0,frameRate:X.frameRate||0,bitrate:X.bitrate||0,codec:X.videoCodec||"",audioCodec:X.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function FJ($,Z,Y,J){let X=await LJ();if(!X)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await j4($,Z,Y);if(Q)return Q;try{let G=OJ($);if(!await I0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await rU(K,{recursive:!0});let W=await k0(G),z=nU($,oU($)),U={src:$,processed:!0,hash:W};J?.({percentage:5,stage:"analyzing"}),U.metadata=await Q6(G)||void 0;let _={};if(Z.quality)_.bitrate=aU(Z.quality);if(Z.platform)Object.assign(_,tU(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){J?.({percentage:10,stage:"transcoding"});let B=`${z}-${W}.mp4`,j=sU(K,B);try{let H=await eU(G,j,_,X,(L)=>J?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)U.transcoded={path:j,url:`${q}/${B}`,duration:H.duration,size:H.size,video:{codec:_.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(H){U.errors=U.errors||[],U.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){J?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await L4(G,B,K,q);if(j)U.poster=j}if(Y.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let B=await F4(G,Y.thumbnails,K,q);if(B.length>0)U.thumbnails=B}if(Z.streaming){J?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await w4(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,hls:j}}if(B.format==="dash"){let j=await N4(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,dash:j}}}if(Z.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await H4($,Z,U,Y),U}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function eU($,Z,Y,J,X){try{let G=await new J.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{X?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var VJ=b(()=>{m1();a3();J6();X6()});var wJ={};o(wJ,{setCachedVideoResult:()=>H4,processVideo:()=>FJ,getCachedVideoResult:()=>j4,generateThumbnails:()=>F4,generateSpriteSheet:()=>qJ,generatePoster:()=>L4,generateHLSManifest:()=>w4,generateDASHManifest:()=>N4,clearVideoCache:()=>KJ,analyzeVideo:()=>Q6,VideoProcessorCache:()=>B4});var NJ=b(()=>{VJ();J6();X6();a3()});async function RJ(){try{return await Promise.resolve().then(() => (NJ(),wJ))}catch($){if(!AJ)console.warn("[stx-media] Video processor not available, some features disabled:",$),AJ=!0;return null}}async function A4($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return Q_(J,Y)}if(Y.processedResult?.processed)return DJ($,Y.processedResult,Z);let X;if(J.generatePoster&&J.src&&!$.poster)X=await G_(J,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:q,controls:W=TJ,autoplay:z=!1,muted:U=!1,loop:_=!1,preload:B=MJ,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:w,disablePictureInPicture:N=!1,disableRemotePlayback:A=!1}=$,R=X||K,T=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return Y_($,Z);if(F&&F!=="video")return Z_(Q||"",F,$);let D=G.length>0?G:Q?[{src:Q,type:IJ(Q)}]:[],E=[`id="${I}"`];if(W)E.push("controls");if(z)E.push("autoplay");if(U)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(N)E.push("disablepictureinpicture");if(A)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),R)E.push(`data-poster="${w0(R)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),R)E.push(`poster="${w0(R)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(T)E.push(`class="${w0(T)}"`);if(M)E.push(`style="${w0(M)}"`);let y=D.map((P)=>{return` <source ${H?`data-src="${w0(P.src)}"`:`src="${w0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
10227
+ </MPD>`,K}function zJ($){let Z=Math.floor($/3600),Y=Math.floor($%3600/60),J=Math.floor($%60),X="PT";if(Z>0)X+=`${Z}H`;if(Y>0)X+=`${Y}M`;return X+=`${J}S`,X}var HJ;var X6=b(()=>{m1();HJ=[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000},{label:"360p",width:640,height:360,bitrate:600000,audioBitrate:64000}]});import{resolve as OJ,basename as nU,extname as oU,join as sU}from"path";import{mkdir as rU}from"fs/promises";async function LJ(){try{return await import("ts-videos")}catch{return null}}function aU($){switch($){case"very-low":return 500000;case"low":return 1e6;case"medium":return 2500000;case"high":return 5000000;case"very-high":return 1e7;case"lossless":return 0;default:return 2500000}}function tU($){switch($){case"youtube":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};case"twitter":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"instagram-feed":return{codec:"h264",maxWidth:1080,maxHeight:1080,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"instagram-story":case"instagram-reels":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:3500000,audioCodec:"aac",audioBitrate:128000};case"tiktok":return{codec:"h264",maxWidth:1080,maxHeight:1920,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"discord":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:60,bitrate:8000000,audioCodec:"aac",audioBitrate:192000};case"linkedin":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,bitrate:5000000,audioCodec:"aac",audioBitrate:128000};case"facebook":return{codec:"h264",maxWidth:1280,maxHeight:720,frameRate:30,bitrate:4000000,audioCodec:"aac",audioBitrate:128000};case"web-progressive":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000,twoPass:!0};case"web-streaming":return{codec:"h264",maxWidth:1920,maxHeight:1080,frameRate:30,audioCodec:"aac",audioBitrate:128000};default:return{}}}async function Q6($){let Z=await LJ();if(!Z)return null;try{let Y=OJ($),X=await new Z.Input(Y).getInfo();return{duration:X.duration||0,width:X.width||0,height:X.height||0,frameRate:X.frameRate||0,bitrate:X.bitrate||0,codec:X.videoCodec||"",audioCodec:X.audioCodec}}catch(Y){return console.warn(`[stx-media] Failed to analyze video: ${Y}`),null}}async function FJ($,Z,Y,J){let X=await LJ();if(!X)return console.warn("[stx-media] ts-videos not installed, skipping processing"),{src:$,processed:!1};let Q=await j4($,Z,Y);if(Q)return Q;try{let G=OJ($);if(!await I0(G))return{src:$,processed:!1,errors:[`Source file not found: ${$}`]};let K=Y.outputDir||"dist/videos",q=Y.baseUrl||"/videos";await rU(K,{recursive:!0});let W=await b0(G),z=nU($,oU($)),U={src:$,processed:!0,hash:W};J?.({percentage:5,stage:"analyzing"}),U.metadata=await Q6(G)||void 0;let _={};if(Z.quality)_.bitrate=aU(Z.quality);if(Z.platform)Object.assign(_,tU(Z.platform));if(Z.transcode)Object.assign(_,Z.transcode);if(Object.keys(_).length>0||Z.process){J?.({percentage:10,stage:"transcoding"});let B=`${z}-${W}.mp4`,j=sU(K,B);try{let H=await eU(G,j,_,X,(L)=>J?.({percentage:10+L*0.5,stage:"transcoding"}));if(H)U.transcoded={path:j,url:`${q}/${B}`,duration:H.duration,size:H.size,video:{codec:_.codec||"h264",width:H.width,height:H.height,bitrate:H.bitrate,frameRate:H.frameRate},audio:H.audioCodec?{codec:_.audioCodec||"aac",bitrate:_.audioBitrate||128000,sampleRate:_.sampleRate||48000,channels:_.channels||2}:void 0}}catch(H){U.errors=U.errors||[],U.errors.push(`Transcoding failed: ${H}`)}}if(Z.generatePoster){J?.({percentage:65,stage:"generating-poster"});let B=typeof Z.generatePoster==="object"?Z.generatePoster:{timestamp:0},j=await L4(G,B,K,q);if(j)U.poster=j}if(Y.thumbnails?.enabled){J?.({percentage:70,stage:"generating-thumbnails"});let B=await F4(G,Y.thumbnails,K,q);if(B.length>0)U.thumbnails=B}if(Z.streaming){J?.({percentage:80,stage:"generating-manifests"});let B=typeof Z.streaming==="object"?Z.streaming:Y.streaming||{format:"hls"};if(B.format==="hls"||B.format===void 0){let j=await w4(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,hls:j}}if(B.format==="dash"){let j=await N4(G,B.qualities||Y.streaming?.defaultQualities||[],K,q);if(j)U.streaming={...U.streaming,dash:j}}}if(Z.spriteSheet)J?.({percentage:90,stage:"generating-sprite-sheet"});return J?.({percentage:100,stage:"complete"}),await H4($,Z,U,Y),U}catch(G){return{src:$,processed:!1,errors:[`Processing failed: ${G}`]}}}async function eU($,Z,Y,J,X){try{let G=await new J.Conversion($,Z,{videoCodec:Y.codec,videoBitrate:Y.bitrate,width:Y.maxWidth,height:Y.maxHeight,frameRate:Y.frameRate,audioCodec:Y.audioCodec,audioBitrate:Y.audioBitrate,sampleRate:Y.sampleRate,channels:Y.channels}).run((K)=>{X?.(K.percentage/100)});return{duration:G.duration||0,size:G.size||0,width:G.width||Y.maxWidth||0,height:G.height||Y.maxHeight||0,bitrate:G.bitrate||Y.bitrate||0,frameRate:G.frameRate||Y.frameRate||30,audioCodec:G.audioCodec}}catch(Q){return console.error(`[stx-media] Transcoding failed: ${Q}`),null}}var VJ=b(()=>{m1();a3();J6();X6()});var wJ={};o(wJ,{setCachedVideoResult:()=>H4,processVideo:()=>FJ,getCachedVideoResult:()=>j4,generateThumbnails:()=>F4,generateSpriteSheet:()=>qJ,generatePoster:()=>L4,generateHLSManifest:()=>w4,generateDASHManifest:()=>N4,clearVideoCache:()=>KJ,analyzeVideo:()=>Q6,VideoProcessorCache:()=>B4});var NJ=b(()=>{VJ();J6();X6();a3()});async function RJ(){try{return await Promise.resolve().then(() => (NJ(),wJ))}catch($){if(!AJ)console.warn("[stx-media] Video processor not available, some features disabled:",$),AJ=!0;return null}}async function A4($,Z={}){let Y=Z,J=$;if(J.process&&!J.skipProcessing){if(Y.tsVideosConfig?.enabled&&!Y.isDev)return Q_(J,Y)}if(Y.processedResult?.processed)return DJ($,Y.processedResult,Z);let X;if(J.generatePoster&&J.src&&!$.poster)X=await G_(J,Y);let{src:Q,sources:G=[],poster:K,posterPlaceholder:q,controls:W=TJ,autoplay:z=!1,muted:U=!1,loop:_=!1,preload:B=MJ,playsinline:j=!0,lazy:H=!0,player:L="native",type:F,width:O,height:V,crossorigin:w,disablePictureInPicture:N=!1,disableRemotePlayback:A=!1}=$,R=X||K,T=$.class,M=$.style,I=$.id||`stx-video-${Math.random().toString(36).slice(2,8)}`;if(L==="ts-video")return Y_($,Z);if(F&&F!=="video")return Z_(Q||"",F,$);let D=G.length>0?G:Q?[{src:Q,type:IJ(Q)}]:[],E=[`id="${I}"`];if(W)E.push("controls");if(z)E.push("autoplay");if(U)E.push("muted");if(_)E.push("loop");if(j)E.push("playsinline");if(N)E.push("disablepictureinpicture");if(A)E.push("disableremoteplayback");if(w)E.push(`crossorigin="${w}"`);if(H){if(E.push(`data-preload="${B}"`),E.push('preload="none"'),R)E.push(`data-poster="${w0(R)}"`);E.push("data-stx-lazy")}else if(E.push(`preload="${B}"`),R)E.push(`poster="${w0(R)}"`);if(O)E.push(`width="${O}"`);if(V)E.push(`height="${V}"`);if(T)E.push(`class="${w0(T)}"`);if(M)E.push(`style="${w0(M)}"`);let C=D.map((P)=>{return` <source ${H?`data-src="${w0(P.src)}"`:`src="${w0(P.src)}"`} type="${P.type}"${P.media?` media="${P.media}"`:""} />`}).join(`
10228
10228
  `),S=`<video ${E.join(" ")}>
10229
- ${y}
10229
+ ${C}
10230
10230
  Your browser does not support the video tag.
10231
10231
  </video>`,k;if(H)k=`
10232
10232
  (function() {
@@ -10472,7 +10472,7 @@ ${D}
10472
10472
 
10473
10473
  observer.observe(video);
10474
10474
  })();
10475
- `.trim();let y;if(w)y=`
10475
+ `.trim();let C;if(w)C=`
10476
10476
  .stx-video-wrapper {
10477
10477
  position: relative;
10478
10478
  width: 100%;
@@ -10481,7 +10481,7 @@ ${D}
10481
10481
  width: 100%;
10482
10482
  height: auto;
10483
10483
  }
10484
- `.trim();return{html:D,script:E,css:y}}var AJ=!1,TJ=!0,MJ="metadata",$_="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var EJ=b(()=>{K6()});function kJ(){return $4({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,J)=>{let{src:X,options:Q}=K_($,Z,Y);if(!X)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:X,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},q={isDev:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},W=await A4(G,q),z=W.html;if(W.css)z+=`
10484
+ `.trim();return{html:D,script:E,css:C}}var AJ=!1,TJ=!0,MJ="metadata",$_="https://cdn.jsdelivr.net/npm/ts-video-player@latest/dist/index.min.js";var EJ=b(()=>{K6()});function kJ(){return $4({name:"video",hasEndTag:!1,description:"Render a video with optional ts-videos processing, streaming, and poster generation",transform:async($,Z,Y,J)=>{let{src:X,options:Q}=K_($,Z,Y);if(!X)return console.warn("@video directive: missing src argument"),"<!-- @video: missing src -->";let G={src:X,poster:Q.poster,controls:Q.controls!==!1,autoplay:Q.autoplay||!1,muted:Q.muted||!1,loop:Q.loop||!1,preload:Q.preload||"metadata",playsinline:Q.playsinline!==!1,lazy:Q.lazy!==!1,player:Q.player||"native",type:Q.type,width:Q.width,height:Q.height,class:Q.class,style:Q.style,id:Q.id,crossorigin:Q.crossorigin,disablePictureInPicture:Q.disablePictureInPicture,disableRemotePlayback:Q.disableRemotePlayback,title:Q.title,quality:Q.quality,platform:Q.platform,process:Q.process,generatePoster:Q.generatePoster,streaming:Q.streaming,transcode:Q.transcode,spriteSheet:Q.spriteSheet,waveform:Q.waveform},q={isDev:Y.__isDev||!1,tsVideosConfig:Y.__tsVideosConfig},W=await A4(G,q),z=W.html;if(W.css)z+=`
10485
10485
  <style>${W.css}</style>`;if(W.script)z+=`
10486
10486
  <script>${W.script}</script>`;return z},defaults:{src:"",options:{controls:!0,lazy:!0,preload:"metadata"}}})}function K_($,Z,Y){if(Z.src)return{src:String(Z.src),options:Z.options||{}};let J=$.trim();if(J.startsWith("@video(")||J.startsWith("("))J=J.replace(/^@video\(/,"").replace(/^\(/,"").replace(/\)$/,"");let X=q_(J),Q=bJ(X[0],Y)||"",G={};if(X[1]){let K=bJ(X[1],Y);if(typeof K==="object"&&K!==null)G=K;else if(typeof X[1]==="string")try{G=JSON.parse(X[1])}catch{}}return{src:Q,options:G}}function q_($){let Z=[],Y="",J=!1,X="",Q=0,G=0;for(let K=0;K<$.length;K++){let q=$[K],W=K>0?$[K-1]:"";if((q==='"'||q==="'"||q==="`")&&W!=="\\"){if(!J)J=!0,X=q;else if(q===X)J=!1,X="";else Y+=q;continue}if(!J){if(q==="{")Q++;if(q==="}")Q--;if(q==="[")G++;if(q==="]")G--;if(q===","&&Q===0&&G===0){Z.push(Y.trim()),Y="";continue}}Y+=q}if(Y.trim())Z.push(Y.trim());return Z}function bJ($,Z){if(typeof $!=="string")return $;let Y=$.trim();if(Y.startsWith('"')&&Y.endsWith('"')||Y.startsWith("'")&&Y.endsWith("'"))return Y.slice(1,-1);if(!Y.startsWith("/")&&!Y.startsWith(".")&&!Y.startsWith("http")&&!Y.startsWith("{")){let J=Z[Y];if(J!==void 0)return J}if(Y.startsWith("{")||Y.startsWith("["))try{return JSON.parse(Y)}catch{}return Y}var G6;var K6=b(()=>{S3();EJ();G6=kJ()});function z_($,Z){let Y=Z.pwa?.manifest?.themeColor||"#4f46e5";return`<div class="stx-pwa-install" style="display:none;">
10487
10487
  ${$}
@@ -10835,7 +10835,7 @@ ${z}
10835
10835
  customElements.define('${Z}', ${G});
10836
10836
  `}async function CJ($,Z,Y,J){if(Z.length<1)return r("WebComponent","@webcomponent directive requires at least the tag name parameter",n.INVALID_DIRECTIVE_SYNTAX);let X=Z[0].replace(/['"]/g,""),G=(Y.__stx_options||{}).componentsDir||"components",K=[l5.join(l5.dirname(J),G,`${X}.stx`),l5.join(process.cwd(),G,`${X}.stx`),l5.join(l5.dirname(J),`${X}.stx`)],q=null;for(let U of K)if(await l(U)){q=await Bun.file(U).text();break}if(!q)return r("WebComponent",`Component file not found: ${X}.stx`,n.FILE_NOT_FOUND);let W=L_(q,X);return`<script type="module">
10837
10837
  ${F_(W)}
10838
- </script>`}var PJ=b(()=>{G1();A0()});var vJ={};o(vJ,{timingPlugin:()=>R_,pluginManager:()=>V_,definePlugin:()=>R4,debugPlugin:()=>A_,createVariablesPlugin:()=>T_,createFilterPlugin:()=>N_,createDirectivePlugin:()=>w_,PluginManager:()=>q6});function R4($){return $}class q6{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,J]of this.plugins)if(J.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let J of this.sortedPlugins){let X=J[$];if(X)try{let Q=await X(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let G=await Q(Z,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${X.name}" ${$} hook:`,G)}}return J}}function w_($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function N_($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function T_($){return R4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var V_,A_,R_;var xJ=b(()=>{V_=new q6;A_=R4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),R_=R4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var K9={};o(K9,{validateConfig:()=>E_,loadStxConfig:()=>h0,defineStxConfig:()=>D_,defaultConfig:()=>K1,config:()=>n4});import z6 from"fs";import b0 from"path";import{loadConfigWithResult as M_}from"bunfig";function I_($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=b0.join(process.cwd(),"resources","views"),X=b0.join(process.cwd(),"resources","layouts");if(z6.existsSync(J)&&z6.existsSync(X))return{root:"resources",pagesDir:"views"};let Q=b0.join(process.cwd(),"resources","views","pages");if(z6.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function h0($){if(!$){if(U5)return U5;if(T4)return T4}let Z=$?b0.resolve($):process.cwd(),Y=fJ.get(Z);if(Y)return Y;let J=(async()=>{let Q=(await M_({name:"stx",alias:"ui",cwd:Z,defaultConfig:K1,verbose:!1})).config,G=I_(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!b0.isAbsolute(Q.partialsDir))Q.partialsDir=b0.join(K,Q.partialsDir);if(Q.componentsDir&&!b0.isAbsolute(Q.componentsDir))Q.componentsDir=b0.join(K,Q.componentsDir);if(Q.layoutsDir&&!b0.isAbsolute(Q.layoutsDir))Q.layoutsDir=b0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (xJ(),vJ)),q=[],W=[];for(let z of Q.plugins){let U=typeof z==="string"?z:z[0],_=typeof z==="string"?{}:z[1]||{};try{let B,j;try{B=await import(U),j=b0.dirname(z0.resolve(U))}catch{let L=b0.resolve(process.cwd(),U);B=await import(L),j=b0.dirname(L)}let H=B.default||B;if(K.register(H,Q),H.components){let L=b0.resolve(j,H.components);q.push(L)}if(H.pages){let L=b0.resolve(j,H.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(B){console.warn(`[stx] Failed to load plugin ${U}:`,B.message)}}Q._pluginComponentDirs=q,Q._pluginPageDirs=W}return Q})();if(fJ.set(Z,J),!$)T4=J,J.then((X)=>{U5=X}).catch(()=>{});return J}function D_($){return $}function E_($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${J.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let J=["AA","AAA"];if(!J.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${X}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${X}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${X}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${X}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${X}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((X,Q)=>{if(!X.pattern||typeof X.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(X.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(X.maxAgeSeconds!==void 0&&(typeof X.maxAgeSeconds!=="number"||X.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(X.maxEntries!==void 0&&(typeof X.maxEntries!=="number"||X.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((X)=>typeof X!=="number"||X<16||X>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var K1,U5=null,fJ,T4=null,n4;var Q1=b(()=>{E4();k4();b4();S4();E3();GJ();K6();yJ();t7();PJ();K1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:yY,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:CJ,hasEndTag:!1,description:"Include a web component in the template"},j6,H6,RZ,TZ,O6,F6,V6,L6,R6,I6,QJ,G6,...SJ],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};fJ=new Map;n4=new Proxy(K1,{get($,Z){if(U5&&Z in U5)return U5[Z];if(!T4)h0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import{matchRoute as ew,Router as k_}from"stx-router";import{findErrorPage as YN,formatRoutes as JN,generateRouteManifest as XN,generateRouteTypes as QN,matchRoute as GN}from"stx-router";function i5($,Z={}){return new k_($,Z).routes}var W6=()=>{};import{createHash as b_}from"crypto";function S_($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function C_($){return Bun.hash($).toString(16)}function gJ($,Z={}){if(!$.includes('type="stx/island"'))return{html:$,chunks:[]};let Y=new Map,J=$.replace(y_,(Q,G,K,q)=>{let W=q.trim();if(!W)return Q;if(/\bdata-stx-src=/.test(K))return Q;if(Z.minify)W=S_(W);let z=C_(W);if(!Y.has(z))Y.set(z,W);let U=Z.integrity?` data-stx-integrity="sha384-${b_("sha384").update(W).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${G}" data-stx-src="/_stx/islands/${z}.js"${U}${K}></script>`}),X=Array.from(Y,([Q,G])=>({hash:Q,code:G}));return{html:J,chunks:X}}function hJ($){if(!$.includes("data-stx-src="))return $;let Z=new Map,Y=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,J;while((J=Y.exec($))!==null)Z.set(J[1],J[2]);let X=new Set,Q=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,G;while((G=Q.exec($))!==null)if(P_.has(Z.get(G[1])||""))X.add(G[2]);let K=$.lastIndexOf("</head>");if(X.size===0||K===-1)return $;let q=Array.from(X).filter((W)=>!$.includes(`rel="prefetch" href="${W}"`)).map((W)=>`<link rel="prefetch" href="${W}" as="script">`).join("");if(!q)return $;return $.slice(0,K)+q+$.slice(K)}var y_,P_;var dJ=b(()=>{y_=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;P_=new Set(["visible","idle"])});import{abortNavigation as UN,clearMiddleware as mJ,createClientCookieManager as _N,createMiddlewareContext as uJ,createRouteLocation as pJ,createServerCookieManager as BN,createStorageManager as jN,defineMiddleware as HN,getMiddleware as ON,getMiddlewareNames as cJ,hasMiddleware as LN,loadMiddlewareFromDirectory as lJ,navigateTo as FN,registerMiddleware as VN,runMiddleware as iJ}from"stx-router";var nJ=()=>{};var YX={};o(YX,{generateStaticSite:()=>aJ,defineStaticPaths:()=>$X,default:()=>i_,createMarkdownLoader:()=>ZX,createISRHandler:()=>eJ});import V0 from"fs";import J0 from"path";class oJ{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=J0.join(this.cacheDir,"build-cache.json");if(await Bun.file($).exists())try{let Z=JSON.parse(await Bun.file($).text());for(let[Y,J]of Object.entries(Z))this.cache.set(Y,J)}catch{}this.loaded=!0}async save(){await V0.promises.mkdir(this.cacheDir,{recursive:!0});let $=J0.join(this.cacheDir,"build-cache.json"),Z={};for(let[Y,J]of this.cache)Z[Y]=J;await Bun.write($,JSON.stringify(Z))}getHash($,Z){let Y=V0.statSync($),J=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(V0.existsSync(Q)){let G=V0.statSync(Q);J+=`:${Q}:${G.mtimeMs}`}let X=0;for(let Q=0;Q<J.length;Q++){let G=J.charCodeAt(Q);X=(X<<5)-X+G,X=X&X}return Math.abs(X).toString(36)}get($,Z){let Y=this.cache.get($);if(!Y)return null;let J=this.getHash(Z,Y.dependencies??[]);if(Y.hash!==J)return this.cache.delete($),null;return Y.html}set($,Z,Y,J){let X=this.getHash(Z,Y);this.cache.set($,{hash:X,html:J,generatedAt:Date.now(),dependencies:Y})}}class sJ{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return J0.join(this.cacheDir,"isr",Z)}async get($){let Z=this.getFilePath($);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set($,Z){let Y=this.getFilePath($);await V0.promises.mkdir(J0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await V0.promises.unlink(Z)}async invalidatePattern($){let Z=J0.join(this.cacheDir,"isr");if(!V0.existsSync(Z))return;let Y=await V0.promises.readdir(Z);for(let J of Y){let X=J.replace(/_/g,"/").replace(".json","");if($.test(X))await V0.promises.unlink(J0.join(Z,J))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function v_($){try{let Y=(await Bun.file($).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return null;let J=Y[1];if(!J.includes("getStaticPaths"))return null;let X=J.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!X)return null;return await Function(`
10838
+ </script>`}var PJ=b(()=>{G1();A0()});var vJ={};o(vJ,{timingPlugin:()=>R_,pluginManager:()=>V_,definePlugin:()=>R4,debugPlugin:()=>A_,createVariablesPlugin:()=>T_,createFilterPlugin:()=>N_,createDirectivePlugin:()=>w_,PluginManager:()=>q6});function R4($){return $}class q6{plugins=new Map;sortedPlugins=[];initialized=!1;async register($,Z){if(this.plugins.has($.name))throw Error(`Plugin "${$.name}" is already registered`);if($.dependencies){for(let Y of $.dependencies)if(!this.plugins.has(Y))throw Error(`Plugin "${$.name}" depends on "${Y}" which is not registered`)}if(this.plugins.set($.name,$),$.onRegister)await $.onRegister(Z);this.sortPlugins()}async unregister($){let Z=this.plugins.get($);if(!Z)return!1;for(let[Y,J]of this.plugins)if(J.dependencies?.includes($))throw Error(`Cannot unregister "${$}" because "${Y}" depends on it`);if(Z.onUnregister)await Z.onUnregister();return this.plugins.delete($),this.sortPlugins(),!0}get($){return this.plugins.get($)}has($){return this.plugins.has($)}getAll(){return[...this.sortedPlugins]}getAllDirectives(){let $=[];for(let Z of this.sortedPlugins)if(Z.registerDirectives)$.push(...Z.registerDirectives());return $}getAllFilters(){let $={};for(let Z of this.sortedPlugins)if(Z.registerFilters)Object.assign($,Z.registerFilters());return $}async runBeforeProcess($){return this.runHooks("beforeProcess",$)}async runAfterParse($){return this.runHooks("afterParse",$)}async runBeforeDirective($,Z){return this.runDirectiveHooks("beforeDirective",$,Z)}async runAfterDirective($,Z){return this.runDirectiveHooks("afterDirective",$,Z)}async runBeforeRender($){return this.runHooks("beforeRender",$)}async runAfterRender($){return this.runHooks("afterRender",$)}async runOnError($){for(let Z of this.sortedPlugins)if(Z.onError)try{let Y=await Z.onError($);if(Y){if(Y.template!==void 0)$.template=Y.template;if(Y.context)$.context={...$.context,...Y.context};if(Y.metadata)$.metadata={...$.metadata,...Y.metadata};if(Y.skip)return $}}catch(Y){console.error(`Error in plugin "${Z.name}" onError hook:`,Y)}return null}sortPlugins(){this.sortedPlugins=Array.from(this.plugins.values()).sort(($,Z)=>($.priority??100)-(Z.priority??100))}async runHooks($,Z){let Y={...Z};for(let J of this.sortedPlugins){let X=J[$];if(X)try{let Q=await X(Y);if(Q){if(Q.template!==void 0)Y.template=Q.template;if(Q.context)Y.context={...Y.context,...Q.context};if(Q.metadata)Y.metadata={...Y.metadata,...Q.metadata};if(Q.skip)break}}catch(Q){console.error(`Error in plugin "${J.name}" ${$} hook:`,Q)}}return Y}async runDirectiveHooks($,Z,Y){let J={...Y};for(let X of this.sortedPlugins){let Q=X[$];if(Q)try{let G=await Q(Z,J);if(G){if(G.template!==void 0)J.template=G.template;if(G.context)J.context={...J.context,...G.context};if(G.metadata)J.metadata={...J.metadata,...G.metadata};if(G.skip)break}}catch(G){console.error(`Error in plugin "${X.name}" ${$} hook:`,G)}}return J}}function w_($,Z,Y={}){return{name:$,...Y,registerDirectives:()=>Z}}function N_($,Z,Y={}){return{name:$,...Y,registerFilters:()=>Z}}function T_($){return R4({name:"stx-variables",version:"1.0.0",description:"Adds predefined variables to template context",beforeProcess(Z){return{context:{...Z.context,...$}}}})}var V_,A_,R_;var xJ=b(()=>{V_=new q6;A_=R4({name:"stx-debug",version:"1.0.0",description:"Logs all plugin lifecycle events for debugging",priority:0,beforeProcess($){console.log("[stx-debug] beforeProcess:",$.filePath)},afterParse($){console.log("[stx-debug] afterParse:",$.template.length,"chars")},beforeDirective($,Z){console.log("[stx-debug] beforeDirective:",$)},afterDirective($,Z){console.log("[stx-debug] afterDirective:",$)},beforeRender($){console.log("[stx-debug] beforeRender")},afterRender($){console.log("[stx-debug] afterRender:",$.template.length,"chars")},onError($){console.error("[stx-debug] onError:",$.error.message,"in phase:",$.phase)}}),R_=R4({name:"stx-timing",version:"1.0.0",description:"Measures template processing time",priority:1,beforeProcess($){$.metadata.startTime=performance.now()},afterRender($){let Z=$.metadata.startTime;if(Z){let Y=performance.now()-Z;console.log(`[stx-timing] Processing took ${Y.toFixed(2)}ms`)}}})});var K9={};o(K9,{validateConfig:()=>E_,loadStxConfig:()=>h0,defineStxConfig:()=>D_,defaultConfig:()=>K1,config:()=>n4});import z6 from"fs";import S0 from"path";import{loadConfigWithResult as M_}from"bunfig";function I_($,Z){let Y=Z||"pages";if($)return{root:$,pagesDir:Y};let J=S0.join(process.cwd(),"resources","views"),X=S0.join(process.cwd(),"resources","layouts");if(z6.existsSync(J)&&z6.existsSync(X))return{root:"resources",pagesDir:"views"};let Q=S0.join(process.cwd(),"resources","views","pages");if(z6.existsSync(Q))return{root:"resources/views",pagesDir:Y};return{root:".",pagesDir:Y}}async function h0($){if(!$){if(U5)return U5;if(T4)return T4}let Z=$?S0.resolve($):process.cwd(),Y=fJ.get(Z);if(Y)return Y;let J=(async()=>{let Q=(await M_({name:"stx",alias:"ui",cwd:Z,defaultConfig:K1,verbose:!1})).config,G=I_(Q.root,Q.pagesDir);if(Q.root=G.root,Q.pagesDir=G.pagesDir,Q.root&&Q.root!=="."){let K=Q.root;if(Q.partialsDir&&!S0.isAbsolute(Q.partialsDir))Q.partialsDir=S0.join(K,Q.partialsDir);if(Q.componentsDir&&!S0.isAbsolute(Q.componentsDir))Q.componentsDir=S0.join(K,Q.componentsDir);if(Q.layoutsDir&&!S0.isAbsolute(Q.layoutsDir))Q.layoutsDir=S0.join(K,Q.layoutsDir)}if(Q.plugins&&Q.plugins.length>0){let{pluginManager:K}=await Promise.resolve().then(() => (xJ(),vJ)),q=[],W=[];for(let z of Q.plugins){let U=typeof z==="string"?z:z[0],_=typeof z==="string"?{}:z[1]||{};try{let B,j;try{B=await import(U),j=S0.dirname(z0.resolve(U))}catch{let L=S0.resolve(process.cwd(),U);B=await import(L),j=S0.dirname(L)}let H=B.default||B;if(K.register(H,Q),H.components){let L=S0.resolve(j,H.components);q.push(L)}if(H.pages){let L=S0.resolve(j,H.pages),F=_.path||"/";W.push({dir:L,prefix:F})}if(H.setup){let L={addDirective:(F)=>{Q.customDirectives=Q.customDirectives||[],Q.customDirectives.push(F)},addRoute:(F,O)=>{Q.apiRoutes=Q.apiRoutes||{},Q.apiRoutes[F]=O},addMiddleware:(F)=>{Q.middleware=Q.middleware||[],Q.middleware.push(F)},pluginDir:j,config:Q};await H.setup(_,L)}console.log(`[stx] Plugin loaded: ${H.name||U}`)}catch(B){console.warn(`[stx] Failed to load plugin ${U}:`,B.message)}}Q._pluginComponentDirs=q,Q._pluginPageDirs=W}return Q})();if(fJ.set(Z,J),!$)T4=J,J.then((X)=>{U5=X}).catch(()=>{});return J}function D_($){return $}function E_($){let Z=[],Y=[];if($.partialsDir!==void 0&&typeof $.partialsDir!=="string")Z.push({path:"partialsDir",message:"partialsDir must be a string",severity:"error"});if($.componentsDir!==void 0&&typeof $.componentsDir!=="string")Z.push({path:"componentsDir",message:"componentsDir must be a string",severity:"error"});if($.cache!==void 0&&typeof $.cache!=="boolean")Z.push({path:"cache",message:"cache must be a boolean",severity:"error"});if($.debug!==void 0&&typeof $.debug!=="boolean")Z.push({path:"debug",message:"debug must be a boolean",severity:"error"});if($.streaming){if($.streaming.bufferSize!==void 0){if(typeof $.streaming.bufferSize!=="number"||$.streaming.bufferSize<=0)Z.push({path:"streaming.bufferSize",message:"streaming.bufferSize must be a positive number",severity:"error"})}if($.streaming.timeout!==void 0){if(typeof $.streaming.timeout!=="number"||$.streaming.timeout<=0)Z.push({path:"streaming.timeout",message:"streaming.timeout must be a positive number",severity:"error"})}if($.streaming.strategy!==void 0){let J=["auto","manual","sections"];if(!J.includes($.streaming.strategy))Z.push({path:"streaming.strategy",message:`streaming.strategy must be one of: ${J.join(", ")}`,severity:"error"})}}if($.i18n){if($.i18n.format!==void 0){let J=["json","yaml","yml","js"];if(!J.includes($.i18n.format))Z.push({path:"i18n.format",message:`i18n.format must be one of: ${J.join(", ")}`,severity:"error"})}}if($.animation){if($.animation.defaultDuration!==void 0){if(typeof $.animation.defaultDuration!=="number"||$.animation.defaultDuration<0)Z.push({path:"animation.defaultDuration",message:"animation.defaultDuration must be a non-negative number",severity:"error"})}if($.animation.staggerDelay!==void 0){if(typeof $.animation.staggerDelay!=="number"||$.animation.staggerDelay<0)Z.push({path:"animation.staggerDelay",message:"animation.staggerDelay must be a non-negative number",severity:"error"})}}if($.a11y){if($.a11y.level!==void 0){let J=["AA","AAA"];if(!J.includes($.a11y.level))Z.push({path:"a11y.level",message:`a11y.level must be one of: ${J.join(", ")}`,severity:"error"})}}if($.hydration){if($.hydration.mode!==void 0){let J=["progressive","islands"];if(!J.includes($.hydration.mode))Z.push({path:"hydration.mode",message:`hydration.mode must be one of: ${J.join(", ")}`,severity:"error"})}if($.hydration.preload!==void 0){let J=["none","eager","lazy"];if(!J.includes($.hydration.preload))Z.push({path:"hydration.preload",message:`hydration.preload must be one of: ${J.join(", ")}`,severity:"error"})}}if($.customDirectives)if(!Array.isArray($.customDirectives))Z.push({path:"customDirectives",message:"customDirectives must be an array",severity:"error"});else $.customDirectives.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`customDirectives[${X}].name`,message:"Custom directive must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`customDirectives[${X}].handler`,message:"Custom directive must have a handler function",severity:"error"})});if($.middleware)if(!Array.isArray($.middleware))Z.push({path:"middleware",message:"middleware must be an array",severity:"error"});else $.middleware.forEach((J,X)=>{if(!J.name||typeof J.name!=="string")Z.push({path:`middleware[${X}].name`,message:"Middleware must have a name string",severity:"error"});if(!J.handler||typeof J.handler!=="function")Z.push({path:`middleware[${X}].handler`,message:"Middleware must have a handler function",severity:"error"});if(!J.timing||!["before","after"].includes(J.timing))Z.push({path:`middleware[${X}].timing`,message:'Middleware timing must be "before" or "after"',severity:"error"})});if($.debug===!0&&$.cache===!0)Y.push({path:"debug+cache",message:"Debug mode with caching enabled may show stale content during development",severity:"warning"});if($.seo?.enabled===!0&&!$.seo?.defaultConfig?.title)Y.push({path:"seo.defaultConfig.title",message:"SEO is enabled but no default title is set",severity:"warning"});if($.pwa){if($.pwa.enabled===!0&&!$.pwa.manifest?.name)Z.push({path:"pwa.manifest.name",message:"PWA manifest name is required when PWA is enabled",severity:"error"});if($.pwa.manifest?.display!==void 0){let J=["fullscreen","standalone","minimal-ui","browser"];if(!J.includes($.pwa.manifest.display))Z.push({path:"pwa.manifest.display",message:`PWA display must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.manifest?.orientation!==void 0){let J=["portrait","landscape","any","portrait-primary","portrait-secondary","landscape-primary","landscape-secondary"];if(!J.includes($.pwa.manifest.orientation))Z.push({path:"pwa.manifest.orientation",message:`PWA orientation must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.routes){let J=["cache-first","network-first","stale-while-revalidate","network-only","cache-only"];$.pwa.routes.forEach((X,Q)=>{if(!X.pattern||typeof X.pattern!=="string")Z.push({path:`pwa.routes[${Q}].pattern`,message:"PWA route must have a pattern string",severity:"error"});if(!J.includes(X.strategy))Z.push({path:`pwa.routes[${Q}].strategy`,message:`PWA route strategy must be one of: ${J.join(", ")}`,severity:"error"});if(X.maxAgeSeconds!==void 0&&(typeof X.maxAgeSeconds!=="number"||X.maxAgeSeconds<0))Z.push({path:`pwa.routes[${Q}].maxAgeSeconds`,message:"PWA route maxAgeSeconds must be a non-negative number",severity:"error"});if(X.maxEntries!==void 0&&(typeof X.maxEntries!=="number"||X.maxEntries<1))Z.push({path:`pwa.routes[${Q}].maxEntries`,message:"PWA route maxEntries must be a positive number",severity:"error"})})}if($.pwa.icons?.sizes){if(!Array.isArray($.pwa.icons.sizes))Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be an array of numbers",severity:"error"});else if($.pwa.icons.sizes.filter((X)=>typeof X!=="number"||X<16||X>1024).length>0)Z.push({path:"pwa.icons.sizes",message:"PWA icon sizes must be numbers between 16 and 1024",severity:"error"})}if($.pwa.icons?.purpose){let J=["any","maskable","monochrome"];if($.pwa.icons.purpose.filter((Q)=>!J.includes(Q)).length>0)Z.push({path:"pwa.icons.purpose",message:`PWA icon purpose must be one of: ${J.join(", ")}`,severity:"error"})}if($.pwa.enabled===!0&&!$.pwa.icons?.src)Y.push({path:"pwa.icons.src",message:"PWA is enabled but no icon source specified. Provide a 512x512 PNG for best results.",severity:"warning"});if($.pwa.enabled===!0&&!$.pwa.manifest?.themeColor)Y.push({path:"pwa.manifest.themeColor",message:"PWA theme color not set, defaulting to black",severity:"warning"})}return{valid:Z.length===0,errors:Z,warnings:Y}}var K1,U5=null,fJ,T4=null,n4;var Q1=b(()=>{E4();k4();b4();S4();E3();GJ();K6();yJ();t7();PJ();K1={enabled:!0,ssr:!1,partialsDir:"partials",componentsDir:"components",layoutsDir:"layouts",defaultLayout:"default",debug:!1,cache:!0,cachePath:".stx/cache",cacheVersion:"1.0.0",build:{pagesDir:"pages",outputDir:"dist",baseUrl:"/",sitemap:!0,minify:!0,cache:!0,cacheDir:".stx/ssg-cache",concurrency:10,generate404:!0,publicDir:"public",trailingSlash:!1,cleanOutput:!0},customDirectives:[{name:"markdown",handler:yY,hasEndTag:!0,description:"Render markdown content to HTML"},{name:"webcomponent",handler:CJ,hasEndTag:!1,description:"Include a web component in the template"},j6,H6,RZ,TZ,O6,F6,V6,L6,R6,I6,QJ,G6,...SJ],middleware:[],i18n:{defaultLocale:"en",locale:"en",translationsDir:"translations",format:"yaml",fallbackToKey:!0,cache:!0},webComponents:{enabled:!1,outputDir:"dist/web-components",components:[]},docs:{enabled:!1,outputDir:"docs",format:"markdown",components:!0,templates:!0,directives:!0},streaming:{enabled:!0,bufferSize:16384,strategy:"auto",timeout:30000},hydration:{enabled:!1,mode:"islands",clientEntry:"src/client.ts",autoMarkers:!0,preload:"lazy"},router:{enabled:!0,container:"#app-content",linkSelector:"a[href]",viewTransitions:!0,scrollToTop:!0,prefetch:!0,cache:!0,cacheTTL:300000,skipSelectors:'[data-no-router], [target="_blank"]',viewTransitionCSS:{oldRoot:"fade-out 0.15s ease-in",newRoot:"fade-in 0.2s ease-out",oldContent:"slide-out 0.2s ease-in",newContent:"slide-in 0.25s ease-out"}},a11y:{enabled:!0,addSrOnlyStyles:!0,level:"AA",autoFix:!1,ignoreChecks:[]},seo:{enabled:!0,socialPreview:!0,defaultConfig:{title:"stx Project",description:"A website built with stx templating engine"}},animation:{enabled:!0,defaultDuration:300,defaultEase:"ease",respectMotionPreferences:!0,staggerDelay:50},markdown:{enabled:!0,syntaxHighlighting:{enabled:!0,serverSide:!0,defaultTheme:"github-dark",highlightUnknownLanguages:!0,additionalThemes:["light-plus","one-dark-pro","dracula","monokai","solarized-light","nord","github-dark"]}},loops:{maxWhileIterations:1000,useAltLoopVariable:!1},story:{enabled:!0,outDir:".stx/dist/story",storyMatch:["**/*.story.stx"],storyIgnored:["**/node_modules/**","**/dist/**","**/.stx/**"],port:6006},pwa:{enabled:!1,manifest:{name:"stx App",shortName:"stx",description:"A Progressive Web App built with stx",startUrl:"/",display:"standalone",orientation:"any",themeColor:"#000000",backgroundColor:"#ffffff",scope:"/"},icons:{src:"public/icon.png",sizes:[72,96,128,144,152,192,384,512],generateWebP:!0,generateAppleIcons:!0,outputDir:"pwa-icons",purpose:["any","maskable"]},routes:[{pattern:"/",strategy:"network-first"},{pattern:"/static/*",strategy:"cache-first",maxAgeSeconds:2592000},{pattern:"/api/*",strategy:"network-only"},{pattern:"*.js",strategy:"stale-while-revalidate"},{pattern:"*.css",strategy:"stale-while-revalidate"},{pattern:"*.png",strategy:"cache-first"},{pattern:"*.jpg",strategy:"cache-first"},{pattern:"*.webp",strategy:"cache-first"},{pattern:"*.svg",strategy:"cache-first"}],offline:{enabled:!0,fallbackTitle:"You are offline",fallbackMessage:"Please check your internet connection and try again.",precacheAssets:[]},serviceWorker:{fileName:"sw.js",cacheVersion:"1.0.0",skipWaiting:!0,clientsClaim:!0,navigationPreload:!1,excludeRoutes:["/api/auth/*"],cacheFileTypes:["html","css","js","png","jpg","jpeg","webp","svg","woff","woff2"],useWorkbox:!1},autoInject:!0,push:{enabled:!1,defaultOptions:{vibrate:[100,50,100],requireInteraction:!1}},backgroundSync:{enabled:!1,queueName:"stx-sync-queue",maxRetentionMinutes:1440,maxRetries:3,minInterval:1000,forms:[],endpoints:[]},shareTarget:{enabled:!1,action:"/share-target",method:"POST",enctype:"multipart/form-data",params:{title:"title",text:"text",url:"url"}},fileHandlers:{enabled:!1},protocolHandlers:[],cacheStorage:{maxSize:100,maxEntries:500,maxAge:30,purgeStrategy:"lru"},updates:{enabled:!0,promptUser:!0,autoReload:!1,message:"A new version is available. Reload to update?"},precache:{enabled:!0,includeHtml:!0,includeJs:!0,includeCss:!0,includeImages:!0,includeFonts:!0,include:[],exclude:["*.map","*.LICENSE.txt"],maxFileSizeKB:500}},media:{enabled:!0,image:{enabled:!0,defaultWidths:[320,480,640,768,1024,1280,1536,1920],defaultFormats:["avif","webp","jpeg"],defaultQuality:80,placeholderStrategy:"thumbhash",lazyByDefault:!0,enableDpr:!0,defaultDpr:[1,2,3],tsImages:{enabled:!0,outputDir:"dist/images",baseUrl:"/images",formatQuality:{jpeg:{quality:85,mozjpeg:!0,progressive:!0},png:{compressionLevel:9,palette:!1},webp:{quality:82,effort:5,smartSubsample:!0},avif:{quality:75,effort:4,lossless:!1}},breakpoints:[320,480,640,768,1024,1280,1536,1920],batchOptions:{concurrency:4,optimizationPreset:"web"}}},video:{enabled:!0,lazyByDefault:!0,defaultControls:!0,tsVideos:{enabled:!0,outputDir:"dist/videos",baseUrl:"/videos",defaultQuality:"high",streaming:{enabled:!0,format:"hls",segmentDuration:6,defaultQualities:[{label:"1080p",width:1920,height:1080,bitrate:5000000,audioBitrate:192000},{label:"720p",width:1280,height:720,bitrate:2500000,audioBitrate:128000},{label:"480p",width:854,height:480,bitrate:1e6,audioBitrate:96000}]},thumbnails:{enabled:!0,count:10,format:"webp",width:320},transcoding:{defaultCodec:"h264",defaultAudioCodec:"aac",speedPreset:"medium"}}},upload:{enabled:!0,maxSize:10485760,allowedTypes:["image/*","video/*","audio/*","application/pdf"],maxConcurrent:3},protected:{enabled:!0,expirationSeconds:3600,batchSize:10},cache:{enabled:!0,directory:".stx/media-cache",maxAge:30,maxSize:500}},broadcasting:{enabled:!1,driver:"bun",host:"0.0.0.0",port:6001,scheme:"ws",verbose:!1}};fJ=new Map;n4=new Proxy(K1,{get($,Z){if(U5&&Z in U5)return U5[Z];if(!T4)h0().catch((Y)=>{console.warn("[stx] Failed to load config file:",Y?.message||Y)});return $[Z]}})});import{matchRoute as ew,Router as k_}from"stx-router";import{findErrorPage as YN,formatRoutes as JN,generateRouteManifest as XN,generateRouteTypes as QN,matchRoute as GN}from"stx-router";function i5($,Z={}){return new k_($,Z).routes}var W6=()=>{};import{createHash as b_}from"crypto";function S_($){try{return new Bun.Transpiler({loader:"js",minifyWhitespace:!0}).transformSync($).replace(/\}(var |let |const |function )/g,"};$1").trim()}catch{return $}}function C_($){return Bun.hash($).toString(16)}function gJ($,Z={}){if(!$.includes('type="stx/island"'))return{html:$,chunks:[]};let Y=new Map,J=$.replace(y_,(Q,G,K,q)=>{let W=q.trim();if(!W)return Q;if(/\bdata-stx-src=/.test(K))return Q;if(Z.minify)W=S_(W);let z=C_(W);if(!Y.has(z))Y.set(z,W);let U=Z.integrity?` data-stx-integrity="sha384-${b_("sha384").update(W).digest("base64")}"`:"";return`<script type="stx/island" data-stx-island="${G}" data-stx-src="/_stx/islands/${z}.js"${U}${K}></script>`}),X=Array.from(Y,([Q,G])=>({hash:Q,code:G}));return{html:J,chunks:X}}function hJ($){if(!$.includes("data-stx-src="))return $;let Z=new Map,Y=/data-stx-scope="([^"]+)"[^>]*?stx-hydrate="([^"]+)"/g,J;while((J=Y.exec($))!==null)Z.set(J[1],J[2]);let X=new Set,Q=/data-stx-island="([^"]+)"[^>]*?data-stx-src="([^"]+)"/g,G;while((G=Q.exec($))!==null)if(P_.has(Z.get(G[1])||""))X.add(G[2]);let K=$.lastIndexOf("</head>");if(X.size===0||K===-1)return $;let q=Array.from(X).filter((W)=>!$.includes(`rel="prefetch" href="${W}"`)).map((W)=>`<link rel="prefetch" href="${W}" as="script">`).join("");if(!q)return $;return $.slice(0,K)+q+$.slice(K)}var y_,P_;var dJ=b(()=>{y_=/<script\s+type="stx\/island"\s+data-stx-island="([^"]+)"([^>]*)>([\s\S]*?)<\/script>/g;P_=new Set(["visible","idle"])});import{abortNavigation as UN,clearMiddleware as mJ,createClientCookieManager as _N,createMiddlewareContext as uJ,createRouteLocation as pJ,createServerCookieManager as BN,createStorageManager as jN,defineMiddleware as HN,getMiddleware as ON,getMiddlewareNames as cJ,hasMiddleware as LN,loadMiddlewareFromDirectory as lJ,navigateTo as FN,registerMiddleware as VN,runMiddleware as iJ}from"stx-router";var nJ=()=>{};var YX={};o(YX,{generateStaticSite:()=>aJ,defineStaticPaths:()=>$X,default:()=>i_,createMarkdownLoader:()=>ZX,createISRHandler:()=>eJ});import V0 from"fs";import J0 from"path";class oJ{cacheDir;cache=new Map;loaded=!1;constructor($){this.cacheDir=$}async load(){if(this.loaded)return;let $=J0.join(this.cacheDir,"build-cache.json");if(await Bun.file($).exists())try{let Z=JSON.parse(await Bun.file($).text());for(let[Y,J]of Object.entries(Z))this.cache.set(Y,J)}catch{}this.loaded=!0}async save(){await V0.promises.mkdir(this.cacheDir,{recursive:!0});let $=J0.join(this.cacheDir,"build-cache.json"),Z={};for(let[Y,J]of this.cache)Z[Y]=J;await Bun.write($,JSON.stringify(Z))}getHash($,Z){let Y=V0.statSync($),J=`${$}:${Y.mtimeMs}`;for(let Q of Z)if(V0.existsSync(Q)){let G=V0.statSync(Q);J+=`:${Q}:${G.mtimeMs}`}let X=0;for(let Q=0;Q<J.length;Q++){let G=J.charCodeAt(Q);X=(X<<5)-X+G,X=X&X}return Math.abs(X).toString(36)}get($,Z){let Y=this.cache.get($);if(!Y)return null;let J=this.getHash(Z,Y.dependencies??[]);if(Y.hash!==J)return this.cache.delete($),null;return Y.html}set($,Z,Y,J){let X=this.getHash(Z,Y);this.cache.set($,{hash:X,html:J,generatedAt:Date.now(),dependencies:Y})}}class sJ{cacheDir;constructor($){this.cacheDir=$}getFilePath($){let Z=$.replace(/[^a-zA-Z0-9]/g,"_")+".json";return J0.join(this.cacheDir,"isr",Z)}async get($){let Z=this.getFilePath($);if(!await Bun.file(Z).exists())return null;try{return JSON.parse(await Bun.file(Z).text())}catch{return null}}async set($,Z){let Y=this.getFilePath($);await V0.promises.mkdir(J0.dirname(Y),{recursive:!0}),await Bun.write(Y,JSON.stringify(Z))}async invalidate($){let Z=this.getFilePath($);if(await Bun.file(Z).exists())await V0.promises.unlink(Z)}async invalidatePattern($){let Z=J0.join(this.cacheDir,"isr");if(!V0.existsSync(Z))return;let Y=await V0.promises.readdir(Z);for(let J of Y){let X=J.replace(/_/g,"/").replace(".json","");if($.test(X))await V0.promises.unlink(J0.join(Z,J))}}async needsRevalidation($){let Z=await this.get($);if(!Z)return!0;return Date.now()>Z.revalidateAfter}}async function v_($){try{let Y=(await Bun.file($).text()).match(/<script\s+server\b[^>]*>([\s\S]*?)<\/script>/i);if(!Y)return null;let J=Y[1];if(!J.includes("getStaticPaths"))return null;let X=J.match(/(?:export\s+)?(?:async\s+)?function\s+getStaticPaths\s*\([^)]*\)\s*\{([\s\S]*?)\n[\t ]*\}/);if(!X)return null;return await Function(`
10839
10839
  return (async function getStaticPaths() {
10840
10840
  ${X[1]}
10841
10841
  })()
@@ -10875,7 +10875,7 @@ ${$.map((J)=>{let X=new URL(J.loc,Z).href,Q=` <url>
10875
10875
  ${Y.join(`
10876
10876
  `)}
10877
10877
  </channel>
10878
- </rss>`}async function aJ($={}){let Z=Date.now(),Y=await h0(),J={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},X={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},q={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&V0.existsSync(J.outputDir))await V0.promises.rm(J.outputDir,{recursive:!0});await V0.promises.mkdir(J.outputDir,{recursive:!0});let z=new oJ(J.cacheDir);if(J.cache)await z.load();try{let{preloadIconCollection:V}=await Promise.resolve().then(() => (I$(),I8));await V("lucide")}catch{}try{let{generateCrosswindCSS:V}=await Promise.resolve().then(() => (R5(),G9));await V('<div class="bg-black"></div>')}catch{}mJ();let U=Y?.routeMiddleware?.dir||"middleware";await lJ(process.cwd(),U);let _=cJ();if(_.length>0)console.log(`Loaded ${_.length} middleware: ${_.join(", ")}`);let B=Y?.routeMiddleware?.global||[],j=i5(".",{pagesDir:J.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let V of j){let w=await x_(V);for(let N of w)H.push({route:V,url:N.url,params:N.params,props:N.props,revalidate:N.revalidate??J.revalidate})}X.totalPages=H.length,console.log(`Generating ${X.totalPages} pages...`);let L=[],F=[];for(let V=0;V<H.length;V+=J.concurrency)F.push(H.slice(V,V+J.concurrency));for(let V of F)await Promise.all(V.map(async(w)=>{let{route:N,url:A,params:R,props:T,revalidate:M}=w;try{await J.hooks.onPageStart?.(A);let I=await Bun.file(N.filePath).text(),D=p_(I),E=D?.middleware?Array.isArray(D.middleware)?D.middleware:[D.middleware]:[],y=[...B,...E];if(y.length>0){let m=pJ(A,R,D||{}),c=uJ(m,null),Y0=await iJ(y,c);if(Y0.redirect){let K0=typeof Y0.redirect==="string"?Y0.redirect:Y0.redirect.path||Y0.redirect,O0=c_(String(K0),A),B0=l_(A,J);await V0.promises.mkdir(J0.dirname(B0),{recursive:!0}),await Bun.write(B0,O0),X.successCount++,X.pages.push({route:A,outputPath:B0,size:Buffer.byteLength(O0),cached:!1}),L.push({loc:A,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${A} \u2192 redirect to ${K0}`);return}if(Y0.abort){let K0=typeof Y0.abort==="string"?Y0.abort:Y0.abort?.error?.message||"aborted";console.warn(` \u21B3 ${A} \u2014 middleware aborted: ${K0}`);return}}let S=I.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(S)try{if(!await Function("route",`
10878
+ </rss>`}async function aJ($={}){let Z=Date.now(),Y=await h0(),J={pagesDir:$.pagesDir||"pages",outputDir:$.outputDir||"dist",baseUrl:$.baseUrl||"/",domain:$.domain||"http://localhost",revalidate:$.revalidate??!1,sitemap:$.sitemap??!0,rss:$.rss??!1,concurrency:$.concurrency||10,cache:$.cache??!0,cacheDir:$.cacheDir||".stx/ssg-cache",contentLoaders:$.contentLoaders||[],hooks:$.hooks||{},minify:$.minify??!1,generate404:$.generate404??!0,publicDir:$.publicDir||"public",trailingSlash:$.trailingSlash??!1,cleanOutput:$.cleanOutput??!0,chunkIslands:$.chunkIslands===!0,prefetchIslands:$.prefetchIslands===!0,integrityIslands:$.integrityIslands===!0},X={totalPages:0,successCount:0,failedCount:0,cachedCount:0,buildTime:0,pages:[],errors:[]},Q=new Set,G=0,K={},q={};await J.hooks.onBuildStart?.();try{if(J.cleanOutput&&V0.existsSync(J.outputDir))await V0.promises.rm(J.outputDir,{recursive:!0});await V0.promises.mkdir(J.outputDir,{recursive:!0});let z=new oJ(J.cacheDir);if(J.cache)await z.load();try{let{preloadIconCollection:V}=await Promise.resolve().then(() => (I$(),I8));await V("lucide")}catch{}try{let{generateCrosswindCSS:V}=await Promise.resolve().then(() => (R5(),G9));await V('<div class="bg-black"></div>')}catch{}mJ();let U=Y?.routeMiddleware?.dir||"middleware";await lJ(process.cwd(),U);let _=cJ();if(_.length>0)console.log(`Loaded ${_.length} middleware: ${_.join(", ")}`);let B=Y?.routeMiddleware?.global||[],j=i5(".",{pagesDir:J.pagesDir});console.log(`Found ${j.length} routes`);let H=[];for(let V of j){let w=await x_(V);for(let N of w)H.push({route:V,url:N.url,params:N.params,props:N.props,revalidate:N.revalidate??J.revalidate})}X.totalPages=H.length,console.log(`Generating ${X.totalPages} pages...`);let L=[],F=[];for(let V=0;V<H.length;V+=J.concurrency)F.push(H.slice(V,V+J.concurrency));for(let V of F)await Promise.all(V.map(async(w)=>{let{route:N,url:A,params:R,props:T,revalidate:M}=w;try{await J.hooks.onPageStart?.(A);let I=await Bun.file(N.filePath).text(),D=p_(I),E=D?.middleware?Array.isArray(D.middleware)?D.middleware:[D.middleware]:[],C=[...B,...E];if(C.length>0){let m=pJ(A,R,D||{}),c=uJ(m,null),Y0=await iJ(C,c);if(Y0.redirect){let K0=typeof Y0.redirect==="string"?Y0.redirect:Y0.redirect.path||Y0.redirect,O0=c_(String(K0),A),B0=l_(A,J);await V0.promises.mkdir(J0.dirname(B0),{recursive:!0}),await Bun.write(B0,O0),X.successCount++,X.pages.push({route:A,outputPath:B0,size:Buffer.byteLength(O0),cached:!1}),L.push({loc:A,lastmod:new Date().toISOString()}),console.log(` \u21B3 ${A} \u2192 redirect to ${K0}`);return}if(Y0.abort){let K0=typeof Y0.abort==="string"?Y0.abort:Y0.abort?.error?.message||"aborted";console.warn(` \u21B3 ${A} \u2014 middleware aborted: ${K0}`);return}}let S=I.match(/definePageMeta\s*\(\s*\{[\s\S]*?validate\s*:\s*((?:\([^)]*\)|[^,}])*(?:\{[\s\S]*?\})?)/m);if(S)try{if(!await Function("route",`
10879
10879
  const validate = ${S[1]};
10880
10880
  return validate(route);
10881
10881
  `)({params:R})){console.warn(`Validation failed for ${A}, skipping...`);return}}catch{}let k=null,P=!1;if(J.cache){if(k=z.get(A,N.filePath),k)P=!0,X.cachedCount++}if(!k){let m=await rJ(N,R,T,J,Y);if(k=m.html,J.cache)z.set(A,N.filePath,m.dependencies,k)}let h;if(J.trailingSlash)h=J0.join(J.outputDir,A,"index.html");else h=A==="/"?J0.join(J.outputDir,"index.html"):J0.join(J.outputDir,`${A}.html`);if(J.chunkIslands){let{html:m,chunks:c}=gJ(k,{integrity:J.integrityIslands,minify:J.minify});if(c.length>0){let Y0=J0.join(J.outputDir,"_stx","islands");await V0.promises.mkdir(Y0,{recursive:!0});for(let K0 of c){let O0=J0.join(Y0,`${K0.hash}.js`);if(!await Bun.file(O0).exists())await Bun.write(O0,K0.code);if(!Q.has(K0.hash)){Q.add(K0.hash);let B0=Buffer.byteLength(K0.code,"utf8");G+=B0,K[K0.hash]={bytes:B0,file:`/_stx/islands/${K0.hash}.js`}}}if(q[A]=c.map((K0)=>K0.hash),k=m,J.prefetchIslands)k=hJ(k)}}await V0.promises.mkdir(J0.dirname(h),{recursive:!0}),await Bun.write(h,k),L.push({loc:A,lastmod:new Date().toISOString().split("T")[0],priority:A==="/"?1:0.8});let f={route:A,outputPath:h,size:Buffer.byteLength(k,"utf8"),cached:P};if(M!==!1)f.revalidateAt=Date.now()+M*1000;X.pages.push(f),X.successCount++,await J.hooks.onPageEnd?.(A,k)}catch(I){X.failedCount++,X.errors.push({route:A,error:I}),await J.hooks.onError?.(I,A),console.error(`Error generating ${A}:`,I)}}));if(J.cache)await z.save();if(J.generate404){let V=J0.join(J.pagesDir,"404.stx");if(await Bun.file(V).exists()){let w=new Set,N={...Y,debug:!1,cache:!1},A=await W0(await Bun.file(V).text(),{},V,N,w);await Bun.write(J0.join(J.outputDir,"404.html"),A)}else await Bun.write(J0.join(J.outputDir,"404.html"),`<!DOCTYPE html>
@@ -10927,5 +10927,5 @@ Build complete!
10927
10927
  `));return K=K.replace(/<body\b[^>]*>/i,""),K=K.replace(/<\/body\s*>/i,""),K.trim()}function zX($,Z="main"){let Y=$.trim(),J=[],X=Y.match(/<head\b[^>]*>([\s\S]*?)<\/head>/i);if(X){let O=X[1],V=/<style\b[^>]*>[\s\S]*?<\/style>/gi,w;while((w=V.exec(O))!==null)J.push(w[0])}let Q=Z.replace(/^[.#]/,"").toLowerCase(),G=new RegExp(`<${Q}\\b[^>]*>`,"i"),K=Y.match(G);if(!K||K.index===void 0)return M4($);let q=K.index+K[0].length,W=new RegExp(`<${Q}\\b[^>]*>`,"gi"),z=new RegExp(`</${Q}\\s*>`,"gi");W.lastIndex=q,z.lastIndex=q;let U=1,_=-1;while(U>0){let O=W.exec(Y),V=z.exec(Y);if(!V)break;if(O&&O.index<V.index)U++,z.lastIndex=O.index+O[0].length;else if(U--,_=V.index,U>0)W.lastIndex=V.index+V[0].length}if(_===-1)return M4($);let B=Y.slice(q,_).trim(),j=[],H=Y.match(/<body\b[^>]*>/i),L=Y.lastIndexOf("</body>");if(H&&H.index!==void 0&&L!==-1){let V=[[H.index+H[0].length,K.index],[_+`</${Q}>`.length,L]],w=/<script\b[^>]*>[\s\S]*?<\/script>/gi;for(let[N,A]of V){if(N>=A)continue;let R=Y.slice(N,A),T;w.lastIndex=0;while((T=w.exec(R))!==null)j.push(T[0])}}let F=[];if(J.length>0)F.push(J.join(`
10928
10928
  `));if(j.length>0)F.push(j.join(`
10929
10929
  `));return F.push(B),F.join(`
10930
- `)}var s_="stx-page-head:";var U6=b(()=>{qX()});import WX from"path";import{createHash as r_}from"crypto";function a_($={}){let Z=new Set;return{context:new Proxy($,{get(J,X){if(X in J)return J[X];if(typeof X==="string"&&!X.startsWith("__"))Z.add(X);return},has(J,X){if(X in J)return!0;if(typeof X==="string"&&!X.startsWith("__"))Z.add(X);return!1}}),accessedKeys:Z}}async function UX($,Z,Y={}){let J=WX.resolve($),X=await Bun.file(J).text(),Q=r_("sha256").update(X).digest("hex").slice(0,16);d6();let G={};try{G=await h0()}catch{}let K=[],q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,W;while((W=q.exec(X))!==null){let L=W[1];if(/\bserver\b/.test(L))K.push(W[2])}let{context:z}=a_({__filename:J,__dirname:WX.dirname(J)}),U=new Set,_={...K1,...G,...Y,buildMode:"compile",strict:!1},B=await W0(X,z,J,_,U),j=M4(B),H=m6();return{route:Z,sourceFile:$,html:B,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(U),contentHash:Q,streamTemplates:z.__streamTemplates}}var _X=b(()=>{C5();Q1();P4();U6()});import t_ from"fs";import e_ from"path";function BX($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function jX($,Z){let Y=e_.join(Z,"manifest.json");t_.writeFileSync(Y,JSON.stringify($,null,2))}var HX=()=>{};var OX={};o(OX,{buildForProduction:()=>YB});import Z1 from"fs";import D0 from"path";function ZB($,Z){let Y=0,J=0;if(!Z1.existsSync($))return{copied:Y,bytes:J};function X(Q,G){let K=Z1.readdirSync(Q,{withFileTypes:!0});for(let q of K){if($B.has(q.name))continue;let W=D0.join(Q,q.name),z=D0.join(G,q.name);if(q.isDirectory())Z1.mkdirSync(z,{recursive:!0}),X(W,z);else if(q.isFile()){if(Z1.existsSync(z))continue;Z1.copyFileSync(W,z),Y++,J+=Z1.statSync(z).size}}}return X($,Z),{copied:Y,bytes:J}}async function YB($={}){let Z=Date.now(),Y=D0.resolve($.root||process.cwd()),J=D0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await h0()}catch{}let Q=$.componentsDir??X.componentsDir??"components",G=$.partialsDir??X.partialsDir??"partials",K=$.layoutsDir??X.layoutsDir??"layouts",q=$.publicDir??X.publicDir??"public",W=X.app?.head||{},z=X.router?.container||"main";if(Z1.existsSync(J))Z1.rmSync(J,{recursive:!0});let U=[D0.join(J,"public","__stx"),D0.join(J,"public","assets"),D0.join(J,"server","pages"),D0.join(J,"server","fragments")];for(let R of U)Z1.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let _=i5(Y),B=["components","layouts","partials"],j=_.filter((R)=>{return!B.some((T)=>R.pattern.startsWith(`/${T}/`)||R.pattern===`/${T}`)});console.log(`[stx build] Found ${j.length} page routes (${_.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=QX($.debug),L=GX();await Bun.write(D0.join(J,"public","__stx",H.filename),H.content),await Bun.write(D0.join(J,"public","__stx",L.filename),L.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],O=[];for(let R of j)try{let T=await UX(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(T),T.html=T.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,L.filename),T.html=x$(T.html,W,{bodyScripts:[`<script src="/__stx/${L.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(T.html)){let y=T.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(y&&y[1]){let S=y[1];T.html=T.html.replace(" "+S,""),T.html=T.html.replace(/<body([^>]*)>/,`<body$1 ${S}>`)}}T.html=T.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),T.html=await D1(T.html),T.fragment=zX(T.html,z);let I=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),D=D0.join("server","pages",`${I}.compiled.json`),E=D0.join("server","fragments",`${I}.html`);await Bun.write(D0.join(J,D),JSON.stringify(T,null,2)),await Bun.write(D0.join(J,E),T.fragment),O.push({pattern:R.pattern,compiledPath:D,fragmentPath:E,isDynamic:T.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(T){console.error(`[stx build] \u2717 ${R.pattern}:`,T instanceof Error?T.message:T)}let V=D0.resolve(Y,q);if(Z1.existsSync(V)){let{copied:R,bytes:T}=ZB(V,D0.join(J,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(T/1024).toFixed(1)}KB) from ${q}/`)}let w={runtime:H.filename,router:L.filename},N=BX(O,w,J);jX(N,J);let A=Date.now()-Z;return console.log(`
10930
+ `)}var s_="stx-page-head:";var U6=b(()=>{qX()});import WX from"path";import{createHash as r_}from"crypto";function a_($={}){let Z=new Set;return{context:new Proxy($,{get(J,X){if(X in J)return J[X];if(typeof X==="string"&&!X.startsWith("__"))Z.add(X);return},has(J,X){if(X in J)return!0;if(typeof X==="string"&&!X.startsWith("__"))Z.add(X);return!1}}),accessedKeys:Z}}async function UX($,Z,Y={}){let J=WX.resolve($),X=await Bun.file(J).text(),Q=r_("sha256").update(X).digest("hex").slice(0,16);d6();let G={};try{G=await h0()}catch{}let K=[],q=/<script\b([^>]*)>([\s\S]*?)<\/script>/gi,W;while((W=q.exec(X))!==null){let L=W[1];if(/\bserver\b/.test(L))K.push(W[2])}let{context:z}=a_({__filename:J,__dirname:WX.dirname(J)}),U=new Set,_={...K1,...G,...Y,buildMode:"compile",strict:!1},B=await W0(X,z,J,_,U),j=M4(B),H=m6();return{route:Z,sourceFile:$,html:B,fragment:j,placeholders:H,hasServerScripts:K.length>0,serverScriptContent:K,dependencies:Array.from(U),contentHash:Q,streamTemplates:z.__streamTemplates}}var _X=b(()=>{C5();Q1();P4();U6()});import t_ from"fs";import e_ from"path";function BX($,Z,Y){return{version:1,buildTime:new Date().toISOString(),routes:$,assets:Z,outputDir:Y}}function jX($,Z){let Y=e_.join(Z,"manifest.json");t_.writeFileSync(Y,JSON.stringify($,null,2))}var HX=()=>{};var OX={};o(OX,{buildForProduction:()=>YB});import Z1 from"fs";import D0 from"path";function ZB($,Z){let Y=0,J=0;if(!Z1.existsSync($))return{copied:Y,bytes:J};function X(Q,G){let K=Z1.readdirSync(Q,{withFileTypes:!0});for(let q of K){if($B.has(q.name))continue;let W=D0.join(Q,q.name),z=D0.join(G,q.name);if(q.isDirectory())Z1.mkdirSync(z,{recursive:!0}),X(W,z);else if(q.isFile()){if(Z1.existsSync(z))continue;Z1.copyFileSync(W,z),Y++,J+=Z1.statSync(z).size}}}return X($,Z),{copied:Y,bytes:J}}async function YB($={}){let Z=Date.now(),Y=D0.resolve($.root||process.cwd()),J=D0.resolve(Y,$.outputDir||".output");console.log("[stx build] Starting production build...");let X={};try{X=await h0()}catch{}let Q=$.componentsDir??X.componentsDir??"components",G=$.partialsDir??X.partialsDir??"partials",K=$.layoutsDir??X.layoutsDir??"layouts",q=$.publicDir??X.publicDir??"public",W=X.app?.head||{},z=X.router?.container||"main";if(Z1.existsSync(J))Z1.rmSync(J,{recursive:!0});let U=[D0.join(J,"public","__stx"),D0.join(J,"public","assets"),D0.join(J,"server","pages"),D0.join(J,"server","fragments")];for(let R of U)Z1.mkdirSync(R,{recursive:!0});console.log("[stx build] Discovering routes...");let _=i5(Y),B=["components","layouts","partials"],j=_.filter((R)=>{return!B.some((T)=>R.pattern.startsWith(`/${T}/`)||R.pattern===`/${T}`)});console.log(`[stx build] Found ${j.length} page routes (${_.length-j.length} non-page files excluded)`),console.log("[stx build] Generating shared assets...");let H=QX($.debug),L=GX();await Bun.write(D0.join(J,"public","__stx",H.filename),H.content),await Bun.write(D0.join(J,"public","__stx",L.filename),L.content),console.log(`[stx build] Runtime: ${H.filename} (${(H.content.length/1024).toFixed(1)}KB)`),console.log(`[stx build] Router: ${L.filename} (${(L.content.length/1024).toFixed(1)}KB)`),console.log("[stx build] Compiling templates...");let F=[],O=[];for(let R of j)try{let T=await UX(R.filePath,R.pattern,{componentsDir:Q,partialsDir:G,layoutsDir:K,debug:$.debug});if(F.push(T),T.html=T.html.replace(/runtime\.__STX_HASH__\.js/g,H.filename).replace(/router\.__STX_HASH__\.js/g,L.filename),T.html=x$(T.html,W,{bodyScripts:[`<script src="/__stx/${L.filename}"></script>`]}),!/<body[^>]*\bdata-stx=/.test(T.html)){let C=T.html.match(/<(?!body\b)[a-zA-Z][a-zA-Z0-9-]*\b[^>]*?\s(data-stx="[^"]+")[^>]*>/);if(C&&C[1]){let S=C[1];T.html=T.html.replace(" "+S,""),T.html=T.html.replace(/<body([^>]*)>/,`<body$1 ${S}>`)}}T.html=T.html.replace(/<style data-crosswind="generated">[\s\S]*?<\/style>\s*/g,""),T.html=await D1(T.html),T.fragment=zX(T.html,z);let I=R.pattern==="/"?"index":R.pattern.slice(1).replace(/\//g,"-").replace(/[[\]]/g,"_"),D=D0.join("server","pages",`${I}.compiled.json`),E=D0.join("server","fragments",`${I}.html`);await Bun.write(D0.join(J,D),JSON.stringify(T,null,2)),await Bun.write(D0.join(J,E),T.fragment),O.push({pattern:R.pattern,compiledPath:D,fragmentPath:E,isDynamic:T.hasServerScripts,hasParams:R.pattern.includes(":")||R.pattern.includes("[")}),console.log(`[stx build] \u2713 ${R.pattern}`)}catch(T){console.error(`[stx build] \u2717 ${R.pattern}:`,T instanceof Error?T.message:T)}let V=D0.resolve(Y,q);if(Z1.existsSync(V)){let{copied:R,bytes:T}=ZB(V,D0.join(J,"public"));if(R>0)console.log(`[stx build] Copied ${R} public asset${R===1?"":"s"} (${(T/1024).toFixed(1)}KB) from ${q}/`)}let w={runtime:H.filename,router:L.filename},N=BX(O,w,J);jX(N,J);let A=Date.now()-Z;return console.log(`
10931
10931
  [stx build] Done in ${A}ms \u2014 ${F.length} pages compiled`),{pageCount:F.length,assets:w,outputDir:J,duration:A}}var $B;var LX=b(()=>{W6();KX();_X();HX();U6();R5();Q1();$B=new Set([".DS_Store","Thumbs.db","desktop.ini",".gitkeep",".gitignore"])});import JB from"path";async function KA($={}){let Z=performance.now(),Y=$.root||process.cwd(),J=await h0(),X=J.ssr?"ssr":"ssg";console.log(`[stx build] Mode: ${X.toUpperCase()}${J.ssr?" (ssr: true in stx.config.ts)":" (default \u2014 ssr is false)"}`);let Q,G;if(X==="ssg"){let{generateStaticSite:q}=await Promise.resolve().then(() => (JX(),YX));Q=await q({pagesDir:JB.join(J.root||".",J.pagesDir||J.build?.pagesDir||"pages"),publicDir:J.publicDir||J.build?.publicDir||"public",outputDir:J.build?.outputDir||"dist",generate404:J.build?.generate404??!0,minify:J.build?.minify??!0,cleanOutput:J.build?.cleanOutput??!0,...$.ssg})}else{let{buildForProduction:q}=await Promise.resolve().then(() => (LX(),OX));G=await q({outputDir:".output",debug:$.debug,...$.ssr})}let K=Math.round(performance.now()-Z);return{mode:X,ssg:Q,ssr:G,duration:K}}var XB=b(()=>{Q1()});XB();export{KA as buildApp};