import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { MONTH_OVERFLOW_POPOVER_ITEM_H } from "../const/bookingCalendarConstants.js";
import { formatHourLabel } from "../utils/bookingCalendarDateUtils.js";
import React, { useCallback } from "react";
import { FixedSizeList } from "react-window";
//#region src/components/pisellRecordBoard/shellFrame/Calendar/modal/OverflowPopover.tsx
/** 月/周格「+N」悬停层内的虚拟列表（overflowPopover） */
function MonthGridOverflowVirtualList({ items, listWidth, onPickItem }) {
	if (!(items === null || items === void 0 ? void 0 : items.length)) return null;
	const listH = Math.min(items.length * MONTH_OVERFLOW_POPOVER_ITEM_H, 280);
	const Row = useCallback(({ index, style }) => {
		const extraItem = items[index];
		if (!extraItem) return null;
		return /* @__PURE__ */ React.createElement("div", { style: _objectSpread2(_objectSpread2({}, style), {}, {
			boxSizing: "border-box",
			paddingLeft: 2,
			paddingRight: 6,
			paddingBottom: 8
		}) }, /* @__PURE__ */ React.createElement("button", {
			type: "button",
			onClick: (e) => {
				e.stopPropagation();
				onPickItem(extraItem);
			},
			className: `flex h-full min-h-0 w-full flex-col justify-center rounded-lg px-3 py-2 text-xs text-left ${extraItem.kind === "block" ? "bg-red-700/70 text-red-100" : "bg-violet-700/90 text-violet-50"}`
		}, /* @__PURE__ */ React.createElement("div", { className: "truncate" }, extraItem.name), /* @__PURE__ */ React.createElement("div", { className: "mt-1 opacity-80" }, formatHourLabel(extraItem.startHour), " -", " ", formatHourLabel(extraItem.endHour))));
	}, [items, onPickItem]);
	return /* @__PURE__ */ React.createElement(FixedSizeList, {
		height: listH,
		itemCount: items.length,
		itemSize: MONTH_OVERFLOW_POPOVER_ITEM_H,
		width: listWidth,
		style: { overflowX: "hidden" }
	}, Row);
}
//#endregion
export { MonthGridOverflowVirtualList };
