import { useRef as C, useInsertionEffect as y, useCallback as M } from "react";
function b(n, f, e) {
  const c = C(e);
  y(() => {
    c.current = e;
  });
  const u = C(null);
  return M((r) => {
    var t;
    r && ((t = n.onMount) == null || t.call(n, r));
    const o = c.current;
    if (typeof o == "function")
      if (r) {
        const p = o(r);
        typeof p == "function" && (u.current = p);
      } else u.current ? (u.current(), u.current = null) : o(r);
    else o && (o.current = r);
    f && (r ? f.mount(r) : f.unmount());
  }, [f]);
}
export {
  b as useMotionRef
};
//# sourceMappingURL=use-motion-ref.es.js.map
