ntainer$getAllowed : 'all';
  var scrollBy = getScrollBy({
    element: element,
    engagement: engagement,
    input: input,
    timeSinceLastFrame: timeSinceLastFrame,
    allowedAxis: allowedAxis,
    config: config
  });

  // Only allow scrolling in directions that have not already been used
  var scroll = {
    top: 0,
    left: 0
  };
  if (available.top && scrollBy.top !== 0) {
    scroll.top = scrollBy.top;
    // can no longer scroll on the top after this
    available.top = false;
  }
  if (available.left && scrollBy.left !== 0) {
    scroll.left = scrollBy.left;
    // can no longer scroll on the left after this
    available.left = false;
  }

  // Only scroll if there is something to scroll
  if (scroll.top !== 0 || scroll.left !== 0) {
    element.scrollBy(scroll);
  }
  return continueSearchUp();
}
function tryScrollWindow(_ref2) {
  var input = _ref2.input,
    timeSinceLastFrame = _ref2.timeSinceLastFrame,
    available = _ref2.available,
    source = _ref2.source,
    entries = _ref2.entries;
  var element = document.documentElement;
  var feedback = {
    input: input,
    source: source,
    element: element
  };
  var _iterator = _createForOfIteratorHelper(entries),
    _step;
  try {
    for (_iterator.s(); !(_step = _iterator.n()).done;) {
      var _entry$getConfigurati, _entry$getAllowedAxis, _entry$getAllowedAxis2;
      var entry = _step.value;
      // this entry is not allowing scrolling, we need to look for another
      if (entry.canScroll && !entry.canScroll(feedback)) {
        continue;
      }

      // Note: if we had an event for when the user is leaving a tab
      // we _could_ conceptually reset the engagement
      var engagement = markAndGetEngagement(element);
      var config = getInternalConfig((_entry$getConfigurati = entry.getConfiguration) === null || _entry$getConfigurati === void 0 ? void 0 : _entry$getConfigurati.call(entry, feedback));
      var allowedAxis = (_entry$getAllowedAxis = (_entry$getAllowedAxis2 = entry.getAllowedAxis) === null || _entry$getAllowedAxis2 === void 0 ? void 0 : _entry$getAllowedAxis2.call(entry, feedback)) !== null && _entry$getAllowedAxis !== void 0 ? _entry$getAllowedAxis : 'all';
      var scrollBy = getScrollBy({
        element: element,
        engagement: engagement,
        input: input,
        config: config,
        allowedAxis: allowedAxis,
        getRect: function getRect(element) {
          return DOMRect.fromRect({
            y: 0,
            x: 0,
            width: element.clientWidth,
            height: element.clientHeight
          });
        },
        timeSinceLastFrame: timeSinceLastFrame
      });
      var scroll = {
        top: available.top ? scrollBy.top : 0,
        left: available.left ? scrollBy.left : 0
      };

      // only trigger a scroll if we are actually scrolling
      if (scroll.top !== 0 || scroll.left !== 0) {
        element.scrollBy(scroll);
      }

      // We only want the window to scroll once
      break;
    }
  } catch (err) {
    _iterator.e(err);
  } finally {
    _iterator.f();
  }
}
export function tryScroll(_ref3) {
  var input = _ref3.input,
    findEntry = _ref3.findEntry,
    timeSinceLastFrame = _ref3.timeSinceLastFrame,
    source = _ref3.source,
    getWindowScrollEntries = _ref3.getWindowScrollEntries,
    underUsersPointer = _ref3.underUsersPointer;
  // We are matching browser behaviour and scrolling inner elements
  // before outer ones. So we try to scroll scroller containers before
  // the window.
  var remainder = tryScrollElements({
    target: underUsersPointer,
    timeSinceLastFrame: timeSinceLastFrame,
    input: input,
    source: source,
    findEntry: findEntry
  });

  // Check if we can do any window scrolling
  if (!isScrollingAvailable(remainder)) {
    return;
  }
  tryScrollWindow({
    input: input,
    source: source,
    entries: getWindowScrollEntries(),
    timeSinceLastFrame: timeSinceLastFrame,
    available: remainder
  });
}