"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var jsx_runtime_1 = require("react/jsx-runtime");
var antd_1 = require("antd");
var misc_1 = require("./misc");
var columns = [
    { title: "Accounts", dataIndex: "type", key: "type" },
    { title: "Hour", dataIndex: "1h", key: "1h" },
    { title: "Day", dataIndex: "1d", key: "1d" },
    { title: "Week", dataIndex: "7d", key: "7d" },
    { title: "Month", dataIndex: "30d", key: "30d" },
];
function connectedUsers(hubServers) {
    if (hubServers == null || hubServers.length === 0) {
        return 0;
    }
    else {
        return hubServers.map(function (x) { return x.clients; }).reduce(function (s, t) { return s + t; });
    }
}
function ActiveUsers(_a) {
    var created = _a.created, active = _a.active, hubServers = _a.hubServers;
    var rows = [
        __assign(__assign({ type: "In use" }, misc_1.ZEROS), active),
        __assign(__assign({ type: "Created" }, misc_1.ZEROS), created),
    ];
    return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h2", { children: ["Connected Users: ", connectedUsers(hubServers)] }), (0, jsx_runtime_1.jsxs)("p", { children: ["There are ", connectedUsers(hubServers), " users connected right now; of these ", active["5min"], " actively edited a file in the last 5 minutes. Track the number of users that were recently active or created new accounts below."] }), (0, jsx_runtime_1.jsx)(antd_1.Table, { dataSource: rows, columns: columns, bordered: true, pagination: false, rowKey: "type" })] }));
}
exports.default = ActiveUsers;
//# sourceMappingURL=active-users.js.map