import * as i0 from '@angular/core';
import { EventEmitter, Component, HostBinding, Input, Output, NgModule } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@softpak/frontend-components-ng/dist/frontend-components-ng';
import { SpfModule } from '@softpak/frontend-components-ng/dist/frontend-components-ng';

var SpaAlertSeverityEnum;
(function (SpaAlertSeverityEnum) {
    SpaAlertSeverityEnum["ERROR"] = "error";
    SpaAlertSeverityEnum["INFO"] = "info";
    SpaAlertSeverityEnum["SUCCESS"] = "success";
    SpaAlertSeverityEnum["WARNING"] = "warning";
})(SpaAlertSeverityEnum || (SpaAlertSeverityEnum = {}));

class SpaAlertComponent {
    constructor(ngZone, applicationRef) {
        this.ngZone = ngZone;
        this.applicationRef = applicationRef;
        this.hostClass = true;
        this.closeable = false; // Closeable: May user close the alert by clicking on the cross icon?
        this.hideTitle = false; // HideTitle: If you want to hide the title above the alert
        this.AlertSeverityEnum = SpaAlertSeverityEnum.INFO;
        this.spClose = new EventEmitter();
    }
    get hostClassCloseable() { return this.closeable; }
    get hostClassError() { return this.severity === SpaAlertSeverityEnum.ERROR; }
    get hostClassInfo() { return this.severity === SpaAlertSeverityEnum.INFO; }
    get hostClassSucess() { return this.severity === SpaAlertSeverityEnum.SUCCESS; }
    get hostClassWarning() { return this.severity === SpaAlertSeverityEnum.WARNING; }
    ngOnInit() {
        if (this.autoClose) {
            this.prepareAutoClose();
        }
        if (!this.title) {
            this._assignDefaultTitle();
        }
    }
    doClose() {
        if (this.closeable) {
            this.spClose.emit();
            this.applicationRef.tick();
        }
    }
    prepareAutoClose() {
        this.ngZone.runOutsideAngular(() => {
            this._autoCloseTimeout = setTimeout(() => {
                this.doClose();
                this._autoCloseTimeout = null;
            }, this.autoClose);
        });
    }
    _assignDefaultTitle() {
        switch (this.severity) {
            case SpaAlertSeverityEnum.ERROR:
                this.title = 'Error';
                break;
            case SpaAlertSeverityEnum.INFO:
                this.title = 'Info';
                break;
            case SpaAlertSeverityEnum.SUCCESS:
                this.title = 'Notification';
                break;
            case SpaAlertSeverityEnum.WARNING:
                this.title = 'Warning';
                break;
        }
    }
}
SpaAlertComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaAlertComponent, deps: [{ token: i0.NgZone }, { token: i0.ApplicationRef }], target: i0.ɵɵFactoryTarget.Component });
SpaAlertComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: SpaAlertComponent, selector: "spa-alert", inputs: { autoClose: "autoClose", closeable: "closeable", content: "content", hideTitle: "hideTitle", title: "title", severity: "severity" }, outputs: { spClose: "spClose" }, host: { properties: { "class.spa-alert": "this.hostClass", "class.spa-alert--closeable": "this.hostClassCloseable", "class.spa-alert--error": "this.hostClassError", "class.spa-alert--info": "this.hostClassInfo", "class.spa-alert--success": "this.hostClassSucess", "class.spa-alert--warning": "this.hostClassWarning" } }, ngImport: i0, template: `<div class="spa-alert__container"
    (click)="doClose()">
      <div class="spa-alert__icon-box">
          <i class="spa-alert__icon fal"
            [class.fa-times]="severity === 'error'"
            [class.fa-check]="severity === 'success'"
            [class.fa-exclamation-triangle]="severity === 'warning'"
            [class.fa-info-circle]="severity === 'info'">
          </i>
      </div>
      <div class="spa-alert__content">
          <div *ngIf="!hideTitle" class="spa-alert__title">{{title}}</div>
          {{content}}<ng-content></ng-content>
      </div>
      <i *ngIf="closeable" class="spa-alert__close-button fal fa-times"></i>
  </div>`, isInline: true, styles: [":host{background-color:#f7f7f7;border-radius:4px;color:#000000e6;display:block;line-height:1.6}:host(.spa-alert--closeable){cursor:pointer}:host(.spa-alert--closeable):hover{opacity:.6}:host(.spa-alert--margin-top){margin-top:15px}.spa-alert__icon-box{border-radius:3px;color:#fff;font-size:20px;width:34px;margin:12px;align-self:center;text-align:center}.spa-alert__icon{font-size:18px}.spa-alert__container{font-size:16px;align-items:center;box-sizing:border-box;display:flex;justify-content:center;width:100%;position:relative}.spa-alert__content{box-sizing:border-box;flex:1;padding:8px 0;line-height:1.3;overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;white-space:pre-line;hyphens:auto}.spa-alert__title{font-weight:700;text-transform:uppercase;line-height:1.6;margin-bottom:-1px}.spa-alert__close-button{box-sizing:border-box;margin:12px;padding:5px}:host(.spa-alert--error){background-color:#f9e8e9}:host(.spa-alert--error) .spa-alert__icon-box{background-color:#d9434e}:host(.spa-alert--error) .spa-alert__title{color:#d9434e}:host(.spa-alert--info){background-color:#e8eff9}:host(.spa-alert--info) .spa-alert__icon-box{background-color:#4a8bdb}:host(.spa-alert--info) .spa-alert__title{color:#4a8bdb}:host(.spa-alert--success){background-color:#e9f9e8}:host(.spa-alert--success) .spa-alert__icon-box{background-color:#3bb85d}:host(.spa-alert--success) .spa-alert__title{color:#3bb85d}:host(.spa-alert--warning){background-color:#f9f6e8}:host(.spa-alert--warning) .spa-alert__icon-box{background-color:#f59b43}:host(.spa-alert--warning) .spa-alert__title{color:#f59b43}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaAlertComponent, decorators: [{
            type: Component,
            args: [{ selector: 'spa-alert', template: `<div class="spa-alert__container"
    (click)="doClose()">
      <div class="spa-alert__icon-box">
          <i class="spa-alert__icon fal"
            [class.fa-times]="severity === 'error'"
            [class.fa-check]="severity === 'success'"
            [class.fa-exclamation-triangle]="severity === 'warning'"
            [class.fa-info-circle]="severity === 'info'">
          </i>
      </div>
      <div class="spa-alert__content">
          <div *ngIf="!hideTitle" class="spa-alert__title">{{title}}</div>
          {{content}}<ng-content></ng-content>
      </div>
      <i *ngIf="closeable" class="spa-alert__close-button fal fa-times"></i>
  </div>`, styles: [":host{background-color:#f7f7f7;border-radius:4px;color:#000000e6;display:block;line-height:1.6}:host(.spa-alert--closeable){cursor:pointer}:host(.spa-alert--closeable):hover{opacity:.6}:host(.spa-alert--margin-top){margin-top:15px}.spa-alert__icon-box{border-radius:3px;color:#fff;font-size:20px;width:34px;margin:12px;align-self:center;text-align:center}.spa-alert__icon{font-size:18px}.spa-alert__container{font-size:16px;align-items:center;box-sizing:border-box;display:flex;justify-content:center;width:100%;position:relative}.spa-alert__content{box-sizing:border-box;flex:1;padding:8px 0;line-height:1.3;overflow-wrap:break-word;word-wrap:break-word;-ms-word-break:break-all;word-break:break-word;-ms-hyphens:auto;-moz-hyphens:auto;-webkit-hyphens:auto;white-space:pre-line;hyphens:auto}.spa-alert__title{font-weight:700;text-transform:uppercase;line-height:1.6;margin-bottom:-1px}.spa-alert__close-button{box-sizing:border-box;margin:12px;padding:5px}:host(.spa-alert--error){background-color:#f9e8e9}:host(.spa-alert--error) .spa-alert__icon-box{background-color:#d9434e}:host(.spa-alert--error) .spa-alert__title{color:#d9434e}:host(.spa-alert--info){background-color:#e8eff9}:host(.spa-alert--info) .spa-alert__icon-box{background-color:#4a8bdb}:host(.spa-alert--info) .spa-alert__title{color:#4a8bdb}:host(.spa-alert--success){background-color:#e9f9e8}:host(.spa-alert--success) .spa-alert__icon-box{background-color:#3bb85d}:host(.spa-alert--success) .spa-alert__title{color:#3bb85d}:host(.spa-alert--warning){background-color:#f9f6e8}:host(.spa-alert--warning) .spa-alert__icon-box{background-color:#f59b43}:host(.spa-alert--warning) .spa-alert__title{color:#f59b43}\n"] }]
        }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i0.ApplicationRef }]; }, propDecorators: { hostClass: [{
                type: HostBinding,
                args: ['class.spa-alert']
            }], hostClassCloseable: [{
                type: HostBinding,
                args: ['class.spa-alert--closeable']
            }], hostClassError: [{
                type: HostBinding,
                args: ['class.spa-alert--error']
            }], hostClassInfo: [{
                type: HostBinding,
                args: ['class.spa-alert--info']
            }], hostClassSucess: [{
                type: HostBinding,
                args: ['class.spa-alert--success']
            }], hostClassWarning: [{
                type: HostBinding,
                args: ['class.spa-alert--warning']
            }], autoClose: [{
                type: Input
            }], closeable: [{
                type: Input
            }], content: [{
                type: Input
            }], hideTitle: [{
                type: Input
            }], title: [{
                type: Input
            }], severity: [{
                type: Input
            }], spClose: [{
                type: Output
            }] } });

