"use client";
import { useState as E, useRef as J, useEffect as c } from "react";
import { resolveDefaultProps as M } from "../util/resolveDefaultProps.js";
import b from "./configUpdate.js";
import { configEasing as y } from "./easing.js";
import { useAnimationManager as B } from "./useAnimationManager.js";
import { noop as P } from "../../../es-toolkit/dist/function/noop.js";
var h = {
  begin: 0,
  duration: 1e3,
  easing: "ease",
  isActive: !0,
  canBegin: !0,
  onAnimationEnd: () => {
  },
  onAnimationStart: () => {
  }
}, v = {
  t: 0
}, e = {
  t: 1
};
function U(g) {
  var r = M(g, h), {
    isActive: t,
    canBegin: m,
    duration: i,
    easing: s,
    begin: u,
    onAnimationEnd: a,
    onAnimationStart: f,
    children: A
  } = r, n = B(r.animationId, r.animationManager), [l, p] = E(t ? v : e), o = J(null);
  return c(() => {
    t || p(e);
  }, [t]), c(() => {
    if (!t || !m)
      return P;
    var d = b(v, e, y(s), i, p, n.getTimeoutController()), S = () => {
      o.current = d();
    };
    return n.start([f, u, S, i, a]), () => {
      n.stop(), o.current && o.current(), a();
    };
  }, [t, m, i, s, u, f, a, n]), A(l.t);
}
export {
  U as JavascriptAnimate
};
