import{jsx as e,jsxs as l}from"react/jsx-runtime";import{memo as o,useRef as t,useMemo as i,useCallback as s}from"react";import{uniqBy as r}from"lodash";import{Table as n,TableBody as a,TableRow as m,TableCell as u}from"@material-ui/core";import{ColumnType as c,METRICS_LIST as f,EXPANDED_WELL_NAME_WIDTH as d,TableColumns as p}from"../../constants.js";import{getIsImperial as W}from"../../utils/getIsImperial.js";import{usePickerPropsStore as w}from"../../stores/picker-props-store/usePickerPropsStore.js";import{useViewStore as h}from"../../stores/view-store/useViewStore.js";import{useViewportStore as b}from"../../stores/viewport-store/useViewportStore.js";import{useRowReorderAnimation as S}from"./hooks/useRowReorderAnimation.js";import{useDeferredLoading as g}from"./hooks/useDeferredLoading.js";import{OffsetWellsTableRow as v}from"./components/OffsetWellsTableRow/OffsetWellsTableRow.js";import{SkeletonRows as y}from"./components/SkeletonRows/SkeletonRows.js";import{useColumnShadow as R}from"./useColumnShadow.js";import j from"./OffsetWellsTable.module.css.js";var C=o((function(o){var C,N=o.isTableLoading,k=o.subjectWellId,L=o.columnsWithDict,O=o.wells,T=o.metricsKeys,I=o.handleChangeOffsetWell,x=o.isLimitedOffsetWells,A=o.maxOffsetWellNumber,V=o.wellSections,D=o.setActiveWellId,P=o.onRowClick,K=o.taScores,B=o.isWellSectionColumnVisible,F=o.isLastWell,M=o.loadingWellIds,E=o.scrollContainerRef,H=o.isAnimatingRef,q=w((function(e){return e.isLoadAllWells})),z=w((function(e){return e.allWellsLoadProgress})),G=q&&z&&!z.isComplete,J=h((function(e){return e.isHScrollMoved})),Q=h((function(e){return e.isWellNameExpand})),U=b((function(e){return e.isAnyTileLoading()})),X=g(U).isLoading,Y=t(null),Z=i((function(){return r(O,"id")}),[O]),$=i((function(){return Z.map((function(e){return e.id}))}),[Z]),_=S($,E,H),ee=_.tableBodyRef,le=_.registerRow,oe=_.capturePositions,te=i((function(){return W()}),[]),ie=null!==(C=null==L?void 0:L.some((function(e){return e.key===c.company})))&&void 0!==C&&C,se=(null==K?void 0:K.length)>0,re=N||X||!!G,ne=i((function(){var e=new Map(f.map((function(e){return[e.key,e]})));return(T||[]).map((function(l){return e.get(l)})).filter(Boolean)}),[T]),ae=i((function(){return Q?d-58:p[0].minWidth[T.length]-58}),[Q,null==T?void 0:T.length]);R(Y,J,Z);var me=s((function(e,l){l&&oe(),I(e,l)}),[oe,I]),ue=s((function(e){Y.current=e,ee(e)}),[ee]);return L?e("div",{className:j.offsetWellsTable,children:e("div",{className:j.bodyTableWrapper,children:e(n,{"aria-label":"ows table body",innerRef:ue,className:j.bodyTable,children:l(a,{children:[Z.map((function(l){return e(v,{columnsWithDict:L,subjectWellId:k,data:l,metricsKeys:T,metricsColumns:ne,handleChangeOffsetWell:me,wellNameStyle:j.wellNameFixed,wellNameWidth:ae,isImperial:te,isLimitedOffsetWells:x,maxOffsetWellNumber:A,wellSections:V,setActiveWellId:D,onRowClick:P,taScores:K,isWellSectionColumnVisible:B,loadingWellIds:M,registerRow:le},l.id)})),e(y,{columnsWithDict:L,metricsKeys:T,hasCompanyColumn:ie,hasTaColumn:se,isWellSectionColumnVisible:B,wellNameStyle:j.wellNameFixed,isLastWell:F,showSkeletonRows:re}),e(m,{children:e(u,{className:j.bottomShadow})})]})})})}):null}));C.displayName="OffsetWellsTable";export{C as OffsetWellsTable};
//# sourceMappingURL=OffsetWellsTable.js.map
