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

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 (140) hide show
  1. package/dist/AlertController-BPGQ5PgH.js +12787 -0
  2. package/dist/AlertController-CjTbf-Vd.cjs +10 -0
  3. package/dist/ApiController-Crww70p3.js +5652 -0
  4. package/dist/ApiController-DB43iwF1.cjs +4 -0
  5. package/dist/CaipNetworkUtil-Bd4HeTLY.js +204 -0
  6. package/dist/CaipNetworkUtil-Bg22uavB.cjs +1 -0
  7. package/dist/HelpersUtil-CeTmhhZv.js +1415 -0
  8. package/dist/HelpersUtil-L0eeYoE2.cjs +225 -0
  9. package/dist/PhArrowCircleDown-BBy_VuPx.js +46 -0
  10. package/dist/PhArrowCircleDown-BU4QSsA3.cjs +14 -0
  11. package/dist/PhArrowClockwise-D8C24T6J.js +46 -0
  12. package/dist/PhArrowClockwise-DWqhijc2.cjs +14 -0
  13. package/dist/PhArrowDown-Qm1T2ueY.cjs +14 -0
  14. package/dist/PhArrowDown-p9Tekztm.js +46 -0
  15. package/dist/PhArrowLeft-CEtyMFdq.cjs +14 -0
  16. package/dist/PhArrowLeft-CgSKs9Xe.js +46 -0
  17. package/dist/PhArrowRight-ZatyoD6R.cjs +14 -0
  18. package/dist/PhArrowRight-dMdzUgrx.js +46 -0
  19. package/dist/PhArrowSquareOut-CbP71Gny.js +46 -0
  20. package/dist/PhArrowSquareOut-HyssV9za.cjs +14 -0
  21. package/dist/PhArrowUp-Cz127u8b.cjs +14 -0
  22. package/dist/PhArrowUp-DNn-RQ7v.js +46 -0
  23. package/dist/PhArrowUpRight-BX6LlOL0.cjs +14 -0
  24. package/dist/PhArrowUpRight-OyGUhoGi.js +46 -0
  25. package/dist/PhArrowsClockwise-B6w_d2Gy.cjs +14 -0
  26. package/dist/PhArrowsClockwise-BWITTwAP.js +46 -0
  27. package/dist/PhArrowsDownUp-CHHtczH8.js +46 -0
  28. package/dist/PhArrowsDownUp-WYzjhvmQ.cjs +14 -0
  29. package/dist/PhArrowsLeftRight-BA0fjcLn.js +46 -0
  30. package/dist/PhArrowsLeftRight-bgyrYWLt.cjs +14 -0
  31. package/dist/PhBank-BInxTxLw.js +46 -0
  32. package/dist/PhBank-CZ_uTsAN.cjs +14 -0
  33. package/dist/PhBrowser--6CxS13p.js +46 -0
  34. package/dist/PhBrowser-BzOw0W8k.cjs +14 -0
  35. package/dist/PhCaretDown-D-zrPZN9.js +46 -0
  36. package/dist/PhCaretDown-DvF3M2iu.cjs +14 -0
  37. package/dist/PhCaretLeft-DND0SNkF.cjs +14 -0
  38. package/dist/PhCaretLeft-Dm6NsnIS.js +46 -0
  39. package/dist/PhCaretRight-BkRzbZ5m.js +46 -0
  40. package/dist/PhCaretRight-xQkT3bmO.cjs +14 -0
  41. package/dist/PhCaretUp-BEk_5jnn.cjs +14 -0
  42. package/dist/PhCaretUp-DZRZQ-T1.js +46 -0
  43. package/dist/PhCheck-BmwCUZuW.js +46 -0
  44. package/dist/PhCheck-C-u2QP3y.cjs +14 -0
  45. package/dist/PhCircleHalf--TfGDEAT.js +46 -0
  46. package/dist/PhCircleHalf-keQfI7pU.cjs +14 -0
  47. package/dist/PhClock-BvmbjmRx.cjs +14 -0
  48. package/dist/PhClock-DNCf5CVD.js +46 -0
  49. package/dist/PhCompass-B6tcbOFZ.js +46 -0
  50. package/dist/PhCompass-rWCQ_cR8.cjs +14 -0
  51. package/dist/PhCopy-CzC1olDO.cjs +14 -0
  52. package/dist/PhCopy-rbBTM6ME.js +46 -0
  53. package/dist/PhCreditCard-DOpOB0Pl.js +46 -0
  54. package/dist/PhCreditCard-D_qRVKuY.cjs +14 -0
  55. package/dist/PhCurrencyDollar-4EASQkjs.js +46 -0
  56. package/dist/PhCurrencyDollar-RVJJ6bQ3.cjs +14 -0
  57. package/dist/PhDesktop-CPaC-lRj.cjs +14 -0
  58. package/dist/PhDesktop-DZPux6RD.js +46 -0
  59. package/dist/PhDeviceMobile-BnXs4f3Q.cjs +14 -0
  60. package/dist/PhDeviceMobile-CcdKzyah.js +46 -0
  61. package/dist/PhDotsThree-19bbXQaM.js +46 -0
  62. package/dist/PhDotsThree-DSmFeW6i.cjs +14 -0
  63. package/dist/PhEnvelope-F7RF6h58.js +46 -0
  64. package/dist/PhEnvelope-QuTMQbE9.cjs +14 -0
  65. package/dist/PhFunnelSimple-B_FRP21W.js +46 -0
  66. package/dist/PhFunnelSimple-D4Ztu4ri.cjs +14 -0
  67. package/dist/PhGlobe-B8GrTk4S.cjs +14 -0
  68. package/dist/PhGlobe-BSPoRqTV.js +46 -0
  69. package/dist/PhIdentificationCard-fGDBGII0.cjs +14 -0
  70. package/dist/PhIdentificationCard-giQnti3K.js +46 -0
  71. package/dist/PhImage-BpUk8j27.cjs +14 -0
  72. package/dist/PhImage-PtBaftbW.js +46 -0
  73. package/dist/PhInfo-DQEDS02h.js +46 -0
  74. package/dist/PhInfo-V5wKJJoK.cjs +14 -0
  75. package/dist/PhLightbulb-Cisg0Myw.js +46 -0
  76. package/dist/PhLightbulb-xP9kaUlD.cjs +14 -0
  77. package/dist/PhMagnifyingGlass-C1cVSYf2.cjs +14 -0
  78. package/dist/PhMagnifyingGlass-DlkOfQXn.js +46 -0
  79. package/dist/PhPaperPlaneRight-C7Jp2jl_.js +46 -0
  80. package/dist/PhPaperPlaneRight-Kh3uxxIy.cjs +14 -0
  81. package/dist/PhPlus-BgHn57eW.js +46 -0
  82. package/dist/PhPlus-hJ6DZNjc.cjs +14 -0
  83. package/dist/PhPower-C369g1jk.js +46 -0
  84. package/dist/PhPower-DZ-SpUrD.cjs +14 -0
  85. package/dist/PhPuzzlePiece-B0oABcWl.js +46 -0
  86. package/dist/PhPuzzlePiece-DLtOLrcw.cjs +14 -0
  87. package/dist/PhQrCode-BT_hyeEa.js +46 -0
  88. package/dist/PhQrCode-yI6bLoYY.cjs +14 -0
  89. package/dist/PhQuestion-B1UeE96D.js +46 -0
  90. package/dist/PhQuestion-icSeWABx.cjs +14 -0
  91. package/dist/PhQuestionMark-CBVW9Awo.js +46 -0
  92. package/dist/PhQuestionMark-Cmhqu81E.cjs +14 -0
  93. package/dist/PhSealCheck-DTKS5QAx.cjs +14 -0
  94. package/dist/PhSealCheck-Dm2I2X7k.js +46 -0
  95. package/dist/PhSignOut-25xp33w2.cjs +14 -0
  96. package/dist/PhSignOut-BTTDADPY.js +46 -0
  97. package/dist/PhSpinner-Dbua7p0Y.js +46 -0
  98. package/dist/PhSpinner-DtpwblyA.cjs +14 -0
  99. package/dist/PhTrash-B3wUg10m.cjs +14 -0
  100. package/dist/PhTrash-gZghJkGX.js +46 -0
  101. package/dist/PhUser-Bvcv05IM.js +46 -0
  102. package/dist/PhUser-COPP3N-M.cjs +14 -0
  103. package/dist/PhVault-CFa5lrPU.cjs +14 -0
  104. package/dist/PhVault-DvlBF0VI.js +46 -0
  105. package/dist/PhWallet-CzJcybaO.cjs +14 -0
  106. package/dist/PhWallet-Do_lf9BX.js +46 -0
  107. package/dist/PhWarning-BrbSc7gQ.cjs +14 -0
  108. package/dist/PhWarning-DiIpJVsx.js +46 -0
  109. package/dist/PhWarningCircle-DE9BlEIc.js +46 -0
  110. package/dist/PhWarningCircle-F5Piypme.cjs +14 -0
  111. package/dist/PhX-BK3VZT8X.cjs +14 -0
  112. package/dist/PhX-CNlXuiat.js +46 -0
  113. package/dist/basic-C16-Uba1.js +3796 -0
  114. package/dist/basic-ChiCOE6E.cjs +1329 -0
  115. package/dist/chunk-2qRSBEuq.js +18 -0
  116. package/dist/chunk-DT80SxnK.cjs +1 -0
  117. package/dist/core-DKXmyfMB.js +2337 -0
  118. package/dist/core-PuDBroil.cjs +1 -0
  119. package/dist/dijkstra-CNhLvnjU.cjs +1 -0
  120. package/dist/dijkstra-kFl0HtsI.js +56 -0
  121. package/dist/features-BYfQH2hG.cjs +2 -0
  122. package/dist/features-_5Pi-gXV.js +245 -0
  123. package/dist/index.cjs +1 -1
  124. package/dist/index.es-DDV8bPq_.js +8311 -0
  125. package/dist/index.es-fgFnvPDP.cjs +19 -0
  126. package/dist/property-Dil4gG0H.cjs +3 -0
  127. package/dist/property-JsW5AM1M.js +578 -0
  128. package/dist/react.cjs +1 -1
  129. package/dist/react.js +133 -131
  130. package/dist/vue.cjs +1 -1
  131. package/dist/vue.js +107 -105
  132. package/dist/w3m-modal-BBvmkTyb.cjs +2416 -0
  133. package/dist/w3m-modal-CFhImDZN.js +5286 -0
  134. package/dist/walletconnect-B0zXLUON.cjs +17 -0
  135. package/dist/walletconnect-Bb4rv9-G.js +11314 -0
  136. package/dist/wui-list-item-BGvfYb1W.cjs +1452 -0
  137. package/dist/wui-list-item-C4wJpGBn.js +2123 -0
  138. package/package.json +2 -3
  139. package/dist/walletconnect-B0L70Mgc.js +0 -1239
  140. package/dist/walletconnect-B_n5YF-h.cjs +0 -8
