import{slicedToArray as t,defineProperty as o}from"../../../_virtual/_rollupPluginBabelHelpers.js";import e,{forwardRef as i,useRef as r,useState as s,useCallback as l,useMemo as n,useEffect as a}from"react";import{camelCase as u}from"es-toolkit";import d from"classnames";import{getStyle as p}from"../../helpers/typesciptCssModulesHelper.js";import m from"../../hooks/usePrevious/index.js";import c from"../../hooks/useMergeRef.js";import{ButtonWrapper as f}from"./ButtonWrapper.js";import{withStaticProps as v}from"../../types/withStaticProps.js";import"../../utils/colors-vars-map.js";import{getTestId as b}from"../../tests/testIds.js";import{ComponentDefaultTestId as h,ComponentVibeId as y}from"../../tests/constants.js";import B from"./ButtonGroup.module.scss.js";import j from"../../../components/button/dist/Button/Button.js";var k=v(i((function(i,v){var j=i.className,k=i.options,C=i.name,T=void 0===C?"":C,g=i.disabled,N=void 0!==g&&g,P=i.value,x=void 0===P?"":P,M=i.onSelect,O=i.size,S=void 0===O?"small":O,U=i.kind,D=void 0===U?"secondary":U,W=i.groupAriaLabel,z=void 0===W?"":W,E=i.tooltipPosition,G=i.tooltipHideDelay,H=i.tooltipShowDelay,I=i.tooltipContainerSelector,_=i.tooltipMoveBy,w=i.blurOnMouseUp,A=void 0===w||w,L=i.id,R=i["data-testid"],F=i.fullWidth,q=void 0!==F&&F,J=r(),K=c(v,J),Q=s(x),V=t(Q,2),X=V[0],Y=V[1],Z=m(x),$=l((function(t){N||t.disabled||(Y(t.value),M&&M(t.value,T))}),[M,N,T]),tt=function(t){return(null==t?void 0:t.value)===X},ot=n((function(){return k.find((function(t){return tt(t)}))}),[k,X]),et=n((function(){return k.map((function(t,i){var r=tt(t),s=0===i,l=i===k.length-1,n=tt(k[i+1]);return e.createElement(f,{key:t.value,size:S,onClick:function(){return $(t)},rightIcon:t.icon,leftIcon:t.leftIcon,active:r,rightFlat:i!==k.length-1,leftFlat:0!==i,kind:"tertiary",preventClickAnimation:!0,ariaLabel:t.ariaLabel,tooltipContent:t.tooltipContent,tooltipPosition:E,tooltipHideDelay:G,tooltipShowDelay:H,tooltipContainerSelector:I,tooltipMoveBy:_,blurOnMouseUp:A,fullWidth:q,className:d(B.button,B.optionText,o(o(o(o(o(o({},B.selected,r),B.disabled,N),B.buttonDisabled,t.disabled),B.fullWidth,q),B.startBorder,s),B.endBorder,l||!n)),activeButtonClassName:B.activeButton},t.text)}))}),[k,X,S,E,G,H,I,_,A,N,q,$]);return a((function(){x!==Z&&x!==X&&Y(x)}),[x,Z,X,Y]),e.createElement("div",{className:d(B.buttonGroup,j,p(B,u("kind-"+D)),o({},B.disabled,N)),id:L,"data-testid":R||b(h.BUTTON_GROUP,L),"data-vibe":y.BUTTON_GROUP,ref:K},e.createElement("div",{role:"group","aria-label":z,className:d(B.buttonsContainer,o({},B.fullWidth,q)),"aria-disabled":N},et),ot&&ot.subText&&e.createElement("div",{className:d(B.subTextContainer)},ot.subText))})),{sizes:j.sizes,kinds:j.kinds});export{k as default};
//# sourceMappingURL=ButtonGroup.js.map
