cppay-sdk 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -1,18 +1,18 @@
1
- import { t as cppay_default } from "./cppay-Db8t1Cra.js";
2
- import { n as injectStyle, r as payment_dialog_default, t as getLocaleMessages } from "./locales-CEspC4rh.js";
1
+ import { t as cppay_default } from "./cppay-CLtfZy7N.js";
2
+ import { n as injectStyle, r as payment_dialog_default, t as getLocaleMessages } from "./locales-lB47Gtma.js";
3
3
  import * as QRCode from "qrcode";
4
4
  import { EMPTY, defer, timer } from "rxjs";
5
5
  import { expand, retry, switchMap, tap, timeout } from "rxjs/operators";
6
- import { createWalletClient, custom, parseUnits } from "viem";
6
+ import { createWalletClient, custom, erc20Abi, parseUnits } from "viem";
7
7
  import { arbitrum, base, bsc, mainnet, optimism, polygon } from "viem/chains";
8
8
  import { createAppKit } from "@reown/appkit";
9
9
  import { EthersAdapter } from "@reown/appkit-adapter-ethers";
10
10
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
11
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
- var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount: d, intervalDays: f, remark: Se, locale: Ce, onSuccess: we, onExpired: Te, onFailed: Ee, onError: p, Slots: m, onPaymentStepChange: De }) => {
13
- let h = useMemo(() => new cppay_default(t, n), [t, n]), g = useMemo(() => getLocaleMessages(Ce), [Ce]), [_, v] = useState("select"), y = useMemo(() => _ === "checking", [_]), [b, x] = useState(!1), [S, C] = useState(), [w, Oe] = useState([]), [T, E] = useState(), [D, O] = useState(), [ke, k] = useState(), [A, j] = useState(), [Ae, je] = useState(!1), [M, N] = useState(), [Me, Ne] = useState(""), [P, F] = useState(!1), [Pe, I] = useState(!1), [L, R] = useState(""), z = useRef(null), B = useRef(null), V = useRef(null), H = useRef(null), U = useRef("");
12
+ var PaymentContent_default = ({ apikey: t, ott: n, plain: p, orderId: ye, amount: m, intervalDays: h, remark: be, locale: xe, onSuccess: Se, onExpired: Ce, onFailed: we, onError: g, Slots: _, onPaymentStepChange: Te }) => {
13
+ let v = useMemo(() => new cppay_default(t, n), [t, n]), y = useMemo(() => getLocaleMessages(xe), [xe]), [b, x] = useState("select"), S = useMemo(() => b === "checking", [b]), [C, w] = useState(!1), [T, E] = useState(), [D, Ee] = useState([]), [O, k] = useState(), [A, j] = useState(), [De, M] = useState(), [N, Oe] = useState(), [ke, Ae] = useState(!1), [P, F] = useState(), [je, Me] = useState(""), [I, L] = useState(!1), [Ne, R] = useState(!1), [z, B] = useState(""), V = useRef(null), H = useRef(null), U = useRef(null), W = useRef(null), G = useRef("");
14
14
  useEffect(() => {
15
- typeof window < "u" && !z.current && (z.current = createAppKit({
15
+ typeof window < "u" && !V.current && (V.current = createAppKit({
16
16
  debug: !1,
17
17
  enableNetworkSwitch: !1,
18
18
  adapters: [new EthersAdapter()],
@@ -33,24 +33,24 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
33
33
  icons: ["https://cppay.com/icon.png"]
34
34
  },
35
35
  features: { analytics: !1 }
36
- }), j(z.current.getAddress()), N(z.current.getProvider("eip155")), z.current.subscribeAccount((e) => {
37
- e.isConnected ? j(e.address) : (j(void 0), N(void 0));
38
- }), z.current.subscribeProviders((e) => {
36
+ }), Oe(V.current.getAddress()), F(V.current.getProvider("eip155")), V.current.subscribeAccount((e) => {
37
+ e.isConnected ? Oe(e.address) : (Oe(void 0), F(void 0));
38
+ }), V.current.subscribeProviders((e) => {
39
39
  let t = e?.eip155;
40
- N(t);
40
+ F(t);
41
41
  }));
42
42
  }, []), useEffect(() => {
43
- De?.(_);
44
- }, [_]);
45
- let Fe = async () => {
43
+ Te?.(b);
44
+ }, [b]);
45
+ let Pe = async () => {
46
46
  try {
47
- je(!0), C(void 0), z.current && await z.current.open();
47
+ Ae(!0), E(void 0), V.current && await V.current.open();
48
48
  } catch (e) {
49
- console.error("钱包连接失败:", e), C(e instanceof Error ? e.message : g.walletConnectionFailed), p?.(e);
49
+ console.error("钱包连接失败:", e), E(e instanceof Error ? e.message : y.walletConnectionFailed), g?.(e);
50
50
  } finally {
51
- je(!1);
51
+ Ae(!1);
52
52
  }
53
- }, W = useMemo(() => w.find((e) => e.chain === T), [w, T]), G = useMemo(() => W?.tokens || [], [W]), K = useMemo(() => G.find((e) => e.symbol === D), [G, D]), q = (e) => [
53
+ }, K = useMemo(() => D.find((e) => e.chain === O), [D, O]), q = useMemo(() => K?.tokens || [], [K]), J = useMemo(() => q.find((e) => e.symbol === A), [q, A]), Y = (e) => [
54
54
  "USDT",
55
55
  "USDC",
56
56
  "BUSD",
@@ -58,177 +58,161 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
58
58
  "TUSD",
59
59
  "USDD",
60
60
  "FDUSD"
61
- ].includes(e.toUpperCase()) ? 2 : 6, J = (e, t) => {
61
+ ].includes(e.toUpperCase()) ? 2 : 6, X = (e, t) => {
62
62
  let n = parseFloat(e);
63
63
  return isNaN(n) ? "0" : n.toFixed(t).replace(/\.?0+$/, "");
64
- }, Ie = (e) => {
65
- if (e <= 0) return g.expired;
64
+ }, Fe = (e) => {
65
+ if (e <= 0) return y.expired;
66
66
  let t = Math.floor(e / 3600), n = Math.floor(e % 3600 / 60), r = e % 60, i = (e) => e.toString().padStart(2, "0");
67
67
  return t > 0 ? `${t}:${i(n)}:${i(r)}` : `${n}:${i(r)}`;
68
- }, Y = (e) => {
69
- V.current && clearInterval(V.current);
68
+ }, Z = (e) => {
69
+ U.current && clearInterval(U.current);
70
70
  let t = () => {
71
- if (_ === "checking") {
72
- X();
71
+ if (b === "checking") {
72
+ Ie();
73
73
  return;
74
74
  }
75
75
  let t = e - Math.floor(Date.now() / 1e3);
76
- Ne(Ie(t)), t <= 0 && X();
76
+ Me(Fe(t)), t <= 0 && Ie();
77
77
  };
78
- t(), V.current = setInterval(t, 1e3);
79
- }, X = () => {
80
- V.current &&= (clearInterval(V.current), null);
81
- }, Z = useMemo(() => {
82
- if (!D || !K) return "0";
83
- let e = parseFloat(K.price);
78
+ t(), U.current = setInterval(t, 1e3);
79
+ }, Ie = () => {
80
+ U.current &&= (clearInterval(U.current), null);
81
+ }, Le = useMemo(() => {
82
+ if (!A || !J) return "0";
83
+ let e = parseFloat(J.price);
84
84
  if (isNaN(e) || e === 0) return "0";
85
- let t = q(D);
86
- return J((parseFloat(d) / e).toFixed(t), t);
85
+ let t = Y(A);
86
+ return X((parseFloat(m) / e).toFixed(t), t);
87
87
  }, [
88
- d,
89
- D,
90
- K
91
- ]), Le = async () => {
88
+ m,
89
+ A,
90
+ J
91
+ ]), Re = async () => {
92
92
  try {
93
- x(!0), C(void 0);
94
- let e = await h.getSupportedChains();
95
- Oe(e), e.length > 0 && E(e[0].chain);
93
+ w(!0), E(void 0);
94
+ let e = await v.getSupportedChains();
95
+ Ee(e), e.length > 0 && k(e[0].chain);
96
96
  } catch (e) {
97
- C(e instanceof Error ? e.message : g.loadPaymentNetworkFailed), p?.(e);
97
+ E(e instanceof Error ? e.message : y.loadPaymentNetworkFailed), g?.(e);
98
98
  } finally {
99
- x(!1);
99
+ w(!1);
100
100
  }
101
- }, Re = async (e) => {
102
- if (M) try {
103
- await M.request({
101
+ }, ze = async (e) => {
102
+ if (P) try {
103
+ await P.request({
104
104
  method: "wallet_switchEthereumChain",
105
105
  params: [{ chainId: `0x${e.toString(16)}` }]
106
106
  });
107
107
  } catch (e) {
108
- throw e.code === 4902 ? Error(g.pleaseAddNetwork) : e;
108
+ throw e.code === 4902 ? Error(y.pleaseAddNetwork) : e;
109
109
  }
110
- }, ze = async () => {
111
- if (!(!A || !M || !H.current || !K || !W)) try {
112
- x(!0);
113
- let e = H.current;
114
- await Re(W.chainId);
110
+ }, Be = async () => {
111
+ if (!(!N || !P || !W.current || !J || !K)) try {
112
+ w(!0);
113
+ let e = W.current;
114
+ await ze(K.chainId);
115
115
  let t = createWalletClient({
116
- account: A,
117
- transport: custom(M)
116
+ account: N,
117
+ transport: custom(P)
118
118
  });
119
- if (K.address) {
119
+ if (J.address) {
120
120
  let n = await t.writeContract({
121
- address: K.address,
122
- abi: [{
123
- name: "transfer",
124
- type: "function",
125
- stateMutability: "nonpayable",
126
- inputs: [{
127
- name: "to",
128
- type: "address"
129
- }, {
130
- name: "amount",
131
- type: "uint256"
132
- }],
133
- outputs: [{ type: "bool" }]
134
- }],
121
+ address: J.address,
122
+ abi: erc20Abi,
135
123
  functionName: "transfer",
136
- args: [e.receiveAddress, parseUnits(e.paymentAmount, K.decimals)],
124
+ args: [e.receiveAddress, parseUnits(e.paymentAmount, J.decimals)],
137
125
  chain: null
138
126
  });
139
- console.log("转账交易哈希:", n), R(n), U.current = n;
127
+ console.log("转账交易哈希:", n), B(n), G.current = n;
140
128
  } else {
141
129
  let n = await t.sendTransaction({
142
130
  to: e.receiveAddress,
143
- value: parseUnits(e.paymentAmount, K.decimals),
131
+ value: parseUnits(e.paymentAmount, J.decimals),
144
132
  chain: null
145
133
  });
146
- console.log("转账交易哈希:", n), R(n), U.current = n;
134
+ console.log("转账交易哈希:", n), B(n), G.current = n;
147
135
  }
148
- x(!1), v("checking"), Q({ paymentId: e.paymentId });
136
+ w(!1), x("checking"), Q({ paymentId: e.paymentId });
149
137
  } catch (e) {
150
- console.error("钱包支付失败:", e), C(e instanceof Error ? e.message : g.walletPaymentFailed), p?.(e), x(!1);
138
+ console.error("钱包支付失败:", e), E(e instanceof Error ? e.message : y.walletPaymentFailed), g?.(e), w(!1);
151
139
  }
152
- }, Be = async () => {
153
- if (!(!A || !M || !H.current || !K || !W)) try {
154
- x(!0);
155
- let e = H.current;
156
- await Re(W.chainId);
140
+ }, Ve = async () => {
141
+ if (!(!N || !P || !W.current || !J || !K)) try {
142
+ w(!0);
143
+ let e = W.current;
144
+ await ze(K.chainId);
157
145
  let t = createWalletClient({
158
- account: A,
159
- transport: custom(M)
146
+ account: N,
147
+ transport: custom(P)
160
148
  });
161
- if (!K.address) throw Error(g.subscriptionDoesNotSupportNative);
149
+ if (!J.address) throw Error(y.subscriptionDoesNotSupportNative);
162
150
  let n = await t.writeContract({
163
- address: K.address,
164
- abi: [{
165
- name: "approve",
166
- type: "function",
167
- stateMutability: "nonpayable",
168
- inputs: [{
169
- name: "spender",
170
- type: "address"
171
- }, {
172
- name: "amount",
173
- type: "uint256"
174
- }],
175
- outputs: [{ type: "bool" }]
176
- }],
151
+ address: J.address,
152
+ abi: erc20Abi,
177
153
  functionName: "approve",
178
- args: [e.spenderAddress, parseUnits(e.approveAmount, K.decimals)],
154
+ args: [e.spenderAddress, parseUnits(e.approveAmount, J.decimals)],
179
155
  chain: null
180
156
  });
181
- console.log("授权交易哈希:", n), R(n), U.current = n, x(!1), v("checking"), Q({ subscriptionId: e.subscriptionId });
157
+ console.log("授权交易哈希:", n), B(n), G.current = n, w(!1), x("checking"), Q({ subscriptionId: e.subscriptionId });
182
158
  } catch (e) {
183
- console.error("钱包授权失败:", e), C(e instanceof Error ? e.message : g.walletPaymentFailed), p?.(e), x(!1);
159
+ console.error("钱包授权失败:", e), E(e instanceof Error ? e.message : y.walletPaymentFailed), g?.(e), w(!1);
184
160
  }
185
- }, Ve = async () => {
186
- if (!A) {
187
- let e = g.pleaseConnectWallet;
188
- C(e), p?.(Error(e));
161
+ }, He = async () => {
162
+ if (!N) {
163
+ let e = y.pleaseConnectWallet;
164
+ E(e), g?.(Error(e));
189
165
  return;
190
166
  }
191
- u === "instant" ? await ze() : u === "subscription" && await Be();
192
- }, He = async () => {
193
- if (!(!T || !D)) try {
194
- x(!0), C(void 0);
195
- let e = "";
196
- if (u === "instant") H.current = await h.createOnetimePayment({
197
- paymentChain: T,
198
- paymentToken: D,
199
- orderId: xe,
200
- amount: Z,
201
- remark: Se
202
- }), e = `${T.toLowerCase()}:${H.current.receiveAddress}?amount=${H.current.paymentAmount}`, Y(H.current.expireAt), Ke(H.current.paymentId, "instant");
203
- else if (u === "subscription") {
204
- if (!f) throw Error(`Invalid Renewal Days: ${f ?? ""}`);
205
- H.current = await h.createSubscriptionPayment({
206
- paymentChain: T,
207
- paymentToken: D,
208
- orderId: xe,
209
- amountOfUsd: Z,
210
- intervalDays: f
211
- }), e = `${T.toLowerCase()}:${H.current.spenderAddress}?amount=${H.current.approveAmount}`, Y(H.current.expireAt), Ke(H.current.subscriptionId, "subscription");
167
+ p === "instant" ? await Be() : p === "subscription" && await Ve();
168
+ }, Ue = (e) => {
169
+ switch (e.toLowerCase()) {
170
+ case "ethereum":
171
+ case "bsc":
172
+ case "bsc-testnet": return "ethereum";
173
+ }
174
+ return "ethereum";
175
+ }, We = async () => {
176
+ if (!(!K || !J)) try {
177
+ if (w(!0), E(void 0), p === "instant") {
178
+ W.current = await v.createOnetimePayment({
179
+ paymentChain: K.chain,
180
+ paymentToken: J.symbol,
181
+ orderId: ye,
182
+ amount: Le,
183
+ remark: be
184
+ }), Z(W.current.expireAt), Je(W.current.paymentId, "instant");
185
+ let e = !J.address, t = Ue(K.chain.toLowerCase()), n = W.current.receiveAddress, r = parseUnits(W.current.paymentAmount, J.decimals), a = e ? `${t}:${n}@${K.chainId}?value=${r}` : `${t}:${J.address}@${K.chainId}/transfer?address=${n}&uint256=${r}`;
186
+ M(await QRCode.toDataURL(a, {
187
+ width: 200,
188
+ margin: 2,
189
+ errorCorrectionLevel: "H"
190
+ }));
191
+ } else if (p === "subscription") {
192
+ if (!h) throw Error(`Invalid Renewal Days: ${h ?? ""}`);
193
+ W.current = await v.createSubscriptionPayment({
194
+ paymentChain: K.chain,
195
+ paymentToken: J.symbol,
196
+ orderId: ye,
197
+ amountOfUsd: Le,
198
+ intervalDays: h
199
+ }), Z(W.current.expireAt), Je(W.current.subscriptionId, "subscription"), M(void 0);
212
200
  }
213
- v("payment"), k(await QRCode.toDataURL(e, {
214
- width: 200,
215
- margin: 2,
216
- errorCorrectionLevel: "H"
217
- }));
201
+ x("payment");
218
202
  } catch (e) {
219
- C(e instanceof Error ? e.message : g.createPaymentFailed), p?.(e);
203
+ E(e instanceof Error ? e.message : y.createPaymentFailed), g?.(e);
220
204
  } finally {
221
- x(!1);
205
+ w(!1);
222
206
  }
223
- }, Ue = () => {
224
- H.current && (v("checking"), C(void 0), u === "instant" ? Q({ paymentId: H.current.paymentId }) : u === "subscription" && Q({ subscriptionId: H.current.subscriptionId }));
207
+ }, Ge = () => {
208
+ W.current && (x("checking"), E(void 0), p === "instant" ? Q({ paymentId: W.current.paymentId }) : p === "subscription" && Q({ subscriptionId: W.current.subscriptionId }));
225
209
  }, Q = (e) => {
226
- B.current?.unsubscribe();
227
- let t = () => defer(() => u === "subscription" ? h.checkSubscriptionPaymentStatus(e) : h.checkOnetimePaymentStatus(e)).pipe(timeout(15e3), retry({ delay: 2e3 }));
228
- B.current = t().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => t())) : EMPTY), tap((e) => {
229
- if (!H.current && u === "instant") {
210
+ H.current?.unsubscribe();
211
+ let t = () => defer(() => p === "subscription" ? v.checkSubscriptionPaymentStatus(e) : v.checkOnetimePaymentStatus(e)).pipe(timeout(15e3), retry({ delay: 2e3 }));
212
+ H.current = t().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => t())) : EMPTY), tap((e) => {
213
+ if (!W.current && p === "instant") {
230
214
  let t = e;
231
- H.current = {
215
+ W.current = {
232
216
  paymentId: t.paymentId,
233
217
  orderId: t.orderId,
234
218
  paymentChain: t.chain,
@@ -236,21 +220,21 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
236
220
  paymentAmount: t.payAmount,
237
221
  receiveAddress: t.receiveAddress,
238
222
  expireAt: t.expireAt
239
- }, E(t.chain), O(t.token), Y(t.expireAt);
240
- let n = `${t.chain.toLowerCase()}:${t.receiveAddress}?amount=${t.payAmount}`;
241
- QRCode.toDataURL(n, {
223
+ }, k(t.chain), j(t.token), Z(t.expireAt);
224
+ let n = !t.tokenAddress, r = Ue(t.chain.toLowerCase()), a = t.receiveAddress, o = parseUnits(t.payAmount, t.tokenDecimals), s = n ? `${r}:${a}@${t.chainId}?value=${o}` : `${r}:${t.tokenAddress}@${t.chainId}/transfer?address=${a}&uint256=${o}`;
225
+ QRCode.toDataURL(s, {
242
226
  width: 200,
243
227
  margin: 2,
244
228
  errorCorrectionLevel: "H"
245
229
  }).then((e) => {
246
- k(e), v("payment");
230
+ M(e), x("payment");
247
231
  }).catch((e) => {
248
- console.error("生成二维码失败:", e), v("payment");
232
+ console.error("生成二维码失败:", e), x("payment");
249
233
  });
250
234
  }
251
- if (!H.current && u === "subscription") {
235
+ if (!W.current && p === "subscription") {
252
236
  let t = e;
253
- H.current = {
237
+ W.current = {
254
238
  subscriptionId: t.subscriptionId,
255
239
  orderId: t.orderId,
256
240
  paymentChain: t.chain,
@@ -260,49 +244,39 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
260
244
  expireAt: t.expireAt,
261
245
  intervalDays: 0,
262
246
  amountOfUsd: t.amountOfUsd
263
- }, E(t.chain), O(t.token), Y(t.expireAt);
264
- let n = `${t.chain.toLowerCase()}:${t.approvedAddress}?amount=${t.approveAmount}`;
265
- QRCode.toDataURL(n, {
266
- width: 200,
267
- margin: 2,
268
- errorCorrectionLevel: "H"
269
- }).then((e) => {
270
- k(e), v("payment");
271
- }).catch((e) => {
272
- console.error("生成二维码失败:", e), v("payment");
273
- });
247
+ }, k(t.chain), j(t.token), Z(t.expireAt), M(void 0);
274
248
  }
275
- (e.status === "paid" || e.status === "approved") && (v("success"), $(), we?.(e)), e.status === "expired" && (v("expired"), $(), Te?.(e)), e.status === "failed" && (v("failed"), $(), Ee?.(e));
249
+ (e.status === "paid" || e.status === "approved") && (x("success"), $(), Se?.(e)), e.status === "expired" && (x("expired"), $(), Ce?.(e)), e.status === "failed" && (x("failed"), $(), we?.(e));
276
250
  })).subscribe({
277
251
  error: (e) => {
278
- if (H.current) {
279
- let t = e instanceof Error ? e.message : g.checkPaymentStatusFailed;
280
- v("error"), C(t), p?.(e);
252
+ if (W.current) {
253
+ let t = e instanceof Error ? e.message : y.checkPaymentStatusFailed;
254
+ x("error"), E(t), g?.(e);
281
255
  }
282
256
  },
283
257
  complete: () => {
284
- B.current?.unsubscribe();
258
+ H.current?.unsubscribe();
285
259
  }
286
260
  });
287
- }, We = async () => {
288
- if (!H.current) return;
289
- let e = u === "subscription" ? H.current.spenderAddress : H.current.receiveAddress;
261
+ }, Ke = async () => {
262
+ if (!W.current) return;
263
+ let e = p === "subscription" ? W.current.spenderAddress : W.current.receiveAddress;
290
264
  if (e) try {
291
- await navigator.clipboard.writeText(e), F(!0), setTimeout(() => {
292
- F(!1);
265
+ await navigator.clipboard.writeText(e), L(!0), setTimeout(() => {
266
+ L(!1);
293
267
  }, 2e3);
294
268
  } catch (e) {
295
269
  console.error("复制失败:", e);
296
270
  }
297
- }, Ge = async () => {
298
- if (L) try {
299
- await navigator.clipboard.writeText(L), F(!0), setTimeout(() => {
300
- F(!1);
271
+ }, qe = async () => {
272
+ if (z) try {
273
+ await navigator.clipboard.writeText(z), L(!0), setTimeout(() => {
274
+ L(!1);
301
275
  }, 2e3);
302
276
  } catch (e) {
303
277
  console.error("复制失败:", e);
304
278
  }
305
- }, Ke = (e, t) => {
279
+ }, Je = (e, t) => {
306
280
  if (!n || typeof window > "u") return;
307
281
  let r = new URL(window.location.href), i = t === "subscription" ? "subscriptionId" : "paymentId";
308
282
  r.searchParams.set(i, e), window.history.replaceState({}, "", r.toString());
@@ -312,25 +286,25 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
312
286
  e.searchParams.delete("paymentId"), e.searchParams.delete("subscriptionId"), window.history.replaceState({}, "", e.toString());
313
287
  };
314
288
  return useEffect(() => {
315
- w.length === 0 && Le();
289
+ D.length === 0 && Re();
316
290
  }, []), useEffect(() => {
317
- G.length > 0 && O(G[0].symbol);
318
- }, [G]), useEffect(() => {
291
+ q.length > 0 && j(q[0].symbol);
292
+ }, [q]), useEffect(() => {
319
293
  if (typeof window > "u") return;
320
294
  let e = new URL(window.location.href);
321
- if (u === "instant") {
295
+ if (p === "instant") {
322
296
  let t = e.searchParams.get("paymentId");
323
- t && (v("payment"), Q({ paymentId: t }));
297
+ t && (x("payment"), Q({ paymentId: t }));
324
298
  }
325
- if (u === "subscription") {
299
+ if (p === "subscription") {
326
300
  let t = e.searchParams.get("subscriptionId");
327
- t && (v("payment"), Q({ subscriptionId: t }));
301
+ t && (x("payment"), Q({ subscriptionId: t }));
328
302
  }
329
303
  }, []), useEffect(() => () => {
330
- B.current?.unsubscribe(), X();
304
+ H.current?.unsubscribe(), Ie();
331
305
  }, []), /* @__PURE__ */ jsx("div", {
332
306
  className: "_cppay-content",
333
- children: _ === "success" ? m?.Success ? /* @__PURE__ */ jsx(m.Success, { paymentInfo: H.current }) : /* @__PURE__ */ jsxs("div", {
307
+ children: b === "success" ? _?.Success ? /* @__PURE__ */ jsx(_.Success, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
334
308
  className: "_cppay-state-container",
335
309
  children: [
336
310
  /* @__PURE__ */ jsx("div", {
@@ -342,22 +316,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
342
316
  }),
343
317
  /* @__PURE__ */ jsx("h3", {
344
318
  className: "_cppay-state-title _cppay-state-title-success",
345
- children: u === "subscription" ? g.authorizationSuccess : g.paymentSuccess
319
+ children: p === "subscription" ? y.authorizationSuccess : y.paymentSuccess
346
320
  }),
347
- L && /* @__PURE__ */ jsxs("div", {
321
+ z && /* @__PURE__ */ jsxs("div", {
348
322
  className: "_cppay-state-hash-container",
349
323
  children: [/* @__PURE__ */ jsx("div", {
350
324
  className: "_cppay-state-label",
351
- children: g.transactionHash
325
+ children: y.transactionHash
352
326
  }), /* @__PURE__ */ jsxs("div", {
353
327
  className: "_cppay-hash-row",
354
328
  children: [/* @__PURE__ */ jsx("code", {
355
329
  className: "_cppay-state-hash",
356
- children: L
330
+ children: z
357
331
  }), /* @__PURE__ */ jsx("button", {
358
- onClick: Ge,
332
+ onClick: qe,
359
333
  className: "_cppay-state-copy-btn",
360
- title: g.copyAddress,
334
+ title: y.copyAddress,
361
335
  children: /* @__PURE__ */ jsxs("svg", {
362
336
  viewBox: "0 0 24 24",
363
337
  fill: "none",
@@ -375,60 +349,60 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
375
349
  })]
376
350
  })]
377
351
  }),
378
- H.current && /* @__PURE__ */ jsxs("div", {
352
+ W.current && /* @__PURE__ */ jsxs("div", {
379
353
  className: "_cppay-success-details",
380
354
  children: [
381
355
  /* @__PURE__ */ jsxs("div", {
382
356
  className: "_cppay-detail-item",
383
357
  children: [/* @__PURE__ */ jsx("span", {
384
358
  className: "_cppay-detail-label",
385
- children: g.orderId
359
+ children: y.orderId
386
360
  }), /* @__PURE__ */ jsx("span", {
387
361
  className: "_cppay-detail-value",
388
- children: H.current.orderId
362
+ children: W.current.orderId
389
363
  })]
390
364
  }),
391
365
  /* @__PURE__ */ jsxs("div", {
392
366
  className: "_cppay-detail-item",
393
367
  children: [/* @__PURE__ */ jsx("span", {
394
368
  className: "_cppay-detail-label",
395
- children: u === "subscription" ? g.authorizationAmount : g.paymentAmount
369
+ children: p === "subscription" ? y.authorizationAmount : y.paymentAmount
396
370
  }), /* @__PURE__ */ jsx("span", {
397
371
  className: "_cppay-detail-value",
398
- children: u === "subscription" ? `${J(H.current.approveAmount, q(D))} ${D}` : `${J(H.current.paymentAmount, q(D))} ${D}`
372
+ children: p === "subscription" ? `${X(W.current.approveAmount, Y(A))} ${A}` : `${X(W.current.paymentAmount, Y(A))} ${A}`
399
373
  })]
400
374
  }),
401
375
  /* @__PURE__ */ jsxs("div", {
402
376
  className: "_cppay-detail-item",
403
377
  children: [/* @__PURE__ */ jsx("span", {
404
378
  className: "_cppay-detail-label",
405
- children: g.paymentNetwork
379
+ children: y.paymentNetwork
406
380
  }), /* @__PURE__ */ jsx("span", {
407
381
  className: "_cppay-detail-value",
408
- children: H.current.paymentChain
382
+ children: W.current.paymentChain
409
383
  })]
410
384
  }),
411
385
  /* @__PURE__ */ jsxs("div", {
412
386
  className: "_cppay-detail-item",
413
387
  children: [/* @__PURE__ */ jsx("span", {
414
388
  className: "_cppay-detail-label",
415
- children: g.paymentToken
389
+ children: y.paymentToken
416
390
  }), /* @__PURE__ */ jsx("span", {
417
391
  className: "_cppay-detail-value",
418
- children: H.current.paymentToken
392
+ children: W.current.paymentToken
419
393
  })]
420
394
  }),
421
- u === "subscription" && /* @__PURE__ */ jsxs("div", {
395
+ p === "subscription" && /* @__PURE__ */ jsxs("div", {
422
396
  className: "_cppay-detail-item",
423
397
  children: [/* @__PURE__ */ jsx("span", {
424
398
  className: "_cppay-detail-label",
425
- children: g.renewalInterval
399
+ children: y.renewalInterval
426
400
  }), /* @__PURE__ */ jsxs("span", {
427
401
  className: "_cppay-detail-value",
428
402
  children: [
429
- H.current.intervalDays,
403
+ W.current.intervalDays,
430
404
  " ",
431
- g.days
405
+ y.days
432
406
  ]
433
407
  })]
434
408
  }),
@@ -436,16 +410,16 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
436
410
  className: "_cppay-detail-item",
437
411
  children: [/* @__PURE__ */ jsx("span", {
438
412
  className: "_cppay-detail-label",
439
- children: u === "subscription" ? g.subscriptionId : g.paymentId
413
+ children: p === "subscription" ? y.subscriptionId : y.paymentId
440
414
  }), /* @__PURE__ */ jsx("span", {
441
415
  className: "_cppay-detail-value _cppay-detail-id",
442
- children: u === "subscription" ? H.current.subscriptionId : H.current.paymentId
416
+ children: p === "subscription" ? W.current.subscriptionId : W.current.paymentId
443
417
  })]
444
418
  })
445
419
  ]
446
420
  })
447
421
  ]
448
- }) : _ === "expired" ? m?.Expired ? /* @__PURE__ */ jsx(m.Expired, { paymentInfo: H.current }) : /* @__PURE__ */ jsxs("div", {
422
+ }) : b === "expired" ? _?.Expired ? /* @__PURE__ */ jsx(_.Expired, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
449
423
  className: "_cppay-state-container",
450
424
  children: [
451
425
  /* @__PURE__ */ jsx("div", {
@@ -457,22 +431,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
457
431
  }),
458
432
  /* @__PURE__ */ jsx("h3", {
459
433
  className: "_cppay-state-title _cppay-state-title-expired",
460
- children: g.paymentExpired
434
+ children: y.paymentExpired
461
435
  }),
462
436
  /* @__PURE__ */ jsx("p", {
463
437
  className: "_cppay-state-message",
464
- children: g.pleaseInitiatePaymentAgain
438
+ children: y.pleaseInitiatePaymentAgain
465
439
  }),
466
440
  /* @__PURE__ */ jsx("button", {
467
441
  onClick: () => {
468
- v("select"), $();
442
+ x("select"), $();
469
443
  },
470
- disabled: b || y,
444
+ disabled: C || S,
471
445
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
472
- children: g.returnButton
446
+ children: y.returnButton
473
447
  })
474
448
  ]
475
- }) : _ === "error" ? m?.Error ? /* @__PURE__ */ jsx(m.Error, { paymentInfo: H.current }) : /* @__PURE__ */ jsxs("div", {
449
+ }) : b === "error" ? _?.Error ? /* @__PURE__ */ jsx(_.Error, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
476
450
  className: "_cppay-state-container",
477
451
  children: [
478
452
  /* @__PURE__ */ jsx("div", {
@@ -484,22 +458,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
484
458
  }),
485
459
  /* @__PURE__ */ jsx("h3", {
486
460
  className: "_cppay-state-title _cppay-state-title-error",
487
- children: S || g.error
461
+ children: T || y.error
488
462
  }),
489
463
  /* @__PURE__ */ jsx("p", {
490
464
  className: "_cppay-state-message",
491
- children: g.checkStatusFailed
465
+ children: y.checkStatusFailed
492
466
  }),
493
467
  /* @__PURE__ */ jsx("button", {
494
468
  onClick: () => {
495
- v("select"), $();
469
+ x("select"), $();
496
470
  },
497
- disabled: b || y,
471
+ disabled: C || S,
498
472
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
499
- children: g.returnButton
473
+ children: y.returnButton
500
474
  })
501
475
  ]
502
- }) : _ === "failed" ? m?.Failed ? /* @__PURE__ */ jsx(m.Failed, { paymentInfo: H.current }) : /* @__PURE__ */ jsxs("div", {
476
+ }) : b === "failed" ? _?.Failed ? /* @__PURE__ */ jsx(_.Failed, { paymentInfo: W.current }) : /* @__PURE__ */ jsxs("div", {
503
477
  className: "_cppay-state-container",
504
478
  children: [
505
479
  /* @__PURE__ */ jsx("div", {
@@ -511,33 +485,33 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
511
485
  }),
512
486
  /* @__PURE__ */ jsx("h3", {
513
487
  className: "_cppay-state-title _cppay-state-title-failed",
514
- children: g.paymentFailed
488
+ children: y.paymentFailed
515
489
  }),
516
490
  /* @__PURE__ */ jsx("p", {
517
491
  className: "_cppay-state-message",
518
- children: g.pleaseInitiatePaymentAgain
492
+ children: y.pleaseInitiatePaymentAgain
519
493
  }),
520
494
  /* @__PURE__ */ jsx("button", {
521
495
  onClick: () => {
522
- v("select"), $();
496
+ x("select"), $();
523
497
  },
524
- disabled: b || y,
498
+ disabled: C || S,
525
499
  className: "_cppay-btn _cppay-btn-primary _cppay-state-btn",
526
- children: g.returnButton
500
+ children: y.returnButton
527
501
  })
528
502
  ]
529
- }) : _ === "select" ? /* @__PURE__ */ jsxs("div", { children: [
530
- m?.ChooseTop,
503
+ }) : b === "select" ? /* @__PURE__ */ jsxs("div", { children: [
504
+ _?.ChooseTop,
531
505
  /* @__PURE__ */ jsxs("div", {
532
506
  className: "_cppay-section",
533
507
  children: [/* @__PURE__ */ jsx("label", {
534
508
  className: "_cppay-label",
535
- children: g.paymentNetwork
509
+ children: y.paymentNetwork
536
510
  }), /* @__PURE__ */ jsx("div", {
537
511
  className: "_cppay-grid",
538
- children: w.map((e) => /* @__PURE__ */ jsxs("button", {
539
- onClick: () => E(e.chain),
540
- className: `_cppay-select-btn ${T === e.chain ? "_cppay-selected" : ""}`,
512
+ children: D.map((e) => /* @__PURE__ */ jsxs("button", {
513
+ onClick: () => k(e.chain),
514
+ className: `_cppay-select-btn ${O === e.chain ? "_cppay-selected" : ""}`,
541
515
  children: [e.icon && /* @__PURE__ */ jsx("img", {
542
516
  src: e.icon,
543
517
  alt: e.chain
@@ -549,12 +523,12 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
549
523
  className: "_cppay-section",
550
524
  children: [/* @__PURE__ */ jsx("label", {
551
525
  className: "_cppay-label",
552
- children: g.paymentToken
526
+ children: y.paymentToken
553
527
  }), /* @__PURE__ */ jsx("div", {
554
528
  className: "_cppay-grid",
555
- children: G.map((e) => /* @__PURE__ */ jsxs("button", {
556
- onClick: () => O(e.symbol),
557
- className: `_cppay-select-btn ${D === e.symbol ? "_cppay-selected" : ""}`,
529
+ children: q.map((e) => /* @__PURE__ */ jsxs("button", {
530
+ onClick: () => j(e.symbol),
531
+ className: `_cppay-select-btn ${A === e.symbol ? "_cppay-selected" : ""}`,
558
532
  children: [e.icon && /* @__PURE__ */ jsx("img", {
559
533
  src: e.icon,
560
534
  alt: e.symbol
@@ -562,7 +536,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
562
536
  }, e.symbol))
563
537
  })]
564
538
  }),
565
- m?.ChooseBottom,
539
+ _?.ChooseBottom,
566
540
  /* @__PURE__ */ jsx("div", {
567
541
  className: "_cppay-section",
568
542
  children: /* @__PURE__ */ jsx("div", {
@@ -571,19 +545,19 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
571
545
  className: "_cppay-price-row",
572
546
  children: [/* @__PURE__ */ jsx("span", {
573
547
  className: "_cppay-price-label",
574
- children: g.paymentAmount
548
+ children: y.paymentAmount
575
549
  }), /* @__PURE__ */ jsxs("div", {
576
550
  className: "_cppay-price-amount",
577
551
  children: [/* @__PURE__ */ jsxs("div", {
578
552
  className: "_cppay-price-main",
579
553
  children: [
580
- Z ?? "-",
554
+ Le ?? "-",
581
555
  " ",
582
- D ?? ""
556
+ A ?? ""
583
557
  ]
584
558
  }), /* @__PURE__ */ jsxs("div", {
585
559
  className: "_cppay-price-sub",
586
- children: ["≈ $", d]
560
+ children: ["≈ $", m]
587
561
  })]
588
562
  })]
589
563
  })
@@ -591,10 +565,10 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
591
565
  }),
592
566
  /* @__PURE__ */ jsxs("div", {
593
567
  className: "_cppay-section",
594
- children: [S && /* @__PURE__ */ jsxs("div", {
568
+ children: [T && /* @__PURE__ */ jsxs("div", {
595
569
  className: "_cppay-error-tooltip-wrapper",
596
- onMouseEnter: () => I(!0),
597
- onMouseLeave: () => I(!1),
570
+ onMouseEnter: () => R(!0),
571
+ onMouseLeave: () => R(!1),
598
572
  children: [/* @__PURE__ */ jsxs("div", {
599
573
  className: "_cppay-error-tooltip",
600
574
  children: [/* @__PURE__ */ jsx("svg", {
@@ -605,25 +579,25 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
605
579
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",
606
580
  clipRule: "evenodd"
607
581
  })
608
- }), /* @__PURE__ */ jsx("span", { children: S })]
609
- }), Pe && /* @__PURE__ */ jsx("div", {
582
+ }), /* @__PURE__ */ jsx("span", { children: T })]
583
+ }), Ne && /* @__PURE__ */ jsx("div", {
610
584
  className: "_cppay-error-tooltip-full",
611
- children: S
585
+ children: T
612
586
  })]
613
587
  }), /* @__PURE__ */ jsx("button", {
614
- onClick: He,
615
- disabled: !T || !D || b,
588
+ onClick: We,
589
+ disabled: !O || !A || C,
616
590
  className: "_cppay-btn _cppay-btn-primary",
617
- children: b ? g.processing : g.continuePayment
591
+ children: C ? y.processing : y.continuePayment
618
592
  })]
619
593
  })
620
594
  ] }) : /* @__PURE__ */ jsxs("div", { children: [
621
- /* @__PURE__ */ jsx("div", {
595
+ De && /* @__PURE__ */ jsx("div", {
622
596
  className: "_cppay-qr-container",
623
597
  children: /* @__PURE__ */ jsx("div", {
624
598
  className: "_cppay-qr-code",
625
- children: ke && /* @__PURE__ */ jsx("img", {
626
- src: ke,
599
+ children: /* @__PURE__ */ jsx("img", {
600
+ src: De,
627
601
  alt: "Payment QR Code",
628
602
  className: "_cppay-qr-image"
629
603
  })
@@ -632,7 +606,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
632
606
  /* @__PURE__ */ jsxs("div", {
633
607
  className: "_cppay-section",
634
608
  children: [
635
- K && /* @__PURE__ */ jsx("div", {
609
+ J && /* @__PURE__ */ jsx("div", {
636
610
  className: "_cppay-info-box",
637
611
  children: /* @__PURE__ */ jsx("div", {
638
612
  className: "_cppay-info-flex-container",
@@ -640,10 +614,10 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
640
614
  className: "_cppay-info-flex-child",
641
615
  children: [/* @__PURE__ */ jsx("div", {
642
616
  className: "_cppay-info-label",
643
- children: u === "subscription" ? g.authorizationAmount : g.paymentAmount
617
+ children: p === "subscription" ? y.authorizationAmount : y.paymentAmount
644
618
  }), /* @__PURE__ */ jsxs("div", {
645
619
  className: "_cppay-info-value _cppay-info-value-flex",
646
- children: [H.current && /* @__PURE__ */ jsx("span", { children: u === "subscription" ? `${J(H.current.approveAmount, q(K.symbol))} ${K.symbol}` : `${J(H.current.paymentAmount, q(K.symbol))} ${K.symbol}` }), /* @__PURE__ */ jsxs("span", { children: ["≈ $", d] })]
620
+ children: [W.current && /* @__PURE__ */ jsx("span", { children: p === "subscription" ? `${X(W.current.approveAmount, Y(J.symbol))} ${J.symbol}` : `${X(W.current.paymentAmount, Y(J.symbol))} ${J.symbol}` }), /* @__PURE__ */ jsxs("span", { children: ["≈ $", m] })]
647
621
  })]
648
622
  })
649
623
  })
@@ -654,17 +628,17 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
654
628
  className: "_cppay-info-flex-child",
655
629
  children: [/* @__PURE__ */ jsxs("div", {
656
630
  className: "_cppay-info-label _cppay-info-label-flex",
657
- children: [/* @__PURE__ */ jsx("span", { children: u === "subscription" ? g.authorizationContractAddress : g.paymentAddress }), Me && /* @__PURE__ */ jsxs("span", {
631
+ children: [/* @__PURE__ */ jsx("span", { children: p === "subscription" ? y.authorizationContractAddress : y.paymentAddress }), je && /* @__PURE__ */ jsxs("span", {
658
632
  className: "_cppay-countdown",
659
- children: ["⏰ ", Me]
633
+ children: ["⏰ ", je]
660
634
  })]
661
635
  }), /* @__PURE__ */ jsxs("div", {
662
636
  className: "_cppay-address-row",
663
- children: [H.current && /* @__PURE__ */ jsx("code", { children: u === "subscription" ? H.current.spenderAddress : H.current.receiveAddress }), /* @__PURE__ */ jsx("button", {
664
- onClick: We,
665
- className: `_cppay-copy-btn ${P ? "_cppay-copy-success" : ""}`,
666
- title: P ? g.copied : g.copyAddress,
667
- children: P ? /* @__PURE__ */ jsx("svg", {
637
+ children: [W.current && /* @__PURE__ */ jsx("code", { children: p === "subscription" ? W.current.spenderAddress : W.current.receiveAddress }), /* @__PURE__ */ jsx("button", {
638
+ onClick: Ke,
639
+ className: `_cppay-copy-btn ${I ? "_cppay-copy-success" : ""}`,
640
+ title: I ? y.copied : y.copyAddress,
641
+ children: I ? /* @__PURE__ */ jsx("svg", {
668
642
  className: "_cppay-copy-icon",
669
643
  viewBox: "0 0 24 24",
670
644
  fill: "currentColor",
@@ -688,22 +662,22 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
688
662
  })]
689
663
  })
690
664
  }),
691
- u === "subscription" && /* @__PURE__ */ jsxs("div", {
665
+ p === "subscription" && /* @__PURE__ */ jsxs("div", {
692
666
  className: "_cppay-info-box _cppay-subscription-box",
693
667
  children: [/* @__PURE__ */ jsx("div", {
694
668
  className: "_cppay-info-label _cppay-subscription-label",
695
- children: g.subscriptionNotice
669
+ children: y.subscriptionNotice
696
670
  }), /* @__PURE__ */ jsx("div", {
697
671
  className: "_cppay-info-value _cppay-subscription-message",
698
- children: g.subscriptionNoticeMessage
672
+ children: y.subscriptionNoticeMessage
699
673
  })]
700
674
  })
701
675
  ]
702
676
  }),
703
- S && /* @__PURE__ */ jsxs("div", {
677
+ T && /* @__PURE__ */ jsxs("div", {
704
678
  className: "_cppay-error-tooltip-wrapper",
705
- onMouseEnter: () => I(!0),
706
- onMouseLeave: () => I(!1),
679
+ onMouseEnter: () => R(!0),
680
+ onMouseLeave: () => R(!1),
707
681
  children: [/* @__PURE__ */ jsxs("div", {
708
682
  className: "_cppay-error-tooltip",
709
683
  children: [/* @__PURE__ */ jsx("svg", {
@@ -714,30 +688,30 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
714
688
  d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",
715
689
  clipRule: "evenodd"
716
690
  })
717
- }), /* @__PURE__ */ jsx("span", { children: S })]
718
- }), Pe && /* @__PURE__ */ jsx("div", {
691
+ }), /* @__PURE__ */ jsx("span", { children: T })]
692
+ }), Ne && /* @__PURE__ */ jsx("div", {
719
693
  className: "_cppay-error-tooltip-full",
720
- children: S
694
+ children: T
721
695
  })]
722
696
  }),
723
- !y && /* @__PURE__ */ jsx("div", {
697
+ !S && /* @__PURE__ */ jsx("div", {
724
698
  className: "_cppay-section",
725
- children: A ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
726
- onClick: Ve,
727
- disabled: b,
699
+ children: N ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
700
+ onClick: He,
701
+ disabled: C,
728
702
  className: "_cppay-btn _cppay-btn-primary",
729
- children: b ? u === "subscription" ? g.authorizing : g.processing : u === "subscription" ? `💳 ${g.connectWallet}` : `💳 ${g.walletPay}`
703
+ children: C ? p === "subscription" ? y.authorizing : y.processing : p === "subscription" ? `💳 ${y.walletAuthorize}` : `💳 ${y.walletPay}`
730
704
  }), /* @__PURE__ */ jsxs("button", {
731
- onClick: Fe,
732
- disabled: b,
705
+ onClick: Pe,
706
+ disabled: C,
733
707
  className: "_cppay-btn _cppay-wallet-address-btn",
734
- title: g.clickToModifyWallet,
708
+ title: y.clickToModifyWallet,
735
709
  children: [/* @__PURE__ */ jsxs("span", {
736
710
  className: "_cppay-wallet-address-text",
737
711
  children: [
738
- A.slice(0, 10),
712
+ N.slice(0, 10),
739
713
  "...",
740
- A.slice(-4)
714
+ N.slice(-4)
741
715
  ]
742
716
  }), /* @__PURE__ */ jsx("svg", {
743
717
  className: "_cppay-wallet-arrow",
@@ -748,19 +722,19 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
748
722
  children: /* @__PURE__ */ jsx("polyline", { points: "6 9 12 15 18 9" })
749
723
  })]
750
724
  })] }) : /* @__PURE__ */ jsx("button", {
751
- onClick: Fe,
752
- disabled: Ae,
725
+ onClick: Pe,
726
+ disabled: ke,
753
727
  className: "_cppay-btn _cppay-btn-secondary _cppay-connect-wallet-btn",
754
- children: /* @__PURE__ */ jsx("span", { children: Ae ? g.processing : `💳 ${g.connectWallet}` })
728
+ children: /* @__PURE__ */ jsx("span", { children: ke ? y.processing : `💳 ${y.connectWallet}` })
755
729
  })
756
730
  }),
757
731
  /* @__PURE__ */ jsx("div", {
758
732
  className: "_cppay-section",
759
733
  children: /* @__PURE__ */ jsx("button", {
760
- onClick: Ue,
761
- disabled: y,
734
+ onClick: Ge,
735
+ disabled: S,
762
736
  className: "_cppay-btn _cppay-btn-primary",
763
- children: y ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("svg", {
737
+ children: S ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("svg", {
764
738
  className: "_cppay-spinner",
765
739
  viewBox: "0 0 24 24",
766
740
  fill: "none",
@@ -778,7 +752,7 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
778
752
  strokeWidth: "3",
779
753
  strokeLinecap: "round"
780
754
  })]
781
- }), g.checking] }) : g.completedPayment
755
+ }), y.checking] }) : y.completedPayment
782
756
  })
783
757
  }),
784
758
  /* @__PURE__ */ jsx("hr", { className: "_cppay-divider" }),
@@ -786,32 +760,32 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
786
760
  className: "_cppay-section",
787
761
  children: /* @__PURE__ */ jsx("button", {
788
762
  onClick: () => {
789
- v("select"), $();
763
+ x("select"), $();
790
764
  },
791
- disabled: b || y,
765
+ disabled: C || S,
792
766
  className: "_cppay-btn _cppay-btn-text",
793
- children: g.changePaymentMethod
767
+ children: y.changePaymentMethod
794
768
  })
795
769
  })
796
770
  ] })
797
771
  });
798
- }, PaymentDialog_default = ({ open: e, onClose: t, ott: n, apikey: i, plain: ue, orderId: de, amount: fe, intervalDays: pe, remark: me, locale: a, onExpired: he, onSuccess: ge, onFailed: _e, onError: ve, Slots: ye }) => {
799
- let [o, be] = useState("select"), s = useMemo(() => o !== "checking", [o]);
772
+ }, PaymentDialog_default = ({ open: e, onClose: t, ott: n, apikey: i, plain: a, orderId: o, amount: s, intervalDays: de, remark: fe, locale: c, onExpired: pe, onSuccess: me, onFailed: he, onError: ge, Slots: _e }) => {
773
+ let [l, ve] = useState("select"), u = useMemo(() => l !== "checking", [l]);
800
774
  useEffect(() => {
801
- e || be("select");
775
+ e || ve("select");
802
776
  }, [e]), useEffect(() => {
803
777
  if (!e) return;
804
778
  let t = (e) => {
805
- e.key === "Escape" && s && c();
779
+ e.key === "Escape" && u && d();
806
780
  };
807
781
  return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
808
- }, [e, s]);
809
- let c = () => {
810
- s && t();
811
- }, l = useMemo(() => getLocaleMessages(a), [a]);
782
+ }, [e, u]);
783
+ let d = () => {
784
+ u && t();
785
+ }, f = useMemo(() => getLocaleMessages(c), [c]);
812
786
  return e ? /* @__PURE__ */ jsx("div", {
813
787
  className: "_cppay-overlay",
814
- onClick: (e) => e.target === e.currentTarget && c(),
788
+ onClick: (e) => e.target === e.currentTarget && d(),
815
789
  children: /* @__PURE__ */ jsxs("div", {
816
790
  className: "_cppay-dialog",
817
791
  children: [/* @__PURE__ */ jsxs("div", {
@@ -819,19 +793,19 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
819
793
  children: [/* @__PURE__ */ jsx("h2", {
820
794
  className: "_cppay-title",
821
795
  children: (() => {
822
- switch (o) {
823
- case "success": return l.paymentResult;
824
- case "expired": return l.paymentExpired;
825
- case "failed": return l.paymentFailed;
826
- case "error": return l.error;
796
+ switch (l) {
797
+ case "success": return f.paymentResult;
798
+ case "expired": return f.paymentExpired;
799
+ case "failed": return f.paymentFailed;
800
+ case "error": return f.error;
827
801
  case "payment":
828
- case "checking": return l.completePayment;
829
- default: return l.selectPaymentMethod;
802
+ case "checking": return f.completePayment;
803
+ default: return f.selectPaymentMethod;
830
804
  }
831
805
  })()
832
806
  }), /* @__PURE__ */ jsx("button", {
833
- onClick: c,
834
- disabled: !s,
807
+ onClick: d,
808
+ disabled: !u,
835
809
  className: "_cppay-close-btn",
836
810
  children: /* @__PURE__ */ jsx("svg", {
837
811
  fill: "none",
@@ -848,51 +822,51 @@ var PaymentContent_default = ({ apikey: t, ott: n, plain: u, orderId: xe, amount
848
822
  }), /* @__PURE__ */ jsx(PaymentContent_default, {
849
823
  apikey: i,
850
824
  ott: n,
851
- plain: ue,
852
- orderId: de,
853
- amount: fe,
854
- intervalDays: pe,
855
- remark: me,
856
- locale: a,
857
- onSuccess: ge,
858
- onExpired: he,
859
- onFailed: _e,
860
- onError: ve,
861
- Slots: ye,
862
- onPaymentStepChange: be
825
+ plain: a,
826
+ orderId: o,
827
+ amount: s,
828
+ intervalDays: de,
829
+ remark: fe,
830
+ locale: c,
831
+ onSuccess: me,
832
+ onExpired: pe,
833
+ onFailed: he,
834
+ onError: ge,
835
+ Slots: _e,
836
+ onPaymentStepChange: ve
863
837
  })]
864
838
  })
865
839
  }) : null;
866
840
  }, CppayContext = createContext(null);
867
841
  const CppayProvider = ({ children: e }) => {
868
- let [t, n] = useState(!1), [r, i] = useState(null), ue = useCallback((e) => {
842
+ let [t, n] = useState(!1), [r, i] = useState(null), a = useCallback((e) => {
869
843
  i(e), n(!0);
870
- }, []), de = useCallback(() => {
844
+ }, []), o = useCallback(() => {
871
845
  n(!1);
872
- }, []), fe = useCallback(() => {
846
+ }, []), s = useCallback(() => {
873
847
  n(!1);
874
- }, []), pe = useCallback((e) => {
848
+ }, []), de = useCallback((e) => {
875
849
  r?.onSuccess?.(e);
876
- }, [r]), me = useCallback((e) => {
850
+ }, [r]), fe = useCallback((e) => {
877
851
  r?.onExpired?.(e);
878
- }, [r]), a = useCallback((e) => {
852
+ }, [r]), c = useCallback((e) => {
879
853
  r?.onFailed?.(e);
880
- }, [r]), he = useCallback((e) => {
854
+ }, [r]), pe = useCallback((e) => {
881
855
  r?.onError?.(e);
882
856
  }, [r]);
883
857
  return /* @__PURE__ */ jsxs(CppayContext.Provider, {
884
858
  value: {
885
- showPayment: ue,
886
- closePayment: de
859
+ showPayment: a,
860
+ closePayment: o
887
861
  },
888
862
  children: [e, r && /* @__PURE__ */ jsx(PaymentDialog_default, {
889
863
  open: t,
890
- onClose: fe,
864
+ onClose: s,
891
865
  ...r,
892
- onSuccess: pe,
893
- onExpired: me,
894
- onFailed: a,
895
- onError: he
866
+ onSuccess: de,
867
+ onExpired: fe,
868
+ onFailed: c,
869
+ onError: pe
896
870
  })]
897
871
  });
898
872
  }, useCppayPayment = () => {