import BookingDashboard from "./bookingDashboard/index.js";
import BookingList from "./bookingList/index.js";
import React, { forwardRef, useImperativeHandle, useMemo, useRef } from "react";
import { locales } from "@pisell/utils";
import { Tabs, useToast } from "@pisell/materials";
import { SyncOutlined } from "@ant-design/icons";
import "./index.less";
//#region src/components/ticketBooking/components/bookingDataPanel/index.tsx
const BookingDataPanel = forwardRef((props, ref) => {
	const { currentDate, onBookingClick, bookingId } = props;
	const Toast = useToast();
	const bookingListRef = useRef(null);
	const bookingDashboardRef = useRef(null);
	const bookingTimeStartBetween = useMemo(() => {
		return [`${currentDate} 00:00:00`, `${currentDate} 23:59:59`];
	}, [currentDate]);
	const items = useMemo(() => {
		return [{
			label: locales.getText("pisell2.ticket-booking.dashboard"),
			key: "data-board",
			children: /* @__PURE__ */ React.createElement(BookingDashboard, {
				bookingTimeStartBetween,
				ref: bookingDashboardRef
			})
		}, {
			label: locales.getText("pisell2.ticket-booking.booking-list"),
			key: "booking-list",
			children: /* @__PURE__ */ React.createElement(BookingList, {
				bookingTimeStartBetween,
				onBookingClick,
				bookingId,
				ref: bookingListRef
			})
		}];
	}, [currentDate, bookingId]);
	useImperativeHandle(ref, () => ({ refresh: () => {
		var _bookingListRef$curre, _bookingDashboardRef$;
		(_bookingListRef$curre = bookingListRef.current) === null || _bookingListRef$curre === void 0 || _bookingListRef$curre.refresh();
		(_bookingDashboardRef$ = bookingDashboardRef.current) === null || _bookingDashboardRef$ === void 0 || _bookingDashboardRef$.refresh();
	} }));
	return /* @__PURE__ */ React.createElement("div", { className: "pisell-ticket-booking-data-panel" }, /* @__PURE__ */ React.createElement("div", {
		className: "pisell-ticket-booking-data-panel-mask",
		style: { display: bookingId ? "block" : "none" },
		onClick: () => {
			onBookingClick({});
		}
	}), /* @__PURE__ */ React.createElement(Tabs, {
		type: "line",
		items,
		tabBarExtraContent: /* @__PURE__ */ React.createElement("div", {
			className: "pisell-ticket-booking-data-panel-tab-extra",
			onClick: () => {
				var _bookingListRef$curre2, _bookingDashboardRef$2, _Toast$success;
				(_bookingListRef$curre2 = bookingListRef.current) === null || _bookingListRef$curre2 === void 0 || _bookingListRef$curre2.refresh();
				(_bookingDashboardRef$2 = bookingDashboardRef.current) === null || _bookingDashboardRef$2 === void 0 || _bookingDashboardRef$2.refresh();
				Toast === null || Toast === void 0 || (_Toast$success = Toast.success) === null || _Toast$success === void 0 || _Toast$success.call(Toast, locales.getText("pisell2.ticket-booking.refresh-success"));
			}
		}, /* @__PURE__ */ React.createElement(SyncOutlined, null)),
		tabBarStyle: {
			margin: "0 0 0 16px",
			height: "40px"
		}
	}));
});
//#endregion
export { BookingDataPanel as default };
