@getspot/spot-widget 1.1.1 → 1.3.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/dist/index.es.js CHANGED
@@ -1,45 +1,116 @@
1
- async function b(i, e, t) {
1
+ async function I(c, e, o) {
2
2
  try {
3
- const o = await fetch(i, {
3
+ const n = await fetch(c, {
4
4
  method: "POST",
5
5
  headers: {
6
6
  "Content-Type": "application/json",
7
7
  "X-Spot-Partner-Id": e
8
8
  },
9
- body: JSON.stringify(t)
10
- }), n = await o.json();
11
- if (!o.ok) {
12
- const r = new Error((n == null ? void 0 : n.message) || "Failed to fetch quote");
13
- throw r.status = o.status, r.responseBody = n, r;
9
+ body: JSON.stringify(o)
10
+ }), t = await n.json();
11
+ if (!n.ok) {
12
+ const r = new Error((t == null ? void 0 : t.message) || "Failed to fetch quote");
13
+ throw r.status = n.status, r.responseBody = t, r;
14
14
  }
15
- return n;
16
- } catch (o) {
17
- throw o instanceof Error ? o : new Error("Unknown error occurred while fetching quote");
15
+ return t;
16
+ } catch (n) {
17
+ throw n instanceof Error ? n : new Error("Unknown error occurred while fetching quote");
18
18
  }
19
19
  }
20
- const v = {
20
+ async function x(c, e, o) {
21
+ try {
22
+ const n = c.replace("/quote", "/quote/batch"), t = await fetch(n, {
23
+ method: "POST",
24
+ headers: {
25
+ "Content-Type": "application/json",
26
+ "X-Spot-Partner-Id": e
27
+ },
28
+ body: JSON.stringify(o)
29
+ }), r = await t.json();
30
+ if (!t.ok) {
31
+ const p = new Error((r == null ? void 0 : r.message) || "Failed to fetch batch quote");
32
+ throw p.status = t.status, p.responseBody = r, p;
33
+ }
34
+ return r;
35
+ } catch (n) {
36
+ throw n instanceof Error ? n : new Error("Unknown error occurred while fetching batch quote");
37
+ }
38
+ }
39
+ async function D(c, e, o) {
40
+ try {
41
+ const n = {
42
+ cartId: o.cartInfo.cartId,
43
+ cartName: o.cartInfo.cartName,
44
+ currencyCode: o.cartInfo.currencyCode,
45
+ items: o.items.map((i, u) => ({
46
+ cartItemId: i.cartItemId || `item-${u + 1}`,
47
+ productPrice: i.productPrice,
48
+ productType: i.productType,
49
+ productDuration: i.productDuration,
50
+ productId: i.productId,
51
+ productName: i.productName,
52
+ participantDescription: i.participantDescription,
53
+ eventType: i.eventType,
54
+ startDate: i.startDate,
55
+ endDate: i.endDate
56
+ }))
57
+ }, t = await x(c, e, n);
58
+ if (t.status !== "QUOTES_AVAILABLE" && t.status !== "QUOTE_AVAILABLE")
59
+ return { status: "NO_MATCHING_QUOTE" };
60
+ const r = t.quotes.map((i) => {
61
+ const u = o.items.find(
62
+ (g) => (g.cartItemId || `item-${o.items.indexOf(g) + 1}`) === i.cartItemId
63
+ );
64
+ return u ? u.participantDescription ? `${u.productName} - ${u.participantDescription}` : u.productName : `Item ${i.cartItemId}`;
65
+ }), p = Math.round((t.totalSpotPrice || t.spotPrice || 0) * 100) / 100;
66
+ return {
67
+ status: "QUOTE_AVAILABLE",
68
+ data: {
69
+ id: t.quotes ? t.quotes.map((i) => i.id).join(",") : t.id,
70
+ spotPrice: p,
71
+ currencyCode: t.currencyCode,
72
+ communication: {
73
+ ...t.communication,
74
+ yesOptionText: t.communication.yesOptionText.replace(t.totalSpotPrice, p)
75
+ },
76
+ payoutSchedule: t.payoutSchedule.map((i) => ({
77
+ ...i,
78
+ amount: i.amount !== void 0 ? i.amount : 0
79
+ })),
80
+ coveredItems: r,
81
+ originalQuotes: t.quotes || [t]
82
+ },
83
+ spotPrice: p,
84
+ coveredItems: r
85
+ };
86
+ } catch (n) {
87
+ throw n instanceof Error ? n : new Error("Unknown error occurred while fetching multiple quotes");
88
+ }
89
+ }
90
+ const N = {
21
91
  sandbox: "https://api.sandbox.getspot.com/v1/quote",
22
- production: "https://api.getspot.com/v1/quote"
92
+ production: "https://api.getspot.com/v1/quote",
93
+ local: "http://localhost:3999/api/v1/quote"
23
94
  };
24
- function y(i) {
95
+ function k(c) {
25
96
  const {
26
97
  apiConfig: e = {},
27
- quoteRequestData: t,
28
- callbacks: o = {},
29
- location: n,
98
+ quoteRequestData: o,
99
+ callbacks: n = {},
100
+ location: t,
30
101
  theme: r
31
- } = i, {
32
- environment: a = "sandbox",
33
- partnerId: p,
34
- endpoint: c
102
+ } = c, {
103
+ environment: p = "sandbox",
104
+ partnerId: i,
105
+ endpoint: u
35
106
  } = e;
36
- if (!p || typeof p != "string")
107
+ if (!i || typeof i != "string")
37
108
  throw new Error("Invalid or missing partnerId in apiConfig");
38
- if (!(c || v[a]))
39
- throw new Error(`Invalid environment in apiConfig: ${a}`);
40
- if (!t || typeof t != "object")
41
- throw new Error("quoteRequestData must be a non-null object");
42
- [
109
+ if (!(u || N[p]))
110
+ throw new Error(`Invalid environment in apiConfig: ${p}`);
111
+ if (!o || typeof o != "object" && !Array.isArray(o))
112
+ throw new Error("quoteRequestData must be a non-null object or array");
113
+ const h = [
43
114
  "startDate",
44
115
  "endDate",
45
116
  "currencyCode",
@@ -50,166 +121,247 @@ function y(i) {
50
121
  "productId",
51
122
  "cartId",
52
123
  "productName"
53
- ].forEach((m) => {
54
- if (!Object.prototype.hasOwnProperty.call(t, m) || t[m] === void 0 || t[m] === null)
55
- throw new Error(`Missing required quoteRequestData field: '${m}'`);
56
- });
57
- const u = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
58
- if (!u.test(t.startDate))
59
- throw new Error("startDate must be a valid ISO8601 string");
60
- if (!u.test(t.endDate))
61
- throw new Error("endDate must be a valid ISO8601 string");
62
- if (typeof t.currencyCode != "string")
63
- throw new Error("currencyCode must be a string");
64
- if (!["USD", "CAD", "AUD"].includes(t.currencyCode))
65
- throw new Error(`Invalid currency code: ${t.currencyCode}`);
66
- if (typeof t.eventType != "string")
67
- throw new Error("eventType must be a string");
68
- if (typeof t.productType != "string")
69
- throw new Error("productType must be a string");
70
- const f = ["Pass", "Trip", "Registration"];
71
- if (!f.includes(t.productType))
72
- throw new Error(
73
- `productType must be one of ${f.join(", ")}`
74
- );
75
- if (typeof t.productDuration != "string")
76
- throw new Error("productDuration must be a string");
77
- const h = ["Daily", "Seasonal", "Trip", "Event"];
78
- if (!h.includes(t.productDuration))
79
- throw new Error(
80
- `productDuration must be one of ${h.join(", ")}`
81
- );
82
- if (typeof t.productPrice != "number" || isNaN(t.productPrice))
83
- throw new Error("productPrice must be a valid number");
84
- if (typeof t.productId != "string")
85
- throw new Error("productId must be a string");
86
- if (typeof t.cartId != "string")
87
- throw new Error("cartId must be a string");
88
- if (typeof t.productName != "string")
89
- throw new Error("productName must be a string");
124
+ ];
125
+ function d(s, l = null) {
126
+ const f = l !== null ? `quoteRequestData[${l}]` : "quoteRequestData";
127
+ h.forEach((v) => {
128
+ if (!Object.prototype.hasOwnProperty.call(s, v) || s[v] === void 0 || s[v] === null)
129
+ throw new Error(`Missing required ${f} field: '${v}'`);
130
+ });
131
+ const w = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
132
+ if (!w.test(s.startDate))
133
+ throw new Error(`${f}.startDate must be a valid ISO8601 string`);
134
+ if (!w.test(s.endDate))
135
+ throw new Error(`${f}.endDate must be a valid ISO8601 string`);
136
+ if (typeof s.currencyCode != "string")
137
+ throw new Error(`${f}.currencyCode must be a string`);
138
+ if (!["USD", "CAD", "AUD"].includes(s.currencyCode))
139
+ throw new Error(`Invalid ${f}.currencyCode: ${s.currencyCode}`);
140
+ if (typeof s.eventType != "string")
141
+ throw new Error(`${f}.eventType must be a string`);
142
+ if (typeof s.productType != "string")
143
+ throw new Error(`${f}.productType must be a string`);
144
+ const _ = ["Pass", "Trip", "Registration"];
145
+ if (!_.includes(s.productType))
146
+ throw new Error(
147
+ `${f}.productType must be one of ${_.join(", ")}`
148
+ );
149
+ if (typeof s.productDuration != "string")
150
+ throw new Error(`${f}.productDuration must be a string`);
151
+ const y = ["Daily", "Seasonal", "Trip", "Event"];
152
+ if (!y.includes(s.productDuration))
153
+ throw new Error(
154
+ `${f}.productDuration must be one of ${y.join(", ")}`
155
+ );
156
+ if (typeof s.productPrice != "number" || isNaN(s.productPrice))
157
+ throw new Error(`${f}.productPrice must be a valid number`);
158
+ if (typeof s.productId != "string")
159
+ throw new Error(`${f}.productId must be a string`);
160
+ if (typeof s.cartId != "string")
161
+ throw new Error(`${f}.cartId must be a string`);
162
+ if (typeof s.productName != "string")
163
+ throw new Error(`${f}.productName must be a string`);
164
+ }
165
+ if (o.cartInfo && o.items) {
166
+ const { cartInfo: s, items: l } = o;
167
+ if (!s || typeof s != "object")
168
+ throw new Error("quoteRequestData.cartInfo must be a non-null object");
169
+ if (!s.cartId || typeof s.cartId != "string")
170
+ throw new Error("quoteRequestData.cartInfo.cartId must be a string");
171
+ if (!s.cartName || typeof s.cartName != "string")
172
+ throw new Error("quoteRequestData.cartInfo.cartName must be a string");
173
+ if (!s.currencyCode || typeof s.currencyCode != "string")
174
+ throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");
175
+ if (!["USD", "CAD", "AUD"].includes(s.currencyCode))
176
+ throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${s.currencyCode}`);
177
+ if (!Array.isArray(l) || l.length === 0)
178
+ throw new Error("quoteRequestData.items must be a non-empty array");
179
+ const w = h.filter((m) => m !== "cartId" && m !== "currencyCode");
180
+ l.forEach((m, _) => {
181
+ if (!m || typeof m != "object")
182
+ throw new Error(`quoteRequestData.items[${_}] must be a non-null object`);
183
+ const y = `quoteRequestData.items[${_}]`;
184
+ w.forEach((C) => {
185
+ if (!Object.prototype.hasOwnProperty.call(m, C) || m[C] === void 0 || m[C] === null)
186
+ throw new Error(`Missing required ${y} field: '${C}'`);
187
+ });
188
+ const v = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;
189
+ if (!v.test(m.startDate))
190
+ throw new Error(`${y}.startDate must be a valid ISO8601 string`);
191
+ if (!v.test(m.endDate))
192
+ throw new Error(`${y}.endDate must be a valid ISO8601 string`);
193
+ if (typeof m.eventType != "string")
194
+ throw new Error(`${y}.eventType must be a string`);
195
+ if (typeof m.productType != "string")
196
+ throw new Error(`${y}.productType must be a string`);
197
+ const E = ["Pass", "Trip", "Registration"];
198
+ if (!E.includes(m.productType))
199
+ throw new Error(`${y}.productType must be one of ${E.join(", ")}`);
200
+ if (typeof m.productDuration != "string")
201
+ throw new Error(`${y}.productDuration must be a string`);
202
+ const q = ["Daily", "Seasonal", "Trip", "Event"];
203
+ if (!q.includes(m.productDuration))
204
+ throw new Error(`${y}.productDuration must be one of ${q.join(", ")}`);
205
+ if (typeof m.productPrice != "number" || isNaN(m.productPrice))
206
+ throw new Error(`${y}.productPrice must be a valid number`);
207
+ if (typeof m.productId != "string")
208
+ throw new Error(`${y}.productId must be a string`);
209
+ if (typeof m.productName != "string")
210
+ throw new Error(`${y}.productName must be a string`);
211
+ });
212
+ } else if (Array.isArray(o)) {
213
+ if (o.length === 0)
214
+ throw new Error("quoteRequestData array cannot be empty");
215
+ o.forEach((s, l) => {
216
+ if (!s || typeof s != "object")
217
+ throw new Error(`quoteRequestData[${l}] must be a non-null object`);
218
+ d(s, l);
219
+ });
220
+ } else
221
+ d(o);
90
222
  if ([
91
223
  "onOptIn",
92
224
  "onOptOut",
93
225
  "onQuoteRetrieved",
94
226
  "onError",
95
227
  "noMatchingQuote"
96
- ].forEach((m) => {
97
- const g = o[m];
98
- if (g && typeof g != "function")
99
- throw new Error(`Callback '${m}' must be a function.`);
100
- }), typeof n == "string" && !document.querySelector(n))
101
- throw new Error(`Invalid location selector: '${n}'`);
228
+ ].forEach((s) => {
229
+ const l = n[s];
230
+ if (l && typeof l != "function")
231
+ throw new Error(`Callback '${s}' must be a function.`);
232
+ }), typeof t == "string" && !document.querySelector(t))
233
+ throw new Error(`Invalid location selector: '${t}'`);
102
234
  if (r && typeof r != "object")
103
235
  throw new Error(
104
236
  "Theme must be an object with CSS variables, do not include the '--' prefix"
105
237
  );
106
238
  }
107
- function s(i, { text: e, className: t, parent: o, innerHTML: n } = {}) {
108
- const r = document.createElement(i);
109
- return t && (r.className = t), e != null && (r.textContent = e), n != null && (r.innerHTML = n), o && o.appendChild(r), r;
239
+ function a(c, { text: e, className: o, parent: n, innerHTML: t } = {}) {
240
+ const r = document.createElement(c);
241
+ return o && (r.className = o), e != null && (r.textContent = e), t != null && (r.innerHTML = t), n && n.appendChild(r), r;
110
242
  }
111
- function w(i, { name: e, description: t }) {
112
- s("div", {
243
+ function O(c, { name: e, description: o }) {
244
+ a("div", {
113
245
  className: "spot-header__title",
114
246
  text: e,
115
- parent: i
116
- }), s("div", {
247
+ parent: c
248
+ }), a("div", {
117
249
  className: "spot-header__description",
118
- text: t,
119
- parent: i
250
+ text: o,
251
+ parent: c
120
252
  });
121
253
  }
122
- function C(i, e = []) {
123
- const t = s("ul", {
254
+ function P(c, e = []) {
255
+ const o = a("ul", {
124
256
  className: "spot-benefits__list",
125
- parent: i
257
+ parent: c
126
258
  });
127
- e.forEach((o) => {
128
- const n = s("li", { parent: t });
129
- n.innerHTML = `
259
+ e.forEach((n) => {
260
+ const t = a("li", { parent: o });
261
+ t.innerHTML = `
130
262
  <svg width="14" height="14" viewBox="0 0 14 14" fill="none">
131
263
  <path d="M11.6666 3.5L5.24998 9.91667L2.33331 7"
132
264
  stroke="#2E2E2E" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
133
- </svg>`, s("span", { text: o, parent: n });
265
+ </svg>`, a("span", { text: n, parent: t });
134
266
  });
135
267
  }
136
- function E(i, e = []) {
137
- const t = s("div", {
268
+ function $(c, e = []) {
269
+ if (e.length === 0) return;
270
+ const o = a("div", {
271
+ className: "spot-covered-items__container",
272
+ parent: c
273
+ });
274
+ a("div", {
275
+ className: "spot-covered-items__title",
276
+ text: "Items covered in your cart:",
277
+ parent: o
278
+ });
279
+ const n = a("ul", {
280
+ className: "spot-covered-items__list",
281
+ parent: o
282
+ });
283
+ e.forEach((t) => {
284
+ const r = a("li", { parent: n });
285
+ a("span", { text: t, parent: r });
286
+ });
287
+ }
288
+ function R(c, e = []) {
289
+ const o = a("div", {
138
290
  className: "spot-table__container",
139
- parent: i
140
- }), o = s("table", {
291
+ parent: c
292
+ }), n = a("table", {
141
293
  className: "spot-refund__table spot-table--dynamic",
142
- parent: t
143
- }), n = s("thead", { parent: o }), r = s("tr", { parent: n });
144
- s("th", { text: "When you cancel", parent: r }), s("th", { text: "You will receive", parent: r });
145
- const a = s("tbody", { parent: o });
146
- e.forEach(({ text: p, percent: c, amount: l }) => {
147
- const d = s("tr", { parent: a });
148
- s("td", { text: p, parent: d });
149
- const u = c === "Not eligible for refund" ? "Not eligible for a refund" : `$${l} refund`;
150
- s("td", { text: u, parent: d });
294
+ parent: o
295
+ }), t = a("thead", { parent: n }), r = a("tr", { parent: t });
296
+ a("th", { text: "When you cancel", parent: r }), a("th", { text: "You will receive", parent: r });
297
+ const p = a("tbody", { parent: n });
298
+ e.forEach(({ text: i, percent: u, amount: g }) => {
299
+ const h = a("tr", { parent: p });
300
+ a("td", { text: i, parent: h });
301
+ const d = u === "Not eligible for refund" ? "Not eligible for a refund" : `$${g} refund`;
302
+ a("td", { text: d, parent: h });
151
303
  });
152
304
  }
153
- function k(i, e, t) {
154
- const o = s("div", {
305
+ function Q(c, e, o) {
306
+ const n = a("div", {
155
307
  className: "spot-selection__options",
156
- parent: i
157
- }), n = s("label", {
308
+ parent: c
309
+ }), t = a("label", {
158
310
  className: `spot-selection__option ${e ? "selected" : ""}`,
159
- parent: o
160
- }), r = s("input", { parent: n });
161
- r.type = "radio", r.name = "selection", r.value = "yes", e && (r.checked = !0), s("strong", {
162
- text: t.yesOptionText,
163
311
  parent: n
164
- }), s("span", {
312
+ }), r = a("input", { parent: t });
313
+ r.type = "radio", r.name = "selection", r.value = "yes", e && (r.checked = !0), a("strong", {
314
+ text: o.yesOptionText,
315
+ parent: t
316
+ }), a("span", {
165
317
  className: "spot-selection__recommended-tag",
166
318
  text: "Recommended",
167
- parent: n
319
+ parent: t
168
320
  });
169
- const a = s("label", {
321
+ const p = a("label", {
170
322
  className: "spot-selection__option",
171
- parent: o
172
- }), p = s("input", { parent: a });
173
- return p.type = "radio", p.name = "selection", p.value = "no", s("span", { text: t.noOptionText, parent: a }), o;
323
+ parent: n
324
+ }), i = a("input", { parent: p });
325
+ return i.type = "radio", i.name = "selection", i.value = "no", a("span", { text: o.noOptionText, parent: p }), n;
174
326
  }
175
- function x(i, e) {
176
- var n;
177
- const t = (n = e.communication) == null ? void 0 : n.paymentTerms, o = s("div", {
327
+ function H(c, e) {
328
+ var t;
329
+ const o = (t = e.communication) == null ? void 0 : t.paymentTerms, n = a("div", {
178
330
  className: "spot-payment-terms",
179
- parent: i
331
+ parent: c
180
332
  });
181
- return s("div", {
333
+ return a("div", {
182
334
  className: "spot-payment-terms__header",
183
335
  text: "PAYMENT TERMS",
184
- parent: o
185
- }), s("div", {
336
+ parent: n
337
+ }), a("div", {
186
338
  className: "spot-payment-terms__body",
187
- text: t,
188
- parent: o
189
- }), o;
339
+ text: o,
340
+ parent: n
341
+ }), n;
190
342
  }
191
- function q(i, e) {
192
- const t = s("div", {
343
+ function S(c, e) {
344
+ const o = a("div", {
193
345
  className: "spot-footer__container",
194
- parent: i
195
- }), o = s("div", {
346
+ parent: c
347
+ }), n = a("div", {
196
348
  className: "spot-footer__terms",
197
- parent: t
349
+ parent: o
198
350
  });
199
- s("span", {
351
+ a("span", {
200
352
  innerHTML: e.communication.legalDisclaimer,
201
- parent: o
202
- }), s("br", { parent: o }), s("a", {
353
+ parent: n
354
+ }), a("br", { parent: n }), a("a", {
203
355
  href: e.communication.termsAndConditionsUrl,
204
356
  className: "spot-footer__terms-link",
205
357
  text: "Refund Guarantee Terms and Conditions",
206
- parent: o
358
+ parent: n
207
359
  });
208
- const n = s("p", {
360
+ const t = a("p", {
209
361
  className: "spot-footer__powered-by",
210
- parent: t
362
+ parent: o
211
363
  });
212
- return n.innerHTML = `
364
+ return t.innerHTML = `
213
365
  <svg width="145" height="28" viewBox="0 0 145 28" fill="none" xmlns="http://www.w3.org/2000/svg">
214
366
  <rect width="145" height="28"/>
215
367
  <rect x="-655" y="-270" width="819" height="325" rx="10"/>
@@ -224,19 +376,20 @@ function q(i, e) {
224
376
  <rect width="45.405" height="14.8867" fill="white" transform="translate(87 8)"/>
225
377
  </clipPath>
226
378
  </defs>
227
- </svg>`, t;
379
+ </svg>`, o;
228
380
  }
229
- const T = ":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-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-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-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}.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}@media (min-width: 48rem){.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr 20.3125rem;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list{grid-row:1}.desktop-layout .spot-selection__options{grid-row:2}.desktop-layout .spot-table__container{grid-row:1 / span 2}}@media (max-width: 52.438rem){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 47.938rem){.spot-selection__recommended-tag{margin-top:0rem}}@media (max-width: 32.125rem){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 47.9375rem){.spot-table__container{display:flex;justify-content:center}.spot-selection__recommended-tag{display:inline-block;margin-left:0}.spot-footer__container{flex-direction:column;margin-top:.5rem}.spot-refund__table{width:100%;table-layout:auto}.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:.5rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.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:1.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;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}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:block;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;gap:.5rem;flex:1 0 0;align-self:stretch}.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:1.5rem;white-space:nowrap}.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)}.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;justify-content:space-between;align-items:center}.spot-footer__powered-by{margin-top:1.5rem}";
230
- function H(i) {
381
+ const z = ":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-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-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-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}.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}@media (min-width: 48rem){.spot-content__wrapper.desktop-layout{display:grid;grid-template-columns:1fr 20.3125rem;align-items:start;gap:1rem}.desktop-layout .spot-benefits__list{grid-row:1}.desktop-layout .spot-covered-items__container{grid-row:2;grid-column:1}.desktop-layout .spot-selection__options{grid-row:3}.desktop-layout .spot-table__container{grid-row:1 / span 3}}@media (max-width: 52.438rem){.spot-selection__recommended-tag{display:inline-block;margin-left:0}}@media (max-width: 47.938rem){.spot-selection__recommended-tag{margin-top:0rem}}@media (max-width: 32.125rem){.spot-selection__recommended-tag{margin-top:.5rem}}@media (max-width: 47.9375rem){.spot-table__container{display:flex;justify-content:center}.spot-selection__recommended-tag{display:inline-block;margin-left:0}.spot-footer__container{flex-direction:column;margin-top:.5rem}.spot-refund__table{width:100%;table-layout:auto}.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:.5rem;display:flex;align-items:flex-start;gap:.5rem}.spot-benefits__list li svg{flex-shrink:0;position:relative;top:.125rem}.spot-covered-items__container{margin-top:0;margin-bottom:1rem}.spot-covered-items__title{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: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-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:1.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;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}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:block;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;gap:.5rem;flex:1 0 0;align-self:stretch}.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:1.5rem;white-space:nowrap}.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)}.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;justify-content:space-between;align-items:center}.spot-footer__powered-by{margin-top:1.5rem}";
382
+ function M(c) {
231
383
  const e = document.createElement("style");
232
- e.textContent = i, document.head.appendChild(e);
384
+ e.textContent = c, document.head.appendChild(e);
233
385
  }
234
- H(T);
235
- const _ = {
386
+ M(z);
387
+ const T = {
236
388
  sandbox: "https://api.sandbox.getspot.com/api/v1/quote",
237
- production: "https://api.getspot.com/api/v1/quote"
389
+ production: "https://api.getspot.com/api/v1/quote",
390
+ local: "http://localhost:3999/api/v1/quote"
238
391
  };
239
- class N {
392
+ class L {
240
393
  constructor(e = {}) {
241
394
  this.options = {
242
395
  location: "body",
@@ -249,14 +402,10 @@ class N {
249
402
  }, 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();
250
403
  }
251
404
  async _init() {
252
- var e, t, o, n, r;
405
+ var e, o, n, t, r;
253
406
  try {
254
- y(this.options);
255
- const { environment: a, partnerId: p } = this.options.apiConfig, l = this.options.apiConfig.customEndpoint || _[a], d = await b(
256
- l,
257
- p,
258
- this.options.quoteRequestData
259
- );
407
+ k(this.options);
408
+ const { environment: p, partnerId: i } = this.options.apiConfig, g = this.options.apiConfig.customEndpoint || T[p], d = this.options.quoteRequestData.cartInfo && this.options.quoteRequestData.items ? await D(g, i, this.options.quoteRequestData) : await I(g, i, this.options.quoteRequestData);
260
409
  if (d.status !== "QUOTE_AVAILABLE") {
261
410
  d.status === "NO_MATCHING_QUOTE" && ((e = this.options.callbacks) != null && e.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
262
411
  status: "NO_MATCHING_QUOTE",
@@ -264,54 +413,95 @@ class N {
264
413
  });
265
414
  return;
266
415
  }
267
- this.quote = d.data, this._renderWidget(), this.options.optInSelected && ((t = this.options.callbacks) != null && t.onOptIn) && this.options.callbacks.onOptIn({
268
- status: "QUOTE_ACCEPTED",
269
- spotPrice: this.quote.spotPrice,
270
- quoteId: this.quote.id
271
- }), (o = this.options.callbacks) != null && o.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote);
272
- } catch (a) {
273
- (n = this.options.callbacks) != null && n.onError && ((r = this.options.callbacks) == null || r.onError({
274
- message: a.message,
275
- status: a.status,
276
- responseBody: a.responseBody
416
+ if (this.quote = d.data, this._renderWidget(), this.options.optInSelected && ((o = this.options.callbacks) != null && o.onOptIn)) {
417
+ const b = {
418
+ status: "QUOTE_ACCEPTED",
419
+ spotPrice: this.quote.spotPrice,
420
+ quoteId: this.quote.id
421
+ };
422
+ this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (b.batchQuoteDetails = this.quote.originalQuotes.map((s) => {
423
+ var f;
424
+ const l = (f = this.options.quoteRequestData.items) == null ? void 0 : f.find(
425
+ (w) => (w.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(w) + 1}`) === s.cartItemId
426
+ );
427
+ return {
428
+ quoteId: s.id,
429
+ productPrice: (l == null ? void 0 : l.productPrice) || s.spotPrice,
430
+ cartItemId: s.cartItemId
431
+ };
432
+ })), this.options.callbacks.onOptIn(b);
433
+ }
434
+ (n = this.options.callbacks) != null && n.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote);
435
+ } catch (p) {
436
+ (t = this.options.callbacks) != null && t.onError && ((r = this.options.callbacks) == null || r.onError({
437
+ message: p.message,
438
+ status: p.status,
439
+ responseBody: p.responseBody
277
440
  }));
278
441
  }
279
442
  }
