"use strict";
/* Socket Lib - Built with rolldown */
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const require_primordials_string = require('../primordials/string.js');
const require_primordials_regexp = require('../primordials/regexp.js');

//#region src/ansi/strip.ts
/**
* @file ANSI escape-code regex factory and stripping helper. Provides
*   `ansiRegex()` for matching CSI/OSC sequences and `stripAnsi()` for removing
*   ANSI formatting from terminal output.
*/
const ANSI_REGEX = /\x1b\[[0-9;]*m/g;
/**
* Create a regular expression for matching ANSI escape codes.
*
* Inlined ansi-regex: https://socket.dev/npm/package/ansi-regexp/overview/6.2.2
* MIT License Copyright (c) Sindre Sorhus
* [sindresorhus@gmail.com](mailto:sindresorhus@gmail.com)
* (https://sindresorhus.com)
*
* @example
*   ;```typescript
*   const regex = ansiRegex()
*   '\u001b[31mHello\u001b[0m'.match(regex) // ['\u001b[31m', '\u001b[0m']
*   ansiRegex({ onlyFirst: true }) // matches only the first code
*   ```
*/
/*@__NO_SIDE_EFFECTS__*/
function ansiRegex(options) {
	const { onlyFirst } = options ?? {};
	return new require_primordials_regexp.RegExpCtor(`(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]`, onlyFirst ? void 0 : "g");
}
/**
* Strip ANSI escape codes from text. Uses the inlined ansi-regex for matching.
*
* @example
*   ;```typescript
*   stripAnsi('\u001b[31mError\u001b[0m') // 'Error'
*   stripAnsi('\u001b[1mBold\u001b[0m') // 'Bold'
*   ```
*/
/*@__NO_SIDE_EFFECTS__*/
function stripAnsi(text) {
	return require_primordials_string.StringPrototypeReplace(text, ANSI_REGEX, "");
}

//#endregion
exports.ansiRegex = ansiRegex;
exports.stripAnsi = stripAnsi;