/*
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 * as tslib_1 from "tslib";
import { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { List$1 } from "igniteui-angular-core";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { markType } from "igniteui-angular-core";
import { truncate } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionChoose = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionChoose, _super);
    function UltraCalcFunctionChoose() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionChoose.prototype.evaluate = function (a, b) {
        var c = new List$1(ExcelCalcValue.$, 0);
        for (var d = 0; d < b - 1; d++) {
            c.insert(0, a.pop());
        }
        var e = a.pop();
        if (e.isError) {
            return new ExcelCalcValue(e.toErrorValue());
        }
        var f;
        if (((function () { var g = e._toDouble1(f); f = g.p0; return g.ret; })()) == false) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        var g = truncate(Math.floor(f));
        if (g < 1 || c.count < g) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        return c._inner[g - 1];
    };
    UltraCalcFunctionChoose.prototype.get_name = function () {
        return "choose";
    };
    Object.defineProperty(UltraCalcFunctionChoose.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionChoose.prototype.get_minArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionChoose.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionChoose.prototype.get_maxArgs = function () {
        return 0x7FFFFFFF;
    };
    Object.defineProperty(UltraCalcFunctionChoose.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionChoose.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return (b == false);
    };
    UltraCalcFunctionChoose.prototype.get__s = function () {
        return true;
    };
    UltraCalcFunctionChoose.prototype._v = function (a) {
        if (a == 0) {
            return true;
        }
        return false;
    };
    UltraCalcFunctionChoose.$t = markType(UltraCalcFunctionChoose, 'UltraCalcFunctionChoose', BuiltInFunctionBase.$);
    return UltraCalcFunctionChoose;
}(BuiltInFunctionBase));
export { UltraCalcFunctionChoose };
//# sourceMappingURL=UltraCalcFunctionChoose.js.map