/*
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 { BuiltInFunctionBase } from "./BuiltInFunctionBase";
import { ExcelCalcValue } from "./ExcelCalcValue";
import { markType } from "igniteui-angular-core";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { MathUtilities } from "./MathUtilities";
import { truncate } from "igniteui-angular-core";
/**
 * @hidden
 */
export class UltraCalcFunctionSearch extends BuiltInFunctionBase {
    evaluate(a, b) {
        let c = null;
        if (b > 2) {
            c = a.pop();
        }
        let d = a.pop();
        let e = a.pop();
        if (e.isError) {
            return e;
        }
        if (d.isError) {
            return d;
        }
        if (c != null && c.isError) {
            return c;
        }
        let f = e.toString();
        let g = d.toString();
        let h = 0;
        if (c != null) {
            let i;
            if (((() => { let j = c._toDouble1(i); i = j.p0; return j.ret; })()) == false) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(1));
            }
            h = truncate(MathUtilities.j(i)) - 1;
            if (h < 0 || g.length <= h) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(1));
            }
        }
        let j = a._w.compareInfo.indexOf6(g, f, h, 1);
        if (j < 0) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        return new ExcelCalcValue(j + 1);
    }
    get_name() {
        return "search";
    }
    get name() {
        return this.get_name();
    }
    get_minArgs() {
        return 2;
    }
    get minArgs() {
        return this.get_minArgs();
    }
    get_maxArgs() {
        return 3;
    }
    get maxArgs() {
        return this.get_maxArgs();
    }
    doesParameterAllowIntermediateResultArray(a, b) {
        return true;
    }
}
UltraCalcFunctionSearch.$t = markType(UltraCalcFunctionSearch, 'UltraCalcFunctionSearch', BuiltInFunctionBase.$);
//# sourceMappingURL=UltraCalcFunctionSearch.js.map