1import{B as u}from"./BaseElement.Dw8b55QC.min.js";import{n as l}from"./property.CoOWCv8E.min.js";import{r as v}from"./state.DSBX3JYf.min.js";import{e as a}from"./query.CpiO8Lcb.min.js";import{r as c}from"./query-all.D646pH-D.min.js";import"./lit-element.D1QXZDXi.min.js";import"./base.CShCMygk.min.js";function p(s,t){let e;return function(...r){e||(s.apply(this,r),e=!0,setTimeout(()=>e=!1,t))}}var f=Object.defineProperty,n=(s,t,e,r)=>{for(var o=void 0,h=s.length-1,d;h>=0;h--)(d=s[h])&&(o=d(t,e,o)||o);return o&&f(t,e,o),o};class i extends u{constructor(){super(),this.n_slides=0,this.n_slidesCloned=0,this.n_pages=0,this.slideWidth=0,this.pageWidth=0,this.spaceBtwSlides=0,this.resizeObserver=null,this.isDesktop=!1,this.itemsToShow=1,this.slideInterval=parseInt(this.dataset.slideInterval||"0",10),this.isMobileOnly=this.dataset.isMobileOnly==="true",this.isDesktopOnly=this.dataset.isDesktopOnly==="true",this.itemsToScroll=parseInt(this.dataset.itemsToScroll||"1",10),this.isPlaying=!1,this.connectedCarousels=null,this.currentSlide=0,this.scrollTimer=null,this.intervalId=null,this.eventListenersHaveBeenAdded=!1,this._slidesMutationWatcher=null,this._isCloningSlides=!1,this.handlePrevClick=()=>{const t=this.index_slideCurrent;t>=0?this.goto(t-1):this.resetScroll(!1)},this.handleNextClick=()=>{const t=this.index_slideCurrent;t<=this.n_slides?this.goto(t+1):this.resetScroll(!0)},this.handleScroll=()=>{requestAnimationFrame(()=>{this.currentSlide=this.index_slideCurrent,this.scrollTimer&&clearTimeout(this.scrollTimer),this._updateScrollProgress(),this.scrollTimer=window.setTimeout(()=>{this.prevBtn&&(this.prevBtn.disabled=!1),this.nextBtn&&(this.nextBtn.disabled=!1),this.pageCounter&&this.setupPageCounter(),this.loop&&this.slidesWrapper.scrollLeft<this.pageWidth*(this.n_slidesCloned-1/2)&&this.resetScroll(!0),this.loop&&this.slidesWrapper.scrollLeft>this.pageWidth*(this.n_slides-1+this.n_slidesCloned+1/2)&&this.resetScroll(!1)},200)})},this.handleResize=()=>{requestAnimationFrame(()=>{this.isDesktop=window.matchMedia("(min-width: 768px)").matches,!(this.isDesktop&&this.isMobileOnly||!this.isDesktop&&this.isDesktopOnly)&&(this.initializeCarousel(),this.isPlaying=!1,this.slideInterval>0&&(this.isPlaying=!0),(this.isDesktop&&this.isMobileOnly||!this.isDesktop&&this.isDesktopOnly)&&!this.eventListenersHaveBeenAdded&&this.addEventListeners(),this.navDotsWrapper&&this.setupNavDots(),this.loop&&this.setupLoop(),this.pageCounter&&this.setupPageCounter())})},this.isDesktop=window.matchMedia("(min-width: 768px)").matches,this.play=this.play.bind(this),this.stop=this.stop.bind(this),this.goto=this.goto.bind(this),this.resetScroll=this.resetScroll.bind(this),this.markNavdot=this.markNavdot.bind(this),this.updateNavdot=this.updateNavdot.bind(this),this.setUpIntersectionObserver=this.setUpIntersectionObserver.bind(this),this.throttledPrevClick=p(this.handlePrevClick,400),this.throttledNextClick=p(this.handleNextClick,400)}connectedCallback(){if(super.connectedCallback(),this.slides.length===0){console.warn("No slides found in the carousel");return}this.init(),this._setupSlidesMutationObserver()}_setupSlidesMutationObserver(){this._slidesMutationWatcher||this.loop||(this._slidesMutationWatcher=new MutationObserver(()=>{this._isCloningSlides||this.init()}),this._slidesMutationWatcher.observe(this.slidesWrapper,{childList:!0}))}init(){this.initializeCarousel(),this.addEventListeners(),this.slideInterval>0&&this.setupAutoplay(),this.navDotsWrapper&&this.setupNavDots(),this.loop&&this.setupLoop(),this.pageCounter&&this.setupPageCounter()}disconnectedCallback(){var t;super.disconnectedCallback(),this.slidesWrapper.removeEventListener("scroll",this.handleScroll),this.removeEventListener("pointerenter",this.stop),this.removeEventListener("pointerleave",this.play),this.removeEventListener("focus",this.stop,!0),this.removeEventListener("blur",this.play,!0),this.removeEventListener("touchstart",this.stop),(t=this.resizeObserver)==null||t.disconnect(),this.prevBtn&&this.prevBtn.removeEventListener("click",this.throttledPrevClick),this.nextBtn&&this.nextBtn.removeEventListener("click",this.throttledNext
1Click),this.scrollTimer&&clearTimeout(this.scrollTimer)}updated(t){super.updated(t),!(this.isDesktop&&this.isMobileOnly||!this.isDesktop&&this.isDesktopOnly)&&(t.has("currentSlide")&&((this.prevBtn||this.nextBtn)&&!this.loop&&this.handlePrevNextBtn(),this.navDotsWrapper&&(this.navDots.forEach(e=>{e.setAttribute("aria-disabled","false")}),this.updateNavdot()),this.connectedCarousels&&this._syncConnectedCarousels()),t.has("isPlaying")&&(this.isPlaying?this.play():this.stop()))}initializeCarousel(){this.itemsToShow=this.isDesktop?parseInt(this.dataset.itemsToShow||"1",10):parseInt(this.dataset.itemsToShowMobile||"1",10),this.itemsToScroll=this.isDesktop?parseInt(this.dataset.itemsToScroll||"1",10):1,this.n_slides=Array.from(this.slides).filter(t=>!t.hasAttribute("aria-hidden")).length,this.n_slidesCloned=this.dataset.loop==="true"?1:0,this.slideWidth=this.slides[0].offsetWidth,this.spaceBtwSlides=this.getSpaceBetweenSlides(),this.slidesWrapper.style.scrollBehavior="smooth",this.n_pages=this.itemsToShow===1?this.n_slides:Math.ceil((this.n_slides-this.itemsToShow)/this.itemsToScroll+1),this.pageWidth=this.itemsToShow===1?this.slideWidth:this.slideWidth*this.itemsToShow+this.spaceBtwSlides*(this.itemsToShow-1)}setupPageCounter(){this.pageCounter&&(this.pageCounter.innerHTML=`${this.currentSlide+1} / ${this.n_pages}`,this.pageCounter.setAttribute("aria-label",`Page ${this.currentSlide+1} of ${this.n_pages}`))}generateNavDots(){this.navDotsWrapper?(this.navDotsWrapper.innerHTML="",this.navDotsWrapper.innerHTML=Array.from({length:this.n_pages},(t,e)=>`<button data-nav-dot="${e}" type="button" aria-label="${e+1} of ${this.n_pages}" aria-disabled="${e===0?"true":"false"}"></button>`).join("")):console.warn("No nav dots wrapper found in the carousel")}addEventListeners(){this.eventListenersHaveBeenAdded=!0,this.setUpResizeObserver(),this.slidesWrapper.addEventListener("scroll",this.handleScroll,{passive:!0}),this.prevBtn&&this.prevBtn.addEventListener("click",this.handlePrevClick),this.nextBtn&&this.nextBtn.addEventListener("click",this.handleNextClick)}setupAutoplay(){this.setUpIntersectionObserver(),this.addEventListener("pointerenter",()=>{this.isPlaying=!1}),this.addEventListener("pointerleave",()=>{this.isPlaying=!0}),this.addEventListener("focus",()=>{this.isPlaying=!1},!0),this.addEventListener("blur",()=>{this.matches(":hover")||(this.isPlaying=!0)},!0),this.addEventListener("touchstart",()=>{this.isPlaying=!1})}setupNavDots(){this.generateNavDots(),this.navDotsWrapper.addEventListener("click",t=>{const e=t.target,r=e.dataset.navDot?parseInt(e.dataset.navDot):-1;r>=0&&(this.goto(r),this.markNavdot(r))})}setupLoop(){this.slides.length!==0&&(this._isCloningSlides=!0,this.cloneSlide(this.slides[0],"end"),this.cloneSlide(this.slides[this.n_slides-1],"start"),this.handleAriaHiddenSlides(),this._isCloningSlides=!1)}cloneSlide(t,e){const r=t.cloneNode(!0);r.setAttribute("aria-hidden","true"),r.removeAttribute("tabindex"),e==="start"?this.slidesWrapper.prepend(r):this.slidesWrapper.append(r)}getSpaceBetweenSlides(){return Number(window.getComputedStyle(this.slidesWrapper).getPropertyValue("grid-column-gap").slice(0,-2))||0}get index_slideCurrent(){const t=this.itemsToScroll===1?this.slideWidth+this.spaceBtwSlides:this.pageWidth,e=Math.round(this.slidesWrapper.scrollLeft/t)-this.n_slidesCloned;return this.currentSlide=e,e}setUpIntersectionObserver(){const t=r=>{r.forEach(o=>{o.isIntersecting?this.isPlaying=!0:this.isPlaying=!1})};new IntersectionObserver(t,{threshold:.99}).observe(this)}handleAriaHiddenSlides(){this.slidesWrapper.querySelectorAll("[aria-hidden]").forEach(t=>{t.querySelectorAll("[tabindex], button, a").forEach(e=>{e.setAttribute("tabindex","-1")})})}_syncConnectedCarousels(){try{if(!this.connectedCarousels)return;this.connectedCarousels.forEach(t=>{const e=document.getElementById(t);e&&e!==this&&e.goto(this.currentSlide)})}catch(t){console.error("Error syncing connected carousels:",t)}}resetScroll(t){this.slidesWrapper.style.scrollBehavior="auto",requestAnimationFrame(()=>{this.slidesWrapper.scrollTo(this.pageWidth*(t?this.n_pages:this.n_slidesCloned),0),this.slidesWrapper.style.scrollBehavior="smooth"})}goto(t){this.prevBtn&&(this.prevBtn.disabled=!0),this.nextBtn&&(this.nextBtn.disabled=!0),this.currentSlide=t;const e=this.itemsToScroll===1?this.slideWidth+this.spaceBtwSlides:this.pageWidth;this.slidesWrapper.scrollTo(e*(t+this.n_slidesCloned),0)}play(){window.matchMedia("(prefers-reduced-motion: reduce)").matches||(this.intervalId&&window.clearInterval(this.intervalId),this.slidesWrapper.setAttribute("aria-live","off"),this.intervalId=window.setInterval(this.handleNextClick,this.slideInterval))}stop(){this.intervalId&&clearInterval(this.intervalId),this.slidesWrapper.setAttribute("aria-live","polite")}_updateScrollProgress(){const t=this.progressBar;if(!t)return;const e=this.slidesWrapper,r=e.scrollWidth-e.offsetWidth,o=r>0?e.scrollLeft/r*100:0;t.style.setProperty("--scroll",`${Math.ceil(o)}%`)}setUpResizeObserver(){this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.slidesWrapper)}markNavdot(t){t<0||t>=this.navDots.length||!this.navDots[t]||this.navDots[t].setAttribute("aria-disabled","true")}
1updateNavdot(){const t=this.index_slideCurrent;t<0||t>=this.n_pages||this.markNavdot(t)}handlePrevNextBtn(){this.currentSlide<=0&&this.prevBtn?(this.prevBtn.classList.add("disabled"),this.prevBtn.disabled=!0):this.prevBtn&&(this.prevBtn.classList.remove("disabled"),this.prevBtn.disabled=!1),this.currentSlide>=this.n_pages-1&&this.nextBtn?(this.nextBtn.classList.add("disabled"),this.nextBtn.disabled=!0):this.nextBtn&&(this.nextBtn.classList.remove("disabled"),this.nextBtn.disabled=!1)}}n([a("[data-carousel-slides]")],i.prototype,"slidesWrapper");n([c("[data-carousel-slide]")],i.prototype,"slides");n([a("[data-nav-dots-wrapper]")],i.prototype,"navDotsWrapper");n([c("[data-nav-dot]")],i.prototype,"navDots");n([a("[data-carousel-prev]")],i.prototype,"prevBtn");n([a("[data-carousel-next]")],i.prototype,"nextBtn");n([a("[data-page-counter]")],i.prototype,"pageCounter");n([a("[data-progress]")],i.prototype,"progressBar");n([l({type:Number,attribute:"data-slide-interval",converter:{fromAttribute:s=>s?parseInt(s,10):0}})],i.prototype,"slideInterval");n([l({type:Boolean,attribute:"data-is-mobile-only",converter:s=>s==="true"})],i.prototype,"isMobileOnly");n([l({type:Boolean,attribute:"data-is-desktop-only",converter:s=>s==="true"})],i.prototype,"isDesktopOnly");n([l({type:Number,attribute:"data-items-to-scroll",converter:{fromAttribute:s=>s?parseInt(s,10):1}})],i.prototype,"itemsToScroll");n([l({type:Boolean,attribute:"data-loop",converter(s){return s==="true"}})],i.prototype,"loop");n([l({type:Boolean,reflect:!0})],i.prototype,"isPlaying");n([l({type:String,attribute:"connected-carousels",converter:s=>s==null?void 0:s.split(",")})],i.prototype,"connectedCarousels");n([v()],i.prototype,"currentSlide");customElements.get("core-carousel")||customElements.define("core-carousel",i);export{i as C};
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.