import _toConsumableArray from"@babel/runtime/helpers/toConsumableArray";import _slicedToArray from"@babel/runtime/helpers/slicedToArray";import{useCallback,useEffect,useLayoutEffect,useRef}from"react";export var usePaginationKeys=function(a){var b=a.containerEventListener,c=void 0===b?window:b,d=a.hotKeys,e=a.nextButtonRef,f=a.prevButtonRef,g=useRef([]),h=useRef(null!==d&&void 0!==d?d:[]),i=function(a){var b=a.key;g.current=g.current.filter(function(a){return a!==b})},j=useCallback(function(a){var b=a.key,c=_slicedToArray(h.current,2),d=c[0],i=c[1];if(null!==d&&void 0!==d&&d.keys.includes(b)||null!==i&&void 0!==i&&i.keys.includes(b)){var l=[].concat(_toConsumableArray(g.current),[b]);if(null!==i&&void 0!==i&&i.keys.every(function(a){return l.includes(a)})){var j;null===e||void 0===e||null===(j=e.current)||void 0===j?void 0:j.click()}else if(null!==d&&void 0!==d&&d.keys.every(function(a){return l.includes(a)})){var k;null===f||void 0===f||null===(k=f.current)||void 0===k?void 0:k.click()}g.current=l}},[d]);useLayoutEffect(function(){return c.addEventListener("keydown",j),c.addEventListener("keyup",i),function(){c.removeEventListener("keydown",j),c.removeEventListener("keyup",i)}},[e,f,c]),useEffect(function(){d&&(h.current=d)},[d])};
//# sourceMappingURL=usePaginationKeys.js.map