"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useBlockingActions = void 0;
const react_1 = require("react");
const Card_1 = require("../../Card");
/**
 * Хук для управления блокирующими операциями в CardGrid
 */
const useBlockingActions = (actions) => {
    const { isDisabled, onActionClick, setDisabledActions, isDisabledCard, removeDisabledActions, } = (0, react_1.useContext)(Card_1.CardActionContext);
    const blockingAction = [...(actions || [])].find((action) => 'isBlockingOperation' in action &&
        action.isBlockingOperation &&
        'loading' in action &&
        action.loading);
    (0, react_1.useEffect)(() => {
        if (blockingAction) {
            setDisabledActions();
            return;
        }
        removeDisabledActions();
    }, [blockingAction]);
    return {
        isDisabled: isDisabled || isDisabledCard,
        onActionClick,
    };
};
exports.useBlockingActions = useBlockingActions;
