import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
// (C) 2019-2025 GoodData Corporation
import { useCallback } from "react";
import { cloneDeep, set } from "lodash-es";
import { useIntl } from "react-intl";
import { getTranslation } from "../../utils/translations.js";
import { DisabledBubbleMessage } from "../DisabledBubbleMessage.js";
export function CheckboxControl({ checked = false, disabled = false, showDisabledMessage = false, labelText, valuePath, disabledMessageId, properties, pushData, isValueInverted = false, }) {
    const intl = useIntl();
    const onValueChanged = useCallback((event) => {
        const clonedProperties = cloneDeep(properties);
        set(clonedProperties, `controls.${valuePath}`, isValueInverted ? !event.target.checked : event.target.checked);
        pushData?.({ properties: clonedProperties });
    }, [properties, valuePath, isValueInverted, pushData]);
    return (_jsx(DisabledBubbleMessage, { showDisabledMessage: showDisabledMessage, messageId: disabledMessageId, children: _jsxs("label", { className: "input-checkbox-label", children: [_jsx("input", { "aria-label": valuePath, checked: checked, disabled: disabled, type: "checkbox", className: "input-checkbox", onChange: onValueChanged }), _jsx("span", { className: "input-label-text", children: getTranslation(labelText, intl) })] }) }));
}
//# sourceMappingURL=CheckboxControl.js.map