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 { modifier } from 'ember-modifier';
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';

const indeterminateModifier = modifier(function invalidateIndeterminate(element, [indeterminate]) {
  if (element) {
    element.indeterminate = indeterminate;
  }
});
const EuiCheckbox = setComponentTemplate(precompileTemplate(`
  {{#let
    (and (has-block "label") (not (argOrDefault @isFakeLabelBlock false)))
    (argOrDefault @id (randomId))
    as |hasLabelBlock id|
  }}
    {{#let
      (classNames
        (if @icon "euiCheckbox--withIcon")
        (if (not (or hasLabelBlock @label)) "euiCheckbox--noLabel")
        (if @compressed "euiCheckbox--compressed")
        "euiCheckbox"
        @className
        @containerClass
      )
      as |classes|
    }}
      <div class={{classes}}>
        <input
          class="euiCheckbox__input"
          type="checkbox"
          id={{id}}
          checked={{@checked}}
          disabled={{@disabled}}
          name={{@name}}
          ...attributes
          {{indeterminateModifier @indeterminate}}
          {{didInsert (optional @inputRef)}}
        />
        <div class="euiCheckbox__square"></div>
        {{#if (or hasLabelBlock @label)}}
          <label
            class={{classNames "euiCheckbox__label" @labelProps.className}}
            for={{id}}
          >
            {{#if hasLabelBlock}}
              {{yield to="label"}}
            {{else}}
              {{@label}}
            {{/if}}
          </label>
        {{/if}}
      </div>
    {{/let}}
  {{/let}}
`, {
  strictMode: true,
  scope: () => ({
    and,
    not,
    argOrDefault,
    randomId,
    classNames,
    or,
    indeterminateModifier,
    didInsert,
    optional
  })
}), templateOnly("eui-checkbox", "EuiCheckbox"));

export { EuiCheckbox as default };
//# sourceMappingURL=eui-checkbox.js.map
