/*
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 { Dictionary$2 } from "igniteui-react-core/ES5/Dictionary$2";
import { Base, Number_$type, String_$type, markType } from "igniteui-react-core/ES5/type";
var DataSourceManager = /** @class */ (function (_super) {
    tslib_1.__extends(DataSourceManager, _super);
    function DataSourceManager() {
        var _this = _super.call(this) || this;
        _this.d = null;
        _this.c = null;
        _this.b = null;
        _this.a = null;
        _this.d = new Dictionary$2(Base.$, Base.$, 0);
        _this.c = new Dictionary$2(Base.$, Base.$, 0);
        _this.b = new Dictionary$2(Base.$, Number_$type, 0);
        _this.a = new Dictionary$2(String_$type, Base.$, 0);
        return _this;
    }
    DataSourceManager.prototype.e = function (target_, dataSource_) {
        if (this.d.containsKey(target_)) {
            this.f(target_);
        }
        this.d.addItem(target_, dataSource_);
        var arr_ = dataSource_.dataView();
        if (this.c.containsKey(arr_)) {
            this.c.removeItem(arr_);
        }
        this.c.addItem(arr_, dataSource_);
        var a = (dataSource_.id);
        if (this.a.containsKey(a)) {
            this.a.removeItem(a);
        }
        this.a.addItem(a, dataSource_);
        if (!this.b.containsKey(dataSource_)) {
            this.b.addItem(dataSource_, 1);
        }
        else {
            this.b.item(dataSource_, this.b.item(dataSource_) + 1);
        }
        target_.itemsSource(arr_);
    };
    DataSourceManager.prototype.f = function (target_) {
        var curr_ = target_.itemsSource();
        this.d.removeItem(target_);
        if (!this.c.containsKey(curr_)) {
            return;
        }
        var ds_ = this.c.item(curr_);
        this.b.item(ds_, this.b.item(ds_) - 1);
        if (this.b.item(ds_) == 0) {
            this.b.removeItem(ds_);
            this.c.removeItem(curr_);
            var a = (ds_.id);
            this.a.removeItem(a);
        }
    };
    DataSourceManager.$t = markType(DataSourceManager, 'DataSourceManager');
    return DataSourceManager;
}(Base));
export { DataSourceManager };
