import { listComponents as dbListComponents } from "../db/queries.js";
export function handleListComponents(db, input) {
    const { category = "all" } = input;
    const components = dbListComponents(db, category === "all" ? undefined : category);
    if (components.length === 0) {
        return {
            content: [
                {
                    type: "text",
                    text: category === "all"
                        ? "No components found in the database."
                        : `No components found in category: ${category}`,
                },
            ],
        };
    }
    // Group by category for better readability
    const grouped = {};
    for (const component of components) {
        const cat = component.category || "other";
        if (!grouped[cat]) {
            grouped[cat] = [];
        }
        grouped[cat].push({
            name: component.name,
            slug: component.slug,
            category: cat,
            description: component.description,
        });
    }
    // Format output
    const output = {
        total: components.length,
        categories: Object.keys(grouped),
        components: category === "all" ? grouped : components,
    };
    return {
        content: [
            {
                type: "text",
                text: JSON.stringify(output, null, 2),
            },
        ],
    };
}
// Tool definition for MCP
export const listComponentsTool = {
    name: "list_components",
    description: "List available Mozaic framework components (Vue/React) by category. For CSS-only utilities (Flexy, Margin, etc.), use list_css_utilities instead.",
    inputSchema: {
        type: "object",
        properties: {
            category: {
                type: "string",
                enum: ["form", "navigation", "feedback", "layout", "data-display", "action", "all"],
                default: "all",
                description: "Filter components by category",
            },
        },
    },
};
//# sourceMappingURL=list-components.js.map