"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DashboardMMWave = void 0;
var utils_1 = require("./utils");
var CELCIUS = 'ºC';
var DashboardMMWave = /** @class */ (function () {
    function DashboardMMWave(Main) {
        this.container = document.querySelector('.ntsh_dashboard-mmwave');
        this.standardPortStatus = this.container.querySelector('.ntsh_dashboard-mmwave-standardstatus');
        this.standardPortInfo = this.container.querySelector('.ntsh_dashboard-mmwave-standardinfo');
        this.enhancedPortStatus = this.container.querySelector('.ntsh_dashboard-mmwave-enhancedstatus');
        this.enhancedPortInfo = this.container.querySelector('.ntsh_dashboard-mmwave-enhancedinfo');
        this.framesPerSecond = this.container.querySelector('.ntsh_dashboard-mmwave-framespersecond');
        this.trackedPersons = this.container.querySelector('.ntsh_dashboard-mmwave-trackedpersons');
        this.personsInBounds = this.container.querySelector('.ntsh_dashboard-mmwave-personsinbounds');
        this.errorContainer = this.container.querySelector('.ntsh_dashboard-mmwave-error');
        this.errorText = this.container.querySelector('.ntsh_dashboard-mmwave-errortext');
        this._Main = Main;
        this.registerListeners();
    }
    DashboardMMWave.prototype.updateState = function (state) {
        var _a;
        if (state == null)
            return;
        var statusColors = {
            CONNECTED: 'green',
            DISCONNECTED: 'gray',
            CONNECTING: 'yellow',
            PROBLEM: 'red',
        };
        // ----------- Standard Port -----------
        (0, utils_1.setStatusState)(this.standardPortStatus, statusColors[state.ports.standard.connected]);
        this.standardPortInfo.innerText = state.ports.standard.info;
        // ----------- Enhanced Port -----------
        (0, utils_1.setStatusState)(this.enhancedPortStatus, statusColors[state.ports.enhanced.connected]);
        this.enhancedPortInfo.innerText = state.ports.enhanced.info;
        // ----------- Statistics -----------
        this.framesPerSecond.innerText = state.framesPerSecond.toString();
        this.trackedPersons.innerText = state.trackedPersons.toString();
        this.personsInBounds.innerText = state.personsInBounds.toString();
        // ----------- Error -----------
        if (((_a = state === null || state === void 0 ? void 0 : state.error) !== null && _a !== void 0 ? _a : '').trim().length > 0) {
            this.errorText.innerText = state.error;
            this.errorContainer.style.display = 'block';
        }
        else {
            this.errorContainer.style.display = 'none';
            this.errorText.innerText = '';
        }
    };
    DashboardMMWave.prototype.registerListeners = function () {
        var _this = this;
        this._Main.socket.on('mmWaveState', function (state) {
            _this.updateState(state);
        });
    };
    return DashboardMMWave;
}());
exports.DashboardMMWave = DashboardMMWave;
//# sourceMappingURL=dashboard.mmwave.js.map