@NlsSafe
  private static String formatSize(long size, @NotNull String format) {
    if (format.equalsIgnoreCase("bytes")) {
      return new DecimalFormat("#,##0").format(size);
    }

    String result;
    if (size == 0) {
      result = "0k";
    }
    else if (size < ONE_KILOBYTE) {
      result = "1k";
    }
    else if (size < ONE_MEGABYTE) {
      result = (size + 512) / ONE_KILOBYTE + "k";
    }
    else if (size < 99 * ONE_MEGABYTE) {
      result = new DecimalFormat("0.0M").format(size / (double)ONE_MEGABYTE);
    }
    else {
      result = (size + (529 * ONE_KILOBYTE)) / ONE_MEGABYTE + "M";
    }

    int charsToAdd = 5 - result.length();
    if (charsToAdd < 0) {
      throw new IllegalArgumentException("Num chars can't be negative");
    }

    if (charsToAdd == 0) {
      return result;
    }

    return " ".repeat(charsToAdd) + result;
  }
@NlsSafe
  private static String formatSize(long size, @NotNull String format)