import * as i0 from '@angular/core';
import { InjectionToken, Component, Inject, Input, HostBinding, Injector, Directive, Host, SkipSelf, NgModule } from '@angular/core';
import { FadeInOutAnimation } from '@mintplayer/ng-animations';
import { BehaviorSubject, map, Subject, takeUntil, delay, take } from 'rxjs';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@mintplayer/ng-bootstrap/has-overlay';
import { BsHasOverlayModule } from '@mintplayer/ng-bootstrap/has-overlay';
import * as i1$1 from '@angular/cdk/overlay';
import { OverlayModule } from '@angular/cdk/overlay';
import { ComponentPortal } from '@angular/cdk/portal';

const POPOVER_CONTENT = new InjectionToken('PopoverContent');

class BsPopoverComponent {
    constructor(content) {
        //#region Position
        this.position$ = new BehaviorSubject('bottom');
        //#endregion
        //#region IsVisible
        this.isVisible$ = new BehaviorSubject(false);
        this.positionRelative = true;
        this.template = content;
        this.marginClass$ = this.position$.pipe(map((position) => {
            switch (position) {
                case 'top': return 'mb-2';
                case 'start': return 'me-2';
                case 'end': return 'ms-2';
                default: return 'mt-2';
            }
        }));
        this.positionClass$ = this.position$
            .pipe(map(position => `bs-popover-${position}`));
    }
    get position() {
        return this.position$.value;
    }
    set position(value) {
        this.position$.next(value);
    }
    get isVisible() {
        return this.isVisible$.value;
    }
    set isVisible(value) {
        this.isVisible$.next(value);
    }
}
BsPopoverComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverComponent, deps: [{ token: POPOVER_CONTENT }], target: i0.ɵɵFactoryTarget.Component });
BsPopoverComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: BsPopoverComponent, selector: "bs-popover", inputs: { position: "position", isVisible: "isVisible" }, host: { properties: { "class.position-relative": "this.positionRelative" } }, ngImport: i0, template: "<div class=\"popover position-relative fade show\" role=\"tooltip\"\n    [class]=\"[marginClass$ | async, positionClass$ | async]\"\n    [@fadeInOut]\n    *ngIf=\"isVisible$ | async\">\n    <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n    <div class=\"popover-arrow position-absolute\"></div>\n    <bs-has-overlay></bs-has-overlay>\n</div>\n", 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 .popover{--bs-popover-zindex: 1070;--bs-popover-max-width: 276px;--bs-popover-font-size: .875rem;--bs-popover-bg: #fff;--bs-popover-border-width: 1px;--bs-popover-border-color: var(--bs-border-color-translucent);--bs-popover-border-radius: .5rem;--bs-popover-inner-border-radius:calc(.5rem - 1px);--bs-popover-box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);--bs-popover-header-padding-x: 1rem;--bs-popover-header-padding-y: .5rem;--bs-popover-header-font-size: 1rem;--bs-popover-header-color: ;--bs-popover-header-bg: #f0f0f0;--bs-popover-body-padding-x: 1rem;--bs-popover-body-padding-y: 1rem;--bs-popover-body-color: #212529;--bs-popover-arrow-width: 1rem;--bs-popover-arrow-height: .5rem;--bs-popover-arrow-border: var(--bs-popover-border-color);z-index:var(--bs-popover-zindex);display:block;max-width:var(--bs-popover-max-width);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-popover-font-size);word-wrap:break-word;background-color:var(--bs-popover-bg);background-clip:padding-box;border:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-radius:var(--bs-popover-border-radius)}:host ::ng-deep .popover .popover-arrow{display:block;width:var(--bs-popover-arrow-width);height:var(--bs-popover-arrow-height)}:host ::ng-deep .popover .popover-arrow:before,:host ::ng-deep .popover .popover-arrow:after{position:absolute;display:block;content:\"\";border-color:transparent;border-style:solid;border-width:0}:host ::ng-deep .bs-popover-top>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow{bottom:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}:host ::ng-deep .bs-popover-top>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:before,:host ::ng-deep .bs-popover-top>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:after{border-width:var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}:host ::ng-deep .bs-popover-top>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:before{bottom:0;border-top-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-top>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:after{bottom:var(--bs-popover-border-width);border-top-color:var(--bs-popover-bg)}:host ::ng-deep .bs-popover-end>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow{left:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}:host ::ng-deep .bs-popover-end>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:before,:host ::ng-deep .bs-popover-end>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:after{border-width:calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}:host ::ng-deep .bs-popover-end>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:before{left:0;border-right-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-end>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:after{left:var(--bs-popover-border-width);border-right-color:var(--bs-popover-bg)}:host ::ng-deep .bs-popover-bottom>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow{top:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}:host ::ng-deep .bs-popover-bottom>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:before,:host ::ng-deep .bs-popover-bottom>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:after{border-width:0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}:host ::ng-deep .bs-popover-bottom>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:before{top:0;border-bottom-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-bottom>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:after{top:var(--bs-popover-border-width);border-bottom-color:var(--bs-popover-bg)}:host ::ng-deep .bs-popover-bottom .popover-header:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom] .popover-header:before{position:absolute;top:0;left:50%;display:block;width:var(--bs-popover-arrow-width);margin-left:calc(-.5 * var(--bs-popover-arrow-width));content:\"\";border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-header-bg)}:host ::ng-deep .bs-popover-start>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow{right:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}:host ::ng-deep .bs-popover-start>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:before,:host ::ng-deep .bs-popover-start>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:after{border-width:calc(var(--bs-popover-arrow-width) * .5) 0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}:host ::ng-deep .bs-popover-start>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:before{right:0;border-left-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-start>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:after{right:var(--bs-popover-border-width);border-left-color:var(--bs-popover-bg)}:host ::ng-deep .popover-header{padding:var(--bs-popover-header-padding-y) var(--bs-popover-header-padding-x);margin-bottom:0;font-size:var(--bs-popover-header-font-size);color:var(--bs-popover-header-color);background-color:var(--bs-popover-header-bg);border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-top-left-radius:var(--bs-popover-inner-border-radius);border-top-right-radius:var(--bs-popover-inner-border-radius)}:host ::ng-deep .popover-header:empty{display:none}:host ::ng-deep .popover-body{padding:var(--bs-popover-body-padding-y) var(--bs-popover-body-padding-x);color:var(--bs-popover-body-color)}.popover.bs-popover-top>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=top]>.popover-arrow,.popover.bs-popover-bottom>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow{left:50%;transform:translate(-50%)}.popover.bs-popover-start>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=left]>.popover-arrow,.popover.bs-popover-end>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=right]>.popover-arrow{top:50%;transform:translateY(-50%)}.popover:not(.show){pointer-events:none}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i2.BsHasOverlayComponent, selector: "bs-has-overlay" }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], animations: [FadeInOutAnimation] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-popover', animations: [FadeInOutAnimation], template: "<div class=\"popover position-relative fade show\" role=\"tooltip\"\n    [class]=\"[marginClass$ | async, positionClass$ | async]\"\n    [@fadeInOut]\n    *ngIf=\"isVisible$ | async\">\n    <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n    <div class=\"popover-arrow position-absolute\"></div>\n    <bs-has-overlay></bs-has-overlay>\n</div>\n", 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 .popover{--bs-popover-zindex: 1070;--bs-popover-max-width: 276px;--bs-popover-font-size: .875rem;--bs-popover-bg: #fff;--bs-popover-border-width: 1px;--bs-popover-border-color: var(--bs-border-color-translucent);--bs-popover-border-radius: .5rem;--bs-popover-inner-border-radius:calc(.5rem - 1px);--bs-popover-box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);--bs-popover-header-padding-x: 1rem;--bs-popover-header-padding-y: .5rem;--bs-popover-header-font-size: 1rem;--bs-popover-header-color: ;--bs-popover-header-bg: #f0f0f0;--bs-popover-body-padding-x: 1rem;--bs-popover-body-padding-y: 1rem;--bs-popover-body-color: #212529;--bs-popover-arrow-width: 1rem;--bs-popover-arrow-height: .5rem;--bs-popover-arrow-border: var(--bs-popover-border-color);z-index:var(--bs-popover-zindex);display:block;max-width:var(--bs-popover-max-width);font-family:var(--bs-font-sans-serif);font-style:normal;font-weight:400;line-height:1.5;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;letter-spacing:normal;word-break:normal;white-space:normal;word-spacing:normal;line-break:auto;font-size:var(--bs-popover-font-size);word-wrap:break-word;background-color:var(--bs-popover-bg);background-clip:padding-box;border:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-radius:var(--bs-popover-border-radius)}:host ::ng-deep .popover .popover-arrow{display:block;width:var(--bs-popover-arrow-width);height:var(--bs-popover-arrow-height)}:host ::ng-deep .popover .popover-arrow:before,:host ::ng-deep .popover .popover-arrow:after{position:absolute;display:block;content:\"\";border-color:transparent;border-style:solid;border-width:0}:host ::ng-deep .bs-popover-top>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow{bottom:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}:host ::ng-deep .bs-popover-top>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:before,:host ::ng-deep .bs-popover-top>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:after{border-width:var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}:host ::ng-deep .bs-popover-top>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:before{bottom:0;border-top-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-top>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=top]>.popover-arrow:after{bottom:var(--bs-popover-border-width);border-top-color:var(--bs-popover-bg)}:host ::ng-deep .bs-popover-end>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow{left:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}:host ::ng-deep .bs-popover-end>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:before,:host ::ng-deep .bs-popover-end>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:after{border-width:calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height) calc(var(--bs-popover-arrow-width) * .5) 0}:host ::ng-deep .bs-popover-end>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:before{left:0;border-right-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-end>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=right]>.popover-arrow:after{left:var(--bs-popover-border-width);border-right-color:var(--bs-popover-bg)}:host ::ng-deep .bs-popover-bottom>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow{top:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width))}:host ::ng-deep .bs-popover-bottom>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:before,:host ::ng-deep .bs-popover-bottom>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:after{border-width:0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}:host ::ng-deep .bs-popover-bottom>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:before{top:0;border-bottom-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-bottom>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow:after{top:var(--bs-popover-border-width);border-bottom-color:var(--bs-popover-bg)}:host ::ng-deep .bs-popover-bottom .popover-header:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=bottom] .popover-header:before{position:absolute;top:0;left:50%;display:block;width:var(--bs-popover-arrow-width);margin-left:calc(-.5 * var(--bs-popover-arrow-width));content:\"\";border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-header-bg)}:host ::ng-deep .bs-popover-start>.popover-arrow,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow{right:calc(-1 * (var(--bs-popover-arrow-height)) - var(--bs-popover-border-width));width:var(--bs-popover-arrow-height);height:var(--bs-popover-arrow-width)}:host ::ng-deep .bs-popover-start>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:before,:host ::ng-deep .bs-popover-start>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:after{border-width:calc(var(--bs-popover-arrow-width) * .5) 0 calc(var(--bs-popover-arrow-width) * .5) var(--bs-popover-arrow-height)}:host ::ng-deep .bs-popover-start>.popover-arrow:before,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:before{right:0;border-left-color:var(--bs-popover-arrow-border)}:host ::ng-deep .bs-popover-start>.popover-arrow:after,:host ::ng-deep .bs-popover-auto[data-popper-placement^=left]>.popover-arrow:after{right:var(--bs-popover-border-width);border-left-color:var(--bs-popover-bg)}:host ::ng-deep .popover-header{padding:var(--bs-popover-header-padding-y) var(--bs-popover-header-padding-x);margin-bottom:0;font-size:var(--bs-popover-header-font-size);color:var(--bs-popover-header-color);background-color:var(--bs-popover-header-bg);border-bottom:var(--bs-popover-border-width) solid var(--bs-popover-border-color);border-top-left-radius:var(--bs-popover-inner-border-radius);border-top-right-radius:var(--bs-popover-inner-border-radius)}:host ::ng-deep .popover-header:empty{display:none}:host ::ng-deep .popover-body{padding:var(--bs-popover-body-padding-y) var(--bs-popover-body-padding-x);color:var(--bs-popover-body-color)}.popover.bs-popover-top>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=top]>.popover-arrow,.popover.bs-popover-bottom>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=bottom]>.popover-arrow{left:50%;transform:translate(-50%)}.popover.bs-popover-start>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=left]>.popover-arrow,.popover.bs-popover-end>.popover-arrow,:host ::ng-deep .popover.bs-popover-auto[data-popper-placement^=right]>.popover-arrow{top:50%;transform:translateY(-50%)}.popover:not(.show){pointer-events:none}\n"] }]
        }], ctorParameters: function () {
        return [{ type: i0.TemplateRef, decorators: [{
                        type: Inject,
                        args: [POPOVER_CONTENT]
                    }] }];
    }, propDecorators: { position: [{
                type: Input
            }], isVisible: [{
                type: Input
            }], positionRelative: [{
                type: HostBinding,
                args: ['class.position-relative']
            }] } });

