import { Component, ElementRef, Self, HostBinding, Input, Optional, Renderer2, ViewEncapsulation } from '@angular/core';
import { NgControl } from '@angular/forms';
import { InputDirective } from '../../input.directive';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
const _c0 = ["euiInputText", ""];
export class EuiInputTextComponent extends InputDirective {
    constructor(control, _elementRef, _renderer) {
        super(_elementRef, _renderer, control);
        this.control = control;
        this._elementRef = _elementRef;
        this._renderer = _renderer;
    }
    get cssClasses() {
        return [
            this.getCssClasses('eui-input-text'),
            this._isInvalid ? `eui-input-text--invalid` : '',
            this.styleClass ? this.styleClass : ``,
        ].join(' ').trim();
    }
    get isInvalid() {
        return this._isInvalid || null;
    }
    set isInvalid(state) {
        this.setInvalid(state);
    }
    ngOnInit() {
        super.ngOnInit();
    }
    ngOnDestroy() {
        super.ngOnDestroy();
    }
    ngDoCheck() {
        if (this.control) {
            this.isInvalid = this.control.invalid && this.control.touched;
        }
    }
    setInvalid(state) {
        // in case it's controlled by NgControl override
        this._isInvalid = this.control ? this.control.invalid && this.control.touched : coerceBooleanProperty(state);
        // set BaseDirective Attribute
        super.euiDanger = this._isInvalid;
    }
}
/** @nocollapse */ EuiInputTextComponent.ɵfac = function EuiInputTextComponent_Factory(t) { return new (t || EuiInputTextComponent)(i0.ɵɵdirectiveInject(i1.NgControl, 10), i0.ɵɵdirectiveInject(i0.ElementRef), i0.ɵɵdirectiveInject(i0.Renderer2)); };
/** @nocollapse */ EuiInputTextComponent.ɵcmp = i0.ɵɵdefineComponent({ type: EuiInputTextComponent, selectors: [["input", "euiInputText", ""]], hostVars: 2, hostBindings: function EuiInputTextComponent_HostBindings(rf, ctx) { if (rf & 2) {
        i0.ɵɵclassMap(ctx.cssClasses);
    } }, inputs: { styleClass: "styleClass", isInvalid: "isInvalid" }, features: [i0.ɵɵInheritDefinitionFeature], attrs: _c0, decls: 0, vars: 0, template: function EuiInputTextComponent_Template(rf, ctx) { }, styles: ["@charset \"UTF-8\";.eui-input-text{-webkit-appearance:none;appearance:none;background-color:var(--eui-color-white);border:1px solid var(--eui-color-grey-light);border-radius:var(--eui-border-radius-base);color:var(--eui-color-black);display:block;height:calc(var(--eui-spacing)*2.75);overflow:hidden;padding:calc(var(--eui-spacing-s) - 1px);text-overflow:ellipsis;white-space:nowrap;width:100%}.eui-input-text:active:not([readonly]),.eui-input-text:focus:not([readonly]){border-color:var(--eui-color-accessible-focus)!important;box-shadow:inset 0 0 0 1px var(--eui-color-accessible-focus),inset 0 0 0 2px var(--eui-color-grey-lightester);outline:none;transition:border-color .15s ease-in-out,box-shadow .15s ease-in-out;z-index:auto}.eui-input-text[readonly]{background-color:initial;border-color:transparent!important;box-shadow:none;font-style:normal;font-weight:700;height:inherit;padding:var(--eui-spacing-2xs) 0}.eui-input-text[readonly]+.eui-feedback-message,.eui-input-text[readonly]+.input-maxlength{-webkit-appearance:none;appearance:none;display:none}.eui-input-text--disabled,.eui-input-text[disabled]{background-color:var(--eui-color-grey-lightester);border:1px solid var(--eui-color-grey-light);color:var(--eui-color-grey-dark);pointer-events:none}.eui-input-text--danger,.eui-input-text--invalid{border:1px solid var(--eui-color-danger);z-index:1}.eui-input-text--clearable{padding-right:var(--eui-spacing-2xl)}.eui-input-text--clearable-icon{display:flex;flex:1 1 0%;position:relative}.eui-input-text--clearable-icon .eui-clearable-input-wrapper__clear,.eui-input-text--clearable-icon .ux-clearable-input-wrapper__clear{-webkit-user-select:none;color:var(--eui-color-grey);cursor:pointer;font-size:var(--eui-font-size-xl);font-style:normal;opacity:var(--eui-disabled-opacity-base);position:absolute;right:var(--eui-spacing-xs);top:50%;transform:translateY(-50%);user-select:none;z-index:var(--eui-z-index-clearable-icon)}.eui-input-text--clearable-icon .eui-clearable-input-wrapper__clear:hover,.eui-input-text--clearable-icon .ux-clearable-input-wrapper__clear:hover{color:var(--eui-color-danger);opacity:1}.eui-input-text--clearable-icon .eui-clearable-input-wrapper__clear:before,.eui-input-text--clearable-icon .ux-clearable-input-wrapper__clear:before{content:\"\uF3BB\";font-family:eui-icons!important}.eui-input-text--loading{padding-right:var(--eui-spacing-2xl)}.eui-input-text--loading-icon{animation:eui-icon-spin-animation 1s linear infinite;position:absolute;right:var(--eui-spacing-xs);top:var(--eui-spacing-xs);z-index:var(--eui-z-index-loading-indicator)}.eui-input-text--loading-icon:before{color:var(--eui-color-primary);content:\"\uF021\";font-family:eui-icons!important;font-size:var(--eui-font-size-3xl)}"], encapsulation: 2 });
/*@__PURE__*/ (function () { i0.ɵsetClassMetadata(EuiInputTextComponent, [{
        type: Component,
        args: [{
                // tslint:disable-next-line:component-selector
                selector: 'input[euiInputText]',
                template: ``,
                styleUrls: ['./styles/_index.scss'],
                encapsulation: ViewEncapsulation.None,
            }]
    }], function () { return [{ type: i1.NgControl, decorators: [{
                type: Optional
            }, {
                type: Self
            }] }, { type: i0.ElementRef }, { type: i0.Renderer2 }]; }, { cssClasses: [{
            type: HostBinding,
            args: ['class']
        }], styleClass: [{
            type: Input
        }], isInvalid: [{
            type: Input
        }] }); })();
//# sourceMappingURL=data:application/json;base64, 