const getMultipleActions = (action, size, isDisabled) => {
    const { text, isNested, actions: nestedActions, disabled, disabledReason, note, isBlockingOperation, ...buttonProps } = action;
    return {
        tooltipProps: {
            key: text,
            title: disabled ? disabledReason : note,
            withoutContainer: !(isDisabled || disabled),
        },
        buttonProps: {
            ...buttonProps,
            disabled: isDisabled || disabled,
            name: text,
            size,
        },
        isNested,
        nestedActions: nestedActions.map(({ text: nestedActionText, ...nestedProps }) => ({
            key: nestedActionText,
            ...nestedProps,
            text: nestedActionText,
        })),
    };
};
const getSingleAction = (action, size, isDisabled) => {
    const { text, disabled, disabledReason, note, isBlockingOperation, isNested, ...mainProps } = action;
    return {
        tooltipProps: {
            key: text,
            title: disabled ? disabledReason : note,
            withoutContainer: !(isDisabled || disabled),
        },
        isNested,
        buttonProps: {
            ...mainProps,
            disabled: isDisabled || disabled,
            children: text,
            size,
        },
        nestedActions: [],
    };
};
export const useMainActions = ({ actions, size = 'medium', isDisabled, }) => {
    return actions.map((action) => {
        if ('isNested' in action) {
            return getMultipleActions(action, size, isDisabled);
        }
        return getSingleAction(action, size, isDisabled);
    });
};
