import type { App, Component } from 'vue'
import type { RouteRecordRaw } from 'vue-router'

// Base module plugin interface
export interface ModulePlugin {
  /** Unique module name */
  name: string
  
  /** Module version */
  version: string
  
  /** Required dependencies (other module names) */
  dependencies?: string[]
  
  /** Module configuration */
  config?: Record<string, any>
  
  /** Install the module */
  install(app: App, options?: any): Promise<void> | void
  
  /** Uninstall the module (cleanup) */
  uninstall?(): Promise<void> | void
  
  /** Routes provided by this module */
  routes?: RouteRecordRaw[]
  
  /** Components provided by this module */
  components?: Record<string, Component>
  
  /** Services provided by this module */
  services?: Record<string, any>
  
  /** Composables provided by this module */
  composables?: Record<string, any>
}

// Module configuration for app setup
export interface ModuleConfig {
  /** Module name */
  name: string
  
  /** Whether module is enabled */
  enabled: boolean
  
  /** Module-specific configuration */
  config?: Record<string, any>
  
  /** Load module dynamically */
  lazy?: boolean
}

// App configuration
export interface AppConfig {
  /** Configured modules */
  modules: Record<string, ModuleConfig>
  
  /** Global app features */
  features: {
    pwa: boolean
    pushNotifications: boolean
    electronApp: boolean
    developmentMode: boolean
  }
}

// Module registration info
export interface ModuleRegistration {
  plugin: ModulePlugin
  config: ModuleConfig
  installed: boolean
  installTime?: number
}

// Event system for inter-module communication
export interface ModuleEvent {
  type: string
  source: string
  data: any
  timestamp: number
}

export type ModuleEventHandler = (event: ModuleEvent) => void

// Service injection tokens
export type ServiceToken = string | symbol

// Dependency injection container interface
export interface DIContainer {
  provide<T>(token: ServiceToken, service: T, scope?: 'singleton' | 'transient'): void
  inject<T>(token: ServiceToken): T | undefined
  remove(token: ServiceToken): boolean
  clear(): void
}