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 { fn } from '@ember/helper';
import { on } from '@ember/modifier';
import { action } from '@ember/object';
import { guidFor } from '@ember/object/internals';
import didInsert from '@ember/render-modifiers/modifiers/did-insert';
import { later } from '@ember/runloop';
import optional from 'ember-composable-helpers/helpers/optional';
import onKey from 'ember-keyboard/modifiers/on-key';
import { and, not, or, eq } from 'ember-truth-helpers';
import argOrDefault, { argOrDefaultDecorator } from '../helpers/arg-or-default.js';
import castTo from '../helpers/cast-to.js';
import simpleStyle from '../modifiers/simple-style.js';
import { keys } from '../utils/keys.js';
import { isWithinRange } from '../utils/number/number.js';
import { EUI_THUMB_SIZE } from '../utils/range/index.js';
import EuiFormControlLayoutDelimited from './eui-form-control-layout-delimited.js';
import EuiInputPopoverComponent from './eui-input-popover.js';
import EuiRangeHighlight from './eui-range-highlight.js';
import EuiRangeInput from './eui-range-input.js';
import EuiRangeLabel from './eui-range-label.js';
import EuiRangeSlider from './eui-range-slider.js';
import EuiRangeThumb from './eui-range-thumb.js';
import EuiRangeTrackComponent from './eui-range-track.js';
import EuiRangeWrapper from './eui-range-wrapper.js';

