'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _defineProperty2 = require('babel-runtime/helpers/defineProperty');

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _objectAssign = require('object-assign');

var _objectAssign2 = _interopRequireDefault(_objectAssign);

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

var defaultFields = {
  media: null,
  title: null,
  subtitle: null,
  color: null
};

var fieldMapping = function fieldMapping() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultFields;
  var _ref = arguments[1];
  var type = _ref.type,
      payload = _ref.payload;

  switch (type) {
    case 'UPDATE_FIELD_MAPPING':
      if (!(payload.type in defaultFields)) {
        console.warn('`' + payload.type + '` is not a valid field type');
        return state;
      }
      return (0, _objectAssign2.default)({}, state, (0, _defineProperty3.default)({}, payload.type, payload.field));

    default:
      return state;
  }
};

exports.default = fieldMapping;
//# sourceMappingURL=field_mapping.js.map