/**
 * Documentation Template Registry
 * Central registry for all documentation templates
 */

import { DocumentationIntent } from '../../../types/workflow';
import { DocumentationTemplate } from './base-template';
import { TroubleshootingTemplate } from './troubleshooting-template';
import { SetupGuideTemplate } from './setup-guide-template';
import { ApiReferenceTemplate } from './api-reference-template';
import { TutorialTemplate } from './tutorial-template';
import { ArchitectureTemplate } from './architecture-template';
import { BestPracticesTemplate } from './best-practices-template';

export class TemplateRegistry {
  private templates: DocumentationTemplate[] = [];

  constructor() {
    // Register all built-in templates
    this.registerTemplate(new TroubleshootingTemplate());
    this.registerTemplate(new SetupGuideTemplate());
    this.registerTemplate(new ApiReferenceTemplate());
    this.registerTemplate(new TutorialTemplate());
    this.registerTemplate(new ArchitectureTemplate());
    this.registerTemplate(new BestPracticesTemplate());
    // Add more templates as they're created
  }

  /**
   * Register a custom template
   */
  registerTemplate(template: DocumentationTemplate): void {
    this.templates.push(template);
  }

  /**
   * Find a template that can handle the given intent
   */
  findTemplate(intent: DocumentationIntent): DocumentationTemplate | undefined {
    return this.templates.find(template => template.canHandle(intent));
  }

  /**
   * Get all registered templates
   */
  getAllTemplates(): DocumentationTemplate[] {
    return this.templates;
  }
}

// Export singleton instance
export const templateRegistry = new TemplateRegistry();
