
@mixin mat-slider-theme($theme) {
  $primary: map-get($theme, accent);
  $accent: map-get($theme, primary);
  $warn: map-get($theme, warn);
  $background: map-get($theme, background);
  $foreground: map-get($theme, foreground);

  $mat-slider-off-color: mat-color($foreground, slider-off);
  $mat-slider-off-focused-color: mat-color($foreground, slider-off-active);
  $mat-slider-disabled-color: mat-color($foreground, slider-off);
  $mat-slider-labeled-min-value-thumb-color: mat-color($foreground, slider-min);
  $mat-slider-labeled-min-value-thumb-label-color: mat-color($foreground, slider-off);
  $mat-slider-tick-opacity: 0.7;
  $mat-slider-tick-color: mat-color($foreground, base, $mat-slider-tick-opacity);
  $mat-slider-tick-size: 2px;

  .mat-slider-track-background {
    background-color: $mat-slider-off-color;
  }

  .mat-primary {
    @include _mat-slider-inner-content-theme($primary);
  }

  .mat-accent {
    @include _mat-slider-inner-content-theme($accent);
  }

  .mat-warn {
    @include _mat-slider-inner-content-theme($warn);
  }

  .mat-slider-focus-ring {
    $opacity: 0.2;
    $color: mat-color($accent, default, $opacity);
    background-color: $color;

    // `mat-color` uses `rgba` for the opacity which won't work with
    // CSS variables so we need to use `opacity` as a fallback.
    @if (type-of($color) != color) {
      opacity: $opacity;
    }
  }

  .mat-slider:hover,
  .cdk-focused {
    .mat-slider-track-background {
      background-color: $mat-slider-off-focused-color;
    }
  }

  .mat-slider-disabled {
    .mat-slider-track-background,
    .mat-slider-track-fill,
    .mat-slider-thumb {
      background-color: $mat-slider-disabled-color;
    }

    &:hover {
      .mat-slider-track-background {
        background-color: $mat-slider-disabled-color;
      }
    }
  }

  .mat-slider-min-value {
    .mat-slider-focus-ring {
      $opacity: 0.12;
      $color: mat-color($foreground, base, $opacity);
      background-color: $color;

      // `mat-color` uses `rgba` for the opacity which won't work with
      // CSS variables so we need to use `opacity` as a fallback.
      @if (type-of($color) != color) {
        opacity: $opacity;
      }
    }

    &.mat-slider-thumb-label-showing {
      .mat-slider-thumb,
      .mat-slider-thumb-label {
        background-color: $mat-slider-labeled-min-value-thumb-color;
      }

      &.cdk-focused {
        .mat-slider-thumb,
        .mat-slider-thumb-label {
          background-color: $mat-slider-labeled-min-value-thumb-label-color;
        }
      }
    }

    &:not(.mat-slider-thumb-label-showing) {
      .mat-slider-thumb {
        border-color: $mat-slider-off-color;
        background-color: transparent;
      }

      &:hover,
      &.cdk-focused {
        .mat-slider-thumb {
          border-color: $mat-slider-off-focused-color;
        }

        &.mat-slider-disabled .mat-slider-thumb {
          border-color: $mat-slider-disabled-color;
        }
      }
    }
  }

  .mat-slider-has-ticks .mat-slider-wrapper::after {
    border-color: $mat-slider-tick-color;

    // `mat-color` uses `rgba` for the opacity which won't work with
    // CSS variables so we need to use `opacity` as a fallback.
    @if (type-of($mat-slider-tick-color) != color) {
      opacity: $mat-slider-tick-opacity;
    }
  }

  .mat-slider-horizontal .mat-slider-ticks {
    background-image: repeating-linear-gradient(to right, $mat-slider-tick-color,
      $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);
    // Firefox doesn't draw the gradient correctly with 'to right'
    // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1314319).
    background-image: -moz-repeating-linear-gradient(0.0001deg, $mat-slider-tick-color,
      $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);

    // `mat-color` uses `rgba` for the opacity which won't work with
    // CSS variables so we need to use `opacity` as a fallback.
    @if (type-of($mat-slider-tick-color) != color) {
      opacity: $mat-slider-tick-opacity;
    }
  }

  .mat-slider-vertical .mat-slider-ticks {
    background-image: repeating-linear-gradient(to bottom, $mat-slider-tick-color,
      $mat-slider-tick-color $mat-slider-tick-size, transparent 0, transparent);

    // `mat-color` uses `rgba` for the opacity which won't work with
    // CSS variables so we need to use `opacity` as a fallback.
    @if (type-of($mat-slider-tick-color) != color) {
      opacity: $mat-slider-tick-opacity;
    }
  }
}
