"use strict";

/**
 * Centralized query keys for TanStack Query
 * 
 * Following best practices:
 * - Use arrays for hierarchical keys
 * - Include all parameters in the key
 * - Use consistent naming conventions
 */

export const queryKeys = {
  // Account queries
  accounts: {
    all: ['accounts'],
    lists: () => [...queryKeys.accounts.all, 'list'],
    list: sessionIds => [...queryKeys.accounts.lists(), sessionIds],
    details: () => [...queryKeys.accounts.all, 'detail'],
    detail: sessionId => [...queryKeys.accounts.details(), sessionId],
    current: () => [...queryKeys.accounts.all, 'current'],
    settings: () => [...queryKeys.accounts.all, 'settings']
  },
  // User queries
  users: {
    all: ['users'],
    lists: () => [...queryKeys.users.all, 'list'],
    list: userIds => [...queryKeys.users.lists(), userIds],
    details: () => [...queryKeys.users.all, 'detail'],
    detail: userId => [...queryKeys.users.details(), userId],
    profile: sessionId => [...queryKeys.users.details(), sessionId, 'profile']
  },
  // Session queries
  sessions: {
    all: ['sessions'],
    lists: () => [...queryKeys.sessions.all, 'list'],
    list: userId => [...queryKeys.sessions.lists(), userId],
    details: () => [...queryKeys.sessions.all, 'detail'],
    detail: sessionId => [...queryKeys.sessions.details(), sessionId],
    active: () => [...queryKeys.sessions.all, 'active'],
    device: deviceId => [...queryKeys.sessions.all, 'device', deviceId]
  },
  // Device queries
  devices: {
    all: ['devices'],
    lists: () => [...queryKeys.devices.all, 'list'],
    list: userId => [...queryKeys.devices.lists(), userId],
    details: () => [...queryKeys.devices.all, 'detail'],
    detail: deviceId => [...queryKeys.devices.details(), deviceId]
  },
  // Privacy settings queries
  privacy: {
    all: ['privacy'],
    settings: userId => [...queryKeys.privacy.all, 'settings', userId || 'current']
  },
  // Security activity queries
  security: {
    all: ['security'],
    activity: (limit, offset, eventType) => [...queryKeys.security.all, 'activity', limit, offset, eventType],
    recent: limit => [...queryKeys.security.all, 'recent', limit]
  }
};

/**
 * Helper to invalidate all account-related queries
 */
export const invalidateAccountQueries = queryClient => {
  queryClient.invalidateQueries({
    queryKey: queryKeys.accounts.all
  });
};

/**
 * Helper to invalidate all user-related queries
 */
export const invalidateUserQueries = queryClient => {
  queryClient.invalidateQueries({
    queryKey: queryKeys.users.all
  });
};

/**
 * Helper to invalidate all session-related queries
 */
export const invalidateSessionQueries = queryClient => {
  queryClient.invalidateQueries({
    queryKey: queryKeys.sessions.all
  });
};
//# sourceMappingURL=queryKeys.js.map