/*
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 { MathUtilities } from "./MathUtilities";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { markType } from "igniteui-angular-core";
import { stringEndsWith, stringStartsWith } from "igniteui-angular-core";
import { trim } from "igniteui-angular-core";
/**
 * @hidden
 */
var UltraCalcFunctionValue = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionValue, _super);
    function UltraCalcFunctionValue() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionValue.prototype.evaluate = function (a, b) {
        var c = a.pop();
        if (c.isError) {
            return new ExcelCalcValue(c.toErrorValue());
        }
        var d = false;
        var e = 0;
        if (typeof c.value === 'string') {
            var f_1 = (c.value).trim();
            if (stringEndsWith(f_1, "kr")) {
                f_1 = f_1.substr(0, f_1.length - 2);
            }
            else if (stringStartsWith(f_1, "R$") || stringStartsWith(f_1, "S/")) {
                f_1 = f_1.substr(2, f_1.length - 2);
            }
            else {
                f_1 = trim.apply(void 0, tslib_1.__spread([f_1], UltraCalcFunctionValue._ak));
            }
            d = ((function () { var g = MathUtilities.c(f_1, a._w, e); e = g.p2; return g.ret; })());
        }
        if (!d) {
            d = ((function () { var g = c._toDouble1(e); e = g.p0; return g.ret; })());
        }
        return (d) ? new ExcelCalcValue(e) : new ExcelCalcValue(new ExcelCalcErrorValue(4));
    };
    UltraCalcFunctionValue.prototype.get_name = function () {
        return "value";
    };
    Object.defineProperty(UltraCalcFunctionValue.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionValue.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionValue.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionValue.prototype.get_maxArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionValue.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionValue.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionValue.$t = markType(UltraCalcFunctionValue, 'UltraCalcFunctionValue', BuiltInFunctionBase.$);
    UltraCalcFunctionValue._ak = ['$', '\u0080', '£', '¤', '¥', '৲', '৳', '฿', '៛', '₠', '₡', '₢', '₣', '₤', '₦', '₧', '₨', '₩', '₪', '₫', '€', '₭', '₮', '₯', '﷼', '﹩', '＄', '￡', '￥', '￦'];
    return UltraCalcFunctionValue;
}(BuiltInFunctionBase));
export { UltraCalcFunctionValue };
//# sourceMappingURL=UltraCalcFunctionValue.js.map