import { PixelRatio } from 'react-native';
import buildUrlQueryParams from './build-query-string';
const MEDIAS_API = 'https://api.coorpacademy.com/api-service/medias';
const getResizedImage = (url, {
  maxWidth,
  maxHeight,
  resizeMode
}) => {
  if (!maxWidth && !maxHeight) {
    return url;
  }
  let queryParams = {
    url,
    m: !resizeMode || resizeMode === 'cover' ? 'crop' : 'contain',
    q: 90
  };
  if (maxWidth) {
    queryParams = {
      ...queryParams,
      w: PixelRatio.getPixelSizeForLayoutSize(maxWidth)
    };
  }
  if (maxHeight) {
    queryParams = {
      ...queryParams,
      h: PixelRatio.getPixelSizeForLayoutSize(maxHeight)
    };
  }
  const queryString = buildUrlQueryParams(queryParams);
  return `${MEDIAS_API}?${queryString}`;
};
export default getResizedImage;
//# sourceMappingURL=get-resized-image.js.map