/*
 * Copyright (C) 2021 The Gravitee team (http://gravitee.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
@use 'sass:map';
@use '@angular/material' as mat;
@use '../../../scss' as gio;

$colorNames: lighter, lighter60, lighter40, lighter20, default, darker20, darker40, darker60, darker, disabled, cyan, blue;
$palettes: (
  primary: gio.$mat-primary-palette,
  accent: gio.$mat-accent-palette,
  success: gio.$mat-success-palette,
  warning: gio.$mat-warning-palette,
  error: gio.$mat-error-palette,
);

/* stylelint-disable selector-pseudo-class-no-unknown */
:root {
  @each $paletteName, $palette in $palettes {
    @each $colorName in $colorNames {
      @if map.has-key($palette, $colorName) {
        $color: mat.m2-get-color-from-palette($palette, $colorName);
        $color-contrast: mat.m2-get-color-from-palette($palette, #{$colorName}-contrast);

        --gp--#{$paletteName}__#{$colorName}: #{$color};
        --gp--#{$paletteName}__#{$colorName}-contrast: #{$color-contrast};
      }
    }
  }

  // Special palettes

  @each $colorName in (patch, post, put, get, delete, option, trace, head) {
    $color: mat.m2-get-color-from-palette(gio.$mat-method-palette, $colorName);
    $color-contrast: mat.m2-get-color-from-palette(gio.$mat-method-palette, #{$colorName}-contrast);

    --gp--method__#{$colorName}: #{$color};
    --gp--method__#{$colorName}-contrast: #{$color-contrast};
  }

  @each $colorName in (white, black, disabled) {
    $color: mat.m2-get-color-from-palette(gio.$mat-basic-palette, $colorName);
    $color-contrast: mat.m2-get-color-from-palette(gio.$mat-basic-palette, #{$colorName}-contrast);

    --gp--basic__#{$colorName}: #{$color};
    --gp--basic__#{$colorName}-contrast: #{$color-contrast};
  }

  @each $colorName in (lighter80, lighter70, lighter60, lighter50, lighter40, lighter30, lighter20, lighter10, default) {
    $color: mat.m2-get-color-from-palette(gio.$mat-space-palette, $colorName);
    $color-contrast: mat.m2-get-color-from-palette(gio.$mat-space-palette, #{$colorName}-contrast);

    --gp--space__#{$colorName}: #{$color};
    --gp--space__#{$colorName}-contrast: #{$color-contrast};
  }

  @each $colorName in (darker80, darker70, darker60, darker50, darker40, darker30, darker20, darker10, default) {
    $color: mat.m2-get-color-from-palette(gio.$mat-dove-palette, $colorName);
    $color-contrast: mat.m2-get-color-from-palette(gio.$mat-dove-palette, #{$colorName}-contrast);

    --gp--dove__#{$colorName}: #{$color};
    --gp--dove__#{$colorName}-contrast: #{$color-contrast};
  }

  @each $colorName in (lighter80, lighter60, lighter40, lighter20, default) {
    $color: mat.m2-get-color-from-palette(gio.$mat-cyan-palette, $colorName);
    $color-contrast: mat.m2-get-color-from-palette(gio.$mat-cyan-palette, #{$colorName}-contrast);

    --gp--cyan__#{$colorName}: #{$color};
    --gp--cyan__#{$colorName}-contrast: #{$color-contrast};
  }

  @each $colorName in (lighter80, lighter60, lighter40, lighter20, default) {
    $color: mat.m2-get-color-from-palette(gio.$mat-blue-palette, $colorName);
    $color-contrast: mat.m2-get-color-from-palette(gio.$mat-blue-palette, #{$colorName}-contrast);

    --gp--blue__#{$colorName}: #{$color};
    --gp--blue__#{$colorName}-contrast: #{$color-contrast};
  }
}
