import { CopyIcon } from 'lucide-react';
import ShikiHighlighter from 'react-shiki';
import { useIntl } from 'react-intl';
import { toast } from 'sonner';
import { jsxs, jsx } from 'react/jsx-runtime';

// src/components/highlighter.tsx
function CustomHighlighter({
  language,
  codeString
}) {
  const intl = useIntl();
  const handleCopy = (e) => {
    e.preventDefault();
    navigator.clipboard.writeText(codeString).then(() => {
      toast(intl.formatMessage({ id: "code.copyToast" }), {
        description: intl.formatMessage({ id: "code.copyToastDescription" }),
        duration: 2e3
      });
    }).catch((err) => {
      console.error("Failed to copy code: ", err);
    });
  };
  return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
    /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
      "button",
      {
        "aria-label": intl.formatMessage({ id: "code.copyAriaLabel" }),
        className: "absolute hover:opacity-50 transition-all right-sm top-sm z-10 p-2",
        onClick: handleCopy,
        children: /* @__PURE__ */ jsx(CopyIcon, { className: "h-4 w-4" })
      }
    ) }),
    /* @__PURE__ */ jsx(
      ShikiHighlighter,
      {
        language,
        theme: {
          light: "github-light-high-contrast",
          dark: "github-dark-high-contrast"
        },
        showLineNumbers: true,
        showLanguage: false,
        children: codeString
      }
    )
  ] });
}

export { CustomHighlighter };
//# sourceMappingURL=chunk-DTS2RIRR.js.map
//# sourceMappingURL=chunk-DTS2RIRR.js.map