/*
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 { UltraCalcFunctionStdev } from "./UltraCalcFunctionStdev";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { CalcFunctionUtilities } from "./CalcFunctionUtilities";
import { UltraCalcFunctionAverage } from "./UltraCalcFunctionAverage";
import { markType } from "igniteui-angular-core";
import { UltraCalcFunctionMax } from "./UltraCalcFunctionMax";
import { UltraCalcFunctionMin } from "./UltraCalcFunctionMin";
import { UltraCalcFunctionProduct } from "./UltraCalcFunctionProduct";
import { UltraCalcFunctionVar } from "./UltraCalcFunctionVar";
import { truncate } from "igniteui-angular-core";
import { boxArray$1 } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionSubtotal = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionSubtotal, _super);
    function UltraCalcFunctionSubtotal() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionSubtotal.prototype.evaluate = function (a, b) {
        var c = new Array(b - 1);
        for (var d = c.length - 1; d >= 0; d--) {
            var e = a.pop();
            c[d] = e;
        }
        var f = a.pop();
        if (f.isError) {
            return f;
        }
        var g;
        if (((function () { var h = f._toDouble1(g); g = h.p0; return h.ret; })()) == false) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        var h = truncate(g);
        var i = false;
        if (h > 100) {
            i = true;
            h -= 100;
        }
        switch (h) {
            case 1: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionAverage._ak);
            case 2: return CalcFunctionUtilities.l(boxArray$1(c), CalcFunctionUtilities.c(a, false, false, i) | 2048);
            case 3: return CalcFunctionUtilities.l(boxArray$1(c), CalcFunctionUtilities.c(a, true, false, i) | 2048);
            case 4: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionMax._ak);
            case 5: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionMin._ak);
            case 6: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, UltraCalcFunctionProduct._ak);
            case 7: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, function (j) { return UltraCalcFunctionStdev._al(j, true); });
            case 8: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, function (j) { return UltraCalcFunctionStdev._al(j, false); });
            case 9:
                {
                    var j_1 = 0;
                    return CalcFunctionUtilities.g(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, function (k) { return j_1 += k; }) || new ExcelCalcValue(j_1);
                }
            case 10: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, function (k) { return UltraCalcFunctionVar._ak(k, true); });
            case 11: return CalcFunctionUtilities.e(boxArray$1(c), CalcFunctionUtilities.b(a, false, false, i) | 2048, function (k) { return UltraCalcFunctionVar._ak(k, false); });
            default: return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
    };
    UltraCalcFunctionSubtotal.prototype.canParameterBeEnumerable = function (a) {
        return 1 <= a;
    };
    UltraCalcFunctionSubtotal.prototype.get_name = function () {
        return "subtotal";
    };
    Object.defineProperty(UltraCalcFunctionSubtotal.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSubtotal.prototype.get_minArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionSubtotal.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSubtotal.prototype.get_maxArgs = function () {
        return 0x7FFFFFFF;
    };
    Object.defineProperty(UltraCalcFunctionSubtotal.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionSubtotal.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionSubtotal.$t = markType(UltraCalcFunctionSubtotal, 'UltraCalcFunctionSubtotal', BuiltInFunctionBase.$);
    return UltraCalcFunctionSubtotal;
}(BuiltInFunctionBase));
export { UltraCalcFunctionSubtotal };
