import { isResponsiveType } from '../../../types/type-guard';
import { getCurrentBreakpoint, createCompleteResponsiveMap } from '../../../utils/breakpoints';
import { parseToPixelString } from '../../../utils/pixel';
/**
 * A class for format WidthType and HeightType
 *
 * @augments ResponsiveWidthAndHeightFormatter
 */
export class ResponsiveWidthAndHeightFormatter {
  /**
   * The function takes a responsive type input, determines the current breakpoint, and formats the width
   * and height based on the breakpoint.
   *
   * @param {ResponsiveType<WidthType | HeightType>} input - The `input` parameter in the `format` function is of type `ResponsiveType<WidthType |
   * HeightType>`. This means that it can accept values that are either of type `WidthType` or
   * `HeightType` within a responsive context.
   * @returns {string} The `format` function returns a string value.
   */
  format(input) {
    const breakpoint = getCurrentBreakpoint();
    if (isResponsiveType(input)) {
      input = createCompleteResponsiveMap(input);
      return parseToPixelString(input[breakpoint]);
    }
    else {
      return parseToPixelString(input);
    }
  }
}
export default new ResponsiveWidthAndHeightFormatter();
