@getspot/spot-widget 3.2.4 → 3.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/CHANGELOG.md +14 -0
- package/dist/index.es.js +6 -6
- package/dist/index.umd.js +4 -4
- package/dist/ui.d.ts.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [3.3.0](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.2.5...@getspot/spot-widget@3.3.0) (2025-12-22)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **react:** add storybook support. run 'pnpm run storybook' to see ([7f751d1](https://gitlab.com/getspot/spot-widget/commit/7f751d15f8d3705ca746bf695169fd0f7b6d79ca))
|
|
7
|
+
|
|
8
|
+
## [3.2.5](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.2.4...@getspot/spot-widget@3.2.5) (2025-12-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **core:** stop event propogation on covered items toggle ([357cd77](https://gitlab.com/getspot/spot-widget/commit/357cd77c01d9245b1ac852270b6494911307abf1))
|
|
14
|
+
|
|
1
15
|
## [3.2.4](https://gitlab.com/getspot/spot-widget/compare/@getspot/spot-widget@3.2.3...@getspot/spot-widget@3.2.4) (2025-12-16)
|
|
2
16
|
|
|
3
17
|
|
package/dist/index.es.js
CHANGED
|
@@ -387,11 +387,11 @@ function O(m, t = [], o) {
|
|
|
387
387
|
c("span", { text: p, parent: l });
|
|
388
388
|
});
|
|
389
389
|
let d = !1;
|
|
390
|
-
h.style.display = "none", n.addEventListener("click", () => {
|
|
391
|
-
d = !d, h.style.display = d ? "block" : "none", f.innerHTML = d ? "▲" : "▼", n.setAttribute("aria-expanded", d.toString());
|
|
390
|
+
h.style.display = "none", n.addEventListener("click", (p) => {
|
|
391
|
+
p.stopPropagation(), d = !d, h.style.display = d ? "block" : "none", f.innerHTML = d ? "▲" : "▼", n.setAttribute("aria-expanded", d.toString());
|
|
392
392
|
}), n.setAttribute("aria-expanded", "false"), n.setAttribute("aria-controls", "covered-items-list"), h.setAttribute("id", "covered-items-list");
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function P(m, t = []) {
|
|
395
395
|
const o = c("div", {
|
|
396
396
|
className: "spot-table__container",
|
|
397
397
|
parent: m
|
|
@@ -408,7 +408,7 @@ function $(m, t = []) {
|
|
|
408
408
|
c("td", { text: h, parent: f });
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
|
-
function
|
|
411
|
+
function $(m, t, o) {
|
|
412
412
|
const s = c("div", {
|
|
413
413
|
className: "spot-selection__options",
|
|
414
414
|
parent: m
|
|
@@ -607,8 +607,8 @@ class A {
|
|
|
607
607
|
const s = this._getTotalItemsInRequest();
|
|
608
608
|
O(t, this.quote.coveredItems, s);
|
|
609
609
|
}
|
|
610
|
-
this.options.showTable && !this.quote.qualifyingReasons &&
|
|
611
|
-
const o =
|
|
610
|
+
this.options.showTable && !this.quote.qualifyingReasons && P(t, this.quote.payoutSchedule);
|
|
611
|
+
const o = $(
|
|
612
612
|
t,
|
|
613
613
|
this.options.optInSelected,
|
|
614
614
|
this.quote.communication
|
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,o){try{const s=await fetch(m,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),a=await s.json();if(!s.ok){const r=new Error((a==null?void 0:a.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=a,r}return a}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"),a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await a.json();if(!a.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=a.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 x(m,t,o){var s;try{const a={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,items:o.items.map((n,u)=>({cartItemId:n.cartItemId||`item-${u+1}`,productPrice:n.productPrice,productType:n.productType,productDuration:n.productDuration,productId:n.productId,productName:n.productName,participantDescription:n.participantDescription,eventType:n.eventType,eventId:n.eventId,startDate:n.startDate,endDate:n.endDate}))},r=await C(m,t,a);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const i=r.quotes.map(n=>{const u=o.items.find((f,h)=>(f.cartItemId||`item-${h+1}`)===n.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${n.id}`}),e=Math.round((r.totalSpotPrice||r.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:r.quotes?r.quotes.map(n=>n.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(n=>({...n,amount:n.amount!==void 0?n.amount:0})),coveredItems:i,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:i}}catch(a){throw a instanceof Error?a: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 E(m){const{apiConfig:t={},quoteRequestData:o,callbacks:s={},location:a,theme:r}=m,{environment:i="sandbox",partnerId:e,customEndpoint:n}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(n||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 f=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function h(d,
|
|
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)}),a=await s.json();if(!s.ok){const r=new Error((a==null?void 0:a.message)||"Failed to fetch quote");throw r.status=s.status,r.responseBody=a,r}return a}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"),a=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json","X-Spot-Partner-Id":t},body:JSON.stringify(o)}),r=await a.json();if(!a.ok){const i=new Error((r==null?void 0:r.message)||"Failed to fetch batch quote");throw i.status=a.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 x(m,t,o){var s;try{const a={cartId:o.cartInfo.cartId,cartName:o.cartInfo.cartName,currencyCode:o.cartInfo.currencyCode,items:o.items.map((n,u)=>({cartItemId:n.cartItemId||`item-${u+1}`,productPrice:n.productPrice,productType:n.productType,productDuration:n.productDuration,productId:n.productId,productName:n.productName,participantDescription:n.participantDescription,eventType:n.eventType,eventId:n.eventId,startDate:n.startDate,endDate:n.endDate}))},r=await C(m,t,a);if(r.status!=="QUOTES_AVAILABLE"&&r.status!=="QUOTE_AVAILABLE")return{status:"NO_MATCHING_QUOTE"};const i=r.quotes.map(n=>{const u=o.items.find((f,h)=>(f.cartItemId||`item-${h+1}`)===n.cartItemId);return u?u.participantDescription?`${u.productName} - ${u.participantDescription}`:u.productName:`Item ${n.id}`}),e=Math.round((r.totalSpotPrice||r.spotPrice||0)*100)/100;return{status:"QUOTE_AVAILABLE",data:{id:r.quotes?r.quotes.map(n=>n.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(n=>({...n,amount:n.amount!==void 0?n.amount:0})),coveredItems:i,originalQuotes:r.quotes||(r.data?[r.data]:[])},spotPrice:e,coveredItems:i}}catch(a){throw a instanceof Error?a: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 E(m){const{apiConfig:t={},quoteRequestData:o,callbacks:s={},location:a,theme:r}=m,{environment:i="sandbox",partnerId:e,customEndpoint:n}=t;if(!e||typeof e!="string")throw new Error("Invalid or missing partnerId in apiConfig");if(!(n||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 f=["startDate","endDate","currencyCode","eventType","productType","productDuration","productPrice","productId","cartId","productName"];function h(d,p=null){const l=p!==null?`quoteRequestData[${p}]`:"quoteRequestData";f.forEach(v=>{if(!Object.prototype.hasOwnProperty.call(d,v)||d[v]===void 0||d[v]===null)throw new Error(`Missing required ${l} field: '${v}'`)});const w=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?Z$/;if(!w.test(d.startDate))throw new Error(`${l}.startDate must be a valid ISO8601 string`);if(!w.test(d.endDate))throw new Error(`${l}.endDate must be a valid ISO8601 string`);if(typeof d.currencyCode!="string")throw new Error(`${l}.currencyCode must be a string`);if(!["USD","CAD","AUD"].includes(d.currencyCode))throw new Error(`Invalid ${l}.currencyCode: ${d.currencyCode}`);if(typeof d.eventType!="string")throw new Error(`${l}.eventType must be a string`);if(typeof d.productType!="string")throw new Error(`${l}.productType must be a string`);const g=["Pass","Trip","Registration"];if(!g.includes(d.productType))throw new Error(`${l}.productType must be one of ${g.join(", ")}`);if(typeof d.productDuration!="string")throw new Error(`${l}.productDuration must be a string`);const b=["Daily","Seasonal","Trip","Event"];if(!b.includes(d.productDuration))throw new Error(`${l}.productDuration must be one of ${b.join(", ")}`);if(typeof d.productPrice!="number"||isNaN(d.productPrice))throw new Error(`${l}.productPrice must be a valid number`);if(typeof d.productId!="string")throw new Error(`${l}.productId must be a string`);if(typeof d.cartId!="string")throw new Error(`${l}.cartId must be a string`);if(typeof d.productName!="string")throw new Error(`${l}.productName must be a string`)}if("cartInfo"in o&&"items"in o){const d=o,{cartInfo:p,items:l}=d;if(!p||typeof p!="object")throw new Error("quoteRequestData.cartInfo must be a non-null object");if(!p.cartId||typeof p.cartId!="string")throw new Error("quoteRequestData.cartInfo.cartId must be a string");if(!p.cartName||typeof p.cartName!="string")throw new Error("quoteRequestData.cartInfo.cartName must be a string");if(!p.currencyCode||typeof p.currencyCode!="string")throw new Error("quoteRequestData.cartInfo.currencyCode must be a string");if(!["USD","CAD","AUD"].includes(p.currencyCode))throw new Error(`Invalid quoteRequestData.cartInfo.currencyCode: ${p.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,b)=>{if(!g||typeof g!="object")throw new Error(`quoteRequestData.items[${b}] must be a non-null object`);const v=`quoteRequestData.items[${b}]`;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((d,p)=>{if(!d||typeof d!="object")throw new Error(`quoteRequestData[${p}] must be a non-null object`);h(d,p)})}else h(o);if(["onOptIn","onOptOut","onQuoteRetrieved","onError","noMatchingQuote"].forEach(d=>{const p=s[d];if(p&&typeof p!="function")throw new Error(`Callback '${d}' must be a function.`)}),typeof a=="string"&&!document.querySelector(a))throw new Error(`Invalid location selector: '${a}'`);if(r&&typeof r!="object")throw new Error("Theme must be an object with CSS variables, do not include the '--' prefix")}function c(m,{text:t,className:o,parent:s,innerHTML:a,href:r,target:i}={}){const e=document.createElement(m);return o&&(e.className=o),t!=null&&(e.textContent=t),a!=null&&(e.innerHTML=a),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}){c("div",{className:"spot-header__title",text:t,parent:m}),c("div",{className:"spot-header__description",text:o,parent:m})}function M(m,t=[]){const o=c("ul",{className:"spot-benefits__list",parent:m});t.forEach(s=>{const a=c("li",{parent:o});a.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>`,
|
|
5
|
+
</svg>`,c("span",{text:s,parent:a})})}function L(m,t=[]){if(!t||t.length===0)return;const o=c("div",{className:"spot-qualifying-reasons__container",parent:m}),s=[...t].sort((e,n)=>e.rank-n.rank),a=c("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 n=new URL(e.src);i=n.origin+n.pathname.replace(/\/[^/]*$/,"/")}else i=window.location.origin+window.location.pathname.replace(/\/[^/]*$/,"/");i+="assets/"}catch{i="./assets/"}s.forEach(e=>{var h,y,d;const n=c("div",{className:"spot-qualifying-reasons__item",parent:a}),u=c("div",{className:"spot-qualifying-reasons__icon-wrapper",parent:n}),f=r[((h=e.benefitType)==null?void 0:h.name)||""]||r[e.name||""];if(f){const p=c("img",{parent:u});p.src=i+f,p.alt=((y=e.benefitType)==null?void 0:y.name)||e.name||"",p.className="spot-qualifying-reasons__icon"}c("span",{className:"spot-qualifying-reasons__label",text:((d=e.benefitType)==null?void 0:d.name)||e.name||"",parent:n})})}function O(m,t=[],o){if(t.length===0||!o||o<=1)return;const s=new Map;t.forEach(p=>{s.set(p,(s.get(p)||0)+1)});const r=Array.from(s.entries()).map(([p,l])=>({item:p,count:l,displayText:l>1?`${l} x ${p}`:p})).sort((p,l)=>{const w=p.item.charAt(0),q=l.item.charAt(0),g=/[a-zA-Z]/.test(w),b=/[a-zA-Z]/.test(q);return!g&&b?-1:g&&!b?1:p.item.localeCompare(l.item,void 0,{sensitivity:"base"})}),i=c("div",{className:"spot-covered-items__container",parent:m}),e=c("div",{className:"spot-covered-items__header",parent:i}),n=c("button",{className:"spot-covered-items__toggle",parent:e});c("span",{className:"spot-covered-items__title",text:`Items Covered in Your Cart (${t.length})`,parent:n});const u=c("div",{className:"spot-covered-items__right-section",parent:n});c("span",{className:"spot-covered-items__view-all",text:"View All",parent:u});const f=c("span",{className:"spot-covered-items__arrow",innerHTML:"▼",parent:u}),h=c("div",{className:"spot-covered-items__content",parent:i}),y=c("ul",{className:"spot-covered-items__list",parent:h});r.forEach(({displayText:p})=>{const l=c("li",{parent:y});c("span",{text:p,parent:l})});let d=!1;h.style.display="none",n.addEventListener("click",p=>{p.stopPropagation(),d=!d,h.style.display=d?"block":"none",f.innerHTML=d?"▲":"▼",n.setAttribute("aria-expanded",d.toString())}),n.setAttribute("aria-expanded","false"),n.setAttribute("aria-controls","covered-items-list"),h.setAttribute("id","covered-items-list")}function P(m,t=[]){const o=c("div",{className:"spot-table__container",parent:m}),s=c("table",{className:"spot-refund__table spot-table--dynamic",parent:o}),a=c("thead",{parent:s}),r=c("tr",{parent:a});c("th",{text:"When you cancel",parent:r}),c("th",{text:"You will receive",parent:r});const i=c("tbody",{parent:s});t.forEach(({text:e,percent:n,amount:u})=>{const f=c("tr",{parent:i});c("td",{text:e,parent:f});const h=n==="Not eligible for refund"?"Not eligible for a refund":`$${u} refund`;c("td",{text:h,parent:f})})}function $(m,t,o){const s=c("div",{className:"spot-selection__options",parent:m}),a=c("label",{className:`spot-selection__option ${t?"selected":""}`,parent:s}),r=c("input",{parent:a});r.type="radio",r.name="selection",r.value="yes",t&&(r.checked=!0),c("strong",{text:o.yesOptionText,parent:a}),c("span",{className:"spot-selection__recommended-tag",text:"Recommended",parent:a});const i=c("label",{className:"spot-selection__option",parent:s}),e=c("input",{parent:i});return e.type="radio",e.name="selection",e.value="no",c("span",{text:o.noOptionText,parent:i}),s}function R(m,t){var a;const o=(a=t.communication)==null?void 0:a.paymentTerms,s=c("div",{className:"spot-payment-terms",parent:m});return c("div",{className:"spot-payment-terms__header",text:"PAYMENT TERMS",parent:s}),c("div",{className:"spot-payment-terms__body",text:o||"",parent:s}),s}function V(m,t,o="bottom-right"){if(o==="top-right"){const e=c("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=
|
|
20
|
+
</svg>`}const s=c("div",{className:"spot-footer__container",parent:m}),a=c("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(c("span",{innerHTML:i,parent:a}),o==="bottom-right"){const e=c("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-max-width: 51rem;--spot-margin: 1rem;--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:var(--spot-max-width);margin:var(--spot-margin);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,a,r;try{E(this.options);let i;if(this.options.useMockData&&this.options.mockData)i=this.options.mockData;else{const{environment:e,partnerId:n}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||I[e];i="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await x(f,n,this.options.quoteRequestData):await _(f,n,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 n=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var h;const f=(h=n.items)==null?void 0:h.find(y=>(y.cartItemId||`item-${n.items.indexOf(y)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(f==null?void 0:f.productPrice)||u.spotPrice,cartItemId:(f==null?void 0:f.cartItemId)||""}})}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((a=this.options.callbacks)!=null&&a.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,a])=>{const r=`--${s}`;this.container.style.setProperty(r,a)}),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,a=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 n=Math.min(i.scrollWidth,400)+s+a;return r&&t.classList.add("desktop-layout"),o>=n}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(a=>{a.addEventListener("change",r=>{var n,u,f;const i=r.target,e=i.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(h=>h.classList.remove("selected")),(n=i.closest(".spot-selection__option"))==null||n.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 h={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;h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var l;const c=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(c==null?void 0:c.productPrice)||d.spotPrice,cartItemId:(c==null?void 0:c.cartItemId)||""}})}this.options.callbacks.onOptIn(h)}if(e==="no"&&((f=this.options.callbacks)!=null&&f.onOptOut)){const h={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var l;const c=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(c==null?void 0:c.productPrice)||d.spotPrice,cartItemId:(c==null?void 0:c.cartItemId)||""}})}this.options.callbacks.onOptOut(h)}})})}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,a,r;try{const i={...this.options,quoteRequestData:t};E(i);const{environment:e,partnerId:n,customEndpoint:u}=this.options.apiConfig,f=u||I[e],y="cartInfo"in i.quoteRequestData&&"items"in i.quoteRequestData?await x(f,n,i.quoteRequestData):await _(f,n,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 d=this.options.callbacks.onQuoteRetrieved(this.quote);d&&this._applyQuoteUpdates(d)}return!0}catch(i){const e=i;return(r=(a=this.options.callbacks)==null?void 0:a.onError)==null||r.call(a,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,a;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((a=this.quote)!=null&&a.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(i=>{var n;const e=(n=r.items)==null?void 0:n.find(u=>(u.cartItemId||`item-${r.items.indexOf(u)+1}`)===i.cartItemId);return{quoteId:i.id,productPrice:(e==null?void 0:e.productPrice)||i.spotPrice,cartItemId:(e==null?void 0:e.cartItemId)||""}})}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-max-width: 51rem;--spot-margin: 1rem;--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:var(--spot-max-width);margin:var(--spot-margin);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,a,r;try{E(this.options);let i;if(this.options.useMockData&&this.options.mockData)i=this.options.mockData;else{const{environment:e,partnerId:n}=this.options.apiConfig,f=this.options.apiConfig.customEndpoint||I[e];i="cartInfo"in this.options.quoteRequestData&&"items"in this.options.quoteRequestData?await x(f,n,this.options.quoteRequestData):await _(f,n,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 n=this.options.quoteRequestData;e.batchQuoteDetails=this.quote.originalQuotes.map(u=>{var h;const f=(h=n.items)==null?void 0:h.find(y=>(y.cartItemId||`item-${n.items.indexOf(y)+1}`)===u.cartItemId);return{quoteId:u.id,productPrice:(f==null?void 0:f.productPrice)||u.spotPrice,cartItemId:(f==null?void 0:f.cartItemId)||""}})}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((a=this.options.callbacks)!=null&&a.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,a])=>{const r=`--${s}`;this.container.style.setProperty(r,a)}),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 o=$(t,this.options.optInSelected,this.quote.communication);t.appendChild(o),this.paymentTermsEl=c("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,a=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 n=Math.min(i.scrollWidth,400)+s+a;return r&&t.classList.add("desktop-layout"),o>=n}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(a=>{a.addEventListener("change",r=>{var n,u,f;const i=r.target,e=i.value;if(this.hideSelectionError(),this.currentSelection=e,s.forEach(h=>h.classList.remove("selected")),(n=i.closest(".spot-selection__option"))==null||n.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 h={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;h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var l;const p=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(p==null?void 0:p.productPrice)||d.spotPrice,cartItemId:(p==null?void 0:p.cartItemId)||""}})}this.options.callbacks.onOptIn(h)}if(e==="no"&&((f=this.options.callbacks)!=null&&f.onOptOut)){const h={status:"QUOTE_DECLINED",quoteId:this.quote.id};if(this.quote.originalQuotes&&this.quote.originalQuotes.length>0){const y=this.options.quoteRequestData;h.batchQuoteDetails=this.quote.originalQuotes.map(d=>{var l;const p=(l=y.items)==null?void 0:l.find(w=>(w.cartItemId||`item-${y.items.indexOf(w)+1}`)===d.cartItemId);return{quoteId:d.id,productPrice:(p==null?void 0:p.productPrice)||d.spotPrice,cartItemId:(p==null?void 0:p.cartItemId)||""}})}this.options.callbacks.onOptOut(h)}})})}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,a,r;try{const i={...this.options,quoteRequestData:t};E(i);const{environment:e,partnerId:n,customEndpoint:u}=this.options.apiConfig,f=u||I[e],y="cartInfo"in i.quoteRequestData&&"items"in i.quoteRequestData?await x(f,n,i.quoteRequestData):await _(f,n,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 d=this.options.callbacks.onQuoteRetrieved(this.quote);d&&this._applyQuoteUpdates(d)}return!0}catch(i){const e=i;return(r=(a=this.options.callbacks)==null?void 0:a.onError)==null||r.call(a,{message:e.message,status:e.status,responseBody:e.responseBody}),!1}}getSelection(){var o,s,a;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((a=this.quote)!=null&&a.originalQuotes&&this.quote.originalQuotes.length>0){const r=this.options.quoteRequestData;t.batchQuoteDetails=this.quote.originalQuotes.map(i=>{var n;const e=(n=r.items)==null?void 0:n.find(u=>(u.cartItemId||`item-${r.items.indexOf(u)+1}`)===i.cartItemId);return{quoteId:i.id,productPrice:(e==null?void 0:e.productPrice)||i.spotPrice,cartItemId:(e==null?void 0:e.cartItemId)||""}})}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});
|
package/dist/ui.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACN,MAAM,YAAY,CAAC;AAEpB,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,qBAAqB,EAC1D,GAAG,EAAE,CAAC,EACN,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB,GACxE,qBAAqB,CAAC,CAAC,CAAC,CAS1B;AAGD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,WAAW,EACtB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAAC,GACjE,IAAI,CAWN;AAGD,wBAAgB,cAAc,CAC5B,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,MAAM,EAAO,GACrB,IAAI,CAcN;AAGD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,EACtB,iBAAiB,GAAE,gBAAgB,EAAO,GACzC,IAAI,CA0EN;AAGD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,EACtB,YAAY,GAAE,MAAM,EAAO,EAC3B,mBAAmB,CAAC,EAAE,MAAM,GAC3B,IAAI,
|
|
1
|
+
{"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,KAAK,EACN,MAAM,YAAY,CAAC;AAEpB,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,qBAAqB,EAC1D,GAAG,EAAE,CAAC,EACN,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAE,cAAmB,GACxE,qBAAqB,CAAC,CAAC,CAAC,CAS1B;AAGD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,WAAW,EACtB,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,aAAa,CAAC,GACjE,IAAI,CAWN;AAGD,wBAAgB,cAAc,CAC5B,SAAS,EAAE,WAAW,EACtB,OAAO,GAAE,MAAM,EAAO,GACrB,IAAI,CAcN;AAGD,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,WAAW,EACtB,iBAAiB,GAAE,gBAAgB,EAAO,GACzC,IAAI,CA0EN;AAGD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,EACtB,YAAY,GAAE,MAAM,EAAO,EAC3B,mBAAmB,CAAC,EAAE,MAAM,GAC3B,IAAI,CAiHN;AAGD,wBAAgB,WAAW,CACzB,SAAS,EAAE,WAAW,EACtB,QAAQ,GAAE,kBAAkB,EAAO,GAClC,IAAI,CAyBN;AAGD,wBAAgB,aAAa,CAC3B,SAAS,EAAE,WAAW,EACtB,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,aAAa,GAC3B,WAAW,CAyCb;AAGD,wBAAgB,kBAAkB,CAChC,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,KAAK,GACX,WAAW,CAqBb;AAGD,wBAAgB,YAAY,CAC1B,SAAS,EAAE,WAAW,EACtB,KAAK,EAAE,KAAK,EACZ,YAAY,GAAE,cAAc,GAAG,WAA4B,GAC1D,WAAW,CAwEb"}
|