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