import { _asyncToGenerator } from "../../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js";
import useEngineContext from "../../../../../hooks/useEngineContext.js";
import { useAppointmentBookingContext } from "../../../context.js";
import { useAppointmentBookingAccount, useAppointmentBookingLogin, useAppointmentBookingSetting } from "../../../hooks.js";
import { checkLogin } from "../utils.js";
import React, { useMemo } from "react";
import { locales } from "@pisell/utils";
import { Button } from "@pisell/materials";
import "./index.less";
//#region src/components/appointmentBooking/components/Cart/ContinueButton/index.tsx
const ContinueButton = ({ onNext }) => {
	var _appointmentBooking$s2;
	const utils = useEngineContext().appHelper.utils || {};
	const { isLogin, openLoginModal } = useAppointmentBookingLogin();
	const { accountLists, getHolders, checkAccount } = useAppointmentBookingAccount();
	const { currentStep, carts, appointmentBooking, setCarts, loading, setIsErrorHolder, isLastStep } = useAppointmentBookingContext();
	const { isFormSubject, isRetailTemplate } = useAppointmentBookingSetting();
	useMemo(() => {
		var _appointmentBooking$s;
		return appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$s = appointmentBooking.store) === null || _appointmentBooking$s === void 0 || (_appointmentBooking$s = _appointmentBooking$s.step) === null || _appointmentBooking$s === void 0 || (_appointmentBooking$s = _appointmentBooking$s.store) === null || _appointmentBooking$s === void 0 ? void 0 : _appointmentBooking$s.stepList;
	}, [appointmentBooking === null || appointmentBooking === void 0 || (_appointmentBooking$s2 = appointmentBooking.store) === null || _appointmentBooking$s2 === void 0 || (_appointmentBooking$s2 = _appointmentBooking$s2.step) === null || _appointmentBooking$s2 === void 0 || (_appointmentBooking$s2 = _appointmentBooking$s2.store) === null || _appointmentBooking$s2 === void 0 ? void 0 : _appointmentBooking$s2.stepList]);
	(function() {
		var _ref = _asyncToGenerator(function* () {
			return yield checkLogin({
				isLogin,
				openLoginModal,
				isFormSubject,
				utils,
				accountLists,
				appointmentBooking,
				getHolders
			});
		});
		return function handleLoginCheck() {
			return _ref.apply(this, arguments);
		};
	})();
	/**
	* @title: 点击继续
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-16 16:30
	*/
	const handleContinue = function() {
		var _ref2 = _asyncToGenerator(function* () {
			try {
				return onNext && onNext();
			} catch (error) {
				console.log(error, "handleContinue_error");
			}
		});
		return function handleContinue() {
			return _ref2.apply(this, arguments);
		};
	}();
	/**
	* @title: 确认按钮文案
	* @description:
	* @param {*} useMemo
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-17 16:10
	*/
	const continueText = useMemo(() => {
		if (isLastStep) return locales.getText("pisell2.event.checkout");
		else return locales.getText("pisell2.event.close.continue");
	}, [isLastStep]);
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Button, {
		disabled: !(carts === null || carts === void 0 ? void 0 : carts.length),
		size: "large",
		type: "primary",
		onClick: () => handleContinue(),
		loading
	}, continueText));
};
//#endregion
export { ContinueButton as default };
