'use client';
import{jsx as o,jsxs as e,Fragment as r}from"react/jsx-runtime";import{useCurrentDevice as t,filterToolbarPreview as a,isEmptyChildren as s}from"@gem-sdk/core";import{forwardRef as l,Children as i,isValidElement as d}from"react";import n from"../dot/Dots.js";import m from"../arrow/Arrow.js";import{mappingNavigationCarousel as c}from"../arrow/common/helpers.js";import{useCarousel as p}from"../../hooks/useCarousel.js";import{getClass as u}from"./common/classes.js";import{getStyle as h}from"./common/styles.js";import{getAttr as f}from"./common/attrs.js";import{getData as k}from"./common/helpers.js";let Carousel=l((l,w)=>{let{children:C,builderAttrs:S,builderProps:v,styles:y,isHiddenArrowWhenDisabled:g=!0,hiddenDotWhenOnlyOne:j,elmRef:b}=l,P=c(l.setting),x={...l,setting:P},{arrowButtonSize:z,arrowBackgroundColor:N,arrowGapToEachSide:T="16",roundedArrow:A,arrowIconSize:I,arrowCustomColor:W,arrowBorder:B,arrowShadow:D,showWhenHover:H}=P??{},{totalSlideItem:O,isInfinity:E,slider:G,currentSlide:F,localRef:U,showNavigation:q,isRenderDots:J,slideMaxIndex:K,handleDotClick:L,getItemsPerPage:M,sliderRef:Q,handleNextAndPrevSlide:R,dispatchEventSelectSlide:V,getNumberOfFullWidthShow:X}=p(x,w),{loopConfig:Y,arrowShowConfig:Z}=k(x),{rootClassRender:$,wrapperClassRender:_,wrapperInnerClass:oo,sliderClass:oe}=u(x),{rootStyleRender:or,wrapperStyleRender:ot,wrapperInnerStyle:oa}=h(x),{rootAttrRender:os,sliderAttr:ol}=f(x),oi=t(),od=P?.sneakPeak?.[oi],on=e=>{let r="next"===e,t=r?!E&&G?.track?.details?.abs===K:!E&&G?.track?.details?.abs===0;return o(m,{uid:v?.uid,custom:P?.arrowCustom??"",showArrow:Z,arrowButtonSize:z||{},arrowIconSize:I||{},arrowBackgroundColor:N||"",arrowCustomColor:W,gapToEachSize:T,showWhenHover:H,arrowBorder:B||{},arrowCorner:A||{},arrowShadow:D||{},onClick:o=>{o.stopPropagation(),R(e)},left:!r,disabled:t,vertical:P?.vertical,isHiddenWhenDisabled:g,rootId:l?.parentClass})},om=()=>o(r,{children:s(C)?o("div",{children:"No Slider"}):i.map(a(C),(e,r)=>d(e)?o(e.type,{...e.props,index:r,parentSettings:P,parentStyle:y,background:P?.background,parentUid:v?.uid,dispatchEventSelectSlide:V}):null)});return o("div",{ref:b,...os,className:$,style:or,children:e("div",{ref:U,...S,className:_,style:ot,children:[e("div",{className:oo,style:oa,children:[q&&on("prev"),o("div",{ref:Q,...ol,className:oe,children:om()}),q&&on("next")]}),J&&o(n,{showDots:P?.dot,dotStyle:P?.dotStyle,totalSlideItem:O,slideItemsPerPage:M(),currentSlide:F,enabledSneakPeak:od,vertical:P?.vertical,loop:Y,dotColor:P?.dotColor,dotGapToCarousel:P?.dotGapToCarousel,dotSize:P?.dotSize,dotActiveColor:P?.dotActiveColor,hiddenWhenOnlyOne:j,sneakPeakType:P?.sneakPeakType,numberOfFullWidthShow:X(oi),onHandleClick:L}),a(C,!0)]})})});export{Carousel as default};
