import * as i0 from '@angular/core';
import { Component, Input, HostBinding, InjectionToken, Injector, Injectable, Inject, Pipe, Directive, HostListener, NgModule } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import * as i1 from '@angular/cdk/overlay';
import { OverlayModule } from '@angular/cdk/overlay';
import * as i2 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i3 from '@mintplayer/ng-bootstrap/has-overlay';
import { BsHasOverlayModule } from '@mintplayer/ng-bootstrap/has-overlay';
import { ComponentPortal } from '@angular/cdk/portal';

class BsToastComponent {
    constructor() {
        this.isVisible = false;
    }
}
BsToastComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
BsToastComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: BsToastComponent, selector: "bs-toast", inputs: { isVisible: "isVisible" }, ngImport: i0, template: "<div class=\"toast d-block fade mb-2 me-2\" [class.show]=\"isVisible\" aria-live=\"assertive\" aria-atomic=\"true\">\n    <ng-content></ng-content>\n</div>", styles: [":host ::ng-deep .fade{transition:opacity .15s linear}@media (prefers-reduced-motion: reduce){:host ::ng-deep .fade{transition:none}}:host ::ng-deep .fade:not(.show){opacity:0}:host ::ng-deep .collapse:not(.show){display:none}:host ::ng-deep .collapsing{height:0;overflow:hidden;transition:height .35s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .collapsing{transition:none}}:host ::ng-deep .collapsing.collapse-horizontal{width:0;height:auto;transition:width .35s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .collapsing.collapse-horizontal{transition:none}}:host ::ng-deep .toast{--bs-toast-zindex: 1090;--bs-toast-padding-x: .75rem;--bs-toast-padding-y: .5rem;--bs-toast-spacing: 1.5rem;--bs-toast-max-width: 350px;--bs-toast-font-size: .875rem;--bs-toast-color: ;--bs-toast-bg: rgba(255, 255, 255, .85);--bs-toast-border-width: 1px;--bs-toast-border-color: var(--bs-border-color-translucent);--bs-toast-border-radius: .375rem;--bs-toast-box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);--bs-toast-header-color: #6c757d;--bs-toast-header-bg: rgba(255, 255, 255, .85);--bs-toast-header-border-color: rgba(0, 0, 0, .05);width:var(--bs-toast-max-width);max-width:100%;font-size:var(--bs-toast-font-size);color:var(--bs-toast-color);pointer-events:auto;background-color:var(--bs-toast-bg);background-clip:padding-box;border:var(--bs-toast-border-width) solid var(--bs-toast-border-color);box-shadow:var(--bs-toast-box-shadow);border-radius:var(--bs-toast-border-radius)}:host ::ng-deep .toast.showing{opacity:0}:host ::ng-deep .toast:not(.show){display:none}:host ::ng-deep .toast-container{--bs-toast-zindex: 1090;position:absolute;z-index:var(--bs-toast-zindex);width:max-content;max-width:100%;pointer-events:none}:host ::ng-deep .toast-container>:not(:last-child){margin-bottom:var(--bs-toast-spacing)}:host ::ng-deep .toast-header{display:flex;align-items:center;padding:var(--bs-toast-padding-y) var(--bs-toast-padding-x);color:var(--bs-toast-header-color);background-color:var(--bs-toast-header-bg);background-clip:padding-box;border-bottom:var(--bs-toast-border-width) solid var(--bs-toast-header-border-color);border-top-left-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width));border-top-right-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width))}:host ::ng-deep .toast-header .btn-close{margin-right:calc(-.5 * var(--bs-toast-padding-x));margin-left:var(--bs-toast-padding-x)}:host ::ng-deep .toast-body{padding:var(--bs-toast-padding-x);word-wrap:break-word}\n"] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-toast', template: "<div class=\"toast d-block fade mb-2 me-2\" [class.show]=\"isVisible\" aria-live=\"assertive\" aria-atomic=\"true\">\n    <ng-content></ng-content>\n</div>", styles: [":host ::ng-deep .fade{transition:opacity .15s linear}@media (prefers-reduced-motion: reduce){:host ::ng-deep .fade{transition:none}}:host ::ng-deep .fade:not(.show){opacity:0}:host ::ng-deep .collapse:not(.show){display:none}:host ::ng-deep .collapsing{height:0;overflow:hidden;transition:height .35s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .collapsing{transition:none}}:host ::ng-deep .collapsing.collapse-horizontal{width:0;height:auto;transition:width .35s ease}@media (prefers-reduced-motion: reduce){:host ::ng-deep .collapsing.collapse-horizontal{transition:none}}:host ::ng-deep .toast{--bs-toast-zindex: 1090;--bs-toast-padding-x: .75rem;--bs-toast-padding-y: .5rem;--bs-toast-spacing: 1.5rem;--bs-toast-max-width: 350px;--bs-toast-font-size: .875rem;--bs-toast-color: ;--bs-toast-bg: rgba(255, 255, 255, .85);--bs-toast-border-width: 1px;--bs-toast-border-color: var(--bs-border-color-translucent);--bs-toast-border-radius: .375rem;--bs-toast-box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);--bs-toast-header-color: #6c757d;--bs-toast-header-bg: rgba(255, 255, 255, .85);--bs-toast-header-border-color: rgba(0, 0, 0, .05);width:var(--bs-toast-max-width);max-width:100%;font-size:var(--bs-toast-font-size);color:var(--bs-toast-color);pointer-events:auto;background-color:var(--bs-toast-bg);background-clip:padding-box;border:var(--bs-toast-border-width) solid var(--bs-toast-border-color);box-shadow:var(--bs-toast-box-shadow);border-radius:var(--bs-toast-border-radius)}:host ::ng-deep .toast.showing{opacity:0}:host ::ng-deep .toast:not(.show){display:none}:host ::ng-deep .toast-container{--bs-toast-zindex: 1090;position:absolute;z-index:var(--bs-toast-zindex);width:max-content;max-width:100%;pointer-events:none}:host ::ng-deep .toast-container>:not(:last-child){margin-bottom:var(--bs-toast-spacing)}:host ::ng-deep .toast-header{display:flex;align-items:center;padding:var(--bs-toast-padding-y) var(--bs-toast-padding-x);color:var(--bs-toast-header-color);background-color:var(--bs-toast-header-bg);background-clip:padding-box;border-bottom:var(--bs-toast-border-width) solid var(--bs-toast-header-border-color);border-top-left-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width));border-top-right-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width))}:host ::ng-deep .toast-header .btn-close{margin-right:calc(-.5 * var(--bs-toast-padding-x));margin-left:var(--bs-toast-padding-x)}:host ::ng-deep .toast-body{padding:var(--bs-toast-padding-x);word-wrap:break-word}\n"] }]
        }], propDecorators: { isVisible: [{
                type: Input
            }] } });

