import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2024-2026 GoodData Corporation
import { FormattedMessage } from "react-intl";
import { Bubble, BubbleHoverTrigger, IconQuestionMark } from "@gooddata/sdk-ui-kit";
import { useTheme } from "@gooddata/sdk-ui-theme-provider";
import { messages } from "../../../../locales.js";
import { changeInsightWidgetIgnoreCrossFiltering } from "../../../../model/commands/insight.js";
import { useDashboardDispatch, useDashboardSelector, } from "../../../../model/react/DashboardStoreProvider.js";
import { selectEnableIgnoreCrossFiltering } from "../../../../model/store/config/configSelectors.js";
import { gdColorStateBlank } from "../../../constants/colors.js";
const TOOLTIP_ALIGN_POINTS = [
    { align: "cr cl", offset: { x: 0, y: 1 } },
    { align: "cl cr", offset: { x: 0, y: 1 } },
];
export function InsightCrossFiltering({ widget }) {
    const dispatch = useDashboardDispatch();
    const theme = useTheme();
    const isIgnoreCrossFilteringEnabled = useDashboardSelector(selectEnableIgnoreCrossFiltering);
    if (!isIgnoreCrossFilteringEnabled) {
        return null;
    }
    return (_jsx("div", { className: "gd-cross-filtering-configuration", children: _jsxs("label", { className: "input-checkbox-label s-respect-cross-filtering", htmlFor: "respect-cross-filtering", children: [
                _jsx("input", { id: "respect-cross-filtering", type: "checkbox", className: "input-checkbox", checked: !widget.ignoreCrossFiltering, onChange: (e) => {
                        dispatch(changeInsightWidgetIgnoreCrossFiltering(widget.ref, !e.target.checked));
                    } }), _jsx("span", { className: "input-label-text", children: _jsx(FormattedMessage, { id: messages.respectCrossFilteringConfig.id }) }), _jsxs(BubbleHoverTrigger, { children: [
                        _jsx(IconQuestionMark, { className: "question-mark-icon", color: theme?.palette?.complementary?.c6 ?? gdColorStateBlank, width: 14, height: 14 }), _jsx(Bubble, { alignPoints: TOOLTIP_ALIGN_POINTS, children: _jsx(FormattedMessage, { id: messages.respectCrossFilteringTooltip.id }) })
                    ] })
            ] }) }));
}
