import { List } from '@iqser/common-ui/lib/utils';

export const FILE_ID = 'fileId';

export const WorkflowFileStatuses = {
    APPROVED: 'APPROVED',
    NEW: 'NEW',
    UNASSIGNED: 'UNASSIGNED',
    UNDER_APPROVAL: 'UNDER_APPROVAL',
    UNDER_REVIEW: 'UNDER_REVIEW',
} as const;

export type WorkflowFileStatus = keyof typeof WorkflowFileStatuses;

export const ProcessingFileStatuses = {
    ANALYSE: 'ANALYSE',
    ERROR: 'ERROR',
    FULLREPROCESS: 'FULLREPROCESS',
    IMAGE_ANALYZING: 'IMAGE_ANALYZING',
    INDEXING: 'INDEXING',
    NER_ANALYZING: 'NER_ANALYZING',
    OCR_PROCESSING_QUEUED: 'OCR_PROCESSING_QUEUED',
    OCR_PROCESSING: 'OCR_PROCESSING',
    PROCESSED: 'PROCESSED',
    PROCESSING: 'PROCESSING',
    REPROCESS: 'REPROCESS',
    SURROUNDING_TEXT_PROCESSING: 'SURROUNDING_TEXT_PROCESSING',
    UNPROCESSED: 'UNPROCESSED',
    FULL_PROCESSING: 'FULL_PROCESSING',
    PRE_PROCESSING_QUEUED: 'PRE_PROCESSING_QUEUED',
    PRE_PROCESSING: 'PRE_PROCESSING',
    PRE_PROCESSED: 'PRE_PROCESSED',
    FIGURE_DETECTION_ANALYZING: 'FIGURE_DETECTION_ANALYZING',
    TABLE_PARSING_ANALYZING: 'TABLE_PARSING_ANALYZING',
} as const;

export type ProcessingFileStatus = keyof typeof ProcessingFileStatuses;

export const isProcessingStatuses: List<ProcessingFileStatus> = [
    ProcessingFileStatuses.ANALYSE,
    ProcessingFileStatuses.FULLREPROCESS,
    ProcessingFileStatuses.REPROCESS,
    ProcessingFileStatuses.SURROUNDING_TEXT_PROCESSING,
    ProcessingFileStatuses.OCR_PROCESSING,
    ProcessingFileStatuses.IMAGE_ANALYZING,
    ProcessingFileStatuses.NER_ANALYZING,
    ProcessingFileStatuses.INDEXING,
    ProcessingFileStatuses.PROCESSING,
    ProcessingFileStatuses.FULL_PROCESSING,
    ProcessingFileStatuses.PRE_PROCESSING,
    ProcessingFileStatuses.TABLE_PARSING_ANALYZING,
] as const;

export const isFullProcessingStatuses: List<ProcessingFileStatus> = [
    ProcessingFileStatuses.ANALYSE,
    ProcessingFileStatuses.FULLREPROCESS,
    ProcessingFileStatuses.IMAGE_ANALYZING,
    ProcessingFileStatuses.NER_ANALYZING,
    ProcessingFileStatuses.OCR_PROCESSING_QUEUED,
    ProcessingFileStatuses.OCR_PROCESSING,
    ProcessingFileStatuses.UNPROCESSED,
    ProcessingFileStatuses.FULL_PROCESSING,
    ProcessingFileStatuses.PRE_PROCESSING_QUEUED,
    ProcessingFileStatuses.PRE_PROCESSING,
    ProcessingFileStatuses.TABLE_PARSING_ANALYZING,
] as const;

export interface StatusBarConfig {
    readonly length: number;
    readonly color: WorkflowFileStatus;
}

export type StatusBarConfigs = List<StatusBarConfig>;

export const PENDING_STATES: ProcessingFileStatus[] = [
    ProcessingFileStatuses.ANALYSE,
    ProcessingFileStatuses.ERROR,
    ProcessingFileStatuses.FULLREPROCESS,
    ProcessingFileStatuses.REPROCESS,
    ProcessingFileStatuses.UNPROCESSED,
    ProcessingFileStatuses.PRE_PROCESSED,
];

export const PROCESSING_STATES: ProcessingFileStatus[] = [
    ProcessingFileStatuses.IMAGE_ANALYZING,
    ProcessingFileStatuses.INDEXING,
    ProcessingFileStatuses.NER_ANALYZING,
    ProcessingFileStatuses.PROCESSING,
    ProcessingFileStatuses.SURROUNDING_TEXT_PROCESSING,
    ProcessingFileStatuses.FULL_PROCESSING,
    ProcessingFileStatuses.PRE_PROCESSING_QUEUED,
    ProcessingFileStatuses.PRE_PROCESSING,
    ProcessingFileStatuses.FIGURE_DETECTION_ANALYZING,
    ProcessingFileStatuses.TABLE_PARSING_ANALYZING,
];

export const PROCESSED_STATES: ProcessingFileStatus[] = [ProcessingFileStatuses.PROCESSED];

export const OCR_STATES: ProcessingFileStatus[] = [ProcessingFileStatuses.OCR_PROCESSING, ProcessingFileStatuses.OCR_PROCESSING_QUEUED];
