"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.AgentDashboard = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_2 = require("@chakra-ui/react");
const ErrorBoundary_js_1 = require("../common/ErrorBoundary.js");
// Lazy load components for better performance
const AgentStatusIndicator = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./AgentStatusIndicator.js'))).then(m => ({ default: m.AgentStatusIndicator })));
const AgentLogs = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./AgentLogs.js'))).then(m => ({ default: m.AgentLogs })));
const AgentControlActions = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./AgentControlActions.js'))).then(m => ({ default: m.AgentControlActions })));
const AgentInteractionPanel = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./AgentInteractionPanel.js'))).then(m => ({ default: m.AgentInteractionPanel })));
const AgentDashboardComponent = ({ agentId, heading = 'Agent Dashboard', showInteractionPanel = true, showLogs = true, onError }) => {
    // Memoize the prompt handler to prevent unnecessary re-renders
    const handleSendPrompt = (0, react_1.useCallback)(async (prompt) => {
        // TODO: Implement integration with BFLLM service to send prompt and receive response
        return `Echo: ${prompt}`;
    }, []);
    // Loading fallback component
    const LoadingFallback = (0, react_1.useMemo)(() => ((0, jsx_runtime_1.jsx)(react_2.Box, { display: "flex", justifyContent: "center", alignItems: "center", minHeight: "100px", children: (0, jsx_runtime_1.jsx)(react_2.Spinner, { size: "lg", color: "blue.500", thickness: "4px" }) })), []);
    // Error fallback component
    const ErrorFallback = (0, react_1.useCallback)(({ error }) => ((0, jsx_runtime_1.jsxs)(react_2.Alert, { status: "error", borderRadius: "md", children: [(0, jsx_runtime_1.jsx)(react_2.AlertIcon, {}), "Failed to load component: ", error.message] })), []);
    return ((0, jsx_runtime_1.jsxs)(react_2.VStack, { spacing: 6, align: "stretch", maxW: "800px", mx: "auto", p: 4, role: "main", "aria-label": `Dashboard for agent ${agentId}`, children: [(0, jsx_runtime_1.jsx)(react_2.Heading, { size: "lg", id: "agent-dashboard-heading", children: heading }), (0, jsx_runtime_1.jsx)(ErrorBoundary_js_1.ErrorBoundary, { fallback: ErrorFallback, onError: onError, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: LoadingFallback, children: (0, jsx_runtime_1.jsx)(AgentStatusIndicator, { agentId: agentId }) }) }), (0, jsx_runtime_1.jsx)(react_2.Divider, { "aria-hidden": "true" }), (0, jsx_runtime_1.jsx)(ErrorBoundary_js_1.ErrorBoundary, { fallback: ErrorFallback, onError: onError, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: LoadingFallback, children: (0, jsx_runtime_1.jsx)(AgentControlActions, { agentId: agentId }) }) }), showInteractionPanel && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.Divider, { "aria-hidden": "true" }), (0, jsx_runtime_1.jsx)(ErrorBoundary_js_1.ErrorBoundary, { fallback: ErrorFallback, onError: onError, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: LoadingFallback, children: (0, jsx_runtime_1.jsx)(AgentInteractionPanel, { agentId: agentId, onSendPrompt: handleSendPrompt }) }) })] })), showLogs && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_2.Divider, { "aria-hidden": "true" }), (0, jsx_runtime_1.jsx)(ErrorBoundary_js_1.ErrorBoundary, { fallback: ErrorFallback, onError: onError, children: (0, jsx_runtime_1.jsx)(react_1.Suspense, { fallback: LoadingFallback, children: (0, jsx_runtime_1.jsx)(AgentLogs, { agentId: agentId }) }) })] }))] }));
};
// Memoize the component for better performance
exports.AgentDashboard = (0, react_1.memo)(AgentDashboardComponent);
exports.AgentDashboard.displayName = 'AgentDashboard';
//# sourceMappingURL=AgentDashboard.js.map