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

export const TRIGGER_NODES: CatalogNodeEntry[] = [
  {
    type: 'manual_trigger',
    label: 'Manual Trigger',
    description: 'Start a workflow manually from the Studio or API.',
    category: 'trigger',
    color: 'text-emerald-500',
    iconName: 'Play',
    inputs: [],
    outputs: [{ name: 'payload', type: 'json', description: 'User-supplied root inputs passed as structured payload' }],
    requiredConfig: [],
    optionalConfig: ['inputSchema'],
    exampleConfig: {
      inputSchema: { topic: 'string', audience: 'string', language: 'string' },
    },
    acceptsInputTypes: ['void'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.manualTrigger',
    docsPath: '/en/explanation/workflows/triggers',
  },
  {
    type: 'event_trigger',
    label: 'Event Trigger',
    description: 'Start a workflow when a platform event fires (battle completed, lens published, etc.).',
    category: 'trigger',
    color: 'text-emerald-500',
    iconName: 'Bell',
    inputs: [],
    outputs: [
      { name: 'event', type: 'json', description: 'Full event payload with type, data, and timestamp' },
    ],
    requiredConfig: ['eventType'],
    optionalConfig: ['filterExpression'],
    exampleConfig: {
      eventType: 'battle.completed',
      filterExpression: 'event.data.winner_id === ctx.lenserId',
    },
    acceptsInputTypes: ['void'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.webhook',
    docsPath: '/en/explanation/workflows/triggers',
  },
  {
    type: 'form_input_trigger',
    label: 'Form / Input Trigger',
    description: 'Start a workflow from a user-submitted form with validated fields.',
    category: 'trigger',
    color: 'text-emerald-500',
    iconName: 'ClipboardList',
    inputs: [],
    outputs: [{ name: 'formData', type: 'json', description: 'Validated form field values keyed by field name' }],
    requiredConfig: ['fields'],
    optionalConfig: ['title', 'description', 'submitLabel'],
    exampleConfig: {
      fields: [
        { name: 'prompt', type: 'text', required: true, label: 'Your question' },
        { name: 'context', type: 'textarea', required: false, label: 'Additional context' },
      ],
      title: 'Ask AI',
      submitLabel: 'Run Workflow',
    },
    acceptsInputTypes: ['void'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.formTrigger',
    docsPath: '/en/explanation/workflows/triggers',
  },
  {
    type: 'webhook_trigger',
    label: 'Webhook Trigger',
    description: 'Register an inbound webhook URL that triggers this workflow on HTTP request.',
    category: 'trigger',
    color: 'text-emerald-500',
    iconName: 'Webhook',
    inputs: [],
    outputs: [
      { name: 'payload', type: 'json', description: 'Parsed request body' },
      { name: 'headers', type: 'json', description: 'Incoming request headers' },
      { name: 'method', type: 'text', description: 'HTTP method (GET, POST, etc.)' },
      { name: 'path', type: 'text', description: 'Webhook path including query string' },
      { name: 'timestamp', type: 'text', description: 'ISO timestamp of the incoming request' },
    ],
    requiredConfig: ['secret'],
    optionalConfig: ['method', 'path', 'authMode', 'allowedHeaders', 'rateLimit'],
    exampleConfig: {
      secret: 'my-secure-webhook-secret-key-16ch',
      method: 'POST',
      path: '/hooks/battle-result',
      authMode: 'hmac',
      rateLimit: 100,
    },
    acceptsInputTypes: ['void'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.webhook',
    docsPath: '/en/explanation/workflows/triggers',
  },
  {
    type: 'schedule_trigger',
    label: 'Schedule Trigger',
    description: 'Run this workflow automatically on a cron schedule (minimum every 5 minutes).',
    category: 'trigger',
    color: 'text-emerald-500',
    iconName: 'CalendarClock',
    inputs: [],
    outputs: [
      { name: 'scheduledFor', type: 'text', description: 'ISO timestamp this run was scheduled for' },
      { name: 'timezone', type: 'text', description: 'Timezone used for schedule evaluation' },
      { name: 'cronExpression', type: 'text', description: 'The cron expression that fired this run' },
      { name: 'runId', type: 'text', description: 'Unique identifier for this scheduled run' },
    ],
    requiredConfig: ['cronExpression'],
    optionalConfig: ['timezone', 'enabled'],
    exampleConfig: {
      cronExpression: '0 9 * * 1',
      timezone: 'Europe/Istanbul',
      enabled: true,
    },
    acceptsInputTypes: ['void'],
    producesOutputType: 'json',
    n8nEquivalent: 'n8n-nodes-base.scheduleTrigger',
    docsPath: '/en/explanation/workflows/triggers',
  },
]
