"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 transform_exports = {};
__export(transform_exports, {
  stripBom: () => stripBom,
  toKebabCase: () => toKebabCase,
  trimNewlines: () => trimNewlines
});
module.exports = __toCommonJS(transform_exports);
var import_string = require("../primordials/string");
// @__NO_SIDE_EFFECTS__
function stripBom(str) {
  return str.length > 0 && (0, import_string.StringPrototypeCharCodeAt)(str, 0) === 65279 ? (0, import_string.StringPrototypeSlice)(str, 1) : str;
}
// @__NO_SIDE_EFFECTS__
function toKebabCase(str) {
  if (!str.length) {
    return str;
  }
  return (0, import_string.StringPrototypeReplace)(str, /([a-z]+[0-9]*)([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
}
// @__NO_SIDE_EFFECTS__
function trimNewlines(str) {
  const { length } = str;
  if (length === 0) {
    return str;
  }
  const first = (0, import_string.StringPrototypeCharCodeAt)(str, 0);
  const noFirstNewline = first !== 13 && first !== 10;
  if (length === 1) {
    return noFirstNewline ? str : "";
  }
  const last = (0, import_string.StringPrototypeCharCodeAt)(str, length - 1);
  const noLastNewline = last !== 13 && last !== 10;
  if (noFirstNewline && noLastNewline) {
    return str;
  }
  let start = 0;
  let end = length;
  while (start < end) {
    const code = (0, import_string.StringPrototypeCharCodeAt)(str, start);
    if (code !== 13 && code !== 10) {
      break;
    }
    start += 1;
  }
  while (end > start) {
    const code = (0, import_string.StringPrototypeCharCodeAt)(str, end - 1);
    if (code !== 13 && code !== 10) {
      break;
    }
    end -= 1;
  }
  return start === 0 && end === length ? str : (0, import_string.StringPrototypeSlice)(str, start, end);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  stripBom,
  toKebabCase,
  trimNewlines
});
