@odus/checkout 0.30.0-beta.3 → 0.30.0-beta.4

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.
@@ -1,4 +1,4 @@
1
- import { l as fe, c as me, a as ye, f as q, d as be, C as A, I as pe, b as P, g as ve, S as _, e as ee, H as Se, V as te, h as D, A as Ce, P as Ee, E as Fe, i as Me, j as Ne, k as we, m as Pe, n as ke, o as Ae, F as xe, p as De, q as Ie } from "./shared.js";
1
+ import { l as fe, c as me, a as ye, f as j, d as be, C as A, I as pe, b as P, g as ve, S as _, e as ee, H as Se, V as te, h as D, A as Ce, P as Ee, E as Fe, i as Me, j as Ne, k as we, m as Pe, n as ke, o as Ae, F as xe, p as De, q as Ie } from "./shared.js";
2
2
  import { r as _t, s as Rt, t as Bt, u as Ut, v as Ot, w as Ht, x as zt, y as $t } from "./shared.js";
3
3
  const F = {
4
4
  // Checkout lifecycle events
@@ -20,30 +20,30 @@ const F = {
20
20
  PAYMENT_AUTHORIZATION_TIME: "payment.authorization_time",
21
21
  CHECKOUT_LOAD_TIME: "checkout.load_time",
22
22
  FORM_RENDER_TIME: "form.render_time"
23
- }, Te = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, Le = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Ve = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, Z = (i) => {
24
- if (!i)
23
+ }, Te = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, Le = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Ve = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, Z = (n) => {
24
+ if (!n)
25
25
  return [];
26
- const e = [], t = i.split(`
26
+ const e = [], t = n.split(`
27
27
  `);
28
28
  for (const s of t) {
29
29
  const a = s.trim();
30
30
  if (!a)
31
31
  continue;
32
- let n = Te.exec(a);
33
- if (n) {
32
+ let i = Te.exec(a);
33
+ if (i) {
34
34
  e.push({
35
- function: n[1] || "(anonymous)",
36
- filename: n[2],
37
- lineno: parseInt(n[3], 10),
38
- colno: parseInt(n[4], 10)
35
+ function: i[1] || "(anonymous)",
36
+ filename: i[2],
37
+ lineno: parseInt(i[3], 10),
38
+ colno: parseInt(i[4], 10)
39
39
  });
40
40
  continue;
41
41
  }
42
- n = Le.exec(a) ?? Ve.exec(a), n && e.push({
43
- function: n[1] || "(anonymous)",
44
- filename: n[2],
45
- lineno: parseInt(n[3], 10),
46
- colno: parseInt(n[4], 10)
42
+ i = Le.exec(a) ?? Ve.exec(a), i && e.push({
43
+ function: i[1] || "(anonymous)",
44
+ filename: i[2],
45
+ lineno: parseInt(i[3], 10),
46
+ colno: parseInt(i[4], 10)
47
47
  });
48
48
  }
49
49
  return e;
@@ -52,10 +52,10 @@ let z, $, X;
52
52
  const Be = () => {
53
53
  if (typeof navigator > "u")
54
54
  return {};
55
- const i = navigator.userAgent;
55
+ const n = navigator.userAgent;
56
56
  let e, t, s;
57
- i.includes("Firefox/") ? (e = "Firefox", t = i.match(/Firefox\/([\d.]+)/)?.[1]) : i.includes("Edg/") ? (e = "Edge", t = i.match(/Edg\/([\d.]+)/)?.[1]) : i.includes("Chrome/") ? (e = "Chrome", t = i.match(/Chrome\/([\d.]+)/)?.[1]) : i.includes("Safari/") && (e = "Safari", t = i.match(/Version\/([\d.]+)/)?.[1]), i.includes("Windows") ? s = "Windows" : i.includes("Mac OS") ? s = "macOS" : i.includes("Linux") ? s = "Linux" : i.includes("Android") ? s = "Android" : (i.includes("iPhone") || i.includes("iPad")) && (s = "iOS");
58
- const a = /Mobi|Android|iPhone|iPad/i.test(i) || void 0;
57
+ n.includes("Firefox/") ? (e = "Firefox", t = n.match(/Firefox\/([\d.]+)/)?.[1]) : n.includes("Edg/") ? (e = "Edge", t = n.match(/Edg\/([\d.]+)/)?.[1]) : n.includes("Chrome/") ? (e = "Chrome", t = n.match(/Chrome\/([\d.]+)/)?.[1]) : n.includes("Safari/") && (e = "Safari", t = n.match(/Version\/([\d.]+)/)?.[1]), n.includes("Windows") ? s = "Windows" : n.includes("Mac OS") ? s = "macOS" : n.includes("Linux") ? s = "Linux" : n.includes("Android") ? s = "Android" : (n.includes("iPhone") || n.includes("iPad")) && (s = "iOS");
58
+ const a = /Mobi|Android|iPhone|iPad/i.test(n) || void 0;
59
59
  return {
60
60
  name: e,
61
61
  version: t,
@@ -64,21 +64,21 @@ const Be = () => {
64
64
  language: navigator.language,
65
65
  viewportWidth: String(window.innerWidth),
66
66
  viewportHeight: String(window.innerHeight),
67
- userAgent: i
67
+ userAgent: n
68
68
  };
69
- }, Ue = () => typeof window > "u" ? {} : { url: window.location.href }, Oe = (i) => {
70
- z = void 0, X = void 0, $ = i.sessionTracking?.session ? { id: i.sessionTracking.session.id } : void 0;
71
- }, He = (i) => {
72
- z = i;
69
+ }, Ue = () => typeof window > "u" ? {} : { url: window.location.href }, Oe = (n) => {
70
+ z = void 0, X = void 0, $ = n.sessionTracking?.session ? { id: n.sessionTracking.session.id } : void 0;
71
+ }, He = (n) => {
72
+ z = n;
73
73
  }, ze = () => {
74
74
  z = void 0;
75
- }, $e = (i) => {
76
- $ = i;
77
- }, Ke = (i) => {
78
- X = i;
79
- }, qe = () => $?.id, je = (i) => ({
75
+ }, $e = (n) => {
76
+ $ = n;
77
+ }, Ke = (n) => {
78
+ X = n;
79
+ }, je = () => $?.id, qe = (n) => ({
80
80
  sdk: { name: _e, version: Re },
81
- app: i.app,
81
+ app: n.app,
82
82
  user: z,
83
83
  session: $,
84
84
  page: Ue(),
@@ -86,18 +86,18 @@ const Be = () => {
86
86
  view: X
87
87
  }), We = 30, Ye = 250, Ge = 6e4;
88
88
  let I = [], k = null, Q = 0, R = null, B = null;
89
- const Ze = (i) => {
89
+ const Ze = (n) => {
90
90
  if (k)
91
91
  return;
92
- const e = i.batching?.sendTimeout ?? Ye;
92
+ const e = n.batching?.sendTimeout ?? Ye;
93
93
  k = setTimeout(() => {
94
- K(i);
94
+ K(n);
95
95
  }, e);
96
- }, Je = (i, e) => {
96
+ }, Je = (n, e) => {
97
97
  const t = {
98
- meta: je(e)
98
+ meta: qe(e)
99
99
  };
100
- for (const s of i)
100
+ for (const s of n)
101
101
  switch (s.type) {
102
102
  case "exception":
103
103
  (t.exceptions ??= []).push(s.payload);
@@ -113,11 +113,11 @@ const Ze = (i) => {
113
113
  break;
114
114
  }
115
115
  return t;
116
- }, Xe = (i, e, t = !1) => {
117
- const s = JSON.stringify(i), a = qe(), n = {
116
+ }, Xe = (n, e, t = !1) => {
117
+ const s = JSON.stringify(n), a = je(), i = {
118
118
  "Content-Type": "application/json"
119
119
  };
120
- if (a && (n["x-faro-session-id"] = a), t && typeof navigator < "u" && navigator.sendBeacon) {
120
+ if (a && (i["x-faro-session-id"] = a), t && typeof navigator < "u" && navigator.sendBeacon) {
121
121
  const o = new Blob([s], { type: "application/json" });
122
122
  navigator.sendBeacon(e, o);
123
123
  return;
@@ -125,7 +125,7 @@ const Ze = (i) => {
125
125
  const r = s.length < Ge;
126
126
  fetch(e, {
127
127
  method: "POST",
128
- headers: n,
128
+ headers: i,
129
129
  body: s,
130
130
  keepalive: r
131
131
  }).then((o) => {
@@ -135,7 +135,7 @@ const Ze = (i) => {
135
135
  }
136
136
  }).catch(() => {
137
137
  });
138
- }, K = (i, e = !1) => {
138
+ }, K = (n, e = !1) => {
139
139
  if (k && (clearTimeout(k), k = null), I.length === 0)
140
140
  return;
141
141
  if (Date.now() < Q) {
@@ -145,35 +145,35 @@ const Ze = (i) => {
145
145
  const t = I;
146
146
  I = [];
147
147
  try {
148
- let s = Je(t, i);
149
- if (i.beforeSend) {
150
- const a = i.beforeSend(s);
148
+ let s = Je(t, n);
149
+ if (n.beforeSend) {
150
+ const a = n.beforeSend(s);
151
151
  if (!a)
152
152
  return;
153
153
  s = a;
154
154
  }
155
- Xe(s, i.url, e);
155
+ Xe(s, n.url, e);
156
156
  } catch {
157
157
  }
158
- }, w = (i, e) => {
159
- I.push(i);
158
+ }, w = (n, e) => {
159
+ I.push(n);
160
160
  const t = e.batching?.itemLimit ?? We;
161
161
  if (I.length >= t) {
162
162
  K(e);
163
163
  return;
164
164
  }
165
165
  Ze(e);
166
- }, Qe = (i) => {
166
+ }, Qe = (n) => {
167
167
  if (I = [], Q = 0, k && (clearTimeout(k), k = null), typeof document > "u")
168
168
  return;
169
169
  R && document.removeEventListener("visibilitychange", R), B && window.removeEventListener("pagehide", B);
170
- const e = () => K(i, !0);
170
+ const e = () => K(n, !0);
171
171
  R = () => {
172
172
  document.visibilityState === "hidden" && e();
173
173
  }, B = e, document.addEventListener("visibilitychange", R), window.addEventListener("pagehide", B);
174
174
  }, ne = () => (/* @__PURE__ */ new Date()).toISOString();
175
175
  let ie = null, ae = null;
176
- const et = (i) => {
176
+ const et = (n) => {
177
177
  typeof window > "u" || (ie = (e) => {
178
178
  const t = e.error instanceof Error ? e.error : new Error(e.message);
179
179
  w({
@@ -184,7 +184,7 @@ const et = (i) => {
184
184
  timestamp: ne(),
185
185
  stacktrace: t.stack ? { frames: Z(t.stack) } : void 0
186
186
  }
187
- }, i);
187
+ }, n);
188
188
  }, ae = (e) => {
189
189
  const t = e.reason, s = t instanceof Error ? t : new Error(String(t));
190
190
  w({
@@ -196,38 +196,38 @@ const et = (i) => {
196
196
  stacktrace: s.stack ? { frames: Z(s.stack) } : void 0,
197
197
  context: { source: "unhandledrejection" }
198
198
  }
199
- }, i);
199
+ }, n);
200
200
  }, window.addEventListener("error", ie), window.addEventListener("unhandledrejection", ae));
201
- }, re = "odus_telemetry_session_id", j = () => {
202
- const i = new Uint8Array(16);
203
- return crypto.getRandomValues(i), Array.from(i, (e) => e.toString(16).padStart(2, "0")).join("");
204
- }, tt = (i) => {
205
- if (i)
206
- return i;
201
+ }, re = "odus_telemetry_session_id", q = () => {
202
+ const n = new Uint8Array(16);
203
+ return crypto.getRandomValues(n), Array.from(n, (e) => e.toString(16).padStart(2, "0")).join("");
204
+ }, tt = (n) => {
205
+ if (n)
206
+ return n;
207
207
  if (typeof sessionStorage > "u")
208
- return j();
208
+ return q();
209
209
  try {
210
210
  const e = sessionStorage.getItem(re);
211
211
  if (e)
212
212
  return e;
213
- const t = j();
213
+ const t = q();
214
214
  return sessionStorage.setItem(re, t), t;
215
215
  } catch {
216
- return j();
216
+ return q();
217
217
  }
218
- }, st = (i) => {
219
- if (!i.sessionTracking?.enabled)
218
+ }, st = (n) => {
219
+ if (!n.sessionTracking?.enabled)
220
220
  return;
221
- const e = tt(i.sessionTracking.session?.id);
221
+ const e = tt(n.sessionTracking.session?.id);
222
222
  $e({ id: e });
223
- }, W = () => (/* @__PURE__ */ new Date()).toISOString(), Y = (i, e) => {
224
- if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(i))
223
+ }, W = () => (/* @__PURE__ */ new Date()).toISOString(), Y = (n, e) => {
224
+ if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(n))
225
225
  return;
226
226
  new PerformanceObserver((s) => {
227
227
  for (const a of s.getEntries())
228
228
  e(a);
229
- }).observe({ type: i, buffered: !0 });
230
- }, nt = (i) => {
229
+ }).observe({ type: n, buffered: !0 });
230
+ }, nt = (n) => {
231
231
  if (typeof window > "u")
232
232
  return;
233
233
  Y("largest-contentful-paint", (t) => {
@@ -238,7 +238,7 @@ const et = (i) => {
238
238
  values: { lcp: t.startTime },
239
239
  timestamp: W()
240
240
  }
241
- }, i);
241
+ }, n);
242
242
  });
243
243
  let e = 0;
244
244
  Y("layout-shift", (t) => {
@@ -250,7 +250,7 @@ const et = (i) => {
250
250
  values: { cls: e },
251
251
  timestamp: W()
252
252
  }
253
- }, i));
253
+ }, n));
254
254
  }), Y("event", (t) => {
255
255
  const s = t;
256
256
  s.duration > 0 && w({
@@ -260,20 +260,20 @@ const et = (i) => {
260
260
  values: { inp: s.duration },
261
261
  timestamp: W()
262
262
  }
263
- }, i);
263
+ }, n);
264
264
  });
265
265
  }, H = {
266
266
  INFO: "info",
267
267
  WARN: "warn",
268
268
  ERROR: "error"
269
- }, U = () => (/* @__PURE__ */ new Date()).toISOString(), it = (i) => {
270
- Oe(i), Qe(i);
271
- const e = i.instrumentations ?? {
269
+ }, U = () => (/* @__PURE__ */ new Date()).toISOString(), it = (n) => {
270
+ Oe(n), Qe(n);
271
+ const e = n.instrumentations ?? {
272
272
  errors: !0,
273
273
  webVitals: !0,
274
274
  session: !0
275
275
  };
276
- return e.session !== !1 && st(i), e.errors !== !1 && et(i), e.webVitals !== !1 && nt(i), {
276
+ return e.session !== !1 && st(n), e.errors !== !1 && et(n), e.webVitals !== !1 && nt(n), {
277
277
  pushError(t, s) {
278
278
  w({
279
279
  type: "exception",
@@ -284,7 +284,7 @@ const et = (i) => {
284
284
  stacktrace: t.stack ? { frames: Z(t.stack) } : void 0,
285
285
  context: s?.context
286
286
  }
287
- }, i);
287
+ }, n);
288
288
  },
289
289
  pushEvent(t, s) {
290
290
  w({
@@ -294,7 +294,7 @@ const et = (i) => {
294
294
  timestamp: U(),
295
295
  attributes: s
296
296
  }
297
- }, i);
297
+ }, n);
298
298
  },
299
299
  pushMeasurement(t) {
300
300
  w({
@@ -305,7 +305,7 @@ const et = (i) => {
305
305
  timestamp: U(),
306
306
  context: t.context
307
307
  }
308
- }, i);
308
+ }, n);
309
309
  },
310
310
  pushLog(t, s) {
311
311
  w({
@@ -316,7 +316,7 @@ const et = (i) => {
316
316
  timestamp: U(),
317
317
  context: s?.context
318
318
  }
319
- }, i);
319
+ }, n);
320
320
  },
321
321
  setUser(t) {
322
322
  He(t);
@@ -328,33 +328,33 @@ const et = (i) => {
328
328
  Ke(t);
329
329
  },
330
330
  flush() {
331
- K(i);
331
+ K(n);
332
332
  }
333
333
  };
334
- }, at = (i) => i === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", rt = () => {
334
+ }, at = (n) => n === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", rt = () => {
335
335
  if (typeof window > "u")
336
336
  return !1;
337
- const i = window.location.hostname;
338
- return i === "localhost" || i === "127.0.0.1" || i === "0.0.0.0" || i === "::1" || i === "[::1]" || i.endsWith(".localhost");
337
+ const n = window.location.hostname;
338
+ return n === "localhost" || n === "127.0.0.1" || n === "0.0.0.0" || n === "::1" || n === "[::1]" || n.endsWith(".localhost");
339
339
  };
340
340
  let C = null;
341
- const ot = (i) => {
341
+ const ot = (n) => {
342
342
  if (C)
343
343
  return C;
344
344
  if (rt())
345
345
  return null;
346
- const e = at(i.environment);
346
+ const e = at(n.environment);
347
347
  return C = it({
348
348
  url: e,
349
349
  app: {
350
350
  name: "odus-checkout",
351
- environment: i.environment === "test" ? "sandbox" : "production"
351
+ environment: n.environment === "test" ? "sandbox" : "production"
352
352
  },
353
353
  isolate: !0,
354
354
  sessionTracking: {
355
355
  enabled: !0,
356
356
  session: {
357
- id: i.sessionId
357
+ id: n.sessionId
358
358
  }
359
359
  },
360
360
  beforeSend: (t) => {
@@ -368,35 +368,35 @@ const ot = (i) => {
368
368
  "card",
369
369
  "cvv",
370
370
  "pan"
371
- ].forEach((n) => {
372
- s.searchParams.has(n) && s.searchParams.set(n, "[REDACTED]");
371
+ ].forEach((i) => {
372
+ s.searchParams.has(i) && s.searchParams.set(i, "[REDACTED]");
373
373
  }), t.meta.view.name = s.toString();
374
374
  } catch {
375
375
  }
376
376
  return t;
377
377
  }
378
378
  }), C;
379
- }, lt = (i, e) => {
380
- C && C.pushError(i, { context: e });
381
- }, M = (i, e) => {
382
- C && C.pushEvent(i, e);
383
- }, oe = (i, e, t, s) => {
379
+ }, lt = (n, e) => {
380
+ C && C.pushError(n, { context: e });
381
+ }, M = (n, e) => {
382
+ C && C.pushEvent(n, e);
383
+ }, oe = (n, e, t, s) => {
384
384
  C && C.pushMeasurement({
385
- type: i,
386
- values: { [i]: e },
385
+ type: n,
386
+ values: { [n]: e },
387
387
  context: {
388
388
  ...t && { unit: t },
389
389
  ...s
390
390
  }
391
391
  });
392
- }, Tt = (i, e = "info", t) => {
392
+ }, Tt = (n, e = "info", t) => {
393
393
  if (!C) return;
394
394
  const s = {
395
395
  info: H.INFO,
396
396
  warn: H.WARN,
397
397
  error: H.ERROR
398
398
  };
399
- C.pushLog([i], {
399
+ C.pushLog([n], {
400
400
  level: s[e],
401
401
  context: t
402
402
  });
@@ -441,7 +441,7 @@ class L {
441
441
  if (!this.vgsForm)
442
442
  throw new Error("VGS form not initialized");
443
443
  if (e.cardNumber) {
444
- const n = this.vgsForm.cardNumberField(e.cardNumber, {
444
+ const i = this.vgsForm.cardNumberField(e.cardNumber, {
445
445
  placeholder: s.cardNumber,
446
446
  autoComplete: "cc-number",
447
447
  validations: ["required", "validCardNumber"],
@@ -481,12 +481,12 @@ class L {
481
481
  ],
482
482
  css: t.cardNumber
483
483
  });
484
- n.on("update", (r) => {
484
+ i.on("update", (r) => {
485
485
  a && a(L.mapCardType(r.cardType));
486
- }), this.fields.push(n);
486
+ }), this.fields.push(i);
487
487
  }
488
488
  if (e.cardExpiry) {
489
- const n = this.vgsForm.cardExpirationDateField(
489
+ const i = this.vgsForm.cardExpirationDateField(
490
490
  e.cardExpiry,
491
491
  {
492
492
  placeholder: s.cardExpiry,
@@ -501,19 +501,19 @@ class L {
501
501
  css: t.cardExpiry
502
502
  }
503
503
  );
504
- this.fields.push(n);
504
+ this.fields.push(i);
505
505
  }
506
506
  if (e.cardCvv) {
507
- const n = this.vgsForm.cardCVCField(e.cardCvv, {
507
+ const i = this.vgsForm.cardCVCField(e.cardCvv, {
508
508
  placeholder: s.cardCvv,
509
509
  autoComplete: "cc-csc",
510
510
  validations: ["required", "validCardSecurityCode"],
511
511
  css: t.cardCvv
512
512
  });
513
- this.fields.push(n);
513
+ this.fields.push(i);
514
514
  }
515
515
  if (e.cardholderName) {
516
- const n = this.vgsForm.cardholderNameField(
516
+ const i = this.vgsForm.cardholderNameField(
517
517
  e.cardholderName,
518
518
  {
519
519
  placeholder: s.cardholderName,
@@ -522,7 +522,7 @@ class L {
522
522
  css: t.cardholderName
523
523
  }
524
524
  );
525
- this.fields.push(n);
525
+ this.fields.push(i);
526
526
  }
527
527
  }
528
528
  waitForFieldsReady() {
@@ -535,7 +535,7 @@ class L {
535
535
  return new Promise((s, a) => {
536
536
  t.createCard(
537
537
  { auth: e },
538
- (n, r) => {
538
+ (i, r) => {
539
539
  if (r?.errors) {
540
540
  a(r.errors);
541
541
  return;
@@ -545,14 +545,14 @@ class L {
545
545
  a(new Error("Card creation failed: no card ID returned"));
546
546
  return;
547
547
  }
548
- if (n === 303) {
548
+ if (i === 303) {
549
549
  this.patchCard(e, o.id).then(s).catch(a);
550
550
  return;
551
551
  }
552
552
  s(L.extractCardResult(o));
553
553
  },
554
- (n) => {
555
- a(n);
554
+ (i) => {
555
+ a(i);
556
556
  }
557
557
  );
558
558
  });
@@ -561,7 +561,7 @@ class L {
561
561
  if (!this.vgsForm || !this.environment)
562
562
  return Promise.reject(new Error("VGS not initialized"));
563
563
  const s = this.vgsForm;
564
- return new Promise((a, n) => {
564
+ return new Promise((a, i) => {
565
565
  s.submit(
566
566
  `/cards/${t}`,
567
567
  {
@@ -584,22 +584,22 @@ class L {
584
584
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
585
585
  (r, o) => {
586
586
  if (r >= 400 || o?.errors) {
587
- n(o?.errors ?? new Error("Card update failed"));
587
+ i(o?.errors ?? new Error("Card update failed"));
588
588
  return;
589
589
  }
590
590
  const d = o?.data;
591
591
  if (!d?.id) {
592
- n(new Error("Card update failed: no card ID returned"));
592
+ i(new Error("Card update failed: no card ID returned"));
593
593
  return;
594
594
  }
595
- const c = L.extractCardResult(d), u = o.included?.find(
595
+ const c = L.extractCardResult(d), m = o.included?.find(
596
596
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
597
597
  (S) => S.type === "card_updates"
598
598
  );
599
- u?.attributes?.updated_values?.length && (c.updatedValues = u.attributes.updated_values), a(c);
599
+ m?.attributes?.updated_values?.length && (c.updatedValues = m.attributes.updated_values), a(c);
600
600
  },
601
601
  (r) => {
602
- n(r);
602
+ i(r);
603
603
  }
604
604
  );
605
605
  });
@@ -633,11 +633,11 @@ class L {
633
633
  }[e] ?? "unknown" : "unknown";
634
634
  }
635
635
  }
636
- function G(i) {
636
+ function G(n) {
637
637
  return {
638
638
  name: "Custom Appearance",
639
- additionalPaymentMethods: i.additionalPaymentMethods || {},
640
- styles: i.styles || {
639
+ additionalPaymentMethods: n.additionalPaymentMethods || {},
640
+ styles: n.styles || {
641
641
  fontSize: 14,
642
642
  textColor: "#000000",
643
643
  buttonColor: "#0070f3",
@@ -647,102 +647,104 @@ function G(i) {
647
647
  buttonFontSize: 16
648
648
  },
649
649
  layout: {
650
- grouped: i.layout?.grouped,
651
- actionButton: i.layout?.actionButton || {
650
+ grouped: n.layout?.grouped,
651
+ actionButton: n.layout?.actionButton || {
652
652
  translationKey: null
653
653
  },
654
- phoneNumber: i.layout?.phoneNumber ? {
655
- enabled: i.layout.phoneNumber.enabled,
656
- label: i.layout.phoneNumber.label,
657
- defaultCountry: i.layout.phoneNumber.defaultCountry,
658
- allowedCountries: i.layout.phoneNumber.allowedCountries
654
+ phoneNumber: n.layout?.phoneNumber ? {
655
+ enabled: n.layout.phoneNumber.enabled,
656
+ label: n.layout.phoneNumber.label,
657
+ defaultCountry: n.layout.phoneNumber.defaultCountry,
658
+ allowedCountries: n.layout.phoneNumber.allowedCountries
659
659
  } : void 0,
660
660
  billingFields: {
661
661
  street: {
662
- enabled: i.layout?.billingFields?.street?.enabled ?? !1,
663
- label: i.layout?.billingFields?.street?.label
662
+ enabled: n.layout?.billingFields?.street?.enabled ?? !1,
663
+ label: n.layout?.billingFields?.street?.label,
664
+ maxLength: n.layout?.billingFields?.street?.maxLength
664
665
  },
665
666
  city: {
666
- enabled: i.layout?.billingFields?.city?.enabled ?? !1,
667
- label: i.layout?.billingFields?.city?.label
667
+ enabled: n.layout?.billingFields?.city?.enabled ?? !1,
668
+ label: n.layout?.billingFields?.city?.label
668
669
  },
669
670
  state: {
670
- enabled: i.layout?.billingFields?.state?.enabled ?? !1,
671
- label: i.layout?.billingFields?.state?.label,
672
- hiddenForCountries: i.layout?.billingFields?.state?.hiddenForCountries
671
+ enabled: n.layout?.billingFields?.state?.enabled ?? !1,
672
+ label: n.layout?.billingFields?.state?.label,
673
+ hiddenForCountries: n.layout?.billingFields?.state?.hiddenForCountries
673
674
  },
674
675
  zipCode: {
675
- enabled: i.layout?.billingFields?.zipCode?.enabled ?? !1,
676
- label: i.layout?.billingFields?.zipCode?.label
676
+ enabled: n.layout?.billingFields?.zipCode?.enabled ?? !1,
677
+ label: n.layout?.billingFields?.zipCode?.label
677
678
  },
678
679
  firstName: {
679
- enabled: i.layout?.billingFields?.firstName?.enabled ?? !1,
680
- label: i.layout?.billingFields?.firstName?.label
680
+ enabled: n.layout?.billingFields?.firstName?.enabled ?? !1,
681
+ label: n.layout?.billingFields?.firstName?.label
681
682
  },
682
683
  lastName: {
683
- enabled: i.layout?.billingFields?.lastName?.enabled ?? !1,
684
- label: i.layout?.billingFields?.lastName?.label
684
+ enabled: n.layout?.billingFields?.lastName?.enabled ?? !1,
685
+ label: n.layout?.billingFields?.lastName?.label
685
686
  },
686
687
  country: {
687
- enabled: i.layout?.billingFields?.country?.enabled ?? !1,
688
- label: i.layout?.billingFields?.country?.label,
689
- options: i.layout?.billingFields?.country?.options
688
+ enabled: n.layout?.billingFields?.country?.enabled ?? !1,
689
+ label: n.layout?.billingFields?.country?.label,
690
+ options: n.layout?.billingFields?.country?.options
690
691
  }
691
692
  },
692
- shippingFields: i.layout?.shippingFields ? {
693
+ shippingFields: n.layout?.shippingFields ? {
693
694
  street: {
694
- enabled: i.layout.shippingFields.street?.enabled ?? !1,
695
- label: i.layout.shippingFields.street?.label
695
+ enabled: n.layout.shippingFields.street?.enabled ?? !1,
696
+ label: n.layout.shippingFields.street?.label,
697
+ maxLength: n.layout.shippingFields.street?.maxLength
696
698
  },
697
699
  firstName: {
698
- enabled: i.layout.shippingFields.firstName?.enabled ?? !1,
699
- label: i.layout.shippingFields.firstName?.label
700
+ enabled: n.layout.shippingFields.firstName?.enabled ?? !1,
701
+ label: n.layout.shippingFields.firstName?.label
700
702
  },
701
703
  lastName: {
702
- enabled: i.layout.shippingFields.lastName?.enabled ?? !1,
703
- label: i.layout.shippingFields.lastName?.label
704
+ enabled: n.layout.shippingFields.lastName?.enabled ?? !1,
705
+ label: n.layout.shippingFields.lastName?.label
704
706
  },
705
707
  city: {
706
- enabled: i.layout.shippingFields.city?.enabled ?? !1,
707
- label: i.layout.shippingFields.city?.label
708
+ enabled: n.layout.shippingFields.city?.enabled ?? !1,
709
+ label: n.layout.shippingFields.city?.label
708
710
  },
709
711
  state: {
710
- enabled: i.layout.shippingFields.state?.enabled ?? !1,
711
- label: i.layout.shippingFields.state?.label,
712
- hiddenForCountries: i.layout.shippingFields.state?.hiddenForCountries
712
+ enabled: n.layout.shippingFields.state?.enabled ?? !1,
713
+ label: n.layout.shippingFields.state?.label,
714
+ hiddenForCountries: n.layout.shippingFields.state?.hiddenForCountries
713
715
  },
714
716
  zipCode: {
715
- enabled: i.layout.shippingFields.zipCode?.enabled ?? !1,
716
- label: i.layout.shippingFields.zipCode?.label
717
+ enabled: n.layout.shippingFields.zipCode?.enabled ?? !1,
718
+ label: n.layout.shippingFields.zipCode?.label
717
719
  },
718
720
  country: {
719
- enabled: i.layout.shippingFields.country?.enabled ?? !1,
720
- label: i.layout.shippingFields.country?.label,
721
- options: i.layout.shippingFields.country?.options
721
+ enabled: n.layout.shippingFields.country?.enabled ?? !1,
722
+ label: n.layout.shippingFields.country?.label,
723
+ options: n.layout.shippingFields.country?.options
722
724
  }
723
725
  } : void 0
724
726
  },
725
727
  appearance: {
726
- additionalPaymentMethods: i.additionalPaymentMethods ? {
727
- applePay: i.additionalPaymentMethods.applePay ? {
728
- displayName: i.additionalPaymentMethods.applePay.displayName,
729
- requiredBillingContactFields: i.additionalPaymentMethods.applePay.requiredBillingContactFields,
730
- requiredShippingContactFields: i.additionalPaymentMethods.applePay.requiredShippingContactFields
728
+ additionalPaymentMethods: n.additionalPaymentMethods ? {
729
+ applePay: n.additionalPaymentMethods.applePay ? {
730
+ displayName: n.additionalPaymentMethods.applePay.displayName,
731
+ requiredBillingContactFields: n.additionalPaymentMethods.applePay.requiredBillingContactFields,
732
+ requiredShippingContactFields: n.additionalPaymentMethods.applePay.requiredShippingContactFields
731
733
  } : void 0
732
734
  } : void 0
733
735
  }
734
736
  };
735
737
  }
736
738
  function dt({
737
- appearance: i
739
+ appearance: n
738
740
  }) {
739
741
  const e = me({
740
742
  checkoutProfile: void 0,
741
743
  isLoading: !0,
742
744
  error: null
743
745
  });
744
- if (i) {
745
- const s = G(i);
746
+ if (n) {
747
+ const s = G(n);
746
748
  return Promise.resolve().then(() => {
747
749
  e.setState({
748
750
  checkoutProfile: s,
@@ -753,9 +755,9 @@ function dt({
753
755
  getState: e.getState.bind(e),
754
756
  subscribe: e.subscribe.bind(e),
755
757
  updateProfile: (a) => {
756
- const n = G(a);
758
+ const i = G(a);
757
759
  e.setState({
758
- checkoutProfile: n,
760
+ checkoutProfile: i,
759
761
  isLoading: !1,
760
762
  error: null
761
763
  });
@@ -814,7 +816,7 @@ function dt({
814
816
  };
815
817
  }
816
818
  const ct = () => {
817
- const i = ye(), e = me({
819
+ const n = ye(), e = me({
818
820
  formData: {
819
821
  name: "",
820
822
  email: "",
@@ -831,62 +833,62 @@ const ct = () => {
831
833
  cardCvv: !1
832
834
  },
833
835
  isValid: !1
834
- }), t = (l, p, y, m) => {
836
+ }), t = (l, p, y, u) => {
835
837
  if (l === "cardCvv")
836
- return i.cardCvv(p, y);
837
- if (l === "phoneNumber" && m)
838
- return i.phoneNumber(p, m);
839
- const g = i[l];
838
+ return n.cardCvv(p, y);
839
+ if (l === "phoneNumber" && u)
840
+ return n.phoneNumber(p, u);
841
+ const g = n[l];
840
842
  return g?.(p);
841
843
  }, s = (l) => {
842
844
  const p = {};
843
- return Object.keys(l).forEach((m) => {
844
- const g = l[m];
845
+ return Object.keys(l).forEach((u) => {
846
+ const g = l[u];
845
847
  if (g === void 0) return;
846
848
  let h;
847
- m === "cardCvv" ? h = t(m, g, l.cardNumber) : m === "phoneNumber" ? h = t(
848
- m,
849
+ u === "cardCvv" ? h = t(u, g, l.cardNumber) : u === "phoneNumber" ? h = t(
850
+ u,
849
851
  g,
850
852
  void 0,
851
853
  l.phoneCountryCode
852
- ) : h = t(m, g), h && (p[m] = h);
854
+ ) : h = t(u, g), h && (p[u] = h);
853
855
  }), [
854
856
  "billingAddress",
855
857
  "shippingAddress"
856
- ].forEach((m) => {
857
- const g = l[m];
858
+ ].forEach((u) => {
859
+ const g = l[u];
858
860
  if (g && typeof g == "object") {
859
861
  const h = {};
860
862
  Object.keys(g).forEach(
861
863
  (b) => {
862
864
  const f = g[b];
863
865
  if (f === void 0) return;
864
- const v = i[b];
866
+ const v = n[b];
865
867
  if (v) {
866
- const E = b === "state" ? i.state(f, g.country) : v(
868
+ const E = b === "state" ? n.state(f, g.country) : v(
867
869
  f
868
870
  );
869
871
  E && (h[b] = E);
870
872
  }
871
873
  }
872
- ), Object.keys(h).length > 0 && (p[m] = h);
874
+ ), Object.keys(h).length > 0 && (p[u] = h);
873
875
  }
874
876
  }), p;
875
877
  }, a = (l) => {
876
878
  const p = s(l);
877
879
  return Object.keys(p).length === 0;
878
- }, n = "billingAddress.", r = "shippingAddress.", o = (l) => l.startsWith(n) ? {
880
+ }, i = "billingAddress.", r = "shippingAddress.", o = (l) => l.startsWith(i) ? {
879
881
  parent: "billingAddress",
880
- field: l.slice(n.length)
882
+ field: l.slice(i.length)
881
883
  } : l.startsWith(r) ? {
882
884
  parent: "shippingAddress",
883
885
  field: l.slice(r.length)
884
- } : null, d = (l, p, y, m) => {
886
+ } : null, d = (l, p, y, u) => {
885
887
  const g = { ...l };
886
- if (m)
888
+ if (u)
887
889
  g[p] = {
888
890
  ...g[p],
889
- [y]: m
891
+ [y]: u
890
892
  };
891
893
  else {
892
894
  const h = {
@@ -897,14 +899,14 @@ const ct = () => {
897
899
  return g;
898
900
  }, c = (l, p) => {
899
901
  const y = e.getState();
900
- let m = p;
902
+ let u = p;
901
903
  const g = o(l);
902
- if (!g && l in q)
904
+ if (!g && l in j)
903
905
  if (l === "cardCvv") {
904
906
  const v = be(y.formData.cardNumber) === "amex" ? 4 : 3;
905
- m = q.cardCvv(p, v);
907
+ u = j.cardCvv(p, v);
906
908
  } else
907
- m = q[l](p);
909
+ u = j[l](p);
908
910
  let h;
909
911
  if (g) {
910
912
  const { parent: f, field: v } = g;
@@ -912,13 +914,13 @@ const ct = () => {
912
914
  ...y.formData,
913
915
  [f]: {
914
916
  ...y.formData[f] ?? {},
915
- [v]: m
917
+ [v]: u
916
918
  }
917
919
  };
918
920
  } else
919
921
  h = {
920
922
  ...y.formData,
921
- [l]: m
923
+ [l]: u
922
924
  };
923
925
  let b = { ...y.errors };
924
926
  if (l === "phoneCountryCode" && h.phoneNumber) {
@@ -926,7 +928,7 @@ const ct = () => {
926
928
  "phoneNumber",
927
929
  h.phoneNumber,
928
930
  void 0,
929
- m
931
+ u
930
932
  );
931
933
  f ? b.phoneNumber = f : delete b.phoneNumber;
932
934
  }
@@ -935,32 +937,32 @@ const ct = () => {
935
937
  const { parent: f, field: v } = g, E = h[f];
936
938
  let N;
937
939
  if (v === "state")
938
- N = i.state(m, E?.country);
940
+ N = n.state(u, E?.country);
939
941
  else {
940
- const x = i[v];
942
+ const x = n[v];
941
943
  N = x ? x(
942
- m
944
+ u
943
945
  ) : void 0;
944
946
  }
945
947
  b = d(b, f, v, N);
946
948
  } else {
947
949
  let f;
948
- l === "cardCvv" ? f = t(l, m, h.cardNumber) : l === "phoneNumber" ? f = t(
950
+ l === "cardCvv" ? f = t(l, u, h.cardNumber) : l === "phoneNumber" ? f = t(
949
951
  l,
950
- m,
952
+ u,
951
953
  void 0,
952
954
  h.phoneCountryCode
953
- ) : f = t(l, m), f ? b[l] = f : delete b[l];
955
+ ) : f = t(l, u), f ? b[l] = f : delete b[l];
954
956
  }
955
957
  e.setState({
956
958
  formData: h,
957
959
  errors: b,
958
960
  isValid: a(h)
959
961
  });
960
- }, u = (l, p) => {
961
- const y = e.getState(), m = o(l);
962
- if (m) {
963
- const { parent: f, field: v } = m, E = {
962
+ }, m = (l, p) => {
963
+ const y = e.getState(), u = o(l);
964
+ if (u) {
965
+ const { parent: f, field: v } = u, E = {
964
966
  ...y.formData,
965
967
  [f]: {
966
968
  ...y.formData[f] ?? {},
@@ -970,9 +972,9 @@ const ct = () => {
970
972
  let N;
971
973
  if (v === "state") {
972
974
  const V = E[f];
973
- N = i.state(p, V?.country);
975
+ N = n.state(p, V?.country);
974
976
  } else {
975
- const V = i[v];
977
+ const V = n[v];
976
978
  N = V ? V(p) : void 0;
977
979
  }
978
980
  const x = d(y.errors, f, v, N);
@@ -1017,33 +1019,33 @@ const ct = () => {
1017
1019
  getFormState: e.getState.bind(e),
1018
1020
  subscribe: e.subscribe.bind(e),
1019
1021
  handleChange: c,
1020
- handleBlur: u,
1022
+ handleBlur: m,
1021
1023
  setFormData: S,
1022
1024
  reset: e.resetState.bind(e)
1023
1025
  };
1024
1026
  }, ht = "https://fonts.googleapis.com/css2", ut = /src:\s*url\(([^)]+\.woff2[^)]*)\)/, mt = /\/\*\s*latin\s*\*\/\s*@font-face\s*\{[^}]*src:\s*url\(([^)]+\.woff2[^)]*)\)[^}]*\}/;
1025
- async function pt(i) {
1026
- if (!i) return null;
1027
- const e = i.trim().replace(/\s+/g, "+"), t = `${ht}?family=${e}:wght@400;700&display=swap`;
1027
+ async function pt(n) {
1028
+ if (!n) return null;
1029
+ const e = n.trim().replace(/\s+/g, "+"), t = `${ht}?family=${e}:wght@400;700&display=swap`;
1028
1030
  try {
1029
1031
  const s = await fetch(t);
1030
1032
  if (!s.ok) return null;
1031
- const a = await s.text(), n = mt.exec(a);
1032
- if (n?.[1]) return n[1];
1033
+ const a = await s.text(), i = mt.exec(a);
1034
+ if (i?.[1]) return i[1];
1033
1035
  const r = ut.exec(a);
1034
1036
  return r?.[1] ? r[1] : null;
1035
1037
  } catch {
1036
1038
  return null;
1037
1039
  }
1038
1040
  }
1039
- function gt(i) {
1040
- if (!i) return !1;
1041
- const { billingFields: e, shippingFields: t } = i, s = e && Object.values(e).some((n) => n?.enabled), a = t && Object.values(t).some((n) => n?.enabled);
1041
+ function gt(n) {
1042
+ if (!n) return !1;
1043
+ const { billingFields: e, shippingFields: t } = n, s = e && Object.values(e).some((i) => i?.enabled), a = t && Object.values(t).some((i) => i?.enabled);
1042
1044
  return !!(s || a);
1043
1045
  }
1044
- function J(i) {
1045
- if (!i) return !1;
1046
- const { billingFields: e, shippingFields: t } = i, s = e?.firstName?.enabled && e?.lastName?.enabled, a = t?.firstName?.enabled && t?.lastName?.enabled;
1046
+ function J(n) {
1047
+ if (!n) return !1;
1048
+ const { billingFields: e, shippingFields: t } = n, s = e?.firstName?.enabled && e?.lastName?.enabled, a = t?.firstName?.enabled && t?.lastName?.enabled;
1047
1049
  return !!(s || a);
1048
1050
  }
1049
1051
  const O = /* @__PURE__ */ new Set(["US", "CA"]);
@@ -1062,25 +1064,25 @@ class ce extends A {
1062
1064
  stateStyles;
1063
1065
  constructor(e) {
1064
1066
  super("div", ["address-section"]), this.type = e.type, this.onChange = e.onChange, this.onBlur = e.onBlur, this.translationFunc = e.translationFunc, this.locale = e.locale, this.grouped = e.grouped ?? !0;
1065
- const { title: t, checkoutProfile: s, fieldsConfig: a, values: n, errors: r, touched: o } = e;
1067
+ const { title: t, checkoutProfile: s, fieldsConfig: a, values: i, errors: r, touched: o } = e;
1066
1068
  if (this.grouped) {
1067
1069
  const d = document.createElement("h3");
1068
1070
  d.className = "address-section-title", d.textContent = t, d.style.color = s.styles.textColor, d.style.fontFamily = `"${s.styles.fontFamily}", sans-serif`, d.style.fontSize = `${s.styles.fontSize}px`, d.style.fontWeight = "normal", this.getElement().appendChild(d);
1069
1071
  }
1070
- this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(s, a, n, r, o);
1072
+ this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(s, a, i, r, o);
1071
1073
  }
1072
- borderRadius(e, t, s, a, n) {
1074
+ borderRadius(e, t, s, a, i) {
1073
1075
  const r = (o) => o ? `${e}px` : "0px";
1074
- return `${r(t)} ${r(s)} ${r(a)} ${r(n)}`;
1076
+ return `${r(t)} ${r(s)} ${r(a)} ${r(i)}`;
1075
1077
  }
1076
- createFields(e, t, s, a, n) {
1078
+ createFields(e, t, s, a, i) {
1077
1079
  if (!this.grouped) {
1078
1080
  this.createUngroupedFields(
1079
1081
  e,
1080
1082
  t,
1081
1083
  s,
1082
1084
  a,
1083
- n
1085
+ i
1084
1086
  );
1085
1087
  return;
1086
1088
  }
@@ -1092,18 +1094,18 @@ class ce extends A {
1092
1094
  t.street?.enabled && d.push({ kind: "street" });
1093
1095
  const c = [];
1094
1096
  t.firstName?.enabled && c.push("firstName"), t.lastName?.enabled && c.push("lastName"), c.length > 0 && d.push({ kind: "name", fields: c }), t.country?.enabled && d.push({ kind: "country" });
1095
- const u = [];
1096
- t.city?.enabled && u.push("city"), t.zipCode?.enabled && u.push("zipCode"), u.length > 0 && d.push({ kind: "cityZip", fields: u }), t.state?.enabled && d.push({ kind: "state" });
1097
+ const m = [];
1098
+ t.city?.enabled && m.push("city"), t.zipCode?.enabled && m.push("zipCode"), m.length > 0 && d.push({ kind: "cityZip", fields: m }), t.state?.enabled && d.push({ kind: "state" });
1097
1099
  const S = d.length;
1098
1100
  d.forEach((l, p) => {
1099
- const y = p === 0, m = p === S - 1, g = (h, b) => ({
1101
+ const y = p === 0, u = p === S - 1, g = (h, b) => ({
1100
1102
  ...o,
1101
1103
  borderRadius: this.borderRadius(
1102
1104
  r,
1103
1105
  y && h,
1104
1106
  y && b,
1105
- m && b,
1106
- m && h
1107
+ u && b,
1108
+ u && h
1107
1109
  )
1108
1110
  });
1109
1111
  if (l.kind === "street") {
@@ -1112,9 +1114,10 @@ class ce extends A {
1112
1114
  t.street?.label ?? this.translationFunc("address.addressLine1"),
1113
1115
  s.street,
1114
1116
  a.street,
1115
- n.street,
1117
+ i.street,
1116
1118
  g(!0, !0),
1117
- "street-address"
1119
+ "street-address",
1120
+ t.street?.maxLength
1118
1121
  );
1119
1122
  this.inputs.set("street", b), h.appendChild(b.getElement()), this.fieldsContainer.appendChild(h);
1120
1123
  return;
@@ -1127,7 +1130,7 @@ class ce extends A {
1127
1130
  t.firstName?.label ?? this.translationFunc("address.firstName"),
1128
1131
  s.firstName,
1129
1132
  a.firstName,
1130
- n.firstName,
1133
+ i.firstName,
1131
1134
  g(!0, f),
1132
1135
  "given-name"
1133
1136
  );
@@ -1139,7 +1142,7 @@ class ce extends A {
1139
1142
  t.lastName?.label ?? this.translationFunc("address.lastName"),
1140
1143
  s.lastName,
1141
1144
  a.lastName,
1142
- n.lastName,
1145
+ i.lastName,
1143
1146
  g(f, !0),
1144
1147
  "family-name"
1145
1148
  );
@@ -1152,7 +1155,7 @@ class ce extends A {
1152
1155
  const h = this.createRow(["full"]), b = this.createCountrySelect(
1153
1156
  s.country,
1154
1157
  a.country,
1155
- n.country,
1158
+ i.country,
1156
1159
  g(!0, !0),
1157
1160
  t.country?.options,
1158
1161
  t.country?.label
@@ -1168,7 +1171,7 @@ class ce extends A {
1168
1171
  t.city?.label ?? this.translationFunc("address.townCity"),
1169
1172
  s.city,
1170
1173
  a.city,
1171
- n.city,
1174
+ i.city,
1172
1175
  g(!0, f),
1173
1176
  "address-level2"
1174
1177
  );
@@ -1180,7 +1183,7 @@ class ce extends A {
1180
1183
  t.zipCode?.label ?? this.translationFunc("address.postalCode"),
1181
1184
  s.zipCode,
1182
1185
  a.zipCode,
1183
- n.zipCode,
1186
+ i.zipCode,
1184
1187
  g(f, !0),
1185
1188
  "postal-code"
1186
1189
  );
@@ -1197,7 +1200,7 @@ class ce extends A {
1197
1200
  const v = this.createStateSelect(
1198
1201
  s.state,
1199
1202
  a.state,
1200
- n.state,
1203
+ i.state,
1201
1204
  this.stateStyles,
1202
1205
  s.country,
1203
1206
  t.state?.label
@@ -1209,7 +1212,7 @@ class ce extends A {
1209
1212
  t.state?.label ?? this.translationFunc("address.state"),
1210
1213
  s.state,
1211
1214
  a.state,
1212
- n.state,
1215
+ i.state,
1213
1216
  this.stateStyles,
1214
1217
  "address-level1"
1215
1218
  );
@@ -1223,47 +1226,54 @@ class ce extends A {
1223
1226
  const t = document.createElement("div");
1224
1227
  return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
1225
1228
  }
1226
- createInput(e, t, s, a, n, r, o) {
1227
- const d = `${this.type}Address.${e}`, c = new pe({
1228
- name: d,
1229
+ createInput(e, t, s, a, i, r, o, d) {
1230
+ const c = `${this.type}Address.${e}`, m = new pe({
1231
+ name: c,
1229
1232
  error: !1,
1230
1233
  errorMsg: void 0,
1231
1234
  styles: r,
1235
+ maxLength: d,
1232
1236
  ...this.grouped ? { placeholder: t } : {
1233
1237
  label: t,
1234
1238
  placeholder: (() => {
1235
- const u = `address.placeholder.${e}`, S = this.translationFunc(u);
1236
- return S !== u ? S : t;
1239
+ const S = `address.placeholder.${e}`, l = this.translationFunc(S);
1240
+ return l !== S ? l : t;
1237
1241
  })()
1238
1242
  },
1239
1243
  value: s,
1240
1244
  autocomplete: o,
1241
- onChange: (u) => {
1242
- c.setError(!1), this.onChange(
1245
+ onChange: (S) => {
1246
+ const l = S.target.value;
1247
+ if (d && l.length >= d) {
1248
+ const p = this.translationFunc("validation.maxLengthExceeded");
1249
+ m.setError(!0, p.replace("{{max}}", String(d)));
1250
+ } else
1251
+ m.setError(!1);
1252
+ this.onChange(
1243
1253
  P({
1244
1254
  type: "input",
1245
1255
  target: {
1246
- name: d,
1247
- value: u.target.value
1256
+ name: c,
1257
+ value: l
1248
1258
  }
1249
1259
  })
1250
1260
  );
1251
1261
  }
1252
1262
  });
1253
- return c.addEventListener("blur", (u) => {
1263
+ return m.addEventListener("blur", (S) => {
1254
1264
  this.onBlur(
1255
1265
  P({
1256
1266
  type: "blur",
1257
1267
  target: {
1258
- name: d,
1259
- value: u.target.value
1268
+ name: c,
1269
+ value: S.target.value
1260
1270
  }
1261
1271
  })
1262
1272
  );
1263
- }), c;
1273
+ }), m;
1264
1274
  }
1265
- createCountrySelect(e, t, s, a, n, r) {
1266
- const o = `${this.type}Address.country`, d = ve(n, this.locale), c = new _({
1275
+ createCountrySelect(e, t, s, a, i, r) {
1276
+ const o = `${this.type}Address.country`, d = ve(i, this.locale), c = new _({
1267
1277
  name: o,
1268
1278
  error: !1,
1269
1279
  errorMsg: void 0,
@@ -1275,9 +1285,9 @@ class ce extends A {
1275
1285
  value: e,
1276
1286
  options: d,
1277
1287
  autocomplete: "country",
1278
- onChange: (u) => {
1288
+ onChange: (m) => {
1279
1289
  c.setError(!1);
1280
- const S = u.target.value;
1290
+ const S = m.target.value;
1281
1291
  this.onChange(
1282
1292
  P({
1283
1293
  type: "change",
@@ -1286,13 +1296,13 @@ class ce extends A {
1286
1296
  ), this.handleCountryChange(S);
1287
1297
  }
1288
1298
  });
1289
- return c.addEventListener("blur", (u) => {
1299
+ return c.addEventListener("blur", (m) => {
1290
1300
  this.onBlur(
1291
1301
  P({
1292
1302
  type: "blur",
1293
1303
  target: {
1294
1304
  name: o,
1295
- value: u.target.value
1305
+ value: m.target.value
1296
1306
  }
1297
1307
  })
1298
1308
  );
@@ -1307,21 +1317,21 @@ class ce extends A {
1307
1317
  return;
1308
1318
  }
1309
1319
  if (!a && s && (this.stateRow.style.display = ""), a) return;
1310
- const n = this.inputs.get("state") instanceof _, r = O.has(e);
1311
- if (n && r) {
1320
+ const i = this.inputs.get("state") instanceof _, r = O.has(e);
1321
+ if (i && r) {
1312
1322
  const o = this.inputs.get("state");
1313
1323
  if (o instanceof _) {
1314
- const d = e === "CA" ? "CA" : "US", c = ee(d), u = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1315
- o.setOptions(c, u);
1324
+ const d = e === "CA" ? "CA" : "US", c = ee(d), m = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1325
+ o.setOptions(c, m);
1316
1326
  }
1317
1327
  this.clearStateValue();
1318
1328
  return;
1319
1329
  }
1320
- if (n !== r) {
1330
+ if (i !== r) {
1321
1331
  this.rebuildStateField(e), this.clearStateValue();
1322
1332
  return;
1323
1333
  }
1324
- !n && !r && t !== e && this.clearStateValue();
1334
+ !i && !r && t !== e && this.clearStateValue();
1325
1335
  }
1326
1336
  rebuildStateField(e) {
1327
1337
  if (!this.stateRow || !this.stateStyles) return;
@@ -1361,14 +1371,14 @@ class ce extends A {
1361
1371
  })
1362
1372
  );
1363
1373
  }
1364
- createStateSelect(e, t, s, a, n, r) {
1365
- const o = `${this.type}Address.state`, d = n === "CA" ? "CA" : "US", c = ee(d), u = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), S = new _({
1374
+ createStateSelect(e, t, s, a, i, r) {
1375
+ const o = `${this.type}Address.state`, d = i === "CA" ? "CA" : "US", c = ee(d), m = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), S = new _({
1366
1376
  name: o,
1367
1377
  error: !1,
1368
1378
  errorMsg: void 0,
1369
1379
  styles: a,
1370
- placeholder: u,
1371
- ...!this.grouped && { label: r ?? u },
1380
+ placeholder: m,
1381
+ ...!this.grouped && { label: r ?? m },
1372
1382
  value: e,
1373
1383
  options: c,
1374
1384
  autocomplete: "address-level1",
@@ -1396,35 +1406,41 @@ class ce extends A {
1396
1406
  );
1397
1407
  }), S;
1398
1408
  }
1399
- createUngroupedFields(e, t, s, a, n) {
1409
+ createUngroupedFields(e, t, s, a, i) {
1400
1410
  const r = e.styles.borderRadius, o = {
1401
1411
  color: e.styles.textColor,
1402
1412
  fontSize: e.styles.fontSize,
1403
1413
  fontFamily: e.styles.fontFamily,
1404
1414
  borderRadius: `${r}px`
1405
- }, d = (c, u, S) => {
1415
+ }, d = (c, m, S, l) => {
1406
1416
  if (!t[c]?.enabled) return;
1407
- const l = t[c]?.label ?? this.translationFunc(u), p = this.createRow(["full"]), y = this.createInput(
1417
+ const p = t[c]?.label ?? this.translationFunc(m), y = this.createRow(["full"]), u = this.createInput(
1408
1418
  c,
1409
- l,
1419
+ p,
1410
1420
  s[c],
1411
1421
  a[c],
1412
- n[c],
1422
+ i[c],
1413
1423
  o,
1414
- S
1424
+ S,
1425
+ l
1415
1426
  );
1416
- this.inputs.set(c, y), p.appendChild(y.getElement()), this.fieldsContainer.appendChild(p);
1427
+ this.inputs.set(c, u), y.appendChild(u.getElement()), this.fieldsContainer.appendChild(y);
1417
1428
  };
1418
- if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d("street", "address.addressLine1", "street-address"), d("city", "address.townCity", "address-level2"), t.country?.enabled) {
1419
- const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), u = this.createRow(["full"]), S = this.createCountrySelect(
1429
+ if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d(
1430
+ "street",
1431
+ "address.addressLine1",
1432
+ "street-address",
1433
+ t.street?.maxLength
1434
+ ), d("city", "address.townCity", "address-level2"), t.country?.enabled) {
1435
+ const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), m = this.createRow(["full"]), S = this.createCountrySelect(
1420
1436
  s.country,
1421
1437
  a.country,
1422
- n.country,
1438
+ i.country,
1423
1439
  o,
1424
1440
  t.country?.options,
1425
1441
  c
1426
1442
  );
1427
- this.inputs.set("country", S), u.appendChild(S.getElement()), this.fieldsContainer.appendChild(u);
1443
+ this.inputs.set("country", S), m.appendChild(S.getElement()), this.fieldsContainer.appendChild(m);
1428
1444
  }
1429
1445
  if (t.state?.enabled) {
1430
1446
  this.stateFieldConfig = t.state;
@@ -1437,7 +1453,7 @@ class ce extends A {
1437
1453
  const p = this.createStateSelect(
1438
1454
  s.state,
1439
1455
  a.state,
1440
- n.state,
1456
+ i.state,
1441
1457
  o,
1442
1458
  s.country,
1443
1459
  l
@@ -1449,7 +1465,7 @@ class ce extends A {
1449
1465
  l,
1450
1466
  s.state,
1451
1467
  a.state,
1452
- n.state,
1468
+ i.state,
1453
1469
  o,
1454
1470
  "address-level1"
1455
1471
  );
@@ -1484,17 +1500,17 @@ class ce extends A {
1484
1500
  setError(e, t, s) {
1485
1501
  const a = this.inputs.get(e);
1486
1502
  if (a) {
1487
- const n = a.getElement().querySelector("input") || a.getElement().querySelector("select");
1488
- document.activeElement !== n && a.setError(t, s);
1503
+ const i = a.getElement().querySelector("input") || a.getElement().querySelector("select");
1504
+ document.activeElement !== i && a.setError(t, s);
1489
1505
  }
1490
1506
  }
1491
1507
  updateField(e, t, s, a) {
1492
- const n = this.inputs.get(e);
1493
- if (!n) return;
1494
- const r = n.getElement().querySelector("input") || n.getElement().querySelector("select"), o = n.getValue();
1508
+ const i = this.inputs.get(e);
1509
+ if (!i) return;
1510
+ const r = i.getElement().querySelector("input") || i.getElement().querySelector("select"), o = i.getValue();
1495
1511
  !(document.activeElement === r) && !(t === "" && o !== "") && this.setValue(e, t);
1496
- const u = !!(a && s);
1497
- this.setError(e, u, s);
1512
+ const m = !!(a && s);
1513
+ this.setError(e, m, s);
1498
1514
  }
1499
1515
  updateAllFields(e, t, s) {
1500
1516
  Object.keys(e).forEach((a) => {
@@ -1524,7 +1540,7 @@ class ft {
1524
1540
  value: t,
1525
1541
  onChange: s,
1526
1542
  onBlur: a,
1527
- errorMsg: n,
1543
+ errorMsg: i,
1528
1544
  checkoutProfile: r,
1529
1545
  translationFunc: o,
1530
1546
  autocomplete: d = "cc-name",
@@ -1534,7 +1550,7 @@ class ft {
1534
1550
  t,
1535
1551
  s,
1536
1552
  a,
1537
- n,
1553
+ i,
1538
1554
  r,
1539
1555
  o,
1540
1556
  d
@@ -1543,29 +1559,29 @@ class ft {
1543
1559
  buildVgsLayout(e, t) {
1544
1560
  const s = e.styles.borderRadius, a = document.createElement("div");
1545
1561
  a.style.marginBottom = "4px";
1546
- const n = document.createElement("label");
1547
- n.className = "input-label", n.textContent = t("cardholderNameLabel"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), this.wrapperElement.appendChild(a), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${s}px`, this.vgsWrapper.style.height = "38.5px", this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
1562
+ const i = document.createElement("label");
1563
+ i.className = "input-label", i.textContent = t("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(i), this.wrapperElement.appendChild(a), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${s}px`, this.vgsWrapper.style.height = "38.5px", this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
1548
1564
  const r = document.createElement("div");
1549
1565
  r.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(r), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new Se({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
1550
1566
  }
1551
- buildNativeLayout(e, t, s, a, n, r, o) {
1567
+ buildNativeLayout(e, t, s, a, i, r, o) {
1552
1568
  this.input = new pe({
1553
1569
  name: "name",
1554
1570
  label: r("cardholderNameLabel"),
1555
1571
  error: !1,
1556
1572
  errorMsg: a,
1557
1573
  styles: {
1558
- color: n.styles.textColor,
1559
- borderRadius: `${n.styles.borderRadius}px`,
1560
- fontSize: n.styles.fontSize,
1561
- fontFamily: n.styles.fontFamily
1574
+ color: i.styles.textColor,
1575
+ borderRadius: `${i.styles.borderRadius}px`,
1576
+ fontSize: i.styles.fontSize,
1577
+ fontFamily: i.styles.fontFamily
1562
1578
  },
1563
1579
  placeholder: r("cardholderNamePlaceholder"),
1564
1580
  value: e,
1565
1581
  autocomplete: o,
1566
1582
  onChange: (d) => {
1567
- const u = d.target.value, S = u.replace(/[^a-zA-Z\s\-'.]/g, "");
1568
- u !== S && this.input?.setValue(S), this.input?.setError(!1), this.trim(), t(d);
1583
+ const m = d.target.value, S = m.replace(/[^a-zA-Z\s\-'.]/g, "");
1584
+ m !== S && this.input?.setValue(S), this.input?.setError(!1), this.trim(), t(d);
1569
1585
  }
1570
1586
  }), this.input.addEventListener("blur", (d) => {
1571
1587
  s(d);
@@ -1641,12 +1657,12 @@ class yt extends A {
1641
1657
  constructor(e) {
1642
1658
  const { translationFunc: t, checkoutProfile: s } = e;
1643
1659
  super("div", ["payment-separator"]);
1644
- const a = this.getElement(), n = document.createElement("span");
1645
- n.className = "payment-separator__line";
1660
+ const a = this.getElement(), i = document.createElement("span");
1661
+ i.className = "payment-separator__line";
1646
1662
  const r = document.createElement("p");
1647
1663
  r.textContent = t("pay-with-card"), r.className = "payment-separator__text", r.style.fontFamily = `${s.styles.fontFamily}, sans-serif`;
1648
1664
  const o = document.createElement("span");
1649
- o.className = "payment-separator__line", a.appendChild(n), a.appendChild(r), a.appendChild(o);
1665
+ o.className = "payment-separator__line", a.appendChild(i), a.appendChild(r), a.appendChild(o);
1650
1666
  }
1651
1667
  }
1652
1668
  class bt extends A {
@@ -1658,12 +1674,12 @@ class bt extends A {
1658
1674
  checkoutProfile: t,
1659
1675
  formData: s,
1660
1676
  onPaypalSubmit: a,
1661
- onApplePaySubmit: n,
1677
+ onApplePaySubmit: i,
1662
1678
  supportedPaymentMethods: r,
1663
1679
  translationFunc: o,
1664
1680
  paymentId: d,
1665
1681
  checkoutKey: c,
1666
- checkoutDetails: u,
1682
+ checkoutDetails: m,
1667
1683
  environment: S,
1668
1684
  countryCode: l
1669
1685
  } = e;
@@ -1677,10 +1693,10 @@ class bt extends A {
1677
1693
  }
1678
1694
  const p = Object.entries(
1679
1695
  t.additionalPaymentMethods
1680
- ).filter(([y, m]) => {
1681
- const g = m.enabled, h = r ? r[y] === !0 : !0, b = !m.countries || l && m.countries.includes(l);
1696
+ ).filter(([y, u]) => {
1697
+ const g = u.enabled, h = r ? r[y] === !0 : !0, b = !u.countries || l && u.countries.includes(l);
1682
1698
  return g && h && b;
1683
- }).sort((y, m) => y[1].order - m[1].order);
1699
+ }).sort((y, u) => y[1].order - u[1].order);
1684
1700
  if (p.length === 0) {
1685
1701
  this.getElement().style.display = "none";
1686
1702
  return;
@@ -1689,28 +1705,28 @@ class bt extends A {
1689
1705
  switch (y) {
1690
1706
  case "paypal": {
1691
1707
  if (a) {
1692
- const m = new Ee({
1708
+ const u = new Ee({
1693
1709
  checkoutProfile: t,
1694
1710
  formData: s,
1695
1711
  onSubmit: a
1696
1712
  });
1697
- this.paymentMethods.set("paypal", m), m.appendTo(this.getElement());
1713
+ this.paymentMethods.set("paypal", u), u.appendTo(this.getElement());
1698
1714
  }
1699
1715
  break;
1700
1716
  }
1701
1717
  case "applePay": {
1702
- if (n && d && c) {
1703
- const m = t.appearance?.additionalPaymentMethods?.applePay, g = new Ce({
1718
+ if (i && d && c) {
1719
+ const u = t.appearance?.additionalPaymentMethods?.applePay, g = new Ce({
1704
1720
  checkoutProfile: t,
1705
1721
  formData: s,
1706
- onSubmit: n,
1722
+ onSubmit: i,
1707
1723
  paymentId: d,
1708
1724
  checkoutKey: c,
1709
- checkoutDetails: u,
1725
+ checkoutDetails: m,
1710
1726
  environment: S,
1711
- displayName: m?.displayName,
1712
- requiredBillingContactFields: m?.requiredBillingContactFields,
1713
- requiredShippingContactFields: m?.requiredShippingContactFields
1727
+ displayName: u?.displayName,
1728
+ requiredBillingContactFields: u?.requiredBillingContactFields,
1729
+ requiredShippingContactFields: u?.requiredShippingContactFields
1714
1730
  });
1715
1731
  this.paymentMethods.set("applePay", g), g.appendTo(this.getElement());
1716
1732
  }
@@ -1868,7 +1884,7 @@ class Et {
1868
1884
  }
1869
1885
  createEmailField(e, t, s, a) {
1870
1886
  try {
1871
- const n = e.layout.billingFields && Object.values(e.layout.billingFields).some(
1887
+ const i = e.layout.billingFields && Object.values(e.layout.billingFields).some(
1872
1888
  (r) => r?.enabled
1873
1889
  ) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some(
1874
1890
  (r) => r?.enabled
@@ -1877,7 +1893,7 @@ class Et {
1877
1893
  value: t.email,
1878
1894
  onChange: this.onChange,
1879
1895
  onBlur: this.onBlur,
1880
- onTab: n ? void 0 : () => this.focusManager.focusField(
1896
+ onTab: i ? void 0 : () => this.focusManager.focusField(
1881
1897
  e.layout.phoneNumber?.enabled ? "phoneNumber" : "cardNumber"
1882
1898
  ),
1883
1899
  error: !!(s.email && a.email),
@@ -1885,14 +1901,14 @@ class Et {
1885
1901
  checkoutProfile: e,
1886
1902
  translationFunc: this.translationFunc
1887
1903
  }), this.emailFocusHandler = () => this.onFieldFocus("email"), this.emailField.getElement().addEventListener("focus", this.emailFocusHandler, !0), this.focusManager.registerField("email", this.emailField), this.formElement.appendChild(this.emailField.getElement());
1888
- } catch (n) {
1889
- throw console.error("Error creating email field:", n), n;
1904
+ } catch (i) {
1905
+ throw console.error("Error creating email field:", i), i;
1890
1906
  }
1891
1907
  }
1892
1908
  createPhoneNumberField(e, t, s, a) {
1893
- const n = document.createElement("div");
1894
- this.phonePlaceholder = n, this.formElement.appendChild(n), Me().then(({ PhoneNumberField: r }) => {
1895
- n.isConnected && (this.phoneNumberField = new r({
1909
+ const i = document.createElement("div");
1910
+ this.phonePlaceholder = i, this.formElement.appendChild(i), Me().then(({ PhoneNumberField: r }) => {
1911
+ i.isConnected && (this.phoneNumberField = new r({
1896
1912
  value: t.phoneNumber ?? "",
1897
1913
  onChange: this.onChange,
1898
1914
  onBlur: this.onBlur,
@@ -1904,9 +1920,9 @@ class Et {
1904
1920
  defaultCountry: e.layout.phoneNumber?.defaultCountry || "US",
1905
1921
  allowedCountries: e.layout.phoneNumber?.allowedCountries,
1906
1922
  locale: this.locale
1907
- }), this.phoneNumberFocusHandler = () => this.onFieldFocus("phoneNumber"), this.phoneNumberField.getElement().addEventListener("focus", this.phoneNumberFocusHandler, !0), this.focusManager.registerField("phoneNumber", this.phoneNumberField), n.replaceWith(this.phoneNumberField.getElement()), this.phonePlaceholder = void 0);
1923
+ }), this.phoneNumberFocusHandler = () => this.onFieldFocus("phoneNumber"), this.phoneNumberField.getElement().addEventListener("focus", this.phoneNumberFocusHandler, !0), this.focusManager.registerField("phoneNumber", this.phoneNumberField), i.replaceWith(this.phoneNumberField.getElement()), this.phonePlaceholder = void 0);
1908
1924
  }).catch((r) => {
1909
- console.error("Error creating phone number field:", r), n.remove(), this.phonePlaceholder = void 0;
1925
+ console.error("Error creating phone number field:", r), i.remove(), this.phonePlaceholder = void 0;
1910
1926
  });
1911
1927
  }
1912
1928
  setCheckoutDetailsLoaded(e) {
@@ -1943,8 +1959,8 @@ class Et {
1943
1959
  vgsService: this.vgsService,
1944
1960
  onVgsStateChange: this.onVgsStateChange
1945
1961
  }), !this.vgsService) {
1946
- const n = this.cardSection.getElement().querySelector('input[name="cardExpiry"]');
1947
- n && (this.cardExpiryFocusHandler = () => this.onFieldFocus("cardExpiry"), n.addEventListener(
1962
+ const i = this.cardSection.getElement().querySelector('input[name="cardExpiry"]');
1963
+ i && (this.cardExpiryFocusHandler = () => this.onFieldFocus("cardExpiry"), i.addEventListener(
1948
1964
  "focus",
1949
1965
  this.cardExpiryFocusHandler
1950
1966
  ));
@@ -1963,8 +1979,8 @@ class Et {
1963
1979
  }), this.focusManager.registerField("cardCvv", {
1964
1980
  focus: () => this.cardSection?.focusField("cardCvv")
1965
1981
  }), this.formElement.appendChild(this.cardSection.getElement());
1966
- } catch (n) {
1967
- throw console.error("Error creating card section:", n), n;
1982
+ } catch (i) {
1983
+ throw console.error("Error creating card section:", i), i;
1968
1984
  }
1969
1985
  }
1970
1986
  createCardholderSection(e, t, s, a) {
@@ -1983,18 +1999,18 @@ class Et {
1983
1999
  translationFunc: this.translationFunc,
1984
2000
  isVgsMode: !!this.vgsService
1985
2001
  }), !this.vgsService) {
1986
- const n = this.cardholderSection.getElement().querySelector('input[name="name"]');
1987
- n && (this.nameFocusHandler = () => this.onFieldFocus("name"), n.addEventListener("focus", this.nameFocusHandler));
2002
+ const i = this.cardholderSection.getElement().querySelector('input[name="name"]');
2003
+ i && (this.nameFocusHandler = () => this.onFieldFocus("name"), i.addEventListener("focus", this.nameFocusHandler));
1988
2004
  }
1989
2005
  this.focusManager.registerField("name", this.cardholderSection), this.formElement.appendChild(this.cardholderSection.getElement());
1990
- } catch (n) {
1991
- throw console.error("Error creating cardholder section:", n), n;
2006
+ } catch (i) {
2007
+ throw console.error("Error creating cardholder section:", i), i;
1992
2008
  }
1993
2009
  }
1994
2010
  createBillingAddressSection(e, t, s, a) {
1995
2011
  try {
1996
- const n = e.layout.billingFields;
1997
- if (!n || !Object.values(n).some(
2012
+ const i = e.layout.billingFields;
2013
+ if (!i || !Object.values(i).some(
1998
2014
  (d) => d?.enabled
1999
2015
  )) return;
2000
2016
  const o = {
@@ -2010,7 +2026,7 @@ class Et {
2010
2026
  type: "billing",
2011
2027
  title: this.translationFunc("address.billingTitle"),
2012
2028
  checkoutProfile: e,
2013
- fieldsConfig: n,
2029
+ fieldsConfig: i,
2014
2030
  values: t.billingAddress ?? o,
2015
2031
  errors: s.billingAddress ?? {},
2016
2032
  touched: a.billingAddress ?? {},
@@ -2020,14 +2036,14 @@ class Et {
2020
2036
  locale: this.locale,
2021
2037
  grouped: e.layout.grouped
2022
2038
  }), this.formElement.appendChild(this.billingAddressSection.getElement());
2023
- } catch (n) {
2024
- throw console.error("Error creating billing address section:", n), n;
2039
+ } catch (i) {
2040
+ throw console.error("Error creating billing address section:", i), i;
2025
2041
  }
2026
2042
  }
2027
2043
  createShippingAddressSection(e, t, s, a) {
2028
2044
  try {
2029
- const n = e.layout.shippingFields;
2030
- if (!n || !Object.values(n).some(
2045
+ const i = e.layout.shippingFields;
2046
+ if (!i || !Object.values(i).some(
2031
2047
  (d) => d?.enabled
2032
2048
  )) return;
2033
2049
  const o = {
@@ -2043,7 +2059,7 @@ class Et {
2043
2059
  type: "shipping",
2044
2060
  title: this.translationFunc("address.shippingTitle"),
2045
2061
  checkoutProfile: e,
2046
- fieldsConfig: n,
2062
+ fieldsConfig: i,
2047
2063
  values: t.shippingAddress ?? o,
2048
2064
  errors: s.shippingAddress ?? {},
2049
2065
  touched: a.shippingAddress ?? {},
@@ -2053,8 +2069,8 @@ class Et {
2053
2069
  locale: this.locale,
2054
2070
  grouped: e.layout.grouped
2055
2071
  }), this.formElement.appendChild(this.shippingAddressSection.getElement());
2056
- } catch (n) {
2057
- throw console.error("Error creating shipping address section:", n), n;
2072
+ } catch (i) {
2073
+ throw console.error("Error creating shipping address section:", i), i;
2058
2074
  }
2059
2075
  }
2060
2076
  createSubmitButton(e, t) {
@@ -2074,12 +2090,12 @@ class Et {
2074
2090
  updatePhoneNumberField(e, t, s) {
2075
2091
  this.phoneNumberField && (this.phoneNumberField.setValue(e), this.phoneNumberField.setError(t, s));
2076
2092
  }
2077
- updateCardSection(e, t, s, a, n, r, o, d, c) {
2093
+ updateCardSection(e, t, s, a, i, r, o, d, c) {
2078
2094
  this.cardSection && (this.cardSection.updateCardNumber(
2079
2095
  e,
2080
2096
  t,
2081
2097
  s
2082
- ), this.cardSection.updateCardCvv(a, n, r), this.cardSection.updateCardExpiry(
2098
+ ), this.cardSection.updateCardCvv(a, i, r), this.cardSection.updateCardExpiry(
2083
2099
  o,
2084
2100
  d,
2085
2101
  c
@@ -2118,8 +2134,8 @@ class Et {
2118
2134
  buildCardSkeleton(e) {
2119
2135
  const t = e.styles.borderRadius, s = document.createElement("div"), a = document.createElement("div");
2120
2136
  a.style.marginBottom = "4px";
2121
- const n = document.createElement("label");
2122
- n.className = "input-label", n.textContent = this.translationFunc("cardInformation"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), s.appendChild(a);
2137
+ const i = document.createElement("label");
2138
+ i.className = "input-label", i.textContent = this.translationFunc("cardInformation"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(i), s.appendChild(a);
2123
2139
  const r = document.createElement("div");
2124
2140
  r.className = "vgs-card-group", r.style.borderRadius = `${t}px`, r.style.background = "#fff", r.style.display = "flex", r.style.flexDirection = "column", r.style.gap = "8px";
2125
2141
  const o = document.createElement("div");
@@ -2128,8 +2144,8 @@ class Et {
2128
2144
  d.style.display = "flex", d.style.gap = "8px";
2129
2145
  const c = document.createElement("div");
2130
2146
  c.style.position = "relative", c.style.flex = "1", c.style.height = "38.5px", c.style.overflow = "hidden", c.style.borderRadius = `${t}px`, c.appendChild(this.createSkeletonDiv()), d.appendChild(c);
2131
- const u = document.createElement("div");
2132
- return u.style.position = "relative", u.style.flex = "1", u.style.height = "38.5px", u.style.overflow = "hidden", u.style.borderRadius = `${t}px`, u.appendChild(this.createSkeletonDiv()), d.appendChild(u), r.appendChild(d), s.appendChild(r), s;
2147
+ const m = document.createElement("div");
2148
+ return m.style.position = "relative", m.style.flex = "1", m.style.height = "38.5px", m.style.overflow = "hidden", m.style.borderRadius = `${t}px`, m.appendChild(this.createSkeletonDiv()), d.appendChild(m), r.appendChild(d), s.appendChild(r), s;
2133
2149
  }
2134
2150
  createSkeletonDiv() {
2135
2151
  const e = document.createElement("div");
@@ -2138,8 +2154,8 @@ class Et {
2138
2154
  buildCardholderSkeleton(e) {
2139
2155
  const t = e.styles.borderRadius, s = document.createElement("div"), a = document.createElement("div");
2140
2156
  a.style.marginBottom = "4px";
2141
- const n = document.createElement("label");
2142
- n.className = "input-label", n.textContent = this.translationFunc("cardholderNameLabel"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), s.appendChild(a);
2157
+ const i = document.createElement("label");
2158
+ i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(i), s.appendChild(a);
2143
2159
  const r = document.createElement("div");
2144
2160
  return r.style.position = "relative", r.style.borderRadius = `${t}px`, r.style.height = "38.5px", r.style.width = "100%", r.style.overflow = "hidden", r.style.background = "#fff", r.appendChild(this.createSkeletonDiv()), s.appendChild(r), s;
2145
2161
  }
@@ -2148,7 +2164,7 @@ class Et {
2148
2164
  await this.vgsService.whenReady();
2149
2165
  const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await pt(
2150
2166
  e.styles.fontFamily
2151
- ), n = this.cardSection.buildVgsFieldCss(
2167
+ ), i = this.cardSection.buildVgsFieldCss(
2152
2168
  e,
2153
2169
  a
2154
2170
  );
@@ -2159,7 +2175,7 @@ class Et {
2159
2175
  cardCvv: t.cardCvv ? `#${t.cardCvv}` : void 0,
2160
2176
  cardholderName: s ? `#${s}` : void 0
2161
2177
  },
2162
- n,
2178
+ i,
2163
2179
  {
2164
2180
  cardNumber: "1234 5678 9012 3456",
2165
2181
  cardExpiry: this.translationFunc("cardExpiry"),
@@ -2216,18 +2232,18 @@ class Ft {
2216
2232
  this.formManager = e.formManager, this.focusManager = e.focusManager, this.onFormSubmit = e.onFormSubmit, this.onUIUpdate = e.onUIUpdate;
2217
2233
  }
2218
2234
  handleChange = (e) => {
2219
- const t = e.target, { name: s, value: a } = t, n = s;
2220
- this.formManager.handleChange(n, a), e instanceof CustomEvent && e.detail?.programmatic ? this.localTouchedFields.delete(n) : this.localTouchedFields.has(n) || (this.localTouchedFields.add(n), this.formManager.handleBlur(n, a));
2235
+ const t = e.target, { name: s, value: a } = t, i = s;
2236
+ this.formManager.handleChange(i, a), e instanceof CustomEvent && e.detail?.programmatic ? this.localTouchedFields.delete(i) : this.localTouchedFields.has(i) || (this.localTouchedFields.add(i), this.formManager.handleBlur(i, a));
2221
2237
  const { formData: o, errors: d, touched: c } = this.formManager.getFormState();
2222
2238
  this.focusManager.handleStateUpdate(o, d, c);
2223
2239
  };
2224
2240
  handleBlur = (e) => {
2225
- const t = e.target, { name: s, value: a } = t, n = s;
2226
- this.localTouchedFields.add(n), this.formManager.handleBlur(n, a), setTimeout(() => {
2241
+ const t = e.target, { name: s, value: a } = t, i = s;
2242
+ this.localTouchedFields.add(i), this.formManager.handleBlur(i, a), setTimeout(() => {
2227
2243
  this.onUIUpdate();
2228
2244
  }, 0);
2229
2245
  const { formData: r, errors: o, touched: d } = this.formManager.getFormState();
2230
- d[n] || this.focusManager.handleStateUpdate(r, o, d);
2246
+ d[i] || this.focusManager.handleStateUpdate(r, o, d);
2231
2247
  };
2232
2248
  handleSubmit = async (e) => {
2233
2249
  e.preventDefault(), await this.onFormSubmit(e);
@@ -2289,15 +2305,15 @@ class Mt {
2289
2305
  isFormDisabled() {
2290
2306
  const e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), s = Object.keys(e.errors).filter(
2291
2307
  (f) => f !== "billingAddress" && f !== "shippingAddress"
2292
- ).length > 0, a = e.errors.billingAddress, n = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || n || o, u = J(
2308
+ ).length > 0, a = e.errors.billingAddress, i = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || i || o, m = J(
2293
2309
  t.checkoutProfile?.layout
2294
- ) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: p, shippingFields: y } = t.checkoutProfile?.layout ?? {}, m = /* @__PURE__ */ new Set(["US", "CA"]), g = (f, v) => {
2310
+ ) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: p, shippingFields: y } = t.checkoutProfile?.layout ?? {}, u = /* @__PURE__ */ new Set(["US", "CA"]), g = (f, v) => {
2295
2311
  if (!f) return !0;
2296
2312
  const E = v?.country ?? "";
2297
- return Object.entries(f).every(([N, x]) => !x?.enabled || N === "state" && (!m.has(E) || x.hiddenForCountries?.includes(E)) ? !0 : !!v?.[N]?.trim());
2313
+ return Object.entries(f).every(([N, x]) => !x?.enabled || N === "state" && (!u.has(E) || x.hiddenForCountries?.includes(E)) ? !0 : !!v?.[N]?.trim());
2298
2314
  }, h = !this.isVgsMode || Object.values(this.vgsFieldsState).every(
2299
2315
  (f) => f?.isValid === !0
2300
- ), b = this.isVgsMode ? !!e.formData.email && l && h && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress) : !!e.formData.email && l && u && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress);
2316
+ ), b = this.isVgsMode ? !!e.formData.email && l && h && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress) : !!e.formData.email && l && m && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress);
2301
2317
  return d || !b || this.isSubmitting;
2302
2318
  }
2303
2319
  setSubmitting(e) {
@@ -2314,9 +2330,9 @@ class Mt {
2314
2330
  for (const [s, a] of Object.entries(this.vgsFieldsState)) {
2315
2331
  if (!a?.isTouched || a.isFocused || a.isValid)
2316
2332
  continue;
2317
- const n = a.errors?.[0];
2318
- if (!n) continue;
2319
- const r = Pe(s, n.code);
2333
+ const i = a.errors?.[0];
2334
+ if (!i) continue;
2335
+ const r = Pe(s, i.code);
2320
2336
  r && (t[s] = e(r));
2321
2337
  }
2322
2338
  return t;
@@ -2347,12 +2363,12 @@ const he = {
2347
2363
  city: "",
2348
2364
  zipCode: "",
2349
2365
  country: ""
2350
- }, ue = (i, e) => {
2366
+ }, ue = (n, e) => {
2351
2367
  const t = {}, s = `${e}.`;
2352
- return Object.keys(i).forEach((a) => {
2368
+ return Object.keys(n).forEach((a) => {
2353
2369
  if (a.startsWith(s)) {
2354
- const n = a.slice(s.length);
2355
- t[n] = i[a];
2370
+ const i = a.slice(s.length);
2371
+ t[i] = n[a];
2356
2372
  }
2357
2373
  }), t;
2358
2374
  };
@@ -2428,7 +2444,7 @@ class wt {
2428
2444
  this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0), this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0), this.alert && (this.alert.getElement().remove(), this.alert = void 0);
2429
2445
  }
2430
2446
  }
2431
- const T = (i) => ({
2447
+ const T = (n) => ({
2432
2448
  street: "",
2433
2449
  firstName: "",
2434
2450
  lastName: "",
@@ -2436,7 +2452,7 @@ const T = (i) => ({
2436
2452
  city: "",
2437
2453
  zipCode: "",
2438
2454
  country: "",
2439
- ...i
2455
+ ...n
2440
2456
  });
2441
2457
  class Pt extends A {
2442
2458
  options;
@@ -2568,7 +2584,7 @@ class Pt extends A {
2568
2584
  }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({
2569
2585
  shippingAddress: T()
2570
2586
  });
2571
- const { formData: t, errors: s, touched: a } = this._getFormStateData(), n = gt(
2587
+ const { formData: t, errors: s, touched: a } = this._getFormStateData(), i = gt(
2572
2588
  e.checkoutProfile.layout
2573
2589
  );
2574
2590
  try {
@@ -2589,7 +2605,7 @@ class Pt extends A {
2589
2605
  } catch (o) {
2590
2606
  console.error("Failed to create email field:", o);
2591
2607
  }
2592
- if (n) {
2608
+ if (i) {
2593
2609
  try {
2594
2610
  this.componentManager.createBillingAddressSection(
2595
2611
  e.checkoutProfile,
@@ -2675,7 +2691,7 @@ class Pt extends A {
2675
2691
  )) return;
2676
2692
  const { formData: s } = this._getFormStateData(), a = s.billingAddress ?? s.shippingAddress;
2677
2693
  if (!a) return;
2678
- const n = a.firstName?.trim() ?? "", r = a.lastName?.trim() ?? "", o = [n, r].filter(Boolean).join(" ");
2694
+ const i = a.firstName?.trim() ?? "", r = a.lastName?.trim() ?? "", o = [i, r].filter(Boolean).join(" ");
2679
2695
  o && this.formManager.setFormData({ name: o });
2680
2696
  }
2681
2697
  /**
@@ -2686,10 +2702,10 @@ class Pt extends A {
2686
2702
  inferAddresses() {
2687
2703
  const e = this.checkoutProfile.getState();
2688
2704
  if (!e.checkoutProfile) return;
2689
- const { billingFields: t, shippingFields: s } = e.checkoutProfile.layout, a = t && Object.values(t).some((o) => o?.enabled), n = s && Object.values(s).some((o) => o?.enabled), { formData: r } = this._getFormStateData();
2690
- !a && n && r.shippingAddress ? this.formManager.setFormData({
2705
+ const { billingFields: t, shippingFields: s } = e.checkoutProfile.layout, a = t && Object.values(t).some((o) => o?.enabled), i = s && Object.values(s).some((o) => o?.enabled), { formData: r } = this._getFormStateData();
2706
+ !a && i && r.shippingAddress ? this.formManager.setFormData({
2691
2707
  billingAddress: { ...r.shippingAddress }
2692
- }) : !n && a && r.billingAddress && this.formManager.setFormData({
2708
+ }) : !i && a && r.billingAddress && this.formManager.setFormData({
2693
2709
  shippingAddress: { ...r.billingAddress }
2694
2710
  });
2695
2711
  }
@@ -2777,8 +2793,8 @@ class Pt extends A {
2777
2793
  this.eventHandler.handleKeyDown
2778
2794
  ), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
2779
2795
  }
2780
- associatePayment(e, t, s, a, n) {
2781
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), n && !this.vgsService && (this.vgsJwt = n, this.vgsService = new L(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
2796
+ associatePayment(e, t, s, a, i) {
2797
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), i && !this.vgsService && (this.vgsJwt = i, this.vgsService = new L(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
2782
2798
  this.vgsService?.createForm(
2783
2799
  o,
2784
2800
  (d) => this.handleVgsStateChange(d)
@@ -2791,7 +2807,7 @@ class Pt extends A {
2791
2807
  e,
2792
2808
  t,
2793
2809
  a
2794
- ), !n && this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents();
2810
+ ), !i && this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents();
2795
2811
  const r = this.checkoutProfile.getState();
2796
2812
  if (r.checkoutProfile) {
2797
2813
  const { formData: o } = this._getFormStateData();
@@ -2854,13 +2870,13 @@ class kt {
2854
2870
  clearError() {
2855
2871
  this.form && this.form.clearErrorMessage();
2856
2872
  }
2857
- async associatePayment(e, t, s, a, n) {
2858
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = a, this.options.vgsJwt = n, this.form && this.form.associatePayment(
2873
+ async associatePayment(e, t, s, a, i) {
2874
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = a, this.options.vgsJwt = i, this.form && this.form.associatePayment(
2859
2875
  e,
2860
2876
  t,
2861
2877
  s,
2862
2878
  a,
2863
- n
2879
+ i
2864
2880
  );
2865
2881
  }
2866
2882
  }
@@ -2889,13 +2905,14 @@ class At {
2889
2905
  const xt = "en";
2890
2906
  class Dt {
2891
2907
  config;
2908
+ _callbacks;
2892
2909
  paymentState;
2893
2910
  apiService;
2894
2911
  formManager;
2895
2912
  stateManager;
2896
2913
  sessionId;
2897
2914
  constructor(e) {
2898
- this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), ot({
2915
+ this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), ot({
2899
2916
  environment: this.config.environment,
2900
2917
  sessionId: this.sessionId
2901
2918
  }), M(F.CHECKOUT_INITIALIZED, {
@@ -2913,7 +2930,7 @@ class Dt {
2913
2930
  disableErrorMessages: this.config.disableErrorMessages,
2914
2931
  environment: this.config.environment,
2915
2932
  appearance: this.config.appearance,
2916
- onLoadingStateChange: this.config.callbacks.onLoadingStateChange,
2933
+ onLoadingStateChange: (...t) => this._callbacks.onLoadingStateChange?.(...t),
2917
2934
  initialValues: this.config.initialValues
2918
2935
  },
2919
2936
  this.handleSubmit.bind(this)
@@ -2979,7 +2996,7 @@ class Dt {
2979
2996
  });
2980
2997
  const a = performance.now();
2981
2998
  try {
2982
- const n = await this.apiService.authorizePayment({
2999
+ const i = await this.apiService.authorizePayment({
2983
3000
  checkoutKey: this.paymentState.checkoutKey,
2984
3001
  formData: e || null,
2985
3002
  paymentId: this.paymentState.paymentId,
@@ -2998,8 +3015,8 @@ class Dt {
2998
3015
  ), M(F.PAYMENT_SUBMIT_SUCCESS, {
2999
3016
  payment_id: this.paymentState.paymentId,
3000
3017
  payment_method: s
3001
- }), this.handlePaymentResponse(n);
3002
- } catch (n) {
3018
+ }), this.handlePaymentResponse(i);
3019
+ } catch (i) {
3003
3020
  const r = performance.now() - a;
3004
3021
  oe(
3005
3022
  se.PAYMENT_AUTHORIZATION_TIME,
@@ -3013,29 +3030,27 @@ class Dt {
3013
3030
  ), M(F.PAYMENT_SUBMIT_FAILED, {
3014
3031
  payment_id: this.paymentState.paymentId,
3015
3032
  payment_method: s,
3016
- error_message: n.details?.message ?? "Unknown error"
3017
- }), this.handleAuthorizationError(n);
3033
+ error_message: i.details?.message ?? "Unknown error"
3034
+ }), this.handleAuthorizationError(i);
3018
3035
  }
3019
3036
  }
3020
3037
  handlePaymentResponse(e) {
3021
3038
  if (e.latestTransaction.status === "authorized" && (M(F.PAYMENT_AUTHORIZED, {
3022
3039
  payment_id: this.paymentState.paymentId ?? "",
3023
3040
  status: e.latestTransaction.status
3024
- }), this.config.callbacks.onPaymentSucceeded?.(
3025
- e.latestTransaction.status
3026
- )), e.latestTransaction.status === "failed" && (M(F.PAYMENT_FAILED, {
3041
+ }), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status)), e.latestTransaction.status === "failed" && (M(F.PAYMENT_FAILED, {
3027
3042
  payment_id: this.paymentState.paymentId ?? "",
3028
3043
  status: e.latestTransaction.status
3029
- }), this.config.callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
3044
+ }), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
3030
3045
  const { redirectUrl: t } = e.action;
3031
3046
  M(F.PAYMENT_ACTION_REQUIRED, {
3032
3047
  payment_id: this.paymentState.paymentId ?? "",
3033
3048
  status: e.status
3034
- }), this.config.manualActionHandling ? this.config.callbacks.onActionRequired?.(t) : globalThis.location.href = t;
3049
+ }), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(t) : globalThis.location.href = t;
3035
3050
  }
3036
3051
  }
3037
3052
  handleAuthorizationError(e) {
3038
- this.config.callbacks.onPaymentFailed?.(e.details?.message);
3053
+ this._callbacks.onPaymentFailed?.(e.details?.message);
3039
3054
  const { form: t } = this.stateManager.getState();
3040
3055
  t && this.formManager.update({ errorMsg: e.details?.message });
3041
3056
  }
@@ -3078,7 +3093,7 @@ class Dt {
3078
3093
  "Invalid response: supportedPaymentMethods must be an array"
3079
3094
  );
3080
3095
  if (!s.supportedPaymentMethods.every(
3081
- (n) => typeof n == "string"
3096
+ (i) => typeof i == "string"
3082
3097
  ))
3083
3098
  throw new Error(
3084
3099
  "Invalid response: all supportedPaymentMethods must be strings"
@@ -3089,7 +3104,7 @@ class Dt {
3089
3104
  countryCode: s.countryCode
3090
3105
  };
3091
3106
  const a = s.supportedPaymentMethods.reduce(
3092
- (n, r) => (n[r] = !0, n),
3107
+ (i, r) => (i[r] = !0, i),
3093
3108
  {}
3094
3109
  );
3095
3110
  await this.formManager.associatePayment(
@@ -3113,6 +3128,9 @@ class Dt {
3113
3128
  ), s;
3114
3129
  }
3115
3130
  }
3131
+ setCallbacks(e) {
3132
+ Object.assign(this._callbacks, e);
3133
+ }
3116
3134
  }
3117
3135
  typeof globalThis < "u" && (globalThis.OdusCheckout = Dt);
3118
3136
  export {