1class CartDrawer extends HTMLElement{constructor(){super(),this.addEventListener("keyup",evt=>evt.code==="Escape"&&this.close()),this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.setHeaderCartIconAccessibility()}connectedCallback(){window.location.hash==="#cart-open"&&this.open()}setHeaderCartIconAccessibility(){const cartLink=document.querySelector("#cart-icon-bubble");cartLink&&(cartLink.setAttribute("role","button"),cartLink.setAttribute("aria-haspopup","dialog"),cartLink.addEventListener("click",event=>{event.preventDefault(),this.open(cartLink)}),cartLink.addEventListener("keydown",event=>{event.code.toUpperCase()==="SPACE"&&(event.preventDefault(),this.open(cartLink))}))}open(triggeredBy){triggeredBy&&this.setActiveElement(triggeredBy);const cartDrawerNote=this.querySelector('[id^="Details-"] summary');cartDrawerNote&&!cartDrawerNote.hasAttribute("role")&&this.setSummaryAccessibility(cartDrawerNote),setTimeout(()=>{this.classList.add("animate","active")}),this.addEventListener("transitionend",()=>{const containerToTrapFocusOn=document.getElementById("CartDrawer"),focusElement=this.querySelector(".drawer__inner")||this.querySelector(".drawer__close");trapFocus(containerToTrapFocusOn,focusElement)},{once:!0}),document.body.classList.add("overflow-hidden"),this.animateCartItems()}animateCartItems(){const items=this.querySelectorAll(".cart-item-card");if(!items.length)return;const duration=Theme.config.motionReduced?0:.3;items.forEach((item,i)=>{Theme.motion.animate(item,{opacity:[0,1],transform:["translateY(10px)","translateY(0)"]},{duration,delay:.15+i*.06,easing:[.25,.1,.25,1]})})}close(){this.classList.remove("active"),removeTrapFocus(this.activeElement),document.body.classList.remove("overflow-hidden")}setSummaryAccessibility(cartDrawerNote){cartDrawerNote.setAttribute("role","button"),cartDrawerNote.setAttribute("aria-expanded","false"),cartDrawerNote.nextElementSibling.getAttribute("id")&&cartDrawerNote.setAttribute("aria-controls",cartDrawerNote.nextElementSibling.id),cartDrawerNote.addEventListener("click",event=>{event.currentTarget.setAttribute("aria-expanded",!event.currentTarget.closest("details").hasAttribute("open"))}),cartDrawerNote.parentElement.addEventListener("keyup",onKeyUpEscape)}renderContents(parsedState){this.classList.remove("is-empty"),this.productId=parsedState.id,parsedState.sections&&this.getSectionsToRender().forEach(section=>{const sectionElement=section.selector?document.querySelector(section.selector):document.getElementById(section.id);if(!sectionElement)return;const html=this.getSectionInnerHTML(parsedState.sections[section.id],section.selector);html&&(sectionElement.innerHTML=html)}),setTimeout(()=>{this.querySelector("#CartDrawer-Overlay").addEventListener("click",this.close.bind(this)),this.open(),this.loadRecommendations()})}getSectionInnerHTML(html,selector=".shopify-section"){if(!html)return"";const el=new DOMParser().parseFromString(html,"text/html").querySelector(selector);return el?el.innerHTML:""}getSectionsToRender(){return[{id:"cart-drawer",selector:"#CartDrawer"},{id:"cart-icon-bubble"}]}getSectionDOM(html,selector=".shopify-section"){return new DOMParser().parseFromString(html,"text/html").querySelector(selector)}setActiveElement(element){this.activeElement=element}loadRecommendations(){const container=this.querySelector(".cart-drawer__upsell[data-recommendations-url]");if(!container)return;const productId=container.dataset.firstProductId,recommendationsUrl=container.dataset.recommendationsUrl;if(!productId||!recommendationsUrl){container.classList.remove("is-visible");return}fetch(`${recommendationsUrl}?product_id=${productId}§ion_id=cart-drawer-recommendations&limit=10`).then(response=>response.text()).then(html=>{const slides=new DOMParser().parseFromString(html,"text/html").querySelectorAll(".swiper-slide");if(!slides.length){container.classList.remove("is-visible");return}const swiperComponent=container.querySelector("swiper-component");if(!swiperComponent)return;const wrapper=swiperComponent.querySelector(".swiper-wrapper");wrapper&&(swiperComponent.swiper&&swiperComponent.swiper.destroy(!0,!0),wrapper.innerHTML="",slides.forEac
1h(slide=>wrapper.appendChild(slide.cloneNode(!0))),typeof swiperComponent.initSwiper=="function"&&swiperComponent.initSwiper(),container.classList.add("is-visible"))}).catch(error=>{container.classList.remove("is-visible"),console.error("Cart drawer recommendations failed:",error)})}}customElements.define("cart-drawer",CartDrawer);class CartDrawerItems extends CartItems{getSectionsToRender(){return[{id:"CartDrawer",section:"cart-drawer",selector:".drawer__inner"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"}]}getSectionInnerHTML(html,selector){if(!html)return"";const el=new DOMParser().parseFromString(html,"text/html").querySelector(selector);return el?el.innerHTML:""}}customElements.define("cart-drawer-items",CartDrawerItems);class CartUpsellCard extends HTMLElement{connectedCallback(){this.hasAttribute("data-link-only")||(this.addBtn=this.querySelector(".cart-upsell-card__add"),this.pills=this.querySelectorAll(".cart-upsell-card__variant-pill"),this.pills.forEach(pill=>pill.addEventListener("click",()=>this.selectVariant(pill))),this.addBtn?.addEventListener("click",()=>this.addToCart()))}selectVariant(pill){if(this.pills.forEach(p=>p.classList.remove("is-active")),pill.classList.add("is-active"),!this.addBtn)return;this.addBtn.dataset.variantId=pill.dataset.variantId;const label=this.addBtn.dataset.addLabel||"ADD - __PRICE__";this.addBtn.textContent=label.replace("__PRICE__",pill.dataset.price)}async addToCart(){const variantId=this.addBtn.dataset.variantId;if(!variantId)return;this.addBtn.disabled=!0,this.addBtn.classList.add("loading");const sections=["cart-drawer","cart-icon-bubble"],body=JSON.stringify({id:parseInt(variantId),quantity:1,sections,sections_url:window.location.pathname});try{const data=await(await fetch(window.Shopify.routes.root+"cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body})).json();if(data.status)throw new Error(data.description);const cartDrawer=document.querySelector("cart-drawer");cartDrawer&&data.sections&&cartDrawer.renderContents({sections:data.sections})}catch(e){console.error(e),this.addBtn.disabled=!1,this.addBtn.classList.remove("loading")}}}customElements.define("cart-upsell-card",CartUpsellCard); 2//# sourceMappingURL=/cdn/shop/t/4/assets/cart-drawer.js.map?v=149124991523818905121776262038
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.