import r from"@babel/runtime/helpers/typeof";import e from"@babel/runtime/helpers/slicedToArray";import{uniqBy as t}from"lodash";import{useState as i,useEffect as n}from"react";import{FilterType as o}from"../constants.js";import{getTimestampByPeriod as m}from"../utils/timePeriod.js";function s(s,u){var a=i(null),c=e(a,2),f=c[0],l=c[1],d=/\sST0/g;return n((function(){if(s){var i=s.filter((function(e){return Object.keys(u).every((function(t){return"object"!==r(u[t])||!(u[t].length>0&&!u[t].includes(e[t]))}))})),n=i;void 0!==u[o.sideTracks]&&(n=i.filter((function(r){return!u[o.sideTracks]||!r.name.match(d)})));var a=u.period,c=u.timeRangeFrom,f=u.timeRangeTo,p=m(a,c,f),b=e(p,2),v=b[0],h=b[1],T=Number.isFinite(v)&&Number.isFinite(h)?n.filter((function(r){return r.lastActive>=v&&r.lastActive<=h})):n,g=u.radius,j=Number.isFinite(g)?T.filter((function(r){return r.distance<=g})):T;l(t(j,"id"))}}),[s,u]),f}export{s as useFilteredWells};
