import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { concat, get, fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { or } from 'ember-truth-helpers';
import argOrDefault from '../helpers/arg-or-default.js';
import validatableControl from '../modifiers/validatable-control.js';
import EuiCheckbox from './eui-checkbox.js';
import EuiFormFieldset from './eui-form-fieldset.js';

const EuiCheckboxGroup = setComponentTemplate(precompileTemplate(`
    {{#let
      (argOrDefault @valueKey "id") (argOrDefault @labelKey "label")
      as |valueKey labelKey|
    }}
      {{!template-lint-disable}}
      <input
        tabindex="-1"
        style="opacity: 0px; width:0px; height:0px; position: absolute; top: 40%; border:solid 1px transparent !important; margin:0px !important;"
        class="fake-input-for-html-form-validity"
        {{validatableControl @isInvalid}}
      />
      {{!template-lint-enable}}
      {{#if @legend}}
        <EuiFormFieldset @legend={{@legend}} @compressed={{@compressed}}>
          {{#each @options key=valueKey as |option|}}
            <EuiCheckbox
              form={{@formId}}
              class={{concat "euiCheckboxGroup__item" option.className}}
              {{!@glint-expect-error}}
              @checked={{get @idToSelectedMap (get option valueKey)}}
              @disabled={{or @disabled option.disabled}}
              @compressed={{@compressed}}
              {{!@glint-expect-error}}
              @label={{get option labelKey}}
              {{on "change" (fn @onChange (get option valueKey))}}
            />
          {{/each}}
        </EuiFormFieldset>
      {{else}}
        <div ...attributes>
          {{#each @options key=valueKey as |option|}}
            <EuiCheckbox
              form={{@formId}}
              class={{concat "euiCheckboxGroup__item" option.className}}
              {{!@glint-expect-error}}
              @checked={{get @idToSelectedMap (get option valueKey)}}
              @disabled={{or @disabled option.disabled}}
              @compressed={{@compressed}}
              {{!@glint-expect-error}}
              @label={{get option labelKey}}
              {{on "change" (fn @onChange (get option valueKey))}}
            />
          {{/each}}
        </div>
      {{/if}}
    {{/let}}
  `, {
  strictMode: true,
  scope: () => ({
    argOrDefault,
    validatableControl,
    EuiFormFieldset,
    EuiCheckbox,
    concat,
    get,
    or,
    on,
    fn
  })
}), templateOnly("eui-checkbox-group", "EuiCheckboxGroup"));

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