import type { SettingsCategory } from '../model.js';

export const generalCategories: SettingsCategory[] = [
	{
		id: 'dates',
		settingsSearch: 'gitlens.default',
		name: 'Dates & Times',
		group: 'General',
		icon: 'calendar',
		hint: 'Controls how dates and times are formatted and displayed throughout GitLens',
		controls: [
			{
				kind: 'check',
				key: 'defaultDateStyle',
				label: 'Allow relative date formatting',
				valueOn: 'relative',
				valueOff: 'absolute',
			},
			{
				kind: 'info',
				text: 'Shows some dates relatively, e.g. 1 day ago',
				visibleWhen: 'defaultDateStyle =relative',
			},
			{
				kind: 'info',
				text: 'Shows dates absolutely, using the date format below',
				visibleWhen: 'defaultDateStyle =absolute',
			},
			{
				kind: 'text',
				key: 'defaultDateLocale',
				label: 'Date locale',
				placeholder: 'defaults to VS Code locale',
				hint: 'Use "system" for the system locale, or a [locale language tag](https://en.wikipedia.org/wiki/IETF_language_tag), e.g. en-US',
				preview: { type: 'date-locale', defaultLookup: 'defaultDateFormat' },
			},
			{
				kind: 'text',
				key: 'defaultDateFormat',
				label: 'Date format',
				placeholder: 'defaults to MMMM Do, YYYY h:mma',
				hint: 'See the [Moment.js docs](https://momentjs.com/docs/#/displaying/format/) for supported formats',
				preview: { type: 'date', default: 'MMMM Do, YYYY h:mma' },
			},
			{
				kind: 'text',
				key: 'defaultDateShortFormat',
				label: 'Short date format',
				placeholder: 'defaults to system short date format',
				preview: { type: 'date', default: 'short' },
			},
			{
				kind: 'text',
				key: 'defaultTimeFormat',
				label: 'Time format',
				placeholder: 'defaults to h:mma',
				preview: { type: 'date', default: 'h:mma' },
			},
		],
	},
	{
		// The legacy section id was 'views'; the anchor alias in categories/index.ts maps it here
		id: 'sorting',
		name: 'Sorting',
		group: 'General',
		icon: 'list-ordered',
		hint: 'Controls how repositories, branches, tags & contributors are sorted in views',
		controls: [
			{
				kind: 'select',
				key: 'sortRepositoriesBy',
				label: 'Sort repositories',
				options: [
					// The legacy partial's value was 'dcovered' — a typo; 'discovered' is the real enum value
					{ value: 'discovered', label: 'by discovery or workspace order' },
					{ value: 'lastFetched:desc', label: 'by last fetched date, descending' },
					{ value: 'lastFetched:asc', label: 'by last fetched date, ascending' },
					{ value: 'name:asc', label: 'by name, ascending' },
					{ value: 'name:desc', label: 'by name, descending' },
				],
			},
			{
				kind: 'select',
				key: 'sortBranchesBy',
				label: 'Sort branches',
				options: [
					{ value: 'date:desc', label: 'by recent commit date, descending' },
					{ value: 'date:asc', label: 'by recent commit date, ascending' },
					{ value: 'name:asc', label: 'by name, ascending' },
					{ value: 'name:desc', label: 'by name, descending' },
				],
			},
			{
				kind: 'select',
				key: 'sortTagsBy',
				label: 'Sort tags',
				options: [
					{ value: 'date:desc', label: 'by recent commit date, descending' },
					{ value: 'date:asc', label: 'by recent commit date, ascending' },
					{ value: 'name:asc', label: 'by name, ascending' },
					{ value: 'name:desc', label: 'by name, descending' },
				],
			},
			{
				kind: 'select',
				key: 'sortContributorsBy',
				label: 'Sort contributors',
				options: [
					{ value: 'count:desc', label: 'by commit count, descending' },
					{ value: 'count:asc', label: 'by commit count, ascending' },
					{ value: 'date:desc', label: 'by recent commit date, descending' },
					{ value: 'date:asc', label: 'by recent commit date, ascending' },
					{ value: 'name:asc', label: 'by name, ascending' },
					{ value: 'name:desc', label: 'by name, descending' },
				],
			},
		],
	},
	{
		id: 'menus',
		settingsSearch: 'gitlens.menus',
		name: 'Menus & Toolbars',
		group: 'General',
		icon: 'ellipsis',
		hint: 'Adds many helpful commands to the built-in menus & toolbars',
		master: {
			kind: 'check',
			key: 'menus',
			label: 'Menus & Toolbars',
			checkedRemoves: true,
		},
		controls: [
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editor',
				label: 'Add to the editor context menu',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editor.compare',
				label: 'Add an Open Changes submenu',
				enabledWhen: 'menus.editor',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editor.remote',
				label: 'Add an Open on Remote (Web) submenu',
				enabledWhen: 'menus.editor',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editor.blame',
				label: 'Add a File Annotations submenu',
				enabledWhen: 'menus.editor',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editor.history',
				label: 'Add a File History submenu',
				enabledWhen: 'menus.editor',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editor.clipboard',
				label: 'Add to the Copy As submenu',
				enabledWhen: 'menus.editor',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorGutter',
				label: "Add to the editor's line number (gutter) context menu",
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorGutter.share',
				label: 'Add a Share submenu',
				enabledWhen: 'menus.editorGutter',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorGutter.compare',
				label: 'Add an Open Changes submenu',
				enabledWhen: 'menus.editorGutter',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorGutter.remote',
				label: 'Add an Open on Remote (Web) submenu',
				enabledWhen: 'menus.editorGutter',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorTab',
				label: 'Add to the editor tab context menu',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorTab.clipboard',
				label: 'Add Copy Remote File URL * commands',
				enabledWhen: 'menus.editorTab',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorTab.compare',
				label: 'Add an Open Changes submenu',
				enabledWhen: 'menus.editorTab',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorTab.remote',
				label: 'Add an Open on Remote (Web) submenu',
				enabledWhen: 'menus.editorTab',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorTab.history',
				label: 'Add a File History submenu',
				enabledWhen: 'menus.editorTab',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorGroup',
				label: 'Add to the editor group toolbar',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorGroup.compare',
				label: 'Add revision history navigation commands',
				enabledWhen: 'menus.editorGroup',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'editorGroup.blame',
				// Legacy was a composite row: checkbox labeled 'Add' followed by the select below
				label: 'Add a File Annotations submenu or command',
				enabledWhen: 'menus.editorGroup',
				indent: true,
			},
			{
				kind: 'select',
				key: 'fileAnnotations.command',
				label: 'Add',
				options: [
					{ value: 'null', label: 'File Annotations submenu' },
					{ value: 'blame', label: 'Toggle File Blame command' },
					{ value: 'heatmap', label: 'Toggle File Heatmap command' },
					{ value: 'changes', label: 'Toggle File Changes command' },
				],
				enabledWhen: 'menus.editorGroup & menus.editorGroup.blame',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'explorer',
				label: 'Add to the Explorer items context menu',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'explorer.compare',
				label: 'Add an Open Changes submenu',
				enabledWhen: 'menus.explorer',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'explorer.remote',
				label: 'Add an Open on Remote (Web) submenu',
				enabledWhen: 'menus.explorer',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'explorer.history',
				label: 'Add a File History submenu',
				enabledWhen: 'menus.explorer',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'explorer.clipboard',
				label: 'Add Copy Remote File URL * commands',
				enabledWhen: 'menus.explorer',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'ghpr',
				label: "Add to the GitHub Pull Request and Issues' pull request context menu",
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'ghpr.worktree',
				label: 'Add an Open Worktree for Pull Request command',
				// The legacy partial had data-enablement="menus.scm" here — a copy/paste error
				// (flagged in parity-verification); the correct parent is menus.ghpr
				enabledWhen: 'menus.ghpr',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scm',
				label: 'Add to the Source Control context menu',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scm.graph',
				label: 'Add a Show Commit Graph command',
				enabledWhen: 'menus.scm',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scm.visualHistory',
				label: 'Add a Visualize Repository History command',
				enabledWhen: 'menus.scm',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepositoryInline',
				label: 'Add to the Source Control repository toolbar',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepositoryInline.stash',
				label: 'Add a Stash All Changes command',
				enabledWhen: 'menus.scmRepositoryInline',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepositoryInline.graph',
				label: 'Add a Show Commit Graph command',
				enabledWhen: 'menus.scmRepositoryInline',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepositoryInline.visualHistory',
				label: 'Add a Visualize Repository History command',
				enabledWhen: 'menus.scmRepositoryInline',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepository',
				label: 'Add to the Source Control repository context menu',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepository.generateCommitMessage',
				label: 'Add a Generate Commit Message (Experimental) command',
				enabledWhen: 'menus.scmRepository',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepository.authors',
				label: 'Add an Add Co-authors command',
				enabledWhen: 'menus.scmRepository',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepository.graph',
				label: 'Add a Show Commit Graph command',
				enabledWhen: 'menus.scmRepository',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmRepository.visualHistory',
				label: 'Add a Visualize Repository History command',
				enabledWhen: 'menus.scmRepository',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmGroupInline',
				label: 'Add to the Source Control groups toolbar',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmGroupInline.stash',
				label: 'Add a Stash All Changes command',
				enabledWhen: 'menus.scmGroupInline',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmGroup',
				label: 'Add to the Source Control groups context menu',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmGroup.stash',
				label: 'Add a Stash All Changes command',
				enabledWhen: 'menus.scmGroup',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmGroup.compare',
				label: 'Add an Open Changes submenu',
				enabledWhen: 'menus.scmGroup',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmGroup.openClose',
				label: 'Add Open Changed Files and Close Unchanged Files commands',
				enabledWhen: 'menus.scmGroup',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmGroup.patch',
				label: 'Add Copy as Patch and Share as Cloud Patch... commands',
				enabledWhen: 'menus.scmGroup',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItemInline',
				label: 'Add to the Source Control items toolbar',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItemInline.stash',
				label: 'Add a Stash Changes command',
				enabledWhen: 'menus.scmItemInline',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItem',
				label: 'Add to the Source Control items context menu',
				checkedRemoves: true,
				enabledWhen: 'menus',
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItem.compare',
				label: 'Add an Open Changes with submenu',
				enabledWhen: 'menus.scmItem',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItem.remote',
				label: 'Add an Open on Remote (Web) submenu',
				enabledWhen: 'menus.scmItem',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItem.history',
				label: 'Add a File History submenu',
				enabledWhen: 'menus.scmItem',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItem.stash',
				label: 'Add a Stash Changes command',
				enabledWhen: 'menus.scmItem',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItem.share',
				label: 'Add a Share submenu',
				enabledWhen: 'menus.scmItem',
				indent: true,
			},
			{
				kind: 'check',
				type: 'object',
				key: 'menus',
				path: 'scmItem.clipboard',
				label: 'Add a Copy Relative Path command',
				enabledWhen: 'menus.scmItem',
				indent: true,
			},
		],
	},
	{
		id: 'shortcuts',
		name: 'Keyboard Shortcuts',
		group: 'General',
		icon: 'keyboard',
		hint: 'Controls the keyboard shortcuts GitLens registers',
		controls: [
			{
				kind: 'select',
				key: 'keymap',
				label: 'Use keyboard shortcuts',
				options: [
					{ value: 'alternate', label: 'alt-based' },
					{ value: 'chorded', label: 'chorded (default)' },
					{ value: 'none', label: 'user-defined' },
				],
			},
			{
				kind: 'info',
				text: 'Alt based (⌥ on macOS) shortcuts. Not great for non-English keyboard layouts',
				visibleWhen: 'keymap =alternate',
			},
			{
				kind: 'info',
				text: 'Chorded shortcuts that start with Ctrl+Shift+G (⌥⌘G on macOS). Better for non-English keyboard layouts',
				visibleWhen: 'keymap =chorded',
			},
			{
				kind: 'info',
				text: "GitLens won't bind any keyboard shortcuts. Configure your own via the Keyboard Shortcuts editor",
				visibleWhen: 'keymap =none',
			},
			{
				kind: 'info',
				text: 'Search for gitlens in the [Keyboard Shortcuts editor](command:workbench.action.openGlobalKeybindings?%22gitlens%22) to see the shortcuts and to customize them further',
			},
		],
	},
	{
		id: 'modes',
		settingsSearch: 'gitlens.modes',
		name: 'Modes',
		group: 'General',
		icon: 'color-mode',
		hint: 'Supports user-defined modes for quickly toggling between sets of settings',
		command: { label: 'GitLens: Switch Mode', command: 'gitlens.switchMode' },
		learnMoreUrl: 'https://help.gitkraken.com/gitlens/gitlens-features/#modes',
		controls: [
			{
				kind: 'info',
				text: 'Use the GitLens: Toggle Review Mode command to toggle Review mode',
			},
			{
				kind: 'info',
				text: 'Use the GitLens: Toggle Zen Mode command to toggle Zen mode',
			},
			{
				kind: 'check',
				key: 'mode.statusBar.enabled',
				label: 'Show the active mode in the status bar',
			},
			{
				kind: 'segmented',
				key: 'mode.statusBar.alignment',
				label: 'Position the annotation on the',
				options: [
					{ value: 'left', label: 'left' },
					{ value: 'right', label: 'right' },
				],
				enabledWhen: 'mode.statusBar.enabled',
				indent: true,
			},
		],
	},
];
