<commit_before>import * as Constants from "../constants";
const assign = require("object-assign");

export const INITIAL_STATE = {
    agentUri: null,
    agentKind: null,
    locale: "en",
    viewer: {
        imageFormat: "PNG",
        selectionColor: "0x0000FFAA",
        pointSelectionBuffer: 2
    },
    externalBaseLayers: [],
    coordinates: {
        decimals: 6
    },
    capabilities: {
        hasTaskPane: false,
        hasTaskBar: false,
        hasStatusBar: false,
        hasNavigator: false,
        hasSelectionPanel: false,
        hasLegend: false,
        hasToolbar: false
    }
};

export function configReducer(state = INITIAL_STATE, action = { type: '', payload: null }) {
    switch (action.type) {
        case Constants.INIT_APP: 
            {
                const newState = assign({}, state, {
                    externalBaseLayers: action.payload.externalBaseLayers,
                    viewer: action.payload.config,
                    capabilities: action.payload.capabilities
                });
                return newState;
            }
        case Constants.MAP_SET_BASE_LAYER:
            {
                const baseLayers = state.externalBaseLayers.map(layer => {
                    layer.visible = false;
                    if (layer.name == action.payload) {
                        layer.visible = true;
                    }
                    return layer;
                });
                const newState = assign({}, state, {
                    externalBaseLayers: baseLayers
                });
                return newState;
            }
    }
    return state;
}<commit_msg>Don't merge in an empty config into the config state branch. This breaks the viewer.<commit_after>import * as Constants from "../constants";
const assign = require("object-assign");

export const INITIAL_STATE = {
    agentUri: null,
    agentKind: null,
    locale: "en",
    viewer: {
        imageFormat: "PNG",
        selectionColor: "0x0000FFAA",
        pointSelectionBuffer: 2
    },
    externalBaseLayers: [],
    coordinates: {
        decimals: 6
    },
    capabilities: {
        hasTaskPane: false,
        hasTaskBar: false,
        hasStatusBar: false,
        hasNavigator: false,
        hasSelectionPanel: false,
        hasLegend: false,
        hasToolbar: false
    }
};

export function configReducer(state = INITIAL_STATE, action = { type: '', payload: null }) {
    switch (action.type) {
        case Constants.INIT_APP: 
            {
                const newState = assign({}, state, {
                    externalBaseLayers: action.payload.externalBaseLayers,
                    capabilities: action.payload.capabilities
                });
                if (action.payload.config != null && Object.keys(action.payload.config).length > 0) {
                    return assign(newState, { viewer: action.payload.config });
                } else {
                    return newState;
                }
            }
        case Constants.MAP_SET_BASE_LAYER:
            {
                const baseLayers = state.externalBaseLayers.map(layer => {
                    layer.visible = false;
                    if (layer.name == action.payload) {
                        layer.visible = true;
                    }
                    return layer;
                });
                const newState = assign({}, state, {
                    externalBaseLayers: baseLayers
                });
                return newState;
            }
    }
    return state;
}
{'fraction_non_alphanumeric': 0.09444601071327882, 'fraction_numerical': 0.00422892585283338, 'mean_word_length': 1.484593837535014, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5275843', 'n_tokens_mistral': 955, 'n_tokens_neox': 892, 'n_words': 204}