"use client";
import * as d from "react";
import { useLayoutEffect as h } from "../../react-use-layout-effect/dist/index.js";
function z(r) {
  const [c, e] = d.useState(void 0);
  return h(() => {
    if (r) {
      e({ width: r.offsetWidth, height: r.offsetHeight });
      const f = new ResizeObserver((i) => {
        if (!Array.isArray(i) || !i.length)
          return;
        const u = i[0];
        let o, t;
        if ("borderBoxSize" in u) {
          const s = u.borderBoxSize, b = Array.isArray(s) ? s[0] : s;
          o = b.inlineSize, t = b.blockSize;
        } else
          o = r.offsetWidth, t = r.offsetHeight;
        e({ width: o, height: t });
      });
      return f.observe(r, { box: "border-box" }), () => f.unobserve(r);
    } else
      e(void 0);
  }, [r]), c;
}
export {
  z as useSize
};
