import { z } from "zod";
import { CLIExecutor } from "../lib/cli-executor.js";
const GetComponentInputSchema = z.object({
  name: z.string().describe(
    'Component name(s) - can be a single component (e.g., "button") or multiple comma-separated components (e.g., "button,list,card")'
  )
});
class GetComponentTool {
  cli;
  constructor() {
    this.cli = new CLIExecutor();
  }
  async execute(input) {
    try {
      const componentNames = input.name.split(",").map((n) => n.trim()).filter((n) => n.length > 0);
      if (componentNames.length === 0) {
        throw new Error("No component names provided");
      }
      const cliResponse = await this.cli.getComponentByName(input.name);
      const components = Array.isArray(cliResponse) ? cliResponse : [cliResponse];
      if (!components || components.length === 0) {
        throw new Error(`Component(s) "${input.name}" not found`);
      }
      return componentNames.length === 1 ? components[0] : components;
    } catch (error) {
      throw new Error(
        `Failed to get component: ${error instanceof Error ? error.message : String(error)}`
      );
    }
  }
}
export {
  GetComponentInputSchema,
  GetComponentTool
};
