import h from "./index-objectWithoutPropertiesLoose.js";
import i from "./index-extends.js";
import * as n from "react";
import { clsx as Y } from "./index-clsx.m.js";
import { WrapperVariantContext as $ } from "./index-WrapperVariantContext.js";
import { getPickersYearUtilityClass as F, pickersYearClasses as t } from "./index-pickersYearClasses.js";
import { jsx as b } from "react/jsx-runtime";
import D from "./index-useForkRef.js";
import _ from "./index-capitalize.js";
import I from "./index-composeClasses.js";
import x from "./index-styled.js";
import { alpha as N } from "./index-colorManipulator.js";
const V = ["autoFocus", "className", "children", "disabled", "onClick", "onKeyDown", "value", "tabIndex", "onFocus", "onBlur"], j = (o) => {
  const {
    wrapperVariant: e,
    disabled: c,
    selected: a,
    classes: l
  } = o, d = {
    root: ["root", e && `mode${_(e)}`],
    yearButton: ["yearButton", c && "disabled", a && "selected"]
  };
  return I(d, F, l);
}, K = x("div", {
  name: "PrivatePickersYear",
  slot: "Root",
  overridesResolver: (o, e) => [e.root, {
    [`&.${t.modeDesktop}`]: e.modeDesktop
  }, {
    [`&.${t.modeMobile}`]: e.modeMobile
  }]
})(({
  ownerState: o
}) => i({
  flexBasis: "33.3%",
  display: "flex",
  alignItems: "center",
  justifyContent: "center"
}, (o == null ? void 0 : o.wrapperVariant) === "desktop" && {
  flexBasis: "25%"
})), M = x("button", {
  name: "PrivatePickersYear",
  slot: "Button",
  overridesResolver: (o, e) => [e.button, {
    [`&.${t.disabled}`]: e.disabled
  }, {
    [`&.${t.selected}`]: e.selected
  }]
})(({
  theme: o
}) => i({
  color: "unset",
  backgroundColor: "transparent",
  border: 0,
  outline: 0
}, o.typography.subtitle1, {
  margin: "8px 0",
  height: 36,
  width: 72,
  borderRadius: 18,
  cursor: "pointer",
  "&:focus, &:hover": {
    backgroundColor: N(o.palette.action.active, o.palette.action.hoverOpacity)
  },
  [`&.${t.disabled}`]: {
    color: o.palette.text.secondary
  },
  [`&.${t.selected}`]: {
    color: o.palette.primary.contrastText,
    backgroundColor: o.palette.primary.main,
    "&:focus, &:hover": {
      backgroundColor: o.palette.primary.dark
    }
  }
})), k = () => {
}, G = /* @__PURE__ */ n.forwardRef(function(e, c) {
  const {
    autoFocus: a,
    className: l,
    children: d,
    disabled: p,
    onClick: y,
    onKeyDown: v,
    value: s,
    tabIndex: C,
    onFocus: w = k,
    onBlur: B = k
  } = e, P = h(e, V), m = n.useRef(null), g = D(m, c), R = n.useContext($), u = i({}, e, {
    wrapperVariant: R
  }), f = j(u);
  return n.useEffect(() => {
    a && m.current.focus();
  }, [a]), /* @__PURE__ */ b(K, {
    className: Y(f.root, l),
    ownerState: u,
    children: /* @__PURE__ */ b(M, i({
      ref: g,
      disabled: p,
      type: "button",
      tabIndex: p ? -1 : C,
      onClick: (r) => y(r, s),
      onKeyDown: (r) => v(r, s),
      onFocus: (r) => w(r, s),
      onBlur: (r) => B(r, s),
      className: f.yearButton,
      ownerState: u
    }, P, {
      children: d
    }))
  });
});
export {
  G as PickersYear
};
