import { jsx as e, jsxs as n } from "react/jsx-runtime";
import { useEffect as C } from "react";
import s from "../../utils/classNames.js";
import v from "./DayPickerDropdownFooter.js";
import u from "./DayPickerDropdownSidebar.js";
import S from "./useStackedDayPickerCalendars.js";
const z = (b) => {
  const {
    assignPopperElement: x,
    popperStyles: w,
    popperAttributes: h,
    enableStackedCalendars: r = !1,
    dropdownClassName: y,
    outsideRef: D,
    updatePopperPosition: l,
    leftSidebar: a,
    rightSidebar: t,
    footer: d,
    leftSidebarClassName: k,
    rightSidebarClassName: N,
    footerClassName: P,
    children: c
  } = b, { calendarsRef: g, stackCalendars: m } = S([c, a, t]);
  C(() => {
    if (!r || !l)
      return;
    const o = window.requestAnimationFrame(() => {
      l();
    });
    return () => window.cancelAnimationFrame(o);
  }, [r, m, l]);
  const p = (o) => {
    const f = o.target;
    if (!f)
      return;
    const i = f.closest(
      'input:not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea, [contenteditable="true"], [role="combobox"], [role="textbox"]'
    );
    i && !i.hasAttribute("disabled") && i.getAttribute("aria-disabled") !== "true" || o.preventDefault();
  };
  return /* @__PURE__ */ e(
    "div",
    {
      ref: x,
      style: w,
      className: s(
        "DayPickerDropdown z-index-max bg-white shadow-default rounded margin-y-3 border",
        y
      ),
      ...h,
      role: "dialog",
      "aria-label": "DayPicker calendar",
      children: /* @__PURE__ */ e(
        "div",
        {
          ref: D,
          className: "display-flex flex-column",
          onPointerDownCapture: p,
          onMouseDownCapture: p,
          children: /* @__PURE__ */ n("div", { className: s(a && "display-flex flex-column-xs flex-row-sm"), children: [
            a && /* @__PURE__ */ e(u, { className: k, children: a }),
            /* @__PURE__ */ n("div", { children: [
              /* @__PURE__ */ n("div", { className: s(t && "display-flex flex-column-xs flex-row-sm"), children: [
                /* @__PURE__ */ e(
                  "div",
                  {
                    ref: r ? g : null,
                    className: s(
                      "DayPickerDropdown-calendars",
                      r && m && "stacked-calendars"
                    ),
                    children: c
                  }
                ),
                t && /* @__PURE__ */ e(u, { side: "right", className: N, children: t })
              ] }),
              d && /* @__PURE__ */ e(v, { className: P, children: d })
            ] })
          ] })
        }
      )
    }
  );
};
export {
  z as default
};
//# sourceMappingURL=DayPickerDropdown.js.map
