import { useContext, useEffect } from "react";
import { PresenceContext } from "../../context/PresenceContext.js";
import { useId } from "../../utils/use-id.js";
function usePresence() {
  var context = useContext(PresenceContext);
  if (context === null)
    return [true, null];
  var isPresent = context.isPresent, onExitComplete = context.onExitComplete, register = context.register;
  var id = useId();
  useEffect(function() {
    return register(id);
  }, []);
  var safeToRemove = function() {
    return onExitComplete === null || onExitComplete === void 0 ? void 0 : onExitComplete(id);
  };
  return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
}
export {
  usePresence
};
//# sourceMappingURL=use-presence.js.map
