"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("lodash"),e=require("../constants/completion.js"),r=require("../constants/streamSourceType.js");exports.getAssetKey=function(t,e,r){return t?"pad--".concat(t.current_pad_id||r):e?"well--".concat(e.id):"common"},exports.getDefaultPadModeSetting=function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e.COMPLETION_APP_TYPES.fracMultiWellApp,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s={};if(t){var i,_,u=(null===(i=t.pad_frac_fleets)||void 0===i||null===(_=i.find((function(t){return t.current})))||void 0===_?void 0:_.frac_fleet_lines)||[],o=a&&u.length;s={mode:o?e.COMPLETION_MODES.padLine:e.COMPLETION_APPTYPE_MODES_DICT[n][0],selectedLine:o?u[0].id:void 0}}else r&&(s={mode:"custom",selectedAssets:[r.id]});return s},exports.resolveActiveFracAsset=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,a){var s=(a.app_streams||[]).find((function(t){return t.source_type===r.STREAM_SOURCE_TYPES.FRAC&&(n||t.status===r.STREAM_STATUS.ACTIVE)}));return!s||!s.last_active_at||e&&e.last_frac_at>s.last_active_at?e:t.set(a,"last_frac_at",s.last_active_at)}),null)},exports.resolveActivePumpdownAsset=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,a){var s=(a.app_streams||[]).find((function(t){return t.source_type===r.STREAM_SOURCE_TYPES.PUMPDOWN&&(n||t.status===r.STREAM_STATUS.ACTIVE)}));return!s||e&&e.last_pumpdown_at>s.last_active_at?e:t.set(a,"last_pumpdown_at",s.last_active_at)}),null)},exports.resolveActiveWirelineAsset=function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,a){var s=(a.app_streams||[]).find((function(t){return t.source_type===r.STREAM_SOURCE_TYPES.WIRELINE&&(n||t.status===r.STREAM_STATUS.ACTIVE)}));return!s||e&&e.last_wireline_at>s.last_active_at?e:t.set(a,"last_wireline_at",s.last_active_at)}),null)};
