{"version":3,"file":"initialiseCarousel-DtphTxwi.js","sources":["../../../app/javascript/modules/initialiseCarousel.js"],"sourcesContent":["export default class Carousel {\n constructor(carouselDotsSelector, slidesSelector) {\n this.carouselDots = document.querySelectorAll(carouselDotsSelector);\n this.slides = document.querySelectorAll(slidesSelector);\n }\n\n init() {\n const observer = new IntersectionObserver(\n observations => {\n observations.forEach(observation => {\n if (observation.isIntersecting) {\n const index = Array.from(this.slides).indexOf(observation.target);\n\n this.carouselDots.forEach(dot => {\n dot.classList.remove(\"bg-ink\");\n dot.classList.add(\"bg-ink-3\");\n });\n\n if (index >= 0 && index < this.carouselDots.length) {\n this.carouselDots[index].classList.remove(\"bg-ink-3\");\n this.carouselDots[index].classList.add(\"bg-ink\");\n }\n }\n });\n },\n {\n threshold: 0.6\n }\n );\n\n this.slides.forEach(slide => observer.observe(slide));\n }\n}\n"],"names":["Carousel","carouselDotsSelector","slidesSelector","observer","observations","observation","index","dot","slide"],"mappings":"AAAe,MAAMA,CAAS,CAC5B,YAAYC,EAAsBC,EAAgB,CAChD,KAAK,aAAe,SAAS,iBAAiBD,CAAoB,EAClE,KAAK,OAAS,SAAS,iBAAiBC,CAAc,CAC1D,CAEE,MAAO,CACL,MAAMC,EAAW,IAAI,qBACnBC,GAAgB,CACdA,EAAa,QAAQC,GAAe,CAClC,GAAIA,EAAY,eAAgB,CAC9B,MAAMC,EAAQ,MAAM,KAAK,KAAK,MAAM,EAAE,QAAQD,EAAY,MAAM,EAEhE,KAAK,aAAa,QAAQE,GAAO,CAC/BA,EAAI,UAAU,OAAO,QAAQ,EAC7BA,EAAI,UAAU,IAAI,UAAU,CAC1C,CAAa,EAEGD,GAAS,GAAKA,EAAQ,KAAK,aAAa,SAC1C,KAAK,aAAaA,CAAK,EAAE,UAAU,OAAO,UAAU,EACpD,KAAK,aAAaA,CAAK,EAAE,UAAU,IAAI,QAAQ,EAE7D,CACA,CAAS,CACF,EACD,CACE,UAAW,EACnB,CACK,EAED,KAAK,OAAO,QAAQE,GAASL,EAAS,QAAQK,CAAK,CAAC,CACxD,CACA"}