import c from "../../../../escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js";
import d from "../../../../@sindresorhus_transliterate@1.6.0/node_modules/@sindresorhus/transliterate/index.js";
import s from "./overridable-replacements.js";
const o = (e) => e.replace(/([A-Z]{2,})(\d+)/g, "$1 $2").replace(/([a-z\d]+)([A-Z]{2,})/g, "$1 $2").replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g, "$1 $2"), $ = (e, r) => {
  const a = c(r);
  return e.replace(new RegExp(`${a}{2,}`, "g"), r).replace(new RegExp(`^${a}|${a}$`, "g"), "");
}, f = (e) => {
  let r = "a-z\\d";
  if (r += e.lowercase ? "" : "A-Z", e.preserveCharacters.length > 0)
    for (const a of e.preserveCharacters) {
      if (a === e.separator)
        throw new Error(`The separator character \`${e.separator}\` cannot be included in preserved characters: ${e.preserveCharacters}`);
      r += c(a);
    }
  return new RegExp(`[^${r}]+`, "g");
};
function n(e, r) {
  if (typeof e != "string")
    throw new TypeError(`Expected a string, got \`${typeof e}\``);
  r = {
    separator: "-",
    lowercase: !0,
    decamelize: !0,
    customReplacements: [],
    preserveLeadingUnderscore: !1,
    preserveTrailingDash: !1,
    preserveCharacters: [],
    ...r
  };
  const a = r.preserveLeadingUnderscore && e.startsWith("_"), t = r.preserveTrailingDash && e.endsWith("-"), l = new Map([
    ...s,
    ...r.customReplacements
  ]);
  e = d(e, { customReplacements: l }), r.decamelize && (e = o(e));
  const p = f(r);
  return r.lowercase && (e = e.toLowerCase()), e = e.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g, "$1$2$3"), e = e.replace(p, r.separator), e = e.replace(/\\/g, ""), r.separator && (e = $(e, r.separator)), a && (e = `_${e}`), t && (e = `${e}-`), e;
}
export {
  n as default
};
