1(()=>{"use strict";const reducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)");class PdpGallery extends HTMLElement{connectedCallback(){if(this.track=this.querySelector("[data-gallery-track]"),this.slides=[...this.querySelectorAll("[data-gallery-slide]")],this.thumbs=[...this.querySelectorAll("[data-gallery-thumb]")],this.thumbList=this.querySelector(".pdp-gallery__thumbs"),this.controls=this.querySelector("[data-gallery-controls]"),this.prevBtn=this.querySelector("[data-gallery-prev]"),this.nextBtn=this.querySelector("[data-gallery-next]"),this.dialog=this.querySelector("[data-gallery-zoom-dialog]"),this.zoomTrack=this.dialog?.querySelector("[data-zoom-track]"),this.zoomSlides=this.dialog?[...this.dialog.querySelectorAll("[data-zoom-slide]")]:[],this.zoomPrevBtn=this.dialog?.querySelector("[data-zoom-prev]"),this.zoomNextBtn=this.dialog?.querySelector("[data-zoom-next]"),this.index=0,this.zoomIndex=0,!this.track||this.slides.length===0)return;this.controls?.removeAttribute("hidden"),this.prevBtn?.addEventListener("click",()=>this.goTo(this.index-1)),this.nextBtn?.addEventListener("click",()=>this.goTo(this.index+1)),this.thumbs.forEach((thumb,i)=>{thumb.addEventListener("click",event=>{event.preventDefault(),this.goTo(i),this.alignBelowHeader()})});let scrollTimer=null;if(this.track.addEventListener("scroll",()=>{window.clearTimeout(scrollTimer),scrollTimer=window.setTimeout(()=>{const width=this.track.clientWidth;if(!width)return;const i=Math.round(this.track.scrollLeft/width);
1this.setCurrent(Math.max(0,Math.min(i,this.slides.length-1)))},80)},{passive:!0}),this.addEventListener("click",event=>{const trigger=event.target.closest("[data-zoom-trigger]");trigger&&this.openZoom(trigger)}),this.dialog&&(this.dialog.addEventListener("click",event=>{if(!event.target.closest("[data-zoom-prev],[data-zoom-next]")){if(event.target.closest("[data-zoom-close]")){this.closeZoom();return}event.target.closest(".pdp-zoom__img, .pdp-zoom__video")||this.closeZoom()}}),this.zoomPrevBtn?.addEventListener("click",()=>this.zoomGoTo(this.zoomIndex-1)),this.zoomNextBtn?.addEventListener("click",()=>this.zoomGoTo(this.zoomIndex+1)),this.dialog.addEventListener("keydown",event=>{event.target.closest("video")||(event.key==="ArrowRight"?(event.preventDefault(),this.zoomGoTo(this.zoomIndex+1)):event.key==="ArrowLeft"&&(event.preventDefault(),this.zoomGoTo(this.zoomIndex-1)))}),this.dialog.addEventListener("close",()=>this.pauseZoomVideos()),this.zoomTrack)){let zoomScrollTimer=null;this.zoomTrack.addEventListener("scroll",()=>{window.clearTimeout(zoomScrollTimer),zoomScrollTimer=window.setTimeout(()=>{const width=this.zoomTrack.clientWidth;if(!width)return;const i=Math.round(this.zoomTrack.scrollLeft/width);this.setZoomCurrent(Math.max(0,Math.min(i,this.zoomSlides.length-1)))},80)},{passive:!0})}this.setCurrent(0,{playVideo:!1})}goTo(index){if(!this.slides.length)return;const i=Math.max(0,Math.min(index,this.slides.length-1));this.track.scrollTo({left:this.slides[i].offsetLeft,behavior:reducedMotion.matches?"auto":"smooth"}),this.setCurrent(i)}setCurrent(index,{playVideo=!0}={}){this.index=index,this.thumbs.forEach((thumb,i)=>{i===index?thumb.setAttribute("aria-current","true"):thumb.removeAttribute("aria-current")}),this.prevBtn&&(this.prevBtn.disabled=index===0),this.nextBtn&&(this.nextBtn.disabled=index===this.slides.length-1),this.slides.forEach((slide,i)=>{i!==index&&slide.querySelectorAll("video").forEach(video=>video.pause())}),playVideo&&this.playSlideVideo(index),this.scrollThumbIntoView(index)}playSlideVideo(index){if(reducedMotion.matches)return;const video=this.slides[index]?.querySelector("video");if(!video||!video.paused)return;video.muted=!0;const played=video.play();played&&typeof played.catch=="function"&&played.catch(()=>{})}alignBelowHeader(){const viewport=this.querySelector(".pdp-gallery__viewport");if(!viewport)return;const header=parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--header-height"))||0,offset=viewport.getBoundingClientRect().top-(header+12);offset>=-1||window.scrollBy({top:offset,behavior:reducedMotion.matches?"auto":"smooth"})}scrollThumbIntoView(index){const list=this.thumbList,thumb=this.thumbs[index];if(!list||!thumb||list.scrollWidth<=list.clientWidth+1)return;const listRect=list.getBoundingClientRect(),thumbRect=thumb.getBoundingClientRect(),pad=12;let delta=0;thumbRect.left<listRect.left+pad?delta=thumbRect.left-listRect.left-pad:thumbRect.right>listRect.right-pad&&(delta=thumbRect.right-listRect.right+pad),delta!==0&&list.scrollBy({left:delta,behavior:reducedMotion.matches?"auto":"smooth"})}goToMediaId(mediaId){if(!mediaId)return;const i=this.slides.findIndex(slide=>slide.getAttribute("data-media-id")===String(mediaId));i>=0&&this.goTo(i)}openZoom(trigger){if(!this.dialog||!this.zoomTrack||!this.zoomSlides.length)return;const requested=parseInt(trigger.getAttribute("data-zoom-index"),10),i=Math.max(0,Math.min(Number.isNaN(requested)?this.index:requested,this.zoomSlides.length-1));
1this.ensureZoomLoaded(i),this.slides.forEach(slide=>slide.querySelector("video")?.pause()),this.dialog.showModal(),this.zoomTrack.scrollLeft=i*this.zoomTrack.clientWidth,this.setZoomCurrent(i)}zoomGoTo(index){if(!this.zoomSlides.length)return;const i=Math.max(0,Math.min(index,this.zoomSlides.length-1));this.zoomTrack.scrollTo({left:i*this.zoomTrack.clientWidth,behavior:reducedMotion.matches?"auto":"smooth"}),this.setZoomCurrent(i)}setZoomCurrent(index){this.zoomIndex=index,this.zoomPrevBtn&&(this.zoomPrevBtn.disabled=index===0),this.zoomNextBtn&&(this.zoomNextBtn.disabled=index===this.zoomSlides.length-1),this.ensureZoomLoaded(index),this.playZoomMedia(index)}ensureZoomLoaded(index){[index-1,index,index+1].forEach(n=>{const slide=this.zoomSlides[n];if(!slide)return;const img=slide.querySelector("img");img&&img.getAttribute("loading")==="lazy"&&img.setAttribute("loading","eager");const video=slide.querySelector("video[data-poster]");video&&(video.setAttribute("poster",video.getAttribute("data-poster")),video.removeAttribute("data-poster"))})}playZoomMedia(index){this.zoomSlides.forEach((slide,i)=>{const video=slide.querySelector("video");if(video)if(i===index){if(!video.paused||reducedMotion.matches)return;video.muted=!0;const played=video.play();played&&typeof played.catch=="function"&&played.catch(()=>{})}else video.pause()})}
1pauseZoomVideos(){this.zoomSlides.forEach(slide=>{slide.querySelector("video")?.pause();const frame=slide.querySelector("iframe");frame&&(frame.src=frame.src)})}closeZoom(){this.pauseZoomVideos(),this.dialog.close()}}class PdpQuantity extends HTMLElement{connectedCallback(){this.input=this.querySelector('input[name="quantity"]'),this.input&&(this.addEventListener("click",event=>{const btn=event.target.closest("[data-qty-change]");if(!btn)return;event.preventDefault();const step=parseInt(btn.getAttribute("data-qty-change"),10)||0,min=parseInt(this.input.min,10)||1;let value=parseInt(this.input.value,10);Number.isNaN(value)&&(value=min),this.input.value=Math.max(min,value+step),this.input.dispatchEvent(new Event("change",{bubbles:!0}))}),this.input.addEventListener("change",()=>{const min=parseInt(this.input.min,10)||1,value=parseInt(this.input.value,10);(Number.isNaN(value)||value<min)&&(this.input.value=min)}))}}class PdpVariantPicker extends HTMLElement{connectedCallback(){this.sectionId=this.getAttribute("data-section"),this.productUrl=this.getAttribute("data-url"),this.select=this.querySelector('select[name="id"]'),this.abortController=null;try{this.variants=JSON.parse(this.querySelector("[data-variant-json]")?.textContent||"[]")}catch{this.variants=[]}this.classList.add("js"),this.addEventListener("change",event=>{event.target.matches('input[type="radio"]')&&this.onOptionChange()})}selectedOptions(){return[...this.querySelectorAll("fieldset[data-option-index]")].map(fieldset=>fieldset.querySelector('input[type="radio"]:checked')?.value??null)}onOptionChange(){const options=this.selectedOptions(),variant=this.variants.find(candidate=>candidate.options.every((option,i)=>option===options[i]));this.updateVariant(variant||null)}updateVariant(variant){if(!variant){const scope=document.querySelector(`[data-
1pdp-section="${this.sectionId}"]`),text=this.getAttribute("data-unavailable-text")||"";scope?.querySelectorAll('[data-swap="atc-label"], [data-swap="sticky-atc-label"]').forEach(label=>{label.textContent=text;const button=label.closest("button");button&&(button.disabled=!0)});return}this.select&&(this.select.value=variant.id);const url=new URL(window.location.href);url.searchParams.set("variant",variant.id),window.history.replaceState({},"",url.toString());const gallery=document.querySelector(`pdp-gallery[data-section="${this.sectionId}"]`);variant.featured_media&&gallery?.goToMediaId(variant.featured_media.id),this.renderSection(variant.id),this.dispatchEvent(new CustomEvent("pdp:variant:change",{bubbles:!0,detail:{variant,sectionId:this.sectionId}}))}renderSection(variantId){if(!this.sectionId||!this.productUrl)return;this.abortController?.abort(),this.abortController=new AbortController;const url=`${this.productUrl}?section_id=${encodeURIComponent(this.sectionId)}`+(variantId?`&variant=${encodeURIComponent(variantId)}`:"");fetch(url,{signal:this.abortController.signal}).then(response=>response.text()).then(html=>{const doc=new DOMParser().parseFromString(html,"text/html"),scope=document.querySelector(`[data-
1pdp-section="${this.sectionId}"]`);scope&&scope.querySelectorAll("[data-swap]").forEach(el=>{const next=doc.querySelector(`[data-swap="${el.getAttribute("data-swap")}"]`);if(next&&(el.innerHTML=next.innerHTML,next.hasAttribute("data-disabled"))){const button=el.closest("button");button&&(button.disabled=next.getAttribute("data-disabled")==="true")}})}).catch(error=>{error?.name!=="AbortError"&&console.warn("[pdp] section render failed",error)})}}class PdpProductForm extends HTMLElement{connectedCallback(){this.form=this.querySelector("form"),this.error=this.querySelector("[data-form-error]"),this.form?.addEventListener("submit",event=>this.onSubmit(event))}submitButtons(){const inside=[...this.form.querySelectorAll('button[type="submit"]')],formId=this.form.getAttribute("id"),outside=formId?[...document.querySelectorAll(`button[form="${formId}"]`)]:[];return inside.concat(outside)}setLoading(isLoading){this.submitButtons().forEach(button=>{isLoading?(button.dataset.wasDisabled=String(button.disabled),button.setAttribute("aria-busy","true"),button.disabled=!0):(button.removeAttribute("aria-busy"),button.disabled=button.dataset.wasDisabled==="true",delete button.dataset.wasDisabled)})}showError(message){this.error&&(this.error.textContent=message||"")}onSubmit(event){event.preventDefault(),this.showError(""),this.setLoading(!0);const formData=new FormData(this.form),drawerSectionId=document.querySelector("[data-cart-drawer]")?.getAttribute("data-section-id");drawerSectionId&&(formData.append("sections",drawerSectionId),formData.append("sections_url",window.location.pathname+window.location.search));const action=this.form.getAttribute("action")||"/cart/add";fetch(`${action}.js`,{method:"POST",credentials:"same-origin",headers:{Accept:"application/json","X-Requested-With":"XMLHttpRequest"},body:formData}).then(response=>response.json().then(data=>{if(!response.ok)throw Object.assign(new Error("Add to cart failed"),{data});return data})).then(item=>{document.dispatchEvent(new CustomEvent("pdp:cart:added",{bubbles:!0,detail:{item}})),window.theme?.Drawer?.addToCartOkay?window.theme.Drawer.addToCartOkay(item):window.location.href=this.getAttribute("data-cart-url")||"/cart"}).catch(error=>{this.showError(error?.data?.description||error?.data?.message||this.getAttribute("data-error-message")||"")}).finally(()=>this.setLoading(!1))}}class PdpStickyAtc extends HTMLElement{connectedCallback(){const target=document.querySelector(this.getAttribute("data-watch")||"");if(!target||!("IntersectionObserver"in window))return;this.pastBuyBox=!1,this.footerInView=!1,this.buyBoxObserver=new IntersectionObserver(entries=>{const entry=entries[entries.length-1];this.pastBuyBox=!entry.isIntersecting&&entry.boundingClientRect.bottom<=0,this.update()},{threshold:0}),this.buyBoxObserver.observe(target);const footer=document.querySelector("#shopify-section-footer")||document.querySelector('[data-section-type="footer"]')||document.querySelector("footer");footer&&(this.footerObserver=new IntersectionObserver(entries=>{this.footerInView=entries[entries.length-1].isIntersecting,this.update()},{threshold:0}),this.footerObserver.observe(footer))}disconnectedCallback(){this.buyBoxObserver?.disconnect(),this.footerObserver?.disconnect(),this.hidden=!0,document.body.classList.remove("pdp-sticky-atc-visible"),this.syncChat()}update(){const visible=this.pastBuyBox&&!this.footerInView;visible!==!this.hidden&&(this.hidden=!visible,document.body.classList.toggle("pdp-sticky-atc-visible",visible),this.syncChat())}syncChat(){typeof window.handleChatWidget=="function"?window.handleChatWidget():window.theme?.ChatWidget&&(this.hidden?window.theme.ChatWidget.show():window.theme.ChatWidget.hide())}}class PdpFaq extends HTMLElement{connectedCallback(){this.toggle=this.querySelector("[data-faq-toggle]"),this.toggle&&(this.onToggle=()=>this.setExpanded(!this.expanded),this.toggle.addEventListener("click",this.onToggle))}disconnectedCallback(){this.toggle&&this.onToggle&&this.toggle.removeEventListener("click",this.onToggle)}get expanded(){return this.classList.contains("is-expanded")}setExpanded(expanded){const overflow=this.querySelector(".pdp-faq__overflow");!expanded&&overflow?.contains(document.activeElement)&&this.toggle.focus(),this.classList.toggle("is-expanded",expanded),this.toggle.setAttribute("aria-expanded",String(expanded)),!expanded&&overflow&&overflow.querySelectorAll(".pdp-accordion[open]").forEach(row=>{row.open=!1})}}class PdpCompare extends HTMLElement{connectedCallback(){this.url=this.dataset.compareUrl,this.url&&("IntersectionObserver"in window?(this.observer=new IntersectionObserver(entries=>{entries.some(entry=>entry.isIntersecting)&&(this.observer.disconnect(),this.load())},{rootMargin:"600px 0px"}),this.observer.observe(this)):this.load())}disconnectedCallback(){this.observer?.disconnect(),this.controller?.abort()}async load(){const url=this.url;this.url=null,this.controller=new AbortController;const timer=window.setTimeout(()=>this.controller.abort(),1e4);try{const response=await fetch(url,{signal:this.controller.signal});if(!response.ok)throw new Error("Compare section responded "+response.status);const doc=new DOMParser().parseFromString(await response.text(),"text/html"),host=doc.querySelector("pdp-compare"),content=host?.querySelector("[data-compare-content]")||doc.querySelector("[data-compare-content]"),target=this.querySelector("[data-compare-content]");if(!content||!content.querySelector(".pdp-compare__table")||!target)return;const style=host?.getAttribute("style");style&&this.setAttribute("style",style),target.replaceWith(document.importNode(content,!0)),this.classList.add("is-loaded")}catch(error){error.name!=="AbortError"&&console.warn("[pdp-compare]",error)}finally{window.clearTimeout(timer)}}}customElements.get("pdp-gallery")||customElements.define("pdp-gallery",PdpGallery),customElements.get("pdp-quantity")||customElements.define("pdp-quantity",PdpQuantity),customElements.get("pdp-variant-picker")||customElements.define("pdp-variant-picker",PdpVariantPicker),customElements.get("pdp-product-form")||customElements.define("pdp-product-form",PdpProductForm),
1customElements.get("pdp-sticky-atc")||customElements.define("pdp-sticky-atc",PdpStickyAtc),customElements.get("pdp-faq")||customElements.define("pdp-faq",PdpFaq),customElements.get("pdp-compare")||customElements.define("pdp-compare",PdpCompare)})(); 2//# sourceMappingURL=/cdn/shop/t/455/assets/product-v2.js.map?v=157400850942529380891790261016
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.