import { KeymapKey, KeymapLayer } from "@keymapkit/ui";
import {
  transparentLeftFingerMods,
  transparentLeftThumbkeys,
  transparentRightFingerMods,
  transparentRightThumbkeys,
} from "./keyTransparents";
import { keyLegends } from "./keyLegends";
import { keyInfo } from "./keyInfo";
import { keySelection } from "./keySelection";

export const layer4nav = KeymapLayer.fromKeyList({
  displayName: "Navigation Layer",
  shortName: "Navigation",
  welcome: [
    `This is the navigation layer`,
    `Select a key from the board above to learn more about it.`,
  ],
  layerEntryKeys: ["l-t-5-5"],
  keys: [
    // #region Left Finger Grid (l-f)
    new KeymapKey({ name: "", id: "l-f-1-1", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "l-f-6-1", unset: true, info: [] }),
    new KeymapKey({
      id: "l-f-10-1",
      ...keyLegends.exposeShowDesktop,
      info: keyInfo.expose,
      selection: keySelection.expose,
    }),
    new KeymapKey({
      id: "l-f-14-1",
      ...keyLegends.exposeShowAllWindows,
      info: keyInfo.expose,
      selection: keySelection.expose,
    }),
    new KeymapKey({
      id: "l-f-18-1",
      ...keyLegends.exposeShowAppWindows,
      info: keyInfo.expose,
      selection: keySelection.expose,
    }),
    new KeymapKey({ name: "", id: "l-f-22-1", unset: true, info: [] }),

    new KeymapKey({ name: "", id: "l-f-1-5", unset: true, info: [] }),
    new KeymapKey({
      id: "l-f-6-5",
      ...keyLegends.home,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({
      id: "l-f-10-5",
      ...keyLegends.pageUp,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({
      id: "l-f-14-5",
      ...keyLegends.pageDown,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({
      id: "l-f-18-5",
      ...keyLegends.end,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({ name: "", id: "l-f-22-5", unset: true, info: [] }),

    new KeymapKey({ name: "", id: "l-f-1-9", unset: true, info: [] }),
    new KeymapKey({
      id: "l-f-6-9",
      ...keyLegends.leftArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({
      id: "l-f-10-9",
      ...keyLegends.downArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({
      id: "l-f-14-9",
      ...keyLegends.upArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({
      id: "l-f-18-9",
      ...keyLegends.rightArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({
      id: "l-f-22-9",
      name: "Hide Application",
      textLegend: "⌘H",
      info: [
        "A key I can hit with my left hand to invoke <kbd>cmd</kbd>+<kbd>h</kbd> to hide the current application.",
        "Useful on a split keyboard where the H key is inaccessible to the left hand, but hiding an app is something you might want to do while the right hand is on the mouse.",
      ],
    }),

    new KeymapKey({ name: "", id: "l-f-1-13", unset: true, info: [] }),
    new KeymapKey({
      id: "l-f-6-13",
      name: "Back (Windows)",
      textLegend: "^[",
      selection: keySelection.navBackForwards,
      info: keyInfo.navBackForwards,
    }),
    new KeymapKey({
      id: "l-f-10-13",
      name: "Back (macOS)",
      textLegend: "⌘[",
      selection: keySelection.navBackForwards,
      info: keyInfo.navBackForwards,
    }),
    new KeymapKey({
      id: "l-f-14-13",
      name: "Forward (macOS)",
      textLegend: "⌘]",
      selection: keySelection.navBackForwards,
      info: keyInfo.navBackForwards,
    }),
    new KeymapKey({
      id: "l-f-18-13",
      name: "Forward (Windows)",
      textLegend: "^]",
      selection: keySelection.navBackForwards,
      info: keyInfo.navBackForwards,
    }),
    new KeymapKey({ name: "", id: "l-f-22-13", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "l-f-1-17", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "l-f-6-17", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "l-f-10-17", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "l-f-14-17", unset: true, info: [] }),
    // #endregion Left Finger Grid (l-f)

    // #region Right Finger Grid (r-f)
    new KeymapKey({ name: "", id: "r-f-9-1", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-13-1", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-17-1", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-21-1", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-25-1", unset: true, info: [] }),

    new KeymapKey({
      id: "r-f-5-5",
      ...keyLegends.home,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({
      id: "r-f-9-5",
      ...keyLegends.pageUp,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({
      id: "r-f-13-5",
      ...keyLegends.pageDown,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({
      id: "r-f-17-5",
      ...keyLegends.end,
      selection: keySelection.navBlocks,
      info: keyInfo.navBlocks,
    }),
    new KeymapKey({ name: "", id: "r-f-21-5", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-25-5", unset: true, info: [] }),

    new KeymapKey({
      id: "r-f-5-9",
      ...keyLegends.leftArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({
      id: "r-f-9-9",
      ...keyLegends.downArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({
      id: "r-f-13-9",
      ...keyLegends.upArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({
      id: "r-f-17-9",
      ...keyLegends.rightArrow,
      selection: keySelection.navArrows,
      info: keyInfo.navArrows,
    }),
    new KeymapKey({ name: "", id: "r-f-21-9", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-25-9", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-5-13", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-9-13", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-13-13", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-17-13", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-21-13", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-25-13", unset: true, info: [] }),

    new KeymapKey({ name: "", id: "r-f-13-17", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-17-17", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-21-17", unset: true, info: [] }),
    new KeymapKey({ name: "", id: "r-f-25-17", unset: true, info: [] }),
    // #endregion Right Finger Grid (r-f)

    // #region Transparent keys
    ...transparentLeftFingerMods,
    ...transparentLeftThumbkeys,
    ...transparentRightFingerMods,
    ...transparentRightThumbkeys,
    // #endregion Transparent keys
  ],
});
