@cedros/pay-react 1.1.30 → 1.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -30
- package/dist/{AISettingsSection-BMh3hAb5.mjs → AISettingsSection-ChBtZVz7.mjs} +4 -4
- package/dist/{AISettingsSection-C0zqPbd6.js → AISettingsSection-DSROL7Lg.js} +2 -2
- package/dist/{AutosaveIndicator-3ctAnz8Y.mjs → AutosaveIndicator-BTa2YPNH.mjs} +1 -1
- package/dist/AutosaveIndicator-BgDnlrCW.js +1 -0
- package/dist/CedrosContext-3Dz7_9Ct.js +3 -0
- package/dist/{CedrosContext-5Gjveoba.mjs → CedrosContext-DQc_k5PG.mjs} +430 -314
- package/dist/ChatLogsSection-B5AdoZls.js +1 -0
- package/dist/{ChatLogsSection-BtJixYAp.mjs → ChatLogsSection-D8FX7Dmn.mjs} +2 -2
- package/dist/{ComplianceSection-BMnb1p4w.mjs → ComplianceSection-A1hgI_X2.mjs} +3 -3
- package/dist/ComplianceSection-UWfkNrmW.js +1 -0
- package/dist/CryptoButton-BQceZhbn.js +1 -0
- package/dist/{CryptoButton-Cl2kZbOP.mjs → CryptoButton-BuO_RZLj.mjs} +4 -5
- package/dist/{CustomersSection-dmwoBhcf.mjs → CustomersSection-BuSVgS16.mjs} +2 -2
- package/dist/CustomersSection-Rh552kcC.js +1 -0
- package/dist/DisputesSection-BtMdxOuD.js +1 -0
- package/dist/{DisputesSection-CHyLne76.mjs → DisputesSection-DqWrBCyC.mjs} +2 -2
- package/dist/Dropdown-CWYy2Rtt.js +1 -0
- package/dist/{Dropdown-BRSZlhik.mjs → Dropdown-DHCHYuTB.mjs} +1 -1
- package/dist/{ErrorBanner-lZJhCmDX.mjs → ErrorBanner-7naZtdtD.mjs} +1 -1
- package/dist/ErrorBanner-BOS1XAPu.js +1 -0
- package/dist/FAQSection-DczKj0C3.js +1 -0
- package/dist/{FAQSection-Di2xE9Sm.mjs → FAQSection-x0ya8PvI.mjs} +3 -3
- package/dist/{ImagesSection-D63PEjR6.mjs → ImagesSection-CMvHgbtL.mjs} +2 -2
- package/dist/ImagesSection-tRpBN-ls.js +1 -0
- package/dist/{InventorySection-Dp5Yu4TA.mjs → InventorySection-5PEOXciZ.mjs} +2 -2
- package/dist/InventorySection-clEVFr_r.js +1 -0
- package/dist/MessagingSection-BpwTsNW1.js +1 -0
- package/dist/{MessagingSection-BLCnCpEv.mjs → MessagingSection-Bt84iW-5.mjs} +3 -3
- package/dist/OrdersSection-Bsou3cwl.js +1 -0
- package/dist/{OrdersSection-Bd56F3cj.mjs → OrdersSection-kJzPO6CP.mjs} +2 -2
- package/dist/{PaymentSettingsSection-B5J56VAk.js → PaymentSettingsSection-CUgUJ7tm.js} +1 -1
- package/dist/{PaymentSettingsSection-52iw47Su.mjs → PaymentSettingsSection-s_XMFPik.mjs} +3 -3
- package/dist/{ReturnsSection-DUVeKrCd.mjs → ReturnsSection-BcwsQbrU.mjs} +2 -2
- package/dist/ReturnsSection-BwHv1HkV.js +1 -0
- package/dist/{SettingsSection-DKkHykaC.js → SettingsSection-B_feZEzU.js} +1 -1
- package/dist/{SettingsSection-vK9WIwXE.mjs → SettingsSection-OI1G3b40.mjs} +1 -1
- package/dist/{ShippingSection-CZRrXrlh.mjs → ShippingSection-B2GtSEvn.mjs} +2 -2
- package/dist/ShippingSection-DyTGH_Fh.js +1 -0
- package/dist/{SingleCategorySettings-C8xJ47_T.mjs → SingleCategorySettings-Cd76sY00.mjs} +4 -4
- package/dist/SingleCategorySettings-Ci6hJ0Xu.js +3 -0
- package/dist/{StatsBar-D4cOKG2e.mjs → StatsBar-B_lf0ph0.mjs} +1 -1
- package/dist/StatsBar-CVqsD8j2.js +1 -0
- package/dist/StorefrontSection-BxaWrsPc.js +1 -0
- package/dist/{StorefrontSection-uXSVbEAa.mjs → StorefrontSection-DW0q9GsC.mjs} +4 -4
- package/dist/{SubscriptionsSection-Ci_AZrWA.mjs → SubscriptionsSection-CNHPCync.mjs} +3 -3
- package/dist/SubscriptionsSection-QMoSKKot.js +1 -0
- package/dist/TaxSection-BKhh7kOv.js +1 -0
- package/dist/{TaxSection-BTukS_cU.mjs → TaxSection-BwLpiery.mjs} +2 -2
- package/dist/Token22Section-B_URxab9.js +1 -0
- package/dist/{Token22Section-DRsPJuTq.mjs → Token22Section-DyNDKGdU.mjs} +227 -212
- package/dist/{WalletManager-D-eoqUDy.mjs → WalletManager-CGR69MiR.mjs} +1 -1
- package/dist/{WalletManager-DXChB9LA.js → WalletManager-ZJbGQHrn.js} +1 -1
- package/dist/WebhooksSection-BIs2Qh-o.js +1 -0
- package/dist/{WebhooksSection-A8Y4ZGcj.mjs → WebhooksSection-bDVQE9Qp.mjs} +2 -2
- package/dist/admin.js +1 -1
- package/dist/admin.mjs +1 -1
- package/dist/crypto-only.js +1 -1
- package/dist/crypto-only.mjs +102 -105
- package/dist/{index-9QF_UfSN.mjs → index-CU6M10Rs.mjs} +13 -14
- package/dist/{index-Cq9ya93W.js → index-DVxx_62C.js} +10 -10
- package/dist/index.js +1 -1
- package/dist/index.mjs +31 -34
- package/dist/pay-react.css +1 -1
- package/dist/plugin-CuoGEYWr.mjs +339 -0
- package/dist/plugin-DNhaPAbC.js +1 -0
- package/dist/sections-BYdyCKFF.js +1 -0
- package/dist/{sections-more-Ixw6mM6R.mjs → sections-vLd_ind5.mjs} +263 -270
- package/dist/src/admin/plugin.d.ts.map +1 -1
- package/dist/src/admin/sectionIds.d.ts.map +1 -1
- package/dist/src/admin.d.ts +0 -7
- package/dist/src/admin.d.ts.map +1 -1
- package/dist/src/components/admin/LiquidityPoolTab.d.ts.map +1 -1
- package/dist/src/components/admin/PoolManagementView.d.ts.map +1 -1
- package/dist/src/components/admin/index.d.ts +0 -1
- package/dist/src/components/admin/index.d.ts.map +1 -1
- package/dist/src/index.d.ts +0 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/managers/MeteoraPoolManager.d.ts.map +1 -1
- package/dist/src/utils/optionalPeerImport.d.ts +6 -0
- package/dist/src/utils/optionalPeerImport.d.ts.map +1 -0
- package/dist/stripe-only.js +1 -1
- package/dist/stripe-only.mjs +18 -19
- package/dist/styles-BwaDljnz.js +1 -0
- package/dist/{styles-DGagylUj.mjs → styles-fihm6qVA.mjs} +51 -52
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.mjs +1 -1
- package/package.json +6 -8
- package/dist/AutosaveIndicator-DXRPr4P7.js +0 -1
- package/dist/CedrosContext-CCakH2SZ.js +0 -3
- package/dist/CedrosPayAdminDashboard-DaJ9JoGn.mjs +0 -250
- package/dist/CedrosPayAdminDashboard-Uvyh9p7A.js +0 -1
- package/dist/ChatLogsSection-FC3O536G.js +0 -1
- package/dist/ComplianceSection-BioTKm7k.js +0 -1
- package/dist/CryptoButton-DxFCYDlJ.js +0 -1
- package/dist/CustomersSection-z6ARxuex.js +0 -1
- package/dist/DisputesSection-BjHHQAi7.js +0 -1
- package/dist/Dropdown-j8o0OO5L.js +0 -1
- package/dist/ErrorBanner-CAgPnj62.js +0 -1
- package/dist/FAQSection-b34DMzgV.js +0 -1
- package/dist/ImagesSection-DGBA7iKY.js +0 -1
- package/dist/InventorySection-bVCECzX5.js +0 -1
- package/dist/LazyCedrosPayAdminDashboard-BqJDNrDI.mjs +0 -9
- package/dist/LazyCedrosPayAdminDashboard-CpfTtOBc.js +0 -1
- package/dist/MessagingSection-DU0dYNMy.js +0 -1
- package/dist/OrdersSection-FOFEAgs1.js +0 -1
- package/dist/ReturnsSection-BjpIVFfN.js +0 -1
- package/dist/ShippingSection-B5lk7zpS.js +0 -1
- package/dist/SingleCategorySettings-g7D-9lG1.js +0 -3
- package/dist/StatsBar-CWXw2ZT3.js +0 -1
- package/dist/StorefrontSection-BWnMB9k-.js +0 -1
- package/dist/SubscriptionsSection-DQfXkuDv.js +0 -1
- package/dist/TaxSection-cuPQISxZ.js +0 -1
- package/dist/ThemeContext-CFXyYx7A.js +0 -1
- package/dist/ThemeContext-l0bqcOGW.mjs +0 -126
- package/dist/Token22Section-CCfkDm8W.js +0 -1
- package/dist/WebhooksSection-CnEmaGH1.js +0 -1
- package/dist/icons-C3yDMnKE.mjs +0 -235
- package/dist/icons-Cjgd9YVo.js +0 -1
- package/dist/pay-react_false-CPX8Vyp9.mjs +0 -5
- package/dist/pay-react_false-DaeIe3_l.js +0 -1
- package/dist/sectionIds-D46-_-h-.js +0 -1
- package/dist/sectionIds-YktNxmRt.mjs +0 -124
- package/dist/sections-511_XBh4.js +0 -1
- package/dist/sections-CRaMa8ZB.mjs +0 -9
- package/dist/sections-more-Cgw2qJlA.js +0 -1
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts +0 -40
- package/dist/src/components/admin/CedrosPayAdminDashboard.d.ts.map +0 -1
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts +0 -4
- package/dist/src/components/admin/LazyCedrosPayAdminDashboard.d.ts.map +0 -1
- package/dist/src/standalone-admin.d.ts +0 -8
- package/dist/src/standalone-admin.d.ts.map +0 -1
- package/dist/standalone-admin.d.ts +0 -2
- package/dist/standalone-admin.js +0 -1
- package/dist/standalone-admin.mjs +0 -4
- package/dist/styles--fxb3lCl.js +0 -1
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { P as ke, u as re,
|
|
1
|
+
import { P as ke, u as re, n as be, l as V, m as pe } from "./CedrosContext-DQc_k5PG.mjs";
|
|
2
2
|
import { jsxs as S, jsx as f, Fragment as me } from "react/jsx-runtime";
|
|
3
3
|
import U, { useState as Q, useRef as X, useCallback as R, useMemo as W, useEffect as te } from "react";
|
|
4
4
|
import { g as j } from "./fetchWithTimeout-DmMOwL0Q.mjs";
|
|
5
|
-
|
|
6
|
-
function kt(e) {
|
|
5
|
+
function Et(e) {
|
|
7
6
|
return !e || !e.coupon_codes ? [] : e.coupon_codes.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
|
|
8
7
|
}
|
|
9
|
-
function
|
|
8
|
+
function kt(e, t = ", ") {
|
|
10
9
|
return e.join(t);
|
|
11
10
|
}
|
|
12
|
-
function
|
|
11
|
+
function _t(e, t) {
|
|
13
12
|
return e <= 0 ? 0 : (e - t) / e * 100;
|
|
14
13
|
}
|
|
15
|
-
function
|
|
14
|
+
function Rt(e, t) {
|
|
16
15
|
if (!t || t.length === 0)
|
|
17
16
|
return e;
|
|
18
17
|
let r = e, n = 0;
|
|
@@ -157,20 +156,20 @@ function oe(e, t, r) {
|
|
|
157
156
|
itemCount: r
|
|
158
157
|
});
|
|
159
158
|
}
|
|
160
|
-
function
|
|
159
|
+
function It(e) {
|
|
161
160
|
Z(J.WALLET_CONNECT, {
|
|
162
161
|
timestamp: Date.now(),
|
|
163
162
|
wallet: e
|
|
164
163
|
});
|
|
165
164
|
}
|
|
166
|
-
function
|
|
165
|
+
function Mt(e, t) {
|
|
167
166
|
Z(J.WALLET_CONNECTED, {
|
|
168
167
|
timestamp: Date.now(),
|
|
169
168
|
wallet: e,
|
|
170
169
|
publicKey: t
|
|
171
170
|
});
|
|
172
171
|
}
|
|
173
|
-
function
|
|
172
|
+
function Tt(e, t) {
|
|
174
173
|
Z(J.WALLET_ERROR, {
|
|
175
174
|
timestamp: Date.now(),
|
|
176
175
|
wallet: t,
|
|
@@ -203,10 +202,10 @@ function Y(e, t, r, n) {
|
|
|
203
202
|
itemCount: n
|
|
204
203
|
});
|
|
205
204
|
}
|
|
206
|
-
function
|
|
205
|
+
function Nt(e) {
|
|
207
206
|
return e instanceof ke && e.canRetry();
|
|
208
207
|
}
|
|
209
|
-
function
|
|
208
|
+
function Dt(e) {
|
|
210
209
|
return e instanceof ke ? e.getUserMessage() : e instanceof Error ? e.message : String(e);
|
|
211
210
|
}
|
|
212
211
|
function Ye(e) {
|
|
@@ -285,17 +284,17 @@ function Ge(e, t = "header") {
|
|
|
285
284
|
throw new Error(`Unknown CSP format: ${t}`);
|
|
286
285
|
}
|
|
287
286
|
}
|
|
288
|
-
function
|
|
287
|
+
function jt(e = {}, t = "header") {
|
|
289
288
|
const r = Ve(e);
|
|
290
289
|
return Ge(r, t);
|
|
291
290
|
}
|
|
292
|
-
const
|
|
291
|
+
const Bt = {
|
|
293
292
|
HELIUS: "https://*.helius-rpc.com",
|
|
294
293
|
QUICKNODE: "https://*.quicknode.pro",
|
|
295
294
|
ALCHEMY: "https://*.alchemy.com",
|
|
296
295
|
ANKR: "https://rpc.ankr.com",
|
|
297
296
|
TRITON: "https://*.rpcpool.com"
|
|
298
|
-
},
|
|
297
|
+
}, Lt = {
|
|
299
298
|
/**
|
|
300
299
|
* Mainnet production with custom RPC (recommended)
|
|
301
300
|
*/
|
|
@@ -461,7 +460,7 @@ async function Ee(e) {
|
|
|
461
460
|
return null;
|
|
462
461
|
}
|
|
463
462
|
}
|
|
464
|
-
async function
|
|
463
|
+
async function $t() {
|
|
465
464
|
if (de)
|
|
466
465
|
return de;
|
|
467
466
|
const e = /* @__PURE__ */ Object.assign({ "./translations/ar.json": () => import("./ar-w27mU-4x.mjs"), "./translations/bn.json": () => import("./bn-Ba_k3Kex.mjs"), "./translations/de.json": () => import("./de-CoZiPFN7.mjs"), "./translations/en.json": () => import("./en-BXheDBal.mjs"), "./translations/es.json": () => import("./es-BWGIBp2f.mjs"), "./translations/fil.json": () => import("./fil-Czo27xmj.mjs"), "./translations/fr.json": () => import("./fr-DQ-2ThBv.mjs"), "./translations/he.json": () => import("./he-DpV1WnBQ.mjs"), "./translations/id.json": () => import("./id-BJMqsu19.mjs"), "./translations/in.json": () => import("./in-BxgxKLQH.mjs"), "./translations/it.json": () => import("./it-DZFFPALf.mjs"), "./translations/jp.json": () => import("./jp-ZExTrlHK.mjs"), "./translations/kr.json": () => import("./kr-DHX3i4Ht.mjs"), "./translations/ms.json": () => import("./ms-Cv1fdIi2.mjs"), "./translations/nl.json": () => import("./nl-BmGonsKb.mjs"), "./translations/pa.json": () => import("./pa-BfwcJIar.mjs"), "./translations/pl.json": () => import("./pl-DE5IB9xv.mjs"), "./translations/pt.json": () => import("./pt-CLzkqDzf.mjs"), "./translations/ru.json": () => import("./ru-DM6-oUR0.mjs"), "./translations/ta.json": () => import("./ta-A5HnrGb5.mjs"), "./translations/th.json": () => import("./th-3fbB3Ytp.mjs"), "./translations/tr.json": () => import("./tr-BrgfFFdq.mjs"), "./translations/uk.json": () => import("./uk-0hFun_g_.mjs"), "./translations/ur.json": () => import("./ur-CaOjJXai.mjs"), "./translations/vn.json": () => import("./vn-0nlIZFLP.mjs"), "./translations/zh.json": () => import("./zh-B4Endr1F.mjs") }), t = [];
|
|
@@ -495,7 +494,7 @@ function Ze(e) {
|
|
|
495
494
|
) : s;
|
|
496
495
|
};
|
|
497
496
|
}
|
|
498
|
-
function
|
|
497
|
+
function At(e, t, r = !0) {
|
|
499
498
|
const n = t.errors[e];
|
|
500
499
|
if (!n) {
|
|
501
500
|
const s = be(e);
|
|
@@ -537,7 +536,7 @@ function ne(e) {
|
|
|
537
536
|
translations: t
|
|
538
537
|
};
|
|
539
538
|
}
|
|
540
|
-
function
|
|
539
|
+
function qt(e, t = !0) {
|
|
541
540
|
const { translations: r } = ne();
|
|
542
541
|
if (!r) {
|
|
543
542
|
const s = be(e);
|
|
@@ -860,7 +859,7 @@ function Te({
|
|
|
860
859
|
] });
|
|
861
860
|
}
|
|
862
861
|
const tt = U.lazy(
|
|
863
|
-
() => import("./CryptoButton-
|
|
862
|
+
() => import("./CryptoButton-BuO_RZLj.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
|
|
864
863
|
), rt = ({
|
|
865
864
|
isOpen: e,
|
|
866
865
|
onClose: t,
|
|
@@ -1173,9 +1172,9 @@ function at({
|
|
|
1173
1172
|
return /* @__PURE__ */ f(s, { endpoint: e, children: /* @__PURE__ */ f(l, { wallets: t, autoConnect: !1, children: r }) });
|
|
1174
1173
|
}
|
|
1175
1174
|
const it = U.lazy(
|
|
1176
|
-
() => import("./CryptoButton-
|
|
1175
|
+
() => import("./CryptoButton-BuO_RZLj.mjs").then((e) => e.a).then((e) => ({ default: e.CryptoButton }))
|
|
1177
1176
|
);
|
|
1178
|
-
function
|
|
1177
|
+
function zt(e) {
|
|
1179
1178
|
const { resource: t, items: r, checkout: n = {}, display: s = {}, callbacks: l = {}, advanced: g = {} } = e, { config: C, walletPool: b } = re(), c = V(), { isCartMode: a } = he(t, r), o = s.showCrypto ?? !0, u = U.useMemo(() => ({
|
|
1180
1179
|
marginTop: "0.5rem",
|
|
1181
1180
|
fontSize: "0.875rem",
|
|
@@ -1295,7 +1294,7 @@ function Ut(e) {
|
|
|
1295
1294
|
] }) });
|
|
1296
1295
|
return /* @__PURE__ */ f("div", { className: c.unstyled ? s.className : c.className, style: c.unstyled ? {} : c.style, children: /* @__PURE__ */ f(at, { endpoint: q || "https://api.devnet.solana.com", wallets: d, children: M }) });
|
|
1297
1296
|
}
|
|
1298
|
-
function
|
|
1297
|
+
function Ut({
|
|
1299
1298
|
product: e,
|
|
1300
1299
|
paymentMethod: t,
|
|
1301
1300
|
showOriginalPrice: r = !1,
|
|
@@ -1345,7 +1344,7 @@ function Ot({
|
|
|
1345
1344
|
)
|
|
1346
1345
|
] });
|
|
1347
1346
|
}
|
|
1348
|
-
function
|
|
1347
|
+
function Ot({
|
|
1349
1348
|
product: e,
|
|
1350
1349
|
paymentMethod: t,
|
|
1351
1350
|
className: r = "",
|
|
@@ -1497,7 +1496,7 @@ function ct() {
|
|
|
1497
1496
|
reset: C
|
|
1498
1497
|
};
|
|
1499
1498
|
}
|
|
1500
|
-
function
|
|
1499
|
+
function Wt({
|
|
1501
1500
|
resource: e,
|
|
1502
1501
|
interval: t,
|
|
1503
1502
|
intervalDays: r,
|
|
@@ -1693,7 +1692,7 @@ function lt() {
|
|
|
1693
1692
|
reset: b
|
|
1694
1693
|
};
|
|
1695
1694
|
}
|
|
1696
|
-
function
|
|
1695
|
+
function Ft({
|
|
1697
1696
|
resource: e,
|
|
1698
1697
|
interval: t,
|
|
1699
1698
|
intervalDays: r,
|
|
@@ -2283,7 +2282,7 @@ function gt({
|
|
|
2283
2282
|
] })
|
|
2284
2283
|
] });
|
|
2285
2284
|
}
|
|
2286
|
-
function
|
|
2285
|
+
function Ht({
|
|
2287
2286
|
resource: e,
|
|
2288
2287
|
userId: t,
|
|
2289
2288
|
availablePlans: r = [],
|
|
@@ -2495,7 +2494,7 @@ function wt() {
|
|
|
2495
2494
|
message: "Mixed content check skipped (HTTP page)"
|
|
2496
2495
|
};
|
|
2497
2496
|
}
|
|
2498
|
-
function
|
|
2497
|
+
function Yt() {
|
|
2499
2498
|
const e = [
|
|
2500
2499
|
ht(),
|
|
2501
2500
|
yt(),
|
|
@@ -2510,13 +2509,13 @@ function Qt() {
|
|
|
2510
2509
|
summary: s
|
|
2511
2510
|
};
|
|
2512
2511
|
}
|
|
2513
|
-
function
|
|
2512
|
+
function Qt(e) {
|
|
2514
2513
|
process.env.NODE_ENV !== "production" && (console.group("🔒 Cedros Pay Security Report"), console.log(`Status: ${e.overallStatus.toUpperCase()}`), console.log(`Summary: ${e.summary}`), console.log(""), e.checks.forEach((t) => {
|
|
2515
2514
|
const r = t.passed ? "✅" : t.severity === "error" ? "❌" : "⚠️";
|
|
2516
2515
|
console.log(`${r} ${t.message}`), t.recommendation && console.log(` → ${t.recommendation}`);
|
|
2517
2516
|
}), console.groupEnd());
|
|
2518
2517
|
}
|
|
2519
|
-
const
|
|
2518
|
+
const Vt = {
|
|
2520
2519
|
CSP: "Use generateCSP() from @cedros/pay-react to generate Content Security Policy headers",
|
|
2521
2520
|
HTTPS: "Always serve payment pages over HTTPS in production",
|
|
2522
2521
|
PACKAGE_UPDATES: "Keep @stripe/stripe-js and @cedros/pay-react updated for security patches",
|
|
@@ -2525,53 +2524,53 @@ const Gt = {
|
|
|
2525
2524
|
NO_SRI: "Do NOT use SRI hashes for Stripe.js - use CSP instead"
|
|
2526
2525
|
};
|
|
2527
2526
|
export {
|
|
2528
|
-
|
|
2529
|
-
|
|
2527
|
+
Dt as A,
|
|
2528
|
+
Nt as B,
|
|
2530
2529
|
J as C,
|
|
2531
2530
|
Je as D,
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2531
|
+
Qt as E,
|
|
2532
|
+
Et as F,
|
|
2533
|
+
Rt as G,
|
|
2535
2534
|
et as H,
|
|
2536
2535
|
lt as I,
|
|
2537
|
-
|
|
2536
|
+
qt as J,
|
|
2538
2537
|
he as K,
|
|
2539
2538
|
Ie as L,
|
|
2540
2539
|
ct as M,
|
|
2541
2540
|
ut as N,
|
|
2542
2541
|
ne as O,
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2542
|
+
Ot as P,
|
|
2543
|
+
Yt as Q,
|
|
2544
|
+
Bt as R,
|
|
2545
|
+
Vt as S,
|
|
2547
2546
|
Ce as T,
|
|
2548
2547
|
ge as U,
|
|
2549
2548
|
se as V,
|
|
2550
2549
|
He as W,
|
|
2551
|
-
|
|
2552
|
-
|
|
2550
|
+
Lt as a,
|
|
2551
|
+
zt as b,
|
|
2553
2552
|
Te as c,
|
|
2554
|
-
|
|
2553
|
+
Ft as d,
|
|
2555
2554
|
rt as e,
|
|
2556
|
-
|
|
2555
|
+
Ut as f,
|
|
2557
2556
|
nt as g,
|
|
2558
2557
|
Me as h,
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2558
|
+
Wt as i,
|
|
2559
|
+
Ht as j,
|
|
2560
|
+
_t as k,
|
|
2562
2561
|
Ze as l,
|
|
2563
2562
|
Xe as m,
|
|
2564
2563
|
Y as n,
|
|
2565
2564
|
ae as o,
|
|
2566
2565
|
oe as p,
|
|
2567
2566
|
ie as q,
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2567
|
+
It as r,
|
|
2568
|
+
Mt as s,
|
|
2569
|
+
Tt as t,
|
|
2571
2570
|
Ge as u,
|
|
2572
|
-
|
|
2573
|
-
|
|
2571
|
+
kt as v,
|
|
2572
|
+
jt as w,
|
|
2574
2573
|
Ve as x,
|
|
2575
|
-
|
|
2576
|
-
|
|
2574
|
+
$t as y,
|
|
2575
|
+
At as z
|
|
2577
2576
|
};
|
package/dist/testing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wr=require("react/jsx-runtime"),Wu=require("../CedrosContext-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wr=require("react/jsx-runtime"),Wu=require("../CedrosContext-3Dz7_9Ct.js");var xs={reset:[0,0],bold:[1,22,"\x1B[22m\x1B[1m"],dim:[2,22,"\x1B[22m\x1B[2m"],italic:[3,23],underline:[4,24],inverse:[7,27],hidden:[8,28],strikethrough:[9,29],black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],gray:[90,39],bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]};function yo(e){return String(e)}yo.open="";yo.close="";function Vu(){let e=typeof process<"u"?process:void 0,t=e?.env||{},n=t.FORCE_TTY!=="false",r=e?.argv||[];return!("NO_COLOR"in t||r.includes("--no-color"))&&("FORCE_COLOR"in t||r.includes("--color")||e?.platform==="win32"||n&&t.TERM!=="dumb"||"CI"in t)||typeof window<"u"&&!!window.chrome}function Uu(){let e=Vu(),t=(s,i,a,u)=>{let c="",l=0;do c+=s.substring(l,u)+a,l=u+i.length,u=s.indexOf(i,l);while(~u);return c+s.substring(l)},n=(s,i,a=s)=>{let u=c=>{let l=String(c),f=l.indexOf(i,s.length);return~f?s+t(l,i,a,f)+i:s+l+i};return u.open=s,u.close=i,u},r={isColorSupported:e},o=s=>`\x1B[${s}m`;for(let s in xs){let i=xs[s];r[s]=e?n(o(i[0]),o(i[1]),i[2]):yo}return r}var ce=Uu();function Pc(e,t){return t.forEach(function(n){n&&typeof n!="string"&&!Array.isArray(n)&&Object.keys(n).forEach(function(r){if(r!=="default"&&!(r in e)){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}})}),Object.freeze(e)}function Ku(e,t){const n=Object.keys(e),r=t===null?n:n.sort(t);if(Object.getOwnPropertySymbols)for(const o of Object.getOwnPropertySymbols(e))Object.getOwnPropertyDescriptor(e,o).enumerable&&r.push(o);return r}function rn(e,t,n,r,o,s,i=": "){let a="",u=0,c=e.next();if(!c.done){a+=t.spacingOuter;const l=n+t.indent;for(;!c.done;){if(a+=l,u++===t.maxWidth){a+="…";break}const f=s(c.value[0],t,l,r,o),h=s(c.value[1],t,l,r,o);a+=f+i+h,c=e.next(),c.done?t.min||(a+=","):a+=`,${t.spacingInner}`}a+=t.spacingOuter+n}return a}function bo(e,t,n,r,o,s){let i="",a=0,u=e.next();if(!u.done){i+=t.spacingOuter;const c=n+t.indent;for(;!u.done;){if(i+=c,a++===t.maxWidth){i+="…";break}i+=s(u.value,t,c,r,o),u=e.next(),u.done?t.min||(i+=","):i+=`,${t.spacingInner}`}i+=t.spacingOuter+n}return i}function $n(e,t,n,r,o,s){let i="";e=e instanceof ArrayBuffer?new DataView(e):e;const a=c=>c instanceof DataView,u=a(e)?e.byteLength:e.length;if(u>0){i+=t.spacingOuter;const c=n+t.indent;for(let l=0;l<u;l++){if(i+=c,l===t.maxWidth){i+="…";break}(a(e)||l in e)&&(i+=s(a(e)?e.getInt8(l):e[l],t,c,r,o)),l<u-1?i+=`,${t.spacingInner}`:t.min||(i+=",")}i+=t.spacingOuter+n}return i}function wo(e,t,n,r,o,s){let i="";const a=Ku(e,t.compareKeys);if(a.length>0){i+=t.spacingOuter;const u=n+t.indent;for(let c=0;c<a.length;c++){const l=a[c],f=s(l,t,u,r,o),h=s(e[l],t,u,r,o);i+=`${u+f}: ${h}`,c<a.length-1?i+=`,${t.spacingInner}`:t.min||(i+=",")}i+=t.spacingOuter+n}return i}const Gu=typeof Symbol=="function"&&Symbol.for?Symbol.for("jest.asymmetricMatcher"):1267621,fn=" ",Yu=(e,t,n,r,o,s)=>{const i=e.toString();if(i==="ArrayContaining"||i==="ArrayNotContaining")return++r>t.maxDepth?`[${i}]`:`${i+fn}[${$n(e.sample,t,n,r,o,s)}]`;if(i==="ObjectContaining"||i==="ObjectNotContaining")return++r>t.maxDepth?`[${i}]`:`${i+fn}{${wo(e.sample,t,n,r,o,s)}}`;if(i==="StringMatching"||i==="StringNotMatching"||i==="StringContaining"||i==="StringNotContaining")return i+fn+s(e.sample,t,n,r,o);if(typeof e.toAsymmetricMatcher!="function")throw new TypeError(`Asymmetric matcher ${e.constructor.name} does not implement toAsymmetricMatcher()`);return e.toAsymmetricMatcher()},Ju=e=>e&&e.$$typeof===Gu,Xu={serialize:Yu,test:Ju},Hu=" ",Ic=new Set(["DOMStringMap","NamedNodeMap"]),Zu=/^(?:HTML\w*Collection|NodeList)$/;function Qu(e){return Ic.has(e)||Zu.test(e)}const el=e=>e&&e.constructor&&!!e.constructor.name&&Qu(e.constructor.name);function tl(e){return e.constructor.name==="NamedNodeMap"}const nl=(e,t,n,r,o,s)=>{const i=e.constructor.name;return++r>t.maxDepth?`[${i}]`:(t.min?"":i+Hu)+(Ic.has(i)?`{${wo(tl(e)?[...e].reduce((a,u)=>(a[u.name]=u.value,a),{}):{...e},t,n,r,o,s)}}`:`[${$n([...e],t,n,r,o,s)}]`)},rl={serialize:nl,test:el};function Nc(e){return e.replaceAll("<","<").replaceAll(">",">")}function To(e,t,n,r,o,s,i){const a=r+n.indent,u=n.colors;return e.map(c=>{const l=t[c];let f=i(l,n,a,o,s);return typeof l!="string"&&(f.includes(`
|
|
2
2
|
`)&&(f=n.spacingOuter+a+f+n.spacingOuter+r),f=`{${f}}`),`${n.spacingInner+r+u.prop.open+c+u.prop.close}=${u.value.open}${f}${u.value.close}`}).join("")}function Rn(e,t,n,r,o,s){return e.map(i=>t.spacingOuter+n+(typeof i=="string"?jc(i,t):s(i,t,n,r,o))).join("")}function ol(e,t,n,r,o,s){return t.printShadowRoot===!1?"":[`${t.spacingOuter+n}#shadow-root`,Rn(e,t,n+t.indent,r,o,s)].join("")}function jc(e,t){const n=t.colors.content;return n.open+Nc(e)+n.close}function sl(e,t){const n=t.colors.comment;return`${n.open}<!--${Nc(e)}-->${n.close}`}function So(e,t,n,r,o){const s=r.colors.tag;return`${s.open}<${e}${t&&s.close+t+r.spacingOuter+o+s.open}${n?`>${s.close}${n}${r.spacingOuter}${o}${s.open}</${e}`:`${t&&!r.min?"":" "}/`}>${s.close}`}function Eo(e,t){const n=t.colors.tag;return`${n.open}<${e}${n.close} …${n.open} />${n.close}`}const il=1,Rc=3,Fc=8,Dc=11,cl=/^(?:(?:HTML|SVG)\w*)?Element$/;function al(e){try{return typeof e.hasAttribute=="function"&&e.hasAttribute("is")}catch{return!1}}function ul(e){const t=e.constructor.name,{nodeType:n,tagName:r}=e,o=typeof r=="string"&&r.includes("-")||al(e);return n===il&&(cl.test(t)||o)||n===Rc&&t==="Text"||n===Fc&&t==="Comment"||n===Dc&&t==="DocumentFragment"}const ll=e=>e?.constructor?.name&&ul(e);function fl(e){return e.nodeType===Rc}function hl(e){return e.nodeType===Fc}function hn(e){return e.nodeType===Dc}const pl=(e,t,n,r,o,s)=>{if(fl(e))return jc(e.data,t);if(hl(e))return sl(e.data,t);const i=hn(e)?"DocumentFragment":e.tagName.toLowerCase();return++r>t.maxDepth?Eo(i,t):So(i,To(hn(e)?[]:Array.from(e.attributes,a=>a.name).sort(),hn(e)?{}:[...e.attributes].reduce((a,u)=>(a[u.name]=u.value,a),{}),t,n+t.indent,r,o,s),(hn(e)||!e.shadowRoot?"":ol(Array.prototype.slice.call(e.shadowRoot.children),t,n+t.indent,r,o,s))+Rn(Array.prototype.slice.call(e.childNodes||e.children),t,n+t.indent,r,o,s),t,n)},dl={serialize:pl,test:ll},ml="@@__IMMUTABLE_ITERABLE__@@",gl="@@__IMMUTABLE_LIST__@@",yl="@@__IMMUTABLE_KEYED__@@",bl="@@__IMMUTABLE_MAP__@@",Ms="@@__IMMUTABLE_ORDERED__@@",wl="@@__IMMUTABLE_RECORD__@@",Tl="@@__IMMUTABLE_SEQ__@@",Sl="@@__IMMUTABLE_SET__@@",El="@@__IMMUTABLE_STACK__@@",At=e=>`Immutable.${e}`,Fn=e=>`[${e}]`,Qt=" ",_s="…";function vl(e,t,n,r,o,s,i){return++r>t.maxDepth?Fn(At(i)):`${At(i)+Qt}{${rn(e.entries(),t,n,r,o,s)}}`}function $l(e){let t=0;return{next(){if(t<e._keys.length){const n=e._keys[t++];return{done:!1,value:[n,e.get(n)]}}return{done:!0,value:void 0}}}}function xl(e,t,n,r,o,s){const i=At(e._name||"Record");return++r>t.maxDepth?Fn(i):`${i+Qt}{${rn($l(e),t,n,r,o,s)}}`}function Ml(e,t,n,r,o,s){const i=At("Seq");return++r>t.maxDepth?Fn(i):e[yl]?`${i+Qt}{${e._iter||e._object?rn(e.entries(),t,n,r,o,s):_s}}`:`${i+Qt}[${e._iter||e._array||e._collection||e._iterable?bo(e.values(),t,n,r,o,s):_s}]`}function sr(e,t,n,r,o,s,i){return++r>t.maxDepth?Fn(At(i)):`${At(i)+Qt}[${bo(e.values(),t,n,r,o,s)}]`}const _l=(e,t,n,r,o,s)=>e[bl]?vl(e,t,n,r,o,s,e[Ms]?"OrderedMap":"Map"):e[gl]?sr(e,t,n,r,o,s,"List"):e[Sl]?sr(e,t,n,r,o,s,e[Ms]?"OrderedSet":"Set"):e[El]?sr(e,t,n,r,o,s,"Stack"):e[Tl]?Ml(e,t,n,r,o,s):xl(e,t,n,r,o,s),Ol=e=>e&&(e[ml]===!0||e[wl]===!0),kl={serialize:_l,test:Ol};function Lc(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ir={exports:{}},Z={};var Os;function Al(){if(Os)return Z;Os=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),i=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),h=Symbol.for("react.view_transition"),p=Symbol.for("react.client.reference");function d(g){if(typeof g=="object"&&g!==null){var w=g.$$typeof;switch(w){case e:switch(g=g.type,g){case n:case o:case r:case u:case c:case h:return g;default:switch(g=g&&g.$$typeof,g){case i:case a:case f:case l:return g;case s:return g;default:return w}}case t:return w}}}return Z.ContextConsumer=s,Z.ContextProvider=i,Z.Element=e,Z.ForwardRef=a,Z.Fragment=n,Z.Lazy=f,Z.Memo=l,Z.Portal=t,Z.Profiler=o,Z.StrictMode=r,Z.Suspense=u,Z.SuspenseList=c,Z.isContextConsumer=function(g){return d(g)===s},Z.isContextProvider=function(g){return d(g)===i},Z.isElement=function(g){return typeof g=="object"&&g!==null&&g.$$typeof===e},Z.isForwardRef=function(g){return d(g)===a},Z.isFragment=function(g){return d(g)===n},Z.isLazy=function(g){return d(g)===f},Z.isMemo=function(g){return d(g)===l},Z.isPortal=function(g){return d(g)===t},Z.isProfiler=function(g){return d(g)===o},Z.isStrictMode=function(g){return d(g)===r},Z.isSuspense=function(g){return d(g)===u},Z.isSuspenseList=function(g){return d(g)===c},Z.isValidElementType=function(g){return typeof g=="string"||typeof g=="function"||g===n||g===o||g===r||g===u||g===c||typeof g=="object"&&g!==null&&(g.$$typeof===f||g.$$typeof===l||g.$$typeof===i||g.$$typeof===s||g.$$typeof===a||g.$$typeof===p||g.getModuleId!==void 0)},Z.typeOf=d,Z}var ks;function Cl(){return ks||(ks=1,ir.exports=Al()),ir.exports}var qc=Cl(),Pl=Lc(qc),Il=Pc({__proto__:null,default:Pl},[qc]),cr={exports:{}},J={};var As;function Nl(){if(As)return J;As=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),i=Symbol.for("react.context"),a=Symbol.for("react.server_context"),u=Symbol.for("react.forward_ref"),c=Symbol.for("react.suspense"),l=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),d;d=Symbol.for("react.module.reference");function g(w){if(typeof w=="object"&&w!==null){var T=w.$$typeof;switch(T){case e:switch(w=w.type,w){case n:case o:case r:case c:case l:return w;default:switch(w=w&&w.$$typeof,w){case a:case i:case u:case h:case f:case s:return w;default:return T}}case t:return T}}}return J.ContextConsumer=i,J.ContextProvider=s,J.Element=e,J.ForwardRef=u,J.Fragment=n,J.Lazy=h,J.Memo=f,J.Portal=t,J.Profiler=o,J.StrictMode=r,J.Suspense=c,J.SuspenseList=l,J.isAsyncMode=function(){return!1},J.isConcurrentMode=function(){return!1},J.isContextConsumer=function(w){return g(w)===i},J.isContextProvider=function(w){return g(w)===s},J.isElement=function(w){return typeof w=="object"&&w!==null&&w.$$typeof===e},J.isForwardRef=function(w){return g(w)===u},J.isFragment=function(w){return g(w)===n},J.isLazy=function(w){return g(w)===h},J.isMemo=function(w){return g(w)===f},J.isPortal=function(w){return g(w)===t},J.isProfiler=function(w){return g(w)===o},J.isStrictMode=function(w){return g(w)===r},J.isSuspense=function(w){return g(w)===c},J.isSuspenseList=function(w){return g(w)===l},J.isValidElementType=function(w){return typeof w=="string"||typeof w=="function"||w===n||w===o||w===r||w===c||w===l||w===p||typeof w=="object"&&w!==null&&(w.$$typeof===h||w.$$typeof===f||w.$$typeof===s||w.$$typeof===i||w.$$typeof===u||w.$$typeof===d||w.getModuleId!==void 0)},J.typeOf=g,J}var Cs;function jl(){return Cs||(Cs=1,cr.exports=Nl()),cr.exports}var Bc=jl(),Rl=Lc(Bc),Fl=Pc({__proto__:null,default:Rl},[Bc]);const Dl=["isAsyncMode","isConcurrentMode","isContextConsumer","isContextProvider","isElement","isForwardRef","isFragment","isLazy","isMemo","isPortal","isProfiler","isStrictMode","isSuspense","isSuspenseList","isValidElementType"],ut=Object.fromEntries(Dl.map(e=>[e,t=>Fl[e](t)||Il[e](t)]));function zc(e,t=[]){if(Array.isArray(e))for(const n of e)zc(n,t);else e!=null&&e!==!1&&e!==""&&t.push(e);return t}function Ps(e){const t=e.type;if(typeof t=="string")return t;if(typeof t=="function")return t.displayName||t.name||"Unknown";if(ut.isFragment(e))return"React.Fragment";if(ut.isSuspense(e))return"React.Suspense";if(typeof t=="object"&&t!==null){if(ut.isContextProvider(e))return"Context.Provider";if(ut.isContextConsumer(e))return"Context.Consumer";if(ut.isForwardRef(e)){if(t.displayName)return t.displayName;const n=t.render.displayName||t.render.name||"";return n===""?"ForwardRef":`ForwardRef(${n})`}if(ut.isMemo(e)){const n=t.displayName||t.type.displayName||t.type.name||"";return n===""?"Memo":`Memo(${n})`}}return"UNDEFINED"}function Ll(e){const{props:t}=e;return Object.keys(t).filter(n=>n!=="children"&&t[n]!==void 0).sort()}const ql=(e,t,n,r,o,s)=>++r>t.maxDepth?Eo(Ps(e),t):So(Ps(e),To(Ll(e),e.props,t,n+t.indent,r,o,s),Rn(zc(e.props.children),t,n+t.indent,r,o,s),t,n),Bl=e=>e!=null&&ut.isElement(e),zl={serialize:ql,test:Bl},Wl=typeof Symbol=="function"&&Symbol.for?Symbol.for("react.test.json"):245830487;function Vl(e){const{props:t}=e;return t?Object.keys(t).filter(n=>t[n]!==void 0).sort():[]}const Ul=(e,t,n,r,o,s)=>++r>t.maxDepth?Eo(e.type,t):So(e.type,e.props?To(Vl(e),e.props,t,n+t.indent,r,o,s):"",e.children?Rn(e.children,t,n+t.indent,r,o,s):"",t,n),Kl=e=>e&&e.$$typeof===Wl,Gl={serialize:Ul,test:Kl},Wc=Object.prototype.toString,Yl=Date.prototype.toISOString,Jl=Error.prototype.toString,Is=RegExp.prototype.toString;function bn(e){return typeof e.constructor=="function"&&e.constructor.name||"Object"}function Xl(e){return typeof window<"u"&&e===window}const Hl=/^Symbol\((.*)\)(.*)$/,Zl=/\n/g;class Vc extends Error{constructor(t,n){super(t),this.stack=n,this.name=this.constructor.name}}function Ql(e){return e==="[object Array]"||e==="[object ArrayBuffer]"||e==="[object DataView]"||e==="[object Float32Array]"||e==="[object Float64Array]"||e==="[object Int8Array]"||e==="[object Int16Array]"||e==="[object Int32Array]"||e==="[object Uint8Array]"||e==="[object Uint8ClampedArray]"||e==="[object Uint16Array]"||e==="[object Uint32Array]"}function ef(e){return Object.is(e,-0)?"-0":String(e)}function tf(e){return`${e}n`}function Ns(e,t){return t?`[Function ${e.name||"anonymous"}]`:"[Function]"}function js(e){return String(e).replace(Hl,"Symbol($1)")}function Rs(e){return`[${Jl.call(e)}]`}function Uc(e,t,n,r){if(e===!0||e===!1)return`${e}`;if(e===void 0)return"undefined";if(e===null)return"null";const o=typeof e;if(o==="number")return ef(e);if(o==="bigint")return tf(e);if(o==="string")return r?`"${e.replaceAll(/"|\\/g,"\\$&")}"`:`"${e}"`;if(o==="function")return Ns(e,t);if(o==="symbol")return js(e);const s=Wc.call(e);return s==="[object WeakMap]"?"WeakMap {}":s==="[object WeakSet]"?"WeakSet {}":s==="[object Function]"||s==="[object GeneratorFunction]"?Ns(e,t):s==="[object Symbol]"?js(e):s==="[object Date]"?Number.isNaN(+e)?"Date { NaN }":Yl.call(e):s==="[object Error]"?Rs(e):s==="[object RegExp]"?n?Is.call(e).replaceAll(/[$()*+.?[\\\]^{|}]/g,"\\$&"):Is.call(e):e instanceof Error?Rs(e):null}function Kc(e,t,n,r,o,s){if(o.includes(e))return"[Circular]";o=[...o],o.push(e);const i=++r>t.maxDepth,a=t.min;if(t.callToJSON&&!i&&e.toJSON&&typeof e.toJSON=="function"&&!s)return tt(e.toJSON(),t,n,r,o,!0);const u=Wc.call(e);return u==="[object Arguments]"?i?"[Arguments]":`${a?"":"Arguments "}[${$n(e,t,n,r,o,tt)}]`:Ql(u)?i?`[${e.constructor.name}]`:`${a||!t.printBasicPrototype&&e.constructor.name==="Array"?"":`${e.constructor.name} `}[${$n(e,t,n,r,o,tt)}]`:u==="[object Map]"?i?"[Map]":`Map {${rn(e.entries(),t,n,r,o,tt," => ")}}`:u==="[object Set]"?i?"[Set]":`Set {${bo(e.values(),t,n,r,o,tt)}}`:i||Xl(e)?`[${bn(e)}]`:`${a||!t.printBasicPrototype&&bn(e)==="Object"?"":`${bn(e)} `}{${wo(e,t,n,r,o,tt)}}`}const nf={test:e=>e&&e instanceof Error,serialize(e,t,n,r,o,s){if(o.includes(e))return"[Circular]";o=[...o,e];const i=++r>t.maxDepth,{message:a,cause:u,...c}=e,l={message:a,...typeof u<"u"?{cause:u}:{},...e instanceof AggregateError?{errors:e.errors}:{},...c},f=e.name!=="Error"?e.name:bn(e);return i?`[${f}]`:`${f} {${rn(Object.entries(l).values(),t,n,r,o,s)}}`}};function rf(e){return e.serialize!=null}function Gc(e,t,n,r,o,s){let i;try{i=rf(e)?e.serialize(t,n,r,o,s,tt):e.print(t,a=>tt(a,n,r,o,s),a=>{const u=r+n.indent;return u+a.replaceAll(Zl,`
|
|
3
3
|
${u}`)},{edgeSpacing:n.spacingOuter,min:n.min,spacing:n.spacingInner},n.colors)}catch(a){throw new Vc(a.message,a.stack)}if(typeof i!="string")throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof i}".`);return i}function Yc(e,t){for(const n of e)try{if(n.test(t))return n}catch(r){throw new Vc(r.message,r.stack)}return null}function tt(e,t,n,r,o,s){const i=Yc(t.plugins,e);if(i!==null)return Gc(i,e,t,n,r,o);const a=Uc(e,t.printFunctionName,t.escapeRegex,t.escapeString);return a!==null?a:Kc(e,t,n,r,o,s)}const vo={comment:"gray",content:"reset",prop:"yellow",tag:"cyan",value:"green"},Jc=Object.keys(vo),Fe={callToJSON:!0,compareKeys:void 0,escapeRegex:!1,escapeString:!0,highlight:!1,indent:2,maxDepth:Number.POSITIVE_INFINITY,maxWidth:Number.POSITIVE_INFINITY,min:!1,plugins:[],printBasicPrototype:!0,printFunctionName:!0,printShadowRoot:!0,theme:vo};function of(e){for(const t of Object.keys(e))if(!Object.hasOwn(Fe,t))throw new Error(`pretty-format: Unknown option "${t}".`);if(e.min&&e.indent!==void 0&&e.indent!==0)throw new Error('pretty-format: Options "min" and "indent" cannot be used together.')}function sf(){return Jc.reduce((e,t)=>{const n=vo[t],r=n&&ce[n];if(r&&typeof r.close=="string"&&typeof r.open=="string")e[t]=r;else throw new Error(`pretty-format: Option "theme" has a key "${t}" whose value "${n}" is undefined in ansi-styles.`);return e},Object.create(null))}function cf(){return Jc.reduce((e,t)=>(e[t]={close:"",open:""},e),Object.create(null))}function Xc(e){return e?.printFunctionName??Fe.printFunctionName}function Hc(e){return e?.escapeRegex??Fe.escapeRegex}function Zc(e){return e?.escapeString??Fe.escapeString}function Fs(e){return{callToJSON:e?.callToJSON??Fe.callToJSON,colors:e?.highlight?sf():cf(),compareKeys:typeof e?.compareKeys=="function"||e?.compareKeys===null?e.compareKeys:Fe.compareKeys,escapeRegex:Hc(e),escapeString:Zc(e),indent:e?.min?"":af(e?.indent??Fe.indent),maxDepth:e?.maxDepth??Fe.maxDepth,maxWidth:e?.maxWidth??Fe.maxWidth,min:e?.min??Fe.min,plugins:e?.plugins??Fe.plugins,printBasicPrototype:e?.printBasicPrototype??!0,printFunctionName:Xc(e),printShadowRoot:e?.printShadowRoot??!0,spacingInner:e?.min?" ":`
|
|
4
4
|
`,spacingOuter:e?.min?"":`
|
package/dist/testing/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedros/pay-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.32",
|
|
4
4
|
"description": "React frontend library for Cedros Pay - unified Stripe and Solana x402 payments",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -18,12 +18,6 @@
|
|
|
18
18
|
"import": "./dist/admin.mjs",
|
|
19
19
|
"require": "./dist/admin.js"
|
|
20
20
|
},
|
|
21
|
-
"./standalone-admin": {
|
|
22
|
-
"react-native": "./src/standalone-admin.ts",
|
|
23
|
-
"types": "./dist/standalone-admin.d.ts",
|
|
24
|
-
"import": "./dist/standalone-admin.mjs",
|
|
25
|
-
"require": "./dist/standalone-admin.js"
|
|
26
|
-
},
|
|
27
21
|
"./stripe-only": {
|
|
28
22
|
"react-native": "./src/stripe-only.ts",
|
|
29
23
|
"types": "./dist/stripe-only.d.ts",
|
|
@@ -69,7 +63,7 @@
|
|
|
69
63
|
"license": "MIT",
|
|
70
64
|
"repository": {
|
|
71
65
|
"type": "git",
|
|
72
|
-
"url": "https://github.com/conorholds/cedros-pay.git",
|
|
66
|
+
"url": "git+https://github.com/conorholds/cedros-pay.git",
|
|
73
67
|
"directory": "ui"
|
|
74
68
|
},
|
|
75
69
|
"bugs": {
|
|
@@ -197,5 +191,9 @@
|
|
|
197
191
|
"elliptic": "npm:@soatok/elliptic-to-noble@9999.0.0",
|
|
198
192
|
"minimatch": "^10.2.3",
|
|
199
193
|
"lodash": "^4.17.23"
|
|
194
|
+
},
|
|
195
|
+
"directories": {
|
|
196
|
+
"doc": "docs",
|
|
197
|
+
"example": "examples"
|
|
200
198
|
}
|
|
201
199
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),i=require("./icons-Cjgd9YVo.js");function s({status:n,error:r}){return n==="idle"?null:e.jsxs("span",{className:`cedros-admin__autosave-indicator cedros-admin__autosave-indicator--${n}`,style:{display:"inline-flex",alignItems:"center",gap:"0.375rem",fontSize:"0.8125rem",color:n==="error"?"var(--cedros-admin-error, #ef4444)":"var(--cedros-admin-text-muted, #64748b)"},children:[n==="pending"&&e.jsx("span",{style:{opacity:.7},children:"Unsaved changes"}),n==="saving"&&e.jsxs(e.Fragment,{children:[i.Icons.loading,e.jsx("span",{children:"Saving..."})]}),n==="saved"&&e.jsxs(e.Fragment,{children:[i.Icons.check,e.jsx("span",{style:{color:"var(--cedros-admin-success, #22c55e)"},children:"Saved"})]}),n==="error"&&e.jsxs("span",{children:["Save failed",r?`: ${r}`:""]})]})}exports.AutosaveIndicator=s;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
"use strict";const G=require("react/jsx-runtime"),S=require("react"),k=require("./uuid-C5B8o31X.js"),s=require("./fetchWithTimeout-CG0EKbhf.js"),ge=require("./ThemeContext-CFXyYx7A.js"),pe=require("./tokenMintValidator-DNBhoefh.js");var ne="https://js.stripe.com/v3",we=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/;var ve=function(){for(var e=document.querySelectorAll('script[src^="'.concat(ne,'"]')),t=0;t<e.length;t++){var r=e[t];if(we.test(r.src))return r}return null},te=function(e){var t="",r=document.createElement("script");r.src="".concat(ne).concat(t);var a=document.head||document.body;if(!a)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return a.appendChild(r),r},be=function(e,t){!e||!e._registerWrapper||e._registerWrapper({name:"stripe-js",version:"4.6.0",startTime:t})},$=null,W=null,H=null,Ee=function(e){return function(){e(new Error("Failed to load Stripe.js"))}},Ce=function(e,t){return function(){window.Stripe?e(window.Stripe):t(new Error("Stripe.js not available"))}},Pe=function(e){return $!==null?$:($=new Promise(function(t,r){if(typeof window>"u"||typeof document>"u"){t(null);return}if(window.Stripe){t(window.Stripe);return}try{var a=ve();if(!(a&&e)){if(!a)a=te(e);else if(a&&H!==null&&W!==null){var i;a.removeEventListener("load",H),a.removeEventListener("error",W),(i=a.parentNode)===null||i===void 0||i.removeChild(a),a=te(e)}}H=Ce(t,r),W=Ee(r),a.addEventListener("load",H),a.addEventListener("error",W)}catch(o){r(o);return}}),$.catch(function(t){return $=null,Promise.reject(t)}))},Te=function(e,t,r){if(e===null)return null;var a=e.apply(void 0,t);return be(a,r),a},j,oe=!1,se=function(){return j||(j=Pe(null).catch(function(e){return j=null,Promise.reject(e)}),j)};Promise.resolve().then(function(){return se()}).catch(function(n){oe||console.warn(n)});var ce=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];oe=!0;var a=Date.now();return se().then(function(i){return Te(i,t,a)})};function D(n,e){return n instanceof Error?n.message:typeof n=="string"?n:e}const Se={service_unavailable:"Service temporarily unavailable. Please try again later or contact support.",server_insufficient_funds:"Service temporarily unavailable. Please try again later or contact support.",insufficient_funds_token:"Insufficient token balance in your wallet. Please add more tokens and try again.",insufficient_funds_sol:"Insufficient SOL for transaction fees. Please add some SOL to your wallet and try again.",insufficient_amount:"Payment amount is insufficient. Please check the required amount.",invalid_signature:"Transaction signature is invalid. Please try again.",send_failed:"Failed to send transaction. Please try again or contact support.",timeout:"Transaction timed out. Please check the blockchain explorer or try again."};async function v(n,e,t=!1){const r=typeof n.clone=="function",a=r?n.clone():void 0;try{const i=await n.json();if(t&&i.verificationError){s.getLogger().debug(`Payment verification failed: ${i.verificationError.code}`);const o=i.verificationError.code;return Se[o]||i.verificationError.message||e}return typeof i.error=="string"?i.error:i.error&&typeof i.error=="object"&&"message"in i.error?i.error.message:e}catch{if(a)try{const i=await a.text();if(i)return i}catch{}if(!r&&typeof n.text=="function")try{const i=await n.text();if(i)return i}catch{}return e}}function L(n){const{maxRequests:e,windowMs:t}=n;let r=e,a=Date.now();const i=e/t;function o(){const h=Date.now(),y=h-a;if(y>0){const g=y*i;r=Math.min(e,r+g),a=h}}function c(){return o(),r>=1?(r-=1,!0):!1}function l(){return o(),Math.floor(r)}function u(){if(o(),r>=1)return 0;const y=(1-r)/i;return Math.ceil(y)}function f(){r=e,a=Date.now()}return{tryConsume:c,getAvailableTokens:l,getTimeUntilRefill:u,reset:f}}const x={PAYMENT:{maxRequests:10,windowMs:6e4},QUOTE:{maxRequests:30,windowMs:6e4},STRICT:{maxRequests:5,windowMs:6e4},PERMISSIVE:{maxRequests:100,windowMs:6e4}};var le=(n=>(n.CLOSED="CLOSED",n.OPEN="OPEN",n.HALF_OPEN="HALF_OPEN",n))(le||{});class w extends Error{constructor(e){super(e),this.name="CircuitBreakerOpenError"}}function q(n){const{failureThreshold:e,timeout:t,failureWindow:r=t*2,name:a="circuit-breaker"}=n;let i="CLOSED",o=[],c=0,l=0,u=null,f=null,h=null,y=!1;function g(){const P=Date.now()-r;o=o.filter(C=>C>P)}function m(){i==="OPEN"&&h!==null&&Date.now()>=h&&(s.getLogger().debug(`[CircuitBreaker:${a}] Transitioning OPEN → HALF_OPEN (timeout expired)`),i="HALF_OPEN",h=null)}function d(){f=Date.now(),c++,i==="HALF_OPEN"?(s.getLogger().debug(`[CircuitBreaker:${a}] Success in HALF_OPEN → CLOSED`),i="CLOSED",o=[]):i==="CLOSED"&&(o=[])}function p(P){const C=Date.now();u=C,o.push(C),g();const U=o.length;s.getLogger().warn(`[CircuitBreaker:${a}] Failure recorded (${U}/${e}):`,P.message),i==="HALF_OPEN"?(s.getLogger().warn(`[CircuitBreaker:${a}] Failed in HALF_OPEN → OPEN`),i="OPEN",h=C+t):i==="CLOSED"&&U>=e&&(s.getLogger().error(`[CircuitBreaker:${a}] Failure threshold reached (${U}) → OPEN`),i="OPEN",h=C+t)}async function R(P){if(m(),i==="OPEN"){l++;const C=h?Math.ceil((h-Date.now())/1e3):0;throw new w(`Circuit breaker is OPEN. Service is unavailable. Retry in ${C}s.`)}if(i==="HALF_OPEN"&&y)throw l++,new w("Circuit breaker is HALF_OPEN. A probe request is already in progress.");i==="HALF_OPEN"&&(y=!0);try{const C=await P();return d(),C}catch(C){throw p(C instanceof Error?C:new Error(String(C))),C}finally{y&&(y=!1)}}function O(){return m(),i}function I(){return m(),g(),{state:i,failures:o.length,successes:c,rejections:l,lastFailureTime:u,lastSuccessTime:f}}function _(){s.getLogger().debug(`[CircuitBreaker:${a}] Manual reset → CLOSED`),i="CLOSED",o=[],c=0,l=0,u=null,f=null,h=null}function A(){s.getLogger().warn(`[CircuitBreaker:${a}] Manual trip → OPEN`),i="OPEN",h=Date.now()+t}return{execute:R,getState:O,getStats:I,reset:_,trip:A}}const Re={STRICT:{failureThreshold:3,timeout:6e4},STANDARD:{failureThreshold:5,timeout:3e4},LENIENT:{failureThreshold:10,timeout:15e3}},ke={invalid_payment_proof:{message:"Payment verification failed",action:"Please try your payment again. If this continues, contact support.",technicalHint:"Invalid payment proof format"},invalid_signature:{message:"Transaction signature is invalid",action:"Please approve the transaction in your wallet and try again.",technicalHint:"Transaction signature verification failed"},invalid_transaction:{message:"Transaction format is invalid",action:"Please try your payment again. If this continues, try updating your wallet app.",technicalHint:"Malformed transaction structure"},transaction_not_found:{message:"Transaction not found on the blockchain",action:"Your transaction may still be processing. Please wait a moment and check your wallet, or try again.",technicalHint:"Transaction signature not found on-chain"},transaction_not_confirmed:{message:"Transaction is still processing",action:"Please wait a moment for the blockchain to confirm your transaction, then try again.",technicalHint:"Transaction not yet confirmed"},transaction_failed:{message:"Transaction failed on the blockchain",action:"Check your wallet for details. You may need to adjust your transaction settings or add more SOL for fees.",technicalHint:"On-chain transaction failure"},transaction_expired:{message:"Transaction took too long to process",action:"Please try your payment again. Consider increasing transaction priority if your wallet supports it.",technicalHint:"Transaction blockhash expired"},invalid_recipient:{message:"Payment was sent to the wrong address",action:"Please try again and ensure you approve the correct transaction in your wallet.",technicalHint:"Recipient address mismatch"},invalid_sender:{message:"Payment sender wallet is invalid",action:"Please reconnect your wallet and try again.",technicalHint:"Sender address validation failed"},unauthorized_refund_issuer:{message:"You are not authorized to issue refunds",action:"Only authorized accounts can process refunds. Please contact support if you believe this is an error.",technicalHint:"Refund issuer not in authorized list"},amount_below_minimum:{message:"Payment amount is too low",action:"Please check the required amount and try again.",technicalHint:"Amount below minimum threshold"},amount_mismatch:{message:"Payment amount does not match the quote",action:"The price may have changed. Please refresh and try your payment again.",technicalHint:"Amount does not match quote"},insufficient_funds_sol:{message:"Not enough SOL for transaction fees",action:"Add at least 0.001 SOL to your wallet to cover network fees, then try again.",technicalHint:"Insufficient SOL balance for fees"},insufficient_funds_token:{message:"Insufficient balance in your wallet",action:"Add more funds to your wallet and try again.",technicalHint:"Insufficient token balance"},invalid_token_mint:{message:"Incorrect payment token",action:"Please pay with the correct token as shown in the payment details.",technicalHint:"Token mint address mismatch"},not_spl_transfer:{message:"Transaction is not a valid token transfer",action:"Please ensure you are sending the correct token type from your wallet.",technicalHint:"Transaction is not an SPL token transfer"},missing_token_account:{message:"Token account not found",action:"Your wallet may need to create a token account first. Try again or use a different wallet.",technicalHint:"Associated token account does not exist"},invalid_token_program:{message:"Invalid token program",action:"Please try your payment again. If this continues, try using a different wallet.",technicalHint:"Token program ID mismatch"},missing_memo:{message:"Payment memo is required but was not included",action:"Please try your payment again and ensure transaction details are approved in your wallet.",technicalHint:"Required memo instruction missing"},invalid_memo:{message:"Payment memo format is invalid",action:"Please try your payment again.",technicalHint:"Memo does not match expected format"},payment_already_used:{message:"This payment has already been processed",action:"Check your transaction history. If you need to make another payment, please start a new transaction.",technicalHint:"Payment signature already recorded"},signature_reused:{message:"Transaction signature has already been used",action:"Please create a new payment transaction.",technicalHint:"Duplicate signature detected"},quote_expired:{message:"Payment quote has expired",action:"Prices are updated frequently. Please refresh and try your payment again.",technicalHint:"Quote timestamp expired"},missing_field:{message:"Required information is missing",action:"Please check all required fields and try again.",technicalHint:"Required field not provided"},invalid_field:{message:"Some information is invalid",action:"Please check your input and try again.",technicalHint:"Field validation failed"},invalid_amount:{message:"Payment amount is invalid",action:"Please check the amount and try again.",technicalHint:"Amount validation failed"},invalid_wallet:{message:"Wallet address is invalid",action:"Please reconnect your wallet and try again.",technicalHint:"Wallet address validation failed"},invalid_resource:{message:"Invalid item selection",action:"Please refresh the page and try again.",technicalHint:"Resource ID validation failed"},invalid_coupon:{message:"Invalid coupon code",action:"Please check the coupon code and try again.",technicalHint:"Coupon code format invalid"},invalid_cart_item:{message:"One or more cart items are invalid",action:"Please review your cart and try again.",technicalHint:"Cart item validation failed"},empty_cart:{message:"Your cart is empty",action:"Please add items to your cart before checking out.",technicalHint:"Cart contains no items"},resource_not_found:{message:"Item not found",action:"This item may no longer be available. Please refresh and try again.",technicalHint:"Resource not found in database"},cart_not_found:{message:"Shopping cart not found",action:"Your cart may have expired. Please start a new order.",technicalHint:"Cart ID not found"},refund_not_found:{message:"Refund not found",action:"Please check your refund reference number or contact support.",technicalHint:"Refund ID not found"},product_not_found:{message:"Product not available",action:"This product may no longer be available. Please browse our current selection.",technicalHint:"Product ID not found"},coupon_not_found:{message:"Coupon code not found",action:"Please check the coupon code or remove it to continue.",technicalHint:"Coupon code not in database"},session_not_found:{message:"Payment session expired",action:"Please start a new payment.",technicalHint:"Session ID not found or expired"},cart_already_paid:{message:"This order has already been paid",action:"Check your order history. If you need to make another purchase, please start a new order.",technicalHint:"Cart marked as paid"},refund_already_processed:{message:"This refund has already been processed",action:"Check your transaction history or contact support for details.",technicalHint:"Refund already completed"},coupon_expired:{message:"Coupon has expired",action:"Please remove the coupon code or use a different code.",technicalHint:"Coupon expiration date passed"},coupon_usage_limit_reached:{message:"Coupon usage limit reached",action:"This coupon has been fully redeemed. Please try a different code.",technicalHint:"Coupon max uses exceeded"},coupon_not_applicable:{message:"Coupon cannot be applied to this purchase",action:"Please check the coupon terms or remove it to continue.",technicalHint:"Coupon conditions not met"},coupon_wrong_payment_method:{message:"Coupon not valid for this payment method",action:"Try a different payment method or remove the coupon code.",technicalHint:"Coupon restricted to specific payment methods"},stripe_error:{message:"Card payment service temporarily unavailable",action:"Please try again in a moment, or use cryptocurrency payment instead.",technicalHint:"Stripe API error"},rpc_error:{message:"Blockchain network temporarily unavailable",action:"Please try again in a moment, or use card payment instead.",technicalHint:"Solana RPC error"},network_error:{message:"Network connection issue",action:"Please check your internet connection and try again.",technicalHint:"Network request failed"},internal_error:{message:"Something went wrong on our end",action:"Please try again. If this continues, contact support.",technicalHint:"Internal server error"},database_error:{message:"Service temporarily unavailable",action:"Please try again in a moment.",technicalHint:"Database operation failed"},config_error:{message:"Service configuration error",action:"Please contact support for assistance.",technicalHint:"Server misconfiguration"}};function ue(n){return ke[n]||{message:"An unexpected error occurred",action:"Please try again or contact support if this continues.",technicalHint:`Unknown error code: ${n}`}}class F extends Error{code;retryable;details;httpStatus;constructor(e,t,r=!1,a,i){super(t),this.name="PaymentError",this.code=e,this.retryable=r,this.details=a,this.httpStatus=i,Object.setPrototypeOf(this,F.prototype)}canRetry(){return this.retryable}is(e){return this.code===e}isInCategory(e){return e.includes(this.code)}getUserMessage(){const e=this.getErrorInfo();return e.action?`${e.message} ${e.action}`:e.message}getShortMessage(){return this.getErrorInfo().message}getAction(){return this.getErrorInfo().action}getErrorInfo(){return ue(this.code)}static fromErrorResponse(e,t){const r=e.error.retryable??de.RETRYABLE.includes(e.error.code);return new F(e.error.code,e.error.message,r,e.error.details,t)}static fromUnknown(e){return e instanceof F?e:e instanceof Error?new F("internal_error",e.message,!1):new F("internal_error",String(e),!1)}}const de={INSUFFICIENT_FUNDS:["insufficient_funds_sol","insufficient_funds_token"],TRANSACTION_PENDING:["transaction_not_confirmed","transaction_not_found"],VALIDATION:["missing_field","invalid_field","invalid_amount","invalid_wallet","invalid_resource","invalid_cart_item","empty_cart"],COUPON:["invalid_coupon","coupon_not_found","coupon_expired","coupon_usage_limit_reached","coupon_not_applicable","coupon_wrong_payment_method"],RETRYABLE:["transaction_not_confirmed","rpc_error","network_error","stripe_error"],NOT_FOUND:["resource_not_found","cart_not_found","refund_not_found","product_not_found","coupon_not_found","session_not_found","credits_hold_not_found"],CREDITS:["insufficient_credits","credits_hold_expired","credits_hold_not_found"],SECURITY:["invalid_redirect_url","rate_limit_exceeded","nonce_already_used"]},re=300*1e3,B=new Map;function _e(n){if(!n)return;const e=Number(n);if(Number.isFinite(e)&&e>=0)return Math.min(e*1e3,re);const t=Date.parse(n);if(!Number.isNaN(t))return Math.min(Math.max(t-Date.now(),0),re)}class T extends Error{httpStatus;retryAfterMs;constructor(e,t,r){super(e),this.name="RetryableHttpError",this.httpStatus=t,this.retryAfterMs=r,Object.setPrototypeOf(this,T.prototype)}static fromResponse(e,t){const r=e.headers&&typeof e.headers.get=="function"?e.headers.get("Retry-After"):null;return new T(t,e.status,_e(r))}}function Ie(n){if(n instanceof F||n instanceof T)return n.httpStatus}function Me(n){if(n instanceof T)return n.retryAfterMs}function De(n,e){const t=Ie(n);if(t!=null){const a=t;return a===429||a>=500&&a<600}const r=n.message.toLowerCase();return!!(r.includes("network")||r.includes("timeout")||r.includes("fetch failed")||r.includes("econnrefused"))}function Le(n,e,t,r,a){const i=e*Math.pow(t,n),o=Math.min(i,r);return Math.floor(a?o*.5+Math.random()*o*.5:o)}function xe(n){return new Promise(e=>setTimeout(e,n))}async function E(n,e={}){const{maxRetries:t=3,initialDelayMs:r=1e3,backoffFactor:a=2,maxDelayMs:i=3e4,jitter:o=!0,shouldRetry:c=De,name:l="retry",inFlightKey:u}=e,f=async()=>{let g=null,m=0;for(let d=0;d<=t;d++)try{const p=await n();return d>0&&s.getLogger().debug(`[Retry:${l}] Succeeded on attempt ${d+1}/${t+1} after ${m}ms`),p}catch(p){g=p instanceof Error?p:new Error(String(p));const R=d===t,O=c(g,d);if(R||!O)throw s.getLogger().warn(`[Retry:${l}] Failed on attempt ${d+1}/${t+1}. ${R?"No more retries.":"Error not retryable."}`),g;const _=Me(g)??Le(d,r,a,i,o);m+=_,s.getLogger().warn(`[Retry:${l}] Attempt ${d+1}/${t+1} failed: ${g.message}. Retrying in ${_}ms...`),await xe(_)}throw g||new Error("Retry failed with no error")};if(!u)return f();const h=B.get(u);if(h)return h;const y=f().finally(()=>{B.get(u)===y&&B.delete(u)});return B.set(u,y),y}const b={QUICK:{maxRetries:3,initialDelayMs:1e3,backoffFactor:2,maxDelayMs:1e4},STANDARD:{maxRetries:3,initialDelayMs:2e3,backoffFactor:2,maxDelayMs:3e4},AGGRESSIVE:{maxRetries:5,initialDelayMs:500,backoffFactor:1.5,maxDelayMs:15e3},PATIENT:{maxRetries:5,initialDelayMs:5e3,backoffFactor:2,maxDelayMs:6e4},IDEMPOTENT_WRITE:{maxRetries:1,initialDelayMs:1e3,backoffFactor:2,maxDelayMs:1e4},WRITE_ONCE:{maxRetries:0,initialDelayMs:1e3,backoffFactor:2,maxDelayMs:1e4}};class Oe{stripe=null;initPromise=null;publicKey;routeDiscovery;complianceCheckEnabled;rateLimiter=L(x.PAYMENT);circuitBreaker=q({failureThreshold:5,timeout:1e4,name:"stripe-manager"});constructor(e,t,r=!1){this.publicKey=e,this.routeDiscovery=t,this.complianceCheckEnabled=r}async initialize(){this.stripe||(this.initPromise||(this.initPromise=(async()=>{try{if(this.stripe=await ce(this.publicKey),!this.stripe)throw new Error("Failed to initialize Stripe")}catch(e){throw this.initPromise=null,e}})()),await this.initPromise)}async createSession(e){if(!this.rateLimiter.tryConsume())throw new Error("Rate limit exceeded for Stripe session creation. Please try again later.");const t=k.generateUUID(),r=JSON.stringify(e);try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const a=await this.routeDiscovery.buildUrl("/paywall/v1/stripe-session");s.getLogger().debug("[StripeManager] Creating session",{resource:e.resource,hasCouponCode:!!e.couponCode,hasMetadata:!!(e.metadata&&Object.keys(e.metadata).length),metadataKeyCount:e.metadata?Object.keys(e.metadata).length:0});const i=await s.fetchWithTimeout(a,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":t},body:r});if(!i.ok){const o=await v(i,"Failed to create Stripe session");throw T.fromResponse(i,o)}return await i.json()},{...b.IDEMPOTENT_WRITE,name:"stripe-create-session",inFlightKey:`stripe:create-session:${r}`}))}catch(a){throw a instanceof w?(s.getLogger().error("[StripeManager] Circuit breaker is OPEN - Stripe service unavailable"),new Error("Stripe payment service is temporarily unavailable. Please try again in a few moments.")):a}}async redirectToCheckout(e){if(this.stripe||await this.initialize(),!this.stripe)return{success:!1,error:"Stripe not initialized"};const t=await this.stripe.redirectToCheckout({sessionId:e});return t.error?{success:!1,error:t.error.message}:{success:!0}}async runComplianceCheck(e){if(!this.complianceCheckEnabled)return null;try{const t=await this.routeDiscovery.buildUrl("/paywall/v1/compliance-check"),r=await s.fetchWithTimeout(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resources:e})});if(!r.ok)return null;const a=await r.json();if(!a.cleared)return{success:!1,error:`Purchase blocked: ${(a.reasons??["Purchase blocked by compliance check"]).join("; ")}`}}catch{s.getLogger().warn("[StripeManager] Compliance pre-check failed, proceeding")}return null}async processPayment(e){try{const t=await this.runComplianceCheck([e.resource]);if(t)return t;const r=await this.createSession(e);return await this.redirectToCheckout(r.sessionId)}catch(t){return{success:!1,error:D(t,"Unknown error")}}}async processCartCheckout(e){const{items:t,successUrl:r,cancelUrl:a,metadata:i,customerEmail:o,customerName:c,customerPhone:l,shippingAddress:u,billingAddress:f,couponCode:h,tipAmount:y,shippingMethodId:g,paymentMethodId:m}=e,d=t.map(P=>P.resource),p=await this.runComplianceCheck(d);if(p)return p;if(!this.rateLimiter.tryConsume())return{success:!1,error:"Rate limit exceeded for cart checkout. Please try again later."};const R=k.generateUUID(),I=JSON.stringify({items:t,metadata:i,coupon:h,couponCode:h}),_=k.generateUUID(),A={items:t,metadata:i,cartId:"",successUrl:r,cancelUrl:a,customerEmail:o,customerName:c,customerPhone:l,shippingAddress:u,billingAddress:f,coupon:h,couponCode:h,tipAmount:y,shippingMethodId:g,paymentMethodId:m};try{const P=await this.circuitBreaker.execute(async()=>{const C=await E(async()=>{const z=await this.routeDiscovery.buildUrl("/paywall/v1/cart/quote"),M=await s.fetchWithTimeout(z,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":R},body:I});if(!M.ok){const J=await v(M,"Failed to create cart quote");throw T.fromResponse(M,J)}return await M.json()},{...b.IDEMPOTENT_WRITE,name:"stripe-cart-quote",inFlightKey:`stripe:cart-quote:${I}`});if(!C.cartId)throw new Error("Invalid cart quote response: missing cartId");const U=JSON.stringify({...A,cartId:C.cartId});return await E(async()=>{const z=await this.routeDiscovery.buildUrl("/paywall/v1/cart/checkout"),M=await s.fetchWithTimeout(z,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":_},body:U});if(!M.ok){const J=await v(M,"Failed to create cart checkout session");throw T.fromResponse(M,J)}return await M.json()},{...b.IDEMPOTENT_WRITE,name:"stripe-cart-checkout",inFlightKey:`stripe:cart-checkout:${U}`})});return await this.redirectToCheckout(P.sessionId)}catch(P){return P instanceof w?{success:!1,error:"Stripe payment service is temporarily unavailable. Please try again in a few moments."}:{success:!1,error:D(P,"Cart checkout failed")}}}}class Fe{routeDiscovery;quoteRateLimiter=L(x.QUOTE);verifyRateLimiter=L(x.PAYMENT);circuitBreaker=q({failureThreshold:5,timeout:1e4,name:"x402-manager"});constructor(e){this.routeDiscovery=e}async requestQuote(e){const{resource:t,couponCode:r}=e;if(!this.quoteRateLimiter.tryConsume())throw new Error("Rate limit exceeded for quote requests. Please try again later.");try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const a="/paywall/v1/quote";s.getLogger().debug("[X402Manager] Requesting quote",r?"with coupon":"without coupon");const i=await this.routeDiscovery.buildUrl(a),o=await s.fetchWithTimeout(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resource:t,couponCode:r||null})});if(o.status!==402)throw new Error(`Expected 402 status, got ${o.status}`);const c=await o.json();if(c.crypto){const l=c.crypto;if(!this.validateRequirement(l))throw new Error("Invalid x402 requirement received from server: missing required fields");return l}else if(c.accepts&&c.accepts.length>0){const l=c.accepts[0];if(!this.validateRequirement(l))throw new Error("Invalid x402 requirement received from server: missing required fields");return l}else throw new Error("Invalid x402 response: missing crypto or accepts field")},{...b.QUICK,name:"x402-quote"}))}catch(a){throw a instanceof w?(s.getLogger().error("[X402Manager] Circuit breaker is OPEN - x402 service unavailable"),new Error("Payment service is temporarily unavailable. Please try again in a few moments.")):a}}async requestCartQuote(e){const{items:t,metadata:r,couponCode:a}=e;if(!this.quoteRateLimiter.tryConsume())throw new Error("Rate limit exceeded for cart quote requests. Please try again later.");const i=k.generateUUID();try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const o=await this.routeDiscovery.buildUrl("/paywall/v1/cart/quote"),c={items:t,metadata:r,coupon:a,couponCode:a},l=await s.fetchWithTimeout(o,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":i},body:JSON.stringify(c)});if(l.status!==402&&!l.ok){const f=await v(l,"Failed to get cart quote");throw new Error(f)}const u=await l.json();if(!u.cartId||!u.quote)throw new Error("Invalid cart quote response: missing cartId or quote");if(u.quote.crypto&&!this.validateRequirement(u.quote.crypto))throw new Error("Invalid x402 cart quote: missing required fields in crypto quote");return u},{...b.QUICK,name:"x402-cart-quote"}))}catch(o){throw o instanceof w?(s.getLogger().error("[X402Manager] Circuit breaker is OPEN - cart quote service unavailable"),new Error("Payment service is temporarily unavailable. Please try again in a few moments.")):o}}buildPaymentHeader(e){const t=JSON.stringify(e);return s.gBase64.encode(t)}parseSettlementResponse(e){const t=e.headers.get("X-PAYMENT-RESPONSE");if(!t)return null;try{const r=s.gBase64.decode(t),a=JSON.parse(r);return typeof a.success!="boolean"?(s.getLogger().error("Invalid settlement response: missing success field"),null):a}catch(r){return s.getLogger().error("Failed to parse settlement response:",r),null}}async submitPayment(e){const{resource:t,payload:r,couponCode:a,metadata:i,resourceType:o="regular"}=e;if(!this.verifyRateLimiter.tryConsume())return{success:!1,error:"Rate limit exceeded for payment verification. Please try again later."};const c=k.generateUUID();try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const u={...r,payload:{...r.payload,resource:t,resourceType:o,metadata:{...r.payload.metadata||{},...i||{},...a?{couponCode:a}:{}}}},f=this.buildPaymentHeader(u),h="/paywall/v1/verify";s.getLogger().debug("[X402Manager] Submitting payment",{resourceType:o,hasCoupon:!!a,hasMetadata:!!i});const y=await this.routeDiscovery.buildUrl(h),g=await s.fetchWithTimeout(y,{method:"POST",headers:{"Content-Type":"application/json","X-PAYMENT":f,"Idempotency-Key":c}});if(g.ok){const{settlement:d,transactionId:p}=await this.handlePaymentVerification(g,r.payload.signature);return{success:!0,transactionId:p,settlement:d||void 0}}return{success:!1,error:await v(g,"Payment verification failed",!0)}},{maxRetries:0,initialDelayMs:0,backoffFactor:1,maxDelayMs:0,name:"x402-verify"}))}catch(l){return l instanceof w?{success:!1,error:"Payment verification service is temporarily unavailable. Please try again in a few moments."}:{success:!1,error:D(l,"Unknown error")}}}async buildGaslessTransaction(e){const{resourceId:t,userWallet:r,feePayer:a,couponCode:i}=e;if(!this.quoteRateLimiter.tryConsume())throw new Error("Rate limit exceeded for gasless transaction requests. Please try again later.");try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const o=await this.routeDiscovery.buildUrl("/paywall/v1/gasless-transaction"),c=await s.fetchWithTimeout(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resourceId:t,userWallet:r,feePayer:a,couponCode:i})});if(!c.ok){const l=await v(c,"Failed to build gasless transaction");throw new Error(l)}return await c.json()},{...b.QUICK,name:"x402-gasless-build"}))}catch(o){throw o instanceof w?(s.getLogger().error("[X402Manager] Circuit breaker is OPEN - gasless transaction service unavailable"),new Error("Gasless transaction service is temporarily unavailable. Please try again in a few moments.")):o}}async submitGaslessTransaction(e){const{resource:t,partialTx:r,couponCode:a,metadata:i,resourceType:o="regular",requirement:c}=e;if(!this.verifyRateLimiter.tryConsume())return{success:!1,error:"Rate limit exceeded for gasless transaction verification. Please try again later."};const l=k.generateUUID();try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const f={x402Version:0,scheme:c?.scheme||"solana-spl-transfer",network:c?.network||"mainnet-beta",payload:{signature:"",transaction:r,feePayer:c?.extra?.feePayer||"",resource:t,resourceType:o,metadata:{...i||{},...a?{couponCode:a}:{}}}},h=this.buildPaymentHeader(f),g=await this.routeDiscovery.buildUrl("/paywall/v1/verify"),m=await s.fetchWithTimeout(g,{method:"POST",headers:{"Content-Type":"application/json","X-PAYMENT":h,"Idempotency-Key":l}});if(m.ok){const{settlement:p,transactionId:R}=await this.handlePaymentVerification(m,"gasless-tx");return{success:!0,transactionId:R,settlement:p||void 0}}return{success:!1,error:await v(m,"Gasless transaction failed",!0)}},{maxRetries:0,initialDelayMs:0,backoffFactor:1,maxDelayMs:0,name:"x402-gasless-verify"}))}catch(u){return u instanceof w?{success:!1,error:"Gasless transaction verification service is temporarily unavailable. Please try again in a few moments."}:{success:!1,error:D(u,"Unknown error")}}}async handlePaymentVerification(e,t){const r=this.parseSettlementResponse(e),a=e.headers.get("Content-Type")||"";let i=t;if(a.includes("application/json"))try{i=(await e.json()).signature||t}catch(o){s.getLogger().warn("Failed to parse JSON response body:",o)}return{settlement:r,transactionId:i}}validateRequirement(e){return!!(e.scheme&&e.network&&e.maxAmountRequired&&e.resource&&e.payTo&&e.asset&&e.maxTimeoutSeconds>0)}}class Ae{stripe=null;initPromise=null;publicKey;routeDiscovery;sessionRateLimiter=L(x.PAYMENT);statusRateLimiter=L(x.QUOTE);circuitBreaker=q({failureThreshold:5,timeout:1e4,name:"subscription-manager"});constructor(e,t){this.publicKey=e,this.routeDiscovery=t}resolveSubscriptionSessionFlow(e){const t=e,r=typeof t.flow=="string"?t.flow:void 0;return r==="payment_sheet"||typeof t.paymentIntentClientSecret=="string"||typeof t.setupIntentClientSecret=="string"?{flow:"payment_sheet",paymentIntentClientSecret:typeof t.paymentIntentClientSecret=="string"?t.paymentIntentClientSecret:void 0,setupIntentClientSecret:typeof t.setupIntentClientSecret=="string"?t.setupIntentClientSecret:void 0,customerId:typeof t.customerId=="string"?t.customerId:void 0,customerEphemeralKeySecret:typeof t.customerEphemeralKeySecret=="string"?t.customerEphemeralKeySecret:void 0,sessionId:typeof t.sessionId=="string"?t.sessionId:void 0,url:typeof t.url=="string"?t.url:void 0}:(r===void 0||r==="redirect_checkout")&&typeof t.sessionId=="string"&&typeof t.url=="string"?{flow:"redirect_checkout",sessionId:t.sessionId,url:t.url}:null}async initialize(){this.stripe||(this.initPromise||(this.initPromise=(async()=>{if(this.stripe=await ce(this.publicKey),!this.stripe)throw new Error("Failed to initialize Stripe")})()),await this.initPromise)}async executeWithResilience(e,t,r,a,i=b.STANDARD){if(!e.tryConsume())throw new Error("Rate limit exceeded. Please try again later.");try{return await this.circuitBreaker.execute(()=>E(t,{...i,name:r}))}catch(o){throw o instanceof w?(s.getLogger().error(`[SubscriptionManager] Circuit breaker OPEN for ${a}`),new Error("Service temporarily unavailable. Please try again in a few moments.")):o}}async createSubscriptionSession(e){if(!this.sessionRateLimiter.tryConsume())throw new Error("Rate limit exceeded for subscription session creation. Please try again later.");const t=k.generateUUID(),r=JSON.stringify(e);try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const a=await this.routeDiscovery.buildUrl("/paywall/v1/subscription/stripe-session");s.getLogger().debug("[SubscriptionManager] Creating subscription session:",{resource:e.resource,interval:e.interval,trialDays:e.trialDays});const i=await s.fetchWithTimeout(a,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":t},body:r});if(!i.ok){const o=await v(i,"Failed to create subscription session");throw T.fromResponse(i,o)}return await i.json()},{...b.IDEMPOTENT_WRITE,name:"subscription-create-session",inFlightKey:`subscription:create-session:${r}`}))}catch(a){throw a instanceof w?(s.getLogger().error("[SubscriptionManager] Circuit breaker is OPEN - service unavailable"),new Error("Subscription service is temporarily unavailable. Please try again in a few moments.")):a}}async redirectToCheckout(e){if(this.stripe||await this.initialize(),!this.stripe)return{success:!1,error:"Stripe not initialized"};const t=await this.stripe.redirectToCheckout({sessionId:e});return t.error?{success:!1,error:t.error.message}:{success:!0,transactionId:e}}async processSubscription(e){try{const t=await this.createSubscriptionSession(e),r=this.resolveSubscriptionSessionFlow(t);return r?r.flow==="payment_sheet"?{success:!1,error:"Native payment sheet subscription sessions are not supported on web. Use redirect checkout instead."}:await this.redirectToCheckout(r.sessionId):{success:!1,error:"Subscription session response was missing required redirect checkout fields."}}catch(t){return{success:!1,error:D(t,"Subscription failed")}}}async checkSubscriptionStatus(e){if(!this.statusRateLimiter.tryConsume())throw new Error("Rate limit exceeded for subscription status check. Please try again later.");try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const t=new URLSearchParams({resource:e.resource,userId:e.userId}),r=await this.routeDiscovery.buildUrl(`/paywall/v1/subscription/status?${t.toString()}`);s.getLogger().debug("[SubscriptionManager] Checking subscription status:",e);const a=await s.fetchWithTimeout(r,{method:"GET",headers:{"Content-Type":"application/json"}});if(!a.ok){const i=await v(a,"Failed to check subscription status");throw new Error(i)}return await a.json()},{...b.STANDARD,name:"subscription-status-check"}))}catch(t){throw t instanceof w?(s.getLogger().error("[SubscriptionManager] Circuit breaker is OPEN for status check"),new Error("Subscription status service is temporarily unavailable. Please try again in a few moments.")):t}}async requestSubscriptionQuote(e,t,r){if(!this.statusRateLimiter.tryConsume())throw new Error("Rate limit exceeded for subscription quote. Please try again later.");try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const a=await this.routeDiscovery.buildUrl("/paywall/v1/subscription/quote"),i={resource:e,interval:t,couponCode:r?.couponCode,intervalDays:r?.intervalDays};s.getLogger().debug("[SubscriptionManager] Requesting subscription quote:",i);const o=await s.fetchWithTimeout(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(o.status!==402&&!o.ok){const c=await v(o,"Failed to get subscription quote");throw new Error(c)}return await o.json()},{...b.STANDARD,name:"subscription-quote"}))}catch(a){throw a instanceof w?(s.getLogger().error("[SubscriptionManager] Circuit breaker is OPEN for quote"),new Error("Subscription quote service is temporarily unavailable. Please try again in a few moments.")):a}}async activateX402Subscription(e){const t=JSON.stringify(e);return this.executeWithResilience(this.sessionRateLimiter,async()=>{const r=await this.routeDiscovery.buildUrl("/paywall/v1/subscription/x402/activate");s.getLogger().debug("[SubscriptionManager] Activating x402 subscription:",e);const a=await s.fetchWithTimeout(r,{method:"POST",headers:{"Content-Type":"application/json"},body:t});if(!a.ok)throw T.fromResponse(a,await v(a,"Failed to activate"));return await a.json()},"subscription-activate","activation",{...b.IDEMPOTENT_WRITE,inFlightKey:`subscription:activate:${t}`})}}class Ne{routeDiscovery;rateLimiter=L(x.PAYMENT);queryRateLimiter=L(x.QUOTE);circuitBreaker=q({failureThreshold:5,timeout:1e4,name:"subscription-change-manager"});constructor(e){this.routeDiscovery=e}async executeWithResilience(e,t,r,a,i=b.STANDARD){if(!e.tryConsume())throw new Error("Rate limit exceeded. Please try again later.");try{return await this.circuitBreaker.execute(()=>E(t,{...i,name:r}))}catch(o){throw o instanceof w?(s.getLogger().error(`[SubscriptionChangeManager] Circuit breaker OPEN for ${a}`),new Error("Service temporarily unavailable. Please try again in a few moments.")):o}}async changeSubscription(e){const t=k.generateUUID(),r=JSON.stringify(e);return this.executeWithResilience(this.rateLimiter,async()=>{const a=await this.routeDiscovery.buildUrl("/paywall/v1/subscription/change");s.getLogger().debug("[SubscriptionChangeManager] Changing subscription:",e);const i=await s.fetchWithTimeout(a,{method:"POST",headers:{"Content-Type":"application/json","Idempotency-Key":t},body:r});if(!i.ok)throw T.fromResponse(i,await v(i,"Failed to change subscription"));return await i.json()},"subscription-change","plan change",{...b.IDEMPOTENT_WRITE,inFlightKey:`subscription:change:${r}`})}async previewChange(e){return this.executeWithResilience(this.queryRateLimiter,async()=>{const t=await this.routeDiscovery.buildUrl("/paywall/v1/subscription/change/preview");s.getLogger().debug("[SubscriptionChangeManager] Previewing subscription change:",e);const r=await s.fetchWithTimeout(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)});if(!r.ok)throw new Error(await v(r,"Failed to preview change"));return await r.json()},"subscription-preview","change preview")}async getDetails(e,t){return this.executeWithResilience(this.queryRateLimiter,async()=>{const r=new URLSearchParams({resource:e,userId:t}),a=await this.routeDiscovery.buildUrl(`/paywall/v1/subscription/details?${r}`);s.getLogger().debug("[SubscriptionChangeManager] Getting subscription details:",{resource:e,userId:t});const i=await s.fetchWithTimeout(a,{method:"GET",headers:{"Content-Type":"application/json"}});if(!i.ok)throw new Error(await v(i,"Failed to get subscription details"));return await i.json()},"subscription-details","details")}async cancel(e){const t=JSON.stringify(e);return this.executeWithResilience(this.rateLimiter,async()=>{const r=await this.routeDiscovery.buildUrl("/paywall/v1/subscription/cancel");s.getLogger().debug("[SubscriptionChangeManager] Canceling subscription:",e);const a=await s.fetchWithTimeout(r,{method:"POST",headers:{"Content-Type":"application/json"},body:t});if(!a.ok)throw T.fromResponse(a,await v(a,"Failed to cancel subscription"));return await a.json()},"subscription-cancel","cancellation",{...b.WRITE_ONCE,inFlightKey:`subscription:cancel:${t}`})}async getBillingPortalUrl(e){const t=JSON.stringify(e);return this.executeWithResilience(this.queryRateLimiter,async()=>{const r=await this.routeDiscovery.buildUrl("/paywall/v1/subscription/portal");s.getLogger().debug("[SubscriptionChangeManager] Getting billing portal URL:",e);const a=await s.fetchWithTimeout(r,{method:"POST",headers:{"Content-Type":"application/json"},body:t});if(!a.ok)throw T.fromResponse(a,await v(a,"Failed to get billing portal URL"));return await a.json()},"subscription-portal","portal",{...b.WRITE_ONCE,inFlightKey:`subscription:portal:${t}`})}}class Ue{routeDiscovery;rateLimiter=L(x.PAYMENT);circuitBreaker=q({failureThreshold:5,timeout:1e4,name:"credits-manager"});constructor(e){this.routeDiscovery=e}async requestQuote(e,t){if(!this.rateLimiter.tryConsume())throw new Error("Rate limit exceeded for credits quote. Please try again later.");try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const r=await this.routeDiscovery.buildUrl("/paywall/v1/quote");s.getLogger().debug("[CreditsManager] Requesting quote");const a=await s.fetchWithTimeout(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({resource:e,couponCode:t})});if(a.status===402)return(await a.json()).credits||null;if(!a.ok){const i=await v(a,"Failed to get credits quote");throw new Error(i)}return null},{...b.STANDARD,name:"credits-quote"}))}catch(r){throw r instanceof w?(s.getLogger().error("[CreditsManager] Circuit breaker is OPEN - credits service unavailable"),new Error("Credits service is temporarily unavailable. Please try again in a few moments.")):r}}async requestCartQuote(e,t){if(!this.rateLimiter.tryConsume())throw new Error("Rate limit exceeded for cart credits quote. Please try again later.");try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const r=await this.routeDiscovery.buildUrl("/paywall/v1/cart/quote");s.getLogger().debug("[CreditsManager] Requesting cart quote for items:",e.length);const a=await s.fetchWithTimeout(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items:e,couponCode:t})});if(a.status===402||a.ok){const o=await a.json();return o.credits?{cartId:o.cartId,credits:o.credits}:null}const i=await v(a,"Failed to get cart credits quote");throw new Error(i)},{...b.STANDARD,name:"credits-cart-quote"}))}catch(r){throw r instanceof w?new Error("Credits service is temporarily unavailable. Please try again in a few moments."):r}}async createHold(e){const{resource:t,couponCode:r,authToken:a}=e;if(!this.rateLimiter.tryConsume())throw new Error("Rate limit exceeded for credits hold. Please try again later.");const i=k.generateUUID(),o=JSON.stringify({resource:t,couponCode:r});try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const c=await this.routeDiscovery.buildUrl("/paywall/v1/credits/hold");s.getLogger().debug("[CreditsManager] Creating hold");const l=await s.fetchWithTimeout(c,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`,"Idempotency-Key":i},body:o});if(!l.ok){const u=await v(l,"Failed to create credits hold");throw T.fromResponse(l,u)}return await l.json()},{...b.IDEMPOTENT_WRITE,name:"credits-create-hold",inFlightKey:`credits:create-hold:${a}:${o}`}))}catch(c){throw c instanceof w?new Error("Credits service is temporarily unavailable. Please try again in a few moments."):c}}async createCartHold(e){const{cartId:t,authToken:r}=e;if(!this.rateLimiter.tryConsume())throw new Error("Rate limit exceeded for cart credits hold. Please try again later.");const a=k.generateUUID();try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const i=await this.routeDiscovery.buildUrl(`/paywall/v1/cart/${encodeURIComponent(t)}/credits/hold`);s.getLogger().debug("[CreditsManager] Creating cart hold for cart:",t);const o=await s.fetchWithTimeout(i,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`,"Idempotency-Key":a},body:JSON.stringify({})});if(!o.ok){const c=await v(o,"Failed to create cart credits hold");throw T.fromResponse(o,c)}return await o.json()},{...b.IDEMPOTENT_WRITE,name:"credits-create-cart-hold",inFlightKey:`credits:create-cart-hold:${r}:${t}`}))}catch(i){throw i instanceof w?new Error("Credits service is temporarily unavailable. Please try again in a few moments."):i}}async authorizePayment(e){const{resource:t,holdId:r,couponCode:a,authToken:i,metadata:o}=e;if(!this.rateLimiter.tryConsume())return{success:!1,error:"Rate limit exceeded for credits authorization. Please try again later.",errorCode:"rate_limit_exceeded"};const c=k.generateUUID(),l=JSON.stringify({resource:t,holdId:r,couponCode:a,...o&&{metadata:o}});try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const u=await this.routeDiscovery.buildUrl("/paywall/v1/credits/authorize");s.getLogger().debug("[CreditsManager] Authorizing payment");const f=await s.fetchWithTimeout(u,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`,"Idempotency-Key":c},body:l});if(!f.ok){const y=await f.json().catch(()=>({}));throw T.fromResponse(f,y.error?.message||"Credits authorization failed")}return{success:!0,transactionId:(await f.json()).transactionId}},{...b.IDEMPOTENT_WRITE,name:"credits-authorize",inFlightKey:`credits:authorize:${i}:${l}`}))}catch(u){return u instanceof w?{success:!1,error:"Credits service is temporarily unavailable. Please try again in a few moments.",errorCode:"service_unavailable"}:{success:!1,error:D(u,"Credits authorization failed"),errorCode:"authorization_failed"}}}async authorizeCartPayment(e){const{cartId:t,holdId:r,authToken:a,metadata:i}=e;if(!this.rateLimiter.tryConsume())return{success:!1,error:"Rate limit exceeded for cart credits authorization. Please try again later.",errorCode:"rate_limit_exceeded"};const o=k.generateUUID(),c=JSON.stringify({holdId:r,...i&&{metadata:i}});try{return await this.circuitBreaker.execute(async()=>await E(async()=>{const l=await this.routeDiscovery.buildUrl(`/paywall/v1/cart/${encodeURIComponent(t)}/credits/authorize`);s.getLogger().debug("[CreditsManager] Authorizing cart payment for cart:",t);const u=await s.fetchWithTimeout(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a}`,"Idempotency-Key":o},body:c});if(!u.ok){const h=await u.json().catch(y=>(s.getLogger().error("[CreditsManager] Failed to parse error response JSON:",y,{cartId:t,status:u.status,statusText:u.statusText}),{}));throw T.fromResponse(u,h.error?.message||"Cart credits authorization failed")}return{success:!0,transactionId:(await u.json()).transactionId}},{...b.IDEMPOTENT_WRITE,name:"credits-cart-authorize",inFlightKey:`credits:cart-authorize:${a}:${t}:${c}`}))}catch(l){return l instanceof w?{success:!1,error:"Credits service is temporarily unavailable. Please try again in a few moments.",errorCode:"service_unavailable"}:{success:!1,error:D(l,"Cart credits authorization failed"),errorCode:"authorization_failed"}}}async releaseHold(e,t){if(e)try{await this.circuitBreaker.execute(async()=>{const r=await this.routeDiscovery.buildUrl(`/paywall/v1/credits/hold/${encodeURIComponent(e)}/release`),a=await s.fetchWithTimeout(r,{method:"POST",headers:{Authorization:`Bearer ${t}`,"Idempotency-Key":k.generateUUID()}});if(!a.ok){const i=await v(a,"Failed to release credits hold");throw new Error(i)}})}catch(r){throw r instanceof w?new Error("Credits service is temporarily unavailable. Please try again in a few moments."):r}}async processPayment(e,t,r,a){let i=null;try{i=(await this.createHold({resource:e,couponCode:r,authToken:t})).holdId;const c=await this.authorizePayment({resource:e,holdId:i,couponCode:r,authToken:t,metadata:a});if(!c.success&&i)try{await this.releaseHold(i,t)}catch(l){s.getLogger().warn("[CreditsManager] Failed to release hold after auth failure:",l)}return{success:c.success,transactionId:c.transactionId,error:c.error}}catch(o){if(i)try{await this.releaseHold(i,t)}catch(c){s.getLogger().warn("[CreditsManager] Failed to release hold after payment failure:",c)}return{success:!1,error:D(o,"Credits payment failed")}}}async getBalance(e){try{return await this.circuitBreaker.execute(async()=>{const t=await this.routeDiscovery.buildUrl("/paywall/v1/credits/balance"),r=await s.fetchWithTimeout(t,{method:"GET",headers:{Authorization:`Bearer ${e}`}});if(!r.ok){const a=await v(r,"Failed to fetch credits balance");throw new Error(a)}return await r.json()})}catch(t){throw t instanceof w?new Error("Credits service is temporarily unavailable. Please try again in a few moments."):t}}}class qe{serverUrl;getLogger;fetchWithTimeout;routePrefix=null;discoveryPromise=null;failedDiscoveryAt=null;maxRetries=2;baseDelayMs=1e3;discoveryTimeoutMs=2e3;failedDiscoveryTtlMs=3e4;constructor(e,t){this.serverUrl=e.replace(/\/+$/,""),this.getLogger=t.getLogger,this.fetchWithTimeout=t.fetchWithTimeout}async discoverPrefix(){if(this.routePrefix!==null)return this.routePrefix;if(this.discoveryPromise)return this.discoveryPromise;if(this.failedDiscoveryAt!==null&&Date.now()-this.failedDiscoveryAt<this.failedDiscoveryTtlMs)return"";const e=(async()=>{let t=0;for(;t<this.maxRetries;)try{const r=await this.fetchWithTimeout(`${this.serverUrl}/cedros-health`,{},this.discoveryTimeoutMs);if(!r.ok){if(r.status>=400&&r.status<500)return this.getLogger().warn(`Route discovery received ${r.status} - not retrying client error`),this.failedDiscoveryAt=Date.now(),"";throw new Error(`Health check returned ${r.status}`)}const a=await r.json(),i=String(a.routePrefix??"");return this.routePrefix=i,this.failedDiscoveryAt=null,this.getLogger().debug("Route discovery successful, prefix:",i||"(empty)"),i}catch(r){if(t++,t>=this.maxRetries)return this.getLogger().warn(`Route discovery failed after ${t} attempts, using empty prefix for this request:`,r),this.failedDiscoveryAt=Date.now(),"";const a=this.baseDelayMs*Math.pow(2,t-1);this.getLogger().warn(`Route discovery failed (attempt ${t}/${this.maxRetries}), retrying in ${a}ms:`,r),await new Promise(i=>setTimeout(i,a))}return""})();this.discoveryPromise=e;try{return await this.discoveryPromise}finally{this.discoveryPromise===e&&(this.discoveryPromise=null)}}async buildUrl(e){const t=await this.discoverPrefix(),r=e.startsWith("/")?e:`/${e}`;return`${this.serverUrl}${t}${r}`}reset(){this.routePrefix=null,this.discoveryPromise=null,this.failedDiscoveryAt=null}}class $e extends qe{constructor(e){super(e,{getLogger:s.getLogger,fetchWithTimeout:s.fetchWithTimeout})}}let Y=null;async function je(){return Y||(Y=(await Promise.resolve().then(()=>require("./WalletManager-DXChB9LA.js"))).WalletManager),Y}const K=new Map,V=new Map;function he(n,e,t,r,a,i){return JSON.stringify({stripePublicKey:n,serverUrl:e,solanaCluster:t,solanaEndpoint:r||"",dangerouslyAllowUnknownMint:a||!1,complianceCheck:i||!1})}async function We(n,e,t,r,a,i){const o=he(n,e,t,r,a,i);let c=K.get(o);if(c)return c.refCount++,s.getLogger().debug(`[ManagerCache] Reusing cached managers (refCount: ${c.refCount}):`,{stripePublicKey:n.slice(0,10)+"...",serverUrl:e}),c;const l=V.get(o);if(l)return c=await l,c.refCount++,s.getLogger().debug(`[ManagerCache] Reusing in-flight managers (refCount: ${c.refCount}):`,{stripePublicKey:n.slice(0,10)+"...",serverUrl:e}),c;s.getLogger().debug("[ManagerCache] Creating new manager instances:",{stripePublicKey:n.slice(0,10)+"...",serverUrl:e});const u=(async()=>{const f=new $e(e),h=new Oe(n,f,i??!1),y=new Fe(f),g=await je(),m=new g(t,r,a??!1),d=new Ae(n,f),p=new Ne(f),R=new Ue(f);return{stripeManager:h,x402Manager:y,walletManager:m,subscriptionManager:d,subscriptionChangeManager:p,creditsManager:R,routeDiscovery:f,refCount:1}})();V.set(o,u);try{return c=await u,K.set(o,c),c}finally{V.delete(o)}}function ae(n,e,t,r,a,i){const o=he(n,e,t,r,a,i),c=K.get(o);if(!c){s.getLogger().warn("[ManagerCache] Attempted to release non-existent managers:",{cacheKey:o});return}c.refCount--,s.getLogger().debug(`[ManagerCache] Released manager reference (refCount: ${c.refCount}):`,{stripePublicKey:n.slice(0,10)+"...",serverUrl:e}),c.refCount<=0&&(K.delete(o),s.getLogger().debug("[ManagerCache] Removed managers from cache (refCount reached 0)"))}function He(n){return`CEDROS_FEATURE_${n.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^a-zA-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").toUpperCase()}`}function Be(n){const e=Object.entries(n).map(([t,r])=>[t,{name:t,description:r.description,default:r.default,stage:r.stage??"experimental",envVar:He(t)}]);return Object.freeze(Object.fromEntries(e))}const N=Be({complianceCheck:{description:"Enable pre-flight compliance checks before Stripe checkout.",default:!1,stage:"stable"}}),Z=Object.freeze(Object.keys(N));function Ke(){return typeof process<"u"&&process.env?process.env:{}}function X(n,e){if(n)for(const[t,r]of Object.entries(n)){if(!(t in N))throw new Error(`Unknown feature flag "${t}" in ${e}`);if(typeof r!="boolean")throw new Error(`Feature flag "${t}" in ${e} must be a boolean`)}}function fe(n){if(n==null)return;const e=n.trim().toLowerCase();if(e){if(e==="1"||e==="true"||e==="yes"||e==="on")return!0;if(e==="0"||e==="false"||e==="no"||e==="off")return!1}}function ze(n){return N[n]}function Je(){return Z.map(n=>N[n])}function ee(n={}){const e=n.env??Ke();X(n.featureFlags,"featureFlags"),X(n.fallbackFlags,"fallbackFlags");const t={};for(const r of Z){const a=n.featureFlags?.[r],i=n.fallbackFlags?.[r],o=fe(e[N[r].envVar]);t[r]=a??i??o??N[r].default}return t}function Ge(n,e={}){return ee(e)[n]}function Ye(n,e="featureFlags"){X(n,e)}const ie=new Set(["mainnet-beta","devnet","testnet"]);function Ve(){if(typeof window<"u"&&window.location)return window.location.origin;throw new Error("serverUrl is required in SSR/Node environments. In browser environments, it defaults to window.location.origin")}function me(n){const e=[];if(n.showCard!==!1){const a=n.stripePublicKey;(typeof a!="string"||a.trim().length===0)&&e.push({field:"stripePublicKey",message:"must be a non-empty string when card payments are enabled (showCard is not false)"})}let r;if(n.serverUrl!==void 0)typeof n.serverUrl!="string"||n.serverUrl.trim().length===0?(e.push({field:"serverUrl",message:"must be a non-empty string when provided"}),r=""):(!n.serverUrl.startsWith("http://")&&!n.serverUrl.startsWith("https://")&&e.push({field:"serverUrl",message:'must start with "http://" or "https://"'}),r=n.serverUrl);else try{r=Ve()}catch(a){e.push({field:"serverUrl",message:a instanceof Error?a.message:"failed to determine default"}),r=""}ie.has(n.solanaCluster)||e.push({field:"solanaCluster",message:`must be one of ${Array.from(ie).join(", ")}`}),n.solanaEndpoint!==void 0&&(typeof n.solanaEndpoint!="string"?e.push({field:"solanaEndpoint",message:"must be a string when provided"}):n.solanaEndpoint.trim().length===0?e.push({field:"solanaEndpoint",message:'must be a non-empty string when provided (e.g., "https://api.mainnet-beta.solana.com")'}):!n.solanaEndpoint.startsWith("http://")&&!n.solanaEndpoint.startsWith("https://")&&e.push({field:"solanaEndpoint",message:'must start with "http://" or "https://" (e.g., "https://api.mainnet-beta.solana.com")'})),n.tokenMint&&typeof n.tokenMint!="string"&&e.push({field:"tokenMint",message:"must be a string when provided"});try{Ye(n.featureFlags,"config.featureFlags")}catch(a){e.push({field:"featureFlags",message:a instanceof Error?a.message:"contains invalid values"})}if(e.length>0){const a=e.map(i=>`- ${i.field} ${i.message}`).join(`
|
|
2
|
-
`);throw new Error(`Invalid Cedros configuration:
|
|
3
|
-
${a}`)}if(n.tokenMint){const a=n.dangerouslyAllowUnknownMint===!0,i=pe.validateTokenMint(n.tokenMint,"CedrosConfig.tokenMint",a);if(!i.isValid&&i.error)throw new Error(i.error);i.warning&&s.getLogger().warn(i.warning)}return{...n,serverUrl:r}}const Q={getAdapters:()=>[],cleanup:async()=>{},isInitialized:()=>!1,getId:()=>"stub"};function Qe(){return typeof process<"u"&&process.env.NODE_ENV==="development"?0:2}const ye=S.createContext(null);function Xe({config:n,children:e}){const t=S.useMemo(()=>me(n),[n]),r=S.useMemo(()=>ee({featureFlags:t.featureFlags,fallbackFlags:t.complianceCheck!=null?{complianceCheck:t.complianceCheck}:void 0}),[t.featureFlags,t.complianceCheck]),[a,i]=S.useState(null),[o,c]=S.useState(Q),l=S.useRef(Q);S.useEffect(()=>{let m=!1;return Promise.resolve().then(()=>require("./walletPool-BjTXX6Vn.js")).then(({createWalletPool:d})=>{if(m)return;const p=d();l.current=p,c(p)}).catch(d=>{m||(s.getLogger().error("[CedrosProvider] Wallet pool initialization failed:",d),i("Failed to initialize Cedros provider"))}),()=>{m=!0}},[]);const[u,f]=S.useState(null);S.useEffect(()=>{let m=!1;return Promise.resolve().then(()=>require("./solanaCheck-BS3QTE63.js")).then(({checkSolanaAvailability:d})=>d()).then(d=>{m||(d.available?f(void 0):f(d.error||"Solana dependencies not available"))}).catch(d=>{m||(s.getLogger().warn("[CedrosProvider] Solana availability check failed:",d),f("Unable to verify Solana availability"))}),()=>{m=!0}},[]),S.useEffect(()=>{const m=t.logLevel??Qe(),d=s.createLogger({level:m,prefix:"[CedrosPay]"});s.setLogger(d)},[t.logLevel]),S.useEffect(()=>()=>{const m=l.current;m&&m!==Q&&m.cleanup().catch(d=>{s.getLogger().warn("[CedrosProvider] Wallet pool cleanup failed:",d)})},[]);const[h,y]=S.useState(null);S.useEffect(()=>{let m=!1,d=!1;const p=t.stripePublicKey??"",R=t.serverUrl??"",O=t.solanaCluster,I=t.solanaEndpoint,_=t.dangerouslyAllowUnknownMint,A=r.complianceCheck;return We(p,R,O,I,_,A).then(P=>{if(m){ae(p,R,O,I,_,A);return}d=!0,y(P)}).catch(P=>{m||(s.getLogger().error("[CedrosProvider] Manager initialization failed:",P),i("Failed to initialize Cedros provider"))}),()=>{m=!0,d&&ae(p,R,O,I,_,A)}},[t.stripePublicKey,t.serverUrl,t.solanaCluster,t.solanaEndpoint,t.dangerouslyAllowUnknownMint,r.complianceCheck]);const g=S.useMemo(()=>h?{config:t,featureFlags:r,...h,walletPool:o,solanaError:u}:null,[t,r,h,o,u]);return a?G.jsx("div",{role:"alert",children:a}):G.jsx(ge.CedrosThemeProvider,{initialMode:t.theme??"light",overrides:t.themeOverrides,unstyled:t.unstyled??!1,children:g?G.jsx(ye.Provider,{value:g,children:e}):null})}function Ze(){const n=S.useContext(ye);if(!n)throw new Error("useCedrosContext must be used within CedrosProvider");return n}exports.CIRCUIT_BREAKER_PRESETS=Re;exports.CedrosProvider=Xe;exports.CircuitBreakerOpenError=w;exports.CircuitState=le;exports.ERROR_CATEGORIES=de;exports.FEATURE_FLAG_NAMES=Z;exports.FEATURE_FLAG_REGISTRY=N;exports.PaymentError=F;exports.RATE_LIMITER_PRESETS=x;exports.RETRY_PRESETS=b;exports.createCircuitBreaker=q;exports.createRateLimiter=L;exports.formatError=D;exports.getFeatureFlagDefinition=ze;exports.getFeatureFlagDefinitions=Je;exports.getUserFriendlyError=ue;exports.isFeatureEnabled=Ge;exports.parseErrorResponse=v;exports.parseFeatureFlagBoolean=fe;exports.resolveFeatureFlags=ee;exports.retryWithBackoff=E;exports.useCedrosContext=Ze;exports.validateConfig=me;
|