import { _ as _applyDecoratedDescriptor, a as _initializerDefineProperty, b as _defineProperty } from '../_rollupPluginBabelHelpers-9wjJaosZ.js';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { on } from '@ember/modifier';
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
import optional from 'ember-composable-helpers/helpers/optional';
import { element } from 'ember-element-helper';
import set from 'ember-set-helper/helpers/set';
import { and, not, or, eq, notEq } 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 EuiBetaBadge from './eui-beta-badge.js';
import EuiCardSelectComponent, { euiCardSelectableColor } from './eui-card-select.js';
import EuiIcon from './eui-icon.js';
import EuiPanel from './eui-panel.js';
import EuiTextComponent from './eui-text.js';
import EuiTitle from './eui-title.js';

var _class, _descriptor;
let EuiCardComponent = setComponentTemplate(precompileTemplate(`
    {{#let
      (if @selectable (randomId))
      (and
        (not @isDisabled)
        (or @onClick @href (and @selectable (not @selectable.isDisabled)))
      )
      (argOrDefault @titleElement "span")
      (argOrDefault @layout "vertical")
      as |selectableId isClickable titleElement layout|
    }}
      <EuiPanel
        class={{classNames
          (if (eq layout "horizontal") "euiCard--horizontal")
          (if isClickable "euiCard--isClickable")
          (if @betaBadgeProps.label "euiCard--hasBetaBadge")
          (if
            @icon "euiCard--hasIcon" (if (has-block "icon") "euiCard--hasIcon")
          )
          (if @selectable "euiCard--isSelectable")
          (if (and @selectable @selectable.isSelected) "euiCard-isSelected")
          (if @isDisabled "euiCard-isDisabled")
          this.selectableColorClass
          componentName="EuiCard"
          textAlign=(argOrDefault @textAlign "center")
        }}
        @color={{if @isDisabled "subdued" @display}}
        @onClick={{if isClickable this.outerOnClick}}
        @hasShadow={{if (or @isDisabled @display) true}}
        @hasBorder={{if @display true undefined}}
        @paddingSize={{@paddingSize}}
        ...attributes
      >

        {{#if (or (has-block "icon") (or @image @icon))}}
          <div class={{this.topClasses}}>
            {{#if (has-block "icon")}}
              {{yield "euiCard__icon" to="icon"}}
            {{else}}
              {{#if (or @image @icon)}}
                {{#if (and @image (notEq layout "horizontal"))}}
                  <div class="euiCard__image">
                    <img src={{@image}} alt="card-top" />
                  </div>
                {{/if}}
                {{#if @icon}}
                  <EuiIcon
                    @iconClasses="euiCard__icon"
                    @type={{@icon}}
                    @size={{@iconSize}}
                  />
                {{/if}}
              {{/if}}
            {{/if}}
          </div>
        {{/if}}

        <div class={{this.contentClasses}}>
          <EuiTitle
            class="euiCard__title"
            @size={{argOrDefault @titleSize "s"}}
          >
            {{#if (has-block "title")}}
              {{yield (set this "link") to="title"}}
            {{else if (and (not @isDisabled) @href)}}
              <a
                class="euiCard__titleAnchor"
                target={{@target}}
                disabled={{@isDisabled}}
                href={{@href}}
                {{didInsert (set this "link")}}
              >
                {{#if (notEq titleElement "span")}}
                  {{#let (element titleElement) as |TitleElement|}}
                    <TitleElement>{{@title}}</TitleElement>
                  {{/let}}
                {{else}}
                  <span>{{@title}}</span>
                {{/if}}

              </a>
            {{else if (or @isDisabled @onClick)}}
              <button
                type="button"
                class="euiCard__titleButton"
                disabled={{@isDisabled}}
                {{didInsert (set this "link")}}
                {{on "click" (optional @onClick)}}
              >
                {{#if (notEq titleElement "span")}}
                  {{#let (element titleElement) as |TitleElement|}}
                    <TitleElement>{{@title}}</TitleElement>
                  {{/let}}
                {{else}}
                  <span>{{@title}}</span>
                {{/if}}
              </button>
            {{else}}
              {{#if (notEq titleElement "span")}}
                {{#let (element titleElement) as |TitleElement|}}
                  <TitleElement>{{@title}}</TitleElement>
                {{/let}}
              {{else}}
                <span>{{@title}}</span>
              {{/if}}
            {{/if}}
          </EuiTitle>
          {{#if (or @description (has-block "description"))}}
            <EuiText @grow={{true}} @size="s" class="euiCard__description">
              {{#if (has-block "description")}}
                <p>{{yield to="description"}}</p>
              {{else}}
                <p>{{@description}}</p>
              {{/if}}
            </EuiText>
          {{/if}}
          {{yield to="body"}}
        </div>
        {{#if @betaBadgeProps.label}}
          <span class="euiCard__betaBadgeWrapper">
            <EuiBetaBadge
              class="euiCard__betaBadge"
              @label={{@betaBadgeProps.label}}
              @title={{@betaBadgeProps.title}}
              @tooltipContent={{@betaBadgeProps.tooltipContent}}
            />
          </span>
        {{/if}}
        {{#if (and (eq layout "vertical") (or (has-block "footer") @footer))}}
          <div class={{this.footerClasses}}>
            {{#if (has-block "footer")}}
              {{yield to="footer"}}
            {{else}}
              {{@footer}}
            {{/if}}
          </div>
        {{/if}}
        {{#if @selectable}}
          <EuiCardSelect
            @type={{@selectable.type}}
            @buttonId={{selectableId}}
            @isSelected={{@selectable.isSelected}}
            @isDisabled={{@selectable.isDisabled}}
            @color={{@selectable.color}}
            @isLoading={{@selectable.isLoading}}
            @href={{@selectable.href}}
            @iconSide={{@selectable.iconSide}}
            @flush={{@selectable.flush}}
            {{didInsert (set this "link")}}
            @onClick={{optional @selectable.onClick}}
          />
        {{/if}}
      </EuiPanel>
    {{/let}}
  `, {
  strictMode: true,
  scope: () => ({
    randomId,
    and,
    not,
    or,
    argOrDefault,
    EuiPanel,
    classNames,
    eq,
    notEq,
    EuiIcon,
    EuiTitle,
    set,
    didInsert,
    element,
    on,
    optional,
    EuiText: EuiTextComponent,
    EuiBetaBadge,
    EuiCardSelect: EuiCardSelectComponent
  })
}), (_class = class EuiCardComponent extends Component {
  constructor(...args) {
    super(...args);
    _initializerDefineProperty(this, "link", _descriptor, this);
    _defineProperty(this, "outerOnClick", e => {
      if (this.link && this.link !== e.target) {
        this.link.click();
      }
    });
  }
  get selectableColorClass() {
    const selectable = this.args.selectable;
    return selectable ? `euiCard--isSelectable--${euiCardSelectableColor(selectable.color, selectable.isSelected)}` : undefined;
  }
  get topClasses() {
    return ['euiCard__top', this.args.topClassName].join(' ');
  }
  get contentClasses() {
    return ['euiCard__content', this.args.contentClassName].join(' ');
  }
  get footerClasses() {
    return ['euiCard__footer', this.args.footerClassName].join(' ');
  }
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "link", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return null;
  }
})), _class));

export { EuiCardComponent as default };
//# sourceMappingURL=eui-card.js.map
