import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette/text';
import { getTokenCSSVariableValueForNonActiveTheme } from './utils';

/**
 * Resolves a text (foreground) color to its equivalent value in the non-active
 * theme (i.e. dark when the editor is in light mode and vice versa).
 *
 * Shared between the text-color plugin state (`getColorInNonActiveTheme`) and the
 * color-accessibility selection walker so both evaluate colors identically.
 *
 * @param color - The raw text color mark (hex/token) or null for the default.
 * @param defaultColor - The plugin's default text color, used when `color` is
 * absent or explicitly the default.
 */
export var getTextColorInNonActiveTheme = function getTextColorInNonActiveTheme(color, defaultColor) {
  if (!color || color === defaultColor) {
    return getTokenCSSVariableValueForNonActiveTheme("var(--ds-text, #292A2E)", defaultColor);
  }
  var colorValue = hexToEditorTextPaletteColor(color) || color;
  return getTokenCSSVariableValueForNonActiveTheme(colorValue, color);
};