function createSlideshow(slideshowContainer){const slides=Array.from(slideshowContainer.querySelectorAll('.collection-item'));let currentSlide=0;let isPlaying=true;let intervalId;let delay;if(slideshowContainer.hasAttribute('data-delay')){delay=slideshowContainer.getAttribute('data-delay');}else{delay=10000;}
function showNextSlide(){slides[currentSlide].classList.remove('playing');currentSlide=(currentSlide+1)%slides.length;slides[currentSlide].classList.add('playing');}
function startSlideshow(){intervalId=setInterval(showNextSlide,delay);slideshowContainer.classList.add('playing');slideshowContainer.classList.remove('paused');}
function stopSlideshow(){clearInterval(intervalId);slideshowContainer.classList.add('paused');slideshowContainer.classList.remove('playing');}
const playButton=slideshowContainer.querySelector('.blk-slideshow__play button');playButton.addEventListener('click',function(){if(isPlaying){stopSlideshow();isPlaying=false;}else{startSlideshow();isPlaying=true;}
this.blur();});slides.forEach((slide,index)=>{slide.addEventListener('click',function(){if(isPlaying){stopSlideshow();isPlaying=false;}else{startSlideshow();isPlaying=true;}});});slides[currentSlide].classList.add('playing');startSlideshow();}
const slideshowContainers=document.querySelectorAll('.blk-slideshow__container');slideshowContainers.forEach(createSlideshow);let carouselContainers=document.getElementsByClassName("blk-carousel");for(let carouselContainer of carouselContainers){let carouselLinks=carouselContainer.querySelectorAll(".blk-carousel__lightbox");for(let link of carouselLinks){link.addEventListener("click",e=>openGallery(e,carouselLinks));}}
let gridContainers=document.getElementsByClassName("blk-grid");for(let gridContainer of gridContainers){let gridLinks=gridContainer.querySelectorAll(".blk-grid__lightbox");for(let link of gridLinks){link.addEventListener("click",e=>openGallery(e,gridLinks));}}