"use strict";
/* Socket Lib - Built with esbuild */
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var metrics_exports = {};
__export(metrics_exports, {
  clearPerformanceMetrics: () => clearPerformanceMetrics,
  getPerformanceMetrics: () => getPerformanceMetrics,
  getPerformanceSummary: () => getPerformanceSummary
});
module.exports = __toCommonJS(metrics_exports);
var import_output = require("../debug/output");
var import_math = require("../primordials/math");
var import_object = require("../primordials/object");
var import_internal = require("./_internal");
function clearPerformanceMetrics() {
  import_internal.performanceMetrics.length = 0;
  (0, import_output.debugLog)("[perf] Cleared performance metrics");
}
function getPerformanceMetrics() {
  return [...import_internal.performanceMetrics];
}
function getPerformanceSummary() {
  const summary = { __proto__: null };
  for (const metric of import_internal.performanceMetrics) {
    const { duration, operation } = metric;
    if (!summary[operation]) {
      summary[operation] = {
        count: 0,
        total: 0,
        min: Number.POSITIVE_INFINITY,
        max: Number.NEGATIVE_INFINITY
      };
    }
    const stats = summary[operation];
    stats.count++;
    stats.total += duration;
    stats.min = (0, import_math.MathMin)(stats.min, duration);
    stats.max = (0, import_math.MathMax)(stats.max, duration);
  }
  const result = { __proto__: null };
  for (const { 0: operation, 1: stats } of (0, import_object.ObjectEntries)(summary)) {
    result[operation] = {
      count: stats.count,
      total: (0, import_math.MathRound)(stats.total * 100) / 100,
      avg: (0, import_math.MathRound)(stats.total / stats.count * 100) / 100,
      min: (0, import_math.MathRound)(stats.min * 100) / 100,
      max: (0, import_math.MathRound)(stats.max * 100) / 100
    };
  }
  return result;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  clearPerformanceMetrics,
  getPerformanceMetrics,
  getPerformanceSummary
});
