/*
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";
/**
 * @hidden
 */
var UltraCalcFunctionFind = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionFind, _super);
    function UltraCalcFunctionFind() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionFind.prototype.evaluate = function (a, b) {
        var c = 0;
        if (b > 2) {
            if (a.peek().isError) {
                return new ExcelCalcValue(a.pop().toErrorValue());
            }
            c = a.pop()._toInt321() - 1;
            if (c < 0) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(1));
            }
        }
        if (a.peek().isError) {
            return new ExcelCalcValue(a.pop().toErrorValue());
        }
        var d = a.pop().toString();
        if (c > d.length - 1) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        if (a.peek().isError) {
            return new ExcelCalcValue(a.pop().toErrorValue());
        }
        var e = -1;
        var f = a.pop().toString();
        if (f.length == 0) {
            e = 1;
        }
        else {
            e = d.indexOf(f, c);
        }
        if (e != -1) {
            return new ExcelCalcValue(e + 1);
        }
        else {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
    };
    UltraCalcFunctionFind.prototype.get_name = function () {
        return "find";
    };
    Object.defineProperty(UltraCalcFunctionFind.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionFind.prototype.get_minArgs = function () {
        return 2;
    };
    Object.defineProperty(UltraCalcFunctionFind.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionFind.prototype.get_maxArgs = function () {
        return 3;
    };
    Object.defineProperty(UltraCalcFunctionFind.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionFind.prototype.doesParameterAllowIntermediateResultArray = function (a, b) {
        return true;
    };
    UltraCalcFunctionFind.$t = markType(UltraCalcFunctionFind, 'UltraCalcFunctionFind', BuiltInFunctionBase.$);
    return UltraCalcFunctionFind;
}(BuiltInFunctionBase));
export { UltraCalcFunctionFind };
//# sourceMappingURL=UltraCalcFunctionFind.js.map