/*
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 { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { typeCast, markType } from "igniteui-angular-core";
import { CellCalcReference } from "./CellCalcReference";
import { WorksheetRegion } from "./WorksheetRegion";
import { ReadOnlyCollection$1 } from "igniteui-angular-core";
import { TempCellCalcReference } from "./TempCellCalcReference";
import { ExcelCalcEngine } from "./ExcelCalcEngine";
/**
 * @hidden
 */
export let UltraCalcFunctionRow = /*@__PURE__*/ (() => {
    class UltraCalcFunctionRow extends BuiltInFunctionBase {
        evaluate(a, b) {
            let c;
            if (b == 0) {
                c = UltraCalcFunctionRow._ak(a._k);
            }
            else {
                let d = a.pop();
                if (d.isReference == false) {
                    if (d.isError) {
                        return d;
                    }
                    return new ExcelCalcValue(new ExcelCalcErrorValue(1));
                }
                c = UltraCalcFunctionRow._ak(d.toReference());
            }
            if (c == -1) {
                return new ExcelCalcValue(new ExcelCalcErrorValue(0));
            }
            return new ExcelCalcValue(c);
        }
        static _ak(a) {
            let b = ExcelCalcEngine.af(a);
            let c = typeCast(CellCalcReference.$, b);
            if (c != null) {
                return c._w.index + 1;
            }
            let d = typeCast(WorksheetRegion.$, b);
            if (d != null) {
                return d.firstRow + 1;
            }
            let e = typeCast(ReadOnlyCollection$1.$.specialize(WorksheetRegion.$), b);
            if (e != null) {
                if (e.count != 1) {
                    return -1;
                }
                return e.item(0).firstRow + 1;
            }
            let f = typeCast(TempCellCalcReference.$, b);
            if (f != null) {
                return f._as + 1;
            }
            return -1;
        }
        get_name() {
            return "row";
        }
        get name() {
            return this.get_name();
        }
        get_minArgs() {
            return 0;
        }
        get minArgs() {
            return this.get_minArgs();
        }
        get_maxArgs() {
            return 1;
        }
        get maxArgs() {
            return this.get_maxArgs();
        }
        _v(a) {
            return false;
        }
    }
    UltraCalcFunctionRow.$t = markType(UltraCalcFunctionRow, 'UltraCalcFunctionRow', BuiltInFunctionBase.$);
    return UltraCalcFunctionRow;
})();