const PORTAL_FACTORY = new InjectionToken('PopoverPortalFactory');

class BsPopoverDirective {
    constructor(overlay, templateRef, parentInjector, portalFactory, parent) {
        this.overlay = overlay;
        this.templateRef = templateRef;
        this.parentInjector = parentInjector;
        this.portalFactory = portalFactory;
        this.parent = parent;
        this.updatePosition = false;
        this.injector = null;
        this.portal = null;
        this.overlayRef = null;
        this.component = null;
        this.position$ = new BehaviorSubject('bottom');
        this.isVisible$ = new BehaviorSubject(false);
        this.destroyed$ = new Subject();
        this.position$.pipe(takeUntil(this.destroyed$)).subscribe((position) => {
            if (this.component) {
                this.component.instance.position = position;
            }
        });
        this.isVisible$.pipe(takeUntil(this.destroyed$)).subscribe((isVisible) => {
            if (this.component) {
                this.component.instance.isVisible = isVisible;
            }
        });
        this.connectedPosition$ = this.position$
            .pipe(delay(20), map((position) => {
            switch (position) {
                case 'top':
                    return {
                        originX: "center",
                        originY: "top",
                        overlayX: "center",
                        overlayY: "bottom"
                    };
                case 'start':
                    return {
                        originX: "start",
                        originY: "center",
                        overlayX: "end",
                        overlayY: "center",
                    };
                case 'end':
                    return {
                        originX: "end",
                        originY: "center",
                        overlayX: "start",
                        overlayY: "center"
                    };
                default:
                    return {
                        originX: "center",
                        originY: "bottom",
                        overlayX: "center",
                        overlayY: "top"
                    };
            }
        }));
        this.connectedPosition$
            .pipe(takeUntil(this.destroyed$))
            .subscribe((connectedPosition) => {
            if (this.overlayRef) {
                this.overlayRef.updatePositionStrategy(this.overlay.position()
                    .flexibleConnectedTo(this.parent)
                    .withPositions([connectedPosition]));
            }
        });
        this.destroyed$.pipe(take(1)).subscribe(() => {
            if (this.overlayRef) {
                this.overlayRef.detach();
                this.overlayRef.dispose();
                this.overlayRef = null;
            }
        });
    }
    set bsPopover(value) {
        this.position$.next(value);
    }
    ngAfterViewInit() {
        this.connectedPosition$.pipe(take(1)).subscribe((connectedPosition) => {
            this.injector = Injector.create({
                providers: [{ provide: POPOVER_CONTENT, useValue: this.templateRef }],
                parent: this.parentInjector
            });
            this.portal = this.portalFactory(this.injector);
            this.overlayRef = this.overlay.create({
                scrollStrategy: this.overlay.scrollStrategies.reposition(),
                positionStrategy: this.overlay.position()
                    .flexibleConnectedTo(this.parent)
                    .withPositions([connectedPosition]),
            });
            this.component = this.overlayRef.attach(this.portal);
            this.component.instance.position = this.position$.value;
        });
        this.parent.nativeElement.onclick = () => {
            var _a;
            if (this.updatePosition) {
                (_a = this.overlayRef) === null || _a === void 0 ? void 0 : _a.updatePosition();
            }
            this.isVisible$.next(!this.isVisible$.value);
        };
    }
    ngOnDestroy() {
        this.destroyed$.next(true);
    }
}
BsPopoverDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverDirective, deps: [{ token: i1$1.Overlay }, { token: i0.TemplateRef }, { token: i0.Injector }, { token: PORTAL_FACTORY }, { token: i0.ElementRef, host: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
BsPopoverDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsPopoverDirective, selector: "*[bsPopover]", inputs: { bsPopover: "bsPopover", updatePosition: "updatePosition" }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '*[bsPopover]'
                }]
        }], ctorParameters: function () {
        return [{ type: i1$1.Overlay }, { type: i0.TemplateRef }, { type: i0.Injector }, { type: undefined, decorators: [{
                        type: Inject,
                        args: [PORTAL_FACTORY]
                    }] }, { type: i0.ElementRef, decorators: [{
                        type: Host
                    }, {
                        type: SkipSelf
                    }] }];
    }, propDecorators: { bsPopover: [{
                type: Input
            }], updatePosition: [{
                type: Input
            }] } });