class BsToastHeaderComponent {
    constructor() {
        this.toastClass = true;
    }
}
BsToastHeaderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastHeaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
BsToastHeaderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: BsToastHeaderComponent, selector: "bs-toast-header", host: { properties: { "class.toast-header": "this.toastClass" } }, ngImport: i0, template: "<ng-content></ng-content>", styles: [""] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastHeaderComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-toast-header', template: "<ng-content></ng-content>" }]
        }], propDecorators: { toastClass: [{
                type: HostBinding,
                args: ['class.toast-header']
            }] } });

class BsToastBodyComponent {
    constructor() {
        this.toastClasses = true;
    }
}
BsToastBodyComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
BsToastBodyComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: BsToastBodyComponent, selector: "bs-toast-body", host: { properties: { "class.d-flex": "this.toastClasses", "class.toast-body": "this.toastClasses" } }, ngImport: i0, template: "<ng-content></ng-content>\n", styles: [""] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastBodyComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-toast-body', template: "<ng-content></ng-content>\n" }]
        }], propDecorators: { toastClasses: [{
                type: HostBinding,
                args: ['class.d-flex']
            }, {
                type: HostBinding,
                args: ['class.toast-body']
            }] } });

const PORTAL_FACTORY = new InjectionToken('ToastPortalFactory');

