import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, inject, Input, ViewEncapsulation } from '@angular/core';
import { KBQ_FORM_FIELD_REF, KbqColorDirective } from '@koobiq/components/core';
import * as i0 from "@angular/core";
export class KbqIcon extends KbqColorDirective {
    constructor() {
        super(...arguments);
        this.elementRef = inject(ElementRef);
        this.formField = inject(KBQ_FORM_FIELD_REF, { optional: true });
        this.changeDetectorRef = inject(ChangeDetectorRef);
        this.small = false;
        this.autoColor = false;
        this.hasError = false;
        this.name = 'KbqIcon';
        this.updateState = () => {
            this.hasError = this.formField?.control?.errorState;
            this.changeDetectorRef.markForCheck();
        };
    }
    getHostElement() {
        return this.elementRef.nativeElement;
    }
    updateMaxHeight() {
        if (this.name !== 'KbqIcon') {
            return;
        }
        const size = parseInt(this.iconName?.split('_')[1]);
        if (size) {
            this.getHostElement().style.maxHeight = `${size}px`;
        }
    }
    ngAfterContentInit() {
        if (this.autoColor) {
            this.formField?.control?.stateChanges.subscribe(this.updateState);
            this.updateState();
        }
        this.updateMaxHeight();
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqIcon, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.14", type: KbqIcon, isStandalone: true, selector: "[kbq-icon]", inputs: { small: "small", autoColor: "autoColor", iconName: ["kbq-icon", "iconName"] }, host: { properties: { "class": "iconName", "class.kbq-error": "color === \"error\" || hasError" }, classAttribute: "kbq kbq-icon" }, usesInheritance: true, ngImport: i0, template: '<ng-content />', isInline: true, styles: [".kbq-icon-rotate_90{transform:rotate(90deg)}.kbq-icon-rotate_180{transform:rotate(180deg)}.kbq-icon-rotate_270{transform:rotate(270deg)}.kbq-icon-flip-h{transform:scaleY(-1)}.kbq-icon-flip-v{transform:scaleX(-1)}.kbq-icon-flip-vh{transform:scale(-1)}.kbq-icon{color:var(--kbq-icon-contrast-color)}.kbq-icon.kbq-theme{color:var(--kbq-icon-theme-color)}.kbq-icon.kbq-contrast{color:var(--kbq-icon-contrast-color)}.kbq-icon.kbq-contrast-fade{color:var(--kbq-icon-fade-contrast-color)}.kbq-icon.kbq-error{color:var(--kbq-icon-error-color)}.kbq-icon.kbq-warning{color:var(--kbq-icon-warning-color)}.kbq-icon.kbq-success{color:var(--kbq-icon-success-color)}\n", ".kbq-icon{--kbq-icon-theme-color: var(--kbq-icon-theme);--kbq-icon-contrast-color: var(--kbq-icon-contrast);--kbq-icon-fade-contrast-color: var(--kbq-icon-contrast-fade);--kbq-icon-error-color: var(--kbq-icon-error);--kbq-icon-success-color: var(--kbq-icon-success);--kbq-icon-warning-color: var(--kbq-icon-warning)}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqIcon, decorators: [{
            type: Component,
            args: [{ standalone: true, selector: '[kbq-icon]', template: '<ng-content />', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
                        class: 'kbq kbq-icon',
                        '[class]': 'iconName',
                        '[class.kbq-error]': 'color === "error" || hasError'
                    }, styles: [".kbq-icon-rotate_90{transform:rotate(90deg)}.kbq-icon-rotate_180{transform:rotate(180deg)}.kbq-icon-rotate_270{transform:rotate(270deg)}.kbq-icon-flip-h{transform:scaleY(-1)}.kbq-icon-flip-v{transform:scaleX(-1)}.kbq-icon-flip-vh{transform:scale(-1)}.kbq-icon{color:var(--kbq-icon-contrast-color)}.kbq-icon.kbq-theme{color:var(--kbq-icon-theme-color)}.kbq-icon.kbq-contrast{color:var(--kbq-icon-contrast-color)}.kbq-icon.kbq-contrast-fade{color:var(--kbq-icon-fade-contrast-color)}.kbq-icon.kbq-error{color:var(--kbq-icon-error-color)}.kbq-icon.kbq-warning{color:var(--kbq-icon-warning-color)}.kbq-icon.kbq-success{color:var(--kbq-icon-success-color)}\n", ".kbq-icon{--kbq-icon-theme-color: var(--kbq-icon-theme);--kbq-icon-contrast-color: var(--kbq-icon-contrast);--kbq-icon-fade-contrast-color: var(--kbq-icon-contrast-fade);--kbq-icon-error-color: var(--kbq-icon-error);--kbq-icon-success-color: var(--kbq-icon-success);--kbq-icon-warning-color: var(--kbq-icon-warning)}\n"] }]
        }], propDecorators: { small: [{
                type: Input
            }], autoColor: [{
                type: Input
            }], iconName: [{
                type: Input,
                args: [{ alias: 'kbq-icon' }]
            }] } });
//# sourceMappingURL=data:application/json;base64, 