@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 private
/// @author <a href="https://github.com/desig9stein" target="_blank">Marin Popov</a>
////

/// Watermark Theme
///
/// PRIMARY TOKENS:
/// - `$link-background` — The link background color.
///
/// Derived colors are auto-calculated for contrast.
///
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
/// @param {Color} $base-color [null] - The base color for all elements of the watermark.
/// @param {Color} $image-color [null] - The color used for the stamp image.
/// @param {Number} $image-opacity [null] - The opacity of the stamp image.
/// @param {Color} $link-background [null] - The background color used for the link. PRIMARY - derives color.
/// @param {Color} $color [null] - The color used for the link text. Auto-derived from link-background.
/// @param {Color} $border-color [null] - The border color used for the  link.
/// @param {List} $border-radius [null] - The border radius used for the link.
///
/// @example scss - Change the watermark link background
/// @requires $light-material-schema
@function watermark-theme(
    $schema: $light-material-schema,
    $base-color: null,
    $image-color: null,
    $image-opacity: null,
    $link-background: null,
    $color: null,
    $border-color: null,
    $border-radius: null
) {
    $selector: 'igc-trial-watermark';
    $watermark-schema: ();

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

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

    @if not($color) and $link-background {
        $color: adaptive-contrast($link-background);
    }

    @return extend(
        $theme,
        (
            selector: $selector,
            base-color: $base-color,
            image-color: $image-color,
            image-opacity: $image-opacity,
            link-background: $link-background,
            color: $color,
            border-color: $border-color,
            border-radius: $border-radius,
        )
    );
}