class BsToastService {
    constructor(overlayService, rootInjector, portalFactory) {
        this.overlayService = overlayService;
        this.rootInjector = rootInjector;
        this.portalFactory = portalFactory;
        this.overlayRef = null;
        this.toasts$ = new BehaviorSubject([]);
    }
    pushToast(toast, context) {
        if (!this.overlayRef) {
            const injector = Injector.create({
                providers: [],
                parent: this.rootInjector,
            });
            const portal = this.portalFactory(injector);
            this.overlayRef = this.overlayService.create({
                scrollStrategy: this.overlayService.scrollStrategies.block(),
                positionStrategy: this.overlayService.position().global()
                    .top('0').left('0').bottom('0').right('0'),
                hasBackdrop: false
            });
            const component = this.overlayRef.attach(portal);
        }
        context = context !== null && context !== void 0 ? context : {};
        const ctx = Object.assign(context, { isVisible: false });
        this.toasts$.value.push({ template: toast, context: ctx });
        this.toasts$.next(this.toasts$.value);
        setTimeout(() => ctx.isVisible = true, 20);
    }
    close(index) {
        const toasts = this.toasts$.value;
        const toast = toasts[index];
        if (toast && toast.context) {
            toast.context.isVisible = false;
        }
        setTimeout(() => {
            toasts.splice(index, 1);
            this.toasts$.next(this.toasts$.value);
        }, 400);
    }
}
BsToastService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastService, deps: [{ token: i1.Overlay }, { token: i0.Injector }, { token: PORTAL_FACTORY }], target: i0.ɵɵFactoryTarget.Injectable });
BsToastService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastService });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastService, decorators: [{
            type: Injectable
        }], ctorParameters: function () {
        return [{ type: i1.Overlay }, { type: i0.Injector }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [PORTAL_FACTORY]
                    }] }];
    } });

class BsAddPropertiesPipe {
    transform(value, toAdd) {
        const result = Object.assign(value !== null && value !== void 0 ? value : {}, toAdd);
        return result;
    }
}
BsAddPropertiesPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsAddPropertiesPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
BsAddPropertiesPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: BsAddPropertiesPipe, name: "bsAddProperties" });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsAddPropertiesPipe, decorators: [{
            type: Pipe,
            args: [{
                    name: 'bsAddProperties'
                }]
        }] });

