@getspot/spot-widget 3.0.5 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/index.es.js +271 -274
- package/dist/index.umd.js +4 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# @getspot/spot-widget [3.1.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.0.5...@getspot/spot-widget@3.1.0) (2025-11-17)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **core:** Replace "terms and conditions" text with T&C link ([4b37ae3](https://gitlab.com/getspot/spot-widget/commit/4b37ae31ad5d163f0e10729a1f409e347cd4455c))
|
|
7
|
+
|
|
1
8
|
## @getspot/spot-widget [3.0.5](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.0.4...@getspot/spot-widget@3.0.5) (2025-10-30)
|
|
2
9
|
|
|
3
10
|
|
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
async function x(m, t,
|
|
1
|
+
async function x(m, t, o) {
|
|
2
2
|
try {
|
|
3
3
|
const s = await fetch(m, {
|
|
4
4
|
method: "POST",
|
|
@@ -6,44 +6,44 @@ async function x(m, t, r) {
|
|
|
6
6
|
"Content-Type": "application/json",
|
|
7
7
|
"X-Spot-Partner-Id": t
|
|
8
8
|
},
|
|
9
|
-
body: JSON.stringify(
|
|
10
|
-
}),
|
|
9
|
+
body: JSON.stringify(o)
|
|
10
|
+
}), n = await s.json();
|
|
11
11
|
if (!s.ok) {
|
|
12
|
-
const
|
|
13
|
-
throw
|
|
12
|
+
const r = new Error((n == null ? void 0 : n.message) || "Failed to fetch quote");
|
|
13
|
+
throw r.status = s.status, r.responseBody = n, r;
|
|
14
14
|
}
|
|
15
|
-
return
|
|
15
|
+
return n;
|
|
16
16
|
} catch (s) {
|
|
17
17
|
throw s instanceof Error ? s : new Error("Unknown error occurred while fetching quote");
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
async function H(m, t,
|
|
20
|
+
async function H(m, t, o) {
|
|
21
21
|
try {
|
|
22
|
-
const s = m.replace("/quote", "/quote/batch"),
|
|
22
|
+
const s = m.replace("/quote", "/quote/batch"), n = await fetch(s, {
|
|
23
23
|
method: "POST",
|
|
24
24
|
headers: {
|
|
25
25
|
"Content-Type": "application/json",
|
|
26
26
|
"X-Spot-Partner-Id": t
|
|
27
27
|
},
|
|
28
|
-
body: JSON.stringify(
|
|
29
|
-
}),
|
|
30
|
-
if (!
|
|
31
|
-
const
|
|
32
|
-
throw
|
|
28
|
+
body: JSON.stringify(o)
|
|
29
|
+
}), r = await n.json();
|
|
30
|
+
if (!n.ok) {
|
|
31
|
+
const i = new Error((r == null ? void 0 : r.message) || "Failed to fetch batch quote");
|
|
32
|
+
throw i.status = n.status, i.responseBody = r, i;
|
|
33
33
|
}
|
|
34
|
-
return
|
|
34
|
+
return r;
|
|
35
35
|
} catch (s) {
|
|
36
36
|
throw s instanceof Error ? s : new Error("Unknown error occurred while fetching batch quote");
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
async function I(m, t,
|
|
39
|
+
async function I(m, t, o) {
|
|
40
40
|
var s;
|
|
41
41
|
try {
|
|
42
|
-
const
|
|
43
|
-
cartId:
|
|
44
|
-
cartName:
|
|
45
|
-
currencyCode:
|
|
46
|
-
items:
|
|
42
|
+
const n = {
|
|
43
|
+
cartId: o.cartInfo.cartId,
|
|
44
|
+
cartName: o.cartInfo.cartName,
|
|
45
|
+
currencyCode: o.cartInfo.currencyCode,
|
|
46
|
+
items: o.items.map((a, u) => ({
|
|
47
47
|
cartItemId: a.cartItemId || `item-${u + 1}`,
|
|
48
48
|
productPrice: a.productPrice,
|
|
49
49
|
productType: a.productType,
|
|
@@ -55,40 +55,40 @@ async function I(m, t, r) {
|
|
|
55
55
|
startDate: a.startDate,
|
|
56
56
|
endDate: a.endDate
|
|
57
57
|
}))
|
|
58
|
-
},
|
|
59
|
-
if (
|
|
58
|
+
}, r = await H(m, t, n);
|
|
59
|
+
if (r.status !== "QUOTES_AVAILABLE" && r.status !== "QUOTE_AVAILABLE")
|
|
60
60
|
return { status: "NO_MATCHING_QUOTE" };
|
|
61
|
-
const
|
|
62
|
-
const u =
|
|
61
|
+
const i = r.quotes.map((a) => {
|
|
62
|
+
const u = o.items.find(
|
|
63
63
|
(h, f) => (h.cartItemId || `item-${f + 1}`) === a.cartItemId
|
|
64
64
|
);
|
|
65
65
|
return u ? u.participantDescription ? `${u.productName} - ${u.participantDescription}` : u.productName : `Item ${a.id}`;
|
|
66
|
-
}),
|
|
66
|
+
}), e = Math.round((r.totalSpotPrice || r.spotPrice || 0) * 100) / 100;
|
|
67
67
|
return {
|
|
68
68
|
status: "QUOTE_AVAILABLE",
|
|
69
69
|
data: {
|
|
70
|
-
id:
|
|
71
|
-
spotPrice:
|
|
72
|
-
currencyCode:
|
|
70
|
+
id: r.quotes ? r.quotes.map((a) => a.id).join(",") : ((s = r.data) == null ? void 0 : s.id) || "",
|
|
71
|
+
spotPrice: e,
|
|
72
|
+
currencyCode: r.currencyCode || "",
|
|
73
73
|
communication: {
|
|
74
|
-
...
|
|
75
|
-
yesOptionText:
|
|
76
|
-
String(
|
|
77
|
-
String(
|
|
74
|
+
...r.communication,
|
|
75
|
+
yesOptionText: r.communication.yesOptionText.replace(
|
|
76
|
+
String(r.totalSpotPrice),
|
|
77
|
+
String(e)
|
|
78
78
|
)
|
|
79
79
|
},
|
|
80
|
-
payoutSchedule:
|
|
80
|
+
payoutSchedule: r.payoutSchedule.map((a) => ({
|
|
81
81
|
...a,
|
|
82
82
|
amount: a.amount !== void 0 ? a.amount : 0
|
|
83
83
|
})),
|
|
84
|
-
coveredItems:
|
|
85
|
-
originalQuotes:
|
|
84
|
+
coveredItems: i,
|
|
85
|
+
originalQuotes: r.quotes || (r.data ? [r.data] : [])
|
|
86
86
|
},
|
|
87
|
-
spotPrice:
|
|
88
|
-
coveredItems:
|
|
87
|
+
spotPrice: e,
|
|
88
|
+
coveredItems: i
|
|
89
89
|
};
|
|
90
|
-
} catch (
|
|
91
|
-
throw
|
|
90
|
+
} catch (n) {
|
|
91
|
+
throw n instanceof Error ? n : new Error("Unknown error occurred while fetching multiple quotes");
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
const z = {
|
|
@@ -99,20 +99,20 @@ const z = {
|
|
|
99
99
|
function D(m) {
|
|
100
100
|
const {
|
|
101
101
|
apiConfig: t = {},
|
|
102
|
-
quoteRequestData:
|
|
102
|
+
quoteRequestData: o,
|
|
103
103
|
callbacks: s = {},
|
|
104
|
-
location:
|
|
105
|
-
theme:
|
|
104
|
+
location: n,
|
|
105
|
+
theme: r
|
|
106
106
|
} = m, {
|
|
107
|
-
environment:
|
|
108
|
-
partnerId:
|
|
107
|
+
environment: i = "sandbox",
|
|
108
|
+
partnerId: e,
|
|
109
109
|
customEndpoint: a
|
|
110
110
|
} = t;
|
|
111
|
-
if (!
|
|
111
|
+
if (!e || typeof e != "string")
|
|
112
112
|
throw new Error("Invalid or missing partnerId in apiConfig");
|
|
113
|
-
if (!(a || z[
|
|
114
|
-
throw new Error(`Invalid environment in apiConfig: ${
|
|
115
|
-
if (!
|
|
113
|
+
if (!(a || z[i]))
|
|
114
|
+
throw new Error(`Invalid environment in apiConfig: ${i}`);
|
|
115
|
+
if (!o || typeof o != "object" && !Array.isArray(o))
|
|
116
116
|
throw new Error("quoteRequestData must be a non-null object or array");
|
|
117
117
|
const h = [
|
|
118
118
|
"startDate",
|
|
@@ -126,48 +126,48 @@ function D(m) {
|
|
|
126
126
|
"cartId",
|
|
127
127
|
"productName"
|
|
128
128
|
];
|
|
129
|
-
function f(
|
|
129
|
+
function f(p, d = null) {
|
|
130
130
|
const l = d !== null ? `quoteRequestData[${d}]` : "quoteRequestData";
|
|
131
131
|
h.forEach((v) => {
|
|
132
|
-
if (!Object.prototype.hasOwnProperty.call(
|
|
132
|
+
if (!Object.prototype.hasOwnProperty.call(p, v) || p[v] === void 0 || p[v] === null)
|
|
133
133
|
throw new Error(`Missing required ${l} field: '${v}'`);
|
|
134
134
|
});
|
|
135
|
-
const
|
|
136
|
-
if (!
|
|
135
|
+
const w = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
|
|
136
|
+
if (!w.test(p.startDate))
|
|
137
137
|
throw new Error(`${l}.startDate must be a valid ISO8601 string`);
|
|
138
|
-
if (!
|
|
138
|
+
if (!w.test(p.endDate))
|
|
139
139
|
throw new Error(`${l}.endDate must be a valid ISO8601 string`);
|
|
140
|
-
if (typeof
|
|
140
|
+
if (typeof p.currencyCode != "string")
|
|
141
141
|
throw new Error(`${l}.currencyCode must be a string`);
|
|
142
|
-
if (!["USD", "CAD", "AUD"].includes(
|
|
143
|
-
throw new Error(`Invalid ${l}.currencyCode: ${
|
|
144
|
-
if (typeof
|
|
142
|
+
if (!["USD", "CAD", "AUD"].includes(p.currencyCode))
|
|
143
|
+
throw new Error(`Invalid ${l}.currencyCode: ${p.currencyCode}`);
|
|
144
|
+
if (typeof p.eventType != "string")
|
|
145
145
|
throw new Error(`${l}.eventType must be a string`);
|
|
146
|
-
if (typeof
|
|
146
|
+
if (typeof p.productType != "string")
|
|
147
147
|
throw new Error(`${l}.productType must be a string`);
|
|
148
148
|
const g = ["Pass", "Trip", "Registration"];
|
|
149
|
-
if (!g.includes(
|
|
149
|
+
if (!g.includes(p.productType))
|
|
150
150
|
throw new Error(
|
|
151
151
|
`${l}.productType must be one of ${g.join(", ")}`
|
|
152
152
|
);
|
|
153
|
-
if (typeof
|
|
153
|
+
if (typeof p.productDuration != "string")
|
|
154
154
|
throw new Error(`${l}.productDuration must be a string`);
|
|
155
|
-
const
|
|
156
|
-
if (!
|
|
155
|
+
const b = ["Daily", "Seasonal", "Trip", "Event"];
|
|
156
|
+
if (!b.includes(p.productDuration))
|
|
157
157
|
throw new Error(
|
|
158
|
-
`${l}.productDuration must be one of ${
|
|
158
|
+
`${l}.productDuration must be one of ${b.join(", ")}`
|
|
159
159
|
);
|
|
160
|
-
if (typeof
|
|
160
|
+
if (typeof p.productPrice != "number" || isNaN(p.productPrice))
|
|
161
161
|
throw new Error(`${l}.productPrice must be a valid number`);
|
|
162
|
-
if (typeof
|
|
162
|
+
if (typeof p.productId != "string")
|
|
163
163
|
throw new Error(`${l}.productId must be a string`);
|
|
164
|
-
if (typeof
|
|
164
|
+
if (typeof p.cartId != "string")
|
|
165
165
|
throw new Error(`${l}.cartId must be a string`);
|
|
166
|
-
if (typeof
|
|
166
|
+
if (typeof p.productName != "string")
|
|
167
167
|
throw new Error(`${l}.productName must be a string`);
|
|
168
168
|
}
|
|
169
|
-
if ("cartInfo" in
|
|
170
|
-
const
|
|
169
|
+
if ("cartInfo" in o && "items" in o) {
|
|
170
|
+
const p = o, { cartInfo: d, items: l } = p;
|
|
171
171
|
if (!d || typeof d != "object")
|
|
172
172
|
throw new Error("quoteRequestData.cartInfo must be a non-null object");
|
|
173
173
|
if (!d.cartId || typeof d.cartId != "string")
|
|
@@ -190,10 +190,10 @@ function D(m) {
|
|
|
190
190
|
"productId",
|
|
191
191
|
"productName"
|
|
192
192
|
];
|
|
193
|
-
l.forEach((g,
|
|
193
|
+
l.forEach((g, b) => {
|
|
194
194
|
if (!g || typeof g != "object")
|
|
195
|
-
throw new Error(`quoteRequestData.items[${
|
|
196
|
-
const v = `quoteRequestData.items[${
|
|
195
|
+
throw new Error(`quoteRequestData.items[${b}] must be a non-null object`);
|
|
196
|
+
const v = `quoteRequestData.items[${b}]`;
|
|
197
197
|
_.forEach((C) => {
|
|
198
198
|
if (!Object.prototype.hasOwnProperty.call(g, C) || g[C] === void 0 || g[C] === null)
|
|
199
199
|
throw new Error(`Missing required ${v} field: '${C}'`);
|
|
@@ -207,14 +207,14 @@ function D(m) {
|
|
|
207
207
|
throw new Error(`${v}.eventType must be a string`);
|
|
208
208
|
if (typeof g.productType != "string")
|
|
209
209
|
throw new Error(`${v}.productType must be a string`);
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
212
|
-
throw new Error(`${v}.productType must be one of ${
|
|
210
|
+
const k = ["Pass", "Trip", "Registration"];
|
|
211
|
+
if (!k.includes(g.productType))
|
|
212
|
+
throw new Error(`${v}.productType must be one of ${k.join(", ")}`);
|
|
213
213
|
if (typeof g.productDuration != "string")
|
|
214
214
|
throw new Error(`${v}.productDuration must be a string`);
|
|
215
|
-
const
|
|
216
|
-
if (!
|
|
217
|
-
throw new Error(`${v}.productDuration must be one of ${
|
|
215
|
+
const E = ["Daily", "Seasonal", "Trip", "Event"];
|
|
216
|
+
if (!E.includes(g.productDuration))
|
|
217
|
+
throw new Error(`${v}.productDuration must be one of ${E.join(", ")}`);
|
|
218
218
|
if (typeof g.productPrice != "number" || isNaN(g.productPrice))
|
|
219
219
|
throw new Error(`${v}.productPrice must be a valid number`);
|
|
220
220
|
if (typeof g.productId != "string")
|
|
@@ -222,71 +222,71 @@ function D(m) {
|
|
|
222
222
|
if (typeof g.productName != "string")
|
|
223
223
|
throw new Error(`${v}.productName must be a string`);
|
|
224
224
|
});
|
|
225
|
-
} else if (Array.isArray(
|
|
226
|
-
if (
|
|
225
|
+
} else if (Array.isArray(o)) {
|
|
226
|
+
if (o.length === 0)
|
|
227
227
|
throw new Error("quoteRequestData array cannot be empty");
|
|
228
|
-
|
|
229
|
-
if (!
|
|
228
|
+
o.forEach((p, d) => {
|
|
229
|
+
if (!p || typeof p != "object")
|
|
230
230
|
throw new Error(`quoteRequestData[${d}] must be a non-null object`);
|
|
231
|
-
f(
|
|
231
|
+
f(p, d);
|
|
232
232
|
});
|
|
233
233
|
} else
|
|
234
|
-
f(
|
|
234
|
+
f(o);
|
|
235
235
|
if ([
|
|
236
236
|
"onOptIn",
|
|
237
237
|
"onOptOut",
|
|
238
238
|
"onQuoteRetrieved",
|
|
239
239
|
"onError",
|
|
240
240
|
"noMatchingQuote"
|
|
241
|
-
].forEach((
|
|
242
|
-
const d = s[
|
|
241
|
+
].forEach((p) => {
|
|
242
|
+
const d = s[p];
|
|
243
243
|
if (d && typeof d != "function")
|
|
244
|
-
throw new Error(`Callback '${
|
|
245
|
-
}), typeof
|
|
246
|
-
throw new Error(`Invalid location selector: '${
|
|
247
|
-
if (
|
|
244
|
+
throw new Error(`Callback '${p}' must be a function.`);
|
|
245
|
+
}), typeof n == "string" && !document.querySelector(n))
|
|
246
|
+
throw new Error(`Invalid location selector: '${n}'`);
|
|
247
|
+
if (r && typeof r != "object")
|
|
248
248
|
throw new Error(
|
|
249
249
|
"Theme must be an object with CSS variables, do not include the '--' prefix"
|
|
250
250
|
);
|
|
251
251
|
}
|
|
252
|
-
function
|
|
253
|
-
const
|
|
254
|
-
return
|
|
252
|
+
function c(m, { text: t, className: o, parent: s, innerHTML: n, href: r, target: i } = {}) {
|
|
253
|
+
const e = document.createElement(m);
|
|
254
|
+
return o && (e.className = o), t != null && (e.textContent = t), n != null && (e.innerHTML = n), r && "href" in e && (e.href = r), i && "target" in e && (e.target = i), s && s.appendChild(e), e;
|
|
255
255
|
}
|
|
256
|
-
function N(m, { name: t, description:
|
|
257
|
-
|
|
256
|
+
function N(m, { name: t, description: o }) {
|
|
257
|
+
c("div", {
|
|
258
258
|
className: "spot-header__title",
|
|
259
259
|
text: t,
|
|
260
260
|
parent: m
|
|
261
|
-
}),
|
|
261
|
+
}), c("div", {
|
|
262
262
|
className: "spot-header__description",
|
|
263
|
-
text:
|
|
263
|
+
text: o,
|
|
264
264
|
parent: m
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
function M(m, t = []) {
|
|
268
|
-
const
|
|
268
|
+
const o = c("ul", {
|
|
269
269
|
className: "spot-benefits__list",
|
|
270
270
|
parent: m
|
|
271
271
|
});
|
|
272
272
|
t.forEach((s) => {
|
|
273
|
-
const
|
|
274
|
-
|
|
273
|
+
const n = c("li", { parent: o });
|
|
274
|
+
n.innerHTML = `
|
|
275
275
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="spot-bullets__checkmark">
|
|
276
276
|
<path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
|
|
277
277
|
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
278
|
-
</svg>`,
|
|
278
|
+
</svg>`, c("span", { text: s, parent: n });
|
|
279
279
|
});
|
|
280
280
|
}
|
|
281
281
|
function L(m, t = []) {
|
|
282
282
|
if (!t || t.length === 0) return;
|
|
283
|
-
const
|
|
283
|
+
const o = c("div", {
|
|
284
284
|
className: "spot-qualifying-reasons__container",
|
|
285
285
|
parent: m
|
|
286
|
-
}), s = [...t].sort((
|
|
286
|
+
}), s = [...t].sort((e, a) => e.rank - a.rank), n = c("div", {
|
|
287
287
|
className: "spot-qualifying-reasons__grid",
|
|
288
|
-
parent:
|
|
289
|
-
}),
|
|
288
|
+
parent: o
|
|
289
|
+
}), r = {
|
|
290
290
|
"Accident & Illness": "cross.svg",
|
|
291
291
|
"Family Emergencies": "users.svg",
|
|
292
292
|
Layoffs: "building.svg",
|
|
@@ -296,158 +296,158 @@ function L(m, t = []) {
|
|
|
296
296
|
"Travel Interruption": "plane.svg",
|
|
297
297
|
"Military Duty": "medal.svg"
|
|
298
298
|
};
|
|
299
|
-
let
|
|
299
|
+
let i;
|
|
300
300
|
try {
|
|
301
|
-
const
|
|
302
|
-
if (
|
|
303
|
-
const a = new URL(
|
|
304
|
-
|
|
301
|
+
const e = document.currentScript;
|
|
302
|
+
if (e != null && e.src) {
|
|
303
|
+
const a = new URL(e.src);
|
|
304
|
+
i = a.origin + a.pathname.replace(/\/[^/]*$/, "/");
|
|
305
305
|
} else
|
|
306
|
-
|
|
307
|
-
|
|
306
|
+
i = window.location.origin + window.location.pathname.replace(/\/[^/]*$/, "/");
|
|
307
|
+
i += "assets/";
|
|
308
308
|
} catch {
|
|
309
|
-
|
|
309
|
+
i = "./assets/";
|
|
310
310
|
}
|
|
311
|
-
s.forEach((
|
|
312
|
-
var f, y,
|
|
313
|
-
const a =
|
|
311
|
+
s.forEach((e) => {
|
|
312
|
+
var f, y, p;
|
|
313
|
+
const a = c("div", {
|
|
314
314
|
className: "spot-qualifying-reasons__item",
|
|
315
|
-
parent:
|
|
316
|
-
}), u =
|
|
315
|
+
parent: n
|
|
316
|
+
}), u = c("div", {
|
|
317
317
|
className: "spot-qualifying-reasons__icon-wrapper",
|
|
318
318
|
parent: a
|
|
319
|
-
}), h =
|
|
319
|
+
}), h = r[((f = e.benefitType) == null ? void 0 : f.name) || ""] || r[e.name || ""];
|
|
320
320
|
if (h) {
|
|
321
|
-
const d =
|
|
321
|
+
const d = c("img", {
|
|
322
322
|
parent: u
|
|
323
323
|
});
|
|
324
|
-
d.src =
|
|
324
|
+
d.src = i + h, d.alt = ((y = e.benefitType) == null ? void 0 : y.name) || e.name || "", d.className = "spot-qualifying-reasons__icon";
|
|
325
325
|
}
|
|
326
|
-
|
|
326
|
+
c("span", {
|
|
327
327
|
className: "spot-qualifying-reasons__label",
|
|
328
|
-
text: ((
|
|
328
|
+
text: ((p = e.benefitType) == null ? void 0 : p.name) || e.name || "",
|
|
329
329
|
parent: a
|
|
330
330
|
});
|
|
331
331
|
});
|
|
332
332
|
}
|
|
333
|
-
function O(m, t = [],
|
|
334
|
-
if (t.length === 0 || !
|
|
333
|
+
function O(m, t = [], o) {
|
|
334
|
+
if (t.length === 0 || !o || o <= 1)
|
|
335
335
|
return;
|
|
336
336
|
const s = /* @__PURE__ */ new Map();
|
|
337
337
|
t.forEach((d) => {
|
|
338
338
|
s.set(d, (s.get(d) || 0) + 1);
|
|
339
339
|
});
|
|
340
|
-
const
|
|
340
|
+
const r = Array.from(s.entries()).map(
|
|
341
341
|
([d, l]) => ({
|
|
342
342
|
item: d,
|
|
343
343
|
count: l,
|
|
344
344
|
displayText: l > 1 ? `${l} x ${d}` : d
|
|
345
345
|
})
|
|
346
346
|
).sort((d, l) => {
|
|
347
|
-
const
|
|
348
|
-
return !g &&
|
|
349
|
-
}),
|
|
347
|
+
const w = d.item.charAt(0), _ = l.item.charAt(0), g = /[a-zA-Z]/.test(w), b = /[a-zA-Z]/.test(_);
|
|
348
|
+
return !g && b ? -1 : g && !b ? 1 : d.item.localeCompare(l.item, void 0, { sensitivity: "base" });
|
|
349
|
+
}), i = c("div", {
|
|
350
350
|
className: "spot-covered-items__container",
|
|
351
351
|
parent: m
|
|
352
|
-
}),
|
|
352
|
+
}), e = c("div", {
|
|
353
353
|
className: "spot-covered-items__header",
|
|
354
|
-
parent:
|
|
355
|
-
}), a =
|
|
354
|
+
parent: i
|
|
355
|
+
}), a = c("button", {
|
|
356
356
|
className: "spot-covered-items__toggle",
|
|
357
|
-
parent:
|
|
357
|
+
parent: e
|
|
358
358
|
});
|
|
359
|
-
|
|
359
|
+
c("span", {
|
|
360
360
|
className: "spot-covered-items__title",
|
|
361
361
|
text: `Items Covered in Your Cart (${t.length})`,
|
|
362
362
|
parent: a
|
|
363
363
|
});
|
|
364
|
-
const u =
|
|
364
|
+
const u = c("div", {
|
|
365
365
|
className: "spot-covered-items__right-section",
|
|
366
366
|
parent: a
|
|
367
367
|
});
|
|
368
|
-
|
|
368
|
+
c("span", {
|
|
369
369
|
className: "spot-covered-items__view-all",
|
|
370
370
|
text: "View All",
|
|
371
371
|
parent: u
|
|
372
372
|
});
|
|
373
|
-
const h =
|
|
373
|
+
const h = c("span", {
|
|
374
374
|
className: "spot-covered-items__arrow",
|
|
375
375
|
innerHTML: "▼",
|
|
376
376
|
parent: u
|
|
377
|
-
}), f =
|
|
377
|
+
}), f = c("div", {
|
|
378
378
|
className: "spot-covered-items__content",
|
|
379
|
-
parent:
|
|
380
|
-
}), y =
|
|
379
|
+
parent: i
|
|
380
|
+
}), y = c("ul", {
|
|
381
381
|
className: "spot-covered-items__list",
|
|
382
382
|
parent: f
|
|
383
383
|
});
|
|
384
|
-
|
|
385
|
-
const l =
|
|
386
|
-
|
|
384
|
+
r.forEach(({ displayText: d }) => {
|
|
385
|
+
const l = c("li", { parent: y });
|
|
386
|
+
c("span", { text: d, parent: l });
|
|
387
387
|
});
|
|
388
|
-
let
|
|
388
|
+
let p = !1;
|
|
389
389
|
f.style.display = "none", a.addEventListener("click", () => {
|
|
390
|
-
|
|
390
|
+
p = !p, f.style.display = p ? "block" : "none", h.innerHTML = p ? "▲" : "▼", a.setAttribute("aria-expanded", p.toString());
|
|
391
391
|
}), a.setAttribute("aria-expanded", "false"), a.setAttribute("aria-controls", "covered-items-list"), f.setAttribute("id", "covered-items-list");
|
|
392
392
|
}
|
|
393
|
-
function
|
|
394
|
-
const
|
|
393
|
+
function $(m, t = []) {
|
|
394
|
+
const o = c("div", {
|
|
395
395
|
className: "spot-table__container",
|
|
396
396
|
parent: m
|
|
397
|
-
}), s =
|
|
397
|
+
}), s = c("table", {
|
|
398
398
|
className: "spot-refund__table spot-table--dynamic",
|
|
399
|
-
parent:
|
|
400
|
-
}),
|
|
401
|
-
|
|
402
|
-
const
|
|
403
|
-
t.forEach(({ text:
|
|
404
|
-
const h =
|
|
405
|
-
|
|
399
|
+
parent: o
|
|
400
|
+
}), n = c("thead", { parent: s }), r = c("tr", { parent: n });
|
|
401
|
+
c("th", { text: "When you cancel", parent: r }), c("th", { text: "You will receive", parent: r });
|
|
402
|
+
const i = c("tbody", { parent: s });
|
|
403
|
+
t.forEach(({ text: e, percent: a, amount: u }) => {
|
|
404
|
+
const h = c("tr", { parent: i });
|
|
405
|
+
c("td", { text: e, parent: h });
|
|
406
406
|
const f = a === "Not eligible for refund" ? "Not eligible for a refund" : `$${u} refund`;
|
|
407
|
-
|
|
407
|
+
c("td", { text: f, parent: h });
|
|
408
408
|
});
|
|
409
409
|
}
|
|
410
|
-
function
|
|
411
|
-
const s =
|
|
410
|
+
function P(m, t, o) {
|
|
411
|
+
const s = c("div", {
|
|
412
412
|
className: "spot-selection__options",
|
|
413
413
|
parent: m
|
|
414
|
-
}),
|
|
414
|
+
}), n = c("label", {
|
|
415
415
|
className: `spot-selection__option ${t ? "selected" : ""}`,
|
|
416
416
|
parent: s
|
|
417
|
-
}),
|
|
418
|
-
|
|
419
|
-
text:
|
|
420
|
-
parent:
|
|
421
|
-
}),
|
|
417
|
+
}), r = c("input", { parent: n });
|
|
418
|
+
r.type = "radio", r.name = "selection", r.value = "yes", t && (r.checked = !0), c("strong", {
|
|
419
|
+
text: o.yesOptionText,
|
|
420
|
+
parent: n
|
|
421
|
+
}), c("span", {
|
|
422
422
|
className: "spot-selection__recommended-tag",
|
|
423
423
|
text: "Recommended",
|
|
424
|
-
parent:
|
|
424
|
+
parent: n
|
|
425
425
|
});
|
|
426
|
-
const
|
|
426
|
+
const i = c("label", {
|
|
427
427
|
className: "spot-selection__option",
|
|
428
428
|
parent: s
|
|
429
|
-
}),
|
|
430
|
-
return
|
|
429
|
+
}), e = c("input", { parent: i });
|
|
430
|
+
return e.type = "radio", e.name = "selection", e.value = "no", c("span", { text: o.noOptionText, parent: i }), s;
|
|
431
431
|
}
|
|
432
432
|
function R(m, t) {
|
|
433
|
-
var
|
|
434
|
-
const
|
|
433
|
+
var n;
|
|
434
|
+
const o = (n = t.communication) == null ? void 0 : n.paymentTerms, s = c("div", {
|
|
435
435
|
className: "spot-payment-terms",
|
|
436
436
|
parent: m
|
|
437
437
|
});
|
|
438
|
-
return
|
|
438
|
+
return c("div", {
|
|
439
439
|
className: "spot-payment-terms__header",
|
|
440
440
|
text: "PAYMENT TERMS",
|
|
441
441
|
parent: s
|
|
442
|
-
}),
|
|
442
|
+
}), c("div", {
|
|
443
443
|
className: "spot-payment-terms__body",
|
|
444
|
-
text:
|
|
444
|
+
text: o || "",
|
|
445
445
|
parent: s
|
|
446
446
|
}), s;
|
|
447
447
|
}
|
|
448
|
-
function V(m, t,
|
|
449
|
-
if (
|
|
450
|
-
const e =
|
|
448
|
+
function V(m, t, o = "bottom-right") {
|
|
449
|
+
if (o === "top-right") {
|
|
450
|
+
const e = c("div", {
|
|
451
451
|
className: "spot-logo__top-right",
|
|
452
452
|
parent: m
|
|
453
453
|
});
|
|
@@ -468,24 +468,21 @@ function V(m, t, r = "bottom-right") {
|
|
|
468
468
|
</defs>
|
|
469
469
|
</svg>`;
|
|
470
470
|
}
|
|
471
|
-
const s =
|
|
471
|
+
const s = c("div", {
|
|
472
472
|
className: "spot-footer__container",
|
|
473
473
|
parent: m
|
|
474
|
-
}),
|
|
474
|
+
}), n = c("div", {
|
|
475
475
|
className: "spot-footer__terms",
|
|
476
476
|
parent: s
|
|
477
|
-
})
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
parent: i
|
|
487
|
-
}), r === "bottom-right") {
|
|
488
|
-
const e = p("p", {
|
|
477
|
+
}), r = `<a href="${t.communication.termsAndConditionsUrl}" target="_blank" class="spot-footer__terms-link">Terms & Conditions</a>`, i = t.communication.legalDisclaimer.replace(
|
|
478
|
+
/terms and conditions/gi,
|
|
479
|
+
r
|
|
480
|
+
);
|
|
481
|
+
if (c("span", {
|
|
482
|
+
innerHTML: i,
|
|
483
|
+
parent: n
|
|
484
|
+
}), o === "bottom-right") {
|
|
485
|
+
const e = c("p", {
|
|
489
486
|
className: "spot-footer__powered-by",
|
|
490
487
|
parent: s
|
|
491
488
|
});
|
|
@@ -534,15 +531,15 @@ class A {
|
|
|
534
531
|
}, this._onResize = this._updateLayout.bind(this), this.root = typeof this.options.location == "string" ? document.querySelector(this.options.location) : this.options.location, this.currentSelection = this.options.optInSelected ? "yes" : null, this._init();
|
|
535
532
|
}
|
|
536
533
|
async _init() {
|
|
537
|
-
var t,
|
|
534
|
+
var t, o, s, n, r;
|
|
538
535
|
try {
|
|
539
536
|
D(this.options);
|
|
540
|
-
let
|
|
537
|
+
let i;
|
|
541
538
|
if (this.options.useMockData && this.options.mockData)
|
|
542
|
-
|
|
539
|
+
i = this.options.mockData;
|
|
543
540
|
else {
|
|
544
|
-
const { environment:
|
|
545
|
-
|
|
541
|
+
const { environment: e, partnerId: a } = this.options.apiConfig, h = this.options.apiConfig.customEndpoint || T[e];
|
|
542
|
+
i = "cartInfo" in this.options.quoteRequestData && "items" in this.options.quoteRequestData ? await I(
|
|
546
543
|
h,
|
|
547
544
|
a,
|
|
548
545
|
this.options.quoteRequestData
|
|
@@ -552,24 +549,24 @@ class A {
|
|
|
552
549
|
this.options.quoteRequestData
|
|
553
550
|
);
|
|
554
551
|
}
|
|
555
|
-
if (
|
|
556
|
-
|
|
552
|
+
if (i.status !== "QUOTE_AVAILABLE") {
|
|
553
|
+
i.status === "NO_MATCHING_QUOTE" && ((t = this.options.callbacks) != null && t.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
|
|
557
554
|
status: "NO_MATCHING_QUOTE",
|
|
558
555
|
data: this.options.quoteRequestData
|
|
559
556
|
});
|
|
560
557
|
return;
|
|
561
558
|
}
|
|
562
|
-
if (this.quote =
|
|
559
|
+
if (this.quote = i.data, !this.quote)
|
|
563
560
|
throw new Error("No quote data in response");
|
|
564
|
-
if (this._renderWidget(), this.options.optInSelected && ((
|
|
565
|
-
const
|
|
561
|
+
if (this._renderWidget(), this.options.optInSelected && ((o = this.options.callbacks) != null && o.onOptIn)) {
|
|
562
|
+
const e = {
|
|
566
563
|
status: "QUOTE_ACCEPTED",
|
|
567
564
|
spotPrice: this.quote.spotPrice,
|
|
568
565
|
quoteId: this.quote.id
|
|
569
566
|
};
|
|
570
567
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
571
568
|
const a = this.options.quoteRequestData;
|
|
572
|
-
|
|
569
|
+
e.batchQuoteDetails = this.quote.originalQuotes.map((u) => {
|
|
573
570
|
var f;
|
|
574
571
|
const h = (f = a.items) == null ? void 0 : f.find(
|
|
575
572
|
(y) => (y.cartItemId || `item-${a.items.indexOf(y) + 1}`) === u.id
|
|
@@ -581,51 +578,51 @@ class A {
|
|
|
581
578
|
};
|
|
582
579
|
});
|
|
583
580
|
}
|
|
584
|
-
this.options.callbacks.onOptIn(
|
|
581
|
+
this.options.callbacks.onOptIn(e);
|
|
585
582
|
}
|
|
586
583
|
if ((s = this.options.callbacks) != null && s.onQuoteRetrieved) {
|
|
587
|
-
const
|
|
588
|
-
|
|
584
|
+
const e = this.options.callbacks.onQuoteRetrieved(this.quote);
|
|
585
|
+
e && this._applyQuoteUpdates(e);
|
|
589
586
|
}
|
|
590
|
-
} catch (
|
|
591
|
-
if ((
|
|
592
|
-
const
|
|
593
|
-
(
|
|
594
|
-
message:
|
|
595
|
-
status:
|
|
596
|
-
responseBody:
|
|
587
|
+
} catch (i) {
|
|
588
|
+
if ((n = this.options.callbacks) != null && n.onError) {
|
|
589
|
+
const e = i;
|
|
590
|
+
(r = this.options.callbacks) == null || r.onError({
|
|
591
|
+
message: e.message,
|
|
592
|
+
status: e.status,
|
|
593
|
+
responseBody: e.responseBody
|
|
597
594
|
});
|
|
598
595
|
}
|
|
599
596
|
}
|
|
600
597
|
}
|
|
601
598
|
_renderWidget() {
|
|
602
599
|
if (!this.quote) return;
|
|
603
|
-
this.container = document.createElement("div"), this.container.className = "spot-refund-guarantee", this.root.appendChild(this.container), Object.entries(this.options.theme || {}).forEach(([s,
|
|
604
|
-
const
|
|
605
|
-
this.container.style.setProperty(
|
|
600
|
+
this.container = document.createElement("div"), this.container.className = "spot-refund-guarantee", this.root.appendChild(this.container), Object.entries(this.options.theme || {}).forEach(([s, n]) => {
|
|
601
|
+
const r = `--${s}`;
|
|
602
|
+
this.container.style.setProperty(r, n);
|
|
606
603
|
}), N(this.container, this.quote.communication);
|
|
607
604
|
const t = document.createElement("div");
|
|
608
605
|
if (t.className = "spot-content__wrapper", this.container.appendChild(t), this.quote.qualifyingReasons ? L(t, this.quote.qualifyingReasons) : M(t, this.quote.communication.bulletPoints), this.quote.coveredItems) {
|
|
609
606
|
const s = this._getTotalItemsInRequest();
|
|
610
607
|
O(t, this.quote.coveredItems, s);
|
|
611
608
|
}
|
|
612
|
-
this.options.showTable && !this.quote.qualifyingReasons &&
|
|
613
|
-
const
|
|
609
|
+
this.options.showTable && !this.quote.qualifyingReasons && $(t, this.quote.payoutSchedule);
|
|
610
|
+
const o = P(
|
|
614
611
|
t,
|
|
615
612
|
this.options.optInSelected,
|
|
616
613
|
this.quote.communication
|
|
617
614
|
);
|
|
618
|
-
t.appendChild(
|
|
615
|
+
t.appendChild(o), this.paymentTermsEl = c("div", {
|
|
619
616
|
className: "spot-payment-terms__wrapper",
|
|
620
617
|
parent: t
|
|
621
|
-
}), V(this.container, this.quote, this.options.logoPosition), window.addEventListener("resize", this._onResize), this._setupResizeObserver(), this._updateLayout(), this._setupOptionListeners(
|
|
618
|
+
}), V(this.container, this.quote, this.options.logoPosition), window.addEventListener("resize", this._onResize), this._setupResizeObserver(), this._updateLayout(), this._setupOptionListeners(o);
|
|
622
619
|
}
|
|
623
620
|
_updateLayout() {
|
|
624
621
|
if (!this.container || !this.quote) return;
|
|
625
622
|
const t = this.container.querySelector(
|
|
626
623
|
".spot-content__wrapper"
|
|
627
|
-
),
|
|
628
|
-
if (!t || !
|
|
624
|
+
), o = this.options.showTable && !this.quote.qualifyingReasons;
|
|
625
|
+
if (!t || !o) {
|
|
629
626
|
t == null || t.classList.remove("desktop-layout");
|
|
630
627
|
return;
|
|
631
628
|
}
|
|
@@ -633,19 +630,19 @@ class A {
|
|
|
633
630
|
t.classList.toggle("desktop-layout", s);
|
|
634
631
|
}
|
|
635
632
|
_shouldUseDesktopLayout(t) {
|
|
636
|
-
const
|
|
637
|
-
if (
|
|
633
|
+
const o = this.container.offsetWidth - 40, s = 325, n = 16;
|
|
634
|
+
if (o >= 900)
|
|
638
635
|
return !0;
|
|
639
|
-
if (
|
|
640
|
-
const
|
|
636
|
+
if (o >= 650) {
|
|
637
|
+
const r = t.classList.contains("desktop-layout");
|
|
641
638
|
t.classList.remove("desktop-layout"), t.offsetHeight;
|
|
642
|
-
const
|
|
639
|
+
const i = t.querySelector(
|
|
643
640
|
".spot-benefits__list, .spot-qualifying-reasons__container"
|
|
644
641
|
);
|
|
645
|
-
if (!
|
|
646
|
-
return
|
|
647
|
-
const a = Math.min(
|
|
648
|
-
return
|
|
642
|
+
if (!i)
|
|
643
|
+
return r && t.classList.add("desktop-layout"), r;
|
|
644
|
+
const a = Math.min(i.scrollWidth, 400) + s + n;
|
|
645
|
+
return r && t.classList.add("desktop-layout"), o >= a;
|
|
649
646
|
}
|
|
650
647
|
return !1;
|
|
651
648
|
}
|
|
@@ -666,14 +663,14 @@ class A {
|
|
|
666
663
|
)), this.destroy(), this._renderWidget());
|
|
667
664
|
}
|
|
668
665
|
_setupOptionListeners(t) {
|
|
669
|
-
const
|
|
666
|
+
const o = t.querySelectorAll(
|
|
670
667
|
'input[type="radio"]'
|
|
671
668
|
), s = t.querySelectorAll(".spot-selection__option");
|
|
672
|
-
|
|
673
|
-
|
|
669
|
+
o.forEach((n) => {
|
|
670
|
+
n.addEventListener("change", (r) => {
|
|
674
671
|
var a, u, h;
|
|
675
|
-
const
|
|
676
|
-
if (this.hideSelectionError(), this.currentSelection =
|
|
672
|
+
const i = r.target, e = i.value;
|
|
673
|
+
if (this.hideSelectionError(), this.currentSelection = e, s.forEach((f) => f.classList.remove("selected")), (a = i.closest(".spot-selection__option")) == null || a.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), e === "yes" && (this.options.quoteRequestData.isPartialPayment && R(this.paymentTermsEl, this.quote), (u = this.options.callbacks) != null && u.onOptIn)) {
|
|
677
674
|
const f = {
|
|
678
675
|
status: "QUOTE_ACCEPTED",
|
|
679
676
|
spotPrice: this.quote.spotPrice,
|
|
@@ -682,22 +679,22 @@ class A {
|
|
|
682
679
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
683
680
|
const y = this.options.quoteRequestData;
|
|
684
681
|
f.batchQuoteDetails = this.quote.originalQuotes.map(
|
|
685
|
-
(
|
|
682
|
+
(p) => {
|
|
686
683
|
var l;
|
|
687
684
|
const d = (l = y.items) == null ? void 0 : l.find(
|
|
688
|
-
(
|
|
685
|
+
(w) => (w.cartItemId || `item-${y.items.indexOf(w) + 1}`) === p.id
|
|
689
686
|
);
|
|
690
687
|
return {
|
|
691
|
-
quoteId:
|
|
692
|
-
productPrice: (d == null ? void 0 : d.productPrice) ||
|
|
693
|
-
cartItemId:
|
|
688
|
+
quoteId: p.id,
|
|
689
|
+
productPrice: (d == null ? void 0 : d.productPrice) || p.spotPrice,
|
|
690
|
+
cartItemId: p.id
|
|
694
691
|
};
|
|
695
692
|
}
|
|
696
693
|
);
|
|
697
694
|
}
|
|
698
695
|
this.options.callbacks.onOptIn(f);
|
|
699
696
|
}
|
|
700
|
-
if (
|
|
697
|
+
if (e === "no" && ((h = this.options.callbacks) != null && h.onOptOut)) {
|
|
701
698
|
const f = {
|
|
702
699
|
status: "QUOTE_DECLINED",
|
|
703
700
|
quoteId: this.quote.id
|
|
@@ -705,15 +702,15 @@ class A {
|
|
|
705
702
|
if (this.quote.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
706
703
|
const y = this.options.quoteRequestData;
|
|
707
704
|
f.batchQuoteDetails = this.quote.originalQuotes.map(
|
|
708
|
-
(
|
|
705
|
+
(p) => {
|
|
709
706
|
var l;
|
|
710
707
|
const d = (l = y.items) == null ? void 0 : l.find(
|
|
711
|
-
(
|
|
708
|
+
(w) => (w.cartItemId || `item-${y.items.indexOf(w) + 1}`) === p.id
|
|
712
709
|
);
|
|
713
710
|
return {
|
|
714
|
-
quoteId:
|
|
715
|
-
productPrice: (d == null ? void 0 : d.productPrice) ||
|
|
716
|
-
cartItemId:
|
|
711
|
+
quoteId: p.id,
|
|
712
|
+
productPrice: (d == null ? void 0 : d.productPrice) || p.spotPrice,
|
|
713
|
+
cartItemId: p.id
|
|
717
714
|
};
|
|
718
715
|
}
|
|
719
716
|
);
|
|
@@ -727,10 +724,10 @@ class A {
|
|
|
727
724
|
var t;
|
|
728
725
|
if (!this.errorEl) {
|
|
729
726
|
this.errorEl = document.createElement("div"), this.errorEl.className = "spot-selection__error", this.errorEl.textContent = "Please make a selection";
|
|
730
|
-
const
|
|
727
|
+
const o = (t = this.container) == null ? void 0 : t.querySelector(
|
|
731
728
|
".spot-selection__options"
|
|
732
729
|
);
|
|
733
|
-
|
|
730
|
+
o && o.insertAdjacentElement("afterend", this.errorEl);
|
|
734
731
|
}
|
|
735
732
|
this.errorEl.style.display = "block";
|
|
736
733
|
}
|
|
@@ -745,61 +742,61 @@ class A {
|
|
|
745
742
|
return t ? this.hideSelectionError() : this.showSelectionError(), t;
|
|
746
743
|
}
|
|
747
744
|
async updateQuote(t) {
|
|
748
|
-
var
|
|
745
|
+
var o, s, n, r;
|
|
749
746
|
try {
|
|
750
|
-
const
|
|
747
|
+
const i = {
|
|
751
748
|
...this.options,
|
|
752
749
|
quoteRequestData: t
|
|
753
750
|
};
|
|
754
|
-
D(
|
|
755
|
-
const { environment:
|
|
751
|
+
D(i);
|
|
752
|
+
const { environment: e, partnerId: a, customEndpoint: u } = this.options.apiConfig, h = u || T[e], y = "cartInfo" in i.quoteRequestData && "items" in i.quoteRequestData ? await I(
|
|
756
753
|
h,
|
|
757
754
|
a,
|
|
758
|
-
|
|
755
|
+
i.quoteRequestData
|
|
759
756
|
) : await x(
|
|
760
757
|
h,
|
|
761
758
|
a,
|
|
762
|
-
|
|
759
|
+
i.quoteRequestData
|
|
763
760
|
);
|
|
764
761
|
if (y.status !== "QUOTE_AVAILABLE")
|
|
765
|
-
return y.status === "NO_MATCHING_QUOTE" && ((
|
|
762
|
+
return y.status === "NO_MATCHING_QUOTE" && ((o = this.options.callbacks) != null && o.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
|
|
766
763
|
status: "NO_MATCHING_QUOTE",
|
|
767
|
-
data:
|
|
764
|
+
data: i.quoteRequestData
|
|
768
765
|
}), !1;
|
|
769
|
-
if (this.options.quoteRequestData =
|
|
770
|
-
const
|
|
771
|
-
|
|
766
|
+
if (this.options.quoteRequestData = i.quoteRequestData, this.quote = y.data, this.currentSelection = null, this.destroy(), this._renderWidget(), (s = this.options.callbacks) != null && s.onQuoteRetrieved) {
|
|
767
|
+
const p = this.options.callbacks.onQuoteRetrieved(this.quote);
|
|
768
|
+
p && this._applyQuoteUpdates(p);
|
|
772
769
|
}
|
|
773
770
|
return !0;
|
|
774
|
-
} catch (
|
|
775
|
-
const
|
|
776
|
-
return (
|
|
777
|
-
message:
|
|
778
|
-
status:
|
|
779
|
-
responseBody:
|
|
771
|
+
} catch (i) {
|
|
772
|
+
const e = i;
|
|
773
|
+
return (r = (n = this.options.callbacks) == null ? void 0 : n.onError) == null || r.call(n, {
|
|
774
|
+
message: e.message,
|
|
775
|
+
status: e.status,
|
|
776
|
+
responseBody: e.responseBody
|
|
780
777
|
}), !1;
|
|
781
778
|
}
|
|
782
779
|
}
|
|
783
780
|
getSelection() {
|
|
784
|
-
var
|
|
781
|
+
var o, s, n;
|
|
785
782
|
if (this.currentSelection == null) return null;
|
|
786
783
|
const t = {
|
|
787
784
|
selection: this.currentSelection,
|
|
788
|
-
quoteId: (
|
|
785
|
+
quoteId: (o = this.quote) == null ? void 0 : o.id,
|
|
789
786
|
spotPrice: (s = this.quote) == null ? void 0 : s.spotPrice,
|
|
790
787
|
status: this.currentSelection === "yes" ? "QUOTE_ACCEPTED" : "QUOTE_DECLINED"
|
|
791
788
|
};
|
|
792
|
-
if ((
|
|
793
|
-
const
|
|
794
|
-
t.batchQuoteDetails = this.quote.originalQuotes.map((
|
|
789
|
+
if ((n = this.quote) != null && n.originalQuotes && this.quote.originalQuotes.length > 0) {
|
|
790
|
+
const r = this.options.quoteRequestData;
|
|
791
|
+
t.batchQuoteDetails = this.quote.originalQuotes.map((i) => {
|
|
795
792
|
var a;
|
|
796
|
-
const
|
|
797
|
-
(u) => (u.cartItemId || `item-${
|
|
793
|
+
const e = (a = r.items) == null ? void 0 : a.find(
|
|
794
|
+
(u) => (u.cartItemId || `item-${r.items.indexOf(u) + 1}`) === i.id
|
|
798
795
|
);
|
|
799
796
|
return {
|
|
800
|
-
quoteId:
|
|
801
|
-
productPrice: (
|
|
802
|
-
cartItemId:
|
|
797
|
+
quoteId: i.id,
|
|
798
|
+
productPrice: (e == null ? void 0 : e.productPrice) || i.spotPrice,
|
|
799
|
+
cartItemId: i.id
|
|
803
800
|
};
|
|
804
801
|
});
|
|
805
802
|
}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(_,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(_=typeof globalThis<"u"?globalThis:_||self,_.SpotWidget=C())})(this,function(){"use strict";async function _(m,t,
|
|
1
|
+
(function(_,C){typeof exports=="object"&&typeof module<"u"?module.exports=C():typeof define=="function"&&define.amd?define(C):(_=typeof globalThis<"u"?globalThis:_||self,_.SpotWidget=C())})(this,function(){"use strict";async function _(m,t,o){try{const s=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),n=await s.json();if(!s.ok){const r=new Error((n==null?void 0:n.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=n,r}return n}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching quote")}}async function C(m,t,o){try{const s=m.replace("/quote","/quote/batch"),n=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await n.json();if(!n.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=n.status,i.responseBody=r,i}return r}catch(s){throw s instanceof Error?s:new Error("Unknown error occurred while fetching batch quote")}}async function E(m,t,o){var s;try{const n={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,items:o.items.map((a,u)=>({cartItemId:a.cartItemId||`item-${u+1}`,productPrice:a.productPrice,productType:a.productType,productDuration:a.productDuration,productId:a.productId,productName:a.productName,participantDescription:a.participantDescription,eventType:a.eventType,startDate:a.startDate,endDate:a.endDate}))},r=await C(m,t,n);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const i=r.quotes.map(a=>{const u=o.items.find((h,f)=>(h.cartItemId||`item-${f+1}`)===a.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${a.id}`}),e=Math.round((r.totalSpotPrice||r.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:r.quotes?r.quotes.map(a=>a.id).join(","):((s=r.data)==null?void 0:s.id)||"",spotPrice:e,currencyCode:r.currencyCode||"",communication:{...r.communication,yesOptionText:r.communication.yesOptionText.replace(String(r.totalSpotPrice),String(e))},payoutSchedule:r.payoutSchedule.map(a=>({...a,amount:a.amount!==void 0?a.amount:0})),coveredItems:i,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:i}}catch(n){throw n instanceof Error?n:new Error("Unknown error occurred while fetching multiple quotes")}}const z={sandbox:"https://api.sandbox.getspot.com/v1/quote",production:"https://api.getspot.com/v1/quote",local:"http://localhost:3999/api/v1/quote"};function x(m){const{apiConfig:t={},quoteRequestData:o,callbacks:s={},location:n,theme:r}=m,{environment:i="sandbox",partnerId:e,customEndpoint:a}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(a||z[i]))throw new Error(`Invalid environment in apiConfig: ${i}`);if(!o||typeof o!="object"&&!Array.isArray(o))throw new Error("quoteRequestData must be a non-null object or array");const h=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function f(c,d=null){const l=d!==null?`quoteRequestData[${d}]`:"quoteRequestData";h.forEach(v=>{if(!Object.prototype.hasOwnProperty.call(c,v)||c[v]===void 0||c[v]===null)throw new Error(`Missing required ${l} field: '${v}'`)});const b=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!b.test(c.startDate))throw new Error(`${l}.startDate must be a valid ISO8601 string`);if(!b.test(c.endDate))throw new Error(`${l}.endDate must be a valid ISO8601 string`);if(typeof c.currencyCode!="string")throw new Error(`${l}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(c.currencyCode))throw new Error(`Invalid ${l}.currencyCode: ${c.currencyCode}`);if(typeof c.eventType!="string")throw new Error(`${l}.eventType must be a string`);if(typeof c.productType!="string")throw new Error(`${l}.productType must be a string`);const g=["Pass","Trip","Registration"];if(!g.includes(c.productType))throw new Error(`${l}.productType must be one of ${g.join(", ")}`);if(typeof c.productDuration!="string")throw new Error(`${l}.productDuration must be a string`);const w=["Daily","Seasonal","Trip","Event"];if(!w.includes(c.productDuration))throw new Error(`${l}.productDuration must be one of ${w.join(", ")}`);if(typeof c.productPrice!="number"||isNaN(c.productPrice))throw new Error(`${l}.productPrice must be a valid number`);if(typeof c.productId!="string")throw new Error(`${l}.productId must be a string`);if(typeof c.cartId!="string")throw new Error(`${l}.cartId must be a string`);if(typeof c.productName!="string")throw new Error(`${l}.productName must be a string`)}if("cartInfo"in o&&"items"in o){const c=o,{cartInfo:d,items:l}=c;if(!d||typeof d!="object")throw new Error("quoteRequestData.cartInfo must be a non-null object");if(!d.cartId||typeof d.cartId!="string")throw new Error("quoteRequestData.cartInfo.cartId must be a string");if(!d.cartName||typeof d.cartName!="string")throw new Error("quoteRequestData.cartInfo.cartName must be a string");if(!d.currencyCode||typeof d.currencyCode!="string")throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(d.currencyCode))throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${d.currencyCode}`);if(!Array.isArray(l)||l.length===0)throw new Error("quoteRequestData.items must be a non-empty array");const q=["startDate","endDate","eventType","productType","productDuration","productPrice","productId","productName"];l.forEach((g,w)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${w}] must be a non-null object`);const v=`quoteRequestData.items[${w}]`;q.forEach(k=>{if(!Object.prototype.hasOwnProperty.call(g,k)||g[k]===void 0||g[k]===null)throw new Error(`Missing required ${v} field: '${k}'`)});const D=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!D.test(g.startDate))throw new Error(`${v}.startDate must be a valid ISO8601 string`);if(!D.test(g.endDate))throw new Error(`${v}.endDate must be a valid ISO8601 string`);if(typeof g.eventType!="string")throw new Error(`${v}.eventType must be a string`);if(typeof g.productType!="string")throw new Error(`${v}.productType must be a string`);const T=["Pass","Trip","Registration"];if(!T.includes(g.productType))throw new Error(`${v}.productType must be one of ${T.join(", ")}`);if(typeof g.productDuration!="string")throw new Error(`${v}.productDuration must be a string`);const H=["Daily","Seasonal","Trip","Event"];if(!H.includes(g.productDuration))throw new Error(`${v}.productDuration must be one of ${H.join(", ")}`);if(typeof g.productPrice!="number"||isNaN(g.productPrice))throw new Error(`${v}.productPrice must be a valid number`);if(typeof g.productId!="string")throw new Error(`${v}.productId must be a string`);if(typeof g.productName!="string")throw new Error(`${v}.productName must be a string`)})}else if(Array.isArray(o)){if(o.length===0)throw new Error("quoteRequestData array cannot be empty");o.forEach((c,d)=>{if(!c||typeof c!="object")throw new Error(`quoteRequestData[${d}] must be a non-null object`);f(c,d)})}else f(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(c=>{const d=s[c];if(d&&typeof d!="function")throw new Error(`Callback '${c}' must be a function.`)}),typeof n=="string"&&!document.querySelector(n))throw new Error(`Invalid location selector: '${n}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function p(m,{text:t,className:o,parent:s,innerHTML:n,href:r,target:i}={}){const e=document.createElement(m);return o&&(e.className=o),t!=null&&(e.textContent=t),n!=null&&(e.innerHTML=n),r&&"href"in e&&(e.href=r),i&&"target"in e&&(e.target=i),s&&s.appendChild(e),e}function N(m,{name:t,description:o}){p("div",{className:"spot-header__title",text:t,parent:m}),p("div",{className:"spot-header__description",text:o,parent:m})}function M(m,t=[]){const o=p("ul",{className:"spot-benefits__list",parent:m});t.forEach(s=>{const n=p("li",{parent:o});n.innerHTML=`
|
|
2
2
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" class="spot-bullets__checkmark">
|
|
3
3
|
<path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
|
|
4
4
|
stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
5
|
-
</svg>`,p("span",{text:s,parent:
|
|
5
|
+
</svg>`,p("span",{text:s,parent:n})})}function L(m,t=[]){if(!t||t.length===0)return;const o=p("div",{className:"spot-qualifying-reasons__container",parent:m}),s=[...t].sort((e,a)=>e.rank-a.rank),n=p("div",{className:"spot-qualifying-reasons__grid",parent:o}),r={"Accident & Illness":"cross.svg","Family Emergencies":"users.svg",Layoffs:"building.svg","Jury Duty":"scale.svg","Work Travel Conflict":"briefcase.svg","Severe Weather":"umbrella.svg","Travel Interruption":"plane.svg","Military Duty":"medal.svg"};let i;try{const e=document.currentScript;if(e!=null&&e.src){const a=new URL(e.src);i=a.origin+a.pathname.replace(/\/[^/]*$/,"/")}else i=window.location.origin+window.location.pathname.replace(/\/[^/]*$/,"/");i+="assets/"}catch{i="./assets/"}s.forEach(e=>{var f,y,c;const a=p("div",{className:"spot-qualifying-reasons__item",parent:n}),u=p("div",{className:"spot-qualifying-reasons__icon-wrapper",parent:a}),h=r[((f=e.benefitType)==null?void 0:f.name)||""]||r[e.name||""];if(h){const d=p("img",{parent:u});d.src=i+h,d.alt=((y=e.benefitType)==null?void 0:y.name)||e.name||"",d.className="spot-qualifying-reasons__icon"}p("span",{className:"spot-qualifying-reasons__label",text:((c=e.benefitType)==null?void 0:c.name)||e.name||"",parent:a})})}function O(m,t=[],o){if(t.length===0||!o||o<=1)return;const s=new Map;t.forEach(d=>{s.set(d,(s.get(d)||0)+1)});const r=Array.from(s.entries()).map(([d,l])=>({item:d,count:l,displayText:l>1?`${l} x ${d}`:d})).sort((d,l)=>{const b=d.item.charAt(0),q=l.item.charAt(0),g=/[a-zA-Z]/.test(b),w=/[a-zA-Z]/.test(q);return!g&&w?-1:g&&!w?1:d.item.localeCompare(l.item,void 0,{sensitivity:"base"})}),i=p("div",{className:"spot-covered-items__container",parent:m}),e=p("div",{className:"spot-covered-items__header",parent:i}),a=p("button",{className:"spot-covered-items__toggle",parent:e});p("span",{className:"spot-covered-items__title",text:`Items Covered in Your Cart (${t.length})`,parent:a});const u=p("div",{className:"spot-covered-items__right-section",parent:a});p("span",{className:"spot-covered-items__view-all",text:"View All",parent:u});const h=p("span",{className:"spot-covered-items__arrow",innerHTML:"▼",parent:u}),f=p("div",{className:"spot-covered-items__content",parent:i}),y=p("ul",{className:"spot-covered-items__list",parent:f});r.forEach(({displayText:d})=>{const l=p("li",{parent:y});p("span",{text:d,parent:l})});let c=!1;f.style.display="none",a.addEventListener("click",()=>{c=!c,f.style.display=c?"block":"none",h.innerHTML=c?"▲":"▼",a.setAttribute("aria-expanded",c.toString())}),a.setAttribute("aria-expanded","false"),a.setAttribute("aria-controls","covered-items-list"),f.setAttribute("id","covered-items-list")}function $(m,t=[]){const o=p("div",{className:"spot-table__container",parent:m}),s=p("table",{className:"spot-refund__table spot-table--dynamic",parent:o}),n=p("thead",{parent:s}),r=p("tr",{parent:n});p("th",{text:"When you cancel",parent:r}),p("th",{text:"You will receive",parent:r});const i=p("tbody",{parent:s});t.forEach(({text:e,percent:a,amount:u})=>{const h=p("tr",{parent:i});p("td",{text:e,parent:h});const f=a==="Not eligible for refund"?"Not eligible for a refund":`$${u} refund`;p("td",{text:f,parent:h})})}function P(m,t,o){const s=p("div",{className:"spot-selection__options",parent:m}),n=p("label",{className:`spot-selection__option ${t?"selected":""}`,parent:s}),r=p("input",{parent:n});r.type="radio",r.name="selection",r.value="yes",t&&(r.checked=!0),p("strong",{text:o.yesOptionText,parent:n}),p("span",{className:"spot-selection__recommended-tag",text:"Recommended",parent:n});const i=p("label",{className:"spot-selection__option",parent:s}),e=p("input",{parent:i});return e.type="radio",e.name="selection",e.value="no",p("span",{text:o.noOptionText,parent:i}),s}function R(m,t){var n;const o=(n=t.communication)==null?void 0:n.paymentTerms,s=p("div",{className:"spot-payment-terms",parent:m});return p("div",{className:"spot-payment-terms__header",text:"PAYMENT TERMS",parent:s}),p("div",{className:"spot-payment-terms__body",text:o||"",parent:s}),s}function V(m,t,o="bottom-right"){if(o==="top-right"){const e=p("div",{className:"spot-logo__top-right",parent:m});e.innerHTML=`
|
|
6
6
|
<svg width="145" height="28" viewBox="0 0 145 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
7
7
|
<rect width="145" height="28"/>
|
|
8
8
|
<rect x="-655" y="-270" width="819" height="325" rx="10"/>
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
|
|
18
18
|
</clipPath>
|
|
19
19
|
</defs>
|
|
20
|
-
</svg>`}const s=p("div",{className:"spot-footer__container",parent:m}),
|
|
20
|
+
</svg>`}const s=p("div",{className:"spot-footer__container",parent:m}),n=p("div",{className:"spot-footer__terms",parent:s}),r=`<a href="${t.communication.termsAndConditionsUrl}" target="_blank" class="spot-footer__terms-link">Terms & Conditions</a>`,i=t.communication.legalDisclaimer.replace(/terms and conditions/gi,r);if(p("span",{innerHTML:i,parent:n}),o==="bottom-right"){const e=p("p",{className:"spot-footer__powered-by",parent:s});e.innerHTML=`
|
|
21
21
|
<svg width="145" height="28" viewBox="0 0 145 28" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
22
22
|
<rect width="145" height="28"/>
|
|
23
23
|
<rect x="-655" y="-270" width="819" height="325" rx="10"/>
|
|
@@ -32,4 +32,4 @@
|
|
|
32
32
|
<rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
|
|
33
33
|
</clipPath>
|
|
34
34
|
</defs>
|
|
35
|
-
</svg>`}return s}const S=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--spot-title-font-size: 1.25rem;--spot-title-font-weight: 700;--spot-title-padding: 0 0 1.25rem 0;--spot-description-font-size: .875rem;--spot-description-font-weight: 400;--spot-description-padding: 0 0 .5rem 0;--spot-bullets-font-size: .875rem;--spot-bullets-font-weight: 400;--spot-bullets-padding: .3125rem;--spot-bullets-checkmark-color: #2e2e2e;--spot-table-border-radius: .625rem;--spot-table-header-font-size: .875rem;--spot-table-header-font-weight: 700;--spot-table-header-padding: 0 .5rem .625rem;--spot-table-cell-font-size: .815rem;--spot-table-cell-font-weight: 400;--spot-table-cell-padding: 0 .625rem;--spot-radio-border: #000000;--spot-radio-border-radius: .625rem;--spot-radio-checked-background: #000000;--spot-radio-text-font-size: .875rem;--spot-radio-text-font-weight: 400;--spot-radio-text-padding: .625rem;--spot-radio-selection-background: #f4f4f4;--spot-radio-selection-border-radius: .625rem;--spot-radio-selection-padding: .625rem;--spot-recommended-tag-background: #000000;--spot-recommended-tag-font-color: #ffffff;--spot-recommended-tag-font-size: .875rem;--spot-recommended-tag-font-weight: 700;--spot-recommended-tag-padding: .25rem .5rem;--spot-recommended-tag-border-radius: .5rem;--spot-selection-error-font-color: #ff0000;--spot-selection-error-font-size: .875rem;--spot-qualifying-reasons-margin: .75rem 0;--spot-qualifying-reasons-padding: 0 .3125rem;--spot-qualifying-reasons-column-gap: 3rem;--spot-qualifying-reasons-row-gap: .25rem;--spot-qualifying-reasons-grid-padding-left: 1rem;--spot-qualifying-reasons-icon-wrapper-size: 1.125rem;--spot-qualifying-reasons-icon-size: .75rem;--spot-qualifying-reasons-icon-border-color: #2e2e2e;--spot-qualifying-reasons-icon-border-width: 1px;--spot-qualifying-reasons-icon-background: #ffffff;--spot-qualifying-reasons-item-gap: .625rem;--spot-qualifying-reasons-label-font-size: .8rem;--spot-qualifying-reasons-label-font-weight: 400;--spot-qualifying-reasons-label-font-color: #000000;--spot-qualifying-reasons-label-font-family: Arial;--spot-selection-error-padding: .5rem;--spot-payment-terms-background: #f4f4f4;--spot-payment-terms-border-radius: .625rem;--spot-payment-terms-padding: 1rem;--spot-payment-terms-font-color: #636569;--spot-payment-terms-font-size: .75rem;--spot-payment-terms-header-font-weight: 700;--spot-payment-terms-header-font-size: .875rem;--spot-payment-terms-header-margin-bottom: .5rem;--spot-payment-terms-header-border-color: #c2c2c2;--spot-payment-terms-header-padding: 0 0 .5rem 0;--spot-terms-font-size: .75rem;--spot-terms-font-weight: 400;--spot-terms-font-color: #636569;--spot-terms-padding: 0;--spot-terms-link-text-decoration: underline;--spot-terms-link-font-size: .75rem;--spot-terms-link-font-weight: 400;--spot-terms-link-font-color: #636569;--spot-terms-link-padding: 0;--spot-covered-items-background: #f1f3f5;--spot-covered-items-hover-background: #e9ecef;--spot-covered-items-border-radius: .5rem;--spot-covered-items-padding: .75rem 1rem;--spot-covered-items-font-size: .875rem;--spot-covered-items-font-weight: 400;--spot-covered-items-font-color: #000000;--spot-covered-items-font-family: Arial;--spot-covered-items-arrow-font-size: .6rem;--spot-covered-items-arrow-color: #636569;--spot-covered-items-view-all-color: #636569;--spot-covered-items-view-all-font-size: .875rem;--spot-covered-items-view-all-font-weight: 400;--spot-covered-items-content-background: #f8f9fa;--spot-covered-items-content-border: 1px solid #e0e0e0;--spot-covered-items-content-border-radius: .5rem;--spot-covered-items-content-padding: .75rem 1rem;--spot-desktop-radio-margin-top: -1.5rem;--spot-benefits-margin-bottom: 0rem;--spot-covered-items-margin-bottom: 1.5rem;--spot-footer-gap: 1rem;--spot-footer-terms-margin-right: 7rem;--spot-payment-terms-margin-top: .5rem;--spot-logo-top-right-margin: 1rem}.spot-refund-guarantee{font-family:var(--spot-font-family);padding:var(--spot-padding);background-color:var(--spot-background-color);color:var(--spot-font-color);border:.0625rem solid #e0e0e0;border-radius:var(--spot-border-radius);max-width:51rem;margin:1rem;container-type:inline-size;position:relative;word-wrap:normal;overflow-wrap:normal;-webkit-hyphens:none;hyphens:none}.spot-refund-guarantee *{color:inherit}.spot-header__title{font-size:var(--spot-title-font-size);font-weight:var(--spot-title-font-weight);padding:var(--spot-title-padding);color:var(--spot-title-font-color);font-family:var(--spot-title-font-family);line-height:120%;letter-spacing:-.03125rem}.spot-header__description{font-size:var(--spot-description-font-size);font-weight:var(--spot-description-font-weight);color:var(--spot-description-font-color);font-family:var(--spot-description-font-family);padding:var(--spot-description-padding);line-height:125%;letter-spacing:-.025rem}.spot-content__wrapper{display:flex;flex-direction:column}.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr auto;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container,.desktop-layout .spot-covered-items__container,.desktop-layout .spot-selection__options{min-width:0;word-wrap:normal}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container{grid-row:1;margin-bottom:var(--spot-benefits-margin-bottom)}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1;margin-bottom:var(--spot-covered-items-margin-bottom)}.desktop-layout .spot-selection__options{grid-row:3;margin-top:var(--spot-desktop-radio-margin-top)}.desktop-layout .spot-payment-terms__wrapper{grid-row:4;grid-column:1;margin-top:var(--spot-payment-terms-margin-top)}.desktop-layout .spot-table__container{grid-row:1 / span 4;grid-column:2;width:auto;min-width:20.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-table__container{display:flex;justify-content:flex-start;margin-top:1rem;margin-bottom:1rem;padding-left:.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-refund__table{width:100%;max-width:22rem;table-layout:auto}@media (max-width: 850px){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 500px){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 600px){.spot-refund__table th{padding:0rem}}.spot-benefits__list{list-style-type:none;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-benefits__list li{margin-bottom:.375rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-bullets__checkmark path{stroke:var(--spot-bullets-checkmark-color)}.spot-qualifying-reasons__container{margin:var(--spot-qualifying-reasons-margin);padding:var(--spot-qualifying-reasons-padding)}.spot-qualifying-reasons__grid{display:grid;grid-template-columns:repeat(2,minmax(0,max-content));column-gap:var(--spot-qualifying-reasons-column-gap);row-gap:var(--spot-qualifying-reasons-row-gap);max-width:100%;padding-left:var(--spot-qualifying-reasons-grid-padding-left)}.spot-qualifying-reasons__item{display:flex;align-items:center;gap:var(--spot-qualifying-reasons-item-gap)}.spot-qualifying-reasons__icon-wrapper{width:var(--spot-qualifying-reasons-icon-wrapper-size);height:var(--spot-qualifying-reasons-icon-wrapper-size);border-radius:50%;border:var(--spot-qualifying-reasons-icon-border-width) solid var(--spot-qualifying-reasons-icon-border-color);background-color:var(--spot-qualifying-reasons-icon-background);display:flex;align-items:center;justify-content:center;flex-shrink:0}.spot-qualifying-reasons__icon{width:var(--spot-qualifying-reasons-icon-size);height:var(--spot-qualifying-reasons-icon-size)}.spot-qualifying-reasons__label{font-size:var(--spot-qualifying-reasons-label-font-size);font-weight:var(--spot-qualifying-reasons-label-font-weight);color:var(--spot-qualifying-reasons-label-font-color);font-family:var(--spot-qualifying-reasons-label-font-family);line-height:1.2}@media (max-width: 480px){.spot-qualifying-reasons__grid{grid-template-columns:1fr}}.spot-covered-items__container{margin-top:.85rem;margin-bottom:.5rem;max-width:26rem}.spot-content__wrapper.desktop-layout:has(.spot-table__container) .spot-covered-items__container{margin-top:0rem;margin-bottom:1rem}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);padding:0 .3125rem .25rem;line-height:125%;margin:0}.spot-covered-items__list{list-style-type:disc;list-style-position:inside;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-covered-items__list li{margin-bottom:.3rem;text-align:left}.spot-covered-items__list li:last-child{margin-bottom:0}.spot-covered-items__header{margin-bottom:.5rem}.spot-covered-items__toggle{background:var(--spot-covered-items-background);border:none;border-radius:var(--spot-covered-items-border-radius);padding:var(--spot-covered-items-padding);cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;transition:all .2s ease}.spot-covered-items__toggle:hover{background-color:var(--spot-covered-items-hover-background)}.spot-covered-items__toggle:focus{outline:none;box-shadow:0 0 0 2px #0000001a}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;margin:0;padding:0}.spot-covered-items__right-section{display:flex;align-items:center;gap:.5rem;margin-left:auto}.spot-covered-items__view-all{font-size:var(--spot-covered-items-view-all-font-size);font-weight:var(--spot-covered-items-view-all-font-weight);color:var(--spot-covered-items-view-all-color);font-family:var(--spot-covered-items-font-family);line-height:125%}.spot-covered-items__arrow{font-size:var(--spot-covered-items-arrow-font-size);transition:transform .2s ease;color:var(--spot-covered-items-arrow-color);flex-shrink:0;transform:scaleX(1.5)}.spot-covered-items__content{margin-top:.5rem;transition:all .2s ease;overflow:hidden}.spot-covered-items__list{background-color:var(--spot-covered-items-content-background);border:var(--spot-covered-items-content-border);border-radius:var(--spot-covered-items-content-border-radius);margin:0;padding:var(--spot-covered-items-content-padding)}.spot-table__container{width:100%}.spot-refund__table{max-width:22rem;border-radius:var(--spot-table-border-radius);overflow:hidden;border:.09375rem solid #636569;table-layout:fixed;margin-bottom:.5rem;margin-top:.25rem;padding:.625rem}.spot-refund__table--dynamic{height:auto!important;min-height:7.5rem}.spot-refund__table td,.spot-refund__table th{padding:.375rem .625rem;text-align:left}.spot-refund__table th{text-align:left;font-size:var(--spot-table-header-font-size);font-weight:var(--spot-table-header-font-weight);color:var(--spot-table-header-font-color);font-family:var(--spot-table-header-font-family);padding:var(--spot-table-header-padding)}.spot-refund__table td{text-align:left;font-size:var(--spot-table-cell-font-size);font-weight:var(--spot-table-cell-font-weight);color:var(--spot-table-cell-font-color);font-family:var(--spot-table-cell-font-family);padding:var(--spot-table-cell-padding)}input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:.75rem;height:.75rem;min-width:.75rem;border:.0625rem solid var(--spot-radio-border);border-radius:var(--spot-radio-border-radius);margin-right:.5rem;position:relative;vertical-align:middle;top:-.0625rem;cursor:pointer;flex-shrink:0}input[type=radio]:checked{background:var(--spot-radio-checked-background);box-shadow:inset 0 0 0 .0625rem #fff}.spot-selection__options{display:flex;flex-direction:column;gap:.5rem}.spot-selection__option{display:flex;align-items:center;flex-wrap:nowrap;position:relative;transition:background .2s;cursor:pointer;font-size:var(--spot-radio-text-font-size);font-weight:var(--spot-radio-text-font-weight);color:var(--spot-radio-text-font-color);font-family:var(--spot-radio-text-font-family);padding:var(--spot-radio-text-padding);margin-right:.5rem}.spot-selection__option.selected{background:var(--spot-radio-selection-background);border-radius:var(--spot-radio-selection-border-radius);padding:var(--spot-radio-selection-padding)}.spot-selection__recommended-tag{background:var(--spot-recommended-tag-background);color:var(--spot-recommended-tag-font-color);font-size:var(--spot-recommended-tag-font-size);font-weight:var(--spot-recommended-tag-font-weight);padding:var(--spot-recommended-tag-padding);border-radius:var(--spot-recommended-tag-border-radius);margin-left:.75rem;white-space:nowrap;flex-shrink:0}@media (max-width: 850px){.spot-selection__recommended-tag{margin-left:.5rem}}@media (max-width: 600px){.spot-selection__recommended-tag{margin-left:.5rem;font-size:.75rem;padding:.1875rem .4375rem}}.spot-selection__error{color:var(--spot-selection-error-font-color);font-size:var(--spot-selection-error-font-size);padding:var(--spot-selection-error-padding);display:none}.spot-payment-terms__wrapper{margin-top:1rem}.spot-payment-terms__header{font-weight:var(--spot-payment-terms-header-font-weight);margin-bottom:.5rem;padding:var(--spot-payment-terms-header-padding);font-size:var(--spot-payment-terms-header-font-size);border-bottom:1px solid var(--spot-payment-terms-header-border-color)}.spot-payment-terms{background-color:var(--spot-payment-terms-background);border-radius:var(--spot-payment-terms-border-radius);padding:var(--spot-payment-terms-padding);margin-right:.5rem;color:var(--spot-payment-terms-font-color);font-size:var(--spot-payment-terms-font-size)}.spot-footer__terms{margin-top:.625rem;margin-right:.25rem;font-size:var(--spot-terms-font-size);font-weight:var(--spot-terms-font-weight);color:var(--spot-terms-font-color);font-family:var(--spot-terms-font-family);padding:var(--spot-terms-padding);line-height:1.4;word-wrap:normal;-webkit-hyphens:none;hyphens:none;flex:1;min-width:0;overflow-wrap:normal}.spot-footer__terms-link{text-decoration:var(--spot-terms-link-text-decoration);font-size:var(--spot-terms-link-font-size);font-weight:var(--spot-terms-link-font-weight);color:var(--spot-terms-link-font-color);font-family:var(--spot-terms-link-font-family);padding:var(--spot-terms-link-padding)}.spot-footer__container{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;flex-wrap:nowrap;gap:var(--spot-footer-gap)}@container (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}@media (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}.spot-footer__powered-by{margin-top:0;flex-shrink:0}.spot-logo__top-right{position:absolute;top:-14px;right:40px;z-index:10;background:#fff;padding:0 8px}@container (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}@media (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}";function Q(m){const t=document.createElement("style");t.textContent=m,document.head.appendChild(t)}Q(S);const I={sandbox:"https://api.sandbox.getspot.com/api/v1/quote",production:"https://api.getspot.com/api/v1/quote",local:"http://localhost:3999/api/v1/quote"};class A{constructor(t={}){this.options={location:"body",showTable:!0,optInSelected:!1,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t},this._onResize=this._updateLayout.bind(this),this.root=typeof this.options.location=="string"?document.querySelector(this.options.location):this.options.location,this.currentSelection=this.options.optInSelected?"yes":null,this._init()}async _init(){var t,r,s,i,e;try{x(this.options);let n;if(this.options.useMockData&&this.options.mockData)n=this.options.mockData;else{const{environment:o,partnerId:a}=this.options.apiConfig,h=this.options.apiConfig.customEndpoint||I[o];n="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await k(h,a,this.options.quoteRequestData):await _(h,a,this.options.quoteRequestData)}if(n.status!=="QUOTE_AVAILABLE"){n.status==="NO_MATCHING_QUOTE"&&((t=this.options.callbacks)!=null&&t.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=n.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.optInSelected&&((r=this.options.callbacks)!=null&&r.onOptIn)){const o={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const a=this.options.quoteRequestData;o.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var f;const h=(f=a.items)==null?void 0:f.find(y=>(y.cartItemId||`item-${a.items.indexOf(y)+1}`)===u.id);return{quoteId:u.id,productPrice:(h==null?void 0:h.productPrice)||u.spotPrice,cartItemId:u.id}})}this.options.callbacks.onOptIn(o)}if((s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const o=this.options.callbacks.onQuoteRetrieved(this.quote);o&&this._applyQuoteUpdates(o)}}catch(n){if((i=this.options.callbacks)!=null&&i.onError){const o=n;(e=this.options.callbacks)==null||e.onError({message:o.message,status:o.status,responseBody:o.responseBody})}}}_renderWidget(){if(!this.quote)return;this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([s,i])=>{const e=`--${s}`;this.container.style.setProperty(e,i)}),N(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?L(t,this.quote.qualifyingReasons):M(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const s=this._getTotalItemsInRequest();O(t,this.quote.coveredItems,s)}this.options.showTable&&!this.quote.qualifyingReasons&&P(t,this.quote.payoutSchedule);const r=$(t,this.options.optInSelected,this.quote.communication);t.appendChild(r),this.paymentTermsEl=p("div",{className:"spot-payment-terms__wrapper",parent:t}),V(this.container,this.quote,this.options.logoPosition),window.addEventListener("resize",this._onResize),this._setupResizeObserver(),this._updateLayout(),this._setupOptionListeners(r)}_updateLayout(){if(!this.container||!this.quote)return;const t=this.container.querySelector(".spot-content__wrapper"),r=this.options.showTable&&!this.quote.qualifyingReasons;if(!t||!r){t==null||t.classList.remove("desktop-layout");return}const s=this._shouldUseDesktopLayout(t);t.classList.toggle("desktop-layout",s)}_shouldUseDesktopLayout(t){const r=this.container.offsetWidth-40,s=325,i=16;if(r>=900)return!0;if(r>=650){const e=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const n=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!n)return e&&t.classList.add("desktop-layout"),e;const a=Math.min(n.scrollWidth,400)+s+i;return e&&t.classList.add("desktop-layout"),r>=a}return!1}_setupResizeObserver(){!this.container||!window.ResizeObserver||(this._resizeObserver=new ResizeObserver(()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=window.setTimeout(()=>{this._updateLayout()},100)}),this._resizeObserver.observe(this.container))}_getTotalItemsInRequest(){return"cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?this.options.quoteRequestData.items.length:1}_applyQuoteUpdates(t){!this.quote||!this.container||(t.spotPriceWithFees!==void 0&&(this.quote.communication.yesOptionText=this.quote.communication.yesOptionText.replace(`$${this.quote.spotPrice.toFixed(2)}`,`$${t.spotPriceWithFees.toFixed(2)}`)),this.destroy(),this._renderWidget())}_setupOptionListeners(t){const r=t.querySelectorAll('input[type="radio"]'),s=t.querySelectorAll(".spot-selection__option");r.forEach(i=>{i.addEventListener("change",e=>{var a,u,h;const n=e.target,o=n.value;if(this.hideSelectionError(),this.currentSelection=o,s.forEach(f=>f.classList.remove("selected")),(a=n.closest(".spot-selection__option"))==null||a.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),o==="yes"&&(this.options.quoteRequestData.isPartialPayment&&R(this.paymentTermsEl,this.quote),(u=this.options.callbacks)!=null&&u.onOptIn)){const f={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;f.batchQuoteDetails=this.quote.originalQuotes.map(c=>{var l;const d=(l=y.items)==null?void 0:l.find(b=>(b.cartItemId||`item-${y.items.indexOf(b)+1}`)===c.id);return{quoteId:c.id,productPrice:(d==null?void 0:d.productPrice)||c.spotPrice,cartItemId:c.id}})}this.options.callbacks.onOptIn(f)}if(o==="no"&&((h=this.options.callbacks)!=null&&h.onOptOut)){const f={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;f.batchQuoteDetails=this.quote.originalQuotes.map(c=>{var l;const d=(l=y.items)==null?void 0:l.find(b=>(b.cartItemId||`item-${y.items.indexOf(b)+1}`)===c.id);return{quoteId:c.id,productPrice:(d==null?void 0:d.productPrice)||c.spotPrice,cartItemId:c.id}})}this.options.callbacks.onOptOut(f)}})})}showSelectionError(){var t;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const r=(t=this.container)==null?void 0:t.querySelector(".spot-selection__options");r&&r.insertAdjacentElement("afterend",this.errorEl)}this.errorEl.style.display="block"}hideSelectionError(){this.errorEl&&(this.errorEl.style.display="none")}validateSelection(){if(!this.container)return!1;const t=!!this.container.querySelector('input[name="selection"]:checked');return t?this.hideSelectionError():this.showSelectionError(),t}async updateQuote(t){var r,s,i,e;try{const n={...this.options,quoteRequestData:t};x(n);const{environment:o,partnerId:a,customEndpoint:u}=this.options.apiConfig,h=u||I[o],y="cartInfo"in n.quoteRequestData&&"items"in n.quoteRequestData?await k(h,a,n.quoteRequestData):await _(h,a,n.quoteRequestData);if(y.status!=="QUOTE_AVAILABLE")return y.status==="NO_MATCHING_QUOTE"&&((r=this.options.callbacks)!=null&&r.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:n.quoteRequestData}),!1;if(this.options.quoteRequestData=n.quoteRequestData,this.quote=y.data,this.currentSelection=null,this.destroy(),this._renderWidget(),(s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const c=this.options.callbacks.onQuoteRetrieved(this.quote);c&&this._applyQuoteUpdates(c)}return!0}catch(n){const o=n;return(e=(i=this.options.callbacks)==null?void 0:i.onError)==null||e.call(i,{message:o.message,status:o.status,responseBody:o.responseBody}),!1}}getSelection(){var r,s,i;if(this.currentSelection==null)return null;const t={selection:this.currentSelection,quoteId:(r=this.quote)==null?void 0:r.id,spotPrice:(s=this.quote)==null?void 0:s.spotPrice,status:this.currentSelection==="yes"?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};if((i=this.quote)!=null&&i.originalQuotes&&this.quote.originalQuotes.length>0){const e=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(n=>{var a;const o=(a=e.items)==null?void 0:a.find(u=>(u.cartItemId||`item-${e.items.indexOf(u)+1}`)===n.id);return{quoteId:n.id,productPrice:(o==null?void 0:o.productPrice)||n.spotPrice,cartItemId:n.id}})}return t}destroy(){window.removeEventListener("resize",this._onResize),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeTimeout&&window.clearTimeout(this._resizeTimeout),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}return A});
|
|
35
|
+
</svg>`}return s}const S=":root{--spot-font-family: Arial;--spot-padding: 1.25rem;--spot-background-color: #ffffff;--spot-font-color: #000000;--spot-border-radius: .5rem;--spot-title-font-size: 1.25rem;--spot-title-font-weight: 700;--spot-title-padding: 0 0 1.25rem 0;--spot-description-font-size: .875rem;--spot-description-font-weight: 400;--spot-description-padding: 0 0 .5rem 0;--spot-bullets-font-size: .875rem;--spot-bullets-font-weight: 400;--spot-bullets-padding: .3125rem;--spot-bullets-checkmark-color: #2e2e2e;--spot-table-border-radius: .625rem;--spot-table-header-font-size: .875rem;--spot-table-header-font-weight: 700;--spot-table-header-padding: 0 .5rem .625rem;--spot-table-cell-font-size: .815rem;--spot-table-cell-font-weight: 400;--spot-table-cell-padding: 0 .625rem;--spot-radio-border: #000000;--spot-radio-border-radius: .625rem;--spot-radio-checked-background: #000000;--spot-radio-text-font-size: .875rem;--spot-radio-text-font-weight: 400;--spot-radio-text-padding: .625rem;--spot-radio-selection-background: #f4f4f4;--spot-radio-selection-border-radius: .625rem;--spot-radio-selection-padding: .625rem;--spot-recommended-tag-background: #000000;--spot-recommended-tag-font-color: #ffffff;--spot-recommended-tag-font-size: .875rem;--spot-recommended-tag-font-weight: 700;--spot-recommended-tag-padding: .25rem .5rem;--spot-recommended-tag-border-radius: .5rem;--spot-selection-error-font-color: #ff0000;--spot-selection-error-font-size: .875rem;--spot-qualifying-reasons-margin: .75rem 0;--spot-qualifying-reasons-padding: 0 .3125rem;--spot-qualifying-reasons-column-gap: 3rem;--spot-qualifying-reasons-row-gap: .25rem;--spot-qualifying-reasons-grid-padding-left: 1rem;--spot-qualifying-reasons-icon-wrapper-size: 1.125rem;--spot-qualifying-reasons-icon-size: .75rem;--spot-qualifying-reasons-icon-border-color: #2e2e2e;--spot-qualifying-reasons-icon-border-width: 1px;--spot-qualifying-reasons-icon-background: #ffffff;--spot-qualifying-reasons-item-gap: .625rem;--spot-qualifying-reasons-label-font-size: .8rem;--spot-qualifying-reasons-label-font-weight: 400;--spot-qualifying-reasons-label-font-color: #000000;--spot-qualifying-reasons-label-font-family: Arial;--spot-selection-error-padding: .5rem;--spot-payment-terms-background: #f4f4f4;--spot-payment-terms-border-radius: .625rem;--spot-payment-terms-padding: 1rem;--spot-payment-terms-font-color: #636569;--spot-payment-terms-font-size: .75rem;--spot-payment-terms-header-font-weight: 700;--spot-payment-terms-header-font-size: .875rem;--spot-payment-terms-header-margin-bottom: .5rem;--spot-payment-terms-header-border-color: #c2c2c2;--spot-payment-terms-header-padding: 0 0 .5rem 0;--spot-terms-font-size: .75rem;--spot-terms-font-weight: 400;--spot-terms-font-color: #636569;--spot-terms-padding: 0;--spot-terms-link-text-decoration: underline;--spot-terms-link-font-size: .75rem;--spot-terms-link-font-weight: 400;--spot-terms-link-font-color: #636569;--spot-terms-link-padding: 0;--spot-covered-items-background: #f1f3f5;--spot-covered-items-hover-background: #e9ecef;--spot-covered-items-border-radius: .5rem;--spot-covered-items-padding: .75rem 1rem;--spot-covered-items-font-size: .875rem;--spot-covered-items-font-weight: 400;--spot-covered-items-font-color: #000000;--spot-covered-items-font-family: Arial;--spot-covered-items-arrow-font-size: .6rem;--spot-covered-items-arrow-color: #636569;--spot-covered-items-view-all-color: #636569;--spot-covered-items-view-all-font-size: .875rem;--spot-covered-items-view-all-font-weight: 400;--spot-covered-items-content-background: #f8f9fa;--spot-covered-items-content-border: 1px solid #e0e0e0;--spot-covered-items-content-border-radius: .5rem;--spot-covered-items-content-padding: .75rem 1rem;--spot-desktop-radio-margin-top: -1.5rem;--spot-benefits-margin-bottom: 0rem;--spot-covered-items-margin-bottom: 1.5rem;--spot-footer-gap: 1rem;--spot-footer-terms-margin-right: 7rem;--spot-payment-terms-margin-top: .5rem;--spot-logo-top-right-margin: 1rem}.spot-refund-guarantee{font-family:var(--spot-font-family);padding:var(--spot-padding);background-color:var(--spot-background-color);color:var(--spot-font-color);border:.0625rem solid #e0e0e0;border-radius:var(--spot-border-radius);max-width:51rem;margin:1rem;container-type:inline-size;position:relative;word-wrap:normal;overflow-wrap:normal;-webkit-hyphens:none;hyphens:none}.spot-refund-guarantee *{color:inherit}.spot-header__title{font-size:var(--spot-title-font-size);font-weight:var(--spot-title-font-weight);padding:var(--spot-title-padding);color:var(--spot-title-font-color);font-family:var(--spot-title-font-family);line-height:120%;letter-spacing:-.03125rem}.spot-header__description{font-size:var(--spot-description-font-size);font-weight:var(--spot-description-font-weight);color:var(--spot-description-font-color);font-family:var(--spot-description-font-family);padding:var(--spot-description-padding);line-height:125%;letter-spacing:-.025rem}.spot-content__wrapper{display:flex;flex-direction:column}.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr auto;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container,.desktop-layout .spot-covered-items__container,.desktop-layout .spot-selection__options{min-width:0;word-wrap:normal}.desktop-layout .spot-benefits__list,.desktop-layout .spot-qualifying-reasons__container{grid-row:1;margin-bottom:var(--spot-benefits-margin-bottom)}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1;margin-bottom:var(--spot-covered-items-margin-bottom)}.desktop-layout .spot-selection__options{grid-row:3;margin-top:var(--spot-desktop-radio-margin-top)}.desktop-layout .spot-payment-terms__wrapper{grid-row:4;grid-column:1;margin-top:var(--spot-payment-terms-margin-top)}.desktop-layout .spot-table__container{grid-row:1 / span 4;grid-column:2;width:auto;min-width:20.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-table__container{display:flex;justify-content:flex-start;margin-top:1rem;margin-bottom:1rem;padding-left:.3125rem}.spot-content__wrapper:not(.desktop-layout) .spot-refund__table{width:100%;max-width:22rem;table-layout:auto}@media (max-width: 850px){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 500px){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 600px){.spot-refund__table th{padding:0rem}}.spot-benefits__list{list-style-type:none;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-benefits__list li{margin-bottom:.375rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-bullets__checkmark path{stroke:var(--spot-bullets-checkmark-color)}.spot-qualifying-reasons__container{margin:var(--spot-qualifying-reasons-margin);padding:var(--spot-qualifying-reasons-padding)}.spot-qualifying-reasons__grid{display:grid;grid-template-columns:repeat(2,minmax(0,max-content));column-gap:var(--spot-qualifying-reasons-column-gap);row-gap:var(--spot-qualifying-reasons-row-gap);max-width:100%;padding-left:var(--spot-qualifying-reasons-grid-padding-left)}.spot-qualifying-reasons__item{display:flex;align-items:center;gap:var(--spot-qualifying-reasons-item-gap)}.spot-qualifying-reasons__icon-wrapper{width:var(--spot-qualifying-reasons-icon-wrapper-size);height:var(--spot-qualifying-reasons-icon-wrapper-size);border-radius:50%;border:var(--spot-qualifying-reasons-icon-border-width) solid var(--spot-qualifying-reasons-icon-border-color);background-color:var(--spot-qualifying-reasons-icon-background);display:flex;align-items:center;justify-content:center;flex-shrink:0}.spot-qualifying-reasons__icon{width:var(--spot-qualifying-reasons-icon-size);height:var(--spot-qualifying-reasons-icon-size)}.spot-qualifying-reasons__label{font-size:var(--spot-qualifying-reasons-label-font-size);font-weight:var(--spot-qualifying-reasons-label-font-weight);color:var(--spot-qualifying-reasons-label-font-color);font-family:var(--spot-qualifying-reasons-label-font-family);line-height:1.2}@media (max-width: 480px){.spot-qualifying-reasons__grid{grid-template-columns:1fr}}.spot-covered-items__container{margin-top:.85rem;margin-bottom:.5rem;max-width:26rem}.spot-content__wrapper.desktop-layout:has(.spot-table__container) .spot-covered-items__container{margin-top:0rem;margin-bottom:1rem}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);padding:0 .3125rem .25rem;line-height:125%;margin:0}.spot-covered-items__list{list-style-type:disc;list-style-position:inside;line-height:125%;gap:.5625rem;font-size:var(--spot-bullets-font-size);font-weight:var(--spot-bullets-font-weight);color:var(--spot-bullets-font-color);font-family:var(--spot-bullets-font-family);padding:var(--spot-bullets-padding);margin-block-start:0rem;margin-block-end:0rem}.spot-covered-items__list li{margin-bottom:.3rem;text-align:left}.spot-covered-items__list li:last-child{margin-bottom:0}.spot-covered-items__header{margin-bottom:.5rem}.spot-covered-items__toggle{background:var(--spot-covered-items-background);border:none;border-radius:var(--spot-covered-items-border-radius);padding:var(--spot-covered-items-padding);cursor:pointer;display:flex;align-items:center;justify-content:space-between;width:100%;font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;transition:all .2s ease}.spot-covered-items__toggle:hover{background-color:var(--spot-covered-items-hover-background)}.spot-covered-items__toggle:focus{outline:none;box-shadow:0 0 0 2px #0000001a}.spot-covered-items__title{font-size:var(--spot-covered-items-font-size);font-weight:var(--spot-covered-items-font-weight);color:var(--spot-covered-items-font-color);font-family:var(--spot-covered-items-font-family);line-height:125%;margin:0;padding:0}.spot-covered-items__right-section{display:flex;align-items:center;gap:.5rem;margin-left:auto}.spot-covered-items__view-all{font-size:var(--spot-covered-items-view-all-font-size);font-weight:var(--spot-covered-items-view-all-font-weight);color:var(--spot-covered-items-view-all-color);font-family:var(--spot-covered-items-font-family);line-height:125%}.spot-covered-items__arrow{font-size:var(--spot-covered-items-arrow-font-size);transition:transform .2s ease;color:var(--spot-covered-items-arrow-color);flex-shrink:0;transform:scaleX(1.5)}.spot-covered-items__content{margin-top:.5rem;transition:all .2s ease;overflow:hidden}.spot-covered-items__list{background-color:var(--spot-covered-items-content-background);border:var(--spot-covered-items-content-border);border-radius:var(--spot-covered-items-content-border-radius);margin:0;padding:var(--spot-covered-items-content-padding)}.spot-table__container{width:100%}.spot-refund__table{max-width:22rem;border-radius:var(--spot-table-border-radius);overflow:hidden;border:.09375rem solid #636569;table-layout:fixed;margin-bottom:.5rem;margin-top:.25rem;padding:.625rem}.spot-refund__table--dynamic{height:auto!important;min-height:7.5rem}.spot-refund__table td,.spot-refund__table th{padding:.375rem .625rem;text-align:left}.spot-refund__table th{text-align:left;font-size:var(--spot-table-header-font-size);font-weight:var(--spot-table-header-font-weight);color:var(--spot-table-header-font-color);font-family:var(--spot-table-header-font-family);padding:var(--spot-table-header-padding)}.spot-refund__table td{text-align:left;font-size:var(--spot-table-cell-font-size);font-weight:var(--spot-table-cell-font-weight);color:var(--spot-table-cell-font-color);font-family:var(--spot-table-cell-font-family);padding:var(--spot-table-cell-padding)}input[type=radio]{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:.75rem;height:.75rem;min-width:.75rem;border:.0625rem solid var(--spot-radio-border);border-radius:var(--spot-radio-border-radius);margin-right:.5rem;position:relative;vertical-align:middle;top:-.0625rem;cursor:pointer;flex-shrink:0}input[type=radio]:checked{background:var(--spot-radio-checked-background);box-shadow:inset 0 0 0 .0625rem #fff}.spot-selection__options{display:flex;flex-direction:column;gap:.5rem}.spot-selection__option{display:flex;align-items:center;flex-wrap:nowrap;position:relative;transition:background .2s;cursor:pointer;font-size:var(--spot-radio-text-font-size);font-weight:var(--spot-radio-text-font-weight);color:var(--spot-radio-text-font-color);font-family:var(--spot-radio-text-font-family);padding:var(--spot-radio-text-padding);margin-right:.5rem}.spot-selection__option.selected{background:var(--spot-radio-selection-background);border-radius:var(--spot-radio-selection-border-radius);padding:var(--spot-radio-selection-padding)}.spot-selection__recommended-tag{background:var(--spot-recommended-tag-background);color:var(--spot-recommended-tag-font-color);font-size:var(--spot-recommended-tag-font-size);font-weight:var(--spot-recommended-tag-font-weight);padding:var(--spot-recommended-tag-padding);border-radius:var(--spot-recommended-tag-border-radius);margin-left:.75rem;white-space:nowrap;flex-shrink:0}@media (max-width: 850px){.spot-selection__recommended-tag{margin-left:.5rem}}@media (max-width: 600px){.spot-selection__recommended-tag{margin-left:.5rem;font-size:.75rem;padding:.1875rem .4375rem}}.spot-selection__error{color:var(--spot-selection-error-font-color);font-size:var(--spot-selection-error-font-size);padding:var(--spot-selection-error-padding);display:none}.spot-payment-terms__wrapper{margin-top:1rem}.spot-payment-terms__header{font-weight:var(--spot-payment-terms-header-font-weight);margin-bottom:.5rem;padding:var(--spot-payment-terms-header-padding);font-size:var(--spot-payment-terms-header-font-size);border-bottom:1px solid var(--spot-payment-terms-header-border-color)}.spot-payment-terms{background-color:var(--spot-payment-terms-background);border-radius:var(--spot-payment-terms-border-radius);padding:var(--spot-payment-terms-padding);margin-right:.5rem;color:var(--spot-payment-terms-font-color);font-size:var(--spot-payment-terms-font-size)}.spot-footer__terms{margin-top:.625rem;margin-right:.25rem;font-size:var(--spot-terms-font-size);font-weight:var(--spot-terms-font-weight);color:var(--spot-terms-font-color);font-family:var(--spot-terms-font-family);padding:var(--spot-terms-padding);line-height:1.4;word-wrap:normal;-webkit-hyphens:none;hyphens:none;flex:1;min-width:0;overflow-wrap:normal}.spot-footer__terms-link{text-decoration:var(--spot-terms-link-text-decoration);font-size:var(--spot-terms-link-font-size);font-weight:var(--spot-terms-link-font-weight);color:var(--spot-terms-link-font-color);font-family:var(--spot-terms-link-font-family);padding:var(--spot-terms-link-padding)}.spot-footer__container{display:flex;flex-direction:row;justify-content:space-between;align-items:flex-start;flex-wrap:nowrap;gap:var(--spot-footer-gap)}@container (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}@media (max-width: 650px){.spot-footer__container{flex-direction:column!important;align-items:flex-start!important;flex-wrap:wrap!important}.spot-footer__terms{margin-right:0!important;margin-bottom:.5rem!important;flex:none!important;width:100%!important;max-width:none!important}}.spot-footer__powered-by{margin-top:0;flex-shrink:0}.spot-logo__top-right{position:absolute;top:-14px;right:40px;z-index:10;background:#fff;padding:0 8px}@container (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}@media (min-width: 651px){.spot-footer__powered-by{margin-top:0;align-self:center}.spot-footer__terms{margin-right:var(--spot-footer-terms-margin-right)}}";function Q(m){const t=document.createElement("style");t.textContent=m,document.head.appendChild(t)}Q(S);const I={sandbox:"https://api.sandbox.getspot.com/api/v1/quote",production:"https://api.getspot.com/api/v1/quote",local:"http://localhost:3999/api/v1/quote"};class A{constructor(t={}){this.options={location:"body",showTable:!0,optInSelected:!1,logoPosition:"bottom-right",apiConfig:{environment:"production",partnerId:""},quoteRequestData:{},callbacks:{},useMockData:!1,...t},this._onResize=this._updateLayout.bind(this),this.root=typeof this.options.location=="string"?document.querySelector(this.options.location):this.options.location,this.currentSelection=this.options.optInSelected?"yes":null,this._init()}async _init(){var t,o,s,n,r;try{x(this.options);let i;if(this.options.useMockData&&this.options.mockData)i=this.options.mockData;else{const{environment:e,partnerId:a}=this.options.apiConfig,h=this.options.apiConfig.customEndpoint||I[e];i="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await E(h,a,this.options.quoteRequestData):await _(h,a,this.options.quoteRequestData)}if(i.status!=="QUOTE_AVAILABLE"){i.status==="NO_MATCHING_QUOTE"&&((t=this.options.callbacks)!=null&&t.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:this.options.quoteRequestData});return}if(this.quote=i.data,!this.quote)throw new Error("No quote data in response");if(this._renderWidget(),this.options.optInSelected&&((o=this.options.callbacks)!=null&&o.onOptIn)){const e={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const a=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var f;const h=(f=a.items)==null?void 0:f.find(y=>(y.cartItemId||`item-${a.items.indexOf(y)+1}`)===u.id);return{quoteId:u.id,productPrice:(h==null?void 0:h.productPrice)||u.spotPrice,cartItemId:u.id}})}this.options.callbacks.onOptIn(e)}if((s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const e=this.options.callbacks.onQuoteRetrieved(this.quote);e&&this._applyQuoteUpdates(e)}}catch(i){if((n=this.options.callbacks)!=null&&n.onError){const e=i;(r=this.options.callbacks)==null||r.onError({message:e.message,status:e.status,responseBody:e.responseBody})}}}_renderWidget(){if(!this.quote)return;this.container=document.createElement("div"),this.container.className="spot-refund-guarantee",this.root.appendChild(this.container),Object.entries(this.options.theme||{}).forEach(([s,n])=>{const r=`--${s}`;this.container.style.setProperty(r,n)}),N(this.container,this.quote.communication);const t=document.createElement("div");if(t.className="spot-content__wrapper",this.container.appendChild(t),this.quote.qualifyingReasons?L(t,this.quote.qualifyingReasons):M(t,this.quote.communication.bulletPoints),this.quote.coveredItems){const s=this._getTotalItemsInRequest();O(t,this.quote.coveredItems,s)}this.options.showTable&&!this.quote.qualifyingReasons&&$(t,this.quote.payoutSchedule);const o=P(t,this.options.optInSelected,this.quote.communication);t.appendChild(o),this.paymentTermsEl=p("div",{className:"spot-payment-terms__wrapper",parent:t}),V(this.container,this.quote,this.options.logoPosition),window.addEventListener("resize",this._onResize),this._setupResizeObserver(),this._updateLayout(),this._setupOptionListeners(o)}_updateLayout(){if(!this.container||!this.quote)return;const t=this.container.querySelector(".spot-content__wrapper"),o=this.options.showTable&&!this.quote.qualifyingReasons;if(!t||!o){t==null||t.classList.remove("desktop-layout");return}const s=this._shouldUseDesktopLayout(t);t.classList.toggle("desktop-layout",s)}_shouldUseDesktopLayout(t){const o=this.container.offsetWidth-40,s=325,n=16;if(o>=900)return!0;if(o>=650){const r=t.classList.contains("desktop-layout");t.classList.remove("desktop-layout"),t.offsetHeight;const i=t.querySelector(".spot-benefits__list, .spot-qualifying-reasons__container");if(!i)return r&&t.classList.add("desktop-layout"),r;const a=Math.min(i.scrollWidth,400)+s+n;return r&&t.classList.add("desktop-layout"),o>=a}return!1}_setupResizeObserver(){!this.container||!window.ResizeObserver||(this._resizeObserver=new ResizeObserver(()=>{this._resizeTimeout&&clearTimeout(this._resizeTimeout),this._resizeTimeout=window.setTimeout(()=>{this._updateLayout()},100)}),this._resizeObserver.observe(this.container))}_getTotalItemsInRequest(){return"cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?this.options.quoteRequestData.items.length:1}_applyQuoteUpdates(t){!this.quote||!this.container||(t.spotPriceWithFees!==void 0&&(this.quote.communication.yesOptionText=this.quote.communication.yesOptionText.replace(`$${this.quote.spotPrice.toFixed(2)}`,`$${t.spotPriceWithFees.toFixed(2)}`)),this.destroy(),this._renderWidget())}_setupOptionListeners(t){const o=t.querySelectorAll('input[type="radio"]'),s=t.querySelectorAll(".spot-selection__option");o.forEach(n=>{n.addEventListener("change",r=>{var a,u,h;const i=r.target,e=i.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(f=>f.classList.remove("selected")),(a=i.closest(".spot-selection__option"))==null||a.classList.add("selected"),this.paymentTermsEl&&(this.paymentTermsEl.innerHTML=""),e==="yes"&&(this.options.quoteRequestData.isPartialPayment&&R(this.paymentTermsEl,this.quote),(u=this.options.callbacks)!=null&&u.onOptIn)){const f={status:"QUOTE_ACCEPTED",spotPrice:this.quote.spotPrice,quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;f.batchQuoteDetails=this.quote.originalQuotes.map(c=>{var l;const d=(l=y.items)==null?void 0:l.find(b=>(b.cartItemId||`item-${y.items.indexOf(b)+1}`)===c.id);return{quoteId:c.id,productPrice:(d==null?void 0:d.productPrice)||c.spotPrice,cartItemId:c.id}})}this.options.callbacks.onOptIn(f)}if(e==="no"&&((h=this.options.callbacks)!=null&&h.onOptOut)){const f={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;f.batchQuoteDetails=this.quote.originalQuotes.map(c=>{var l;const d=(l=y.items)==null?void 0:l.find(b=>(b.cartItemId||`item-${y.items.indexOf(b)+1}`)===c.id);return{quoteId:c.id,productPrice:(d==null?void 0:d.productPrice)||c.spotPrice,cartItemId:c.id}})}this.options.callbacks.onOptOut(f)}})})}showSelectionError(){var t;if(!this.errorEl){this.errorEl=document.createElement("div"),this.errorEl.className="spot-selection__error",this.errorEl.textContent="Please make a selection";const o=(t=this.container)==null?void 0:t.querySelector(".spot-selection__options");o&&o.insertAdjacentElement("afterend",this.errorEl)}this.errorEl.style.display="block"}hideSelectionError(){this.errorEl&&(this.errorEl.style.display="none")}validateSelection(){if(!this.container)return!1;const t=!!this.container.querySelector('input[name="selection"]:checked');return t?this.hideSelectionError():this.showSelectionError(),t}async updateQuote(t){var o,s,n,r;try{const i={...this.options,quoteRequestData:t};x(i);const{environment:e,partnerId:a,customEndpoint:u}=this.options.apiConfig,h=u||I[e],y="cartInfo"in i.quoteRequestData&&"items"in i.quoteRequestData?await E(h,a,i.quoteRequestData):await _(h,a,i.quoteRequestData);if(y.status!=="QUOTE_AVAILABLE")return y.status==="NO_MATCHING_QUOTE"&&((o=this.options.callbacks)!=null&&o.noMatchingQuote)&&this.options.callbacks.noMatchingQuote({status:"NO_MATCHING_QUOTE",data:i.quoteRequestData}),!1;if(this.options.quoteRequestData=i.quoteRequestData,this.quote=y.data,this.currentSelection=null,this.destroy(),this._renderWidget(),(s=this.options.callbacks)!=null&&s.onQuoteRetrieved){const c=this.options.callbacks.onQuoteRetrieved(this.quote);c&&this._applyQuoteUpdates(c)}return!0}catch(i){const e=i;return(r=(n=this.options.callbacks)==null?void 0:n.onError)==null||r.call(n,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,n;if(this.currentSelection==null)return null;const t={selection:this.currentSelection,quoteId:(o=this.quote)==null?void 0:o.id,spotPrice:(s=this.quote)==null?void 0:s.spotPrice,status:this.currentSelection==="yes"?"QUOTE_ACCEPTED":"QUOTE_DECLINED"};if((n=this.quote)!=null&&n.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(i=>{var a;const e=(a=r.items)==null?void 0:a.find(u=>(u.cartItemId||`item-${r.items.indexOf(u)+1}`)===i.id);return{quoteId:i.id,productPrice:(e==null?void 0:e.productPrice)||i.spotPrice,cartItemId:i.id}})}return t}destroy(){window.removeEventListener("resize",this._onResize),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0),this._resizeTimeout&&window.clearTimeout(this._resizeTimeout),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container)}}return A});
|