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