class BsToastContainerComponent {
    constructor(toastService) {
        this.overflowY = 'auto';
        this.toastService = toastService;
    }
}
BsToastContainerComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastContainerComponent, deps: [{ token: BsToastService }], target: i0.ɵɵFactoryTarget.Component });
BsToastContainerComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: BsToastContainerComponent, selector: "bs-toast-container", host: { properties: { "style.overflow-y": "this.overflowY" } }, ngImport: i0, template: "<bs-has-overlay></bs-has-overlay>\n<ng-container *ngFor=\"let toast of (toastService.toasts$ | async); let i = index\">\n    <ng-container [ngTemplateOutlet]=\"toast.template\" [ngTemplateOutletContext]=\"toast.context | bsAddProperties: {toastIndex: i}\"></ng-container>\n</ng-container>", styles: [":host ::ng-deep .toast{--bs-toast-zindex: 1090;--bs-toast-padding-x: .75rem;--bs-toast-padding-y: .5rem;--bs-toast-spacing: 1.5rem;--bs-toast-max-width: 350px;--bs-toast-font-size: .875rem;--bs-toast-color: ;--bs-toast-bg: rgba(255, 255, 255, .85);--bs-toast-border-width: 1px;--bs-toast-border-color: var(--bs-border-color-translucent);--bs-toast-border-radius: .375rem;--bs-toast-box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);--bs-toast-header-color: #6c757d;--bs-toast-header-bg: rgba(255, 255, 255, .85);--bs-toast-header-border-color: rgba(0, 0, 0, .05);width:var(--bs-toast-max-width);max-width:100%;font-size:var(--bs-toast-font-size);color:var(--bs-toast-color);pointer-events:auto;background-color:var(--bs-toast-bg);background-clip:padding-box;border:var(--bs-toast-border-width) solid var(--bs-toast-border-color);box-shadow:var(--bs-toast-box-shadow);border-radius:var(--bs-toast-border-radius)}:host ::ng-deep .toast.showing{opacity:0}:host ::ng-deep .toast:not(.show){display:none}:host ::ng-deep .toast-container{--bs-toast-zindex: 1090;position:absolute;z-index:var(--bs-toast-zindex);width:max-content;max-width:100%;pointer-events:none}:host ::ng-deep .toast-container>:not(:last-child){margin-bottom:var(--bs-toast-spacing)}:host ::ng-deep .toast-header{display:flex;align-items:center;padding:var(--bs-toast-padding-y) var(--bs-toast-padding-x);color:var(--bs-toast-header-color);background-color:var(--bs-toast-header-bg);background-clip:padding-box;border-bottom:var(--bs-toast-border-width) solid var(--bs-toast-header-border-color);border-top-left-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width));border-top-right-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width))}:host ::ng-deep .toast-header .btn-close{margin-right:calc(-.5 * var(--bs-toast-padding-x));margin-left:var(--bs-toast-padding-x)}:host ::ng-deep .toast-body{padding:var(--bs-toast-padding-x);word-wrap:break-word}\n"], dependencies: [{ kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i3.BsHasOverlayComponent, selector: "bs-has-overlay" }, { kind: "pipe", type: i2.AsyncPipe, name: "async" }, { kind: "pipe", type: BsAddPropertiesPipe, name: "bsAddProperties" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastContainerComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-toast-container', template: "<bs-has-overlay></bs-has-overlay>\n<ng-container *ngFor=\"let toast of (toastService.toasts$ | async); let i = index\">\n    <ng-container [ngTemplateOutlet]=\"toast.template\" [ngTemplateOutletContext]=\"toast.context | bsAddProperties: {toastIndex: i}\"></ng-container>\n</ng-container>", styles: [":host ::ng-deep .toast{--bs-toast-zindex: 1090;--bs-toast-padding-x: .75rem;--bs-toast-padding-y: .5rem;--bs-toast-spacing: 1.5rem;--bs-toast-max-width: 350px;--bs-toast-font-size: .875rem;--bs-toast-color: ;--bs-toast-bg: rgba(255, 255, 255, .85);--bs-toast-border-width: 1px;--bs-toast-border-color: var(--bs-border-color-translucent);--bs-toast-border-radius: .375rem;--bs-toast-box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);--bs-toast-header-color: #6c757d;--bs-toast-header-bg: rgba(255, 255, 255, .85);--bs-toast-header-border-color: rgba(0, 0, 0, .05);width:var(--bs-toast-max-width);max-width:100%;font-size:var(--bs-toast-font-size);color:var(--bs-toast-color);pointer-events:auto;background-color:var(--bs-toast-bg);background-clip:padding-box;border:var(--bs-toast-border-width) solid var(--bs-toast-border-color);box-shadow:var(--bs-toast-box-shadow);border-radius:var(--bs-toast-border-radius)}:host ::ng-deep .toast.showing{opacity:0}:host ::ng-deep .toast:not(.show){display:none}:host ::ng-deep .toast-container{--bs-toast-zindex: 1090;position:absolute;z-index:var(--bs-toast-zindex);width:max-content;max-width:100%;pointer-events:none}:host ::ng-deep .toast-container>:not(:last-child){margin-bottom:var(--bs-toast-spacing)}:host ::ng-deep .toast-header{display:flex;align-items:center;padding:var(--bs-toast-padding-y) var(--bs-toast-padding-x);color:var(--bs-toast-header-color);background-color:var(--bs-toast-header-bg);background-clip:padding-box;border-bottom:var(--bs-toast-border-width) solid var(--bs-toast-header-border-color);border-top-left-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width));border-top-right-radius:calc(var(--bs-toast-border-radius) - var(--bs-toast-border-width))}:host ::ng-deep .toast-header .btn-close{margin-right:calc(-.5 * var(--bs-toast-padding-x));margin-left:var(--bs-toast-padding-x)}:host ::ng-deep .toast-body{padding:var(--bs-toast-padding-x);word-wrap:break-word}\n"] }]
        }], ctorParameters: function () { return [{ type: BsToastService }]; }, propDecorators: { overflowY: [{
                type: HostBinding,
                args: ['style.overflow-y']
            }] } });

