import React__default, { useContext } from "react";
import cs from "../../_util/classNames.js";
import WeekList from "./week-list.js";
import useClassName from "../hooks/useCellClassName.js";
import PickerContext from "../context.js";
import { isDisabledDate } from "../util.js";
import { jsxs, jsx, Fragment } 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);
};
function Body(props) {
  var prefixCls = props.prefixCls, isWeek = props.isWeek, disabledDate = props.disabledDate, onSelectDate = props.onSelectDate, dateRender = props.dateRender, onMouseEnterCell = props.onMouseEnterCell, onMouseLeaveCell = props.onMouseLeaveCell, CALENDAR_LOCALE = props.CALENDAR_LOCALE, rows = props.rows, showWeekList = props.showWeekList, isSameTime = props.isSameTime, format = props.format, mode = props.mode, originMode = props.originMode;
  var _a = useContext(PickerContext), utcOffset = _a.utcOffset, timezone = _a.timezone, weekStart = _a.weekStart;
  var getCellClassName = useClassName(__assign(__assign({}, props), {
    isSameTime
  }));
  function renderRow(row) {
    return row.map(function(col, index) {
      if (col.time) {
        var disabled_1 = isDisabledDate(col.time, disabledDate, mode, originMode);
        var onClickHandler = function() {
          return !disabled_1 && onSelectDate(col.time.format(format), col.time);
        };
        return /* @__PURE__ */ jsx("div", {
          className: getCellClassName(col, disabled_1, utcOffset, timezone),
          onMouseEnter: function() {
            return onMouseEnterCell && onMouseEnterCell(col.time, disabled_1);
          },
          onMouseLeave: function() {
            return onMouseLeaveCell && onMouseLeaveCell(col.time, disabled_1);
          },
          onClick: onClickHandler,
          children: dateRender ? React__default.cloneElement(dateRender(col.time)) : /* @__PURE__ */ jsx("div", {
            className: prefixCls + "-date",
            children: /* @__PURE__ */ jsx("div", {
              className: prefixCls + "-date-value",
              children: col.name
            })
          })
        }, index);
      }
      if ("weekOfYear" in col) {
        return /* @__PURE__ */ jsx("div", {
          className: cs(prefixCls + "-cell", prefixCls + "-cell-week"),
          children: /* @__PURE__ */ jsx("div", {
            className: prefixCls + "-date",
            children: /* @__PURE__ */ jsx("div", {
              className: prefixCls + "-date-value",
              children: col.weekOfYear
            })
          })
        }, index);
      }
    });
  }
  return /* @__PURE__ */ jsxs(Fragment, {
    children: [showWeekList && /* @__PURE__ */ jsx(WeekList, {
      prefixCls,
      weekStart,
      isWeek,
      CALENDAR_LOCALE
    }), /* @__PURE__ */ jsx("div", {
      className: prefixCls + "-body",
      children: rows.map(function(row, index) {
        var _a2;
        return /* @__PURE__ */ jsx("div", {
          className: cs(prefixCls + "-row", (_a2 = {}, _a2[prefixCls + "-row-week"] = isWeek, _a2)),
          children: renderRow(row)
        }, index);
      })
    })]
  });
}
export {
  Body as default
};
//# sourceMappingURL=body.js.map
