const require_runtime = require("../../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_bookingCalendarConstants = require("../const/bookingCalendarConstants.js");
const require_bookingCalendarDateUtils = require("../utils/bookingCalendarDateUtils.js");
const require_BookingCalendarStyle = require("../utils/BookingCalendarStyle.js");
const require_bookingCalendarViewShared = require("../bookingCalendarViewShared.js");
let react = require("react");
react = require_runtime.__toESM(react);
let react_window = require("react-window");
let react_virtualized_auto_sizer = require("react-virtualized-auto-sizer");
react_virtualized_auto_sizer = require_runtime.__toESM(react_virtualized_auto_sizer);
//#region src/components/pisellRecordBoard/shellFrame/Calendar/modal/OverflowListModal.tsx
/**
* 溢出预约列表弹层：`FixedSizeList` 虚拟列表；视口宽高由 `AutoSizer` 跟随 flex 剩余区域，
* 列表可视高度取 `min(内容总高, 可用高度)`，避免条数少时底部大块空白。
*/
function OverflowListModalVirtualList({ items, dateKey, onPickItem, onClose, showStatusUi = true }) {
	const Row = (0, react.useCallback)(({ index, style }) => {
		const extraItem = items[index];
		if (!extraItem) return null;
		const displayTag = showStatusUi ? require_bookingCalendarDateUtils.getDisplayStatusTag(extraItem, dateKey) : null;
		const tagMeta = showStatusUi && displayTag ? require_bookingCalendarViewShared.statusTagMeta(displayTag) : null;
		const rowStateClass = showStatusUi ? require_BookingCalendarStyle.getBookingStateClasses(extraItem, dateKey) : require_BookingCalendarStyle.getGridBookingRowStateClasses(extraItem);
		return /* @__PURE__ */ react.default.createElement("div", { style: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, style), {}, {
			boxSizing: "border-box",
			paddingLeft: 4,
			paddingRight: 4,
			paddingBottom: 8
		}) }, /* @__PURE__ */ react.default.createElement("button", {
			type: "button",
			onClick: () => {
				onClose();
				onPickItem(extraItem);
			},
			className: `flex h-full min-h-0 w-full min-w-0 flex-col justify-center rounded-xl px-4 py-3 text-left text-white ${rowStateClass}`
		}, /* @__PURE__ */ react.default.createElement("div", { className: "min-w-0 break-words font-medium" }, extraItem.name), /* @__PURE__ */ react.default.createElement("div", { className: "mt-1 text-sm opacity-85" }, require_bookingCalendarDateUtils.formatHourLabel(extraItem.startHour), " -", " ", require_bookingCalendarDateUtils.formatHourLabel(extraItem.endHour)), tagMeta && /* @__PURE__ */ react.default.createElement("div", { className: "mt-2 flex justify-end" }, /* @__PURE__ */ react.default.createElement("span", { className: `rounded-lg px-2 py-0.5 text-[10px] font-semibold ${tagMeta.className} backdrop-blur-[2px]` }, tagMeta.label))));
	}, [
		items,
		dateKey,
		onPickItem,
		onClose,
		showStatusUi
	]);
	if (!(items === null || items === void 0 ? void 0 : items.length)) return null;
	return /* @__PURE__ */ react.default.createElement("div", { className: "pisell-scroll-hidden flex h-full min-h-0 w-full min-w-0 flex-1 flex-col touch-pan-y" }, /* @__PURE__ */ react.default.createElement(react_virtualized_auto_sizer.default, null, ({ height, width }) => {
		/**
		* flex + max-h 弹层里 AutoSizer 初测常为 0：用常量回退，避免整段 `return null` 空白。
		* 父级列表区已设 min-height，正常情况会得到真实像素。
		*/
		const effH = height >= 1 ? height : 420;
		const effW = width >= 1 ? width : 320;
		const contentHeight = items.length * require_bookingCalendarConstants.OVERFLOW_MODAL_ROW_H;
		const listHeight = Math.max(1, Math.min(contentHeight, effH));
		return /* @__PURE__ */ react.default.createElement(react_window.FixedSizeList, {
			height: listHeight,
			itemCount: items.length,
			itemSize: require_bookingCalendarConstants.OVERFLOW_MODAL_ROW_H,
			width: effW,
			style: { overflowX: "hidden" }
		}, Row);
	}));
}
//#endregion
exports.OverflowListModalVirtualList = OverflowListModalVirtualList;
