import { Component, input, signal } from '@angular/core';
import { AlertType } from './alert-type.enum';
import * as i0 from "@angular/core";
import * as i1 from "./alert.service";
import * as i2 from "@angular/common";
import * as i3 from "@angular/material/button";
import * as i4 from "@angular/material/card";
import * as i5 from "@angular/material/icon";
/**
 * Component to manage alerts.
 *
 * <b>Requirements: </b>
 *
 * - Add the alert center component on this *layout component* : `<mic-alert-center></mic-alert-center>`
 *
 * <b>On business component: </b>
 * - Add the `AlertService` on the constructor of your component.
 * - If using Angular 18 with stanalone feature need to add the AlertService in the providers of the app (in the AppComponent or LayoutComponent) `providers: [AlertService, ...]`
 * - Use `showAlert` method from this service to display an alert.
 */
export class AlertComponent {
    constructor(alertService) {
        this.alertService = alertService;
        /**
         * Input that define the display alert
         */
        this.alert = input.required();
        /**
         * Alert display icon
         */
        this.icon = signal('');
    }
    ngOnInit() {
        this.icon.set(this.getAlertIcon());
    }
    /**
     * Get alert icon from alert type
     *
     * @returns
     */
    getAlertIcon() {
        switch (this.alert().type) {
            case AlertType.success:
                return 'done';
            case AlertType.strong:
                return 'error_outline';
            case AlertType.critical:
                return 'priority_high';
            case AlertType.classical:
            case AlertType.clear:
            default:
                return 'notifications';
        }
    }
    hideAlert() {
        this.alertService.hideAlert(this.alert().timestamp);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: AlertComponent, deps: [{ token: i1.AlertService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: AlertComponent, selector: "mic-alert", inputs: { alert: { classPropertyName: "alert", publicName: "alert", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: "@if (alert()) {\n<mat-card class=\"alert mat-elevation-z2\" [ngClass]=\"'alert-' + alert().type\">\n  <div class=\"flex flex-row items-center gap-x-3\">\n    <mat-icon role=\"img\" [attr.aria-label]=\"alert().type + 'alert box'\" aria-hidden=\"false\">{{ icon() }}</mat-icon>\n    <div class=\"flex-1\">\n      @if (alert().title) {\n      <strong>{{ alert().title }}</strong>\n      }\n      <div [ngClass]=\"{ 'alert-small': alert().title }\">\n        <ng-content></ng-content>\n      </div>\n    </div>\n    <div class=\"flex-none\">\n      <button mat-icon-button (click)=\"hideAlert()\"><mat-icon role=\"img\" aria-label=\"close\">close</mat-icon></button>\n    </div>\n  </div>\n</mat-card>\n}\n", styles: [":host{margin-top:15px}.alert{width:100%;animation-name:fade-in;animation-fill-mode:both;animation-duration:.2s}.alert .alert-small{font-size:12px}@keyframes fade-in{0%{opacity:0}to{opacity:1}}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: i3.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }, { kind: "component", type: i4.MatCard, selector: "mat-card", inputs: ["appearance"], exportAs: ["matCard"] }, { kind: "component", type: i5.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: AlertComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mic-alert', template: "@if (alert()) {\n<mat-card class=\"alert mat-elevation-z2\" [ngClass]=\"'alert-' + alert().type\">\n  <div class=\"flex flex-row items-center gap-x-3\">\n    <mat-icon role=\"img\" [attr.aria-label]=\"alert().type + 'alert box'\" aria-hidden=\"false\">{{ icon() }}</mat-icon>\n    <div class=\"flex-1\">\n      @if (alert().title) {\n      <strong>{{ alert().title }}</strong>\n      }\n      <div [ngClass]=\"{ 'alert-small': alert().title }\">\n        <ng-content></ng-content>\n      </div>\n    </div>\n    <div class=\"flex-none\">\n      <button mat-icon-button (click)=\"hideAlert()\"><mat-icon role=\"img\" aria-label=\"close\">close</mat-icon></button>\n    </div>\n  </div>\n</mat-card>\n}\n", styles: [":host{margin-top:15px}.alert{width:100%;animation-name:fade-in;animation-fill-mode:both;animation-duration:.2s}.alert .alert-small{font-size:12px}@keyframes fade-in{0%{opacity:0}to{opacity:1}}\n"] }]
        }], ctorParameters: () => [{ type: i1.AlertService }] });
//# sourceMappingURL=data:application/json;base64, 