import"./hoisted.BphEqU85.js";class u{constructor(e,n,r){this.element=e,this.onSwipeLeft=n,this.onSwipeRight=r,this.init()}startX=0;startY=0;threshold=50;restrictedAngle=30;init(){this.element.addEventListener("touchstart",e=>this.handleTouchStart(e),{passive:!0}),this.element.addEventListener("touchmove",e=>this.handleTouchMove(e),{passive:!0})}handleTouchStart(e){const n=e.touches[0];this.startX=n.clientX,this.startY=n.clientY}handleTouchMove(e){if(!e.touches[0])return;const n=e.touches[0],r=this.startX-n.clientX,o=this.startY-n.clientY,c=Math.abs(Math.atan2(o,r)*180/Math.PI);Math.abs(r)>this.threshold&&c<=this.restrictedAngle&&(r>0?this.onSwipeLeft():this.onSwipeRight(),this.startX=n.clientX,this.startY=n.clientY)}}function h(t){const e={currentIndex:0,slides:Array.from(t.querySelectorAll("[data-slide]")),dots:Array.from(t.querySelectorAll("[data-dot]")),autoplayInterval:null};v(t,e),p(t,e),a(e)}function v(t,e){const n=t.querySelector("[data-prev]"),r=t.querySelector("[data-next]");n?.addEventListener("click",()=>{d(e),i(e)}),r?.addEventListener("click",()=>{l(e),i(e)}),e.dots.forEach((o,c)=>{o.addEventListener("click",()=>{s(e,c),i(e)})})}function p(t,e){new u(t,()=>{l(e),i(e)},()=>{d(e),i(e)})}function s(t,e){t.slides[t.currentIndex].classList.remove("opacity-100","z-10"),t.slides[t.currentIndex].classList.add("opacity-0","z-0"),t.dots[t.currentIndex].classList.remove("w-8","bg-primary"),t.dots[t.currentIndex].classList.add("w-4","bg-gray-600"),t.currentIndex=e,t.slides[t.currentIndex].classList.remove("opacity-0","z-0"),t.slides[t.currentIndex].classList.add("opacity-100","z-10"),t.dots[t.currentIndex].classList.remove("w-4","bg-gray-600"),t.dots[t.currentIndex].classList.add("w-8","bg-primary")}function l(t){s(t,(t.currentIndex+1)%t.slides.length)}function d(t){s(t,(t.currentIndex-1+t.slides.length)%t.slides.length)}function a(t){t.autoplayInterval=window.setInterval(()=>l(t),5e3)}function i(t){t.autoplayInterval&&(clearInterval(t.autoplayInterval),a(t))}document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll("[data-carousel]").forEach(t=>{t instanceof HTMLElement&&h(t)})});