"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/typeof"),r=require("react"),n=require("../constants.js"),i=require("../stores/filter-store/useFilterStore.js"),s=require("../stores/filter-store/utils/cascade-hierarchies.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(e),u=o(t);function l(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}exports.useFilterValidation=function(e){var t=e.open,o=e.isAllWellsLoaded,c=e.filters,f=e.filterOptions,p=e.isLoadAllWells,y=e.setFilters,b=i.useFilterStore((function(e){return e.segment}));r.useEffect((function(){if(t&&o&&c){var e=s.getCascadeMaps(b).upstream,r=new Map;f.forEach((function(e){var t=e.value,i=e.options;if(Array.isArray(i)){var s=t===n.FilterType.company?i.map((function(e){return e&&"object"===u.default(e)?e.id:e})):i;r.set(t,new Set(s.filter((function(e){return null!=e}))))}else r.set(t,new Set)})),r.set(n.FilterType.status,new Set(n.StatusOptions.map((function(e){return e.value}))));var i=!1,O=function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?l(Object(r),!0).forEach((function(t){a.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):l(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}({},c);r.forEach((function(t,r){var s=c[r];if(Array.isArray(s)&&0!==s.length&&(!e.has(r)||r===n.FilterType.status)&&0!==t.size){var o=s.filter((function(e){return t.has(e)}));o.length!==s.length&&(i=!0,o.length>0?O[r]=o:r===n.FilterType.company&&p?O[r]=[]:delete O[r])}})),i&&y(O,"system")}}),[t,o,c,f,p,y,b])};
//# sourceMappingURL=useFilterValidation.js.map
