import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { notFound } from 'next/navigation';
import { resolve } from '../../../lib/server-container.js';
import { getFeatureFlags } from '../../../lib/feature-flags.js';
import { AgentEditorTabs } from '../../../components/agent-editor/agent-editor-tabs.js';
export const dynamic = 'force-dynamic';
export default async function AgentEditorRoute({ params }) {
    const flags = getFeatureFlags();
    if (!flags.collaboration) {
        notFound();
    }
    const { agentType } = await params;
    const listPrompts = resolve('ListAgentPromptsUseCase');
    const getGraph = resolve('GetAgentGraphUseCase');
    const [prompts, graphResult] = await Promise.all([
        listPrompts.execute({ agentType }),
        getGraph.execute({ agentType }),
    ]);
    if (prompts.length === 0) {
        notFound();
    }
    const graph = graphResult
        ? { agentType, nodes: graphResult.nodes, edges: graphResult.edges }
        : null;
    const bundled = graphResult
        ? {
            agentType,
            nodes: graphResult.bundled.nodes,
            edges: graphResult.bundled.edges,
        }
        : null;
    const hasGraphOverride = graphResult?.hasOverride ?? false;
    return (_jsxs("div", { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [_jsxs("header", { className: "flex flex-col gap-1", children: [_jsx("h1", { className: "text-2xl font-semibold", children: agentType }), _jsxs("p", { className: "text-muted-foreground text-sm", children: [prompts.length, " prompt slot", prompts.length === 1 ? '' : 's', " \u00B7", ' ', prompts.filter((p) => p.hasOverride).length, " override", prompts.filter((p) => p.hasOverride).length === 1 ? '' : 's'] })] }), _jsx(AgentEditorTabs, { agentType: agentType, prompts: prompts, graph: graph, bundledGraph: bundled, hasGraphOverride: hasGraphOverride })] }));
}
