"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/slicedToArray"),t=require("@babel/runtime/regenerator"),s=require("react"),i=require("../../api/wells/fetchWellsByIds.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}require("lodash"),require("@babel/runtime/helpers/toConsumableArray"),require("@babel/runtime/helpers/defineProperty"),require("uuid"),require("lodash/set"),require("lodash/get"),require("lodash/unset"),require("moment"),require("../../../../clients/jsonApi/index.js"),require("../../../../clients/subscriptions/constants.js"),require("../../../../clients/subscriptions.v1.js"),require("../../../../clients/subscriptions/subscriptions-client.factory.js"),require("../../../../clients/api/apiCore.js"),require("../../../../clients/constants.js"),require("../../../../clients/sso/auth0.js"),require("../../../../clients/sso/oauth2.js"),require("../../../../clients/api/rateLimiter.js"),require("../../constants.js"),require("../../api/shared/dataFormatter.js");var n=u(e),a=u(r),l=u(t);exports.useFetchSubjectWell=function(e){var r=s.useState(null),t=a.default(r,2),u=t[0],c=t[1],o=s.useState(!1),p=a.default(o,2),f=p[0],q=p[1];return s.useEffect((function(){if(!e||e<=0)return c(null),void q(!1);var r=!1,t=e;function s(){return(s=n.default(l.default.mark((function e(){var s;return l.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return q(!0),e.prev=1,e.next=4,i.fetchWellsByIds([t]);case 4:s=e.sent,!r&&s&&s.length>0&&c(s[0]),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.error("Error fetching subject well:",e.t0),r||c(null);case 12:return e.prev=12,r||q(!1),e.finish(12);case 15:case"end":return e.stop()}}),e,null,[[1,8,12,15]])})))).apply(this,arguments)}return function(){s.apply(this,arguments)}(),function(){r=!0}}),[e]),[u,f]};
//# sourceMappingURL=useFetchSubjectWell.js.map
