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

import { elementInViewport } from '../../utils/dom.mjs';
import '../../_chunks/dep-a0b4a044.mjs';
import '../../_chunks/dep-1cf2b129.mjs';
import '../../_chunks/dep-c959a6fb.mjs';
import '../../_chunks/dep-b4041200.mjs';
import '../../_chunks/dep-e3b14d70.mjs';
import '../../_chunks/dep-66d6733b.mjs';
import '../../_chunks/dep-c31e1d9e.mjs';
import '../../_chunks/dep-6b22dd27.mjs';
import '../../_chunks/dep-0f0c89ff.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
