// @bun
var{defineProperty:M,getOwnPropertyNames:R,getOwnPropertyDescriptor:_}=Object,T=Object.prototype.hasOwnProperty;function N(q){return this[q]}var f=(q)=>{var Q=(U??=new WeakMap).get(q),W;if(Q)return Q;if(Q=M({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var Z of R(q))if(!T.call(Q,Z))M(Q,Z,{get:N.bind(q,Z),enumerable:!(W=_(q,Z))||W.enumerable})}return U.set(q,Q),Q},U;var A=(q)=>q;function g(q,Q){this[q]=A.bind(null,Q)}var d=(q,Q)=>{for(var W in Q)M(q,W,{get:Q[W],enumerable:!0,configurable:!0,set:g.bind(Q,W)})};var G=(q,Q)=>()=>(q&&(Q=q(q=0)),Q);var l=import.meta.require;function x(q){V={...V,...q}}function p(){V={...I}}function a(){return{...V}}function j(q){let Q="",W=null,Z=!1;for(let $=0;$<q.length;$++){let w=q[$];if(Z){Z=!1;continue}if(w==="\\"&&W){Z=!0;continue}if(W){if(W==="`"&&w==="$"&&$+1<q.length&&q[$+1]==="{"){let H=1;$+=2;while($<q.length&&H>0){if(q[$]==="{")H++;else if(q[$]==="}")H--;if(H>0)Q+=q[$],$++}continue}if(w===W)W=null;continue}if(w==='"'||w==="'"||w==="`"){W=w;continue}Q+=w}return Q}function S(q,Q){let W=/[$A-Z_a-z][$\w]*/g,Z;while((Z=W.exec(q))!==null){let $=Z[0],w=q[Z.index-1];if(v.has($))throw Error(`Potentially unsafe expression (matched /\\b${$}\\b/; identifier ${$}): ${Q}`);if(w==="."&&O.has($))throw Error(`Potentially unsafe expression (matched /.${$}/; property ${$}): ${Q}`)}}function b(q){let Q=/\[\s*(['"])(.*?)\1\s*\]/g,W;while((W=Q.exec(q))!==null){let Z=W[2];if(!O.has(Z))continue;let $=q.slice(0,W.index).match(/\S(?=\s*$)/)?.[0],w=q.slice(W.index+W[0].length).match(/^\s*(\S)/)?.[1];if(!(($==="{"||$===",")&&w===":"))throw Error(`Potentially unsafe expression (bracket key ${W[2]}): ${q}`)}}function L(q){let Q=q.trim(),W=j(Q);S(W,Q),b(Q);for(let Z of B)if(Z.test(W))throw Error(`Potentially unsafe expression (matched /${Z.source}/): ${Q}`);if(!V.allowBracketNotation&&h.test(Q))throw Error(`Bracket notation with strings not allowed: ${Q}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return Q}function D(q){let Q={};Q.Math=Math,Q.JSON=JSON,Q.Date=Date,Q.String=String,Q.Number=Number,Q.Boolean=Boolean,Q.Array=Array,Q.parseInt=Number.parseInt,Q.parseFloat=Number.parseFloat,Q.isNaN=Number.isNaN,Q.isFinite=Number.isFinite,Q.encodeURIComponent=encodeURIComponent,Q.decodeURIComponent=decodeURIComponent;for(let[W,Z]of Object.entries(q)){if(W.startsWith("__")||B.some(($)=>$.test(W)))continue;if(Z&&typeof Z==="object"&&!Array.isArray(Z))Q[W]=F(Z);else Q[W]=Z}return Q}function F(q,Q=0){if(Q>=V.maxSanitizeDepth)return"[Object too deep]";if(q===null||typeof q!=="object")return q;if(Array.isArray(q))return q.map((Z)=>F(Z,Q+1));if(q instanceof Date||q instanceof RegExp||q instanceof Map||q instanceof Set||q instanceof Error)return q;let W={};for(let[Z,$]of Object.entries(q)){if(Z.startsWith("__")||Z==="constructor"||Z==="prototype")continue;if($&&typeof $==="object")W[Z]=F($,Q+1);else W[Z]=$}return W}function P(q,Q){try{let W=D(Q),Z=Object.keys(W),$=Object.values(W);return y(q,Z)(...$)}catch{return}}function r(q){try{return L(q),!0}catch{return!1}}function n(q){try{return L(q),null}catch(Q){return Q instanceof Error?Q.message:String(Q)}}function o(q,Q){try{let W=P(q,Q);return Boolean(W)}catch{return!1}}function i(q,Q){try{let W=P(q,Q);if(Array.isArray(W))return W;if(W&&typeof W==="object"&&"length"in W){let Z=W.length;if(typeof Z==="number"&&Number.isFinite(Z)&&Z>=0&&Number.isInteger(Z))return Array.from(W)}return[]}catch{return[]}}function k(q,Q){try{let W=P(q,Q);if(W&&typeof W==="object"&&!Array.isArray(W))return W;return{}}catch{return{}}}function y(q,Q){let W=L(q),Z=/^[A-Za-z_$][\w$]*$/,$=[],w=[];for(let X=0;X<Q.length;X++){let Y=Q[X];if(!Z.test(Y))continue;if(C.has(Y))continue;$.push(X),w.push(Y)}let H=Function(...w,`
    'use strict';
    try {
      return ${W};
    }
catch (e) {
      if (e instanceof ReferenceError || e instanceof TypeError) {
        return undefined;
      }
      throw e;
    }
  `);if(w.length===Q.length)return H;return(...X)=>{let Y=Array($.length);for(let J=0;J<$.length;J++)Y[J]=X[$[J]];return H(...Y)}}function s(q,Q){try{if(typeof q!=="string")return;if(q.length>z)throw Error(`safeEvaluateCode: input exceeds ${z} chars`);for(let H of B)if(H.test(q))throw Error("Potentially unsafe code detected");let W=D(Q),Z=Object.keys(W),$=Object.values(W);return Function(...Z,`
      'use strict';
      ${q}
    `)(...$)}catch{return}}function m(q){let Q=q.trim(),W=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let Z of W)if(Z.test(Q))return!1;return!0}function t(q,Q,W,Z,$=1000){if(!m(Q))throw Error(`Unsafe expression in @${q}: ${Q}`);let w=W.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(H,X)=>{return`\${${X}}`});if(q==="for")return Function(...Z,`
      'use strict';
      let result = '';
      for (${Q}) {
        result += \`${w}\`;
      }
      return result;
    // eslint-disable-next-line pickier/no-unused-vars
    `);else return Function(...Z,`
      'use strict';
      let result = '';
      let __safeCounter = 0;
      const __maxIterations = ${$};
      while (${Q} && __safeCounter < __maxIterations) {
        __safeCounter++;
        result += \`${w}\`;
      }
      // Surface the truncation both inline (for end users) and via
      // console.warn (for developers running \`stx dev\`). A silent cut-off
      // made pages render half a list with no breadcrumb.
      if (__safeCounter >= __maxIterations) {
        result += '<!-- [Loop Error]: Maximum iterations exceeded -->';
        if (typeof console !== 'undefined' && typeof console.warn === 'function') {
          console.warn('[stx] @while loop hit max iterations (' + __maxIterations + '); template output was truncated. Raise via createSafeForLoop(..., maxIterations) if intentional.');
        }
      }
      return result;
    // eslint-disable-next-line pickier/no-unused-vars
    `)}var I,V,B,v,O,h,C,z=65536;var K=G(()=>{I={maxSanitizeDepth:10,allowBracketNotation:!1},V={...I};B=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],v=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),O=new Set(["__proto__","constructor","prototype"]),h=/[\w)\]]\s*\[\s*['"]/;C=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});import{defineRoute as wq,defineRoutes as Hq,resetRoutes as Xq,route as Yq,setAppUrl as Vq}from"stx-router";import{route as E}from"stx-router";function Wq(q){return q.replace(/@route\(\s*(['"])([^'"]+)\1(?:\s*,\s*(\{[^}]+\}))?\s*(?:,\s*(true|false)\s*)?\)/g,(Q,W,Z,$,w)=>{try{let H=$?k($,{}):{};return E(Z,H,w==="true")}catch(H){return console.error(`Error processing @route directive: ${H}`),"#route-error"}})}var u=G(()=>{K()});u();export{Vq as setAppUrl,Yq as route,Xq as resetRoutes,Wq as processRouteDirectives,Hq as defineRoutes,wq as defineRoute};
