1const{getElement}=window.BAO.Utils;class PushCartError{static async handle(error){const instance=new this(error);return instance.genericError?instance.render(instance.MESSAGES.GENERIC):instance.emailIsInvalid?instance.render(instance.MESSAGES.EMAIL):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.ADD_TOO_MANY)}constructor(error){this.error=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",CANNOT_FIND_VARIANT:"There was an error adding this product to cart.",GENERIC:"There was an error adding this product to cart.",NOT_ENOUGH_IN_STOCK:"Unfortunately, there isn't enough of this product available",SOLD_OUT:"Unfortunately, this product is sold out."},this.description=error?.description??"",this.status=error?.status??null,this.pushCart=getElement("push-cart")}render(message){const clone=this.pushCart.els["error-template"].element.content.cloneNode(!0),text=getElement(this.selectors.text,{context:clone});return text.textContent=message,this.pushCart.els.errors.element.appendChild(clone),this}get emailIsInvalid(){return this.error?.errors?.hasOwnProperty("email")}get addedMoreThanExists(){if(typeof this.description!="object")return this.description.slice(0,18)==="You can't add more"}get alreadyHaveAllInCart(){if(typeof this.description!="object")return this.description.slice(0,4)==="All "}get genericError(){if(typeof this.description!="object")return this.error?.errors.toLowerCase()===" error"}get soldOut(){return this.description.slice(0,13)==="The product '"}get cannotFindVariant(){if(typeof this.description!="object")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]"}}}export 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.sections=window.BAO.sectionRenderer.pushCartSections,this.drawer==null&&this.throwError("needs to be used within a <site-drawer> element")}setupListeners(){super.setupListeners(),this.onBeforeCartAdd=this.onBeforeCartAdd.bind(this),this.onAfterCartAdd=this.onAfterCartAdd.bind(this),this.onAfterCartAddError=this.onAfterCartAddError.bind(this),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),window.BAO.eventBus.addEventListener(window.BAO.EVENTS.PUSH_CART.AFTER_ADD_FROM_FORM_ERROR,this.onAfterCartAddError)}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&&event.detail.state.sections!=null&&this.renderSections(event.detail.state.sections),window.Nosto&&window.Nosto.reloadCart(),this.loading=!1}onAfterCartAddError(){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/914/assets/push-cart.js.map?v=19882017277006258921787650543
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.