"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _classnames = _interopRequireDefault(require("classnames"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const preventDefault = e => e.preventDefault();
const stopPropagation = e => e.stopPropagation();
const Draggable = props => {
  const {
    id,
    dragging = false,
    onDragStart,
    onDragOver,
    onDragLeave,
    onDrop,
    children
  } = props;
  const dragStartHandler = (0, _react.useCallback)(e => {
    stopPropagation(e);
    onDragStart(id);
  }, [id, onDragStart]);
  const dragOverHandler = (0, _react.useCallback)(e => {
    preventDefault(e);
    onDragOver(id);
  }, [id, onDragOver]);
  const dragLeaveHandler = (0, _react.useCallback)(e => {
    preventDefault(e);
    onDragLeave(id);
  }, [id, onDragLeave]);
  const dropHandler = (0, _react.useCallback)(e => {
    preventDefault(e);
    onDrop(id);
  }, [id, onDrop]);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: (0, _classnames.default)(dragging ? _style.default.dragging : null, _style.default.draggable),
    "data-testid": `draggable-${id}`,
    onDragStart: dragStartHandler,
    onDragOver: dragOverHandler,
    onDragLeave: dragLeaveHandler,
    onDrop: dropHandler,
    draggable: true
  }, children);
};
Draggable.propTypes = process.env.NODE_ENV !== "production" ? {
  id: _propTypes.default.string,
  dragging: _propTypes.default.bool,
  onDragStart: _propTypes.default.func,
  onDragOver: _propTypes.default.func,
  onDragLeave: _propTypes.default.func,
  onDrop: _propTypes.default.func,
  children: _propTypes.default.element
} : {};
var _default = exports.default = Draggable;
//# sourceMappingURL=index.js.map