import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import clsx from "clsx";
import { CheckCheck, Copy } from "lucide-react";
import { useState } from "react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { vscDarkPlus } from "react-syntax-highlighter/dist/cjs/styles/prism";
import { IconButton } from "../IconButton";
export const CodeBlock = ({ language, codeString, theme }) => {
    const [copied, setCopied] = useState(false);
    const handleCopy = () => {
        navigator.clipboard.writeText(codeString);
        setCopied(true);
        setTimeout(() => setCopied(false), 1000);
    };
    return (_jsxs("div", { className: "openui-code-block-wrapper", children: [_jsx(IconButton, { onClick: handleCopy, variant: "secondary", size: "small", className: clsx("openui-code-block-copy-button", {
                    "openui-code-block-copy-button-copied": copied,
                }), icon: copied ? _jsx(CheckCheck, {}) : _jsx(Copy, {}) }), _jsx(SyntaxHighlighter, { style: theme ?? vscDarkPlus, language: language, PreTag: "div", className: "openui-code-block-syntax-highlighter", children: codeString })] }));
};
//# sourceMappingURL=CodeBlock.js.map