import{jsx as e}from"react/jsx-runtime";import{makeStyles as t,FormControl as r,Tooltip as n,Typography as i,MenuItem as o}from"@material-ui/core";import{METRICS_LIST as a}from"../../../../constants.js";import{useSegmentConfig as c}from"../../../../segment-config/useSegmentConfig.js";import{getUnitDisplay as l}from"../../../../../../utils/index.js";import p from"../../../../../Select/index.js";var m=t((function(e){return{metricsForm:{width:"calc(100% - 32px)","& .MuiInputBase-root":{"&:hover $primaryText":{color:e.palette.primary.text1},"&:hover $primaryIcon":{color:e.palette.primary.text1},"&:focused $primaryIcon":{color:e.palette.primary.main}}},metricsSelect:{"&:before":{borderBottom:"none !important"},"&:after":{borderBottom:"none !important"}},primaryText:{fontWeight:500,fontSize:"12px",lineHeight:"14px",letterSpacing:"0.4px",color:e.palette.primary.text7,overflow:"hidden",textOverflow:"ellipsis"},primaryIcon:{color:e.palette.primary.text6},metricsMenuPaper:{backgroundColor:e.palette.background.b9,maxHeight:"calc(100% - 300px)",top:"150px !important"},valueLabel:{display:"-webkit-box",alignItems:"center",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflowWrap:"break-word",fontWeight:500,fontSize:"12px",lineHeight:"14px",letterSpacing:"0.4px",overflow:"hidden",whiteSpace:"normal"}}})),u=function(e){var t=a.find((function(t){return t.key===e}));if(!t)return"";var r=t.unitType?" (".concat(l(t.unitType,t.to),")"):"";return t.label+r},s=function(t){var l=t.isTooltipVisible,s=t.currentValue,f=t.metricsKeys,d=t.onChange,x=t.setIsMenuOpen,y=m(),h=c().defaultMetricKey,b=a.filter((function(e){return!f.includes(e.key)}));return null!=h&&s===h?e(n,{title:l?u(s):"",children:e(i,{className:y.valueLabel,children:u(s)})}):e(r,{className:y.metricsForm,children:e(p,{"data-testid":"".concat("MetricsSelect","_select_").concat(s),className:y.metricsSelect,classes:{select:y.primaryText,icon:y.primaryIcon},MenuProps:{paper:y.metricsMenuPaper},value:s,renderValue:function(t){return e(n,{title:l?u(t):"",children:e(i,{className:y.valueLabel,children:u(t)})})},onOpen:function(){return x(!0)},onClose:function(){return x(!1)},onChange:function(e){return d(e.target.value)},children:b.map((function(t){return e(o,{"data-testid":"".concat("MetricsSelect","_option_").concat(t.key,"MenuItem"),value:t.key,children:t.label},t.key)}))})})};export{s as MetricsSelect};
//# sourceMappingURL=MetricsSelect.js.map
