import { CollisionPriority as a, CollisionType as u } from "../../../../../@dnd-kit_abstract@0.1.21/node_modules/@dnd-kit/abstract/index.js";
import { Point as c, Rectangle as p } from "../../../../../@dnd-kit_geometry@0.1.21/node_modules/@dnd-kit/geometry/dist/index.js";
var y = ({
  dragOperation: e,
  droppable: n
}) => {
  const t = e.position.current;
  if (!t)
    return null;
  const { id: r } = n;
  if (!n.shape)
    return null;
  if (n.shape.containsPoint(t)) {
    const i = c.distance(n.shape.center, t);
    return {
      id: r,
      value: 1 / i,
      type: u.PointerIntersection,
      priority: a.High
    };
  }
  return null;
}, m = ({
  dragOperation: e,
  droppable: n
}) => {
  const { shape: t } = e;
  if (!n.shape || !t?.current)
    return null;
  const r = t.current.intersectionArea(n.shape);
  if (r) {
    const { position: i } = e, o = c.distance(n.shape.center, i.current), l = r / (t.current.area + n.shape.area - r) / o;
    return {
      id: n.id,
      value: l,
      type: u.ShapeIntersection,
      priority: a.Normal
    };
  }
  return null;
}, g = (e) => {
  var n;
  return (n = y(e)) != null ? n : m(e);
}, I = (e) => {
  const { dragOperation: n, droppable: t } = e, { shape: r, position: i } = n;
  if (!t.shape)
    return null;
  const o = r ? p.from(r.current.boundingRectangle).corners : void 0, l = p.from(
    t.shape.boundingRectangle
  ).corners.reduce(
    (d, f, v) => {
      var h;
      return d + c.distance(
        c.from(f),
        (h = o?.[v]) != null ? h : i.current
      );
    },
    0
  ) / 4;
  return {
    id: t.id,
    value: 1 / l,
    type: u.Collision,
    priority: a.Normal
  };
}, N = ({
  dragOperation: e,
  droppable: n
}) => {
  if (!n.shape)
    return null;
  const { position: t, shape: r } = e, { direction: i } = t;
  if (!r)
    return null;
  if (i === null)
    return g({ dragOperation: e, droppable: n });
  const { center: o, boundingRectangle: s } = r.current;
  return i === "down" && s.bottom >= n.shape.center.y || i === "up" && s.top <= n.shape.center.y || i === "left" && s.left <= n.shape.center.x || i === "right" && s.right >= n.shape.center.x ? {
    id: n.id,
    value: 1 / c.distance(n.shape.center, o),
    type: u.Collision,
    priority: a.Normal
  } : null;
}, P = (e) => {
  const { dragOperation: n, droppable: t } = e, { position: r } = n;
  if (!t.shape)
    return null;
  const o = 1 / c.distance(t.shape.center, r.current);
  return {
    id: t.id,
    value: o,
    type: u.Collision,
    priority: a.Normal
  };
};
export {
  I as closestCorners,
  g as defaultCollisionDetection,
  N as directionBiased,
  P as pointerDistance,
  y as pointerIntersection,
  m as shapeIntersection
};
//# sourceMappingURL=index.js.map
