import { useEffect } from "react";
const useOutsideEvent = (ref, callback, events = ["mousedown"]) => {
	const refArray = Array.isArray(ref) ? ref : [ref];
	const handleOutsideEvent = (event) => {
		if (refArray.every((r) => r.current && !event.composedPath().includes(r.current))) callback(event);
	};
	useEffect(() => {
		events.forEach((eventName) => document.addEventListener(eventName, handleOutsideEvent));
		return () => {
			events.forEach((eventName) => document.removeEventListener(eventName, handleOutsideEvent));
		};
	}, [
		refArray,
		callback,
		events
	]);
};
export { useOutsideEvent as t };

//# sourceMappingURL=useOutsideEvent.js.map