"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/toConsumableArray"),r=require("react"),s=require("lodash"),n=require("../../constants.js"),l=require("../../utils/isXtoIdasPicker.js"),a=require("./buildOffsetSourceLabel.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=i(e),o=i(t);function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,s)}return r}exports.useSaveResetDerivedState=function(e){var t,i=e.externalOffsets,d=e.selectedWells,f=e.selectedWellsCount,h=e.selectedWellSection,b=e.subjectWellId,O=e.rawWellsWithSubject,p=e.maxOffsetSize,v=e.companyProvider,g=e.isWDUser,y=e.isManualWellsEnabled,S=e.hasValidAssetId,W=e.isAllWellsLoaded,I=e.filters,m=e.idasWellIds,P=e.owsWellIds,j=e.wellhubWellIds,w=e.savedIdasWellIds,M=e.savedOwsWellIds,D=e.savedWellhubWellIds,E=e.savedHandpickedWellIds,L=r.useMemo((function(){return l.isXtoIdasPicker({isWDUser:g,isManualWellsEnabled:y,companyProvider:v})}),[g,y,v]),R=r.useMemo((function(){var e,t,r=s.uniq([].concat(o.default(w),o.default(M),o.default(D),o.default(E))).filter((function(e){return e!==b})),l=(null!==(e=null==i?void 0:i[n.ALL_SECTION_KEY])&&void 0!==e?e:[]).filter((function(e){return null!=e&&e!==b})),a=new Set([].concat(o.default(d.map((function(e){return e.id}))),o.default(null!==(t=null==O?void 0:O.map((function(e){return e.id})))&&void 0!==t?t:[]))),u=L||W?l.filter((function(e){return a.has(e)})):l,c=new Set;null!=b&&c.add(b),u.slice(0,Math.max(0,p-1)).forEach((function(e){return c.add(e)}));var f=d.map((function(e){return e.id}));return{isSynced:f.length===c.size&&f.every((function(e){return c.has(e)})),hasResetTarget:u.length>0||r.length>0}}),[i,d,b,O,p,L,W,w,M,D,E]),_=R.isSynced,q=R.hasResetTarget,A=r.useMemo((function(){return!!v&&n.COMPANY_PROVIDERS_FOR_IDAS.includes(v)}),[v]),T=r.useMemo((function(){return a.buildOffsetSourceLabel({isWDUser:g,isIdasProvider:A,hasIdas:m.length>0,hasOws:P.length>0,hasWellhub:j.length>0})}),[g,A,m,P,j]).label,k=r.useMemo((function(){var e=w.length+M.length+D.length>0?{hasIdas:w.length>0,hasOws:M.length>0,hasWellhub:D.length>0}:{hasIdas:m.length>0,hasOws:P.length>0,hasWellhub:j.length>0};return a.buildOffsetSourceLabel(function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?c(Object(r),!0).forEach((function(t){u.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):c(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({isWDUser:g,isIdasProvider:A},e))}),[g,A,w,M,D,m,P,j]),x=k.label,C=T?"".concat(T,"."):"",U=x?"".concat(x,"."):"",X=r.useMemo((function(){return g?m.length>0||P.length>0:j.length>0}),[g,j,m,P]);t=T?"Reset to Synced Offsets in ".concat(T):q?"Reset to Synced Offsets":"Reset Selection";var N=r.useMemo((function(){return!!S&&(!(_||!(q||f>0))||(!(s.isEmpty(I)||null==I||!I[n.FilterType.sideTracks])||h!==n.ALL_SECTION_KEY))}),[S,q,_,f,I,h]);return{isSynced:_,isXtoProvider:A,isXtoIdas:L,syncedOffsetLabel:C,savedOffsetLabel:U,resetTooltipLabel:t,isResetVisible:N,hasOffsetSource:X,hasSavedHandpicked:E.length>0}};
//# sourceMappingURL=useSaveResetDerivedState.js.map
