/*
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 { Dictionary$2 } from "igniteui-react-core/ES2015/Dictionary$2";
import { Base, Number_$type, String_$type, markType } from "igniteui-react-core/ES2015/type";
export class DataSourceManager extends Base {
    constructor() {
        super();
        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);
    }
    e(target_, dataSource_) {
        if (this.d.containsKey(target_)) {
            this.f(target_);
        }
        this.d.addItem(target_, dataSource_);
        let arr_ = dataSource_.dataView();
        if (this.c.containsKey(arr_)) {
            this.c.removeItem(arr_);
        }
        this.c.addItem(arr_, dataSource_);
        let 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_);
    }
    f(target_) {
        let curr_ = target_.itemsSource();
        this.d.removeItem(target_);
        if (!this.c.containsKey(curr_)) {
            return;
        }
        let 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_);
            let a = (ds_.id);
            this.a.removeItem(a);
        }
    }
}
DataSourceManager.$t = markType(DataSourceManager, 'DataSourceManager');
