ui.shipaid.com 0.3.101 → 0.3.102

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
@@ -3303,7 +3303,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3303
3303
  }
3304
3304
  }
3305
3305
  promptTemplate() {
3306
- var _a, _b, _c;
3306
+ var _a, _b, _c, _d, _e;
3307
3307
  if (this.useShipAidCheckout && this.dataSelector) {
3308
3308
  return this.checkoutButtonTemplate();
3309
3309
  }
@@ -3328,16 +3328,32 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3328
3328
  )}
3329
3329
  </div>
3330
3330
  <div class="prompt-product-details">
3331
- <p class="prompt-product-details-title">
3332
- <slot name="title">${translate("title")}</slot>
3333
- </p>
3331
+ <div class="heading-container">
3332
+ <p class="prompt-product-details-title">
3333
+ <slot name="title">${translate("title")}</slot>
3334
+ </p>
3335
+ ${n(
3336
+ !((_c = this._store) == null ? void 0 : _c.useCustomApp),
3337
+ () => x`<button
3338
+ class="prompt-information-button"
3339
+ @click=${() => {
3340
+ this._popup = "learn-more";
3341
+ if (this.persistPopup) {
3342
+ this.setPopupKey();
3343
+ }
3344
+ }}
3345
+ >
3346
+ i
3347
+ </button>`
3348
+ )}
3349
+ </div>
3334
3350
  <p class="prompt-product-details-description">
3335
3351
  <slot name="subtitle">${translate("description")}</slot>
3336
3352
  </p>
3337
3353
  </div>
3338
3354
  <div class="prompt-product-actions">
3339
3355
  <p class="prompt-product-actions-price">
3340
- ${((_c = this._protectionVariant) == null ? void 0 : _c.price) && this._currencyFormat(this._protectionVariant.price)}
3356
+ ${((_d = this._protectionVariant) == null ? void 0 : _d.price) && this._currencyFormat(this._protectionVariant.price)}
3341
3357
  </p>
3342
3358
  ${!(useToggle || useCheckbox) && !this.defaultToggleButton ? n(
3343
3359
  !this.disableActions,
@@ -3365,31 +3381,36 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3365
3381
  this._state.error,
3366
3382
  () => x`<p class="error">${this._state.error}</p>`
3367
3383
  )}
3368
- <div class="prompt-footer">
3369
- <a
3370
- class="prompt-footer-badge"
3371
- @click=${() => {
3372
- this._popup = "learn-more";
3373
- if (this.persistPopup) {
3374
- this.setPopupKey();
3375
- }
3376
- }}
3377
- >
3378
- <span>${translate("footer.button")}</span>
3379
- ${ShipAidLogoText}
3380
- <button
3381
- class="prompt-footer-about"
3382
- @click=${() => {
3383
- this._popup = "learn-more";
3384
- if (this.persistPopup) {
3385
- this.setPopupKey();
3386
- }
3387
- }}
3388
- >
3389
- i
3390
- </button>
3391
- </a>
3392
- </div>
3384
+ ${n(
3385
+ (_e = this._store) == null ? void 0 : _e.useCustomApp,
3386
+ () => x`
3387
+ <div class="prompt-footer">
3388
+ <a
3389
+ class="prompt-footer-badge"
3390
+ @click=${() => {
3391
+ this._popup = "learn-more";
3392
+ if (this.persistPopup) {
3393
+ this.setPopupKey();
3394
+ }
3395
+ }}
3396
+ >
3397
+ <span>${translate("footer.button")}</span>
3398
+ ${ShipAidLogoText}
3399
+ <button
3400
+ class="prompt-footer-about"
3401
+ @click=${() => {
3402
+ this._popup = "learn-more";
3403
+ if (this.persistPopup) {
3404
+ this.setPopupKey();
3405
+ }
3406
+ }}
3407
+ >
3408
+ i
3409
+ </button>
3410
+ </a>
3411
+ </div>
3412
+ `
3413
+ )}
3393
3414
  </div>
