/* eslint-disable @angular-eslint/no-output-on-prefix */
import { Component, EventEmitter, Input, Output, ViewChild, ViewEncapsulation, } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import * as i0 from "@angular/core";
import * as i1 from "@seniorsistemas/angular-components/button";
import * as i2 from "@angular/common";
import * as i3 from "@angular/forms";
import * as i4 from "primeng/inputtext";
import * as i5 from "@seniorsistemas/angular-components/tooltip";
import * as i6 from "@seniorsistemas/angular-components/password-strength";
import * as i7 from "../../../components/field-label/field-label.component";
export class PasswordFieldComponent {
    changeDetectorRef;
    field;
    formControl;
    onInput = new EventEmitter();
    onFocus = new EventEmitter();
    onComplete = new EventEmitter();
    inputRef = null;
    ngUnsubscribe = new Subject();
    passwordVisible = false;
    constructor(changeDetectorRef) {
        this.changeDetectorRef = changeDetectorRef;
    }
    ngOnInit() {
        this.onFocus.pipe(takeUntil(this.ngUnsubscribe)).subscribe((event) => {
            if (this.field.onFocus) {
                this.field.onFocus(event);
            }
        });
        this.onInput.pipe(takeUntil(this.ngUnsubscribe)).subscribe((event) => {
            if (this.field.onInput) {
                this.field.onInput(event);
            }
        });
        this.onComplete.pipe(takeUntil(this.ngUnsubscribe)).subscribe((event) => {
            if (this.field.onComplete) {
                this.field.onComplete(event);
            }
        });
    }
    ngOnDestroy() {
        this.ngUnsubscribe.next();
        this.ngUnsubscribe.complete();
    }
    onChangeVisible() {
        this.passwordVisible = !this.passwordVisible;
    }
    ngAfterViewInit() {
        this.changeDetectorRef.detectChanges();
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PasswordFieldComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: PasswordFieldComponent, selector: "ng-component", inputs: { field: "field", formControl: "formControl" }, outputs: { onInput: "onInput", onFocus: "onFocus", onComplete: "onComplete" }, viewQueries: [{ propertyName: "inputRef", first: true, predicate: ["inputRef"], descendants: true }], ngImport: i0, template: "@if(inputRef) {\n    <s-field-label\n        [field]=\"field\"\n        [fieldContainerRef]=\"inputRef\"\n    ></s-field-label>\n}\n\n<div\n    class=\"password-field\"\n    [ngClass]=\"{ 'password-field--toggle': field.showToggle }\"\n>\n    <input\n        #inputRef\n        [type]=\"passwordVisible ? 'text' : 'password'\"\n        [id]=\"field.id || field.name\"\n        class=\"password-input\"\n        [name]=\"field.name\"\n        [sTooltip]=\"field.tooltip\"\n        tooltipPosition=\"top\"\n        [placeholder]=\"field.placeholder\"\n        [showDelay]=\"500\"\n        [maxLength]=\"field.maxLength\"\n        pInputText\n        [ngClass]=\"'mousetrap'\"\n        (blur)=\"field.onBlur ? field.onBlur($event) : null\"\n        (focus)=\"onFocus.next($event)\"\n        (input)=\"onInput.next($event)\"\n        [formControl]=\"formControl\"\n        [ngStyle]=\"field.style\"\n        [sPasswordStrength]=\"field.passwordStrength ? field.passwordStrength : false\"\n        [passwordStrengthDescription]=\"field.passwordStrengthOptions?.description ? field.passwordStrengthOptions!.description : ''\"\n        [passwordStrengthWeakTitle]=\"field.passwordStrengthOptions?.weakTitle ? field.passwordStrengthOptions?.weakTitle : ''\"\n        [passwordStrengthMediumTitle]=\"field.passwordStrengthOptions?.mediumTitle ? field.passwordStrengthOptions?.mediumTitle : ''\"\n        [passwordStrengthStrongTitle]=\"field.passwordStrengthOptions?.strongTitle ? field.passwordStrengthOptions?.strongTitle : ''\"\n        [passwordStrengthValidation]=\"field.passwordStrengthOptions?.validation\"\n    />\n    @if (field.showToggle) {\n        <span class=\"toggle-button\">\n            <s-button\n                [iconClass]=\"passwordVisible ? 'fas fa-eye-slash' : 'fas fa-eye'\"\n                priority=\"default\"\n                (clicked)=\"onChangeVisible()\"\n            >\n            </s-button>\n        </span>\n    }\n</div>\n", styles: ["s-text-field.ng-dirty.ng-invalid .password-input{border-color:#c13018}s-text-field.ng-dirty.ng-invalid .password-input:hover{border-color:highlight(#c13018)}.password-field{display:flex}.password-field--toggle .password-input{border-top-right-radius:0;border-bottom-right-radius:0;border-right:none}.password-field--toggle .toggle-button s-button button{border-bottom-left-radius:0;border-top-left-radius:0}.password-field:has(.password-input.ng-invalid.ng-dirty) s-button button{border:1px solid #c13018}.password-field:has(.password-input:focus) s-button button{border:1px solid #428bca}.password-field:has(.password-input:focus):has(button) .password-input{border-right:none}\n"], dependencies: [{ kind: "component", type: i1.ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor"], outputs: ["clicked"] }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: i3.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i4.InputText, selector: "[pInputText]", inputs: ["variant", "fluid", "pSize"] }, { kind: "directive", type: i3.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i5.TooltipDirective, selector: "[sTooltip]", inputs: ["sTooltip", "tooltipPosition", "showDelay", "displayTime", "tooltipEvent", "escape", "visible", "mobileBehavior", "focusedInputRef", "checkTruncatedText"] }, { kind: "directive", type: i6.PasswordStrengthDirective, selector: "[sPasswordStrength]", inputs: ["sPasswordStrength", "passwordStrengthValidation", "passwordStrengthPosition", "passwordStrengthWeakTitle", "passwordStrengthMediumTitle", "passwordStrengthStrongTitle", "passwordStrengthDescription"] }, { kind: "component", type: i7.FieldLabelComponent, selector: "s-field-label", inputs: ["field", "fieldContainerRef"] }], encapsulation: i0.ViewEncapsulation.None });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PasswordFieldComponent, decorators: [{
            type: Component,
            args: [{ encapsulation: ViewEncapsulation.None, template: "@if(inputRef) {\n    <s-field-label\n        [field]=\"field\"\n        [fieldContainerRef]=\"inputRef\"\n    ></s-field-label>\n}\n\n<div\n    class=\"password-field\"\n    [ngClass]=\"{ 'password-field--toggle': field.showToggle }\"\n>\n    <input\n        #inputRef\n        [type]=\"passwordVisible ? 'text' : 'password'\"\n        [id]=\"field.id || field.name\"\n        class=\"password-input\"\n        [name]=\"field.name\"\n        [sTooltip]=\"field.tooltip\"\n        tooltipPosition=\"top\"\n        [placeholder]=\"field.placeholder\"\n        [showDelay]=\"500\"\n        [maxLength]=\"field.maxLength\"\n        pInputText\n        [ngClass]=\"'mousetrap'\"\n        (blur)=\"field.onBlur ? field.onBlur($event) : null\"\n        (focus)=\"onFocus.next($event)\"\n        (input)=\"onInput.next($event)\"\n        [formControl]=\"formControl\"\n        [ngStyle]=\"field.style\"\n        [sPasswordStrength]=\"field.passwordStrength ? field.passwordStrength : false\"\n        [passwordStrengthDescription]=\"field.passwordStrengthOptions?.description ? field.passwordStrengthOptions!.description : ''\"\n        [passwordStrengthWeakTitle]=\"field.passwordStrengthOptions?.weakTitle ? field.passwordStrengthOptions?.weakTitle : ''\"\n        [passwordStrengthMediumTitle]=\"field.passwordStrengthOptions?.mediumTitle ? field.passwordStrengthOptions?.mediumTitle : ''\"\n        [passwordStrengthStrongTitle]=\"field.passwordStrengthOptions?.strongTitle ? field.passwordStrengthOptions?.strongTitle : ''\"\n        [passwordStrengthValidation]=\"field.passwordStrengthOptions?.validation\"\n    />\n    @if (field.showToggle) {\n        <span class=\"toggle-button\">\n            <s-button\n                [iconClass]=\"passwordVisible ? 'fas fa-eye-slash' : 'fas fa-eye'\"\n                priority=\"default\"\n                (clicked)=\"onChangeVisible()\"\n            >\n            </s-button>\n        </span>\n    }\n</div>\n", styles: ["s-text-field.ng-dirty.ng-invalid .password-input{border-color:#c13018}s-text-field.ng-dirty.ng-invalid .password-input:hover{border-color:highlight(#c13018)}.password-field{display:flex}.password-field--toggle .password-input{border-top-right-radius:0;border-bottom-right-radius:0;border-right:none}.password-field--toggle .toggle-button s-button button{border-bottom-left-radius:0;border-top-left-radius:0}.password-field:has(.password-input.ng-invalid.ng-dirty) s-button button{border:1px solid #c13018}.password-field:has(.password-input:focus) s-button button{border:1px solid #428bca}.password-field:has(.password-input:focus):has(button) .password-input{border-right:none}\n"] }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { field: [{
                type: Input,
                args: [{ required: true }]
            }], formControl: [{
                type: Input,
                args: [{ required: true }]
            }], onInput: [{
                type: Output
            }], onFocus: [{
                type: Output
            }], onComplete: [{
                type: Output
            }], inputRef: [{
                type: ViewChild,
                args: ['inputRef']
            }] } });
//# sourceMappingURL=data:application/json;base64, 