import { Options as u, tokenize as c } from "../../linkifyjs/dist/linkify.js";
function l(e) {
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
}
function f(e) {
  return e.replace(/"/g, "&quot;");
}
function s(e) {
  const t = [];
  for (const n in e) {
    let r = e[n] + "";
    t.push(`${n}="${f(r)}"`);
  }
  return t.join(" ");
}
function p({
  tagName: e,
  attributes: t,
  content: n
}) {
  return `<${e} ${s(t)}>${l(n)}</${e}>`;
}
function a(e, t = {}) {
  t = new u(t, p);
  const n = c(e), r = [];
  for (let o = 0; o < n.length; o++) {
    const i = n[o];
    i.t === "nl" && t.get("nl2br") ? r.push(`<br>
`) : !i.isLink || !t.check(i) ? r.push(l(i.toString())) : r.push(t.render(i));
  }
  return r.join("");
}
String.prototype.linkify || Object.defineProperty(String.prototype, "linkify", {
  writable: !1,
  value: function(t) {
    return a(this, t);
  }
});
export {
  a as default
};
