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