/*
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 UltraCalcFunctionPmt extends BuiltInFunctionBase {
    evaluate(a, b) {
        let c = 0;
        if (b == 5) {
            c = a.pop()._toInt321();
        }
        let d = 0;
        if (b >= 4 && !((() => { let e = a.pop()._toDouble1(d); d = e.p0; return e.ret; })())) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        let e, f, g;
        if (!((() => { let h = a.pop()._toDouble1(e); e = h.p0; return h.ret; })()) || !((() => { let h = a.pop()._toDouble1(f); f = h.p0; return h.ret; })()) || !((() => { let h = a.pop()._toDouble1(g); g = h.p0; return h.ret; })())) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        if (d != 0 && g != 0) {
            d = c == 0 ? (d * g) / (1 - Math.pow(g + 1, f)) : ((d * g) / (1 - Math.pow(g + 1, f))) / (g + 1);
        }
        if (g != 0) {
            if (c == 0) {
                return new ExcelCalcValue((e * (g / (1 - Math.pow(g + 1, -f))) - d) * -1);
            }
            else {
                return new ExcelCalcValue(((e / (1 + g)) * (g / (1 - Math.pow(g + 1, -f))) - d) * -1);
            }
        }
        return new ExcelCalcValue((e / f - d) * -1);
    }
    get_name() {
        return "pmt";
    }
    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();
    }
}
UltraCalcFunctionPmt.$t = markType(UltraCalcFunctionPmt, 'UltraCalcFunctionPmt', BuiltInFunctionBase.$);
//# sourceMappingURL=UltraCalcFunctionPmt.js.map