/*
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 { 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
 */
export let UltraCalcFunctionSmall = /*@__PURE__*/ (() => {
    class UltraCalcFunctionSmall extends BuiltInFunctionBase {
        static _ak(a, b) {
            let c = a.pop();
            let d = a.pop();
            if (c.isError) {
                return new ExcelCalcValue(c.toErrorValue());
            }
            let e = c._toDouble3();
            let f = new List$1(Number_$type, 0);
            let 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--;
            }
            let h = f._inner[truncate(e)];
            return new ExcelCalcValue(h);
        }
        evaluate(a, b) {
            return UltraCalcFunctionSmall._ak(a, false);
        }
        get_maxArgs() {
            return 2;
        }
        get maxArgs() {
            return this.get_maxArgs();
        }
        get_minArgs() {
            return 2;
        }
        get minArgs() {
            return this.get_minArgs();
        }
        get_name() {
            return "small";
        }
        get name() {
            return this.get_name();
        }
    }
    UltraCalcFunctionSmall.$t = markType(UltraCalcFunctionSmall, 'UltraCalcFunctionSmall', BuiltInFunctionBase.$);
    return UltraCalcFunctionSmall;
})();
