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