"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 generic_exports = {};
__export(generic_exports, {
  genericFilter: () => genericFilter
});
module.exports = __toCommonJS(generic_exports);
const genericFilter = {
  name: "generic",
  matches(_command) {
    return true;
  },
  filter(_command, rawOutput, level) {
    const lines = rawOutput.split("\n");
    if (lines.length <= 15) {
      return { output: rawOutput, strategy: "generic:short" };
    }
    let filtered = lines.filter((l) => {
      const trimmed = l.trim();
      if (!trimmed) return false;
      if (/^[▓░█▒■□●○◐◑◒◓⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏]/.test(trimmed)) return false;
      if (/^\d+%\s*[|█▓░]/.test(trimmed)) return false;
      if (/^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⣾⣽⣻⢿⡿⣟⣯⣷]/.test(trimmed)) return false;
      return true;
    });
    const deduped = [];
    let lastPattern = "";
    let repeatCount = 0;
    for (const line of filtered) {
      const pattern = normalizeForComparison(line);
      if (pattern === lastPattern) {
        repeatCount++;
      } else {
        if (repeatCount > 2) {
          deduped.push(`  \u2026repeated ${repeatCount} times`);
        } else if (repeatCount === 2) {
          deduped.push(filtered[deduped.length] || "");
        }
        deduped.push(line);
        lastPattern = pattern;
        repeatCount = 1;
      }
    }
    if (repeatCount > 2) {
      deduped.push(`  \u2026repeated ${repeatCount} times`);
    }
    filtered = deduped;
    const maxLines = level === "ultra" ? 30 : level === "aggressive" ? 60 : 100;
    if (filtered.length <= maxLines) {
      return { output: filtered.join("\n"), strategy: "generic:deduped" };
    }
    const headSize = Math.floor(maxLines * 0.6);
    const tailSize = maxLines - headSize;
    const head = filtered.slice(0, headSize);
    const tail = filtered.slice(-tailSize);
    const omitted = filtered.length - headSize - tailSize;
    const output = [...head, `
\u2026(${omitted} lines omitted)
`, ...tail].join("\n");
    return { output, strategy: "generic:truncated" };
  }
};
function normalizeForComparison(line) {
  return line.replace(/\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}[.\d]*Z?/g, "<ts>").replace(/\b\d{10,13}\b/g, "<ts>").replace(/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi, "<uuid>").replace(/\b[0-9a-f]{7,40}\b/g, "<hash>").replace(/(?<![a-zA-Z_])\d+(?![a-zA-Z_])/g, "<n>");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  genericFilter
});
//# sourceMappingURL=generic.js.map
