import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2022-2025 GoodData Corporation
import { useCallback } from "react";
import { FormattedMessage } from "react-intl";
import { dialogEmptyInsightMessageLabels } from "../../../../locales.js";
/**
 * @internal
 */
export function CodeArea({ code, onCopyCode }) {
    const onAreaCopyCode = useCallback(() => {
        onCopyCode(code);
    }, [code, onCopyCode]);
    return (_jsx("div", { className: "embed-insight-dialog-code-content", children: _jsx("textarea", { className: "embed-insight-dialog-code-area s-code-content", readOnly: true, value: code, onCopy: onAreaCopyCode }) }));
}
/**
 * @internal
 */
export function CodeAreaDisableMessage({ componentType, embedType, openSaveInsightDialog, }) {
    const getEmptyMessage = useCallback(() => {
        const isDefinitionMsg = embedType === "react" && componentType === "definition";
        return (_jsx(FormattedMessage, { id: dialogEmptyInsightMessageLabels[isDefinitionMsg ? "definition" : "reference"].id, values: {
                a: (chunk) => {
                    return _jsx("a", { onClick: openSaveInsightDialog, children: chunk });
                },
            } }));
    }, [embedType, componentType, openSaveInsightDialog]);
    return (_jsx("div", { className: `embed-insight-dialog-code-empty ${componentType}`, children: _jsx("div", { className: "embed-insight-dialog-code-empty-msg", children: getEmptyMessage() }) }));
}
/**
 * @internal
 */
export function EmbedInsightCodeArea({ code, onCopyCode, ...restProps }) {
    return code ? (_jsx(CodeArea, { code: code, onCopyCode: onCopyCode })) : (_jsx(CodeAreaDisableMessage, { ...restProps }));
}
