import{r as o}from"./main-TIUJvpaR.js";function b(){let n=o.useRef(new Map),u=o.useCallback((e,l,r,t)=>{let a=t!=null&&t.once?(...d)=>{n.current.delete(r),r(...d)}:r;n.current.set(r,{type:l,eventTarget:e,fn:a,options:t}),e.addEventListener(l,a,t)},[]),s=o.useCallback((e,l,r,t)=>{var a;let d=((a=n.current.get(r))===null||a===void 0?void 0:a.fn)||r;e.removeEventListener(l,d,t),n.current.delete(r)},[]),c=o.useCallback(()=>{n.current.forEach((e,l)=>{s(e.eventTarget,e.type,l,e.options)})},[s]);return o.useEffect(()=>c,[c]),{addGlobalListener:u,removeGlobalListener:s,removeAllGlobalListeners:c}}export{b as $};
