import type { KeybindingBlock } from "./types.js";

export const DEFAULT_BINDINGS: KeybindingBlock[] = [
  {
    context: "Global",
    bindings: {
      "ctrl+c": "app:interrupt",
      "ctrl+d": "app:exit",
      "ctrl+l": "app:redraw",
      "ctrl+t": "app:toggleTodos",
      "ctrl+o": "app:toggleTranscript",
      "ctrl+b": "app:toggleBackgroundPanel",
      "ctrl+]": "app:toggleAgentsPanel",
      "ctrl+r": "history:search",
      "ctrl+x ctrl+]": "agent:focusNext",
      "ctrl+x ctrl+[": "agent:focusPrev",
      "ctrl+x enter": "agent:openViewed",
      "ctrl+x a": "agent:sendInput",
    },
  },
  {
    context: "Chat",
    bindings: {
      escape: "chat:cancel",
      "ctrl+x ctrl+k": "chat:killAgents",
      "shift+tab": "chat:cycleMode",
      enter: "chat:submit",
      "shift+enter": "chat:newline",
      up: "history:previous",
      down: "history:next",
      "ctrl+x ctrl+e": "chat:externalEditor",
      "ctrl+g": "chat:externalEditor",
      pageup: "scroll:pageUp",
      pagedown: "scroll:pageDown",
      home: "scroll:top",
      end: "scroll:bottom",
      wheelup: "scroll:wheelUp",
      wheeldown: "scroll:wheelDown",
    },
  },
  {
    context: "Autocomplete",
    bindings: {
      tab: "autocomplete:accept",
      escape: "autocomplete:dismiss",
      up: "autocomplete:previous",
      down: "autocomplete:next",
    },
  },
  {
    context: "Confirmation",
    bindings: {
      y: "confirm:yes",
      n: "confirm:no",
      enter: "confirm:yes",
      escape: "confirm:no",
      up: "confirm:previous",
      down: "confirm:next",
      tab: "confirm:nextField",
      "shift+tab": "confirm:previousField",
      a: "permission:allowAlways",
      e: "permission:editInput",
      "1": "confirm:digit1",
      "2": "confirm:digit2",
      "3": "confirm:digit3",
      "4": "confirm:digit4",
      "5": "confirm:digit5",
      "6": "confirm:digit6",
      "7": "confirm:digit7",
      "8": "confirm:digit8",
      "9": "confirm:digit9",
    },
  },
  {
    context: "PermissionEdit",
    bindings: {
      enter: "confirm:yes",
      escape: "confirm:no",
      y: null,
      n: null,
      a: null,
      e: null,
    },
  },
  {
    context: "MessageActions",
    bindings: {
      enter: "messageActions:enter",
      escape: "messageActions:escape",
      t: "transcript:targetCursor",
      "ctrl+e": "transcript:toggleShowAll",
      "ctrl+s": "transcript:export",
      "ctrl+x ctrl+e": "transcript:externalEditor",
      up: "messageActions:prev",
      down: "messageActions:next",
      home: "messageActions:top",
      end: "messageActions:bottom",
      pageup: "scroll:pageUp",
      pagedown: "scroll:pageDown",
      wheelup: "scroll:wheelUp",
      wheeldown: "scroll:wheelDown",
    },
  },
  {
    context: "Transcript",
    bindings: {
      escape: "app:toggleTranscript",
      "/": "history:search",
      "ctrl+e": "transcript:toggleShowAll",
      "ctrl+s": "transcript:export",
      "ctrl+x ctrl+e": "transcript:externalEditor",
      n: "transcript:searchNext",
      p: "transcript:searchPrev",
      v: "transcript:openSelector",
      t: "transcript:targetCursor",
      enter: "transcript:confirmSelection",
      "ctrl+r": "transcript:rewind",
      u: "transcript:restore",
      backspace: "transcript:clearSelection",
      up: "transcript:selectorUp",
      down: "transcript:selectorDown",
      pageup: "scroll:pageUp",
      pagedown: "scroll:pageDown",
      home: "scroll:top",
      end: "scroll:bottom",
      wheelup: "scroll:wheelUp",
      wheeldown: "scroll:wheelDown",
    },
  },
];
