import React from 'react';
import dayjs from 'dayjs';
import { formatDate, getRelativeDay, getRelativeDayLabel } from "../utils";
/**
 * 日期展示块（复用 PisellDateTimeDisplay 的 formatDate 与相对日逻辑）
 */
export var DateBlock = function DateBlock(_ref) {
  var _labels$relativeDay;
  var date = _ref.date,
    format = _ref.format,
    _ref$referenceDate = _ref.referenceDate,
    referenceDate = _ref$referenceDate === void 0 ? dayjs() : _ref$referenceDate,
    style = _ref.style,
    className = _ref.className;
  var labels = format === null || format === void 0 ? void 0 : format.relativeDayLabels;
  var relativeDay = format !== null && format !== void 0 && format.showRelativeDay ? getRelativeDay(date, referenceDate) : null;
  var formattedDate = relativeDay ? (_labels$relativeDay = labels === null || labels === void 0 ? void 0 : labels[relativeDay]) !== null && _labels$relativeDay !== void 0 ? _labels$relativeDay : getRelativeDayLabel(relativeDay, date.locale()) : formatDate(date, format);
  if (!formattedDate) return null;
  var inlineStyle = {
    fontSize: style === null || style === void 0 ? void 0 : style.fontSize,
    fontWeight: style === null || style === void 0 ? void 0 : style.fontWeight,
    color: style === null || style === void 0 ? void 0 : style.color,
    lineHeight: style === null || style === void 0 ? void 0 : style.lineHeight
  };
  return /*#__PURE__*/React.createElement("span", {
    className: "pisell-time-range-display-date ".concat(className || '').trim(),
    style: inlineStyle
  }, formattedDate);
};
export default DateBlock;