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