function s(t, o) {
  const e = Array.isArray(o) ? o : [o], a = e[0], i = e[1] ?? l(e[0]), f = t.trim(), r = f, p = `${a}${r}${i}`;
  if (r.length === t.length)
    return p;
  const g = a + r + i;
  return t.replace(f, g);
}
const l = (t) => t.split("").reverse().join(""), m = (t, o) => (o.strikethrough && o.bold && o.italic ? t = s(t, "~~***") : o.bold && o.italic ? t = s(t, "***") : (o.bold && (t = s(t, "**")), o.italic && (t = s(t, "_")), o.strikethrough && (t = s(t, "~~")), o.code && (t = s(t, "`"))), t = b(t, o), t), b = (t, o) => {
  const e = `
`;
  return (o.strikethrough || o.bold || o.italic) && new RegExp(e, "g").test(t) && (t = t.replaceAll(e, `\\
`)), t;
};
export {
  m as applyFormattingToLeafNode,
  s as retainWhitespaceAndFormat
};
//# sourceMappingURL=applyFormattingToLeafNode.es.js.map
