define(["require", "exports", "rx/dist/rx.all", "./config/Breakpoints", "./Utils"], function (require, exports, Rx, Breakpoints_1, Utils_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var DEBOUNCE_DELAY = 200;
    var ScreenSizeDetection = /** @class */ (function () {
        function ScreenSizeDetection() {
            this.screensize = this.calculate();
            this.subject = new Rx.BehaviorSubject(this.screensize);
            this.addEventListeners();
        }
        ScreenSizeDetection.prototype.get = function () {
            return this.subject;
        };
        ScreenSizeDetection.prototype.calculate = function () {
            var deviceWidth = this.mocksize || window.innerWidth;
            var sizes = Object.keys(Breakpoints_1.Breakpoints);
            for (var i = 0; i < sizes.length; i++) {
                if (i === sizes.length - 1) {
                    return sizes[i];
                }
                ;
                var current = Breakpoints_1.Breakpoints[sizes[i]];
                var next = Breakpoints_1.Breakpoints[sizes[i + 1]];
                if (deviceWidth > current && deviceWidth <= next) {
                    return sizes[i];
                }
            }
        };
        ScreenSizeDetection.prototype.resizeHandler = function () {
            var screensize = this.calculate();
            if (screensize !== this.screensize) {
                this.screensize = screensize;
                console.log('screen', this.screensize);
                this.subject.onNext(this.screensize);
            }
            ;
        };
        ScreenSizeDetection.prototype.addEventListeners = function () {
            var _this = this;
            window.addEventListener('resize', Utils_1.Utils.debounce(function () {
                _this.resizeHandler();
            }, DEBOUNCE_DELAY), false);
        };
        return ScreenSizeDetection;
    }());
    exports.default = new ScreenSizeDetection;
});
//# sourceMappingURL=ScreenSizeDetection.js.map