import * as i0 from '@angular/core';
import { Component, ChangeDetectionStrategy, Input, Directive, ViewContainerRef, ContentChild, NgModule } from '@angular/core';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import { TooltipPosition } from '@ironsource/fusion-ui/components/tooltip/common/base';
import { Subject, fromEvent, of } from 'rxjs';
import { takeUntil, switchMap } from 'rxjs/operators';

function TooltipContentComponent_ng_container_1_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainer(0, 3);
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.temp);
} }
function TooltipContentComponent_span_2_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "span");
    i0.ɵɵtext(1);
    i0.ɵɵelementEnd();
} if (rf & 2) {
    const ctx_r1 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(ctx_r1.tooltipInnerText);
} }
class TooltipContentComponent {
    set tooltipTextContent(text) {
        if (text) {
            this.tooltipInnerText = text;
        }
    }
    /** @internal */
    set templateRef(template) {
        this.temp = template;
    }
    set tooltipPositionClass(pos) {
        this.position = TooltipPosition[pos]?.toLowerCase();
        this.renderer.addClass(this.elementRef.nativeElement, 'fu-tooltip-' + this.position);
    }
    set tooltipStyleConfiguration(config) {
        if (config) {
            this.setTooltipStyle(config);
        }
    }
    constructor(
    /** @internal */
    elementRef, renderer) {
        this.elementRef = elementRef;
        this.renderer = renderer;
    }
    setTooltipStyle(propertyValue) {
        Object.keys(propertyValue).forEach(val => {
            if (val === 'backgroundColor' && !!propertyValue[val]) {
                this.elementRef.nativeElement.style.setProperty('--fu-tooltip-background-color', propertyValue[val]);
            }
            else {
                this.renderer.setStyle(this.elementRef.nativeElement, val, propertyValue[val]);
            }
        });
    }
    static { this.ɵfac = function TooltipContentComponent_Factory(t) { return new (t || TooltipContentComponent)(i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2)); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TooltipContentComponent, selectors: [["fusion-tooltip-content"]], inputs: { tooltipTextContent: "tooltipTextContent", templateRef: "templateRef", tooltipPositionClass: "tooltipPositionClass", tooltipStyleConfiguration: "tooltipStyleConfiguration" }, decls: 3, vars: 2, consts: [[1, "fu-tooltip-component"], [3, "ngTemplateOutlet", 4, "ngIf"], [4, "ngIf"], [3, "ngTemplateOutlet"]], template: function TooltipContentComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵelementStart(0, "div", 0);
            i0.ɵɵtemplate(1, TooltipContentComponent_ng_container_1_Template, 1, 1, "ng-container", 1)(2, TooltipContentComponent_span_2_Template, 2, 1, "span", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", !ctx.tooltipInnerText);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.tooltipInnerText);
        } }, dependencies: [i1.NgIf, i1.NgTemplateOutlet], styles: ["@font-face{font-family:NHaasGroteskDSPro;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.ttf) format(\"truetype\")}@font-face{font-family:NHaasGroteskDSPro-65Md;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue-Medium;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.ttf) format(\"truetype\")}.font-heading-6[_ngcontent-%COMP%], .font-heading-5[_ngcontent-%COMP%], .font-heading-4[_ngcontent-%COMP%], .font-heading-3[_ngcontent-%COMP%], .font-heading-2[_ngcontent-%COMP%], .font-heading-1[_ngcontent-%COMP%]{font-family:NHaasGroteskDSPro,sans-serif}.font-heading-1[_ngcontent-%COMP%]{font-size:60px}.font-heading-2[_ngcontent-%COMP%]{font-size:32px}.font-heading-3[_ngcontent-%COMP%]{font-size:22px}.font-heading-4[_ngcontent-%COMP%]{font-size:18px}.font-heading-5[_ngcontent-%COMP%]{font-size:15px}.font-heading-6[_ngcontent-%COMP%]{font-size:13px}.font-heading-label[_ngcontent-%COMP%]{font-size:11px;font-family:NHaasGroteskDSPro-65Md,sans-serif;letter-spacing:.25px}.font-caption[_ngcontent-%COMP%], .font-bodyXSmall[_ngcontent-%COMP%], .font-bodySmall[_ngcontent-%COMP%], .font-bodyMedium[_ngcontent-%COMP%], .font-bodyLarge[_ngcontent-%COMP%]{font-family:HelveticaNeue,helvetica,sans-serif;line-height:1.5}.font-bodyXSmallStrong[_ngcontent-%COMP%], [_nghost-%COMP%], .font-bodySmallStrong[_ngcontent-%COMP%], .font-bodyMediumStrong[_ngcontent-%COMP%], .font-bodyLargeStrong[_ngcontent-%COMP%]{font-family:HelveticaNeue-Medium,helvetica,sans-serif;line-height:1.5}.font-bodyLarge[_ngcontent-%COMP%], .font-bodyLargeStrong[_ngcontent-%COMP%]{font-size:16px}.font-bodyMedium[_ngcontent-%COMP%], .font-bodyMediumStrong[_ngcontent-%COMP%]{font-size:14px}.font-bodySmall[_ngcontent-%COMP%]{font-size:13px;letter-spacing:.24px}[_nghost-%COMP%], .font-bodySmallStrong[_ngcontent-%COMP%]{font-size:13px;letter-spacing:.24px}.font-bodyXSmall[_ngcontent-%COMP%], .font-bodyXSmallStrong[_ngcontent-%COMP%]{font-size:12px;letter-spacing:.24px}.font-caption[_ngcontent-%COMP%]{font-size:11px}@keyframes _ngcontent-%COMP%_rotation{0%{transform:rotate(0)}to{transform:rotate(359deg)}}@keyframes _ngcontent-%COMP%_shineAnimation{0%{background-position:-750px 0}to{background-position:750px 0}}.fu-tooltip-right[_nghost-%COMP%]:after, .fu-tooltip-left[_nghost-%COMP%]:after{content:\"\";position:absolute;margin-top:-5px;border-width:5px;border-style:solid}.fu-tooltip-bottomleft[_nghost-%COMP%]:after, .fu-tooltip-bottomright[_nghost-%COMP%]:after, .fu-tooltip-topleft[_nghost-%COMP%]:after, .fu-tooltip-topright[_nghost-%COMP%]:after, .fu-tooltip-bottom[_nghost-%COMP%]:after, .fu-tooltip-top[_nghost-%COMP%]:after{content:\"\";position:absolute;margin-left:-5px;border-width:5px;border-style:solid}[_nghost-%COMP%]{box-sizing:border-box;position:fixed;width:-moz-fit-content;width:fit-content;color:#fff;border-radius:8px;line-height:19.5px;letter-spacing:.24px;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:var(--fu-tooltip-padding, 8px 8px 7px);background-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D));z-index:3020;box-shadow:0 6px 6px -6px #00000029;filter:drop-shadow(0px 0px 1px rgba(0,0,0,.4))}.fu-tooltip-top[_nghost-%COMP%]:after{top:100%;left:50%;border-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent transparent}.fu-tooltip-bottom[_nghost-%COMP%]:after{bottom:100%;left:50%;border-color:transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent}.fu-tooltip-left[_nghost-%COMP%]:after{top:50%;left:100%;border-color:transparent transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D))}.fu-tooltip-right[_nghost-%COMP%]:after{top:50%;right:100%;border-color:transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent}.fu-tooltip-topright[_nghost-%COMP%]:after{top:100%;left:calc(100% - 20px);border-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent transparent}.fu-tooltip-topleft[_nghost-%COMP%]:after{top:100%;left:20px;border-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent transparent}.fu-tooltip-bottomright[_nghost-%COMP%]:after{bottom:100%;left:calc(100% - 20px);border-color:transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent}.fu-tooltip-bottomleft[_nghost-%COMP%]:after{bottom:100%;left:20px;border-color:transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent}"], changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TooltipContentComponent, [{
        type: Component,
        args: [{ selector: 'fusion-tooltip-content', template: ` <div class="fu-tooltip-component">
        <ng-container *ngIf="!tooltipInnerText" [ngTemplateOutlet]="temp"></ng-container>
        <span *ngIf="tooltipInnerText">{{ tooltipInnerText }}</span>
    </div>`, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["@font-face{font-family:NHaasGroteskDSPro;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-75Bd.ttf) format(\"truetype\")}@font-face{font-family:NHaasGroteskDSPro-65Md;src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot);src:url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/NHaasGroteskDSPro-65Md.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue.ttf) format(\"truetype\")}@font-face{font-family:HelveticaNeue-Medium;src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot);src:url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.eot?#iefix) format(\"embedded-opentype\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff2) format(\"woff2\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.woff) format(\"woff\"),url(https://fusion.ironsrc.net/assets/fonts/HelveticaNeue-Medium.ttf) format(\"truetype\")}.font-heading-6,.font-heading-5,.font-heading-4,.font-heading-3,.font-heading-2,.font-heading-1{font-family:NHaasGroteskDSPro,sans-serif}.font-heading-1{font-size:60px}.font-heading-2{font-size:32px}.font-heading-3{font-size:22px}.font-heading-4{font-size:18px}.font-heading-5{font-size:15px}.font-heading-6{font-size:13px}.font-heading-label{font-size:11px;font-family:NHaasGroteskDSPro-65Md,sans-serif;letter-spacing:.25px}.font-caption,.font-bodyXSmall,.font-bodySmall,.font-bodyMedium,.font-bodyLarge{font-family:HelveticaNeue,helvetica,sans-serif;line-height:1.5}.font-bodyXSmallStrong,:host,.font-bodySmallStrong,.font-bodyMediumStrong,.font-bodyLargeStrong{font-family:HelveticaNeue-Medium,helvetica,sans-serif;line-height:1.5}.font-bodyLarge,.font-bodyLargeStrong{font-size:16px}.font-bodyMedium,.font-bodyMediumStrong{font-size:14px}.font-bodySmall{font-size:13px;letter-spacing:.24px}:host,.font-bodySmallStrong{font-size:13px;letter-spacing:.24px}.font-bodyXSmall,.font-bodyXSmallStrong{font-size:12px;letter-spacing:.24px}.font-caption{font-size:11px}@keyframes rotation{0%{transform:rotate(0)}to{transform:rotate(359deg)}}@keyframes shineAnimation{0%{background-position:-750px 0}to{background-position:750px 0}}:host.fu-tooltip-right:after,:host.fu-tooltip-left:after{content:\"\";position:absolute;margin-top:-5px;border-width:5px;border-style:solid}:host.fu-tooltip-bottomleft:after,:host.fu-tooltip-bottomright:after,:host.fu-tooltip-topleft:after,:host.fu-tooltip-topright:after,:host.fu-tooltip-bottom:after,:host.fu-tooltip-top:after{content:\"\";position:absolute;margin-left:-5px;border-width:5px;border-style:solid}:host{box-sizing:border-box;position:fixed;width:-moz-fit-content;width:fit-content;color:#fff;border-radius:8px;line-height:19.5px;letter-spacing:.24px;display:flex;flex-direction:column;justify-content:center;align-items:center;padding:var(--fu-tooltip-padding, 8px 8px 7px);background-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D));z-index:3020;box-shadow:0 6px 6px -6px #00000029;filter:drop-shadow(0px 0px 1px rgba(0,0,0,.4))}:host.fu-tooltip-top:after{top:100%;left:50%;border-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent transparent}:host.fu-tooltip-bottom:after{bottom:100%;left:50%;border-color:transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent}:host.fu-tooltip-left:after{top:50%;left:100%;border-color:transparent transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D))}:host.fu-tooltip-right:after{top:50%;right:100%;border-color:transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent}:host.fu-tooltip-topright:after{top:100%;left:calc(100% - 20px);border-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent transparent}:host.fu-tooltip-topleft:after{top:100%;left:20px;border-color:var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent transparent transparent}:host.fu-tooltip-bottomright:after{bottom:100%;left:calc(100% - 20px);border-color:transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent}:host.fu-tooltip-bottomleft:after{bottom:100%;left:20px;border-color:transparent transparent var(--fu-tooltip-background-color, var(--fu-black-900, #41454D)) transparent}\n"] }]
    }], () => [{ type: i0.ElementRef }, { type: i0.Renderer2 }], { tooltipTextContent: [{
            type: Input
        }], templateRef: [{
            type: Input
        }], tooltipPositionClass: [{
            type: Input
        }], tooltipStyleConfiguration: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TooltipContentComponent, { className: "TooltipContentComponent", filePath: "tooltip.content.component.ts", lineNumber: 13 }); })();