class BsPopoverBodyDirective {
    constructor() {
        this.bodyClass = true;
    }
}
BsPopoverBodyDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverBodyDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
BsPopoverBodyDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsPopoverBodyDirective, selector: "[bsPopoverBody]", host: { properties: { "class.popover-body": "this.bodyClass" } }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverBodyDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bsPopoverBody]'
                }]
        }], propDecorators: { bodyClass: [{
                type: HostBinding,
                args: ['class.popover-body']
            }] } });

class BsPopoverHeaderDirective {
    constructor() {
        this.headerClass = true;
    }
}
BsPopoverHeaderDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverHeaderDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
BsPopoverHeaderDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsPopoverHeaderDirective, selector: "[bsPopoverHeader]", host: { properties: { "class.popover-header": "this.headerClass" } }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverHeaderDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[bsPopoverHeader]'
                }]
        }], propDecorators: { headerClass: [{
                type: HostBinding,
                args: ['class.popover-header']
            }] } });

class BsPopoverModule {
}
BsPopoverModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
BsPopoverModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverModule, declarations: [BsPopoverComponent, BsPopoverDirective, BsPopoverHeaderDirective, BsPopoverBodyDirective], imports: [CommonModule, OverlayModule, BsHasOverlayModule], exports: [BsPopoverDirective, BsPopoverHeaderDirective, BsPopoverBodyDirective] });
BsPopoverModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverModule, providers: [{
            provide: PORTAL_FACTORY,
            useValue: (injector) => {
                return new ComponentPortal(BsPopoverComponent, null, injector);
            }
        }], imports: [CommonModule, OverlayModule, BsHasOverlayModule] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsPopoverModule, decorators: [{
            type: NgModule,
            args: [{
                    declarations: [BsPopoverComponent, BsPopoverDirective, BsPopoverHeaderDirective, BsPopoverBodyDirective],
                    imports: [CommonModule, OverlayModule, BsHasOverlayModule],
                    exports: [BsPopoverDirective, BsPopoverHeaderDirective, BsPopoverBodyDirective],
                    providers: [{
                            provide: PORTAL_FACTORY,
                            useValue: (injector) => {
                                return new ComponentPortal(BsPopoverComponent, null, injector);
                            }
                        }]
                }]
        }] });

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

export { BsPopoverBodyDirective, BsPopoverComponent, BsPopoverDirective, BsPopoverHeaderDirective, BsPopoverModule };
//# sourceMappingURL=mintplayer-ng-bootstrap-popover.mjs.map
