// @flow
import { getPaletteColor } from '../../../mixins/branding';
import {
  getFontColor as _getFontColor,
  getDisabledFillColor,
} from '../icon.css-rules';
import type { PatchworkTheme } from '../../../themes';
import type { ColorPaletteColorNameKey } from '../../../mixins/branding';

export const getStrokeColor = (
  theme: PatchworkTheme,
  disabled?: boolean,
  inverted?: boolean,
  colorName?: ColorPaletteColorNameKey,
) => {
  if (inverted) {
    return getPaletteColor('white')({ theme });
  }

  if (disabled) {
    return getDisabledFillColor({ theme });
  }

  return getPaletteColor(colorName || 'brand-primary-base')({ theme });
};

export const getFillColor = (
  theme: PatchworkTheme,
  disabled?: boolean,
  inverted?: boolean,
  colorName?: ColorPaletteColorNameKey,
) => {
  if (inverted) {
    return getPaletteColor('white')({ theme });
  }

  if (disabled) {
    return getDisabledFillColor({ theme });
  }

  return getPaletteColor(colorName || 'brand-primary-base')({ theme });
};

export const getFontColor = (
  theme: PatchworkTheme,
  disabled?: boolean,
  inverted?: boolean,
  colorName?: ColorPaletteColorNameKey,
) => {
  if (disabled && inverted) {
    return getDisabledFillColor({ theme });
  }

  if (inverted) {
    return getPaletteColor(colorName || 'brand-primary-base')({ theme });
  }

  if (disabled) {
    return getPaletteColor('white')({ theme });
  }

  return _getFontColor(theme);
};
