"use strict";
const React = require("react");
const merge = require("../../../../../../../../lodash@4.17.21/node_modules/lodash/merge.js");
const dayjs = require("../../../_util/dayjs.js");
const classNames = require("../../../_util/classNames.js");
const index = require("../../../ConfigProvider/index.js");
const header = require("../header.js");
const body = require("../body.js");
const index$1 = require("../year/index.js");
const pad = require("../../../_util/pad.js");
const emotionReactJsxRuntime_browser_esm = require("../../../../../../../../@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 QuarterPicker(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, getHeaderOperations = props.getHeaderOperations, setPageShowDate = props.setPageShowDate, icons = props.icons, panelMode = props.panelMode, setPanelMode = props.setPanelMode, rest = __rest(props, ["pageShowDate", "style", "onMouseEnterCell", "onMouseLeaveCell", "dateRender", "disabledDate", "value", "locale", "isRangePicker", "onSelect", "rangeValues", "onSuperPrev", "onSuperNext", "format", "getHeaderOperations", "setPageShowDate", "icons", "panelMode", "setPanelMode"]);
  var _a = React.useContext(index.ConfigContext), globalLocale = _a.locale, getPrefixCls = _a.getPrefixCls, rtl = _a.rtl;
  var DATEPICKER_LOCALE = merge(globalLocale.DatePicker, locale);
  var CALENDAR_LOCALE = DATEPICKER_LOCALE.Calendar;
  var prefixCls = getPrefixCls("panel-quarter");
  var classNames$1 = classNames(prefixCls);
  var bodyProps = isRangePicker ? {
    rangeValues
  } : {
    value
  };
  var showYear = pageShowDate.year();
  var rows = [[1, 2, 3, 4].map(function(q) {
    return {
      name: "Q" + q,
      time: dayjs.dayjs(showYear + "-" + pad.padStart((q - 1) * 3 + 1, 2, "0") + "-01")
    };
  })];
  function renderCalendar() {
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(body, {
      ...__assign({}, rest, bodyProps, {
        prefixCls: getPrefixCls("picker"),
        rows,
        onSelectDate: onSelect,
        isSameTime: function(current, target) {
          return current.isSame(target, "month");
        },
        onMouseEnterCell,
        onMouseLeaveCell,
        dateRender,
        disabledDate,
        CALENDAR_LOCALE,
        mode: "quarter",
        format
      })
    });
  }
  var headerOperations = {
    onSuperPrev,
    onSuperNext
  };
  function onChangePanel(mode) {
    setPanelMode(mode);
  }
  if (panelMode === "year") {
    return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(index$1, {
      ...__assign({}, getHeaderOperations(panelMode), {
        pageShowDate,
        onSelect: function(_, date) {
          setPanelMode("quarter");
          setPageShowDate(date);
        },
        disabledDate,
        originMode: "quarter"
      })
    });
  }
  return /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsxs("div", {
    className: classNames$1,
    style,
    children: [/* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx(header, {
      ...__assign({}, headerOperations, {
        icons,
        prefixCls: getPrefixCls("picker"),
        value: pageShowDate,
        mode: panelMode,
        onChangePanel,
        rtl
      })
    }), /* @__PURE__ */ emotionReactJsxRuntime_browser_esm.jsx("div", {
      className: prefixCls + "-wrapper",
      children: renderCalendar()
    })]
  });
}
QuarterPicker.defaultProps = {
  pickerType: "quarter"
};
module.exports = QuarterPicker;
//# sourceMappingURL=index.js.map
