cppay-sdk 0.0.2-beta.25 → 0.0.2-beta.26

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.
Files changed (141) hide show
  1. package/dist/cppay-sdk.css +1 -1
  2. package/dist/index.cjs +1 -1
  3. package/dist/polygon-1pLQCNfb.js +3952 -0
  4. package/dist/polygon-zw79IkW8.cjs +15 -0
  5. package/dist/react.cjs +6 -1
  6. package/dist/react.js +422 -303
  7. package/dist/vue.cjs +1 -1
  8. package/dist/vue.js +174 -235
  9. package/package.json +24 -7
  10. package/dist/AlertController-BPGQ5PgH.js +0 -12787
  11. package/dist/AlertController-CjTbf-Vd.cjs +0 -10
  12. package/dist/ApiController-Crww70p3.js +0 -5652
  13. package/dist/ApiController-DB43iwF1.cjs +0 -4
  14. package/dist/CaipNetworkUtil-Bd4HeTLY.js +0 -204
  15. package/dist/CaipNetworkUtil-Bg22uavB.cjs +0 -1
  16. package/dist/HelpersUtil-CeTmhhZv.js +0 -1415
  17. package/dist/HelpersUtil-L0eeYoE2.cjs +0 -225
  18. package/dist/PhArrowCircleDown-BBy_VuPx.js +0 -46
  19. package/dist/PhArrowCircleDown-BU4QSsA3.cjs +0 -14
  20. package/dist/PhArrowClockwise-D8C24T6J.js +0 -46
  21. package/dist/PhArrowClockwise-DWqhijc2.cjs +0 -14
  22. package/dist/PhArrowDown-Qm1T2ueY.cjs +0 -14
  23. package/dist/PhArrowDown-p9Tekztm.js +0 -46
  24. package/dist/PhArrowLeft-CEtyMFdq.cjs +0 -14
  25. package/dist/PhArrowLeft-CgSKs9Xe.js +0 -46
  26. package/dist/PhArrowRight-ZatyoD6R.cjs +0 -14
  27. package/dist/PhArrowRight-dMdzUgrx.js +0 -46
  28. package/dist/PhArrowSquareOut-CbP71Gny.js +0 -46
  29. package/dist/PhArrowSquareOut-HyssV9za.cjs +0 -14
  30. package/dist/PhArrowUp-Cz127u8b.cjs +0 -14
  31. package/dist/PhArrowUp-DNn-RQ7v.js +0 -46
  32. package/dist/PhArrowUpRight-BX6LlOL0.cjs +0 -14
  33. package/dist/PhArrowUpRight-OyGUhoGi.js +0 -46
  34. package/dist/PhArrowsClockwise-B6w_d2Gy.cjs +0 -14
  35. package/dist/PhArrowsClockwise-BWITTwAP.js +0 -46
  36. package/dist/PhArrowsDownUp-CHHtczH8.js +0 -46
  37. package/dist/PhArrowsDownUp-WYzjhvmQ.cjs +0 -14
  38. package/dist/PhArrowsLeftRight-BA0fjcLn.js +0 -46
  39. package/dist/PhArrowsLeftRight-bgyrYWLt.cjs +0 -14
  40. package/dist/PhBank-BInxTxLw.js +0 -46
  41. package/dist/PhBank-CZ_uTsAN.cjs +0 -14
  42. package/dist/PhBrowser--6CxS13p.js +0 -46
  43. package/dist/PhBrowser-BzOw0W8k.cjs +0 -14
  44. package/dist/PhCaretDown-D-zrPZN9.js +0 -46
  45. package/dist/PhCaretDown-DvF3M2iu.cjs +0 -14
  46. package/dist/PhCaretLeft-DND0SNkF.cjs +0 -14
  47. package/dist/PhCaretLeft-Dm6NsnIS.js +0 -46
  48. package/dist/PhCaretRight-BkRzbZ5m.js +0 -46
  49. package/dist/PhCaretRight-xQkT3bmO.cjs +0 -14
  50. package/dist/PhCaretUp-BEk_5jnn.cjs +0 -14
  51. package/dist/PhCaretUp-DZRZQ-T1.js +0 -46
  52. package/dist/PhCheck-BmwCUZuW.js +0 -46
  53. package/dist/PhCheck-C-u2QP3y.cjs +0 -14
  54. package/dist/PhCircleHalf--TfGDEAT.js +0 -46
  55. package/dist/PhCircleHalf-keQfI7pU.cjs +0 -14
  56. package/dist/PhClock-BvmbjmRx.cjs +0 -14
  57. package/dist/PhClock-DNCf5CVD.js +0 -46
  58. package/dist/PhCompass-B6tcbOFZ.js +0 -46
  59. package/dist/PhCompass-rWCQ_cR8.cjs +0 -14
  60. package/dist/PhCopy-CzC1olDO.cjs +0 -14
  61. package/dist/PhCopy-rbBTM6ME.js +0 -46
  62. package/dist/PhCreditCard-DOpOB0Pl.js +0 -46
  63. package/dist/PhCreditCard-D_qRVKuY.cjs +0 -14
  64. package/dist/PhCurrencyDollar-4EASQkjs.js +0 -46
  65. package/dist/PhCurrencyDollar-RVJJ6bQ3.cjs +0 -14
  66. package/dist/PhDesktop-CPaC-lRj.cjs +0 -14
  67. package/dist/PhDesktop-DZPux6RD.js +0 -46
  68. package/dist/PhDeviceMobile-BnXs4f3Q.cjs +0 -14
  69. package/dist/PhDeviceMobile-CcdKzyah.js +0 -46
  70. package/dist/PhDotsThree-19bbXQaM.js +0 -46
  71. package/dist/PhDotsThree-DSmFeW6i.cjs +0 -14
  72. package/dist/PhEnvelope-F7RF6h58.js +0 -46
  73. package/dist/PhEnvelope-QuTMQbE9.cjs +0 -14
  74. package/dist/PhFunnelSimple-B_FRP21W.js +0 -46
  75. package/dist/PhFunnelSimple-D4Ztu4ri.cjs +0 -14
  76. package/dist/PhGlobe-B8GrTk4S.cjs +0 -14
  77. package/dist/PhGlobe-BSPoRqTV.js +0 -46
  78. package/dist/PhIdentificationCard-fGDBGII0.cjs +0 -14
  79. package/dist/PhIdentificationCard-giQnti3K.js +0 -46
  80. package/dist/PhImage-BpUk8j27.cjs +0 -14
  81. package/dist/PhImage-PtBaftbW.js +0 -46
  82. package/dist/PhInfo-DQEDS02h.js +0 -46
  83. package/dist/PhInfo-V5wKJJoK.cjs +0 -14
  84. package/dist/PhLightbulb-Cisg0Myw.js +0 -46
  85. package/dist/PhLightbulb-xP9kaUlD.cjs +0 -14
  86. package/dist/PhMagnifyingGlass-C1cVSYf2.cjs +0 -14
  87. package/dist/PhMagnifyingGlass-DlkOfQXn.js +0 -46
  88. package/dist/PhPaperPlaneRight-C7Jp2jl_.js +0 -46
  89. package/dist/PhPaperPlaneRight-Kh3uxxIy.cjs +0 -14
  90. package/dist/PhPlus-BgHn57eW.js +0 -46
  91. package/dist/PhPlus-hJ6DZNjc.cjs +0 -14
  92. package/dist/PhPower-C369g1jk.js +0 -46
  93. package/dist/PhPower-DZ-SpUrD.cjs +0 -14
  94. package/dist/PhPuzzlePiece-B0oABcWl.js +0 -46
  95. package/dist/PhPuzzlePiece-DLtOLrcw.cjs +0 -14
  96. package/dist/PhQrCode-BT_hyeEa.js +0 -46
  97. package/dist/PhQrCode-yI6bLoYY.cjs +0 -14
  98. package/dist/PhQuestion-B1UeE96D.js +0 -46
  99. package/dist/PhQuestion-icSeWABx.cjs +0 -14
  100. package/dist/PhQuestionMark-CBVW9Awo.js +0 -46
  101. package/dist/PhQuestionMark-Cmhqu81E.cjs +0 -14
  102. package/dist/PhSealCheck-DTKS5QAx.cjs +0 -14
  103. package/dist/PhSealCheck-Dm2I2X7k.js +0 -46
  104. package/dist/PhSignOut-25xp33w2.cjs +0 -14
  105. package/dist/PhSignOut-BTTDADPY.js +0 -46
  106. package/dist/PhSpinner-Dbua7p0Y.js +0 -46
  107. package/dist/PhSpinner-DtpwblyA.cjs +0 -14
  108. package/dist/PhTrash-B3wUg10m.cjs +0 -14
  109. package/dist/PhTrash-gZghJkGX.js +0 -46
  110. package/dist/PhUser-Bvcv05IM.js +0 -46
  111. package/dist/PhUser-COPP3N-M.cjs +0 -14
  112. package/dist/PhVault-CFa5lrPU.cjs +0 -14
  113. package/dist/PhVault-DvlBF0VI.js +0 -46
  114. package/dist/PhWallet-CzJcybaO.cjs +0 -14
  115. package/dist/PhWallet-Do_lf9BX.js +0 -46
  116. package/dist/PhWarning-BrbSc7gQ.cjs +0 -14
  117. package/dist/PhWarning-DiIpJVsx.js +0 -46
  118. package/dist/PhWarningCircle-DE9BlEIc.js +0 -46
  119. package/dist/PhWarningCircle-F5Piypme.cjs +0 -14
  120. package/dist/PhX-BK3VZT8X.cjs +0 -14
  121. package/dist/PhX-CNlXuiat.js +0 -46
  122. package/dist/basic-C16-Uba1.js +0 -3796
  123. package/dist/basic-ChiCOE6E.cjs +0 -1329
  124. package/dist/chunk-2qRSBEuq.js +0 -18
  125. package/dist/chunk-DT80SxnK.cjs +0 -1
  126. package/dist/core-DKXmyfMB.js +0 -2337
  127. package/dist/core-PuDBroil.cjs +0 -1
  128. package/dist/dijkstra-CNhLvnjU.cjs +0 -1
  129. package/dist/dijkstra-kFl0HtsI.js +0 -56
  130. package/dist/features-BYfQH2hG.cjs +0 -2
  131. package/dist/features-_5Pi-gXV.js +0 -245
  132. package/dist/index.es-DDV8bPq_.js +0 -8311
  133. package/dist/index.es-fgFnvPDP.cjs +0 -19
  134. package/dist/property-Dil4gG0H.cjs +0 -3
  135. package/dist/property-JsW5AM1M.js +0 -578
  136. package/dist/w3m-modal-BBvmkTyb.cjs +0 -2416
  137. package/dist/w3m-modal-CFhImDZN.js +0 -5286
  138. package/dist/walletconnect-B0zXLUON.cjs +0 -17
  139. package/dist/walletconnect-Bb4rv9-G.js +0 -11314
  140. package/dist/wui-list-item-BGvfYb1W.cjs +0 -1452
  141. package/dist/wui-list-item-C4wJpGBn.js +0 -2123
