import { z } from "zod";
const LibrarySuggestionSchema = z.object({
  name: z.string().min(1, "Name is required"),
  path: z.string().min(1, "Path is required"),
  type: z.enum(["deployment", "domain", "manifest", "type", "standard"]),
  description: z.string().min(1, "Description is required"),
  ai_description: z.string().min(1, "AI description is required"),
  expansion_factor: z.number().min(1, "Expansion factor must be >= 1"),
  complexity_level: z.enum(["low", "medium", "high"]),
  best_for: z.array(z.string()).min(1, "Must specify at least one use case")
});
class LibrarySuggestionModel {
  constructor(name, path, type, description, ai_description, expansion_factor, complexity_level, best_for) {
    this.name = name;
    this.path = path;
    this.type = type;
    this.description = description;
    this.ai_description = ai_description;
    this.expansion_factor = expansion_factor;
    this.complexity_level = complexity_level;
    this.best_for = best_for;
  }
  static create(data) {
    const validated = LibrarySuggestionSchema.parse(data);
    return new LibrarySuggestionModel(
      validated.name,
      validated.path,
      validated.type,
      validated.description,
      validated.ai_description,
      validated.expansion_factor,
      validated.complexity_level,
      validated.best_for
    );
  }
  static fromJson(json) {
    const data = JSON.parse(json);
    return this.create(data);
  }
  toJson() {
    return JSON.stringify({
      name: this.name,
      path: this.path,
      type: this.type,
      description: this.description,
      ai_description: this.ai_description,
      expansion_factor: this.expansion_factor,
      complexity_level: this.complexity_level,
      best_for: this.best_for
    });
  }
  matchesContext(context, scale) {
    let score = 0;
    const contextLower = context.toLowerCase();
    for (const useCase of this.best_for) {
      if (contextLower.includes(useCase.toLowerCase())) {
        score += 2;
      }
    }
    const scaleComplexity = this.getScaleComplexity(scale);
    const complexityScore = this.getComplexityScore();
    const complexityMatch = Math.abs(complexityScore - scaleComplexity);
    score += Math.max(0, 3 - complexityMatch);
    return score;
  }
  getScaleComplexity(scale) {
    switch (scale) {
      case "personal":
        return 1;
      case "business":
        return 2;
      case "enterprise":
        return 3;
      default:
        return 2;
    }
  }
  getComplexityScore() {
    switch (this.complexity_level) {
      case "low":
        return 1;
      case "medium":
        return 2;
      case "high":
        return 3;
      default:
        return 2;
    }
  }
  getRelevanceScore() {
    return this.expansion_factor * this.getComplexityScore();
  }
}
export {
  LibrarySuggestionModel,
  LibrarySuggestionSchema
};
