import e from"@babel/runtime/helpers/defineProperty";import t from"@babel/runtime/helpers/slicedToArray";import{useState as l,useRef as r,useCallback as n,useMemo as s}from"react";import{ALL_SECTION_KEY as i}from"../../constants.js";import{useFilterPruneEffect as o}from"./useFilterPruneEffect.js";import{useWellReconciliation as c}from"./useWellReconciliation.js";import{useSelectionHandlers as f}from"./useSelectionHandlers.js";function u(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),l.push.apply(l,r)}return l}var a=function(a){var d=a.subjectWellId,S=a.subjectWell,p=a.wells,W=a.filteredWells,b=a.externalOffsets,m=a.rawWellsWithSubject,O=a.offsetSettings,h=a.maxOffsetWellNumber,j=a.maxOffsetSize,g=a.open,y=a.isAllWellsLoaded,w=a.fetchSearchedWells,v=a.filters,P=a.filterMutationSeq,E=a.lastFilterMutationSource,R=a.includeHidden,x=l([]),A=t(x,2),I=A[0],U=A[1],Z=r(!1),C=r(0),D=l((function(){var e;return null!==(e=null==O?void 0:O.lastSelectionZone)&&void 0!==e?e:null})),M=t(D,2),F=M[0],H=M[1],L=l((null==O?void 0:O.wellSection)||i),k=t(L,2),q=k[0],z=k[1],N=l([]),G=t(N,2),T=G[0],B=G[1];o({filterMutationSeq:P,lastFilterMutationSource:E,open:g,filters:v,includeHidden:R,subjectWellId:d,setSelectedWells:U,setCurrentSelectionZone:H,hasUserSelectionEditsRef:Z});var J=c({subjectWell:S,wells:p,offsetSettings:O,open:g,isAllWellsLoaded:y,fetchSearchedWells:w,setSelectedWells:U,hasUserSelectionEditsRef:Z}).isReconciled,K=f({subjectWell:S,wells:p,filteredWells:W,externalOffsets:b,rawWellsWithSubject:m,maxOffsetWellNumber:h,maxOffsetSize:j,fetchSearchedWells:w,setSelectedWells:U,setCurrentSelectionZone:H,setSelectedWellSection:z,hasUserSelectionEditsRef:Z}),Q=n((function(){Z.current=!0}),[]),V=n((function(){C.current+=1}),[]),X=s((function(){return I.find((function(e){return e.id===d}))?I.length-1:I.length}),[I,d]),Y=s((function(){return I.map((function(e){return e.id}))}),[I]);return function(t){for(var l=1;l<arguments.length;l++){var r=null!=arguments[l]?arguments[l]:{};l%2?u(Object(r),!0).forEach((function(l){e(t,l,r[l])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({selectedWells:I,setSelectedWells:U,selectedWellsCount:X,selectedWellIds:Y,isReconciled:J,currentSelectionZone:F,setCurrentSelectionZone:H,selectedWellSection:q,setSelectedWellSection:z,loadingAssetIds:T,setLoadingAssetIds:B,searchGenerationRef:C,hasUserSelectionEditsRef:Z,markUserEdit:Q,abandonPendingSearch:V},K)};export{a as useWellSelection};
//# sourceMappingURL=useWellSelection.js.map
