import r from"@babel/runtime/helpers/defineProperty";import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/helpers/toConsumableArray";import{useState as n,useMemo as o,useCallback as i}from"react";import a from"lodash/isEmpty";import s from"lodash/isEqual";import u from"lodash/omit";import{FilterType as m}from"../../constants.js";import{useFilterStore as l}from"../../stores/filter-store/useFilterStore.js";import"../../stores/company-safeguard/CompanySafeguardContext.js";import{useCompanySafeguard as f}from"../../stores/company-safeguard/useCompanySafeguard.js";import{SELECTION_FILTER_KEYS as c}from"../../stores/filter-store/types.js";function p(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),t.push.apply(t,n)}return t}function d(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?p(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):p(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}var y=["hasUserConfirmedAllCompaniesLoadAll"].concat(t(c)),g=function(){var t=f(),c=t.isSafeguardReady,p=t.targetCompanyId,g=l((function(r){return r.filters})),b=l((function(r){return r.defaultFilters})),O=l((function(r){return r.tempFilters})),h=l((function(r){return r.setFilter})),j=l((function(r){return r.setFilters})),C=l((function(r){return r.resetFilterCriteria})),F=n({}),P=e(F,2),v=P[0],R=P[1],D=o((function(){if(!c)return!0;if(!a(O))return!1;var r=p?d(d({},b),{},{companyId:p}):b,e=u(g,y),t=u(r,y);return s(e,t)}),[g,O,b,c,p]),S=i((function(){C("manual_ui"),p&&h("companyId",p,"manual_ui")}),[C,h,p]);return{errors:v,isAtDefaultState:D,handleChangeFilter:i((function(r,e){r===m.sideTracks||r===m.drillingWells||null!=e?h(r,e,"manual_ui"):j(u(null!=g?g:{},[r]),"manual_ui")}),[g,h,j]),handleCustomDateChange:function(e){return function(t){if(t&&t.isValid()){var n=t.unix(),o=!1;"timeRangeFrom"===e&&g.timeRangeTo?o=n>=g.timeRangeTo:"timeRangeTo"===e&&g.timeRangeFrom&&(o=n<=g.timeRangeFrom),R(o?r({},e,!0):{}),h(e,n,"manual_ui")}}},handleResetToDefaults:S}};export{g as useFilterHandlers};
//# sourceMappingURL=useFilterHandlers.js.map
