import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { hash, get } from '@ember/helper';
import { eq, and, not, or } from 'ember-truth-helpers';
import argOrDefault from '../helpers/arg-or-default.js';
import classNames from '../helpers/class-names.js';
import inlineStyles from '../helpers/inline-styles.js';
import { toInitials } from '../helpers/to-initials.js';
import simpleStyle from '../modifiers/simple-style.js';
import EuiIcon from './eui-icon.js';

const EuiAvatar = setComponentTemplate(precompileTemplate(`
  {{#let
    (inlineStyles
      componentName="EuiAvatar"
      componentArgs=(hash
        name=@name
        color=@color
        iconColor=@iconColor
        iconSize=@iconSize
        iconType=@iconType
        imageUrl=@imageUrl
        initials=@initials
      )
    )
    as |inlineStyles|
  }}
    <div
      class={{classNames
        (if @isDisabled "euiAvatar-isDisabled")
        (if (eq @color "plain") "euiAvatar--plain")
        componentName="EuiAvatar"
        size=(argOrDefault @size "m")
        type=(argOrDefault @type "user")
      }}
      aria-label={{if @isDisabled undefined @name}}
      title={{@name}}
      role={{if @isDisabled "presentation" "img"}}
      ...attributes
      {{simpleStyle inlineStyles}}
    >
      {{#if (and (not @imageUrl) (not @iconType))}}
        <span aria-hidden="true">
          {{#if @name}}
            {{toInitials @name @initialLength @initials}}
          {{/if}}
        </span>
      {{else if @iconType}}
        <EuiIcon
          @iconClasses="euiAvatar__icon"
          @size={{or @iconSize @size}}
          @type={{@iconType}}
          aria-label={{@name}}
          role={{if @isDisabled "presentation" "img"}}
          @color={{or
            @iconColor
            (if (eq @iconColor null) @iconColor (get inlineStyles "color"))
          }}
        />
      {{/if}}
    </div>
  {{/let}}
`, {
  strictMode: true,
  scope: () => ({
    inlineStyles,
    hash,
    classNames,
    eq,
    argOrDefault,
    simpleStyle,
    and,
    not,
    toInitials,
    EuiIcon,
    or,
    get
  })
}), templateOnly("eui-avatar", "EuiAvatar"));

export { EuiAvatar as default };
//# sourceMappingURL=eui-avatar.js.map
