"use client";
'use strict';

var React = require('react');
var MotionConfigContext = require('../context/MotionConfigContext.js');
var frame = require('../../../../../../motion-dom@12.38.0/node_modules/motion-dom/dist/es/frameloop/frame.js');

function useAnimationFrame(callback) {
    const initialTimestamp = React.useRef(0);
    const { isStatic } = React.useContext(MotionConfigContext.MotionConfigContext);
    React.useEffect(() => {
        if (isStatic)
            return;
        const provideTimeSinceStart = ({ timestamp, delta }) => {
            if (!initialTimestamp.current)
                initialTimestamp.current = timestamp;
            callback(timestamp - initialTimestamp.current, delta);
        };
        frame.frame.update(provideTimeSinceStart, true);
        return () => frame.cancelFrame(provideTimeSinceStart);
    }, [callback]);
}

exports.useAnimationFrame = useAnimationFrame;
