import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
import optional from 'ember-composable-helpers/helpers/optional';
import { and, not, or } from 'ember-truth-helpers';
import randomId from '../-private/random-id.js';
import argOrDefault from '../helpers/arg-or-default.js';
import classNames from '../helpers/class-names.js';
import validatableControl from '../modifiers/validatable-control.js';
import EuiFormControlLayout from './eui-form-control-layout.js';

const EuiFieldText = setComponentTemplate(precompileTemplate(`
  {{#let
    (and (not (argOrDefault @isFakePrependBlock false)) (has-block "prepend"))
    (and (not (argOrDefault @isFakeAppendBlock false)) (has-block "append"))
    (argOrDefault @id (randomId))
    as |hasPrepend hasAppend inputId|
  }}
    {{#let
      (classNames
        (if @icon "euiFieldText--withIcon")
        (if @fullWidth "euiFieldText--fullWidth")
        (if @compressed "euiFieldText--compressed")
        (if (or hasPrepend hasAppend) "euiFieldText--inGroup")
        (if @isLoading "euiFieldText--isLoading")
        "euiFieldText"
      )
      as |classes|
    }}
      {{#if @controlOnly}}
        <input
          id={{inputId}}
          value={{@value}}
          class={{classes}}
          disabled={{@disabled}}
          type="text"
          placeholder={{@placeholder}}
          readonly={{@readOnly}}
          ...attributes
          {{validatableControl @isInvalid}}
          {{didInsert (optional @inputRef)}}
        />
      {{else}}
        <EuiFormControlLayout
          @icon={{@icon}}
          @clear={{@clear}}
          @fullWidth={{@fullWidth}}
          @isLoading={{@isLoading}}
          @compressed={{@compressed}}
          @readOnly={{@readOnly}}
          @disabled={{@disabled}}
          @useGroup={{or hasPrepend hasAppend}}
        >
          <:prepend as |prependClasses|>
            {{yield prependClasses inputId to="prepend"}}
          </:prepend>
          <:field>
            <input
              id={{inputId}}
              value={{@value}}
              class={{classes}}
              disabled={{@disabled}}
              type="text"
              placeholder={{@placeholder}}
              readonly={{@readOnly}}
              ...attributes
              {{validatableControl @isInvalid}}
            />
          </:field>
          <:append as |appendClasses|>
            {{yield appendClasses inputId to="append"}}
          </:append>
        </EuiFormControlLayout>
      {{/if}}
    {{/let}}
  {{/let}}
`, {
  strictMode: true,
  scope: () => ({
    and,
    not,
    argOrDefault,
    randomId,
    classNames,
    or,
    validatableControl,
    didInsert,
    optional,
    EuiFormControlLayout
  })
}), templateOnly("eui-field-text", "EuiFieldText"));

export { EuiFieldText as default };
//# sourceMappingURL=eui-field-text.js.map
