'use client'; import * as React from 'react'; import type { AnimationHandle, MotionImperativeRef } from '../types'; export function useMotionImperativeRef( imperativeRef: React.Ref | undefined, // eslint-disable-next-line @typescript-eslint/no-deprecated ): React.MutableRefObject { const animationRef = React.useRef(undefined); React.useImperativeHandle(imperativeRef, () => ({ setPlayState: state => { if (state === 'running') { animationRef.current?.play(); } if (state === 'paused') { animationRef.current?.pause(); } }, setPlaybackRate: rate => { if (animationRef.current) { animationRef.current.playbackRate = rate; } }, })); return animationRef; }