var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pay/toC/PaymentList/serve.ts
var serve_exports = {};
__export(serve_exports, {
  filterPaymentList: () => filterPaymentList,
  getPaymentList: () => getPaymentList
});
module.exports = __toCommonJS(serve_exports);
var import_utils = require("../../../../utils");
var import_status = require("./status");
var import_utils2 = require("@pisell/utils");
var import_status2 = require("./status");
var import_utils3 = require("./utils");
var getPaymentList = async (values) => {
  let { data = [] } = await import_utils.request.getRequest().get("/h5/pay/order/payments", values);
  return filterPaymentList(data);
};
var filterPaymentList = (list, platform = "h5", isApp, amount) => {
  let paymentList = [...list];
  let _paymentKeys = [...import_status.paymentKeys];
  const walletPass = paymentList.find((d) => d.service === "pisell.wallet_pass");
  let arr = [];
  if (!(0, import_utils2.isWx)() && !isApp) {
    arr = arr.concat(["globepay.wechat.jsapi", "superpay.wechat.h5"]);
  }
  if (platform === "h5") {
    arr = arr.concat(["globepay.wechat.qrcode", "globepay.alipay.qrcode"]);
  }
  if (!(0, import_utils2.isIOS)()) {
    arr = arr.concat(["mw.apple"]);
  }
  if ((0, import_utils2.isIOS)() && isApp) {
    arr = arr.concat(["mw.google"]);
  }
  _paymentKeys = _paymentKeys.filter((d) => !arr.includes(d));
  paymentList = paymentList.filter(
    (d) => _paymentKeys.includes(d.service)
  );
  if (paymentList.length === 0) {
    return {
      message: "该店铺暂未启用支付功能",
      // '该支付功能暂未启用',
      status: "error",
      paymentList: [],
      walletPass
    };
  }
  paymentList = paymentList.map((d) => {
    let _item = import_status2.paymentTypes.find((t) => t.service === d.service);
    let service = d.service;
    if ((0, import_status2.isCustomPayment)(d.service)) {
      service = service + "|" + d.params.custom_payment_id;
    }
    if (service === "mw.credit_card") {
      d.surcharge = (0, import_utils3.formatCreditCardSurchargeText)(d == null ? void 0 : d.surcharge_config, d == null ? void 0 : d.surcharge_text);
      d.surcharge_config_result = (0, import_utils3.formatCreditCardSurchargeList)(d, amount ?? 0);
    }
    return {
      ...d,
      service,
      title: d.name,
      url: _item == null ? void 0 : _item.url,
      imageStyle: _item == null ? void 0 : _item.imageStyle
    };
  });
  return {
    message: "",
    status: "ready",
    paymentList,
    walletPass
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  filterPaymentList,
  getPaymentList
});
