whole_func_string: function changeTarget(state, action) {
    const layerIdx = getLayerIndexById(state.layers, action.layerId);
    const layer = state.layers[layerIdx];
    const layerGroup = getGroup(layer);
    const targetIdx = getLayerIndexById(state.layers, action.targetId);
    if (layerGroup) {
      return false;
    }
    let i, ii;
    if (layerIdx < targetIdx) {
      // move up
      for (i = targetIdx + 1, ii = state.layers.length; i < ii; i++) {
        if (getGroup(state.layers[i]) === layerGroup) {
          return state.layers[i - 1].id;
        }
      }
      return state.layers[ii - 1].id;
    } else {
      // move down
      for (i = targetIdx - 1; i >= 0; i--) {
        if (getGroup(state.layers[i]) === layerGroup) {
          return state.layers[i + 1].id;
        }
      }
      return state.layers[0].id;
    }
  }
func_code_string: function changeTarget(state, action) {
    const layerIdx = getLayerIndexById(state.layers, action.layerId);
    const layer = state.layers[layerIdx];
    const layerGroup = getGroup(layer);
    const targetIdx = getLayerIndexById(state.layers, action.targetId);
    if (layerGroup) {
      return false;
    }
    let i, ii;
    if (layerIdx < targetIdx) {
      // move up
      for (i = targetIdx + 1, ii = state.layers.length; i < ii; i++) {
        if (getGroup(state.layers[i]) === layerGroup) {
          return state.layers[i - 1].id;
        }
      }
      return state.layers[ii - 1].id;
    } else {
      // move down
      for (i = targetIdx - 1; i >= 0; i--) {
        if (getGroup(state.layers[i]) === layerGroup) {
          return state.layers[i + 1].id;
        }
      }
      return state.layers[0].id;
    }
  }
func_documentation_string: Change the target for reodering of layers. This makes sure that groups
  stay together in the layer stack. Layers of a group cannot move outside of
  the group.
  @param {Object} state Current state.
  @param {Object} action Action to handle.
  
  @returns {string|boolean} The new targetId or false if moving should be blocked.