import { FocusMonitor } from '@angular/cdk/a11y';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { Overlay } from '@angular/cdk/overlay';
import { NgClass, NgTemplateOutlet } from '@angular/common';
import * as i0 from '@angular/core';
import { InjectionToken, Component, ViewEncapsulation, ChangeDetectionStrategy, Inject, ViewChild, inject, EventEmitter, booleanAttribute, numberAttribute, Directive, Input, Output, NgModule } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { KbqPopUp, applyPopupMargins, KbqPopUpTrigger, KBQ_PARENT_POPUP, PopUpTriggers, KbqComponentColors, POSITION_TO_CSS_MAP, PopUpPlacements } from '@koobiq/components/core';
import { merge, EMPTY } from 'rxjs';
import { trigger, state, style, transition, animate, keyframes } from '@angular/animations';

/**
 * Animations used by KbqTooltip.
 * @docs-private
 */
const kbqTooltipAnimations = {
    /** Animation that transitions a tooltip in and out. */
    tooltipState: trigger('state', [
        state('initial, void, hidden', style({ opacity: 0, transform: 'scale(0)' })),
        state('visible', style({ transform: 'scale(0.99)' })),
        transition('* => visible', animate('200ms cubic-bezier(0, 0, 0.2, 1)', keyframes([
            style({ opacity: 0, transform: 'scale(0)', offset: 0 }),
            style({ opacity: 0.5, transform: 'scale(0.9)', offset: 0.5 }),
            style({ opacity: 1, transform: 'scale(0.99)', offset: 1 })
        ]))),
        transition('* => hidden', animate('100ms cubic-bezier(0, 0, 0.2, 1)', style({ opacity: 0 })))
    ])
};

