/*
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 { Base, fromEnum, markType } from "./type";
import { List$1 } from "./List$1";
import { Transaction } from "./Transaction";
import { Dictionary$2 } from "./Dictionary$2";
import { TransactionState } from "./TransactionState";
import { ArgumentNullException } from "./ArgumentNullException";
import { stringIsNullOrWhiteSpace } from "./string";
/**
 * @hidden
 */
var BaseTransactionService = /** @class */ (function (_super) {
    tslib_1.__extends(BaseTransactionService, _super);
    function BaseTransactionService(a, b, c) {
        var _this = _super.call(this) || this;
        _this.i = false;
        _this.p = new List$1(Transaction.$, 0);
        _this.n = null;
        _this.h = null;
        _this.r = null;
        _this.stateChanged = null;
        if (a == null || b == null) {
            throw new ArgumentNullException(1);
        }
        _this.h = a;
        _this.r = b;
        if (c != null) {
            _this.n = new Dictionary$2(Base.$, TransactionState.$, 2, c);
        }
        else {
            _this.n = new Dictionary$2(Base.$, TransactionState.$, 0);
        }
        return _this;
    }
    Object.defineProperty(BaseTransactionService.prototype, "m", {
        get: function () {
            return this.i;
        },
        set: function (a) {
            this.i = a;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BaseTransactionService.prototype, "q", {
        get: function () {
            return this.p;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(BaseTransactionService.prototype, "o", {
        get: function () {
            return this.n;
        },
        enumerable: true,
        configurable: true
    });
    BaseTransactionService.prototype.get_l = function () {
        return this.i;
    };
    BaseTransactionService.prototype.set_l = function (a) {
    };
    Object.defineProperty(BaseTransactionService.prototype, "l", {
        get: function () {
            return this.get_l();
        },
        set: function (a) {
            this.set_l(a);
        },
        enumerable: true,
        configurable: true
    });
    BaseTransactionService.prototype.get_k = function () {
        return false;
    };
    Object.defineProperty(BaseTransactionService.prototype, "k", {
        get: function () {
            return this.get_k();
        },
        enumerable: true,
        configurable: true
    });
    BaseTransactionService.prototype.get_j = function () {
        return false;
    };
    Object.defineProperty(BaseTransactionService.prototype, "j", {
        get: function () {
            return this.get_j();
        },
        enumerable: true,
        configurable: true
    });
    BaseTransactionService.prototype.af = function (a, b) {
        if (a.containsKey(b.id)) {
            if (this.h != null) {
                this.h(a.item(b.id), b.value);
            }
            else {
                a.item(b.id).value = b.value;
            }
        }
        else {
            a.addItem(b.id, new TransactionState(b.id, b.type, this.r(b.value)));
        }
    };
    BaseTransactionService.prototype.aa = function (a, b) {
        if (this.stateChanged != null) {
            this.stateChanged(a, b);
        }
    };
    BaseTransactionService.prototype.z = function (a, b, c) {
    };
    BaseTransactionService.prototype.v = function (a, b) {
        if (b === void 0) { b = false; }
        if (this.m) {
            this.af(this.o, a);
            this.q.add(a);
        }
    };
    BaseTransactionService.prototype.w = function (a) {
        if (a === void 0) { a = null; }
        this.n.clear();
        this.p.clear();
    };
    BaseTransactionService.prototype.g = function (a) {
        if (this.o.count > 0 && this.o.containsKey(a)) {
            return this.o.item(a);
        }
        return null;
    };
    BaseTransactionService.prototype.ad = function () {
        this.i = true;
    };
    BaseTransactionService.prototype.y = function (a) {
        this.i = false;
        this.x();
    };
    BaseTransactionService.prototype.x = function (a) {
        if (a === void 0) { a = -1; }
        if (a > -1) {
            for (var b = 0; b < this.q.count; b++) {
                var c = this.q._inner[b];
                if (c.transactionID == a) {
                    this.q.removeAt(b);
                    this.o.clear();
                    for (var d = 0; d < this.q.count; d++) {
                        this.af(this.o, this.q._inner[d]);
                    }
                    break;
                }
            }
        }
        else {
            this.n.clear();
            this.p.clear();
        }
    };
    BaseTransactionService.prototype.d = function (a) {
        for (var b = 0; b < this.q.count; b++) {
            if (this.q._inner[b].transactionID == a) {
                return this.q._inner[b];
            }
        }
        return null;
    };
    BaseTransactionService.prototype.e = function (a) {
        return null;
    };
    BaseTransactionService.prototype.s = function (a) {
        return -1;
    };
    BaseTransactionService.prototype.u = function (a) {
    };
    BaseTransactionService.prototype.ac = function (a) {
    };
    BaseTransactionService.prototype.ae = function () {
    };
    BaseTransactionService.prototype.ab = function () {
    };
    BaseTransactionService.prototype.a = function (a) {
        var e_1, _a;
        if (a === void 0) { a = -1; }
        var b = new List$1(TransactionState.$, 0);
        try {
            for (var _b = tslib_1.__values(fromEnum(this.o.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                b.add(c);
            }
        }
        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; }
        }
        return b.toArray();
    };
    BaseTransactionService.prototype.c = function (a) {
        if (a === void 0) { a = null; }
        if (a != null) {
            var b = new List$1(Transaction.$, 0);
            for (var c = 0; c < this.q.count; c++) {
                if (this.q._inner[c].id == a) {
                    b.add(this.q._inner[c]);
                }
            }
            return b.toArray();
        }
        return this.q.toArray();
    };
    BaseTransactionService.prototype.b = function () {
        var a = new List$1(Transaction.$, 0);
        for (var b = 0; b < this.q.count; b++) {
            if (!stringIsNullOrWhiteSpace(this.q._inner[b].error)) {
                a.add(this.q._inner[b]);
            }
        }
        return a.toArray();
    };
    BaseTransactionService.$t = markType(BaseTransactionService, 'BaseTransactionService');
    return BaseTransactionService;
}(Base));
export { BaseTransactionService };
//# sourceMappingURL=BaseTransactionService.js.map