/*
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 { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { UltraCalcFunctionGcd } from "./UltraCalcFunctionGcd";
import { markType } from "igniteui-angular-core";
import { intDivide } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionLcm = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionLcm, _super);
    function UltraCalcFunctionLcm() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionLcm.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 = UltraCalcFunctionLcm._ak(d, e);
        }
        return new ExcelCalcValue(d);
    };
    UltraCalcFunctionLcm.prototype.canParameterBeEnumerable = function (a) {
        return true;
    };
    UltraCalcFunctionLcm.prototype.get_name = function () {
        return "lcm";
    };
    Object.defineProperty(UltraCalcFunctionLcm.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionLcm.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionLcm.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionLcm.prototype.get_maxArgs = function () {
        return 0x7FFFFFFF;
    };
    Object.defineProperty(UltraCalcFunctionLcm.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionLcm._ak = function (a, b) {
        if (a == 0 && b == 0) {
            return 0;
        }
        return intDivide((a * b), UltraCalcFunctionGcd._ak(a, b));
    };
    UltraCalcFunctionLcm.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return (b == false);
    };
    UltraCalcFunctionLcm.$t = markType(UltraCalcFunctionLcm, 'UltraCalcFunctionLcm', BuiltInFunctionBase.$);
    return UltraCalcFunctionLcm;
}(BuiltInFunctionBase));
export { UltraCalcFunctionLcm };
//# sourceMappingURL=UltraCalcFunctionLcm.js.map