/**
 * V4.0 作品状态常量（数值型）
 * 从 lesingle-aicreate-client/utils/status.js 迁移
 *
 * 状态流转: PENDING(1) -> PROCESSING(2) -> COMPLETED(3) -> CATALOGED(4) -> DUBBED(5)
 *           任意阶段可能 -> FAILED(-1)
 */
export const STATUS = {
  FAILED: -1,
  PENDING: 1,
  PROCESSING: 2,
  COMPLETED: 3,
  CATALOGED: 4,
  DUBBED: 5
} as const

export type StatusValue = typeof STATUS[keyof typeof STATUS]

/**
 * 根据作品状态决定应导航到的路由
 */
export function getRouteByStatus(status: StatusValue, workId: string): { name: string; params?: Record<string, string> } | null {
  switch (status) {
    case STATUS.PENDING:
    case STATUS.PROCESSING:
      return { name: 'PublicCreateCreating' }
    case STATUS.COMPLETED:
      return { name: 'PublicCreatePreview', params: { workId } }
    case STATUS.CATALOGED:
      return { name: 'PublicCreateDubbing', params: { workId } }
    case STATUS.DUBBED:
      return { name: 'PublicCreateEditInfo', params: { workId } }
    case STATUS.FAILED:
      return null
    default:
      return null
  }
}
