import { Context } from "../../info/model.js";
import Info from "./addService/index.js";
import { setOpenNormalServiceHandler } from "./openNormalService.js";
import editService_default from "./editService/index.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 useClearCart from "../../hooks/useClearCart.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 { detailRef, handleEdit, handleAction, dispatchService, showAddTimeModal, editNormalServiceRef } = useInfoHolder(state, dispatch);
	useEffect(() => {
		document.body.id = "body";
	}, []);
	useEffect(() => {
		setOpenNormalServiceHandler((payload) => {
			var _editNormalServiceRef;
			(_editNormalServiceRef = editNormalServiceRef.current) === null || _editNormalServiceRef === void 0 || _editNormalServiceRef.init(payload);
		});
		return () => {
			setOpenNormalServiceHandler(void 0);
		};
	}, [editNormalServiceRef]);
	const clearCart = useClearCart(state, dispatch);
	const { dom } = useQuotation(state, dispatch);
	const renderMemo = useMemo(() => {
		console.log("render info22222");
		return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-service-wrap" }, (state === null || state === void 0 ? void 0 : state.isBookingTicket2) ? null : clearCart, /* @__PURE__ */ React.createElement(Lists, {
			isParallelResource: true,
			onEdit: handleEdit,
			onAction: handleAction,
			onChange: (e, type) => dispatchService(type || "setService", e)
		}), !state.isBookingCreatePage ? /* @__PURE__ */ React.createElement(Info, { 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,
		clearCart,
		state === null || state === void 0 ? void 0 : state.isBookingTicket2
	]);
	return /* @__PURE__ */ React.createElement(React.Fragment, null, renderMemo);
};
var service_default = React.memo(Service);
//#endregion
export { service_default as default };
