// @bun
var{defineProperty:B,getOwnPropertyNames:N,getOwnPropertyDescriptor:_}=Object,T=Object.prototype.hasOwnProperty;function A(J){return this[J]}var E=(J)=>{var q=(G??=new WeakMap).get(J),Q;if(q)return q;if(q=B({},"__esModule",{value:!0}),J&&typeof J==="object"||typeof J==="function"){for(var W of N(J))if(!T.call(q,W))B(q,W,{get:A.bind(J,W),enumerable:!(Q=_(J,W))||Q.enumerable})}return G.set(J,q),q},G;var v=(J)=>J;function g(J,q){this[J]=v.bind(null,q)}var f=(J,q)=>{for(var Q in q)B(J,Q,{get:q[Q],enumerable:!0,configurable:!0,set:g.bind(q,Q)})};var z=(J,q)=>()=>(J&&(q=J(J=0)),q);var l=import.meta.require;function c(J){Y={...Y,...J}}function a(){Y={...O}}function p(){return{...Y}}function h(J){let q="",Q=null,W=!1;for(let Z=0;Z<J.length;Z++){let $=J[Z];if(W){W=!1;continue}if($==="\\"&&Q){W=!0;continue}if(Q){if(Q==="`"&&$==="$"&&Z+1<J.length&&J[Z+1]==="{"){let w=1;Z+=2;while(Z<J.length&&w>0){if(J[Z]==="{")w++;else if(J[Z]==="}")w--;if(w>0)q+=J[Z],Z++}continue}if($===Q)Q=null;continue}if($==='"'||$==="'"||$==="`"){Q=$;continue}q+=$}return q}function S(J,q){let Q=/[$A-Z_a-z][$\w]*/g,W;while((W=Q.exec(J))!==null){let Z=W[0],$=J[W.index-1];if(j.has(Z))throw Error(`Potentially unsafe expression (matched /\\b${Z}\\b/; identifier ${Z}): ${q}`);if($==="."&&D.has(Z))throw Error(`Potentially unsafe expression (matched /.${Z}/; property ${Z}): ${q}`)}}function m(J){let q=/\[\s*(['"])(.*?)\1\s*\]/g,Q;while((Q=q.exec(J))!==null){let W=Q[2];if(!D.has(W))continue;let Z=J.slice(0,Q.index).match(/\S(?=\s*$)/)?.[0],$=J.slice(Q.index+Q[0].length).match(/^\s*(\S)/)?.[1];if(!((Z==="{"||Z===",")&&$===":"))throw Error(`Potentially unsafe expression (bracket key ${Q[2]}): ${J}`)}}function L(J){let q=J.trim(),Q=h(q);S(Q,q),m(q);for(let W of P)if(W.test(Q))throw Error(`Potentially unsafe expression (matched /${W.source}/): ${q}`);if(!Y.allowBracketNotation&&b.test(q))throw Error(`Bracket notation with strings not allowed: ${q}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return q}function k(J){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[Q,W]of Object.entries(J)){if(Q.startsWith("__")||P.some((Z)=>Z.test(Q)))continue;if(W&&typeof W==="object"&&!Array.isArray(W))q[Q]=F(W);else q[Q]=W}return q}function F(J,q=0){if(q>=Y.maxSanitizeDepth)return"[Object too deep]";if(J===null||typeof J!=="object")return J;if(Array.isArray(J))return J.map((W)=>F(W,q+1));if(J instanceof Date||J instanceof RegExp||J instanceof Map||J instanceof Set||J instanceof Error)return J;let Q={};for(let[W,Z]of Object.entries(J)){if(W.startsWith("__")||W==="constructor"||W==="prototype")continue;if(Z&&typeof Z==="object")Q[W]=F(Z,q+1);else Q[W]=Z}return Q}function V(J,q){try{let Q=k(q),W=Object.keys(Q),Z=Object.values(Q);return U(J,W)(...Z)}catch{return}}function K(J){try{return L(J),!0}catch{return!1}}function x(J){try{return L(J),null}catch(q){return q instanceof Error?q.message:String(q)}}function r(J,q){try{let Q=V(J,q);return Boolean(Q)}catch{return!1}}function o(J,q){try{let Q=V(J,q);if(Array.isArray(Q))return Q;if(Q&&typeof Q==="object"&&"length"in Q){let W=Q.length;if(typeof W==="number"&&Number.isFinite(W)&&W>=0&&Number.isInteger(W))return Array.from(Q)}return[]}catch{return[]}}function n(J,q){try{let Q=V(J,q);if(Q&&typeof Q==="object"&&!Array.isArray(Q))return Q;return{}}catch{return{}}}function U(J,q){let Q=L(J),W=/^[A-Za-z_$][\w$]*$/,Z=[],$=[];for(let H=0;H<q.length;H++){let X=q[H];if(!W.test(X))continue;if(C.has(X))continue;Z.push(H),$.push(X)}let w=Function(...$,`
    'use strict';
    try {
      return ${Q};
    }
catch (e) {
      if (e instanceof ReferenceError || e instanceof TypeError) {
        return undefined;
      }
      throw e;
    }
  `);if($.length===q.length)return w;return(...H)=>{let X=Array(Z.length);for(let M=0;M<Z.length;M++)X[M]=H[Z[M]];return w(...X)}}function i(J,q){try{if(typeof J!=="string")return;if(J.length>I)throw Error(`safeEvaluateCode: input exceeds ${I} chars`);for(let w of P)if(w.test(J))throw Error("Potentially unsafe code detected");let Q=k(q),W=Object.keys(Q),Z=Object.values(Q);return Function(...W,`
      'use strict';
      ${J}
    `)(...Z)}catch{return}}function y(J){let q=J.trim(),Q=[/\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 W of Q)if(W.test(q))return!1;return!0}function s(J,q,Q,W,Z=1000){if(!y(q))throw Error(`Unsafe expression in @${J}: ${q}`);let $=Q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,H)=>{return`\${${H}}`});if(J==="for")return Function(...W,`
      'use strict';
      let result = '';
      for (${q}) {
        result += \`${$}\`;
      }
      return result;
    // eslint-disable-next-line pickier/no-unused-vars
    `);else return Function(...W,`
      'use strict';
      let result = '';
      let __safeCounter = 0;
      const __maxIterations = ${Z};
      while (${q} && __safeCounter < __maxIterations) {
        __safeCounter++;
        result += \`${$}\`;
      }
      // 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 O,Y,P,j,D,b,C,I=65536;var R=z(()=>{O={maxSanitizeDepth:10,allowBracketNotation:!1},Y={...O};P=[/\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/],j=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"]),D=new Set(["__proto__","constructor","prototype"]),b=/[\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"])});function qq(J,q){try{let Q=J.trim();if(K(Q))return U(Q,Object.keys(q))(...Object.values(q));else return V(Q,q)}catch{return!1}}var u=z(()=>{R()});u();export{qq as evaluateAuthExpression};
