"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),S=()=>{const[n,s]=t.useState(null),[u,o]=t.useState(0),[c,l]=t.useState(!0),[f,i]=t.useState(!1),[r,d]=t.useState(!1),[b,h]=t.useState(!1),a=t.useCallback(e=>{o(e.activeIndex),i(e.isEnd),l(e.isBeginning)},[]),k=t.useCallback(()=>{n&&(n.slidePrev(),a(n))},[n,a]),v=t.useCallback(()=>{n&&(n.slideNext(),a(n))},[n,a]),g=t.useCallback(e=>{n&&(n.slideTo(e),a(n))},[n,a]),C=e=>{s(e),d(e==null?void 0:e.isLocked),h(e==null?void 0:e.isLocked),a(e)},E=t.useCallback(e=>{i(e.isEnd),d(e==null?void 0:e.isLocked),h(e==null?void 0:e.isLocked),a(e)},[a]),y=t.useCallback(()=>{i(!0),l(!1)},[]),L=t.useCallback(()=>{l(!0),i(!1)},[]);return{swiper:n,setSwiper:s,activeIndex:u,setActiveIndex:o,isEnd:f,setIsEnd:i,hideNav:r,handleSlideChange:a,handlePrevClick:k,handleNextClick:v,handleSlideTo:g,onSwiperInit:C,handleSwiperResize:E,isBeginning:c,isLocked:b,setIsBeginning:l,handleReachEnd:y,handleReachBeginning:L}},I=(n=3e3)=>{const s=S(),[u,o]=t.useState(!0),c=t.useRef(null),l=t.useCallback(()=>{o(!1),c.current&&(clearInterval(c.current),c.current=null)},[]),f=t.useCallback(()=>{o(!0)},[]),i=t.useCallback(()=>{l()},[l]);return t.useEffect(()=>{if(!(!u||!s.swiper||s.swiper.slides.length<=1))return c.current=setInterval(()=>{s.swiper&&(s.isEnd?s.swiper.slideTo(0):s.swiper.slideNext())},n),()=>{c.current&&(clearInterval(c.current),c.current=null)}},[u,s.swiper,s.isEnd,n]),t.useEffect(()=>{const r=()=>l(),d=()=>{document.hidden&&l()};return window.addEventListener("beforeunload",r),document.addEventListener("visibilitychange",d),()=>{window.removeEventListener("beforeunload",r),document.removeEventListener("visibilitychange",d)}},[l]),{...s,isAutoPlay:u,stopAutoPlay:l,startAutoPlay:f,handleUserInteraction:i}};exports.useSwiper=S;exports.useSwiperWithAutoPlay=I;
