/**
 * @license
 * Copyright Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
///
/// Adapted and influenced from [Material Web](https://github.com/material-components/material-web).
/// The original source code can be found at [GitHub](https://github.com/material-components/material-web/blob/main/linearprogress/lib/_linear-progress.scss)
///

@use './token-utils' as *;

@mixin keyframes {
  @include _directional-keyframes('ltr');
  @include _directional-keyframes('rtl');

  @keyframes primary-indeterminate-scale {
    0% {
      transform: scaleX(0.08);
    }
  
    36.65% {
      animation-timing-function: cubic-bezier(0.334731, 0.12482, 0.785844, 1);
      transform: scaleX(0.08);
    }
  
    69.15% {
      animation-timing-function: cubic-bezier(0.06, 0.11, 0.6, 1);
      transform: scaleX(0.661479);
    }
  
    100% {
      transform: scaleX(0.08);
    }
  }
  
  @keyframes secondary-indeterminate-scale {
    0% {
      animation-timing-function: cubic-bezier(
        0.205028,
        0.057051,
        0.57661,
        0.453971
      );
      transform: scaleX(0.08);
    }
  
    19.15% {
      animation-timing-function: cubic-bezier(
        0.152313,
        0.196432,
        0.648374,
        1.00432
      );
      transform: scaleX(0.457104);
    }
  
    44.15% {
      animation-timing-function: cubic-bezier(
        0.257759,
        -0.003163,
        0.211762,
        1.38179
      );
      transform: scaleX(0.72796);
    }
  
    100% {
      transform: scaleX(0.08);
    }
  }
}

// Generates keyframes for ltr and rtl.
@mixin _directional-keyframes($dir) {
  $is-rtl: $dir == 'rtl';
  $sign: if($is-rtl, -1, 1);
  $suffix: if($is-rtl, '-rtl', '');

  @keyframes buffering#{$suffix} {
    0% {
      transform: translateX(calc(#{$sign} * #{token(track-background-width, custom)}));
    }
  }

  @keyframes primary-indeterminate-translate#{$suffix} {
    0% {
      transform: translateX(0);
    }

    20% {
      animation-timing-function: cubic-bezier(0.5, 0, 0.701732, 0.495819);
      transform: translateX(0);
    }

    59.15% {
      animation-timing-function: cubic-bezier(
        0.302435,
        0.381352,
        0.55,
        0.956352
      );
      transform: translateX(calc(#{$sign} * 83.6714%));
    }

    100% {
      transform: translateX(calc(#{$sign} * 200.611%));
    }
  }

  @keyframes secondary-indeterminate-translate#{$suffix} {
    0% {
      animation-timing-function: cubic-bezier(0.15, 0, 0.515058, 0.409685);
      transform: translateX(0);
    }

    25% {
      animation-timing-function: cubic-bezier(0.31033, 0.284058, 0.8, 0.733712);
      transform: translateX(calc(#{$sign} * 37.6519%));
    }

    48.35% {
      animation-timing-function: cubic-bezier(0.4, 0.627035, 0.6, 0.902026);
      transform: translateX(calc(#{$sign} * 84.3862%));
    }

    100% {
      transform: translateX(calc(#{$sign} * 160.278%));
    }
  }
}
