1if(!customElements.get('product-card-image-slider')){customElements.whenDefined('carousel-slider').then(()=>{class ProductCardImageSlider extends CarouselSlider{constructor(){super();this.productCard=this.closest('product-card');this.productCardSwatches=this.productCard.querySelectorAll('.card__swatches .opt-btn');this.slides=this.querySelectorAll('.slider__item');this.productCard.addEventListener('change',this.handleSwatchChange.bind(this))} 2init(){super.init();this.slider.addEventListener('scroll',this.scrollInProgress.bind(this));if(this.productCardSwatches){const activeSlide=this.querySelector('.slider__item[aria-current]');const activeSwatchId=this.productCard.querySelector('.card__swatches .opt-btn:checked')?.dataset.mediaId||activeSlide?.dataset.mediaId;let activeSwatchSlide;if(activeSwatchId){this.productCardSwatches.forEach((swatch)=>{const swatchSlide=this.querySelector(`[data-media-id="${swatch.dataset.mediaId}"]`);if(swatchSlide){swatchSlide.setAttribute('data-swatch-anchor','true');if(swatchSlide.dataset.mediaId===activeSwatchId){activeSlide.removeAttribute('aria-current');swatchSlide.setAttribute('aria-current','true');activeSwatchSlide=swatchSlide}}})} 3if(activeSwatchSlide)this.handleSwatchChange(null,activeSwatchSlide.dataset.mediaId);}else{const activeSlide=this.querySelector('.slider__item[aria-current]');if(activeSlide){this.handleSwatchChange(null,activeSlide.dataset.mediaId)}else{this.slider.slides[1]?.setAttribute('aria-current','true')}}} 4updateSlideVisibility(mediaId){let hideSlide=!0;let foundMediaId=!1;this.slides.forEach((slide)=>{if(!foundMediaId&&slide.getAttribute('data-media-id')===mediaId){hideSlide=!1;foundMediaId=!0}else if(foundMediaId&&slide.hasAttribute('data-swatch-anchor')){hideSlide=!0} 5slide.toggleAttribute('hidden',hideSlide)});this.setButtonStates()} 6handleSwatchChange(evt,mediaId){const swatchMediaId=evt?.target.dataset.mediaId||mediaId;if(swatchMediaId){this.updateSlideVisibility(swatchMediaId);const variantMedia=this.querySelector(`[data-media-id="${swatchMediaId}"]`);if(variantMedia){const left=variantMedia.closest('.slider__item').offsetLeft;this.slider.scrollTo({left,behavior:'instant'})}}} 7setButtonStates(){if(!this.prevBtn&&!this.nextBtn){return} 8const currentSlideIndex=Math.round(this.slider.scrollLeft/this.slideSpan)+1;const visibleSlideCount=this.slides.filter((slide)=>slide.hidden!==!0).length;this.prevBtn.disabled=currentSlideIndex===1||(this.getSlideVisibility(this.slides[0])&&this.slider.scrollLeft===0);this.nextBtn.disabled=visibleSlideCount===currentSlideIndex||this.getSlideVisibility(this.slides[this.slides.length-1])} 9scrollInProgress(){this.slider.querySelector('[aria-current]')?.removeAttribute('aria-current')} 10handleScroll(){super.handleScroll();this.slides[this.currentIndex].setAttribute('aria-current','true')}} 11customElements.define('product-card-image-slider',ProductCardImageSlider)})}
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.