import type { FaqItem, PublicSocialLink } from './public'

export interface CreateNominationPayload {
  year: number
  categoryId?: number | null
  categoryGroupName?: string
  twitchUserId: string
  nominees?: string[]
  nominations?: Array<{
    name?: string
    streamUrl: string
  }>
}

export interface CreateClipPayload {
  year: number
  categoryId: number | null
  candidateId: number | null
  twitchUserId: string
  clipUrl: string
  title: string
  creator: string
}

export interface VoteEntryPayload {
  categoryId: number
  candidateId: number
}

export interface CreateVotePayload {
  seasonId: number
  twitchUserId: string
  entries: VoteEntryPayload[]
}

export interface CreateSeasonPayload {
  year: number
  name: string
  currentPhase: string
  isCurrent: boolean
  isCommunityOnly: boolean
  nominationStartsAt: string
  nominationEndsAt: string
  votingStartsAt: string
  votingEndsAt: string
  reviewStartsAt: string
  reviewEndsAt: string
  showDate: string
  showStartsAt: string
  copyStructureFromSeasonId?: number | null
}

export interface UpdateSeasonPayload {
  year: number
  name: string
  currentPhase: string
  isCurrent: boolean
  isCommunityOnly: boolean
  nominationStartsAt: string
  nominationEndsAt: string
  votingStartsAt: string
  votingEndsAt: string
  reviewStartsAt: string
  reviewEndsAt: string
  showDate: string
  showStartsAt: string
}

export interface UpsertCategoryPayload {
  groupName: string
  name: string
  slug: string
  description: string
  sortOrder: number
  maxNomineesPerUser: number
  viewerRangeMin: number | null
  viewerRangeMax: number | null
}

export interface UpsertCategoryGroupPayload {
  groupName: string
  description: string
  sortOrder: number
  maxNomineesPerUser: number
}

export interface AdminSubcategoryTemplatePayload {
  name: string
  slug: string
  sortOrder: number
  viewerRangeMin: number | null
  viewerRangeMax: number | null
}

export interface UpdateSeasonSubcategoryTemplatesPayload {
  templates: AdminSubcategoryTemplatePayload[]
}

export interface UpsertCandidatePayload {
  categoryId: number
  displayName: string
  channelSlug: string
  platform: string
  acceptanceStatus?: string | null
  acceptanceNote?: string | null
  clipCompilationUrl?: string | null
  clipCompilationTitle?: string | null
  clipCompilationPlatform?: string | null
  clipEmbedStatus?: string | null
}

export interface UpdateClipStatusPayload {
  status: string
  reviewNote?: string
}

export interface ResolveRiskFlagPayload {
  status: string
  reviewNote?: string
}

export interface BulkResolveRiskFlagsPayload {
  riskFlagIds: number[]
  status: string
  reviewNote?: string
}

export interface UpdateRiskRulePayload {
  key: string
  label: string
  enabled: boolean
  threshold: number
  windowMinutes: number
  severity: string
  description: string
}

export interface UpdateRiskRulesPayload {
  rules: UpdateRiskRulePayload[]
}

export interface UpdateWorkflowRulePayload {
  key: string
  label: string
  enabled: boolean
  limit: number
  mode: string
  description: string
}

export interface UpdateWorkflowRulesPayload {
  rules: UpdateWorkflowRulePayload[]
}

export interface UpdateTrackingRulesPayload {
  source: {
    providerKey: string
    providerLabel: string
    baseUrl: string
    notesSummary: string
    showManualReviewNotesInReview: boolean
  }
  importantMetrics: Array<{
    key: string
    label: string
    enabled: boolean
    sourceSupport: string
    description: string
    requiredForAutoClassification: boolean
    showInReview: boolean
    showInAdminSummary: boolean
    manualOverrideAllowed: boolean
    windowKey: string
    autoSupportedWindowKeys: string[]
    providerFieldKey: string | null
    topCount: number | null
    minPrimaryCategorySharePercent: number | null
    minPrimaryCategoryHours: number | null
    maxDistinctCategoriesBeforeFlag: number | null
    ignoredCategories: string[]
    matchAwardCategoryAgainstTopCategories: boolean
    flagIfAwardCategoryNotInTopX: boolean
    flagIfCategorySpreadTooWide: boolean
    flagIfNoCategoryContextAvailable: boolean
    minValue: number | null
    maxValue: number | null
  }>
  optionalMetrics: Array<{
    key: string
    label: string
    enabled: boolean
    sourceSupport: string
    description: string
    requiredForAutoClassification: boolean
    showInReview: boolean
    showInAdminSummary: boolean
    manualOverrideAllowed: boolean
    windowKey: string
    autoSupportedWindowKeys: string[]
    providerFieldKey: string | null
    topCount: number | null
    minPrimaryCategorySharePercent: number | null
    minPrimaryCategoryHours: number | null
    maxDistinctCategoriesBeforeFlag: number | null
    ignoredCategories: string[]
    matchAwardCategoryAgainstTopCategories: boolean
    flagIfAwardCategoryNotInTopX: boolean
    flagIfCategorySpreadTooWide: boolean
    flagIfNoCategoryContextAvailable: boolean
    minValue: number | null
    maxValue: number | null
  }>
  flags: Array<{
    key: string
    label: string
    enabled: boolean
    severity: string
    description: string
    autoTriggerEnabled: boolean
    requiresManualReview: boolean
    blocksApproval: boolean
    adminNoteRequiredOnOverride: boolean
  }>
  manualReviewNotes: string
}

