const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_useLogger = require("../../../../hooks/useLogger.js");
const require_index = require("../components/EFTPOS/index.js");
const require_index$1 = require("../components/MX51/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
//#region src/components/pay/toB/paymentMethods/index.tsx
const _excluded = ["callback"];
const PaymentMethods = (props, ref) => {
	const eftposRef = (0, react.useRef)(null);
	const mx51Ref = (0, react.useRef)(null);
	const logger = require_useLogger.default();
	const onPay = (type, params) => {
		const { callback } = params, otherParams = require_objectWithoutProperties._objectWithoutProperties(params, _excluded);
		console.log("onPay_params>>>>", type, params);
		logger === null || logger === void 0 || logger.addLog({
			type: "info",
			title: "ToB_PaymentMethods_onPay 开始调用",
			metadata: {
				type,
				params
			}
		});
		if (type === "eftpos") {
			var _eftposRef$current, _eftposRef$current$op;
			(_eftposRef$current = eftposRef.current) === null || _eftposRef$current === void 0 || (_eftposRef$current$op = _eftposRef$current.open) === null || _eftposRef$current$op === void 0 || _eftposRef$current$op.call(_eftposRef$current, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, otherParams), {}, { payCallback: (res) => _eftpcallback(res, callback) }));
		} else if (type === "mx51") {
			var _mx51Ref$current, _mx51Ref$current$open;
			(_mx51Ref$current = mx51Ref.current) === null || _mx51Ref$current === void 0 || (_mx51Ref$current$open = _mx51Ref$current.open) === null || _mx51Ref$current$open === void 0 || _mx51Ref$current$open.call(_mx51Ref$current, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, otherParams), {}, { payCallback: (res) => _mx51callback(res, callback) }));
		}
	};
	const _eftpcallback = (res, callback) => {
		const params = {
			status: res.status,
			data: res.params
		};
		logger === null || logger === void 0 || logger.addLog({
			type: "info",
			title: "ToB_PaymentMethods_eftpos_callback",
			metadata: {
				res,
				params
			}
		});
		callback(params);
	};
	const _mx51callback = (res, callback) => {
		const params = {
			status: res.result ? "success" : "fail",
			data: {
				amount: res.amount,
				surcharge: res.surcharge,
				uniquePaymentNumber: res.uniquePaymentNumber
			},
			msg: res.msg
		};
		logger === null || logger === void 0 || logger.addLog({
			type: "info",
			title: "ToB_PaymentMethods_mx51_callback",
			metadata: {
				res,
				params
			}
		});
		callback(params);
	};
	(0, react.useImperativeHandle)(ref, () => ({ onPay }));
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(require_index.default, {
		ref: eftposRef,
		dynamicMaxHeight: props === null || props === void 0 ? void 0 : props.dynamicMaxHeight,
		isWebPos: props === null || props === void 0 ? void 0 : props.isWebPos
	}), /* @__PURE__ */ react.default.createElement(require_index$1.default, { ref: mx51Ref }));
};
var paymentMethods_default = (0, react.forwardRef)(PaymentMethods);
//#endregion
exports.default = paymentMethods_default;
