import "core-js/modules/es.array.includes.js";
import { canUseDom } from './can-use-dom';
var defaultRoot = canUseDom ? window : undefined;
var overflowStylePatterns = ['scroll', 'auto', 'overlay'];
function isElement(node) {
  var ELEMENT_NODE_TYPE = 1;
  return node.nodeType === ELEMENT_NODE_TYPE;
}
export function getScrollParent(el) {
  var root = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultRoot;
  var node = el;
  while (node && node !== root && isElement(node)) {
    if (node === document.body) {
      return root;
    }
    var _window$getComputedSt = window.getComputedStyle(node),
      overflowY = _window$getComputedSt.overflowY;
    if (overflowStylePatterns.includes(overflowY) && node.scrollHeight > node.clientHeight) {
      return node;
    }
    node = node.parentNode;
  }
  return root;
}