// @bun
var{defineProperty:Z,getOwnPropertyNames:z,getOwnPropertyDescriptor:G}=Object,H=Object.prototype.hasOwnProperty;function A(j){return this[j]}var E=(j)=>{var D=(W??=new WeakMap).get(j),F;if(D)return D;if(D=Z({},"__esModule",{value:!0}),j&&typeof j==="object"||typeof j==="function"){for(var J of z(j))if(!H.call(D,J))Z(D,J,{get:A.bind(j,J),enumerable:!(F=G(j,J))||F.enumerable})}return W.set(j,D),D},W;var X=(j)=>j;function M(j,D){this[j]=X.bind(null,D)}var k=(j,D)=>{for(var F in D)Z(j,F,{get:D[F],enumerable:!0,configurable:!0,set:M.bind(D,F)})};var P=(j,D)=>()=>(j&&(D=j(j=0)),D);var p=import.meta.require;class R{cache=new Map;maxSize;constructor(j=100){this.maxSize=j}get(j){if(!this.cache.has(j))return;let D=this.cache.get(j);return this.cache.delete(j),this.cache.set(j,D),D}set(j,D){if(this.cache.has(j))this.cache.delete(j);else if(this.cache.size>=this.maxSize){let F=this.cache.keys().next().value;if(F!==void 0)this.cache.delete(F)}this.cache.set(j,D)}has(j){return this.cache.has(j)}delete(j){return this.cache.delete(j)}clear(){this.cache.clear()}get size(){return this.cache.size}keys(){return this.cache.keys()}values(){return this.cache.values()}}function _(j,D){if(D?.includes("g"))return new RegExp(j,D);let F=`${j}:${D||""}`;if(!U.has(F)){if(U.size>=S){let J=U.keys().next().value;if(J)U.delete(J)}U.set(F,new RegExp(j,D))}return U.get(F)}function h(){U.clear()}class v{cache=new Map;maxSize;ttl;constructor(j=1000,D=300000){this.maxSize=j,this.ttl=D}get(j){let D=this.cache.get(j);if(!D)return null;if(Date.now()-D.timestamp>this.ttl)return this.cache.delete(j),null;return D.result}set(j,D,F=new Set){if(this.cache.size>=this.maxSize){let J=this.cache.keys().next().value;if(J)this.cache.delete(J)}this.cache.set(j,{result:D,timestamp:Date.now(),dependencies:F})}invalidateDependency(j){let D=0;for(let[F,J]of this.cache.entries())if(J.dependencies.has(j))this.cache.delete(F),D++;return D}clear(){this.cache.clear()}getStats(){return{size:this.cache.size,maxSize:this.maxSize}}}function y(j,D){let F;return(...J)=>{if(F)clearTimeout(F);F=setTimeout(()=>{j(...J)},D)}}function f(j,D){let F=0,J;return(...N)=>{let Q=Date.now();if(Q-F>=D)F=Q,J=j(...N);return J}}function b(j,D=100){let F=new Map;return(...J)=>{let N;try{N=JSON.stringify(J)}catch{return j(...J)}if(F.has(N))return F.get(N);if(F.size>=D){let O=F.keys().next().value;if(O)F.delete(O)}let Q=j(...J);return F.set(N,Q),Q}}function g(j,D,F,J){if(typeof D==="string"){let N=_(D,J);if(typeof F==="string"&&J?.includes("i")){let Q=F;return j.replace(N,(O)=>{if(O===O.toUpperCase()&&O!==O.toLowerCase())return Q.toUpperCase();else if(O[0]===O[0].toUpperCase()&&O[0]!==O[0].toLowerCase())return Q[0].toUpperCase()+Q.slice(1).toLowerCase();else return Q.toLowerCase()})}return j.replace(N,F)}return j.replace(D,F)}class w{pool=[];maxPoolSize=10;fnCache=new Map;fnCacheMaxSize=200;getEvaluator(j){let D=Array.from(new Set(j)),F=D.sort().join(","),J=this.pool.find((T)=>T.context.join(",")===F);if(J)return J.func;let N=this.fnCache,Q=this.fnCacheMaxSize,O=(...T)=>{return(Y)=>{try{let q=`${F}:${Y}`,$=N.get(q);if(!$){if(N.size>=Q){let L=N.keys().next().value;if(L)N.delete(L)}$=Function(...D,`
              'use strict';
              try {
                return ${Y};
              }
catch (e) {
                if (e instanceof ReferenceError || e instanceof TypeError) {
                  return undefined;
                }
                throw e;
              }
            `),N.set(q,$)}return $(...T)}catch{return}}};if(this.pool.length<this.maxPoolSize)this.pool.push({func:O,context:D.slice()});return O}clear(){this.pool.length=0,this.fnCache.clear()}}class I{metrics=new Map;budgets=new Map;violations=[];maxViolations=100;violationHandlers=[];enabled=!0;setEnabled(j){this.enabled=j}isEnabled(){return this.enabled}setBudget(j,D){this.budgets.set(j,{warnThreshold:0.8,action:"warn",...D})}setBudgets(j){for(let[D,F]of Object.entries(j))this.setBudget(D,F)}removeBudget(j){this.budgets.delete(j)}getBudgets(){let j={};for(let[D,F]of this.budgets.entries())j[D]=F;return j}onViolation(j){this.violationHandlers.push(j)}offViolation(j){let D=this.violationHandlers.indexOf(j);if(D!==-1)this.violationHandlers.splice(D,1)}time(j,D){if(!this.enabled)return D();let F=performance.now(),J=D(),N=performance.now()-F;return this.recordTime(j,N),this.checkBudget(j,N),J}async timeAsync(j,D){if(!this.enabled)return D();let F=performance.now(),J=await D(),N=performance.now()-F;return this.recordTime(j,N),this.checkBudget(j,N),J}checkBudget(j,D){let F=this.budgets.get(j);if(!F)return;let J=D/F.maxTime*100,N=F.warnThreshold!==void 0?D>=F.maxTime*F.warnThreshold&&D<F.maxTime:!1,Q=D>=F.maxTime;if(!N&&!Q)return;let O={label:j,actualTime:D,budgetTime:F.maxTime,exceedancePercent:J,timestamp:new Date,isWarning:N};this.violations.push(O);while(this.violations.length>this.maxViolations)this.violations.shift();for(let Y of this.violationHandlers)try{Y(O)}catch{}let T=N?`[Performance Warning] "${j}" took ${D.toFixed(2)}ms (${J.toFixed(1)}% of ${F.maxTime}ms budget)`:`[Performance Budget Exceeded] "${j}" took ${D.toFixed(2)}ms (exceeded ${F.maxTime}ms budget by ${(J-100).toFixed(1)}%)`;switch(F.action){case"log":console.log(T);break;case"warn":console.warn(T);break;case"error":console.error(T);break;case"throw":if(Q)throw Error(T);else console.warn(T);break}}recordTime(j,D){let F=this.metrics.get(j);if(F)F.count++,F.totalTime+=D,F.maxTime=Math.max(F.maxTime,D),F.minTime=Math.min(F.minTime,D);else this.metrics.set(j,{count:1,totalTime:D,maxTime:D,minTime:D})}getStats(j){if(j){let F=this.metrics.get(j);if(!F)return{};let J=this.budgets.get(j);return{count:F.count,avgTime:F.totalTime/F.count,totalTime:F.totalTime,maxTime:F.maxTime,minTime:F.minTime,budget:J?.maxTime,budgetUtilization:J?F.totalTime/F.count/J.maxTime*100:void 0}}let D={};for(let[F,J]of this.metrics.entries()){let N=this.budgets.get(F);D[F]={count:J.count,avgTime:J.totalTime/J.count,totalTime:J.totalTime,maxTime:J.maxTime,minTime:J.minTime,budget:N?.maxTime,budgetUtilization:N?J.totalTime/J.count/N.maxTime*100:void 0}}return D}getViolations(j){if(j)return this.violations.filter((D)=>D.label===j);return[...this.violations]}getViolationStats(){let j={},D=0,F=0;for(let J of this.violations)if(j[J.label]=(j[J.label]||0)+1,J.isWarning)D++;else F++;return{total:this.violations.length,byLabel:j,warnings:D,errors:F}}clear(){this.metrics.clear()}clearViolations(){this.violations.length=0}clearBudgets(){this.budgets.clear()}reset(){this.clear(),this.clearViolations(),this.clearBudgets(),this.violationHandlers.length=0}}function V(){if(!B)B=new I;return B}function s(j=V()){j.setBudgets(K)}function u(){B=null}var U,S=500,m,K,B=null,d;var C=P(()=>{U=new Map;m=new w;K={processDirectives:{maxTime:500,warnThreshold:0.8,action:"warn"},processTemplate:{maxTime:200,warnThreshold:0.8,action:"warn"},processIncludes:{maxTime:100,warnThreshold:0.8,action:"warn"},processLoops:{maxTime:50,warnThreshold:0.8,action:"warn"},processConditionals:{maxTime:50,warnThreshold:0.8,action:"warn"},processExpressions:{maxTime:100,warnThreshold:0.8,action:"warn"},renderComponent:{maxTime:150,warnThreshold:0.8,action:"warn"},buildWebComponents:{maxTime:1000,warnThreshold:0.8,action:"warn"}};d=new Proxy({},{get(j,D){return V()[D]}})});C();export{f as throttle,u as resetPerformanceMonitor,d as performanceMonitor,g as optimizedReplace,b as memoize,V as getPerformanceMonitor,_ as getCachedRegex,m as expressionEvaluatorPool,K as defaultPerformanceBudgets,y as debounce,h as clearRegexCache,s as applyDefaultBudgets,v as TemplateCache,I as PerformanceMonitor,R as LRUCache};