class BsToastCloseDirective {
    constructor(toast, toastService) {
        this.toast = toast;
        this.toastService = toastService;
        this.index = null;
    }
    onClick() {
        if (this.index !== null) {
            this.toastService.close(this.index);
        }
    }
}
BsToastCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastCloseDirective, deps: [{ token: BsToastComponent }, { token: BsToastService }], target: i0.ɵɵFactoryTarget.Directive });
BsToastCloseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.7", type: BsToastCloseDirective, selector: "bs-close", inputs: { index: "index" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastCloseDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: 'bs-close'
                }]
        }], ctorParameters: function () { return [{ type: BsToastComponent }, { type: BsToastService }]; }, propDecorators: { onClick: [{
                type: HostListener,
                args: ['click']
            }], index: [{
                type: Input
            }] } });

class BsToastModule {
}
BsToastModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
BsToastModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: BsToastModule, declarations: [BsToastComponent,
        BsToastBodyComponent,
        BsToastHeaderComponent,
        BsToastContainerComponent,
        BsToastCloseDirective,
        BsAddPropertiesPipe], imports: [CommonModule,
        OverlayModule,
        BsHasOverlayModule], exports: [BsToastComponent,
        BsToastBodyComponent,
        BsToastHeaderComponent,
        BsToastContainerComponent,
        BsToastCloseDirective,
        BsAddPropertiesPipe] });
BsToastModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastModule, providers: [
        {
            provide: PORTAL_FACTORY,
            useValue: (injector) => {
                return new ComponentPortal(BsToastContainerComponent, null, injector);
            }
        },
        BsToastService
    ], imports: [CommonModule,
        OverlayModule,
        BsHasOverlayModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsToastModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        BsToastComponent,
                        BsToastBodyComponent,
                        BsToastHeaderComponent,
                        BsToastContainerComponent,
                        BsToastCloseDirective,
                        BsAddPropertiesPipe,
                    ],
                    imports: [
                        CommonModule,
                        OverlayModule,
                        BsHasOverlayModule,
                    ],
                    exports: [
                        BsToastComponent,
                        BsToastBodyComponent,
                        BsToastHeaderComponent,
                        BsToastContainerComponent,
                        BsToastCloseDirective,
                        BsAddPropertiesPipe,
                    ],
                    providers: [
                        {
                            provide: PORTAL_FACTORY,
                            useValue: (injector) => {
                                return new ComponentPortal(BsToastContainerComponent, null, injector);
                            }
                        },
                        BsToastService
                    ]
                }]
        }] });

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

export { BsAddPropertiesPipe, BsToastBodyComponent, BsToastCloseDirective, BsToastComponent, BsToastContainerComponent, BsToastHeaderComponent, BsToastModule, BsToastService };
//# sourceMappingURL=mintplayer-ng-bootstrap-toast.mjs.map
