var V=Object.defineProperty;var q=i=>{throw TypeError(i)};var k=(i,e,t)=>e in i?V(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var x=(i,e,t)=>k(i,typeof e!="symbol"?e+"":e,t),O=(i,e,t)=>e.has(i)||q("Cannot "+t);var r=(i,e,t)=>(O(i,e,"read from private field"),t?t.call(i):e.get(i)),T=(i,e,t)=>e.has(i)?q("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(i):e.set(i,t),H=(i,e,t,s)=>(O(i,e,"write to private field"),s?s.call(i,t):e.set(i,t),t);var l,c,b;const n=class n{static init(){return r(n,l)||H(n,l,new n),r(n,l).initCarousels(document),r(n,l)}static reInit(e=document){if(!r(n,l)){n.init();return}r(n,l).initCarousels(e)}static cleanupHoverZones(e){const t=r(n,c).get(e);t&&(t.abort(),r(n,c).delete(e))}static addHoverNavigationZones(e,t){if(!t.slides||t.slides.length<=1||e.querySelector(".fct-hover-zone")||!window.matchMedia("(hover: hover)").matches)return;const s=r(n,c).get(e);s&&s.abort();const o=new AbortController;r(n,c).set(e,o);const a=document.createElement("div"),d=document.createElement("div");a.className="fct-hover-zone fct-hover-left",d.className="fct-hover-zone fct-hover-right";const v=e.querySelector(".swiper-wrapper");if(v){const f=v.offsetHeight+"px";a.style.height=f,d.style.height=f}let u=!1;const w=f=>{u||(u=!0,f==="prev"?t.slidePrev():t.slideNext(),setTimeout(()=>{u=!1},n.SLIDE_THROTTLE_MS))};a.addEventListener("mouseenter",()=>{w("prev")},{signal:o.signal}),d.addEventListener("mouseenter",()=>{w("next")},{signal:o.signal}),e.appendChild(a),e.appendChild(d)}initCarousels(e=document){if(!e||!e.querySelectorAll)return;const t=e.querySelectorAll(".swiper.fct-product-carousel[data-fluent-cart-product-carousel]");t.length&&t.forEach(s=>{if(s.swiper)return;let o={};try{o=JSON.parse(s.getAttribute("data-carousel-settings")||"{}")}catch(p){console.warn("FluentCart: Invalid carousel settings",p)}const a=Math.max(1,Number(o.slidesToShow||3)),d=Number(o.spaceBetween||16),v=s.querySelector(".swiper-button-next"),u=s.querySelector(".swiper-button-prev"),w=s.querySelector(".swiper-pagination"),f=o.pagination==="yes"||o.dots==="yes",Z={bullets:"bullets",dots:"bullets",fraction:"fraction",progress:"progressbar",segmented:"custom"},h=o.autoplay||"no",A=h==="yes"||h==="hover"?{delay:Number(o.autoplayDelay||3e3),disableOnInteraction:!1,pauseOnMouseEnter:h==="yes"}:!1;let C=!1;if(f&&w){const p=Z[o.paginationType]||"bullets";C={el:w,clickable:!0,type:p},o.paginationType==="segmented"&&(C.renderCustom=function(E,g,y){let L="";for(let S=1;S<=y;S++){let N="swiper-pagination-segment";S<g?N+=" is-completed":S===g&&(N+=" is-active"),L+=`<div class="${N}"></div>`}return L+=`<span class="segment-counter">${g} / ${y}</span>`,L})}const I={slidesPerView:a,spaceBetween:d,loop:o.infinite==="yes",grabCursor:!0,watchOverflow:!0,observer:!0,observeParents:!0,rtl:document.documentElement.dir==="rtl",autoplay:A,on:{init(p){o.autoplay==="hover"&&p.autoplay.stop()}},navigation:o.arrows==="yes"&&v&&u?{nextEl:v,prevEl:u}:!1,pagination:C,breakpoints:{0:{slidesPerView:1},640:{slidesPerView:Math.min(2,a)},1024:{slidesPerView:Math.min(3,a)},1280:{slidesPerView:a}}},m=new Swiper(s,I);if(h==="hover"&&m.autoplay){const p=r(n,b).get(s);p&&p.abort();const E=new AbortController;r(n,b).set(s,E);const g=s.querySelector(".swiper-wrapper"),y=s.closest(".fct-product-carousel-wrapper");g&&g.addEventListener("mouseenter",()=>{m.autoplay.start()},{signal:E.signal}),y&&y.addEventListener("mouseleave",()=>{m.autoplay.stop()},{signal:E.signal})}h==="hover"&&n.addHoverNavigationZones(s,m),s.swiper=m})}};l=new WeakMap,c=new WeakMap,b=new WeakMap,T(n,l,null),x(n,"SLIDE_THROTTLE_MS",350),T(n,c,new WeakMap),T(n,b,new WeakMap);let M=n;window.FluentCartProductCarousel=M;document.addEventListener("DOMContentLoaded",()=>{M.init()});
