'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var dnd = require('@react-aria/dnd');
var dnd$1 = require('@react-stately/dnd');
var React = require('react');

/**
 * Provides the hooks required to enable drag and drop behavior for a drag and
 * drop compatible component.
 */
// NOTE: if more components become drag-n-droppable move elsewhere.
function useDragAndDrop(options) {
  let dragAndDropHooks = React.useMemo(() => {
    let {
      onDrop,
      onInsert,
      onItemDrop,
      onReorder,
      onRootDrop,
      getItems
    } = options;
    let isDraggable = !!getItems;
    let isDroppable = !!(onDrop || onInsert || onItemDrop || onReorder || onRootDrop);
    let hooks = {};
    if (isDraggable) {
      // @ts-expect-error
      hooks.useDraggableCollectionState = function useDraggableCollectionStateOverride(props) {
        return dnd$1.useDraggableCollectionState({
          ...props,
          ...options
        });
      };
      hooks.useDraggableCollection = dnd.useDraggableCollection;
      hooks.useDraggableItem = dnd.useDraggableItem;
      hooks.DragPreview = dnd.DragPreview;
    }
    if (isDroppable) {
      // eslint-disable-next-line no-unused-expressions
      hooks.useDroppableCollectionState = function useDroppableCollectionStateOverride(props) {
        return dnd$1.useDroppableCollectionState({
          ...props,
          ...options
        });
      }, hooks.useDroppableItem = dnd.useDroppableItem;
      hooks.useDroppableCollection = function useDroppableCollectionOverride(props, state, ref) {
        return dnd.useDroppableCollection({
          ...props,
          ...options
        }, state, ref);
      };
      hooks.useDropIndicator = dnd.useDropIndicator;
    }
    if (isDraggable || isDroppable) {
      hooks.isVirtualDragging = dnd.isVirtualDragging;
    }
    return hooks;
  }, [options]);
  return {
    dragAndDropHooks
  };
}

Object.defineProperty(exports, 'DIRECTORY_DRAG_TYPE', {
  enumerable: true,
  get: function () { return dnd.DIRECTORY_DRAG_TYPE; }
});
exports.useDragAndDrop = useDragAndDrop;
