"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("react"),r=require("lodash"),n=require("../../constants.js"),l=require("../../stores/filter-store/utils/normalizeFilters.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=i(e);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?s(Object(r),!0).forEach((function(t){o.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}exports.useCancelHandler=function(e){var i=e.setSelectedWells,o=e.setSelectedWellSection,s=e.setCurrentSelectionZone,a=e.offsetSettings,c=e.subjectWell,d=e.isMapHidden,f=e.isFilterExpanded,p=e.wells,v=e.pinnedWells,b=e.onClose,O=e.onSave,S=e.setFilters,j=e.resetIsLoadAllWells,y=e.resetSafeguard,g=e.abandonPendingSearch;return t.useCallback((function(){var e,t,h;g();var P=new Set((null==a?void 0:a.selectedWellIds)||[]),w=(p||[]).filter((function(e){return P.has(e.id)}));if(null!=v&&v.length){var m=new Set(w.map((function(e){return e.id}))),E=v.filter((function(e){return P.has(e.id)&&!m.has(e.id)}));w=w.concat(E)}c&&(w=w.concat(c)),i(r.uniqBy(w,"id")),s(null!==(e=null==a?void 0:a.lastSelectionZone)&&void 0!==e?e:null);var W=u(u({},a),{},{selectedWellIds:null!==(t=null==a?void 0:a.selectedWellIds)&&void 0!==t?t:[],mapHidden:d,filterExpanded:f});null==O||O(W);var I=l.normalizeFilters(null==a?void 0:a.filters);S(u(u({},I),{},{radius:null!==(h=null==I?void 0:I.radius)&&void 0!==h?h:n.DEFAULT_RADIUS_MILES}),"external_sync"),o((null==a?void 0:a.wellSection)||n.ALL_SECTION_KEY),j(),y(),null==b||b()}),[i,o,s,a,c,d,f,p,v,b,O,S,j,y,g])};
//# sourceMappingURL=useCancelHandler.js.map
