'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
var imageComposer = exports.imageComposer = function imageComposer(article) {
  var image = void 0;
  var heroImage = article.heroImage;
  var facebookImage = article.ogImage;

  if (heroImage && heroImage.image) {
    return {
      desktopImage: heroImage.image.resizedTargets.desktop.url,
      mobileImage: heroImage.image.resizedTargets.mobile.url
    };
  }

  var source = void 0;
  if (image) {
    var regex = /.+~(.+)/;
    source = image.match(regex);
    source = source ? source[1] : '';
  }

  var imageSet = {};
  if (facebookImage && facebookImage.image) {
    imageSet = {
      desktopImage: facebookImage.image.resizedTargets.desktop.url,
      mobileImage: facebookImage.image.resizedTargets.mobile.url
    };
  } else {
    // display logo when the image is empty
    image = '/asset/review.png';
    imageSet = {
      desktopImage: image,
      mobileImage: image
    };
  }

  return imageSet;
};