@lydianpay/sdk-web 3.0.1 → 3.2.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.
Files changed (72) hide show
  1. package/README.md +9 -8
  2. package/dist/chunks/index-BhtU_AAG.js +740 -0
  3. package/dist/chunks/{index-YAGlsS0s.js → index-CVTOXcSY.js} +13 -14
  4. package/dist/chunks/{metamask-sdk-CFm2IK48.js → metamask-sdk-BwVxHW1_.js} +1 -1
  5. package/dist/chunks/mountEngine-P1Ws89oo.js +34936 -0
  6. package/dist/lydian.js +1 -1
  7. package/dist/types/.tsbuildinfo +1 -1
  8. package/dist/types/constants.d.ts +6 -0
  9. package/dist/types/types.d.ts +1 -0
  10. package/dist/types/ui/Checkout.d.ts +11 -143
  11. package/dist/types/ui/checkoutCallbacks.d.ts +26 -0
  12. package/dist/types/ui/checkoutEngine.d.ts +28 -0
  13. package/dist/types/ui/checkoutPresentation.d.ts +24 -0
  14. package/dist/types/ui/checkoutSelection.d.ts +30 -0
  15. package/dist/types/ui/components/icons.d.ts +0 -1
  16. package/dist/types/ui/copyFields.d.ts +13 -0
  17. package/dist/types/ui/countdownClock.d.ts +5 -0
  18. package/dist/types/ui/dialogController.d.ts +35 -0
  19. package/dist/types/ui/failureReport.d.ts +13 -0
  20. package/dist/types/ui/flowConfig.d.ts +3 -2
  21. package/dist/types/ui/hostCallbacks.d.ts +10 -0
  22. package/dist/types/ui/kycFlow.d.ts +44 -0
  23. package/dist/types/ui/kycVerificationRequest.d.ts +17 -0
  24. package/dist/types/ui/networkListHelpers.d.ts +9 -1
  25. package/dist/types/ui/paymentFlow.d.ts +49 -0
  26. package/dist/types/ui/pollTick.d.ts +15 -0
  27. package/dist/types/ui/react/AssetSelectScreen.d.ts +1 -5
  28. package/dist/types/ui/react/CheckoutApp.d.ts +1 -4
  29. package/dist/types/ui/react/CloseTransactionDialogBody.d.ts +1 -6
  30. package/dist/types/ui/react/ConnectWithQrScreen.d.ts +1 -5
  31. package/dist/types/ui/react/ConnectingWalletScreen.d.ts +1 -5
  32. package/dist/types/ui/react/KycScreen.d.ts +1 -5
  33. package/dist/types/ui/react/LoadingScreen.d.ts +1 -8
  34. package/dist/types/ui/react/NetworkSelectScreen.d.ts +1 -5
  35. package/dist/types/ui/react/PaymentFailureScreen.d.ts +1 -5
  36. package/dist/types/ui/react/PaymentHeaderSection.d.ts +1 -12
  37. package/dist/types/ui/react/PaymentSuccessScreen.d.ts +1 -5
  38. package/dist/types/ui/react/RestoreDetailsDialogBody.d.ts +1 -4
  39. package/dist/types/ui/react/ScanToPayScreen.d.ts +1 -5
  40. package/dist/types/ui/react/TimerBanner/TimerBanner.d.ts +2 -0
  41. package/dist/types/ui/react/TimerBanner/timerBannerHelpers.d.ts +13 -0
  42. package/dist/types/ui/react/WalletSelectScreen.d.ts +1 -5
  43. package/dist/types/ui/react/checkoutActions.d.ts +107 -0
  44. package/dist/types/ui/react/checkoutContext.d.ts +9 -0
  45. package/dist/types/ui/react/checkoutReducer.d.ts +11 -0
  46. package/dist/types/ui/react/checkoutStore.d.ts +19 -11
  47. package/dist/types/ui/react/engine/CheckoutEngine.d.ts +30 -0
  48. package/dist/types/ui/react/engine/checkoutShell.d.ts +3 -0
  49. package/dist/types/ui/react/engine/mountEngine.d.ts +10 -0
  50. package/dist/types/ui/react/engine/useBranding.d.ts +1 -0
  51. package/dist/types/ui/react/engine/useCopyFields.d.ts +1 -0
  52. package/dist/types/ui/react/engine/useHostCallbacks.d.ts +2 -0
  53. package/dist/types/ui/react/engine/useProcessingOverlay.d.ts +1 -0
  54. package/dist/types/ui/react/engine/useScreenNavigator.d.ts +3 -0
  55. package/dist/types/ui/react/mount.d.ts +7 -5
  56. package/dist/types/ui/react/useQrCanvas.d.ts +9 -0
  57. package/dist/types/ui/screenNavigator.d.ts +13 -0
  58. package/dist/types/ui/sessionBootstrap.d.ts +36 -0
  59. package/dist/types/ui/sessionHelpers.d.ts +1 -2
  60. package/dist/types/ui/sessionLifecycle.d.ts +37 -0
  61. package/dist/types/ui/sessionQuoteWatcher.d.ts +7 -8
  62. package/dist/types/ui/settledOutcome.d.ts +14 -0
  63. package/dist/types/ui/transactionOutcome.d.ts +2 -0
  64. package/dist/types/ui/transactionPoller.d.ts +16 -0
  65. package/dist/types/ui/walletConnection.d.ts +48 -0
  66. package/package.json +2 -1
  67. package/dist/chunks/index-NI3RoQG3.js +0 -22485
  68. package/dist/chunks/mount-bhuHFGLm.js +0 -12914
  69. package/dist/types/ui/countdownBanner.d.ts +0 -33
  70. package/dist/types/ui/react/DownloadWalletScreen.d.ts +0 -4
  71. package/dist/types/ui/react/TimerBanner.d.ts +0 -4
  72. package/dist/types/ui/react/callbacksFixture.d.ts +0 -6
