"use strict";var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("react/jsx-runtime"),n=require("react"),i=require("prop-types"),a=require("classnames"),o=require("react-draggable"),u=require("@material-ui/core/styles"),l=require("@material-ui/core");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(e),s=d(t),f=d(i),p=d(a),v=d(o);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?b(Object(r),!0).forEach((function(t){c.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):b(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var h=u.makeStyles((function(e){return{resizableColumnHeader:{display:"flex",paddingRight:0,justifyContent:"space-between"},tableResizer:{width:6,borderRadius:10,opacity:.7,cursor:"col-resize",marginRight:-11,marginTop:-16,marginBottom:-16},hovered:{backgroundColor:e.palette.primary.main}}})),y=function(e){var t;return null===(t=document.getElementById(e))||void 0===t?void 0:t.offsetWidth};function g(e){var t,i,a=e.children,o=e.cellName,u=e.nextCellName,d=e.widths,f=e.handleWidthsUpdate,b=h(),g=n.useState(!1),j=s.default(g,2),O=j[0],q=j[1],x=n.useState(),w=s.default(x,2),R=w[0],P=w[1],S=n.useState(),C=s.default(S,2),z=C[0],N=C[1];if(n.useEffect((function(){var e=y("content-".concat(o)),t=y("content-".concat(u));void 0!==e&&P(e+12),void 0!==t&&N(t+12);var r=y(o);void 0!==r&&f(c.default({},o,r))}),[]),!a)return null;return r.jsx(l.TableCell,m(m({width:d[o],id:o},a.props),{},{children:r.jsxs("div",{className:b.resizableColumnHeader,children:[r.jsx("div",{id:"content-".concat(o),children:null!==(t=null==a||null===(i=a.props)||void 0===i?void 0:i.children)&&void 0!==t?t:null}),r.jsx(v.default,{axis:"x",onDrag:function(e,t){!function(e){var t,r=d[o]+e,n=d[u]-e;r<0||void 0!==R&&r<R||void 0!==z&&n<z||f((t={},c.default(t,o,r),c.default(t,u,n),t))}(t.deltaX)},position:{x:0},zIndex:999,onStart:function(){q(!0)},onStop:function(){var e=y(o);void 0!==e&&d[o]!==e&&f(c.default({},o,e)),q(!1)},children:r.jsx("div",{className:p.default(b.tableResizer,O&&b.hovered),onMouseEnter:function(){return q(!0)},onMouseLeave:function(){return q(!1)}})})]})}))}var j={children:f.default.element.isRequired,cellName:f.default.string.isRequired,nextCellName:f.default.string.isRequired,widths:f.default.shape({}).isRequired,handleWidthsUpdate:f.default.func.isRequired};g.propTypes=j,module.exports=g;
//# sourceMappingURL=ResizableTableHeaderCell.js.map
