import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2022-2026 GoodData Corporation
import { useCallback } from "react";
import cx from "classnames";
import copy from "copy-to-clipboard";
import { useIntl } from "react-intl";
import { dialogEmbedTabLabels, dialogHeadlineLabels } from "../../../locales.js";
import { Tabs } from "../../../Tabs/Tabs.js";
import { ConfirmDialogBase } from "../../ConfirmDialogBase.js";
import { CompleteListPropsMessage } from "./components/CompleteListPropsMessage.js";
import { EmbedInsightContent } from "./components/EmbedInsightContent.js";
/**
 * @internal
 */
export function EmbedInsightDialogBase({ code, propertiesLink, integrationDocLink, embedTab, embedTypeOptions, openSaveInsightDialog, onClose, onCopyCode, onOptionsChange, onTabChange, showWebComponentsTab, }) {
    const intl = useIntl();
    const onCopyButtonClick = useCallback(() => {
        copy(code);
        onCopyCode(code, "button", embedTab);
    }, [code, onCopyCode, embedTab]);
    const onAreaCopy = useCallback(() => {
        copy(code);
        onCopyCode(code, "keyboard", embedTab);
    }, [code, onCopyCode, embedTab]);
    return (_jsxs(ConfirmDialogBase, { isPositive: true, onClose: onClose, onCancel: onClose, onSubmit: onCopyButtonClick, cancelButtonText: intl.formatMessage({ id: "embedInsightDialog.actions.close" }), submitButtonText: intl.formatMessage({ id: "embedInsightDialog.actions.copyCode" }), isSubmitDisabled: !code, headline: intl.formatMessage({ id: dialogHeadlineLabels.embedInsight.id }), className: cx("embed-insight-dialog", "s-embed-insight-dialog"), dialogHeaderClassName: "embed-insight-dialog-header", footerLeftRenderer: propertiesLink
            ? () => {
                return (_jsx("div", { className: "embed-insight-dialog-left-footer-renderer", children: _jsx(CompleteListPropsMessage, { documentationLink: propertiesLink }) }));
            }
            : undefined, children: [showWebComponentsTab ? (_jsx(Tabs, { tabs: getTabIds(), onTabSelect: (tab) => {
                    onTabChange(tab.id.includes("react") ? "react" : "webComponents");
                }, selectedTabId: dialogEmbedTabLabels[embedTab]?.id ?? "" })) : null, _jsx(EmbedInsightContent, { integrationDocLink: integrationDocLink ?? "", code: code, embedTypeOptions: embedTypeOptions, onCopyCode: onAreaCopy, openSaveInsightDialog: openSaveInsightDialog, onOptionsChange: onOptionsChange })
        ] }));
}
const getTabIds = () => {
    return [{ id: dialogEmbedTabLabels.react.id }, { id: dialogEmbedTabLabels.webComponents.id }];
};
