ui.shipaid.com 0.2.0 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnPropertyDescriptors;var at=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable;var pt=(o,t,e)=>t in o?xt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,
|
|
1
|
+
var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnPropertyDescriptors;var at=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable;var pt=(o,t,e)=>t in o?xt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[t]=e,b=(o,t)=>{for(var e in t||(t={}))Ut.call(t,e)&&pt(o,e,t[e]);if(at)for(var e of at(t))kt.call(t,e)&&pt(o,e,t[e]);return o},L=(o,t)=>Pt(o,Tt(t));/**
|
|
2
2
|
* @license
|
|
3
3
|
* Copyright 2017 Google LLC
|
|
4
4
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -6,11 +6,11 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2017 Google LLC
|
|
8
8
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
-
*/const Nt=(o,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?b(
|
|
9
|
+
*/const Nt=(o,t)=>t.kind==="method"&&t.descriptor&&!("value"in t.descriptor)?L(b({},t),{finisher(e){e.createProperty(t.key,o)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:t.key,initializer(){typeof t.initializer=="function"&&(this[t.key]=t.initializer.call(this))},finisher(e){e.createProperty(t.key,o)}};function B(o){return(t,e)=>e!==void 0?((i,r,s)=>{r.constructor.createProperty(s,i)})(o,t,e):Nt(o,t)}/**
|
|
10
10
|
* @license
|
|
11
11
|
* Copyright 2017 Google LLC
|
|
12
12
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
-
*/function g(o){return B(b(
|
|
13
|
+
*/function g(o){return B(L(b({},o),{state:!0}))}/**
|
|
14
14
|
* @license
|
|
15
15
|
* Copyright 2021 Google LLC
|
|
16
16
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -18,7 +18,7 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
18
18
|
* @license
|
|
19
19
|
* Copyright 2019 Google LLC
|
|
20
20
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
21
|
-
*/const V=window.ShadowRoot&&(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,q=Symbol(),
|
|
21
|
+
*/const V=window.ShadowRoot&&(window.ShadyCSS===void 0||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,q=Symbol(),ht=new Map;class lt{constructor(t,e){if(this._$cssResult$=!0,e!==q)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=ht.get(this.cssText);return V&&t===void 0&&(ht.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const It=o=>new lt(typeof o=="string"?o:o+"",q),Ot=(o,...t)=>{const e=o.length===1?o[0]:t.reduce((i,r,s)=>i+(n=>{if(n._$cssResult$===!0)return n.cssText;if(typeof n=="number")return n;throw Error("Value passed to 'css' function must be a 'css' function result: "+n+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+o[s+1],o[0]);return new lt(e,q)},zt=(o,t)=>{V?o.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet):t.forEach(e=>{const i=document.createElement("style"),r=window.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=e.cssText,o.appendChild(i)})},dt=V?o=>o:o=>o instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return It(e)})(o):o;/**
|
|
22
22
|
* @license
|
|
23
23
|
* Copyright 2017 Google LLC
|
|
24
24
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -26,7 +26,7 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
26
26
|
* @license
|
|
27
27
|
* Copyright 2017 Google LLC
|
|
28
28
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
29
|
-
*/var K;const x=globalThis.trustedTypes,mt=x?x.createPolicy("lit-html",{createHTML:o=>o}):void 0
|
|
29
|
+
*/var K;const x=globalThis.trustedTypes,mt=x?x.createPolicy("lit-html",{createHTML:o=>o}):void 0,w=`lit$${(Math.random()+"").slice(9)}$`,vt="?"+w,Rt=`<${vt}>`,P=document,M=(o="")=>P.createComment(o),N=o=>o===null||typeof o!="object"&&typeof o!="function",gt=Array.isArray,Dt=o=>{var t;return gt(o)||typeof((t=o)===null||t===void 0?void 0:t[Symbol.iterator])=="function"},I=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_t=/-->/g,yt=/>/g,S=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,Ct=/'/g,$t=/"/g,wt=/^(?:script|style|textarea|title)$/i,Ft=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),A=Ft(1),T=Symbol.for("lit-noChange"),f=Symbol.for("lit-nothing"),At=new WeakMap,jt=(o,t,e)=>{var i,r;const s=(i=e==null?void 0:e.renderBefore)!==null&&i!==void 0?i:t;let n=s._$litPart$;if(n===void 0){const d=(r=e==null?void 0:e.renderBefore)!==null&&r!==void 0?r:null;s._$litPart$=n=new R(t.insertBefore(M(),d),d,void 0,e!=null?e:{})}return n._$AI(o),n},U=P.createTreeWalker(P,129,null,!1),Bt=(o,t)=>{const e=o.length-1,i=[];let r,s=t===2?"<svg>":"",n=I;for(let a=0;a<e;a++){const p=o[a];let c,h,l=-1,u=0;for(;u<p.length&&(n.lastIndex=u,h=n.exec(p),h!==null);)u=n.lastIndex,n===I?h[1]==="!--"?n=_t:h[1]!==void 0?n=yt:h[2]!==void 0?(wt.test(h[2])&&(r=RegExp("</"+h[2],"g")),n=S):h[3]!==void 0&&(n=S):n===S?h[0]===">"?(n=r!=null?r:I,l=-1):h[1]===void 0?l=-2:(l=n.lastIndex-h[2].length,c=h[1],n=h[3]===void 0?S:h[3]==='"'?$t:Ct):n===$t||n===Ct?n=S:n===_t||n===yt?n=I:(n=S,r=void 0);const _=n===S&&o[a+1].startsWith("/>")?" ":"";s+=n===I?p+Rt:l>=0?(i.push(c),p.slice(0,l)+"$lit$"+p.slice(l)+w+_):p+w+(l===-2?(i.push(void 0),a):_)}const d=s+(o[e]||"<?>")+(t===2?"</svg>":"");if(!Array.isArray(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return[mt!==void 0?mt.createHTML(d):d,i]};class H{constructor({strings:t,_$litType$:e},i){let r;this.parts=[];let s=0,n=0;const d=t.length-1,a=this.parts,[p,c]=Bt(t,e);if(this.el=H.createElement(p,i),U.currentNode=this.el.content,e===2){const h=this.el.content,l=h.firstChild;l.remove(),h.append(...l.childNodes)}for(;(r=U.nextNode())!==null&&a.length<d;){if(r.nodeType===1){if(r.hasAttributes()){const h=[];for(const l of r.getAttributeNames())if(l.endsWith("$lit$")||l.startsWith(w)){const u=c[n++];if(h.push(l),u!==void 0){const _=r.getAttribute(u.toLowerCase()+"$lit$").split(w),y=/([.?@])?(.*)/.exec(u);a.push({type:1,index:s,name:y[2],strings:_,ctor:y[1]==="."?Vt:y[1]==="?"?Zt:y[1]==="@"?Jt:D})}else a.push({type:6,index:s})}for(const l of h)r.removeAttribute(l)}if(wt.test(r.tagName)){const h=r.textContent.split(w),l=h.length-1;if(l>0){r.textContent=x?x.emptyScript:"";for(let u=0;u<l;u++)r.append(h[u],M()),U.nextNode(),a.push({type:2,index:++s});r.append(h[l],M())}}}else if(r.nodeType===8)if(r.data===vt)a.push({type:2,index:s});else{let h=-1;for(;(h=r.data.indexOf(w,h+1))!==-1;)a.push({type:7,index:s}),h+=w.length-1}s++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function k(o,t,e=o,i){var r,s,n,d;if(t===T)return t;let a=i!==void 0?(r=e._$Cl)===null||r===void 0?void 0:r[i]:e._$Cu;const p=N(t)?void 0:t._$litDirective$;return(a==null?void 0:a.constructor)!==p&&((s=a==null?void 0:a._$AO)===null||s===void 0||s.call(a,!1),p===void 0?a=void 0:(a=new p(o),a._$AT(o,e,i)),i!==void 0?((n=(d=e)._$Cl)!==null&&n!==void 0?n:d._$Cl=[])[i]=a:e._$Cu=a),a!==void 0&&(t=k(o,a._$AS(o,t.values),a,i)),t}class Wt{constructor(t,e){this.v=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}p(t){var e;const{el:{content:i},parts:r}=this._$AD,s=((e=t==null?void 0:t.creationScope)!==null&&e!==void 0?e:P).importNode(i,!0);U.currentNode=s;let n=U.nextNode(),d=0,a=0,p=r[0];for(;p!==void 0;){if(d===p.index){let c;p.type===2?c=new R(n,n.nextSibling,this,t):p.type===1?c=new p.ctor(n,p.name,p.strings,this,t):p.type===6&&(c=new Yt(n,this,t)),this.v.push(c),p=r[++a]}d!==(p==null?void 0:p.index)&&(n=U.nextNode(),d++)}return s}m(t){let e=0;for(const i of this.v)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class R{constructor(t,e,i,r){var s;this.type=2,this._$AH=f,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=r,this._$Cg=(s=r==null?void 0:r.isConnected)===null||s===void 0||s}get _$AU(){var t,e;return(e=(t=this._$AM)===null||t===void 0?void 0:t._$AU)!==null&&e!==void 0?e:this._$Cg}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&t.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=k(this,t,e),N(t)?t===f||t==null||t===""?(this._$AH!==f&&this._$AR(),this._$AH=f):t!==this._$AH&&t!==T&&this.$(t):t._$litType$!==void 0?this.T(t):t.nodeType!==void 0?this.k(t):Dt(t)?this.S(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}k(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==f&&N(this._$AH)?this._$AA.nextSibling.data=t:this.k(P.createTextNode(t)),this._$AH=t}T(t){var e;const{values:i,_$litType$:r}=t,s=typeof r=="number"?this._$AC(t):(r.el===void 0&&(r.el=H.createElement(r.h,this.options)),r);if(((e=this._$AH)===null||e===void 0?void 0:e._$AD)===s)this._$AH.m(i);else{const n=new Wt(s,this),d=n.p(this.options);n.m(i),this.k(d),this._$AH=n}}_$AC(t){let e=At.get(t.strings);return e===void 0&&At.set(t.strings,e=new H(t)),e}S(t){gt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,r=0;for(const s of t)r===e.length?e.push(i=new R(this.A(M()),this.A(M()),this,this.options)):i=e[r],i._$AI(s),r++;r<e.length&&(this._$AR(i&&i._$AB.nextSibling,r),e.length=r)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)===null||i===void 0||i.call(this,!1,!0,e);t&&t!==this._$AB;){const r=t.nextSibling;t.remove(),t=r}}setConnected(t){var e;this._$AM===void 0&&(this._$Cg=t,(e=this._$AP)===null||e===void 0||e.call(this,t))}}class D{constructor(t,e,i,r,s){this.type=1,this._$AH=f,this._$AN=void 0,this.element=t,this.name=e,this._$AM=r,this.options=s,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=f}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,r){const s=this.strings;let n=!1;if(s===void 0)t=k(this,t,e,0),n=!N(t)||t!==this._$AH&&t!==T,n&&(this._$AH=t);else{const d=t;let a,p;for(t=s[0],a=0;a<s.length-1;a++)p=k(this,d[i+a],e,a),p===T&&(p=this._$AH[a]),n||(n=!N(p)||p!==this._$AH[a]),p===f?t=f:t!==f&&(t+=(p!=null?p:"")+s[a+1]),this._$AH[a]=p}n&&!r&&this.C(t)}C(t){t===f?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t!=null?t:"")}}class Vt extends D{constructor(){super(...arguments),this.type=3}C(t){this.element[this.name]=t===f?void 0:t}}const qt=x?x.emptyScript:"";class Zt extends D{constructor(){super(...arguments),this.type=4}C(t){t&&t!==f?this.element.setAttribute(this.name,qt):this.element.removeAttribute(this.name)}}class Jt extends D{constructor(t,e,i,r,s){super(t,e,i,r,s),this.type=5}_$AI(t,e=this){var i;if((t=(i=k(this,t,e,0))!==null&&i!==void 0?i:f)===T)return;const r=this._$AH,s=t===f&&r!==f||t.capture!==r.capture||t.once!==r.once||t.passive!==r.passive,n=t!==f&&(r===f||s);s&&this.element.removeEventListener(this.name,this,r),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;typeof this._$AH=="function"?this._$AH.call((i=(e=this.options)===null||e===void 0?void 0:e.host)!==null&&i!==void 0?i:this.element,t):this._$AH.handleEvent(t)}}class Yt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){k(this,t)}}const bt=window.litHtmlPolyfillSupport;bt==null||bt(H,R),((K=globalThis.litHtmlVersions)!==null&&K!==void 0?K:globalThis.litHtmlVersions=[]).push("2.2.0");/**
|
|
30
30
|
* @license
|
|
31
31
|
* Copyright 2017 Google LLC
|
|
32
32
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
@@ -36,14 +36,14 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
36
36
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
37
|
*/function F(o,t,e){return o?t():e==null?void 0:e()}var te=Ot`
|
|
38
38
|
:host {
|
|
39
|
-
--shipaid-primary:
|
|
40
|
-
--shipaid-secondary:
|
|
39
|
+
--shipaid-primary: inherit;
|
|
40
|
+
--shipaid-secondary: inherit;
|
|
41
41
|
--shipaid-danger: #f44336;
|
|
42
42
|
--shipaid-text: #000000;
|
|
43
43
|
--shipaid-text-muted: #cccccc;
|
|
44
44
|
--shipaid-text-grey: #aaaaaa;
|
|
45
45
|
--shipaid-light-grey: #ebecf0;
|
|
46
|
-
--shipaid-font:
|
|
46
|
+
--shipaid-font: inherit;
|
|
47
47
|
--shipaid-font-sm: 14px;
|
|
48
48
|
--shipaid-font-base: 16px;
|
|
49
49
|
--shipaid-font-lg: 18px;
|
|
@@ -271,7 +271,7 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
271
271
|
color: var(--shipaid-text-grey);
|
|
272
272
|
font-weight: var(--shipaid-font-heavy);
|
|
273
273
|
}
|
|
274
|
-
`,z=(o=>(o.LOADED="shipaid-loaded",o.STATUS_UPDATE="shipaid-protection-status",o))(z||{}),ee=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,v=(o,t,e,i)=>{for(var r=i>1?void 0:i?ie(t,e):t,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&ee(t,e,r),r};const St=async(o,t)=>{try{const e=await fetch(o,t);if(!e.ok)throw new Error(await e.text());return await e.json()}catch(e){throw console.error(e)
|
|
274
|
+
`,z=(o=>(o.LOADED="shipaid-loaded",o.STATUS_UPDATE="shipaid-protection-status",o))(z||{}),ee=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,v=(o,t,e,i)=>{for(var r=i>1?void 0:i?ie(t,e):t,s=o.length-1,n;s>=0;s--)(n=o[s])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&ee(t,e,r),r};const $={warn:o=>console.warn(`[ShipAid] ${o}`),error:o=>console.error(`[ShipAid] ${o}`),throw:o=>new Error(`[ShipAid] ${o}`)},St=async(o,t)=>{try{const e=await fetch(o,t);if(!e.ok)throw new Error(await e.text());return await e.json()}catch(e){throw console.error(e),$.throw("Failed to complete fetch request.")}},oe=2500,tt="shipaid-protection";let m=class extends O{constructor(){super(...arguments);var o;this.disablePolling=!1,this.pollingInterval=oe,this._apiEndpoint="/apps/shipaid",this._storeDomain=(o=window.Shopify)==null?void 0:o.shop,this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>St(t),post:(t,e)=>St(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var e;Qt(this,async()=>{var r,s,n,d;const i=document.createElement("link");i.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),i.setAttribute("rel","stylesheet"),document.head.appendChild(i);try{const a=localStorage.getItem(tt),{lastAction:p}=a?JSON.parse(a):{};p&&(this._lastAction=p)}catch{$.warn("Failed to parse local storage.")}try{const[a,p]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=a,this._cart=p}catch{this._hasFinishedSetup=!0,this._shouldShowWidget=!1;return}if(!((s=(r=this._store)==null?void 0:r.plan)!=null&&s.active)){$.warn("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,this._shouldShowWidget=!1;return}if(!((d=(n=this._store)==null?void 0:n.protectionSettings)!=null&&d.protectionType)){$.warn("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,this._shouldShowWidget=!1;return}this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(z.LOADED,this._store),setTimeout(async()=>{var c;const a=localStorage.getItem(tt),{lastAction:p}=a?JSON.parse(a):{};p!=="removed"&&!this._hasProtectionInCart&&((c=this._store)==null?void 0:c.widgetAutoOptIn)&&this._store.widgetShowCart&&await this.addProtection()},500),!this.disablePolling&&setInterval(async()=>{const a=this._cartLastUpdated;a&&new Date().getTime()-a.getTime()<this.pollingInterval||await this.updateCart()},this.pollingInterval)}),Q(this,()=>{const i={hasProtection:this._hasProtectionInCart,lastAction:this._lastAction};localStorage.setItem(tt,JSON.stringify(i))},[this._lastAction]),Q(this,async()=>{var h,l,u,_,y;if(this._cartLastUpdated=new Date,!((h=this._cart)!=null&&h.items))return;const i=await this.calculateProtectionTotal(this._cart),r=this._findProtectionVariant(i);if(this._protectionVariant=r,!(r!=null&&r.id)){this._shouldShowWidget=!1,$.error("No matching protection variant found.");return}const s=(u=(l=this._cart.items)==null?void 0:l.findIndex(Et=>{var et,it,ot,rt,st;return(st=(rt=(ot=(it=(et=this._store)==null?void 0:et.protectionSettings)==null?void 0:it.product)==null?void 0:ot.variants)==null?void 0:rt.edges)==null?void 0:st.some(({node:j})=>{var nt;return(nt=j==null?void 0:j.id)==null?void 0:nt.includes(Et.variant_id.toString())})}))!=null?u:[],n=(_=this._cart)==null?void 0:_.items[s];if(this._hasProtectionInCart=!!n,!n)return;if((y=r.id)!=null&&y.includes(n.id.toString())){this._protectionCartItem=L(b({},n),{index:s,position:s+1});return}const d={id:n.key,quantity:0};await this._fetch.post("/cart/change.js",d);const a={id:r.id.replace("gid://shopify/ProductVariant/",""),quantity:1},p=await this._fetch.post("/cart/add.js",a),c=L(b({},this._cart),{items:[p,...this._cart.items]});this._cart=c,this._dispatchEvent(z.STATUS_UPDATE,{protection:!0,cart:c,lineItem:p}),this.disablePolling||window.location.reload()},[this._store,this._cart]);const o=A`
|
|
275
275
|
<div class=${`shipaid-popup ${this._popup==="learn-more"&&"active"}`}>
|
|
276
276
|
<div class="popup">
|
|
277
277
|
<button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
|
|
@@ -291,11 +291,11 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
291
291
|
</div>
|
|
292
292
|
</div>
|
|
293
293
|
</div>
|
|
294
|
-
`,t=
|
|
294
|
+
`,t=A`
|
|
295
295
|
<div class="shipaid-prompt">
|
|
296
296
|
<div class="prompt-product">
|
|
297
297
|
<div class="prompt-product-image">
|
|
298
|
-
${F(this._hasProtectionInCart,()=>w`<svg viewBox="0 0 384 383.999986" preserveAspectRatio="xMidYMid meet"><defs><clipPath id="id1"><path d="M 22.078125 0.753906 L 361.777344 0.753906 L 361.777344 383.4375 L 22.078125 383.4375 Z M 22.078125 0.753906 " clip-rule="nonzero"/></clipPath><clipPath id="id2"><path d="M 37.261719 0 L 347.011719 0 L 347.011719 353 L 37.261719 353 Z M 37.261719 0 " clip-rule="nonzero"/></clipPath></defs><g clip-path="url(#id1)"><path fill="#0056d6" d="M 351.222656 50.539062 L 196.8125 1.5 C 193.632812 0.484375 190.222656 0.484375 187.042969 1.5 L 32.632812 50.539062 C 26.390625 52.28125 22.078125 57.988281 22.078125 64.484375 C 24.226562 117.867188 39.199219 277.527344 39.199219 277.527344 C 39.679688 283.640625 42.972656 289.175781 48.125 292.507812 L 186.605469 381.867188 C 189.839844 383.957031 194.015625 383.957031 197.253906 381.867188 L 335.730469 292.507812 C 340.882812 289.175781 344.175781 283.640625 344.65625 277.527344 C 344.65625 277.527344 359.632812 117.867188 361.777344 64.484375 C 361.777344 57.988281 357.46875 52.28125 351.222656 50.539062 " fill-opacity="1" fill-rule="nonzero"/></g><path fill="#ffffff" d="M 292.539062 118.640625 C 291.910156 117.488281 291.085938 116.351562 289.371094 115.484375 L 264.84375 101.324219 C 264.503906 101.132812 264.140625 100.984375 263.753906 100.886719 C 263.632812 100.855469 263.511719 100.855469 263.378906 100.835938 C 263.125 100.792969 262.871094 100.746094 262.617188 100.75 L 262.570312 100.746094 L 262.570312 100.757812 C 261.84375 100.773438 261.128906 100.96875 260.5 101.328125 L 205.3125 133.175781 L 205.265625 133.078125 L 200.8125 135.65625 C 195.441406 138.75 188.832031 138.75 183.460938 135.65625 L 159.335938 121.738281 C 158 120.960938 157.171875 119.53125 157.171875 117.980469 C 157.171875 116.429688 158 115 159.335938 114.222656 L 183.460938 100.3125 C 188.832031 97.214844 195.441406 97.214844 200.8125 100.3125 L 206.621094 103.664062 C 207.964844 104.4375 209.609375 104.4375 210.953125 103.664062 L 233.421875 90.703125 C 234.765625 89.929688 235.585938 88.5 235.585938 86.949219 C 235.585938 85.402344 234.765625 83.96875 233.421875 83.195312 L 200.8125 64.375 C 195.441406 61.28125 188.832031 61.28125 183.460938 64.375 L 103.578125 110.472656 C 97.796875 113.8125 97.796875 122.148438 103.578125 125.484375 L 183.460938 171.582031 C 188.832031 174.679688 195.441406 174.679688 200.8125 171.582031 L 262.570312 135.945312 L 262.570312 217.125 L 242.726562 228.609375 L 200.8125 252.867188 C 199.480469 253.628906 198.066406 254.210938 196.589844 254.609375 C 192.160156 255.785156 187.441406 255.15625 183.460938 252.867188 L 126.035156 219.734375 C 123.351562 218.1875 121.699219 215.320312 121.699219 212.226562 L 121.699219 164.90625 C 121.699219 163.359375 120.871094 161.921875 119.53125 161.160156 L 97.070312 148.183594 C 95.726562 147.410156 94.074219 147.410156 92.730469 148.183594 C 91.390625 148.957031 90.5625 150.394531 90.5625 151.945312 L 90.5625 230.195312 C 90.5625 233.292969 92.21875 236.144531 94.902344 237.703125 L 183.460938 288.808594 C 186.0625 290.308594 189.015625 291.09375 192.015625 291.117188 L 192.078125 291.117188 C 192.5 291.117188 192.921875 291.070312 193.347656 291.046875 C 193.671875 291.019531 194 291.019531 194.328125 290.984375 C 194.773438 290.925781 195.222656 290.816406 195.65625 290.730469 C 195.960938 290.660156 196.261719 290.621094 196.554688 290.550781 C 197.039062 290.429688 197.496094 290.246094 197.957031 290.078125 C 198.222656 289.980469 198.476562 289.921875 198.71875 289.824219 C 199.433594 289.535156 200.132812 289.195312 200.800781 288.808594 L 277.210938 244.71875 L 289.320312 237.851562 C 292.03125 236.3125 293.714844 233.4375 293.714844 230.316406 L 293.714844 122.980469 C 293.714844 121.433594 293.289062 119.941406 292.539062 118.640625 " fill-opacity="1" fill-rule="nonzero"/><g clip-path="url(#id2)"><path fill="#0056d6" d="M 200.59375 38.453125 C 198.015625 36.96875 195.113281 36.175781 192.136719 36.148438 C 189.171875 36.175781 186.257812 36.972656 183.679688 38.453125 L 76.964844 100.03125 C 71.613281 103.121094 68.316406 108.828125 68.3125 115.003906 L 68.3125 238.167969 C 68.3125 244.347656 71.609375 250.054688 76.964844 253.140625 L 183.679688 314.714844 C 186.292969 316.226562 189.246094 317.023438 192.257812 317.035156 C 195.269531 317.023438 198.234375 316.226562 200.847656 314.726562 L 307.09375 253.417969 C 312.441406 250.332031 315.746094 244.625 315.746094 238.445312 L 315.746094 202.859375 C 315.734375 201.308594 316.570312 199.882812 317.898438 199.109375 L 340.527344 186.0625 C 341.855469 185.285156 343.515625 185.285156 344.847656 186.0625 C 346.1875 186.835938 347.011719 188.261719 347.011719 189.808594 L 347.011719 256.089844 C 347 258.917969 346.296875 261.699219 344.96875 264.191406 C 344.628906 265.824219 342.847656 267.746094 340.332031 269.71875 C 340.285156 269.765625 340.210938 269.8125 340.152344 269.863281 C 333.761719 274.832031 323.1875 279.960938 321.3125 281.046875 L 200.847656 350.558594 C 198.148438 352.105469 195.078125 352.902344 191.96875 352.867188 L 191.835938 352.867188 L 191.835938 352.855469 C 188.964844 352.78125 186.160156 351.984375 183.679688 350.558594 L 45.914062 271.058594 C 40.558594 267.976562 37.261719 262.269531 37.261719 256.089844 L 37.261719 97.09375 C 37.261719 94.320312 37.613281 91.492188 38.832031 89.097656 C 39 88.476562 40.667969 85.421875 44.109375 82.910156 C 45.40625 82.039062 47.699219 80.863281 49.847656 79.621094 L 183.292969 2.625 C 185.980469 1.078125 189.039062 0.28125 192.136719 0.320312 C 195.246094 0.28125 198.296875 1.078125 200.984375 2.625 L 324.121094 73.667969 C 324.398438 73.839844 324.617188 74.042969 324.859375 74.238281 L 326.417969 75.132812 C 330.605469 77.351562 337.164062 80.730469 340.722656 83.429688 L 341.011719 83.648438 C 341.058594 83.6875 341.109375 83.722656 341.15625 83.753906 C 341.277344 83.859375 341.363281 83.960938 341.484375 84.070312 C 342.789062 85.164062 343.902344 86.445312 344.761719 87.878906 C 344.785156 87.898438 344.800781 87.921875 344.824219 87.945312 L 344.8125 87.949219 C 346.25 90.351562 347.011719 93.097656 347.011719 95.894531 L 347.011719 154.113281 C 347.011719 155.660156 346.191406 157.085938 344.847656 157.859375 L 322.222656 170.921875 C 320.890625 171.683594 319.230469 171.683594 317.902344 170.921875 C 316.558594 170.144531 315.734375 168.71875 315.734375 167.171875 L 315.734375 114.671875 C 315.734375 108.484375 312.433594 102.773438 307.070312 99.6875 L 200.597656 38.453125 L 200.597656 38.457031 Z M 200.59375 38.453125 " fill-opacity="1" fill-rule="nonzero"/></g></svg>`,()=>w`<svg viewBox="0 0 384 383.999986" preserveAspectRatio="xMidYMid meet"><defs><clipPath id="id1"><path d="M 22.078125 0.753906 L 361.777344 0.753906 L 361.777344 383.4375 L 22.078125 383.4375 Z M 22.078125 0.753906 " clip-rule="nonzero"/></clipPath><clipPath id="id2"><path d="M 37.261719 0 L 347.011719 0 L 347.011719 353 L 37.261719 353 Z M 37.261719 0 " clip-rule="nonzero"/></clipPath></defs><g clip-path="url(#id1)"><path fill="#e5f3f9" d="M 351.222656 50.539062 L 196.8125 1.5 C 193.632812 0.484375 190.222656 0.484375 187.042969 1.5 L 32.632812 50.539062 C 26.390625 52.28125 22.078125 57.988281 22.078125 64.484375 C 24.226562 117.867188 39.199219 277.527344 39.199219 277.527344 C 39.679688 283.640625 42.972656 289.175781 48.125 292.507812 L 186.605469 381.867188 C 189.839844 383.957031 194.015625 383.957031 197.253906 381.867188 L 335.730469 292.507812 C 340.882812 289.175781 344.175781 283.640625 344.65625 277.527344 C 344.65625 277.527344 359.632812 117.867188 361.777344 64.484375 C 361.777344 57.988281 357.46875 52.28125 351.222656 50.539062 " fill-opacity="1" fill-rule="nonzero"/></g><path fill="#ffffff" d="M 292.539062 118.640625 C 291.910156 117.488281 291.085938 116.351562 289.371094 115.484375 L 264.84375 101.324219 C 264.503906 101.132812 264.140625 100.984375 263.753906 100.886719 C 263.632812 100.855469 263.511719 100.855469 263.378906 100.835938 C 263.125 100.792969 262.871094 100.746094 262.617188 100.75 L 262.570312 100.746094 L 262.570312 100.757812 C 261.84375 100.773438 261.128906 100.96875 260.5 101.328125 L 205.3125 133.175781 L 205.265625 133.078125 L 200.8125 135.65625 C 195.441406 138.75 188.832031 138.75 183.460938 135.65625 L 159.335938 121.738281 C 158 120.960938 157.171875 119.53125 157.171875 117.980469 C 157.171875 116.429688 158 115 159.335938 114.222656 L 183.460938 100.3125 C 188.832031 97.214844 195.441406 97.214844 200.8125 100.3125 L 206.621094 103.664062 C 207.964844 104.4375 209.609375 104.4375 210.953125 103.664062 L 233.421875 90.703125 C 234.765625 89.929688 235.585938 88.5 235.585938 86.949219 C 235.585938 85.402344 234.765625 83.96875 233.421875 83.195312 L 200.8125 64.375 C 195.441406 61.28125 188.832031 61.28125 183.460938 64.375 L 103.578125 110.472656 C 97.796875 113.8125 97.796875 122.148438 103.578125 125.484375 L 183.460938 171.582031 C 188.832031 174.679688 195.441406 174.679688 200.8125 171.582031 L 262.570312 135.945312 L 262.570312 217.125 L 242.726562 228.609375 L 200.8125 252.867188 C 199.480469 253.628906 198.066406 254.210938 196.589844 254.609375 C 192.160156 255.785156 187.441406 255.15625 183.460938 252.867188 L 126.035156 219.734375 C 123.351562 218.1875 121.699219 215.320312 121.699219 212.226562 L 121.699219 164.90625 C 121.699219 163.359375 120.871094 161.921875 119.53125 161.160156 L 97.070312 148.183594 C 95.726562 147.410156 94.074219 147.410156 92.730469 148.183594 C 91.390625 148.957031 90.5625 150.394531 90.5625 151.945312 L 90.5625 230.195312 C 90.5625 233.292969 92.21875 236.144531 94.902344 237.703125 L 183.460938 288.808594 C 186.0625 290.308594 189.015625 291.09375 192.015625 291.117188 L 192.078125 291.117188 C 192.5 291.117188 192.921875 291.070312 193.347656 291.046875 C 193.671875 291.019531 194 291.019531 194.328125 290.984375 C 194.773438 290.925781 195.222656 290.816406 195.65625 290.730469 C 195.960938 290.660156 196.261719 290.621094 196.554688 290.550781 C 197.039062 290.429688 197.496094 290.246094 197.957031 290.078125 C 198.222656 289.980469 198.476562 289.921875 198.71875 289.824219 C 199.433594 289.535156 200.132812 289.195312 200.800781 288.808594 L 277.210938 244.71875 L 289.320312 237.851562 C 292.03125 236.3125 293.714844 233.4375 293.714844 230.316406 L 293.714844 122.980469 C 293.714844 121.433594 293.289062 119.941406 292.539062 118.640625 " fill-opacity="1" fill-rule="nonzero"/><g clip-path="url(#id2)"><path fill="#e5f3f9" d="M 200.59375 38.453125 C 198.015625 36.96875 195.113281 36.175781 192.136719 36.148438 C 189.171875 36.175781 186.257812 36.972656 183.679688 38.453125 L 76.964844 100.03125 C 71.613281 103.121094 68.316406 108.828125 68.3125 115.003906 L 68.3125 238.167969 C 68.3125 244.347656 71.609375 250.054688 76.964844 253.140625 L 183.679688 314.714844 C 186.292969 316.226562 189.246094 317.023438 192.257812 317.035156 C 195.269531 317.023438 198.234375 316.226562 200.847656 314.726562 L 307.09375 253.417969 C 312.441406 250.332031 315.746094 244.625 315.746094 238.445312 L 315.746094 202.859375 C 315.734375 201.308594 316.570312 199.882812 317.898438 199.109375 L 340.527344 186.0625 C 341.855469 185.285156 343.515625 185.285156 344.847656 186.0625 C 346.1875 186.835938 347.011719 188.261719 347.011719 189.808594 L 347.011719 256.089844 C 347 258.917969 346.296875 261.699219 344.96875 264.191406 C 344.628906 265.824219 342.847656 267.746094 340.332031 269.71875 C 340.285156 269.765625 340.210938 269.8125 340.152344 269.863281 C 333.761719 274.832031 323.1875 279.960938 321.3125 281.046875 L 200.847656 350.558594 C 198.148438 352.105469 195.078125 352.902344 191.96875 352.867188 L 191.835938 352.867188 L 191.835938 352.855469 C 188.964844 352.78125 186.160156 351.984375 183.679688 350.558594 L 45.914062 271.058594 C 40.558594 267.976562 37.261719 262.269531 37.261719 256.089844 L 37.261719 97.09375 C 37.261719 94.320312 37.613281 91.492188 38.832031 89.097656 C 39 88.476562 40.667969 85.421875 44.109375 82.910156 C 45.40625 82.039062 47.699219 80.863281 49.847656 79.621094 L 183.292969 2.625 C 185.980469 1.078125 189.039062 0.28125 192.136719 0.320312 C 195.246094 0.28125 198.296875 1.078125 200.984375 2.625 L 324.121094 73.667969 C 324.398438 73.839844 324.617188 74.042969 324.859375 74.238281 L 326.417969 75.132812 C 330.605469 77.351562 337.164062 80.730469 340.722656 83.429688 L 341.011719 83.648438 C 341.058594 83.6875 341.109375 83.722656 341.15625 83.753906 C 341.277344 83.859375 341.363281 83.960938 341.484375 84.070312 C 342.789062 85.164062 343.902344 86.445312 344.761719 87.878906 C 344.785156 87.898438 344.800781 87.921875 344.824219 87.945312 L 344.8125 87.949219 C 346.25 90.351562 347.011719 93.097656 347.011719 95.894531 L 347.011719 154.113281 C 347.011719 155.660156 346.191406 157.085938 344.847656 157.859375 L 322.222656 170.921875 C 320.890625 171.683594 319.230469 171.683594 317.902344 170.921875 C 316.558594 170.144531 315.734375 168.71875 315.734375 167.171875 L 315.734375 114.671875 C 315.734375 108.484375 312.433594 102.773438 307.070312 99.6875 L 200.597656 38.453125 L 200.597656 38.457031 Z M 200.59375 38.453125 " fill-opacity="1" fill-rule="nonzero"/></g></svg>`)}
|
|
298
|
+
${F(this._hasProtectionInCart,()=>A`<svg viewBox="0 0 384 383.999986" preserveAspectRatio="xMidYMid meet"><defs><clipPath id="id1"><path d="M 22.078125 0.753906 L 361.777344 0.753906 L 361.777344 383.4375 L 22.078125 383.4375 Z M 22.078125 0.753906 " clip-rule="nonzero"/></clipPath><clipPath id="id2"><path d="M 37.261719 0 L 347.011719 0 L 347.011719 353 L 37.261719 353 Z M 37.261719 0 " clip-rule="nonzero"/></clipPath></defs><g clip-path="url(#id1)"><path fill="#0056d6" d="M 351.222656 50.539062 L 196.8125 1.5 C 193.632812 0.484375 190.222656 0.484375 187.042969 1.5 L 32.632812 50.539062 C 26.390625 52.28125 22.078125 57.988281 22.078125 64.484375 C 24.226562 117.867188 39.199219 277.527344 39.199219 277.527344 C 39.679688 283.640625 42.972656 289.175781 48.125 292.507812 L 186.605469 381.867188 C 189.839844 383.957031 194.015625 383.957031 197.253906 381.867188 L 335.730469 292.507812 C 340.882812 289.175781 344.175781 283.640625 344.65625 277.527344 C 344.65625 277.527344 359.632812 117.867188 361.777344 64.484375 C 361.777344 57.988281 357.46875 52.28125 351.222656 50.539062 " fill-opacity="1" fill-rule="nonzero"/></g><path fill="#ffffff" d="M 292.539062 118.640625 C 291.910156 117.488281 291.085938 116.351562 289.371094 115.484375 L 264.84375 101.324219 C 264.503906 101.132812 264.140625 100.984375 263.753906 100.886719 C 263.632812 100.855469 263.511719 100.855469 263.378906 100.835938 C 263.125 100.792969 262.871094 100.746094 262.617188 100.75 L 262.570312 100.746094 L 262.570312 100.757812 C 261.84375 100.773438 261.128906 100.96875 260.5 101.328125 L 205.3125 133.175781 L 205.265625 133.078125 L 200.8125 135.65625 C 195.441406 138.75 188.832031 138.75 183.460938 135.65625 L 159.335938 121.738281 C 158 120.960938 157.171875 119.53125 157.171875 117.980469 C 157.171875 116.429688 158 115 159.335938 114.222656 L 183.460938 100.3125 C 188.832031 97.214844 195.441406 97.214844 200.8125 100.3125 L 206.621094 103.664062 C 207.964844 104.4375 209.609375 104.4375 210.953125 103.664062 L 233.421875 90.703125 C 234.765625 89.929688 235.585938 88.5 235.585938 86.949219 C 235.585938 85.402344 234.765625 83.96875 233.421875 83.195312 L 200.8125 64.375 C 195.441406 61.28125 188.832031 61.28125 183.460938 64.375 L 103.578125 110.472656 C 97.796875 113.8125 97.796875 122.148438 103.578125 125.484375 L 183.460938 171.582031 C 188.832031 174.679688 195.441406 174.679688 200.8125 171.582031 L 262.570312 135.945312 L 262.570312 217.125 L 242.726562 228.609375 L 200.8125 252.867188 C 199.480469 253.628906 198.066406 254.210938 196.589844 254.609375 C 192.160156 255.785156 187.441406 255.15625 183.460938 252.867188 L 126.035156 219.734375 C 123.351562 218.1875 121.699219 215.320312 121.699219 212.226562 L 121.699219 164.90625 C 121.699219 163.359375 120.871094 161.921875 119.53125 161.160156 L 97.070312 148.183594 C 95.726562 147.410156 94.074219 147.410156 92.730469 148.183594 C 91.390625 148.957031 90.5625 150.394531 90.5625 151.945312 L 90.5625 230.195312 C 90.5625 233.292969 92.21875 236.144531 94.902344 237.703125 L 183.460938 288.808594 C 186.0625 290.308594 189.015625 291.09375 192.015625 291.117188 L 192.078125 291.117188 C 192.5 291.117188 192.921875 291.070312 193.347656 291.046875 C 193.671875 291.019531 194 291.019531 194.328125 290.984375 C 194.773438 290.925781 195.222656 290.816406 195.65625 290.730469 C 195.960938 290.660156 196.261719 290.621094 196.554688 290.550781 C 197.039062 290.429688 197.496094 290.246094 197.957031 290.078125 C 198.222656 289.980469 198.476562 289.921875 198.71875 289.824219 C 199.433594 289.535156 200.132812 289.195312 200.800781 288.808594 L 277.210938 244.71875 L 289.320312 237.851562 C 292.03125 236.3125 293.714844 233.4375 293.714844 230.316406 L 293.714844 122.980469 C 293.714844 121.433594 293.289062 119.941406 292.539062 118.640625 " fill-opacity="1" fill-rule="nonzero"/><g clip-path="url(#id2)"><path fill="#0056d6" d="M 200.59375 38.453125 C 198.015625 36.96875 195.113281 36.175781 192.136719 36.148438 C 189.171875 36.175781 186.257812 36.972656 183.679688 38.453125 L 76.964844 100.03125 C 71.613281 103.121094 68.316406 108.828125 68.3125 115.003906 L 68.3125 238.167969 C 68.3125 244.347656 71.609375 250.054688 76.964844 253.140625 L 183.679688 314.714844 C 186.292969 316.226562 189.246094 317.023438 192.257812 317.035156 C 195.269531 317.023438 198.234375 316.226562 200.847656 314.726562 L 307.09375 253.417969 C 312.441406 250.332031 315.746094 244.625 315.746094 238.445312 L 315.746094 202.859375 C 315.734375 201.308594 316.570312 199.882812 317.898438 199.109375 L 340.527344 186.0625 C 341.855469 185.285156 343.515625 185.285156 344.847656 186.0625 C 346.1875 186.835938 347.011719 188.261719 347.011719 189.808594 L 347.011719 256.089844 C 347 258.917969 346.296875 261.699219 344.96875 264.191406 C 344.628906 265.824219 342.847656 267.746094 340.332031 269.71875 C 340.285156 269.765625 340.210938 269.8125 340.152344 269.863281 C 333.761719 274.832031 323.1875 279.960938 321.3125 281.046875 L 200.847656 350.558594 C 198.148438 352.105469 195.078125 352.902344 191.96875 352.867188 L 191.835938 352.867188 L 191.835938 352.855469 C 188.964844 352.78125 186.160156 351.984375 183.679688 350.558594 L 45.914062 271.058594 C 40.558594 267.976562 37.261719 262.269531 37.261719 256.089844 L 37.261719 97.09375 C 37.261719 94.320312 37.613281 91.492188 38.832031 89.097656 C 39 88.476562 40.667969 85.421875 44.109375 82.910156 C 45.40625 82.039062 47.699219 80.863281 49.847656 79.621094 L 183.292969 2.625 C 185.980469 1.078125 189.039062 0.28125 192.136719 0.320312 C 195.246094 0.28125 198.296875 1.078125 200.984375 2.625 L 324.121094 73.667969 C 324.398438 73.839844 324.617188 74.042969 324.859375 74.238281 L 326.417969 75.132812 C 330.605469 77.351562 337.164062 80.730469 340.722656 83.429688 L 341.011719 83.648438 C 341.058594 83.6875 341.109375 83.722656 341.15625 83.753906 C 341.277344 83.859375 341.363281 83.960938 341.484375 84.070312 C 342.789062 85.164062 343.902344 86.445312 344.761719 87.878906 C 344.785156 87.898438 344.800781 87.921875 344.824219 87.945312 L 344.8125 87.949219 C 346.25 90.351562 347.011719 93.097656 347.011719 95.894531 L 347.011719 154.113281 C 347.011719 155.660156 346.191406 157.085938 344.847656 157.859375 L 322.222656 170.921875 C 320.890625 171.683594 319.230469 171.683594 317.902344 170.921875 C 316.558594 170.144531 315.734375 168.71875 315.734375 167.171875 L 315.734375 114.671875 C 315.734375 108.484375 312.433594 102.773438 307.070312 99.6875 L 200.597656 38.453125 L 200.597656 38.457031 Z M 200.59375 38.453125 " fill-opacity="1" fill-rule="nonzero"/></g></svg>`,()=>A`<svg viewBox="0 0 384 383.999986" preserveAspectRatio="xMidYMid meet"><defs><clipPath id="id1"><path d="M 22.078125 0.753906 L 361.777344 0.753906 L 361.777344 383.4375 L 22.078125 383.4375 Z M 22.078125 0.753906 " clip-rule="nonzero"/></clipPath><clipPath id="id2"><path d="M 37.261719 0 L 347.011719 0 L 347.011719 353 L 37.261719 353 Z M 37.261719 0 " clip-rule="nonzero"/></clipPath></defs><g clip-path="url(#id1)"><path fill="#e5f3f9" d="M 351.222656 50.539062 L 196.8125 1.5 C 193.632812 0.484375 190.222656 0.484375 187.042969 1.5 L 32.632812 50.539062 C 26.390625 52.28125 22.078125 57.988281 22.078125 64.484375 C 24.226562 117.867188 39.199219 277.527344 39.199219 277.527344 C 39.679688 283.640625 42.972656 289.175781 48.125 292.507812 L 186.605469 381.867188 C 189.839844 383.957031 194.015625 383.957031 197.253906 381.867188 L 335.730469 292.507812 C 340.882812 289.175781 344.175781 283.640625 344.65625 277.527344 C 344.65625 277.527344 359.632812 117.867188 361.777344 64.484375 C 361.777344 57.988281 357.46875 52.28125 351.222656 50.539062 " fill-opacity="1" fill-rule="nonzero"/></g><path fill="#ffffff" d="M 292.539062 118.640625 C 291.910156 117.488281 291.085938 116.351562 289.371094 115.484375 L 264.84375 101.324219 C 264.503906 101.132812 264.140625 100.984375 263.753906 100.886719 C 263.632812 100.855469 263.511719 100.855469 263.378906 100.835938 C 263.125 100.792969 262.871094 100.746094 262.617188 100.75 L 262.570312 100.746094 L 262.570312 100.757812 C 261.84375 100.773438 261.128906 100.96875 260.5 101.328125 L 205.3125 133.175781 L 205.265625 133.078125 L 200.8125 135.65625 C 195.441406 138.75 188.832031 138.75 183.460938 135.65625 L 159.335938 121.738281 C 158 120.960938 157.171875 119.53125 157.171875 117.980469 C 157.171875 116.429688 158 115 159.335938 114.222656 L 183.460938 100.3125 C 188.832031 97.214844 195.441406 97.214844 200.8125 100.3125 L 206.621094 103.664062 C 207.964844 104.4375 209.609375 104.4375 210.953125 103.664062 L 233.421875 90.703125 C 234.765625 89.929688 235.585938 88.5 235.585938 86.949219 C 235.585938 85.402344 234.765625 83.96875 233.421875 83.195312 L 200.8125 64.375 C 195.441406 61.28125 188.832031 61.28125 183.460938 64.375 L 103.578125 110.472656 C 97.796875 113.8125 97.796875 122.148438 103.578125 125.484375 L 183.460938 171.582031 C 188.832031 174.679688 195.441406 174.679688 200.8125 171.582031 L 262.570312 135.945312 L 262.570312 217.125 L 242.726562 228.609375 L 200.8125 252.867188 C 199.480469 253.628906 198.066406 254.210938 196.589844 254.609375 C 192.160156 255.785156 187.441406 255.15625 183.460938 252.867188 L 126.035156 219.734375 C 123.351562 218.1875 121.699219 215.320312 121.699219 212.226562 L 121.699219 164.90625 C 121.699219 163.359375 120.871094 161.921875 119.53125 161.160156 L 97.070312 148.183594 C 95.726562 147.410156 94.074219 147.410156 92.730469 148.183594 C 91.390625 148.957031 90.5625 150.394531 90.5625 151.945312 L 90.5625 230.195312 C 90.5625 233.292969 92.21875 236.144531 94.902344 237.703125 L 183.460938 288.808594 C 186.0625 290.308594 189.015625 291.09375 192.015625 291.117188 L 192.078125 291.117188 C 192.5 291.117188 192.921875 291.070312 193.347656 291.046875 C 193.671875 291.019531 194 291.019531 194.328125 290.984375 C 194.773438 290.925781 195.222656 290.816406 195.65625 290.730469 C 195.960938 290.660156 196.261719 290.621094 196.554688 290.550781 C 197.039062 290.429688 197.496094 290.246094 197.957031 290.078125 C 198.222656 289.980469 198.476562 289.921875 198.71875 289.824219 C 199.433594 289.535156 200.132812 289.195312 200.800781 288.808594 L 277.210938 244.71875 L 289.320312 237.851562 C 292.03125 236.3125 293.714844 233.4375 293.714844 230.316406 L 293.714844 122.980469 C 293.714844 121.433594 293.289062 119.941406 292.539062 118.640625 " fill-opacity="1" fill-rule="nonzero"/><g clip-path="url(#id2)"><path fill="#e5f3f9" d="M 200.59375 38.453125 C 198.015625 36.96875 195.113281 36.175781 192.136719 36.148438 C 189.171875 36.175781 186.257812 36.972656 183.679688 38.453125 L 76.964844 100.03125 C 71.613281 103.121094 68.316406 108.828125 68.3125 115.003906 L 68.3125 238.167969 C 68.3125 244.347656 71.609375 250.054688 76.964844 253.140625 L 183.679688 314.714844 C 186.292969 316.226562 189.246094 317.023438 192.257812 317.035156 C 195.269531 317.023438 198.234375 316.226562 200.847656 314.726562 L 307.09375 253.417969 C 312.441406 250.332031 315.746094 244.625 315.746094 238.445312 L 315.746094 202.859375 C 315.734375 201.308594 316.570312 199.882812 317.898438 199.109375 L 340.527344 186.0625 C 341.855469 185.285156 343.515625 185.285156 344.847656 186.0625 C 346.1875 186.835938 347.011719 188.261719 347.011719 189.808594 L 347.011719 256.089844 C 347 258.917969 346.296875 261.699219 344.96875 264.191406 C 344.628906 265.824219 342.847656 267.746094 340.332031 269.71875 C 340.285156 269.765625 340.210938 269.8125 340.152344 269.863281 C 333.761719 274.832031 323.1875 279.960938 321.3125 281.046875 L 200.847656 350.558594 C 198.148438 352.105469 195.078125 352.902344 191.96875 352.867188 L 191.835938 352.867188 L 191.835938 352.855469 C 188.964844 352.78125 186.160156 351.984375 183.679688 350.558594 L 45.914062 271.058594 C 40.558594 267.976562 37.261719 262.269531 37.261719 256.089844 L 37.261719 97.09375 C 37.261719 94.320312 37.613281 91.492188 38.832031 89.097656 C 39 88.476562 40.667969 85.421875 44.109375 82.910156 C 45.40625 82.039062 47.699219 80.863281 49.847656 79.621094 L 183.292969 2.625 C 185.980469 1.078125 189.039062 0.28125 192.136719 0.320312 C 195.246094 0.28125 198.296875 1.078125 200.984375 2.625 L 324.121094 73.667969 C 324.398438 73.839844 324.617188 74.042969 324.859375 74.238281 L 326.417969 75.132812 C 330.605469 77.351562 337.164062 80.730469 340.722656 83.429688 L 341.011719 83.648438 C 341.058594 83.6875 341.109375 83.722656 341.15625 83.753906 C 341.277344 83.859375 341.363281 83.960938 341.484375 84.070312 C 342.789062 85.164062 343.902344 86.445312 344.761719 87.878906 C 344.785156 87.898438 344.800781 87.921875 344.824219 87.945312 L 344.8125 87.949219 C 346.25 90.351562 347.011719 93.097656 347.011719 95.894531 L 347.011719 154.113281 C 347.011719 155.660156 346.191406 157.085938 344.847656 157.859375 L 322.222656 170.921875 C 320.890625 171.683594 319.230469 171.683594 317.902344 170.921875 C 316.558594 170.144531 315.734375 168.71875 315.734375 167.171875 L 315.734375 114.671875 C 315.734375 108.484375 312.433594 102.773438 307.070312 99.6875 L 200.597656 38.453125 L 200.597656 38.457031 Z M 200.59375 38.453125 " fill-opacity="1" fill-rule="nonzero"/></g></svg>`)}
|
|
299
299
|
</div>
|
|
300
300
|
<div class="prompt-product-details">
|
|
301
301
|
<p class="prompt-product-details-title">Instant Package Protection</p>
|
|
@@ -308,7 +308,7 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
308
308
|
</button>
|
|
309
309
|
</div>
|
|
310
310
|
</div>
|
|
311
|
-
${F(this._state.error,()=>
|
|
311
|
+
${F(this._state.error,()=>A`<p class="error">${this._state.error}</p>`)}
|
|
312
312
|
<div class="prompt-footer">
|
|
313
313
|
<button class="prompt-footer-about" @click=${()=>{this._popup="learn-more"}}>Learn More</button>
|
|
314
314
|
<a class="prompt-footer-badge" href="/">
|
|
@@ -318,8 +318,8 @@ var xt=Object.defineProperty,Pt=Object.defineProperties;var Tt=Object.getOwnProp
|
|
|
318
318
|
</a>
|
|
319
319
|
</div>
|
|
320
320
|
</div>
|
|
321
|
-
`;return
|
|
321
|
+
`;return A`
|
|
322
322
|
<div class="shipaid">
|
|
323
|
-
${F(this._hasFinishedSetup,()=>{var i,r;return F(this._shouldShowWidget&&((r=(i=this._store)==null?void 0:i.plan)==null?void 0:r.active)&&this._store.widgetShowCart,()=>[o,t],()=>
|
|
323
|
+
${F(this._hasFinishedSetup,()=>{var i,r;return F(this._shouldShowWidget&&((r=(i=this._store)==null?void 0:i.plan)==null?void 0:r.active)&&this._store.widgetShowCart,()=>[o,t],()=>A``)},()=>A`<p><slot>Loading ShipAid Widget...</slot></p>`)}
|
|
324
324
|
</div>
|
|
325
|
-
`}_currencyFormat(o){var t,e,i,r,s;return new Intl.NumberFormat((e=(t=window.Shopify)==null?void 0:t.locale)!=null?e:void 0,{currency:((i=this._store)==null?void 0:i.currency)||((s=(r=window.Shopify)==null?void 0:r.currency)==null?void 0:s.active)||"USD",style:"currency"}).format(Number(o))}_dispatchEvent(o,t={}){this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:t}))}async calculateProtectionTotal(o){var s,n,d,a,p;if(o||(o=await this._fetchCart()),!o)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const t=(s=this._store)==null?void 0:s.protectionSettings;if(!t||!t.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const e=((n=this._store)==null?void 0:n.excludedProductSkus)&&o.items?o.items.reduce((c,
|
|
325
|
+
`}_currencyFormat(o){var t,e,i,r,s;return new Intl.NumberFormat((e=(t=window.Shopify)==null?void 0:t.locale)!=null?e:void 0,{currency:((i=this._store)==null?void 0:i.currency)||((s=(r=window.Shopify)==null?void 0:r.currency)==null?void 0:s.active)||"USD",style:"currency"}).format(Number(o))}_dispatchEvent(o,t={}){this.dispatchEvent(new CustomEvent(o,{bubbles:!0,composed:!0,detail:t}))}async calculateProtectionTotal(o){var s,n,d,a,p;if(o||(o=await this._fetchCart()),!o)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const t=(s=this._store)==null?void 0:s.protectionSettings;if(!t||!t.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const e=((n=this._store)==null?void 0:n.excludedProductSkus)&&o.items?o.items.reduce((c,h)=>h.sku&&this._store.excludedProductSkus.find(l=>l===h.sku)?c-h.final_price:c,o.total_price):o.total_price,i=((a=(d=o.items)==null?void 0:d.filter(c=>{var h,l,u;return(u=(l=(h=t.product)==null?void 0:h.variants)==null?void 0:l.edges)==null?void 0:u.some(({node:_})=>{var y;return(y=_==null?void 0:_.id)==null?void 0:y.includes(c.variant_id.toString())})}))!=null?a:[]).reduce((c,h)=>c+=h.final_line_price,0),r=e-i;if(t.protectionType==="FIXED"){if(!t.defaultFee)throw new Error("Missing default fee amount.");if(!((p=t.rules)!=null&&p.length))return t.defaultFee;const c=r/100,h=t.rules.sort((l,u)=>!l.rangeLower||!u.rangeLower?0:l.rangeLower-u.rangeLower).find(l=>{const u=Boolean(l.rangeLower&&l.rangeLower<c);return l.rangeUpper?u&&l.rangeUpper>=c:u});return typeof(h==null?void 0:h.fee)=="number"?h.fee:t.defaultFee}if(t.protectionType==="PERCENTAGE"){const c=r*t.percentage/100;return c>=t.minimumFee?c:t.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(o){var e,i,r;const t=(e=this._store)==null?void 0:e.protectionSettings;if(!t||!((r=(i=t.product)==null?void 0:i.variants)!=null&&r.edges))throw new Error("Missing product and variants from protection settings.");return t.product.variants.edges.flatMap(({node:s})=>{if(!s||!s.price)return[];const n=Number(s.price);return[L(b({},s),{formattedPrice:n})]}).sort((s,n)=>s.formattedPrice-n.formattedPrice).find(s=>s.formattedPrice>=o)}_setState(o,t){this._state={loading:o==="loading",success:o==="success",error:o==="error"?t||!0:!1}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const o=new URL(window.location.href);o.pathname=this._apiEndpoint;const t=await this._fetch.get(o.toString());if(!t)throw new Error(`Failed to fetch store data for ${o.toString()}`);const[e]=t.stores;if(!e)throw new Error(`Could not find a store for this URL ${o.toString()}.`);return e}catch(o){throw console.error(o),$.throw(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(o){const t=o;throw $.error(t.message),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(o){o||(o=await this._fetchCart()),this._cart=o}async addProtection(){var o,t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!((o=this._cart)!=null&&o.items))throw new Error("Cart has not been loaded.");if(!((t=this._protectionVariant)!=null&&t.id))throw new Error("No protection variant found.");this._setState("loading");const i={id:this._protectionVariant.id.replace("gid://shopify/ProductVariant/",""),quantity:1},r=await this._fetch.post("/cart/add.js",i),s=L(b({},this._cart),{items:[r,...this._cart.items]});if(this._lastAction="added",this._dispatchEvent(z.STATUS_UPDATE,{protection:!0,cart:s,lineItem:r}),((e=window.Shopify)==null?void 0:e.Checkout)||!this.disablePolling)return window.location.reload();this._cart=s,this._setState("success")}catch(i){const r=i;$.error(r.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var o;try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const t={id:this._protectionCartItem.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);if(this._lastAction="removed",this._dispatchEvent(z.STATUS_UPDATE,{protection:!1,cart:e,lineItem:this._protectionCartItem}),((o=window.Shopify)==null?void 0:o.Checkout)||!this.disablePolling)return window.location.reload();this._cart=e,this._setState("success")}catch(t){const e=t;$.error(e.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}};m.styles=te,v([B({type:Boolean,attribute:!0})],m.prototype,"disablePolling",2),v([B({type:Number,attribute:!0})],m.prototype,"pollingInterval",2),v([g()],m.prototype,"_storeDomain",2),v([g()],m.prototype,"_store",2),v([g()],m.prototype,"_cart",2),v([g()],m.prototype,"_cartLastUpdated",2),v([g()],m.prototype,"_hasFinishedSetup",2),v([g()],m.prototype,"_shouldShowWidget",2),v([g()],m.prototype,"_hasProtectionInCart",2),v([g()],m.prototype,"_lastAction",2),v([g()],m.prototype,"_protectionCartItem",2),v([g()],m.prototype,"_protectionVariant",2),v([g()],m.prototype,"_state",2),v([g()],m.prototype,"_popup",2),m=v([Mt("shipaid-widget")],m);export{m as ShipAidWidget};
|
|
@@ -49,14 +49,14 @@ var at,pt;null==nt||nt(K,Q),(null!==(E=globalThis.litHtmlVersions)&&void 0!==E?E
|
|
|
49
49
|
*/
|
|
50
50
|
function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1]),t[0]);return new g(i,v)})`
|
|
51
51
|
:host {
|
|
52
|
-
--shipaid-primary:
|
|
53
|
-
--shipaid-secondary:
|
|
52
|
+
--shipaid-primary: inherit;
|
|
53
|
+
--shipaid-secondary: inherit;
|
|
54
54
|
--shipaid-danger: #f44336;
|
|
55
55
|
--shipaid-text: #000000;
|
|
56
56
|
--shipaid-text-muted: #cccccc;
|
|
57
57
|
--shipaid-text-grey: #aaaaaa;
|
|
58
58
|
--shipaid-light-grey: #ebecf0;
|
|
59
|
-
--shipaid-font:
|
|
59
|
+
--shipaid-font: inherit;
|
|
60
60
|
--shipaid-font-sm: 14px;
|
|
61
61
|
--shipaid-font-base: 16px;
|
|
62
62
|
--shipaid-font-lg: 18px;
|
|
@@ -284,7 +284,7 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
|
|
|
284
284
|
color: var(--shipaid-text-grey);
|
|
285
285
|
font-weight: var(--shipaid-font-heavy);
|
|
286
286
|
}
|
|
287
|
-
`,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&>(e,i,s),s};const Ct=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i)
|
|
287
|
+
`,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&>(e,i,s),s};const Ct=t=>console.warn(`[ShipAid] ${t}`),wt=t=>console.error(`[ShipAid] ${t}`),$t=t=>new Error(`[ShipAid] ${t}`),At=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),$t("Failed to complete fetch request.")}},St="shipaid-protection";return t.ShipAidWidget=class extends lt{constructor(){var t;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this._apiEndpoint="/apps/shipaid",this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>At(t),post:(t,e)=>At(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t;((t,e)=>{ut(t,e,[])})(this,(async()=>{var t,e,i,o;const r=document.createElement("link");r.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),r.setAttribute("rel","stylesheet"),document.head.appendChild(r);try{const t=localStorage.getItem(St),{lastAction:e}=t?JSON.parse(t):{};e&&(this._lastAction=e)}catch{Ct("Failed to parse local storage.")}try{const[t,e]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=t,this._cart=e}catch{return this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return null!=(e=null==(t=this._store)?void 0:t.plan)&&e.active?null!=(o=null==(i=this._store)?void 0:i.protectionSettings)&&o.protectionType?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;const e=localStorage.getItem(St),{lastAction:i}=e?JSON.parse(e):{};"removed"!==i&&!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&this._store.widgetShowCart&&await this.addProtection()}),500),void(!this.disablePolling&&setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval))):(Ct("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(Ct("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))})),ut(this,(()=>{const t={hasProtection:this._hasProtectionInCart,lastAction:this._lastAction};localStorage.setItem(St,JSON.stringify(t))}),[this._lastAction]),ut(this,(async()=>{var t,e,i,o,r;if(this._cartLastUpdated=new Date,null==(t=this._cart)||!t.items)return;const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,null==n||!n.id)return this._shouldShowWidget=!1,void wt("No matching protection variant found.");const a=null!=(i=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i,o,r,s;return null==(s=null==(r=null==(o=null==(i=null==(e=this._store)?void 0:e.protectionSettings)?void 0:i.product)?void 0:o.variants)?void 0:r.edges)?void 0:s.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?i:[],d=null==(o=this._cart)?void 0:o.items[a];if(this._hasProtectionInCart=!!d,!d)return;if(null!=(r=n.id)&&r.includes(d.id.toString()))return void(this._protectionCartItem=l(p({},d),{index:a,position:a+1}));const h={id:d.key,quantity:0};await this._fetch.post("/cart/change.js",h);const c={id:n.id.replace("gid://shopify/ProductVariant/",""),quantity:1},u=await this._fetch.post("/cart/add.js",c),f=l(p({},this._cart),{items:[u,...this._cart.items]});this._cart=f,this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:f,lineItem:u}),this.disablePolling||window.location.reload()}),[this._store,this._cart]);const e=B`
|
|
288
288
|
<div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
|
|
289
289
|
<div class="popup">
|
|
290
290
|
<button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
|
|
@@ -335,4 +335,4 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
|
|
|
335
335
|
<div class="shipaid">
|
|
336
336
|
${ft(this._hasFinishedSetup,(()=>{var t,o;return ft(this._shouldShowWidget&&(null==(o=null==(t=this._store)?void 0:t.plan)?void 0:o.active)&&this._store.widgetShowCart,(()=>[e,i]),(()=>B``))}),(()=>B`<p><slot>Loading ShipAid Widget...</slot></p>`))}
|
|
337
337
|
</div>
|
|
338
|
-
`}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async calculateProtectionTotal(t){var e,i,o,r,s;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const n=null==(e=this._store)?void 0:e.protectionSettings;if(!n||!n.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=((null==(i=this._store)?void 0:i.excludedProductSkus)&&t.items?t.items.reduce(((t,e)=>e.sku&&this._store.excludedProductSkus.find((t=>t===e.sku))?t-e.final_price:t),t.total_price):t.total_price)-(null!=(r=null==(o=t.items)?void 0:o.filter((t=>{var e,i,o;return null==(o=null==(i=null==(e=n.product)?void 0:e.variants)?void 0:i.edges)?void 0:o.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?r:[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===n.protectionType){if(!n.defaultFee)throw new Error("Missing default fee amount.");if(null==(s=n.rules)||!s.length)return n.defaultFee;const t=a/100,e=n.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:n.defaultFee}if("PERCENTAGE"===n.protectionType){const t=a*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o;const r=null==(e=this._store)?void 0:e.protectionSettings;if(!r||null==(o=null==(i=r.product)?void 0:i.variants)||!o.edges)throw new Error("Missing product and variants from protection settings.");return r.product.variants.edges.flatMap((({node:t})=>{if(!t||!t.price)return[];const e=Number(t.price);return[l(p({},t),{formattedPrice:e})]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)).find((e=>e.formattedPrice>=t))}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e=await this._fetch.get(t.toString());if(!e)throw new Error(`Failed to fetch store data for ${t.toString()}`);const[i]=e.stores;if(!i)throw new Error(`Could not find a store for this URL ${t.toString()}.`);return i}catch(Y){throw console.error(Y)
|
|
338
|
+
`}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async calculateProtectionTotal(t){var e,i,o,r,s;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const n=null==(e=this._store)?void 0:e.protectionSettings;if(!n||!n.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=((null==(i=this._store)?void 0:i.excludedProductSkus)&&t.items?t.items.reduce(((t,e)=>e.sku&&this._store.excludedProductSkus.find((t=>t===e.sku))?t-e.final_price:t),t.total_price):t.total_price)-(null!=(r=null==(o=t.items)?void 0:o.filter((t=>{var e,i,o;return null==(o=null==(i=null==(e=n.product)?void 0:e.variants)?void 0:i.edges)?void 0:o.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?r:[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===n.protectionType){if(!n.defaultFee)throw new Error("Missing default fee amount.");if(null==(s=n.rules)||!s.length)return n.defaultFee;const t=a/100,e=n.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:n.defaultFee}if("PERCENTAGE"===n.protectionType){const t=a*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o;const r=null==(e=this._store)?void 0:e.protectionSettings;if(!r||null==(o=null==(i=r.product)?void 0:i.variants)||!o.edges)throw new Error("Missing product and variants from protection settings.");return r.product.variants.edges.flatMap((({node:t})=>{if(!t||!t.price)return[];const e=Number(t.price);return[l(p({},t),{formattedPrice:e})]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)).find((e=>e.formattedPrice>=t))}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e=await this._fetch.get(t.toString());if(!e)throw new Error(`Failed to fetch store data for ${t.toString()}`);const[i]=e.stores;if(!i)throw new Error(`Could not find a store for this URL ${t.toString()}.`);return i}catch(Y){throw console.error(Y),$t(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(Y){throw wt(Y.message),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e,i;try{if(!this._store)throw new Error("Store has not been loaded.");if(null==(t=this._cart)||!t.items)throw new Error("Cart has not been loaded.");if(null==(e=this._protectionVariant)||!e.id)throw new Error("No protection variant found.");this._setState("loading");const o={id:this._protectionVariant.id.replace("gid://shopify/ProductVariant/",""),quantity:1},r=await this._fetch.post("/cart/add.js",o),s=l(p({},this._cart),{items:[r,...this._cart.items]});if(this._lastAction="added",this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:s,lineItem:r}),(null==(i=window.Shopify)?void 0:i.Checkout)||!this.disablePolling)return window.location.reload();this._cart=s,this._setState("success")}catch(o){wt(o.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var t;try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const e={id:this._protectionCartItem.key,quantity:0},i=await this._fetch.post("/cart/change.js",e);if(this._lastAction="removed",this._dispatchEvent(mt.STATUS_UPDATE,{protection:!1,cart:i,lineItem:this._protectionCartItem}),(null==(t=window.Shopify)?void 0:t.Checkout)||!this.disablePolling)return window.location.reload();this._cart=i,this._setState("success")}catch(e){wt(e.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}},t.ShipAidWidget.styles=vt,yt([h({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),yt([h({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),yt([c()],t.ShipAidWidget.prototype,"_storeDomain",2),yt([c()],t.ShipAidWidget.prototype,"_store",2),yt([c()],t.ShipAidWidget.prototype,"_cart",2),yt([c()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),yt([c()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),yt([c()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),yt([c()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),yt([c()],t.ShipAidWidget.prototype,"_lastAction",2),yt([c()],t.ShipAidWidget.prototype,"_protectionCartItem",2),yt([c()],t.ShipAidWidget.prototype,"_protectionVariant",2),yt([c()],t.ShipAidWidget.prototype,"_state",2),yt([c()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=yt([(t=>e=>{return"function"==typeof e?(i=t,o=e,window.customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){window.customElements.define(t,e)}}})(t,e);var i,o})("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),t}({});
|
|
@@ -29,7 +29,7 @@ const f=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad
|
|
|
29
29
|
* @license
|
|
30
30
|
* Copyright 2017 Google LLC
|
|
31
31
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
32
|
-
*/;var y;const C=window.trustedTypes,w=C?C.emptyScript:"",$=window.reactiveElementPolyfillSupport,A={toAttribute(t,e){switch(e){case Boolean:t=t?w:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},
|
|
32
|
+
*/;var y;const C=window.trustedTypes,w=C?C.emptyScript:"",$=window.reactiveElementPolyfillSupport,A={toAttribute(t,e){switch(e){case Boolean:t=t?w:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch{i=null}}return i}},S=(t,e)=>e!==t&&(e==e||t==t),b={attribute:!0,type:String,converter:A,reflect:!1,hasChanged:S};class L extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const o=this._$Eh(i,e);void 0!==o&&(this._$Eu.set(o,i),t.push(o))})),t}static createProperty(t,e=b){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const i="symbol"==typeof t?Symbol():"__"+t,o=this.getPropertyDescriptor(t,i,e);void 0!==o&&Object.defineProperty(this.prototype,t,o)}}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(o){const r=this[t];this[e]=o,this.requestUpdate(t,r,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||b}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(_(t))}else void 0!==t&&e.push(_(t));return e}static _$Eh(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ep=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Em(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$Eg)&&void 0!==e?e:this._$Eg=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$Eg)||void 0===e||e.splice(this._$Eg.indexOf(t)>>>0,1)}_$Em(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{f?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),o=window.litNonce;void 0!==o&&i.setAttribute("nonce",o),i.textContent=e.cssText,t.appendChild(i)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$ES(t,e,i=b){var o,r;const s=this.constructor._$Eh(t,i);if(void 0!==s&&!0===i.reflect){const n=(null!==(r=null===(o=i.converter)||void 0===o?void 0:o.toAttribute)&&void 0!==r?r:A.toAttribute)(e,i.type);this._$Ei=t,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$Ei=null}}_$AK(t,e){var i,o,r;const s=this.constructor,n=s._$Eu.get(t);if(void 0!==n&&this._$Ei!==n){const t=s.getPropertyOptions(n),a=t.converter,p=null!==(r=null!==(o=null===(i=a)||void 0===i?void 0:i.fromAttribute)&&void 0!==o?o:"function"==typeof a?a:null)&&void 0!==r?r:A.fromAttribute;this._$Ei=n,this[n]=p(e,t.type),this._$Ei=null}}requestUpdate(t,e,i){let o=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||S)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$Ei!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):o=!1),!this.isUpdatePending&&o&&(this._$Ep=this._$E_())}async _$E_(){this.isUpdatePending=!0;try{await this._$Ep}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$Eg)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$EU()}catch(o){throw e=!1,this._$EU(),o}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Eg)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ep}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$ES(e,this[e],t))),this._$EC=void 0),this._$EU()}updated(t){}firstUpdated(t){}}
|
|
33
33
|
/**
|
|
34
34
|
* @license
|
|
35
35
|
* Copyright 2017 Google LLC
|
|
@@ -49,14 +49,14 @@ var at,pt;null==nt||nt(K,Q),(null!==(E=globalThis.litHtmlVersions)&&void 0!==E?E
|
|
|
49
49
|
*/
|
|
50
50
|
function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[o+1]),t[0]);return new g(i,v)})`
|
|
51
51
|
:host {
|
|
52
|
-
--shipaid-primary:
|
|
53
|
-
--shipaid-secondary:
|
|
52
|
+
--shipaid-primary: inherit;
|
|
53
|
+
--shipaid-secondary: inherit;
|
|
54
54
|
--shipaid-danger: #f44336;
|
|
55
55
|
--shipaid-text: #000000;
|
|
56
56
|
--shipaid-text-muted: #cccccc;
|
|
57
57
|
--shipaid-text-grey: #aaaaaa;
|
|
58
58
|
--shipaid-light-grey: #ebecf0;
|
|
59
|
-
--shipaid-font:
|
|
59
|
+
--shipaid-font: inherit;
|
|
60
60
|
--shipaid-font-sm: 14px;
|
|
61
61
|
--shipaid-font-base: 16px;
|
|
62
62
|
--shipaid-font-lg: 18px;
|
|
@@ -284,7 +284,7 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
|
|
|
284
284
|
color: var(--shipaid-text-grey);
|
|
285
285
|
font-weight: var(--shipaid-font-heavy);
|
|
286
286
|
}
|
|
287
|
-
`,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&>(e,i,s),s};const Ct=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i)
|
|
287
|
+
`,mt=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(mt||{}),gt=Object.defineProperty,_t=Object.getOwnPropertyDescriptor,yt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?_t(e,i):e,n=t.length-1;n>=0;n--)(r=t[n])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&>(e,i,s),s};const Ct=t=>console.warn(`[ShipAid] ${t}`),wt=t=>console.error(`[ShipAid] ${t}`),$t=t=>new Error(`[ShipAid] ${t}`),At=async(t,e)=>{try{const i=await fetch(t,e);if(!i.ok)throw new Error(await i.text());return await i.json()}catch(i){throw console.error(i),$t("Failed to complete fetch request.")}},St="shipaid-protection";t.ShipAidWidget=class extends lt{constructor(){var t;super(...arguments),this.disablePolling=!1,this.pollingInterval=2500,this._apiEndpoint="/apps/shipaid",this._storeDomain=null==(t=window.Shopify)?void 0:t.shop,this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>At(t),post:(t,e)=>At(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}render(){var t;((t,e)=>{ut(t,e,[])})(this,(async()=>{var t,e,i,o;const r=document.createElement("link");r.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),r.setAttribute("rel","stylesheet"),document.head.appendChild(r);try{const t=localStorage.getItem(St),{lastAction:e}=t?JSON.parse(t):{};e&&(this._lastAction=e)}catch{Ct("Failed to parse local storage.")}try{const[t,e]=await Promise.all([this._fetchShipAidData(),this._fetchCart()]);this._store=t,this._cart=e}catch{return this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return null!=(e=null==(t=this._store)?void 0:t.plan)&&e.active?null!=(o=null==(i=this._store)?void 0:i.protectionSettings)&&o.protectionType?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(mt.LOADED,this._store),setTimeout((async()=>{var t;const e=localStorage.getItem(St),{lastAction:i}=e?JSON.parse(e):{};"removed"!==i&&!this._hasProtectionInCart&&(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&this._store.widgetShowCart&&await this.addProtection()}),500),void(!this.disablePolling&&setInterval((async()=>{const t=this._cartLastUpdated;t&&(new Date).getTime()-t.getTime()<this.pollingInterval||await this.updateCart()}),this.pollingInterval))):(Ct("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(Ct("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))})),ut(this,(()=>{const t={hasProtection:this._hasProtectionInCart,lastAction:this._lastAction};localStorage.setItem(St,JSON.stringify(t))}),[this._lastAction]),ut(this,(async()=>{var t,e,i,o,r;if(this._cartLastUpdated=new Date,null==(t=this._cart)||!t.items)return;const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,null==n||!n.id)return this._shouldShowWidget=!1,void wt("No matching protection variant found.");const a=null!=(i=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i,o,r,s;return null==(s=null==(r=null==(o=null==(i=null==(e=this._store)?void 0:e.protectionSettings)?void 0:i.product)?void 0:o.variants)?void 0:r.edges)?void 0:s.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?i:[],d=null==(o=this._cart)?void 0:o.items[a];if(this._hasProtectionInCart=!!d,!d)return;if(null!=(r=n.id)&&r.includes(d.id.toString()))return void(this._protectionCartItem=l(p({},d),{index:a,position:a+1}));const h={id:d.key,quantity:0};await this._fetch.post("/cart/change.js",h);const c={id:n.id.replace("gid://shopify/ProductVariant/",""),quantity:1},u=await this._fetch.post("/cart/add.js",c),f=l(p({},this._cart),{items:[u,...this._cart.items]});this._cart=f,this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:f,lineItem:u}),this.disablePolling||window.location.reload()}),[this._store,this._cart]);const e=B`
|
|
288
288
|
<div class=${`shipaid-popup ${"learn-more"===this._popup&&"active"}`}>
|
|
289
289
|
<div class="popup">
|
|
290
290
|
<button class="popup-close" @click=${()=>{this._popup=null}}>Close</button>
|
|
@@ -335,4 +335,4 @@ function ft(t,e,i){return t?e():null==i?void 0:i()}var vt=((t,...e)=>{const i=1=
|
|
|
335
335
|
<div class="shipaid">
|
|
336
336
|
${ft(this._hasFinishedSetup,(()=>{var t,o;return ft(this._shouldShowWidget&&(null==(o=null==(t=this._store)?void 0:t.plan)?void 0:o.active)&&this._store.widgetShowCart,(()=>[e,i]),(()=>B``))}),(()=>B`<p><slot>Loading ShipAid Widget...</slot></p>`))}
|
|
337
337
|
</div>
|
|
338
|
-
`}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async calculateProtectionTotal(t){var e,i,o,r,s;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const n=null==(e=this._store)?void 0:e.protectionSettings;if(!n||!n.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=((null==(i=this._store)?void 0:i.excludedProductSkus)&&t.items?t.items.reduce(((t,e)=>e.sku&&this._store.excludedProductSkus.find((t=>t===e.sku))?t-e.final_price:t),t.total_price):t.total_price)-(null!=(r=null==(o=t.items)?void 0:o.filter((t=>{var e,i,o;return null==(o=null==(i=null==(e=n.product)?void 0:e.variants)?void 0:i.edges)?void 0:o.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?r:[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===n.protectionType){if(!n.defaultFee)throw new Error("Missing default fee amount.");if(null==(s=n.rules)||!s.length)return n.defaultFee;const t=a/100,e=n.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:n.defaultFee}if("PERCENTAGE"===n.protectionType){const t=a*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o;const r=null==(e=this._store)?void 0:e.protectionSettings;if(!r||null==(o=null==(i=r.product)?void 0:i.variants)||!o.edges)throw new Error("Missing product and variants from protection settings.");return r.product.variants.edges.flatMap((({node:t})=>{if(!t||!t.price)return[];const e=Number(t.price);return[l(p({},t),{formattedPrice:e})]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)).find((e=>e.formattedPrice>=t))}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e=await this._fetch.get(t.toString());if(!e)throw new Error(`Failed to fetch store data for ${t.toString()}`);const[i]=e.stores;if(!i)throw new Error(`Could not find a store for this URL ${t.toString()}.`);return i}catch(Y){throw console.error(Y)
|
|
338
|
+
`}_currencyFormat(t){var e,i,o,r,s;return new Intl.NumberFormat(null!=(i=null==(e=window.Shopify)?void 0:e.locale)?i:void 0,{currency:(null==(o=this._store)?void 0:o.currency)||(null==(s=null==(r=window.Shopify)?void 0:r.currency)?void 0:s.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async calculateProtectionTotal(t){var e,i,o,r,s;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const n=null==(e=this._store)?void 0:e.protectionSettings;if(!n||!n.product)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=((null==(i=this._store)?void 0:i.excludedProductSkus)&&t.items?t.items.reduce(((t,e)=>e.sku&&this._store.excludedProductSkus.find((t=>t===e.sku))?t-e.final_price:t),t.total_price):t.total_price)-(null!=(r=null==(o=t.items)?void 0:o.filter((t=>{var e,i,o;return null==(o=null==(i=null==(e=n.product)?void 0:e.variants)?void 0:i.edges)?void 0:o.some((({node:e})=>{var i;return null==(i=null==e?void 0:e.id)?void 0:i.includes(t.variant_id.toString())}))})))?r:[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===n.protectionType){if(!n.defaultFee)throw new Error("Missing default fee amount.");if(null==(s=n.rules)||!s.length)return n.defaultFee;const t=a/100,e=n.rules.sort(((t,e)=>t.rangeLower&&e.rangeLower?t.rangeLower-e.rangeLower:0)).find((e=>{const i=Boolean(e.rangeLower&&e.rangeLower<t);return e.rangeUpper?i&&e.rangeUpper>=t:i}));return"number"==typeof(null==e?void 0:e.fee)?e.fee:n.defaultFee}if("PERCENTAGE"===n.protectionType){const t=a*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o;const r=null==(e=this._store)?void 0:e.protectionSettings;if(!r||null==(o=null==(i=r.product)?void 0:i.variants)||!o.edges)throw new Error("Missing product and variants from protection settings.");return r.product.variants.edges.flatMap((({node:t})=>{if(!t||!t.price)return[];const e=Number(t.price);return[l(p({},t),{formattedPrice:e})]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)).find((e=>e.formattedPrice>=t))}_setState(t,e){this._state={loading:"loading"===t,success:"success"===t,error:"error"===t&&(e||!0)}}async _updateProtection(){return this._hasProtectionInCart?this.removeProtection():this.addProtection()}async _fetchShipAidData(){try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e=await this._fetch.get(t.toString());if(!e)throw new Error(`Failed to fetch store data for ${t.toString()}`);const[i]=e.stores;if(!i)throw new Error(`Could not find a store for this URL ${t.toString()}.`);return i}catch(Y){throw console.error(Y),$t(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(Y){throw wt(Y.message),new Error("Could not fetch cart for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e,i;try{if(!this._store)throw new Error("Store has not been loaded.");if(null==(t=this._cart)||!t.items)throw new Error("Cart has not been loaded.");if(null==(e=this._protectionVariant)||!e.id)throw new Error("No protection variant found.");this._setState("loading");const o={id:this._protectionVariant.id.replace("gid://shopify/ProductVariant/",""),quantity:1},r=await this._fetch.post("/cart/add.js",o),s=l(p({},this._cart),{items:[r,...this._cart.items]});if(this._lastAction="added",this._dispatchEvent(mt.STATUS_UPDATE,{protection:!0,cart:s,lineItem:r}),(null==(i=window.Shopify)?void 0:i.Checkout)||!this.disablePolling)return window.location.reload();this._cart=s,this._setState("success")}catch(o){wt(o.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){var t;try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const e={id:this._protectionCartItem.key,quantity:0},i=await this._fetch.post("/cart/change.js",e);if(this._lastAction="removed",this._dispatchEvent(mt.STATUS_UPDATE,{protection:!1,cart:i,lineItem:this._protectionCartItem}),(null==(t=window.Shopify)?void 0:t.Checkout)||!this.disablePolling)return window.location.reload();this._cart=i,this._setState("success")}catch(e){wt(e.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}},t.ShipAidWidget.styles=vt,yt([h({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),yt([h({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),yt([c()],t.ShipAidWidget.prototype,"_storeDomain",2),yt([c()],t.ShipAidWidget.prototype,"_store",2),yt([c()],t.ShipAidWidget.prototype,"_cart",2),yt([c()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),yt([c()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),yt([c()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),yt([c()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),yt([c()],t.ShipAidWidget.prototype,"_lastAction",2),yt([c()],t.ShipAidWidget.prototype,"_protectionCartItem",2),yt([c()],t.ShipAidWidget.prototype,"_protectionVariant",2),yt([c()],t.ShipAidWidget.prototype,"_state",2),yt([c()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=yt([(t=>e=>{return"function"==typeof e?(i=t,o=e,window.customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){window.customElements.define(t,e)}}})(t,e);var i,o})("shipaid-widget")],t.ShipAidWidget),Object.defineProperties(t,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
|