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/PaymentMethods/StripePay/Stripe/index.tsx
var Stripe_exports = {};
__export(Stripe_exports, {
  default: () => Stripe_default
});
module.exports = __toCommonJS(Stripe_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_StripeSDK = __toESM(require("./StripeSDK"));
var import_SetupForm = __toESM(require("./components/SetupForm"));
var import_PageLoading = __toESM(require("./components/PageLoading"));
var import_serve = require("./serve");
var import_index_module = require("./index.module.less");
var StripePayment = () => {
  const [loading, setLoading] = (0, import_react.useState)(true);
  const [stripeConfig, setStripeConfig] = (0, import_react.useState)({});
  const [props, setProps] = (0, import_react.useState)(0);
  const init = async (props2) => {
    setProps(props2);
    setLoading(true);
    const { data } = await (0, import_serve.getStripeConfig)(props2.order_id);
    setStripeConfig(data);
    listenerLoad();
  };
  const setupFormReady = () => {
    setLoading(false);
  };
  const listenerLoad = () => {
    setTimeout(() => {
      if (loading) {
        import_antd.message.error("Stripe加载失败, 请刷新页面重试");
      }
    }, 30 * 1e3);
  };
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "stripe-payment-page" }, loading ? /* @__PURE__ */ import_react.default.createElement(import_PageLoading.default, null) : null, /* @__PURE__ */ import_react.default.createElement(
    import_StripeSDK.default,
    {
      public_key: stripeConfig.publishable_key,
      client_secret: stripeConfig.payment_intent_client_secret
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_SetupForm.default,
      {
        onReady: setupFormReady,
        amount: stripeConfig.pay_amount,
        order_id: props.order_id,
        payment_method: props.payment_method,
        scene: props.scene
      }
    )
  ));
};
var Stripe_default = StripePayment;
