import{jsx as e}from"react/jsx-runtime";import{useRef as r,useMemo as t,useEffect as i}from"react";import{getStyleSwiperContainer as s}from"./common/styles.js";import{register as n}from"@gem-sdk/swiper/element/bundle";function p(n){let p=r(null),{children:o,totalSlides:m,onSwiperReset:c,onSwiperReady:l,sliderClass:w,sliderOrder:u,thumbsSwiper:a,...d}=n,f=JSON.stringify(d),y=t(()=>a?{"thumbs-swiper":a}:{},[a]),b=s(),g=()=>{p.current?.swiper&&p.current.swiper.wrapperEl.style.setProperty("width",`${p.current.swiper.width}px`)};return i(()=>{let e=p.current;if(e)return Object.assign(e,d),e.initialize?.(),l?.(e.swiper),g(),e.addEventListener("swiperresize",g),()=>{e.removeEventListener("swiperresize",g),c()}},[]),i(()=>{let e=p.current,r=e?.swiper;e&&r&&!r.destroyed&&(Object.assign(e,d),r.update(),g())},[f]),i(()=>{c()},[u,c]),e("swiper-container",{init:!1,ref:p,class:w,style:{...b},...y,children:o})}n();export{p as Swiper};
