import { _objectSpread2 } from "../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js";
import useEngineContext from "../../../../hooks/useEngineContext.js";
import AuthWrap from "../authWrap/index.js";
import VoucherCard from "../voucher/index.js";
import ActionButtons from "../actionButtons/index.js";
import React, { useMemo } from "react";
import { Skeleton } from "antd";
import classNames from "classnames";
import "./index.less";
//#region src/components/booking/components/tabPane/index.tsx
const TabPane = ({ children, header, footer, style, loading, bodyClassName, state, dispatch, source }) => {
	var _context$appHelper, _businessUtils$getApp, _businessUtils$getApp2, _state$service, _state$addons, _state$client;
	const { businessUtils } = ((_context$appHelper = useEngineContext().appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	const hasGoodPassApp = !!(businessUtils === null || businessUtils === void 0 || (_businessUtils$getApp = businessUtils.getAppByModal) === null || _businessUtils$getApp === void 0 ? void 0 : _businessUtils$getApp.call(businessUtils, "goodpass"));
	const hasDiscountCardApp = !!(businessUtils === null || businessUtils === void 0 || (_businessUtils$getApp2 = businessUtils.getAppByModal) === null || _businessUtils$getApp2 === void 0 ? void 0 : _businessUtils$getApp2.call(businessUtils, "discountcard"));
	const paymentRefundedStatus = useMemo(() => {
		var _state$bookingDetail;
		return ["partially_refunded", "refunded"].includes(state === null || state === void 0 || (_state$bookingDetail = state.bookingDetail) === null || _state$bookingDetail === void 0 ? void 0 : _state$bookingDetail.payment_status);
	}, [state === null || state === void 0 ? void 0 : state.bookingDetail]);
	const voucherBaseCondition = (hasGoodPassApp || hasDiscountCardApp) && ["addons", "info"].includes(source) && !paymentRefundedStatus;
	voucherBaseCondition && (state === null || state === void 0 || state.isBookingTicket2);
	const shouldShowFooterVoucher = voucherBaseCondition && !(state === null || state === void 0 ? void 0 : state.isBookingTicket2);
	return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
		className: "pisell-lowcode__booking-tab-pane-wrap",
		style
	}, /* @__PURE__ */ React.createElement("div", { className: typeof header === "string" ? "pisell-lowcode__booking-tab-pane-title" : "" }, header), /* @__PURE__ */ React.createElement("div", { className: classNames("pisell-lowcode__booking-tab-pane-body", bodyClassName) }, /* @__PURE__ */ React.createElement(Skeleton, {
		loading,
		round: true,
		active: true,
		avatar: false,
		style: { padding: 20 }
	}, children)), state && dispatch && (state === null || state === void 0 ? void 0 : state.isBookingTicket2) && /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-tab-pane-voucher-section" }, /* @__PURE__ */ React.createElement(ActionButtons, {
		state,
		dispatch
	})), /* @__PURE__ */ React.createElement(AuthWrap, {
		show: !!footer || shouldShowFooterVoucher,
		trueRender: /* @__PURE__ */ React.createElement("div", { className: "pisell-lowcode__booking-tab-pane-footer" }, shouldShowFooterVoucher && state && dispatch && /* @__PURE__ */ React.createElement(VoucherCard, {
			state: _objectSpread2(_objectSpread2({}, state), {}, {
				service: _objectSpread2(_objectSpread2({}, state.service || {}), {}, { value: ((_state$service = state.service) === null || _state$service === void 0 ? void 0 : _state$service.value) || [] }),
				addons: _objectSpread2(_objectSpread2({}, state.addons || {}), {}, { value: ((_state$addons = state.addons) === null || _state$addons === void 0 ? void 0 : _state$addons.value) || [] }),
				client: _objectSpread2(_objectSpread2({}, state.client || {}), {}, { value: ((_state$client = state.client) === null || _state$client === void 0 ? void 0 : _state$client.value) || {} })
			}),
			dispatch,
			source
		}), footer)
	})));
};
//#endregion
export { TabPane as default };
