import * as i1$1 from '@angular/cdk/overlay';
import { OverlayModule } from '@angular/cdk/overlay';
import { ComponentPortal } from '@angular/cdk/portal';
import * as i0 from '@angular/core';
import { InjectionToken, Component, Inject, Input, HostBinding, Injector, Directive, Host, SkipSelf, HostListener, NgModule } from '@angular/core';
import { BehaviorSubject, map } from 'rxjs';
import { FadeInOutAnimation } from '@mintplayer/ng-animations';
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';

const TOOLTIP_CONTENT = new InjectionToken('TooltipContent');

class BsTooltipComponent {
    constructor(content) {
        //#region Position
        this.position$ = new BehaviorSubject('bottom');
        this.positionRelative = true;
        this.template = content;
        this.positionClass$ = this.position$
            .pipe(map(position => `bs-tooltip-${position}`));
    }
    get position() {
        return this.position$.value;
    }
    set position(value) {
        this.position$.next(value);
    }
}
BsTooltipComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsTooltipComponent, deps: [{ token: TOOLTIP_CONTENT }], target: i0.ɵɵFactoryTarget.Component });
BsTooltipComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.4", type: BsTooltipComponent, selector: "bs-tooltip", inputs: { position: "position" }, host: { properties: { "class.position-relative": "this.positionRelative" } }, ngImport: i0, template: "<bs-has-overlay></bs-has-overlay>\n<div [@fadeInOut] class=\"tooltip position-absolute show\"\n    [class]=\"[positionClass$ | async]\">\n    <div class=\"tooltip-arrow position-absolute\"></div>\n    <div class=\"tooltip-inner\">\n        <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n    </div>\n</div>\n", styles: [":host ::ng-deep .tooltip{--bs-tooltip-zindex: 1080;--bs-tooltip-max-width: 200px;--bs-tooltip-padding-x: .5rem;--bs-tooltip-padding-y: .25rem;--bs-tooltip-margin: ;--bs-tooltip-font-size: .875rem;--bs-tooltip-color: #fff;--bs-tooltip-bg: #000;--bs-tooltip-border-radius: .375rem;--bs-tooltip-opacity: .9;--bs-tooltip-arrow-width: .8rem;--bs-tooltip-arrow-height: .4rem;z-index:var(--bs-tooltip-zindex);display:block;padding:var(--bs-tooltip-arrow-height);margin:var(--bs-tooltip-margin);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-tooltip-font-size);word-wrap:break-word;opacity:0}:host ::ng-deep .tooltip.show{opacity:var(--bs-tooltip-opacity)}:host ::ng-deep .tooltip .tooltip-arrow{display:block;width:var(--bs-tooltip-arrow-width);height:var(--bs-tooltip-arrow-height)}:host ::ng-deep .tooltip .tooltip-arrow:before{position:absolute;content:\"\";border-color:transparent;border-style:solid}:host ::ng-deep .bs-tooltip-top .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow{bottom:0}:host ::ng-deep .bs-tooltip-top .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow:before{top:-1px;border-width:var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-top-color:var(--bs-tooltip-bg)}:host ::ng-deep .bs-tooltip-end .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow{left:0;width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}:host ::ng-deep .bs-tooltip-end .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow:before{right:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-right-color:var(--bs-tooltip-bg)}:host ::ng-deep .bs-tooltip-bottom .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow{top:0}:host ::ng-deep .bs-tooltip-bottom .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow:before{bottom:-1px;border-width:0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-bottom-color:var(--bs-tooltip-bg)}:host ::ng-deep .bs-tooltip-start .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow{right:0;width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}:host ::ng-deep .bs-tooltip-start .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow:before{left:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) 0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-left-color:var(--bs-tooltip-bg)}:host ::ng-deep .tooltip-inner{max-width:var(--bs-tooltip-max-width);padding:var(--bs-tooltip-padding-y) var(--bs-tooltip-padding-x);color:var(--bs-tooltip-color);text-align:center;background-color:var(--bs-tooltip-bg);border-radius:var(--bs-tooltip-border-radius)}.tooltip.bs-tooltip-start,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=left]{right:0}.tooltip.bs-tooltip-start,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=left],.tooltip.bs-tooltip-end,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=right]{transform:translateY(-50%)}.tooltip.bs-tooltip-bottom,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=bottom]{transform:translate(-50%)}.tooltip.bs-tooltip-top,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=top]{transform:translate(-50%) translateY(-100%)}.tooltip.bs-tooltip-bottom .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow,.tooltip.bs-tooltip-top .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow{left:50%;transform:translate(-50%)}.tooltip.bs-tooltip-start .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow,.tooltip.bs-tooltip-end .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow{top:50%;transform:translateY(-50%)}\n"], dependencies: [{ 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: BsTooltipComponent, decorators: [{
            type: Component,
            args: [{ selector: 'bs-tooltip', animations: [FadeInOutAnimation], template: "<bs-has-overlay></bs-has-overlay>\n<div [@fadeInOut] class=\"tooltip position-absolute show\"\n    [class]=\"[positionClass$ | async]\">\n    <div class=\"tooltip-arrow position-absolute\"></div>\n    <div class=\"tooltip-inner\">\n        <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n    </div>\n</div>\n", styles: [":host ::ng-deep .tooltip{--bs-tooltip-zindex: 1080;--bs-tooltip-max-width: 200px;--bs-tooltip-padding-x: .5rem;--bs-tooltip-padding-y: .25rem;--bs-tooltip-margin: ;--bs-tooltip-font-size: .875rem;--bs-tooltip-color: #fff;--bs-tooltip-bg: #000;--bs-tooltip-border-radius: .375rem;--bs-tooltip-opacity: .9;--bs-tooltip-arrow-width: .8rem;--bs-tooltip-arrow-height: .4rem;z-index:var(--bs-tooltip-zindex);display:block;padding:var(--bs-tooltip-arrow-height);margin:var(--bs-tooltip-margin);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-tooltip-font-size);word-wrap:break-word;opacity:0}:host ::ng-deep .tooltip.show{opacity:var(--bs-tooltip-opacity)}:host ::ng-deep .tooltip .tooltip-arrow{display:block;width:var(--bs-tooltip-arrow-width);height:var(--bs-tooltip-arrow-height)}:host ::ng-deep .tooltip .tooltip-arrow:before{position:absolute;content:\"\";border-color:transparent;border-style:solid}:host ::ng-deep .bs-tooltip-top .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow{bottom:0}:host ::ng-deep .bs-tooltip-top .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow:before{top:-1px;border-width:var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-top-color:var(--bs-tooltip-bg)}:host ::ng-deep .bs-tooltip-end .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow{left:0;width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}:host ::ng-deep .bs-tooltip-end .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow:before{right:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height) calc(var(--bs-tooltip-arrow-width) * .5) 0;border-right-color:var(--bs-tooltip-bg)}:host ::ng-deep .bs-tooltip-bottom .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow{top:0}:host ::ng-deep .bs-tooltip-bottom .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow:before{bottom:-1px;border-width:0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-bottom-color:var(--bs-tooltip-bg)}:host ::ng-deep .bs-tooltip-start .tooltip-arrow,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow{right:0;width:var(--bs-tooltip-arrow-height);height:var(--bs-tooltip-arrow-width)}:host ::ng-deep .bs-tooltip-start .tooltip-arrow:before,:host ::ng-deep .bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow:before{left:-1px;border-width:calc(var(--bs-tooltip-arrow-width) * .5) 0 calc(var(--bs-tooltip-arrow-width) * .5) var(--bs-tooltip-arrow-height);border-left-color:var(--bs-tooltip-bg)}:host ::ng-deep .tooltip-inner{max-width:var(--bs-tooltip-max-width);padding:var(--bs-tooltip-padding-y) var(--bs-tooltip-padding-x);color:var(--bs-tooltip-color);text-align:center;background-color:var(--bs-tooltip-bg);border-radius:var(--bs-tooltip-border-radius)}.tooltip.bs-tooltip-start,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=left]{right:0}.tooltip.bs-tooltip-start,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=left],.tooltip.bs-tooltip-end,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=right]{transform:translateY(-50%)}.tooltip.bs-tooltip-bottom,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=bottom]{transform:translate(-50%)}.tooltip.bs-tooltip-top,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=top]{transform:translate(-50%) translateY(-100%)}.tooltip.bs-tooltip-bottom .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=bottom] .tooltip-arrow,.tooltip.bs-tooltip-top .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=top] .tooltip-arrow{left:50%;transform:translate(-50%)}.tooltip.bs-tooltip-start .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=left] .tooltip-arrow,.tooltip.bs-tooltip-end .tooltip-arrow,:host ::ng-deep .tooltip.bs-tooltip-auto[data-popper-placement^=right] .tooltip-arrow{top:50%;transform:translateY(-50%)}\n"] }]
        }], ctorParameters: function () { return [{ type: i0.TemplateRef, decorators: [{
                    type: Inject,
                    args: [TOOLTIP_CONTENT]
                }] }]; }, propDecorators: { position: [{
                type: Input
            }], positionRelative: [{
                type: HostBinding,
                args: ['class.position-relative']
            }] } });

