@odus/checkout 0.29.0 → 0.29.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.
@@ -1,5 +1,5 @@
1
- import { c as ie, a as ce, f as V, d as he, C as A, I as re, g as ue, S as R, b as Z, e as w, A as me, P as pe, E as fe, l as ge, h as ye, i as be, j as Ee, k as Se, F as Fe, m as ve, n as Ce } from "./shared.js";
2
- import { o as vt, p as Ct, q as Mt, r as Nt, s as Pt, t as At, u as wt, v as kt } from "./shared.js";
1
+ import { c as le, a as he, f as j, d as ue, C as w, I as de, g as me, S as _, b as Q, e as k, A as pe, P as fe, E as ge, l as ye, h as be, i as Ee, j as Se, k as Fe, F as Ce, m as ve, n as Me } from "./shared.js";
2
+ import { o as vt, p as Mt, q as Nt, r as Pt, s as At, t as wt, u as kt, v as It } from "./shared.js";
3
3
  const v = {
4
4
  // Checkout lifecycle events
5
5
  CHECKOUT_INITIALIZED: "checkout.initialized",
@@ -16,86 +16,86 @@ const v = {
16
16
  PAYMENT_AUTHORIZED: "payment.authorized",
17
17
  PAYMENT_FAILED: "payment.failed",
18
18
  PAYMENT_ACTION_REQUIRED: "payment.action_required"
19
- }, G = {
19
+ }, J = {
20
20
  PAYMENT_AUTHORIZATION_TIME: "payment.authorization_time",
21
21
  CHECKOUT_LOAD_TIME: "checkout.load_time",
22
22
  FORM_RENDER_TIME: "form.render_time"
23
- }, Me = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, Ne = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Pe = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, q = (n) => {
23
+ }, Ne = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, Pe = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Ae = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, W = (n) => {
24
24
  if (!n)
25
25
  return [];
26
26
  const e = [], t = n.split(`
27
27
  `);
28
28
  for (const s of t) {
29
- const i = s.trim();
30
- if (!i)
29
+ const a = s.trim();
30
+ if (!a)
31
31
  continue;
32
- let a = Me.exec(i);
33
- if (a) {
32
+ let i = Ne.exec(a);
33
+ if (i) {
34
34
  e.push({
35
- function: a[1] || "(anonymous)",
36
- filename: a[2],
37
- lineno: parseInt(a[3], 10),
38
- colno: parseInt(a[4], 10)
35
+ function: i[1] || "(anonymous)",
36
+ filename: i[2],
37
+ lineno: parseInt(i[3], 10),
38
+ colno: parseInt(i[4], 10)
39
39
  });
40
40
  continue;
41
41
  }
42
- a = Ne.exec(i) ?? Pe.exec(i), a && e.push({
43
- function: a[1] || "(anonymous)",
44
- filename: a[2],
45
- lineno: parseInt(a[3], 10),
46
- colno: parseInt(a[4], 10)
42
+ i = Pe.exec(a) ?? Ae.exec(a), i && e.push({
43
+ function: i[1] || "(anonymous)",
44
+ filename: i[2],
45
+ lineno: parseInt(i[3], 10),
46
+ colno: parseInt(i[4], 10)
47
47
  });
48
48
  }
49
49
  return e;
50
- }, Ae = "@odus/telemetry", we = "0.0.1";
51
- let O, x, Y;
52
- const ke = () => {
50
+ }, we = "@odus/telemetry", ke = "0.0.1";
51
+ let V, H, G;
52
+ const Ie = () => {
53
53
  if (typeof navigator > "u")
54
54
  return {};
55
55
  const n = navigator.userAgent;
56
56
  let e, t, s;
57
57
  n.includes("Firefox/") ? (e = "Firefox", t = n.match(/Firefox\/([\d.]+)/)?.[1]) : n.includes("Edg/") ? (e = "Edge", t = n.match(/Edg\/([\d.]+)/)?.[1]) : n.includes("Chrome/") ? (e = "Chrome", t = n.match(/Chrome\/([\d.]+)/)?.[1]) : n.includes("Safari/") && (e = "Safari", t = n.match(/Version\/([\d.]+)/)?.[1]), n.includes("Windows") ? s = "Windows" : n.includes("Mac OS") ? s = "macOS" : n.includes("Linux") ? s = "Linux" : n.includes("Android") ? s = "Android" : (n.includes("iPhone") || n.includes("iPad")) && (s = "iOS");
58
- const i = /Mobi|Android|iPhone|iPad/i.test(n) || void 0;
58
+ const a = /Mobi|Android|iPhone|iPad/i.test(n) || void 0;
59
59
  return {
60
60
  name: e,
61
61
  version: t,
62
62
  os: s,
63
- mobile: i ?? !1,
63
+ mobile: a ?? !1,
64
64
  language: navigator.language,
65
65
  viewportWidth: String(window.innerWidth),
66
66
  viewportHeight: String(window.innerHeight),
67
67
  userAgent: n
68
68
  };
69
- }, Ie = () => typeof window > "u" ? {} : { url: window.location.href }, De = (n) => {
70
- O = void 0, Y = void 0, x = n.sessionTracking?.session ? { id: n.sessionTracking.session.id } : void 0;
71
- }, Te = (n) => {
72
- O = n;
73
- }, Le = () => {
74
- O = void 0;
75
- }, _e = (n) => {
76
- x = n;
69
+ }, De = () => typeof window > "u" ? {} : { url: window.location.href }, Te = (n) => {
70
+ V = void 0, G = void 0, H = n.sessionTracking?.session ? { id: n.sessionTracking.session.id } : void 0;
71
+ }, Le = (n) => {
72
+ V = n;
73
+ }, _e = () => {
74
+ V = void 0;
77
75
  }, Be = (n) => {
78
- Y = n;
79
- }, Oe = () => x?.id, xe = (n) => ({
80
- sdk: { name: Ae, version: we },
76
+ H = n;
77
+ }, Ue = (n) => {
78
+ G = n;
79
+ }, xe = () => H?.id, Oe = (n) => ({
80
+ sdk: { name: we, version: ke },
81
81
  app: n.app,
82
- user: O,
83
- session: x,
84
- page: Ie(),
85
- browser: ke(),
86
- view: Y
87
- }), Ue = 30, Ve = 250, Re = 6e4;
88
- let k = [], P = null, W = 0, T = null, L = null;
89
- const He = (n) => {
90
- if (P)
82
+ user: V,
83
+ session: H,
84
+ page: De(),
85
+ browser: Ie(),
86
+ view: G
87
+ }), Re = 30, Ve = 250, He = 6e4;
88
+ let I = [], A = null, X = 0, B = null, U = null;
89
+ const ze = (n) => {
90
+ if (A)
91
91
  return;
92
92
  const e = n.batching?.sendTimeout ?? Ve;
93
- P = setTimeout(() => {
94
- U(n);
93
+ A = setTimeout(() => {
94
+ z(n);
95
95
  }, e);
96
- }, ze = (n, e) => {
96
+ }, je = (n, e) => {
97
97
  const t = {
98
- meta: xe(e)
98
+ meta: Oe(e)
99
99
  };
100
100
  for (const s of n)
101
101
  switch (s.type) {
@@ -113,238 +113,238 @@ const He = (n) => {
113
113
  break;
114
114
  }
115
115
  return t;
116
- }, je = (n, e, t = !1) => {
117
- const s = JSON.stringify(n), i = Oe(), a = {
116
+ }, Ke = (n, e, t = !1) => {
117
+ const s = JSON.stringify(n), a = xe(), i = {
118
118
  "Content-Type": "application/json"
119
119
  };
120
- if (i && (a["x-faro-session-id"] = i), t && typeof navigator < "u" && navigator.sendBeacon) {
121
- const d = new Blob([s], { type: "application/json" });
122
- navigator.sendBeacon(e, d);
120
+ if (a && (i["x-faro-session-id"] = a), t && typeof navigator < "u" && navigator.sendBeacon) {
121
+ const l = new Blob([s], { type: "application/json" });
122
+ navigator.sendBeacon(e, l);
123
123
  return;
124
124
  }
125
- const r = s.length < Re;
125
+ const r = s.length < He;
126
126
  fetch(e, {
127
127
  method: "POST",
128
- headers: a,
128
+ headers: i,
129
129
  body: s,
130
130
  keepalive: r
131
- }).then((d) => {
132
- if (d.status === 429) {
133
- const l = d.headers.get("Retry-After"), u = l ? parseInt(l, 10) * 1e3 : 3e4;
134
- W = Date.now() + u;
131
+ }).then((l) => {
132
+ if (l.status === 429) {
133
+ const d = l.headers.get("Retry-After"), h = d ? parseInt(d, 10) * 1e3 : 3e4;
134
+ X = Date.now() + h;
135
135
  }
136
136
  }).catch(() => {
137
137
  });
138
- }, U = (n, e = !1) => {
139
- if (P && (clearTimeout(P), P = null), k.length === 0)
138
+ }, z = (n, e = !1) => {
139
+ if (A && (clearTimeout(A), A = null), I.length === 0)
140
140
  return;
141
- if (Date.now() < W) {
142
- k = [];
141
+ if (Date.now() < X) {
142
+ I = [];
143
143
  return;
144
144
  }
145
- const t = k;
146
- k = [];
145
+ const t = I;
146
+ I = [];
147
147
  try {
148
- let s = ze(t, n);
148
+ let s = je(t, n);
149
149
  if (n.beforeSend) {
150
- const i = n.beforeSend(s);
151
- if (!i)
150
+ const a = n.beforeSend(s);
151
+ if (!a)
152
152
  return;
153
- s = i;
153
+ s = a;
154
154
  }
155
- je(s, n.url, e);
155
+ Ke(s, n.url, e);
156
156
  } catch {
157
157
  }
158
- }, M = (n, e) => {
159
- k.push(n);
160
- const t = e.batching?.itemLimit ?? Ue;
161
- if (k.length >= t) {
162
- U(e);
158
+ }, P = (n, e) => {
159
+ I.push(n);
160
+ const t = e.batching?.itemLimit ?? Re;
161
+ if (I.length >= t) {
162
+ z(e);
163
163
  return;
164
164
  }
165
- He(e);
166
- }, Ke = (n) => {
167
- if (k = [], W = 0, P && (clearTimeout(P), P = null), typeof document > "u")
165
+ ze(e);
166
+ }, qe = (n) => {
167
+ if (I = [], X = 0, A && (clearTimeout(A), A = null), typeof document > "u")
168
168
  return;
169
- T && document.removeEventListener("visibilitychange", T), L && window.removeEventListener("pagehide", L);
170
- const e = () => U(n, !0);
171
- T = () => {
169
+ B && document.removeEventListener("visibilitychange", B), U && window.removeEventListener("pagehide", U);
170
+ const e = () => z(n, !0);
171
+ B = () => {
172
172
  document.visibilityState === "hidden" && e();
173
- }, L = e, document.addEventListener("visibilitychange", T), window.addEventListener("pagehide", L);
174
- }, X = () => (/* @__PURE__ */ new Date()).toISOString();
175
- let Q = null, J = null;
176
- const qe = (n) => {
177
- typeof window > "u" || (Q = (e) => {
173
+ }, U = e, document.addEventListener("visibilitychange", B), window.addEventListener("pagehide", U);
174
+ }, ee = () => (/* @__PURE__ */ new Date()).toISOString();
175
+ let te = null, se = null;
176
+ const $e = (n) => {
177
+ typeof window > "u" || (te = (e) => {
178
178
  const t = e.error instanceof Error ? e.error : new Error(e.message);
179
- M({
179
+ P({
180
180
  type: "exception",
181
181
  payload: {
182
182
  type: t.name,
183
183
  value: t.message,
184
- timestamp: X(),
185
- stacktrace: t.stack ? { frames: q(t.stack) } : void 0
184
+ timestamp: ee(),
185
+ stacktrace: t.stack ? { frames: W(t.stack) } : void 0
186
186
  }
187
187
  }, n);
188
- }, J = (e) => {
188
+ }, se = (e) => {
189
189
  const t = e.reason, s = t instanceof Error ? t : new Error(String(t));
190
- M({
190
+ P({
191
191
  type: "exception",
192
192
  payload: {
193
193
  type: s.name,
194
194
  value: s.message,
195
- timestamp: X(),
196
- stacktrace: s.stack ? { frames: q(s.stack) } : void 0,
195
+ timestamp: ee(),
196
+ stacktrace: s.stack ? { frames: W(s.stack) } : void 0,
197
197
  context: { source: "unhandledrejection" }
198
198
  }
199
199
  }, n);
200
- }, window.addEventListener("error", Q), window.addEventListener("unhandledrejection", J));
201
- }, ee = "odus_telemetry_session_id", H = () => {
200
+ }, window.addEventListener("error", te), window.addEventListener("unhandledrejection", se));
201
+ }, ne = "odus_telemetry_session_id", K = () => {
202
202
  const n = new Uint8Array(16);
203
203
  return crypto.getRandomValues(n), Array.from(n, (e) => e.toString(16).padStart(2, "0")).join("");
204
- }, $e = (n) => {
204
+ }, Ye = (n) => {
205
205
  if (n)
206
206
  return n;
207
207
  if (typeof sessionStorage > "u")
208
- return H();
208
+ return K();
209
209
  try {
210
- const e = sessionStorage.getItem(ee);
210
+ const e = sessionStorage.getItem(ne);
211
211
  if (e)
212
212
  return e;
213
- const t = H();
214
- return sessionStorage.setItem(ee, t), t;
213
+ const t = K();
214
+ return sessionStorage.setItem(ne, t), t;
215
215
  } catch {
216
- return H();
216
+ return K();
217
217
  }
218
- }, Ye = (n) => {
218
+ }, We = (n) => {
219
219
  if (!n.sessionTracking?.enabled)
220
220
  return;
221
- const e = $e(n.sessionTracking.session?.id);
222
- _e({ id: e });
223
- }, z = () => (/* @__PURE__ */ new Date()).toISOString(), j = (n, e) => {
221
+ const e = Ye(n.sessionTracking.session?.id);
222
+ Be({ id: e });
223
+ }, q = () => (/* @__PURE__ */ new Date()).toISOString(), $ = (n, e) => {
224
224
  if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(n))
225
225
  return;
226
226
  new PerformanceObserver((s) => {
227
- for (const i of s.getEntries())
228
- e(i);
227
+ for (const a of s.getEntries())
228
+ e(a);
229
229
  }).observe({ type: n, buffered: !0 });
230
- }, We = (n) => {
230
+ }, Ze = (n) => {
231
231
  if (typeof window > "u")
232
232
  return;
233
- j("largest-contentful-paint", (t) => {
234
- M({
233
+ $("largest-contentful-paint", (t) => {
234
+ P({
235
235
  type: "measurement",
236
236
  payload: {
237
237
  type: "web-vitals",
238
238
  values: { lcp: t.startTime },
239
- timestamp: z()
239
+ timestamp: q()
240
240
  }
241
241
  }, n);
242
242
  });
243
243
  let e = 0;
244
- j("layout-shift", (t) => {
244
+ $("layout-shift", (t) => {
245
245
  const s = t;
246
- s.hadRecentInput || (e += s.value, M({
246
+ s.hadRecentInput || (e += s.value, P({
247
247
  type: "measurement",
248
248
  payload: {
249
249
  type: "web-vitals",
250
250
  values: { cls: e },
251
- timestamp: z()
251
+ timestamp: q()
252
252
  }
253
253
  }, n));
254
- }), j("event", (t) => {
254
+ }), $("event", (t) => {
255
255
  const s = t;
256
- s.duration > 0 && M({
256
+ s.duration > 0 && P({
257
257
  type: "measurement",
258
258
  payload: {
259
259
  type: "web-vitals",
260
260
  values: { inp: s.duration },
261
- timestamp: z()
261
+ timestamp: q()
262
262
  }
263
263
  }, n);
264
264
  });
265
- }, B = {
265
+ }, R = {
266
266
  INFO: "info",
267
267
  WARN: "warn",
268
268
  ERROR: "error"
269
- }, _ = () => (/* @__PURE__ */ new Date()).toISOString(), Ze = (n) => {
270
- De(n), Ke(n);
269
+ }, x = () => (/* @__PURE__ */ new Date()).toISOString(), Ge = (n) => {
270
+ Te(n), qe(n);
271
271
  const e = n.instrumentations ?? {
272
272
  errors: !0,
273
273
  webVitals: !0,
274
274
  session: !0
275
275
  };
276
- return e.session !== !1 && Ye(n), e.errors !== !1 && qe(n), e.webVitals !== !1 && We(n), {
276
+ return e.session !== !1 && We(n), e.errors !== !1 && $e(n), e.webVitals !== !1 && Ze(n), {
277
277
  pushError(t, s) {
278
- M({
278
+ P({
279
279
  type: "exception",
280
280
  payload: {
281
281
  type: t.name,
282
282
  value: t.message,
283
- timestamp: _(),
284
- stacktrace: t.stack ? { frames: q(t.stack) } : void 0,
283
+ timestamp: x(),
284
+ stacktrace: t.stack ? { frames: W(t.stack) } : void 0,
285
285
  context: s?.context
286
286
  }
287
287
  }, n);
288
288
  },
289
289
  pushEvent(t, s) {
290
- M({
290
+ P({
291
291
  type: "event",
292
292
  payload: {
293
293
  name: t,
294
- timestamp: _(),
294
+ timestamp: x(),
295
295
  attributes: s
296
296
  }
297
297
  }, n);
298
298
  },
299
299
  pushMeasurement(t) {
300
- M({
300
+ P({
301
301
  type: "measurement",
302
302
  payload: {
303
303
  type: t.type,
304
304
  values: t.values,
305
- timestamp: _(),
305
+ timestamp: x(),
306
306
  context: t.context
307
307
  }
308
308
  }, n);
309
309
  },
310
310
  pushLog(t, s) {
311
- M({
311
+ P({
312
312
  type: "log",
313
313
  payload: {
314
314
  message: t.join(" "),
315
- level: s?.level ?? B.INFO,
316
- timestamp: _(),
315
+ level: s?.level ?? R.INFO,
316
+ timestamp: x(),
317
317
  context: s?.context
318
318
  }
319
319
  }, n);
320
320
  },
321
321
  setUser(t) {
322
- Te(t);
322
+ Le(t);
323
323
  },
324
324
  resetUser() {
325
- Le();
325
+ _e();
326
326
  },
327
327
  setView(t) {
328
- Be(t);
328
+ Ue(t);
329
329
  },
330
330
  flush() {
331
- U(n);
331
+ z(n);
332
332
  }
333
333
  };
334
- }, Ge = (n) => n === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", Xe = () => {
334
+ }, Xe = (n) => n === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", Qe = () => {
335
335
  if (typeof window > "u")
336
336
  return !1;
337
337
  const n = window.location.hostname;
338
338
  return n === "localhost" || n === "127.0.0.1" || n === "0.0.0.0" || n === "::1" || n === "[::1]" || n.endsWith(".localhost");
339
339
  };
340
340
  let F = null;
341
- const Qe = (n) => {
341
+ const Je = (n) => {
342
342
  if (F)
343
343
  return F;
344
- if (Xe())
344
+ if (Qe())
345
345
  return null;
346
- const e = Ge(n.environment);
347
- return F = Ze({
346
+ const e = Xe(n.environment);
347
+ return F = Ge({
348
348
  url: e,
349
349
  app: {
350
350
  name: "odus-checkout",
@@ -368,19 +368,19 @@ const Qe = (n) => {
368
368
  "card",
369
369
  "cvv",
370
370
  "pan"
371
- ].forEach((a) => {
372
- s.searchParams.has(a) && s.searchParams.set(a, "[REDACTED]");
371
+ ].forEach((i) => {
372
+ s.searchParams.has(i) && s.searchParams.set(i, "[REDACTED]");
373
373
  }), t.meta.view.name = s.toString();
374
374
  } catch {
375
375
  }
376
376
  return t;
377
377
  }
378
378
  }), F;
379
- }, Je = (n, e) => {
379
+ }, et = (n, e) => {
380
380
  F && F.pushError(n, { context: e });
381
- }, C = (n, e) => {
381
+ }, M = (n, e) => {
382
382
  F && F.pushEvent(n, e);
383
- }, te = (n, e, t, s) => {
383
+ }, ae = (n, e, t, s) => {
384
384
  F && F.pushMeasurement({
385
385
  type: n,
386
386
  values: { [n]: e },
@@ -389,19 +389,19 @@ const Qe = (n) => {
389
389
  ...s
390
390
  }
391
391
  });
392
- }, Et = (n, e = "info", t) => {
392
+ }, St = (n, e = "info", t) => {
393
393
  if (!F) return;
394
394
  const s = {
395
- info: B.INFO,
396
- warn: B.WARN,
397
- error: B.ERROR
395
+ info: R.INFO,
396
+ warn: R.WARN,
397
+ error: R.ERROR
398
398
  };
399
399
  F.pushLog([n], {
400
400
  level: s[e],
401
401
  context: t
402
402
  });
403
403
  };
404
- function K(n) {
404
+ function Y(n) {
405
405
  return {
406
406
  name: "Custom Appearance",
407
407
  additionalPaymentMethods: n.additionalPaymentMethods || {},
@@ -437,7 +437,7 @@ function K(n) {
437
437
  state: {
438
438
  enabled: n.layout?.billingFields?.state?.enabled ?? !1,
439
439
  label: n.layout?.billingFields?.state?.label,
440
- options: n.layout?.billingFields?.state?.options
440
+ hiddenForCountries: n.layout?.billingFields?.state?.hiddenForCountries
441
441
  },
442
442
  zipCode: {
443
443
  enabled: n.layout?.billingFields?.zipCode?.enabled ?? !1,
@@ -477,7 +477,7 @@ function K(n) {
477
477
  state: {
478
478
  enabled: n.layout.shippingFields.state?.enabled ?? !1,
479
479
  label: n.layout.shippingFields.state?.label,
480
- options: n.layout.shippingFields.state?.options
480
+ hiddenForCountries: n.layout.shippingFields.state?.hiddenForCountries
481
481
  },
482
482
  zipCode: {
483
483
  enabled: n.layout.shippingFields.zipCode?.enabled ?? !1,
@@ -501,16 +501,16 @@ function K(n) {
501
501
  }
502
502
  };
503
503
  }
504
- function et({
504
+ function tt({
505
505
  appearance: n
506
506
  }) {
507
- const e = ie({
507
+ const e = le({
508
508
  checkoutProfile: void 0,
509
509
  isLoading: !0,
510
510
  error: null
511
511
  });
512
512
  if (n) {
513
- const s = K(n);
513
+ const s = Y(n);
514
514
  return Promise.resolve().then(() => {
515
515
  e.setState({
516
516
  checkoutProfile: s,
@@ -520,10 +520,10 @@ function et({
520
520
  }), {
521
521
  getState: e.getState.bind(e),
522
522
  subscribe: e.subscribe.bind(e),
523
- updateProfile: (i) => {
524
- const a = K(i);
523
+ updateProfile: (a) => {
524
+ const i = Y(a);
525
525
  e.setState({
526
- checkoutProfile: a,
526
+ checkoutProfile: i,
527
527
  isLoading: !1,
528
528
  error: null
529
529
  });
@@ -570,9 +570,9 @@ function et({
570
570
  getState: e.getState.bind(e),
571
571
  subscribe: e.subscribe.bind(e),
572
572
  updateProfile: (s) => {
573
- const i = K(s);
573
+ const a = Y(s);
574
574
  e.setState({
575
- checkoutProfile: i,
575
+ checkoutProfile: a,
576
576
  isLoading: !1,
577
577
  error: null
578
578
  });
@@ -581,8 +581,8 @@ function et({
581
581
  }
582
582
  };
583
583
  }
584
- const tt = () => {
585
- const n = ce(), e = ie({
584
+ const st = () => {
585
+ const n = he(), e = le({
586
586
  formData: {
587
587
  name: "",
588
588
  email: "",
@@ -599,185 +599,204 @@ const tt = () => {
599
599
  cardCvv: !1
600
600
  },
601
601
  isValid: !1
602
- }), t = (o, f, m, h) => {
602
+ }), t = (o, u, g, m) => {
603
603
  if (o === "cardCvv")
604
- return n.cardCvv(f, m);
605
- if (o === "phoneNumber" && h)
606
- return n.phoneNumber(f, h);
604
+ return n.cardCvv(u, g);
605
+ if (o === "phoneNumber" && m)
606
+ return n.phoneNumber(u, m);
607
607
  const p = n[o];
608
- return p?.(f);
608
+ return p?.(u);
609
609
  }, s = (o) => {
610
- const f = {};
611
- return Object.keys(o).forEach((h) => {
612
- const p = o[h];
610
+ const u = {};
611
+ return Object.keys(o).forEach((m) => {
612
+ const p = o[m];
613
613
  if (p === void 0) return;
614
614
  let c;
615
- h === "cardCvv" ? c = t(h, p, o.cardNumber) : h === "phoneNumber" ? c = t(
616
- h,
615
+ m === "cardCvv" ? c = t(m, p, o.cardNumber) : m === "phoneNumber" ? c = t(
616
+ m,
617
617
  p,
618
618
  void 0,
619
619
  o.phoneCountryCode
620
- ) : c = t(h, p), c && (f[h] = c);
620
+ ) : c = t(m, p), c && (u[m] = c);
621
621
  }), [
622
622
  "billingAddress",
623
623
  "shippingAddress"
624
- ].forEach((h) => {
625
- const p = o[h];
624
+ ].forEach((m) => {
625
+ const p = o[m];
626
626
  if (p && typeof p == "object") {
627
627
  const c = {};
628
628
  Object.keys(p).forEach(
629
- (b) => {
630
- const g = p[b];
631
- if (g === void 0) return;
632
- const S = n[b];
633
- if (S) {
634
- const N = S(g);
635
- N && (c[b] = N);
629
+ (f) => {
630
+ const y = p[f];
631
+ if (y === void 0) return;
632
+ const b = n[f];
633
+ if (b) {
634
+ const C = f === "state" ? n.state(y, p.country) : b(
635
+ y
636
+ );
637
+ C && (c[f] = C);
636
638
  }
637
639
  }
638
- ), Object.keys(c).length > 0 && (f[h] = c);
640
+ ), Object.keys(c).length > 0 && (u[m] = c);
639
641
  }
640
- }), f;
641
- }, i = (o) => {
642
- const f = s(o);
643
- return Object.keys(f).length === 0;
644
- }, a = "billingAddress.", r = "shippingAddress.", d = (o) => o.startsWith(a) ? {
642
+ }), u;
643
+ }, a = (o) => {
644
+ const u = s(o);
645
+ return Object.keys(u).length === 0;
646
+ }, i = "billingAddress.", r = "shippingAddress.", l = (o) => o.startsWith(i) ? {
645
647
  parent: "billingAddress",
646
- field: o.slice(a.length)
648
+ field: o.slice(i.length)
647
649
  } : o.startsWith(r) ? {
648
650
  parent: "shippingAddress",
649
651
  field: o.slice(r.length)
650
- } : null, l = (o, f, m, h) => {
652
+ } : null, d = (o, u, g, m) => {
651
653
  const p = { ...o };
652
- if (h)
653
- p[f] = {
654
- ...p[f],
655
- [m]: h
654
+ if (m)
655
+ p[u] = {
656
+ ...p[u],
657
+ [g]: m
656
658
  };
657
659
  else {
658
660
  const c = {
659
- ...p[f]
661
+ ...p[u]
660
662
  };
661
- delete c[m], Object.keys(c).length === 0 ? delete p[f] : p[f] = c;
663
+ delete c[g], Object.keys(c).length === 0 ? delete p[u] : p[u] = c;
662
664
  }
663
665
  return p;
664
- }, u = (o, f) => {
665
- const m = e.getState();
666
- let h = f;
667
- const p = d(o);
668
- if (!p && o in V)
666
+ }, h = (o, u) => {
667
+ const g = e.getState();
668
+ let m = u;
669
+ const p = l(o);
670
+ if (!p && o in j)
669
671
  if (o === "cardCvv") {
670
- const S = he(m.formData.cardNumber) === "amex" ? 4 : 3;
671
- h = V.cardCvv(f, S);
672
+ const b = ue(g.formData.cardNumber) === "amex" ? 4 : 3;
673
+ m = j.cardCvv(u, b);
672
674
  } else
673
- h = V[o](f);
675
+ m = j[o](u);
674
676
  let c;
675
677
  if (p) {
676
- const { parent: g, field: S } = p;
678
+ const { parent: y, field: b } = p;
677
679
  c = {
678
- ...m.formData,
679
- [g]: {
680
- ...m.formData[g] ?? {},
681
- [S]: h
680
+ ...g.formData,
681
+ [y]: {
682
+ ...g.formData[y] ?? {},
683
+ [b]: m
682
684
  }
683
685
  };
684
686
  } else
685
687
  c = {
686
- ...m.formData,
687
- [o]: h
688
+ ...g.formData,
689
+ [o]: m
688
690
  };
689
- let b = { ...m.errors };
691
+ let f = { ...g.errors };
690
692
  if (o === "phoneCountryCode" && c.phoneNumber) {
691
- const g = t(
693
+ const y = t(
692
694
  "phoneNumber",
693
695
  c.phoneNumber,
694
696
  void 0,
695
- h
697
+ m
696
698
  );
697
- g ? b.phoneNumber = g : delete b.phoneNumber;
699
+ y ? f.phoneNumber = y : delete f.phoneNumber;
698
700
  }
699
- if (m.touched[o])
701
+ if (g.touched[o])
700
702
  if (p) {
701
- const { parent: g, field: S } = p, N = n[S], D = N ? N(
702
- h
703
- ) : void 0;
704
- b = l(b, g, S, D);
703
+ const { parent: y, field: b } = p, C = c[y];
704
+ let N;
705
+ if (b === "state")
706
+ N = n.state(m, C?.country);
707
+ else {
708
+ const T = n[b];
709
+ N = T ? T(
710
+ m
711
+ ) : void 0;
712
+ }
713
+ f = d(f, y, b, N);
705
714
  } else {
706
- let g;
707
- o === "cardCvv" ? g = t(o, h, c.cardNumber) : o === "phoneNumber" ? g = t(
715
+ let y;
716
+ o === "cardCvv" ? y = t(o, m, c.cardNumber) : o === "phoneNumber" ? y = t(
708
717
  o,
709
- h,
718
+ m,
710
719
  void 0,
711
720
  c.phoneCountryCode
712
- ) : g = t(o, h), g ? b[o] = g : delete b[o];
721
+ ) : y = t(o, m), y ? f[o] = y : delete f[o];
713
722
  }
714
723
  e.setState({
715
724
  formData: c,
716
- errors: b,
717
- isValid: i(c)
725
+ errors: f,
726
+ isValid: a(c)
718
727
  });
719
- }, E = (o, f) => {
720
- const m = e.getState(), h = d(o);
721
- if (h) {
722
- const { parent: g, field: S } = h, N = {
723
- ...m.formData,
724
- [g]: {
725
- ...m.formData[g] ?? {},
726
- [S]: f
728
+ }, E = (o, u) => {
729
+ const g = e.getState(), m = l(o);
730
+ if (m) {
731
+ const { parent: y, field: b } = m, C = {
732
+ ...g.formData,
733
+ [y]: {
734
+ ...g.formData[y] ?? {},
735
+ [b]: u
727
736
  }
728
- }, D = n[S], le = D ? D(f) : void 0, de = l(m.errors, g, S, le);
737
+ };
738
+ let N;
739
+ if (b === "state") {
740
+ const L = C[y];
741
+ N = n.state(u, L?.country);
742
+ } else {
743
+ const L = n[b];
744
+ N = L ? L(u) : void 0;
745
+ }
746
+ const T = d(g.errors, y, b, N);
729
747
  e.setState({
730
- formData: N,
748
+ formData: C,
731
749
  touched: {
732
- ...m.touched,
750
+ ...g.touched,
733
751
  [o]: !0
734
752
  },
735
- errors: de,
736
- isValid: i(N)
753
+ errors: T,
754
+ isValid: a(C)
737
755
  });
738
756
  return;
739
757
  }
740
758
  const p = {
741
- ...m.touched,
759
+ ...g.touched,
742
760
  [o]: !0
743
761
  };
744
762
  let c;
745
- o === "cardCvv" ? c = t(o, f, m.formData.cardNumber) : o === "phoneNumber" ? c = t(
763
+ o === "cardCvv" ? c = t(o, u, g.formData.cardNumber) : o === "phoneNumber" ? c = t(
746
764
  o,
747
- f,
765
+ u,
748
766
  void 0,
749
- m.formData.phoneCountryCode
750
- ) : c = t(o, f);
751
- const b = { ...m.errors };
752
- c ? b[o] = c : delete b[o], e.setState({
767
+ g.formData.phoneCountryCode
768
+ ) : c = t(o, u);
769
+ const f = { ...g.errors };
770
+ c ? f[o] = c : delete f[o], e.setState({
753
771
  touched: p,
754
- errors: b
772
+ errors: f
755
773
  });
756
- }, y = (o) => {
757
- const m = {
774
+ }, S = (o) => {
775
+ const g = {
758
776
  ...e.getState().formData,
759
777
  ...o
760
778
  };
761
779
  e.setState({
762
- formData: m,
763
- isValid: i(m)
780
+ formData: g,
781
+ isValid: a(g)
764
782
  });
765
783
  };
766
784
  return {
767
785
  getFormState: e.getState.bind(e),
768
786
  subscribe: e.subscribe.bind(e),
769
- handleChange: u,
787
+ handleChange: h,
770
788
  handleBlur: E,
771
- setFormData: y,
789
+ setFormData: S,
772
790
  reset: e.resetState.bind(e)
773
791
  };
774
792
  };
775
- function $(n) {
793
+ function Z(n) {
776
794
  if (!n) return !1;
777
- const { billingFields: e, shippingFields: t } = n, s = e && Object.values(e).some((a) => a?.enabled), i = t && Object.values(t).some((a) => a?.enabled);
778
- return !!(s || i);
795
+ const { billingFields: e, shippingFields: t } = n, s = e && Object.values(e).some((i) => i?.enabled), a = t && Object.values(t).some((i) => i?.enabled);
796
+ return !!(s || a);
779
797
  }
780
- class se extends A {
798
+ const O = /* @__PURE__ */ new Set(["US", "CA"]);
799
+ class ie extends w {
781
800
  inputs = /* @__PURE__ */ new Map();
782
801
  type;
783
802
  onChange;
@@ -785,161 +804,165 @@ class se extends A {
785
804
  fieldsContainer;
786
805
  translationFunc;
787
806
  locale;
788
- stateOptions;
789
807
  grouped;
808
+ currentCountry = "";
809
+ stateRow = null;
810
+ stateFieldConfig;
811
+ stateStyles;
790
812
  constructor(e) {
791
813
  super("div", ["address-section"]), this.type = e.type, this.onChange = e.onChange, this.onBlur = e.onBlur, this.translationFunc = e.translationFunc, this.locale = e.locale, this.grouped = e.grouped ?? !0;
792
- const { title: t, checkoutProfile: s, fieldsConfig: i, values: a, errors: r, touched: d } = e;
814
+ const { title: t, checkoutProfile: s, fieldsConfig: a, values: i, errors: r, touched: l } = e;
793
815
  if (this.grouped) {
794
- const l = document.createElement("h3");
795
- l.className = "address-section-title", l.textContent = t, l.style.color = s.styles.textColor, l.style.fontFamily = `"${s.styles.fontFamily}", sans-serif`, l.style.fontSize = `${s.styles.fontSize}px`, l.style.fontWeight = "normal", this.getElement().appendChild(l);
816
+ const d = document.createElement("h3");
817
+ d.className = "address-section-title", d.textContent = t, d.style.color = s.styles.textColor, d.style.fontFamily = `"${s.styles.fontFamily}", sans-serif`, d.style.fontSize = `${s.styles.fontSize}px`, d.style.fontWeight = "normal", this.getElement().appendChild(d);
796
818
  }
797
- this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(s, i, a, r, d);
819
+ this.fieldsContainer = document.createElement("div"), this.fieldsContainer.className = "address-fields", this.grouped || this.fieldsContainer.classList.add("address-fields--ungrouped"), this.getElement().appendChild(this.fieldsContainer), this.createFields(s, a, i, r, l);
798
820
  }
799
- borderRadius(e, t, s, i, a) {
800
- const r = (d) => d ? `${e}px` : "0px";
801
- return `${r(t)} ${r(s)} ${r(i)} ${r(a)}`;
821
+ borderRadius(e, t, s, a, i) {
822
+ const r = (l) => l ? `${e}px` : "0px";
823
+ return `${r(t)} ${r(s)} ${r(a)} ${r(i)}`;
802
824
  }
803
- createFields(e, t, s, i, a) {
825
+ createFields(e, t, s, a, i) {
804
826
  if (!this.grouped) {
805
827
  this.createUngroupedFields(
806
828
  e,
807
829
  t,
808
830
  s,
809
- i,
810
- a
831
+ a,
832
+ i
811
833
  );
812
834
  return;
813
835
  }
814
- const r = e.styles.borderRadius, d = {
836
+ const r = e.styles.borderRadius, l = {
815
837
  color: e.styles.textColor,
816
838
  fontSize: e.styles.fontSize,
817
839
  fontFamily: e.styles.fontFamily
818
- }, l = [];
819
- t.street?.enabled && l.push({ kind: "street" });
820
- const u = [];
821
- t.firstName?.enabled && u.push("firstName"), t.lastName?.enabled && u.push("lastName"), u.length > 0 && l.push({ kind: "name", fields: u }), t.country?.enabled && l.push({ kind: "country" });
840
+ }, d = [];
841
+ t.street?.enabled && d.push({ kind: "street" });
842
+ const h = [];
843
+ t.firstName?.enabled && h.push("firstName"), t.lastName?.enabled && h.push("lastName"), h.length > 0 && d.push({ kind: "name", fields: h }), t.country?.enabled && d.push({ kind: "country" });
822
844
  const E = [];
823
- t.city?.enabled && E.push("city"), t.zipCode?.enabled && E.push("zipCode"), E.length > 0 && l.push({ kind: "cityZip", fields: E }), t.state?.enabled && l.push({ kind: "state" });
824
- const y = l.length;
825
- l.forEach((o, f) => {
826
- const m = f === 0, h = f === y - 1, p = (c, b) => ({
827
- ...d,
845
+ t.city?.enabled && E.push("city"), t.zipCode?.enabled && E.push("zipCode"), E.length > 0 && d.push({ kind: "cityZip", fields: E }), t.state?.enabled && d.push({ kind: "state" });
846
+ const S = d.length;
847
+ d.forEach((o, u) => {
848
+ const g = u === 0, m = u === S - 1, p = (c, f) => ({
849
+ ...l,
828
850
  borderRadius: this.borderRadius(
829
851
  r,
830
- m && c,
831
- m && b,
832
- h && b,
833
- h && c
852
+ g && c,
853
+ g && f,
854
+ m && f,
855
+ m && c
834
856
  )
835
857
  });
836
858
  if (o.kind === "street") {
837
- const c = this.createRow(["full"]), b = this.createInput(
859
+ const c = this.createRow(["full"]), f = this.createInput(
838
860
  "street",
839
861
  t.street?.label ?? this.translationFunc("address.addressLine1"),
840
862
  s.street,
841
- i.street,
842
863
  a.street,
864
+ i.street,
843
865
  p(!0, !0),
844
866
  "street-address"
845
867
  );
846
- this.inputs.set("street", b), c.appendChild(b.getElement()), this.fieldsContainer.appendChild(c);
868
+ this.inputs.set("street", f), c.appendChild(f.getElement()), this.fieldsContainer.appendChild(c);
847
869
  return;
848
870
  }
849
871
  if (o.kind === "name") {
850
- const c = this.createRow(o.fields.map(() => "half")), b = o.fields.length === 1;
872
+ const c = this.createRow(o.fields.map(() => "half")), f = o.fields.length === 1;
851
873
  if (o.fields.includes("firstName")) {
852
- const g = b || o.fields[o.fields.length - 1] === "firstName", S = this.createInput(
874
+ const y = f || o.fields[o.fields.length - 1] === "firstName", b = this.createInput(
853
875
  "firstName",
854
876
  t.firstName?.label ?? this.translationFunc("address.firstName"),
855
877
  s.firstName,
856
- i.firstName,
857
878
  a.firstName,
858
- p(!0, g),
879
+ i.firstName,
880
+ p(!0, y),
859
881
  "given-name"
860
882
  );
861
- this.inputs.set("firstName", S), c.appendChild(S.getElement());
883
+ this.inputs.set("firstName", b), c.appendChild(b.getElement());
862
884
  }
863
885
  if (o.fields.includes("lastName")) {
864
- const g = b || o.fields[0] === "lastName", S = this.createInput(
886
+ const y = f || o.fields[0] === "lastName", b = this.createInput(
865
887
  "lastName",
866
888
  t.lastName?.label ?? this.translationFunc("address.lastName"),
867
889
  s.lastName,
868
- i.lastName,
869
890
  a.lastName,
870
- p(g, !0),
891
+ i.lastName,
892
+ p(y, !0),
871
893
  "family-name"
872
894
  );
873
- this.inputs.set("lastName", S), c.appendChild(S.getElement());
895
+ this.inputs.set("lastName", b), c.appendChild(b.getElement());
874
896
  }
875
897
  this.fieldsContainer.appendChild(c);
876
898
  return;
877
899
  }
878
900
  if (o.kind === "country") {
879
- const c = this.createRow(["full"]), b = this.createCountrySelect(
901
+ const c = this.createRow(["full"]), f = this.createCountrySelect(
880
902
  s.country,
881
- i.country,
882
903
  a.country,
904
+ i.country,
883
905
  p(!0, !0),
884
906
  t.country?.options,
885
907
  t.country?.label
886
908
  );
887
- this.inputs.set("country", b), c.appendChild(b.getElement()), this.fieldsContainer.appendChild(c);
909
+ this.inputs.set("country", f), c.appendChild(f.getElement()), this.fieldsContainer.appendChild(c);
888
910
  return;
889
911
  }
890
912
  if (o.kind === "cityZip") {
891
- const c = this.createRow(o.fields.map(() => "half")), b = o.fields.length === 1;
913
+ const c = this.createRow(o.fields.map(() => "half")), f = o.fields.length === 1;
892
914
  if (o.fields.includes("city")) {
893
- const g = b || o.fields[o.fields.length - 1] === "city", S = this.createInput(
915
+ const y = f || o.fields[o.fields.length - 1] === "city", b = this.createInput(
894
916
  "city",
895
917
  t.city?.label ?? this.translationFunc("address.townCity"),
896
918
  s.city,
897
- i.city,
898
919
  a.city,
899
- p(!0, g),
920
+ i.city,
921
+ p(!0, y),
900
922
  "address-level2"
901
923
  );
902
- this.inputs.set("city", S), c.appendChild(S.getElement());
924
+ this.inputs.set("city", b), c.appendChild(b.getElement());
903
925
  }
904
926
  if (o.fields.includes("zipCode")) {
905
- const g = b || o.fields[0] === "zipCode", S = this.createInput(
927
+ const y = f || o.fields[0] === "zipCode", b = this.createInput(
906
928
  "zipCode",
907
929
  t.zipCode?.label ?? this.translationFunc("address.postalCode"),
908
930
  s.zipCode,
909
- i.zipCode,
910
931
  a.zipCode,
911
- p(g, !0),
932
+ i.zipCode,
933
+ p(y, !0),
912
934
  "postal-code"
913
935
  );
914
- this.inputs.set("zipCode", S), c.appendChild(S.getElement());
936
+ this.inputs.set("zipCode", b), c.appendChild(b.getElement());
915
937
  }
916
938
  this.fieldsContainer.appendChild(c);
917
939
  return;
918
940
  }
919
941
  if (o.kind === "state") {
920
942
  const c = this.createRow(["full"]);
921
- if (this.stateOptions = t.state?.options, t.state?.options && t.state.options.length > 0) {
922
- const g = this.createStateSelect(
943
+ if (this.stateFieldConfig = t.state, this.stateRow = c, this.stateStyles = p(!0, !0), this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
944
+ s.country
945
+ ) && (c.style.display = "none"), O.has(s.country)) {
946
+ const b = this.createStateSelect(
923
947
  s.state,
924
- i.state,
925
948
  a.state,
926
- p(!0, !0),
927
- t.state?.options,
949
+ i.state,
950
+ this.stateStyles,
928
951
  s.country,
929
952
  t.state?.label
930
953
  );
931
- this.inputs.set("state", g), c.appendChild(g.getElement());
954
+ this.inputs.set("state", b), c.appendChild(b.getElement());
932
955
  } else {
933
- const g = this.createInput(
956
+ const b = this.createInput(
934
957
  "state",
935
- t.state?.label ?? this.translationFunc("address.chooseState"),
958
+ t.state?.label ?? this.translationFunc("address.state"),
936
959
  s.state,
937
- i.state,
938
960
  a.state,
939
- p(!0, !0),
961
+ i.state,
962
+ this.stateStyles,
940
963
  "address-level1"
941
964
  );
942
- this.inputs.set("state", g), c.appendChild(g.getElement());
965
+ this.inputs.set("state", b), c.appendChild(b.getElement());
943
966
  }
944
967
  this.fieldsContainer.appendChild(c);
945
968
  }
@@ -949,181 +972,239 @@ class se extends A {
949
972
  const t = document.createElement("div");
950
973
  return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
951
974
  }
952
- createInput(e, t, s, i, a, r, d) {
953
- const l = `${this.type}Address.${e}`, u = new re({
954
- name: l,
975
+ createInput(e, t, s, a, i, r, l) {
976
+ const d = `${this.type}Address.${e}`, h = new de({
977
+ name: d,
955
978
  error: !1,
956
979
  errorMsg: void 0,
957
980
  styles: r,
958
981
  ...this.grouped ? { placeholder: t } : {
959
982
  label: t,
960
983
  placeholder: (() => {
961
- const E = `address.placeholder.${e}`, y = this.translationFunc(E);
962
- return y !== E ? y : t;
984
+ const E = `address.placeholder.${e}`, S = this.translationFunc(E);
985
+ return S !== E ? S : t;
963
986
  })()
964
987
  },
965
988
  value: s,
966
- autocomplete: d,
989
+ autocomplete: l,
967
990
  onChange: (E) => {
968
- u.setError(!1);
969
- const y = new Event("input", { bubbles: !0 });
970
- Object.defineProperty(y, "target", {
991
+ h.setError(!1);
992
+ const S = new Event("input", { bubbles: !0 });
993
+ Object.defineProperty(S, "target", {
971
994
  writable: !1,
972
995
  value: {
973
- name: l,
996
+ name: d,
974
997
  value: E.target.value
975
998
  }
976
- }), this.onChange(y);
999
+ }), this.onChange(S);
977
1000
  }
978
1001
  });
979
- return u.addEventListener("blur", (E) => {
980
- const y = new Event("blur", { bubbles: !0 });
981
- Object.defineProperty(y, "target", {
1002
+ return h.addEventListener("blur", (E) => {
1003
+ const S = new Event("blur", { bubbles: !0 });
1004
+ Object.defineProperty(S, "target", {
982
1005
  writable: !1,
983
1006
  value: {
984
- name: l,
1007
+ name: d,
985
1008
  value: E.target.value
986
1009
  }
987
- }), this.onBlur(y);
988
- }), u;
1010
+ }), this.onBlur(S);
1011
+ }), h;
989
1012
  }
990
- createCountrySelect(e, t, s, i, a, r) {
991
- const d = `${this.type}Address.country`, l = ue(a, this.locale), u = new R({
992
- name: d,
1013
+ createCountrySelect(e, t, s, a, i, r) {
1014
+ const l = `${this.type}Address.country`, d = me(i, this.locale), h = new _({
1015
+ name: l,
993
1016
  error: !1,
994
1017
  errorMsg: void 0,
995
- styles: i,
1018
+ styles: a,
996
1019
  placeholder: this.translationFunc("address.chooseCountry"),
997
1020
  ...!this.grouped && {
998
1021
  label: r ?? this.translationFunc("address.chooseCountry")
999
1022
  },
1000
1023
  value: e,
1001
- options: l,
1024
+ options: d,
1002
1025
  autocomplete: "country",
1003
1026
  onChange: (E) => {
1004
- u.setError(!1);
1005
- const y = E.target.value;
1006
- this.updateStateOptionsForCountry(y);
1007
- const o = new Event("change", { bubbles: !0 });
1027
+ h.setError(!1);
1028
+ const S = E.target.value, o = new Event("change", { bubbles: !0 });
1008
1029
  Object.defineProperty(o, "target", {
1009
1030
  writable: !1,
1010
1031
  value: {
1011
- name: d,
1012
- value: y
1032
+ name: l,
1033
+ value: S
1013
1034
  }
1014
- }), this.onChange(o);
1035
+ }), this.onChange(o), this.handleCountryChange(S);
1015
1036
  }
1016
1037
  });
1017
- return u.addEventListener("blur", (E) => {
1018
- const y = new Event("blur", { bubbles: !0 });
1019
- Object.defineProperty(y, "target", {
1038
+ return h.addEventListener("blur", (E) => {
1039
+ const S = new Event("blur", { bubbles: !0 });
1040
+ Object.defineProperty(S, "target", {
1020
1041
  writable: !1,
1021
1042
  value: {
1022
- name: d,
1043
+ name: l,
1023
1044
  value: E.target.value
1024
1045
  }
1025
- }), this.onBlur(y);
1026
- }), u;
1046
+ }), this.onBlur(S);
1047
+ }), h;
1048
+ }
1049
+ handleCountryChange(e) {
1050
+ const t = this.currentCountry;
1051
+ if (this.currentCountry = e, !this.stateRow || !this.stateFieldConfig?.enabled) return;
1052
+ const s = this.stateFieldConfig.hiddenForCountries?.includes(t), a = this.stateFieldConfig.hiddenForCountries?.includes(e);
1053
+ if (a && !s) {
1054
+ this.stateRow.style.display = "none", this.clearStateValue();
1055
+ return;
1056
+ }
1057
+ if (!a && s && (this.stateRow.style.display = ""), a) return;
1058
+ const i = this.inputs.get("state") instanceof _, r = O.has(e);
1059
+ if (i && r) {
1060
+ const l = this.inputs.get("state");
1061
+ if (l instanceof _) {
1062
+ const d = e === "CA" ? "CA" : "US", h = Q(d), E = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1063
+ l.setOptions(h, E);
1064
+ }
1065
+ this.clearStateValue();
1066
+ return;
1067
+ }
1068
+ if (i !== r) {
1069
+ this.rebuildStateField(e), this.clearStateValue();
1070
+ return;
1071
+ }
1072
+ !i && !r && t !== e && this.clearStateValue();
1027
1073
  }
1028
- updateStateOptionsForCountry(e) {
1074
+ rebuildStateField(e) {
1075
+ if (!this.stateRow || !this.stateStyles) return;
1029
1076
  const t = this.inputs.get("state");
1030
- if (!(t instanceof R)) return;
1031
- const s = e === "CA" ? "CA" : "US", i = Z(this.stateOptions, s), a = s === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1032
- t.setOptions(i, a);
1077
+ if (t && (t.getElement().remove(), this.inputs.delete("state")), O.has(e)) {
1078
+ const a = this.createStateSelect(
1079
+ "",
1080
+ void 0,
1081
+ void 0,
1082
+ this.stateStyles,
1083
+ e,
1084
+ this.stateFieldConfig?.label
1085
+ );
1086
+ this.inputs.set("state", a), this.stateRow.appendChild(a.getElement());
1087
+ } else {
1088
+ const a = this.createInput(
1089
+ "state",
1090
+ this.stateFieldConfig?.label ?? this.translationFunc("address.state"),
1091
+ "",
1092
+ void 0,
1093
+ void 0,
1094
+ this.stateStyles,
1095
+ "address-level1"
1096
+ );
1097
+ this.inputs.set("state", a), this.stateRow.appendChild(a.getElement());
1098
+ }
1099
+ }
1100
+ clearStateValue() {
1101
+ const e = this.inputs.get("state");
1102
+ e && e.setValue("");
1103
+ const t = `${this.type}Address.state`, s = new CustomEvent("input", {
1104
+ bubbles: !0,
1105
+ detail: { programmatic: !0 }
1106
+ });
1107
+ Object.defineProperty(s, "target", {
1108
+ writable: !1,
1109
+ value: { name: t, value: "" }
1110
+ }), this.onChange(s);
1033
1111
  }
1034
- createStateSelect(e, t, s, i, a, r, d) {
1035
- const l = `${this.type}Address.state`, u = r === "CA" ? "CA" : "US", E = Z(a, u), y = u === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), o = new R({
1112
+ createStateSelect(e, t, s, a, i, r) {
1113
+ const l = `${this.type}Address.state`, d = i === "CA" ? "CA" : "US", h = Q(d), E = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), S = new _({
1036
1114
  name: l,
1037
1115
  error: !1,
1038
1116
  errorMsg: void 0,
1039
- styles: i,
1040
- placeholder: y,
1041
- ...!this.grouped && { label: d ?? y },
1117
+ styles: a,
1118
+ placeholder: E,
1119
+ ...!this.grouped && { label: r ?? E },
1042
1120
  value: e,
1043
- options: E,
1121
+ options: h,
1044
1122
  autocomplete: "address-level1",
1045
- onChange: (f) => {
1046
- o.setError(!1);
1047
- const m = new Event("change", { bubbles: !0 });
1048
- Object.defineProperty(m, "target", {
1123
+ onChange: (o) => {
1124
+ S.setError(!1);
1125
+ const u = new Event("change", { bubbles: !0 });
1126
+ Object.defineProperty(u, "target", {
1049
1127
  writable: !1,
1050
1128
  value: {
1051
1129
  name: l,
1052
- value: f.target.value
1130
+ value: o.target.value
1053
1131
  }
1054
- }), this.onChange(m);
1132
+ }), this.onChange(u);
1055
1133
  }
1056
1134
  });
1057
- return o.addEventListener("blur", (f) => {
1058
- const m = new Event("blur", { bubbles: !0 });
1059
- Object.defineProperty(m, "target", {
1135
+ return S.addEventListener("blur", (o) => {
1136
+ const u = new Event("blur", { bubbles: !0 });
1137
+ Object.defineProperty(u, "target", {
1060
1138
  writable: !1,
1061
1139
  value: {
1062
1140
  name: l,
1063
- value: f.target.value
1141
+ value: o.target.value
1064
1142
  }
1065
- }), this.onBlur(m);
1066
- }), o;
1143
+ }), this.onBlur(u);
1144
+ }), S;
1067
1145
  }
1068
- createUngroupedFields(e, t, s, i, a) {
1069
- const r = e.styles.borderRadius, d = {
1146
+ createUngroupedFields(e, t, s, a, i) {
1147
+ const r = e.styles.borderRadius, l = {
1070
1148
  color: e.styles.textColor,
1071
1149
  fontSize: e.styles.fontSize,
1072
1150
  fontFamily: e.styles.fontFamily,
1073
1151
  borderRadius: `${r}px`
1074
- }, l = (u, E, y) => {
1075
- if (!t[u]?.enabled) return;
1076
- const o = t[u]?.label ?? this.translationFunc(E), f = this.createRow(["full"]), m = this.createInput(
1077
- u,
1152
+ }, d = (h, E, S) => {
1153
+ if (!t[h]?.enabled) return;
1154
+ const o = t[h]?.label ?? this.translationFunc(E), u = this.createRow(["full"]), g = this.createInput(
1155
+ h,
1078
1156
  o,
1079
- s[u],
1080
- i[u],
1081
- a[u],
1082
- d,
1083
- y
1157
+ s[h],
1158
+ a[h],
1159
+ i[h],
1160
+ l,
1161
+ S
1084
1162
  );
1085
- this.inputs.set(u, m), f.appendChild(m.getElement()), this.fieldsContainer.appendChild(f);
1163
+ this.inputs.set(h, g), u.appendChild(g.getElement()), this.fieldsContainer.appendChild(u);
1086
1164
  };
1087
- if (l("firstName", "address.firstName", "given-name"), l("lastName", "address.lastName", "family-name"), l("street", "address.addressLine1", "street-address"), l("city", "address.townCity", "address-level2"), t.country?.enabled) {
1088
- const u = t.country?.label ?? this.translationFunc("address.chooseCountry"), E = this.createRow(["full"]), y = this.createCountrySelect(
1165
+ if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d("street", "address.addressLine1", "street-address"), d("city", "address.townCity", "address-level2"), t.country?.enabled) {
1166
+ const h = t.country?.label ?? this.translationFunc("address.chooseCountry"), E = this.createRow(["full"]), S = this.createCountrySelect(
1089
1167
  s.country,
1090
- i.country,
1091
1168
  a.country,
1092
- d,
1169
+ i.country,
1170
+ l,
1093
1171
  t.country?.options,
1094
- u
1172
+ h
1095
1173
  );
1096
- this.inputs.set("country", y), E.appendChild(y.getElement()), this.fieldsContainer.appendChild(E);
1174
+ this.inputs.set("country", S), E.appendChild(S.getElement()), this.fieldsContainer.appendChild(E);
1097
1175
  }
1098
1176
  if (t.state?.enabled) {
1099
- this.stateOptions = t.state?.options;
1100
- const u = this.createRow(["full"]), E = t.state?.options && t.state.options.length > 0, y = t.state?.label ?? this.translationFunc("address.chooseState");
1101
- if (E) {
1102
- const o = this.createStateSelect(
1177
+ this.stateFieldConfig = t.state;
1178
+ const h = this.createRow(["full"]);
1179
+ this.stateRow = h, this.stateStyles = l, this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
1180
+ s.country
1181
+ ) && (h.style.display = "none");
1182
+ const S = O.has(s.country), o = t.state?.label ?? this.translationFunc("address.state");
1183
+ if (S) {
1184
+ const u = this.createStateSelect(
1103
1185
  s.state,
1104
- i.state,
1105
1186
  a.state,
1106
- d,
1107
- t.state?.options,
1187
+ i.state,
1188
+ l,
1108
1189
  s.country,
1109
- y
1190
+ o
1110
1191
  );
1111
- this.inputs.set("state", o), u.appendChild(o.getElement());
1192
+ this.inputs.set("state", u), h.appendChild(u.getElement());
1112
1193
  } else {
1113
- const o = this.createInput(
1194
+ const u = this.createInput(
1114
1195
  "state",
1115
- y,
1196
+ o,
1116
1197
  s.state,
1117
- i.state,
1118
1198
  a.state,
1119
- d,
1199
+ i.state,
1200
+ l,
1120
1201
  "address-level1"
1121
1202
  );
1122
- this.inputs.set("state", o), u.appendChild(o.getElement());
1203
+ this.inputs.set("state", u), h.appendChild(u.getElement());
1123
1204
  }
1124
- this.fieldsContainer.appendChild(u);
1205
+ this.fieldsContainer.appendChild(h);
1125
1206
  }
1126
- l("zipCode", "address.postalCode", "postal-code");
1207
+ d("zipCode", "address.postalCode", "postal-code");
1127
1208
  }
1128
1209
  getValue(e) {
1129
1210
  return this.inputs.get(e)?.getValue() ?? "";
@@ -1148,28 +1229,27 @@ class se extends A {
1148
1229
  });
1149
1230
  }
1150
1231
  setError(e, t, s) {
1151
- const i = this.inputs.get(e);
1152
- if (i) {
1153
- const a = i.getElement().querySelector("input") || i.getElement().querySelector("select");
1154
- document.activeElement !== a && i.setError(t, s);
1155
- }
1156
- }
1157
- updateField(e, t, s, i) {
1158
1232
  const a = this.inputs.get(e);
1159
1233
  if (a) {
1160
- const d = a.getElement().querySelector("input") || a.getElement().querySelector("select"), l = a.getValue();
1161
- !(document.activeElement === d) && !(t === "" && l !== "") && this.setValue(e, t);
1234
+ const i = a.getElement().querySelector("input") || a.getElement().querySelector("select");
1235
+ document.activeElement !== i && a.setError(t, s);
1162
1236
  }
1163
- const r = !!(i && s);
1164
- this.setError(e, r, s);
1237
+ }
1238
+ updateField(e, t, s, a) {
1239
+ const i = this.inputs.get(e);
1240
+ if (!i) return;
1241
+ const r = i.getElement().querySelector("input") || i.getElement().querySelector("select"), l = i.getValue();
1242
+ !(document.activeElement === r) && !(t === "" && l !== "") && this.setValue(e, t);
1243
+ const E = !!(a && s);
1244
+ this.setError(e, E, s);
1165
1245
  }
1166
1246
  updateAllFields(e, t, s) {
1167
- Object.keys(e).forEach((i) => {
1247
+ Object.keys(e).forEach((a) => {
1168
1248
  this.updateField(
1169
- i,
1170
- e[i],
1171
- t[i],
1172
- !!s[i]
1249
+ a,
1250
+ e[a],
1251
+ t[a],
1252
+ !!s[a]
1173
1253
  );
1174
1254
  });
1175
1255
  }
@@ -1178,39 +1258,39 @@ class se extends A {
1178
1258
  e && e.focus();
1179
1259
  }
1180
1260
  }
1181
- class st {
1261
+ class nt {
1182
1262
  input;
1183
1263
  constructor(e) {
1184
1264
  const {
1185
1265
  value: t,
1186
1266
  onChange: s,
1187
- onBlur: i,
1188
- errorMsg: a,
1267
+ onBlur: a,
1268
+ errorMsg: i,
1189
1269
  checkoutProfile: r,
1190
- translationFunc: d,
1191
- autocomplete: l = "cc-name"
1270
+ translationFunc: l,
1271
+ autocomplete: d = "cc-name"
1192
1272
  } = e;
1193
- this.input = new re({
1273
+ this.input = new de({
1194
1274
  name: "name",
1195
- label: d("cardholderNameLabel"),
1275
+ label: l("cardholderNameLabel"),
1196
1276
  // Always hide error initially - we'll show it only on blur if needed
1197
1277
  error: !1,
1198
- errorMsg: a,
1278
+ errorMsg: i,
1199
1279
  styles: {
1200
1280
  color: r.styles.textColor,
1201
1281
  borderRadius: `${r.styles.borderRadius}px`,
1202
1282
  fontSize: r.styles.fontSize,
1203
1283
  fontFamily: r.styles.fontFamily
1204
1284
  },
1205
- placeholder: d("cardholderNamePlaceholder"),
1285
+ placeholder: l("cardholderNamePlaceholder"),
1206
1286
  value: t,
1207
- autocomplete: l,
1208
- onChange: (u) => {
1209
- const y = u.target.value, o = y.replace(/[^a-zA-Z\s\-'.]/g, "");
1210
- y !== o && this.input.setValue(o), this.input.setError(!1), this.trim(), s(u);
1287
+ autocomplete: d,
1288
+ onChange: (h) => {
1289
+ const S = h.target.value, o = S.replace(/[^a-zA-Z\s\-'.]/g, "");
1290
+ S !== o && this.input.setValue(o), this.input.setError(!1), this.trim(), s(h);
1211
1291
  }
1212
- }), this.input.addEventListener("blur", (u) => {
1213
- i(u);
1292
+ }), this.input.addEventListener("blur", (h) => {
1293
+ a(h);
1214
1294
  });
1215
1295
  }
1216
1296
  getValue() {
@@ -1237,7 +1317,7 @@ class st {
1237
1317
  this.input.focus();
1238
1318
  }
1239
1319
  }
1240
- class oe extends A {
1320
+ class ce extends w {
1241
1321
  constructor() {
1242
1322
  super("div", ["skeleton-container"]), this.createSkeletonElements();
1243
1323
  }
@@ -1245,35 +1325,35 @@ class oe extends A {
1245
1325
  this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
1246
1326
  }
1247
1327
  createPaymentMethodSkeleton() {
1248
- const e = w.createDiv(["skeleton-field"]), t = w.createDiv([
1328
+ const e = k.createDiv(["skeleton-field"]), t = k.createDiv([
1249
1329
  "skeleton",
1250
1330
  "skeleton-payment-method"
1251
1331
  ]);
1252
1332
  return e.appendChild(t), e;
1253
1333
  }
1254
1334
  createPaymentSeparatorSkeleton() {
1255
- const e = w.createDiv([
1335
+ const e = k.createDiv([
1256
1336
  "payment-separator_container"
1257
- ]), t = w.createDiv(["payment-separator__line"]), s = w.createDiv([
1337
+ ]), t = k.createDiv(["payment-separator__line"]), s = k.createDiv([
1258
1338
  "skeleton",
1259
1339
  "skeleton-separator-text"
1260
- ]), i = w.createDiv(["payment-separator__line"]);
1261
- return e.appendChild(t), e.appendChild(s), e.appendChild(i), e;
1340
+ ]), a = k.createDiv(["payment-separator__line"]);
1341
+ return e.appendChild(t), e.appendChild(s), e.appendChild(a), e;
1262
1342
  }
1263
1343
  }
1264
- class nt extends A {
1344
+ class at extends w {
1265
1345
  constructor(e) {
1266
1346
  const { translationFunc: t, checkoutProfile: s } = e;
1267
1347
  super("div", ["payment-separator"]);
1268
- const i = this.getElement(), a = document.createElement("span");
1269
- a.className = "payment-separator__line";
1348
+ const a = this.getElement(), i = document.createElement("span");
1349
+ i.className = "payment-separator__line";
1270
1350
  const r = document.createElement("p");
1271
1351
  r.textContent = t("pay-with-card"), r.className = "payment-separator__text", r.style.fontFamily = `${s.styles.fontFamily}, sans-serif`;
1272
- const d = document.createElement("span");
1273
- d.className = "payment-separator__line", i.appendChild(a), i.appendChild(r), i.appendChild(d);
1352
+ const l = document.createElement("span");
1353
+ l.className = "payment-separator__line", a.appendChild(i), a.appendChild(r), a.appendChild(l);
1274
1354
  }
1275
1355
  }
1276
- class at extends A {
1356
+ class it extends w {
1277
1357
  paymentMethods;
1278
1358
  paymentSeparator;
1279
1359
  skeleton;
@@ -1281,14 +1361,14 @@ class at extends A {
1281
1361
  const {
1282
1362
  checkoutProfile: t,
1283
1363
  formData: s,
1284
- onPaypalSubmit: i,
1285
- onApplePaySubmit: a,
1364
+ onPaypalSubmit: a,
1365
+ onApplePaySubmit: i,
1286
1366
  supportedPaymentMethods: r,
1287
- translationFunc: d,
1288
- paymentId: l,
1289
- checkoutKey: u,
1367
+ translationFunc: l,
1368
+ paymentId: d,
1369
+ checkoutKey: h,
1290
1370
  checkoutDetails: E,
1291
- environment: y,
1371
+ environment: S,
1292
1372
  countryCode: o
1293
1373
  } = e;
1294
1374
  if (super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), !t?.additionalPaymentMethods) {
@@ -1299,42 +1379,42 @@ class at extends A {
1299
1379
  this.renderSkeleton();
1300
1380
  return;
1301
1381
  }
1302
- const f = Object.entries(
1382
+ const u = Object.entries(
1303
1383
  t.additionalPaymentMethods
1304
- ).filter(([m, h]) => {
1305
- const p = h.enabled, c = r ? r[m] === !0 : !0, b = !h.countries || o && h.countries.includes(o);
1306
- return p && c && b;
1307
- }).sort((m, h) => m[1].order - h[1].order);
1308
- if (f.length === 0) {
1384
+ ).filter(([g, m]) => {
1385
+ const p = m.enabled, c = r ? r[g] === !0 : !0, f = !m.countries || o && m.countries.includes(o);
1386
+ return p && c && f;
1387
+ }).sort((g, m) => g[1].order - m[1].order);
1388
+ if (u.length === 0) {
1309
1389
  this.getElement().style.display = "none";
1310
1390
  return;
1311
1391
  }
1312
- for (const [m] of f)
1313
- switch (m) {
1392
+ for (const [g] of u)
1393
+ switch (g) {
1314
1394
  case "paypal": {
1315
- if (i) {
1316
- const h = new pe({
1395
+ if (a) {
1396
+ const m = new fe({
1317
1397
  checkoutProfile: t,
1318
1398
  formData: s,
1319
- onSubmit: i
1399
+ onSubmit: a
1320
1400
  });
1321
- this.paymentMethods.set("paypal", h), h.appendTo(this.getElement());
1401
+ this.paymentMethods.set("paypal", m), m.appendTo(this.getElement());
1322
1402
  }
1323
1403
  break;
1324
1404
  }
1325
1405
  case "applePay": {
1326
- if (a && l && u) {
1327
- const h = t.appearance?.additionalPaymentMethods?.applePay, p = new me({
1406
+ if (i && d && h) {
1407
+ const m = t.appearance?.additionalPaymentMethods?.applePay, p = new pe({
1328
1408
  checkoutProfile: t,
1329
1409
  formData: s,
1330
- onSubmit: a,
1331
- paymentId: l,
1332
- checkoutKey: u,
1410
+ onSubmit: i,
1411
+ paymentId: d,
1412
+ checkoutKey: h,
1333
1413
  checkoutDetails: E,
1334
- environment: y,
1335
- displayName: h?.displayName,
1336
- requiredBillingContactFields: h?.requiredBillingContactFields,
1337
- requiredShippingContactFields: h?.requiredShippingContactFields
1414
+ environment: S,
1415
+ displayName: m?.displayName,
1416
+ requiredBillingContactFields: m?.requiredBillingContactFields,
1417
+ requiredShippingContactFields: m?.requiredShippingContactFields
1338
1418
  });
1339
1419
  this.paymentMethods.set("applePay", p), p.appendTo(this.getElement());
1340
1420
  }
@@ -1348,17 +1428,17 @@ class at extends A {
1348
1428
  // break;
1349
1429
  default:
1350
1430
  console.warn(
1351
- `[PaymentMethods] Unsupported payment method: ${m}`
1431
+ `[PaymentMethods] Unsupported payment method: ${g}`
1352
1432
  );
1353
1433
  break;
1354
1434
  }
1355
- this.paymentMethods.size > 0 && (this.paymentSeparator = new nt({
1356
- translationFunc: d,
1435
+ this.paymentMethods.size > 0 && (this.paymentSeparator = new at({
1436
+ translationFunc: l,
1357
1437
  checkoutProfile: t
1358
1438
  }), this.getElement().appendChild(this.paymentSeparator.getElement()));
1359
1439
  }
1360
1440
  renderSkeleton() {
1361
- this.skeleton = new oe(), this.getElement().appendChild(this.skeleton.getElement());
1441
+ this.skeleton = new ce(), this.getElement().appendChild(this.skeleton.getElement());
1362
1442
  }
1363
1443
  updateFormData(e) {
1364
1444
  const t = this.paymentMethods.get("paypal");
@@ -1370,8 +1450,8 @@ class at extends A {
1370
1450
  return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
1371
1451
  }
1372
1452
  }
1373
- const it = 17;
1374
- class rt extends A {
1453
+ const rt = 17;
1454
+ class ot extends w {
1375
1455
  styles;
1376
1456
  isHovered = !1;
1377
1457
  constructor(e) {
@@ -1381,7 +1461,7 @@ class rt extends A {
1381
1461
  }
1382
1462
  applyStyles() {
1383
1463
  const e = this.getElement();
1384
- 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 === it ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
1464
+ 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 === rt ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
1385
1465
  }
1386
1466
  handleMouseEnter() {
1387
1467
  this.isHovered = !0, this.applyStyles();
@@ -1393,12 +1473,12 @@ class rt extends A {
1393
1473
  return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
1394
1474
  }
1395
1475
  }
1396
- class ot {
1476
+ class lt {
1397
1477
  button;
1398
1478
  constructor(e) {
1399
- const { disabled: t, checkoutProfile: s, translationFunc: i } = e;
1400
- this.button = new rt({
1401
- text: i(
1479
+ const { disabled: t, checkoutProfile: s, translationFunc: a } = e;
1480
+ this.button = new ot({
1481
+ text: a(
1402
1482
  `buttonTexts.${s?.layout.actionButton.translationKey}`
1403
1483
  ),
1404
1484
  styles: {
@@ -1424,7 +1504,7 @@ class ot {
1424
1504
  return this.button.appendTo(e), this;
1425
1505
  }
1426
1506
  }
1427
- class lt {
1507
+ class dt {
1428
1508
  formElement;
1429
1509
  focusManager;
1430
1510
  translationFunc;
@@ -1462,10 +1542,10 @@ class lt {
1462
1542
  createPaymentMethods(e, t, s = !1) {
1463
1543
  try {
1464
1544
  if (!e?.additionalPaymentMethods || Object.keys(e.additionalPaymentMethods).length === 0 || !Object.values(e.additionalPaymentMethods).some(
1465
- (i) => i.enabled
1545
+ (a) => a.enabled
1466
1546
  ))
1467
1547
  return;
1468
- this.paymentMethods = new at({
1548
+ this.paymentMethods = new it({
1469
1549
  checkoutProfile: e,
1470
1550
  formData: t,
1471
1551
  supportedPaymentMethods: this.supportedPaymentMethods,
@@ -1481,119 +1561,119 @@ class lt {
1481
1561
  this.paymentMethods.getElement(),
1482
1562
  this.formElement.firstChild
1483
1563
  ) : this.formElement.appendChild(this.paymentMethods.getElement());
1484
- } catch (i) {
1485
- throw console.error("Error creating payment methods:", i), i;
1564
+ } catch (a) {
1565
+ throw console.error("Error creating payment methods:", a), a;
1486
1566
  }
1487
1567
  }
1488
- createEmailField(e, t, s, i) {
1568
+ createEmailField(e, t, s, a) {
1489
1569
  try {
1490
- const a = e.layout.billingFields && Object.values(e.layout.billingFields).some(
1570
+ const i = e.layout.billingFields && Object.values(e.layout.billingFields).some(
1491
1571
  (r) => r?.enabled
1492
1572
  ) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some(
1493
1573
  (r) => r?.enabled
1494
1574
  );
1495
- this.emailField = new fe({
1575
+ this.emailField = new ge({
1496
1576
  value: t.email,
1497
1577
  onChange: this.onChange,
1498
1578
  onBlur: this.onBlur,
1499
- onTab: a ? void 0 : () => this.focusManager.focusField(
1579
+ onTab: i ? void 0 : () => this.focusManager.focusField(
1500
1580
  e.layout.phoneNumber?.enabled ? "phoneNumber" : "cardNumber"
1501
1581
  ),
1502
- error: !!(s.email && i.email),
1582
+ error: !!(s.email && a.email),
1503
1583
  errorMsg: s.email,
1504
1584
  checkoutProfile: e,
1505
1585
  translationFunc: this.translationFunc
1506
1586
  }), this.emailFocusHandler = () => this.onFieldFocus("email"), this.emailField.getElement().addEventListener("focus", this.emailFocusHandler, !0), this.focusManager.registerField("email", this.emailField), this.formElement.appendChild(this.emailField.getElement());
1507
- } catch (a) {
1508
- throw console.error("Error creating email field:", a), a;
1587
+ } catch (i) {
1588
+ throw console.error("Error creating email field:", i), i;
1509
1589
  }
1510
1590
  }
1511
- createPhoneNumberField(e, t, s, i) {
1512
- const a = document.createElement("div");
1513
- this.phonePlaceholder = a, this.formElement.appendChild(a), ge().then(({ PhoneNumberField: r }) => {
1514
- a.isConnected && (this.phoneNumberField = new r({
1591
+ createPhoneNumberField(e, t, s, a) {
1592
+ const i = document.createElement("div");
1593
+ this.phonePlaceholder = i, this.formElement.appendChild(i), ye().then(({ PhoneNumberField: r }) => {
1594
+ i.isConnected && (this.phoneNumberField = new r({
1515
1595
  value: t.phoneNumber ?? "",
1516
1596
  onChange: this.onChange,
1517
1597
  onBlur: this.onBlur,
1518
1598
  onTab: () => this.focusManager.focusField("cardNumber"),
1519
- error: !!(s.phoneNumber && i.phoneNumber),
1599
+ error: !!(s.phoneNumber && a.phoneNumber),
1520
1600
  errorMsg: s.phoneNumber,
1521
1601
  checkoutProfile: e,
1522
1602
  translationFunc: this.translationFunc,
1523
1603
  defaultCountry: e.layout.phoneNumber?.defaultCountry || "US",
1524
1604
  allowedCountries: e.layout.phoneNumber?.allowedCountries,
1525
1605
  locale: this.locale
1526
- }), 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);
1606
+ }), 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);
1527
1607
  }).catch((r) => {
1528
- console.error("Error creating phone number field:", r), a.remove(), this.phonePlaceholder = void 0;
1608
+ console.error("Error creating phone number field:", r), i.remove(), this.phonePlaceholder = void 0;
1529
1609
  });
1530
1610
  }
1531
- createCardSection(e, t, s, i) {
1611
+ createCardSection(e, t, s, a) {
1532
1612
  try {
1533
- this.cardSection = new ye({
1613
+ this.cardSection = new be({
1534
1614
  checkoutProfile: e,
1535
1615
  cardNumber: t.cardNumber,
1536
1616
  cardNumberError: s.cardNumber,
1537
- cardNumberTouched: !!i.cardNumber,
1617
+ cardNumberTouched: !!a.cardNumber,
1538
1618
  cardCvv: t.cardCvv,
1539
1619
  cardCvvError: s.cardCvv,
1540
- cardCvvTouched: !!i.cardCvv,
1620
+ cardCvvTouched: !!a.cardCvv,
1541
1621
  cardExpiry: t.cardExpiry,
1542
1622
  cardExpiryError: s.cardExpiry,
1543
- cardExpiryTouched: !!i.cardExpiry,
1623
+ cardExpiryTouched: !!a.cardExpiry,
1544
1624
  onChange: this.onChange,
1545
1625
  onBlur: this.onBlur,
1546
1626
  onCardBrandChange: () => {
1547
1627
  if (t.cardCvv) {
1548
- const l = new Event("blur", { bubbles: !0 });
1549
- Object.defineProperty(l, "target", {
1628
+ const d = new Event("blur", { bubbles: !0 });
1629
+ Object.defineProperty(d, "target", {
1550
1630
  writable: !1,
1551
1631
  value: { name: "cardCvv", value: t.cardCvv }
1552
- }), this.onBlur(l);
1632
+ }), this.onBlur(d);
1553
1633
  }
1554
1634
  },
1555
1635
  translationFunc: this.translationFunc
1556
1636
  });
1557
- const a = this.cardSection.getElement().querySelector('input[name="cardExpiry"]');
1558
- a && (this.cardExpiryFocusHandler = () => this.onFieldFocus("cardExpiry"), a.addEventListener("focus", this.cardExpiryFocusHandler));
1637
+ const i = this.cardSection.getElement().querySelector('input[name="cardExpiry"]');
1638
+ i && (this.cardExpiryFocusHandler = () => this.onFieldFocus("cardExpiry"), i.addEventListener("focus", this.cardExpiryFocusHandler));
1559
1639
  const r = this.cardSection.getElement().querySelector('input[name="cardNumber"]');
1560
1640
  r && (this.cardNumberFocusHandler = () => this.onFieldFocus("cardNumber"), r.addEventListener("focus", this.cardNumberFocusHandler));
1561
- const d = this.cardSection.getElement().querySelector('input[name="cardCvv"]');
1562
- d && (this.cardCvvFocusHandler = () => this.onFieldFocus("cardCvv"), d.addEventListener("focus", this.cardCvvFocusHandler)), this.focusManager.registerField("cardNumber", {
1641
+ const l = this.cardSection.getElement().querySelector('input[name="cardCvv"]');
1642
+ l && (this.cardCvvFocusHandler = () => this.onFieldFocus("cardCvv"), l.addEventListener("focus", this.cardCvvFocusHandler)), this.focusManager.registerField("cardNumber", {
1563
1643
  focus: () => this.cardSection?.focusField("cardNumber")
1564
1644
  }), this.focusManager.registerField("cardExpiry", {
1565
1645
  focus: () => this.cardSection?.focusField("cardExpiry")
1566
1646
  }), this.focusManager.registerField("cardCvv", {
1567
1647
  focus: () => this.cardSection?.focusField("cardCvv")
1568
1648
  }), this.formElement.appendChild(this.cardSection.getElement());
1569
- } catch (a) {
1570
- throw console.error("Error creating card section:", a), a;
1649
+ } catch (i) {
1650
+ throw console.error("Error creating card section:", i), i;
1571
1651
  }
1572
1652
  }
1573
- createCardholderSection(e, t, s, i) {
1653
+ createCardholderSection(e, t, s, a) {
1574
1654
  try {
1575
- this.cardholderSection = new st({
1655
+ this.cardholderSection = new nt({
1576
1656
  value: t.name,
1577
1657
  onChange: this.onChange,
1578
1658
  onBlur: this.onBlur,
1579
- error: !!(s.name && i.name),
1659
+ error: !!(s.name && a.name),
1580
1660
  errorMsg: s.name,
1581
1661
  checkoutProfile: e,
1582
1662
  translationFunc: this.translationFunc
1583
1663
  });
1584
- const a = this.cardholderSection.getElement().querySelector('input[name="name"]');
1585
- a && (this.nameFocusHandler = () => this.onFieldFocus("name"), a.addEventListener("focus", this.nameFocusHandler)), this.focusManager.registerField("name", this.cardholderSection), this.formElement.appendChild(this.cardholderSection.getElement());
1586
- } catch (a) {
1587
- throw console.error("Error creating cardholder section:", a), a;
1664
+ const i = this.cardholderSection.getElement().querySelector('input[name="name"]');
1665
+ i && (this.nameFocusHandler = () => this.onFieldFocus("name"), i.addEventListener("focus", this.nameFocusHandler)), this.focusManager.registerField("name", this.cardholderSection), this.formElement.appendChild(this.cardholderSection.getElement());
1666
+ } catch (i) {
1667
+ throw console.error("Error creating cardholder section:", i), i;
1588
1668
  }
1589
1669
  }
1590
- createBillingAddressSection(e, t, s, i) {
1670
+ createBillingAddressSection(e, t, s, a) {
1591
1671
  try {
1592
- const a = e.layout.billingFields;
1593
- if (!a || !Object.values(a).some(
1594
- (l) => l?.enabled
1672
+ const i = e.layout.billingFields;
1673
+ if (!i || !Object.values(i).some(
1674
+ (d) => d?.enabled
1595
1675
  )) return;
1596
- const d = {
1676
+ const l = {
1597
1677
  street: "",
1598
1678
  firstName: "",
1599
1679
  lastName: "",
@@ -1602,31 +1682,31 @@ class lt {
1602
1682
  zipCode: "",
1603
1683
  country: ""
1604
1684
  };
1605
- this.billingAddressSection = new se({
1685
+ this.billingAddressSection = new ie({
1606
1686
  type: "billing",
1607
1687
  title: this.translationFunc("address.billingTitle"),
1608
1688
  checkoutProfile: e,
1609
- fieldsConfig: a,
1610
- values: t.billingAddress ?? d,
1689
+ fieldsConfig: i,
1690
+ values: t.billingAddress ?? l,
1611
1691
  errors: s.billingAddress ?? {},
1612
- touched: i.billingAddress ?? {},
1692
+ touched: a.billingAddress ?? {},
1613
1693
  onChange: this.onChange,
1614
1694
  onBlur: this.onBlur,
1615
1695
  translationFunc: this.translationFunc,
1616
1696
  locale: this.locale,
1617
1697
  grouped: e.layout.grouped
1618
1698
  }), this.formElement.appendChild(this.billingAddressSection.getElement());
1619
- } catch (a) {
1620
- throw console.error("Error creating billing address section:", a), a;
1699
+ } catch (i) {
1700
+ throw console.error("Error creating billing address section:", i), i;
1621
1701
  }
1622
1702
  }
1623
- createShippingAddressSection(e, t, s, i) {
1703
+ createShippingAddressSection(e, t, s, a) {
1624
1704
  try {
1625
- const a = e.layout.shippingFields;
1626
- if (!a || !Object.values(a).some(
1627
- (l) => l?.enabled
1705
+ const i = e.layout.shippingFields;
1706
+ if (!i || !Object.values(i).some(
1707
+ (d) => d?.enabled
1628
1708
  )) return;
1629
- const d = {
1709
+ const l = {
1630
1710
  street: "",
1631
1711
  firstName: "",
1632
1712
  lastName: "",
@@ -1635,27 +1715,27 @@ class lt {
1635
1715
  zipCode: "",
1636
1716
  country: ""
1637
1717
  };
1638
- this.shippingAddressSection = new se({
1718
+ this.shippingAddressSection = new ie({
1639
1719
  type: "shipping",
1640
1720
  title: this.translationFunc("address.shippingTitle"),
1641
1721
  checkoutProfile: e,
1642
- fieldsConfig: a,
1643
- values: t.shippingAddress ?? d,
1722
+ fieldsConfig: i,
1723
+ values: t.shippingAddress ?? l,
1644
1724
  errors: s.shippingAddress ?? {},
1645
- touched: i.shippingAddress ?? {},
1725
+ touched: a.shippingAddress ?? {},
1646
1726
  onChange: this.onChange,
1647
1727
  onBlur: this.onBlur,
1648
1728
  translationFunc: this.translationFunc,
1649
1729
  locale: this.locale,
1650
1730
  grouped: e.layout.grouped
1651
1731
  }), this.formElement.appendChild(this.shippingAddressSection.getElement());
1652
- } catch (a) {
1653
- throw console.error("Error creating shipping address section:", a), a;
1732
+ } catch (i) {
1733
+ throw console.error("Error creating shipping address section:", i), i;
1654
1734
  }
1655
1735
  }
1656
1736
  createSubmitButton(e, t) {
1657
1737
  try {
1658
- this.submitButton = new ot({
1738
+ this.submitButton = new lt({
1659
1739
  disabled: t,
1660
1740
  checkoutProfile: e,
1661
1741
  translationFunc: this.translationFunc
@@ -1670,15 +1750,15 @@ class lt {
1670
1750
  updatePhoneNumberField(e, t, s) {
1671
1751
  this.phoneNumberField && (this.phoneNumberField.setValue(e), this.phoneNumberField.setError(t, s));
1672
1752
  }
1673
- updateCardSection(e, t, s, i, a, r, d, l, u) {
1753
+ updateCardSection(e, t, s, a, i, r, l, d, h) {
1674
1754
  this.cardSection && (this.cardSection.updateCardNumber(
1675
1755
  e,
1676
1756
  t,
1677
1757
  s
1678
- ), this.cardSection.updateCardCvv(i, a, r), this.cardSection.updateCardExpiry(
1679
- d,
1758
+ ), this.cardSection.updateCardCvv(a, i, r), this.cardSection.updateCardExpiry(
1680
1759
  l,
1681
- u
1760
+ d,
1761
+ h
1682
1762
  ));
1683
1763
  }
1684
1764
  updateCardholderSection(e, t, s) {
@@ -1738,7 +1818,7 @@ class lt {
1738
1818
  this.billingAddressSection && (this.billingAddressSection.getElement().remove(), this.billingAddressSection = void 0), this.shippingAddressSection && (this.shippingAddressSection.getElement().remove(), this.shippingAddressSection = void 0), this.submitButton && (this.submitButton.getElement().remove(), this.submitButton = void 0), this.paymentMethods && (this.paymentMethods.getElement().remove(), this.paymentMethods = void 0);
1739
1819
  }
1740
1820
  }
1741
- class dt {
1821
+ class ct {
1742
1822
  formManager;
1743
1823
  focusManager;
1744
1824
  onFormSubmit;
@@ -1748,18 +1828,18 @@ class dt {
1748
1828
  this.formManager = e.formManager, this.focusManager = e.focusManager, this.onFormSubmit = e.onFormSubmit, this.onUIUpdate = e.onUIUpdate;
1749
1829
  }
1750
1830
  handleChange = (e) => {
1751
- const t = e.target, { name: s, value: i } = t, a = s;
1752
- this.formManager.handleChange(a, i), this.localTouchedFields.has(a) || (this.localTouchedFields.add(a), this.formManager.handleBlur(a, i));
1753
- const { formData: r, errors: d, touched: l } = this.formManager.getFormState();
1754
- this.focusManager.handleStateUpdate(r, d, l);
1831
+ const t = e.target, { name: s, value: a } = t, i = s;
1832
+ this.formManager.handleChange(i, a), e instanceof CustomEvent && e.detail?.programmatic ? this.localTouchedFields.delete(i) : this.localTouchedFields.has(i) || (this.localTouchedFields.add(i), this.formManager.handleBlur(i, a));
1833
+ const { formData: l, errors: d, touched: h } = this.formManager.getFormState();
1834
+ this.focusManager.handleStateUpdate(l, d, h);
1755
1835
  };
1756
1836
  handleBlur = (e) => {
1757
- const t = e.target, { name: s, value: i } = t, a = s;
1758
- this.localTouchedFields.add(a), this.formManager.handleBlur(a, i), setTimeout(() => {
1837
+ const t = e.target, { name: s, value: a } = t, i = s;
1838
+ this.localTouchedFields.add(i), this.formManager.handleBlur(i, a), setTimeout(() => {
1759
1839
  this.onUIUpdate();
1760
1840
  }, 0);
1761
- const { formData: r, errors: d, touched: l } = this.formManager.getFormState();
1762
- l[a] || this.focusManager.handleStateUpdate(r, d, l);
1841
+ const { formData: r, errors: l, touched: d } = this.formManager.getFormState();
1842
+ d[i] || this.focusManager.handleStateUpdate(r, l, d);
1763
1843
  };
1764
1844
  handleSubmit = async (e) => {
1765
1845
  e.preventDefault(), await this.onFormSubmit(e);
@@ -1779,7 +1859,7 @@ class dt {
1779
1859
  this.localTouchedFields.clear();
1780
1860
  }
1781
1861
  }
1782
- class ct {
1862
+ class ht {
1783
1863
  formManager;
1784
1864
  checkoutProfile;
1785
1865
  formElement;
@@ -1801,7 +1881,7 @@ class ct {
1801
1881
  try {
1802
1882
  if (e.checkoutProfile.styles?.fontFamily)
1803
1883
  try {
1804
- const { cleanup: t } = be({
1884
+ const { cleanup: t } = Ee({
1805
1885
  fontFamily: e.checkoutProfile.styles.fontFamily
1806
1886
  });
1807
1887
  this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
@@ -1818,13 +1898,15 @@ class ct {
1818
1898
  };
1819
1899
  isFormDisabled() {
1820
1900
  const e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), s = Object.keys(e.errors).filter(
1821
- (c) => c !== "billingAddress" && c !== "shippingAddress"
1822
- ).length > 0, i = e.errors.billingAddress, a = i && typeof i == "object" ? Object.keys(i).length > 0 : !1, r = e.errors.shippingAddress, d = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, l = s || a || d, E = $(
1901
+ (f) => f !== "billingAddress" && f !== "shippingAddress"
1902
+ ).length > 0, a = e.errors.billingAddress, i = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, l = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || i || l, E = Z(
1823
1903
  t.checkoutProfile?.layout
1824
- ) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, o = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: f, shippingFields: m } = t.checkoutProfile?.layout ?? {}, h = (c, b) => !c || Object.entries(c).every(
1825
- ([g, S]) => !S?.enabled || !!b?.[g]?.trim()
1826
- ), p = !!e.formData.email && o && E && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && h(f, e.formData.billingAddress) && h(m, e.formData.shippingAddress);
1827
- return l || !p || this.isSubmitting;
1904
+ ) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, o = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: u, shippingFields: g } = t.checkoutProfile?.layout ?? {}, m = /* @__PURE__ */ new Set(["US", "CA"]), p = (f, y) => {
1905
+ if (!f) return !0;
1906
+ const b = y?.country ?? "";
1907
+ return Object.entries(f).every(([C, N]) => !N?.enabled || C === "state" && (!m.has(b) || N.hiddenForCountries?.includes(b)) ? !0 : !!y?.[C]?.trim());
1908
+ }, c = !!e.formData.email && o && E && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && p(u, e.formData.billingAddress) && p(g, e.formData.shippingAddress);
1909
+ return d || !c || this.isSubmitting;
1828
1910
  }
1829
1911
  setSubmitting(e) {
1830
1912
  this.isSubmitting = e;
@@ -1836,18 +1918,18 @@ class ct {
1836
1918
  this.fontCleanup && (this.fontCleanup(), this.fontCleanup = void 0);
1837
1919
  }
1838
1920
  }
1839
- class ht extends A {
1921
+ class ut extends w {
1840
1922
  titleElement;
1841
1923
  constructor(e = {}) {
1842
1924
  super("div", ["blur-bg"]);
1843
- const t = w.createDiv(["loader"]);
1844
- this.titleElement = new A("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
1925
+ const t = k.createDiv(["loader"]);
1926
+ this.titleElement = new w("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
1845
1927
  }
1846
1928
  setText(e) {
1847
1929
  return this.titleElement.setText(e), this;
1848
1930
  }
1849
1931
  }
1850
- const ne = {
1932
+ const re = {
1851
1933
  street: "",
1852
1934
  firstName: "",
1853
1935
  lastName: "",
@@ -1855,16 +1937,16 @@ const ne = {
1855
1937
  city: "",
1856
1938
  zipCode: "",
1857
1939
  country: ""
1858
- }, ae = (n, e) => {
1940
+ }, oe = (n, e) => {
1859
1941
  const t = {}, s = `${e}.`;
1860
- return Object.keys(n).forEach((i) => {
1861
- if (i.startsWith(s)) {
1862
- const a = i.slice(s.length);
1863
- t[a] = n[i];
1942
+ return Object.keys(n).forEach((a) => {
1943
+ if (a.startsWith(s)) {
1944
+ const i = a.slice(s.length);
1945
+ t[i] = n[a];
1864
1946
  }
1865
1947
  }), t;
1866
1948
  };
1867
- class ut {
1949
+ class mt {
1868
1950
  formElement;
1869
1951
  componentManager;
1870
1952
  onLoadingStateChange;
@@ -1898,13 +1980,13 @@ class ut {
1898
1980
  !!(e.errors.name && e.touched.name),
1899
1981
  e.errors.name
1900
1982
  ), this.componentManager.updateBillingAddressSection(
1901
- e.formData.billingAddress ?? ne,
1983
+ e.formData.billingAddress ?? re,
1902
1984
  e.errors.billingAddress ?? {},
1903
- ae(e.touched, "billingAddress")
1985
+ oe(e.touched, "billingAddress")
1904
1986
  ), this.componentManager.updateShippingAddressSection(
1905
- e.formData.shippingAddress ?? ne,
1987
+ e.formData.shippingAddress ?? re,
1906
1988
  e.errors.shippingAddress ?? {},
1907
- ae(e.touched, "shippingAddress")
1989
+ oe(e.touched, "shippingAddress")
1908
1990
  ), this.componentManager.updateSubmitButton(t);
1909
1991
  }
1910
1992
  setLoadingState(e) {
@@ -1912,10 +1994,10 @@ class ut {
1912
1994
  this.onLoadingStateChange(e);
1913
1995
  return;
1914
1996
  }
1915
- e ? (this.hideSkeleton(), this.formSkeleton = new oe(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
1997
+ e ? (this.hideSkeleton(), this.formSkeleton = new ce(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
1916
1998
  }
1917
1999
  showSpinner(e) {
1918
- this.hideSpinner(), this.spinner = new ht({ text: e }), this.formElement.appendChild(this.spinner.getElement());
2000
+ this.hideSpinner(), this.spinner = new ut({ text: e }), this.formElement.appendChild(this.spinner.getElement());
1919
2001
  }
1920
2002
  hideSpinner() {
1921
2003
  this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0);
@@ -1924,7 +2006,7 @@ class ut {
1924
2006
  this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0);
1925
2007
  }
1926
2008
  setErrorMessage(e) {
1927
- this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new Ee({ message: e }), this.formElement.insertBefore(
2009
+ this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new Se({ message: e }), this.formElement.insertBefore(
1928
2010
  this.alert.getElement(),
1929
2011
  this.formElement.firstChild
1930
2012
  );
@@ -1936,7 +2018,7 @@ class ut {
1936
2018
  this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0), this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0), this.alert && (this.alert.getElement().remove(), this.alert = void 0);
1937
2019
  }
1938
2020
  }
1939
- const I = (n) => ({
2021
+ const D = (n) => ({
1940
2022
  street: "",
1941
2023
  firstName: "",
1942
2024
  lastName: "",
@@ -1946,21 +2028,21 @@ const I = (n) => ({
1946
2028
  country: "",
1947
2029
  ...n
1948
2030
  });
1949
- class mt extends A {
2031
+ class pt extends w {
1950
2032
  options;
1951
- formManager = tt();
2033
+ formManager = st();
1952
2034
  checkoutProfile;
1953
- translation = Se();
1954
- focusManager = new Fe();
2035
+ translation = Fe();
2036
+ focusManager = new Ce();
1955
2037
  // Managers
1956
2038
  componentManager;
1957
2039
  eventHandler;
1958
2040
  stateCoordinator;
1959
2041
  uiManager;
1960
2042
  constructor(e) {
1961
- super("form", ["form-container"]), this.options = e, this.checkoutProfile = et({
2043
+ super("form", ["form-container"]), this.options = e, this.checkoutProfile = tt({
1962
2044
  appearance: e.appearance
1963
- }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new lt({
2045
+ }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new dt({
1964
2046
  formElement: this.element,
1965
2047
  focusManager: this.focusManager,
1966
2048
  translationFunc: this.translation.t,
@@ -1975,11 +2057,11 @@ class mt extends A {
1975
2057
  checkoutKey: e.checkoutKey,
1976
2058
  checkoutDetails: e.checkoutDetails,
1977
2059
  environment: e.environment
1978
- }), this.uiManager = new ut({
2060
+ }), this.uiManager = new mt({
1979
2061
  formElement: this.element,
1980
2062
  componentManager: this.componentManager,
1981
2063
  onLoadingStateChange: e.onLoadingStateChange
1982
- }), this.stateCoordinator = new ct({
2064
+ }), this.stateCoordinator = new ht({
1983
2065
  formManager: this.formManager,
1984
2066
  checkoutProfile: this.checkoutProfile,
1985
2067
  componentManager: this.componentManager,
@@ -1989,7 +2071,7 @@ class mt extends A {
1989
2071
  onError: (t) => this.uiManager.setErrorMessage(t),
1990
2072
  onLoadingChange: (t) => this.uiManager.setLoadingState(t),
1991
2073
  getInitialFormData: () => this._getFormStateData().formData
1992
- }), this.eventHandler = new dt({
2074
+ }), this.eventHandler = new ct({
1993
2075
  formManager: this.formManager,
1994
2076
  focusManager: this.focusManager,
1995
2077
  onFormSubmit: async () => this.handleSubmit(),
@@ -2014,12 +2096,12 @@ class mt extends A {
2014
2096
  },
2015
2097
  ...e.initialValues.name && { name: e.initialValues.name },
2016
2098
  ...e.initialValues.billingAddress && {
2017
- billingAddress: I(
2099
+ billingAddress: D(
2018
2100
  e.initialValues.billingAddress
2019
2101
  )
2020
2102
  },
2021
2103
  ...e.initialValues.shippingAddress && {
2022
- shippingAddress: I(
2104
+ shippingAddress: D(
2023
2105
  e.initialValues.shippingAddress
2024
2106
  )
2025
2107
  }
@@ -2036,10 +2118,10 @@ class mt extends A {
2036
2118
  cardNumber: "",
2037
2119
  cardCvv: "",
2038
2120
  ...t?.billingAddress && {
2039
- billingAddress: I(t.billingAddress)
2121
+ billingAddress: D(t.billingAddress)
2040
2122
  },
2041
2123
  ...t?.shippingAddress && {
2042
- shippingAddress: I(t.shippingAddress)
2124
+ shippingAddress: D(t.shippingAddress)
2043
2125
  }
2044
2126
  },
2045
2127
  errors: e.errors || {},
@@ -2055,12 +2137,15 @@ class mt extends A {
2055
2137
  this.uiManager.setErrorMessage("Failed to load checkout configuration");
2056
2138
  return;
2057
2139
  }
2058
- this.componentManager.hasComponents() && this.componentManager.cleanup(), e.checkoutProfile.layout.phoneNumber?.enabled && this.formManager.getFormState().formData.phoneNumber === void 0 && this.formManager.setFormData({ phoneNumber: "" }), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({
2059
- billingAddress: I()
2140
+ this.componentManager.hasComponents() && this.componentManager.cleanup(), e.checkoutProfile.layout.phoneNumber?.enabled && this.formManager.getFormState().formData.phoneNumber === void 0 && this.formManager.setFormData({
2141
+ phoneNumber: "",
2142
+ phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
2143
+ }), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({
2144
+ billingAddress: D()
2060
2145
  }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({
2061
- shippingAddress: I()
2146
+ shippingAddress: D()
2062
2147
  });
2063
- const { formData: t, errors: s, touched: i } = this._getFormStateData(), a = $(
2148
+ const { formData: t, errors: s, touched: a } = this._getFormStateData(), i = Z(
2064
2149
  e.checkoutProfile.layout
2065
2150
  );
2066
2151
  try {
@@ -2076,18 +2161,18 @@ class mt extends A {
2076
2161
  e.checkoutProfile,
2077
2162
  t,
2078
2163
  s,
2079
- i
2164
+ a
2080
2165
  );
2081
2166
  } catch (r) {
2082
2167
  console.error("Failed to create email field:", r);
2083
2168
  }
2084
- if (a) {
2169
+ if (i) {
2085
2170
  try {
2086
2171
  this.componentManager.createBillingAddressSection(
2087
2172
  e.checkoutProfile,
2088
2173
  t,
2089
2174
  s,
2090
- i
2175
+ a
2091
2176
  );
2092
2177
  } catch (r) {
2093
2178
  console.error("Failed to create billing address section:", r);
@@ -2097,7 +2182,7 @@ class mt extends A {
2097
2182
  e.checkoutProfile,
2098
2183
  t,
2099
2184
  s,
2100
- i
2185
+ a
2101
2186
  );
2102
2187
  } catch (r) {
2103
2188
  console.error("Failed to create shipping address section:", r);
@@ -2109,7 +2194,7 @@ class mt extends A {
2109
2194
  e.checkoutProfile,
2110
2195
  t,
2111
2196
  s,
2112
- i
2197
+ a
2113
2198
  );
2114
2199
  } catch (r) {
2115
2200
  console.error("Failed to create phone number field:", r);
@@ -2119,18 +2204,18 @@ class mt extends A {
2119
2204
  e.checkoutProfile,
2120
2205
  t,
2121
2206
  s,
2122
- i
2207
+ a
2123
2208
  );
2124
2209
  } catch (r) {
2125
2210
  console.error("Failed to create card section:", r);
2126
2211
  }
2127
- if (!a)
2212
+ if (!i)
2128
2213
  try {
2129
2214
  this.componentManager.createCardholderSection(
2130
2215
  e.checkoutProfile,
2131
2216
  t,
2132
2217
  s,
2133
- i
2218
+ a
2134
2219
  );
2135
2220
  } catch (r) {
2136
2221
  console.error("Failed to create cardholder section:", r);
@@ -2157,13 +2242,13 @@ class mt extends A {
2157
2242
  */
2158
2243
  inferCardholderName() {
2159
2244
  const e = this.checkoutProfile.getState();
2160
- if (!e.checkoutProfile || !$(
2245
+ if (!e.checkoutProfile || !Z(
2161
2246
  e.checkoutProfile.layout
2162
2247
  )) return;
2163
- const { formData: s } = this._getFormStateData(), i = s.billingAddress ?? s.shippingAddress;
2164
- if (!i) return;
2165
- const a = i.firstName?.trim() ?? "", r = i.lastName?.trim() ?? "", d = [a, r].filter(Boolean).join(" ");
2166
- d && this.formManager.setFormData({ name: d });
2248
+ const { formData: s } = this._getFormStateData(), a = s.billingAddress ?? s.shippingAddress;
2249
+ if (!a) return;
2250
+ const i = a.firstName?.trim() ?? "", r = a.lastName?.trim() ?? "", l = [i, r].filter(Boolean).join(" ");
2251
+ l && this.formManager.setFormData({ name: l });
2167
2252
  }
2168
2253
  /**
2169
2254
  * Infers address data based on field configuration.
@@ -2173,10 +2258,10 @@ class mt extends A {
2173
2258
  inferAddresses() {
2174
2259
  const e = this.checkoutProfile.getState();
2175
2260
  if (!e.checkoutProfile) return;
2176
- const { billingFields: t, shippingFields: s } = e.checkoutProfile.layout, i = t && Object.values(t).some((d) => d?.enabled), a = s && Object.values(s).some((d) => d?.enabled), { formData: r } = this._getFormStateData();
2177
- !i && a && r.shippingAddress ? this.formManager.setFormData({
2261
+ const { billingFields: t, shippingFields: s } = e.checkoutProfile.layout, a = t && Object.values(t).some((l) => l?.enabled), i = s && Object.values(s).some((l) => l?.enabled), { formData: r } = this._getFormStateData();
2262
+ !a && i && r.shippingAddress ? this.formManager.setFormData({
2178
2263
  billingAddress: { ...r.shippingAddress }
2179
- }) : !a && i && r.billingAddress && this.formManager.setFormData({
2264
+ }) : !i && a && r.billingAddress && this.formManager.setFormData({
2180
2265
  shippingAddress: { ...r.billingAddress }
2181
2266
  });
2182
2267
  }
@@ -2236,26 +2321,26 @@ class mt extends A {
2236
2321
  this.eventHandler.handleKeyDown
2237
2322
  ), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
2238
2323
  }
2239
- associatePayment(e, t, s, i) {
2240
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = i, this.componentManager.removePaymentMethods(), this.componentManager.updateSupportedPaymentMethods(
2324
+ associatePayment(e, t, s, a) {
2325
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.removePaymentMethods(), this.componentManager.updateSupportedPaymentMethods(
2241
2326
  s
2242
2327
  ), this.componentManager.updatePaymentDetails(
2243
2328
  e,
2244
2329
  t,
2245
- i
2330
+ a
2246
2331
  );
2247
- const a = this.checkoutProfile.getState();
2248
- if (a.checkoutProfile) {
2332
+ const i = this.checkoutProfile.getState();
2333
+ if (i.checkoutProfile) {
2249
2334
  const { formData: r } = this._getFormStateData();
2250
2335
  this.componentManager.createPaymentMethods(
2251
- a.checkoutProfile,
2336
+ i.checkoutProfile,
2252
2337
  r,
2253
2338
  !0
2254
2339
  );
2255
2340
  }
2256
2341
  }
2257
2342
  }
2258
- class pt {
2343
+ class ft {
2259
2344
  container = null;
2260
2345
  options;
2261
2346
  onSubmit;
@@ -2279,7 +2364,7 @@ class pt {
2279
2364
  }
2280
2365
  }
2281
2366
  renderForm(e) {
2282
- this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new mt({
2367
+ this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new pt({
2283
2368
  apiKey: this.options.apiKey,
2284
2369
  onSubmit: this.onSubmit,
2285
2370
  locale: this.options.locale,
@@ -2305,16 +2390,16 @@ class pt {
2305
2390
  clearError() {
2306
2391
  this.form && this.form.clearErrorMessage();
2307
2392
  }
2308
- async associatePayment(e, t, s, i) {
2309
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = i, this.form && this.form.associatePayment(
2393
+ async associatePayment(e, t, s, a) {
2394
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.checkoutDetails = a, this.form && this.form.associatePayment(
2310
2395
  e,
2311
2396
  t,
2312
2397
  s,
2313
- i
2398
+ a
2314
2399
  );
2315
2400
  }
2316
2401
  }
2317
- class ft {
2402
+ class gt {
2318
2403
  state;
2319
2404
  listeners = /* @__PURE__ */ new Set();
2320
2405
  constructor(e) {
@@ -2336,8 +2421,8 @@ class ft {
2336
2421
  this.listeners.forEach((t) => t(e));
2337
2422
  }
2338
2423
  }
2339
- const gt = "en";
2340
- class yt {
2424
+ const yt = "en";
2425
+ class bt {
2341
2426
  config;
2342
2427
  paymentState;
2343
2428
  apiService;
@@ -2345,18 +2430,18 @@ class yt {
2345
2430
  stateManager;
2346
2431
  sessionId;
2347
2432
  constructor(e) {
2348
- this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), Qe({
2433
+ this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), Je({
2349
2434
  environment: this.config.environment,
2350
2435
  sessionId: this.sessionId
2351
- }), C(v.CHECKOUT_INITIALIZED, {
2436
+ }), M(v.CHECKOUT_INITIALIZED, {
2352
2437
  environment: this.config.environment
2353
2438
  }), this.apiService = new ve(
2354
2439
  this.config.apiKey,
2355
2440
  this.config.environment
2356
- ), this.stateManager = new ft({
2441
+ ), this.stateManager = new gt({
2357
2442
  mounted: !1,
2358
2443
  form: null
2359
- }), this.formManager = new pt(
2444
+ }), this.formManager = new ft(
2360
2445
  {
2361
2446
  locale: this.config.locale,
2362
2447
  apiKey: this.config.apiKey,
@@ -2378,7 +2463,7 @@ class yt {
2378
2463
  apiKey: e.apiKey,
2379
2464
  returnUrl: e.returnUrl,
2380
2465
  environment: e.environment,
2381
- locale: e.locale || gt,
2466
+ locale: e.locale || yt,
2382
2467
  disableErrorMessages: e.disableErrorMessages ?? !1,
2383
2468
  manualActionHandling: e.manualActionHandling ?? !1,
2384
2469
  appearance: e.appearance,
@@ -2399,7 +2484,7 @@ class yt {
2399
2484
  return t.appendChild(s), this.stateManager.updateState({
2400
2485
  form: s,
2401
2486
  mounted: !0
2402
- }), this.formManager.mount(s), C(v.CHECKOUT_MOUNTED, {
2487
+ }), this.formManager.mount(s), M(v.CHECKOUT_MOUNTED, {
2403
2488
  container_id: e
2404
2489
  }), this;
2405
2490
  }
@@ -2411,7 +2496,7 @@ class yt {
2411
2496
  t && t.remove(), this.stateManager.updateState({
2412
2497
  form: null,
2413
2498
  mounted: !1
2414
- }), C(v.CHECKOUT_UNMOUNTED);
2499
+ }), M(v.CHECKOUT_UNMOUNTED);
2415
2500
  });
2416
2501
  }
2417
2502
  async handleSubmit({
@@ -2423,21 +2508,21 @@ class yt {
2423
2508
  "Payment must be associated before submitting. Call associatePayment() first."
2424
2509
  );
2425
2510
  const s = this.getPaymentMethod(e, t);
2426
- C(v.PAYMENT_SUBMIT_STARTED, {
2511
+ M(v.PAYMENT_SUBMIT_STARTED, {
2427
2512
  payment_id: this.paymentState.paymentId,
2428
2513
  payment_method: s
2429
2514
  });
2430
- const i = performance.now();
2515
+ const a = performance.now();
2431
2516
  try {
2432
- const a = await this.apiService.authorizePayment({
2517
+ const i = await this.apiService.authorizePayment({
2433
2518
  checkoutKey: this.paymentState.checkoutKey,
2434
2519
  formData: e || null,
2435
2520
  paymentId: this.paymentState.paymentId,
2436
2521
  returnUrl: this.config.returnUrl,
2437
2522
  applePayData: t
2438
- }), r = performance.now() - i;
2439
- te(
2440
- G.PAYMENT_AUTHORIZATION_TIME,
2523
+ }), r = performance.now() - a;
2524
+ ae(
2525
+ J.PAYMENT_AUTHORIZATION_TIME,
2441
2526
  r,
2442
2527
  "ms",
2443
2528
  {
@@ -2445,14 +2530,14 @@ class yt {
2445
2530
  payment_method: s,
2446
2531
  status: "success"
2447
2532
  }
2448
- ), C(v.PAYMENT_SUBMIT_SUCCESS, {
2533
+ ), M(v.PAYMENT_SUBMIT_SUCCESS, {
2449
2534
  payment_id: this.paymentState.paymentId,
2450
2535
  payment_method: s
2451
- }), this.handlePaymentResponse(a);
2452
- } catch (a) {
2453
- const r = performance.now() - i;
2454
- te(
2455
- G.PAYMENT_AUTHORIZATION_TIME,
2536
+ }), this.handlePaymentResponse(i);
2537
+ } catch (i) {
2538
+ const r = performance.now() - a;
2539
+ ae(
2540
+ J.PAYMENT_AUTHORIZATION_TIME,
2456
2541
  r,
2457
2542
  "ms",
2458
2543
  {
@@ -2460,25 +2545,25 @@ class yt {
2460
2545
  payment_method: s,
2461
2546
  status: "failed"
2462
2547
  }
2463
- ), C(v.PAYMENT_SUBMIT_FAILED, {
2548
+ ), M(v.PAYMENT_SUBMIT_FAILED, {
2464
2549
  payment_id: this.paymentState.paymentId,
2465
2550
  payment_method: s,
2466
- error_message: a.details?.message ?? "Unknown error"
2467
- }), this.handleAuthorizationError(a);
2551
+ error_message: i.details?.message ?? "Unknown error"
2552
+ }), this.handleAuthorizationError(i);
2468
2553
  }
2469
2554
  }
2470
2555
  handlePaymentResponse(e) {
2471
- if (e.latestTransaction.status === "authorized" && (C(v.PAYMENT_AUTHORIZED, {
2556
+ if (e.latestTransaction.status === "authorized" && (M(v.PAYMENT_AUTHORIZED, {
2472
2557
  payment_id: this.paymentState.paymentId ?? "",
2473
2558
  status: e.latestTransaction.status
2474
2559
  }), this.config.callbacks.onPaymentSucceeded?.(
2475
2560
  e.latestTransaction.status
2476
- )), e.latestTransaction.status === "failed" && (C(v.PAYMENT_FAILED, {
2561
+ )), e.latestTransaction.status === "failed" && (M(v.PAYMENT_FAILED, {
2477
2562
  payment_id: this.paymentState.paymentId ?? "",
2478
2563
  status: e.latestTransaction.status
2479
2564
  }), this.config.callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
2480
2565
  const { redirectUrl: t } = e.action;
2481
- C(v.PAYMENT_ACTION_REQUIRED, {
2566
+ M(v.PAYMENT_ACTION_REQUIRED, {
2482
2567
  payment_id: this.paymentState.paymentId ?? "",
2483
2568
  status: e.status
2484
2569
  }), this.config.manualActionHandling ? this.config.callbacks.onActionRequired?.(t) : globalThis.location.href = t;
@@ -2518,7 +2603,7 @@ class yt {
2518
2603
  throw new Error("paymentId and checkoutKey are required");
2519
2604
  this.paymentState.paymentId = e, this.paymentState.checkoutKey = t;
2520
2605
  try {
2521
- const s = await Ce({
2606
+ const s = await Me({
2522
2607
  id: e,
2523
2608
  checkoutKey: t,
2524
2609
  environment: this.config.environment
@@ -2528,7 +2613,7 @@ class yt {
2528
2613
  "Invalid response: supportedPaymentMethods must be an array"
2529
2614
  );
2530
2615
  if (!s.supportedPaymentMethods.every(
2531
- (a) => typeof a == "string"
2616
+ (i) => typeof i == "string"
2532
2617
  ))
2533
2618
  throw new Error(
2534
2619
  "Invalid response: all supportedPaymentMethods must be strings"
@@ -2538,44 +2623,44 @@ class yt {
2538
2623
  currency: s.currency,
2539
2624
  countryCode: s.countryCode
2540
2625
  };
2541
- const i = s.supportedPaymentMethods.reduce(
2542
- (a, r) => (a[r] = !0, a),
2626
+ const a = s.supportedPaymentMethods.reduce(
2627
+ (i, r) => (i[r] = !0, i),
2543
2628
  {}
2544
2629
  );
2545
2630
  await this.formManager.associatePayment(
2546
2631
  e,
2547
2632
  t,
2548
- i,
2633
+ a,
2549
2634
  this.paymentState.checkoutDetails
2550
- ), C(v.PAYMENT_ASSOCIATED, {
2635
+ ), M(v.PAYMENT_ASSOCIATED, {
2551
2636
  payment_id: e,
2552
2637
  currency: s.currency,
2553
2638
  country_code: s.countryCode
2554
2639
  });
2555
2640
  } catch (s) {
2556
- throw C(v.PAYMENT_ASSOCIATION_FAILED, {
2641
+ throw M(v.PAYMENT_ASSOCIATION_FAILED, {
2557
2642
  payment_id: e,
2558
2643
  error_message: s instanceof Error ? s.message : "Unknown error"
2559
- }), Je(
2644
+ }), et(
2560
2645
  s instanceof Error ? s : new Error("Failed to associate payment"),
2561
2646
  { payment_id: e }
2562
2647
  ), s;
2563
2648
  }
2564
2649
  }
2565
2650
  }
2566
- typeof globalThis < "u" && (globalThis.OdusCheckout = yt);
2651
+ typeof globalThis < "u" && (globalThis.OdusCheckout = bt);
2567
2652
  export {
2568
- yt as OdusCheckout,
2653
+ bt as OdusCheckout,
2569
2654
  vt as deLocale,
2570
- Ct as enLocale,
2571
- Mt as esLocale,
2572
- Nt as frLocale,
2573
- Pt as itLocale,
2574
- At as plLocale,
2575
- wt as ptLocale,
2576
- Je as pushError,
2577
- C as pushEvent,
2578
- Et as pushLog,
2579
- te as pushMeasurement,
2580
- kt as trLocale
2655
+ Mt as enLocale,
2656
+ Nt as esLocale,
2657
+ Pt as frLocale,
2658
+ At as itLocale,
2659
+ wt as plLocale,
2660
+ kt as ptLocale,
2661
+ et as pushError,
2662
+ M as pushEvent,
2663
+ St as pushLog,
2664
+ ae as pushMeasurement,
2665
+ It as trLocale
2581
2666
  };