@odus/checkout 1.9.2 → 1.10.1

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 (70) hide show
  1. package/dist/checkout.es.js +288 -199
  2. package/dist/components/checkout/form/CardSection.d.ts +6 -25
  3. package/dist/components/checkout/form/CardSection.d.ts.map +1 -1
  4. package/dist/components/checkout/form/CardUnavailableNotice.d.ts +16 -0
  5. package/dist/components/checkout/form/CardUnavailableNotice.d.ts.map +1 -0
  6. package/dist/components/checkout/form/Form.d.ts +17 -3
  7. package/dist/components/checkout/form/Form.d.ts.map +1 -1
  8. package/dist/components/checkout/form/FormComponentManager.d.ts +7 -7
  9. package/dist/components/checkout/form/FormComponentManager.d.ts.map +1 -1
  10. package/dist/components/checkout/form/FormStateCoordinator.d.ts +2 -0
  11. package/dist/components/checkout/form/FormStateCoordinator.d.ts.map +1 -1
  12. package/dist/components/checkout/form/FormUIManager.d.ts.map +1 -1
  13. package/dist/core/api/CheckoutAPI.service.d.ts +5 -1
  14. package/dist/core/api/CheckoutAPI.service.d.ts.map +1 -1
  15. package/dist/elements/CardElement.d.ts +42 -5
  16. package/dist/elements/CardElement.d.ts.map +1 -1
  17. package/dist/elements/OdusElements.d.ts.map +1 -1
  18. package/dist/elements/card/VgsCardAdapter.d.ts +6 -1
  19. package/dist/elements/card/VgsCardAdapter.d.ts.map +1 -1
  20. package/dist/elements/cardElement.constants.d.ts +0 -2
  21. package/dist/elements/cardElement.constants.d.ts.map +1 -1
  22. package/dist/elements/types/CardPayload.type.d.ts +0 -6
  23. package/dist/elements/types/CardPayload.type.d.ts.map +1 -1
  24. package/dist/elements/types/index.d.ts +1 -1
  25. package/dist/elements/types/index.d.ts.map +1 -1
  26. package/dist/elements.d.ts +1 -1
  27. package/dist/elements.d.ts.map +1 -1
  28. package/dist/elements.es.js +269 -335
  29. package/dist/factories/createForm.d.ts.map +1 -1
  30. package/dist/index.css +1 -1
  31. package/dist/locales/cs.json.d.ts +1 -0
  32. package/dist/locales/de.json.d.ts +1 -0
  33. package/dist/locales/en.json.d.ts +1 -0
  34. package/dist/locales/es.json.d.ts +1 -0
  35. package/dist/locales/fr.json.d.ts +1 -0
  36. package/dist/locales/it.json.d.ts +1 -0
  37. package/dist/locales/nl.json.d.ts +1 -0
  38. package/dist/locales/pl.json.d.ts +1 -0
  39. package/dist/locales/pt.json.d.ts +1 -0
  40. package/dist/locales/sk.json.d.ts +1 -0
  41. package/dist/locales/tr.json.d.ts +1 -0
  42. package/dist/phone.js +46 -45
  43. package/dist/services/checkout/CheckoutAPI.service.d.ts +1 -1
  44. package/dist/services/checkout/CheckoutAPI.service.d.ts.map +1 -1
  45. package/dist/services/checkout/CheckoutForm.service.d.ts +6 -0
  46. package/dist/services/checkout/CheckoutForm.service.d.ts.map +1 -1
  47. package/dist/shared.js +3656 -5960
  48. package/dist/shared2.js +13 -0
  49. package/dist/types/common/FormData.type.d.ts +0 -3
  50. package/dist/types/common/FormData.type.d.ts.map +1 -1
  51. package/dist/types/telemetry/TelemetryEvents.type.d.ts +15 -0
  52. package/dist/types/telemetry/TelemetryEvents.type.d.ts.map +1 -1
  53. package/dist/utils/focus/FocusManager.d.ts.map +1 -1
  54. package/dist/utils/validation/createValidationSchema.d.ts +0 -3
  55. package/dist/utils/validation/createValidationSchema.d.ts.map +1 -1
  56. package/package.json +1 -2
  57. package/dist/components/checkout/card-elements/CardCvvElement.d.ts +0 -28
  58. package/dist/components/checkout/card-elements/CardCvvElement.d.ts.map +0 -1
  59. package/dist/components/checkout/card-elements/CardNumberElement.d.ts +0 -32
  60. package/dist/components/checkout/card-elements/CardNumberElement.d.ts.map +0 -1
  61. package/dist/components/checkout/card-elements/index.d.ts +0 -3
  62. package/dist/components/checkout/card-elements/index.d.ts.map +0 -1
  63. package/dist/elements/card/NativeCardAdapter.d.ts +0 -35
  64. package/dist/elements/card/NativeCardAdapter.d.ts.map +0 -1
  65. package/dist/utils/card/detectCardBrand.d.ts +0 -3
  66. package/dist/utils/card/detectCardBrand.d.ts.map +0 -1
  67. package/dist/utils/card/luhnCheck.d.ts +0 -7
  68. package/dist/utils/card/luhnCheck.d.ts.map +0 -1
  69. package/dist/utils/formatters/formatters.d.ts +0 -6
  70. package/dist/utils/formatters/formatters.d.ts.map +0 -1
@@ -1,18 +1,99 @@
1
- import { A as e, B as t, C as n, E as r, F as i, G as a, H as o, I as s, J as c, K as l, L as u, M as d, N as f, O as p, P as m, Q as h, S as g, T as ee, V as te, X as _, Y as v, Z as y, a as b, b as x, c as S, d as C, g as w, h as T, j as E, k as D, l as O, m as k, n as A, o as j, p as M, q as N, r as ne, s as re, t as ie, u as P, w as F, x as I, y as L, z as R } from "./shared.js";
1
+ import { A as e, B as t, C as n, D as r, E as i, F as a, G as o, H as s, I as c, J as l, K as u, L as d, M as f, N as p, P as m, R as h, S as g, T as _, U as v, W as y, X as b, Y as x, _ as S, a as C, b as w, c as ee, d as T, f as E, g as D, h as O, j as k, k as te, l as A, m as j, n as M, o as N, q as P, r as ne, s as re, t as F, u as I, w as L, x as R, z } from "./shared.js";
2
+ import { t as B } from "./shared2.js";
3
+ //#region libs/checkout/src/utils/focus/FocusManager.ts
4
+ var V = class {
5
+ focusSequence = [
6
+ "cardNumber",
7
+ "cardExpiry",
8
+ "cardCvv",
9
+ "name"
10
+ ];
11
+ currentFocusIndex = 0;
12
+ fields = {
13
+ email: null,
14
+ phoneNumber: null,
15
+ cardNumber: null,
16
+ cardExpiry: null,
17
+ cardCvv: null,
18
+ name: null
19
+ };
20
+ fieldValidState = {
21
+ email: !1,
22
+ phoneNumber: !1,
23
+ cardNumber: !1,
24
+ cardExpiry: !1,
25
+ cardCvv: !1,
26
+ name: !1
27
+ };
28
+ previousFieldValidState = {
29
+ email: !1,
30
+ phoneNumber: !1,
31
+ cardNumber: !1,
32
+ cardExpiry: !1,
33
+ cardCvv: !1,
34
+ name: !1
35
+ };
36
+ registerField(e, t) {
37
+ this.fields[e] = t;
38
+ }
39
+ handleFieldFocus(e) {
40
+ let t = this.focusSequence.findIndex((t) => t === e);
41
+ t >= 0 && (this.currentFocusIndex = t);
42
+ }
43
+ handleStateUpdate(e, t, n) {
44
+ Object.assign(this.previousFieldValidState, this.fieldValidState);
45
+ let r = !!e.email && !t.email && !!n.email;
46
+ this.fieldValidState.email = r;
47
+ let i = !!e.phoneNumber && !t.phoneNumber && !!n.phoneNumber;
48
+ this.fieldValidState.phoneNumber = i;
49
+ let a = !!e.name && !t.name && !!n.name;
50
+ this.fieldValidState.name = a, this.checkForValidTransitions();
51
+ }
52
+ checkForValidTransitions() {
53
+ let e = this.focusSequence[this.currentFocusIndex];
54
+ e && this.fieldValidState[e] && !this.previousFieldValidState[e] && this.focusNextField();
55
+ }
56
+ focusNextField() {
57
+ this.currentFocusIndex = Math.min(this.currentFocusIndex + 1, this.focusSequence.length - 1), this.applyFocusToCurrentField();
58
+ }
59
+ focusFieldByIndex(e) {
60
+ e >= 0 && e < this.focusSequence.length && (this.currentFocusIndex = e, this.applyFocusToCurrentField());
61
+ }
62
+ applyFocusToCurrentField() {
63
+ let e = this.focusSequence[this.currentFocusIndex], t = this.fields[e];
64
+ t && setTimeout(() => {
65
+ t.focus();
66
+ }, 0);
67
+ }
68
+ focusCardNumberField() {
69
+ this.currentFocusIndex = 0, this.applyFocusToCurrentField();
70
+ }
71
+ focusField(e) {
72
+ let t = this.focusSequence.findIndex((t) => t === e);
73
+ if (t >= 0) this.currentFocusIndex = t, this.applyFocusToCurrentField();
74
+ else if (this.fields[e]) {
75
+ let t = this.fields[e];
76
+ t && setTimeout(() => {
77
+ t.focus();
78
+ }, 0);
79
+ }
80
+ }
81
+ };
82
+ //#endregion
2
83
  //#region libs/checkout/src/utils/helpers/hasAddressConfiguration.util.ts
