var u = Object.defineProperty, g = Object.defineProperties;
var w = Object.getOwnPropertyDescriptors;
var i = Object.getOwnPropertySymbols;
var d = Object.prototype.hasOwnProperty, l = Object.prototype.propertyIsEnumerable;
var f = (r, o, e) => o in r ? u(r, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[o] = e, t = (r, o) => {
  for (var e in o || (o = {}))
    d.call(o, e) && f(r, e, o[e]);
  if (i)
    for (var e of i(o))
      l.call(o, e) && f(r, e, o[e]);
  return r;
}, s = (r, o) => g(r, w(o));
var k = (r, o) => {
  var e = {};
  for (var m in r)
    d.call(r, m) && o.indexOf(m) < 0 && (e[m] = r[m]);
  if (r != null && i)
    for (var m of i(r))
      o.indexOf(m) < 0 && l.call(r, m) && (e[m] = r[m]);
  return e;
};
import { jsx as a } from "react/jsx-runtime";
import { useRef as h } from "react";
import M from "react-markdown";
import x from "remark-gfm";
import y from "rehype-raw";
import R from "rehype-external-links";
import v from "remark-math";
import L from "rehype-katex";
import "katex/dist/katex.min.css";
import "./style.less.mjs";
import P from "./Image/index.mjs";
import T from "./Code/index.mjs";
import { replaceLatexDelimiters as b } from "../../utils/markdown/index.mjs";
import j from "./ATag/index.mjs";
import A from "./Video/index.mjs";
const S = (C) => {
  var n = C, {
    showLatex: r = !0,
    components: o = {},
    children: e
  } = n, m = k(n, [
    "showLatex",
    "components",
    "children"
  ]);
  const c = h(null);
  return /* @__PURE__ */ a("div", {
    ref: c,
    children: /* @__PURE__ */ a(M, s(t({
      className: "markdown",
      rehypePlugins: [L, y, [R, {
        target: "_blank"
      }]],
      remarkPlugins: [v, [x, {
        singleTilde: !1
      }]]
    }, m), {
      children: r ? b(e) : e,
      components: t({
        img(p) {
          return /* @__PURE__ */ a(P, t({}, p));
        },
        code(p) {
          return /* @__PURE__ */ a(T, t({}, p));
        },
        video: A,
        a: j
      }, o)
    }))
  });
};
export {
  S as Markdown
};
