@use 'sass:color'
@use 'sass:map'
@use 'sass:meta'

@function map-deep-get($map, $keys...)
  @each $key in $keys
    $map: map.get($map, $key)

  @return $map

// Adapted from https://gist.github.com/pentzzsolt/4949bbd7691d43d00616dc4f1451cae9#file-non-destructive-map-merge-4-scss
@function map-deep-merge($parent-map, $child-map)
  $result: $parent-map

  @each $key, $child in $child-map
    $parent-has-key: map.has-key($result, $key)
    $parent-value: map.get($result, $key)
    $parent-type: meta.type-of($parent-value)
    $child-type: meta.type-of($child)
    $parent-is-map: $parent-type == map
    $child-is-map: $child-type == map

    @if (not $parent-has-key) or ($parent-type != $child-type) or (not ($parent-is-map and $child-is-map))
      $result: map.merge($result, ( $key: $child ))

    @else
      $result: map.merge($result, ( $key: map-deep-merge($parent-value, $child) ))

  @return $result

@function convert-hex-to-rgba($map, $theme:light, $shade:500, $opacity:1)
  $red: color.red(map-get(map-get($map, $theme), $shade))
  $green: color.green(map-get(map-get($map, $theme), $shade))
  $blue: color.blue(map-get(map-get($map, $theme), $shade))

  @return rgba($red, $green, $blue, $opacity)



  // @each $color-pack-name, $color-pack-themes in colors.$color-packs {
  //     @each $color-pack-theme, $color-pack-tokens in $color-pack-themes {
  //       @if ($color-pack-theme == light) {
  //         @each $token-value, $token-color in $color-pack-tokens {
  //           --sd-sys-color-#{$token-value}: #{$token-color};
  //         }
  //       }
  //     }
  //   }

@function generate-system-classes($theme:light, $component:null)