/*
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 { markType } from "igniteui-angular-core";
import { CalcFunctionUtilities } from "./CalcFunctionUtilities";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
/**
 * @hidden
 */
var UltraCalcFunctionSkew = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionSkew, _super);
    function UltraCalcFunctionSkew() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionSkew.prototype.evaluate = function (a, b) {
        return UltraCalcFunctionSkew._ak(a, b, true);
    };
    UltraCalcFunctionSkew._ak = function (a, b, c) {
        return CalcFunctionUtilities.d(a, b, 1229, function (d) {
            if (d.count < 3) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(2));
            }
            var e = CalcFunctionUtilities.z(d);
            var f = CalcFunctionUtilities.t(d.count, e);
            var g = CalcFunctionUtilities.s(d, f);
            var h = CalcFunctionUtilities.y(g, d.count, c);
            if (h == 0) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(2));
            }
            var i = 0;
            for (var j = 0; j < d.count; j++) {
                var k = (d._inner[j] - f) / h;
                i += (k * k * k);
            }
            var l = c ? d.count / ((d.count - 1) * (d.count - 2)) : (1 / d.count);
            return new ExcelCalcValue(l * i);
        });
    };
    UltraCalcFunctionSkew.prototype.get_name = function () {
        return "skew";
    };
    Object.defineProperty(UltraCalcFunctionSkew.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionSkew.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionSkew.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionSkew.prototype.get_maxArgs = function () {
        return 0x7FFFFFFF;
    };
    Object.defineProperty(UltraCalcFunctionSkew.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionSkew.$t = markType(UltraCalcFunctionSkew, 'UltraCalcFunctionSkew', BuiltInFunctionBase.$);
    return UltraCalcFunctionSkew;
}(BuiltInFunctionBase));
export { UltraCalcFunctionSkew };
//# sourceMappingURL=UltraCalcFunctionSkew.js.map