import { _objectSpread2 } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import { _asyncToGenerator } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import { updateMainProductSellingPrice } from "../../../info/service/serviceManager/distributeDiscount.js";
import { getErrorList, getIsNoSpecAndPackage } from "../../utilsByBooking.js";
import { formatResources, getDurationProps, getFlexibleOption, getMultiDay, getTimeObj, setDefaultCapacitys } from "../addService/utils.js";
import { getProductAllDiscountList, mergeBundleWithOriginalPrice, mergeBundles, setProductPrice } from "./utils.js";
import { addService, genHolderKey, genServiceKey, getIsShowNumber } from "../../../../ticketBooking/utils/index.js";
import { createBookingItemsByGroup, getGroupTotalPrice } from "../../../info/service2/Group/utils.js";
import { disabledDate, isNormalProductByDurationSchedule } from "../../../info/service2/utils.js";
import { deleteCacheParams, getDays, getIsEject, getProductOriginTotalPrice, getProductTotalPrice, getServiceTimes, isSessionProduct, isWalkIn } from "../../../utils.js";
import { editSessionProduct } from "../../../info/utils.js";
import { Context } from "../../../info/model.js";
import Drawer$2 from "../../../components/drawer/index.js";
import Duration from "../../../materiels/duration/index.js";
import Capacity_default from "./Capacity/index.js";
import Resources_default from "./Resources/index.js";
import Holder from "./Holder/index.js";
import CollapsibleList from "../../../components/collapsibleList/index.js";
import { renderBundles } from "../../../components/collapsibleList/utils.js";
import NoteModal from "../../../../../plus/noteModal/index.js";
import DiscountKeyboard from "../../../../../pro/priceKeyboard/components/discountKeyboard/index.js";
import Demo from "../../../info/service/editService/EditTabs/index.js";
import BookingList from "../../../info/service/editService/BookingList/index.js";
import { getOpenNormalServiceHandler } from "../openNormalService.js";
import { useShopDiscountModule } from "../../../../ticketBooking/hooks/pisellos/useShopDiscountModule.js";
import DiscountChangeModal from "./DiscountChangeModal/index.js";
import dayjs from "dayjs";
import React, { forwardRef, useContext, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
import { Button, Col, DatePicker, Form, Input, InputNumber, Row, message } from "antd";
import { formatAmount, getUniqueId, locales } from "@pisell/utils";
import { ConfigProvider as ConfigProvider$1, Iconfont } from "@pisell/materials";
import { useDebounceFn, useMemoizedFn, useUpdateEffect } from "ahooks";
import Delete_wght300_24px from "@pisell/icon/es/Delete_wght300_24px";
import "./index.less";
//#region src/components/booking/info2/service/editService/index.tsx
let submitLock = false;
const Info = (_, ref) => {
	var _state$service4, _state$bookingConfig2, _state$bookingConfig3, _state$service$cacheI5, _state$service$cacheI7, _state$service6, _window$BaseMaterials, _state$service8, _state$service$cacheI12, _state$bookingConfig5, _state$service$cacheI13, _state$service$cacheI14, _state$service9, _state$service$resour2, _state$service$cacheI16, _state$service$cacheI17, _state$client2;
	const [form] = Form.useForm();
	const useTotal = Form.useWatch("total", form);
	const useResource = Form.useWatch("resource", form);
	const useStartTime = Form.useWatch("start_time", form);
	const useDuration = Form.useWatch("duration", form);
	Form.useWatch("holder", form);
	const useHolderId = Form.useWatch("holder_id", form);
	const useNote = Form.useWatch("note", form);
	const useStartDate = Form.useWatch("start_date", form);
	const useEndDate = Form.useWatch("end_date", form);
	const shopDiscount = useShopDiscountModule();
	const [discountChangeModalOpen, setDiscountChangeModalOpen] = useState(false);
	const { state, dispatch } = useContext(Context);
	const resourcesRef = useRef(null);
	const isChangeTotal = useRef(false);
	const [noteModalOpen, setNoteModalOpen] = useState(false);
	const [open, setOpen] = useState(false);
	const [currentTab, setCurrentTab] = useState("batch_edit");
	const valuesRef = useRef({});
	const noInOriginalDiscountIdsRef = useRef([]);
	/** 标记 handleEdit 是否执行过，用于判断保存时是否需要检查折扣变化 */
	const isEditedRef = useRef(false);
	useEffect(() => {
		window.openBookingEditModal = () => {
			setOpen(true);
		};
		window.closeBookingEditModal = () => {
			setOpen(false);
		};
	}, []);
	const isNormalProduct = useMemo(() => {
		var _state$service, _state$service2, _state$service3;
		if (!(state === null || state === void 0 || (_state$service = state.service) === null || _state$service === void 0 ? void 0 : _state$service.cacheItem)) return true;
		return (state === null || state === void 0 || (_state$service2 = state.service) === null || _state$service2 === void 0 ? void 0 : _state$service2.cacheItem) && isNormalProductByDurationSchedule(state === null || state === void 0 || (_state$service3 = state.service) === null || _state$service3 === void 0 ? void 0 : _state$service3.cacheItem);
	}, [state === null || state === void 0 || (_state$service4 = state.service) === null || _state$service4 === void 0 ? void 0 : _state$service4.cacheItem]);
	const getCurrentCacheItem = useMemoizedFn((_cacheItem) => {
		let values = form.getFieldsValue();
		let _item = _cacheItem || state.service.cacheItem;
		return _objectSpread2(_objectSpread2({}, _item), {}, { _extend: _objectSpread2(_objectSpread2({}, _item === null || _item === void 0 ? void 0 : _item._extend), values) });
	});
	/**
	* @title: 当前的资源
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 14:06
	*/
	const currentResource = useMemo(() => {
		return null;
	}, []);
	/**
	* @title: 持续时长组件的props
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-02-23 09:59
	*/
	const durationProps = useMemo(() => {
		var _state$bookingConfig;
		return getDurationProps({
			cacheItem: getCurrentCacheItem(),
			useStartTime,
			slice: (_state$bookingConfig = state.bookingConfig) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.config) === null || _state$bookingConfig === void 0 || (_state$bookingConfig = _state$bookingConfig.basic) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.service_time
		});
	}, [
		state.service.cacheItem,
		useStartTime,
		useResource,
		(_state$bookingConfig2 = state.bookingConfig) === null || _state$bookingConfig2 === void 0 || (_state$bookingConfig2 = _state$bookingConfig2.config) === null || _state$bookingConfig2 === void 0 || (_state$bookingConfig2 = _state$bookingConfig2.basic) === null || _state$bookingConfig2 === void 0 ? void 0 : _state$bookingConfig2.service_time
	]);
	/**
	* @title: 灵活时长选项
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-02-23 10:10
	*/
	const flexibleOption = useMemo(() => {
		return getFlexibleOption({ durationProps });
	}, [durationProps, locales.locale]);
	/**
	* @title: 时间切片
	* @description:
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 13:37
	*/
	const timeObj = useMemo(() => {
		return getTimeObj({
			cacheItem: getCurrentCacheItem(),
			durationProps,
			useStartTime,
			currentResource,
			state,
			useDuration
		});
	}, [
		durationProps,
		useStartTime,
		currentResource,
		(_state$bookingConfig3 = state.bookingConfig) === null || _state$bookingConfig3 === void 0 || (_state$bookingConfig3 = _state$bookingConfig3.config) === null || _state$bookingConfig3 === void 0 || (_state$bookingConfig3 = _state$bookingConfig3.basic) === null || _state$bookingConfig3 === void 0 ? void 0 : _state$bookingConfig3.service_time,
		useDuration
	]);
	useEffect(() => {
		console.log("执行次数:于灵活时长的结束时间随");
		try {
			if (useDuration.indexOf("flexible_") == 0) {
				if (flexibleOption) form.setFieldsValue({ duration: flexibleOption.value });
			}
		} catch (err) {}
	}, [useDuration, flexibleOption]);
	/**
	* @title: 删除服务商品
	* @description:
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 13:59
	*/
	const handleDeleteProduct = useMemoizedFn(() => {
		var _state$service$cacheI, _window$closeBookingE, _window;
		if (state.channelDisabledEdit) return;
		let _list = [...state.service.value];
		let _id = (_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI._id;
		_list = _list.filter((d) => d._id !== _id);
		(_window$closeBookingE = (_window = window).closeBookingEditModal) === null || _window$closeBookingE === void 0 || _window$closeBookingE.call(_window);
		dispatch({
			type: "setService",
			payload: {
				editModal: false,
				value: _list,
				edit: true,
				cacheItem: null
			}
		});
	});
	/**
	* @title: 计算折扣
	* @description: 仅是文案展示
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 14:03
	*/
	const getDiscount = () => {
		var _state$service$cacheI2;
		let oPrice = Number(((_state$service$cacheI2 = state.service.cacheItem) === null || _state$service$cacheI2 === void 0 ? void 0 : _state$service$cacheI2._extend.origin_total) || 0);
		let cPrice = Number(useTotal || 0);
		let discount = "";
		if (cPrice === oPrice) discount = locales.getText("pisell2.text.status.no-discount");
		else {
			discount = `${locales.getText("pisell2.text.status.manual")} `;
			if (cPrice < oPrice) discount += formatAmount(cPrice - oPrice, 2, state.amountSymbol) + "";
			else discount += "+" + formatAmount(cPrice - oPrice, 2, state.amountSymbol);
		}
		form.setFieldsValue({ discount });
	};
	const onFinishBefore = (values) => {
		if (!isEditedRef.current) {
			onFinish(values);
			return;
		}
		valuesRef.current = values;
		const originalDiscountList = shopDiscount.getDiscountList();
		const productAllDiscountList = getProductAllDiscountList(state.service.cacheItem);
		const noInOriginalDiscountList = productAllDiscountList.filter((item) => {
			return !originalDiscountList.some((d) => {
				var _item$discount;
				return !d.isEditMode && d.id === (item === null || item === void 0 || (_item$discount = item.discount) === null || _item$discount === void 0 ? void 0 : _item$discount.resource_id);
			});
		});
		if (noInOriginalDiscountList.length > 0) {
			noInOriginalDiscountIdsRef.current = noInOriginalDiscountList.map((item) => {
				var _item$discount2;
				return item === null || item === void 0 || (_item$discount2 = item.discount) === null || _item$discount2 === void 0 ? void 0 : _item$discount2.resource_id;
			});
			setDiscountChangeModalOpen(true);
		} else {
			let cacheItem = _objectSpread2({}, state.service.cacheItem);
			cacheItem = deleteDiscountList(cacheItem);
			onFinish(values, cacheItem);
			if (!!(productAllDiscountList === null || productAllDiscountList === void 0 ? void 0 : productAllDiscountList.length)) message.success(locales.getText("pisell2.text.edit-service-success"));
		}
	};
	/**
	* @title: 提交,
	* @description:
	* @param {any} values
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 14:04
	*/
	const onFinish = (values, cacheItem) => {
		var _resourcesRef$current, _item$_extend, _item$_extend2, _item$_extend3, _item$_extend4, _item$_extend5, _item$_extend6, _state$service$cacheI3, _window$closeBookingE2, _window2;
		let isSuccess = (_resourcesRef$current = resourcesRef.current) === null || _resourcesRef$current === void 0 ? void 0 : _resourcesRef$current.check();
		if (isShowTimeAndResource && !isSuccess) return;
		if (submitLock) return;
		submitLock = true;
		setTimeout(() => {
			submitLock = false;
		}, 1500);
		let _list = [...state.service.value];
		let _item = _objectSpread2(_objectSpread2({}, cacheItem !== null && cacheItem !== void 0 ? cacheItem : state.service.cacheItem), {}, { autoClose: false });
		let _extend = _objectSpread2(_objectSpread2({}, _item._extend), {}, { other: _objectSpread2(_objectSpread2({}, ((_item$_extend = _item._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.other) || {}), {}, { quantity: values.quantity }) }, values);
		if (isEditGroup) {
			_extend.quantity = 1;
			_extend.startDate = _extend === null || _extend === void 0 ? void 0 : _extend.start_date;
			_extend.endDate = _extend === null || _extend === void 0 ? void 0 : _extend.end_date;
		} else {
			const { startDate, endDate } = getServiceTimes({ _extend });
			_extend.startDate = startDate;
			_extend.endDate = endDate;
		}
		if (isChangeTotal.current) updateMainProductSellingPrice(_extend);
		if (_extend.bundle_edit !== void 0 || (cacheItem === null || cacheItem === void 0 ? void 0 : cacheItem.edit)) _extend.bundle_edit = 1;
		_item._extend = _extend;
		_item._time = (/* @__PURE__ */ new Date()).getTime();
		_item._serviceKey = genServiceKey(_item);
		_item._holderKey = genHolderKey(_item);
		if (((_item$_extend2 = _item._extend) === null || _item$_extend2 === void 0 || (_item$_extend2 = _item$_extend2.holder_id) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.length) > 1 || ((_item$_extend3 = _item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.quantity) > 1 && ((_item$_extend4 = _item._extend) === null || _item$_extend4 === void 0 || (_item$_extend4 = _item$_extend4.holder_id) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.length) >= 1) {
			let holder_ids = _item._extend.holder_id;
			_item._extend.holder_id = holder_ids[0];
			holder_ids = holder_ids.slice(1);
			_item._holderKey = genHolderKey(_item);
			holder_ids.forEach((holder_id) => {
				const newItem = _objectSpread2(_objectSpread2({}, _item), {}, {
					_id: getUniqueId(),
					_extend: _objectSpread2(_objectSpread2({}, _item._extend), {}, {
						holder_id: [holder_id],
						quantity: 1
					})
				});
				newItem._holderKey = genHolderKey(newItem);
				_list.unshift(newItem);
				_item._extend.quantity -= 1;
			});
			if (_item._extend.quantity > 1) {
				const newItem = _objectSpread2(_objectSpread2({}, _item), {}, {
					_id: getUniqueId(),
					_extend: _objectSpread2(_objectSpread2({}, _item._extend), {}, {
						holder_id: void 0,
						quantity: _item._extend.quantity - 1
					})
				});
				newItem._holderKey = genHolderKey(newItem);
				_list.unshift(newItem);
				_item._extend.quantity = 1;
			}
		}
		let _id = _item === null || _item === void 0 ? void 0 : _item._id;
		let groupId = _item === null || _item === void 0 || (_item$_extend5 = _item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.groupId;
		const origin_total = (_item$_extend6 = _item._extend) === null || _item$_extend6 === void 0 || (_item$_extend6 = _item$_extend6.items) === null || _item$_extend6 === void 0 || (_item$_extend6 = _item$_extend6[0]) === null || _item$_extend6 === void 0 || (_item$_extend6 = _item$_extend6._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.origin_total;
		if (groupId) {
			if (isChangeTotal.current) _item = deleteDiscountList(_item);
			_list = _list.filter((d) => {
				var _d$_extend;
				return ((_d$_extend = d._extend) === null || _d$_extend === void 0 ? void 0 : _d$_extend.groupId) !== groupId;
			});
			_list = _list.concat(createBookingItemsByGroup(_item, true));
		} else {
			var _item$_extend7;
			_item = setProductPrice(_item, {
				newTotal: values.total,
				origin_total: origin_total !== null && origin_total !== void 0 ? origin_total : (_item$_extend7 = _item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.origin_total
			});
			if (!_list.some((d) => d._id === _id)) _list = addService(_list, _item, state).list;
			else {
				if (isChangeTotal.current) _item = deleteDiscountList(_item);
				_list = _list.map((d) => d._id === _id ? _objectSpread2(_objectSpread2({}, _item), {}, { new: 0 }) : d);
			}
		}
		deleteCacheParams();
		console.log("_onFinish", _list);
		form.resetFields();
		if (!!((_state$service$cacheI3 = state.service.cacheItem) === null || _state$service$cacheI3 === void 0 ? void 0 : _state$service$cacheI3.new)) window.dispatchEvent(new CustomEvent("onAddNewService", { detail: { cacheItem: _objectSpread2({}, state.service.cacheItem) } }));
		(_window$closeBookingE2 = (_window2 = window).closeBookingEditModal) === null || _window$closeBookingE2 === void 0 || _window$closeBookingE2.call(_window2);
		_list.sort((a, b) => {
			var _a$_extend, _b$_extend;
			const aHasHolderId = ((_a$_extend = a._extend) === null || _a$_extend === void 0 ? void 0 : _a$_extend.holder_id) && (Array.isArray(a._extend.holder_id) ? a._extend.holder_id.length > 0 : true);
			const bHasHolderId = ((_b$_extend = b._extend) === null || _b$_extend === void 0 ? void 0 : _b$_extend.holder_id) && (Array.isArray(b._extend.holder_id) ? b._extend.holder_id.length > 0 : true);
			if (!aHasHolderId && bHasHolderId) return -1;
			if (aHasHolderId && !bHasHolderId) return 1;
			return 0;
		});
		dispatch({
			type: "setService",
			payload: {
				editModal: false,
				addModal: false,
				value: _list,
				edit: true,
				cacheItem: null,
				changeService: false
			}
		});
	};
	const { run: setEditDataRun } = useDebounceFn((...params) => {
		setEditData(...params);
	}, {
		wait: 50,
		leading: true,
		trailing: false
	});
	const setEditData = useMemoizedFn((_cacheItem, open, openProductDetail) => {
		console.timeEnd("handleChange");
		console.log("setEditDatasetEditData", _cacheItem, open);
		setCurrentTab("batch_edit");
		isChangeTotal.current = false;
		isEditedRef.current = false;
		let values = (_cacheItem || state.service.cacheItem)._extend;
		const startTime = performance.now();
		console.log(startTime, "startTime");
		form.resetFields();
		form.setFieldsValue({
			capacity: values.capacity,
			discount_reason: values.discount_reason,
			duration: values.duration,
			endDate: values.endDate,
			end_date: values.end_date,
			origin_total: values.origin_total,
			price: values.price,
			product_name: values.product_name,
			quantity: values.quantity,
			resource: values.resource,
			startDate: values.startDate,
			start_time: values.start_time,
			start_date: values.start_date,
			total: values.total,
			holder_id: values.holder_id,
			note: values.note
		});
		const endTime = performance.now();
		console.log(endTime - window.pp1, "打开商品5");
		console.log("执行时间", endTime - startTime, values);
		setTimeout(() => {}, 20);
		if (openProductDetail) setTimeout(() => {
			handleEdit({});
		}, 100);
	});
	/**
	* @title: 是否显示折扣原因
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 14:06
	*/
	const isReason = useMemo(() => {
		var _state$service$cacheI4;
		let oPrice = Number(((_state$service$cacheI4 = state.service.cacheItem) === null || _state$service$cacheI4 === void 0 ? void 0 : _state$service$cacheI4._extend.origin_total) || 0);
		return Number(useTotal || 0) !== oPrice;
	}, [useTotal, (_state$service$cacheI5 = state.service.cacheItem) === null || _state$service$cacheI5 === void 0 || (_state$service$cacheI5 = _state$service$cacheI5._extend) === null || _state$service$cacheI5 === void 0 ? void 0 : _state$service$cacheI5.origin_total]);
	const getResources = () => {
		var _state$service$cacheI6;
		let res = formatResources({
			cacheItem: getCurrentCacheItem(),
			resourcesOrigin: (_state$service$cacheI6 = state.service.cacheItem) === null || _state$service$cacheI6 === void 0 || (_state$service$cacheI6 = _state$service$cacheI6._data) === null || _state$service$cacheI6 === void 0 ? void 0 : _state$service$cacheI6.resourcesOrigin
		});
		dispatch({
			type: "setService",
			payload: { cacheItem: _objectSpread2(_objectSpread2({}, state.service.cacheItem), {}, { _data: _objectSpread2(_objectSpread2({}, state.service.cacheItem._data), {}, {
				resources: res.list,
				resourceMaps: res.maps
			}) }) }
		});
		updateResourceErrors(res.maps);
	};
	const updateResourceErrors = (resourceMaps) => {
		let { resource } = form.getFieldsValue();
		if (resource) {
			let _resource = _objectSpread2({}, resource);
			for (let form_id in _resource) _resource[form_id] = _resource[form_id].map((d) => {
				var _resourceMaps$form_id;
				return _objectSpread2(_objectSpread2({}, d), {}, { errors: getErrorList(resourceMaps === null || resourceMaps === void 0 || (_resourceMaps$form_id = resourceMaps[form_id]) === null || _resourceMaps$form_id === void 0 || (_resourceMaps$form_id = _resourceMaps$form_id.renderListMaps) === null || _resourceMaps$form_id === void 0 ? void 0 : _resourceMaps$form_id[d === null || d === void 0 ? void 0 : d.relation_id], getCurrentCacheItem()) });
			});
			form.setFieldsValue({ resource: _resource });
			return _resource;
		}
	};
	/**
	* @title: 开始时间 和 服务时间 发生变化时,重新计算资源
	* @description:
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 14:07
	*/
	useUpdateEffect(() => {
		if (!state.service.cacheItem) return;
		if (useStartTime && useDuration && state.renderType !== "eventBooking") getResources();
	}, [
		useStartTime,
		useDuration,
		state.renderType,
		state.service.resourcesOrigin
	]);
	useEffect(() => {
		if (state.isBookingCreatePage && state.service.editModal) setEditDataRun(null);
	}, [state.service.editModal, state.isBookingCreatePage]);
	/**
	* @title: 价格发生变化,重新计算折扣
	* @description:
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-01-09 14:08
	*/
	useEffect(() => {
		getDiscount();
	}, [useTotal, (_state$service$cacheI7 = state.service.cacheItem) === null || _state$service$cacheI7 === void 0 || (_state$service$cacheI7 = _state$service$cacheI7._extend) === null || _state$service$cacheI7 === void 0 ? void 0 : _state$service$cacheI7.origin_total]);
	const bundles = useMemo(() => {
		var _state$service5;
		return ((_state$service5 = state.service) === null || _state$service5 === void 0 || (_state$service5 = _state$service5.cacheItem) === null || _state$service5 === void 0 || (_state$service5 = _state$service5._extend) === null || _state$service5 === void 0 || (_state$service5 = _state$service5.other) === null || _state$service5 === void 0 ? void 0 : _state$service5.bundle) || [];
	}, [(_state$service6 = state.service) === null || _state$service6 === void 0 || (_state$service6 = _state$service6.cacheItem) === null || _state$service6 === void 0 || (_state$service6 = _state$service6._extend) === null || _state$service6 === void 0 || (_state$service6 = _state$service6.other) === null || _state$service6 === void 0 ? void 0 : _state$service6.bundle]);
	/**
	* @title: 编辑商品
	* @description:
	* @param {any} e
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-08-28 17:08
	*/
	const handleEdit = useMemoizedFn((e) => {
		const item = state.service.cacheItem;
		let values = form.getFieldsValue();
		const isSession = isSessionProduct(item);
		getIsEject(item, "detail");
		const sessionValue = {};
		if (isSession) {
			var _item$_extend8, _item$_extend9, _item$_extend10;
			sessionValue.startEndTime = {
				startDate: item === null || item === void 0 || (_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.start_date,
				endDate: item === null || item === void 0 || (_item$_extend9 = item._extend) === null || _item$_extend9 === void 0 ? void 0 : _item$_extend9.end_date,
				duration: item === null || item === void 0 || (_item$_extend10 = item._extend) === null || _item$_extend10 === void 0 ? void 0 : _item$_extend10.duration
			};
		}
		const callback = (e, extension_type, detail) => {
			var _detail$_extend, _cacheItem$metadata, _cacheItem$_extend, _cacheItem$_extend2;
			isEditedRef.current = true;
			const _detail = detail || item;
			let other = JSON.parse(JSON.stringify(e));
			if (item.discount_amount) {
				var _item$_extend11;
				other = mergeBundleWithOriginalPrice(other, ((_item$_extend11 = item._extend) === null || _item$_extend11 === void 0 ? void 0 : _item$_extend11.other) || {});
			}
			other.session = e.session;
			let cacheItem = _objectSpread2(_objectSpread2(_objectSpread2({}, item), _detail), {}, {
				product_id: item.id,
				_id: item === null || item === void 0 ? void 0 : item._id,
				_key: e.key,
				_extend: _objectSpread2(_objectSpread2(_objectSpread2({}, item._extend), values), {}, {
					quantity: (e === null || e === void 0 ? void 0 : e.quantity) || (values === null || values === void 0 ? void 0 : values.quantity) || 1,
					other,
					priceOverride: (_detail$_extend = _detail._extend) === null || _detail$_extend === void 0 ? void 0 : _detail$_extend.priceOverride
				}),
				new: 0
			});
			if (cacheItem.discount_amount && (cacheItem === null || cacheItem === void 0 || (_cacheItem$metadata = cacheItem.metadata) === null || _cacheItem$metadata === void 0 ? void 0 : _cacheItem$metadata.main_product_selling_price)) {
				var _cacheItem$metadata2;
				cacheItem._extend.price = cacheItem === null || cacheItem === void 0 || (_cacheItem$metadata2 = cacheItem.metadata) === null || _cacheItem$metadata2 === void 0 ? void 0 : _cacheItem$metadata2.main_product_selling_price;
			}
			let _total = getProductTotalPrice(cacheItem);
			cacheItem._extend.total = _total;
			try {
				cacheItem._extend.capacity = setDefaultCapacitys({
					capacitys: cacheItem._data.capacitys,
					cacheItem
				});
			} catch (err) {}
			const sessionDetail = editSessionProduct(cacheItem, e.session);
			if (sessionDetail) setTimeout(() => {
				form.setFieldsValue({
					start_time: sessionDetail.start_time,
					duration: sessionDetail.duration
				});
			}, 200);
			let origin_total = _total;
			if (item.discount_amount) origin_total = getProductOriginTotalPrice(cacheItem);
			cacheItem._extend.origin_total = origin_total;
			(((_cacheItem$_extend = cacheItem._extend) === null || _cacheItem$_extend === void 0 ? void 0 : _cacheItem$_extend.items) || []).forEach((item) => item._extend.origin_total = origin_total);
			dispatch({
				type: "setService",
				payload: { cacheItem }
			});
			form.setFieldsValue({
				total: _total,
				capacity: (_cacheItem$_extend2 = cacheItem._extend) === null || _cacheItem$_extend2 === void 0 ? void 0 : _cacheItem$_extend2.capacity,
				quantity: (e === null || e === void 0 ? void 0 : e.quantity) || (values === null || values === void 0 ? void 0 : values.quantity) || 1
			});
		};
		if (isNormalProductByDurationSchedule(item)) {
			const openNormalService = getOpenNormalServiceHandler();
			if (openNormalService) openNormalService({
				mode: "edit",
				cacheItem: item,
				callback
			});
		} else {
			var _state$client;
			state.action({
				type: "pisell1.handleOpenProductModal",
				data: {
					id: item.id,
					date: state.date.value.format("YYYY-MM-DD"),
					showConfig: {
						option: true,
						session: isSession,
						variant: true,
						package: true,
						number: getIsShowNumber(item, state)
					},
					isOS: isSession,
					customer_id: (_state$client = state.client) === null || _state$client === void 0 || (_state$client = _state$client.value) === null || _state$client === void 0 ? void 0 : _state$client.id,
					value: _objectSpread2(_objectSpread2(_objectSpread2({}, item._extend.other), {}, { bundle: mergeBundles(item._extend.other) }, sessionValue), {}, { quantity: values.quantity || item._extend.quantity })
				},
				callback
			});
		}
	});
	/**
	* @title: 更换商品
	* @description:
	* @param {any} e
	* @return {*}
	* @Author: zhiwei.Wang
	* @Date: 2024-08-28 17:10
	*/
	const handleChange = useMemoizedFn((e) => {
		var _window$closeBookingE3, _window3;
		if (state.channelDisabledEdit) return;
		form.resetFields();
		(_window$closeBookingE3 = (_window3 = window).closeBookingEditModal) === null || _window$closeBookingE3 === void 0 || _window$closeBookingE3.call(_window3);
		dispatch({
			type: "setService",
			payload: {
				addModal: true,
				editModal: false
			}
		});
	});
	useImperativeHandle(ref, () => {
		return { init: setEditDataRun };
	});
	const handleTotalChange = (number) => {
		isChangeTotal.current = true;
	};
	const isShowTimeAndResource = useMemo(() => {
		if (state.renderType !== "eventBooking" && !isNormalProduct) return true;
		return false;
	}, [state.renderType, isNormalProduct]);
	const SelectTime = (_window$BaseMaterials = window.BaseMaterials) === null || _window$BaseMaterials === void 0 ? void 0 : _window$BaseMaterials.SelectTime;
	const isNoSpecAndPackage = getIsNoSpecAndPackage(state.service.cacheItem);
	const items = useMemo(() => {
		var _getCurrentCacheItem;
		return ((_getCurrentCacheItem = getCurrentCacheItem()) === null || _getCurrentCacheItem === void 0 || (_getCurrentCacheItem = _getCurrentCacheItem._extend) === null || _getCurrentCacheItem === void 0 ? void 0 : _getCurrentCacheItem.items) || [];
	}, [
		getCurrentCacheItem(),
		state.service.cacheItem,
		currentResource,
		useTotal
	]);
	const isEditGroup = useMemo(() => {
		return items.length;
	}, [items]);
	const productName = useMemo(() => {
		var _state$service7;
		return /* @__PURE__ */ React.createElement(Col, { span: 24 }, /* @__PURE__ */ React.createElement(Form.Item, { name: "product_name" }, /* @__PURE__ */ React.createElement("div", { className: "current-service-info" }, /* @__PURE__ */ React.createElement("div", { className: "current-service-info-name-wrap" }, /* @__PURE__ */ React.createElement("div", { className: "current-service-info-name" }, ((_state$service7 = state.service) === null || _state$service7 === void 0 || (_state$service7 = _state$service7.cacheItem) === null || _state$service7 === void 0 || (_state$service7 = _state$service7._extend) === null || _state$service7 === void 0 ? void 0 : _state$service7.product_name) || "-"), /* @__PURE__ */ React.createElement(Button, { onClick: handleEdit }, locales.getText("pisell2.text.edit")), !state.isBookingCreatePage && /* @__PURE__ */ React.createElement(Button, { onClick: handleChange }, locales.getText("pisell2.text.change"))), /* @__PURE__ */ React.createElement(CollapsibleList, {
			style: { marginTop: bundles.length ? "8px" : 0 },
			list: bundles,
			renderItem: (item) => renderBundles(item, state.amountSymbol)
		}))));
	}, [
		(_state$service8 = state.service) === null || _state$service8 === void 0 || (_state$service8 = _state$service8.cacheItem) === null || _state$service8 === void 0 || (_state$service8 = _state$service8._extend) === null || _state$service8 === void 0 ? void 0 : _state$service8.product_name,
		bundles,
		state.amountSymbol,
		state.isBookingCreatePage
	]);
	const price = useMemo(() => {
		var _state$service$cacheI8, _state$service$cacheI9, _state$service$cacheI10, _state$service$cacheI11;
		return /* @__PURE__ */ React.createElement(Col, { span: 24 }, /* @__PURE__ */ React.createElement(Form.Item, {
			label: locales.getText("pisell2.text.price"),
			name: "total",
			rules: [{ required: true }],
			extra: useTotal !== ((_state$service$cacheI8 = state.service.cacheItem) === null || _state$service$cacheI8 === void 0 || (_state$service$cacheI8 = _state$service$cacheI8._extend) === null || _state$service$cacheI8 === void 0 ? void 0 : _state$service$cacheI8.origin_total) && locales.getText("page.booking.text.price-extra")(formatAmount((_state$service$cacheI9 = state.service.cacheItem) === null || _state$service$cacheI9 === void 0 || (_state$service$cacheI9 = _state$service$cacheI9._extend) === null || _state$service$cacheI9 === void 0 ? void 0 : _state$service$cacheI9.origin_total, 2, state.amountSymbol), formatAmount(useTotal, 2, state.amountSymbol))
		}, /* @__PURE__ */ React.createElement(DiscountKeyboard.InputNumber, {
			style: { width: "100%" },
			min: 0,
			precision: 2,
			prefix: state.amountSymbol,
			onChange: handleTotalChange,
			disabled: state.channelDisabledEdit,
			originalValue: ((_state$service$cacheI10 = state.service.cacheItem) === null || _state$service$cacheI10 === void 0 || (_state$service$cacheI10 = _state$service$cacheI10._extend) === null || _state$service$cacheI10 === void 0 ? void 0 : _state$service$cacheI10.origin_total) || 0,
			placeholder: ((_state$service$cacheI11 = state.service.cacheItem) === null || _state$service$cacheI11 === void 0 || (_state$service$cacheI11 = _state$service$cacheI11._extend) === null || _state$service$cacheI11 === void 0 ? void 0 : _state$service$cacheI11.origin_total) || "0",
			size: "large",
			keyboardProps: {
				containerProps: { renderType: "modal" },
				selectType: "dark"
			}
		})));
	}, [
		useTotal,
		(_state$service$cacheI12 = state.service.cacheItem) === null || _state$service$cacheI12 === void 0 || (_state$service$cacheI12 = _state$service$cacheI12._extend) === null || _state$service$cacheI12 === void 0 ? void 0 : _state$service$cacheI12.origin_total,
		state.amountSymbol,
		state.channelDisabledEdit
	]);
	const reason = useMemo(() => {
		return isReason ? /* @__PURE__ */ React.createElement(Col, { span: 24 }, /* @__PURE__ */ React.createElement(Form.Item, {
			label: locales.getText("pisell2.text.discount-reason"),
			name: "discount_reason"
		}, /* @__PURE__ */ React.createElement(Input.TextArea, { size: "large" }))) : null;
	}, [isReason]);
	const DateCom = (position) => {
		return /* @__PURE__ */ React.createElement(DatePicker, {
			className: "pisell-lowcode__booking-service-select-date",
			disabledDate: (current) => disabledDate(current, position, state.date.value),
			size: "large",
			style: { width: "100%" },
			format: state.locale === "en" ? "DD/MM/YYYY" : "YYYY-MM-DD"
		});
	};
	const startTime = useMemo(() => {
		var _state$bookingConfig4;
		return /* @__PURE__ */ React.createElement(Col, { span: 12 }, /* @__PURE__ */ React.createElement(Form.Item, {
			label: locales.getText(isEditGroup ? "pisell2.text.start_date" : "pisell2.text.start_time"),
			name: isEditGroup ? "start_date" : "start_time",
			rules: [{ required: true }]
		}, isEditGroup ? DateCom("start") : SelectTime ? /* @__PURE__ */ React.createElement(SelectTime, {
			slice: (_state$bookingConfig4 = state.bookingConfig) === null || _state$bookingConfig4 === void 0 || (_state$bookingConfig4 = _state$bookingConfig4.config) === null || _state$bookingConfig4 === void 0 || (_state$bookingConfig4 = _state$bookingConfig4.basic) === null || _state$bookingConfig4 === void 0 || (_state$bookingConfig4 = _state$bookingConfig4.service_time) === null || _state$bookingConfig4 === void 0 ? void 0 : _state$bookingConfig4.value,
			timePickerProps: { style: { width: "100%" } },
			timeProps: { style: { zoom: .8 } }
		}) : null));
	}, [
		SelectTime,
		(_state$bookingConfig5 = state.bookingConfig) === null || _state$bookingConfig5 === void 0 || (_state$bookingConfig5 = _state$bookingConfig5.config) === null || _state$bookingConfig5 === void 0 || (_state$bookingConfig5 = _state$bookingConfig5.basic) === null || _state$bookingConfig5 === void 0 || (_state$bookingConfig5 = _state$bookingConfig5.service_time) === null || _state$bookingConfig5 === void 0 ? void 0 : _state$bookingConfig5.value,
		isEditGroup
	]);
	const endTime = useMemo(() => {
		if (!isEditGroup) return null;
		return /* @__PURE__ */ React.createElement(Col, { span: 12 }, /* @__PURE__ */ React.createElement(Form.Item, {
			label: locales.getText("pisell2.text.end_date"),
			name: "end_date"
		}, DateCom("end")));
	}, [isEditGroup]);
	const duration = useMemo(() => {
		console.log("render form duration");
		return /* @__PURE__ */ React.createElement(Col, { span: isEditGroup ? 24 : 12 }, /* @__PURE__ */ React.createElement(Form.Item, {
			label: locales.getText("pisell2.text.duration"),
			name: "duration",
			rules: [{ required: true }]
		}, /* @__PURE__ */ React.createElement(Duration, _objectSpread2(_objectSpread2({}, durationProps), {}, { timeObj }))));
	}, [
		durationProps,
		timeObj,
		isEditGroup
	]);
	const resource = useMemo(() => {
		console.log("render form resource");
		return /* @__PURE__ */ React.createElement(Form.Item, {
			noStyle: true,
			name: "resource"
		}, /* @__PURE__ */ React.createElement(Resources_default, {
			ref: resourcesRef,
			state,
			cacheItem: state.service.cacheItem,
			getCurrentCacheItem
		}));
	}, [
		state.renderType,
		(_state$service$cacheI13 = state.service.cacheItem) === null || _state$service$cacheI13 === void 0 || (_state$service$cacheI13 = _state$service$cacheI13._data) === null || _state$service$cacheI13 === void 0 ? void 0 : _state$service$cacheI13.resources,
		(_state$service$cacheI14 = state.service.cacheItem) === null || _state$service$cacheI14 === void 0 || (_state$service$cacheI14 = _state$service$cacheI14._data) === null || _state$service$cacheI14 === void 0 ? void 0 : _state$service$cacheI14.resourceMaps
	]);
	const holder = useMemo(() => {
		var _state$bookingConfig6, _state$service$cacheI15, _state$bookingConfig7;
		const showExtra = (state === null || state === void 0 || (_state$bookingConfig6 = state.bookingConfig) === null || _state$bookingConfig6 === void 0 || (_state$bookingConfig6 = _state$bookingConfig6.config) === null || _state$bookingConfig6 === void 0 || (_state$bookingConfig6 = _state$bookingConfig6.basic) === null || _state$bookingConfig6 === void 0 ? void 0 : _state$bookingConfig6.subject_require) === "require" && (!useHolderId || (useHolderId === null || useHolderId === void 0 ? void 0 : useHolderId.length) < ((_state$service$cacheI15 = state.service.cacheItem) === null || _state$service$cacheI15 === void 0 || (_state$service$cacheI15 = _state$service$cacheI15._extend) === null || _state$service$cacheI15 === void 0 ? void 0 : _state$service$cacheI15.quantity));
		return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Form.Item, {
			name: "holder_id",
			style: { width: "100%" },
			rules: [{
				required: (state === null || state === void 0 || (_state$bookingConfig7 = state.bookingConfig) === null || _state$bookingConfig7 === void 0 || (_state$bookingConfig7 = _state$bookingConfig7.config) === null || _state$bookingConfig7 === void 0 || (_state$bookingConfig7 = _state$bookingConfig7.basic) === null || _state$bookingConfig7 === void 0 ? void 0 : _state$bookingConfig7.subject_require) === "require",
				validator: (rule, value, callback) => {
					if (showExtra) callback(locales.getText("page.booking.text.holder.length-error"));
					else callback();
				}
			}]
		}, /* @__PURE__ */ React.createElement(Holder, {
			state,
			cacheItem: state.service.cacheItem,
			dispatch
		})));
	}, [
		state.pet,
		state.client,
		state.service.cacheItem,
		useHolderId
	]);
	const capacity = useMemo(() => {
		return /* @__PURE__ */ React.createElement(Form.Item, {
			noStyle: true,
			name: "capacity"
		}, /* @__PURE__ */ React.createElement(Capacity_default, {
			state,
			cacheItem: state.service.cacheItem
		}));
	}, [
		state.locale,
		state.isTerminal,
		(_state$service9 = state.service) === null || _state$service9 === void 0 || (_state$service9 = _state$service9.cacheItem) === null || _state$service9 === void 0 || (_state$service9 = _state$service9._data) === null || _state$service9 === void 0 ? void 0 : _state$service9.capacitys
	]);
	const hiddenQuantity = useMemo(() => {
		return /* @__PURE__ */ React.createElement(Form.Item, {
			hidden: true,
			name: "quantity"
		}, /* @__PURE__ */ React.createElement(InputNumber, null));
	}, []);
	const quantity = useMemo(() => {
		return /* @__PURE__ */ React.createElement(Col, { span: 24 }, /* @__PURE__ */ React.createElement(Form.Item, {
			label: locales.getText("pisell2.text.quantity"),
			name: "quantity",
			rules: [{ required: true }]
		}, /* @__PURE__ */ React.createElement(InputNumber, {
			size: "large",
			style: { width: "100%" },
			min: 1,
			max: 999999,
			formatter: (value) => {
				if (value !== void 0) return Math.floor(value);
				return value;
			}
		})));
	}, []);
	const footer = useMemo(() => {
		var _state$service$resour;
		return /* @__PURE__ */ React.createElement("div", {
			className: "pisell-lowcode__booking-service-body-edit-footer",
			style: (state === null || state === void 0 ? void 0 : state.isBookingTicket2) ? { justifyContent: "space-between" } : {}
		}, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-service-body-edit-footer-left" }, /* @__PURE__ */ React.createElement("div", {
			className: "pisell-lowcode__booking-service-delete-wrap",
			onClick: handleDeleteProduct
		}, /* @__PURE__ */ React.createElement(Delete_wght300_24px, { className: "pisell-lowcode__booking-service-delete-icon" })), (state === null || state === void 0 ? void 0 : state.isBookingTicket2) && /* @__PURE__ */ React.createElement(ConfigProvider$1, { theme: { token: { colorPrimary: "#0d7fa9" } } }, /* @__PURE__ */ React.createElement(Button, {
			className: "pisell-lowcode__booking-service-buttons-item note-button",
			type: "primary",
			size: "large",
			onClick: () => setNoteModalOpen(true),
			style: {
				height: "48px",
				width: "140px"
			}
		}, locales.getText("pisell2.ticket-booking.note"), useNote && /* @__PURE__ */ React.createElement("span", { className: "note-indicator" }, /* @__PURE__ */ React.createElement(Iconfont, { type: "pisell2-info-circle2" }))))), /* @__PURE__ */ React.createElement(Button, {
			type: "primary",
			className: "pisell-lowcode__booking-service-body-edit-footer-apple",
			disabled: !isNormalProduct && !((_state$service$resour = state.service.resourcesOrigin) === null || _state$service$resour === void 0 ? void 0 : _state$service$resour.length),
			onClick: () => {
				form.submit();
			}
		}, locales.getText("pisell2.text.apply")));
	}, [(_state$service$resour2 = state.service.resourcesOrigin) === null || _state$service$resour2 === void 0 ? void 0 : _state$service$resour2.length, isNormalProduct]);
	console.log("render edit");
	console.log(state.service.editModal && !((_state$service$cacheI16 = state.service.cacheItem) === null || _state$service$cacheI16 === void 0 ? void 0 : _state$service$cacheI16.autoClose), performance.now() - window.pp1, "打开商品1");
	const [val, setVal] = useState(false);
	useEffect(() => {
		if (isShowTimeAndResource) setTimeout(() => {
			setVal(true);
		}, 200);
		else setVal(false);
	}, [isShowTimeAndResource]);
	const handleNoteConfirm = (noteValue) => {
		form.setFieldsValue({ note: noteValue });
		setNoteModalOpen(false);
	};
	const handleNoteDelete = () => {
		form.setFieldsValue({ note: "" });
		setNoteModalOpen(false);
	};
	const handleNoteCancel = () => {
		setNoteModalOpen(false);
	};
	const groupDom = useMemo(() => {
		return /* @__PURE__ */ React.createElement(React.Fragment, null, !!isEditGroup && /* @__PURE__ */ React.createElement(Demo, {
			value: currentTab,
			onChange: (e) => {
				console.log(e);
				setCurrentTab(e);
			}
		}), /* @__PURE__ */ React.createElement("div", {
			className: "",
			style: { display: currentTab === "booking_list" ? "block" : "none" }
		}, /* @__PURE__ */ React.createElement(BookingList, { items })));
	}, [
		isEditGroup,
		currentTab,
		items
	]);
	const updateMultiDay = function() {
		var _ref = _asyncToGenerator(function* ({ start_date, end_date, duration }) {
			const cacheItem = yield getMultiDay({
				start_date,
				end_date,
				state,
				cacheItem: getCurrentCacheItem()
			});
			if (duration !== void 0) cacheItem._extend.duration = duration;
			cacheItem._extend.items = createBookingItemsByGroup(cacheItem);
			cacheItem._extend = _objectSpread2(_objectSpread2({}, cacheItem._extend), getGroupTotalPrice(cacheItem._extend.items));
			dispatch({
				type: "setService",
				payload: { cacheItem }
			});
			let fieldsValues = { total: cacheItem._extend.total };
			form.setFieldsValue(fieldsValues);
		});
		return function updateMultiDay(_x) {
			return _ref.apply(this, arguments);
		};
	}();
	const onValuesChange = (changedValues) => {
		if (isEditGroup) {
			if (changedValues === null || changedValues === void 0 ? void 0 : changedValues.duration) {
				const end_date = dayjs(useStartDate).add(changedValues === null || changedValues === void 0 ? void 0 : changedValues.duration, "day");
				form.setFieldsValue({ end_date });
				return updateMultiDay({
					start_date: useStartDate,
					end_date,
					duration: changedValues === null || changedValues === void 0 ? void 0 : changedValues.duration
				});
			}
			if (changedValues === null || changedValues === void 0 ? void 0 : changedValues.start_date) {
				const startDate = dayjs(changedValues === null || changedValues === void 0 ? void 0 : changedValues.start_date);
				const endDate = dayjs(useEndDate);
				if (startDate.isAfter(endDate)) return form.setFieldsValue({
					duration: void 0,
					end_date: void 0
				});
			}
			if ((changedValues === null || changedValues === void 0 ? void 0 : changedValues.start_date) || (changedValues === null || changedValues === void 0 ? void 0 : changedValues.end_date)) {
				const duration = getDays(getCurrentCacheItem(), "days");
				updateMultiDay({
					start_date: (changedValues === null || changedValues === void 0 ? void 0 : changedValues.start_date) || useStartDate,
					end_date: (changedValues === null || changedValues === void 0 ? void 0 : changedValues.end_date) || useEndDate,
					duration
				});
				return form.setFieldsValue({ duration });
			}
		}
	};
	const deleteDiscountList = (cacheItem) => {
		var _cacheItem$_extend$ot, _cacheItem$_extend$ot2;
		delete cacheItem.discount_list;
		(_cacheItem$_extend$ot = cacheItem._extend.other) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot = _cacheItem$_extend$ot.bundle) === null || _cacheItem$_extend$ot === void 0 || (_cacheItem$_extend$ot2 = _cacheItem$_extend$ot.forEach) === null || _cacheItem$_extend$ot2 === void 0 || _cacheItem$_extend$ot2.call(_cacheItem$_extend$ot, (bundle) => {
			var _bundle$metadata;
			bundle === null || bundle === void 0 || (_bundle$metadata = bundle.metadata) === null || _bundle$metadata === void 0 || delete _bundle$metadata.custom_product_bundle_map_id;
			bundle === null || bundle === void 0 || delete bundle.discount_list;
			bundle === null || bundle === void 0 || delete bundle.booking_id;
			bundle === null || bundle === void 0 || delete bundle.bundle_selling_price;
			bundle === null || bundle === void 0 || delete bundle.bundle_payment_price;
		});
		return cacheItem;
	};
	const handleKeepOriginal = () => {
		setDiscountChangeModalOpen(false);
	};
	const handleContinue = function() {
		var _ref2 = _asyncToGenerator(function* () {
			let cacheItem = _objectSpread2({}, state.service.cacheItem);
			cacheItem = deleteDiscountList(cacheItem);
			yield shopDiscount.batchSearchByProductIds(noInOriginalDiscountIdsRef.current);
			onFinish(valuesRef.current, cacheItem);
			setDiscountChangeModalOpen(false);
		});
		return function handleContinue() {
			return _ref2.apply(this, arguments);
		};
	}();
	const handleRemove = () => {
		setDiscountChangeModalOpen(false);
		const cacheItem = deleteDiscountList(_objectSpread2({}, state.service.cacheItem));
		onFinish(valuesRef.current, cacheItem);
	};
	const handleCancel = () => {
		setDiscountChangeModalOpen(false);
	};
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Drawer$2, {
		titleNoWrap: true,
		zIndex: state.service.changeService ? 999 : 1e3,
		forceRender: true,
		mask: state.drawerMask,
		open: !isNoSpecAndPackage && state.service.editModal && !((_state$service$cacheI17 = state.service.cacheItem) === null || _state$service$cacheI17 === void 0 ? void 0 : _state$service$cacheI17.autoClose),
		title: locales.getText("pisell2.text.edit-service"),
		onClose: () => {
			var _window$closeBookingE4, _window4;
			(_window$closeBookingE4 = (_window4 = window).closeBookingEditModal) === null || _window$closeBookingE4 === void 0 || _window$closeBookingE4.call(_window4);
			dispatch({
				type: "setService",
				payload: {
					editModal: false,
					cacheItem: null,
					changeService: false
				}
			});
		}
	}, /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-service-body-edit" }, groupDom, /* @__PURE__ */ React.createElement(Form, {
		layout: "vertical",
		form,
		onFinish: onFinishBefore,
		onValuesChange,
		style: { display: currentTab === "batch_edit" ? "block" : "none" }
	}, /* @__PURE__ */ React.createElement(Row, {
		style: { width: "100%" },
		gutter: [16, 0]
	}, productName, price, reason, val && isShowTimeAndResource && /* @__PURE__ */ React.createElement(React.Fragment, null, startTime, endTime, duration, resource, capacity, hiddenQuantity), isNormalProduct && quantity, !isNormalProductByDurationSchedule(state.service.cacheItem) && !isWalkIn((_state$client2 = state.client) === null || _state$client2 === void 0 || (_state$client2 = _state$client2.value) === null || _state$client2 === void 0 ? void 0 : _state$client2.id) && holder), /* @__PURE__ */ React.createElement(Form.Item, {
		noStyle: true,
		name: "note"
	}, noteModalOpen && /* @__PURE__ */ React.createElement(NoteModal, {
		open: noteModalOpen,
		value: form.getFieldValue("note"),
		onConfirm: handleNoteConfirm,
		onDelete: handleNoteDelete,
		onCancel: handleNoteCancel
	}))), footer)), /* @__PURE__ */ React.createElement(DiscountChangeModal, {
		open: discountChangeModalOpen,
		onKeepOriginal: handleKeepOriginal,
		onContinue: handleContinue,
		onRemove: handleRemove,
		onCancel: handleCancel
	}));
};
var editService_default = forwardRef(Info);
//#endregion
export { editService_default as default };
