'use strict';

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

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

var _defineProperty3 = _interopRequireDefault(_defineProperty2);

var _isValidFormat;

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

var _objectAssign2 = _interopRequireDefault(_objectAssign);

var _constants = require('../constants');

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

var defaultSettings = {
  coordFormat: _constants.FORMATS_DEC_DEG
};

var isValidFormat = (_isValidFormat = {}, (0, _defineProperty3.default)(_isValidFormat, _constants.FORMATS_UTM, true), (0, _defineProperty3.default)(_isValidFormat, _constants.FORMATS_DEC_DEG, true), (0, _defineProperty3.default)(_isValidFormat, _constants.FORMATS_DEG_MIN_SEC, true), _isValidFormat);

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

  switch (type) {
    case 'CHANGE_COORDINATE_FORMAT':
      if (!isValidFormat[payload]) {
        console.warn('`' + payload + '` is not a valid coordinate format');
        return state;
      }
      return (0, _objectAssign2.default)({}, state, {
        coordFormat: payload
      });

    default:
      return state;
  }
};

exports.default = settings;
//# sourceMappingURL=settings.js.map