(()=>{"use strict";function e(){document.querySelectorAll(".flexa-product-image").forEach(e=>function(e){const t=e.querySelector(".flexa-product-image__main img"),o=e.querySelector(".flexa-product-image__thumbs"),i=Array.from(e.querySelectorAll(".flexa-product-image__thumb"));if(!t||0===i.length)return;const l=e.classList.contains("flexa-product-image--pos-left")||e.classList.contains("flexa-product-image--pos-right"),a=e=>{const a=e.dataset.full;a&&(t.src=a,t.removeAttribute("srcset")),i.forEach(t=>t.classList.toggle("is-active",t===e)),(e=>{if(!o)return;const t=o.getBoundingClientRect(),i=e.getBoundingClientRect();l?i.top<t.top?o.scrollTop-=t.top-i.top+8:i.bottom>t.bottom&&(o.scrollTop+=i.bottom-t.bottom+8):i.left<t.left?o.scrollLeft-=t.left-i.left+8:i.right>t.right&&(o.scrollLeft+=i.right-t.right+8)})(e)};i.forEach(e=>{e.addEventListener("click",()=>a(e))});const n=e.querySelector(".flexa-product-image__nav--prev"),r=e.querySelector(".flexa-product-image__nav--next");if(o&&(n||r)){const e=()=>l?o.scrollTop:o.scrollLeft,t=()=>(l?o.scrollHeight-o.clientHeight:o.scrollWidth-o.clientWidth)-1,i=()=>Math.max(120,.9*(l?o.clientHeight:o.clientWidth)),a=()=>{n&&(n.disabled=e()<=0),r&&(r.disabled=e()>=t())};n?.addEventListener("click",()=>o.scrollBy(l?{top:-i(),behavior:"smooth"}:{left:-i(),behavior:"smooth"})),r?.addEventListener("click",()=>o.scrollBy(l?{top:i(),behavior:"smooth"}:{left:i(),behavior:"smooth"})),o.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),a()}const c="1"===e.dataset.flexaAutoplay,s="function"==typeof window.matchMedia&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;if(c&&!s&&i.length>1){const t=Math.max(1e3,parseInt(e.dataset.flexaAutoplaySpeed||"4000",10)||4e3);let o=0;const l=()=>{const e=i.findIndex(e=>e.classList.contains("is-active")),t=i[(e+1)%i.length];t&&a(t)},n=()=>{o&&(window.clearInterval(o),o=0)},r=()=>{n(),o=window.setInterval(l,t)};e.addEventListener("mouseenter",n),e.addEventListener("mouseleave",r),r()}}(e))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e()})();