// * Private directives *

import { Directive, ElementRef, HostListener, Input } from '@angular/core';

/**
 * Load default OpenVidu logo if custom one is not exist
 * @internal
 */
@Directive({
	selector: 'img[ovLogo]'
})
export class LogoDirective {
	defaultLogo =
		'data:image/png;base64,[encoded data, 5476 characters]';
	@Input() ovLogo: string;
	constructor(public elementRef: ElementRef) {}

	@HostListener('error')
	loadDefaultLogo() {
		const element = <HTMLImageElement>this.elementRef.nativeElement;
		element.src = this.ovLogo || this.defaultLogo;
	}
}

