"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = config;

var _constants = require("../actions/constants");

var _ramda = require("ramda");

function config() {
  var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  var action = arguments.length > 1 ? arguments[1] : undefined;

  if (action.type === (0, _constants.getAction)('SET_CONFIG')) {
    // Put the components childrenProps in windows for side usage.
    window.__dashprivate_childrenProps = (0, _ramda.mergeDeepRight)(window.__dashprivate_childrenProps || {}, action.payload.children_props);
    return action.payload;
  } else if (action.type === (0, _constants.getAction)('ADD_HTTP_HEADERS')) {
    return (0, _ramda.mergeDeepRight)(state, {
      fetch: {
        headers: action.payload
      }
    });
  }

  return state;
}