import type { CatalogNodeEntry } from '../workflow-node-catalog'

export const BATTLE_NODES: CatalogNodeEntry[] = [
  {
    type: 'battle_create',
    label: 'Battle Create',
    description: 'Create a new battle with contenders, prompt, judge strategy, and visibility settings.',
    category: 'battle',
    color: 'text-orange-500',
    iconName: 'Swords',
    inputs: [{ name: 'config', type: 'json', description: 'Optional dynamic battle parameters' }],
    outputs: [{ name: 'battle', type: 'json', description: 'Created battle record with ID and status' }],
    requiredConfig: ['promptTemplateId', 'contenderLensIds'],
    optionalConfig: ['title', 'visibility', 'judgeStrategy', 'maxRounds', 'fundingSource'],
    exampleConfig: {
      promptTemplateId: 'c3d4e5f6-a7b8-9012-cdef-123456789012',
      contenderLensIds: ['lens-a-uuid', 'lens-b-uuid'],
      title: 'Creative Writing Battle: Sonnet vs Opus',
      visibility: 'public',
      judgeStrategy: 'community_vote',
      maxRounds: 3,
      fundingSource: 'platform',
    },
    acceptsInputTypes: ['json', 'any', 'void'],
    producesOutputType: 'json',
    docsPath: '/en/explanation/battles/automation',
  },
  {
    type: 'battle_execute',
    label: 'Battle Execute',
    description: 'Execute all contender runs for a battle and collect outputs.',
    category: 'battle',
    color: 'text-orange-500',
    iconName: 'Play',
    inputs: [{ name: 'battle', type: 'json', required: true, description: 'Battle record from Battle Create' }],
    outputs: [
      { name: 'results', type: 'battle_result', description: 'All contender outputs and execution metadata' },
    ],
    requiredConfig: [],
    optionalConfig: ['timeoutMs', 'parallel', 'fundingSource'],
    exampleConfig: { timeoutMs: 60000, parallel: true, fundingSource: 'platform' },
    acceptsInputTypes: ['json', 'any'],
    producesOutputType: 'battle_result',
    docsPath: '/en/explanation/battles/execution',
  },
  {
    type: 'contender_run',
    label: 'Contender Run',
    description: 'Execute a single contender Lens within a battle context.',
    category: 'battle',
    color: 'text-orange-500',
    iconName: 'UserRound',
    inputs: [{ name: 'prompt', type: 'text', required: true, description: 'Battle prompt for the contender' }],
    outputs: [
      { name: 'output', type: 'text', description: 'Contender generated output' },
      { name: 'metadata', type: 'json', description: 'Execution metadata (tokens, duration, model)' },
    ],
    requiredConfig: ['lensId', 'model_id'],
    optionalConfig: ['slot', 'maxTokens', 'temperature'],
    exampleConfig: {
      lensId: 'd4e5f6a7-b8c9-0123-def0-123456789abc',
      model_id: 'claude-sonnet-4-6',
      slot: 'A',
      maxTokens: 4096,
      temperature: '0.8',
    },
    acceptsInputTypes: ['text', 'json', 'any'],
    producesOutputType: 'text',
  },
  {
    type: 'judge_battle',
    label: 'Judge Battle',
    description: 'Evaluate battle contender outputs using an AI judge or rubric-based scoring.',
    category: 'battle',
    color: 'text-orange-500',
    iconName: 'Scale',
    inputs: [{ name: 'results', type: 'battle_result', required: true, description: 'Battle execution results' }],
    outputs: [
      { name: 'verdict', type: 'json', description: 'Judge verdict with winner, scores, and reasoning' },
    ],
    requiredConfig: ['judgeLensId'],
    optionalConfig: ['rubric', 'scoringScale', 'tieBreakRule', 'model_id', 'confidenceThreshold'],
    exampleConfig: {
      judgeLensId: 'e5f6a7b8-c9d0-1234-ef01-23456789abcd',
      rubric: 'Evaluate creativity (0-10), accuracy (0-10), depth (0-10), and style (0-10)',
      scoringScale: 10,
      tieBreakRule: 'higher_creativity',
      model_id: 'claude-opus-4-6',
      confidenceThreshold: 0.7,
    },
    acceptsInputTypes: ['battle_result', 'json', 'any'],
    producesOutputType: 'json',
    docsPath: '/en/explanation/battles/judging',
  },
  {
    type: 'vote_collector',
    label: 'Vote Collector',
    description: 'Collect and tally community votes for a battle within a time window.',
    category: 'battle',
    color: 'text-orange-500',
    iconName: 'Vote',
    inputs: [{ name: 'battle', type: 'json', required: true, description: 'Battle record to collect votes for' }],
    outputs: [
      { name: 'tally', type: 'json', description: 'Vote counts per contender with voter breakdown' },
    ],
    requiredConfig: ['battleId'],
    optionalConfig: ['durationMs', 'minVotes', 'closingStrategy'],
    exampleConfig: {
      battleId: '{{n1.battle.id}}',
      durationMs: 86400000,
      minVotes: 10,
      closingStrategy: 'time_or_quorum',
    },
    acceptsInputTypes: ['json', 'any'],
    producesOutputType: 'json',
  },
  {
    type: 'score_aggregator',
    label: 'Score Aggregator',
    description: 'Aggregate judge scores and community votes into a final battle result.',
    category: 'battle',
    color: 'text-orange-500',
    iconName: 'BarChart3',
    inputs: [
      { name: 'judgeVerdict', type: 'json', description: 'AI judge verdict' },
      { name: 'voteTally', type: 'json', description: 'Community vote tally' },
    ],
    outputs: [
      { name: 'finalScore', type: 'json', description: 'Weighted final scores and winner declaration' },
    ],
    requiredConfig: ['weights'],
    optionalConfig: ['tieBreaker', 'minimumMargin'],
    exampleConfig: {
      weights: { judge: 0.6, community: 0.4 },
      tieBreaker: 'judge_preferred',
      minimumMargin: 0.05,
    },
    acceptsInputTypes: ['json', 'battle_result', 'any'],
    producesOutputType: 'json',
  },
  {
    type: 'leaderboard_update',
    label: 'Leaderboard Update',
    description: 'Update ELO ratings and leaderboard positions based on battle results.',
    category: 'battle',
    color: 'text-orange-500',
    iconName: 'Trophy',
    inputs: [{ name: 'result', type: 'json', required: true, description: 'Final battle result with winner' }],
    outputs: [{ name: 'update', type: 'json', description: 'Updated ratings and rank changes' }],
    requiredConfig: ['battleId'],
    optionalConfig: ['kFactor', 'leaderboardId'],
    exampleConfig: {
      battleId: '{{n1.battle.id}}',
      kFactor: 32,
      leaderboardId: 'global',
    },
    acceptsInputTypes: ['json', 'battle_result', 'any'],
    producesOutputType: 'json',
    docsPath: '/en/explanation/battles/elo',
  },
]
