{"version":3,"file":"imagesCarousel-BgablUkg.js","sources":["../../src/scripts/modules/imagesCarousel.ts"],"sourcesContent":["import { Component } from '@verndale/core';\nimport Swiper from 'swiper';\nimport { Navigation, Keyboard, Pagination, Controller, A11y } from 'swiper/modules';\nimport 'swiper/css/bundle';\n\nclass ImagesCarousel extends Component {\n private separator: string;\n public imagesCarousel: Swiper | null;\n\n constructor(el: HTMLElement) {\n super(el);\n this.imagesCarousel = null;\n this.separator = this.el.dataset.separator || '';\n Swiper.use([Navigation, Keyboard, Pagination, Controller, A11y]);\n this.initSwiper();\n }\n\n setupDefaults() {\n this.dom = {\n el: this.el,\n swiperContainer: this.el.querySelector('.swiper'),\n swiperWrapper: this.el.querySelector('.swiper-wrapper'),\n swiperItems: this.el.querySelectorAll('.swiper-slide'),\n pagination: this.el.querySelector('.images-carousel__slider-pagination'),\n prevButton: this.el.querySelector('.btn-previous-slide'),\n nextButton: this.el.querySelector('.btn-next-slide'),\n controlsContainer: this.el.querySelector(\n '.images-carousel__slider-controls-container'\n ),\n captions: this.el.querySelectorAll('.images-carousel__slide-caption')\n };\n }\n\n addListeners() {\n window.addEventListener('resize', this.initSwiper.bind(this));\n }\n\n initSwiper() {\n if (\n this.imagesCarousel &&\n this.imagesCarousel.destroy &&\n typeof this.imagesCarousel.destroy === 'function'\n )\n this.imagesCarousel.destroy();\n\n this.imagesCarousel = new Swiper(this.dom.swiperContainer as HTMLElement, {\n pagination: {\n el: this.dom.pagination as HTMLElement,\n type: 'custom',\n renderCustom: (_self, current, total) => {\n return `${current} ${this.separator} ${total}`;\n }\n },\n on: {\n init: () => {\n if ((this.dom.captions as NodeList).length > 0) {\n let maxCaptionHeight = 0;\n (this.dom.captions as NodeList).forEach(caption => {\n const captionHeight = (caption as HTMLElement).offsetHeight;\n if (captionHeight > maxCaptionHeight) {\n maxCaptionHeight = captionHeight;\n }\n });\n (this.dom.controlsContainer as HTMLElement).style.setProperty(\n '--caption-height',\n `${maxCaptionHeight - 1}px`\n );\n (this.dom.swiperWrapper as HTMLElement).style.height = 'fit-content';\n } else {\n (this.dom.controlsContainer as HTMLElement).style.setProperty('--caption-height', '0');\n }\n }\n },\n a11y: {\n enabled: true,\n prevSlideMessage: 'Previous slide',\n nextSlideMessage: 'Next slide'\n },\n navigation: {\n nextEl: this.dom.nextButton as HTMLElement,\n prevEl: this.dom.prevButton as HTMLElement\n },\n autoHeight: true,\n slidesPerView: 1,\n loop: true\n });\n }\n}\n\nexport default ImagesCarousel;\n"],"names":["ImagesCarousel","Component","el","__publicField","Swiper","Navigation","Keyboard","Pagination","Controller","A11y","_self","current","total","maxCaptionHeight","caption","captionHeight"],"mappings":"gZAKA,MAAMA,UAAuBC,CAAU,CAIrC,YAAYC,EAAiB,CAC3B,MAAMA,CAAE,EAJFC,EAAA,kBACDA,EAAA,uBAIL,KAAK,eAAiB,KACtB,KAAK,UAAY,KAAK,GAAG,QAAQ,WAAa,GAC9CC,EAAO,IAAI,CAACC,EAAYC,EAAUC,EAAYC,EAAYC,CAAI,CAAC,EAC/D,KAAK,WAAW,CAClB,CAEA,eAAgB,CACd,KAAK,IAAM,CACT,GAAI,KAAK,GACT,gBAAiB,KAAK,GAAG,cAA2B,SAAS,EAC7D,cAAe,KAAK,GAAG,cAA2B,iBAAiB,EACnE,YAAa,KAAK,GAAG,iBAA8B,eAAe,EAClE,WAAY,KAAK,GAAG,cAA2B,qCAAqC,EACpF,WAAY,KAAK,GAAG,cAA2B,qBAAqB,EACpE,WAAY,KAAK,GAAG,cAA2B,iBAAiB,EAChE,kBAAmB,KAAK,GAAG,cACzB,6CACF,EACA,SAAU,KAAK,GAAG,iBAA8B,iCAAiC,CAAA,CAErF,CAEA,cAAe,CACb,OAAO,iBAAiB,SAAU,KAAK,WAAW,KAAK,IAAI,CAAC,CAC9D,CAEA,YAAa,CAET,KAAK,gBACL,KAAK,eAAe,SACpB,OAAO,KAAK,eAAe,SAAY,YAEvC,KAAK,eAAe,UAEtB,KAAK,eAAiB,IAAIL,EAAO,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