import { useContext as r, useRef as m, useEffect as c } from "react";
import { PresenceContext as p } from "../../context/PresenceContext.es.js";
import { useVisualElementContext as C } from "../../context/MotionContext/index.es.js";
import { useIsomorphicLayoutEffect as u } from "../../utils/use-isomorphic-effect.es.js";
import { LazyContext as x } from "../../context/LazyContext.es.js";
import { useReducedMotionConfig as R } from "../../utils/use-reduced-motion.es.js";
function z(d, a, f, e) {
  var l = r(x), v = C(), o = r(p), s = R(), t = m(void 0);
  e || (e = l.renderer), !t.current && e && (t.current = e(d, {
    visualState: a,
    parent: v,
    props: f,
    presenceId: o == null ? void 0 : o.id,
    blockInitialAnimation: (o == null ? void 0 : o.initial) === !1,
    shouldReduceMotion: s
  }));
  var n = t.current;
  return u(function() {
    n == null || n.syncRender();
  }), c(function() {
    var i;
    (i = n == null ? void 0 : n.animationState) === null || i === void 0 || i.animateChanges();
  }), u(function() {
    return function() {
      return n == null ? void 0 : n.notifyUnmount();
    };
  }, []), n;
}
export {
  z as useVisualElement
};
//# sourceMappingURL=use-visual-element.es.js.map
