import { j as t } from "../../../../_virtual/jsx-runtime.js";
import l from "../../../../icons/ChevronDown.js";
import d from "../../../../icons/ChevronLeft.js";
import c from "../../../../icons/ChevronRight.js";
import m from "../../../../icons/ChevronUp.js";
import { getId as y } from "../../../../utils/index.js";
import { SingleDateWrapper as b, RangeButtonsWrapper as k, MonthSelector as z, YearSelector as M, ButtonsWrapper as h } from "./styles.js";
import { IconButton as e } from "../../../IconButton/index.js";
import { getMonthName as B, YEARS_TO_DISPLAY as I } from "../../dateUtils.js";
const Y = "previousMonthIconButton";
function D({
  viewType: o,
  locale: x,
  currentMonth: p,
  currentYear: i,
  minDate: r,
  maxDate: n,
  updateViewType: s,
  handlePrevYear: j,
  handleNextYear: g,
  handlePrevMonth: v,
  handleNextMonth: u,
  "data-testid": f
}) {
  const a = y(f), C = () => {
    s(o === "year" ? "calendar" : "year");
  }, S = () => {
    s(o === "month" ? "calendar" : "month");
  };
  return /* @__PURE__ */ t.jsxs(b, { "data-testid": a("single-date"), children: [
    /* @__PURE__ */ t.jsxs(k, { children: [
      /* @__PURE__ */ t.jsx(
        z,
        {
          "data-testid": a("month-selector"),
          "aria-live": "polite",
          variant: "ghost",
          size: "xSmall",
          icon: o === "month" ? /* @__PURE__ */ t.jsx(m, {}) : /* @__PURE__ */ t.jsx(l, {}),
          iconPosition: "trailing",
          onClick: S,
          children: B(p, x)
        }
      ),
      /* @__PURE__ */ t.jsx(
        M,
        {
          "data-testid": a("year-selector"),
          "aria-live": "polite",
          variant: "ghost",
          size: "xSmall",
          icon: o === "year" ? /* @__PURE__ */ t.jsx(m, {}) : /* @__PURE__ */ t.jsx(l, {}),
          iconPosition: "trailing",
          onClick: C,
          children: i
        }
      )
    ] }),
    o === "calendar" && /* @__PURE__ */ t.jsxs(h, { "data-testid": a("calendar-navigation"), children: [
      /* @__PURE__ */ t.jsx(
        e,
        {
          className: Y,
          icon: /* @__PURE__ */ t.jsx(d, {}),
          variant: "ghost-tertiary",
          size: "x-small",
          onClick: v,
          "aria-label": "previous month",
          "data-testid": a("previous-month")
        }
      ),
      /* @__PURE__ */ t.jsx(
        e,
        {
          icon: /* @__PURE__ */ t.jsx(c, {}),
          variant: "ghost-tertiary",
          size: "x-small",
          onClick: u,
          "aria-label": "next month",
          "data-testid": a("next-month")
        }
      )
    ] }),
    o === "year" && /* @__PURE__ */ t.jsxs(h, { "data-testid": a("year-navigation"), children: [
      /* @__PURE__ */ t.jsx(
        e,
        {
          icon: /* @__PURE__ */ t.jsx(d, {}),
          variant: "ghost-tertiary",
          size: "x-small",
          onClick: j,
          "aria-label": "previous year",
          "data-testid": a("previous-year"),
          disabled: r && i - 1 < r.getFullYear()
        }
      ),
      /* @__PURE__ */ t.jsx(
        e,
        {
          icon: /* @__PURE__ */ t.jsx(c, {}),
          variant: "ghost-tertiary",
          size: "x-small",
          onClick: g,
          "aria-label": "next year",
          "data-testid": a("next-year"),
          disabled: n && i + I > n.getFullYear()
        }
      )
    ] })
  ] });
}
export {
  D as MonthAndYearSelectionHeader,
  Y as previousMonthButton
};
