import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
// (C) 2024-2026 GoodData Corporation
import cx from "classnames";
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
import { selectInsightsMap } from "../../../model/store/insights/insightsSelectors.js";
import { useDashboardComponentsContext } from "../../dashboardContexts/DashboardComponentsContext.js";
import { DashboardInsight } from "../insight/DashboardInsight.js";
export function AllVisualizationsDashInsights({ visualizations, onError, onExportReady, onLoadingChanged, activeVisualization, showOthers, clientHeight, clientWidth, visualizationClassName, exportData, }) {
    const insights = useDashboardSelector(selectInsightsMap);
    const { ErrorComponent, LoadingComponent } = useDashboardComponentsContext();
    return (_jsx(_Fragment, { children: visualizations
            .filter((vis) => vis.identifier === activeVisualization.identifier || showOthers)
            .map((visualization) => {
            const insight = insights.get(visualization.insight);
            if (!insight) {
                return null;
            }
            const isActive = visualization.identifier === activeVisualization.identifier;
            const containerClassName = cx(visualizationClassName, {
                "gd-visualization-switcher-visible-visualization": isActive,
                "gd-visualization-switcher-hidden-visualization": !isActive,
            });
            return (_jsx("div", { className: containerClassName, children: _jsx(DashboardInsight, { clientHeight: isActive ? clientHeight : 0, clientWidth: isActive ? clientWidth : 0, insight: insight, widget: visualization, onExportReady: onExportReady, onLoadingChanged: onLoadingChanged, onError: onError, ErrorComponent: ErrorComponent, LoadingComponent: LoadingComponent, exportData: exportData }, visualization.identifier) }, visualization.identifier));
        }) }));
}
