import f from "./index-extends.js";
import "react";
import { useLocaleText as _, useUtils as W } from "./index-useUtils.js";
import { PickersFadeTransitionGroup as F } from "./index-PickersFadeTransitionGroup.js";
import { ArrowDropDown as U } from "./index-icons.js";
import { PickersArrowSwitcher as j } from "./index-PickersArrowSwitcher.js";
import { useNextMonthDisabled as z, usePreviousMonthDisabled as O } from "./index-date-helpers-hooks.js";
import { buildDeprecatedPropsWarning as Y } from "./index-warning.js";
import { getPickersCalendarHeaderUtilityClass as G } from "./index-pickersCalendarHeaderClasses.js";
import { jsxs as b, jsx as n } from "react/jsx-runtime";
import K from "./index-useThemeProps.js";
import q from "./index-Fade.js";
import E from "./index-composeClasses.js";
import a from "./index-styled.js";
import J from "./index-IconButton2.js";
const Q = (t) => {
  const {
    classes: e
  } = t;
  return E({
    root: ["root"],
    labelContainer: ["labelContainer"],
    label: ["label"],
    switchViewButton: ["switchViewButton"],
    switchViewIcon: ["switchViewIcon"]
  }, G, e);
}, X = a("div", {
  name: "MuiPickersCalendarHeader",
  slot: "Root",
  overridesResolver: (t, e) => e.root
})({
  display: "flex",
  alignItems: "center",
  marginTop: 16,
  marginBottom: 8,
  paddingLeft: 24,
  paddingRight: 12,
  // prevent jumping in safari
  maxHeight: 30,
  minHeight: 30
}), Z = a("div", {
  name: "MuiPickersCalendarHeader",
  slot: "LabelContainer",
  overridesResolver: (t, e) => e.labelContainer
})(({
  theme: t
}) => f({
  display: "flex",
  maxHeight: 30,
  overflow: "hidden",
  alignItems: "center",
  cursor: "pointer",
  marginRight: "auto"
}, t.typography.body1, {
  fontWeight: t.typography.fontWeightMedium
})), $ = a("div", {
  name: "MuiPickersCalendarHeader",
  slot: "Label",
  overridesResolver: (t, e) => e.label
})({
  marginRight: 6
}), ee = a(J, {
  name: "MuiPickersCalendarHeader",
  slot: "SwitchViewButton",
  overridesResolver: (t, e) => e.switchViewButton
})({
  marginRight: "auto"
}), te = a(U, {
  name: "MuiPickersCalendarHeader",
  slot: "SwitchViewIcon",
  overridesResolver: (t, e) => e.switchViewIcon
})(({
  theme: t,
  ownerState: e
}) => f({
  willChange: "transform",
  transition: t.transitions.create("transform"),
  transform: "rotate(0deg)"
}, e.openView === "year" && {
  transform: "rotate(180deg)"
})), oe = Y("Props for translation are deprecated. See https://mui.com/x/react-date-pickers/localization for more information.");
function xe(t) {
  const e = K({
    props: t,
    name: "MuiPickersCalendarHeader"
  }), {
    components: s = {},
    componentsProps: x = {},
    currentMonth: r,
    disabled: P,
    disableFuture: B,
    disablePast: V,
    getViewSwitchingButtonText: m,
    leftArrowButtonText: h,
    maxDate: v,
    minDate: T,
    onMonthChange: C,
    onViewChange: w,
    openView: l,
    reduceAnimations: k,
    rightArrowButtonText: u,
    views: o,
    labelId: M
  } = e;
  oe({
    leftArrowButtonText: h,
    rightArrowButtonText: u,
    getViewSwitchingButtonText: m
  });
  const p = _(), S = h ?? p.previousMonth, A = u ?? p.nextMonth, H = m ?? p.calendarViewSwitchingButtonAriaLabel, c = W(), i = Q(e), y = x.switchViewButton || {}, R = () => C(c.getNextMonth(r), "left"), I = () => C(c.getPreviousMonth(r), "right"), D = z(r, {
    disableFuture: B,
    maxDate: v
  }), L = O(r, {
    disablePast: V,
    minDate: T
  }), N = () => {
    if (!(o.length === 1 || !w || P))
      if (o.length === 2)
        w(o.find((g) => g !== l) || o[0]);
      else {
        const g = o.indexOf(l) !== 0 ? 0 : 1;
        w(o[g]);
      }
  };
  if (o.length === 1 && o[0] === "year")
    return null;
  const d = e;
  return /* @__PURE__ */ b(X, {
    ownerState: d,
    className: i.root,
    children: [/* @__PURE__ */ b(Z, {
      role: "presentation",
      onClick: N,
      ownerState: d,
      "aria-live": "polite",
      className: i.labelContainer,
      children: [/* @__PURE__ */ n(F, {
        reduceAnimations: k,
        transKey: c.format(r, "monthAndYear"),
        children: /* @__PURE__ */ n($, {
          id: M,
          ownerState: d,
          className: i.label,
          children: c.format(r, "monthAndYear")
        })
      }), o.length > 1 && !P && /* @__PURE__ */ n(ee, f({
        size: "small",
        as: s.SwitchViewButton,
        "aria-label": H(l),
        className: i.switchViewButton
      }, y, {
        children: /* @__PURE__ */ n(te, {
          as: s.SwitchViewIcon,
          ownerState: d,
          className: i.switchViewIcon
        })
      }))]
    }), /* @__PURE__ */ n(q, {
      in: l === "day",
      children: /* @__PURE__ */ n(j, {
        leftArrowButtonText: S,
        rightArrowButtonText: A,
        components: s,
        componentsProps: x,
        onLeftClick: I,
        onRightClick: R,
        isLeftDisabled: L,
        isRightDisabled: D
      })
    })]
  });
}
export {
  xe as PickersCalendarHeader
};
