/*
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 { MathUtilities } from "./MathUtilities";
import { markType } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionEcmaCeiling = /** @class */ /*@__PURE__*/ (function (_super) {
    __extends(UltraCalcFunctionEcmaCeiling, _super);
    function UltraCalcFunctionEcmaCeiling() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionEcmaCeiling.prototype.evaluate = function (a, b) {
        var c = null;
        if (b == 2) {
            c = a.pop();
        }
        var d = a.pop();
        if (d.isError) {
            return new ExcelCalcValue(d.toErrorValue());
        }
        if (c != null && c.isError) {
            return new ExcelCalcValue(c.toErrorValue());
        }
        var e = d._toDouble3();
        var f = c == null ? 1 : c._toDouble3();
        if (e == 0 || f == 0) {
            return new ExcelCalcValue(0);
        }
        if (f < 0 && e > 0) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        var g = MathUtilities.i(Math.ceil(e / f) * f);
        return new ExcelCalcValue(g);
    };
    UltraCalcFunctionEcmaCeiling.prototype.get_name = function () {
        return "ecma.ceiling";
    };
    Object.defineProperty(UltraCalcFunctionEcmaCeiling.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionEcmaCeiling.prototype.get_minArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionEcmaCeiling.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionEcmaCeiling.prototype.get_maxArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionEcmaCeiling.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: false,
        configurable: true
    });
    UltraCalcFunctionEcmaCeiling.$t = markType(UltraCalcFunctionEcmaCeiling, 'UltraCalcFunctionEcmaCeiling', BuiltInFunctionBase.$);
    return UltraCalcFunctionEcmaCeiling;
}(BuiltInFunctionBase));
export { UltraCalcFunctionEcmaCeiling };