var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5, _descriptor6, _descriptor7, _descriptor8, _descriptor9, _descriptor10, _descriptor11, _descriptor12, _descriptor13, _descriptor14, _descriptor15, _descriptor16;
let EuiDualRangeComponent = setComponentTemplate(precompileTemplate(`
    {{#let
      (and (argOrDefault @isPrependProvided true) (has-block "prepend"))
      (and (argOrDefault @isAppendProvided true) (has-block "append"))
      (and (not (argOrDefault @isFakeMaxBlock false)) (has-block "max"))
      (and (not (argOrDefault @isFakeMinBlock false)) (has-block "min"))
      as |hasPrepend hasAppend hasMaxBlock hasMinBlock|
    }}
      {{#if this.showInputOnly}}
        <EuiInputPopover
          class="euiRange__popover"
          @fullWidth={{this.fullWidth}}
          @isOpen={{this.isPopoverOpen}}
          @closePopover={{this.closePopover}}
          @disableFocusTrap={{true}}
          @onPanelResize={{this.onResize}}
        >
          <:input>
            <EuiFormControlLayoutDelimited
              @fullWidth={{this.fullWidth}}
              @compressed={{this.compressed}}
              @readOnly={{@readOnly}}
              @disabled={{@disabled}}
              @useGroup={{or hasPrepend hasAppend}}
            >
              <:prepend as |prependClasses|>
                {{yield prependClasses to="prepend"}}
              </:prepend>
              <:startControl as |classes|>
                <EuiRangeInput
                  class={{classes}}
                  @digitTolerance={{this.digitTolerance}}
                  @side="min"
                  @min={{this.min}}
                  {{!@glint-expect-error}}
                  @max={{castTo this.upperValue to="number"}}
                  @step={{this.step}}
                  @value={{this.lowerValue}}
                  @disabled={{@disabled}}
                  @compressed={{this.compressed}}
                  @onChange={{this.handleLowerInputChange}}
                  @name="{{@name}}-minValue"
                  @readOnly={{@readOnly}}
                  @autoSize={{false}}
                  @fullWidth={{this.fullWidth}}
                  @isInvalid={{@isInvalid}}
                  @isPrependProvided={{hasAppend}}
                  @isAppendProvided={{hasPrepend}}
                  @controlOnly={{true}}
                  @disable={{@disable}}
                  ...attributes
                  {{on "mousedown" (fn this.setPreventPopoverClose true)}}
                  {{onKey "_all" this.handleInputKeyDown}}
                  {{on
                    "focus"
                    (if
                      this.canShowDropdown this.onInputFocus (optional @onFocus)
                    )
                  }}
                  {{on
                    "blur"
                    (if
                      this.canShowDropdown this.onInputBlur (optional @onBlur)
                    )
                  }}
                  {{on "input" this.handleLowerInputChange}}
                >
                  <:prepend as |classes|>
                    {{yield classes to="prepend"}}
                  </:prepend>
                  <:append as |classes|>
                    {{yield classes to="append"}}
                  </:append>
                </EuiRangeInput>
              </:startControl>
              <:endControl as |classes|>
                <EuiRangeInput
                  class={{classes}}
                  @digitTolerance={{this.digitTolerance}}
                  @side="max"
                  {{!@glint-expect-error}}
                  @min={{castTo this.lowerValue to="number"}}
                  @max={{this.max}}
                  @step={{this.step}}
                  @value={{this.upperValue}}
                  @disabled={{@disabled}}
                  @compressed={{this.compressed}}
                  @name="{{@name}}-maxValue"
                  @readOnly={{@readOnly}}
                  @autoSize={{false}}
                  @fullWidth={{this.fullWidth}}
                  @isInvalid={{@isInvalid}}
                  @isPrependProvided={{hasAppend}}
                  @isAppendProvided={{hasPrepend}}
                  @controlOnly={{true}}
                  @disable={{@disable}}
                  ...attributes
                  {{on "mousedown" (fn this.setPreventPopoverClose true)}}
                  {{onKey "_all" this.handleInputKeyDown}}
                  {{on
                    "focus"
                    (if
                      this.canShowDropdown this.onInputFocus (optional @onFocus)
                    )
                  }}
                  {{on
                    "blur"
                    (if
                      this.canShowDropdown this.onInputBlur (optional @onBlur)
                    )
                  }}
                  {{on "input" this.handleUpperInputChange}}
                >
                  <:prepend as |classes|>
                    {{yield classes to="prepend"}}
                  </:prepend>
                  <:append as |classes|>
                    {{yield classes to="append"}}
                  </:append>
                </EuiRangeInput>
              </:endControl>
              <:append as |appendClasses|>
                {{yield appendClasses to="append"}}
              </:append>
            </EuiFormControlLayoutDelimited>
          </:input>
          <:content>
            <EuiRangeWrapper
              class="euiDualRange"
              @fullWidth={{this.fullWidth}}
              @compressed={{this.compressed}}
            >
              {{#if this.showLabels}}
                <EuiRangeLabel @side="min" @disabled={{@disabled}}>
                  {{#if hasMinBlock}}
                    {{yield this.min to="min"}}
                  {{else}}
                    {{this.min}}
                  {{/if}}
                </EuiRangeLabel>
              {{/if}}
              <EuiRangeTrack
                aria-hidden={{if (eq this.showInput true) "true" "false"}}
                @compressed={{this.compressed}}
                @disabled={{@disabled}}
                @max={{this.max}}
                @min={{this.min}}
                @step={{this.step}}
                @showTicks={{this.showTicks}}
                @tickInterval={{@tickInterval}}
                @ticks={{@ticks}}
                @levels={{this.levels}}
                @onChange={{this.handleSliderChange}}
                @value={{@value}}
              >
                {{#if (and this.showRange this.isValid)}}
                  <EuiRangeHighlight
                    @compressed={{this.compressed}}
                    @hasFocus={{this.hasFocus}}
                    @showTicks={{this.showTicks}}
                    {{!@glint-expect-error}}
                    @min={{castTo this.min to="number"}}
                    {{!@glint-expect-error}}
                    @max={{castTo this.max to="number"}}
                    {{!@glint-expect-error}}
                    @lowerValue={{castTo this.lowerValue to="number"}}
                    {{!@glint-expect-error}}
                    @upperValue={{castTo this.upperValue to="number"}}
                  />
                {{/if}}
                <EuiRangeSlider
                  class="euiDualRange__slider"
                  aria-hidden="true"
                  @id={{this.id}}
                  @name={{@name}}
                  @min={{this.min}}
                  @max={{this.max}}
                  @step={{this.step}}
                  @disabled={{@disabled}}
                  @compressed={{this.compressed}}
                  @onChange={{this.handleSliderChange}}
                  @showTicks={{this.showTicks}}
                  @hasFocus={{this.hasFocus}}
                  tabindex="-1"
                  @showRange={{this.showRange}}
                  ...attributes
                  {{didInsert this.didInsertRangeSlider}}
                  {{on "mousedown" (fn this.setPreventPopoverClose true)}}
                  {{on "focus" (optional @onFocus)}}
                  {{on "blur" (optional @onBlur)}}
                  {{on "input" this.handleSliderChange}}
                />
                {{#if this.rangeSliderRefAvailable}}
                  <EuiRangeThumb
                    @min={{this.min}}
                    {{!@glint-expect-error}}
                    @max={{castTo this.upperValue to="number"}}
                    {{!@glint-expect-error}}
                    @value={{this.lowerValue}}
                    @disabled={{@disabled}}
                    @showTicks={{this.showTicks}}
                    @showInput={{not this.showInput}}
                    aria-describedby={{@ariaDescribedby}}
                    aria-label={{@ariaLabel}}
                    {{simpleStyle this.calculateLowerValueThumbPositionStyle}}
                    {{on "focus" this.onThumbFocus}}
                    {{on "blur" this.onThumbBlur}}
                    {{onKey "_all" this.handleLowerKeyDown}}
                  />
                  <EuiRangeThumb
                    {{!@glint-expect-error}}
                    @min={{castTo this.lowerValue to="number"}}
                    @max={{this.max}}
                    {{!@glint-expect-error}}
                    @value={{this.upperValue}}
                    @disabled={{@disabled}}
                    @showTicks={{this.showTicks}}
                    @showInput={{not this.showInput}}
                    aria-describedby={{@ariaDescribedby}}
                    aria-label={{@ariaLabel}}
                    {{simpleStyle this.calculateUpperValueThumbPositionStyle}}
                    {{on "focus" this.onThumbFocus}}
                    {{on "blur" this.onThumbBlur}}
                    {{onKey "_all" this.handleUpperKeyDown}}
                  />
                {{/if}}
              </EuiRangeTrack>
              {{#if this.showLabels}}
                <EuiRangeLabel @disabled={{@disabled}}>
                  {{#if hasMaxBlock}}
                    {{yield this.max to="max"}}
                  {{else}}
                    {{this.max}}
                  {{/if}}
                </EuiRangeLabel>
              {{/if}}
            </EuiRangeWrapper>
          </:content>
        </EuiInputPopover>
      {{else}}
        <EuiRangeWrapper
          class="euiDualRange"
          @fullWidth={{this.fullWidth}}
          @compressed={{this.compressed}}
        >
          {{#if this.showInput}}
            <EuiRangeInput
              @digitTolerance={{this.digitTolerance}}
              @side="min"
              @min={{this.min}}
              {{!@glint-expect-error}}
              @max={{castTo this.upperValue to="number"}}
              @step={{this.step}}
              @value={{this.lowerValue}}
              @disabled={{@disabled}}
              @compressed={{this.compressed}}
              @onChange={{this.handleLowerInputChange}}
              @name="{{@name}}-minValue"
              @readOnly={{@readOnly}}
              @fullWidth={{this.fullWidth}}
              @isInvalid={{@isInvalid}}
              @isPrependProvided={{false}}
              @isAppendProvided={{false}}
              @controlOnly={{true}}
              @disable={{@disable}}
              ...attributes
              {{onKey "_all" this.handleInputKeyDown}}
              {{on "focus" (optional @onFocus)}}
              {{on "blur" (optional @onBlur)}}
              {{on "input" this.handleLowerInputChange}}
            />
            <div class="euiRange__horizontalSpacer"></div>
          {{/if}}
          {{#if this.showLabels}}
            <EuiRangeLabel @side="min" @disabled={{@disabled}}>
              {{#if hasMinBlock}}
                {{yield this.min to="min"}}
              {{else}}
                {{this.min}}
              {{/if}}
            </EuiRangeLabel>
          {{/if}}
          <EuiRangeTrack
            aria-hidden={{if (eq this.showInput true) "true" "false"}}
            @compressed={{this.compressed}}
            @disabled={{@disabled}}
            @max={{this.max}}
            @min={{this.min}}
            @step={{this.step}}
            @showTicks={{this.showTicks}}
            @tickInterval={{@tickInterval}}
            @ticks={{@ticks}}
            @levels={{this.levels}}
            @onChange={{this.handleSliderChange}}
            @value={{@value}}
          >
            {{#if (and this.showRange this.isValid)}}
              <EuiRangeHighlight
                @compressed={{this.compressed}}
                @hasFocus={{this.hasFocus}}
                @showTicks={{this.showTicks}}
                {{!@glint-expect-error}}
                @min={{castTo this.min to="number"}}
                {{!@glint-expect-error}}
                @max={{castTo this.max to="number"}}
                {{!@glint-expect-error}}
                @lowerValue={{castTo this.lowerValue to="number"}}
                {{!@glint-expect-error}}
                @upperValue={{castTo this.upperValue to="number"}}
              />
            {{/if}}
            <EuiRangeSlider
              class="euiDualRange__slider"
              aria-hidden="true"
              @id={{this.id}}
              @name={{@name}}
              @min={{this.min}}
              @max={{this.max}}
              @step={{this.step}}
              @disabled={{@disabled}}
              @compressed={{this.compressed}}
              @onChange={{this.handleSliderChange}}
              @showTicks={{this.showTicks}}
              @hasFocus={{this.hasFocus}}
              tabindex="-1"
              @showRange={{this.showRange}}
              ...attributes
              {{didInsert this.didInsertRangeSlider}}
              {{on "mousedown" (fn this.setPreventPopoverClose true)}}
              {{on "focus" (optional @onFocus)}}
              {{on "blur" (optional @onBlur)}}
              {{on "input" this.handleSliderChange}}
            />
            {{#if this.rangeSliderRefAvailable}}
              <EuiRangeThumb
                @min={{this.min}}
                {{!@glint-expect-error}}
                @max={{castTo this.upperValue to="number"}}
                {{!@glint-expect-error}}
                @value={{this.lowerValue}}
                @disabled={{@disabled}}
                @showTicks={{this.showTicks}}
                @showInput={{not this.showInput}}
                aria-describedby={{@ariaDescribedby}}
                aria-label={{@ariaLabel}}
                {{simpleStyle this.calculateLowerValueThumbPositionStyle}}
                {{on "focus" this.onThumbFocus}}
                {{on "blur" this.onThumbBlur}}
                {{!@glint-expect-error}}
                {{on "click" this.handleLowerKeyDown}}
              />
              <EuiRangeThumb
                {{!@glint-expect-error}}
                @min={{castTo this.lowerValue to="number"}}
                @max={{this.max}}
                {{!@glint-expect-error}}
                @value={{this.upperValue}}
                @disabled={{@disabled}}
                @showTicks={{this.showTicks}}
                @showInput={{not this.showInput}}
                aria-describedby={{@ariaDescribedby}}
                aria-label={{@ariaLabel}}
                {{simpleStyle this.calculateUpperValueThumbPositionStyle}}
                {{on "focus" this.onThumbFocus}}
                {{on "blur" this.onThumbBlur}}
                {{on "keydown" this.handleUpperKeyDown}}
              />
            {{/if}}
          </EuiRangeTrack>
          {{#if this.showLabels}}
            <EuiRangeLabel @disabled={{@disabled}}>
              {{#if hasMaxBlock}}
                {{yield this.max to="max"}}
              {{else}}
                {{this.max}}
              {{/if}}
            </EuiRangeLabel>
          {{/if}}
          {{#if this.showInput}}
            <div class="euiRange__horizontalSpacer"></div>
            {{! maxinput }}
            <EuiRangeInput
              @digitTolerance={{this.digitTolerance}}
              @side="max"
              {{!@glint-expect-error}}
              @min={{castTo this.lowerValue to="number"}}
              @max={{this.max}}
              @step={{this.step}}
              @value={{this.upperValue}}
              @disabled={{@disabled}}
              @compressed={{this.compressed}}
              @name="{{@name}}-maxValue"
              @readOnly={{@readOnly}}
              @fullWidth={{this.fullWidth}}
              @isInvalid={{@isInvalid}}
              @controlOnly={{this.showInputOnly}}
              @isPrependProvided={{false}}
              @isAppendProvided={{false}}
              @disable={{@disable}}
              ...attributes
              {{onKey "_all" this.handleInputKeyDown}}
              {{on "focus" (optional @onFocus)}}
              {{on "blur" (optional @onBlur)}}
              {{on "input" this.handleUpperInputChange}}
            />
          {{/if}}
        </EuiRangeWrapper>
      {{/if}}
    {{/let}}
  `, {
  strictMode: true,
  scope: () => ({
    and,
    argOrDefault,
    not,
    EuiInputPopover: EuiInputPopoverComponent,
    EuiFormControlLayoutDelimited,
    or,
    EuiRangeInput,
    castTo,
    on,
    fn,
    onKey,
    optional,
    EuiRangeWrapper,
    EuiRangeLabel,
    EuiRangeTrack: EuiRangeTrackComponent,
    eq,
    EuiRangeHighlight,
    EuiRangeSlider,
    didInsert,
    EuiRangeThumb,
    simpleStyle
  })
}), (_dec = argOrDefaultDecorator(0), _dec2 = argOrDefaultDecorator(100), _dec3 = argOrDefaultDecorator(1), _dec4 = argOrDefaultDecorator(false), _dec5 = argOrDefaultDecorator(false), _dec6 = argOrDefaultDecorator(false), _dec7 = argOrDefaultDecorator(false), _dec8 = argOrDefaultDecorator(true), _dec9 = argOrDefaultDecorator(false), _dec10 = argOrDefaultDecorator([]), (_class = class EuiDualRangeComponent extends Component {
  constructor(...args) {
    super(...args);
    // Defaults
    _initializerDefineProperty(this, "min", _descriptor, this);
    _initializerDefineProperty(this, "max", _descriptor2, this);
    _initializerDefineProperty(this, "step", _descriptor3, this);
    _initializerDefineProperty(this, "fullWidth", _descriptor4, this);
    _initializerDefineProperty(this, "compressed", _descriptor5, this);
    _initializerDefineProperty(this, "showLabels", _descriptor6, this);
    _initializerDefineProperty(this, "showInput", _descriptor7, this);
    _initializerDefineProperty(this, "showRange", _descriptor8, this);
    _initializerDefineProperty(this, "showTicks", _descriptor9, this);
    _initializerDefineProperty(this, "levels", _descriptor10, this);
    //State
    _initializerDefineProperty(this, "id", _descriptor11, this);
    _initializerDefineProperty(this, "hasFocus", _descriptor12, this);
    _initializerDefineProperty(this, "rangeSliderRefAvailable", _descriptor13, this);
    _initializerDefineProperty(this, "isPopoverOpen", _descriptor14, this);
    _initializerDefineProperty(this, "rangeWidth", _descriptor15, this);
    _initializerDefineProperty(this, "isVisible", _descriptor16, this);
    ///
    _defineProperty(this, "preventPopoverClose", false);
    _defineProperty(this, "rangeSliderRef", null);
  }
  didInsertRangeSlider(ref) {
    this.rangeSliderRef = ref;
    this.rangeSliderRefAvailable = !!ref;
    this.rangeWidth = ref ? ref.clientWidth : undefined;
    if (this.rangeSliderRef?.clientWidth && !this.isVisible) {
      this.isVisible = true;
    }
  }
  get lowerValue() {
    return this.args.value ? this.args.value[0] : this.min;
  }
  get upperValue() {
    return this.args.value ? this.args.value[1] : this.max;
  }
  get lowerValueIsValid() {
    return isWithinRange(this.min, this.upperValue, this.lowerValue);
  }
  get upperValueIsValid() {
    return isWithinRange(this.lowerValue, this.max, this.upperValue);
  }
  get isValid() {
    return this.lowerValueIsValid && this.upperValueIsValid;
  }
  _determineInvalidThumbMovement(newVal, lower, upper, e) {
    // If the values are invalid, find whether the new value is in the upper
    // or lower half and move the appropriate handle to the new value,
    // while the other handle gets moved to the opposite bound (if invalid)
    const lowerHalf = Math.abs(this.max - this.min) / 2 + this.min;
    const newValIsLow = isWithinRange(this.min, lowerHalf, newVal);
    if (newValIsLow) {
      lower = newVal;
      upper = !this.upperValueIsValid ? this.max : upper;
    } else {
      lower = !this.lowerValueIsValid ? this.min : lower;
      upper = newVal;
    }
    this._handleOnChange(lower, upper, e);
  }
  _determineValidThumbMovement(newVal, lower, upper, e) {
    // Lower thumb targeted or right-moving swap has occurred
    if (Math.abs(lower - newVal) < Math.abs(upper - newVal)) {
      lower = newVal;
    }
    // Upper thumb targeted or left-moving swap has occurred
    else {
      upper = newVal;
    }
    this._handleOnChange(lower, upper, e);
  }
  _determineThumbMovement(newVal, e) {
    // Determine thumb movement based on slider interaction
    if (!this.isValid) {
      // Non-standard positioning follows
      this._determineInvalidThumbMovement(newVal, this.lowerValue, this.upperValue, e);
    } else {
      // Standard positioning based on click event proximity to thumb locations
      this._determineValidThumbMovement(newVal, this.lowerValue, this.upperValue, e);
    }
  }
  _handleOnChange(lower, upper, e) {
    const isValid = isWithinRange(this.min, upper, lower) && isWithinRange(lower, this.max, upper);
    this.args.onChange([lower, upper], isValid, e);
  }
  handleSliderChange(e) {
    this._determineThumbMovement(Number(e.currentTarget.value), e);
  }
  _resetToRangeEnds(e) {
    // Arbitrary decision to pass `min` instead of `max`. Result is the same.
    this._determineInvalidThumbMovement(this.min, this.lowerValue, this.upperValue, e);
  }
  _isDirectionalKeyPress(event) {
    return [keys.ARROW_UP, keys.ARROW_RIGHT, keys.ARROW_DOWN, keys.ARROW_LEFT].indexOf(event.key) > -1;
  }
  handleInputKeyDown(e) {
    // Relevant only when initial values are both `''` and `showInput` is set
    if (this._isDirectionalKeyPress(e) && !this.isValid) {
      e.preventDefault();
      this._resetToRangeEnds(e);
    }
  }
  handleLowerInputChange(e) {
    this._handleOnChange(e.target.value, this.upperValue, e);
  }
  handleUpperInputChange(e) {
    this._handleOnChange(this.lowerValue, e.target.value, e);
  }
  _handleKeyDown(value, event) {
    let newVal = Number(value);
    let stepRemainder = 0;
    const step = this.args.step || 1;
    switch (event.key) {
      case keys.ARROW_UP:
      case keys.ARROW_RIGHT:
        event.preventDefault();
        newVal += step;
        stepRemainder = (newVal - this.min) % step;
        if (step !== 1 && stepRemainder > 0) {
          newVal = newVal - stepRemainder;
        }
        break;
      case keys.ARROW_DOWN:
      case keys.ARROW_LEFT:
        event.preventDefault();
        newVal -= step;
        stepRemainder = (newVal - this.min) % step;
        if (step !== 1 && stepRemainder > 0) {
          newVal = newVal + (step - stepRemainder);
        }
        break;
    }
    return newVal;
  }
  handleLowerKeyDown(event) {
    let lower = this.lowerValue;
    switch (event.key) {
      case keys.TAB:
        return;
      default:
        if (!this.lowerValueIsValid) {
          // Relevant only when initial value is `''` and `showInput` is not set
          event.preventDefault();
          this._resetToRangeEnds(event);
          return;
        }
        lower = this._handleKeyDown(lower, event);
    }
    if (lower >= this.upperValue || lower < this.min) return;
    this._handleOnChange(lower, this.upperValue, event);
  }
  handleUpperKeyDown(event) {
    let upper = this.upperValue;
    switch (event.key) {
      case keys.TAB:
        return;
      default:
        if (!this.upperValueIsValid) {
          // Relevant only when initial value is `''` and `showInput` is not set
          event.preventDefault();
          this._resetToRangeEnds(event);
          return;
        }
        upper = this._handleKeyDown(upper, event);
    }
    if (upper <= this.lowerValue || upper > this.max) return;
    this._handleOnChange(this.lowerValue, upper, event);
  }
  calculateThumbPositionStyle(value, width) {
    // Calculate the left position based on value
    const decimal = (value - this.min) / (this.max - this.min);
    // Must be between 0-100%
    let valuePosition = decimal <= 1 ? decimal : 1;
    valuePosition = valuePosition >= 0 ? valuePosition : 0;
    const trackWidth = this.args.showInput === 'inputWithPopover' && !!width ? width : this.rangeSliderRef?.clientWidth;
    let thumbToTrackRatio = 0;
    if (trackWidth) {
      thumbToTrackRatio = EUI_THUMB_SIZE / trackWidth;
    } else {
      thumbToTrackRatio = EUI_THUMB_SIZE / 1;
    }
    const trackPositionScale = (1 - thumbToTrackRatio) * 100;
    return {
      left: `${valuePosition * trackPositionScale}%`
    };
  }
  setPreventPopoverClose(value) {
    this.preventPopoverClose = value;
  }
  get calculateLowerValueThumbPositionStyle() {
    return this.calculateThumbPositionStyle(Number(this.lowerValue) || this.min, this.rangeWidth);
  }
  get calculateUpperValueThumbPositionStyle() {
    return this.calculateThumbPositionStyle(Number(this.upperValue) || this.max, this.rangeWidth);
  }
  toggleHasFocus() {
    this.hasFocus = !this.hasFocus;
  }
  onThumbFocus(e) {
    if (this.args.onFocus) {
      this.args.onFocus(e);
    }
    this.hasFocus = true;
  }
  onThumbBlur(e) {
    if (this.args.onBlur) {
      this.args.onBlur(e);
    }
    this.hasFocus = false;
  }
  onInputFocus(e) {
    if (this.args.onFocus) {
      this.args.onFocus(e);
    }
    this.preventPopoverClose = true;
    this.isPopoverOpen = true;
  }
  onInputBlur(e) {
    later(this, () => {
      // Safari does not recognize any focus-related eventing for input[type=range]
      // making it impossible to capture its state using active/focus/relatedTarget
      // Instead, a prevention flag is set on mousedown, with a waiting period here.
      // Mousedown is viable because in the popover case, it is inaccessible via keyboard (intentionally)
      if (this.preventPopoverClose) {
        this.preventPopoverClose = false;
        return;
      }
      if (this.args.onBlur) {
        this.args.onBlur(e);
      }
      this.closePopover();
    }, 200);
  }
  closePopover() {
    this.preventPopoverClose = false;
    this.isPopoverOpen = false;
  }
  onResize(width) {
    this.rangeWidth = width;
  }
  get digitTolerance() {
    return Math.max(String(this.min).length, String(this.max).length);
  }
  get showInputOnly() {
    return this.showInput === 'inputWithPopover';
  }
  get canShowDropdown() {
    return this.showInputOnly && !this.args.readOnly && !this.args.disabled;
  }
}, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "min", [_dec], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "max", [_dec2], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "step", [_dec3], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "fullWidth", [_dec4], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "compressed", [_dec5], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor6 = _applyDecoratedDescriptor(_class.prototype, "showLabels", [_dec6], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor7 = _applyDecoratedDescriptor(_class.prototype, "showInput", [_dec7], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor8 = _applyDecoratedDescriptor(_class.prototype, "showRange", [_dec8], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor9 = _applyDecoratedDescriptor(_class.prototype, "showTicks", [_dec9], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor10 = _applyDecoratedDescriptor(_class.prototype, "levels", [_dec10], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor11 = _applyDecoratedDescriptor(_class.prototype, "id", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return this.args.id || guidFor({});
  }
}), _descriptor12 = _applyDecoratedDescriptor(_class.prototype, "hasFocus", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return false;
  }
}), _descriptor13 = _applyDecoratedDescriptor(_class.prototype, "rangeSliderRefAvailable", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return false;
  }
}), _descriptor14 = _applyDecoratedDescriptor(_class.prototype, "isPopoverOpen", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return false;
  }
}), _descriptor15 = _applyDecoratedDescriptor(_class.prototype, "rangeWidth", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: null
}), _descriptor16 = _applyDecoratedDescriptor(_class.prototype, "isVisible", [tracked], {
  configurable: true,
  enumerable: true,
  writable: true,
  initializer: function () {
    return true;
  }
}), _applyDecoratedDescriptor(_class.prototype, "didInsertRangeSlider", [action], Object.getOwnPropertyDescriptor(_class.prototype, "didInsertRangeSlider"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_determineInvalidThumbMovement", [action], Object.getOwnPropertyDescriptor(_class.prototype, "_determineInvalidThumbMovement"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_determineValidThumbMovement", [action], Object.getOwnPropertyDescriptor(_class.prototype, "_determineValidThumbMovement"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_determineThumbMovement", [action], Object.getOwnPropertyDescriptor(_class.prototype, "_determineThumbMovement"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_handleOnChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "_handleOnChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleSliderChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleSliderChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_resetToRangeEnds", [action], Object.getOwnPropertyDescriptor(_class.prototype, "_resetToRangeEnds"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_isDirectionalKeyPress", [action], Object.getOwnPropertyDescriptor(_class.prototype, "_isDirectionalKeyPress"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleInputKeyDown", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleInputKeyDown"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleLowerInputChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleLowerInputChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleUpperInputChange", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleUpperInputChange"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "_handleKeyDown", [action], Object.getOwnPropertyDescriptor(_class.prototype, "_handleKeyDown"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleLowerKeyDown", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleLowerKeyDown"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleUpperKeyDown", [action], Object.getOwnPropertyDescriptor(_class.prototype, "handleUpperKeyDown"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "calculateThumbPositionStyle", [action], Object.getOwnPropertyDescriptor(_class.prototype, "calculateThumbPositionStyle"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "setPreventPopoverClose", [action], Object.getOwnPropertyDescriptor(_class.prototype, "setPreventPopoverClose"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "toggleHasFocus", [action], Object.getOwnPropertyDescriptor(_class.prototype, "toggleHasFocus"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onThumbFocus", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onThumbFocus"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onThumbBlur", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onThumbBlur"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onInputFocus", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onInputFocus"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onInputBlur", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onInputBlur"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "closePopover", [action], Object.getOwnPropertyDescriptor(_class.prototype, "closePopover"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "onResize", [action], Object.getOwnPropertyDescriptor(_class.prototype, "onResize"), _class.prototype)), _class)));

export { EuiDualRangeComponent as default };
//# sourceMappingURL=eui-dual-range.js.map
