/**
 * Canvas Settings State Types
 *
 * Event-action mappings, presets, persisted state, and default mappings.
 *
 * Extracted from settings-types.ts in v1.9.0.
 *
 * @since 1.9.0
 */

import { CanvasEventType } from './event-types';
import { BuiltInActionId } from './action-types';

// =============================================================================
// Event-Action Mappings
// =============================================================================

/**
 * Mapping of events to action IDs.
 */
export type EventActionMapping = {
	[K in CanvasEventType]: string;
};

// =============================================================================
// Presets
// =============================================================================

/**
 * A settings preset with a name and full event-action mappings.
 */
export interface SettingsPreset {
	id: string;
	name: string;
	description?: string;
	mappings: EventActionMapping;
	isBuiltIn: boolean;
}

// =============================================================================
// Persisted State
// =============================================================================

/**
 * The full settings state that gets persisted to localStorage.
 */
export interface CanvasSettingsState {
	mappings: EventActionMapping;
	activePresetId: string | null;
	customPresets: SettingsPreset[];
	isPanelOpen: boolean;
	virtualizationEnabled: boolean;
}

// =============================================================================
// Default Mappings
// =============================================================================

/**
 * Default event-action mappings (the "Default" preset).
 */
export const DEFAULT_MAPPINGS: EventActionMapping = {
	[CanvasEventType.NodeClick]: BuiltInActionId.None,
	[CanvasEventType.NodeDoubleClick]: BuiltInActionId.FitToView,
	[CanvasEventType.NodeTripleClick]: BuiltInActionId.ToggleLock,
	[CanvasEventType.NodeRightClick]: BuiltInActionId.OpenContextMenu,
	[CanvasEventType.NodeLongPress]: BuiltInActionId.OpenContextMenu,
	[CanvasEventType.EdgeClick]: BuiltInActionId.SelectEdge,
	[CanvasEventType.EdgeDoubleClick]: BuiltInActionId.None,
	[CanvasEventType.EdgeRightClick]: BuiltInActionId.OpenContextMenu,
	[CanvasEventType.BackgroundClick]: BuiltInActionId.ClearSelection,
	[CanvasEventType.BackgroundDoubleClick]: BuiltInActionId.FitAllToView,
	[CanvasEventType.BackgroundRightClick]: BuiltInActionId.None,
	[CanvasEventType.BackgroundLongPress]: BuiltInActionId.CreateNode,
};
