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BAAe,EAWf,KAAK,SAAS,YACf,KAAK,SAAS,cAAa,CAEnC,CACH,E,6MCjDD,IAAME,EACDC,GAA8B,CAACC,EAAqBC,IAAiB,CAC9DF,GACAG,GAAM,OAAO,IAAMH,EAAQC,EAAOC,CAAI,EAAG,GAAO,EAAI,CAE5D,EAESE,EAAP,cAA0BC,EAAgB,CAAhD,aAAA,qBAGY,KAAA,0BAAsCC,EA8ClD,CA5CI,cAAcC,EAA8B,CACxC,KAAK,QAAU,IAAIC,EACfD,EACA,KAAK,kBAAiB,EACtB,CACI,mBAAoB,KAAK,KAAK,sBAAqB,EACnD,cAAeE,EAAiB,KAAK,IAAI,CAC5C,CAAA,CAET,CAEA,mBAAiB,CACb,GAAM,CAAE,kBAAAC,EAAmB,WAAAC,EAAY,MAAAC,EAAO,SAAAC,CAAQ,EAClD,KAAK,KAAK,SAAQ,EAEtB,MAAO,CACH,eAAgBd,EAAaW,CAAiB,EAC9C,QAASX,EAAaY,CAAU,EAChC,OAAQZ,EAAaa,CAAK,EAC1B,MAAO,CAACX,EAAqBC,IAAiB,CAC1C,OAAO,KAAK,QACRW,GACAV,GAAM,WAAW,IAAMU,EAASZ,EAAOC,CAAI,CAAC,CAEpD,EAER,CAEA,OAAK,CACD,KAAK,0BAA4BY,GAC7B,KAAK,KAAK,QACV,cACCb,GAAwB,KAAK,cAAcA,CAAK,CAAC,CAE1D,CAEA,QAAM,CACF,KAAK,SAAW,KAAK,QAAQ,eAAe,KAAK,kBAAiB,CAAE,CACxE,CAEA,SAAO,CACH,KAAK,0BAAyB,EAC9B,KAAK,SAAW,KAAK,QAAQ,IAAG,CACpC,CACH,uICzDM,IAAMc,GAAwB,CACjC,IAAK,CACD,QAASC,CACZ,EACD,KAAM,CACF,QAASC,EACT,eAAgBC,GAChB,cAAAC,EACH","names":["getContextWindow","current","overflowStyles","PanSession","event","handlers","transformPagePoint","contextWindow","dragSnapToOrigin","distanceThreshold","element","transformPoint","info","getPanInfo","isPanStarted","isDistancePastThreshold","distance2D","point","timestamp","frameData","onStart","onMove","frame","onEnd","onSessionEnd","resumeAnimation","panInfo","isPrimaryPointer","extractEventInfo","initialInfo","onSessionStart","pipe","addPointerEvent","current","style","target","initial","isWindow","delta","cancelFrame","subtractPoint","a","b","history","lastDevicePoint","startDevicePoint","getVelocity","timeDelta","i","timestampedPoint","lastPoint","secondsToMilliseconds","time","millisecondsToSeconds","currentVelocity","applyConstraints","point","min","max","elastic","mixNumber","calcRelativeAxisConstraints","axis","calcRelativeConstraints","layoutBox","top","left","bottom","right","calcViewportAxisConstraints","layoutAxis","constraintsAxis","calcViewportConstraints","constraintsBox","calcOrigin","source","target","origin","sourceLength","calcLength","targetLength","calcProgress","clamp","rebaseAxisConstraints","layout","constraints","relativeConstraints","defaultElastic","resolveDragElastic","dragElastic","resolveAxisElastic","minLabel","maxLabel","resolvePointElastic","label","elementDragControls","VisualElementDragControls","visualElement","createBox","originEvent","snapToCursor","distanceThreshold","presenceContext","onSessionStart","event","extractEventInfo","onStart","info","drag","dragPropagation","onDragStart","setDragLock","eachAxis","axis","current","percent","projection","measuredAxis","calcLength","frame","addValueToWillChange","animationState","onMove","dragDirectionLock","onDirectionLock","onDrag","offset","getCurrentDirection","onSessionEnd","resumeAnimation","snap","dragSnapToOrigin","PanSession","getContextWindow","panInfo","finalEvent","finalPanInfo","isDragging","velocity","onDragEnd","_point","shouldDrag","axisValue","next","applyConstraints","dragConstraints","dragElastic","layout","prevConstraints","isRefObject","calcRelativeConstraints","resolveDragElastic","rebaseAxisConstraints","constraints","onMeasureDragConstraints","constraintsElement","invariant","constraintsBox","measurePageBox","measuredConstraints","calcViewportConstraints","userConstraints","convertBoxToBoundingBox","convertBoundingBoxToBox","dragMomentum","dragTransition","onDragTransitionEnd","momentumAnimations","transition","bounceStiffness","bounceDamping","inertia","animateMotionValue","dragKey","props","externalMotionValue","point","min","max","mixNumber","boxProgress","latest","calcOrigin","transformTemplate","element","stopPointerListener","addPointerEvent","dragListener","target","isClickingTextInputChild","isElementTextInput","stopResizeObservers","measureDragConstraints","startResizeObservers","stopMeasureLayoutListener","stopResizeListener","addDomEvent","stopLayoutUpdateListener","delta","hasLayoutChanged","motionValue","defaultElastic","skipFirstCall","callback","isFirst","onResize","stopElement","resize","stopContainer","direction","currentDirection","lockThreshold","DragGesture","Feature","node","noop","VisualElementDragControls","dragControls","prevDragControls","asyncHandler","handler","event","info","frame","PanGesture","Feature","noop","pointerDownEvent","PanSession","getContextWindow","onPanSessionStart","onPanStart","onPan","onPanEnd","addPointerEvent","drag","PanGesture","DragGesture","HTMLProjectionNode","MeasureLayout"],"sources":["../esm/npm/framer-motion@12.38.0/node_modules/framer-motion/src/utils/get-context-window.ts","../esm/npm/framer-motion@12.38.0/node_modules/framer-motion/src/gestures/pan/PanSession.ts","../esm/npm/framer-motion@12.38.0/node_modules/framer-motion/src/gestures/drag/utils/constraints.ts","../esm/npm/framer-motion@12.38.0/node_modules/framer-motion/src/gestures/drag/VisualElementDragControls.ts","../esm/npm/framer-motion@12.38.0/node_modules/framer-motion/src/gestures/drag/index.ts","../esm/npm/framer-motion@12.38.0/node_modules/framer-motion/src/gestures/pan/index.ts","../esm/npm/framer-motion@12.38.0/node_modules/framer-motion/src/motion/features/drag.ts"],"sourcesContent":["import type { VisualElement } from \"motion-dom\"\n\n// Fixes https://github.com/motiondivision/motion/issues/2270\nexport const getContextWindow = ({ current }: VisualElement\u003cElement\u003e) =\u003e {\n    return current ? current.ownerDocument.defaultView : null\n}\n","import type { EventInfo, PanHandler } from \"motion-dom\"\nimport { cancelFrame, frame, frameData, isPrimaryPointer } from \"motion-dom\"\nimport {\n    millisecondsToSeconds,\n    pipe,\n    Point,\n    secondsToMilliseconds,\n    TransformPoint,\n} from \"motion-utils\"\nimport { addPointerEvent } from \"../../events/add-pointer-event\"\nimport { extractEventInfo } from \"../../events/event-info\"\nimport { distance2D } from \"../../utils/distance\"\n\ninterface PanSessionHandlers {\n    onSessionStart: PanHandler\n    onStart: PanHandler\n    onMove: PanHandler\n    onEnd: PanHandler\n    onSessionEnd: PanHandler\n    resumeAnimation: () =\u003e void\n}\n\ninterface PanSessionOptions {\n    transformPagePoint?: TransformPoint\n    dragSnapToOrigin?: boolean | \"x\" | \"y\"\n    distanceThreshold?: number\n    contextWindow?: (Window \u0026 typeof globalThis) | null\n    /**\n     * Element being dragged. When provided, scroll events on its\n     * ancestors and window are compensated so the gesture continues\n     * smoothly during scroll.\n     */\n    element?: HTMLElement | null\n}\n\ninterface TimestampedPoint extends Point {\n    timestamp: number\n}\n\nconst overflowStyles = /*#__PURE__*/ new Set([\"auto\", \"scroll\"])\n\n/**\n * @internal\n */\nexport class PanSession {\n    /**\n     * @internal\n     */\n    private history: TimestampedPoint[]\n\n    /**\n     * @internal\n     */\n    private startEvent: PointerEvent | null = null\n\n    /**\n     * @internal\n     */\n    private lastMoveEvent: PointerEvent | null = null\n\n    /**\n     * @internal\n     */\n    private lastMoveEventInfo: EventInfo | null = null\n\n    /**\n     * Raw (untransformed) event info, re-transformed each frame\n     * so transformPagePoint sees the current parent matrix.\n     * @internal\n     */\n    private lastRawMoveEventInfo: EventInfo | null = null\n\n    /**\n     * @internal\n     */\n    private transformPagePoint?: TransformPoint\n\n    /**\n     * @internal\n     */\n    private handlers: Partial\u003cPanSessionHandlers\u003e = {}\n\n    /**\n     * @internal\n     */\n    private removeListeners: Function\n\n    /**\n     * For determining if an animation should resume after it is interupted\n     *\n     * @internal\n     */\n    private dragSnapToOrigin: boolean | \"x\" | \"y\"\n\n    /**\n     * The distance after which panning should start.\n     *\n     * @internal\n     */\n    private distanceThreshold: number\n\n    /**\n     * @internal\n     */\n    private contextWindow: PanSessionOptions[\"contextWindow\"] = window\n\n    /**\n     * Scroll positions of scrollable ancestors and window.\n     * @internal\n     */\n    private scrollPositions: Map\u003cElement | Window, Point\u003e = new Map()\n\n    /**\n     * Cleanup function for scroll listeners.\n     * @internal\n     */\n    private removeScrollListeners: (() =\u003e void) | null = null\n\n    constructor(\n        event: PointerEvent,\n        handlers: Partial\u003cPanSessionHandlers\u003e,\n        {\n            transformPagePoint,\n            contextWindow = window,\n            dragSnapToOrigin = false,\n            distanceThreshold = 3,\n            element,\n        }: PanSessionOptions = {}\n    ) {\n        // If we have more than one touch, don't start detecting this gesture\n        if (!isPrimaryPointer(event)) return\n\n        this.dragSnapToOrigin = dragSnapToOrigin\n        this.handlers = handlers\n        this.transformPagePoint = transformPagePoint\n        this.distanceThreshold = distanceThreshold\n        this.contextWindow = contextWindow || window\n\n        const info = extractEventInfo(event)\n        const initialInfo = transformPoint(info, this.transformPagePoint)\n        const { point } = initialInfo\n\n        const { timestamp } = frameData\n\n        this.history = [{ ...point, timestamp }]\n\n        const { onSessionStart } = handlers\n        onSessionStart \u0026\u0026\n            onSessionStart(event, getPanInfo(initialInfo, this.history))\n\n        this.removeListeners = pipe(\n            addPointerEvent(\n                this.contextWindow,\n                \"pointermove\",\n                this.handlePointerMove\n            ),\n            addPointerEvent(\n                this.contextWindow,\n                \"pointerup\",\n                this.handlePointerUp\n            ),\n            addPointerEvent(\n                this.contextWindow,\n                \"pointercancel\",\n                this.handlePointerUp\n            )\n        )\n\n        // Start scroll tracking if element provided\n        if (element) {\n            this.startScrollTracking(element)\n        }\n    }\n\n    /**\n     * Start tracking scroll on ancestors and window.\n     */\n    private startScrollTracking(element: HTMLElement): void {\n        // Store initial scroll positions for scrollable ancestors\n        let current = element.parentElement\n        while (current) {\n            const style = getComputedStyle(current)\n            if (\n                overflowStyles.has(style.overflowX) ||\n                overflowStyles.has(style.overflowY)\n            ) {\n                this.scrollPositions.set(current, {\n                    x: current.scrollLeft,\n                    y: current.scrollTop,\n                })\n            }\n            current = current.parentElement\n        }\n\n        // Track window scroll\n        this.scrollPositions.set(window, {\n            x: window.scrollX,\n            y: window.scrollY,\n        })\n\n        // Capture listener catches element scroll events as they bubble\n        window.addEventListener(\"scroll\", this.onElementScroll, {\n            capture: true,\n        })\n\n        // Direct window scroll listener (window scroll doesn't bubble)\n        window.addEventListener(\"scroll\", this.onWindowScroll)\n\n        this.removeScrollListeners = () =\u003e {\n            window.removeEventListener(\"scroll\", this.onElementScroll, {\n                capture: true,\n            })\n            window.removeEventListener(\"scroll\", this.onWindowScroll)\n        }\n    }\n\n    private onElementScroll = (event: Event): void =\u003e {\n        this.handleScroll(event.target as Element)\n    }\n\n    private onWindowScroll = (): void =\u003e {\n        this.handleScroll(window)\n    }\n\n    /**\n     * Handle scroll compensation during drag.\n     *\n     * For element scroll: adjusts history origin since pageX/pageY doesn't change.\n     * For window scroll: adjusts lastMoveEventInfo since pageX/pageY would change.\n     */\n    private handleScroll(target: Element | Window): void {\n        const initial = this.scrollPositions.get(target)\n        if (!initial) return\n\n        const isWindow = target === window\n        const current = isWindow\n            ? { x: window.scrollX, y: window.scrollY }\n            : {\n                  x: (target as Element).scrollLeft,\n                  y: (target as Element).scrollTop,\n              }\n\n        const delta = { x: current.x - initial.x, y: current.y - initial.y }\n        if (delta.x === 0 \u0026\u0026 delta.y === 0) return\n\n        if (isWindow) {\n            // Window scroll: pageX/pageY changes, so update lastMoveEventInfo\n            if (this.lastMoveEventInfo) {\n                this.lastMoveEventInfo.point.x += delta.x\n                this.lastMoveEventInfo.point.y += delta.y\n            }\n        } else {\n            // Element scroll: pageX/pageY unchanged, so adjust history origin\n            if (this.history.length \u003e 0) {\n                this.history[0].x -= delta.x\n                this.history[0].y -= delta.y\n            }\n        }\n\n        this.scrollPositions.set(target, current)\n        frame.update(this.updatePoint, true)\n    }\n\n    private updatePoint = () =\u003e {\n        if (!(this.lastMoveEvent \u0026\u0026 this.lastMoveEventInfo)) return\n\n        // Re-transform raw point through current transformPagePoint so\n        // animated parent transforms (e.g. rotation) are picked up each frame\n        if (this.lastRawMoveEventInfo) {\n            this.lastMoveEventInfo = transformPoint(\n                this.lastRawMoveEventInfo,\n                this.transformPagePoint\n            )\n        }\n\n        const info = getPanInfo(this.lastMoveEventInfo, this.history)\n        const isPanStarted = this.startEvent !== null\n\n        // Only start panning if the offset is larger than 3 pixels. If we make it\n        // any larger than this we'll want to reset the pointer history\n        // on the first update to avoid visual snapping to the cursor.\n        const isDistancePastThreshold =\n            distance2D(info.offset, { x: 0, y: 0 }) \u003e= this.distanceThreshold\n\n        if (!isPanStarted \u0026\u0026 !isDistancePastThreshold) return\n\n        const { point } = info\n        const { timestamp } = frameData\n        this.history.push({ ...point, timestamp })\n\n        const { onStart, onMove } = this.handlers\n\n        if (!isPanStarted) {\n            onStart \u0026\u0026 onStart(this.lastMoveEvent, info)\n            this.startEvent = this.lastMoveEvent\n        }\n\n        onMove \u0026\u0026 onMove(this.lastMoveEvent, info)\n    }\n\n    private handlePointerMove = (event: PointerEvent, info: EventInfo) =\u003e {\n        this.lastMoveEvent = event\n        this.lastRawMoveEventInfo = info\n        this.lastMoveEventInfo = transformPoint(info, this.transformPagePoint)\n\n        // Throttle mouse move event to once per frame\n        frame.update(this.updatePoint, true)\n    }\n\n    private handlePointerUp = (event: PointerEvent, info: EventInfo) =\u003e {\n        this.end()\n\n        const { onEnd, onSessionEnd, resumeAnimation } = this.handlers\n\n        // Resume animation if dragSnapToOrigin is set OR if no drag started (user just clicked)\n        // This ensures constraint animations continue when interrupted by a click\n        if (this.dragSnapToOrigin || !this.startEvent) {\n            resumeAnimation \u0026\u0026 resumeAnimation()\n        }\n        if (!(this.lastMoveEvent \u0026\u0026 this.lastMoveEventInfo)) return\n\n        const panInfo = getPanInfo(\n            event.type === \"pointercancel\"\n                ? this.lastMoveEventInfo\n                : transformPoint(info, this.transformPagePoint),\n            this.history\n        )\n\n        if (this.startEvent \u0026\u0026 onEnd) {\n            onEnd(event, panInfo)\n        }\n\n        onSessionEnd \u0026\u0026 onSessionEnd(event, panInfo)\n    }\n\n    updateHandlers(handlers: Partial\u003cPanSessionHandlers\u003e) {\n        this.handlers = handlers\n    }\n\n    end() {\n        this.removeListeners \u0026\u0026 this.removeListeners()\n        this.removeScrollListeners \u0026\u0026 this.removeScrollListeners()\n        this.scrollPositions.clear()\n        cancelFrame(this.updatePoint)\n    }\n}\n\nfunction transformPoint(\n    info: EventInfo,\n    transformPagePoint?: (point: Point) =\u003e Point\n) {\n    return transformPagePoint ? { point: transformPagePoint(info.point) } : info\n}\n\nfunction subtractPoint(a: Point, b: Point): Point {\n    return { x: a.x - b.x, y: a.y - b.y }\n}\n\nfunction getPanInfo({ point }: EventInfo, history: TimestampedPoint[]) {\n    return {\n        point,\n        delta: subtractPoint(point, lastDevicePoint(history)),\n        offset: subtractPoint(point, startDevicePoint(history)),\n        velocity: getVelocity(history, 0.1),\n    }\n}\n\nfunction startDevicePoint(history: TimestampedPoint[]): TimestampedPoint {\n    return history[0]\n}\n\nfunction lastDevicePoint(history: TimestampedPoint[]): TimestampedPoint {\n    return history[history.length - 1]\n}\n\nfunction getVelocity(history: TimestampedPoint[], timeDelta: number): Point {\n    if (history.length \u003c 2) {\n        return { x: 0, y: 0 }\n    }\n\n    let i = history.length - 1\n    let timestampedPoint: TimestampedPoint | null = null\n    const lastPoint = lastDevicePoint(history)\n    while (i \u003e= 0) {\n        timestampedPoint = history[i]\n        if (\n            lastPoint.timestamp - timestampedPoint.timestamp \u003e\n            secondsToMilliseconds(timeDelta)\n        ) {\n            break\n        }\n        i--\n    }\n\n    if (!timestampedPoint) {\n        return { x: 0, y: 0 }\n    }\n\n    /**\n     * If the selected point is the pointer-down origin (history[0]),\n     * there are better movement points available, and the time gap\n     * is suspiciously large (\u003e2x timeDelta), use the next point instead.\n     * This prevents stale pointer-down points from diluting velocity\n     * in hold-then-flick gestures.\n     */\n    if (\n        timestampedPoint === history[0] \u0026\u0026\n        history.length \u003e 2 \u0026\u0026\n        lastPoint.timestamp - timestampedPoint.timestamp \u003e\n            secondsToMilliseconds(timeDelta) * 2\n    ) {\n        timestampedPoint = history[1]\n    }\n\n    const time = millisecondsToSeconds(\n        lastPoint.timestamp - timestampedPoint.timestamp\n    )\n    if (time === 0) {\n        return { x: 0, y: 0 }\n    }\n\n    const currentVelocity = {\n        x: (lastPoint.x - timestampedPoint.x) / time,\n        y: (lastPoint.y - timestampedPoint.y) / time,\n    }\n\n    if (currentVelocity.x === Infinity) {\n        currentVelocity.x = 0\n    }\n    if (currentVelocity.y === Infinity) {\n        currentVelocity.y = 0\n    }\n\n    return currentVelocity\n}\n","import { calcLength, mixNumber, type DragElastic, type ResolvedConstraints } from \"motion-dom\"\nimport {\n    Axis,\n    BoundingBox,\n    Box,\n    progress as calcProgress,\n    clamp,\n    Point,\n} from \"motion-utils\"\n\n/**\n * Apply constraints to a point. These constraints are both physical along an\n * axis, and an elastic factor that determines how much to constrain the point\n * by if it does lie outside the defined parameters.\n */\nexport function applyConstraints(\n    point: number,\n    { min, max }: Partial\u003cAxis\u003e,\n    elastic?: Axis\n): number {\n    if (min !== undefined \u0026\u0026 point \u003c min) {\n        // If we have a min point defined, and this is outside of that, constrain\n        point = elastic\n            ? mixNumber(min, point, elastic.min)\n            : Math.max(point, min)\n    } else if (max !== undefined \u0026\u0026 point \u003e max) {\n        // If we have a max point defined, and this is outside of that, constrain\n        point = elastic\n            ? mixNumber(max, point, elastic.max)\n            : Math.min(point, max)\n    }\n\n    return point\n}\n\n/**\n * Calculates a min projection point based on a pointer, pointer progress\n * within the drag target, and constraints.\n *\n * For instance if an element was 100px width, we were dragging from 0.25\n * along this axis, the pointer is at 200px, and there were no constraints,\n * we would calculate a min projection point of 175px.\n */\nexport function calcConstrainedMinPoint(\n    point: number,\n    length: number,\n    progress: number,\n    constraints?: Partial\u003cAxis\u003e,\n    elastic?: Axis\n): number {\n    // Calculate a min point for this axis and apply it to the current pointer\n    const min = point - length * progress\n\n    return constraints ? applyConstraints(min, constraints, elastic) : min\n}\n\n/**\n * Calculate constraints in terms of the viewport when defined relatively to the\n * measured axis. This is measured from the nearest edge, so a max constraint of 200\n * on an axis with a max value of 300 would return a constraint of 500 - axis length\n */\nexport function calcRelativeAxisConstraints(\n    axis: Axis,\n    min?: number,\n    max?: number\n): Partial\u003cAxis\u003e {\n    return {\n        min: min !== undefined ? axis.min + min : undefined,\n        max:\n            max !== undefined\n                ? axis.max + max - (axis.max - axis.min)\n                : undefined,\n    }\n}\n\n/**\n * Calculate constraints in terms of the viewport when\n * defined relatively to the measured bounding box.\n */\nexport function calcRelativeConstraints(\n    layoutBox: Box,\n    { top, left, bottom, right }: Partial\u003cBoundingBox\u003e\n): ResolvedConstraints {\n    return {\n        x: calcRelativeAxisConstraints(layoutBox.x, left, right),\n        y: calcRelativeAxisConstraints(layoutBox.y, top, bottom),\n    }\n}\n\n/**\n * Calculate viewport constraints when defined as another viewport-relative axis\n */\nexport function calcViewportAxisConstraints(\n    layoutAxis: Axis,\n    constraintsAxis: Axis\n) {\n    let min = constraintsAxis.min - layoutAxis.min\n    let max = constraintsAxis.max - layoutAxis.max\n\n    // If the constraints axis is actually smaller than the layout axis then we can\n    // flip the constraints\n    if (\n        constraintsAxis.max - constraintsAxis.min \u003c\n        layoutAxis.max - layoutAxis.min\n    ) {\n        ;[min, max] = [max, min]\n    }\n\n    return { min, max }\n}\n\n/**\n * Calculate viewport constraints when defined as another viewport-relative box\n */\nexport function calcViewportConstraints(layoutBox: Box, constraintsBox: Box) {\n    return {\n        x: calcViewportAxisConstraints(layoutBox.x, constraintsBox.x),\n        y: calcViewportAxisConstraints(layoutBox.y, constraintsBox.y),\n    }\n}\n\n/**\n * Calculate a transform origin relative to the source axis, between 0-1, that results\n * in an asthetically pleasing scale/transform needed to project from source to target.\n */\nexport function calcOrigin(source: Axis, target: Axis): number {\n    let origin = 0.5\n    const sourceLength = calcLength(source)\n    const targetLength = calcLength(target)\n\n    if (targetLength \u003e sourceLength) {\n        origin = calcProgress(target.min, target.max - sourceLength, source.min)\n    } else if (sourceLength \u003e targetLength) {\n        origin = calcProgress(source.min, source.max - targetLength, target.min)\n    }\n\n    return clamp(0, 1, origin)\n}\n\n/**\n * Calculate the relative progress of one constraints box relative to another.\n * Imagine a page scroll bar. At the top, this would return 0, at the bottom, 1.\n * Anywhere in-between, a value between 0 and 1.\n *\n * This also handles flipped constraints, for instance a draggable container within\n * a smaller viewport like a scrollable view.\n */\nexport function calcProgressWithinConstraints(\n    layoutBox: Box,\n    constraintsBox: Box\n): Point {\n    return {\n        x: calcOrigin(layoutBox.x, constraintsBox.x),\n        y: calcOrigin(layoutBox.y, constraintsBox.y),\n    }\n}\n\n/**\n * Calculate the an axis position based on two axes and a progress value.\n */\nexport function calcPositionFromProgress(\n    axis: Axis,\n    constraints: Axis,\n    progress: number\n): Axis {\n    const axisLength = axis.max - axis.min\n    const min = mixNumber(\n        constraints.min,\n        constraints.max - axisLength,\n        progress\n    )\n    return { min, max: min + axisLength }\n}\n\n/**\n * Rebase the calculated viewport constraints relative to the layout.min point.\n */\nexport function rebaseAxisConstraints(\n    layout: Axis,\n    constraints: Partial\u003cAxis\u003e\n): Partial\u003cAxis\u003e {\n    const relativeConstraints: Partial\u003cAxis\u003e = {}\n\n    if (constraints.min !== undefined) {\n        relativeConstraints.min = constraints.min - layout.min\n    }\n\n    if (constraints.max !== undefined) {\n        relativeConstraints.max = constraints.max - layout.min\n    }\n\n    return relativeConstraints\n}\n\nexport const defaultElastic = 0.35\n/**\n * Accepts a dragElastic prop and returns resolved elastic values for each axis.\n */\nexport function resolveDragElastic(\n    dragElastic: DragElastic = defaultElastic\n): Box {\n    if (dragElastic === false) {\n        dragElastic = 0\n    } else if (dragElastic === true) {\n        dragElastic = defaultElastic\n    }\n\n    return {\n        x: resolveAxisElastic(dragElastic, \"left\", \"right\"),\n        y: resolveAxisElastic(dragElastic, \"top\", \"bottom\"),\n    }\n}\n\nexport function resolveAxisElastic(\n    dragElastic: DragElastic,\n    minLabel: string,\n    maxLabel: string\n): Axis {\n    return {\n        min: resolvePointElastic(dragElastic, minLabel),\n        max: resolvePointElastic(dragElastic, maxLabel),\n    }\n}\n\nexport function resolvePointElastic(\n    dragElastic: DragElastic,\n    label: string\n): number {\n    return typeof dragElastic === \"number\"\n        ? dragElastic\n        : dragElastic[label as keyof typeof dragElastic] || 0\n}\n","import {\n    addValueToWillChange,\n    animateMotionValue,\n    calcLength,\n    convertBoundingBoxToBox,\n    convertBoxToBoundingBox,\n    createBox,\n    eachAxis,\n    frame,\n    isElementTextInput,\n    measurePageBox,\n    mixNumber,\n    PanInfo,\n    percent,\n    ResolvedConstraints,\n    resize,\n    setDragLock,\n    Transition,\n    type VisualElement,\n} from \"motion-dom\"\nimport { Axis, Point, invariant } from \"motion-utils\"\nimport { addDomEvent, type LayoutUpdateData } from \"motion-dom\"\nimport { addPointerEvent } from \"../../events/add-pointer-event\"\nimport { extractEventInfo } from \"../../events/event-info\"\nimport { MotionProps } from \"../../motion/types\"\nimport { getContextWindow } from \"../../utils/get-context-window\"\nimport { isRefObject } from \"../../utils/is-ref-object\"\nimport { PanSession } from \"../pan/PanSession\"\nimport {\n    applyConstraints,\n    calcOrigin,\n    calcRelativeConstraints,\n    calcViewportConstraints,\n    defaultElastic,\n    rebaseAxisConstraints,\n    resolveDragElastic,\n} from \"./utils/constraints\"\n\nexport const elementDragControls = new WeakMap\u003c\n    VisualElement,\n    VisualElementDragControls\n\u003e()\n\nexport interface DragControlOptions {\n    /**\n     * This distance after which dragging starts and a direction is locked in.\n     *\n     * @public\n     */\n    distanceThreshold?: number\n\n    /**\n     * Whether to immediately snap to the cursor when dragging starts.\n     *\n     * @public\n     */\n    snapToCursor?: boolean\n}\n\ntype DragDirection = \"x\" | \"y\"\n\nexport class VisualElementDragControls {\n    private visualElement: VisualElement\u003cHTMLElement\u003e\n\n    private panSession?: PanSession\n\n    private openDragLock: VoidFunction | null = null\n\n    isDragging = false\n    private currentDirection: DragDirection | null = null\n\n    private originPoint: Point = { x: 0, y: 0 }\n\n    /**\n     * The permitted boundaries of travel, in pixels.\n     */\n    private constraints: ResolvedConstraints | false = false\n\n    private hasMutatedConstraints = false\n\n    /**\n     * The per-axis resolved elastic values.\n     */\n    private elastic = createBox()\n\n    /**\n     * The latest pointer event. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n     */\n    private latestPointerEvent: PointerEvent | null = null\n\n    /**\n     * The latest pan info. Used as fallback when the `cancel` and `stop` functions are called without arguments.\n     */\n    private latestPanInfo: PanInfo | null = null\n\n    constructor(visualElement: VisualElement\u003cHTMLElement\u003e) {\n        this.visualElement = visualElement\n    }\n\n    start(\n        originEvent: PointerEvent,\n        { snapToCursor = false, distanceThreshold }: DragControlOptions = {}\n    ) {\n        /**\n         * Don't start dragging if this component is exiting\n         */\n        const { presenceContext } = this.visualElement\n        if (presenceContext \u0026\u0026 presenceContext.isPresent === false) return\n\n        const onSessionStart = (event: PointerEvent) =\u003e {\n            if (snapToCursor) {\n                this.snapToCursor(extractEventInfo(event).point)\n            }\n            this.stopAnimation()\n        }\n\n        const onStart = (event: PointerEvent, info: PanInfo) =\u003e {\n            // Attempt to grab the global drag gesture lock - maybe make this part of PanSession\n            const { drag, dragPropagation, onDragStart } = this.getProps()\n\n            if (drag \u0026\u0026 !dragPropagation) {\n                if (this.openDragLock) this.openDragLock()\n\n                this.openDragLock = setDragLock(drag)\n\n                // If we don 't have the lock, don't start dragging\n                if (!this.openDragLock) return\n            }\n\n            this.latestPointerEvent = event\n            this.latestPanInfo = info\n            this.isDragging = true\n\n            this.currentDirection = null\n\n            this.resolveConstraints()\n\n            if (this.visualElement.projection) {\n                this.visualElement.projection.isAnimationBlocked = true\n                this.visualElement.projection.target = undefined\n            }\n\n            /**\n             * Record gesture origin and pointer offset\n             */\n            eachAxis((axis) =\u003e {\n                let current = this.getAxisMotionValue(axis).get() || 0\n\n                /**\n                 * If the MotionValue is a percentage value convert to px\n                 */\n                if (percent.test(current)) {\n                    const { projection } = this.visualElement\n\n                    if (projection \u0026\u0026 projection.layout) {\n                        const measuredAxis = projection.layout.layoutBox[axis]\n\n                        if (measuredAxis) {\n                            const length = calcLength(measuredAxis)\n                            current = length * (parseFloat(current) / 100)\n                        }\n                    }\n                }\n\n                this.originPoint[axis] = current\n            })\n\n            // Fire onDragStart event\n            if (onDragStart) {\n                frame.update(() =\u003e onDragStart(event, info), false, true)\n            }\n\n            addValueToWillChange(this.visualElement, \"transform\")\n\n            const { animationState } = this.visualElement\n            animationState \u0026\u0026 animationState.setActive(\"whileDrag\", true)\n        }\n\n        const onMove = (event: PointerEvent, info: PanInfo) =\u003e {\n            this.latestPointerEvent = event\n            this.latestPanInfo = info\n\n            const {\n                dragPropagation,\n                dragDirectionLock,\n                onDirectionLock,\n                onDrag,\n            } = this.getProps()\n\n            // If we didn't successfully receive the gesture lock, early return.\n            if (!dragPropagation \u0026\u0026 !this.openDragLock) return\n\n            const { offset } = info\n            // Attempt to detect drag direction if directionLock is true\n            if (dragDirectionLock \u0026\u0026 this.currentDirection === null) {\n                this.currentDirection = getCurrentDirection(offset)\n\n                // If we've successfully set a direction, notify listener\n                if (this.currentDirection !== null) {\n                    onDirectionLock \u0026\u0026 onDirectionLock(this.currentDirection)\n                }\n\n                return\n            }\n\n            // Update each point with the latest position\n            this.updateAxis(\"x\", info.point, offset)\n            this.updateAxis(\"y\", info.point, offset)\n\n            /**\n             * Ideally we would leave the renderer to fire naturally at the end of\n             * this frame but if the element is about to change layout as the result\n             * of a re-render we want to ensure the browser can read the latest\n             * bounding box to ensure the pointer and element don't fall out of sync.\n             */\n            this.visualElement.render()\n\n            /**\n             * This must fire after the render call as it might trigger a state\n             * change which itself might trigger a layout update.\n             */\n            if (onDrag) {\n                frame.update(() =\u003e onDrag(event, info), false, true)\n            }\n        }\n\n        const onSessionEnd = (event: PointerEvent, info: PanInfo) =\u003e {\n            this.latestPointerEvent = event\n            this.latestPanInfo = info\n\n            this.stop(event, info)\n\n            this.latestPointerEvent = null\n            this.latestPanInfo = null\n        }\n\n        const resumeAnimation = () =\u003e {\n            const { dragSnapToOrigin: snap } = this.getProps()\n            if (snap || this.constraints) {\n                this.startAnimation({ x: 0, y: 0 })\n            }\n        }\n\n        const { dragSnapToOrigin } = this.getProps()\n        this.panSession = new PanSession(\n            originEvent,\n            {\n                onSessionStart,\n                onStart,\n                onMove,\n                onSessionEnd,\n                resumeAnimation,\n            },\n            {\n                transformPagePoint: this.visualElement.getTransformPagePoint(),\n                dragSnapToOrigin,\n                distanceThreshold,\n                contextWindow: getContextWindow(this.visualElement),\n                element: this.visualElement.current,\n            }\n        )\n    }\n\n    /**\n     * @internal\n     */\n    stop(event?: PointerEvent, panInfo?: PanInfo) {\n        const finalEvent = event || this.latestPointerEvent\n        const finalPanInfo = panInfo || this.latestPanInfo\n\n        const isDragging = this.isDragging\n        this.cancel()\n        if (!isDragging || !finalPanInfo || !finalEvent) return\n\n        const { velocity } = finalPanInfo\n        this.startAnimation(velocity)\n\n        const { onDragEnd } = this.getProps()\n        if (onDragEnd) {\n            frame.postRender(() =\u003e onDragEnd(finalEvent, finalPanInfo))\n        }\n    }\n\n    /**\n     * @internal\n     */\n    cancel() {\n        this.isDragging = false\n\n        const { projection, animationState } = this.visualElement\n\n        if (projection) {\n            projection.isAnimationBlocked = false\n        }\n\n        this.endPanSession()\n\n        const { dragPropagation } = this.getProps()\n\n        if (!dragPropagation \u0026\u0026 this.openDragLock) {\n            this.openDragLock()\n            this.openDragLock = null\n        }\n\n        animationState \u0026\u0026 animationState.setActive(\"whileDrag\", false)\n    }\n\n    /**\n     * Clean up the pan session without modifying other drag state.\n     * This is used during unmount to ensure event listeners are removed\n     * without affecting projection animations or drag locks.\n     * @internal\n     */\n    endPanSession() {\n        this.panSession \u0026\u0026 this.panSession.end()\n        this.panSession = undefined\n    }\n\n    private updateAxis(axis: DragDirection, _point: Point, offset?: Point) {\n        const { drag } = this.getProps()\n\n        // If we're not dragging this axis, do an early return.\n        if (!offset || !shouldDrag(axis, drag, this.currentDirection)) return\n\n        const axisValue = this.getAxisMotionValue(axis)\n        let next = this.originPoint[axis] + offset[axis]\n\n        // Apply constraints\n        if (this.constraints \u0026\u0026 this.constraints[axis]) {\n            next = applyConstraints(\n                next,\n                this.constraints[axis],\n                this.elastic[axis]\n            )\n        }\n\n        axisValue.set(next)\n    }\n\n    private resolveConstraints() {\n        const { dragConstraints, dragElastic } = this.getProps()\n\n        const layout =\n            this.visualElement.projection \u0026\u0026\n            !this.visualElement.projection.layout\n                ? this.visualElement.projection.measure(false)\n                : this.visualElement.projection?.layout\n\n        const prevConstraints = this.constraints\n\n        if (dragConstraints \u0026\u0026 isRefObject(dragConstraints)) {\n            if (!this.constraints) {\n                this.constraints = this.resolveRefConstraints()\n            }\n        } else {\n            if (dragConstraints \u0026\u0026 layout) {\n                this.constraints = calcRelativeConstraints(\n                    layout.layoutBox,\n                    dragConstraints\n                )\n            } else {\n                this.constraints = false\n            }\n        }\n\n        this.elastic = resolveDragElastic(dragElastic)\n\n        /**\n         * If we're outputting to external MotionValues, we want to rebase the measured constraints\n         * from viewport-relative to component-relative. This only applies to relative (non-ref)\n         * constraints, as ref-based constraints from calcViewportConstraints are already in the\n         * correct coordinate space for the motion value transform offset.\n         */\n        if (\n            prevConstraints !== this.constraints \u0026\u0026\n            !isRefObject(dragConstraints) \u0026\u0026\n            layout \u0026\u0026\n            this.constraints \u0026\u0026\n            !this.hasMutatedConstraints\n        ) {\n            eachAxis((axis) =\u003e {\n                if (\n                    this.constraints !== false \u0026\u0026\n                    this.getAxisMotionValue(axis)\n                ) {\n                    this.constraints[axis] = rebaseAxisConstraints(\n                        layout.layoutBox[axis],\n                        this.constraints[axis]\n                    )\n                }\n            })\n        }\n    }\n\n    private resolveRefConstraints() {\n        const { dragConstraints: constraints, onMeasureDragConstraints } =\n            this.getProps()\n        if (!constraints || !isRefObject(constraints)) return false\n\n        const constraintsElement = constraints.current as HTMLElement\n\n        invariant(\n            constraintsElement !== null,\n            \"If `dragConstraints` is set as a React ref, that ref must be passed to another component's `ref` prop.\",\n            \"drag-constraints-ref\"\n        )\n\n        const { projection } = this.visualElement\n\n        // TODO\n        if (!projection || !projection.layout) return false\n\n        const constraintsBox = measurePageBox(\n            constraintsElement,\n            projection.root!,\n            this.visualElement.getTransformPagePoint()\n        )\n\n        let measuredConstraints = calcViewportConstraints(\n            projection.layout.layoutBox,\n            constraintsBox\n        )\n\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            const userConstraints = onMeasureDragConstraints(\n                convertBoxToBoundingBox(measuredConstraints)\n            )\n\n            this.hasMutatedConstraints = !!userConstraints\n\n            if (userConstraints) {\n                measuredConstraints = convertBoundingBoxToBox(userConstraints)\n            }\n        }\n\n        return measuredConstraints\n    }\n\n    private startAnimation(velocity: Point) {\n        const {\n            drag,\n            dragMomentum,\n            dragElastic,\n            dragTransition,\n            dragSnapToOrigin,\n            onDragTransitionEnd,\n        } = this.getProps()\n\n        const constraints: Partial\u003cResolvedConstraints\u003e = this.constraints || {}\n\n        const momentumAnimations = eachAxis((axis) =\u003e {\n            if (!shouldDrag(axis, drag, this.currentDirection)) {\n                return\n            }\n\n            let transition = (constraints \u0026\u0026 constraints[axis]) || {}\n\n            if (\n                dragSnapToOrigin === true ||\n                (dragSnapToOrigin as unknown) === axis\n            )\n                transition = { min: 0, max: 0 }\n\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            const bounceStiffness = dragElastic ? 200 : 1000000\n            const bounceDamping = dragElastic ? 40 : 10000000\n\n            const inertia: Transition = {\n                type: \"inertia\",\n                velocity: dragMomentum ? velocity[axis] : 0,\n                bounceStiffness,\n                bounceDamping,\n                timeConstant: 750,\n                restDelta: 1,\n                restSpeed: 10,\n                ...dragTransition,\n                ...transition,\n            }\n\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.startAxisValueAnimation(axis, inertia)\n        })\n\n        // Run all animations and then resolve the new drag constraints.\n        return Promise.all(momentumAnimations).then(onDragTransitionEnd)\n    }\n\n    private startAxisValueAnimation(\n        axis: DragDirection,\n        transition: Transition\n    ) {\n        const axisValue = this.getAxisMotionValue(axis)\n\n        addValueToWillChange(this.visualElement, axis)\n\n        return axisValue.start(\n            animateMotionValue(\n                axis,\n                axisValue,\n                0,\n                transition,\n                this.visualElement,\n                false\n            )\n        )\n    }\n\n    private stopAnimation() {\n        eachAxis((axis) =\u003e this.getAxisMotionValue(axis).stop())\n    }\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     * - Otherwise, we apply the delta to the x/y motion values.\n     */\n    private getAxisMotionValue(axis: DragDirection) {\n        const dragKey =\n            `_drag${axis.toUpperCase()}` as `_drag${Uppercase\u003cDragDirection\u003e}`\n        const props = this.visualElement.getProps()\n        const externalMotionValue = props[dragKey]\n\n        return externalMotionValue\n            ? externalMotionValue\n            : this.visualElement.getValue(\n                  axis,\n                  (props.initial\n                      ? props.initial[axis as keyof typeof props.initial]\n                      : undefined) || 0\n              )\n    }\n\n    private snapToCursor(point: Point) {\n        eachAxis((axis) =\u003e {\n            const { drag } = this.getProps()\n\n            // If we're not dragging this axis, do an early return.\n            if (!shouldDrag(axis, drag, this.currentDirection)) return\n\n            const { projection } = this.visualElement\n            const axisValue = this.getAxisMotionValue(axis)\n\n            if (projection \u0026\u0026 projection.layout) {\n                const { min, max } = projection.layout.layoutBox[axis]\n\n                /**\n                 * The layout measurement includes the current transform value,\n                 * so we need to add it back to get the correct snap position.\n                 * This fixes an issue where elements with initial coordinates\n                 * would snap to the wrong position on the first drag.\n                 */\n                const current = axisValue.get() || 0\n\n                axisValue.set(point[axis] - mixNumber(min, max, 0.5) + current)\n            }\n        })\n    }\n\n    /**\n     * When the viewport resizes we want to check if the measured constraints\n     * have changed and, if so, reposition the element within those new constraints\n     * relative to where it was before the resize.\n     */\n    scalePositionWithinConstraints() {\n        if (!this.visualElement.current) return\n\n        const { drag, dragConstraints } = this.getProps()\n        const { projection } = this.visualElement\n        if (!isRefObject(dragConstraints) || !projection || !this.constraints)\n            return\n\n        /**\n         * Stop current animations as there can be visual glitching if we try to do\n         * this mid-animation\n         */\n        this.stopAnimation()\n\n        /**\n         * Record the relative position of the dragged element relative to the\n         * constraints box and save as a progress value.\n         */\n        const boxProgress = { x: 0, y: 0 }\n        eachAxis((axis) =\u003e {\n            const axisValue = this.getAxisMotionValue(axis)\n            if (axisValue \u0026\u0026 this.constraints !== false) {\n                const latest = axisValue.get()\n                boxProgress[axis] = calcOrigin(\n                    { min: latest, max: latest },\n                    this.constraints[axis] as Axis\n                )\n            }\n        })\n\n        /**\n         * Update the layout of this element and resolve the latest drag constraints\n         */\n        const { transformTemplate } = this.visualElement.getProps()\n        this.visualElement.current.style.transform = transformTemplate\n            ? transformTemplate({}, \"\")\n            : \"none\"\n        projection.root \u0026\u0026 projection.root.updateScroll()\n        projection.updateLayout()\n\n        /**\n         * Reset constraints so resolveConstraints() will recalculate them\n         * with the freshly measured layout rather than returning the cached value.\n         */\n        this.constraints = false\n        this.resolveConstraints()\n\n        /**\n         * For each axis, calculate the current progress of the layout axis\n         * within the new constraints.\n         */\n        eachAxis((axis) =\u003e {\n            if (!shouldDrag(axis, drag, null)) return\n\n            /**\n             * Calculate a new transform based on the previous box progress\n             */\n            const axisValue = this.getAxisMotionValue(axis)\n            const { min, max } = (this.constraints as ResolvedConstraints)[\n                axis\n            ] as Axis\n            axisValue.set(mixNumber(min, max, boxProgress[axis]))\n        })\n\n        /**\n         * Flush the updated transform to the DOM synchronously to prevent\n         * a visual flash at the element's CSS layout position (0,0) when\n         * the transform was stripped for measurement.\n         */\n        this.visualElement.render()\n    }\n\n    addListeners() {\n        if (!this.visualElement.current) return\n        elementDragControls.set(this.visualElement, this)\n        const element = this.visualElement.current\n\n        /**\n         * Attach a pointerdown event listener on this DOM element to initiate drag tracking.\n         */\n        const stopPointerListener = addPointerEvent(\n            element,\n            \"pointerdown\",\n            (event) =\u003e {\n                const { drag, dragListener = true } = this.getProps()\n                const target = event.target as Element\n\n                /**\n                 * Only block drag if clicking on a text input child element\n                 * (input, textarea, select, contenteditable) where users might\n                 * want to select text or interact with the control.\n                 *\n                 * Buttons and links don't block drag since they don't have\n                 * click-and-move actions of their own.\n                 */\n                const isClickingTextInputChild =\n                    target !== element \u0026\u0026 isElementTextInput(target)\n\n                if (drag \u0026\u0026 dragListener \u0026\u0026 !isClickingTextInputChild) {\n                    this.start(event)\n                }\n            }\n        )\n\n        /**\n         * If using ref-based constraints, observe both the draggable element\n         * and the constraint container for size changes via ResizeObserver.\n         * Setup is deferred because dragConstraints.current is null when\n         * addListeners first runs (React hasn't committed the ref yet).\n         */\n        let stopResizeObservers: VoidFunction | undefined\n\n        const measureDragConstraints = () =\u003e {\n            const { dragConstraints } = this.getProps()\n            if (isRefObject(dragConstraints) \u0026\u0026 dragConstraints.current) {\n                this.constraints = this.resolveRefConstraints()\n\n                if (!stopResizeObservers) {\n                    stopResizeObservers = startResizeObservers(\n                        element,\n                        dragConstraints.current as HTMLElement,\n                        () =\u003e this.scalePositionWithinConstraints()\n                    )\n                }\n            }\n        }\n\n        const { projection } = this.visualElement\n\n        const stopMeasureLayoutListener = projection!.addEventListener(\n            \"measure\",\n            measureDragConstraints\n        )\n\n        if (projection \u0026\u0026 !projection!.layout) {\n            projection.root \u0026\u0026 projection.root.updateScroll()\n            projection.updateLayout()\n        }\n\n        frame.read(measureDragConstraints)\n\n        /**\n         * Attach a window resize listener to scale the draggable target within its defined\n         * constraints as the window resizes.\n         */\n        const stopResizeListener = addDomEvent(window, \"resize\", () =\u003e\n            this.scalePositionWithinConstraints()\n        )\n\n        /**\n         * If the element's layout changes, calculate the delta and apply that to\n         * the drag gesture's origin point.\n         */\n        const stopLayoutUpdateListener = projection!.addEventListener(\n            \"didUpdate\",\n            (({ delta, hasLayoutChanged }: LayoutUpdateData) =\u003e {\n                if (this.isDragging \u0026\u0026 hasLayoutChanged) {\n                    eachAxis((axis) =\u003e {\n                        const motionValue = this.getAxisMotionValue(axis)\n                        if (!motionValue) return\n\n                        this.originPoint[axis] += delta[axis].translate\n                        motionValue.set(\n                            motionValue.get() + delta[axis].translate\n                        )\n                    })\n\n                    this.visualElement.render()\n                }\n            }) as any\n        )\n\n        return () =\u003e {\n            stopResizeListener()\n            stopPointerListener()\n            stopMeasureLayoutListener()\n            stopLayoutUpdateListener \u0026\u0026 stopLayoutUpdateListener()\n            stopResizeObservers \u0026\u0026 stopResizeObservers()\n        }\n    }\n\n    getProps(): MotionProps {\n        const props = this.visualElement.getProps()\n        const {\n            drag = false,\n            dragDirectionLock = false,\n            dragPropagation = false,\n            dragConstraints = false,\n            dragElastic = defaultElastic,\n            dragMomentum = true,\n        } = props\n        return {\n            ...props,\n            drag,\n            dragDirectionLock,\n            dragPropagation,\n            dragConstraints,\n            dragElastic,\n            dragMomentum,\n        }\n    }\n}\n\nfunction skipFirstCall(callback: VoidFunction): VoidFunction {\n    let isFirst = true\n    return () =\u003e {\n        if (isFirst) {\n            isFirst = false\n            return\n        }\n        callback()\n    }\n}\n\nfunction startResizeObservers(\n    element: HTMLElement,\n    constraintsElement: HTMLElement,\n    onResize: VoidFunction\n): VoidFunction {\n    const stopElement = resize(element, skipFirstCall(onResize))\n    const stopContainer = resize(constraintsElement, skipFirstCall(onResize))\n    return () =\u003e {\n        stopElement()\n        stopContainer()\n    }\n}\n\nfunction shouldDrag(\n    direction: DragDirection,\n    drag: boolean | DragDirection | undefined,\n    currentDirection: null | DragDirection\n) {\n    return (\n        (drag === true || drag === direction) \u0026\u0026\n        (currentDirection === null || currentDirection === direction)\n    )\n}\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(\n    offset: Point,\n    lockThreshold = 10\n): DragDirection | null {\n    let direction: DragDirection | null = null\n\n    if (Math.abs(offset.y) \u003e lockThreshold) {\n        direction = \"y\"\n    } else if (Math.abs(offset.x) \u003e lockThreshold) {\n        direction = \"x\"\n    }\n\n    return direction\n}\n\nexport function expectsResolvedDragConstraints({\n    dragConstraints,\n    onMeasureDragConstraints,\n}: MotionProps) {\n    return isRefObject(dragConstraints) \u0026\u0026 !!onMeasureDragConstraints\n}\n","import { Feature, type VisualElement } from \"motion-dom\"\nimport { noop } from \"motion-utils\"\nimport { VisualElementDragControls } from \"./VisualElementDragControls\"\n\nexport class DragGesture extends Feature\u003cHTMLElement\u003e {\n    controls: VisualElementDragControls\n\n    removeGroupControls: Function = noop\n    removeListeners: Function = noop\n\n    constructor(node: VisualElement\u003cHTMLElement\u003e) {\n        super(node)\n        this.controls = new VisualElementDragControls(node)\n    }\n\n    mount() {\n        // If we've been provided a DragControls for manual control over the drag gesture,\n        // subscribe this component to it on mount.\n        const { dragControls } = this.node.getProps()\n\n        if (dragControls) {\n            this.removeGroupControls = dragControls.subscribe(this.controls)\n        }\n\n        this.removeListeners = this.controls.addListeners() || noop\n    }\n\n    update() {\n        const { dragControls } = this.node.getProps()\n        const { dragControls: prevDragControls } = this.node.prevProps || {}\n\n        if (dragControls !== prevDragControls) {\n            this.removeGroupControls()\n            if (dragControls) {\n                this.removeGroupControls = dragControls.subscribe(this.controls)\n            }\n        }\n    }\n\n    unmount() {\n        this.removeGroupControls()\n        this.removeListeners()\n        /**\n         * In React 19, during list reorder reconciliation, components may\n         * briefly unmount and remount while the drag is still active. If we're\n         * actively dragging, we should NOT end the pan session - it will\n         * continue tracking pointer events via its window-level listeners.\n         *\n         * The pan session will be properly cleaned up when:\n         * 1. The drag ends naturally (pointerup/pointercancel)\n         * 2. The component is truly removed from the DOM\n         */\n        if (!this.controls.isDragging) {\n            this.controls.endPanSession()\n        }\n    }\n}\n","import { Feature, frame, type PanInfo } from \"motion-dom\"\nimport { noop } from \"motion-utils\"\nimport { addPointerEvent } from \"../../events/add-pointer-event\"\nimport { getContextWindow } from \"../../utils/get-context-window\"\nimport { PanSession } from \"./PanSession\"\n\ntype PanEventHandler = (event: PointerEvent, info: PanInfo) =\u003e void\nconst asyncHandler =\n    (handler?: PanEventHandler) =\u003e (event: PointerEvent, info: PanInfo) =\u003e {\n        if (handler) {\n            frame.update(() =\u003e handler(event, info), false, true)\n        }\n    }\n\nexport class PanGesture extends Feature\u003cElement\u003e {\n    private session?: PanSession\n\n    private removePointerDownListener: Function = noop\n\n    onPointerDown(pointerDownEvent: PointerEvent) {\n        this.session = new PanSession(\n            pointerDownEvent,\n            this.createPanHandlers(),\n            {\n                transformPagePoint: this.node.getTransformPagePoint(),\n                contextWindow: getContextWindow(this.node),\n            }\n        )\n    }\n\n    createPanHandlers() {\n        const { onPanSessionStart, onPanStart, onPan, onPanEnd } =\n            this.node.getProps()\n\n        return {\n            onSessionStart: asyncHandler(onPanSessionStart),\n            onStart: asyncHandler(onPanStart),\n            onMove: asyncHandler(onPan),\n            onEnd: (event: PointerEvent, info: PanInfo) =\u003e {\n                delete this.session\n                if (onPanEnd) {\n                    frame.postRender(() =\u003e onPanEnd(event, info))\n                }\n            },\n        }\n    }\n\n    mount() {\n        this.removePointerDownListener = addPointerEvent(\n            this.node.current!,\n            \"pointerdown\",\n            (event: PointerEvent) =\u003e this.onPointerDown(event)\n        )\n    }\n\n    update() {\n        this.session \u0026\u0026 this.session.updateHandlers(this.createPanHandlers())\n    }\n\n    unmount() {\n        this.removePointerDownListener()\n        this.session \u0026\u0026 this.session.end()\n    }\n}\n","import { DragGesture } from \"../../gestures/drag\"\nimport { PanGesture } from \"../../gestures/pan\"\nimport { HTMLProjectionNode } from \"../../projection\"\nimport { MeasureLayout } from \"./layout/MeasureLayout\"\nimport { FeaturePackages } from \"./types\"\n\nexport const drag: FeaturePackages = {\n    pan: {\n        Feature: PanGesture,\n    },\n    drag: {\n        Feature: DragGesture,\n        ProjectionNode: HTMLProjectionNode,\n        MeasureLayout,\n    },\n}\n"],"version":3}
