import { getFinalKeyframe as A } from "../animators/waapi/utils/get-final-keyframe.es.js";
import { getDefaultTransition as k } from "../utils/default-transitions.es.js";
import { isTransitionDefined as D } from "../utils/is-transition-defined.es.js";
import { getValueTransition as g } from "../../../../../../../motion-dom@12.23.23/node_modules/motion-dom/dist/es/animation/utils/get-value-transition.es.js";
import { secondsToMilliseconds as f } from "../../../../../../../motion-utils@12.23.6/node_modules/motion-utils/dist/es/time-conversion.es.js";
import { makeAnimationInstant as p } from "../../../../../../../motion-dom@12.23.23/node_modules/motion-dom/dist/es/animation/utils/make-animation-instant.es.js";
import { MotionGlobalConfig as d } from "../../../../../../../motion-utils@12.23.6/node_modules/motion-utils/dist/es/global-config.es.js";
import { frame as C } from "../../../../../../../motion-dom@12.23.23/node_modules/motion-dom/dist/es/frameloop/frame.es.js";
import { JSAnimation as T } from "../../../../../../../motion-dom@12.23.23/node_modules/motion-dom/dist/es/animation/JSAnimation.es.js";
import { AsyncMotionValueAnimation as V } from "../../../../../../../motion-dom@12.23.23/node_modules/motion-dom/dist/es/animation/AsyncMotionValueAnimation.es.js";
const x = (i, n, a, r = {}, y, s) => (u) => {
  const o = g(r, i) || {}, c = o.delay || r.delay || 0;
  let { elapsed: m = 0 } = r;
  m = m - f(c);
  const e = {
    keyframes: Array.isArray(a) ? a : [null, a],
    ease: "easeOut",
    velocity: n.getVelocity(),
    ...o,
    delay: -m,
    onUpdate: (t) => {
      n.set(t), o.onUpdate && o.onUpdate(t);
    },
    onComplete: () => {
      u(), o.onComplete && o.onComplete();
    },
    name: i,
    motionValue: n,
    element: s ? void 0 : y
  };
  D(o) || Object.assign(e, k(i, e)), e.duration && (e.duration = f(e.duration)), e.repeatDelay && (e.repeatDelay = f(e.repeatDelay)), e.from !== void 0 && (e.keyframes[0] = e.from);
  let l = !1;
  if ((e.type === !1 || e.duration === 0 && !e.repeatDelay) && (p(e), e.delay === 0 && (l = !0)), (d.instantAnimations || d.skipAnimations) && (l = !0, p(e), e.delay = 0), e.allowFlatten = !o.type && !o.ease, l && !s && n.get() !== void 0) {
    const t = A(e.keyframes, o);
    if (t !== void 0) {
      C.update(() => {
        e.onUpdate(t), e.onComplete();
      });
      return;
    }
  }
  return o.isSync ? new T(e) : new V(e);
};
export {
  x as animateMotionValue
};
//# sourceMappingURL=motion-value.es.js.map
