"use strict";var e=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/objectWithoutProperties"),t=require("@babel/runtime/helpers/defineProperty"),i=require("react"),o=require("prop-types"),l=require("@material-ui/core"),n=require("classnames"),a=require("react/jsx-runtime");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=s(e),c=s(r),p=s(t),f=s(o),d=s(n),b=["children","className","maxLines","showTooltip"];function m(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,i)}return t}function h(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?m(Object(t),!0).forEach((function(r){p.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):m(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var y=l.makeStyles({root:function(e){var r=e.maxLines;return h({overflow:"hidden"},r?{display:"-webkit-box","-webkit-line-clamp":r,"-webkit-box-orient":"vertical"}:{whiteSpace:"nowrap",textOverflow:"ellipsis"})}});function O(e){var r=e.children,t=e.className,o=void 0===t?"":t,n=e.maxLines,s=void 0===n?null:n,p=e.showTooltip,f=void 0===p||p,m=c.default(e,b),O=i.useState(!1),v=u.default(O,2),w=v[0],j=v[1],x=i.useRef(),g=y({maxLines:s});i.useEffect((function(){var e=x.current,r=e.scrollWidth,t=e.clientWidth,i=e.scrollHeight,o=e.clientHeight;j(s?i>o:r>t)}));var P=a.jsx("div",h(h({className:d.default(g.root,o),ref:x},m),{},{children:r}));return w&&f?a.jsx(l.Tooltip,{title:r,children:P}):P}O.propTypes={children:f.default.oneOfType([f.default.node,f.default.string]).isRequired,className:f.default.string,maxLines:f.default.number,showTooltip:f.default.bool},O.defaultProps={className:"",maxLines:null,showTooltip:!0},module.exports=O;
