@use 'sass:map';
@use '~@angular/material' as mat;

@mixin color($theme, $success, $incomplete) {
  $config: mat.get-color-config($theme);
  $primary: map.get($config, primary);
  $accent: map.get($config, accent);
  $warn: map.get($config, warn);
  $foreground: map.get($config, foreground);

  mtna-status-circle.mat-primary {
    @include _status-circle-palette($primary, $success, $warn, $foreground, $incomplete);
  }
  mtna-status-circle.mat-accent {
    @include _status-circle-palette($accent, $success, $warn, $foreground, $incomplete);
  }
}

@mixin typography($theme) {
}

@mixin theme($theme, $success, $incomplete) {
  $config: mat.get-color-config($theme);
  @if $config != null and $success != null and $incomplete != null {
    @include color($theme, $success, $incomplete);
  }

  $typography-config: mat.get-typography-config($theme);
  @if $typography-config != null {
    @include typography($theme);
  }
}

@mixin _status-circle-palette($mainPalette, $success, $warn, $foreground, $incomplete) {
  border-color: mat.get-color-from-palette($mainPalette, default);
  &.valid {
    border-color: mat.get-color-from-palette($success, default);
    mat-icon {
      color: mat.get-color-from-palette($success, default);
    }
  }
  &.error {
    border-color: mat.get-color-from-palette($warn, default);
    mat-icon {
      color: mat.get-color-from-palette($warn, default);
    }
  }
  &.incomplete {
    border-color: $incomplete;
    mat-icon {
      color: $incomplete;
    }
  }
  &.optional {
    border-color: mat.get-color-from-palette($foreground, icon);
    &:not(.valid) mat-icon {
      color: mat.get-color-from-palette($foreground, icon);
    }
  }
  &.disabled {
    border-color: mat.get-color-from-palette($foreground, disabled-button);
    mat-icon {
      color: mat.get-color-from-palette($foreground, disabled-button);
    }
  }
}
