const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_hooks = require("../../hooks.js");
const require_context = require("../../context.js");
const require_index = require("../Cart/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
let src_components_appointmentBooking_assets_shopping_cart_svg = require("../../../appointmentBooking/assets/shopping-cart.svg");
src_components_appointmentBooking_assets_shopping_cart_svg = require_runtime.__toESM(src_components_appointmentBooking_assets_shopping_cart_svg);
require("./index.less");
//#region src/components/venueBooking/components/Footer/index.tsx
/**
* venueBooking 移动端底栏
* 参照 scanOrder/Footer 实现：总价显示 + Badge 购物车按钮 + 操作按钮
* 购物车抽屉（Cart drawer）由此组件内部管理状态
*/
function Footer() {
	var _viewModel$cartItems;
	const symbol = require_hooks.useVenueBookingSymbol();
	const { currentStep, viewModel, handlePrimaryAction, isSubmittingOrder } = require_context.useVenueBookingContext();
	const [cartOpen, setCartOpen] = (0, react.useState)(false);
	/** 从 OS summary 中提取总金额 */
	const totalAmount = (0, react.useMemo)(() => {
		var _ref, _ref2, _ref3, _ref4, _ref5, _viewModel$summary$to, _viewModel$summary, _viewModel$summary2, _viewModel$summary3, _viewModel$summary4, _viewModel$summary5, _viewModel$summary6;
		const rawAmount = (_ref = (_ref2 = (_ref3 = (_ref4 = (_ref5 = (_viewModel$summary$to = (_viewModel$summary = viewModel.summary) === null || _viewModel$summary === void 0 ? void 0 : _viewModel$summary.total_amount) !== null && _viewModel$summary$to !== void 0 ? _viewModel$summary$to : (_viewModel$summary2 = viewModel.summary) === null || _viewModel$summary2 === void 0 ? void 0 : _viewModel$summary2.expect_amount) !== null && _ref5 !== void 0 ? _ref5 : (_viewModel$summary3 = viewModel.summary) === null || _viewModel$summary3 === void 0 ? void 0 : _viewModel$summary3.amount) !== null && _ref4 !== void 0 ? _ref4 : (_viewModel$summary4 = viewModel.summary) === null || _viewModel$summary4 === void 0 ? void 0 : _viewModel$summary4.total) !== null && _ref3 !== void 0 ? _ref3 : (_viewModel$summary5 = viewModel.summary) === null || _viewModel$summary5 === void 0 ? void 0 : _viewModel$summary5.totalAmount) !== null && _ref2 !== void 0 ? _ref2 : (_viewModel$summary6 = viewModel.summary) === null || _viewModel$summary6 === void 0 ? void 0 : _viewModel$summary6.payable_amount) !== null && _ref !== void 0 ? _ref : 0;
		const parsedAmount = Number(rawAmount);
		if (Number.isNaN(parsedAmount)) return "0.00";
		return parsedAmount.toFixed(2);
	}, [viewModel.summary]);
	/** 操作按钮文案：最后一步显示"立即支付"，其余步骤统一显示"下一步" */
	const actionText = (0, react.useMemo)(() => currentStep === "checkout" ? String(_pisell_utils.locales.getText("pisell2.venue.action.pay.now") || "立即支付") : String(_pisell_utils.locales.getText("pisell2.venue.action.next") || "下一步"), [currentStep]);
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-venue-booking-footer" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-venue-booking-footer-left" }, /* @__PURE__ */ react.default.createElement("div", { className: "pisell-venue-booking-footer-total-label" }, _pisell_utils.locales.getText("pisell2.event.total") || "合计"), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-venue-booking-footer-total-amount" }, symbol, totalAmount)), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-venue-booking-footer-right" }, /* @__PURE__ */ react.default.createElement(_pisell_materials.Badge, {
		count: ((_viewModel$cartItems = viewModel.cartItems) === null || _viewModel$cartItems === void 0 ? void 0 : _viewModel$cartItems.length) || 0,
		id: "venue-booking-cart-btn"
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		size: "large",
		className: "pisell-venue-booking-footer-cart-btn",
		onClick: () => setCartOpen(true)
	}, /* @__PURE__ */ react.default.createElement(_pisell_materials.Image, {
		src: src_components_appointmentBooking_assets_shopping_cart_svg.default,
		preview: false
	}))), /* @__PURE__ */ react.default.createElement(_pisell_materials.Button, {
		type: "primary",
		size: "large",
		className: "pisell-venue-booking-footer-btn",
		onClick: handlePrimaryAction,
		loading: isSubmittingOrder
	}, actionText))), /* @__PURE__ */ react.default.createElement(require_index.default, {
		open: cartOpen,
		items: viewModel.cartItems || [],
		summary: viewModel.summary || {},
		onCancel: () => setCartOpen(false),
		onNext: () => {
			setCartOpen(false);
			handlePrimaryAction();
		},
		confirmLoading: isSubmittingOrder
	}));
}
//#endregion
exports.default = Footer;
