import { formatDate } from "../utils/formatDate.js";
import { getRelativeDay, getRelativeDayLabel } from "../utils/relativeDay.js";
import React from "react";
import dayjs from "dayjs";
//#region src/components/pisellDateTimeDisplay/components/DateDisplay.tsx
/**
* 日期展示组件
*
* @description
* - 格式化并展示日期
* - 支持 showRelativeDay：今天/昨天/明天时用相对日替换原日期展示，不展示具体日期
* - 支持不同的日期顺序（YMD/MDY/DMY）
* - 支持年月日字段显隐
* - 支持中文单位（年、月、日）
* - 支持英文月份格式（简写/完整/数字）
*
* @example
* <DateDisplay
*   date={dayjs()}
*   format={{ order: 'YMD', showYear: true, showChineseUnit: true }}
*   style={{ fontSize: 18, fontWeight: 400, color: '#666' }}
* />
*/
const DateDisplay = ({ date, format, referenceDate = dayjs(), style, className }) => {
	var _labels$relativeDay;
	const labels = format === null || format === void 0 ? void 0 : format.relativeDayLabels;
	const relativeDay = (format === null || format === void 0 ? void 0 : format.showRelativeDay) ? getRelativeDay(date, referenceDate) : null;
	const 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;
	const 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-datetime-display-date ${className || ""}`.trim(),
		style: inlineStyle
	}, formattedDate);
};
//#endregion
export { DateDisplay as default };
