import{slicedToArray as e}from"../../../_virtual/_rollupPluginBabelHelpers.js";import{jsx as r}from"react/jsx-runtime";import t,{forwardRef as a,useRef as i,useState as s,useEffect as o,useCallback as n}from"react";import l from"classnames";import c from"../../../hooks/useMergeRefs.js";import m from"../../../hooks/usePrevious/index.js";import"./TabsContext.scss.js";var p=a((function(a,p){var u=a.className,f=a.id,d=a.activeTabId,b=void 0===d?0:d,v=a.children,T=i(null),h=c({refs:[p,T]}),j=s(b),x=e(j,2),g=x[0],y=x[1],C=s(b),I=e(C,2),P=I[0],k=I[1],E=m(b);o((function(){b!==E&&b!==P&&(y(P),k(b))}),[b,E,P,y,k]);var N=n((function(e){y(P),k(e)}),[y,P,k]);return r("div",Object.assign({ref:h,className:l("tabs-context--wrapper",u),id:f},{children:t.Children.map(v,(function(e){return e.type.isTabList?t.cloneElement(e,{activeTabId:P,onTabChange:N}):e.type.isTabPanels?t.cloneElement(e,{activeTabId:P,animationDirection:P>g?"ltr":"rtl"}):e}))}))}));export{p as default};
