import{__assign as t}from'./../../ext-esm/tslib/tslib.es6.js';import{jsx as e}from"react/jsx-runtime";import r from"prop-types";import a from"classnames";import{withStyles as i}from"@material-ui/core/styles";import s from"@material-ui/core/Avatar";import{Tooltip as o}from"../Tooltip/Tooltip.js";import"../Tooltip/ScrollableTooltip.js";import l from"../../utils/main.js";var n=function(t){switch(t){case 24:return 12;case 32:return 14;case 40:return 16;case 48:return 20;case 128:return 64;case 200:return 80;default:return Math.floor(t/2)}},m=function(t){return{minWidth:t,width:t,height:t,lineHeight:"".concat(t,"px"),fontSize:n(t)}},c=["#5F47A4","#9078C8","#DC74FD","#F695B5","#CB4F4F","#896F65","#F3AE96","#EE7850","#DDAE67","#A6CA72","#62893D","#91C9C4","#38818D","#77B5F1","#3F4C99","#919DA4"],u=function(t){return c[Math.abs(l.hashCode(t)%c.length)]},d=function(r){var i=r.displayName,n=r.showTooltip,c=r.size,d=r.className,p=r.imgSrc,h=r.alt,f=r.classes,g=r["data-testid"];return e(o,t({title:i,disableFocusListener:!n,disableHoverListener:!n,disableTouchListener:!n},{children:e(s,t({"data-testid":g,alt:h,src:p,className:a(f.avatar,d),style:t(t({},m(Number(c))),{backgroundColor:!!i&&u(i)})},{children:i?l.getNameInitials(i):null}))}))},p={displayName:r.string,showTooltip:r.bool,size:r.number,className:r.string,imgSrc:r.string,alt:r.string,"data-testid":r.string,classes:r.shape({avatar:r.string}).isRequired};d.propTypes=p,d.defaultProps={displayName:"",showTooltip:!1,size:32,className:void 0,imgSrc:void 0,alt:void 0,"data-testid":"generic_avatar"};var h=i((function(t){return{avatar:{color:t.palette.common.white,fontWeight:"bold"}}}))(d);export{d as AvatarComponent,h as default};
