ui.shipaid.com 0.3.147 → 0.3.149
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
|
@@ -3506,6 +3506,21 @@ const openCarousel = (from) => {
|
|
|
3506
3506
|
} catch {
|
|
3507
3507
|
}
|
|
3508
3508
|
};
|
|
3509
|
+
const ensureLearnMoreCarousel = (store) => {
|
|
3510
|
+
var _a, _b;
|
|
3511
|
+
try {
|
|
3512
|
+
const existing = document.querySelector("shipaid-learn-more-carousel");
|
|
3513
|
+
if (existing) return;
|
|
3514
|
+
const el = document.createElement("shipaid-learn-more-carousel");
|
|
3515
|
+
const isGreenEnabled = Boolean((_a = store == null ? void 0 : store.greenProtection) == null ? void 0 : _a.enabled);
|
|
3516
|
+
const isFreeGiftEnabled = Boolean((_b = store == null ? void 0 : store.freeGifts) == null ? void 0 : _b.enabled);
|
|
3517
|
+
if (isGreenEnabled) el.setAttribute("green-protection", "true");
|
|
3518
|
+
if (isFreeGiftEnabled) el.setAttribute("free-gift", "true");
|
|
3519
|
+
el.setAttribute("carousel-state", "close");
|
|
3520
|
+
document.body.appendChild(el);
|
|
3521
|
+
} catch {
|
|
3522
|
+
}
|
|
3523
|
+
};
|
|
3509
3524
|
const refreshShopifyCartUI = async () => {
|
|
3510
3525
|
try {
|
|
3511
3526
|
const sectionIds = ["cart-drawer", "cart-icon-bubble", "main-cart-items"];
|
|
@@ -3628,7 +3643,9 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3628
3643
|
this._sellingPlanId = null;
|
|
3629
3644
|
this._isUpdatingShipAid = false;
|
|
3630
3645
|
this._lastCartEventAt = 0;
|
|
3631
|
-
this.
|
|
3646
|
+
this._checkoutButtonStylesInjected = false;
|
|
3647
|
+
this._cachedCheckoutButton = null;
|
|
3648
|
+
this._cachedCheckoutButtonClasses = "";
|
|
3632
3649
|
this._onShipAidCartEvent = (event) => {
|
|
3633
3650
|
var _a2, _b2;
|
|
3634
3651
|
if (((_b2 = (_a2 = event == null ? void 0 : event.detail) == null ? void 0 : _a2.data) == null ? void 0 : _b2.source) === "shipaid-widget") return;
|
|
@@ -3659,7 +3676,6 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3659
3676
|
} catch {
|
|
3660
3677
|
}
|
|
3661
3678
|
};
|
|
3662
|
-
this._pendingLearnMoreSource = null;
|
|
3663
3679
|
this._handleHelpClick = (event) => {
|
|
3664
3680
|
if (event) event.preventDefault();
|
|
3665
3681
|
this._toggleBenefits();
|
|
@@ -3746,8 +3762,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3746
3762
|
}
|
|
3747
3763
|
}
|
|
3748
3764
|
_openLearnMore(source) {
|
|
3749
|
-
|
|
3750
|
-
this._pendingLearnMoreSource = source;
|
|
3765
|
+
openCarousel(source);
|
|
3751
3766
|
if (this.persistPopup) {
|
|
3752
3767
|
this.setPopupKey();
|
|
3753
3768
|
}
|
|
@@ -3755,6 +3770,47 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
3755
3770
|
_toggleBenefits() {
|
|
3756
3771
|
this._isBenefitsOpen = !this._isBenefitsOpen;
|
|
3757
3772
|
}
|
|
3773
|
+
/**
|
|
3774
|
+
* Get the contactless checkout selector from DB or sessionStorage
|
|
3775
|
+
* @private
|
|
3776
|
+
*/
|
|
3777
|
+
_getContactlessCheckoutSelector() {
|
|
3778
|
+
var _a, _b, _c, _d;
|
|
3779
|
+
return ((_d = (_c = (_b = (_a = this._store) == null ? void 0 : _a.widgetConfigurations) == null ? void 0 : _b.widget) == null ? void 0 : _c.theme_checkout) == null ? void 0 : _d.checkoutButtonSelector) || null;
|
|
3780
|
+
}
|
|
3781
|
+
/**
|
|
3782
|
+
* Check if we should use contactless checkout template
|
|
3783
|
+
* @private
|
|
3784
|
+
*/
|
|
3785
|
+
_shouldUseContactlessCheckout() {
|
|
3786
|
+
const dbSelector = this._getContactlessCheckoutSelector();
|
|
3787
|
+
const sessionSelector = sessionStorage.getItem("shipaidWidgetTheme");
|
|
3788
|
+
if (this.useShipAidCheckout || !dbSelector) {
|
|
3789
|
+
return false;
|
|
3790
|
+
}
|
|
3791
|
+
return !!sessionSelector;
|
|
3792
|
+
}
|
|
3793
|
+
/**
|
|
3794
|
+
* Check if widget should be shown based on config
|
|
3795
|
+
* @private
|
|
3796
|
+
*/
|
|
3797
|
+
_shouldShowWidgetContent() {
|
|
3798
|
+
var _a;
|
|
3799
|
+
return !!(this._shouldShowWidget && this.planActive && ((_a = this._store) == null ? void 0 : _a.widgetShowCart));
|
|
3800
|
+
}
|
|
3801
|
+
/**
|
|
3802
|
+
* Determine which template to render
|
|
3803
|
+
* @private
|
|
3804
|
+
*/
|
|
3805
|
+
_getTemplateToRender() {
|
|
3806
|
+
if (!this._hasFinishedSetup) {
|
|
3807
|
+
return this._shouldUseContactlessCheckout() ? this.contactlessCheckoutButtonTemplate() : this.promptTemplate();
|
|
3808
|
+
}
|
|
3809
|
+
if (this._shouldShowWidgetContent()) {
|
|
3810
|
+
return this._shouldUseContactlessCheckout() ? this.contactlessCheckoutButtonTemplate() : this.promptTemplate();
|
|
3811
|
+
}
|
|
3812
|
+
return A;
|
|
3813
|
+
}
|
|
3758
3814
|
get nhost() {
|
|
3759
3815
|
const subdomain = this.env === "prod" ? "gjiyysyzjwuculcymsvb" : this.env === "staging" ? "xfnjpunvafvudwuzwjlm" : "local";
|
|
3760
3816
|
const region = "us-east-1";
|
|
@@ -4147,13 +4203,6 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
4147
4203
|
} catch {
|
|
4148
4204
|
}
|
|
4149
4205
|
}
|
|
4150
|
-
try {
|
|
4151
|
-
this._isReplacingCartSections = true;
|
|
4152
|
-
await refreshShopifyCartUI();
|
|
4153
|
-
} catch {
|
|
4154
|
-
} finally {
|
|
4155
|
-
this._isReplacingCartSections = false;
|
|
4156
|
-
}
|
|
4157
4206
|
}
|
|
4158
4207
|
async addCartProtectionVariant() {
|
|
4159
4208
|
var _a, _b;
|
|
@@ -4427,19 +4476,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
4427
4476
|
}
|
|
4428
4477
|
/** Templates */
|
|
4429
4478
|
learnMorePopupTemplate() {
|
|
4430
|
-
|
|
4431
|
-
const carousel = document.querySelector("shipaid-learn-more-carousel");
|
|
4432
|
-
const isGreenEnabled = Boolean((_b = (_a = this._store) == null ? void 0 : _a.greenProtection) == null ? void 0 : _b.enabled);
|
|
4433
|
-
const isFreeGiftEnabled = Boolean((_d = (_c = this._store) == null ? void 0 : _c.freeGifts) == null ? void 0 : _d.enabled);
|
|
4434
|
-
if (carousel) return;
|
|
4435
|
-
return x`
|
|
4436
|
-
<shipaid-learn-more-carousel
|
|
4437
|
-
carousel-state=${this._popup === "learn-more" ? "open" : "close"}
|
|
4438
|
-
free-gift=${isFreeGiftEnabled}
|
|
4439
|
-
green-protection=${isGreenEnabled}
|
|
4440
|
-
>
|
|
4441
|
-
</shipaid-learn-more-carousel>
|
|
4442
|
-
`;
|
|
4479
|
+
return null;
|
|
4443
4480
|
}
|
|
4444
4481
|
confirmationPopupTemplate() {
|
|
4445
4482
|
return x`
|
|
@@ -4681,8 +4718,12 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
4681
4718
|
</div>
|
|
4682
4719
|
`;
|
|
4683
4720
|
}
|
|
4684
|
-
|
|
4685
|
-
|
|
4721
|
+
/**
|
|
4722
|
+
* Inject global styles for checkoutButtonTemplate (only once)
|
|
4723
|
+
* @private
|
|
4724
|
+
*/
|
|
4725
|
+
_injectCheckoutButtonGlobalStyles() {
|
|
4726
|
+
if (this._checkoutButtonStylesInjected) return;
|
|
4686
4727
|
if (!document.getElementById("shipaid-styles")) {
|
|
4687
4728
|
const style = document.createElement("style");
|
|
4688
4729
|
style.id = "shipaid-styles";
|
|
@@ -4697,70 +4738,257 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
4697
4738
|
`;
|
|
4698
4739
|
document.head.appendChild(style);
|
|
4699
4740
|
}
|
|
4741
|
+
this._checkoutButtonStylesInjected = true;
|
|
4742
|
+
}
|
|
4743
|
+
/**
|
|
4744
|
+
* Find and cache the original checkout button for checkoutButtonTemplate
|
|
4745
|
+
* @private
|
|
4746
|
+
*/
|
|
4747
|
+
_findAndCacheCheckoutButton() {
|
|
4748
|
+
var _a;
|
|
4749
|
+
if (this._cachedCheckoutButton && document.contains(this._cachedCheckoutButton)) {
|
|
4750
|
+
return this._cachedCheckoutButton;
|
|
4751
|
+
}
|
|
4700
4752
|
if (!this.dataSelector) {
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
);
|
|
4704
|
-
return;
|
|
4753
|
+
logger.warn("[shipaid-widget] Missing 'data-selector' attribute for checkout button");
|
|
4754
|
+
return null;
|
|
4705
4755
|
}
|
|
4706
|
-
let
|
|
4756
|
+
let button = null;
|
|
4707
4757
|
if (this.shadowRootSelector) {
|
|
4708
4758
|
const shadowHost = document.querySelector(this.shadowRootSelector);
|
|
4709
|
-
if (shadowHost
|
|
4710
|
-
|
|
4759
|
+
if (shadowHost == null ? void 0 : shadowHost.shadowRoot) {
|
|
4760
|
+
button = shadowHost.shadowRoot.querySelector(
|
|
4711
4761
|
`${this.dataSelector}:not(#${this.buttonId || "shipaid-checkout-button"})`
|
|
4712
4762
|
);
|
|
4713
4763
|
} else {
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
);
|
|
4717
|
-
return;
|
|
4764
|
+
logger.warn(`ShadowRoot not found for selector '${this.shadowRootSelector}'`);
|
|
4765
|
+
return null;
|
|
4718
4766
|
}
|
|
4719
4767
|
} else {
|
|
4720
|
-
|
|
4721
|
-
this.dataSelector
|
|
4722
|
-
)) == null ? void 0 : _a[0];
|
|
4768
|
+
button = (_a = this.getElementsBySelector(this.dataSelector)) == null ? void 0 : _a[0];
|
|
4723
4769
|
}
|
|
4724
|
-
if (!
|
|
4725
|
-
|
|
4726
|
-
return;
|
|
4770
|
+
if (!button) {
|
|
4771
|
+
logger.warn(`Checkout button not found with selector '${this.dataSelector}'`);
|
|
4772
|
+
return null;
|
|
4727
4773
|
}
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4774
|
+
this._cachedCheckoutButton = button;
|
|
4775
|
+
this._cachedCheckoutButtonClasses = button.className;
|
|
4776
|
+
return button;
|
|
4777
|
+
}
|
|
4778
|
+
/**
|
|
4779
|
+
* Calculate cart totals for checkoutButtonTemplate
|
|
4780
|
+
* @private
|
|
4781
|
+
*/
|
|
4782
|
+
_calculateCheckoutCartTotals() {
|
|
4783
|
+
var _a, _b;
|
|
4784
|
+
const protectionPrice = Number((_a = this._protectionVariant) == null ? void 0 : _a.price) || 0;
|
|
4785
|
+
const cartPrice = (Number((_b = this._cart) == null ? void 0 : _b.total_price) || 0) / 100;
|
|
4732
4786
|
const cartTotal = !this._hasProtectionInCart ? protectionPrice + cartPrice : cartPrice;
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4737
|
-
|
|
4738
|
-
|
|
4787
|
+
return { protectionPrice, cartPrice, cartTotal };
|
|
4788
|
+
}
|
|
4789
|
+
/**
|
|
4790
|
+
* Get impact features for checkoutButtonTemplate
|
|
4791
|
+
* @private
|
|
4792
|
+
*/
|
|
4793
|
+
_getCheckoutImpactFeatures() {
|
|
4794
|
+
var _a, _b, _c, _d;
|
|
4795
|
+
const isGreenProtectionEnabled = Boolean((_b = (_a = this._store) == null ? void 0 : _a.greenProtection) == null ? void 0 : _b.enabled);
|
|
4796
|
+
const isFreeGiftEnabled = Boolean((_d = (_c = this._store) == null ? void 0 : _c.freeGifts) == null ? void 0 : _d.enabled);
|
|
4739
4797
|
const impactActive = isGreenProtectionEnabled || isFreeGiftEnabled;
|
|
4740
|
-
|
|
4741
|
-
|
|
4742
|
-
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
|
|
4746
|
-
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
>
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
4755
|
-
|
|
4756
|
-
|
|
4757
|
-
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4798
|
+
return { isGreenProtectionEnabled, isFreeGiftEnabled, impactActive };
|
|
4799
|
+
}
|
|
4800
|
+
/**
|
|
4801
|
+
* Render Get Mechanism theme checkout button
|
|
4802
|
+
* Modern UI based on the mechanism theme design
|
|
4803
|
+
* @private
|
|
4804
|
+
*/
|
|
4805
|
+
_renderGetMechanismCheckoutButton(originalClasses, protectionPrice, cartTotal, _isGreenProtectionEnabled, _isFreeGiftEnabled, loading2) {
|
|
4806
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4807
|
+
return x`
|
|
4808
|
+
<style>
|
|
4809
|
+
:host {
|
|
4810
|
+
display: inline-block;
|
|
4811
|
+
font-family: Arial, sans-serif;
|
|
4812
|
+
width: 100%;
|
|
4813
|
+
}
|
|
4814
|
+
|
|
4815
|
+
.mechanism-container {
|
|
4816
|
+
width: 100%;
|
|
4817
|
+
display: flex;
|
|
4818
|
+
flex-direction: column;
|
|
4819
|
+
}
|
|
4820
|
+
|
|
4821
|
+
.mechanism-protection-card {
|
|
4822
|
+
display: flex;
|
|
4823
|
+
align-items: center;
|
|
4824
|
+
justify-content: space-between;
|
|
4825
|
+
padding: 12px 16px;
|
|
4826
|
+
background: #fff;
|
|
4827
|
+
}
|
|
4828
|
+
|
|
4829
|
+
.mechanism-left {
|
|
4830
|
+
display: flex;
|
|
4831
|
+
align-items: center;
|
|
4832
|
+
gap: 12px;
|
|
4833
|
+
}
|
|
4834
|
+
|
|
4835
|
+
.mechanism-icon {
|
|
4836
|
+
width: 40px;
|
|
4837
|
+
height: 40px;
|
|
4838
|
+
display: flex;
|
|
4839
|
+
align-items: center;
|
|
4840
|
+
justify-content: center;
|
|
4841
|
+
flex-shrink: 0;
|
|
4842
|
+
}
|
|
4843
|
+
|
|
4844
|
+
.mechanism-icon img {
|
|
4845
|
+
width: 100%;
|
|
4846
|
+
height: 100%;
|
|
4847
|
+
object-fit: contain;
|
|
4848
|
+
border-radius: 6px;
|
|
4849
|
+
}
|
|
4850
|
+
|
|
4851
|
+
.mechanism-info {
|
|
4852
|
+
display: flex;
|
|
4853
|
+
flex-direction: column;
|
|
4854
|
+
gap: 2px;
|
|
4855
|
+
}
|
|
4856
|
+
|
|
4857
|
+
.mechanism-title {
|
|
4858
|
+
display: flex;
|
|
4859
|
+
font-weight: 600;
|
|
4860
|
+
font-size: 14px;
|
|
4861
|
+
line-height: 1.2;
|
|
4862
|
+
margin: 0;
|
|
4863
|
+
}
|
|
4864
|
+
|
|
4865
|
+
.mechanism-subtitle {
|
|
4866
|
+
font-size: 12px;
|
|
4867
|
+
color: #6b7280;
|
|
4868
|
+
margin: 0;
|
|
4869
|
+
}
|
|
4870
|
+
|
|
4871
|
+
.mechanism-price {
|
|
4872
|
+
font-weight: 600;
|
|
4873
|
+
font-size: 14px;
|
|
4874
|
+
color: #000;
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4877
|
+
.mechanism-info-icon {
|
|
4878
|
+
width: 16px;
|
|
4879
|
+
height: 16px;
|
|
4880
|
+
border-radius: 50%;
|
|
4881
|
+
border: 1.5px solid #9ca3af;
|
|
4882
|
+
display: flex;
|
|
4883
|
+
align-items: center;
|
|
4884
|
+
justify-content: center;
|
|
4885
|
+
font-size: 11px;
|
|
4886
|
+
color: #9ca3af;
|
|
4887
|
+
font-weight: 600;
|
|
4888
|
+
cursor: pointer;
|
|
4889
|
+
margin-left: 6px;
|
|
4890
|
+
}
|
|
4891
|
+
|
|
4892
|
+
.mechanism-checkout-button {
|
|
4893
|
+
width: 100%;
|
|
4894
|
+
padding: 14px;
|
|
4895
|
+
background: #000;
|
|
4896
|
+
color: #fff;
|
|
4897
|
+
border: none;
|
|
4898
|
+
border-radius: 6px;
|
|
4899
|
+
font-weight: 600;
|
|
4900
|
+
font-size: 15px;
|
|
4901
|
+
cursor: pointer;
|
|
4902
|
+
transition: opacity 0.2s;
|
|
4903
|
+
display: flex;
|
|
4904
|
+
align-items: center;
|
|
4905
|
+
justify-content: center;
|
|
4906
|
+
gap: 8px;
|
|
4907
|
+
}
|
|
4908
|
+
|
|
4909
|
+
.mechanism-checkout-button:hover {
|
|
4910
|
+
opacity: 0.9;
|
|
4911
|
+
}
|
|
4912
|
+
|
|
4913
|
+
.mechanism-continue-link {
|
|
4914
|
+
text-align: center;
|
|
4915
|
+
font-size: 13px;
|
|
4916
|
+
color: #6b7280;
|
|
4917
|
+
text-decoration: underline;
|
|
4918
|
+
cursor: pointer;
|
|
4919
|
+
padding: 8px;
|
|
4920
|
+
}
|
|
4921
|
+
|
|
4922
|
+
.mechanism-continue-link:hover {
|
|
4923
|
+
color: #000;
|
|
4924
|
+
}
|
|
4925
|
+
</style>
|
|
4926
|
+
|
|
4927
|
+
<div class="mechanism-container">
|
|
4928
|
+
<div class="mechanism-protection-card">
|
|
4929
|
+
<div class="mechanism-left">
|
|
4930
|
+
<div class="mechanism-icon">
|
|
4931
|
+
${((_b = (_a = this._store) == null ? void 0 : _a.widgetConfigurations) == null ? void 0 : _b.theme_logo) ? x`<img src="${this._store.widgetConfigurations.theme_logo}" alt="Logo" />` : x`<img src="${ShipAidBlueIcon}" alt="ShipAid" />`}
|
|
4932
|
+
</div>
|
|
4933
|
+
<div class="mechanism-info">
|
|
4934
|
+
<p class="mechanism-title">
|
|
4935
|
+
Checkout+
|
|
4936
|
+
<span class="mechanism-info-icon" @click=${this._openLearnMore}>i</span>
|
|
4937
|
+
</p>
|
|
4938
|
+
<p class="mechanism-subtitle">Free returns + package protection</p>
|
|
4939
|
+
</div>
|
|
4940
|
+
</div>
|
|
4941
|
+
<div class="mechanism-price">
|
|
4942
|
+
${protectionPrice ? this._currencyFormat(protectionPrice) : loading2}
|
|
4943
|
+
</div>
|
|
4944
|
+
</div>
|
|
4945
|
+
|
|
4946
|
+
${this._sellingPlanId ? x`
|
|
4947
|
+
<button
|
|
4948
|
+
class="mechanism-checkout-button ${originalClasses}"
|
|
4949
|
+
@click=${async () => {
|
|
4950
|
+
var _a2, _b2;
|
|
4951
|
+
sessionStorage.setItem(
|
|
4952
|
+
"shipaid_variant",
|
|
4953
|
+
JSON.stringify((_a2 = this._protectionVariant) == null ? void 0 : _a2.id)
|
|
4954
|
+
);
|
|
4955
|
+
await this.addCartProtectionVariant();
|
|
4956
|
+
window.location.href = `/checkout?attributes[_shipaid-internal]=1&updates[${(_b2 = this._protectionVariant) == null ? void 0 : _b2.id}]=1`;
|
|
4957
|
+
}}
|
|
4958
|
+
>
|
|
4959
|
+
Checkout+ | ${cartTotal ? this._currencyFormat(cartTotal) : loading2}
|
|
4960
|
+
</button>
|
|
4961
|
+
` : x`
|
|
4962
|
+
<a
|
|
4963
|
+
href="/checkout${((_c = this._protectionVariant) == null ? void 0 : _c.id) ? `?attributes[_shipaid-internal]=1&updates[${(_d = this._protectionVariant) == null ? void 0 : _d.id}]=1` : ""}"
|
|
4964
|
+
class="mechanism-checkout-button ${originalClasses}"
|
|
4965
|
+
@click=${() => {
|
|
4966
|
+
var _a2;
|
|
4967
|
+
sessionStorage.setItem(
|
|
4968
|
+
"shipaid_variant",
|
|
4969
|
+
JSON.stringify((_a2 = this._protectionVariant) == null ? void 0 : _a2.id)
|
|
4970
|
+
);
|
|
4971
|
+
}}
|
|
4972
|
+
>
|
|
4973
|
+
Checkout+ | ${cartTotal ? this._currencyFormat(cartTotal) : loading2}
|
|
4974
|
+
</a>
|
|
4975
|
+
`}
|
|
4976
|
+
|
|
4977
|
+
<a
|
|
4978
|
+
href="/checkout${((_e = this._protectionVariant) == null ? void 0 : _e.id) ? `?attributes[_shipaid-internal]=1&updates[${(_f = this._protectionVariant) == null ? void 0 : _f.id}]=0` : ""}"
|
|
4979
|
+
class="mechanism-continue-link"
|
|
4980
|
+
>
|
|
4981
|
+
Checkout without free returns & package protection
|
|
4982
|
+
</a>
|
|
4983
|
+
</div>
|
|
4763
4984
|
`;
|
|
4985
|
+
}
|
|
4986
|
+
/**
|
|
4987
|
+
* Render default/original checkout button UI
|
|
4988
|
+
* @private
|
|
4989
|
+
*/
|
|
4990
|
+
_renderDefaultCheckoutButton(originalClasses, protectionPrice, cartTotal, isGreenProtectionEnabled, isFreeGiftEnabled, impactActive, loading2) {
|
|
4991
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4764
4992
|
return x`
|
|
4765
4993
|
<style>
|
|
4766
4994
|
:host {
|
|
@@ -4966,7 +5194,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
4966
5194
|
${this._sellingPlanId ? x`
|
|
4967
5195
|
<button
|
|
4968
5196
|
id="${this.buttonId || "shipaid-checkout-button"}"
|
|
4969
|
-
variant="${(
|
|
5197
|
+
variant="${(_a = this._protectionVariant) == null ? void 0 : _a.id}"
|
|
4970
5198
|
class="${this.buttonClasses || originalClasses}"
|
|
4971
5199
|
@click=${async () => {
|
|
4972
5200
|
var _a2, _b2;
|
|
@@ -4983,8 +5211,8 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
4983
5211
|
</button>
|
|
4984
5212
|
` : x`
|
|
4985
5213
|
<a
|
|
4986
|
-
variant="${(
|
|
4987
|
-
href="/checkout${((
|
|
5214
|
+
variant="${(_b = this._protectionVariant) == null ? void 0 : _b.id}"
|
|
5215
|
+
href="/checkout${((_c = this._protectionVariant) == null ? void 0 : _c.id) ? `?attributes[_shipaid-internal]=1&updates[${(_d = this._protectionVariant) == null ? void 0 : _d.id}]=1` : ""}"
|
|
4988
5216
|
id="${this.buttonId || "shipaid-checkout-button"}"
|
|
4989
5217
|
class="${this.buttonClasses || originalClasses}"
|
|
4990
5218
|
@click=${() => {
|
|
@@ -5006,7 +5234,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5006
5234
|
</a>
|
|
5007
5235
|
`}
|
|
5008
5236
|
<a
|
|
5009
|
-
href="/checkout${((
|
|
5237
|
+
href="/checkout${((_e = this._protectionVariant) == null ? void 0 : _e.id) ? `?attributes[_shipaid-internal]=1&updates[${(_f = this._protectionVariant) == null ? void 0 : _f.id}]=0` : ""}"
|
|
5010
5238
|
class="continue-link"
|
|
5011
5239
|
>
|
|
5012
5240
|
<slot name="link-continue"
|
|
@@ -5016,18 +5244,71 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5016
5244
|
</div>
|
|
5017
5245
|
`;
|
|
5018
5246
|
}
|
|
5247
|
+
checkoutButtonTemplate() {
|
|
5248
|
+
var _a, _b;
|
|
5249
|
+
this._injectCheckoutButtonGlobalStyles();
|
|
5250
|
+
const originalCheckoutButton = this._findAndCacheCheckoutButton();
|
|
5251
|
+
if (!originalCheckoutButton) return;
|
|
5252
|
+
originalCheckoutButton.setAttribute("shipaid-hidden", "");
|
|
5253
|
+
const originalClasses = this._cachedCheckoutButtonClasses || originalCheckoutButton.className;
|
|
5254
|
+
const { protectionPrice, cartTotal } = this._calculateCheckoutCartTotals();
|
|
5255
|
+
const { isGreenProtectionEnabled, isFreeGiftEnabled, impactActive } = this._getCheckoutImpactFeatures();
|
|
5256
|
+
const loading2 = x`
|
|
5257
|
+
<svg
|
|
5258
|
+
width="1.5rem"
|
|
5259
|
+
height="1.5rem"
|
|
5260
|
+
viewBox="0 0 50 50"
|
|
5261
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5262
|
+
fill="none"
|
|
5263
|
+
stroke="currentColor"
|
|
5264
|
+
stroke-width="4"
|
|
5265
|
+
class="shipaid-loader"
|
|
5266
|
+
>
|
|
5267
|
+
<circle cx="25" cy="25" r="20" stroke-opacity="0.5" />
|
|
5268
|
+
<path d="M45 25a20 20 0 0 1-40 0" stroke="currentColor">
|
|
5269
|
+
<animateTransform
|
|
5270
|
+
attributeName="transform"
|
|
5271
|
+
type="rotate"
|
|
5272
|
+
from="0 25 25"
|
|
5273
|
+
to="360 25 25"
|
|
5274
|
+
dur="1s"
|
|
5275
|
+
repeatCount="indefinite"
|
|
5276
|
+
/>
|
|
5277
|
+
</path>
|
|
5278
|
+
</svg>
|
|
5279
|
+
`;
|
|
5280
|
+
const useGetMechanismTheme = ((_b = (_a = this._store) == null ? void 0 : _a.widgetConfigurations) == null ? void 0 : _b.theme) === "get_mechanism";
|
|
5281
|
+
if (useGetMechanismTheme) {
|
|
5282
|
+
return this._renderGetMechanismCheckoutButton(
|
|
5283
|
+
originalClasses,
|
|
5284
|
+
protectionPrice,
|
|
5285
|
+
cartTotal,
|
|
5286
|
+
isGreenProtectionEnabled,
|
|
5287
|
+
isFreeGiftEnabled,
|
|
5288
|
+
loading2
|
|
5289
|
+
);
|
|
5290
|
+
}
|
|
5291
|
+
return this._renderDefaultCheckoutButton(
|
|
5292
|
+
originalClasses,
|
|
5293
|
+
protectionPrice,
|
|
5294
|
+
cartTotal,
|
|
5295
|
+
isGreenProtectionEnabled,
|
|
5296
|
+
isFreeGiftEnabled,
|
|
5297
|
+
impactActive,
|
|
5298
|
+
loading2
|
|
5299
|
+
);
|
|
5300
|
+
}
|
|
5019
5301
|
renderPopups() {
|
|
5020
5302
|
if (this.persistPopup) {
|
|
5021
5303
|
this._popup = this.shouldPersistPopup();
|
|
5022
|
-
if (this._popup === "learn-more"
|
|
5023
|
-
|
|
5304
|
+
if (this._popup === "learn-more") {
|
|
5305
|
+
openCarousel("shipaid-widget");
|
|
5306
|
+
this._popup = null;
|
|
5024
5307
|
}
|
|
5025
5308
|
}
|
|
5026
5309
|
switch (this._popup) {
|
|
5027
5310
|
case "confirmation":
|
|
5028
5311
|
return this.confirmationPopupTemplate();
|
|
5029
|
-
case "learn-more":
|
|
5030
|
-
return this.learnMorePopupTemplate();
|
|
5031
5312
|
default:
|
|
5032
5313
|
return null;
|
|
5033
5314
|
}
|
|
@@ -5225,6 +5506,29 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5225
5506
|
} catch {
|
|
5226
5507
|
}
|
|
5227
5508
|
}
|
|
5509
|
+
updated(changedProperties) {
|
|
5510
|
+
super.updated(changedProperties);
|
|
5511
|
+
if (!this._hasFinishedSetup) return;
|
|
5512
|
+
const dbContactlessSelector = this._getContactlessCheckoutSelector();
|
|
5513
|
+
const sessionSelector = sessionStorage.getItem("shipaidWidgetTheme");
|
|
5514
|
+
if (!sessionSelector && dbContactlessSelector) {
|
|
5515
|
+
sessionStorage.setItem("shipaidWidgetTheme", dbContactlessSelector);
|
|
5516
|
+
}
|
|
5517
|
+
if (this.useShipAidCheckout || !dbContactlessSelector) {
|
|
5518
|
+
sessionStorage.removeItem("shipaidWidgetTheme");
|
|
5519
|
+
}
|
|
5520
|
+
if (!this.useShipAidCheckout) {
|
|
5521
|
+
document.querySelectorAll('[id*="shipaid-checkout-container"]').forEach((container) => container.remove());
|
|
5522
|
+
}
|
|
5523
|
+
if (!this._shouldShowWidgetContent()) {
|
|
5524
|
+
const selector = sessionStorage.getItem("shipaidWidgetTheme") || this.dataSelector;
|
|
5525
|
+
if (selector) {
|
|
5526
|
+
this.getElementsBySelector(selector).forEach((button) => {
|
|
5527
|
+
button.removeAttribute("shipaid-hidden");
|
|
5528
|
+
});
|
|
5529
|
+
}
|
|
5530
|
+
}
|
|
5531
|
+
}
|
|
5228
5532
|
async updateProtection(force = false) {
|
|
5229
5533
|
var _a, _b, _c;
|
|
5230
5534
|
this._cartLastUpdated = /* @__PURE__ */ new Date();
|
|
@@ -5420,6 +5724,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5420
5724
|
return;
|
|
5421
5725
|
}
|
|
5422
5726
|
this._hasFinishedSetup = true;
|
|
5727
|
+
ensureLearnMoreCarousel(this._store);
|
|
5423
5728
|
this._dispatchEvent(SHIPAID_EVENTS.LOADED, this._store);
|
|
5424
5729
|
setTimeout(async () => {
|
|
5425
5730
|
var _a2, _b2, _c2, _d2;
|
|
@@ -5481,24 +5786,6 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5481
5786
|
this,
|
|
5482
5787
|
() => {
|
|
5483
5788
|
D(this.renderPopups(), document.body);
|
|
5484
|
-
if (this._popup === "learn-more") {
|
|
5485
|
-
const source = this._pendingLearnMoreSource ?? "shipaid-widget";
|
|
5486
|
-
this._pendingLearnMoreSource = null;
|
|
5487
|
-
requestAnimationFrame(() => {
|
|
5488
|
-
try {
|
|
5489
|
-
window.dispatchEvent(
|
|
5490
|
-
new CustomEvent(SHIPAID_EVENTS.LEARN_MORE_OPENED, {
|
|
5491
|
-
detail: { source }
|
|
5492
|
-
})
|
|
5493
|
-
);
|
|
5494
|
-
} catch (error) {
|
|
5495
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
5496
|
-
logger.error(`Failed to open ShipAid learn more carousel: ${message}`);
|
|
5497
|
-
}
|
|
5498
|
-
});
|
|
5499
|
-
} else {
|
|
5500
|
-
this._pendingLearnMoreSource = null;
|
|
5501
|
-
}
|
|
5502
5789
|
},
|
|
5503
5790
|
[this._popup]
|
|
5504
5791
|
);
|
|
@@ -5859,35 +6146,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
|
|
|
5859
6146
|
}
|
|
5860
6147
|
</style>
|
|
5861
6148
|
<div class="shipaid">
|
|
5862
|
-
${
|
|
5863
|
-
this._hasFinishedSetup,
|
|
5864
|
-
() => {
|
|
5865
|
-
var _a, _b, _c, _d, _e;
|
|
5866
|
-
const dbContactlessCheckoutSelector = (_d = (_c = (_b = (_a = this._store) == null ? void 0 : _a.widgetConfigurations) == null ? void 0 : _b.widget) == null ? void 0 : _c.theme_checkout) == null ? void 0 : _d.checkoutButtonSelector;
|
|
5867
|
-
const inSessionStorageCheckoutButtonSelector = sessionStorage.getItem("shipaidWidgetTheme");
|
|
5868
|
-
if (!inSessionStorageCheckoutButtonSelector && dbContactlessCheckoutSelector) {
|
|
5869
|
-
sessionStorage.setItem(
|
|
5870
|
-
"shipaidWidgetTheme",
|
|
5871
|
-
dbContactlessCheckoutSelector
|
|
5872
|
-
);
|
|
5873
|
-
}
|
|
5874
|
-
if (this.useShipAidCheckout || !dbContactlessCheckoutSelector) {
|
|
5875
|
-
sessionStorage.removeItem("shipaidWidgetTheme");
|
|
5876
|
-
}
|
|
5877
|
-
const configOk = this._shouldShowWidget && this.planActive && ((_e = this._store) == null ? void 0 : _e.widgetShowCart);
|
|
5878
|
-
if (configOk) {
|
|
5879
|
-
return inSessionStorageCheckoutButtonSelector ? this.contactlessCheckoutButtonTemplate() : this.promptTemplate();
|
|
5880
|
-
}
|
|
5881
|
-
if (!this.useShipAidCheckout) {
|
|
5882
|
-
document.querySelectorAll('[id*="shipaid-checkout-container"]').forEach((container) => container.remove());
|
|
5883
|
-
}
|
|
5884
|
-
this.getElementsBySelector(
|
|
5885
|
-
sessionStorage.getItem("shipaidWidgetTheme") || this.dataSelector
|
|
5886
|
-
).forEach((button) => button.removeAttribute("shipaid-hidden"));
|
|
5887
|
-
return A;
|
|
5888
|
-
},
|
|
5889
|
-
() => sessionStorage.getItem("shipaidWidgetTheme") ? this.contactlessCheckoutButtonTemplate() : this.promptTemplate()
|
|
5890
|
-
)}
|
|
6149
|
+
${this._getTemplateToRender()}
|
|
5891
6150
|
</div>
|
|
5892
6151
|
`;
|
|
5893
6152
|
}
|
|
@@ -6198,19 +6457,7 @@ class ShipAidCheckoutPlus extends s$1 {
|
|
|
6198
6457
|
}
|
|
6199
6458
|
}
|
|
6200
6459
|
_ensureLearnMoreCarousel() {
|
|
6201
|
-
|
|
6202
|
-
try {
|
|
6203
|
-
const existing = document.querySelector("shipaid-learn-more-carousel");
|
|
6204
|
-
if (existing) return;
|
|
6205
|
-
const el = document.createElement("shipaid-learn-more-carousel");
|
|
6206
|
-
const isGreenEnabled = Boolean((_b = (_a = this._store) == null ? void 0 : _a.greenProtection) == null ? void 0 : _b.enabled);
|
|
6207
|
-
const isFreeGiftEnabled = Boolean((_d = (_c = this._store) == null ? void 0 : _c.freeGifts) == null ? void 0 : _d.enabled);
|
|
6208
|
-
if (isGreenEnabled) el.setAttribute("green-protection", "true");
|
|
6209
|
-
if (isFreeGiftEnabled) el.setAttribute("free-gift", "true");
|
|
6210
|
-
el.setAttribute("carousel-state", "close");
|
|
6211
|
-
document.body.appendChild(el);
|
|
6212
|
-
} catch {
|
|
6213
|
-
}
|
|
6460
|
+
ensureLearnMoreCarousel(this._store);
|
|
6214
6461
|
}
|
|
6215
6462
|
_shouldShowWidget() {
|
|
6216
6463
|
var _a;
|