"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = commonTableCellRender;
var _defaultRender = _interopRequireDefault(require("./defaultRender"));
var _timestampRender = _interopRequireDefault(require("./timestampRender"));
var _cascadeTimestampRender = _interopRequireDefault(require("./cascadeTimestampRender"));
var _moneyRender = _interopRequireDefault(require("./moneyRender"));
var _moneyRangeRender = _interopRequireDefault(require("./moneyRangeRender"));
var _linkRender = _interopRequireDefault(require("./linkRender"));
var _fileRender = _interopRequireDefault(require("./fileRender"));
var _enumRender = _interopRequireDefault(require("./enumRender"));
var _imageRender = _interopRequireDefault(require("./imageRender"));
function commonTableCellRender(value, index, rowData, column) {
  var dataType = column.dataType;
  if (dataType === 'text') {
    return (0, _defaultRender["default"])(value);
  }
  if (dataType === 'link') {
    return (0, _linkRender["default"])(value, column, rowData);
  }
  if (dataType === 'file') {
    return (0, _fileRender["default"])(value);
  }
  if (dataType === 'image') {
    return (0, _imageRender["default"])(value, column, rowData);
  }
  if (dataType === 'enum') {
    return (0, _enumRender["default"])(value, column);
  }
  if (dataType === 'timestamp') {
    return (0, _timestampRender["default"])(value, column);
  }
  if (dataType === 'cascadeTimestamp') {
    return (0, _cascadeTimestampRender["default"])(value, column);
  }
  if (dataType === 'money') {
    return (0, _moneyRender["default"])(value);
  }
  if (dataType === 'moneyRange') {
    return (0, _moneyRangeRender["default"])(value);
  }
  var render = column.render;
  if (render) {
    try {
      return render(value, index, rowData);
    } catch (e) {
      if (e instanceof Error) {
        console.warn(e.stack);
      }
      return (0, _defaultRender["default"])(value);
    }
  } else {
    return (0, _defaultRender["default"])(value);
  }
}