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

@mixin color($theme, $success-palette, $caution-palette) {
  $config: mat.get-color-config($theme);
  $is-dark-theme: map.get($config, is-dark);
  $primary: map.get($config, primary);
  $accent: map.get($config, accent);
  $warn: map.get($config, warn);

  mtna-notification {
    &.mtna-primary {
      @include _notification-palette($primary, $is-dark-theme);
    }
    &.mtna-accent {
      @include _notification-palette($accent, $is-dark-theme);
    }
    &.mtna-caution {
      @include _notification-palette($caution-palette, $is-dark-theme);
    }
    &.mtna-warn {
      @include _notification-palette($warn, $is-dark-theme);
    }
    &.mtna-success {
      @include _notification-palette($success-palette, $is-dark-theme);
    }
  }
}

@mixin typography($theme) {
}

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

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

@mixin _notification-palette($palette, $is-dark-theme) {
  .notification {
    border-color: mat.get-color-from-palette($palette, default);

    @if ($is-dark-theme) {
      background-color: mat.get-color-from-palette($palette, 900, 0.1);
      color: mat.get-color-from-palette($palette, 50);
    } @else {
      background-color: mat.get-color-from-palette($palette, 50);
      color: mat.get-color-from-palette($palette, 900);
    }
  }
  &.high-contrast .notification {
    @if ($is-dark-theme) {
      color: mat.get-contrast-color-from-palette($palette, 900);
    } @else {
      color: mat.get-contrast-color-from-palette($palette, 50);
    }
  }
}
