1customElements.get("product-info")||customElements.define("product-info",class extends HTMLElement{quantityInput=void 0;quantityForm=void 0;onVariantChangeUnsubscriber=void 0;cartUpdateUnsubscriber=void 0;abortController=void 0;pendingRequestUrl=null;preProcessHtmlCallbacks=[];postProcessHtmlCallbacks=[];constructor(){super(),this.quantityInput=this.querySelector(".quantity__input")}connectedCallback(){this.initializeProductSwapUtility(),this.onVariantChangeUnsubscriber=subscribe(PUB_SUB_EVENTS.optionValueSelectionChange,this.handleOptionValueChange.bind(this)),this.initQuantityHandlers(),this.dispatchEvent(new CustomEvent("product-info:loaded",{bubbles:!0}))}addPreProcessCallback(callback){this.preProcessHtmlCallbacks.push(callback)}initQuantityHandlers(){this.quantityInput&&(this.quantityForm=this.querySelector(".product-form__quantity"),this.quantityForm&&(this.setQuantityBoundries(),this.dataset.originalSection||(this.cartUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.cartUpdate,this.fetchQuantityRules.bind(this)))))}disconnectedCallback(){this.onVariantChangeUnsubscriber(),this.cartUpdateUnsubscriber?.()}initializeProductSwapUtility(){this.preProcessHtmlCallbacks.push(html=>html.querySelectorAll(".scroll-trigger").forEach(element=>element.classList.add("scroll-trigger--cancel"))),this.postProcessHtmlCallbacks.push(newNode=>{window?.Shopify?.PaymentButton?.init(),window?.ProductModel?.loadShopifyXR()})}handleOptionValueChange({data:{event,target,selectedOptionValues}}){if(!this.contains(event.target))return;this.resetProductFormState();const productUrl=target.dataset.productUrl||this.pendingRequestUrl||this.dataset.url;this.pendingRequestUrl=productUrl;const shouldSwapProduct=this.dataset.url!==productUrl,shouldFetchFullPage=this.dataset.updateUrl==="true"&&shouldSwapProduct;this.renderProductInfo({requestUrl:this.buildRequestUrlWithParams(productUrl,selectedOptionValues,shouldFetchFullPage),targetId:target.id,callback:shouldSwapProduct?this.handleSwapProduct(productUrl,shouldFetchFullPage):this.handleUpdateProductInfo(productUrl)})}resetProductFormState(){const productForm=this.productForm;productForm?.toggleSubmitButton(!0),productForm?.handleErrorMessage()}handleSwapProduct(productUrl,updateFullPage){return html=>{this.productModal?.remove();const selector=updateFullPage?"product-info[id^='MainProduct']":"product-info",variant=this.getSelectedVariant(html.querySelector(selector));this.updateURL(productUrl,variant?.id),updateFullPage?(document.querySelector("head title").innerHTML=html.querySelector("head title").innerHTML,HTMLUpdateUtility.viewTransition(document.querySelector("main"),html.querySelector("main"),this.preProcessHtmlCallbacks,this.postProcessHtmlCallbacks)):HTMLUpdateUtility.viewTransition(this,html.querySelector("product-info"),this.preProcessHtmlCallbacks,this.postProcessHtmlCallbacks)}}renderProductInfo({requestUrl,targetId,callback}){this.abortController?.abort(),this.abortController=new AbortController,fetch(requestUrl,{signal:this.abortController.signal}).then(response=>response.text()).then(responseText=>{this.pendingRequestUrl=null;const html=new DOMParser().parseFromString(responseText,"text/html");callback(html)}).then(()=>{document.querySelector(`#${targetId}`)?.focus()}).catch(error=>{error.name==="AbortError"?console.log("Fetch aborted by user"):console.error(error)})}getSelectedVariant(productInfoNode){const selectedVariant=productInfoNode.querySelector("variant-selects [data-selected-variant]")?.innerHTML;return selectedVariant?JSON.parse(selectedVariant):null}buildRequestUrlWithParams(url,optionValues,shouldFetchFullPage=!1){const params=[];return!shouldFetchFullPage&¶ms.push(`section_id=${this.sectionId}`),optionValues.length&¶ms.push(`option_values=${optionValues.join(",")}`),`${url}?${params.join("&")}`}updateOptionValues(html){const variantSelects=html.querySelector("variant-selects");variantSelects&&HTMLUpdateUtility.viewTransition(this.variantSelectors,variantSelects,this.preProcessHtmlCallbacks)}handleUpdateProductInfo(productUrl){return html=>{const variant=this.getSelectedVariant(html);if(this.pickupAvailability?.update(variant),this.updateOptionValues(html),this.updateURL(productUrl,variant?.id),this.updateV
1ariantInputs(variant?.id),initVariantDrawer(),!variant){this.setUnavailable();return}this.updateMedia(html,variant?.featured_media?.id);const updateSourceFromDestination=(id,shouldHide=source=>!1)=>{const source=html.getElementById(`${id}-${this.sectionId}`),destination=this.querySelector(`#${id}-${this.dataset.section}`);source&&destination&&(destination.innerHTML=source.innerHTML,destination.classList.toggle("hidden",shouldHide(source)))};sliderArrows(),thumbnailsScroll();const slidesContainer=document.getElementById("SlidesCon");slidesContainer&&slidesContainer.addEventListener("scroll",function(){handleScroll()}),updateSourceFromDestination("price"),updateSourceFromDestination("Sku",({classList})=>classList.contains("hidden")),updateSourceFromDestination("Inventory",({innerText})=>innerText===""),updateSourceFromDestination("Volume"),updateSourceFromDestination("Price-Per-Item",({classList})=>classList.contains("hidden")),this.updateQuantityRules(this.sectionId,html),this.querySelector(`#Quantity-Rules-${this.dataset.section}`)?.classList.remove("hidden"),this.querySelector(`#Volume-Note-${this.dataset.section}`)?.classList.remove("hidden"),this.productForm?.toggleSubmitButton(html.getElementById(`ProductSubmitButton-${this.sectionId}`)?.hasAttribute("disabled")??!0,window.variantStrings.soldOut),publish(PUB_SUB_EVENTS.variantChange,{data:{sectionId:this.sectionId,html,variant}})}}updateVariantInputs(variantId){this.querySelectorAll(`#product-form-${this.dataset.section}, #product-form-installment-${this.dataset.section}`).forEach(productForm=>{const input=productForm.querySelector('input[name="id"]');input.value=variantId??"",input.dispatchEvent(new Event("change",{bubbles:!0}))})}updateURL(url,variantId){this.querySelector("share-button")?.updateUrl(`${window.shopUrl}${url}${variantId?`?variant=${variantId}`:""}`),this.dataset.updateUrl!=="false"&&window.history.replaceState({},"",`${url}${variantId?`?variant=${variantId}`:""}`)}setUnavailable(){this.productForm?.toggleSubmitButton(!0,window.variantStrings.unavailable);const selectors=["price","Inventory","Sku","Price-Per-Item","Volume-Note","Volume","Quantity-Rules"].map(id=>`#${id}-${this.dataset.section}`).join(", ");document.querySelectorAll(selectors).forEach(({classList})=>classList.add("hidden"))}handleScroll(){const slidesContainer=document.getElementById("SlidesCon"),slideWidth=slidesContainer.offsetWidth,scrollPosition=slidesContainer.scrollLeft,thumbnails=document.getElementsByClassName("gallery-slider--thumbnail");if(slidesContainer){const index=Math.round(scrollPosition/slideWidth)+1;pauseGalleryMedia();for(var i=0;i<thumbnails.length;i++)thumbnails[i].classList.remove("active"),thumbnails[i].getAttribute("data-slide-index")==index&&thumbnails[i].classList.add("active")}}initVariantDrawer(){const toggles=document.querySelectorAll(".radio-drawer--opener"),drawers=document.querySelectorAll(".radio-options-drawer"),closeButtons=document.querySelectorAll(".rod--drawer-close"),closeButtonsFooter=document.querySelectorAll(".rod--drawer-footer-button"),backgrounds=document.querySelectorAll(".radio-options-drawer--background");toggles.forEach(function(toggle,index){const drawer=drawers[index],closeButton=closeButtons[index],closeButtonFooter=closeButtonsFooter[index],drawerBg=backgrounds[index];if(!drawer)return;const isAccordion=drawer.classList.contains("ro-display-type--accordion");let drawerKey;isAccordion&&(drawerKey=`drawerOpen-${document.querySelector("[data-product-id]")?.dataset.productId||"unknown"}-${index}`,window.location.search.includes("variant=")&&localStorage.getItem(drawerKey)==="true"&&(drawer.classList.add("open"),drawerBg&&drawerBg.classList.add("open")));const closeDrawer=()=>{drawer.classList.remove("open"),drawerBg&&drawerBg.classList.remove("open"),isAccordion&&localStorage.setItem(drawerKey,"false")};drawerBg&&drawerBg.addEventListener("click",closeDrawer),closeButtonFooter&&closeButtonFooter.addEventListener("click",closeDrawer),closeButton&&closeButton.addEventListener("click",closeDrawer),toggle.addEventListener("click",function(){const isOpen=drawer.classList.toggle("open");drawerBg&&drawerBg.classList.toggle("open",isOpen),isAccordion&&localStorage.setItem(drawerKey,isOpen.toString())})})}updateMedia(html,variantFeaturedMediaId){if(!variantFeaturedMediaId)return;const srcId=this.dataset.originalSection?this.dataset.originalSection:this.dataset.section,galSource=html.getElementById(`pageGallery-${srcId}`),galDestination=document.getElementById(`pageGallery-${this.dataset.section}`);
1if(!galSource||!galDestination)return;const isAndroid=/Android/i.test(navigator.userAgent),yBefore=isAndroid?window.scrollY:0;let prevHeight=0;isAndroid&&(prevHeight=galDestination.offsetHeight,prevHeight&&(galDestination.style.minHeight=`${prevHeight}px`)),galDestination.innerHTML=galSource.innerHTML,isAndroid&&requestAnimationFrame(()=>{window.scrollTo(0,yBefore),setTimeout(()=>window.scrollTo(0,yBefore),120),setTimeout(()=>{galDestination.style.minHeight=""},250)})}setQuantityBoundries(){const data={cartQuantity:this.quantityInput.dataset.cartQuantity?parseInt(this.quantityInput.dataset.cartQuantity):0,min:this.quantityInput.dataset.min?parseInt(this.quantityInput.dataset.min):1,max:this.quantityInput.dataset.max?parseInt(this.quantityInput.dataset.max):null,step:this.quantityInput.step?parseInt(this.quantityInput.step):1};let min=data.min;const max=data.max===null?data.max:data.max-data.cartQuantity;max!==null&&(min=Math.min(min,max)),data.cartQuantity>=data.min&&(min=Math.min(min,data.step)),this.quantityInput.min=min,max?this.quantityInput.max=max:this.quantityInput.max=max,this.quantityInput.value=min,publish(PUB_SUB_EVENTS.quantityUpdate,void 0)}fetchQuantityRules(){const currentVariantId=this.productForm?.variantIdInput?.value;if(currentVariantId)return this.querySelector(".quantity__rules-cart .loading__spinner").classList.remove("hidden"),fetch(`${this.dataset.url}?variant=${currentVariantId}§ion_id=${this.dataset.section}`).then(response=>response.text()).then(responseText=>{const html=new DOMParser().parseFromString(responseText,"text/html");this.updateQuantityRules(this.dataset.section,html)}).catch(e=>console.error(e)).finally(()=>this.querySelector(".quantity__rules-cart .loading__spinner").classList.add("hidden"))}updateQuantityRules(sectionId,html){if(!this.quantityInput)return;this.setQuantityBoundries();const quantityFormUpdated=html.getElementById(`Quantity-Form-${sectionId}`),selectors=[".quantity__input",".quantity__rules",".quantity__label"];for(let selector of selectors){const current=this.quantityForm.querySelector(selector),updated=quantityFormUpdated.querySelector(selector);if(!(!current||!updated)){if(selector===".quantity__input"){const attributes=["data-cart-quantity","data-min","data-max","step"];for(let attribute of attributes){const valueUpdated=updated.getAttribute(attribute);valueUpdated!==null?current.setAttribute(attribute,valueUpdated):current.removeAttribute(attribute)}this.setQuantityBoundries()}else if(current.innerHTML=updated.innerHTML,selector===".quantity__label"){const updatedAriaLabelledBy=updated.getAttribute("aria-labelledby");if(updatedAriaLabelledBy){current.setAttribute("aria-labelledby",updatedAriaLabelledBy);const labelId=updatedAriaLabelledBy,currentHiddenLabel=document.getElementById(labelId),updatedHiddenLabel=html.getElementById(labelId);currentHiddenLabel&&updatedHiddenLabel&&(currentHiddenLabel.textContent=updatedHiddenLabel.textContent)}}}}}get productForm(){return this.querySelector("product-form")}get productModal(){return document.querySelector(`#ProductModal-${this.dataset.section}`)}get pickupAvailability(){return this.querySelector("pickup-availability")}get variantSelectors(){return this.querySelector("variant-selects")}get relatedProducts(){const relatedProductsSectionId=SectionId.getIdForSection(SectionId.parseId(this.sectionId),"related-products");return document.querySelector(`product-recommendations[data-section-id^="${relatedProductsSectionId}"]`)}get quickOrderList(){const quickOrderListSectionId=SectionId.getIdForSection(SectionId.parseId(this.sectionId),"quick_order_list");return document.querySelector(`quick-order-list[data-id^="${quickOrderListSectionId}"]`)}get sectionId(){return this.dataset.originalSection||this.dataset.section}}); 2//# sourceMappingURL=/cdn/shop/t/63/assets/product-info.js.map?v=141461016413398990031787809114
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.