import { useState as A, useCallback as b, useEffect as B } from "react";
import M from "../../hooks/useResizeObserver.js";
import k from "../../hooks/useWindowResize.js";
const q = 480, _ = (f = []) => {
  const [l, , { inlineSize: u }] = M(), [g, o] = A(!1), s = b(() => {
    const n = l.current;
    if (!n || typeof window > "u")
      return;
    const r = n.querySelector(".rdp-months"), d = r ? Array.from(r.querySelectorAll(".rdp-month")) : [], m = d[0];
    if (!r || !m) {
      o(!1);
      return;
    }
    const i = n.parentElement, a = i?.parentElement, h = a?.parentElement, c = window.document.documentElement.clientWidth;
    if (!i || !a || !h || !u || !c) {
      o(!1);
      return;
    }
    if (c < q) {
      o(!1);
      return;
    }
    const p = Number.parseFloat(window.getComputedStyle(r).columnGap || "0") || 0, w = m.getBoundingClientRect().width, C = Math.max(
      0,
      n.getBoundingClientRect().width - r.getBoundingClientRect().width
    ), E = w * d.length + p * (d.length - 1) + C, S = Array.from(i.children).reduce((e, t) => t === n ? e : e + t.getBoundingClientRect().width, 0), R = Array.from(a.children).reduce((e, t) => t === i ? e : Math.max(e, t.getBoundingClientRect().width), 0), y = Array.from(h.children).reduce((e, t) => t === a ? e : e + t.getBoundingClientRect().width, 0), W = Math.max(E + S, R);
    o(W + y > c - 32);
  }, [u, l]);
  return k(s), B(() => {
    s();
  }, [s, ...f]), {
    calendarsRef: l,
    stackCalendars: g
  };
};
export {
  _ as default
};
//# sourceMappingURL=useStackedDayPickerCalendars.js.map
