class GcoSnapCarousel extends HTMLElement{connectedCallback(){this._abort=new AbortController,this._io=new IntersectionObserver(entries=>{entries.some(entry=>entry.isIntersecting)&&(this._io.disconnect(),this._bind())},{rootMargin:"200px 0px"}),this._io.observe(this)}disconnectedCallback(){this._io?.disconnect(),this._ro?.disconnect(),this._abort?.abort(),cancelAnimationFrame(this._raf),this._bound=!1}reinit(){this._bound&&this._update()}_bind(){const scroller=this.querySelector('[role="list"]');if(!scroller||!this.isConnected)return;this._scroller=scroller,this._prev=this.querySelector(".carousel-button.prev"),this._next=this.querySelector(".carousel-button.next");const{signal}=this._abort,step=direction=>{const slide=scroller.firstElementChild;if(!slide)return;const gap=parseFloat(getComputedStyle(scroller).columnGap)||0,reduced=window.matchMedia("(prefers-reduced-motion: reduce)").matches;scroller.scrollBy({left:direction*(slide.getBoundingClientRect().width+gap),behavior:reduced?"instant":"smooth"})};this._prev?.addEventListener("click",()=>step(-1),{signal}),this._next?.addEventListener("click",()=>step(1),{signal});const schedule=()=>{cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>this._update())};scroller.addEventListener("scroll",schedule,{passive:!0,signal}),this._ro=new ResizeObserver(schedule),this._ro.observe(scroller),this._bound=!0,this._update()}_update(){const scroller=this._scroller,max=scroller.scrollWidth-scroller.clientWidth;this._setDisabled(this._prev,this._next,scroller.scrollLeft<=1),this._setDisabled(this._next,this._prev,scroller.scrollLeft>=max-1)}_setDisabled(button,other,disabled){if(!button||button.disabled===disabled)return;const hadFocus=disabled&&document.activeElement===button;button.disabled=disabled,hadFocus&&other&&!other.disabled&&other.focus()}}customElements.get("gco-snap-carousel")||customElements.define("gco-snap-carousel",GcoSnapCarousel); //# sourceMappingURL=/cdn/shop/t/35/assets/gco-snap-carousel.js.map?v=55765323232812957911793372365