import { Component, ElementRef, EventEmitter, HostBinding, HostListener, Input, Output, Renderer2, } from '@angular/core';
import { RToast } from './model';
export class RToastComponent {
    constructor(renderer, elementRef) {
        this.renderer = renderer;
        this.elementRef = elementRef;
        this.destroy = new EventEmitter();
    }
    get success() {
        return this.toast.config.status === 'success';
    }
    get info() {
        return this.toast.config.status === 'info';
    }
    get warning() {
        return this.toast.config.status === 'warning';
    }
    get primary() {
        return this.toast.config.status === 'primary';
    }
    get danger() {
        return this.toast.config.status === 'danger';
    }
    get basic() {
        return this.toast.config.status === 'basic';
    }
    get control() {
        return this.toast.config.status === 'control';
    }
    get destroyByClick() {
        return this.toast.config.destroyByClick;
    }
    get hasIcon() {
        const { icon } = this.toast.config;
        if (typeof icon === 'string') {
            return true;
        }
        return !!(icon && icon.icon);
    }
    get customIcon() {
        return !!this.icon;
    }
    get icon() {
        return this.toast.config.icon;
    }
    onClick() {
        this.destroy.emit();
    }
    ngOnInit() {
        if (this.toast.config.toastClass) {
            this.renderer.addClass(this.elementRef.nativeElement, this.toast.config.toastClass);
        }
    }
}
RToastComponent.decorators = [
    { type: Component, args: [{
                selector: 'r-toast',
                template: "<div class=\"icon-container\" *ngIf=\"hasIcon && icon\">\r\n  <r-icon [config]=\"icon\"></r-icon>\r\n</div>\r\n<div class=\"content-container\">\r\n  <span class=\"title subtitle\">{{ toast.title }}</span>\r\n  <div class=\"message\">{{ toast.message }}</div>\r\n</div>\r\n",
                styles: [":host{display:flex;align-items:center;width:25rem;margin:.5rem}:host .title{margin-right:.25rem}:host.default .content-container,:host:not(.has-icon) .content-container{display:flex;flex-direction:row}:host.destroy-by-click{cursor:pointer}:host r-icon{font-size:2.5rem}:host svg{width:2.5rem;height:2.5rem}"]
            },] }
];
RToastComponent.ctorParameters = () => [
    { type: Renderer2 },
    { type: ElementRef }
];
RToastComponent.propDecorators = {
    toast: [{ type: Input }],
    destroy: [{ type: Output }],
    success: [{ type: HostBinding, args: ['class.status-success',] }],
    info: [{ type: HostBinding, args: ['class.status-info',] }],
    warning: [{ type: HostBinding, args: ['class.status-warning',] }],
    primary: [{ type: HostBinding, args: ['class.status-primary',] }],
    danger: [{ type: HostBinding, args: ['class.status-danger',] }],
    basic: [{ type: HostBinding, args: ['class.status-basic',] }],
    control: [{ type: HostBinding, args: ['class.status-control',] }],
    destroyByClick: [{ type: HostBinding, args: ['class.destroy-by-click',] }],
    hasIcon: [{ type: HostBinding, args: ['class.has-icon',] }],
    customIcon: [{ type: HostBinding, args: ['class.custom-icon',] }],
    onClick: [{ type: HostListener, args: ['click',] }]
};
//# sourceMappingURL=toast.component.js.map