import { useRef as u, useEffect as s } from "react";
function d(r) {
  const t = u(null);
  return s(() => {
    const e = (n) => {
      const o = t == null ? void 0 : t.current;
      !o || o.contains((n == null ? void 0 : n.target) || null) || r(n);
    };
    return document.addEventListener("mousedown", e), document.addEventListener("touchstart", e), () => {
      document.removeEventListener("mousedown", e), document.removeEventListener("touchstart", e);
    };
  }, [t, r]), { containerRef: t };
}
export {
  d as useOnClickOutside
};
