"use strict";
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;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.GlobalLoaderService = void 0;
var aurelia_framework_1 = require("aurelia-framework");
var ui_internal_1 = require("../../utils/ui-internal");
var GlobalLoaderService = exports.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;
        ui_internal_1.UIInternal.broadcast(ui_internal_1.UIInternal.EVT_GLOBAL_LOADER_SHOW);
    };
    GlobalLoaderService.prototype.hide = function () {
        this.forceShow = false;
        this.reset();
        ui_internal_1.UIInternal.broadcast(ui_internal_1.UIInternal.EVT_GLOBAL_LOADER_HIDE);
    };
    GlobalLoaderService = __decorate([
        (0, aurelia_framework_1.singleton)(false)
    ], GlobalLoaderService);
    return GlobalLoaderService;
}());

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