'use strict';

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

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

function DateBody(_props) {
  const props = useMergeProps.default(_props);
  const {
    prefixCls,
    generateConfig,
    prefixColumn,
    locale,
    rowCount,
    viewDate,
    value,
    dateRender
  } = props;
  const {
    rangedValue,
    hoverRangedValue
  } = RangeContext.useInjectRange();
  const baseDate = dateUtil.getWeekStartDate(locale.locale, generateConfig, viewDate);
  const cellPrefixCls = `${prefixCls}-cell`;
  const weekFirstDay = generateConfig.locale.getWeekFirstDay(locale.locale);
  const today = generateConfig.getNow();
  const headerCells = [];
  const weekDaysLocale = locale.shortWeekDays || (generateConfig.locale.getShortWeekDays ? generateConfig.locale.getShortWeekDays(locale.locale) : []);
  if (prefixColumn)
    headerCells.push(vue.createVNode("th", {
      "key": "empty",
      "aria-label": "empty cell"
    }, null));
  for (let i = 0; i < dateUtil.WEEK_DAY_COUNT; i += 1)
    headerCells.push(vue.createVNode("th", {
      "key": i
    }, [weekDaysLocale[(i + weekFirstDay) % dateUtil.WEEK_DAY_COUNT]]));
  const getCellClassName = useCellClassName.default({
    cellPrefixCls,
    today,
    value,
    generateConfig,
    rangedValue: prefixColumn ? null : rangedValue.value,
    hoverRangedValue: prefixColumn ? null : hoverRangedValue.value,
    isSameCell: (current, target) => dateUtil.isSameDate(generateConfig, current, target),
    isInView: (date) => dateUtil.isSameMonth(generateConfig, date, viewDate),
    offsetCell: (date, offset) => generateConfig.addDate(date, offset)
  });
  const getCellNode = dateRender ? (date) => dateRender({
    current: date,
    today
  }) : void 0;
  return vue.createVNode(PanelBody.default, {
    ...props,
    "rowNum": rowCount,
    "colNum": dateUtil.WEEK_DAY_COUNT,
    "baseDate": baseDate,
    "getCellNode": getCellNode,
    "getCellText": generateConfig.getDate,
    "getCellClassName": getCellClassName,
    "getCellDate": generateConfig.addDate,
    "titleCell": (date) => dateUtil.formatValue(date, {
      locale,
      format: "YYYY-MM-DD",
      generateConfig
    }),
    "headerCells": headerCells
  }, null);
}
DateBody.displayName = "DateBody";
DateBody.inheritAttrs = false;
DateBody.props = [
  "prefixCls",
  "generateConfig",
  "value?",
  "viewDate",
  "locale",
  "rowCount",
  "onSelect",
  "dateRender?",
  "disabledDate?",
  // Used for week panel
  "prefixColumn?",
  "rowClassName?"
];

exports.default = DateBody;
//# sourceMappingURL=DateBody.cjs.map
