/*
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 { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { markType } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionGcd = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionGcd, _super);
    function UltraCalcFunctionGcd() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionGcd.prototype.evaluate = function (a, b) {
        var c = this._getArguments(a, b, true);
        var d = c[0]._toInt();
        if (d < 0) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        var e;
        if (c.length == 1) {
            return new ExcelCalcValue(d);
        }
        for (var f = 1; f < c.length; f++) {
            var g = c[f];
            if (g.isError) {
                return new ExcelCalcValue(g.toErrorValue());
            }
            e = g._toInt();
            if (e < 0) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
            d = UltraCalcFunctionGcd._ak(d, e);
        }
        return new ExcelCalcValue(d);
    };
    UltraCalcFunctionGcd.prototype.canParameterBeEnumerable = function (a) {
        return true;
    };
    UltraCalcFunctionGcd.prototype.get_name = function () {
        return "gcd";
    };
    Object.defineProperty(UltraCalcFunctionGcd.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionGcd.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionGcd.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionGcd.prototype.get_maxArgs = function () {
        return 0x7FFFFFFF;
    };
    Object.defineProperty(UltraCalcFunctionGcd.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionGcd._ak = function (a, b) {
        if (b == 0) {
            return a;
        }
        return UltraCalcFunctionGcd._ak(b, a % b);
    };
    UltraCalcFunctionGcd.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return (b == false);
    };
    UltraCalcFunctionGcd.$t = markType(UltraCalcFunctionGcd, 'UltraCalcFunctionGcd', BuiltInFunctionBase.$);
    return UltraCalcFunctionGcd;
}(BuiltInFunctionBase));
export { UltraCalcFunctionGcd };
