import t from"@babel/runtime/helpers/defineProperty";import n from"@babel/runtime/helpers/asyncToGenerator";import r from"@babel/runtime/helpers/slicedToArray";import e from"@babel/runtime/regenerator";import{useRef as o,useEffect as i,useState as s}from"react";import{get as a}from"lodash";import{fetchCompanyGoals as c,fetchWells as u,fetchMetricsData as f}from"../../../utils/apiCalls.js";import{FILTERS as l,METRICS_KEYS as p}from"../constants.js";import{mapbox as m}from"../../../../../utils/index.js";import{BENCHMARK_METRIC_GOAL as h}from"../../../../../constants/goals.js";import"../../../../../constants/segment.js";import"../../../../../constants/alerts.js";import"../../../../../constants/apps.js";import"../../../../../constants/drillstring.js";import"../../../../../constants/completion.js";import"../../../../../constants/appPackages.js";import"../../../../../constants/notifications.js";import"../../../../../constants/feed.js";import"../../../../../constants/bha.js";import"../../../../../constants/corvaCompanyId.js";import"../../../../GradientManager/configuration/constants.js";export{default as useBidirectionalFiltering}from"./biDirectionalFiltering.js";import{getCompanyGoalSetting as v}from"../../../../../utils/goals.js";function d(t,n){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(t);n&&(e=e.filter((function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable}))),r.push.apply(r,e)}return r}function b(n){for(var r=1;r<arguments.length;r++){var e=null!=arguments[r]?arguments[r]:{};r%2?d(Object(e),!0).forEach((function(r){t(n,r,e[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(e)):d(Object(e)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(e,t))}))}return n}var j=m.getAssetV2Coordinates,y=m.getDistanceByCoordinates;function g(t){var n=o();return i((function(){n.current=t})),n.current}function O(t){var o=s(null),a=r(o,2),u=a[0],f=a[1];return i((function(){function r(){return(r=n(e.mark((function n(){var r,o;return e.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,c(t);case 2:r=n.sent,o=v(r,h),f(o);case 5:case"end":return n.stop()}}),n)})))).apply(this,arguments)}f(null),function(){r.apply(this,arguments)}()}),[t]),u}function w(t,o){var a=s(null),c=r(a,2),f=c[0],l=c[1];return i((function(){function r(){return(r=n(e.mark((function n(){var r;return e.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t){n.next=6;break}return n.next=3,u(t,o);case 3:n.t0=n.sent,n.next=7;break;case 6:n.t0=null;case 7:r=n.t0,l(r);case 9:case"end":return n.stop()}}),n)})))).apply(this,arguments)}l(null),function(){r.apply(this,arguments)}()}),[t]),f}function x(t,n,e){var o=s(null),a=r(o,2),c=a[0],u=a[1],f=/\sST0/g;return i((function(){if(e){var r=Object.values(l).reduce((function(n,r){return n.filter((function(n){return e=n[r],!(o=t[r])||0===o.length||o.includes(e);var e,o}))}),e).filter((function(t){return n&&!t.name.match(f)||!n}));u(r)}else u(null)}),[e,t,n]),c}function P(t,n){var e=s(null),o=r(e,2),a=o[0],c=o[1];return i((function(){if(t){var r=n&&j(n,"topHole");if(r){var e=[];t.forEach((function(t){var n=j(t,"topHole");if(n){var o=parseFloat(y(r,n));e.push(b(b({},t),{},{distance:o}))}else e.push(t)})),c(e)}else c(t)}else c(t)}),[t,n]),a}function E(t,n,e){var o=s(null),a=r(o,2),c=a[0],u=a[1];return i((function(){if(n){var t=[];n.forEach((function(n){e.includes(n.id)&&n.is_usable&&t.push(n)})),u(t)}else u(null)}),[t,n,e]),c}function k(t,c){var u=o({}),l=s(!0),m=r(l,2),h=m[0],v=m[1],d=s(null),j=r(d,2),y=j[0],g=j[1];return i((function(){function r(){return(r=n(e.mark((function n(r){var o,i,s;return e.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,f(t,r);case 2:o=n.sent,i={},r.forEach((function(t){var n={},r=o.filter((function(n){return a(n,"asset_id")===t}));p.forEach((function(t){var e=r.find((function(n){return a(n,"data.key")===t})),o=a(e,"data.value");n[t]=Number.isFinite(o)?parseFloat(o).toFixed(2):null})),i[t]=n})),u.current=b(b({},u.current),i),s=[],c.forEach((function(t){s.push(b(b({},t),u.current[t.id]))})),v(!1),g(s);case 10:case"end":return n.stop()}}),n)})))).apply(this,arguments)}if(c)if(0!==c.length){var o=[];c.forEach((function(t){u.current[t.id]||o.push(t.id)})),v(!0),function(t){r.apply(this,arguments)}(o)}else g([]);else g(null)}),[c]),[h,y]}function D(t,n,r){var e=o(!1);i((function(){if(n){if(e.current){var o=[];n.forEach((function(n){n.distance<=t&&o.push(n.id)})),r(o)}e.current=!0}}),[t,n])}export{O as useCompanyMetricKey,x as useFilteredWells,k as useMetricsData,E as useOffsetWells,g as usePrevious,D as useRadiusWells,w as useWells,P as useWellsWithCoords};
//# sourceMappingURL=index.js.map
