@odus/checkout 1.11.1 → 1.11.2

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 { $ as e, A as t, B as n, C as r, D 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, O as m, P as h, Q as g, R as _, S as ee, T as v, U as y, X as b, Y as x, Z as S, a as te, b as C, c as w, d as T, et as E, f as D, g as O, h as k, j as ne, k as re, l as A, m as j, n as ie, o as ae, q as M, r as N, s as P, t as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./shared.js";
1
+ import { $ as e, A 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, O as m, P as h, Q as g, R as _, S as v, V as ee, W as y, X as b, Y as x, Z as S, a as te, b as C, c as ne, d as w, et as T, f as E, g as D, h as O, j as k, k as re, l as A, m as j, n as ie, o as ae, q as M, r as oe, s as N, t as P, tt as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./shared.js";
2
2
  import { t as H } from "./shared2.js";
3
3
  //#region libs/checkout/src/utils/focus/FocusManager.ts
4
4
  var U = class {
@@ -115,7 +115,7 @@ var K = class extends C {
115
115
  let e = document.createElement("h3");
116
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);
117
117
  }
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 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({
119
119
  text: "",
120
120
  visible: !1
121
121
  }), this.fieldsContainer.appendChild(this.groupMessage.getElement()));
@@ -189,7 +189,7 @@ var K = class extends C {
189
189
  }
190
190
  if (e.kind === "state") {
191
191
  let e = this.createRow(["full"]);
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"), V(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"), _(n.country)) {
193
193
  let a = this.createStateSelect(n.state, r.state, i.state, this.stateStyles, n.country, t.state?.label);
194
194
  this.inputs.set("state", a), e.appendChild(a.getElement());
195
195
  } else {
@@ -205,7 +205,7 @@ var K = class extends C {
205
205
  return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
206
206
  }
207
207
  createInput(e, t, n, r, i, a, o, s) {
208
- let c = `${this.type}Address.${e}`, l = new D({
208
+ let c = `${this.type}Address.${e}`, l = new E({
209
209
  name: c,
210
210
  error: !1,
211
211
  errorMsg: void 0,
@@ -247,7 +247,7 @@ var K = class extends C {
247
247
  }), l;
248
248
  }
249
249
  createCountrySelect(e, t, n, r, i, a) {
250
- let o = `${this.type}Address.country`, s = O(i, this.locale), c = new T({
250
+ let o = `${this.type}Address.country`, s = D(i, this.locale), c = new w({
251
251
  name: o,
252
252
  error: !1,
253
253
  errorMsg: void 0,
@@ -283,33 +283,33 @@ var K = class extends C {
283
283
  handleCountryChange(e) {
284
284
  let t = this.currentCountry;
285
285
  if (this.currentCountry = e, !this.stateRow || !this.stateFieldConfig?.enabled) return;
286
- let r = this.stateFieldConfig.hiddenForCountries?.includes(t), i = this.stateFieldConfig.hiddenForCountries?.includes(e);
287
- if (i && !r) {
286
+ let n = this.stateFieldConfig.hiddenForCountries?.includes(t), r = this.stateFieldConfig.hiddenForCountries?.includes(e);
287
+ if (r && !n) {
288
288
  this.stateRow.style.display = "none", this.applyFieldError("state", !1), this.clearStateValue();
289
289
  return;
290
290
  }
291
- if (!i && r && (this.stateRow.style.display = ""), i) return;
292
- let a = this.inputs.get("state") instanceof T, o = V(e);
293
- if (a && o) {
291
+ if (!r && n && (this.stateRow.style.display = ""), r) return;
292
+ let i = this.inputs.get("state") instanceof w, a = _(e);
293
+ if (i && a) {
294
294
  let t = this.inputs.get("state");
295
- if (t instanceof T) {
296
- let r = n(e), i = d(r), a = this.translationFunc(_(r));
297
- t.setOptions(i, a);
295
+ if (t instanceof w) {
296
+ let n = V(e), r = c(n), i = this.translationFunc(d(n));
297
+ t.setOptions(r, i);
298
298
  }
299
299
  this.clearStateValue();
300
300
  return;
301
301
  }
302
- if (a !== o) {
302
+ if (i !== a) {
303
303
  this.rebuildStateField(e), this.clearStateValue();
304
304
  return;
305
305
  }
306
- !a && !o && t !== e && this.clearStateValue();
306
+ !i && !a && t !== e && this.clearStateValue();
307
307
  }
308
308
  rebuildStateField(e) {
309
309
  if (!this.stateRow || !this.stateStyles) return;
310
310
  this.applyFieldError("state", !1);
311
311
  let t = this.inputs.get("state");
312
- if (t && (t.getElement().remove(), this.inputs.delete("state")), V(e)) {
312
+ if (t && (t.getElement().remove(), this.inputs.delete("state")), _(e)) {
313
313
  let t = this.createStateSelect("", void 0, void 0, this.stateStyles, e, this.stateFieldConfig?.label);
314
314
  this.inputs.set("state", t), this.stateRow.appendChild(t.getElement());
315
315
  } else {
@@ -330,15 +330,15 @@ var K = class extends C {
330
330
  detail: { programmatic: !0 }
331
331
  }));
332
332
  }
333
- createStateSelect(e, t, r, i, a, o) {
334
- let s = `${this.type}Address.state`, c = n(a), l = d(c), u = this.translationFunc(_(c)), f = new T({
335
- name: s,
333
+ createStateSelect(e, t, n, r, i, a) {
334
+ let o = `${this.type}Address.state`, s = V(i), l = c(s), u = this.translationFunc(d(s)), f = new w({
335
+ name: o,
336
336
  error: !1,
337
337
  errorMsg: void 0,
338
- styles: i,
338
+ styles: r,
339
339
  placeholder: u,
340
340
  renderMessage: !this.grouped,
341
- ...!this.grouped && { label: o ?? u },
341
+ ...!this.grouped && { label: a ?? u },
342
342
  value: e,
343
343
  options: l,
344
344
  autocomplete: "address-level1",
@@ -346,7 +346,7 @@ var K = class extends C {
346
346
  this.applyFieldError("state", !1), this.onChange(H({
347
347
  type: "change",
348
348
  target: {
349
- name: s,
349
+ name: o,
350
350
  value: e.target.value
351
351
  }
352
352
  }));
@@ -356,7 +356,7 @@ var K = class extends C {
356
356
  this.onBlur(H({
357
357
  type: "blur",
358
358
  target: {
359
- name: s,
359
+ name: o,
360
360
  value: e.target.value
361
361
  }
362
362
  }));
@@ -381,7 +381,7 @@ var K = class extends C {
381
381
  this.stateFieldConfig = t.state;
382
382
  let e = this.createRow(["full"]);
383
383
  this.stateRow = e, this.stateStyles = o, this.currentCountry = n.country, t.state?.hiddenForCountries?.includes(n.country) && (e.style.display = "none");
384
- let a = V(n.country), s = t.state?.label ?? this.translationFunc("address.state");
384
+ let a = _(n.country), s = t.state?.label ?? this.translationFunc("address.state");
385
385
  if (a) {
386
386
  let t = this.createStateSelect(n.state, r.state, i.state, o, n.country, s);
387
387
  this.inputs.set("state", t), e.appendChild(t.getElement());
@@ -469,10 +469,10 @@ var K = class extends C {
469
469
  let i = document.createElement("label");
470
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";
471
471
  let a = document.createElement("div");
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 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());
473
473
  }
474
474
  buildNativeLayout(e, t, n, r, i, a, o) {
475
- this.input = new D({
475
+ this.input = new E({
476
476
  name: "name",
477
477
  label: a("cardholderNameLabel"),
478
478
  error: !1,
@@ -558,7 +558,7 @@ var K = class extends C {
558
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"]);
559
559
  return e.appendChild(t), e.appendChild(n), e.appendChild(r), e;
560
560
  }
561
- }, oe = class extends C {
561
+ }, se = class extends C {
562
562
  constructor(e) {
563
563
  let { translationFunc: t, checkoutProfile: n } = e;
564
564
  super("div", ["payment-separator"]);
@@ -569,7 +569,7 @@ var K = class extends C {
569
569
  let o = document.createElement("span");
570
570
  o.className = "payment-separator__line", r.appendChild(i), r.appendChild(a), r.appendChild(o);
571
571
  }
572
- }, se = class extends C {
572
+ }, ce = class extends C {
573
573
  paymentMethods;
574
574
  paymentSeparator;
575
575
  skeleton;
@@ -604,7 +604,7 @@ var K = class extends C {
604
604
  break;
605
605
  case "applePay":
606
606
  if (i && s && c) {
607
- let e = t.appearance?.additionalPaymentMethods?.applePay, r = new N({
607
+ let e = t.appearance?.additionalPaymentMethods?.applePay, r = new oe({
608
608
  checkoutProfile: t,
609
609
  formData: n,
610
610
  onSubmit: i,
@@ -621,7 +621,7 @@ var K = class extends C {
621
621
  break;
622
622
  default: console.warn(`[PaymentMethods] Unsupported payment method: ${e}`);
623
623
  }
624
- this.paymentMethods.size > 0 && (this.paymentSeparator = new oe({
624
+ this.paymentMethods.size > 0 && (this.paymentSeparator = new se({
625
625
  translationFunc: o,
626
626
  checkoutProfile: t
627
627
  }), this.getElement().appendChild(this.paymentSeparator.getElement()));
@@ -638,7 +638,7 @@ var K = class extends C {
638
638
  hasVisiblePaymentMethods() {
639
639
  return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
640
640
  }
641
- }, ce = 17, le = class extends C {
641
+ }, le = 17, ue = class extends C {
642
642
  styles;
643
643
  isHovered = !1;
644
644
  constructor(e) {
@@ -646,7 +646,7 @@ var K = class extends C {
646
646
  }
647
647
  applyStyles() {
648
648
  let e = this.getElement();
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 === ce ? "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 === le ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
650
650
  }
651
651
  handleMouseEnter() {
652
652
  this.isHovered = !0, this.applyStyles();
@@ -657,11 +657,11 @@ var K = class extends C {
657
657
  setDisabled(e) {
658
658
  return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
659
659
  }
660
- }, ue = class {
660
+ }, de = class {
661
661
  button;
662
662
  constructor(e) {
663
663
  let { disabled: t, checkoutProfile: n, translationFunc: r } = e;
664
- this.button = new le({
664
+ this.button = new ue({
665
665
  text: r(`buttonTexts.${n?.layout.actionButton.translationKey}`),
666
666
  styles: {
667
667
  backgroundColor: n.styles.buttonColor,
@@ -685,7 +685,7 @@ var K = class extends C {
685
685
  appendTo(e) {
686
686
  return this.button.appendTo(e), this;
687
687
  }
688
- }, de = class {
688
+ }, fe = class {
689
689
  formElement;
690
690
  focusManager;
691
691
  translationFunc;
@@ -723,7 +723,7 @@ var K = class extends C {
723
723
  createPaymentMethods(e, t, n = !1) {
724
724
  try {
725
725
  if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some((e) => e.enabled)) return;
726
- this.removePaymentMethods(), this.paymentMethods = new se({
726
+ this.removePaymentMethods(), this.paymentMethods = new ce({
727
727
  checkoutProfile: e,
728
728
  formData: t,
729
729
  supportedPaymentMethods: this.supportedPaymentMethods,
@@ -759,7 +759,7 @@ var K = class extends C {
759
759
  }
760
760
  createPhoneNumberField(e, t, n, r) {
761
761
  let i = document.createElement("div");
762
- this.phonePlaceholder = i, this.formElement.appendChild(i), y().then(({ PhoneNumberField: a }) => {
762
+ this.phonePlaceholder = i, this.formElement.appendChild(i), s().then(({ PhoneNumberField: a }) => {
763
763
  i.isConnected && (this.phoneNumberField = new a({
764
764
  value: t.phoneNumber ?? "",
765
765
  onChange: this.onChange,
@@ -788,13 +788,13 @@ var K = class extends C {
788
788
  }
789
789
  if (!this.isCardSupported()) return;
790
790
  if (!this.vgsService) {
791
- this.cardUnavailableNotice = new P({
791
+ this.cardUnavailableNotice = new N({
792
792
  checkoutProfile: e,
793
793
  translationFunc: this.translationFunc
794
794
  }), this.formElement.appendChild(this.cardUnavailableNotice.getElement());
795
795
  return;
796
796
  }
797
- this.cardSection = new w({
797
+ this.cardSection = new ne({
798
798
  checkoutProfile: e,
799
799
  translationFunc: this.translationFunc,
800
800
  vgsService: this.vgsService
@@ -893,7 +893,7 @@ var K = class extends C {
893
893
  }
894
894
  createSubmitButton(e, t) {
895
895
  try {
896
- this.submitButton = new ue({
896
+ this.submitButton = new de({
897
897
  disabled: t,
898
898
  checkoutProfile: e,
899
899
  translationFunc: this.translationFunc
@@ -975,20 +975,21 @@ var K = class extends C {
975
975
  }
976
976
  async mountVgsFields(e) {
977
977
  if (!this.vgsService || !this.cardSection) return;
978
+ let t = z(e.styles.fontFamily);
978
979
  await this.vgsService.whenReady();
979
- let t = this.cardSection.getVgsContainerIds(), n = this.cardholderSection?.getVgsContainerId(), r = await z(e.styles.fontFamily), i = this.cardSection.buildVgsFieldCss(e, r);
980
- if (this.cardholderSection && i.cardholderName) {
981
- let e = i.cardholderName;
980
+ let n = this.cardSection.getVgsContainerIds(), r = this.cardholderSection?.getVgsContainerId(), i = await t, a = this.cardSection.buildVgsFieldCss(e, i);
981
+ if (this.cardholderSection && a.cardholderName) {
982
+ let e = a.cardholderName;
982
983
  typeof e.height == "string" && this.cardholderSection.setFieldHeight(e.height);
983
984
  let t = e["border-radius"];
984
985
  typeof t == "string" && this.cardholderSection.setBorderRadius(parseFloat(t));
985
986
  }
986
987
  this.vgsService.mountCardFields({
987
- cardNumber: t.cardNumber ? `#${t.cardNumber}` : void 0,
988
- cardExpiry: t.cardExpiry ? `#${t.cardExpiry}` : void 0,
989
- cardCvv: t.cardCvv ? `#${t.cardCvv}` : void 0,
990
- cardholderName: n ? `#${n}` : void 0
991
- }, i, {
988
+ cardNumber: n.cardNumber ? `#${n.cardNumber}` : void 0,
989
+ cardExpiry: n.cardExpiry ? `#${n.cardExpiry}` : void 0,
990
+ cardCvv: n.cardCvv ? `#${n.cardCvv}` : void 0,
991
+ cardholderName: r ? `#${r}` : void 0
992
+ }, a, {
992
993
  cardNumber: "1234 5678 9012 3456",
993
994
  cardExpiry: this.translationFunc("cardExpiry"),
994
995
  cardCvv: "CVV",
@@ -1015,7 +1016,7 @@ var K = class extends C {
1015
1016
  }
1016
1017
  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);
1017
1018
  }
1018
- }, fe = class {
1019
+ }, pe = class {
1019
1020
  formManager;
1020
1021
  focusManager;
1021
1022
  onFormSubmit;
@@ -1055,7 +1056,7 @@ var K = class extends C {
1055
1056
  clearTouchedFields() {
1056
1057
  this.localTouchedFields.clear();
1057
1058
  }
1058
- }, pe = class {
1059
+ }, me = class {
1059
1060
  formManager;
1060
1061
  checkoutProfile;
1061
1062
  formElement;
@@ -1078,7 +1079,7 @@ var K = class extends C {
1078
1079
  if (!e.isLoading) {
1079
1080
  if (e.checkoutProfile) try {
1080
1081
  if (e.checkoutProfile.styles?.fontFamily) try {
1081
- let { cleanup: t } = ee({ fontFamily: e.checkoutProfile.styles.fontFamily });
1082
+ let { cleanup: t } = v({ fontFamily: e.checkoutProfile.styles.fontFamily });
1082
1083
  this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
1083
1084
  } catch (e) {
1084
1085
  console.error("Error loading Google Font:", e);
@@ -1097,7 +1098,7 @@ var K = class extends C {
1097
1098
  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 = (e, t) => {
1098
1099
  if (!e) return !0;
1099
1100
  let n = t?.country ?? "";
1100
- return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!V(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
1101
+ return Object.entries(e).every(([e, r]) => !r?.enabled || e === "state" && (!_(n) || r.hiddenForCountries?.includes(n)) ? !0 : !!t?.[e]?.trim());
1101
1102
  }, f = Object.values(this.vgsFieldsState), p = f.length > 0 && f.every((e) => e?.isValid === !0), m = this.isVgsMode && !!e.formData.email && c && p && d(l, e.formData.billingAddress) && d(u, e.formData.shippingAddress);
1102
1103
  return s || !m || this.isSubmitting;
1103
1104
  }
@@ -1130,7 +1131,7 @@ var K = class extends C {
1130
1131
  cleanup() {
1131
1132
  this.fontCleanup &&= (this.fontCleanup(), void 0);
1132
1133
  }
1133
- }, me = class extends C {
1134
+ }, he = class extends C {
1134
1135
  titleElement;
1135
1136
  constructor(e = {}) {
1136
1137
  super("div", ["blur-bg"]);
@@ -1156,11 +1157,11 @@ var K = class extends C {
1156
1157
  n[i] = e[t];
1157
1158
  }
1158
1159
  }), n;
1159
- }, he = class {
1160
+ }, Z = class {
1160
1161
  formElement;
1161
1162
  componentManager;
1162
1163
  onLoadingStateChange;
1163
- validationSchema = c();
1164
+ validationSchema = a();
1164
1165
  spinner;
1165
1166
  formSkeleton;
1166
1167
  alert;
@@ -1178,7 +1179,7 @@ var K = class extends C {
1178
1179
  e ? (this.hideSkeleton(), this.formSkeleton = new J(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
1179
1180
  }
1180
1181
  showSpinner(e) {
1181
- this.hideSpinner(), this.spinner = new me({ text: e }), this.formElement.appendChild(this.spinner.getElement());
1182
+ this.hideSpinner(), this.spinner = new he({ text: e }), this.formElement.appendChild(this.spinner.getElement());
1182
1183
  }
1183
1184
  hideSpinner() {
1184
1185
  this.spinner &&= (this.spinner.getElement().remove(), void 0);
@@ -1187,7 +1188,7 @@ var K = class extends C {
1187
1188
  this.formSkeleton &&= (this.formSkeleton.getElement().remove(), void 0);
1188
1189
  }
1189
1190
  setErrorMessage(e) {
1190
- this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new F({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
1191
+ this.alert &&= (this.alert.getElement().remove(), void 0), this.alert = new P({ message: e }), this.formElement.insertBefore(this.alert.getElement(), this.formElement.firstChild);
1191
1192
  }
1192
1193
  clearErrorMessage() {
1193
1194
  this.alert &&= (this.alert.getElement().remove(), void 0);
@@ -1197,7 +1198,7 @@ var K = class extends C {
1197
1198
  }
1198
1199
  };
1199
1200
  globalThis.navigator.userAgent;
1200
- var Z = (e) => ({
1201
+ var Q = (e) => ({
1201
1202
  street: "",
1202
1203
  firstName: "",
1203
1204
  lastName: "",
@@ -1208,9 +1209,9 @@ var Z = (e) => ({
1208
1209
  ...e
1209
1210
  }), ge = class extends C {
1210
1211
  options;
1211
- formManager = a();
1212
+ formManager = h();
1212
1213
  checkoutProfile;
1213
- translation = v();
1214
+ translation = R();
1214
1215
  focusManager = new U();
1215
1216
  componentManager;
1216
1217
  eventHandler;
@@ -1225,7 +1226,7 @@ var Z = (e) => ({
1225
1226
  constructor(e) {
1226
1227
  super("form", ["form-container"]), this.options = e;
1227
1228
  let t = !e.supportedPaymentMethods || !!e.supportedPaymentMethods.card;
1228
- e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new r()), this.checkoutProfile = s({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new de({
1229
+ e.vgsJwt && t && (this.vgsJwt = e.vgsJwt, this.vgsService = new o()), this.checkoutProfile = ee({ appearance: e.appearance }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new fe({
1229
1230
  formElement: this.element,
1230
1231
  focusManager: this.focusManager,
1231
1232
  translationFunc: this.translation.t,
@@ -1241,11 +1242,11 @@ var Z = (e) => ({
1241
1242
  checkoutDetails: e.checkoutDetails,
1242
1243
  environment: e.environment,
1243
1244
  vgsService: this.vgsService
1244
- }), this.uiManager = new he({
1245
+ }), this.uiManager = new Z({
1245
1246
  formElement: this.element,
1246
1247
  componentManager: this.componentManager,
1247
1248
  onLoadingStateChange: e.onLoadingStateChange
1248
- }), this.stateCoordinator = new pe({
1249
+ }), this.stateCoordinator = new me({
1249
1250
  formManager: this.formManager,
1250
1251
  checkoutProfile: this.checkoutProfile,
1251
1252
  componentManager: this.componentManager,
@@ -1255,7 +1256,7 @@ var Z = (e) => ({
1255
1256
  onError: (e) => this.uiManager.setErrorMessage(e),
1256
1257
  onLoadingChange: (e) => this.uiManager.setLoadingState(e),
1257
1258
  getInitialFormData: () => this._getFormStateData().formData
1258
- }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new fe({
1259
+ }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new pe({
1259
1260
  formManager: this.formManager,
1260
1261
  focusManager: this.focusManager,
1261
1262
  onFormSubmit: async () => this.handleSubmit(),
@@ -1267,8 +1268,8 @@ var Z = (e) => ({
1267
1268
  ...e.initialValues.email && { email: e.initialValues.email },
1268
1269
  ...e.initialValues.phoneNumber && { phoneNumber: e.initialValues.phoneNumber },
1269
1270
  ...e.initialValues.name && { name: e.initialValues.name },
1270
- ...e.initialValues.billingAddress && { billingAddress: Z(e.initialValues.billingAddress) },
1271
- ...e.initialValues.shippingAddress && { shippingAddress: Z(e.initialValues.shippingAddress) }
1271
+ ...e.initialValues.billingAddress && { billingAddress: Q(e.initialValues.billingAddress) },
1272
+ ...e.initialValues.shippingAddress && { shippingAddress: Q(e.initialValues.shippingAddress) }
1272
1273
  }), this.initializeForm(), this.appendTo(e.container);
1273
1274
  }
1274
1275
  _getFormStateData() {
@@ -1281,8 +1282,8 @@ var Z = (e) => ({
1281
1282
  cardExpiry: "",
1282
1283
  cardNumber: "",
1283
1284
  cardCvv: "",
1284
- ...t?.billingAddress && { billingAddress: Z(t.billingAddress) },
1285
- ...t?.shippingAddress && { shippingAddress: Z(t.shippingAddress) }
1285
+ ...t?.billingAddress && { billingAddress: Q(t.billingAddress) },
1286
+ ...t?.shippingAddress && { shippingAddress: Q(t.shippingAddress) }
1286
1287
  },
1287
1288
  errors: e.errors || {},
1288
1289
  touched: e.touched || {}
@@ -1290,7 +1291,7 @@ var Z = (e) => ({
1290
1291
  }
1291
1292
  initializeForm() {
1292
1293
  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(S.NO_TOKENIZATION_SESSION);
1294
+ this.failCardCaptureClosed(M.NO_TOKENIZATION_SESSION);
1294
1295
  return;
1295
1296
  }
1296
1297
  if (this.vgsService) {
@@ -1298,7 +1299,7 @@ var Z = (e) => ({
1298
1299
  e.init(this.options.environment).then((t) => {
1299
1300
  this.vgsService === e && e.createForm(t, (e) => this.handleVgsStateChange(e));
1300
1301
  }).catch((t) => {
1301
- this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(S.INIT_FAILED));
1302
+ this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(M.INIT_FAILED));
1302
1303
  });
1303
1304
  }
1304
1305
  }
@@ -1309,7 +1310,7 @@ var Z = (e) => ({
1309
1310
  return;
1310
1311
  }
1311
1312
  let t = this.isCardCaptureUnavailable;
1312
- this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), t || M(g.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
1313
+ this.isCardCaptureUnavailable = !0, this.dropVgsService(), this.stateCoordinator.setVgsMode(!1), this.stateCoordinator.setCardCaptureUnavailable(!0), t || g(l.CARD_CAPTURE_UNAVAILABLE, { reason: e }), this.checkoutProfile.getState().checkoutProfile && this.renderFormComponents(), this.updateFormUI();
1313
1314
  }
1314
1315
  dropVgsService() {
1315
1316
  let e = this.vgsService;
@@ -1327,7 +1328,7 @@ var Z = (e) => ({
1327
1328
  this.componentManager.hasComponents() && this.componentManager.cleanup(), e.checkoutProfile.layout.phoneNumber?.enabled && this.formManager.getFormState().formData.phoneNumber === void 0 && this.formManager.setFormData({
1328
1329
  phoneNumber: "",
1329
1330
  phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
1330
- }), 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() });
1331
+ }), 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
1332
  let { formData: t, errors: n, touched: r } = this._getFormStateData(), i = W(e.checkoutProfile.layout);
1332
1333
  try {
1333
1334
  this.componentManager.createPaymentMethods(e.checkoutProfile, t);
@@ -1369,7 +1370,7 @@ var Z = (e) => ({
1369
1370
  if (this.vgsService) {
1370
1371
  let t = this.vgsService, n = ++this.vgsMountGeneration;
1371
1372
  this.componentManager.mountVgsFields(e.checkoutProfile).catch((e) => {
1372
- this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(S.FIELDS_NOT_READY));
1373
+ this.vgsMountGeneration === n && this.vgsService === t && (console.error("Failed to mount VGS fields:", e), this.failCardCaptureClosed(M.FIELDS_NOT_READY));
1373
1374
  });
1374
1375
  }
1375
1376
  try {
@@ -1463,18 +1464,18 @@ var Z = (e) => ({
1463
1464
  destroy() {
1464
1465
  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
  }
1466
- associatePayment(e, t, n, i, a) {
1467
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails = i, this.componentManager.setCheckoutDetailsLoaded(!0), this.componentManager.updateSupportedPaymentMethods(n);
1468
- let o = this.componentManager.isCardSupported();
1469
- if (a && o && (this.vgsJwt = a), a && o && !this.vgsService) {
1470
- let e = new r();
1467
+ associatePayment(e, t, n, r, i) {
1468
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = n, this.options.checkoutDetails = r, this.componentManager.setCheckoutDetailsLoaded(!0), this.componentManager.updateSupportedPaymentMethods(n);
1469
+ let a = this.componentManager.isCardSupported();
1470
+ if (i && a && (this.vgsJwt = i), i && a && !this.vgsService) {
1471
+ let e = new o();
1471
1472
  this.vgsService = e, this.componentManager.setVgsService(e), this.stateCoordinator.setVgsMode(!0), e.init(this.options.environment).then((t) => {
1472
1473
  this.vgsService === e && (e.createForm(t, (e) => this.handleVgsStateChange(e)), this.recoverCardCapture(), this.renderFormComponents());
1473
1474
  }).catch((t) => {
1474
- this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(S.INIT_FAILED));
1475
+ this.vgsService === e && (console.error("Failed to load VGS Collect:", t), this.failCardCaptureClosed(M.INIT_FAILED));
1475
1476
  });
1476
1477
  }
1477
- this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, i), (!a || !o) && this.failCardCaptureClosed(S.NO_TOKENIZATION_SESSION);
1478
+ this.componentManager.removePaymentMethods(), this.componentManager.updatePaymentDetails(e, t, r), (!i || !a) && this.failCardCaptureClosed(M.NO_TOKENIZATION_SESSION);
1478
1479
  let s = this.checkoutProfile.getState();
1479
1480
  if (s.checkoutProfile) {
1480
1481
  let { formData: e } = this._getFormStateData();
@@ -1535,7 +1536,7 @@ var Z = (e) => ({
1535
1536
  async associatePayment(e, t, n, r, i) {
1536
1537
  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);
1537
1538
  }
1538
- }, Q = class {
1539
+ }, ve = class {
1539
1540
  state;
1540
1541
  listeners = /* @__PURE__ */ new Set();
1541
1542
  constructor(e) {
@@ -1559,7 +1560,7 @@ var Z = (e) => ({
1559
1560
  let e = this.getState();
1560
1561
  this.listeners.forEach((t) => t(e));
1561
1562
  }
1562
- }, ve = "en", $ = class {
1563
+ }, ye = "en", $ = class {
1563
1564
  config;
1564
1565
  _callbacks;
1565
1566
  paymentState;
@@ -1568,11 +1569,11 @@ var Z = (e) => ({
1568
1569
  stateManager;
1569
1570
  sessionId;
1570
1571
  constructor(e) {
1571
- this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), b(), o({
1572
+ this.config = this.validateConfig(e), this._callbacks = { ...this.config.callbacks }, this.paymentState = {}, this.sessionId = crypto.randomUUID(), y(), b({
1572
1573
  environment: this.config.environment,
1573
1574
  sessionId: this.sessionId,
1574
1575
  integration: "dropin"
1575
- }), M(g.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new R(this.config.apiKey, this.config.environment), this.stateManager = new Q({
1576
+ }), g(l.CHECKOUT_INITIALIZED, { environment: this.config.environment }), this.apiService = new n(this.config.apiKey, this.config.environment), this.stateManager = new ve({
1576
1577
  mounted: !1,
1577
1578
  form: null
1578
1579
  }), this.formManager = new _e({
@@ -1592,7 +1593,7 @@ var Z = (e) => ({
1592
1593
  apiKey: e.apiKey,
1593
1594
  returnUrl: e.returnUrl,
1594
1595
  environment: e.environment,
1595
- locale: e.locale || ve,
1596
+ locale: e.locale || ye,
1596
1597
  disableErrorMessages: e.disableErrorMessages ?? !1,
1597
1598
  manualActionHandling: e.manualActionHandling ?? !1,
1598
1599
  appearance: e.appearance,
@@ -1613,15 +1614,15 @@ var Z = (e) => ({
1613
1614
  return t = document.createElement("div"), n.appendChild(t), this.stateManager.updateState({
1614
1615
  form: t,
1615
1616
  mounted: !0
1616
- }), this.formManager.mount(t), M(g.CHECKOUT_MOUNTED, { container_id: e }), this;
1617
+ }), this.formManager.mount(t), g(l.CHECKOUT_MOUNTED, { container_id: e }), this;
1617
1618
  } catch (n) {
1618
1619
  throw t?.remove(), this.stateManager.updateState({
1619
1620
  form: null,
1620
1621
  mounted: !1
1621
- }), M(g.CHECKOUT_MOUNT_FAILED, {
1622
+ }), g(l.CHECKOUT_MOUNT_FAILED, {
1622
1623
  container_id: e,
1623
1624
  error_message: n instanceof Error ? n.message : "Unknown error"
1624
- }), u(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n;
1625
+ }), S(n instanceof Error ? n : /* @__PURE__ */ Error("Failed to mount checkout"), { container_id: e }), n;
1625
1626
  }
1626
1627
  }
1627
1628
  unmount() {
@@ -1632,57 +1633,57 @@ var Z = (e) => ({
1632
1633
  e && e.remove(), this.stateManager.updateState({
1633
1634
  form: null,
1634
1635
  mounted: !1
1635
- }), M(g.CHECKOUT_UNMOUNTED);
1636
+ }), g(l.CHECKOUT_UNMOUNTED);
1636
1637
  });
1637
1638
  }
1638
- async handleSubmit({ formData: t, applePayData: n }) {
1639
+ async handleSubmit({ formData: e, applePayData: t }) {
1639
1640
  if (!this.paymentState.paymentId || !this.paymentState.checkoutKey) throw Error("Payment must be associated before submitting. Call associatePayment() first.");
1640
- let r = this.getPaymentMethod(t, n);
1641
- M(g.PAYMENT_SUBMIT_STARTED, {
1641
+ let n = this.getPaymentMethod(e, t);
1642
+ g(l.PAYMENT_SUBMIT_STARTED, {
1642
1643
  payment_id: this.paymentState.paymentId,
1643
- payment_method: r
1644
+ payment_method: n
1644
1645
  });
1645
- let i = performance.now();
1646
+ let r = performance.now();
1646
1647
  try {
1647
- let a = await this.apiService.authorizePayment({
1648
+ let i = await this.apiService.authorizePayment({
1648
1649
  checkoutKey: this.paymentState.checkoutKey,
1649
- formData: t || null,
1650
+ formData: e || null,
1650
1651
  paymentId: this.paymentState.paymentId,
1651
1652
  returnUrl: this.config.returnUrl,
1652
- applePayData: n
1653
- }), o = performance.now() - i;
1654
- return x(e.PAYMENT_AUTHORIZATION_TIME, o, "ms", {
1653
+ applePayData: t
1654
+ }), a = performance.now() - r;
1655
+ return T(x.PAYMENT_AUTHORIZATION_TIME, a, "ms", {
1655
1656
  payment_id: this.paymentState.paymentId,
1656
- payment_method: r,
1657
+ payment_method: n,
1657
1658
  status: "success"
1658
- }), M(g.PAYMENT_SUBMIT_SUCCESS, {
1659
+ }), g(l.PAYMENT_SUBMIT_SUCCESS, {
1659
1660
  payment_id: this.paymentState.paymentId,
1660
- payment_method: r
1661
- }), this.handlePaymentResponse(a);
1662
- } catch (t) {
1663
- let n = performance.now() - i;
1664
- return x(e.PAYMENT_AUTHORIZATION_TIME, n, "ms", {
1661
+ payment_method: n
1662
+ }), this.handlePaymentResponse(i);
1663
+ } catch (e) {
1664
+ let t = performance.now() - r;
1665
+ return T(x.PAYMENT_AUTHORIZATION_TIME, t, "ms", {
1665
1666
  payment_id: this.paymentState.paymentId,
1666
- payment_method: r,
1667
+ payment_method: n,
1667
1668
  status: "failed"
1668
- }), M(g.PAYMENT_SUBMIT_FAILED, {
1669
+ }), g(l.PAYMENT_SUBMIT_FAILED, {
1669
1670
  payment_id: this.paymentState.paymentId,
1670
- payment_method: r,
1671
- error_message: t.details?.message ?? "Unknown error"
1672
- }), this.handleAuthorizationError(t), !1;
1671
+ payment_method: n,
1672
+ error_message: e.details?.message ?? "Unknown error"
1673
+ }), this.handleAuthorizationError(e), !1;
1673
1674
  }
1674
1675
  }
1675
1676
  handlePaymentResponse(e) {
1676
1677
  let t = !1;
1677
- if (e.latestTransaction.status === "authorized" && (M(g.PAYMENT_AUTHORIZED, {
1678
+ if (e.latestTransaction.status === "authorized" && (g(l.PAYMENT_AUTHORIZED, {
1678
1679
  payment_id: this.paymentState.paymentId ?? "",
1679
1680
  status: e.latestTransaction.status
1680
- }), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (M(g.PAYMENT_FAILED, {
1681
+ }), this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status), t = !0), e.latestTransaction.status === "failed" && (g(l.PAYMENT_FAILED, {
1681
1682
  payment_id: this.paymentState.paymentId ?? "",
1682
1683
  status: e.latestTransaction.status
1683
1684
  }), this._callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
1684
1685
  let { redirectUrl: n } = e.action;
1685
- M(g.PAYMENT_ACTION_REQUIRED, {
1686
+ g(l.PAYMENT_ACTION_REQUIRED, {
1686
1687
  payment_id: this.paymentState.paymentId ?? "",
1687
1688
  status: e.status
1688
1689
  }), this.config.manualActionHandling ? this._callbacks.onActionRequired?.(n) : globalThis.location.href = n, t = !0;
@@ -1717,9 +1718,9 @@ var Z = (e) => ({
1717
1718
  }
1718
1719
  async associatePayment(e, t) {
1719
1720
  if (!e || !t) throw Error("paymentId and checkoutKey are required");
1720
- this.paymentState.paymentId = e, this.paymentState.checkoutKey = t;
1721
+ this.paymentState.paymentId = e, this.paymentState.checkoutKey = t, u(this.config.environment);
1721
1722
  try {
1722
- let n = await E({
1723
+ let n = await F({
1723
1724
  id: e,
1724
1725
  checkoutKey: t,
1725
1726
  environment: this.config.environment
@@ -1732,16 +1733,16 @@ var Z = (e) => ({
1732
1733
  countryCode: n.countryCode
1733
1734
  };
1734
1735
  let r = n.supportedPaymentMethods.reduce((e, t) => (e[t] = !0, e), {});
1735
- await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt), M(g.PAYMENT_ASSOCIATED, {
1736
+ await this.formManager.associatePayment(e, t, r, this.paymentState.checkoutDetails, n.vgsJwt), g(l.PAYMENT_ASSOCIATED, {
1736
1737
  payment_id: e,
1737
1738
  currency: n.currency,
1738
1739
  country_code: n.countryCode
1739
1740
  });
1740
1741
  } catch (t) {
1741
- throw M(g.PAYMENT_ASSOCIATION_FAILED, {
1742
+ throw g(l.PAYMENT_ASSOCIATION_FAILED, {
1742
1743
  payment_id: e,
1743
1744
  error_message: t instanceof Error ? t.message : "Unknown error"
1744
- }), u(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), t;
1745
+ }), S(t instanceof Error ? t : /* @__PURE__ */ Error("Failed to associate payment"), { payment_id: e }), t;
1745
1746
  }
1746
1747
  }
1747
1748
  setCallbacks(e) {
@@ -1752,4 +1753,4 @@ var Z = (e) => ({
1752
1753
  //#region libs/checkout/src/index.ts
1753
1754
  typeof globalThis < "u" && (globalThis.OdusCheckout = $);
1754
1755
  //#endregion
1755
- export { $ as OdusCheckout, h as deLocale, p as enLocale, f as esLocale, ne as frLocale, t as itLocale, re as plLocale, m as ptLocale, u as pushError, M as pushEvent, l as pushLog, x as pushMeasurement, i as trLocale };
1756
+ export { $ as OdusCheckout, p as deLocale, f as enLocale, k as esLocale, t as frLocale, re as itLocale, m as plLocale, r as ptLocale, S as pushError, g as pushEvent, e as pushLog, T as pushMeasurement, i as trLocale };