@cedros/pay-react 1.1.5 → 1.1.9

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 (57) hide show
  1. package/dist/CedrosContext-C2v_s8cc.js +6 -0
  2. package/dist/CedrosContext-D7nh5-Zh.mjs +2100 -0
  3. package/dist/WalletManager-B5KLZK2D.js +1 -0
  4. package/dist/WalletManager-oEjZhaFk.mjs +219 -0
  5. package/dist/components/CedrosPay.d.ts.map +1 -1
  6. package/dist/components/admin/AISettingsSection.d.ts.map +1 -1
  7. package/dist/components/admin/CouponsSection.d.ts.map +1 -1
  8. package/dist/components/admin/ErrorBanner.d.ts +11 -0
  9. package/dist/components/admin/ErrorBanner.d.ts.map +1 -0
  10. package/dist/components/admin/FAQSection.d.ts.map +1 -1
  11. package/dist/components/admin/MessagingSection.d.ts.map +1 -1
  12. package/dist/components/admin/OverviewSection.d.ts.map +1 -1
  13. package/dist/components/admin/ProductsSection.d.ts.map +1 -1
  14. package/dist/components/admin/RefundsSection.d.ts.map +1 -1
  15. package/dist/components/admin/SingleCategorySettings.d.ts.map +1 -1
  16. package/dist/components/admin/StorefrontSection.d.ts.map +1 -1
  17. package/dist/components/admin/SubscriptionsSection.d.ts.map +1 -1
  18. package/dist/components/admin/TransactionsSection.d.ts.map +1 -1
  19. package/dist/context/CedrosContext.d.ts +9 -3
  20. package/dist/context/CedrosContext.d.ts.map +1 -1
  21. package/dist/crypto-only.d.ts +9 -19
  22. package/dist/crypto-only.d.ts.map +1 -1
  23. package/dist/crypto-only.js +1 -1
  24. package/dist/crypto-only.mjs +766 -32
  25. package/dist/index-BFt38o8Q.mjs +88 -0
  26. package/dist/index-S3b2N8tp.js +136 -0
  27. package/dist/index-WcOlBYZJ.js +1 -0
  28. package/dist/{index-Bzp2srIS.mjs → index-iIxY1o71.mjs} +10413 -9402
  29. package/dist/index.d.ts +1 -7
  30. package/dist/index.d.ts.map +1 -1
  31. package/dist/index.js +1 -1
  32. package/dist/index.mjs +68 -75
  33. package/dist/managers/ManagerCache.d.ts +2 -2
  34. package/dist/managers/ManagerCache.d.ts.map +1 -1
  35. package/dist/pay-react.css +1 -1
  36. package/dist/{sections-D6R2jRAp.js → sections-bhZyRM7o.js} +1 -1
  37. package/dist/{sections-cz9ughWO.mjs → sections-otLBNrzu.mjs} +2 -2
  38. package/dist/solanaCheck-BS3QTE63.js +6 -0
  39. package/dist/solanaCheck-IlYsbXDd.mjs +27 -0
  40. package/dist/stripe-only.d.ts +4 -21
  41. package/dist/stripe-only.d.ts.map +1 -1
  42. package/dist/stripe-only.js +1 -1
  43. package/dist/stripe-only.mjs +71 -29
  44. package/dist/testing/index.js +1 -1
  45. package/dist/testing/index.mjs +1 -1
  46. package/dist/types/componentOptions.d.ts +15 -2
  47. package/dist/types/componentOptions.d.ts.map +1 -1
  48. package/dist/utils/index.d.ts +0 -1
  49. package/dist/utils/index.d.ts.map +1 -1
  50. package/dist/walletPool-BR6etEiq.mjs +67 -0
  51. package/dist/walletPool-BZyAG4YS.js +1 -0
  52. package/package.json +6 -1
  53. package/dist/CedrosContext-DUT3cLZg.mjs +0 -2474
  54. package/dist/CedrosContext-efFL4kQz.js +0 -11
  55. package/dist/index-CFzfjC82.js +0 -136
  56. package/dist/styles-C4-_hbgr.js +0 -1
  57. package/dist/styles-QcAsIVWl.mjs +0 -1909
