"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/regenerator"),u=require("react"),n=require("lodash"),a=require("../utils/apiCalls.js");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=s(e),c=s(t),i=s(r);exports.useFetchBicWellsData=function(e,t){var r=u.useState([]),s=c.default(r,2),f=s[0],o=s[1];return u.useEffect((function(){var r,u=(r=l.default(i.default.mark((function t(){var r,u,s,l,f;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,!e){t.next=7;break}return t.next=4,Promise.all([a.fetchBicWellSections(e)]);case 4:t.t0=t.sent,t.next=8;break;case 7:t.t0=[];case 8:u=t.t0,s=c.default(u,1),r=s[0],l=!n.isEmpty(r)&&JSON.parse(r[0].data.filters)||void 0,f=!n.isEmpty(r)&&r[0].data.result&&JSON.parse(r[0].data.result)||void 0,o({filters:l,result:f}),t.next=19;break;case 16:t.prev=16,t.t1=t.catch(0),o(null);case 19:case"end":return t.stop()}}),t,null,[[0,16]])}))),function(){return r.apply(this,arguments)});t&&u()}),[e,t]),f},exports.usePrevious=function(e){var t=u.useRef();return u.useEffect((function(){t.current=e})),t.current},exports.useWells=function(e,t){var r=u.useRef(!0),n=u.useState(null),s=c.default(n,2),f=s[0],o=s[1];return u.useEffect((function(){function u(){return(u=l.default(i.default.mark((function t(){var r;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,a.fetchWells(e);case 2:r=t.sent,o(r);case 4:case"end":return t.stop()}}),t)})))).apply(this,arguments)}t&&r.current&&(o(null),function(){u.apply(this,arguments)}(),r.current=!1)}),[e,t]),f};
