// ============================================================================================= //
//                                             COLOR                                             //
// ============================================================================================= //

@use "sass:map";
@use "../core/functions";
@use "../core/mixins";
@use "../core/variables";

$_custom-property-prefix: map.get(variables.$color, "prefix");
$_tokens: map.get(variables.$color, "tokens");

///
/// The "color.theme()" emit `--mg-color-*` custom properties for a user-provided theme's tokens.
///
/// @example - scss
///   @use "@magnesium/theme/color";
///
///   .foo {
///     @include color.theme(
///       "primary": darkcyan,
///       "secondary": darkorange
///     );
///   }
///
/// @example - css
///   .foo {
///     --mg-color-primary: darkcyan;
///     --mg-color-secondary: darkcyan;
///   }
///
/// @param {Map} $tokens - The `color` tokens map.
///
@mixin theme($tokens) {
    $tokens: functions.validation($_tokens, $tokens, $_custom-property-prefix);

    @include mixins.emit-custom-props($tokens, $_custom-property-prefix);
}
