"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/asyncToGenerator"),n=require("@babel/runtime/regenerator"),i=require("lodash"),s=require("../../../../api/wells/fetchWellsByIds.js");require("@babel/runtime/helpers/toConsumableArray"),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");var u=require("../../../../api/wells/fetchWellsByRigIds.js");require("../../../../constants.js"),require("../../../../api/shared/dataFormatter.js");var a=require("../../../../utils/doesWellPassFilters.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var l=o(e),c=o(r),p=o(t),f=o(n);function d(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function b(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?d(Object(t),!0).forEach((function(r){c.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):d(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}var h=function(e){return Number.isFinite(Number(e))},m=function(){var e=p.default(f.default.mark((function e(r,t){var n,s;return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==r.length){e.next=2;break}return e.abrupt("return",new Map);case 2:return e.next=4,u.fetchWellsByRigIds(r,t);case 4:return n=e.sent,s=i.groupBy(n.filter((function(e){return h(null==e?void 0:e.rigId)})),(function(e){return Number(e.rigId)})),e.abrupt("return",new Map(r.map((function(e){return[e,s[e]||[]]}))));case 7:case"end":return e.stop()}}),e)})));return function(r,t){return e.apply(this,arguments)}}(),y=function(){var e=p.default(f.default.mark((function e(r){var t;return f.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==r.length){e.next=2;break}return e.abrupt("return",new Map);case 2:return e.next=4,s.fetchWellsByIds(r);case 4:return t=e.sent,e.abrupt("return",new Map(t.filter((function(e){return h(null==e?void 0:e.id)})).map((function(e){return[Number(e.id),e]}))));case 6:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}();exports.EXCLUDE_RIG_NAME_FILTER=a.EXCLUDE_RIG_NAME_FILTER,exports.doesWellPassFilters=a.doesWellPassFilters,exports.MAX_EMPTY_PAGES=5,exports.computeRigCheckedState=function(e,r,t){if(0===r.length)return b(b({},e),{},{checked:!1,disabledReason:"This rig has no wells"});var n=r.filter((function(e){return t.includes(e.id)})).length,i=n===r.length,s=n>0;return b(b({},e),{},{checked:s,indeterminate:s&&!i})},exports.countFilteredItems=function(e){return e.reduce((function(e,r){return e+l.default(r,2)[1].length}),0)},exports.fetchRigWellsMap=m,exports.fetchWellDataMap=y,exports.groupByType=function(e){return Object.entries(i.groupBy(e,"type"))},exports.hasActiveWellFilters=function(e){return!!e&&(!!a.WELL_PROPERTY_FILTER_KEYS.some((function(r){var t=e[r];return Array.isArray(t)&&t.length>0}))||(!!e.sideTracks||(!!e.drillingWells||(!(!e.period||"all"===e.period)||(Number.isFinite(e.timeRangeFrom)||Number.isFinite(e.timeRangeTo))))))},exports.isFiniteNumber=h;
//# sourceMappingURL=useAssetsData.utils.js.map
