import type { UseCaseOutputPort } from '@core/shared/application';
import type { RequestAvatarGenerationResult } from '@core/media/application/use-cases/RequestAvatarGenerationUseCase';
import type { RequestAvatarGenerationOutputDTO } from '../dtos/RequestAvatarGenerationOutputDTO';

type RequestAvatarGenerationResponseModel = RequestAvatarGenerationOutputDTO;

export class RequestAvatarGenerationPresenter implements UseCaseOutputPort<RequestAvatarGenerationResult> {
  private model: RequestAvatarGenerationResponseModel | null = null;

  reset() {
    this.model = null;
  }

  present(result: RequestAvatarGenerationResult): void {
    this.model = {
      success: result.status === 'completed',
      requestId: result.requestId,
      avatarUrls: result.avatarUrls || [],
    };
  }

  getResponseModel(): RequestAvatarGenerationResponseModel | null {
    return this.model;
  }

  get responseModel(): RequestAvatarGenerationResponseModel {
    if (!this.model) throw new Error('Presenter not presented');
    return this.model;
  }
}