/*
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 { fromEn, typeCast, markType } from "igniteui-angular-core";
import { ExcelCalcErrorValue } from "./ExcelCalcErrorValue";
import { NamedCalcReferenceUnconnected } from "./NamedCalcReferenceUnconnected";
/**
 * @hidden
 */
var UltraCalcFunctionCountBlank = /** @class */ (function (_super) {
    tslib_1.__extends(UltraCalcFunctionCountBlank, _super);
    function UltraCalcFunctionCountBlank() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    UltraCalcFunctionCountBlank.prototype.evaluate = function (a, b) {
        var e_1, _a;
        var c = a.pop();
        if (!c.isReference) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        if (c.isArrayGroup) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(1));
        }
        if (c.isArray) {
            var d = c.toArrayProxy();
            var e_2 = 0;
            d._m(false, function (f, g) {
                if (!f.isNull) {
                    e_2++;
                }
            });
            var f = d.getLength(0) * d.getLength(1);
            return new ExcelCalcValue(f - e_2);
        }
        var g = c.toReference();
        var h = 0;
        if (g.isEnumerable) {
            try {
                for (var _b = tslib_1.__values(fromEn(g.references)), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var i = _c.value;
                    if (i.value.isNull) {
                        h++;
                    }
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_1) throw e_1.error; }
            }
        }
        else if (typeCast(NamedCalcReferenceUnconnected.$, g) !== null) {
            return new ExcelCalcValue(new ExcelCalcErrorValue(7));
        }
        else {
            h = c.isNull ? 1 : 0;
        }
        return new ExcelCalcValue(h);
    };
    UltraCalcFunctionCountBlank.prototype.get_name = function () {
        return "countblank";
    };
    Object.defineProperty(UltraCalcFunctionCountBlank.prototype, "name", {
        get: function () {
            return this.get_name();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionCountBlank.prototype.get_minArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionCountBlank.prototype, "minArgs", {
        get: function () {
            return this.get_minArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionCountBlank.prototype.get_maxArgs = function () {
        return 1;
    };
    Object.defineProperty(UltraCalcFunctionCountBlank.prototype, "maxArgs", {
        get: function () {
            return this.get_maxArgs();
        },
        enumerable: true,
        configurable: true
    });
    UltraCalcFunctionCountBlank.$t = markType(UltraCalcFunctionCountBlank, 'UltraCalcFunctionCountBlank', BuiltInFunctionBase.$);
    return UltraCalcFunctionCountBlank;
}(BuiltInFunctionBase));
export { UltraCalcFunctionCountBlank };
//# sourceMappingURL=UltraCalcFunctionCountBlank.js.map