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

const SNACKBAR_CONTENT = new InjectionToken('SnackbarContent');

class BsSnackbarComponent {
    constructor(content) {
        this.displayBlock = true;
        this.width100 = true;
        this.instance = null;
        //#region Monitor @slideUpDownNgif hooks
        this.animationState = '';
        this.animationStateChanged = new EventEmitter();
        this.content = content;
    }
    onAnimationChanged(event) {
        this.animationStateChanged.emit(event);
    }
}
BsSnackbarComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarComponent, deps: [{ token: SNACKBAR_CONTENT }], target: i0.ɵɵFactoryTarget.Component });
BsSnackbarComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.7", type: BsSnackbarComponent, selector: "bs-snackbar", host: { properties: { "class.d-block": "this.displayBlock", "class.w-100": "this.width100" } }, ngImport: i0, template: "<bs-has-overlay></bs-has-overlay>\n<div [@slideUpDownNgif]=\"animationState\"\n     (@slideUpDownNgif.start)=\"onAnimationChanged($event)\"\n     (@slideUpDownNgif.done)=\"onAnimationChanged($event)\">\n    <ng-container *ngTemplateOutlet=\"content; context: { $implicit: this }\" ></ng-container>\n</div>", styles: [":host{background:#232323;color:rgba(var(--bs-light-rgb))}\n"], dependencies: [{ kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i2.BsHasOverlayComponent, selector: "bs-has-overlay" }], animations: [SlideUpDownNgifAnimation] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-snackbar', animations: [SlideUpDownNgifAnimation], template: "<bs-has-overlay></bs-has-overlay>\n<div [@slideUpDownNgif]=\"animationState\"\n     (@slideUpDownNgif.start)=\"onAnimationChanged($event)\"\n     (@slideUpDownNgif.done)=\"onAnimationChanged($event)\">\n    <ng-container *ngTemplateOutlet=\"content; context: { $implicit: this }\" ></ng-container>\n</div>", styles: [":host{background:#232323;color:rgba(var(--bs-light-rgb))}\n"] }]
        }], ctorParameters: function () {
        return [{ type: i0.TemplateRef, decorators: [{
                        type: Inject,
                        args: [SNACKBAR_CONTENT]
                    }] }];
    }, propDecorators: { displayBlock: [{
                type: HostBinding,
                args: ['class.d-block']
            }], width100: [{
                type: HostBinding,
                args: ['class.w-100']
            }] } });

class BsSnackbarService {
    constructor(overlay, parentInjector) {
        this.overlay = overlay;
        this.parentInjector = parentInjector;
    }
    show(template) {
        const injector = Injector.create({
            providers: [{ provide: SNACKBAR_CONTENT, useValue: template }],
            parent: this.parentInjector
        });
        const portal = new ComponentPortal(BsSnackbarComponent, null, injector);
        const overlayRef = this.overlay.create({
            scrollStrategy: this.overlay.scrollStrategies.reposition(),
            positionStrategy: this.overlay.position()
                .global().centerHorizontally().bottom('0'),
            width: '100%'
        });
        const componentInstance = overlayRef.attach(portal);
        componentInstance.instance['instance'] = {
            component: componentInstance,
            overlay: overlayRef
        };
        return componentInstance.instance;
    }
    hide(snackbar) {
        snackbar.animationStateChanged.pipe(filter(ev => ev.phaseName === 'done' && ev.toState === 'void'), take(1)).subscribe(() => {
            var _a;
            (_a = snackbar['instance']) === null || _a === void 0 ? void 0 : _a.overlay.dispose();
        });
        snackbar.animationState = 'void';
    }
}
BsSnackbarService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarService, deps: [{ token: i1$1.Overlay }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
BsSnackbarService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarService });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarService, decorators: [{
            type: Injectable
        }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i0.Injector }]; } });

class BsSnackbarCloseDirective {
    constructor(snackbarService) {
        this.snackbarService = snackbarService;
    }
    onClick() {
        this.snackbarService.hide(this.bsSnackbarClose);
    }
}
BsSnackbarCloseDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarCloseDirective, deps: [{ token: BsSnackbarService }], target: i0.ɵɵFactoryTarget.Directive });
BsSnackbarCloseDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.7", type: BsSnackbarCloseDirective, selector: "[bsSnackbarClose]", inputs: { bsSnackbarClose: "bsSnackbarClose" }, host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarCloseDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bsSnackbarClose]'
                }]
        }], ctorParameters: function () { return [{ type: BsSnackbarService }]; }, propDecorators: { bsSnackbarClose: [{
                type: Input
            }], onClick: [{
                type: HostListener,
                args: ['click']
            }] } });

class BsSnackbarModule {
}
BsSnackbarModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
BsSnackbarModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarModule, declarations: [BsSnackbarComponent,
        BsSnackbarCloseDirective], imports: [CommonModule,
        OverlayModule,
        BsHasOverlayModule], exports: [BsSnackbarComponent,
        BsSnackbarCloseDirective] });
BsSnackbarModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarModule, providers: [
        BsSnackbarService
    ], imports: [CommonModule,
        OverlayModule,
        BsHasOverlayModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BsSnackbarModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [
                        BsSnackbarComponent,
                        BsSnackbarCloseDirective
                    ],
                    imports: [
                        CommonModule,
                        OverlayModule,
                        BsHasOverlayModule
                    ],
                    exports: [
                        BsSnackbarComponent,
                        BsSnackbarCloseDirective
                    ],
                    providers: [
                        BsSnackbarService
                    ]
                }]
        }] });

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

export { BsSnackbarCloseDirective, BsSnackbarComponent, BsSnackbarModule, BsSnackbarService };
//# sourceMappingURL=mintplayer-ng-bootstrap-snackbar.mjs.map
