import { Component, EventEmitter, Input, Output, ChangeDetectionStrategy } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

@Component({
  selector: 'app-patient-security-panel',
  standalone: true,
  imports: [CommonModule, FormsModule],
  templateUrl: './patient-security-panel.component.html',
  styleUrls: ['./patient-security-panel.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class PatientSecurityPanelComponent {
  @Input() twoFAEnabled = false;
  @Input() twoFAStatus: any = null;
  @Input() show2FAModal = false;
  @Input() qrCodeUrl = '';
  @Input() twoFASecretKey = '';
  @Input() twoFABackupCodes: string[] = [];
  @Input() twoFACodeInput = '';

  @Output() twoFACodeInputChange = new EventEmitter<string>();
  @Output() setup2FA = new EventEmitter<void>();
  @Output() disable2FA = new EventEmitter<void>();
  @Output() close2FAModal = new EventEmitter<void>();
  @Output() verifyAndEnable2FA = new EventEmitter<void>();

  onSetup(): void {
    this.setup2FA.emit();
  }

  onDisable(): void {
    this.disable2FA.emit();
  }

  onCloseModal(): void {
    this.close2FAModal.emit();
  }

  onVerify(): void {
    this.verifyAndEnable2FA.emit();
  }

  onCodeChange(value: string): void {
    this.twoFACodeInput = value;
    this.twoFACodeInputChange.emit(value);
  }
}