3
- function z(e) {
84
+ function H(e) {
4
85
  if (!e) return !1;
5
86
  let { billingFields: t, shippingFields: n } = e, r = t && Object.values(t).some((e) => e?.enabled), i = n && Object.values(n).some((e) => e?.enabled);
6
87
  return !!(r || i);
7
88
  }
8
- function B(e) {
89
+ function U(e) {
9
90
  if (!e) return !1;
10
91
  let { billingFields: t, shippingFields: n } = e, r = t?.firstName?.enabled && t?.lastName?.enabled, i = n?.firstName?.enabled && n?.lastName?.enabled;
11
92
  return !!(r || i);
12
93
  }
13
94
  //#endregion
14
95
  //#region libs/checkout/src/components/checkout/form/AddressSection.ts
15
- var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
96
+ var W = /* @__PURE__ */ new Set(["US", "CA"]), G = class extends g {
16
97
  inputs = /* @__PURE__ */ new Map();
17
98
  type;
18
99
  onChange;
@@ -34,7 +115,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
34
115
  let e = document.createElement("h3");
35
116
  e.className = "address-section-title", e.textContent = t, e.style.color = n.styles.textColor, e.style.fontFamily = `"${n.styles.fontFamily}", sans-serif`, e.style.fontSize = `${n.styles.fontSize}px`, e.style.fontWeight = "normal", this.getElement().appendChild(e);
36
117
  }
37
- 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(n, r, i, a, o), this.grouped && (this.groupMessage = new k({
118
+ 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(n, r, i, a, o), this.grouped && (this.groupMessage = new O({
38
119
  text: "",
39
120
  visible: !1
40
121
  }), this.fieldsContainer.appendChild(this.groupMessage.getElement()));
@@ -108,7 +189,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
108
189
  }
109
190
  if (e.kind === "state") {
110
191
  let e = this.createRow(["full"]);
111
- if (this.stateFieldConfig = t.state, this.stateRow = e, this.stateStyles = d(!0, !0), this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none"), V.has(n.country)) {
192
+ if (this.stateFieldConfig = t.state, this.stateRow = e, this.stateStyles = d(!0, !0), this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none"), W.has(n.country)) {
112
193
  let a = this.createStateSelect(n.state, r.state, i.state, this.stateStyles, n.country, t.state?.label);
113
194
  this.inputs.set("state", a), e.appendChild(a.getElement());
114
195
  } else {
@@ -124,7 +205,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
124
205
  return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
125
206
  }
126
207
  createInput(e, t, n, r, i, a, o, s) {
127
- let c = `${this.type}Address.${e}`, l = new C({
208
+ let c = `${this.type}Address.${e}`, l = new E({
128
209
  name: c,
129
210
  error: !1,
130
211
  errorMsg: void 0,
@@ -146,7 +227,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
146
227
  let t = this.translationFunc("validation.maxLengthExceeded");
147
228
  this.applyFieldError(e, !0, t.replace("{{max}}", String(s)));
148
229
  } else this.applyFieldError(e, !1);
149
- this.onChange(F({
230
+ this.onChange(B({
150
231
  type: "input",
151
232
  target: {
152
233
  name: c,
@@ -156,7 +237,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
156
237
  }
157
238
  });
158
239
  return l.addEventListener("blur", (e) => {
159
- this.onBlur(F({
240
+ this.onBlur(B({
160
241
  type: "blur",
161
242
  target: {
162
243
  name: c,
@@ -166,7 +247,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
166
247
  }), l;
167
248
  }
168
249
  createCountrySelect(e, t, n, r, i, a) {
169
- let o = `${this.type}Address.country`, s = w(i, this.locale), c = new P({
250
+ let o = `${this.type}Address.country`, s = S(i, this.locale), c = new T({
170
251
  name: o,
171
252
  error: !1,
172
253
  errorMsg: void 0,
@@ -180,7 +261,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
180
261
  onChange: (e) => {
181
262
  this.applyFieldError("country", !1);
182
263
  let t = e.target.value;
183
- this.onChange(F({
264
+ this.onChange(B({
184
265
  type: "change",
185
266
  target: {
186
267
  name: o,
@@ -190,7 +271,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
190
271
  }
191
272
  });
192
273
  return c.addEventListener("blur", (e) => {
193
- this.onBlur(F({
274
+ this.onBlur(B({
194
275
  type: "blur",
195
276
  target: {
196
277
  name: o,
@@ -208,11 +289,11 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
208
289
  return;
209
290
  }
210
291
  if (!r && n && (this.stateRow.style.display = ""), r) return;
211
- let i = this.inputs.get("state") instanceof P, a = V.has(e);
292
+ let i = this.inputs.get("state") instanceof T, a = W.has(e);
212
293
  if (i && a) {
213
294
  let t = this.inputs.get("state");
214
- if (t instanceof P) {
215
- let n = e === "CA" ? "CA" : "US", r = T(n), i = n === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
295
+ if (t instanceof T) {
296
+ let n = e === "CA" ? "CA" : "US", r = D(n), i = n === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
216
297
  t.setOptions(r, i);
217
298
  }
218
299
  this.clearStateValue();
@@ -228,7 +309,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
228
309
  if (!this.stateRow || !this.stateStyles) return;
229
310
  this.applyFieldError("state", !1);
230
311
  let t = this.inputs.get("state");
231
- if (t && (t.getElement().remove(), this.inputs.delete("state")), V.has(e)) {
312
+ if (t && (t.getElement().remove(), this.inputs.delete("state")), W.has(e)) {
232
313
  let t = this.createStateSelect("", void 0, void 0, this.stateStyles, e, this.stateFieldConfig?.label);
233
314
  this.inputs.set("state", t), this.stateRow.appendChild(t.getElement());
234
315
  } else {
@@ -240,7 +321,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
240
321
  let e = this.inputs.get("state");
241
322
  e && e.setValue("");
242
323
  let t = `${this.type}Address.state`;
243
- this.onChange(F({
324
+ this.onChange(B({
244
325
  type: "input",
245
326
  target: {
246
327
  name: t,
@@ -250,7 +331,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
250
331
  }));
251
332
  }
252
333
  createStateSelect(e, t, n, r, i, a) {
253
- let o = `${this.type}Address.state`, s = i === "CA" ? "CA" : "US", c = T(s), l = s === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), u = new P({
334
+ let o = `${this.type}Address.state`, s = i === "CA" ? "CA" : "US", c = D(s), l = s === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), u = new T({
254
335
  name: o,
255
336
  error: !1,
256
337
  errorMsg: void 0,
@@ -262,7 +343,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
262
343
  options: c,
263
344
  autocomplete: "address-level1",
264
345
  onChange: (e) => {
265
- this.applyFieldError("state", !1), this.onChange(F({
346
+ this.applyFieldError("state", !1), this.onChange(B({
266
347
  type: "change",
267
348
  target: {
268
349
  name: o,
@@ -272,7 +353,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
272
353
  }
273
354
  });
274
355
  return u.addEventListener("blur", (e) => {
275
- this.onBlur(F({
356
+ this.onBlur(B({
276
357
  type: "blur",
277
358
  target: {
278
359
  name: o,
@@ -300,7 +381,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
300
381
  this.stateFieldConfig = t.state;
301
382
  let e = this.createRow(["full"]);
302
383
  this.stateRow = e, this.stateStyles = o, this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none");
303
- let a = V.has(n.country), s = t.state?.label ?? this.translationFunc("address.state");
384
+ let a = W.has(n.country), s = t.state?.label ?? this.translationFunc("address.state");
304
385
  if (a) {
305
386
  let t = this.createStateSelect(n.state, r.state, i.state, o, n.country, s);
306
387
  this.inputs.set("state", t), e.appendChild(t.getElement());
@@ -366,7 +447,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
366
447
  let e = this.inputs.values().next().value;
367
448
  e && e.focus();
368
449
  }
369
- }, U = class {
450
+ }, K = class {
370
451
  input = null;
371
452
  isVgsMode;
372
453
  vgsWrapper = null;
@@ -374,7 +455,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
374
455
  vgsHelperText = null;
375
456
  wrapperElement;
376
457
  _vgsFieldsReady = !1;
377
- _fieldHeight = x(L, 14);
458
+ _fieldHeight = R(w, 14);
378
459
  _borderRadius = 0;
379
460
  constructor(e) {
380
461
  let { value: t, onChange: n, onBlur: r, errorMsg: i, checkoutProfile: a, translationFunc: o, autocomplete: s = "cc-name", isVgsMode: c = !1 } = e;
@@ -382,16 +463,16 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
382
463
  }
383
464
  buildVgsLayout(e, t) {
384
465
  let n = e.styles.borderRadius;
385
- this._borderRadius = n, this._fieldHeight = x(L, e.styles.fontSize);
466
+ this._borderRadius = n, this._fieldHeight = R(w, e.styles.fontSize);
386
467
  let r = document.createElement("div");
387
468
  r.style.marginBottom = "4px";
388
469
  let i = document.createElement("label");
389
470
  i.className = "input-label", i.textContent = t("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), this.wrapperElement.appendChild(r), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${n}px`, this.vgsWrapper.style.height = this._fieldHeight, this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
390
471
  let a = document.createElement("div");
391
- a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), 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 k({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
472
+ a.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(a), 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 O({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
392
473
  }
393
474
  buildNativeLayout(e, t, n, r, i, a, o) {
394
- this.input = new C({
475
+ this.input = new E({
395
476
  name: "name",
396
477
  label: a("cardholderNameLabel"),
397
478
  error: !1,
@@ -418,9 +499,9 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
418
499
  }
419
500
  handleVgsStateChange(e, t) {
420
501
  if (!this.isVgsMode || !this.vgsWrapper) return;
421
- let n = e[S.CARDHOLDER]?.isFocused;
502
+ let n = e[A.CARDHOLDER]?.isFocused;
422
503
  if (this._vgsFieldsReady && (this.vgsWrapper.style.boxShadow = n ? "0 0 0 1px rgba(50, 151, 211, 0.7), 0 1px 1px 0 rgba(0, 0, 0, 0.07), 0 0 0 4px rgba(50, 151, 211, 0.3)" : "0 0 0 1px #e0e0e0, 0 2px 4px 0 rgba(0,0,0,0.07), 0 1px 1.5px 0 rgba(0,0,0,0.05)"), !t || !this.vgsHelperText) return;
423
- let r = t[S.CARDHOLDER];
504
+ let r = t[A.CARDHOLDER];
424
505
  r ? (this.vgsHelperText.setText(r), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
425
506
  }
426
507
  setFieldHeight(e) {
@@ -462,7 +543,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
462
543
  focus() {
463
544
  this.isVgsMode || this.input?.focus();
464
545
  }
465
- }, W = class extends I {
546
+ }, q = class extends g {
466
547
  constructor() {
467
548
  super("div", ["skeleton-container"]), this.createSkeletonElements();
468
549
  }
@@ -470,14 +551,14 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
470
551
  this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
471
552
  }
472
553
  createPaymentMethodSkeleton() {
473
- let e = M.createDiv(["skeleton-field"]), t = M.createDiv(["skeleton", "skeleton-payment-method"]);
554
+ let e = j.createDiv(["skeleton-field"]), t = j.createDiv(["skeleton", "skeleton-payment-method"]);
474
555
  return e.appendChild(t), e;
475
556
  }
476
557
  createPaymentSeparatorSkeleton() {
477
- let e = M.createDiv(["payment-separator_container"]), t = M.createDiv(["payment-separator__line"]), n = M.createDiv(["skeleton", "skeleton-separator-text"]), r = M.createDiv(["payment-separator__line"]);
558
+ let e = j.createDiv(["payment-separator_container"]), t = j.createDiv(["payment-separator__line"]), n = j.createDiv(["skeleton", "skeleton-separator-text"]), r = j.createDiv(["payment-separator__line"]);
478
559
  return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
479
560
  }
480
- }, G = class extends I {
561
+ }, J = class extends g {
481
562
  constructor(e) {
482
563
  let { translationFunc: t, checkoutProfile: n } = e;
483
564
  super("div", ["payment-separator"]);
@@ -488,7 +569,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
488
569
  let o = document.createElement("span");
489
570
  o.className = "payment-separator__line", r.appendChild(i), r.appendChild(a), r.appendChild(o);
490
571
  }
491
- }, K = class extends I {
572
+ }, Y = class extends g {
492
573
  paymentMethods;
493
574
  paymentSeparator;
494
575
  skeleton;
@@ -503,7 +584,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
503
584
  return;
504
585
  }
505
586
  let f = Object.entries(t.additionalPaymentMethods).filter(([e, t]) => {
506
- let n = t.enabled, r = !a || a[e] === !0, i = b(t.countries, d);
587
+ let n = t.enabled, r = !a || a[e] === !0, i = C(t.countries, d);
507
588
  return n && r && i;
508
589
  }).sort((e, t) => e[1].order - t[1].order);
509
590
  if (f.length === 0) {
@@ -513,7 +594,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
513
594
  for (let [e] of f) switch (e) {
514
595
  case "paypal":
515
596
  if (r) {
516
- let e = new A({
597
+ let e = new M({
517
598
  checkoutProfile: t,
518
599
  formData: n,
519
600
  onSubmit: r
@@ -540,13 +621,13 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
540
621
  break;
541
622
  default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
542
623
  }
543
- this.paymentMethods.size > 0 && (this.paymentSeparator = new G({
624
+ this.paymentMethods.size > 0 && (this.paymentSeparator = new J({
544
625
  translationFunc: o,
545
626
  checkoutProfile: t
546
627
  }), this.getElement().appendChild(this.paymentSeparator.getElement()));
547
628
  }
548
629
  renderSkeleton() {
549
- this.skeleton = new W(), this.getElement().appendChild(this.skeleton.getElement());
630
+ this.skeleton = new q(), this.getElement().appendChild(this.skeleton.getElement());
550
631
  }
551
632
  updateFormData(e) {
552
633
  let t = this.paymentMethods.get("paypal");
@@ -557,7 +638,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
557
638
  hasVisiblePaymentMethods() {
558
639
  return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
559
640
  }
560
- }, q = 17, J = class extends I {
641
+ }, ie = 17, ae = class extends g {
561
642
  styles;
562
643
  isHovered = !1;
563
644
  constructor(e) {
@@ -565,7 +646,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
565
646
  }
566
647
  applyStyles() {
567
648
  let e = this.getElement();
568
- e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius === q ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
649
+ e.style.backgroundColor = this.isHovered ? `color-mix(in srgb, ${this.styles.backgroundColor} 80%, transparent)` : this.styles.backgroundColor, e.disabled ? (e.style.color = "rgb(150, 150, 150)", e.style.backgroundColor = "rgb(200, 200, 200)") : e.style.color = this.styles.color, e.style.borderRadius = this.styles.borderRadius === ie ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
569
650
  }
570
651
  handleMouseEnter() {
571
652
  this.isHovered = !0, this.applyStyles();
@@ -576,11 +657,11 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
576
657
  setDisabled(e) {
577
658
  return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
578
659
  }
579
- }, ae = class {
660
+ }, oe = class {
580
661
  button;
581
662
  constructor(e) {
582
663
  let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
583
- this.button = new J({
664
+ this.button = new ae({
584
665
  text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
585
666
  styles: {
586
667
  backgroundColor: n.styles.buttonColor,
@@ -604,7 +685,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
604
685
  appendTo(e) {
605
686
  return this.button.appendTo(e), this;
606
687
  }
607
- }, oe = class {
688
+ }, se = class {
608
689
  formElement;
609
690
  focusManager;
610
691
  translationFunc;
@@ -620,11 +701,11 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
620
701
  checkoutDetails;
621
702
  environment;
622
703
  vgsService;
623
- onVgsStateChange;
624
704
  emailField;
625
705
  phoneNumberField;
626
706
  phonePlaceholder;
627
707
  cardSection;
708
+ cardUnavailableNotice;
628
709
  cardholderSection;
629
710
  submitButton;
630
711
  paymentMethods;
@@ -635,17 +716,14 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
635
716
  isCheckoutDetailsLoaded = !1;
636
717
  emailFocusHandler;
637
718
  phoneNumberFocusHandler;
638
- cardExpiryFocusHandler;
639
- cardNumberFocusHandler;
640
- cardCvvFocusHandler;
641
719
  nameFocusHandler;
642
720
  constructor(e) {
643
- this.formElement = e.formElement, this.focusManager = e.focusManager, this.translationFunc = e.translationFunc, this.locale = e.locale, this.onFieldFocus = e.onFieldFocus, this.onChange = e.onChange, this.onBlur = e.onBlur, this.onPaypalSubmit = e.onPaypalSubmit, this.onApplePaySubmit = e.onApplePaySubmit, this.supportedPaymentMethods = e.supportedPaymentMethods, this.paymentId = e.paymentId, this.checkoutKey = e.checkoutKey, this.checkoutDetails = e.checkoutDetails, this.environment = e.environment, this.vgsService = e.vgsService, this.onVgsStateChange = e.onVgsStateChange;
721
+ this.formElement = e.formElement, this.focusManager = e.focusManager, this.translationFunc = e.translationFunc, this.locale = e.locale, this.onFieldFocus = e.onFieldFocus, this.onChange = e.onChange, this.onBlur = e.onBlur, this.onPaypalSubmit = e.onPaypalSubmit, this.onApplePaySubmit = e.onApplePaySubmit, this.supportedPaymentMethods = e.supportedPaymentMethods, this.paymentId = e.paymentId, this.checkoutKey = e.checkoutKey, this.checkoutDetails = e.checkoutDetails, this.environment = e.environment, this.vgsService = e.vgsService, this.isCheckoutDetailsLoaded = !!(e.paymentId && e.checkoutDetails);
644
722
  }
645
723
  createPaymentMethods(e, t, n = !1) {
646
724
  try {
647
725
  if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
648
- this.paymentMethods = new K({
726
+ this.removePaymentMethods(), this.paymentMethods = new Y({
649
727
  checkoutProfile: e,
650
728
  formData: t,
651
729
  supportedPaymentMethods: this.supportedPaymentMethods,
@@ -665,7 +743,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
665
743
  createEmailField(e, t, n, r) {
666
744
  try {
667
745
  let i = e.layout.billingFields && Object.values(e.layout.billingFields).some((e) => e?.enabled) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some((e) => e?.enabled);
668
- this.emailField = new j({
746
+ this.emailField = new N({
669
747
  value: t.email,
670
748
  onChange: this.onChange,
671
749
  onBlur: this.onBlur,
@@ -679,72 +757,50 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
679
757
  throw console.error("Error creating email field:", e), e;
680
758
  }
681
759
  }
682
- createPhoneNumberField(e, t, n, r) {
683
- let i = document.createElement("div");
684
- this.phonePlaceholder = i, this.formElement.appendChild(i), o().then(({ PhoneNumberField: a }) => {
685
- i.isConnected && (this.phoneNumberField = new a({
686
- value: t.phoneNumber ?? "",
760
+ createPhoneNumberField(e, n, r, i) {
761
+ let a = document.createElement("div");
762
+ this.phonePlaceholder = a, this.formElement.appendChild(a), t().then(({ PhoneNumberField: t }) => {
763
+ a.isConnected && (this.phoneNumberField = new t({
764
+ value: n.phoneNumber ?? "",
687
765
  onChange: this.onChange,
688
766
  onBlur: this.onBlur,
689
767
  onTab: () => this.focusManager.focusField("cardNumber"),
690
- error: !!(n.phoneNumber && r.phoneNumber),
691
- errorMsg: n.phoneNumber,
768
+ error: !!(r.phoneNumber && i.phoneNumber),
769
+ errorMsg: r.phoneNumber,
692
770
  checkoutProfile: e,
693
771
  translationFunc: this.translationFunc,
694
772
  defaultCountry: e.layout.phoneNumber?.defaultCountry || "US",
695
773
  allowedCountries: e.layout.phoneNumber?.allowedCountries,
696
774
  locale: this.locale
697
- }), 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);
775
+ }), this.phoneNumberFocusHandler = () => this.onFieldFocus("phoneNumber"), this.phoneNumberField.getElement().addEventListener("focus", this.phoneNumberFocusHandler, !0), this.focusManager.registerField("phoneNumber", this.phoneNumberField), a.replaceWith(this.phoneNumberField.getElement()), this.phonePlaceholder = void 0);
698
776
  }).catch((e) => {
699
- console.error("Error creating phone number field:", e), i.remove(), this.phonePlaceholder = void 0;
777
+ console.error("Error creating phone number field:", e), a.remove(), this.phonePlaceholder = void 0;
700
778
  });
701
779
  }
702
780
  setCheckoutDetailsLoaded(e) {
703
781
  this.isCheckoutDetailsLoaded = e;
704
782
  }
705
- createCardSection(e, t, n, r) {
783
+ createCardSection(e) {
706
784
  try {
707
785
  if (!this.isCheckoutDetailsLoaded) {
708
786
  this.cardSectionSkeleton = this.buildCardSkeleton(e), this.formElement.appendChild(this.cardSectionSkeleton);
709
787
  return;
710
788
  }
711
- if (this.cardSection = new re({
789
+ if (!this.isCardSupported()) return;
790
+ if (!this.vgsService) {
791
+ this.cardUnavailableNotice = new re({
792
+ checkoutProfile: e,
793
+ translationFunc: this.translationFunc
794
+ }), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
795
+ return;
796
+ }
797
+ this.cardSection = new ee({
712
798
  checkoutProfile: e,
713
- cardNumber: t.cardNumber,
714
- cardNumberError: n.cardNumber,
715
- cardNumberTouched: !!r.cardNumber,
716
- cardCvv: t.cardCvv,
717
- cardCvvError: n.cardCvv,
718
- cardCvvTouched: !!r.cardCvv,
719
- cardExpiry: t.cardExpiry,
720
- cardExpiryError: n.cardExpiry,
721
- cardExpiryTouched: !!r.cardExpiry,
722
- onChange: this.onChange,
723
- onBlur: this.onBlur,
724
- onCardBrandChange: () => {
725
- t.cardCvv && this.onBlur(F({
726
- type: "blur",
727
- target: {
728
- name: "cardCvv",
729
- value: t.cardCvv
730
- }
731
- }));
732
- },
733
799
  translationFunc: this.translationFunc,
734
- vgsService: this.vgsService,
735
- onVgsStateChange: this.onVgsStateChange
736
- }), this.vgsService) this.cardSection.setOnVgsAutoFocus((e) => {
800
+ vgsService: this.vgsService
801
+ }), this.cardSection.setOnVgsAutoFocus((e) => {
737
802
  this.onFieldFocus(e);
738
- });
739
- else {
740
- let e = this.cardSection.getElement().querySelector("input[name=\"cardExpiry\"]");
741
- e && (this.cardExpiryFocusHandler = () => this.onFieldFocus("cardExpiry"), e.addEventListener("focus", this.cardExpiryFocusHandler));
742
- let t = this.cardSection.getElement().querySelector("input[name=\"cardNumber\"]");
743
- t && (this.cardNumberFocusHandler = () => this.onFieldFocus("cardNumber"), t.addEventListener("focus", this.cardNumberFocusHandler));
744
- let n = this.cardSection.getElement().querySelector("input[name=\"cardCvv\"]");
745
- n && (this.cardCvvFocusHandler = () => this.onFieldFocus("cardCvv"), n.addEventListener("focus", this.cardCvvFocusHandler));
746
- }
747
- this.focusManager.registerField("cardNumber", { focus: () => this.cardSection?.focusField("cardNumber") }), this.focusManager.registerField("cardExpiry", { focus: () => this.cardSection?.focusField("cardExpiry") }), this.focusManager.registerField("cardCvv", { focus: () => this.cardSection?.focusField("cardCvv") }), this.formElement.appendChild(this.cardSection.getElement());
803
+ }), this.focusManager.registerField("cardNumber", { focus: () => this.cardSection?.focusField("cardNumber") }), this.focusManager.registerField("cardExpiry", { focus: () => this.cardSection?.focusField("cardExpiry") }), this.focusManager.registerField("cardCvv", { focus: () => this.cardSection?.focusField("cardCvv") }), this.formElement.appendChild(this.cardSection.getElement());
748
804
  } catch (e) {
749
805
  throw console.error("Error creating card section:", e), e;
750
806
  }
@@ -755,7 +811,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
755
811
  this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
756
812
  return;
757
813
  }
758
- if (this.cardholderSection = new U({
814
+ if (this.cardholderSection = new K({
759
815
  value: t.name,
760
816
  onChange: this.onChange,
761
817
  onBlur: this.onBlur,
@@ -786,7 +842,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
786
842
  zipCode: "",
787
843
  country: ""
788
844
  };
789
- this.billingAddressSection = new H({
845
+ this.billingAddressSection = new G({
790
846
  type: "billing",
791
847
  title: this.translationFunc("address.billingTitle"),
792
848
  checkoutProfile: e,
@@ -817,7 +873,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
817
873
  zipCode: "",
818
874
  country: ""
819
875
  };
820
- this.shippingAddressSection = new H({
876
+ this.shippingAddressSection = new G({
821
877
  type: "shipping",
822
878
  title: this.translationFunc("address.shippingTitle"),
823
879
  checkoutProfile: e,
@@ -837,7 +893,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
837
893
  }
838
894
  createSubmitButton(e, t) {
839
895
  try {
840
- this.submitButton = new ae({
896
+ this.submitButton = new oe({
841
897
  disabled: t,
842
898
  checkoutProfile: e,
843
899
  translationFunc: this.translationFunc
@@ -852,9 +908,6 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
852
908
  updatePhoneNumberField(e, t, n) {
853
909
  this.phoneNumberField && (this.phoneNumberField.setValue(e), this.phoneNumberField.setError(t, n));
854
910
  }
855
- updateCardSection(e, t, n, r, i, a, o, s, c) {
856
- this.cardSection && (this.cardSection.updateCardNumber(e, t, n), this.cardSection.updateCardCvv(r, i, a), this.cardSection.updateCardExpiry(o, s, c));
857
- }
858
911
  updateCardholderSection(e, t, n) {
859
912
  this.cardholderSection && (this.cardholderSection.setValue(e), this.cardholderSection.setError(t, n));
860
913
  }
@@ -885,8 +938,11 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
885
938
  setVgsService(e) {
886
939
  this.vgsService = e;
887
940
  }
941
+ isCardSupported() {
942
+ return !this.supportedPaymentMethods || !!this.supportedPaymentMethods.card;
943
+ }
888
944
  buildCardSkeleton(e) {
889
- let t = e.styles.borderRadius, n = x(L, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
945
+ let t = e.styles.borderRadius, n = R(w, e.styles.fontSize), r = document.createElement("div"), i = document.createElement("div");
890
946
  i.style.marginBottom = "4px";
891
947
  let a = document.createElement("label");
892
948
  a.className = "input-label", a.textContent = this.translationFunc("cardInformation"), a.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.style.fontSize = `${e.styles.fontSize}px`, i.appendChild(a), r.appendChild(i);
@@ -915,7 +971,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
915
971
  let i = document.createElement("label");
916
972
  i.className = "input-label", i.textContent = this.translationFunc("cardholderNameLabel"), i.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, i.style.fontSize = `${e.styles.fontSize}px`, r.appendChild(i), n.appendChild(r);
917
973
  let a = document.createElement("div");
918
- return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = x(L, e.styles.fontSize), a.style.width = "100%", a.style.overflow = "hidden", a.style.background = "#fff", a.appendChild(this.createSkeletonDiv()), n.appendChild(a), n.appendChild(this.createHelperTextSpacer("form-helper-text-anchor")), n;
974
+ return a.style.position = "relative", a.style.borderRadius = `${t}px`, a.style.height = R(w, e.styles.fontSize), a.style.width = "100%", a.style.overflow = "hidden", a.style.background = "#fff", a.appendChild(this.createSkeletonDiv()), n.appendChild(a), n.appendChild(this.createHelperTextSpacer("form-helper-text-anchor")), n;
919
975
  }
920
976
  async mountVgsFields(e) {
921
977
  if (!this.vgsService || !this.cardSection) return;
@@ -937,10 +993,8 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
937
993
  cardExpiry: this.translationFunc("cardExpiry"),
938
994
  cardCvv: "CVV",
939
995
  cardholderName: this.translationFunc("cardholderNamePlaceholder")
940
- }, (e) => this.cardSection?.updateVgsCardBrand(e)), this.vgsService.waitForFieldsReady().then(() => {
941
- requestAnimationFrame(() => {
942
- this.cardSection?.hideFakePlaceholders(), this.cardholderSection?.hideFakePlaceholder();
943
- });
996
+ }, (e) => this.cardSection?.updateVgsCardBrand(e)), await this.vgsService.waitForFieldsReady(), requestAnimationFrame(() => {
997
+ this.cardSection?.hideFakePlaceholders(), this.cardholderSection?.hideFakePlaceholder();
944
998
  });
945
999
  }
946
1000
  handleVgsStateChange(e, t) {
@@ -955,21 +1009,13 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
955
1009
  let e = this.phoneNumberField.getElement().querySelector("input[name=\"phoneNumber\"]");
956
1010
  e && this.phoneNumberFocusHandler && e.removeEventListener("focus", this.phoneNumberFocusHandler), this.phoneNumberField.getElement().remove(), this.phoneNumberField = void 0;
957
1011
  }
958
- if (this.cardSectionSkeleton &&= (this.cardSectionSkeleton.remove(), void 0), this.cardSection) {
959
- let e = this.cardSection.getElement().querySelector("input[name=\"cardExpiry\"]");
960
- e && this.cardExpiryFocusHandler && e.removeEventListener("focus", this.cardExpiryFocusHandler);
961
- let t = this.cardSection.getElement().querySelector("input[name=\"cardNumber\"]");
962
- t && this.cardNumberFocusHandler && t.removeEventListener("focus", this.cardNumberFocusHandler);
963
- let n = this.cardSection.getElement().querySelector("input[name=\"cardCvv\"]");
964
- n && this.cardCvvFocusHandler && n.removeEventListener("focus", this.cardCvvFocusHandler), this.cardSection.getElement().remove(), this.cardSection = void 0;
965
- }
966
- if (this.cardholderSectionSkeleton &&= (this.cardholderSectionSkeleton.remove(), void 0), this.cardholderSection) {
1012
+ if (this.cardSectionSkeleton &&= (this.cardSectionSkeleton.remove(), void 0), this.cardSection &&= (this.cardSection.getElement().remove(), void 0), this.cardUnavailableNotice &&= (this.cardUnavailableNotice.getElement().remove(), void 0), this.cardholderSectionSkeleton &&= (this.cardholderSectionSkeleton.remove(), void 0), this.cardholderSection) {
967
1013
  let e = this.cardholderSection.getElement().querySelector("input[name=\"name\"]");
968
1014
  e && this.nameFocusHandler && e.removeEventListener("focus", this.nameFocusHandler), this.cardholderSection.getElement().remove(), this.cardholderSection = void 0;
969
1015
  }
970
1016
  this.billingAddressSection &&= (this.billingAddressSection.getElement().remove(), void 0), this.shippingAddressSection &&= (this.shippingAddressSection.getElement().remove(), void 0), this.submitButton &&= (this.submitButton.getElement().remove(), void 0), this.paymentMethods &&= (this.paymentMethods.getElement().remove(), void 0);
971
1017
  }
972
- }, se = class {
1018
+ }, ce = class {
973
1019
  formManager;
974
1020
  focusManager;
975
1021
  onFormSubmit;
@@ -1009,7 +1055,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1009
1055
  clearTouchedFields() {
1010
1056
  this.localTouchedFields.clear();
1011
1057
  }
1012
- }, ce = class {
1058
+ }, le = class {
1013
1059
  formManager;
1014
1060
  checkoutProfile;
1015
1061
  formElement;
@@ -1020,6 +1066,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1020
1066
  fontCleanup;
1021
1067
  isSubmitting = !1;
1022
1068
  isVgsMode = !1;
1069
+ isCardCaptureUnavailable = !1;
1023
1070
  vgsFieldsState = {};
1024
1071
  constructor(e) {
1025
1072
  this.formManager = e.formManager, this.checkoutProfile = e.checkoutProfile, this.formElement = e.formElement, this.onUIUpdate = e.onUIUpdate, this.onProfileLoaded = e.onProfileLoaded, this.onError = e.onError, this.onLoadingChange = e.onLoadingChange;
@@ -1031,7 +1078,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1031
1078
  if (!e.isLoading) {
1032
1079
  if (e.checkoutProfile) try {
1033
1080
  if (e.checkoutProfile.styles?.fontFamily) try {
1034
- let { cleanup: t } = ee({ fontFamily: e.checkoutProfile.styles.fontFamily });
1081
+ let { cleanup: t } = L({ fontFamily: e.checkoutProfile.styles.fontFamily });
1035
1082
  this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
1036
1083
  } catch (e) {
1037
1084
  console.error("Error loading Google Font:", e);
@@ -1046,18 +1093,22 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1046
1093
  }
1047
1094
  };
1048
1095
  isFormDisabled() {
1049
- let e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), n = Object.keys(e.errors).filter((e) => e !== "billingAddress" && e !== "shippingAddress").length > 0, r = e.errors.billingAddress, i = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, a = e.errors.shippingAddress, o = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, s = n || i || o, c = B(t.checkoutProfile?.layout) ? !!(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: u, shippingFields: d } = t.checkoutProfile?.layout ?? {}, f = /* @__PURE__ */ new Set(["US", "CA"]), p = (e, t) => {
1096
+ if (this.isCardCaptureUnavailable) return !0;
1097
+ let e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), n = Object.keys(e.errors).filter((e) => e !== "billingAddress" && e !== "shippingAddress").length > 0, r = e.errors.billingAddress, i = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, a = e.errors.shippingAddress, o = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, s = n || i || o, c = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: l, shippingFields: u } = t.checkoutProfile?.layout ?? {}, d = /* @__PURE__ */ new Set(["US", "CA"]), f = (e, t) => {
1050
1098
  if (!e) return !0;
1051
1099
  let n = t?.country ?? "";
1052
- return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!f.has(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
1053
- }, m = !this.isVgsMode || Object.values(this.vgsFieldsState).every((e) => e?.isValid === !0), h = this.isVgsMode ? !!e.formData.email && l && m && p(u, e.formData.billingAddress) && p(d, e.formData.shippingAddress) : !!e.formData.email && l && c && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && p(u, e.formData.billingAddress) && p(d, e.formData.shippingAddress);
1100
+ return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!d.has(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
1101
+ }, p = Object.values(this.vgsFieldsState), m = p.length > 0 && p.every((e) => e?.isValid === !0), h = this.isVgsMode && !!e.formData.email && c && m && f(l, e.formData.billingAddress) && f(u, e.formData.shippingAddress);
1054
1102
  return s || !h || this.isSubmitting;
1055
1103
  }
1056
1104
  setSubmitting(e) {
1057
1105
  this.isSubmitting = e;
1058
1106
  }
1059
1107
  setVgsMode(e) {
1060
- this.isVgsMode = e;
1108
+ this.isVgsMode = e, e || (this.vgsFieldsState = {});
1109
+ }
1110
+ setCardCaptureUnavailable(e) {
1111
+ this.isCardCaptureUnavailable = e;
1061
1112
  }
1062
1113
  updateVgsState(e) {
1063
1114
  this.vgsFieldsState = e;
@@ -1068,7 +1119,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1068
1119
  if (!r?.isTouched || r.isFocused || r.isValid) continue;
1069
1120
  let i = r.errors?.[0];
1070
1121
  if (!i) continue;
1071
- let a = O(n, i.code);
1122
+ let a = I(n, i.code);
1072
1123
  a && (t[n] = e(a));
1073
1124
  }
1074
1125
  return t;
@@ -1079,17 +1130,17 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1079
1130
  cleanup() {
1080
1131
  this.fontCleanup &&= (this.fontCleanup(), void 0);
1081
1132
  }
1082
- }, le = class extends I {
1133
+ }, ue = class extends g {
1083
1134
  titleElement;
1084
1135
  constructor(e = {}) {
1085
1136
  super("div", ["blur-bg"]);
1086
- let t = M.createDiv(["loader"]);
1087
- this.titleElement = new I("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
1137
+ let t = j.createDiv(["loader"]);
1138
+ this.titleElement = new g("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
1088
1139
  }
1089
1140
  setText(e) {
1090
1141
  return this.titleElement.setText(e), this;
1091
1142
  }
1092
- }, Y = {
1143
+ }, X = {
1093
1144
  street: "",
1094
1145
  firstName: "",
1095
1146
  lastName: "",
@@ -1097,7 +1148,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1097
1148
  city: "",
1098
1149
  zipCode: "",
1099
1150
  country: ""
1100
- }, X = (e, t) => {
1151
+ }, Z = (e, t) => {
1101
1152
  let n = {}, r = `${t}.`;
1102
1153
  return Object.keys(e).forEach((t) => {
1103
1154
  if (t.startsWith(r)) {
@@ -1105,11 +1156,11 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1105
1156
  n[i] = e[t];
1106
1157
  }
1107
1158
  }), n;
1108
- }, ue = class {
1159
+ }, de = class {
1109
1160
  formElement;
1110
1161
  componentManager;
1111
1162
  onLoadingStateChange;
1112
- validationSchema = u();
1163
+ validationSchema = h();
1113
1164
  spinner;
1114
1165
  formSkeleton;
1115
1166
  alert;
@@ -1117,17 +1168,17 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1117
1168
  this.formElement = e.formElement, this.componentManager = e.componentManager, this.onLoadingStateChange = e.onLoadingStateChange;
1118
1169
  }
1119
1170
  updateFormUI(e, t) {
1120
- this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardSection(e.formData.cardNumber, e.errors.cardNumber, !!e.touched.cardNumber, e.formData.cardCvv, e.errors.cardCvv, !!e.touched.cardCvv, e.formData.cardExpiry, e.errors.cardExpiry, !!e.touched.cardExpiry), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ?? Y, e.errors.billingAddress ?? {}, X(e.touched, "billingAddress")), this.componentManager.updateShippingAddressSection(e.formData.shippingAddress ?? Y, e.errors.shippingAddress ?? {}, X(e.touched, "shippingAddress")), this.componentManager.updateSubmitButton(t);
1171
+ this.componentManager.updatePaymentMethods(e.formData), this.componentManager.updateEmailField(e.formData.email, !!(e.errors.email && e.touched.email), e.errors.email, e.touched.email ? this.validationSchema.emailSuggestion(e.formData.email) : void 0), this.componentManager.updatePhoneNumberField(e.formData.phoneNumber ?? "", !!(e.errors.phoneNumber && e.touched.phoneNumber), e.errors.phoneNumber), this.componentManager.updateCardholderSection(e.formData.name, !!(e.errors.name && e.touched.name), e.errors.name), this.componentManager.updateBillingAddressSection(e.formData.billingAddress ?? X, e.errors.billingAddress ?? {}, Z(e.touched, "billingAddress")), this.componentManager.updateShippingAddressSection(e.formData.shippingAddress ?? X, e.errors.shippingAddress ?? {}, Z(e.touched, "shippingAddress")), this.componentManager.updateSubmitButton(t);
1121
1172
  }
1122
1173
  setLoadingState(e) {
1123
1174
  if (this.onLoadingStateChange) {
1124
1175
  this.onLoadingStateChange(e);
1125
1176
  return;
1126
1177
  }
1127
- e ? (this.hideSkeleton(), this.formSkeleton = new W(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
1178
+ e ? (this.hideSkeleton(), this.formSkeleton = new q(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
1128
1179
  }
1129
1180
  showSpinner(e) {
1130
- this.hideSpinner(), this.spinner = new le({ text: e }), this.formElement.appendChild(this.spinner.getElement());
1181
+ this.hideSpinner(), this.spinner = new ue({ text: e }), this.formElement.appendChild(this.spinner.getElement());
1131
1182
  }
1132
1183
  hideSpinner() {
1133
1184
  this.spinner &&= (this.spinner.getElement().remove(), void 0);
@@ -1136,7 +1187,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1136
1187
  this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
1137
1188
  }
1138
1189
  setErrorMessage(e) {
1139
- this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new ie({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
1190
+ this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new F({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
1140
1191
  }
1141
1192
  clearErrorMessage() {
1142
1193
  this.alert &&= (this.alert.getElement().remove(), void 0);
@@ -1146,7 +1197,7 @@ var V = /* @__PURE__ */ new Set(["US", "CA"]), H = class extends I {
1146
1197
  }
1147
1198
  };
1148
1199
  globalThis.navigator.userAgent;
1149
- var Z = (e) => ({
1200
+ var Q = (e) => ({
1150
1201
  street: "",
1151
1202
  firstName: "",
1152
1203
  lastName: "",
@@ -1155,12 +1206,12 @@ var Z = (e) => ({
1155
1206
  zipCode: "",
1156
1207
  country: "",
1157
1208
  ...e
1158
- }), Q = class extends I {
1209
+ }), fe = class extends g {
1159
1210
  options;
1160
- formManager = s();
1211
+ formManager = d();
1161
1212
  checkoutProfile;
1162
1213
  translation = r();
1163
- focusManager = new g();
1214
+ focusManager = new V();
1164
1215
  componentManager;
1165
1216
  eventHandler;
1166
1217
  stateCoordinator;
@@ -1168,8 +1219,13 @@ var Z = (e) => ({
1168
1219
  vgsService;
1169
1220
  vgsJwt;
1170
1221
  vgsCardResult;
1222
+ isCardCaptureUnavailable = !1;
1223
+ vgsMountGeneration = 0;
1224
+ isDestroyed = !1;
1171
1225
  constructor(e) {
1172
- super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new t()), this.checkoutProfile = R({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new oe({
1226
+ super("form", ["form-container"]), this.options = e;
1227
+ let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
1228
+ e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new _()), this.checkoutProfile = z({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new se({
1173
1229
  formElement: this.element,
1174
1230
  focusManager: this.focusManager,
1175
1231
  translationFunc: this.translation.t,
@@ -1184,13 +1240,12 @@ var Z = (e) => ({
1184
1240
  checkoutKey: e.checkoutKey,
1185
1241
  checkoutDetails: e.checkoutDetails,
1186
1242
  environment: e.environment,
1187
- vgsService: this.vgsService,
1188
- onVgsStateChange: (e) => this.handleVgsStateChange(e)
1189
- }), this.uiManager = new ue({
1243
+ vgsService: this.vgsService
1244
+ }), this.uiManager = new de({
1190
1245
  formElement: this.element,
1191
1246
  componentManager: this.componentManager,
1192
1247
  onLoadingStateChange: e.onLoadingStateChange
1193
- }), this.stateCoordinator = new ce({
1248
+ }), this.stateCoordinator = new le({
1194
1249
  formManager: this.formManager,
1195
1250
  checkoutProfile: this.checkoutProfile,
1196
1251
  componentManager: this.componentManager,
@@ -1200,7 +1255,7 @@ var Z = (e) => ({
1200
1255
  onError: (e) => this.uiManager.setErrorMessage(e),
1201
1256
  onLoadingChange: (e) => this.uiManager.setLoadingState(e),
1202
1257
  getInitialFormData: () => this._getFormStateData().formData
1203
- }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new se({
1258
+ }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new ce({
1204
1259
  formManager: this.formManager,
1205
1260
  focusManager: this.focusManager,
1206
1261
  onFormSubmit: async () => this.handleSubmit(),
@@ -1212,8 +1267,8 @@ var Z = (e) => ({
1212
1267
  ...e.initialValues.email && { email: e.initialValues.email },
1213
1268
  ...e.initialValues.phoneNumber && { phoneNumber: e.initialValues.phoneNumber },
1214
1269
  ...e.initialValues.name && { name: e.initialValues.name },
1215
- ...e.initialValues.billingAddress && { billingAddress: Z(e.initialValues.billingAddress) },
1216
- ...e.initialValues.shippingAddress && { shippingAddress: Z(e.initialValues.shippingAddress) }
1270
+ ...e.initialValues.billingAddress && { billingAddress: Q(e.initialValues.billingAddress) },
1271
+ ...e.initialValues.shippingAddress && { shippingAddress: Q(e.initialValues.shippingAddress) }
1217
1272
  }), this.initializeForm(), this.appendTo(e.container);
1218
1273
  }
1219
1274
  _getFormStateData() {
@@ -1226,22 +1281,42 @@ var Z = (e) => ({
1226
1281
  cardExpiry: "",
1227
1282
  cardNumber: "",
1228
1283
  cardCvv: "",
1229
- ...t?.billingAddress && { billingAddress: Z(t.billingAddress) },
1230
- ...t?.shippingAddress && { shippingAddress: Z(t.shippingAddress) }
1284
+ ...t?.billingAddress && { billingAddress: Q(t.billingAddress) },
1285
+ ...t?.shippingAddress && { shippingAddress: Q(t.shippingAddress) }
1231
1286
  },
1232
1287
  errors: e.errors || {},
1233
1288
  touched: e.touched || {}
1234
1289
  };
1235
1290
  }
1236
1291
  initializeForm() {
1237
- this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), this.vgsService && this.vgsService.init(this.options.environment).then((e) => {
1238
- this.vgsService?.createForm(e, (e) => this.handleVgsStateChange(e));
1239
- }).catch((e) => {
1240
- console.error("Failed to load VGS Collect:", e), this.fallBackToNativeCardFields();
1241
- });
1292
+ if (this.uiManager.setLoadingState(!0), this.options.errorMsg && this.uiManager.setErrorMessage(this.options.errorMsg), !this.vgsService && this.options.paymentId && this.options.checkoutDetails) {
1293
+ this.failCardCaptureClosed(P.NO_TOKENIZATION_SESSION);
1294
+ return;
1295
+ }
1296
+ if (this.vgsService) {
1297
+ let e = this.vgsService;
1298
+ e.init(this.options.environment).then((t) => {
1299
+ this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
1300
+ }).catch((t) => {
1301
+ this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(P.INIT_FAILED));
1302
+ });
1303
+ }
1304
+ }
1305
+ failCardCaptureClosed(e) {
1306
+ if (this.isDestroyed) return;
1307
+ if (!this.componentManager.isCardSupported()) {
1308
+ this.dropVgsService(), this.isCardCaptureUnavailable = !1, this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!1), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
1309
+ return;
1310
+ }
1311
+ let t = this.isCardCaptureUnavailable;
1312
+ this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), t || y(l.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
1242
1313
  }
1243
- fallBackToNativeCardFields() {
1244
- this.vgsService = void 0, this.vgsJwt = void 0, this.componentManager.setVgsService(void 0), this.stateCoordinator.setVgsMode(!1), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents();
1314
+ dropVgsService() {
1315
+ let e = this.vgsService;
1316
+ this.vgsService = void 0, this.vgsJwt = void 0, this.componentManager.setVgsService(void 0), e?.destroy();
1317
+ }
1318
+ recoverCardCapture() {
1319
+ this.isCardCaptureUnavailable && (this.isCardCaptureUnavailable = !1, this.stateCoordinator.setCardCaptureUnavailable(!1), this.updateFormUI());
1245
1320
  }
1246
1321
  renderFormComponents() {
1247
1322
  let e = this.checkoutProfile.getState();
@@ -1252,8 +1327,8 @@ var Z = (e) => ({
1252
1327
  this.componentManager.hasComponents() && this.componentManager.cleanup(), e.checkoutProfile.layout.phoneNumber?.enabled && this.formManager.getFormState().formData.phoneNumber === void 0 && this.formManager.setFormData({
1253
1328
  phoneNumber: "",
1254
1329
  phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
1255
- }), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({ billingAddress: Z() }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({ shippingAddress: Z() });
1256
- let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = z(e.checkoutProfile.layout);
1330
+ }), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({ billingAddress: Q() }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({ shippingAddress: Q() });
1331
+ let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = H(e.checkoutProfile.layout);
1257
1332
  try {
1258
1333
  this.componentManager.createPaymentMethods(e.checkoutProfile, t);
1259
1334
  } catch (e) {
@@ -1282,18 +1357,21 @@ var Z = (e) => ({
1282
1357
  console.error("Failed to create phone number field:", e);
1283
1358
  }
1284
1359
  try {
1285
- this.componentManager.createCardSection(e.checkoutProfile, t, n, r);
1360
+ this.componentManager.createCardSection(e.checkoutProfile);
1286
1361
  } catch (e) {
1287
1362
  console.error("Failed to create card section:", e);
1288
1363
  }
1289
- if (!B(e.checkoutProfile.layout)) try {
1364
+ if (!U(e.checkoutProfile.layout) && this.componentManager.isCardSupported()) try {
1290
1365
  this.componentManager.createCardholderSection(e.checkoutProfile, t, n, r);
1291
1366
  } catch (e) {
1292
1367
  console.error("Failed to create cardholder section:", e);
1293
1368
  }
1294
- this.vgsService && this.componentManager.mountVgsFields(e.checkoutProfile).catch((e) => {
1295
- console.error("Failed to mount VGS fields:", e);
1296
- });
1369
+ if (this.vgsService) {
1370
+ let t = this.vgsService, n = ++this.vgsMountGeneration;
1371
+ this.componentManager.mountVgsFields(e.checkoutProfile).catch((e) => {
1372
+ this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(P.FIELDS_NOT_READY));
1373
+ });
1374
+ }
1297
1375
  try {
1298
1376
  this.componentManager.createSubmitButton(e.checkoutProfile, this.stateCoordinator.isFormDisabled());
1299
1377
  } catch (e) {
@@ -1306,7 +1384,7 @@ var Z = (e) => ({
1306
1384
  }
1307
1385
  inferCardholderName() {
1308
1386
  let e = this.checkoutProfile.getState();
1309
- if (!e.checkoutProfile || !B(e.checkoutProfile.layout)) return;
1387
+ if (!e.checkoutProfile || !U(e.checkoutProfile.layout)) return;
1310
1388
  let { formData: t } = this._getFormStateData(), n = t.billingAddress ?? t.shippingAddress;
1311
1389
  if (!n) return;
1312
1390
  let r = [n.firstName?.trim() ?? "", n.lastName?.trim() ?? ""].filter(Boolean).join(" ");
@@ -1325,7 +1403,11 @@ var Z = (e) => ({
1325
1403
  }
1326
1404
  async handleSubmit() {
1327
1405
  if (!this.stateCoordinator.isFormDisabled()) try {
1328
- if (this.stateCoordinator.setSubmitting(!0), this.updateFormUI(), this.options.onLoadingStateChange?.(!0), this.uiManager.showSpinner(this.translation.t("loading")), this.inferCardholderName(), this.inferAddresses(), this.vgsService && this.vgsJwt) try {
1406
+ if (this.stateCoordinator.setSubmitting(!0), this.updateFormUI(), this.options.onLoadingStateChange?.(!0), this.uiManager.showSpinner(this.translation.t("loading")), this.inferCardholderName(), this.inferAddresses(), !this.vgsService || !this.vgsJwt) {
1407
+ this.handleSubmitError(this.translation.t("cardUnavailable"));
1408
+ return;
1409
+ }
1410
+ try {
1329
1411
  this.vgsCardResult = await this.vgsService.createCard(this.vgsJwt);
1330
1412
  } catch (e) {
1331
1413
  console.error("VGS card creation failed:", e), this.handleSubmitError("Card processing failed. Please check your card details and try again.");
@@ -1379,21 +1461,27 @@ var Z = (e) => ({
1379
1461
  e.locale && this.translation.setLocale(e.locale), e.appearance && this.checkoutProfile.updateProfile(e.appearance), e.locale && (this.componentManager.cleanup(), this.renderFormComponents());
1380
1462
  }
1381
1463
  destroy() {
1382
- this.vgsService?.destroy(), this.stateCoordinator.cleanup(), this.eventHandler.clearTouchedFields(), this.getElement().removeEventListener("submit", this.eventHandler.handleSubmit), this.getElement().removeEventListener("keydown", this.eventHandler.handleKeyDown), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
1383
- }
1384
- associatePayment(e, n, r, i, a) {
1385
- this.options.paymentId = e, this.options.checkoutKey = n, this.options.supportedPaymentMethods = r, this.options.checkoutDetails = i, this.componentManager.setCheckoutDetailsLoaded(!0), a && !this.vgsService && (this.vgsJwt = a, this.vgsService = new t(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((e) => {
1386
- this.vgsService?.createForm(e, (e) => this.handleVgsStateChange(e)), this.renderFormComponents();
1387
- }).catch((e) => {
1388
- console.error("Failed to load VGS Collect:", e), this.fallBackToNativeCardFields();
1389
- })), this.componentManager.removePaymentMethods(), this.componentManager.updateSupportedPaymentMethods(r), this.componentManager.updatePaymentDetails(e, n, i), !a && this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents();
1464
+ this.isDestroyed = !0, this.vgsMountGeneration += 1, this.vgsService?.destroy(), this.vgsService = void 0, this.stateCoordinator.cleanup(), this.eventHandler.clearTouchedFields(), this.getElement().removeEventListener("submit", this.eventHandler.handleSubmit), this.getElement().removeEventListener("keydown", this.eventHandler.handleKeyDown), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
1465
+ }
1466
+ associatePayment(e, t, n, r, i) {
1467
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails = r, this.componentManager.setCheckoutDetailsLoaded(!0), this.componentManager.updateSupportedPaymentMethods(n);
1468
+ let a = this.componentManager.isCardSupported();
1469
+ if (i && a && (this.vgsJwt = i), i && a && !this.vgsService) {
1470
+ let e = new _();
1471
+ this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
1472
+ this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
1473
+ }).catch((t) => {
1474
+ this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(P.INIT_FAILED));
1475
+ });
1476
+ }
1477
+ this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(P.NO_TOKENIZATION_SESSION);
1390
1478
  let o = this.checkoutProfile.getState();
1391
1479
  if (o.checkoutProfile) {
1392
1480
  let { formData: e } = this._getFormStateData();
1393
1481
  this.componentManager.createPaymentMethods(o.checkoutProfile, e, !0);
1394
1482
  }
1395
1483
  }
1396
- }, de = class {
1484
+ }, pe = class {
1397
1485
  container = null;
1398
1486
  options;
1399
1487
  onSubmit;
@@ -1417,7 +1505,7 @@ var Z = (e) => ({
1417
1505
  }
1418
1506
  }
1419
1507
  renderForm(e) {
1420
- this.container && (this.form &&= (this.form.destroy(), null), this.form = new Q({
1508
+ this.container && (this.form &&= (this.form.destroy(), null), this.form = new fe({
1421
1509
  apiKey: this.options.apiKey,
1422
1510
  onSubmit: this.onSubmit,
1423
1511
  locale: this.options.locale,
@@ -1430,7 +1518,8 @@ var Z = (e) => ({
1430
1518
  checkoutKey: this.options.checkoutKey,
1431
1519
  checkoutDetails: this.options.checkoutDetails,
1432
1520
  initialValues: this.options.initialValues,
1433
- vgsJwt: this.options.vgsJwt
1521
+ vgsJwt: this.options.vgsJwt,
1522
+ supportedPaymentMethods: this.options.supportedPaymentMethods
1434
1523
  }));
1435
1524
  }
1436
1525
  unmount() {
@@ -1444,9 +1533,9 @@ var Z = (e) => ({
1444
1533
  this.form && this.form.clearErrorMessage();
1445
1534
  }
1446
1535
  async associatePayment(e, t, n, r, i) {
1447
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = r, this.options.vgsJwt = i, this.form && this.form.associatePayment(e, t, n, r, i);
1536
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = r, this.options.vgsJwt = i, this.options.supportedPaymentMethods = n, this.form && this.form.associatePayment(e, t, n, r, i);
1448
1537
  }
1449
- }, fe = class {
1538
+ }, me = class {
1450
1539
  state;
1451
1540
  listeners = /* @__PURE__ */ new Set();
1452
1541
  constructor(e) {
@@ -1470,7 +1559,7 @@ var Z = (e) => ({
1470
1559
  let e = this.getState();
1471
1560
  this.listeners.forEach((t) => t(e));
1472
1561
  }
1473
- }, pe = "en", $ = class {
1562
+ }, he = "en", $ = class {
1474
1563
  config;
1475
1564
  _callbacks;
1476
1565
  paymentState;
@@ -1479,14 +1568,14 @@ var Z = (e) => ({
1479
1568
  stateManager;
1480
1569
  sessionId;
1481
1570
  constructor(e) {
1482
- this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), a({
1571
+ this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), s({
1483
1572
  environment: this.config.environment,
1484
1573
  sessionId: this.sessionId,
1485
1574
  integration: "dropin"
1486
- }), N(_.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new te(this.config.apiKey, this.config.environment), this.stateManager = new fe({
1575
+ }), y(l.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new i(this.config.apiKey, this.config.environment), this.stateManager = new me({
1487
1576
  mounted: !1,
1488
1577
  form: null
1489
- }), this.formManager = new de({
1578
+ }), this.formManager = new pe({
1490
1579
  locale: this.config.locale,
1491
1580
  apiKey: this.config.apiKey,
1492
1581
  disableErrorMessages: this.config.disableErrorMessages,
@@ -1503,7 +1592,7 @@ var Z = (e) => ({
1503
1592
  apiKey: e.apiKey,
1504
1593
  returnUrl: e.returnUrl,
1505
1594
  environment: e.environment,
1506
- locale: e.locale || pe,
1595
+ locale: e.locale || he,
1507
1596
  disableErrorMessages: e.disableErrorMessages ?? !1,
1508
1597
  manualActionHandling: e.manualActionHandling ?? !1,
1509
1598
  appearance: e.appearance,
@@ -1524,15 +1613,15 @@ var Z = (e) => ({
1524
1613
  return t = document.createElement("div"), n.appendChild(t), this.stateManager.updateState({
1525
1614
  form: t,
1526
1615
  mounted: !0
1527
- }), this.formManager.mount(t), N(_.CHECKOUT_MOUNTED, { container_id: e }), this;
1616
+ }), this.formManager.mount(t), y(l.CHECKOUT_MOUNTED, { container_id: e }), this;
1528
1617
  } catch (n) {
1529
1618
  throw t?.remove(), this.stateManager.updateState({
1530
1619
  form: null,
1531
1620
  mounted: !1
1532
- }), N(_.CHECKOUT_MOUNT_FAILED, {
1621
+ }), y(l.CHECKOUT_MOUNT_FAILED, {
1533
1622
  container_id: e,
1534
1623
  error_message: n instanceof Error ? n.message : "Unknown error"
1535
- }), l(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n;
1624
+ }), v(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n;
1536
1625
  }
1537
1626
  }
1538
1627
  unmount() {
@@ -1543,13 +1632,13 @@ var Z = (e) => ({
1543
1632
  e && e.remove(), this.stateManager.updateState({
1544
1633
  form: null,
1545
1634
  mounted: !1
1546
- }), N(_.CHECKOUT_UNMOUNTED);
1635
+ }), y(l.CHECKOUT_UNMOUNTED);
1547
1636
  });
1548
1637
  }
1549
1638
  async handleSubmit({ formData: e, applePayData: t }) {
1550
1639
  if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
1551
1640
  let n = this.getPaymentMethod(e, t);
1552
- N(_.PAYMENT_SUBMIT_STARTED, {
1641
+ y(l.PAYMENT_SUBMIT_STARTED, {
1553
1642
  payment_id: this.paymentState.paymentId,
1554
1643
  payment_method: n
1555
1644
  });
@@ -1562,21 +1651,21 @@ var Z = (e) => ({
1562
1651
  returnUrl: this.config.returnUrl,
1563
1652
  applePayData: t
1564
1653
  }), a = performance.now() - r;
1565
- return v(y.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
1654
+ return u(x.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
1566
1655
  payment_id: this.paymentState.paymentId,
1567
1656
  payment_method: n,
1568
1657
  status: "success"
1569
- }), N(_.PAYMENT_SUBMIT_SUCCESS, {
1658
+ }), y(l.PAYMENT_SUBMIT_SUCCESS, {
1570
1659
  payment_id: this.paymentState.paymentId,
1571
1660
  payment_method: n
1572
1661
  }), this.handlePaymentResponse(i);
1573
1662
  } catch (e) {
1574
1663
  let t = performance.now() - r;
1575
- return v(y.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
1664
+ return u(x.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
1576
1665
  payment_id: this.paymentState.paymentId,
1577
1666
  payment_method: n,
1578
1667
  status: "failed"
1579
- }), N(_.PAYMENT_SUBMIT_FAILED, {
1668
+ }), y(l.PAYMENT_SUBMIT_FAILED, {
1580
1669
  payment_id: this.paymentState.paymentId,
1581
1670
  payment_method: n,
1582
1671
  error_message: e.details?.message ?? "Unknown error"
@@ -1585,15 +1674,15 @@ var Z = (e) => ({
1585
1674
  }
1586
1675
  handlePaymentResponse(e) {
1587
1676
  let t = !1;
1588
- if (e.latestTransaction.status === "authorized" && (N(_.PAYMENT_AUTHORIZED, {
1677
+ if (e.latestTransaction.status === "authorized" && (y(l.PAYMENT_AUTHORIZED, {
1589
1678
  payment_id: this.paymentState.paymentId ?? "",
1590
1679
  status: e.latestTransaction.status
1591
- }), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (N(_.PAYMENT_FAILED, {
1680
+ }), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (y(l.PAYMENT_FAILED, {
1592
1681
  payment_id: this.paymentState.paymentId ?? "",
1593
1682
  status: e.latestTransaction.status
1594
1683
  }), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
1595
1684
  let { redirectUrl: n } = e.action;
1596
- N(_.PAYMENT_ACTION_REQUIRED, {
1685
+ y(l.PAYMENT_ACTION_REQUIRED, {
1597
1686
  payment_id: this.paymentState.paymentId ?? "",
1598
1687
  status: e.status
1599
1688
  }), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(n) : globalThis.location.href = n, t = !0;
@@ -1630,7 +1719,7 @@ var Z = (e) => ({
1630
1719
  if (!e || !t) throw Error("paymentId and checkoutKey are required");
1631
1720
  this.paymentState.paymentId = e, this.paymentState.checkoutKey = t;
1632
1721
  try {
1633
- let n = await h({
1722
+ let n = await b({
1634
1723
  id: e,
1635
1724
  checkoutKey: t,
1636
1725
  environment: this.config.environment
@@ -1643,16 +1732,16 @@ var Z = (e) => ({
1643
1732
  countryCode: n.countryCode
1644
1733
  };
1645
1734
  let r = n.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
1646
- await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt), N(_.PAYMENT_ASSOCIATED, {
1735
+ await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt), y(l.PAYMENT_ASSOCIATED, {
1647
1736
  payment_id: e,
1648
1737
  currency: n.currency,
1649
1738
  country_code: n.countryCode
1650
1739
  });
1651
1740
  } catch (t) {
1652
- throw N(_.PAYMENT_ASSOCIATION_FAILED, {
1741
+ throw y(l.PAYMENT_ASSOCIATION_FAILED, {
1653
1742
  payment_id: e,
1654
1743
  error_message: t instanceof Error ? t.message : "Unknown error"
1655
- }), l(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), t;
1744
+ }), v(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), t;
1656
1745
  }
1657
1746
  }
1658
1747
  setCallbacks(e) {
@@ -1663,4 +1752,4 @@ var Z = (e) => ({
1663
1752
  //#region libs/checkout/src/index.ts
1664
1753
  typeof globalThis < "u" && (globalThis.OdusCheckout = $);
1665
1754
  //#endregion
1666
- export { $ as OdusCheckout, i as deLocale, m as enLocale, f as esLocale, d as frLocale, E as itLocale, e as plLocale, D as ptLocale, l as pushError, N as pushEvent, c as pushLog, v as pushMeasurement, p as trLocale };
1755
+ export { $ as OdusCheckout, c as deLocale, a as enLocale, m as esLocale, p as frLocale, f as itLocale, k as plLocale, e as ptLocale, v as pushError, y as pushEvent, o as pushLog, u as pushMeasurement, te as trLocale };