var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { singleton } from 'aurelia-framework';
import { UIInternal } from '../../utils/ui-internal';
export var GlobalLoaderService = (function () {
    function GlobalLoaderService() {
        this.allowToShowGlobalLoader = false;
        this.forceShow = false;
    }
    GlobalLoaderService.prototype.allow = function (value, delay) {
        if (value === void 0) { value = true; }
        if (delay === void 0) { delay = null; }
        if (typeof value == 'boolean') {
            this.allowToShowGlobalLoader = value;
        }
        else if (typeof value == 'string') {
            this.text = value;
            this.allowToShowGlobalLoader = true;
        }
        else {
            this.text = null;
            this.allowToShowGlobalLoader = true;
        }
        this.delay = delay;
    };
    ;
    GlobalLoaderService.prototype.reset = function () {
        if (this.forceShow == false) {
            this.allowToShowGlobalLoader = false;
            this.text = null;
            this.delay = null;
        }
    };
    GlobalLoaderService.prototype.show = function (value, delay) {
        if (value === void 0) { value = true; }
        if (delay === void 0) { delay = null; }
        this.allow(value, delay);
        this.forceShow = true;
        UIInternal.broadcast(UIInternal.EVT_GLOBAL_LOADER_SHOW);
    };
    GlobalLoaderService.prototype.hide = function () {
        this.forceShow = false;
        this.reset();
        UIInternal.broadcast(UIInternal.EVT_GLOBAL_LOADER_HIDE);
    };
    GlobalLoaderService = __decorate([
        singleton(false)
    ], GlobalLoaderService);
    return GlobalLoaderService;
}());

//# sourceMappingURL=global-loader-service.js.map
