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";
//#region src/components/appointmentBooking/components/Cart/utils.ts
const checkLogin = function() {
	var _ref = _asyncToGenerator(function* ({ isLogin, openLoginModal, isFormSubject, utils, accountLists, appointmentBooking, getHolders }) {
		if (!isLogin) {
			openLoginModal({ callback: (status) => {
				if (status === "success") {}
			} });
			return false;
		}
		return true;
	});
	return function checkLogin(_x) {
		return _ref.apply(this, arguments);
	};
}();
/**
* @title: 添加holder
* @description: 
* @param {any} res
* @param {any} bookingSubject
* @param {any} accountLists
* @param {any} e
* @return {*}
* @Author: WangHan
* @Date: 2025-05-10 18:25
*/
const handleAddHolder = function() {
	var _ref2 = _asyncToGenerator(function* ({ res, bookingSubject, accountLists, cartItem, getHolders, appointmentBooking }) {
		try {
			var _res$values;
			let result = void 0;
			const currentForm = ((res === null || res === void 0 || (_res$values = res.values) === null || _res$values === void 0 ? void 0 : _res$values.form_to_form_value) || []).find((item) => item.form_id === (bookingSubject === null || bookingSubject === void 0 ? void 0 : bookingSubject.form_id));
			const form_record_id = Math.max(...(currentForm === null || currentForm === void 0 ? void 0 : currentForm.form_data_value) || []);
			const oldAccount = accountLists.find((item) => item.id === form_record_id);
			yield getHolders();
			const newAccountLists = yield appointmentBooking.getAccounts();
			if (oldAccount) result = !(cartItem === null || cartItem === void 0 ? void 0 : cartItem.holder_id) ? _objectSpread2({}, accountLists === null || accountLists === void 0 ? void 0 : accountLists[0]) : void 0;
			else result = _objectSpread2({}, newAccountLists.find((item) => item.id === form_record_id) || (newAccountLists === null || newAccountLists === void 0 ? void 0 : newAccountLists[0]));
			return result;
		} catch (error) {}
	});
	return function handleAddHolder(_x2) {
		return _ref2.apply(this, arguments);
	};
}();
//#endregion
export { checkLogin, handleAddHolder };
