@use 'sass:map';
@use '@material/tooltip/plain-tooltip-theme';
@use '@material/theme/theme-color' as mdc-theme-color;
@use '@material/typography/typography' as mdc-typography;
@use '../core/theming/theming';
@use '../core/theming/palette';
@use '../core/mdc-helpers/mdc-helpers';
@use '../core/typography/typography';

@mixin color($config-or-theme) {
  $config: theming.get-color-config($config-or-theme);
  @include mdc-helpers.using-mdc-theme($config) {
    .mat-mdc-tooltip {
      @include plain-tooltip-theme.theme((
        container-color: map.get(palette.$light-theme-background-palette, tooltip),
        supporting-text-color: mdc-theme-color.prop-value(text-primary-on-dark)
      ));
    }
  }
}

@mixin typography($config-or-theme) {
  $config: typography.private-typography-to-2018-config(
          theming.get-typography-config($config-or-theme));
  @include mdc-helpers.using-mdc-typography($config) {
    .mat-mdc-tooltip {
      @include plain-tooltip-theme.theme((
        supporting-text-font: mdc-typography.get-font(caption),
        supporting-text-size: mdc-typography.get-size(caption),
        supporting-text-weight: mdc-typography.get-weight(caption),
        supporting-text-tracking: mdc-typography.get-tracking(caption),
      ));
    }
  }
}

@mixin density($config-or-theme) {
  $density-scale: theming.get-density-config($config-or-theme);
}

@mixin theme($theme-or-color-config) {
  $theme: theming.private-legacy-get-theme($theme-or-color-config);
  @include theming.private-check-duplicate-theme-styles($theme, 'mat-tooltip') {
    $color: theming.get-color-config($theme);
    $density: theming.get-density-config($theme);
    $typography: theming.get-typography-config($theme);

    @if $color != null {
      @include color($color);
    }
    @if $density != null {
      @include density($density);
    }
    @if $typography != null {
      @include typography($typography);
    }
  }
}
