"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgentStatusIndicator = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_2 = require("@chakra-ui/react");
const api_js_1 = require("../../services/api.js");
const AgentStatusIndicator = ({ agentId }) => {
    const [agent, setAgent] = (0, react_1.useState)(null);
    const [loading, setLoading] = (0, react_1.useState)(true);
    const [error, setError] = (0, react_1.useState)(null);
    (0, react_1.useEffect)(() => {
        const fetchAgentDetails = async () => {
            setLoading(true);
            setError(null);
            try {
                if (typeof api_js_1.apiClient.getAgentDetails === 'function') {
                    const data = await api_js_1.apiClient.getAgentDetails(agentId);
                    setAgent(data);
                }
                else {
                    throw new Error('getAgentDetails method is not available on apiClient.');
                }
            }
            catch (err) {
                setError('Failed to load agent details');
            }
            finally {
                setLoading(false);
            }
        };
        fetchAgentDetails();
    }, [agentId]);
    if (loading) {
        return (0, jsx_runtime_1.jsx)(react_2.Spinner, { size: "md" });
    }
    if (error) {
        return (0, jsx_runtime_1.jsx)(react_2.Text, { color: "red.500", children: error });
    }
    if (!agent) {
        return (0, jsx_runtime_1.jsx)(react_2.Text, { children: "No agent data available" });
    }
    return ((0, jsx_runtime_1.jsx)(react_2.Box, { borderWidth: "1px", borderRadius: "md", p: 4, maxW: "400px", children: (0, jsx_runtime_1.jsxs)(react_2.Stat, { children: [(0, jsx_runtime_1.jsxs)(react_2.StatLabel, { children: ["Agent: ", agent.name] }), (0, jsx_runtime_1.jsxs)(react_2.StatNumber, { children: ["Model: ", agent.model] }), (0, jsx_runtime_1.jsxs)(react_2.StatHelpText, { children: ["Tools: ", agent.tools.length] }), (0, jsx_runtime_1.jsxs)(react_2.StatHelpText, { children: ["Created: ", new Date(agent.created).toLocaleString()] })] }) }));
};
exports.AgentStatusIndicator = AgentStatusIndicator;
//# sourceMappingURL=AgentStatusIndicator.js.map