export interface UpdateTrackingSourcePayload {
  source: {
    providerKey: string
    providerLabel: string
    baseUrl: string
    notesSummary: string
    showManualReviewNotesInReview: boolean
  }
}

export interface UpdateTrackingReviewNotesPayload {
  manualReviewNotes: string
  showManualReviewNotesInReview: boolean
}

export interface SetAwardResultPayload {
  categoryId: number
  candidateId: number
}

export interface UpsertArchivedWinnerPayload {
  year: number
  category: string
  subcategory: string
  winnerName: string
  winnerUrl: string
}

export interface ApproveNominationPayload {
  displayName: string
  channelSlug: string
  platform: string
  categoryId?: number | null
  reviewNote?: string
}

export interface RejectNominationPayload {
  reviewNote?: string
}

export interface ReopenRejectedNominationPayload {
  reviewNote?: string
}

export interface UpdateNominationTrackingReviewPayload {
  status: string
  reviewNote?: string
}

export interface UpdateNominationLinkBlacklistPayload {
  urls: string[]
}

export interface AddNominationLinkBlacklistEntryPayload {
  url: string
}

export interface UpdateSiteSettingsPayload {
  hostDisplayName: string
  hostTagline: string
  hostArtistName: string
  newsletterUrl: string
  shareXUrl: string
  shareDiscordUrl: string
  privacyEmail: string
  privacyPolicyContent: string
  imprintUrl: string
  imprintContent: string
  contactUrl: string
  contactContent: string
  sponsorsUrl: string
  sponsorsContent: string
  showactsUrl: string
  showactsContent: string
  streamBannerEyebrow: string
  streamBannerTitle: string
  streamBannerText: string
  streamBannerLiveButtonLabel: string
  streamBannerLiveButtonUrl: string
  streamBannerLockedButtonLabel: string
  streamBannerUseCompletedContent: boolean
  streamBannerCompletedEyebrow: string
  streamBannerCompletedTitle: string
  streamBannerCompletedText: string
  streamBannerCompletedButtonLabel: string
  streamBannerCompletedButtonUrl: string
  awardsSectionTitle: string
  awardsSectionDescription: string
  subcategoriesSectionTitle: string
  subcategoriesSectionDescription: string
  socialLinks: PublicSocialLink[]
  faq: FaqItem[]
  showactFormSchemaJson: string
}

export interface UpdateOperationalSettingsPayload {
  demoLoginEnabled: boolean
  demoLoginEmail: string
  demoLoginPassword?: string
  demoLoginTwitchUserId: string
  demoLoginDisplayName: string
  twitchClientId: string
  twitchClientSecret?: string
  twitchRedirectUri: string
  twitchScope: string
  sessionIdleTimeoutHours: number
  maintenanceModeEnabled: boolean
  maintenanceTitle: string
  maintenanceMessage: string
}

export interface UpdateOptionalFeatureSettingsPayload {
  clipSubmissionsEnabled: boolean
  clipReviewEnabled: boolean
  clipAdminMenuVisible: boolean
  clipSubmissionDisabledMessage: string
  showactApplicationsEnabled: boolean
  showactApplicationStartsAt: string | null
  showactApplicationEndsAt: string | null
  showactApplicationDisabledMessage: string
  sponsorsVisible: boolean
}

export interface UpsertSponsorPayload {
  name: string
  websiteUrl: string
  logoUrl: string
  description: string
  tier: string
  sortOrder: number
  isVisible: boolean
}

export interface UpdateShowactStatusPayload {
  status: string
  reviewNote?: string
}

export interface CreateShowactApplicationPayload {
  artistName?: string
  contactEmail?: string
  contactDiscord?: string
  platformUrl?: string
  performanceType?: string
  description?: string
  technicalNotes?: string
  referenceUrl?: string
  fieldResponsesJson?: string
}
