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 i from"./TableHeaderCell.module.scss.js";import a 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"../../../../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,I=r.onSortClicked,L=r.infoContent,N=r.icon,g=r.sortState,B=void 0===g?"none":g,h=r.sortButtonAriaLabel,k=void 0===h?"Sort":h,A=r.sticky,w=n(!1),S=e(w,2),_=S[0],F=S[1],M=p(B),P="none"!==M||_;return o.createElement("div",{ref:C,id:x,className:s(i.tableHeaderCell,t(t({},i.sortActive,I&&"none"!==M),i.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":I?M:void 0,tabIndex:I?0:void 0},o.createElement(c,{direction:"row",align:"center",className:i.tableHeaderCellContent,gap:"xs"},N&&o.createElement(b,{icon:N,className:i.icon}),"string"==typeof H?o.createElement(l,{type:"text2",weight:"medium",color:"secondary"},H):H,L&&o.createElement(f,{content:L,referenceWrapperClassName:i.infoTooltip},o.createElement(b,{icon:v,iconLabel:L}))),I&&o.createElement(c,{direction:"row",align:"center",className:i.tableHeaderCellSort},o.createElement(a,{icon:m(B),kind:"tertiary",size:"xs",ariaLabel:k,"aria-hidden":!P,className:s(i.sort,E(i,B),t({},i.show,P)),onClick:function(){return I(d(B))}})))}));export{C as default};
//# sourceMappingURL=TableHeaderCell.js.map
