import { __read as f } from "../../../../../tslib/tslib.es6.es.js";
import { useEffect as u, useContext as c } from "react";
import { isAnimationControls as p } from "../../animation/utils/is-animation-controls.es.js";
import { usePresence as d } from "../../components/AnimatePresence/use-presence.es.js";
import { PresenceContext as x } from "../../context/PresenceContext.es.js";
import { createAnimationState as E } from "../../render/utils/animation-state.es.js";
import { AnimationType as C } from "../../render/utils/types.es.js";
import { makeRenderlessComponent as v } from "../utils/make-renderless-component.es.js";
var k = {
  animation: v(function(i) {
    var t = i.visualElement, e = i.animate;
    t.animationState || (t.animationState = E(t)), p(e) && u(function() {
      return e.subscribe(t);
    }, [e]);
  }),
  exit: v(function(i) {
    var t = i.custom, e = i.visualElement, s = f(d(), 2), n = s[0], l = s[1], o = c(x);
    u(function() {
      var a, m;
      e.isPresent = n;
      var r = (a = e.animationState) === null || a === void 0 ? void 0 : a.setActive(C.Exit, !n, { custom: (m = o == null ? void 0 : o.custom) !== null && m !== void 0 ? m : t });
      !n && (r == null || r.then(l));
    }, [n]);
  })
};
export {
  k as animations
};
//# sourceMappingURL=animations.es.js.map
