export const queryKeys = {
  servers: {
    all: ['servers'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.servers.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.servers.all, 'detail', id] as const,
  },
  clusters: {
    all: ['clusters'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.clusters.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.clusters.all, 'detail', id] as const,
  },
  standingOrders: {
    all: ['standing-orders'] as const,
    list: () => [...queryKeys.standingOrders.all, 'list'] as const,
    detail: (id: string) => [...queryKeys.standingOrders.all, 'detail', id] as const,
    executions: (id: string) => [...queryKeys.standingOrders.all, 'executions', id] as const,
    stats: (id: string) => [...queryKeys.standingOrders.all, 'stats', id] as const,
  },
  auditLogs: {
    all: ['audit-logs'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.auditLogs.all, 'list', params] as const,
  },
  alerts: {
    rules: () => ['alert-rules'] as const,
    events: (params?: Record<string, string>) => ['alert-events', params] as const,
  },
  runbooks: {
    all: ['runbooks'] as const,
    list: () => [...queryKeys.runbooks.all, 'list'] as const,
    detail: (id: string) => [...queryKeys.runbooks.all, 'detail', id] as const,
    executions: (id: string) => [...queryKeys.runbooks.all, 'executions', id] as const,
  },
  credentials: {
    all: ['credentials'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.credentials.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.credentials.all, 'detail', id] as const,
  },
  healthChecks: {
    all: ['health-checks'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.healthChecks.all, 'list', params] as const,
  },
  tasks: {
    all: ['tasks'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.tasks.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.tasks.all, 'detail', id] as const,
  },
  approvals: {
    all: ['approvals'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.approvals.all, 'list', params] as const,
  },
  contacts: {
    all: ['contacts'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.contacts.all, 'list', params] as const,
  },
  messages: {
    all: ['messages'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.messages.all, 'list', params] as const,
  },
  tenants: {
    all: ['tenants'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.tenants.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.tenants.all, 'detail', id] as const,
    invites: (id: string) => [...queryKeys.tenants.all, 'invites', id] as const,
  },
  channels: {
    all: ['channels'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.channels.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.channels.all, 'detail', id] as const,
  },
  escalationPolicies: {
    all: ['escalation-policies'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.escalationPolicies.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.escalationPolicies.all, 'detail', id] as const,
  },
  agentConfig: {
    all: ['agent-config'] as const,
    current: () => [...queryKeys.agentConfig.all, 'current'] as const,
  },
  tenantSdkConfig: {
    all: ['tenant-sdk-config'] as const,
    current: () => [...queryKeys.tenantSdkConfig.all, 'current'] as const,
  },
  skills: {
    all: ['skills'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.skills.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.skills.all, 'detail', id] as const,
  },
  hooks: {
    all: ['hooks'] as const,
    list: () => [...queryKeys.hooks.all, 'list'] as const,
    detail: (id: string) => [...queryKeys.hooks.all, 'detail', id] as const,
  },
  riskRules: {
    all: ['risk-rules'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.riskRules.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.riskRules.all, 'detail', id] as const,
  },
  permissions: {
    all: ['permissions'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.permissions.all, 'list', params] as const,
    matrix: () => [...queryKeys.permissions.all, 'matrix'] as const,
  },
  users: {
    all: ['users'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.users.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.users.all, 'detail', id] as const,
    activity: (id: string) => [...queryKeys.users.all, 'activity', id] as const,
  },
  roles: {
    all: ['roles'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.roles.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.roles.all, 'detail', id] as const,
    permissions: (id: string) => [...queryKeys.roles.all, 'permissions', id] as const,
  },
  metrics: {
    all: ['metrics'] as const,
    overview: () => [...queryKeys.metrics.all, 'overview'] as const,
    servers: (params?: Record<string, string>) => [...queryKeys.metrics.all, 'servers', params] as const,
  },
  sessions: {
    all: ['sessions'] as const,
    list: (params?: Record<string, string>) => [...queryKeys.sessions.all, 'list', params] as const,
    detail: (id: string) => [...queryKeys.sessions.all, 'detail', id] as const,
    events: (id: string) => ['session-events', id] as const,
  },
  settings: {
    all: ['settings'] as const,
    general: () => [...queryKeys.settings.all, 'general'] as const,
    notifications: () => [...queryKeys.settings.all, 'notifications'] as const,
    apiKeys: () => [...queryKeys.settings.all, 'api-keys'] as const,
    theme: () => [...queryKeys.settings.all, 'theme'] as const,
    account: () => [...queryKeys.settings.all, 'account'] as const,
    voice: () => [...queryKeys.settings.all, 'voice'] as const,
  },
};
