import { useRef as o, useEffect as c } from "react";
function i(t) {
  const e = o(null);
  return c(() => {
    function n(r) {
      const u = r.target;
      e.current && !e.current.contains(u) && t(r);
    }
    return document.addEventListener("mousedown", n), () => {
      document.removeEventListener("mousedown", n);
    };
  }, [e, t]), e;
}
export {
  i as u
};
