import e from"prop-types";import{makeStyles as r,FormControl as t,Tooltip as i,Typography as n,MenuItem as o}from"@material-ui/core";import{METRICS_LIST as a,DEFAULT_METRICS_KEY as c}from"../../constants.js";import{getUnitDisplay as l}from"../../../../utils/index.js";import p from"../../../Select/index.js";import{jsx as s}from"react/jsx-runtime";var u=r((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"}}}));function m(e){var r=a.find((function(r){return r.key===e}));if(!r)return"";var t=r.unitType?" (".concat(l(r.unitType),")"):"";return r.label+t}var d=function(e){var r=e.isTooltipVisible,l=e.currentValue,d=e.metricsKeys,f=e.onChange,y=e.setIsMenuOpen,x=u(),h=a.filter((function(e){return!d.includes(e.key)}));return l!==c?s(t,{className:x.metricsForm,children:s(p,{"data-testid":"".concat("MetricsSelect","_select_").concat(l),className:x.metricsSelect,classes:{select:x.primaryText,icon:x.primaryIcon},MenuProps:{paper:x.metricsMenuPaper},value:l,renderValue:function(e){return s(i,{title:r?m(e):"",children:s(n,{className:x.valueLabel,children:m(e)})})},onOpen:function(){return y(!0)},onClose:function(){return y(!1)},onChange:function(e){return f(e.target.value)},children:h.map((function(e){return s(o,{"data-testid":"".concat("MetricsSelect","_option_").concat(e.key,"MenuItem"),value:e.key,children:e.label},e.key)}))})}):s(i,{title:r?m(l):"",children:s(n,{className:x.valueLabel,children:m(l)})})};d.propTypes={isTooltipVisible:e.bool.isRequired,currentValue:e.string.isRequired,metricsKeys:e.arrayOf(e.string).isRequired,onChange:e.func.isRequired,setIsMenuOpen:e.func.isRequired};export{d as MetricsSelect};
