import templateOnly from '@ember/component/template-only';
import { setComponentTemplate } from '@ember/component';
import { precompileTemplate } from '@ember/template-compilation';
import { hash, fn } from '@ember/helper';
import { on } from '@ember/modifier';
import sub from 'ember-math-helpers/helpers/sub';
import { eq } from 'ember-truth-helpers';
import EuiButtonIcon from '../eui-button-icon.js';
import EuiI18nComponent from '../eui-i18n.js';

const PreviousButton = setComponentTemplate(precompileTemplate(`
    <EuiI18n
      @token="euiPagination.previousPage"
      @default="Previous page, {page}"
      @values={{hash page=@activePage}}
      as |Token|
    >
      <Token as |previousPage|>
        <EuiI18n
          @token="euiPagination.disabledPreviousPage"
          @default="Previous page"
          as |InnerToken|
        >
          <InnerToken as |disabledPreviousPage|>
            <EuiButtonIcon
              {{on "click" (fn @safeClick (sub @activePage 1))}}
              @iconType="arrowLeft"
              @color="text"
              aria-label={{if
                (eq @activePage 0)
                disabledPreviousPage
                previousPage
              }}
              aria-controls={{if @props.aria-controls @props.aria-controls}}
              href={{if @props.href @props.href}}
              disabled={{eq @props.disabled true}}
              ...attributes
            />
          </InnerToken>
        </EuiI18n>
      </Token>
    </EuiI18n>
  `, {
  strictMode: true,
  scope: () => ({
    EuiI18n: EuiI18nComponent,
    hash,
    EuiButtonIcon,
    eq,
    on,
    fn,
    sub
  })
}), templateOnly("previous-button", "PreviousButton"));

export { PreviousButton as default };
//# sourceMappingURL=previous-button.js.map
