ui.shipaid.com 0.3.0-beta.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/widget.es.js +0 -7
- package/dist/widget.iife.js +33 -37
- package/dist/widget.umd.js +33 -37
- package/package.json +1 -1
package/dist/widget.es.js
CHANGED
|
@@ -1836,13 +1836,6 @@ let ShipAidWidget = class extends s$1 {
|
|
|
1836
1836
|
i
|
|
1837
1837
|
</button>
|
|
1838
1838
|
</div>
|
|
1839
|
-
<div>
|
|
1840
|
-
<p>Switch Locales</p>
|
|
1841
|
-
${Object.keys(langFiles).map((filePath) => {
|
|
1842
|
-
const lang = filePath.replace("./lang/", "").replace(".json", "");
|
|
1843
|
-
return y`<button @click="${() => use(lang)}">${lang}</button>`;
|
|
1844
|
-
})}
|
|
1845
|
-
</div>
|
|
1846
1839
|
</div>
|
|
1847
1840
|
`;
|
|
1848
1841
|
}
|
package/dist/widget.iife.js
CHANGED
|
@@ -24,7 +24,7 @@ var ShipAidWidget=function(t){"use strict";
|
|
|
24
24
|
* Copyright 2019 Google LLC
|
|
25
25
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
26
26
|
*/
|
|
27
|
-
const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),
|
|
27
|
+
const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),d=new WeakMap;let p=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==l)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(a&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=d.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&d.set(e,t))}return t}toString(){return this.cssText}};const h=(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 p(i,t,l)},c=a?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new p("string"==typeof t?t:t+"",void 0,l))(e)})(t):t
|
|
28
28
|
/**
|
|
29
29
|
* @license
|
|
30
30
|
* Copyright 2017 Google LLC
|
|
@@ -35,39 +35,39 @@ const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"
|
|
|
35
35
|
* Copyright 2017 Google LLC
|
|
36
36
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
37
|
*/
|
|
38
|
-
var b;$.finalized=!0,$.elementProperties=new Map,$.elementStyles=[],$.shadowRootOptions={mode:"open"},null==m||m({ReactiveElement:$}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.6.1");const w=window,A=w.trustedTypes,L=A?A.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,z=(t="")=>P.createComment(t),k=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,U=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),j=/'/g,R=/"/g,I=/^(?:script|style|textarea|title)$/i,W=(V=1,(t,...e)=>({_$litType$:V,strings:t,values:e})),H=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),q=new WeakMap,B=P.createTreeWalker(P,129,null,!1);var V;class F{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[l,
|
|
38
|
+
var b;$.finalized=!0,$.elementProperties=new Map,$.elementStyles=[],$.shadowRootOptions={mode:"open"},null==m||m({ReactiveElement:$}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.6.1");const w=window,A=w.trustedTypes,L=A?A.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,z=(t="")=>P.createComment(t),k=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,U=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),j=/'/g,R=/"/g,I=/^(?:script|style|textarea|title)$/i,W=(V=1,(t,...e)=>({_$litType$:V,strings:t,values:e})),H=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),q=new WeakMap,B=P.createTreeWalker(P,129,null,!1);var V;class F{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[l,d]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=M;for(let l=0;l<i;l++){const e=t[l];let i,a,d=-1,p=0;for(;p<e.length&&(n.lastIndex=p,a=n.exec(e),null!==a);)p=n.lastIndex,n===M?"!--"===a[1]?n=O:void 0!==a[1]?n=U:void 0!==a[2]?(I.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=N):void 0!==a[3]&&(n=N):n===N?">"===a[0]?(n=null!=r?r:M,d=-1):void 0===a[1]?d=-2:(d=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?N:'"'===a[3]?R:j):n===R||n===j?n=N:n===O||n===U?n=M:(n=N,r=void 0);const h=n===N&&t[l+1].startsWith("/>")?" ":"";s+=n===M?e+E:d>=0?(o.push(i),e.slice(0,d)+"$lit$"+e.slice(d)+S+h):e+S+(-2===d?(o.push(void 0),l):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==L?L.createHTML(a):a,o]})(t,e);if(this.el=F.createElement(l,i),B.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=B.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(S)){const i=d[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split(S),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?Q:"?"===e[1]?X:"@"===e[1]?tt:K})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(I.test(o.tagName)){const t=o.textContent.split(S),e=t.length-1;if(e>0){o.textContent=A?A.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],z()),B.nextNode(),a.push({type:2,index:++r});o.append(t[e],z())}}}else if(8===o.nodeType)if(o.data===x)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(S,t+1));)a.push({type:7,index:r}),t+=S.length-1}r++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function Z(t,e,i=t,o){var r,s,n,a;if(e===H)return e;let l=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const d=k(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==d&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===d?l=void 0:(l=new d(t),l._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=l:i._$Cl=l),void 0!==l&&(e=Z(t,l._$AS(t,e.values),l,o)),e}class G{constructor(t,e){this.u=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:P).importNode(i,!0);B.currentNode=r;let s=B.nextNode(),n=0,a=0,l=o[0];for(;void 0!==l;){if(n===l.index){let e;2===l.type?e=new J(s,s.nextSibling,this,t):1===l.type?e=new l.ctor(s,l.name,l.strings,this,t):6===l.type&&(e=new et(s,this,t)),this.u.push(e),l=o[++a]}n!==(null==l?void 0:l.index)&&(s=B.nextNode(),n++)}return r}p(t){let e=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class J{constructor(t,e,i,o){var r;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cm=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cm}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),k(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==H&&this.g(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>T(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==D&&k(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=F.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new G(r,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=q.get(t.strings);return void 0===e&&q.set(t.strings,e=new F(t)),e}k(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new J(this.O(z()),this.O(z()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cm=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class K{constructor(t,e,i,o,r){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=Z(this,t,e,0),s=!k(t)||t!==this._$AH&&t!==H,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=Z(this,o[i+n],e,n),a===H&&(a=this._$AH[n]),s||(s=!k(a)||a!==this._$AH[n]),a===D?t=D:t!==D&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Q extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const Y=A?A.emptyScript:"";class X extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,Y):this.element.removeAttribute(this.name)}}class tt extends K{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=Z(this,t,e,0))&&void 0!==i?i:D)===H)return;const o=this._$AH,r=t===D&&o!==D||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==D&&(o===D||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class et{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){Z(this,t)}}const it=w.litHtmlPolyfillSupport;null==it||it(F,J),(null!==(b=w.litHtmlVersions)&&void 0!==b?b:w.litHtmlVersions=[]).push("2.6.1");const ot=(t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new J(e.insertBefore(z(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
|
|
39
39
|
/**
|
|
40
40
|
* @license
|
|
41
41
|
* Copyright 2017 Google LLC
|
|
42
42
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/var rt,st;let nt=class extends ${constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=ot(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return H}};nt.finalized=!0,nt._$litElement$=!0,null===(rt=globalThis.litElementHydrateSupport)||void 0===rt||rt.call(globalThis,{LitElement:nt});const at=globalThis.litElementPolyfillSupport;null==at||at({LitElement:nt}),(null!==(st=globalThis.litElementVersions)&&void 0!==st?st:globalThis.litElementVersions=[]).push("3.2.0");const lt="langChanged";function
|
|
43
|
+
*/var rt,st;let nt=class extends ${constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=ot(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return H}};nt.finalized=!0,nt._$litElement$=!0,null===(rt=globalThis.litElementHydrateSupport)||void 0===rt||rt.call(globalThis,{LitElement:nt});const at=globalThis.litElementPolyfillSupport;null==at||at({LitElement:nt}),(null!==(st=globalThis.litElementVersions)&&void 0!==st?st:globalThis.litElementVersions=[]).push("3.2.0");const lt="langChanged";function dt(t,e,i){return Object.entries(ht(e||{})).reduce(((t,[e,i])=>t.replace(new RegExp(`{{[ ]*${e}[ ]*}}`,"gm"),String(ht(i)))),t)}function pt(t,e){const i=t.split(".");let o=e.strings;for(;null!=o&&i.length>0;)o=o[i.shift()];return null!=o?o.toString():null}function ht(t){return"function"==typeof t?t():t}let ct={loader:()=>Promise.resolve({}),empty:t=>`[${t}]`,lookup:pt,interpolate:dt,translationCache:{}};function ut(t,e,i=ct){var o;o={previousStrings:i.strings,previousLang:i.lang,lang:i.lang=t,strings:i.strings=e},window.dispatchEvent(new CustomEvent(lt,{detail:o}))}
|
|
44
44
|
/**
|
|
45
45
|
* @license
|
|
46
46
|
* Copyright 2017 Google LLC
|
|
47
47
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
48
48
|
*/
|
|
49
|
-
const
|
|
49
|
+
const ft=2;class gt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
50
50
|
/**
|
|
51
51
|
* @license
|
|
52
52
|
* Copyright 2020 Google LLC
|
|
53
53
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
54
|
-
*/const
|
|
54
|
+
*/const vt=(t,e)=>{var i,o;const r=t._$AN;if(void 0===r)return!1;for(const s of r)null===(o=(i=s)._$AO)||void 0===o||o.call(i,e,!1),vt(s,e);return!0},mt=t=>{let e,i;do{if(void 0===(e=t._$AM))break;i=e._$AN,i.delete(t),t=e}while(0===(null==i?void 0:i.size))},_t=t=>{for(let e;e=t._$AM;t=e){let i=e._$AN;if(void 0===i)e._$AN=i=new Set;else if(i.has(t))break;i.add(t),$t(e)}};
|
|
55
55
|
/**
|
|
56
56
|
* @license
|
|
57
57
|
* Copyright 2017 Google LLC
|
|
58
58
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
59
|
-
*/function
|
|
59
|
+
*/function yt(t){void 0!==this._$AN?(mt(this),this._$AM=t,_t(this)):this._$AM=t}function Ct(t,e=!1,i=0){const o=this._$AH,r=this._$AN;if(void 0!==r&&0!==r.size)if(e)if(Array.isArray(o))for(let s=i;s<o.length;s++)vt(o[s],!1),mt(o[s]);else null!=o&&(vt(o,!1),mt(o));else vt(this,t)}const $t=t=>{var e,i,o,r;t.type==ft&&(null!==(e=(o=t)._$AP)&&void 0!==e||(o._$AP=Ct),null!==(i=(r=t)._$AQ)&&void 0!==i||(r._$AQ=yt))};class bt extends gt{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),_t(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,o;t!==this.isConnected&&(this.isConnected=t,t?null===(i=this.reconnected)||void 0===i||i.call(this):null===(o=this.disconnected)||void 0===o||o.call(this)),e&&(vt(this,t),mt(this))}setValue(t){if(void 0===this._$Ct.strings)this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}class wt extends bt{constructor(){super(...arguments),this.langChangedSubscription=null,this.getValue=()=>""}renderValue(t){return this.getValue=t,this.subscribe(),this.getValue()}langChanged(t){this.setValue(this.getValue(t))}subscribe(){null==this.langChangedSubscription&&(this.langChangedSubscription=function(t,e){const i=e=>t(e.detail);return window.addEventListener(lt,i,e),()=>window.removeEventListener(lt,i)}(this.langChanged.bind(this)))}unsubscribe(){null!=this.langChangedSubscription&&this.langChangedSubscription()}disconnected(){this.unsubscribe()}reconnected(){this.subscribe()}}const At=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends wt{render(t,e,i){return this.renderValue((()=>function(t,e,i=ct){let o=i.translationCache[t]||(i.translationCache[t]=i.lookup(t,i)||i.empty(t,i));return null!=(e=null!=e?ht(e):null)?i.interpolate(o,e,i):o}(t,e,i)))}});
|
|
60
60
|
/**
|
|
61
61
|
* @license
|
|
62
62
|
* Copyright 2017 Google LLC
|
|
63
63
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
64
|
-
*/class
|
|
64
|
+
*/class Lt extends gt{constructor(t){if(super(t),this.it=D,t.type!==ft)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===D||null==t)return this._t=void 0,this.it=t;if(t===H)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}Lt.directiveName="unsafeHTML",Lt.resultType=1;const St="__registered_effects";function xt(t){const e=t;if(e[St])return e;const i=function(t){if(!t.dispatchEvent||!t.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return t}(t),o=i.updated;return e[St]={index:0,count:0,effects:[]},i.updated=t=>(e[St].index=0,o(t)),e}function Et(t,e,i){const o=function(t,e){const i=xt(t),{index:o,count:r}=i[St];return o===r?(i[St].index++,i[St].count++,i[St].effects.push(e),e):(i[St].index++,i[St].effects[o])}(t,{on:e,observe:["__initial__dirty"]});o.observe.some(((t,e)=>i[e]!==t))&&o.on(),o.observe=i}
|
|
65
65
|
/**
|
|
66
66
|
* @license
|
|
67
67
|
* Copyright 2021 Google LLC
|
|
68
68
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
69
69
|
*/
|
|
70
|
-
function
|
|
70
|
+
function Pt(t,e,i){return t?e():null==i?void 0:i()}const zt=h`
|
|
71
71
|
:host {
|
|
72
72
|
--shipaid-primary: #002bd6;
|
|
73
73
|
--shipaid-secondary: #0076ff;
|
|
@@ -199,30 +199,30 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
199
199
|
font-size: var(--shipaid-font-sm);
|
|
200
200
|
color: var(--shipaid-text);
|
|
201
201
|
}
|
|
202
|
-
`;var
|
|
202
|
+
`;var kt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,Mt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?Tt(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&&kt(e,i,s),s};let Ot=class extends nt{constructor(){super(...arguments),this.active=!1}handleClosePopup(){const t=new Event("close");this.dispatchEvent(t)}render(){return W`
|
|
203
203
|
<div class=${`shipaid-popup ${this.active&&"active"}`}>
|
|
204
204
|
<button
|
|
205
205
|
type="button"
|
|
206
206
|
class="popup-close"
|
|
207
207
|
@click=${this.handleClosePopup}
|
|
208
208
|
>
|
|
209
|
-
${
|
|
209
|
+
${At("learn-more-popup.close")}
|
|
210
210
|
</button>
|
|
211
|
-
<p class="popup-title">${
|
|
211
|
+
<p class="popup-title">${At("learn-more-popup.title")}</p>
|
|
212
212
|
<p>
|
|
213
|
-
${
|
|
213
|
+
${At("learn-more-popup.subtitle")}
|
|
214
214
|
</p>
|
|
215
215
|
<img
|
|
216
216
|
src="https://res.cloudinary.com/dxyz34kfj/image/upload/v1660782754/shipaid-image_hoz6k8.jpg"
|
|
217
217
|
alt="shipaid protected parcel"
|
|
218
218
|
class="popup-top-image"
|
|
219
219
|
/>
|
|
220
|
-
<p class="popup-title">${
|
|
220
|
+
<p class="popup-title">${At("learn-more-popup.disclaimer.title")}</p>
|
|
221
221
|
<p>
|
|
222
|
-
${
|
|
222
|
+
${At("learn-more-popup.disclaimer.subtitle")}
|
|
223
223
|
</p>
|
|
224
224
|
<p class="popup-disclaimer">
|
|
225
|
-
${
|
|
225
|
+
${At("learn-more-popup.disclaimer.text")}
|
|
226
226
|
</p>
|
|
227
227
|
<div class="popup-footer">
|
|
228
228
|
<div class="footer-links">
|
|
@@ -231,14 +231,14 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
231
231
|
target="_blank"
|
|
232
232
|
rel="noreferrer"
|
|
233
233
|
>
|
|
234
|
-
${
|
|
234
|
+
${At("learn-more-popup.links.terms")}
|
|
235
235
|
</a>
|
|
236
236
|
<a
|
|
237
237
|
href="https://www.shipaid.com/privacy-policy"
|
|
238
238
|
target="_blank"
|
|
239
239
|
rel="noreferrer"
|
|
240
240
|
>
|
|
241
|
-
${
|
|
241
|
+
${At("learn-more-popup.links.privacy")}
|
|
242
242
|
</a>
|
|
243
243
|
</div>
|
|
244
244
|
<div class="footer-date">
|
|
@@ -246,7 +246,7 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
246
246
|
</div>
|
|
247
247
|
</div>
|
|
248
248
|
</div>
|
|
249
|
-
`}};
|
|
249
|
+
`}};Ot.styles=zt,Mt([o({type:Boolean,attribute:!0})],Ot.prototype,"active",2),Ot=Mt([e("shipaid-popup-learn-more")],Ot);const Ut="Loading ShipAid Widget...",Nt="Delivery Guarantee",jt="in case of Loss, Damage or Theft",Rt={button:"Powered by"},It={add:"Add",remove:"Remove",loading:"Loading..."},Wt={loading:Ut,title:Nt,description:jt,footer:Rt,actions:It,"learn-more-popup":{close:"Close",title:"Delivery Guarantee",subtitle:"We empower your favorite brands to offer a delivery guarantee because every order is precious!",disclaimer:{title:"Shop Worry-Free",subtitle:"Brands and shipment carriers cannot always guarantee your order will arrive at your doorstep safely. Things happen! We help the brand you are purchasing from replace the product you ordered in the chance of an issue in transit. If you encounter an issue, simply reach out to the brand and they will get it resolved as soon as possible.",text:"By purchasing this delivery guarantee, you agree to our Terms Of Service and Privacy Policy. You are not obligated to purchase this guarantee. This guarantee is NOT insurance and does not provide indemnification against loss, damage, or liability arising from a contingent or unknown event, but rather, through ShipAid brands provide a delivery guarantee whereby if the product you ordered is not delivered in satisfactory condition, the brand from which you ordered the product may replace the product free of charge. ShipAid does not provide any products or services directly to consumers, but instead provides a service that allow brands to facilitate product replacement to their customers. Purchasing this guarantee does not mean that you will automatically be reimbursed for any product or shipping costs because the resolution process and decision for compensation is strictly decided by the brand you a purchasing from. The brand will require proof of damage or undelivered product."},links:{terms:"Terms of Service",privacy:"Privacy Policy"}}},Ht=Object.freeze(Object.defineProperty({__proto__:null,actions:It,default:Wt,description:jt,footer:Rt,loading:Ut,title:Nt},Symbol.toStringTag,{value:"Module"})),Dt=h`
|
|
250
250
|
:host {
|
|
251
251
|
--shipaid-primary: #002bd6;
|
|
252
252
|
--shipaid-secondary: #0076ff;
|
|
@@ -392,14 +392,14 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
392
392
|
.shipaid-prompt .prompt-footer .prompt-footer-badge svg {
|
|
393
393
|
height: 9px;
|
|
394
394
|
}
|
|
395
|
-
`,
|
|
395
|
+
`,qt=W`
|
|
396
396
|
<svg viewBox="0 0 453 511" version="1.1" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
397
397
|
<g transform="matrix(1,0,0,1,-29.4375,-0.984384)">
|
|
398
398
|
<path d="M468.297,67.385L262.417,2C258.177,0.646 253.63,0.646 249.391,2L43.51,67.385C35.188,69.708 29.438,77.318 29.438,85.979C32.302,157.156 52.266,370.036 52.266,370.036C52.906,378.188 57.297,385.568 64.167,390.01L248.807,509.156C253.12,511.943 258.688,511.943 263.005,509.156L447.641,390.01C454.51,385.568 458.901,378.188 459.542,370.036C459.542,370.036 479.51,157.156 482.37,85.979C482.37,77.318 476.625,69.708 468.297,67.385" style="fill:rgb(47,52,61);fill-rule:nonzero;"/>
|
|
399
399
|
<path d="M256.01,120.969C286.193,120.969 314.057,130.87 336.536,147.604L309.406,174.656C294.073,164.573 275.729,158.708 256.01,158.708C229.141,158.708 204.823,169.604 187.214,187.198C169.615,204.797 158.719,229.125 158.719,255.995C158.719,282.865 169.615,307.182 187.214,324.792C204.813,342.406 229.141,353.286 256.01,353.286C282.88,353.286 307.208,342.406 324.807,324.792C342.406,307.193 353.297,282.865 353.297,255.995C353.297,251.818 353.036,247.719 352.526,243.688L383.859,212.458C388.51,226.115 391.036,240.766 391.036,255.995C391.036,293.286 375.927,327.047 351.49,351.479C327.057,375.911 293.302,391.021 256.01,391.021C218.729,391.021 184.964,375.911 160.526,351.479C136.094,327.047 120.984,293.286 120.984,255.995C120.984,218.719 136.094,184.948 160.526,160.516C184.964,136.083 218.719,120.969 256.01,120.969ZM218.141,220.906L253.615,259.729L354.844,158.813L381.375,185.484L252.396,314.068L190.422,246.255L218.13,220.906L218.141,220.906Z" style="fill:white;fill-rule:nonzero;"/>
|
|
400
400
|
</g>
|
|
401
401
|
</svg>
|
|
402
|
-
`,
|
|
402
|
+
`,Bt=W`
|
|
403
403
|
<svg
|
|
404
404
|
viewBox="0 0 384 383.999986"
|
|
405
405
|
preserveAspectRatio="xMidYMid meet"
|
|
@@ -441,7 +441,7 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
441
441
|
/>
|
|
442
442
|
</g>
|
|
443
443
|
</svg>
|
|
444
|
-
`,
|
|
444
|
+
`,Vt=W`
|
|
445
445
|
<svg
|
|
446
446
|
viewBox="0 0 423 62"
|
|
447
447
|
version="1.1"
|
|
@@ -523,45 +523,45 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
523
523
|
/>
|
|
524
524
|
</g>
|
|
525
525
|
</svg>
|
|
526
|
-
`;var
|
|
526
|
+
`;var Ft=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(Ft||{}),Zt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Jt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?Gt(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&&Zt(e,i,s),s};const Kt=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),new Error("Failed to complete fetch request.")}},Qt=t=>console.warn(`[ShipAid] ${t}`),Yt=t=>console.error(`[ShipAid] ${t}`),Xt="shipaid-protection",te=Object.assign({"./lang/en.json":()=>Promise.resolve().then((()=>Ht)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>le)).then((t=>t.default))});var ee;ee={loader:async t=>{if("en"===t)return Wt;const e=Reflect.get(te,`./lang/${t}.json`);return e?await e():Wt}},ct=Object.assign(Object.assign({},ct),ee),t.ShipAidWidget=class extends nt{constructor(){var t,e,i;super(...arguments),this.disablePolling=!1,this.disableActions=!1,this.pollingInterval=2500,this.disableRefresh=!1,this.lang="en",this.currency=void 0,this._apiEndpoint="/apps/shipaid",this._storeDomain=(null==(t=window.Shopify)?void 0:t.shop)??(null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost),this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this.hasLoadedStrings=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Kt(t),post:(t,e)=>Kt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(Qt("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o;return new Intl.NumberFormat(void 0,{currency:this.currency||(null==(e=this._store)?void 0:e.currency)||(null==(o=null==(i=window.Shopify)?void 0:i.currency)?void 0:o.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(Ft.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){var e,i,o,r,s,n;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const a=null==(e=this._store)?void 0:e.protectionSettings;if(!a||!this._protectionProduct)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const l=Array.isArray(null==(i=this._store)?void 0:i.excludedProductSkus)?null==(o=this._store)?void 0:o.excludedProductSkus.map((t=>t.trim())):[],d=((null==(r=t.items)?void 0:r.reduce(((t,e)=>{if(!e.sku)return t;return l.some((t=>t===e.sku.trim()))?t-e.final_line_price:t}),t.total_price))??t.total_price)-((null==(s=t.items)?void 0:s.filter((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))??[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===a.protectionType){if("number"!=typeof a.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(n=a.rules)?void 0:n.length))return a.defaultFee;const t=d/100,e=a.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:a.defaultFee}if("PERCENTAGE"===a.protectionType){const t=d*a.percentage/100;return t>=a.minimumFee?t:a.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o,r;if(!(null==(e=this._store)?void 0:e.protectionSettings)||!(null==(o=null==(i=this._protectionProduct)?void 0:i.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const s=null==(r=this._protectionProduct)?void 0:r.variants.flatMap((t=>{if(!t||!t.price)return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=s.find((e=>e.formattedPrice>=t));return n||s[s.length-1]}_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(){var t,e,i,o,r;const s=(null==(t=window.Shopify)?void 0:t.shop)??(null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost);if(!s)throw new Error("No shop found in Shopify object.");try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e={query:"query StoreByDomain ($store: String!) {\n store: storeByDomain (input: {store: $store}) {\n currency\n planActive\n store\n widgetAutoOptIn\n widgetShowCart\n excludedProductSkus\n protectionSettings\n }\n}",variables:{store:s}},i=await this._fetch.post(t.toString(),e);if(!i)throw new Error("Missing response for store query.");if(null==(o=i.errors)?void 0:o.length)throw new Error(i.errors[0].message);if(!(null==(r=i.data)?void 0:r.store))throw new Error("Missing store from store query response.");return i.data.store}catch(n){throw console.error(n),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw Yt(t.message),new Error("Could not fetch cart for current domain.")}}async _fetchProduct(){try{const{product:t}=await this._fetch.get("/products/shipaid-protection.json");return t}catch(t){throw Yt(t.message),new Error("Could not fetch protection product for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!(null==(t=this._cart)?void 0:t.items))throw new Error("Cart has not been loaded.");if(!(null==(e=this._protectionVariant)?void 0:e.id))throw new Error("No protection variant found.");this._setState("loading");const i={quantity:1,id:this._protectionVariant.id},o=await this._fetch.post("/cart/add.js",i);await this._handleRefresh(o),this._setState("success")}catch(i){Yt(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){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={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){Yt(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}learnMorePopupTemplate(){return W`
|
|
527
527
|
<shipaid-popup-learn-more ?active=${"learn-more"===this._popup} @close=${()=>{this._popup=null}}></shipaid-popup-learn-more>
|
|
528
528
|
`}promptTemplate(){var t;return W`
|
|
529
529
|
<div class="shipaid-prompt">
|
|
530
530
|
<div class="prompt-product">
|
|
531
531
|
<div class="prompt-product-image">
|
|
532
|
-
${
|
|
532
|
+
${Pt(this._hasProtectionInCart,(()=>qt),(()=>Bt))}
|
|
533
533
|
</div>
|
|
534
534
|
<div class="prompt-product-details">
|
|
535
535
|
<p class="prompt-product-details-title">
|
|
536
|
-
<slot name="title">${
|
|
536
|
+
<slot name="title">${At("title")}</slot>
|
|
537
537
|
</p>
|
|
538
538
|
<p class="prompt-product-details-description">
|
|
539
|
-
<slot name="subtitle">${
|
|
539
|
+
<slot name="subtitle">${At("description")}</slot>
|
|
540
540
|
</p>
|
|
541
541
|
</div>
|
|
542
542
|
<div class="prompt-product-actions">
|
|
543
543
|
<p class="prompt-product-actions-price">
|
|
544
544
|
${(null==(t=this._protectionVariant)?void 0:t.price)&&this._currencyFormat(this._protectionVariant.price)}
|
|
545
545
|
</p>
|
|
546
|
-
${
|
|
546
|
+
${Pt(!this.disableActions,(()=>W`
|
|
547
547
|
<button
|
|
548
548
|
class="prompt-product-actions-button"
|
|
549
549
|
@click=${this._updateProtection}
|
|
550
550
|
?disabled=${this._state.loading}
|
|
551
551
|
>
|
|
552
|
-
${this._state.loading?
|
|
552
|
+
${this._state.loading?At("actions.loading"):this._hasProtectionInCart?At("actions.remove"):W`+ ${At("actions.add")}`}
|
|
553
553
|
</button>
|
|
554
554
|
`))}
|
|
555
555
|
</div>
|
|
556
556
|
</div>
|
|
557
|
-
${
|
|
557
|
+
${Pt(this._state.error,(()=>W`<p class="error">${this._state.error}</p>`))}
|
|
558
558
|
<div class="prompt-footer">
|
|
559
559
|
<a
|
|
560
560
|
class="prompt-footer-badge"
|
|
561
561
|
@click=${()=>{this._popup="learn-more"}}
|
|
562
562
|
>
|
|
563
|
-
<span>${
|
|
564
|
-
${
|
|
563
|
+
<span>${At("footer.button")}</span>
|
|
564
|
+
${Vt}
|
|
565
565
|
</a>
|
|
566
566
|
<button
|
|
567
567
|
class="prompt-footer-about"
|
|
@@ -570,13 +570,9 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
570
570
|
i
|
|
571
571
|
</button>
|
|
572
572
|
</div>
|
|
573
|
-
<div>
|
|
574
|
-
<p>Switch Locales</p>
|
|
575
|
-
${Object.keys(ee).map((t=>{const e=t.replace("./lang/","").replace(".json","");return W`<button @click="${()=>ft(e)}">${e}</button>`}))}
|
|
576
|
-
</div>
|
|
577
573
|
</div>
|
|
578
|
-
`}async connectedCallback(){super.connectedCallback(),await
|
|
574
|
+
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=ct){const i=await e.loader(t,e);e.translationCache={},ut(t,i,e)}(this.lang),this.hasLoadedStrings=!0}render(){return Et(this,(async()=>{var t,e;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[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(o){return Yt(o.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(Ft.LOADED,this._store),setTimeout((async()=>{var t,e,i;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(sessionStorage.getItem(Xt)||(sessionStorage.setItem(Xt,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(i=this._cart)?void 0:i.item_count)&&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))):(Qt("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(Qt("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(Qt("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Et(this,(async()=>{var t,e,i;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const o=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),r=null==(i=this._cart)?void 0:i.items[o];if(this._hasProtectionInCart=!!r,1===this._cart.item_count&&r){const t={id:r.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,!(null==n?void 0:n.id))return this._shouldShowWidget=!1,void Yt("No matching protection variant found.");if(!r)return;if(n.id===r.id){if(this._protectionCartItem={...r,index:o,position:o+1},1===r.quantity)return;const t={id:r.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},l=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(l)}),[this._store,this._cart]),ot(this.learnMorePopupTemplate(),document.body),W`
|
|
579
575
|
<div class="shipaid">
|
|
580
|
-
${
|
|
576
|
+
${Pt(this._hasFinishedSetup,(()=>{var t;return Pt(this._shouldShowWidget&&this.planActive&&(null==(t=this._store)?void 0:t.widgetShowCart),(()=>this.promptTemplate()),(()=>D))}),(()=>W`<p><slot name="loading" default>${At("loading")}</slot></p>`))}
|
|
581
577
|
</div>
|
|
582
|
-
`}},t.ShipAidWidget.styles=
|
|
578
|
+
`}},t.ShipAidWidget.styles=Dt,Jt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),Jt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableActions",2),Jt([o({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),Jt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),Jt([o({type:String,attribute:!0})],t.ShipAidWidget.prototype,"lang",2),Jt([o({type:String,attribute:!0})],t.ShipAidWidget.prototype,"currency",2),Jt([r()],t.ShipAidWidget.prototype,"_storeDomain",2),Jt([r()],t.ShipAidWidget.prototype,"_store",2),Jt([r()],t.ShipAidWidget.prototype,"_cart",2),Jt([r()],t.ShipAidWidget.prototype,"_protectionProduct",2),Jt([r()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),Jt([r()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),Jt([r()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),Jt([r()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),Jt([r()],t.ShipAidWidget.prototype,"_protectionCartItem",2),Jt([r()],t.ShipAidWidget.prototype,"_protectionVariant",2),Jt([r()],t.ShipAidWidget.prototype,"hasLoadedStrings",2),Jt([r()],t.ShipAidWidget.prototype,"_state",2),Jt([r()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=Jt([e("shipaid-widget")],t.ShipAidWidget);const ie="Caricamento del widget ShipAid...",oe="Garanzia di consegna",re="in caso di Perdita, Danno o Furto",se={button:"Offerto da"},ne={add:"Aggiungere",remove:"Rimuovere",loading:"Caricamento ..."},ae={loading:ie,title:oe,description:re,footer:se,actions:ne,"learn-more-popup":{close:"Vicina",title:"Garanzia di consegna",subtitle:"Consentiamo ai tuoi marchi preferiti di offrire una garanzia di consegna perché ogni ordine è prezioso!",disclaimer:{title:"Acquista senza preoccupazioni",subtitle:"I marchi e i corrieri non possono sempre garantire che il tuo ordine arrivi a casa tua in sicurezza. Le cose accadono! Aiutiamo il marchio da cui stai acquistando a sostituire il prodotto che hai ordinato in caso di problemi durante il trasporto. Se riscontri un problema, contatta semplicemente il marchio e lo risolveranno il prima possibile.",text:"Acquistando questa garanzia di consegna, accetti i nostri Termini di servizio e l'Informativa sulla privacy. Non sei obbligato ad acquistare questa garanzia. Questa garanzia NON è un'assicurazione e non fornisce un indennizzo contro perdite, danni o responsabilità derivanti da un evento contingente o sconosciuto, ma piuttosto, attraverso ShipAid i marchi forniscono una garanzia di consegna in base alla quale se il prodotto ordinato non viene consegnato in condizioni soddisfacenti, il marchio da cui hai ordinato il prodotto può sostituire il prodotto gratuitamente. ShipAid non fornisce alcun prodotto o servizio direttamente ai consumatori, ma fornisce invece un servizio che consente ai marchi di facilitare la sostituzione del prodotto ai propri clienti. L'acquisto di questa garanzia non significa che verrai automaticamente rimborsato per qualsiasi prodotto o costo di spedizione perché il processo di risoluzione e la decisione per il risarcimento sono rigorosamente decisi dal marchio da cui stai acquistando. Il marchio richiederà la prova del danno o del prodotto non consegnato."},links:{terms:"Termini di servizio",privacy:"Politica sulla riservatezza"}}},le=Object.freeze(Object.defineProperty({__proto__:null,actions:ne,default:ae,description:re,footer:se,loading:ie,title:oe},Symbol.toStringTag,{value:"Module"}));return Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
|
package/dist/widget.umd.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* Copyright 2019 Google LLC
|
|
25
25
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
26
26
|
*/
|
|
27
|
-
const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),
|
|
27
|
+
const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,l=Symbol(),d=new WeakMap;let p=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==l)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(a&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=d.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&d.set(e,t))}return t}toString(){return this.cssText}};const h=(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 p(i,t,l)},c=a?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new p("string"==typeof t?t:t+"",void 0,l))(e)})(t):t
|
|
28
28
|
/**
|
|
29
29
|
* @license
|
|
30
30
|
* Copyright 2017 Google LLC
|
|
@@ -35,39 +35,39 @@ const n=window,a=n.ShadowRoot&&(void 0===n.ShadyCSS||n.ShadyCSS.nativeShadow)&&"
|
|
|
35
35
|
* Copyright 2017 Google LLC
|
|
36
36
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
37
37
|
*/
|
|
38
|
-
var b;$.finalized=!0,$.elementProperties=new Map,$.elementStyles=[],$.shadowRootOptions={mode:"open"},null==m||m({ReactiveElement:$}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.6.1");const w=window,A=w.trustedTypes,L=A?A.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,z=(t="")=>P.createComment(t),k=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,U=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),j=/'/g,R=/"/g,I=/^(?:script|style|textarea|title)$/i,W=(V=1,(t,...e)=>({_$litType$:V,strings:t,values:e})),H=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),q=new WeakMap,B=P.createTreeWalker(P,129,null,!1);var V;class F{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[l,
|
|
38
|
+
var b;$.finalized=!0,$.elementProperties=new Map,$.elementStyles=[],$.shadowRootOptions={mode:"open"},null==m||m({ReactiveElement:$}),(null!==(u=f.reactiveElementVersions)&&void 0!==u?u:f.reactiveElementVersions=[]).push("1.6.1");const w=window,A=w.trustedTypes,L=A?A.createPolicy("lit-html",{createHTML:t=>t}):void 0,S=`lit$${(Math.random()+"").slice(9)}$`,x="?"+S,E=`<${x}>`,P=document,z=(t="")=>P.createComment(t),k=t=>null===t||"object"!=typeof t&&"function"!=typeof t,T=Array.isArray,M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,O=/-->/g,U=/>/g,N=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),j=/'/g,R=/"/g,I=/^(?:script|style|textarea|title)$/i,W=(V=1,(t,...e)=>({_$litType$:V,strings:t,values:e})),H=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),q=new WeakMap,B=P.createTreeWalker(P,129,null,!1);var V;class F{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[l,d]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=M;for(let l=0;l<i;l++){const e=t[l];let i,a,d=-1,p=0;for(;p<e.length&&(n.lastIndex=p,a=n.exec(e),null!==a);)p=n.lastIndex,n===M?"!--"===a[1]?n=O:void 0!==a[1]?n=U:void 0!==a[2]?(I.test(a[2])&&(r=RegExp("</"+a[2],"g")),n=N):void 0!==a[3]&&(n=N):n===N?">"===a[0]?(n=null!=r?r:M,d=-1):void 0===a[1]?d=-2:(d=n.lastIndex-a[2].length,i=a[1],n=void 0===a[3]?N:'"'===a[3]?R:j):n===R||n===j?n=N:n===O||n===U?n=M:(n=N,r=void 0);const h=n===N&&t[l+1].startsWith("/>")?" ":"";s+=n===M?e+E:d>=0?(o.push(i),e.slice(0,d)+"$lit$"+e.slice(d)+S+h):e+S+(-2===d?(o.push(void 0),l):h)}const a=s+(t[i]||"<?>")+(2===e?"</svg>":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return[void 0!==L?L.createHTML(a):a,o]})(t,e);if(this.el=F.createElement(l,i),B.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=B.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith("$lit$")||e.startsWith(S)){const i=d[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+"$lit$").split(S),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?Q:"?"===e[1]?X:"@"===e[1]?tt:K})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(I.test(o.tagName)){const t=o.textContent.split(S),e=t.length-1;if(e>0){o.textContent=A?A.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],z()),B.nextNode(),a.push({type:2,index:++r});o.append(t[e],z())}}}else if(8===o.nodeType)if(o.data===x)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(S,t+1));)a.push({type:7,index:r}),t+=S.length-1}r++}}static createElement(t,e){const i=P.createElement("template");return i.innerHTML=t,i}}function Z(t,e,i=t,o){var r,s,n,a;if(e===H)return e;let l=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const d=k(e)?void 0:e._$litDirective$;return(null==l?void 0:l.constructor)!==d&&(null===(s=null==l?void 0:l._$AO)||void 0===s||s.call(l,!1),void 0===d?l=void 0:(l=new d(t),l._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=l:i._$Cl=l),void 0!==l&&(e=Z(t,l._$AS(t,e.values),l,o)),e}class G{constructor(t,e){this.u=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}v(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:P).importNode(i,!0);B.currentNode=r;let s=B.nextNode(),n=0,a=0,l=o[0];for(;void 0!==l;){if(n===l.index){let e;2===l.type?e=new J(s,s.nextSibling,this,t):1===l.type?e=new l.ctor(s,l.name,l.strings,this,t):6===l.type&&(e=new et(s,this,t)),this.u.push(e),l=o[++a]}n!==(null==l?void 0:l.index)&&(s=B.nextNode(),n++)}return r}p(t){let e=0;for(const i of this.u)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class J{constructor(t,e,i,o){var r;this.type=2,this._$AH=D,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cm=null===(r=null==o?void 0:o.isConnected)||void 0===r||r}get _$AU(){var t,e;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cm}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===t.nodeType&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=Z(this,t,e),k(t)?t===D||null==t||""===t?(this._$AH!==D&&this._$AR(),this._$AH=D):t!==this._$AH&&t!==H&&this.g(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):(t=>T(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.k(t):this.g(t)}O(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}g(t){this._$AH!==D&&k(this._$AH)?this._$AA.nextSibling.data=t:this.T(P.createTextNode(t)),this._$AH=t}$(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=F.createElement(o.h,this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.p(i);else{const t=new G(r,this),e=t.v(this.options);t.p(i),this.T(e),this._$AH=t}}_$AC(t){let e=q.get(t.strings);return void 0===e&&q.set(t.strings,e=new F(t)),e}k(t){T(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,o=0;for(const r of t)o===e.length?e.push(i=new J(this.O(z()),this.O(z()),this,this.options)):i=e[o],i._$AI(r),o++;o<e.length&&(this._$AR(i&&i._$AB.nextSibling,o),e.length=o)}_$AR(t=this._$AA.nextSibling,e){var i;for(null===(i=this._$AP)||void 0===i||i.call(this,!1,!0,e);t&&t!==this._$AB;){const e=t.nextSibling;t.remove(),t=e}}setConnected(t){var e;void 0===this._$AM&&(this._$Cm=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class K{constructor(t,e,i,o,r){this.type=1,this._$AH=D,this._$AN=void 0,this.element=t,this.name=e,this._$AM=o,this.options=r,i.length>2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,o){const r=this.strings;let s=!1;if(void 0===r)t=Z(this,t,e,0),s=!k(t)||t!==this._$AH&&t!==H,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=Z(this,o[i+n],e,n),a===H&&(a=this._$AH[n]),s||(s=!k(a)||a!==this._$AH[n]),a===D?t=D:t!==D&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===D?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class Q extends K{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===D?void 0:t}}const Y=A?A.emptyScript:"";class X extends K{constructor(){super(...arguments),this.type=4}j(t){t&&t!==D?this.element.setAttribute(this.name,Y):this.element.removeAttribute(this.name)}}class tt extends K{constructor(t,e,i,o,r){super(t,e,i,o,r),this.type=5}_$AI(t,e=this){var i;if((t=null!==(i=Z(this,t,e,0))&&void 0!==i?i:D)===H)return;const o=this._$AH,r=t===D&&o!==D||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==D&&(o===D||r);r&&this.element.removeEventListener(this.name,this,o),s&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e,i;"function"==typeof this._$AH?this._$AH.call(null!==(i=null===(e=this.options)||void 0===e?void 0:e.host)&&void 0!==i?i:this.element,t):this._$AH.handleEvent(t)}}class et{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){Z(this,t)}}const it=w.litHtmlPolyfillSupport;null==it||it(F,J),(null!==(b=w.litHtmlVersions)&&void 0!==b?b:w.litHtmlVersions=[]).push("2.6.1");const ot=(t,e,i)=>{var o,r;const s=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:e;let n=s._$litPart$;if(void 0===n){const t=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:null;s._$litPart$=n=new J(e.insertBefore(z(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
|
|
39
39
|
/**
|
|
40
40
|
* @license
|
|
41
41
|
* Copyright 2017 Google LLC
|
|
42
42
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
43
|
-
*/var rt,st;let nt=class extends ${constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=ot(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return H}};nt.finalized=!0,nt._$litElement$=!0,null===(rt=globalThis.litElementHydrateSupport)||void 0===rt||rt.call(globalThis,{LitElement:nt});const at=globalThis.litElementPolyfillSupport;null==at||at({LitElement:nt}),(null!==(st=globalThis.litElementVersions)&&void 0!==st?st:globalThis.litElementVersions=[]).push("3.2.0");const lt="langChanged";function
|
|
43
|
+
*/var rt,st;let nt=class extends ${constructor(){super(...arguments),this.renderOptions={host:this},this._$Dt=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Dt=ot(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return H}};nt.finalized=!0,nt._$litElement$=!0,null===(rt=globalThis.litElementHydrateSupport)||void 0===rt||rt.call(globalThis,{LitElement:nt});const at=globalThis.litElementPolyfillSupport;null==at||at({LitElement:nt}),(null!==(st=globalThis.litElementVersions)&&void 0!==st?st:globalThis.litElementVersions=[]).push("3.2.0");const lt="langChanged";function dt(t,e,i){return Object.entries(ht(e||{})).reduce(((t,[e,i])=>t.replace(new RegExp(`{{[ ]*${e}[ ]*}}`,"gm"),String(ht(i)))),t)}function pt(t,e){const i=t.split(".");let o=e.strings;for(;null!=o&&i.length>0;)o=o[i.shift()];return null!=o?o.toString():null}function ht(t){return"function"==typeof t?t():t}let ct={loader:()=>Promise.resolve({}),empty:t=>`[${t}]`,lookup:pt,interpolate:dt,translationCache:{}};function ut(t,e,i=ct){var o;o={previousStrings:i.strings,previousLang:i.lang,lang:i.lang=t,strings:i.strings=e},window.dispatchEvent(new CustomEvent(lt,{detail:o}))}
|
|
44
44
|
/**
|
|
45
45
|
* @license
|
|
46
46
|
* Copyright 2017 Google LLC
|
|
47
47
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
48
48
|
*/
|
|
49
|
-
const
|
|
49
|
+
const ft=2;class gt{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,i){this._$Ct=t,this._$AM=e,this._$Ci=i}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}}
|
|
50
50
|
/**
|
|
51
51
|
* @license
|
|
52
52
|
* Copyright 2020 Google LLC
|
|
53
53
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
54
|
-
*/const
|
|
54
|
+
*/const vt=(t,e)=>{var i,o;const r=t._$AN;if(void 0===r)return!1;for(const s of r)null===(o=(i=s)._$AO)||void 0===o||o.call(i,e,!1),vt(s,e);return!0},mt=t=>{let e,i;do{if(void 0===(e=t._$AM))break;i=e._$AN,i.delete(t),t=e}while(0===(null==i?void 0:i.size))},_t=t=>{for(let e;e=t._$AM;t=e){let i=e._$AN;if(void 0===i)e._$AN=i=new Set;else if(i.has(t))break;i.add(t),$t(e)}};
|
|
55
55
|
/**
|
|
56
56
|
* @license
|
|
57
57
|
* Copyright 2017 Google LLC
|
|
58
58
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
59
|
-
*/function
|
|
59
|
+
*/function yt(t){void 0!==this._$AN?(mt(this),this._$AM=t,_t(this)):this._$AM=t}function Ct(t,e=!1,i=0){const o=this._$AH,r=this._$AN;if(void 0!==r&&0!==r.size)if(e)if(Array.isArray(o))for(let s=i;s<o.length;s++)vt(o[s],!1),mt(o[s]);else null!=o&&(vt(o,!1),mt(o));else vt(this,t)}const $t=t=>{var e,i,o,r;t.type==ft&&(null!==(e=(o=t)._$AP)&&void 0!==e||(o._$AP=Ct),null!==(i=(r=t)._$AQ)&&void 0!==i||(r._$AQ=yt))};class bt extends gt{constructor(){super(...arguments),this._$AN=void 0}_$AT(t,e,i){super._$AT(t,e,i),_t(this),this.isConnected=t._$AU}_$AO(t,e=!0){var i,o;t!==this.isConnected&&(this.isConnected=t,t?null===(i=this.reconnected)||void 0===i||i.call(this):null===(o=this.disconnected)||void 0===o||o.call(this)),e&&(vt(this,t),mt(this))}setValue(t){if(void 0===this._$Ct.strings)this._$Ct._$AI(t,this);else{const e=[...this._$Ct._$AH];e[this._$Ci]=t,this._$Ct._$AI(e,this,0)}}disconnected(){}reconnected(){}}class wt extends bt{constructor(){super(...arguments),this.langChangedSubscription=null,this.getValue=()=>""}renderValue(t){return this.getValue=t,this.subscribe(),this.getValue()}langChanged(t){this.setValue(this.getValue(t))}subscribe(){null==this.langChangedSubscription&&(this.langChangedSubscription=function(t,e){const i=e=>t(e.detail);return window.addEventListener(lt,i,e),()=>window.removeEventListener(lt,i)}(this.langChanged.bind(this)))}unsubscribe(){null!=this.langChangedSubscription&&this.langChangedSubscription()}disconnected(){this.unsubscribe()}reconnected(){this.subscribe()}}const At=(t=>(...e)=>({_$litDirective$:t,values:e}))(class extends wt{render(t,e,i){return this.renderValue((()=>function(t,e,i=ct){let o=i.translationCache[t]||(i.translationCache[t]=i.lookup(t,i)||i.empty(t,i));return null!=(e=null!=e?ht(e):null)?i.interpolate(o,e,i):o}(t,e,i)))}});
|
|
60
60
|
/**
|
|
61
61
|
* @license
|
|
62
62
|
* Copyright 2017 Google LLC
|
|
63
63
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
64
|
-
*/class
|
|
64
|
+
*/class Lt extends gt{constructor(t){if(super(t),this.it=D,t.type!==ft)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(t){if(t===D||null==t)return this._t=void 0,this.it=t;if(t===H)return t;if("string"!=typeof t)throw Error(this.constructor.directiveName+"() called with a non-string value");if(t===this.it)return this._t;this.it=t;const e=[t];return e.raw=e,this._t={_$litType$:this.constructor.resultType,strings:e,values:[]}}}Lt.directiveName="unsafeHTML",Lt.resultType=1;const St="__registered_effects";function xt(t){const e=t;if(e[St])return e;const i=function(t){if(!t.dispatchEvent||!t.requestUpdate)throw new Error("Element missing required functions (dispatchEvent/requestUpdate)");return t}(t),o=i.updated;return e[St]={index:0,count:0,effects:[]},i.updated=t=>(e[St].index=0,o(t)),e}function Et(t,e,i){const o=function(t,e){const i=xt(t),{index:o,count:r}=i[St];return o===r?(i[St].index++,i[St].count++,i[St].effects.push(e),e):(i[St].index++,i[St].effects[o])}(t,{on:e,observe:["__initial__dirty"]});o.observe.some(((t,e)=>i[e]!==t))&&o.on(),o.observe=i}
|
|
65
65
|
/**
|
|
66
66
|
* @license
|
|
67
67
|
* Copyright 2021 Google LLC
|
|
68
68
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
69
69
|
*/
|
|
70
|
-
function
|
|
70
|
+
function Pt(t,e,i){return t?e():null==i?void 0:i()}const zt=h`
|
|
71
71
|
:host {
|
|
72
72
|
--shipaid-primary: #002bd6;
|
|
73
73
|
--shipaid-secondary: #0076ff;
|
|
@@ -199,30 +199,30 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
199
199
|
font-size: var(--shipaid-font-sm);
|
|
200
200
|
color: var(--shipaid-text);
|
|
201
201
|
}
|
|
202
|
-
`;var
|
|
202
|
+
`;var kt=Object.defineProperty,Tt=Object.getOwnPropertyDescriptor,Mt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?Tt(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&&kt(e,i,s),s};let Ot=class extends nt{constructor(){super(...arguments),this.active=!1}handleClosePopup(){const t=new Event("close");this.dispatchEvent(t)}render(){return W`
|
|
203
203
|
<div class=${`shipaid-popup ${this.active&&"active"}`}>
|
|
204
204
|
<button
|
|
205
205
|
type="button"
|
|
206
206
|
class="popup-close"
|
|
207
207
|
@click=${this.handleClosePopup}
|
|
208
208
|
>
|
|
209
|
-
${
|
|
209
|
+
${At("learn-more-popup.close")}
|
|
210
210
|
</button>
|
|
211
|
-
<p class="popup-title">${
|
|
211
|
+
<p class="popup-title">${At("learn-more-popup.title")}</p>
|
|
212
212
|
<p>
|
|
213
|
-
${
|
|
213
|
+
${At("learn-more-popup.subtitle")}
|
|
214
214
|
</p>
|
|
215
215
|
<img
|
|
216
216
|
src="https://res.cloudinary.com/dxyz34kfj/image/upload/v1660782754/shipaid-image_hoz6k8.jpg"
|
|
217
217
|
alt="shipaid protected parcel"
|
|
218
218
|
class="popup-top-image"
|
|
219
219
|
/>
|
|
220
|
-
<p class="popup-title">${
|
|
220
|
+
<p class="popup-title">${At("learn-more-popup.disclaimer.title")}</p>
|
|
221
221
|
<p>
|
|
222
|
-
${
|
|
222
|
+
${At("learn-more-popup.disclaimer.subtitle")}
|
|
223
223
|
</p>
|
|
224
224
|
<p class="popup-disclaimer">
|
|
225
|
-
${
|
|
225
|
+
${At("learn-more-popup.disclaimer.text")}
|
|
226
226
|
</p>
|
|
227
227
|
<div class="popup-footer">
|
|
228
228
|
<div class="footer-links">
|
|
@@ -231,14 +231,14 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
231
231
|
target="_blank"
|
|
232
232
|
rel="noreferrer"
|
|
233
233
|
>
|
|
234
|
-
${
|
|
234
|
+
${At("learn-more-popup.links.terms")}
|
|
235
235
|
</a>
|
|
236
236
|
<a
|
|
237
237
|
href="https://www.shipaid.com/privacy-policy"
|
|
238
238
|
target="_blank"
|
|
239
239
|
rel="noreferrer"
|
|
240
240
|
>
|
|
241
|
-
${
|
|
241
|
+
${At("learn-more-popup.links.privacy")}
|
|
242
242
|
</a>
|
|
243
243
|
</div>
|
|
244
244
|
<div class="footer-date">
|
|
@@ -246,7 +246,7 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
246
246
|
</div>
|
|
247
247
|
</div>
|
|
248
248
|
</div>
|
|
249
|
-
`}};
|
|
249
|
+
`}};Ot.styles=zt,Mt([o({type:Boolean,attribute:!0})],Ot.prototype,"active",2),Ot=Mt([e("shipaid-popup-learn-more")],Ot);const Ut="Loading ShipAid Widget...",Nt="Delivery Guarantee",jt="in case of Loss, Damage or Theft",Rt={button:"Powered by"},It={add:"Add",remove:"Remove",loading:"Loading..."},Wt={loading:Ut,title:Nt,description:jt,footer:Rt,actions:It,"learn-more-popup":{close:"Close",title:"Delivery Guarantee",subtitle:"We empower your favorite brands to offer a delivery guarantee because every order is precious!",disclaimer:{title:"Shop Worry-Free",subtitle:"Brands and shipment carriers cannot always guarantee your order will arrive at your doorstep safely. Things happen! We help the brand you are purchasing from replace the product you ordered in the chance of an issue in transit. If you encounter an issue, simply reach out to the brand and they will get it resolved as soon as possible.",text:"By purchasing this delivery guarantee, you agree to our Terms Of Service and Privacy Policy. You are not obligated to purchase this guarantee. This guarantee is NOT insurance and does not provide indemnification against loss, damage, or liability arising from a contingent or unknown event, but rather, through ShipAid brands provide a delivery guarantee whereby if the product you ordered is not delivered in satisfactory condition, the brand from which you ordered the product may replace the product free of charge. ShipAid does not provide any products or services directly to consumers, but instead provides a service that allow brands to facilitate product replacement to their customers. Purchasing this guarantee does not mean that you will automatically be reimbursed for any product or shipping costs because the resolution process and decision for compensation is strictly decided by the brand you a purchasing from. The brand will require proof of damage or undelivered product."},links:{terms:"Terms of Service",privacy:"Privacy Policy"}}},Ht=Object.freeze(Object.defineProperty({__proto__:null,actions:It,default:Wt,description:jt,footer:Rt,loading:Ut,title:Nt},Symbol.toStringTag,{value:"Module"})),Dt=h`
|
|
250
250
|
:host {
|
|
251
251
|
--shipaid-primary: #002bd6;
|
|
252
252
|
--shipaid-secondary: #0076ff;
|
|
@@ -392,14 +392,14 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
392
392
|
.shipaid-prompt .prompt-footer .prompt-footer-badge svg {
|
|
393
393
|
height: 9px;
|
|
394
394
|
}
|
|
395
|
-
`,
|
|
395
|
+
`,qt=W`
|
|
396
396
|
<svg viewBox="0 0 453 511" version="1.1" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
|
|
397
397
|
<g transform="matrix(1,0,0,1,-29.4375,-0.984384)">
|
|
398
398
|
<path d="M468.297,67.385L262.417,2C258.177,0.646 253.63,0.646 249.391,2L43.51,67.385C35.188,69.708 29.438,77.318 29.438,85.979C32.302,157.156 52.266,370.036 52.266,370.036C52.906,378.188 57.297,385.568 64.167,390.01L248.807,509.156C253.12,511.943 258.688,511.943 263.005,509.156L447.641,390.01C454.51,385.568 458.901,378.188 459.542,370.036C459.542,370.036 479.51,157.156 482.37,85.979C482.37,77.318 476.625,69.708 468.297,67.385" style="fill:rgb(47,52,61);fill-rule:nonzero;"/>
|
|
399
399
|
<path d="M256.01,120.969C286.193,120.969 314.057,130.87 336.536,147.604L309.406,174.656C294.073,164.573 275.729,158.708 256.01,158.708C229.141,158.708 204.823,169.604 187.214,187.198C169.615,204.797 158.719,229.125 158.719,255.995C158.719,282.865 169.615,307.182 187.214,324.792C204.813,342.406 229.141,353.286 256.01,353.286C282.88,353.286 307.208,342.406 324.807,324.792C342.406,307.193 353.297,282.865 353.297,255.995C353.297,251.818 353.036,247.719 352.526,243.688L383.859,212.458C388.51,226.115 391.036,240.766 391.036,255.995C391.036,293.286 375.927,327.047 351.49,351.479C327.057,375.911 293.302,391.021 256.01,391.021C218.729,391.021 184.964,375.911 160.526,351.479C136.094,327.047 120.984,293.286 120.984,255.995C120.984,218.719 136.094,184.948 160.526,160.516C184.964,136.083 218.719,120.969 256.01,120.969ZM218.141,220.906L253.615,259.729L354.844,158.813L381.375,185.484L252.396,314.068L190.422,246.255L218.13,220.906L218.141,220.906Z" style="fill:white;fill-rule:nonzero;"/>
|
|
400
400
|
</g>
|
|
401
401
|
</svg>
|
|
402
|
-
`,
|
|
402
|
+
`,Bt=W`
|
|
403
403
|
<svg
|
|
404
404
|
viewBox="0 0 384 383.999986"
|
|
405
405
|
preserveAspectRatio="xMidYMid meet"
|
|
@@ -441,7 +441,7 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
441
441
|
/>
|
|
442
442
|
</g>
|
|
443
443
|
</svg>
|
|
444
|
-
`,
|
|
444
|
+
`,Vt=W`
|
|
445
445
|
<svg
|
|
446
446
|
viewBox="0 0 423 62"
|
|
447
447
|
version="1.1"
|
|
@@ -523,45 +523,45 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
523
523
|
/>
|
|
524
524
|
</g>
|
|
525
525
|
</svg>
|
|
526
|
-
`;var
|
|
526
|
+
`;var Ft=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(Ft||{}),Zt=Object.defineProperty,Gt=Object.getOwnPropertyDescriptor,Jt=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?Gt(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&&Zt(e,i,s),s};const Kt=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),new Error("Failed to complete fetch request.")}},Qt=t=>console.warn(`[ShipAid] ${t}`),Yt=t=>console.error(`[ShipAid] ${t}`),Xt="shipaid-protection",te=Object.assign({"./lang/en.json":()=>Promise.resolve().then((()=>Ht)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>le)).then((t=>t.default))});var ee;ee={loader:async t=>{if("en"===t)return Wt;const e=Reflect.get(te,`./lang/${t}.json`);return e?await e():Wt}},ct=Object.assign(Object.assign({},ct),ee),t.ShipAidWidget=class extends nt{constructor(){var t,e,i;super(...arguments),this.disablePolling=!1,this.disableActions=!1,this.pollingInterval=2500,this.disableRefresh=!1,this.lang="en",this.currency=void 0,this._apiEndpoint="/apps/shipaid",this._storeDomain=(null==(t=window.Shopify)?void 0:t.shop)??(null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost),this._hasFinishedSetup=!1,this._shouldShowWidget=!0,this._hasProtectionInCart=!1,this.hasLoadedStrings=!1,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>Kt(t),post:(t,e)=>Kt(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(Qt("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o;return new Intl.NumberFormat(void 0,{currency:this.currency||(null==(e=this._store)?void 0:e.currency)||(null==(o=null==(i=window.Shopify)?void 0:i.currency)?void 0:o.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(Ft.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){var e,i,o,r,s,n;if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing store settings.");const a=null==(e=this._store)?void 0:e.protectionSettings;if(!a||!this._protectionProduct)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const l=Array.isArray(null==(i=this._store)?void 0:i.excludedProductSkus)?null==(o=this._store)?void 0:o.excludedProductSkus.map((t=>t.trim())):[],d=((null==(r=t.items)?void 0:r.reduce(((t,e)=>{if(!e.sku)return t;return l.some((t=>t===e.sku.trim()))?t-e.final_line_price:t}),t.total_price))??t.total_price)-((null==(s=t.items)?void 0:s.filter((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))??[]).reduce(((t,e)=>t+e.final_line_price),0);if("FIXED"===a.protectionType){if("number"!=typeof a.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(n=a.rules)?void 0:n.length))return a.defaultFee;const t=d/100,e=a.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:a.defaultFee}if("PERCENTAGE"===a.protectionType){const t=d*a.percentage/100;return t>=a.minimumFee?t:a.minimumFee}throw new Error("No protection type handler found for this store.")}_findProtectionVariant(t){var e,i,o,r;if(!(null==(e=this._store)?void 0:e.protectionSettings)||!(null==(o=null==(i=this._protectionProduct)?void 0:i.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const s=null==(r=this._protectionProduct)?void 0:r.variants.flatMap((t=>{if(!t||!t.price)return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),n=s.find((e=>e.formattedPrice>=t));return n||s[s.length-1]}_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(){var t,e,i,o,r;const s=(null==(t=window.Shopify)?void 0:t.shop)??(null==(i=null==(e=window.Shopify)?void 0:e.Checkout)?void 0:i.apiHost);if(!s)throw new Error("No shop found in Shopify object.");try{const t=new URL(window.location.href);t.pathname=this._apiEndpoint;const e={query:"query StoreByDomain ($store: String!) {\n store: storeByDomain (input: {store: $store}) {\n currency\n planActive\n store\n widgetAutoOptIn\n widgetShowCart\n excludedProductSkus\n protectionSettings\n }\n}",variables:{store:s}},i=await this._fetch.post(t.toString(),e);if(!i)throw new Error("Missing response for store query.");if(null==(o=i.errors)?void 0:o.length)throw new Error(i.errors[0].message);if(!(null==(r=i.data)?void 0:r.store))throw new Error("Missing store from store query response.");return i.data.store}catch(n){throw console.error(n),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw Yt(t.message),new Error("Could not fetch cart for current domain.")}}async _fetchProduct(){try{const{product:t}=await this._fetch.get("/products/shipaid-protection.json");return t}catch(t){throw Yt(t.message),new Error("Could not fetch protection product for current domain.")}}hasProtection(){return this._hasProtectionInCart}async updateCart(t){t||(t=await this._fetchCart()),this._cart=t}async addProtection(){var t,e;try{if(!this._store)throw new Error("Store has not been loaded.");if(!(null==(t=this._cart)?void 0:t.items))throw new Error("Cart has not been loaded.");if(!(null==(e=this._protectionVariant)?void 0:e.id))throw new Error("No protection variant found.");this._setState("loading");const i={quantity:1,id:this._protectionVariant.id},o=await this._fetch.post("/cart/add.js",i);await this._handleRefresh(o),this._setState("success")}catch(i){Yt(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){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={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){Yt(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}learnMorePopupTemplate(){return W`
|
|
527
527
|
<shipaid-popup-learn-more ?active=${"learn-more"===this._popup} @close=${()=>{this._popup=null}}></shipaid-popup-learn-more>
|
|
528
528
|
`}promptTemplate(){var t;return W`
|
|
529
529
|
<div class="shipaid-prompt">
|
|
530
530
|
<div class="prompt-product">
|
|
531
531
|
<div class="prompt-product-image">
|
|
532
|
-
${
|
|
532
|
+
${Pt(this._hasProtectionInCart,(()=>qt),(()=>Bt))}
|
|
533
533
|
</div>
|
|
534
534
|
<div class="prompt-product-details">
|
|
535
535
|
<p class="prompt-product-details-title">
|
|
536
|
-
<slot name="title">${
|
|
536
|
+
<slot name="title">${At("title")}</slot>
|
|
537
537
|
</p>
|
|
538
538
|
<p class="prompt-product-details-description">
|
|
539
|
-
<slot name="subtitle">${
|
|
539
|
+
<slot name="subtitle">${At("description")}</slot>
|
|
540
540
|
</p>
|
|
541
541
|
</div>
|
|
542
542
|
<div class="prompt-product-actions">
|
|
543
543
|
<p class="prompt-product-actions-price">
|
|
544
544
|
${(null==(t=this._protectionVariant)?void 0:t.price)&&this._currencyFormat(this._protectionVariant.price)}
|
|
545
545
|
</p>
|
|
546
|
-
${
|
|
546
|
+
${Pt(!this.disableActions,(()=>W`
|
|
547
547
|
<button
|
|
548
548
|
class="prompt-product-actions-button"
|
|
549
549
|
@click=${this._updateProtection}
|
|
550
550
|
?disabled=${this._state.loading}
|
|
551
551
|
>
|
|
552
|
-
${this._state.loading?
|
|
552
|
+
${this._state.loading?At("actions.loading"):this._hasProtectionInCart?At("actions.remove"):W`+ ${At("actions.add")}`}
|
|
553
553
|
</button>
|
|
554
554
|
`))}
|
|
555
555
|
</div>
|
|
556
556
|
</div>
|
|
557
|
-
${
|
|
557
|
+
${Pt(this._state.error,(()=>W`<p class="error">${this._state.error}</p>`))}
|
|
558
558
|
<div class="prompt-footer">
|
|
559
559
|
<a
|
|
560
560
|
class="prompt-footer-badge"
|
|
561
561
|
@click=${()=>{this._popup="learn-more"}}
|
|
562
562
|
>
|
|
563
|
-
<span>${
|
|
564
|
-
${
|
|
563
|
+
<span>${At("footer.button")}</span>
|
|
564
|
+
${Vt}
|
|
565
565
|
</a>
|
|
566
566
|
<button
|
|
567
567
|
class="prompt-footer-about"
|
|
@@ -570,13 +570,9 @@ function zt(t,e,i){return t?e():null==i?void 0:i()}const kt=h`
|
|
|
570
570
|
i
|
|
571
571
|
</button>
|
|
572
572
|
</div>
|
|
573
|
-
<div>
|
|
574
|
-
<p>Switch Locales</p>
|
|
575
|
-
${Object.keys(ee).map((t=>{const e=t.replace("./lang/","").replace(".json","");return W`<button @click="${()=>ft(e)}">${e}</button>`}))}
|
|
576
|
-
</div>
|
|
577
573
|
</div>
|
|
578
|
-
`}async connectedCallback(){super.connectedCallback(),await
|
|
574
|
+
`}async connectedCallback(){super.connectedCallback(),await async function(t,e=ct){const i=await e.loader(t,e);e.translationCache={},ut(t,i,e)}(this.lang),this.hasLoadedStrings=!0}render(){return Et(this,(async()=>{var t,e;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[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(o){return Yt(o.message),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)}return this.planActive?(null==(e=null==(t=this._store)?void 0:t.protectionSettings)?void 0:e.protectionType)?this._protectionProduct?(this._hasFinishedSetup=!0,this._shouldShowWidget=!0,this._dispatchEvent(Ft.LOADED,this._store),setTimeout((async()=>{var t,e,i;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(sessionStorage.getItem(Xt)||(sessionStorage.setItem(Xt,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(i=this._cart)?void 0:i.item_count)&&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))):(Qt("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(Qt("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(Qt("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Et(this,(async()=>{var t,e,i;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const o=null==(e=this._cart.items)?void 0:e.findIndex((t=>{var e,i;return null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})),r=null==(i=this._cart)?void 0:i.items[o];if(this._hasProtectionInCart=!!r,1===this._cart.item_count&&r){const t={id:r.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const s=await this.calculateProtectionTotal(this._cart),n=this._findProtectionVariant(s);if(this._protectionVariant=n,!(null==n?void 0:n.id))return this._shouldShowWidget=!1,void Yt("No matching protection variant found.");if(!r)return;if(n.id===r.id){if(this._protectionCartItem={...r,index:o,position:o+1},1===r.quantity)return;const t={id:r.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},l=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(l)}),[this._store,this._cart]),ot(this.learnMorePopupTemplate(),document.body),W`
|
|
579
575
|
<div class="shipaid">
|
|
580
|
-
${
|
|
576
|
+
${Pt(this._hasFinishedSetup,(()=>{var t;return Pt(this._shouldShowWidget&&this.planActive&&(null==(t=this._store)?void 0:t.widgetShowCart),(()=>this.promptTemplate()),(()=>D))}),(()=>W`<p><slot name="loading" default>${At("loading")}</slot></p>`))}
|
|
581
577
|
</div>
|
|
582
|
-
`}},t.ShipAidWidget.styles=
|
|
578
|
+
`}},t.ShipAidWidget.styles=Dt,Jt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),Jt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableActions",2),Jt([o({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),Jt([o({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),Jt([o({type:String,attribute:!0})],t.ShipAidWidget.prototype,"lang",2),Jt([o({type:String,attribute:!0})],t.ShipAidWidget.prototype,"currency",2),Jt([r()],t.ShipAidWidget.prototype,"_storeDomain",2),Jt([r()],t.ShipAidWidget.prototype,"_store",2),Jt([r()],t.ShipAidWidget.prototype,"_cart",2),Jt([r()],t.ShipAidWidget.prototype,"_protectionProduct",2),Jt([r()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),Jt([r()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),Jt([r()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),Jt([r()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),Jt([r()],t.ShipAidWidget.prototype,"_protectionCartItem",2),Jt([r()],t.ShipAidWidget.prototype,"_protectionVariant",2),Jt([r()],t.ShipAidWidget.prototype,"hasLoadedStrings",2),Jt([r()],t.ShipAidWidget.prototype,"_state",2),Jt([r()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=Jt([e("shipaid-widget")],t.ShipAidWidget);const ie="Caricamento del widget ShipAid...",oe="Garanzia di consegna",re="in caso di Perdita, Danno o Furto",se={button:"Offerto da"},ne={add:"Aggiungere",remove:"Rimuovere",loading:"Caricamento ..."},ae={loading:ie,title:oe,description:re,footer:se,actions:ne,"learn-more-popup":{close:"Vicina",title:"Garanzia di consegna",subtitle:"Consentiamo ai tuoi marchi preferiti di offrire una garanzia di consegna perché ogni ordine è prezioso!",disclaimer:{title:"Acquista senza preoccupazioni",subtitle:"I marchi e i corrieri non possono sempre garantire che il tuo ordine arrivi a casa tua in sicurezza. Le cose accadono! Aiutiamo il marchio da cui stai acquistando a sostituire il prodotto che hai ordinato in caso di problemi durante il trasporto. Se riscontri un problema, contatta semplicemente il marchio e lo risolveranno il prima possibile.",text:"Acquistando questa garanzia di consegna, accetti i nostri Termini di servizio e l'Informativa sulla privacy. Non sei obbligato ad acquistare questa garanzia. Questa garanzia NON è un'assicurazione e non fornisce un indennizzo contro perdite, danni o responsabilità derivanti da un evento contingente o sconosciuto, ma piuttosto, attraverso ShipAid i marchi forniscono una garanzia di consegna in base alla quale se il prodotto ordinato non viene consegnato in condizioni soddisfacenti, il marchio da cui hai ordinato il prodotto può sostituire il prodotto gratuitamente. ShipAid non fornisce alcun prodotto o servizio direttamente ai consumatori, ma fornisce invece un servizio che consente ai marchi di facilitare la sostituzione del prodotto ai propri clienti. L'acquisto di questa garanzia non significa che verrai automaticamente rimborsato per qualsiasi prodotto o costo di spedizione perché il processo di risoluzione e la decisione per il risarcimento sono rigorosamente decisi dal marchio da cui stai acquistando. Il marchio richiederà la prova del danno o del prodotto non consegnato."},links:{terms:"Termini di servizio",privacy:"Politica sulla riservatezza"}}},le=Object.freeze(Object.defineProperty({__proto__:null,actions:ne,default:ae,description:re,footer:se,loading:ie,title:oe},Symbol.toStringTag,{value:"Module"}));Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}));
|