@use "sass:math";
@function v($var, $fallback: null) {
    @if ($fallback) {
        @return var(--#{$var}, #{$fallback});
    }
    @else {
        @return var(--#{$var});
    }
}
@function map-deep-get($map, $keys...) {
    @each $key in $keys {
        @debug #{$map};
        $map: map-get($map, $key);
    }
    @return $map;
}
@function toRGB($color) {
    @return "rgb(" + red($color) + ", " + green($color) + ", " + blue($color)+ ")";
}
@function getContrast($color) {
    $color-brightness: round((red($color) * 299) + (green($color) * 587) + math.div((blue($color) * 114), 1000));
    $light-color: round((red(#fff) * 299) + (green(#fff) * 587) + math.div((blue(#fff) * 114), 1000));
    @if abs($color-brightness) < math.div($light-color, 2) {
        @return white;
    }
    @else {
        @return map-get($ecl-base-colors, 'grey-100');
    }
}
@function getColor($shade: primary, $hue: 100) {
    $selected-shade: map-get($eui-base-tokens-colors, $shade);
    @if ($selected-shade) {
        @return map-get($selected-shade, $hue);
    }
    @else {
        @return black;
    }
    @return $selected-color;
}

/**
   * ECL color variants formula
   * Applies tint or shade of base color provided
   *
   * @param color: base color, has variant of 100
   * @param variant: number in range between 0 - 200
   *                 100 - neutral variant, no changes
   *                 0 - 99: brightens base color by mixing in white color, the lower, the brighter
   *                 99 - 200: darkens base color by mixing in black color, the bigger, the darker
   *
   * @return color variant of provided base color
   *
   * @examples
   *
   * // provides 30% darker pink color
   * background-color: eui-color-variant(pink, 130);
   *
   * // provides 95% lighter pink color
   * background-color: eui-color-variant(pink, 5);
   */
@function eui-color-variant($color, $variant: 100) {
    @if ($variant < 100) {
        @return mix(#ffffff, $color, (100 - $variant) * 1%);
    }
    @else {
        @return mix(#000000, $color, ($variant - 100) * 1%);
    }
}
@function new-breakpoint($query: $feature $value) {
    @if length($query) == 1 {
        $query: $default-feature nth($query, 1);
    }
    @else if is-even(length($query)) {
        $query: append($query, 12);
    }
    @return $query;
}
@function strip-units($value) {
    @return math.div($value, $value * 0 + 1);
}
@function to-rem($pxval) {
    @if not unitless($pxval) {
        $pxval: strip-units($pxval);
    }
    $base: 16px;
    @if not unitless($base) {
        $base: strip-units($base);
    }
    @return math.div($pxval, $base) * 1rem;
}
