import { useContext } from "react";
import merge_1 from "../../../../../../../../lodash@4.17.21/node_modules/lodash/merge.js";
import { getNow, dayjs } from "../../../_util/dayjs.js";
import cs from "../../../_util/classNames.js";
import { ConfigContext } from "../../../ConfigProvider/index.js";
import Header from "../header.js";
import Body from "../body.js";
import { newArray } from "../../../_util/constant.js";
import PickerContext from "../../context.js";
import { jsxs, jsx } from "../../../../../../../../@emotion_react@11.10.4_3toe27fv7etiytxb5kxc7fxaw4/node_modules/@emotion/react/jsx-runtime/dist/emotion-react-jsx-runtime.browser.esm.js";
var __assign = globalThis && globalThis.__assign || function() {
  __assign = Object.assign || function(t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];
      for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p))
          t[p] = s[p];
    }
    return t;
  };
  return __assign.apply(this, arguments);
};
var __rest = globalThis && globalThis.__rest || function(s, e) {
  var t = {};
  for (var p in s)
    if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
      t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
function YearPicker(props) {
  var pageShowDate = props.pageShowDate, style = props.style, onMouseEnterCell = props.onMouseEnterCell, onMouseLeaveCell = props.onMouseLeaveCell, dateRender = props.dateRender, disabledDate = props.disabledDate, value = props.value, locale = props.locale, isRangePicker = props.isRangePicker, onSelect = props.onSelect, rangeValues = props.rangeValues, onSuperPrev = props.onSuperPrev, onSuperNext = props.onSuperNext, format = props.format, icons = props.icons, originMode = props.originMode, rest = __rest(props, ["pageShowDate", "style", "onMouseEnterCell", "onMouseLeaveCell", "dateRender", "disabledDate", "value", "locale", "isRangePicker", "onSelect", "rangeValues", "onSuperPrev", "onSuperNext", "format", "icons", "originMode"]);
  var _a = useContext(ConfigContext), globalLocale = _a.locale, getPrefixCls = _a.getPrefixCls, rtl = _a.rtl;
  var DATEPICKER_LOCALE = merge_1(globalLocale.DatePicker, locale);
  var CALENDAR_LOCALE = DATEPICKER_LOCALE.Calendar;
  var _b = useContext(PickerContext), utcOffset = _b.utcOffset, timezone = _b.timezone;
  var prefixCls = getPrefixCls("panel-year");
  var classNames = cs(prefixCls);
  var bodyProps = isRangePicker ? {
    rangeValues
  } : {
    value
  };
  var showYear = pageShowDate ? pageShowDate.year() : getNow(utcOffset, timezone).year();
  var startYear = Math.floor(showYear / 10) * 10 - 1;
  var groupRow = newArray(3).map(function(_) {
    return "";
  });
  var rows = newArray(4).map(function(_) {
    return groupRow;
  }).map(function(arr, i) {
    return arr.map(function(_, j) {
      return {
        name: startYear + i * 3 + j,
        time: dayjs("" + (startYear + i * 3 + j), "YYYY").endOf("year"),
        isPrev: i === 0 && j === 0,
        isNext: i === 3 && j === 2
      };
    });
  });
  function renderCalendar() {
    return /* @__PURE__ */ jsx(Body, {
      ...__assign({}, rest, bodyProps, {
        prefixCls: getPrefixCls("picker"),
        rows,
        onSelectDate: onSelect,
        isSameTime: function(current, target) {
          return current.isSame(target, "year");
        },
        onMouseEnterCell,
        onMouseLeaveCell,
        dateRender,
        disabledDate,
        CALENDAR_LOCALE,
        mode: "year",
        originMode,
        format
      })
    });
  }
  var headerOperations = {
    onSuperPrev,
    onSuperNext
  };
  return /* @__PURE__ */ jsxs("div", {
    className: classNames,
    style,
    children: [/* @__PURE__ */ jsx(Header, {
      ...__assign({
        prefixCls: getPrefixCls("picker"),
        icons,
        title: rows[0][1].name + " - " + rows[3][2].name,
        rtl
      }, headerOperations)
    }), renderCalendar()]
  });
}
YearPicker.defaultProps = {
  pickerType: "year"
};
export {
  YearPicker as default
};
//# sourceMappingURL=index.js.map
