/*
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 { 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
 */
var UltraCalcFunctionRow = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionRow, _super);
    function UltraCalcFunctionRow() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionRow.prototype.evaluate = function (a, b) {
        var c;
        if (b == 0) {
            c = UltraCalcFunctionRow._ak(a._k);
        }
        else {
            var 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);
    };
    UltraCalcFunctionRow._ak = function (a) {
        var b = ExcelCalcEngine.u(a);
        var c = typeCast(CellCalcReference.$, b);
        if (c != null) {
            return c._w.index + 1;
        }
        var d = typeCast(WorksheetRegion.$, b);
        if (d != null) {
            return d.firstRow + 1;
        }
        var e = typeCast(ReadOnlyCollection$1.$.specialize(WorksheetRegion.$), b);
        if (e != null) {
            if (e.count != 1) {
                return -1;
            }
            return e.item(0).firstRow + 1;
        }
        var f = typeCast(TempCellCalcReference.$, b);
        if (f != null) {
            return f._as + 1;
        }
        return -1;
    };
    UltraCalcFunctionRow.prototype.get_name = function () {
        return "row";
    };
    Object.defineProperty(UltraCalcFunctionRow.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionRow.prototype.get_minArgs = function () {
        return 0;
    };
    Object.defineProperty(UltraCalcFunctionRow.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionRow.prototype.get_maxArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionRow.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionRow.prototype._v = function (a) {
        return false;
    };
    UltraCalcFunctionRow.$t = markType(UltraCalcFunctionRow, 'UltraCalcFunctionRow', BuiltInFunctionBase.$);
    return UltraCalcFunctionRow;
}(BuiltInFunctionBase));
export { UltraCalcFunctionRow };
//# sourceMappingURL=UltraCalcFunctionRow.js.map