ui.shipaid.com 0.3.12 → 0.3.14

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/README.md CHANGED
@@ -133,6 +133,12 @@ If you need to change any of the widget colors to suit a specific theme, there a
133
133
  | `--shipaid-logo-max-height` | Changes the max height of ShipAid logo. | `var(--shipaid-logo-max-height, 35px)` |
134
134
  | `--shipaid-logo-width` | Changes the width of ShipAid logo. | `var(--shipaid-logo-width, auto)` |
135
135
  | `--shipaid-logo-max-width` | Changes the max width of ShipAid logo. | `var(--shipaid-logo-max-width, 50px)` |
136
+ | `--shipaid-prompt-footer-button-size` | Changes the height of info button in footer. | `var(--shipaid-prompt-footer-button-size, 10px)` |
137
+ | `--shipaid-prompt-badge-border-radius` | Changes border radius of footer | `var(--shipaid-prompt-badge-border-radius, 30px)` |
138
+ | `--shipaid-footer-badge-logo-height` | Changes the height of logo in footer. | `var(--shipaid-footer-badge-logo-height, 9px)` |
139
+ | `--shipaid-prompt-footer-location` | Changes the position of footer badge | `var(--shipaid-prompt-footer-location, flex-start)` |
140
+ | `--shipaid-prompt-product-actions-content` | Changes the spaces between price and add/remove button | `var(--shipaid-prompt-product-actions-content, space-between)` |
141
+ | `--shipaid-prompt-footer-topMargin` | Changes margin between header and badge footer | `var(--shipaid-prompt-footer-topMargin, 0px)` |
136
142
 
137
143
  Other variables can be found [here](/widget/src/assets/styles.ts) (`/widget/src/assets/styles.ts`).
138
144
 
package/dist/widget.es.js CHANGED
@@ -1704,7 +1704,7 @@ const styles = i$2`
1704
1704
  margin-left: auto;
1705
1705
  display: flex;
1706
1706
  flex-direction: column;
1707
- justify-content: space-between;
1707
+ justify-content: var(--shipaid-prompt-product-actions-content, space-between);
1708
1708
  text-align: right;
1709
1709
  min-width: 55px;
1710
1710
  }
@@ -1729,15 +1729,16 @@ const styles = i$2`
1729
1729
  text-align: right;
1730
1730
  }
1731
1731
  .shipaid-prompt .prompt-footer {
1732
+ margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
1732
1733
  display: flex;
1733
1734
  flex-direction: row;
1734
- justify-content: flex-start;
1735
+ justify-content: var(--shipaid-prompt-footer-location, flex-start);
1735
1736
  align-items: center;
1736
1737
  }
1737
1738
  .shipaid-prompt .prompt-footer .prompt-footer-about {
1738
1739
  color: var(--shipaid-text);
1739
1740
  cursor: pointer;
1740
- font-size: 10px;
1741
+ font-size: var(--shipaid-prompt-footer-button-size, 10px);
1741
1742
  background-color: transparent;
1742
1743
  cursor: pointer;
1743
1744
  border: 1px solid var(--shipaid-text);
@@ -1751,7 +1752,7 @@ const styles = i$2`
1751
1752
  );
1752
1753
  color: var(--shipaid-prompt-badge-text-color, var(--shipaid-text));
1753
1754
  padding: 0.2rem 1rem;
1754
- border-radius: 30px;
1755
+ border-radius: var(--shipaid-prompt-badge-border-radius, 30px);
1755
1756
  cursor: pointer;
1756
1757
  text-decoration: none;
1757
1758
  font-size: var(--shipaid-font-xs);
@@ -1761,7 +1762,7 @@ const styles = i$2`
1761
1762
  white-space: nowrap;
1762
1763
  }
1763
1764
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
1764
- height: 9px;
1765
+ height:var(--shipaid-footer-badge-logo-height, 9px);
1765
1766
  }
