import { isSVGElement as r } from "../utils/is-svg-element.es.js";
import { resolveElements as h } from "../utils/resolve-elements.es.js";
const o = /* @__PURE__ */ new WeakMap();
let n;
const c = (i, f, s) => (t, e) => e && e[0] ? e[0][i + "Size"] : r(t) && "getBBox" in t ? t.getBBox()[f] : t[s], u = /* @__PURE__ */ c("inline", "width", "offsetWidth"), g = /* @__PURE__ */ c("block", "height", "offsetHeight");
function l({ target: i, borderBoxSize: f }) {
  var s;
  (s = o.get(i)) == null || s.forEach((t) => {
    t(i, {
      get width() {
        return u(i, f);
      },
      get height() {
        return g(i, f);
      }
    });
  });
}
function E(i) {
  i.forEach(l);
}
function p() {
  typeof ResizeObserver > "u" || (n = new ResizeObserver(E));
}
function d(i, f) {
  n || p();
  const s = h(i);
  return s.forEach((t) => {
    let e = o.get(t);
    e || (e = /* @__PURE__ */ new Set(), o.set(t, e)), e.add(f), n == null || n.observe(t);
  }), () => {
    s.forEach((t) => {
      const e = o.get(t);
      e == null || e.delete(f), e != null && e.size || n == null || n.unobserve(t);
    });
  };
}
export {
  d as resizeElement
};
//# sourceMappingURL=handle-element.es.js.map
