@use 'sass:color';
@use 'sass:string';
@use 'sass:math';

@function hex-to-hsl($color) {
  @if type-of($color) != 'color' {
    @error "The value `#{$color}` is not a valid color.";
  }

  $hue: math.round(color.hue($color));
  $saturation: math.round(color.saturation($color));
  $lightness: math.round(color.lightness($color));

  @return string.unquote("#{$hue}, #{$saturation}, #{$lightness}");
}
