import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2023-2025 GoodData Corporation
import { useMemo } from "react";
import { useIntl } from "react-intl";
import { CalculationListItem } from "./CalculationListItem.js";
import { comparisonMessages } from "../../../../../locales.js";
import { calculationDropdownItems } from "../../../../constants/dropdowns.js";
import { DropdownControl } from "../../DropdownControl.js";
import { COMPARISON_CALCULATION_TYPE_VALUE_PATH } from "../ComparisonValuePath.js";
const CALCULATION_DROPDOWN_WIDTH = 194;
const DISABLED_MESSAGE_ALIGN_POINTS = [{ align: "cr cl", offset: { x: 0, y: 7 } }];
export function CalculationControl({ disabled, defaultCalculationType, properties, showDisabledMessage, pushData, }) {
    const { formatMessage } = useIntl();
    const calculationType = properties.controls?.comparison?.calculationType || defaultCalculationType;
    const items = useMemo(() => calculationDropdownItems.map((item) => ({
        ...item,
        title: formatMessage({ id: item.title }),
    })), [formatMessage]);
    return (_jsx("div", { className: "calculation-control s-calculation-control", children: _jsx(DropdownControl, { value: calculationType, valuePath: COMPARISON_CALCULATION_TYPE_VALUE_PATH, labelText: comparisonMessages["calculationTypeTitle"].id, disabled: disabled, showDisabledMessage: showDisabledMessage, disabledMessageAlignPoints: DISABLED_MESSAGE_ALIGN_POINTS, width: CALCULATION_DROPDOWN_WIDTH, items: items, customListItem: CalculationListItem, properties: properties, pushData: pushData }) }));
}
//# sourceMappingURL=CalculationControl.js.map