"use strict";

exports.__esModule = true;
exports.default = void 0;
var _reactNative = require("react-native");
var _buildQueryString = _interopRequireDefault(require("./build-query-string"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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: _reactNative.PixelRatio.getPixelSizeForLayoutSize(maxWidth)
    };
  }
  if (maxHeight) {
    queryParams = {
      ...queryParams,
      h: _reactNative.PixelRatio.getPixelSizeForLayoutSize(maxHeight)
    };
  }
  const queryString = (0, _buildQueryString.default)(queryParams);
  return `${MEDIAS_API}?${queryString}`;
};
var _default = exports.default = getResizedImage;
//# sourceMappingURL=get-resized-image.js.map