import { top as h, left as w, right as W, end as E, bottom as F } from "../enums.es.js";
import Y from "../dom-utils/getOffsetParent.es.js";
import k from "../dom-utils/getWindow.es.js";
import T from "../dom-utils/getDocumentElement.es.js";
import H from "../dom-utils/getComputedStyle.es.js";
import q from "../utils/getBasePlacement.es.js";
import z from "../utils/getVariation.es.js";
import { round as $ } from "../utils/math.es.js";
var G = {
  top: "auto",
  right: "auto",
  bottom: "auto",
  left: "auto"
};
function I(e) {
  var t = e.x, a = e.y, s = window, o = s.devicePixelRatio || 1;
  return {
    x: $(t * o) / o || 0,
    y: $(a * o) / o || 0
  };
}
function B(e) {
  var t, a = e.popper, s = e.popperRect, o = e.placement, f = e.variation, n = e.offsets, d = e.position, m = e.gpuAcceleration, v = e.adaptive, c = e.roundOffsets, y = e.isFixed, O = n.x, i = O === void 0 ? 0 : O, b = n.y, r = b === void 0 ? 0 : b, S = typeof c == "function" ? c({
    x: i,
    y: r
  }) : {
    x: i,
    y: r
  };
  i = S.x, r = S.y;
  var D = n.hasOwnProperty("x"), j = n.hasOwnProperty("y"), g = w, x = h, l = window;
  if (v) {
    var p = Y(a), A = "clientHeight", R = "clientWidth";
    if (p === k(a) && (p = T(a), H(p).position !== "static" && d === "absolute" && (A = "scrollHeight", R = "scrollWidth")), p = p, o === h || (o === w || o === W) && f === E) {
      x = F;
      var N = y && p === l && l.visualViewport ? l.visualViewport.height : p[A];
      r -= N - s.height, r *= m ? 1 : -1;
    }
    if (o === w || (o === h || o === F) && f === E) {
      g = W;
      var X = y && p === l && l.visualViewport ? l.visualViewport.width : p[R];
      i -= X - s.width, i *= m ? 1 : -1;
    }
  }
  var V = Object.assign({
    position: d
  }, v && G), C = c === !0 ? I({
    x: i,
    y: r
  }) : {
    x: i,
    y: r
  };
  if (i = C.x, r = C.y, m) {
    var u;
    return Object.assign({}, V, (u = {}, u[x] = j ? "0" : "", u[g] = D ? "0" : "", u.transform = (l.devicePixelRatio || 1) <= 1 ? "translate(" + i + "px, " + r + "px)" : "translate3d(" + i + "px, " + r + "px, 0)", u));
  }
  return Object.assign({}, V, (t = {}, t[x] = j ? r + "px" : "", t[g] = D ? i + "px" : "", t.transform = "", t));
}
function J(e) {
  var t = e.state, a = e.options, s = a.gpuAcceleration, o = s === void 0 ? !0 : s, f = a.adaptive, n = f === void 0 ? !0 : f, d = a.roundOffsets, m = d === void 0 ? !0 : d;
  if (process.env.NODE_ENV !== "production") {
    var v = H(t.elements.popper).transitionProperty || "";
    n && ["transform", "top", "right", "bottom", "left"].some(function(y) {
      return v.indexOf(y) >= 0;
    }) && console.warn(["Popper: Detected CSS transitions on at least one of the following", 'CSS properties: "transform", "top", "right", "bottom", "left".', `

`, 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', "for smooth transitions, or remove these properties from the CSS", "transition declaration on the popper element if only transitioning", "opacity or background-color for example.", `

`, "We recommend using the popper element as a wrapper around an inner", "element that can have any CSS property transitioned for animations."].join(" "));
  }
  var c = {
    placement: q(t.placement),
    variation: z(t.placement),
    popper: t.elements.popper,
    popperRect: t.rects.popper,
    gpuAcceleration: o,
    isFixed: t.options.strategy === "fixed"
  };
  t.modifiersData.popperOffsets != null && (t.styles.popper = Object.assign({}, t.styles.popper, B(Object.assign({}, c, {
    offsets: t.modifiersData.popperOffsets,
    position: t.options.strategy,
    adaptive: n,
    roundOffsets: m
  })))), t.modifiersData.arrow != null && (t.styles.arrow = Object.assign({}, t.styles.arrow, B(Object.assign({}, c, {
    offsets: t.modifiersData.arrow,
    position: "absolute",
    adaptive: !1,
    roundOffsets: m
  })))), t.attributes.popper = Object.assign({}, t.attributes.popper, {
    "data-popper-placement": t.placement
  });
}
const tt = {
  name: "computeStyles",
  enabled: !0,
  phase: "beforeWrite",
  fn: J,
  data: {}
};
export {
  tt as default,
  B as mapToStyles
};
//# sourceMappingURL=computeStyles.es.js.map
