1class PushCartError{static async handle(error){const instance=new this(error);return instance.soldOut?instance.render(instance.MESSAGES.SOLD_OUT):instance.alreadyHaveAllInCart?instance.render(instance.MESSAGES.ALREADY_HAVE_ALL_STOCK):instance.addedMoreThanExists?instance.render(instance.MESSAGES.NOT_ENOUGH_IN_STOCK):instance.cannotFindVariant?instance.render(instance.MESSAGES.CANNOT_FIND_VARIANT):instance.render(instance.MESSAGES.GENERAL)}constructor(error){this.MESSAGES={ADD_TOO_MANY:"Unfortunately, there isn't enough of this product available",ALREADY_HAVE_ALL_STOCK:"You already have all of the remaining stock in your cart",NOT_ENOUGH_IN_STOCK:"Unfortunately, there isn't enough of this product available",SOLD_OUT:"Unfortunately, this product is sold out.",CANNOT_FIND_VARIANT:"There was an error adding this product to cart.",GENERAL:"There was an error adding this product to cart."},this.description=error.description||"",this.status=error.status||"",this.pushCart=window.BAO.Utils.getElement("push-cart")}render(message){const clone=this.pushCart.els["error-template"].element.content.cloneNode(!0),text=window.BAO.Utils.getElement(this.selectors.text,{context:clone});return text.textContent=message,this.pushCart.els.errors.element.appendChild(clone),this}get addedMoreThanExists(){return this.description.slice(0,18)==="You can't add more"}get alreadyHaveAllInCart(){return this.description.slice(0,4)==="All "}get soldOut(){return this.description.slice(0,13)==="The product '"}get cannotFindVariant(){return this.description.toLowerCase()==="cannot find variant"}get selectors(){return{item:"[data-push-cart-errors-item]",text:"[data-push-cart-errors-text]",close:"[data-push-cart-errors-close]"}}}class PushCart extends window.BAO.CustomElement(){static get requiredElements(){return["error-template","errors"]}_loading=!1;get loading(){return this._loading}set loading(val){this._loading=val,this.classList.toggle(this.loadingClass,val)}constructor(){super(),this.setPushCartSections(),this.drawer==null&&this.throwError("needs to be used within a <site-drawer> element"),this.setupListeners()}setPushCartSections(){this.sections=window.BAO.sectionRenderer.pushCartSections}setupListeners(){super.setupListeners(),this.onBeforeCartAdd=this.onBeforeCartAdd.bind(this),this.onAfterCartAdd=this.onAfterCartAdd.bind(this),document.addEventListener("DOMContentLoaded",()=>{const[navigationEntry]=performance.getEntriesByType("navigation");navigationEntry&&navigationEntry.type==="back_forward"&&this.setPushCartSections(),window.addEventListener("popstate",()=>{this.setPushCartSections()})}),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD,this.onBeforeCartAdd),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.BEFORE_MULTIPLE_ADD,this.onBeforeCartAdd),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD_FROM_FORM,this.onBeforeCartAdd),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.AFTER_ADD,this.onAfterCartAdd),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.AFTER_MULTIPLE_ADD,this.onAfterCartAdd),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.AFTER_ADD_FROM_FORM,this.onAfterCartAdd)}disconnectedCallback(){super.disconnectedCallback(),window.BAO.eventBus.removeEventListener(window.BAO.EVENTS.PUSH_CART.BEFORE_ADD,this.onBeforeCartAdd),window.BAO.eventBus.removeEventListener(window.BAO.EVENTS.PUSH_CART.AFTER_ADD,this.onBeforeCartAdd)}onBeforeCartAdd(){this.drawers.activeDrawerKey=this.drawer.getAttribute("key"),this.loading=!0}onAfterCartAdd(event){"sections"in event.detail.state&&this.renderSections(event.detail.state.sections),this.loading=!1}async handleError(res){return this.loading=!1,PushCartError.handle(await res.json())}get drawers(){return this.closest("site-drawers")}get drawer(){return this.closest("site-drawer")}get loadingClass(){return this.getAttribute("loading-class")}}customElements.get("push-cart")||customElements.define("push-cart",PushCart); 2//# sourceMappingURL=/cdn/shop/t/291/assets/push-cart.js.map?v=12970037329921749491761906982
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.