@cedros/pay-react 0.1.0
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/LICENSE +21 -0
- package/README.md +1731 -0
- package/dist/CedrosContext-B3iCqN6e.js +11 -0
- package/dist/CedrosContext-vX9uqZKp.mjs +1796 -0
- package/dist/ar-LVoQZTFI.js +1 -0
- package/dist/ar-w27mU-4x.mjs +19 -0
- package/dist/bn-BR5Cv1T4.js +1 -0
- package/dist/bn-Ba_k3Kex.mjs +19 -0
- package/dist/components/CedrosPay.d.ts +54 -0
- package/dist/components/CedrosPay.d.ts.map +1 -0
- package/dist/components/CryptoButton.d.ts +26 -0
- package/dist/components/CryptoButton.d.ts.map +1 -0
- package/dist/components/PaymentModal.d.ts +28 -0
- package/dist/components/PaymentModal.d.ts.map +1 -0
- package/dist/components/ProductPrice.d.ts +56 -0
- package/dist/components/ProductPrice.d.ts.map +1 -0
- package/dist/components/PurchaseButton.d.ts +52 -0
- package/dist/components/PurchaseButton.d.ts.map +1 -0
- package/dist/components/StripeButton.d.ts +27 -0
- package/dist/components/StripeButton.d.ts.map +1 -0
- package/dist/context/CedrosContext.d.ts +46 -0
- package/dist/context/CedrosContext.d.ts.map +1 -0
- package/dist/context/ThemeContext.d.ts +30 -0
- package/dist/context/ThemeContext.d.ts.map +1 -0
- package/dist/context/index.d.ts +3 -0
- package/dist/context/index.d.ts.map +1 -0
- package/dist/crypto-only.d.ts +33 -0
- package/dist/crypto-only.d.ts.map +1 -0
- package/dist/crypto-only.js +1 -0
- package/dist/crypto-only.mjs +35 -0
- package/dist/de-CoZiPFN7.mjs +19 -0
- package/dist/de-pQxy-oD1.js +1 -0
- package/dist/en-CSsJl3nf.mjs +19 -0
- package/dist/en-D-uY3ltT.js +1 -0
- package/dist/es-BWGIBp2f.mjs +19 -0
- package/dist/es-D24cg8dD.js +1 -0
- package/dist/fil-BOBft9G-.js +1 -0
- package/dist/fil-Czo27xmj.mjs +19 -0
- package/dist/fr-Ct9ub8Fa.js +1 -0
- package/dist/fr-DQ-2ThBv.mjs +19 -0
- package/dist/he-DpV1WnBQ.mjs +19 -0
- package/dist/he-DtQqRKRq.js +1 -0
- package/dist/hooks/usePaymentMode.d.ts +39 -0
- package/dist/hooks/usePaymentMode.d.ts.map +1 -0
- package/dist/hooks/useRefundVerification.d.ts +30 -0
- package/dist/hooks/useRefundVerification.d.ts.map +1 -0
- package/dist/hooks/useStripeCheckout.d.ts +20 -0
- package/dist/hooks/useStripeCheckout.d.ts.map +1 -0
- package/dist/hooks/useX402Payment.d.ts +24 -0
- package/dist/hooks/useX402Payment.d.ts.map +1 -0
- package/dist/i18n/index.d.ts +107 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/useTranslation.d.ts +55 -0
- package/dist/i18n/useTranslation.d.ts.map +1 -0
- package/dist/id-BJMqsu19.mjs +19 -0
- package/dist/id-CiM2mL7C.js +1 -0
- package/dist/in-BxgxKLQH.mjs +19 -0
- package/dist/in-Bzcjmxcc.js +1 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +626 -0
- package/dist/it-Blb_pIJl.js +1 -0
- package/dist/it-DZFFPALf.mjs +19 -0
- package/dist/jp-9NHyIuwY.js +1 -0
- package/dist/jp-ZExTrlHK.mjs +19 -0
- package/dist/kr-DHX3i4Ht.mjs +19 -0
- package/dist/kr-DvzJ-0yX.js +1 -0
- package/dist/managers/ManagerCache.d.ts +49 -0
- package/dist/managers/ManagerCache.d.ts.map +1 -0
- package/dist/managers/RouteDiscoveryManager.d.ts +72 -0
- package/dist/managers/RouteDiscoveryManager.d.ts.map +1 -0
- package/dist/managers/StripeManager.d.ts +110 -0
- package/dist/managers/StripeManager.d.ts.map +1 -0
- package/dist/managers/WalletManager.d.ts +150 -0
- package/dist/managers/WalletManager.d.ts.map +1 -0
- package/dist/managers/X402Manager.d.ts +176 -0
- package/dist/managers/X402Manager.d.ts.map +1 -0
- package/dist/ms-BOAu5pUB.js +1 -0
- package/dist/ms-Cv1fdIi2.mjs +19 -0
- package/dist/nl-BmGonsKb.mjs +19 -0
- package/dist/nl-WHh_DfO8.js +1 -0
- package/dist/pa-B7kIhZCF.js +1 -0
- package/dist/pa-BfwcJIar.mjs +19 -0
- package/dist/pay-react.css +1 -0
- package/dist/pl-DE5IB9xv.mjs +19 -0
- package/dist/pl-H0hBKdvF.js +1 -0
- package/dist/pt-CLzkqDzf.mjs +19 -0
- package/dist/pt-DwGrViQ3.js +1 -0
- package/dist/ru-CB2m0UDT.js +1 -0
- package/dist/ru-DM6-oUR0.mjs +19 -0
- package/dist/stripe-only.d.ts +31 -0
- package/dist/stripe-only.d.ts.map +1 -0
- package/dist/stripe-only.js +1 -0
- package/dist/stripe-only.mjs +33 -0
- package/dist/styles-D3XGpsqb.js +1 -0
- package/dist/styles-zgmHs6Hs.mjs +1601 -0
- package/dist/ta-A5HnrGb5.mjs +19 -0
- package/dist/ta-CAS197uN.js +1 -0
- package/dist/telemetry.d.ts +27 -0
- package/dist/telemetry.d.ts.map +1 -0
- package/dist/telemetry.js +1 -0
- package/dist/telemetry.mjs +127 -0
- package/dist/testing/__tests__/providers.test.d.ts +10 -0
- package/dist/testing/__tests__/providers.test.d.ts.map +1 -0
- package/dist/testing/helpers.d.ts +242 -0
- package/dist/testing/helpers.d.ts.map +1 -0
- package/dist/testing/index.d.ts +12 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.mjs +374 -0
- package/dist/testing/mocks.d.ts +225 -0
- package/dist/testing/mocks.d.ts.map +1 -0
- package/dist/testing/providers.d.ts +89 -0
- package/dist/testing/providers.d.ts.map +1 -0
- package/dist/th-3fbB3Ytp.mjs +19 -0
- package/dist/th-Cpz2cFcg.js +1 -0
- package/dist/tr-BrgfFFdq.mjs +19 -0
- package/dist/tr-hQrEFk86.js +1 -0
- package/dist/types/componentOptions.d.ts +138 -0
- package/dist/types/componentOptions.d.ts.map +1 -0
- package/dist/types/errors.d.ts +213 -0
- package/dist/types/errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +248 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/uk-0hFun_g_.mjs +19 -0
- package/dist/uk-DrK2Sv8C.js +1 -0
- package/dist/ur-CaOjJXai.mjs +19 -0
- package/dist/ur-D5-7mN9a.js +1 -0
- package/dist/utils/__tests__/cspHelper.test.d.ts +9 -0
- package/dist/utils/__tests__/cspHelper.test.d.ts.map +1 -0
- package/dist/utils/__tests__/fetchWithTimeout.test.d.ts +11 -0
- package/dist/utils/__tests__/fetchWithTimeout.test.d.ts.map +1 -0
- package/dist/utils/cartHelpers.d.ts +105 -0
- package/dist/utils/cartHelpers.d.ts.map +1 -0
- package/dist/utils/circuitBreaker.d.ts +112 -0
- package/dist/utils/circuitBreaker.d.ts.map +1 -0
- package/dist/utils/couponHelpers.d.ts +50 -0
- package/dist/utils/couponHelpers.d.ts.map +1 -0
- package/dist/utils/cspHelper.d.ts +162 -0
- package/dist/utils/cspHelper.d.ts.map +1 -0
- package/dist/utils/deprecation.d.ts +128 -0
- package/dist/utils/deprecation.d.ts.map +1 -0
- package/dist/utils/errorHandling.d.ts +30 -0
- package/dist/utils/errorHandling.d.ts.map +1 -0
- package/dist/utils/errorMessages.d.ts +47 -0
- package/dist/utils/errorMessages.d.ts.map +1 -0
- package/dist/utils/errorParser.d.ts +37 -0
- package/dist/utils/errorParser.d.ts.map +1 -0
- package/dist/utils/eventEmitter.d.ts +119 -0
- package/dist/utils/eventEmitter.d.ts.map +1 -0
- package/dist/utils/exponentialBackoff.d.ts +104 -0
- package/dist/utils/exponentialBackoff.d.ts.map +1 -0
- package/dist/utils/fetchWithTimeout.d.ts +13 -0
- package/dist/utils/fetchWithTimeout.d.ts.map +1 -0
- package/dist/utils/index.d.ts +15 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/logger.d.ts +76 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/modalStyles.d.ts +13 -0
- package/dist/utils/modalStyles.d.ts.map +1 -0
- package/dist/utils/rateLimiter.d.ts +88 -0
- package/dist/utils/rateLimiter.d.ts.map +1 -0
- package/dist/utils/requestDeduplication.d.ts +124 -0
- package/dist/utils/requestDeduplication.d.ts.map +1 -0
- package/dist/utils/securityValidation.d.ts +75 -0
- package/dist/utils/securityValidation.d.ts.map +1 -0
- package/dist/utils/solanaCheck.d.ts +10 -0
- package/dist/utils/solanaCheck.d.ts.map +1 -0
- package/dist/utils/telemetry.d.ts +277 -0
- package/dist/utils/telemetry.d.ts.map +1 -0
- package/dist/utils/tokenMintValidator.d.ts +77 -0
- package/dist/utils/tokenMintValidator.d.ts.map +1 -0
- package/dist/utils/uuid.d.ts +13 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/validateConfig.d.ts +13 -0
- package/dist/utils/validateConfig.d.ts.map +1 -0
- package/dist/utils/walletDetection.d.ts +6 -0
- package/dist/utils/walletDetection.d.ts.map +1 -0
- package/dist/utils/walletPool.d.ts +57 -0
- package/dist/utils/walletPool.d.ts.map +1 -0
- package/dist/uuid-C0iMjdcc.js +1 -0
- package/dist/uuid-UlzrVY8Y.mjs +17 -0
- package/dist/vn-0nlIZFLP.mjs +19 -0
- package/dist/vn-B_iut9YL.js +1 -0
- package/dist/walletDetection-JZR3UCOa.mjs +27 -0
- package/dist/walletDetection-bNmV5ItZ.js +1 -0
- package/dist/zh-B4Endr1F.mjs +19 -0
- package/dist/zh-PR82dCHr.js +1 -0
- package/package.json +139 -0
|
@@ -0,0 +1,1601 @@
|
|
|
1
|
+
import { jsxs as E, jsx as C } from "react/jsx-runtime";
|
|
2
|
+
import { useState as F, useCallback as A, useMemo as W, useEffect as U, useRef as ke } from "react";
|
|
3
|
+
import { g as f, u as me, a as fe, f as se } from "./CedrosContext-vX9uqZKp.mjs";
|
|
4
|
+
import { useWallet as De } from "@solana/wallet-adapter-react";
|
|
5
|
+
import { WalletReadyState as Ce } from "@solana/wallet-adapter-base";
|
|
6
|
+
import { WalletIcon as Ge } from "@solana/wallet-adapter-react-ui";
|
|
7
|
+
import "@solana/wallet-adapter-wallets";
|
|
8
|
+
function wt(e) {
|
|
9
|
+
return !e || !e.coupon_codes ? [] : e.coupon_codes.split(",").map((t) => t.trim()).filter((t) => t.length > 0);
|
|
10
|
+
}
|
|
11
|
+
function bt(e, t = ", ") {
|
|
12
|
+
return e.join(t);
|
|
13
|
+
}
|
|
14
|
+
function vt(e, t) {
|
|
15
|
+
return e <= 0 ? 0 : (e - t) / e * 100;
|
|
16
|
+
}
|
|
17
|
+
function Ee(e) {
|
|
18
|
+
const t = Number(e);
|
|
19
|
+
if (!Number.isFinite(t) || t <= 0)
|
|
20
|
+
return 1;
|
|
21
|
+
const n = Math.floor(t);
|
|
22
|
+
return n > 0 ? n : 1;
|
|
23
|
+
}
|
|
24
|
+
function Oe(e) {
|
|
25
|
+
return e.map((t) => ({
|
|
26
|
+
resource: t.resource,
|
|
27
|
+
quantity: Ee(t.quantity),
|
|
28
|
+
metadata: t.metadata
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
function K(e) {
|
|
32
|
+
return e.reduce((t, n) => t + Ee(n.quantity), 0);
|
|
33
|
+
}
|
|
34
|
+
function Ve(e) {
|
|
35
|
+
return !!(e && e.length > 0 && (e.length > 1 || e.length === 1 && (e[0].quantity ?? 1) > 1));
|
|
36
|
+
}
|
|
37
|
+
const Xe = {
|
|
38
|
+
// ===== PAYMENT VERIFICATION ERRORS (402) =====
|
|
39
|
+
invalid_payment_proof: {
|
|
40
|
+
message: "Payment verification failed",
|
|
41
|
+
action: "Please try your payment again. If this continues, contact support.",
|
|
42
|
+
technicalHint: "Invalid payment proof format"
|
|
43
|
+
},
|
|
44
|
+
invalid_signature: {
|
|
45
|
+
message: "Transaction signature is invalid",
|
|
46
|
+
action: "Please approve the transaction in your wallet and try again.",
|
|
47
|
+
technicalHint: "Transaction signature verification failed"
|
|
48
|
+
},
|
|
49
|
+
invalid_transaction: {
|
|
50
|
+
message: "Transaction format is invalid",
|
|
51
|
+
action: "Please try your payment again. If this continues, try updating your wallet app.",
|
|
52
|
+
technicalHint: "Malformed transaction structure"
|
|
53
|
+
},
|
|
54
|
+
transaction_not_found: {
|
|
55
|
+
message: "Transaction not found on the blockchain",
|
|
56
|
+
action: "Your transaction may still be processing. Please wait a moment and check your wallet, or try again.",
|
|
57
|
+
technicalHint: "Transaction signature not found on-chain"
|
|
58
|
+
},
|
|
59
|
+
transaction_not_confirmed: {
|
|
60
|
+
message: "Transaction is still processing",
|
|
61
|
+
action: "Please wait a moment for the blockchain to confirm your transaction, then try again.",
|
|
62
|
+
technicalHint: "Transaction not yet confirmed"
|
|
63
|
+
},
|
|
64
|
+
transaction_failed: {
|
|
65
|
+
message: "Transaction failed on the blockchain",
|
|
66
|
+
action: "Check your wallet for details. You may need to adjust your transaction settings or add more SOL for fees.",
|
|
67
|
+
technicalHint: "On-chain transaction failure"
|
|
68
|
+
},
|
|
69
|
+
transaction_expired: {
|
|
70
|
+
message: "Transaction took too long to process",
|
|
71
|
+
action: "Please try your payment again. Consider increasing transaction priority if your wallet supports it.",
|
|
72
|
+
technicalHint: "Transaction blockhash expired"
|
|
73
|
+
},
|
|
74
|
+
invalid_recipient: {
|
|
75
|
+
message: "Payment was sent to the wrong address",
|
|
76
|
+
action: "Please try again and ensure you approve the correct transaction in your wallet.",
|
|
77
|
+
technicalHint: "Recipient address mismatch"
|
|
78
|
+
},
|
|
79
|
+
invalid_sender: {
|
|
80
|
+
message: "Payment sender wallet is invalid",
|
|
81
|
+
action: "Please reconnect your wallet and try again.",
|
|
82
|
+
technicalHint: "Sender address validation failed"
|
|
83
|
+
},
|
|
84
|
+
unauthorized_refund_issuer: {
|
|
85
|
+
message: "You are not authorized to issue refunds",
|
|
86
|
+
action: "Only authorized accounts can process refunds. Please contact support if you believe this is an error.",
|
|
87
|
+
technicalHint: "Refund issuer not in authorized list"
|
|
88
|
+
},
|
|
89
|
+
amount_below_minimum: {
|
|
90
|
+
message: "Payment amount is too low",
|
|
91
|
+
action: "Please check the required amount and try again.",
|
|
92
|
+
technicalHint: "Amount below minimum threshold"
|
|
93
|
+
},
|
|
94
|
+
amount_mismatch: {
|
|
95
|
+
message: "Payment amount does not match the quote",
|
|
96
|
+
action: "The price may have changed. Please refresh and try your payment again.",
|
|
97
|
+
technicalHint: "Amount does not match quote"
|
|
98
|
+
},
|
|
99
|
+
insufficient_funds_sol: {
|
|
100
|
+
message: "Not enough SOL for transaction fees",
|
|
101
|
+
action: "Add at least 0.001 SOL to your wallet to cover network fees, then try again.",
|
|
102
|
+
technicalHint: "Insufficient SOL balance for fees"
|
|
103
|
+
},
|
|
104
|
+
insufficient_funds_token: {
|
|
105
|
+
message: "Insufficient balance in your wallet",
|
|
106
|
+
action: "Add more funds to your wallet and try again.",
|
|
107
|
+
technicalHint: "Insufficient token balance"
|
|
108
|
+
},
|
|
109
|
+
invalid_token_mint: {
|
|
110
|
+
message: "Incorrect payment token",
|
|
111
|
+
action: "Please pay with the correct token as shown in the payment details.",
|
|
112
|
+
technicalHint: "Token mint address mismatch"
|
|
113
|
+
},
|
|
114
|
+
not_spl_transfer: {
|
|
115
|
+
message: "Transaction is not a valid token transfer",
|
|
116
|
+
action: "Please ensure you are sending the correct token type from your wallet.",
|
|
117
|
+
technicalHint: "Transaction is not an SPL token transfer"
|
|
118
|
+
},
|
|
119
|
+
missing_token_account: {
|
|
120
|
+
message: "Token account not found",
|
|
121
|
+
action: "Your wallet may need to create a token account first. Try again or use a different wallet.",
|
|
122
|
+
technicalHint: "Associated token account does not exist"
|
|
123
|
+
},
|
|
124
|
+
invalid_token_program: {
|
|
125
|
+
message: "Invalid token program",
|
|
126
|
+
action: "Please try your payment again. If this continues, try using a different wallet.",
|
|
127
|
+
technicalHint: "Token program ID mismatch"
|
|
128
|
+
},
|
|
129
|
+
missing_memo: {
|
|
130
|
+
message: "Payment memo is required but was not included",
|
|
131
|
+
action: "Please try your payment again and ensure transaction details are approved in your wallet.",
|
|
132
|
+
technicalHint: "Required memo instruction missing"
|
|
133
|
+
},
|
|
134
|
+
invalid_memo: {
|
|
135
|
+
message: "Payment memo format is invalid",
|
|
136
|
+
action: "Please try your payment again.",
|
|
137
|
+
technicalHint: "Memo does not match expected format"
|
|
138
|
+
},
|
|
139
|
+
payment_already_used: {
|
|
140
|
+
message: "This payment has already been processed",
|
|
141
|
+
action: "Check your transaction history. If you need to make another payment, please start a new transaction.",
|
|
142
|
+
technicalHint: "Payment signature already recorded"
|
|
143
|
+
},
|
|
144
|
+
signature_reused: {
|
|
145
|
+
message: "Transaction signature has already been used",
|
|
146
|
+
action: "Please create a new payment transaction.",
|
|
147
|
+
technicalHint: "Duplicate signature detected"
|
|
148
|
+
},
|
|
149
|
+
quote_expired: {
|
|
150
|
+
message: "Payment quote has expired",
|
|
151
|
+
action: "Prices are updated frequently. Please refresh and try your payment again.",
|
|
152
|
+
technicalHint: "Quote timestamp expired"
|
|
153
|
+
},
|
|
154
|
+
// ===== VALIDATION ERRORS (400) =====
|
|
155
|
+
missing_field: {
|
|
156
|
+
message: "Required information is missing",
|
|
157
|
+
action: "Please check all required fields and try again.",
|
|
158
|
+
technicalHint: "Required field not provided"
|
|
159
|
+
},
|
|
160
|
+
invalid_field: {
|
|
161
|
+
message: "Some information is invalid",
|
|
162
|
+
action: "Please check your input and try again.",
|
|
163
|
+
technicalHint: "Field validation failed"
|
|
164
|
+
},
|
|
165
|
+
invalid_amount: {
|
|
166
|
+
message: "Payment amount is invalid",
|
|
167
|
+
action: "Please check the amount and try again.",
|
|
168
|
+
technicalHint: "Amount validation failed"
|
|
169
|
+
},
|
|
170
|
+
invalid_wallet: {
|
|
171
|
+
message: "Wallet address is invalid",
|
|
172
|
+
action: "Please reconnect your wallet and try again.",
|
|
173
|
+
technicalHint: "Wallet address validation failed"
|
|
174
|
+
},
|
|
175
|
+
invalid_resource: {
|
|
176
|
+
message: "Invalid item selection",
|
|
177
|
+
action: "Please refresh the page and try again.",
|
|
178
|
+
technicalHint: "Resource ID validation failed"
|
|
179
|
+
},
|
|
180
|
+
invalid_coupon: {
|
|
181
|
+
message: "Invalid coupon code",
|
|
182
|
+
action: "Please check the coupon code and try again.",
|
|
183
|
+
technicalHint: "Coupon code format invalid"
|
|
184
|
+
},
|
|
185
|
+
invalid_cart_item: {
|
|
186
|
+
message: "One or more cart items are invalid",
|
|
187
|
+
action: "Please review your cart and try again.",
|
|
188
|
+
technicalHint: "Cart item validation failed"
|
|
189
|
+
},
|
|
190
|
+
empty_cart: {
|
|
191
|
+
message: "Your cart is empty",
|
|
192
|
+
action: "Please add items to your cart before checking out.",
|
|
193
|
+
technicalHint: "Cart contains no items"
|
|
194
|
+
},
|
|
195
|
+
// ===== RESOURCE/STATE ERRORS (404) =====
|
|
196
|
+
resource_not_found: {
|
|
197
|
+
message: "Item not found",
|
|
198
|
+
action: "This item may no longer be available. Please refresh and try again.",
|
|
199
|
+
technicalHint: "Resource not found in database"
|
|
200
|
+
},
|
|
201
|
+
cart_not_found: {
|
|
202
|
+
message: "Shopping cart not found",
|
|
203
|
+
action: "Your cart may have expired. Please start a new order.",
|
|
204
|
+
technicalHint: "Cart ID not found"
|
|
205
|
+
},
|
|
206
|
+
refund_not_found: {
|
|
207
|
+
message: "Refund not found",
|
|
208
|
+
action: "Please check your refund reference number or contact support.",
|
|
209
|
+
technicalHint: "Refund ID not found"
|
|
210
|
+
},
|
|
211
|
+
product_not_found: {
|
|
212
|
+
message: "Product not available",
|
|
213
|
+
action: "This product may no longer be available. Please browse our current selection.",
|
|
214
|
+
technicalHint: "Product ID not found"
|
|
215
|
+
},
|
|
216
|
+
coupon_not_found: {
|
|
217
|
+
message: "Coupon code not found",
|
|
218
|
+
action: "Please check the coupon code or remove it to continue.",
|
|
219
|
+
technicalHint: "Coupon code not in database"
|
|
220
|
+
},
|
|
221
|
+
session_not_found: {
|
|
222
|
+
message: "Payment session expired",
|
|
223
|
+
action: "Please start a new payment.",
|
|
224
|
+
technicalHint: "Session ID not found or expired"
|
|
225
|
+
},
|
|
226
|
+
cart_already_paid: {
|
|
227
|
+
message: "This order has already been paid",
|
|
228
|
+
action: "Check your order history. If you need to make another purchase, please start a new order.",
|
|
229
|
+
technicalHint: "Cart marked as paid"
|
|
230
|
+
},
|
|
231
|
+
refund_already_processed: {
|
|
232
|
+
message: "This refund has already been processed",
|
|
233
|
+
action: "Check your transaction history or contact support for details.",
|
|
234
|
+
technicalHint: "Refund already completed"
|
|
235
|
+
},
|
|
236
|
+
// ===== COUPON-SPECIFIC ERRORS (409) =====
|
|
237
|
+
coupon_expired: {
|
|
238
|
+
message: "Coupon has expired",
|
|
239
|
+
action: "Please remove the coupon code or use a different code.",
|
|
240
|
+
technicalHint: "Coupon expiration date passed"
|
|
241
|
+
},
|
|
242
|
+
coupon_usage_limit_reached: {
|
|
243
|
+
message: "Coupon usage limit reached",
|
|
244
|
+
action: "This coupon has been fully redeemed. Please try a different code.",
|
|
245
|
+
technicalHint: "Coupon max uses exceeded"
|
|
246
|
+
},
|
|
247
|
+
coupon_not_applicable: {
|
|
248
|
+
message: "Coupon cannot be applied to this purchase",
|
|
249
|
+
action: "Please check the coupon terms or remove it to continue.",
|
|
250
|
+
technicalHint: "Coupon conditions not met"
|
|
251
|
+
},
|
|
252
|
+
coupon_wrong_payment_method: {
|
|
253
|
+
message: "Coupon not valid for this payment method",
|
|
254
|
+
action: "Try a different payment method or remove the coupon code.",
|
|
255
|
+
technicalHint: "Coupon restricted to specific payment methods"
|
|
256
|
+
},
|
|
257
|
+
// ===== EXTERNAL SERVICE ERRORS (502) =====
|
|
258
|
+
stripe_error: {
|
|
259
|
+
message: "Card payment service temporarily unavailable",
|
|
260
|
+
action: "Please try again in a moment, or use cryptocurrency payment instead.",
|
|
261
|
+
technicalHint: "Stripe API error"
|
|
262
|
+
},
|
|
263
|
+
rpc_error: {
|
|
264
|
+
message: "Blockchain network temporarily unavailable",
|
|
265
|
+
action: "Please try again in a moment, or use card payment instead.",
|
|
266
|
+
technicalHint: "Solana RPC error"
|
|
267
|
+
},
|
|
268
|
+
network_error: {
|
|
269
|
+
message: "Network connection issue",
|
|
270
|
+
action: "Please check your internet connection and try again.",
|
|
271
|
+
technicalHint: "Network request failed"
|
|
272
|
+
},
|
|
273
|
+
// ===== INTERNAL/SYSTEM ERRORS (500) =====
|
|
274
|
+
internal_error: {
|
|
275
|
+
message: "Something went wrong on our end",
|
|
276
|
+
action: "Please try again. If this continues, contact support.",
|
|
277
|
+
technicalHint: "Internal server error"
|
|
278
|
+
},
|
|
279
|
+
database_error: {
|
|
280
|
+
message: "Service temporarily unavailable",
|
|
281
|
+
action: "Please try again in a moment.",
|
|
282
|
+
technicalHint: "Database operation failed"
|
|
283
|
+
},
|
|
284
|
+
config_error: {
|
|
285
|
+
message: "Service configuration error",
|
|
286
|
+
action: "Please contact support for assistance.",
|
|
287
|
+
technicalHint: "Server misconfiguration"
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
function ne(e) {
|
|
291
|
+
return Xe[e] || {
|
|
292
|
+
message: "An unexpected error occurred",
|
|
293
|
+
action: "Please try again or contact support if this continues.",
|
|
294
|
+
technicalHint: `Unknown error code: ${e}`
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
const Ae = /* @__PURE__ */ new Map(), le = /* @__PURE__ */ new Map(), ue = /* @__PURE__ */ new Map(), xe = 200, ge = 2e3;
|
|
298
|
+
function Ke(e) {
|
|
299
|
+
const t = ue.get(e);
|
|
300
|
+
return t ? Date.now() < t ? !0 : (ue.delete(e), !1) : !1;
|
|
301
|
+
}
|
|
302
|
+
function Qe(e, t = xe) {
|
|
303
|
+
const n = Date.now() + t;
|
|
304
|
+
ue.set(e, n);
|
|
305
|
+
}
|
|
306
|
+
function Ze(e, t = ge) {
|
|
307
|
+
const n = Ae.get(e);
|
|
308
|
+
if (!n)
|
|
309
|
+
return !1;
|
|
310
|
+
const o = Date.now() - n;
|
|
311
|
+
return o < t ? (f().debug(`[Deduplication] Duplicate request blocked: ${e} (${o}ms ago)`), !0) : !1;
|
|
312
|
+
}
|
|
313
|
+
function Je(e) {
|
|
314
|
+
Ae.set(e, Date.now());
|
|
315
|
+
}
|
|
316
|
+
function et(e) {
|
|
317
|
+
return le.get(e) || null;
|
|
318
|
+
}
|
|
319
|
+
function tt(e, t) {
|
|
320
|
+
le.set(e, t);
|
|
321
|
+
const n = () => {
|
|
322
|
+
le.delete(e), Je(e);
|
|
323
|
+
};
|
|
324
|
+
return t.then(n, n), t;
|
|
325
|
+
}
|
|
326
|
+
async function nt(e, t, n = {}) {
|
|
327
|
+
const { windowMs: a = ge, throwOnDuplicate: o = !0 } = n, r = et(e);
|
|
328
|
+
if (r)
|
|
329
|
+
return f().debug(`[Deduplication] Reusing in-flight request: ${e}`), r;
|
|
330
|
+
if (Ze(e, a)) {
|
|
331
|
+
if (o)
|
|
332
|
+
throw new Error(`Duplicate request blocked: ${e}`);
|
|
333
|
+
return f().warn(`[Deduplication] Duplicate request blocked but not throwing: ${e}`), Promise.reject(new Error("Duplicate request"));
|
|
334
|
+
}
|
|
335
|
+
const l = t();
|
|
336
|
+
return tt(e, l);
|
|
337
|
+
}
|
|
338
|
+
function Le(e, t, n = {}) {
|
|
339
|
+
const { cooldownMs: a = xe, deduplicationWindowMs: o = ge } = n;
|
|
340
|
+
return async () => {
|
|
341
|
+
if (Ke(e)) {
|
|
342
|
+
f().debug(`[Deduplication] Button in cooldown: ${e}`);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
Qe(e, a);
|
|
346
|
+
try {
|
|
347
|
+
await nt(
|
|
348
|
+
e,
|
|
349
|
+
async () => {
|
|
350
|
+
const r = t();
|
|
351
|
+
r instanceof Promise && await r;
|
|
352
|
+
},
|
|
353
|
+
{ windowMs: o, throwOnDuplicate: !1 }
|
|
354
|
+
);
|
|
355
|
+
} catch (r) {
|
|
356
|
+
if (r instanceof Error && r.message.includes("Duplicate request"))
|
|
357
|
+
return;
|
|
358
|
+
throw r;
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
function je(e) {
|
|
363
|
+
return {
|
|
364
|
+
background: "none",
|
|
365
|
+
border: "none",
|
|
366
|
+
fontSize: "1.5rem",
|
|
367
|
+
cursor: "pointer",
|
|
368
|
+
color: e,
|
|
369
|
+
opacity: 0.6,
|
|
370
|
+
padding: "0.25rem",
|
|
371
|
+
lineHeight: 1
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
const $ = {
|
|
375
|
+
PAYMENT_START: "cedros:payment:start",
|
|
376
|
+
WALLET_CONNECT: "cedros:wallet:connect",
|
|
377
|
+
WALLET_CONNECTED: "cedros:wallet:connected",
|
|
378
|
+
WALLET_ERROR: "cedros:wallet:error",
|
|
379
|
+
PAYMENT_PROCESSING: "cedros:payment:processing",
|
|
380
|
+
PAYMENT_SUCCESS: "cedros:payment:success",
|
|
381
|
+
PAYMENT_ERROR: "cedros:payment:error"
|
|
382
|
+
};
|
|
383
|
+
function z(e, t) {
|
|
384
|
+
if (typeof window > "u")
|
|
385
|
+
return;
|
|
386
|
+
const n = new CustomEvent(e, {
|
|
387
|
+
detail: t,
|
|
388
|
+
bubbles: !0,
|
|
389
|
+
cancelable: !1
|
|
390
|
+
});
|
|
391
|
+
window.dispatchEvent(n);
|
|
392
|
+
}
|
|
393
|
+
function Me(e, t, n) {
|
|
394
|
+
z($.PAYMENT_START, {
|
|
395
|
+
timestamp: Date.now(),
|
|
396
|
+
method: e,
|
|
397
|
+
resource: t,
|
|
398
|
+
itemCount: n
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
function Se(e) {
|
|
402
|
+
z($.WALLET_CONNECT, {
|
|
403
|
+
timestamp: Date.now(),
|
|
404
|
+
wallet: e
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
function at(e, t) {
|
|
408
|
+
z($.WALLET_CONNECTED, {
|
|
409
|
+
timestamp: Date.now(),
|
|
410
|
+
wallet: e,
|
|
411
|
+
publicKey: t
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function ie(e, t) {
|
|
415
|
+
z($.WALLET_ERROR, {
|
|
416
|
+
timestamp: Date.now(),
|
|
417
|
+
wallet: t,
|
|
418
|
+
error: e
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
function de(e, t, n) {
|
|
422
|
+
z($.PAYMENT_PROCESSING, {
|
|
423
|
+
timestamp: Date.now(),
|
|
424
|
+
method: e,
|
|
425
|
+
resource: t,
|
|
426
|
+
itemCount: n
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
function He(e, t, n, a) {
|
|
430
|
+
z($.PAYMENT_SUCCESS, {
|
|
431
|
+
timestamp: Date.now(),
|
|
432
|
+
method: e,
|
|
433
|
+
transactionId: t,
|
|
434
|
+
resource: n,
|
|
435
|
+
itemCount: a
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
function ae(e, t, n, a) {
|
|
439
|
+
z($.PAYMENT_ERROR, {
|
|
440
|
+
timestamp: Date.now(),
|
|
441
|
+
method: e,
|
|
442
|
+
error: t,
|
|
443
|
+
resource: n,
|
|
444
|
+
itemCount: a
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
var pe = /* @__PURE__ */ ((e) => (e.INVALID_PAYMENT_PROOF = "invalid_payment_proof", e.INVALID_SIGNATURE = "invalid_signature", e.INVALID_TRANSACTION = "invalid_transaction", e.TRANSACTION_NOT_FOUND = "transaction_not_found", e.TRANSACTION_NOT_CONFIRMED = "transaction_not_confirmed", e.TRANSACTION_FAILED = "transaction_failed", e.TRANSACTION_EXPIRED = "transaction_expired", e.INVALID_RECIPIENT = "invalid_recipient", e.INVALID_SENDER = "invalid_sender", e.UNAUTHORIZED_REFUND_ISSUER = "unauthorized_refund_issuer", e.AMOUNT_BELOW_MINIMUM = "amount_below_minimum", e.AMOUNT_MISMATCH = "amount_mismatch", e.INSUFFICIENT_FUNDS_SOL = "insufficient_funds_sol", e.INSUFFICIENT_FUNDS_TOKEN = "insufficient_funds_token", e.INVALID_TOKEN_MINT = "invalid_token_mint", e.NOT_SPL_TRANSFER = "not_spl_transfer", e.MISSING_TOKEN_ACCOUNT = "missing_token_account", e.INVALID_TOKEN_PROGRAM = "invalid_token_program", e.MISSING_MEMO = "missing_memo", e.INVALID_MEMO = "invalid_memo", e.PAYMENT_ALREADY_USED = "payment_already_used", e.SIGNATURE_REUSED = "signature_reused", e.QUOTE_EXPIRED = "quote_expired", e.MISSING_FIELD = "missing_field", e.INVALID_FIELD = "invalid_field", e.INVALID_AMOUNT = "invalid_amount", e.INVALID_WALLET = "invalid_wallet", e.INVALID_RESOURCE = "invalid_resource", e.INVALID_COUPON = "invalid_coupon", e.INVALID_CART_ITEM = "invalid_cart_item", e.EMPTY_CART = "empty_cart", e.RESOURCE_NOT_FOUND = "resource_not_found", e.CART_NOT_FOUND = "cart_not_found", e.REFUND_NOT_FOUND = "refund_not_found", e.PRODUCT_NOT_FOUND = "product_not_found", e.COUPON_NOT_FOUND = "coupon_not_found", e.SESSION_NOT_FOUND = "session_not_found", e.CART_ALREADY_PAID = "cart_already_paid", e.REFUND_ALREADY_PROCESSED = "refund_already_processed", e.COUPON_EXPIRED = "coupon_expired", e.COUPON_USAGE_LIMIT_REACHED = "coupon_usage_limit_reached", e.COUPON_NOT_APPLICABLE = "coupon_not_applicable", e.COUPON_WRONG_PAYMENT_METHOD = "coupon_wrong_payment_method", e.STRIPE_ERROR = "stripe_error", e.RPC_ERROR = "rpc_error", e.NETWORK_ERROR = "network_error", e.INTERNAL_ERROR = "internal_error", e.DATABASE_ERROR = "database_error", e.CONFIG_ERROR = "config_error", e))(pe || {});
|
|
448
|
+
class M extends Error {
|
|
449
|
+
/** Machine-readable error code enum */
|
|
450
|
+
code;
|
|
451
|
+
/** Whether this error can be safely retried */
|
|
452
|
+
retryable;
|
|
453
|
+
/** Additional error context */
|
|
454
|
+
details;
|
|
455
|
+
/** HTTP status code (if from API response) */
|
|
456
|
+
httpStatus;
|
|
457
|
+
constructor(t, n, a = !1, o, r) {
|
|
458
|
+
super(n), this.name = "PaymentError", this.code = t, this.retryable = a, this.details = o, this.httpStatus = r, Object.setPrototypeOf(this, M.prototype);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Check if this error is retryable
|
|
462
|
+
*/
|
|
463
|
+
canRetry() {
|
|
464
|
+
return this.retryable;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Check if this is a specific error code
|
|
468
|
+
*/
|
|
469
|
+
is(t) {
|
|
470
|
+
return this.code === t;
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Check if this error is in a specific category
|
|
474
|
+
*/
|
|
475
|
+
isInCategory(t) {
|
|
476
|
+
return t.includes(this.code);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Get a user-friendly error message
|
|
480
|
+
* Uses structured error messages with actionable guidance
|
|
481
|
+
*/
|
|
482
|
+
getUserMessage() {
|
|
483
|
+
const t = this.getErrorInfo();
|
|
484
|
+
return t.action ? `${t.message} ${t.action}` : t.message;
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Get short error message without action guidance
|
|
488
|
+
*/
|
|
489
|
+
getShortMessage() {
|
|
490
|
+
return this.getErrorInfo().message;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Get actionable guidance for this error
|
|
494
|
+
*/
|
|
495
|
+
getAction() {
|
|
496
|
+
return this.getErrorInfo().action;
|
|
497
|
+
}
|
|
498
|
+
/**
|
|
499
|
+
* Get error info from error messages map
|
|
500
|
+
* @private
|
|
501
|
+
*/
|
|
502
|
+
getErrorInfo() {
|
|
503
|
+
return ne(this.code);
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Create PaymentError from API error response
|
|
507
|
+
*/
|
|
508
|
+
static fromErrorResponse(t, n) {
|
|
509
|
+
return new M(
|
|
510
|
+
t.error.code,
|
|
511
|
+
t.error.message,
|
|
512
|
+
t.error.retryable,
|
|
513
|
+
t.error.details,
|
|
514
|
+
n
|
|
515
|
+
);
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Create PaymentError from unknown error
|
|
519
|
+
* Useful for catch blocks where error type is unknown
|
|
520
|
+
*/
|
|
521
|
+
static fromUnknown(t) {
|
|
522
|
+
return t instanceof M ? t : t instanceof Error ? new M(
|
|
523
|
+
"internal_error",
|
|
524
|
+
t.message,
|
|
525
|
+
!1
|
|
526
|
+
) : new M(
|
|
527
|
+
"internal_error",
|
|
528
|
+
String(t),
|
|
529
|
+
!1
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
const It = {
|
|
534
|
+
/** Insufficient funds errors requiring user to add funds */
|
|
535
|
+
INSUFFICIENT_FUNDS: [
|
|
536
|
+
"insufficient_funds_sol",
|
|
537
|
+
"insufficient_funds_token"
|
|
538
|
+
/* INSUFFICIENT_FUNDS_TOKEN */
|
|
539
|
+
],
|
|
540
|
+
/** Transaction state errors that may resolve with time */
|
|
541
|
+
TRANSACTION_PENDING: [
|
|
542
|
+
"transaction_not_confirmed",
|
|
543
|
+
"transaction_not_found"
|
|
544
|
+
/* TRANSACTION_NOT_FOUND */
|
|
545
|
+
],
|
|
546
|
+
/** Validation errors requiring input correction */
|
|
547
|
+
VALIDATION: [
|
|
548
|
+
"missing_field",
|
|
549
|
+
"invalid_field",
|
|
550
|
+
"invalid_amount",
|
|
551
|
+
"invalid_wallet",
|
|
552
|
+
"invalid_resource",
|
|
553
|
+
"invalid_cart_item",
|
|
554
|
+
"empty_cart"
|
|
555
|
+
/* EMPTY_CART */
|
|
556
|
+
],
|
|
557
|
+
/** Coupon-related errors */
|
|
558
|
+
COUPON: [
|
|
559
|
+
"invalid_coupon",
|
|
560
|
+
"coupon_not_found",
|
|
561
|
+
"coupon_expired",
|
|
562
|
+
"coupon_usage_limit_reached",
|
|
563
|
+
"coupon_not_applicable",
|
|
564
|
+
"coupon_wrong_payment_method"
|
|
565
|
+
/* COUPON_WRONG_PAYMENT_METHOD */
|
|
566
|
+
],
|
|
567
|
+
/** Retryable errors (temporary failures) */
|
|
568
|
+
RETRYABLE: [
|
|
569
|
+
"transaction_not_confirmed",
|
|
570
|
+
"rpc_error",
|
|
571
|
+
"network_error",
|
|
572
|
+
"stripe_error"
|
|
573
|
+
/* STRIPE_ERROR */
|
|
574
|
+
],
|
|
575
|
+
/** Resource not found errors */
|
|
576
|
+
NOT_FOUND: [
|
|
577
|
+
"resource_not_found",
|
|
578
|
+
"cart_not_found",
|
|
579
|
+
"refund_not_found",
|
|
580
|
+
"product_not_found",
|
|
581
|
+
"coupon_not_found",
|
|
582
|
+
"session_not_found"
|
|
583
|
+
/* SESSION_NOT_FOUND */
|
|
584
|
+
]
|
|
585
|
+
};
|
|
586
|
+
async function Tt(e) {
|
|
587
|
+
const t = e.status;
|
|
588
|
+
try {
|
|
589
|
+
const n = await e.json();
|
|
590
|
+
if (n.error && typeof n.error.code == "string") {
|
|
591
|
+
const a = n;
|
|
592
|
+
return M.fromErrorResponse(a, t);
|
|
593
|
+
}
|
|
594
|
+
return new M(
|
|
595
|
+
pe.INTERNAL_ERROR,
|
|
596
|
+
n.error || n.message || "An unknown error occurred",
|
|
597
|
+
!1,
|
|
598
|
+
void 0,
|
|
599
|
+
t
|
|
600
|
+
);
|
|
601
|
+
} catch {
|
|
602
|
+
return new M(
|
|
603
|
+
pe.INTERNAL_ERROR,
|
|
604
|
+
e.statusText || "Request failed",
|
|
605
|
+
!1,
|
|
606
|
+
void 0,
|
|
607
|
+
t
|
|
608
|
+
);
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
function Rt(e) {
|
|
612
|
+
return e instanceof M && e.canRetry();
|
|
613
|
+
}
|
|
614
|
+
function Nt(e) {
|
|
615
|
+
return e instanceof M ? e.getUserMessage() : e instanceof Error ? e.message : String(e);
|
|
616
|
+
}
|
|
617
|
+
function ot() {
|
|
618
|
+
const { stripeManager: e } = me(), [t, n] = F({
|
|
619
|
+
status: "idle",
|
|
620
|
+
error: null,
|
|
621
|
+
transactionId: null
|
|
622
|
+
}), a = A(
|
|
623
|
+
async (l, p, S, g, _, w) => {
|
|
624
|
+
n({
|
|
625
|
+
status: "loading",
|
|
626
|
+
error: null,
|
|
627
|
+
transactionId: null
|
|
628
|
+
});
|
|
629
|
+
const y = {
|
|
630
|
+
resource: l,
|
|
631
|
+
successUrl: p,
|
|
632
|
+
cancelUrl: S,
|
|
633
|
+
metadata: g,
|
|
634
|
+
customerEmail: _,
|
|
635
|
+
couponCode: w
|
|
636
|
+
}, b = await e.processPayment(y);
|
|
637
|
+
return n({
|
|
638
|
+
status: b.success ? "success" : "error",
|
|
639
|
+
error: b.success ? null : b.error || "Payment failed",
|
|
640
|
+
transactionId: b.success && b.transactionId || null
|
|
641
|
+
}), b;
|
|
642
|
+
},
|
|
643
|
+
[e]
|
|
644
|
+
), o = A(
|
|
645
|
+
async (l, p, S, g, _, w) => {
|
|
646
|
+
n({
|
|
647
|
+
status: "loading",
|
|
648
|
+
error: null,
|
|
649
|
+
transactionId: null
|
|
650
|
+
});
|
|
651
|
+
const y = Oe(l), b = await e.processCartCheckout({
|
|
652
|
+
items: y,
|
|
653
|
+
successUrl: p,
|
|
654
|
+
cancelUrl: S,
|
|
655
|
+
metadata: g,
|
|
656
|
+
customerEmail: _,
|
|
657
|
+
couponCode: w
|
|
658
|
+
});
|
|
659
|
+
return n({
|
|
660
|
+
status: b.success ? "success" : "error",
|
|
661
|
+
error: b.success ? null : b.error || "Cart checkout failed",
|
|
662
|
+
transactionId: b.success && b.transactionId || null
|
|
663
|
+
}), b;
|
|
664
|
+
},
|
|
665
|
+
[e]
|
|
666
|
+
), r = A(() => {
|
|
667
|
+
n({
|
|
668
|
+
status: "idle",
|
|
669
|
+
error: null,
|
|
670
|
+
transactionId: null
|
|
671
|
+
});
|
|
672
|
+
}, []);
|
|
673
|
+
return {
|
|
674
|
+
...t,
|
|
675
|
+
processPayment: a,
|
|
676
|
+
processCartCheckout: o,
|
|
677
|
+
reset: r
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
function Fe(e, t) {
|
|
681
|
+
const n = Ve(t), a = e || (t?.length === 1 ? t[0].resource : "");
|
|
682
|
+
return {
|
|
683
|
+
isCartMode: n,
|
|
684
|
+
effectiveResource: a
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
const rt = (e, t, n) => {
|
|
688
|
+
const a = e[t];
|
|
689
|
+
return a ? typeof a == "function" ? a() : Promise.resolve(a) : new Promise((o, r) => {
|
|
690
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(r.bind(null, /* @__PURE__ */ new Error("Unknown variable dynamic import: " + t + (t.split("/").length !== n ? ". Note that variables only represent file names one level deep." : ""))));
|
|
691
|
+
});
|
|
692
|
+
}, ce = /* @__PURE__ */ new Map();
|
|
693
|
+
let te = null;
|
|
694
|
+
async function Pe(e) {
|
|
695
|
+
if (ce.has(e))
|
|
696
|
+
return ce.get(e);
|
|
697
|
+
try {
|
|
698
|
+
const t = await rt(/* @__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-CSsJl3nf.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") }), `./translations/${e}.json`, 3), n = t.default || t;
|
|
699
|
+
return ce.set(e, n), n;
|
|
700
|
+
} catch {
|
|
701
|
+
return null;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
async function kt() {
|
|
705
|
+
if (te)
|
|
706
|
+
return te;
|
|
707
|
+
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-CSsJl3nf.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 = [];
|
|
708
|
+
for (const n in e) {
|
|
709
|
+
const a = n.match(/\.\/translations\/([a-z]{2,3}(?:-[A-Z]{2})?)\.json$/);
|
|
710
|
+
a && t.push(a[1]);
|
|
711
|
+
}
|
|
712
|
+
return te = t.length > 0 ? t : ["en"], te;
|
|
713
|
+
}
|
|
714
|
+
function st() {
|
|
715
|
+
return typeof navigator > "u" ? "en" : (navigator.language || navigator.userLanguage || "en").split("-")[0].toLowerCase();
|
|
716
|
+
}
|
|
717
|
+
async function it(e) {
|
|
718
|
+
let t = await Pe(e);
|
|
719
|
+
if (t || (t = await Pe("en"), t))
|
|
720
|
+
return t;
|
|
721
|
+
throw new Error("Critical: No translation files found, not even en.json");
|
|
722
|
+
}
|
|
723
|
+
function ct(e) {
|
|
724
|
+
return (t, n) => {
|
|
725
|
+
const a = t.split(".");
|
|
726
|
+
let o = e;
|
|
727
|
+
for (const r of a)
|
|
728
|
+
if (o && typeof o == "object" && r in o)
|
|
729
|
+
o = o[r];
|
|
730
|
+
else
|
|
731
|
+
return t;
|
|
732
|
+
return typeof o != "string" ? t : n ? Object.entries(n).reduce(
|
|
733
|
+
(r, [l, p]) => r.replace(new RegExp(`\\{${l}\\}`, "g"), p),
|
|
734
|
+
o
|
|
735
|
+
) : o;
|
|
736
|
+
};
|
|
737
|
+
}
|
|
738
|
+
function Ct(e, t, n = !0) {
|
|
739
|
+
const a = t.errors[e];
|
|
740
|
+
if (!a) {
|
|
741
|
+
const o = ne(e);
|
|
742
|
+
return n && o.action ? `${o.message} ${o.action}` : o.message;
|
|
743
|
+
}
|
|
744
|
+
return n && a.action ? `${a.message} ${a.action}` : a.message;
|
|
745
|
+
}
|
|
746
|
+
function ye(e) {
|
|
747
|
+
const [t, n] = F(null), [a, o] = F(!0), r = W(() => e || st(), [e]);
|
|
748
|
+
return U(() => {
|
|
749
|
+
let p = !1;
|
|
750
|
+
return (async () => {
|
|
751
|
+
o(!0);
|
|
752
|
+
try {
|
|
753
|
+
const g = await it(r);
|
|
754
|
+
p || (n(g), o(!1));
|
|
755
|
+
} catch (g) {
|
|
756
|
+
console.error("[CedrosPay] Failed to load translations:", g), p || o(!1);
|
|
757
|
+
}
|
|
758
|
+
})(), () => {
|
|
759
|
+
p = !0;
|
|
760
|
+
};
|
|
761
|
+
}, [r]), {
|
|
762
|
+
t: W(() => t ? ct(t) : (p) => p, [t]),
|
|
763
|
+
locale: r,
|
|
764
|
+
isLoading: a,
|
|
765
|
+
translations: t
|
|
766
|
+
};
|
|
767
|
+
}
|
|
768
|
+
function St(e, t = !0) {
|
|
769
|
+
const { translations: n } = ye();
|
|
770
|
+
if (!n) {
|
|
771
|
+
const o = ne(e);
|
|
772
|
+
return t && o.action ? `${o.message} ${o.action}` : o.message;
|
|
773
|
+
}
|
|
774
|
+
const a = n.errors[e];
|
|
775
|
+
if (!a) {
|
|
776
|
+
const o = ne(e);
|
|
777
|
+
return t && o.action ? `${o.message} ${o.action}` : o.message;
|
|
778
|
+
}
|
|
779
|
+
return t && a.action ? `${a.message} ${a.action}` : a.message;
|
|
780
|
+
}
|
|
781
|
+
function lt({
|
|
782
|
+
resource: e,
|
|
783
|
+
items: t,
|
|
784
|
+
successUrl: n,
|
|
785
|
+
cancelUrl: a,
|
|
786
|
+
metadata: o,
|
|
787
|
+
customerEmail: r,
|
|
788
|
+
couponCode: l,
|
|
789
|
+
label: p,
|
|
790
|
+
disabled: S = !1,
|
|
791
|
+
onAttempt: g,
|
|
792
|
+
onSuccess: _,
|
|
793
|
+
onError: w,
|
|
794
|
+
className: y = ""
|
|
795
|
+
}) {
|
|
796
|
+
const { status: b, error: D, transactionId: H, processPayment: m, processCartCheckout: h } = ot(), i = fe(), { isCartMode: v, effectiveResource: c } = Fe(e, t), { t: u, translations: N } = ye(), I = p || u("ui.pay_with_card"), k = i.unstyled ? y : `${i.className} cedros-theme__stripe-button ${y}`.trim(), d = D && typeof D != "string" ? D?.code ?? null : null, O = D ? typeof D == "string" ? D : ((L) => {
|
|
797
|
+
if (!L || !N) return "";
|
|
798
|
+
const R = N.errors[L];
|
|
799
|
+
return R ? R.action ? `${R.message} ${R.action}` : R.message : "";
|
|
800
|
+
})(d) : null, P = A(async () => {
|
|
801
|
+
f().debug("[StripeButton] executePayment with couponCode:", l);
|
|
802
|
+
const L = v && t ? K(t) : void 0;
|
|
803
|
+
if (Me("stripe", c, L), g && g("stripe"), !v && !c) {
|
|
804
|
+
const Y = "Invalid payment configuration: missing resource or items";
|
|
805
|
+
f().error("[StripeButton]", Y), ae("stripe", Y, c, L), w && w(Y);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
let R;
|
|
809
|
+
de("stripe", c, L), v && t ? (f().debug("[StripeButton] Processing cart checkout with coupon:", l), R = await h(
|
|
810
|
+
t,
|
|
811
|
+
n,
|
|
812
|
+
a,
|
|
813
|
+
o,
|
|
814
|
+
r,
|
|
815
|
+
l
|
|
816
|
+
)) : c && (f().debug("[StripeButton] Processing single payment with coupon:", l), R = await m(
|
|
817
|
+
c,
|
|
818
|
+
n,
|
|
819
|
+
a,
|
|
820
|
+
o,
|
|
821
|
+
r,
|
|
822
|
+
l
|
|
823
|
+
)), R && R.success && R.transactionId ? (He("stripe", R.transactionId, c, L), _ && _(R.transactionId)) : R && !R.success && R.error && (ae("stripe", R.error, c, L), w && w(R.error));
|
|
824
|
+
}, [l, v, c, t, n, a, o, r, h, m, g, _, w]), B = W(() => v && t ? `stripe-cart-${t.map((L) => L.resource).join("-")}` : `stripe-${c || "unknown"}`, [v, t, c]), Q = W(
|
|
825
|
+
() => Le(B, P),
|
|
826
|
+
[B, P]
|
|
827
|
+
), Z = b === "loading", oe = S || Z;
|
|
828
|
+
return /* @__PURE__ */ E("div", { className: k, style: i.unstyled ? {} : i.style, children: [
|
|
829
|
+
/* @__PURE__ */ C(
|
|
830
|
+
"button",
|
|
831
|
+
{
|
|
832
|
+
onClick: Q,
|
|
833
|
+
disabled: oe,
|
|
834
|
+
className: i.unstyled ? y : "cedros-theme__button cedros-theme__stripe",
|
|
835
|
+
type: "button",
|
|
836
|
+
children: Z ? u("ui.processing") : I
|
|
837
|
+
}
|
|
838
|
+
),
|
|
839
|
+
O && /* @__PURE__ */ C("div", { className: i.unstyled ? "" : "cedros-theme__error", children: O }),
|
|
840
|
+
H && /* @__PURE__ */ C("div", { className: i.unstyled ? "" : "cedros-theme__success", children: u("ui.payment_successful") })
|
|
841
|
+
] });
|
|
842
|
+
}
|
|
843
|
+
function ut() {
|
|
844
|
+
const { x402Manager: e, walletManager: t } = me(), { publicKey: n, signTransaction: a } = De(), [o, r] = F({
|
|
845
|
+
status: "idle",
|
|
846
|
+
error: null,
|
|
847
|
+
transactionId: null
|
|
848
|
+
}), [l, p] = F(null), [S, g] = F(null), _ = A(() => {
|
|
849
|
+
if (!n) {
|
|
850
|
+
const m = "Wallet not connected";
|
|
851
|
+
return r({ status: "error", error: m, transactionId: null }), { valid: !1, error: m };
|
|
852
|
+
}
|
|
853
|
+
if (!a) {
|
|
854
|
+
const m = "Wallet does not support signing";
|
|
855
|
+
return r({ status: "error", error: m, transactionId: null }), { valid: !1, error: m };
|
|
856
|
+
}
|
|
857
|
+
return { valid: !0 };
|
|
858
|
+
}, [n, a]), w = A(
|
|
859
|
+
async (m) => {
|
|
860
|
+
try {
|
|
861
|
+
r((i) => ({ ...i, status: "loading" }));
|
|
862
|
+
const h = await e.requestQuote({ resource: m });
|
|
863
|
+
if (!e.validateRequirement(h))
|
|
864
|
+
throw new Error("Invalid requirement received from server");
|
|
865
|
+
return p(h), r((i) => ({ ...i, status: "idle" })), h;
|
|
866
|
+
} catch (h) {
|
|
867
|
+
const i = se(h, "Failed to fetch requirement");
|
|
868
|
+
throw r({
|
|
869
|
+
status: "error",
|
|
870
|
+
error: i,
|
|
871
|
+
transactionId: null
|
|
872
|
+
}), h;
|
|
873
|
+
}
|
|
874
|
+
},
|
|
875
|
+
[e]
|
|
876
|
+
), y = A(
|
|
877
|
+
async (m, h, i, v, c = "regular") => {
|
|
878
|
+
if (!!m.extra?.feePayer) {
|
|
879
|
+
console.log("⚡ [useX402Payment] GASLESS FLOW - Backend pays fees"), console.log("🔨 [useX402Payment] Requesting backend to build gasless transaction");
|
|
880
|
+
const { transaction: N, blockhash: I } = await e.buildGaslessTransaction({
|
|
881
|
+
resourceId: h,
|
|
882
|
+
userWallet: n.toString(),
|
|
883
|
+
feePayer: m.extra.feePayer,
|
|
884
|
+
couponCode: i
|
|
885
|
+
});
|
|
886
|
+
console.log("📦 [useX402Payment] Deserializing transaction from backend");
|
|
887
|
+
const k = t.deserializeTransaction(N);
|
|
888
|
+
console.log("✍️ [useX402Payment] Requesting wallet to partially sign (transfer authority only)");
|
|
889
|
+
const d = await t.partiallySignTransaction({
|
|
890
|
+
transaction: k,
|
|
891
|
+
signTransaction: a,
|
|
892
|
+
blockhash: I
|
|
893
|
+
});
|
|
894
|
+
console.log("📤 [useX402Payment] Submitting partially-signed transaction to backend");
|
|
895
|
+
const x = await e.submitGaslessTransaction({
|
|
896
|
+
resource: h,
|
|
897
|
+
partialTx: d,
|
|
898
|
+
couponCode: i,
|
|
899
|
+
metadata: v,
|
|
900
|
+
resourceType: c,
|
|
901
|
+
requirement: m
|
|
902
|
+
});
|
|
903
|
+
return x.success && x.settlement && g(x.settlement), x;
|
|
904
|
+
} else {
|
|
905
|
+
const N = await t.buildTransaction({
|
|
906
|
+
requirement: m,
|
|
907
|
+
payerPublicKey: n
|
|
908
|
+
}), I = await t.signTransaction({
|
|
909
|
+
transaction: N,
|
|
910
|
+
signTransaction: a
|
|
911
|
+
}), k = t.buildPaymentPayload({
|
|
912
|
+
requirement: m,
|
|
913
|
+
signedTx: I,
|
|
914
|
+
payerPublicKey: n
|
|
915
|
+
}), d = await e.submitPayment({
|
|
916
|
+
resource: h,
|
|
917
|
+
payload: k,
|
|
918
|
+
couponCode: i,
|
|
919
|
+
metadata: v,
|
|
920
|
+
resourceType: c
|
|
921
|
+
});
|
|
922
|
+
return d.success && d.settlement && g(d.settlement), d;
|
|
923
|
+
}
|
|
924
|
+
},
|
|
925
|
+
[n, a, e, t]
|
|
926
|
+
), b = A(
|
|
927
|
+
async (m, h, i) => {
|
|
928
|
+
const v = _();
|
|
929
|
+
if (!v.valid)
|
|
930
|
+
return { success: !1, error: v.error };
|
|
931
|
+
r({
|
|
932
|
+
status: "loading",
|
|
933
|
+
error: null,
|
|
934
|
+
transactionId: null
|
|
935
|
+
});
|
|
936
|
+
try {
|
|
937
|
+
console.log("🔍 [useX402Payment] Fetching fresh quote for resource:", m);
|
|
938
|
+
const c = await e.requestQuote({ resource: m, couponCode: h });
|
|
939
|
+
console.log("✅ [useX402Payment] Got quote:", { payTo: c.payTo, amount: c.maxAmountRequired }), p(c), console.log("⚙️ [useX402Payment] Executing payment flow with fresh requirement");
|
|
940
|
+
const u = await y(c, m, h, i, "regular");
|
|
941
|
+
return u.success ? r({
|
|
942
|
+
status: "success",
|
|
943
|
+
error: null,
|
|
944
|
+
transactionId: u.transactionId || "payment-success"
|
|
945
|
+
}) : r({
|
|
946
|
+
status: "error",
|
|
947
|
+
error: u.error || "Payment failed",
|
|
948
|
+
transactionId: null
|
|
949
|
+
}), u;
|
|
950
|
+
} catch (c) {
|
|
951
|
+
const u = se(c, "Payment failed");
|
|
952
|
+
return r({
|
|
953
|
+
status: "error",
|
|
954
|
+
error: u,
|
|
955
|
+
transactionId: null
|
|
956
|
+
}), { success: !1, error: u };
|
|
957
|
+
}
|
|
958
|
+
},
|
|
959
|
+
[_, e, y]
|
|
960
|
+
), D = A(
|
|
961
|
+
async (m, h, i) => {
|
|
962
|
+
const v = _();
|
|
963
|
+
if (!v.valid)
|
|
964
|
+
return { success: !1, error: v.error };
|
|
965
|
+
r({
|
|
966
|
+
status: "loading",
|
|
967
|
+
error: null,
|
|
968
|
+
transactionId: null
|
|
969
|
+
});
|
|
970
|
+
try {
|
|
971
|
+
const c = Oe(m), u = await e.requestCartQuote({
|
|
972
|
+
items: c,
|
|
973
|
+
metadata: h,
|
|
974
|
+
couponCode: i
|
|
975
|
+
}), N = u.cartId, I = u.quote;
|
|
976
|
+
if (!e.validateRequirement(I))
|
|
977
|
+
throw new Error("Invalid cart quote received from server");
|
|
978
|
+
p(I);
|
|
979
|
+
const k = await y(I, N, i, h, "cart");
|
|
980
|
+
return k.success ? r({
|
|
981
|
+
status: "success",
|
|
982
|
+
error: null,
|
|
983
|
+
transactionId: k.transactionId || "cart-payment-success"
|
|
984
|
+
}) : r({
|
|
985
|
+
status: "error",
|
|
986
|
+
error: k.error || "Cart payment failed",
|
|
987
|
+
transactionId: null
|
|
988
|
+
}), k;
|
|
989
|
+
} catch (c) {
|
|
990
|
+
const u = se(c, "Cart payment failed");
|
|
991
|
+
return r({
|
|
992
|
+
status: "error",
|
|
993
|
+
error: u,
|
|
994
|
+
transactionId: null
|
|
995
|
+
}), { success: !1, error: u };
|
|
996
|
+
}
|
|
997
|
+
},
|
|
998
|
+
[_, e, y]
|
|
999
|
+
), H = A(() => {
|
|
1000
|
+
r({
|
|
1001
|
+
status: "idle",
|
|
1002
|
+
error: null,
|
|
1003
|
+
transactionId: null
|
|
1004
|
+
}), p(null), g(null);
|
|
1005
|
+
}, []);
|
|
1006
|
+
return {
|
|
1007
|
+
...o,
|
|
1008
|
+
requirement: l,
|
|
1009
|
+
settlement: S,
|
|
1010
|
+
fetchQuote: w,
|
|
1011
|
+
processPayment: b,
|
|
1012
|
+
processCartPayment: D,
|
|
1013
|
+
reset: H
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
function dt({
|
|
1017
|
+
resource: e,
|
|
1018
|
+
items: t,
|
|
1019
|
+
label: n,
|
|
1020
|
+
disabled: a = !1,
|
|
1021
|
+
onAttempt: o,
|
|
1022
|
+
onSuccess: r,
|
|
1023
|
+
onError: l,
|
|
1024
|
+
className: p = "",
|
|
1025
|
+
testPageUrl: S,
|
|
1026
|
+
hideMessages: g = !1,
|
|
1027
|
+
metadata: _,
|
|
1028
|
+
couponCode: w
|
|
1029
|
+
}) {
|
|
1030
|
+
const { connected: y, connecting: b, connect: D, disconnect: H, select: m, wallets: h, wallet: i, publicKey: v } = De(), { status: c, error: u, transactionId: N, processPayment: I, processCartPayment: k } = ut(), d = fe(), { solanaError: x } = me(), { isCartMode: O, effectiveResource: P } = Fe(e, t), { t: B, translations: Q } = ye(), Z = n || B("ui.pay_with_crypto"), oe = u && typeof u != "string" ? u?.code ?? null : null, L = x && typeof x != "string" ? x?.code ?? null : null, R = (s) => {
|
|
1031
|
+
if (!s || !Q) return "";
|
|
1032
|
+
const T = Q.errors[s];
|
|
1033
|
+
return T ? T.action ? `${T.message} ${T.action}` : T.message : "";
|
|
1034
|
+
}, Y = u ? typeof u == "string" ? u : R(oe) : null, he = x ? typeof x == "string" ? x : R(L) : null, _e = ke(I), we = ke(k);
|
|
1035
|
+
U(() => {
|
|
1036
|
+
_e.current = I, we.current = k;
|
|
1037
|
+
}, [I, k]);
|
|
1038
|
+
const Be = W(
|
|
1039
|
+
() => h.map((s) => `${s.adapter.name}-${s.readyState}`).join(","),
|
|
1040
|
+
[h]
|
|
1041
|
+
), J = W(
|
|
1042
|
+
() => h.filter(
|
|
1043
|
+
({ readyState: s }) => s === Ce.Installed || s === Ce.Loadable
|
|
1044
|
+
),
|
|
1045
|
+
// walletStateKey is derived from availableWallets, so we only need availableWallets as dependency
|
|
1046
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1047
|
+
[Be]
|
|
1048
|
+
);
|
|
1049
|
+
U(() => {
|
|
1050
|
+
if (c === "success" && N) {
|
|
1051
|
+
const s = O && t ? K(t) : void 0;
|
|
1052
|
+
He("crypto", N, P, s), r && r(N);
|
|
1053
|
+
}
|
|
1054
|
+
}, [c, N, r, O, t, P]), U(() => {
|
|
1055
|
+
if (c === "error" && u) {
|
|
1056
|
+
const s = O && t ? K(t) : void 0;
|
|
1057
|
+
ae("crypto", u, P, s), l && l(u);
|
|
1058
|
+
}
|
|
1059
|
+
}, [c, u, l, O, t, P]);
|
|
1060
|
+
const be = typeof window < "u" && window.top !== window.self, [ve, G] = F(!1), [Ie, re] = F(!1), [V, q] = F(null), X = x;
|
|
1061
|
+
U(() => {
|
|
1062
|
+
let s = !1;
|
|
1063
|
+
return s || (async () => {
|
|
1064
|
+
if (Ie && i && !y && !b) {
|
|
1065
|
+
f().debug("[CryptoButton] Wallet detected, attempting auto-connect:", i.adapter.name), re(!1), Se(i.adapter.name);
|
|
1066
|
+
try {
|
|
1067
|
+
await D(), s || f().debug("[CryptoButton] Auto-connect successful");
|
|
1068
|
+
} catch (j) {
|
|
1069
|
+
if (!s) {
|
|
1070
|
+
f().error("[CryptoButton] Auto-connect failed:", j);
|
|
1071
|
+
const ee = j instanceof Error ? j.message : "Failed to connect wallet";
|
|
1072
|
+
ie(ee, i.adapter.name), q(null);
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
})(), () => {
|
|
1077
|
+
s = !0;
|
|
1078
|
+
};
|
|
1079
|
+
}, [i, Ie, y, b, D]), U(() => {
|
|
1080
|
+
if (f().debug("[CryptoButton] Payment useEffect triggered", {
|
|
1081
|
+
connected: y,
|
|
1082
|
+
hasPendingPayment: !!V,
|
|
1083
|
+
hasPublicKey: !!v,
|
|
1084
|
+
pendingPaymentType: V?.type
|
|
1085
|
+
}), y && V && v && i) {
|
|
1086
|
+
at(i.adapter.name, v.toString()), f().debug("[CryptoButton] All conditions met! Processing pending payment:", V);
|
|
1087
|
+
const s = V;
|
|
1088
|
+
q(null), G(!1);
|
|
1089
|
+
const T = s.type === "cart" && s.items ? K(s.items) : void 0;
|
|
1090
|
+
de("crypto", s.resource, T), s.type === "cart" && s.items ? (f().debug("[CryptoButton] Auto-processing cart payment"), we.current(s.items, s.metadata, s.couponCode)) : s.type === "single" && s.resource && (f().debug("[CryptoButton] Auto-processing single payment"), _e.current(s.resource, s.couponCode, s.metadata));
|
|
1091
|
+
}
|
|
1092
|
+
}, [y, V, v, i]);
|
|
1093
|
+
const Te = A(async () => {
|
|
1094
|
+
f().debug("[CryptoButton] executePaymentFlow called", {
|
|
1095
|
+
connected: y,
|
|
1096
|
+
wallet: i?.adapter.name,
|
|
1097
|
+
couponCode: w,
|
|
1098
|
+
isCartMode: O,
|
|
1099
|
+
hasItems: !!t,
|
|
1100
|
+
effectiveResource: P
|
|
1101
|
+
});
|
|
1102
|
+
const s = O && t ? K(t) : void 0;
|
|
1103
|
+
if (Me("crypto", P, s), o && o("crypto"), X) {
|
|
1104
|
+
f().error("[CryptoButton] Solana dependencies missing:", X), ae("crypto", X, P, s), l && l(X);
|
|
1105
|
+
return;
|
|
1106
|
+
}
|
|
1107
|
+
if (be) {
|
|
1108
|
+
const T = S || window.location.href;
|
|
1109
|
+
window.open(T, "_blank", "noopener,noreferrer");
|
|
1110
|
+
return;
|
|
1111
|
+
}
|
|
1112
|
+
if (y)
|
|
1113
|
+
de("crypto", P, s), O && t ? (f().debug("[CryptoButton] Processing cart payment with coupon:", w), await k(t, _, w)) : P && (f().debug("[CryptoButton] Processing single payment with coupon:", w), await I(P, w, _));
|
|
1114
|
+
else {
|
|
1115
|
+
let T = !1;
|
|
1116
|
+
if (O && t ? (f().debug("[CryptoButton] Setting pending cart payment with coupon:", w), q({ type: "cart", items: t, metadata: _, couponCode: w }), T = !0) : P && (f().debug("[CryptoButton] Setting pending single payment with coupon:", w), q({ type: "single", resource: P, metadata: _, couponCode: w }), T = !0), !T) {
|
|
1117
|
+
f().error("[CryptoButton] No valid payment to process");
|
|
1118
|
+
return;
|
|
1119
|
+
}
|
|
1120
|
+
try {
|
|
1121
|
+
if (i)
|
|
1122
|
+
f().debug("[CryptoButton] Wallet already selected, connecting:", i.adapter.name), Se(i.adapter.name), await D();
|
|
1123
|
+
else {
|
|
1124
|
+
if (f().debug(
|
|
1125
|
+
"[CryptoButton] No wallet selected, showing selector. Available wallets:",
|
|
1126
|
+
J.map((j) => j.adapter.name)
|
|
1127
|
+
), J.length === 0) {
|
|
1128
|
+
q(null);
|
|
1129
|
+
const j = "No wallets available";
|
|
1130
|
+
throw ie(j), new Error(j);
|
|
1131
|
+
}
|
|
1132
|
+
G(!0);
|
|
1133
|
+
}
|
|
1134
|
+
} catch (j) {
|
|
1135
|
+
q(null);
|
|
1136
|
+
const ee = j instanceof Error ? j.message : "Failed to connect wallet";
|
|
1137
|
+
f().error("[CryptoButton] Connection error:", ee), ie(ee, i?.adapter.name);
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
}, [y, i, w, O, t, P, be, S, J, D, _, k, I, X, o, l]), Re = W(() => O && t ? `crypto-cart-${t.map((s) => s.resource).join("-")}` : `crypto-${P || "unknown"}`, [O, t, P]), Ue = W(
|
|
1141
|
+
() => Le(Re, Te, {
|
|
1142
|
+
cooldownMs: 200,
|
|
1143
|
+
deduplicationWindowMs: 0
|
|
1144
|
+
// MUST be 0 for crypto - each payment needs fresh transaction
|
|
1145
|
+
}),
|
|
1146
|
+
[Re, Te]
|
|
1147
|
+
), Ne = c === "loading", We = a || Ne || b || !!X, qe = Ne ? B("ui.processing") : Z, $e = A(async () => {
|
|
1148
|
+
try {
|
|
1149
|
+
re(!1), y && await H(), m(null), G(!0);
|
|
1150
|
+
} catch (s) {
|
|
1151
|
+
f().error("Failed to change wallet:", s);
|
|
1152
|
+
}
|
|
1153
|
+
}, [y, H, m]), ze = A((s) => {
|
|
1154
|
+
f().debug("[CryptoButton] Wallet clicked:", s), G(!1), m(s), re(!0), f().debug("[CryptoButton] Wallet selected, useEffect will auto-connect");
|
|
1155
|
+
}, [m]), Ye = A(async () => {
|
|
1156
|
+
try {
|
|
1157
|
+
await H(), q(null), typeof window < "u" && window.localStorage && window.localStorage.removeItem("walletName");
|
|
1158
|
+
} catch (s) {
|
|
1159
|
+
f().error("Failed to disconnect wallet:", s);
|
|
1160
|
+
}
|
|
1161
|
+
}, [H]);
|
|
1162
|
+
return /* @__PURE__ */ E("div", { className: d.unstyled ? p : `${d.className} cedros-theme__crypto-button ${p || ""}`, style: d.unstyled ? {} : d.style, children: [
|
|
1163
|
+
/* @__PURE__ */ C(
|
|
1164
|
+
"button",
|
|
1165
|
+
{
|
|
1166
|
+
onClick: Ue,
|
|
1167
|
+
disabled: We,
|
|
1168
|
+
className: d.unstyled ? p : "cedros-theme__button cedros-theme__crypto",
|
|
1169
|
+
type: "button",
|
|
1170
|
+
children: qe
|
|
1171
|
+
}
|
|
1172
|
+
),
|
|
1173
|
+
ve && !g && /* @__PURE__ */ C(
|
|
1174
|
+
"div",
|
|
1175
|
+
{
|
|
1176
|
+
className: "cedros-modal-overlay",
|
|
1177
|
+
style: {
|
|
1178
|
+
position: "fixed",
|
|
1179
|
+
top: 0,
|
|
1180
|
+
left: 0,
|
|
1181
|
+
right: 0,
|
|
1182
|
+
bottom: 0,
|
|
1183
|
+
backgroundColor: d.tokens.modalOverlay,
|
|
1184
|
+
display: "flex",
|
|
1185
|
+
alignItems: "center",
|
|
1186
|
+
justifyContent: "center",
|
|
1187
|
+
zIndex: 9999,
|
|
1188
|
+
padding: "1rem"
|
|
1189
|
+
},
|
|
1190
|
+
onClick: () => G(!1),
|
|
1191
|
+
children: /* @__PURE__ */ E(
|
|
1192
|
+
"div",
|
|
1193
|
+
{
|
|
1194
|
+
className: "cedros-modal-content",
|
|
1195
|
+
style: {
|
|
1196
|
+
backgroundColor: d.tokens.modalBackground,
|
|
1197
|
+
borderRadius: "12px",
|
|
1198
|
+
padding: "2rem",
|
|
1199
|
+
maxWidth: "400px",
|
|
1200
|
+
width: "100%",
|
|
1201
|
+
boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
1202
|
+
border: `1px solid ${d.tokens.modalBorder}`
|
|
1203
|
+
},
|
|
1204
|
+
onClick: (s) => s.stopPropagation(),
|
|
1205
|
+
children: [
|
|
1206
|
+
/* @__PURE__ */ E(
|
|
1207
|
+
"div",
|
|
1208
|
+
{
|
|
1209
|
+
style: {
|
|
1210
|
+
display: "flex",
|
|
1211
|
+
justifyContent: "space-between",
|
|
1212
|
+
alignItems: "center",
|
|
1213
|
+
marginBottom: "1.5rem"
|
|
1214
|
+
},
|
|
1215
|
+
children: [
|
|
1216
|
+
/* @__PURE__ */ C(
|
|
1217
|
+
"h3",
|
|
1218
|
+
{
|
|
1219
|
+
style: {
|
|
1220
|
+
margin: 0,
|
|
1221
|
+
fontSize: "1.25rem",
|
|
1222
|
+
fontWeight: 600,
|
|
1223
|
+
color: d.tokens.surfaceText
|
|
1224
|
+
},
|
|
1225
|
+
children: B("wallet.select_wallet")
|
|
1226
|
+
}
|
|
1227
|
+
),
|
|
1228
|
+
/* @__PURE__ */ C(
|
|
1229
|
+
"button",
|
|
1230
|
+
{
|
|
1231
|
+
onClick: () => G(!1),
|
|
1232
|
+
style: je(d.tokens.surfaceText),
|
|
1233
|
+
"aria-label": "Close modal",
|
|
1234
|
+
type: "button",
|
|
1235
|
+
children: "×"
|
|
1236
|
+
}
|
|
1237
|
+
)
|
|
1238
|
+
]
|
|
1239
|
+
}
|
|
1240
|
+
),
|
|
1241
|
+
/* @__PURE__ */ C("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" }, children: J.map((s) => /* @__PURE__ */ E(
|
|
1242
|
+
"button",
|
|
1243
|
+
{
|
|
1244
|
+
onClick: () => ze(s.adapter.name),
|
|
1245
|
+
style: {
|
|
1246
|
+
width: "100%",
|
|
1247
|
+
padding: "1rem",
|
|
1248
|
+
backgroundColor: d.tokens.surfaceBackground,
|
|
1249
|
+
border: `1px solid ${d.tokens.surfaceBorder}`,
|
|
1250
|
+
borderRadius: "0.5rem",
|
|
1251
|
+
cursor: "pointer",
|
|
1252
|
+
fontSize: "1rem",
|
|
1253
|
+
textAlign: "left",
|
|
1254
|
+
color: d.tokens.surfaceText,
|
|
1255
|
+
display: "flex",
|
|
1256
|
+
alignItems: "center",
|
|
1257
|
+
gap: "1rem",
|
|
1258
|
+
transition: "all 0.2s ease"
|
|
1259
|
+
},
|
|
1260
|
+
onMouseEnter: (T) => {
|
|
1261
|
+
T.currentTarget.style.backgroundColor = d.tokens.modalBackground, T.currentTarget.style.borderColor = d.tokens.surfaceText, T.currentTarget.style.transform = "translateY(-2px)";
|
|
1262
|
+
},
|
|
1263
|
+
onMouseLeave: (T) => {
|
|
1264
|
+
T.currentTarget.style.backgroundColor = d.tokens.surfaceBackground, T.currentTarget.style.borderColor = d.tokens.surfaceBorder, T.currentTarget.style.transform = "translateY(0)";
|
|
1265
|
+
},
|
|
1266
|
+
type: "button",
|
|
1267
|
+
children: [
|
|
1268
|
+
/* @__PURE__ */ C(Ge, { wallet: s, style: { width: "24px", height: "24px" } }),
|
|
1269
|
+
/* @__PURE__ */ C("span", { style: { fontWeight: 500 }, children: s.adapter.name })
|
|
1270
|
+
]
|
|
1271
|
+
},
|
|
1272
|
+
s.adapter.name
|
|
1273
|
+
)) })
|
|
1274
|
+
]
|
|
1275
|
+
}
|
|
1276
|
+
)
|
|
1277
|
+
}
|
|
1278
|
+
),
|
|
1279
|
+
y && !g && !ve && /* @__PURE__ */ E("div", { style: {
|
|
1280
|
+
display: "flex",
|
|
1281
|
+
justifyContent: "space-between",
|
|
1282
|
+
marginTop: "0.5rem",
|
|
1283
|
+
fontSize: "0.75rem",
|
|
1284
|
+
color: d.tokens.surfaceText,
|
|
1285
|
+
opacity: 0.7
|
|
1286
|
+
}, children: [
|
|
1287
|
+
/* @__PURE__ */ C(
|
|
1288
|
+
"button",
|
|
1289
|
+
{
|
|
1290
|
+
onClick: $e,
|
|
1291
|
+
style: {
|
|
1292
|
+
background: "none",
|
|
1293
|
+
border: "none",
|
|
1294
|
+
padding: 0,
|
|
1295
|
+
color: "inherit",
|
|
1296
|
+
textDecoration: "none",
|
|
1297
|
+
cursor: "pointer",
|
|
1298
|
+
fontSize: "inherit"
|
|
1299
|
+
},
|
|
1300
|
+
type: "button",
|
|
1301
|
+
children: "Change Wallet"
|
|
1302
|
+
}
|
|
1303
|
+
),
|
|
1304
|
+
/* @__PURE__ */ C(
|
|
1305
|
+
"button",
|
|
1306
|
+
{
|
|
1307
|
+
onClick: Ye,
|
|
1308
|
+
style: {
|
|
1309
|
+
background: "none",
|
|
1310
|
+
border: "none",
|
|
1311
|
+
padding: 0,
|
|
1312
|
+
color: "inherit",
|
|
1313
|
+
textDecoration: "none",
|
|
1314
|
+
cursor: "pointer",
|
|
1315
|
+
fontSize: "inherit"
|
|
1316
|
+
},
|
|
1317
|
+
type: "button",
|
|
1318
|
+
children: B("ui.disconnect")
|
|
1319
|
+
}
|
|
1320
|
+
)
|
|
1321
|
+
] }),
|
|
1322
|
+
!g && he && /* @__PURE__ */ C("div", { className: d.unstyled ? "" : "cedros-theme__error", children: he }),
|
|
1323
|
+
!g && Y && /* @__PURE__ */ C("div", { className: d.unstyled ? "" : "cedros-theme__error", children: Y }),
|
|
1324
|
+
!g && N && /* @__PURE__ */ C("div", { className: d.unstyled ? "" : "cedros-theme__success", children: B("ui.payment_successful") })
|
|
1325
|
+
] });
|
|
1326
|
+
}
|
|
1327
|
+
const Pt = ({
|
|
1328
|
+
isOpen: e,
|
|
1329
|
+
onClose: t,
|
|
1330
|
+
resource: n,
|
|
1331
|
+
items: a,
|
|
1332
|
+
cardLabel: o = "Card",
|
|
1333
|
+
cryptoLabel: r = "USDC (Solana)",
|
|
1334
|
+
showCard: l = !0,
|
|
1335
|
+
showCrypto: p = !0,
|
|
1336
|
+
onPaymentAttempt: S,
|
|
1337
|
+
onPaymentSuccess: g,
|
|
1338
|
+
onPaymentError: _,
|
|
1339
|
+
onStripeSuccess: w,
|
|
1340
|
+
onCryptoSuccess: y,
|
|
1341
|
+
onStripeError: b,
|
|
1342
|
+
onCryptoError: D,
|
|
1343
|
+
customerEmail: H,
|
|
1344
|
+
successUrl: m,
|
|
1345
|
+
cancelUrl: h,
|
|
1346
|
+
metadata: i,
|
|
1347
|
+
couponCode: v,
|
|
1348
|
+
testPageUrl: c,
|
|
1349
|
+
hideMessages: u = !1
|
|
1350
|
+
}) => {
|
|
1351
|
+
const { tokens: N } = fe();
|
|
1352
|
+
return U(() => {
|
|
1353
|
+
const I = (k) => {
|
|
1354
|
+
k.key === "Escape" && e && t();
|
|
1355
|
+
};
|
|
1356
|
+
return window.addEventListener("keydown", I), () => window.removeEventListener("keydown", I);
|
|
1357
|
+
}, [e, t]), U(() => {
|
|
1358
|
+
if (e) {
|
|
1359
|
+
const I = window.scrollY;
|
|
1360
|
+
return document.body.style.position = "fixed", document.body.style.top = `-${I}px`, document.body.style.width = "100%", document.body.style.overflowY = "scroll", () => {
|
|
1361
|
+
const k = document.body.style.top ? Math.abs(parseInt(document.body.style.top.replace("px", ""), 10)) : 0;
|
|
1362
|
+
document.body.style.position = "", document.body.style.top = "", document.body.style.width = "", document.body.style.overflowY = "", window.scrollTo(0, k);
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
}, [e]), e ? /* @__PURE__ */ C(
|
|
1366
|
+
"div",
|
|
1367
|
+
{
|
|
1368
|
+
className: "cedros-modal-overlay",
|
|
1369
|
+
style: {
|
|
1370
|
+
position: "fixed",
|
|
1371
|
+
top: 0,
|
|
1372
|
+
left: 0,
|
|
1373
|
+
right: 0,
|
|
1374
|
+
bottom: 0,
|
|
1375
|
+
backgroundColor: N.modalOverlay,
|
|
1376
|
+
display: "flex",
|
|
1377
|
+
alignItems: "center",
|
|
1378
|
+
justifyContent: "center",
|
|
1379
|
+
zIndex: 9999,
|
|
1380
|
+
padding: "1rem"
|
|
1381
|
+
},
|
|
1382
|
+
onClick: t,
|
|
1383
|
+
children: /* @__PURE__ */ E(
|
|
1384
|
+
"div",
|
|
1385
|
+
{
|
|
1386
|
+
className: "cedros-modal-content",
|
|
1387
|
+
style: {
|
|
1388
|
+
backgroundColor: N.modalBackground,
|
|
1389
|
+
borderRadius: "12px",
|
|
1390
|
+
padding: "2rem",
|
|
1391
|
+
maxWidth: "400px",
|
|
1392
|
+
width: "100%",
|
|
1393
|
+
boxShadow: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
1394
|
+
border: `1px solid ${N.modalBorder}`
|
|
1395
|
+
},
|
|
1396
|
+
onClick: (I) => I.stopPropagation(),
|
|
1397
|
+
children: [
|
|
1398
|
+
/* @__PURE__ */ E(
|
|
1399
|
+
"div",
|
|
1400
|
+
{
|
|
1401
|
+
style: {
|
|
1402
|
+
display: "flex",
|
|
1403
|
+
justifyContent: "space-between",
|
|
1404
|
+
alignItems: "center",
|
|
1405
|
+
marginBottom: "1.5rem"
|
|
1406
|
+
},
|
|
1407
|
+
children: [
|
|
1408
|
+
/* @__PURE__ */ C(
|
|
1409
|
+
"h3",
|
|
1410
|
+
{
|
|
1411
|
+
style: {
|
|
1412
|
+
margin: 0,
|
|
1413
|
+
fontSize: "1.25rem",
|
|
1414
|
+
fontWeight: 600,
|
|
1415
|
+
color: N.surfaceText
|
|
1416
|
+
},
|
|
1417
|
+
children: "Choose Payment Method"
|
|
1418
|
+
}
|
|
1419
|
+
),
|
|
1420
|
+
/* @__PURE__ */ C(
|
|
1421
|
+
"button",
|
|
1422
|
+
{
|
|
1423
|
+
onClick: t,
|
|
1424
|
+
style: je(N.surfaceText),
|
|
1425
|
+
"aria-label": "Close modal",
|
|
1426
|
+
children: "×"
|
|
1427
|
+
}
|
|
1428
|
+
)
|
|
1429
|
+
]
|
|
1430
|
+
}
|
|
1431
|
+
),
|
|
1432
|
+
/* @__PURE__ */ E("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
1433
|
+
l && /* @__PURE__ */ C(
|
|
1434
|
+
lt,
|
|
1435
|
+
{
|
|
1436
|
+
resource: n,
|
|
1437
|
+
items: a,
|
|
1438
|
+
label: o,
|
|
1439
|
+
onAttempt: S,
|
|
1440
|
+
onSuccess: w || g,
|
|
1441
|
+
onError: b || _,
|
|
1442
|
+
customerEmail: H,
|
|
1443
|
+
successUrl: m,
|
|
1444
|
+
cancelUrl: h,
|
|
1445
|
+
metadata: i,
|
|
1446
|
+
couponCode: v
|
|
1447
|
+
}
|
|
1448
|
+
),
|
|
1449
|
+
p && /* @__PURE__ */ C(
|
|
1450
|
+
dt,
|
|
1451
|
+
{
|
|
1452
|
+
resource: n,
|
|
1453
|
+
items: a,
|
|
1454
|
+
label: r,
|
|
1455
|
+
onAttempt: S,
|
|
1456
|
+
onSuccess: y || g,
|
|
1457
|
+
onError: D || _,
|
|
1458
|
+
testPageUrl: c,
|
|
1459
|
+
hideMessages: u,
|
|
1460
|
+
metadata: i,
|
|
1461
|
+
couponCode: v
|
|
1462
|
+
}
|
|
1463
|
+
)
|
|
1464
|
+
] })
|
|
1465
|
+
]
|
|
1466
|
+
}
|
|
1467
|
+
)
|
|
1468
|
+
}
|
|
1469
|
+
) : null;
|
|
1470
|
+
};
|
|
1471
|
+
function Dt({
|
|
1472
|
+
product: e,
|
|
1473
|
+
paymentMethod: t,
|
|
1474
|
+
showOriginalPrice: n = !1,
|
|
1475
|
+
className: a = "",
|
|
1476
|
+
style: o = {}
|
|
1477
|
+
}) {
|
|
1478
|
+
const r = t === "stripe", l = r ? e.fiatAmount : e.cryptoAmount, p = r ? e.effectiveFiatAmount : e.effectiveCryptoAmount, S = r ? e.fiatCurrency.toUpperCase() : e.cryptoToken, g = r ? e.hasStripeCoupon : e.hasCryptoCoupon, _ = r ? e.stripeDiscountPercent : e.cryptoDiscountPercent;
|
|
1479
|
+
return /* @__PURE__ */ E("div", { className: a, style: o, children: [
|
|
1480
|
+
n && g && /* @__PURE__ */ E(
|
|
1481
|
+
"span",
|
|
1482
|
+
{
|
|
1483
|
+
style: {
|
|
1484
|
+
textDecoration: "line-through",
|
|
1485
|
+
opacity: 0.6,
|
|
1486
|
+
marginRight: "0.5rem",
|
|
1487
|
+
fontSize: "0.875em"
|
|
1488
|
+
},
|
|
1489
|
+
children: [
|
|
1490
|
+
l.toFixed(2),
|
|
1491
|
+
" ",
|
|
1492
|
+
S
|
|
1493
|
+
]
|
|
1494
|
+
}
|
|
1495
|
+
),
|
|
1496
|
+
/* @__PURE__ */ E("span", { style: { fontWeight: 600 }, children: [
|
|
1497
|
+
p.toFixed(2),
|
|
1498
|
+
" ",
|
|
1499
|
+
S
|
|
1500
|
+
] }),
|
|
1501
|
+
g && _ > 0 && /* @__PURE__ */ E(
|
|
1502
|
+
"span",
|
|
1503
|
+
{
|
|
1504
|
+
style: {
|
|
1505
|
+
marginLeft: "0.5rem",
|
|
1506
|
+
padding: "0.125rem 0.375rem",
|
|
1507
|
+
backgroundColor: "#10b981",
|
|
1508
|
+
color: "white",
|
|
1509
|
+
borderRadius: "0.25rem",
|
|
1510
|
+
fontSize: "0.75em",
|
|
1511
|
+
fontWeight: 600
|
|
1512
|
+
},
|
|
1513
|
+
children: [
|
|
1514
|
+
_,
|
|
1515
|
+
"% OFF"
|
|
1516
|
+
]
|
|
1517
|
+
}
|
|
1518
|
+
)
|
|
1519
|
+
] });
|
|
1520
|
+
}
|
|
1521
|
+
function Et({
|
|
1522
|
+
product: e,
|
|
1523
|
+
paymentMethod: t,
|
|
1524
|
+
className: n = "",
|
|
1525
|
+
style: a = {}
|
|
1526
|
+
}) {
|
|
1527
|
+
const o = t === "stripe", r = o ? e.hasStripeCoupon : e.hasCryptoCoupon, l = o ? e.stripeDiscountPercent : e.cryptoDiscountPercent, p = o ? e.stripeCouponCode : e.cryptoCouponCode;
|
|
1528
|
+
if (!r || l === 0)
|
|
1529
|
+
return null;
|
|
1530
|
+
const S = o ? `${l}% off with card!` : `${l}% off with crypto!`;
|
|
1531
|
+
return /* @__PURE__ */ E(
|
|
1532
|
+
"div",
|
|
1533
|
+
{
|
|
1534
|
+
className: n,
|
|
1535
|
+
style: {
|
|
1536
|
+
display: "inline-flex",
|
|
1537
|
+
alignItems: "center",
|
|
1538
|
+
padding: "0.5rem 0.75rem",
|
|
1539
|
+
backgroundColor: o ? "#6366f1" : "#10b981",
|
|
1540
|
+
color: "white",
|
|
1541
|
+
borderRadius: "0.375rem",
|
|
1542
|
+
fontSize: "0.875rem",
|
|
1543
|
+
fontWeight: 600,
|
|
1544
|
+
...a
|
|
1545
|
+
},
|
|
1546
|
+
children: [
|
|
1547
|
+
S,
|
|
1548
|
+
p && /* @__PURE__ */ E(
|
|
1549
|
+
"span",
|
|
1550
|
+
{
|
|
1551
|
+
style: {
|
|
1552
|
+
marginLeft: "0.5rem",
|
|
1553
|
+
opacity: 0.8,
|
|
1554
|
+
fontSize: "0.75em",
|
|
1555
|
+
fontWeight: 400
|
|
1556
|
+
},
|
|
1557
|
+
children: [
|
|
1558
|
+
"(",
|
|
1559
|
+
p,
|
|
1560
|
+
")"
|
|
1561
|
+
]
|
|
1562
|
+
}
|
|
1563
|
+
)
|
|
1564
|
+
]
|
|
1565
|
+
}
|
|
1566
|
+
);
|
|
1567
|
+
}
|
|
1568
|
+
export {
|
|
1569
|
+
Ct as A,
|
|
1570
|
+
St as B,
|
|
1571
|
+
$ as C,
|
|
1572
|
+
It as E,
|
|
1573
|
+
Pt as P,
|
|
1574
|
+
lt as S,
|
|
1575
|
+
Dt as a,
|
|
1576
|
+
Et as b,
|
|
1577
|
+
Fe as c,
|
|
1578
|
+
vt as d,
|
|
1579
|
+
Me as e,
|
|
1580
|
+
bt as f,
|
|
1581
|
+
de as g,
|
|
1582
|
+
He as h,
|
|
1583
|
+
ae as i,
|
|
1584
|
+
Tt as j,
|
|
1585
|
+
Rt as k,
|
|
1586
|
+
Nt as l,
|
|
1587
|
+
dt as m,
|
|
1588
|
+
ut as n,
|
|
1589
|
+
ye as o,
|
|
1590
|
+
wt as p,
|
|
1591
|
+
K as q,
|
|
1592
|
+
Le as r,
|
|
1593
|
+
Se as s,
|
|
1594
|
+
at as t,
|
|
1595
|
+
ot as u,
|
|
1596
|
+
ie as v,
|
|
1597
|
+
st as w,
|
|
1598
|
+
it as x,
|
|
1599
|
+
kt as y,
|
|
1600
|
+
ct as z
|
|
1601
|
+
};
|