"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 format_exports = {};
__export(format_exports, {
  applyLinePrefix: () => applyLinePrefix,
  centerText: () => centerText,
  fromCharCode: () => fromCharCode,
  indentString: () => indentString,
  repeatString: () => repeatString
});
module.exports = __toCommonJS(format_exports);
var import_strip = require("../ansi/strip");
var import_math = require("../primordials/math");
var import_string = require("../primordials/string");
const fromCharCode = String.fromCharCode;
// @__NO_SIDE_EFFECTS__
function applyLinePrefix(str, options) {
  const { prefix = "" } = {
    __proto__: null,
    ...options
  };
  return prefix.length ? `${prefix}${(0, import_string.StringPrototypeIncludes)(str, "\n") ? str.replace(/\n/g, `
${prefix}`) : str}` : str;
}
// @__NO_SIDE_EFFECTS__
function centerText(text, width) {
  const textLength = (0, import_strip.stripAnsi)(text).length;
  if (textLength >= width) {
    return text;
  }
  const padding = width - textLength;
  const leftPad = (0, import_math.MathFloor)(padding / 2);
  const rightPad = padding - leftPad;
  return " ".repeat(leftPad) + text + " ".repeat(rightPad);
}
// @__NO_SIDE_EFFECTS__
function indentString(str, options) {
  const { count = 1 } = { __proto__: null, ...options };
  return str.replace(/^(?!\s*$)/gm, " ".repeat(count));
}
// @__NO_SIDE_EFFECTS__
function repeatString(str, count) {
  if (count <= 0) {
    return "";
  }
  return (0, import_string.StringPrototypeRepeat)(str, count);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  applyLinePrefix,
  centerText,
  fromCharCode,
  indentString,
  repeatString
});
