@use "sass:map";
@use "sass:meta";
@use "./dark/index" as dark;
@use "./light/index" as light;

$dark-override: () !default;
$light-override: () !default;

$dark-theme: () !default;
$light-theme: () !default;

/**
 * Helper function to get the right color overlay function according to the theme.
 */
@function get-overlay-function($theme) {
  $-theme: map.get($theme, theme);
  @return meta.get-function("color-overlay", false, if($-theme == "light", "light", "dark"));
}

@function define() {
  $dark-theme: dark.define($dark-override) !global;
  $light-theme: light.define($light-override) !global;
  @return (dark-theme: $dark-theme, light-theme: $light-theme);
}

@mixin override-themes() {
  body.dark-theme & {
    @content ($dark-theme);
  }
  body.light-theme & {
    @content ($light-theme);
  }
}

@function dark-color-overlay($elevation) {
  @return dark.color-overlay($elevation);
}

@function light-color-overlay($elevation) {
  @return light.color-overlay($elevation);
}

@function dark-background-palette() {
  @return map.get($dark-theme, background);
}

@function dark-foreground-palette() {
  @return map.get($dark-theme, foreground);
}

@function light-background-palette() {
  @return map.get($light-theme, background);
}

@function light-foreground-palette() {
  @return map.get($light-theme, foreground);
}
