/**
 *
 * @ai-apps/angular v2.152.0 | colors.scss
 *
 * Copyright 2014, 2023 IBM
 *
 * 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.
 */


@import './color-palatte.scss';

@function getThemeColors() {
	@if $carbon--theme ==
		$carbon--theme--g100 or
		$carbon--theme ==
		$carbon--theme--g90
	{
		@return color-property(null, $dark-theme-colors);
	} @else {
		@return color-property(null, $white-theme-colors);
	}
}

@function getGradientColors() {
	$monochrome: color-property(null, $monochrome-quantize-colors);
	$divergent: color-property(null, $divergent-quantize-colors);

	@return map-merge($monochrome, $divergent);
}

@function getLegendAreaItemColors() {
	@if $carbon--theme ==
		$carbon--theme--g100 or
		$carbon--theme ==
		$carbon--theme--g90
	{
		@return color-property(null, $dark-theme-legend-area-item-colors);
	} @else {
		@return color-property(null, $white-theme-legend-area-item-colors);
	}
}

@function color-property($name, $theme-colors) {
	$color-items: ();

	@if type-of($theme-colors) == map {
		@each $category, $value in $theme-colors {
			@if $name == null {
				$color-items: map-merge(
					$color-items,
					color-property('#{$category}', $value)
				);
			} @else {
				$color-items: map-merge(
					$color-items,
					color-property('#{$name}-#{$category}', $value)
				);
			}
		}
		@return $color-items;
	} @else {
		@return (#{$name}: $theme-colors);
	}
}

@function gradient-color-property($name, $theme-colors) {
	$color-items: ();

	@if type-of($theme-colors) == map {
		@each $category, $value in $theme-colors {
			@if $name == null {
				$color-items: map-merge(
					$color-items,
					color-property('#{$category}', $value)
				);
			} @else {
				$color-items: map-merge(
					$color-items,
					color-property('#{$name}-#{$category}', $value)
				);
			}
		}
		@return $color-items;
	} @else {
		@return (#{$name}: $theme-colors);
	}
}

.#{$prefix}--#{$charts-prefix}--chart-wrapper {
	$color-map: map-merge(getThemeColors(), getGradientColors());

	@each $token, $color in $color-map {
		.fill-#{$token} {
			fill: $color;

			&.hovered {
				fill: darken($color, 7%);
				@include default_transition;
			}
		}

		.background-#{$token} {
			background-color: $color;

			&.hovered {
				background-color: darken($color, 7%);
				@include default_transition;
			}
		}

		.stroke-#{$token} {
			stroke: $color;
		}

		.stop-color-#{$token} {
			stop-color: $color;
		}
	}
}

.#{$prefix}--#{$charts-prefix}--tooltip {
	$color-map: getThemeColors();

	@each $token, $color in $color-map {
		.tooltip-#{$token} {
			background-color: $color;
		}
	}
}

.#{$prefix}--#{$charts-prefix}--legend {
	$area-item-color-map: getLegendAreaItemColors();

	.additional > .icon {
		@each $token, $color in $area-item-color-map {
			.area-#{$token} {
				fill: $color;

				@if $carbon--theme ==
					$carbon--theme--g100 or
					$carbon--theme ==
					$carbon--theme--g90
				{
					stroke: $dark-theme-legend-area-item-stroke;
				} @else {
					stroke: $white-theme-legend-area-item-stroke;
				}
			}
		}

		.quartile {
			&-wrapper {
				@if $carbon--theme ==
					$carbon--theme--g100 or
					$carbon--theme ==
					$carbon--theme--g90
				{
					fill: getColorValue('gray', 80);
					stroke: $dark-theme-legend-area-item-stroke;
				} @else {
					fill: getColorValue('gray', 20);
					stroke: $white-theme-legend-area-item-stroke;
				}
			}

			&-line {
				@if $carbon--theme ==
					$carbon--theme--g100 or
					$carbon--theme ==
					$carbon--theme--g90
				{
					fill: #fff;
				} @else {
					fill: #000;
				}
			}
		}
	}
}
