"use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("./common/styles.js");require("@gem-sdk/swiper/element/bundle").register(),exports.Swiper=function(n){let i=r.useRef(null),s=r.useRef(null),{children:u,totalSlides:l,onSwiperReset:c,onSwiperReady:p,sliderClass:a,sliderOrder:o,thumbsSwiper:w,...d}=n,f=r.useMemo(()=>w?{"thumbs-swiper":w}:{},[w]),m=t.getStyleSwiperContainer(),y=(e,r)=>{if(!e?.wrapperEl)return!1;let t=e.el,n=r||e.width||t?.clientWidth||t?.parentElement?.clientWidth||0;return!(n<=0)&&(e.wrapperEl.style.setProperty("width",`${n}px`),!0)},b=r.useCallback(({width:e}={})=>{!y(i.current?.swiper,e)&&"undefined"!=typeof window&&i.current&&(s.current&&cancelAnimationFrame(s.current),s.current=window.requestAnimationFrame(()=>{s.current=null,y(i.current?.swiper,e)}))},[]);return r.useEffect(()=>{let e;let r=i.current;if(!r)return;let t="function"==typeof r.closest&&!!r.closest("swiper-slide");Object.assign(r,{...d,...t&&{nested:!0}}),r.initialize?.(),p?.(r.swiper),b(),r.swiper?.on?.("resize",b);let n=r.parentElement;return n&&"undefined"!=typeof ResizeObserver&&(e=new ResizeObserver(()=>{let e=i.current?.swiper;e&&!(e.width>0)&&(b(),e.update?.())})).observe(n),()=>{r.swiper?.off?.("resize",b),e?.disconnect(),c(),s.current&&(cancelAnimationFrame(s.current),s.current=null)}},[]),r.useEffect(()=>{let e=i.current,r=e?.swiper;e&&r&&!r.destroyed&&(Object.assign(e,d),r.update(),b())},[JSON.stringify(d)]),r.useEffect(()=>{c()},[o,c]),e.jsx("swiper-container",{init:!1,ref:i,class:a,style:{...m},...f,children:u})};
