@cedros/pay-react 1.1.27 → 1.1.29

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 (172) hide show
  1. package/dist/{AISettingsSection-DELur7D2.js → AISettingsSection-B7qrycfY.js} +2 -2
  2. package/dist/{AISettingsSection-BlIv3CzS.mjs → AISettingsSection-DtAgMsDw.mjs} +6 -4
  3. package/dist/{AutosaveIndicator-Bed0-ekg.mjs → AutosaveIndicator-BEvABoKU.mjs} +1 -1
  4. package/dist/AutosaveIndicator-DiyeAg93.js +1 -0
  5. package/dist/CedrosContext-5Gjveoba.mjs +2555 -0
  6. package/dist/CedrosContext-CCakH2SZ.js +3 -0
  7. package/dist/CedrosPayAdminDashboard-CAwEvn66.js +1 -0
  8. package/dist/CedrosPayAdminDashboard-CBuvNAtB.mjs +250 -0
  9. package/dist/{ChatLogsSection-v4zwzCTC.mjs → ChatLogsSection-Ber5o8hF.mjs} +19 -17
  10. package/dist/ChatLogsSection-DLxMMi9I.js +1 -0
  11. package/dist/ComplianceSection-Buu0zTiL.js +1 -0
  12. package/dist/{ComplianceSection-CemgfDrL.mjs → ComplianceSection-ZCr0wsvw.mjs} +18 -15
  13. package/dist/{CryptoButton-BV9owVe2.mjs → CryptoButton-Cl2kZbOP.mjs} +26 -24
  14. package/dist/CryptoButton-DxFCYDlJ.js +1 -0
  15. package/dist/CustomersSection-BywmMLur.js +1 -0
  16. package/dist/{CustomersSection-D_j7OrfS.mjs → CustomersSection-D9UknSKC.mjs} +21 -19
  17. package/dist/{DisputesSection-BcAbXp3K.mjs → DisputesSection-C_eySK-W.mjs} +19 -17
  18. package/dist/DisputesSection-DwkHGv2a.js +1 -0
  19. package/dist/Dropdown-B90Zabxr.mjs +111 -0
  20. package/dist/Dropdown-CtY91emj.js +1 -0
  21. package/dist/ErrorBanner-CZXsHi3H.mjs +22 -0
  22. package/dist/ErrorBanner-Cx2dUhps.js +1 -0
  23. package/dist/{FAQSection-Dn38OhB_.mjs → FAQSection-Bv_Hdt8B.mjs} +8 -6
  24. package/dist/FAQSection-DlPLnIJD.js +1 -0
  25. package/dist/ImagesSection-B4Jzet79.js +1 -0
  26. package/dist/{ImagesSection-Ctw9Icym.mjs → ImagesSection-DpdXQ6qu.mjs} +6 -4
  27. package/dist/InventorySection-BgRdpn1l.js +1 -0
  28. package/dist/{InventorySection-DmhjUlRZ.mjs → InventorySection-DZMu9DMw.mjs} +25 -23
  29. package/dist/MessagingSection-CxV-pf-f.js +1 -0
  30. package/dist/{MessagingSection-B1FaGxkp.mjs → MessagingSection-D_cOBfFt.mjs} +5 -4
  31. package/dist/OrdersSection-BbAX79Ff.js +1 -0
  32. package/dist/{OrdersSection-Bj8bPdg8.mjs → OrdersSection-wfPavit9.mjs} +27 -24
  33. package/dist/PaymentSettingsSection-BdBDgaRg.js +1 -0
  34. package/dist/PaymentSettingsSection-DunzBo9n.mjs +648 -0
  35. package/dist/ReturnsSection-7k4LZ8yp.js +1 -0
  36. package/dist/{ReturnsSection-BC0L8r2e.mjs → ReturnsSection-B4FL7bUv.mjs} +11 -9
  37. package/dist/{SettingsSection-vdYFSNxB.js → SettingsSection-Cz2Yjdhr.js} +1 -1
  38. package/dist/{SettingsSection-KYdEizq_.mjs → SettingsSection-DoeNDbqd.mjs} +1 -1
  39. package/dist/{ShippingSection-BOgto6_9.mjs → ShippingSection-BlVsYC6B.mjs} +5 -3
  40. package/dist/ShippingSection-C-HI8rOb.js +1 -0
  41. package/dist/{SingleCategorySettings-suJ8z9d8.mjs → SingleCategorySettings-B406nnF-.mjs} +143 -140
  42. package/dist/SingleCategorySettings-BqC2UXt3.js +3 -0
  43. package/dist/StatsBar-D4v-I_Dj.mjs +25 -0
  44. package/dist/StatsBar-m6GSRNxs.js +1 -0
  45. package/dist/StorefrontSection-Axvh_KeS.js +1 -0
  46. package/dist/{StorefrontSection-BRvIGBEJ.mjs → StorefrontSection-BK_rhrAi.mjs} +121 -119
  47. package/dist/{SubscriptionsSection-D60qrX9a.mjs → SubscriptionsSection-D8V9RBv-.mjs} +11 -9
  48. package/dist/SubscriptionsSection-EeULMWIB.js +1 -0
  49. package/dist/{TaxSection-C7-pv-Rl.mjs → TaxSection-Cj6TXL6x.mjs} +23 -21
  50. package/dist/TaxSection-CzHPhaHl.js +1 -0
  51. package/dist/ThemeContext-CFXyYx7A.js +1 -0
  52. package/dist/ThemeContext-l0bqcOGW.mjs +126 -0
  53. package/dist/Token22Section-DqRKVG_G.js +1 -0
  54. package/dist/{Token22Section-CrHLQ0EB.mjs → Token22Section-DtYAcT54.mjs} +7 -6
  55. package/dist/{WalletManager-BIwH8Dw_.mjs → WalletManager-D-eoqUDy.mjs} +21 -19
  56. package/dist/WalletManager-DXChB9LA.js +1 -0
  57. package/dist/WebhooksSection-D--iPZuM.js +1 -0
  58. package/dist/{WebhooksSection-COPW4Ec0.mjs → WebhooksSection-DBAIxtBy.mjs} +40 -38
  59. package/dist/admin.d.ts +2 -0
  60. package/dist/admin.js +1 -0
  61. package/dist/admin.mjs +8 -0
  62. package/dist/configApi-BS5UJfzm.js +1 -0
  63. package/dist/{configApi-6XhAJGKX.mjs → configApi-BUXZOMWK.mjs} +57 -3
  64. package/dist/crypto-only.js +1 -1
  65. package/dist/crypto-only.mjs +214 -202
  66. package/dist/dateHelpers-BKW_lGND.js +1 -0
  67. package/dist/dateHelpers-yvPkofYQ.mjs +6 -0
  68. package/dist/fetchWithTimeout-CG0EKbhf.js +1 -0
  69. package/dist/fetchWithTimeout-DmMOwL0Q.mjs +195 -0
  70. package/dist/index-9QF_UfSN.mjs +18668 -0
  71. package/dist/index-Cq9ya93W.js +84 -0
  72. package/dist/index.js +1 -1
  73. package/dist/index.mjs +74 -64
  74. package/dist/safeHref-DqJPLPl5.mjs +12 -0
  75. package/dist/safeHref-DyHIpVjY.js +1 -0
  76. package/dist/sectionIds-B_tFiNvF.js +1 -0
  77. package/dist/sectionIds-DBavltrL.mjs +359 -0
  78. package/dist/sections-BHph7CYj.mjs +9 -0
  79. package/dist/sections-C2zEJr5G.js +1 -0
  80. package/dist/sections-more-C1VNVwkp.js +1 -0
  81. package/dist/sections-more-CMFgfU4d.mjs +3082 -0
  82. package/dist/src/admin/index.d.ts +3 -3
  83. package/dist/src/admin/index.d.ts.map +1 -1
  84. package/dist/src/admin/plugin.d.ts.map +1 -1
  85. package/dist/src/admin/types.d.ts +2 -6
  86. package/dist/src/admin/types.d.ts.map +1 -1
  87. package/dist/src/admin.d.ts +9 -0
  88. package/dist/src/admin.d.ts.map +1 -0
  89. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +4 -0
  90. package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +1 -0
  91. package/dist/src/components/admin/PaymentReadinessChecklist.d.ts +9 -0
  92. package/dist/src/components/admin/PaymentReadinessChecklist.d.ts.map +1 -0
  93. package/dist/src/components/admin/PaymentSettingsSection.d.ts.map +1 -1
  94. package/dist/src/components/admin/PaymentSetupGuide.d.ts +6 -0
  95. package/dist/src/components/admin/PaymentSetupGuide.d.ts.map +1 -0
  96. package/dist/src/components/admin/ProductsSection.d.ts.map +1 -1
  97. package/dist/src/components/admin/configApi.d.ts +1 -1
  98. package/dist/src/components/admin/configApi.d.ts.map +1 -1
  99. package/dist/src/components/admin/icons.d.ts +3 -50
  100. package/dist/src/components/admin/icons.d.ts.map +1 -1
  101. package/dist/src/components/admin/index.d.ts +1 -1
  102. package/dist/src/components/admin/index.d.ts.map +1 -1
  103. package/dist/src/components/admin/types.d.ts +43 -0
  104. package/dist/src/components/admin/types.d.ts.map +1 -1
  105. package/dist/src/context/CedrosContext.d.ts +2 -0
  106. package/dist/src/context/CedrosContext.d.ts.map +1 -1
  107. package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts +2 -0
  108. package/dist/src/ecommerce/__tests__/featureFlags.test.d.ts.map +1 -0
  109. package/dist/src/ecommerce/adapters/paywall/paywallAdapter.d.ts.map +1 -1
  110. package/dist/src/ecommerce/components/general/ErrorBoundary.d.ts +1 -1
  111. package/dist/src/ecommerce/components/ui/button.d.ts +1 -1
  112. package/dist/src/ecommerce/components/ui/sheet.d.ts +1 -1
  113. package/dist/src/ecommerce/config/context.d.ts +2 -0
  114. package/dist/src/ecommerce/config/context.d.ts.map +1 -1
  115. package/dist/src/ecommerce/config/types.d.ts +2 -0
  116. package/dist/src/ecommerce/config/types.d.ts.map +1 -1
  117. package/dist/src/ecommerce/index.d.ts +2 -0
  118. package/dist/src/ecommerce/index.d.ts.map +1 -1
  119. package/dist/src/featureFlags.d.ts +41 -0
  120. package/dist/src/featureFlags.d.ts.map +1 -0
  121. package/dist/src/index.d.ts +4 -2
  122. package/dist/src/index.d.ts.map +1 -1
  123. package/dist/src/managers/StripeManager.d.ts.map +1 -1
  124. package/dist/src/managers/SubscriptionManager.d.ts +1 -0
  125. package/dist/src/managers/SubscriptionManager.d.ts.map +1 -1
  126. package/dist/src/types/index.d.ts +14 -1
  127. package/dist/src/types/index.d.ts.map +1 -1
  128. package/dist/src/types/subscription.d.ts +47 -1
  129. package/dist/src/types/subscription.d.ts.map +1 -1
  130. package/dist/src/utils/validateConfig.d.ts.map +1 -1
  131. package/dist/stripe-only.js +1 -1
  132. package/dist/stripe-only.mjs +35 -33
  133. package/dist/styles--fxb3lCl.js +1 -0
  134. package/dist/{styles-D4SQkuV3.mjs → styles-DGagylUj.mjs} +53 -51
  135. package/dist/testing/index.js +1 -1
  136. package/dist/testing/index.mjs +1 -1
  137. package/dist/tokenMintValidator-DAjQld0r.mjs +98 -0
  138. package/dist/tokenMintValidator-DNBhoefh.js +4 -0
  139. package/dist/{walletPool-DE-t1wSW.mjs → walletPool-9MylB2QK.mjs} +1 -1
  140. package/dist/walletPool-BjTXX6Vn.js +1 -0
  141. package/package.json +6 -5
  142. package/dist/AutosaveIndicator-Dn_qA2hK.js +0 -1
  143. package/dist/CedrosContext-C2RjHLaQ.js +0 -6
  144. package/dist/CedrosContext-CY6zvjvJ.mjs +0 -2801
  145. package/dist/ChatLogsSection-BH5tLA4T.js +0 -1
  146. package/dist/ComplianceSection-DP2a9-S0.js +0 -1
  147. package/dist/CryptoButton-DpiCnyXE.js +0 -1
  148. package/dist/CustomersSection-CBwy_waO.js +0 -1
  149. package/dist/DisputesSection-BLjIk60n.js +0 -1
  150. package/dist/FAQSection-wNeH0i6Q.js +0 -1
  151. package/dist/ImagesSection-0ZzKlzMJ.js +0 -1
  152. package/dist/InventorySection-zV6lTmue.js +0 -1
  153. package/dist/MessagingSection-B_wdFR0j.js +0 -1
  154. package/dist/OrdersSection-Dw2FX-1d.js +0 -1
  155. package/dist/PaymentSettingsSection-BYF4D-GR.js +0 -1
  156. package/dist/PaymentSettingsSection-EnMxeWjv.mjs +0 -94
  157. package/dist/ReturnsSection-D_pJVxuG.js +0 -1
  158. package/dist/ShippingSection-1DRSTu49.js +0 -1
  159. package/dist/SingleCategorySettings-DwCnBdRf.js +0 -3
  160. package/dist/StorefrontSection-RumGkb3C.js +0 -1
  161. package/dist/SubscriptionsSection-C2aLLn7L.js +0 -1
  162. package/dist/TaxSection-Dt1DnM51.js +0 -1
  163. package/dist/Token22Section-DY3mUwTY.js +0 -1
  164. package/dist/WalletManager-B3UdQ5pQ.js +0 -1
  165. package/dist/WebhooksSection-CKeiJ7Py.js +0 -1
  166. package/dist/configApi-DkduMQg1.js +0 -1
  167. package/dist/index-C0g-JxJk.js +0 -84
  168. package/dist/index-DXnuQp5x.mjs +0 -22128
  169. package/dist/sections-C1NpK7hk.mjs +0 -9
  170. package/dist/sections-DVVSZBhW.js +0 -1
  171. package/dist/styles-BT4bhFey.js +0 -1
  172. package/dist/walletPool-IS7R3MR1.js +0 -1