280
443
  _renderWidget() {
281
- this.container = document.createElement("div"), this.container.className = "spot-refund-guarantee", this.root.appendChild(this.container), Object.entries(this.options.theme || {}).forEach(([o, n]) => {
282
- const r = `--${o}`;
283
- this.container.style.setProperty(r, n);
284
- }), w(this.container, this.quote.communication);
444
+ this.container = document.createElement("div"), this.container.className = "spot-refund-guarantee", this.root.appendChild(this.container), Object.entries(this.options.theme || {}).forEach(([n, t]) => {
445
+ const r = `--${n}`;
446
+ this.container.style.setProperty(r, t);
447
+ }), O(this.container, this.quote.communication);
285
448
  const e = document.createElement("div");
286
- e.className = "spot-content__wrapper", this.container.appendChild(e), C(e, this.quote.communication.bulletPoints), this.options.showTable && E(e, this.quote.payoutSchedule);
287
- const t = k(
449
+ e.className = "spot-content__wrapper", this.container.appendChild(e), P(e, this.quote.communication.bulletPoints), this.quote.coveredItems && $(e, this.quote.coveredItems), this.options.showTable && R(e, this.quote.payoutSchedule);
450
+ const o = Q(
288
451
  e,
289
452
  this.options.optInSelected,
290
453
  this.quote.communication
291
454
  );
292
- e.appendChild(t), this.paymentTermsEl = s("div", {
455
+ e.appendChild(o), this.paymentTermsEl = a("div", {
293
456
  className: "spot-payment-terms__wrapper",
294
457
  parent: e
295
- }), q(this.container, this.quote), window.addEventListener("resize", this._onResize), this._updateLayout(), this._setupOptionListeners(t);
458
+ }), S(this.container, this.quote), window.addEventListener("resize", this._onResize), this._updateLayout(), this._setupOptionListeners(o);
296
459
  }
297
460
  _updateLayout() {
298
461
  const e = window.matchMedia("(min-width: 768px)").matches;
299
462
  this.container.querySelector(".spot-content__wrapper").classList.toggle("desktop-layout", e && this.options.showTable);
300
463
  }
301
464
  _setupOptionListeners(e) {
302
- const t = e.querySelectorAll('input[type="radio"]'), o = e.querySelectorAll(".spot-selection__option");
303
- t.forEach((n) => {
304
- n.addEventListener("change", (r) => {
305
- var p, c, l;
306
- const a = r.target.value;
307
- this.hideSelectionError(), this.currentSelection = a, o.forEach((d) => d.classList.remove("selected")), (p = r.target.closest(".spot-selection__option")) == null || p.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), a === "yes" && (this.options.quoteRequestData.isPartialPayment && x(this.paymentTermsEl, this.quote), (c = this.options.callbacks) != null && c.onOptIn && this.options.callbacks.onOptIn({
308
- status: "QUOTE_ACCEPTED",
309
- spotPrice: this.quote.spotPrice,
310
- quoteId: this.quote.id
311
- })), a === "no" && ((l = this.options.callbacks) != null && l.onOptOut) && this.options.callbacks.onOptOut({
312
- status: "QUOTE_DECLINED",
313
- quoteId: this.quote.id
314
- });
465
+ const o = e.querySelectorAll('input[type="radio"]'), n = e.querySelectorAll(".spot-selection__option");
466
+ o.forEach((t) => {
467
+ t.addEventListener("change", (r) => {
468
+ var i, u, g;
469
+ const p = r.target.value;
470
+ if (this.hideSelectionError(), this.currentSelection = p, n.forEach((h) => h.classList.remove("selected")), (i = r.target.closest(".spot-selection__option")) == null || i.classList.add("selected"), this.paymentTermsEl && (this.paymentTermsEl.innerHTML = ""), p === "yes" && (this.options.quoteRequestData.isPartialPayment && H(this.paymentTermsEl, this.quote), (u = this.options.callbacks) != null && u.onOptIn)) {
471
+ const h = {
472
+ status: "QUOTE_ACCEPTED",
473
+ spotPrice: this.quote.spotPrice,
474
+ quoteId: this.quote.id
475
+ };
476
+ this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (h.batchQuoteDetails = this.quote.originalQuotes.map((d) => {
477
+ var s;
478
+ const b = (s = this.options.quoteRequestData.items) == null ? void 0 : s.find(
479
+ (l) => (l.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(l) + 1}`) === d.cartItemId
480
+ );
481
+ return {
482
+ quoteId: d.id,
483
+ productPrice: (b == null ? void 0 : b.productPrice) || d.spotPrice,
484
+ cartItemId: d.cartItemId
485
+ };
486
+ })), this.options.callbacks.onOptIn(h);
487
+ }
488
+ if (p === "no" && ((g = this.options.callbacks) != null && g.onOptOut)) {
489
+ const h = {
490
+ status: "QUOTE_DECLINED",
491
+ quoteId: this.quote.id
492
+ };
493
+ this.quote.originalQuotes && this.quote.originalQuotes.length > 0 && (h.batchQuoteDetails = this.quote.originalQuotes.map((d) => {
494
+ var s;
495
+ const b = (s = this.options.quoteRequestData.items) == null ? void 0 : s.find(
496
+ (l) => (l.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(l) + 1}`) === d.cartItemId
497
+ );
498
+ return {
499
+ quoteId: d.id,
500
+ productPrice: (b == null ? void 0 : b.productPrice) || d.spotPrice,
501
+ cartItemId: d.cartItemId
502
+ };
503
+ })), this.options.callbacks.onOptOut(h);
504
+ }
315
505
  });
316
506
  });
317
507
  }
@@ -319,10 +509,10 @@ class N {
319
509
  var e;
320
510
  if (!this.errorEl) {
321
511
  this.errorEl = document.createElement("div"), this.errorEl.className = "spot-selection__error", this.errorEl.textContent = "Please make a selection";
322
- const t = (e = this.container) == null ? void 0 : e.querySelector(
512
+ const o = (e = this.container) == null ? void 0 : e.querySelector(
323
513
  ".spot-selection__options"
324
514
  );
325
- t && t.insertAdjacentElement("afterend", this.errorEl);
515
+ o && o.insertAdjacentElement("afterend", this.errorEl);
326
516
  }
327
517
  this.errorEl.style.display = "block";
328
518
  }
@@ -337,31 +527,24 @@ class N {
337
527
  return e ? this.hideSelectionError() : this.showSelectionError(), e;
338
528
  }
339
529
  async updateQuote(e) {
340
- var t, o, n;
530
+ var o, n, t;
341
531
  try {
342
532
  const r = {
343
533
  ...this.options,
344
- quoteRequestData: {
345
- ...this.options.quoteRequestData,
346
- ...e
347
- }
534
+ quoteRequestData: e
348
535
  };
349
- y(r);
536
+ k(r);
350
537
  const {
351
- environment: a,
352
- partnerId: p,
353
- endpoint: c
354
- } = this.options.apiConfig, l = c || _[a], d = await b(
355
- l,
356
- p,
357
- r.quoteRequestData
358
- );
359
- return d.status !== "QUOTE_AVAILABLE" ? (d.status === "NO_MATCHING_QUOTE" && ((t = this.options.callbacks) != null && t.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
538
+ environment: p,
539
+ partnerId: i,
540
+ endpoint: u
541
+ } = this.options.apiConfig, g = u || T[p], d = r.quoteRequestData.cartInfo && r.quoteRequestData.items ? await D(g, i, r.quoteRequestData) : await I(g, i, r.quoteRequestData);
542
+ return d.status !== "QUOTE_AVAILABLE" ? (d.status === "NO_MATCHING_QUOTE" && ((o = this.options.callbacks) != null && o.noMatchingQuote) && this.options.callbacks.noMatchingQuote({
360
543
  status: "NO_MATCHING_QUOTE",
361
544
  data: r.quoteRequestData
362
- }), !1) : (this.options.quoteRequestData = r.quoteRequestData, this.quote = d.data, this.currentSelection = null, this.destroy(), this._renderWidget(), (o = this.options.callbacks) != null && o.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote), !0);
545
+ }), !1) : (this.options.quoteRequestData = r.quoteRequestData, this.quote = d.data, this.currentSelection = null, this.destroy(), this._renderWidget(), (n = this.options.callbacks) != null && n.onQuoteRetrieved && this.options.callbacks.onQuoteRetrieved(this.quote), !0);
363
546
  } catch (r) {
364
- return (n = this.options.callbacks) == null || n.onError({
547
+ return (t = this.options.callbacks) == null || t.onError({
365
548
  message: r.message,
366
549
  status: r.status,
367
550
  responseBody: r.responseBody
@@ -369,18 +552,30 @@ class N {
369
552
  }
370
553
  }
371
554
  getSelection() {
372
- var e, t;
373
- return this.currentSelection == null ? null : {
555
+ var o, n, t;
556
+ if (this.currentSelection == null) return null;
557
+ const e = {
374
558
  selection: this.currentSelection,
375
- quoteId: (e = this.quote) == null ? void 0 : e.id,
376
- spotPrice: (t = this.quote) == null ? void 0 : t.spotPrice,
559
+ quoteId: (o = this.quote) == null ? void 0 : o.id,
560
+ spotPrice: (n = this.quote) == null ? void 0 : n.spotPrice,
377
561
  status: this.currentSelection === "yes" ? "QUOTE_ACCEPTED" : "QUOTE_DECLINED"
378
562
  };
563
+ return (t = this.quote) != null && t.originalQuotes && this.quote.originalQuotes.length > 0 && (e.batchQuoteDetails = this.quote.originalQuotes.map((r) => {
564
+ var i;
565
+ const p = (i = this.options.quoteRequestData.items) == null ? void 0 : i.find(
566
+ (u) => (u.cartItemId || `item-${this.options.quoteRequestData.items.indexOf(u) + 1}`) === r.cartItemId
567
+ );
568
+ return {
569
+ quoteId: r.id,
570
+ productPrice: (p == null ? void 0 : p.productPrice) || r.spotPrice,
571
+ cartItemId: r.cartItemId
572
+ };
573
+ })), e;
379
574
  }
380
575
  destroy() {
381
576
  window.removeEventListener("resize", this._onResize), this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container);
382
577
  }
383
578
  }
384
579
  export {
385
- N as default
580
+ L as default
386
581
  };