@odus/checkout 1.4.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1751 +1,1336 @@
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{box-shadow:0 0 0 1px var(--odus-color-error,#dc2727), 0 2px 4px 0 #00000012, 0 1px 1.5px 0 #0000000d}.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
+ _appliedTheme = {};
8
+ listeners = /* @__PURE__ */ new Map();
9
+ get isMounted() {
10
+ return this.host !== null;
11
+ }
12
+ mount(e) {
13
+ this.isMounted && this.unmount();
14
+ let t = typeof e == "string" ? document.querySelector(e) : e;
15
+ if (!t) throw Error(`[BaseElement] mount target not found: ${String(e)}`);
16
+ this.host = document.createElement("div"), this.shadowRoot = this.host.attachShadow({ mode: "open" });
17
+ let n = document.createElement("style");
18
+ n.textContent = this.getCss(), this.shadowRoot.appendChild(n), t.appendChild(this.host), this.reapplyTheme(), this.render(), this.emit("ready");
19
+ }
20
+ unmount() {
21
+ this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null;
22
+ }
23
+ destroy() {
24
+ this.unmount(), this.listeners.clear();
25
+ }
26
+ on(e, t) {
27
+ let n = this.listeners.get(e) ?? [];
28
+ return n.push(t), this.listeners.set(e, n), this;
29
+ }
30
+ update(e) {
31
+ if (this.options = {
32
+ ...this.options,
33
+ ...e
34
+ }, this.shadowRoot) {
35
+ let e = this.shadowRoot.querySelector("style");
36
+ e && (e.textContent = this.getCss()), this.render();
37
+ }
38
+ }
39
+ setTheme(e) {
40
+ if (this._appliedTheme = {
41
+ ...this._appliedTheme,
42
+ ...e
43
+ }, this.host) for (let [t, n] of Object.entries(e)) this.host.style.setProperty(t, n);
44
+ }
45
+ resetTheme(e) {
46
+ for (let t of Object.keys(e)) delete this._appliedTheme[t];
47
+ if (this.host) for (let t of Object.keys(e)) this.host.style.removeProperty(t);
48
+ }
49
+ reapplyTheme() {
50
+ if (this.host) for (let [e, t] of Object.entries(this._appliedTheme)) this.host.style.setProperty(e, t);
51
+ }
52
+ get value() {
53
+ return this.getValue();
54
+ }
55
+ get isValid() {
56
+ return this.getIsValid();
57
+ }
58
+ get error() {
59
+ return this.getError();
60
+ }
61
+ emit(e, t) {
62
+ let n = this.listeners.get(e) ?? [];
63
+ for (let e of n) e(t);
64
+ this.options.callbacks?.[e]?.(t);
65
+ }
66
+ getCss() {
67
+ return w;
68
+ }
69
+ }, E = class extends T {
70
+ _value = "";
71
+ _error = null;
72
+ _input = null;
73
+ render() {
74
+ if (!this.shadowRoot) return;
75
+ this._input?.getElement().remove();
76
+ let { t: e } = o();
77
+ this._input = new u({
78
+ name: "billingAddress.city",
79
+ label: e("address.townCity"),
80
+ error: !1,
81
+ placeholder: e("address.placeholder.city"),
82
+ value: this._value,
83
+ autocomplete: "address-level2",
84
+ onChange: (e) => {
85
+ this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
86
+ }
87
+ }), this._input.addEventListener("blur", () => {
88
+ let { t: e } = o();
89
+ this._error = this._value.trim() ? null : e("validation.townCityRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
90
+ }), this.shadowRoot.appendChild(this._input.getElement());
91
+ }
92
+ getCss() {
93
+ return super.getCss() + [
94
+ S,
95
+ C,
96
+ x
97
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
98
+ }
99
+ getValue() {
100
+ return this._value;
101
+ }
102
+ getIsValid() {
103
+ return !!this._value.trim();
104
+ }
105
+ getError() {
106
+ return this._error;
107
+ }
108
+ }, 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{box-shadow:0 0 0 1px var(--odus-color-error,#dc2727), 0 2px 4px 0 #00000012, 0 1px 1.5px 0 #0000000d}.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 {
109
+ _value = "";
110
+ _error = null;
111
+ _select = null;
112
+ _allowedCountries;
113
+ setCountries(e) {
114
+ 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();
115
+ }
116
+ render() {
117
+ if (!this.shadowRoot) return;
118
+ this._select?.getElement().remove(), this.options.initialValue && !this._value && (this._value = String(this.options.initialValue), this.emit("change", this._value));
119
+ let { t: e, locale: t } = o();
120
+ this._select = new c({
121
+ name: "billingAddress.country",
122
+ label: e("address.chooseCountry"),
123
+ error: !1,
124
+ placeholder: e("address.chooseCountry"),
125
+ value: this._value,
126
+ options: d(this._allowedCountries, t),
127
+ autocomplete: "country",
128
+ onChange: (e) => {
129
+ this._value = e.target.value, this._error = null, this.emit("change", this._value);
130
+ }
131
+ }), this._select.addEventListener("blur", () => {
132
+ let { t: e } = o();
133
+ this._error = this._value ? null : e("validation.countryRequired"), this._select?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
134
+ }), this.shadowRoot.appendChild(this._select.getElement());
135
+ }
136
+ getCss() {
137
+ return super.getCss() + [
138
+ C,
139
+ x,
140
+ D
141
+ ].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 ";
142
+ }
143
+ getValue() {
144
+ return this._value;
145
+ }
146
+ getIsValid() {
147
+ return !!this._value;
148
+ }
149
+ getError() {
150
+ return this._error;
151
+ }
152
+ }, k = class extends T {
153
+ _value = "";
154
+ _error = null;
155
+ _input = null;
156
+ render() {
157
+ if (!this.shadowRoot) return;
158
+ this._input?.getElement().remove();
159
+ let { t: e } = o();
160
+ this._input = new u({
161
+ name: "billingAddress.firstName",
162
+ label: e("address.firstName"),
163
+ error: !1,
164
+ placeholder: e("address.placeholder.firstName"),
165
+ value: this._value,
166
+ autocomplete: "given-name",
167
+ onChange: (e) => {
168
+ this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
169
+ }
170
+ }), this._input.addEventListener("blur", () => {
171
+ let { t: e } = o();
172
+ this._error = this._value.trim() ? null : e("validation.firstNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
173
+ }), this.shadowRoot.appendChild(this._input.getElement());
174
+ }
175
+ getCss() {
176
+ return super.getCss() + [
177
+ S,
178
+ C,
179
+ x
180
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
181
+ }
182
+ getValue() {
183
+ return this._value;
184
+ }
185
+ getIsValid() {
186
+ return !!this._value.trim();
187
+ }
188
+ getError() {
189
+ return this._error;
190
+ }
191
+ }, A = class extends T {
192
+ _value = "";
193
+ _error = null;
194
+ _input = null;
195
+ render() {
196
+ if (!this.shadowRoot) return;
197
+ this._input?.getElement().remove();
198
+ let { t: e } = o();
199
+ this._input = new u({
200
+ name: "billingAddress.lastName",
201
+ label: e("address.lastName"),
202
+ error: !1,
203
+ placeholder: e("address.placeholder.lastName"),
204
+ value: this._value,
205
+ autocomplete: "family-name",
206
+ onChange: (e) => {
207
+ this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
208
+ }
209
+ }), this._input.addEventListener("blur", () => {
210
+ let { t: e } = o();
211
+ this._error = this._value.trim() ? null : e("validation.lastNameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
212
+ }), this.shadowRoot.appendChild(this._input.getElement());
213
+ }
214
+ getCss() {
215
+ return super.getCss() + [
216
+ S,
217
+ C,
218
+ x
219
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
220
+ }
221
+ getValue() {
222
+ return this._value;
223
+ }
224
+ getIsValid() {
225
+ return !!this._value.trim();
226
+ }
227
+ getError() {
228
+ return this._error;
229
+ }
230
+ }, j = new Set(["US", "CA"]), M = class extends T {
231
+ _value = "";
232
+ _country = "";
233
+ _input = null;
234
+ _select = null;
235
+ setCountry(e) {
236
+ let t = this._country;
237
+ if (this._country = e, !this.shadowRoot) return;
238
+ let n = j.has(t), r = j.has(e);
239
+ if (n && r && t !== e) {
240
+ let { t } = o(), n = e, r = t(n === "US" ? "address.chooseState" : "address.chooseProvince");
241
+ this._select?.setOptions(p(n), r), this._value = "";
242
+ return;
243
+ }
244
+ n !== r && (this._value = "", this.render());
245
+ }
246
+ render() {
247
+ if (this.shadowRoot) if (this._input?.getElement().remove(), this._select?.getElement().remove(), this._input = null, this._select = null, j.has(this._country)) {
248
+ let e = this._country;
249
+ this._renderSelect(e);
250
+ } else this._renderInput();
251
+ }
252
+ _renderInput() {
253
+ let { t: e } = o();
254
+ this._input = new u({
255
+ name: "billingAddress.state",
256
+ label: e("address.state"),
257
+ error: !1,
258
+ placeholder: e("address.state"),
259
+ value: this._value,
260
+ autocomplete: "address-level1",
261
+ onChange: (e) => {
262
+ this._value = e.target.value, this.emit("change", this._value);
263
+ }
264
+ }), this._input.addEventListener("blur", () => {
265
+ this.emit("blur", this._value);
266
+ }), this.shadowRoot.appendChild(this._input.getElement());
267
+ }
268
+ _renderSelect(e) {
269
+ let { t } = o(), n = p(e), r = t(e === "US" ? "address.chooseState" : "address.chooseProvince");
270
+ this._select = new c({
271
+ name: "billingAddress.state",
272
+ label: t("address.state"),
273
+ error: !1,
274
+ placeholder: r,
275
+ value: this._value,
276
+ options: n,
277
+ autocomplete: "address-level1",
278
+ onChange: (e) => {
279
+ this._value = e.target.value, this.emit("change", this._value);
280
+ }
281
+ }), this._select.addEventListener("blur", () => {
282
+ this.emit("blur", this._value);
283
+ }), this.shadowRoot.appendChild(this._select.getElement());
284
+ }
285
+ getCss() {
286
+ return super.getCss() + [
287
+ S,
288
+ C,
289
+ x,
290
+ D
291
+ ].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-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-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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
292
+ }
293
+ getValue() {
294
+ return this._value;
295
+ }
296
+ getIsValid() {
297
+ return !0;
298
+ }
299
+ getError() {
300
+ return null;
301
+ }
302
+ }, N = class extends T {
303
+ _value = "";
304
+ _error = null;
305
+ _input = null;
306
+ render() {
307
+ if (!this.shadowRoot) return;
308
+ this._input?.getElement().remove();
309
+ let { t: e } = o();
310
+ this._input = new u({
311
+ name: "billingAddress.street",
312
+ label: e("address.addressLine1"),
313
+ error: !1,
314
+ placeholder: e("address.placeholder.street"),
315
+ value: this._value,
316
+ autocomplete: "street-address",
317
+ maxLength: this.options.maxLength,
318
+ onChange: (t) => {
319
+ if (this._value = t.target.value, this._error = null, this.options.maxLength && this._value.length >= this.options.maxLength) {
320
+ let t = e("validation.maxLengthExceeded");
321
+ this._error = t.replace("{{max}}", String(this.options.maxLength)), this._input?.setError(!0, this._error);
322
+ } else this._input?.setError(!1);
323
+ this.emit("change", this._value);
324
+ }
325
+ }), this._input.addEventListener("blur", () => {
326
+ let { t: e } = o();
327
+ this._error = this._value.trim() ? null : e("validation.addressLine1Required"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
328
+ }), this.shadowRoot.appendChild(this._input.getElement());
329
+ }
330
+ getCss() {
331
+ return super.getCss() + [
332
+ S,
333
+ C,
334
+ x
335
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
336
+ }
337
+ getValue() {
338
+ return this._value;
339
+ }
340
+ getIsValid() {
341
+ return !!this._value.trim();
342
+ }
343
+ getError() {
344
+ return this._error;
345
+ }
346
+ }, P = class extends T {
347
+ _value = "";
348
+ _error = null;
349
+ _input = null;
350
+ render() {
351
+ if (!this.shadowRoot) return;
352
+ this._input?.getElement().remove();
353
+ let { t: e } = o();
354
+ this._input = new u({
355
+ name: "billingAddress.zipCode",
356
+ label: e("address.postalCode"),
357
+ error: !1,
358
+ placeholder: e("address.placeholder.zipCode"),
359
+ value: this._value,
360
+ autocomplete: "postal-code",
361
+ onChange: (e) => {
362
+ this._value = e.target.value, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
363
+ }
364
+ }), this._input.addEventListener("blur", () => {
365
+ let { t: e } = o();
366
+ this._error = this._value.trim() ? null : e("validation.postalCodeRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
367
+ }), this.shadowRoot.appendChild(this._input.getElement());
368
+ }
369
+ getCss() {
370
+ return super.getCss() + [
371
+ S,
372
+ C,
373
+ x
374
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
375
+ }
376
+ getValue() {
377
+ return this._value;
378
+ }
379
+ getIsValid() {
380
+ return !!this._value.trim();
381
+ }
382
+ getError() {
383
+ return this._error;
384
+ }
385
+ }, 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 = {
386
+ name: "odus-elements",
387
+ styles: {
388
+ fontSize: 14,
389
+ textColor: "#000000",
390
+ buttonColor: "#0070f3",
391
+ borderRadius: 4,
392
+ fontFamily: "system-ui",
393
+ buttonTextColor: "#ffffff",
394
+ buttonFontSize: 16
395
+ },
396
+ layout: {
397
+ actionButton: { translationKey: null },
398
+ billingFields: {
399
+ street: { enabled: !1 },
400
+ city: { enabled: !1 },
401
+ state: { enabled: !1 },
402
+ zipCode: { enabled: !1 },
403
+ firstName: { enabled: !1 },
404
+ lastName: { enabled: !1 },
405
+ country: { enabled: !1 }
406
+ }
407
+ },
408
+ additionalPaymentMethods: {}
409
+ }, L = class extends T {
410
+ _paymentContext = null;
411
+ _applePayData = null;
412
+ _authorized = !1;
413
+ _button = null;
414
+ setPaymentContext(e) {
415
+ this._paymentContext = e, this.isMounted && this.render();
416
+ }
417
+ render() {
418
+ if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext)) return;
419
+ let { paymentId: e, checkoutKey: t, environment: n, checkoutDetails: r, displayName: i, countries: a, requiredBillingContactFields: o, requiredShippingContactFields: s, onAuthorize: c } = this._paymentContext;
420
+ a?.length && r?.countryCode && !a.map((e) => e.toUpperCase()).includes(r.countryCode.toUpperCase()) || (this._button = new h({
421
+ checkoutProfile: I,
422
+ paymentId: e,
423
+ checkoutKey: t,
424
+ environment: n,
425
+ checkoutDetails: r,
426
+ displayName: i,
427
+ requiredBillingContactFields: o,
428
+ requiredShippingContactFields: s,
429
+ onSubmit: async ({ applePayData: e }) => {
430
+ e && (this._applePayData = e, this._authorized = !0, this.emit("change", e), await c(e));
431
+ }
432
+ }), this.shadowRoot.appendChild(this._button.getElement()));
433
+ }
434
+ getCss() {
435
+ 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 ";
436
+ }
437
+ getValue() {
438
+ return this._applePayData;
439
+ }
440
+ getIsValid() {
441
+ return this._authorized;
442
+ }
443
+ getError() {
444
+ return null;
445
+ }
446
+ }, 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 = {
447
+ name: "odus-elements",
448
+ styles: {
449
+ fontSize: 14,
450
+ textColor: "#000000",
451
+ buttonColor: "#0070f3",
452
+ borderRadius: 4,
453
+ fontFamily: "system-ui",
454
+ buttonTextColor: "#ffffff",
455
+ buttonFontSize: 16
456
+ },
457
+ layout: {
458
+ actionButton: { translationKey: null },
459
+ billingFields: {
460
+ street: { enabled: !0 },
461
+ city: { enabled: !0 },
462
+ state: { enabled: !0 },
463
+ zipCode: { enabled: !0 },
464
+ firstName: { enabled: !0 },
465
+ lastName: { enabled: !0 },
466
+ country: { enabled: !0 }
467
+ }
468
+ },
469
+ additionalPaymentMethods: {}
470
+ }, H = class {
471
+ _cardNumber = "";
472
+ _cardExpiry = "";
473
+ _cardCvv = "";
474
+ _section = null;
475
+ _focusManager = new v();
476
+ _touchedFields = /* @__PURE__ */ new Set();
477
+ _focusHandlers = [];
478
+ get section() {
479
+ return this._section;
480
+ }
481
+ renderSection(e, t, n) {
482
+ this._section?.getElement().remove();
483
+ let { t: a } = o();
484
+ this._section = new s({
485
+ checkoutProfile: V,
486
+ cardNumber: this._cardNumber,
487
+ cardNumberTouched: !1,
488
+ cardCvv: this._cardCvv,
489
+ cardCvvTouched: !1,
490
+ cardExpiry: this._cardExpiry,
491
+ cardExpiryTouched: !1,
492
+ translationFunc: a,
493
+ onChange: (e) => {
494
+ let n = e.target;
495
+ if (n.name === "cardNumber") this._cardNumber = n.value;
496
+ else if (n.name === "cardExpiry") {
497
+ let e = i.cardExpiry(n.value);
498
+ this._cardExpiry = e, this._section?.updateCardExpiry(e);
499
+ } else n.name === "cardCvv" && (this._cardCvv = n.value);
500
+ this._touchedFields.add(n.name), this._updateFocusManagerState(), t(this.getValue());
501
+ },
502
+ onBlur: (e) => {
503
+ let t = e.target, i = t.name ?? "cardExpiry", a = r();
504
+ if (this._touchedFields.add(i), t.name === "cardNumber") {
505
+ let e = a.cardNumber(this._cardNumber);
506
+ this._section?.updateCardNumber(this._cardNumber, e, !0);
507
+ } else if (t.name === "cardCvv") {
508
+ let e = a.cardCvv(this._cardCvv, this._cardNumber);
509
+ this._section?.updateCardCvv(this._cardCvv, e, !0);
510
+ } else {
511
+ let e = a.cardExpiry(this._cardExpiry);
512
+ this._section?.updateCardExpiry(this._cardExpiry, e, !0);
513
+ }
514
+ this._updateFocusManagerState(), n(this.getValue());
515
+ }
516
+ }), e.appendChild(this._section.getElement()), this._registerFocusFields();
517
+ }
518
+ getValue() {
519
+ return {
520
+ number: this._cardNumber,
521
+ expiry: this._cardExpiry,
522
+ cvv: this._cardCvv
523
+ };
524
+ }
525
+ async getPayload(e) {
526
+ let t = e === "live" ? B : z, n = new b();
527
+ n.setPublicKey(t);
528
+ let r = this._cardNumber.replace(/\s+/g, ""), i = this._cardExpiry.replace(/\s+/g, "").split("/"), a = i[0] ?? "", o = i[1] ?? "";
529
+ return o.length === 2 && (o = `20${o}`), {
530
+ encryptedCardNumber: n.encrypt(r),
531
+ encryptedCvv: n.encrypt(this._cardCvv),
532
+ expMonth: a,
533
+ expYear: o
534
+ };
535
+ }
536
+ isValid() {
537
+ let e = r(), t = this._cardCvv.length >= 3;
538
+ return !e.cardNumber(this._cardNumber) && !e.cardExpiry(this._cardExpiry) && t;
539
+ }
540
+ getError() {
541
+ let e = r();
542
+ return e.cardNumber(this._cardNumber) ?? e.cardExpiry(this._cardExpiry) ?? null;
543
+ }
544
+ destroy() {
545
+ this._cleanupFocusHandlers(), this._section = null;
546
+ }
547
+ _registerFocusFields() {
548
+ if (this._cleanupFocusHandlers(), !this._section) return;
549
+ let e = this._section.getElement();
550
+ 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") });
551
+ for (let t of [
552
+ "cardNumber",
553
+ "cardExpiry",
554
+ "cardCvv"
555
+ ]) {
556
+ let n = e.querySelector(`input[name="${t}"]`);
557
+ if (!n) continue;
558
+ let r = () => this._focusManager.handleFieldFocus(t);
559
+ n.addEventListener("focus", r), this._focusHandlers.push(() => n.removeEventListener("focus", r));
560
+ }
561
+ }
562
+ _cleanupFocusHandlers() {
563
+ for (let e of this._focusHandlers) e();
564
+ this._focusHandlers = [];
565
+ }
566
+ _updateFocusManagerState() {
567
+ let e = r(), t = {
568
+ cardNumber: this._cardNumber,
569
+ cardExpiry: this._cardExpiry,
570
+ cardCvv: this._cardCvv,
571
+ name: "",
572
+ email: ""
573
+ }, n = {}, i = e.cardNumber(this._cardNumber), a = e.cardExpiry(this._cardExpiry), o = e.cardCvv(this._cardCvv, this._cardNumber);
574
+ i && (n.cardNumber = i), a && (n.cardExpiry = a), o && (n.cardCvv = o);
575
+ let s = {};
576
+ for (let e of this._touchedFields) s[e] = !0;
577
+ this._focusManager.handleStateUpdate(t, n, s);
578
+ }
579
+ }, U = class {
580
+ _vgsService;
581
+ _vgsJwt;
582
+ _vgsState = {};
583
+ _vgsFieldsValid = !1;
584
+ _vgsReinitTimer = null;
585
+ _currentTheme = {};
586
+ _environment = "test";
587
+ _section = null;
588
+ _initGeneration = 0;
589
+ constructor(e, n) {
590
+ this._vgsJwt = e, this._environment = n, this._vgsService = new t();
591
+ }
592
+ get section() {
593
+ return this._section;
594
+ }
595
+ renderSection(e, t) {
596
+ this._section?.getElement().remove();
597
+ let { t: n } = o();
598
+ this._section = new s({
599
+ checkoutProfile: V,
600
+ cardNumber: "",
601
+ cardNumberTouched: !1,
602
+ cardCvv: "",
603
+ cardCvvTouched: !1,
604
+ cardExpiry: "",
605
+ cardExpiryTouched: !1,
606
+ translationFunc: n,
607
+ onChange: () => {},
608
+ onBlur: () => {},
609
+ vgsService: this._vgsService
610
+ }), e.appendChild(this._section.getElement()), this._onChangeEmit = t;
611
+ }
612
+ _onChangeEmit = null;
613
+ initVgs() {
614
+ let e = ++this._initGeneration;
615
+ this._vgsService.init(this._environment).then((t) => {
616
+ e === this._initGeneration && (this._vgsService.createForm(t, (e) => this._handleStateChange(e)), this._mountFields(e));
617
+ });
618
+ }
619
+ async getPayload() {
620
+ if (!this._vgsJwt) throw Error("VGS not initialized");
621
+ let e = await this._vgsService.createCard(this._vgsJwt);
622
+ return {
623
+ cardId: e.cardId,
624
+ expMonth: e.expMonth,
625
+ expYear: e.expYear,
626
+ name: e.name
627
+ };
628
+ }
629
+ isValid() {
630
+ return this._vgsFieldsValid;
631
+ }
632
+ getError() {
633
+ let { t: e } = o();
634
+ for (let [t, n] of Object.entries(this._vgsState)) {
635
+ if (!n?.isTouched || n.isFocused || n.isValid) continue;
636
+ let r = n.errors?.[0];
637
+ if (!r) continue;
638
+ let i = g(t, r.code);
639
+ if (i) return e(i);
640
+ }
641
+ return null;
642
+ }
643
+ applyTheme(e) {
644
+ if (this._currentTheme = {
645
+ ...this._currentTheme,
646
+ ...e
647
+ }, !this._section) return;
648
+ let t = this._buildProfileFromTheme(this._currentTheme), n = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
649
+ this._section.updateVgsWrapperStyles(n, t.styles.borderRadius), this._reinitWithTheme();
650
+ }
651
+ resetTheme(e) {
652
+ for (let t of e) delete this._currentTheme[t];
653
+ if (!this._section) return;
654
+ let t = this._buildProfileFromTheme(this._currentTheme), n = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
655
+ this._section.updateVgsWrapperStyles(n, t.styles.borderRadius), this._reinitWithTheme();
656
+ }
657
+ destroy() {
658
+ this._vgsReinitTimer &&= (clearTimeout(this._vgsReinitTimer), null), this._vgsService.destroy(), this._section = null;
659
+ }
660
+ _reinitWithTheme() {
661
+ this._vgsReinitTimer && clearTimeout(this._vgsReinitTimer), this._vgsReinitTimer = setTimeout(() => {
662
+ this._vgsReinitTimer = null, this._vgsService.destroy(), this._vgsService = new t(), this.initVgs();
663
+ }, 300);
664
+ }
665
+ _buildProfileFromTheme(e) {
666
+ 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`;
667
+ return {
668
+ ...V,
669
+ styles: {
670
+ ...V.styles,
671
+ fontSize: parseInt(t, 10) || V.styles.fontSize,
672
+ fontFamily: n,
673
+ textColor: r,
674
+ borderRadius: parseInt(i, 10) || V.styles.borderRadius
675
+ }
676
+ };
677
+ }
678
+ async _mountFields(e) {
679
+ if (!this._section) return;
680
+ let t = Object.keys(this._currentTheme).length > 0 ? this._buildProfileFromTheme(this._currentTheme) : V, n = this._currentTheme["--odus-border-color"] ?? "#e0e0e0";
681
+ this._section.updateVgsWrapperStyles(n, t.styles.borderRadius);
682
+ let r = this._section.getVgsContainerIds();
683
+ for (let e of Object.values(r)) {
684
+ if (!e) continue;
685
+ let t = document.getElementById(e);
686
+ t && t.querySelectorAll("iframe").forEach((e) => e.remove());
687
+ }
688
+ let i = await y(t.styles.fontFamily);
689
+ if (e !== this._initGeneration) return;
690
+ let a = this._section.buildVgsFieldCss(t, i, {
691
+ borderColor: n,
692
+ backgroundColor: this._currentTheme["--odus-color-background"],
693
+ placeholderColor: this._currentTheme["--odus-input-placeholder-color"],
694
+ placeholderOpacity: this._currentTheme["--odus-input-placeholder-opacity"],
695
+ padding: this._currentTheme["--odus-input-padding"]
696
+ }), { t: s } = o();
697
+ this._vgsService.mountCardFields({
698
+ cardNumber: r.cardNumber ? `#${r.cardNumber}` : void 0,
699
+ cardExpiry: r.cardExpiry ? `#${r.cardExpiry}` : void 0,
700
+ cardCvv: r.cardCvv ? `#${r.cardCvv}` : void 0
701
+ }, a, {
702
+ cardNumber: "1234 5678 9012 3456",
703
+ cardExpiry: s("cardExpiry"),
704
+ cardCvv: "CVV",
705
+ cardholderName: s("cardholderName")
706
+ }, (e) => {
707
+ this._section?.updateVgsCardBrand(e);
708
+ }), this._vgsService.waitForFieldsReady().then(() => {
709
+ this._section?.hideFakePlaceholders();
710
+ });
711
+ }
712
+ _handleStateChange(e) {
713
+ this._vgsState = e, this._vgsFieldsValid = Object.values(e).every((e) => e?.isValid === !0);
714
+ let { t } = o(), n = this._deriveFieldErrors(t);
715
+ this._section?.handleVgsStateChange(e, n), this._onChangeEmit?.();
716
+ }
717
+ _deriveFieldErrors(e) {
718
+ let t = {};
719
+ for (let [n, r] of Object.entries(this._vgsState)) {
720
+ if (!r?.isTouched || r.isFocused || r.isValid) continue;
721
+ let i = r.errors?.[0];
722
+ if (!i) continue;
723
+ let a = g(n, i.code);
724
+ a && (t[n] = e(a));
725
+ }
726
+ return t;
727
+ }
728
+ }, W = class extends T {
729
+ _environment = "test";
730
+ _isVgsMode = !1;
731
+ _mountContainer = null;
732
+ _nativeAdapter = new H();
733
+ _vgsAdapter = null;
734
+ get isVgsMode() {
735
+ return this._isVgsMode;
736
+ }
737
+ setEnvironment(e) {
738
+ this._environment = e;
739
+ }
740
+ setVgsJwt(e) {
741
+ this._isVgsMode = !0, this._vgsAdapter = new U(e, this._environment), this.isMounted && this._mountContainer && (this.unmount(), this.mount(this._mountContainer));
742
+ }
743
+ mount(e) {
744
+ this.isMounted && this.unmount();
745
+ let t = typeof e == "string" ? document.querySelector(e) : e;
746
+ if (!t) throw Error(`[CardElement] mount target not found: ${String(e)}`);
747
+ if (this._mountContainer = e, this._isVgsMode) {
748
+ this.host = document.createElement("div");
749
+ let e = document.createElement("style");
750
+ e.textContent = this.getCss(), this.host.appendChild(e), t.appendChild(this.host), this.reapplyTheme(), Object.keys(this._appliedTheme).length > 0 && this._vgsAdapter?.applyTheme(this._appliedTheme), this.render(), this._vgsAdapter?.initVgs(), this.emit("ready");
751
+ } else super.mount(e);
752
+ }
753
+ unmount() {
754
+ this._isVgsMode ? (this.host?.parentElement?.removeChild(this.host), this.host = null, this.shadowRoot = null) : super.unmount();
755
+ }
756
+ render() {
757
+ if (this._isVgsMode) {
758
+ if (!this.host || !this._vgsAdapter) return;
759
+ this._vgsAdapter.renderSection(this.host, () => this.emit("change", this.getValue()));
760
+ } else {
761
+ if (!this.shadowRoot) return;
762
+ this._nativeAdapter.renderSection(this.shadowRoot, (e) => this.emit("change", e), (e) => this.emit("blur", e));
763
+ }
764
+ }
765
+ focus() {
766
+ (this._isVgsMode ? this._vgsAdapter?.section : this._nativeAdapter.section)?.focus();
767
+ }
768
+ focusField(e) {
769
+ (this._isVgsMode ? this._vgsAdapter?.section : this._nativeAdapter.section)?.focusField(e);
770
+ }
771
+ destroy() {
772
+ this._nativeAdapter.destroy(), this._vgsAdapter?.destroy(), this._vgsAdapter = null, super.destroy();
773
+ }
774
+ setTheme(e) {
775
+ super.setTheme(e), !(!this._isVgsMode || !this._vgsAdapter) && this._vgsAdapter.applyTheme(e);
776
+ }
777
+ resetTheme(e) {
778
+ super.resetTheme(e), !(!this._isVgsMode || !this._vgsAdapter) && this._vgsAdapter.resetTheme(Object.keys(e));
779
+ }
780
+ getCss() {
781
+ return super.getCss() + [
782
+ S,
783
+ C,
784
+ x,
785
+ R
786
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
787
+ }
788
+ getValue() {
789
+ return this._isVgsMode ? {
790
+ number: "",
791
+ expiry: "",
792
+ cvv: ""
793
+ } : this._nativeAdapter.getValue();
794
+ }
795
+ async getPayload() {
796
+ if (this._isVgsMode) {
797
+ if (!this._vgsAdapter) throw Error("VGS not initialized");
798
+ return this._vgsAdapter.getPayload();
799
+ }
800
+ return this._nativeAdapter.getPayload(this._environment);
801
+ }
802
+ getIsValid() {
803
+ return this._isVgsMode ? this._vgsAdapter?.isValid() ?? !1 : this._nativeAdapter.isValid();
804
+ }
805
+ getError() {
806
+ return this._isVgsMode ? this._vgsAdapter?.getError() ?? null : this._nativeAdapter.getError();
807
+ }
808
+ }, G = class extends T {
809
+ _value = "";
810
+ _error = null;
811
+ _input = null;
812
+ render() {
813
+ if (!this.shadowRoot) return;
814
+ this._input?.getElement().remove();
815
+ let { t: e } = o();
816
+ this._input = new u({
817
+ name: "billingAddress.cardholderName",
818
+ label: e("cardholderNameLabel"),
819
+ error: !1,
820
+ placeholder: e("cardholderNamePlaceholder"),
821
+ value: this._value,
822
+ autocomplete: "cc-name",
823
+ onChange: (e) => {
824
+ let t = e.target.value, n = t.replace(/[^a-zA-Z\s\-'.]/g, "");
825
+ t !== n && this._input?.setValue(n), this._value = n, this._error = null, this._input?.setError(!1), this.emit("change", this._value);
826
+ }
827
+ }), this._input.addEventListener("blur", () => {
828
+ let { t: e } = o();
829
+ this._error = this._value.trim() ? null : e("validation.nameRequired"), this._input?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._value);
830
+ }), this.shadowRoot.appendChild(this._input.getElement());
831
+ }
832
+ getCss() {
833
+ return super.getCss() + [
834
+ S,
835
+ C,
836
+ x
837
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
838
+ }
839
+ getValue() {
840
+ return this._value;
841
+ }
842
+ getIsValid() {
843
+ return !!this._value.trim();
844
+ }
845
+ getError() {
846
+ return this._error;
847
+ }
848
+ }, K = {
849
+ name: "odus-elements",
850
+ styles: {
851
+ fontSize: 14,
852
+ textColor: "#000000",
853
+ buttonColor: "#0070f3",
854
+ borderRadius: 4,
855
+ fontFamily: "system-ui",
856
+ buttonTextColor: "#ffffff",
857
+ buttonFontSize: 16
858
+ },
859
+ layout: {
860
+ actionButton: { translationKey: null },
861
+ billingFields: {
862
+ street: { enabled: !1 },
863
+ city: { enabled: !1 },
864
+ state: { enabled: !1 },
865
+ zipCode: { enabled: !1 },
866
+ firstName: { enabled: !1 },
867
+ lastName: { enabled: !1 },
868
+ country: { enabled: !1 }
869
+ }
870
+ },
871
+ additionalPaymentMethods: {}
872
+ }, q = class extends T {
873
+ _email = "";
874
+ _error = null;
875
+ _field = null;
876
+ render() {
877
+ if (!this.shadowRoot) return;
878
+ this._field?.getElement().remove(), this.options.initialValue && !this._email && (this._email = String(this.options.initialValue));
879
+ let { t: e } = o();
880
+ this._field = new l({
881
+ value: this._email,
882
+ error: !1,
883
+ checkoutProfile: K,
884
+ translationFunc: e,
885
+ onChange: (e) => {
886
+ let t = e.target;
887
+ this._email = t.value ?? this._field?.getValue() ?? "", this._error = null, this._field?.setError(!1), this.emit("change", this._email);
888
+ },
889
+ onBlur: () => {
890
+ let e = r();
891
+ this._error = e.email(this._email) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._email);
892
+ }
893
+ }), this.shadowRoot.appendChild(this._field.getElement());
894
+ }
895
+ getCss() {
896
+ return super.getCss() + [
897
+ S,
898
+ C,
899
+ x
900
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
901
+ }
902
+ getValue() {
903
+ return this._email;
904
+ }
905
+ getIsValid() {
906
+ return !r().email(this._email);
907
+ }
908
+ getError() {
909
+ return this._error;
910
+ }
911
+ }, 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 {
912
+ _alert = null;
913
+ _message = null;
914
+ render() {
915
+ this.shadowRoot && (this._alert?.getElement().remove(), this._alert = null, this._message && (this._alert = new _({ message: this._message }), this.shadowRoot.appendChild(this._alert.getElement())));
916
+ }
917
+ setError(e) {
918
+ if (this._message = e, !this.shadowRoot) {
919
+ this.emit("error", e);
920
+ return;
921
+ }
922
+ this._alert ? this._alert.setMessage(e) : (this._alert = new _({ message: e }), this.shadowRoot.appendChild(this._alert.getElement())), this.emit("error", e);
923
+ }
924
+ clearError() {
925
+ this._message = null, this._alert?.getElement().remove(), this._alert = null;
926
+ }
927
+ getCss() {
928
+ 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 ";
929
+ }
930
+ getValue() {
931
+ return null;
932
+ }
933
+ getIsValid() {
934
+ return !0;
935
+ }
936
+ getError() {
937
+ return this._message;
938
+ }
939
+ }, 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 = {
940
+ name: "odus-elements",
941
+ styles: {
942
+ fontSize: 14,
943
+ textColor: "#000000",
944
+ buttonColor: "#0070f3",
945
+ borderRadius: 4,
946
+ fontFamily: "system-ui",
947
+ buttonTextColor: "#ffffff",
948
+ buttonFontSize: 16
949
+ },
950
+ layout: {
951
+ actionButton: { translationKey: null },
952
+ billingFields: {
953
+ street: { enabled: !1 },
954
+ city: { enabled: !1 },
955
+ state: { enabled: !1 },
956
+ zipCode: { enabled: !1 },
957
+ firstName: { enabled: !1 },
958
+ lastName: { enabled: !1 },
959
+ country: { enabled: !1 }
960
+ }
961
+ },
962
+ additionalPaymentMethods: {}
963
+ }, Q = class extends T {
964
+ _paymentContext = null;
965
+ _button = null;
966
+ setPaymentContext(e) {
967
+ this._paymentContext = e, this.isMounted && this.render();
968
+ }
969
+ render() {
970
+ if (!this.shadowRoot || (this._button?.getElement().remove(), this._button = null, !this._paymentContext)) return;
971
+ let { onAuthorize: e } = this._paymentContext;
972
+ this._button = new f({
973
+ checkoutProfile: Z,
974
+ onSubmit: async () => {
975
+ this._button?.setSubmitting(!0);
976
+ try {
977
+ await e();
978
+ } finally {
979
+ this._button?.setSubmitting(!1);
980
+ }
981
+ }
982
+ }), this.shadowRoot.appendChild(this._button.getElement());
983
+ }
984
+ getCss() {
985
+ 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 ";
986
+ }
987
+ getValue() {
988
+ return null;
989
+ }
990
+ getIsValid() {
991
+ return !0;
992
+ }
993
+ getError() {
994
+ return null;
995
+ }
996
+ }, 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 = {
997
+ name: "odus-elements",
998
+ styles: {
999
+ fontSize: 14,
1000
+ textColor: "#000000",
1001
+ buttonColor: "#0070f3",
1002
+ borderRadius: 4,
1003
+ fontFamily: "system-ui",
1004
+ buttonTextColor: "#ffffff",
1005
+ buttonFontSize: 16
1006
+ },
1007
+ layout: {
1008
+ actionButton: { translationKey: null },
1009
+ billingFields: {
1010
+ street: { enabled: !1 },
1011
+ city: { enabled: !1 },
1012
+ state: { enabled: !1 },
1013
+ zipCode: { enabled: !1 },
1014
+ firstName: { enabled: !1 },
1015
+ lastName: { enabled: !1 },
1016
+ country: { enabled: !1 }
1017
+ }
1018
+ },
1019
+ additionalPaymentMethods: {}
1020
+ }, $ = class extends T {
1021
+ _phone = "";
1022
+ _error = null;
1023
+ _field = null;
1024
+ _renderGeneration = 0;
1025
+ render() {
1026
+ if (!this.shadowRoot) return;
1027
+ this._field?.destroy(), this._field?.getElement().remove(), this._field = null, this.options.initialValue && !this._phone && (this._phone = String(this.options.initialValue));
1028
+ let e = ++this._renderGeneration;
1029
+ a().then(({ PhoneNumberField: t }) => {
1030
+ if (!this.shadowRoot || this._renderGeneration !== e) return;
1031
+ let { t: n, locale: i } = o();
1032
+ this._field = new t({
1033
+ value: this._phone,
1034
+ error: !1,
1035
+ checkoutProfile: ne,
1036
+ translationFunc: n,
1037
+ locale: i,
1038
+ onChange: () => {
1039
+ this._phone = this._field?.getValue() ?? "", this._error = null, this._field?.setError(!1), this.emit("change", this._phone);
1040
+ },
1041
+ onBlur: () => {
1042
+ this._phone = this._field?.getValue() ?? "";
1043
+ let e = r(), t = this._field?.getCountry();
1044
+ this._error = e.phoneNumber(this._phone, t) ?? null, this._field?.setError(!!this._error, this._error ?? void 0), this.emit("blur", this._phone);
1045
+ }
1046
+ }), this.shadowRoot.appendChild(this._field.getElement());
1047
+ });
1048
+ }
1049
+ getCss() {
1050
+ return super.getCss() + [
1051
+ S,
1052
+ C,
1053
+ x,
1054
+ te
1055
+ ].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 box-shadow:\n 0 0 0 1px var(--odus-color-error, #dc2727),\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-helper-text {\n color: var(--odus-color-error, #dc2727) !important;\n }\n ";
1056
+ }
1057
+ getValue() {
1058
+ return this._phone;
1059
+ }
1060
+ getIsValid() {
1061
+ let e = r(), t = this._field?.getCountry();
1062
+ return !e.phoneNumber(this._phone, t);
1063
+ }
1064
+ getError() {
1065
+ return this._error;
1066
+ }
1067
+ }, re = class {
1068
+ _config;
1069
+ _apiService;
1070
+ _changeListeners = [];
1071
+ _callbacks;
1072
+ _paymentState = {};
1073
+ _fontCleanup;
1074
+ _card;
1075
+ _email;
1076
+ _phone;
1077
+ _addressStreet;
1078
+ _addressFirstName;
1079
+ _addressLastName;
1080
+ _cardholderName;
1081
+ _addressCity;
1082
+ _addressState;
1083
+ _addressZipCode;
1084
+ _addressCountry;
1085
+ _applePay;
1086
+ _paypal;
1087
+ _error;
1088
+ elements;
1089
+ constructor(t) {
1090
+ this._config = t, this._callbacks = { ...t.callbacks }, t.locale && e.setLocale(t.locale), this._apiService = new n(t.apiKey, t.environment);
1091
+ let r = {};
1092
+ Object.defineProperty(r, "email", {
1093
+ get: () => (this._email || (this._email = new q(), this._trackElement(this._email)), this._email),
1094
+ enumerable: !0
1095
+ }), Object.defineProperty(r, "phone", {
1096
+ get: () => (this._phone || (this._phone = new $(), this._trackElement(this._phone)), this._phone),
1097
+ enumerable: !0
1098
+ });
1099
+ let i = {};
1100
+ Object.defineProperty(i, "applePay", {
1101
+ get: () => (this._applePay || (this._applePay = new L(), this._trackElement(this._applePay), this._paymentState.paymentId && this._paymentState.checkoutKey && this._applePay.setPaymentContext({
1102
+ paymentId: this._paymentState.paymentId,
1103
+ checkoutKey: this._paymentState.checkoutKey,
1104
+ environment: this._config.environment,
1105
+ checkoutDetails: this._paymentState.checkoutDetails,
1106
+ ...this._config.additionalPaymentMethods?.applePay,
1107
+ onAuthorize: (e) => this._executeAuthorization({
1108
+ formData: null,
1109
+ applePayData: e
1110
+ })
1111
+ })), this._applePay),
1112
+ enumerable: !0
1113
+ }), Object.defineProperty(i, "payPal", {
1114
+ get: () => (this._paypal || (this._paypal = new Q(), this._trackElement(this._paypal), this._paymentState.paymentId && this._paymentState.checkoutKey && this._paypal.setPaymentContext({
1115
+ paymentId: this._paymentState.paymentId,
1116
+ checkoutKey: this._paymentState.checkoutKey,
1117
+ onAuthorize: () => this._executeAuthorization({ formData: null })
1118
+ })), this._paypal),
1119
+ enumerable: !0
1120
+ });
1121
+ let a = {};
1122
+ Object.defineProperty(a, "street", {
1123
+ get: () => (this._addressStreet || (this._addressStreet = new N(), this._trackElement(this._addressStreet)), this._addressStreet),
1124
+ enumerable: !0
1125
+ }), Object.defineProperty(a, "firstName", {
1126
+ get: () => (this._addressFirstName || (this._addressFirstName = new k(), this._trackElement(this._addressFirstName)), this._addressFirstName),
1127
+ enumerable: !0
1128
+ }), Object.defineProperty(a, "lastName", {
1129
+ get: () => (this._addressLastName || (this._addressLastName = new A(), this._trackElement(this._addressLastName)), this._addressLastName),
1130
+ enumerable: !0
1131
+ }), Object.defineProperty(a, "city", {
1132
+ get: () => (this._addressCity || (this._addressCity = new E(), this._trackElement(this._addressCity)), this._addressCity),
1133
+ enumerable: !0
1134
+ }), Object.defineProperty(a, "state", {
1135
+ get: () => (this._addressState || (this._addressState = new M(), this._trackElement(this._addressState), this._addressCountry?.value && this._addressState.setCountry(this._addressCountry.value)), this._addressState),
1136
+ enumerable: !0
1137
+ }), Object.defineProperty(a, "zipCode", {
1138
+ get: () => (this._addressZipCode || (this._addressZipCode = new P(), this._trackElement(this._addressZipCode)), this._addressZipCode),
1139
+ enumerable: !0
1140
+ }), Object.defineProperty(a, "country", {
1141
+ get: () => (this._addressCountry || (this._addressCountry = new O(), this._trackElement(this._addressCountry), this._addressCountry.on("change", (e) => {
1142
+ this._addressState?.setCountry(e);
1143
+ })), this._addressCountry),
1144
+ enumerable: !0
1145
+ });
1146
+ let o = {
1147
+ contact: r,
1148
+ express: i
1149
+ };
1150
+ Object.defineProperty(o, "card", {
1151
+ 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),
1152
+ enumerable: !0
1153
+ }), Object.defineProperty(o, "cardholderName", {
1154
+ get: () => (this._cardholderName || (this._cardholderName = new G(), this._trackElement(this._cardholderName)), this._cardholderName),
1155
+ enumerable: !0
1156
+ }), Object.defineProperty(o, "address", {
1157
+ get: () => a,
1158
+ enumerable: !0
1159
+ }), Object.defineProperty(o, "error", {
1160
+ get: () => (this._error || (this._error = new Y(), this._trackElement(this._error)), this._error),
1161
+ enumerable: !0
1162
+ }), this.elements = o;
1163
+ }
1164
+ async associatePayment(e, t) {
1165
+ if (!e || !t) throw Error("paymentId and checkoutKey are required");
1166
+ this._paymentState.paymentId = e, this._paymentState.checkoutKey = t;
1167
+ let n = await m({
1168
+ id: e,
1169
+ checkoutKey: t,
1170
+ environment: this._config.environment
1171
+ });
1172
+ this._paymentState.checkoutDetails = {
1173
+ amount: n.amount,
1174
+ currency: n.currency,
1175
+ countryCode: n.countryCode
1176
+ }, n.vgsJwt && (this._paymentState.vgsJwt = n.vgsJwt, this._card?.setVgsJwt(n.vgsJwt)), this._card?.setEnvironment(this._config.environment), this._applePay?.setPaymentContext({
1177
+ paymentId: e,
1178
+ checkoutKey: t,
1179
+ environment: this._config.environment,
1180
+ checkoutDetails: this._paymentState.checkoutDetails,
1181
+ ...this._config.additionalPaymentMethods?.applePay,
1182
+ onAuthorize: (e) => this._executeAuthorization({
1183
+ formData: null,
1184
+ applePayData: e
1185
+ })
1186
+ }), this._paypal?.setPaymentContext({
1187
+ paymentId: e,
1188
+ checkoutKey: t,
1189
+ onAuthorize: () => this._executeAuthorization({ formData: null })
1190
+ });
1191
+ }
1192
+ validate() {
1193
+ let e = {}, { t } = o();
1194
+ 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"), {
1195
+ valid: Object.keys(e).length === 0,
1196
+ errors: e
1197
+ };
1198
+ }
1199
+ async _getPayload() {
1200
+ if (this._applePay?.isMounted && this._applePay.isValid) return null;
1201
+ 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 ? {
1202
+ street: this._addressStreet?.isMounted ? this._addressStreet.value : "",
1203
+ city: this._addressCity?.isMounted ? this._addressCity.value : "",
1204
+ country: this._addressCountry?.isMounted ? this._addressCountry.value : "",
1205
+ firstName: this._addressFirstName?.isMounted ? this._addressFirstName.value : "",
1206
+ lastName: this._addressLastName?.isMounted ? this._addressLastName.value : "",
1207
+ state: this._addressState?.isMounted ? this._addressState.value : "",
1208
+ zipCode: this._addressZipCode?.isMounted ? this._addressZipCode.value : ""
1209
+ } : void 0, r = this._cardholderName?.isMounted ? this._cardholderName.value : "", i = [n?.firstName ?? "", n?.lastName ?? ""].filter(Boolean), a = r || i.join(" ");
1210
+ if (this._card?.isMounted && this._card.isVgsMode) try {
1211
+ let r = await this._card.getPayload();
1212
+ return {
1213
+ name: a,
1214
+ email: e,
1215
+ phoneNumber: t || void 0,
1216
+ cardNumber: "",
1217
+ cardExpiry: "",
1218
+ cardCvv: "",
1219
+ billingAddress: n,
1220
+ vgsCardData: r
1221
+ };
1222
+ } catch {
1223
+ return this._handleAuthorizationError({
1224
+ message: "We couldn't securely process your card details. Please check your card information and try again.",
1225
+ status: 0,
1226
+ statusText: "Card Tokenization Failed"
1227
+ }), null;
1228
+ }
1229
+ let o = this._card?.isMounted ? this._card.value : null;
1230
+ return o ? {
1231
+ name: a,
1232
+ email: e,
1233
+ phoneNumber: t || void 0,
1234
+ cardNumber: o.number,
1235
+ cardExpiry: o.expiry,
1236
+ cardCvv: o.cvv,
1237
+ billingAddress: n
1238
+ } : null;
1239
+ }
1240
+ async authorize(e) {
1241
+ if (!this._paymentState.paymentId || !this._paymentState.checkoutKey) throw Error("Call associatePayment() before authorize()");
1242
+ if (this._applePay?.isMounted && this._applePay.isValid) {
1243
+ await this._executeAuthorization({
1244
+ formData: null,
1245
+ applePayData: this._applePay.value
1246
+ });
1247
+ return;
1248
+ }
1249
+ let t = await this._getPayload();
1250
+ await this._executeAuthorization({
1251
+ formData: t,
1252
+ applePayData: void 0,
1253
+ customCustomerData: e?.customerData
1254
+ });
1255
+ }
1256
+ applyTheme(e) {
1257
+ let t = e["--odus-font-family"];
1258
+ if (t) {
1259
+ this._fontCleanup?.();
1260
+ let { cleanup: e } = ee({ fontFamily: t });
1261
+ this._fontCleanup = e;
1262
+ }
1263
+ for (let t of this._allElements()) t.setTheme(e);
1264
+ }
1265
+ resetTheme(e) {
1266
+ "--odus-font-family" in e && (this._fontCleanup?.(), this._fontCleanup = void 0);
1267
+ for (let t of this._allElements()) t.resetTheme(e);
1268
+ }
1269
+ get isValid() {
1270
+ return this.validate().valid;
1271
+ }
1272
+ onChange(e) {
1273
+ this._changeListeners.push(e);
1274
+ }
1275
+ destroy() {
1276
+ 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;
1277
+ }
1278
+ setCallbacks(e) {
1279
+ Object.assign(this._callbacks, e);
1280
+ }
1281
+ _trackElement(e) {
1282
+ e.on("change", () => {
1283
+ for (let e of this._changeListeners) e();
1284
+ });
1285
+ }
1286
+ _allElements() {
1287
+ return [
1288
+ this._card,
1289
+ this._email,
1290
+ this._phone,
1291
+ this._addressStreet,
1292
+ this._addressFirstName,
1293
+ this._addressLastName,
1294
+ this._cardholderName,
1295
+ this._addressCity,
1296
+ this._addressState,
1297
+ this._addressZipCode,
1298
+ this._addressCountry,
1299
+ this._applePay,
1300
+ this._paypal,
1301
+ this._error
1302
+ ].filter((e) => e !== void 0);
1303
+ }
1304
+ async _executeAuthorization({ formData: e, applePayData: t, customCustomerData: n }) {
1305
+ try {
1306
+ let r = await this._apiService.authorizePayment({
1307
+ paymentId: this._paymentState.paymentId,
1308
+ checkoutKey: this._paymentState.checkoutKey,
1309
+ formData: e,
1310
+ returnUrl: this._config.returnUrl,
1311
+ applePayData: t,
1312
+ customCustomerData: n
1313
+ });
1314
+ this._handlePaymentResponse(r);
1315
+ } catch (e) {
1316
+ this._handleAuthorizationError(e);
1317
+ }
1318
+ }
1319
+ _handlePaymentResponse(e) {
1320
+ if (e.latestTransaction.status === "authorized") {
1321
+ this._callbacks.onPaymentSucceeded?.(e.latestTransaction.status);
1322
+ return;
1323
+ }
1324
+ if (e.latestTransaction.status === "failed") {
1325
+ this._callbacks.onPaymentFailed?.(e.latestTransaction.status);
1326
+ return;
1327
+ }
1328
+ e.status === "requires_action" && this._callbacks.onActionRequired?.(e.action.redirectUrl);
1329
+ }
1330
+ _handleAuthorizationError(e) {
1331
+ let t = e.details?.message ?? "Payment failed";
1332
+ this._callbacks.onPaymentFailed?.(t), this._error?.isMounted && this._error.setError(t);
1333
+ }
1751
1334
  };
1335
+ //#endregion
1336
+ 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 };