import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { ChangeDetectorRef, Component, ContentChild, inject, Input } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { kbqInjectNativeElement, PopUpPlacements, PopUpTriggers } from '@koobiq/components/core';
import { KbqTooltipTrigger } from '@koobiq/components/tooltip';
import { KbqNavbarFocusableItem, KbqNavbarRectangleElement, KbqNavbarTitle } from './navbar-item.component';
import * as i0 from "@angular/core";
export class KbqNavbarBrand extends KbqTooltipTrigger {
    get isLink() {
        return this.nativeElement.tagName === 'A';
    }
    /** @docs-private */
    get croppedText() {
        const croppedTitleText = this.title?.isOverflown ? this.titleText : '';
        return `${croppedTitleText}`;
    }
    /** @docs-private */
    get hasCroppedText() {
        return !!this.title?.isOverflown;
    }
    /** @docs-private */
    get titleText() {
        return this.collapsedText || this.title?.text || null;
    }
    /** @docs-private */
    get disabled() {
        if (this._disabled !== undefined) {
            return this._disabled;
        }
        return !this.collapsed && !this.hasCroppedText;
    }
    set disabled(value) {
        this._disabled = coerceBooleanProperty(value);
    }
    /** @docs-private */
    get collapsed() {
        return this._collapsed ?? this.rectangleElement.collapsed;
    }
    set collapsed(value) {
        if (this._collapsed !== value) {
            this._collapsed = value;
            this.updateTooltip();
        }
    }
    constructor() {
        super();
        /** @docs-private */
        this.nativeElement = kbqInjectNativeElement();
        /** @docs-private */
        this.changeDetectorRef = inject(ChangeDetectorRef);
        /** @docs-private */
        this.rectangleElement = inject(KbqNavbarRectangleElement);
        /** @docs-private */
        this.navbarFocusableItem = inject(KbqNavbarFocusableItem);
        /** alternative display of the brand name in two lines */
        this.longTitle = false;
        this._collapsed = false;
        this.rectangleElement.state.pipe(takeUntilDestroyed()).subscribe(() => {
            this.collapsed = this.rectangleElement.collapsed;
            this.changeDetectorRef.detectChanges();
        });
        this._trigger = `${PopUpTriggers.Hover}`;
        this.navbarFocusableItem.setTooltip(this);
        this.arrow = false;
        this.offset = 0;
        this.navbarFocusableItem.disabled = !this.isLink;
    }
    ngAfterContentInit() {
        this.updateTooltip();
    }
    updateTooltip() {
        if (this.collapsed) {
            this.content = `${this.titleText || ''}`;
        }
        else if (!this.collapsed && this.hasCroppedText) {
            this.content = this.croppedText;
        }
        if (this.rectangleElement.vertical) {
            this.placement = PopUpPlacements.Right;
        }
        this.changeDetectorRef.markForCheck();
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqNavbarBrand, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: KbqNavbarBrand, selector: "kbq-navbar-brand, [kbq-navbar-brand]", inputs: { longTitle: "longTitle", collapsedText: "collapsedText" }, host: { properties: { "class.kbq-navbar-brand_long-title": "longTitle", "class.kbq-navbar-brand_link": "isLink" }, classAttribute: "kbq-navbar-brand" }, queries: [{ propertyName: "title", first: true, predicate: KbqNavbarTitle, descendants: true }], exportAs: ["kbqNavbarBrand"], usesInheritance: true, ngImport: i0, template: `
        <ng-content />
    `, isInline: true, styles: ["button.kbq-navbar-item,button.kbq-navbar-brand{background:transparent;border:none}.kbq-navbar-logo{display:flex}.kbq-navbar-brand{position:relative;display:flex;border-radius:var(--kbq-size-s)}.kbq-navbar-brand:after{position:absolute;content:\"\";display:none;border-radius:var(--kbq-navbar-item-size-content-border-radius)}.kbq-navbar-brand .kbq-navbar-title{cursor:pointer}a.kbq-navbar-brand{text-decoration:none}.kbq-navbar-brand.kbq-horizontal{padding:var(--kbq-size-s) var(--kbq-size-xs) var(--kbq-size-s) var(--kbq-size-xxs);align-items:center;gap:var(--kbq-size-s)}.kbq-navbar-brand.kbq-horizontal:after{top:var(--kbq-size-xxs);right:var(--kbq-size-xxs);bottom:var(--kbq-size-xxs);left:0}.kbq-navbar-brand.kbq-horizontal .kbq-navbar-title{padding-right:var(--kbq-size-m)}.kbq-navbar-brand.kbq-vertical{flex-direction:row;align-items:center;padding:var(--kbq-size-xxs) var(--kbq-size-m) var(--kbq-size-m)}.kbq-navbar-brand.kbq-vertical:after{top:0;right:var(--kbq-size-s);bottom:var(--kbq-size-s);left:var(--kbq-size-s)}.kbq-navbar-brand.kbq-vertical .kbq-navbar-logo{align-items:center}.kbq-navbar-brand.kbq-vertical .kbq-navbar-title{display:block;align-items:center;padding-left:var(--kbq-size-s)}.kbq-navbar-brand.kbq-vertical.kbq-expanded .kbq-navbar-title{max-width:200px}.kbq-navbar-brand.kbq-vertical.kbq-collapsed .kbq-navbar-title{display:none!important}.kbq-navbar-brand.kbq-vertical.kbq-navbar-brand_long-title .kbq-navbar-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;white-space:normal}.kbq-navbar-brand:not(.kbq-navbar-item_has-nested):after{display:block;background:var(--kbq-navbar-item-default-content-background)}.kbq-navbar-brand .kbq-navbar-title{color:var(--kbq-navbar-item-default-content-text)}.kbq-navbar-brand>.kbq-icon.kbq-empty{color:var(--kbq-navbar-item-default-content-icon-left)!important}.kbq-navbar-brand .kbq-navbar-item__arrow-icon{color:var(--kbq-navbar-item-default-content-icon-right)!important}.kbq-navbar-brand.kbq-navbar-brand_link{cursor:pointer}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled):not(.kbq-navbar-item_has-nested):after{display:block;background:var(--kbq-navbar-item-states-hover-content-background)}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled) .kbq-navbar-title{color:var(--kbq-navbar-item-states-hover-content-text)}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled)>.kbq-icon.kbq-empty{color:var(--kbq-navbar-item-states-hover-content-icon-left)!important}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled) .kbq-navbar-item__arrow-icon{color:var(--kbq-navbar-item-states-hover-content-icon-right)!important}.kbq-navbar-brand.kbq-navbar-brand_link.cdk-focused.cdk-keyboard-focused{outline:none}.kbq-navbar-brand.kbq-navbar-brand_link.cdk-focused.cdk-keyboard-focused:after{display:block;box-shadow:inset 0 0 0 2px var(--kbq-states-line-focus-theme)}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand):not(.kbq-navbar-item_has-nested):after,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand):not(.kbq-navbar-item_has-nested):after{display:block;background:var(--kbq-navbar-item-states-selected-content-background)}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-title,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-title{color:var(--kbq-navbar-item-states-selected-content-text)}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand)>.kbq-icon.kbq-empty,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand)>.kbq-icon.kbq-empty{color:var(--kbq-navbar-item-states-selected-content-icon-left)!important}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-item__arrow-icon,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-item__arrow-icon{color:var(--kbq-navbar-item-states-selected-content-icon-right)!important}.kbq-navbar-brand.kbq-navbar-brand_link.kbq-vertical:hover .kbq-navbar-logo{transform:scale(1.06)}.kbq-navbar-brand.kbq-navbar-brand_link.kbq-horizontal:hover .kbq-navbar-logo{z-index:1}.kbq-navbar-brand.kbq-navbar-focusable-item{outline:none}.kbq-navbar-brand .kbq-navbar-title{font-size:var(--kbq-typography-navbar-title-font-size);font-style:var(--kbq-typography-navbar-title-font-style);font-weight:var(--kbq-typography-navbar-title-font-weight);line-height:var(--kbq-typography-navbar-title-line-height);font-family:var(--kbq-typography-navbar-title-font-family);text-transform:var(--kbq-typography-navbar-title-text-transform);font-feature-settings:var(--kbq-typography-navbar-title-font-feature-settings);letter-spacing:var(--kbq-typography-navbar-title-letter-spacing)}.kbq-navbar-brand.kbq-navbar-brand_long-title .kbq-navbar-title{font-size:var(--kbq-typography-text-normal-strong-font-size);font-style:var(--kbq-typography-text-normal-strong-font-style);font-weight:var(--kbq-typography-text-normal-strong-font-weight);line-height:var(--kbq-typography-text-normal-strong-line-height);font-family:var(--kbq-typography-text-normal-strong-font-family);text-transform:var(--kbq-typography-text-normal-strong-text-transform);font-feature-settings:var(--kbq-typography-text-normal-strong-font-feature-settings);letter-spacing:var(--kbq-typography-text-normal-strong-letter-spacing)}\n"] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqNavbarBrand, decorators: [{
            type: Component,
            args: [{ selector: 'kbq-navbar-brand, [kbq-navbar-brand]', exportAs: 'kbqNavbarBrand', template: `
        <ng-content />
    `, host: {
                        class: 'kbq-navbar-brand',
                        '[class.kbq-navbar-brand_long-title]': 'longTitle',
                        '[class.kbq-navbar-brand_link]': 'isLink'
                    }, styles: ["button.kbq-navbar-item,button.kbq-navbar-brand{background:transparent;border:none}.kbq-navbar-logo{display:flex}.kbq-navbar-brand{position:relative;display:flex;border-radius:var(--kbq-size-s)}.kbq-navbar-brand:after{position:absolute;content:\"\";display:none;border-radius:var(--kbq-navbar-item-size-content-border-radius)}.kbq-navbar-brand .kbq-navbar-title{cursor:pointer}a.kbq-navbar-brand{text-decoration:none}.kbq-navbar-brand.kbq-horizontal{padding:var(--kbq-size-s) var(--kbq-size-xs) var(--kbq-size-s) var(--kbq-size-xxs);align-items:center;gap:var(--kbq-size-s)}.kbq-navbar-brand.kbq-horizontal:after{top:var(--kbq-size-xxs);right:var(--kbq-size-xxs);bottom:var(--kbq-size-xxs);left:0}.kbq-navbar-brand.kbq-horizontal .kbq-navbar-title{padding-right:var(--kbq-size-m)}.kbq-navbar-brand.kbq-vertical{flex-direction:row;align-items:center;padding:var(--kbq-size-xxs) var(--kbq-size-m) var(--kbq-size-m)}.kbq-navbar-brand.kbq-vertical:after{top:0;right:var(--kbq-size-s);bottom:var(--kbq-size-s);left:var(--kbq-size-s)}.kbq-navbar-brand.kbq-vertical .kbq-navbar-logo{align-items:center}.kbq-navbar-brand.kbq-vertical .kbq-navbar-title{display:block;align-items:center;padding-left:var(--kbq-size-s)}.kbq-navbar-brand.kbq-vertical.kbq-expanded .kbq-navbar-title{max-width:200px}.kbq-navbar-brand.kbq-vertical.kbq-collapsed .kbq-navbar-title{display:none!important}.kbq-navbar-brand.kbq-vertical.kbq-navbar-brand_long-title .kbq-navbar-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;white-space:normal}.kbq-navbar-brand:not(.kbq-navbar-item_has-nested):after{display:block;background:var(--kbq-navbar-item-default-content-background)}.kbq-navbar-brand .kbq-navbar-title{color:var(--kbq-navbar-item-default-content-text)}.kbq-navbar-brand>.kbq-icon.kbq-empty{color:var(--kbq-navbar-item-default-content-icon-left)!important}.kbq-navbar-brand .kbq-navbar-item__arrow-icon{color:var(--kbq-navbar-item-default-content-icon-right)!important}.kbq-navbar-brand.kbq-navbar-brand_link{cursor:pointer}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled):not(.kbq-navbar-item_has-nested):after{display:block;background:var(--kbq-navbar-item-states-hover-content-background)}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled) .kbq-navbar-title{color:var(--kbq-navbar-item-states-hover-content-text)}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled)>.kbq-icon.kbq-empty{color:var(--kbq-navbar-item-states-hover-content-icon-left)!important}.kbq-navbar-brand.kbq-navbar-brand_link:hover:not(.kbq-disabled) .kbq-navbar-item__arrow-icon{color:var(--kbq-navbar-item-states-hover-content-icon-right)!important}.kbq-navbar-brand.kbq-navbar-brand_link.cdk-focused.cdk-keyboard-focused{outline:none}.kbq-navbar-brand.kbq-navbar-brand_link.cdk-focused.cdk-keyboard-focused:after{display:block;box-shadow:inset 0 0 0 2px var(--kbq-states-line-focus-theme)}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand):not(.kbq-navbar-item_has-nested):after,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand):not(.kbq-navbar-item_has-nested):after{display:block;background:var(--kbq-navbar-item-states-selected-content-background)}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-title,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-title{color:var(--kbq-navbar-item-states-selected-content-text)}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand)>.kbq-icon.kbq-empty,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand)>.kbq-icon.kbq-empty{color:var(--kbq-navbar-item-states-selected-content-icon-left)!important}.kbq-navbar-brand.kbq-navbar-brand_link:active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-item__arrow-icon,.kbq-navbar-brand.kbq-navbar-brand_link.kbq-active:not(.kbq-disabled,.kbq-vertical.kbq-navbar-brand) .kbq-navbar-item__arrow-icon{color:var(--kbq-navbar-item-states-selected-content-icon-right)!important}.kbq-navbar-brand.kbq-navbar-brand_link.kbq-vertical:hover .kbq-navbar-logo{transform:scale(1.06)}.kbq-navbar-brand.kbq-navbar-brand_link.kbq-horizontal:hover .kbq-navbar-logo{z-index:1}.kbq-navbar-brand.kbq-navbar-focusable-item{outline:none}.kbq-navbar-brand .kbq-navbar-title{font-size:var(--kbq-typography-navbar-title-font-size);font-style:var(--kbq-typography-navbar-title-font-style);font-weight:var(--kbq-typography-navbar-title-font-weight);line-height:var(--kbq-typography-navbar-title-line-height);font-family:var(--kbq-typography-navbar-title-font-family);text-transform:var(--kbq-typography-navbar-title-text-transform);font-feature-settings:var(--kbq-typography-navbar-title-font-feature-settings);letter-spacing:var(--kbq-typography-navbar-title-letter-spacing)}.kbq-navbar-brand.kbq-navbar-brand_long-title .kbq-navbar-title{font-size:var(--kbq-typography-text-normal-strong-font-size);font-style:var(--kbq-typography-text-normal-strong-font-style);font-weight:var(--kbq-typography-text-normal-strong-font-weight);line-height:var(--kbq-typography-text-normal-strong-line-height);font-family:var(--kbq-typography-text-normal-strong-font-family);text-transform:var(--kbq-typography-text-normal-strong-text-transform);font-feature-settings:var(--kbq-typography-text-normal-strong-font-feature-settings);letter-spacing:var(--kbq-typography-text-normal-strong-letter-spacing)}\n"] }]
        }], ctorParameters: () => [], propDecorators: { title: [{
                type: ContentChild,
                args: [KbqNavbarTitle]
            }], longTitle: [{
                type: Input
            }], collapsedText: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 