import c from "../dom-utils/getNodeName.es.js";
import { isHTMLElement as f } from "../dom-utils/instanceOf.es.js";
function p(l) {
  var e = l.state;
  Object.keys(e.elements).forEach(function(t) {
    var r = e.styles[t] || {}, s = e.attributes[t] || {}, o = e.elements[t];
    !f(o) || !c(o) || (Object.assign(o.style, r), Object.keys(s).forEach(function(a) {
      var i = s[a];
      i === !1 ? o.removeAttribute(a) : o.setAttribute(a, i === !0 ? "" : i);
    }));
  });
}
function y(l) {
  var e = l.state, t = {
    popper: {
      position: e.options.strategy,
      left: "0",
      top: "0",
      margin: "0"
    },
    arrow: {
      position: "absolute"
    },
    reference: {}
  };
  return Object.assign(e.elements.popper.style, t.popper), e.styles = t, e.elements.arrow && Object.assign(e.elements.arrow.style, t.arrow), function() {
    Object.keys(e.elements).forEach(function(r) {
      var s = e.elements[r], o = e.attributes[r] || {}, a = Object.keys(e.styles.hasOwnProperty(r) ? e.styles[r] : t[r]), i = a.reduce(function(n, u) {
        return n[u] = "", n;
      }, {});
      !f(s) || !c(s) || (Object.assign(s.style, i), Object.keys(o).forEach(function(n) {
        s.removeAttribute(n);
      }));
    });
  };
}
const m = {
  name: "applyStyles",
  enabled: !0,
  phase: "write",
  fn: p,
  effect: y,
  requires: ["computeStyles"]
};
export {
  m as default
};
//# sourceMappingURL=applyStyles.es.js.map