1766
1767
  `;
1767
1768
  var Events = /* @__PURE__ */ ((Events2) => {
@@ -2454,7 +2455,7 @@ let ShipAidWidget = class extends s$1 {
2454
2455
  margin-left: auto;
2455
2456
  display: flex;
2456
2457
  flex-direction: column;
2457
- justify-content: space-between;
2458
+ justify-content: var(--shipaid-prompt-product-actions-content, space-between);
2458
2459
  text-align: right;
2459
2460
  min-width: 55px;
2460
2461
  }
@@ -2479,15 +2480,16 @@ let ShipAidWidget = class extends s$1 {
2479
2480
  text-align: right;
2480
2481
  }
2481
2482
  .shipaid-prompt .prompt-footer {
2483
+ margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
2482
2484
  display: flex;
2483
2485
  flex-direction: row;
2484
- justify-content: flex-start;
2486
+ justify-content: var(--shipaid-prompt-footer-location, flex-start);
2485
2487
  align-items: center;
2486
2488
  }
2487
2489
  .shipaid-prompt .prompt-footer .prompt-footer-about {
2488
2490
  color: var(--shipaid-text);
2489
2491
  cursor: pointer;
2490
- font-size: 10px;
2492
+ font-size: var(--shipaid-prompt-footer-button-size, 10px);
2491
2493
  background-color: transparent;
2492
2494
  cursor: pointer;
2493
2495
  border: 1px solid var(--shipaid-text);
@@ -2501,7 +2503,7 @@ let ShipAidWidget = class extends s$1 {
2501
2503
  );
2502
2504
  color: var(--shipaid-prompt-badge-text-color, var(--shipaid-text));
2503
2505
  padding: 0.2rem 1rem;
2504
- border-radius: 30px;
2506
+ border-radius: var(--shipaid-prompt-badge-border-radius, 30px);
2505
2507
  cursor: pointer;
2506
2508
  text-decoration: none;
2507
2509
  font-size: var(--shipaid-font-xs);
@@ -2511,7 +2513,7 @@ let ShipAidWidget = class extends s$1 {
2511
2513
  white-space: nowrap;
2512
2514
  }
2513
2515
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
2514
- height: 9px;
2516
+ height:var(--shipaid-footer-badge-logo-height, 9px);
2515
2517
  }
2516
2518
  </style>
2517
2519
  <div class="shipaid">
@@ -728,7 +728,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
728
728
  margin-left: auto;
729
729
  display: flex;
730
730
  flex-direction: column;
731
- justify-content: space-between;
731
+ justify-content: var(--shipaid-prompt-product-actions-content, space-between);
732
732
  text-align: right;
733
733
  min-width: 55px;
734
734
  }
@@ -753,15 +753,16 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
753
753
  text-align: right;
754
754
  }
755
755
  .shipaid-prompt .prompt-footer {
756
+ margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
756
757
  display: flex;
757
758
  flex-direction: row;
758
- justify-content: flex-start;
759
+ justify-content: var(--shipaid-prompt-footer-location, flex-start);
759
760
  align-items: center;
760
761
  }
761
762
  .shipaid-prompt .prompt-footer .prompt-footer-about {
762
763
  color: var(--shipaid-text);
763
764
  cursor: pointer;
764
- font-size: 10px;
765
+ font-size: var(--shipaid-prompt-footer-button-size, 10px);
765
766
  background-color: transparent;
766
767
  cursor: pointer;
767
768
  border: 1px solid var(--shipaid-text);
@@ -775,7 +776,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
775
776
  );
776
777
  color: var(--shipaid-prompt-badge-text-color, var(--shipaid-text));
777
778
  padding: 0.2rem 1rem;
778
- border-radius: 30px;
779
+ border-radius: var(--shipaid-prompt-badge-border-radius, 30px);
779
780
  cursor: pointer;
780
781
  text-decoration: none;
781
782
  font-size: var(--shipaid-font-xs);
@@ -785,7 +786,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
785
786
  white-space: nowrap;
786
787
  }
787
788
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
788
- height: 9px;
789
+ height:var(--shipaid-footer-badge-logo-height, 9px);
789
790
  }
790
791
  `;var oe=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(oe||{}),re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ae=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?se(e,i):e,a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&re(e,i,s),s};const ne=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.")}},pe=t=>console.warn(`[ShipAid] ${t}`),de=t=>console.error(`[ShipAid] ${t}`),le="shipaid-protection",ce=Object.assign({"./lang/en.json":()=>Promise.resolve().then((()=>ee)).then((t=>t.default)),"./lang/es.json":()=>Promise.resolve().then((()=>ye)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>Le)).then((t=>t.default)),"./lang/pt.json":()=>Promise.resolve().then((()=>Te)).then((t=>t.default))});var he;he={loader:async t=>{if("en"===t)return te;const e=Reflect.get(ce,`./lang/${t}.json`);return e?await e():te}},_t=Object.assign(Object.assign({},_t),he),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.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=>ne(t),post:(t,e)=>ne(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(pe("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o;return new Intl.NumberFormat(void 0,{currency:this.currency||(null==(e=this._store)?void 0:e.currency)||(null==(o=null==(i=window.Shopify)?void 0:i.currency)?void 0:o.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(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 }\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(a){throw console.error(a),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw de(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 de(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){de(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const t={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){de(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}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 a=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))})),n=null==(r=this._cart)?void 0:r.items[a];if(this._hasProtectionInCart=!!n,1===this._cart.item_count&&n)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())}learnMorePopupTemplate(){return B`
791
792
  <shipaid-popup-learn-more
@@ -935,7 +936,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
935
936
  margin-left: auto;
936
937
  display: flex;
937
938
  flex-direction: column;
938
- justify-content: space-between;
939
+ justify-content: var(--shipaid-prompt-product-actions-content, space-between);
939
940
  text-align: right;
940
941
  min-width: 55px;
941
942
  }
@@ -960,15 +961,16 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
960
961
  text-align: right;
961
962
  }
962
963
  .shipaid-prompt .prompt-footer {
964
+ margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
963
965
  display: flex;
964
966
  flex-direction: row;
965
- justify-content: flex-start;
967
+ justify-content: var(--shipaid-prompt-footer-location, flex-start);
966
968
  align-items: center;
967
969
  }
968
970
  .shipaid-prompt .prompt-footer .prompt-footer-about {
969
971
  color: var(--shipaid-text);
970
972
  cursor: pointer;
971
- font-size: 10px;
973
+ font-size: var(--shipaid-prompt-footer-button-size, 10px);
972
974
  background-color: transparent;
973
975
  cursor: pointer;
974
976
  border: 1px solid var(--shipaid-text);
@@ -982,7 +984,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
982
984
  );
983
985
  color: var(--shipaid-prompt-badge-text-color, var(--shipaid-text));
984
986
  padding: 0.2rem 1rem;
985
- border-radius: 30px;
987
+ border-radius: var(--shipaid-prompt-badge-border-radius, 30px);
986
988
  cursor: pointer;
987
989
  text-decoration: none;
988
990
  font-size: var(--shipaid-font-xs);
@@ -992,7 +994,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
992
994
  white-space: nowrap;
993
995
  }
994
996
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
995
- height: 9px;
997
+ height:var(--shipaid-footer-badge-logo-height, 9px);
996
998
  }
997
999
  </style>
998
1000
  <div class="shipaid">
@@ -728,7 +728,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
728
728
  margin-left: auto;
729
729
  display: flex;
730
730
  flex-direction: column;
731
- justify-content: space-between;
731
+ justify-content: var(--shipaid-prompt-product-actions-content, space-between);
732
732
  text-align: right;
733
733
  min-width: 55px;
734
734
  }
@@ -753,15 +753,16 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
753
753
  text-align: right;
754
754
  }
755
755
  .shipaid-prompt .prompt-footer {
756
+ margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
756
757
  display: flex;
757
758
  flex-direction: row;
758
- justify-content: flex-start;
759
+ justify-content: var(--shipaid-prompt-footer-location, flex-start);
759
760
  align-items: center;
760
761
  }
761
762
  .shipaid-prompt .prompt-footer .prompt-footer-about {
762
763
  color: var(--shipaid-text);
763
764
  cursor: pointer;
764
- font-size: 10px;
765
+ font-size: var(--shipaid-prompt-footer-button-size, 10px);
765
766
  background-color: transparent;
766
767
  cursor: pointer;
767
768
  border: 1px solid var(--shipaid-text);
@@ -775,7 +776,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
775
776
  );
776
777
  color: var(--shipaid-prompt-badge-text-color, var(--shipaid-text));
777
778
  padding: 0.2rem 1rem;
778
- border-radius: 30px;
779
+ border-radius: var(--shipaid-prompt-badge-border-radius, 30px);
779
780
  cursor: pointer;
780
781
  text-decoration: none;
781
782
  font-size: var(--shipaid-font-xs);
@@ -785,7 +786,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
785
786
  white-space: nowrap;
786
787
  }
787
788
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
788
- height: 9px;
789
+ height:var(--shipaid-footer-badge-logo-height, 9px);
789
790
  }
790
791
  `;var oe=(t=>(t.LOADED="shipaid-loaded",t.STATUS_UPDATE="shipaid-protection-status",t))(oe||{}),re=Object.defineProperty,se=Object.getOwnPropertyDescriptor,ae=(t,e,i,o)=>{for(var r,s=o>1?void 0:o?se(e,i):e,a=t.length-1;a>=0;a--)(r=t[a])&&(s=(o?r(e,i,s):r(s))||s);return o&&s&&re(e,i,s),s};const ne=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.")}},pe=t=>console.warn(`[ShipAid] ${t}`),de=t=>console.error(`[ShipAid] ${t}`),le="shipaid-protection",ce=Object.assign({"./lang/en.json":()=>Promise.resolve().then((()=>ee)).then((t=>t.default)),"./lang/es.json":()=>Promise.resolve().then((()=>ye)).then((t=>t.default)),"./lang/it.json":()=>Promise.resolve().then((()=>Le)).then((t=>t.default)),"./lang/pt.json":()=>Promise.resolve().then((()=>Te)).then((t=>t.default))});var he;he={loader:async t=>{if("en"===t)return te;const e=Reflect.get(ce,`./lang/${t}.json`);return e?await e():te}},_t=Object.assign(Object.assign({},_t),he),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.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=>ne(t),post:(t,e)=>ne(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}}shouldUpdate(t){return this.hasLoadedStrings&&super.shouldUpdate(t)}get shouldRefreshOnUpdate(){return!this.disablePolling&&!this.disableRefresh}get planActive(){var t,e;const{searchParams:i}=new URL(window.location.href);return(null==(t=window.Shopify)?void 0:t.designMode)||i.has("shipaid-test")?(pe("Currently in preview mode."),!0):!!(null==(e=this._store)?void 0:e.planActive)}_currencyFormat(t){var e,i,o;return new Intl.NumberFormat(void 0,{currency:this.currency||(null==(e=this._store)?void 0:e.currency)||(null==(o=null==(i=window.Shopify)?void 0:i.currency)?void 0:o.active)||"USD",style:"currency"}).format(Number(t))}_dispatchEvent(t,e={}){this.dispatchEvent(new CustomEvent(t,{bubbles:!0,composed:!0,detail:e}))}async _handleRefresh(t){const e=Reflect.has(t,"items");if(this.shouldRefreshOnUpdate)return window.location.reload();e||await this.updateCart(),this._dispatchEvent(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 }\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(a){throw console.error(a),new Error(`Could not find a store for ${this._storeDomain}`)}}async _fetchCart(){try{return await this._fetch.get("/cart.js")}catch(t){throw de(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 de(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){de(i.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}async removeProtection(){try{if(!this._store)throw new Error("Store has not been loaded.");if(!this._protectionCartItem)throw new Error("Protection product not found.");this._setState("loading");const t={quantity:0,id:this._protectionCartItem.key},e=await this._fetch.post("/cart/change.js",t);await this._handleRefresh(e),this._cart=e,this._setState("success")}catch(t){de(t.message),this._setState("error","Failed to add protection to cart - please try again, or contact us for help.")}}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 a=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))})),n=null==(r=this._cart)?void 0:r.items[a];if(this._hasProtectionInCart=!!n,1===this._cart.item_count&&n)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())}learnMorePopupTemplate(){return B`
791
792
  <shipaid-popup-learn-more
@@ -935,7 +936,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
935
936
  margin-left: auto;
936
937
  display: flex;
937
938
  flex-direction: column;
938
- justify-content: space-between;
939
+ justify-content: var(--shipaid-prompt-product-actions-content, space-between);
939
940
  text-align: right;
940
941
  min-width: 55px;
941
942
  }
@@ -960,15 +961,16 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
960
961
  text-align: right;
961
962
  }
