/**
 * ImageViewer type definitions
 */

// =============================================================================
// FILE TYPES
// =============================================================================

export interface ImageFile {
  /** Display name for the image */
  name: string;
  /** File path used for change detection and caching */
  path: string;
  /** Optional MIME type */
  mimeType?: string;
}

export interface ImageItem {
  /** File info for this image */
  file: ImageFile;
  /** Direct image URL (use when serving from CDN/server) */
  src?: string;
  /** Raw image content — ArrayBuffer or base64/binary string (use when serving from memory) */
  content?: string | ArrayBuffer;
}

// =============================================================================
// COMPONENT PROPS
// =============================================================================

export interface ImageViewerProps {
  /**
   * Gallery images array.
   * When provided, enables gallery mode with prev/next navigation.
   * Single-image mode: pass one item.
   * Each item can have `src` (URL) or `content` (ArrayBuffer/base64) or both.
   */
  images: ImageItem[];
  /**
   * Initial index to show (default: 0).
   * Useful when opening a specific image from a grid.
   */
  initialIndex?: number;
  /** Hide expand button when already in dialog */
  inDialog?: boolean;
  /** Focus the viewer container on mount so its keyboard scope is active
   *  immediately (zoom/rotate/gallery hotkeys). Pair with `key={src}`
   *  upstream when the parent wants a fresh focus per source change. */
  autoFocus?: boolean;
}

export interface ImageToolbarProps {
  /** Current zoom scale */
  scale: number;
  /** Current transform state */
  transform: ImageTransform;
  /** Rotate image callback */
  onRotate: () => void;
  /** Flip horizontal callback */
  onFlipH: () => void;
  /** Flip vertical callback */
  onFlipV: () => void;
  /** Zoom preset selection callback */
  onZoomPreset: (value: number | 'fit') => void;
  /** Expand to fullscreen callback (undefined hides button) */
  onExpand?: () => void;
}

export interface ImageInfoProps {
  /** Image source URL */
  src: string;
}

// =============================================================================
// STATE TYPES
// =============================================================================

export interface ImageTransform {
  /** Rotation angle: 0, 90, 180, or 270 degrees */
  rotation: number;
  /** Horizontal flip state */
  flipH: boolean;
  /** Vertical flip state */
  flipV: boolean;
}

// =============================================================================
// UI TYPES
// =============================================================================

export interface ZoomPreset {
  /** Display label (e.g., "100%", "Fit") */
  label: string;
  /** Zoom value or 'fit' for fit-to-view */
  value: number | 'fit';
}
