/*
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 { __extends } from "tslib";
import { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { List$1 } from "igniteui-angular-core";
import { Number_$type, runOn, markType } from "igniteui-angular-core";
import { CalcArgumentHelper } from "./CalcArgumentHelper";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { truncate } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionSmall = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionSmall, _super);
    function UltraCalcFunctionSmall() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionSmall._ak = function (a, b) {
        var c = a.pop();
        var d = a.pop();
        if (c.isError) {
            return new ExcelCalcValue(c.toErrorValue());
        }
        var e = c._toDouble3();
        var f = new List$1(Number_$type, 0);
        var g = CalcArgumentHelper.c(d, 0, 1101, runOn(f, f.add));
        if (g != null) {
            return g;
        }
        if (e < 1) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        if (f.count == 0 || e > f.count) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        f.y();
        if (b) {
            e = f.count - e;
        }
        else {
            e--;
        }
        var h = f._inner[truncate(e)];
        return new ExcelCalcValue(h);
    };
    UltraCalcFunctionSmall.prototype.evaluate = function (a, b) {
        return UltraCalcFunctionSmall._ak(a, false);
    };
    UltraCalcFunctionSmall.prototype.get_maxArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionSmall.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSmall.prototype.get_minArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionSmall.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSmall.prototype.get_name = function () {
        return "small";
    };
    Object.defineProperty(UltraCalcFunctionSmall.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSmall.$t = markType(UltraCalcFunctionSmall, 'UltraCalcFunctionSmall', BuiltInFunctionBase.$);
    return UltraCalcFunctionSmall;
}(BuiltInFunctionBase));
export { UltraCalcFunctionSmall };