class TooltipContentDirective {
    constructor(templateRef, viewContainerRef) {
        this.templateRef = templateRef;
        this.viewContainerRef = viewContainerRef;
    }
    get tooltipComponentRef() {
        return this.componentRef;
    }
    create() {
        if (!this.componentRef) {
            this.componentRef = this.viewContainerRef.createComponent(TooltipContentComponent);
            this.componentRef.instance.templateRef = this.templateRef;
        }
    }
    destroy() {
        this.componentRef.destroy();
        this.componentRef = null;
    }
    static { this.ɵfac = function TooltipContentDirective_Factory(t) { return new (t || TooltipContentDirective)(i0.ɵɵdirectiveInject(i0.TemplateRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef)); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TooltipContentDirective, selectors: [["", "fusionTooltipContent", ""]] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TooltipContentDirective, [{
        type: Directive,
        args: [{
                selector: `[fusionTooltipContent]`
            }]
    }], () => [{ type: i0.TemplateRef }, { type: i0.ViewContainerRef }], null); })();

const _c0$1 = ["tooltipTriggerElement"];
class TooltipDirective {
    set configuration(config) {
        if (config) {
            this.width = config?.width;
            this.height = config?.height;
            this.backgroundColor = config?.backgroundColor;
            this.preventTooltipToClose = config?.preventTooltipToClose;
        }
    }
    constructor(renderer, elementRef, vcr) {
        this.renderer = renderer;
        this.elementRef = elementRef;
        this.vcr = vcr;
        this.fusionTooltip = '';
        this.preventTooltipToClose = false;
        this.visible = false;
        this.onDestroy$ = new Subject();
        this.position = TooltipPosition.Top;
    }
    ngAfterViewInit() {
        this.viewContainerRef = this.viewTriggerContainer ? this.viewTriggerContainer : this.vcr;
        this.tooltipElement = this.preventTooltipToClose
            ? this.elementRef.nativeElement
            : !!this.tooltipTriggerElement?.nativeElement
                ? this.tooltipTriggerElement?.nativeElement
                : this.elementRef.nativeElement;
        this.initListeners();
    }
    ngOnDestroy() {
        this.onDestroy$.next();
        this.onDestroy$.complete();
    }
    initListeners() {
        fromEvent(this.tooltipElement, 'mouseenter').pipe(takeUntil(this.onDestroy$)).subscribe(this.showTooltip.bind(this));
        fromEvent(this.tooltipElement, 'mouseleave')
            .pipe(takeUntil(this.onDestroy$), switchMap((event) => {
            return this.haveToBeClosed(event);
        }))
            .subscribe(this.hideTooltip.bind(this));
    }
    showTooltip() {
        const needToShow = this.calcTruncate();
        if (!needToShow || this.visible) {
            return;
        }
        if (this.directiveRef && !this.fusionTooltip) {
            this.directiveRef.create();
            this.tooltipComponentRef = this.directiveRef.tooltipComponentRef;
        }
        else if (this.fusionTooltip) {
            this.tooltipComponentRef = this.viewContainerRef.createComponent(TooltipContentComponent);
            this.tooltipComponentRef.instance.tooltipTextContent = this.fusionTooltip;
        }
        else {
            return;
        }
        this.tooltipComponentRef.changeDetectorRef.detectChanges();
        const rectTooltip = this.tooltipComponentRef.instance.elementRef.nativeElement.getBoundingClientRect();
        this.setTooltipPosition(this.position, rectTooltip);
        this.setTooltipConfiguration();
        this.visible = true;
    }
    hideTooltip() {
        if (!this.visible) {
            return;
        }
        if (this.directiveRef && !this.fusionTooltip) {
            this.directiveRef.destroy();
            this.tooltipComponentRef = null;
        }
        else if (this.fusionTooltip) {
            this.tooltipComponentRef.destroy();
            this.tooltipComponentRef = null;
        }
        else {
            return;
        }
        this.visible = false;
    }
    adjustTooltipPosition(position, tooltipWidth, tooltipHeight, hostRect) {
        if (position === TooltipPosition.TopFixed) {
            return TooltipPosition.Top;
        }
        const isTopPosNegative = hostRect.top + this.elementRef.nativeElement.offsetHeight / 2 - tooltipHeight / 2 >= 0;
        if (window.innerWidth - tooltipWidth - hostRect.left <= 0 && isTopPosNegative) {
            position = TooltipPosition.Left;
        }
        else if (hostRect.left - tooltipWidth <= 0 && isTopPosNegative) {
            position = TooltipPosition.Right;
        }
        else if (hostRect.top - tooltipHeight <= 0) {
            position = hostRect.left - tooltipWidth <= 0 && isTopPosNegative ? TooltipPosition.Right : TooltipPosition.Bottom;
        }
        return position;
    }
    setTooltipPosition(position, tooltipElement) {
        let shiftPosition;
        const tooltipWidth = this.width || tooltipElement.width;
        const tooltipHeight = this.height || tooltipElement.height;
        const rect = this.elementRef.nativeElement.getBoundingClientRect();
        position = this.adjustTooltipPosition(position, tooltipWidth, tooltipHeight, rect);
        switch (position) {
            case TooltipPosition.Left:
                shiftPosition = { ...this.setPositionLeftRight('left', tooltipWidth, tooltipHeight) };
                break;
            case TooltipPosition.Right:
                shiftPosition = { ...this.setPositionLeftRight('right', tooltipWidth, tooltipHeight) };
                break;
            case TooltipPosition.Bottom:
                shiftPosition = { ...this.setPositionBottomTop('bottom', tooltipWidth, tooltipHeight) };
                break;
            default:
                shiftPosition = { ...this.setPositionBottomTop('top', tooltipWidth, tooltipHeight) };
                break;
        }
        const { tooltipLeft, pos } = this.adjustArrowPos(shiftPosition.left, rect.left, position, tooltipWidth);
        this.tooltipPosition = {
            position: pos,
            left: tooltipLeft,
            top: shiftPosition.top + rect.top
        };
    }
    setTooltipConfiguration() {
        this.tooltipComponentRef.instance.tooltipStyleConfiguration = {
            top: this.tooltipPosition.top.toString() + 'px',
            left: this.tooltipPosition.left.toString() + 'px',
            width: this.width?.toString() + 'px',
            height: this.height?.toString() + 'px',
            backgroundColor: this.backgroundColor
        };
        this.tooltipComponentRef.instance.tooltipPositionClass = this.tooltipPosition.position;
    }
    setPositionLeftRight(pos, tooltipWidth, tooltipHeight) {
        const position = {
            top: this.elementRef.nativeElement.offsetHeight / 2 - tooltipHeight / 2,
            left: 0
        };
        if (pos === 'left') {
            position.left = 0 - tooltipWidth - 6;
        }
        else {
            position.left = this.elementRef.nativeElement.offsetWidth + 6;
        }
        return position;
    }
    setPositionBottomTop(pos, tooltipWidth, tooltipHeight) {
        const position = {
            top: 0,
            left: this.elementRef.nativeElement.offsetWidth / 2 - tooltipWidth / 2
        };
        if (pos === 'bottom') {
            position.top = this.elementRef.nativeElement.offsetHeight + 6;
        }
        else {
            position.top = 0 - tooltipHeight - 6;
        }
        return position;
    }
    calcTruncate() {
        const nativeElement = this.elementRef.nativeElement;
        return !(nativeElement.className.includes('truncate') && nativeElement.clientWidth >= nativeElement.scrollWidth);
    }
    adjustArrowPos(tooltipLeft, rectLeft, position, tooltipWidth) {
        let posLeft = tooltipLeft + rectLeft;
        let newPosition = position;
        if (posLeft < 0 && (position === TooltipPosition.Top || position === TooltipPosition.Bottom)) {
            newPosition = position === TooltipPosition.Top ? TooltipPosition.TopLeft : TooltipPosition.BottomLeft;
            posLeft = rectLeft + this.elementRef.nativeElement.offsetWidth / 2 - 20;
        }
        else if (window.innerWidth - Math.round(rectLeft + this.elementRef.nativeElement.offsetWidth) <= 0 &&
            (position === TooltipPosition.Top || position === TooltipPosition.Bottom)) {
            newPosition = position === TooltipPosition.Top ? TooltipPosition.TopRight : TooltipPosition.BottomRight;
            posLeft = rectLeft + this.elementRef.nativeElement.offsetWidth / 2 - tooltipWidth + 20;
        }
        return { tooltipLeft: posLeft, pos: newPosition };
    }
    haveToBeClosed(event) {
        const marginSize = 10;
        let haveToBeClosed = true;
        const tooltipEl = this.elementRef.nativeElement.querySelector('fusion-tooltip-content');
        if (this.preventTooltipToClose && this.visible && !!tooltipEl) {
            const rectTooltip = tooltipEl.getBoundingClientRect();
            haveToBeClosed = !(event.x >= rectTooltip.left - marginSize &&
                event.x <= rectTooltip.right + marginSize &&
                event.y >= rectTooltip.top - marginSize &&
                event.y <= rectTooltip.bottom + marginSize);
        }
        return haveToBeClosed ? of(event) : fromEvent(tooltipEl, 'mouseleave');
    }
    static { this.ɵfac = function TooltipDirective_Factory(t) { return new (t || TooltipDirective)(i0.ɵɵdirectiveInject(i0.Renderer2), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.ViewContainerRef)); }; }
    static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: TooltipDirective, selectors: [["", "fusionTooltip", ""]], contentQueries: function TooltipDirective_ContentQueries(rf, ctx, dirIndex) { if (rf & 1) {
            i0.ɵɵcontentQuery(dirIndex, TooltipContentDirective, 7);
            i0.ɵɵcontentQuery(dirIndex, _c0$1, 7);
            i0.ɵɵcontentQuery(dirIndex, _c0$1, 7, ViewContainerRef);
        } if (rf & 2) {
            let _t;
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.directiveRef = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.tooltipTriggerElement = _t.first);
            i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.viewTriggerContainer = _t.first);
        } }, inputs: { fusionTooltip: "fusionTooltip", configuration: "configuration" } }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TooltipDirective, [{
        type: Directive,
        args: [{ selector: '[fusionTooltip]' }]
    }], () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i0.ViewContainerRef }], { directiveRef: [{
            type: ContentChild,
            args: [TooltipContentDirective, { static: true }]
        }], tooltipTriggerElement: [{
            type: ContentChild,
            args: ['tooltipTriggerElement', { static: true }]
        }], viewTriggerContainer: [{
            type: ContentChild,
            args: ['tooltipTriggerElement', { static: true, read: ViewContainerRef }]
        }], fusionTooltip: [{
            type: Input
        }], configuration: [{
            type: Input
        }] }); })();

