import { isResponsiveType } from '../../../types/type-guard';
import { getCurrentBreakpoint, createCompleteResponsiveMap } from '../../../utils/breakpoints';
/**
 * A class for format Custom types
 *
 * @augments ResponsiveCustomFormatter
 */
export class ResponsiveCustomFormatter {
  /**
   * If the input is not a responsive type, return it. If it is a responsive type, return the value for
   * the current breakpoint
   *
   * @typedef T generic type parameter
   * @param {ResponsiveType<T>} input - ResponsiveType<T>
   * @returns {T} The value of the current breakpoint.
   */
  format(input) {
    const breakpoint = getCurrentBreakpoint();
    if (isResponsiveType(input)) {
      input = createCompleteResponsiveMap(input);
      return input[breakpoint];
    }
    else {
      return input;
    }
  }
}
export default new ResponsiveCustomFormatter();
