import { useMemo } from 'react';
export const useDragAndDropHandlers = ({ date, isInSelectedRange, isSelected, isDisabled, dragAndDropProps, }) => {
    const hasDragAndDrop = Boolean(dragAndDropProps && !isDisabled);
    const isDraggable = (hasDragAndDrop && isInSelectedRange && isSelected) || undefined;
    const handleDragStart = useMemo(() => isDraggable
        ? () => dragAndDropProps?.onRangeDayDragStart(date)
        : undefined, [isDraggable, dragAndDropProps]);
    const { handleDragEnd, handleDragOver, handleDrop, handleDragEnter } = useMemo(() => {
        if (!hasDragAndDrop) {
            return {};
        }
        return {
            handleDragEnter: () => dragAndDropProps?.onDayDragEnter(date),
            //По документации требуется вызывать e.preventDefault() внутри обработчика 'dragOver' иначе не будет отрабатывать 'drop'
            handleDragOver: (e) => e.preventDefault(),
            handleDrop: () => dragAndDropProps?.onDayDrop(date),
            handleDragEnd: () => dragAndDropProps?.onRangeDayDragEnd(date),
        };
    }, [hasDragAndDrop, dragAndDropProps]);
    return {
        handleDragStart,
        handleDragEnd,
        handleDragEnter,
        handleDragOver,
        handleDrop,
        isDraggable,
    };
};
