const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_const = require("../../const.js");
const require_index = require("../../store/index.js");
const require_payLog = require("../../utils/payLog.js");
const require_manufacturer = require("../../manufacturer.js");
const require_index$1 = require("../header/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let antd = require("antd");
let _pisell_utils = require("@pisell/utils");
let ahooks = require("ahooks");
let _pisell_icon_es_XClose = require("@pisell/icon/es/XClose");
_pisell_icon_es_XClose = require_runtime.__toESM(_pisell_icon_es_XClose);
//#region src/components/eftposPay/component/fail/failCustom.tsx
var failCustom_default = ({ className = "", isMobile, onChange }) => {
	const { eftpos, custom, mode, name, symbol, amount, order_id, number, device, client, originalParams } = require_index.useContextData();
	const failCustom = custom === null || custom === void 0 ? void 0 : custom.failCustom;
	const dispatch = require_index.useDispatch();
	/**
	* @title: 重新支付
	* @Author: hongbing.wang
	* @Date: 2024-08-20 11:30
	*/
	const onRetry = () => {
		require_payLog.default.log("自定义失败页：点击重试");
		onChange("page", "pay");
		const params = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, originalParams || {}), {}, {
			mode,
			name,
			symbol,
			amount,
			order_id,
			client
		});
		if (mode !== require_const.ModeEnum.Query) params.number = "";
		dispatch(require_index.updateState(require_manufacturer.getInitState(eftpos, params)));
	};
	/**
	* @title: 手动标记
	* @description: 前往手动标记
	* @return {*}
	* @Author: hongbing.wang
	* @Date: 2024-08-20 11:31
	*/
	const onManually = () => {
		require_payLog.default.log("自定义失败页：点击手动标记");
		dispatch(require_index.updateState({ manual: {
			title: _pisell_utils.locales.getText("page.eftpos-pay.text.request.unknown.title")(mode),
			text: _pisell_utils.locales.getText("page.eftpos-pay.text.request.unknown.text")(mode)
		} }));
		dispatch(require_index.updateComponent("Manual"));
	};
	const onNotin = () => {
		require_payLog.default.log("自定义失败页：点击打印小票");
		onChange("print", [], "print_on_timeout");
	};
	/**
	* @title: 关闭支付页面
	* @description: 交易关闭页面
	* @Author: hongbing.wang
	* @Date: 2024-08-20 11:32
	*/
	const onClose = () => {
		require_payLog.default.log("自定义失败页：关闭");
		onChange("fail", {
			number,
			uniquePaymentNumber: number,
			device,
			order_id
		});
	};
	(0, ahooks.useMount)(() => {
		require_payLog.default.log("自定义失败页展示", {
			status: failCustom === null || failCustom === void 0 ? void 0 : failCustom.status,
			client
		});
		if ((failCustom === null || failCustom === void 0 ? void 0 : failCustom.status) === "fail") onChange("page", "fail");
	});
	return /* @__PURE__ */ react.default.createElement("div", { className: `pisell-lowcode__eft-pay-box ${className}` }, /* @__PURE__ */ react.default.createElement(require_index$1.default, { status: failCustom.status }, (failCustom === null || failCustom === void 0 ? void 0 : failCustom.status) === "fail" && !isMobile ? /* @__PURE__ */ react.default.createElement(_pisell_icon_es_XClose.default, {
		size: 20,
		style: {
			fontSize: "24px",
			position: "absolute",
			top: 0,
			right: 0
		},
		onClick: onClose
	}) : null), /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-fail-title" }, failCustom.title || _pisell_utils.locales.getText("page.eftpos-pay.text.failed")(mode)), (failCustom === null || failCustom === void 0 ? void 0 : failCustom.status) === "fail" ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-fail-text pisell-lowcode__eft-pay-body" }, failCustom === null || failCustom === void 0 ? void 0 : failCustom.fail) : (failCustom === null || failCustom === void 0 ? void 0 : failCustom.status) === "warn" ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-warn-text pisell-lowcode__eft-pay-body" }, failCustom === null || failCustom === void 0 ? void 0 : failCustom.warn) : null, (failCustom === null || failCustom === void 0 ? void 0 : failCustom.isPosNetworkError) ? /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, client === require_const.ClientEnum.Merchant ? /* @__PURE__ */ react.default.createElement(antd.Button, {
		block: true,
		className: "pisell-lowcode__eft-pay-step-item-btn",
		onClick: onManually
	}, _pisell_utils.locales.getText("page.eftpos-pay.text.manual.marking")) : /* @__PURE__ */ react.default.createElement(antd.Button, {
		block: true,
		className: "pisell-lowcode__eft-pay-step-item-btn",
		onClick: onNotin
	}, _pisell_utils.locales.getText("page.eftpos-pay.text.manual.print_receipt"))) : /* @__PURE__ */ react.default.createElement("div", { className: "pisell-lowcode__eft-pay-step-item-btns" }, /* @__PURE__ */ react.default.createElement(antd.Button, {
		block: true,
		className: "pisell-lowcode__eft-pay-step-item-btn",
		onClick: onClose
	}, _pisell_utils.locales.getText("page.eftpos-pay.text.cancel")), /* @__PURE__ */ react.default.createElement(antd.Button, {
		block: true,
		type: "primary",
		className: "pisell-lowcode__eft-pay-step-item-btn",
		onClick: onRetry
	}, _pisell_utils.locales.getText("page.eftpos-pay.text.retry"))));
};
//#endregion
exports.default = failCustom_default;
