function loadScript(src){return new Promise((resolve,reject)=>{const s=document.createElement("script");s.src=src,s.onload=resolve,s.onerror=reject,document.body.appendChild(s)})}if(!customElements.get("cart-drawer-disclosure")){class CartDrawerDisclosure extends DetailsDisclosure{constructor(){super(),this.openBtn=this.querySelector("summary"),this.closeBtn=this.querySelector(".js-close"),this.overlay=document.getElementById("cart-drawer").querySelector(".overlay")}handleClick(evt){evt.target.matches(".js-close")&&this.close()}open(){this.overlay.classList.add("is-visible"),super.open(),trapFocus(this),this.clickHandler=this.clickHandler||this.handleClick.bind(this),this.keyupHandler=evt=>evt.key==="Escape"&&this.close(),this.addEventListener("click",this.clickHandler),this.addEventListener("keyup",this.keyupHandler),this.overlay.addEventListener("click",this.clickHandler)}close(){this.overlay.classList.remove("is-visible"),super.close(),removeTrapFocus(this.openBtn),this.removeEventListener("click",this.clickHandler),this.removeEventListener("keyup",this.keyupHandler),this.overlay.removeEventListener("click",this.clickHandler)}}customElements.define("cart-drawer-disclosure",CartDrawerDisclosure)}if(!customElements.get("cart-drawer")){class CartDrawer extends SideDrawer{constructor(){super(),this.init(),this.bindEvents()}disconnectedCallback(){document.removeEventListener("dispatch:cart-drawer:refresh",this.cartRefreshHandler),document.removeEventListener("dispatch:cart-drawer:open",this.openDrawerViaEventHandler),document.removeEventListener("dispatch:cart-drawer:close",this.closeDrawerViaEventHandler),Shopify.designMode&&(document.removeEventListener("shopify:section:select",this.sectionSelectHandler),document.removeEventListener("shopify:section:deselect",this.sectionDeselectHandler))}init(){const cartIcon=document.getElementById("cart-icon");cartIcon&&(cartIcon.setAttribute("role","button"),cartIcon.setAttribute("aria-haspopup","dialog"),cartIcon.addEventListener("click",evt=>{evt.preventDefault(),this.open(cartIcon)}),cartIcon.addEventListener("keydown",evt=>{evt.key===" "&&(evt.preventDefault(),this.open(cartIcon))}))}bindEvents(){Shopify.designMode&&(this.sectionSelectHandler=this.handleSectionSelect.bind(this),this.sectionDeselectHandler=this.handleSectionDeselect.bind(this),document.addEventListener("shopify:section:select",this.sectionSelectHandler),document.addEventListener("shopify:section:deselect",this.sectionDeselectHandler)),this.openDrawerViaEventHandler=this.handleDrawerOpenViaEvent.bind(this),this.closeDrawerViaEventHandler=this.close.bind(this,null),document.addEventListener("dispatch:cart-drawer:open",this.openDrawerViaEventHandler),document.addEventListener("dispatch:cart-drawer:close",this.closeDrawerViaEventHandler)}handleSectionSelect(evt){evt.target===this.closest(".shopify-section")&&this.open()}handleSectionDeselect(evt){evt.target===this.closest(".shopify-section")&&this.close()}handleDrawerOpenViaEvent(evt){this.open(evt.detail?evt.detail.opener:null)}open(opener,elementToFocus,callback){const quickAddDrawer=document.querySelector('quick-add-drawer[aria-hidden="false"]'),overlay=document.querySelector(".js-overlay.is-visible");quickAddDrawer&&(overlay&&(overlay.style.transitionDelay="200ms"),quickAddDrawer.close()),setTimeout(()=>{super.open(opener,elementToFocus,callback),overlay&&(overlay.style.transitionDelay="")},quickAddDrawer?200:0)}async renderContents(data,openDrawer=!0){this.scriptsLoaded||(document.querySelector(`script[src="${theme.scripts.cartItems}"]`)||await loadScript(theme.scripts.cartItems),!document.querySelector(`script[src="${theme.scripts.shippingCalculator}"]`)&&this.dataset.shippingCalculator&&(await loadScript(theme.scripts.countryProvinceSelector),await loadScript(theme.scripts.shippingCalculator)),this.scriptsLoaded=!0),this.getSectionsToRender().forEach(section=>{const el=document.getElementById(section.id);el&&(el.innerHTML=CartDrawer.getElementHTML(data.sections[section.section],section.selector))}),openDrawer&&this.getAttribute("open")===null&&setTimeout(()=>this.open())}getSectionsToRender(){return[{id:"cart-drawer",section:this.closest(".shopify-section").id.replace("shopify-section-",""),selector:"cart-drawer"},{id:"cart-icon-bubble",section:"cart-icon-bubble",selector:".shopify-section"}]}static getElementHTML(html,selector){const tmpl=document.createElement("template");return tmpl.innerHTML=html,tmpl.content.querySelector(selector).innerHTML}}customElements.define("cart-drawer",CartDrawer)} //# sourceMappingURL=/cdn/shop/t/15/assets/cart-drawer.js.map?v=91247615818806992981710950269