"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 strip_exports = {};
__export(strip_exports, {
  ansiRegex: () => ansiRegex,
  stripAnsi: () => stripAnsi
});
module.exports = __toCommonJS(strip_exports);
var import_regexp = require("../primordials/regexp");
var import_string = require("../primordials/string");
const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
// @__NO_SIDE_EFFECTS__
function ansiRegex(options) {
  const { onlyFirst } = options ?? {};
  const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
  const osc = `(?:\\u001B\\][\\s\\S]*?${ST})`;
  const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
  const pattern = `${osc}|${csi}`;
  return new import_regexp.RegExpCtor(pattern, onlyFirst ? void 0 : "g");
}
// @__NO_SIDE_EFFECTS__
function stripAnsi(text) {
  return (0, import_string.StringPrototypeReplace)(text, ANSI_REGEX, "");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ansiRegex,
  stripAnsi
});
