import { NgClass } from '@angular/common';
import { afterNextRender, booleanAttribute, ChangeDetectionStrategy, ChangeDetectorRef, Component, computed, DestroyRef, inject, input, ViewEncapsulation } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { KBQ_FORM_FIELD_REF, KbqComponentColors } from '@koobiq/components/core';
import { KbqIconModule } from '@koobiq/components/icon';
import { EMPTY } from 'rxjs';
import { delay } from 'rxjs/operators';
import { KbqHint } from './hint';
import * as i0 from "@angular/core";
import * as i1 from "@koobiq/components/icon";
/** Password hint to be shown below the password form field control. */
export class KbqReactivePasswordHint extends KbqHint {
    constructor() {
        super();
        // @TODO fix types (#DS-2915)
        this.formField = inject(KBQ_FORM_FIELD_REF, { optional: true });
        this.destroyRef = inject(DestroyRef);
        this.changeDetectorRef = inject(ChangeDetectorRef);
        /** Whether the form field control has an error. */
        this.hasError = input(false, { transform: booleanAttribute });
        /**
         * The form field hint icon.
         *
         * @docs-private
         */
        this.icon = computed(() => (this.hasError() ? 'kbq-xmark-s_16' : 'kbq-check-s_16'));
        this.fillTextOff = true;
        this.compact = false;
        this.color = KbqComponentColors.ContrastFade;
        afterNextRender(() => {
            (this.formField?.control?.stateChanges || EMPTY)
                .pipe(delay(0), takeUntilDestroyed(this.destroyRef))
                .subscribe(() => {
                this.color = this.makeColor();
                this.changeDetectorRef.markForCheck();
            });
        });
    }
    makeColor() {
        if (this.formField?.control.ngControl?.untouched && this.formField.control.ngControl.pristine) {
            return KbqComponentColors.ContrastFade;
        }
        return this.hasError() ? KbqComponentColors.Error : KbqComponentColors.Success;
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqReactivePasswordHint, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.1.0", version: "18.2.14", type: KbqReactivePasswordHint, isStandalone: true, selector: "kbq-reactive-password-hint", inputs: { hasError: { classPropertyName: "hasError", publicName: "hasError", isSignal: true, isRequired: false, transformFunction: null } }, host: { classAttribute: "kbq-reactive-password-hint" }, exportAs: ["kbqReactivePasswordHint"], usesInheritance: true, ngImport: i0, template: `
        <i kbq-icon="" [ngClass]="icon()" [color]="color"></i>

        <span class="kbq-hint__text">
            <ng-content />
        </span>
    `, isInline: true, styles: [".kbq-hint{display:flex}.kbq-hint .kbq-icon{margin-top:var(--kbq-hint-size-normal-margin-top);margin-right:var(--kbq-hint-size-normal-content-padding)}.kbq-hint.kbq-hint_compact .kbq-icon{margin-top:var(--kbq-hint-size-compact-margin-top);margin-right:var(--kbq-hint-size-compact-content-padding)}.kbq-hint.kbq-contrast-fade{color:var(--kbq-hint-fill-text-on-fade-contrast-text)}.kbq-hint.kbq-contrast-fade .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-fade-contrast-icon)!important}.kbq-hint.kbq-success{color:var(--kbq-hint-fill-text-on-success-text)}.kbq-hint.kbq-success .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-success-icon)!important}.kbq-hint.kbq-warning{color:var(--kbq-hint-fill-text-on-warning-text)}.kbq-hint.kbq-warning .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-warning-icon)!important}.kbq-hint.kbq-error{color:var(--kbq-hint-fill-text-on-error-text)}.kbq-hint.kbq-error .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-error-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-contrast-fade{color:var(--kbq-hint-fill-text-off-fade-contrast-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-contrast-fade .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-fade-contrast-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-success{color:var(--kbq-hint-fill-text-off-success-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-success .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-success-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-warning{color:var(--kbq-hint-fill-text-off-warning-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-warning .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-warning-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-error{color:var(--kbq-hint-fill-text-off-error-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-error .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-error-icon)!important}.kbq-hint .kbq-hint__text{font-size:var(--kbq-typography-text-normal-font-size);font-style:var(--kbq-typography-text-normal-font-style);font-weight:var(--kbq-typography-text-normal-font-weight);line-height:var(--kbq-typography-text-normal-line-height);font-family:var(--kbq-typography-text-normal-font-family);text-transform:var(--kbq-typography-text-normal-text-transform);font-feature-settings:var(--kbq-typography-text-normal-font-feature-settings);letter-spacing:var(--kbq-typography-text-normal-letter-spacing)}.kbq-hint.kbq-hint_compact .kbq-hint__text{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)}\n", ".kbq-hint{--kbq-hint-size-normal-margin-top: var(--kbq-size-3xs);--kbq-hint-size-normal-content-padding: var(--kbq-size-xxs);--kbq-hint-size-compact-margin-top: 0;--kbq-hint-size-compact-content-padding: var(--kbq-size-xxs);--kbq-hint-fill-text-off-fade-contrast-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-fade-contrast-icon: var(--kbq-icon-contrast-fade);--kbq-hint-fill-text-off-success-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-success-icon: var(--kbq-icon-success);--kbq-hint-fill-text-off-warning-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-warning-icon: var(--kbq-icon-warning);--kbq-hint-fill-text-off-error-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-error-icon: var(--kbq-icon-error);--kbq-hint-fill-text-on-fade-contrast-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-on-fade-contrast-icon: var(--kbq-icon-contrast-fade);--kbq-hint-fill-text-on-success-text: var(--kbq-foreground-success);--kbq-hint-fill-text-on-success-icon: var(--kbq-icon-success);--kbq-hint-fill-text-on-warning-text: var(--kbq-foreground-warning);--kbq-hint-fill-text-on-warning-icon: var(--kbq-icon-warning);--kbq-hint-fill-text-on-error-text: var(--kbq-foreground-error);--kbq-hint-fill-text-on-error-icon: var(--kbq-icon-error)}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: KbqIconModule }, { kind: "component", type: i1.KbqIcon, selector: "[kbq-icon]", inputs: ["small", "autoColor", "kbq-icon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: KbqReactivePasswordHint, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [NgClass, KbqIconModule], selector: 'kbq-reactive-password-hint', exportAs: 'kbqReactivePasswordHint', template: `
        <i kbq-icon="" [ngClass]="icon()" [color]="color"></i>

        <span class="kbq-hint__text">
            <ng-content />
        </span>
    `, host: {
                        class: 'kbq-reactive-password-hint'
                    }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: [".kbq-hint{display:flex}.kbq-hint .kbq-icon{margin-top:var(--kbq-hint-size-normal-margin-top);margin-right:var(--kbq-hint-size-normal-content-padding)}.kbq-hint.kbq-hint_compact .kbq-icon{margin-top:var(--kbq-hint-size-compact-margin-top);margin-right:var(--kbq-hint-size-compact-content-padding)}.kbq-hint.kbq-contrast-fade{color:var(--kbq-hint-fill-text-on-fade-contrast-text)}.kbq-hint.kbq-contrast-fade .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-fade-contrast-icon)!important}.kbq-hint.kbq-success{color:var(--kbq-hint-fill-text-on-success-text)}.kbq-hint.kbq-success .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-success-icon)!important}.kbq-hint.kbq-warning{color:var(--kbq-hint-fill-text-on-warning-text)}.kbq-hint.kbq-warning .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-warning-icon)!important}.kbq-hint.kbq-error{color:var(--kbq-hint-fill-text-on-error-text)}.kbq-hint.kbq-error .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-on-error-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-contrast-fade{color:var(--kbq-hint-fill-text-off-fade-contrast-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-contrast-fade .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-fade-contrast-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-success{color:var(--kbq-hint-fill-text-off-success-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-success .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-success-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-warning{color:var(--kbq-hint-fill-text-off-warning-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-warning .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-warning-icon)!important}.kbq-hint.kbq-hint_fill-text-off.kbq-error{color:var(--kbq-hint-fill-text-off-error-text)}.kbq-hint.kbq-hint_fill-text-off.kbq-error .kbq-icon.kbq-empty{color:var(--kbq-hint-fill-text-off-error-icon)!important}.kbq-hint .kbq-hint__text{font-size:var(--kbq-typography-text-normal-font-size);font-style:var(--kbq-typography-text-normal-font-style);font-weight:var(--kbq-typography-text-normal-font-weight);line-height:var(--kbq-typography-text-normal-line-height);font-family:var(--kbq-typography-text-normal-font-family);text-transform:var(--kbq-typography-text-normal-text-transform);font-feature-settings:var(--kbq-typography-text-normal-font-feature-settings);letter-spacing:var(--kbq-typography-text-normal-letter-spacing)}.kbq-hint.kbq-hint_compact .kbq-hint__text{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)}\n", ".kbq-hint{--kbq-hint-size-normal-margin-top: var(--kbq-size-3xs);--kbq-hint-size-normal-content-padding: var(--kbq-size-xxs);--kbq-hint-size-compact-margin-top: 0;--kbq-hint-size-compact-content-padding: var(--kbq-size-xxs);--kbq-hint-fill-text-off-fade-contrast-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-fade-contrast-icon: var(--kbq-icon-contrast-fade);--kbq-hint-fill-text-off-success-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-success-icon: var(--kbq-icon-success);--kbq-hint-fill-text-off-warning-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-warning-icon: var(--kbq-icon-warning);--kbq-hint-fill-text-off-error-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-off-error-icon: var(--kbq-icon-error);--kbq-hint-fill-text-on-fade-contrast-text: var(--kbq-foreground-contrast);--kbq-hint-fill-text-on-fade-contrast-icon: var(--kbq-icon-contrast-fade);--kbq-hint-fill-text-on-success-text: var(--kbq-foreground-success);--kbq-hint-fill-text-on-success-icon: var(--kbq-icon-success);--kbq-hint-fill-text-on-warning-text: var(--kbq-foreground-warning);--kbq-hint-fill-text-on-warning-icon: var(--kbq-icon-warning);--kbq-hint-fill-text-on-error-text: var(--kbq-foreground-error);--kbq-hint-fill-text-on-error-icon: var(--kbq-icon-error)}\n"] }]
        }], ctorParameters: () => [] });
//# sourceMappingURL=data:application/json;base64, 