962
963
  .shipaid-prompt .prompt-footer {
964
+ margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
963
965
  display: flex;
964
966
  flex-direction: row;
965
- justify-content: flex-start;
967
+ justify-content: var(--shipaid-prompt-footer-location, flex-start);
966
968
  align-items: center;
967
969
  }
968
970
  .shipaid-prompt .prompt-footer .prompt-footer-about {
969
971
  color: var(--shipaid-text);
970
972
  cursor: pointer;
971
- font-size: 10px;
973
+ font-size: var(--shipaid-prompt-footer-button-size, 10px);
972
974
  background-color: transparent;
973
975
  cursor: pointer;
974
976
  border: 1px solid var(--shipaid-text);
@@ -982,7 +984,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
982
984
  );
983
985
  color: var(--shipaid-prompt-badge-text-color, var(--shipaid-text));
984
986
  padding: 0.2rem 1rem;
985
- border-radius: 30px;
987
+ border-radius: var(--shipaid-prompt-badge-border-radius, 30px);
986
988
  cursor: pointer;
987
989
  text-decoration: none;
988
990
  font-size: var(--shipaid-font-xs);
@@ -992,7 +994,7 @@ function It(t,e,i){return t?e():null==i?void 0:i()}const qt=u`
992
994
  white-space: nowrap;
993
995
  }
994
996
  .shipaid-prompt .prompt-footer .prompt-footer-badge svg {
995
- height: 9px;
997
+ height:var(--shipaid-footer-badge-logo-height, 9px);
996
998
  }
997
999
  </style>
998
1000
  <div class="shipaid">
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui.shipaid.com",
3
3
  "private": false,
4
- "version": "0.3.12",
4
+ "version": "0.3.14",
5
5
  "type": "module",
6
6
  "main": "dist/widget.umd.js",
7
7
  "unpkg": "dist/widget.iife.js",