"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgentTableEmptyState = exports.getAgentId = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const EmptyState_1 = tslib_1.__importDefault(require("../../../common/components/ui/uiState/EmptyState"));
const connected_icon_1 = require("@patternfly/react-icons/dist/js/icons/connected-icon");
const tableUtils_1 = require("./tableUtils");
const tableColumns_1 = require("./tableColumns");
const common_1 = require("../../../common");
const HostsTable_1 = tslib_1.__importStar(require("../../../common/components/hosts/HostsTable"));
const usePagination_1 = require("../../../common/components/hosts/usePagination");
const use_translation_wrapper_1 = require("../../../common/hooks/use-translation-wrapper");
const agentStatus_1 = require("../helpers/agentStatus");
const getAgentId = (agent) => { var _a; return (_a = agent.metadata) === null || _a === void 0 ? void 0 : _a.uid; };
exports.getAgentId = getAgentId;
const AgentTableEmptyState = () => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    return (React.createElement(EmptyState_1.default, { icon: connected_icon_1.ConnectedIcon, title: t('ai:Waiting for hosts...'), content: t('ai:Hosts may take a few minutes to appear here after booting.') }));
};
exports.AgentTableEmptyState = AgentTableEmptyState;
const AgentTable = ({ agents, agentClusterInstall, className, onUnbindHost, }) => {
    const { t } = (0, use_translation_wrapper_1.useTranslation)();
    const agentClusterInstalls = React.useMemo(() => [agentClusterInstall], [agentClusterInstall]);
    const agentStatuses = (0, agentStatus_1.agentStatus)(t);
    const [hosts, hostActions, actionResolver] = (0, tableUtils_1.useAgentsTable)({ agents, agentClusterInstalls }, {
        onUnbindHost,
    });
    const content = React.useMemo(() => [
        (0, common_1.hostnameColumn)(t, hostActions.onEditHost),
        (0, common_1.roleColumn)(t),
        (0, tableColumns_1.agentStatusColumn)({
            agents,
            agentStatuses,
            t,
        }),
        (0, tableColumns_1.infraEnvColumn)(agents, t),
        (0, common_1.cpuArchitectureColumn)(t),
        (0, common_1.cpuCoresColumn)(t),
        (0, common_1.memoryColumn)(t),
        (0, common_1.disksColumn)(t),
    ], [agentStatuses, agents, hostActions.onEditHost, t]);
    const paginationProps = (0, usePagination_1.usePagination)(agents.length);
    return (React.createElement(HostsTable_1.default, Object.assign({ hosts: hosts, content: content, actionResolver: actionResolver, className: className, ExpandComponent: HostsTable_1.DefaultExpandComponent }, paginationProps),
        React.createElement(exports.AgentTableEmptyState, null)));
};
exports.default = AgentTable;
//# sourceMappingURL=AgentTable.js.map