var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
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;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "../../App", "../../di/Inject", "../../di/RegisterSingleton", "../../services/BusyIndicatorService", "../../services/NavigationService", "../controls/AtomControl", "../styles/StyleBuilder"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.WebBusyIndicatorService = void 0;
    var App_1 = require("../../App");
    var Inject_1 = require("../../di/Inject");
    var RegisterSingleton_1 = require("../../di/RegisterSingleton");
    var BusyIndicatorService_1 = require("../../services/BusyIndicatorService");
    var NavigationService_1 = require("../../services/NavigationService");
    var AtomControl_1 = require("../controls/AtomControl");
    var StyleBuilder_1 = require("../styles/StyleBuilder");
    var WebBusyIndicatorService = /** @class */ (function (_super) {
        __extends(WebBusyIndicatorService, _super);
        function WebBusyIndicatorService() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.zIndex = 50000;
            return _this;
        }
        WebBusyIndicatorService.prototype.createIndicator = function () {
            var host = document.createElement("div");
            var popup = new AtomControl_1.AtomControl(this.app, host);
            host.className = "indicator-host";
            var span = document.createElement("i");
            var divStyle = host.style;
            divStyle.position = "absolute";
            divStyle.left = divStyle.right = divStyle.bottom = divStyle.top = "0";
            divStyle.zIndex = (this.zIndex++) + "";
            var spanStyle = span.style;
            spanStyle.position = "absolute";
            spanStyle.margin = "auto";
            spanStyle.width = "16px";
            spanStyle.height = "16px";
            spanStyle.maxHeight = "100%";
            spanStyle.maxWidth = "100%";
            spanStyle.left = spanStyle.right = spanStyle.bottom = spanStyle.top = "0";
            // span.src = ModuleFiles.src.web.images.busy_gif;
            span.className = "fas fa-spinner fa-spin";
            host.appendChild(span);
            var ws = this.navigationService;
            var e = ws.getHostForElement();
            if (e) {
                e.appendChild(host);
            }
            else {
                document.body.appendChild(host);
                ws.refreshScreen();
                popup.bind(host, "styleLeft", [["this", "scrollLeft"]], false, StyleBuilder_1.cssNumberToString, ws.screen);
                popup.bind(host, "styleTop", [["this", "scrollTop"]], false, StyleBuilder_1.cssNumberToString, ws.screen);
                popup.bind(host, "styleWidth", [["this", "width"]], false, StyleBuilder_1.cssNumberToString, ws.screen);
                popup.bind(host, "styleHeight", [["this", "height"]], false, StyleBuilder_1.cssNumberToString, ws.screen);
            }
            popup.registerDisposable({
                dispose: function () {
                    host.remove();
                }
            });
            return popup;
        };
        __decorate([
            Inject_1.Inject,
            __metadata("design:type", NavigationService_1.NavigationService)
        ], WebBusyIndicatorService.prototype, "navigationService", void 0);
        __decorate([
            Inject_1.Inject,
            __metadata("design:type", App_1.App)
        ], WebBusyIndicatorService.prototype, "app", void 0);
        WebBusyIndicatorService = __decorate([
            RegisterSingleton_1.RegisterSingleton
        ], WebBusyIndicatorService);
        return WebBusyIndicatorService;
    }(BusyIndicatorService_1.BusyIndicatorService));
    exports.WebBusyIndicatorService = WebBusyIndicatorService;
});
//# sourceMappingURL=WebBusyIndicatorService.js.map