import { ButtonColors, ButtonVariants } from '../../Button';
import { usePopover } from '../../usePopover';
import { confirmActionClassnames } from '../constants';
export const useLogic = ({ confirmButtonProps: externalConfirmButtonProps, onConfirm, }) => {
    const { isOpen, anchor, actions } = usePopover();
    const { isAccented } = externalConfirmButtonProps || {};
    const confirmButtonVariant = isAccented
        ? ButtonVariants.Light
        : ButtonVariants.Contained;
    const confirmButtonColor = isAccented
        ? ButtonColors.Error
        : ButtonColors.Primary;
    const handleConfirm = () => {
        onConfirm();
        actions.close();
    };
    return {
        actionComponentProps: {
            onClick: actions.open,
            className: confirmActionClassnames.actionComponent,
            selected: isOpen,
            'aria-selected': isOpen,
        },
        popoverProps: {
            open: isOpen,
            anchorEl: anchor,
            onClose: actions.close,
        },
        cancelButtonProps: {
            onClick: actions.close,
        },
        confirmButtonProps: {
            variant: confirmButtonVariant,
            color: confirmButtonColor,
            onClick: handleConfirm,
        },
    };
};
