(()=>{window.addEventListener("load",()=>{g.init()});var g={lightBox:null,lightBoxView:null,lightBoxCounter:null,lightBoxCaption:null,lightBoxThumblist:null,lightBoxImg:null,lightBoxTimer:null,lightBoxButtons:{},gallery:null,galleryId:null,galleryIndex:null,galleryData:{},init(){this.lightBox=document.querySelector(".cm4all-gallery-lightbox"),this.lightBox||(document.body.insertAdjacentHTML("beforeend",`
`),this.lightBox=document.querySelector(".cm4all-gallery-lightbox"),this.lightBoxView=this.lightBox.querySelector(".cm4all-gallery-lightbox-view"),this.lightBoxCounter=this.lightBox.querySelector(".cm4all-gallery-lightbox-counter"),this.lightBoxCaption=this.lightBox.querySelector(".cm4all-gallery-lightbox-caption"),this.lightBoxThumblist=this.lightBox.querySelector(".cm4all-gallery-lightbox-thumblist"),this.addNavigation(),this.addKeyListeners(),this.addMouseListener(),this.addTouchListeners()),this.update()},update(){this.galleryData={},[...document.querySelectorAll(".cm4all-gallery")].forEach((t,i)=>{let e=t.dataset.showLightbox==="true",s=t.dataset.showCaption==="true",o=t.dataset.showThumblist==="true";e&&(this.galleryData[i]={showLightbox:e,showCaption:s,showThumblist:o,images:[]},[...t.querySelectorAll(".cm4all-gallery-item")].forEach((a,h)=>{this.galleryData[i].images.push({id:a.dataset.lightboxId,alt:a.dataset.lightboxAlt,link:a.dataset.lightboxLink,caption:a.dataset.lightboxCaption,thumbUrl:a.dataset.lightboxThumb,mediumUrl:a.dataset.lightboxMedium,largeUrl:a.dataset.lightboxLarge,fullUrl:a.dataset.lightboxFull}),a.addEventListener("click",r=>{this.show(i,h),r.stopPropagation()},!1)}))})},click(l){switch(l){case"screen":this.stop(),this.lightBoxImg.requestFullscreen();break;case"link":this.stop(),this.link();break;case"play":this.play();break;case"stop":this.stop();break;case"back":this.stop(),this.back();break;case"next":this.stop(),this.next();break;case"close":this.stop(),this.show();break;default:break}},show(l,t){if(typeof t=="number"){if(t=Math.min(Math.max(t,0),this.galleryData[l].images.length-1),l===this.galleryId&&t===this.galleryIndex)return;let i=l!==this.galleryId;this.galleryId=l,this.galleryIndex=t,this.gallery=this.galleryData[this.galleryId],i&&(this.createView(),this.createThumblist()),this.updateView(),this.updateNavigation(),this.updateCounter(),this.updateCaption(),this.updateThumblist(),this.lightBox.classList.remove("hidden"),document.body.classList.add("noScroll")}else this.lightBox.classList.add("hidden"),document.body.classList.remove("noScroll"),this.galleryId=null,this.galleryIndex=null,this.gallery=null,this.stop()},back(){this.show(this.galleryId,this.galleryIndex-1)},next(){this.show(this.galleryId,this.galleryIndex+1)},play(){this.lightBoxTimer?(clearInterval(this.lightBoxTimer),this.lightBoxTimer=null):(this.next(),this.lightBoxTimer=setInterval(()=>{this.gallery.images.length-1===this.galleryIndex?this.stop():this.next()},3e3)),this.updatePlayButton()},stop(){this.lightBoxTimer&&this.play()},link(){window.open(this.gallery.images[this.galleryIndex].link,"cm4all-gallery")},addNavigation(){[...this.lightBox.querySelectorAll(".cm4all-gallery-lightbox-button")].forEach(t=>{let i=t.getAttribute("aria-label");t.addEventListener("click",e=>{this.click(i),e.stopPropagation()},!1),this.lightBoxButtons[i]=t})},addKeyListeners(){document.addEventListener("keydown",l=>{if(this.gallery)switch(l.key){case"ArrowLeft":this.back();break;case"ArrowRight":this.next();break;case"Escape":this.show();break;case"Enter":l.target.ariaLabel==="thumb"&&document.activeElement.click();break;case" ":this.play();break;default:break}l.stopPropagation()},!1)},addMouseListener(){this.lightBox.addEventListener("click",l=>{(l.target===this.lightBox||l.target===this.lightBoxView)&&(this.click("close"),l.stopPropagation())},!1)},addTouchListeners(){let l=null;document.addEventListener("touchstart",t=>{l=t.changedTouches[0]}),document.addEventListener("touchend",t=>{let i=t.changedTouches[0];i.screenX