/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE  AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE:  you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { markType } from "igniteui-angular-core";
/**
 * @hidden
 */
export class UltraCalcFunctionFV extends BuiltInFunctionBase {
    evaluate(a, b) {
        let c = 0;
        if (b == 5) {
            let d = a.pop();
            if (d.isError) {
                return d;
            }
            c = d._toInt321();
        }
        let e = 0;
        if (b >= 4) {
            let f = a.pop();
            if (f.isError) {
                return new ExcelCalcValue(f.toErrorValue());
            }
            if (!((() => { let g = f._toDouble1(e); e = g.p0; return g.ret; })())) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
        }
        let g, h, i;
        let j = a.pop();
        let k = a.pop();
        let l = a.pop();
        if (l.isError) {
            return l;
        }
        if (k.isError) {
            return k;
        }
        if (j.isError) {
            return j;
        }
        if (!((() => { let m = j._toDouble1(g); g = m.p0; return m.ret; })()) || !((() => { let m = k._toDouble1(h); h = m.p0; return m.ret; })()) || !((() => { let m = l._toDouble1(i); i = m.p0; return m.ret; })())) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        return new ExcelCalcValue(UltraCalcFunctionFV._ak(i, h, g, e, c));
    }
    static _ak(a, b, c, d, e) {
        return (c * ((Math.pow(1 + a, e == 0 ? b : b + 1) - 1) / a) - (e == 0 ? 0 : c) + (d * Math.pow(1 + a, b))) * -1;
    }
    get_name() {
        return "fv";
    }
    get name() {
        return this.get_name();
    }
    get_minArgs() {
        return 3;
    }
    get minArgs() {
        return this.get_minArgs();
    }
    get_maxArgs() {
        return 5;
    }
    get maxArgs() {
        return this.get_maxArgs();
    }
    doesParameterAllowIntermediateResultArray(a, b) {
        return true;
    }
}
UltraCalcFunctionFV.$t = markType(UltraCalcFunctionFV, 'UltraCalcFunctionFV', BuiltInFunctionBase.$);
//# sourceMappingURL=UltraCalcFunctionFV.js.map