"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"),n=require("react"),u=require("../../api/wells/fetchWellsByIds.js");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 s=require("../../stores/picker-props-store/usePickerPropsStore.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=i(e),c=i(r),o=i(t);exports.useSearchedWells=function(){var e=s.usePickerPropsStore((function(e){return e.addWellsUsabilityInfo})),r=n.useState([]),t=c.default(r,2),i=t[0],l=t[1],f=n.useState(!1),p=c.default(f,2),d=p[0],b=p[1],h=n.useRef(new Map),q=n.useCallback(function(){var r=a.default(o.default.mark((function r(t){var n,s,i;return o.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(0!==t.length){r.next=2;break}return r.abrupt("return",[]);case 2:if(0!==(n=t.filter((function(e){return!h.current.has(e)}))).length){r.next=5;break}return r.abrupt("return",t.map((function(e){return h.current.get(e)})).filter((function(e){return void 0!==e})));case 5:return b(!0),r.prev=6,r.next=9,u.fetchWellsByIds(n);case 9:if(s=r.sent,"function"!=typeof e){r.next=16;break}return r.next=13,e(s);case 13:r.t0=r.sent,r.next=17;break;case 16:r.t0=s;case 17:return r.t0.forEach((function(e){h.current.set(e.id,e)})),i=t.map((function(e){return h.current.get(e)})).filter((function(e){return void 0!==e})),l((function(e){var r=new Set(e.map((function(e){return e.id}))),t=i.filter((function(e){return!r.has(e.id)}));return t.length>0?(null!=e?e:[]).concat(t):e})),r.abrupt("return",i);case 24:return r.prev=24,r.t1=r.catch(6),console.error("Error fetching searched wells:",r.t1),r.abrupt("return",[]);case 28:return r.prev=28,b(!1),r.finish(28);case 31:case"end":return r.stop()}}),r,null,[[6,24,28,31]])})));return function(e){return r.apply(this,arguments)}}(),[e]);return[i,d,q]};
//# sourceMappingURL=useSearchedWells.js.map
