/*
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 { markType } from "igniteui-angular-core";
import { UltraCalcFunctionXBase2Dec } from "./UltraCalcFunctionXBase2Dec";
import { UltraCalcFunctionDec2XBase } from "./UltraCalcFunctionDec2XBase";
import { stringFormat } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionXBase2XBase = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionXBase2XBase, _super);
    function UltraCalcFunctionXBase2XBase() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionXBase2XBase.prototype.evaluate = function (a, b) {
        var _this = this;
        var c = 0;
        if (b == 2) {
            var d = a.pop()._toInt321();
            if (d <= 0) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
            else {
                c = d;
            }
        }
        var e = a.pop();
        if (e.isError) {
            return new ExcelCalcValue(e.toErrorValue());
        }
        var f = e.toString();
        if (f.length > this._am) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        var g;
        var h = ((function () { var i = UltraCalcFunctionXBase2Dec._al(a._w, f, _this._al, _this._aq, _this._ap, g); g = i.p5; return i.ret; })());
        if (null != g) {
            return new ExcelCalcValue(g);
        }
        if (h < this._ao || this._an < h) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(4));
        }
        var i = UltraCalcFunctionDec2XBase._at(h, this._ak, this._ao, this._an);
        if (c > 0) {
            if (i.length < 10 && i.length > c) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(4));
            }
        }
        else {
            c = 1;
        }
        while (i.length < c) {
            i = stringFormat("{0}{1}", "0", i);
        }
        return new ExcelCalcValue(i);
    };
    UltraCalcFunctionXBase2XBase.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionXBase2XBase.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionXBase2XBase.prototype.get_maxArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionXBase2XBase.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionXBase2XBase.$t = markType(UltraCalcFunctionXBase2XBase, 'UltraCalcFunctionXBase2XBase', BuiltInFunctionBase.$);
    return UltraCalcFunctionXBase2XBase;
}(BuiltInFunctionBase));
export { UltraCalcFunctionXBase2XBase };
//# sourceMappingURL=UltraCalcFunctionXBase2XBase.js.map