var A = Object.defineProperty;
var f = Object.getOwnPropertySymbols;
var H = Object.prototype.hasOwnProperty, L = Object.prototype.propertyIsEnumerable;
var h = (r, e, t) => e in r ? A(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, p = (r, e) => {
  for (var t in e || (e = {}))
    H.call(e, t) && h(r, t, e[t]);
  if (f)
    for (var t of f(e))
      L.call(e, t) && h(r, t, e[t]);
  return r;
};
import M from "markdown-it";
import R from "markdown-it-highlightjs";
import y from "mermaid";
/* istanbul ignore file -- @preserve */
function b(r, e) {
  y.initialize(p({
    securityLevel: "loose"
  }, e));
  function t(n) {
    return n.split(/\s+/g)[0];
  }
  const d = r.renderer.rules.fence;
  function x(n, s, I, $, c) {
    const l = n[s], u = l.info.trim(), k = u ? t(u) : "";
    if (["mermaid", "{mermaid}"].indexOf(k) === -1)
      return d !== void 0 ? d(n, s, I, $, c) : "";
    let g = "";
    const m = [], o = document.createElement("div");
    document.body.appendChild(o);
    try {
      const i = "mermaid-container";
      y.mermaidAPI.render(
        i,
        l.content,
        (w) => {
          const a = document.getElementById(i);
          a !== null && m.push(["style", `max-width:${a.style.maxWidth};max-height:${a.style.maxHeight}`]), g = w;
        },
        o
      );
    } catch (i) {
      return `<div class="alert alert-danger">${i}</div>`;
    } finally {
      o.remove();
    }
    return m.push(["src", `data:image/svg+xml,${encodeURIComponent(g)}`]), `<img ${c.renderAttrs({ attrs: m })}>`;
  }
  r.renderer.rules.fence = x;
}
const v = new M({
  html: !0,
  linkify: !0,
  typographer: !0,
  breaks: !0
});
v.use(R);
v.use(b);
export {
  v as default
};