class SpaAlertModule {
}
SpaAlertModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaAlertModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
SpaAlertModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: SpaAlertModule, declarations: [SpaAlertComponent], imports: [CommonModule], exports: [SpaAlertComponent] });
SpaAlertModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaAlertModule, imports: [CommonModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaAlertModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        SpaAlertComponent,
                    ],
                    imports: [
                        CommonModule,
                    ],
                    exports: [
                        SpaAlertComponent,
                    ],
                }]
        }] });

var SpaToasterSeverityEnum;
(function (SpaToasterSeverityEnum) {
    SpaToasterSeverityEnum["ERROR"] = "error";
    SpaToasterSeverityEnum["INFO"] = "info";
    SpaToasterSeverityEnum["SUCCESS"] = "success";
    SpaToasterSeverityEnum["WARNING"] = "warning";
})(SpaToasterSeverityEnum || (SpaToasterSeverityEnum = {}));
var SpaToasterAutoCloseSpeedEnum;
(function (SpaToasterAutoCloseSpeedEnum) {
    SpaToasterAutoCloseSpeedEnum[SpaToasterAutoCloseSpeedEnum["DEFAULT"] = -1] = "DEFAULT";
    SpaToasterAutoCloseSpeedEnum[SpaToasterAutoCloseSpeedEnum["SLOW"] = -2] = "SLOW";
})(SpaToasterAutoCloseSpeedEnum || (SpaToasterAutoCloseSpeedEnum = {}));
function toasterAutocloseSpeed(autoCloseSpeed, messageText) {
    switch (autoCloseSpeed) {
        case SpaToasterAutoCloseSpeedEnum.DEFAULT:
            return Math.min(Math.max(messageText.length * 50, 2000), 7000);
        case SpaToasterAutoCloseSpeedEnum.SLOW:
            return Math.min(Math.max(messageText.length * 60, 3000), 10000);
        default:
            return autoCloseSpeed;
    }
}

