function attachClosestEdge(userData, _ref) {
  var _entries$sort$0$edge, _entries$sort$;
  var element = _ref.element,
    input = _ref.input,
    allowedEdges = _ref.allowedEdges;
  var client = {
    x: input.clientX,
    y: input.clientY
  };
  // I tried caching the result of `getBoundingClientRect()` for a single
  // frame in order to improve performance.
  // However, on measurement I saw no improvement. So no longer caching
  var rect = element.getBoundingClientRect();
  var entries = allowedEdges.map(function (edge) {
    return {
      edge: edge,
      value: getDistanceToEdge[edge](rect, client)
    };
  });

  // edge can be `null` when `allowedEdges` is []
  var addClosestEdge = (_entries$sort$0$edge = (_entries$sort$ = entries.sort(function (a, b) {
    return a.value - b.value;
  })[0]) === null || _entries$sort$ === void 0 ? void 0 : _entries$sort$.edge) !== null && _entries$sort$0$edge !== void 0 ? _entries$sort$0$edge : null;
  return _objectSpread(_objectSpread({}, userData), {}, _defineProperty({}, uniqueKey, addClosestEdge));
}
Adds a unique `Symbol` to the `userData` object. Use with `extractClosestEdge()` for type safe lookups.