import { isBreakpointsForPrefixType, isBorderRadiusTokenType, isDirectionalBorderRadiusType, } from '../../../types/type-guard';
import { LogUtility } from '../../../utils/log';
import { ResponsiveClassStringFormatter } from './responsive-class-string-formatter';
import { BorderRadius } from '../../../constants/public-api';
const BORDER_RADIUS_DIRECTION_CLASS_PARTIAL_MAP = {
  'top': 't',
  'right': 'r',
  'bottom': 'b',
  'left': 'l',
  'top-left': 'tl',
  'top-right': 'tr',
  'bottom-left': 'bl',
  'bottom-right': 'br',
};
/**
 * A class for format BorderRadiusType with BreakpointsForPrefixType to CSS class string
 *
 * @deprecated Please use the `ResponsiveBorderRadiusStyleStyleFormatter` instead.
 * @augments ResponsiveClassStringFormatter
 */
class ResponsiveBorderRadiusFormatter extends ResponsiveClassStringFormatter {
  /**
   * Given a border-radius type, return a string of CSS classes that can be used to apply the border-radius to an element
   *
   * @param {CornersType} input - CornersType
   * @param {BreakpointsForPrefixType} [breakpoint] - Breakpoints for prefix of the class
   * @returns {string} - A string of CSS classes.
   */
  formatToken(input, breakpoint) {
    const prefix = isBreakpointsForPrefixType(breakpoint) ? `${breakpoint}:` : '';
    if (isBorderRadiusTokenType(input)) {
      return `${prefix}v-${this.transformRoundedNoneAndFill(input)}`;
    }
    else if (isDirectionalBorderRadiusType(input)) {
      return Object.keys(input)
        .map((direction) => {
        return `${prefix}v-rounded-${BORDER_RADIUS_DIRECTION_CLASS_PARTIAL_MAP[direction]}-${this.transformRoundedNoneAndFill(input[direction]).replace('rounded-', '')}`;
      })
        .join(' ');
    }
    else {
      LogUtility.warn(`The border radius value ${input} is invalid, it must be a value of: `, BorderRadius);
      return '';
    }
  }
  /**
   * The function `transformRoundedNoneAndFill` replaces 'rounded-none' with 'rounded-0' and
   * 'rounded-full' with 'rounded-9999'.
   *
   * @param {string} rounded - The `rounded` parameter is a string that represents a CSS class related to the rounding of elements
   * @returns {string} The transformed value .
   */
  transformRoundedNoneAndFill(rounded) {
    return rounded.replace('rounded-none', 'rounded-0').replace('rounded-full', 'rounded-9999');
  }
}
export default new ResponsiveBorderRadiusFormatter();
