@odus/checkout 1.4.0 → 1.5.0

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,1751 +1,1319 @@
1
- import { m as a, I as g, S as E, w as z, x, a as N, F as V, C as k, n as _, t as P, J as F, V as y, z as w, s as A, E as R, A as C, P as M, G as T, T as I, b as B, v as L, j } from "./shared.js";
2
- const p = ".form-helper-text{color:#dc2727;font-family:var(--odus-font-family, inherit);font-size:12px;font-weight:500;margin-top:4px;display:block;overflow:hidden;max-height:100px;transition:max-height .3s ease-in-out,opacity .3s ease-in-out,margin .3s ease-in-out}.form-helper-text-hidden{max-height:0;opacity:0;margin-top:0;overflow:hidden}", f = ".input-wrapper{display:flex;flex-direction:column;width:100%;min-width:0;box-sizing:border-box;align-items:stretch}.input-wrapper *{box-sizing:border-box}.form-input{opacity:1;font-size:var(--odus-input-font-size, 16px);font-weight:var(--odus-input-font-weight, 400);letter-spacing:var(--odus-input-letter-spacing, .02em);transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px var(--odus-border-color, #e0e0e0),0 2px 4px #00000012,0 1px 1.5px #0000000d;background:var(--odus-color-background, #fff);padding:var(--odus-input-padding, 8px 12px);border:none;outline:none;line-height:var(--odus-input-line-height, 1.5);z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%}.form-input[name=cardNumber]{padding-right:100px}.form-input-error{color:#dc2727}.form-input::placeholder{color:var(--odus-input-placeholder-color, #717173);opacity:var(--odus-input-placeholder-opacity, .3)}.form-input:focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;position:relative;z-index:2}", m = ".input-label{font-family:var(--odus-font-family, inherit);font-size:var(--odus-label-font-size, 14px);font-weight:var(--odus-label-font-weight, 400);color:var(--odus-label-color, var(--odus-color-text, #1a1a1a));letter-spacing:var(--odus-label-letter-spacing, normal);line-height:var(--odus-label-line-height, 1.4);margin-bottom:var(--odus-label-margin-bottom, 6px)}", O = ":host{--odus-font-family: system-ui, sans-serif;--odus-font-size: 16px;--odus-color-error: #dc2727;--odus-color-text: #1a1a1a;--odus-color-background: #ffffff;--odus-border-color: #e0e0e0;--odus-border-radius: 6px;--odus-spacing-sm: 8px;--odus-spacing-md: 16px;--odus-spacing-lg: 24px;--odus-input-height: 44px;--odus-input-padding: 8px 12px;--odus-input-font-size: var(--odus-font-size);--odus-input-font-weight: 400;--odus-input-letter-spacing: .02em;--odus-input-line-height: 1.5;--odus-input-placeholder-color: #717173;--odus-input-placeholder-opacity: .3;--odus-input-focus-shadow: 0 0 0 1px rgba(50, 151, 211, .7), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 0 4px rgba(50, 151, 211, .3);--odus-label-font-size: 14px;--odus-label-font-weight: 400;--odus-label-color: var(--odus-color-text);--odus-label-letter-spacing: normal;--odus-label-line-height: 1.4;--odus-label-margin-bottom: 6px;--odus-card-gap: 12px;--odus-button-height: 48px;--odus-button-border-radius: var(--odus-border-radius)}.form-input{opacity:1;font-weight:var(--odus-input-font-weight, 400);letter-spacing:var(--odus-input-letter-spacing, .02em);transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px var(--odus-border-color, #e0e0e0),0 2px 4px #00000012,0 1px 1.5px #0000000d;background:var(--odus-color-background, #fff);padding:var(--odus-input-padding, 8px 12px);border:none;outline:none;line-height:var(--odus-input-line-height, 1.5);z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%}.form-input::placeholder{color:var(--odus-input-placeholder-color, #717173);opacity:var(--odus-input-placeholder-opacity, .3)}.form-input:focus{box-shadow:var( --odus-input-focus-shadow, 0 0 0 1px rgba(50, 151, 211, .7), 0 1px 1px 0 rgba(0, 0, 0, .07), 0 0 0 4px rgba(50, 151, 211, .3) );position:relative;z-index:2}.input-label{font-family:var(--odus-font-family, inherit)!important;font-size:var(--odus-label-font-size, 14px)!important;font-weight:var(--odus-label-font-weight, 400)!important;color:var(--odus-label-color, var(--odus-color-text, #1a1a1a))!important;letter-spacing:var(--odus-label-letter-spacing, normal)!important;line-height:var(--odus-label-line-height, 1.4)!important;margin-bottom:var(--odus-label-margin-bottom, 6px)!important}.form-helper-text{font-family:var(--odus-font-family, inherit)!important}";
3
- class u {
4
- shadowRoot = null;
5
- host = null;
6
- options = {};
7
- listeners = /* @__PURE__ */ new Map();
8
- get isMounted() {
9
- return this.host !== null;
10
- }
11
- mount(e) {
12
- this.isMounted && this.unmount();
13
- const t = typeof e == "string" ? document.querySelector(e) : e;
14
- if (!t)
15
- throw new Error(
16
- `[BaseElement] mount target not found: ${String(e)}`
17
- );
18
- this.host = document.createElement("div"), this.shadowRoot = this.host.attachShadow({ mode: "open" });
19
- const r = document.createElement("style");
20
- r.textContent = this.getCss(), this.shadowRoot.appendChild(r), t.appendChild(this.host), this.render(), this.emit("ready");
21
- }
22
- unmount() {
23
- this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null;
24
- }
25
- destroy() {
26
- this.unmount(), this.listeners.clear();
27
- }
28
- on(e, t) {
29
- const r = this.listeners.get(e) ?? [];
30
- return r.push(t), this.listeners.set(e, r), this;
31
- }
32
- update(e) {
33
- if (this.options = { ...this.options, ...e }, this.shadowRoot) {
34
- const t = this.shadowRoot.querySelector("style");
35
- t && (t.textContent = this.getCss()), this.render();
36
- }
37
- }
38
- setTheme(e) {
39
- if (this.host)
40
- for (const [t, r] of Object.entries(e))
41
- this.host.style.setProperty(t, r);
42
- }
43
- resetTheme(e) {
44
- if (this.host)
45
- for (const t of Object.keys(e))
46
- this.host.style.removeProperty(t);
47
- }
48
- get value() {
49
- return this.getValue();
50
- }
51
- get isValid() {
52
- return this.getIsValid();
53
- }
54
- get error() {
55
- return this.getError();
56
- }
57
- emit(e, t) {
58
- const r = this.listeners.get(e) ?? [];
59
- for (const s of r)
60
- s(t);
61
- this.options.callbacks?.[e]?.(t);
62
- }
63
- getCss() {
64
- return O;
65
- }
66
- }
67
- class q extends u {
68
- _value = "";
69
- _error = null;
70
- _input = null;
71
- render() {
72
- if (!this.shadowRoot) return;
73
- this._input?.getElement().remove();
74
- const { t: e } = a();
75
- this._input = new g({
76
- name: "billingAddress.city",
77
- label: e("address.city"),
78
- error: !1,
79
- placeholder: e("address.placeholder.city"),
80
- value: this._value,
81
- autocomplete: "address-level2",
82
- onChange: (t) => {
83
- this._value = t.target.value, this._error = null, this.emit("change", this._value);
84
- }
85
- }), this._input.addEventListener("blur", () => {
86
- const { t } = a();
87
- this._error = this._value.trim() ? null : t("validation.cityRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
88
- }), this.shadowRoot.appendChild(this._input.getElement());
89
- }
90
- getCss() {
91
- return super.getCss() + [f, m, p].join(`
92
- `) + `
93
- :host { display: block; }
94
- .form-input {
95
- color: var(--odus-color-text, #1a1a1a) !important;
96
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
97
- font-size: var(--odus-input-font-size, 16px) !important;
98
- background: var(--odus-color-background, #ffffff) !important;
99
- border-radius: var(--odus-border-radius, 6px) !important;
100
- box-shadow:
101
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
102
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
103
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
104
- }
105
- .form-input:focus {
106
- box-shadow: var(
107
- --odus-input-focus-shadow,
108
- 0 0 0 1px rgba(50, 151, 211, 0.7),
109
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
110
- 0 0 0 4px rgba(50, 151, 211, 0.3)
111
- ) !important;
112
- outline: none !important;
113
- }
114
- .form-input-error {
115
- color: var(--odus-color-error, #dc2727) !important;
116
- }
117
- .form-helper-text {
118
- color: var(--odus-color-error, #dc2727) !important;
119
- }
120
- `;
121
- }
122
- getValue() {
123
- return this._value;
124
- }
125
- getIsValid() {
126
- return !!this._value.trim();
127
- }
128
- getError() {
129
- return this._error;
130
- }
131
- }
132
- const S = `.form-select{opacity:1;font-weight:400;letter-spacing:.02em;transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;background:#fff;padding:var(--odus-input-padding, 8px 12px);border:none;outline:none;line-height:1.5;z-index:0;box-sizing:border-box;min-height:0;flex:1;width:100%;cursor:pointer;appearance:none;-webkit-appearance:none;-moz-appearance:none;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2 3.5L5 6.5L8 3.5' stroke='%23717173' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;padding-right:32px}.form-select-error{color:#dc2727}.form-select-placeholder{color:#d4d4d5}.form-select option[disabled]{color:#717173;opacity:.5}.form-select:focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;position:relative;z-index:2}`;
133
- class D extends u {
134
- _value = "";
135
- _error = null;
136
- _select = null;
137
- _allowedCountries;
138
- setCountries(e) {
139
- this._allowedCountries = e.length > 0 ? e : void 0, this._value && this._allowedCountries && !this._allowedCountries.includes(this._value) && (this._value = "", this._error = null, this.emit("change", this._value)), this.shadowRoot && this.render();
140
- }
141
- render() {
142
- if (!this.shadowRoot) return;
143
- this._select?.getElement().remove(), this.options.initialValue && !this._value && (this._value = String(this.options.initialValue));
144
- const { t: e, locale: t } = a();
145
- this._select = new E({
146
- name: "billingAddress.country",
147
- label: e("address.country"),
148
- error: !1,
149
- placeholder: e("address.chooseCountry"),
150
- value: this._value,
151
- options: z(this._allowedCountries, t),
152
- autocomplete: "country",
153
- onChange: (r) => {
154
- this._value = r.target.value, this._error = null, this.emit("change", this._value);
155
- }
156
- }), this._select.addEventListener("blur", () => {
157
- const { t: r } = a();
158
- this._error = this._value ? null : r("validation.countryRequired"), this._select?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
159
- }), this.shadowRoot.appendChild(this._select.getElement());
160
- }
161
- getCss() {
162
- return super.getCss() + [m, p, S].join(`
163
- `) + `
164
- :host { display: block; }
165
- .form-select {
166
- color: var(--odus-color-text, #1a1a1a) !important;
167
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
168
- font-size: var(--odus-input-font-size, 16px) !important;
169
- background-color: var(--odus-color-background, #ffffff) !important;
170
- border-radius: var(--odus-border-radius, 6px) !important;
171
- box-shadow:
172
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
173
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
174
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
175
- }
176
- .form-select:focus {
177
- box-shadow: var(
178
- --odus-input-focus-shadow,
179
- 0 0 0 1px rgba(50, 151, 211, 0.7),
180
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
181
- 0 0 0 4px rgba(50, 151, 211, 0.3)
182
- ) !important;
183
- outline: none !important;
184
- }
185
- .form-select-error {
186
- color: var(--odus-color-error, #dc2727) !important;
187
- }
188
- .form-helper-text {
189
- color: var(--odus-color-error, #dc2727) !important;
190
- }
191
- `;
192
- }
193
- getValue() {
194
- return this._value;
195
- }
196
- getIsValid() {
197
- return !!this._value;
198
- }
199
- getError() {
200
- return this._error;
201
- }
202
- }
203
- class J extends u {
204
- _value = "";
205
- _error = null;
206
- _input = null;
207
- render() {
208
- if (!this.shadowRoot) return;
209
- this._input?.getElement().remove();
210
- const { t: e } = a();
211
- this._input = new g({
212
- name: "billingAddress.firstName",
213
- label: e("address.firstName"),
214
- error: !1,
215
- placeholder: e("address.placeholder.firstName"),
216
- value: this._value,
217
- autocomplete: "given-name",
218
- onChange: (t) => {
219
- this._value = t.target.value, this._error = null, this.emit("change", this._value);
220
- }
221
- }), this._input.addEventListener("blur", () => {
222
- const { t } = a();
223
- this._error = this._value.trim() ? null : t("validation.firstNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
224
- }), this.shadowRoot.appendChild(this._input.getElement());
225
- }
226
- getCss() {
227
- return super.getCss() + [f, m, p].join(`
228
- `) + `
229
- :host { display: block; }
230
- .form-input {
231
- color: var(--odus-color-text, #1a1a1a) !important;
232
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
233
- font-size: var(--odus-input-font-size, 16px) !important;
234
- background: var(--odus-color-background, #ffffff) !important;
235
- border-radius: var(--odus-border-radius, 6px) !important;
236
- box-shadow:
237
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
238
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
239
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
240
- }
241
- .form-input:focus {
242
- box-shadow: var(
243
- --odus-input-focus-shadow,
244
- 0 0 0 1px rgba(50, 151, 211, 0.7),
245
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
246
- 0 0 0 4px rgba(50, 151, 211, 0.3)
247
- ) !important;
248
- outline: none !important;
249
- }
250
- .form-input-error {
251
- color: var(--odus-color-error, #dc2727) !important;
252
- }
253
- .form-helper-text {
254
- color: var(--odus-color-error, #dc2727) !important;
255
- }
256
- `;
257
- }
258
- getValue() {
259
- return this._value;
260
- }
261
- getIsValid() {
262
- return !!this._value.trim();
263
- }
264
- getError() {
265
- return this._error;
266
- }
267
- }
268
- class K extends u {
269
- _value = "";
270
- _error = null;
271
- _input = null;
272
- render() {
273
- if (!this.shadowRoot) return;
274
- this._input?.getElement().remove();
275
- const { t: e } = a();
276
- this._input = new g({
277
- name: "billingAddress.lastName",
278
- label: e("address.lastName"),
279
- error: !1,
280
- placeholder: e("address.placeholder.lastName"),
281
- value: this._value,
282
- autocomplete: "family-name",
283
- onChange: (t) => {
284
- this._value = t.target.value, this._error = null, this.emit("change", this._value);
285
- }
286
- }), this._input.addEventListener("blur", () => {
287
- const { t } = a();
288
- this._error = this._value.trim() ? null : t("validation.lastNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
289
- }), this.shadowRoot.appendChild(this._input.getElement());
290
- }
291
- getCss() {
292
- return super.getCss() + [f, m, p].join(`
293
- `) + `
294
- :host { display: block; }
295
- .form-input {
296
- color: var(--odus-color-text, #1a1a1a) !important;
297
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
298
- font-size: var(--odus-input-font-size, 16px) !important;
299
- background: var(--odus-color-background, #ffffff) !important;
300
- border-radius: var(--odus-border-radius, 6px) !important;
301
- box-shadow:
302
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
303
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
304
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
305
- }
306
- .form-input:focus {
307
- box-shadow: var(
308
- --odus-input-focus-shadow,
309
- 0 0 0 1px rgba(50, 151, 211, 0.7),
310
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
311
- 0 0 0 4px rgba(50, 151, 211, 0.3)
312
- ) !important;
313
- outline: none !important;
314
- }
315
- .form-input-error {
316
- color: var(--odus-color-error, #dc2727) !important;
317
- }
318
- .form-helper-text {
319
- color: var(--odus-color-error, #dc2727) !important;
320
- }
321
- `;
322
- }
323
- getValue() {
324
- return this._value;
325
- }
326
- getIsValid() {
327
- return !!this._value.trim();
328
- }
329
- getError() {
330
- return this._error;
331
- }
332
- }
333
- const v = /* @__PURE__ */ new Set(["US", "CA"]);
334
- class Z extends u {
335
- _value = "";
336
- _country = "";
337
- _input = null;
338
- _select = null;
339
- setCountry(e) {
340
- const t = this._country;
341
- if (this._country = e, !this.shadowRoot) return;
342
- const r = v.has(t), s = v.has(e);
343
- if (r && s && t !== e) {
344
- const { t: o } = a(), i = e, n = o(i === "US" ? "address.chooseState" : "address.chooseProvince");
345
- this._select?.setOptions(x(i), n), this._value = "";
346
- return;
347
- }
348
- r !== s && (this._value = "", this.render());
349
- }
350
- render() {
351
- if (!this.shadowRoot) return;
352
- if (this._input?.getElement().remove(), this._select?.getElement().remove(), this._input = null, this._select = null, v.has(this._country)) {
353
- const t = this._country;
354
- this._renderSelect(t);
355
- } else
356
- this._renderInput();
357
- }
358
- _renderInput() {
359
- const { t: e } = a();
360
- this._input = new g({
361
- name: "billingAddress.state",
362
- label: e("address.state"),
363
- error: !1,
364
- placeholder: e("address.state"),
365
- value: this._value,
366
- autocomplete: "address-level1",
367
- onChange: (t) => {
368
- this._value = t.target.value, this.emit("change", this._value);
369
- }
370
- }), this._input.addEventListener("blur", () => {
371
- this.emit("blur", this._value);
372
- }), this.shadowRoot.appendChild(this._input.getElement());
373
- }
374
- _renderSelect(e) {
375
- const { t } = a(), r = x(e), s = t(e === "US" ? "address.chooseState" : "address.chooseProvince");
376
- this._select = new E({
377
- name: "billingAddress.state",
378
- label: t("address.state"),
379
- error: !1,
380
- placeholder: s,
381
- value: this._value,
382
- options: r,
383
- autocomplete: "address-level1",
384
- onChange: (o) => {
385
- this._value = o.target.value, this.emit("change", this._value);
386
- }
387
- }), this._select.addEventListener("blur", () => {
388
- this.emit("blur", this._value);
389
- }), this.shadowRoot.appendChild(this._select.getElement());
390
- }
391
- getCss() {
392
- return super.getCss() + [f, m, p, S].join(`
393
- `) + `
394
- :host { display: block; }
395
- .form-input,
396
- .form-select {
397
- color: var(--odus-color-text, #1a1a1a) !important;
398
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
399
- font-size: var(--odus-input-font-size, 16px) !important;
400
- background: var(--odus-color-background, #ffffff) !important;
401
- border-radius: var(--odus-border-radius, 6px) !important;
402
- box-shadow:
403
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
404
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
405
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
406
- }
407
- .form-input:focus,
408
- .form-select:focus {
409
- box-shadow: var(
410
- --odus-input-focus-shadow,
411
- 0 0 0 1px rgba(50, 151, 211, 0.7),
412
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
413
- 0 0 0 4px rgba(50, 151, 211, 0.3)
414
- ) !important;
415
- outline: none !important;
416
- }
417
- .form-input-error,
418
- .form-select-error {
419
- color: var(--odus-color-error, #dc2727) !important;
420
- }
421
- .form-helper-text {
422
- color: var(--odus-color-error, #dc2727) !important;
423
- }
424
- `;
425
- }
426
- getValue() {
427
- return this._value;
428
- }
429
- getIsValid() {
430
- return !0;
431
- }
432
- getError() {
433
- return null;
434
- }
435
- }
436
- class G extends u {
437
- _value = "";
438
- _error = null;
439
- _input = null;
440
- render() {
441
- if (!this.shadowRoot) return;
442
- this._input?.getElement().remove();
443
- const { t: e } = a();
444
- this._input = new g({
445
- name: "billingAddress.street",
446
- label: e("address.street"),
447
- error: !1,
448
- placeholder: e("address.placeholder.street"),
449
- value: this._value,
450
- autocomplete: "street-address",
451
- maxLength: this.options.maxLength,
452
- onChange: (t) => {
453
- if (this._value = t.target.value, this._error = null, this.options.maxLength && this._value.length >= this.options.maxLength) {
454
- const r = e("validation.maxLengthExceeded");
455
- this._error = r.replace("{{max}}", String(this.options.maxLength)), this._input?.setError(!0, this._error);
456
- } else
457
- this._input?.setError(!1);
458
- this.emit("change", this._value);
459
- }
460
- }), this._input.addEventListener("blur", () => {
461
- const { t } = a();
462
- this._error = this._value.trim() ? null : t("validation.streetRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
463
- }), this.shadowRoot.appendChild(this._input.getElement());
464
- }
465
- getCss() {
466
- return super.getCss() + [f, m, p].join(`
467
- `) + `
468
- :host { display: block; }
469
- .form-input {
470
- color: var(--odus-color-text, #1a1a1a) !important;
471
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
472
- font-size: var(--odus-input-font-size, 16px) !important;
473
- background: var(--odus-color-background, #ffffff) !important;
474
- border-radius: var(--odus-border-radius, 6px) !important;
475
- box-shadow:
476
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
477
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
478
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
479
- }
480
- .form-input:focus {
481
- box-shadow: var(
482
- --odus-input-focus-shadow,
483
- 0 0 0 1px rgba(50, 151, 211, 0.7),
484
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
485
- 0 0 0 4px rgba(50, 151, 211, 0.3)
486
- ) !important;
487
- outline: none !important;
488
- }
489
- .form-input-error {
490
- color: var(--odus-color-error, #dc2727) !important;
491
- }
492
- .form-helper-text {
493
- color: var(--odus-color-error, #dc2727) !important;
494
- }
495
- `;
496
- }
497
- getValue() {
498
- return this._value;
499
- }
500
- getIsValid() {
501
- return !!this._value.trim();
502
- }
503
- getError() {
504
- return this._error;
505
- }
506
- }
507
- class U extends u {
508
- _value = "";
509
- _error = null;
510
- _input = null;
511
- render() {
512
- if (!this.shadowRoot) return;
513
- this._input?.getElement().remove();
514
- const { t: e } = a();
515
- this._input = new g({
516
- name: "billingAddress.zipCode",
517
- label: e("address.zipCode"),
518
- error: !1,
519
- placeholder: e("address.placeholder.zipCode"),
520
- value: this._value,
521
- autocomplete: "postal-code",
522
- onChange: (t) => {
523
- this._value = t.target.value, this._error = null, this.emit("change", this._value);
524
- }
525
- }), this._input.addEventListener("blur", () => {
526
- const { t } = a();
527
- this._error = this._value.trim() ? null : t("validation.zipCodeRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
528
- }), this.shadowRoot.appendChild(this._input.getElement());
529
- }
530
- getCss() {
531
- return super.getCss() + [f, m, p].join(`
532
- `) + `
533
- :host { display: block; }
534
- .form-input {
535
- color: var(--odus-color-text, #1a1a1a) !important;
536
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
537
- font-size: var(--odus-input-font-size, 16px) !important;
538
- background: var(--odus-color-background, #ffffff) !important;
539
- border-radius: var(--odus-border-radius, 6px) !important;
540
- box-shadow:
541
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
542
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
543
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
544
- }
545
- .form-input:focus {
546
- box-shadow: var(
547
- --odus-input-focus-shadow,
548
- 0 0 0 1px rgba(50, 151, 211, 0.7),
549
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
550
- 0 0 0 4px rgba(50, 151, 211, 0.3)
551
- ) !important;
552
- outline: none !important;
553
- }
554
- .form-input-error {
555
- color: var(--odus-color-error, #dc2727) !important;
556
- }
557
- .form-helper-text {
558
- color: var(--odus-color-error, #dc2727) !important;
559
- }
560
- `;
561
- }
562
- getValue() {
563
- return this._value;
564
- }
565
- getIsValid() {
566
- return !!this._value.trim();
567
- }
568
- getError() {
569
- return this._error;
570
- }
571
- }
572
- const Q = "apple-pay-button{-webkit-appearance:-apple-pay-button;-apple-pay-button-type:plain;-apple-pay-button-style:black;appearance:-apple-pay-button;height:40px;min-height:40px;border-radius:4px;cursor:pointer;display:inline-block;width:100%;box-sizing:border-box}apple-pay-button:hover{filter:brightness(.9)}", W = {
573
- name: "odus-elements",
574
- styles: {
575
- fontSize: 14,
576
- textColor: "#000000",
577
- buttonColor: "#0070f3",
578
- borderRadius: 4,
579
- fontFamily: "system-ui",
580
- buttonTextColor: "#ffffff",
581
- buttonFontSize: 16
582
- },
583
- layout: {
584
- actionButton: { translationKey: null },
585
- billingFields: {
586
- street: { enabled: !1 },
587
- city: { enabled: !1 },
588
- state: { enabled: !1 },
589
- zipCode: { enabled: !1 },
590
- firstName: { enabled: !1 },
591
- lastName: { enabled: !1 },
592
- country: { enabled: !1 }
593
- }
594
- },
595
- additionalPaymentMethods: {}
596
- };
597
- class H extends u {
598
- _paymentContext = null;
599
- _applePayData = null;
600
- _authorized = !1;
601
- _button = null;
602
- setPaymentContext(e) {
603
- this._paymentContext = e, this.isMounted && this.render();
604
- }
605
- render() {
606
- if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext))
607
- return;
608
- const {
609
- paymentId: e,
610
- checkoutKey: t,
611
- environment: r,
612
- checkoutDetails: s,
613
- displayName: o,
614
- countries: i,
615
- requiredBillingContactFields: n,
616
- requiredShippingContactFields: l,
617
- onAuthorize: h
618
- } = this._paymentContext;
619
- i?.length && s?.countryCode && !i.map((b) => b.toUpperCase()).includes(s.countryCode.toUpperCase()) || (this._button = new N({
620
- checkoutProfile: W,
621
- paymentId: e,
622
- checkoutKey: t,
623
- environment: r,
624
- checkoutDetails: s,
625
- displayName: o,
626
- requiredBillingContactFields: n,
627
- requiredShippingContactFields: l,
628
- onSubmit: async ({ applePayData: b }) => {
629
- b && (this._applePayData = b, this._authorized = !0, this.emit("change", b), await h(b));
630
- }
631
- }), this.shadowRoot.appendChild(this._button.getElement()));
632
- }
633
- getCss() {
634
- return super.getCss() + Q + `
635
- :host { display: block; }
636
- apple-pay-button {
637
- width: 100%;
638
- height: var(--odus-button-height, 48px);
639
- border-radius: var(--odus-button-border-radius, 6px);
640
- }
641
- `;
642
- }
643
- getValue() {
644
- return this._applePayData;
645
- }
646
- getIsValid() {
647
- return this._authorized;
648
- }
649
- getError() {
650
- return null;
651
- }
652
- }
653
- const Y = '.card-element{position:relative;height:38.5px;transition:box-shadow .1s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;padding:0;border:none;background:#fff;border-radius:inherit;box-sizing:border-box}.card-element iframe{width:100%;min-width:0;display:block}.card-element-focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}.card-icon{width:18px;transition:opacity .6s ease-in;opacity:1}.card-icon img{max-width:100%;display:block;height:auto}.cards-position{position:absolute;z-index:10;right:12px;top:50%;transform:translateY(-50%);display:flex;align-items:center;gap:8px;pointer-events:none}.loading{position:relative}.loading:after{content:"";position:absolute;inset:0;height:100%;width:100%;background-color:#fff;border-radius:inherit}@media only screen and (min-width: 600px){.card-icon{width:20px}}.vgs-card-group iframe,.vgs-wrap iframe{width:100%;min-width:0;display:block}.fake-ph{position:absolute;inset:0;display:flex;align-items:center;padding:8px 12px;color:#717173;opacity:.3;font-size:var(--odus-input-font-size, 16px);font-weight:400;letter-spacing:.02em;line-height:1.5;font-family:var(--odus-font-family, inherit);background:#fff;pointer-events:none;user-select:none;white-space:nowrap;z-index:0}@keyframes vgs-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.vgs-field-skeleton{position:absolute;inset:0;background:linear-gradient(90deg,#f7f7f7 25%,#fdfdfd,#f7f7f7 75%);background-size:200% 100%;animation:vgs-shimmer 1.5s ease-in-out infinite;pointer-events:none;z-index:11;border-radius:inherit}', $ = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvWpIQFjQQCPpaIlJKpegirp5kLkzLB1AxHmnLk73D3TJbAGqr1QmlsWDBtMPMRpdzzUM7ZwX3kzhIuATV4Pe7RKp3nZlVmcrT0YCQXBrTwqZNh775z58GP2kZs+gVfNqBampJPzSB/hB62KkByhECn6grrRjiAVwJyZVEvs/2vrxaEpO+aE16emtX12RgI5JdzdOiNyZEQteU6zRBRJEocPWVxExaOpVVVJ5+UnW0LcalzA+lRGRTrQJ5JguAPiAOzRPTK/lYFFpCAl/F8wtoAVG1c8zO2NcQ0Pko+fmeidRFxJ/did2btV+9Mkze3mBphwFmvnxa35LF+Cs/XJHDwIDAQAB", X = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8gGPMwBRPuVyJReZGIkWH/+Bf5pnpDN1bSR2cLYLXVT8CaSnTw74qeboSnktgYCi1D9R3Bj2fYzTIwGGZb8KinLdxwbqZmHwrE9cFhCaHbG/E0PbqQGhXP2vbniZTT4M0i0Cbi7ES3Bw5zqNbIZZnX041QEpxLvIyWPKZCX+fBogNMhWfCF779aclChjHkwZMsufThVWE9xklWGxXiytx5aL4I5JPxq0I7cAkZGGs4aF/GxWwPaq7R3wPikJQ0YHnCMfcURzl2Hnw/inqyMy+JB6djTq2/BdzMAhWTh3cDWq9Xu+gEkb/QCd0n1yYIdKuDISlk/AfHdWe34IvzhVyQIDAQAB", c = {
654
- name: "odus-elements",
655
- styles: {
656
- fontSize: 14,
657
- textColor: "#000000",
658
- buttonColor: "#0070f3",
659
- borderRadius: 4,
660
- fontFamily: "system-ui",
661
- buttonTextColor: "#ffffff",
662
- buttonFontSize: 16
663
- },
664
- layout: {
665
- actionButton: { translationKey: null },
666
- billingFields: {
667
- street: { enabled: !0 },
668
- city: { enabled: !0 },
669
- state: { enabled: !0 },
670
- zipCode: { enabled: !0 },
671
- firstName: { enabled: !0 },
672
- lastName: { enabled: !0 },
673
- country: { enabled: !0 }
674
- }
675
- },
676
- additionalPaymentMethods: {}
677
- };
678
- class ee {
679
- _cardNumber = "";
680
- _cardExpiry = "";
681
- _cardCvv = "";
682
- _section = null;
683
- _focusManager = new V();
684
- _touchedFields = /* @__PURE__ */ new Set();
685
- _focusHandlers = [];
686
- get section() {
687
- return this._section;
688
- }
689
- renderSection(e, t, r) {
690
- this._section?.getElement().remove();
691
- const { t: s } = a();
692
- this._section = new k({
693
- checkoutProfile: c,
694
- cardNumber: this._cardNumber,
695
- cardNumberTouched: !1,
696
- cardCvv: this._cardCvv,
697
- cardCvvTouched: !1,
698
- cardExpiry: this._cardExpiry,
699
- cardExpiryTouched: !1,
700
- translationFunc: s,
701
- onChange: (o) => {
702
- const i = o.target;
703
- if (i.name === "cardNumber")
704
- this._cardNumber = i.value;
705
- else if (i.name === "cardExpiry") {
706
- const n = P.cardExpiry(i.value);
707
- this._cardExpiry = n, this._section?.updateCardExpiry(n);
708
- } else i.name === "cardCvv" && (this._cardCvv = i.value);
709
- this._touchedFields.add(i.name), this._updateFocusManagerState(), t(this.getValue());
710
- },
711
- onBlur: (o) => {
712
- const i = o.target, n = i.name ?? "cardExpiry", l = _();
713
- if (this._touchedFields.add(n), i.name === "cardNumber") {
714
- const h = l.cardNumber(this._cardNumber);
715
- this._section?.updateCardNumber(this._cardNumber, h, !0);
716
- } else if (i.name === "cardCvv") {
717
- const h = l.cardCvv(this._cardCvv, this._cardNumber);
718
- this._section?.updateCardCvv(this._cardCvv, h, !0);
719
- } else {
720
- const h = l.cardExpiry(this._cardExpiry);
721
- this._section?.updateCardExpiry(this._cardExpiry, h, !0);
722
- }
723
- this._updateFocusManagerState(), r(this.getValue());
724
- }
725
- }), e.appendChild(this._section.getElement()), this._registerFocusFields();
726
- }
727
- getValue() {
728
- return {
729
- number: this._cardNumber,
730
- expiry: this._cardExpiry,
731
- cvv: this._cardCvv
732
- };
733
- }
734
- async getPayload(e) {
735
- const t = e === "live" ? X : $, r = new F();
736
- r.setPublicKey(t);
737
- const s = this._cardNumber.replace(/\s+/g, ""), o = this._cardExpiry.replace(/\s+/g, "").split("/"), i = o[0] ?? "";
738
- let n = o[1] ?? "";
739
- return n.length === 2 && (n = `20${n}`), {
740
- encryptedCardNumber: r.encrypt(s),
741
- encryptedCvv: r.encrypt(this._cardCvv),
742
- expMonth: i,
743
- expYear: n
744
- };
745
- }
746
- isValid() {
747
- const e = _(), t = this._cardCvv.length >= 3;
748
- return !e.cardNumber(this._cardNumber) && !e.cardExpiry(this._cardExpiry) && t;
749
- }
750
- getError() {
751
- const e = _();
752
- return e.cardNumber(this._cardNumber) ?? e.cardExpiry(this._cardExpiry) ?? null;
753
- }
754
- destroy() {
755
- this._cleanupFocusHandlers(), this._section = null;
756
- }
757
- _registerFocusFields() {
758
- if (this._cleanupFocusHandlers(), !this._section) return;
759
- const e = this._section.getElement();
760
- this._focusManager.registerField("cardNumber", {
761
- focus: () => this._section?.focusField("cardNumber")
762
- }), this._focusManager.registerField("cardExpiry", {
763
- focus: () => this._section?.focusField("cardExpiry")
764
- }), this._focusManager.registerField("cardCvv", {
765
- focus: () => this._section?.focusField("cardCvv")
766
- });
767
- const t = ["cardNumber", "cardExpiry", "cardCvv"];
768
- for (const r of t) {
769
- const s = e.querySelector(`input[name="${r}"]`);
770
- if (!s) continue;
771
- const o = () => this._focusManager.handleFieldFocus(r);
772
- s.addEventListener("focus", o), this._focusHandlers.push(
773
- () => s.removeEventListener("focus", o)
774
- );
775
- }
776
- }
777
- _cleanupFocusHandlers() {
778
- for (const e of this._focusHandlers)
779
- e();
780
- this._focusHandlers = [];
781
- }
782
- _updateFocusManagerState() {
783
- const e = _(), t = {
784
- cardNumber: this._cardNumber,
785
- cardExpiry: this._cardExpiry,
786
- cardCvv: this._cardCvv,
787
- name: "",
788
- email: ""
789
- }, r = {}, s = e.cardNumber(this._cardNumber), o = e.cardExpiry(this._cardExpiry), i = e.cardCvv(this._cardCvv, this._cardNumber);
790
- s && (r.cardNumber = s), o && (r.cardExpiry = o), i && (r.cardCvv = i);
791
- const n = {};
792
- for (const l of this._touchedFields)
793
- n[l] = !0;
794
- this._focusManager.handleStateUpdate(t, r, n);
795
- }
796
- }
797
- class te {
798
- _vgsService;
799
- _vgsJwt;
800
- _vgsState = {};
801
- _vgsFieldsValid = !1;
802
- _vgsReinitTimer = null;
803
- _currentTheme = {};
804
- _environment = "test";
805
- _section = null;
806
- constructor(e, t) {
807
- this._vgsJwt = e, this._environment = t, this._vgsService = new y();
808
- }
809
- get section() {
810
- return this._section;
811
- }
812
- renderSection(e, t) {
813
- this._section?.getElement().remove();
814
- const { t: r } = a();
815
- this._section = new k({
816
- checkoutProfile: c,
817
- cardNumber: "",
818
- cardNumberTouched: !1,
819
- cardCvv: "",
820
- cardCvvTouched: !1,
821
- cardExpiry: "",
822
- cardExpiryTouched: !1,
823
- translationFunc: r,
824
- // eslint-disable-next-line @typescript-eslint/no-empty-function
825
- onChange: () => {
826
- },
827
- // eslint-disable-next-line @typescript-eslint/no-empty-function
828
- onBlur: () => {
829
- },
830
- vgsService: this._vgsService
831
- }), e.appendChild(this._section.getElement()), this._onChangeEmit = t;
832
- }
833
- _onChangeEmit = null;
834
- initVgs() {
835
- this._vgsService.init(this._environment).then((e) => {
836
- this._vgsService.createForm(
837
- e,
838
- (t) => this._handleStateChange(t)
839
- ), this._mountFields();
840
- });
841
- }
842
- async getPayload() {
843
- if (!this._vgsJwt)
844
- throw new Error("VGS not initialized");
845
- const e = await this._vgsService.createCard(this._vgsJwt);
846
- return {
847
- cardId: e.cardId,
848
- expMonth: e.expMonth,
849
- expYear: e.expYear,
850
- name: e.name
851
- };
852
- }
853
- isValid() {
854
- return this._vgsFieldsValid;
855
- }
856
- getError() {
857
- const { t: e } = a();
858
- for (const [t, r] of Object.entries(this._vgsState)) {
859
- if (!r?.isTouched || r.isFocused || r.isValid)
860
- continue;
861
- const s = r.errors?.[0];
862
- if (!s) continue;
863
- const o = w(t, s.code);
864
- if (o) return e(o);
865
- }
866
- return null;
867
- }
868
- applyTheme(e) {
869
- if (this._currentTheme = { ...this._currentTheme, ...e }, !this._section) return;
870
- const t = this._buildProfileFromTheme(this._currentTheme), r = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
871
- this._section.updateVgsWrapperStyles(
872
- r,
873
- t.styles.borderRadius
874
- ), this._reinitWithTheme();
875
- }
876
- destroy() {
877
- this._vgsReinitTimer && (clearTimeout(this._vgsReinitTimer), this._vgsReinitTimer = null), this._vgsService.destroy(), this._section = null;
878
- }
879
- _reinitWithTheme() {
880
- this._vgsReinitTimer && clearTimeout(this._vgsReinitTimer), this._vgsReinitTimer = setTimeout(() => {
881
- this._vgsReinitTimer = null, this._vgsService.destroy(), this._vgsService = new y(), this.initVgs();
882
- }, 300);
883
- }
884
- _buildProfileFromTheme(e) {
885
- const t = e["--odus-input-font-size"] ?? e["--odus-font-size"] ?? `${c.styles.fontSize}px`, r = e["--odus-font-family"] ?? c.styles.fontFamily, s = e["--odus-color-text"] ?? c.styles.textColor, o = e["--odus-border-radius"] ?? `${c.styles.borderRadius}px`;
886
- return {
887
- ...c,
888
- styles: {
889
- ...c.styles,
890
- fontSize: parseInt(t, 10) || c.styles.fontSize,
891
- fontFamily: r,
892
- textColor: s,
893
- borderRadius: parseInt(o, 10) || c.styles.borderRadius
894
- }
895
- };
896
- }
897
- async _mountFields() {
898
- if (!this._section) return;
899
- const e = Object.keys(this._currentTheme).length > 0 ? this._buildProfileFromTheme(this._currentTheme) : c, t = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
900
- this._section.updateVgsWrapperStyles(
901
- t,
902
- e.styles.borderRadius
903
- );
904
- const r = this._section.getVgsContainerIds();
905
- for (const n of Object.values(r)) {
906
- if (!n) continue;
907
- const l = document.getElementById(n);
908
- l && l.querySelectorAll("iframe").forEach((h) => h.remove());
909
- }
910
- const s = await A(e.styles.fontFamily), o = this._section.buildVgsFieldCss(e, s, {
911
- borderColor: t,
912
- backgroundColor: this._currentTheme["--odus-color-background"],
913
- placeholderColor: this._currentTheme["--odus-input-placeholder-color"],
914
- placeholderOpacity: this._currentTheme["--odus-input-placeholder-opacity"],
915
- padding: this._currentTheme["--odus-input-padding"]
916
- }), { t: i } = a();
917
- this._vgsService.mountCardFields(
918
- {
919
- cardNumber: r.cardNumber ? `#${r.cardNumber}` : void 0,
920
- cardExpiry: r.cardExpiry ? `#${r.cardExpiry}` : void 0,
921
- cardCvv: r.cardCvv ? `#${r.cardCvv}` : void 0
922
- },
923
- o,
924
- {
925
- cardNumber: "1234 5678 9012 3456",
926
- cardExpiry: i("cardExpiry"),
927
- cardCvv: "CVV",
928
- cardholderName: i("cardholderName")
929
- },
930
- (n) => {
931
- this._section?.updateVgsCardBrand(n);
932
- }
933
- ), this._vgsService.waitForFieldsReady().then(() => {
934
- this._section?.hideFakePlaceholders();
935
- });
936
- }
937
- _handleStateChange(e) {
938
- this._vgsState = e, this._vgsFieldsValid = Object.values(e).every(
939
- (s) => s?.isValid === !0
940
- );
941
- const { t } = a(), r = this._deriveFieldErrors(t);
942
- this._section?.handleVgsStateChange(e, r), this._onChangeEmit?.();
943
- }
944
- _deriveFieldErrors(e) {
945
- const t = {};
946
- for (const [r, s] of Object.entries(this._vgsState)) {
947
- if (!s?.isTouched || s.isFocused || s.isValid)
948
- continue;
949
- const o = s.errors?.[0];
950
- if (!o) continue;
951
- const i = w(r, o.code);
952
- i && (t[r] = e(i));
953
- }
954
- return t;
955
- }
956
- }
957
- class re extends u {
958
- _environment = "test";
959
- _isVgsMode = !1;
960
- _mountContainer = null;
961
- _nativeAdapter = new ee();
962
- _vgsAdapter = null;
963
- get isVgsMode() {
964
- return this._isVgsMode;
965
- }
966
- setEnvironment(e) {
967
- this._environment = e;
968
- }
969
- setVgsJwt(e) {
970
- this._isVgsMode = !0, this._vgsAdapter = new te(e, this._environment), this.isMounted && this._mountContainer && (this.unmount(), this.mount(this._mountContainer));
971
- }
972
- mount(e) {
973
- this.isMounted && this.unmount();
974
- const t = typeof e == "string" ? document.querySelector(e) : e;
975
- if (!t)
976
- throw new Error(
977
- `[CardElement] mount target not found: ${String(e)}`
978
- );
979
- if (this._mountContainer = e, this._isVgsMode) {
980
- this.host = document.createElement("div");
981
- const r = document.createElement("style");
982
- r.textContent = this.getCss(), this.host.appendChild(r), t.appendChild(this.host), this.render(), this._vgsAdapter?.initVgs(), this.emit("ready");
983
- } else
984
- super.mount(e);
985
- }
986
- unmount() {
987
- this._isVgsMode ? (this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null) : super.unmount();
988
- }
989
- render() {
990
- if (this._isVgsMode) {
991
- if (!this.host || !this._vgsAdapter) return;
992
- this._vgsAdapter.renderSection(
993
- this.host,
994
- () => this.emit("change", this.getValue())
995
- );
996
- } else {
997
- if (!this.shadowRoot) return;
998
- this._nativeAdapter.renderSection(
999
- this.shadowRoot,
1000
- (e) => this.emit("change", e),
1001
- (e) => this.emit("blur", e)
1002
- );
1003
- }
1004
- }
1005
- focus() {
1006
- (this._isVgsMode ? this._vgsAdapter?.section : this._nativeAdapter.section)?.focus();
1007
- }
1008
- focusField(e) {
1009
- (this._isVgsMode ? this._vgsAdapter?.section : this._nativeAdapter.section)?.focusField(e);
1010
- }
1011
- destroy() {
1012
- this._nativeAdapter.destroy(), this._vgsAdapter?.destroy(), this._vgsAdapter = null, super.destroy();
1013
- }
1014
- setTheme(e) {
1015
- super.setTheme(e), !(!this._isVgsMode || !this._vgsAdapter) && this._vgsAdapter.applyTheme(e);
1016
- }
1017
- getCss() {
1018
- return super.getCss() + [f, m, p, Y].join(`
1019
- `) + `
1020
- :host { display: block; }
1021
- .card-grid {
1022
- display: flex;
1023
- flex-direction: column;
1024
- gap: var(--odus-card-gap, 12px);
1025
- }
1026
- .card-details {
1027
- display: flex;
1028
- gap: var(--odus-card-gap, 12px);
1029
- }
1030
- .form-input,
1031
- .form-select {
1032
- color: var(--odus-color-text, #1a1a1a) !important;
1033
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
1034
- font-size: var(--odus-input-font-size, 16px) !important;
1035
- background: var(--odus-color-background, #ffffff) !important;
1036
- border-radius: var(--odus-border-radius, 6px) !important;
1037
- box-shadow:
1038
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
1039
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
1040
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
1041
- }
1042
- .form-input:focus,
1043
- .form-select:focus {
1044
- box-shadow: var(
1045
- --odus-input-focus-shadow,
1046
- 0 0 0 1px rgba(50, 151, 211, 0.7),
1047
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
1048
- 0 0 0 4px rgba(50, 151, 211, 0.3)
1049
- ) !important;
1050
- outline: none !important;
1051
- }
1052
- .form-input-error,
1053
- .form-select-error {
1054
- color: var(--odus-color-error, #dc2727) !important;
1055
- }
1056
- .form-helper-text {
1057
- color: var(--odus-color-error, #dc2727) !important;
1058
- }
1059
- `;
1060
- }
1061
- getValue() {
1062
- return this._isVgsMode ? { number: "", expiry: "", cvv: "" } : this._nativeAdapter.getValue();
1063
- }
1064
- async getPayload() {
1065
- if (this._isVgsMode) {
1066
- if (!this._vgsAdapter)
1067
- throw new Error("VGS not initialized");
1068
- return this._vgsAdapter.getPayload();
1069
- }
1070
- return this._nativeAdapter.getPayload(this._environment);
1071
- }
1072
- getIsValid() {
1073
- return this._isVgsMode ? this._vgsAdapter?.isValid() ?? !1 : this._nativeAdapter.isValid();
1074
- }
1075
- getError() {
1076
- return this._isVgsMode ? this._vgsAdapter?.getError() ?? null : this._nativeAdapter.getError();
1077
- }
1078
- }
1079
- class se extends u {
1080
- _value = "";
1081
- _error = null;
1082
- _input = null;
1083
- render() {
1084
- if (!this.shadowRoot) return;
1085
- this._input?.getElement().remove();
1086
- const { t: e } = a();
1087
- this._input = new g({
1088
- name: "billingAddress.cardholderName",
1089
- label: e("cardholderNameLabel"),
1090
- error: !1,
1091
- placeholder: e("cardholderNamePlaceholder"),
1092
- value: this._value,
1093
- autocomplete: "cc-name",
1094
- onChange: (t) => {
1095
- const s = t.target.value, o = s.replace(/[^a-zA-Z\s\-'.]/g, "");
1096
- s !== o && this._input?.setValue(o), this._value = o, this._error = null, this.emit("change", this._value);
1097
- }
1098
- }), this._input.addEventListener("blur", () => {
1099
- const { t } = a();
1100
- this._error = this._value.trim() ? null : t("validation.nameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
1101
- }), this.shadowRoot.appendChild(this._input.getElement());
1102
- }
1103
- getCss() {
1104
- return super.getCss() + [f, m, p].join(`
1105
- `) + `
1106
- :host { display: block; }
1107
- .form-input {
1108
- color: var(--odus-color-text, #1a1a1a) !important;
1109
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
1110
- font-size: var(--odus-input-font-size, 16px) !important;
1111
- background: var(--odus-color-background, #ffffff) !important;
1112
- border-radius: var(--odus-border-radius, 6px) !important;
1113
- box-shadow:
1114
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
1115
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
1116
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
1117
- }
1118
- .form-input:focus {
1119
- box-shadow: var(
1120
- --odus-input-focus-shadow,
1121
- 0 0 0 1px rgba(50, 151, 211, 0.7),
1122
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
1123
- 0 0 0 4px rgba(50, 151, 211, 0.3)
1124
- ) !important;
1125
- outline: none !important;
1126
- }
1127
- .form-input-error {
1128
- color: var(--odus-color-error, #dc2727) !important;
1129
- }
1130
- .form-helper-text {
1131
- color: var(--odus-color-error, #dc2727) !important;
1132
- }
1133
- `;
1134
- }
1135
- getValue() {
1136
- return this._value;
1137
- }
1138
- getIsValid() {
1139
- return !!this._value.trim();
1140
- }
1141
- getError() {
1142
- return this._error;
1143
- }
1144
- }
1145
- const oe = {
1146
- name: "odus-elements",
1147
- styles: {
1148
- fontSize: 14,
1149
- textColor: "#000000",
1150
- buttonColor: "#0070f3",
1151
- borderRadius: 4,
1152
- fontFamily: "system-ui",
1153
- buttonTextColor: "#ffffff",
1154
- buttonFontSize: 16
1155
- },
1156
- layout: {
1157
- actionButton: { translationKey: null },
1158
- billingFields: {
1159
- street: { enabled: !1 },
1160
- city: { enabled: !1 },
1161
- state: { enabled: !1 },
1162
- zipCode: { enabled: !1 },
1163
- firstName: { enabled: !1 },
1164
- lastName: { enabled: !1 },
1165
- country: { enabled: !1 }
1166
- }
1167
- },
1168
- additionalPaymentMethods: {}
1169
- };
1170
- class ie extends u {
1171
- _email = "";
1172
- _error = null;
1173
- _field = null;
1174
- render() {
1175
- if (!this.shadowRoot) return;
1176
- this._field?.getElement().remove(), this.options.initialValue && !this._email && (this._email = String(this.options.initialValue));
1177
- const { t: e } = a();
1178
- this._field = new R({
1179
- value: this._email,
1180
- error: !1,
1181
- checkoutProfile: oe,
1182
- translationFunc: e,
1183
- onChange: (t) => {
1184
- const r = t.target;
1185
- this._email = r.value ?? this._field?.getValue() ?? "", this._error = null, this.emit("change", this._email);
1186
- },
1187
- onBlur: () => {
1188
- const t = _();
1189
- this._error = t.email(this._email) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._email);
1190
- }
1191
- }), this.shadowRoot.appendChild(this._field.getElement());
1192
- }
1193
- getCss() {
1194
- return super.getCss() + [f, m, p].join(`
1195
- `) + `
1196
- :host { display: block; }
1197
- .form-input {
1198
- color: var(--odus-color-text, #1a1a1a) !important;
1199
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
1200
- font-size: var(--odus-input-font-size, 16px) !important;
1201
- background: var(--odus-color-background, #ffffff) !important;
1202
- border-radius: var(--odus-border-radius, 6px) !important;
1203
- box-shadow:
1204
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
1205
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
1206
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
1207
- }
1208
- .form-input:focus {
1209
- box-shadow: var(
1210
- --odus-input-focus-shadow,
1211
- 0 0 0 1px rgba(50, 151, 211, 0.7),
1212
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
1213
- 0 0 0 4px rgba(50, 151, 211, 0.3)
1214
- ) !important;
1215
- outline: none !important;
1216
- }
1217
- .form-input-error {
1218
- color: var(--odus-color-error, #dc2727) !important;
1219
- }
1220
- .form-helper-text {
1221
- color: var(--odus-color-error, #dc2727) !important;
1222
- }
1223
- `;
1224
- }
1225
- getValue() {
1226
- return this._email;
1227
- }
1228
- getIsValid() {
1229
- return !_().email(this._email);
1230
- }
1231
- getError() {
1232
- return this._error;
1233
- }
1234
- }
1235
- const ae = "@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.error-alert{background-color:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f;animation:slideIn .3s ease-out}.error-alert-content{display:flex;align-items:flex-start;gap:12px}.error-alert-icon-container{flex-shrink:0;display:flex;align-items:center;justify-content:center;width:32px;height:32px;background-color:#fee2e2;border-radius:50%;color:#dc2626}.error-alert-icon{color:#dc2626}.error-alert-text-container{flex:1;min-width:0}.error-alert-title{margin:0 0 4px;font-size:14px;font-weight:600;color:#991b1b;line-height:1.4}.error-alert-message{margin:0;font-family:var(--odus-font-family, inherit);font-size:14px;color:#7f1d1d;line-height:1.5;word-break:break-word}";
1236
- class ne extends u {
1237
- _alert = null;
1238
- _message = null;
1239
- render() {
1240
- this.shadowRoot && (this._alert?.getElement().remove(), this._alert = null, this._message && (this._alert = new C({ message: this._message }), this.shadowRoot.appendChild(this._alert.getElement())));
1241
- }
1242
- setError(e) {
1243
- if (this._message = e, !this.shadowRoot) {
1244
- this.emit("error", e);
1245
- return;
1246
- }
1247
- this._alert ? this._alert.setMessage(e) : (this._alert = new C({ message: e }), this.shadowRoot.appendChild(this._alert.getElement())), this.emit("error", e);
1248
- }
1249
- clearError() {
1250
- this._message = null, this._alert?.getElement().remove(), this._alert = null;
1251
- }
1252
- getCss() {
1253
- return super.getCss() + ae + `
1254
- :host { display: block; }
1255
- .error-alert-icon,
1256
- .error-alert-icon-container {
1257
- color: var(--odus-color-error, #e53e3e) !important;
1258
- }
1259
- .error-alert-message {
1260
- color: var(--odus-color-text, #1a1a1a) !important;
1261
- }
1262
- `;
1263
- }
1264
- getValue() {
1265
- return null;
1266
- }
1267
- getIsValid() {
1268
- return !0;
1269
- }
1270
- getError() {
1271
- return this._message;
1272
- }
1273
- }
1274
- const de = ".paypal{background-color:#ffc439;color:#253b80;font-weight:700;padding:8px 16px;box-shadow:0 2px 4px #0000001a;text-transform:none;cursor:pointer;border-radius:4px}.paypal:hover{background-color:#ffc439;filter:brightness(.95)}.paypal-icon-container{display:flex;align-items:center;justify-content:center}.paypal-icon-container img{width:69px;height:22px}", le = {
1275
- name: "odus-elements",
1276
- styles: {
1277
- fontSize: 14,
1278
- textColor: "#000000",
1279
- buttonColor: "#0070f3",
1280
- borderRadius: 4,
1281
- fontFamily: "system-ui",
1282
- buttonTextColor: "#ffffff",
1283
- buttonFontSize: 16
1284
- },
1285
- layout: {
1286
- actionButton: { translationKey: null },
1287
- billingFields: {
1288
- street: { enabled: !1 },
1289
- city: { enabled: !1 },
1290
- state: { enabled: !1 },
1291
- zipCode: { enabled: !1 },
1292
- firstName: { enabled: !1 },
1293
- lastName: { enabled: !1 },
1294
- country: { enabled: !1 }
1295
- }
1296
- },
1297
- additionalPaymentMethods: {}
1298
- };
1299
- class ue extends u {
1300
- _paymentContext = null;
1301
- _button = null;
1302
- setPaymentContext(e) {
1303
- this._paymentContext = e, this.isMounted && this.render();
1304
- }
1305
- render() {
1306
- if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext)) return;
1307
- const { onAuthorize: e } = this._paymentContext;
1308
- this._button = new M({
1309
- checkoutProfile: le,
1310
- onSubmit: async () => {
1311
- this._button?.setSubmitting(!0);
1312
- try {
1313
- await e();
1314
- } finally {
1315
- this._button?.setSubmitting(!1);
1316
- }
1317
- }
1318
- }), this.shadowRoot.appendChild(this._button.getElement());
1319
- }
1320
- getCss() {
1321
- return super.getCss() + de + `
1322
- :host { display: block; }
1323
- .paypal {
1324
- width: 100%;
1325
- box-sizing: border-box;
1326
- border-radius: var(--odus-button-border-radius, 6px);
1327
- display: flex;
1328
- align-items: center;
1329
- justify-content: center;
1330
- }
1331
- `;
1332
- }
1333
- getValue() {
1334
- return null;
1335
- }
1336
- getIsValid() {
1337
- return !0;
1338
- }
1339
- getError() {
1340
- return null;
1341
- }
1342
- }
1343
- const he = ".country-dial-code-dropdown{position:relative;display:inline-block}.country-dial-code-trigger{display:flex;align-items:center;gap:6px;padding:var(--odus-input-padding, 8px 12px);padding-right:8px;background:#fff;border:none;cursor:pointer;font-weight:400;letter-spacing:.02em;line-height:var(--odus-input-line-height, 1.5);transition:all .1s ease-in;white-space:nowrap;border-right:1px solid #e0e0e0;box-sizing:border-box}.country-dial-code-trigger:hover{background:#f5f5f5}.country-dial-code-trigger:focus{outline:none}.country-dial-code-trigger .country-flag{font-size:14px;line-height:1}.country-dial-code-trigger .country-chevron{color:#717173;flex-shrink:0;transition:transform .15s ease}.country-dial-code-trigger[aria-expanded=true] .country-chevron{transform:rotate(180deg)}.country-dial-code-panel{position:fixed;top:0;left:0;z-index:10000;width:280px;background:#fff;border-radius:8px;box-shadow:0 0 0 1px #0000000d,0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f;max-height:360px;display:flex;flex-direction:column;overflow:hidden}.country-dial-code-panel.hidden{display:none}.country-search-wrapper{padding:12px;border-bottom:1px solid #e0e0e0;flex-shrink:0}.country-search{width:100%;padding:6px 12px;border:1px solid #e0e0e0;border-radius:6px;font-size:inherit;font-family:inherit;outline:none;transition:all .1s ease-in;box-sizing:border-box}.country-search:focus{border-color:#3297d3b3;box-shadow:0 0 0 3px #3297d31a}.country-search::placeholder{color:#717173;opacity:.6}.countries-list{overflow-y:auto;flex:1;min-height:0}.countries-list::-webkit-scrollbar{width:8px}.countries-list::-webkit-scrollbar-track{background:#f5f5f5}.countries-list::-webkit-scrollbar-thumb{background:#d0d0d0;border-radius:4px}.countries-list::-webkit-scrollbar-thumb:hover{background:#b0b0b0}.country-group-header{padding:8px 16px 4px;font-size:12px;font-weight:600;color:#717173;text-transform:uppercase;letter-spacing:.05em;background:#fafafa;position:sticky;top:0;z-index:1}.country-item{display:flex;align-items:center;gap:12px;padding:10px 16px;width:100%;border:none;background:#fff;cursor:pointer;transition:background .1s ease;text-align:left;font-size:14px;font-family:inherit;color:inherit}.country-item:hover{background:#f5f5f5}.country-item.selected{background:#3297d314;color:#3297d3}.country-item:focus{outline:none;background:#f0f0f0}.country-item .country-flag{font-size:20px;line-height:1;flex-shrink:0}.country-item .country-name{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.country-item .country-dial-code{color:#717173;font-size:.95em;flex-shrink:0}.country-item.selected .country-dial-code{color:#3297d3cc}.no-results{padding:24px 16px;text-align:center;color:#717173;font-size:14px}.phone-number-field-wrapper{display:flex;width:100%}.phone-number-field-container{display:flex;align-items:center;width:100%;border-radius:inherit;transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d;background:#fff;position:relative}.phone-number-field-container.focused{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d;z-index:2}.phone-number-field-container.error{box-shadow:0 0 0 1px #dc2727,0 2px 4px #dc27271a}.phone-number-field-container.error.focused{box-shadow:0 0 0 1px #dc2727,0 1px 1px #00000012,0 0 0 4px #dc272733}.phone-number-field-container .country-select-wrapper{flex-shrink:0;position:relative;display:flex;align-items:center;gap:4px;padding:var(--odus-input-padding, 8px 12px);padding-right:6px;background:transparent;border-top-left-radius:var(--phone-border-radius, 0px);border-bottom-left-radius:var(--phone-border-radius, 0px);white-space:nowrap}.phone-number-field-container .country-select-wrapper .country-flag{font-size:14px;line-height:1;pointer-events:none}.phone-number-field-container .country-select-wrapper .country-chevron{display:flex;align-items:center;color:#717173;flex-shrink:0;pointer-events:none}.phone-number-field-container .country-select-wrapper .country-select{position:absolute;inset:0;border:none;outline:none;background:transparent;cursor:pointer;opacity:0;width:100%;height:100%}.phone-number-field-container .phone-input-wrapper{flex:1;min-width:0}.phone-number-field-container .phone-input-wrapper .form-input{border:none;box-shadow:none;border-radius:0;border-top-right-radius:var(--phone-border-radius, 0px);border-bottom-right-radius:var(--phone-border-radius, 0px);padding:var(--odus-input-padding, 8px 2px)}.phone-number-field-container .phone-input-wrapper .form-input:focus{box-shadow:none;z-index:auto}", ce = {
1344
- name: "odus-elements",
1345
- styles: {
1346
- fontSize: 14,
1347
- textColor: "#000000",
1348
- buttonColor: "#0070f3",
1349
- borderRadius: 4,
1350
- fontFamily: "system-ui",
1351
- buttonTextColor: "#ffffff",
1352
- buttonFontSize: 16
1353
- },
1354
- layout: {
1355
- actionButton: { translationKey: null },
1356
- billingFields: {
1357
- street: { enabled: !1 },
1358
- city: { enabled: !1 },
1359
- state: { enabled: !1 },
1360
- zipCode: { enabled: !1 },
1361
- firstName: { enabled: !1 },
1362
- lastName: { enabled: !1 },
1363
- country: { enabled: !1 }
1364
- }
1365
- },
1366
- additionalPaymentMethods: {}
1367
- };
1368
- class pe extends u {
1369
- _phone = "";
1370
- _error = null;
1371
- _field = null;
1372
- _renderGeneration = 0;
1373
- render() {
1374
- if (!this.shadowRoot) return;
1375
- this._field?.destroy(), this._field?.getElement().remove(), this._field = null, this.options.initialValue && !this._phone && (this._phone = String(this.options.initialValue));
1376
- const e = ++this._renderGeneration;
1377
- T().then(({ PhoneNumberField: t }) => {
1378
- if (!this.shadowRoot || this._renderGeneration !== e) return;
1379
- const { t: r, locale: s } = a();
1380
- this._field = new t({
1381
- value: this._phone,
1382
- error: !1,
1383
- checkoutProfile: ce,
1384
- translationFunc: r,
1385
- locale: s,
1386
- onChange: () => {
1387
- this._phone = this._field?.getValue() ?? "", this._error = null, this.emit("change", this._phone);
1388
- },
1389
- onBlur: () => {
1390
- this._phone = this._field?.getValue() ?? "";
1391
- const o = _(), i = this._field?.getCountry();
1392
- this._error = o.phoneNumber(this._phone, i) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._phone);
1393
- }
1394
- }), this.shadowRoot.appendChild(this._field.getElement());
1395
- });
1396
- }
1397
- getCss() {
1398
- return super.getCss() + [f, m, p, he].join(`
1399
- `) + `
1400
- :host { display: block; }
1401
- .form-input,
1402
- .country-select-wrapper {
1403
- color: var(--odus-color-text, #1a1a1a) !important;
1404
- font-family: var(--odus-font-family, system-ui, sans-serif) !important;
1405
- font-size: var(--odus-input-font-size, 16px) !important;
1406
- background: var(--odus-color-background, #ffffff) !important;
1407
- border-radius: 0 !important;
1408
- box-shadow: none !important;
1409
- }
1410
- .phone-number-field-container {
1411
- min-height: calc(var(--odus-input-font-size, 16px) * 1.5 + 16px);
1412
- box-shadow:
1413
- 0 0 0 1px var(--odus-border-color, #e0e0e0),
1414
- 0 2px 4px 0 rgba(0, 0, 0, 0.07),
1415
- 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;
1416
- border-radius: var(--odus-border-radius, 6px) !important;
1417
- overflow: hidden;
1418
- }
1419
- .phone-number-field-container:focus-within {
1420
- box-shadow: var(
1421
- --odus-input-focus-shadow,
1422
- 0 0 0 1px rgba(50, 151, 211, 0.7),
1423
- 0 1px 1px 0 rgba(0, 0, 0, 0.07),
1424
- 0 0 0 4px rgba(50, 151, 211, 0.3)
1425
- ) !important;
1426
- }
1427
- .phone-number-field-container.error {
1428
- box-shadow: 0 0 0 1px var(--odus-color-error, #dc2727) !important;
1429
- }
1430
- .form-input:focus {
1431
- box-shadow: none !important;
1432
- outline: none !important;
1433
- }
1434
- .form-input-error {
1435
- color: var(--odus-color-error, #dc2727) !important;
1436
- }
1437
- .form-helper-text {
1438
- color: var(--odus-color-error, #dc2727) !important;
1439
- }
1440
- `;
1441
- }
1442
- getValue() {
1443
- return this._phone;
1444
- }
1445
- getIsValid() {
1446
- const e = _(), t = this._field?.getCountry();
1447
- return !e.phoneNumber(this._phone, t);
1448
- }
1449
- getError() {
1450
- return this._error;
1451
- }
1452
- }
1453
- class fe {
1454
- _config;
1455
- _apiService;
1456
- _changeListeners = [];
1457
- _callbacks;
1458
- _paymentState = {};
1459
- _fontCleanup;
1460
- _card;
1461
- _email;
1462
- _phone;
1463
- _addressStreet;
1464
- _addressFirstName;
1465
- _addressLastName;
1466
- _cardholderName;
1467
- _addressCity;
1468
- _addressState;
1469
- _addressZipCode;
1470
- _addressCountry;
1471
- _applePay;
1472
- _paypal;
1473
- _error;
1474
- elements;
1475
- constructor(e) {
1476
- this._config = e, this._callbacks = { ...e.callbacks }, e.locale && I.setLocale(e.locale), this._apiService = new B(
1477
- e.apiKey,
1478
- e.environment
1479
- );
1480
- const t = {};
1481
- Object.defineProperty(t, "email", {
1482
- get: () => (this._email || (this._email = new ie(), this._trackElement(this._email)), this._email),
1483
- enumerable: !0
1484
- }), Object.defineProperty(t, "phone", {
1485
- get: () => (this._phone || (this._phone = new pe(), this._trackElement(this._phone)), this._phone),
1486
- enumerable: !0
1487
- });
1488
- const r = {};
1489
- Object.defineProperty(r, "applePay", {
1490
- get: () => (this._applePay || (this._applePay = new H(), this._trackElement(this._applePay), this._paymentState.paymentId && this._paymentState.checkoutKey && this._applePay.setPaymentContext({
1491
- paymentId: this._paymentState.paymentId,
1492
- checkoutKey: this._paymentState.checkoutKey,
1493
- environment: this._config.environment,
1494
- checkoutDetails: this._paymentState.checkoutDetails,
1495
- ...this._config.additionalPaymentMethods?.applePay,
1496
- onAuthorize: (i) => this._executeAuthorization({ formData: null, applePayData: i })
1497
- })), this._applePay),
1498
- enumerable: !0
1499
- }), Object.defineProperty(r, "payPal", {
1500
- get: () => (this._paypal || (this._paypal = new ue(), this._trackElement(this._paypal), this._paymentState.paymentId && this._paymentState.checkoutKey && this._paypal.setPaymentContext({
1501
- paymentId: this._paymentState.paymentId,
1502
- checkoutKey: this._paymentState.checkoutKey,
1503
- onAuthorize: () => this._executeAuthorization({ formData: null })
1504
- })), this._paypal),
1505
- enumerable: !0
1506
- });
1507
- const s = {};
1508
- Object.defineProperty(s, "street", {
1509
- get: () => (this._addressStreet || (this._addressStreet = new G(), this._trackElement(this._addressStreet)), this._addressStreet),
1510
- enumerable: !0
1511
- }), Object.defineProperty(s, "firstName", {
1512
- get: () => (this._addressFirstName || (this._addressFirstName = new J(), this._trackElement(this._addressFirstName)), this._addressFirstName),
1513
- enumerable: !0
1514
- }), Object.defineProperty(s, "lastName", {
1515
- get: () => (this._addressLastName || (this._addressLastName = new K(), this._trackElement(this._addressLastName)), this._addressLastName),
1516
- enumerable: !0
1517
- }), Object.defineProperty(s, "city", {
1518
- get: () => (this._addressCity || (this._addressCity = new q(), this._trackElement(this._addressCity)), this._addressCity),
1519
- enumerable: !0
1520
- }), Object.defineProperty(s, "state", {
1521
- get: () => (this._addressState || (this._addressState = new Z(), this._trackElement(this._addressState)), this._addressState),
1522
- enumerable: !0
1523
- }), Object.defineProperty(s, "zipCode", {
1524
- get: () => (this._addressZipCode || (this._addressZipCode = new U(), this._trackElement(this._addressZipCode)), this._addressZipCode),
1525
- enumerable: !0
1526
- }), Object.defineProperty(s, "country", {
1527
- get: () => (this._addressCountry || (this._addressCountry = new D(), this._trackElement(this._addressCountry), this._addressCountry.on("change", (i) => {
1528
- this._addressState?.setCountry(i);
1529
- })), this._addressCountry),
1530
- enumerable: !0
1531
- });
1532
- const o = { contact: t, express: r };
1533
- Object.defineProperty(o, "card", {
1534
- get: () => (this._card || (this._card = new re(), this._card.setEnvironment(this._config.environment), this._trackElement(this._card), this._paymentState.vgsJwt && this._card.setVgsJwt(this._paymentState.vgsJwt)), this._card),
1535
- enumerable: !0
1536
- }), Object.defineProperty(o, "cardholderName", {
1537
- get: () => (this._cardholderName || (this._cardholderName = new se(), this._trackElement(this._cardholderName)), this._cardholderName),
1538
- enumerable: !0
1539
- }), Object.defineProperty(o, "address", {
1540
- get: () => s,
1541
- enumerable: !0
1542
- }), Object.defineProperty(o, "error", {
1543
- get: () => (this._error || (this._error = new ne(), this._trackElement(this._error)), this._error),
1544
- enumerable: !0
1545
- }), this.elements = o;
1546
- }
1547
- async associatePayment(e, t) {
1548
- if (!e || !t)
1549
- throw new Error("paymentId and checkoutKey are required");
1550
- this._paymentState.paymentId = e, this._paymentState.checkoutKey = t;
1551
- const r = await L({
1552
- id: e,
1553
- checkoutKey: t,
1554
- environment: this._config.environment
1555
- });
1556
- this._paymentState.checkoutDetails = {
1557
- amount: r.amount,
1558
- currency: r.currency,
1559
- countryCode: r.countryCode
1560
- }, r.vgsJwt && (this._paymentState.vgsJwt = r.vgsJwt, this._card?.setVgsJwt(r.vgsJwt)), this._card?.setEnvironment(this._config.environment), this._applePay?.setPaymentContext({
1561
- paymentId: e,
1562
- checkoutKey: t,
1563
- environment: this._config.environment,
1564
- checkoutDetails: this._paymentState.checkoutDetails,
1565
- ...this._config.additionalPaymentMethods?.applePay,
1566
- onAuthorize: (s) => this._executeAuthorization({ formData: null, applePayData: s })
1567
- }), this._paypal?.setPaymentContext({
1568
- paymentId: e,
1569
- checkoutKey: t,
1570
- onAuthorize: () => this._executeAuthorization({ formData: null })
1571
- });
1572
- }
1573
- validate() {
1574
- const e = {}, { t } = a();
1575
- return this._card?.isMounted && !this._card.isValid && (e.card = this._card.error ?? "Card details are invalid"), this._email?.isMounted && !this._email.isValid && (e.email = this._email.error ?? t("validation.emailInvalid")), this._phone?.isMounted && !this._phone.isValid && (e.phone = this._phone.error ?? t("validation.phoneNumberInvalid")), this._addressStreet?.isMounted && !this._addressStreet.isValid && (e["address.street"] = this._addressStreet.error ?? t("validation.streetRequired")), this._addressCity?.isMounted && !this._addressCity.isValid && (e["address.city"] = this._addressCity.error ?? t("validation.cityRequired")), this._addressCountry?.isMounted && !this._addressCountry.isValid && (e["address.country"] = this._addressCountry.error ?? t("validation.countryRequired")), this._addressFirstName?.isMounted && !this._addressFirstName.isValid && (e["address.firstName"] = this._addressFirstName.error ?? t("validation.firstNameRequired")), this._addressLastName?.isMounted && !this._addressLastName.isValid && (e["address.lastName"] = this._addressLastName.error ?? t("validation.lastNameRequired")), this._cardholderName?.isMounted && !this._cardholderName.isValid && (e.cardholderName = this._cardholderName.error ?? t("validation.nameRequired")), this._addressState?.isMounted && !this._addressState.isValid && (e["address.state"] = this._addressState.error ?? t("validation.stateRequired")), this._addressZipCode?.isMounted && !this._addressZipCode.isValid && (e["address.zipCode"] = this._addressZipCode.error ?? t("validation.zipCodeRequired")), this._applePay?.isMounted && !this._applePay.isValid && (e.applePay = "Apple Pay authorization required"), this._paypal?.isMounted && !this._paypal.isValid && (e.paypal = "PayPal authorization required"), { valid: Object.keys(e).length === 0, errors: e };
1576
- }
1577
- async _getPayload() {
1578
- if (this._applePay?.isMounted && this._applePay.isValid || this._paypal?.isMounted)
1579
- return null;
1580
- const e = this._email?.isMounted ? this._email.value : "", t = this._phone?.isMounted ? this._phone.value : void 0, s = this._addressStreet?.isMounted || this._addressCity?.isMounted || this._addressCountry?.isMounted || this._addressFirstName?.isMounted || this._addressLastName?.isMounted || this._cardholderName?.isMounted || this._addressState?.isMounted || this._addressZipCode?.isMounted ? {
1581
- street: this._addressStreet?.isMounted ? this._addressStreet.value : "",
1582
- city: this._addressCity?.isMounted ? this._addressCity.value : "",
1583
- country: this._addressCountry?.isMounted ? this._addressCountry.value : "",
1584
- firstName: this._addressFirstName?.isMounted ? this._addressFirstName.value : "",
1585
- lastName: this._addressLastName?.isMounted ? this._addressLastName.value : "",
1586
- state: this._addressState?.isMounted ? this._addressState.value : "",
1587
- zipCode: this._addressZipCode?.isMounted ? this._addressZipCode.value : ""
1588
- } : void 0, o = this._cardholderName?.isMounted ? this._cardholderName.value : "", i = [
1589
- s?.firstName ?? "",
1590
- s?.lastName ?? ""
1591
- ].filter(Boolean), n = o || i.join(" ");
1592
- if (this._card?.isMounted && this._card.isVgsMode)
1593
- try {
1594
- const h = await this._card.getPayload();
1595
- return {
1596
- name: n,
1597
- email: e,
1598
- phoneNumber: t || void 0,
1599
- cardNumber: "",
1600
- cardExpiry: "",
1601
- cardCvv: "",
1602
- billingAddress: s,
1603
- vgsCardData: h
1604
- };
1605
- } catch {
1606
- return this._handleAuthorizationError({
1607
- message: "We couldn't securely process your card details. Please check your card information and try again.",
1608
- status: 0,
1609
- statusText: "Card Tokenization Failed"
1610
- }), null;
1611
- }
1612
- const l = this._card?.isMounted ? this._card.value : null;
1613
- return l ? {
1614
- name: n,
1615
- email: e,
1616
- phoneNumber: t || void 0,
1617
- cardNumber: l.number,
1618
- cardExpiry: l.expiry,
1619
- cardCvv: l.cvv,
1620
- billingAddress: s
1621
- } : null;
1622
- }
1623
- async authorize(e) {
1624
- if (!this._paymentState.paymentId || !this._paymentState.checkoutKey)
1625
- throw new Error("Call associatePayment() before authorize()");
1626
- if (this._applePay?.isMounted && this._applePay.isValid) {
1627
- await this._executeAuthorization({
1628
- formData: null,
1629
- applePayData: this._applePay.value
1630
- });
1631
- return;
1632
- }
1633
- if (this._paypal?.isMounted) {
1634
- await this._executeAuthorization({ formData: null });
1635
- return;
1636
- }
1637
- const t = await this._getPayload();
1638
- await this._executeAuthorization({
1639
- formData: t,
1640
- applePayData: void 0,
1641
- customCustomerData: e?.customerData
1642
- });
1643
- }
1644
- applyTheme(e) {
1645
- const t = e["--odus-font-family"];
1646
- if (t) {
1647
- this._fontCleanup?.();
1648
- const { cleanup: r } = j({ fontFamily: t });
1649
- this._fontCleanup = r;
1650
- }
1651
- for (const r of this._allElements())
1652
- r.setTheme(e);
1653
- }
1654
- resetTheme(e) {
1655
- "--odus-font-family" in e && (this._fontCleanup?.(), this._fontCleanup = void 0);
1656
- for (const t of this._allElements())
1657
- t.resetTheme(e);
1658
- }
1659
- get isValid() {
1660
- return this.validate().valid;
1661
- }
1662
- onChange(e) {
1663
- this._changeListeners.push(e);
1664
- }
1665
- destroy() {
1666
- this._fontCleanup?.(), this._card?.destroy(), this._email?.destroy(), this._phone?.destroy(), this._addressStreet?.destroy(), this._addressFirstName?.destroy(), this._addressLastName?.destroy(), this._cardholderName?.destroy(), this._addressCity?.destroy(), this._addressState?.destroy(), this._addressZipCode?.destroy(), this._addressCountry?.destroy(), this._applePay?.destroy(), this._paypal?.destroy(), this._error?.destroy(), this._changeListeners.length = 0;
1667
- }
1668
- setCallbacks(e) {
1669
- Object.assign(this._callbacks, e);
1670
- }
1671
- _trackElement(e) {
1672
- e.on("change", () => {
1673
- for (const t of this._changeListeners)
1674
- t();
1675
- });
1676
- }
1677
- _allElements() {
1678
- return [
1679
- this._card,
1680
- this._email,
1681
- this._phone,
1682
- this._addressStreet,
1683
- this._addressFirstName,
1684
- this._addressLastName,
1685
- this._cardholderName,
1686
- this._addressCity,
1687
- this._addressState,
1688
- this._addressZipCode,
1689
- this._addressCountry,
1690
- this._applePay,
1691
- this._paypal,
1692
- this._error
1693
- ].filter((e) => e !== void 0);
1694
- }
1695
- async _executeAuthorization({
1696
- formData: e,
1697
- applePayData: t,
1698
- customCustomerData: r
1699
- }) {
1700
- try {
1701
- const s = await this._apiService.authorizePayment({
1702
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1703
- paymentId: this._paymentState.paymentId,
1704
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1705
- checkoutKey: this._paymentState.checkoutKey,
1706
- formData: e,
1707
- returnUrl: this._config.returnUrl,
1708
- applePayData: t,
1709
- customCustomerData: r
1710
- });
1711
- this._handlePaymentResponse(s);
1712
- } catch (s) {
1713
- this._handleAuthorizationError(s);
1714
- }
1715
- }
1716
- _handlePaymentResponse(e) {
1717
- if (e.latestTransaction.status === "authorized") {
1718
- this._callbacks.onPaymentSucceeded?.(
1719
- e.latestTransaction.status
1720
- );
1721
- return;
1722
- }
1723
- if (e.latestTransaction.status === "failed") {
1724
- this._callbacks.onPaymentFailed?.(e.latestTransaction.status);
1725
- return;
1726
- }
1727
- e.status === "requires_action" && this._callbacks.onActionRequired?.(e.action.redirectUrl);
1728
- }
1729
- _handleAuthorizationError(e) {
1730
- const t = e.details?.message ?? "Payment failed";
1731
- this._callbacks.onPaymentFailed?.(t), this._error?.isMounted && this._error.setError(t);
1732
- }
1733
- }
1734
- export {
1735
- q as AddressCityElement,
1736
- D as AddressCountryElement,
1737
- J as AddressFirstNameElement,
1738
- K as AddressLastNameElement,
1739
- Z as AddressStateElement,
1740
- G as AddressStreetElement,
1741
- U as AddressZipCodeElement,
1742
- H as ApplePayElement,
1743
- u as BaseElement,
1744
- re as CardElement,
1745
- se as CardholderElement,
1746
- ie as EmailElement,
1747
- ne as ErrorElement,
1748
- fe as OdusElements,
1749
- ue as PayPalElement,
1750
- pe as PhoneElement
1
+ import { C as e, I as t, L as n, N as r, P as i, R as a, S as o, a as s, c, i as l, l as u, m as d, n as f, p, q as m, r as h, s as g, t as _, v, x as ee, y, z as b } from "./shared.js";
2
+ //#region libs/checkout/src/assets/styles/helperText.css?inline
3
+ var x = ".form-helper-text{color:#dc2727;font-family:var(--odus-font-family,inherit);max-height:100px;margin-top:4px;font-size:12px;font-weight:500;transition:max-height .3s ease-in-out,opacity .3s ease-in-out,margin .3s ease-in-out;display:block;overflow:hidden}.form-helper-text-hidden{opacity:0;max-height:0;margin-top:0;overflow:hidden}", S = ".input-wrapper{box-sizing:border-box;flex-direction:column;align-items:stretch;width:100%;min-width:0;display:flex}.input-wrapper *{box-sizing:border-box}.form-input{opacity:1;font-size:var(--odus-input-font-size,16px);font-weight:var(--odus-input-font-weight,400);letter-spacing:var(--odus-input-letter-spacing,.02em);box-shadow:0 0 0 1px var(--odus-border-color,#e0e0e0), 0 2px 4px 0 #00000012, 0 1px 1.5px 0 #0000000d;background:var(--odus-color-background,#fff);padding:var(--odus-input-padding,8px 12px);line-height:var(--odus-input-line-height,1.5);z-index:0;box-sizing:border-box;border:none;outline:none;flex:1;width:100%;min-height:0;transition:box-shadow .1s ease-in,border-radius .2s ease-in}.form-input[name=cardNumber]{padding-right:100px}.form-input-error{color:#dc2727}.form-input::placeholder{color:var(--odus-input-placeholder-color,#717173);opacity:var(--odus-input-placeholder-opacity,.3)}.form-input:focus{z-index:2;position:relative;box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}", C = ".input-label{font-family:var(--odus-font-family,inherit);font-size:var(--odus-label-font-size,14px);font-weight:var(--odus-label-font-weight,400);color:var(--odus-label-color,var(--odus-color-text,#1a1a1a));letter-spacing:var(--odus-label-letter-spacing,normal);line-height:var(--odus-label-line-height,1.4);margin-bottom:var(--odus-label-margin-bottom,6px)}", w = ":host{--odus-font-family:system-ui, sans-serif;--odus-font-size:16px;--odus-color-error:#dc2727;--odus-color-text:#1a1a1a;--odus-color-background:#fff;--odus-border-color:#e0e0e0;--odus-border-radius:6px;--odus-spacing-sm:8px;--odus-spacing-md:16px;--odus-spacing-lg:24px;--odus-input-height:44px;--odus-input-padding:8px 12px;--odus-input-font-size:var(--odus-font-size);--odus-input-font-weight:400;--odus-input-letter-spacing:.02em;--odus-input-line-height:1.5;--odus-input-placeholder-color:#717173;--odus-input-placeholder-opacity:.3;--odus-input-focus-shadow:0 0 0 1px #3297d3b3, 0 1px 1px 0 #00000012, 0 0 0 4px #3297d34d;--odus-label-font-size:14px;--odus-label-font-weight:400;--odus-label-color:var(--odus-color-text);--odus-label-letter-spacing:normal;--odus-label-line-height:1.4;--odus-label-margin-bottom:6px;--odus-card-gap:12px;--odus-button-height:48px;--odus-button-border-radius:var(--odus-border-radius)}.form-input{opacity:1;font-weight:var(--odus-input-font-weight,400);letter-spacing:var(--odus-input-letter-spacing,.02em);box-shadow:0 0 0 1px var(--odus-border-color,#e0e0e0), 0 2px 4px 0 #00000012, 0 1px 1.5px 0 #0000000d;background:var(--odus-color-background,#fff);padding:var(--odus-input-padding,8px 12px);line-height:var(--odus-input-line-height,1.5);z-index:0;box-sizing:border-box;border:none;outline:none;flex:1;width:100%;min-height:0;transition:box-shadow .1s ease-in,border-radius .2s ease-in}.form-input::placeholder{color:var(--odus-input-placeholder-color,#717173);opacity:var(--odus-input-placeholder-opacity,.3)}.form-input:focus{box-shadow:var(--odus-input-focus-shadow,0 0 0 1px #3297d3b3, 0 1px 1px 0 #00000012, 0 0 0 4px #3297d34d);z-index:2;position:relative}.input-label{font-family:var(--odus-font-family,inherit)!important;font-size:var(--odus-label-font-size,14px)!important;font-weight:var(--odus-label-font-weight,400)!important;color:var(--odus-label-color,var(--odus-color-text,#1a1a1a))!important;letter-spacing:var(--odus-label-letter-spacing,normal)!important;line-height:var(--odus-label-line-height,1.4)!important;margin-bottom:var(--odus-label-margin-bottom,6px)!important}.form-helper-text{font-family:var(--odus-font-family,inherit)!important}", T = class {
4
+ shadowRoot = null;
5
+ host = null;
6
+ options = {};
7
+ listeners = /* @__PURE__ */ new Map();
8
+ get isMounted() {
9
+ return this.host !== null;
10
+ }
11
+ mount(e) {
12
+ this.isMounted && this.unmount();
13
+ let t = typeof e == "string" ? document.querySelector(e) : e;
14
+ if (!t) throw Error(`[BaseElement] mount target not found: ${String(e)}`);
15
+ this.host = document.createElement("div"), this.shadowRoot = this.host.attachShadow({ mode: "open" });
16
+ let n = document.createElement("style");
17
+ n.textContent = this.getCss(), this.shadowRoot.appendChild(n), t.appendChild(this.host), this.render(), this.emit("ready");
18
+ }
19
+ unmount() {
20
+ this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null;
21
+ }
22
+ destroy() {
23
+ this.unmount(), this.listeners.clear();
24
+ }
25
+ on(e, t) {
26
+ let n = this.listeners.get(e) ?? [];
27
+ return n.push(t), this.listeners.set(e, n), this;
28
+ }
29
+ update(e) {
30
+ if (this.options = {
31
+ ...this.options,
32
+ ...e
33
+ }, this.shadowRoot) {
34
+ let e = this.shadowRoot.querySelector("style");
35
+ e && (e.textContent = this.getCss()), this.render();
36
+ }
37
+ }
38
+ setTheme(e) {
39
+ if (this.host) for (let [t, n] of Object.entries(e)) this.host.style.setProperty(t, n);
40
+ }
41
+ resetTheme(e) {
42
+ if (this.host) for (let t of Object.keys(e)) this.host.style.removeProperty(t);
43
+ }
44
+ get value() {
45
+ return this.getValue();
46
+ }
47
+ get isValid() {
48
+ return this.getIsValid();
49
+ }
50
+ get error() {
51
+ return this.getError();
52
+ }
53
+ emit(e, t) {
54
+ let n = this.listeners.get(e) ?? [];
55
+ for (let e of n) e(t);
56
+ this.options.callbacks?.[e]?.(t);
57
+ }
58
+ getCss() {
59
+ return w;
60
+ }
61
+ }, E = class extends T {
62
+ _value = "";
63
+ _error = null;
64
+ _input = null;
65
+ render() {
66
+ if (!this.shadowRoot) return;
67
+ this._input?.getElement().remove();
68
+ let { t: e } = o();
69
+ this._input = new u({
70
+ name: "billingAddress.city",
71
+ label: e("address.townCity"),
72
+ error: !1,
73
+ placeholder: e("address.placeholder.city"),
74
+ value: this._value,
75
+ autocomplete: "address-level2",
76
+ onChange: (e) => {
77
+ this._value = e.target.value, this._error = null, this.emit("change", this._value);
78
+ }
79
+ }), this._input.addEventListener("blur", () => {
80
+ let { t: e } = o();
81
+ this._error = this._value.trim() ? null : e("validation.townCityRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
82
+ }), this.shadowRoot.appendChild(this._input.getElement());
83
+ }
84
+ getCss() {
85
+ return super.getCss() + [
86
+ S,
87
+ C,
88
+ x
89
+ ].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
90
+ }
91
+ getValue() {
92
+ return this._value;
93
+ }
94
+ getIsValid() {
95
+ return !!this._value.trim();
96
+ }
97
+ getError() {
98
+ return this._error;
99
+ }
100
+ }, D = ".form-select{opacity:1;letter-spacing:.02em;padding:var(--odus-input-padding,8px 12px);z-index:0;box-sizing:border-box;cursor:pointer;appearance:none;background:#fff url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2 3.5L5 6.5L8 3.5' stroke='%23717173' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E\") right 12px center no-repeat;border:none;outline:none;flex:1;width:100%;min-height:0;padding-right:32px;font-weight:400;line-height:1.5;transition:box-shadow .1s ease-in,border-radius .2s ease-in;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d}.form-select-error{color:#dc2727}.form-select-placeholder{color:#d4d4d5}.form-select option[disabled]{color:#717173;opacity:.5}.form-select:focus{z-index:2;position:relative;box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}", O = class extends T {
101
+ _value = "";
102
+ _error = null;
103
+ _select = null;
104
+ _allowedCountries;
105
+ setCountries(e) {
106
+ this._allowedCountries = e.length > 0 ? e : void 0, this._value && this._allowedCountries && !this._allowedCountries.includes(this._value) && (this._value = "", this._error = null, this.emit("change", this._value)), this.shadowRoot && this.render();
107
+ }
108
+ render() {
109
+ if (!this.shadowRoot) return;
110
+ this._select?.getElement().remove(), this.options.initialValue && !this._value && (this._value = String(this.options.initialValue));
111
+ let { t: e, locale: t } = o();
112
+ this._select = new c({
113
+ name: "billingAddress.country",
114
+ label: e("address.chooseCountry"),
115
+ error: !1,
116
+ placeholder: e("address.chooseCountry"),
117
+ value: this._value,
118
+ options: d(this._allowedCountries, t),
119
+ autocomplete: "country",
120
+ onChange: (e) => {
121
+ this._value = e.target.value, this._error = null, this.emit("change", this._value);
122
+ }
123
+ }), this._select.addEventListener("blur", () => {
124
+ let { t: e } = o();
125
+ this._error = this._value ? null : e("validation.countryRequired"), this._select?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
126
+ }), this.shadowRoot.appendChild(this._select.getElement());
127
+ }
128
+ getCss() {
129
+ return super.getCss() + [
130
+ C,
131
+ x,
132
+ D
133
+ ].join("\n") + "\n :host { display: block; }\n .form-select {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background-color: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-select:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-select-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
134
+ }
135
+ getValue() {
136
+ return this._value;
137
+ }
138
+ getIsValid() {
139
+ return !!this._value;
140
+ }
141
+ getError() {
142
+ return this._error;
143
+ }
144
+ }, k = class extends T {
145
+ _value = "";
146
+ _error = null;
147
+ _input = null;
148
+ render() {
149
+ if (!this.shadowRoot) return;
150
+ this._input?.getElement().remove();
151
+ let { t: e } = o();
152
+ this._input = new u({
153
+ name: "billingAddress.firstName",
154
+ label: e("address.firstName"),
155
+ error: !1,
156
+ placeholder: e("address.placeholder.firstName"),
157
+ value: this._value,
158
+ autocomplete: "given-name",
159
+ onChange: (e) => {
160
+ this._value = e.target.value, this._error = null, this.emit("change", this._value);
161
+ }
162
+ }), this._input.addEventListener("blur", () => {
163
+ let { t: e } = o();
164
+ this._error = this._value.trim() ? null : e("validation.firstNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
165
+ }), this.shadowRoot.appendChild(this._input.getElement());
166
+ }
167
+ getCss() {
168
+ return super.getCss() + [
169
+ S,
170
+ C,
171
+ x
172
+ ].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
173
+ }
174
+ getValue() {
175
+ return this._value;
176
+ }
177
+ getIsValid() {
178
+ return !!this._value.trim();
179
+ }
180
+ getError() {
181
+ return this._error;
182
+ }
183
+ }, A = class extends T {
184
+ _value = "";
185
+ _error = null;
186
+ _input = null;
187
+ render() {
188
+ if (!this.shadowRoot) return;
189
+ this._input?.getElement().remove();
190
+ let { t: e } = o();
191
+ this._input = new u({
192
+ name: "billingAddress.lastName",
193
+ label: e("address.lastName"),
194
+ error: !1,
195
+ placeholder: e("address.placeholder.lastName"),
196
+ value: this._value,
197
+ autocomplete: "family-name",
198
+ onChange: (e) => {
199
+ this._value = e.target.value, this._error = null, this.emit("change", this._value);
200
+ }
201
+ }), this._input.addEventListener("blur", () => {
202
+ let { t: e } = o();
203
+ this._error = this._value.trim() ? null : e("validation.lastNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
204
+ }), this.shadowRoot.appendChild(this._input.getElement());
205
+ }
206
+ getCss() {
207
+ return super.getCss() + [
208
+ S,
209
+ C,
210
+ x
211
+ ].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
212
+ }
213
+ getValue() {
214
+ return this._value;
215
+ }
216
+ getIsValid() {
217
+ return !!this._value.trim();
218
+ }
219
+ getError() {
220
+ return this._error;
221
+ }
222
+ }, j = new Set(["US", "CA"]), M = class extends T {
223
+ _value = "";
224
+ _country = "";
225
+ _input = null;
226
+ _select = null;
227
+ setCountry(e) {
228
+ let t = this._country;
229
+ if (this._country = e, !this.shadowRoot) return;
230
+ let n = j.has(t), r = j.has(e);
231
+ if (n && r && t !== e) {
232
+ let { t } = o(), n = e, r = t(n === "US" ? "address.chooseState" : "address.chooseProvince");
233
+ this._select?.setOptions(p(n), r), this._value = "";
234
+ return;
235
+ }
236
+ n !== r && (this._value = "", this.render());
237
+ }
238
+ render() {
239
+ if (this.shadowRoot) if (this._input?.getElement().remove(), this._select?.getElement().remove(), this._input = null, this._select = null, j.has(this._country)) {
240
+ let e = this._country;
241
+ this._renderSelect(e);
242
+ } else this._renderInput();
243
+ }
244
+ _renderInput() {
245
+ let { t: e } = o();
246
+ this._input = new u({
247
+ name: "billingAddress.state",
248
+ label: e("address.state"),
249
+ error: !1,
250
+ placeholder: e("address.state"),
251
+ value: this._value,
252
+ autocomplete: "address-level1",
253
+ onChange: (e) => {
254
+ this._value = e.target.value, this.emit("change", this._value);
255
+ }
256
+ }), this._input.addEventListener("blur", () => {
257
+ this.emit("blur", this._value);
258
+ }), this.shadowRoot.appendChild(this._input.getElement());
259
+ }
260
+ _renderSelect(e) {
261
+ let { t } = o(), n = p(e), r = t(e === "US" ? "address.chooseState" : "address.chooseProvince");
262
+ this._select = new c({
263
+ name: "billingAddress.state",
264
+ label: t("address.state"),
265
+ error: !1,
266
+ placeholder: r,
267
+ value: this._value,
268
+ options: n,
269
+ autocomplete: "address-level1",
270
+ onChange: (e) => {
271
+ this._value = e.target.value, this.emit("change", this._value);
272
+ }
273
+ }), this._select.addEventListener("blur", () => {
274
+ this.emit("blur", this._value);
275
+ }), this.shadowRoot.appendChild(this._select.getElement());
276
+ }
277
+ getCss() {
278
+ return super.getCss() + [
279
+ S,
280
+ C,
281
+ x,
282
+ D
283
+ ].join("\n") + "\n :host { display: block; }\n .form-input,\n .form-select {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus,\n .form-select:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error,\n .form-select-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
284
+ }
285
+ getValue() {
286
+ return this._value;
287
+ }
288
+ getIsValid() {
289
+ return !0;
290
+ }
291
+ getError() {
292
+ return null;
293
+ }
294
+ }, N = class extends T {
295
+ _value = "";
296
+ _error = null;
297
+ _input = null;
298
+ render() {
299
+ if (!this.shadowRoot) return;
300
+ this._input?.getElement().remove();
301
+ let { t: e } = o();
302
+ this._input = new u({
303
+ name: "billingAddress.street",
304
+ label: e("address.addressLine1"),
305
+ error: !1,
306
+ placeholder: e("address.placeholder.street"),
307
+ value: this._value,
308
+ autocomplete: "street-address",
309
+ maxLength: this.options.maxLength,
310
+ onChange: (t) => {
311
+ if (this._value = t.target.value, this._error = null, this.options.maxLength && this._value.length >= this.options.maxLength) {
312
+ let t = e("validation.maxLengthExceeded");
313
+ this._error = t.replace("{{max}}", String(this.options.maxLength)), this._input?.setError(!0, this._error);
314
+ } else this._input?.setError(!1);
315
+ this.emit("change", this._value);
316
+ }
317
+ }), this._input.addEventListener("blur", () => {
318
+ let { t: e } = o();
319
+ this._error = this._value.trim() ? null : e("validation.addressLine1Required"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
320
+ }), this.shadowRoot.appendChild(this._input.getElement());
321
+ }
322
+ getCss() {
323
+ return super.getCss() + [
324
+ S,
325
+ C,
326
+ x
327
+ ].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
328
+ }
329
+ getValue() {
330
+ return this._value;
331
+ }
332
+ getIsValid() {
333
+ return !!this._value.trim();
334
+ }
335
+ getError() {
336
+ return this._error;
337
+ }
338
+ }, P = class extends T {
339
+ _value = "";
340
+ _error = null;
341
+ _input = null;
342
+ render() {
343
+ if (!this.shadowRoot) return;
344
+ this._input?.getElement().remove();
345
+ let { t: e } = o();
346
+ this._input = new u({
347
+ name: "billingAddress.zipCode",
348
+ label: e("address.postalCode"),
349
+ error: !1,
350
+ placeholder: e("address.placeholder.zipCode"),
351
+ value: this._value,
352
+ autocomplete: "postal-code",
353
+ onChange: (e) => {
354
+ this._value = e.target.value, this._error = null, this.emit("change", this._value);
355
+ }
356
+ }), this._input.addEventListener("blur", () => {
357
+ let { t: e } = o();
358
+ this._error = this._value.trim() ? null : e("validation.postalCodeRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
359
+ }), this.shadowRoot.appendChild(this._input.getElement());
360
+ }
361
+ getCss() {
362
+ return super.getCss() + [
363
+ S,
364
+ C,
365
+ x
366
+ ].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
367
+ }
368
+ getValue() {
369
+ return this._value;
370
+ }
371
+ getIsValid() {
372
+ return !!this._value.trim();
373
+ }
374
+ getError() {
375
+ return this._error;
376
+ }
377
+ }, F = "apple-pay-button{appearance:-apple-pay-button;-apple-pay-button-type:plain;-apple-pay-button-style:black;cursor:pointer;box-sizing:border-box;border-radius:4px;width:100%;height:40px;min-height:40px;display:inline-block}apple-pay-button:hover{filter:brightness(.9)}", I = {
378
+ name: "odus-elements",
379
+ styles: {
380
+ fontSize: 14,
381
+ textColor: "#000000",
382
+ buttonColor: "#0070f3",
383
+ borderRadius: 4,
384
+ fontFamily: "system-ui",
385
+ buttonTextColor: "#ffffff",
386
+ buttonFontSize: 16
387
+ },
388
+ layout: {
389
+ actionButton: { translationKey: null },
390
+ billingFields: {
391
+ street: { enabled: !1 },
392
+ city: { enabled: !1 },
393
+ state: { enabled: !1 },
394
+ zipCode: { enabled: !1 },
395
+ firstName: { enabled: !1 },
396
+ lastName: { enabled: !1 },
397
+ country: { enabled: !1 }
398
+ }
399
+ },
400
+ additionalPaymentMethods: {}
401
+ }, L = class extends T {
402
+ _paymentContext = null;
403
+ _applePayData = null;
404
+ _authorized = !1;
405
+ _button = null;
406
+ setPaymentContext(e) {
407
+ this._paymentContext = e, this.isMounted && this.render();
408
+ }
409
+ render() {
410
+ if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext)) return;
411
+ let { paymentId: e, checkoutKey: t, environment: n, checkoutDetails: r, displayName: i, countries: a, requiredBillingContactFields: o, requiredShippingContactFields: s, onAuthorize: c } = this._paymentContext;
412
+ a?.length && r?.countryCode && !a.map((e) => e.toUpperCase()).includes(r.countryCode.toUpperCase()) || (this._button = new h({
413
+ checkoutProfile: I,
414
+ paymentId: e,
415
+ checkoutKey: t,
416
+ environment: n,
417
+ checkoutDetails: r,
418
+ displayName: i,
419
+ requiredBillingContactFields: o,
420
+ requiredShippingContactFields: s,
421
+ onSubmit: async ({ applePayData: e }) => {
422
+ e && (this._applePayData = e, this._authorized = !0, this.emit("change", e), await c(e));
423
+ }
424
+ }), this.shadowRoot.appendChild(this._button.getElement()));
425
+ }
426
+ getCss() {
427
+ return super.getCss() + F + "\n :host { display: block; }\n apple-pay-button {\n width: 100%;\n height: var(--odus-button-height, 48px);\n border-radius: var(--odus-button-border-radius, 6px);\n }\n ";
428
+ }
429
+ getValue() {
430
+ return this._applePayData;
431
+ }
432
+ getIsValid() {
433
+ return this._authorized;
434
+ }
435
+ getError() {
436
+ return null;
437
+ }
438
+ }, R = ".card-element{border-radius:inherit;box-sizing:border-box;background:#fff;border:none;height:38.5px;padding:0;transition:box-shadow .1s ease-in;position:relative;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d}.card-element iframe{width:100%;min-width:0;display:block}.card-element-focus{box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}.card-icon{opacity:1;width:18px;transition:opacity .6s ease-in}.card-icon img{max-width:100%;height:auto;display:block}.cards-position{z-index:10;pointer-events:none;align-items:center;gap:8px;display:flex;position:absolute;top:50%;right:12px;transform:translateY(-50%)}.loading{position:relative}.loading:after{content:\"\";border-radius:inherit;background-color:#fff;width:100%;height:100%;position:absolute;inset:0}@media only screen and (min-width:600px){.card-icon{width:20px}}.vgs-card-group iframe,.vgs-wrap iframe{width:100%;min-width:0;display:block}.fake-ph{color:#717173;opacity:.3;font-size:var(--odus-input-font-size,16px);letter-spacing:.02em;font-weight:400;line-height:1.5;font-family:var(--odus-font-family,inherit);pointer-events:none;-webkit-user-select:none;user-select:none;white-space:nowrap;z-index:0;background:#fff;align-items:center;padding:8px 12px;display:flex;position:absolute;inset:0}@keyframes vgs-shimmer{0%{background-position:-200% 0}to{background-position:200% 0}}.vgs-field-skeleton{pointer-events:none;z-index:11;border-radius:inherit;background:linear-gradient(90deg,#f7f7f7 25%,#fdfdfd 50%,#f7f7f7 75%) 0 0/200% 100%;animation:1.5s ease-in-out infinite vgs-shimmer;position:absolute;inset:0}", z = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvWpIQFjQQCPpaIlJKpegirp5kLkzLB1AxHmnLk73D3TJbAGqr1QmlsWDBtMPMRpdzzUM7ZwX3kzhIuATV4Pe7RKp3nZlVmcrT0YCQXBrTwqZNh775z58GP2kZs+gVfNqBampJPzSB/hB62KkByhECn6grrRjiAVwJyZVEvs/2vrxaEpO+aE16emtX12RgI5JdzdOiNyZEQteU6zRBRJEocPWVxExaOpVVVJ5+UnW0LcalzA+lRGRTrQJ5JguAPiAOzRPTK/lYFFpCAl/F8wtoAVG1c8zO2NcQ0Pko+fmeidRFxJ/did2btV+9Mkze3mBphwFmvnxa35LF+Cs/XJHDwIDAQAB", B = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA8gGPMwBRPuVyJReZGIkWH/+Bf5pnpDN1bSR2cLYLXVT8CaSnTw74qeboSnktgYCi1D9R3Bj2fYzTIwGGZb8KinLdxwbqZmHwrE9cFhCaHbG/E0PbqQGhXP2vbniZTT4M0i0Cbi7ES3Bw5zqNbIZZnX041QEpxLvIyWPKZCX+fBogNMhWfCF779aclChjHkwZMsufThVWE9xklWGxXiytx5aL4I5JPxq0I7cAkZGGs4aF/GxWwPaq7R3wPikJQ0YHnCMfcURzl2Hnw/inqyMy+JB6djTq2/BdzMAhWTh3cDWq9Xu+gEkb/QCd0n1yYIdKuDISlk/AfHdWe34IvzhVyQIDAQAB", V = {
439
+ name: "odus-elements",
440
+ styles: {
441
+ fontSize: 14,
442
+ textColor: "#000000",
443
+ buttonColor: "#0070f3",
444
+ borderRadius: 4,
445
+ fontFamily: "system-ui",
446
+ buttonTextColor: "#ffffff",
447
+ buttonFontSize: 16
448
+ },
449
+ layout: {
450
+ actionButton: { translationKey: null },
451
+ billingFields: {
452
+ street: { enabled: !0 },
453
+ city: { enabled: !0 },
454
+ state: { enabled: !0 },
455
+ zipCode: { enabled: !0 },
456
+ firstName: { enabled: !0 },
457
+ lastName: { enabled: !0 },
458
+ country: { enabled: !0 }
459
+ }
460
+ },
461
+ additionalPaymentMethods: {}
462
+ }, H = class {
463
+ _cardNumber = "";
464
+ _cardExpiry = "";
465
+ _cardCvv = "";
466
+ _section = null;
467
+ _focusManager = new v();
468
+ _touchedFields = /* @__PURE__ */ new Set();
469
+ _focusHandlers = [];
470
+ get section() {
471
+ return this._section;
472
+ }
473
+ renderSection(e, t, n) {
474
+ this._section?.getElement().remove();
475
+ let { t: a } = o();
476
+ this._section = new s({
477
+ checkoutProfile: V,
478
+ cardNumber: this._cardNumber,
479
+ cardNumberTouched: !1,
480
+ cardCvv: this._cardCvv,
481
+ cardCvvTouched: !1,
482
+ cardExpiry: this._cardExpiry,
483
+ cardExpiryTouched: !1,
484
+ translationFunc: a,
485
+ onChange: (e) => {
486
+ let n = e.target;
487
+ if (n.name === "cardNumber") this._cardNumber = n.value;
488
+ else if (n.name === "cardExpiry") {
489
+ let e = i.cardExpiry(n.value);
490
+ this._cardExpiry = e, this._section?.updateCardExpiry(e);
491
+ } else n.name === "cardCvv" && (this._cardCvv = n.value);
492
+ this._touchedFields.add(n.name), this._updateFocusManagerState(), t(this.getValue());
493
+ },
494
+ onBlur: (e) => {
495
+ let t = e.target, i = t.name ?? "cardExpiry", a = r();
496
+ if (this._touchedFields.add(i), t.name === "cardNumber") {
497
+ let e = a.cardNumber(this._cardNumber);
498
+ this._section?.updateCardNumber(this._cardNumber, e, !0);
499
+ } else if (t.name === "cardCvv") {
500
+ let e = a.cardCvv(this._cardCvv, this._cardNumber);
501
+ this._section?.updateCardCvv(this._cardCvv, e, !0);
502
+ } else {
503
+ let e = a.cardExpiry(this._cardExpiry);
504
+ this._section?.updateCardExpiry(this._cardExpiry, e, !0);
505
+ }
506
+ this._updateFocusManagerState(), n(this.getValue());
507
+ }
508
+ }), e.appendChild(this._section.getElement()), this._registerFocusFields();
509
+ }
510
+ getValue() {
511
+ return {
512
+ number: this._cardNumber,
513
+ expiry: this._cardExpiry,
514
+ cvv: this._cardCvv
515
+ };
516
+ }
517
+ async getPayload(e) {
518
+ let t = e === "live" ? B : z, n = new b();
519
+ n.setPublicKey(t);
520
+ let r = this._cardNumber.replace(/\s+/g, ""), i = this._cardExpiry.replace(/\s+/g, "").split("/"), a = i[0] ?? "", o = i[1] ?? "";
521
+ return o.length === 2 && (o = `20${o}`), {
522
+ encryptedCardNumber: n.encrypt(r),
523
+ encryptedCvv: n.encrypt(this._cardCvv),
524
+ expMonth: a,
525
+ expYear: o
526
+ };
527
+ }
528
+ isValid() {
529
+ let e = r(), t = this._cardCvv.length >= 3;
530
+ return !e.cardNumber(this._cardNumber) && !e.cardExpiry(this._cardExpiry) && t;
531
+ }
532
+ getError() {
533
+ let e = r();
534
+ return e.cardNumber(this._cardNumber) ?? e.cardExpiry(this._cardExpiry) ?? null;
535
+ }
536
+ destroy() {
537
+ this._cleanupFocusHandlers(), this._section = null;
538
+ }
539
+ _registerFocusFields() {
540
+ if (this._cleanupFocusHandlers(), !this._section) return;
541
+ let e = this._section.getElement();
542
+ this._focusManager.registerField("cardNumber", { focus: () => this._section?.focusField("cardNumber") }), this._focusManager.registerField("cardExpiry", { focus: () => this._section?.focusField("cardExpiry") }), this._focusManager.registerField("cardCvv", { focus: () => this._section?.focusField("cardCvv") });
543
+ for (let t of [
544
+ "cardNumber",
545
+ "cardExpiry",
546
+ "cardCvv"
547
+ ]) {
548
+ let n = e.querySelector(`input[name="${t}"]`);
549
+ if (!n) continue;
550
+ let r = () => this._focusManager.handleFieldFocus(t);
551
+ n.addEventListener("focus", r), this._focusHandlers.push(() => n.removeEventListener("focus", r));
552
+ }
553
+ }
554
+ _cleanupFocusHandlers() {
555
+ for (let e of this._focusHandlers) e();
556
+ this._focusHandlers = [];
557
+ }
558
+ _updateFocusManagerState() {
559
+ let e = r(), t = {
560
+ cardNumber: this._cardNumber,
561
+ cardExpiry: this._cardExpiry,
562
+ cardCvv: this._cardCvv,
563
+ name: "",
564
+ email: ""
565
+ }, n = {}, i = e.cardNumber(this._cardNumber), a = e.cardExpiry(this._cardExpiry), o = e.cardCvv(this._cardCvv, this._cardNumber);
566
+ i && (n.cardNumber = i), a && (n.cardExpiry = a), o && (n.cardCvv = o);
567
+ let s = {};
568
+ for (let e of this._touchedFields) s[e] = !0;
569
+ this._focusManager.handleStateUpdate(t, n, s);
570
+ }
571
+ }, U = class {
572
+ _vgsService;
573
+ _vgsJwt;
574
+ _vgsState = {};
575
+ _vgsFieldsValid = !1;
576
+ _vgsReinitTimer = null;
577
+ _currentTheme = {};
578
+ _environment = "test";
579
+ _section = null;
580
+ constructor(e, n) {
581
+ this._vgsJwt = e, this._environment = n, this._vgsService = new t();
582
+ }
583
+ get section() {
584
+ return this._section;
585
+ }
586
+ renderSection(e, t) {
587
+ this._section?.getElement().remove();
588
+ let { t: n } = o();
589
+ this._section = new s({
590
+ checkoutProfile: V,
591
+ cardNumber: "",
592
+ cardNumberTouched: !1,
593
+ cardCvv: "",
594
+ cardCvvTouched: !1,
595
+ cardExpiry: "",
596
+ cardExpiryTouched: !1,
597
+ translationFunc: n,
598
+ onChange: () => {},
599
+ onBlur: () => {},
600
+ vgsService: this._vgsService
601
+ }), e.appendChild(this._section.getElement()), this._onChangeEmit = t;
602
+ }
603
+ _onChangeEmit = null;
604
+ initVgs() {
605
+ this._vgsService.init(this._environment).then((e) => {
606
+ this._vgsService.createForm(e, (e) => this._handleStateChange(e)), this._mountFields();
607
+ });
608
+ }
609
+ async getPayload() {
610
+ if (!this._vgsJwt) throw Error("VGS not initialized");
611
+ let e = await this._vgsService.createCard(this._vgsJwt);
612
+ return {
613
+ cardId: e.cardId,
614
+ expMonth: e.expMonth,
615
+ expYear: e.expYear,
616
+ name: e.name
617
+ };
618
+ }
619
+ isValid() {
620
+ return this._vgsFieldsValid;
621
+ }
622
+ getError() {
623
+ let { t: e } = o();
624
+ for (let [t, n] of Object.entries(this._vgsState)) {
625
+ if (!n?.isTouched || n.isFocused || n.isValid) continue;
626
+ let r = n.errors?.[0];
627
+ if (!r) continue;
628
+ let i = g(t, r.code);
629
+ if (i) return e(i);
630
+ }
631
+ return null;
632
+ }
633
+ applyTheme(e) {
634
+ if (this._currentTheme = {
635
+ ...this._currentTheme,
636
+ ...e
637
+ }, !this._section) return;
638
+ let t = this._buildProfileFromTheme(this._currentTheme), n = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
639
+ this._section.updateVgsWrapperStyles(n, t.styles.borderRadius), this._reinitWithTheme();
640
+ }
641
+ destroy() {
642
+ this._vgsReinitTimer &&= (clearTimeout(this._vgsReinitTimer), null), this._vgsService.destroy(), this._section = null;
643
+ }
644
+ _reinitWithTheme() {
645
+ this._vgsReinitTimer && clearTimeout(this._vgsReinitTimer), this._vgsReinitTimer = setTimeout(() => {
646
+ this._vgsReinitTimer = null, this._vgsService.destroy(), this._vgsService = new t(), this.initVgs();
647
+ }, 300);
648
+ }
649
+ _buildProfileFromTheme(e) {
650
+ let t = e["--odus-input-font-size"] ?? e["--odus-font-size"] ?? `${V.styles.fontSize}px`, n = e["--odus-font-family"] ?? V.styles.fontFamily, r = e["--odus-color-text"] ?? V.styles.textColor, i = e["--odus-border-radius"] ?? `${V.styles.borderRadius}px`;
651
+ return {
652
+ ...V,
653
+ styles: {
654
+ ...V.styles,
655
+ fontSize: parseInt(t, 10) || V.styles.fontSize,
656
+ fontFamily: n,
657
+ textColor: r,
658
+ borderRadius: parseInt(i, 10) || V.styles.borderRadius
659
+ }
660
+ };
661
+ }
662
+ async _mountFields() {
663
+ if (!this._section) return;
664
+ let e = Object.keys(this._currentTheme).length > 0 ? this._buildProfileFromTheme(this._currentTheme) : V, t = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
665
+ this._section.updateVgsWrapperStyles(t, e.styles.borderRadius);
666
+ let n = this._section.getVgsContainerIds();
667
+ for (let e of Object.values(n)) {
668
+ if (!e) continue;
669
+ let t = document.getElementById(e);
670
+ t && t.querySelectorAll("iframe").forEach((e) => e.remove());
671
+ }
672
+ let r = await y(e.styles.fontFamily), i = this._section.buildVgsFieldCss(e, r, {
673
+ borderColor: t,
674
+ backgroundColor: this._currentTheme["--odus-color-background"],
675
+ placeholderColor: this._currentTheme["--odus-input-placeholder-color"],
676
+ placeholderOpacity: this._currentTheme["--odus-input-placeholder-opacity"],
677
+ padding: this._currentTheme["--odus-input-padding"]
678
+ }), { t: a } = o();
679
+ this._vgsService.mountCardFields({
680
+ cardNumber: n.cardNumber ? `#${n.cardNumber}` : void 0,
681
+ cardExpiry: n.cardExpiry ? `#${n.cardExpiry}` : void 0,
682
+ cardCvv: n.cardCvv ? `#${n.cardCvv}` : void 0
683
+ }, i, {
684
+ cardNumber: "1234 5678 9012 3456",
685
+ cardExpiry: a("cardExpiry"),
686
+ cardCvv: "CVV",
687
+ cardholderName: a("cardholderName")
688
+ }, (e) => {
689
+ this._section?.updateVgsCardBrand(e);
690
+ }), this._vgsService.waitForFieldsReady().then(() => {
691
+ this._section?.hideFakePlaceholders();
692
+ });
693
+ }
694
+ _handleStateChange(e) {
695
+ this._vgsState = e, this._vgsFieldsValid = Object.values(e).every((e) => e?.isValid === !0);
696
+ let { t } = o(), n = this._deriveFieldErrors(t);
697
+ this._section?.handleVgsStateChange(e, n), this._onChangeEmit?.();
698
+ }
699
+ _deriveFieldErrors(e) {
700
+ let t = {};
701
+ for (let [n, r] of Object.entries(this._vgsState)) {
702
+ if (!r?.isTouched || r.isFocused || r.isValid) continue;
703
+ let i = r.errors?.[0];
704
+ if (!i) continue;
705
+ let a = g(n, i.code);
706
+ a && (t[n] = e(a));
707
+ }
708
+ return t;
709
+ }
710
+ }, W = class extends T {
711
+ _environment = "test";
712
+ _isVgsMode = !1;
713
+ _mountContainer = null;
714
+ _nativeAdapter = new H();
715
+ _vgsAdapter = null;
716
+ get isVgsMode() {
717
+ return this._isVgsMode;
718
+ }
719
+ setEnvironment(e) {
720
+ this._environment = e;
721
+ }
722
+ setVgsJwt(e) {
723
+ this._isVgsMode = !0, this._vgsAdapter = new U(e, this._environment), this.isMounted && this._mountContainer && (this.unmount(), this.mount(this._mountContainer));
724
+ }
725
+ mount(e) {
726
+ this.isMounted && this.unmount();
727
+ let t = typeof e == "string" ? document.querySelector(e) : e;
728
+ if (!t) throw Error(`[CardElement] mount target not found: ${String(e)}`);
729
+ if (this._mountContainer = e, this._isVgsMode) {
730
+ this.host = document.createElement("div");
731
+ let e = document.createElement("style");
732
+ e.textContent = this.getCss(), this.host.appendChild(e), t.appendChild(this.host), this.render(), this._vgsAdapter?.initVgs(), this.emit("ready");
733
+ } else super.mount(e);
734
+ }
735
+ unmount() {
736
+ this._isVgsMode ? (this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null) : super.unmount();
737
+ }
738
+ render() {
739
+ if (this._isVgsMode) {
740
+ if (!this.host || !this._vgsAdapter) return;
741
+ this._vgsAdapter.renderSection(this.host, () => this.emit("change", this.getValue()));
742
+ } else {
743
+ if (!this.shadowRoot) return;
744
+ this._nativeAdapter.renderSection(this.shadowRoot, (e) => this.emit("change", e), (e) => this.emit("blur", e));
745
+ }
746
+ }
747
+ focus() {
748
+ (this._isVgsMode ? this._vgsAdapter?.section : this._nativeAdapter.section)?.focus();
749
+ }
750
+ focusField(e) {
751
+ (this._isVgsMode ? this._vgsAdapter?.section : this._nativeAdapter.section)?.focusField(e);
752
+ }
753
+ destroy() {
754
+ this._nativeAdapter.destroy(), this._vgsAdapter?.destroy(), this._vgsAdapter = null, super.destroy();
755
+ }
756
+ setTheme(e) {
757
+ super.setTheme(e), !(!this._isVgsMode || !this._vgsAdapter) && this._vgsAdapter.applyTheme(e);
758
+ }
759
+ getCss() {
760
+ return super.getCss() + [
761
+ S,
762
+ C,
763
+ x,
764
+ R
765
+ ].join("\n") + "\n :host { display: block; }\n .card-grid {\n display: flex;\n flex-direction: column;\n gap: var(--odus-card-gap, 12px);\n }\n .card-details {\n display: flex;\n gap: var(--odus-card-gap, 12px);\n }\n .form-input,\n .form-select {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus,\n .form-select:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error,\n .form-select-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
766
+ }
767
+ getValue() {
768
+ return this._isVgsMode ? {
769
+ number: "",
770
+ expiry: "",
771
+ cvv: ""
772
+ } : this._nativeAdapter.getValue();
773
+ }
774
+ async getPayload() {
775
+ if (this._isVgsMode) {
776
+ if (!this._vgsAdapter) throw Error("VGS not initialized");
777
+ return this._vgsAdapter.getPayload();
778
+ }
779
+ return this._nativeAdapter.getPayload(this._environment);
780
+ }
781
+ getIsValid() {
782
+ return this._isVgsMode ? this._vgsAdapter?.isValid() ?? !1 : this._nativeAdapter.isValid();
783
+ }
784
+ getError() {
785
+ return this._isVgsMode ? this._vgsAdapter?.getError() ?? null : this._nativeAdapter.getError();
786
+ }
787
+ }, G = class extends T {
788
+ _value = "";
789
+ _error = null;
790
+ _input = null;
791
+ render() {
792
+ if (!this.shadowRoot) return;
793
+ this._input?.getElement().remove();
794
+ let { t: e } = o();
795
+ this._input = new u({
796
+ name: "billingAddress.cardholderName",
797
+ label: e("cardholderNameLabel"),
798
+ error: !1,
799
+ placeholder: e("cardholderNamePlaceholder"),
800
+ value: this._value,
801
+ autocomplete: "cc-name",
802
+ onChange: (e) => {
803
+ let t = e.target.value, n = t.replace(/[^a-zA-Z\s\-'.]/g, "");
804
+ t !== n && this._input?.setValue(n), this._value = n, this._error = null, this.emit("change", this._value);
805
+ }
806
+ }), this._input.addEventListener("blur", () => {
807
+ let { t: e } = o();
808
+ this._error = this._value.trim() ? null : e("validation.nameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
809
+ }), this.shadowRoot.appendChild(this._input.getElement());
810
+ }
811
+ getCss() {
812
+ return super.getCss() + [
813
+ S,
814
+ C,
815
+ x
816
+ ].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
817
+ }
818
+ getValue() {
819
+ return this._value;
820
+ }
821
+ getIsValid() {
822
+ return !!this._value.trim();
823
+ }
824
+ getError() {
825
+ return this._error;
826
+ }
827
+ }, K = {
828
+ name: "odus-elements",
829
+ styles: {
830
+ fontSize: 14,
831
+ textColor: "#000000",
832
+ buttonColor: "#0070f3",
833
+ borderRadius: 4,
834
+ fontFamily: "system-ui",
835
+ buttonTextColor: "#ffffff",
836
+ buttonFontSize: 16
837
+ },
838
+ layout: {
839
+ actionButton: { translationKey: null },
840
+ billingFields: {
841
+ street: { enabled: !1 },
842
+ city: { enabled: !1 },
843
+ state: { enabled: !1 },
844
+ zipCode: { enabled: !1 },
845
+ firstName: { enabled: !1 },
846
+ lastName: { enabled: !1 },
847
+ country: { enabled: !1 }
848
+ }
849
+ },
850
+ additionalPaymentMethods: {}
851
+ }, q = class extends T {
852
+ _email = "";
853
+ _error = null;
854
+ _field = null;
855
+ render() {
856
+ if (!this.shadowRoot) return;
857
+ this._field?.getElement().remove(), this.options.initialValue && !this._email && (this._email = String(this.options.initialValue));
858
+ let { t: e } = o();
859
+ this._field = new l({
860
+ value: this._email,
861
+ error: !1,
862
+ checkoutProfile: K,
863
+ translationFunc: e,
864
+ onChange: (e) => {
865
+ let t = e.target;
866
+ this._email = t.value ?? this._field?.getValue() ?? "", this._error = null, this.emit("change", this._email);
867
+ },
868
+ onBlur: () => {
869
+ let e = r();
870
+ this._error = e.email(this._email) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._email);
871
+ }
872
+ }), this.shadowRoot.appendChild(this._field.getElement());
873
+ }
874
+ getCss() {
875
+ return super.getCss() + [
876
+ S,
877
+ C,
878
+ x
879
+ ].join("\n") + "\n :host { display: block; }\n .form-input {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n }\n .form-input:focus {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
880
+ }
881
+ getValue() {
882
+ return this._email;
883
+ }
884
+ getIsValid() {
885
+ return !r().email(this._email);
886
+ }
887
+ getError() {
888
+ return this._error;
889
+ }
890
+ }, J = "@keyframes slideIn{0%{opacity:0;transform:translateY(-10px)}to{opacity:1;transform:translateY(0)}}.error-alert{background-color:#fef2f2;border:1px solid #fecaca;border-radius:8px;padding:16px;animation:.3s ease-out slideIn;box-shadow:0 1px 3px #0000001a,0 1px 2px #0000000f}.error-alert-content{align-items:flex-start;gap:12px;display:flex}.error-alert-icon-container{color:#dc2626;background-color:#fee2e2;border-radius:50%;flex-shrink:0;justify-content:center;align-items:center;width:32px;height:32px;display:flex}.error-alert-icon{color:#dc2626}.error-alert-text-container{flex:1;min-width:0}.error-alert-title{color:#991b1b;margin:0 0 4px;font-size:14px;font-weight:600;line-height:1.4}.error-alert-message{font-family:var(--odus-font-family,inherit);color:#7f1d1d;word-break:break-word;margin:0;font-size:14px;line-height:1.5}", Y = class extends T {
891
+ _alert = null;
892
+ _message = null;
893
+ render() {
894
+ this.shadowRoot && (this._alert?.getElement().remove(), this._alert = null, this._message && (this._alert = new _({ message: this._message }), this.shadowRoot.appendChild(this._alert.getElement())));
895
+ }
896
+ setError(e) {
897
+ if (this._message = e, !this.shadowRoot) {
898
+ this.emit("error", e);
899
+ return;
900
+ }
901
+ this._alert ? this._alert.setMessage(e) : (this._alert = new _({ message: e }), this.shadowRoot.appendChild(this._alert.getElement())), this.emit("error", e);
902
+ }
903
+ clearError() {
904
+ this._message = null, this._alert?.getElement().remove(), this._alert = null;
905
+ }
906
+ getCss() {
907
+ return super.getCss() + J + "\n :host { display: block; }\n .error-alert-icon,\n .error-alert-icon-container {\n color: var(--odus-color-error, #e53e3e) !important;\n }\n .error-alert-message {\n color: var(--odus-color-text, #1a1a1a) !important;\n }\n ";
908
+ }
909
+ getValue() {
910
+ return null;
911
+ }
912
+ getIsValid() {
913
+ return !0;
914
+ }
915
+ getError() {
916
+ return this._message;
917
+ }
918
+ }, X = ".paypal{color:#253b80;text-transform:none;cursor:pointer;background-color:#ffc439;border-radius:4px;padding:8px 16px;font-weight:700;box-shadow:0 2px 4px #0000001a}.paypal:hover{filter:brightness(.95);background-color:#ffc439}.paypal-icon-container{justify-content:center;align-items:center;display:flex}.paypal-icon-container img{width:69px;height:22px}", Z = {
919
+ name: "odus-elements",
920
+ styles: {
921
+ fontSize: 14,
922
+ textColor: "#000000",
923
+ buttonColor: "#0070f3",
924
+ borderRadius: 4,
925
+ fontFamily: "system-ui",
926
+ buttonTextColor: "#ffffff",
927
+ buttonFontSize: 16
928
+ },
929
+ layout: {
930
+ actionButton: { translationKey: null },
931
+ billingFields: {
932
+ street: { enabled: !1 },
933
+ city: { enabled: !1 },
934
+ state: { enabled: !1 },
935
+ zipCode: { enabled: !1 },
936
+ firstName: { enabled: !1 },
937
+ lastName: { enabled: !1 },
938
+ country: { enabled: !1 }
939
+ }
940
+ },
941
+ additionalPaymentMethods: {}
942
+ }, Q = class extends T {
943
+ _paymentContext = null;
944
+ _button = null;
945
+ setPaymentContext(e) {
946
+ this._paymentContext = e, this.isMounted && this.render();
947
+ }
948
+ render() {
949
+ if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext)) return;
950
+ let { onAuthorize: e } = this._paymentContext;
951
+ this._button = new f({
952
+ checkoutProfile: Z,
953
+ onSubmit: async () => {
954
+ this._button?.setSubmitting(!0);
955
+ try {
956
+ await e();
957
+ } finally {
958
+ this._button?.setSubmitting(!1);
959
+ }
960
+ }
961
+ }), this.shadowRoot.appendChild(this._button.getElement());
962
+ }
963
+ getCss() {
964
+ return super.getCss() + X + "\n :host { display: block; }\n .paypal {\n width: 100%;\n box-sizing: border-box;\n border-radius: var(--odus-button-border-radius, 6px);\n display: flex;\n align-items: center;\n justify-content: center;\n }\n ";
965
+ }
966
+ getValue() {
967
+ return null;
968
+ }
969
+ getIsValid() {
970
+ return !0;
971
+ }
972
+ getError() {
973
+ return null;
974
+ }
975
+ }, te = ".country-dial-code-dropdown{display:inline-block;position:relative}.country-dial-code-trigger{padding:var(--odus-input-padding,8px 12px);cursor:pointer;letter-spacing:.02em;font-weight:400;line-height:var(--odus-input-line-height,1.5);white-space:nowrap;box-sizing:border-box;background:#fff;border:none;border-right:1px solid #e0e0e0;align-items:center;gap:6px;padding-right:8px;transition:all .1s ease-in;display:flex}.country-dial-code-trigger:hover{background:#f5f5f5}.country-dial-code-trigger:focus{outline:none}.country-dial-code-trigger .country-flag{font-size:14px;line-height:1}.country-dial-code-trigger .country-chevron{color:#717173;flex-shrink:0;transition:transform .15s}.country-dial-code-trigger[aria-expanded=true] .country-chevron{transform:rotate(180deg)}.country-dial-code-panel{z-index:10000;background:#fff;border-radius:8px;flex-direction:column;width:280px;max-height:360px;display:flex;position:fixed;top:0;left:0;overflow:hidden;box-shadow:0 0 0 1px #0000000d,0 4px 6px -1px #0000001a,0 2px 4px -1px #0000000f}.country-dial-code-panel.hidden{display:none}.country-search-wrapper{border-bottom:1px solid #e0e0e0;flex-shrink:0;padding:12px}.country-search{width:100%;font-size:inherit;box-sizing:border-box;border:1px solid #e0e0e0;border-radius:6px;outline:none;padding:6px 12px;font-family:inherit;transition:all .1s ease-in}.country-search:focus{border-color:#3297d3b3;box-shadow:0 0 0 3px #3297d31a}.country-search::placeholder{color:#717173;opacity:.6}.countries-list{flex:1;min-height:0;overflow-y:auto}.countries-list::-webkit-scrollbar{width:8px}.countries-list::-webkit-scrollbar-track{background:#f5f5f5}.countries-list::-webkit-scrollbar-thumb{background:#d0d0d0;border-radius:4px}.countries-list::-webkit-scrollbar-thumb:hover{background:#b0b0b0}.country-group-header{color:#717173;text-transform:uppercase;letter-spacing:.05em;z-index:1;background:#fafafa;padding:8px 16px 4px;font-size:12px;font-weight:600;position:sticky;top:0}.country-item{cursor:pointer;text-align:left;width:100%;color:inherit;background:#fff;border:none;align-items:center;gap:12px;padding:10px 16px;font-family:inherit;font-size:14px;transition:background .1s;display:flex}.country-item:hover{background:#f5f5f5}.country-item.selected{color:#3297d3;background:#3297d314}.country-item:focus{background:#f0f0f0;outline:none}.country-item .country-flag{flex-shrink:0;font-size:20px;line-height:1}.country-item .country-name{text-overflow:ellipsis;white-space:nowrap;flex:1;overflow:hidden}.country-item .country-dial-code{color:#717173;flex-shrink:0;font-size:.95em}.country-item.selected .country-dial-code{color:#3297d3cc}.no-results{text-align:center;color:#717173;padding:24px 16px;font-size:14px}.phone-number-field-wrapper{width:100%;display:flex}.phone-number-field-container{border-radius:inherit;background:#fff;align-items:center;width:100%;transition:box-shadow .1s ease-in,border-radius .2s ease-in;display:flex;position:relative;box-shadow:0 0 0 1px #e0e0e0,0 2px 4px #00000012,0 1px 1.5px #0000000d}.phone-number-field-container.focused{z-index:2;box-shadow:0 0 0 1px #3297d3b3,0 1px 1px #00000012,0 0 0 4px #3297d34d}.phone-number-field-container.error{box-shadow:0 0 0 1px #dc2727,0 2px 4px #dc27271a}.phone-number-field-container.error.focused{box-shadow:0 0 0 1px #dc2727,0 1px 1px #00000012,0 0 0 4px #dc272733}.phone-number-field-container .country-select-wrapper{padding:var(--odus-input-padding,8px 12px);border-top-left-radius:var(--phone-border-radius,0px);border-bottom-left-radius:var(--phone-border-radius,0px);white-space:nowrap;background:0 0;flex-shrink:0;align-items:center;gap:4px;padding-right:6px;display:flex;position:relative}.phone-number-field-container .country-select-wrapper .country-flag{pointer-events:none;font-size:14px;line-height:1}.phone-number-field-container .country-select-wrapper .country-chevron{color:#717173;pointer-events:none;flex-shrink:0;align-items:center;display:flex}.phone-number-field-container .country-select-wrapper .country-select{cursor:pointer;opacity:0;background:0 0;border:none;outline:none;width:100%;height:100%;position:absolute;inset:0}.phone-number-field-container .phone-input-wrapper{flex:1;min-width:0}.phone-number-field-container .phone-input-wrapper .form-input{box-shadow:none;border-radius:0;border-top-right-radius:var(--phone-border-radius,0px);border-bottom-right-radius:var(--phone-border-radius,0px);padding:var(--odus-input-padding,8px 2px);border:none}.phone-number-field-container .phone-input-wrapper .form-input:focus{box-shadow:none;z-index:auto}", ne = {
976
+ name: "odus-elements",
977
+ styles: {
978
+ fontSize: 14,
979
+ textColor: "#000000",
980
+ buttonColor: "#0070f3",
981
+ borderRadius: 4,
982
+ fontFamily: "system-ui",
983
+ buttonTextColor: "#ffffff",
984
+ buttonFontSize: 16
985
+ },
986
+ layout: {
987
+ actionButton: { translationKey: null },
988
+ billingFields: {
989
+ street: { enabled: !1 },
990
+ city: { enabled: !1 },
991
+ state: { enabled: !1 },
992
+ zipCode: { enabled: !1 },
993
+ firstName: { enabled: !1 },
994
+ lastName: { enabled: !1 },
995
+ country: { enabled: !1 }
996
+ }
997
+ },
998
+ additionalPaymentMethods: {}
999
+ }, $ = class extends T {
1000
+ _phone = "";
1001
+ _error = null;
1002
+ _field = null;
1003
+ _renderGeneration = 0;
1004
+ render() {
1005
+ if (!this.shadowRoot) return;
1006
+ this._field?.destroy(), this._field?.getElement().remove(), this._field = null, this.options.initialValue && !this._phone && (this._phone = String(this.options.initialValue));
1007
+ let e = ++this._renderGeneration;
1008
+ a().then(({ PhoneNumberField: t }) => {
1009
+ if (!this.shadowRoot || this._renderGeneration !== e) return;
1010
+ let { t: n, locale: i } = o();
1011
+ this._field = new t({
1012
+ value: this._phone,
1013
+ error: !1,
1014
+ checkoutProfile: ne,
1015
+ translationFunc: n,
1016
+ locale: i,
1017
+ onChange: () => {
1018
+ this._phone = this._field?.getValue() ?? "", this._error = null, this.emit("change", this._phone);
1019
+ },
1020
+ onBlur: () => {
1021
+ this._phone = this._field?.getValue() ?? "";
1022
+ let e = r(), t = this._field?.getCountry();
1023
+ this._error = e.phoneNumber(this._phone, t) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._phone);
1024
+ }
1025
+ }), this.shadowRoot.appendChild(this._field.getElement());
1026
+ });
1027
+ }
1028
+ getCss() {
1029
+ return super.getCss() + [
1030
+ S,
1031
+ C,
1032
+ x,
1033
+ te
1034
+ ].join("\n") + "\n :host { display: block; }\n .form-input,\n .country-select-wrapper {\n color: var(--odus-color-text, #1a1a1a) !important;\n font-family: var(--odus-font-family, system-ui, sans-serif) !important;\n font-size: var(--odus-input-font-size, 16px) !important;\n background: var(--odus-color-background, #ffffff) !important;\n border-radius: 0 !important;\n box-shadow: none !important;\n }\n .phone-number-field-container {\n min-height: calc(var(--odus-input-font-size, 16px) * 1.5 + 16px);\n box-shadow:\n 0 0 0 1px var(--odus-border-color, #e0e0e0),\n 0 2px 4px 0 rgba(0, 0, 0, 0.07),\n 0 1px 1.5px 0 rgba(0, 0, 0, 0.05) !important;\n border-radius: var(--odus-border-radius, 6px) !important;\n overflow: hidden;\n }\n .phone-number-field-container:focus-within {\n box-shadow: var(\n --odus-input-focus-shadow,\n 0 0 0 1px rgba(50, 151, 211, 0.7),\n 0 1px 1px 0 rgba(0, 0, 0, 0.07),\n 0 0 0 4px rgba(50, 151, 211, 0.3)\n ) !important;\n }\n .phone-number-field-container.error {\n box-shadow: 0 0 0 1px var(--odus-color-error, #dc2727) !important;\n }\n .form-input:focus {\n box-shadow: none !important;\n outline: none !important;\n }\n .form-input-error {\n color: var(--odus-color-error, #dc2727) !important;\n }\n .form-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
1035
+ }
1036
+ getValue() {
1037
+ return this._phone;
1038
+ }
1039
+ getIsValid() {
1040
+ let e = r(), t = this._field?.getCountry();
1041
+ return !e.phoneNumber(this._phone, t);
1042
+ }
1043
+ getError() {
1044
+ return this._error;
1045
+ }
1046
+ }, re = class {
1047
+ _config;
1048
+ _apiService;
1049
+ _changeListeners = [];
1050
+ _callbacks;
1051
+ _paymentState = {};
1052
+ _fontCleanup;
1053
+ _card;
1054
+ _email;
1055
+ _phone;
1056
+ _addressStreet;
1057
+ _addressFirstName;
1058
+ _addressLastName;
1059
+ _cardholderName;
1060
+ _addressCity;
1061
+ _addressState;
1062
+ _addressZipCode;
1063
+ _addressCountry;
1064
+ _applePay;
1065
+ _paypal;
1066
+ _error;
1067
+ elements;
1068
+ constructor(t) {
1069
+ this._config = t, this._callbacks = { ...t.callbacks }, t.locale && e.setLocale(t.locale), this._apiService = new n(t.apiKey, t.environment);
1070
+ let r = {};
1071
+ Object.defineProperty(r, "email", {
1072
+ get: () => (this._email || (this._email = new q(), this._trackElement(this._email)), this._email),
1073
+ enumerable: !0
1074
+ }), Object.defineProperty(r, "phone", {
1075
+ get: () => (this._phone || (this._phone = new $(), this._trackElement(this._phone)), this._phone),
1076
+ enumerable: !0
1077
+ });
1078
+ let i = {};
1079
+ Object.defineProperty(i, "applePay", {
1080
+ get: () => (this._applePay || (this._applePay = new L(), this._trackElement(this._applePay), this._paymentState.paymentId && this._paymentState.checkoutKey && this._applePay.setPaymentContext({
1081
+ paymentId: this._paymentState.paymentId,
1082
+ checkoutKey: this._paymentState.checkoutKey,
1083
+ environment: this._config.environment,
1084
+ checkoutDetails: this._paymentState.checkoutDetails,
1085
+ ...this._config.additionalPaymentMethods?.applePay,
1086
+ onAuthorize: (e) => this._executeAuthorization({
1087
+ formData: null,
1088
+ applePayData: e
1089
+ })
1090
+ })), this._applePay),
1091
+ enumerable: !0
1092
+ }), Object.defineProperty(i, "payPal", {
1093
+ get: () => (this._paypal || (this._paypal = new Q(), this._trackElement(this._paypal), this._paymentState.paymentId && this._paymentState.checkoutKey && this._paypal.setPaymentContext({
1094
+ paymentId: this._paymentState.paymentId,
1095
+ checkoutKey: this._paymentState.checkoutKey,
1096
+ onAuthorize: () => this._executeAuthorization({ formData: null })
1097
+ })), this._paypal),
1098
+ enumerable: !0
1099
+ });
1100
+ let a = {};
1101
+ Object.defineProperty(a, "street", {
1102
+ get: () => (this._addressStreet || (this._addressStreet = new N(), this._trackElement(this._addressStreet)), this._addressStreet),
1103
+ enumerable: !0
1104
+ }), Object.defineProperty(a, "firstName", {
1105
+ get: () => (this._addressFirstName || (this._addressFirstName = new k(), this._trackElement(this._addressFirstName)), this._addressFirstName),
1106
+ enumerable: !0
1107
+ }), Object.defineProperty(a, "lastName", {
1108
+ get: () => (this._addressLastName || (this._addressLastName = new A(), this._trackElement(this._addressLastName)), this._addressLastName),
1109
+ enumerable: !0
1110
+ }), Object.defineProperty(a, "city", {
1111
+ get: () => (this._addressCity || (this._addressCity = new E(), this._trackElement(this._addressCity)), this._addressCity),
1112
+ enumerable: !0
1113
+ }), Object.defineProperty(a, "state", {
1114
+ get: () => (this._addressState || (this._addressState = new M(), this._trackElement(this._addressState)), this._addressState),
1115
+ enumerable: !0
1116
+ }), Object.defineProperty(a, "zipCode", {
1117
+ get: () => (this._addressZipCode || (this._addressZipCode = new P(), this._trackElement(this._addressZipCode)), this._addressZipCode),
1118
+ enumerable: !0
1119
+ }), Object.defineProperty(a, "country", {
1120
+ get: () => (this._addressCountry || (this._addressCountry = new O(), this._trackElement(this._addressCountry), this._addressCountry.on("change", (e) => {
1121
+ this._addressState?.setCountry(e);
1122
+ })), this._addressCountry),
1123
+ enumerable: !0
1124
+ });
1125
+ let o = {
1126
+ contact: r,
1127
+ express: i
1128
+ };
1129
+ Object.defineProperty(o, "card", {
1130
+ get: () => (this._card || (this._card = new W(), this._card.setEnvironment(this._config.environment), this._trackElement(this._card), this._paymentState.vgsJwt && this._card.setVgsJwt(this._paymentState.vgsJwt)), this._card),
1131
+ enumerable: !0
1132
+ }), Object.defineProperty(o, "cardholderName", {
1133
+ get: () => (this._cardholderName || (this._cardholderName = new G(), this._trackElement(this._cardholderName)), this._cardholderName),
1134
+ enumerable: !0
1135
+ }), Object.defineProperty(o, "address", {
1136
+ get: () => a,
1137
+ enumerable: !0
1138
+ }), Object.defineProperty(o, "error", {
1139
+ get: () => (this._error || (this._error = new Y(), this._trackElement(this._error)), this._error),
1140
+ enumerable: !0
1141
+ }), this.elements = o;
1142
+ }
1143
+ async associatePayment(e, t) {
1144
+ if (!e || !t) throw Error("paymentId and checkoutKey are required");
1145
+ this._paymentState.paymentId = e, this._paymentState.checkoutKey = t;
1146
+ let n = await m({
1147
+ id: e,
1148
+ checkoutKey: t,
1149
+ environment: this._config.environment
1150
+ });
1151
+ this._paymentState.checkoutDetails = {
1152
+ amount: n.amount,
1153
+ currency: n.currency,
1154
+ countryCode: n.countryCode
1155
+ }, n.vgsJwt && (this._paymentState.vgsJwt = n.vgsJwt, this._card?.setVgsJwt(n.vgsJwt)), this._card?.setEnvironment(this._config.environment), this._applePay?.setPaymentContext({
1156
+ paymentId: e,
1157
+ checkoutKey: t,
1158
+ environment: this._config.environment,
1159
+ checkoutDetails: this._paymentState.checkoutDetails,
1160
+ ...this._config.additionalPaymentMethods?.applePay,
1161
+ onAuthorize: (e) => this._executeAuthorization({
1162
+ formData: null,
1163
+ applePayData: e
1164
+ })
1165
+ }), this._paypal?.setPaymentContext({
1166
+ paymentId: e,
1167
+ checkoutKey: t,
1168
+ onAuthorize: () => this._executeAuthorization({ formData: null })
1169
+ });
1170
+ }
1171
+ validate() {
1172
+ let e = {}, { t } = o();
1173
+ return this._card?.isMounted && !this._card.isValid && (e.card = this._card.error ?? t("validation.cardNumberInvalid")), this._email?.isMounted && !this._email.isValid && (e.email = this._email.error ?? t("validation.emailInvalid")), this._phone?.isMounted && !this._phone.isValid && (e.phone = this._phone.error ?? t("validation.phoneNumberInvalid")), this._addressStreet?.isMounted && !this._addressStreet.isValid && (e["address.street"] = this._addressStreet.error ?? t("validation.addressLine1Required")), this._addressCity?.isMounted && !this._addressCity.isValid && (e["address.city"] = this._addressCity.error ?? t("validation.townCityRequired")), this._addressCountry?.isMounted && !this._addressCountry.isValid && (e["address.country"] = this._addressCountry.error ?? t("validation.countryRequired")), this._addressFirstName?.isMounted && !this._addressFirstName.isValid && (e["address.firstName"] = this._addressFirstName.error ?? t("validation.firstNameRequired")), this._addressLastName?.isMounted && !this._addressLastName.isValid && (e["address.lastName"] = this._addressLastName.error ?? t("validation.lastNameRequired")), this._cardholderName?.isMounted && !this._cardholderName.isValid && (e.cardholderName = this._cardholderName.error ?? t("validation.nameRequired")), this._addressState?.isMounted && !this._addressState.isValid && (e["address.state"] = this._addressState.error ?? t("validation.stateRequired")), this._addressZipCode?.isMounted && !this._addressZipCode.isValid && (e["address.zipCode"] = this._addressZipCode.error ?? t("validation.postalCodeRequired")), this._applePay?.isMounted && !this._applePay.isValid && (e.applePay = "Apple Pay authorization required"), this._paypal?.isMounted && !this._paypal.isValid && (e.paypal = "PayPal authorization required"), {
1174
+ valid: Object.keys(e).length === 0,
1175
+ errors: e
1176
+ };
1177
+ }
1178
+ async _getPayload() {
1179
+ if (this._applePay?.isMounted && this._applePay.isValid || this._paypal?.isMounted) return null;
1180
+ let e = this._email?.isMounted ? this._email.value : "", t = this._phone?.isMounted ? this._phone.value : void 0, n = this._addressStreet?.isMounted || this._addressCity?.isMounted || this._addressCountry?.isMounted || this._addressFirstName?.isMounted || this._addressLastName?.isMounted || this._cardholderName?.isMounted || this._addressState?.isMounted || this._addressZipCode?.isMounted ? {
1181
+ street: this._addressStreet?.isMounted ? this._addressStreet.value : "",
1182
+ city: this._addressCity?.isMounted ? this._addressCity.value : "",
1183
+ country: this._addressCountry?.isMounted ? this._addressCountry.value : "",
1184
+ firstName: this._addressFirstName?.isMounted ? this._addressFirstName.value : "",
1185
+ lastName: this._addressLastName?.isMounted ? this._addressLastName.value : "",
1186
+ state: this._addressState?.isMounted ? this._addressState.value : "",
1187
+ zipCode: this._addressZipCode?.isMounted ? this._addressZipCode.value : ""
1188
+ } : void 0, r = this._cardholderName?.isMounted ? this._cardholderName.value : "", i = [n?.firstName ?? "", n?.lastName ?? ""].filter(Boolean), a = r || i.join(" ");
1189
+ if (this._card?.isMounted && this._card.isVgsMode) try {
1190
+ let r = await this._card.getPayload();
1191
+ return {
1192
+ name: a,
1193
+ email: e,
1194
+ phoneNumber: t || void 0,
1195
+ cardNumber: "",
1196
+ cardExpiry: "",
1197
+ cardCvv: "",
1198
+ billingAddress: n,
1199
+ vgsCardData: r
1200
+ };
1201
+ } catch {
1202
+ return this._handleAuthorizationError({
1203
+ message: "We couldn't securely process your card details. Please check your card information and try again.",
1204
+ status: 0,
1205
+ statusText: "Card Tokenization Failed"
1206
+ }), null;
1207
+ }
1208
+ let o = this._card?.isMounted ? this._card.value : null;
1209
+ return o ? {
1210
+ name: a,
1211
+ email: e,
1212
+ phoneNumber: t || void 0,
1213
+ cardNumber: o.number,
1214
+ cardExpiry: o.expiry,
1215
+ cardCvv: o.cvv,
1216
+ billingAddress: n
1217
+ } : null;
1218
+ }
1219
+ async authorize(e) {
1220
+ if (!this._paymentState.paymentId || !this._paymentState.checkoutKey) throw Error("Call associatePayment() before authorize()");
1221
+ if (this._applePay?.isMounted && this._applePay.isValid) {
1222
+ await this._executeAuthorization({
1223
+ formData: null,
1224
+ applePayData: this._applePay.value
1225
+ });
1226
+ return;
1227
+ }
1228
+ if (this._paypal?.isMounted) {
1229
+ await this._executeAuthorization({ formData: null });
1230
+ return;
1231
+ }
1232
+ let t = await this._getPayload();
1233
+ await this._executeAuthorization({
1234
+ formData: t,
1235
+ applePayData: void 0,
1236
+ customCustomerData: e?.customerData
1237
+ });
1238
+ }
1239
+ applyTheme(e) {
1240
+ let t = e["--odus-font-family"];
1241
+ if (t) {
1242
+ this._fontCleanup?.();
1243
+ let { cleanup: e } = ee({ fontFamily: t });
1244
+ this._fontCleanup = e;
1245
+ }
1246
+ for (let t of this._allElements()) t.setTheme(e);
1247
+ }
1248
+ resetTheme(e) {
1249
+ "--odus-font-family" in e && (this._fontCleanup?.(), this._fontCleanup = void 0);
1250
+ for (let t of this._allElements()) t.resetTheme(e);
1251
+ }
1252
+ get isValid() {
1253
+ return this.validate().valid;
1254
+ }
1255
+ onChange(e) {
1256
+ this._changeListeners.push(e);
1257
+ }
1258
+ destroy() {
1259
+ this._fontCleanup?.(), this._card?.destroy(), this._email?.destroy(), this._phone?.destroy(), this._addressStreet?.destroy(), this._addressFirstName?.destroy(), this._addressLastName?.destroy(), this._cardholderName?.destroy(), this._addressCity?.destroy(), this._addressState?.destroy(), this._addressZipCode?.destroy(), this._addressCountry?.destroy(), this._applePay?.destroy(), this._paypal?.destroy(), this._error?.destroy(), this._changeListeners.length = 0;
1260
+ }
1261
+ setCallbacks(e) {
1262
+ Object.assign(this._callbacks, e);
1263
+ }
1264
+ _trackElement(e) {
1265
+ e.on("change", () => {
1266
+ for (let e of this._changeListeners) e();
1267
+ });
1268
+ }
1269
+ _allElements() {
1270
+ return [
1271
+ this._card,
1272
+ this._email,
1273
+ this._phone,
1274
+ this._addressStreet,
1275
+ this._addressFirstName,
1276
+ this._addressLastName,
1277
+ this._cardholderName,
1278
+ this._addressCity,
1279
+ this._addressState,
1280
+ this._addressZipCode,
1281
+ this._addressCountry,
1282
+ this._applePay,
1283
+ this._paypal,
1284
+ this._error
1285
+ ].filter((e) => e !== void 0);
1286
+ }
1287
+ async _executeAuthorization({ formData: e, applePayData: t, customCustomerData: n }) {
1288
+ try {
1289
+ let r = await this._apiService.authorizePayment({
1290
+ paymentId: this._paymentState.paymentId,
1291
+ checkoutKey: this._paymentState.checkoutKey,
1292
+ formData: e,
1293
+ returnUrl: this._config.returnUrl,
1294
+ applePayData: t,
1295
+ customCustomerData: n
1296
+ });
1297
+ this._handlePaymentResponse(r);
1298
+ } catch (e) {
1299
+ this._handleAuthorizationError(e);
1300
+ }
1301
+ }
1302
+ _handlePaymentResponse(e) {
1303
+ if (e.latestTransaction.status === "authorized") {
1304
+ this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status);
1305
+ return;
1306
+ }
1307
+ if (e.latestTransaction.status === "failed") {
1308
+ this._callbacks.onPaymentFailed?.(e.latestTransaction.status);
1309
+ return;
1310
+ }
1311
+ e.status === "requires_action" && this._callbacks.onActionRequired?.(e.action.redirectUrl);
1312
+ }
1313
+ _handleAuthorizationError(e) {
1314
+ let t = e.details?.message ?? "Payment failed";
1315
+ this._callbacks.onPaymentFailed?.(t), this._error?.isMounted && this._error.setError(t);
1316
+ }
1751
1317
  };
1318
+ //#endregion
1319
+ export { E as AddressCityElement, O as AddressCountryElement, k as AddressFirstNameElement, A as AddressLastNameElement, M as AddressStateElement, N as AddressStreetElement, P as AddressZipCodeElement, L as ApplePayElement, T as BaseElement, W as CardElement, G as CardholderElement, q as EmailElement, Y as ErrorElement, re as OdusElements, Q as PayPalElement, $ as PhoneElement };