"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/defineProperty"),t=require("./convert.js"),r=require("../constants/completion.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=o(e);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,o)}return r}function u(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){n.default(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var i=function(e,t){return e.reduce((function(e,t){var r=t.type,o=t.amount?parseFloat(t.amount):0,a=e[r]?e[r].amount+o:o;return u(u({},e),{},n.default({},r,{amount:a,unit_type:t.unit_type,unit:t.unit}))}),t)};exports.getAggreElems=i,exports.getDifference=function(e,t){return Number.isFinite(e)&&e?Number.isFinite(t)?Math.round(t/e*1e3)/10:0:"-"},exports.getElemActualColor=function(e,t){var o;if("proppants"===e?o=r.PROPPANTS_TYPES:"fluids"===e?o=r.FLUIDS_TYPES:"volumeChemicals"!==e&&"massChemicals"!==e||(o=r.CHEMICALS_TYPES),o){var n=o.find((function(e){return e.name===t}));return n&&n.color}return r.STAGE_ACTUAL_PARAM_COLORS[e]},exports.getFormattedValue=function(e){return Number.isFinite(e)?Math.floor(e)===e?e.formatNumeral("0,0"):e.formatNumeral("0,0.0"):""},exports.getIsGreaterThanTenPercent=function(e){return!Number.isFinite(e)||Math.abs(e-100)>=10},exports.getStageSummary=function(e,r){var o=r.data||{},n=o.fluids||[],a=o.chemicals||[],u=o.proppants||[],l=t.convertValue(Math.min(o.top_perforation,e.top_perforation),"length","ft"),s=t.convertValue(Math.max(o.bottom_perforation,e.bottom_perforation),"length","ft"),p=t.convertValue(e.perforated_length+o.perforated_length,"length","ft"),c=t.convertValue(e.flush_volume+o.flush_volume,"oil","bbl");return{top_perforation:l,bottom_perforation:s,perforated_length:p,total_shots:e.total_shots+o.total_shots,flush_volume:c,chemicals:i(a,e.chemicals),proppants:i(u,e.proppants),fluids:i(n,e.fluids)}};
//# sourceMappingURL=StageDesignVActualUtils.js.map
