/*
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 { ObservableCollection$1 } from "igniteui-webcomponents-core";
import { PrimaryKeyValue } from "./PrimaryKeyValue";
import { PropertyChangedEventArgs, delegateCombine, Number_$type, fromEnum, markType } from "igniteui-webcomponents-core";
import { NotifyCollectionChangedEventArgs } from "igniteui-webcomponents-core";
import { Dictionary$2 } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var GridSelectedKeysCollection = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(GridSelectedKeysCollection, _super);
    function GridSelectedKeysCollection() {
        var _this = _super.call(this, PrimaryKeyValue.$, 0) || this;
        _this.af = false;
        _this.ag = new Dictionary$2(PrimaryKeyValue.$, Number_$type, 0);
        _this.ah = new Dictionary$2(Number_$type, PrimaryKeyValue.$, 0);
        return _this;
    }
    Object.defineProperty(GridSelectedKeysCollection.prototype, "ae", {
        get: function () {
            return this;
        },
        enumerable: true,
        configurable: true
    });
    GridSelectedKeysCollection.prototype.aj = function (a) {
        this.collectionChanged = delegateCombine(this.collectionChanged, a);
    };
    GridSelectedKeysCollection.prototype.n = function (a) {
        _super.prototype.n.call(this, a);
        this.ag.addItem(a, this.count - 1);
        this.ah.addItem(this.count - 1, a);
    };
    GridSelectedKeysCollection.prototype.o = function (a) {
        var e_1, _a;
        var b = this.count;
        _super.prototype.o.call(this, a);
        try {
            for (var _b = tslib_1.__values(fromEnum(a)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var c = _c.value;
                this.ag.addItem(c, b);
                this.ah.addItem(b, c);
                b++;
            }
        }
        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;
            }
        }
    };
    GridSelectedKeysCollection.prototype.p = function () {
        _super.prototype.p.call(this);
        this.ag.clear();
        this.ah.clear();
    };
    GridSelectedKeysCollection.prototype.u = function (a) {
        if (this.ah.containsKey(a)) {
            var b = this.ah.item(a);
            this.ag.removeItem(b);
            this.ah.removeItem(a);
            for (var c = a + 1; c < this.count; c++) {
                if (this.ah.containsKey(c)) {
                    var d = this.ah.item(c);
                    this.ah.removeItem(c);
                    this.ah.addItem(c - 1, d);
                    this.ag.item(d, c - 1);
                }
            }
        }
        var e = this._inner[a];
        if (a == 0) {
            this._inner.shift();
        }
        else {
            this._inner.splice(a, 1);
        }
        this.ad(new PropertyChangedEventArgs("Count"));
        this.ad(new PropertyChangedEventArgs("Item[]"));
        if (!this.af) {
            this.ac(new NotifyCollectionChangedEventArgs(1, 1, e, a));
        }
    };
    GridSelectedKeysCollection.prototype.v = function (index_, numToRemove_) {
        _super.prototype.v.call(this, index_, numToRemove_);
        for (var a = index_; a < index_ + numToRemove_; a++) {
            if (this.ah.containsKey(a)) {
                var b = this.ah.item(a);
                this.ag.removeItem(b);
                this.ah.removeItem(a);
            }
        }
    };
    GridSelectedKeysCollection.prototype.x = function (a, b) {
        _super.prototype.x.call(this, a, b);
        if (this.ah.containsKey(a)) {
            var c = this.ah.item(a);
            this.ah.item(a, b);
            this.ag.removeItem(c);
            this.ag.addItem(b, a);
        }
    };
    GridSelectedKeysCollection.prototype.r = function (a, b) {
        _super.prototype.r.call(this, a, b);
        for (var c = a; c < this.count; c++) {
            var d = this._inner[c];
            if (this.ag.containsKey(d)) {
                this.ag.item(d, c);
                this.ah.removeItem(c);
                this.ah.addItem(c, d);
            }
            else {
                this.ag.addItem(d, c);
                this.ah.addItem(c, d);
            }
        }
    };
    GridSelectedKeysCollection.prototype.ai = function (a) {
        if (this.ag.containsKey(a)) {
            return this.ag.item(a);
        }
        return -1;
    };
    GridSelectedKeysCollection.$t = markType(GridSelectedKeysCollection, 'GridSelectedKeysCollection', ObservableCollection$1.$.specialize(PrimaryKeyValue.$));
    return GridSelectedKeysCollection;
}(ObservableCollection$1));
export { GridSelectedKeysCollection };
//# sourceMappingURL=GridSelectedKeysCollection.js.map
