@use 'sass:meta';

/// Converts a color into a string representation of that color.
///
/// @param {Color} $color - The color to convert into a string.
///
/// @return {String} A color value wrapped inside a string.
///
/// @access public
/// @group Utilities
///
/// @throw Invalid $color data type warning.
@function color-to-string($color) {
  @if meta.type-of($color) != 'color' {
    @warn 'Incorrect data type passed to [ color-to-string() ] function. You ' +
      'passed `#{meta.inspect($color)}` for the $color argument, which is ' +
      'not recognized as a color by Sass. Returning the given value as a ' +
      'string anyway.';
  }

  @return '#{$color}';
}

/// Converts a color into a string representation of that color.
///
/// @param {Color} $color - The color to convert into a string.
///
/// @return {String} A color value wrapped inside a string.
///
/// @access public
/// @group Utilities
/// @require {function} color-to-string
///
/// @throw Invalid $color data type error, $color cannot be of type 'map'.
/// @throw Invalid $color data type warning.
///
/// @alias color-to-string
@function color-to-str($color) {
  @return color-to-string($color);
}
