/** * Viewer Initialization Helper * * Extracts initialization logic from Viewer.svelte to improve testability * and reduce complexity in the component. This follows CODE_REVIEW.md * recommendation 1.3: "Extract Viewer Initialization Logic" */ import type { ManifestEntry } from '../../core/state/manifests'; import type { MediaSource } from '../../iiif/mediaResolver'; import { type ImageFilters } from '../../core/types/filters'; import type { ViewBox } from '../../core/types/viewer'; import type { ViewerConfig } from '../../core/types/config'; import type { URLStateParams } from '../osd/URLStateManager'; /** * Configuration for viewer initialization */ export type ViewerInitConfig = { manifestId: string; initialCanvasIndex?: number; initialMediaIndex?: number; }; export type InitialViewerState = { selectedCanvasIndex: number; layoutMode: 'single' | 'two-page' | 'continuous' | 'gallery'; rotation: number; viewBox: ViewBox | null; }; /** Resolve startup defaults, with URL hash values taking precedence over config. */ export declare const resolveInitialViewerState: (config?: ViewerConfig, urlState?: URLStateParams) => InitialViewerState; /** * State that needs to be reset when manifest changes */ export type ManifestChangeState = { selectedCanvasIndex: number; selectedMediaIndex: number; viewBox: ViewBox | null; zoom: number; searchQuery: string; imageFilters: ImageFilters; }; /** * Result of media resolution */ export type MediaResolution = { mediaSources: MediaSource[]; mediaSource: MediaSource | null; mediaType: string | null; }; /** * Create initial state when manifest changes * Returns state that should be reset */ export declare const createManifestChangeState: () => ManifestChangeState; /** * Resolve media sources for a canvas * Extracts the logic for determining which media sources are available */ export declare const resolveMediaForCanvas: (manifestEntry: ManifestEntry | undefined, canvasId: string | undefined, canvasIndex: number, selectedMediaIndex: number) => MediaResolution; /** * Validate and clamp canvas index to valid range */ export declare const validateCanvasIndex: (canvasIndex: number, totalCanvases: number) => number; /** * Check if manifest has changed */ export declare const hasManifestChanged: (currentManifestId: string, previousManifestId: string) => boolean;