@use 'sass:color';
@use 'sass:map';
@use 'sass:math';
@use 'design-tokens';

@function mapGet($map, $keys...) {
  $value: map.get($map, $keys...);

  @if not $value {
    @error "Value not found for keys: #{$keys}";
  }

  @return $value;
}

@function getSemanticColor($color, $shade) {
  @return mapGet(design-tokens.$tokens, color, semantic, $color, $shade);
}

@function getSpacing($spacingType) {
  @return mapGet(design-tokens.$tokens, spacing, $spacingType);
}

@function getBoxShadow($type, $variant) {
  @return mapGet(design-tokens.$tokens, Shadow, $type, $variant);
}

@function getBorderRadius($spacingType) {
  @return mapGet(design-tokens.$tokens, 'borderRadius', $spacingType);
}

@function getFontFamily($type, $level) {
  $typo-settings: map.get(map.get(design-tokens.$tokens, $type), $level);

  @return map.get($typo-settings, 'fontFamily'), 'Helvetica Neue', 'Arial', sans-serif;
}

@function hex2rgb($hex) {
  @return color.channel($hex, 'red', $space: rgb),
    color.channel($hex, 'green', $space: rgb), color.channel($hex, 'blue', $space: rgb);
}

@function ceilFunction($number) {
  @return math.ceil($number);
}
