"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"),s=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 u=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.usePinnedWells=function(e){var r=u.usePickerPropsStore((function(e){return e.addWellsUsabilityInfo})),t=n.useState(null),i=c.default(t,2),l=i[0],f=i[1],p=n.useState(!1),d=c.default(p,2),b=d[0],q=d[1],h=n.useRef(new Map),j=n.useCallback(function(){var e=a.default(o.default.mark((function e(t){var n,u,i,a,c;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==t.length){e.next=3;break}return f([]),e.abrupt("return");case 3:if(0!==(n=t.filter((function(e){return!h.current.has(e)}))).length){e.next=8;break}return u=t.map((function(e){return h.current.get(e)})).filter((function(e){return void 0!==e})),f(u),e.abrupt("return");case 8:return q(!0),e.prev=9,e.next=12,s.fetchWellsByIds(n);case 12:if(i=e.sent,"function"!=typeof r){e.next=19;break}return e.next=16,r(i);case 16:e.t0=e.sent,e.next=20;break;case 19:e.t0=i;case 20:e.t0.forEach((function(e){h.current.set(e.id,e)})),a=t.map((function(e){return h.current.get(e)})).filter((function(e){return void 0!==e})),f(a),e.next=31;break;case 26:e.prev=26,e.t1=e.catch(9),console.error("Error fetching pinned wells:",e.t1),c=t.map((function(e){return h.current.get(e)})).filter((function(e){return void 0!==e})),f(c.length>0?c:null);case 31:return e.prev=31,q(!1),e.finish(31);case 34:case"end":return e.stop()}}),e,null,[[9,26,31,34]])})));return function(r){return e.apply(this,arguments)}}(),[r]);return n.useEffect((function(){j(e||[])}),[e,j]),[l,b]};
//# sourceMappingURL=usePinnedWells.js.map
