ui.shipaid.com 0.3.25 → 0.3.26

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  function calculateProtectionTotal(store, protectionProduct, cart) {
2
- var _a, _b, _c;
2
+ var _a, _b;
3
3
  if (!store)
4
4
  throw new Error("Missing store settings.");
5
5
  if (!protectionProduct)
@@ -10,23 +10,34 @@ function calculateProtectionTotal(store, protectionProduct, cart) {
10
10
  if (!settings) {
11
11
  throw new Error("Tried to find protection variant, but protection settings for this store are missing.");
12
12
  }
13
- const excludedProductSkus = Array.isArray(store == null ? void 0 : store.excludedProductSkus) ? store == null ? void 0 : store.excludedProductSkus.map((sku) => sku.trim()) : [];
14
- const itemTotal = ((_a = cart.items) == null ? void 0 : _a.reduce((total, item) => {
15
- if (!item.sku)
16
- return total;
17
- const itemIsExcluded = excludedProductSkus.some((sku) => sku === item.sku.trim());
18
- return itemIsExcluded ? total - item.final_line_price : total;
19
- }, cart.total_price)) ?? cart.total_price;
20
- const protectionVariantsInCart = ((_b = cart.items) == null ? void 0 : _b.filter((item) => {
13
+ const excludedProductSkus = Array.isArray(store == null ? void 0 : store.excludedProductSkus) ? store.excludedProductSkus.map((sku) => sku.trim()) : [];
14
+ const excludedProductIds = Array.isArray(store == null ? void 0 : store.excludedProductsVariantsId) ? store.excludedProductsVariantsId.map((id) => {
15
+ var _a2;
16
+ return parseInt(((_a2 = id.match(/\d+/)) == null ? void 0 : _a2[0]) || "", 10);
17
+ }) : [];
18
+ const isItemExcluded = (item) => {
19
+ if (item.sku && excludedProductSkus.includes(item.sku.trim())) {
20
+ return true;
21
+ } else if (item.variant_id && excludedProductIds.includes(item.variant_id)) {
22
+ return true;
23
+ }
24
+ return false;
25
+ };
26
+ const itemTotal = (cart.items || []).reduce((total, item) => {
27
+ return isItemExcluded(item) ? total - item.final_line_price : total;
28
+ }, cart.total_price || 0);
29
+ const protectionVariantsInCart = ((_a = cart.items) == null ? void 0 : _a.filter((item) => {
21
30
  var _a2;
22
31
  return (_a2 = protectionProduct == null ? void 0 : protectionProduct.variants) == null ? void 0 : _a2.some((variant) => variant.id === item.variant_id);
23
32
  })) ?? [];
24
33
  const protectionVariantsInCartTotal = protectionVariantsInCart.reduce((total, item) => total + item.final_line_price, 0);
25
34
  const cartTotal = itemTotal - protectionVariantsInCartTotal;
35
+ if (cartTotal === 0)
36
+ return cartTotal;
26
37
  if (settings.protectionType === "FIXED") {
27
38
  if (typeof settings.defaultFee !== "number")
28
39
  throw new Error("Missing default fee amount.");
29
- if (!((_c = settings.rules) == null ? void 0 : _c.length))
40
+ if (!((_b = settings.rules) == null ? void 0 : _b.length))
30
41
  return settings.defaultFee;
31
42
  const formattedCartTotal = cartTotal / 100;
32
43
  const sortedRules = settings.rules.sort((a2, b) => {
@@ -1717,7 +1728,7 @@ const styles = i$2`
1717
1728
  .prompt-product-actions
1718
1729
  .prompt-product-actions-price {
1719
1730
  color: var(--shipaid-prompt-actions-price-color, var(--shipaid-text-muted));
1720
- font-size: var(--shipaid-font-base);
1731
+ font-size: var(--shipaid-prompt-actions-price-fontSize, --shipaid-font-base);
1721
1732
  }
1722
1733
  .shipaid-prompt
1723
1734
  .prompt-product
@@ -1854,7 +1865,7 @@ let ShipAidWidget = class extends s$1 {
1854
1865
  this._apiEndpoint = "/apps/shipaid";
1855
1866
  this._storeDomain = ((_a = window.Shopify) == null ? void 0 : _a.shop) ?? ((_c = (_b = window.Shopify) == null ? void 0 : _b.Checkout) == null ? void 0 : _c.apiHost);
1856
1867
  this._hasFinishedSetup = false;
1857
- this._shouldShowWidget = true;
1868
+ this._shouldShowWidget = false;
1858
1869
  this._hasProtectionInCart = false;
1859
1870
  this.hasLoadedStrings = false;
1860
1871
  this.intervalId = 0;
@@ -1905,9 +1916,14 @@ let ShipAidWidget = class extends s$1 {
1905
1916
  }
1906
1917
  // ? Internal Helpers
1907
1918
  _currencyFormat(value) {
1908
- var _a, _b, _c;
1919
+ var _a, _b, _c, _d, _e, _f;
1920
+ const currency = this.currency || ((_b = (_a = window.Shopify) == null ? void 0 : _a.currency) == null ? void 0 : _b.active) || ((_c = this._store) == null ? void 0 : _c.currency) || "USD";
1921
+ if ((_f = (_e = (_d = this._store) == null ? void 0 : _d.widgetConfigurations) == null ? void 0 : _e.widget) == null ? void 0 : _f.currencyFormat) {
1922
+ const format = this._store.widgetConfigurations.widget.currencyFormat;
1923
+ return format.replace("_value_", Number(value)).replace("_currency_", currency);
1924
+ }
1909
1925
  return new Intl.NumberFormat(void 0, {
1910
- currency: this.currency || ((_b = (_a = window.Shopify) == null ? void 0 : _a.currency) == null ? void 0 : _b.active) || ((_c = this._store) == null ? void 0 : _c.currency) || "USD",
1926
+ currency,
1911
1927
  style: "currency"
1912
1928
  }).format(Number(value));
1913
1929
  }
@@ -2314,7 +2330,6 @@ let ShipAidWidget = class extends s$1 {
2314
2330
  return;
2315
2331
  }
2316
2332
  this._hasFinishedSetup = true;
2317
- this._shouldShowWidget = true;
2318
2333
  this._dispatchEvent(Events.LOADED, this._store);
2319
2334
  setTimeout(async () => {
2320
2335
  var _a2, _b2, _c2, _d2;
@@ -2368,7 +2383,7 @@ let ShipAidWidget = class extends s$1 {
2368
2383
  useEffect(
2369
2384
  this,
2370
2385
  async () => {
2371
- var _a, _b, _c;
2386
+ var _a, _b, _c, _d;
2372
2387
  this._cartLastUpdated = /* @__PURE__ */ new Date();
2373
2388
  if (!((_a = this._cart) == null ? void 0 : _a.items))
2374
2389
  return;
@@ -2380,7 +2395,10 @@ let ShipAidWidget = class extends s$1 {
2380
2395
  });
2381
2396
  const protectionCartItem = (_c = this._cart) == null ? void 0 : _c.items[protectionCartItemIndex];
2382
2397
  this._hasProtectionInCart = !!protectionCartItem;
2383
- if (this._cart.item_count === 1 && !!protectionCartItem) {
2398
+ if (!this._store)
2399
+ return;
2400
+ const protectionFee = await this.calculateProtectionTotal(this._cart);
2401
+ if (this._cart.item_count > 0 && !!protectionCartItem && (this._cart.total_price === protectionCartItem.final_line_price || !protectionFee)) {
2384
2402
  const removePayload = {
2385
2403
  id: protectionCartItem.key,
2386
2404
  quantity: 0
@@ -2392,16 +2410,25 @@ let ShipAidWidget = class extends s$1 {
2392
2410
  sessionStorage.removeItem(LOCAL_STORAGE_KEY);
2393
2411
  return await this._handleRefresh(cart2);
2394
2412
  }
2395
- if (!this._store)
2396
- return;
2397
- const protectionFee = await this.calculateProtectionTotal(this._cart);
2398
2413
  const protectionVariant = this._findProtectionVariant(protectionFee);
2399
- this._protectionVariant = protectionVariant;
2414
+ if (!protectionFee) {
2415
+ this._protectionVariant = {
2416
+ id: 0,
2417
+ price: "0"
2418
+ };
2419
+ } else {
2420
+ this._protectionVariant = protectionVariant;
2421
+ this._shouldShowWidget = true;
2422
+ }
2400
2423
  if (!(protectionVariant == null ? void 0 : protectionVariant.id)) {
2401
2424
  this._shouldShowWidget = false;
2402
2425
  logger.error("No matching protection variant found.");
2403
2426
  return;
2404
2427
  }
2428
+ if (!((_d = this._protectionVariant) == null ? void 0 : _d.id)) {
2429
+ this._shouldShowWidget = false;
2430
+ return;
2431
+ }
2405
2432
  if (!protectionCartItem)
2406
2433
  return;
2407
2434
  if (protectionVariant.id === protectionCartItem.variant_id) {
@@ -2544,7 +2571,7 @@ let ShipAidWidget = class extends s$1 {
2544
2571
  .prompt-product-actions
2545
2572
  .prompt-product-actions-price {
2546
2573
  color: var(--shipaid-prompt-actions-price-color, var(--shipaid-text-muted));
2547
- font-size: var(--shipaid-font-base);
2574
+ font-size: var(--shipaid-prompt-actions-price-fontSize, --shipaid-font-base);
2548
2575
  }
2549
2576
  .shipaid-prompt
2550
2577
  .prompt-product
@@ -1,4 +1,4 @@
1
- var ShipAidWidget=function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r,s;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const n=null==t?void 0:t.protectionSettings;if(!n)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=Array.isArray(null==t?void 0:t.excludedProductSkus)?null==t?void 0:t.excludedProductSkus.map((t=>t.trim())):[],d=((null==(o=i.items)?void 0:o.reduce(((t,e)=>{if(!e.sku)return t;return a.some((t=>t===e.sku.trim()))?t-e.final_line_price:t}),i.total_price))??i.total_price)-((null==(r=i.items)?void 0:r.filter((t=>{var i;return null==(i=null==e?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"===n.protectionType){if("number"!=typeof n.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(s=n.rules)?void 0:s.length))return n.defaultFee;const t=d/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=d*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")},findProtectionVariant:function(t,e,i){var o;if(!(null==t?void 0:t.protectionSettings)||!(null==(o=null==e?void 0:e.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const r=null==e?void 0:e.variants.flatMap((t=>{if(!(null==t?void 0:t.price))return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),s=r.find((t=>t.formattedPrice>=i));return s||r[r.length-1]}},i=t=>e=>{return"function"==typeof e?(i=t,o=e,customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){customElements.define(t,e)}}})(t,e);
1
+ var ShipAidWidget=function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const s=null==t?void 0:t.protectionSettings;if(!s)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const n=Array.isArray(null==t?void 0:t.excludedProductSkus)?t.excludedProductSkus.map((t=>t.trim())):[],a=Array.isArray(null==t?void 0:t.excludedProductsVariantsId)?t.excludedProductsVariantsId.map((t=>{var e;return parseInt((null==(e=t.match(/\d+/))?void 0:e[0])||"",10)})):[],d=(i.items||[]).reduce(((t,e)=>(t=>!(!t.sku||!n.includes(t.sku.trim()))||!(!t.variant_id||!a.includes(t.variant_id)))(e)?t-e.final_line_price:t),i.total_price||0)-((null==(o=i.items)?void 0:o.filter((t=>{var i;return null==(i=null==e?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))??[]).reduce(((t,e)=>t+e.final_line_price),0);if(0===d)return d;if("FIXED"===s.protectionType){if("number"!=typeof s.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(r=s.rules)?void 0:r.length))return s.defaultFee;const t=d/100,e=s.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:s.defaultFee}if("PERCENTAGE"===s.protectionType){const t=d*s.percentage/100;return t>=s.minimumFee?t:s.minimumFee}throw new Error("No protection type handler found for this store.")},findProtectionVariant:function(t,e,i){var o;if(!(null==t?void 0:t.protectionSettings)||!(null==(o=null==e?void 0:e.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const r=null==e?void 0:e.variants.flatMap((t=>{if(!(null==t?void 0:t.price))return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),s=r.find((t=>t.formattedPrice>=i));return s||r[r.length-1]}},i=t=>e=>{return"function"==typeof e?(i=t,o=e,customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){customElements.define(t,e)}}})(t,e);
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
@@ -35,7 +35,7 @@ const d=window,p=d.ShadowRoot&&(void 0===d.ShadyCSS||d.ShadyCSS.nativeShadow)&&"
35
35
  * Copyright 2017 Google LLC
36
36
  * SPDX-License-Identifier: BSD-3-Clause
37
37
  */
38
- var A;x[$]=!0,x.elementProperties=new Map,x.elementStyles=[],x.shadowRootOptions={mode:"open"},null==y||y({ReactiveElement:x}),(null!==(g=f.reactiveElementVersions)&&void 0!==g?g:f.reactiveElementVersions=[]).push("1.6.3");const S=window,L=S.trustedTypes,P=L?L.createPolicy("lit-html",{createHTML:t=>t}):void 0,z="$lit$",E=`lit$${(Math.random()+"").slice(9)}$`,k="?"+E,M=`<${k}>`,q=document,T=()=>q.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,j="[ \t\n\f\r]",N=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,U=/-->/g,R=/>/g,W=RegExp(`>|${j}(?:([^\\s"'>=/]+)(${j}*=${j}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,V=/"/g,H=/^(?:script|style|textarea|title)$/i,B=(Y=1,(t,...e)=>({_$litType$:Y,strings:t,values:e})),Z=Symbol.for("lit-noChange"),F=Symbol.for("lit-nothing"),G=new WeakMap,K=q.createTreeWalker(q,129,null,!1);var Y;function J(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==P?P.createHTML(e):e}class Q{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[d,p]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=N;for(let a=0;a<i;a++){const e=t[a];let i,d,p=-1,l=0;for(;l<e.length&&(n.lastIndex=l,d=n.exec(e),null!==d);)l=n.lastIndex,n===N?"!--"===d[1]?n=U:void 0!==d[1]?n=R:void 0!==d[2]?(H.test(d[2])&&(r=RegExp("</"+d[2],"g")),n=W):void 0!==d[3]&&(n=W):n===W?">"===d[0]?(n=null!=r?r:N,p=-1):void 0===d[1]?p=-2:(p=n.lastIndex-d[2].length,i=d[1],n=void 0===d[3]?W:'"'===d[3]?V:D):n===V||n===D?n=W:n===U||n===R?n=N:(n=W,r=void 0);const c=n===W&&t[a+1].startsWith("/>")?" ":"";s+=n===N?e+M:p>=0?(o.push(i),e.slice(0,p)+z+e.slice(p)+E+c):e+E+(-2===p?(o.push(void 0),a):c)}return[J(t,s+(t[i]||"<?>")+(2===e?"</svg>":"")),o]})(t,e);if(this.el=Q.createElement(d,i),K.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=K.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith(z)||e.startsWith(E)){const i=p[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+z).split(E),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?ot:"?"===e[1]?st:"@"===e[1]?nt:it})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(H.test(o.tagName)){const t=o.textContent.split(E),e=t.length-1;if(e>0){o.textContent=L?L.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],T()),K.nextNode(),a.push({type:2,index:++r});o.append(t[e],T())}}}else if(8===o.nodeType)if(o.data===k)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(E,t+1));)a.push({type:7,index:r}),t+=E.length-1}r++}}static createElement(t,e){const i=q.createElement("template");return i.innerHTML=t,i}}function X(t,e,i=t,o){var r,s,n,a;if(e===Z)return e;let d=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const p=I(e)?void 0:e._$litDirective$;return(null==d?void 0:d.constructor)!==p&&(null===(s=null==d?void 0:d._$AO)||void 0===s||s.call(d,!1),void 0===p?d=void 0:(d=new p(t),d._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=d:i._$Cl=d),void 0!==d&&(e=X(t,d._$AS(t,e.values),d,o)),e}class tt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:q).importNode(i,!0);K.currentNode=r;let s=K.nextNode(),n=0,a=0,d=o[0];for(;void 0!==d;){if(n===d.index){let e;2===d.type?e=new et(s,s.nextSibling,this,t):1===d.type?e=new d.ctor(s,d.name,d.strings,this,t):6===d.type&&(e=new at(s,this,t)),this._$AV.push(e),d=o[++a]}n!==(null==d?void 0:d.index)&&(s=K.nextNode(),n++)}return K.currentNode=q,r}v(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class et{constructor(t,e,i,o){var r;this.type=2,this._$AH=F,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cp=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._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=X(this,t,e),I(t)?t===F||null==t||""===t?(this._$AH!==F&&this._$AR(),this._$AH=F):t!==this._$AH&&t!==Z&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>O(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==F&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(q.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=Q.createElement(J(o.h,o.h[0]),this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(i);else{const t=new tt(r,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=G.get(t.strings);return void 0===e&&G.set(t.strings,e=new Q(t)),e}T(t){O(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 et(this.k(T()),this.k(T()),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._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class it{constructor(t,e,i,o,r){this.type=1,this._$AH=F,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=F}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=X(this,t,e,0),s=!I(t)||t!==this._$AH&&t!==Z,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=X(this,o[i+n],e,n),a===Z&&(a=this._$AH[n]),s||(s=!I(a)||a!==this._$AH[n]),a===F?t=F:t!==F&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===F?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class ot extends it{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===F?void 0:t}}const rt=L?L.emptyScript:"";class st extends it{constructor(){super(...arguments),this.type=4}j(t){t&&t!==F?this.element.setAttribute(this.name,rt):this.element.removeAttribute(this.name)}}class nt extends it{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=X(this,t,e,0))&&void 0!==i?i:F)===Z)return;const o=this._$AH,r=t===F&&o!==F||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==F&&(o===F||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 at{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){X(this,t)}}const dt=S.litHtmlPolyfillSupport;null==dt||dt(Q,et),(null!==(A=S.litHtmlVersions)&&void 0!==A?A:S.litHtmlVersions=[]).push("2.8.0");const pt=(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 et(e.insertBefore(T(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
38
+ var A;x[$]=!0,x.elementProperties=new Map,x.elementStyles=[],x.shadowRootOptions={mode:"open"},null==y||y({ReactiveElement:x}),(null!==(g=f.reactiveElementVersions)&&void 0!==g?g:f.reactiveElementVersions=[]).push("1.6.3");const S=window,L=S.trustedTypes,P=L?L.createPolicy("lit-html",{createHTML:t=>t}):void 0,z="$lit$",E=`lit$${(Math.random()+"").slice(9)}$`,k="?"+E,M=`<${k}>`,q=document,T=()=>q.createComment(""),I=t=>null===t||"object"!=typeof t&&"function"!=typeof t,O=Array.isArray,N="[ \t\n\f\r]",j=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,U=/-->/g,R=/>/g,W=RegExp(`>|${N}(?:([^\\s"'>=/]+)(${N}*=${N}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,V=/"/g,H=/^(?:script|style|textarea|title)$/i,B=(Y=1,(t,...e)=>({_$litType$:Y,strings:t,values:e})),Z=Symbol.for("lit-noChange"),F=Symbol.for("lit-nothing"),G=new WeakMap,K=q.createTreeWalker(q,129,null,!1);var Y;function J(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==P?P.createHTML(e):e}class Q{constructor({strings:t,_$litType$:e},i){let o;this.parts=[];let r=0,s=0;const n=t.length-1,a=this.parts,[d,p]=((t,e)=>{const i=t.length-1,o=[];let r,s=2===e?"<svg>":"",n=j;for(let a=0;a<i;a++){const e=t[a];let i,d,p=-1,l=0;for(;l<e.length&&(n.lastIndex=l,d=n.exec(e),null!==d);)l=n.lastIndex,n===j?"!--"===d[1]?n=U:void 0!==d[1]?n=R:void 0!==d[2]?(H.test(d[2])&&(r=RegExp("</"+d[2],"g")),n=W):void 0!==d[3]&&(n=W):n===W?">"===d[0]?(n=null!=r?r:j,p=-1):void 0===d[1]?p=-2:(p=n.lastIndex-d[2].length,i=d[1],n=void 0===d[3]?W:'"'===d[3]?V:D):n===V||n===D?n=W:n===U||n===R?n=j:(n=W,r=void 0);const c=n===W&&t[a+1].startsWith("/>")?" ":"";s+=n===j?e+M:p>=0?(o.push(i),e.slice(0,p)+z+e.slice(p)+E+c):e+E+(-2===p?(o.push(void 0),a):c)}return[J(t,s+(t[i]||"<?>")+(2===e?"</svg>":"")),o]})(t,e);if(this.el=Q.createElement(d,i),K.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(o=K.nextNode())&&a.length<n;){if(1===o.nodeType){if(o.hasAttributes()){const t=[];for(const e of o.getAttributeNames())if(e.endsWith(z)||e.startsWith(E)){const i=p[s++];if(t.push(e),void 0!==i){const t=o.getAttribute(i.toLowerCase()+z).split(E),e=/([.?@])?(.*)/.exec(i);a.push({type:1,index:r,name:e[2],strings:t,ctor:"."===e[1]?ot:"?"===e[1]?st:"@"===e[1]?nt:it})}else a.push({type:6,index:r})}for(const e of t)o.removeAttribute(e)}if(H.test(o.tagName)){const t=o.textContent.split(E),e=t.length-1;if(e>0){o.textContent=L?L.emptyScript:"";for(let i=0;i<e;i++)o.append(t[i],T()),K.nextNode(),a.push({type:2,index:++r});o.append(t[e],T())}}}else if(8===o.nodeType)if(o.data===k)a.push({type:2,index:r});else{let t=-1;for(;-1!==(t=o.data.indexOf(E,t+1));)a.push({type:7,index:r}),t+=E.length-1}r++}}static createElement(t,e){const i=q.createElement("template");return i.innerHTML=t,i}}function X(t,e,i=t,o){var r,s,n,a;if(e===Z)return e;let d=void 0!==o?null===(r=i._$Co)||void 0===r?void 0:r[o]:i._$Cl;const p=I(e)?void 0:e._$litDirective$;return(null==d?void 0:d.constructor)!==p&&(null===(s=null==d?void 0:d._$AO)||void 0===s||s.call(d,!1),void 0===p?d=void 0:(d=new p(t),d._$AT(t,i,o)),void 0!==o?(null!==(n=(a=i)._$Co)&&void 0!==n?n:a._$Co=[])[o]=d:i._$Cl=d),void 0!==d&&(e=X(t,d._$AS(t,e.values),d,o)),e}class tt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){var e;const{el:{content:i},parts:o}=this._$AD,r=(null!==(e=null==t?void 0:t.creationScope)&&void 0!==e?e:q).importNode(i,!0);K.currentNode=r;let s=K.nextNode(),n=0,a=0,d=o[0];for(;void 0!==d;){if(n===d.index){let e;2===d.type?e=new et(s,s.nextSibling,this,t):1===d.type?e=new d.ctor(s,d.name,d.strings,this,t):6===d.type&&(e=new at(s,this,t)),this._$AV.push(e),d=o[++a]}n!==(null==d?void 0:d.index)&&(s=K.nextNode(),n++)}return K.currentNode=q,r}v(t){let e=0;for(const i of this._$AV)void 0!==i&&(void 0!==i.strings?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class et{constructor(t,e,i,o){var r;this.type=2,this._$AH=F,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=o,this._$Cp=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._$Cp}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return void 0!==e&&11===(null==t?void 0:t.nodeType)&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=X(this,t,e),I(t)?t===F||null==t||""===t?(this._$AH!==F&&this._$AR(),this._$AH=F):t!==this._$AH&&t!==Z&&this._(t):void 0!==t._$litType$?this.g(t):void 0!==t.nodeType?this.$(t):(t=>O(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==F&&I(this._$AH)?this._$AA.nextSibling.data=t:this.$(q.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:o}=t,r="number"==typeof o?this._$AC(t):(void 0===o.el&&(o.el=Q.createElement(J(o.h,o.h[0]),this.options)),o);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===r)this._$AH.v(i);else{const t=new tt(r,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=G.get(t.strings);return void 0===e&&G.set(t.strings,e=new Q(t)),e}T(t){O(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 et(this.k(T()),this.k(T()),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._$Cp=t,null===(e=this._$AP)||void 0===e||e.call(this,t))}}class it{constructor(t,e,i,o,r){this.type=1,this._$AH=F,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=F}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=X(this,t,e,0),s=!I(t)||t!==this._$AH&&t!==Z,s&&(this._$AH=t);else{const o=t;let n,a;for(t=r[0],n=0;n<r.length-1;n++)a=X(this,o[i+n],e,n),a===Z&&(a=this._$AH[n]),s||(s=!I(a)||a!==this._$AH[n]),a===F?t=F:t!==F&&(t+=(null!=a?a:"")+r[n+1]),this._$AH[n]=a}s&&!o&&this.j(t)}j(t){t===F?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!=t?t:"")}}class ot extends it{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===F?void 0:t}}const rt=L?L.emptyScript:"";class st extends it{constructor(){super(...arguments),this.type=4}j(t){t&&t!==F?this.element.setAttribute(this.name,rt):this.element.removeAttribute(this.name)}}class nt extends it{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=X(this,t,e,0))&&void 0!==i?i:F)===Z)return;const o=this._$AH,r=t===F&&o!==F||t.capture!==o.capture||t.once!==o.once||t.passive!==o.passive,s=t!==F&&(o===F||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 at{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){X(this,t)}}const dt=S.litHtmlPolyfillSupport;null==dt||dt(Q,et),(null!==(A=S.litHtmlVersions)&&void 0!==A?A:S.litHtmlVersions=[]).push("2.8.0");const pt=(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 et(e.insertBefore(T(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n};
39
39
  /**
40
40
  * @license
41
41
  * Copyright 2017 Google LLC
@@ -271,7 +271,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
271
271
  background: transparent;
272
272
  z-index: -1;
273
273
  }
274
- `,jt=B`
274
+ `,Nt=B`
275
275
  <svg
276
276
  version="1.0"
277
277
  width="50.000000pt"
@@ -292,7 +292,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
292
292
  />
293
293
  </g>
294
294
  </svg>
295
- `,Nt=B`
295
+ `,jt=B`
296
296
  <svg
297
297
  version="1.0"
298
298
  width="50.000000pt"
@@ -741,7 +741,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
741
741
  .prompt-product-actions
742
742
  .prompt-product-actions-price {
743
743
  color: var(--shipaid-prompt-actions-price-color, var(--shipaid-text-muted));
744
- font-size: var(--shipaid-font-base);
744
+ font-size: var(--shipaid-prompt-actions-price-fontSize, --shipaid-font-base);
745
745
  }
746
746
  .shipaid-prompt
747
747
  .prompt-product
@@ -792,7 +792,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
792
792
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
793
793
  height:var(--shipaid-footer-badge-logo-height, 9px);
794
794
  }
795
- `;var oe=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(oe||{}),re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ne=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?se(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&&re(e,i,s),s};const ae=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.")}},de=t=>console.warn(`[ShipAid] ${t}`),pe=t=>console.error(`[ShipAid] ${t}`),le="shipaid-protection",ce="shipaid-protection-popup-show",he=Object.assign({"./lang/de.json":()=>Promise.resolve().then((()=>be)).then((t=>t.default)),"./lang/en.json":()=>Promise.resolve().then((()=>ee)).then((t=>t.default)),"./lang/es.json":()=>Promise.resolve().then((()=>Le)).then((t=>t.default)),"./lang/fr.json":()=>Promise.resolve().then((()=>Te)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>We)).then((t=>t.default)),"./lang/pt.json":()=>Promise.resolve().then((()=>Ge)).then((t=>t.default))});var ue;ue={loader:async t=>{if("en"===t)return te;const e=Reflect.get(he,`./lang/${t}.json`);return e?await e():te}},_t=Object.assign(Object.assign({},_t),ue),t.ShipAidWidget=class extends ht{constructor(){var t,e,i;super(...arguments),this.disablePolling=!1,this.disableActions=!1,this.pollingInterval=2500,this.disableRefresh=!1,this.refreshCart=!1,this.persistPopup=!1,this.defaultToggleButton=!1,this.lang="en",this.currency=void 0,this.customerId=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.intervalId=0,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>ae(t),post:(t,e)=>ae(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}shouldPersistPopup(){return"true"===localStorage.getItem(`${ce}`)?"learn-more":null}setPopupKey(){this.persistPopup&&localStorage.setItem(`${ce}`,"true")}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")?(de("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==(i=null==(e=window.Shopify)?void 0:e.currency)?void 0:i.active)||(null==(o=this._store)?void 0:o.currency)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_handleRefreshCart(){if(this.refreshCart)return window.location.reload()}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(oe.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.calculateProtectionTotal(this._store,this._protectionProduct,t)}_findProtectionVariant(t){if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.findProtectionVariant(this._store,this._protectionProduct,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(){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 widgetPollProtection\n widgetShowCart\n excludedProductSkus\n excludedCustomersIdsAutoOptIn\n protectionSettings\n widgetConfigurations\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 pe(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 pe(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){pe(i.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}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){pe(t.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}async attemptAddProtection(){var t,e,i,o,r,s;if(!(null==(t=this._store)?void 0:t.widgetAutoOptIn))return;if(!(null==(e=this._cart)?void 0:e.items)||!(null==(i=this._cart)?void 0:i.item_count))return;const n=null==(o=this._cart.items)?void 0:o.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))})),a=null==(r=this._cart)?void 0:r.items[n];if(this._hasProtectionInCart=!!a,1===this._cart.item_count&&a)return;!!sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(s=this._cart)?void 0:s.item_count)&&this._store.widgetShowCart&&await this.addProtection())}async handleMultipleProtectionVariants(){var t,e,i,o,r;if(!(null==(t=this._cart)?void 0:t.items)||!(null==(e=this._cart)?void 0:e.item_count))return;let s=0;if(null==(i=this._cart.items)||i.forEach((t=>{var e,i;(null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id)))&&s++})),s>1){const t=null==(o=this._cart.items)?void 0:o.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))})),e={id:(null==(r=this._cart)?void 0:r.items[t]).key,quantity:0},i=await this._fetch.post("/cart/change.js",e);return await this._handleRefresh(i)}}learnMorePopupTemplate(){return this.persistPopup&&(this._popup=this.shouldPersistPopup()),B`
795
+ `;var oe=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(oe||{}),re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ne=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?se(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&&re(e,i,s),s};const ae=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.")}},de=t=>console.warn(`[ShipAid] ${t}`),pe=t=>console.error(`[ShipAid] ${t}`),le="shipaid-protection",ce="shipaid-protection-popup-show",he=Object.assign({"./lang/de.json":()=>Promise.resolve().then((()=>be)).then((t=>t.default)),"./lang/en.json":()=>Promise.resolve().then((()=>ee)).then((t=>t.default)),"./lang/es.json":()=>Promise.resolve().then((()=>Le)).then((t=>t.default)),"./lang/fr.json":()=>Promise.resolve().then((()=>Te)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>We)).then((t=>t.default)),"./lang/pt.json":()=>Promise.resolve().then((()=>Ge)).then((t=>t.default))});var ue;ue={loader:async t=>{if("en"===t)return te;const e=Reflect.get(he,`./lang/${t}.json`);return e?await e():te}},_t=Object.assign(Object.assign({},_t),ue),t.ShipAidWidget=class extends ht{constructor(){var t,e,i;super(...arguments),this.disablePolling=!1,this.disableActions=!1,this.pollingInterval=2500,this.disableRefresh=!1,this.refreshCart=!1,this.persistPopup=!1,this.defaultToggleButton=!1,this.lang="en",this.currency=void 0,this.customerId=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=!1,this._hasProtectionInCart=!1,this.hasLoadedStrings=!1,this.intervalId=0,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>ae(t),post:(t,e)=>ae(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}shouldPersistPopup(){return"true"===localStorage.getItem(`${ce}`)?"learn-more":null}setPopupKey(){this.persistPopup&&localStorage.setItem(`${ce}`,"true")}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")?(de("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o,r,s,n;const a=this.currency||(null==(i=null==(e=window.Shopify)?void 0:e.currency)?void 0:i.active)||(null==(o=this._store)?void 0:o.currency)||"USD";if(null==(n=null==(s=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:s.widget)?void 0:n.currencyFormat){return this._store.widgetConfigurations.widget.currencyFormat.replace("_value_",Number(t)).replace("_currency_",a)}return new Intl.NumberFormat(void 0,{currency:a,style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_handleRefreshCart(){if(this.refreshCart)return window.location.reload()}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(oe.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.calculateProtectionTotal(this._store,this._protectionProduct,t)}_findProtectionVariant(t){if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.findProtectionVariant(this._store,this._protectionProduct,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(){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 widgetPollProtection\n widgetShowCart\n excludedProductSkus\n excludedCustomersIdsAutoOptIn\n protectionSettings\n widgetConfigurations\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 pe(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 pe(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){pe(i.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}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){pe(t.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}async attemptAddProtection(){var t,e,i,o,r,s;if(!(null==(t=this._store)?void 0:t.widgetAutoOptIn))return;if(!(null==(e=this._cart)?void 0:e.items)||!(null==(i=this._cart)?void 0:i.item_count))return;const n=null==(o=this._cart.items)?void 0:o.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))})),a=null==(r=this._cart)?void 0:r.items[n];if(this._hasProtectionInCart=!!a,1===this._cart.item_count&&a)return;!!sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(s=this._cart)?void 0:s.item_count)&&this._store.widgetShowCart&&await this.addProtection())}async handleMultipleProtectionVariants(){var t,e,i,o,r;if(!(null==(t=this._cart)?void 0:t.items)||!(null==(e=this._cart)?void 0:e.item_count))return;let s=0;if(null==(i=this._cart.items)||i.forEach((t=>{var e,i;(null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id)))&&s++})),s>1){const t=null==(o=this._cart.items)?void 0:o.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))})),e={id:(null==(r=this._cart)?void 0:r.items[t]).key,quantity:0},i=await this._fetch.post("/cart/change.js",e);return await this._handleRefresh(i)}}learnMorePopupTemplate(){return this.persistPopup&&(this._popup=this.shouldPersistPopup()),B`
796
796
  <shipaid-popup-learn-more
797
797
  ?active=${"learn-more"===this._popup}
798
798
  @close=${()=>{this.persistPopup&&localStorage.removeItem(`${ce}`),this._popup=null}}
@@ -801,7 +801,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
801
801
  <div class="shipaid-prompt">
802
802
  <div class="prompt-product">
803
803
  <div class="prompt-product-image">
804
- ${It(this._hasProtectionInCart,(()=>Nt),(()=>jt))}
804
+ ${It(this._hasProtectionInCart,(()=>jt),(()=>Nt))}
805
805
  </div>
806
806
  <div class="prompt-product-details">
807
807
  <p class="prompt-product-details-title">
@@ -848,7 +848,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
848
848
  </a>
849
849
  </div>
850
850
  </div>
851
- `}async connectedCallback(){super.connectedCallback(),await async function(t,e=_t){const i=await e.loader(t,e);e.translationCache={},yt(t,i,e)}(this.lang),this.hasLoadedStrings=!0}render(){return Tt(this,(async()=>{var t,e,i,o,r,s;const n=document.createElement("link");n.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),n.setAttribute("rel","stylesheet"),document.head.appendChild(n);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(a){return pe(a.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(oe.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.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),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(s=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:s.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(de("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Tt(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 sessionStorage.removeItem(le),await this._handleRefresh(e)}if(!this._store)return;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 pe("No matching protection variant found.");if(!r)return;if(n.id===r.variant_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 this._handleRefreshCart(),await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},d=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(d)}),[this._store,this._cart]),pt(this.learnMorePopupTemplate(),document.body),B`
851
+ `}async connectedCallback(){super.connectedCallback(),await async function(t,e=_t){const i=await e.loader(t,e);e.translationCache={},yt(t,i,e)}(this.lang),this.hasLoadedStrings=!0}render(){return Tt(this,(async()=>{var t,e,i,o,r,s;const n=document.createElement("link");n.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),n.setAttribute("rel","stylesheet"),document.head.appendChild(n);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(a){return pe(a.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._dispatchEvent(oe.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.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),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(s=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:s.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(de("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Tt(this,(async()=>{var t,e,i,o;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const r=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))})),s=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!s,!this._store)return;const n=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&s&&(this._cart.total_price===s.final_line_price||!n)){const t={id:s.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return sessionStorage.removeItem(le),await this._handleRefresh(e)}const a=this._findProtectionVariant(n);if(n?(this._protectionVariant=a,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==a?void 0:a.id))return this._shouldShowWidget=!1,void pe("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(!s)return;if(a.id===s.variant_id){if(this._protectionCartItem={...s,index:r,position:r+1},1===s.quantity)return;const t={id:s.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return this._handleRefreshCart(),await this._handleRefresh(e)}const d={updates:{[s.variant_id]:0,[a.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}),[this._store,this._cart]),pt(this.learnMorePopupTemplate(),document.body),B`
852
852
  <style>
853
853
  :host {
854
854
  --shipaid-primary: #002bd6;
@@ -954,7 +954,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
954
954
  .prompt-product-actions
955
955
  .prompt-product-actions-price {
956
956
  color: var(--shipaid-prompt-actions-price-color, var(--shipaid-text-muted));
957
- font-size: var(--shipaid-font-base);
957
+ font-size: var(--shipaid-prompt-actions-price-fontSize, --shipaid-font-base);
958
958
  }
959
959
  .shipaid-prompt
960
960
  .prompt-product
@@ -1053,4 +1053,4 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
1053
1053
  <div class="shipaid">
1054
1054
  ${It(this._hasFinishedSetup,(()=>{var t;return It(this._shouldShowWidget&&this.planActive&&(null==(t=this._store)?void 0:t.widgetShowCart),(()=>this.promptTemplate()),(()=>F))}),(()=>this.promptTemplate()))}
1055
1055
  </div>
1056
- `}},t.ShipAidWidget.styles=ie,ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableActions",2),ne([s({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"refreshCart",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"persistPopup",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"defaultToggleButton",2),ne([s({type:String,attribute:!0})],t.ShipAidWidget.prototype,"lang",2),ne([s({type:String,attribute:!0})],t.ShipAidWidget.prototype,"currency",2),ne([s({type:String,attribute:!0})],t.ShipAidWidget.prototype,"customerId",2),ne([n()],t.ShipAidWidget.prototype,"_storeDomain",2),ne([n()],t.ShipAidWidget.prototype,"_store",2),ne([n()],t.ShipAidWidget.prototype,"_cart",2),ne([n()],t.ShipAidWidget.prototype,"_protectionProduct",2),ne([n()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),ne([n()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),ne([n()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),ne([n()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),ne([n()],t.ShipAidWidget.prototype,"_protectionCartItem",2),ne([n()],t.ShipAidWidget.prototype,"_protectionVariant",2),ne([n()],t.ShipAidWidget.prototype,"hasLoadedStrings",2),ne([n()],t.ShipAidWidget.prototype,"intervalId",2),ne([n()],t.ShipAidWidget.prototype,"_state",2),ne([n()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=ne([i("shipaid-widget")],t.ShipAidWidget);const me="Laden des ShipAid-Widgets...",ge="Liefergarantie",fe="im Falle von Verlust, Beschädigung oder Diebstahl",ve={button:"Bereitgestellt von"},_e={add:"Hinzufügen",remove:"Entfernen",loading:"Lädt..."},ye={loading:me,title:ge,description:fe,footer:ve,actions:_e,"learn-more-popup":{close:"Schließen",title:"Liefergarantie",subtitle:"Wir ermöglichen es Ihren Lieblingsmarken, eine Liefergarantie anzubieten, weil jede Bestellung wertvoll ist!",disclaimer:{"subtitle-enable":"Wir ermöglichen es Ihren Lieblingsmarken, eine Liefergarantie zu bieten, denn wir wissen, dass jede Bestellung wertvoll ist und Dinge passieren können!","subtitle-monitor":"Wir überwachen Ihr Paket kontinuierlich und bieten ein praktisches Portal, damit Sie den Fortschritt Ihrer Bestellung jederzeit verfolgen können!","subtitle-notify":"Sie werden während des gesamten Versandprozesses benachrichtigt, um sicherzustellen, dass Sie auf dem Laufenden bleiben.","subtitle-resolution":"Sie werden während des gesamten Versandprozesses benachrichtigt, um sicherzustellen, dass Sie auf dem Laufenden bleiben.",text:"Durch den Erwerb dieser Liefergarantie stimmen Sie unseren Servicebedingungen und Datenschutzrichtlinien zu. Diese Garantie ist nicht verpflichtend, IST KEINE Versicherung und bietet keine Entschädigung für Verluste, Schäden oder Haftungen, die aus einem zufälligen oder unbekannten Ereignis resultieren. Sollte das Produkt nicht in zufriedenstellendem Zustand geliefert werden, kann die Marke, bei der Sie gekauft haben, dieses kostenlos ersetzen. ShipAid liefert keine Produkte oder Dienstleistungen direkt an Verbraucher, sondern bietet einen Dienst an, der Marken ermöglicht, den Produktersatz für ihre Kunden zu erleichtern. Der Erwerb dieser Garantie bedeutet nicht, dass Sie automatisch eine Rückerstattung für irgendwelche Produkte oder Versandkosten erhalten, da der Lösungsprozess und die Entscheidung über eine Kompensation strikt von der Marke, bei der Sie kaufen, entschieden werden. Die Marke wird einen Nachweis für Beschädigungen oder die Nichtlieferung des Produkts verlangen."},links:{terms:"Servicebedingungen",privacy:"Datenschutzrichtlinie"}}},be=Object.freeze(Object.defineProperty({__proto__:null,actions:_e,default:ye,description:fe,footer:ve,loading:me,title:ge},Symbol.toStringTag,{value:"Module"})),Ce="Cargando el widget ShipAid...",we="Garantía de entrega",$e="en caso de Pérdida, Daño o Robo",xe={button:"Energizado por"},Ae={add:"Agregar",remove:"Eliminar",loading:"Cargando..."},Se={loading:Ce,title:we,description:$e,footer:xe,actions:Ae,"learn-more-popup":{close:"Cerca",title:"Garantía de entrega",disclaimer:{"subtitle-enable":"Permitimos que sus marcas favoritas brinden una garantía de entrega porque sabemos que cada pedido es valioso y las cosas suceden!","subtitle-monitor":"Supervisamos continuamente su paquete y le ofrecemos un portal conveniente para que pueda realizar un seguimiento del progreso de su pedido en cualquier momento.","subtitle-notify":"Se le notificará durante todo el proceso de envío, asegurándose de que esté actualizado en cada paso del camino.","subtitle-resolution":"En caso de cualquier problema durante el tránsito, ofrecemos un método rápido y fácil para informar el problema directamente a la marca, para una resolución rápida.",text:"Al comprar esta garantía de entrega, acepta nuestros Términos de servicio y Política de privacidad. Usted no está obligado a comprar esta garantía. Esta garantía NO es un seguro y no brinda indemnización por pérdida, daño o responsabilidad que surja de un evento contingente o desconocido, sino que, a través de las marcas de ShipAid, brinda una garantía de entrega mediante la cual, si el producto que ordenó no se entrega en condiciones satisfactorias, la marca desde el que ordenó el producto puede reemplazar el producto sin cargo. ShipAid no proporciona ningún producto o servicio directamente a los consumidores, sino que proporciona un servicio que permite a las marcas facilitar el reemplazo de productos a sus clientes. La compra de esta garantía no significa que se le reembolsará automáticamente cualquier producto o costo de envío porque el proceso de resolución y la decisión de compensación lo decide estrictamente la marca a la que le compra. La marca requerirá prueba de daño o producto no entregado."},links:{terms:"Términos de servicio",privacy:"Política de Privacidad"}}},Le=Object.freeze(Object.defineProperty({__proto__:null,actions:Ae,default:Se,description:$e,footer:xe,loading:Ce,title:we},Symbol.toStringTag,{value:"Module"})),Pe="Chargement du widget ShipAid...",ze="Garantie de livraison",Ee="en cas de Perte, Dommages ou Vol",ke={button:"Propulsé par"},Me={add:"Ajouter",remove:"Retirer",loading:"Chargement..."},qe={loading:Pe,title:ze,description:Ee,footer:ke,actions:Me,"learn-more-popup":{close:"Fermer",title:"Garantie de livraison",subtitle:"Nous permettons à vos marques préférées d'offrir une garantie de livraison car chaque commande est précieuse !",disclaimer:{"subtitle-enable":"Nous permettons à vos marques préférées de fournir une garantie de livraison car nous savons que chaque commande est précieuse et que des incidents peuvent survenir !","subtitle-monitor":"Nous surveillons continuellement votre colis et offrons un portail pratique pour vous permettre de suivre l'avancement de votre commande à tout moment !","subtitle-notify":"Vous serez notifié tout au long du processus d'expédition, vous assurant que vous restez informé à chaque étape du parcours.","subtitle-resolution":"Vous serez notifié tout au long du processus d'expédition, vous assurant que vous restez informé à chaque étape du parcours.",text:"En acquérant cette garantie de livraison, vous acceptez nos Conditions de Service et notre Politique de Confidentialité. Cette garantie n'est pas obligatoire, N'EST PAS une assurance et ne fournit pas d'indemnisation pour les pertes, dommages ou responsabilités résultant d'un événement contingent ou inconnu. Si le produit n'est pas livré dans des conditions satisfaisantes, la marque auprès de laquelle vous avez acheté peut le remplacer gratuitement. ShipAid ne fournit aucun produit ou service directement aux consommateurs, mais offre un service permettant aux marques de faciliter le remplacement du produit pour leurs clients. L'achat de cette garantie ne signifie pas que vous serez automatiquement remboursé pour tout produit ou frais de port, car le processus de résolution et la décision de compensation sont strictement décidés par la marque que vous achetez. La marque exigera une preuve de dommage ou de produit non livré."},links:{terms:"Conditions de service",privacy:"Politique de Confidentialité"}}},Te=Object.freeze(Object.defineProperty({__proto__:null,actions:Me,default:qe,description:Ee,footer:ke,loading:Pe,title:ze},Symbol.toStringTag,{value:"Module"})),Ie="Caricamento del widget ShipAid...",Oe="Garanzia di consegna",je="in caso di Perdita, Danno o Furto",Ne={button:"Offerto da"},Ue={add:"Aggiungere",remove:"Rimuovere",loading:"Caricamento ..."},Re={loading:Ie,title:Oe,description:je,footer:Ne,actions:Ue,"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:{"subtitle-enable":"Consentiamo ai tuoi marchi preferiti di fornire una garanzia di consegna perché sappiamo che ogni ordine è prezioso e le cose accadono!","subtitle-monitor":"Monitoriamo continuamente il tuo pacco e ti offriamo un comodo portale per monitorare lo stato di avanzamento del tuo ordine in qualsiasi momento!","subtitle-notify":"Riceverai una notifica durante l'intero processo di spedizione, assicurandoti di rimanere aggiornato in ogni fase del processo.","subtitle-resolution":"Você será notificado durante todo o processo de envio, garantindo que você fique atualizado a cada passo do caminho.",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"}}},We=Object.freeze(Object.defineProperty({__proto__:null,actions:Ue,default:Re,description:je,footer:Ne,loading:Ie,title:Oe},Symbol.toStringTag,{value:"Module"})),De="Carregando o widget ShipAid...",Ve="Garantia de entrega",He="em caso de Perda, Danos ou Roubo",Be={button:"Distribuído por"},Ze={add:"Adicionar",remove:"Remover",loading:"Carregando..."},Fe={loading:De,title:Ve,description:He,footer:Be,actions:Ze,"learn-more-popup":{close:"Fechar",title:"Garantia de entrega",subtitle:"Capacitamos suas marcas favoritas para oferecer uma garantia de entrega porque cada pedido é precioso!",disclaimer:{"subtitle-enable":"Permitimos que suas marcas favoritas forneçam uma garantia de entrega porque sabemos que cada pedido é precioso e as coisas acontecem!","subtitle-monitor":"Monitoramos continuamente o seu pacote e oferecemos um portal conveniente para você acompanhar o andamento do seu pedido a qualquer momento!","subtitle-notify":"Você será notificado durante todo o processo de envio, garantindo que você fique atualizado a cada passo do caminho.","subtitle-resolution":"Você será notificado durante todo o processo de envio, garantindo que você fique atualizado a cada passo do caminho.",text:"Ao adquirir esta garantia de entrega, você concorda com nossos Termos de Serviço e Política de Privacidade. Esta garantia não é obrigatória, NÃO é um seguro e não fornece indenização contra perdas, danos ou responsabilidade decorrentes de um contingente ou desconhecido. Caso o produto não seja entregue em condições satisfatórias, a marca da qual você comprou pode substituí-lo gratuitamente. A ShipAid não fornece nenhum produto ou serviço diretamente aos consumidores, mas sim presta um serviço que permite às marcas facilitar a substituição do produto aos seus clientes. Adquirir esta garantia não significa que você será automaticamente reembolsado por qualquer produto ou custos de envio porque o processo de resolução e decisão de compensação é estritamente decidido pela marca que você está comprando. A marca exigirá prova de danos ou produto não entregue."},links:{terms:"Termos de serviço",privacy:"Política de Privacidade"}}},Ge=Object.freeze(Object.defineProperty({__proto__:null,actions:Ze,default:Fe,description:He,footer:Be,loading:De,title:Ve},Symbol.toStringTag,{value:"Module"}));return Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
1056
+ `}},t.ShipAidWidget.styles=ie,ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disablePolling",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableActions",2),ne([s({type:Number,attribute:!0})],t.ShipAidWidget.prototype,"pollingInterval",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"disableRefresh",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"refreshCart",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"persistPopup",2),ne([s({type:Boolean,attribute:!0})],t.ShipAidWidget.prototype,"defaultToggleButton",2),ne([s({type:String,attribute:!0})],t.ShipAidWidget.prototype,"lang",2),ne([s({type:String,attribute:!0})],t.ShipAidWidget.prototype,"currency",2),ne([s({type:String,attribute:!0})],t.ShipAidWidget.prototype,"customerId",2),ne([n()],t.ShipAidWidget.prototype,"_storeDomain",2),ne([n()],t.ShipAidWidget.prototype,"_store",2),ne([n()],t.ShipAidWidget.prototype,"_cart",2),ne([n()],t.ShipAidWidget.prototype,"_protectionProduct",2),ne([n()],t.ShipAidWidget.prototype,"_cartLastUpdated",2),ne([n()],t.ShipAidWidget.prototype,"_hasFinishedSetup",2),ne([n()],t.ShipAidWidget.prototype,"_shouldShowWidget",2),ne([n()],t.ShipAidWidget.prototype,"_hasProtectionInCart",2),ne([n()],t.ShipAidWidget.prototype,"_protectionCartItem",2),ne([n()],t.ShipAidWidget.prototype,"_protectionVariant",2),ne([n()],t.ShipAidWidget.prototype,"hasLoadedStrings",2),ne([n()],t.ShipAidWidget.prototype,"intervalId",2),ne([n()],t.ShipAidWidget.prototype,"_state",2),ne([n()],t.ShipAidWidget.prototype,"_popup",2),t.ShipAidWidget=ne([i("shipaid-widget")],t.ShipAidWidget);const me="Laden des ShipAid-Widgets...",ge="Liefergarantie",fe="im Falle von Verlust, Beschädigung oder Diebstahl",ve={button:"Bereitgestellt von"},_e={add:"Hinzufügen",remove:"Entfernen",loading:"Lädt..."},ye={loading:me,title:ge,description:fe,footer:ve,actions:_e,"learn-more-popup":{close:"Schließen",title:"Liefergarantie",subtitle:"Wir ermöglichen es Ihren Lieblingsmarken, eine Liefergarantie anzubieten, weil jede Bestellung wertvoll ist!",disclaimer:{"subtitle-enable":"Wir ermöglichen es Ihren Lieblingsmarken, eine Liefergarantie zu bieten, denn wir wissen, dass jede Bestellung wertvoll ist und Dinge passieren können!","subtitle-monitor":"Wir überwachen Ihr Paket kontinuierlich und bieten ein praktisches Portal, damit Sie den Fortschritt Ihrer Bestellung jederzeit verfolgen können!","subtitle-notify":"Sie werden während des gesamten Versandprozesses benachrichtigt, um sicherzustellen, dass Sie auf dem Laufenden bleiben.","subtitle-resolution":"Sie werden während des gesamten Versandprozesses benachrichtigt, um sicherzustellen, dass Sie auf dem Laufenden bleiben.",text:"Durch den Erwerb dieser Liefergarantie stimmen Sie unseren Servicebedingungen und Datenschutzrichtlinien zu. Diese Garantie ist nicht verpflichtend, IST KEINE Versicherung und bietet keine Entschädigung für Verluste, Schäden oder Haftungen, die aus einem zufälligen oder unbekannten Ereignis resultieren. Sollte das Produkt nicht in zufriedenstellendem Zustand geliefert werden, kann die Marke, bei der Sie gekauft haben, dieses kostenlos ersetzen. ShipAid liefert keine Produkte oder Dienstleistungen direkt an Verbraucher, sondern bietet einen Dienst an, der Marken ermöglicht, den Produktersatz für ihre Kunden zu erleichtern. Der Erwerb dieser Garantie bedeutet nicht, dass Sie automatisch eine Rückerstattung für irgendwelche Produkte oder Versandkosten erhalten, da der Lösungsprozess und die Entscheidung über eine Kompensation strikt von der Marke, bei der Sie kaufen, entschieden werden. Die Marke wird einen Nachweis für Beschädigungen oder die Nichtlieferung des Produkts verlangen."},links:{terms:"Servicebedingungen",privacy:"Datenschutzrichtlinie"}}},be=Object.freeze(Object.defineProperty({__proto__:null,actions:_e,default:ye,description:fe,footer:ve,loading:me,title:ge},Symbol.toStringTag,{value:"Module"})),Ce="Cargando el widget ShipAid...",we="Garantía de entrega",$e="en caso de Pérdida, Daño o Robo",xe={button:"Energizado por"},Ae={add:"Agregar",remove:"Eliminar",loading:"Cargando..."},Se={loading:Ce,title:we,description:$e,footer:xe,actions:Ae,"learn-more-popup":{close:"Cerca",title:"Garantía de entrega",disclaimer:{"subtitle-enable":"Permitimos que sus marcas favoritas brinden una garantía de entrega porque sabemos que cada pedido es valioso y las cosas suceden!","subtitle-monitor":"Supervisamos continuamente su paquete y le ofrecemos un portal conveniente para que pueda realizar un seguimiento del progreso de su pedido en cualquier momento.","subtitle-notify":"Se le notificará durante todo el proceso de envío, asegurándose de que esté actualizado en cada paso del camino.","subtitle-resolution":"En caso de cualquier problema durante el tránsito, ofrecemos un método rápido y fácil para informar el problema directamente a la marca, para una resolución rápida.",text:"Al comprar esta garantía de entrega, acepta nuestros Términos de servicio y Política de privacidad. Usted no está obligado a comprar esta garantía. Esta garantía NO es un seguro y no brinda indemnización por pérdida, daño o responsabilidad que surja de un evento contingente o desconocido, sino que, a través de las marcas de ShipAid, brinda una garantía de entrega mediante la cual, si el producto que ordenó no se entrega en condiciones satisfactorias, la marca desde el que ordenó el producto puede reemplazar el producto sin cargo. ShipAid no proporciona ningún producto o servicio directamente a los consumidores, sino que proporciona un servicio que permite a las marcas facilitar el reemplazo de productos a sus clientes. La compra de esta garantía no significa que se le reembolsará automáticamente cualquier producto o costo de envío porque el proceso de resolución y la decisión de compensación lo decide estrictamente la marca a la que le compra. La marca requerirá prueba de daño o producto no entregado."},links:{terms:"Términos de servicio",privacy:"Política de Privacidad"}}},Le=Object.freeze(Object.defineProperty({__proto__:null,actions:Ae,default:Se,description:$e,footer:xe,loading:Ce,title:we},Symbol.toStringTag,{value:"Module"})),Pe="Chargement du widget ShipAid...",ze="Garantie de livraison",Ee="en cas de Perte, Dommages ou Vol",ke={button:"Propulsé par"},Me={add:"Ajouter",remove:"Retirer",loading:"Chargement..."},qe={loading:Pe,title:ze,description:Ee,footer:ke,actions:Me,"learn-more-popup":{close:"Fermer",title:"Garantie de livraison",subtitle:"Nous permettons à vos marques préférées d'offrir une garantie de livraison car chaque commande est précieuse !",disclaimer:{"subtitle-enable":"Nous permettons à vos marques préférées de fournir une garantie de livraison car nous savons que chaque commande est précieuse et que des incidents peuvent survenir !","subtitle-monitor":"Nous surveillons continuellement votre colis et offrons un portail pratique pour vous permettre de suivre l'avancement de votre commande à tout moment !","subtitle-notify":"Vous serez notifié tout au long du processus d'expédition, vous assurant que vous restez informé à chaque étape du parcours.","subtitle-resolution":"Vous serez notifié tout au long du processus d'expédition, vous assurant que vous restez informé à chaque étape du parcours.",text:"En acquérant cette garantie de livraison, vous acceptez nos Conditions de Service et notre Politique de Confidentialité. Cette garantie n'est pas obligatoire, N'EST PAS une assurance et ne fournit pas d'indemnisation pour les pertes, dommages ou responsabilités résultant d'un événement contingent ou inconnu. Si le produit n'est pas livré dans des conditions satisfaisantes, la marque auprès de laquelle vous avez acheté peut le remplacer gratuitement. ShipAid ne fournit aucun produit ou service directement aux consommateurs, mais offre un service permettant aux marques de faciliter le remplacement du produit pour leurs clients. L'achat de cette garantie ne signifie pas que vous serez automatiquement remboursé pour tout produit ou frais de port, car le processus de résolution et la décision de compensation sont strictement décidés par la marque que vous achetez. La marque exigera une preuve de dommage ou de produit non livré."},links:{terms:"Conditions de service",privacy:"Politique de Confidentialité"}}},Te=Object.freeze(Object.defineProperty({__proto__:null,actions:Me,default:qe,description:Ee,footer:ke,loading:Pe,title:ze},Symbol.toStringTag,{value:"Module"})),Ie="Caricamento del widget ShipAid...",Oe="Garanzia di consegna",Ne="in caso di Perdita, Danno o Furto",je={button:"Offerto da"},Ue={add:"Aggiungere",remove:"Rimuovere",loading:"Caricamento ..."},Re={loading:Ie,title:Oe,description:Ne,footer:je,actions:Ue,"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:{"subtitle-enable":"Consentiamo ai tuoi marchi preferiti di fornire una garanzia di consegna perché sappiamo che ogni ordine è prezioso e le cose accadono!","subtitle-monitor":"Monitoriamo continuamente il tuo pacco e ti offriamo un comodo portale per monitorare lo stato di avanzamento del tuo ordine in qualsiasi momento!","subtitle-notify":"Riceverai una notifica durante l'intero processo di spedizione, assicurandoti di rimanere aggiornato in ogni fase del processo.","subtitle-resolution":"Você será notificado durante todo o processo de envio, garantindo que você fique atualizado a cada passo do caminho.",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"}}},We=Object.freeze(Object.defineProperty({__proto__:null,actions:Ue,default:Re,description:Ne,footer:je,loading:Ie,title:Oe},Symbol.toStringTag,{value:"Module"})),De="Carregando o widget ShipAid...",Ve="Garantia de entrega",He="em caso de Perda, Danos ou Roubo",Be={button:"Distribuído por"},Ze={add:"Adicionar",remove:"Remover",loading:"Carregando..."},Fe={loading:De,title:Ve,description:He,footer:Be,actions:Ze,"learn-more-popup":{close:"Fechar",title:"Garantia de entrega",subtitle:"Capacitamos suas marcas favoritas para oferecer uma garantia de entrega porque cada pedido é precioso!",disclaimer:{"subtitle-enable":"Permitimos que suas marcas favoritas forneçam uma garantia de entrega porque sabemos que cada pedido é precioso e as coisas acontecem!","subtitle-monitor":"Monitoramos continuamente o seu pacote e oferecemos um portal conveniente para você acompanhar o andamento do seu pedido a qualquer momento!","subtitle-notify":"Você será notificado durante todo o processo de envio, garantindo que você fique atualizado a cada passo do caminho.","subtitle-resolution":"Você será notificado durante todo o processo de envio, garantindo que você fique atualizado a cada passo do caminho.",text:"Ao adquirir esta garantia de entrega, você concorda com nossos Termos de Serviço e Política de Privacidade. Esta garantia não é obrigatória, NÃO é um seguro e não fornece indenização contra perdas, danos ou responsabilidade decorrentes de um contingente ou desconhecido. Caso o produto não seja entregue em condições satisfatórias, a marca da qual você comprou pode substituí-lo gratuitamente. A ShipAid não fornece nenhum produto ou serviço diretamente aos consumidores, mas sim presta um serviço que permite às marcas facilitar a substituição do produto aos seus clientes. Adquirir esta garantia não significa que você será automaticamente reembolsado por qualquer produto ou custos de envio porque o processo de resolução e decisão de compensação é estritamente decidido pela marca que você está comprando. A marca exigirá prova de danos ou produto não entregue."},links:{terms:"Termos de serviço",privacy:"Política de Privacidade"}}},Ge=Object.freeze(Object.defineProperty({__proto__:null,actions:Ze,default:Fe,description:He,footer:Be,loading:De,title:Ve},Symbol.toStringTag,{value:"Module"}));return Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),t}({});
@@ -1,4 +1,4 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShipAidWidget={})}(this,(function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r,s;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const n=null==t?void 0:t.protectionSettings;if(!n)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const a=Array.isArray(null==t?void 0:t.excludedProductSkus)?null==t?void 0:t.excludedProductSkus.map((t=>t.trim())):[],d=((null==(o=i.items)?void 0:o.reduce(((t,e)=>{if(!e.sku)return t;return a.some((t=>t===e.sku.trim()))?t-e.final_line_price:t}),i.total_price))??i.total_price)-((null==(r=i.items)?void 0:r.filter((t=>{var i;return null==(i=null==e?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"===n.protectionType){if("number"!=typeof n.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(s=n.rules)?void 0:s.length))return n.defaultFee;const t=d/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=d*n.percentage/100;return t>=n.minimumFee?t:n.minimumFee}throw new Error("No protection type handler found for this store.")},findProtectionVariant:function(t,e,i){var o;if(!(null==t?void 0:t.protectionSettings)||!(null==(o=null==e?void 0:e.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const r=null==e?void 0:e.variants.flatMap((t=>{if(!(null==t?void 0:t.price))return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),s=r.find((t=>t.formattedPrice>=i));return s||r[r.length-1]}},i=t=>e=>{return"function"==typeof e?(i=t,o=e,customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){customElements.define(t,e)}}})(t,e);
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).ShipAidWidget={})}(this,(function(t){"use strict";const e={calculateProtectionTotal:function(t,e,i){var o,r;if(!t)throw new Error("Missing store settings.");if(!e)throw new Error("Missing protectionProduct.");if(!i)throw new Error("Missing Shopify cart.");const s=null==t?void 0:t.protectionSettings;if(!s)throw new Error("Tried to find protection variant, but protection settings for this store are missing.");const n=Array.isArray(null==t?void 0:t.excludedProductSkus)?t.excludedProductSkus.map((t=>t.trim())):[],a=Array.isArray(null==t?void 0:t.excludedProductsVariantsId)?t.excludedProductsVariantsId.map((t=>{var e;return parseInt((null==(e=t.match(/\d+/))?void 0:e[0])||"",10)})):[],d=(i.items||[]).reduce(((t,e)=>(t=>!(!t.sku||!n.includes(t.sku.trim()))||!(!t.variant_id||!a.includes(t.variant_id)))(e)?t-e.final_line_price:t),i.total_price||0)-((null==(o=i.items)?void 0:o.filter((t=>{var i;return null==(i=null==e?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id))})))??[]).reduce(((t,e)=>t+e.final_line_price),0);if(0===d)return d;if("FIXED"===s.protectionType){if("number"!=typeof s.defaultFee)throw new Error("Missing default fee amount.");if(!(null==(r=s.rules)?void 0:r.length))return s.defaultFee;const t=d/100,e=s.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:s.defaultFee}if("PERCENTAGE"===s.protectionType){const t=d*s.percentage/100;return t>=s.minimumFee?t:s.minimumFee}throw new Error("No protection type handler found for this store.")},findProtectionVariant:function(t,e,i){var o;if(!(null==t?void 0:t.protectionSettings)||!(null==(o=null==e?void 0:e.variants)?void 0:o.length))throw new Error("Missing product and variants from protection settings.");const r=null==e?void 0:e.variants.flatMap((t=>{if(!(null==t?void 0:t.price))return[];const e=Number(t.price);return[{...t,formattedPrice:e}]})).sort(((t,e)=>t.formattedPrice-e.formattedPrice)),s=r.find((t=>t.formattedPrice>=i));return s||r[r.length-1]}},i=t=>e=>{return"function"==typeof e?(i=t,o=e,customElements.define(i,o),o):((t,e)=>{const{kind:i,elements:o}=e;return{kind:i,elements:o,finisher(e){customElements.define(t,e)}}})(t,e);
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC
@@ -741,7 +741,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
741
741
  .prompt-product-actions
742
742
  .prompt-product-actions-price {
743
743
  color: var(--shipaid-prompt-actions-price-color, var(--shipaid-text-muted));
744
- font-size: var(--shipaid-font-base);
744
+ font-size: var(--shipaid-prompt-actions-price-fontSize, --shipaid-font-base);
745
745
  }
746
746
  .shipaid-prompt
747
747
  .prompt-product
@@ -792,7 +792,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
792
792
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
793
793
  height:var(--shipaid-footer-badge-logo-height, 9px);
794
794
  }
795
- `;var oe=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(oe||{}),re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ne=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?se(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&&re(e,i,s),s};const ae=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.")}},de=t=>console.warn(`[ShipAid] ${t}`),pe=t=>console.error(`[ShipAid] ${t}`),le="shipaid-protection",ce="shipaid-protection-popup-show",he=Object.assign({"./lang/de.json":()=>Promise.resolve().then((()=>be)).then((t=>t.default)),"./lang/en.json":()=>Promise.resolve().then((()=>ee)).then((t=>t.default)),"./lang/es.json":()=>Promise.resolve().then((()=>Le)).then((t=>t.default)),"./lang/fr.json":()=>Promise.resolve().then((()=>Te)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>We)).then((t=>t.default)),"./lang/pt.json":()=>Promise.resolve().then((()=>Ge)).then((t=>t.default))});var ue;ue={loader:async t=>{if("en"===t)return te;const e=Reflect.get(he,`./lang/${t}.json`);return e?await e():te}},_t=Object.assign(Object.assign({},_t),ue),t.ShipAidWidget=class extends ht{constructor(){var t,e,i;super(...arguments),this.disablePolling=!1,this.disableActions=!1,this.pollingInterval=2500,this.disableRefresh=!1,this.refreshCart=!1,this.persistPopup=!1,this.defaultToggleButton=!1,this.lang="en",this.currency=void 0,this.customerId=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.intervalId=0,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>ae(t),post:(t,e)=>ae(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}shouldPersistPopup(){return"true"===localStorage.getItem(`${ce}`)?"learn-more":null}setPopupKey(){this.persistPopup&&localStorage.setItem(`${ce}`,"true")}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")?(de("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==(i=null==(e=window.Shopify)?void 0:e.currency)?void 0:i.active)||(null==(o=this._store)?void 0:o.currency)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_handleRefreshCart(){if(this.refreshCart)return window.location.reload()}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(oe.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.calculateProtectionTotal(this._store,this._protectionProduct,t)}_findProtectionVariant(t){if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.findProtectionVariant(this._store,this._protectionProduct,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(){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 widgetPollProtection\n widgetShowCart\n excludedProductSkus\n excludedCustomersIdsAutoOptIn\n protectionSettings\n widgetConfigurations\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 pe(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 pe(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){pe(i.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}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){pe(t.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}async attemptAddProtection(){var t,e,i,o,r,s;if(!(null==(t=this._store)?void 0:t.widgetAutoOptIn))return;if(!(null==(e=this._cart)?void 0:e.items)||!(null==(i=this._cart)?void 0:i.item_count))return;const n=null==(o=this._cart.items)?void 0:o.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))})),a=null==(r=this._cart)?void 0:r.items[n];if(this._hasProtectionInCart=!!a,1===this._cart.item_count&&a)return;!!sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(s=this._cart)?void 0:s.item_count)&&this._store.widgetShowCart&&await this.addProtection())}async handleMultipleProtectionVariants(){var t,e,i,o,r;if(!(null==(t=this._cart)?void 0:t.items)||!(null==(e=this._cart)?void 0:e.item_count))return;let s=0;if(null==(i=this._cart.items)||i.forEach((t=>{var e,i;(null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id)))&&s++})),s>1){const t=null==(o=this._cart.items)?void 0:o.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))})),e={id:(null==(r=this._cart)?void 0:r.items[t]).key,quantity:0},i=await this._fetch.post("/cart/change.js",e);return await this._handleRefresh(i)}}learnMorePopupTemplate(){return this.persistPopup&&(this._popup=this.shouldPersistPopup()),B`
795
+ `;var oe=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(oe||{}),re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ne=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?se(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&&re(e,i,s),s};const ae=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.")}},de=t=>console.warn(`[ShipAid] ${t}`),pe=t=>console.error(`[ShipAid] ${t}`),le="shipaid-protection",ce="shipaid-protection-popup-show",he=Object.assign({"./lang/de.json":()=>Promise.resolve().then((()=>be)).then((t=>t.default)),"./lang/en.json":()=>Promise.resolve().then((()=>ee)).then((t=>t.default)),"./lang/es.json":()=>Promise.resolve().then((()=>Le)).then((t=>t.default)),"./lang/fr.json":()=>Promise.resolve().then((()=>Te)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>We)).then((t=>t.default)),"./lang/pt.json":()=>Promise.resolve().then((()=>Ge)).then((t=>t.default))});var ue;ue={loader:async t=>{if("en"===t)return te;const e=Reflect.get(he,`./lang/${t}.json`);return e?await e():te}},_t=Object.assign(Object.assign({},_t),ue),t.ShipAidWidget=class extends ht{constructor(){var t,e,i;super(...arguments),this.disablePolling=!1,this.disableActions=!1,this.pollingInterval=2500,this.disableRefresh=!1,this.refreshCart=!1,this.persistPopup=!1,this.defaultToggleButton=!1,this.lang="en",this.currency=void 0,this.customerId=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=!1,this._hasProtectionInCart=!1,this.hasLoadedStrings=!1,this.intervalId=0,this._state={loading:!1,success:null,error:!1},this._popup=null,this._fetch={get:t=>ae(t),post:(t,e)=>ae(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}shouldPersistPopup(){return"true"===localStorage.getItem(`${ce}`)?"learn-more":null}setPopupKey(){this.persistPopup&&localStorage.setItem(`${ce}`,"true")}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")?(de("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o,r,s,n;const a=this.currency||(null==(i=null==(e=window.Shopify)?void 0:e.currency)?void 0:i.active)||(null==(o=this._store)?void 0:o.currency)||"USD";if(null==(n=null==(s=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:s.widget)?void 0:n.currencyFormat){return this._store.widgetConfigurations.widget.currencyFormat.replace("_value_",Number(t)).replace("_currency_",a)}return new Intl.NumberFormat(void 0,{currency:a,style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}_handleRefreshCart(){if(this.refreshCart)return window.location.reload()}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(oe.STATUS_UPDATE,{protection:this._hasProtectionInCart,cart:e?t:this._cart,lineItem:e?this._protectionCartItem:t})}async calculateProtectionTotal(t){if(t||(t=await this._fetchCart()),!t)throw new Error("Could not fetch cart.");if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.calculateProtectionTotal(this._store,this._protectionProduct,t)}_findProtectionVariant(t){if(!this._store)throw new Error("Missing ShipAid store");if(!this._protectionProduct)throw new Error("Missing Shopify protection product");return e.findProtectionVariant(this._store,this._protectionProduct,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(){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 widgetPollProtection\n widgetShowCart\n excludedProductSkus\n excludedCustomersIdsAutoOptIn\n protectionSettings\n widgetConfigurations\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 pe(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 pe(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){pe(i.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}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){pe(t.message)}finally{this._cart=await this._fetchCart(),this._setState("success")}}async attemptAddProtection(){var t,e,i,o,r,s;if(!(null==(t=this._store)?void 0:t.widgetAutoOptIn))return;if(!(null==(e=this._cart)?void 0:e.items)||!(null==(i=this._cart)?void 0:i.item_count))return;const n=null==(o=this._cart.items)?void 0:o.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))})),a=null==(r=this._cart)?void 0:r.items[n];if(this._hasProtectionInCart=!!a,1===this._cart.item_count&&a)return;!!sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(s=this._cart)?void 0:s.item_count)&&this._store.widgetShowCart&&await this.addProtection())}async handleMultipleProtectionVariants(){var t,e,i,o,r;if(!(null==(t=this._cart)?void 0:t.items)||!(null==(e=this._cart)?void 0:e.item_count))return;let s=0;if(null==(i=this._cart.items)||i.forEach((t=>{var e,i;(null==(i=null==(e=this._protectionProduct)?void 0:e.variants)?void 0:i.some((e=>e.id===t.variant_id)))&&s++})),s>1){const t=null==(o=this._cart.items)?void 0:o.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))})),e={id:(null==(r=this._cart)?void 0:r.items[t]).key,quantity:0},i=await this._fetch.post("/cart/change.js",e);return await this._handleRefresh(i)}}learnMorePopupTemplate(){return this.persistPopup&&(this._popup=this.shouldPersistPopup()),B`
796
796
  <shipaid-popup-learn-more
797
797
  ?active=${"learn-more"===this._popup}
798
798
  @close=${()=>{this.persistPopup&&localStorage.removeItem(`${ce}`),this._popup=null}}
@@ -848,7 +848,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
848
848
  </a>
849
849
  </div>
850
850
  </div>
851
- `}async connectedCallback(){super.connectedCallback(),await async function(t,e=_t){const i=await e.loader(t,e);e.translationCache={},yt(t,i,e)}(this.lang),this.hasLoadedStrings=!0}render(){return Tt(this,(async()=>{var t,e,i,o,r,s;const n=document.createElement("link");n.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),n.setAttribute("rel","stylesheet"),document.head.appendChild(n);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(a){return pe(a.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(oe.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.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),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(s=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:s.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(de("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Tt(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 sessionStorage.removeItem(le),await this._handleRefresh(e)}if(!this._store)return;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 pe("No matching protection variant found.");if(!r)return;if(n.id===r.variant_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 this._handleRefreshCart(),await this._handleRefresh(e)}const a={updates:{[r.variant_id]:0,[n.id]:1}},d=await this._fetch.post("/cart/update.js",a);await this._handleRefresh(d)}),[this._store,this._cart]),pt(this.learnMorePopupTemplate(),document.body),B`
851
+ `}async connectedCallback(){super.connectedCallback(),await async function(t,e=_t){const i=await e.loader(t,e);e.translationCache={},yt(t,i,e)}(this.lang),this.hasLoadedStrings=!0}render(){return Tt(this,(async()=>{var t,e,i,o,r,s;const n=document.createElement("link");n.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),n.setAttribute("rel","stylesheet"),document.head.appendChild(n);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(a){return pe(a.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._dispatchEvent(oe.LOADED,this._store),setTimeout((async()=>{var t,e,i,o;(null==(t=this._store)?void 0:t.widgetAutoOptIn)&&(null==(e=this._cart)?void 0:e.item_count)&&(this.customerId&&this._store.excludedCustomersIdsAutoOptIn&&(null==(i=this._store.excludedCustomersIdsAutoOptIn)?void 0:i.length)&&this._store.excludedCustomersIdsAutoOptIn.includes(`gid://shopify/Customer/${this.customerId}`)||sessionStorage.getItem(le)||(sessionStorage.setItem(le,JSON.stringify({loaded:!0})),!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.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),(null==(i=this._store)?void 0:i.widgetPollProtection)&&!this.intervalId&&(this.intervalId=setInterval((async()=>{await this.attemptAddProtection()}),400),localStorage.setItem(`polling-shipaid-protection_${this.intervalId}`,`${this.intervalId}`)),(null==(s=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:s.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(de("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(de("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Tt(this,(async()=>{var t,e,i,o;if(this._cartLastUpdated=new Date,!(null==(t=this._cart)?void 0:t.items))return;const r=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))})),s=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!s,!this._store)return;const n=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&s&&(this._cart.total_price===s.final_line_price||!n)){const t={id:s.key,quantity:0},e=await this._fetch.post("/cart/change.js",t);return sessionStorage.removeItem(le),await this._handleRefresh(e)}const a=this._findProtectionVariant(n);if(n?(this._protectionVariant=a,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==a?void 0:a.id))return this._shouldShowWidget=!1,void pe("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(!s)return;if(a.id===s.variant_id){if(this._protectionCartItem={...s,index:r,position:r+1},1===s.quantity)return;const t={id:s.key,quantity:1},e=await this._fetch.post("/cart/change.js",t);return this._handleRefreshCart(),await this._handleRefresh(e)}const d={updates:{[s.variant_id]:0,[a.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}),[this._store,this._cart]),pt(this.learnMorePopupTemplate(),document.body),B`
852
852
  <style>
853
853
  :host {
854
854
  --shipaid-primary: #002bd6;
@@ -954,7 +954,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const Ot=u`
954
954
  .prompt-product-actions
955
955
  .prompt-product-actions-price {
956
956
  color: var(--shipaid-prompt-actions-price-color, var(--shipaid-text-muted));
957
- font-size: var(--shipaid-font-base);
957
+ font-size: var(--shipaid-prompt-actions-price-fontSize, --shipaid-font-base);
958
958
  }
959
959
  .shipaid-prompt
960
960
  .prompt-product
@@ -45,6 +45,7 @@ export interface ShipAidStore {
45
45
  widgetPollProtection?: boolean;
46
46
  widgetShowCart?: boolean;
47
47
  excludedProductSkus?: string[];
48
+ excludedProductsVariantsId?: string[];
48
49
  excludedCustomersIdsAutoOptIn?: string[] | null;
49
50
  planActive: boolean;
50
51
  protectionSettings: ProtectionSettingsFixed | ProtectionSettingsPercentage;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui.shipaid.com",
3
3
  "private": false,
4
- "version": "0.3.25",
4
+ "version": "0.3.26",
5
5
  "type": "module",
6
6
  "main": "dist/widget.umd.js",
7
7
  "unpkg": "dist/widget.iife.js",