import r from"@babel/runtime/helpers/slicedToArray";import{jsx as e,jsxs as t}from"react/jsx-runtime";import{memo as i,useState as n,useRef as o,useEffect as s}from"react";import{makeStyles as a,Tooltip as c}from"@material-ui/core";import m from"classnames";import{MIXPANEL_ACTION_TYPES as l}from"../../constants/mixpanel.js";import"../DevCenter/DevCenterRouterContext/DevCenterRouterContext.js";import{UniversalLink as u}from"../DevCenter/DevCenterRouterContext/UniversalLink/UniversalLink.js";import"@babel/runtime/helpers/defineProperty";import"@babel/runtime/helpers/objectWithoutProperties";import"react-router-dom";import"query-string";import{truncateInTheMiddle as d}from"../../utils/formatting.js";import p from"./AssetNameLabel.styles.css.js";var f=a({assetName:{maxWidth:function(r){return r.chipMaxWidth}}}),h=i((function(i){var a,h=i.assetName,v=i.classes,x=i.coordinatesPixelWidth,C=i.dataTestId,b=i.href,N=i.icon,D=i.statusBadge,j=n(h),W=r(j,2),A=W[0],R=W[1],y=o(null),T=o(),g=(a=null!=x?x:0)>=1024?244:a>=768?184:a>=420?134:44,S=o(g),k=f({chipMaxWidth:g});return s((function(){R(h),T.current=void 0}),[h]),s((function(){!T.current&&y.current&&(T.current=y.current.scrollWidth)}),[T.current]),s((function(){if(y.current&&T.current){if(g>S.current)return R(h),T.current=void 0,void(S.current=g);var r=d(h,y.current.clientWidth,T.current);R(r),S.current=g}}),[h,g,y.current,T.current]),e(c,{title:h||"",children:e("div",{className:m(p.wrapper),children:t(u,{className:m(p.item,null==v?void 0:v.item),"data-testid":C,href:b,onClick:function(){var r,e;null===(r=(e=window)[Symbol.for("logToMixpanel")])||void 0===r||r.call(e,l.REDIRECT.ASSET_DASHBOARD,{referer:"Asset Chip"})},children:[N&&e("div",{className:p.startIcon,children:N}),e("span",{className:m(p.assetName,k.assetName),ref:y,children:A}),D]})})})}));export{h as AssetNameLabel};
//# sourceMappingURL=AssetNameLabel.js.map
