var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pay/toC/index.tsx
var toC_exports = {};
__export(toC_exports, {
  default: () => toC_default
});
module.exports = __toCommonJS(toC_exports);
var import_react = __toESM(require("react"));
var import_decimal = require("decimal.js");
var import_ahooks = require("ahooks");
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_PayCountdown = __toESM(require("./PayCountdown"));
var import_PayAmount = __toESM(require("./PayAmount"));
var import_WalletPassBlock = __toESM(require("./WalletPassBlock"));
var import_PaymentList = __toESM(require("./PaymentList"));
var import_PaymentMethods = __toESM(require("./PaymentMethods"));
var import_serve = require("./serve");
var import_model = require("./model");
var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
var import_usePaymentLogger = __toESM(require("../../../hooks/usePaymentLogger"));
var import_utils2 = require("../../../utils");
var import_payGroup = require("./payGroup");
var import_locales = __toESM(require("./locales"));
var import_utils3 = require("./utils");
var import_status = require("./status");
var import_index = require("./index.less");
var ToCPay = (props, ref) => {
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
  const { state, dispatch } = (0, import_react.useContext)(import_model.Context);
  const paymentListRef = (0, import_react.useRef)();
  const paymentMethodsRef = (0, import_react.useRef)();
  const [loading, setLoading] = (0, import_react.useState)(true);
  const [submitLoading, setSubmitLoading] = (0, import_react.useState)(false);
  const [open, setOpen] = (0, import_react.useState)(false);
  const [renderType, setRenderType] = (0, import_react.useState)("modal");
  const walletPassBlockRef = (0, import_react.useRef)(null);
  const context = (0, import_useEngineContext.default)();
  const paymentLogger = (0, import_usePaymentLogger.default)({
    orderId: ((_a = state.payGroup) == null ? void 0 : _a.order_id) || "unknown",
    step: "1"
  });
  const [showInformation, setShowInformation] = (0, import_react.useState)(false);
  const [showDetectIncognitoConfirm, setShowDetectIncognitoConfirm] = (0, import_react.useState)(false);
  const [showPendingPayment, setShowPendingPayment] = (0, import_react.useState)(false);
  const utils = context.appHelper.utils || {};
  const dvaStore = (_d = (_c = (_b = context.appHelper.utils) == null ? void 0 : _b.getStore) == null ? void 0 : _c.call(_b)) == null ? void 0 : _d.getState();
  const customer_id = (_j = (_i = (_h = (_g = (_f = (_e = context.appHelper.utils) == null ? void 0 : _e.getStore()) == null ? void 0 : _f.getState) == null ? void 0 : _g.call(_f)) == null ? void 0 : _h.global) == null ? void 0 : _i.userInfo) == null ? void 0 : _j.id;
  const shopName = (_m = (_l = (_k = dvaStore.core) == null ? void 0 : _k.core) == null ? void 0 : _l.shop) == null ? void 0 : _m.name;
  import_utils.locales.init(import_locales.default, ((_n = dvaStore.core) == null ? void 0 : _n.translateLocale) || "en");
  import_utils2.request.setRequest(utils == null ? void 0 : utils.request);
  const _initStore = (initProps) => {
    var _a2;
    dispatch({
      type: "init",
      payload: {
        ...initProps,
        status: "init",
        // 将支付回调储存在store, 方便其他模块调用
        payCallback,
        history: (_a2 = context.appHelper.utils) == null ? void 0 : _a2.history,
        front_order_uuid: (0, import_utils.getUniqueId)("front_order_uuid_")
        // 支付组
        // payGroup: {
        //   order_id: initProps?.order?.order_id,
        //   total_amount: initProps?.order?.amount,
        //   // 原订单信息
        //   _order: initProps?.order,
        //   payment_group_id: initProps?.order?.payment_group_id,
        // },
      }
    });
  };
  const getWalletSetting = async (initProps) => {
    var _a2, _b2;
    let sale_channel = ((_a2 = initProps == null ? void 0 : initProps.order) == null ? void 0 : _a2.sale_channel) || "online-store";
    sale_channel = import_status.saleChannelMap[sale_channel] || sale_channel;
    const { wallet, wallet_setting } = await (0, import_serve.getWalletNameAndPopupStatus)({
      setting_type: `${sale_channel}-wallet-setting`
    });
    const setting = {
      name: ((_b2 = utils == null ? void 0 : utils.translation) == null ? void 0 : _b2.call(utils, wallet == null ? void 0 : wallet.name)) || import_utils.locales.getText("tocPay.text.walletName")(shopName),
      popup_status: (wallet_setting == null ? void 0 : wallet_setting.popup_status) ?? 1
    };
    if (setting.popup_status === 1) {
      setTimeout(() => {
        var _a3;
        (_a3 = walletPassBlockRef.current) == null ? void 0 : _a3.open();
      });
    }
    dispatch({
      type: "setWalletSetting",
      payload: setting
    });
  };
  const init = async (initProps) => {
    var _a2, _b2, _c2;
    const { renderType: renderType2 } = initProps;
    paymentLogger.addLog({
      key: "初始化开始",
      value: ``
    });
    try {
      setRenderType(renderType2 ?? "modal");
      setOpen(true);
      setSubmitLoading(false);
      setLoading(true);
      const { has_pending } = await (0, import_serve.checkPendingPayment)({
        order_id: (_a2 = initProps.order) == null ? void 0 : _a2.order_id
      });
      if (has_pending) {
        paymentLogger.addLog({
          key: "检测到处理中的交易",
          value: `订单${(_b2 = initProps.order) == null ? void 0 : _b2.order_id} 存在处理中的交易，中断支付流程`
        });
        setLoading(false);
        setShowPendingPayment(true);
        return;
      }
      _initStore(initProps);
      (0, import_payGroup.removePayGroupFromStorage)(initProps.order.order_id);
      await _getPaymentsAndWalletPass(initProps.order);
      await getWalletSetting(initProps);
      paymentLogger.addLog({
        key: "初始化成功",
        value: ``
      });
    } catch (error) {
      paymentLogger.addLog({
        key: "初始化错误",
        value: {
          title: `订单${(_c2 = initProps == null ? void 0 : initProps.order) == null ? void 0 : _c2.order_id} 初始化失败: ${(error == null ? void 0 : error.message) || "未知错误"}`,
          data: {
            order: initProps == null ? void 0 : initProps.order
          }
        }
      });
      paymentLogger.sendLogs("支付初始化失败", error);
      setOpen(false);
      setLoading(false);
      throw error;
    }
  };
  const _getPaymentsAndWalletPass = async (order) => {
    var _a2, _b2;
    paymentLogger.addLog({
      key: "获取支付列表开始",
      value: {
        title: `订单${order == null ? void 0 : order.order_id} 开始获取支付列表, 金额: ${order == null ? void 0 : order.amount}`
      }
    });
    try {
      const data = await (0, import_serve.getPaymentsAndWalletPass)({
        order_id: order.order_id,
        total_amount: order.amount,
        sale_channel: order.sale_channel || "online-store"
      });
      const {
        remain_amount = 0,
        wallet_pass_recommend_list,
        wallet_pass_amount,
        payment_list,
        walletPass
      } = data || {};
      paymentLogger.addLog({
        key: "支付数据获取",
        value: ""
      });
      const withCustomerIdList = (wallet_pass_recommend_list || []).map(
        (item) => {
          return {
            ...item,
            customer_id: customer_id || item.customer_id,
            metadata: {
              ...item.metadata || {},
              unique_payment_number: (0, import_utils.getUniqueId)()
            }
          };
        }
      );
      dispatch({
        type: "setPayGroup",
        payload: {
          // ...state.payGroup,
          order_id: order == null ? void 0 : order.order_id,
          // total_amount: order?.amount,
          // 原订单信息
          _order: order,
          payment_group_id: order == null ? void 0 : order.payment_group_id,
          // 支付方式没有walletPass时walletPass设置null
          walletPass: walletPass ? {
            ...(_a2 = state.payGroup) == null ? void 0 : _a2.walletPass,
            ...walletPass,
            amount: wallet_pass_amount,
            cards: withCustomerIdList
          } : null,
          total_amount: order == null ? void 0 : order.amount,
          wait_amount: remain_amount
        }
      });
      await ((_b2 = paymentListRef.current) == null ? void 0 : _b2.init(payment_list, remain_amount || 0));
      setTimeout(() => {
        setLoading(false);
      }, 100);
      paymentLogger.addLog({
        key: "获取支付列表成功",
        value: ""
      });
    } catch (err) {
      console.log("err", err);
      paymentLogger.addLog({
        key: "获取支付列表错误",
        value: {
          title: `订单${order == null ? void 0 : order.order_id} 获取失败: ${(err == null ? void 0 : err.message) || "未知错误"}`,
          data: {
            order
          }
        }
      });
      paymentLogger.sendLogs("获取支付列表失败", err);
      payCallback({
        key: "fail",
        data: {
          err,
          order,
          fn: "_getPaymentsAndWalletPass"
        }
      });
    }
  };
  const handlePaymentByType = async (type, payGroup) => {
    var _a2, _b2, _c2;
    const paymentType = type || ((_b2 = (_a2 = state.payGroup) == null ? void 0 : _a2.otherPayment) == null ? void 0 : _b2.service);
    const currentPayGroup = payGroup || state.payGroup;
    paymentLogger.addLog({
      key: "开始支付处理",
      value: ""
    });
    try {
      setSubmitLoading(true);
      await ((_c2 = paymentMethodsRef.current) == null ? void 0 : _c2.onPay({
        type: paymentType,
        payGroup: currentPayGroup
      }));
      paymentLogger.addLog({
        key: "支付方法调用成功",
        value: ""
      });
      paymentLogger.sendLogs("支付方法调用成功");
      setSubmitLoading(false);
    } catch (error) {
      paymentLogger.addLog({
        key: "支付处理错误",
        value: {
          title: `订单${currentPayGroup == null ? void 0 : currentPayGroup.order_id} ${paymentType}支付失败: ${(error == null ? void 0 : error.message) || "未知错误"}`,
          data: {
            type: paymentType,
            payGroup: currentPayGroup
          }
        }
      });
      paymentLogger.sendLogs("支付处理失败", error);
      setSubmitLoading(false);
      throw error;
    }
  };
  const paymentInit = async (newOrderId) => {
    var _a2, _b2;
    const orderId = newOrderId || ((_a2 = state.payGroup) == null ? void 0 : _a2.order_id);
    paymentLogger.addLog({
      key: "开始创建交易组",
      value: ""
    });
    setSubmitLoading(true);
    try {
      const data = await (0, import_serve.getPaymentInit)({
        order_id: orderId,
        amount: (_b2 = state.payGroup) == null ? void 0 : _b2.total_amount
      });
      dispatch({
        type: "setPayGroup",
        payload: {
          order_id: orderId,
          total_amount: data.amount,
          payment_group_id: data.payment_group_id,
          payment_priority: data.payment_priority
        }
      });
      paymentLogger.addLog({
        key: "创建交易组成功",
        value: ""
      });
      return {
        ...state.payGroup,
        order_id: orderId,
        total_amount: data.amount,
        payment_group_id: data.payment_group_id,
        payment_priority: data.payment_priority
      };
    } catch (err) {
      paymentLogger.addLog({
        key: "创建交易组错误",
        value: {
          title: `订单${orderId} 创建交易组失败: ${(err == null ? void 0 : err.message) || "未知错误"}`,
          data: {
            order: orderId
          }
        }
      });
      paymentLogger.sendLogs("创建交易组失败", err);
      setSubmitLoading(false);
      payCallback({
        key: "fail",
        data: {
          err,
          orderId,
          fn: "paymentInit"
        }
      });
      throw err;
    }
  };
  const waitAmount = (0, import_react.useMemo)(() => {
    var _a2;
    return ((_a2 = state.payGroup) == null ? void 0 : _a2.wait_amount) || 0;
  }, [(_o = state.payGroup) == null ? void 0 : _o.wait_amount]);
  const isWalletPassPay = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2;
    const isWalletPass = (_c2 = (_b2 = (_a2 = state.payGroup) == null ? void 0 : _a2.walletPass) == null ? void 0 : _b2.cards) == null ? void 0 : _c2.length;
    return waitAmount <= 0 && isWalletPass;
  }, [state.payGroup, waitAmount]);
  const isDisabled = (0, import_react.useMemo)(() => {
    var _a2, _b2;
    if (waitAmount > 0) {
      const isOtherPayment = (_b2 = (_a2 = state.payGroup) == null ? void 0 : _a2.otherPayment) == null ? void 0 : _b2.service;
      return !isOtherPayment;
    } else {
      return !isWalletPassPay;
    }
  }, [state.payGroup, waitAmount, isWalletPassPay]);
  const getIsShowDetectIncognitoConfirm = async (payGroup) => {
    const { isPrivate } = await (0, import_utils.detectIncognito)();
    return ((payGroup == null ? void 0 : payGroup.wait_amount) || 0) > 0 && (0, import_utils3.getIsWalletPassAndTripartitePayment)(payGroup) && isPrivate;
  };
  const onSubmit = async (newOrderId) => {
    var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
    paymentLogger.addLog({
      key: "开始提交支付",
      value: `订单${newOrderId || ((_a2 = state.payGroup) == null ? void 0 : _a2.order_id)} 开始提交, 待支付: ${(_b2 = state.payGroup) == null ? void 0 : _b2.wait_amount}, 总金额: ${(_c2 = state.payGroup) == null ? void 0 : _c2.total_amount}`
    });
    let newPayGroup = state.payGroup;
    try {
      const result = await getIsShowDetectIncognitoConfirm(newPayGroup);
      if (result) {
        paymentLogger.addLog({
          key: "无痕模式检测",
          value: ""
        });
        setShowDetectIncognitoConfirm(true);
        return;
      }
      if (!((_d2 = state.payGroup) == null ? void 0 : _d2.payment_group_id)) {
        paymentLogger.addLog({
          key: "需要创建交易组",
          value: ""
        });
        newPayGroup = await paymentInit(newOrderId);
      }
      paymentLogger.addLog({
        key: "调用支付方法",
        value: `订单${newPayGroup == null ? void 0 : newPayGroup.order_id} 交易组${newPayGroup == null ? void 0 : newPayGroup.payment_group_id} 使用${(_f2 = (_e2 = state.payGroup) == null ? void 0 : _e2.otherPayment) == null ? void 0 : _f2.service}支付`
      });
      handlePaymentByType(void 0, newPayGroup);
      paymentLogger.addLog({
        key: "支付提交调用成功",
        value: ""
      });
    } catch (err) {
      console.log("err", err);
      paymentLogger.addLog({
        key: "提交支付错误",
        value: {
          title: `订单${newOrderId || ((_g2 = state.payGroup) == null ? void 0 : _g2.order_id)} 提交失败: ${(err == null ? void 0 : err.message) || "未知错误"}`,
          data: {
            newPayGroup
          }
        }
      });
      paymentLogger.sendLogs("提交支付失败", err);
    }
  };
  const paymentTypeChange = (payload) => {
    dispatch({
      type: "setPayGroup",
      payload: {
        otherPayment: payload
      }
    });
  };
  const okText = (0, import_react.useMemo)(() => {
    var _a2, _b2, _c2, _d2;
    let current = (_a2 = state.payGroup) == null ? void 0 : _a2.otherPayment;
    if (((_b2 = state.payGroup) == null ? void 0 : _b2.wait_amount) == 0) {
      return import_utils.locales.getText("tocPay.text.submit");
    }
    if (current == null ? void 0 : current.surcharge) {
      return /* @__PURE__ */ import_react.default.createElement("span", { className: "" }, import_utils.locales.getText("tocPay.text.pay"), " ", /* @__PURE__ */ import_react.default.createElement(import_materials.PisellText.Amount, { value: ((_c2 = state.payGroup) == null ? void 0 : _c2.wait_amount) || 0 }), " +", import_utils.locales.getText("tocPay.text.surcharge"));
    } else {
      return /* @__PURE__ */ import_react.default.createElement("span", { className: "" }, import_utils.locales.getText("tocPay.text.pay"), " ", /* @__PURE__ */ import_react.default.createElement(import_materials.PisellText.Amount, { value: ((_d2 = state.payGroup) == null ? void 0 : _d2.wait_amount) || 0 }));
    }
  }, [state.payGroup]);
  const payCallback = async (res) => {
    var _a2, _b2, _c2, _d2;
    const orderId = ((_a2 = res == null ? void 0 : res.data) == null ? void 0 : _a2.order_id) || ((_b2 = state.payGroup) == null ? void 0 : _b2.order_id);
    if (res.key === "success") {
      paymentLogger.addLog({
        key: "支付最终成功",
        value: `订单${orderId} 支付成功`
      });
      paymentLogger.sendLogs("支付成功");
    } else if (res.key === "fail") {
      paymentLogger.addLog({
        key: "支付最终失败",
        value: {
          title: `订单${orderId} 支付失败`,
          data: res == null ? void 0 : res.data
        }
      });
      paymentLogger.sendLogs("支付失败", (_c2 = res == null ? void 0 : res.data) == null ? void 0 : _c2.err);
    } else if (res.key === "cancel") {
      paymentLogger.addLog({
        key: "支付被取消",
        value: `订单${orderId} 支付被取消`
      });
      setOpen(false);
    }
    (_d2 = props.callback) == null ? void 0 : _d2.call(props, res);
  };
  const onCancel = () => {
    var _a2, _b2, _c2;
    paymentLogger.addLog({
      key: "用户主动取消支付",
      value: `订单${(_a2 = state.payGroup) == null ? void 0 : _a2.order_id} 用户取消支付`
    });
    (0, import_payGroup.removePayGroupFromStorage)((_b2 = state.payGroup) == null ? void 0 : _b2.order_id);
    setShowInformation(false);
    setOpen(false);
    payCallback({
      key: "cancel",
      data: {
        order_id: (_c2 = state.payGroup) == null ? void 0 : _c2.order_id
      }
    });
  };
  (0, import_ahooks.useUpdateEffect)(() => {
    var _a2, _b2;
    (_b2 = paymentListRef.current) == null ? void 0 : _b2.calculateSurcharge(
      ((_a2 = state.payGroup) == null ? void 0 : _a2.wait_amount) || 0
    );
  }, [(_p = state.payGroup) == null ? void 0 : _p.wait_amount]);
  (0, import_react.useImperativeHandle)(ref, () => {
    return {
      init,
      payCallback,
      onSubmit
    };
  });
  const renderPaymentListTitle = () => {
    var _a2, _b2;
    if (waitAmount == 0) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "custom-payment-list-title" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "" }, import_utils.locales.getText("tocPay.text.clickSubmitToComplete")), /* @__PURE__ */ import_react.default.createElement("div", { className: "custom-payment-list-title-desc" }, import_utils.locales.getText("tocPay.text.noExtraPayNeeded")));
    }
    if (((_a2 = state.payGroup) == null ? void 0 : _a2.total_amount) !== waitAmount) {
      return /* @__PURE__ */ import_react.default.createElement("div", { className: "custom-payment-list-title" }, import_utils.locales.getText("tocPay.text.continuePayment"), " ", /* @__PURE__ */ import_react.default.createElement(
        import_materials.PisellText.Amount,
        {
          className: "custom-payment-list-title-price",
          value: ((_b2 = state.payGroup) == null ? void 0 : _b2.wait_amount) || 0
        }
      ));
    }
    return import_utils.locales.getText("tocPay.text.paymentMethod");
  };
  const onWalletPassChange = (0, import_ahooks.useMemoizedFn)(
    (walletPass) => {
      var _a2, _b2;
      const _waitAmount = new import_decimal.Decimal(String(((_a2 = state.payGroup) == null ? void 0 : _a2.total_amount) || 0)).minus(new import_decimal.Decimal(String(walletPass.amount || 0))).toNumber();
      dispatch({
        type: "setPayGroup",
        payload: {
          walletPass: {
            ...(_b2 = state.payGroup) == null ? void 0 : _b2.walletPass,
            ...walletPass
          },
          wait_amount: _waitAmount
        }
      });
    }
  );
  return /* @__PURE__ */ import_react.default.createElement(
    import_materials.PisellContainer,
    {
      renderType,
      props: {
        forceRender: true,
        title: /* @__PURE__ */ import_react.default.createElement("div", null, import_utils.locales.getText("tocPay.text.checkout")),
        open,
        cancelVisible: false,
        okText,
        wrapClassName: "toc-pay-modal-content",
        bodyStyle: {
          padding: 24
        },
        onCancel: () => {
          setShowInformation(true);
        },
        okButtonProps: {
          disabled: isDisabled,
          loading: submitLoading,
          className: "toc-pay-submit-btn"
        },
        onOk: () => {
          onSubmit();
        }
      }
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellModal.Information,
      {
        open: showInformation,
        title: import_utils.locales.getText("tocPay.text.prompt"),
        describe: import_utils.locales.getText("tocPay.text.confirmLeave"),
        okText: import_utils.locales.getText("tocPay.text.continuePay"),
        cancelText: import_utils.locales.getText("tocPay.text.leave"),
        closable: true,
        cancelButtonProps: {
          onClick: () => {
            onCancel();
          }
        },
        maskClosable: false,
        onCancel: () => {
          setShowInformation(false);
        },
        onOk: () => {
          setShowInformation(false);
        }
      }
    ),
    /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellModal.Information,
      {
        open: showPendingPayment,
        describe: import_utils.locales.getText("tocPay.text.pendingPaymentDesc"),
        okText: import_utils.locales.getText("tocPay.text.pendingPaymentOk"),
        cancelVisible: false,
        closable: false,
        maskClosable: false,
        onOk: () => {
          paymentLogger.sendLogs("此订单有一笔支付正在处理中");
          setShowPendingPayment(false);
          setOpen(false);
        }
      }
    ),
    /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellModal.Information,
      {
        open: showDetectIncognitoConfirm,
        describe: import_utils.locales.getText("tocPay.text.detectIncognitoConfirm"),
        okText: import_utils.locales.getText("tocPay.text.copyLink"),
        closable: true,
        maskClosable: false,
        onCancel: () => {
          setShowDetectIncognitoConfirm(false);
        },
        onOk: async () => {
          await (0, import_utils.copyToClipboard)(window.location.href);
          (0, import_materials.PisellToast)({
            content: import_utils.locales.getText("tocPay.text.copySuccess")
          });
        }
      }
    ),
    /* @__PURE__ */ import_react.default.createElement(
      import_materials.PisellLoading,
      {
        loading,
        mask: true
      },
      ((_q = state.order) == null ? void 0 : _q.countdown) && /* @__PURE__ */ import_react.default.createElement(import_PayCountdown.default, { time: (_r = state.order) == null ? void 0 : _r.countdown }),
      /* @__PURE__ */ import_react.default.createElement(import_PayAmount.default, { amount: ((_s = state.payGroup) == null ? void 0 : _s.total_amount) || 0 }),
      ((_t = state.payGroup) == null ? void 0 : _t.walletPass) && /* @__PURE__ */ import_react.default.createElement(
        import_WalletPassBlock.default,
        {
          customer_id,
          payGroup: state.payGroup,
          onWalletPassChange,
          ref: walletPassBlockRef,
          walletSetting: state.walletSetting
        }
      ),
      /* @__PURE__ */ import_react.default.createElement(
        import_PaymentList.default,
        {
          ref: paymentListRef,
          handlePayment: (detail) => {
            handlePaymentByType(detail == null ? void 0 : detail.service);
          },
          paymentTypeChange,
          hide: ((_u = state.payGroup) == null ? void 0 : _u.wait_amount) == 0,
          renderTitle: renderPaymentListTitle
        }
      )
    ),
    /* @__PURE__ */ import_react.default.createElement(import_PaymentMethods.default, { ref: paymentMethodsRef, payCallback })
  );
};
var toC_default = (0, import_model.Provider)((0, import_react.forwardRef)(ToCPay));