@@ -1,7 +1,8 @@
1
1
  import { jsxs as t, jsx as e, Fragment as O } from "react/jsx-runtime";
2
2
  import { useState as p, useCallback as M, useEffect as H, useRef as Te } from "react";
3
- import { E as Ne, I as Be } from "./index-DXnuQp5x.mjs";
4
- import { a as ae } from "./configApi-6XhAJGKX.mjs";
3
+ import { I as Ne } from "./sectionIds-DBavltrL.mjs";
4
+ import { E as Be } from "./ErrorBanner-CZXsHi3H.mjs";
5
+ import { C as ae } from "./configApi-BUXZOMWK.mjs";
5
6
  const ke = [
6
7
  { value: "text", label: "Short Text" },
7
8
  { value: "email", label: "Email" },
@@ -1959,7 +1960,7 @@ function le({ label: n, met: r }) {
1959
1960
  /* @__PURE__ */ e("span", { style: { opacity: r ? 0.8 : 0.5 }, children: n })
1960
1961
  ] });
1961
1962
  }
1962
- function ft({ serverUrl: n, apiKey: r, authManager: a }) {
1963
+ function bt({ serverUrl: n, apiKey: r, authManager: a }) {
1963
1964
  const [i, s] = p(null), [c, f] = p([]), [h, S] = p(!0), [o, l] = p(null), [m, w] = p("mint"), [b, _] = p({
1964
1965
  treasuryAddress: "",
1965
1966
  tokenSymbol: "storeUSD",
@@ -2039,7 +2040,7 @@ function ft({ serverUrl: n, apiKey: r, authManager: a }) {
2039
2040
  }
2040
2041
  };
2041
2042
  return /* @__PURE__ */ t("div", { className: "cedros-admin__page", children: [
2042
- /* @__PURE__ */ e(Ne, { message: o, onRetry: C }),
2043
+ /* @__PURE__ */ e(Be, { message: o, onRetry: C }),
2043
2044
  /* @__PURE__ */ e("div", { style: { display: "flex", gap: 0, borderBottom: "1px solid rgba(0,0,0,0.1)", marginBottom: "1rem" }, children: ["mint", "inventory", "analytics", "redemptions", "compliance", "liquidity", "asset-classes", "asset-redemptions"].map((k) => /* @__PURE__ */ e(
2044
2045
  "button",
2045
2046
  {
@@ -2059,7 +2060,7 @@ function ft({ serverUrl: n, apiKey: r, authManager: a }) {
2059
2060
  k
2060
2061
  )) }),
2061
2062
  h ? /* @__PURE__ */ t("div", { className: "cedros-admin__loading", children: [
2062
- Be.loading,
2063
+ Ne.loading,
2063
2064
  " Loading..."
2064
2065
  ] }) : m === "mint" ? /* @__PURE__ */ e(
2065
2066
  mt,
@@ -2256,5 +2257,5 @@ function ut({
2256
2257
  ] }) }) : /* @__PURE__ */ e("div", { style: { padding: "2rem", textAlign: "center", opacity: 0.6 }, children: "No gift card redemptions yet." });
2257
2258
  }
2258
2259
  export {
2259
- ft as Token22Section
2260
+ bt as Token22Section
2260
2261
  };
@@ -1,8 +1,10 @@
1
- import { clusterApiUrl as C, Connection as b, Transaction as P, PublicKey as l, TransactionInstruction as R, LAMPORTS_PER_SOL as x } from "@solana/web3.js";
1
+ import { clusterApiUrl as b, Connection as C, Transaction as P, PublicKey as l, TransactionInstruction as R, LAMPORTS_PER_SOL as x } from "@solana/web3.js";
2
2
  import { getAssociatedTokenAddress as T, createTransferInstruction as A } from "@solana/spl-token";
3
- import { h as v, f as B, i as u, k as S, r as m, e as g, b as w, l as f, m as M } from "./CedrosContext-CY6zvjvJ.mjs";
3
+ import { g as u, b as d } from "./fetchWithTimeout-DmMOwL0Q.mjs";
4
4
  import { b as k } from "./index-BFt38o8Q.mjs";
5
- class z {
5
+ import { g as v, f as B, k as m, e as g, b as f, l as S } from "./CedrosContext-5Gjveoba.mjs";
6
+ import { v as M } from "./tokenMintValidator-DAjQld0r.mjs";
7
+ class Q {
6
8
  connection;
7
9
  cluster;
8
10
  endpoint;
@@ -25,8 +27,8 @@ class z {
25
27
  * Create Solana RPC connection
26
28
  */
27
29
  createConnection() {
28
- const r = this.endpoint ?? C(this.cluster);
29
- return new b(r, "confirmed");
30
+ const r = this.endpoint ?? b(this.cluster);
31
+ return new C(r, "confirmed");
30
32
  }
31
33
  /**
32
34
  * Transform RPC errors into user-friendly messages
@@ -50,7 +52,7 @@ class z {
50
52
  const a = new P(), s = this.resolveAmountInMinorUnits(e), o = e.asset;
51
53
  if (!o)
52
54
  throw new Error("asset is required in x402 requirement");
53
- const c = S(o, e.resource, this.allowUnknownMint);
55
+ const c = M(o, e.resource, this.allowUnknownMint);
54
56
  if (!c.isValid && c.error)
55
57
  throw new Error(c.error);
56
58
  c.warning && u().warn(c.warning);
@@ -67,7 +69,7 @@ class z {
67
69
  { ...g.QUICK, name: "rpc-get-account-info" }
68
70
  ));
69
71
  } catch (i) {
70
- throw i instanceof w ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(i);
72
+ throw i instanceof f ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(i);
71
73
  }
72
74
  if (!y)
73
75
  throw new Error("Payer is missing an associated token account for this mint");
@@ -92,22 +94,22 @@ class z {
92
94
  });
93
95
  a.add(i);
94
96
  }
95
- let d;
97
+ let w;
96
98
  if (n)
97
- d = n;
99
+ w = n;
98
100
  else {
99
101
  if (!this.rpcRateLimiter.tryConsume())
100
102
  throw new Error("RPC rate limit exceeded. Please try again in a moment.");
101
103
  try {
102
- d = (await this.rpcCircuitBreaker.execute(async () => await m(
104
+ w = (await this.rpcCircuitBreaker.execute(async () => await m(
103
105
  async () => await this.connection.getLatestBlockhash(),
104
106
  { ...g.QUICK, name: "rpc-get-blockhash" }
105
107
  ))).blockhash;
106
108
  } catch (i) {
107
- throw i instanceof w ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(i);
109
+ throw i instanceof f ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(i);
108
110
  }
109
111
  }
110
- return a.recentBlockhash = d, e.extra?.feePayer ? a.feePayer = new l(e.extra.feePayer) : a.feePayer = t, a;
112
+ return a.recentBlockhash = w, e.extra?.feePayer ? a.feePayer = new l(e.extra.feePayer) : a.feePayer = t, a;
111
113
  }
112
114
  /**
113
115
  * Parse amount from x402 requirement (already in atomic units as string).
@@ -151,7 +153,7 @@ class z {
151
153
  throw new Error("Signed transaction missing signature");
152
154
  const o = k.encode(s);
153
155
  return u().debug("[WalletManager] Transaction signed with signature:", o.substring(0, 20) + "..."), {
154
- serialized: f.fromUint8Array(a),
156
+ serialized: d.fromUint8Array(a),
155
157
  signature: o
156
158
  };
157
159
  }
@@ -161,11 +163,11 @@ class z {
161
163
  */
162
164
  deserializeTransaction(r) {
163
165
  try {
164
- const e = f.toUint8Array(r);
166
+ const e = d.toUint8Array(r);
165
167
  return P.from(e);
166
168
  } catch (e) {
167
169
  throw new Error(
168
- `Failed to deserialize transaction: ${M(e, "Unknown error")}`
170
+ `Failed to deserialize transaction: ${S(e, "Unknown error")}`
169
171
  );
170
172
  }
171
173
  }
@@ -185,7 +187,7 @@ class z {
185
187
  requireAllSignatures: !1,
186
188
  verifySignatures: !1
187
189
  });
188
- return f.fromUint8Array(o);
190
+ return d.fromUint8Array(o);
189
191
  }
190
192
  /**
191
193
  * Get wallet balance
@@ -199,7 +201,7 @@ class z {
199
201
  { ...g.QUICK, name: "rpc-get-balance" }
200
202
  )) / x;
201
203
  } catch (e) {
202
- throw e instanceof w ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(e);
204
+ throw e instanceof f ? new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments.") : this.transformRpcError(e);
203
205
  }
204
206
  }
205
207
  /**
@@ -214,10 +216,10 @@ class z {
214
216
  { ...g.QUICK, name: "rpc-verify-tx" }
215
217
  ))).value?.confirmationStatus;
216
218
  } catch (e) {
217
- return e instanceof w && u().warn("[WalletManager] Circuit breaker OPEN - cannot verify transaction"), !1;
219
+ return e instanceof f && u().warn("[WalletManager] Circuit breaker OPEN - cannot verify transaction"), !1;
218
220
  }
219
221
  }
220
222
  }
221
223
  export {
222
- z as WalletManager
224
+ Q as WalletManager
223
225
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@solana/web3.js"),w=require("@solana/spl-token"),c=require("./fetchWithTimeout-CG0EKbhf.js"),y=require("./index-WcOlBYZJ.js"),n=require("./CedrosContext-CCakH2SZ.js"),E=require("./tokenMintValidator-DNBhoefh.js");class P{connection;cluster;endpoint;allowUnknownMint;rpcRateLimiter=n.createRateLimiter({maxRequests:50,windowMs:6e4});rpcCircuitBreaker=n.createCircuitBreaker({failureThreshold:5,timeout:1e4,name:"solana-rpc"});constructor(r="mainnet-beta",e,t=!1){this.cluster=r,this.endpoint=e,this.allowUnknownMint=t,this.connection=this.createConnection()}createConnection(){const r=this.endpoint??o.clusterApiUrl(this.cluster);return new o.Connection(r,"confirmed")}transformRpcError(r){const e=r instanceof Error?r.message:typeof r=="string"?r:String(r);return e.includes("403")||e.includes("Access forbidden")?new Error("Public Solana RPC access denied. Please configure a custom RPC endpoint (e.g., from Helius, QuickNode, or Alchemy) in your CedrosProvider config using the solanaEndpoint option."):e.includes("429")||e.includes("Too Many Requests")?new Error("Solana RPC rate limit exceeded. Please configure a custom RPC endpoint with higher limits in your CedrosProvider config using the solanaEndpoint option."):r instanceof Error?r:new Error(e)}async buildTransaction(r){const{requirement:e,payerPublicKey:t,blockhash:a}=r;if(!e||!e.payTo)throw new Error("Invalid requirement: missing payTo");c.getLogger().debug("[WalletManager] Building transaction for resource:",e.resource);const i=new o.Transaction,l=this.resolveAmountInMinorUnits(e),u=e.asset;if(!u)throw new Error("asset is required in x402 requirement");const g=E.validateX402Asset(u,e.resource,this.allowUnknownMint);if(!g.isValid&&g.error)throw new Error(g.error);g.warning&&c.getLogger().warn(g.warning);const p=new o.PublicKey(u),d=await w.getAssociatedTokenAddress(p,t);if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded. Please try again in a moment.");let f;try{f=await this.rpcCircuitBreaker.execute(async()=>await n.retryWithBackoff(async()=>await this.connection.getAccountInfo(d),{...n.RETRY_PRESETS.QUICK,name:"rpc-get-account-info"}))}catch(s){throw s instanceof n.CircuitBreakerOpenError?new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments."):this.transformRpcError(s)}if(!f)throw new Error("Payer is missing an associated token account for this mint");let h;try{h=e.extra?.recipientTokenAccount?new o.PublicKey(e.extra.recipientTokenAccount):new o.PublicKey(e.payTo)}catch(s){throw c.getLogger().warn("[WalletManager] Failed to resolve recipient address:",s),new Error("We are currently unable to process payment, please try again later")}if(i.add(w.createTransferInstruction(d,h,t,l)),e.extra?.memo){const s=new o.TransactionInstruction({keys:[],programId:new o.PublicKey("MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"),data:Buffer.from(e.extra.memo,"utf8")});i.add(s)}let m;if(a)m=a;else{if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded. Please try again in a moment.");try{m=(await this.rpcCircuitBreaker.execute(async()=>await n.retryWithBackoff(async()=>await this.connection.getLatestBlockhash(),{...n.RETRY_PRESETS.QUICK,name:"rpc-get-blockhash"}))).blockhash}catch(s){throw s instanceof n.CircuitBreakerOpenError?new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments."):this.transformRpcError(s)}}return i.recentBlockhash=m,e.extra?.feePayer?i.feePayer=new o.PublicKey(e.extra.feePayer):i.feePayer=t,i}resolveAmountInMinorUnits(r){const e=r.maxAmountRequired;if(!/^\d+$/.test(e))throw new Error("Invalid maxAmountRequired in requirement: must be a non-negative integer string");const t=BigInt(e);if(t<=0n)throw new Error("Invalid maxAmountRequired in requirement");return t}buildPaymentPayload(r){const{requirement:e,signedTx:t,payerPublicKey:a}=r;return{x402Version:0,scheme:e.scheme,network:e.network,payload:{signature:t.signature,transaction:t.serialized,payer:a.toString(),memo:e.extra?.memo,recipientTokenAccount:e.extra?.recipientTokenAccount}}}async signTransaction(r){const{transaction:e,signTransaction:t}=r;c.getLogger().debug("[WalletManager] Requesting wallet to sign transaction");const a=await t(e),i=a.serialize(),l=a.signatures[0]?.signature;if(!l)throw new Error("Signed transaction missing signature");const u=y.bs58.encode(l);return c.getLogger().debug("[WalletManager] Transaction signed with signature:",u.substring(0,20)+"..."),{serialized:c.gBase64.fromUint8Array(i),signature:u}}deserializeTransaction(r){try{const e=c.gBase64.toUint8Array(r);return o.Transaction.from(e)}catch(e){throw new Error(`Failed to deserialize transaction: ${n.formatError(e,"Unknown error")}`)}}async partiallySignTransaction(r){const{transaction:e,signTransaction:t,blockhash:a}=r;a&&e.recentBlockhash!==a&&(e.recentBlockhash=a);const i=await t(e),l=i.signatures[0]?.signature;if(l){const g=y.bs58.encode(l);c.getLogger().debug("[WalletManager] Partially signed with signature:",g.substring(0,20)+"...")}const u=i.serialize({requireAllSignatures:!1,verifySignatures:!1});return c.gBase64.fromUint8Array(u)}async getBalance(r){if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded. Please try again in a moment.");try{return await this.rpcCircuitBreaker.execute(async()=>await n.retryWithBackoff(async()=>await this.connection.getBalance(r),{...n.RETRY_PRESETS.QUICK,name:"rpc-get-balance"}))/o.LAMPORTS_PER_SOL}catch(e){throw e instanceof n.CircuitBreakerOpenError?new Error("Solana RPC service is temporarily unavailable. Please try again in a few moments."):this.transformRpcError(e)}}async verifyTransaction(r){if(!this.rpcRateLimiter.tryConsume())throw new Error("RPC rate limit exceeded for transaction verification");try{return!!(await this.rpcCircuitBreaker.execute(async()=>await n.retryWithBackoff(async()=>await this.connection.getSignatureStatus(r),{...n.RETRY_PRESETS.QUICK,name:"rpc-verify-tx"}))).value?.confirmationStatus}catch(e){return e instanceof n.CircuitBreakerOpenError&&c.getLogger().warn("[WalletManager] Circuit breaker OPEN - cannot verify transaction"),!1}}}exports.WalletManager=P;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react"),q=require("./sectionIds-B_tFiNvF.js"),D=require("./ErrorBanner-Cx2dUhps.js"),E=require("./dateHelpers-BKW_lGND.js"),U=n=>n==="success"?"success":n==="failed"?"failed":n==="pending"||n==="processing"?"pending":"muted",x=(n,d=48)=>n.length>d?`${n.slice(0,d)}…`:n;function O({serverUrl:n,apiKey:d,authManager:j}){const[a,L]=s.useState("active"),[y,p]=s.useState([]),[c,W]=s.useState(0),[h,C]=s.useState("all"),[N,f]=s.useState(!0),[_,g]=s.useState([]),[k,T]=s.useState(0),[F,v]=s.useState(!1),[w,A]=s.useState(!1),[$,l]=s.useState(null),[z,o]=s.useState(null),r=s.useCallback(async(t,i)=>{if(j?.isAuthenticated())return j.fetchWithAuth(t,i);const S={"Content-Type":"application/json"};d&&(S["X-API-Key"]=d);const u=await fetch(`${n}${t}`,{...i,headers:{...S,...i?.headers}});if(!u.ok)throw new Error(`Request failed: ${u.status}`);if(u.status!==204)return u.json()},[n,d,j]),m=s.useCallback(async()=>{f(!0),l(null);try{const t=new URLSearchParams({limit:"100"});h!=="all"&&t.set("status",h);const i=await r(`/admin/webhooks?${t.toString()}`);p(i.webhooks??[]),W(i.count??0)}catch{l("Failed to load webhooks"),p([])}finally{f(!1)}},[r,h]);s.useEffect(()=>{m()},[m]);const b=s.useCallback(async()=>{v(!0),l(null);try{const t=await r("/admin/webhooks/dlq?limit=100");g(t.webhooks??[]),T(t.count??0),A(!0)}catch{l("Failed to load DLQ webhooks"),g([])}finally{v(!1)}},[r]),R=t=>{L(t),l(null),o(null),t==="dlq"&&!w&&b()},I=async t=>{o(null);try{await r(`/admin/webhooks/${encodeURIComponent(t)}/retry`,{method:"POST"}),m()}catch{o("Failed to retry webhook")}},B=async t=>{if(window.confirm("Delete this webhook?")){o(null);try{await r(`/admin/webhooks/${encodeURIComponent(t)}`,{method:"DELETE"}),m()}catch{o("Failed to delete webhook")}}},Q=async t=>{o(null);try{await r(`/admin/webhooks/dlq/${encodeURIComponent(t)}/retry`,{method:"POST"}),b()}catch{o("Failed to retry DLQ webhook")}},P=async t=>{if(window.confirm("Delete this DLQ entry?")){o(null);try{await r(`/admin/webhooks/dlq/${encodeURIComponent(t)}`,{method:"DELETE"}),b()}catch{o("Failed to delete DLQ entry")}}};return e.jsxs("div",{children:[e.jsx("div",{className:"cedros-admin__section-header",children:e.jsx("h3",{className:"cedros-admin__section-title",children:"Webhooks"})}),e.jsx(D.ErrorBanner,{message:$}),e.jsx(D.ErrorBanner,{message:z}),e.jsx("div",{style:{display:"flex",gap:"0.25rem",marginBottom:"1rem",borderBottom:"1px solid var(--cedros-admin-border, #e0e0e0)"},children:["active","dlq"].map(t=>e.jsx("button",{type:"button",onClick:()=>R(t),style:{padding:"0.5rem 1rem",fontSize:"0.85rem",fontWeight:a===t?600:400,background:"none",border:"none",borderBottom:a===t?"2px solid var(--cedros-admin-primary, #000)":"2px solid transparent",cursor:"pointer",color:a===t?"var(--cedros-admin-text, #333)":"var(--cedros-admin-text-muted, #888)",marginBottom:"-1px"},children:t==="active"?`Active Webhooks${c>0?` (${c})`:""}`:`Dead Letter Queue${k>0?` (${k})`:""}`},t))}),a==="active"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",gap:"0.5rem",marginBottom:"1rem",alignItems:"center"},children:[e.jsxs("select",{className:"cedros-admin__input",value:h,onChange:t=>{C(t.target.value)},style:{width:"auto",fontSize:"0.85rem"},children:[e.jsx("option",{value:"all",children:"All statuses"}),e.jsx("option",{value:"pending",children:"Pending"}),e.jsx("option",{value:"processing",children:"Processing"}),e.jsx("option",{value:"failed",children:"Failed"}),e.jsx("option",{value:"success",children:"Success"})]}),e.jsxs("span",{style:{fontSize:"0.85rem",color:"var(--cedros-admin-text-muted, #888)"},children:[c," webhook",c!==1?"s":""]})]}),N?e.jsxs("div",{className:"cedros-admin__loading",children:[q.Icons.loading," Loading webhooks..."]}):y.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"No webhooks found."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Event Type"}),e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Attempts"}),e.jsx("th",{children:"Last Error"}),e.jsx("th",{children:"Created"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:y.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{maxWidth:"200px"},children:e.jsx("span",{title:t.url,style:{fontSize:"0.8rem",fontFamily:"monospace"},children:x(t.url,40)})}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.eventType}),e.jsx("td",{children:e.jsx("span",{className:`cedros-admin__badge cedros-admin__badge--${U(t.status)}`,children:t.status})}),e.jsxs("td",{style:{fontSize:"0.85rem"},children:[t.attempts,"/",t.maxAttempts]}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"180px",color:"var(--cedros-admin-text-muted, #888)"},children:t.lastError?e.jsx("span",{title:t.lastError,children:x(t.lastError,40)}):"—"}),e.jsx("td",{style:{fontSize:"0.8rem"},children:E.formatDateTime(t.createdAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>I(t.id),children:"Retry"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>B(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})]}),a==="dlq"&&e.jsx(e.Fragment,{children:F?e.jsxs("div",{className:"cedros-admin__loading",children:[q.Icons.loading," Loading DLQ..."]}):_.length===0?e.jsx("div",{className:"cedros-admin__empty",children:"Dead Letter Queue is empty."}):e.jsx("div",{className:"cedros-admin__table-container",children:e.jsxs("table",{className:"cedros-admin__table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"URL"}),e.jsx("th",{children:"Event Type"}),e.jsx("th",{children:"Attempts"}),e.jsx("th",{children:"Final Error"}),e.jsx("th",{children:"Moved to DLQ"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:_.map(t=>e.jsxs("tr",{children:[e.jsx("td",{style:{maxWidth:"200px"},children:e.jsx("span",{title:t.url,style:{fontSize:"0.8rem",fontFamily:"monospace"},children:x(t.url,40)})}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.eventType}),e.jsx("td",{style:{fontSize:"0.85rem"},children:t.totalAttempts}),e.jsx("td",{style:{fontSize:"0.8rem",maxWidth:"200px",color:"var(--cedros-admin-text-muted, #888)"},children:e.jsx("span",{title:t.finalError,children:x(t.finalError,40)})}),e.jsx("td",{style:{fontSize:"0.8rem"},children:E.formatDateTime(t.movedToDlqAt)}),e.jsx("td",{children:e.jsxs("div",{style:{display:"flex",gap:"0.25rem"},children:[e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>Q(t.id),children:"Retry"}),e.jsx("button",{type:"button",className:"cedros-admin__button cedros-admin__button--ghost cedros-admin__button--sm",onClick:()=>P(t.id),style:{color:"var(--cedros-admin-danger, #c00)"},children:"Delete"})]})})]},t.id))})]})})})]})}exports.WebhooksSection=O;
@@ -1,30 +1,32 @@
1
- import { jsxs as n, jsx as t, Fragment as q } from "react/jsx-runtime";
1
+ import { jsxs as o, jsx as t, Fragment as q } from "react/jsx-runtime";
2
2
  import { useState as r, useCallback as _, useEffect as G } from "react";
3
- import { E as W, I as C, k as N } from "./index-DXnuQp5x.mjs";
4
- const H = (o) => o === "success" ? "success" : o === "failed" ? "failed" : o === "pending" || o === "processing" ? "pending" : "muted", y = (o, s = 48) => o.length > s ? `${o.slice(0, s)}…` : o;
5
- function Z({ serverUrl: o, apiKey: s, authManager: p }) {
6
- const [a, w] = r("active"), [g, k] = r([]), [h, A] = r(0), [m, F] = r("all"), [T, v] = r(!0), [x, D] = r([]), [E, $] = r(0), [z, S] = r(!1), [I, R] = r(!1), [Q, c] = r(null), [B, d] = r(null), i = _(async (e, l) => {
7
- if (p?.isAuthenticated())
8
- return p.fetchWithAuth(e, l);
3
+ import { I as W } from "./sectionIds-DBavltrL.mjs";
4
+ import { E as C } from "./ErrorBanner-CZXsHi3H.mjs";
5
+ import { f as N } from "./dateHelpers-yvPkofYQ.mjs";
6
+ const H = (n) => n === "success" ? "success" : n === "failed" ? "failed" : n === "pending" || n === "processing" ? "pending" : "muted", p = (n, s = 48) => n.length > s ? `${n.slice(0, s)}…` : n;
7
+ function M({ serverUrl: n, apiKey: s, authManager: y }) {
8
+ const [a, w] = r("active"), [g, v] = r([]), [h, A] = r(0), [m, F] = r("all"), [T, k] = r(!0), [x, D] = r([]), [E, $] = r(0), [z, S] = r(!1), [I, R] = r(!1), [Q, c] = r(null), [B, d] = r(null), i = _(async (e, l) => {
9
+ if (y?.isAuthenticated())
10
+ return y.fetchWithAuth(e, l);
9
11
  const L = { "Content-Type": "application/json" };
10
12
  s && (L["X-API-Key"] = s);
11
- const b = await fetch(`${o}${e}`, { ...l, headers: { ...L, ...l?.headers } });
13
+ const b = await fetch(`${n}${e}`, { ...l, headers: { ...L, ...l?.headers } });
12
14
  if (!b.ok) throw new Error(`Request failed: ${b.status}`);
13
15
  if (b.status !== 204)
14
16
  return b.json();
15
- }, [o, s, p]), u = _(async () => {
16
- v(!0), c(null);
17
+ }, [n, s, y]), u = _(async () => {
18
+ k(!0), c(null);
17
19
  try {
18
20
  const e = new URLSearchParams({ limit: "100" });
19
21
  m !== "all" && e.set("status", m);
20
22
  const l = await i(
21
23
  `/admin/webhooks?${e.toString()}`
22
24
  );
23
- k(l.webhooks ?? []), A(l.count ?? 0);
25
+ v(l.webhooks ?? []), A(l.count ?? 0);
24
26
  } catch {
25
- c("Failed to load webhooks"), k([]);
27
+ c("Failed to load webhooks"), v([]);
26
28
  } finally {
27
- v(!1);
29
+ k(!1);
28
30
  }
29
31
  }, [i, m]);
30
32
  G(() => {
@@ -77,10 +79,10 @@ function Z({ serverUrl: o, apiKey: s, authManager: p }) {
77
79
  }
78
80
  }
79
81
  };
80
- return /* @__PURE__ */ n("div", { children: [
82
+ return /* @__PURE__ */ o("div", { children: [
81
83
  /* @__PURE__ */ t("div", { className: "cedros-admin__section-header", children: /* @__PURE__ */ t("h3", { className: "cedros-admin__section-title", children: "Webhooks" }) }),
82
- /* @__PURE__ */ t(W, { message: Q }),
83
- /* @__PURE__ */ t(W, { message: B }),
84
+ /* @__PURE__ */ t(C, { message: Q }),
85
+ /* @__PURE__ */ t(C, { message: B }),
84
86
  /* @__PURE__ */ t("div", { style: { display: "flex", gap: "0.25rem", marginBottom: "1rem", borderBottom: "1px solid var(--cedros-admin-border, #e0e0e0)" }, children: ["active", "dlq"].map((e) => /* @__PURE__ */ t(
85
87
  "button",
86
88
  {
@@ -101,9 +103,9 @@ function Z({ serverUrl: o, apiKey: s, authManager: p }) {
101
103
  },
102
104
  e
103
105
  )) }),
104
- a === "active" && /* @__PURE__ */ n(q, { children: [
105
- /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "1rem", alignItems: "center" }, children: [
106
- /* @__PURE__ */ n(
106
+ a === "active" && /* @__PURE__ */ o(q, { children: [
107
+ /* @__PURE__ */ o("div", { style: { display: "flex", gap: "0.5rem", marginBottom: "1rem", alignItems: "center" }, children: [
108
+ /* @__PURE__ */ o(
107
109
  "select",
108
110
  {
109
111
  className: "cedros-admin__input",
@@ -121,17 +123,17 @@ function Z({ serverUrl: o, apiKey: s, authManager: p }) {
121
123
  ]
122
124
  }
123
125
  ),
124
- /* @__PURE__ */ n("span", { style: { fontSize: "0.85rem", color: "var(--cedros-admin-text-muted, #888)" }, children: [
126
+ /* @__PURE__ */ o("span", { style: { fontSize: "0.85rem", color: "var(--cedros-admin-text-muted, #888)" }, children: [
125
127
  h,
126
128
  " webhook",
127
129
  h !== 1 ? "s" : ""
128
130
  ] })
129
131
  ] }),
130
- T ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
131
- C.loading,
132
+ T ? /* @__PURE__ */ o("div", { className: "cedros-admin__loading", children: [
133
+ W.loading,
132
134
  " Loading webhooks..."
133
- ] }) : g.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No webhooks found." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
134
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ n("tr", { children: [
135
+ ] }) : g.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "No webhooks found." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ o("table", { className: "cedros-admin__table", children: [
136
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ o("tr", { children: [
135
137
  /* @__PURE__ */ t("th", { children: "URL" }),
136
138
  /* @__PURE__ */ t("th", { children: "Event Type" }),
137
139
  /* @__PURE__ */ t("th", { children: "Status" }),
@@ -140,18 +142,18 @@ function Z({ serverUrl: o, apiKey: s, authManager: p }) {
140
142
  /* @__PURE__ */ t("th", { children: "Created" }),
141
143
  /* @__PURE__ */ t("th", {})
142
144
  ] }) }),
143
- /* @__PURE__ */ t("tbody", { children: g.map((e) => /* @__PURE__ */ n("tr", { children: [
144
- /* @__PURE__ */ t("td", { style: { maxWidth: "200px" }, children: /* @__PURE__ */ t("span", { title: e.url, style: { fontSize: "0.8rem", fontFamily: "monospace" }, children: y(e.url, 40) }) }),
145
+ /* @__PURE__ */ t("tbody", { children: g.map((e) => /* @__PURE__ */ o("tr", { children: [
146
+ /* @__PURE__ */ t("td", { style: { maxWidth: "200px" }, children: /* @__PURE__ */ t("span", { title: e.url, style: { fontSize: "0.8rem", fontFamily: "monospace" }, children: p(e.url, 40) }) }),
145
147
  /* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: e.eventType }),
146
148
  /* @__PURE__ */ t("td", { children: /* @__PURE__ */ t("span", { className: `cedros-admin__badge cedros-admin__badge--${H(e.status)}`, children: e.status }) }),
147
- /* @__PURE__ */ n("td", { style: { fontSize: "0.85rem" }, children: [
149
+ /* @__PURE__ */ o("td", { style: { fontSize: "0.85rem" }, children: [
148
150
  e.attempts,
149
151
  "/",
150
152
  e.maxAttempts
151
153
  ] }),
152
- /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", maxWidth: "180px", color: "var(--cedros-admin-text-muted, #888)" }, children: e.lastError ? /* @__PURE__ */ t("span", { title: e.lastError, children: y(e.lastError, 40) }) : "—" }),
154
+ /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", maxWidth: "180px", color: "var(--cedros-admin-text-muted, #888)" }, children: e.lastError ? /* @__PURE__ */ t("span", { title: e.lastError, children: p(e.lastError, 40) }) : "—" }),
153
155
  /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem" }, children: N(e.createdAt) }),
154
- /* @__PURE__ */ t("td", { children: /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.25rem" }, children: [
156
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ o("div", { style: { display: "flex", gap: "0.25rem" }, children: [
155
157
  /* @__PURE__ */ t(
156
158
  "button",
157
159
  {
@@ -175,11 +177,11 @@ function Z({ serverUrl: o, apiKey: s, authManager: p }) {
175
177
  ] }, e.id)) })
176
178
  ] }) })
177
179
  ] }),
178
- a === "dlq" && /* @__PURE__ */ t(q, { children: z ? /* @__PURE__ */ n("div", { className: "cedros-admin__loading", children: [
179
- C.loading,
180
+ a === "dlq" && /* @__PURE__ */ t(q, { children: z ? /* @__PURE__ */ o("div", { className: "cedros-admin__loading", children: [
181
+ W.loading,
180
182
  " Loading DLQ..."
181
- ] }) : x.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "Dead Letter Queue is empty." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ n("table", { className: "cedros-admin__table", children: [
182
- /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ n("tr", { children: [
183
+ ] }) : x.length === 0 ? /* @__PURE__ */ t("div", { className: "cedros-admin__empty", children: "Dead Letter Queue is empty." }) : /* @__PURE__ */ t("div", { className: "cedros-admin__table-container", children: /* @__PURE__ */ o("table", { className: "cedros-admin__table", children: [
184
+ /* @__PURE__ */ t("thead", { children: /* @__PURE__ */ o("tr", { children: [
183
185
  /* @__PURE__ */ t("th", { children: "URL" }),
184
186
  /* @__PURE__ */ t("th", { children: "Event Type" }),
185
187
  /* @__PURE__ */ t("th", { children: "Attempts" }),
@@ -187,13 +189,13 @@ function Z({ serverUrl: o, apiKey: s, authManager: p }) {
187
189
  /* @__PURE__ */ t("th", { children: "Moved to DLQ" }),
188
190
  /* @__PURE__ */ t("th", {})
189
191
  ] }) }),
190
- /* @__PURE__ */ t("tbody", { children: x.map((e) => /* @__PURE__ */ n("tr", { children: [
191
- /* @__PURE__ */ t("td", { style: { maxWidth: "200px" }, children: /* @__PURE__ */ t("span", { title: e.url, style: { fontSize: "0.8rem", fontFamily: "monospace" }, children: y(e.url, 40) }) }),
192
+ /* @__PURE__ */ t("tbody", { children: x.map((e) => /* @__PURE__ */ o("tr", { children: [
193
+ /* @__PURE__ */ t("td", { style: { maxWidth: "200px" }, children: /* @__PURE__ */ t("span", { title: e.url, style: { fontSize: "0.8rem", fontFamily: "monospace" }, children: p(e.url, 40) }) }),
192
194
  /* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: e.eventType }),
193
195
  /* @__PURE__ */ t("td", { style: { fontSize: "0.85rem" }, children: e.totalAttempts }),
194
- /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", maxWidth: "200px", color: "var(--cedros-admin-text-muted, #888)" }, children: /* @__PURE__ */ t("span", { title: e.finalError, children: y(e.finalError, 40) }) }),
196
+ /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem", maxWidth: "200px", color: "var(--cedros-admin-text-muted, #888)" }, children: /* @__PURE__ */ t("span", { title: e.finalError, children: p(e.finalError, 40) }) }),
195
197
  /* @__PURE__ */ t("td", { style: { fontSize: "0.8rem" }, children: N(e.movedToDlqAt) }),
196
- /* @__PURE__ */ t("td", { children: /* @__PURE__ */ n("div", { style: { display: "flex", gap: "0.25rem" }, children: [
198
+ /* @__PURE__ */ t("td", { children: /* @__PURE__ */ o("div", { style: { display: "flex", gap: "0.25rem" }, children: [
197
199
  /* @__PURE__ */ t(
198
200
  "button",
199
201
  {
@@ -219,5 +221,5 @@ function Z({ serverUrl: o, apiKey: s, authManager: p }) {
219
221
  ] });
220
222
  }
221
223
  export {
222
- Z as WebhooksSection
224
+ M as WebhooksSection
223
225
  };
@@ -0,0 +1,2 @@
1
+ export * from './src/admin'
2
+ export {}
package/dist/admin.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("./sectionIds-B_tFiNvF.js");exports.CEDROS_PAY_GROUPS=S.CEDROS_PAY_GROUPS;exports.CEDROS_PAY_SECTIONS=S.CEDROS_PAY_SECTIONS;exports.CEDROS_PAY_SECTION_IDS=S.CEDROS_PAY_SECTION_IDS;exports.CedrosPayAdminDashboard=S.CedrosPayAdminDashboard;exports.cedrosPayPlugin=S.cedrosPayPlugin;
package/dist/admin.mjs ADDED
@@ -0,0 +1,8 @@
1
+ import { C as S, a as C, b as P, c as _, d as O } from "./sectionIds-DBavltrL.mjs";
2
+ export {
3
+ S as CEDROS_PAY_GROUPS,
4
+ C as CEDROS_PAY_SECTIONS,
5
+ P as CEDROS_PAY_SECTION_IDS,
6
+ _ as CedrosPayAdminDashboard,
7
+ O as cedrosPayPlugin
8
+ };
@@ -0,0 +1 @@
1
+ "use strict";class r{constructor(e,t,i){this._serverUrl=e,this.auth=t,this.authManager=i}get serverUrl(){return this._serverUrl}async fetch(e,t={}){if(this.authManager?.isAuthenticated())return this.authManager.fetchWithAuth(e,t);throw this.auth?new Error("Legacy AdminAuth is no longer supported due to replay vulnerability. Use IAdminAuthManager instead."):new Error("Admin authentication required. Provide an IAdminAuthManager to ConfigApi.")}async listCategories(e=100){return this.fetch(`/admin/config?limit=${e}`)}async getConfig(e,t=!0){return this.fetch(`/admin/config/${e}?redact_secrets=${t}`)}async updateConfig(e,t,i){await this.fetch(`/admin/config/${e}`,{method:"PUT",body:JSON.stringify({config:t,description:i})})}async patchConfig(e,t,i){await this.fetch(`/admin/config/${e}`,{method:"PATCH",body:JSON.stringify({updates:t,description:i})})}async batchUpdate(e){await this.fetch("/admin/config/batch",{method:"POST",body:JSON.stringify({updates:e})})}async validateConfig(e,t){return this.fetch("/admin/config/validate",{method:"POST",body:JSON.stringify({category:e,config:t})})}async getHistory(e,t=50){const i=new URLSearchParams({limit:t.toString()});return e&&i.set("category",e),this.fetch(`/admin/config/history?${i}`)}}const o={server:{label:"Server",secrets:[],icon:"🖥️",fields:{admin_metrics_api_key:{hidden:!0},cors_allowed_origins:{hidden:!0}}},security:{label:"Security",description:"Configure CORS, rate limiting, and other security settings",secrets:[],icon:"🔒",fields:{cors_allowed_origins:{description:'List of allowed origins for CORS requests. Use ["*"] to allow all origins (not recommended for production).'}}},metrics:{label:"Metrics",description:"Configure metrics collection and API access",secrets:["admin_metrics_api_key"],icon:"📊",fields:{admin_metrics_api_key:{description:"API key for accessing the admin metrics endpoint. Keep this secret."}}},logging:{label:"Logging",secrets:[],icon:"📝",fields:{level:{type:"dropdown",options:["trace","debug","info","warn","error"]},format:{hidden:!0},environment:{hidden:!0}}},stripe:{label:"Stripe",secrets:["secret_key","webhook_secret"],icon:"💳",fields:{enabled:{hidden:!0},secret_key:{description:"Stripe Dashboard → Developers → API keys → Secret key. Use the test key (sk_test_...) for testing, or the live key (sk_live_...) for production."},publishable_key:{description:"Stripe Dashboard → Developers → API keys → Publishable key. Starts with pk_test_... or pk_live_..."},mode:{type:"dropdown",options:["test","live"],description:'Use "test" mode with test API keys during development, then switch to "live" with live keys for real payments.'},webhook_url:{description:"The full URL Stripe sends webhook events to. Default is your server URL + /webhook/stripe (e.g. https://example.com/webhook/stripe). Only change this if you've customized the route in your cedros-pay server."},webhook_secret:{description:`Stripe Dashboard → Developers → Webhooks → "Create an event destination" → select events: checkout.session.completed, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.paid, invoice.payment_failed → Continue → choose "Webhook endpoint" → enter your server's webhook endpoint, e.g. https://example.com/webhook/stripe (your server URL + /webhook/stripe) → after creating, click the endpoint and "Click to reveal" the signing secret. Starts with whsec_...`},allowed_redirect_schemes:{type:"array",description:`Optional mobile deep-link URI schemes Cedros should allow for Stripe success/cancel/portal redirects, for example ["covenant"]. Only add your app's custom schemes here. HTTPS links do not need to be listed.`},tax_rate_id:{description:`Stripe Dashboard → More → Product catalog → Tax rates → "+ New" → set the percentage, region, and whether tax is inclusive or exclusive → Save → copy the tax rate ID from the detail page (starts with txr_...). Leave empty if you don't collect tax.`},success_url:{hidden:!0},cancel_url:{hidden:!0}}},native_store:{label:"App Stores",description:"Configure Apple App Store and Google Play billing credentials, notification endpoints, and server-side verification.",secrets:["apple_private_key","google_private_key"],icon:"📱",fields:{enabled:{hidden:!0},apple_enabled:{type:"toggle",description:"Enable Apple App Store verification and lifecycle handling for this tenant."},apple_issuer_id:{description:"App Store Connect → Users and Access → Integrations → App Store Server API → Issuer ID."},apple_key_id:{description:"App Store Connect → Users and Access → Integrations → App Store Server API → Key ID."},apple_private_key:{description:"The contents of your App Store Server API private key (.p8). Keep this secret."},apple_bundle_id:{description:"The bundle identifier of the app that ships with Apple In-App Purchase enabled."},apple_allow_sandbox_fallback:{type:"toggle",description:"When enabled, Cedros will fall back to Apple sandbox verification where appropriate."},google_enabled:{type:"toggle",description:"Enable Google Play purchase verification, acknowledgment, and RTDN processing."},google_service_account_email:{description:"Google Cloud service-account email with Android Publisher API access."},google_private_key:{description:"The private key for the Google service account used to call the Play Developer API."},google_package_name:{description:"Default Android package name for this tenant’s Google Play app."},google_push_service_account_email:{description:"Expected Google-signed Pub/Sub push identity for RTDN requests."},google_push_audience:{description:"Expected RTDN push audience. This should match the audience configured on your Pub/Sub push subscription."}}},x402:{label:"X402 (Crypto)",secrets:["server_wallets"],icon:"⚡",fields:{enabled:{hidden:!0},payment_address:{type:"solana_address",description:"The Solana wallet address where payments are received. This is where customer funds are sent."},token_mint:{type:"token_mint",description:"The SPL token used for payments. Most commonly USDC."},token_decimals:{type:"number",description:"Number of decimal places for the token (e.g., USDC has 6 decimals).",hidden:!0},custom_token_symbol:{description:'Display symbol for your custom token (e.g., "MYTOKEN").',hidden:!0},custom_token_icon:{description:"URL to your token's icon image.",hidden:!0},rpc_url:{description:"Solana RPC endpoint URL. Required for crypto payment verification (e.g., from Helius, QuickNode, or Alchemy)."},gasless_enabled:{type:"toggle",description:"When enabled, your server pays transaction fees so customers don't need SOL."},server_wallets:{type:"secret_array",description:"Server keypair(s) used to sign and pay for transactions. Required for gasless payments.",showWhen:"gasless_enabled"},rounding_mode:{type:"dropdown",options:["nearest","up","down"],description:"How to round fractional token amounts: nearest (default), up (always round up), or down (always round down)."},network:{hidden:!0},ws_url:{hidden:!0},skip_preflight:{hidden:!0},commitment:{hidden:!0},compute_unit_limit:{hidden:!0},compute_unit_price:{hidden:!0}}},paywall:{label:"Paywall",secrets:[],icon:"🚪",fields:{product_cache_ttl:{type:"number",unit:"seconds"}}},coupons:{label:"Coupons",secrets:[],icon:"🎟️",fields:{cache_ttl:{type:"number",unit:"seconds"}}},subscriptions:{label:"Subscriptions",secrets:[],icon:"🔄",fields:{grace_period_hours:{type:"number",unit:"hours"}}},callbacks:{label:"Callbacks",secrets:["hmac_secret"],icon:"🔔"},email:{label:"Email",description:"Email receipts for customers after purchase",secrets:["smtp_password"],icon:"📧",fields:{enabled:{hidden:!0},provider:{type:"dropdown",options:["sendgrid","mailgun","postmark","ses","resend","custom"],description:"Email service provider."},smtp_host:{description:"SMTP server hostname.",showWhen:"provider"},smtp_port:{type:"number",description:"SMTP server port (typically 587 for TLS).",showWhen:"provider"},smtp_user:{description:"SMTP authentication username or API key name.",showWhen:"provider"},smtp_password:{description:"SMTP password or API key.",showWhen:"provider"},from_address:{description:"Sender email address (e.g., orders@yourstore.com)."},from_name:{description:'Sender display name (e.g., "Your Store").'}}},webhook:{label:"Webhook",description:"HTTP notifications when purchases occur",secrets:["secret"],icon:"🔔",fields:{enabled:{hidden:!0},url:{description:"URL to receive POST notifications (e.g., https://api.yoursite.com/webhooks/orders)."},secret:{description:"Shared secret for HMAC-SHA256 signature verification."},retry_attempts:{type:"number",description:"Number of retry attempts on failure (default: 3)."}}},messaging:{label:"Messaging",description:"Email and webhook notifications for purchases",secrets:["smtp_password","webhook_secret"],icon:"📬",fields:{email_enabled:{type:"boolean",description:"Send order confirmation emails to customers."},email_provider:{description:"Email service provider (mailgun, sendgrid, postmark, ses, resend, custom).",showWhen:"email_enabled"},smtp_host:{description:"SMTP server hostname.",showWhen:"email_enabled"},smtp_port:{type:"number",description:"SMTP server port (typically 587 for TLS).",showWhen:"email_enabled"},smtp_username:{description:"SMTP authentication username or API key.",showWhen:"email_enabled"},smtp_password:{description:"SMTP password or API key.",showWhen:"email_enabled"},from_email:{description:"Sender email address (e.g., orders@yourstore.com).",showWhen:"email_enabled"},from_name:{description:'Sender display name (e.g., "Your Store").',showWhen:"email_enabled"},webhook_enabled:{type:"boolean",description:"Send webhook notifications when purchases complete."},webhook_url:{description:"URL to receive POST notifications.",showWhen:"webhook_enabled"},webhook_secret:{description:"Shared secret for HMAC-SHA256 signature verification.",showWhen:"webhook_enabled"},webhook_timeout:{type:"number",description:"Request timeout in seconds (default: 30).",showWhen:"webhook_enabled"}}},monitoring:{label:"Monitoring",secrets:[],icon:"📊",fields:{check_interval:{type:"number",unit:"seconds"},low_balance_threshold:{type:"number",unit:"SOL"}}},rate_limit:{label:"Rate Limiting",secrets:[],icon:"⏱️"},circuit_breaker:{label:"Circuit Breaker",secrets:[],icon:"🔌"},admin:{label:"Admin Keys",secrets:[],icon:"👤"},api_keys:{label:"API Keys",secrets:[],icon:"🔐"},cedros_login:{label:"Cedros Login",secrets:["api_key"],icon:"🔑",fields:{enabled:{hidden:!0},credits_enabled:{hidden:!0},base_url:{hidden:!0},timeout:{hidden:!0},jwt_issuer:{hidden:!0},jwt_audience:{hidden:!0}}},gift_cards:{label:"Gift Cards",description:"Gift card issuance, expiry, and Token-22 secondary market settings",secrets:[],icon:"🎁",fields:{enabled:{hidden:!0},secondary_market_enabled:{type:"toggle",description:"Enable Token-22 secondary market for gift card store credit tokens."},transfer_fee_bps:{type:"number",description:"Transfer fee in basis points charged on secondary market trades (e.g. 250 = 2.5%)."},max_transfer_fee:{type:"number",description:"Maximum transfer fee in token atomic units (e.g. 500 = $5.00 with 2 decimals)."},treasury_address:{type:"solana_address",description:"Solana wallet address where collected transfer fees are sent."},token_name:{description:'Display name for the store credit token (e.g. "Store Credits USD").'},token_symbol:{description:'Token symbol for the store credit token (e.g. "storeUSD").'},token_decimals:{type:"number",description:"Number of decimal places for the token (default: 2 for cent precision)."},mint_address:{type:"solana_address",description:"Solana Token-22 mint address (auto-populated after initialization)."},business_state:{type:"dropdown",options:["AL","AK","AZ","AR","CA","CO","CT","DE","FL","GA","HI","ID","IL","IN","IA","KS","KY","LA","ME","MD","MA","MI","MN","MS","MO","MT","NE","NV","NH","NJ","NM","NY","NC","ND","OH","OK","OR","PA","RI","SC","SD","TN","TX","UT","VT","VA","WA","WV","WI","WY","DC","PR"],description:"US state where your business is registered. Determines applicable gift card regulations."},min_gift_card_value_cents:{type:"number",description:"Minimum gift card face value in cents. Auto-suggested based on state cash-out threshold."},max_gift_card_value_cents:{type:"number",description:"Maximum gift card face value in cents. Default $10,000 (AML compliance)."},liquidity_pool_address:{type:"solana_address",description:"Meteora DLMM pool address for gift card secondary market buyback."},buyback_rate_bps:{type:"number",description:"Buyback rate in basis points (8000 = 80 cents on the dollar)."},liquidity_usdc_amount:{type:"number",description:"USDC amount deposited into the liquidity pool (in atomic units).",hidden:!0},liquidity_deployed_at:{description:"ISO timestamp when the liquidity pool was deployed.",hidden:!0}}},tokenization:{label:"Asset Tokenization",description:"Settings for tokenized asset classes and on-chain minting",secrets:[],icon:"🪙",fields:{enabled:{type:"toggle",description:"Enable asset tokenization features."},default_transfer_fee_bps:{type:"number",description:"Default transfer fee in basis points for tokenized asset transfers (e.g. 250 = 2.5%)."},require_custody_proof:{type:"toggle",description:"Require a custody proof URL before an asset class can be activated."}}},storage:{label:"Image Storage",description:"S3-compatible storage for product images",secrets:["access_key_id","secret_access_key"],icon:"🗄️",fields:{provider:{type:"dropdown",options:["digitalocean","aws","other"],description:"Storage provider (DigitalOcean Spaces, AWS S3, or other S3-compatible)."},endpoint_url:{description:"S3-compatible endpoint URL (e.g., https://nyc3.digitaloceanspaces.com for DO Spaces)."},bucket_name:{description:"Storage bucket name."},region:{description:"Bucket region (e.g., us-east-1, nyc3). Defaults to us-east-1."},access_key_id:{description:"Access key ID for S3-compatible API authentication."},secret_access_key:{description:"Secret access key for S3-compatible API authentication."},cdn_url:{description:"CDN URL prefix for serving images (e.g., https://cdn.example.com). If empty, images are served from the S3 endpoint directly."}}},shop:{label:"Storefront",description:"Product pages & display settings",secrets:[],icon:"🏪",fields:{enabled:{hidden:!0},"relatedProducts.mode":{type:"dropdown",options:["most_recent","by_category","manual","ai"]},"relatedProducts.maxItems":{type:"number"}}}};function n(s,e){return o[s]?.secrets.includes(e)??!1}const a="[REDACTED]";exports.CONFIG_CATEGORIES=o;exports.ConfigApiClient=r;exports.REDACTED_VALUE=a;exports.isSecretField=n;
@@ -1,4 +1,4 @@
1
- class o {
1
+ class r {
2
2
  constructor(e, t, i) {
3
3
  this._serverUrl = e, this.auth = t, this.authManager = i;
4
4
  }
@@ -57,7 +57,7 @@ class o {
57
57
  return e && i.set("category", e), this.fetch(`/admin/config/history?${i}`);
58
58
  }
59
59
  }
60
- const r = {
60
+ const o = {
61
61
  server: {
62
62
  label: "Server",
63
63
  secrets: [],
@@ -127,6 +127,10 @@ const r = {
127
127
  webhook_secret: {
128
128
  description: `Stripe Dashboard → Developers → Webhooks → "Create an event destination" → select events: checkout.session.completed, customer.subscription.created, customer.subscription.updated, customer.subscription.deleted, invoice.paid, invoice.payment_failed → Continue → choose "Webhook endpoint" → enter your server's webhook endpoint, e.g. https://example.com/webhook/stripe (your server URL + /webhook/stripe) → after creating, click the endpoint and "Click to reveal" the signing secret. Starts with whsec_...`
129
129
  },
130
+ allowed_redirect_schemes: {
131
+ type: "array",
132
+ description: `Optional mobile deep-link URI schemes Cedros should allow for Stripe success/cancel/portal redirects, for example ["covenant"]. Only add your app's custom schemes here. HTTPS links do not need to be listed.`
133
+ },
130
134
  tax_rate_id: {
131
135
  description: `Stripe Dashboard → More → Product catalog → Tax rates → "+ New" → set the percentage, region, and whether tax is inclusive or exclusive → Save → copy the tax rate ID from the detail page (starts with txr_...). Leave empty if you don't collect tax.`
132
136
  },
@@ -136,6 +140,56 @@ const r = {
136
140
  // Library provides default pages
137
141
  }
138
142
  },
143
+ native_store: {
144
+ label: "App Stores",
145
+ description: "Configure Apple App Store and Google Play billing credentials, notification endpoints, and server-side verification.",
146
+ secrets: ["apple_private_key", "google_private_key"],
147
+ icon: "📱",
148
+ fields: {
149
+ enabled: {
150
+ hidden: !0
151
+ },
152
+ apple_enabled: {
153
+ type: "toggle",
154
+ description: "Enable Apple App Store verification and lifecycle handling for this tenant."
155
+ },
156
+ apple_issuer_id: {
157
+ description: "App Store Connect → Users and Access → Integrations → App Store Server API → Issuer ID."
158
+ },
159
+ apple_key_id: {
160
+ description: "App Store Connect → Users and Access → Integrations → App Store Server API → Key ID."
161
+ },
162
+ apple_private_key: {
163
+ description: "The contents of your App Store Server API private key (.p8). Keep this secret."
164
+ },
165
+ apple_bundle_id: {
166
+ description: "The bundle identifier of the app that ships with Apple In-App Purchase enabled."
167
+ },
168
+ apple_allow_sandbox_fallback: {
169
+ type: "toggle",
170
+ description: "When enabled, Cedros will fall back to Apple sandbox verification where appropriate."
171
+ },
172
+ google_enabled: {
173
+ type: "toggle",
174
+ description: "Enable Google Play purchase verification, acknowledgment, and RTDN processing."
175
+ },
176
+ google_service_account_email: {
177
+ description: "Google Cloud service-account email with Android Publisher API access."
178
+ },
179
+ google_private_key: {
180
+ description: "The private key for the Google service account used to call the Play Developer API."
181
+ },
182
+ google_package_name: {
183
+ description: "Default Android package name for this tenant’s Google Play app."
184
+ },
185
+ google_push_service_account_email: {
186
+ description: "Expected Google-signed Pub/Sub push identity for RTDN requests."
187
+ },
188
+ google_push_audience: {
189
+ description: "Expected RTDN push audience. This should match the audience configured on your Pub/Sub push subscription."
190
+ }
191
+ }
192
+ },
139
193
  x402: {
140
194
  label: "X402 (Crypto)",
141
195
  secrets: ["server_wallets"],
@@ -574,7 +628,7 @@ const r = {
574
628
  }
575
629
  };
576
630
  function n(s, e) {
577
- return r[s]?.secrets.includes(e) ?? !1;
631
+ return o[s]?.secrets.includes(e) ?? !1;
578
632
  }
579
633
  const a = "[REDACTED]";
580
634
  export {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./styles-BT4bhFey.js"),T=require("./index-C0g-JxJk.js"),t=require("./CedrosContext-C2RjHLaQ.js"),ce=require("./CryptoButton-DpiCnyXE.js"),C=require("react/jsx-runtime"),a=require("react"),Y=require("@solana/wallet-adapter-react"),ie=require("@solana/wallet-adapter-base"),Ee=require("@solana/wallet-adapter-react-ui"),le=require("./walletPool-IS7R3MR1.js");function ue(){const{subscriptionManager:o,x402Manager:d,walletManager:f}=t.useCedrosContext(),{publicKey:u,signTransaction:k}=Y.useWallet(),[E,y]=a.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),[B,R]=a.useState(null),x=a.useRef(!1),w=a.useCallback(()=>{if(!u){const c="Wallet not connected";return y(n=>({...n,status:"error",error:c})),{valid:!1,error:c}}if(!k){const c="Wallet does not support signing";return y(n=>({...n,status:"error",error:c})),{valid:!1,error:c}}return{valid:!0}},[u,k]),_=a.useCallback(async c=>{if(!u)return y(n=>({...n,status:"error",error:"Wallet not connected"})),null;y(n=>({...n,status:"checking",error:null}));try{const n=await o.checkSubscriptionStatus({resource:c,userId:u.toString()});return y(s=>({...s,status:n.active?"success":"idle",subscriptionStatus:n.status,expiresAt:n.expiresAt||n.currentPeriodEnd||null})),n}catch(n){const s=t.formatError(n,"Failed to check subscription status");return y(g=>({...g,status:"error",error:s})),null}},[u,o]),W=a.useCallback(async(c,n,s)=>{y(g=>({...g,status:"loading",error:null}));try{const g=await o.requestSubscriptionQuote(c,n,s);return R(g),y(i=>({...i,status:"idle"})),g}catch(g){const i=t.formatError(g,"Failed to get subscription quote");return y(l=>({...l,status:"error",error:i})),null}},[o]),S=a.useCallback(async(c,n,s)=>{if(x.current)return{success:!1,error:"Payment already in progress"};const g=w();if(!g.valid)return{success:!1,error:g.error};x.current=!0,y(i=>({...i,status:"loading",error:null}));try{const i=await o.requestSubscriptionQuote(c,n,s);R(i);const l=i.requirement;if(!d.validateRequirement(l))throw new Error("Invalid subscription quote received from server");const P=!!l.extra?.feePayer;let b;if(P){const{transaction:h,blockhash:M}=await d.buildGaslessTransaction({resourceId:c,userWallet:u.toString(),feePayer:l.extra.feePayer,couponCode:s?.couponCode}),q=f.deserializeTransaction(h),O=await f.partiallySignTransaction({transaction:q,signTransaction:k,blockhash:M});b=await d.submitGaslessTransaction({resource:c,partialTx:O,couponCode:s?.couponCode,resourceType:"regular",requirement:l})}else{const h=await f.buildTransaction({requirement:l,payerPublicKey:u}),M=await f.signTransaction({transaction:h,signTransaction:k}),q=f.buildPaymentPayload({requirement:l,signedTx:M,payerPublicKey:u});b=await d.submitPayment({resource:c,payload:q,couponCode:s?.couponCode,resourceType:"regular"})}if(b.success){const h=await o.checkSubscriptionStatus({resource:c,userId:u.toString()});y({status:"success",error:null,sessionId:b.transactionId||null,subscriptionStatus:h.status,expiresAt:h.expiresAt||h.currentPeriodEnd||null})}else y(h=>({...h,status:"error",error:b.error||"Subscription payment failed"}));return b}catch(i){const l=t.formatError(i,"Subscription payment failed");return y(P=>({...P,status:"error",error:l})),{success:!1,error:l}}finally{x.current=!1}},[w,o,d,f,u,k]),I=a.useCallback(()=>{y({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),R(null)},[]);return{...E,quote:B,checkStatus:_,requestQuote:W,processPayment:S,reset:I}}function he({resource:o,interval:d,intervalDays:f,couponCode:u,label:k,disabled:E=!1,onAttempt:y,onSuccess:B,onError:R,className:x="",testPageUrl:w,hideMessages:_=!1,autoCheckStatus:W=!0}){const{connected:S,connecting:I,connect:c,disconnect:n,select:s,wallets:g,wallet:i,publicKey:l}=Y.useWallet(),{status:P,error:b,subscriptionStatus:h,expiresAt:M,checkStatus:q,processPayment:O}=ue(),p=t.useCedrosTheme(),{solanaError:L}=t.useCedrosContext(),{t:v,translations:$}=e.useTranslation(),de=k||v("ui.subscribe_with_crypto"),Q=a.useRef(B),F=a.useRef(R),V=a.useRef(O),X=a.useRef(q);Q.current=B,F.current=R,V.current=O,X.current=q;const ge=b&&typeof b!="string"?b?.code??null:null,pe=L&&typeof L!="string"?L?.code??null:null,H=r=>{if(!r||!$)return"";const m=$.errors[r];return m?m.action?`${m.message} ${m.action}`:m.message:""},J=b?typeof b=="string"?b:H(ge):null,Z=L?typeof L=="string"?L:H(pe):null,me=a.useMemo(()=>g.map(r=>`${r.adapter.name}-${r.readyState}`).join(","),[g]),G=a.useMemo(()=>g.filter(({readyState:r})=>r===ie.WalletReadyState.Installed||r===ie.WalletReadyState.Loadable),[me]);a.useEffect(()=>{W&&S&&l&&(t.getLogger().debug("[CryptoSubscribeButton] Auto-checking subscription status"),X.current(o))},[W,S,l,o]),a.useEffect(()=>{P==="success"&&h==="active"&&(e.emitPaymentSuccess("crypto","subscription-active",o),Q.current?.("subscription-active"))},[P,h,o]),a.useEffect(()=>{P==="error"&&b&&(e.emitPaymentError("crypto",b,o),F.current?.(b))},[P,b,o]);const ee=typeof window<"u"&&window.top!==window.self,[te,A]=a.useState(!1),[re,K]=a.useState(!1),[ne,D]=a.useState(!1),N=L;a.useEffect(()=>{let r=!1;return r||(async()=>{if(re&&i&&!S&&!I){t.getLogger().debug("[CryptoSubscribeButton] Wallet detected, attempting auto-connect:",i.adapter.name),K(!1),e.emitWalletConnect(i.adapter.name);try{await c(),r||t.getLogger().debug("[CryptoSubscribeButton] Auto-connect successful")}catch(U){if(!r){t.getLogger().error("[CryptoSubscribeButton] Auto-connect failed:",U);const Pe=U instanceof Error?U.message:"Failed to connect wallet";e.emitWalletError(Pe,i.adapter.name),D(!1)}}}})(),()=>{r=!0}},[i,re,S,I,c]),a.useEffect(()=>{S&&ne&&l&&i&&(e.emitWalletConnected(i.adapter.name,l.toString()),t.getLogger().debug("[CryptoSubscribeButton] Processing pending subscription payment"),D(!1),A(!1),e.emitPaymentProcessing("crypto",o),V.current(o,d,{couponCode:u,intervalDays:f}))},[S,ne,l,i,o,d,u,f]);const oe=a.useCallback(async()=>{if(t.getLogger().debug("[CryptoSubscribeButton] executeSubscriptionFlow called",{connected:S,wallet:i?.adapter.name,resource:o,interval:d}),e.emitPaymentStart("crypto",o),y&&y("crypto"),N){t.getLogger().error("[CryptoSubscribeButton] Solana dependencies missing:",N),e.emitPaymentError("crypto",N,o),R&&R(N);return}if(ee){const r=w||window.location.href;try{if(new URL(r,window.location.origin).origin!==window.location.origin)throw t.getLogger().error("[CryptoSubscribeButton] Blocked attempt to open external URL:",r),new Error("Cannot open external URLs from embedded context");window.open(r,"_blank","noopener,noreferrer")}catch(m){throw t.getLogger().error("[CryptoSubscribeButton] URL validation failed:",m),m}return}if(S)e.emitPaymentProcessing("crypto",o),await O(o,d,{couponCode:u,intervalDays:f});else{D(!0);try{if(i)t.getLogger().debug("[CryptoSubscribeButton] Wallet already selected, connecting:",i.adapter.name),e.emitWalletConnect(i.adapter.name),await c();else{if(t.getLogger().debug("[CryptoSubscribeButton] No wallet selected, showing selector"),G.length===0){D(!1);const r="No wallets available";throw e.emitWalletError(r),new Error(r)}A(!0)}}catch(r){D(!1);const m=r instanceof Error?r.message:"Failed to connect wallet";t.getLogger().error("[CryptoSubscribeButton] Connection error:",m),e.emitWalletError(m,i?.adapter.name)}}},[S,i,o,d,u,f,ee,w,G,c,O,N,y,R]),ae=a.useMemo(()=>`crypto-subscribe-${o}-${d}`,[o,d]),ye=a.useMemo(()=>e.createDedupedClickHandler(ae,oe,{cooldownMs:200,deduplicationWindowMs:0}),[ae,oe]),se=P==="loading"||P==="checking",j=h==="active"||h==="trialing",fe=E||se||I||!!N||j;let z=de;if(se)z=v("ui.processing");else if(j&&M){const r=new Date(M).toLocaleDateString();z=`${v("ui.subscribed_until")} ${r}`}else j&&(z=v("ui.subscribed"));const be=a.useCallback(async()=>{try{K(!1),S&&await n(),s(null),A(!0)}catch(r){t.getLogger().error("Failed to change wallet:",r)}},[S,n,s]),Ce=a.useCallback(r=>{t.getLogger().debug("[CryptoSubscribeButton] Wallet clicked:",r),A(!1),s(r),K(!0)},[s]),Se=a.useCallback(async()=>{try{if(await n(),D(!1),typeof window<"u"&&window.localStorage)try{window.localStorage.removeItem("walletName")}catch(r){r instanceof Error&&r.name==="QuotaExceededError"?t.getLogger().warn("localStorage quota exceeded when removing wallet preference"):t.getLogger().error("Failed to clear wallet preference from localStorage:",r)}}catch(r){t.getLogger().error("Failed to disconnect wallet:",r)}},[n]);return C.jsxs("div",{className:p.unstyled?x:`${p.className} cedros-theme__crypto-button ${x||""}`,style:p.unstyled?{}:p.style,children:[C.jsx("button",{onClick:ye,disabled:fe,className:p.unstyled?x:"cedros-theme__button cedros-theme__crypto",type:"button",children:z}),te&&!_&&C.jsx("div",{className:"cedros-modal-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:p.tokens.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem"},onClick:()=>A(!1),children:C.jsxs("div",{className:"cedros-modal-content",style:{backgroundColor:p.tokens.modalBackground,borderRadius:"12px",padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",border:`1px solid ${p.tokens.modalBorder}`},onClick:r=>r.stopPropagation(),children:[C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[C.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600,color:p.tokens.surfaceText},children:v("wallet.select_wallet")}),C.jsx("button",{onClick:()=>A(!1),style:e.getModalCloseButtonStyles(p.tokens.surfaceText),"aria-label":"Close modal",type:"button",children:"×"})]}),C.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:G.map(r=>C.jsxs("button",{onClick:()=>Ce(r.adapter.name),style:{width:"100%",padding:"1rem",backgroundColor:p.tokens.surfaceBackground,border:`1px solid ${p.tokens.surfaceBorder}`,borderRadius:"0.5rem",cursor:"pointer",fontSize:"1rem",textAlign:"left",color:p.tokens.surfaceText,display:"flex",alignItems:"center",gap:"1rem",transition:"all 0.2s ease"},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=p.tokens.modalBackground,m.currentTarget.style.borderColor=p.tokens.surfaceText,m.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=p.tokens.surfaceBackground,m.currentTarget.style.borderColor=p.tokens.surfaceBorder,m.currentTarget.style.transform="translateY(0)"},type:"button",children:[C.jsx(Ee.WalletIcon,{wallet:r,style:{width:"24px",height:"24px"}}),C.jsx("span",{style:{fontWeight:500},children:r.adapter.name})]},r.adapter.name))})]})}),S&&!_&&!te&&C.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem",fontSize:"0.75rem",color:p.tokens.surfaceText,opacity:.7},children:[C.jsx("button",{onClick:be,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:v("wallet.change")}),C.jsx("button",{onClick:Se,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:v("ui.disconnect")})]}),!_&&Z&&C.jsx("div",{className:p.unstyled?"":"cedros-theme__error",children:Z}),!_&&J&&C.jsx("div",{className:p.unstyled?"":"cedros-theme__error",children:J}),!_&&j&&C.jsx("div",{className:p.unstyled?"":"cedros-theme__success",children:v("ui.subscription_active")})]})}function we(){const{x402Manager:o,walletManager:d}=t.useCedrosContext(),{publicKey:f,signTransaction:u}=Y.useWallet(),[k,E]=a.useState({status:"idle",error:null,transactionId:null}),[y,B]=a.useState(null),[R,x]=a.useState(null),w=a.useRef(!1),_=a.useCallback(async c=>{try{E(s=>({...s,status:"loading"}));const n=await o.requestQuote({resource:c});if(!o.validateRequirement(n))throw new Error("Invalid refund requirement received from server");return B(n),E(s=>({...s,status:"idle"})),n}catch(n){const s=t.formatError(n,"Failed to fetch refund requirement");throw E({status:"error",error:s,transactionId:null}),n}},[o]),W=a.useCallback(async(c,n)=>{if(w.current)throw new Error("Refund already in progress");if(!f||!u)throw new Error("Wallet not connected");w.current=!0;try{E({status:"loading",error:null,transactionId:null});const s=await o.requestQuote({resource:c,couponCode:n});if(!o.validateRequirement(s))throw new Error("Invalid refund requirement received");B(s);const g=await d.buildTransaction({requirement:s,payerPublicKey:f}),i=await d.signTransaction({transaction:g,signTransaction:u}),l=d.buildPaymentPayload({requirement:s,signedTx:i,payerPublicKey:f}),P=await o.submitPayment({resource:c,payload:l,couponCode:n,metadata:void 0,resourceType:"refund"});return P.settlement&&x(P.settlement),E({status:"success",error:null,transactionId:P.transactionId||i.signature}),P}catch(s){const g=t.formatError(s,"Refund payment failed");throw E({status:"error",error:g,transactionId:null}),s}finally{w.current=!1}},[f,u,o,d]),S=a.useCallback(async c=>{if(w.current)throw new Error("Refund already in progress");if(!f||!u)throw new Error("Wallet not connected");w.current=!0;try{E({status:"loading",error:null,transactionId:null});const n=await o.requestQuote({resource:c});if(!o.validateRequirement(n))throw new Error("Invalid refund requirement received");B(n);const{transaction:s}=await o.buildGaslessTransaction({resourceId:c,userWallet:f.toString(),feePayer:n.extra.feePayer}),g=d.deserializeTransaction(s),i=await d.partiallySignTransaction({transaction:g,signTransaction:u}),l=await o.submitGaslessTransaction({resource:c,partialTx:i,couponCode:void 0,metadata:void 0,resourceType:"refund",requirement:n});return l.settlement&&x(l.settlement),E({status:"success",error:null,transactionId:l.transactionId||"gasless-refund-tx"}),l}catch(n){const s=t.formatError(n,"Gasless refund payment failed");throw E({status:"error",error:s,transactionId:null}),n}finally{w.current=!1}},[f,u,o,d]),I=a.useCallback(()=>{E({status:"idle",error:null,transactionId:null}),B(null),x(null)},[]);return{state:k,requirement:y,settlement:R,fetchRefundQuote:_,processRefund:W,processGaslessRefund:S,reset:I}}exports.CEDROS_EVENTS=e.CEDROS_EVENTS;exports.CSP_PRESETS=e.CSP_PRESETS;exports.CedrosPay=e.CedrosPay;exports.CreditsButton=e.CreditsButton;exports.CreditsSubscribeButton=e.CreditsSubscribeButton;exports.PaymentMethodBadge=e.PaymentMethodBadge;exports.PaymentModal=e.PaymentModal;exports.ProductPrice=e.ProductPrice;exports.PurchaseButton=e.PurchaseButton;exports.RPC_PROVIDERS=e.RPC_PROVIDERS;exports.SECURITY_RECOMMENDATIONS=e.SECURITY_RECOMMENDATIONS;exports.StripeButton=e.StripeButton;exports.SubscribeButton=e.SubscribeButton;exports.SubscriptionManagementPanel=e.SubscriptionManagementPanel;exports.calculateDiscountPercentage=e.calculateDiscountPercentage;exports.createTranslator=e.createTranslator;exports.detectLocale=e.detectLocale;exports.emitPaymentError=e.emitPaymentError;exports.emitPaymentProcessing=e.emitPaymentProcessing;exports.emitPaymentStart=e.emitPaymentStart;exports.emitPaymentSuccess=e.emitPaymentSuccess;exports.emitWalletConnect=e.emitWalletConnect;exports.emitWalletConnected=e.emitWalletConnected;exports.emitWalletError=e.emitWalletError;exports.formatCSP=e.formatCSP;exports.formatCouponCodes=e.formatCouponCodes;exports.generateCSP=e.generateCSP;exports.generateCSPDirectives=e.generateCSPDirectives;exports.getAvailableLocales=e.getAvailableLocales;exports.getLocalizedError=e.getLocalizedError;exports.getUserErrorMessage=e.getUserErrorMessage;exports.isRetryableError=e.isRetryableError;exports.loadLocale=e.loadLocale;exports.logSecurityReport=e.logSecurityReport;exports.parseCouponCodes=e.parseCouponCodes;exports.stackCheckoutCoupons=e.stackCheckoutCoupons;exports.useCreditsPayment=e.useCreditsPayment;exports.useCreditsSubscription=e.useCreditsSubscription;exports.useLocalizedError=e.useLocalizedError;exports.usePaymentMode=e.usePaymentMode;exports.useStripeCheckout=e.useStripeCheckout;exports.useSubscription=e.useSubscription;exports.useSubscriptionManagement=e.useSubscriptionManagement;exports.useTranslation=e.useTranslation;exports.validateSecurity=e.validateSecurity;exports.CEDROS_PAY_GROUPS=T.CEDROS_PAY_GROUPS;exports.CEDROS_PAY_SECTIONS=T.CEDROS_PAY_SECTIONS;exports.CEDROS_PAY_SECTION_IDS=T.CEDROS_PAY_SECTION_IDS;exports.CedrosPayAdminDashboard=T.CedrosPayAdminDashboard;exports.ComplianceGatePage=T.ComplianceGatePage;exports.CreditsBalance=T.CreditsBalance;exports.cedrosPayPlugin=T.cedrosPayPlugin;exports.ecommerce=T.index;exports.useComplianceCheck=T.useComplianceCheck;exports.useCreditsBalance=T.useCreditsBalance;exports.CIRCUIT_BREAKER_PRESETS=t.CIRCUIT_BREAKER_PRESETS;exports.CedrosProvider=t.CedrosProvider;exports.CircuitBreakerOpenError=t.CircuitBreakerOpenError;exports.CircuitState=t.CircuitState;exports.ERROR_CATEGORIES=t.ERROR_CATEGORIES;exports.KNOWN_STABLECOINS=t.KNOWN_STABLECOINS;exports.LogLevel=t.LogLevel;exports.Logger=t.Logger;exports.RATE_LIMITER_PRESETS=t.RATE_LIMITER_PRESETS;exports.RETRY_PRESETS=t.RETRY_PRESETS;exports.createCircuitBreaker=t.createCircuitBreaker;exports.createLogger=t.createLogger;exports.createRateLimiter=t.createRateLimiter;exports.getLogger=t.getLogger;exports.retryWithBackoff=t.retryWithBackoff;exports.useCedrosContext=t.useCedrosContext;exports.useCedrosTheme=t.useCedrosTheme;exports.validateConfig=t.validateConfig;exports.validateTokenMint=t.validateTokenMint;exports.CryptoButton=ce.CryptoButton;exports.useX402Payment=ce.useX402Payment;exports.WalletPool=le.WalletPool;exports.createWalletPool=le.createWalletPool;exports.CryptoSubscribeButton=he;exports.useCryptoSubscription=ue;exports.useRefundVerification=we;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./styles--fxb3lCl.js"),N=require("./index-Cq9ya93W.js"),l=require("./CedrosContext-CCakH2SZ.js"),f=require("./fetchWithTimeout-CG0EKbhf.js"),ue=require("./CryptoButton-DxFCYDlJ.js"),S=require("react/jsx-runtime"),o=require("react"),$=require("@solana/wallet-adapter-react"),ce=require("@solana/wallet-adapter-base"),xe=require("@solana/wallet-adapter-react-ui"),de=require("./ThemeContext-CFXyYx7A.js"),ge=require("./walletPool-BjTXX6Vn.js"),pe=require("./tokenMintValidator-DNBhoefh.js"),j=require("./sectionIds-B_tFiNvF.js");function me(){const{subscriptionManager:n,x402Manager:d,walletManager:b}=l.useCedrosContext(),{publicKey:u,signTransaction:k}=$.useWallet(),[h,y]=o.useState({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),[_,x]=o.useState(null),T=o.useRef(!1),R=o.useCallback(()=>{if(!u){const i="Wallet not connected";return y(r=>({...r,status:"error",error:i})),{valid:!1,error:i}}if(!k){const i="Wallet does not support signing";return y(r=>({...r,status:"error",error:i})),{valid:!1,error:i}}return{valid:!0}},[u,k]),B=o.useCallback(async i=>{if(!u)return y(r=>({...r,status:"error",error:"Wallet not connected"})),null;y(r=>({...r,status:"checking",error:null}));try{const r=await n.checkSubscriptionStatus({resource:i,userId:u.toString()});return y(a=>({...a,status:r.active?"success":"idle",subscriptionStatus:r.status,expiresAt:r.expiresAt||r.currentPeriodEnd||null})),r}catch(r){const a=l.formatError(r,"Failed to check subscription status");return y(g=>({...g,status:"error",error:a})),null}},[u,n]),W=o.useCallback(async(i,r,a)=>{y(g=>({...g,status:"loading",error:null}));try{const g=await n.requestSubscriptionQuote(i,r,a);return x(g),y(s=>({...s,status:"idle"})),g}catch(g){const s=l.formatError(g,"Failed to get subscription quote");return y(c=>({...c,status:"error",error:s})),null}},[n]),E=o.useCallback(async(i,r,a)=>{if(T.current)return{success:!1,error:"Payment already in progress"};const g=R();if(!g.valid)return{success:!1,error:g.error};T.current=!0,y(s=>({...s,status:"loading",error:null}));try{const s=await n.requestSubscriptionQuote(i,r,a);x(s);const c=s.requirement;if(!d.validateRequirement(c))throw new Error("Invalid subscription quote received from server");const P=!!c.extra?.feePayer;let C;if(P){const{transaction:w,blockhash:q}=await d.buildGaslessTransaction({resourceId:i,userWallet:u.toString(),feePayer:c.extra.feePayer,couponCode:a?.couponCode}),A=b.deserializeTransaction(w),M=await b.partiallySignTransaction({transaction:A,signTransaction:k,blockhash:q});C=await d.submitGaslessTransaction({resource:i,partialTx:M,couponCode:a?.couponCode,resourceType:"regular",requirement:c})}else{const w=await b.buildTransaction({requirement:c,payerPublicKey:u}),q=await b.signTransaction({transaction:w,signTransaction:k}),A=b.buildPaymentPayload({requirement:c,signedTx:q,payerPublicKey:u});C=await d.submitPayment({resource:i,payload:A,couponCode:a?.couponCode,resourceType:"regular"})}if(C.success){const w=await n.checkSubscriptionStatus({resource:i,userId:u.toString()});y({status:"success",error:null,sessionId:C.transactionId||null,subscriptionStatus:w.status,expiresAt:w.expiresAt||w.currentPeriodEnd||null})}else y(w=>({...w,status:"error",error:C.error||"Subscription payment failed"}));return C}catch(s){const c=l.formatError(s,"Subscription payment failed");return y(P=>({...P,status:"error",error:c})),{success:!1,error:c}}finally{T.current=!1}},[R,n,d,b,u,k]),I=o.useCallback(()=>{y({status:"idle",error:null,sessionId:null,subscriptionStatus:null,expiresAt:null}),x(null)},[]);return{...h,quote:_,checkStatus:B,requestQuote:W,processPayment:E,reset:I}}function Te({resource:n,interval:d,intervalDays:b,couponCode:u,label:k,disabled:h=!1,onAttempt:y,onSuccess:_,onError:x,className:T="",testPageUrl:R,hideMessages:B=!1,autoCheckStatus:W=!0}){const{connected:E,connecting:I,connect:i,disconnect:r,select:a,wallets:g,wallet:s,publicKey:c}=$.useWallet(),{status:P,error:C,subscriptionStatus:w,expiresAt:q,checkStatus:A,processPayment:M}=me(),p=de.useCedrosTheme(),{solanaError:v}=l.useCedrosContext(),{t:L,translations:Q}=e.useTranslation(),fe=k||L("ui.subscribe_with_crypto"),V=o.useRef(_),X=o.useRef(x),H=o.useRef(M),J=o.useRef(A);V.current=_,X.current=x,H.current=M,J.current=A;const ye=C&&typeof C!="string"?C?.code??null:null,be=v&&typeof v!="string"?v?.code??null:null,Z=t=>{if(!t||!Q)return"";const m=Q.errors[t];return m?m.action?`${m.message} ${m.action}`:m.message:""},ee=C?typeof C=="string"?C:Z(ye):null,te=v?typeof v=="string"?v:Z(be):null,Ce=o.useMemo(()=>g.map(t=>`${t.adapter.name}-${t.readyState}`).join(","),[g]),z=o.useMemo(()=>g.filter(({readyState:t})=>t===ce.WalletReadyState.Installed||t===ce.WalletReadyState.Loadable),[Ce]);o.useEffect(()=>{W&&E&&c&&(f.getLogger().debug("[CryptoSubscribeButton] Auto-checking subscription status"),J.current(n))},[W,E,c,n]),o.useEffect(()=>{P==="success"&&w==="active"&&(e.emitPaymentSuccess("crypto","subscription-active",n),V.current?.("subscription-active"))},[P,w,n]),o.useEffect(()=>{P==="error"&&C&&(e.emitPaymentError("crypto",C,n),X.current?.(C))},[P,C,n]);const re=typeof window<"u"&&window.top!==window.self,[ne,F]=o.useState(!1),[oe,Y]=o.useState(!1),[ae,O]=o.useState(!1),D=v;o.useEffect(()=>{let t=!1;return t||(async()=>{if(oe&&s&&!E&&!I){f.getLogger().debug("[CryptoSubscribeButton] Wallet detected, attempting auto-connect:",s.adapter.name),Y(!1),e.emitWalletConnect(s.adapter.name);try{await i(),t||f.getLogger().debug("[CryptoSubscribeButton] Auto-connect successful")}catch(K){if(!t){f.getLogger().error("[CryptoSubscribeButton] Auto-connect failed:",K);const Re=K instanceof Error?K.message:"Failed to connect wallet";e.emitWalletError(Re,s.adapter.name),O(!1)}}}})(),()=>{t=!0}},[s,oe,E,I,i]),o.useEffect(()=>{E&&ae&&c&&s&&(e.emitWalletConnected(s.adapter.name,c.toString()),f.getLogger().debug("[CryptoSubscribeButton] Processing pending subscription payment"),O(!1),F(!1),e.emitPaymentProcessing("crypto",n),H.current(n,d,{couponCode:u,intervalDays:b}))},[E,ae,c,s,n,d,u,b]);const se=o.useCallback(async()=>{if(f.getLogger().debug("[CryptoSubscribeButton] executeSubscriptionFlow called",{connected:E,wallet:s?.adapter.name,resource:n,interval:d}),e.emitPaymentStart("crypto",n),y&&y("crypto"),D){f.getLogger().error("[CryptoSubscribeButton] Solana dependencies missing:",D),e.emitPaymentError("crypto",D,n),x&&x(D);return}if(re){const t=R||window.location.href;try{if(new URL(t,window.location.origin).origin!==window.location.origin)throw f.getLogger().error("[CryptoSubscribeButton] Blocked attempt to open external URL:",t),new Error("Cannot open external URLs from embedded context");window.open(t,"_blank","noopener,noreferrer")}catch(m){throw f.getLogger().error("[CryptoSubscribeButton] URL validation failed:",m),m}return}if(E)e.emitPaymentProcessing("crypto",n),await M(n,d,{couponCode:u,intervalDays:b});else{O(!0);try{if(s)f.getLogger().debug("[CryptoSubscribeButton] Wallet already selected, connecting:",s.adapter.name),e.emitWalletConnect(s.adapter.name),await i();else{if(f.getLogger().debug("[CryptoSubscribeButton] No wallet selected, showing selector"),z.length===0){O(!1);const t="No wallets available";throw e.emitWalletError(t),new Error(t)}F(!0)}}catch(t){O(!1);const m=t instanceof Error?t.message:"Failed to connect wallet";f.getLogger().error("[CryptoSubscribeButton] Connection error:",m),e.emitWalletError(m,s?.adapter.name)}}},[E,s,n,d,u,b,re,R,z,i,M,D,y,x]),ie=o.useMemo(()=>`crypto-subscribe-${n}-${d}`,[n,d]),Se=o.useMemo(()=>e.createDedupedClickHandler(ie,se,{cooldownMs:200,deduplicationWindowMs:0}),[ie,se]),le=P==="loading"||P==="checking",G=w==="active"||w==="trialing",Ee=h||le||I||!!D||G;let U=fe;if(le)U=L("ui.processing");else if(G&&q){const t=new Date(q).toLocaleDateString();U=`${L("ui.subscribed_until")} ${t}`}else G&&(U=L("ui.subscribed"));const Pe=o.useCallback(async()=>{try{Y(!1),E&&await r(),a(null),F(!0)}catch(t){f.getLogger().error("Failed to change wallet:",t)}},[E,r,a]),he=o.useCallback(t=>{f.getLogger().debug("[CryptoSubscribeButton] Wallet clicked:",t),F(!1),a(t),Y(!0)},[a]),we=o.useCallback(async()=>{try{if(await r(),O(!1),typeof window<"u"&&window.localStorage)try{window.localStorage.removeItem("walletName")}catch(t){t instanceof Error&&t.name==="QuotaExceededError"?f.getLogger().warn("localStorage quota exceeded when removing wallet preference"):f.getLogger().error("Failed to clear wallet preference from localStorage:",t)}}catch(t){f.getLogger().error("Failed to disconnect wallet:",t)}},[r]);return S.jsxs("div",{className:p.unstyled?T:`${p.className} cedros-theme__crypto-button ${T||""}`,style:p.unstyled?{}:p.style,children:[S.jsx("button",{onClick:Se,disabled:Ee,className:p.unstyled?T:"cedros-theme__button cedros-theme__crypto",type:"button",children:U}),ne&&!B&&S.jsx("div",{className:"cedros-modal-overlay",style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:p.tokens.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999,padding:"1rem"},onClick:()=>F(!1),children:S.jsxs("div",{className:"cedros-modal-content",style:{backgroundColor:p.tokens.modalBackground,borderRadius:"12px",padding:"2rem",maxWidth:"400px",width:"100%",boxShadow:"0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",border:`1px solid ${p.tokens.modalBorder}`},onClick:t=>t.stopPropagation(),children:[S.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"1.5rem"},children:[S.jsx("h3",{style:{margin:0,fontSize:"1.25rem",fontWeight:600,color:p.tokens.surfaceText},children:L("wallet.select_wallet")}),S.jsx("button",{onClick:()=>F(!1),style:e.getModalCloseButtonStyles(p.tokens.surfaceText),"aria-label":"Close modal",type:"button",children:"×"})]}),S.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"0.75rem"},children:z.map(t=>S.jsxs("button",{onClick:()=>he(t.adapter.name),style:{width:"100%",padding:"1rem",backgroundColor:p.tokens.surfaceBackground,border:`1px solid ${p.tokens.surfaceBorder}`,borderRadius:"0.5rem",cursor:"pointer",fontSize:"1rem",textAlign:"left",color:p.tokens.surfaceText,display:"flex",alignItems:"center",gap:"1rem",transition:"all 0.2s ease"},onMouseEnter:m=>{m.currentTarget.style.backgroundColor=p.tokens.modalBackground,m.currentTarget.style.borderColor=p.tokens.surfaceText,m.currentTarget.style.transform="translateY(-2px)"},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=p.tokens.surfaceBackground,m.currentTarget.style.borderColor=p.tokens.surfaceBorder,m.currentTarget.style.transform="translateY(0)"},type:"button",children:[S.jsx(xe.WalletIcon,{wallet:t,style:{width:"24px",height:"24px"}}),S.jsx("span",{style:{fontWeight:500},children:t.adapter.name})]},t.adapter.name))})]})}),E&&!B&&!ne&&S.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"0.5rem",fontSize:"0.75rem",color:p.tokens.surfaceText,opacity:.7},children:[S.jsx("button",{onClick:Pe,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:L("wallet.change")}),S.jsx("button",{onClick:we,style:{background:"none",border:"none",padding:0,color:"inherit",textDecoration:"none",cursor:"pointer",fontSize:"inherit"},type:"button",children:L("ui.disconnect")})]}),!B&&te&&S.jsx("div",{className:p.unstyled?"":"cedros-theme__error",children:te}),!B&&ee&&S.jsx("div",{className:p.unstyled?"":"cedros-theme__error",children:ee}),!B&&G&&S.jsx("div",{className:p.unstyled?"":"cedros-theme__success",children:L("ui.subscription_active")})]})}function ke(){const{x402Manager:n,walletManager:d}=l.useCedrosContext(),{publicKey:b,signTransaction:u}=$.useWallet(),[k,h]=o.useState({status:"idle",error:null,transactionId:null}),[y,_]=o.useState(null),[x,T]=o.useState(null),R=o.useRef(!1),B=o.useCallback(async i=>{try{h(a=>({...a,status:"loading"}));const r=await n.requestQuote({resource:i});if(!n.validateRequirement(r))throw new Error("Invalid refund requirement received from server");return _(r),h(a=>({...a,status:"idle"})),r}catch(r){const a=l.formatError(r,"Failed to fetch refund requirement");throw h({status:"error",error:a,transactionId:null}),r}},[n]),W=o.useCallback(async(i,r)=>{if(R.current)throw new Error("Refund already in progress");if(!b||!u)throw new Error("Wallet not connected");R.current=!0;try{h({status:"loading",error:null,transactionId:null});const a=await n.requestQuote({resource:i,couponCode:r});if(!n.validateRequirement(a))throw new Error("Invalid refund requirement received");_(a);const g=await d.buildTransaction({requirement:a,payerPublicKey:b}),s=await d.signTransaction({transaction:g,signTransaction:u}),c=d.buildPaymentPayload({requirement:a,signedTx:s,payerPublicKey:b}),P=await n.submitPayment({resource:i,payload:c,couponCode:r,metadata:void 0,resourceType:"refund"});return P.settlement&&T(P.settlement),h({status:"success",error:null,transactionId:P.transactionId||s.signature}),P}catch(a){const g=l.formatError(a,"Refund payment failed");throw h({status:"error",error:g,transactionId:null}),a}finally{R.current=!1}},[b,u,n,d]),E=o.useCallback(async i=>{if(R.current)throw new Error("Refund already in progress");if(!b||!u)throw new Error("Wallet not connected");R.current=!0;try{h({status:"loading",error:null,transactionId:null});const r=await n.requestQuote({resource:i});if(!n.validateRequirement(r))throw new Error("Invalid refund requirement received");_(r);const{transaction:a}=await n.buildGaslessTransaction({resourceId:i,userWallet:b.toString(),feePayer:r.extra.feePayer}),g=d.deserializeTransaction(a),s=await d.partiallySignTransaction({transaction:g,signTransaction:u}),c=await n.submitGaslessTransaction({resource:i,partialTx:s,couponCode:void 0,metadata:void 0,resourceType:"refund",requirement:r});return c.settlement&&T(c.settlement),h({status:"success",error:null,transactionId:c.transactionId||"gasless-refund-tx"}),c}catch(r){const a=l.formatError(r,"Gasless refund payment failed");throw h({status:"error",error:a,transactionId:null}),r}finally{R.current=!1}},[b,u,n,d]),I=o.useCallback(()=>{h({status:"idle",error:null,transactionId:null}),_(null),T(null)},[]);return{state:k,requirement:y,settlement:x,fetchRefundQuote:B,processRefund:W,processGaslessRefund:E,reset:I}}exports.CEDROS_EVENTS=e.CEDROS_EVENTS;exports.CSP_PRESETS=e.CSP_PRESETS;exports.CedrosPay=e.CedrosPay;exports.CreditsButton=e.CreditsButton;exports.CreditsSubscribeButton=e.CreditsSubscribeButton;exports.PaymentMethodBadge=e.PaymentMethodBadge;exports.PaymentModal=e.PaymentModal;exports.ProductPrice=e.ProductPrice;exports.PurchaseButton=e.PurchaseButton;exports.RPC_PROVIDERS=e.RPC_PROVIDERS;exports.SECURITY_RECOMMENDATIONS=e.SECURITY_RECOMMENDATIONS;exports.StripeButton=e.StripeButton;exports.SubscribeButton=e.SubscribeButton;exports.SubscriptionManagementPanel=e.SubscriptionManagementPanel;exports.calculateDiscountPercentage=e.calculateDiscountPercentage;exports.createTranslator=e.createTranslator;exports.detectLocale=e.detectLocale;exports.emitPaymentError=e.emitPaymentError;exports.emitPaymentProcessing=e.emitPaymentProcessing;exports.emitPaymentStart=e.emitPaymentStart;exports.emitPaymentSuccess=e.emitPaymentSuccess;exports.emitWalletConnect=e.emitWalletConnect;exports.emitWalletConnected=e.emitWalletConnected;exports.emitWalletError=e.emitWalletError;exports.formatCSP=e.formatCSP;exports.formatCouponCodes=e.formatCouponCodes;exports.generateCSP=e.generateCSP;exports.generateCSPDirectives=e.generateCSPDirectives;exports.getAvailableLocales=e.getAvailableLocales;exports.getLocalizedError=e.getLocalizedError;exports.getUserErrorMessage=e.getUserErrorMessage;exports.isRetryableError=e.isRetryableError;exports.loadLocale=e.loadLocale;exports.logSecurityReport=e.logSecurityReport;exports.parseCouponCodes=e.parseCouponCodes;exports.stackCheckoutCoupons=e.stackCheckoutCoupons;exports.useCreditsPayment=e.useCreditsPayment;exports.useCreditsSubscription=e.useCreditsSubscription;exports.useLocalizedError=e.useLocalizedError;exports.usePaymentMode=e.usePaymentMode;exports.useStripeCheckout=e.useStripeCheckout;exports.useSubscription=e.useSubscription;exports.useSubscriptionManagement=e.useSubscriptionManagement;exports.useTranslation=e.useTranslation;exports.validateSecurity=e.validateSecurity;exports.ComplianceGatePage=N.ComplianceGatePage;exports.CreditsBalance=N.CreditsBalance;exports.ecommerce=N.index;exports.useComplianceCheck=N.useComplianceCheck;exports.useCreditsBalance=N.useCreditsBalance;exports.CIRCUIT_BREAKER_PRESETS=l.CIRCUIT_BREAKER_PRESETS;exports.CedrosProvider=l.CedrosProvider;exports.CircuitBreakerOpenError=l.CircuitBreakerOpenError;exports.CircuitState=l.CircuitState;exports.ERROR_CATEGORIES=l.ERROR_CATEGORIES;exports.FEATURE_FLAG_NAMES=l.FEATURE_FLAG_NAMES;exports.FEATURE_FLAG_REGISTRY=l.FEATURE_FLAG_REGISTRY;exports.RATE_LIMITER_PRESETS=l.RATE_LIMITER_PRESETS;exports.RETRY_PRESETS=l.RETRY_PRESETS;exports.createCircuitBreaker=l.createCircuitBreaker;exports.createRateLimiter=l.createRateLimiter;exports.getFeatureFlagDefinition=l.getFeatureFlagDefinition;exports.getFeatureFlagDefinitions=l.getFeatureFlagDefinitions;exports.isFeatureEnabled=l.isFeatureEnabled;exports.parseFeatureFlagBoolean=l.parseFeatureFlagBoolean;exports.resolveFeatureFlags=l.resolveFeatureFlags;exports.retryWithBackoff=l.retryWithBackoff;exports.useCedrosContext=l.useCedrosContext;exports.validateConfig=l.validateConfig;exports.LogLevel=f.LogLevel;exports.Logger=f.Logger;exports.createLogger=f.createLogger;exports.getLogger=f.getLogger;exports.CryptoButton=ue.CryptoButton;exports.useX402Payment=ue.useX402Payment;exports.useCedrosTheme=de.useCedrosTheme;exports.WalletPool=ge.WalletPool;exports.createWalletPool=ge.createWalletPool;exports.KNOWN_STABLECOINS=pe.KNOWN_STABLECOINS;exports.validateTokenMint=pe.validateTokenMint;exports.CEDROS_PAY_GROUPS=j.CEDROS_PAY_GROUPS;exports.CEDROS_PAY_SECTIONS=j.CEDROS_PAY_SECTIONS;exports.CEDROS_PAY_SECTION_IDS=j.CEDROS_PAY_SECTION_IDS;exports.CedrosPayAdminDashboard=j.CedrosPayAdminDashboard;exports.cedrosPayPlugin=j.cedrosPayPlugin;exports.CryptoSubscribeButton=Te;exports.useCryptoSubscription=me;exports.useRefundVerification=ke;