class SpaToasterComponent {
    constructor() {
        this.hostClass = true;
        this.spaClose = new EventEmitter();
    }
    doCloseMessage(id) {
        this.spaClose.emit(id);
    }
}
SpaToasterComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaToasterComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
SpaToasterComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", type: SpaToasterComponent, selector: "spa-toaster", inputs: { messages: "messages" }, outputs: { spaClose: "spaClose" }, host: { properties: { "class.spa-toasts-displayer": "this.hostClass" } }, ngImport: i0, template: `<spn-alert
        *ngFor="let message of messages"
        [spfAutoclose]="message.autoClose"
        [spfCloseable]="message.closeable"
        [spfSeverity]="message.severity"
        [spfTitle]="message.title"
        (spfClose)="doCloseMessage(message.id)">{{message.message}}</spn-alert>`, isInline: true, styles: [":host(.spa-toasts-displayer){display:block;position:fixed;bottom:85px;left:0;right:0;margin:0 auto;width:80%;z-index:500}spn-alert+spn-alert{margin-top:6px}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i2.SpnAlert, selector: "spn-alert", inputs: ["spfAutoclose", "spfCloseable", "spfHideTitle", "spfMarginTop", "spfSeverity", "spfTitle"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaToasterComponent, decorators: [{
            type: Component,
            args: [{ selector: 'spa-toaster', template: `<spn-alert
        *ngFor="let message of messages"
        [spfAutoclose]="message.autoClose"
        [spfCloseable]="message.closeable"
        [spfSeverity]="message.severity"
        [spfTitle]="message.title"
        (spfClose)="doCloseMessage(message.id)">{{message.message}}</spn-alert>`, styles: [":host(.spa-toasts-displayer){display:block;position:fixed;bottom:85px;left:0;right:0;margin:0 auto;width:80%;z-index:500}spn-alert+spn-alert{margin-top:6px}\n"] }]
        }], propDecorators: { hostClass: [{
                type: HostBinding,
                args: ['class.spa-toasts-displayer']
            }], messages: [{
                type: Input
            }], spaClose: [{
                type: Output
            }] } });

class SpaToasterMessageI {
}

class SpaToasterModule {
    static forRoot() {
        return {
            ngModule: SpaToasterModule,
        };
    }
}
SpaToasterModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaToasterModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
SpaToasterModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.3.0", ngImport: i0, type: SpaToasterModule, declarations: [SpaToasterComponent], imports: [CommonModule,
        SpfModule], exports: [SpaToasterComponent] });
SpaToasterModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaToasterModule, imports: [CommonModule,
        SpfModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: SpaToasterModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        SpaToasterComponent,
                    ],
                    imports: [
                        CommonModule,
                        SpfModule,
                    ],
                    exports: [
                        SpaToasterComponent,
                    ]
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { SpaAlertComponent, SpaAlertModule, SpaAlertSeverityEnum, SpaToasterAutoCloseSpeedEnum, SpaToasterComponent, SpaToasterMessageI, SpaToasterModule, SpaToasterSeverityEnum, toasterAutocloseSpeed };
//# sourceMappingURL=softpak-ng-components-spa-toaster.mjs.map
