text: import { useEffect } from 'react';
  export function useScrollLock(allowScrollWithin, disabled) {
      if (disabled === void 0) { disabled = false; }
      useEffect(function () {
          var scrollTop = window.scrollY;
          var scrollTarget = document;
          function stopScroll(e) {
              if (e.target !== null && e.target !== scrollTarget) {
                  scrollTarget = e.target;
                  scrollTop =
                      scrollTarget instanceof Element
                          ? scrollTarget.scrollTop
                          : window.scrollY;
              }
              if (scrollTarget instanceof Element &&
                  !(allowScrollWithin &&
                      allowScrollWithin.current &&
                      allowScrollWithin.current.contains(scrollTarget))) {
                  scrollTarget.scrollTop = scrollTop;
              }
              else if (scrollTarget === document) {
                  window.scrollTo({ top: scrollTop });
              }
          }
          if (disabled) {
              window.removeEventListener('scroll', stopScroll, true);
          }
          else {
              window.addEventListener('scroll', stopScroll, true);
          }
          return function () {
              window.removeEventListener('scroll', stopScroll, true);
          };
      }, [disabled, allowScrollWithin]);
  }
  //# sourceMappingURL=useScrollLock.js.map