import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { or, and, eq, notEq } from 'ember-truth-helpers';
import argOrDefault from '../helpers/arg-or-default.js';
import classNames from '../helpers/class-names.js';
import screenReaderOnly from '../modifiers/screen-reader-only.js';
import EuiIcon from './eui-icon.js';

const EuiLink = setComponentTemplate(precompileTemplate(`
  {{#let (argOrDefault @color "primary") as |color|}}
    {{#if @href}}
      <a
        href={{@href}}
        class={{classNames
          (if @disabled "euiLink--disabled")
          componentName="EuiLink"
          color=(unless @disabled color)
        }}
        target={{@target}}
        disabled={{@disabled}}
        ...attributes
      >

        {{yield}}
        {{#if
          (or
            (and (eq @target "_blank") (notEq @external false))
            (eq @external true)
          )
        }}
          <EuiIcon
            @type="popout"
            aria-label="External link"
            @size="s"
            class="euiLink__externalIcon"
          />
        {{/if}}
        {{#if (eq @target "_blank")}}
          <span {{screenReaderOnly}}>
            (opens in a new tab or window)
          </span>
        {{/if}}
      </a>
    {{else}}
      <button
        type={{argOrDefault @type "button"}}
        class={{classNames
          (if @disabled "euiLink-disabled")
          componentName="EuiLink"
          color=(unless @disabled color)
        }}
        disabled={{@disabled}}
        ...attributes
      >
        {{yield}}
      </button>

    {{/if}}
  {{/let}}
`, {
  strictMode: true,
  scope: () => ({
    argOrDefault,
    classNames,
    or,
    and,
    eq,
    notEq,
    EuiIcon,
    screenReaderOnly
  })
}), templateOnly("eui-link", "EuiLink"));

export { EuiLink as default };
//# sourceMappingURL=eui-link.js.map
