/*
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, Number_$type, Delegate_$type, fromEnum, runOn, markType } from "igniteui-webcomponents-core";
import { ITickProvider_$type } from "igniteui-webcomponents-core";
import { List$1 } from "igniteui-webcomponents-core";
import { Dictionary$2 } from "igniteui-webcomponents-core";
/**
 * @hidden
 */
var BrowserTickProvider = /** @class */ /*@__PURE__*/ (function (_super) {
    tslib_1.__extends(BrowserTickProvider, _super);
    function BrowserTickProvider(a) {
        var _this = _super.call(this) || this;
        _this.e = 0;
        _this.c = null;
        _this._requestAnimationFrame = null;
        _this.d = new List$1(Delegate_$type, 0);
        _this.b = false;
        _this.requestAnimationFrame = a.getRequestAnimationFrame();
        _this.c = new Dictionary$2(Number_$type, Delegate_$type, 0);
        return _this;
    }
    Object.defineProperty(BrowserTickProvider.prototype, "requestAnimationFrame", {
        get: function () {
            return this._requestAnimationFrame;
        },
        set: function (a) {
            this._requestAnimationFrame = a;
        },
        enumerable: true,
        configurable: true
    });
    BrowserTickProvider.prototype.f = function () {
        var e_1, _a;
        this.b = false;
        this.d.clear();
        try {
            for (var _b = tslib_1.__values(fromEnum(this.c.values)), _c = _b.next(); !_c.done; _c = _b.next()) {
                var a = _c.value;
                this.d.add(a);
            }
        }
        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;
            }
        }
        for (var b = 0; b < this.d.count; b++) {
            this.d._inner[b]();
        }
        this.d.clear();
    };
    BrowserTickProvider.prototype.setupTicking = function (a) {
        var b = this.e;
        this.e++;
        this.c.item(b, a);
        return b;
    };
    BrowserTickProvider.prototype.requestFrame = function (a) {
        if (this.b) {
            return;
        }
        this.b = true;
        this.requestAnimationFrame(runOn(this, this.f));
    };
    BrowserTickProvider.prototype.teardownTicking = function (a) {
        if (this.c.containsKey(a)) {
            this.c.removeItem(a);
        }
    };
    BrowserTickProvider.$t = markType(BrowserTickProvider, 'BrowserTickProvider', Base.$, [ITickProvider_$type]);
    return BrowserTickProvider;
}(Base));
export { BrowserTickProvider };
//# sourceMappingURL=BrowserTickProvider.js.map
