/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-a795c5b | Cube Dev Team */
import { useIsDarwin } from "./useIsDarwin.js";
import { useMemo } from "react";

//#region src/utils/react/useKeySymbols.ts
const COMMON = {
	esc: "Esc",
	escape: "Esc",
	enter: "⏎",
	return: "⏎",
	space: "␣",
	backspace: "⌫",
	delete: "⌦",
	up: "↑",
	arrowup: "↑",
	down: "↓",
	arrowdown: "↓",
	left: "←",
	arrowleft: "←",
	right: "→",
	arrowright: "→"
};
const MAC = {
	mod: "⌘",
	meta: "⌘",
	cmd: "⌘",
	command: "⌘",
	ctrl: "⌃",
	control: "⌃",
	alt: "⌥",
	option: "⌥",
	shift: "⇧"
};
const PC = {
	mod: "Ctrl",
	ctrl: "Ctrl",
	control: "Ctrl",
	meta: "Win",
	win: "Win",
	windows: "Win",
	cmd: "Win",
	command: "Win",
	alt: "⎇",
	option: "⎇",
	shift: "⇧"
};
/**
* useKeySymbols
* -------------
* Turns an author string such as
*   "mod+k, ctrl+k"
* into
*   [["⌘", "K"], ["Ctrl", "K"]]
*/
function useKeySymbols(combo) {
	const modifiers = useIsDarwin() ? MAC : PC;
	return useMemo(() => {
		/** split on commas, trim each alternative */
		return combo.split(",").map((raw) => raw.trim().toLowerCase()).filter(Boolean).map((alternative) => alternative.split("+").map((part) => {
			const key = part.trim();
			return modifiers[key] ?? COMMON[key] ?? part.toUpperCase();
		}));
	}, [combo, modifiers]);
}

//#endregion
export { useKeySymbols };
//# sourceMappingURL=useKeySymbols.js.map