import type { ContentFilter } from '../services/FeedService'

/**
 * Predefined content filters for different types of Nostr content
 */
export const CONTENT_FILTERS: Record<string, ContentFilter> = {
  // Text content
  textNotes: {
    id: 'text-notes',
    label: 'Text Posts',
    kinds: [1], // NIP-01: Short Text Note
    description: 'Regular text posts and announcements'
  },

  // Admin/moderator announcements
  adminAnnouncements: {
    id: 'admin-announcements',
    label: 'Admin Announcements',
    kinds: [1],
    description: 'Official announcements from administrators',
    filterByAuthor: 'admin'
  },

  // General community posts (excluding admin)
  communityPosts: {
    id: 'community-posts',
    label: 'Community Posts',
    kinds: [1],
    description: 'Posts from community members',
    filterByAuthor: 'exclude-admin'
  },


  // Chat messages (if user wants to see them in feed)
  chatMessages: {
    id: 'chat-messages',
    label: 'Chat Messages',
    kinds: [4], // NIP-04: Encrypted Direct Messages
    description: 'Private messages (requires authentication)',
    requiresAuth: true
  },

  // Events and calendar
  calendarEvents: {
    id: 'calendar-events',
    label: 'Calendar Events',
    kinds: [31922, 31923], // NIP-52: Calendar Events
    description: 'Calendar events and time-based activities'
  },

  // Long-form content
  longFormContent: {
    id: 'long-form',
    label: 'Articles',
    kinds: [30023], // NIP-23: Long-form Content
    description: 'Long-form articles and blog posts'
  },

  // Reactions and social
  reactions: {
    id: 'reactions',
    label: 'Reactions',
    kinds: [7], // NIP-25: Reactions
    description: 'Likes, reactions, and responses'
  },

  // Reposts/shares
  reposts: {
    id: 'reposts',
    label: 'Reposts',
    kinds: [6, 16], // NIP-18: Reposts, NIP-18: Generic Reposts
    description: 'Shared and reposted content'
  },

  // Live events
  liveEvents: {
    id: 'live-events',
    label: 'Live Events',
    kinds: [30311], // NIP-53: Live Events
    description: 'Live streaming and real-time events'
  },

  // Rideshare content
  rideshare: {
    id: 'rideshare',
    label: 'Rideshare',
    kinds: [1, 31001], // Text notes + custom rideshare events
    description: 'Rideshare requests, offers, and coordination',
    tags: ['rideshare', 'uber', 'lyft', 'carpool', 'taxi', 'ride'], // NIP-12 tags
    keywords: ['rideshare', 'ride share', 'carpool', 'uber', 'lyft', 'taxi', 'pickup', 'dropoff']
  }
}

/**
 * Predefined filter combinations for common use cases
 */
export const FILTER_PRESETS: Record<string, ContentFilter[]> = {
  // Basic presets
  all: [
    CONTENT_FILTERS.textNotes,
    CONTENT_FILTERS.calendarEvents,
    CONTENT_FILTERS.longFormContent
    // Note: reactions (kind 7) are handled separately by ReactionService
  ],

  announcements: [
    CONTENT_FILTERS.adminAnnouncements,
    CONTENT_FILTERS.textNotes  // Include all text posts as fallback
  ],

  community: [
    CONTENT_FILTERS.communityPosts,
    CONTENT_FILTERS.reposts
    // Note: reactions are handled separately for counts
  ],


  social: [
    CONTENT_FILTERS.textNotes,
    CONTENT_FILTERS.reposts,
    CONTENT_FILTERS.chatMessages
    // Note: reactions are for interaction counts, not displayed as posts
  ],

  events: [
    CONTENT_FILTERS.calendarEvents,
    CONTENT_FILTERS.liveEvents
  ],

  content: [
    CONTENT_FILTERS.longFormContent,
    CONTENT_FILTERS.textNotes
  ],

  rideshare: [
    CONTENT_FILTERS.rideshare
  ]
}

/**
 * Get content filters by category
 */
export function getContentFiltersByCategory(category: keyof typeof FILTER_PRESETS): ContentFilter[] {
  return FILTER_PRESETS[category] || []
}

/**
 * Get all available content filters
 */
export function getAllContentFilters(): ContentFilter[] {
  return Object.values(CONTENT_FILTERS)
}