import { isResponsiveType, isTranslocationType } from '../../../types/type-guard';
import { getCurrentBreakpoint, createCompleteResponsiveMap } from '../../../utils/breakpoints';
/**
 * A class for format TranslocationType
 *
 * @augments ResponsiveTranslocationFormatter
 */
class ResponsiveTranslocationFormatter {
  /**
   * Given a responsive size, return the size according current window width
   *
   * @param {ResponsiveType<TranslocationType>} input - ResponsiveScope
   * @returns {Nullable<TranslocationType>} - size.
   */
  format(input) {
    if (isTranslocationType(input)) {
      return input;
    }
    else if (isResponsiveType(input)) {
      const breakpoint = getCurrentBreakpoint();
      input = createCompleteResponsiveMap(input);
      return input[breakpoint];
    }
    else {
      return null;
    }
  }
}
export default new ResponsiveTranslocationFormatter();
