'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var dateUtil = require('../../utils/dateUtil.cjs');
var RangeContext = require('../../RangeContext.cjs');
var useCellClassName = require('../../hooks/useCellClassName.cjs');
var PanelBody = require('../PanelBody.cjs');
var useMergeProps = require('../../hooks/useMergeProps.cjs');

const MONTH_COL_COUNT = 3;
const MONTH_ROW_COUNT = 4;
function MonthBody(_props) {
  const props = useMergeProps.default(_props);
  const {
    prefixCls,
    locale,
    value,
    viewDate,
    generateConfig,
    monthCellRender
  } = props;
  const {
    rangedValue,
    hoverRangedValue
  } = RangeContext.useInjectRange();
  const cellPrefixCls = `${prefixCls}-cell`;
  const getCellClassName = useCellClassName.default({
    cellPrefixCls,
    value,
    generateConfig,
    rangedValue: rangedValue.value,
    hoverRangedValue: hoverRangedValue.value,
    isSameCell: (current, target) => dateUtil.isSameMonth(generateConfig, current, target),
    isInView: () => true,
    offsetCell: (date, offset) => generateConfig.addMonth(date, offset)
  });
  const monthsLocale = locale.shortMonths || (generateConfig.locale.getShortMonths ? generateConfig.locale.getShortMonths(locale.locale) : []);
  const baseMonth = generateConfig.setMonth(viewDate, 0);
  const getCellNode = monthCellRender ? (date) => monthCellRender({
    current: date,
    locale
  }) : void 0;
  return vue.createVNode(PanelBody.default, {
    ...props,
    "rowNum": MONTH_ROW_COUNT,
    "colNum": MONTH_COL_COUNT,
    "baseDate": baseMonth,
    "getCellNode": getCellNode,
    "getCellText": (date) => locale.monthFormat ? dateUtil.formatValue(date, {
      locale,
      format: locale.monthFormat,
      generateConfig
    }) : monthsLocale[generateConfig.getMonth(date)],
    "getCellClassName": getCellClassName,
    "getCellDate": generateConfig.addMonth,
    "titleCell": (date) => dateUtil.formatValue(date, {
      locale,
      format: "YYYY-MM",
      generateConfig
    })
  }, null);
}
MonthBody.displayName = "MonthBody";
MonthBody.inheritAttrs = false;

exports.MONTH_COL_COUNT = MONTH_COL_COUNT;
exports.default = MonthBody;
//# sourceMappingURL=MonthBody.cjs.map
