/**
 * Settings Presets & Utilities
 *
 * Built-in presets and utility functions extracted from settings-store.ts.
 */

import {
	type EventActionMapping,
	type SettingsPreset,
	CanvasEventType,
	DEFAULT_MAPPINGS,
	BuiltInActionId,
} from './settings-types';

// =============================================================================
// Built-in Presets
// =============================================================================

export const BUILT_IN_PRESETS: SettingsPreset[] = [
	{
		id: 'default',
		name: 'Default',
		description: 'Standard canvas interactions',
		isBuiltIn: true,
		mappings: DEFAULT_MAPPINGS,
	},
	{
		id: 'minimal',
		name: 'Minimal',
		description: 'Only essential selection and context menu actions',
		isBuiltIn: true,
		mappings: {
			[CanvasEventType.NodeClick]: BuiltInActionId.None,
			[CanvasEventType.NodeDoubleClick]: BuiltInActionId.None,
			[CanvasEventType.NodeTripleClick]: BuiltInActionId.None,
			[CanvasEventType.NodeRightClick]: BuiltInActionId.OpenContextMenu,
			[CanvasEventType.NodeLongPress]: BuiltInActionId.OpenContextMenu,
			[CanvasEventType.EdgeClick]: BuiltInActionId.SelectEdge,
			[CanvasEventType.EdgeDoubleClick]: BuiltInActionId.None,
			[CanvasEventType.EdgeRightClick]: BuiltInActionId.None,
			[CanvasEventType.BackgroundClick]: BuiltInActionId.ClearSelection,
			[CanvasEventType.BackgroundDoubleClick]: BuiltInActionId.None,
			[CanvasEventType.BackgroundRightClick]: BuiltInActionId.None,
			[CanvasEventType.BackgroundLongPress]: BuiltInActionId.None,
		},
	},
	{
		id: 'power-user',
		name: 'Power User',
		description: 'Quick actions for experienced users',
		isBuiltIn: true,
		mappings: {
			[CanvasEventType.NodeClick]: BuiltInActionId.None,
			[CanvasEventType.NodeDoubleClick]: BuiltInActionId.ToggleLock,
			[CanvasEventType.NodeTripleClick]: BuiltInActionId.DeleteSelected,
			[CanvasEventType.NodeRightClick]: BuiltInActionId.OpenContextMenu,
			[CanvasEventType.NodeLongPress]: BuiltInActionId.AddToSelection,
			[CanvasEventType.EdgeClick]: BuiltInActionId.SelectEdge,
			[CanvasEventType.EdgeDoubleClick]: BuiltInActionId.None,
			[CanvasEventType.EdgeRightClick]: BuiltInActionId.OpenContextMenu,
			[CanvasEventType.BackgroundClick]: BuiltInActionId.ClearSelection,
			[CanvasEventType.BackgroundDoubleClick]: BuiltInActionId.CreateNode,
			[CanvasEventType.BackgroundRightClick]: BuiltInActionId.OpenContextMenu,
			[CanvasEventType.BackgroundLongPress]: BuiltInActionId.ApplyForceLayout,
		},
	},
];

// =============================================================================
// Utility Functions
// =============================================================================

/**
 * Get the action ID for a specific event from mappings.
 */
export function getActionForEvent(
	mappings: EventActionMapping,
	event: CanvasEventType
): string {
	return mappings[event] || BuiltInActionId.None;
}
