import { Context } from "../../info/model.js";
import addService_default from "./addService/index.js";
import { setOpenNormalServiceHandler } from "./openNormalService.js";
import { useIsActive } from "../../../ticketBooking/context/IsActiveContext.js";
import editService_default from "./editService/index.js";
import usePromotion from "../../hooks/usePromotion.js";
import Lists from "../../info/service/Lists.js";
import addTimeModal_default from "./addTimeModal/index.js";
import useInfoHolder from "../../info/hooks/useInfoHolder.js";
import useQuotation from "../../hooks/useQuotation.js";
import EditNormalService from "./editNormalService/index.js";
import React, { useContext, useEffect, useMemo } from "react";
import "../../info/service/index.less";
//#region src/components/booking/info2/service/index.tsx
const Service = () => {
	const { state, dispatch } = useContext(Context);
	const isActive = useIsActive();
	const { detailRef, handleEdit, handleAction, dispatchService, showAddTimeModal, editNormalServiceRef } = useInfoHolder(state, dispatch);
	useEffect(() => {
		document.body.id = "body";
	}, []);
	useEffect(() => {
		if (isActive && state.isBookingTicket2) setOpenNormalServiceHandler((payload) => {
			var _editNormalServiceRef;
			editNormalServiceRef === null || editNormalServiceRef === void 0 || (_editNormalServiceRef = editNormalServiceRef.current) === null || _editNormalServiceRef === void 0 || _editNormalServiceRef.init(payload);
		});
	}, [isActive]);
	const { dom } = useQuotation(state, dispatch);
	const { run, formatProductList } = usePromotion(state, dispatch, { onGiftSelection: (params) => {
		console.log(params, "params444");
	} });
	useEffect(() => {
		const unsubscribe = run();
		return () => {
			unsubscribe === null || unsubscribe === void 0 || unsubscribe();
		};
	}, [run]);
	const renderMemo = useMemo(() => {
		console.log("render info22222");
		return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-service-wrap" }, /* @__PURE__ */ React.createElement(Lists, {
			isParallelResource: true,
			onEdit: handleEdit,
			onAction: handleAction,
			onChange: (e, type) => dispatchService(type || "setService", e)
		}), !state.isBookingCreatePage ? /* @__PURE__ */ React.createElement(addService_default, { onEdit: handleEdit }) : null), /* @__PURE__ */ React.createElement(editService_default, { ref: detailRef }), showAddTimeModal && /* @__PURE__ */ React.createElement(addTimeModal_default, null), /* @__PURE__ */ React.createElement(EditNormalService, { ref: editNormalServiceRef }), dom);
	}, [dom, showAddTimeModal]);
	return /* @__PURE__ */ React.createElement(React.Fragment, null, renderMemo);
};
var service_default = React.memo(Service);
//#endregion
export { service_default as default };
