var loadScript=function(t,e){var n=document.createElement("script");n.type="text/javascript",n.readyState?n.onreadystatechange=function(){"loaded"!=n.readyState&&"complete"!=n.readyState||(n.onreadystatechange=null,e())}:n.onload=function(){e()},n.src=t,document.getElementsByTagName("head")[0].appendChild(n)},myFrontendJavascriptUN=function(t){function e(){var e=this,n=function(t){"undefined"==typeof un.debug&&(un.debug=[]),un.debug.push(t)},o=function(t){return"string"==typeof t&&""!==t},i=function(t){return void 0!==t&&null!=t&&!1!==t},r=function(t){return void 0!==t&&null!=t&&t.length>0},a=function(t,e){function n(t,e){return void 0===t?e:t}function o(t,e,o,i){if(e=n(e,2),o=n(o,","),i=n(i,"."),isNaN(t)||null==t)return 0;var r=(t=(t/100).toFixed(e)).split(".");return r[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+o)+(r[1]?i+r[1]:"")}if(void 0===t||null==t)return"";if("string"==typeof t&&0==t.length)return"";var i=/\{\{\s*(\w+)\s*\}\}/;"string"==typeof t&&(t=t.replace(".",""));var r="";switch(e.match(i)[1]){case"amount":r=o(t,2);break;case"amount_no_decimals":r=o(t,0);break;case"amount_no_decimals_with_comma_separator":r=o(t,0,".",",");break;case"amount_with_comma_separator":r=o(t,2,".",",")}return e.replace(i,r)},c=function(t){return Math.round(100*t)+"%"},u=function(){for(var t=document.getElementsByTagName("script"),n="",o="",i=0;i<t.length;i++)if((n=t[i].getAttribute("src"))&&(n=n.match(/^(.*)widget\/javascript(\?\s*(.+))?\s*/))){o=n[3].match(/shop=(.+).myshopify.com/)[1];break}return".myshopify.com"===(o+=".myshopify.com")&&e.objectChecker(window.Shopify)&&e.objectChecker(window.Shopify.shop)&&(o=window.Shopify.shop),".myshopify.com"===o&&console.log("UN: unable to get shop domain"),o},s=function(){return e.stringChecker(f.primary_domain)?f.primary_domain:f.shopify_domain},l=function(){return"un-chris-local-2.myshopify.com"===u()?"https://wod.ngrok.io":"un-marc-local-pc.myshopify.com"===u()?"https://wod4.ngrok.io":"pn-teej-local.myshopify.com"===u()?"https://wod3.ngrok.io":"https://upsell-now.herokuapp.com"},d=function(){return!("undefined"==typeof window.un||"undefined"==typeof window.un.datastore)},h=function(){return m()&&y().length>0},m=function(){return!(!d()||"undefined"==typeof window.un.datastore.shop)&&window.un.datastore.shop},y=function(){return d()&&"undefined"!=typeof window.un.datastore.offers?window.un.datastore.offers:[]},v=function(){return"undefined"!=typeof window.un&&"undefined"!=typeof window.un.offers?window.un.offers:[]},b=function(n){var o=!1,i=e.getOfferObjects();return p.arrayChecker(i)&&t.each(i,function(t,e){n===e.id&&(o=e)}),o},C=function(){return-1!==window.location.href.replace("https://","").indexOf("/products")},k=function(){return-1!==window.location.href.replace("https://","").indexOf("/cart")},w=function(){return-1!==window.location.href.indexOf("/collections/")&&-1===window.location.href.indexOf("/products/")},P=function(){return"/"===window.location.pathname},I=function(){return window.un.datastore.shop.enabled_on_homepage},x=function(){return window.un.datastore.shop.enabled_on_collection_pages},O=function(){return p.onHomePage()&&p.enabledOnHomePage()||p.onCollectionPage()&&p.enabledOnCollectionPage()||!p.onHomePage()&&!p.onCollectionPage()},S=function(){var e=1;return t('form[action="/cart/add"]:first').find("input[name=quantity]:visible").length>0&&(e=t('form[action="/cart/add"]:first').find("input[name=quantity]:visible").val()),Number(e)},T=function(){var n=window.un.datastore.theme_setting,i=window.un.datastore.shop,r=[["cart_subtotal_selector","cart_subtotal_selector"],["checkout_button_selector","checkout_button_selector"],["add_to_cart_form_selector","add_to_cart_form_selector"],["add_to_cart_button_selector","add_to_cart_button_selector"],["quantity_selector","quantity_selector"],["cart_form_selector","cart_form_selector"],["quantity_button_selector","quantity_button_selector"],["variant_selector","variant_selector"],["swatch_selector","swatch_selector"],["mutation_ids","mutation_ids"],["mutation_classes","mutation_classes"],["cart_bar_placement_selector","cart_bar_placement_selector"],["cart_bar_placement_position","cart_bar_placement_position"],["cart_bar_ajax_placement_selector","cart_bar_ajax_placement_selector"],["cart_bar_ajax_placement_position","cart_bar_ajax_placement_position"]];t.each(r,function(t,o){i[o[0]]=e.mergeValues(i[o[0]],n[o[1]])}),null==i.custom_css&&(i.custom_css=""),i.add_to_cart_button_selector=i.add_to_cart_button_selector+", .un-cloned-atc-btn",o(n.custom_css)&&(i.custom_css=i.custom_css+"\r\n"+n.custom_css),o(i.custom_css)&&t("head").append('<style type="text/css">'+i.custom_css+"</style>"),window.un.datastore.shop=i,window.un.addedToCart={}},D=function(t,e){return o(t)?t:e},F=function(t,e,n){var o=new Date;o.setTime(o.getTime()+24*n*60*60*1e3);var i="expires="+o.toUTCString();document.cookie=t+"="+e+";"+i+";path=/"},j=function(t){var e=new Date;e.setTime(e.getTime()-2592e6);var n="expires="+e.toUTCString();document.cookie=t+"=;"+n+";path=/"},A=function(t){for(var e=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){for(var i=n[o];" "==i.charAt(0);)i=i.substring(1);if(0==i.indexOf(e))return i.substring(e.length,i.length)}return""},q=function(t){for(var e=[],n=t,o=document.cookie.split(";"),i=0;i<o.length;i++){for(var r=o[i];" "==r.charAt(0);)r=r.substring(1);0==r.indexOf(n)&&e.push(r)}return e},L=function(){var e=location.search.match(/variant=([0-9]+)/);return null!=e?e[1]:"radio"===t(f.add_to_cart_form_selector).find('select[name="id"], input[name="id"]').attr("type")?t(f.add_to_cart_form_selector).find('input[name="id"]:checked').val():t(f.add_to_cart_form_selector).find('select[name="id"], input[name="id"]').val()},E=function(){if(!e.onProductPage())return null;if(void 0!==e.getCurrentVariantId()){var t=window.un.product.variants.find(function(t){return t.id.toString()===e.getCurrentVariantId().toString()});return void 0===t?(p.log("Unable to find current variant because current variant ID isn't matching a variant in un.product.variants object. Returning first variant in product object."),window.un.product.variants[0]):t}return p.log("Unable to find current variant because getCurrentVariantId() is returning undefined. Returning first variant in product object."),window.un.product.variants[0]},Q=function(t){var n=e.getCookie("_un_discounted_line_item_"+t);return""!==n&&(n.indexOf("_")>-1?parseInt(n.split("_")[0]):parseInt(n))},N=function(t){var n=e.getCookie("_un_discounted_line_item_"+t);return""!==n&&(n.indexOf("_")>-1&&parseInt(n.split("_")[1]))},M=function(e){if("function"==typeof Spinner){var n=new Spinner({top:"-50px",left:"50%",position:"relative"}).spin().el;t(e).first().after(n)}},V=function(){t(".spinner").remove()},R=function(e){t(e).css("background","#EEEEEE"),t(e).css("color","#FFFFFF"),t(e).css("border","1px solid #DDDDDD")},U=function(t){return!t.available},H=function(e,n,o){p.stringChecker(o)&&t(e).css(n,o)},B=function(){return window.location.href.indexOf("upsell-now-debug")<0},K=function(t){return t<0?0:t},W=function(t,e){return this.checkMutationIds(t,e)||this.checkMutationClasses(t,e)},z=function(e,n){var o=[],i=!1;return"ajaxCart"===n&&(o=["drawer","cart-drawer__item-list","cart-item__qty","mm-opened","cart-sidebar","opened","cart-preview","ajaxcart__inner","cart--is-visible"]),t.each(o,function(t,n){"undefined"!=typeof e.target.classList&&e.target.classList.contains(n)&&(i=!0)}),i},G=function(t,e){var n=[];return"ajaxCart"===e&&(n=["ajaxifyCart","cart-loading","AjaxifyCart","layer-addcart-modal"]),n.indexOf(t.target.id)>-1},J=function(t){if("string"==typeof t){var e=[];return e.push(t),e}return t},Y=function(){var t=p.getCookiesWithPartialName("_un_discounted_line_item_");return t=t.filter(function(t){return t.indexOf(g)<0&&t.indexOf(_)<0})},$=function(e,n){var o=["display","border","background","margin","padding","font-family","font-size","font-weight","height","width","text-transform","font-style","letter-spacing","flex","color","line-height","text-decoration","text-align","vertical-align","white-space","border-radius","cursor","position"];t.each(o,function(o,i){t(n).css(i,t(e).css(i))})};this.stringChecker=o,this.objectChecker=i,this.arrayChecker=r,this.unFormatCents=a,this.unFormatPercent=c,this.getShopifyDomain=u,this.getPrimaryDomain=s,this.getServerAddress=l,this.checkDatastore=d,this.checkSettingsInDatastore=h,this.getShopInDatastore=m,this.getOffersInDatastore=y,this.getOfferObjects=v,this.onProductPage=C,this.onCartPage=k,this.onCollectionPage=w,this.onHomePage=P,this.enabledOnHomePage=I,this.enabledOnCollectionPage=x,this.getProductPageQuantityValue=S,this.mergeThemeAndShopSettings=T,this.mergeValues=D,this.setCookie=F,this.expireCookie=j,this.getCookie=A,this.getCookiesWithPartialName=q,this.getOfferIdForItemKeyFromCookie=Q,this.getQuantityForItemKeyFromCookie=N,this.enableSpinner=M,this.disableSpinner=V,this.applyDisabledStyles=R,this.outOfStock=U,this.applyStyle=H,this.log=n,this.notInDebugMode=B,this.noNegative=K,this.enabledOnCurrentPage=O,this.getCurrentVariant=E,this.getCurrentVariantId=L,this.checkMutations=W,this.checkMutationClasses=z,this.checkMutationIds=G,this.arrayify=J,this.getDiscountedLineItemsFromCookies=Y,this.getOfferById=b,this.cloneStyles=$}function n(e){var n=this,o=function(){n.checkBundleIntegrity()},i=function(){h.updateCart(function(){n.switchTempOriginalProductLinksToLineItemKeys(),n.clearOldLineItemKeys(),f.remove_upsell_products_if_original_product_removed&&(p.log("Checking for original products"),n.initAjaxCartMutationObserver(),n.disableRemoveButtonClickListeners(),n.createRemoveButtonClickEventListener(),n.checkIfOriginalProductStillInCart()),f.remove_upsell_products_if_trigger_products_removed&&(p.log("Checking for trigger product requirements"),n.checkTriggerProductRequirements()),f.prevent_upsell_product_qty_change&&(p.log("Checking for upsell product quantity changes"),n.checkUpsellProductQtys())})},r=function(){var e=p.getDiscountedLineItemsFromCookies(),n=[];t.each(e,function(t,e){var o=e.substring(0,e.indexOf("=")),i=o.substring(o.lastIndexOf("_")+1),r=p.getOfferIdForItemKeyFromCookie(i);if(r){var a=p.getOfferById(r);a&&(a.checkIfTriggerProductsInCart()||(p.log("Trigger products req not met for "+r+". Removing associated upsell items."),n.push(i)))}}),n.length>0&&(p.log("Removing line items:"+n),h.removeLineItemKeysFromCart(n))},a=function(){var e=p.getDiscountedLineItemsFromCookies();t.each(e,function(t,e){var n=e.substring(0,e.indexOf("=")),o=n.substring(n.lastIndexOf("_")+1);h.hasLineItemKey(o)||p.expireCookie(n)})},c=function(){var e=p.getDiscountedLineItemsFromCookies();t.each(e,function(t,e){var n=e.substring(0,e.indexOf("=")),o=n.substring(n.lastIndexOf("_")+1),i=p.getQuantityForItemKeyFromCookie(o);i!==h.getLineItemQuantity(o)&&(p.log("Upsell product quantity changed for: "+o+". Resetting quantity."),h.changeQuantity(o,i))})},u=function(){var e=p.getCookiesWithPartialName(_);t.each(e,function(t,e){var n=e.substring(e.lastIndexOf("_")+1,e.indexOf("=")),o=e.substring(e.indexOf("=")+1).split(",");h.hasLineItemKey(n)?p.log("Original product line item key found in cart."):(p.log("Original product line item key missing from cart. Removing upsell items."),o=p.arrayify(o),p.expireCookie(e.substring(0,e.indexOf("="))),h.removeLineItemKeysFromCart(o))})},s=function(){var t=n.generateOriginalProductVariantIdToUpsellKeyMap();n.setOriginalProductLineItemKeyToUpsellItemKeysCookie(t),n.clearTempOriginalProductLinkCookies()},l=function(){var e=p.getCookiesWithPartialName(g),n={};return t.each(e,function(t,e){var o=e.substring(g.length,e.indexOf("=")),i=e.substring(e.indexOf("=")+1,e.length);p.objectChecker(n[i])||(n[i]=[]),n[i].push(o)}),n},d=function(e){t.each(Object.keys(e),function(t,n){var o=h.getLastLineItemKeyForVariantId(n);if(o){var i=e[n].join(",");p.stringChecker(i)&&p.stringChecker(o)&&p.setCookie(_+o,i,30)}})},y=function(){var e=p.getCookiesWithPartialName(g);t.each(e,function(t,e){var n=e.substring(0,e.indexOf("="));p.expireCookie(n)})},v=function(){t(document).on("click",m,function(t){return t.stopPropagation(),t.preventDefault(),t.stopImmediatePropagation(),h.updateCart(function(){n.switchTempOriginalProductLinksToLineItemKeys(),n.handleRemoveButtonClick(t)}),!1})},b=function(){var t=!1,e=new MutationObserver(function(e){e.forEach(function(e){!t&&p.checkMutations(e,"ajaxCart")&&(setTimeout(function(){p.log("Ajax cart mutation triggered."),n.disableRemoveButtonClickListeners(),n.checkBundleIntegrity()},250),t=!0)}),setTimeout(function(){t=!1},2e3)}),o={attributes:!0,childList:!0,characterData:!0,subtree:!0},i=document.body;e.observe(i,o)},C=function(){t(".cart-item__remove, .cart-drawer__item-delete").removeAttr("data-cart-item-delete"),t.each(t(".cart-item__remove"),function(e,n){t(n).replaceWith(t(n).clone().removeClass("cart-item__remove").addClass("un-remove-btn"))})},k=function(t){var e=n.getRemovedLineItemKeyFromLink(t);if(e){var o=p.getCookie(_+e);if(p.stringChecker(o))p.log("Found upsell cookie, displaying warning"),n.showUpsellProductRemovalWarning(e,o);else{p.log("Couldn't find upsell item cookie for removed item.");var i=[];i.push(e),h.removeLineItemKeysFromCart(i)}}else p.log("Couldn't find line item key for removed item.")},w=function(e,o){var i=n.convertProductKeysToProductNames(e)[0],r=o.split(","),a=n.convertProductKeysToProductNames(r);if(a.length>0){var c=a.join(", "),u=f.removing_original_product_will_remove_upsell_products_warning.replace("{{original_product}}",i).replace("{{upsell_products}}",c);if(u=t("<div/>").html(u).text(),confirm(u))(s=[]).push(e),s=s.concat(r),p.expireCookie(_+e),h.removeLineItemKeysFromCart(s)}else{var s;p.log("No upsell items associated with line item key. Clearing cookie and removing item from cart."),(s=[]).push(e),p.expireCookie(_+e),h.removeLineItemKeysFromCart(s)}},P=function(e){var n=[];if("string"==typeof e){var o=h.getProductTitleFromLineItemKey(e);p.stringChecker(o)&&n.push(o)}else"object"==typeof e&&t.each(e,function(t,e){var o=h.getProductTitleFromLineItemKey(e);p.stringChecker(o)&&n.push(o)});return n},I=function(e){var n=!1,o=t(e.target).attr("href");if(p.stringChecker(o)||(o=t(e.target).parent().attr("href")),p.stringChecker(o)&&o.indexOf("line=")>=0){var i=/line=([0-9]+)/g.exec(o)[1]-1;n=un.cart.items[i].key}else n=t(e.target).parents(".cart-drawer__item").data("cart-item-id");return p.stringChecker(n)||(n=t(e.target).parents(".cart-row").data("id")),n};this.offers=e,this.startBundleEnforcer=o,this.switchTempOriginalProductLinksToLineItemKeys=s,this.createRemoveButtonClickEventListener=v,this.handleRemoveButtonClick=k,this.clearTempOriginalProductLinkCookies=y,this.generateOriginalProductVariantIdToUpsellKeyMap=l,this.setOriginalProductLineItemKeyToUpsellItemKeysCookie=d,this.getRemovedLineItemKeyFromLink=I,this.showUpsellProductRemovalWarning=w,this.convertProductKeysToProductNames=P,this.initAjaxCartMutationObserver=b,this.disableRemoveButtonClickListeners=C,this.checkBundleIntegrity=i,this.checkIfOriginalProductStillInCart=u,this.checkUpsellProductQtys=c,this.clearOldLineItemKeys=a,this.checkTriggerProductRequirements=r}function o(e){var n=this,o=function(){n.checkIfItemsWereAddedViaUpsellPopup(),n.updateCartPageWithDiscounts(),n.initRefreshCartPageEventHandler()},i=function(){n.updateDiscountedSubtotal(),n.updateLineItemPrices(),n.updateLineItemTotals(),f.cart_bar_enabled&&p.objectChecker(un.cart.un_total_discount)&&un.cart.un_total_discount>0&&n.showCartBar()},r=function(){0===t("#un-cart-bar-page").length&&n.addBarToPage(f.cart_bar_placement_selector,f.cart_bar_placement_position,"un-cart-bar-page"),0===t("#un-cart-bar-ajax").length&&f.ajax_cart_integration_enabled&&n.addBarToPage(f.cart_bar_ajax_placement_selector,f.cart_bar_ajax_placement_position,"un-cart-bar-ajax"),n.applyBarStyles()},a=function(){p.stringChecker(f.cart_bar_font_family)&&(t("head").append('<link href="https://fonts.googleapis.com/css?family='+f.cart_bar_font_family+'" rel="stylesheet">'),t(".un-cart-bar").css("font-family",f.cart_bar_font_family.replace(/\+/g," ")+", sans-serif")),p.applyStyle(".un-cart-bar","background-color",f.cart_bar_bg_color),p.applyStyle(".un-cart-bar","color",f.cart_bar_text_color),p.applyStyle(".un-cart-bar","padding",f.cart_bar_padding),p.applyStyle(".un-cart-bar","font-size",f.cart_bar_font_size),p.applyStyle(".un-cart-bar","border-radius",f.cart_bar_border_radius)},u=function(e,n,o){var i='<div class="un-cart-bar" style="display: none;" id="'+o+'">'+f.cart_bar_text+"</div>",r=f.cart_bar_fade_in_duration||0,a=f.cart_bar_fade_out_duration||0,c=f.cart_bar_display_duration||0;p.stringChecker(n)&&"after"!==n?"before"===n?t(e).before(i):"prepend"===n?t(e).prepend(i):"append"===n&&t(e).append(i):t(e).after(i),t(".un-cart-bar").fadeIn(1e3*r),c>0&&setTimeout(function(){t(".un-cart-bar").fadeOut(1e3*a)},1e3*c)},s=function(){p.stringChecker(f.cart_form_selector)&&(p.stringChecker(f.quantity_selector)&&t(document).on("change",f.quantity_selector,function(){setTimeout(function(){t(f.cart_form_selector).submit()},1500)}),p.stringChecker(f.quantity_button_selector)&&t(document).on("click",f.quantity_button_selector,function(){setTimeout(function(){t(f.cart_form_selector).submit()},1500)}))},l=function(){var e=d();t(f.cart_subtotal_selector).html(p.unFormatCents(e,f.money_with_currency_format))},d=function(){var e=0;return t.each(un.cart.items,function(t,n){p.objectChecker(n.un_total_discount_value)&&(e+=n.un_total_discount_value)}),un.cart.un_total_discount=e,un.cart.total_price-e},_=function(){var e=t(".un-line-item-unit-price");t.each(un.cart.items,function(n,o){p.objectChecker(o.un_discount_value)&&t.each(e,function(e,n){t(n).data("id")===o.key&&t(n).html(p.unFormatCents(o.un_discounted_price,f.money_format))})})},g=function(){var e=t(".un-line-item-total");t.each(un.cart.items,function(n,o){p.objectChecker(o.un_discount_value)&&t.each(e,function(e,n){if(t(n).data("id")===o.key){var i=o.line_price-o.un_total_discount_value;t(n).html(p.unFormatCents(i,f.money_format))}})})},m=function(){p.objectChecker(window.un.cart.items)&&t.each(window.un.cart.items,function(t,e){var o=p.getOfferIdForItemKeyFromCookie(e.key);if(o){var i=c.getActiveOfferById(o);p.objectChecker(i)&&n.applyOfferDiscountToItem(e,i)}})},y=function(t,e){"percentage_discount"===e.discountType?(t.appliedDiscount=n.percentageDiscountHash(t,e),t.un_discount_value=100*t.appliedDiscount.discount_amount,t.un_total_discount_value=100*t.appliedDiscount.total_discount_amount,t.un_discounted_price=t.price-t.un_discount_value):"fixed_amount_discount"===e.discountType?(t.appliedDiscount=n.fixedAmountDiscountHash(t,e),t.un_discount_value=e.discountFixedAmount,t.un_total_discount_value=t.appliedDiscount.total_discount_amount,t.un_discounted_price=t.price-e.discountFixedAmount):"set_price"===e.discountType&&(t.appliedDiscount=n.setPriceDiscountHash(t,e),t.un_discount_value=t.price-e.discountPrice,t.un_total_discount_value=t.appliedDiscount.total_discount_amount,t.un_discounted_price=e.discountPrice)},v=function(t,e){var n=Math.floor(e.discountFixedAmount),o={};return n>t.price&&(n=t.price),o.discount_amount=n,o.total_discount_amount=n*t.quantity,o.value_type="fixed_amount",o.description=f.discount_title,o.title=f.discount_title,o.value=n/100,o.amount=n*t.quantity/100,o},b=function(t,e){var n={},o=t.price/100;return n.value=Math.floor(e.discountPercent),n.discount_amount=Math.floor(o*n.value)/100,n.total_discount_amount=Math.floor(o*n.value*t.quantity)/100,n.value_type="percentage",n.description=f.discount_title,n.title=f.discount_title,n.amount=Math.floor(o*n.value*t.quantity)/100,n},C=function(t,e){var n=Math.floor(t.price-e.discountPrice),o={};return o.discount_amount=n,o.total_discount_amount=n*t.quantity,o.value_type="fixed_amount",o.description=f.discount_title,o.title=f.discount_title,o.value=n/100,o.amount=n*t.quantity/100,o},k=function(t){var e=["ajaxifyCart","cart-loading","AjaxifyCart","layer-addcart-modal"];if(p.stringChecker(f.mutation_ids)){var n=f.mutation_ids.replace(/ /g,"").split(",");e=e.concat(n)}return-1!==e.indexOf(t.target.id)},w=function(e){var n=["drawer","cart-drawer__item-list","ajaxcart__footer--fixed","cart-item__qty","mm-opened","cart-sidebar","opened","cart-preview","mfp-ready"];if(p.stringChecker(f.mutation_classes)){var o=f.mutation_classes.replace(/ /g,"").split(",");n=n.concat(o)}var i=!1;return t.each(n,function(t,n){"undefined"!=typeof e.target.classList&&e.target.classList.contains(n)&&(i=!0)}),i},P=function(t){return k(t)||w(t)},I=function(){var t=!1,e=new MutationObserver(function(e){e.forEach(function(e){!t&&P(e)&&(setTimeout(function(){h.updateCart(function(){n.applyOfferDiscountsToCart(),c.createCheckoutEventListener()})},250),t=!0)}),setTimeout(function(){t=!1},2e3)}),o={attributes:!0,childList:!0,characterData:!0,subtree:!0},i=document.body;e.observe(i,o)};this.offers=e,this.applyOfferDiscountsToCart=o,this.checkIfItemsWereAddedViaUpsellPopup=m,this.applyOfferDiscountToItem=y,this.updateDiscountedSubtotal=l,this.updateLineItemPrices=_,this.updateLineItemTotals=g,this.fixedAmountDiscountHash=v,this.percentageDiscountHash=b,this.setPriceDiscountHash=C,this.updateCartPageWithDiscounts=i,this.initRefreshCartPageEventHandler=s,this.initAjaxCartObserver=I,this.showCartBar=r,this.addBarToPage=u,this.applyBarStyles=a}function i(){var e=this,n=function(e,n,o,i){window.un.addedToCart[e]=!0;var r={quantity:n,id:e};o.length>0&&(r.properties=o[0]),t.ajax({cache:!1,type:"POST",url:"/cart/add.js",data:r,dataType:"json"}).done(function(t){i(t)})},o=function(t){return"undefined"==typeof window.un.addedToCart[t]},i=function(e){t.ajax({cache:!1,type:"GET",url:"https://"+window.location.hostname+"/cart?view=upsell-now-cart",success:function(t){window.un.cart=JSON.parse(t),e()}})},r=function(){var n={};return n.line_items=JSON.stringify(e.getLineItemsHash()),n.order_notes="",t("#CartSpecialInstructions:visible").length>0&&(n.order_notes=t("#CartSpecialInstructions:visible").val()),t("#cartSpecialInstructions:visible").length>0&&(n.order_notes+=t("#cartSpecialInstructions:visible").val()),t("#cartSpecialInstructionsFromPopup:visible").length>0&&(n.order_notes+=t("#cartSpecialInstructionsFromPopup:visible").val()),""===n.order_notes&&t("textarea[name='note']:visible:first").length>0&&(n.order_notes+=t("textarea[name='note']:visible:first").val()),n},a=function(){var n=[];return t.each(window.un.cart.items,function(t,o){n.push(e.getLineItemHash(o))}),n},c=function(t){var n={};return n.title=t.title,n.variant_id=t.variant_id,n.product_id=t.product_id,n.image=t.image,n.quantity=t.quantity,n.grams=t.grams,n.requires_shipping=t.requires_shipping,n.price=t.price/100,n.properties=e.getLineItemPropertiesArray(t),p.objectChecker(t.appliedDiscount)&&(n.applied_discount=t.appliedDiscount),n},u=function(e){var n=[];return null!=e.properties&&t.each(Object.keys(e.properties),function(t,o){var i={};i.name=o,i.value=e.properties[o],n.push(i)}),n},s=function(){var e=!1;return t.each(window.un.cart.items,function(t,n){p.objectChecker(n.appliedDiscount)&&(e=!0)}),e},l=function(e){t.ajax({cache:!1,type:"POST",url:p.getServerAddress()+"/get_checkout_url?shopify_domain="+p.getShopifyDomain(),data:JSON.stringify(e),dataType:"json",contentType:"application/json; charset=utf-8",success:function(t){t.invoice_url?window.location.href=t.invoice_url.replace("checkout.shopify.com",f.primary_domain):alert("An error occured, and we're unable to process your order at this time. Please contact customer service for assistance. ")}})},d=function(){var t=e.cloneUnCart();return e.addCurrentProductPageVariantAsLineItem(t),t},h=function(){return JSON.parse(JSON.stringify(window.un.cart))},_=function(t){if(!p.onProductPage())return t;var e=p.getCurrentVariantId(),n=t.items.find(function(t){return t.variant_id==e});return"object"==typeof n?n.quantity+=p.getProductPageQuantityValue():((n={}).quantity=p.getProductPageQuantityValue(),n.price=p.getCurrentVariant().price,n.collection_ids=window.un.product_collections,n.product_id=window.un.product.id,n.variant_id=Number(e),t.items.push(n)),t.total_price=t.items.reduce(function(t,e){return t+e.price*e.quantity},0),t.original_total_price=t.total_price,t},g=function(n){var o=!1,i=e.cloneWithCurrentProductPageVariantAsLineItem();return t.each(i.items,function(t,e){e.product_id.toString()===n&&(o=!0)}),o},m=function(e){var n=!1;return t.each(un.cart.items,function(t,o){o.key===e&&(n=!0)}),n},y=function(e){var n=!1;return t.each(un.cart.items,function(t,o){o.key===e&&(n=o)}),n},v=function(t){var n=e.getLineItem(t);return!!n&&n.quantity},b=function(e){var n=!1,o=un.cart.items.reverse();return t.each(o,function(t,o){o.variant_id.toString()===e.toString()&&(n=o.key)}),n},C=function(e){var n=!1;return t.each(un.cart.items,function(t,o){o.key.toString()===e&&(n=o.title)}),n},k=function(n){var o=e.createUpdateQtyHash(n,0);t.ajax({cache:!1,type:"POST",url:"/cart/update.js",data:{updates:o},dataType:"json"}).done(function(){e.redirectToCartPage()})},w=function(n,o){var i=p.arrayify(n),r=e.createUpdateQtyHash(i,o);t.ajax({cache:!1,type:"POST",url:"/cart/update.js",data:{updates:r},dataType:"json"}).done(function(){e.redirectToCartPage()})},P=function(e,n){var o={};return t.each(e,function(t,e){o[e]=n}),o},I=function(){setTimeout(function(){window.location.href="/cart"},250)};this.updateCart=i,this.changeQuantity=w,this.addToCart=n,this.createDraftOrder=r,this.getLineItemsHash=a,this.getLineItemHash=c,this.getLineItemPropertiesArray=u,this.hasDiscounts=s,this.getAndSendToCheckoutUrl=l,this.cloneWithCurrentProductPageVariantAsLineItem=d,this.cloneUnCart=h,this.addCurrentProductPageVariantAsLineItem=_,this.inCart=g,this.notYetAddedToCart=o,this.getLastLineItemKeyForVariantId=b,this.getProductTitleFromLineItemKey=C,this.removeLineItemKeysFromCart=k,this.redirectToCartPage=I,this.createUpdateQtyHash=P,this.hasLineItemKey=m,this.getLineItem=y,this.getLineItemQuantity=v}function r(e){var n=this,o="_un_closed_offer_"+e.id.toString(),r=function(){t("#un-modal-title").text(e.popupTitle),t("#un-modal-description").text(e.popupDescription),t("#upsell-popup-close-link").text(f.no_thanks_text),n.printProductRows(),t("#un-modal-background").addClass("un-manual-modal-container"),n.initializeAddToCartButtons(),n.initializeVariantFields(),n.initializeCloseButtons(),n.applyStyles()},a=function(){t(window).click(function(t){!n.fullsizeImageModalOpenedOnPage()&&t.target.classList.contains("un-manual-modal-container")&&n.close(),n.closeImagePopupOnClickOutside()}),t("#un-modal-close-btn, #upsell-popup-close-link").click(function(){n.close()}),n.initializeAddToCartButtons(),n.initializeVariantFields(),n.initializeQuantityFields(),n.applyStyles()},c=function(){t("#un-modal-background").removeClass("un-manual-modal-container"),window.un.atcPopupClosed||(window.un.atcPopupClosed=!0,"omorose-natural-products.myshopify.com"!==p.getShopifyDomain()&&"roadgods-dev.myshopify.com"!==p.getShopifyDomain()&&t(f.add_to_cart_button_selector).trigger("click"),"honu-au.myshopify.com"===p.getShopifyDomain()&&setTimeout(function(){window.location.href="/cart"},250)),f.hide_offer_if_already_declined&&p.setCookie(o,e.id,f.num_days_before_showing_offer_again)},u=function(){n.fullsizeImageModalOpenedOnPage()&&(t("#un-modal-background-for-full-img").hasClass("opened")?(t("#un-modal-background-for-full-img").removeClass("opened"),t("#un-modal-background-for-full-img").removeClass("un-manual-modal-container")):t("#un-modal-background-for-full-img").addClass("opened"))},s=function(){t("#un-modal-background").removeClass("un-manual-modal-container"),window.un.checkoutPopupClosed=!0,f.hide_offer_if_already_declined&&p.setCookie(o,e.id,f.num_days_before_showing_offer_again),i.checkoutEventHandler()},l=function(){t("#upsell-product-table").html(""),t.each(e.productsForPopup,function(o,i){var r=t("#upsell-popup-product-row").html(),a=n.getPrices(i.originalPrice,i.price),c=p.outOfStock(i),u=t("<div/>").html(i.title).text(),s=t("<div/>").html(a[0]).text(),l=t("<div/>").html(a[1]).text(),d=n.getVariantFieldHTML(i),h=n.getProductLink(i),_=e.showVariantField,g=n.getUpsellProductQty(i,e),m=n.getProductImageSetting(e.productImageSetting),y=n.showFullSizeProductImage(e);i.variants.length<2&&(_=!1);var v={show_product_image:m,upsell_product_img_src:i.imgSrc,upsell_product_title:u,upsell_product_qty:g,upsell_product_original_price:s,upsell_product_price:l,upsell_product_id:i.productId,upsell_variant_id:i.variantId,upsell_product_out_of_stock:c,upsell_product_in_stock:!c,upsell_product_add_to_cart_text:f.add_to_cart_button_text,upsell_product_sold_out_text:f.sold_out_button_text,upsell_show_quantity_field:e.showQuantityField,upsell_hide_quantity_field:!e.showQuantityField,upsell_show_variant_field:_,upsell_product_variants:d,upsell_product_link:h,product_links_enabled:e.productLinksEnabled,show_full_product_image:y},b=unHandleBars.compile(r)(v);b=b.replace(/undefined/g," "),t("#upsell-product-table").append(b)})},d=function(t,o){var i=[];return"no_discount"!==e.discountType&&0!==e.discountType?(i[0]=p.unFormatCents(o,f.money_format),i[1]=p.unFormatCents(n.getDiscountedPrice(o),f.money_format)):("number"==typeof parseInt(t)&&parseInt(t)>parseInt(o)?i[0]=p.unFormatCents(t,f.money_format):i[0]=!1,i[1]=p.unFormatCents(o,f.money_format)),i},_=function(t){var n=0,o=e.discountType;return"percentage_discount"===o?n=Math.floor(t*(1-e.discountPercent/100)):"fixed_amount_discount"===o?n=t-e.discountFixedAmount:"set_price"===o&&(n=e.discountPrice),(n<0||""===n)&&(n=0),n},g=function(){t(document).on("click",".upsell-product-add-to-cart",function(o){var i=t(o.target).data("id"),r=t(o.target).data("product-id");if(h.notYetAddedToCart(i)){if(t(o.target).text(f.added_to_cart_button_text).val(f.added_to_cart_button_text),t(o.target).addClass("disabled"),t("#upsell-now-qty-"+i).length>0)var a=t("#upsell-now-qty-"+i).val();else if(e.showQuantityField)a=t(".upsell-now-quantity-field[data-product-id='"+r+"']").val();else a=t(o.target).data("quantity");var c=e.getLineItemDiscountPropertyArray();h.addToCart(i,a,c,function(t){var o=t.key,i=p.getCurrentVariantId();p.setCookie("_un_discounted_line_item_"+o,e.id.toString()+"_"+a,30),p.setCookie("_un_discounted_line_item_original_product_link_temp_"+o,i,30),e.closePopupOnATC&&n.close()}),o.stopPropagation(),o.preventDefault()}})},m=function(){p.stringChecker(f.add_to_cart_button_font_family)&&(t("head").append('<link href="https://fonts.googleapis.com/css?family='+f.add_to_cart_button_font_family+'" rel="stylesheet">'),t("body #upsell-product-table .upsell-product-add-to-cart").css("font-family",f.add_to_cart_button_font_family.replace(/\+/g," ")+", sans-serif")),p.stringChecker(f.popup_font_family)&&(t("head").append('<link href="https://fonts.googleapis.com/css?family='+f.popup_font_family+'" rel="stylesheet">'),t("body #un-modal-content").css("font-family",f.popup_font_family.replace(/\+/g," ")+", sans-serif")),p.applyStyle("#upsell-product-table .upsell-product-add-to-cart","background-color",f.add_to_cart_button_bg_color),p.applyStyle("#upsell-product-table .upsell-product-add-to-cart","color",f.add_to_cart_button_text_color),p.applyStyle("#upsell-popup-close-link","color",f.no_thanks_text_color),p.applyStyle(".upsell-product-title","color",f.product_title_text_color),p.applyStyle(".upsell-product-original-price","color",f.regular_price_text_color),p.applyStyle(".upsell-product-price","color",f.sale_price_text_color),p.applyStyle("#un-modal-content","background-color",f.popup_bg_color),p.applyStyle("#un-modal-title","color",f.popup_title_text_color),p.applyStyle("#un-modal-description","color",f.popup_description_text_color)},y=function(e){var o="",i=!0,r="";return n.offer.showVariantField&&e.variants.length>1&&(o='<select class="upsell-product-variant-field" data-id="'+e.productId+'">',t.each(e.variants,function(t,e){e.available&&i?(r="SELECTED",i=!1):r="",o+='<option value="'+e.id+'" '+r+">"+e.title+"</option>"}),o+="</select>"),o},v=function(){n.offer.showVariantField&&t(document).on("change",".upsell-product-variant-field",function(e){var o=t(e.target).data("id").toString(),i=t(e.target).find(":selected").val(),r=n.offer.getPopupProductVariantData(o,i);!1!==r&&(n.swapPricesInRow(o,r),n.swapButtonIdAndStatusInRow(o,r),n.validateQuantityFieldOnChangeOfVariant(o,r)),e.preventDefault(),e.stopPropagation()})},b=function(){n.offer.showQuantityField&&t(document).on("change",".upsell-now-quantity-field",function(){var e=t(this),o=t(this).data("product-id").toString(),i=n.getVariantId(o),r=n.offer.getPopupProductVariantData(o,i);!1!==r&&(n.variantPresentInCart(i,r)?n.cartAndInventoryStocklimitChecker(i,e,r):n.verifyIsUpsellQtyGreaterThanInventoryQty(e,r,i))})},C=function(e){
var n=t("#upsell-product-"+e+" .upsell-product-add-to-cart").data("id");return t("#upsell-product-"+e+" .upsell-product-variant-field").length>0&&(n=t(".upsell-product-variant-field[data-id='"+e+"']").val()),n.toString()},k=function(e,o){var i=n.getPrices(o.originalPrice,o.price),r=t("<div/>").html(i[0]).text(),a=t("<div/>").html(i[1]).text();t("#upsell-product-"+e+" .upsell-product-original-price").html(r),t("#upsell-product-"+e+" .upsell-product-price").html(a)},w=function(e,n){var o=t("#upsell-product-"+e+" .upsell-product-add-to-cart");t(o).data("id",n.id),n.available?(t(o).text(f.add_to_cart_button_text),t(o).removeClass("disabled"),t(o).prop("disabled",!1)):(t(o).text(f.sold_out_button_text),t(o).addClass("disabled"),t(o).prop("disabled",!0))},P=function(e,o){var i=o.id,r=t(".upsell-now-quantity-field[data-product-id='"+e+"']");n.hideInsufficientStockWarning(r),n.variantPresentInCart(i,o)?n.cartAndInventoryStocklimitChecker(i,r,o):n.verifyIsUpsellQtyGreaterThanInventoryQty(r,o,i)},I=function(t){return"show_product_image"===t},x=function(t){return"https://"+window.Shopify.shop+"/products/"+t.handle},O=function(t){return"show_product_image_with_zoom"===t.productImageSetting&&(n.initalizeFullSizeImageModal(),!0)},S=function(){t(document).on("click","#un-modal-background img",function(){var e=t(this).attr("src").replace("100x100","600x600");t(".upsell-product-image-for-full-img").attr("src",e),t("#un-modal-background-for-full-img").addClass("un-manual-modal-container")}),t("#un-modal-close-btn-for-full-img, #upsell-popup-close-link-for-full-img").click(function(){t("#un-modal-background-for-full-img").removeClass("un-manual-modal-container"),t("#un-modal-background-for-full-img").removeClass("opened")})},T=function(){var t=document.getElementById("un-modal-background-for-full-img");return null!==t&&t.classList.contains("un-manual-modal-container")},D=function(e,o,i){var r=parseInt(o.val());t.each(un.cart.items,function(t,a){if(a.variant_id===parseInt(e)){var c=a.quantity+r;if(n.isUpsellQtyGreaterThanInventoryAndCartQty(c,i)){var u=p.noNegative(parseInt(i.inventoryQuantity)-a.quantity);n.showInsufficientStockWarning(i,o,u,e)}else n.hideInsufficientStockWarning(o);return!1}})},F=function(t,e){return t>parseInt(e.inventoryQuantity)&&p.stringChecker(e.inventoryManagement)&&!(p.stringChecker(e.inventoryPolicy)&&"continue"===e.inventoryPolicy)},j=function(t,e,o){var i=f.insufficient_stock_message.replace("{quantity}",o);n.hideInsufficientStockWarning(e),e.after("<span class='qty-alert-popup-field upsell-now-qty-alert-"+e.data("product-id")+"'>"+i+"</span>"),e.val(o)},A=function(e,o){var i=o.upsellQty;return!o.showQuantityField||!p.stringChecker(e.inventoryManagement)||p.stringChecker(e.inventoryPolicy)&&"continue"===e.inventoryPolicy||(i>parseInt(e.inventoryQuantity)&&(i=p.noNegative(parseInt(e.inventoryQuantity))),t.each(un.cart.items,function(t,r){if(parseInt(e.variantId)===r.variant_id){var a=o.upsellQty+r.quantity;return n.isUpsellQtyGreaterThanInventoryAndCartQty(a,e)&&(i=p.noNegative(parseInt(e.inventoryQuantity)-r.quantity)),!1}})),i},q=function(e){t(".upsell-now-qty-alert-"+e.data("product-id")).remove()},L=function(e){var n=!1;return t.each(un.cart.items,function(t,o){if(o.variant_id===parseInt(e))return n=!0,!1}),n},E=function(t,e,o){if(parseInt(t.val())>e.inventoryQuantity&&p.stringChecker(e.inventoryManagement)&&(!p.stringChecker(e.inventoryPolicy)||"continue"!==e.inventoryPolicy)){var i=p.noNegative(parseInt(e.inventoryQuantity));n.showInsufficientStockWarning(e,t,i,o)}else n.hideInsufficientStockWarning(t)};this.offer=e,this.show=r,"add_to_cart"===e.triggerEvent?this.close=c:"checkout"===e.triggerEvent&&(this.close=s),this.printProductRows=l,this.getPrices=d,this.getDiscountedPrice=_,this.initializeAddToCartButtons=g,this.applyStyles=m,this.getVariantFieldHTML=y,this.initializeVariantFields=v,this.initializeQuantityFields=b,this.swapPricesInRow=k,this.swapButtonIdAndStatusInRow=w,this.getProductImageSetting=I,this.getProductLink=x,this.cartAndInventoryStocklimitChecker=D,this.getUpsellProductQty=A,this.showInsufficientStockWarning=j,this.validateQuantityFieldOnChangeOfVariant=P,this.hideInsufficientStockWarning=q,this.variantPresentInCart=L,this.verifyIsUpsellQtyGreaterThanInventoryQty=E,this.isUpsellQtyGreaterThanInventoryAndCartQty=F,this.getVariantId=C,this.showFullSizeProductImage=O,this.initalizeFullSizeImageModal=S,this.fullsizeImageModalOpenedOnPage=T,this.initializeCloseButtons=a,this.closeImagePopupOnClickOutside=u}function a(e,n){var o=this,i=function(t,e,n,i,r){o.productHandles=t,o.shopifyDomain=r,o.collectionHandles=e,o.maxNumberOfProducts=n,o.maxNumberOfProductsPerCollection=i,o.productsArray=[],t.length>0?(p.log("Getting upsell products for offer "+o.offer.id),o.ajaxCallToGetProduct(0)):o.getProductsFromSelectedCollections()},r=function(e){var n=o.productHandles[e];o.inProductCache(n.shopify_product_id)?o.processProductData(o.getCachedProduct(n.shopify_product_id),e):t.ajax({cache:!0,type:"GET",url:"https://"+o.shopifyDomain+"/products/"+n.handle+"?view=upsell-now-product",success:function(t){o.setCachedProduct(t,n.shopify_product_id),o.processProductData(t,e)},error:function(){o.processProductData(!1,e)}})},a=function(t,e){t=JSON.parse(t);var n=o.createNewProduct(t);n&&p.outOfStock(n)&&o.offer.hideOutOfStockProducts&&(n=!1,p.log("Not adding "+n.title+" to popup for offer "+o.offer.id+" because it's out of stock and hide out of stock products is enabled.")),n&&h.inCart(n.productId)&&o.offer.hideProductsAlreadyInCart&&(n=!1,p.log("Not adding "+n.title+" to popup for offer "+o.offer.id+" because it's in the cart and hide products in cart is enabled.")),n&&(p.log("Adding "+n.title+" to popup for offer "+o.offer.id+"."),o.productsArray.push(n)),o.productsArray.length===o.maxNumberOfProducts?o.callback(o.productsArray):e<o.productHandles.length-1?(e+=1,o.ajaxCallToGetProduct(e)):o.productsArray.length<o.maxNumberOfProducts&&e===o.productHandles.length-1&&o.getProductsFromSelectedCollections()},c=function(){o.collectionHandles.length>0?(p.log("Getting upsell products from upsell collections for offer "+o.offer.id),o.ajaxCallToGetCollection(0)):o.callback(this.productsArray)},u=function(e){var n=o.collectionHandles[e];o.inCollectionCache(n.shopify_collection_id)?o.processCollectionData(o.getCachedCollection(n.shopify_collection_id),e):t.ajax({cache:!0,type:"GET",url:"https://"+o.shopifyDomain+"/collections/"+n.handle+"?view=upsell-now-collection",success:function(t){o.setCachedCollection(t,n.shopify_collection_id),o.processCollectionData(t,e)}})},s=function(e,n){e=JSON.parse(e);var i=0;t.each(e,function(t,e){if(!o.inProductsArray(e)&&o.productsArray.length<o.maxNumberOfProducts&&i<o.maxNumberOfProductsPerCollection){var n=o.createNewProduct(e);n&&p.outOfStock(n)&&o.offer.hideOutOfStockProducts&&(n=!1,p.log("Not adding "+n.title+" to popup for offer "+o.offer.id+" because it's out of stock and hide out of stock products is enabled.")),n&&h.inCart(n)&&o.offer.hideProductsAlreadyInCart&&(n=!1,p.log("Not adding "+n.title+" to popup for offer "+o.offer.id+" because it's in the cart and hide products in cart is enabled.")),n&&(p.log("Adding "+n.title+" to popup for offer "+o.offer.id+"."),o.productsArray.push(n),i+=1)}});var r=o.productsArray.length===o.maxNumberOfProducts,a=n===o.collectionHandles.length-1,c=n<o.collectionHandles.length-1;r||a?o.callback(o.productsArray):c&&u(n+=1)},l=function(e){var n=!1;return t.each(o.productsArray,function(t,o){e.handle===o.handle&&(n=!0)}),n},d=function(t){if(!1===t)return!1;var e={};return e.title=t.title,e.originalPrice=t.original_price,e.price=t.price,e.variantId=t.variant_id,e.inventoryQuantity=t.inventory_quantity,e.inventoryManagement=t.inventory_management,e.inventoryPolicy=t.inventory_policy,e.productId=t.id,e.available=t.available,e.handle=t.handle,e.variants=f(t.variants),null!=t.img?"wld-pch.myshopify.com"===p.getShopifyDomain()?e.imgSrc=t.img.replace("_100x100","_400x"):e.imgSrc=t.img:e.imgSrc=!1,e},f=function(e){var n=[];return t.each(e,function(t,e){var o={};o.originalPrice=e.original_price,o.price=e.price,o.title=e.variant_title,o.id=e.variant_id,o.inventoryQuantity=e.inventory_quantity,o.inventoryPolicy=e.inventory_policy,o.inventoryManagement=e.inventory_management,o.available=e.available,n.push(o)}),n},_=function(t){return"undefined"!=typeof window.un.cache.collections[t]},g=function(t){return window.un.cache.collections[t]},m=function(t,e){p.objectChecker(window.un.cache)&&p.objectChecker(window.un.cache.collections)&&(window.un.cache.collections[e]=t)},y=function(t){return"undefined"!=typeof window.un.cache.products[t]},v=function(t){return window.un.cache.products[t]},b=function(t,e){p.objectChecker(window.un.cache)&&p.objectChecker(window.un.cache.products)&&(window.un.cache.products[e]=t)};this.getProducts=i,this.ajaxCallToGetProduct=r,this.processProductData=a,this.getProductsFromSelectedCollections=c,this.ajaxCallToGetCollection=u,this.processCollectionData=s,this.createNewProduct=d,this.inProductsArray=l,this.createVariantArray=f,this.inCollectionCache=_,this.getCachedCollection=g,this.setCachedCollection=m,this.inProductCache=y,this.getCachedProduct=v,this.setCachedProduct=b,this.callback=e,this.offer=n}function c(e){var n=this,o=function(){var t="checkout"===n.triggerEvent||p.onProductPage(),e=n.withinStartEndDate(),o=!n.disabledForCustomers();return!t&&p.log("Offer "+n.id+" not qualified because is ATC and we're not on a product page."),!e&&p.log("Offer "+n.id+" not qualified because outside start/end date."),!o&&p.log("Offer "+n.id+" not qualified because customer is logged in and offer disabled for logged-in customers."),t&&e&&o},i=function(){return n.disableForLoggedInCustomers&&p.objectChecker(window.un.customer_id)},r=function(){return!n.beforeStartDate()&&!n.afterEndDate()},c=function(){if(p.stringChecker(n.startDate)){var t=new Date(n.startDate);return new Date<t}return!1},u=function(){if(p.stringChecker(n.endDate)){var t=new Date(n.endDate);return new Date>t}return!1},s=function(){var t=h.cloneWithCurrentProductPageVariantAsLineItem(),e=n.checkIfTriggerProductsInCart(t),o=n.checkIfRequiredCartValueMet(t),i=n.checkIfOnSelectedProductPage(),r="Upsell offer reqs failed because:";return!e&&(r+=" trigger products not in card,"),!o&&(r+=" required cart value not met,"),!i&&(r+=" not on selected product page,"),"Upsell offer reqs failed because:"!==r&&p.log(r),e&&i&&o},l=function(t){p.objectChecker(t)||(t=h.cloneUnCart());var e=0;"undefined"!=typeof t.un_total_discount&&(Number.isNaN(t.un_total_discount)||(e=t.un_total_discount));var o=n.requiredMinimumCartValue<=t.total_price-e;return message=o?"Required cart value met: "+n.requiredMinimumCartValue+" <= "+(t.total_price-e):"Required cart value not met: "+n.requiredMinimumCartValue+" > "+(t.total_price-e),p.log(message),o},d=function(){var t=!1;if("checkout"===n.triggerEvent||p.onCartPage())t=!0;else if(0===n.productPages.length&&0===n.collectionPages.length)t=!0;else if(p.objectChecker(un.product)&&p.objectChecker(un.product_collections)){var e={};e.product_id=un.product.id,e.collection_ids=un.product_collections,t=n.itemInProductArray(e,n.productPages)||n.itemInCollectionArray(e,n.collectionPages)}return t},_=function(e){p.objectChecker(e)||(e=h.cloneUnCart());var o=!1;return 0===n.triggerProducts.length&&0===n.triggerCollections.length?o=!0:t.each(e.items,function(t,e){e.quantity>=n.triggerQty&&(m(e,n.triggerProducts)||y(e,n.triggerCollections))&&(o=!0)}),o},g=function(t){return n.itemInProductArray(t,n.upsellProducts)||n.itemInCollectionArray(t,n.upsellCollections)},m=function(e,n){var o=!1;return t.each(n,function(t,n){e.product_id===n.shopify_product_id&&(o=!0)}),o},y=function(e,n){var o=!1;return t.each(e.collection_ids,function(e,i){t.each(n,function(t,e){i===e.shopify_collection_id&&(o=!0)})}),o},v=function(){var e=[],o={};if("percentage_discount"===n.discountType)o[f.line_item_message_key]=f.line_item_discount_amount_message.replace("{{discount_amount}}",p.unFormatPercent(n.discountPercent/100)),e.push(o);else if("fixed_amount_discount"===n.discountType){var i=t("<div/>").html(p.unFormatCents(n.discountFixedAmount,f.money_format)).text();o[f.line_item_message_key]=f.line_item_discount_amount_message.replace("{{discount_amount}}",i),e.push(o)}else if("set_price"===n.discountType){var r=t("<div/>").html(p.unFormatCents(n.discountPrice,f.money_format)).text();o[f.line_item_message_key]=f.line_item_set_price_message.replace("{{set_price}}",r),e.push(o)}return e},b=function(t){n.productsForPopup=t},C=function(){n.productGetter.getProducts(n.upsellProducts,n.upsellCollections,f.max_products_to_show,f.max_products_per_category_to_show,p.getPrimaryDomain())},k=function(){var t=!0;return!0===f.hide_offer_if_already_declined&&""!==n.getCookie("_un_closed_offer_"+n.id.toString())&&(t=!1),t},w=function(t){for(var e=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){for(var i=n[o];" "==i.charAt(0);)i=i.substring(1);if(0==i.indexOf(e))return i.substring(e.length,i.length)}return""},P=function(){return n.productsForPopup.length>0},I=function(e,o){var i=!1;return t.each(n.productsForPopup,function(n,r){r.productId===e&&t.each(r.variants,function(t,e){e.id===o&&(i=e)})}),i};this.upsellProducts=e.upsell_products||[],this.upsellCollections=e.upsell_collections||[],this.triggerProducts=e.trigger_products||[],this.triggerCollections=e.trigger_collections||[],this.productPages=e.product_pages||[],this.collectionPages=e.collection_pages||[],this.id=e.id,this.offerEnabled=e.offer_enabled||!1,this.productLinksEnabled=e.product_links_enabled||!1,this.offerName=e.offer_name||"",this.discountType=e.discount_type||0,this.discountFixedAmount=e.discount_fixed_amount||"",this.discountPrice=e.discount_price||"",this.discountPercent=e.discount_percent||"",this.triggerEvent=e.trigger_event||"",this.popupTitle=e.popup_title||"",this.popupDescription=e.popup_description||"",this.popupSuccessMessage=e.popup_success_message||"",this.startDate=e.start_date||"",this.endDate=e.end_date||"",this.disableForLoggedInCustomers=e.disable_for_logged_in_customers||!1,this.upsellQty=e.upsell_qty||1,this.triggerQty=e.trigger_qty||0,this.requiredMinimumCartValue=e.required_minimum_cart_value||0,this.productsForPopup=[],this.hideOutOfStockProducts=e.hide_out_of_stock_products||!1,this.hideProductsAlreadyInCart=e.hide_products_already_in_cart||!1,this.showQuantityField=e.show_quantity_field||!1,this.showVariantField=e.show_variant_field,this.closePopupOnATC=e.close_popup_on_atc||!1,this.productImageSetting=e.product_image_setting||"show_product_image",this.storeProductsCallback=b,this.triggerProductRequirementsMet=s,this.appliesToItem=g,this.getLineItemDiscountPropertyArray=v,this.getProductsForPopup=C,this.itemInProductArray=m,this.itemInCollectionArray=y,this.checkIfTriggerProductsInCart=_,this.checkIfOnSelectedProductPage=d,this.notDeclined=k,this.getCookie=w,this.beforeStartDate=c,this.afterEndDate=u,this.withinStartEndDate=r,this.disabledForCustomers=i,this.baseRequirementsMet=o,this.checkIfRequiredCartValueMet=l,this.hasEligibleUpsellProductsToShow=P,this.getPopupProductVariantData=I,this.baseRequirementsMet()&&this.notDeclined()?(p.log("Loading products for offer: "+this.id),this.productGetter=new a(n.storeProductsCallback,n),this.getProductsForPopup()):p.log("Requirements check failed. Not loading products for offer: "+this.id)}function u(){c.createOfferObjects()&&(s(),p.onProductPage()&&l(),h.updateCart(d))}function s(){t.getScript("https://cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js"),f.hide_express_checkout_buttons&&t("head").append('<style type="text/css">.additional-checkout-button,.google-wallet-button-holder,.amazon-payments-pay-button,.shopify-payment-button{\ndisplay:none !important;\n}</style>')}function l(){t.each(window.un.offers,function(t,e){"add_to_cart"===e.triggerEvent&&e.baseRequirementsMet()&&window.un.qualifyingATCOffers.push(e)}),window.un.qualifyingATCOffers.length>0&&c.createATCEventListener()}function d(){t.each(window.un.offers,function(t,e){"checkout"===e.triggerEvent&&e.baseRequirementsMet()&&window.un.qualifyingCheckoutOffers.push(e)}),c.createCheckoutEventListener();var e=new o(window.un.offers);e.applyOfferDiscountsToCart(),new n(window.un.offers).startBundleEnforcer(),f.ajax_cart_integration_enabled&&e.initAjaxCartObserver()}var p=new e,f=p.getShopInDatastore(),h=new i,_="_un_discounted_line_item_original_product_link_perm_",g="_un_discounted_line_item_original_product_link_temp_",m=".btn-link, .remove, form a:contains(emove), .cart__remove a, .cart-drawer__item-delete, [data-cart-item-delete], .un-remove-btn";i.checkoutEventHandler=function(){p.stringChecker(f.redirecting_to_checkout_text)&&t(f.checkout_button_selector).after("<span id='un-checkout-redirect-msg'>"+f.redirecting_to_checkout_text+"</span>"),h.updateCart(function(){if(new o(window.un.offers).applyOfferDiscountsToCart(),new n(window.un.offers).startBundleEnforcer(),window.un.cartCheckedForDiscounts=!0,p.notInDebugMode())if(h.hasDiscounts()||"asoflattetest.myshopify.com"===p.getShopifyDomain()){var e=h.createDraftOrder();h.getAndSendToCheckoutUrl(e)}else"the-screen-surgery.myshopify.com"===p.getShopifyDomain()?window.location.href="/checkout":t(f.checkout_button_selector).trigger("click")})},c.createOfferObjects=function(){return window.un.offers=[],window.un.qualifyingATCOffers=[],window.un.qualifyingCheckoutOffers=[],t.each(p.getOffersInDatastore(),function(t,e){!0===e.offer_enabled?window.un.offers.push(new c(e)):p.log("One offer disabled - not creating offer object for it")}),p.arrayChecker(window.un.offers)},c.removeOtherATCEventListeners=function(){if(f.remove_add_to_cart_event_listeners){var e=t(f.add_to_cart_button_selector).clone();p.cloneStyles(t(f.add_to_cart_button_selector),e),t(f.add_to_cart_button_selector).replaceWith(e.attr("id","").attr("data-action","").attr("class","").addClass("un-cloned-atc-btn"))}},c.createATCEventListener=function(){c.removeThemeSpecificATCEventListeners(),c.removeOtherATCEventListeners(),0===t(f.add_to_cart_button_selector).length&&(p.log("WARNING: Add to cart button selector does not match any elements on page."),p.log(f.add_to_cart_button_selector)),p.notInDebugMode()||(console.log("UN found these add to cart buttons for selector: "+f.add_to_cart_button_selector),console.log(t(f.add_to_cart_button_selector))),t(document).on("click",f.add_to_cart_button_selector,function(){if("undefined"==typeof un.atcPopupClosed)return p.log("ATC event triggered"),c.atcEventHandler(),!1})},c.removeThemeSpecificATCEventListeners=function(){t.each(t(".product-single__meta .product-form #AddToCart"),function(e,n){t(n).replaceWith(t(n).clone().addClass("un-cloned-atc-btn"))})},c.createCheckoutEventListener=function(){0===t(f.checkout_button_selector).length&&(p.log("WARNING: Checkout button selector does not match any elements on page."),p.log(f.checkout_button_selector)),p.notInDebugMode()||(console.log("UN found these checkout buttons for selector: "+f.checkout_button_selector),console.log(t(f.checkout_button_selector))),t(document).on("click",f.checkout_button_selector,function(){if("undefined"==typeof un.checkingOut&&(p.log("Checkout event triggered"),un.checkingOut=!0,p.enableSpinner(f.checkout_button_selector),p.applyDisabledStyles(f.checkout_button_selector),t(f.checkout_button_selector).addClass("un-disabled-btn"),"undefined"==typeof un.checkoutPopupClosed))return c.checkoutEventHandler(),!1})},c.atcEventHandler=function(){var e=c.getFirstActiveOffer(window.un.qualifyingATCOffers);e?(p.log("Showing ATC popup for offer "+e.id),new r(e).show()):p.notInDebugMode()&&(window.un.atcPopupClosed||(window.un.atcPopupClosed=!0,"omorose-natural-products.myshopify.com"!==p.getShopifyDomain()&&"roadgods-dev.myshopify.com"!==p.getShopifyDomain()&&t(f.add_to_cart_button_selector).trigger("click")))},c.checkoutEventHandler=function(){var t=c.getFirstActiveOffer(window.un.qualifyingCheckoutOffers);t?(p.log("Showing checkout popup for offer "+t.id),new r(t).show()):p.notInDebugMode()&&(window.un.checkoutPopupClosed=!0,i.checkoutEventHandler())},c.getFirstActiveOffer=function(e){var n=!1;return t.each(e,function(t,e){p.log("Examining offer "+e.id+" ("+e.triggerEvent+").");var o=e.triggerProductRequirementsMet(),i=e.notDeclined(),r=e.hasEligibleUpsellProductsToShow();if(o&&i&&r)return n=e,p.log("Offer "+e.id+" passed."),!1;var a="Offer "+e.id+" failed because:";!o&&(a+=" upsell offer reqs not met,"),!i&&(a+=" offer has been previously declined,"),!r&&(a+=" no eligible upsell products to show in popup,"),p.log(a)}),n?p.log("Returning offer "+n.id.toString()):p.log("No valid offers"),n},c.getOfferForItem=function(e,n){var o=!1;return t.each(n,function(t,n){n.triggerProductRequirementsMet()&&n.appliesToItem(e)&&(o=n)}),o},c.getActiveOfferById=function(e){var n=!1;return t.each(un.offers,function(t,o){o.id.toString()===e.toString()&&(n=o)}),n},t(document).ready(function(){p.objectChecker(window.un)&&"undefined"==typeof window.un.running&&(window.un.running=!0,p.checkSettingsInDatastore()&&(p.mergeThemeAndShopSettings(),p.enabledOnCurrentPage()&&u()))})};"undefined"==typeof jQuery||"undefined"==typeof jQuery.fn||"undefined"==typeof jQuery.fn.jquery||parseFloat(jQuery.fn.jquery)<1.7?loadScript("//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js",function(){var t=jQuery.noConflict(!0);myFrontendJavascriptUN(t)}):myFrontendJavascriptUN(jQuery);