import { Component, Input, Output, EventEmitter } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import {
  faEdit,
  faAlignLeft,
  faFileAlt,
  faEnvelope,
  IconDefinition
} from '@fortawesome/free-solid-svg-icons';
import { Agent } from '../../models/data.model';

@Component({
  selector: 'app-agent-card',
  standalone: true,
  imports: [CommonModule, FontAwesomeModule],
  templateUrl: './agent-card.html',
  styleUrls: ['./agent-card.scss']
})
export class AgentCard {
  @Input() agent!: Agent;
  @Output() selected = new EventEmitter<Agent>();

  private iconMap: { [key: string]: IconDefinition } = {
    'edit': faEdit,
    'align-left': faAlignLeft,
    'file-alt': faFileAlt,
    'envelope': faEnvelope
  };

  getIcon(): IconDefinition {
    return this.iconMap[this.agent.icon] || faEdit;
  }

  onSelect(): void {
    this.selected.emit(this.agent);
  }
}
