/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

import { elementInViewport } from '../../utils/dom.mjs';
import '../../_chunks/dep-eba0ea6e.mjs';
import '../../_chunks/dep-876fb3ec.mjs';
import '../../_chunks/dep-469b4ae0.mjs';
import '../../_chunks/dep-255303ba.mjs';
import '../../_chunks/dep-b57180d0.mjs';
import '../../_chunks/dep-c8d7b6b4.mjs';
import '../../_chunks/dep-3da99438.mjs';
import '../../_chunks/dep-5717e263.mjs';
import '../../_chunks/dep-a8bcacea.mjs';
import '../../utils/easing.mjs';

function getScrollParent(element) {
  var style = window.getComputedStyle(element);
  var excludeStaticParent = style.position === "absolute";
  var overflowRegex = /(auto|scroll)/;
  if (style.position === "fixed") return document.body;
  for (var parent = element; parent.parentElement;) {
    parent = parent.parentElement;
    style = window.getComputedStyle(parent);
    if (excludeStaticParent && style.position === "static") continue;
    if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) return parent;
  }
  return document.body;
}
function scrollToParentVisibleArea(element) {
  var parent = getScrollParent(element);
  if (parent === document.body) return;
  if (elementInViewport(element, parent)) return;
  parent.scrollTop = element.offsetTop - parent.offsetTop;
}

export { getScrollParent, scrollToParentVisibleArea };
//# sourceMappingURL=getScrollParent.mjs.map