@@ -0,0 +1,578 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC
4
+ * SPDX-License-Identifier: BSD-3-Clause
5
+ */
6
+ var r = globalThis, c$1 = r.ShadowRoot && (r.ShadyCSS === void 0 || r.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, a$1 = Symbol(), i$1 = /* @__PURE__ */ new WeakMap(), l$2 = class {
7
+ constructor(e, t, C) {
8
+ if (this._$cssResult$ = !0, C !== a$1) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
9
+ this.cssText = e, this.t = t;
10
+ }
11
+ get styleSheet() {
12
+ let e = this.o, i = this.t;
13
+ if (c$1 && e === void 0) {
14
+ let t = i !== void 0 && i.length === 1;
15
+ t && (e = i$1.get(i)), e === void 0 && ((this.o = e = new CSSStyleSheet()).replaceSync(this.cssText), t && i$1.set(i, e));
16
+ }
17
+ return e;
18
+ }
19
+ toString() {
20
+ return this.cssText;
21
+ }
22
+ }, h$1 = (e) => new l$2(typeof e == "string" ? e : e + "", void 0, a$1), p$3 = (e, ...t) => new l$2(e.length === 1 ? e[0] : t.reduce((t, i, C) => t + ((e) => {
23
+ if (e._$cssResult$ === !0) return e.cssText;
24
+ if (typeof e == "number") return e;
25
+ throw Error("Value passed to 'css' function must be a 'css' function result: " + e + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.");
26
+ })(i) + e[C + 1], e[0]), e, a$1), d$2 = (i, C) => {
27
+ if (c$1) i.adoptedStyleSheets = C.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
28
+ else for (let t of C) {
29
+ let C = document.createElement("style"), L = r.litNonce;
30
+ L !== void 0 && C.setAttribute("nonce", L), C.textContent = t.cssText, i.appendChild(C);
31
+ }
32
+ }, y$3 = c$1 ? (e) => e : (e) => e instanceof CSSStyleSheet ? ((e) => {
33
+ let t = "";
34
+ for (let i of e.cssRules) t += i.cssText;
35
+ return h$1(t);
36
+ })(e) : e, { is: b$2, defineProperty: v$1, getOwnPropertyDescriptor: S$1, getOwnPropertyNames: U$1, getOwnPropertySymbols: w$2, getPrototypeOf: A } = Object, a = globalThis, f$2 = a.trustedTypes, O$2 = f$2 ? f$2.emptyScript : "", p$2 = a.reactiveElementPolyfillSupport, l$1 = (e, t) => e, d = {
37
+ toAttribute(e, t) {
38
+ switch (t) {
39
+ case Boolean:
40
+ e = e ? O$2 : null;
41
+ break;
42
+ case Object:
43
+ case Array: e = e == null ? e : JSON.stringify(e);
44
+ }
45
+ return e;
46
+ },
47
+ fromAttribute(e, t) {
48
+ let i = e;
49
+ switch (t) {
50
+ case Boolean:
51
+ i = e !== null;
52
+ break;
53
+ case Number:
54
+ i = e === null ? null : Number(e);
55
+ break;
56
+ case Object:
57
+ case Array: try {
58
+ i = JSON.parse(e);
59
+ } catch {
60
+ i = null;
61
+ }
62
+ }
63
+ return i;
64
+ }
65
+ }, y = (e, t) => !b$2(e, t), E$1 = {
66
+ attribute: !0,
67
+ type: String,
68
+ converter: d,
69
+ reflect: !1,
70
+ hasChanged: y
71
+ };
72
+ Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), a.litPropertyMetadata ??= /* @__PURE__ */ new WeakMap();
73
+ var c = class extends HTMLElement {
74
+ static addInitializer(e) {
75
+ this._$Ei(), (this.l ??= []).push(e);
76
+ }
77
+ static get observedAttributes() {
78
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
79
+ }
80
+ static createProperty(e, t = E$1) {
81
+ if (t.state && (t.attribute = !1), this._$Ei(), this.elementProperties.set(e, t), !t.noAccessor) {
82
+ let i = Symbol(), C = this.getPropertyDescriptor(e, i, t);
83
+ C !== void 0 && v$1(this.prototype, e, C);
84
+ }
85
+ }
86
+ static getPropertyDescriptor(e, t, i) {
87
+ let { get: C, set: L } = S$1(this.prototype, e) ?? {
88
+ get() {
89
+ return this[t];
90
+ },
91
+ set(e) {
92
+ this[t] = e;
93
+ }
94
+ };
95
+ return {
96
+ get() {
97
+ return C?.call(this);
98
+ },
99
+ set(t) {
100
+ let gt = C?.call(this);
101
+ L.call(this, t), this.requestUpdate(e, gt, i);
102
+ },
103
+ configurable: !0,
104
+ enumerable: !0
105
+ };
106
+ }
107
+ static getPropertyOptions(e) {
108
+ return this.elementProperties.get(e) ?? E$1;
109
+ }
110
+ static _$Ei() {
111
+ if (this.hasOwnProperty(l$1("elementProperties"))) return;
112
+ let e = A(this);
113
+ e.finalize(), e.l !== void 0 && (this.l = [...e.l]), this.elementProperties = new Map(e.elementProperties);
114
+ }
115
+ static finalize() {
116
+ if (this.hasOwnProperty(l$1("finalized"))) return;
117
+ if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(l$1("properties"))) {
118
+ let e = this.properties, t = [...U$1(e), ...w$2(e)];
119
+ for (let i of t) this.createProperty(i, e[i]);
120
+ }
121
+ let e = this[Symbol.metadata];
122
+ if (e !== null) {
123
+ let t = litPropertyMetadata.get(e);
124
+ if (t !== void 0) for (let [e, i] of t) this.elementProperties.set(e, i);
125
+ }
126
+ this._$Eh = /* @__PURE__ */ new Map();
127
+ for (let [e, t] of this.elementProperties) {
128
+ let i = this._$Eu(e, t);
129
+ i !== void 0 && this._$Eh.set(i, e);
130
+ }
131
+ this.elementStyles = this.finalizeStyles(this.styles);
132
+ }
133
+ static finalizeStyles(e) {
134
+ let t = [];
135
+ if (Array.isArray(e)) {
136
+ let i = new Set(e.flat(Infinity).reverse());
137
+ for (let e of i) t.unshift(y$3(e));
138
+ } else e !== void 0 && t.push(y$3(e));
139
+ return t;
140
+ }
141
+ static _$Eu(e, t) {
142
+ let i = t.attribute;
143
+ return i === !1 ? void 0 : typeof i == "string" ? i : typeof e == "string" ? e.toLowerCase() : void 0;
144
+ }
145
+ constructor() {
146
+ super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
147
+ }
148
+ _$Ev() {
149
+ var e;
150
+ this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (e = this.constructor.l) == null || e.forEach((e) => e(this));
151
+ }
152
+ addController(e) {
153
+ var t;
154
+ (this._$EO ??= /* @__PURE__ */ new Set()).add(e), this.renderRoot !== void 0 && this.isConnected && ((t = e.hostConnected) == null || t.call(e));
155
+ }
156
+ removeController(e) {
157
+ var t;
158
+ (t = this._$EO) == null || t.delete(e);
159
+ }
160
+ _$E_() {
161
+ let e = /* @__PURE__ */ new Map(), t = this.constructor.elementProperties;
162
+ for (let i of t.keys()) this.hasOwnProperty(i) && (e.set(i, this[i]), delete this[i]);
163
+ e.size > 0 && (this._$Ep = e);
164
+ }
165
+ createRenderRoot() {
166
+ let e = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
167
+ return d$2(e, this.constructor.elementStyles), e;
168
+ }
169
+ connectedCallback() {
170
+ var e;
171
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(!0), (e = this._$EO) == null || e.forEach((e) => e.hostConnected?.call(e));
172
+ }
173
+ enableUpdating(e) {}
174
+ disconnectedCallback() {
175
+ var e;
176
+ (e = this._$EO) == null || e.forEach((e) => e.hostDisconnected?.call(e));
177
+ }
178
+ attributeChangedCallback(e, t, i) {
179
+ this._$AK(e, i);
180
+ }
181
+ _$EC(e, t) {
182
+ let i = this.constructor.elementProperties.get(e), C = this.constructor._$Eu(e, i);
183
+ if (C !== void 0 && i.reflect === !0) {
184
+ let L = (i.converter?.toAttribute === void 0 ? d : i.converter).toAttribute(t, i.type);
185
+ this._$Em = e, L == null ? this.removeAttribute(C) : this.setAttribute(C, L), this._$Em = null;
186
+ }
187
+ }
188
+ _$AK(e, t) {
189
+ let i = this.constructor, C = i._$Eh.get(e);
190
+ if (C !== void 0 && this._$Em !== C) {
191
+ let e = i.getPropertyOptions(C), L = typeof e.converter == "function" ? { fromAttribute: e.converter } : e.converter?.fromAttribute === void 0 ? d : e.converter;
192
+ this._$Em = C, this[C] = L.fromAttribute(t, e.type), this._$Em = null;
193
+ }
194
+ }
195
+ requestUpdate(e, t, i) {
196
+ if (e !== void 0) {
197
+ if (i ??= this.constructor.getPropertyOptions(e), !(i.hasChanged ?? y)(this[e], t)) return;
198
+ this.P(e, t, i);
199
+ }
200
+ this.isUpdatePending === !1 && (this._$ES = this._$ET());
201
+ }
202
+ P(e, t, i) {
203
+ this._$AL.has(e) || this._$AL.set(e, t), i.reflect === !0 && this._$Em !== e && (this._$Ej ??= /* @__PURE__ */ new Set()).add(e);
204
+ }
205
+ async _$ET() {
206
+ this.isUpdatePending = !0;
207
+ try {
208
+ await this._$ES;
209
+ } catch (e) {
210
+ Promise.reject(e);
211
+ }
212
+ let e = this.scheduleUpdate();
213
+ return e != null && await e, !this.isUpdatePending;
214
+ }
215
+ scheduleUpdate() {
216
+ return this.performUpdate();
217
+ }
218
+ performUpdate() {
219
+ var e;
220
+ if (!this.isUpdatePending) return;
221
+ if (!this.hasUpdated) {
222
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
223
+ for (let [e, t] of this._$Ep) this[e] = t;
224
+ this._$Ep = void 0;
225
+ }
226
+ let e = this.constructor.elementProperties;
227
+ if (e.size > 0) for (let [t, i] of e) i.wrapped !== !0 || this._$AL.has(t) || this[t] === void 0 || this.P(t, this[t], i);
228
+ }
229
+ let t = !1, i = this._$AL;
230
+ try {
231
+ t = this.shouldUpdate(i), t ? (this.willUpdate(i), (e = this._$EO) == null || e.forEach((e) => e.hostUpdate?.call(e)), this.update(i)) : this._$EU();
232
+ } catch (e) {
233
+ throw t = !1, this._$EU(), e;
234
+ }
235
+ t && this._$AE(i);
236
+ }
237
+ willUpdate(e) {}
238
+ _$AE(e) {
239
+ var t;
240
+ (t = this._$EO) == null || t.forEach((e) => e.hostUpdated?.call(e)), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(e)), this.updated(e);
241
+ }
242
+ _$EU() {
243
+ this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
244
+ }
245
+ get updateComplete() {
246
+ return this.getUpdateComplete();
247
+ }
248
+ getUpdateComplete() {
249
+ return this._$ES;
250
+ }
251
+ shouldUpdate(e) {
252
+ return !0;
253
+ }
254
+ update(e) {
255
+ this._$Ej &&= this._$Ej.forEach((e) => this._$EC(e, this[e])), this._$EU();
256
+ }
257
+ updated(e) {}
258
+ firstUpdated(e) {}
259
+ };
260
+ c.elementStyles = [], c.shadowRootOptions = { mode: "open" }, c[l$1("elementProperties")] = /* @__PURE__ */ new Map(), c[l$1("finalized")] = /* @__PURE__ */ new Map(), p$2?.({ ReactiveElement: c }), (a.reactiveElementVersions ??= []).push("2.0.4");
261
+ /**
262
+ * @license
263
+ * Copyright 2017 Google LLC
264
+ * SPDX-License-Identifier: BSD-3-Clause
265
+ */
266
+ var y$2 = globalThis, S = y$2.trustedTypes, I = S ? S.createPolicy("lit-html", { createHTML: (e) => e }) : void 0, W = "$lit$", p$1 = `lit$${Math.random().toFixed(9).slice(2)}$`, k = "?" + p$1, F = `<${k}>`, v = document, x = () => v.createComment(""), H = (e) => e === null || typeof e != "object" && typeof e != "function", D = Array.isArray, Z = (e) => D(e) || typeof e?.[Symbol.iterator] == "function", w$1 = "[ \n\f\r]", m = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, B = /-->/g, P$1 = />/g, u$1 = RegExp(`>|${w$1}(?:([^\\s"'>=/]+)(${w$1}*=${w$1}*(?:[^
267
+ \f\r"'\`<>=]|("|')|))|$)`, "g"), R = /'/g, U = /"/g, V = /^(?:script|style|textarea|title)$/i, O$1 = (e) => (t, ...i) => ({
268
+ _$litType$: e,
269
+ strings: t,
270
+ values: i
271
+ }), Y = O$1(1), tt = O$1(2), N = Symbol.for("lit-noChange"), _ = Symbol.for("lit-nothing"), j = /* @__PURE__ */ new WeakMap(), g$1 = v.createTreeWalker(v, 129);
272
+ function z(e, t) {
273
+ if (!Array.isArray(e) || !e.hasOwnProperty("raw")) throw Error("invalid template strings array");
274
+ return I === void 0 ? t : I.createHTML(t);
275
+ }
276
+ var q = (e, t) => {
277
+ let i = e.length - 1, C = [], L, gt = t === 2 ? "<svg>" : "", $ = m;
278
+ for (let t = 0; t < i; t++) {
279
+ let i = e[t], _t, vt, yt = -1, bt = 0;
280
+ for (; bt < i.length && ($.lastIndex = bt, vt = $.exec(i), vt !== null);) bt = $.lastIndex, $ === m ? vt[1] === "!--" ? $ = B : vt[1] === void 0 ? vt[2] === void 0 ? vt[3] !== void 0 && ($ = u$1) : (V.test(vt[2]) && (L = RegExp("</" + vt[2], "g")), $ = u$1) : $ = P$1 : $ === u$1 ? vt[0] === ">" ? ($ = L ?? m, yt = -1) : vt[1] === void 0 ? yt = -2 : (yt = $.lastIndex - vt[2].length, _t = vt[1], $ = vt[3] === void 0 ? u$1 : vt[3] === "\"" ? U : R) : $ === U || $ === R ? $ = u$1 : $ === B || $ === P$1 ? $ = m : ($ = u$1, L = void 0);
281
+ let xt = $ === u$1 && e[t + 1].startsWith("/>") ? " " : "";
282
+ gt += $ === m ? i + F : yt >= 0 ? (C.push(_t), i.slice(0, yt) + W + i.slice(yt) + p$1 + xt) : i + p$1 + (yt === -2 ? t : xt);
283
+ }
284
+ return [z(e, gt + (e[i] || "<?>") + (t === 2 ? "</svg>" : "")), C];
285
+ }, T = class e {
286
+ constructor({ strings: t, _$litType$: i }, C) {
287
+ let L;
288
+ this.parts = [];
289
+ let gt = 0, $ = 0, _t = t.length - 1, vt = this.parts, [yt, bt] = q(t, i);
290
+ if (this.el = e.createElement(yt, C), g$1.currentNode = this.el.content, i === 2) {
291
+ let e = this.el.content.firstChild;
292
+ e.replaceWith(...e.childNodes);
293
+ }
294
+ for (; (L = g$1.nextNode()) !== null && vt.length < _t;) {
295
+ if (L.nodeType === 1) {
296
+ if (L.hasAttributes()) for (let e of L.getAttributeNames()) if (e.endsWith(W)) {
297
+ let t = bt[$++], i = L.getAttribute(e).split(p$1), C = /([.?@])?(.*)/.exec(t);
298
+ vt.push({
299
+ type: 1,
300
+ index: gt,
301
+ name: C[2],
302
+ strings: i,
303
+ ctor: C[1] === "." ? J : C[1] === "?" ? K : C[1] === "@" ? Q : M
304
+ }), L.removeAttribute(e);
305
+ } else e.startsWith(p$1) && (vt.push({
306
+ type: 6,
307
+ index: gt
308
+ }), L.removeAttribute(e));
309
+ if (V.test(L.tagName)) {
310
+ let e = L.textContent.split(p$1), t = e.length - 1;
311
+ if (t > 0) {
312
+ L.textContent = S ? S.emptyScript : "";
313
+ for (let i = 0; i < t; i++) L.append(e[i], x()), g$1.nextNode(), vt.push({
314
+ type: 2,
315
+ index: ++gt
316
+ });
317
+ L.append(e[t], x());
318
+ }
319
+ }
320
+ } else if (L.nodeType === 8) if (L.data === k) vt.push({
321
+ type: 2,
322
+ index: gt
323
+ });
324
+ else {
325
+ let e = -1;
326
+ for (; (e = L.data.indexOf(p$1, e + 1)) !== -1;) vt.push({
327
+ type: 7,
328
+ index: gt
329
+ }), e += p$1.length - 1;
330
+ }
331
+ gt++;
332
+ }
333
+ }
334
+ static createElement(e, t) {
335
+ let i = v.createElement("template");
336
+ return i.innerHTML = e, i;
337
+ }
338
+ };
339
+ function f$1(e, t, i = e, C) {
340
+ var L;
341
+ if (t === N) return t;
342
+ let gt = C === void 0 ? i._$Cl : i._$Co?.[C], $ = H(t) ? void 0 : t._$litDirective$;
343
+ return gt?.constructor !== $ && ((L = gt?._$AO) == null || L.call(gt, !1), $ === void 0 ? gt = void 0 : (gt = new $(e), gt._$AT(e, i, C)), C === void 0 ? i._$Cl = gt : (i._$Co ??= [])[C] = gt), gt !== void 0 && (t = f$1(e, gt._$AS(e, t.values), gt, C)), t;
344
+ }
345
+ var G = class {
346
+ constructor(e, t) {
347
+ this._$AV = [], this._$AN = void 0, this._$AD = e, this._$AM = t;
348
+ }
349
+ get parentNode() {
350
+ return this._$AM.parentNode;
351
+ }
352
+ get _$AU() {
353
+ return this._$AM._$AU;
354
+ }
355
+ u(e) {
356
+ let { el: { content: t }, parts: i } = this._$AD, C = (e?.creationScope ?? v).importNode(t, !0);
357
+ g$1.currentNode = C;
358
+ let L = g$1.nextNode(), gt = 0, $ = 0, _t = i[0];
359
+ for (; _t !== void 0;) {
360
+ if (gt === _t.index) {
361
+ let t;
362
+ _t.type === 2 ? t = new b$1(L, L.nextSibling, this, e) : _t.type === 1 ? t = new _t.ctor(L, _t.name, _t.strings, this, e) : _t.type === 6 && (t = new X(L, this, e)), this._$AV.push(t), _t = i[++$];
363
+ }
364
+ gt !== _t?.index && (L = g$1.nextNode(), gt++);
365
+ }
366
+ return g$1.currentNode = v, C;
367
+ }
368
+ p(e) {
369
+ let t = 0;
370
+ for (let i of this._$AV) i !== void 0 && (i.strings === void 0 ? i._$AI(e[t]) : (i._$AI(e, i, t), t += i.strings.length - 2)), t++;
371
+ }
372
+ }, b$1 = class e {
373
+ get _$AU() {
374
+ return this._$AM?._$AU ?? this._$Cv;
375
+ }
376
+ constructor(e, t, i, C) {
377
+ this.type = 2, this._$AH = _, this._$AN = void 0, this._$AA = e, this._$AB = t, this._$AM = i, this.options = C, this._$Cv = C?.isConnected ?? !0;
378
+ }
379
+ get parentNode() {
380
+ let e = this._$AA.parentNode, t = this._$AM;
381
+ return t !== void 0 && e?.nodeType === 11 && (e = t.parentNode), e;
382
+ }
383
+ get startNode() {
384
+ return this._$AA;
385
+ }
386
+ get endNode() {
387
+ return this._$AB;
388
+ }
389
+ _$AI(e, t = this) {
390
+ e = f$1(this, e, t), H(e) ? e === _ || e == null || e === "" ? (this._$AH !== _ && this._$AR(), this._$AH = _) : e !== this._$AH && e !== N && this._(e) : e._$litType$ === void 0 ? e.nodeType === void 0 ? Z(e) ? this.k(e) : this._(e) : this.T(e) : this.$(e);
391
+ }
392
+ S(e) {
393
+ return this._$AA.parentNode.insertBefore(e, this._$AB);
394
+ }
395
+ T(e) {
396
+ this._$AH !== e && (this._$AR(), this._$AH = this.S(e));
397
+ }
398
+ _(e) {
399
+ this._$AH !== _ && H(this._$AH) ? this._$AA.nextSibling.data = e : this.T(v.createTextNode(e)), this._$AH = e;
400
+ }
401
+ $(e) {
402
+ let { values: t, _$litType$: i } = e, C = typeof i == "number" ? this._$AC(e) : (i.el === void 0 && (i.el = T.createElement(z(i.h, i.h[0]), this.options)), i);
403
+ if (this._$AH?._$AD === C) this._$AH.p(t);
404
+ else {
405
+ let e = new G(C, this), i = e.u(this.options);
406
+ e.p(t), this.T(i), this._$AH = e;
407
+ }
408
+ }
409
+ _$AC(e) {
410
+ let t = j.get(e.strings);
411
+ return t === void 0 && j.set(e.strings, t = new T(e)), t;
412
+ }
413
+ k(t) {
414
+ D(this._$AH) || (this._$AH = [], this._$AR());
415
+ let i = this._$AH, C, L = 0;
416
+ for (let gt of t) L === i.length ? i.push(C = new e(this.S(x()), this.S(x()), this, this.options)) : C = i[L], C._$AI(gt), L++;
417
+ L < i.length && (this._$AR(C && C._$AB.nextSibling, L), i.length = L);
418
+ }
419
+ _$AR(e = this._$AA.nextSibling, t) {
420
+ var i;
421
+ for ((i = this._$AP) == null || i.call(this, !1, !0, t); e && e !== this._$AB;) {
422
+ let t = e.nextSibling;
423
+ e.remove(), e = t;
424
+ }
425
+ }
426
+ setConnected(e) {
427
+ var t;
428
+ this._$AM === void 0 && (this._$Cv = e, (t = this._$AP) == null || t.call(this, e));
429
+ }
430
+ }, M = class {
431
+ get tagName() {
432
+ return this.element.tagName;
433
+ }
434
+ get _$AU() {
435
+ return this._$AM._$AU;
436
+ }
437
+ constructor(e, t, i, C, L) {
438
+ this.type = 1, this._$AH = _, this._$AN = void 0, this.element = e, this.name = t, this._$AM = C, this.options = L, i.length > 2 || i[0] !== "" || i[1] !== "" ? (this._$AH = Array(i.length - 1).fill(/* @__PURE__ */ new String()), this.strings = i) : this._$AH = _;
439
+ }
440
+ _$AI(e, t = this, i, C) {
441
+ let L = this.strings, gt = !1;
442
+ if (L === void 0) e = f$1(this, e, t, 0), gt = !H(e) || e !== this._$AH && e !== N, gt && (this._$AH = e);
443
+ else {
444
+ let C = e, $, _t;
445
+ for (e = L[0], $ = 0; $ < L.length - 1; $++) _t = f$1(this, C[i + $], t, $), _t === N && (_t = this._$AH[$]), gt ||= !H(_t) || _t !== this._$AH[$], _t === _ ? e = _ : e !== _ && (e += (_t ?? "") + L[$ + 1]), this._$AH[$] = _t;
446
+ }
447
+ gt && !C && this.j(e);
448
+ }
449
+ j(e) {
450
+ e === _ ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, e ?? "");
451
+ }
452
+ }, J = class extends M {
453
+ constructor() {
454
+ super(...arguments), this.type = 3;
455
+ }
456
+ j(e) {
457
+ this.element[this.name] = e === _ ? void 0 : e;
458
+ }
459
+ }, K = class extends M {
460
+ constructor() {
461
+ super(...arguments), this.type = 4;
462
+ }
463
+ j(e) {
464
+ this.element.toggleAttribute(this.name, !!e && e !== _);
465
+ }
466
+ }, Q = class extends M {
467
+ constructor(e, t, i, C, L) {
468
+ super(e, t, i, C, L), this.type = 5;
469
+ }
470
+ _$AI(e, t = this) {
471
+ if ((e = f$1(this, e, t, 0) ?? _) === N) return;
472
+ let i = this._$AH, C = e === _ && i !== _ || e.capture !== i.capture || e.once !== i.once || e.passive !== i.passive, L = e !== _ && (i === _ || C);
473
+ C && this.element.removeEventListener(this.name, this, i), L && this.element.addEventListener(this.name, this, e), this._$AH = e;
474
+ }
475
+ handleEvent(e) {
476
+ typeof this._$AH == "function" ? this._$AH.call(this.options?.host ?? this.element, e) : this._$AH.handleEvent(e);
477
+ }
478
+ }, X = class {
479
+ constructor(e, t, i) {
480
+ this.element = e, this.type = 6, this._$AN = void 0, this._$AM = t, this.options = i;
481
+ }
482
+ get _$AU() {
483
+ return this._$AM._$AU;
484
+ }
485
+ _$AI(e) {
486
+ f$1(this, e);
487
+ }
488
+ }, E = y$2.litHtmlPolyfillSupport;
489
+ E?.(T, b$1), (y$2.litHtmlVersions ??= []).push("3.1.4");
490
+ var et = (e, t, i) => {
491
+ let C = i?.renderBefore ?? t, L = C._$litPart$;
492
+ if (L === void 0) {
493
+ let e = i?.renderBefore ?? null;
494
+ C._$litPart$ = L = new b$1(t.insertBefore(x(), e), e, void 0, i ?? {});
495
+ }
496
+ return L._$AI(e), L;
497
+ }, n = class extends c {
498
+ constructor() {
499
+ super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0;
500
+ }
501
+ createRenderRoot() {
502
+ var e;
503
+ let t = super.createRenderRoot();
504
+ return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
505
+ }
506
+ update(e) {
507
+ let t = this.render();
508
+ this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(e), this._$Do = et(t, this.renderRoot, this.renderOptions);
509
+ }
510
+ connectedCallback() {
511
+ var e;
512
+ super.connectedCallback(), (e = this._$Do) == null || e.setConnected(!0);
513
+ }
514
+ disconnectedCallback() {
515
+ var e;
516
+ super.disconnectedCallback(), (e = this._$Do) == null || e.setConnected(!1);
517
+ }
518
+ render() {
519
+ return N;
520
+ }
521
+ }, o;
522
+ n._$litElement$ = !0, n.finalized = !0, (o = globalThis.litElementHydrateSupport) == null || o.call(globalThis, { LitElement: n });
523
+ var s$1 = globalThis.litElementPolyfillSupport;
524
+ s$1?.({ LitElement: n }), (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.0.6");
525
+ /**
526
+ * @license
527
+ * Copyright 2017 Google LLC
528
+ * SPDX-License-Identifier: BSD-3-Clause
529
+ */
530
+ var s = (e) => (t, i) => {
531
+ i === void 0 ? customElements.define(e, t) : i.addInitializer(() => {
532
+ customElements.define(e, t);
533
+ });
534
+ }, h = Object.defineProperty, f = Object.defineProperties, y$1 = Object.getOwnPropertyDescriptors, p = Object.getOwnPropertySymbols, g = Object.prototype.hasOwnProperty, P = Object.prototype.propertyIsEnumerable, d$1 = (e, t, i) => t in e ? h(e, t, {
535
+ enumerable: !0,
536
+ configurable: !0,
537
+ writable: !0,
538
+ value: i
539
+ }) : e[t] = i, l = (e, t) => {
540
+ for (var i in t ||= {}) g.call(t, i) && d$1(e, i, t[i]);
541
+ if (p) for (var i of p(t)) P.call(t, i) && d$1(e, i, t[i]);
542
+ return e;
543
+ }, u = (e, t) => f(e, y$1(t)), b = {
544
+ attribute: !0,
545
+ type: String,
546
+ converter: d,
547
+ reflect: !1,
548
+ hasChanged: y
549
+ }, w = (e = b, t, i) => {
550
+ let { kind: C, metadata: L } = i, gt = globalThis.litPropertyMetadata.get(L);
551
+ if (gt === void 0 && globalThis.litPropertyMetadata.set(L, gt = /* @__PURE__ */ new Map()), gt.set(i.name, e), C === "accessor") {
552
+ let { name: C } = i;
553
+ return {
554
+ set(i) {
555
+ let L = t.get.call(this);
556
+ t.set.call(this, i), this.requestUpdate(C, L, e);
557
+ },
558
+ init(t) {
559
+ return t !== void 0 && this.P(C, void 0, e), t;
560
+ }
561
+ };
562
+ }
563
+ if (C === "setter") {
564
+ let { name: C } = i;
565
+ return function(i) {
566
+ let L = this[C];
567
+ t.call(this, i), this.requestUpdate(C, L, e);
568
+ };
569
+ }
570
+ throw Error("Unsupported decorator location: " + C);
571
+ };
572
+ function O(e) {
573
+ return (t, i) => typeof i == "object" ? w(e, t, i) : ((e, t, i) => {
574
+ let C = t.hasOwnProperty(i);
575
+ return t.constructor.createProperty(i, C ? u(l({}, e), { wrapped: !0 }) : e), C ? Object.getOwnPropertyDescriptor(t, i) : void 0;
576
+ })(e, t, i);
577
+ }
578
+ export { tt as a, Y as i, s as n, p$3 as o, n as r, O as t };
package/dist/react.cjs CHANGED
@@ -1 +1 @@
1
- const e=require(`./walletconnect-B_n5YF-h.cjs`),t=require(`./cppay-DnxPUyM2.cjs`);let n=require(`rxjs`),r=require(`rxjs/operators`),i=require(`viem`),a=require(`viem/chains`),o=require(`@walletconnect/ethereum-provider`);o=e.o(o);let s=require(`react`);s=e.o(s);let c=require(`react/jsx-runtime`);var l=e.o(e.r(),1),u=({open:u,onClose:d,apikey:f,plain:p,orderId:m,amount:h,intervalDays:g,onExpired:_,onSuccess:v,onFailed:y,onError:b})=>{let x=(0,s.useMemo)(()=>new t.t(f),[f]),[S,C]=(0,s.useState)(`select`),[w,T]=(0,s.useState)(!1),[E,D]=(0,s.useState)([]),[O,k]=(0,s.useState)(``),[A,j]=(0,s.useState)(``),[M,N]=(0,s.useState)(``),[P,F]=(0,s.useState)(``),[I,L]=(0,s.useState)(!1),[R,z]=(0,s.useState)(null),B=(0,s.useRef)(null),V=(0,s.useRef)(null),H=(0,s.useMemo)(()=>E.find(e=>e.chain===O),[E,O]),U=(0,s.useMemo)(()=>H?.tokens||[],[H]),W=(0,s.useMemo)(()=>U.find(e=>e.symbol===A),[U,A]),G=e=>[`USDT`,`USDC`,`BUSD`,`DAI`,`TUSD`,`USDD`,`FDUSD`].includes(e.toUpperCase())?2:6,K=e=>({ETH:a.mainnet,BSC:a.bsc,Polygon:a.polygon,Arbitrum:a.arbitrum,Optimism:a.optimism,Base:a.base})[e]||a.mainnet,q=(e,t)=>{let n=parseFloat(e);return isNaN(n)?`0`:n.toFixed(t).replace(/\.?0+$/,``)},J=(0,s.useMemo)(()=>{if(!A||!W)return`0`;let e=parseFloat(W.price);if(isNaN(e)||e===0)return`0`;let t=G(A);return q((parseFloat(h)/e).toFixed(t),t)},[h,A,W]),ee=async()=>{try{T(!0);let e=await x.getSupportedChains();D(e),e.length>0&&k(e[0].chain)}catch(e){b?.(e)}finally{T(!1)}},Y=async e=>{try{if(L(!0),e===`metamask`){if(typeof window<`u`&&window.ethereum?.isMetaMask){let e=await window.ethereum.request({method:`eth_requestAccounts`});if(e&&e.length>0){F(e[0]),z(`metamask`);return}}throw Error(`请安装 MetaMask 扩展`)}if(e===`walletconnect`){let e=await o.default.init({projectId:`8d2e1854d3f1782e45aa15fbd8938894`,chains:[1],showQrModal:!0,optionalChains:[56,137,42161,10,8453],methods:[`eth_sendTransaction`,`eth_signTransaction`,`eth_sign`,`personal_sign`,`eth_signTypedData`],events:[`chainChanged`,`accountsChanged`],metadata:{name:`Cppay`,description:`Cppay Payment Gateway`,url:typeof window<`u`?window.location.origin:`https://cppay.com`,icons:[`https://cppay.com/icon.png`]},rpcMap:{1:`https://ethereum.publicnode.com`,56:`https://bsc-dataseed.binance.org`,137:`https://polygon-rpc.com`,42161:`https://arb1.arbitrum.io/rpc`,10:`https://mainnet.optimism.io`,8453:`https://mainnet.base.org`}});await e.enable();let t=await e.request({method:`eth_accounts`});t&&t.length>0&&(F(t[0]),z(`walletconnect`),B.current=e)}}catch(e){console.error(`钱包连接失败:`,e),b?.(e)}finally{L(!1)}},X=async e=>{let t;if(t=R===`walletconnect`?B.current:window.ethereum,t)try{await t.request({method:`wallet_switchEthereumChain`,params:[{chainId:`0x${e.toString(16)}`}]})}catch(e){throw e.code===4902?Error(`请在钱包中添加该网络`):e}},te=async()=>{if(!(!P||!Z.current||!W))try{T(!0);let e=Z.current,t=K(O);await X(H.chainId);let n=(0,i.createWalletClient)({account:P,chain:t,transport:(0,i.custom)(R===`walletconnect`?B.current:window.ethereum)});if(W.address){let t=await n.writeContract({address:W.address,abi:[{name:`transfer`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`to`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`transfer`,args:[e.receiveAddress,(0,i.parseUnits)(e.paymentAmount,W.decimals)],chain:null});console.log(`转账交易哈希:`,t)}else{let t=await n.sendTransaction({to:e.receiveAddress,value:(0,i.parseUnits)(e.paymentAmount,W.decimals),chain:null});console.log(`转账交易哈希:`,t)}Q(e.paymentId)}catch(e){console.error(`钱包支付失败:`,e),b?.(e)}finally{T(!1)}},ne=async()=>{if(!(!P||!Z.current||!W))try{T(!0);let e=Z.current,t=K(O);await X(H.chainId);let n=(0,i.createWalletClient)({account:P,chain:t,transport:(0,i.custom)(R===`walletconnect`?B.current:window.ethereum)});if(!W.address)throw Error(`订阅支付不支持原生代币`);let r=await n.writeContract({address:W.address,abi:[{name:`approve`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`spender`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`approve`,args:[e.spenderAddress,(0,i.parseUnits)(e.approveAmount,W.decimals)],chain:null});console.log(`授权交易哈希:`,r),Q(e.subscriptionId)}catch(e){console.error(`钱包授权失败:`,e),b?.(e)}finally{T(!1)}},re=async()=>{if(!P){b?.(Error(`请先连接钱包`));return}p===`one-time`?await te():p===`subscription`&&await ne()},Z=(0,s.useRef)(null),ie=async()=>{if(!(!O||!A))try{T(!0);let e=``;p===`one-time`?(Z.current=await x.createOnetimePayment({paymentChain:O,paymentToken:A,orderId:m,amount:J}),e=`${O.toLowerCase()}:${Z.current.receiveAddress}?amount=${Z.current.paymentAmount}`):p===`subscription`&&(Z.current=await x.createSubscriptionPayment({paymentChain:O,paymentToken:A,orderId:m,amountOfUsd:J,intervalDays:g||30}),e=`${O.toLowerCase()}:${Z.current.spenderAddress}?amount=${Z.current.approveAmount}`),C(`payment`),N(await l.toDataURL(e,{width:200,margin:2,errorCorrectionLevel:`H`}))}catch(e){b?.(e)}finally{T(!1)}},ae=async()=>{if(Z.current)try{T(!0),p===`one-time`?Q(Z.current.paymentId):p===`subscription`&&Q(Z.current.subscriptionId)}catch(e){console.error(`支付状态检查错误:`,e),b?.(e),T(!1)}},Q=e=>{let t=()=>(0,n.defer)(()=>p===`subscription`?x.checkSubscriptionPaymentStatus({subscriptionId:e}):x.checkOnetimePaymentStatus({paymentId:e})).pipe((0,r.timeout)(15e3),(0,r.retry)({count:3,delay:2e3}));V.current?.unsubscribe(),V.current=t().pipe((0,r.expand)(e=>e.status===`pending`?(0,n.timer)(2e3).pipe((0,r.switchMap)(()=>t())):n.EMPTY),(0,r.tap)(e=>{e.status===`expired`&&(T(!1),_?.(e)),e.status===`paid`&&(T(!1),C(`success`),v?.(e)),e.status===`failed`&&(T(!1),y?.(e)),e.status===`approved`&&(T(!1),C(`success`),v?.(e))})).subscribe({error:e=>{console.error(`支付状态检查错误:`,e),T(!1),b?.(e)}})},oe=async()=>{if(!Z.current)return;let e=p===`subscription`?Z.current.spenderAddress:Z.current.receiveAddress;e&&await navigator.clipboard.writeText(e)},$=()=>{w||(d(),setTimeout(()=>{C(`select`),Z.current=null},300))};return(0,s.useEffect)(()=>{u&&E.length===0&&ee()},[u]),(0,s.useEffect)(()=>{U.length>0&&j(U[0].symbol)},[U]),(0,s.useEffect)(()=>()=>{V.current?.unsubscribe()},[]),u?(0,c.jsx)(`div`,{className:`_cppay-overlay`,onClick:e=>e.target===e.currentTarget&&!w&&$(),children:(0,c.jsxs)(`div`,{className:`_cppay-dialog`,children:[(0,c.jsxs)(`div`,{className:`_cppay-header`,children:[(0,c.jsx)(`h2`,{className:`_cppay-title`,children:S===`select`?`选择支付方式`:`完成支付`}),(0,c.jsx)(`button`,{onClick:$,disabled:w,className:`_cppay-close-btn`,children:(0,c.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,c.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]}),(0,c.jsx)(`div`,{className:`_cppay-content`,children:S===`success`?(0,c.jsxs)(`div`,{style:{textAlign:`center`,padding:`2rem 0`},children:[(0,c.jsx)(`div`,{style:{fontSize:`64px`,marginBottom:`1rem`},children:`✅`}),(0,c.jsx)(`h3`,{style:{fontSize:`1.5rem`,fontWeight:600,color:`#10b981`,margin:`0 0 0.5rem 0`},children:p===`subscription`?`授权成功!`:`支付成功!`}),(0,c.jsx)(`p`,{style:{color:`#6b7280`,margin:0},children:p===`subscription`?`订阅已激活`:`交易已完成`})]}):S===`select`?(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`div`,{className:`_cppay-section`,children:[(0,c.jsx)(`label`,{className:`_cppay-label`,children:`支付网络`}),(0,c.jsx)(`div`,{className:`_cppay-grid`,children:E.map(e=>(0,c.jsxs)(`button`,{onClick:()=>k(e.chain),className:`_cppay-select-btn ${O===e.chain?`_cppay-selected`:``}`,children:[e.icon&&(0,c.jsx)(`img`,{src:e.icon,alt:e.chain}),(0,c.jsx)(`span`,{children:e.chain})]},e.chain))})]}),(0,c.jsxs)(`div`,{className:`_cppay-section`,children:[(0,c.jsx)(`label`,{className:`_cppay-label`,children:`支付代币`}),(0,c.jsx)(`div`,{className:`_cppay-grid`,children:U.map(e=>(0,c.jsxs)(`button`,{onClick:()=>j(e.symbol),className:`_cppay-select-btn ${A===e.symbol?`_cppay-selected`:``}`,children:[e.icon&&(0,c.jsx)(`img`,{src:e.icon,alt:e.symbol}),(0,c.jsx)(`span`,{children:e.symbol})]},e.symbol))})]}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`div`,{className:`_cppay-price-box`,children:(0,c.jsxs)(`div`,{className:`_cppay-price-row`,children:[(0,c.jsx)(`span`,{className:`_cppay-price-label`,children:`支付金额`}),(0,c.jsxs)(`div`,{className:`_cppay-price-amount`,children:[(0,c.jsxs)(`div`,{className:`_cppay-price-main`,children:[J,` `,A]}),(0,c.jsxs)(`div`,{className:`_cppay-price-sub`,children:[`≈ $`,h]})]})]})})}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`button`,{onClick:ie,disabled:!O||!A||w,className:`_cppay-btn _cppay-btn-primary`,children:w?`处理中...`:`继续支付`})})]}):(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`div`,{className:`_cppay-qr-container`,children:(0,c.jsx)(`div`,{className:`_cppay-qr-code`,children:M&&(0,c.jsx)(`img`,{src:M,alt:`Payment QR Code`,style:{width:`160px`,height:`160px`,display:`block`}})})}),(0,c.jsxs)(`div`,{className:`_cppay-section`,children:[(0,c.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,c.jsx)(`div`,{className:`_cppay-info-label`,children:p===`subscription`?`授权金额`:`支付金额`}),(0,c.jsx)(`div`,{className:`_cppay-info-value`,children:p===`subscription`?`${q(Z.current.approveAmount,G(A))} ${A}`:`${q(Z.current.paymentAmount,G(A))} ${A}`})]}),(0,c.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,c.jsx)(`div`,{className:`_cppay-info-label`,children:p===`subscription`?`授权合约地址`:`支付地址`}),(0,c.jsxs)(`div`,{className:`_cppay-address-row`,children:[(0,c.jsx)(`code`,{children:p===`subscription`?Z.current.spenderAddress:Z.current.receiveAddress}),(0,c.jsx)(`button`,{onClick:oe,className:`_cppay-copy-btn`,title:`复制地址`,children:(0,c.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,c.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})})})]})]}),p===`subscription`&&(0,c.jsxs)(`div`,{className:`_cppay-info-box`,style:{background:`#fff3cd`,borderColor:`#ffc107`},children:[(0,c.jsx)(`div`,{className:`_cppay-info-label`,style:{color:`#856404`},children:`📌 订阅说明`}),(0,c.jsx)(`div`,{className:`_cppay-info-value`,style:{fontSize:`12px`,color:`#856404`},children:`订阅支付需要授权代币给合约地址,系统将按周期自动扣款。授权后无需每次手动支付。`})]})]}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:P?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`button`,{onClick:re,disabled:w,className:`_cppay-btn _cppay-btn-primary`,children:w?p===`subscription`?`授权中...`:`支付中...`:p===`subscription`?`💳 钱包授权`:`💳 钱包支付`}),(0,c.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`8px`,fontSize:`12px`,color:`#666`},children:[`已连接: `,P.slice(0,6),`...`,P.slice(-4)]})]}):(0,c.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:`0.5rem`,justifyContent:`center`},children:[(0,c.jsxs)(`button`,{onClick:()=>Y(`metamask`),disabled:I,className:`_cppay-btn _cppay-btn-secondary`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`0.5rem`,padding:`0.5rem 1rem`,fontSize:`14px`,flex:`1`},children:[(0,c.jsx)(`img`,{src:e.n,alt:`MetaMask`,style:{width:`20px`,height:`20px`}}),(0,c.jsx)(`span`,{children:`MetaMask`})]}),(0,c.jsxs)(`button`,{onClick:()=>Y(`walletconnect`),disabled:I,className:`_cppay-btn _cppay-btn-secondary`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`0.5rem`,padding:`0.5rem 1rem`,fontSize:`14px`,flex:`1`},children:[(0,c.jsx)(`img`,{src:e.t,alt:`WalletConnect`,style:{width:`20px`,height:`20px`}}),(0,c.jsx)(`span`,{children:`WalletConnect`})]})]})}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`button`,{onClick:ae,disabled:w,className:`_cppay-btn _cppay-btn-primary`,children:w?`检查中...`:`我已完成支付`})}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`button`,{onClick:()=>C(`select`),disabled:w,className:`_cppay-btn _cppay-btn-text`,children:`更改支付方式`})})]})})]})}):null},d=s.default.memo(u),f=(0,s.createContext)(null);const p=({apikey:e,children:t})=>{let[n,r]=(0,s.useState)(!1),[i,a]=(0,s.useState)(null),o=(0,s.useCallback)(e=>{a(e),r(!0)},[]),l=(0,s.useCallback)(()=>{r(!1)},[]),u=(0,s.useCallback)(e=>{i?.onSuccess?.(e),r(!1)},[i]),p=(0,s.useCallback)(e=>{i?.onError?.(e)},[i]);return(0,c.jsxs)(f.Provider,{value:{showPayment:o},children:[t,i&&(0,c.jsx)(d,{open:n,onClose:l,apikey:e,plain:i.plain,orderId:i.orderId,amount:i.amount,intervalDays:i.intervalDays,onSuccess:u,onError:p})]})},m=()=>{let e=(0,s.useContext)(f);if(!e)throw Error(`useCppayPayment must be used within CppayProvider`);return e};e.i(e.a),exports.CppayProvider=p,exports.PaymentDialog=d,exports.useCppayPayment=m;
1
+ const e=require(`./chunk-DT80SxnK.cjs`),t=require(`./cppay-DnxPUyM2.cjs`),n=require(`./walletconnect-B0zXLUON.cjs`);require(`./dijkstra-CNhLvnjU.cjs`),require(`./index.es-fgFnvPDP.cjs`);let r=require(`rxjs`),i=require(`rxjs/operators`),a=require(`viem`),o=require(`viem/chains`),s=require(`react`);s=e.o(s);let c=require(`react/jsx-runtime`);var l=e.o(n.i(),1),u=({open:e,onClose:u,apikey:d,plain:f,orderId:p,amount:m,intervalDays:h,onExpired:g,onSuccess:_,onFailed:v,onError:y})=>{let b=(0,s.useMemo)(()=>new t.t(d),[d]),[x,S]=(0,s.useState)(`select`),[C,w]=(0,s.useState)(!1),[T,E]=(0,s.useState)([]),[D,O]=(0,s.useState)(``),[k,A]=(0,s.useState)(``),[j,M]=(0,s.useState)(``),[N,P]=(0,s.useState)(``),[F,I]=(0,s.useState)(!1),[L,R]=(0,s.useState)(null),z=(0,s.useRef)(null),B=(0,s.useRef)(null),V=(0,s.useMemo)(()=>T.find(e=>e.chain===D),[T,D]),H=(0,s.useMemo)(()=>V?.tokens||[],[V]),U=(0,s.useMemo)(()=>H.find(e=>e.symbol===k),[H,k]),W=e=>[`USDT`,`USDC`,`BUSD`,`DAI`,`TUSD`,`USDD`,`FDUSD`].includes(e.toUpperCase())?2:6,G=e=>({ETH:o.mainnet,BSC:o.bsc,Polygon:o.polygon,Arbitrum:o.arbitrum,Optimism:o.optimism,Base:o.base})[e]||o.mainnet,K=(e,t)=>{let n=parseFloat(e);return isNaN(n)?`0`:n.toFixed(t).replace(/\.?0+$/,``)},q=(0,s.useMemo)(()=>{if(!k||!U)return`0`;let e=parseFloat(U.price);if(isNaN(e)||e===0)return`0`;let t=W(k);return K((parseFloat(m)/e).toFixed(t),t)},[m,k,U]),J=async()=>{try{w(!0);let e=await b.getSupportedChains();E(e),e.length>0&&O(e[0].chain)}catch(e){y?.(e)}finally{w(!1)}},Y=async e=>{try{if(I(!0),e===`metamask`){if(typeof window<`u`&&window.ethereum?.isMetaMask){let e=await window.ethereum.request({method:`eth_requestAccounts`});if(e&&e.length>0){P(e[0]),R(`metamask`);return}}throw Error(`请安装 MetaMask 扩展`)}if(e===`walletconnect`){let e=await n.r.init({projectId:`8d2e1854d3f1782e45aa15fbd8938894`,chains:[1],showQrModal:!0,optionalChains:[56,137,42161,10,8453],methods:[`eth_sendTransaction`,`eth_signTransaction`,`eth_sign`,`personal_sign`,`eth_signTypedData`],events:[`chainChanged`,`accountsChanged`],metadata:{name:`Cppay`,description:`Cppay Payment Gateway`,url:typeof window<`u`?window.location.origin:`https://cppay.com`,icons:[`https://cppay.com/icon.png`]},rpcMap:{1:`https://ethereum.publicnode.com`,56:`https://bsc-dataseed.binance.org`,137:`https://polygon-rpc.com`,42161:`https://arb1.arbitrum.io/rpc`,10:`https://mainnet.optimism.io`,8453:`https://mainnet.base.org`}});await e.enable();let t=await e.request({method:`eth_accounts`});t&&t.length>0&&(P(t[0]),R(`walletconnect`),z.current=e)}}catch(e){console.error(`钱包连接失败:`,e),y?.(e)}finally{I(!1)}},X=async e=>{let t;if(t=L===`walletconnect`?z.current:window.ethereum,t)try{await t.request({method:`wallet_switchEthereumChain`,params:[{chainId:`0x${e.toString(16)}`}]})}catch(e){throw e.code===4902?Error(`请在钱包中添加该网络`):e}},ee=async()=>{if(!(!N||!Z.current||!U))try{w(!0);let e=Z.current,t=G(D);await X(V.chainId);let n=(0,a.createWalletClient)({account:N,chain:t,transport:(0,a.custom)(L===`walletconnect`?z.current:window.ethereum)});if(U.address){let t=await n.writeContract({address:U.address,abi:[{name:`transfer`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`to`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`transfer`,args:[e.receiveAddress,(0,a.parseUnits)(e.paymentAmount,U.decimals)],chain:null});console.log(`转账交易哈希:`,t)}else{let t=await n.sendTransaction({to:e.receiveAddress,value:(0,a.parseUnits)(e.paymentAmount,U.decimals),chain:null});console.log(`转账交易哈希:`,t)}Q(e.paymentId)}catch(e){console.error(`钱包支付失败:`,e),y?.(e)}finally{w(!1)}},te=async()=>{if(!(!N||!Z.current||!U))try{w(!0);let e=Z.current,t=G(D);await X(V.chainId);let n=(0,a.createWalletClient)({account:N,chain:t,transport:(0,a.custom)(L===`walletconnect`?z.current:window.ethereum)});if(!U.address)throw Error(`订阅支付不支持原生代币`);let r=await n.writeContract({address:U.address,abi:[{name:`approve`,type:`function`,stateMutability:`nonpayable`,inputs:[{name:`spender`,type:`address`},{name:`amount`,type:`uint256`}],outputs:[{type:`bool`}]}],functionName:`approve`,args:[e.spenderAddress,(0,a.parseUnits)(e.approveAmount,U.decimals)],chain:null});console.log(`授权交易哈希:`,r),Q(e.subscriptionId)}catch(e){console.error(`钱包授权失败:`,e),y?.(e)}finally{w(!1)}},ne=async()=>{if(!N){y?.(Error(`请先连接钱包`));return}f===`one-time`?await ee():f===`subscription`&&await te()},Z=(0,s.useRef)(null),re=async()=>{if(!(!D||!k))try{w(!0);let e=``;f===`one-time`?(Z.current=await b.createOnetimePayment({paymentChain:D,paymentToken:k,orderId:p,amount:q}),e=`${D.toLowerCase()}:${Z.current.receiveAddress}?amount=${Z.current.paymentAmount}`):f===`subscription`&&(Z.current=await b.createSubscriptionPayment({paymentChain:D,paymentToken:k,orderId:p,amountOfUsd:q,intervalDays:h||30}),e=`${D.toLowerCase()}:${Z.current.spenderAddress}?amount=${Z.current.approveAmount}`),S(`payment`),M(await l.toDataURL(e,{width:200,margin:2,errorCorrectionLevel:`H`}))}catch(e){y?.(e)}finally{w(!1)}},ie=async()=>{if(Z.current)try{w(!0),f===`one-time`?Q(Z.current.paymentId):f===`subscription`&&Q(Z.current.subscriptionId)}catch(e){console.error(`支付状态检查错误:`,e),y?.(e),w(!1)}},Q=e=>{let t=()=>(0,r.defer)(()=>f===`subscription`?b.checkSubscriptionPaymentStatus({subscriptionId:e}):b.checkOnetimePaymentStatus({paymentId:e})).pipe((0,i.timeout)(15e3),(0,i.retry)({count:3,delay:2e3}));B.current?.unsubscribe(),B.current=t().pipe((0,i.expand)(e=>e.status===`pending`?(0,r.timer)(2e3).pipe((0,i.switchMap)(()=>t())):r.EMPTY),(0,i.tap)(e=>{e.status===`expired`&&(w(!1),g?.(e)),e.status===`paid`&&(w(!1),S(`success`),_?.(e)),e.status===`failed`&&(w(!1),v?.(e)),e.status===`approved`&&(w(!1),S(`success`),_?.(e))})).subscribe({error:e=>{console.error(`支付状态检查错误:`,e),w(!1),y?.(e)}})},ae=async()=>{if(!Z.current)return;let e=f===`subscription`?Z.current.spenderAddress:Z.current.receiveAddress;e&&await navigator.clipboard.writeText(e)},$=()=>{C||(u(),setTimeout(()=>{S(`select`),Z.current=null},300))};return(0,s.useEffect)(()=>{e&&T.length===0&&J()},[e]),(0,s.useEffect)(()=>{H.length>0&&A(H[0].symbol)},[H]),(0,s.useEffect)(()=>()=>{B.current?.unsubscribe()},[]),e?(0,c.jsx)(`div`,{className:`_cppay-overlay`,onClick:e=>e.target===e.currentTarget&&!C&&$(),children:(0,c.jsxs)(`div`,{className:`_cppay-dialog`,children:[(0,c.jsxs)(`div`,{className:`_cppay-header`,children:[(0,c.jsx)(`h2`,{className:`_cppay-title`,children:x===`select`?`选择支付方式`:`完成支付`}),(0,c.jsx)(`button`,{onClick:$,disabled:C,className:`_cppay-close-btn`,children:(0,c.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,c.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})})]}),(0,c.jsx)(`div`,{className:`_cppay-content`,children:x===`success`?(0,c.jsxs)(`div`,{style:{textAlign:`center`,padding:`2rem 0`},children:[(0,c.jsx)(`div`,{style:{fontSize:`64px`,marginBottom:`1rem`},children:`✅`}),(0,c.jsx)(`h3`,{style:{fontSize:`1.5rem`,fontWeight:600,color:`#10b981`,margin:`0 0 0.5rem 0`},children:f===`subscription`?`授权成功!`:`支付成功!`}),(0,c.jsx)(`p`,{style:{color:`#6b7280`,margin:0},children:f===`subscription`?`订阅已激活`:`交易已完成`})]}):x===`select`?(0,c.jsxs)(`div`,{children:[(0,c.jsxs)(`div`,{className:`_cppay-section`,children:[(0,c.jsx)(`label`,{className:`_cppay-label`,children:`支付网络`}),(0,c.jsx)(`div`,{className:`_cppay-grid`,children:T.map(e=>(0,c.jsxs)(`button`,{onClick:()=>O(e.chain),className:`_cppay-select-btn ${D===e.chain?`_cppay-selected`:``}`,children:[e.icon&&(0,c.jsx)(`img`,{src:e.icon,alt:e.chain}),(0,c.jsx)(`span`,{children:e.chain})]},e.chain))})]}),(0,c.jsxs)(`div`,{className:`_cppay-section`,children:[(0,c.jsx)(`label`,{className:`_cppay-label`,children:`支付代币`}),(0,c.jsx)(`div`,{className:`_cppay-grid`,children:H.map(e=>(0,c.jsxs)(`button`,{onClick:()=>A(e.symbol),className:`_cppay-select-btn ${k===e.symbol?`_cppay-selected`:``}`,children:[e.icon&&(0,c.jsx)(`img`,{src:e.icon,alt:e.symbol}),(0,c.jsx)(`span`,{children:e.symbol})]},e.symbol))})]}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`div`,{className:`_cppay-price-box`,children:(0,c.jsxs)(`div`,{className:`_cppay-price-row`,children:[(0,c.jsx)(`span`,{className:`_cppay-price-label`,children:`支付金额`}),(0,c.jsxs)(`div`,{className:`_cppay-price-amount`,children:[(0,c.jsxs)(`div`,{className:`_cppay-price-main`,children:[q,` `,k]}),(0,c.jsxs)(`div`,{className:`_cppay-price-sub`,children:[`≈ $`,m]})]})]})})}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`button`,{onClick:re,disabled:!D||!k||C,className:`_cppay-btn _cppay-btn-primary`,children:C?`处理中...`:`继续支付`})})]}):(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`div`,{className:`_cppay-qr-container`,children:(0,c.jsx)(`div`,{className:`_cppay-qr-code`,children:j&&(0,c.jsx)(`img`,{src:j,alt:`Payment QR Code`,style:{width:`160px`,height:`160px`,display:`block`}})})}),(0,c.jsxs)(`div`,{className:`_cppay-section`,children:[(0,c.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,c.jsx)(`div`,{className:`_cppay-info-label`,children:f===`subscription`?`授权金额`:`支付金额`}),(0,c.jsx)(`div`,{className:`_cppay-info-value`,children:f===`subscription`?`${K(Z.current.approveAmount,W(k))} ${k}`:`${K(Z.current.paymentAmount,W(k))} ${k}`})]}),(0,c.jsxs)(`div`,{className:`_cppay-info-box`,children:[(0,c.jsx)(`div`,{className:`_cppay-info-label`,children:f===`subscription`?`授权合约地址`:`支付地址`}),(0,c.jsxs)(`div`,{className:`_cppay-address-row`,children:[(0,c.jsx)(`code`,{children:f===`subscription`?Z.current.spenderAddress:Z.current.receiveAddress}),(0,c.jsx)(`button`,{onClick:ae,className:`_cppay-copy-btn`,title:`复制地址`,children:(0,c.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,c.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})})})]})]}),f===`subscription`&&(0,c.jsxs)(`div`,{className:`_cppay-info-box`,style:{background:`#fff3cd`,borderColor:`#ffc107`},children:[(0,c.jsx)(`div`,{className:`_cppay-info-label`,style:{color:`#856404`},children:`📌 订阅说明`}),(0,c.jsx)(`div`,{className:`_cppay-info-value`,style:{fontSize:`12px`,color:`#856404`},children:`订阅支付需要授权代币给合约地址,系统将按周期自动扣款。授权后无需每次手动支付。`})]})]}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:N?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`button`,{onClick:ne,disabled:C,className:`_cppay-btn _cppay-btn-primary`,children:C?f===`subscription`?`授权中...`:`支付中...`:f===`subscription`?`💳 钱包授权`:`💳 钱包支付`}),(0,c.jsxs)(`div`,{style:{textAlign:`center`,marginTop:`8px`,fontSize:`12px`,color:`#666`},children:[`已连接: `,N.slice(0,6),`...`,N.slice(-4)]})]}):(0,c.jsxs)(`div`,{style:{display:`flex`,flexDirection:`row`,gap:`0.5rem`,justifyContent:`center`},children:[(0,c.jsxs)(`button`,{onClick:()=>Y(`metamask`),disabled:F,className:`_cppay-btn _cppay-btn-secondary`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`0.5rem`,padding:`0.5rem 1rem`,fontSize:`14px`,flex:`1`},children:[(0,c.jsx)(`img`,{src:n.n,alt:`MetaMask`,style:{width:`20px`,height:`20px`}}),(0,c.jsx)(`span`,{children:`MetaMask`})]}),(0,c.jsxs)(`button`,{onClick:()=>Y(`walletconnect`),disabled:F,className:`_cppay-btn _cppay-btn-secondary`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`,gap:`0.5rem`,padding:`0.5rem 1rem`,fontSize:`14px`,flex:`1`},children:[(0,c.jsx)(`img`,{src:n.t,alt:`WalletConnect`,style:{width:`20px`,height:`20px`}}),(0,c.jsx)(`span`,{children:`WalletConnect`})]})]})}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`button`,{onClick:ie,disabled:C,className:`_cppay-btn _cppay-btn-primary`,children:C?`检查中...`:`我已完成支付`})}),(0,c.jsx)(`div`,{className:`_cppay-section`,children:(0,c.jsx)(`button`,{onClick:()=>S(`select`),disabled:C,className:`_cppay-btn _cppay-btn-text`,children:`更改支付方式`})})]})})]})}):null},d=s.default.memo(u),f=(0,s.createContext)(null);const p=({apikey:e,children:t})=>{let[n,r]=(0,s.useState)(!1),[i,a]=(0,s.useState)(null),o=(0,s.useCallback)(e=>{a(e),r(!0)},[]),l=(0,s.useCallback)(()=>{r(!1)},[]),u=(0,s.useCallback)(e=>{i?.onSuccess?.(e),r(!1)},[i]),p=(0,s.useCallback)(e=>{i?.onError?.(e)},[i]);return(0,c.jsxs)(f.Provider,{value:{showPayment:o},children:[t,i&&(0,c.jsx)(d,{open:n,onClose:l,apikey:e,plain:i.plain,orderId:i.orderId,amount:i.amount,intervalDays:i.intervalDays,onSuccess:u,onError:p})]})},m=()=>{let e=(0,s.useContext)(f);if(!e)throw Error(`useCppayPayment must be used within CppayProvider`);return e};n.a(n.o),exports.CppayProvider=p,exports.PaymentDialog=d,exports.useCppayPayment=m;