/**
 * @license
 * Copyright 2020 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

@use 'sass:list';
@use 'sass:map';
@use '@material/circular-progress' as circularprogress;
@use '@material/theme/css';
@use '@material/theme/theme-color';

$light-theme: (
  bar-color: theme-color.prop-value(primary),
  bar-indeterminate-colors: (
    theme-color.prop-value(primary),
    theme-color.prop-value(primary),
    theme-color.prop-value(primary),
    theme-color.prop-value(primary),
  ),
  track-color: transparent,
);

@mixin theme($theme: $light-theme) {
  $bar-color: map.get($theme, bar-color);
  $bar-indeterminate-colors: map.get($theme, bar-indeterminate-colors);
  $track-color: map.get($theme, track-color);

  @include css.declaration(--mdc-theme-primary, $bar-color);

  @if $bar-indeterminate-colors {
    @if list.length($bar-indeterminate-colors) != 4 {
      @error "`mwc-circular-progress-four-colors` accepts exactly 4 colors";
    }

    @include css.declaration(
      --mdc-circular-progress-bar-color-1,
      nth($bar-indeterminate-colors, 1)
    );
    @include css.declaration(
      --mdc-circular-progress-bar-color-2,
      nth($bar-indeterminate-colors, 2)
    );
    @include css.declaration(
      --mdc-circular-progress-bar-color-3,
      nth($bar-indeterminate-colors, 3)
    );
    @include css.declaration(
      --mdc-circular-progress-bar-color-4,
      nth($bar-indeterminate-colors, 4)
    );
  }

  @include css.declaration(--mdc-circular-progress-track-color, $track-color);
}
