import G from "./index-objectWithoutPropertiesLoose.js";
import y from "./index-extends.js";
import * as m from "react";
import e from "./index-_virtual16.js";
import { clsx as T } from "./index-clsx.m.js";
import { useUtils as L } from "./index-useUtils.js";
import { DAY_SIZE as S, DAY_MARGIN as V } from "./index-dimensions.js";
import { getPickersDayUtilityClass as Z, pickersDayClasses as u } from "./index-pickersDayClasses.js";
import { jsx as A } from "react/jsx-runtime";
import z from "./index-useThemeProps.js";
import J from "./index-useForkRef.js";
import Q from "./index-useEnhancedEffect2.js";
import X from "./index-composeClasses.js";
import B from "./index-styled.js";
import v from "./index-ButtonBase.js";
import { alpha as N } from "./index-colorManipulator.js";
const P = ["autoFocus", "className", "day", "disabled", "disableHighlightToday", "disableMargin", "hidden", "isAnimating", "onClick", "onDaySelect", "onFocus", "onBlur", "onKeyDown", "onMouseDown", "outsideCurrentMonth", "selected", "showDaysOutsideCurrentMonth", "children", "today"], oo = (o) => {
  const {
    selected: t,
    disableMargin: a,
    disableHighlightToday: r,
    today: l,
    disabled: c,
    outsideCurrentMonth: n,
    showDaysOutsideCurrentMonth: s,
    classes: h
  } = o;
  return X({
    root: ["root", t && "selected", c && "disabled", !a && "dayWithMargin", !r && l && "today", n && s && "dayOutsideMonth", n && !s && "hiddenDaySpacingFiller"],
    hiddenDaySpacingFiller: ["hiddenDaySpacingFiller"]
  }, Z, h);
}, H = ({
  theme: o,
  ownerState: t
}) => y({}, o.typography.caption, {
  width: S,
  height: S,
  borderRadius: "50%",
  padding: 0,
  // background required here to prevent collides with the other days when animating with transition group
  backgroundColor: o.palette.background.paper,
  color: o.palette.text.primary,
  "&:hover": {
    backgroundColor: N(o.palette.action.active, o.palette.action.hoverOpacity)
  },
  "&:focus": {
    backgroundColor: N(o.palette.action.active, o.palette.action.hoverOpacity),
    [`&.${u.selected}`]: {
      willChange: "background-color",
      backgroundColor: o.palette.primary.dark
    }
  },
  [`&.${u.selected}`]: {
    color: o.palette.primary.contrastText,
    backgroundColor: o.palette.primary.main,
    fontWeight: o.typography.fontWeightMedium,
    transition: o.transitions.create("background-color", {
      duration: o.transitions.duration.short
    }),
    "&:hover": {
      willChange: "background-color",
      backgroundColor: o.palette.primary.dark
    }
  },
  [`&.${u.disabled}`]: {
    color: o.palette.text.disabled
  }
}, !t.disableMargin && {
  margin: `0 ${V}px`
}, t.outsideCurrentMonth && t.showDaysOutsideCurrentMonth && {
  color: o.palette.text.secondary
}, !t.disableHighlightToday && t.today && {
  [`&:not(.${u.selected})`]: {
    border: `1px solid ${o.palette.text.secondary}`
  }
}), E = (o, t) => {
  const {
    ownerState: a
  } = o;
  return [t.root, !a.disableMargin && t.dayWithMargin, !a.disableHighlightToday && a.today && t.today, !a.outsideCurrentMonth && a.showDaysOutsideCurrentMonth && t.dayOutsideMonth, a.outsideCurrentMonth && !a.showDaysOutsideCurrentMonth && t.hiddenDaySpacingFiller];
}, to = B(v, {
  name: "MuiPickersDay",
  slot: "Root",
  overridesResolver: E
})(H), eo = B("div", {
  name: "MuiPickersDay",
  slot: "Root",
  overridesResolver: E
})(({
  theme: o,
  ownerState: t
}) => y({}, H({
  theme: o,
  ownerState: t
}), {
  // visibility: 'hidden' does not work here as it hides the element from screen readers as well
  opacity: 0,
  pointerEvents: "none"
})), b = () => {
}, _ = /* @__PURE__ */ m.forwardRef(function(t, a) {
  const r = z({
    props: t,
    name: "MuiPickersDay"
  }), {
    autoFocus: l = !1,
    className: c,
    day: n,
    disabled: s = !1,
    disableHighlightToday: h = !1,
    disableMargin: D = !1,
    isAnimating: M,
    onClick: p,
    onDaySelect: $,
    onFocus: j = b,
    onBlur: W = b,
    onKeyDown: q = b,
    onMouseDown: C,
    outsideCurrentMonth: d,
    selected: k = !1,
    showDaysOutsideCurrentMonth: w = !1,
    children: O,
    today: K = !1
  } = r, F = G(r, P), f = y({}, r, {
    autoFocus: l,
    disabled: s,
    disableHighlightToday: h,
    disableMargin: D,
    selected: k,
    showDaysOutsideCurrentMonth: w,
    today: K
  }), g = oo(f), x = L(), R = m.useRef(null), I = J(R, a);
  Q(() => {
    l && !s && !M && !d && R.current.focus();
  }, [l, s, M, d]);
  const U = (i) => {
    C && C(i), d && i.preventDefault();
  }, Y = (i) => {
    s || $(n, "finish"), d && i.currentTarget.focus(), p && p(i);
  };
  return d && !w ? /* @__PURE__ */ A(eo, {
    className: T(g.root, g.hiddenDaySpacingFiller, c),
    ownerState: f,
    role: F.role
  }) : /* @__PURE__ */ A(to, y({
    className: T(g.root, c),
    ownerState: f,
    ref: I,
    centerRipple: !0,
    disabled: s,
    tabIndex: k ? 0 : -1,
    onKeyDown: (i) => q(i, n),
    onFocus: (i) => j(i, n),
    onBlur: (i) => W(i, n),
    onClick: Y,
    onMouseDown: U
  }, F, {
    children: O || x.format(n, "dayOfMonth")
  }));
}), ao = (o, t) => o.autoFocus === t.autoFocus && o.isAnimating === t.isAnimating && o.today === t.today && o.disabled === t.disabled && o.selected === t.selected && o.disableMargin === t.disableMargin && o.showDaysOutsideCurrentMonth === t.showDaysOutsideCurrentMonth && o.disableHighlightToday === t.disableHighlightToday && o.className === t.className && o.sx === t.sx && o.outsideCurrentMonth === t.outsideCurrentMonth && o.onFocus === t.onFocus && o.onBlur === t.onBlur && o.onDaySelect === t.onDaySelect;
process.env.NODE_ENV !== "production" && (_.propTypes = {
  // ----------------------------- Warning --------------------------------
  // | These PropTypes are generated from the TypeScript type definitions |
  // | To update them edit the TypeScript types and run "yarn proptypes"  |
  // ----------------------------------------------------------------------
  /**
   * Override or extend the styles applied to the component.
   */
  classes: e.object,
  /**
   * The date to show.
   */
  day: e.any.isRequired,
  /**
   * If `true`, renders as disabled.
   * @default false
   */
  disabled: e.bool,
  /**
   * If `true`, today's date is rendering without highlighting with circle.
   * @default false
   */
  disableHighlightToday: e.bool,
  /**
   * If `true`, days are rendering without margin. Useful for displaying linked range of days.
   * @default false
   */
  disableMargin: e.bool,
  isAnimating: e.bool,
  onBlur: e.func,
  onDaySelect: e.func.isRequired,
  onFocus: e.func,
  onKeyDown: e.func,
  /**
   * If `true`, day is outside of month and will be hidden.
   */
  outsideCurrentMonth: e.bool.isRequired,
  /**
   * If `true`, renders as selected.
   * @default false
   */
  selected: e.bool,
  /**
   * If `true`, days that have `outsideCurrentMonth={true}` are displayed.
   * @default false
   */
  showDaysOutsideCurrentMonth: e.bool,
  /**
   * The system prop that allows defining system overrides as well as additional CSS styles.
   */
  sx: e.oneOfType([e.arrayOf(e.oneOfType([e.func, e.object, e.bool])), e.func, e.object]),
  /**
   * If `true`, renders as today date.
   * @default false
   */
  today: e.bool
});
const po = /* @__PURE__ */ m.memo(_, ao);
export {
  po as PickersDay,
  ao as areDayPropsEqual
};