@@ -1,34 +1,768 @@
1
- import { C as t, K as r, L as o, b as m, R as n, d as i, c as g, g as d, u as C, a as E, v as P, e as c } from "./CedrosContext-DUT3cLZg.mjs";
2
- import { C as R, l as y, E as L, b as S, P as l, a as p, d as T, i as M, g as f, e as v, h as O, f as _, k as I, j as N, p as b, c as h, m as x } from "./styles-QcAsIVWl.mjs";
3
- import "@solana/wallet-adapter-wallets";
1
+ import { U as ke, F as Te, G as ue, A as Re, D as de, y as ve, z as pe, B as V, a0 as Be, a1 as Ie } from "./index-iIxY1o71.mjs";
2
+ import { x as Ue, w as Ve, C as Ye, a as He, b as Je, h as Xe, a2 as Ze, E as et, f as tt, d as rt, e as at, P as nt, R as st, L as ot, S as it, g as ct, i as lt, q as ut, c as dt, Q as pt, M as mt, W as ft, v as yt, o as bt, r as gt, t as wt, O as St, T as ht, I as Ct, H as xt, N as Pt, K as Et, p as kt, s as Tt, j as Rt, m as vt, V as Bt, k as It, u as Wt, l as qt, n as _t, a3 as Mt, J as Lt } from "./index-iIxY1o71.mjs";
3
+ import { jsxs as O, jsx as x } from "react/jsx-runtime";
4
+ import { useState as B, useCallback as h, useRef as me, useEffect as N, useMemo as F } from "react";
5
+ import { u as Y, m as D, a as We, i as y } from "./CedrosContext-D7nh5-Zh.mjs";
6
+ import { f as Nt, C as Dt, e as zt, d as Kt, K as Ot, L as Qt, h as $t, R as Ft, g as Gt, b as jt, j as Ut, c as Vt, r as Yt, v as Ht, n as Jt } from "./CedrosContext-D7nh5-Zh.mjs";
7
+ import "@solana/web3.js";
8
+ import "./index-BFt38o8Q.mjs";
9
+ import { useWallet as H } from "@solana/wallet-adapter-react";
10
+ import { WalletReadyState as fe } from "@solana/wallet-adapter-base";
11
+ import { WalletIcon as qe } from "@solana/wallet-adapter-react-ui";
12
+ import { WalletPool as Zt, createWalletPool as er } from "./walletPool-BR6etEiq.mjs";
13
+ function _e() {
14
+ const { subscriptionManager: r, x402Manager: c, walletManager: m } = Y(), { publicKey: o, signTransaction: k } = H(), [g, d] = B({
15
+ status: "idle",
16
+ error: null,
17
+ sessionId: null,
18
+ subscriptionStatus: null,
19
+ expiresAt: null
20
+ }), [P, C] = B(null), E = h(() => {
21
+ if (!o) {
22
+ const s = "Wallet not connected";
23
+ return d((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
24
+ }
25
+ if (!k) {
26
+ const s = "Wallet does not support signing";
27
+ return d((t) => ({ ...t, status: "error", error: s })), { valid: !1, error: s };
28
+ }
29
+ return { valid: !0 };
30
+ }, [o, k]), W = h(
31
+ async (s) => {
32
+ if (!o)
33
+ return d((t) => ({
34
+ ...t,
35
+ status: "error",
36
+ error: "Wallet not connected"
37
+ })), null;
38
+ d((t) => ({
39
+ ...t,
40
+ status: "checking",
41
+ error: null
42
+ }));
43
+ try {
44
+ const t = await r.checkSubscriptionStatus({
45
+ resource: s,
46
+ userId: o.toString()
47
+ });
48
+ return d((a) => ({
49
+ ...a,
50
+ status: t.active ? "success" : "idle",
51
+ subscriptionStatus: t.status,
52
+ expiresAt: t.expiresAt || t.currentPeriodEnd || null
53
+ })), t;
54
+ } catch (t) {
55
+ const a = D(t, "Failed to check subscription status");
56
+ return d((i) => ({
57
+ ...i,
58
+ status: "error",
59
+ error: a
60
+ })), null;
61
+ }
62
+ },
63
+ [o, r]
64
+ ), T = h(
65
+ async (s, t, a) => {
66
+ d((i) => ({
67
+ ...i,
68
+ status: "loading",
69
+ error: null
70
+ }));
71
+ try {
72
+ const i = await r.requestSubscriptionQuote(
73
+ s,
74
+ t,
75
+ a
76
+ );
77
+ return C(i), d((f) => ({
78
+ ...f,
79
+ status: "idle"
80
+ })), i;
81
+ } catch (i) {
82
+ const f = D(i, "Failed to get subscription quote");
83
+ return d((n) => ({
84
+ ...n,
85
+ status: "error",
86
+ error: f
87
+ })), null;
88
+ }
89
+ },
90
+ [r]
91
+ ), q = h(
92
+ async (s, t, a) => {
93
+ const i = E();
94
+ if (!i.valid)
95
+ return { success: !1, error: i.error };
96
+ d((f) => ({
97
+ ...f,
98
+ status: "loading",
99
+ error: null
100
+ }));
101
+ try {
102
+ const f = await r.requestSubscriptionQuote(
103
+ s,
104
+ t,
105
+ a
106
+ );
107
+ C(f);
108
+ const n = f.requirement;
109
+ if (!c.validateRequirement(n))
110
+ throw new Error("Invalid subscription quote received from server");
111
+ const w = !!n.extra?.feePayer;
112
+ let S;
113
+ if (w) {
114
+ const { transaction: p, blockhash: R } = await c.buildGaslessTransaction({
115
+ resourceId: s,
116
+ userWallet: o.toString(),
117
+ feePayer: n.extra.feePayer,
118
+ couponCode: a?.couponCode
119
+ }), _ = m.deserializeTransaction(p), z = await m.partiallySignTransaction({
120
+ transaction: _,
121
+ signTransaction: k,
122
+ blockhash: R
123
+ });
124
+ S = await c.submitGaslessTransaction({
125
+ resource: s,
126
+ partialTx: z,
127
+ couponCode: a?.couponCode,
128
+ resourceType: "regular",
129
+ requirement: n
130
+ });
131
+ } else {
132
+ const p = await m.buildTransaction({
133
+ requirement: n,
134
+ payerPublicKey: o
135
+ }), R = await m.signTransaction({
136
+ transaction: p,
137
+ signTransaction: k
138
+ }), _ = m.buildPaymentPayload({
139
+ requirement: n,
140
+ signedTx: R,
141
+ payerPublicKey: o
142
+ });
143
+ S = await c.submitPayment({
144
+ resource: s,
145
+ payload: _,
146
+ couponCode: a?.couponCode,
147
+ resourceType: "regular"
148
+ });
149
+ }
150
+ if (S.success) {
151
+ const p = await r.checkSubscriptionStatus({
152
+ resource: s,
153
+ userId: o.toString()
154
+ });
155
+ d({
156
+ status: "success",
157
+ error: null,
158
+ sessionId: S.transactionId || null,
159
+ subscriptionStatus: p.status,
160
+ expiresAt: p.expiresAt || p.currentPeriodEnd || null
161
+ });
162
+ } else
163
+ d((p) => ({
164
+ ...p,
165
+ status: "error",
166
+ error: S.error || "Subscription payment failed"
167
+ }));
168
+ return S;
169
+ } catch (f) {
170
+ const n = D(f, "Subscription payment failed");
171
+ return d((w) => ({
172
+ ...w,
173
+ status: "error",
174
+ error: n
175
+ })), { success: !1, error: n };
176
+ }
177
+ },
178
+ [
179
+ E,
180
+ r,
181
+ c,
182
+ m,
183
+ o,
184
+ k
185
+ ]
186
+ ), b = h(() => {
187
+ d({
188
+ status: "idle",
189
+ error: null,
190
+ sessionId: null,
191
+ subscriptionStatus: null,
192
+ expiresAt: null
193
+ }), C(null);
194
+ }, []);
195
+ return {
196
+ ...g,
197
+ quote: P,
198
+ checkStatus: W,
199
+ requestQuote: T,
200
+ processPayment: q,
201
+ reset: b
202
+ };
203
+ }
204
+ function $e({
205
+ resource: r,
206
+ interval: c,
207
+ intervalDays: m,
208
+ couponCode: o,
209
+ label: k,
210
+ disabled: g = !1,
211
+ onAttempt: d,
212
+ onSuccess: P,
213
+ onError: C,
214
+ className: E = "",
215
+ testPageUrl: W,
216
+ hideMessages: T = !1,
217
+ autoCheckStatus: q = !0
218
+ }) {
219
+ const {
220
+ connected: b,
221
+ connecting: s,
222
+ connect: t,
223
+ disconnect: a,
224
+ select: i,
225
+ wallets: f,
226
+ wallet: n,
227
+ publicKey: w
228
+ } = H(), {
229
+ status: S,
230
+ error: p,
231
+ subscriptionStatus: R,
232
+ expiresAt: _,
233
+ checkStatus: z,
234
+ processPayment: K
235
+ } = _e(), l = We(), { solanaError: I } = Y(), { t: v, translations: J } = ke(), ye = k || v("ui.subscribe_with_crypto"), X = me(K), Z = me(z);
236
+ N(() => {
237
+ X.current = K, Z.current = z;
238
+ }, [K, z]);
239
+ const be = p && typeof p != "string" ? p?.code ?? null : null, ge = I && typeof I != "string" ? I?.code ?? null : null, ee = (e) => {
240
+ if (!e || !J) return "";
241
+ const u = J.errors[e];
242
+ return u ? u.action ? `${u.message} ${u.action}` : u.message : "";
243
+ }, te = p ? typeof p == "string" ? p : ee(be) : null, re = I ? typeof I == "string" ? I : ee(ge) : null, we = F(
244
+ () => f.map((e) => `${e.adapter.name}-${e.readyState}`).join(","),
245
+ [f]
246
+ ), G = F(
247
+ () => f.filter(
248
+ ({ readyState: e }) => e === fe.Installed || e === fe.Loadable
249
+ ),
250
+ // eslint-disable-next-line react-hooks/exhaustive-deps
251
+ [we]
252
+ );
253
+ N(() => {
254
+ q && b && w && (y().debug("[CryptoSubscribeButton] Auto-checking subscription status"), Z.current(r));
255
+ }, [q, b, w, r]), N(() => {
256
+ S === "success" && R === "active" && (Te("crypto", "subscription-active", r), P && P("subscription-active"));
257
+ }, [S, R, r, P]), N(() => {
258
+ S === "error" && p && (ue("crypto", p, r), C && C(p));
259
+ }, [S, p, r, C]);
260
+ const ae = typeof window < "u" && window.top !== window.self, [ne, M] = B(!1), [se, j] = B(!1), [oe, L] = B(!1), A = I;
261
+ N(() => {
262
+ let e = !1;
263
+ return e || (async () => {
264
+ if (se && n && !b && !s) {
265
+ y().debug(
266
+ "[CryptoSubscribeButton] Wallet detected, attempting auto-connect:",
267
+ n.adapter.name
268
+ ), j(!1), pe(n.adapter.name);
269
+ try {
270
+ await t(), e || y().debug("[CryptoSubscribeButton] Auto-connect successful");
271
+ } catch (U) {
272
+ if (!e) {
273
+ y().error("[CryptoSubscribeButton] Auto-connect failed:", U);
274
+ const Ee = U instanceof Error ? U.message : "Failed to connect wallet";
275
+ V(Ee, n.adapter.name), L(!1);
276
+ }
277
+ }
278
+ }
279
+ })(), () => {
280
+ e = !0;
281
+ };
282
+ }, [n, se, b, s, t]), N(() => {
283
+ b && oe && w && n && (Re(n.adapter.name, w.toString()), y().debug("[CryptoSubscribeButton] Processing pending subscription payment"), L(!1), M(!1), de("crypto", r), X.current(r, c, { couponCode: o, intervalDays: m }));
284
+ }, [b, oe, w, n, r, c, o, m]);
285
+ const ie = h(async () => {
286
+ if (y().debug("[CryptoSubscribeButton] executeSubscriptionFlow called", {
287
+ connected: b,
288
+ wallet: n?.adapter.name,
289
+ resource: r,
290
+ interval: c
291
+ }), ve("crypto", r), d && d("crypto"), A) {
292
+ y().error("[CryptoSubscribeButton] Solana dependencies missing:", A), ue("crypto", A, r), C && C(A);
293
+ return;
294
+ }
295
+ if (ae) {
296
+ const e = W || window.location.href;
297
+ try {
298
+ if (new URL(e, window.location.origin).origin !== window.location.origin)
299
+ throw y().error("[CryptoSubscribeButton] Blocked attempt to open external URL:", e), new Error("Cannot open external URLs from embedded context");
300
+ window.open(e, "_blank", "noopener,noreferrer");
301
+ } catch (u) {
302
+ throw y().error("[CryptoSubscribeButton] URL validation failed:", u), u;
303
+ }
304
+ return;
305
+ }
306
+ if (b)
307
+ de("crypto", r), await K(r, c, { couponCode: o, intervalDays: m });
308
+ else {
309
+ L(!0);
310
+ try {
311
+ if (n)
312
+ y().debug(
313
+ "[CryptoSubscribeButton] Wallet already selected, connecting:",
314
+ n.adapter.name
315
+ ), pe(n.adapter.name), await t();
316
+ else {
317
+ if (y().debug("[CryptoSubscribeButton] No wallet selected, showing selector"), G.length === 0) {
318
+ L(!1);
319
+ const e = "No wallets available";
320
+ throw V(e), new Error(e);
321
+ }
322
+ M(!0);
323
+ }
324
+ } catch (e) {
325
+ L(!1);
326
+ const u = e instanceof Error ? e.message : "Failed to connect wallet";
327
+ y().error("[CryptoSubscribeButton] Connection error:", u), V(u, n?.adapter.name);
328
+ }
329
+ }
330
+ }, [
331
+ b,
332
+ n,
333
+ r,
334
+ c,
335
+ o,
336
+ m,
337
+ ae,
338
+ W,
339
+ G,
340
+ t,
341
+ K,
342
+ A,
343
+ d,
344
+ C
345
+ ]), ce = F(() => `crypto-subscribe-${r}-${c}`, [r, c]), Se = F(
346
+ () => Be(ce, ie, {
347
+ cooldownMs: 200,
348
+ deduplicationWindowMs: 0
349
+ }),
350
+ [ce, ie]
351
+ ), le = S === "loading" || S === "checking", Q = R === "active" || R === "trialing", he = g || le || s || !!A || Q;
352
+ let $ = ye;
353
+ if (le)
354
+ $ = v("ui.processing");
355
+ else if (Q && _) {
356
+ const e = new Date(_).toLocaleDateString();
357
+ $ = `${v("ui.subscribed_until")} ${e}`;
358
+ } else Q && ($ = v("ui.subscribed"));
359
+ const Ce = h(async () => {
360
+ try {
361
+ j(!1), b && await a(), i(null), M(!0);
362
+ } catch (e) {
363
+ y().error("Failed to change wallet:", e);
364
+ }
365
+ }, [b, a, i]), xe = h(
366
+ (e) => {
367
+ y().debug("[CryptoSubscribeButton] Wallet clicked:", e), M(!1), i(e), j(!0);
368
+ },
369
+ [i]
370
+ ), Pe = h(async () => {
371
+ try {
372
+ if (await a(), L(!1), typeof window < "u" && window.localStorage)
373
+ try {
374
+ window.localStorage.removeItem("walletName");
375
+ } catch (e) {
376
+ e instanceof Error && e.name === "QuotaExceededError" ? y().warn("localStorage quota exceeded when removing wallet preference") : y().error("Failed to clear wallet preference from localStorage:", e);
377
+ }
378
+ } catch (e) {
379
+ y().error("Failed to disconnect wallet:", e);
380
+ }
381
+ }, [a]);
382
+ return /* @__PURE__ */ O(
383
+ "div",
384
+ {
385
+ className: l.unstyled ? E : `${l.className} cedros-theme__crypto-button ${E || ""}`,
386
+ style: l.unstyled ? {} : l.style,
387
+ children: [
388
+ /* @__PURE__ */ x(
389
+ "button",
390
+ {
391
+ onClick: Se,
392
+ disabled: he,
393
+ className: l.unstyled ? E : "cedros-theme__button cedros-theme__crypto",
394
+ type: "button",
395
+ children: $
396
+ }
397
+ ),
398
+ ne && !T && /* @__PURE__ */ x(
399
+ "div",
400
+ {
401
+ className: "cedros-modal-overlay",
402
+ style: {
403
+ position: "fixed",
404
+ top: 0,
405
+ left: 0,
406
+ right: 0,
407
+ bottom: 0,
408
+ backgroundColor: l.tokens.modalOverlay,
409
+ display: "flex",
410
+ alignItems: "center",
411
+ justifyContent: "center",
412
+ zIndex: 9999,
413
+ padding: "1rem"
414
+ },
415
+ onClick: () => M(!1),
416
+ children: /* @__PURE__ */ O(
417
+ "div",
418
+ {
419
+ className: "cedros-modal-content",
420
+ style: {
421
+ backgroundColor: l.tokens.modalBackground,
422
+ borderRadius: "12px",
423
+ padding: "2rem",
424
+ maxWidth: "400px",
425
+ width: "100%",
426
+ boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
427
+ border: `1px solid ${l.tokens.modalBorder}`
428
+ },
429
+ onClick: (e) => e.stopPropagation(),
430
+ children: [
431
+ /* @__PURE__ */ O(
432
+ "div",
433
+ {
434
+ style: {
435
+ display: "flex",
436
+ justifyContent: "space-between",
437
+ alignItems: "center",
438
+ marginBottom: "1.5rem"
439
+ },
440
+ children: [
441
+ /* @__PURE__ */ x(
442
+ "h3",
443
+ {
444
+ style: {
445
+ margin: 0,
446
+ fontSize: "1.25rem",
447
+ fontWeight: 600,
448
+ color: l.tokens.surfaceText
449
+ },
450
+ children: v("wallet.select_wallet")
451
+ }
452
+ ),
453
+ /* @__PURE__ */ x(
454
+ "button",
455
+ {
456
+ onClick: () => M(!1),
457
+ style: Ie(l.tokens.surfaceText),
458
+ "aria-label": "Close modal",
459
+ type: "button",
460
+ children: "×"
461
+ }
462
+ )
463
+ ]
464
+ }
465
+ ),
466
+ /* @__PURE__ */ x("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: G.map((e) => /* @__PURE__ */ O(
467
+ "button",
468
+ {
469
+ onClick: () => xe(e.adapter.name),
470
+ style: {
471
+ width: "100%",
472
+ padding: "1rem",
473
+ backgroundColor: l.tokens.surfaceBackground,
474
+ border: `1px solid ${l.tokens.surfaceBorder}`,
475
+ borderRadius: "0.5rem",
476
+ cursor: "pointer",
477
+ fontSize: "1rem",
478
+ textAlign: "left",
479
+ color: l.tokens.surfaceText,
480
+ display: "flex",
481
+ alignItems: "center",
482
+ gap: "1rem",
483
+ transition: "all 0.2s ease"
484
+ },
485
+ onMouseEnter: (u) => {
486
+ u.currentTarget.style.backgroundColor = l.tokens.modalBackground, u.currentTarget.style.borderColor = l.tokens.surfaceText, u.currentTarget.style.transform = "translateY(-2px)";
487
+ },
488
+ onMouseLeave: (u) => {
489
+ u.currentTarget.style.backgroundColor = l.tokens.surfaceBackground, u.currentTarget.style.borderColor = l.tokens.surfaceBorder, u.currentTarget.style.transform = "translateY(0)";
490
+ },
491
+ type: "button",
492
+ children: [
493
+ /* @__PURE__ */ x(qe, { wallet: e, style: { width: "24px", height: "24px" } }),
494
+ /* @__PURE__ */ x("span", { style: { fontWeight: 500 }, children: e.adapter.name })
495
+ ]
496
+ },
497
+ e.adapter.name
498
+ )) })
499
+ ]
500
+ }
501
+ )
502
+ }
503
+ ),
504
+ b && !T && !ne && /* @__PURE__ */ O(
505
+ "div",
506
+ {
507
+ style: {
508
+ display: "flex",
509
+ justifyContent: "space-between",
510
+ marginTop: "0.5rem",
511
+ fontSize: "0.75rem",
512
+ color: l.tokens.surfaceText,
513
+ opacity: 0.7
514
+ },
515
+ children: [
516
+ /* @__PURE__ */ x(
517
+ "button",
518
+ {
519
+ onClick: Ce,
520
+ style: {
521
+ background: "none",
522
+ border: "none",
523
+ padding: 0,
524
+ color: "inherit",
525
+ textDecoration: "none",
526
+ cursor: "pointer",
527
+ fontSize: "inherit"
528
+ },
529
+ type: "button",
530
+ children: v("wallet.change")
531
+ }
532
+ ),
533
+ /* @__PURE__ */ x(
534
+ "button",
535
+ {
536
+ onClick: Pe,
537
+ style: {
538
+ background: "none",
539
+ border: "none",
540
+ padding: 0,
541
+ color: "inherit",
542
+ textDecoration: "none",
543
+ cursor: "pointer",
544
+ fontSize: "inherit"
545
+ },
546
+ type: "button",
547
+ children: v("ui.disconnect")
548
+ }
549
+ )
550
+ ]
551
+ }
552
+ ),
553
+ !T && re && /* @__PURE__ */ x("div", { className: l.unstyled ? "" : "cedros-theme__error", children: re }),
554
+ !T && te && /* @__PURE__ */ x("div", { className: l.unstyled ? "" : "cedros-theme__error", children: te }),
555
+ !T && Q && /* @__PURE__ */ x("div", { className: l.unstyled ? "" : "cedros-theme__success", children: v("ui.subscription_active") })
556
+ ]
557
+ }
558
+ );
559
+ }
560
+ function Fe() {
561
+ const { x402Manager: r, walletManager: c } = Y(), { publicKey: m, signTransaction: o } = H(), [k, g] = B({
562
+ status: "idle",
563
+ error: null,
564
+ transactionId: null
565
+ }), [d, P] = B(null), [C, E] = B(null), W = h(
566
+ async (s) => {
567
+ try {
568
+ g((a) => ({ ...a, status: "loading" }));
569
+ const t = await r.requestQuote({ resource: s });
570
+ if (!r.validateRequirement(t))
571
+ throw new Error("Invalid refund requirement received from server");
572
+ return P(t), g((a) => ({ ...a, status: "idle" })), t;
573
+ } catch (t) {
574
+ const a = D(t, "Failed to fetch refund requirement");
575
+ throw g({
576
+ status: "error",
577
+ error: a,
578
+ transactionId: null
579
+ }), t;
580
+ }
581
+ },
582
+ [r]
583
+ ), T = h(
584
+ async (s, t) => {
585
+ if (!m || !o)
586
+ throw new Error("Wallet not connected");
587
+ try {
588
+ g({
589
+ status: "loading",
590
+ error: null,
591
+ transactionId: null
592
+ });
593
+ const a = await r.requestQuote({ resource: s, couponCode: t });
594
+ if (!r.validateRequirement(a))
595
+ throw new Error("Invalid refund requirement received");
596
+ P(a);
597
+ const i = await c.buildTransaction({
598
+ requirement: a,
599
+ payerPublicKey: m
600
+ }), f = await c.signTransaction({
601
+ transaction: i,
602
+ signTransaction: o
603
+ }), n = c.buildPaymentPayload({
604
+ requirement: a,
605
+ signedTx: f,
606
+ payerPublicKey: m
607
+ }), w = await r.submitPayment({
608
+ resource: s,
609
+ payload: n,
610
+ couponCode: t,
611
+ metadata: void 0,
612
+ // no metadata for refunds
613
+ resourceType: "refund"
614
+ });
615
+ return w.settlement && E(w.settlement), g({
616
+ status: "success",
617
+ error: null,
618
+ transactionId: w.transactionId || f.signature
619
+ }), w;
620
+ } catch (a) {
621
+ const i = D(a, "Refund payment failed");
622
+ throw g({
623
+ status: "error",
624
+ error: i,
625
+ transactionId: null
626
+ }), a;
627
+ }
628
+ },
629
+ [m, o, r, c]
630
+ ), q = h(
631
+ async (s) => {
632
+ if (!m || !o)
633
+ throw new Error("Wallet not connected");
634
+ try {
635
+ g({
636
+ status: "loading",
637
+ error: null,
638
+ transactionId: null
639
+ });
640
+ const t = await r.requestQuote({ resource: s });
641
+ if (!r.validateRequirement(t))
642
+ throw new Error("Invalid refund requirement received");
643
+ P(t);
644
+ const { transaction: a } = await r.buildGaslessTransaction({
645
+ resourceId: s,
646
+ userWallet: m.toString(),
647
+ feePayer: t.extra.feePayer
648
+ }), i = c.deserializeTransaction(a), f = await c.partiallySignTransaction({
649
+ transaction: i,
650
+ signTransaction: o
651
+ }), n = await r.submitGaslessTransaction({
652
+ resource: s,
653
+ partialTx: f,
654
+ couponCode: void 0,
655
+ // no couponCode
656
+ metadata: void 0,
657
+ // no metadata
658
+ resourceType: "refund",
659
+ requirement: t
660
+ });
661
+ return n.settlement && E(n.settlement), g({
662
+ status: "success",
663
+ error: null,
664
+ transactionId: n.transactionId || "gasless-refund-tx"
665
+ }), n;
666
+ } catch (t) {
667
+ const a = D(t, "Gasless refund payment failed");
668
+ throw g({
669
+ status: "error",
670
+ error: a,
671
+ transactionId: null
672
+ }), t;
673
+ }
674
+ },
675
+ [m, o, r, c]
676
+ ), b = h(() => {
677
+ g({
678
+ status: "idle",
679
+ error: null,
680
+ transactionId: null
681
+ }), P(null), E(null);
682
+ }, []);
683
+ return {
684
+ state: k,
685
+ requirement: d,
686
+ settlement: C,
687
+ fetchRefundQuote: W,
688
+ processRefund: T,
689
+ processGaslessRefund: q,
690
+ reset: b
691
+ };
692
+ }
4
693
  export {
5
- R as CEDROS_EVENTS,
6
- t as CedrosProvider,
7
- y as CryptoButton,
8
- L as ERROR_CATEGORIES,
9
- r as KNOWN_STABLECOINS,
10
- o as LogLevel,
11
- m as Logger,
12
- S as PaymentMethodBadge,
13
- l as PaymentModal,
14
- p as ProductPrice,
15
- n as RATE_LIMITER_PRESETS,
16
- T as calculateDiscountPercentage,
17
- i as createLogger,
18
- g as createRateLimiter,
19
- M as emitPaymentError,
20
- f as emitPaymentProcessing,
21
- v as emitPaymentStart,
22
- O as emitPaymentSuccess,
23
- _ as formatCouponCodes,
24
- d as getLogger,
25
- I as getUserErrorMessage,
26
- N as isRetryableError,
27
- b as parseCouponCodes,
28
- C as useCedrosContext,
29
- E as useCedrosTheme,
30
- h as usePaymentMode,
31
- x as useX402Payment,
32
- P as validateConfig,
33
- c as validateTokenMint
694
+ Ue as CEDROS_EVENTS,
695
+ Nt as CIRCUIT_BREAKER_PRESETS,
696
+ Ve as CSP_PRESETS,
697
+ Ye as CedrosPay,
698
+ He as CedrosPayAdminDashboard,
699
+ Dt as CedrosProvider,
700
+ zt as CircuitBreakerOpenError,
701
+ Kt as CircuitState,
702
+ Je as CreditsButton,
703
+ Xe as CreditsSubscribeButton,
704
+ Ze as CryptoButton,
705
+ $e as CryptoSubscribeButton,
706
+ et as ERROR_CATEGORIES,
707
+ Ot as KNOWN_STABLECOINS,
708
+ Qt as LogLevel,
709
+ $t as Logger,
710
+ tt as PaymentMethodBadge,
711
+ rt as PaymentModal,
712
+ at as ProductPrice,
713
+ nt as PurchaseButton,
714
+ Ft as RATE_LIMITER_PRESETS,
715
+ Gt as RETRY_PRESETS,
716
+ st as RPC_PROVIDERS,
717
+ ot as SECURITY_RECOMMENDATIONS,
718
+ it as StripeButton,
719
+ ct as SubscribeButton,
720
+ lt as SubscriptionManagementPanel,
721
+ Zt as WalletPool,
722
+ ut as calculateDiscountPercentage,
723
+ dt as cedrosPayPlugin,
724
+ jt as createCircuitBreaker,
725
+ Ut as createLogger,
726
+ Vt as createRateLimiter,
727
+ pt as createTranslator,
728
+ er as createWalletPool,
729
+ mt as detectLocale,
730
+ ft as ecommerce,
731
+ ue as emitPaymentError,
732
+ de as emitPaymentProcessing,
733
+ ve as emitPaymentStart,
734
+ Te as emitPaymentSuccess,
735
+ pe as emitWalletConnect,
736
+ Re as emitWalletConnected,
737
+ V as emitWalletError,
738
+ yt as formatCSP,
739
+ bt as formatCouponCodes,
740
+ gt as generateCSP,
741
+ wt as generateCSPDirectives,
742
+ St as getAvailableLocales,
743
+ ht as getLocalizedError,
744
+ y as getLogger,
745
+ Ct as getUserErrorMessage,
746
+ xt as isRetryableError,
747
+ Pt as loadLocale,
748
+ Et as logSecurityReport,
749
+ kt as parseCouponCodes,
750
+ Yt as retryWithBackoff,
751
+ Tt as stackCheckoutCoupons,
752
+ Y as useCedrosContext,
753
+ We as useCedrosTheme,
754
+ Rt as useCreditsPayment,
755
+ vt as useCreditsSubscription,
756
+ _e as useCryptoSubscription,
757
+ Bt as useLocalizedError,
758
+ It as usePaymentMode,
759
+ Fe as useRefundVerification,
760
+ Wt as useStripeCheckout,
761
+ qt as useSubscription,
762
+ _t as useSubscriptionManagement,
763
+ ke as useTranslation,
764
+ Mt as useX402Payment,
765
+ Ht as validateConfig,
766
+ Lt as validateSecurity,
767
+ Jt as validateTokenMint
34
768
  };