"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require('./../../ext-esm/tslib/tslib.es6.js'),t=require("react/jsx-runtime"),r=require("react"),n=require("classnames"),i=require("react-virtualized"),o=require("@material-ui/core"),a=require("@material-ui/icons"),l=require("../../utils/convert.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=u(n),c=o.makeStyles((function(e){return{table:{"& .ReactVirtualized__Table__headerRow":{textTransform:"none",borderBottom:e.isLightTheme?"1px solid rgba(224, 224, 224, 1)":"1px solid rgba(81, 81, 81, 1)"},"& .ReactVirtualized__Table__row":{borderBottom:e.isLightTheme?"1px solid rgba(224, 224, 224, 1)":"1px solid rgba(81, 81, 81, 1)"},"& .ReactVirtualized__Table__Grid":{outline:"none"},"& .ReactVirtualized__Table__headerColumn":{outline:"none"}},oddRow:{backgroundColor:e.isLightTheme?"rgba(189, 189, 189, 0.1)":"#303030"},headerLabel:{lineHeight:"14px",fontSize:"12px",fontStyle:"normal",letterSpacing:"-0.25px",display:"flex",alignItems:"center",flexWrap:"wrap"},cellData:{lineHeight:"14px",fontSize:"12px",fontWeight:"normal",fontStyle:"normal",letterSpacing:"0.15px"},unitLabel:{fontSize:"10px",opacity:.5},settingIcon:{padding:"3px",fontSize:"20px"},sortIcon:{fontSize:"16px"}}}));function d(e,t){var r=e.find((function(e){return e.key===t}))||{},n=r.unitType,i=r.customUnit;return i?"(".concat(i,")"):n?"(".concat(l.getUnitDisplay(n),")"):""}function f(e,t){return(e.find((function(e){return e.key===t}))||{}).headerLabelClassName||""}function h(e,t){return(e.find((function(e){return e.key===t}))||{}).headerLabelUnitClassName||""}var m=function(n){var l=n.columns,u=n.data,m=n.useColumnSetting,p=n.useFixedColumnWidth,g=n.onOpenSettingDlg,y=n.width,x=n.height,b=n.headerHeight,w=n.rowHeight,S=n.showTopSettingIcon,_=n.customMuiStyles,v=n.isTopSettingIconShownAlways,j=n.CustomCellRenderer,z=void 0===j?null:j,T=n.customRowStyle,k=void 0===T?null:T,C=n.sort,N=void 0===C?null:C,R=n.sortBy,I=void 0===R?null:R,D=n.sortDirection,L=void 0===D?null:D,q=c(),M=e.__assign(e.__assign({},q),_),A=r.useMemo((function(){return{label:"",key:"setting",width:m?25:0}}),[m]),H=r.useMemo((function(){return l.filter((function(e){return e.show}))}),[l]),B=r.useMemo((function(){return m?e.__spreadArray(e.__spreadArray([],H,!0),[A],!1):H}),[H,m,A]),V=r.useMemo((function(){var e;if(y<=0)return{};var t=((e={})[A.key]=A.width,e),r=[];return H.filter((function(e){return Number.isFinite(e.width)})).forEach((function(e){t[e.key]=e.width-1,r.push(e.width-1)})),H.filter((function(e){return!Number.isFinite(e.width)})).forEach((function(e){var n=r.reduce((function(e,t){return e+t}),0),i=Math.floor((y-n-A.width)/(H.length-r.length)),o=e.minWidth||65,a=i<o?o:i;t[e.key]=a-1,r.push(a-1)})),t}),[y,H,A]),F=r.useMemo((function(){return Object.values(V).reduce((function(e,t){return e+t}),0)}),[V]),K=v||F-12.5>=y;r.useEffect((function(){S(K)}),[K]);var U=function(e){var r=e.label,n=e.dataKey,u=I||L||N;return n===A.key?K?null:t.jsx(o.IconButton,{size:"small","aria-label":"customize columns",className:M.settingIcon,onClick:g,children:t.jsx(a.Settings,{fontSize:"inherit"})}):t.jsxs(o.Typography,{variant:"body2",className:s.default(M.headerLabel,f(l,n)),children:[r," ",t.jsx("span",{className:s.default(M.unitLabel,h(l,n)),children:d(l,n)}),u&&n!==I&&t.jsx(o.Tooltip,{title:"Sort A-Z",children:t.jsx(a.Sort,{fontSize:"small",className:q.sortIcon})}),u&&n===I&&(L===i.SortDirection.ASC?t.jsx(a.ArrowUpward,{fontSize:"small",className:q.sortIcon}):t.jsx(a.ArrowDownward,{fontSize:"small",className:q.sortIcon}))]})},W=function(e){var r=e.dataKey,n=e.rowData;return z?t.jsx(z,{columnKey:r,value:n[r]}):t.jsx(o.Typography,{variant:"body2",className:M.cellData,children:n[r]})};return t.jsx(t.Fragment,{children:t.jsx(i.Table,{width:p?F:y,height:x,headerHeight:b,rowClassName:function(e){var t,r=e.index;return s.default(((t={})[M.oddRow]=r%2==1,t))},rowHeight:w,rowCount:u.length,rowGetter:function(e){var t=e.index;return u[t]},rowStyle:k||{},className:M.table,sort:N,sortBy:I,sortDirection:L,children:B.map((function(e){return t.jsx(i.Column,{width:V[e.key]||0,dataKey:e.key,label:e.label,headerRenderer:U,cellRenderer:W},e.key)}))})})};exports.VirtualizedTableComponent=m,exports.default=m;
