"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.originalImage = exports.originalJpegImage = exports.mediumImage = exports.smallImage = exports.thumbnailImage = exports.derivativeImage = exports.getDerivativePath = exports.getImageViewerPath = exports.DERIVATIVE_ORIGINAL = exports.DERIVATIVE_ORIGINAL_JPEG = exports.DERIVATIVE_MEDIUM = exports.DERIVATIVE_SMALL = exports.DERIVATIVE_THUMBNAIL = exports.VIEWER_WINDOW_NAME = void 0;

var _react = _interopRequireDefault(require("react"));

var _BlobImage = _interopRequireDefault(require("../components/media/BlobImage"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const VIEWER_WINDOW_NAME = 'viewer';
exports.VIEWER_WINDOW_NAME = VIEWER_WINDOW_NAME;
const DERIVATIVE_THUMBNAIL = 'Thumbnail';
exports.DERIVATIVE_THUMBNAIL = DERIVATIVE_THUMBNAIL;
const DERIVATIVE_SMALL = 'Small';
exports.DERIVATIVE_SMALL = DERIVATIVE_SMALL;
const DERIVATIVE_MEDIUM = 'Medium';
exports.DERIVATIVE_MEDIUM = DERIVATIVE_MEDIUM;
const DERIVATIVE_ORIGINAL_JPEG = 'OriginalJpeg';
exports.DERIVATIVE_ORIGINAL_JPEG = DERIVATIVE_ORIGINAL_JPEG;
const DERIVATIVE_ORIGINAL = '';
exports.DERIVATIVE_ORIGINAL = DERIVATIVE_ORIGINAL;

const getImageViewerPath = (config, imagePath) => {
  const {
    basename
  } = config;
  return "".concat(basename || '', "/view/").concat(imagePath);
};

exports.getImageViewerPath = getImageViewerPath;

const getDerivativePath = (csid, derivative) => {
  const derivativePath = derivative ? "/derivatives/".concat(derivative) : '';
  return "blobs/".concat(csid).concat(derivativePath, "/content");
};

exports.getDerivativePath = getDerivativePath;

const derivativeImage = (blobCsid, derivative) => blobCsid ? _react.default.createElement(_BlobImage.default, {
  csid: blobCsid,
  derivative: derivative
}) : null;

exports.derivativeImage = derivativeImage;

const thumbnailImage = blobCsid => derivativeImage(blobCsid, DERIVATIVE_THUMBNAIL);

exports.thumbnailImage = thumbnailImage;

const smallImage = blobCsid => derivativeImage(blobCsid, DERIVATIVE_SMALL);

exports.smallImage = smallImage;

const mediumImage = blobCsid => derivativeImage(blobCsid, DERIVATIVE_MEDIUM);

exports.mediumImage = mediumImage;

const originalJpegImage = blobCsid => derivativeImage(blobCsid, DERIVATIVE_ORIGINAL_JPEG);

exports.originalJpegImage = originalJpegImage;

const originalImage = blobCsid => derivativeImage(blobCsid, DERIVATIVE_ORIGINAL);

exports.originalImage = originalImage;