"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("lodash"),t=require("../../../../../utils/index.js"),n=function(e,t){var n=parseFloat(e),r=parseFloat(t);return Number.isNaN(n)||Number.isNaN(r)?null:(n*r).fixFloat(2)};exports.calculateComponent=function(r,i,a){var o,l,s,u,h,c,g,_,m=r.family,f=e.cloneDeep(r);if(f[i]=a,"bit"===m)return"nozzle_sizes"===i&&(f.tfa=(o=f.nozzle_sizes||[],l=t.getUnitPreference("shortLength"),s=Math.PI/4*o.reduce((function(e,n){var r=n.count||0,i=n.size||0,a="in"!==l?32*t.convertValue(i,"shortLength",l,"in"):i;return e+r*(a/32*(a/32))}),0),(u=t.convertValue(1,"shortLength","in",l))*u*s)),f;switch(i){case"inner_diameter":case"outer_diameter":f.linear_weight=function(e,n){var r=t.getUnitPreference("shortLength"),i=parseFloat(n),a=parseFloat(e);if(Number.isNaN(i)||Number.isNaN(a)||a<i)return null;"in"!==r&&(i=t.convertValue(i,"shortLength",r,"in"),a=t.convertValue(a,"shortLength",r,"in"));var o=2.673*(a*a-i*i);return"in"!==r?t.convertValue(o,"massPerLength","lb-ft"):o.fixFloat(2)}(f.outer_diameter,f.inner_diameter),f.weight=n(f.linear_weight,f.length);break;case"number_of_joints":case"component_length":f.length=(h=f.number_of_joints,c=f.component_length,g=parseFloat(h),_=parseFloat(c),Number.isFinite(g)&&Number.isFinite(_)?(g*_).fixFloat(2):null),f.weight=n(f.linear_weight,f.length);break;case"linear_weight":f.weight=n(f.linear_weight,f.length);break;case"length":f.weight=n(f.linear_weight,f.length),f.component_length=function(e,t){var n=parseFloat(e),r=parseFloat(t);return Number.isFinite(n)&&Number.isFinite(r)?(n/r).fixFloat(2):null}(f.length,f.number_of_joints)}return f};
//# sourceMappingURL=calculation.js.map
