import type { AnkiConnectConfig } from '../../types'; import type { createBuildInitializeOverlayRuntimeOptionsHandler } from './overlay-runtime-options'; type OverlayRuntimeOptionsMainDeps = Parameters< typeof createBuildInitializeOverlayRuntimeOptionsHandler >[0]; export function createBuildInitializeOverlayRuntimeMainDepsHandler(deps: { appState: { backendOverride: string | null; windowTracker: Parameters[0]; subtitleTimingTracker: ReturnType; mpvClient: ReturnType; mpvSocketPath: string; runtimeOptionsManager: ReturnType; ankiIntegration: Parameters[0]; }; overlayManager: { getVisibleOverlayVisible: () => boolean; }; overlayVisibilityRuntime: { updateVisibleOverlayVisibility: () => void; }; overlayShortcutsRuntime: { syncOverlayShortcuts: () => void; }; createMainWindow: () => void; registerGlobalShortcuts: () => void; updateVisibleOverlayBounds: (geometry: { x: number; y: number; width: number; height: number; }) => void; getOverlayWindows: OverlayRuntimeOptionsMainDeps['getOverlayWindows']; getResolvedConfig: () => { ankiConnect?: AnkiConnectConfig }; showDesktopNotification: (title: string, options: { body?: string; icon?: string }) => void; createFieldGroupingCallback: OverlayRuntimeOptionsMainDeps['createFieldGroupingCallback']; getKnownWordCacheStatePath: () => string; }) { return (): OverlayRuntimeOptionsMainDeps => ({ getBackendOverride: () => deps.appState.backendOverride, createMainWindow: () => deps.createMainWindow(), registerGlobalShortcuts: () => deps.registerGlobalShortcuts(), updateVisibleOverlayBounds: (geometry: { x: number; y: number; width: number; height: number; }) => deps.updateVisibleOverlayBounds(geometry), isVisibleOverlayVisible: () => deps.overlayManager.getVisibleOverlayVisible(), updateVisibleOverlayVisibility: () => deps.overlayVisibilityRuntime.updateVisibleOverlayVisibility(), getOverlayWindows: () => deps.getOverlayWindows(), syncOverlayShortcuts: () => deps.overlayShortcutsRuntime.syncOverlayShortcuts(), setWindowTracker: (tracker) => { deps.appState.windowTracker = tracker; }, getResolvedConfig: () => deps.getResolvedConfig(), getSubtitleTimingTracker: () => deps.appState.subtitleTimingTracker, getMpvClient: () => deps.appState.mpvClient, getMpvSocketPath: () => deps.appState.mpvSocketPath, getRuntimeOptionsManager: () => deps.appState.runtimeOptionsManager, setAnkiIntegration: (integration) => { deps.appState.ankiIntegration = integration; }, showDesktopNotification: deps.showDesktopNotification, createFieldGroupingCallback: () => deps.createFieldGroupingCallback(), getKnownWordCacheStatePath: () => deps.getKnownWordCacheStatePath(), }); }