import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import cx from "classnames";
import { FormattedMessage } from "react-intl";
import { insightBuckets } from "@gooddata/sdk-model";
import { Bubble, BubbleHoverTrigger } from "@gooddata/sdk-ui-kit";
import { ConfigurationPanelContent } from "./ConfigurationPanelContent.js";
import { messages } from "../../../locales.js";
import { BUBBLE_ARROW_OFFSET_X, BUBBLE_ARROW_OFFSET_Y, HIDE_DELAY_DEFAULT, SHOW_DELAY_DEFAULT, } from "../../constants/bubble.js";
import { noColumnsAndHasOneMeasure, noRowsAndHasOneMeasure } from "../../utils/bucketHelper.js";
import { LabelSubsection } from "../configurationControls/axis/LabelSubsection.js";
import { NameSubsection } from "../configurationControls/axis/NameSubsection.js";
import { ConfigSection } from "../configurationControls/ConfigSection.js";
import { DataLabelsControl } from "../configurationControls/DataLabelsControl.js";
export class HeatMapConfigurationPanel extends ConfigurationPanelContent {
    renderConfigurationPanel() {
        const { propertiesMeta, properties, pushData } = this.props;
        const { xAxisVisible, yAxisVisible } = this.getControlProperties();
        const controlsDisabled = this.isControlDisabled();
        const xAxisDisabled = this.isAxisDisabled(controlsDisabled, "xaxis", this.props.insight);
        const yAxisDisabled = this.isAxisDisabled(controlsDisabled, "yaxis", this.props.insight);
        return (_jsxs(BubbleHoverTrigger, { showDelay: SHOW_DELAY_DEFAULT, hideDelay: HIDE_DELAY_DEFAULT, children: [_jsxs("div", { children: [this.renderColorSection(), _jsxs(ConfigSection, { id: "xaxis_section", title: messages["xaxisTitle"].id, valuePath: "xaxis.visible", canBeToggled: true, toggledOn: xAxisVisible, toggleDisabled: xAxisDisabled, showDisabledMessage: !controlsDisabled && xAxisDisabled, propertiesMeta: propertiesMeta, properties: properties, pushData: pushData, children: [_jsx(NameSubsection, { disabled: xAxisDisabled, configPanelDisabled: controlsDisabled, axis: "xaxis", properties: properties, pushData: pushData }), _jsx(LabelSubsection, { disabled: xAxisDisabled, configPanelDisabled: controlsDisabled, axis: "xaxis", properties: properties, pushData: pushData })] }), _jsxs(ConfigSection, { id: "yaxis_section", title: messages["yaxisTitle"].id, valuePath: "yaxis.visible", canBeToggled: true, toggledOn: yAxisVisible, toggleDisabled: yAxisDisabled, showDisabledMessage: !controlsDisabled && yAxisDisabled, propertiesMeta: propertiesMeta, properties: properties, pushData: pushData, children: [_jsx(NameSubsection, { disabled: yAxisDisabled, configPanelDisabled: controlsDisabled, axis: "yaxis", properties: properties, pushData: pushData }), _jsx(LabelSubsection, { disabled: yAxisDisabled, configPanelDisabled: controlsDisabled, axis: "yaxis", properties: properties, pushData: pushData })] }), this.renderLegendSection(), this.renderInteractionsSection(), _jsx(ConfigSection, { id: "canvas_section", title: messages["canvasTitle"].id, propertiesMeta: propertiesMeta, properties: properties, pushData: pushData, children: _jsx(DataLabelsControl, { pushData: pushData, properties: properties, isDisabled: controlsDisabled, defaultValue: "auto" }) }), this.renderAdvancedSection()] }), _jsx(Bubble, { className: this.getBubbleClassNames(), arrowOffsets: { "tc bc": [BUBBLE_ARROW_OFFSET_X, BUBBLE_ARROW_OFFSET_Y] }, alignPoints: [{ align: "tc bc" }], children: _jsx(FormattedMessage, { id: "properties.config.not_applicable" }) })] }));
    }
    getBubbleClassNames() {
        return cx("bubble-primary", {
            invisible: !this.isControlDisabled(),
        });
    }
    getControlProperties() {
        const propertiesControls = this.props.properties?.controls;
        const xAxisVisible = propertiesControls?.["xaxis"]?.visible ?? true;
        const yAxisVisible = propertiesControls?.["yaxis"]?.visible ?? true;
        return {
            xAxisVisible,
            yAxisVisible,
        };
    }
    isAxisDisabled(controlsDisabled, axis, insight) {
        const isAxisDisabled = axis === "xaxis"
            ? noColumnsAndHasOneMeasure(insightBuckets(insight))
            : noRowsAndHasOneMeasure(insightBuckets(insight));
        return Boolean(controlsDisabled || isAxisDisabled);
    }
}
//# sourceMappingURL=HeatMapConfigurationPanel.js.map