/**
 * Photo-related type definitions
 */

import type { PhotoSubmissionItem } from './photo-submissions';

// Re-export for convenience
export type { PhotoSubmissionItem } from './photo-submissions';

// Core photo display interface
export interface PhotoItem {
  id: string;
  url: string;
  filename: string;
  caption?: string | null;
  size?: number;
  type?: string;
  title?: string | null;
  date_taken?: string | null;
}

// Normalized photo for consistent display
export interface NormalizedPhoto {
  id: string;
  url: string;
  filename: string;
  caption?: string;
  title?: string;
  date_taken?: string;
  order_index: number;
}

// Photo data source types
export type PhotoDataSource = 
  | { type: 'review'; photos: PhotoItem[] }
  | { type: 'submission_jsonb'; photos: PhotoItem[] }
  | { type: 'submission_items'; items: PhotoSubmissionItem[] };

// Type guard for photo arrays
export function isPhotoItem(data: unknown): data is PhotoItem {
  return (
    typeof data === 'object' &&
    data !== null &&
    'id' in data &&
    'url' in data &&
    'filename' in data
  );
}

// Type guard for photo arrays
export function isPhotoItemArray(data: unknown): data is PhotoItem[] {
  return Array.isArray(data) && (data.length === 0 || isPhotoItem(data[0]));
}
