"use strict";var jsxRuntime=require("react/jsx-runtime"),React=require("react"),styles=require("./common/styles.js");function Swiper(e){let t=React.useRef(null),{children:r,totalSlides:s,onSwiperReset:i,onSwiperReady:n,sliderClass:c,sliderOrder:u,thumbsSwiper:a,...p}=e,[l,o]=React.useState(!1),w=React.useMemo(()=>a?{"thumbs-swiper":a}:{},[a]),f=styles.getStyleSwiperContainer(),d="object"==typeof e.autoplay&&null!==e.autoplay?e.autoplay.pauseOnMouseEnter:void 0,y=()=>{t.current?.swiper&&t.current.swiper.wrapperEl.style.setProperty("width",`${t.current.swiper.width}px`)};return React.useEffect(()=>{let e=async()=>{let e=await import("@gem-sdk/swiper/element/bundle");e.register(),o(!0)};e()},[]),React.useEffect(()=>{l&&(Object.assign(t.current,p),t.current.initialize(),n?.(t.current.swiper),y())},[l]),React.useEffect(()=>{t.current?.swiper&&(t.current.swiper.destroy(!1,!1),Object.assign(t.current,p),t.current.initialize(),n(t.current.swiper),i())},[p.dir,p.loop,d,p.slidesPerView,n,i,p.spaceBetween,p.slidesOffsetBefore]),React.useEffect(()=>{let e=t.current;e&&(Object.assign(e,p),e.swiper?.update(),y())},[p]),React.useEffect(()=>{i()},[u,i]),React.useEffect(()=>{let e=t.current;if(!e)return;let r=()=>{y()};return e.addEventListener("swiperresize",r),()=>{e.removeEventListener("swiperresize",r)}},[]),jsxRuntime.jsx("swiper-container",{init:!1,ref:t,class:c,style:{...f,display:l?"block":"none"},...w,children:r})}exports.Swiper=Swiper;
