import r from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/regenerator";import{useRef as n,useState as a,useEffect as s}from"react";import{isEmpty as u,get as c}from"lodash";import{fetchBicWellSections as o,fetchWellhubWells as i,fetchWells as p}from"../utils/apiCalls.js";function l(u){var c=n(!0),o=a(null),i=e(o,2),l=i[0],f=i[1];return s((function(){function e(){return(e=r(t.mark((function r(){var e;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.next=2,p(u);case 2:e=r.sent,f(e);case 4:case"end":return r.stop()}}),r)})))).apply(this,arguments)}c.current&&(f(null),function(){e.apply(this,arguments)}(),c.current=!1)}),[u]),l}var f=function(n){var c=a([]),i=e(c,2),p=i[0],l=i[1];return s((function(){var e,a=(e=r(t.mark((function r(){var e,a,s;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(r.prev=0,!n){r.next=7;break}return r.next=4,o(n);case 4:r.t0=r.sent,r.next=8;break;case 7:r.t0=[];case 8:e=r.t0,a=!u(e)&&JSON.parse(e[0].data.filters)||void 0,s=!u(e)&&e[0].data.result&&JSON.parse(e[0].data.result)||void 0,l({filters:a,result:s}),r.next=17;break;case 14:r.prev=14,r.t1=r.catch(0),l(null);case 17:case"end":return r.stop()}}),r,null,[[0,14]])}))),function(){return e.apply(this,arguments)});a()}),[n]),p},m=function(n){var u=a([]),o=e(u,2),p=o[0],l=o[1];return s((function(){var e,a=(e=r(t.mark((function r(){var e,a;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,i(n);case 3:e=r.sent,a=c(e[0],"data.offset_wells")||[],l(a),r.next=11;break;case 8:r.prev=8,r.t0=r.catch(0),l([]);case 11:case"end":return r.stop()}}),r,null,[[0,8]])}))),function(){return e.apply(this,arguments)});a()}),[n]),p};export{f as useFetchBicWellsData,m as useFetchWellhubWells,l as useWells};
