function s() {
  return typeof window < "u";
}
function f(t) {
  return m(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function i(t) {
  var n;
  return (t == null || (n = t.ownerDocument) == null ? void 0 : n.defaultView) || window;
}
function L(t) {
  var n;
  return (n = (m(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : n.documentElement;
}
function m(t) {
  return s() ? t instanceof Node || t instanceof i(t).Node : !1;
}
function h(t) {
  return s() ? t instanceof Element || t instanceof i(t).Element : !1;
}
function g(t) {
  return s() ? t instanceof HTMLElement || t instanceof i(t).HTMLElement : !1;
}
function p(t) {
  return !s() || typeof ShadowRoot > "u" ? !1 : t instanceof ShadowRoot || t instanceof i(t).ShadowRoot;
}
function y(t) {
  const {
    overflow: n,
    overflowX: r,
    overflowY: c,
    display: e
  } = N(t);
  return /auto|scroll|overlay|hidden|clip/.test(n + c + r) && e !== "inline" && e !== "contents";
}
function _(t) {
  return /^(table|td|th)$/.test(f(t));
}
function T(t) {
  try {
    if (t.matches(":popover-open"))
      return !0;
  } catch {
  }
  try {
    return t.matches(":modal");
  } catch {
    return !1;
  }
}
const v = /transform|translate|scale|rotate|perspective|filter/, C = /paint|layout|strict|content/, o = (t) => !!t && t !== "none";
let l;
function D(t) {
  const n = h(t) ? N(t) : t;
  return o(n.transform) || o(n.translate) || o(n.scale) || o(n.rotate) || o(n.perspective) || !k() && (o(n.backdropFilter) || o(n.filter)) || v.test(n.willChange || "") || C.test(n.contain || "");
}
function W(t) {
  let n = a(t);
  for (; g(n) && !b(n); ) {
    if (D(n))
      return n;
    if (T(n))
      return null;
    n = a(n);
  }
  return null;
}
function k() {
  return l == null && (l = typeof CSS < "u" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none")), l;
}
function b(t) {
  return /^(html|body|#document)$/.test(f(t));
}
function N(t) {
  return i(t).getComputedStyle(t);
}
function $(t) {
  return h(t) ? {
    scrollLeft: t.scrollLeft,
    scrollTop: t.scrollTop
  } : {
    scrollLeft: t.scrollX,
    scrollTop: t.scrollY
  };
}
function a(t) {
  if (f(t) === "html")
    return t;
  const n = (
    // Step into the shadow DOM of the parent of a slotted node.
    t.assignedSlot || // DOM Element detected.
    t.parentNode || // ShadowRoot detected.
    p(t) && t.host || // Fallback.
    L(t)
  );
  return p(n) ? n.host : n;
}
function S(t) {
  const n = a(t);
  return b(n) ? t.ownerDocument ? t.ownerDocument.body : t.body : g(n) && y(n) ? n : S(n);
}
function w(t, n, r) {
  var c;
  n === void 0 && (n = []), r === void 0 && (r = !0);
  const e = S(t), E = e === ((c = t.ownerDocument) == null ? void 0 : c.body), u = i(e);
  if (E) {
    const d = R(u);
    return n.concat(u, u.visualViewport || [], y(e) ? e : [], d && r ? w(d) : []);
  } else
    return n.concat(e, w(e, [], r));
}
function R(t) {
  return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
export {
  h as a,
  N as b,
  p as c,
  y as d,
  f as e,
  w as f,
  i as g,
  L as h,
  g as i,
  R as j,
  k,
  T as l,
  a as m,
  b as n,
  _ as o,
  D as p,
  W as q,
  $ as r,
  m as s
};
