import{slicedToArray as e,defineProperty as t}from"../../../../_virtual/_rollupPluginBabelHelpers.js";import o,{forwardRef as r,useState as n}from"react";import s from"classnames";import a from"./TableHeaderCell.module.scss.js";import i from"../../IconButton/IconButton.js";import l from"../../Text/Text.js";import c from"../../Flex/Flex.js";import{getSortIcon as m,getNextSortState as d,getAriaSort as p}from"../Table/tableHelpers.js";import f from"../../Tooltip/Tooltip.js";import{getTestId as u}from"../../../tests/testIds.js";import{ComponentDefaultTestId as j}from"../../../tests/constants.js";import{getStyle as E}from"../../../helpers/typesciptCssModulesHelper.js";import b from"../../../../components/icon/dist/Icon/Icon.js";import v from"../../../../packages/icons/dist/react/Info.js";var C=r((function(r,C){var x=r.id,y=r.className,T=r["data-testid"],H=r.title,g=r.onSortClicked,I=r.infoContent,L=r.icon,N=r.sortState,k=void 0===N?"none":N,B=r.sortButtonAriaLabel,h=void 0===B?"Sort":B,A=r.sticky,w=n(!1),S=e(w,2),_=S[0],F=S[1],M=p(k),P="none"!==M||_;return o.createElement("div",{ref:C,id:x,className:s(a.tableHeaderCell,t(t({},a.sortActive,g&&"none"!==M),a.sticky,A),y),"data-testid":T||u(j.TABLE_HEADER_CELL,x),role:"columnheader",onMouseOver:function(){return F(!0)},onMouseLeave:function(){return F(!1)},onFocus:function(){return F(!0)},onBlur:function(){return F(!1)},"aria-sort":g?M:void 0,tabIndex:g?0:void 0},o.createElement(c,{direction:"row",align:"center",className:a.tableHeaderCellContent,gap:"xs"},L&&o.createElement(b,{icon:L,className:a.icon}),"string"==typeof H?o.createElement(l,{type:"text2",weight:"medium",color:"secondary"},H):H,I&&o.createElement(f,{content:I,referenceWrapperClassName:a.infoTooltip},o.createElement(b,{icon:v,iconLabel:I}))),g&&o.createElement(c,{direction:"row",align:"center",className:a.tableHeaderCellSort},o.createElement(i,{icon:m(k),kind:"tertiary",size:"xs",ariaLabel:h,"aria-hidden":!P,className:s(a.sort,E(a,k),t({},a.show,P)),onClick:function(){return g(d(k))}})))}));export{C as default};
//# sourceMappingURL=TableHeaderCell.js.map
