var TOLERANCE = 1; // Погрешность для субпиксельного рендеринга

var getIsFirstOverflowingTab = function getIsFirstOverflowingTab(item, maxScroll) {
  var orientation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'horizontal';
  if (!item.current) {
    return;
  }
  var currentOffset = orientation === 'horizontal' ? item.current.offsetLeft : item.current.offsetTop;
  if (currentOffset === undefined) {
    return;
  }
  return currentOffset < maxScroll - TOLERANCE;
};
var getIsLastOverflowingTab = function getIsLastOverflowingTab(item, minScroll) {
  var orientation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'horizontal';
  if (!item.current) {
    return;
  }
  var currentOffset = orientation === 'horizontal' ? item.current.offsetLeft : item.current.offsetTop;
  if (currentOffset === undefined) {
    return;
  }
  var additionalOffset = orientation === 'horizontal' ? item.current.offsetWidth : item.current.offsetHeight;
  var itemRightEdge = currentOffset + additionalOffset;
  return itemRightEdge > minScroll + TOLERANCE;
};
var getFirstOverflowingTab = function getFirstOverflowingTab(items, maxScroll) {
  var orientation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'horizontal';
  return items.find(function (item) {
    return getIsFirstOverflowingTab(item, maxScroll, orientation);
  });
};
var getLastOverflowingTab = function getLastOverflowingTab(items, minScroll) {
  var orientation = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'horizontal';
  return items.find(function (item) {
    return getIsLastOverflowingTab(item, minScroll, orientation);
  });
};

export { getFirstOverflowingTab, getLastOverflowingTab };
