import { useMemo } from 'react';
import { useBlockingActions } from '../../hooks/useBlockingActions';
export const useLogic = ({ actions }) => {
    const processedActions = useMemo(() => {
        if (!actions?.length) {
            return actions;
        }
        const hasMobilePrimary = actions.some((action) => !action.nested && action.isMobilePrimary);
        if (hasMobilePrimary) {
            return actions;
        }
        return actions.map((action, index) => {
            if (index === 0 && !action.nested) {
                return { ...action, isMobilePrimary: true };
            }
            return action;
        });
    }, [actions]);
    const { isDisabled, onActionClick } = useBlockingActions(processedActions);
    return {
        processedActions,
        isDisabled,
        onActionClick,
    };
};
