import e from"@babel/runtime/helpers/toConsumableArray";import{useMemo as t}from"react";import{lowerCase as r}from"lodash";import{MAX_TVD as n}from"../../constants.js";import{sortPads as o}from"./sortPads.js";var l=function(l){var s=l.data,i=l.searchText,a=l.selectedWellIds,u=l.sortBy,m=l.sortDirection,c=l.filters,f=l.mainItem;return t((function(){if(!s||!f)return[];var t=s.filter((function(e){return!i||[e.name,e.fleetName,e.wellsNamesCombined,e.formationsCombined].some((function(e){return e&&r(String(e)).includes(r(i))}))}));if((c.selectedFracFleets.length||c.selectedFormations.length||!!c.tvdMin||c.tvdMax!==n)&&(t=t.filter((function(e){var t,r,o=!c.selectedFracFleets.length||c.selectedFracFleets.includes(e.fleetName),l=!c.selectedFormations.length||e.wells.some((function(e){return e.formation&&c.selectedFormations.includes(e.formation)})),s=(t=c.tvdMin,r=c.tvdMax,!t&&r===n||(t&&r===n?e.wells.some((function(e){return e.totalDepth&&e.totalDepth>=Number(t)})):r===n||t?e.wells.some((function(e){return e.totalDepth&&e.totalDepth>=Number(t)&&e.totalDepth<=Number(r)})):e.wells.some((function(e){return e.totalDepth&&e.totalDepth<=Number(r)}))));return o&&l&&s}))),a.length){var l=t.filter((function(e){return e.wells.some((function(e){return a.includes(e.id)}))})),d=t.filter((function(e){return e.wells.every((function(e){return!a.includes(e.id)}))}));u&&(l.sort(o(u,m)),d.sort(o(u,m))),t=[].concat(e(l),e(d))}else if(u){t=Array.from(t).sort(o(u,m))}return t}),[s,f,c,a,u,i,m])};export{l as useFilteredData};
//# sourceMappingURL=useFilteredData.js.map
