var _createReducer;
//./selectionLayer.js
import { createReducer } from "redux-act";
import createAction from "./utils/createMetaAction";

// ------------------------------------
// Actions
// ------------------------------------
export var selectionLayerClear = createAction("SELECTION_LAYER_CLEAR");
export var selectionLayerUpdate = createAction("SELECTION_LAYER_UPDATE");

// ------------------------------------
// Reducer
// ------------------------------------
export default createReducer((_createReducer = {
  CARET_POSITION_UPDATE: function CARET_POSITION_UPDATE() {
    //clear the selection layer if the caret is updated!
    return {
      start: -1,
      end: -1
    };
  }
}, _createReducer[selectionLayerClear] = function () {
  return {
    start: -1,
    end: -1
  };
}, _createReducer[selectionLayerUpdate] = function (state, newSelectionLayer) {
  if (!newSelectionLayer || !(newSelectionLayer.start >= 0 && newSelectionLayer.end >= 0)) {
    console.error("we should never be here! selectionLayerUpdate must always be called with a valid selection layer");
    return state;
  }
  return newSelectionLayer;
}, _createReducer), {
  start: -1,
  end: -1
});