import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ucapAnimations } from '../../animations';
import { FileEventJson } from '@ucap-webmessenger/protocol-event';
import { FileDownloadItem } from '@ucap-webmessenger/api';

@Component({
  selector: 'ucap-binary-viewer',
  templateUrl: './binary-viewer.component.html',
  styleUrls: ['./binary-viewer.component.scss'],
  animations: ucapAnimations
})
export class BinaryViewerComponent implements OnInit {
  @Input()
  fileInfo: FileEventJson;

  @Input()
  fileDownloadUrl: string;

  @Output()
  download = new EventEmitter<FileDownloadItem>();

  @Output()
  closed = new EventEmitter<void>();

  fileDownloadItem: FileDownloadItem;

  constructor() {}

  ngOnInit() {}

  onClickDownload(): void {
    this.fileDownloadItem = new FileDownloadItem();
    this.download.emit(this.fileDownloadItem);
  }

  onClickClose(): void {
    this.closed.emit();
  }
}
