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

/// Paginator Theme
///
/// PRIMARY TOKENS:
/// - `$background` — The paginator background.
///
/// Derived colors are auto-calculated for contrast.
///
/// @param {Map} $schema [$light-material-schema] - The schema used as basis for styling the component.
/// @param {Color} $foreground [currentColor] - The text color. Auto-derived from background.
/// @param {Color} $background [rgba(0, 0, 0, .04)] - The background color of the paging panel. PRIMARY - derives foreground.
/// @param {Color} $border-color [rgba(0, 0, 0, .26)] - The border color of the paging panel.
/// @param {Color} $accent-color [null] - The accent color used for paginator interactive elements.
/// @requires $light-material-schema
/// @example scss - Change the stripes color
///   $my-paginator-theme: paginator-theme(
///     $stripes-color: orange
///   );
///   // Pass the theme to the css-vars() mixin
///   @include css-vars($my-paginator-theme);
@function paginator-theme(
    $schema: $light-material-schema,

    $foreground: null,
    $background: null,
    $border-color: null,
    $accent-color: null
) {
    $selector: #{config.element-prefix() + '-' + 'paginator'};
    $grid-paginator-schema: ();

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

    $theme: digest-schema($grid-paginator-schema);

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

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