const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_mock = require("../../mock.js");
const require_status = require("./status.js");
const require_asyncToGenerator = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
const require_serve = require("../service/serve.js");
const require_locales = require("../../locales.js");
const require_utilsByBooking = require("../../info2/utilsByBooking.js");
const require_utils = require("../../info2/service/addService/utils.js");
const require_amount = require("../../components/footer/amount.js");
const require_utils$1 = require("./Group/utils.js");
const require_utils$2 = require("../service/addService/utils.js");
const require_utils$3 = require("../../utils.js");
const require_utils$4 = require("../utils.js");
let dayjs = require("dayjs");
dayjs = require_runtime.__toESM(dayjs);
let _pisell_utils = require("@pisell/utils");
//#region src/components/booking/info/service2/utils.ts
_pisell_utils.locales.init(require_locales.default, localStorage.getItem("umi_locale") || "en");
const formatActiveKey = (lists, platform, isEdit) => {
	if (!(lists === null || lists === void 0 ? void 0 : lists.length)) return [];
	if (lists.length === 1 && isEdit) return [];
	if (platform === "shop") {
		var _lists2;
		return [(_lists2 = lists[lists.length - 1]) === null || _lists2 === void 0 ? void 0 : _lists2.key];
	}
	return lists === null || lists === void 0 ? void 0 : lists.map((cart) => cart === null || cart === void 0 ? void 0 : cart.key);
};
/**
* @title: 获取资源名称
* @description:
* @param {any} id
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-11-29 18:02
*/
const getResourceItem = (id, state) => {
	var _state$service$resour;
	if (id === 0) return require_mock.getNoResource();
	return (_state$service$resour = state.service.resources) === null || _state$service$resour === void 0 ? void 0 : _state$service$resour.find((d) => d.form_record_id === id);
};
const errorTypes = {
	product: _pisell_utils.locales.getText("pisell2.text.status.service-error-1"),
	time: _pisell_utils.locales.getText("pisell2.text.status.service-error-2"),
	maxLimit: _pisell_utils.locales.getText("pisell2.text.status.service-error-3"),
	limit: _pisell_utils.locales.getText("pisell2.text.status.service-error-3")
};
/**
* @title: 错误提示
* @description:
* @param {any} service
* @param {any} resourceItem
* @return {*}
* @Author: WangHan
* @Date: 2024-11-29 18:41
*/
const getErrorMessage = (service, resourceItem, isDay) => {
	const errorList = require_utils$3.getErrorList(resourceItem, service, isDay);
	let errorMessage = "";
	if (!service.id) return errorList[0].label;
	if (errorList.length) if (errorList.length > 1) errorMessage = `${errorList.length} ${_pisell_utils.locales.getText("pisell2.text.warnings")}`;
	else errorMessage = (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.labelText) + " " + errorTypes[errorList[0].type];
	return errorMessage;
};
/**
* @title: 格式化主体列表
* @description:
* @param {any} lists
* @param {boolean} isOpenGroup
* @return {*}
* @Author: WangHan
* @Date: 2024-12-04 11:27
*/
const formatHolderLists = (lists) => {
	const _lists = lists === null || lists === void 0 ? void 0 : lists.map((item) => {
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, {
			id: (item === null || item === void 0 ? void 0 : item.id) || (item === null || item === void 0 ? void 0 : item.form_record_id),
			key: (item === null || item === void 0 ? void 0 : item.id) || (item === null || item === void 0 ? void 0 : item.form_record_id),
			label: _pisell_utils.locales.getText("pisell2.text.cart.of")(item === null || item === void 0 ? void 0 : item.main_field)
		});
	});
	return [{
		key: 0,
		id: 0,
		label: _pisell_utils.locales.getText("pisell2.text.open.items"),
		main_field: _pisell_utils.locales.getText("pisell2.text.open.items")
	}].concat(_lists);
};
/**
* @title: pets数据加 open items
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-03 11:40
*/
const getHolderLists = (state) => {
	var _state$bookingConfig, _state$pet;
	const form_id = (state === null || state === void 0 || (_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 || (_state$bookingConfig = _state$bookingConfig.appointment_subject) === null || _state$bookingConfig === void 0 ? void 0 : _state$bookingConfig.form_id) || 0;
	return formatHolderLists((state === null || state === void 0 || (_state$pet = state.pet) === null || _state$pet === void 0 || (_state$pet = _state$pet.value) === null || _state$pet === void 0 ? void 0 : _state$pet[form_id]) || []);
};
/**
* @title: 获取pet名称
* @description:
* @param {any} state
* @param {number} id
* @return {*}
* @Author: WangHan
* @Date: 2024-12-03 11:42
*/
const getHolderName = (state, id) => {
	const holderLists = getHolderLists(state);
	if (!holderLists.length || !id) return "";
	const resource = holderLists.find((d) => (d === null || d === void 0 ? void 0 : d.id) === id);
	return resource === null || resource === void 0 ? void 0 : resource.main_field;
};
const isBookingProduct = (extension_type, bol) => {
	return require_status.appointmentTypes.includes(extension_type) || bol;
};
/**
* @title: 是否是预约商品
* @description:
* @return {*}
* @Author: WangHan
* @Date: 2024-12-06 11:24
*/
const isDayBookingProduct = (item, state) => {
	return isBookingProduct(item === null || item === void 0 ? void 0 : item.extension_type) && state.renderType === "dayBooking";
};
const currentResource = (state, useResource, cacheItem) => {
	const resourcesOrigin = state.service.resourcesOrigin;
	return require_utils$2.formatResources({
		cacheItem,
		resourcesOrigin,
		isDay: false
	}).find((d) => d.form_record_id == useResource) || {};
};
const handleChangeHolder = (products, currentItem, other) => {
	return products.map((item) => {
		var _item$_extend, _item$_extend2, _currentItem$_origin;
		const isSameGroup = (item === null || item === void 0 || (_item$_extend = item._extend) === null || _item$_extend === void 0 ? void 0 : _item$_extend.groupId) && ((_item$_extend2 = item._extend) === null || _item$_extend2 === void 0 ? void 0 : _item$_extend2.groupId) === (currentItem === null || currentItem === void 0 || (_currentItem$_origin = currentItem._origin) === null || _currentItem$_origin === void 0 || (_currentItem$_origin = _currentItem$_origin._extend) === null || _currentItem$_origin === void 0 ? void 0 : _currentItem$_origin.groupId);
		if (item._id === currentItem._id || isSameGroup) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { _extend: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item._extend), {}, { holder_id: (0, _pisell_utils.isArr)(other) ? other.map((item) => item.id) : item._extend.quantity > 1 ? [other.id] : other === null || other === void 0 ? void 0 : other.id }) });
		return item;
	});
};
const handleLike = (products, currentItem, other) => {
	return products.map((item) => {
		var _item$_extend3, _item$_extend4;
		const isSameGroup = (item === null || item === void 0 || (_item$_extend3 = item._extend) === null || _item$_extend3 === void 0 ? void 0 : _item$_extend3.groupId) && ((_item$_extend4 = item._extend) === null || _item$_extend4 === void 0 ? void 0 : _item$_extend4.groupId) === (currentItem === null || currentItem === void 0 ? void 0 : currentItem.serviceId);
		if (currentItem.isParallelResource) {
			if (item._id === currentItem.serviceId || isSameGroup) {
				var _item$_extend5, _item$_extend6;
				return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { _extend: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item._extend), {}, { resource: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, (_item$_extend5 = item._extend) === null || _item$_extend5 === void 0 ? void 0 : _item$_extend5.resource), {}, { [currentItem.resourceId]: (_item$_extend6 = item._extend) === null || _item$_extend6 === void 0 ? void 0 : _item$_extend6.resource[currentItem.resourceId].map((item) => require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { like_status: other.like_status })) }) }) });
			}
			return item;
		} else {
			if (item._id === currentItem._id || isSameGroup) return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { _extend: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item._extend), {}, { like_status: other.like_status }) });
			return item;
		}
	});
};
const handleChangeResource = (products, currentItem, other, state) => {
	return products.map((item) => {
		var _item$_extend7, _item$_extend8, _currentItem$_origin2;
		const { props, value } = other || {};
		const { isParallelResource, resourceId } = props || {};
		const isSameGroup = (item === null || item === void 0 || (_item$_extend7 = item._extend) === null || _item$_extend7 === void 0 ? void 0 : _item$_extend7.groupId) && ((_item$_extend8 = item._extend) === null || _item$_extend8 === void 0 ? void 0 : _item$_extend8.groupId) === (currentItem === null || currentItem === void 0 || (_currentItem$_origin2 = currentItem._origin) === null || _currentItem$_origin2 === void 0 || (_currentItem$_origin2 = _currentItem$_origin2._extend) === null || _currentItem$_origin2 === void 0 ? void 0 : _currentItem$_origin2.groupId);
		if (isParallelResource) {
			if (item._id === currentItem._id || isSameGroup) {
				const hasDataItem = require_utils.getProductExtend({
					cacheItem: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { new: 0 }),
					state
				});
				const maps = hasDataItem._extend.resource[resourceId] ? hasDataItem._extend.resource[resourceId].reduce((pre, cur) => {
					pre[cur.relation_id] = cur;
					return pre;
				}, {}) : {};
				item._extend.resource[resourceId] = value.map((d) => {
					var _hasDataItem$_data$re, _currentForm$renderLi, _currentForm$renderLi2, _currentForm$renderLi3, _currentForm$renderLi4, _currentForm$renderLi5;
					const currentForm = ((_hasDataItem$_data$re = hasDataItem._data.resourceMaps) === null || _hasDataItem$_data$re === void 0 ? void 0 : _hasDataItem$_data$re[resourceId]) || {};
					return maps[d] || {
						relation_type: ((_currentForm$renderLi = currentForm.renderListMaps[d]) === null || _currentForm$renderLi === void 0 || (_currentForm$renderLi = _currentForm$renderLi.usable) === null || _currentForm$renderLi === void 0 ? void 0 : _currentForm$renderLi.relation_type) || "form",
						form_id: resourceId,
						relation_id: d,
						like_status: "common",
						errors: require_utilsByBooking.getErrorList((_currentForm$renderLi2 = currentForm.renderListMaps) === null || _currentForm$renderLi2 === void 0 ? void 0 : _currentForm$renderLi2[d], hasDataItem),
						children: (_currentForm$renderLi3 = currentForm.renderListMaps) === null || _currentForm$renderLi3 === void 0 || (_currentForm$renderLi3 = _currentForm$renderLi3[d]) === null || _currentForm$renderLi3 === void 0 ? void 0 : _currentForm$renderLi3.children,
						metadata: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, (_currentForm$renderLi4 = currentForm.renderListMaps) === null || _currentForm$renderLi4 === void 0 || (_currentForm$renderLi4 = _currentForm$renderLi4[d]) === null || _currentForm$renderLi4 === void 0 ? void 0 : _currentForm$renderLi4.metadata), {}, {
							form_name: currentForm.title,
							resource_name: (_currentForm$renderLi5 = currentForm.renderListMaps[d]) === null || _currentForm$renderLi5 === void 0 ? void 0 : _currentForm$renderLi5.main_field
						})
					};
				});
			}
			return item;
		} else {
			if (item._id === currentItem._id || isSameGroup) {
				var _resourceItem$_extend;
				const resourceItem = currentResource(state, other.id, item);
				const { relation_type, item_id, schedule_id } = (resourceItem === null || resourceItem === void 0 || (_resourceItem$_extend = resourceItem._extend) === null || _resourceItem$_extend === void 0 ? void 0 : _resourceItem$_extend.usableTime) || {};
				return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { _extend: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item._extend), {}, {
					resource: item_id || (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.form_record_id) || 0,
					relation_type: relation_type || "form",
					relation_id: item_id || (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.form_record_id) || 0,
					schedule_id: schedule_id || 0
				}) });
			}
			return item;
		}
	});
};
/**
* @title: 更新商品数据
* @description:
* @param {any} state
* @param currentItem
* @param {string} type
* @param {any} other
* @param actions
* @return {*}
* @Author: WangHan
* @Date: 2025-01-03 15:00
*/
const updateServices = (state, currentItem, type, other, actions) => {
	var _state$service, _state$service2;
	if (!(state === null || state === void 0 || (_state$service = state.service) === null || _state$service === void 0 ? void 0 : _state$service.value)) return [];
	let products = (state === null || state === void 0 || (_state$service2 = state.service) === null || _state$service2 === void 0 ? void 0 : _state$service2.value) || [];
	const isGroup = require_utils$1.isGroupBooking(currentItem._id);
	if (type === "delete") {
		let deleteIds = [];
		if (isGroup) deleteIds = require_utils$1.getProductByGroupId(currentItem._id, products);
		else deleteIds = [currentItem._id];
		products = products === null || products === void 0 ? void 0 : products.filter((item) => !deleteIds.includes(item === null || item === void 0 ? void 0 : item._id));
	}
	if (type === "delete_holders") products = products === null || products === void 0 ? void 0 : products.filter((item) => {
		var _item$_extend9;
		return (item === null || item === void 0 || (_item$_extend9 = item._extend) === null || _item$_extend9 === void 0 ? void 0 : _item$_extend9.holder_id) !== other;
	});
	if (type === "change_holder") {
		products = handleChangeHolder(products, currentItem, other);
		return products;
	}
	if (type === "add_holder") {
		var _actions$handleAddHol;
		actions === null || actions === void 0 || (_actions$handleAddHol = actions.handleAddHolder) === null || _actions$handleAddHol === void 0 || _actions$handleAddHol.call(actions, products, currentItem);
		return products;
	}
	if (type === "like") products = handleLike(products, currentItem, other);
	if (type === "change_resource") {
		products = handleChangeResource(products, currentItem, other, state);
		return products;
	}
	if (type === "num") return products.map((product) => {
		if (product._id === currentItem._id) {
			product._extend.quantity = other.num;
			return product;
		}
		return product;
	});
	if (type === "update_holders") products = products === null || products === void 0 ? void 0 : products.map((item) => {
		const ids = currentItem.map((d) => d._id);
		if (ids === null || ids === void 0 ? void 0 : ids.includes(item === null || item === void 0 ? void 0 : item._id)) {
			let _extend = item._extend || {};
			if (Array.isArray(other)) {
				var _other$find;
				_extend.holder_id = (_other$find = other.find((other) => (other === null || other === void 0 ? void 0 : other._id) === (item === null || item === void 0 ? void 0 : item._id))) === null || _other$find === void 0 ? void 0 : _other$find.holder_id;
			} else _extend.holder_id = other;
			return item;
		}
		return item;
	});
	else products = products === null || products === void 0 ? void 0 : products.map((item) => {
		let updateIds = [];
		if (isGroup) updateIds = require_utils$1.getProductByGroupId(currentItem._id, products);
		else updateIds = [currentItem._id];
		if (updateIds.includes(item._id)) {
			if (type === "like") {
				let _extend = item._extend || {};
				_extend.like_status = other === null || other === void 0 ? void 0 : other.like_status;
			} else item = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), other);
			return item;
		}
		return item;
	});
	return products;
};
/**
* @title: 格式化套餐
* @description:
* @param {any} bundle
* @return {*}
* @Author: WangHan
* @Date: 2025-01-03 00:03
*/
const formatBundle = (bundle) => {
	if (!(bundle === null || bundle === void 0 ? void 0 : bundle.length)) return [];
	return bundle.map((item) => {
		return {
			id: item === null || item === void 0 ? void 0 : item.id,
			title: item === null || item === void 0 ? void 0 : item.title,
			cover: item === null || item === void 0 ? void 0 : item.cover,
			num: item === null || item === void 0 ? void 0 : item.num,
			price: item === null || item === void 0 ? void 0 : item.price,
			total: item === null || item === void 0 ? void 0 : item.price,
			origin_total: item.original_total,
			price_type: item === null || item === void 0 ? void 0 : item.price_type,
			bundle_sum_price: item === null || item === void 0 ? void 0 : item.bundle_sum_price,
			bundle_sum_type: item === null || item === void 0 ? void 0 : item.bundle_sum_type,
			options: formatOptions(item === null || item === void 0 ? void 0 : item.option)
		};
	});
};
/**
* @title: 格式化单规格
* @description:
* @param {any} options
* @return {*}
* @Author: WangHan
* @Date: 2025-01-02 23:58
*/
const formatOptions = (options) => {
	if (!(options === null || options === void 0 ? void 0 : options.length)) return [];
	return options.map((item) => {
		const price = Number((item === null || item === void 0 ? void 0 : item.price) || (item === null || item === void 0 ? void 0 : item.add_price));
		return {
			id: item === null || item === void 0 ? void 0 : item.id,
			name: item === null || item === void 0 ? void 0 : item.name,
			num: item === null || item === void 0 ? void 0 : item.num,
			price,
			total: price,
			origin_total: item === null || item === void 0 ? void 0 : item.original_price
		};
	});
};
const formItems = (items) => {
	return items.map((d) => {
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, d), {}, {
			start_date: d._extend.start_date,
			end_date: d._extend.end_date,
			num: d === null || d === void 0 ? void 0 : d._extend.quantity,
			total: d._extend.total,
			origin_total: d._extend.origin_total
		});
	});
};
const formatHolders = (items) => {
	return items.map((d) => {
		return {
			id: d === null || d === void 0 ? void 0 : d.form_record_id,
			label: d === null || d === void 0 ? void 0 : d.main_field
		};
	});
};
const getErrorMessageInfo2 = (errorList) => {
	let errorMessage = "";
	if (errorList === null || errorList === void 0 ? void 0 : errorList.length) if (errorList.length === 1) errorMessage = errorList[0].label + " " + errorTypes[errorList[0].type];
	else errorMessage = `${errorList.length} ${_pisell_utils.locales.getText("pisell2.text.warnings")}`;
	return errorMessage;
};
const getAllErrorList = (item) => {
	const { resourceMaps } = item._data || {};
	const { resource = {} } = item._extend || {};
	const errorList = [];
	Object.entries(resource).forEach(([key, value]) => {
		value.forEach((val) => {
			var _resourceMaps$key;
			const list = require_utilsByBooking.getErrorList((_resourceMaps$key = resourceMaps[key]) === null || _resourceMaps$key === void 0 ? void 0 : _resourceMaps$key.renderListMaps[val.relation_id], item);
			errorList.push(...list);
			console.log(list, "list");
		});
	});
	return errorList;
};
const mapListItems = (items) => items.map((item) => ({
	id: item.id || item.form_record_id,
	label: item.labelText,
	isError: !item.usable || item.unbound
}));
const getIsSubjectRequire = (state) => {
	var _state$bookingConfig2, _state$bookingConfig3;
	return (state === null || state === void 0 || (_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 || (_state$bookingConfig2 = _state$bookingConfig2.appointment_subject) === null || _state$bookingConfig2 === void 0 ? void 0 : _state$bookingConfig2.type) === "form" && (state === null || state === void 0 || (_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.subject_require) === "require";
};
const isNormalProductByDurationSchedule = (item) => {
	var _item$schedules, _item$scheduleIds;
	return !(item === null || item === void 0 ? void 0 : item.duration) && !(item === null || item === void 0 || (_item$schedules = item.schedules) === null || _item$schedules === void 0 ? void 0 : _item$schedules.length) && !(item === null || item === void 0 || (_item$scheduleIds = item["schedule.ids"]) === null || _item$scheduleIds === void 0 ? void 0 : _item$scheduleIds.length);
};
const genRowKey = (key) => {
	return `rowKey-${key}`;
};
const getGeneralParams = (item, state, isParallelResource) => {
	var _state$bookingConfig4, _state$bookingConfig5, _formData$, _item$_extend11, _item$_extend12, _item$_extend13, _item$_extend14, _item$_extend15;
	const { pet, service } = state;
	const { holders = [], formData } = pet || {};
	const parallelResourceOtherParams = {};
	let multiResources;
	if (isParallelResource) {
		let hasDataItem = item;
		if (!isNormalProductByDurationSchedule(hasDataItem) && !hasDataItem._data) hasDataItem = require_utils.getProductExtend({
			cacheItem: require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { new: 0 }),
			state
		});
		const { resourceMaps, resources } = hasDataItem._data || {};
		parallelResourceOtherParams.errorMessage = getErrorMessageInfo2(getAllErrorList(hasDataItem));
		multiResources = resources.map((resource) => {
			var _detail$select_type, _value$;
			const key = resource.form_id;
			const detail = resourceMaps === null || resourceMaps === void 0 ? void 0 : resourceMaps[key];
			const isMultiple = (detail === null || detail === void 0 || (_detail$select_type = detail.select_type) === null || _detail$select_type === void 0 ? void 0 : _detail$select_type.type) === "multiple";
			const value = item._extend.resource[key];
			return {
				is_hide_like: isMultiple,
				isParallelResource: true,
				maxLength: isMultiple && detail.select_type.max,
				resourceMode: isMultiple ? "multiple" : void 0,
				serviceId: item._id,
				resourceId: key,
				_id: key,
				id: (value || []).map((val) => val.relation_id),
				status: (value === null || value === void 0 || (_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.like_status) || "common",
				lists: (detail === null || detail === void 0 ? void 0 : detail.renderList) ? mapListItems(detail === null || detail === void 0 ? void 0 : detail.renderList) : [],
				disabled: state.disabledEdit || state.disableEventBookingEdit
			};
		});
	} else {
		var _item$_extend10;
		const { resourcesOrigin } = service || {};
		const resource = require_utils$2.formatResources({
			cacheItem: item,
			resourcesOrigin,
			isDay: false
		});
		multiResources = [{
			_id: item._id,
			id: item._extend.resource,
			status: ((_item$_extend10 = item._extend) === null || _item$_extend10 === void 0 ? void 0 : _item$_extend10.like_status) || "common",
			lists: mapListItems(resource)
		}];
	}
	const isNormalProduct = isNormalProductByDurationSchedule(item);
	return require_objectSpread2._objectSpread2({
		format: ["HH:mm", "HH:mm"],
		show_time: true,
		duration_type: require_utils.isMultiDayProduct(item) ? "days" : "minutes",
		holders: formatHolders(holders),
		isShowChangeHolder: !isNormalProduct,
		isShowAction: require_utils$4.isShowAddTime(state, item),
		allowClearHolder: true,
		actionText: _pisell_utils.locales.getText("page.booking.text.add-time"),
		actionIcon: "pisell2-clock-plus",
		isMultipleResource: true,
		isFormSubject: (state === null || state === void 0 || (_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.appointment_subject) === null || _state$bookingConfig4 === void 0 ? void 0 : _state$bookingConfig4.type) === "form",
		holderType: (state === null || state === void 0 || (_state$bookingConfig5 = state.bookingConfig) === null || _state$bookingConfig5 === void 0 || (_state$bookingConfig5 = _state$bookingConfig5.holder) === null || _state$bookingConfig5 === void 0 || (_state$bookingConfig5 = _state$bookingConfig5.form) === null || _state$bookingConfig5 === void 0 ? void 0 : _state$bookingConfig5.form_type) || "minors",
		multiResources,
		holderMaxCount: item === null || item === void 0 ? void 0 : item._extend.quantity,
		holderMode: (item === null || item === void 0 ? void 0 : item._extend.quantity) > 1 ? "multiple" : void 0,
		isErrorHolder: getIsSubjectRequire(state),
		addHolderButtonText: (formData === null || formData === void 0 || (_formData$ = formData[0]) === null || _formData$ === void 0 || (_formData$ = _formData$.form) === null || _formData$ === void 0 ? void 0 : _formData$.title) || "",
		holder_id: item === null || item === void 0 || (_item$_extend11 = item._extend) === null || _item$_extend11 === void 0 ? void 0 : _item$_extend11.holder_id,
		start_date: !isNormalProduct ? item === null || item === void 0 || (_item$_extend12 = item._extend) === null || _item$_extend12 === void 0 ? void 0 : _item$_extend12.startDate : "",
		end_date: !isNormalProduct ? (item === null || item === void 0 || (_item$_extend13 = item._extend) === null || _item$_extend13 === void 0 ? void 0 : _item$_extend13.endDate) || (item === null || item === void 0 || (_item$_extend14 = item._extend) === null || _item$_extend14 === void 0 ? void 0 : _item$_extend14.end_date) : "",
		rowKey: genRowKey(item === null || item === void 0 || (_item$_extend15 = item._extend) === null || _item$_extend15 === void 0 || (_item$_extend15 = _item$_extend15.other) === null || _item$_extend15 === void 0 ? void 0 : _item$_extend15.rowKey)
	}, parallelResourceOtherParams);
};
const calcAddTimeTotalPrice = (total, addTimeProducts) => {
	return (Number(total) || 0) + require_amount.getRelationDetailsTotal(addTimeProducts || []);
};
/**
* @title: 格式化商品数据
* @description:
* @param {any} lists
* @return {*}
* @Author: WangHan
* @Date: 2024-11-29 17:36
*/
const formatProducts = (lists, state, isRenderGroup = true, isGeneral, isParallelResource) => {
	if (!(lists === null || lists === void 0 ? void 0 : lists.length)) return [];
	const formItem = (item) => {
		var _item$_extend16, _item$_extend17, _item$_extend18, _item$_extend20, _item$_extend21, _item$_extend22, _item$_extend23, _item$_extend24, _item$_extend25, _item$_extend26, _item$_extend27, _item$_extend28, _item$_extend29, _item$_extend30, _item$_extend31, _item$_extend32, _item$_extend33, _item$_extend34;
		const _isDayBookingProduct = isDayBookingProduct(item, state);
		const clientTitle = getHolderName(state, item === null || item === void 0 || (_item$_extend16 = item._extend) === null || _item$_extend16 === void 0 ? void 0 : _item$_extend16.holder_id);
		const options = formatOptions(item === null || item === void 0 || (_item$_extend17 = item._extend) === null || _item$_extend17 === void 0 || (_item$_extend17 = _item$_extend17.other) === null || _item$_extend17 === void 0 ? void 0 : _item$_extend17.option);
		const bundle = formatBundle(item === null || item === void 0 || (_item$_extend18 = item._extend) === null || _item$_extend18 === void 0 || (_item$_extend18 = _item$_extend18.other) === null || _item$_extend18 === void 0 ? void 0 : _item$_extend18.bundle);
		const isNormalProduct = !require_status.appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type) || (state === null || state === void 0 ? void 0 : state.renderType) === "eventBooking";
		const isNormalProductByDurationScheduleVal = isNormalProductByDurationSchedule(item);
		let resourceItem = {};
		let errorMessage = "";
		if ((_isDayBookingProduct || isGeneral) && !isNormalProductByDurationScheduleVal) {
			var _item$_extend19;
			resourceItem = getResourceItem(item === null || item === void 0 || (_item$_extend19 = item._extend) === null || _item$_extend19 === void 0 ? void 0 : _item$_extend19.resource, state);
			errorMessage = getErrorMessage(item, resourceItem, isDayBooking(state));
		}
		let generalParams = {};
		if (isGeneral && !isNormalProductByDurationScheduleVal) generalParams = getGeneralParams(item, state, !!isParallelResource);
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({
			id: item === null || item === void 0 ? void 0 : item.id,
			_id: item === null || item === void 0 ? void 0 : item._id,
			name: item === null || item === void 0 ? void 0 : item.title,
			title: item === null || item === void 0 ? void 0 : item.title,
			price: item === null || item === void 0 || (_item$_extend20 = item._extend) === null || _item$_extend20 === void 0 ? void 0 : _item$_extend20.price,
			totalDifference: require_amount.getProductDiscountProductDiscountDifference(item),
			total: calcAddTimeTotalPrice(item === null || item === void 0 || (_item$_extend21 = item._extend) === null || _item$_extend21 === void 0 ? void 0 : _item$_extend21.total, item === null || item === void 0 || (_item$_extend22 = item._extend) === null || _item$_extend22 === void 0 ? void 0 : _item$_extend22.relation_details),
			origin_total: calcAddTimeTotalPrice(item === null || item === void 0 || (_item$_extend23 = item._extend) === null || _item$_extend23 === void 0 ? void 0 : _item$_extend23.origin_total, item === null || item === void 0 || (_item$_extend24 = item._extend) === null || _item$_extend24 === void 0 ? void 0 : _item$_extend24.relation_details),
			num: item === null || item === void 0 ? void 0 : item._extend.quantity,
			image: item === null || item === void 0 ? void 0 : item.cover,
			isShowNote: true,
			note: (item === null || item === void 0 ? void 0 : item.note) || (item === null || item === void 0 || (_item$_extend25 = item._extend) === null || _item$_extend25 === void 0 ? void 0 : _item$_extend25.note),
			like_status: item === null || item === void 0 || (_item$_extend26 = item._extend) === null || _item$_extend26 === void 0 ? void 0 : _item$_extend26.like_status,
			bundle,
			options,
			errorMessage,
			product_option_string: item === null || item === void 0 || (_item$_extend27 = item._extend) === null || _item$_extend27 === void 0 || (_item$_extend27 = _item$_extend27.other) === null || _item$_extend27 === void 0 ? void 0 : _item$_extend27.product_option_string,
			discount_reason: item === null || item === void 0 || (_item$_extend28 = item._extend) === null || _item$_extend28 === void 0 ? void 0 : _item$_extend28.discount_reason,
			resource_id: isNormalProduct ? 0 : item === null || item === void 0 || (_item$_extend29 = item._extend) === null || _item$_extend29 === void 0 ? void 0 : _item$_extend29.resource,
			relation_form_name: isNormalProduct ? "" : (resourceItem === null || resourceItem === void 0 ? void 0 : resourceItem.labelText) || item.relation_form_name,
			holder_title: clientTitle,
			start_date: !isNormalProduct ? item === null || item === void 0 || (_item$_extend30 = item._extend) === null || _item$_extend30 === void 0 ? void 0 : _item$_extend30.start_date : "",
			end_date: !isNormalProduct ? item === null || item === void 0 || (_item$_extend31 = item._extend) === null || _item$_extend31 === void 0 ? void 0 : _item$_extend31.end_date : "",
			holder_id: (item === null || item === void 0 || (_item$_extend32 = item._extend) === null || _item$_extend32 === void 0 ? void 0 : _item$_extend32.holder_id) || 0,
			isNormalProduct,
			isCustomItem: item === null || item === void 0 ? void 0 : item.isCustomItem,
			vouchersApplicable: item === null || item === void 0 ? void 0 : item.vouchersApplicable,
			locale: state.locale,
			symbol: state.amountSymbol,
			relation_products: (item === null || item === void 0 || (_item$_extend33 = item._extend) === null || _item$_extend33 === void 0 ? void 0 : _item$_extend33.relation_details) || [],
			items: isEventBooking(state) ? [] : formItems((item === null || item === void 0 || (_item$_extend34 = item._extend) === null || _item$_extend34 === void 0 ? void 0 : _item$_extend34.items) || [])
		}, generalParams), {}, { _origin: item });
	};
	if (isRenderGroup) {
		const normalItemsWithIndex = [];
		const groupItemsWithIndex = [];
		const groupFirstIndexMap = {};
		lists.forEach((item, index) => {
			var _item$_extend35;
			if (!(item === null || item === void 0 || (_item$_extend35 = item._extend) === null || _item$_extend35 === void 0 ? void 0 : _item$_extend35.groupId)) normalItemsWithIndex.push({
				item,
				index
			});
			else {
				var _item$_extend36;
				const groupId = item === null || item === void 0 || (_item$_extend36 = item._extend) === null || _item$_extend36 === void 0 ? void 0 : _item$_extend36.groupId;
				groupItemsWithIndex.push({
					item,
					index
				});
				if (groupFirstIndexMap[groupId] === void 0) groupFirstIndexMap[groupId] = index;
			}
		});
		const groups = groupItemsWithIndex.reduce((prev, { item }) => {
			var _item$_extend37;
			const groupId = item === null || item === void 0 || (_item$_extend37 = item._extend) === null || _item$_extend37 === void 0 ? void 0 : _item$_extend37.groupId;
			if (!prev[groupId]) prev[groupId] = [];
			prev[groupId].push(item);
			return prev;
		}, {});
		const mergedGroupItems = Object.entries(groups).map(([groupId, items]) => ({
			item: formItem(require_utils$1.concatBookings(items)),
			index: groupFirstIndexMap[groupId]
		}));
		const formattedNormalItems = normalItemsWithIndex.map(({ item, index }) => ({
			item: formItem(item),
			index
		}));
		return [...mergedGroupItems, ...formattedNormalItems].sort((a, b) => a.index - b.index).map(({ item }) => item);
	} else return lists === null || lists === void 0 ? void 0 : lists.map((item) => formItem(item));
};
/**
* @title: 禁用日期
* @description:
* @param {any} current
* @param {string} position
* @param {any} startDate
* @return {*}
* @Author: WangHan
* @Date: 2024-12-03 17:51
*/
const disabledDate = (current, position, currentDate) => {
	if (!(0, dayjs.default)(currentDate).isValid()) return;
	if (position === "start") return false;
	if (position === "end" && current.endOf("day") && currentDate) return (0, dayjs.default)(currentDate.add(8, "months").format("YYYY-MM-DD")) < current.startOf("day") || current.startOf("day") <= currentDate;
	return current && current <= currentDate;
};
/**
* @title: 是否是跨日预约
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-04 09:49
*/
const isDayBooking = (state) => {
	return (state === null || state === void 0 ? void 0 : state.renderType) === "dayBooking" || (state === null || state === void 0 ? void 0 : state.renderType) === "eventBooking";
};
const isDaysBooking = (state) => {
	return (state === null || state === void 0 ? void 0 : state.renderType) === "dayBooking";
};
const isEventBooking = (state) => {
	return state.renderType === "eventBooking";
};
/**
* @title: 是否是terminal上的跨日预约
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-04 15:31
*/
const isTerminalDayBooking = (state) => {
	return state.isTerminalDayBookingPage;
};
const formatDayDate = (_extend) => {
	let startDate = (0, dayjs.default)(_extend === null || _extend === void 0 ? void 0 : _extend.start_date).startOf("day");
	let endDate = (0, dayjs.default)(_extend === null || _extend === void 0 ? void 0 : _extend.end_date).startOf("day");
	return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, _extend), {}, {
		start_date: startDate,
		end_date: endDate
	});
};
/**
* @title: 根据营业日时间格式化时间
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-04 12:07
*/
const formatDayTime = ({ startDate, endDate }) => {
	const shopOpeningTime = localStorage.getItem("shopOpeningHours") || "00:00";
	let start_date = (0, dayjs.default)(startDate).format("YYYY-MM-DD");
	let end_date = (0, dayjs.default)(endDate).format("YYYY-MM-DD");
	return {
		startDateTime: (0, dayjs.default)(`${start_date}T${shopOpeningTime}:00`),
		endDateTime: (0, dayjs.default)(`${end_date}T${shopOpeningTime}:00`).subtract(1, "minute")
	};
};
/**
* @title: 是否有预约商品
* @description:
* @return {*}
* @Author: WangHan
* @Date: 2024-12-12 15:47
*/
const isHasDayAppointmentProduct = (state) => {
	var _state$bookingConfig6, _state$service3, _state$pet2;
	const form_id = (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 || (_state$bookingConfig6 = _state$bookingConfig6.appointment_subject) === null || _state$bookingConfig6 === void 0 ? void 0 : _state$bookingConfig6.form_id) || 0;
	const services = ((_state$service3 = state.service) === null || _state$service3 === void 0 ? void 0 : _state$service3.value) || [];
	const pets = ((_state$pet2 = state.pet) === null || _state$pet2 === void 0 || (_state$pet2 = _state$pet2.value) === null || _state$pet2 === void 0 ? void 0 : _state$pet2[form_id]) || [];
	if (!pets.length) return true;
	const checkType = (extension_type) => {
		if (isEventBooking(state)) return true;
		return require_status.appointmentTypes.includes(extension_type);
	};
	if (!services.filter((d) => checkType(d.extension_type)).length) return true;
	let _pets = pets === null || pets === void 0 ? void 0 : pets.map((d) => {
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, d), {}, { services: services.filter((item) => {
			var _item$_extend38;
			return ((_item$_extend38 = item._extend) === null || _item$_extend38 === void 0 ? void 0 : _item$_extend38.holder_id) == d.form_record_id && checkType(item.extension_type);
		}) });
	});
	_pets = _pets.filter((d) => !d.services.length);
	return _pets.length > 0;
};
/**
* @title: 过滤出如果是预约商品，则只获取跨日的预约商品
* @description:
* @param {any} lists
* @return {*}
* @Author: WangHan
* @Date: 2024-12-13 16:44
*/
const getDayProducts = (holderId, lists, isTerminal) => {
	let _lists = lists || [];
	if (!holderId && !isTerminal) _lists = _lists.filter((item) => !require_status.appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type));
	else _lists = _lists.filter((item) => {
		var _item$duration;
		return !require_status.appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type) || require_status.appointmentTypes.includes(item === null || item === void 0 ? void 0 : item.extension_type) && ((_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.type) === "days";
	});
	return _lists;
};
/**
* @title: 格式化表单数据
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-30 22:19
*/
const getPets = (state) => {
	var _state$bookingConfig7, _state$pet3;
	const form_id = (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 || (_state$bookingConfig7 = _state$bookingConfig7.appointment_subject) === null || _state$bookingConfig7 === void 0 ? void 0 : _state$bookingConfig7.form_id) || 0;
	return (state === null || state === void 0 || (_state$pet3 = state.pet) === null || _state$pet3 === void 0 || (_state$pet3 = _state$pet3.value) === null || _state$pet3 === void 0 ? void 0 : _state$pet3[form_id]) || [];
};
/**
* @title: 得出预约商品
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-30 22:26
*/
const getAppointmentService = (state) => {
	var _state$service4;
	return (((_state$service4 = state.service) === null || _state$service4 === void 0 ? void 0 : _state$service4.value) || []).filter((item) => require_status.appointmentTypes.includes(item.extension_type));
};
/**
* @title: 判断是否打开删除宠物弹窗
* @description:
* @param {any} state
* @param {any} newVal
* @return {*}
* @Author: WangHan
* @Date: 2024-12-16 16:12
*/
const isOpenDeletePet = (state, newVal) => {
	var _state$bookingConfig8, _state$pet4;
	const form_id = (state === null || state === void 0 || (_state$bookingConfig8 = state.bookingConfig) === null || _state$bookingConfig8 === void 0 || (_state$bookingConfig8 = _state$bookingConfig8.config) === null || _state$bookingConfig8 === void 0 || (_state$bookingConfig8 = _state$bookingConfig8.basic) === null || _state$bookingConfig8 === void 0 || (_state$bookingConfig8 = _state$bookingConfig8.appointment_subject) === null || _state$bookingConfig8 === void 0 ? void 0 : _state$bookingConfig8.form_id) || 0;
	const oldPets = (state === null || state === void 0 || (_state$pet4 = state.pet) === null || _state$pet4 === void 0 || (_state$pet4 = _state$pet4.value) === null || _state$pet4 === void 0 ? void 0 : _state$pet4[form_id]) || [];
	const newPets = (newVal === null || newVal === void 0 ? void 0 : newVal[form_id]) || [];
	const lists = oldPets.filter((item) => !newPets.some((newItem) => newItem.form_record_id === item.form_record_id)).map((item) => {
		var _state$service5;
		return require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, item), {}, { services: (_state$service5 = state.service) === null || _state$service5 === void 0 || (_state$service5 = _state$service5.value) === null || _state$service5 === void 0 ? void 0 : _state$service5.filter((d) => {
			var _d$_extend;
			return ((_d$_extend = d._extend) === null || _d$_extend === void 0 ? void 0 : _d$_extend.holder_id) == item.form_record_id;
		}) });
	}).filter((item) => {
		var _item$services;
		return ((_item$services = item.services) === null || _item$services === void 0 ? void 0 : _item$services.length) > 0;
	});
	return {
		ids: lists.map((item) => item.form_record_id),
		lists
	};
};
/**
* @title: 当前选中的表单id
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-17 14:40
*/
const holderId = (state) => {
	var _state$activeCartId;
	return Number((state === null || state === void 0 || (_state$activeCartId = state.activeCartId) === null || _state$activeCartId === void 0 ? void 0 : _state$activeCartId[0]) || 0);
};
/**
* @title: 计算总价
* @description:
* @param {any} data
* @return {*}
* @Author: WangHan
* @Date: 2024-12-31 15:18
*/
function calculateTotalPrice(data) {
	const _price = data === null || data === void 0 ? void 0 : data.reduce((total, item) => total + ((item === null || item === void 0 ? void 0 : item.price) || (item === null || item === void 0 ? void 0 : item.add_price)) * item.num, 0);
	return parseFloat(_price);
}
/**
* @title: 更新单规格价格
* @description:
* @param {any} currentValue
* @param {any} single
* @return {*}
* @Author: WangHan
* @Date: 2024-12-31 15:18
*/
function updateSinglePrice(currentValue, single) {
	const _single = [];
	for (let index = 0; index < currentValue.length; index++) {
		const item = currentValue[index];
		const currentIndex = single.findIndex((_single) => _single.id === item.id);
		if (currentIndex !== -1) {
			item.add_price = single[currentIndex].add_price;
			item.name = single[currentIndex].name;
			_single.push(item);
		}
	}
	return _single;
}
/**
* @title: 更新套餐价格
* @description:
* @param {any} currentValue
* @param {any} param2
* @return {*}
* @Author: WangHan
* @Date: 2024-12-31 15:17
*/
function updateBundlePrice(currentValue, [bundle, single]) {
	const _bundle = [];
	for (let index = 0; index < currentValue.length; index++) {
		const item = currentValue[index];
		const currentIndex = bundle.findIndex((_bundle) => _bundle.id === item.id);
		if (currentIndex !== -1 && bundle[currentIndex]) {
			var _item$option;
			item.title = bundle[currentIndex].title;
			item.price_type = bundle[currentIndex].price_type;
			item._price = bundle[currentIndex].price;
			const bundle_sum_price = parseFloat(bundle[currentIndex].price_type === "markdown" ? bundle[currentIndex].price * -1 : bundle[currentIndex].price).toFixed(2);
			item.price = bundle_sum_price;
			item.bundle_sum_price = bundle_sum_price;
			if (item === null || item === void 0 || (_item$option = item.option) === null || _item$option === void 0 ? void 0 : _item$option.length) {
				item.option = updateSinglePrice(JSON.parse(JSON.stringify(item.option)), single);
				let optionPrice = 0;
				optionPrice = calculateTotalPrice(item.option);
				const bundle_sum_price = (parseFloat(bundle[currentIndex].price_type === "markdown" ? bundle[currentIndex].price * -1 : bundle[currentIndex].price) + optionPrice).toFixed(2);
				item.price = bundle_sum_price;
				item.bundle_sum_price = bundle_sum_price;
			}
			_bundle.push(item);
		}
	}
	return _bundle;
}
/**
* @title: 平铺套餐数据
* @description:
* @param {any} newPackageData
* @return {*}
* @Author: WangHan
* @Date: 2024-12-31 15:17
*/
function flatData(newPackageData) {
	let bundle = [];
	let single = [];
	for (const group of newPackageData) {
		var _group$bundle_item;
		if (group === null || group === void 0 || (_group$bundle_item = group.bundle_item) === null || _group$bundle_item === void 0 ? void 0 : _group$bundle_item.length) for (const item of group.bundle_item) bundle.push(item);
	}
	for (const bundleItem of bundle) {
		var _bundleItem$option_gr;
		if (bundleItem === null || bundleItem === void 0 || (_bundleItem$option_gr = bundleItem.option_group) === null || _bundleItem$option_gr === void 0 ? void 0 : _bundleItem$option_gr.length) for (const group of bundleItem.option_group) {
			var _group$option_item;
			if (group === null || group === void 0 || (_group$option_item = group.option_item) === null || _group$option_item === void 0 ? void 0 : _group$option_item.length) for (const item of group.option_item) single.push(item);
		}
	}
	return [bundle, single];
}
/**
* @title: 更新套餐的价格
* @description:
* @param {any} currentValue
* @param {any} newBundleData
* @return {*}
* @Author: WangHan
* @Date: 2024-12-31 15:16
*/
function updateNormalBundlePrice(currentValue, newBundleData) {
	return updateBundlePrice(JSON.parse(JSON.stringify(currentValue)), flatData(newBundleData));
}
/**
* @title: 更新普通商品价格
* @description:
* @param {any} ids
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-31 15:15
*/
const normalServicePrice = function() {
	var _ref = require_asyncToGenerator._asyncToGenerator(function* (ids, state) {
		var _state$service6, _state$client, _data$list;
		const services = ((_state$service6 = state.service) === null || _state$service6 === void 0 ? void 0 : _state$service6.value) || [];
		const customerId = (state === null || state === void 0 || (_state$client = state.client) === null || _state$client === void 0 || (_state$client = _state$client.value) === null || _state$client === void 0 ? void 0 : _state$client.id) || 0;
		let data = yield state.apis.getServices({
			skip: 1,
			num: 500,
			ids,
			customer_id: customerId,
			open_quotation: 1,
			open_bundle: 1,
			with: ["bundleGroup.bundleItem", "optionGroup.optionItem"],
			_config: { abort: true }
		});
		if (!(data === null || data === void 0 || (_data$list = data.list) === null || _data$list === void 0 ? void 0 : _data$list.length)) return;
		return services.map((item) => {
			let obj = require_objectSpread2._objectSpread2({}, item);
			if (!require_status.appointmentTypes.includes(obj.extension_type)) {
				const product = data.list.find((p) => p.id === (item === null || item === void 0 ? void 0 : item.product_id));
				let _extend = (obj === null || obj === void 0 ? void 0 : obj._extend) || {};
				const other = (_extend === null || _extend === void 0 ? void 0 : _extend.other) || {};
				if (product) {
					var _product$variant, _other$bundle, _product$bundle_group;
					if ((product === null || product === void 0 || (_product$variant = product.variant) === null || _product$variant === void 0 ? void 0 : _product$variant.length) && (other === null || other === void 0 ? void 0 : other.product_variant_id)) {
						var _product$variant2;
						const _variant = product === null || product === void 0 || (_product$variant2 = product.variant) === null || _product$variant2 === void 0 ? void 0 : _product$variant2.find((v) => v.id === (other === null || other === void 0 ? void 0 : other.product_variant_id));
						obj._extend.price = Number(_variant === null || _variant === void 0 ? void 0 : _variant.price);
						obj._extend.other.price = Number(_variant === null || _variant === void 0 ? void 0 : _variant.price);
					} else obj._extend.price = Number(product === null || product === void 0 ? void 0 : product.price);
					if ((other === null || other === void 0 || (_other$bundle = other.bundle) === null || _other$bundle === void 0 ? void 0 : _other$bundle.length) && (product === null || product === void 0 || (_product$bundle_group = product.bundle_group) === null || _product$bundle_group === void 0 ? void 0 : _product$bundle_group.length)) {
						let _bundle = updateNormalBundlePrice(other.bundle, product === null || product === void 0 ? void 0 : product.bundle_group);
						obj._extend.other = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, other), {}, { bundle: _bundle });
					}
					obj._extend.total = require_utils$3.getProductTotalPrice(obj);
					obj._extend.origin_total = require_utils$3.getProductTotalPrice(obj);
				}
			}
			return obj;
		});
	});
	return function normalServicePrice(_x, _x2) {
		return _ref.apply(this, arguments);
	};
}();
/**
* @title: 更新预约商品报价单
* @description:
* @param {any} state
* @param {any} cacheItem
* @return {*}
* @Author: WangHan
* @Date: 2024-12-25 16:41
*/
const updateAppointmentServicePrice = function() {
	var _ref2 = require_asyncToGenerator._asyncToGenerator(function* (state, { start_date, end_date, product_id }) {
		var _state$service7;
		const defaultReturn = {
			multiDayPrices: [],
			price: Number(state === null || state === void 0 || (_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.price) || 0
		};
		try {
			var _state$client2, _state$service$cacheI, _res$data, _res$data2;
			const format = "YYYY-MM-DD";
			const customer_id = (state === null || state === void 0 || (_state$client2 = state.client) === null || _state$client2 === void 0 || (_state$client2 = _state$client2.value) === null || _state$client2 === void 0 ? void 0 : _state$client2.id) || 1;
			const _product_id = product_id || ((_state$service$cacheI = state.service.cacheItem) === null || _state$service$cacheI === void 0 ? void 0 : _state$service$cacheI.product_id) || 0;
			let multi_day_price = null;
			if (!product_id) {
				console.log("updateAppointmentServicePrice", product_id);
				return defaultReturn;
			}
			const res = yield require_serve.postMultiDay(_product_id, {
				customer_id,
				multi_day: {
					start: (0, dayjs.default)(start_date).format(format),
					end: (0, dayjs.default)(end_date).subtract(1, "days").format(format)
				}
			});
			const _prices = (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.multi_day_price) || [];
			multi_day_price = _prices === null || _prices === void 0 ? void 0 : _prices.map((p) => {
				var _p$multi_day, _p$multi_day2;
				const startDate = (0, dayjs.default)(p === null || p === void 0 || (_p$multi_day = p.multi_day) === null || _p$multi_day === void 0 ? void 0 : _p$multi_day.start);
				const endDate = (0, dayjs.default)(p === null || p === void 0 || (_p$multi_day2 = p.multi_day) === null || _p$multi_day2 === void 0 ? void 0 : _p$multi_day2.end).add(1, "day");
				let duration = (endDate === null || endDate === void 0 ? void 0 : endDate.diff(startDate, "day")) || 1;
				return {
					total: Number(p === null || p === void 0 ? void 0 : p.price),
					origin_total: Number(p === null || p === void 0 ? void 0 : p.price),
					num: duration,
					quotation_id: (p === null || p === void 0 ? void 0 : p.quotation_id) || 0,
					start_date: startDate === null || startDate === void 0 ? void 0 : startDate.format(format),
					end_date: endDate === null || endDate === void 0 ? void 0 : endDate.format(format)
				};
			});
			return {
				multiDayPrices: multi_day_price,
				price: Number(res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.price) || 0
			};
		} catch (error) {
			console.log("updateAppointmentServicePrice", error);
		}
		return defaultReturn;
	});
	return function updateAppointmentServicePrice(_x3, _x4) {
		return _ref2.apply(this, arguments);
	};
}();
/**
* @title: 更新普通商品报价单价格
* @description:
* @param {any} state
* @return {*}
* @Author: WangHan
* @Date: 2024-12-24 11:32
*/
const updateServicePrice = (state) => {
	var _state$service8;
	let services = ((_state$service8 = state.service) === null || _state$service8 === void 0 ? void 0 : _state$service8.value) || [];
	let normalServices = services === null || services === void 0 ? void 0 : services.filter((item) => isEventBooking(state) ? true : !require_status.appointmentTypes.includes(item.extension_type));
	let newNormalIds = normalServices === null || normalServices === void 0 ? void 0 : normalServices.map((item) => (item === null || item === void 0 ? void 0 : item.product_id) || (item === null || item === void 0 ? void 0 : item.id));
	newNormalIds = [...new Set(newNormalIds)];
	if (newNormalIds === null || newNormalIds === void 0 ? void 0 : newNormalIds.length) return normalServicePrice(newNormalIds, state);
	return [];
};
//#endregion
exports.disabledDate = disabledDate;
exports.formatActiveKey = formatActiveKey;
exports.formatDayDate = formatDayDate;
exports.formatDayTime = formatDayTime;
exports.formatHolderLists = formatHolderLists;
exports.formatProducts = formatProducts;
exports.genRowKey = genRowKey;
exports.getAppointmentService = getAppointmentService;
exports.getDayProducts = getDayProducts;
exports.getIsSubjectRequire = getIsSubjectRequire;
exports.getPets = getPets;
exports.handleChangeHolder = handleChangeHolder;
exports.holderId = holderId;
exports.isBookingProduct = isBookingProduct;
exports.isDayBooking = isDayBooking;
exports.isDayBookingProduct = isDayBookingProduct;
exports.isDaysBooking = isDaysBooking;
exports.isEventBooking = isEventBooking;
exports.isHasDayAppointmentProduct = isHasDayAppointmentProduct;
exports.isNormalProductByDurationSchedule = isNormalProductByDurationSchedule;
exports.isOpenDeletePet = isOpenDeletePet;
exports.isTerminalDayBooking = isTerminalDayBooking;
exports.updateAppointmentServicePrice = updateAppointmentServicePrice;
exports.updateServicePrice = updateServicePrice;
exports.updateServices = updateServices;
