const require_runtime = require("../../../../../../_virtual/_rolldown/runtime.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/eventBooking/components/scheduleCalendar/components/ScheduleTimeItem/index.tsx
const ScheduleTimeItem = ({ timeList }) => {
	const [times, setTimes] = (0, react.useState)([]);
	const [isExpand, setIsExpand] = (0, react.useState)(false);
	(0, react.useEffect)(() => {
		if ((timeList === null || timeList === void 0 ? void 0 : timeList.length) > 4) setTimes(timeList === null || timeList === void 0 ? void 0 : timeList.slice(0, 4));
		else setTimes(timeList);
	}, [timeList]);
	const handleExpand = () => {
		const nextExpandStatus = !isExpand;
		if (nextExpandStatus) setTimes(timeList);
		else setTimes(timeList === null || timeList === void 0 ? void 0 : timeList.slice(0, 4));
		setIsExpand(nextExpandStatus);
	};
	return /* @__PURE__ */ react.default.createElement("div", { className: "schedule-time-item" }, /* @__PURE__ */ react.default.createElement("div", { className: "schedule-time-item-content-wrapper" }, (times === null || times === void 0 ? void 0 : times.length) > 0 ? times === null || times === void 0 ? void 0 : times.map((item) => /* @__PURE__ */ react.default.createElement("div", {
		className: (0, _pisell_utils.isMobile)() ? "schedule-time-item-content-mobile" : "schedule-time-item-content",
		key: (item.start_at || "") + (item.end_at || "")
	}, /* @__PURE__ */ react.default.createElement("div", { className: "schedule-time-item-content-time" }, (item === null || item === void 0 ? void 0 : item.start_date) || ""), /* @__PURE__ */ react.default.createElement("div", { className: "schedule-time-item-content-time" }, (0, dayjs.default)((item === null || item === void 0 ? void 0 : item.start_at) || "").format("HH:mm"), " - ", (0, dayjs.default)((item === null || item === void 0 ? void 0 : item.end_at) || "").format("HH:mm")))) : /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellEmpty, null)), (timeList === null || timeList === void 0 ? void 0 : timeList.length) > 4 && /* @__PURE__ */ react.default.createElement("div", {
		className: "schedule-time-item-expand-btn",
		onClick: handleExpand
	}, isExpand ? _pisell_utils.locales.getText("pisell2.event.schedule.item.collapse") : _pisell_utils.locales.getText("pisell2.event.schedule.item.expand"), /* @__PURE__ */ react.default.createElement(_pisell_materials.Iconfont, {
		type: isExpand ? "pisell2-chevron-up-double" : "pisell2-chevron-down-double",
		className: "schedule-time-item-expand-btn-icon"
	})));
};
//#endregion
exports.default = ScheduleTimeItem;
