@use 'sass:map';
@use '../../config';
@use '../../functions' as *;
@use '../../schemas/' as *;
@use '../../../utils/map' as *;
@use '../../../color/functions' as *;
@use '../../../elevations/' as *;

////
/// @package theming
/// @group themes
/// @access public
/// @author <a href="https://github.com/simeonoff" target="_blank">Simeon Simeonoff</a>
/// @author <a href="https://github.com/desig9stein" target="_blank">Marin Popov</a>
////

/// Overlay Theme
///
/// This theme has no automatic token derivation. Only one token: background-color.
///
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
/// @param {Color} $background-color [null] - The background color used for modal overlays.
/// @requires $light-material-schema
/// @example scss - Change the background color
///   $my-overlay-theme: overlay-theme($background-color: rgba(yellow, .74));
///   // Pass the theme to the css-vars() mixin
///   @include css-vars($my-overlay-theme);
@function overlay-theme($schema: $light-material-schema, $background-color: null) {
    $selector: (
        #{config.element-prefix() + '-' + 'overlay'},
        '.igx-overlay__wrapper--modal',
        '.igx-overlay__content--modal'
    );
    $overlay-schema: ();

    @if map.has-key($schema, 'overlay') {
        $overlay-schema: map.get($schema, 'overlay');
    } @else {
        $overlay-schema: $schema;
    }

    $theme: digest-schema($overlay-schema);

    @return extend(
        $theme,
        (
            selector: $selector,
            background-color: $background-color,
        )
    );
}