function TooltipComponent_div_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div");
    i0.ɵɵprojection(1, 1);
    i0.ɵɵelementEnd();
} }
const _c0 = [[["", 8, "fusiontooltiptrigger"]], [["", 8, "fusiontooltipcontent"]]];
const _c1 = [".fusionTooltipTrigger", ".fusionTooltipContent"];
class TooltipComponent {
    constructor() {
        /** @internal */
        this.tooltipText = '';
    }
    /** @internal */
    set fusionTooltipText(value) {
        this.tooltipText = value;
    }
    /** @internal */
    set tooltipConfiguration(value) {
        this.tooltipConfig = { ...value };
    }
    static { this.ɵfac = function TooltipComponent_Factory(t) { return new (t || TooltipComponent)(); }; }
    static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: TooltipComponent, selectors: [["fusion-tooltip"]], inputs: { fusionTooltipText: "fusionTooltipText", tooltipConfiguration: "tooltipConfiguration" }, ngContentSelectors: _c1, decls: 5, vars: 2, consts: [[1, "tooltip-container", 3, "fusionTooltip", "configuration"], ["tooltipTriggerElement", ""], [4, "fusionTooltipContent"]], template: function TooltipComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵprojectionDef(_c0);
            i0.ɵɵelementStart(0, "div", 0)(1, "div", null, 1);
            i0.ɵɵprojection(3);
            i0.ɵɵelementEnd();
            i0.ɵɵtemplate(4, TooltipComponent_div_4_Template, 2, 0, "div", 2);
            i0.ɵɵelementEnd();
        } if (rf & 2) {
            i0.ɵɵproperty("fusionTooltip", ctx.tooltipText)("configuration", ctx.tooltipConfig);
        } }, dependencies: [TooltipDirective, TooltipContentDirective], styles: [".tooltip-container[_ngcontent-%COMP%]{display:inline-block;position:relative}"], changeDetection: 0 }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TooltipComponent, [{
        type: Component,
        args: [{ selector: 'fusion-tooltip', template: `
        <div class="tooltip-container" [fusionTooltip]="tooltipText" [configuration]="tooltipConfig">
            <div #tooltipTriggerElement>
                <ng-content select=".fusionTooltipTrigger"></ng-content>
            </div>
            <div *fusionTooltipContent>
                <ng-content select=".fusionTooltipContent"></ng-content>
            </div>
        </div>
    `, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".tooltip-container{display:inline-block;position:relative}\n"] }]
    }], null, { fusionTooltipText: [{
            type: Input
        }], tooltipConfiguration: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(TooltipComponent, { className: "TooltipComponent", filePath: "tooltip.component.ts", lineNumber: 26 }); })();

