import { jsxs as t, jsx as a } from "react/jsx-runtime";
import { Classes as B } from "../../constants/selectors.js";
import { cn as x } from "../../utils/cn.js";
import { getNodeText as C } from "../../utils/get-node-text.js";
import { BaseCodeBlock as y } from "./base-code-block.js";
import { CodeHeader as w } from "./code-header.js";
import { CopyToClipboardButton as k } from "./copy-button.js";
const H = function(d) {
  const {
    filename: n,
    children: m,
    className: p,
    icon: s,
    isSmallText: b,
    hideAskAiButton: h,
    feedbackModalOpen: g,
    anchorRef: f,
    codeBlockTheme: o = "system",
    codeBlockThemeObject: u,
    askAiButton: e,
    feedbackButton: r,
    copyButtonProps: i
  } = d, c = C(m), l = !!n || !!s;
  return /* @__PURE__ */ t(
    "div",
    {
      className: x(
        B.CodeBlock,
        "not-prose group relative mt-5 mb-8 rounded-2xl",
        o === "system" && "codeblock-light dark:twoslash-dark border border-stone-950/10 bg-stone-50 text-stone-950 dark:border-white/10 dark:bg-white/5 dark:text-stone-50",
        o === "dark" && "codeblock-dark twoslash-dark dark:twoslash-dark bg-codeblock text-stone-50 ring-1 ring-transparent dark:bg-white/5 dark:ring-white/[0.14]",
        l ? "p-0.5" : "bg-transparent dark:bg-transparent",
        g && "border border-primary dark:border-primary-light",
        p
      ),
      ref: f,
      children: [
        l ? /* @__PURE__ */ t(
          w,
          {
            codeBlockTheme: o,
            filename: n,
            icon: s,
            children: [
              r && r,
              /* @__PURE__ */ a(
                k,
                {
                  codeBlockTheme: o,
                  textToCopy: c,
                  ...i
                }
              ),
              e && e
            ]
          }
        ) : /* @__PURE__ */ t(
          "div",
          {
            className: "absolute top-3 right-4 flex items-center gap-1.5",
            "data-floating-buttons": !0,
            children: [
              r && r,
              /* @__PURE__ */ a(
                k,
                {
                  codeBlockTheme: o,
                  textToCopy: c,
                  ...i
                }
              ),
              e && e
            ]
          }
        ),
        /* @__PURE__ */ a(
          y,
          {
            codeBlockTheme: o,
            codeBlockThemeObject: u,
            hideAskAiButton: h,
            isSmallText: b,
            ...d
          }
        )
      ]
    }
  );
};
export {
  H as CodeBlock
};