@@ -0,0 +1,740 @@
1
+ const g = ["USD", "TRY", "PHP"];
2
+ function S(t) {
3
+ return typeof t == "string" && g.includes(t);
4
+ }
5
+ function c(t) {
6
+ return "sessionID" in t && typeof t.sessionID == "string" && t.sessionID.length > 0;
7
+ }
8
+ class u {
9
+ // Optional: a caller-supplied session has no key and needs none (see Sessions).
10
+ // The key is still required when the SDK creates the session, enforced in
11
+ // index.ts where that is known.
12
+ constructor(e, a) {
13
+ if (this.baseUri = e, this.publishableKey = a, !this.baseUri)
14
+ throw new Error("baseUri is required");
15
+ }
16
+ // Omitted rather than blank when there is no key: the gateway checks the pk_
17
+ // prefix first, so an empty header is a 400 where an absent one is anonymous.
18
+ headers(e) {
19
+ const a = { ...e };
20
+ return this.publishableKey && (a["X-Publishable-Key"] = this.publishableKey), a;
21
+ }
22
+ async request(e, a) {
23
+ const n = `${this.baseUri}${e}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
24
+ if (s.ok)
25
+ return await s.json();
26
+ throw new Error(s.statusText);
27
+ }
28
+ // For endpoints that reply text/plain rather than JSON (e.g. PATCH
29
+ // /customer/otp -> "OTP sent"). Sends the same JSON request headers but does
30
+ // not call response.json(), which would throw on a non-JSON body.
31
+ async requestText(e, a) {
32
+ const n = `${this.baseUri}${e}`, o = this.headers({ "Content-Type": "application/json" }), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
33
+ if (s.ok)
34
+ return await s.text();
35
+ throw new Error(s.statusText);
36
+ }
37
+ async requestWithFormData(e, a) {
38
+ const n = `${this.baseUri}${e}`, o = this.headers(), r = Object.assign({}, a, { headers: o }), s = await fetch(n, r);
39
+ if (s.ok)
40
+ return await s.json();
41
+ throw new Error(s.statusText);
42
+ }
43
+ }
44
+ const l = "transaction";
45
+ class N extends u {
46
+ async getCryptoTransaction(e) {
47
+ return await this.request(`/${l}/${e}`);
48
+ }
49
+ async createPaymentRequest(e, a) {
50
+ return await this.request(
51
+ `/${l}/${e}/payment`,
52
+ {
53
+ method: "POST",
54
+ body: JSON.stringify(a)
55
+ }
56
+ );
57
+ }
58
+ async cancelCryptoTransaction(e, a) {
59
+ return await this.request(
60
+ `/${l}/${e}/cancel`,
61
+ {
62
+ method: "PATCH",
63
+ body: JSON.stringify(a)
64
+ }
65
+ );
66
+ }
67
+ async kycVerification(e, a) {
68
+ const n = new FormData();
69
+ return n.append("asset", a.asset), n.append("network", a.network), n.append("firstName", a.firstName), n.append("lastName", a.lastName), n.append("email", a.email), n.append("street", a.street), n.append("city", a.city), n.append("region", a.region), n.append("postalCode", a.postalCode), n.append("country", a.country), n.append("storeKYC", a.storeKYC ? "true" : "false"), a.customerUUID && n.append("customerUUID", a.customerUUID), a.documentType && n.append("documentType", a.documentType), a.documentFiles.forEach((o) => n.append("documentFiles", o)), await this.requestWithFormData(
70
+ `/${l}/${e}/verification`,
71
+ {
72
+ method: "POST",
73
+ body: n
74
+ }
75
+ );
76
+ }
77
+ }
78
+ function I(t, e) {
79
+ e.forEach((a) => {
80
+ Object.getOwnPropertyNames(a.prototype).forEach((n) => {
81
+ const o = Object.getOwnPropertyDescriptor(a.prototype, n);
82
+ o && Object.defineProperty(t.prototype, n, o);
83
+ });
84
+ });
85
+ }
86
+ const w = "customer/otp";
87
+ class A extends u {
88
+ // PATCH /customer/otp -> text/plain "OTP sent" (no JSON body).
89
+ async sendCustomerOTP(e) {
90
+ return await this.requestText(`/${w}`, {
91
+ method: "PATCH",
92
+ body: JSON.stringify(e)
93
+ });
94
+ }
95
+ // PUT /customer/otp -> { customerUUID, kycValidated }.
96
+ async authenticateCustomerOTP(e) {
97
+ return await this.request(`/${w}`, {
98
+ method: "PUT",
99
+ body: JSON.stringify(e)
100
+ });
101
+ }
102
+ }
103
+ const d = "session";
104
+ class L extends u {
105
+ async createSession(e) {
106
+ return await this.request(`/${d}`, {
107
+ method: "POST",
108
+ body: JSON.stringify(e)
109
+ });
110
+ }
111
+ async getSession(e) {
112
+ return await this.request(`/${d}/${e}`);
113
+ }
114
+ // Promotes the session into a transaction. Allowed once per session — except
115
+ // that a KYC-pending (-3) response does not consume the promotion, which is
116
+ // what lets the restore-details flow re-promote with a customerUUID.
117
+ async createSessionTransaction(e, a) {
118
+ return await this.request(
119
+ `/${d}/${e}/transaction`,
120
+ {
121
+ method: "POST",
122
+ body: JSON.stringify(a)
123
+ }
124
+ );
125
+ }
126
+ // PATCH /session/{id}/cancel replies text/plain (the merchant's cancel URL),
127
+ // not JSON. Cancelling cascades to the linked transaction, if any.
128
+ async cancelSession(e) {
129
+ return await this.requestText(`/${d}/${e}/cancel`, {
130
+ method: "PATCH"
131
+ });
132
+ }
133
+ }
134
+ class P extends u {
135
+ }
136
+ I(P, [N, A, L]);
137
+ const R = P;
138
+ var y = {
139
+ API_CANCELLED: -9,
140
+ PAYMENT_TIMEOUT: -8,
141
+ FRAUD_DECLINED: -7,
142
+ FRAUD_REFUNDED: -6,
143
+ // models names this TxnStatusFraudRefundHeld; FRAUD_HELD is kept for
144
+ // continuity with the merchant dashboard's existing call sites.
145
+ FRAUD_HELD: -5,
146
+ FORFEITED: -4,
147
+ // A KYC-pending promote is NOT terminal and does not consume the session's
148
+ // one promotion — the OTP restore flow re-promotes the same session.
149
+ KYC_VERIFICATION_PENDING: -3,
150
+ CANCELLED: -2,
151
+ FRAUD: -1,
152
+ PENDING: 0,
153
+ SUCCESS: 1
154
+ }, Z = {
155
+ PARTIALLY_PAID: 1,
156
+ OVERPAID: 3
157
+ }, U = {
158
+ PENDING: 0,
159
+ CONFIRMED: 1
160
+ }, p = {
161
+ dev: "https://api.lydian.dev",
162
+ sandbox: "https://api.sandbox.lydian.com",
163
+ prod: "https://api.lydian.com"
164
+ };
165
+ function O(t) {
166
+ return t.dev ? p.dev : t.sandbox ? p.sandbox : p.prod;
167
+ }
168
+ function b({
169
+ options: t,
170
+ unsupportedKeys: e,
171
+ entryPoint: a
172
+ }) {
173
+ const n = e.filter((o) => t[o] !== void 0);
174
+ return n.length === 0 ? null : `${n.join(" and ")} ${n.length > 1 ? "are" : "is"} not used by ${a}. Passing it has no effect, so this is almost always a mistake.`;
175
+ }
176
+ function C(t) {
177
+ var e;
178
+ return (e = t.flow) != null && e.walletConnect && !t.walletConnectProjectId ? "walletConnectProjectId is required when flow.walletConnect is on" : null;
179
+ }
180
+ function X(t) {
181
+ return t !== null && !c(t) && !!t.publishableKey;
182
+ }
183
+ function V(t) {
184
+ return t !== null && !c(t);
185
+ }
186
+ function ee({
187
+ options: t,
188
+ session: e,
189
+ settled: a
190
+ }) {
191
+ return !a && e !== null && t !== null && c(t);
192
+ }
193
+ function T(t, e, a) {
194
+ try {
195
+ t == null || t(e, a);
196
+ } catch (n) {
197
+ console.error(`onEvent("${e}") threw:`, n);
198
+ }
199
+ }
200
+ async function F({
201
+ api: t,
202
+ options: e,
203
+ emit: a
204
+ }) {
205
+ try {
206
+ const n = await W({ api: t, options: e }), { session: o, sessionPromoted: r } = await x({ api: t, sessionID: n });
207
+ a("session.loaded", $(o));
208
+ const s = await M({
209
+ api: t,
210
+ transactionID: o.transactionID
211
+ });
212
+ return { ok: !0, session: o, sessionPromoted: r, linkedTransaction: s };
213
+ } catch {
214
+ return { ok: !1 };
215
+ }
216
+ }
217
+ async function W({
218
+ api: t,
219
+ options: e
220
+ }) {
221
+ return c(e) ? e.sessionID : (await t.createSession({
222
+ amount: e.transaction.amount,
223
+ amountCurrency: e.transaction.currency,
224
+ descriptor: e.transaction.descriptor,
225
+ referenceNumber: e.transaction.referenceNumber
226
+ })).sessionID;
227
+ }
228
+ async function x({
229
+ api: t,
230
+ sessionID: e
231
+ }) {
232
+ const a = await t.getSession(e);
233
+ return { session: a, sessionPromoted: k(a) };
234
+ }
235
+ function $(t) {
236
+ return {
237
+ sessionID: t.sessionID,
238
+ merchantName: t.merchantName,
239
+ alreadyPromoted: k(t)
240
+ };
241
+ }
242
+ function k(t) {
243
+ return !!t.transactionID;
244
+ }
245
+ async function M({
246
+ api: t,
247
+ transactionID: e
248
+ }) {
249
+ if (!e)
250
+ return null;
251
+ try {
252
+ return await t.getCryptoTransaction(e);
253
+ } catch (a) {
254
+ return console.error("Failed to resolve the session transaction:", a), null;
255
+ }
256
+ }
257
+ function m(t) {
258
+ if (!t)
259
+ return;
260
+ let e;
261
+ try {
262
+ e = new URL(t);
263
+ } catch {
264
+ return;
265
+ }
266
+ return e.protocol === "https:" || e.protocol === "http:" ? t : void 0;
267
+ }
268
+ function Y({
269
+ message: t,
270
+ reason: e,
271
+ shouldEndCheckout: a,
272
+ transactionID: n,
273
+ session: o
274
+ }) {
275
+ return {
276
+ event: { reason: e, shouldEndCheckout: a, message: t },
277
+ failure: {
278
+ shouldEndCheckout: a,
279
+ reason: e,
280
+ transactionID: n,
281
+ // Only a failure that ends the checkout carries a redirect. A retryable one
282
+ // leaves the customer mid-flow with something still to do, and a host that
283
+ // navigated on it would eject them on a hiccup.
284
+ redirectURL: a ? m(o == null ? void 0 : o.failureURL) : void 0
285
+ }
286
+ };
287
+ }
288
+ const q = {
289
+ "common.cancelTransaction": "Cancel Transaction",
290
+ "common.cancel": "Cancel",
291
+ "common.back": "Back",
292
+ "common.close": "Close",
293
+ "common.done": "Done",
294
+ "common.continue": "Continue",
295
+ "common.retry": "Retry",
296
+ "common.warningAlt": "Warning",
297
+ "common.checkoutAria": "Checkout",
298
+ "common.closeAria": "Close",
299
+ "common.networkLabel": "Network",
300
+ "common.coinLabel": "Coin",
301
+ "common.cryptoWalletLabel": "Crypto wallet",
302
+ "common.emailAddress": "Email address",
303
+ "common.enterEmail": "Enter email",
304
+ "common.country": "Country",
305
+ "common.selectCountry": "Select country",
306
+ "common.noResults": 'No results for "{query}"',
307
+ "pay.withLydian": "Pay with Lydian",
308
+ "pay.withCrypto": "Pay With Crypto",
309
+ "header.youArePaying": "You are paying",
310
+ "header.paymentAmount": "Payment amount",
311
+ "header.merchantLogoAlt": "Merchant logo",
312
+ "header.changePaymentMethod": "Change payment method",
313
+ "wallet.chooseWallet": "Choose your crypto wallet",
314
+ "wallet.featured": "FEATURED",
315
+ "wallet.manualQrName": "Manual QR Code",
316
+ "wallet.otherWallets": "Other wallets",
317
+ "wallet.connectingTo": "Connecting to {wallet}",
318
+ "wallet.approveInApp": "Open {wallet} to connect your wallet, then navigate back to this page.",
319
+ "wallet.openFailedHint": "Didn't see {wallet} open? Tap the button above to try again, or make sure it's installed.",
320
+ "wallet.openApp": "Open {wallet}",
321
+ "wallet.openInBrowser": "Try a different way to open {wallet}",
322
+ "wallet.install": "Install {wallet}",
323
+ "wallet.connectNamed": "Connect {wallet}",
324
+ "wallet.scanToConnect": "Scan with your phone to connect with {wallet}.",
325
+ "asset.chooseCoin": "Choose a coin",
326
+ "asset.markupNotice": "Conversion includes a {percent}% markup fee",
327
+ "network.chooseNetwork": "Choose a network",
328
+ "network.walletSupportWarning": "Please make sure you choose a network that your crypto wallet supports.",
329
+ "network.noSupportedNetworks": "{wallet} doesn't support any of the networks available for this payment.",
330
+ "network.noSupportedNetworksForMerchant": "{wallet} doesn't support any of the networks available for {merchant}.",
331
+ "network.recommended": "RECOMMENDED",
332
+ "network.fee": "Network fee: {fee}",
333
+ "kyc.additionalInfoRequired": "Additional info required",
334
+ "kyc.stepBasic": "Basic details",
335
+ "kyc.stepAddress": "Address",
336
+ "kyc.stepDocument": "Verification document",
337
+ "kyc.firstNamesLabel": "Legal first name",
338
+ "kyc.firstNamesPlaceholder": "Enter legal first name",
339
+ "kyc.lastNameLabel": "Legal last name",
340
+ "kyc.lastNamePlaceholder": "Enter legal last name",
341
+ "kyc.streetLabel": "Street address",
342
+ "kyc.streetPlaceholder": "Enter street address",
343
+ "kyc.cityLabel": "City",
344
+ "kyc.cityPlaceholder": "Enter city",
345
+ "kyc.regionLabel": "State / Region",
346
+ "kyc.regionPlaceholder": "Enter state or region",
347
+ "kyc.postalCodeLabel": "ZIP / Postal code",
348
+ "kyc.postalCodePlaceholder": "Enter ZIP or postal code",
349
+ "kyc.documentTypeLabel": "Document type",
350
+ "kyc.documentTypeAria": "Document Type",
351
+ "kyc.docTypeIdCard": "Identity (ID) Card",
352
+ "kyc.docTypePassport": "Passport",
353
+ "kyc.docTypeResidencePermit": "Residence Permit",
354
+ "kyc.docTypeDrivers": "Drivers License",
355
+ "kyc.frontPage": "Front page",
356
+ "kyc.backPage": "Back page",
357
+ "kyc.fileHint": "PNG, JPG or PDF, up to 10 MB",
358
+ "kyc.saveInfo": "Securely save this info for next time",
359
+ "kyc.saveInfoDescription": "Next time, skip this step by entering the one-time code sent to your email.",
360
+ "scan.exactAmountNotice": "Make sure you send the exact amount on the correct network to complete your payment smoothly.",
361
+ "scan.scanWithWallet": "Scan the QR code with your preferred wallet",
362
+ "scan.payOnWallet": "Pay on {wallet}",
363
+ "scan.scanToPay": "Scan to pay",
364
+ "scan.payOnYourWallet": "Pay on your crypto wallet",
365
+ "scan.amountToPay": "Amount to pay",
366
+ "scan.remainingAmountToPay": "Remaining amount to pay",
367
+ "scan.subtotal": "Subtotal",
368
+ "scan.networkFee": "Network fee",
369
+ "scan.markup": "Markup fee",
370
+ "scan.total": "Total",
371
+ "scan.walletAddress": "Wallet address",
372
+ "scan.amountLabel": "Amount",
373
+ "scan.downloadQr": "Download QR",
374
+ "scan.changeCoin": "Change coin",
375
+ "scan.waitingForPayment": "Waiting for payment...",
376
+ "scan.cancelPayment": "Cancel payment",
377
+ "scan.openWalletToPay": "Open {wallet}",
378
+ "scan.payWithWallet": "Pay with your wallet",
379
+ "scan.exchangeRate": "1 {asset} = {amount}",
380
+ "scan.qrUnavailable": "We couldn't generate a QR code for this payment. Copy the amount and wallet address below and send it from your wallet instead.",
381
+ "scan.addressCopied": "Wallet address copied",
382
+ "loading.approveInWallet": "Approve the transaction in your wallet app",
383
+ "loading.stayOnPage": "Please stay on this page until we confirm your transaction.",
384
+ "loading.waitingForConfirmation": "Waiting for transaction confirmation...",
385
+ "timer.completePaymentWithin": "Complete payment within",
386
+ "timer.priceValidNote": "The crypto price is only valid during this time",
387
+ "underpaid.notice": "You haven't sent the full amount yet. Scan the QR code below to send the remaining balance.",
388
+ "underpaid.paymentProgress": "PAYMENT PROGRESS",
389
+ "underpaid.transactionAmount": "Transaction amount",
390
+ "underpaid.alreadyPaid": "Already paid",
391
+ "underpaid.remainingBalance": "Remaining balance",
392
+ "underpaid.paymentsReceived": "PAYMENTS RECEIVED",
393
+ "underpaid.paymentReceivedFallback": "Payment received",
394
+ "underpaid.ledgerValue": "{amount} {asset} on {network}",
395
+ "underpaid.chooseDifferentAsset": "Choose Different Asset",
396
+ "success.title": "Payment Successful",
397
+ "success.overpaidNotice": "You transferred more than required. The excess will be returned within 24 hours, minus any applicable gas fees.",
398
+ "success.transactionDetails": "TRANSACTION DETAILS",
399
+ "success.transactionId": "Transaction ID",
400
+ "success.paymentDate": "Payment date",
401
+ "success.paymentMethod": "Payment method",
402
+ "success.paymentDetails": "PAYMENT DETAILS",
403
+ "success.currency": "Currency",
404
+ "success.subtotal": "Subtotal",
405
+ "success.networkFee": "Network fee",
406
+ "success.markup": "Markup fee",
407
+ "success.exchangeRate": "Exchange rate",
408
+ "success.overpayment": "Overpayment",
409
+ "success.amountToBeReturned": "Amount to be returned",
410
+ "success.totalAmountPaid": "Total amount paid",
411
+ "success.cryptoMethod": "Crypto – {asset} on {network}",
412
+ "success.cryptoMethodWallet": "Crypto – {wallet}",
413
+ "failure.title": "We couldn't complete your payment",
414
+ "failure.paymentId": "Payment ID",
415
+ "failure.copyPaymentId": "Copy payment ID",
416
+ "restore.title": "Restore Details",
417
+ "restore.heading": "Restore your details",
418
+ "restore.sendCode": "Send code",
419
+ "restore.verifyCode": "Verify code",
420
+ "restore.autoFillHeading": "Auto-fill info below",
421
+ "restore.otpPrompt": "Please enter the 6-digit code sent to",
422
+ "restore.notYou": "Not you?",
423
+ "restore.didntGetCode": "Didn't get the code?",
424
+ "restore.sendAgain": "Send again",
425
+ "restore.digitLabel": "Digit {index}",
426
+ "restore.somethingWentWrong": "Something went wrong",
427
+ "restore.sendingOtp": "Sending OTP...",
428
+ "restore.verifyingCode": "Verifying code...",
429
+ "restore.unableToSendOtpTitle": "Unable to send OTP",
430
+ "restore.unableToSendOtpBody": "Check your email and try again.",
431
+ "restore.unableToVerifyCode": "Unable to verify code.",
432
+ "modal.areYouSure": "Are you sure?",
433
+ "modal.closeDescription": "Are you sure you want to cancel this payment? If you continue, you will lose any progress you have made.",
434
+ "modal.approvedInWalletNote": "If you already approved in your wallet, the transaction is on-chain — cancelling here only stops this page from waiting.",
435
+ "modal.goBackToTransaction": "Go Back to Transaction",
436
+ "modal.cancelAndForfeitTitle": "Cancel Transaction and Forfeit Funds",
437
+ "modal.forfeitDescription": "Are you sure you want to cancel this payment? If you continue, you will forfeit the {amount} USDT already transferred, and your order will not be placed.",
438
+ "copy.pressToCopy": "Press ⌘C",
439
+ "copy.copied": "Copied",
440
+ "copy.copyLabel": "Copy {label}",
441
+ "file.dragAndDrop": "Drag and drop or click to browse",
442
+ "file.dropzoneAria": "{label}. Drag and drop or click to browse",
443
+ "file.removeAria": "Remove {label}",
444
+ "file.sizeReady": "{size} MB, ready to upload",
445
+ "errors.assetNetworkRequired": "Choose a coin and network to continue.",
446
+ "errors.notInitialized": "Checkout isn't ready yet. Please refresh the page and try again.",
447
+ "errors.paymentCouldNotComplete": "Your payment could not be completed. Please try again and choose an available payment method.",
448
+ "errors.unableToCollectUnderpaid": "We couldn't set up the remaining balance. Please try again.",
449
+ "errors.paymentTimedOut": "Your payment timed out. Please try again and choose an available payment method.",
450
+ "errors.paymentStatusUnavailable": "We’re having trouble confirming your payment. If you’ve already sent it, it will still be picked up — keep this page open.",
451
+ "errors.unableToCreateSession": "We couldn't start your checkout. Please refresh the page and try again.",
452
+ "errors.checkoutUnavailable": "We couldn't load the checkout. Please refresh the page and try again.",
453
+ "errors.sessionExpired": "This checkout session has expired. Please start again.",
454
+ "errors.sdkNotInitialized": "SDK not initialized.",
455
+ "errors.unableToConnectWallet": "Unable to connect to your wallet. Please try again.",
456
+ "errors.walletNoAccount": "Your wallet didn't return a valid account. Please try again.",
457
+ "errors.walletWrongNetwork": "Your wallet switched to a different network. Switch back to {network} to pay from it, or scan the code below instead.",
458
+ "errors.walletOnWrongNetwork": "Your wallet is on a different network. Switch to {network} to pay from it, or scan the code below instead.",
459
+ "errors.walletDisconnected": "Your wallet disconnected. Reconnect it, or scan the code below to pay.",
460
+ "errors.walletDeclinedScanInstead": "Your wallet didn’t approve the payment. You can still pay by scanning the code below.",
461
+ "errors.unableToCreateCryptoTransaction": "We couldn't set up your payment. Please try again, or choose a different coin.",
462
+ "errors.cryptoTransactionNotCreated": "Your payment hasn’t been set up yet. Choose a coin and network to continue.",
463
+ "errors.unableToVerifyDetails": "We could not verify your details. Please try again or contact support.",
464
+ "errors.unableToRestoreDetails": "Unable to restore your details. Please try again.",
465
+ "errors.couldNotRestoreDetails": "We could not restore your details. Please try again or contact support.",
466
+ "validation.emailRequired": "Please enter your email address.",
467
+ "validation.firstNameRequired": "Please enter your legal first name.",
468
+ "validation.lastNameRequired": "Please enter your legal last name.",
469
+ "validation.countryRequired": "Please select your country.",
470
+ "validation.streetRequired": "Please enter your street address.",
471
+ "validation.cityRequired": "Please enter your city.",
472
+ "validation.regionRequired": "Please enter your state or region.",
473
+ "validation.postalCodeRequired": "Please enter your ZIP or postal code.",
474
+ "validation.documentFrontRequired": "Please upload the front image of the document.",
475
+ "validation.documentBackRequired": "Please upload the back image of the document.",
476
+ "validation.emailOrCountryMissing": "Email or country is missing.",
477
+ "validation.invalidEmail": "Please enter a valid email address.",
478
+ "validation.customerDetailsMissing": "Customer details are missing.",
479
+ "validation.invalidOtp": "Please enter a valid 6-digit code.",
480
+ "terms.notice": 'By continuing, you agree to Lydian <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Terms and Conditions</a> and understand your data will be processed according to the <a href="https://lydian.com/privacy" target="_blank" rel="noopener noreferrer">Privacy Notice</a>.'
481
+ }, f = { en: q }, D = "en";
482
+ let E = D;
483
+ function te() {
484
+ return E;
485
+ }
486
+ function v(t, e) {
487
+ var n;
488
+ const a = ((n = f[E]) == null ? void 0 : n[t]) ?? f[D][t] ?? t;
489
+ return e ? a.replace(
490
+ /\{(\w+)\}/g,
491
+ (o, r) => e[r] != null ? String(e[r]) : `{${r}}`
492
+ ) : a;
493
+ }
494
+ function B(t) {
495
+ return t === y.SUCCESS ? "succeeded" : t < y.PENDING && t !== y.KYC_VERIFICATION_PENDING ? "failed" : "active";
496
+ }
497
+ function _({
498
+ transaction: t,
499
+ session: e
500
+ }) {
501
+ var o, r, s;
502
+ const a = B(t.status);
503
+ if (a === "active")
504
+ return null;
505
+ if (a === "failed")
506
+ return {
507
+ outcome: a,
508
+ message: v("errors.paymentCouldNotComplete"),
509
+ failure: {
510
+ shouldEndCheckout: !0,
511
+ // Negative (non-KYC) status — cancelled / fraud / timeout.
512
+ reason: "blocked",
513
+ transactionID: t.transactionID,
514
+ redirectURL: m(e == null ? void 0 : e.failureURL)
515
+ }
516
+ };
517
+ const n = (o = t.payments) == null ? void 0 : o.find(
518
+ (i) => i.status === U.CONFIRMED
519
+ );
520
+ return {
521
+ outcome: a,
522
+ event: {
523
+ transactionID: t.transactionID,
524
+ asset: n == null ? void 0 : n.cryptoAsset,
525
+ network: n == null ? void 0 : n.cryptoNetwork
526
+ },
527
+ result: {
528
+ transactionID: t.transactionID,
529
+ amount: (r = t.amounts) == null ? void 0 : r.totalLocal,
530
+ currency: (s = t.amounts) == null ? void 0 : s.currency,
531
+ asset: n == null ? void 0 : n.cryptoAsset,
532
+ network: n == null ? void 0 : n.cryptoNetwork,
533
+ completedAt: n == null ? void 0 : n.completedAt,
534
+ redirectURL: m(e == null ? void 0 : e.successURL)
535
+ }
536
+ };
537
+ }
538
+ function K() {
539
+ let t = null;
540
+ return {
541
+ setOptions: (e) => {
542
+ t = e;
543
+ },
544
+ emit: (e, a) => T(t == null ? void 0 : t.onEvent, e, a),
545
+ paymentFailed: (e, a) => {
546
+ var n;
547
+ return (n = t == null ? void 0 : t.paymentFailedListener) == null ? void 0 : n.call(t, e, a);
548
+ },
549
+ paymentSucceeded: (e) => {
550
+ var a;
551
+ return (a = t == null ? void 0 : t.paymentSuccessListener) == null ? void 0 : a.call(t, e);
552
+ },
553
+ paymentCanceled: (e) => {
554
+ var a;
555
+ return (a = t == null ? void 0 : t.paymentCanceledListener) == null ? void 0 : a.call(t, e);
556
+ }
557
+ };
558
+ }
559
+ class j extends HTMLElement {
560
+ constructor() {
561
+ super(), this.engine = null, this.engineLoadPromise = null, this.isTornDown = !1, this.shadow = this.attachShadow({ mode: "open" });
562
+ }
563
+ // The same checkout element can be removed and re-added.
564
+ // Reset teardown state when it reconnects.
565
+ connectedCallback() {
566
+ this.isTornDown = !1;
567
+ }
568
+ async initialize(e) {
569
+ const a = H(e), n = z({ api: a, options: e }), o = await this.loadEngine(e, n);
570
+ !o || this.isTornDown || (this.engine = o, await o.initialize(e, { api: a, sessionLoad: n }));
571
+ }
572
+ async loadEngine(e, a) {
573
+ const n = this.getOrLoadEngine();
574
+ try {
575
+ return await n;
576
+ } catch {
577
+ return await this.handleEngineLoadFailure({
578
+ engineLoad: n,
579
+ options: e,
580
+ sessionLoad: a
581
+ }), null;
582
+ }
583
+ }
584
+ async updateTransaction(e) {
585
+ if (!this.engine)
586
+ throw new Error("Tether Pay not initialized.");
587
+ await this.engine.updateTransaction(e);
588
+ }
589
+ // A merchant SPA can unmount the element at any time; nothing else stops this
590
+ // instance's timers.
591
+ disconnectedCallback() {
592
+ this.isTornDown = !0, this.releaseEngine();
593
+ }
594
+ // Not started in the constructor: a page can carry the tag and never check out.
595
+ // Overlapping initialize() calls share one download.
596
+ getOrLoadEngine() {
597
+ return this.engineLoadPromise ?? (this.engineLoadPromise = import("./mountEngine-P1Ws89oo.js").then((e) => e.m).then((e) => {
598
+ const a = e.mountCheckoutEngine({
599
+ host: this,
600
+ shadowRoot: this.shadow
601
+ });
602
+ return this.isTornDown ? this.releaseEngine(a) : this.engine = a, a;
603
+ })), this.engineLoadPromise;
604
+ }
605
+ async handleEngineLoadFailure({
606
+ engineLoad: e,
607
+ options: a,
608
+ sessionLoad: n
609
+ }) {
610
+ this.engineLoadPromise === e && (this.engineLoadPromise = null, await this.reportEngineFailure({ options: a, sessionLoad: n }));
611
+ }
612
+ // A host that removed the element has walked away; a failure report could send
613
+ // it to a failureURL for a checkout it dismissed.
614
+ get isDismissedByHost() {
615
+ return this.isTornDown || !this.isConnected;
616
+ }
617
+ // No engine means no checkout: orchestration lives inside the React tree, and a
618
+ // customer with no UI has nothing left to do. What the merchant is still owed is
619
+ // an outcome the gateway has already decided — a session resumed after the
620
+ // payment settled must report that payment, not a dead checkout.
621
+ async reportEngineFailure({
622
+ options: e,
623
+ sessionLoad: a
624
+ }) {
625
+ if (this.isDismissedByHost)
626
+ return;
627
+ const n = await a;
628
+ if (this.isDismissedByHost)
629
+ return;
630
+ const o = K();
631
+ o.setOptions(e);
632
+ const r = n.ok && n.linkedTransaction ? _({
633
+ transaction: n.linkedTransaction,
634
+ session: n.session
635
+ }) : null;
636
+ if ((r == null ? void 0 : r.outcome) === "succeeded") {
637
+ o.emit("payment.succeeded", r.event), o.paymentSucceeded(r.result);
638
+ return;
639
+ }
640
+ if (r) {
641
+ o.emit("payment.failed", {
642
+ reason: r.failure.reason,
643
+ shouldEndCheckout: !0,
644
+ message: r.message
645
+ }), o.paymentFailed(r.message, r.failure);
646
+ return;
647
+ }
648
+ const s = v("errors.checkoutUnavailable"), i = Y({
649
+ message: s,
650
+ reason: "error",
651
+ shouldEndCheckout: !0,
652
+ session: n.ok ? n.session : null
653
+ });
654
+ o.emit("payment.failed", i.event), o.paymentFailed(s, i.failure);
655
+ }
656
+ // Always teardown and unmount together to avoid leaking the React engine.
657
+ // Clear the cached load so a later initialize() creates a fresh engine.
658
+ releaseEngine(e = this.engine) {
659
+ e == null || e.teardown(), e == null || e.unmount(), this.engine = null, this.engineLoadPromise = null;
660
+ }
661
+ }
662
+ function H(t) {
663
+ return new R(
664
+ O(t),
665
+ c(t) ? void 0 : t.publishableKey
666
+ );
667
+ }
668
+ function z({
669
+ api: t,
670
+ options: e
671
+ }) {
672
+ return F({
673
+ api: t,
674
+ options: e,
675
+ emit: (a, n) => T(e.onEvent, a, n)
676
+ });
677
+ }
678
+ customElements.get("lydian-checkout") || customElements.define("lydian-checkout", j);
679
+ function h() {
680
+ return document.querySelector("lydian-checkout");
681
+ }
682
+ async function G(t) {
683
+ if (!t.publishableKey || !t.transaction.amount || !t.transaction.currency)
684
+ throw new Error("SDK initialization requires publishableKey and a transaction");
685
+ const e = C(t);
686
+ if (e)
687
+ throw new Error(e);
688
+ if (!S(t.transaction.currency))
689
+ throw new Error("Invalid value for currency, valid values are: " + g.join(", "));
690
+ const a = b({
691
+ options: t,
692
+ unsupportedKeys: ["sessionID"],
693
+ entryPoint: "init"
694
+ });
695
+ if (a)
696
+ throw new Error(a);
697
+ await h().initialize(t);
698
+ }
699
+ async function Q(t) {
700
+ if (!t.sessionID)
701
+ throw new Error("initExistingSession requires a sessionID");
702
+ const e = C(t);
703
+ if (e)
704
+ throw new Error(e);
705
+ const a = b({
706
+ options: t,
707
+ unsupportedKeys: ["publishableKey", "transaction"],
708
+ entryPoint: "initExistingSession"
709
+ });
710
+ if (a)
711
+ throw new Error(a);
712
+ await h().initialize(t);
713
+ }
714
+ async function J(t) {
715
+ await h().updateTransaction(t);
716
+ }
717
+ window.Lydian = { init: G, initExistingSession: Q, updateTransaction: J };
718
+ export {
719
+ U as P,
720
+ y as T,
721
+ Z as a,
722
+ V as b,
723
+ g as c,
724
+ x as d,
725
+ $ as e,
726
+ M as f,
727
+ te as g,
728
+ c as h,
729
+ S as i,
730
+ B as j,
731
+ _ as k,
732
+ k as l,
733
+ ee as m,
734
+ Y as n,
735
+ X as o,
736
+ K as p,
737
+ W as r,
738
+ m as s,
739
+ v as t
740
+ };