1(function(){"use strict";const BrogloPdpBundle={state:{},init(sectionId){const data=window.brogloPdpBundleData?.[sectionId];if(!data)return;const initialShade=data.variants.find(v=>v.id===data.currentVariantId)?.handle||"original";this.state[sectionId]={data,currentVariantId:data.currentVariantId,currentShade:initialShade,currentSlide:0,crossSellChecked:!1},this.initGallery(sectionId),this.filterGalleryByVariant(sectionId,initialShade),this.initStickyAtc(sectionId),this.initUrgencyCycle(sectionId),this.initTickerCycle(sectionId),this.updateBundleItemsAvailability(sectionId,initialShade),this.updatePricing(sectionId);const urlVariantId=parseInt(new URLSearchParams(window.location.search).get("variant"));if(urlVariantId&&urlVariantId!==data.currentVariantId){const urlVariant=data.variants.find(v=>v.id===urlVariantId);if(urlVariant){const btn=document.querySelector(`#BrogloPdp-${sectionId} .broglo-pdp__shade-btn[data-shade="${urlVariant.handle}"]`);btn&&this.selectShade(sectionId,btn)}}},selectShade(sectionId,btn){const st=this.state[sectionId];if(!st)return;const shade=btn.dataset.shade,variantId=parseInt(btn.dataset.variantId);st.currentShade=shade,st.currentVariantId=variantId;const container=document.getElementById(`brogloPdpShades-${sectionId}`);container&&(container.querySelectorAll(".broglo-pdp__shade-btn").forEach(b=>{b.classList.remove("active"),b.setAttribute("aria-pressed","false")}),btn.classList.add("active"),btn.setAttribute("aria-pressed","true"));const section=document.getElementById(`BrogloPdp-${sectionId}`);section&&(section.dataset.shade=shade);const badge=document.getElementById(`brogloPdpBadgeLeft-${sectionId}`);badge&&(badge.textContent=btn.querySelector(".broglo-pdp__shade-name")?.textContent||shade),this.filterGalleryByVariant(sectionId,shade),this.updateInsideImages(sectionId,shade),this.updateBundleItemsAvailability(sectionId,shade),this.updatePricing(sectionId);const variant=st.data.variants.find(v=>v.id===variantId),stickyName=document.getElementById(`brogloPdpStickyName-${sectionId}`);stickyName&&(stickyName.textContent=`${st.data.productTitle} \u2014 ${variant?.title||shade}`);const url=new URL(window.location);url.searchParams.set("variant",variantId),history.replaceState(null,"",url),this.announce(sectionId,`${shade} shade selected`)},updatePricing(sectionId){const st=this.state[sectionId];if(!st)return;const variant=st.data.variants.find(v=>v.id===st.currentVariantId);if(!variant)return;const bundlePrice=variant.price,comparePrice=variant.compareAtPrice||0,saleNow=!!(window.BrogloSale&&window.BrogloSale.active),crossSellPrice=st.crossSellChecked?saleNow?st.data.crossSell?.originalPrice||st.data.crossSell?.price||0:st.data.crossSell?.price||0:0,totalPrice=bundlePrice+crossSellPrice,fmt=this.formatMoney,priceEl=document.getElementById(`brogloPdpPrice-${sectionId}`);priceEl&&(priceEl.textContent=fmt(totalPrice));const compareEl=document.getElementById(`brogloPdpCompare-${sectionId}`);if(compareEl){const totalCompare=comparePrice+crossSellPrice;comparePrice>bundlePrice?(compareEl.textContent=fmt(totalCompare),compareEl.classList.add("visible"),compareEl.style.display=""):(compareEl.classList.remove("visible"),compareEl.style.display="none")}const savingsEl=document.getElementById(`brogloPdpSaveBadge-${sectionId}`);if(savingsEl)if(comparePrice>bundlePrice){const savings=comparePrice-bundlePrice,pct=Math.round(savings/comparePrice*100);savingsEl.textContent=`Save ${fmt(savings)} (${pct}%)`,savingsEl.style.display=""}else savingsEl.style.display="none";const purchasable=variant.available&&st.bundleItemsAvailable!==!1,atcBtn=document.getElementById(`brogloPdpAtcBtn-${sectionId}`),atcPrice=document.getElementById(`brogloPdpAtcPrice-${sectionId}`),atcLabel=document.getElementById(`brogloPdpAtcLabel-${sectionId}`);atcBtn&&(atcBtn.disabled=!purchasable,atcBtn.setAttribute("aria-disabled",purchasable?"false":"true"),atcLabel&&(atcLabel.textContent=purchasable?"Add to Cart":"Sold Out"),atcPrice&&(purchasable?(atcPrice.textContent=` \u2014 ${fmt(totalPrice)}`,atcPrice.style.display=""):atcPrice.style.display="none"));const stickyBtn=document.getElementById(`brogloPdpStickyBtn-${sectionId}`);stickyBtn&&(stickyBtn.disabled=!purchasable,stickyBtn.textContent=purchasable?"Add to Cart":"Sold Out");const stickyPrice=document.getElementById(`brogloPdpStickyPrice-${sectionId}`);stickyPrice&&(stickyPrice.textContent=fmt(totalPrice)),this.updateShippingBar(sectionId,totalPrice)},updateShippingBar(sectionId,totalCents){const threshold=this.state[sectionId]?.data?.freeShipThreshold;if(!threshold)return;const fill=document.getElementById(`brogloPdpShipFill-${sectionId}`),text=document.getElementById(`brogloPdpShipText-${sectionId}`);if(!fill||!text)return;fill.style.width=Math.min(100,Math.round(totalCents/threshold*100))+"%";const remaining=threshold-totalCents;text.innerHTML=remaining<=0?'\u{1F389} <strong style="color:#2D9B5E">You qualify for free shipping!</strong>':`Add <strong>${this.formatMoney(remaining)}</strong> more for free shipping`},updateInsideImages(sectionId,shade){const section=document.getElementById(`BrogloPdp-${sectionId}`);if(!section)return;section.querySelectorAll(".broglo-pdp__inside-img img[data-img-original]").forEach(img=>
1{const src=shade==="darker"&&img.dataset.imgDarker||img.dataset.imgOriginal;src&&img.src!==src&&(img.style.opacity="0",setTimeout(()=>{img.src=src,img.style.opacity="1"},150))})},getAvailableStock(entity){return entity&&entity.inventoryManagement==="shopify"&&entity.inventoryPolicy!=="continue"?entity.inventoryQuantity??0:1/0},updateBundleItemsAvailability(sectionId,shade){const st=this.state[sectionId];if(!st)return;const items=st.data.bundleItems||[],section=document.getElementById(`BrogloPdp-${sectionId}`);let anyOutOfStock=!1;items.forEach(item=>{const variant=shade==="darker"?item.darkerVariant:item.originalVariant,ok=this.getAvailableStock(variant)>=(item.qty||1);if(ok||(anyOutOfStock=!0),!section)return;const row=section.querySelector(`.broglo-pdp__inside-item[data-item-index="${item.index}"]`);row&&row.classList.toggle("broglo-pdp__inside-item--disabled",!ok);const note=section.querySelector(`.broglo-pdp__inside-stock-note[data-item-index="${item.index}"]`);note&&(note.hidden=ok);const checkIcon=row?.querySelector(".broglo-pdp__inside-check svg");checkIcon&&(checkIcon.innerHTML=ok?'<path stroke-linecap="round" stroke-linejoin="round" d="m4.5 12.75 6 6 9-13.5"/>':'<path stroke-linecap="round" stroke-linejoin="round" d="M6 18 18 6M6 6l12 12"/>')}),st.bundleItemsAvailable=!anyOutOfStock},toggleCrossSell(sectionId){const st=this.state[sectionId];if(!st)return;st.crossSellChecked=!st.crossSellChecked;const card=document.getElementById(`brogloPdpCrossSell-${sectionId}`);card&&(card.classList.toggle("selected",st.crossSellChecked),card.setAttribute("aria-checked",st.crossSellChecked)),this.updatePricing(sectionId),this.announce(sectionId,st.crossSellChecked?"Added to order":"Removed from order")},initGallery(sectionId){const slidesEl=document.getElementById(`brogloPdpSlides-${sectionId}`);slidesEl&&window.innerWidth<768&&slidesEl.addEventListener("scroll",()=>{const slides=slidesEl.querySelectorAll(".broglo-pdp__slide"),scrollLeft=slidesEl.scrollLeft;let closest=0,minDist=1/0;slides.forEach((slide,i)=>{if(slide.classList.contains("variant-hidden"))return;const dist=Math.abs(slide.offsetLeft-scrollLeft-slidesEl.offsetWidth*.06);dist<minDist&&(minDist=dist,closest=i)}),this.setSlide(sectionId,closest,!1)},{passive:!0})},setSlide(sectionId,index,scroll){const st=this.state[sectionId];if(!st)return;st.currentSlide=index;const dotsEl=document.getElementById(`brogloPdpDots-${sectionId}`);dotsEl&&dotsEl.querySelectorAll(".broglo-pdp__dot").forEach(dot=>{dot.classList.toggle("active",parseInt(dot.dataset.slide)===index)});const thumbsEl=document.getElementById(`brogloPdpThumbs-${sectionId}`);if(thumbsEl&&thumbsEl.querySelectorAll(".broglo-pdp__thumb").forEach(thumb=>{const isActive=parseInt(thumb.dataset.slide)===index;if(thumb.classList.toggle("active",isActive),isActive&&!thumb.classList.contains("variant-hidden")){const thumbCenter=thumb.offsetLeft-thumbsEl.offsetLeft-thumbsEl.offsetWidth/2+thumb.offsetWidth/2;thumbsEl.scrollTo({left:thumbCenter,behavior:"smooth"})}}),scroll!==!1&&window.innerWidth>=768){const slidesEl=document.getElementById(`brogloPdpSlides-${sectionId}`);if(slidesEl){const allSlides=Array.from(slidesEl.querySelectorAll(".broglo-pdp__slide"));let visibleOffset=0;for(let i=0;i<allSlides.length&&i!==index;i++)allSlides[i].classList.contains("variant-hidden")||visibleOffset++;slidesEl.style.transform=`translateX(-${visibleOffset*100}%)`}}},goToSlide(sectionId,index){if(this.setSlide(sectionId,index,!0),window.innerWidth<768){const slidesEl=document.getElementById(`brogloPdpSlides-${sectionId}`),slide=slidesEl?.querySelectorAll(".broglo-pdp__slide")[index];slide&&slidesEl&&slidesEl.scrollTo({left:slide.offsetLeft-slidesEl.offsetLeft,behavior:"smooth"})}},filterGalleryByVariant(sectionId,shade){const section=document.getElementById(`BrogloPdp-${sectionId}`);if(!section)return;const slides=section.querySelectorAll(".broglo-pdp__slide"),thumbs=section.querySelectorAll(".broglo-pdp__thumb"),dots=section.querySelectorAll(".broglo-pdp__dot");let hasVariantGroups=!1;if(slides.forEach(s=>{s.dataset.variantGroup&&s.dataset.variantGroup!=="shared"&&(hasVariantGroups=!0)}
1),!hasVariantGroups){slides.forEach(s=>s.classList.remove("variant-hidden")),thumbs.forEach(t=>t.classList.remove("variant-hidden")),dots.forEach(d=>d.classList.remove("variant-hidden")),this.goToSlide(sectionId,0),this.updateThumbArrows(sectionId);return}let firstVisibleIndex=null;slides.forEach((slide,i)=>{const group=slide.dataset.variantGroup||"shared",visible=group===shade||group==="shared";slide.classList.toggle("variant-hidden",!visible),visible&&firstVisibleIndex===null&&(firstVisibleIndex=i)}),thumbs.forEach(thumb=>{const group=thumb.dataset.variantGroup||"shared";thumb.classList.toggle("variant-hidden",!(group===shade||group==="shared"))}),dots.forEach(dot=>{const group=dot.dataset.variantGroup||"shared";dot.classList.toggle("variant-hidden",!(group===shade||group==="shared"))}),firstVisibleIndex!==null&&this.goToSlide(sectionId,firstVisibleIndex),this.updateThumbArrows(sectionId)},scrollThumbs(sectionId,direction){const container=document.getElementById(`brogloPdpThumbs-${sectionId}`);container&&(container.scrollBy({left:direction*200,behavior:"smooth"}),setTimeout(()=>this.updateThumbArrows(sectionId),350))},updateThumbArrows(sectionId){const thumbsEl=document.getElementById(`brogloPdpThumbs-${sectionId}`),prevBtn=document.getElementById(`brogloPdpThumbPrev-${sectionId}`),nextBtn=document.getElementById(`brogloPdpThumbNext-${sectionId}`);thumbsEl&&(prevBtn&&(prevBtn.disabled=thumbsEl.scrollLeft<=2),nextBtn&&(nextBtn.disabled=thumbsEl.scrollLeft+thumbsEl.clientWidth>=thumbsEl.scrollWidth-2))},async addToCart(sectionId){const st=this.state[sectionId];if(!st)return;this.updateBundleItemsAvailability(sectionId,st.currentShade),this.updatePricing(sectionId);const btn=document.getElementById(`brogloPdpAtcBtn-${sectionId}`);if(!btn||btn.disabled)return;const originalText=btn.innerHTML;btn.disabled=!0,btn.innerHTML='<span style="opacity:.7">Adding\u2026</span>';try{const items=[{id:st.currentVariantId,quantity:1}];if(st.crossSellChecked&&st.data.crossSell?.variantId){const xsellSaleActive=!!(window.BrogloSale&&window.BrogloSale.active);items.push({id:st.data.crossSell.variantId,quantity:1,properties:xsellSaleActive?{}:{_bundle_addon:"true",_discount_pct:String(st.data.crossSell.discountPct||0)}})}const res=await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({items})});if(!res.ok)throw new Error("Cart add failed");const cartData=await res.json();this.announce(sectionId,`${st.data.productTitle} added to cart`),btn.innerHTML="\u2713 Added to Cart!",btn.style.background="#2D9B5E";const count=cartData.items?.reduce?.((sum,i)=>sum+i.quantity,0);count&&this.updateCartCount(count),setTimeout(()=>this.openCartDrawer(),300),setTimeout(()=>{btn.innerHTML=originalText,btn.disabled=!1,btn.style.background=""},2e3)}catch(err){console.error("BrogloPdpBundle ATC error:",err),btn.innerHTML="Error \u2014 Try Again",btn.disabled=!1,this.announce(sectionId,"Error adding to cart. Please try again."),setTimeout(()=>{btn.innerHTML=originalText,btn.style.background=""},2e3)}},openCartDrawer(){if(window.BWCart?.refresh){BWCart.refresh(!0);return}const headerCart=document.querySelector('.header a[href="/cart"], header a[href*="/cart"], .header__icon--cart');if(headerCart){headerCart.click();return}window.location.href="/cart"},updateCartCount(count){document.querySelectorAll(".cart-count-bubble span, [data-cart-count], .header__cart-count, .cart-count, .js-cart-count").forEach(el=>{el.textContent=count}),document.querySelectorAll(".cart-count-bubble").forEach(el=>{el.style.display=count>0?"":"none"})},initStickyAtc(sectionId){const sticky=document.getElementById(`brogloPdpStickyAtc-${sectionId}`),atcBtn=document.getElementById(`brogloPdpAtcBtn-${sectionId}`);if(!sticky||!atcBtn)return;new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.isIntersecting?sticky.classList.remove("visible"):sticky.classList.toggle("visible",entry.boundingClientRect.top<0)})},{threshold:0}).observe(atcBtn)},initUrgencyCycle(sectionId){const el=document.getElementById(`brogloPdpUrgency-${sectionId}`);if(!el)return;const cfg=this.state[sectionId]?.data?.urgency;
1if(!cfg)return;const storageKey="broglo_urgency_bundle_"+sectionId,today=new Date().toDateString();let saved=null;try{saved=JSON.parse(localStorage.getItem(storageKey))}catch{}let count=saved&&saved.date===today&&saved.count>=cfg.base?Math.min(saved.count,cfg.cap):cfg.base;el.textContent=count+" people bought this today";const scheduleNext=()=>{const interval=cfg.minInterval+Math.random()*(cfg.maxInterval-cfg.minInterval);setTimeout(()=>{const inc=cfg.minIncrement+Math.floor(Math.random()*(cfg.maxIncrement-cfg.minIncrement+1));count=Math.min(count+inc,cfg.cap),el.textContent=count+" people bought this today";try{localStorage.setItem(storageKey,JSON.stringify({date:today,count}))}catch{}count<cfg.cap&&scheduleNext()},interval*1e3)};count<cfg.cap&&scheduleNext()},initTickerCycle(sectionId){const el=document.getElementById(`brogloPdpTicker-${sectionId}`);if(!el)return;const msgs=this.state[sectionId]?.data?.tickerMessages?.filter(m=>m&&m.trim())||[];if(msgs.length<=1)return;let i=0;el.style.transition="opacity 0.3s",setInterval(()=>{i=(i+1)%msgs.length,el.style.opacity="0",setTimeout(()=>{el.innerHTML=msgs[i],el.style.opacity="1"},300)},4e3)},toggleAccordion(trigger){const item=trigger.closest(".broglo-pdp__accordion-item");if(!item)return;const isOpen=item.classList.contains("open"),content=item.querySelector(".broglo-pdp__accordion-content");if(!content)return;const accordion=item.closest(".broglo-pdp__accordion");accordion&&accordion.querySelectorAll(".broglo-pdp__accordion-item.open").forEach(other=>{if(other!==item){other.classList.remove("open");const c=other.querySelector(".broglo-pdp__accordion-content"),t=other.querySelector(".broglo-pdp__accordion-trigger");c&&(c.style.maxHeight="0"),t&&t.setAttribute("aria-expanded","false")}}),isOpen?(item.classList.remove("open"),content.style.maxHeight="0",trigger.setAttribute("aria-expanded","false")):(item.classList.add("open"),content.style.maxHeight=content.scrollHeight+"px",trigger.setAttribute("aria-expanded","true"))},formatMoney(cents){return typeof cents!="number"||isNaN(cents)?"$0.00":"$"+(cents/100).toFixed(2)},announce(sectionId,message){const el=document.getElementById(`brogloPdpSrAnnounce-${sectionId}`);el&&(el.textContent="",requestAnimationFrame(()=>{el.textContent=message}))}};window.BrogloPdpBundle=BrogloPdpBundle;const initAll=()=>{document.querySelectorAll('.broglo-pdp[data-pdp-type="bundle"]').forEach(section=>{const sectionId=section.dataset.sectionId;sectionId&&BrogloPdpBundle.init(sectionId)})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",initAll):initAll(),Shopify?.designMode&&document.addEventListener("shopify:section:load",e=>{const section=e.target.querySelector('.broglo-pdp[data-pdp-type="bundle"]');section&&BrogloPdpBundle.init(section.dataset.sectionId)}),document.addEventListener("click",e=>{const bundleSection=e.target.closest('.broglo-pdp[data-pdp-type="bundle"]');if(!bundleSection)return;const sectionId=bundleSection.dataset.sectionId;if(!sectionId)return;const dot=e.target.closest(".broglo-pdp__dot"),thumb=e.target.closest(".broglo-pdp__thumb"),shadeBtn=e.target.closest(".broglo-pdp__shade-btn"),xsellCard=e.target.closest(".broglo-pdp__xsell-card");dot&&BrogloPdpBundle.goToSlide(sectionId,parseInt(dot.dataset.slide)),thumb&&BrogloPdpBundle.goToSlide(sectionId,parseInt(thumb.dataset.slide)),shadeBtn&&!shadeBtn.classList.contains("active")&&BrogloPdpBundle.selectShade(sectionId,shadeBtn),xsellCard&&BrogloPdpBundle.toggleCrossSell(sectionId)}),document.addEventListener("keydown",e=>{if(e.key!=="Enter"&&e.key!==" ")return;const xsellCard=e.target.closest(".broglo-pdp__xsell-card");if(!xsellCard)return;e.preventDefault();const sectionId=xsellCard.closest('.broglo-pdp[data-pdp-type="bundle"]')?.dataset.sectionId;sectionId&&BrogloPdpBundle.toggleCrossSell(sectionId)})})(); 2//# sourceMappingURL=/cdn/shop/t/86/assets/broglo-pdp-bundle.js.map?v=173227090952198361741786110251
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.