import { useRef as o, useCallback as l, useMemo as s } from "react";
function p(e) {
  const t = o(null), r = o(void 0), u = l((n) => {
    if (typeof e == "function") {
      const c = e, f = c(n);
      return () => {
        typeof f == "function" ? f() : c(null);
      };
    } else if (e)
      return e.current = n, () => {
        e.current = null;
      };
  }, [
    e
  ]);
  return s(() => ({
    get current() {
      return t.current;
    },
    set current(n) {
      t.current = n, r.current && (r.current(), r.current = void 0), n != null && (r.current = u(n));
    }
  }), [
    u
  ]);
}
export {
  p as $
};
//# sourceMappingURL=useObjectRef-CaJ5pgjX.es.js.map
