1function updateItemCount(){if(window.Rebuy.SmartCart.cart){const itemCount=window.Rebuy.SmartCart.cart.item_count?window.Rebuy.SmartCart.cart.item_count:"";document.querySelector(".rebuy-cart__flyout-header .rebuy-cart-count")&&(document.querySelector(".rebuy-cart__flyout-header .rebuy-cart-count").innerHTML=`(${itemCount})`),document.querySelector("[data-cart-item-count]")&&(document.querySelector("[data-cart-item-count]").innerHTML=`${itemCount}`)}}document.addEventListener("rebuy:cart.ready",async event=>{const cart=event.detail.cart;let logoContainer=document.querySelector("#payment-logos");if(!logoContainer){logoContainer=document.createElement("div"),logoContainer.setAttribute("id","payment-logos"),logoContainer.classList.add("payment-logos");const html=document.querySelector(".footer-group .payment-types").innerHTML;logoContainer.innerHTML=html;const cartFooter=document.querySelector(".rebuy-cart__flyout-footer");cartFooter&&cartFooter.appendChild(logoContainer)}await updateSmartCartLanguage(),setTimeout(updateRemaining,0),setTimeout(()=>{updateItemCount()},500)}),document.addEventListener("rebuy:cart.change",event=>{setTimeout(()=>{updateItemCount(),updatePrices(event)},500)});async function updatePrices(event){const blocks=document.querySelector("#rebuy-cart [data-smartcart-items]"),products=event.detail.cart.cart.items;let total_discount=0;total_discount=event.detail.cart.cart.total_discount;let index=0;if(blocks!=null){const variants=await getVariants();[...products].map(product=>{const listItem=blocks.querySelector(`li[data-variant="${product.variant_id}"]`),price=listItem.getAttribute("data-price"),compare_at=variants.data.filter(variant=>variant.id==listItem.getAttribute("data-variant"))[0].compare_at_price;compare_at!=null&&compare_at!=0&&(total_discount=total_discount+Math.abs(compare_at-price)*listItem.getAttribute("data-quantity"));let discount="";price<compare_at&&(discount=Math.round((compare_at-price)/compare_at*100)),listItem.querySelector(".tags .discount.active")&&(listItem.querySelector(".tags .discount").innerText=`${discount}% OFF`),index++})}}async function getSubTitle(item){const response=await fetch(`${window.Shopify.routes.root}products/${item.handle}?view=subtitle`),data=await response.json();return{response,data}}async function getVariants(handle){const response=await fetch(`${window.Shopify.routes.root}cart?view=items`),data=await response.json();return{response,data}}document.addEventListener("rebuy:smartcart.ready",event=>{window.Rebuy.SmartCart.itemObject=function(item){return object=JSON.stringify(item),object},window.Rebuy.SmartCart.discountFlag=function(item){let discount="",classes="",multiplier=Shopify.currency.active=="EUR"?1:100;const compare_at=window.Rebuy.SmartCart.compareAtPrice(item)*multiplier,price=window.Rebuy.SmartCart.itemPrice(item);return price<compare_at&&(discount=Math.round((compare_at-price)/compare_at*100)+"% OFF",classes="active"),classes},window.Rebuy.SmartCart.customSubTitle=function(item){let tags=window.Rebuy.SmartCart.itemProductTagsClasses(item),subTitle="";return tags=tags.match(/tag-subtitle_([\w'-]+)/),tags&&(subTitle=tags[0].replace("tag-subtitle_",""),subTitle=subTitle.replace("-"," ")),subTitle},window.Rebuy.SmartCart.showDiscountTotal=function(){return window.Rebuy.SmartCart.cart.total_discount>0},window.Rebuy.SmartCart.customDiscountTotal=function(){return`-${window.Rebuy.SmartCart.formatMoney(window.Rebuy.SmartCart.cart.total_discount,window.theme.moneyFormat)}`},window.Rebuy.SmartCart.subtotal=function(){return window.Rebuy.SmartCart.formatMoney(window.Rebuy.SmartCart.cart.total_price,window.theme.moneyFormat)}});function addSubTitles(){[...document.querySelectorAll(".rebuy-product-block")].map(block=>{let tags=block.classList.toString().match(/tag-subtitle_([\w'-]+)/),subTitle="";tags&&(subTitle=tags[0].replace("tag-subtitle_",""),subTitle=subTitle.replace("-"," ")),block.querySelector(".subtitle")&&(block.querySelector(".subtitle").innerHTML=subTitle)})}function decodeString(str){var parser=new DOMParser,dom=parser.parseFromString("<!doctype html><body>"+str,"text/html");return dom.body.textContent}function setWidgetTitle(){const lang=JSON.parse(rebuyLang);lang.minicart_recommendations.title&&document.querySelector(".rebuy-cart__flyout-recommendations .rebuy-widget .primary-title")&&(document.querySelector(".rebuy-cart__flyout-recommendations .rebuy-widget .primary-title").innerHTML=decodeString(lang.minicart_recommendations.title)),lang.pdp_bundle.title&&document.querySelector("#rebuy-widget-149274 .primary-title")&&(document.querySelector("#rebuy-widget-149274 .primary-title").innerHTML=decodeString(lang.pdp_bundle.title))}function addBundle(event){console.log("add bundle"),console.log("event: ",event),console.log("event.detail.widget.id: ",event.detail.widget.id)}document.addEventListener("rebuy.ready",function(event){addSubTitles(),setWidgetTitle()}),document.addEventListener("rebuy.add",function(event){addSubTitles()}),document.addEventListener("rebuy.ready",event=>{const widget=event.detail.widget;
1updateWidgetLanguage(widget)}),updateSmartCartLanguage=async function(){const locale=Shopify?.locale,translation=translations[locale]?.smart_cart;locale&&translation&&(Object.assign(Rebuy.SmartCart.settings.language,translation),translations[locale]?.announcement_bar&&Object.assign(Rebuy.SmartCart.settings.announcement_bar,translations[locale].announcement_bar))},updateWidgetLanguage=widget=>{const locale=Shopify?.locale,widgetTranslation=translations[locale]?.[widget.id],globalTranslation=translations[locale]?.widget;locale&&widgetTranslation?(Object.assign(widget.data.settings.language,widgetTranslation),widget.compileConfig()):locale&&globalTranslation&&(Object.assign(widget.data.settings.language,globalTranslation),widget.compileConfig())},updateRemaining=()=>{const locale=Shopify?.locale;if(translations[locale]){const remainingAmount=document.querySelector(".rebuy-cart__flyout-subtotal-label .item-count");remainingAmount&&(remainingAmount.innerHTML=Rebuy.Cart.cart.item_count);const tiers=Rebuy.SmartCart?.settings?.buy_more_save_more?.tiers;tiers&&tiers.forEach((tier,index)=>{document.querySelectorAll(".rebuy-cart__flyout-item-buy-more-save-more-button").length>0&&(document.querySelectorAll(".rebuy-cart__flyout-item-buy-more-save-more-button .bmsm-discount")[index].innerHTML=tier.discount+"%",document.querySelectorAll(".rebuy-cart__flyout-item-buy-more-save-more-button .bmsm-quantity")[index].innerHTML=tier.quantity)});const bar=Rebuy.SmartCart.getCurrentTier(Rebuy.SmartCart?.progressBar),barEl=document.getElementById("rebuy-cart__progress-bar-meter-label"),helperShipping=barEl.querySelector(".helper-shipping"),helperProduct=barEl.querySelector(".helper-product");bar&&barEl&&(bar.type==="shipping"?(helperShipping||(barEl.innerHTML=translations[locale]?.smart_cart?.free_shipping_remaining),barEl.querySelector(".helper-shipping").innerHTML=Rebuy.util.formatMoney(-Math.round(-bar.minimum*100)-Rebuy.SmartCart.shippingExcludedSubtotal())):(helperProduct||(barEl.innerHTML=translations[locale]?.smart_cart?.free_product_tier_remaining),barEl.querySelector(".helper-amount").innerHTML=Rebuy.util.formatMoney(-Math.round(-bar.minimum*100)-Rebuy.SmartCart.shippingExcludedSubtotal()),barEl.querySelector(".helper-product").innerHTML=bar.products[0].title??"Free Product"))}}; 2//# sourceMappingURL=/cdn/shop/t/363/assets/rebuy-custom.js.map?v=23381219069010254171764089843
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.