// packages/commands/src/store/reducer.js
import { combineReducers } from "@wordpress/data";
function commands(state = {}, action) {
  switch (action.type) {
    case "REGISTER_COMMAND":
      return {
        ...state,
        [action.name]: {
          name: action.name,
          label: action.label,
          searchLabel: action.searchLabel,
          context: action.context,
          callback: action.callback,
          icon: action.icon,
          keywords: action.keywords
        }
      };
    case "UNREGISTER_COMMAND": {
      const { [action.name]: _, ...remainingState } = state;
      return remainingState;
    }
  }
  return state;
}
function commandLoaders(state = {}, action) {
  switch (action.type) {
    case "REGISTER_COMMAND_LOADER":
      return {
        ...state,
        [action.name]: {
          name: action.name,
          context: action.context,
          hook: action.hook
        }
      };
    case "UNREGISTER_COMMAND_LOADER": {
      const { [action.name]: _, ...remainingState } = state;
      return remainingState;
    }
  }
  return state;
}
function isOpen(state = false, action) {
  switch (action.type) {
    case "OPEN":
      return true;
    case "CLOSE":
      return false;
  }
  return state;
}
function context(state = "root", action) {
  switch (action.type) {
    case "SET_CONTEXT":
      return action.context;
  }
  return state;
}
var reducer = combineReducers({
  commands,
  commandLoaders,
  isOpen,
  context
});
var reducer_default = reducer;
export {
  reducer_default as default
};
//# sourceMappingURL=reducer.mjs.map