var TooltipModifier;
(function (TooltipModifier) {
    TooltipModifier["Default"] = "default";
    TooltipModifier["Warning"] = "warning";
    TooltipModifier["Extended"] = "extended";
})(TooltipModifier || (TooltipModifier = {}));
const KBQ_TOOLTIP_OPEN_TIME = new InjectionToken('kbq-tooltip-open-time');
/** @docs-private */
const KBQ_TOOLTIP_OPEN_TIME_PROVIDER = {
    provide: KBQ_TOOLTIP_OPEN_TIME,
    useValue: { value: 0 }
};
const MIN_TIME_FOR_DELAY = 2000;
class KbqTooltipComponent extends KbqPopUp {
    constructor(openTime) {
        super();
        this.openTime = openTime;
        this.prefix = 'kbq-tooltip';
    }
    show(delay) {
        if (!this.content) {
            return;
        }
        super.show(Date.now() - this.openTime.value < MIN_TIME_FOR_DELAY ? 0 : delay);
        if (this.offset !== null) {
            applyPopupMargins(this.renderer, this.elementRef.nativeElement, this.prefix, `${this.offset.toString()}px`);
        }
        this.openTime.value = Date.now();
    }
    updateClassMap(placement, customClass, { modifier }) {
        const classMap = {
            [`${this.prefix}_${modifier}`]: true
        };
        super.updateClassMap(placement, customClass, classMap);
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqTooltipComponent, deps: [{ token: KBQ_TOOLTIP_OPEN_TIME }], target: i0.ɵɵFactoryTarget.Component }); }
    /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: KbqTooltipComponent, isStandalone: true, selector: "kbq-tooltip-component", providers: [KBQ_TOOLTIP_OPEN_TIME_PROVIDER], viewQueries: [{ propertyName: "elementRef", first: true, predicate: ["tooltip"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<div\n    #tooltip\n    class=\"kbq-tooltip\"\n    [class.kbq-tooltip_arrowless]=\"!arrow\"\n    [ngClass]=\"classMap\"\n    [@state]=\"visibility\"\n    (@state.done)=\"animationDone($event)\"\n    (@state.start)=\"animationStart()\"\n>\n    <div class=\"kbq-tooltip__inner\">\n        @if (arrow) {\n            <div class=\"kbq-tooltip__arrow\"></div>\n        }\n\n        @if (header) {\n            <div class=\"kbq-tooltip__header\">\n                @if (isTemplateRef(header)) {\n                    <ng-container [ngTemplateOutlet]=\"$any(header)\" [ngTemplateOutletContext]=\"context\" />\n                }\n                @if (!isTemplateRef(header)) {\n                    <div>{{ header }}</div>\n                }\n            </div>\n        }\n        <div class=\"kbq-tooltip__content\">\n            @if (isTemplateRef(content)) {\n                <ng-container [ngTemplateOutlet]=\"$any(content)\" [ngTemplateOutletContext]=\"context\" />\n            }\n            @if (!isTemplateRef(content)) {\n                <div>{{ content }}</div>\n            }\n        </div>\n    </div>\n</div>\n", styles: [".kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-top),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-top-left),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-top-right){margin-bottom:9px}.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-right),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-right-top),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-right-bottom){margin-left:9px}.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-bottom),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-bottom-left),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-bottom-right){margin-top:9px}.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-left),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-left-top),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-left-bottom){margin-right:9px}.kbq-tooltip__inner{border-radius:var(--kbq-tooltip-size-border-radius);word-break:break-word}.kbq-tooltip{box-sizing:border-box;border-radius:var(--kbq-tooltip-size-border-radius);white-space:pre-line;max-width:var(--kbq-tooltip-size-max-width)}.kbq-tooltip.kbq-tooltip_placement-top,.kbq-tooltip.kbq-tooltip_placement-top-left,.kbq-tooltip.kbq-tooltip_placement-top-right{margin-bottom:8px}.kbq-tooltip.kbq-tooltip_placement-right,.kbq-tooltip.kbq-tooltip_placement-right-top,.kbq-tooltip.kbq-tooltip_placement-right-bottom{margin-left:8px}.kbq-tooltip.kbq-tooltip_placement-bottom,.kbq-tooltip.kbq-tooltip_placement-bottom-left,.kbq-tooltip.kbq-tooltip_placement-bottom-right{margin-top:8px}.kbq-tooltip.kbq-tooltip_placement-left,.kbq-tooltip.kbq-tooltip_placement-left-top,.kbq-tooltip.kbq-tooltip_placement-left-bottom{margin-right:8px}.kbq-tooltip .kbq-tooltip__inner{padding:var(--kbq-tooltip-size-padding-vertical) var(--kbq-tooltip-size-padding-horizontal)}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-top,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-top-left,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-top-right{margin-bottom:4px}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-right,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-right-top,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-right-bottom{margin-left:4px}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-bottom,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-bottom-left,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-bottom-right{margin-top:4px}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-left,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-left-top,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-left-bottom{margin-right:4px}.kbq-tooltip,.kbq-tooltip__arrow{box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-theme .kbq-tooltip__inner{color:var(--kbq-tooltip-theme-fade-off-text);background-color:var(--kbq-tooltip-theme-fade-off-background)}.kbq-tooltip.kbq-theme .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-theme-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-theme.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-theme-fade-off-shadow)}.kbq-tooltip.kbq-contrast .kbq-tooltip__inner{color:var(--kbq-tooltip-contrast-fade-off-text);background-color:var(--kbq-tooltip-contrast-fade-off-background)}.kbq-tooltip.kbq-contrast .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-contrast-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-contrast.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-contrast-fade-off-shadow)}.kbq-tooltip.kbq-contrast-fade .kbq-tooltip__inner{color:var(--kbq-tooltip-contrast-fade-on-text);background-color:var(--kbq-tooltip-contrast-fade-on-background)}.kbq-tooltip.kbq-contrast-fade .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-contrast-fade-on-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-contrast-fade.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-contrast-fade-on-shadow)}.kbq-tooltip.kbq-warning .kbq-tooltip__inner{color:var(--kbq-tooltip-warning-fade-off-text);background-color:var(--kbq-tooltip-warning-fade-off-background)}.kbq-tooltip.kbq-warning .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-warning-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-warning.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-warning-fade-off-shadow)}.kbq-tooltip.kbq-error .kbq-tooltip__inner{color:var(--kbq-tooltip-error-fade-off-text);background-color:var(--kbq-tooltip-error-fade-off-background)}.kbq-tooltip.kbq-error .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-error-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-error.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-error-fade-off-shadow)}.kbq-tooltip,.kbq-tooltip .kbq-tooltip__header{font-size:var(--kbq-typography-text-compact-font-size);font-style:var(--kbq-typography-text-compact-font-style);font-weight:var(--kbq-typography-text-compact-font-weight);line-height:var(--kbq-typography-text-compact-line-height);font-family:var(--kbq-typography-text-compact-font-family);text-transform:var(--kbq-typography-text-compact-text-transform);font-feature-settings:var(--kbq-typography-text-compact-font-feature-settings);letter-spacing:var(--kbq-typography-text-compact-letter-spacing)}.kbq-tooltip__arrow{position:absolute;width:var(--kbq-tooltip-size-arrow-size);height:var(--kbq-tooltip-size-arrow-size);transform:rotate(45deg);z-index:-1}.kbq-tooltip_placement-top .kbq-tooltip__arrow{bottom:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:50%;margin-left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-top-left .kbq-tooltip__arrow{bottom:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:13px}.kbq-tooltip_placement-top-right .kbq-tooltip__arrow{bottom:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);right:13px}.kbq-tooltip_placement-right .kbq-tooltip__arrow{left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:50%;margin-top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-right-top .kbq-tooltip__arrow{left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:13px}.kbq-tooltip_placement-right-bottom .kbq-tooltip__arrow{left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);bottom:13px}.kbq-tooltip_placement-left .kbq-tooltip__arrow{right:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:50%;margin-top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-left-top .kbq-tooltip__arrow{right:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:13px}.kbq-tooltip_placement-left-bottom .kbq-tooltip__arrow{right:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);bottom:13px}.kbq-tooltip_placement-bottom .kbq-tooltip__arrow{top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:50%;margin-left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-bottom-left .kbq-tooltip__arrow{top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:13px}.kbq-tooltip_placement-bottom-right .kbq-tooltip__arrow{top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);right:13px}\n", ".kbq-tooltip{--kbq-tooltip-size-max-width: 300px;--kbq-tooltip-size-border-radius: var(--kbq-size-s);--kbq-tooltip-size-padding-horizontal: var(--kbq-size-m);--kbq-tooltip-size-padding-vertical: var(--kbq-size-s);--kbq-tooltip-size-arrow-size: var(--kbq-size-m);--kbq-tooltip-contrast-fade-on-background: var(--kbq-background-card);--kbq-tooltip-contrast-fade-on-text: var(--kbq-foreground-contrast);--kbq-tooltip-contrast-fade-on-shadow: var(--kbq-shadow-popup);--kbq-tooltip-contrast-fade-off-background: var(--kbq-background-night);--kbq-tooltip-contrast-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-contrast-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-theme-fade-off-background: var(--kbq-background-theme);--kbq-tooltip-theme-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-theme-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-warning-fade-off-background: var(--kbq-background-warning);--kbq-tooltip-warning-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-warning-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-error-fade-off-background: var(--kbq-background-error);--kbq-tooltip-error-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-error-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-borderless-shadow: 0 2px 8px var(--kbq-shadow-key), 0 3px 8px var(--kbq-shadow-ambient)}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], animations: [kbqTooltipAnimations.tooltipState], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqTooltipComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [
                        NgClass,
                        NgTemplateOutlet
                    ], selector: 'kbq-tooltip-component', animations: [kbqTooltipAnimations.tooltipState], encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [KBQ_TOOLTIP_OPEN_TIME_PROVIDER], template: "<div\n    #tooltip\n    class=\"kbq-tooltip\"\n    [class.kbq-tooltip_arrowless]=\"!arrow\"\n    [ngClass]=\"classMap\"\n    [@state]=\"visibility\"\n    (@state.done)=\"animationDone($event)\"\n    (@state.start)=\"animationStart()\"\n>\n    <div class=\"kbq-tooltip__inner\">\n        @if (arrow) {\n            <div class=\"kbq-tooltip__arrow\"></div>\n        }\n\n        @if (header) {\n            <div class=\"kbq-tooltip__header\">\n                @if (isTemplateRef(header)) {\n                    <ng-container [ngTemplateOutlet]=\"$any(header)\" [ngTemplateOutletContext]=\"context\" />\n                }\n                @if (!isTemplateRef(header)) {\n                    <div>{{ header }}</div>\n                }\n            </div>\n        }\n        <div class=\"kbq-tooltip__content\">\n            @if (isTemplateRef(content)) {\n                <ng-container [ngTemplateOutlet]=\"$any(content)\" [ngTemplateOutletContext]=\"context\" />\n            }\n            @if (!isTemplateRef(content)) {\n                <div>{{ content }}</div>\n            }\n        </div>\n    </div>\n</div>\n", styles: [".kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-top),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-top-left),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-top-right){margin-bottom:9px}.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-right),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-right-top),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-right-bottom){margin-left:9px}.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-bottom),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-bottom-left),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-bottom-right){margin-top:9px}.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-left),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-left-top),.kbq-tooltip-panel_horizontal-navbar:has(.kbq-tooltip_placement-left-bottom){margin-right:9px}.kbq-tooltip__inner{border-radius:var(--kbq-tooltip-size-border-radius);word-break:break-word}.kbq-tooltip{box-sizing:border-box;border-radius:var(--kbq-tooltip-size-border-radius);white-space:pre-line;max-width:var(--kbq-tooltip-size-max-width)}.kbq-tooltip.kbq-tooltip_placement-top,.kbq-tooltip.kbq-tooltip_placement-top-left,.kbq-tooltip.kbq-tooltip_placement-top-right{margin-bottom:8px}.kbq-tooltip.kbq-tooltip_placement-right,.kbq-tooltip.kbq-tooltip_placement-right-top,.kbq-tooltip.kbq-tooltip_placement-right-bottom{margin-left:8px}.kbq-tooltip.kbq-tooltip_placement-bottom,.kbq-tooltip.kbq-tooltip_placement-bottom-left,.kbq-tooltip.kbq-tooltip_placement-bottom-right{margin-top:8px}.kbq-tooltip.kbq-tooltip_placement-left,.kbq-tooltip.kbq-tooltip_placement-left-top,.kbq-tooltip.kbq-tooltip_placement-left-bottom{margin-right:8px}.kbq-tooltip .kbq-tooltip__inner{padding:var(--kbq-tooltip-size-padding-vertical) var(--kbq-tooltip-size-padding-horizontal)}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-top,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-top-left,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-top-right{margin-bottom:4px}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-right,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-right-top,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-right-bottom{margin-left:4px}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-bottom,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-bottom-left,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-bottom-right{margin-top:4px}.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-left,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-left-top,.kbq-tooltip.kbq-tooltip_arrowless.kbq-tooltip_placement-left-bottom{margin-right:4px}.kbq-tooltip,.kbq-tooltip__arrow{box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-theme .kbq-tooltip__inner{color:var(--kbq-tooltip-theme-fade-off-text);background-color:var(--kbq-tooltip-theme-fade-off-background)}.kbq-tooltip.kbq-theme .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-theme-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-theme.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-theme-fade-off-shadow)}.kbq-tooltip.kbq-contrast .kbq-tooltip__inner{color:var(--kbq-tooltip-contrast-fade-off-text);background-color:var(--kbq-tooltip-contrast-fade-off-background)}.kbq-tooltip.kbq-contrast .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-contrast-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-contrast.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-contrast-fade-off-shadow)}.kbq-tooltip.kbq-contrast-fade .kbq-tooltip__inner{color:var(--kbq-tooltip-contrast-fade-on-text);background-color:var(--kbq-tooltip-contrast-fade-on-background)}.kbq-tooltip.kbq-contrast-fade .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-contrast-fade-on-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-contrast-fade.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-contrast-fade-on-shadow)}.kbq-tooltip.kbq-warning .kbq-tooltip__inner{color:var(--kbq-tooltip-warning-fade-off-text);background-color:var(--kbq-tooltip-warning-fade-off-background)}.kbq-tooltip.kbq-warning .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-warning-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-warning.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-warning-fade-off-shadow)}.kbq-tooltip.kbq-error .kbq-tooltip__inner{color:var(--kbq-tooltip-error-fade-off-text);background-color:var(--kbq-tooltip-error-fade-off-background)}.kbq-tooltip.kbq-error .kbq-tooltip__arrow{background-color:var(--kbq-tooltip-error-fade-off-background);box-shadow:var(--kbq-tooltip-borderless-shadow)}.kbq-tooltip.kbq-error.kbq-tooltip_arrowless{box-shadow:var(--kbq-tooltip-error-fade-off-shadow)}.kbq-tooltip,.kbq-tooltip .kbq-tooltip__header{font-size:var(--kbq-typography-text-compact-font-size);font-style:var(--kbq-typography-text-compact-font-style);font-weight:var(--kbq-typography-text-compact-font-weight);line-height:var(--kbq-typography-text-compact-line-height);font-family:var(--kbq-typography-text-compact-font-family);text-transform:var(--kbq-typography-text-compact-text-transform);font-feature-settings:var(--kbq-typography-text-compact-font-feature-settings);letter-spacing:var(--kbq-typography-text-compact-letter-spacing)}.kbq-tooltip__arrow{position:absolute;width:var(--kbq-tooltip-size-arrow-size);height:var(--kbq-tooltip-size-arrow-size);transform:rotate(45deg);z-index:-1}.kbq-tooltip_placement-top .kbq-tooltip__arrow{bottom:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:50%;margin-left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-top-left .kbq-tooltip__arrow{bottom:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:13px}.kbq-tooltip_placement-top-right .kbq-tooltip__arrow{bottom:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);right:13px}.kbq-tooltip_placement-right .kbq-tooltip__arrow{left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:50%;margin-top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-right-top .kbq-tooltip__arrow{left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:13px}.kbq-tooltip_placement-right-bottom .kbq-tooltip__arrow{left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);bottom:13px}.kbq-tooltip_placement-left .kbq-tooltip__arrow{right:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:50%;margin-top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-left-top .kbq-tooltip__arrow{right:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);top:13px}.kbq-tooltip_placement-left-bottom .kbq-tooltip__arrow{right:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);bottom:13px}.kbq-tooltip_placement-bottom .kbq-tooltip__arrow{top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:50%;margin-left:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2)}.kbq-tooltip_placement-bottom-left .kbq-tooltip__arrow{top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);left:13px}.kbq-tooltip_placement-bottom-right .kbq-tooltip__arrow{top:calc((var(--kbq-tooltip-size-arrow-size) - 1px) / -2);right:13px}\n", ".kbq-tooltip{--kbq-tooltip-size-max-width: 300px;--kbq-tooltip-size-border-radius: var(--kbq-size-s);--kbq-tooltip-size-padding-horizontal: var(--kbq-size-m);--kbq-tooltip-size-padding-vertical: var(--kbq-size-s);--kbq-tooltip-size-arrow-size: var(--kbq-size-m);--kbq-tooltip-contrast-fade-on-background: var(--kbq-background-card);--kbq-tooltip-contrast-fade-on-text: var(--kbq-foreground-contrast);--kbq-tooltip-contrast-fade-on-shadow: var(--kbq-shadow-popup);--kbq-tooltip-contrast-fade-off-background: var(--kbq-background-night);--kbq-tooltip-contrast-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-contrast-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-theme-fade-off-background: var(--kbq-background-theme);--kbq-tooltip-theme-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-theme-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-warning-fade-off-background: var(--kbq-background-warning);--kbq-tooltip-warning-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-warning-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-error-fade-off-background: var(--kbq-background-error);--kbq-tooltip-error-fade-off-text: var(--kbq-foreground-white);--kbq-tooltip-error-fade-off-shadow: var(--kbq-shadow-popup);--kbq-tooltip-borderless-shadow: 0 2px 8px var(--kbq-shadow-key), 0 3px 8px var(--kbq-shadow-ambient)}\n"] }]
        }], ctorParameters: () => [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [KBQ_TOOLTIP_OPEN_TIME]
                }] }], propDecorators: { elementRef: [{
                type: ViewChild,
                args: ['tooltip']
            }] } });
