(()=>{"use strict";let e=null,t=[],a=0,l=!0;function n(){e&&(e.remove(),e=null,document.removeEventListener("keydown",r))}function o(){if(!e)return;const n=t[a],o=e.querySelector(".flexa-images-gallery-lightbox__img"),i=e.querySelector(".flexa-images-gallery-lightbox__caption");o&&(o.src=n.src,o.alt=n.caption||""),i&&(i.textContent=l?n.caption:"",i.style.display=l&&n.caption?"":"none")}function i(e){t.length&&(a=(a+e+t.length)%t.length,o())}function r(e){"Escape"===e.key?n():"ArrowLeft"===e.key?i(-1):"ArrowRight"===e.key&&i(1)}function c(e,t,a){const l=document.createElement("button");return l.type="button",l.className=e,l.setAttribute("aria-label",t),l.innerHTML=`<svg viewBox="0 0 24 24" width="28" height="28" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="${a}"/></svg>`,l}function s(){document.querySelectorAll(".flexa-images-gallery[data-click]").forEach(s=>{const d=s.dataset.click,g=Array.from(s.querySelectorAll(".flexa-images-gallery__item"));g.forEach((m,u)=>{const h=m.querySelector(".flexa-images-gallery__media");h&&("lightbox"===d?(h.style.cursor="zoom-in",h.addEventListener("click",()=>{t=g.map(e=>{const t=e.querySelector(".flexa-images-gallery__image");return{src:e.dataset.full||t?.currentSrc||t?.src||"",caption:e.dataset.caption||""}}).filter(e=>e.src),a=u,l="1"!==s.dataset.lightboxNoCaption,function(a){n();const l=document.createElement("div");l.className="flexa-images-gallery-lightbox",a&&l.style.setProperty("--flexa-lightbox-bg",a);const s=document.createElement("button");s.type="button",s.className="flexa-images-gallery-lightbox__close",s.setAttribute("aria-label","Close"),s.textContent="×";const d=c("flexa-images-gallery-lightbox__nav flexa-images-gallery-lightbox__nav--prev","Previous","M15 18l-6-6 6-6"),g=c("flexa-images-gallery-lightbox__nav flexa-images-gallery-lightbox__nav--next","Next","M9 6l6 6-6 6"),m=document.createElement("figure");m.className="flexa-images-gallery-lightbox__figure";const u=document.createElement("img");u.className="flexa-images-gallery-lightbox__img",m.appendChild(u);const h=document.createElement("figcaption");h.className="flexa-images-gallery-lightbox__caption",m.appendChild(h),l.appendChild(s),t.length>1&&(l.appendChild(d),l.appendChild(g)),l.appendChild(m),d.addEventListener("click",e=>{e.stopPropagation(),i(-1)}),g.addEventListener("click",e=>{e.stopPropagation(),i(1)}),l.addEventListener("click",e=>{e.target!==l&&e.target!==s||n()}),document.body.appendChild(l),e=l,document.addEventListener("keydown",r),o()}(("dark"===document.documentElement.getAttribute("data-theme")||"dark"===document.body.getAttribute("data-theme")||window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches)&&s.dataset.lightboxBgDark?s.dataset.lightboxBgDark:s.dataset.lightboxBg||"")})):"media"===d&&(h.style.cursor="pointer",h.addEventListener("click",()=>{const e=m.dataset.full;e&&window.open(e,"_blank","noopener")})))})})}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",s):s()})();