package/dist/react.js CHANGED
@@ -1,16 +1,234 @@
1
- import { o as __toESM } from "./chunk-2qRSBEuq.js";
1
+ import { _ as __toESM, a as base, c as tap, d as expand, f as require_browser, g as __require, h as __commonJSMin, i as bsc, l as switchMap, m as payment_dialog_default, n as optimism, o as arbitrum, p as injectStyle, r as mainnet, s as timeout, t as polygon, u as retry } from "./polygon-1pLQCNfb.js";
2
2
  import { t as cppay_default } from "./cppay-BcCDwXlg.js";
3
- import { a as injectStyle, i as require_browser, n as metamask_default, o as payment_dialog_default, r as E, t as walletconnect_default } from "./walletconnect-Bb4rv9-G.js";
4
- import "./dijkstra-kFl0HtsI.js";
5
- import "./index.es-DDV8bPq_.js";
6
3
  import { EMPTY, defer, timer } from "rxjs";
7
- import { expand, retry, switchMap, tap, timeout } from "rxjs/operators";
8
4
  import { createWalletClient, custom, parseUnits } from "viem";
9
- import { arbitrum, base, bsc, mainnet, optimism, polygon } from "viem/chains";
5
+ import { createAppKit } from "@reown/appkit";
6
+ import { EthersAdapter } from "@reown/appkit-adapter-ethers";
10
7
  import React, { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
11
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
12
- var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialog_default = React.memo(({ open: e, onClose: n, apikey: r, plain: a, orderId: l, amount: u, intervalDays: d, onExpired: f, onSuccess: p, onFailed: m, onError: h }) => {
13
- let g = useMemo(() => new cppay_default(r), [r]), [_, v] = useState("select"), [y, b] = useState(!1), [x, S] = useState([]), [C, w] = useState(""), [T, D] = useState(""), [O, k] = useState(""), [A, j] = useState(""), [M, N] = useState(!1), [P, F] = useState(null), I = useRef(null), L = useRef(null), R = useMemo(() => x.find((e) => e.chain === C), [x, C]), z = useMemo(() => R?.tokens || [], [R]), B = useMemo(() => z.find((e) => e.symbol === T), [z, T]), V = (e) => [
8
+ /**
9
+ * @license React
10
+ * react-jsx-runtime.production.js
11
+ *
12
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
13
+ *
14
+ * This source code is licensed under the MIT license found in the
15
+ * LICENSE file in the root directory of this source tree.
16
+ */
17
+ var require_react_jsx_runtime_production = /* @__PURE__ */ __commonJSMin(((e) => {
18
+ var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
19
+ function r(e, n, r) {
20
+ var i = null;
21
+ if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
22
+ else r = n;
23
+ return n = r.ref, {
24
+ $$typeof: t,
25
+ type: e,
26
+ key: i,
27
+ ref: n === void 0 ? null : n,
28
+ props: r
29
+ };
30
+ }
31
+ e.Fragment = n, e.jsx = r, e.jsxs = r;
32
+ })), require_react_jsx_runtime_development = /* @__PURE__ */ __commonJSMin(((e) => {
33
+ process.env.NODE_ENV !== "production" && (function() {
34
+ function t(e) {
35
+ if (e == null) return null;
36
+ if (typeof e == "function") return e.$$typeof === de ? null : e.displayName || e.name || null;
37
+ if (typeof e == "string") return e;
38
+ switch (e) {
39
+ case m: return "Fragment";
40
+ case ae: return "Profiler";
41
+ case ie: return "StrictMode";
42
+ case le: return "Suspense";
43
+ case ue: return "SuspenseList";
44
+ case _: return "Activity";
45
+ }
46
+ if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
47
+ case re: return "Portal";
48
+ case se: return e.displayName || "Context";
49
+ case oe: return (e._context.displayName || "Context") + ".Consumer";
50
+ case ce:
51
+ var n = e.render;
52
+ return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
53
+ case h: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
54
+ case g:
55
+ n = e._payload, e = e._init;
56
+ try {
57
+ return t(e(n));
58
+ } catch {}
59
+ }
60
+ return null;
61
+ }
62
+ function n(e) {
63
+ return "" + e;
64
+ }
65
+ function r(e) {
66
+ try {
67
+ n(e);
68
+ var t = !1;
69
+ } catch {
70
+ t = !0;
71
+ }
72
+ if (t) {
73
+ t = console;
74
+ var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
75
+ return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
76
+ }
77
+ }
78
+ function i(e) {
79
+ if (e === m) return "<>";
80
+ if (typeof e == "object" && e && e.$$typeof === g) return "<...>";
81
+ try {
82
+ var n = t(e);
83
+ return n ? "<" + n + ">" : "<...>";
84
+ } catch {
85
+ return "<...>";
86
+ }
87
+ }
88
+ function o() {
89
+ var e = v.A;
90
+ return e === null ? null : e.getOwner();
91
+ }
92
+ function s() {
93
+ return Error("react-stack-top-frame");
94
+ }
95
+ function c(e) {
96
+ if (fe.call(e, "key")) {
97
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
98
+ if (t && t.isReactWarning) return !1;
99
+ }
100
+ return e.key !== void 0;
101
+ }
102
+ function l(e, t) {
103
+ function n() {
104
+ b || (b = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
105
+ }
106
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
107
+ get: n,
108
+ configurable: !0
109
+ });
110
+ }
111
+ function ee() {
112
+ var e = t(this.type);
113
+ return x[e] || (x[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
114
+ }
115
+ function te(e, t, n, r, i, a) {
116
+ var o = n.ref;
117
+ return e = {
118
+ $$typeof: p,
119
+ type: e,
120
+ key: t,
121
+ props: n,
122
+ _owner: r
123
+ }, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
124
+ enumerable: !1,
125
+ value: null
126
+ }) : Object.defineProperty(e, "ref", {
127
+ enumerable: !1,
128
+ get: ee
129
+ }), e._store = {}, Object.defineProperty(e._store, "validated", {
130
+ configurable: !1,
131
+ enumerable: !1,
132
+ writable: !0,
133
+ value: 0
134
+ }), Object.defineProperty(e, "_debugInfo", {
135
+ configurable: !1,
136
+ enumerable: !1,
137
+ writable: !0,
138
+ value: null
139
+ }), Object.defineProperty(e, "_debugStack", {
140
+ configurable: !1,
141
+ enumerable: !1,
142
+ writable: !0,
143
+ value: i
144
+ }), Object.defineProperty(e, "_debugTask", {
145
+ configurable: !1,
146
+ enumerable: !1,
147
+ writable: !0,
148
+ value: a
149
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
150
+ }
151
+ function u(e, n, i, a, s, ee) {
152
+ var u = n.children;
153
+ if (u !== void 0) if (a) if (pe(u)) {
154
+ for (a = 0; a < u.length; a++) ne(u[a]);
155
+ Object.freeze && Object.freeze(u);
156
+ } else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
157
+ else ne(u);
158
+ if (fe.call(n, "key")) {
159
+ u = t(e);
160
+ var d = Object.keys(n).filter(function(e) {
161
+ return e !== "key";
162
+ });
163
+ a = 0 < d.length ? "{key: someKey, " + d.join(": ..., ") + ": ...}" : "{key: someKey}", w[u + a] || (d = 0 < d.length ? "{" + d.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", a, u, d, u), w[u + a] = !0);
164
+ }
165
+ if (u = null, i !== void 0 && (r(i), u = "" + i), c(n) && (r(n.key), u = "" + n.key), "key" in n) for (var f in i = {}, n) f !== "key" && (i[f] = n[f]);
166
+ else i = n;
167
+ return u && l(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), te(e, u, i, o(), s, ee);
168
+ }
169
+ function ne(e) {
170
+ d(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === g && (e._payload.status === "fulfilled" ? d(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
171
+ }
172
+ function d(e) {
173
+ return typeof e == "object" && !!e && e.$$typeof === p;
174
+ }
175
+ var f = __require("react"), p = Symbol.for("react.transitional.element"), re = Symbol.for("react.portal"), m = Symbol.for("react.fragment"), ie = Symbol.for("react.strict_mode"), ae = Symbol.for("react.profiler"), oe = Symbol.for("react.consumer"), se = Symbol.for("react.context"), ce = Symbol.for("react.forward_ref"), le = Symbol.for("react.suspense"), ue = Symbol.for("react.suspense_list"), h = Symbol.for("react.memo"), g = Symbol.for("react.lazy"), _ = Symbol.for("react.activity"), de = Symbol.for("react.client.reference"), v = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, fe = Object.prototype.hasOwnProperty, pe = Array.isArray, y = console.createTask ? console.createTask : function() {
176
+ return null;
177
+ };
178
+ f = { react_stack_bottom_frame: function(e) {
179
+ return e();
180
+ } };
181
+ var b, x = {}, S = f.react_stack_bottom_frame.bind(f, s)(), C = y(i(s)), w = {};
182
+ e.Fragment = m, e.jsx = function(e, t, n) {
183
+ var r = 1e4 > v.recentlyCreatedOwnerStacks++;
184
+ return u(e, t, n, !1, r ? Error("react-stack-top-frame") : S, r ? y(i(e)) : C);
185
+ }, e.jsxs = function(e, t, n) {
186
+ var r = 1e4 > v.recentlyCreatedOwnerStacks++;
187
+ return u(e, t, n, !0, r ? Error("react-stack-top-frame") : S, r ? y(i(e)) : C);
188
+ };
189
+ })();
190
+ })), require_jsx_runtime = /* @__PURE__ */ __commonJSMin(((e, t) => {
191
+ process.env.NODE_ENV === "production" ? t.exports = require_react_jsx_runtime_production() : t.exports = require_react_jsx_runtime_development();
192
+ })), import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), import_jsx_runtime = require_jsx_runtime(), PaymentDialog_default = React.memo(({ open: e, onClose: i, apikey: a, plain: o, orderId: l, amount: u, intervalDays: h, onExpired: g, onSuccess: _, onFailed: de, onError: b }) => {
193
+ let x = useMemo(() => new cppay_default(a), [a]), [S, T] = useState("select"), [E, D] = useState(!1), [O, k] = useState(!1), [A, me] = useState([]), [j, M] = useState(), [N, P] = useState(), [F, he] = useState(), [I, L] = useState(), [R, z] = useState(!1), [B, V] = useState(), H = useRef(null), U = useRef(null);
194
+ useEffect(() => {
195
+ typeof window < "u" && !H.current && (H.current = createAppKit({
196
+ debug: !1,
197
+ enableNetworkSwitch: !1,
198
+ adapters: [new EthersAdapter()],
199
+ projectId: "8d2e1854d3f1782e45aa15fbd8938894",
200
+ allowUnsupportedChain: !0,
201
+ networks: [
202
+ mainnet,
203
+ bsc,
204
+ polygon,
205
+ arbitrum,
206
+ optimism,
207
+ base
208
+ ],
209
+ metadata: {
210
+ name: "Cppay",
211
+ description: "Cppay Payment Gateway",
212
+ url: window.location.origin,
213
+ icons: ["https://cppay.com/icon.png"]
214
+ },
215
+ features: { analytics: !1 }
216
+ }), L(H.current.getAddress()), V(H.current.getProvider("eip155")), H.current.subscribeAccount((e) => {
217
+ e.isConnected ? L(e.address) : (L(void 0), V(void 0));
218
+ }), H.current.subscribeProviders((e) => {
219
+ let t = e?.eip155;
220
+ V(t);
221
+ }));
222
+ }, []);
223
+ let W = async () => {
224
+ try {
225
+ z(!0), H.current && await H.current.open();
226
+ } catch (e) {
227
+ console.error("钱包连接失败:", e), b?.(e);
228
+ } finally {
229
+ z(!1);
230
+ }
231
+ }, G = useMemo(() => A.find((e) => e.chain === j), [A, j]), K = useMemo(() => G?.tokens || [], [G]), q = useMemo(() => K.find((e) => e.symbol === N), [K, N]), J = (e) => [
14
232
  "USDT",
15
233
  "USDC",
16
234
  "BUSD",
@@ -18,115 +236,50 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
18
236
  "TUSD",
19
237
  "USDD",
20
238
  "FDUSD"
21
- ].includes(e.toUpperCase()) ? 2 : 6, H = (e) => ({
22
- ETH: mainnet,
23
- BSC: bsc,
24
- Polygon: polygon,
25
- Arbitrum: arbitrum,
26
- Optimism: optimism,
27
- Base: base
28
- })[e] || mainnet, U = (e, t) => {
239
+ ].includes(e.toUpperCase()) ? 2 : 6, Y = (e, t) => {
29
240
  let n = parseFloat(e);
30
241
  return isNaN(n) ? "0" : n.toFixed(t).replace(/\.?0+$/, "");
31
- }, W = useMemo(() => {
32
- if (!T || !B) return "0";
33
- let e = parseFloat(B.price);
242
+ }, X = useMemo(() => {
243
+ if (!N || !q) return "0";
244
+ let e = parseFloat(q.price);
34
245
  if (isNaN(e) || e === 0) return "0";
35
- let t = V(T);
36
- return U((parseFloat(u) / e).toFixed(t), t);
246
+ let t = J(N);
247
+ return Y((parseFloat(u) / e).toFixed(t), t);
37
248
  }, [
38
249
  u,
39
- T,
40
- B
41
- ]), G = async () => {
42
- try {
43
- b(!0);
44
- let e = await g.getSupportedChains();
45
- S(e), e.length > 0 && w(e[0].chain);
46
- } catch (e) {
47
- h?.(e);
48
- } finally {
49
- b(!1);
50
- }
51
- }, K = async (e) => {
250
+ N,
251
+ q
252
+ ]), ge = async () => {
52
253
  try {
53
- if (N(!0), e === "metamask") {
54
- if (typeof window < "u" && window.ethereum?.isMetaMask) {
55
- let e = await window.ethereum.request({ method: "eth_requestAccounts" });
56
- if (e && e.length > 0) {
57
- j(e[0]), F("metamask");
58
- return;
59
- }
60
- }
61
- throw Error("请安装 MetaMask 扩展");
62
- }
63
- if (e === "walletconnect") {
64
- let e = await E.init({
65
- projectId: "8d2e1854d3f1782e45aa15fbd8938894",
66
- chains: [1],
67
- showQrModal: !0,
68
- optionalChains: [
69
- 56,
70
- 137,
71
- 42161,
72
- 10,
73
- 8453
74
- ],
75
- methods: [
76
- "eth_sendTransaction",
77
- "eth_signTransaction",
78
- "eth_sign",
79
- "personal_sign",
80
- "eth_signTypedData"
81
- ],
82
- events: ["chainChanged", "accountsChanged"],
83
- metadata: {
84
- name: "Cppay",
85
- description: "Cppay Payment Gateway",
86
- url: typeof window < "u" ? window.location.origin : "https://cppay.com",
87
- icons: ["https://cppay.com/icon.png"]
88
- },
89
- rpcMap: {
90
- 1: "https://ethereum.publicnode.com",
91
- 56: "https://bsc-dataseed.binance.org",
92
- 137: "https://polygon-rpc.com",
93
- 42161: "https://arb1.arbitrum.io/rpc",
94
- 10: "https://mainnet.optimism.io",
95
- 8453: "https://mainnet.base.org"
96
- }
97
- });
98
- await e.enable();
99
- let t = await e.request({ method: "eth_accounts" });
100
- t && t.length > 0 && (j(t[0]), F("walletconnect"), I.current = e);
101
- }
254
+ D(!0);
255
+ let e = await x.getSupportedChains();
256
+ me(e), e.length > 0 && M(e[0].chain);
102
257
  } catch (e) {
103
- console.error("钱包连接失败:", e), h?.(e);
258
+ b?.(e);
104
259
  } finally {
105
- N(!1);
260
+ D(!1);
106
261
  }
107
- }, q = async (e) => {
108
- let t;
109
- if (t = P === "walletconnect" ? I.current : window.ethereum, t) try {
110
- await t.request({
262
+ }, _e = async (e) => {
263
+ if (B) try {
264
+ await B.request({
111
265
  method: "wallet_switchEthereumChain",
112
266
  params: [{ chainId: `0x${e.toString(16)}` }]
113
267
  });
114
268
  } catch (e) {
115
269
  throw e.code === 4902 ? Error("请在钱包中添加该网络") : e;
116
270
  }
117
- }, J = async () => {
118
- if (!(!A || !X.current || !B)) try {
119
- b(!0);
120
- let e = X.current, t = H(C);
121
- await q(R.chainId);
122
- let n = createWalletClient({
123
- account: A,
124
- chain: t,
125
- transport: custom(P === "walletconnect" ? I.current : window.ethereum)
271
+ }, ve = async () => {
272
+ if (!(!I || !B || !Z.current || !q || !G)) try {
273
+ D(!0);
274
+ let e = Z.current;
275
+ await _e(G.chainId);
276
+ let t = createWalletClient({
277
+ account: I,
278
+ transport: custom(B)
126
279
  });
127
- if (B.address) {
128
- let t = await n.writeContract({
129
- address: B.address,
280
+ if (q.address) {
281
+ let n = await t.writeContract({
282
+ address: q.address,
130
283
  abi: [{
131
284
  name: "transfer",
132
285
  type: "function",
@@ -141,37 +294,34 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
141
294
  outputs: [{ type: "bool" }]
142
295
  }],
143
296
  functionName: "transfer",
144
- args: [e.receiveAddress, parseUnits(e.paymentAmount, B.decimals)],
297
+ args: [e.receiveAddress, parseUnits(e.paymentAmount, q.decimals)],
145
298
  chain: null
146
299
  });
147
- console.log("转账交易哈希:", t);
300
+ console.log("转账交易哈希:", n);
148
301
  } else {
149
- let t = await n.sendTransaction({
302
+ let n = await t.sendTransaction({
150
303
  to: e.receiveAddress,
151
- value: parseUnits(e.paymentAmount, B.decimals),
304
+ value: parseUnits(e.paymentAmount, q.decimals),
152
305
  chain: null
153
306
  });
154
- console.log("转账交易哈希:", t);
307
+ console.log("转账交易哈希:", n);
155
308
  }
156
- Z(e.paymentId);
309
+ D(!1), k(!0), Q(e.paymentId);
157
310
  } catch (e) {
158
- console.error("钱包支付失败:", e), h?.(e);
159
- } finally {
160
- b(!1);
311
+ console.error("钱包支付失败:", e), b?.(e), D(!1);
161
312
  }
162
- }, Y = async () => {
163
- if (!(!A || !X.current || !B)) try {
164
- b(!0);
165
- let e = X.current, t = H(C);
166
- await q(R.chainId);
167
- let n = createWalletClient({
168
- account: A,
169
- chain: t,
170
- transport: custom(P === "walletconnect" ? I.current : window.ethereum)
313
+ }, ye = async () => {
314
+ if (!(!I || !B || !Z.current || !q || !G)) try {
315
+ D(!0);
316
+ let e = Z.current;
317
+ await _e(G.chainId);
318
+ let t = createWalletClient({
319
+ account: I,
320
+ transport: custom(B)
171
321
  });
172
- if (!B.address) throw Error("订阅支付不支持原生代币");
173
- let r = await n.writeContract({
174
- address: B.address,
322
+ if (!q.address) throw Error("订阅支付不支持原生代币");
323
+ let n = await t.writeContract({
324
+ address: q.address,
175
325
  abi: [{
176
326
  name: "approve",
177
327
  type: "function",
@@ -186,96 +336,94 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
186
336
  outputs: [{ type: "bool" }]
187
337
  }],
188
338
  functionName: "approve",
189
- args: [e.spenderAddress, parseUnits(e.approveAmount, B.decimals)],
339
+ args: [e.spenderAddress, parseUnits(e.approveAmount, q.decimals)],
190
340
  chain: null
191
341
  });
192
- console.log("授权交易哈希:", r), Z(e.subscriptionId);
342
+ console.log("授权交易哈希:", n), D(!1), k(!0), Q(e.subscriptionId);
193
343
  } catch (e) {
194
- console.error("钱包授权失败:", e), h?.(e);
195
- } finally {
196
- b(!1);
344
+ console.error("钱包授权失败:", e), b?.(e), D(!1);
197
345
  }
198
- }, we = async () => {
199
- if (!A) {
200
- h?.(/* @__PURE__ */ Error("请先连接钱包"));
346
+ }, be = async () => {
347
+ if (!I) {
348
+ b?.(/* @__PURE__ */ Error("请先连接钱包"));
201
349
  return;
202
350
  }
203
- a === "one-time" ? await J() : a === "subscription" && await Y();
204
- }, X = useRef(null), Te = async () => {
205
- if (!(!C || !T)) try {
206
- b(!0);
351
+ o === "one-time" ? await ve() : o === "subscription" && await ye();
352
+ }, Z = useRef(null), xe = async () => {
353
+ if (!(!j || !N)) try {
354
+ D(!0);
207
355
  let e = "";
208
- a === "one-time" ? (X.current = await g.createOnetimePayment({
209
- paymentChain: C,
210
- paymentToken: T,
356
+ o === "one-time" ? (Z.current = await x.createOnetimePayment({
357
+ paymentChain: j,
358
+ paymentToken: N,
211
359
  orderId: l,
212
- amount: W
213
- }), e = `${C.toLowerCase()}:${X.current.receiveAddress}?amount=${X.current.paymentAmount}`) : a === "subscription" && (X.current = await g.createSubscriptionPayment({
214
- paymentChain: C,
215
- paymentToken: T,
360
+ amount: X
361
+ }), e = `${j.toLowerCase()}:${Z.current.receiveAddress}?amount=${Z.current.paymentAmount}`) : o === "subscription" && (Z.current = await x.createSubscriptionPayment({
362
+ paymentChain: j,
363
+ paymentToken: N,
216
364
  orderId: l,
217
- amountOfUsd: W,
218
- intervalDays: d || 30
219
- }), e = `${C.toLowerCase()}:${X.current.spenderAddress}?amount=${X.current.approveAmount}`), v("payment"), k(await import_browser.toDataURL(e, {
365
+ amountOfUsd: X,
366
+ intervalDays: h || 30
367
+ }), e = `${j.toLowerCase()}:${Z.current.spenderAddress}?amount=${Z.current.approveAmount}`), T("payment"), he(await import_browser.toDataURL(e, {
220
368
  width: 200,
221
369
  margin: 2,
222
370
  errorCorrectionLevel: "H"
223
371
  }));
224
372
  } catch (e) {
225
- h?.(e);
373
+ b?.(e);
226
374
  } finally {
227
- b(!1);
375
+ D(!1);
228
376
  }
229
- }, Ee = async () => {
230
- if (X.current) try {
231
- b(!0), a === "one-time" ? Z(X.current.paymentId) : a === "subscription" && Z(X.current.subscriptionId);
377
+ }, Se = async () => {
378
+ if (Z.current) try {
379
+ k(!0), o === "one-time" ? Q(Z.current.paymentId) : o === "subscription" && Q(Z.current.subscriptionId);
232
380
  } catch (e) {
233
- console.error("支付状态检查错误:", e), h?.(e), b(!1);
381
+ console.error("支付状态检查错误:", e), b?.(e), k(!1);
234
382
  }
235
- }, Z = (e) => {
236
- let t = () => defer(() => a === "subscription" ? g.checkSubscriptionPaymentStatus({ subscriptionId: e }) : g.checkOnetimePaymentStatus({ paymentId: e })).pipe(timeout(15e3), retry({
383
+ }, Q = (e) => {
384
+ let t = () => defer(() => o === "subscription" ? x.checkSubscriptionPaymentStatus({ subscriptionId: e }) : x.checkOnetimePaymentStatus({ paymentId: e })).pipe(timeout(15e3), retry({
237
385
  count: 3,
238
386
  delay: 2e3
239
387
  }));
240
- L.current?.unsubscribe(), L.current = t().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => t())) : EMPTY), tap((e) => {
241
- e.status === "expired" && (b(!1), f?.(e)), e.status === "paid" && (b(!1), v("success"), p?.(e)), e.status === "failed" && (b(!1), m?.(e)), e.status === "approved" && (b(!1), v("success"), p?.(e));
388
+ U.current?.unsubscribe(), U.current = t().pipe(expand((e) => e.status === "pending" ? timer(2e3).pipe(switchMap(() => t())) : EMPTY), tap((e) => {
389
+ e.status === "expired" && (k(!1), g?.(e)), e.status === "paid" && (k(!1), T("success"), _?.(e)), e.status === "failed" && (k(!1), de?.(e)), e.status === "approved" && (k(!1), T("success"), _?.(e));
242
390
  })).subscribe({ error: (e) => {
243
- console.error("支付状态检查错误:", e), b(!1), h?.(e);
391
+ console.error("支付状态检查错误:", e), k(!1), b?.(e);
244
392
  } });
245
- }, Q = async () => {
246
- if (!X.current) return;
247
- let e = a === "subscription" ? X.current.spenderAddress : X.current.receiveAddress;
393
+ }, Ce = async () => {
394
+ if (!Z.current) return;
395
+ let e = o === "subscription" ? Z.current.spenderAddress : Z.current.receiveAddress;
248
396
  e && await navigator.clipboard.writeText(e);
249
397
  }, $ = () => {
250
- y || (n(), setTimeout(() => {
251
- v("select"), X.current = null;
398
+ E || O || (i(), setTimeout(() => {
399
+ T("select"), Z.current = null;
252
400
  }, 300));
253
401
  };
254
402
  return useEffect(() => {
255
- e && x.length === 0 && G();
403
+ e && A.length === 0 && ge();
256
404
  }, [e]), useEffect(() => {
257
- z.length > 0 && D(z[0].symbol);
258
- }, [z]), useEffect(() => () => {
259
- L.current?.unsubscribe();
260
- }, []), e ? /* @__PURE__ */ jsx("div", {
405
+ K.length > 0 && P(K[0].symbol);
406
+ }, [K]), useEffect(() => () => {
407
+ U.current?.unsubscribe();
408
+ }, []), e ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
261
409
  className: "_cppay-overlay",
262
- onClick: (e) => e.target === e.currentTarget && !y && $(),
263
- children: /* @__PURE__ */ jsxs("div", {
410
+ onClick: (e) => e.target === e.currentTarget && !E && !O && $(),
411
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
264
412
  className: "_cppay-dialog",
265
- children: [/* @__PURE__ */ jsxs("div", {
413
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
266
414
  className: "_cppay-header",
267
- children: [/* @__PURE__ */ jsx("h2", {
415
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
268
416
  className: "_cppay-title",
269
- children: _ === "select" ? "选择支付方式" : "完成支付"
270
- }), /* @__PURE__ */ jsx("button", {
417
+ children: S === "select" ? "选择支付方式" : "完成支付"
418
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
271
419
  onClick: $,
272
- disabled: y,
420
+ disabled: E || O,
273
421
  className: "_cppay-close-btn",
274
- children: /* @__PURE__ */ jsx("svg", {
422
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
275
423
  fill: "none",
276
424
  stroke: "currentColor",
277
425
  viewBox: "0 0 24 24",
278
- children: /* @__PURE__ */ jsx("path", {
426
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
279
427
  strokeLinecap: "round",
280
428
  strokeLinejoin: "round",
281
429
  strokeWidth: 2,
@@ -283,92 +431,92 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
283
431
  })
284
432
  })
285
433
  })]
286
- }), /* @__PURE__ */ jsx("div", {
434
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
287
435
  className: "_cppay-content",
288
- children: _ === "success" ? /* @__PURE__ */ jsxs("div", {
436
+ children: S === "success" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
289
437
  style: {
290
438
  textAlign: "center",
291
439
  padding: "2rem 0"
292
440
  },
293
441
  children: [
294
- /* @__PURE__ */ jsx("div", {
442
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
295
443
  style: {
296
444
  fontSize: "64px",
297
445
  marginBottom: "1rem"
298
446
  },
299
447
  children: "✅"
300
448
  }),
301
- /* @__PURE__ */ jsx("h3", {
449
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
302
450
  style: {
303
451
  fontSize: "1.5rem",
304
452
  fontWeight: 600,
305
453
  color: "#10b981",
306
454
  margin: "0 0 0.5rem 0"
307
455
  },
308
- children: a === "subscription" ? "授权成功!" : "支付成功!"
456
+ children: o === "subscription" ? "授权成功!" : "支付成功!"
309
457
  }),
310
- /* @__PURE__ */ jsx("p", {
458
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
311
459
  style: {
312
460
  color: "#6b7280",
313
461
  margin: 0
314
462
  },
315
- children: a === "subscription" ? "订阅已激活" : "交易已完成"
463
+ children: o === "subscription" ? "订阅已激活" : "交易已完成"
316
464
  })
317
465
  ]
318
- }) : _ === "select" ? /* @__PURE__ */ jsxs("div", { children: [
319
- /* @__PURE__ */ jsxs("div", {
466
+ }) : S === "select" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
467
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
320
468
  className: "_cppay-section",
321
- children: [/* @__PURE__ */ jsx("label", {
469
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
322
470
  className: "_cppay-label",
323
471
  children: "支付网络"
324
- }), /* @__PURE__ */ jsx("div", {
472
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
325
473
  className: "_cppay-grid",
326
- children: x.map((e) => /* @__PURE__ */ jsxs("button", {
327
- onClick: () => w(e.chain),
328
- className: `_cppay-select-btn ${C === e.chain ? "_cppay-selected" : ""}`,
329
- children: [e.icon && /* @__PURE__ */ jsx("img", {
474
+ children: A.map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
475
+ onClick: () => M(e.chain),
476
+ className: `_cppay-select-btn ${j === e.chain ? "_cppay-selected" : ""}`,
477
+ children: [e.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
330
478
  src: e.icon,
331
479
  alt: e.chain
332
- }), /* @__PURE__ */ jsx("span", { children: e.chain })]
480
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: e.chain })]
333
481
  }, e.chain))
334
482
  })]
335
483
  }),
336
- /* @__PURE__ */ jsxs("div", {
484
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
337
485
  className: "_cppay-section",
338
- children: [/* @__PURE__ */ jsx("label", {
486
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", {
339
487
  className: "_cppay-label",
340
488
  children: "支付代币"
341
- }), /* @__PURE__ */ jsx("div", {
489
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
342
490
  className: "_cppay-grid",
343
- children: z.map((e) => /* @__PURE__ */ jsxs("button", {
344
- onClick: () => D(e.symbol),
345
- className: `_cppay-select-btn ${T === e.symbol ? "_cppay-selected" : ""}`,
346
- children: [e.icon && /* @__PURE__ */ jsx("img", {
491
+ children: K.map((e) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
492
+ onClick: () => P(e.symbol),
493
+ className: `_cppay-select-btn ${N === e.symbol ? "_cppay-selected" : ""}`,
494
+ children: [e.icon && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
347
495
  src: e.icon,
348
496
  alt: e.symbol
349
- }), /* @__PURE__ */ jsx("span", { children: e.symbol })]
497
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: e.symbol })]
350
498
  }, e.symbol))
351
499
  })]
352
500
  }),
353
- /* @__PURE__ */ jsx("div", {
501
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
354
502
  className: "_cppay-section",
355
- children: /* @__PURE__ */ jsx("div", {
503
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
356
504
  className: "_cppay-price-box",
357
- children: /* @__PURE__ */ jsxs("div", {
505
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
358
506
  className: "_cppay-price-row",
359
- children: [/* @__PURE__ */ jsx("span", {
507
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
360
508
  className: "_cppay-price-label",
361
509
  children: "支付金额"
362
- }), /* @__PURE__ */ jsxs("div", {
510
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
363
511
  className: "_cppay-price-amount",
364
- children: [/* @__PURE__ */ jsxs("div", {
512
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
365
513
  className: "_cppay-price-main",
366
514
  children: [
367
- W,
515
+ X ?? "-",
368
516
  " ",
369
- T
517
+ N ?? ""
370
518
  ]
371
- }), /* @__PURE__ */ jsxs("div", {
519
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
372
520
  className: "_cppay-price-sub",
373
521
  children: ["≈ $", u]
374
522
  })]
@@ -376,22 +524,22 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
376
524
  })
377
525
  })
378
526
  }),
379
- /* @__PURE__ */ jsx("div", {
527
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
380
528
  className: "_cppay-section",
381
- children: /* @__PURE__ */ jsx("button", {
382
- onClick: Te,
383
- disabled: !C || !T || y,
529
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
530
+ onClick: xe,
531
+ disabled: !j || !N || E,
384
532
  className: "_cppay-btn _cppay-btn-primary",
385
- children: y ? "处理中..." : "继续支付"
533
+ children: E ? "处理中..." : "继续支付"
386
534
  })
387
535
  })
388
- ] }) : /* @__PURE__ */ jsxs("div", { children: [
389
- /* @__PURE__ */ jsx("div", {
536
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
537
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
390
538
  className: "_cppay-qr-container",
391
- children: /* @__PURE__ */ jsx("div", {
539
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
392
540
  className: "_cppay-qr-code",
393
- children: O && /* @__PURE__ */ jsx("img", {
394
- src: O,
541
+ children: F && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", {
542
+ src: F,
395
543
  alt: "Payment QR Code",
396
544
  style: {
397
545
  width: "160px",
@@ -401,35 +549,35 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
401
549
  })
402
550
  })
403
551
  }),
404
- /* @__PURE__ */ jsxs("div", {
552
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
405
553
  className: "_cppay-section",
406
554
  children: [
407
- /* @__PURE__ */ jsxs("div", {
555
+ N && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
408
556
  className: "_cppay-info-box",
409
- children: [/* @__PURE__ */ jsx("div", {
557
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
410
558
  className: "_cppay-info-label",
411
- children: a === "subscription" ? "授权金额" : "支付金额"
412
- }), /* @__PURE__ */ jsx("div", {
559
+ children: o === "subscription" ? "授权金额" : "支付金额"
560
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
413
561
  className: "_cppay-info-value",
414
- children: a === "subscription" ? `${U(X.current.approveAmount, V(T))} ${T}` : `${U(X.current.paymentAmount, V(T))} ${T}`
562
+ children: o === "subscription" ? `${Y(Z.current.approveAmount, J(N))} ${N}` : `${Y(Z.current.paymentAmount, J(N))} ${N}`
415
563
  })]
416
564
  }),
417
- /* @__PURE__ */ jsxs("div", {
565
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
418
566
  className: "_cppay-info-box",
419
- children: [/* @__PURE__ */ jsx("div", {
567
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
420
568
  className: "_cppay-info-label",
421
- children: a === "subscription" ? "授权合约地址" : "支付地址"
422
- }), /* @__PURE__ */ jsxs("div", {
569
+ children: o === "subscription" ? "授权合约地址" : "支付地址"
570
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
423
571
  className: "_cppay-address-row",
424
- children: [/* @__PURE__ */ jsx("code", { children: a === "subscription" ? X.current.spenderAddress : X.current.receiveAddress }), /* @__PURE__ */ jsx("button", {
425
- onClick: Q,
572
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: o === "subscription" ? Z.current.spenderAddress : Z.current.receiveAddress }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
573
+ onClick: Ce,
426
574
  className: "_cppay-copy-btn",
427
575
  title: "复制地址",
428
- children: /* @__PURE__ */ jsx("svg", {
576
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", {
429
577
  fill: "none",
430
578
  stroke: "currentColor",
431
579
  viewBox: "0 0 24 24",
432
- children: /* @__PURE__ */ jsx("path", {
580
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
433
581
  strokeLinecap: "round",
434
582
  strokeLinejoin: "round",
435
583
  strokeWidth: 2,
@@ -439,17 +587,17 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
439
587
  })]
440
588
  })]
441
589
  }),
442
- a === "subscription" && /* @__PURE__ */ jsxs("div", {
590
+ o === "subscription" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
443
591
  className: "_cppay-info-box",
444
592
  style: {
445
593
  background: "#fff3cd",
446
594
  borderColor: "#ffc107"
447
595
  },
448
- children: [/* @__PURE__ */ jsx("div", {
596
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
449
597
  className: "_cppay-info-label",
450
598
  style: { color: "#856404" },
451
599
  children: "📌 订阅说明"
452
- }), /* @__PURE__ */ jsx("div", {
600
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
453
601
  className: "_cppay-info-value",
454
602
  style: {
455
603
  fontSize: "12px",
@@ -460,14 +608,22 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
460
608
  })
461
609
  ]
462
610
  }),
463
- /* @__PURE__ */ jsx("div", {
611
+ !O && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
464
612
  className: "_cppay-section",
465
- children: A ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
466
- onClick: we,
467
- disabled: y,
468
- className: "_cppay-btn _cppay-btn-primary",
469
- children: y ? a === "subscription" ? "授权中..." : "支付中..." : a === "subscription" ? "💳 钱包授权" : "💳 钱包支付"
470
- }), /* @__PURE__ */ jsxs("div", {
613
+ children: I ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
614
+ className: "_cppay-btn-container",
615
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
616
+ onClick: be,
617
+ disabled: E,
618
+ className: "_cppay-btn _cppay-btn-primary",
619
+ children: E ? o === "subscription" ? "授权中..." : "支付中..." : o === "subscription" ? "💳 钱包授权" : "💳 钱包支付"
620
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
621
+ onClick: W,
622
+ disabled: E,
623
+ className: "_cppay-btn _cppay-btn-primary",
624
+ children: "💰钱包状态"
625
+ })]
626
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
471
627
  style: {
472
628
  textAlign: "center",
473
629
  marginTop: "8px",
@@ -476,76 +632,39 @@ var import_browser = /* @__PURE__ */ __toESM(require_browser(), 1), PaymentDialo
476
632
  },
477
633
  children: [
478
634
  "已连接: ",
479
- A.slice(0, 6),
635
+ I.slice(0, 6),
480
636
  "...",
481
- A.slice(-4)
637
+ I.slice(-4)
482
638
  ]
483
- })] }) : /* @__PURE__ */ jsxs("div", {
639
+ })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
640
+ onClick: W,
641
+ disabled: R,
642
+ className: "_cppay-btn _cppay-btn-secondary",
484
643
  style: {
485
644
  display: "flex",
486
- flexDirection: "row",
645
+ alignItems: "center",
646
+ justifyContent: "center",
487
647
  gap: "0.5rem",
488
- justifyContent: "center"
648
+ padding: "0.75rem 1rem",
649
+ width: "100%"
489
650
  },
490
- children: [/* @__PURE__ */ jsxs("button", {
491
- onClick: () => K("metamask"),
492
- disabled: M,
493
- className: "_cppay-btn _cppay-btn-secondary",
494
- style: {
495
- display: "flex",
496
- alignItems: "center",
497
- justifyContent: "center",
498
- gap: "0.5rem",
499
- padding: "0.5rem 1rem",
500
- fontSize: "14px",
501
- flex: "1"
502
- },
503
- children: [/* @__PURE__ */ jsx("img", {
504
- src: metamask_default,
505
- alt: "MetaMask",
506
- style: {
507
- width: "20px",
508
- height: "20px"
509
- }
510
- }), /* @__PURE__ */ jsx("span", { children: "MetaMask" })]
511
- }), /* @__PURE__ */ jsxs("button", {
512
- onClick: () => K("walletconnect"),
513
- disabled: M,
514
- className: "_cppay-btn _cppay-btn-secondary",
515
- style: {
516
- display: "flex",
517
- alignItems: "center",
518
- justifyContent: "center",
519
- gap: "0.5rem",
520
- padding: "0.5rem 1rem",
521
- fontSize: "14px",
522
- flex: "1"
523
- },
524
- children: [/* @__PURE__ */ jsx("img", {
525
- src: walletconnect_default,
526
- alt: "WalletConnect",
527
- style: {
528
- width: "20px",
529
- height: "20px"
530
- }
531
- }), /* @__PURE__ */ jsx("span", { children: "WalletConnect" })]
532
- })]
651
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: R ? "连接中..." : "💳 连接钱包" })
533
652
  })
534
653
  }),
535
- /* @__PURE__ */ jsx("div", {
654
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
536
655
  className: "_cppay-section",
537
- children: /* @__PURE__ */ jsx("button", {
538
- onClick: Ee,
539
- disabled: y,
656
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
657
+ onClick: Se,
658
+ disabled: O,
540
659
  className: "_cppay-btn _cppay-btn-primary",
541
- children: y ? "检查中..." : "我已完成支付"
660
+ children: O ? "检查中..." : "我已完成支付"
542
661
  })
543
662
  }),
544
- /* @__PURE__ */ jsx("div", {
663
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
545
664
  className: "_cppay-section",
546
- children: /* @__PURE__ */ jsx("button", {
547
- onClick: () => v("select"),
548
- disabled: y,
665
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
666
+ onClick: () => T("select"),
667
+ disabled: E || O,
549
668
  className: "_cppay-btn _cppay-btn-text",
550
669
  children: "更改支付方式"
551
670
  })
@@ -562,12 +681,12 @@ const CppayProvider = ({ apikey: e, children: t }) => {
562
681
  r(!1);
563
682
  }, []), c = useCallback((e) => {
564
683
  i?.onSuccess?.(e), r(!1);
565
- }, [i]), Ce = useCallback((e) => {
684
+ }, [i]), l = useCallback((e) => {
566
685
  i?.onError?.(e);
567
686
  }, [i]);
568
- return /* @__PURE__ */ jsxs(CppayContext.Provider, {
687
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(CppayContext.Provider, {
569
688
  value: { showPayment: o },
570
- children: [t, i && /* @__PURE__ */ jsx(PaymentDialog_default, {
689
+ children: [t, i && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PaymentDialog_default, {
571
690
  open: n,
572
691
  onClose: s,
573
692
  apikey: e,
@@ -576,7 +695,7 @@ const CppayProvider = ({ apikey: e, children: t }) => {
576
695
  amount: i.amount,
577
696
  intervalDays: i.intervalDays,
578
697
  onSuccess: c,
579
- onError: Ce
698
+ onError: l
580
699
  })]
581
700
  });
582
701
  }, useCppayPayment = () => {