"use strict";(self["webpackChunkaida"]=self["webpackChunkaida"]||[]).push([[1782],{91782:function(t,e,o){o.r(e),o.d(e,{PerformanceManager:function(){return s}});class s{constructor(){this.stats={totalExecutions:0,totalUndos:0,totalRedos:0,totalExecutionTime:0,totalUndoTime:0,totalRedoTime:0,commandStats:new Map,recentOperations:[]},this.maxRecentOperations=100}recordExecution(t,e){this.stats.totalExecutions++,this.stats.totalExecutionTime+=e,this._updateCommandStats(t,"executions",e),this._addRecentOperation("execute",t,e)}recordUndo(t,e){this.stats.totalUndos++,this.stats.totalUndoTime+=e,this._updateCommandStats(t,"undos",e),this._addRecentOperation("undo",t,e)}recordRedo(t,e){this.stats.totalRedos++,this.stats.totalRedoTime+=e,this._updateCommandStats(t,"redos",e),this._addRecentOperation("redo",t,e)}getStats(){const t=this.stats.totalExecutions>0?this.stats.totalExecutionTime/this.stats.totalExecutions:0,e=this.stats.totalUndos>0?this.stats.totalUndoTime/this.stats.totalUndos:0,o=this.stats.totalRedos>0?this.stats.totalRedoTime/this.stats.totalRedos:0;return{overview:{totalExecutions:this.stats.totalExecutions,totalUndos:this.stats.totalUndos,totalRedos:this.stats.totalRedos,avgExecutionTime:Number(t.toFixed(2)),avgUndoTime:Number(e.toFixed(2)),avgRedoTime:Number(o.toFixed(2))},commandBreakdown:Array.from(this.stats.commandStats.entries()).map((([t,e])=>({commandName:t,executions:e.executions,undos:e.undos,redos:e.redos,avgExecutionTime:e.executions>0?Number((e.totalExecutionTime/e.executions).toFixed(2)):0,avgUndoTime:e.undos>0?Number((e.totalUndoTime/e.undos).toFixed(2)):0,avgRedoTime:e.redos>0?Number((e.totalRedoTime/e.redos).toFixed(2)):0}))),recentOperations:this.stats.recentOperations.slice(-20)}}getSlowCommandsReport(t=100){const e=[];for(const[o,s]of this.stats.commandStats.entries()){const a=s.executions>0?s.totalExecutionTime/s.executions:0,i=s.undos>0?s.totalUndoTime/s.undos:0;(a>t||i>t)&&e.push({commandName:o,avgExecutionTime:Number(a.toFixed(2)),avgUndoTime:Number(i.toFixed(2)),executions:s.executions,undos:s.undos})}return e.sort(((t,e)=>Math.max(e.avgExecutionTime,e.avgUndoTime)-Math.max(t.avgExecutionTime,t.avgUndoTime)))}reset(){this.stats={totalExecutions:0,totalUndos:0,totalRedos:0,totalExecutionTime:0,totalUndoTime:0,totalRedoTime:0,commandStats:new Map,recentOperations:[]}}_updateCommandStats(t,e,o){this.stats.commandStats.has(t)||this.stats.commandStats.set(t,{executions:0,undos:0,redos:0,totalExecutionTime:0,totalUndoTime:0,totalRedoTime:0});const s=this.stats.commandStats.get(t);"executions"===e?(s.executions++,s.totalExecutionTime+=o):"undos"===e?(s.undos++,s.totalUndoTime+=o):"redos"===e&&(s.redos++,s.totalRedoTime+=o)}_addRecentOperation(t,e,o){this.stats.recentOperations.push({type:t,commandName:e,duration:Number(o.toFixed(2)),timestamp:Date.now()}),this.stats.recentOperations.length>this.maxRecentOperations&&this.stats.recentOperations.shift()}}}}]);