3394
3415
  `;
3395
3416
  }
@@ -3774,6 +3795,17 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3774
3795
  padding: 6px 0;
3775
3796
  text-align: right;
3776
3797
  }
3798
+ .shipaid-prompt .prompt-information-button {
3799
+ color: var(--shipaid-text);
3800
+ cursor: pointer;
3801
+ font-size: var(--shipaid-prompt-prompt-information-button-size, 10px);
3802
+ background-color: transparent;
3803
+ cursor: pointer;
3804
+ border: 1px solid var(--shipaid-text);
3805
+ border-radius: 10px;
3806
+ margin-left: 0.5rem;
3807
+ }
3808
+
3777
3809
  .shipaid-prompt .prompt-footer {
3778
3810
  margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
3779
3811
  margin-left: var(--shipaid-prompt-footer-leftMargin, 0px);
@@ -3812,6 +3844,16 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3812
3844
  height:var(--shipaid-footer-badge-logo-height, 9px);
3813
3845
  }
3814
3846
 
3847
+ .shipaid-prompt .heading-container{
3848
+ display: var(--shipaid-prompt-heading-container-display, flex);
3849
+ justify-content: var(--shipaid-prompt-heading-container-justify-content, start);
3850
+ align-items: var(--shipaid-prompt-heading-container-align-items, center);
3851
+ }
3852
+
3853
+ .shipaid-prompt .heading-container > p{
3854
+ margin: var(--shipaid-prompt-heading-container-gap-margin, 0px 10px 0px 0px);
3855
+ }
3856
+
3815
3857
  .shipaid-checkbox {
3816
3858
  display: inline-block;
3817
3859
  position: relative;
@@ -1412,10 +1412,10 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1412
1412
  <slot name="link-continue">${Lt("checkout-plus.continue")}</slot>
1413
1413
  </a>
1414
1414
  </div>
1415
- `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:o,useCheckbox:r,leftCheckbox:n}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1415
+ `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i,o,r;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:n,useCheckbox:a,leftCheckbox:s}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1416
1416
  <div class="shipaid-prompt">
1417
1417
  <div class="prompt-product">
1418
- ${Tt(!this.disableActions&&n,(()=>F`
1418
+ ${Tt(!this.disableActions&&s,(()=>F`
1419
1419
  <label class="shipaid-checkbox">
1420
1420
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1421
1421
  <span class="shipaid-checkMark left"></span>
@@ -1425,21 +1425,29 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1425
1425
  ${Tt(this._hasProtectionInCart,(()=>Nt),(()=>jt))}
1426
1426
  </div>
1427
1427
  <div class="prompt-product-details">
1428
- <p class="prompt-product-details-title">
1429
- <slot name="title">${Lt("title")}</slot>
1430
- </p>
1428
+ <div class="heading-container">
1429
+ <p class="prompt-product-details-title">
1430
+ <slot name="title">${Lt("title")}</slot>
1431
+ </p>
1432
+ ${Tt(!(null==(i=this._store)?void 0:i.useCustomApp),(()=>F`<button
1433
+ class="prompt-information-button"
1434
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1435
+ >
1436
+ i
1437
+ </button>`))}
1438
+ </div>
1431
1439
  <p class="prompt-product-details-description">
1432
1440
  <slot name="subtitle">${Lt("description")}</slot>
1433
1441
  </p>
1434
1442
  </div>
1435
1443
  <div class="prompt-product-actions">
1436
1444
  <p class="prompt-product-actions-price">
1437
- ${(null==(i=this._protectionVariant)?void 0:i.price)&&this._currencyFormat(this._protectionVariant.price)}
1445
+ ${(null==(o=this._protectionVariant)?void 0:o.price)&&this._currencyFormat(this._protectionVariant.price)}
1438
1446
  </p>
1439
- ${o||r||this.defaultToggleButton?Tt(!this.disableActions&&!n,(()=>F`
1440
- <label class="shipaid-${o?"toggle":r?"checkbox":""}">
1447
+ ${n||a||this.defaultToggleButton?Tt(!this.disableActions&&!s,(()=>F`
1448
+ <label class="shipaid-${n?"toggle":a?"checkbox":""}">
1441
1449
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1442
- <span class="shipaid-${o?"slider":r?"checkMark":""}"></span>
1450
+ <span class="shipaid-${n?"slider":a?"checkMark":""}"></span>
1443
1451
  </label>
1444
1452
  `)):Tt(!this.disableActions,(()=>F`
1445
1453
  <button
@@ -1453,21 +1461,23 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1453
1461
  </div>
1454
1462
  </div>
1455
1463
  ${Tt(this._state.error,(()=>F`<p class="error">${this._state.error}</p>`))}
1456
- <div class="prompt-footer">
1457
- <a
1458
- class="prompt-footer-badge"
1459
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1460
- >
1461
- <span>${Lt("footer.button")}</span>
1462
- ${Vt}
1463
- <button
1464
- class="prompt-footer-about"
1465
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1466
- >
1467
- i
1468
- </button>
1469
- </a>
1470
- </div>
1464
+ ${Tt(null==(r=this._store)?void 0:r.useCustomApp,(()=>F`
1465
+ <div class="prompt-footer">
1466
+ <a
1467
+ class="prompt-footer-badge"
1468
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1469
+ >
1470
+ <span>${Lt("footer.button")}</span>
1471
+ ${Vt}
1472
+ <button
1473
+ class="prompt-footer-about"
1474
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1475
+ >
1476
+ i
1477
+ </button>
1478
+ </a>
1479
+ </div>
1480
+ `))}
1471
1481
  </div>
1472
1482
  `}async connectedCallback(){super.connectedCallback(),await async function(t,e=vt){const i=await e.loader(t,e);e.translationCache={},bt(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const n=e(o,r);if(i)try{await t([o,r],n)}catch(a){console.warn(a)}return await n};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,n;if(null==(o=null==(i=t[1])?void 0:i.headers)?void 0:o["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const a=(null==(n=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:n.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',s=document.querySelector(a);if(console.log("q",s),s){s.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{s.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){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))})),n=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t=await this.updateCartProtectionVariant(0,n);return sessionStorage.removeItem(_e),await this._handleRefresh(t)}const s=this._findProtectionVariant(a);if(a?(this._protectionVariant=s,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==s?void 0:s.id))return this._shouldShowWidget=!1,void ye("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(this.useShipAidCheckout&&this.supportSubscriptions&&(this._sellingPlanId=await this.getSubscription(this._cart)),!n)return;if(this.supportSubscriptions&&!this.useShipAidCheckout){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let e=!0;if(!t&&(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=null:t&&!(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=await this.getSubscription(this._cart):e=!1,e){const t=await this.updateCartProtectionVariant(1,n);await this._handleRefresh(t)}}if(s.id===n.variant_id){if(this._protectionCartItem={...n,index:r,position:r+1},1===n.quantity)return;const t=await this.updateCartProtectionVariant(1,n);return this._handleRefreshCart(),await this._handleRefresh(t)}const d={updates:{[n.variant_id]:0,[s.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}render(){return Mt(this,(async()=>{var t,e,i,o,r,n;const a=document.createElement("link");a.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),a.setAttribute("rel","stylesheet"),document.head.appendChild(a);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(s){return ye(s.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(ue.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(_e)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(_e,JSON.stringify({loaded:!0}))))}),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==(n=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:n.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(be("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Mt(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),Mt(this,(async()=>{dt(this.renderPopups(),document.body)}),[this._popup]),F`
1473
1483
  <style>
@@ -1598,6 +1608,17 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1598
1608
  padding: 6px 0;
1599
1609
  text-align: right;
1600
1610
  }
1611
+ .shipaid-prompt .prompt-information-button {
1612
+ color: var(--shipaid-text);
1613
+ cursor: pointer;
1614
+ font-size: var(--shipaid-prompt-prompt-information-button-size, 10px);
1615
+ background-color: transparent;
1616
+ cursor: pointer;
1617
+ border: 1px solid var(--shipaid-text);
1618
+ border-radius: 10px;
1619
+ margin-left: 0.5rem;
1620
+ }
1621
+
1601
1622
  .shipaid-prompt .prompt-footer {
1602
1623
  margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
1603
1624
  margin-left: var(--shipaid-prompt-footer-leftMargin, 0px);
@@ -1636,6 +1657,16 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1636
1657
  height:var(--shipaid-footer-badge-logo-height, 9px);
1637
1658
  }
1638
1659
 
1660
+ .shipaid-prompt .heading-container{
1661
+ display: var(--shipaid-prompt-heading-container-display, flex);
1662
+ justify-content: var(--shipaid-prompt-heading-container-justify-content, start);
1663
+ align-items: var(--shipaid-prompt-heading-container-align-items, center);
1664
+ }
1665
+
1666
+ .shipaid-prompt .heading-container > p{
1667
+ margin: var(--shipaid-prompt-heading-container-gap-margin, 0px 10px 0px 0px);
1668
+ }
1669
+
1639
1670
  .shipaid-checkbox {
1640
1671
  display: inline-block;
1641
1672
  position: relative;
@@ -1412,10 +1412,10 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1412
1412
  <slot name="link-continue">${Lt("checkout-plus.continue")}</slot>
1413
1413
  </a>
1414
1414
  </div>
1415
- `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:o,useCheckbox:r,leftCheckbox:n}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1415
+ `}renderPopups(){switch(this.persistPopup&&(this._popup=this.shouldPersistPopup()),this._popup){case"confirmation":return this.confirmationPopupTemplate();case"learn-more":return this.learnMorePopupTemplate();default:return null}}promptTemplate(){var t,e,i,o,r;if(this.useShipAidCheckout&&this.dataSelector)return this.checkoutButtonTemplate();const{useToggle:n,useCheckbox:a,leftCheckbox:s}=(null==(e=null==(t=this._store)?void 0:t.widgetConfigurations)?void 0:e.widget)||{useToggle:!1,useCheckbox:!1,leftCheckbox:!1};return F`
1416
1416
  <div class="shipaid-prompt">
1417
1417
  <div class="prompt-product">
1418
- ${Tt(!this.disableActions&&n,(()=>F`
1418
+ ${Tt(!this.disableActions&&s,(()=>F`
1419
1419
  <label class="shipaid-checkbox">
1420
1420
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1421
1421
  <span class="shipaid-checkMark left"></span>
@@ -1425,21 +1425,29 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1425
1425
  ${Tt(this._hasProtectionInCart,(()=>Nt),(()=>jt))}
1426
1426
  </div>
1427
1427
  <div class="prompt-product-details">
1428
- <p class="prompt-product-details-title">
1429
- <slot name="title">${Lt("title")}</slot>
1430
- </p>
1428
+ <div class="heading-container">
1429
+ <p class="prompt-product-details-title">
1430
+ <slot name="title">${Lt("title")}</slot>
1431
+ </p>
1432
+ ${Tt(!(null==(i=this._store)?void 0:i.useCustomApp),(()=>F`<button
1433
+ class="prompt-information-button"
1434
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1435
+ >
1436
+ i
1437
+ </button>`))}
1438
+ </div>
1431
1439
  <p class="prompt-product-details-description">
1432
1440
  <slot name="subtitle">${Lt("description")}</slot>
1433
1441
  </p>
1434
1442
  </div>
1435
1443
  <div class="prompt-product-actions">
1436
1444
  <p class="prompt-product-actions-price">
1437
- ${(null==(i=this._protectionVariant)?void 0:i.price)&&this._currencyFormat(this._protectionVariant.price)}
1445
+ ${(null==(o=this._protectionVariant)?void 0:o.price)&&this._currencyFormat(this._protectionVariant.price)}
1438
1446
  </p>
1439
- ${o||r||this.defaultToggleButton?Tt(!this.disableActions&&!n,(()=>F`
1440
- <label class="shipaid-${o?"toggle":r?"checkbox":""}">
1447
+ ${n||a||this.defaultToggleButton?Tt(!this.disableActions&&!s,(()=>F`
1448
+ <label class="shipaid-${n?"toggle":a?"checkbox":""}">
1441
1449
  ${this._hasProtectionInCart||!this._hasFinishedSetup?F`<input type="checkbox" checked @click=${this._updateProtection} ?disabled=${this._state.loading}>`:F`<input type="checkbox" @click=${this._updateProtection} ?disabled=${this._state.loading}>`}
1442
- <span class="shipaid-${o?"slider":r?"checkMark":""}"></span>
1450
+ <span class="shipaid-${n?"slider":a?"checkMark":""}"></span>
1443
1451
  </label>
1444
1452
  `)):Tt(!this.disableActions,(()=>F`
1445
1453
  <button
@@ -1453,21 +1461,23 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1453
1461
  </div>
1454
1462
  </div>
1455
1463
  ${Tt(this._state.error,(()=>F`<p class="error">${this._state.error}</p>`))}
1456
- <div class="prompt-footer">
1457
- <a
1458
- class="prompt-footer-badge"
1459
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1460
- >
1461
- <span>${Lt("footer.button")}</span>
1462
- ${Vt}
1463
- <button
1464
- class="prompt-footer-about"
1465
- @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1466
- >
1467
- i
1468
- </button>
1469
- </a>
1470
- </div>
1464
+ ${Tt(null==(r=this._store)?void 0:r.useCustomApp,(()=>F`
1465
+ <div class="prompt-footer">
1466
+ <a
1467
+ class="prompt-footer-badge"
1468
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1469
+ >
1470
+ <span>${Lt("footer.button")}</span>
1471
+ ${Vt}
1472
+ <button
1473
+ class="prompt-footer-about"
1474
+ @click=${()=>{this._popup="learn-more",this.persistPopup&&this.setPopupKey()}}
1475
+ >
1476
+ i
1477
+ </button>
1478
+ </a>
1479
+ </div>
1480
+ `))}
1471
1481
  </div>
1472
1482
  `}async connectedCallback(){super.connectedCallback(),await async function(t,e=vt){const i=await e.loader(t,e);e.translationCache={},bt(t,i,e)}(this.lang),this.hasLoadedStrings=!0,this.fetchInterceptorCleanup=function(t){const e=window.fetch;let i=!0;const o=async(o,r)=>{const n=e(o,r);if(i)try{await t([o,r],n)}catch(a){console.warn(a)}return await n};return window.fetch=o,()=>{window.fetch===o?window.fetch=e:i=!1}}((async(t,e)=>{var i,o,r,n;if(null==(o=null==(i=t[1])?void 0:i.headers)?void 0:o["X-ShipAid"])return;if(!t[0].startsWith("/cart/change")&&!t[0].startsWith("/cart/update"))return;const a=(null==(n=null==(r=this._store)?void 0:r.widgetConfigurations)?void 0:n.checkoutButtonSelector)||'button[type="submit"][name="checkout"][form="cart"]',s=document.querySelector(a);if(console.log("q",s),s){s.setAttribute("disabled","true"),console.debug("button","t");try{await e,await this.updateCart(),await this.updateProtection()}finally{s.removeAttribute("disabled"),console.debug("button","f")}}}))}disconnectedCallback(){var t;super.disconnectedCallback(),null==(t=this.fetchInterceptorCleanup)||t.call(this)}async updateProtection(){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))})),n=null==(i=this._cart)?void 0:i.items[r];if(this._hasProtectionInCart=!!n,!this._store)return;const a=await this.calculateProtectionTotal(this._cart);if(this._cart.item_count>0&&n&&(this._cart.total_price===(null==n?void 0:n.final_line_price)||!a)){const t=await this.updateCartProtectionVariant(0,n);return sessionStorage.removeItem(_e),await this._handleRefresh(t)}const s=this._findProtectionVariant(a);if(a?(this._protectionVariant=s,this._shouldShowWidget=!0):this._protectionVariant={id:0,price:"0"},!(null==s?void 0:s.id))return this._shouldShowWidget=!1,void ye("No matching protection variant found.");if(!(null==(o=this._protectionVariant)?void 0:o.id))return void(this._shouldShowWidget=!1);if(this.useShipAidCheckout&&this.supportSubscriptions&&(this._sellingPlanId=await this.getSubscription(this._cart)),!n)return;if(this.supportSubscriptions&&!this.useShipAidCheckout){const t=this._cart.items.find((t=>{var e;return t.id!==(null==(e=this._protectionVariant)?void 0:e.id)&&!!(null==t?void 0:t.selling_plan_allocation)}));let e=!0;if(!t&&(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=null:t&&!(null==n?void 0:n.selling_plan_allocation)?this._sellingPlanId=await this.getSubscription(this._cart):e=!1,e){const t=await this.updateCartProtectionVariant(1,n);await this._handleRefresh(t)}}if(s.id===n.variant_id){if(this._protectionCartItem={...n,index:r,position:r+1},1===n.quantity)return;const t=await this.updateCartProtectionVariant(1,n);return this._handleRefreshCart(),await this._handleRefresh(t)}const d={updates:{[n.variant_id]:0,[s.id]:1}},p=await this._fetch.post("/cart/update.js",d);await this._handleRefresh(p)}render(){return Mt(this,(async()=>{var t,e,i,o,r,n;const a=document.createElement("link");a.setAttribute("href","https://fonts.googleapis.com/css2?family=Lato&display=swap"),a.setAttribute("rel","stylesheet"),document.head.appendChild(a);try{const[t,e,i]=await Promise.all([this._fetchShipAidData(),this._fetchCart(),this._fetchProduct()]);this._store=t,this._cart=e,this._protectionProduct=i}catch(s){return ye(s.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(ue.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(_e)||!this._hasProtectionInCart&&(null==(o=this._cart)?void 0:o.item_count)&&this._store.widgetShowCart&&(await this.addProtection(),sessionStorage.setItem(_e,JSON.stringify({loaded:!0}))))}),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==(n=null==(r=null==(o=this._store)?void 0:o.widgetConfigurations)?void 0:r.widget)?void 0:n.pollVariantsCheck)&&setInterval((async()=>{await this.handleMultipleProtectionVariants()}),400)))):(be("No protection settings product for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No protection settings for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1)):(be("No plan is active for this store - skipping setup."),this._hasFinishedSetup=!0,void(this._shouldShowWidget=!1))}),[]),Mt(this,(async()=>{await this.updateProtection()}),[this._store,this._cart]),Mt(this,(async()=>{dt(this.renderPopups(),document.body)}),[this._popup]),F`
1473
1483
  <style>
@@ -1598,6 +1608,17 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1598
1608
  padding: 6px 0;
1599
1609
  text-align: right;
1600
1610
  }
1611
+ .shipaid-prompt .prompt-information-button {
1612
+ color: var(--shipaid-text);
1613
+ cursor: pointer;
1614
+ font-size: var(--shipaid-prompt-prompt-information-button-size, 10px);
1615
+ background-color: transparent;
1616
+ cursor: pointer;
1617
+ border: 1px solid var(--shipaid-text);
1618
+ border-radius: 10px;
1619
+ margin-left: 0.5rem;
1620
+ }
1621
+
1601
1622
  .shipaid-prompt .prompt-footer {
1602
1623
  margin-top: var(--shipaid-prompt-footer-topMargin, 0px);
1603
1624
  margin-left: var(--shipaid-prompt-footer-leftMargin, 0px);
@@ -1636,6 +1657,16 @@ function Tt(t,e,i){return t?e():null==i?void 0:i()}const qt=h`
1636
1657
  height:var(--shipaid-footer-badge-logo-height, 9px);
1637
1658
  }
1638
1659
 
1660
+ .shipaid-prompt .heading-container{
1661
+ display: var(--shipaid-prompt-heading-container-display, flex);
1662
+ justify-content: var(--shipaid-prompt-heading-container-justify-content, start);
1663
+ align-items: var(--shipaid-prompt-heading-container-align-items, center);
1664
+ }
1665
+
1666
+ .shipaid-prompt .heading-container > p{
1667
+ margin: var(--shipaid-prompt-heading-container-gap-margin, 0px 10px 0px 0px);
1668
+ }
1669
+
1639
1670
  .shipaid-checkbox {
1640
1671
  display: inline-block;
1641
1672
  position: relative;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ui.shipaid.com",
3
3
  "private": false,
4
- "version": "0.3.101",
4
+ "version": "0.3.102",
5
5
  "type": "module",
6
6
  "main": "dist/widget.umd.js",
7
7
  "unpkg": "dist/widget.iife.js",