1const{Cart}=window.BAO,{formatMoney,getElement,translateString}=window.BAO.Utils,{productDataCache}=window.BAO.Caches;function warmUpCache(cache){return function(...handles){handles.forEach(handle=>cache.get(handle))}}class ShopTheLookProduct extends window.BAO.CustomElement(){static get requiredElements(){return["id-input","quantity-input","form","submit","image","title","price"]}connectedCallback(){super.connectedCallback(),this._disabled=!1,warmUpCache(productDataCache)(...this.relatedProductHandles)}setupListeners(){this.handleFormSubmit=this.handleFormSubmit.bind(this),this.handleProductSelectorChange=this.handleProductSelectorChange.bind(this),this.updateVariant=this.updateVariant.bind(this),this.productSelectors.forEach(selector=>{this.listeners.add(selector,"change",this.handleProductSelectorChange)}),this.variantSelectors.forEach(selector=>{this.listeners.add(selector,"change",this.updateVariant)}),this.listeners.add(this.els.form.element,"submit",this.handleFormSubmit)}handleFormSubmit(event){event.preventDefault(),this.addToCart()}async addToCart(){this.dispatchEvent(new CustomEvent("shop-the-look:product:before-add",{bubbles:!0}));const formData=new FormData(this.els.form.element),sectionsToRequest=getElement("push-cart")?window.BAO.sectionRenderer.pushCartSections:getElement("cart-items")?window.BAO.sectionRenderer.cartSections:[],state=await Cart.addItemFromForm(formData,{sections:sectionsToRequest.map(s=>s.section)});return this.dispatchEvent(new CustomEvent("shop-the-look:product:after-add",{bubbles:!0})),state}setQuantity(quantity){this.els["quantity-input"].element.value=quantity}handleProductSelectorChange(event){const selectedOption=event.target.selectedOptions[0];this.updateProduct(selectedOption.dataset.productHandle)}async updateProduct(handle){const product=await productDataCache.get(handle),variant=this.getVariantFromOptions(product,this.selectedOptions);this.dispatchEvent(new CustomEvent("shop-the-look:product:replace",{bubbles:!0,detail:{product,variant}}))}updateVariant(){this.render()}async render(){const variant=this.variantFromOptionSelectors;this.els.price.element.textContent=translateString(this.translations.price,{price:formatMoney(variant.price)}),this.els["id-input"].element.value=variant.id,this.els.submit.element.disabled=!variant.available,this.els.submit.element.ariaHidden=!variant.available,this.els.notify.element.ariaHidden=variant.available,this.els.form.element.dataset.available=variant.available,this.els["submit-text"].element.textContent=variant.available?this.translations.add_to_bag:this.translations.out_of_stock,this.dispatchEvent(new CustomEvent("shop-the-look:variant:change",{bubbles:!0}))}getVariantFromOptions(product,options){return product.variants.find(variant=>options.every(option=>variant[`option${option.position}`]===option.value))}get relatedProductHandles(){return JSON.parse(this.getAttribute("related-product-handles"))}get product(){return JSON.parse(this.getAttribute("product"))}get translations(){return JSON.parse(this.getAttribute("translations"))}get optionSelectors(){const{"option-selector":optionSelector}=this.els;return optionSelector?optionSelector.elements:[]}get productSelectors(){return this.optionSelectors.filter(selector=>selector.dataset.optionType==="product")}get variantSelectors(){return this.optionSelectors.filter(selector=>selector.dataset.optionType==="variant")}get variantFromOptionSelectors(){return this.getVariantFromOptions(this.product,this.selectedOptions)}get selectedOptions(){return this.variantSelectors.map(selector=>({position:selector.dataset.optionPosition,value:selector.value}))}get disabled(){return this._disabled}set disabled(disabled){this._disabled=disabled,this.els.submit.element.disabled=disabled}}customElements.get("shop-the-look-product")||customElements.define("shop-the-look-product",ShopTheLookProduct); 2//# sourceMappingURL=/cdn/shop/t/1379/assets/shop-the-look-product.js.map?v=14291794584812964131789975684
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.