"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");exports.useGlobalListeners=function(){let t=e.useRef(new Map),r=e.useCallback(((e,r,n,l)=>{let o=(null==l?void 0:l.once)?function(){t.current.delete(n),n(...arguments)}:n;t.current.set(n,{type:r,eventTarget:e,fn:o,options:l}),e.addEventListener(r,o,l)}),[]),n=e.useCallback(((e,r,n,l)=>{var o;let s=(null===(o=t.current.get(n))||void 0===o?void 0:o.fn)||n;e.removeEventListener(r,s,l),t.current.delete(n)}),[]),l=e.useCallback((()=>{t.current.forEach(((e,t)=>{n(e.eventTarget,e.type,t,e.options)}))}),[n]);return e.useEffect((()=>l),[l]),{addGlobalListener:r,removeGlobalListener:n,removeAllGlobalListeners:l}};
//# sourceMappingURL=useGlobalListeners.mjs.js.map