const KBQ_TOOLTIP_SCROLL_STRATEGY = new InjectionToken('kbq-tooltip-scroll-strategy');
/** @docs-private */
function kbqTooltipScrollStrategyFactory(overlay) {
    return () => overlay.scrollStrategies.close();
}
/** @docs-private */
const KBQ_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER = {
    provide: KBQ_TOOLTIP_SCROLL_STRATEGY,
    deps: [Overlay],
    useFactory: kbqTooltipScrollStrategyFactory
};
class KbqTooltipTrigger extends KbqPopUpTrigger {
    constructor() {
        super(...arguments);
        this.scrollStrategy = inject(KBQ_TOOLTIP_SCROLL_STRATEGY);
        this.parentPopup = inject(KBQ_PARENT_POPUP, { optional: true });
        this.focusMonitor = inject(FocusMonitor);
        /**
         * Changes hiding behavior. By default, tooltip is hidden on mouseleave from trigger.
         * Setting hideWithTimeout to true will delay tooltip hiding and will not hide when the mouse moves from trigger
         * to tooltip.
         */
        this.hideWithTimeout = false;
        /**
         * Positions the tooltip relative to the mouse cursor. Only available for top and bottom kbqPlacement.
         * Does not work with kbqPlacementPriority.
         */
        this.relativeToPointer = false;
        this.enterDelay = 400;
        this.leaveDelay = 0;
        this._trigger = `${PopUpTriggers.Hover}, ${PopUpTriggers.Focus}`;
        this._context = null;
        this._color = KbqComponentColors.Contrast;
        this.arrow = true;
        this.offset = null;
        this.placementChange = new EventEmitter();
        this.visibleChange = new EventEmitter();
        this.originSelector = '.kbq-tooltip';
        this.overlayConfig = {
            panelClass: 'kbq-tooltip-panel'
        };
        this.modifier = TooltipModifier.Default;
    }
    get tooltipVisible() {
        return this.visible;
    }
    set tooltipVisible(value) {
        super.updateVisible(value);
    }
    get tooltipPlacement() {
        return this.placement;
    }
    set tooltipPlacement(value) {
        super.updatePlacement(value);
    }
    get tooltipPlacementPriority() {
        return this.placementPriority;
    }
    set tooltipPlacementPriority(value) {
        super.updatePlacementPriority(value);
    }
    get content() {
        return this._content;
    }
    set content(content) {
        this._content = content;
        this.updateData();
    }
    get disabled() {
        return this._disabled;
    }
    set disabled(value) {
        this._disabled = coerceBooleanProperty(value);
        if (this._disabled) {
            this.hide();
        }
    }
    get trigger() {
        return this._trigger;
    }
    set trigger(value) {
        if (value) {
            this._trigger = value;
        }
        else {
            this._trigger = `${PopUpTriggers.Hover}, ${PopUpTriggers.Focus}`;
        }
        this.initListeners();
    }
    get customClass() {
        return this._customClass || '';
    }
    set customClass(value) {
        if (value) {
            this._customClass = value;
            this.updateClassMap();
        }
        else {
            this._customClass = '';
        }
    }
    get context() {
        return this._context;
    }
    set context(ctx) {
        this._context = ctx;
        this.updateData();
    }
    get color() {
        return `kbq-${this._color}`;
    }
    set color(value) {
        this._color = value || KbqComponentColors.Contrast;
    }
    get hasClickInTrigger() {
        return this.trigger.includes(PopUpTriggers.Click);
    }
    ngAfterViewInit() {
        this.parentPopup?.closedStream.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.hide());
        this.focusMonitor.monitor(this.elementRef.nativeElement);
    }
    ngOnDestroy() {
        this.focusMonitor.stopMonitoring(this.elementRef.nativeElement);
        super.ngOnDestroy();
    }
    show(delay = this.enterDelay) {
        if (this.triggerName === 'focus' && this.focusMonitor['_lastFocusOrigin'] !== 'keyboard') {
            return;
        }
        super.show(delay);
        if (this.relativeToPointer) {
            this.applyRelativeToPointer();
        }
    }
    /**
     * method allows to show the tooltip relative to the element
     * Use this approach when it is not possible to define a trigger in the template.
     *
     * For example:
     * const tooltip = new KbqTooltipTrigger();
     * tooltip.showForElement(element);
     */
    showForElement(element) {
        this.show();
        this.strategy.setOrigin(element);
    }
    updateData() {
        if (!this.instance) {
            return;
        }
        this.instance.content = this.content;
        this.instance.context = this.context && { $implicit: this.context };
        this.instance.arrow = this.arrow;
        this.instance.offset = this.offset;
        this.instance.detectChanges();
        this.updatePosition(true);
    }
    closingActions() {
        return merge(this.hasClickInTrigger ? this.overlayRef.outsidePointerEvents() : EMPTY, this.overlayRef.detachments());
    }
    getOverlayHandleComponentType() {
        return KbqTooltipComponent;
    }
    updateClassMap(newPlacement = this.placement) {
        if (!this.instance) {
            return;
        }
        this.instance.updateClassMap(POSITION_TO_CSS_MAP[newPlacement], `${this.customClass} ${this.color}`, {
            modifier: this.modifier
        });
        this.instance.markForCheck();
    }
    applyRelativeToPointer() {
        if (!this.strategy ||
            ![PopUpPlacements.Top, PopUpPlacements.Bottom].includes(this.placement) ||
            this.triggerName !== 'mouseenter') {
            this.resetOrigin();
            return;
        }
        const triggerRects = this.elementRef.nativeElement.getBoundingClientRect();
        const point = { x: 0, y: 0 };
        this.placementPriority = null;
        if (this.placement === PopUpPlacements.Top) {
            point.x = this.mouseEvent.x;
            point.y = triggerRects.y;
        }
        else if (this.placement === PopUpPlacements.Bottom) {
            point.x = this.mouseEvent.x;
            point.y = triggerRects.y + triggerRects.height;
        }
        this.strategy.setOrigin(point);
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqTooltipTrigger, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
    /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "18.2.14", type: KbqTooltipTrigger, isStandalone: true, selector: "[kbqTooltip]", inputs: { hideWithTimeout: ["hideWithTimeout", "hideWithTimeout", booleanAttribute], tooltipVisible: ["kbqVisible", "tooltipVisible"], tooltipPlacement: ["kbqPlacement", "tooltipPlacement"], relativeToPointer: ["kbqRelativeToPointer", "relativeToPointer", booleanAttribute], tooltipPlacementPriority: ["kbqPlacementPriority", "tooltipPlacementPriority"], content: ["kbqTooltip", "content"], disabled: ["kbqTooltipDisabled", "disabled"], enterDelay: ["kbqEnterDelay", "enterDelay"], leaveDelay: ["kbqLeaveDelay", "leaveDelay"], trigger: ["kbqTrigger", "trigger"], customClass: ["kbqTooltipClass", "customClass"], context: ["kbqTooltipContext", "context"], color: ["kbqTooltipColor", "color"], arrow: ["kbqTooltipArrow", "arrow", booleanAttribute], offset: ["kbqTooltipOffset", "offset", numberAttribute] }, outputs: { placementChange: "kbqPlacementChange", visibleChange: "kbqVisibleChange" }, host: { listeners: { "keydown": "keydownHandler($event)", "touchend": "touchendHandler()" }, properties: { "class.kbq-tooltip_open": "isOpen" } }, exportAs: ["kbqTooltip"], usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqTooltipTrigger, decorators: [{
            type: Directive,
            args: [{
                    standalone: true,
                    selector: '[kbqTooltip]',
                    exportAs: 'kbqTooltip',
                    host: {
                        '[class.kbq-tooltip_open]': 'isOpen',
                        '(keydown)': 'keydownHandler($event)',
                        '(touchend)': 'touchendHandler()'
                    }
                }]
        }], propDecorators: { hideWithTimeout: [{
                type: Input,
                args: [{ transform: booleanAttribute }]
            }], tooltipVisible: [{
                type: Input,
                args: ['kbqVisible']
            }], tooltipPlacement: [{
                type: Input,
                args: ['kbqPlacement']
            }], relativeToPointer: [{
                type: Input,
                args: [{ alias: 'kbqRelativeToPointer', transform: booleanAttribute }]
            }], tooltipPlacementPriority: [{
                type: Input,
                args: ['kbqPlacementPriority']
            }], content: [{
                type: Input,
                args: ['kbqTooltip']
            }], disabled: [{
                type: Input,
                args: ['kbqTooltipDisabled']
            }], enterDelay: [{
                type: Input,
                args: ['kbqEnterDelay']
            }], leaveDelay: [{
                type: Input,
                args: ['kbqLeaveDelay']
            }], trigger: [{
                type: Input,
                args: ['kbqTrigger']
            }], customClass: [{
                type: Input,
                args: ['kbqTooltipClass']
            }], context: [{
                type: Input,
                args: ['kbqTooltipContext']
            }], color: [{
                type: Input,
                args: ['kbqTooltipColor']
            }], arrow: [{
                type: Input,
                args: [{ alias: 'kbqTooltipArrow', transform: booleanAttribute }]
            }], offset: [{
                type: Input,
                args: [{ alias: 'kbqTooltipOffset', transform: numberAttribute }]
            }], placementChange: [{
                type: Output,
                args: ['kbqPlacementChange']
            }], visibleChange: [{
                type: Output,
                args: ['kbqVisibleChange']
            }] } });
