import { T as A } from "./Text-By4P3in5.js";
import { jsxs as s, jsx as a } from "react/jsx-runtime";
import m from "@mui/material/Typography";
import c from "@mui/material/Box";
import d from "@mui/icons-material/Link";
import { C as S } from "./CodeBlock-B1iQO7zU.js";
import h from "@mui/material/Link";
import { toMuiColor as v } from "./types.js";
const g = {
  1: "h1",
  2: "h2",
  3: "h3",
  4: "h4",
  5: "h5",
  6: "h6"
};
function y({
  children: n,
  level: o = 2,
  id: r,
  copyLink: i = !1,
  sx: e
}) {
  const t = typeof o == "string" ? parseInt(o.replace("h", ""), 10) : o, p = g[t], l = () => {
    if (r) {
      const f = `${window.location.origin}${window.location.pathname}#${r}`;
      navigator.clipboard.writeText(f);
    }
  };
  return /* @__PURE__ */ s(
    m,
    {
      variant: p,
      id: r,
      sx: {
        color: "var(--ov-fg-base)",
        fontWeight: "var(--ov-weight-semibold)",
        display: "flex",
        alignItems: "center",
        gap: 0.5,
        "&:hover .ov-heading-anchor": { opacity: 1 },
        ...typeof e == "object" && !Array.isArray(e) ? e : {}
      },
      children: [
        n,
        i && r && /* @__PURE__ */ a(
          c,
          {
            component: "button",
            className: "ov-heading-anchor",
            onClick: l,
            sx: {
              opacity: 0,
              transition: "opacity 150ms",
              background: "none",
              border: "none",
              cursor: "pointer",
              color: "var(--ov-fg-faint)",
              display: "inline-flex",
              p: 0,
              "&:hover": { color: "var(--ov-fg-default)" }
            },
            children: /* @__PURE__ */ a(d, { sx: { fontSize: "0.7em" } })
          }
        )
      ]
    }
  );
}
y.displayName = "Heading";
function u({ children: n, sx: o }) {
  return /* @__PURE__ */ a(
    c,
    {
      component: "code",
      sx: {
        fontFamily: "var(--ov-font-mono)",
        fontSize: "0.85em",
        backgroundColor: "var(--ov-bg-surface-inset)",
        color: "var(--ov-fg-default)",
        padding: "2px 6px",
        borderRadius: "3px",
        whiteSpace: "nowrap",
        ...typeof o == "object" && !Array.isArray(o) ? o : {}
      },
      children: n
    }
  );
}
u.displayName = "CodeInline";
function x({
  children: n,
  href: o,
  color: r = "primary",
  underline: i = "hover",
  external: e = !1,
  onClick: t,
  sx: p
}) {
  return /* @__PURE__ */ a(
    h,
    {
      href: o,
      color: v(r),
      underline: i,
      onClick: t,
      ...e ? { target: "_blank", rel: "noopener noreferrer" } : {},
      sx: p,
      children: n
    }
  );
}
x.displayName = "Link";
export {
  S as CodeBlock,
  u as CodeInline,
  y as Heading,
  x as Link,
  A as Text
};
