import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2024-2026 GoodData Corporation
import cx from "classnames";
import { useIntl } from "react-intl";
import { insightVisualizationType } from "@gooddata/sdk-model";
import { IconVisualizationSwitcher, Typography } from "@gooddata/sdk-ui-kit";
import { useTheme } from "@gooddata/sdk-ui-theme-provider";
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
import { selectInsightsMap } from "../../../model/store/insights/insightsSelectors.js";
import { DashboardItem } from "../../presentationComponents/DashboardItems/DashboardItem.js";
import { DashboardItemVisualization } from "../../presentationComponents/DashboardItems/DashboardItemVisualization.js";
import { getVisTypeCssClass } from "../../presentationComponents/DashboardItems/utils.js";
import { EditableDashboardInsightWidgetHeader } from "../widget/InsightWidget/EditableDashboardInsightWidgetHeader.js";
import { AllVisualizationsDashInsights } from "./AllVisualizationsDashInsights.js";
import { useExecutionProgress } from "./useExecutionProgress.js";
/**
 * @internal
 */
export function EditModeDashboardVisualizationSwitcher({ widget, activeVisualizationId, onError, onExportReady, onLoadingChanged, screen, }) {
    const activeVisualization = widget.visualizations.find((visualization) => visualization.identifier === activeVisualizationId) ??
        widget.visualizations[0];
    const theme = useTheme();
    const intl = useIntl();
    const emptyContentIconColor = theme?.palette?.complementary?.c7 ?? "#6D7680";
    const insights = useDashboardSelector(selectInsightsMap);
    const insight = activeVisualization ? insights.get(activeVisualization.insight) : undefined;
    const { showOthers } = useExecutionProgress();
    if (!activeVisualization || !insight) {
        return (_jsxs("div", { className: "gd-visualization-switcher-widget-empty-content", children: [
                _jsx(IconVisualizationSwitcher, { width: 32, height: 38, color: emptyContentIconColor }), _jsx(Typography, { tagName: "p", children: intl.formatMessage({ id: "visualizationSwitcher.emptyContent" }) })
            ] }));
    }
    else {
        const visType = insightVisualizationType(insight);
        return (_jsx(DashboardItem, { as: "div", className: cx("type-visualization", "gd-dashboard-view-widget", "is-edit-mode", getVisTypeCssClass(activeVisualization.type, visType)), screen: screen, children: _jsx(DashboardItemVisualization, { renderHeadline: (clientHeight) => !activeVisualization.configuration?.hideTitle && (_jsx(EditableDashboardInsightWidgetHeader, { clientHeight: clientHeight, widget: activeVisualization, insight: insight })), children: ({ clientHeight, clientWidth }) => (_jsx(AllVisualizationsDashInsights, { visualizationClassName: "is-edit-mode", clientHeight: clientHeight, clientWidth: clientWidth, visualizations: widget.visualizations, showOthers: showOthers, activeVisualization: activeVisualization, onExportReady: onExportReady, onLoadingChanged: onLoadingChanged, onError: onError })) }) }));
    }
}
