import { viewport as c } from "../enums.js";
import v from "./getViewportRect.js";
import C from "./getDocumentRect.js";
import x from "./listScrollParents.js";
import b from "./getOffsetParent.js";
import E from "./getDocumentElement.js";
import P from "./getComputedStyle.js";
import { isHTMLElement as w, isElement as m } from "./instanceOf.js";
import T from "./getBoundingClientRect.js";
import H from "./getParentNode.js";
import N from "./contains.js";
import y from "./getNodeName.js";
import l from "../utils/rectToClientRect.js";
import { max as u, min as a } from "../utils/math.js";
function B(i, r) {
  var t = T(i, !1, r === "fixed");
  return t.top = t.top + i.clientTop, t.left = t.left + i.clientLeft, t.bottom = t.top + i.clientHeight, t.right = t.left + i.clientWidth, t.width = i.clientWidth, t.height = i.clientHeight, t.x = t.left, t.y = t.top, t;
}
function d(i, r, t) {
  return r === c ? l(v(i, t)) : m(r) ? B(r, t) : l(C(E(i)));
}
function D(i) {
  var r = x(H(i)), t = ["absolute", "fixed"].indexOf(P(i).position) >= 0, e = t && w(i) ? b(i) : i;
  return m(e) ? r.filter(function(p) {
    return m(p) && N(p, e) && y(p) !== "body";
  }) : [];
}
function J(i, r, t, e) {
  var p = r === "clippingParents" ? D(i) : [].concat(r), g = [].concat(p, [t]), h = g[0], o = g.reduce(function(n, s) {
    var f = d(i, s, e);
    return n.top = u(f.top, n.top), n.right = a(f.right, n.right), n.bottom = a(f.bottom, n.bottom), n.left = u(f.left, n.left), n;
  }, d(i, h, e));
  return o.width = o.right - o.left, o.height = o.bottom - o.top, o.x = o.left, o.y = o.top, o;
}
export {
  J as default
};
//# sourceMappingURL=getClippingRect.js.map