class KbqWarningTooltipTrigger extends KbqTooltipTrigger {
    constructor() {
        super(...arguments);
        this.modifier = TooltipModifier.Warning;
    }
    get content() {
        return this._content;
    }
    set content(content) {
        this._content = content;
        this.updateData();
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqWarningTooltipTrigger, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
    /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: KbqWarningTooltipTrigger, isStandalone: true, selector: "[kbqWarningTooltip]", inputs: { content: ["kbqWarningTooltip", "content"] }, host: { listeners: { "keydown": "keydownHandler($event)", "touchend": "touchendHandler()" }, properties: { "class.kbq-tooltip_open": "isOpen" } }, exportAs: ["kbqWarningTooltip"], usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqWarningTooltipTrigger, decorators: [{
            type: Directive,
            args: [{
                    standalone: true,
                    selector: '[kbqWarningTooltip]',
                    exportAs: 'kbqWarningTooltip',
                    host: {
                        '[class.kbq-tooltip_open]': 'isOpen',
                        '(keydown)': 'keydownHandler($event)',
                        '(touchend)': 'touchendHandler()'
                    }
                }]
        }], propDecorators: { content: [{
                type: Input,
                args: ['kbqWarningTooltip']
            }] } });
class KbqExtendedTooltipTrigger extends KbqTooltipTrigger {
    constructor() {
        super(...arguments);
        this.modifier = TooltipModifier.Extended;
    }
    get content() {
        return this._content;
    }
    set content(content) {
        this._content = content;
        this.updateData();
    }
    get header() {
        return this._header;
    }
    set header(header) {
        this._header = header;
        this.updateData();
    }
    updateData() {
        if (!this.instance) {
            return;
        }
        super.updateData();
        this.instance.header = this.header;
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqExtendedTooltipTrigger, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
    /** @nocollapse */ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.14", type: KbqExtendedTooltipTrigger, isStandalone: true, selector: "[kbqExtendedTooltip]", inputs: { content: ["kbqExtendedTooltip", "content"], header: ["kbqTooltipHeader", "header"] }, host: { listeners: { "keydown": "keydownHandler($event)", "touchend": "touchendHandler()" }, properties: { "class.kbq-tooltip_open": "isOpen" } }, exportAs: ["kbqExtendedTooltip"], usesInheritance: true, ngImport: i0 }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqExtendedTooltipTrigger, decorators: [{
            type: Directive,
            args: [{
                    standalone: true,
                    selector: '[kbqExtendedTooltip]',
                    exportAs: 'kbqExtendedTooltip',
                    host: {
                        '[class.kbq-tooltip_open]': 'isOpen',
                        '(keydown)': 'keydownHandler($event)',
                        '(touchend)': 'touchendHandler()'
                    }
                }]
        }], propDecorators: { content: [{
                type: Input,
                args: ['kbqExtendedTooltip']
            }], header: [{
                type: Input,
                args: ['kbqTooltipHeader']
            }] } });