class BsTooltipDirective {
    constructor(overlay, templateRef, parentInjector, parent) {
        this.overlay = overlay;
        this.templateRef = templateRef;
        this.parentInjector = parentInjector;
        this.parent = parent;
        this.bsTooltip = 'bottom';
        this.overlayRef = null;
        this.injector = Injector.create({
            providers: [{ provide: TOOLTIP_CONTENT, useValue: this.templateRef }],
            parent: this.parentInjector
        });
        this.portal = new ComponentPortal(BsTooltipComponent, null, this.injector);
        parent.nativeElement.onmouseenter = () => {
            this.showTooltip();
        };
        parent.nativeElement.onmouseleave = () => {
            this.hideTooltip();
        };
    }
    onBlur() {
        this.hideTooltip();
    }
    showTooltip() {
        const positions = [];
        switch (this.bsTooltip) {
            case 'bottom':
                {
                    positions.push({
                        originX: "center",
                        originY: "bottom",
                        overlayX: "center",
                        overlayY: "top"
                    });
                }
                break;
            case 'top':
                {
                    positions.push({
                        originX: "center",
                        originY: "top",
                        overlayX: "center",
                        overlayY: "bottom"
                    });
                }
                break;
            case 'start':
                {
                    positions.push({
                        originX: "start",
                        originY: "center",
                        overlayX: "end",
                        overlayY: "center",
                    });
                }
                break;
            case 'end':
                {
                    positions.push({
                        originX: "end",
                        originY: "center",
                        overlayX: "start",
                        overlayY: "center"
                    });
                }
                break;
        }
        this.overlayRef = this.overlay.create({
            scrollStrategy: this.overlay.scrollStrategies.reposition(),
            positionStrategy: this.overlay.position()
                .flexibleConnectedTo(this.parent)
                .withPositions(positions),
        });
        const component = this.overlayRef.attach(this.portal);
        component.instance.position = this.bsTooltip;
    }
    hideTooltip() {
        if (this.overlayRef) {
            this.overlayRef.detach();
            this.overlayRef.dispose();
            this.overlayRef = null;
        }
    }
}
BsTooltipDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsTooltipDirective, deps: [{ token: i1$1.Overlay }, { token: i0.TemplateRef }, { token: i0.Injector }, { token: i0.ElementRef, host: true, skipSelf: true }], target: i0.ɵɵFactoryTarget.Directive });
BsTooltipDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.0.4", type: BsTooltipDirective, selector: "*[bsTooltip]", inputs: { bsTooltip: "bsTooltip" }, host: { listeners: { "window:blur": "onBlur()" } }, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.4", ngImport: i0, type: BsTooltipDirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '*[bsTooltip]'
                }]
        }], ctorParameters: function () { return [{ type: i1$1.Overlay }, { type: i0.TemplateRef }, { type: i0.Injector }, { type: i0.ElementRef, decorators: [{
                    type: Host
                }, {
                    type: SkipSelf
                }] }]; }, propDecorators: { bsTooltip: [{
                type: Input
            }], onBlur: [{
                type: HostListener,
                args: ['window:blur']
            }] } });

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

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

export { BsTooltipDirective, BsTooltipModule };
//# sourceMappingURL=mintplayer-ng-bootstrap-tooltip.mjs.map
