"use strict";function _createForOfIteratorHelper(e,t){var n,i,l,a,r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return i=!(n=!0),{s:function(){r=r.call(e)},n:function(){var e=r.next();return n=e.done,e},e:function(e){i=!0,l=e},f:function(){try{n||null==r.return||r.return()}finally{if(i)throw l}}};if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length)return r&&(e=r),a=0,{s:t=function(){},n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:t};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){var n;if(e)return"string"==typeof e?_arrayLikeToArray(e,t):"Map"===(n="Object"===(n=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:n)||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=new Array(t);n'.concat(e.formattedPrice,""),secondSellingPlanPrice:''.concat(e.secondFormattedPrice||e.secondSellingPlanPrice,""),discountText:null==e?void 0:e.discountText,totalPrice:''.concat(null==e?void 0:e.totalPrice,"")}:{sellingPlanName:e.name,totalPrice:''.concat(null==e?void 0:e.totalPrice,""),sellingPlanPrice:''.concat(e.formattedPrice,""),secondSellingPlanPrice:''.concat(e.secondFormattedPrice||"",""),discountText:e.discountText};return wrapPriceWithSpanTag(Mustache.render((null==e||!e.prepaidFlag)&&widgetLabels["appstle.subscription.wg.sellingPlanTitleTextNonPrepaid"]||RS.Config.sellingPlanTitleText,t))}function buildAtcButtonSelector(){var e=RSConfig.atcButtonSelector||"div.product-form-buttons, div.product__submit__buttons, form[action$='/cart/add'] [type='submit'], #MainPaymentContainer",t={productId:product.id},e=Mustache.render(e,t);return DOMPurify.sanitize(e)}function buildOneTimePriceText(e){e={price:e,showOneTimeComparePrice:RS.Config.showOneTimeComparePrice};return wrapPriceWithSpanTag(Mustache.render(RS.Config.oneTimePriceText,e))}function buildSubscriptionOptionText(e,t,n,i,l,a,r){e=formatPrice(100*(parseFloat((null==e?void 0:e.replace(/[^0-9.]/g,""))||"0")*parseFloat((null==n?void 0:n.replace("%",""))||"0")/100));return wrapPriceWithSpanTag(Mustache.render(RS.Config.subscriptionOptionText,{discountValue:n,frequency:i,price:l,groupName:a,discountValueInAmount:e,sellingPlanName:r}))}function buildSelectedPriceText(e,t,n,i,l){var a=t?RS.Config.selectedPrepaidSellingPlanPriceText:RS.Config.selectedPayAsYouGoSellingPlanPriceText;return wrapPriceWithSpanTag(Mustache.render(a,t?{pricePerDelivery:e,totalPrice:n}:{price:e,secondPrice:l?i:e}))}function buildPrepaidPerDeliveryPriceText(e){return wrapPriceWithSpanTag(Mustache.render(RS.Config.totalPricePerDeliveryText,{prepaidPerDeliveryPrice:e}))}function buildPayAsYouGoPriceText(e){return wrapPriceWithSpanTag(Mustache.render(RS.Config.selectedPayAsYouGoSellingPlanPriceText,{price:e}))}function buildSelectedTooltipPrePaidText(e,t){var n=RS.Config.tooltipDescriptionOnPrepaidPlan;return wrapPriceWithSpanTag(Mustache.render(n,{pricePerDelivery:e,totalPrice:t}))}function buildSelectedTooltipDiscountText(e,t){var n,i;if(0<(null==e||null==(n=e.price_adjustments)?void 0:n.length))return 2==(null==e||null==(n=e.price_adjustments)?void 0:n.length)?(i={firstPrice:formatPriceWithQuantity(null==e||null==(n=e.price_adjustments[0])?void 0:n.price),secondPrice:formatPriceWithQuantity(null==e||null==(n=e.price_adjustments[1])?void 0:n.price),discountOne:0<(null==t?void 0:t.length)?t[0]:"",discountTwo:2==(null==t?void 0:t.length)?t[1]:""},wrapPriceWithSpanTag(Mustache.render(RS.Config.tooltipDescriptionOnMultipleDiscount,i))):(i={firstPrice:formatPriceWithQuantity(null==e||null==(n=e.price_adjustments[0])?void 0:n.price),discountOne:t},wrapPriceWithSpanTag(Mustache.render(RS.Config.tooltipDescriptionOnMultipleDiscount.replaceAll("{{secondPrice}}","").replaceAll("{{discountTwo}}",""),i)))}function buildTooltipDetailsText(e,t,n){t=t?{prepaidDetails:e,discountDetails:n,defaultTooltipDescription:RS.Config.tooltipDesctiption}:{defaultTooltipDescription:RS.Config.tooltipDesctiption,discountDetails:n},e=RS.Config.tooltipDescriptionCustomization;return wrapPriceWithSpanTag(Mustache.render(e,t))}function populateDropdown(purchaseOptions,variant,isPrepaidDropdown,selectedSellingPlan,selectedPayAsYouGoPlan,selectedPrepaidPlan){var sellingPlanVariants=[],validSellingPlanCounter=0,_sellingPlanVariants,_RSConfig14,_RSConfig15,_RSConfig16,_RSConfig17,_RSConfig18,_RSConfig20,_sellingPlanVariants$,_sellingPlanVariants$2,singleSellingPlanDisplayText,planText,_sellingPlanVariants$3,_sellingPlanVariants$4,_sellingPlanVariants$5,_sellingPlanVariants$6,_sellingPlanVariants2;if(jQuery.each(product.selling_plan_groups,function(index,sellingPlanGroup){"appstle"===sellingPlanGroup.app_id&&jQuery.each(sellingPlanGroup.selling_plans,function(subIndex,sellingPlan){var visible=isSellingPlanVisible(sellingPlan.id),_RS6,_sellingPlanDetails$f,sellingPlanAllocation,price,totalPrice,formattedPrice,compareAtPrice,formattedCompareAtPrice,secondPrice,secondFormattedPrice,discountText,secondFormattedPrice,priceAdjustment,discountText,jsonOfSellingPlans,sellingPlanFrequency,sellingPlanFrequencyText,sellingPlanDetails,details,daysInBillingFrequency,totalDaysInBillingFrequency,sellingPlanFrequencyType;visible&&(sellingPlanAllocation=getSellingPlanAllocation(variant.id,sellingPlan.id),sellingPlanAllocation)&&(validSellingPlanCounter++,price=sellingPlanAllocation.per_delivery_price,totalPrice=formatPrice(null==sellingPlanAllocation?void 0:sellingPlanAllocation.price),formattedPrice=formatPrice(price),compareAtPrice=sellingPlanAllocation.compare_at_price,formattedCompareAtPrice="",compareAtPrice&&(formattedCompareAtPrice=formatPrice(compareAtPrice)),secondPrice=null,secondFormattedPrice=null,secondFormattedPrice=sellingPlanAllocation&&sellingPlanAllocation.price_adjustments&&2===sellingPlanAllocation.price_adjustments.length?(secondPrice=sellingPlanAllocation.price_adjustments[1].price,formatPrice(secondPrice)):(secondPrice=price,formattedPrice),priceAdjustment=null==sellingPlan?void 0:sellingPlan.price_adjustments[0],discountText="percentage"!==(null==priceAdjustment?void 0:priceAdjustment.value_type)?formatPrice(null==priceAdjustment?void 0:priceAdjustment.value):(null==priceAdjustment?void 0:priceAdjustment.value)+"%",jsonOfSellingPlans=null==(_RS6=RS)||null==(_RS6=_RS6.Config)?void 0:_RS6.sellingPlansJson,null!=jsonOfSellingPlans&&jsonOfSellingPlans.length&&(sellingPlanFrequency=null==jsonOfSellingPlans?void 0:jsonOfSellingPlans.find(function(e){return(null==e||null==(e=e.id)||null==(e=e.split("/"))?void 0:e.pop())==sellingPlan.id}),"MONTH"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval)&&1<(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)+" "+DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.monthsFrequencyTextV2"])),"MONTH"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval)&&1===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.monthlyLabelTextV2"])),"WEEK"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval)&&1<(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)+" "+DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.weeksFrequencyTextV2"])),"WEEK"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval)&&1===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.weeklyLabelTextV2"])),"DAY"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval)&&1<(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)+" "+DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.daysFrequencyTextV2"])),"DAY"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval)&&1===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.dayFrequencyTextV2"])),"YEAR"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval)&&1<(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)+" "+DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.yearsFrequencyTextV2"])),"YEAR"===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.frequencyInterval))&&1===(null==sellingPlanFrequency?void 0:sellingPlanFrequency.billingFrequencyCount)&&(sellingPlanFrequencyText=DOMPurify.sanitize(widgetLabels["appstle.subscription.wg.yearlyLabelTextV2"])),sellingPlanDetails={name:sellingPlan.name,description:sellingPlan.description,sellingPlanId:sellingPlan.id,formattedPrice:buildPayAsYouGoPriceText(formattedPrice),compareAtPrice:compareAtPrice,formattedCompareAtPrice:formattedCompareAtPrice,price:price,isFreeTrial:!price,totalPrice:totalPrice,secondPrice:secondPrice,secondSellingPlanPrice:secondFormattedPrice,hasSecondSellingPlanPrice:!!secondPrice,sellingPlanFrequencyText:DOMPurify.sanitize(sellingPlanFrequencyText),discountText:null!=priceAdjustment&&priceAdjustment.value?discountText:null,formattedDiscountText:null!=priceAdjustment&&priceAdjustment.value?buildDiscountText(discountText):"",showFormattedDiscountText:!(null==priceAdjustment||!priceAdjustment.value),isChecked:!1,formattedPrepaidPerDeliveryPriceText:buildPrepaidPerDeliveryPriceText(formattedPrice)},details=getSellingPlanDetailsById(sellingPlan.id),details&&jQuery.extend(sellingPlanDetails,JSON.parse(JSON.stringify(details))),sellingPlanDetails.id=sellingPlan.id,sellingPlanDetails.isFrequencySubsequent=1'.concat(singleSellingPlanDisplayText,""))),planText.appendTo(purchaseOptions.find(".appstle_subscribe_option")),null!=(_sellingPlanVariants$=sellingPlanVariants[0])&&_sellingPlanVariants$.description&&null!=(_sellingPlanVariants$2=sellingPlanVariants[0])&&_sellingPlanVariants$2.description.includes("{{sellingPlanName}}")?jQuery('
'.concat(null==(_sellingPlanVariants$3=sellingPlanVariants[0])||null==(_sellingPlanVariants$3=_sellingPlanVariants$3.description)?void 0:_sellingPlanVariants$3.replace("{{sellingPlanName}}",null==(_sellingPlanVariants$4=sellingPlanVariants[0])?void 0:_sellingPlanVariants$4.name),"
")).appendTo(purchaseOptions.find(".appstle_subscribe_option")):null!=(_sellingPlanVariants$5=sellingPlanVariants[0])&&_sellingPlanVariants$5.description&&jQuery(DOMPurify.sanitize('
'.concat(null==(_sellingPlanVariants$6=sellingPlanVariants[0])?void 0:_sellingPlanVariants$6.description,"
"))).appendTo(purchaseOptions.find(".appstle_subscribe_option"))):Selling_Plan_Variants_Global.multipleSellingPlan=!0,sellingPlanVariants=null==(_sellingPlanVariants=sellingPlanVariants)?void 0:_sellingPlanVariants.map(function(t){var e=null==(e=RSConfig)||null==(e=e.sellingPlansJson)?void 0:e.find(function(e){return e.idNew==t.idNew});return t.frequencySequence=(null==e?void 0:e.frequencySequence)||0,t}),sellingPlanVariants.sort(function(e,t){return e.frequencySequence-t.frequencySequence}),null!=(_RSConfig14=RSConfig)&&_RSConfig14.sortByDefaultSequence||sellingPlanVariants.sort(function(e,t){return e.price-t.price}),null!=(_RSConfig15=RSConfig)&&_RSConfig15.sortAlphabetically&&null!=(_sellingPlanVariants2=sellingPlanVariants)&&_sellingPlanVariants2.sort(function(e,t){return null==e||null==(e=e.name)?void 0:e.localeCompare(t.name)}),(null!=(_RSConfig16=RSConfig)&&_RSConfig16.subscriptionOptionSelectedByDefault||product.requires_selling_plan)&&(sellingPlanVariants[0].isChecked=!0),null!=(_RSConfig17=RSConfig)&&_RSConfig17.showPrepaidPlanSeparately&&!isPrepaidDropdown&&(sellingPlanVariants=sellingPlanVariants.filter(function(e){return!(null!=e&&e.prepaidFlag)})),null!=(_RSConfig18=RSConfig)&&_RSConfig18.showPrepaidPlanSeparately&&isPrepaidDropdown&&(sellingPlanVariants=sellingPlanVariants.filter(function(e){return null==e?void 0:e.prepaidFlag})),jQuery(sellingPlanVariants).each(function(e,t){var n,i=buildSellingPlantText(t);t.sellingPlanDisplayText=i,null!=(n=RSConfig)&&n.switchRadioButtonWidget?jQuery(DOMPurify.sanitize('
\n
\n \n \n
\n ").concat(null!=t&&t.description&&null!=t&&t.description.includes("{{sellingPlanName}}")?'
'.concat(null==t?void 0:t.description.replace("{{sellingPlanName}}",null==t?void 0:t.name),"
"):null!=t&&t.description?'
'.concat(null==t?void 0:t.description,"
"):"","\n
"))).appendTo(purchaseOptions.find(".appstleRadioSellingPlanWrapper")):jQuery("