class TooltipModule {
    static { this.ɵfac = function TooltipModule_Factory(t) { return new (t || TooltipModule)(); }; }
    static { this.ɵmod = /*@__PURE__*/ i0.ɵɵdefineNgModule({ type: TooltipModule }); }
    static { this.ɵinj = /*@__PURE__*/ i0.ɵɵdefineInjector({ imports: [CommonModule] }); }
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(TooltipModule, [{
        type: NgModule,
        args: [{
                declarations: [TooltipDirective, TooltipContentDirective, TooltipContentComponent, TooltipComponent],
                exports: [TooltipDirective, TooltipContentDirective, TooltipContentComponent, TooltipComponent],
                imports: [CommonModule]
            }]
    }], null, null); })();
(function () { (typeof ngJitMode === "undefined" || ngJitMode) && i0.ɵɵsetNgModuleScope(TooltipModule, { declarations: [TooltipDirective, TooltipContentDirective, TooltipContentComponent, TooltipComponent], imports: [CommonModule], exports: [TooltipDirective, TooltipContentDirective, TooltipContentComponent, TooltipComponent] }); })();

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

export { TooltipComponent, TooltipContentComponent, TooltipContentDirective, TooltipDirective, TooltipModule };
//# sourceMappingURL=ironsource-fusion-ui-components-tooltip-v3.mjs.map
