/**
 * Central registry for all vim actions
 */

import type { Action } from "../core/types";
import { joinLinesAction } from "./join-lines-action";
import { joinLinesNoSpaceAction } from "./join-lines-no-space-action";
import { pasteAction, pasteBeforeAction } from "./paste-actions";
import { repeatAction } from "./repeat-action";
import { replaceAction } from "./replace-action";
import { toggleCaseAction } from "./toggle-case-action";

/**
 * Registry of all available actions
 */
export const actionRegistry: Record<string, Action> = {
  p: pasteAction,
  P: pasteBeforeAction,
  J: joinLinesAction,
  gJ: joinLinesNoSpaceAction,
  "~": toggleCaseAction,
  ".": repeatAction,
  r: replaceAction,
};

/**
 * Get an action by key
 */
export const getAction = (key: string): Action | undefined => {
  return actionRegistry[key];
};

/**
 * Check if a key is a registered action
 */
export const isAction = (key: string): boolean => {
  return key in actionRegistry;
};

/**
 * Get all action keys
 */
export const getActionKeys = (): string[] => {
  return Object.keys(actionRegistry);
};
