if(!customElements.get("slide-show")){class SlideShow extends HTMLElement{constructor(){super(),window.initLazyScript(this,this.init.bind(this))}init(){this.slideshow=this.querySelector(".slideshow"),this.slides=this.querySelectorAll(".slideshow__slide"),this.nav=this.querySelector(".slideshow-nav"),this.pagination=this.querySelector(".slideshow-pagination"),this.rtl=document.dir==="rtl",this.currentIndex=0,this.swipeThreshold=80,this.nav&&(this.counterCurrent=this.querySelector(".slideshow-nav__counter-current"),this.nav.addEventListener("click",this.handleNavClick.bind(this))),this.pagination&&(this.pageBtns=this.querySelectorAll(".page-btn"),this.pagination.addEventListener("click",this.handlePaginationClick.bind(this))),theme.device.hasTouch&&(this.slideshow.addEventListener("touchstart",this.handleTouchStart.bind(this),{passive:!0}),this.slideshow.addEventListener("touchmove",debounce(this.handleTouchMove.bind(this),200),{passive:!0})),this.slideshow.addEventListener("transitionend",SlideShow.handleTransitionend),this.setSlideVisibility(),this.dataset.autoplay==="true"&&this.initAutoPlay()}initAutoPlay(){this.autoplayEnabled=!0,this.autoplaySpeed=this.dataset.speed*1e3,this.addEventListener("mouseover",this.pauseAutoplay.bind(this)),this.addEventListener("mouseleave",this.resumeAutoplay.bind(this)),this.slideshow.addEventListener("focusin",this.pauseAutoplay.bind(this)),this.slideshow.addEventListener("focusout",this.resumeAutoplay.bind(this)),this.addObserver(),this.startAutoplay()}handleNavClick(evt){if(evt.target.matches(".autoplay-btn")){this.togglePlayState(evt);return}evt.target.name==="next"?this.showNextSlide():evt.target.name==="prev"&&this.showPrevSlide()}handlePaginationClick(evt){evt.target.matches(".page-btn")&&(this.autoplayTimeLeft=this.autoplaySpeed,this.setActiveSlide(Number(evt.target.dataset.index)))}handleTouchStart(evt){this.touchStart=evt.changedTouches[0].screenX}handleTouchMove(evt){const touchEnd=evt.changedTouches[0].screenX;touchEndthis.touchStart+this.swipeThreshold&&(this.rtl?this.showNextSlide():this.showPrevSlide())}static handleTransitionend(evt){evt.target.matches(".has-motion")&&evt.target.classList.remove("transition-out")}showNextSlide(){let index=this.currentIndex+1;index===this.slides.length&&(index=0),this.setActiveSlide(index,"next")}showPrevSlide(){let index=this.currentIndex-1;index<0&&(index=this.slides.length-1),this.setActiveSlide(index,"prev")}setActiveSlide(slideIndex,slideDirection){if(slideIndex===this.currentIndex)return;let dir=slideDirection||(slideIndex{this.slideshow.scrollTo({left:this.slides[slideIndex].offsetLeft,behavior:"instant"}),this.slides[slideIndex].classList.add("is-active"),this.slides[this.currentIndex].classList.remove("is-active","transition-out");const transitionedEl=this.slides[this.currentIndex].querySelector(".has-motion");transitionedEl&&transitionedEl.classList.add("transition-out"),this.autoplayEnabled&&(this.autoplayStartTime=Date.now()),this.counterCurrent&&(this.counterCurrent.textContent=slideIndex+1),this.currentIndex=slideIndex,this.setSlideVisibility(),this.updatePagination()},200)}updatePagination(){this.pagination&&this.pageBtns.forEach((el,index)=>{index===this.currentIndex?el.setAttribute("aria-current","true"):el.removeAttribute("aria-current")})}stopAutoplay(){this.setSlideshowState("paused"),clearInterval(this.autoplayTimer),clearTimeout(this.resumeTimer)}startAutoplay(){this.autoplayTimeLeft=null,this.autoplayStartTime=Date.now(),this.autoplayTimer=setInterval(this.showNextSlide.bind(this),this.autoplaySpeed),this.setSlideshowState("running")}pauseAutoplay(){!this.autoplayEnabled||this.autoplayPaused||(this.stopAutoplay(),this.autoplayTimeLeft?this.autoplayTimeLeft-=Date.now()-this.resumedTime:this.autoplayTimeLeft=this.autoplaySpeed-(Date.now()-this.autoplayStartTime))}resumeAutoplay(){!this.autoplayEnabled||!this.autoplayPaused||(this.resumedTime=Date.now(),this.resumeTimer=setTimeout(()=>{this.showNextSlide(),this.startAutoplay()},this.autoplayTimeLeft),this.setSlideshowState("running"))}addObserver(){if(!("IntersectionObserver"in window))return;new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.isIntersecting?this.resumeAutoplay():this.pauseAutoplay()})}).observe(this)}setSlideVisibility(){this.slides.forEach((el,index)=>{const btns=el.querySelectorAll("a");index===this.currentIndex?(el.setAttribute("aria-hidden","false"),el.removeAttribute("tabindex"),btns.forEach(btn=>{btn.removeAttribute("tabindex")})):(el.setAttribute("aria-hidden","true"),el.setAttribute("tabindex","-1"),btns.forEach(btn=>{btn.setAttribute("tabindex","-1")}))})}setSlideshowState(state){this.style.setProperty("--play-state",state),this.slideshow.setAttribute("aria-live",state==="running"?"off":"polite"),this.autoplayPaused=state==="paused"}togglePlayState(evt){evt.target.classList.toggle("is-paused"),this.autoplayEnabled=!this.autoplayEnabled,this.dataset.autoplay=this.autoplayEnabled?"true":"false",this.autoplayEnabled?this.startAutoplay():this.stopAutoplay()}}customElements.define("slide-show",SlideShow)} //# sourceMappingURL=/cdn/shop/t/15/assets/slideshow.js.map?v=155680942656247695561710950269