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.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):typeof error?.message=="string"?instance.render(error.message):typeof error?.errors=="string"?instance.render(error.errors):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 addedMoreThanExists(){return this.description.slice(0,18)==="You can't add more"}get alreadyHaveAllInCart(){return this.description.slice(0,4)==="All "}get genericError(){return this.error?.errors?.toLowerCase()===" error"}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]"}}}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),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.onAfterCartAdd)}onBeforeCartAdd(){window.drawers.activeDrawerKey="cart",this.loading=!0}onAfterCartAdd(event){"sections"in event.detail.state&&this.renderSections(event.detail.state.sections),this.loading=!1;const type=event.detail.form?.dataset?.nostoType;if(!type)return;const productId=event.detail.state.id,productUrl=event.detail.state.url;if(type==="recommendations"){const placementId=event.detail.form.dataset.nostoPlacementId;if(!placementId)return;try{window.nostojs(api=>{api.recommendedProductAddedToCart(productId,placementId)})}catch(error){console.error("NostoJS API call failed:",error)}return}const object=type==="autocomplete"?window.theme.autocomplete:window.theme.results;window.theme.nosto.eventBus.publish(object.events.TRACKING.PRODUCT_ADDED_TO_CART,{productId,productUrl,type})}async handleError(res){return this.loading=!1,PushCartError.handle(await res.json())}get drawer(){return this.closest('[is="site-drawer"]')}get loadingClass(){return this.getAttribute("loading-class")}}customElements.get("push-cart")||customElements.define("push-cart",PushCart); 2//# sourceMappingURL=/cdn/shop/t/1735/assets/push-cart.js.map?v=171917522134850855511782836744
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.