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

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,6 +1,6 @@
1
- import { l as pe, c as de, a as ge, f as U, d as fe, C as P, I as ce, g as ye, S as H, b as Z, H as be, V as J, e as k, A as ve, P as Se, E as Ee, h as Ce, i as Fe, j as Me, k as Ne, m as we, n as Pe, F as ke, o as Ae, p as De } from "./shared.js";
2
- import { q as Tt, r as Vt, s as _t, t as Bt, u as Ot, v as Rt, w as Ut, x as Ht } from "./shared.js";
3
- const C = {
1
+ import { l as fe, c as me, a as ye, f as q, d as be, C as A, I as pe, b as P, g as ve, S as _, e as ee, H as Se, V as te, h as D, A as Ce, P as Ee, E as Fe, i as Me, j as Ne, k as we, m as Pe, n as ke, o as Ae, F as xe, p as De, q as Ie } from "./shared.js";
2
+ import { r as _t, s as Rt, t as Bt, u as Ut, v as Ot, w as Ht, x as zt, y as $t } from "./shared.js";
3
+ const F = {
4
4
  // Checkout lifecycle events
5
5
  CHECKOUT_INITIALIZED: "checkout.initialized",
6
6
  CHECKOUT_MOUNTED: "checkout.mounted",
@@ -16,11 +16,11 @@ const C = {
16
16
  PAYMENT_AUTHORIZED: "payment.authorized",
17
17
  PAYMENT_FAILED: "payment.failed",
18
18
  PAYMENT_ACTION_REQUIRED: "payment.action_required"
19
- }, X = {
19
+ }, se = {
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
- }, Ie = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, xe = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Le = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, q = (i) => {
23
+ }, Te = /^\s*at (?:(.+?) ?\()?((?:file|https?|chrome-extension|webpack-internal):\/\/.+?):(\d+):(\d+)\)?\s*$/, Le = /^([^@]+)@((?:file|https?|chrome-extension|webpack-internal):\/\/[^\s:]+):(\d+):(\d+)$/, Ve = /^(?:([^@]+)@)?((?:file|https?):\/\/[^\s:]+):(\d+):(\d+)$/, Z = (i) => {
24
24
  if (!i)
25
25
  return [];
26
26
  const e = [], t = i.split(`
@@ -29,7 +29,7 @@ const C = {
29
29
  const a = s.trim();
30
30
  if (!a)
31
31
  continue;
32
- let n = Ie.exec(a);
32
+ let n = Te.exec(a);
33
33
  if (n) {
34
34
  e.push({
35
35
  function: n[1] || "(anonymous)",
@@ -39,7 +39,7 @@ const C = {
39
39
  });
40
40
  continue;
41
41
  }
42
- n = xe.exec(a) ?? Le.exec(a), n && e.push({
42
+ n = Le.exec(a) ?? Ve.exec(a), n && e.push({
43
43
  function: n[1] || "(anonymous)",
44
44
  filename: n[2],
45
45
  lineno: parseInt(n[3], 10),
@@ -47,9 +47,9 @@ const C = {
47
47
  });
48
48
  }
49
49
  return e;
50
- }, Te = "@odus/telemetry", Ve = "0.0.1";
51
- let B, O, Y;
52
- const _e = () => {
50
+ }, _e = "@odus/telemetry", Re = "0.0.1";
51
+ let z, $, X;
52
+ const Be = () => {
53
53
  if (typeof navigator > "u")
54
54
  return {};
55
55
  const i = navigator.userAgent;
@@ -66,34 +66,34 @@ const _e = () => {
66
66
  viewportHeight: String(window.innerHeight),
67
67
  userAgent: i
68
68
  };
69
- }, Be = () => typeof window > "u" ? {} : { url: window.location.href }, Oe = (i) => {
70
- B = void 0, Y = void 0, O = i.sessionTracking?.session ? { id: i.sessionTracking.session.id } : void 0;
71
- }, Re = (i) => {
72
- B = i;
73
- }, Ue = () => {
74
- B = void 0;
69
+ }, Ue = () => typeof window > "u" ? {} : { url: window.location.href }, Oe = (i) => {
70
+ z = void 0, X = void 0, $ = i.sessionTracking?.session ? { id: i.sessionTracking.session.id } : void 0;
75
71
  }, He = (i) => {
76
- O = i;
77
- }, ze = (i) => {
78
- Y = i;
79
- }, $e = () => O?.id, je = (i) => ({
80
- sdk: { name: Te, version: Ve },
72
+ z = i;
73
+ }, ze = () => {
74
+ z = void 0;
75
+ }, $e = (i) => {
76
+ $ = i;
77
+ }, Ke = (i) => {
78
+ X = i;
79
+ }, qe = () => $?.id, je = (i) => ({
80
+ sdk: { name: _e, version: Re },
81
81
  app: i.app,
82
- user: B,
83
- session: O,
84
- page: Be(),
85
- browser: _e(),
86
- view: Y
87
- }), Ke = 30, qe = 250, We = 6e4;
88
- let A = [], w = null, G = 0, L = null, T = null;
89
- const Ye = (i) => {
90
- if (w)
82
+ user: z,
83
+ session: $,
84
+ page: Ue(),
85
+ browser: Be(),
86
+ view: X
87
+ }), We = 30, Ye = 250, Ge = 6e4;
88
+ let I = [], k = null, Q = 0, R = null, B = null;
89
+ const Ze = (i) => {
90
+ if (k)
91
91
  return;
92
- const e = i.batching?.sendTimeout ?? qe;
93
- w = setTimeout(() => {
94
- R(i);
92
+ const e = i.batching?.sendTimeout ?? Ye;
93
+ k = setTimeout(() => {
94
+ K(i);
95
95
  }, e);
96
- }, Ge = (i, e) => {
96
+ }, Je = (i, e) => {
97
97
  const t = {
98
98
  meta: je(e)
99
99
  };
@@ -113,8 +113,8 @@ const Ye = (i) => {
113
113
  break;
114
114
  }
115
115
  return t;
116
- }, Ze = (i, e, t = !1) => {
117
- const s = JSON.stringify(i), a = $e(), n = {
116
+ }, Xe = (i, e, t = !1) => {
117
+ const s = JSON.stringify(i), a = qe(), n = {
118
118
  "Content-Type": "application/json"
119
119
  };
120
120
  if (a && (n["x-faro-session-id"] = a), t && typeof navigator < "u" && navigator.sendBeacon) {
@@ -122,7 +122,7 @@ const Ye = (i) => {
122
122
  navigator.sendBeacon(e, o);
123
123
  return;
124
124
  }
125
- const r = s.length < We;
125
+ const r = s.length < Ge;
126
126
  fetch(e, {
127
127
  method: "POST",
128
128
  headers: n,
@@ -131,220 +131,220 @@ const Ye = (i) => {
131
131
  }).then((o) => {
132
132
  if (o.status === 429) {
133
133
  const d = o.headers.get("Retry-After"), c = d ? parseInt(d, 10) * 1e3 : 3e4;
134
- G = Date.now() + c;
134
+ Q = Date.now() + c;
135
135
  }
136
136
  }).catch(() => {
137
137
  });
138
- }, R = (i, e = !1) => {
139
- if (w && (clearTimeout(w), w = null), A.length === 0)
138
+ }, K = (i, e = !1) => {
139
+ if (k && (clearTimeout(k), k = null), I.length === 0)
140
140
  return;
141
- if (Date.now() < G) {
142
- A = [];
141
+ if (Date.now() < Q) {
142
+ I = [];
143
143
  return;
144
144
  }
145
- const t = A;
146
- A = [];
145
+ const t = I;
146
+ I = [];
147
147
  try {
148
- let s = Ge(t, i);
148
+ let s = Je(t, i);
149
149
  if (i.beforeSend) {
150
150
  const a = i.beforeSend(s);
151
151
  if (!a)
152
152
  return;
153
153
  s = a;
154
154
  }
155
- Ze(s, i.url, e);
155
+ Xe(s, i.url, e);
156
156
  } catch {
157
157
  }
158
- }, N = (i, e) => {
159
- A.push(i);
160
- const t = e.batching?.itemLimit ?? Ke;
161
- if (A.length >= t) {
162
- R(e);
158
+ }, w = (i, e) => {
159
+ I.push(i);
160
+ const t = e.batching?.itemLimit ?? We;
161
+ if (I.length >= t) {
162
+ K(e);
163
163
  return;
164
164
  }
165
- Ye(e);
166
- }, Je = (i) => {
167
- if (A = [], G = 0, w && (clearTimeout(w), w = null), typeof document > "u")
165
+ Ze(e);
166
+ }, Qe = (i) => {
167
+ if (I = [], Q = 0, k && (clearTimeout(k), k = null), typeof document > "u")
168
168
  return;
169
- L && document.removeEventListener("visibilitychange", L), T && window.removeEventListener("pagehide", T);
170
- const e = () => R(i, !0);
171
- L = () => {
169
+ R && document.removeEventListener("visibilitychange", R), B && window.removeEventListener("pagehide", B);
170
+ const e = () => K(i, !0);
171
+ R = () => {
172
172
  document.visibilityState === "hidden" && e();
173
- }, T = e, document.addEventListener("visibilitychange", L), window.addEventListener("pagehide", T);
174
- }, Q = () => (/* @__PURE__ */ new Date()).toISOString();
175
- let ee = null, te = null;
176
- const Xe = (i) => {
177
- typeof window > "u" || (ee = (e) => {
173
+ }, B = e, document.addEventListener("visibilitychange", R), window.addEventListener("pagehide", B);
174
+ }, ne = () => (/* @__PURE__ */ new Date()).toISOString();
175
+ let ie = null, ae = null;
176
+ const et = (i) => {
177
+ typeof window > "u" || (ie = (e) => {
178
178
  const t = e.error instanceof Error ? e.error : new Error(e.message);
179
- N({
179
+ w({
180
180
  type: "exception",
181
181
  payload: {
182
182
  type: t.name,
183
183
  value: t.message,
184
- timestamp: Q(),
185
- stacktrace: t.stack ? { frames: q(t.stack) } : void 0
184
+ timestamp: ne(),
185
+ stacktrace: t.stack ? { frames: Z(t.stack) } : void 0
186
186
  }
187
187
  }, i);
188
- }, te = (e) => {
188
+ }, ae = (e) => {
189
189
  const t = e.reason, s = t instanceof Error ? t : new Error(String(t));
190
- N({
190
+ w({
191
191
  type: "exception",
192
192
  payload: {
193
193
  type: s.name,
194
194
  value: s.message,
195
- timestamp: Q(),
196
- stacktrace: s.stack ? { frames: q(s.stack) } : void 0,
195
+ timestamp: ne(),
196
+ stacktrace: s.stack ? { frames: Z(s.stack) } : void 0,
197
197
  context: { source: "unhandledrejection" }
198
198
  }
199
199
  }, i);
200
- }, window.addEventListener("error", ee), window.addEventListener("unhandledrejection", te));
201
- }, se = "odus_telemetry_session_id", z = () => {
200
+ }, window.addEventListener("error", ie), window.addEventListener("unhandledrejection", ae));
201
+ }, re = "odus_telemetry_session_id", j = () => {
202
202
  const i = new Uint8Array(16);
203
203
  return crypto.getRandomValues(i), Array.from(i, (e) => e.toString(16).padStart(2, "0")).join("");
204
- }, Qe = (i) => {
204
+ }, tt = (i) => {
205
205
  if (i)
206
206
  return i;
207
207
  if (typeof sessionStorage > "u")
208
- return z();
208
+ return j();
209
209
  try {
210
- const e = sessionStorage.getItem(se);
210
+ const e = sessionStorage.getItem(re);
211
211
  if (e)
212
212
  return e;
213
- const t = z();
214
- return sessionStorage.setItem(se, t), t;
213
+ const t = j();
214
+ return sessionStorage.setItem(re, t), t;
215
215
  } catch {
216
- return z();
216
+ return j();
217
217
  }
218
- }, et = (i) => {
218
+ }, st = (i) => {
219
219
  if (!i.sessionTracking?.enabled)
220
220
  return;
221
- const e = Qe(i.sessionTracking.session?.id);
222
- He({ id: e });
223
- }, $ = () => (/* @__PURE__ */ new Date()).toISOString(), j = (i, e) => {
221
+ const e = tt(i.sessionTracking.session?.id);
222
+ $e({ id: e });
223
+ }, W = () => (/* @__PURE__ */ new Date()).toISOString(), Y = (i, e) => {
224
224
  if (typeof PerformanceObserver > "u" || !PerformanceObserver.supportedEntryTypes?.includes(i))
225
225
  return;
226
226
  new PerformanceObserver((s) => {
227
227
  for (const a of s.getEntries())
228
228
  e(a);
229
229
  }).observe({ type: i, buffered: !0 });
230
- }, tt = (i) => {
230
+ }, nt = (i) => {
231
231
  if (typeof window > "u")
232
232
  return;
233
- j("largest-contentful-paint", (t) => {
234
- N({
233
+ Y("largest-contentful-paint", (t) => {
234
+ w({
235
235
  type: "measurement",
236
236
  payload: {
237
237
  type: "web-vitals",
238
238
  values: { lcp: t.startTime },
239
- timestamp: $()
239
+ timestamp: W()
240
240
  }
241
241
  }, i);
242
242
  });
243
243
  let e = 0;
244
- j("layout-shift", (t) => {
244
+ Y("layout-shift", (t) => {
245
245
  const s = t;
246
- s.hadRecentInput || (e += s.value, N({
246
+ s.hadRecentInput || (e += s.value, w({
247
247
  type: "measurement",
248
248
  payload: {
249
249
  type: "web-vitals",
250
250
  values: { cls: e },
251
- timestamp: $()
251
+ timestamp: W()
252
252
  }
253
253
  }, i));
254
- }), j("event", (t) => {
254
+ }), Y("event", (t) => {
255
255
  const s = t;
256
- s.duration > 0 && N({
256
+ s.duration > 0 && w({
257
257
  type: "measurement",
258
258
  payload: {
259
259
  type: "web-vitals",
260
260
  values: { inp: s.duration },
261
- timestamp: $()
261
+ timestamp: W()
262
262
  }
263
263
  }, i);
264
264
  });
265
- }, _ = {
265
+ }, H = {
266
266
  INFO: "info",
267
267
  WARN: "warn",
268
268
  ERROR: "error"
269
- }, V = () => (/* @__PURE__ */ new Date()).toISOString(), st = (i) => {
270
- Oe(i), Je(i);
269
+ }, U = () => (/* @__PURE__ */ new Date()).toISOString(), it = (i) => {
270
+ Oe(i), Qe(i);
271
271
  const e = i.instrumentations ?? {
272
272
  errors: !0,
273
273
  webVitals: !0,
274
274
  session: !0
275
275
  };
276
- return e.session !== !1 && et(i), e.errors !== !1 && Xe(i), e.webVitals !== !1 && tt(i), {
276
+ return e.session !== !1 && st(i), e.errors !== !1 && et(i), e.webVitals !== !1 && nt(i), {
277
277
  pushError(t, s) {
278
- N({
278
+ w({
279
279
  type: "exception",
280
280
  payload: {
281
281
  type: t.name,
282
282
  value: t.message,
283
- timestamp: V(),
284
- stacktrace: t.stack ? { frames: q(t.stack) } : void 0,
283
+ timestamp: U(),
284
+ stacktrace: t.stack ? { frames: Z(t.stack) } : void 0,
285
285
  context: s?.context
286
286
  }
287
287
  }, i);
288
288
  },
289
289
  pushEvent(t, s) {
290
- N({
290
+ w({
291
291
  type: "event",
292
292
  payload: {
293
293
  name: t,
294
- timestamp: V(),
294
+ timestamp: U(),
295
295
  attributes: s
296
296
  }
297
297
  }, i);
298
298
  },
299
299
  pushMeasurement(t) {
300
- N({
300
+ w({
301
301
  type: "measurement",
302
302
  payload: {
303
303
  type: t.type,
304
304
  values: t.values,
305
- timestamp: V(),
305
+ timestamp: U(),
306
306
  context: t.context
307
307
  }
308
308
  }, i);
309
309
  },
310
310
  pushLog(t, s) {
311
- N({
311
+ w({
312
312
  type: "log",
313
313
  payload: {
314
314
  message: t.join(" "),
315
- level: s?.level ?? _.INFO,
316
- timestamp: V(),
315
+ level: s?.level ?? H.INFO,
316
+ timestamp: U(),
317
317
  context: s?.context
318
318
  }
319
319
  }, i);
320
320
  },
321
321
  setUser(t) {
322
- Re(t);
322
+ He(t);
323
323
  },
324
324
  resetUser() {
325
- Ue();
325
+ ze();
326
326
  },
327
327
  setView(t) {
328
- ze(t);
328
+ Ke(t);
329
329
  },
330
330
  flush() {
331
- R(i);
331
+ K(i);
332
332
  }
333
333
  };
334
- }, nt = (i) => i === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", it = () => {
334
+ }, at = (i) => i === "test" ? "https://sandbox-analytics.odus.com/collect" : "https://analytics.odus.com/collect", rt = () => {
335
335
  if (typeof window > "u")
336
336
  return !1;
337
337
  const i = window.location.hostname;
338
338
  return i === "localhost" || i === "127.0.0.1" || i === "0.0.0.0" || i === "::1" || i === "[::1]" || i.endsWith(".localhost");
339
339
  };
340
- let E = null;
341
- const at = (i) => {
342
- if (E)
343
- return E;
344
- if (it())
340
+ let C = null;
341
+ const ot = (i) => {
342
+ if (C)
343
+ return C;
344
+ if (rt())
345
345
  return null;
346
- const e = nt(i.environment);
347
- return E = st({
346
+ const e = at(i.environment);
347
+ return C = it({
348
348
  url: e,
349
349
  app: {
350
350
  name: "odus-checkout",
@@ -375,13 +375,13 @@ const at = (i) => {
375
375
  }
376
376
  return t;
377
377
  }
378
- }), E;
379
- }, rt = (i, e) => {
380
- E && E.pushError(i, { context: e });
381
- }, F = (i, e) => {
382
- E && E.pushEvent(i, e);
383
- }, ne = (i, e, t, s) => {
384
- E && E.pushMeasurement({
378
+ }), C;
379
+ }, lt = (i, e) => {
380
+ C && C.pushError(i, { context: e });
381
+ }, M = (i, e) => {
382
+ C && C.pushEvent(i, e);
383
+ }, oe = (i, e, t, s) => {
384
+ C && C.pushMeasurement({
385
385
  type: i,
386
386
  values: { [i]: e },
387
387
  context: {
@@ -389,25 +389,25 @@ const at = (i) => {
389
389
  ...s
390
390
  }
391
391
  });
392
- }, It = (i, e = "info", t) => {
393
- if (!E) return;
392
+ }, Tt = (i, e = "info", t) => {
393
+ if (!C) return;
394
394
  const s = {
395
- info: _.INFO,
396
- warn: _.WARN,
397
- error: _.ERROR
395
+ info: H.INFO,
396
+ warn: H.WARN,
397
+ error: H.ERROR
398
398
  };
399
- E.pushLog([i], {
399
+ C.pushLog([i], {
400
400
  level: s[e],
401
401
  context: t
402
402
  });
403
- }, ie = {
403
+ }, le = {
404
404
  test: "tntwpdhfwng",
405
405
  live: "TBD"
406
- }, ae = {
406
+ }, de = {
407
407
  test: "sandbox",
408
408
  live: "live"
409
409
  };
410
- class I {
410
+ class L {
411
411
  vgsForm = null;
412
412
  fields = [];
413
413
  readyResolve;
@@ -419,18 +419,18 @@ class I {
419
419
  });
420
420
  }
421
421
  async init(e) {
422
- return this.environment = e, await pe({
423
- vaultId: ie[e],
424
- environment: ae[e],
425
- version: "3.2.2"
422
+ return this.environment = e, await fe({
423
+ vaultId: le[e],
424
+ environment: de[e],
425
+ version: "3.3.0"
426
426
  });
427
427
  }
428
428
  createForm(e, t) {
429
429
  if (!this.environment)
430
430
  throw new Error("VGS not initialized — call init() first");
431
431
  return this.vgsForm = e.create(
432
- ie[this.environment],
433
- ae[this.environment],
432
+ le[this.environment],
433
+ de[this.environment],
434
434
  t
435
435
  ), this.readyResolve?.(), this.vgsForm;
436
436
  }
@@ -479,10 +479,10 @@ class I {
479
479
  luhn: !0
480
480
  }
481
481
  ],
482
- css: t
482
+ css: t.cardNumber
483
483
  });
484
484
  n.on("update", (r) => {
485
- a && a(I.mapCardType(r.cardType));
485
+ a && a(L.mapCardType(r.cardType));
486
486
  }), this.fields.push(n);
487
487
  }
488
488
  if (e.cardExpiry) {
@@ -492,7 +492,13 @@ class I {
492
492
  placeholder: s.cardExpiry,
493
493
  autoComplete: "cc-exp",
494
494
  validations: ["required", "validCardExpirationDate"],
495
- css: t
495
+ serializers: [
496
+ {
497
+ name: "separate",
498
+ options: { monthName: "month", yearName: "year" }
499
+ }
500
+ ],
501
+ css: t.cardExpiry
496
502
  }
497
503
  );
498
504
  this.fields.push(n);
@@ -502,7 +508,7 @@ class I {
502
508
  placeholder: s.cardCvv,
503
509
  autoComplete: "cc-csc",
504
510
  validations: ["required", "validCardSecurityCode"],
505
- css: t
511
+ css: t.cardCvv
506
512
  });
507
513
  this.fields.push(n);
508
514
  }
@@ -513,7 +519,7 @@ class I {
513
519
  placeholder: s.cardholderName,
514
520
  autoComplete: "cc-name",
515
521
  validations: ["required"],
516
- css: t
522
+ css: t.cardholderName
517
523
  }
518
524
  );
519
525
  this.fields.push(n);
@@ -543,7 +549,7 @@ class I {
543
549
  this.patchCard(e, o.id).then(s).catch(a);
544
550
  return;
545
551
  }
546
- s(I.extractCardResult(o));
552
+ s(L.extractCardResult(o));
547
553
  },
548
554
  (n) => {
549
555
  a(n);
@@ -586,11 +592,11 @@ class I {
586
592
  n(new Error("Card update failed: no card ID returned"));
587
593
  return;
588
594
  }
589
- const c = I.extractCardResult(d), p = o.included?.find(
595
+ const c = L.extractCardResult(d), u = o.included?.find(
590
596
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
591
- (b) => b.type === "card_updates"
597
+ (S) => S.type === "card_updates"
592
598
  );
593
- p?.attributes?.updated_values?.length && (c.updatedValues = p.attributes.updated_values), a(c);
599
+ u?.attributes?.updated_values?.length && (c.updatedValues = u.attributes.updated_values), a(c);
594
600
  },
595
601
  (r) => {
596
602
  n(r);
@@ -627,7 +633,7 @@ class I {
627
633
  }[e] ?? "unknown" : "unknown";
628
634
  }
629
635
  }
630
- function K(i) {
636
+ function G(i) {
631
637
  return {
632
638
  name: "Custom Appearance",
633
639
  additionalPaymentMethods: i.additionalPaymentMethods || {},
@@ -663,7 +669,7 @@ function K(i) {
663
669
  state: {
664
670
  enabled: i.layout?.billingFields?.state?.enabled ?? !1,
665
671
  label: i.layout?.billingFields?.state?.label,
666
- options: i.layout?.billingFields?.state?.options
672
+ hiddenForCountries: i.layout?.billingFields?.state?.hiddenForCountries
667
673
  },
668
674
  zipCode: {
669
675
  enabled: i.layout?.billingFields?.zipCode?.enabled ?? !1,
@@ -703,7 +709,7 @@ function K(i) {
703
709
  state: {
704
710
  enabled: i.layout.shippingFields.state?.enabled ?? !1,
705
711
  label: i.layout.shippingFields.state?.label,
706
- options: i.layout.shippingFields.state?.options
712
+ hiddenForCountries: i.layout.shippingFields.state?.hiddenForCountries
707
713
  },
708
714
  zipCode: {
709
715
  enabled: i.layout.shippingFields.zipCode?.enabled ?? !1,
@@ -727,16 +733,16 @@ function K(i) {
727
733
  }
728
734
  };
729
735
  }
730
- function ot({
736
+ function dt({
731
737
  appearance: i
732
738
  }) {
733
- const e = de({
739
+ const e = me({
734
740
  checkoutProfile: void 0,
735
741
  isLoading: !0,
736
742
  error: null
737
743
  });
738
744
  if (i) {
739
- const s = K(i);
745
+ const s = G(i);
740
746
  return Promise.resolve().then(() => {
741
747
  e.setState({
742
748
  checkoutProfile: s,
@@ -747,7 +753,7 @@ function ot({
747
753
  getState: e.getState.bind(e),
748
754
  subscribe: e.subscribe.bind(e),
749
755
  updateProfile: (a) => {
750
- const n = K(a);
756
+ const n = G(a);
751
757
  e.setState({
752
758
  checkoutProfile: n,
753
759
  isLoading: !1,
@@ -796,7 +802,7 @@ function ot({
796
802
  getState: e.getState.bind(e),
797
803
  subscribe: e.subscribe.bind(e),
798
804
  updateProfile: (s) => {
799
- const a = K(s);
805
+ const a = G(s);
800
806
  e.setState({
801
807
  checkoutProfile: a,
802
808
  isLoading: !1,
@@ -807,8 +813,8 @@ function ot({
807
813
  }
808
814
  };
809
815
  }
810
- const lt = () => {
811
- const i = ge(), e = de({
816
+ const ct = () => {
817
+ const i = ye(), e = me({
812
818
  formData: {
813
819
  name: "",
814
820
  email: "",
@@ -825,204 +831,223 @@ const lt = () => {
825
831
  cardCvv: !1
826
832
  },
827
833
  isValid: !1
828
- }), t = (l, g, m, u) => {
834
+ }), t = (l, p, y, m) => {
829
835
  if (l === "cardCvv")
830
- return i.cardCvv(g, m);
831
- if (l === "phoneNumber" && u)
832
- return i.phoneNumber(g, u);
833
- const f = i[l];
834
- return f?.(g);
836
+ return i.cardCvv(p, y);
837
+ if (l === "phoneNumber" && m)
838
+ return i.phoneNumber(p, m);
839
+ const g = i[l];
840
+ return g?.(p);
835
841
  }, s = (l) => {
836
- const g = {};
837
- return Object.keys(l).forEach((u) => {
838
- const f = l[u];
839
- if (f === void 0) return;
842
+ const p = {};
843
+ return Object.keys(l).forEach((m) => {
844
+ const g = l[m];
845
+ if (g === void 0) return;
840
846
  let h;
841
- u === "cardCvv" ? h = t(u, f, l.cardNumber) : u === "phoneNumber" ? h = t(
842
- u,
843
- f,
847
+ m === "cardCvv" ? h = t(m, g, l.cardNumber) : m === "phoneNumber" ? h = t(
848
+ m,
849
+ g,
844
850
  void 0,
845
851
  l.phoneCountryCode
846
- ) : h = t(u, f), h && (g[u] = h);
852
+ ) : h = t(m, g), h && (p[m] = h);
847
853
  }), [
848
854
  "billingAddress",
849
855
  "shippingAddress"
850
- ].forEach((u) => {
851
- const f = l[u];
852
- if (f && typeof f == "object") {
856
+ ].forEach((m) => {
857
+ const g = l[m];
858
+ if (g && typeof g == "object") {
853
859
  const h = {};
854
- Object.keys(f).forEach(
855
- (y) => {
856
- const v = f[y];
857
- if (v === void 0) return;
858
- const S = i[y];
859
- if (S) {
860
- const M = S(v);
861
- M && (h[y] = M);
860
+ Object.keys(g).forEach(
861
+ (b) => {
862
+ const f = g[b];
863
+ if (f === void 0) return;
864
+ const v = i[b];
865
+ if (v) {
866
+ const E = b === "state" ? i.state(f, g.country) : v(
867
+ f
868
+ );
869
+ E && (h[b] = E);
862
870
  }
863
871
  }
864
- ), Object.keys(h).length > 0 && (g[u] = h);
872
+ ), Object.keys(h).length > 0 && (p[m] = h);
865
873
  }
866
- }), g;
874
+ }), p;
867
875
  }, a = (l) => {
868
- const g = s(l);
869
- return Object.keys(g).length === 0;
876
+ const p = s(l);
877
+ return Object.keys(p).length === 0;
870
878
  }, n = "billingAddress.", r = "shippingAddress.", o = (l) => l.startsWith(n) ? {
871
879
  parent: "billingAddress",
872
880
  field: l.slice(n.length)
873
881
  } : l.startsWith(r) ? {
874
882
  parent: "shippingAddress",
875
883
  field: l.slice(r.length)
876
- } : null, d = (l, g, m, u) => {
877
- const f = { ...l };
878
- if (u)
879
- f[g] = {
880
- ...f[g],
881
- [m]: u
884
+ } : null, d = (l, p, y, m) => {
885
+ const g = { ...l };
886
+ if (m)
887
+ g[p] = {
888
+ ...g[p],
889
+ [y]: m
882
890
  };
883
891
  else {
884
892
  const h = {
885
- ...f[g]
893
+ ...g[p]
886
894
  };
887
- delete h[m], Object.keys(h).length === 0 ? delete f[g] : f[g] = h;
895
+ delete h[y], Object.keys(h).length === 0 ? delete g[p] : g[p] = h;
888
896
  }
889
- return f;
890
- }, c = (l, g) => {
891
- const m = e.getState();
892
- let u = g;
893
- const f = o(l);
894
- if (!f && l in U)
897
+ return g;
898
+ }, c = (l, p) => {
899
+ const y = e.getState();
900
+ let m = p;
901
+ const g = o(l);
902
+ if (!g && l in q)
895
903
  if (l === "cardCvv") {
896
- const S = fe(m.formData.cardNumber) === "amex" ? 4 : 3;
897
- u = U.cardCvv(g, S);
904
+ const v = be(y.formData.cardNumber) === "amex" ? 4 : 3;
905
+ m = q.cardCvv(p, v);
898
906
  } else
899
- u = U[l](g);
907
+ m = q[l](p);
900
908
  let h;
901
- if (f) {
902
- const { parent: v, field: S } = f;
909
+ if (g) {
910
+ const { parent: f, field: v } = g;
903
911
  h = {
904
- ...m.formData,
905
- [v]: {
906
- ...m.formData[v] ?? {},
907
- [S]: u
912
+ ...y.formData,
913
+ [f]: {
914
+ ...y.formData[f] ?? {},
915
+ [v]: m
908
916
  }
909
917
  };
910
918
  } else
911
919
  h = {
912
- ...m.formData,
913
- [l]: u
920
+ ...y.formData,
921
+ [l]: m
914
922
  };
915
- let y = { ...m.errors };
923
+ let b = { ...y.errors };
916
924
  if (l === "phoneCountryCode" && h.phoneNumber) {
917
- const v = t(
925
+ const f = t(
918
926
  "phoneNumber",
919
927
  h.phoneNumber,
920
928
  void 0,
921
- u
929
+ m
922
930
  );
923
- v ? y.phoneNumber = v : delete y.phoneNumber;
931
+ f ? b.phoneNumber = f : delete b.phoneNumber;
924
932
  }
925
- if (m.touched[l])
926
- if (f) {
927
- const { parent: v, field: S } = f, M = i[S], x = M ? M(
928
- u
929
- ) : void 0;
930
- y = d(y, v, S, x);
933
+ if (y.touched[l])
934
+ if (g) {
935
+ const { parent: f, field: v } = g, E = h[f];
936
+ let N;
937
+ if (v === "state")
938
+ N = i.state(m, E?.country);
939
+ else {
940
+ const x = i[v];
941
+ N = x ? x(
942
+ m
943
+ ) : void 0;
944
+ }
945
+ b = d(b, f, v, N);
931
946
  } else {
932
- let v;
933
- l === "cardCvv" ? v = t(l, u, h.cardNumber) : l === "phoneNumber" ? v = t(
947
+ let f;
948
+ l === "cardCvv" ? f = t(l, m, h.cardNumber) : l === "phoneNumber" ? f = t(
934
949
  l,
935
- u,
950
+ m,
936
951
  void 0,
937
952
  h.phoneCountryCode
938
- ) : v = t(l, u), v ? y[l] = v : delete y[l];
953
+ ) : f = t(l, m), f ? b[l] = f : delete b[l];
939
954
  }
940
955
  e.setState({
941
956
  formData: h,
942
- errors: y,
957
+ errors: b,
943
958
  isValid: a(h)
944
959
  });
945
- }, p = (l, g) => {
946
- const m = e.getState(), u = o(l);
947
- if (u) {
948
- const { parent: v, field: S } = u, M = {
949
- ...m.formData,
950
- [v]: {
951
- ...m.formData[v] ?? {},
952
- [S]: g
960
+ }, u = (l, p) => {
961
+ const y = e.getState(), m = o(l);
962
+ if (m) {
963
+ const { parent: f, field: v } = m, E = {
964
+ ...y.formData,
965
+ [f]: {
966
+ ...y.formData[f] ?? {},
967
+ [v]: p
953
968
  }
954
- }, x = i[S], ue = x ? x(g) : void 0, me = d(m.errors, v, S, ue);
969
+ };
970
+ let N;
971
+ if (v === "state") {
972
+ const V = E[f];
973
+ N = i.state(p, V?.country);
974
+ } else {
975
+ const V = i[v];
976
+ N = V ? V(p) : void 0;
977
+ }
978
+ const x = d(y.errors, f, v, N);
955
979
  e.setState({
956
- formData: M,
980
+ formData: E,
957
981
  touched: {
958
- ...m.touched,
982
+ ...y.touched,
959
983
  [l]: !0
960
984
  },
961
- errors: me,
962
- isValid: a(M)
985
+ errors: x,
986
+ isValid: a(E)
963
987
  });
964
988
  return;
965
989
  }
966
- const f = {
967
- ...m.touched,
990
+ const g = {
991
+ ...y.touched,
968
992
  [l]: !0
969
993
  };
970
994
  let h;
971
- l === "cardCvv" ? h = t(l, g, m.formData.cardNumber) : l === "phoneNumber" ? h = t(
995
+ l === "cardCvv" ? h = t(l, p, y.formData.cardNumber) : l === "phoneNumber" ? h = t(
972
996
  l,
973
- g,
997
+ p,
974
998
  void 0,
975
- m.formData.phoneCountryCode
976
- ) : h = t(l, g);
977
- const y = { ...m.errors };
978
- h ? y[l] = h : delete y[l], e.setState({
979
- touched: f,
980
- errors: y
999
+ y.formData.phoneCountryCode
1000
+ ) : h = t(l, p);
1001
+ const b = { ...y.errors };
1002
+ h ? b[l] = h : delete b[l], e.setState({
1003
+ touched: g,
1004
+ errors: b
981
1005
  });
982
- }, b = (l) => {
983
- const m = {
1006
+ }, S = (l) => {
1007
+ const y = {
984
1008
  ...e.getState().formData,
985
1009
  ...l
986
1010
  };
987
1011
  e.setState({
988
- formData: m,
989
- isValid: a(m)
1012
+ formData: y,
1013
+ isValid: a(y)
990
1014
  });
991
1015
  };
992
1016
  return {
993
1017
  getFormState: e.getState.bind(e),
994
1018
  subscribe: e.subscribe.bind(e),
995
1019
  handleChange: c,
996
- handleBlur: p,
997
- setFormData: b,
1020
+ handleBlur: u,
1021
+ setFormData: S,
998
1022
  reset: e.resetState.bind(e)
999
1023
  };
1000
- }, dt = "https://fonts.googleapis.com/css2", ct = /src:\s*url\(([^)]+\.woff2[^)]*)\)/, ht = /\/\*\s*latin\s*\*\/\s*@font-face\s*\{[^}]*src:\s*url\(([^)]+\.woff2[^)]*)\)[^}]*\}/;
1001
- async function ut(i) {
1024
+ }, ht = "https://fonts.googleapis.com/css2", ut = /src:\s*url\(([^)]+\.woff2[^)]*)\)/, mt = /\/\*\s*latin\s*\*\/\s*@font-face\s*\{[^}]*src:\s*url\(([^)]+\.woff2[^)]*)\)[^}]*\}/;
1025
+ async function pt(i) {
1002
1026
  if (!i) return null;
1003
- const e = i.trim().replace(/\s+/g, "+"), t = `${dt}?family=${e}:wght@400;700&display=swap`;
1027
+ const e = i.trim().replace(/\s+/g, "+"), t = `${ht}?family=${e}:wght@400;700&display=swap`;
1004
1028
  try {
1005
1029
  const s = await fetch(t);
1006
1030
  if (!s.ok) return null;
1007
- const a = await s.text(), n = ht.exec(a);
1031
+ const a = await s.text(), n = mt.exec(a);
1008
1032
  if (n?.[1]) return n[1];
1009
- const r = ct.exec(a);
1033
+ const r = ut.exec(a);
1010
1034
  return r?.[1] ? r[1] : null;
1011
1035
  } catch {
1012
1036
  return null;
1013
1037
  }
1014
1038
  }
1015
- function mt(i) {
1039
+ function gt(i) {
1016
1040
  if (!i) return !1;
1017
1041
  const { billingFields: e, shippingFields: t } = i, s = e && Object.values(e).some((n) => n?.enabled), a = t && Object.values(t).some((n) => n?.enabled);
1018
1042
  return !!(s || a);
1019
1043
  }
1020
- function W(i) {
1044
+ function J(i) {
1021
1045
  if (!i) return !1;
1022
1046
  const { billingFields: e, shippingFields: t } = i, s = e?.firstName?.enabled && e?.lastName?.enabled, a = t?.firstName?.enabled && t?.lastName?.enabled;
1023
1047
  return !!(s || a);
1024
1048
  }
1025
- class re extends P {
1049
+ const O = /* @__PURE__ */ new Set(["US", "CA"]);
1050
+ class ce extends A {
1026
1051
  inputs = /* @__PURE__ */ new Map();
1027
1052
  type;
1028
1053
  onChange;
@@ -1030,8 +1055,11 @@ class re extends P {
1030
1055
  fieldsContainer;
1031
1056
  translationFunc;
1032
1057
  locale;
1033
- stateOptions;
1034
1058
  grouped;
1059
+ currentCountry = "";
1060
+ stateRow = null;
1061
+ stateFieldConfig;
1062
+ stateStyles;
1035
1063
  constructor(e) {
1036
1064
  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;
1037
1065
  const { title: t, checkoutProfile: s, fieldsConfig: a, values: n, errors: r, touched: o } = e;
@@ -1064,112 +1092,113 @@ class re extends P {
1064
1092
  t.street?.enabled && d.push({ kind: "street" });
1065
1093
  const c = [];
1066
1094
  t.firstName?.enabled && c.push("firstName"), t.lastName?.enabled && c.push("lastName"), c.length > 0 && d.push({ kind: "name", fields: c }), t.country?.enabled && d.push({ kind: "country" });
1067
- const p = [];
1068
- t.city?.enabled && p.push("city"), t.zipCode?.enabled && p.push("zipCode"), p.length > 0 && d.push({ kind: "cityZip", fields: p }), t.state?.enabled && d.push({ kind: "state" });
1069
- const b = d.length;
1070
- d.forEach((l, g) => {
1071
- const m = g === 0, u = g === b - 1, f = (h, y) => ({
1095
+ const u = [];
1096
+ t.city?.enabled && u.push("city"), t.zipCode?.enabled && u.push("zipCode"), u.length > 0 && d.push({ kind: "cityZip", fields: u }), t.state?.enabled && d.push({ kind: "state" });
1097
+ const S = d.length;
1098
+ d.forEach((l, p) => {
1099
+ const y = p === 0, m = p === S - 1, g = (h, b) => ({
1072
1100
  ...o,
1073
1101
  borderRadius: this.borderRadius(
1074
1102
  r,
1075
- m && h,
1076
- m && y,
1077
- u && y,
1078
- u && h
1103
+ y && h,
1104
+ y && b,
1105
+ m && b,
1106
+ m && h
1079
1107
  )
1080
1108
  });
1081
1109
  if (l.kind === "street") {
1082
- const h = this.createRow(["full"]), y = this.createInput(
1110
+ const h = this.createRow(["full"]), b = this.createInput(
1083
1111
  "street",
1084
1112
  t.street?.label ?? this.translationFunc("address.addressLine1"),
1085
1113
  s.street,
1086
1114
  a.street,
1087
1115
  n.street,
1088
- f(!0, !0),
1116
+ g(!0, !0),
1089
1117
  "street-address"
1090
1118
  );
1091
- this.inputs.set("street", y), h.appendChild(y.getElement()), this.fieldsContainer.appendChild(h);
1119
+ this.inputs.set("street", b), h.appendChild(b.getElement()), this.fieldsContainer.appendChild(h);
1092
1120
  return;
1093
1121
  }
1094
1122
  if (l.kind === "name") {
1095
- const h = this.createRow(l.fields.map(() => "half")), y = l.fields.length === 1;
1123
+ const h = this.createRow(l.fields.map(() => "half")), b = l.fields.length === 1;
1096
1124
  if (l.fields.includes("firstName")) {
1097
- const v = y || l.fields[l.fields.length - 1] === "firstName", S = this.createInput(
1125
+ const f = b || l.fields[l.fields.length - 1] === "firstName", v = this.createInput(
1098
1126
  "firstName",
1099
1127
  t.firstName?.label ?? this.translationFunc("address.firstName"),
1100
1128
  s.firstName,
1101
1129
  a.firstName,
1102
1130
  n.firstName,
1103
- f(!0, v),
1131
+ g(!0, f),
1104
1132
  "given-name"
1105
1133
  );
1106
- this.inputs.set("firstName", S), h.appendChild(S.getElement());
1134
+ this.inputs.set("firstName", v), h.appendChild(v.getElement());
1107
1135
  }
1108
1136
  if (l.fields.includes("lastName")) {
1109
- const v = y || l.fields[0] === "lastName", S = this.createInput(
1137
+ const f = b || l.fields[0] === "lastName", v = this.createInput(
1110
1138
  "lastName",
1111
1139
  t.lastName?.label ?? this.translationFunc("address.lastName"),
1112
1140
  s.lastName,
1113
1141
  a.lastName,
1114
1142
  n.lastName,
1115
- f(v, !0),
1143
+ g(f, !0),
1116
1144
  "family-name"
1117
1145
  );
1118
- this.inputs.set("lastName", S), h.appendChild(S.getElement());
1146
+ this.inputs.set("lastName", v), h.appendChild(v.getElement());
1119
1147
  }
1120
1148
  this.fieldsContainer.appendChild(h);
1121
1149
  return;
1122
1150
  }
1123
1151
  if (l.kind === "country") {
1124
- const h = this.createRow(["full"]), y = this.createCountrySelect(
1152
+ const h = this.createRow(["full"]), b = this.createCountrySelect(
1125
1153
  s.country,
1126
1154
  a.country,
1127
1155
  n.country,
1128
- f(!0, !0),
1156
+ g(!0, !0),
1129
1157
  t.country?.options,
1130
1158
  t.country?.label
1131
1159
  );
1132
- this.inputs.set("country", y), h.appendChild(y.getElement()), this.fieldsContainer.appendChild(h);
1160
+ this.inputs.set("country", b), h.appendChild(b.getElement()), this.fieldsContainer.appendChild(h);
1133
1161
  return;
1134
1162
  }
1135
1163
  if (l.kind === "cityZip") {
1136
- const h = this.createRow(l.fields.map(() => "half")), y = l.fields.length === 1;
1164
+ const h = this.createRow(l.fields.map(() => "half")), b = l.fields.length === 1;
1137
1165
  if (l.fields.includes("city")) {
1138
- const v = y || l.fields[l.fields.length - 1] === "city", S = this.createInput(
1166
+ const f = b || l.fields[l.fields.length - 1] === "city", v = this.createInput(
1139
1167
  "city",
1140
1168
  t.city?.label ?? this.translationFunc("address.townCity"),
1141
1169
  s.city,
1142
1170
  a.city,
1143
1171
  n.city,
1144
- f(!0, v),
1172
+ g(!0, f),
1145
1173
  "address-level2"
1146
1174
  );
1147
- this.inputs.set("city", S), h.appendChild(S.getElement());
1175
+ this.inputs.set("city", v), h.appendChild(v.getElement());
1148
1176
  }
1149
1177
  if (l.fields.includes("zipCode")) {
1150
- const v = y || l.fields[0] === "zipCode", S = this.createInput(
1178
+ const f = b || l.fields[0] === "zipCode", v = this.createInput(
1151
1179
  "zipCode",
1152
1180
  t.zipCode?.label ?? this.translationFunc("address.postalCode"),
1153
1181
  s.zipCode,
1154
1182
  a.zipCode,
1155
1183
  n.zipCode,
1156
- f(v, !0),
1184
+ g(f, !0),
1157
1185
  "postal-code"
1158
1186
  );
1159
- this.inputs.set("zipCode", S), h.appendChild(S.getElement());
1187
+ this.inputs.set("zipCode", v), h.appendChild(v.getElement());
1160
1188
  }
1161
1189
  this.fieldsContainer.appendChild(h);
1162
1190
  return;
1163
1191
  }
1164
1192
  if (l.kind === "state") {
1165
1193
  const h = this.createRow(["full"]);
1166
- if (this.stateOptions = t.state?.options, t.state?.options && t.state.options.length > 0) {
1194
+ if (this.stateFieldConfig = t.state, this.stateRow = h, this.stateStyles = g(!0, !0), this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
1195
+ s.country
1196
+ ) && (h.style.display = "none"), O.has(s.country)) {
1167
1197
  const v = this.createStateSelect(
1168
1198
  s.state,
1169
1199
  a.state,
1170
1200
  n.state,
1171
- f(!0, !0),
1172
- t.state?.options,
1201
+ this.stateStyles,
1173
1202
  s.country,
1174
1203
  t.state?.label
1175
1204
  );
@@ -1177,11 +1206,11 @@ class re extends P {
1177
1206
  } else {
1178
1207
  const v = this.createInput(
1179
1208
  "state",
1180
- t.state?.label ?? this.translationFunc("address.chooseState"),
1209
+ t.state?.label ?? this.translationFunc("address.state"),
1181
1210
  s.state,
1182
1211
  a.state,
1183
1212
  n.state,
1184
- f(!0, !0),
1213
+ this.stateStyles,
1185
1214
  "address-level1"
1186
1215
  );
1187
1216
  this.inputs.set("state", v), h.appendChild(v.getElement());
@@ -1195,7 +1224,7 @@ class re extends P {
1195
1224
  return t.className = `address-row address-row-${e.length === 1 ? "single" : "double"}`, t;
1196
1225
  }
1197
1226
  createInput(e, t, s, a, n, r, o) {
1198
- const d = `${this.type}Address.${e}`, c = new ce({
1227
+ const d = `${this.type}Address.${e}`, c = new pe({
1199
1228
  name: d,
1200
1229
  error: !1,
1201
1230
  errorMsg: void 0,
@@ -1203,37 +1232,38 @@ class re extends P {
1203
1232
  ...this.grouped ? { placeholder: t } : {
1204
1233
  label: t,
1205
1234
  placeholder: (() => {
1206
- const p = `address.placeholder.${e}`, b = this.translationFunc(p);
1207
- return b !== p ? b : t;
1235
+ const u = `address.placeholder.${e}`, S = this.translationFunc(u);
1236
+ return S !== u ? S : t;
1208
1237
  })()
1209
1238
  },
1210
1239
  value: s,
1211
1240
  autocomplete: o,
1212
- onChange: (p) => {
1213
- c.setError(!1);
1214
- const b = new Event("input", { bubbles: !0 });
1215
- Object.defineProperty(b, "target", {
1216
- writable: !1,
1217
- value: {
1218
- name: d,
1219
- value: p.target.value
1220
- }
1221
- }), this.onChange(b);
1241
+ onChange: (u) => {
1242
+ c.setError(!1), this.onChange(
1243
+ P({
1244
+ type: "input",
1245
+ target: {
1246
+ name: d,
1247
+ value: u.target.value
1248
+ }
1249
+ })
1250
+ );
1222
1251
  }
1223
1252
  });
1224
- return c.addEventListener("blur", (p) => {
1225
- const b = new Event("blur", { bubbles: !0 });
1226
- Object.defineProperty(b, "target", {
1227
- writable: !1,
1228
- value: {
1229
- name: d,
1230
- value: p.target.value
1231
- }
1232
- }), this.onBlur(b);
1253
+ return c.addEventListener("blur", (u) => {
1254
+ this.onBlur(
1255
+ P({
1256
+ type: "blur",
1257
+ target: {
1258
+ name: d,
1259
+ value: u.target.value
1260
+ }
1261
+ })
1262
+ );
1233
1263
  }), c;
1234
1264
  }
1235
1265
  createCountrySelect(e, t, s, a, n, r) {
1236
- const o = `${this.type}Address.country`, d = ye(n, this.locale), c = new H({
1266
+ const o = `${this.type}Address.country`, d = ve(n, this.locale), c = new _({
1237
1267
  name: o,
1238
1268
  error: !1,
1239
1269
  errorMsg: void 0,
@@ -1245,70 +1275,126 @@ class re extends P {
1245
1275
  value: e,
1246
1276
  options: d,
1247
1277
  autocomplete: "country",
1248
- onChange: (p) => {
1278
+ onChange: (u) => {
1249
1279
  c.setError(!1);
1250
- const b = p.target.value;
1251
- this.updateStateOptionsForCountry(b);
1252
- const l = new Event("change", { bubbles: !0 });
1253
- Object.defineProperty(l, "target", {
1254
- writable: !1,
1255
- value: {
1256
- name: o,
1257
- value: b
1258
- }
1259
- }), this.onChange(l);
1280
+ const S = u.target.value;
1281
+ this.onChange(
1282
+ P({
1283
+ type: "change",
1284
+ target: { name: o, value: S }
1285
+ })
1286
+ ), this.handleCountryChange(S);
1260
1287
  }
1261
1288
  });
1262
- return c.addEventListener("blur", (p) => {
1263
- const b = new Event("blur", { bubbles: !0 });
1264
- Object.defineProperty(b, "target", {
1265
- writable: !1,
1266
- value: {
1267
- name: o,
1268
- value: p.target.value
1269
- }
1270
- }), this.onBlur(b);
1289
+ return c.addEventListener("blur", (u) => {
1290
+ this.onBlur(
1291
+ P({
1292
+ type: "blur",
1293
+ target: {
1294
+ name: o,
1295
+ value: u.target.value
1296
+ }
1297
+ })
1298
+ );
1271
1299
  }), c;
1272
1300
  }
1273
- updateStateOptionsForCountry(e) {
1301
+ handleCountryChange(e) {
1302
+ const t = this.currentCountry;
1303
+ if (this.currentCountry = e, !this.stateRow || !this.stateFieldConfig?.enabled) return;
1304
+ const s = this.stateFieldConfig.hiddenForCountries?.includes(t), a = this.stateFieldConfig.hiddenForCountries?.includes(e);
1305
+ if (a && !s) {
1306
+ this.stateRow.style.display = "none", this.clearStateValue();
1307
+ return;
1308
+ }
1309
+ if (!a && s && (this.stateRow.style.display = ""), a) return;
1310
+ const n = this.inputs.get("state") instanceof _, r = O.has(e);
1311
+ if (n && r) {
1312
+ const o = this.inputs.get("state");
1313
+ if (o instanceof _) {
1314
+ const d = e === "CA" ? "CA" : "US", c = ee(d), u = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1315
+ o.setOptions(c, u);
1316
+ }
1317
+ this.clearStateValue();
1318
+ return;
1319
+ }
1320
+ if (n !== r) {
1321
+ this.rebuildStateField(e), this.clearStateValue();
1322
+ return;
1323
+ }
1324
+ !n && !r && t !== e && this.clearStateValue();
1325
+ }
1326
+ rebuildStateField(e) {
1327
+ if (!this.stateRow || !this.stateStyles) return;
1274
1328
  const t = this.inputs.get("state");
1275
- if (!(t instanceof H)) return;
1276
- const s = e === "CA" ? "CA" : "US", a = Z(this.stateOptions, s), n = s === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState");
1277
- t.setOptions(a, n);
1329
+ if (t && (t.getElement().remove(), this.inputs.delete("state")), O.has(e)) {
1330
+ const a = this.createStateSelect(
1331
+ "",
1332
+ void 0,
1333
+ void 0,
1334
+ this.stateStyles,
1335
+ e,
1336
+ this.stateFieldConfig?.label
1337
+ );
1338
+ this.inputs.set("state", a), this.stateRow.appendChild(a.getElement());
1339
+ } else {
1340
+ const a = this.createInput(
1341
+ "state",
1342
+ this.stateFieldConfig?.label ?? this.translationFunc("address.state"),
1343
+ "",
1344
+ void 0,
1345
+ void 0,
1346
+ this.stateStyles,
1347
+ "address-level1"
1348
+ );
1349
+ this.inputs.set("state", a), this.stateRow.appendChild(a.getElement());
1350
+ }
1278
1351
  }
1279
- createStateSelect(e, t, s, a, n, r, o) {
1280
- const d = `${this.type}Address.state`, c = r === "CA" ? "CA" : "US", p = Z(n, c), b = c === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), l = new H({
1281
- name: d,
1352
+ clearStateValue() {
1353
+ const e = this.inputs.get("state");
1354
+ e && e.setValue("");
1355
+ const t = `${this.type}Address.state`;
1356
+ this.onChange(
1357
+ P({
1358
+ type: "input",
1359
+ target: { name: t, value: "" },
1360
+ detail: { programmatic: !0 }
1361
+ })
1362
+ );
1363
+ }
1364
+ createStateSelect(e, t, s, a, n, r) {
1365
+ const o = `${this.type}Address.state`, d = n === "CA" ? "CA" : "US", c = ee(d), u = d === "CA" ? this.translationFunc("address.chooseProvince") : this.translationFunc("address.chooseState"), S = new _({
1366
+ name: o,
1282
1367
  error: !1,
1283
1368
  errorMsg: void 0,
1284
1369
  styles: a,
1285
- placeholder: b,
1286
- ...!this.grouped && { label: o ?? b },
1370
+ placeholder: u,
1371
+ ...!this.grouped && { label: r ?? u },
1287
1372
  value: e,
1288
- options: p,
1373
+ options: c,
1289
1374
  autocomplete: "address-level1",
1290
- onChange: (g) => {
1291
- l.setError(!1);
1292
- const m = new Event("change", { bubbles: !0 });
1293
- Object.defineProperty(m, "target", {
1294
- writable: !1,
1295
- value: {
1296
- name: d,
1297
- value: g.target.value
1298
- }
1299
- }), this.onChange(m);
1375
+ onChange: (l) => {
1376
+ S.setError(!1), this.onChange(
1377
+ P({
1378
+ type: "change",
1379
+ target: {
1380
+ name: o,
1381
+ value: l.target.value
1382
+ }
1383
+ })
1384
+ );
1300
1385
  }
1301
1386
  });
1302
- return l.addEventListener("blur", (g) => {
1303
- const m = new Event("blur", { bubbles: !0 });
1304
- Object.defineProperty(m, "target", {
1305
- writable: !1,
1306
- value: {
1307
- name: d,
1308
- value: g.target.value
1309
- }
1310
- }), this.onBlur(m);
1311
- }), l;
1387
+ return S.addEventListener("blur", (l) => {
1388
+ this.onBlur(
1389
+ P({
1390
+ type: "blur",
1391
+ target: {
1392
+ name: o,
1393
+ value: l.target.value
1394
+ }
1395
+ })
1396
+ );
1397
+ }), S;
1312
1398
  }
1313
1399
  createUngroupedFields(e, t, s, a, n) {
1314
1400
  const r = e.styles.borderRadius, o = {
@@ -1316,21 +1402,21 @@ class re extends P {
1316
1402
  fontSize: e.styles.fontSize,
1317
1403
  fontFamily: e.styles.fontFamily,
1318
1404
  borderRadius: `${r}px`
1319
- }, d = (c, p, b) => {
1405
+ }, d = (c, u, S) => {
1320
1406
  if (!t[c]?.enabled) return;
1321
- const l = t[c]?.label ?? this.translationFunc(p), g = this.createRow(["full"]), m = this.createInput(
1407
+ const l = t[c]?.label ?? this.translationFunc(u), p = this.createRow(["full"]), y = this.createInput(
1322
1408
  c,
1323
1409
  l,
1324
1410
  s[c],
1325
1411
  a[c],
1326
1412
  n[c],
1327
1413
  o,
1328
- b
1414
+ S
1329
1415
  );
1330
- this.inputs.set(c, m), g.appendChild(m.getElement()), this.fieldsContainer.appendChild(g);
1416
+ this.inputs.set(c, y), p.appendChild(y.getElement()), this.fieldsContainer.appendChild(p);
1331
1417
  };
1332
1418
  if (d("firstName", "address.firstName", "given-name"), d("lastName", "address.lastName", "family-name"), d("street", "address.addressLine1", "street-address"), d("city", "address.townCity", "address-level2"), t.country?.enabled) {
1333
- const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), p = this.createRow(["full"]), b = this.createCountrySelect(
1419
+ const c = t.country?.label ?? this.translationFunc("address.chooseCountry"), u = this.createRow(["full"]), S = this.createCountrySelect(
1334
1420
  s.country,
1335
1421
  a.country,
1336
1422
  n.country,
@@ -1338,33 +1424,36 @@ class re extends P {
1338
1424
  t.country?.options,
1339
1425
  c
1340
1426
  );
1341
- this.inputs.set("country", b), p.appendChild(b.getElement()), this.fieldsContainer.appendChild(p);
1427
+ this.inputs.set("country", S), u.appendChild(S.getElement()), this.fieldsContainer.appendChild(u);
1342
1428
  }
1343
1429
  if (t.state?.enabled) {
1344
- this.stateOptions = t.state?.options;
1345
- const c = this.createRow(["full"]), p = t.state?.options && t.state.options.length > 0, b = t.state?.label ?? this.translationFunc("address.chooseState");
1346
- if (p) {
1347
- const l = this.createStateSelect(
1430
+ this.stateFieldConfig = t.state;
1431
+ const c = this.createRow(["full"]);
1432
+ this.stateRow = c, this.stateStyles = o, this.currentCountry = s.country, t.state?.hiddenForCountries?.includes(
1433
+ s.country
1434
+ ) && (c.style.display = "none");
1435
+ const S = O.has(s.country), l = t.state?.label ?? this.translationFunc("address.state");
1436
+ if (S) {
1437
+ const p = this.createStateSelect(
1348
1438
  s.state,
1349
1439
  a.state,
1350
1440
  n.state,
1351
1441
  o,
1352
- t.state?.options,
1353
1442
  s.country,
1354
- b
1443
+ l
1355
1444
  );
1356
- this.inputs.set("state", l), c.appendChild(l.getElement());
1445
+ this.inputs.set("state", p), c.appendChild(p.getElement());
1357
1446
  } else {
1358
- const l = this.createInput(
1447
+ const p = this.createInput(
1359
1448
  "state",
1360
- b,
1449
+ l,
1361
1450
  s.state,
1362
1451
  a.state,
1363
1452
  n.state,
1364
1453
  o,
1365
1454
  "address-level1"
1366
1455
  );
1367
- this.inputs.set("state", l), c.appendChild(l.getElement());
1456
+ this.inputs.set("state", p), c.appendChild(p.getElement());
1368
1457
  }
1369
1458
  this.fieldsContainer.appendChild(c);
1370
1459
  }
@@ -1401,12 +1490,11 @@ class re extends P {
1401
1490
  }
1402
1491
  updateField(e, t, s, a) {
1403
1492
  const n = this.inputs.get(e);
1404
- if (n) {
1405
- const o = n.getElement().querySelector("input") || n.getElement().querySelector("select"), d = n.getValue();
1406
- !(document.activeElement === o) && !(t === "" && d !== "") && this.setValue(e, t);
1407
- }
1408
- const r = !!(a && s);
1409
- this.setError(e, r, s);
1493
+ if (!n) return;
1494
+ const r = n.getElement().querySelector("input") || n.getElement().querySelector("select"), o = n.getValue();
1495
+ !(document.activeElement === r) && !(t === "" && o !== "") && this.setValue(e, t);
1496
+ const u = !!(a && s);
1497
+ this.setError(e, u, s);
1410
1498
  }
1411
1499
  updateAllFields(e, t, s) {
1412
1500
  Object.keys(e).forEach((a) => {
@@ -1423,13 +1511,14 @@ class re extends P {
1423
1511
  e && e.focus();
1424
1512
  }
1425
1513
  }
1426
- class pt {
1514
+ class ft {
1427
1515
  input = null;
1428
1516
  isVgsMode;
1429
1517
  vgsWrapper = null;
1430
1518
  vgsContainer = null;
1431
1519
  vgsHelperText = null;
1432
1520
  wrapperElement;
1521
+ _vgsFieldsReady = !1;
1433
1522
  constructor(e) {
1434
1523
  const {
1435
1524
  value: t,
@@ -1455,12 +1544,12 @@ class pt {
1455
1544
  const s = e.styles.borderRadius, a = document.createElement("div");
1456
1545
  a.style.marginBottom = "4px";
1457
1546
  const n = document.createElement("label");
1458
- n.className = "input-label", n.textContent = t("cardholderNameLabel"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), this.wrapperElement.appendChild(a), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${s}px`, this.vgsWrapper.style.height = "38.5px", this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden", this.vgsWrapper.style.background = "#fff", this.vgsWrapper.style.boxShadow = "none";
1547
+ n.className = "input-label", n.textContent = t("cardholderNameLabel"), n.style.fontFamily = `"${e.styles.fontFamily}", sans-serif`, a.appendChild(n), this.wrapperElement.appendChild(a), this.vgsWrapper = document.createElement("div"), this.vgsWrapper.className = "vgs-wrap", this.vgsWrapper.style.position = "relative", this.vgsWrapper.style.borderRadius = `${s}px`, this.vgsWrapper.style.height = "38.5px", this.vgsWrapper.style.width = "100%", this.vgsWrapper.style.overflow = "hidden";
1459
1548
  const r = document.createElement("div");
1460
- r.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(r), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new be({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
1549
+ r.className = "vgs-field-skeleton", this.vgsWrapper.appendChild(r), this.vgsContainer = document.createElement("div"), this.vgsContainer.id = `vgs-cc-name-${Date.now()}`, this.vgsContainer.style.position = "relative", this.vgsContainer.style.zIndex = "1", this.vgsContainer.style.width = "100%", this.vgsContainer.style.height = "100%", this.vgsWrapper.appendChild(this.vgsContainer), this.wrapperElement.appendChild(this.vgsWrapper), this.vgsHelperText = new Se({ visible: !1 }), this.wrapperElement.appendChild(this.vgsHelperText.getElement());
1461
1550
  }
1462
1551
  buildNativeLayout(e, t, s, a, n, r, o) {
1463
- this.input = new ce({
1552
+ this.input = new pe({
1464
1553
  name: "name",
1465
1554
  label: r("cardholderNameLabel"),
1466
1555
  error: !1,
@@ -1475,8 +1564,8 @@ class pt {
1475
1564
  value: e,
1476
1565
  autocomplete: o,
1477
1566
  onChange: (d) => {
1478
- const p = d.target.value, b = p.replace(/[^a-zA-Z\s\-'.]/g, "");
1479
- p !== b && this.input?.setValue(b), this.input?.setError(!1), this.trim(), t(d);
1567
+ const u = d.target.value, S = u.replace(/[^a-zA-Z\s\-'.]/g, "");
1568
+ u !== S && this.input?.setValue(S), this.input?.setError(!1), this.trim(), t(d);
1480
1569
  }
1481
1570
  }), this.input.addEventListener("blur", (d) => {
1482
1571
  s(d);
@@ -1487,16 +1576,16 @@ class pt {
1487
1576
  }
1488
1577
  handleVgsStateChange(e, t) {
1489
1578
  if (!this.isVgsMode || !this.vgsWrapper) return;
1490
- const a = !!e[J.CARDHOLDER]?.isFocused;
1491
- if (this.vgsWrapper.classList.toggle("vgs-wrap-focused", a), !t || !this.vgsHelperText) return;
1492
- const n = t[J.CARDHOLDER];
1493
- n ? (this.vgsHelperText.setText(n), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
1579
+ const s = e[te.CARDHOLDER]?.isFocused;
1580
+ if (this._vgsFieldsReady && (this.vgsWrapper.style.boxShadow = s ? "0 0 0 1px rgba(50, 151, 211, 0.7), 0 1px 1px 0 rgba(0, 0, 0, 0.07), 0 0 0 4px rgba(50, 151, 211, 0.3)" : "0 0 0 1px #e0e0e0, 0 2px 4px 0 rgba(0,0,0,0.07), 0 1px 1.5px 0 rgba(0,0,0,0.05)"), !t || !this.vgsHelperText) return;
1581
+ const a = t[te.CARDHOLDER];
1582
+ a ? (this.vgsHelperText.setText(a), this.vgsHelperText.toggleVisibility(!0)) : this.vgsHelperText.toggleVisibility(!1);
1494
1583
  }
1495
1584
  hideFakePlaceholder() {
1496
1585
  if (!this.vgsWrapper) return;
1497
- this.vgsWrapper.style.boxShadow = "";
1586
+ this._vgsFieldsReady = !0, this.vgsWrapper.style.overflow = "visible", this.vgsWrapper.style.transition = "box-shadow 0.1s ease-in", this.vgsWrapper.style.boxShadow = "0 0 0 1px #e0e0e0, 0 2px 4px 0 rgba(0,0,0,0.07), 0 1px 1.5px 0 rgba(0,0,0,0.05)";
1498
1587
  const e = this.vgsWrapper.querySelector(".vgs-field-skeleton");
1499
- e && e.remove();
1588
+ e && e.remove(), this.vgsContainer?.querySelectorAll("iframe").forEach((t) => t.style.height = "38.5px");
1500
1589
  }
1501
1590
  getValue() {
1502
1591
  return this.isVgsMode ? "" : this.input?.getValue() ?? "";
@@ -1524,7 +1613,7 @@ class pt {
1524
1613
  this.isVgsMode || this.input?.focus();
1525
1614
  }
1526
1615
  }
1527
- class he extends P {
1616
+ class ge extends A {
1528
1617
  constructor() {
1529
1618
  super("div", ["skeleton-container"]), this.createSkeletonElements();
1530
1619
  }
@@ -1532,23 +1621,23 @@ class he extends P {
1532
1621
  this.appendChild(this.createPaymentMethodSkeleton()), this.appendChild(this.createPaymentSeparatorSkeleton());
1533
1622
  }
1534
1623
  createPaymentMethodSkeleton() {
1535
- const e = k.createDiv(["skeleton-field"]), t = k.createDiv([
1624
+ const e = D.createDiv(["skeleton-field"]), t = D.createDiv([
1536
1625
  "skeleton",
1537
1626
  "skeleton-payment-method"
1538
1627
  ]);
1539
1628
  return e.appendChild(t), e;
1540
1629
  }
1541
1630
  createPaymentSeparatorSkeleton() {
1542
- const e = k.createDiv([
1631
+ const e = D.createDiv([
1543
1632
  "payment-separator_container"
1544
- ]), t = k.createDiv(["payment-separator__line"]), s = k.createDiv([
1633
+ ]), t = D.createDiv(["payment-separator__line"]), s = D.createDiv([
1545
1634
  "skeleton",
1546
1635
  "skeleton-separator-text"
1547
- ]), a = k.createDiv(["payment-separator__line"]);
1636
+ ]), a = D.createDiv(["payment-separator__line"]);
1548
1637
  return e.appendChild(t), e.appendChild(s), e.appendChild(a), e;
1549
1638
  }
1550
1639
  }
1551
- class gt extends P {
1640
+ class yt extends A {
1552
1641
  constructor(e) {
1553
1642
  const { translationFunc: t, checkoutProfile: s } = e;
1554
1643
  super("div", ["payment-separator"]);
@@ -1560,7 +1649,7 @@ class gt extends P {
1560
1649
  o.className = "payment-separator__line", a.appendChild(n), a.appendChild(r), a.appendChild(o);
1561
1650
  }
1562
1651
  }
1563
- class ft extends P {
1652
+ class bt extends A {
1564
1653
  paymentMethods;
1565
1654
  paymentSeparator;
1566
1655
  skeleton;
@@ -1574,8 +1663,8 @@ class ft extends P {
1574
1663
  translationFunc: o,
1575
1664
  paymentId: d,
1576
1665
  checkoutKey: c,
1577
- checkoutDetails: p,
1578
- environment: b,
1666
+ checkoutDetails: u,
1667
+ environment: S,
1579
1668
  countryCode: l
1580
1669
  } = e;
1581
1670
  if (super("div", ["payment-methods"]), this.paymentMethods = /* @__PURE__ */ new Map(), !t?.additionalPaymentMethods) {
@@ -1586,44 +1675,44 @@ class ft extends P {
1586
1675
  this.renderSkeleton();
1587
1676
  return;
1588
1677
  }
1589
- const g = Object.entries(
1678
+ const p = Object.entries(
1590
1679
  t.additionalPaymentMethods
1591
- ).filter(([m, u]) => {
1592
- const f = u.enabled, h = r ? r[m] === !0 : !0, y = !u.countries || l && u.countries.includes(l);
1593
- return f && h && y;
1594
- }).sort((m, u) => m[1].order - u[1].order);
1595
- if (g.length === 0) {
1680
+ ).filter(([y, m]) => {
1681
+ const g = m.enabled, h = r ? r[y] === !0 : !0, b = !m.countries || l && m.countries.includes(l);
1682
+ return g && h && b;
1683
+ }).sort((y, m) => y[1].order - m[1].order);
1684
+ if (p.length === 0) {
1596
1685
  this.getElement().style.display = "none";
1597
1686
  return;
1598
1687
  }
1599
- for (const [m] of g)
1600
- switch (m) {
1688
+ for (const [y] of p)
1689
+ switch (y) {
1601
1690
  case "paypal": {
1602
1691
  if (a) {
1603
- const u = new Se({
1692
+ const m = new Ee({
1604
1693
  checkoutProfile: t,
1605
1694
  formData: s,
1606
1695
  onSubmit: a
1607
1696
  });
1608
- this.paymentMethods.set("paypal", u), u.appendTo(this.getElement());
1697
+ this.paymentMethods.set("paypal", m), m.appendTo(this.getElement());
1609
1698
  }
1610
1699
  break;
1611
1700
  }
1612
1701
  case "applePay": {
1613
1702
  if (n && d && c) {
1614
- const u = t.appearance?.additionalPaymentMethods?.applePay, f = new ve({
1703
+ const m = t.appearance?.additionalPaymentMethods?.applePay, g = new Ce({
1615
1704
  checkoutProfile: t,
1616
1705
  formData: s,
1617
1706
  onSubmit: n,
1618
1707
  paymentId: d,
1619
1708
  checkoutKey: c,
1620
- checkoutDetails: p,
1621
- environment: b,
1622
- displayName: u?.displayName,
1623
- requiredBillingContactFields: u?.requiredBillingContactFields,
1624
- requiredShippingContactFields: u?.requiredShippingContactFields
1709
+ checkoutDetails: u,
1710
+ environment: S,
1711
+ displayName: m?.displayName,
1712
+ requiredBillingContactFields: m?.requiredBillingContactFields,
1713
+ requiredShippingContactFields: m?.requiredShippingContactFields
1625
1714
  });
1626
- this.paymentMethods.set("applePay", f), f.appendTo(this.getElement());
1715
+ this.paymentMethods.set("applePay", g), g.appendTo(this.getElement());
1627
1716
  }
1628
1717
  break;
1629
1718
  }
@@ -1635,17 +1724,17 @@ class ft extends P {
1635
1724
  // break;
1636
1725
  default:
1637
1726
  console.warn(
1638
- `[PaymentMethods] Unsupported payment method: ${m}`
1727
+ `[PaymentMethods] Unsupported payment method: ${y}`
1639
1728
  );
1640
1729
  break;
1641
1730
  }
1642
- this.paymentMethods.size > 0 && (this.paymentSeparator = new gt({
1731
+ this.paymentMethods.size > 0 && (this.paymentSeparator = new yt({
1643
1732
  translationFunc: o,
1644
1733
  checkoutProfile: t
1645
1734
  }), this.getElement().appendChild(this.paymentSeparator.getElement()));
1646
1735
  }
1647
1736
  renderSkeleton() {
1648
- this.skeleton = new he(), this.getElement().appendChild(this.skeleton.getElement());
1737
+ this.skeleton = new ge(), this.getElement().appendChild(this.skeleton.getElement());
1649
1738
  }
1650
1739
  updateFormData(e) {
1651
1740
  const t = this.paymentMethods.get("paypal");
@@ -1657,8 +1746,8 @@ class ft extends P {
1657
1746
  return this.paymentMethods.size > 0 && this.getElement().style.display !== "none";
1658
1747
  }
1659
1748
  }
1660
- const yt = 17;
1661
- class bt extends P {
1749
+ const vt = 17;
1750
+ class St extends A {
1662
1751
  styles;
1663
1752
  isHovered = !1;
1664
1753
  constructor(e) {
@@ -1668,7 +1757,7 @@ class bt extends P {
1668
1757
  }
1669
1758
  applyStyles() {
1670
1759
  const e = this.getElement();
1671
- 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 === yt ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
1760
+ 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 === vt ? "100vmax" : `${this.styles.borderRadius}px`, e.style.fontSize = `${this.styles.fontSize}px`, e.style.fontFamily = `${this.styles.fontFamily}, sans-serif`;
1672
1761
  }
1673
1762
  handleMouseEnter() {
1674
1763
  this.isHovered = !0, this.applyStyles();
@@ -1680,11 +1769,11 @@ class bt extends P {
1680
1769
  return this.getElement().disabled = e, e ? (this.addClass("disabled"), this.removeClass("valid")) : (this.removeClass("disabled"), this.addClass("valid")), this.applyStyles(), this;
1681
1770
  }
1682
1771
  }
1683
- class vt {
1772
+ class Ct {
1684
1773
  button;
1685
1774
  constructor(e) {
1686
1775
  const { disabled: t, checkoutProfile: s, translationFunc: a } = e;
1687
- this.button = new bt({
1776
+ this.button = new St({
1688
1777
  text: a(
1689
1778
  `buttonTexts.${s?.layout.actionButton.translationKey}`
1690
1779
  ),
@@ -1711,7 +1800,7 @@ class vt {
1711
1800
  return this.button.appendTo(e), this;
1712
1801
  }
1713
1802
  }
1714
- class St {
1803
+ class Et {
1715
1804
  formElement;
1716
1805
  focusManager;
1717
1806
  translationFunc;
@@ -1757,7 +1846,7 @@ class St {
1757
1846
  (a) => a.enabled
1758
1847
  ))
1759
1848
  return;
1760
- this.paymentMethods = new ft({
1849
+ this.paymentMethods = new bt({
1761
1850
  checkoutProfile: e,
1762
1851
  formData: t,
1763
1852
  supportedPaymentMethods: this.supportedPaymentMethods,
@@ -1784,7 +1873,7 @@ class St {
1784
1873
  ) || e.layout.shippingFields && Object.values(e.layout.shippingFields).some(
1785
1874
  (r) => r?.enabled
1786
1875
  );
1787
- this.emailField = new Ee({
1876
+ this.emailField = new Fe({
1788
1877
  value: t.email,
1789
1878
  onChange: this.onChange,
1790
1879
  onBlur: this.onBlur,
@@ -1802,7 +1891,7 @@ class St {
1802
1891
  }
1803
1892
  createPhoneNumberField(e, t, s, a) {
1804
1893
  const n = document.createElement("div");
1805
- this.phonePlaceholder = n, this.formElement.appendChild(n), Ce().then(({ PhoneNumberField: r }) => {
1894
+ this.phonePlaceholder = n, this.formElement.appendChild(n), Me().then(({ PhoneNumberField: r }) => {
1806
1895
  n.isConnected && (this.phoneNumberField = new r({
1807
1896
  value: t.phoneNumber ?? "",
1808
1897
  onChange: this.onChange,
@@ -1829,7 +1918,7 @@ class St {
1829
1918
  this.cardSectionSkeleton = this.buildCardSkeleton(e), this.formElement.appendChild(this.cardSectionSkeleton);
1830
1919
  return;
1831
1920
  }
1832
- if (this.cardSection = new Fe({
1921
+ if (this.cardSection = new Ne({
1833
1922
  checkoutProfile: e,
1834
1923
  cardNumber: t.cardNumber,
1835
1924
  cardNumberError: s.cardNumber,
@@ -1843,13 +1932,12 @@ class St {
1843
1932
  onChange: this.onChange,
1844
1933
  onBlur: this.onBlur,
1845
1934
  onCardBrandChange: () => {
1846
- if (t.cardCvv) {
1847
- const n = new Event("blur", { bubbles: !0 });
1848
- Object.defineProperty(n, "target", {
1849
- writable: !1,
1850
- value: { name: "cardCvv", value: t.cardCvv }
1851
- }), this.onBlur(n);
1852
- }
1935
+ t.cardCvv && this.onBlur(
1936
+ P({
1937
+ type: "blur",
1938
+ target: { name: "cardCvv", value: t.cardCvv }
1939
+ })
1940
+ );
1853
1941
  },
1854
1942
  translationFunc: this.translationFunc,
1855
1943
  vgsService: this.vgsService,
@@ -1885,7 +1973,7 @@ class St {
1885
1973
  this.cardholderSectionSkeleton = this.buildCardholderSkeleton(e), this.formElement.appendChild(this.cardholderSectionSkeleton);
1886
1974
  return;
1887
1975
  }
1888
- if (this.cardholderSection = new pt({
1976
+ if (this.cardholderSection = new ft({
1889
1977
  value: t.name,
1890
1978
  onChange: this.onChange,
1891
1979
  onBlur: this.onBlur,
@@ -1918,7 +2006,7 @@ class St {
1918
2006
  zipCode: "",
1919
2007
  country: ""
1920
2008
  };
1921
- this.billingAddressSection = new re({
2009
+ this.billingAddressSection = new ce({
1922
2010
  type: "billing",
1923
2011
  title: this.translationFunc("address.billingTitle"),
1924
2012
  checkoutProfile: e,
@@ -1951,7 +2039,7 @@ class St {
1951
2039
  zipCode: "",
1952
2040
  country: ""
1953
2041
  };
1954
- this.shippingAddressSection = new re({
2042
+ this.shippingAddressSection = new ce({
1955
2043
  type: "shipping",
1956
2044
  title: this.translationFunc("address.shippingTitle"),
1957
2045
  checkoutProfile: e,
@@ -1971,7 +2059,7 @@ class St {
1971
2059
  }
1972
2060
  createSubmitButton(e, t) {
1973
2061
  try {
1974
- this.submitButton = new vt({
2062
+ this.submitButton = new Ct({
1975
2063
  disabled: t,
1976
2064
  checkoutProfile: e,
1977
2065
  translationFunc: this.translationFunc
@@ -2040,8 +2128,8 @@ class St {
2040
2128
  d.style.display = "flex", d.style.gap = "8px";
2041
2129
  const c = document.createElement("div");
2042
2130
  c.style.position = "relative", c.style.flex = "1", c.style.height = "38.5px", c.style.overflow = "hidden", c.style.borderRadius = `${t}px`, c.appendChild(this.createSkeletonDiv()), d.appendChild(c);
2043
- const p = document.createElement("div");
2044
- return p.style.position = "relative", p.style.flex = "1", p.style.height = "38.5px", p.style.overflow = "hidden", p.style.borderRadius = `${t}px`, p.appendChild(this.createSkeletonDiv()), d.appendChild(p), r.appendChild(d), s.appendChild(r), s;
2131
+ const u = document.createElement("div");
2132
+ return u.style.position = "relative", u.style.flex = "1", u.style.height = "38.5px", u.style.overflow = "hidden", u.style.borderRadius = `${t}px`, u.appendChild(this.createSkeletonDiv()), d.appendChild(u), r.appendChild(d), s.appendChild(r), s;
2045
2133
  }
2046
2134
  createSkeletonDiv() {
2047
2135
  const e = document.createElement("div");
@@ -2058,7 +2146,7 @@ class St {
2058
2146
  async mountVgsFields(e) {
2059
2147
  if (!this.vgsService || !this.cardSection) return;
2060
2148
  await this.vgsService.whenReady();
2061
- const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await ut(
2149
+ const t = this.cardSection.getVgsContainerIds(), s = this.cardholderSection?.getVgsContainerId(), a = await pt(
2062
2150
  e.styles.fontFamily
2063
2151
  ), n = this.cardSection.buildVgsFieldCss(
2064
2152
  e,
@@ -2118,7 +2206,7 @@ class St {
2118
2206
  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);
2119
2207
  }
2120
2208
  }
2121
- class Et {
2209
+ class Ft {
2122
2210
  formManager;
2123
2211
  focusManager;
2124
2212
  onFormSubmit;
@@ -2129,9 +2217,9 @@ class Et {
2129
2217
  }
2130
2218
  handleChange = (e) => {
2131
2219
  const t = e.target, { name: s, value: a } = t, n = s;
2132
- this.formManager.handleChange(n, a), this.localTouchedFields.has(n) || (this.localTouchedFields.add(n), this.formManager.handleBlur(n, a));
2133
- const { formData: r, errors: o, touched: d } = this.formManager.getFormState();
2134
- this.focusManager.handleStateUpdate(r, o, d);
2220
+ this.formManager.handleChange(n, a), e instanceof CustomEvent && e.detail?.programmatic ? this.localTouchedFields.delete(n) : this.localTouchedFields.has(n) || (this.localTouchedFields.add(n), this.formManager.handleBlur(n, a));
2221
+ const { formData: o, errors: d, touched: c } = this.formManager.getFormState();
2222
+ this.focusManager.handleStateUpdate(o, d, c);
2135
2223
  };
2136
2224
  handleBlur = (e) => {
2137
2225
  const t = e.target, { name: s, value: a } = t, n = s;
@@ -2159,7 +2247,7 @@ class Et {
2159
2247
  this.localTouchedFields.clear();
2160
2248
  }
2161
2249
  }
2162
- class Ct {
2250
+ class Mt {
2163
2251
  formManager;
2164
2252
  checkoutProfile;
2165
2253
  formElement;
@@ -2183,7 +2271,7 @@ class Ct {
2183
2271
  try {
2184
2272
  if (e.checkoutProfile.styles?.fontFamily)
2185
2273
  try {
2186
- const { cleanup: t } = Me({
2274
+ const { cleanup: t } = we({
2187
2275
  fontFamily: e.checkoutProfile.styles.fontFamily
2188
2276
  });
2189
2277
  this.fontCleanup = t, this.formElement.style.fontFamily = e.checkoutProfile.styles.fontFamily;
@@ -2200,15 +2288,17 @@ class Ct {
2200
2288
  };
2201
2289
  isFormDisabled() {
2202
2290
  const e = this.formManager.getFormState(), t = this.checkoutProfile.getState(), s = Object.keys(e.errors).filter(
2203
- (y) => y !== "billingAddress" && y !== "shippingAddress"
2204
- ).length > 0, a = e.errors.billingAddress, n = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || n || o, p = W(
2291
+ (f) => f !== "billingAddress" && f !== "shippingAddress"
2292
+ ).length > 0, a = e.errors.billingAddress, n = a && typeof a == "object" ? Object.keys(a).length > 0 : !1, r = e.errors.shippingAddress, o = r && typeof r == "object" ? Object.keys(r).length > 0 : !1, d = s || n || o, u = J(
2205
2293
  t.checkoutProfile?.layout
2206
- ) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: g, shippingFields: m } = t.checkoutProfile?.layout ?? {}, u = (y, v) => !y || Object.entries(y).every(
2207
- ([S, M]) => !M?.enabled || !!v?.[S]?.trim()
2208
- ), f = !this.isVgsMode || Object.values(this.vgsFieldsState).every(
2209
- (y) => y?.isValid === !0
2210
- ), h = this.isVgsMode ? !!e.formData.email && l && f && u(g, e.formData.billingAddress) && u(m, e.formData.shippingAddress) : !!e.formData.email && l && p && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && u(g, e.formData.billingAddress) && u(m, e.formData.shippingAddress);
2211
- return d || !h || this.isSubmitting;
2294
+ ) ? !!(e.formData.billingAddress?.firstName || e.formData.billingAddress?.lastName || e.formData.shippingAddress?.firstName || e.formData.shippingAddress?.lastName) : !!e.formData.name, l = t.checkoutProfile?.layout.phoneNumber?.enabled ?? !1 ? !!e.formData.phoneNumber : !0, { billingFields: p, shippingFields: y } = t.checkoutProfile?.layout ?? {}, m = /* @__PURE__ */ new Set(["US", "CA"]), g = (f, v) => {
2295
+ if (!f) return !0;
2296
+ const E = v?.country ?? "";
2297
+ return Object.entries(f).every(([N, x]) => !x?.enabled || N === "state" && (!m.has(E) || x.hiddenForCountries?.includes(E)) ? !0 : !!v?.[N]?.trim());
2298
+ }, h = !this.isVgsMode || Object.values(this.vgsFieldsState).every(
2299
+ (f) => f?.isValid === !0
2300
+ ), b = this.isVgsMode ? !!e.formData.email && l && h && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress) : !!e.formData.email && l && u && !!e.formData.cardNumber && !!e.formData.cardCvv && !!e.formData.cardExpiry && g(p, e.formData.billingAddress) && g(y, e.formData.shippingAddress);
2301
+ return d || !b || this.isSubmitting;
2212
2302
  }
2213
2303
  setSubmitting(e) {
2214
2304
  this.isSubmitting = e;
@@ -2226,7 +2316,7 @@ class Ct {
2226
2316
  continue;
2227
2317
  const n = a.errors?.[0];
2228
2318
  if (!n) continue;
2229
- const r = Ne(s, n.code);
2319
+ const r = Pe(s, n.code);
2230
2320
  r && (t[s] = e(r));
2231
2321
  }
2232
2322
  return t;
@@ -2238,18 +2328,18 @@ class Ct {
2238
2328
  this.fontCleanup && (this.fontCleanup(), this.fontCleanup = void 0);
2239
2329
  }
2240
2330
  }
2241
- class Ft extends P {
2331
+ class Nt extends A {
2242
2332
  titleElement;
2243
2333
  constructor(e = {}) {
2244
2334
  super("div", ["blur-bg"]);
2245
- const t = k.createDiv(["loader"]);
2246
- this.titleElement = new P("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
2335
+ const t = D.createDiv(["loader"]);
2336
+ this.titleElement = new A("h3", ["title"]), this.titleElement.setText(e.text || ""), this.appendChild(t), this.appendChild(this.titleElement);
2247
2337
  }
2248
2338
  setText(e) {
2249
2339
  return this.titleElement.setText(e), this;
2250
2340
  }
2251
2341
  }
2252
- const oe = {
2342
+ const he = {
2253
2343
  street: "",
2254
2344
  firstName: "",
2255
2345
  lastName: "",
@@ -2257,7 +2347,7 @@ const oe = {
2257
2347
  city: "",
2258
2348
  zipCode: "",
2259
2349
  country: ""
2260
- }, le = (i, e) => {
2350
+ }, ue = (i, e) => {
2261
2351
  const t = {}, s = `${e}.`;
2262
2352
  return Object.keys(i).forEach((a) => {
2263
2353
  if (a.startsWith(s)) {
@@ -2266,7 +2356,7 @@ const oe = {
2266
2356
  }
2267
2357
  }), t;
2268
2358
  };
2269
- class Mt {
2359
+ class wt {
2270
2360
  formElement;
2271
2361
  componentManager;
2272
2362
  onLoadingStateChange;
@@ -2300,13 +2390,13 @@ class Mt {
2300
2390
  !!(e.errors.name && e.touched.name),
2301
2391
  e.errors.name
2302
2392
  ), this.componentManager.updateBillingAddressSection(
2303
- e.formData.billingAddress ?? oe,
2393
+ e.formData.billingAddress ?? he,
2304
2394
  e.errors.billingAddress ?? {},
2305
- le(e.touched, "billingAddress")
2395
+ ue(e.touched, "billingAddress")
2306
2396
  ), this.componentManager.updateShippingAddressSection(
2307
- e.formData.shippingAddress ?? oe,
2397
+ e.formData.shippingAddress ?? he,
2308
2398
  e.errors.shippingAddress ?? {},
2309
- le(e.touched, "shippingAddress")
2399
+ ue(e.touched, "shippingAddress")
2310
2400
  ), this.componentManager.updateSubmitButton(t);
2311
2401
  }
2312
2402
  setLoadingState(e) {
@@ -2314,10 +2404,10 @@ class Mt {
2314
2404
  this.onLoadingStateChange(e);
2315
2405
  return;
2316
2406
  }
2317
- e ? (this.hideSkeleton(), this.formSkeleton = new he(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
2407
+ e ? (this.hideSkeleton(), this.formSkeleton = new ge(), this.formElement.appendChild(this.formSkeleton.getElement())) : this.hideSkeleton();
2318
2408
  }
2319
2409
  showSpinner(e) {
2320
- this.hideSpinner(), this.spinner = new Ft({ text: e }), this.formElement.appendChild(this.spinner.getElement());
2410
+ this.hideSpinner(), this.spinner = new Nt({ text: e }), this.formElement.appendChild(this.spinner.getElement());
2321
2411
  }
2322
2412
  hideSpinner() {
2323
2413
  this.spinner && (this.spinner.getElement().remove(), this.spinner = void 0);
@@ -2326,7 +2416,7 @@ class Mt {
2326
2416
  this.formSkeleton && (this.formSkeleton.getElement().remove(), this.formSkeleton = void 0);
2327
2417
  }
2328
2418
  setErrorMessage(e) {
2329
- this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new we({ message: e }), this.formElement.insertBefore(
2419
+ this.alert && (this.alert.getElement().remove(), this.alert = void 0), this.alert = new ke({ message: e }), this.formElement.insertBefore(
2330
2420
  this.alert.getElement(),
2331
2421
  this.formElement.firstChild
2332
2422
  );
@@ -2338,7 +2428,7 @@ class Mt {
2338
2428
  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);
2339
2429
  }
2340
2430
  }
2341
- const D = (i) => ({
2431
+ const T = (i) => ({
2342
2432
  street: "",
2343
2433
  firstName: "",
2344
2434
  lastName: "",
@@ -2348,12 +2438,12 @@ const D = (i) => ({
2348
2438
  country: "",
2349
2439
  ...i
2350
2440
  });
2351
- class Nt extends P {
2441
+ class Pt extends A {
2352
2442
  options;
2353
- formManager = lt();
2443
+ formManager = ct();
2354
2444
  checkoutProfile;
2355
- translation = Pe();
2356
- focusManager = new ke();
2445
+ translation = Ae();
2446
+ focusManager = new xe();
2357
2447
  // Managers
2358
2448
  componentManager;
2359
2449
  eventHandler;
@@ -2364,9 +2454,9 @@ class Nt extends P {
2364
2454
  vgsJwt;
2365
2455
  vgsCardResult;
2366
2456
  constructor(e) {
2367
- super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new I()), this.checkoutProfile = ot({
2457
+ super("form", ["form-container"]), this.options = e, this.vgsJwt = e.vgsJwt, this.vgsJwt && (this.vgsService = new L()), this.checkoutProfile = dt({
2368
2458
  appearance: e.appearance
2369
- }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new St({
2459
+ }), e.locale && this.translation.setLocale(e.locale), this.componentManager = new Et({
2370
2460
  formElement: this.element,
2371
2461
  focusManager: this.focusManager,
2372
2462
  translationFunc: this.translation.t,
@@ -2383,11 +2473,11 @@ class Nt extends P {
2383
2473
  environment: e.environment,
2384
2474
  vgsService: this.vgsService,
2385
2475
  onVgsStateChange: (t) => this.handleVgsStateChange(t)
2386
- }), this.uiManager = new Mt({
2476
+ }), this.uiManager = new wt({
2387
2477
  formElement: this.element,
2388
2478
  componentManager: this.componentManager,
2389
2479
  onLoadingStateChange: e.onLoadingStateChange
2390
- }), this.stateCoordinator = new Ct({
2480
+ }), this.stateCoordinator = new Mt({
2391
2481
  formManager: this.formManager,
2392
2482
  checkoutProfile: this.checkoutProfile,
2393
2483
  componentManager: this.componentManager,
@@ -2397,7 +2487,7 @@ class Nt extends P {
2397
2487
  onError: (t) => this.uiManager.setErrorMessage(t),
2398
2488
  onLoadingChange: (t) => this.uiManager.setLoadingState(t),
2399
2489
  getInitialFormData: () => this._getFormStateData().formData
2400
- }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Et({
2490
+ }), this.vgsService && this.stateCoordinator.setVgsMode(!0), this.eventHandler = new Ft({
2401
2491
  formManager: this.formManager,
2402
2492
  focusManager: this.focusManager,
2403
2493
  onFormSubmit: async () => this.handleSubmit(),
@@ -2422,12 +2512,12 @@ class Nt extends P {
2422
2512
  },
2423
2513
  ...e.initialValues.name && { name: e.initialValues.name },
2424
2514
  ...e.initialValues.billingAddress && {
2425
- billingAddress: D(
2515
+ billingAddress: T(
2426
2516
  e.initialValues.billingAddress
2427
2517
  )
2428
2518
  },
2429
2519
  ...e.initialValues.shippingAddress && {
2430
- shippingAddress: D(
2520
+ shippingAddress: T(
2431
2521
  e.initialValues.shippingAddress
2432
2522
  )
2433
2523
  }
@@ -2444,10 +2534,10 @@ class Nt extends P {
2444
2534
  cardNumber: "",
2445
2535
  cardCvv: "",
2446
2536
  ...t?.billingAddress && {
2447
- billingAddress: D(t.billingAddress)
2537
+ billingAddress: T(t.billingAddress)
2448
2538
  },
2449
2539
  ...t?.shippingAddress && {
2450
- shippingAddress: D(t.shippingAddress)
2540
+ shippingAddress: T(t.shippingAddress)
2451
2541
  }
2452
2542
  },
2453
2543
  errors: e.errors || {},
@@ -2474,11 +2564,11 @@ class Nt extends P {
2474
2564
  phoneNumber: "",
2475
2565
  phoneCountryCode: e.checkoutProfile.layout.phoneNumber.defaultCountry?.toUpperCase() || "US"
2476
2566
  }), e.checkoutProfile.layout.billingFields && this.formManager.getFormState().formData.billingAddress === void 0 && this.formManager.setFormData({
2477
- billingAddress: D()
2567
+ billingAddress: T()
2478
2568
  }), e.checkoutProfile.layout.shippingFields && this.formManager.getFormState().formData.shippingAddress === void 0 && this.formManager.setFormData({
2479
- shippingAddress: D()
2569
+ shippingAddress: T()
2480
2570
  });
2481
- const { formData: t, errors: s, touched: a } = this._getFormStateData(), n = mt(
2571
+ const { formData: t, errors: s, touched: a } = this._getFormStateData(), n = gt(
2482
2572
  e.checkoutProfile.layout
2483
2573
  );
2484
2574
  try {
@@ -2542,7 +2632,7 @@ class Nt extends P {
2542
2632
  } catch (o) {
2543
2633
  console.error("Failed to create card section:", o);
2544
2634
  }
2545
- if (!W(
2635
+ if (!J(
2546
2636
  e.checkoutProfile.layout
2547
2637
  ))
2548
2638
  try {
@@ -2580,7 +2670,7 @@ class Nt extends P {
2580
2670
  */
2581
2671
  inferCardholderName() {
2582
2672
  const e = this.checkoutProfile.getState();
2583
- if (!e.checkoutProfile || !W(
2673
+ if (!e.checkoutProfile || !J(
2584
2674
  e.checkoutProfile.layout
2585
2675
  )) return;
2586
2676
  const { formData: s } = this._getFormStateData(), a = s.billingAddress ?? s.shippingAddress;
@@ -2688,7 +2778,7 @@ class Nt extends P {
2688
2778
  ), this.componentManager.cleanup(), this.uiManager.cleanup(), this.getElement().remove();
2689
2779
  }
2690
2780
  associatePayment(e, t, s, a, n) {
2691
- this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), n && !this.vgsService && (this.vgsJwt = n, this.vgsService = new I(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
2781
+ this.options.paymentId = e, this.options.checkoutKey = t, this.options.supportedPaymentMethods = s, this.options.checkoutDetails = a, this.componentManager.setCheckoutDetailsLoaded(!0), n && !this.vgsService && (this.vgsJwt = n, this.vgsService = new L(), this.componentManager.setVgsService(this.vgsService), this.stateCoordinator.setVgsMode(!0), this.vgsService.init(this.options.environment).then((o) => {
2692
2782
  this.vgsService?.createForm(
2693
2783
  o,
2694
2784
  (d) => this.handleVgsStateChange(d)
@@ -2713,7 +2803,7 @@ class Nt extends P {
2713
2803
  }
2714
2804
  }
2715
2805
  }
2716
- class wt {
2806
+ class kt {
2717
2807
  container = null;
2718
2808
  options;
2719
2809
  onSubmit;
@@ -2737,7 +2827,7 @@ class wt {
2737
2827
  }
2738
2828
  }
2739
2829
  renderForm(e) {
2740
- this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new Nt({
2830
+ this.container && (this.form && (this.form.destroy(), this.form = null), this.form = new Pt({
2741
2831
  apiKey: this.options.apiKey,
2742
2832
  onSubmit: this.onSubmit,
2743
2833
  locale: this.options.locale,
@@ -2774,7 +2864,7 @@ class wt {
2774
2864
  );
2775
2865
  }
2776
2866
  }
2777
- class Pt {
2867
+ class At {
2778
2868
  state;
2779
2869
  listeners = /* @__PURE__ */ new Set();
2780
2870
  constructor(e) {
@@ -2796,8 +2886,8 @@ class Pt {
2796
2886
  this.listeners.forEach((t) => t(e));
2797
2887
  }
2798
2888
  }
2799
- const kt = "en";
2800
- class At {
2889
+ const xt = "en";
2890
+ class Dt {
2801
2891
  config;
2802
2892
  paymentState;
2803
2893
  apiService;
@@ -2805,18 +2895,18 @@ class At {
2805
2895
  stateManager;
2806
2896
  sessionId;
2807
2897
  constructor(e) {
2808
- this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), at({
2898
+ this.config = this.validateConfig(e), this.paymentState = {}, this.sessionId = crypto.randomUUID(), ot({
2809
2899
  environment: this.config.environment,
2810
2900
  sessionId: this.sessionId
2811
- }), F(C.CHECKOUT_INITIALIZED, {
2901
+ }), M(F.CHECKOUT_INITIALIZED, {
2812
2902
  environment: this.config.environment
2813
- }), this.apiService = new Ae(
2903
+ }), this.apiService = new De(
2814
2904
  this.config.apiKey,
2815
2905
  this.config.environment
2816
- ), this.stateManager = new Pt({
2906
+ ), this.stateManager = new At({
2817
2907
  mounted: !1,
2818
2908
  form: null
2819
- }), this.formManager = new wt(
2909
+ }), this.formManager = new kt(
2820
2910
  {
2821
2911
  locale: this.config.locale,
2822
2912
  apiKey: this.config.apiKey,
@@ -2838,7 +2928,7 @@ class At {
2838
2928
  apiKey: e.apiKey,
2839
2929
  returnUrl: e.returnUrl,
2840
2930
  environment: e.environment,
2841
- locale: e.locale || kt,
2931
+ locale: e.locale || xt,
2842
2932
  disableErrorMessages: e.disableErrorMessages ?? !1,
2843
2933
  manualActionHandling: e.manualActionHandling ?? !1,
2844
2934
  appearance: e.appearance,
@@ -2859,7 +2949,7 @@ class At {
2859
2949
  return t.appendChild(s), this.stateManager.updateState({
2860
2950
  form: s,
2861
2951
  mounted: !0
2862
- }), this.formManager.mount(s), F(C.CHECKOUT_MOUNTED, {
2952
+ }), this.formManager.mount(s), M(F.CHECKOUT_MOUNTED, {
2863
2953
  container_id: e
2864
2954
  }), this;
2865
2955
  }
@@ -2871,7 +2961,7 @@ class At {
2871
2961
  t && t.remove(), this.stateManager.updateState({
2872
2962
  form: null,
2873
2963
  mounted: !1
2874
- }), F(C.CHECKOUT_UNMOUNTED);
2964
+ }), M(F.CHECKOUT_UNMOUNTED);
2875
2965
  });
2876
2966
  }
2877
2967
  async handleSubmit({
@@ -2883,7 +2973,7 @@ class At {
2883
2973
  "Payment must be associated before submitting. Call associatePayment() first."
2884
2974
  );
2885
2975
  const s = this.getPaymentMethod(e, t);
2886
- F(C.PAYMENT_SUBMIT_STARTED, {
2976
+ M(F.PAYMENT_SUBMIT_STARTED, {
2887
2977
  payment_id: this.paymentState.paymentId,
2888
2978
  payment_method: s
2889
2979
  });
@@ -2896,8 +2986,8 @@ class At {
2896
2986
  returnUrl: this.config.returnUrl,
2897
2987
  applePayData: t
2898
2988
  }), r = performance.now() - a;
2899
- ne(
2900
- X.PAYMENT_AUTHORIZATION_TIME,
2989
+ oe(
2990
+ se.PAYMENT_AUTHORIZATION_TIME,
2901
2991
  r,
2902
2992
  "ms",
2903
2993
  {
@@ -2905,14 +2995,14 @@ class At {
2905
2995
  payment_method: s,
2906
2996
  status: "success"
2907
2997
  }
2908
- ), F(C.PAYMENT_SUBMIT_SUCCESS, {
2998
+ ), M(F.PAYMENT_SUBMIT_SUCCESS, {
2909
2999
  payment_id: this.paymentState.paymentId,
2910
3000
  payment_method: s
2911
3001
  }), this.handlePaymentResponse(n);
2912
3002
  } catch (n) {
2913
3003
  const r = performance.now() - a;
2914
- ne(
2915
- X.PAYMENT_AUTHORIZATION_TIME,
3004
+ oe(
3005
+ se.PAYMENT_AUTHORIZATION_TIME,
2916
3006
  r,
2917
3007
  "ms",
2918
3008
  {
@@ -2920,7 +3010,7 @@ class At {
2920
3010
  payment_method: s,
2921
3011
  status: "failed"
2922
3012
  }
2923
- ), F(C.PAYMENT_SUBMIT_FAILED, {
3013
+ ), M(F.PAYMENT_SUBMIT_FAILED, {
2924
3014
  payment_id: this.paymentState.paymentId,
2925
3015
  payment_method: s,
2926
3016
  error_message: n.details?.message ?? "Unknown error"
@@ -2928,17 +3018,17 @@ class At {
2928
3018
  }
2929
3019
  }
2930
3020
  handlePaymentResponse(e) {
2931
- if (e.latestTransaction.status === "authorized" && (F(C.PAYMENT_AUTHORIZED, {
3021
+ if (e.latestTransaction.status === "authorized" && (M(F.PAYMENT_AUTHORIZED, {
2932
3022
  payment_id: this.paymentState.paymentId ?? "",
2933
3023
  status: e.latestTransaction.status
2934
3024
  }), this.config.callbacks.onPaymentSucceeded?.(
2935
3025
  e.latestTransaction.status
2936
- )), e.latestTransaction.status === "failed" && (F(C.PAYMENT_FAILED, {
3026
+ )), e.latestTransaction.status === "failed" && (M(F.PAYMENT_FAILED, {
2937
3027
  payment_id: this.paymentState.paymentId ?? "",
2938
3028
  status: e.latestTransaction.status
2939
3029
  }), this.config.callbacks.onPaymentFailed?.(e.latestTransaction.status)), e.status === "requires_action") {
2940
3030
  const { redirectUrl: t } = e.action;
2941
- F(C.PAYMENT_ACTION_REQUIRED, {
3031
+ M(F.PAYMENT_ACTION_REQUIRED, {
2942
3032
  payment_id: this.paymentState.paymentId ?? "",
2943
3033
  status: e.status
2944
3034
  }), this.config.manualActionHandling ? this.config.callbacks.onActionRequired?.(t) : globalThis.location.href = t;
@@ -2978,7 +3068,7 @@ class At {
2978
3068
  throw new Error("paymentId and checkoutKey are required");
2979
3069
  this.paymentState.paymentId = e, this.paymentState.checkoutKey = t;
2980
3070
  try {
2981
- const s = await De({
3071
+ const s = await Ie({
2982
3072
  id: e,
2983
3073
  checkoutKey: t,
2984
3074
  environment: this.config.environment
@@ -3008,35 +3098,35 @@ class At {
3008
3098
  a,
3009
3099
  this.paymentState.checkoutDetails,
3010
3100
  s.vgsJwt
3011
- ), F(C.PAYMENT_ASSOCIATED, {
3101
+ ), M(F.PAYMENT_ASSOCIATED, {
3012
3102
  payment_id: e,
3013
3103
  currency: s.currency,
3014
3104
  country_code: s.countryCode
3015
3105
  });
3016
3106
  } catch (s) {
3017
- throw F(C.PAYMENT_ASSOCIATION_FAILED, {
3107
+ throw M(F.PAYMENT_ASSOCIATION_FAILED, {
3018
3108
  payment_id: e,
3019
3109
  error_message: s instanceof Error ? s.message : "Unknown error"
3020
- }), rt(
3110
+ }), lt(
3021
3111
  s instanceof Error ? s : new Error("Failed to associate payment"),
3022
3112
  { payment_id: e }
3023
3113
  ), s;
3024
3114
  }
3025
3115
  }
3026
3116
  }
3027
- typeof globalThis < "u" && (globalThis.OdusCheckout = At);
3117
+ typeof globalThis < "u" && (globalThis.OdusCheckout = Dt);
3028
3118
  export {
3029
- At as OdusCheckout,
3030
- Tt as deLocale,
3031
- Vt as enLocale,
3032
- _t as esLocale,
3033
- Bt as frLocale,
3119
+ Dt as OdusCheckout,
3120
+ _t as deLocale,
3121
+ Rt as enLocale,
3122
+ Bt as esLocale,
3123
+ Ut as frLocale,
3034
3124
  Ot as itLocale,
3035
- Rt as plLocale,
3036
- Ut as ptLocale,
3037
- rt as pushError,
3038
- F as pushEvent,
3039
- It as pushLog,
3040
- ne as pushMeasurement,
3041
- Ht as trLocale
3125
+ Ht as plLocale,
3126
+ zt as ptLocale,
3127
+ lt as pushError,
3128
+ M as pushEvent,
3129
+ Tt as pushLog,
3130
+ oe as pushMeasurement,
3131
+ $t as trLocale
3042
3132
  };