const COMPONENTS = [
    KbqTooltipComponent,
    KbqTooltipTrigger,
    KbqExtendedTooltipTrigger,
    KbqWarningTooltipTrigger
];
class KbqToolTipModule {
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqToolTipModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.14", ngImport: i0, type: KbqToolTipModule, imports: [KbqTooltipComponent,
            KbqTooltipTrigger,
            KbqExtendedTooltipTrigger,
            KbqWarningTooltipTrigger], exports: [KbqTooltipComponent,
            KbqTooltipTrigger,
            KbqExtendedTooltipTrigger,
            KbqWarningTooltipTrigger] }); }
    /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqToolTipModule, providers: [
            KBQ_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER,
            KBQ_TOOLTIP_OPEN_TIME_PROVIDER
        ] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqToolTipModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: COMPONENTS,
                    exports: COMPONENTS,
                    providers: [
                        KBQ_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER,
                        KBQ_TOOLTIP_OPEN_TIME_PROVIDER
                    ]
                }]
        }] });

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

export { KBQ_TOOLTIP_OPEN_TIME, KBQ_TOOLTIP_OPEN_TIME_PROVIDER, KBQ_TOOLTIP_SCROLL_STRATEGY, KBQ_TOOLTIP_SCROLL_STRATEGY_FACTORY_PROVIDER, KbqExtendedTooltipTrigger, KbqToolTipModule, KbqTooltipComponent, KbqTooltipTrigger, KbqWarningTooltipTrigger, MIN_TIME_FOR_DELAY, TooltipModifier, kbqTooltipScrollStrategyFactory };
//# sourceMappingURL=koobiq-components-tooltip.mjs.map
