import{useEffect}from"react";const useClickOutside=(e,t)=>{useEffect((()=>{let n=!1,r=!1;const c=c=>{!n&&r&&e.current&&!e.current.contains(c.target)&&t(c)},u=t=>{r=e.current,n=e.current&&e.current.contains(t.target)};return document.addEventListener("mousedown",u),document.addEventListener("touchstart",u),document.addEventListener("click",c),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("touchstart",u),document.removeEventListener("click",c)}}),[e,t])};export default useClickOutside;