1function updateLearnMoreSaveAmount(){var discountVal=jQuery('.sbs-popup-mask:visible .sub-discount-val').first().text();if(discountVal){jQuery('.learn-more-popup .save-amount').text(discountVal)}} 2class SbsPopup 3{constructor(urls){this.urls=urls||{};this.inProgress=!1;this.sbsTo={};this.dataLayers={};this.requestParams={}} 4start(sbsTo){if(this.inProgress){return} 5if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){this.show();return} 6this.inProgress=!0;this.sbsTo=sbsTo||{};jQuery.ajax({url:this.urls.validation,data:{...Object.getPrototypeOf(sbsPopup).requestParams,...{render:!0,sbsTo:sbsTo,skip_flag_check:1,is_place_order_btn:jQuery('#onestepcheckout-shipping-payment-review.step_active').length>0}},dataType:'JSON',method:'POST'}).done((response)=>{try{if(response.valid&&response.popup.length>0){let frequency=jQuery('select.offer-popup-select option:selected').val();jQuery('#sbs-popup-wrapper').replaceWith(response.popup);this.show();if(jQuery('.sbs-popup-mask select.offer-popup-select option:selected').length&&frequency){jQuery('select.offer-popup-select').val(frequency).change()}}else{this.skip({cancel:!1})}}finally{this.inProgress=!1}}).always(()=>this.inProgress=!1)} 7show(dataLayerTrigger='show'){jQuery('html, body').addClass('noscroll');if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){var popupSelector=SubscriptionPopupConfig.isAllInOnCheckout?'.sbs-popup-mask.payment-step-popup':'.sbs-popup-mask.order-place-sbs-popup'}else{popupSelector='.sbs-popup-mask.order-place-sbs-popup'} 8const reviewsSelectors=jQuery(popupSelector+' .yotpo-bottomline-placeholder');reviewsSelectors.each(function(idx,reviewsSelector){let productId=jQuery(reviewsSelector).data('productId');if(productId&&!jQuery(reviewsSelector).has('.yotpo-bottomline').length){setYotpoBottomlineRating(productId,reviewsSelector)}}) 9jQuery(popupSelector).show();jQuery(document).trigger('sbs-popup-show');this.pushDataLayers(dataLayerTrigger)} 10hide(dataLayerTrigger){jQuery('html, body').removeClass('noscroll');jQuery(document).trigger('sbs-popup-hide');if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){var popupSelector=SubscriptionPopupConfig.isAllInOnCheckout?'.sbs-popup-mask.payment-step-popup':'.sbs-popup-mask.order-place-sbs-popup'}else{popupSelector='.sbs-popup-mask.order-place-sbs-popup'} 11jQuery(popupSelector).hide();if(dataLayerTrigger!==undefined){this.pushDataLayers(dataLayerTrigger)}} 12skip(dataLayerTrigger='skip'){this.hide(dataLayerTrigger)} 13placeOrder(dataLayerTrigger='accept'){this.pushDataLayers(dataLayerTrigger)} 14pushDataLayers(type){if(!type){return} 15if(!type in this.dataLayers){return} 16window.dataLayer2=window.dataLayer2||[];window.dataLayer=window.dataLayer||[];let events=Object.getPrototypeOf(sbsPopup).dataLayers 17if(Array.isArray(events[type])){events[type].forEach(e=>{dataLayer2.push(e);dataLayer.push(e)})}else{dataLayer2.push(events[type]);dataLayer.push(events[type])}} 18isCheckout(){return jQuery('body').hasClass('onestepcheckout-index-index')} 19isShoppingCart(){return jQuery('body').hasClass('checkout-cart-index')} 20isPaymentStepShown(){return jQuery(".address-information.address-info-3-columns.step").hasClass('step_disabled')} 21isTestresult(){return jQuery('body').attr('class').includes('testresult')} 22saveOptimizely(){try{Optimizely.saveDataToOrder()}catch(err){console.error(err.message)}} 23log(flow,step,status,data){let event={'event':'js-log','flow':(flow||'sbs-popup'),'step':(step||''),'status':(status||''),'data':(data||{})};if(typeof dataLayer2Push==='function'){dataLayer2Push(event)}else{window.dataLayer2.push(event)}} 24extendDataLayers(variable){Object.keys(this.dataLayers).forEach((key)=>{this.dataLayers[key].event+=`_${variable}`})} 25updateContext(page){if(page){this.extendDataLayers(page)}} 26getDesignValue(){if(getCookie('subpopup_pay_design')){return getCookie('subpopup_pay_design')} 27return 1} 28getFutureDiscount(){return window.sbs_future_discount||''} 29getCouponValue(){return window.sbs_coupon_value||''} 30getSbsOfferPopupEvent(action,options={}){const location=options.location;const click_count=options.click_count;const allinCo=typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout;let $mask;if(allinCo&&location==='ship_popup'){$mask=jQuery('.sbs-popup-mask.shipping_design_popup')}else if(allinCo){$mask=jQuery('.sbs-popup-mask.payment-step-popup')}else{$mask=jQuery('.sbs-popup-mask.order-place-sbs-popup')} 31const $dataEl=$mask;window.dispatchEvent(new CustomEvent('ship_popup_shown'));const allinFlow=(window.allinData&&window.allinData.flow)?window.allinData.flow:'';const featuredDiscountAttr=$dataEl.attr('data-featured-discount');const futureDiscount=(featuredDiscountAttr!==undefined&&featuredDiscountAttr!=='')?featuredDiscountAttr:this.getFutureDiscount();const allinShipAttr=$dataEl.attr('data-allin-shipping-price');const shippingCostFromAllin=(allinShipAttr!=null&&String(allinShipAttr).trim()!=='')?String(allinShipAttr).trim():'';return{event:window.allinData?.isTbyb?'sub_offer_tbyb':'sub_offer_buy',location:location,action:action,future_discount:futureDiscount,shipping_cost:shippingCostFromAllin||($dataEl.attr('data-shipping-cost')||''),shipping_time:$dataEl.attr('data-shipping-time'),fe_gift:(getCookie("opt_gift")==='gift_fif'?"concealer":null)||(getCookie("opt_gift")==='gift_prim'?"primer":null)||$dataEl.attr('data-fe-gift'),actual_gift:$dataEl.attr('data-actual-gift'),coupon:this.getCouponValue(),frequency:$mask.find('select.offer-popup-select').val(),flow:allinFlow,...(typeof click_count!=='undefined'&&{click_count})}}} 32class PayPalSbsPopup extends SbsPopup 33{constructor(urls){super(urls);this.dataLayers={show:{'event':'popup_sub_cart_shown'},accept:{'event':'popup_sub_cart_chosen'},complete:{'event':'popup_sub_cart_complete'},skip:{'event':'popup_sub_cart_skip'}};document.addEventListener('pageContextChanged',(e)=>{this.updateContext(e.detail.page)});
33if(typeof window.allinData!=='undefined'){this.requestParams.force_shipping_allin_price=!0}} 34skip(dataLayerTrigger='skip'){this.hide(dataLayerTrigger);let url=this.urls.payment;if(typeof this.dataLayerParam!=='undefined'){let params={};params[this.dataLayerParam]=1;url=`${url}?${new URLSearchParams(params).toString()}`} 35if(this.isShoppingCart()){dataLayer2.push(this.getSbsOfferPopupEvent('skip',{location:'cart_popup'}))} 36if(!this.isShoppingCart()&&!this.isCheckout()){dataLayer2.push(this.getSbsOfferPopupEvent('skip',{location:'minicart_popup'}))} 37if(window.ilmPayPal){this.hideAllInPopup();window.ilmPayPal.redirect(url);return} 38window.location.href=url} 39placeOrder(dataLayerTrigger='accept'){super.placeOrder(dataLayerTrigger);let params={sbs_status:1,checkout:this.isCheckout(),frequency:jQuery('select.offer-popup-select option:selected').val()};if(typeof this.dataLayerParam!=='undefined'){params[this.dataLayerParam]=1} 40if(this.isShoppingCart()){dataLayer2.push(this.getSbsOfferPopupEvent('add',{location:'cart_popup'}))} 41if(!this.isShoppingCart()&&!this.isCheckout()){dataLayer2.push(this.getSbsOfferPopupEvent('add',{location:'minicart_popup'}))} 42if(typeof SubscriptionPopupConfig==='undefined'||!SubscriptionPopupConfig.isAllInOnCheckout){let redirectUrl=`${this.urls.payment}?${new URLSearchParams(params).toString()}`;if(window.ilmPayPal){this.hideAllInPopup();window.ilmPayPal.redirect(redirectUrl);return} 43window.location.href=redirectUrl;return} 44const _this=this;jQuery.ajax({url:getMagentoBaseUrl()+'/sbsoffer/shipping/showOffer/',dataType:'JSON',method:'POST',}).always(()=>{let redirectUrl=`${this.urls.payment}?${new URLSearchParams(params).toString()}`;if(window.ilmPayPal){_this.hideAllInPopup();window.ilmPayPal.redirect(redirectUrl);return} 45window.location.href=redirectUrl})} 46hideAllInPopup(){let hideSelectors=['.sbs-popup-mask.payment-step-popup','.sbs-popup-mask.order-place-sbs-popup',];for(let selector of hideSelectors){jQuery(selector).hide()} 47jQuery('html, body').removeClass('noscroll')} 48start(sbsTo){if(this.isShoppingCart()){dataLayer2.push(this.getSbsOfferPopupEvent('view',{location:'cart_popup'}))} 49if(!this.isShoppingCart()&&!this.isCheckout()){dataLayer2.push(this.getSbsOfferPopupEvent('view',{location:'minicart_popup'}))} 50return super.start(sbsTo)}} 51class PayPalSbsPopupExpressCO extends PayPalSbsPopup 52{constructor(urls,tbybFlag){super(urls);this.dataLayers={show:{'event':'popup_sub_exp_shown'},accept:{'event':'popup_sub_exp_chosen'},complete:{'event':'popup_sub_exp_complete'},skip:{'event':'popup_sub_exp_skip'}};if(tbybFlag){this.dataLayers.show=[{'event':'popup_sub_exp_shown'},{'event':'sub_view_pp','design':this.getDesignValue(),'location':'express checkout'},this.getSbsOfferPopupEvent('view',{location:'exp_popup'})]} 53if(typeof window.allinData!=='undefined'){this.requestParams.force_shipping_allin_price=!0}} 54skip(dataLayerTrigger='skip'){super.skip(dataLayerTrigger)} 55placeOrder(dataLayerTrigger='accept'){localStorage.setItem('sbs-state',1);localStorage.setItem('sbs-checkbox',!0);super.placeOrder(dataLayerTrigger)}} 56class PayPalSbsPopupExpressRP extends PayPalSbsPopup 57{constructor(urls){super(urls);this.dataLayers={show:{'event':'popup_sub_exp_rp_shown'},accept:{'event':'popup_sub_exp_rp_chosen'},complete:{'event':'popup_sub_exp_rp_complete'},skip:{'event':'popup_sub_exp_rp_skip'}};this.requestParams={check_accepted:1}} 58skip(dataLayerTrigger='skip'){super.skip(dataLayerTrigger)} 59show(){jQuery('.product-picker-popup, #testresult-bundle-popup, .product-picker-popup-mask').hide();super.show()}} 60class RPSbsPopup extends SbsPopup 61{constructor(urls,products,parentProducts){super(urls);this.products=products||[];this.parentProducts=parentProducts||[];this.dataLayers={show:{'event':'popup_sub_bundle_shown'},accept:{'event':'popup_sub_bundle_chosen'},complete:{'event':'popup_sub_bundle_complete'}};this.requestParams={bundle_rp_flag:!0}} 62skip(params){params=params||{};const cancel='cancel' in params?params.cancel:!0;this.hide();if(!cancel){window.ajaxCartHelper.goToCheckout(!0);return} 63jQuery.ajax({url:this.urls.cancel,data:{bundle_rp_flag:!0}}).done(()=>{window.ajaxCartHelper.goToCheckout(!0)})} 64placeOrder(){jQuery.ajax({url:this.urls.accept,data:{checked:!0,sbsTo:this.sbsTo,frequency:jQuery('.sbs-popup select[name="switch"]').val(),popup_rp:!0,source:'rp',bundle_rp_flag:!0},type:'POST',dataType:'json'}).done(data=>{this.pushDataLayers('accept');window.ajaxCartHelper.goToCheckout(!0)})}} 65class ApplePaySbsPopup extends SbsPopup{constructor(urls,frequency,accepted,path,tbybFlag=!1){super(urls);this.valid=!0;this.accepted=accepted&&accepted==='1';this.path=path;this.frequency=frequency||'4';this.express=!1;this.tbybFlag=tbybFlag;this.dataLayers={show:{'event':'popup_sub_cart_shown'},accept:{'event':'popup_sub_cart_chosen'},complete:{'event':'popup_sub_cart_complete'},skip:{'event':'popup_sub_cart_skip'},popup_sub_exp_show:{'event':'popup_sub_exp_shown'},popup_sub_exp_subscribe:{'event':'popup_sub_exp_chosen'},popup_sub_exp_skip:{'event':'popup_sub_exp_skip'}};if(this.isCheckout()&&this.tbybFlag){this.dataLayers.popup_sub_exp_show=[this.dataLayers.popup_sub_exp_show,{event:'sub_view_pp',design:this.getDesignValue(),location:'express checkout'}
65,this.getSbsOfferPopupEvent('view',{location:'exp_popup'})];this.dataLayers.show=[this.dataLayers.show,{event:'sub_view_pp',design:this.getDesignValue(),location:'place order'}];this.dataLayers.accept=[this.dataLayers.accept,{event:'sub_click_pp',design:this.getDesignValue(),location:'place order',action:'accept'}];this.dataLayers.skip=[this.dataLayers.skip,{event:'sub_click_pp',design:this.getDesignValue(),location:'place order',action:'skip'}]} 66document.addEventListener('pageContextChanged',(e)=>{this.updateContext(e.detail.page)});let _this=this;jQuery(document).ready(function(){_this.allowed(!0,!0).then(()=>{_this.initEventHandling(_this.clickHandler)})})} 67initEventHandling(clickHandler){this.attachClickHandler({data:{clickHandler}});jQuery(document).on('click','a[href="#header-cart"]',{clickHandler},this.attachClickHandler);jQuery(document).on('add-to-cart-success',{clickHandler},this.attachClickHandler);jQuery(document).on('cart-content-updated',{clickHandler},this.attachClickHandler);jQuery(document).on('payment.methods.refreshed',{clickHandler},this.attachClickHandler);jQuery(document).on('applepay-sbs-popup-shown',{clickHandler},this.attachClickHandler);jQuery(document).on('add-to-cart-success',{},this.recheck);jQuery(document).on('cart-content-updated',{},this.recheck);jQuery(document).on('extended-order-summary-updated',{},this.recheck);jQuery(document).on('change','#sbs',()=>{let sbsPath=4;let forcedSbsPath=window.localStorage.getItem('forcedSbsPath');let accepted=jQuery('#sbs').is(':checked');this.setAccepted(accepted);if(accepted){if(forcedSbsPath!==null){sbsPath=forcedSbsPath}}else{sbsPath=0} 68this.setSbsPath(sbsPath)});jQuery(document).on('change','.offer-popup-select',()=>{let frequency=jQuery('.offer-popup-select').val();this.setFrequency(frequency)});jQuery(document).on('change','.sbs-option-wrapper .frequency-option input',()=>{let frequency=jQuery('input[name=frequency]:checked','.sbs-option-wrapper').val();this.setFrequency(frequency)});jQuery(document).on('change','.frequency-selection-container select[name="frequency"]',()=>{let frequency=jQuery('.frequency-selection-container select[name="frequency"]').val();this.setFrequency(frequency)})} 69attachClickHandler(event){const clickHandler=event.data.clickHandler;document.querySelectorAll('[data-applepay-button][data-sbs-popup]').forEach(function(node){node.addEventListener('click',clickHandler,{capture:!0})})} 70clickHandler=async function(event){let popup=apSbsPopup||!1;let choice=jQuery(this).data('sbs-popup-choice');let express=jQuery(this).data('button-type')==='express';try{if(popup){Object.setPrototypeOf(sbsPopup,popup);if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){var popupCheckSelector=SubscriptionPopupConfig.isAllInOnCheckout?'.sbs-popup-mask.payment-step-popup':'.sbs-popup-mask.order-place-sbs-popup'}else{popupCheckSelector='.sbs-popup-mask.order-place-sbs-popup'} 71if(typeof choice==='undefined'&&popup.valid&&!popup.accepted&&jQuery(popupCheckSelector).length){popup.setExpress(express);if(window.allinData){Object.getPrototypeOf(sbsPopup).requestParams.force_shipping_allin_price=!0;Object.getPrototypeOf(sbsPopup).requestParams.ap_express=express;popup.start()}else{popup.show()} 72return}else if(choice===1){await popup.placeOrder()}else if(choice===0){popup.skip()}}}catch(err){popup.log('apSbsPopup.clickHandler()','ERR: '+err.message)} 73popup.showApplepayPopup(this,event)} 74showApplepayPopup(node,event){let popup=apSbsPopup||!1;let context=window.applePayIntegration;if(!context){console.log('ApplePay is unavailable.') 75return} 76event.preventDefault();event.stopImmediatePropagation();const applepaySession=context.startSession(jQuery(node).data('button-type'));if(!applepaySession){console.log('Cannot init ApplePay session.') 77return} 78applepaySession.onvalidatemerchant=function(event){context.getSelectedGatewayHandler().onValidateMerchantHandler(event,applepaySession)};applepaySession.onpaymentmethodselected=function(event){if(popup&&typeof popup.accept==='function'){popup.accept(event,applepaySession);popup.saveOptimizely()}} 79context.showApplepayPopup()} 80accept(e,session){let context=window.applePayIntegration;const payload={checked:this.isAccepted(),frequency:this.getFrequency(),checkout:this.isCheckout(),minicart:(!this.isCheckout()&&!this.isShoppingCart()),shopping_cart:this.isShoppingCart(),sbs_path:this.getSbsPath(),ap_express:this.isExpress()};jQuery.ajax({url:this.urls.accept,data:payload,dataType:'JSON',method:'POST'}).done((resp)=>{context.setTotalAmount(resp.total);session.completePaymentMethodSelection({newTotal:{label:context.displayName(),amount:context.getTotalAmount()||0}})}).fail((err)=>{const errors=err.responseJSON?.errors||[];console.debug('Subscription attempt ... ERROR: '+errors);session.completePaymentMethodSelection({errors:context.processErrors(errors,'unknown'),newTotal:{type:"pending",label:context.displayName(),amount:context.getTotalAmount()||0}})}).always()} 81show(dataLayerTrigger='show'){jQuery('.sbs-popup-buttons-regular').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay').each(function(){jQuery(this).show()});if(this.isExpress()){dataLayerTrigger='popup_sub_exp_show'} 82super.show(dataLayerTrigger);jQuery(document).trigger('applepay-sbs-popup-shown');if(this.isShoppingCart()&&this.tbybFlag){dataLayer2.push(this.getSbsOfferPopupEvent('view',{location:'cart_popup'}))} 83if(!this.isShoppingCart()&&!this.isCheckout()&&this.tbybFlag){dataLayer2.push(this.getSbsOfferPopupEvent('view',{location:'minicart_popup'}))}} 84hide(dataLayerTrigger){super.hide(dataLayerTrigger);jQuery('.sbs-popup-buttons-applepay').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-regular').each(function(){jQuery(this).show()})} 85skip(dataLayerTrigger='skip'){this.update(!1,0);if(this.isExpress()){dataLayerTrigger='popup_sub_exp_skip'} 86this.hide(dataLayerTrigger);if(this.isShoppingCart()&&this.tbybFlag){dataLayer2.push(this.getSbsOfferPopupEvent('skip',{location:'cart_popup'}))} 87if(!this.isShoppingCart()&&!this.isCheckout()&&this.tbybFlag){dataLayer2.push(this.getSbsOfferPopupEvent('skip',{location:'minicart_popup'}))}} 88placeOrder(dataLayerTrigger='accept'){let sbsPath;if(this.isCheckout()&&this.isExpress()){sbsPath=20}else if(this.isCheckout()){sbsPath=3}else{sbsPath=19} 89this.update(!0,sbsPath,!0);this.hide(!1);if(this.isExpress()){dataLayerTrigger='popup_sub_exp_subscribe'} 90super.placeOrder(dataLayerTrigger);if(this.isShoppingCart()&&this.tbybFlag){dataLayer2.push(this.getSbsOfferPopupEvent('add',{location:'cart_popup'}))} 91if(!this.isShoppingCart()&&!this.isCheckout()&&this.tbybFlag){dataLayer2.push(this.getSbsOfferPopupEvent('add',{location:'minicart_popup'}))}} 92isExpress(){return this.express} 93setExpress(apExpress){this.express=apExpress;let popupButtons=document.querySelectorAll('[data-applepay-button][data-sbs-popup-choice]');popupButtons.forEach(function(node){jQuery(node).data('button-type',(apExpress?'express':''))})} 94isAccepted(){return this.accepted} 95setAccepted(accepted){this.accepted=accepted} 96setFrequency(frequency){this.frequency=frequency;jQuery('.sbs_offer_details.freq').text(frequency)} 97getFrequency(){return this.frequency} 98setSbsPath(sbsPath){this.path=sbsPath;jQuery.ajax({url:getMagentoBaseUrl()+'sbspopup/action/savePath',data:{path:sbsPath}}).done()} 99getSbsPath(){return this.path} 100update(accepted,sbsPath,toggle=!1){let popup=this;this.setAccepted(accepted);this.path=sbsPath;jQuery.ajax({url:getMagentoBaseUrl()+'sbspopup/action/savePath',data:{path:sbsPath}}).done(()=>{if(toggle){popup.toggleCheckbox(accepted).then()}})} 101async toggleCheckbox(checked){if(this.isCheckout()){jQuery("#sbs").prop('checked',checked);if(typeof toggleGifts!='undefined'){toggleGifts(checked,!0)}} 102return 1} 103content(html){if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){return} 104if(this.isCheckout()){jQuery('#sbs-popup-wrapper').replaceWith('<div id="sbs-popup-wrapper"></div>');jQuery('.sbs-popup-mask.order-place-sbs-popup').replaceWith(html)}else{jQuery('#sbs-popup-wrapper').replaceWith(html)}} 105async allowed(reload=!0,initializationFlag=!1){let popup=apSbsPopup||{};const sbsCheckbox=jQuery('#sbs');if(popup.isCheckout()&&sbsCheckbox.length&&sbsCheckbox.is(':checked')){popup.setAccepted(!0);return!1} 106if(popup.isCheckout()&&typeof isSbsAcceptedExtSummary==='function'){if(isSbsAcceptedExtSummary()){popup.setAccepted(!0);return!1}} 107if(!reload&&popup.isCheckout()&&popup.valid!==null){return popup.valid} 108popup.valid=!1;await jQuery.ajax({url:popup.urls.validation,data:{render:reload,sbsTo:popup.sbsTo,check_accepted:!0,ap_express:popup.isExpress(),ver:4,initialization:initializationFlag},dataType:'JSON'}).done((resp)=>{popup.valid=resp?.valid;popup.accepted=resp?.accepted;if(reload&&resp.popup&&resp.popup.length>0){popup.content(resp.popup)}});return popup.valid} 109recheck(){let popup=apSbsPopup||{};popup.allowed().then()} 110saveOptimizely(){try{Optimizely.saveDataToOrder()}catch(err){console.error(err.message)}} 111log(step,status){let event={'event':'js-log','flow':'applepay-sbs','step':(step||''),'status':(status||'')};if(typeof dataLayer2Push==='function'){dataLayer2Push(event)}else{window.dataLayer2.push(event)}}} 112class ApplePaySbsPopupRP extends SbsPopup{constructor(urls,frequency,accepted,path){super(urls);this.addUrl=null;this.productId=null;this.packageId=null;this.valid=!0;this.accepted=accepted&&accepted==='1';this.path=path;this.frequency=frequency||'4';this.express=!0;this.dataLayers={click:{'event':'ap_exp_rp_click'},show:{'event':'popup_sub_exp_rp_shown'},skip:{'event':'popup_sub_exp_rp_skip'},accept:{'event':'popup_sub_exp_rp_chosen'},complete:{'event':'ap_exp_rp_complete'}};let _this=this;
112jQuery(document).ready(function(){_this.initEventHandling(_this.clickHandler)})} 113initEventHandling(clickHandler){this.attachClickHandler({data:{clickHandler}});jQuery(document).on('applepay-sbs-popup-shown-rp',{clickHandler},this.attachClickHandler);jQuery(document).on('change','.offer-popup-select',()=>{this.frequency=jQuery('.offer-popup-select').val()})} 114attachClickHandler(event){const clickHandler=event.data.clickHandler;document.querySelectorAll('[data-applepay-button][data-sbs-popup-resultpage]').forEach(function(node){node.addEventListener('click',clickHandler,{capture:!0})})} 115clickHandler=async function(event){let popup=apSbsPopupRP||this;let choice=jQuery(this).data('sbs-popup-choice');let addUrl=jQuery(this).data('button-resultpage-click-add-url');let productId=jQuery(this).data('button-resultpage-click-add-product');let packageId=jQuery(this).data('button-resultpage-click-add-type');let sbsTo=popup.getProducts(productId,packageId);if(popup){Object.setPrototypeOf(sbsPopup,popup);if(typeof choice==='undefined'){popup.pushDataLayers('click');popup.addUrl=addUrl;popup.productId=productId;popup.packageId=packageId;popup.load(sbsTo).then((res)=>{if(res){popup.show()}else{popup.overlay(!0);popup.showApplepayPopup(this,event,addUrl,productId,packageId,sbsTo)}});return}else if(choice===1){popup.overlay(!0);await popup.placeOrder()}else if(choice===0){popup.overlay(!0);popup.skip()}} 116addUrl=popup.addUrl;productId=popup.productId;packageId=popup.packageId;sbsTo=popup.getProducts(productId,packageId);popup.showApplepayPopup(this,event,addUrl,productId,packageId,sbsTo)} 117showApplepayPopup(node,event,addUrl,productId,packageId,sbsTo){let popup=apSbsPopupRP||this;let context=window.applePayIntegration;if(!context){console.log('ApplePay is unavailable.') 118return} 119event.preventDefault();event.stopImmediatePropagation();const applepaySession=context.startSession(jQuery(node).data('button-type'));if(!applepaySession){console.log('Cannot init ApplePay session.');popup.overlay(!1);return} 120applepaySession.onvalidatemerchant=function(event){context.getSelectedGatewayHandler().onValidateMerchantHandler(event,applepaySession)};this.addProductsAndSbs(addUrl,productId,packageId,sbsTo).then((res)=>{if(res){context.showApplepayPopup();jQuery(document).trigger('applepay-sbs-popup-shown-rp')}}).finally(()=>{popup.overlay(!1)})} 121async load(sbsTo){let result=!1;await jQuery.ajax({url:this.urls.popup,data:{render:!0,sbsTo:sbsTo,skipQuote:!0},dataType:'JSON',method:'POST'}).done((response)=>{if(response.valid&&response.popup.length>0){this.content(response.popup);result=!0}}).always();return result} 122content(html){if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){return} 123jQuery('#sbs-popup-wrapper').replaceWith(html)} 124show(dataLayerTrigger='show'){jQuery('.sbs-popup-buttons-regular').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay-pdp').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay-resultpage').each(function(){jQuery(this).show()});super.show(dataLayerTrigger);jQuery(document).trigger('applepay-sbs-popup-shown-rp')} 125hide(dataLayerTrigger){super.hide(dataLayerTrigger);jQuery('.sbs-popup-buttons-applepay-resultpage').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay-pdp').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-regular').each(function(){jQuery(this).show()})} 126skip(dataLayerTrigger='skip'){this.accepted=!1;if(typeof apSbsPopup=="object"){apSbsPopup.accepted=!1} 127this.path=0;this.hide(dataLayerTrigger)} 128placeOrder(dataLayerTrigger='accept'){this.path=24;this.accepted=!0;if(typeof apSbsPopup=="object"){apSbsPopup.accepted=!0} 129this.hide(!1);super.placeOrder(dataLayerTrigger)} 130getProducts(productId,packageId){let pids=[];if(typeof window.ajaxCartHelper!=='undefined'){let data=window.ajaxCartHelper.getData(productId,packageId) 131let keysToFetch=['id','package','package1','package2','package3','package4'];for(let key=0;key<keysToFetch.length;key++){if(keysToFetch[key]in data){if(data[keysToFetch[key]]){pids.push(parseInt(data[keysToFetch[key]]))}}}} 132return pids} 133async addProductsAndSbs(addUrl,productId,packageId,sbsTo){let result=!1;let popup=apSbsPopupRP||this;let tryathome=!1;let tryon=tryathome?$j(".btn-try-at-home").data("tryonpw"):$j('.tryBuy.active').length?null:$j('.tryon').attr("data-tryon");let data=window.ajaxCartHelper.getData(productId,packageId,null,tryon,null);let sbsData={checked:this.accepted,sbsTo:sbsTo,frequency:this.frequency,sbs_path:this.path,ap_express:!0,method:'applepay'};jQuery.extend(data,sbsData||{});addUrl=data.url?data.url:addUrl;await jQuery.ajax({url:addUrl.replace("checkout/cart","sbspopup/resultpage"),data:data,dataType:'json',method:'POST'}).done((resp)=>{if(popup){popup.updateMinicart(resp) 134popup.saveOptimizely()}else{} 135result=!0}).fail((err)=>{const errors=err.responseJSON?.errors||[];alert('Something went wrong! Please, try to reload');console.log('Failure to add products! ERR: '+errors)}).always();return result} 136updateMinicart(response,open=!0){let html=jQuery(response.sidebar);let products=jQuery('.minicart-wrapper-two',html);jQuery('.minicart-wrapper-two').html(products.html());products=jQuery('.minicart-bottom .minicart-wrapper-two',html);jQuery('.minicart-bottom .minicart-wrapper-two').html(products.html());if(open){jQuery('.header-minicart a.skip-cart').click()}} 137overlay(show){if(show&&typeof showSbsPopupGiftOverlay==='function'){showSbsPopupGiftOverlay()}else if(!show&&typeof hideSbsPopupGiftOverlay==='function'){hideSbsPopupGiftOverlay()}else{jQuery('.sbs-popup-overlay').remove()}} 138setAccepted(accepted){this.accepted=accepted}} 139class ApplePaySbsPopupPDP extends SbsPopup{constructor(urls,frequency,accepted,path){super(urls);this.addUrl=null;this.productId=null;this.packageId=null;this.valid=!0;this.accepted=accepted&&accepted==='1';this.path=path;this.frequency=frequency||'4';this.express=!0;this.dataLayers={click:{'event':'ap_exp_pdp_click'},clickBundle:{'event':'ap_exp_bundle_pdp_click'},show:{'event':'popup_sub_exp_pdp_shown'},skip:{'event':'popup_sub_exp_pdp_skip'},accept:{'event':'popup_sub_exp_pdp_chosen'},complete:{'event':'ap_exp_pdp_complete'},completeBundle:{'event':'ap_exp_bundle_pdp_complete'}};let _this=this;
139jQuery(document).ready(function(){_this.initEventHandling(_this.clickHandler)})} 140initEventHandling(clickHandler){this.attachClickHandler({data:{clickHandler}});jQuery(document).on('applepay-sbs-popup-shown-pdp',{clickHandler},this.attachClickHandler);jQuery(document).on('change','.offer-popup-select',()=>{this.frequency=jQuery('.offer-popup-select').val()})} 141attachClickHandler(event){const clickHandler=event.data.clickHandler;document.querySelectorAll('[data-applepay-button][data-sbs-popup-pdp]').forEach(function(node){node.addEventListener('click',clickHandler,{capture:!0})})} 142clickHandler=async function(event){let popup=apSbsPopupPDP||this;let choice=jQuery(this).data('sbs-popup-choice');let addUrl=jQuery(this).data('button-pdp-click-add-url');let productId=popup.getProductId(jQuery(this).data('button-pdp-click-add-product'))+'';let packageId=jQuery(this).data('button-pdp-click-add-bundle')+'';let sbsTo=popup.getProducts(productId,packageId);if(typeof BundlePDPPopup==='object'){BundlePDPPopup.skip()} 143if(popup){Object.setPrototypeOf(sbsPopup,popup);if(typeof choice==='undefined'){popup.pushDataLayers((packageId?'clickBundle':'click'));popup.addUrl=addUrl;popup.productId=productId;popup.packageId=packageId;popup.load(sbsTo).then((res)=>{if(res){popup.show()}else{popup.overlay(!0);popup.showApplepayPopup(this,event,addUrl,productId,packageId,sbsTo)}});return}else if(choice===1){popup.overlay(!0);popup.placeOrder()}else if(choice===0){popup.overlay(!0);popup.skip()}} 144addUrl=popup.addUrl;productId=popup.productId;packageId=popup.packageId;sbsTo=popup.getProducts(productId,packageId);popup.showApplepayPopup(this,event,addUrl,productId,packageId,sbsTo)} 145showApplepayPopup(node,event,addUrl,productId,packageId,sbsTo){let popup=apSbsPopupPDP||this;let context=window.applePayIntegration;if(!context){console.log('ApplePay is unavailable.') 146return} 147event.preventDefault();event.stopImmediatePropagation();const applepaySession=context.startSession(jQuery(node).data('button-type'));if(!applepaySession){console.log('Cannot init ApplePay session.');popup.overlay(!1);return} 148applepaySession.onvalidatemerchant=function(event){context.getSelectedGatewayHandler().onValidateMerchantHandler(event,applepaySession)};this.addProductsAndSbs(addUrl,productId,packageId,sbsTo).then((res)=>{if(res){context.showApplepayPopup();jQuery(document).trigger('applepay-sbs-popup-shown-pdp')}}).finally(()=>{popup.overlay(!1)})} 149async load(sbsTo){let result=!1;await jQuery.ajax({url:this.urls.popup,data:{render:!0,sbsTo:sbsTo,skipQuote:!0},dataType:'JSON',method:'POST'}).done((response)=>{if(response.valid&&response.popup.length>0){this.content(response.popup);result=!0}}).always();return result} 150content(html){if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){return} 151let wrapper=jQuery('.sbs-popup-mask').length?'.sbs-popup-mask':'#sbs-popup-wrapper';jQuery(wrapper).replaceWith(html)} 152show(dataLayerTrigger='show'){jQuery('.sbs-popup-buttons-regular').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay-resultpage').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay-pdp').each(function(){jQuery(this).show()});super.show(dataLayerTrigger);jQuery(document).trigger('applepay-sbs-popup-shown-pdp')} 153hide(dataLayerTrigger){super.hide(dataLayerTrigger);jQuery('.sbs-popup-buttons-applepay-pdp').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay-resultpage').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-applepay').each(function(){jQuery(this).hide()});jQuery('.sbs-popup-buttons-regular').each(function(){jQuery(this).show()})} 154skip(dataLayerTrigger='skip'){this.accepted=!1;if(typeof apSbsPopup=="object"){apSbsPopup.accepted=!1} 155this.path=0;this.hide(dataLayerTrigger)} 156placeOrder(dataLayerTrigger='accept'){this.path=27;this.accepted=!0;if(typeof apSbsPopup=="object"){apSbsPopup.accepted=!0} 157this.hide(!1);super.placeOrder(dataLayerTrigger)} 158getProductId(defaultId){let productId=defaultId;if(typeof getSelectedProductId=='function'){productId=getSelectedProductId()} 159return productId+''} 160getProducts(productId,packageId){productId=this.getProductId(productId);if(packageId){productId=productId+','+packageId} 161productId+='';return productId.split(',')} 162async addProductsAndSbs(addUrl,productId,packageId,sbsTo){let result=!1;let popup=apSbsPopupPDP||this;let tryathome=!1;let tryon=tryathome?$j(".btn-try-at-home").data("tryonpw"):$j('.tryBuy.active').length?null:$j('.tryon').attr("data-tryon");let data=window.ajaxCartHelper.getData(productId,packageId,null,tryon,null);let sbsData={checked:this.accepted,sbsTo:sbsTo,frequency:this.frequency,sbs_path:this.path,ap_express:!0,bundle:!!packageId,method:'applepay'};jQuery.extend(data,sbsData||{});addUrl=data.url?data.url:addUrl;await jQuery.ajax({url:addUrl.replace("checkout/cart","sbspopup/pdp"),data:data,dataType:'json',method:'POST'}).done((resp)=>{if(popup){popup.updateMinicart(resp) 163popup.saveOptimizely()}else{} 164result=!0}).fail((err)=>{const errors=err.responseJSON?.errors||[];alert('Something went wrong! Please, try to reload');console.log('Failure to add products! ERR: '+errors)}).always();return result} 165updateMinicart(response,open=!0){let html=jQuery(response.sidebar);let products=jQuery('.minicart-wrapper-two',html);jQuery('.minicart-wrapper-two').html(products.html());products=jQuery('.minicart-bottom .minicart-wrapper-two',html);jQuery('.minicart-bottom .minicart-wrapper-two').html(products.html());if(open){jQuery('.header-minicart a.skip-cart').click()}} 166overlay(show){if(show&&typeof showSbsPopupGiftOverlay==='function'){showSbsPopupGiftOverlay()}else if(!show&&typeof hideSbsPopupGiftOverlay==='function'){hideSbsPopupGiftOverlay()}else{jQuery('.sbs-popup-overlay').remove()}} 167setAccepted(accepted){this.accepted=accepted}} 168class PayPalSbsPopupExpressPDP extends PayPalSbsPopup 169{constructor(urls,frequency){super(urls);this.frequency=frequency||'4';this.dataLayers={show:{'event':'popup_sub_exp_pdp_shown'},skip:{'event':'popup_sub_exp_pdp_skip'},accept:{'event':'popup_sub_exp_pdp_chosen'}}}} 170class ToggleSbsPopupCO extends SbsPopup 171{constructor(urls,sbsPath){super(urls);this.sbsPath=sbsPath;this.dataLayers={show:[{'event':'sub_view_pp','design':this.getDesignValue(),'location':'between steps'}],accept:[{'event':'sub_click_pp','design':this.getDesignValue(),'location':'between steps','action':'accept'}],skip:[{'event':'sub_click_pp','design':this.getDesignValue(),'location':'between steps','action':'skip'}]}} 172start(sbsTo,callback){const isSimpleCo=window.simpleCheckout;const hasPopupCookies=typeof window.allinData!=='undefined';const flowMode=Mage.Cookies.get('smplcosubs_flow_mode');if(isSimpleCo&&(flowMode!=='3'||!hasPopupCookies)){if(typeof callback==='function'){callback()} 173return} 174this.callback=callback;if(this.inProgress){return} 175if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){if(!jQuery('.shipping_design_popup').length){this.callback();return} 176this.show();if(!this._subOfferBuyShipPopupViewSent){this._subOfferBuyShipPopupViewSent=!0;dataLayer2.push(this.getSbsOfferPopupEvent('view',{location:'ship_popup'}))} 177return} 178this.inProgress=!0;this.sbsTo=sbsTo||{};
178jQuery.ajax({url:this.__proto__.urls.validation,data:{render:!0},dataType:'JSON',method:'POST'}).done((response)=>{try{if(response.valid&&response.popup.length>0){if(jQuery('#sbs-popup-wrapper').length&&jQuery('.sbs-popup-mask.order-place-sbs-popup').length){jQuery('.sbs-popup-mask.order-place-sbs-popup').remove()} 179jQuery('#sbs-popup-wrapper').replaceWith(response.popup);this.show()}else{this.skip({cancel:!1})}}finally{this.inProgress=!1;if(!(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout)){dataLayer2.push(this.getSbsOfferPopupEvent('view',{location:'ship_popup'}))}}}).always(()=>this.inProgress=!1)} 180show(dataLayerTrigger='show'){jQuery('html, body').addClass('noscroll');if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){var popupSelector=SubscriptionPopupConfig.isAllInOnCheckout?'.sbs-popup-mask.shipping_design_popup':'.sbs-popup-mask.order-place-sbs-popup';if(SubscriptionPopupConfig.isAllInOnCheckout){if(typeof setShippingPopupShownFlag==='function'){setShippingPopupShownFlag()}}}else{popupSelector='.sbs-popup-mask.order-place-sbs-popup'} 181const reviewsSelectors=jQuery(popupSelector+' .yotpo-bottomline-placeholder');reviewsSelectors.each(function(idx,reviewsSelector){let productId=jQuery(reviewsSelector).data('productId');if(productId&&!jQuery(reviewsSelector).has('.yotpo-bottomline').length){setYotpoBottomlineRating(productId,reviewsSelector)}}) 182jQuery(popupSelector).show();jQuery(document).trigger('sbs-popup-show');this.pushDataLayers(dataLayerTrigger)} 183placeOrder(dataLayerTrigger='accept'){this.pushDataLayers(dataLayerTrigger);let giftAddedRe=getCookie('gift_added_re')==='1';let overlay=!0;if(giftAddedRe){overlay=!1} 184let loaderOptoutFlow=getCookie('loader_optout')==="1";let translation=loaderOptoutFlow?Translator.translate("Processing")+'...':Translator.translate("Your gift is being added...");if(overlay){jQuery(".overlyoffer").toggle();jQuery(".overlyoffer .lds-ring").show();jQuery(".overlyoffer").append('<div class="text"></div>');jQuery(".overlyoffer .text").html(translation)} 185jQuery.ajax({url:this.__proto__.urls.accept,data:{checked:!0,sbs_path:this.sbsPath,frequency:jQuery('select.offer-popup-select option:selected').val(),},type:'POST',dataType:'json',}).always((data)=>{if(typeof apSbsPopup!=='undefined'){apSbsPopup.setAccepted(!0)} 186if(overlay){jQuery(".overlyoffer .lds-ring").hide();jQuery(".overlyoffer").toggle();jQuery(".overlyoffer .text").remove()} 187if(data.review){jQuery('#checkout-review-load').html(jQuery(data.review));jQuery('#checkout-review-table tbody tr').css('border-bottom','1px solid #BEBCB7!important')} 188jQuery('.sbs_offer_details.regular-price').text(data.regular_price);jQuery('.sbs_offer_details.special-price').text(data.special_price);jQuery('.sbs_offer_details.instant-price').text(data.instant_price);jQuery(".sbs-bottom-container").addClass('hide');jQuery('#sbs').prop('checked',!0);const location='ship_popup';const click_count=window.ilmakiage?.subOfferClickTracker?.incrementClickCount((typeof SubscriptionPopupConfig!=='undefined'&&!SubscriptionPopupConfig.isTbyb)?'ship_popup':location)||0;dataLayer2.push(this.getSbsOfferPopupEvent('add',{location:'ship_popup',click_count:click_count}));if(data.payment_method){$$('div.onestepcheckout-payment-methods')[0]?.update(data.payment_method)} 189if('shipping_method_component' in data){$$('div.onestepcheckout-shipping-method-section')[0]?.update(data.shipping_method_component)} 190if(data.sbs_component){const sbsComponentIdentifier='.gift-product-wrapper';const sbsComponent=jQuery(data.sbs_component).find(sbsComponentIdentifier);const wrapperSbs=jQuery('.wrapper-sbs');if(wrapperSbs.length&&sbsComponent.length){wrapperSbs.find(sbsComponentIdentifier).replaceWith(sbsComponent);jQuery(`${sbsComponentIdentifier} .yotpo.bottomLine`).each(function(){if(jQuery(this).data('productId')>0){setYotpoBottomlineRating(jQuery(this).data('productId'),jQuery(this)[0])}});jQuery(`${sbsComponentIdentifier} .ilmakiage-gift-yotpo`).each(function(){var $t=jQuery(this);if($t.data('productId')>0&&!$t.find('.yotpo-bottomline').length){setYotpoBottomlineRating($t.data('productId'),this)}})} 191const benefitsComponent=jQuery(data.sbs_component).find('.benefits.benef
191its-starts');const wrapperBenefits=jQuery('.benefits.benefits-starts');if(benefitsComponent.length&&wrapperBenefits.length){wrapperBenefits.replaceWith(benefitsComponent)} 192applyShippingBenefitToggle()} 193if(data.shipping_price){jQuery('.extr_container .tbyb_wrapper .price.shipping-price-display, .tbybfaq-wrapper .price.shipping-price-display').html(data.shipping_price)} 194updateLearnMoreSaveAmount();this.hide()})} 195skip(dataLayerTrigger='skip'){this.hide();this.pushDataLayers(dataLayerTrigger);if(window.allinData&&typeof toggleGifts==="function"){toggleGifts(!1,!1)} 196localStorage.setItem('shippingBannerGiftVisible','true');const location='ship_popup';const click_count=window.ilmakiage?.subOfferClickTracker?.incrementClickCount((typeof SubscriptionPopupConfig!=='undefined'&&!SubscriptionPopupConfig.isTbyb)?'ship_popup':location)||0;dataLayer2.push(this.getSbsOfferPopupEvent('skip',{location:'ship_popup',click_count:click_count}))} 197hide(){if(typeof SubscriptionPopupConfig!=='undefined'&&SubscriptionPopupConfig.isAllInOnCheckout){var popupSelector=SubscriptionPopupConfig.isAllInOnCheckout?'.sbs-popup-mask.shipping_design_popup':'.sbs-popup-mask.order-place-sbs-popup'}else{popupSelector='.sbs-popup-mask.order-place-sbs-popup'} 198jQuery(popupSelector).hide();jQuery('html, body').removeClass('noscroll');this.callback();hideSbsOffer();jQuery('#payment-express-buttons-container').hide();jQuery('.radioparent.ilmakiage_applepay').show();jQuery(document).trigger('payment.methods.refreshed')} 199getDesignValue(){if(getCookie('subpopup_step_design')){return getCookie('subpopup_step_design')} 200return 1}} 201class ReviewSbsPopup extends SbsPopup 202{constructor(urls,sbsPath){super(urls);this.sbsPath=sbsPath;this.dataLayers={show:{'event':'order_review_sub_popup_shown'},skip:{'event':'order_review_sub_popup_decline'},accept:{'event':'order_review_sub_popup_accept'}}} 203placeOrder(dataLayerTrigger='accept'){super.placeOrder(dataLayerTrigger);jQuery.ajax({url:this.urls.accept,data:{sbs_status:1,sbs_path:this.sbsPath,checkout:this.isCheckout(),frequency:jQuery('select.offer-popup-select option:selected').val()},type:'POST',dataType:'json',}).always((data)=>{dataLayer2.push(this.getSbsOfferPopupEvent('add',{location:'order_review_popup'}));this.hide();updateLearnMoreSaveAmount();window.location.href=getMagentoBaseUrl()+'onestepcheckout/index'+'?ot='+this.oType})} 204orderReviewSub(show,link){if(show){sbsPopup.start();reviewSbsPopupShownFlag=!0}else{window.location.href=link}} 205skip(dataLayerTrigger='skip'){this.pushDataLayers(dataLayerTrigger)}}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.