import { formatTime } from "../../pisellDateTimeDisplay/utils/formatTime.js";
import { getDatePartDisplay } from "../../pisellDateTimeDisplay/utils/formatDateOrRelative.js";
import React from "react";
import dayjs from "dayjs";
//#region src/components/pisellTimeRangeDisplay/components/TimeRangeBlock.tsx
/**
* 时间区间展示块
* - 同一天：HH:mm-HH:mm
* - 跨天：起止完整日期时间；若某端为相对日（今天/昨天/明天）则只显示「时间 相对日」，不显示星期+日期
*/
const TimeRangeBlock = ({ start, end, isSameDay, timeFormat, dateFormat, weekdayFormat, referenceDate = dayjs(), style, className }) => {
	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
	};
	if (isSameDay) {
		const startStr = formatTime(start, timeFormat);
		const endStr = formatTime(end, timeFormat);
		return /* @__PURE__ */ React.createElement("span", {
			className: `pisell-time-range-display-time ${className || ""}`.trim(),
			style: inlineStyle
		}, /* @__PURE__ */ React.createElement("span", { className: "pisell-time-range-display-time-start" }, startStr), /* @__PURE__ */ React.createElement("span", { className: "pisell-time-range-display-time-end-wrap" }, /* @__PURE__ */ React.createElement("span", {
			className: "pisell-time-range-display-time-sep",
			"aria-hidden": true
		}, " - "), /* @__PURE__ */ React.createElement("span", { className: "pisell-time-range-display-time-end" }, endStr)));
	}
	const dateFormatOverride = {
		order: "DMY",
		shortMonth: true,
		showYear: start.year() !== end.year(),
		showMonth: true,
		showDay: true,
		useCommaBeforeYear: false
	};
	const startTimeStr = formatTime(start, timeFormat);
	const endTimeStr = formatTime(end, timeFormat);
	const startDatePart = getDatePartDisplay({
		date: start,
		dateFormat,
		weekdayFormat,
		referenceDate,
		dateFormatOverride
	});
	const endDatePart = getDatePartDisplay({
		date: end,
		dateFormat,
		weekdayFormat,
		referenceDate,
		dateFormatOverride
	});
	const startPart = `${startTimeStr} ${startDatePart}`;
	const endPart = `${endTimeStr} ${endDatePart}`;
	const timeClass = "pisell-time-range-display-time pisell-time-range-display-time-cross";
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
		key: "time-start",
		className: `${timeClass} ${className || ""}`.trim(),
		style: inlineStyle
	}, startPart), /* @__PURE__ */ React.createElement("span", {
		key: "time-end",
		className: `${timeClass} ${className || ""}`.trim(),
		style: inlineStyle
	}, " - ", endPart));
};
//#endregion
export { TimeRangeBlock as default };
