{"ast":null,"code":"import { __rest, __assign, __spreadArray, __read } from 'tslib';\nimport { invariant } from 'hey-listen';\nimport { PanSession } from '../PanSession.js';\nimport { getGlobalLock } from './utils/lock.js';\nimport { isRefObject } from '../../utils/is-ref-object.js';\nimport { addPointerEvent } from '../../events/use-pointer-event.js';\nimport { addDomEvent } from '../../events/use-dom-event.js';\nimport { getViewportPointFromEvent } from '../../events/event-info.js';\nimport { axisBox, convertAxisBoxToBoundingBox, convertBoundingBoxToAxisBox } from '../../utils/geometry/index.js';\nimport { eachAxis } from '../../utils/each-axis.js';\nimport { calcRelativeConstraints, resolveDragElastic, rebaseAxisConstraints, calcViewportConstraints, applyConstraints, calcConstrainedMinPoint, calcPositionFromProgress, defaultElastic } from './utils/constraints.js';\nimport { getBoundingBox } from '../../render/dom/projection/measure.js';\nimport { calcOrigin } from '../../utils/geometry/delta-calc.js';\nimport { startAnimation } from '../../animation/utils/transitions.js';\nimport { AnimationType } from '../../render/utils/types.js';\nimport { collectProjectingAncestors, updateLayoutMeasurement, collectProjectingChildren } from '../../render/dom/projection/utils.js';\nimport { progress } from 'popmotion';\nimport { convertToRelativeProjection } from '../../render/dom/projection/convert-to-relative.js';\nimport { calcRelativeOffset } from '../../motion/features/layout/utils.js';\nimport { flushLayout, batchLayout } from '../../render/dom/utils/batch-layout.js';\nimport { flushSync } from 'framesync';\nvar elementDragControls = new WeakMap();\n/**\n *\n */\nvar lastPointerEvent;\nvar VisualElementDragControls = /** @class */function () {\n  function VisualElementDragControls(_a) {\n    var visualElement = _a.visualElement;\n    /**\n     * Track whether we're currently dragging.\n     *\n     * @internal\n     */\n    this.isDragging = false;\n    /**\n     * The current direction of drag, or `null` if both.\n     *\n     * @internal\n     */\n    this.currentDirection = null;\n    /**\n     * The permitted boundaries of travel, in pixels.\n     *\n     * @internal\n     */\n    this.constraints = false;\n    /**\n     * The per-axis resolved elastic values.\n     *\n     * @internal\n     */\n    this.elastic = axisBox();\n    /**\n     * A reference to the host component's latest props.\n     *\n     * @internal\n     */\n    this.props = {};\n    /**\n     * @internal\n     */\n    this.hasMutatedConstraints = false;\n    /**\n     * Track the initial position of the cursor relative to the dragging element\n     * when dragging starts as a value of 0-1 on each axis. We then use this to calculate\n     * an ideal bounding box for the VisualElement renderer to project into every frame.\n     *\n     * @internal\n     */\n    this.cursorProgress = {\n      x: 0.5,\n      y: 0.5\n    };\n    // When updating _dragX, or _dragY instead of the VisualElement,\n    // persist their values between drag gestures.\n    this.originPoint = {};\n    // This is a reference to the global drag gesture lock, ensuring only one component\n    // can \"capture\" the drag of one or both axes.\n    // TODO: Look into moving this into pansession?\n    this.openGlobalLock = null;\n    /**\n     * @internal\n     */\n    this.panSession = null;\n    this.visualElement = visualElement;\n    this.visualElement.enableLayoutProjection();\n    elementDragControls.set(visualElement, this);\n  }\n  /**\n   * Instantiate a PanSession for the drag gesture\n   *\n   * @public\n   */\n  VisualElementDragControls.prototype.start = function (originEvent, _a) {\n    var _this = this;\n    var _b = _a === void 0 ? {} : _a,\n      _c = _b.snapToCursor,\n      snapToCursor = _c === void 0 ? false : _c,\n      cursorProgress = _b.cursorProgress;\n    var onSessionStart = function onSessionStart(event) {\n      var _a;\n      // Stop any animations on both axis values immediately. This allows the user to throw and catch\n      // the component.\n      _this.stopMotion();\n      /**\n       * Save the initial point. We'll use this to calculate the pointer's position rather\n       * than the one we receive when the gesture actually starts. By then, the pointer will\n       * have already moved, and the perception will be of the pointer \"slipping\" across the element\n       */\n      var initialPoint = getViewportPointFromEvent(event).point;\n      (_a = _this.cancelLayout) === null || _a === void 0 ? void 0 : _a.call(_this);\n      _this.cancelLayout = batchLayout(function (read, write) {\n        var ancestors = collectProjectingAncestors(_this.visualElement);\n        var children = collectProjectingChildren(_this.visualElement);\n        var tree = __spreadArray(__spreadArray([], __read(ancestors)), __read(children));\n        var hasManuallySetCursorOrigin = false;\n        /**\n         * Apply a simple lock to the projection target. This ensures no animations\n         * can run on the projection box while this lock is active.\n         */\n        _this.isLayoutDrag() && _this.visualElement.lockProjectionTarget();\n        write(function () {\n          tree.forEach(function (element) {\n            return element.resetTransform();\n          });\n        });\n        read(function () {\n          updateLayoutMeasurement(_this.visualElement);\n          children.forEach(updateLayoutMeasurement);\n        });\n        write(function () {\n          tree.forEach(function (element) {\n            return element.restoreTransform();\n          });\n          if (snapToCursor) {\n            hasManuallySetCursorOrigin = _this.snapToCursor(initialPoint);\n          }\n        });\n        read(function () {\n          var isRelativeDrag = Boolean(_this.getAxisMotionValue(\"x\") && !_this.isExternalDrag());\n          if (!isRelativeDrag) {\n            _this.visualElement.rebaseProjectionTarget(true, _this.visualElement.measureViewportBox(false));\n          }\n          _this.visualElement.scheduleUpdateLayoutProjection();\n          /**\n           * When dragging starts, we want to find where the cursor is relative to the bounding box\n           * of the element. Every frame, we calculate a new bounding box using this relative position\n           * and let the visualElement renderer figure out how to reproject the element into this bounding\n           * box.\n           *\n           * By doing it this way, rather than applying an x/y transform directly to the element,\n           * we can ensure the component always visually sticks to the cursor as we'd expect, even\n           * if the DOM element itself changes layout as a result of React updates the user might\n           * make based on the drag position.\n           */\n          var projection = _this.visualElement.projection;\n          eachAxis(function (axis) {\n            if (!hasManuallySetCursorOrigin) {\n              var _a = projection.target[axis],\n                min = _a.min,\n                max = _a.max;\n              _this.cursorProgress[axis] = cursorProgress ? cursorProgress[axis] : progress(min, max, initialPoint[axis]);\n            }\n            /**\n             * If we have external drag MotionValues, record their origin point. On pointermove\n             * we'll apply the pan gesture offset directly to this value.\n             */\n            var axisValue = _this.getAxisMotionValue(axis);\n            if (axisValue) {\n              _this.originPoint[axis] = axisValue.get();\n            }\n          });\n        });\n        write(function () {\n          flushSync.update();\n          flushSync.preRender();\n          flushSync.render();\n          flushSync.postRender();\n        });\n        read(function () {\n          return _this.resolveDragConstraints();\n        });\n      });\n    };\n    var onStart = function onStart(event, info) {\n      var _a, _b, _c;\n      // Attempt to grab the global drag gesture lock - maybe make this part of PanSession\n      var _d = _this.props,\n        drag = _d.drag,\n        dragPropagation = _d.dragPropagation;\n      if (drag && !dragPropagation) {\n        if (_this.openGlobalLock) _this.openGlobalLock();\n        _this.openGlobalLock = getGlobalLock(drag);\n        // If we don 't have the lock, don't start dragging\n        if (!_this.openGlobalLock) return;\n      }\n      flushLayout();\n      // Set current drag status\n      _this.isDragging = true;\n      _this.currentDirection = null;\n      // Fire onDragStart event\n      (_b = (_a = _this.props).onDragStart) === null || _b === void 0 ? void 0 : _b.call(_a, event, info);\n      (_c = _this.visualElement.animationState) === null || _c === void 0 ? void 0 : _c.setActive(AnimationType.Drag, true);\n    };\n    var onMove = function onMove(event, info) {\n      var _a, _b, _c, _d;\n      var _e = _this.props,\n        dragPropagation = _e.dragPropagation,\n        dragDirectionLock = _e.dragDirectionLock;\n      // If we didn't successfully receive the gesture lock, early return.\n      if (!dragPropagation && !_this.openGlobalLock) return;\n      var offset = info.offset;\n      // Attempt to detect drag direction if directionLock is true\n      if (dragDirectionLock && _this.currentDirection === null) {\n        _this.currentDirection = getCurrentDirection(offset);\n        // If we've successfully set a direction, notify listener\n        if (_this.currentDirection !== null) {\n          (_b = (_a = _this.props).onDirectionLock) === null || _b === void 0 ? void 0 : _b.call(_a, _this.currentDirection);\n        }\n        return;\n      }\n      // Update each point with the latest position\n      _this.updateAxis(\"x\", info.point, offset);\n      _this.updateAxis(\"y\", info.point, offset);\n      // Fire onDrag event\n      (_d = (_c = _this.props).onDrag) === null || _d === void 0 ? void 0 : _d.call(_c, event, info);\n      // Update the last pointer event\n      lastPointerEvent = event;\n    };\n    var onSessionEnd = function onSessionEnd(event, info) {\n      return _this.stop(event, info);\n    };\n    var transformPagePoint = this.props.transformPagePoint;\n    this.panSession = new PanSession(originEvent, {\n      onSessionStart: onSessionStart,\n      onStart: onStart,\n      onMove: onMove,\n      onSessionEnd: onSessionEnd\n    }, {\n      transformPagePoint: transformPagePoint\n    });\n  };\n  VisualElementDragControls.prototype.resolveDragConstraints = function () {\n    var _this = this;\n    var _a = this.props,\n      dragConstraints = _a.dragConstraints,\n      dragElastic = _a.dragElastic;\n    var layout = this.visualElement.getLayoutState().layoutCorrected;\n    if (dragConstraints) {\n      this.constraints = isRefObject(dragConstraints) ? this.resolveRefConstraints(layout, dragConstraints) : calcRelativeConstraints(layout, dragConstraints);\n    } else {\n      this.constraints = false;\n    }\n    this.elastic = resolveDragElastic(dragElastic);\n    /**\n     * If we're outputting to external MotionValues, we want to rebase the measured constraints\n     * from viewport-relative to component-relative.\n     */\n    if (this.constraints && !this.hasMutatedConstraints) {\n      eachAxis(function (axis) {\n        if (_this.getAxisMotionValue(axis)) {\n          _this.constraints[axis] = rebaseAxisConstraints(layout[axis], _this.constraints[axis]);\n        }\n      });\n    }\n  };\n  VisualElementDragControls.prototype.resolveRefConstraints = function (layoutBox, constraints) {\n    var _a = this.props,\n      onMeasureDragConstraints = _a.onMeasureDragConstraints,\n      transformPagePoint = _a.transformPagePoint;\n    var constraintsElement = constraints.current;\n    invariant(constraintsElement !== null, \"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.\");\n    this.constraintsBox = getBoundingBox(constraintsElement, transformPagePoint);\n    var measuredConstraints = calcViewportConstraints(layoutBox, this.constraintsBox);\n    /**\n     * If there's an onMeasureDragConstraints listener we call it and\n     * if different constraints are returned, set constraints to that\n     */\n    if (onMeasureDragConstraints) {\n      var userConstraints = onMeasureDragConstraints(convertAxisBoxToBoundingBox(measuredConstraints));\n      this.hasMutatedConstraints = !!userConstraints;\n      if (userConstraints) {\n        measuredConstraints = convertBoundingBoxToAxisBox(userConstraints);\n      }\n    }\n    return measuredConstraints;\n  };\n  VisualElementDragControls.prototype.cancelDrag = function () {\n    var _a, _b;\n    this.visualElement.unlockProjectionTarget();\n    (_a = this.cancelLayout) === null || _a === void 0 ? void 0 : _a.call(this);\n    this.isDragging = false;\n    this.panSession && this.panSession.end();\n    this.panSession = null;\n    if (!this.props.dragPropagation && this.openGlobalLock) {\n      this.openGlobalLock();\n      this.openGlobalLock = null;\n    }\n    (_b = this.visualElement.animationState) === null || _b === void 0 ? void 0 : _b.setActive(AnimationType.Drag, false);\n  };\n  VisualElementDragControls.prototype.stop = function (event, info) {\n    var _a, _b, _c;\n    (_a = this.panSession) === null || _a === void 0 ? void 0 : _a.end();\n    this.panSession = null;\n    var isDragging = this.isDragging;\n    this.cancelDrag();\n    if (!isDragging) return;\n    var velocity = info.velocity;\n    this.animateDragEnd(velocity);\n    (_c = (_b = this.props).onDragEnd) === null || _c === void 0 ? void 0 : _c.call(_b, event, info);\n  };\n  VisualElementDragControls.prototype.snapToCursor = function (point) {\n    var _this = this;\n    return eachAxis(function (axis) {\n      var drag = _this.props.drag;\n      // If we're not dragging this axis, do an early return.\n      if (!shouldDrag(axis, drag, _this.currentDirection)) return;\n      var axisValue = _this.getAxisMotionValue(axis);\n      if (axisValue) {\n        var box = _this.visualElement.getLayoutState().layout;\n        var length_1 = box[axis].max - box[axis].min;\n        var center = box[axis].min + length_1 / 2;\n        var offset = point[axis] - center;\n        _this.originPoint[axis] = point[axis];\n        axisValue.set(offset);\n      } else {\n        _this.cursorProgress[axis] = 0.5;\n        return true;\n      }\n    }).includes(true);\n  };\n  /**\n   * Update the specified axis with the latest pointer information.\n   */\n  VisualElementDragControls.prototype.updateAxis = function (axis, point, offset) {\n    var drag = this.props.drag;\n    // If we're not dragging this axis, do an early return.\n    if (!shouldDrag(axis, drag, this.currentDirection)) return;\n    return this.getAxisMotionValue(axis) ? this.updateAxisMotionValue(axis, offset) : this.updateVisualElementAxis(axis, point);\n  };\n  VisualElementDragControls.prototype.updateAxisMotionValue = function (axis, offset) {\n    var axisValue = this.getAxisMotionValue(axis);\n    if (!offset || !axisValue) return;\n    var nextValue = this.originPoint[axis] + offset[axis];\n    var update = this.constraints ? applyConstraints(nextValue, this.constraints[axis], this.elastic[axis]) : nextValue;\n    axisValue.set(update);\n  };\n  VisualElementDragControls.prototype.updateVisualElementAxis = function (axis, point) {\n    var _a;\n    // Get the actual layout bounding box of the element\n    var axisLayout = this.visualElement.getLayoutState().layout[axis];\n    // Calculate its current length. In the future we might want to lerp this to animate\n    // between lengths if the layout changes as we change the DOM\n    var axisLength = axisLayout.max - axisLayout.min;\n    // Get the initial progress that the pointer sat on this axis on gesture start.\n    var axisProgress = this.cursorProgress[axis];\n    // Calculate a new min point based on the latest pointer position, constraints and elastic\n    var min = calcConstrainedMinPoint(point[axis], axisLength, axisProgress, (_a = this.constraints) === null || _a === void 0 ? void 0 : _a[axis], this.elastic[axis]);\n    // Update the axis viewport target with this new min and the length\n    this.visualElement.setProjectionTargetAxis(axis, min, min + axisLength);\n  };\n  VisualElementDragControls.prototype.setProps = function (_a) {\n    var _b = _a.drag,\n      drag = _b === void 0 ? false : _b,\n      _c = _a.dragDirectionLock,\n      dragDirectionLock = _c === void 0 ? false : _c,\n      _d = _a.dragPropagation,\n      dragPropagation = _d === void 0 ? false : _d,\n      _e = _a.dragConstraints,\n      dragConstraints = _e === void 0 ? false : _e,\n      _f = _a.dragElastic,\n      dragElastic = _f === void 0 ? defaultElastic : _f,\n      _g = _a.dragMomentum,\n      dragMomentum = _g === void 0 ? true : _g,\n      remainingProps = __rest(_a, [\"drag\", \"dragDirectionLock\", \"dragPropagation\", \"dragConstraints\", \"dragElastic\", \"dragMomentum\"]);\n    this.props = __assign({\n      drag: drag,\n      dragDirectionLock: dragDirectionLock,\n      dragPropagation: dragPropagation,\n      dragConstraints: dragConstraints,\n      dragElastic: dragElastic,\n      dragMomentum: dragMomentum\n    }, remainingProps);\n  };\n  /**\n   * Drag works differently depending on which props are provided.\n   *\n   * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.\n   * - If the component will perform layout animations, we output the gesture to the component's\n   *      visual bounding box\n   * - Otherwise, we apply the delta to the x/y motion values.\n   */\n  VisualElementDragControls.prototype.getAxisMotionValue = function (axis) {\n    var _a = this.props,\n      layout = _a.layout,\n      layoutId = _a.layoutId;\n    var dragKey = \"_drag\" + axis.toUpperCase();\n    if (this.props[dragKey]) {\n      return this.props[dragKey];\n    } else if (!layout && layoutId === undefined) {\n      return this.visualElement.getValue(axis, 0);\n    }\n  };\n  VisualElementDragControls.prototype.isLayoutDrag = function () {\n    return !this.getAxisMotionValue(\"x\");\n  };\n  VisualElementDragControls.prototype.isExternalDrag = function () {\n    var _a = this.props,\n      _dragX = _a._dragX,\n      _dragY = _a._dragY;\n    return _dragX || _dragY;\n  };\n  VisualElementDragControls.prototype.animateDragEnd = function (velocity) {\n    var _this = this;\n    var _a = this.props,\n      drag = _a.drag,\n      dragMomentum = _a.dragMomentum,\n      dragElastic = _a.dragElastic,\n      dragTransition = _a.dragTransition;\n    /**\n     * Everything beyond the drag gesture should be performed with\n     * relative projection so children stay in sync with their parent element.\n     */\n    var isRelative = convertToRelativeProjection(this.visualElement, this.isLayoutDrag() && !this.isExternalDrag());\n    /**\n     * If we had previously resolved constraints relative to the viewport,\n     * we need to also convert those to a relative coordinate space for the animation\n     */\n    var constraints = this.constraints || {};\n    if (isRelative && Object.keys(constraints).length && this.isLayoutDrag()) {\n      var projectionParent = this.visualElement.getProjectionParent();\n      if (projectionParent) {\n        var relativeConstraints_1 = calcRelativeOffset(projectionParent.projection.targetFinal, constraints);\n        eachAxis(function (axis) {\n          var _a = relativeConstraints_1[axis],\n            min = _a.min,\n            max = _a.max;\n          constraints[axis] = {\n            min: isNaN(min) ? undefined : min,\n            max: isNaN(max) ? undefined : max\n          };\n        });\n      }\n    }\n    var momentumAnimations = eachAxis(function (axis) {\n      var _a;\n      if (!shouldDrag(axis, drag, _this.currentDirection)) {\n        return;\n      }\n      var transition = (_a = constraints === null || constraints === void 0 ? void 0 : constraints[axis]) !== null && _a !== void 0 ? _a : {};\n      /**\n       * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame\n       * of spring animations so we should look into adding a disable spring option to `inertia`.\n       * We could do something here where we affect the `bounceStiffness` and `bounceDamping`\n       * using the value of `dragElastic`.\n       */\n      var bounceStiffness = dragElastic ? 200 : 1000000;\n      var bounceDamping = dragElastic ? 40 : 10000000;\n      var inertia = __assign(__assign({\n        type: \"inertia\",\n        velocity: dragMomentum ? velocity[axis] : 0,\n        bounceStiffness: bounceStiffness,\n        bounceDamping: bounceDamping,\n        timeConstant: 750,\n        restDelta: 1,\n        restSpeed: 10\n      }, dragTransition), transition);\n      // If we're not animating on an externally-provided `MotionValue` we can use the\n      // component's animation controls which will handle interactions with whileHover (etc),\n      // otherwise we just have to animate the `MotionValue` itself.\n      return _this.getAxisMotionValue(axis) ? _this.startAxisValueAnimation(axis, inertia) : _this.visualElement.startLayoutAnimation(axis, inertia, isRelative);\n    });\n    // Run all animations and then resolve the new drag constraints.\n    return Promise.all(momentumAnimations).then(function () {\n      var _a, _b;\n      (_b = (_a = _this.props).onDragTransitionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);\n    });\n  };\n  VisualElementDragControls.prototype.stopMotion = function () {\n    var _this = this;\n    eachAxis(function (axis) {\n      var axisValue = _this.getAxisMotionValue(axis);\n      axisValue ? axisValue.stop() : _this.visualElement.stopLayoutAnimation();\n    });\n  };\n  VisualElementDragControls.prototype.startAxisValueAnimation = function (axis, transition) {\n    var axisValue = this.getAxisMotionValue(axis);\n    if (!axisValue) return;\n    var currentValue = axisValue.get();\n    axisValue.set(currentValue);\n    axisValue.set(currentValue); // Set twice to hard-reset velocity\n    return startAnimation(axis, axisValue, 0, transition);\n  };\n  VisualElementDragControls.prototype.scalePoint = function () {\n    var _this = this;\n    var _a = this.props,\n      drag = _a.drag,\n      dragConstraints = _a.dragConstraints;\n    if (!isRefObject(dragConstraints) || !this.constraintsBox) return;\n    // Stop any current animations as there can be some visual glitching if we resize mid animation\n    this.stopMotion();\n    // Record the relative progress of the targetBox relative to the constraintsBox\n    var boxProgress = {\n      x: 0,\n      y: 0\n    };\n    eachAxis(function (axis) {\n      boxProgress[axis] = calcOrigin(_this.visualElement.projection.target[axis], _this.constraintsBox[axis]);\n    });\n    /**\n     * For each axis, calculate the current progress of the layout axis within the constraints.\n     * Then, using the latest layout and constraints measurements, reposition the new layout axis\n     * proportionally within the constraints.\n     */\n    this.updateConstraints(function () {\n      eachAxis(function (axis) {\n        if (!shouldDrag(axis, drag, null)) return;\n        // Calculate the position of the targetBox relative to the constraintsBox using the\n        // previously calculated progress\n        var _a = calcPositionFromProgress(_this.visualElement.projection.target[axis], _this.constraintsBox[axis], boxProgress[axis]),\n          min = _a.min,\n          max = _a.max;\n        _this.visualElement.setProjectionTargetAxis(axis, min, max);\n      });\n    });\n    /**\n     * If any other draggable components are queuing the same tasks synchronously\n     * this will wait until they've all been scheduled before flushing.\n     */\n    setTimeout(flushLayout, 1);\n  };\n  VisualElementDragControls.prototype.updateConstraints = function (onReady) {\n    var _this = this;\n    this.cancelLayout = batchLayout(function (read, write) {\n      var ancestors = collectProjectingAncestors(_this.visualElement);\n      write(function () {\n        return ancestors.forEach(function (element) {\n          return element.resetTransform();\n        });\n      });\n      read(function () {\n        return updateLayoutMeasurement(_this.visualElement);\n      });\n      write(function () {\n        return ancestors.forEach(function (element) {\n          return element.restoreTransform();\n        });\n      });\n      read(function () {\n        _this.resolveDragConstraints();\n      });\n      if (onReady) write(onReady);\n    });\n  };\n  VisualElementDragControls.prototype.mount = function (visualElement) {\n    var _this = this;\n    var element = visualElement.getInstance();\n    /**\n     * Attach a pointerdown event listener on this DOM element to initiate drag tracking.\n     */\n    var stopPointerListener = addPointerEvent(element, \"pointerdown\", function (event) {\n      var _a = _this.props,\n        drag = _a.drag,\n        _b = _a.dragListener,\n        dragListener = _b === void 0 ? true : _b;\n      drag && dragListener && _this.start(event);\n    });\n    /**\n     * Attach a window resize listener to scale the draggable target within its defined\n     * constraints as the window resizes.\n     */\n    var stopResizeListener = addDomEvent(window, \"resize\", function () {\n      _this.scalePoint();\n    });\n    /**\n     * Ensure drag constraints are resolved correctly relative to the dragging element\n     * whenever its layout changes.\n     */\n    var stopLayoutUpdateListener = visualElement.onLayoutUpdate(function () {\n      if (_this.isDragging) {\n        _this.resolveDragConstraints();\n      }\n    });\n    /**\n     * If the previous component with this same layoutId was dragging at the time\n     * it was unmounted, we want to continue the same gesture on this component.\n     */\n    var prevDragCursor = visualElement.prevDragCursor;\n    if (prevDragCursor) {\n      this.start(lastPointerEvent, {\n        cursorProgress: prevDragCursor\n      });\n    }\n    /**\n     * Return a function that will teardown the drag gesture\n     */\n    return function () {\n      stopPointerListener === null || stopPointerListener === void 0 ? void 0 : stopPointerListener();\n      stopResizeListener === null || stopResizeListener === void 0 ? void 0 : stopResizeListener();\n      stopLayoutUpdateListener === null || stopLayoutUpdateListener === void 0 ? void 0 : stopLayoutUpdateListener();\n      _this.cancelDrag();\n    };\n  };\n  return VisualElementDragControls;\n}();\nfunction shouldDrag(direction, drag, currentDirection) {\n  return (drag === true || drag === direction) && (currentDirection === null || currentDirection === direction);\n}\n/**\n * Based on an x/y offset determine the current drag direction. If both axis' offsets are lower\n * than the provided threshold, return `null`.\n *\n * @param offset - The x/y offset from origin.\n * @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.\n */\nfunction getCurrentDirection(offset, lockThreshold) {\n  if (lockThreshold === void 0) {\n    lockThreshold = 10;\n  }\n  var direction = null;\n  if (Math.abs(offset.y) > lockThreshold) {\n    direction = \"y\";\n  } else if (Math.abs(offset.x) > lockThreshold) {\n    direction = \"x\";\n  }\n  return direction;\n}\nexport { VisualElementDragControls, elementDragControls };","map":{"version":3,"names":["__rest","__assign","__spreadArray","__read","invariant","PanSession","getGlobalLock","isRefObject","addPointerEvent","addDomEvent","getViewportPointFromEvent","axisBox","convertAxisBoxToBoundingBox","convertBoundingBoxToAxisBox","eachAxis","calcRelativeConstraints","resolveDragElastic","rebaseAxisConstraints","calcViewportConstraints","applyConstraints","calcConstrainedMinPoint","calcPositionFromProgress","defaultElastic","getBoundingBox","calcOrigin","startAnimation","AnimationType","collectProjectingAncestors","updateLayoutMeasurement","collectProjectingChildren","progress","convertToRelativeProjection","calcRelativeOffset","flushLayout","batchLayout","flushSync","elementDragControls","WeakMap","lastPointerEvent","VisualElementDragControls","_a","visualElement","isDragging","currentDirection","constraints","elastic","props","hasMutatedConstraints","cursorProgress","x","y","originPoint","openGlobalLock","panSession","enableLayoutProjection","set","prototype","start","originEvent","_this","_b","_c","snapToCursor","onSessionStart","event","stopMotion","initialPoint","point","cancelLayout","call","read","write","ancestors","children","tree","hasManuallySetCursorOrigin","isLayoutDrag","lockProjectionTarget","forEach","element","resetTransform","restoreTransform","isRelativeDrag","Boolean","getAxisMotionValue","isExternalDrag","rebaseProjectionTarget","measureViewportBox","scheduleUpdateLayoutProjection","projection","axis","target","min","max","axisValue","get","update","preRender","render","postRender","resolveDragConstraints","onStart","info","_d","drag","dragPropagation","onDragStart","animationState","setActive","Drag","onMove","_e","dragDirectionLock","offset","getCurrentDirection","onDirectionLock","updateAxis","onDrag","onSessionEnd","stop","transformPagePoint","dragConstraints","dragElastic","layout","getLayoutState","layoutCorrected","resolveRefConstraints","layoutBox","onMeasureDragConstraints","constraintsElement","current","constraintsBox","measuredConstraints","userConstraints","cancelDrag","unlockProjectionTarget","end","velocity","animateDragEnd","onDragEnd","shouldDrag","box","length_1","center","includes","updateAxisMotionValue","updateVisualElementAxis","nextValue","axisLayout","axisLength","axisProgress","setProjectionTargetAxis","setProps","_f","_g","dragMomentum","remainingProps","layoutId","dragKey","toUpperCase","undefined","getValue","_dragX","_dragY","dragTransition","isRelative","Object","keys","length","projectionParent","getProjectionParent","relativeConstraints_1","targetFinal","isNaN","momentumAnimations","transition","bounceStiffness","bounceDamping","inertia","type","timeConstant","restDelta","restSpeed","startAxisValueAnimation","startLayoutAnimation","Promise","all","then","onDragTransitionEnd","stopLayoutAnimation","currentValue","scalePoint","boxProgress","updateConstraints","setTimeout","onReady","mount","getInstance","stopPointerListener","dragListener","stopResizeListener","window","stopLayoutUpdateListener","onLayoutUpdate","prevDragCursor","direction","lockThreshold","Math","abs"],"sources":["D:/DSP_Management/node_modules/framer-motion/dist/es/gestures/drag/VisualElementDragControls.js"],"sourcesContent":["import { __rest, __assign, __spreadArray, __read } from 'tslib';\nimport { invariant } from 'hey-listen';\nimport { PanSession } from '../PanSession.js';\nimport { getGlobalLock } from './utils/lock.js';\nimport { isRefObject } from '../../utils/is-ref-object.js';\nimport { addPointerEvent } from '../../events/use-pointer-event.js';\nimport { addDomEvent } from '../../events/use-dom-event.js';\nimport { getViewportPointFromEvent } from '../../events/event-info.js';\nimport { axisBox, convertAxisBoxToBoundingBox, convertBoundingBoxToAxisBox } from '../../utils/geometry/index.js';\nimport { eachAxis } from '../../utils/each-axis.js';\nimport { calcRelativeConstraints, resolveDragElastic, rebaseAxisConstraints, calcViewportConstraints, applyConstraints, calcConstrainedMinPoint, calcPositionFromProgress, defaultElastic } from './utils/constraints.js';\nimport { getBoundingBox } from '../../render/dom/projection/measure.js';\nimport { calcOrigin } from '../../utils/geometry/delta-calc.js';\nimport { startAnimation } from '../../animation/utils/transitions.js';\nimport { AnimationType } from '../../render/utils/types.js';\nimport { collectProjectingAncestors, updateLayoutMeasurement, collectProjectingChildren } from '../../render/dom/projection/utils.js';\nimport { progress } from 'popmotion';\nimport { convertToRelativeProjection } from '../../render/dom/projection/convert-to-relative.js';\nimport { calcRelativeOffset } from '../../motion/features/layout/utils.js';\nimport { flushLayout, batchLayout } from '../../render/dom/utils/batch-layout.js';\nimport { flushSync } from 'framesync';\n\nvar elementDragControls = new WeakMap();\n/**\n *\n */\nvar lastPointerEvent;\nvar VisualElementDragControls = /** @class */ (function () {\n    function VisualElementDragControls(_a) {\n        var visualElement = _a.visualElement;\n        /**\n         * Track whether we're currently dragging.\n         *\n         * @internal\n         */\n        this.isDragging = false;\n        /**\n         * The current direction of drag, or `null` if both.\n         *\n         * @internal\n         */\n        this.currentDirection = null;\n        /**\n         * The permitted boundaries of travel, in pixels.\n         *\n         * @internal\n         */\n        this.constraints = false;\n        /**\n         * The per-axis resolved elastic values.\n         *\n         * @internal\n         */\n        this.elastic = axisBox();\n        /**\n         * A reference to the host component's latest props.\n         *\n         * @internal\n         */\n        this.props = {};\n        /**\n         * @internal\n         */\n        this.hasMutatedConstraints = false;\n        /**\n         * Track the initial position of the cursor relative to the dragging element\n         * when dragging starts as a value of 0-1 on each axis. We then use this to calculate\n         * an ideal bounding box for the VisualElement renderer to project into every frame.\n         *\n         * @internal\n         */\n        this.cursorProgress = {\n            x: 0.5,\n            y: 0.5,\n        };\n        // When updating _dragX, or _dragY instead of the VisualElement,\n        // persist their values between drag gestures.\n        this.originPoint = {};\n        // This is a reference to the global drag gesture lock, ensuring only one component\n        // can \"capture\" the drag of one or both axes.\n        // TODO: Look into moving this into pansession?\n        this.openGlobalLock = null;\n        /**\n         * @internal\n         */\n        this.panSession = null;\n        this.visualElement = visualElement;\n        this.visualElement.enableLayoutProjection();\n        elementDragControls.set(visualElement, this);\n    }\n    /**\n     * Instantiate a PanSession for the drag gesture\n     *\n     * @public\n     */\n    VisualElementDragControls.prototype.start = function (originEvent, _a) {\n        var _this = this;\n        var _b = _a === void 0 ? {} : _a, _c = _b.snapToCursor, snapToCursor = _c === void 0 ? false : _c, cursorProgress = _b.cursorProgress;\n        var onSessionStart = function (event) {\n            var _a;\n            // Stop any animations on both axis values immediately. This allows the user to throw and catch\n            // the component.\n            _this.stopMotion();\n            /**\n             * Save the initial point. We'll use this to calculate the pointer's position rather\n             * than the one we receive when the gesture actually starts. By then, the pointer will\n             * have already moved, and the perception will be of the pointer \"slipping\" across the element\n             */\n            var initialPoint = getViewportPointFromEvent(event).point;\n            (_a = _this.cancelLayout) === null || _a === void 0 ? void 0 : _a.call(_this);\n            _this.cancelLayout = batchLayout(function (read, write) {\n                var ancestors = collectProjectingAncestors(_this.visualElement);\n                var children = collectProjectingChildren(_this.visualElement);\n                var tree = __spreadArray(__spreadArray([], __read(ancestors)), __read(children));\n                var hasManuallySetCursorOrigin = false;\n                /**\n                 * Apply a simple lock to the projection target. This ensures no animations\n                 * can run on the projection box while this lock is active.\n                 */\n                _this.isLayoutDrag() && _this.visualElement.lockProjectionTarget();\n                write(function () {\n                    tree.forEach(function (element) { return element.resetTransform(); });\n                });\n                read(function () {\n                    updateLayoutMeasurement(_this.visualElement);\n                    children.forEach(updateLayoutMeasurement);\n                });\n                write(function () {\n                    tree.forEach(function (element) { return element.restoreTransform(); });\n                    if (snapToCursor) {\n                        hasManuallySetCursorOrigin = _this.snapToCursor(initialPoint);\n                    }\n                });\n                read(function () {\n                    var isRelativeDrag = Boolean(_this.getAxisMotionValue(\"x\") && !_this.isExternalDrag());\n                    if (!isRelativeDrag) {\n                        _this.visualElement.rebaseProjectionTarget(true, _this.visualElement.measureViewportBox(false));\n                    }\n                    _this.visualElement.scheduleUpdateLayoutProjection();\n                    /**\n                     * When dragging starts, we want to find where the cursor is relative to the bounding box\n                     * of the element. Every frame, we calculate a new bounding box using this relative position\n                     * and let the visualElement renderer figure out how to reproject the element into this bounding\n                     * box.\n                     *\n                     * By doing it this way, rather than applying an x/y transform directly to the element,\n                     * we can ensure the component always visually sticks to the cursor as we'd expect, even\n                     * if the DOM element itself changes layout as a result of React updates the user might\n                     * make based on the drag position.\n                     */\n                    var projection = _this.visualElement.projection;\n                    eachAxis(function (axis) {\n                        if (!hasManuallySetCursorOrigin) {\n                            var _a = projection.target[axis], min = _a.min, max = _a.max;\n                            _this.cursorProgress[axis] = cursorProgress\n                                ? cursorProgress[axis]\n                                : progress(min, max, initialPoint[axis]);\n                        }\n                        /**\n                         * If we have external drag MotionValues, record their origin point. On pointermove\n                         * we'll apply the pan gesture offset directly to this value.\n                         */\n                        var axisValue = _this.getAxisMotionValue(axis);\n                        if (axisValue) {\n                            _this.originPoint[axis] = axisValue.get();\n                        }\n                    });\n                });\n                write(function () {\n                    flushSync.update();\n                    flushSync.preRender();\n                    flushSync.render();\n                    flushSync.postRender();\n                });\n                read(function () { return _this.resolveDragConstraints(); });\n            });\n        };\n        var onStart = function (event, info) {\n            var _a, _b, _c;\n            // Attempt to grab the global drag gesture lock - maybe make this part of PanSession\n            var _d = _this.props, drag = _d.drag, dragPropagation = _d.dragPropagation;\n            if (drag && !dragPropagation) {\n                if (_this.openGlobalLock)\n                    _this.openGlobalLock();\n                _this.openGlobalLock = getGlobalLock(drag);\n                // If we don 't have the lock, don't start dragging\n                if (!_this.openGlobalLock)\n                    return;\n            }\n            flushLayout();\n            // Set current drag status\n            _this.isDragging = true;\n            _this.currentDirection = null;\n            // Fire onDragStart event\n            (_b = (_a = _this.props).onDragStart) === null || _b === void 0 ? void 0 : _b.call(_a, event, info);\n            (_c = _this.visualElement.animationState) === null || _c === void 0 ? void 0 : _c.setActive(AnimationType.Drag, true);\n        };\n        var onMove = function (event, info) {\n            var _a, _b, _c, _d;\n            var _e = _this.props, dragPropagation = _e.dragPropagation, dragDirectionLock = _e.dragDirectionLock;\n            // If we didn't successfully receive the gesture lock, early return.\n            if (!dragPropagation && !_this.openGlobalLock)\n                return;\n            var offset = info.offset;\n            // Attempt to detect drag direction if directionLock is true\n            if (dragDirectionLock && _this.currentDirection === null) {\n                _this.currentDirection = getCurrentDirection(offset);\n                // If we've successfully set a direction, notify listener\n                if (_this.currentDirection !== null) {\n                    (_b = (_a = _this.props).onDirectionLock) === null || _b === void 0 ? void 0 : _b.call(_a, _this.currentDirection);\n                }\n                return;\n            }\n            // Update each point with the latest position\n            _this.updateAxis(\"x\", info.point, offset);\n            _this.updateAxis(\"y\", info.point, offset);\n            // Fire onDrag event\n            (_d = (_c = _this.props).onDrag) === null || _d === void 0 ? void 0 : _d.call(_c, event, info);\n            // Update the last pointer event\n            lastPointerEvent = event;\n        };\n        var onSessionEnd = function (event, info) {\n            return _this.stop(event, info);\n        };\n        var transformPagePoint = this.props.transformPagePoint;\n        this.panSession = new PanSession(originEvent, {\n            onSessionStart: onSessionStart,\n            onStart: onStart,\n            onMove: onMove,\n            onSessionEnd: onSessionEnd,\n        }, { transformPagePoint: transformPagePoint });\n    };\n    VisualElementDragControls.prototype.resolveDragConstraints = function () {\n        var _this = this;\n        var _a = this.props, dragConstraints = _a.dragConstraints, dragElastic = _a.dragElastic;\n        var layout = this.visualElement.getLayoutState().layoutCorrected;\n        if (dragConstraints) {\n            this.constraints = isRefObject(dragConstraints)\n                ? this.resolveRefConstraints(layout, dragConstraints)\n                : calcRelativeConstraints(layout, dragConstraints);\n        }\n        else {\n            this.constraints = false;\n        }\n        this.elastic = resolveDragElastic(dragElastic);\n        /**\n         * If we're outputting to external MotionValues, we want to rebase the measured constraints\n         * from viewport-relative to component-relative.\n         */\n        if (this.constraints && !this.hasMutatedConstraints) {\n            eachAxis(function (axis) {\n                if (_this.getAxisMotionValue(axis)) {\n                    _this.constraints[axis] = rebaseAxisConstraints(layout[axis], _this.constraints[axis]);\n                }\n            });\n        }\n    };\n    VisualElementDragControls.prototype.resolveRefConstraints = function (layoutBox, constraints) {\n        var _a = this.props, onMeasureDragConstraints = _a.onMeasureDragConstraints, transformPagePoint = _a.transformPagePoint;\n        var constraintsElement = constraints.current;\n        invariant(constraintsElement !== null, \"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.\");\n        this.constraintsBox = getBoundingBox(constraintsElement, transformPagePoint);\n        var measuredConstraints = calcViewportConstraints(layoutBox, this.constraintsBox);\n        /**\n         * If there's an onMeasureDragConstraints listener we call it and\n         * if different constraints are returned, set constraints to that\n         */\n        if (onMeasureDragConstraints) {\n            var userConstraints = onMeasureDragConstraints(convertAxisBoxToBoundingBox(measuredConstraints));\n            this.hasMutatedConstraints = !!userConstraints;\n            if (userConstraints) {\n                measuredConstraints = convertBoundingBoxToAxisBox(userConstraints);\n            }\n        }\n        return measuredConstraints;\n    };\n    VisualElementDragControls.prototype.cancelDrag = function () {\n        var _a, _b;\n        this.visualElement.unlockProjectionTarget();\n        (_a = this.cancelLayout) === null || _a === void 0 ? void 0 : _a.call(this);\n        this.isDragging = false;\n        this.panSession && this.panSession.end();\n        this.panSession = null;\n        if (!this.props.dragPropagation && this.openGlobalLock) {\n            this.openGlobalLock();\n            this.openGlobalLock = null;\n        }\n        (_b = this.visualElement.animationState) === null || _b === void 0 ? void 0 : _b.setActive(AnimationType.Drag, false);\n    };\n    VisualElementDragControls.prototype.stop = function (event, info) {\n        var _a, _b, _c;\n        (_a = this.panSession) === null || _a === void 0 ? void 0 : _a.end();\n        this.panSession = null;\n        var isDragging = this.isDragging;\n        this.cancelDrag();\n        if (!isDragging)\n            return;\n        var velocity = info.velocity;\n        this.animateDragEnd(velocity);\n        (_c = (_b = this.props).onDragEnd) === null || _c === void 0 ? void 0 : _c.call(_b, event, info);\n    };\n    VisualElementDragControls.prototype.snapToCursor = function (point) {\n        var _this = this;\n        return eachAxis(function (axis) {\n            var drag = _this.props.drag;\n            // If we're not dragging this axis, do an early return.\n            if (!shouldDrag(axis, drag, _this.currentDirection))\n                return;\n            var axisValue = _this.getAxisMotionValue(axis);\n            if (axisValue) {\n                var box = _this.visualElement.getLayoutState().layout;\n                var length_1 = box[axis].max - box[axis].min;\n                var center = box[axis].min + length_1 / 2;\n                var offset = point[axis] - center;\n                _this.originPoint[axis] = point[axis];\n                axisValue.set(offset);\n            }\n            else {\n                _this.cursorProgress[axis] = 0.5;\n                return true;\n            }\n        }).includes(true);\n    };\n    /**\n     * Update the specified axis with the latest pointer information.\n     */\n    VisualElementDragControls.prototype.updateAxis = function (axis, point, offset) {\n        var drag = this.props.drag;\n        // If we're not dragging this axis, do an early return.\n        if (!shouldDrag(axis, drag, this.currentDirection))\n            return;\n        return this.getAxisMotionValue(axis)\n            ? this.updateAxisMotionValue(axis, offset)\n            : this.updateVisualElementAxis(axis, point);\n    };\n    VisualElementDragControls.prototype.updateAxisMotionValue = function (axis, offset) {\n        var axisValue = this.getAxisMotionValue(axis);\n        if (!offset || !axisValue)\n            return;\n        var nextValue = this.originPoint[axis] + offset[axis];\n        var update = this.constraints\n            ? applyConstraints(nextValue, this.constraints[axis], this.elastic[axis])\n            : nextValue;\n        axisValue.set(update);\n    };\n    VisualElementDragControls.prototype.updateVisualElementAxis = function (axis, point) {\n        var _a;\n        // Get the actual layout bounding box of the element\n        var axisLayout = this.visualElement.getLayoutState().layout[axis];\n        // Calculate its current length. In the future we might want to lerp this to animate\n        // between lengths if the layout changes as we change the DOM\n        var axisLength = axisLayout.max - axisLayout.min;\n        // Get the initial progress that the pointer sat on this axis on gesture start.\n        var axisProgress = this.cursorProgress[axis];\n        // Calculate a new min point based on the latest pointer position, constraints and elastic\n        var min = calcConstrainedMinPoint(point[axis], axisLength, axisProgress, (_a = this.constraints) === null || _a === void 0 ? void 0 : _a[axis], this.elastic[axis]);\n        // Update the axis viewport target with this new min and the length\n        this.visualElement.setProjectionTargetAxis(axis, min, min + axisLength);\n    };\n    VisualElementDragControls.prototype.setProps = function (_a) {\n        var _b = _a.drag, drag = _b === void 0 ? false : _b, _c = _a.dragDirectionLock, dragDirectionLock = _c === void 0 ? false : _c, _d = _a.dragPropagation, dragPropagation = _d === void 0 ? false : _d, _e = _a.dragConstraints, dragConstraints = _e === void 0 ? false : _e, _f = _a.dragElastic, dragElastic = _f === void 0 ? defaultElastic : _f, _g = _a.dragMomentum, dragMomentum = _g === void 0 ? true : _g, remainingProps = __rest(_a, [\"drag\", \"dragDirectionLock\", \"dragPropagation\", \"dragConstraints\", \"dragElastic\", \"dragMomentum\"]);\n        this.props = __assign({ drag: drag,\n            dragDirectionLock: dragDirectionLock,\n            dragPropagation: dragPropagation,\n            dragConstraints: dragConstraints,\n            dragElastic: dragElastic,\n            dragMomentum: dragMomentum }, remainingProps);\n    };\n    /**\n     * Drag works differently depending on which props are provided.\n     *\n     * - If _dragX and _dragY are provided, we output the gesture delta directly to those motion values.\n     * - If the component will perform layout animations, we output the gesture to the component's\n     *      visual bounding box\n     * - Otherwise, we apply the delta to the x/y motion values.\n     */\n    VisualElementDragControls.prototype.getAxisMotionValue = function (axis) {\n        var _a = this.props, layout = _a.layout, layoutId = _a.layoutId;\n        var dragKey = \"_drag\" + axis.toUpperCase();\n        if (this.props[dragKey]) {\n            return this.props[dragKey];\n        }\n        else if (!layout && layoutId === undefined) {\n            return this.visualElement.getValue(axis, 0);\n        }\n    };\n    VisualElementDragControls.prototype.isLayoutDrag = function () {\n        return !this.getAxisMotionValue(\"x\");\n    };\n    VisualElementDragControls.prototype.isExternalDrag = function () {\n        var _a = this.props, _dragX = _a._dragX, _dragY = _a._dragY;\n        return _dragX || _dragY;\n    };\n    VisualElementDragControls.prototype.animateDragEnd = function (velocity) {\n        var _this = this;\n        var _a = this.props, drag = _a.drag, dragMomentum = _a.dragMomentum, dragElastic = _a.dragElastic, dragTransition = _a.dragTransition;\n        /**\n         * Everything beyond the drag gesture should be performed with\n         * relative projection so children stay in sync with their parent element.\n         */\n        var isRelative = convertToRelativeProjection(this.visualElement, this.isLayoutDrag() && !this.isExternalDrag());\n        /**\n         * If we had previously resolved constraints relative to the viewport,\n         * we need to also convert those to a relative coordinate space for the animation\n         */\n        var constraints = this.constraints || {};\n        if (isRelative &&\n            Object.keys(constraints).length &&\n            this.isLayoutDrag()) {\n            var projectionParent = this.visualElement.getProjectionParent();\n            if (projectionParent) {\n                var relativeConstraints_1 = calcRelativeOffset(projectionParent.projection.targetFinal, constraints);\n                eachAxis(function (axis) {\n                    var _a = relativeConstraints_1[axis], min = _a.min, max = _a.max;\n                    constraints[axis] = {\n                        min: isNaN(min) ? undefined : min,\n                        max: isNaN(max) ? undefined : max,\n                    };\n                });\n            }\n        }\n        var momentumAnimations = eachAxis(function (axis) {\n            var _a;\n            if (!shouldDrag(axis, drag, _this.currentDirection)) {\n                return;\n            }\n            var transition = (_a = constraints === null || constraints === void 0 ? void 0 : constraints[axis]) !== null && _a !== void 0 ? _a : {};\n            /**\n             * Overdamp the boundary spring if `dragElastic` is disabled. There's still a frame\n             * of spring animations so we should look into adding a disable spring option to `inertia`.\n             * We could do something here where we affect the `bounceStiffness` and `bounceDamping`\n             * using the value of `dragElastic`.\n             */\n            var bounceStiffness = dragElastic ? 200 : 1000000;\n            var bounceDamping = dragElastic ? 40 : 10000000;\n            var inertia = __assign(__assign({ type: \"inertia\", velocity: dragMomentum ? velocity[axis] : 0, bounceStiffness: bounceStiffness,\n                bounceDamping: bounceDamping, timeConstant: 750, restDelta: 1, restSpeed: 10 }, dragTransition), transition);\n            // If we're not animating on an externally-provided `MotionValue` we can use the\n            // component's animation controls which will handle interactions with whileHover (etc),\n            // otherwise we just have to animate the `MotionValue` itself.\n            return _this.getAxisMotionValue(axis)\n                ? _this.startAxisValueAnimation(axis, inertia)\n                : _this.visualElement.startLayoutAnimation(axis, inertia, isRelative);\n        });\n        // Run all animations and then resolve the new drag constraints.\n        return Promise.all(momentumAnimations).then(function () {\n            var _a, _b;\n            (_b = (_a = _this.props).onDragTransitionEnd) === null || _b === void 0 ? void 0 : _b.call(_a);\n        });\n    };\n    VisualElementDragControls.prototype.stopMotion = function () {\n        var _this = this;\n        eachAxis(function (axis) {\n            var axisValue = _this.getAxisMotionValue(axis);\n            axisValue\n                ? axisValue.stop()\n                : _this.visualElement.stopLayoutAnimation();\n        });\n    };\n    VisualElementDragControls.prototype.startAxisValueAnimation = function (axis, transition) {\n        var axisValue = this.getAxisMotionValue(axis);\n        if (!axisValue)\n            return;\n        var currentValue = axisValue.get();\n        axisValue.set(currentValue);\n        axisValue.set(currentValue); // Set twice to hard-reset velocity\n        return startAnimation(axis, axisValue, 0, transition);\n    };\n    VisualElementDragControls.prototype.scalePoint = function () {\n        var _this = this;\n        var _a = this.props, drag = _a.drag, dragConstraints = _a.dragConstraints;\n        if (!isRefObject(dragConstraints) || !this.constraintsBox)\n            return;\n        // Stop any current animations as there can be some visual glitching if we resize mid animation\n        this.stopMotion();\n        // Record the relative progress of the targetBox relative to the constraintsBox\n        var boxProgress = { x: 0, y: 0 };\n        eachAxis(function (axis) {\n            boxProgress[axis] = calcOrigin(_this.visualElement.projection.target[axis], _this.constraintsBox[axis]);\n        });\n        /**\n         * For each axis, calculate the current progress of the layout axis within the constraints.\n         * Then, using the latest layout and constraints measurements, reposition the new layout axis\n         * proportionally within the constraints.\n         */\n        this.updateConstraints(function () {\n            eachAxis(function (axis) {\n                if (!shouldDrag(axis, drag, null))\n                    return;\n                // Calculate the position of the targetBox relative to the constraintsBox using the\n                // previously calculated progress\n                var _a = calcPositionFromProgress(_this.visualElement.projection.target[axis], _this.constraintsBox[axis], boxProgress[axis]), min = _a.min, max = _a.max;\n                _this.visualElement.setProjectionTargetAxis(axis, min, max);\n            });\n        });\n        /**\n         * If any other draggable components are queuing the same tasks synchronously\n         * this will wait until they've all been scheduled before flushing.\n         */\n        setTimeout(flushLayout, 1);\n    };\n    VisualElementDragControls.prototype.updateConstraints = function (onReady) {\n        var _this = this;\n        this.cancelLayout = batchLayout(function (read, write) {\n            var ancestors = collectProjectingAncestors(_this.visualElement);\n            write(function () {\n                return ancestors.forEach(function (element) { return element.resetTransform(); });\n            });\n            read(function () { return updateLayoutMeasurement(_this.visualElement); });\n            write(function () {\n                return ancestors.forEach(function (element) { return element.restoreTransform(); });\n            });\n            read(function () {\n                _this.resolveDragConstraints();\n            });\n            if (onReady)\n                write(onReady);\n        });\n    };\n    VisualElementDragControls.prototype.mount = function (visualElement) {\n        var _this = this;\n        var element = visualElement.getInstance();\n        /**\n         * Attach a pointerdown event listener on this DOM element to initiate drag tracking.\n         */\n        var stopPointerListener = addPointerEvent(element, \"pointerdown\", function (event) {\n            var _a = _this.props, drag = _a.drag, _b = _a.dragListener, dragListener = _b === void 0 ? true : _b;\n            drag && dragListener && _this.start(event);\n        });\n        /**\n         * Attach a window resize listener to scale the draggable target within its defined\n         * constraints as the window resizes.\n         */\n        var stopResizeListener = addDomEvent(window, \"resize\", function () {\n            _this.scalePoint();\n        });\n        /**\n         * Ensure drag constraints are resolved correctly relative to the dragging element\n         * whenever its layout changes.\n         */\n        var stopLayoutUpdateListener = visualElement.onLayoutUpdate(function () {\n            if (_this.isDragging) {\n                _this.resolveDragConstraints();\n            }\n        });\n        /**\n         * If the previous component with this same layoutId was dragging at the time\n         * it was unmounted, we want to continue the same gesture on this component.\n         */\n        var prevDragCursor = visualElement.prevDragCursor;\n        if (prevDragCursor) {\n            this.start(lastPointerEvent, { cursorProgress: prevDragCursor });\n        }\n        /**\n         * Return a function that will teardown the drag gesture\n         */\n        return function () {\n            stopPointerListener === null || stopPointerListener === void 0 ? void 0 : stopPointerListener();\n            stopResizeListener === null || stopResizeListener === void 0 ? void 0 : stopResizeListener();\n            stopLayoutUpdateListener === null || stopLayoutUpdateListener === void 0 ? void 0 : stopLayoutUpdateListener();\n            _this.cancelDrag();\n        };\n    };\n    return VisualElementDragControls;\n}());\nfunction shouldDrag(direction, drag, currentDirection) {\n    return ((drag === true || drag === direction) &&\n        (currentDirection === null || currentDirection === direction));\n}\n/**\n * Based on an x/y offset determine the current drag direction. If both axis' offsets are lower\n * than the provided threshold, return `null`.\n *\n * @param offset - The x/y offset from origin.\n * @param lockThreshold - (Optional) - the minimum absolute offset before we can determine a drag direction.\n */\nfunction getCurrentDirection(offset, lockThreshold) {\n    if (lockThreshold === void 0) { lockThreshold = 10; }\n    var direction = null;\n    if (Math.abs(offset.y) > lockThreshold) {\n        direction = \"y\";\n    }\n    else if (Math.abs(offset.x) > lockThreshold) {\n        direction = \"x\";\n    }\n    return direction;\n}\n\nexport { VisualElementDragControls, elementDragControls };\n"],"mappings":"AAAA,SAASA,MAAM,EAAEC,QAAQ,EAAEC,aAAa,EAAEC,MAAM,QAAQ,OAAO;AAC/D,SAASC,SAAS,QAAQ,YAAY;AACtC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,aAAa,QAAQ,iBAAiB;AAC/C,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,eAAe,QAAQ,mCAAmC;AACnE,SAASC,WAAW,QAAQ,+BAA+B;AAC3D,SAASC,yBAAyB,QAAQ,4BAA4B;AACtE,SAASC,OAAO,EAAEC,2BAA2B,EAAEC,2BAA2B,QAAQ,+BAA+B;AACjH,SAASC,QAAQ,QAAQ,0BAA0B;AACnD,SAASC,uBAAuB,EAAEC,kBAAkB,EAAEC,qBAAqB,EAAEC,uBAAuB,EAAEC,gBAAgB,EAAEC,uBAAuB,EAAEC,wBAAwB,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