const STORE_SLICE_DOMAINS: Record<string, string> = {
  messages: 'chat',
  users: 'users',
  rooms: 'rooms'
};
const COMPONENT_PREFIX_DOMAINS: [string, string][] = [
  ['Voice', 'voice-connection'],
  ['ScreenShare', 'screen-share'],
  ['Dm', 'direct-message'],
  ['DirectCall', 'direct-call'],
  ['DirectMessage', 'direct-message'],
  ['Plugin', 'plugins'],
  ['Chat', 'chat'],
  ['Message', 'chat'],
  ['Server', 'server-directory'],
  ['Room', 'rooms'],
  ['Theme', 'theme'],
  ['Emoji', 'custom-emoji'],
  ['Notification', 'notifications'],
  ['Game', 'game-activity'],
  ['Profile', 'profile-avatar'],
  ['Attachment', 'attachment'],
  ['Auth', 'authentication'],
  ['Login', 'authentication'],
  ['Register', 'authentication']
];

export function mapStoreSliceToDomain(sliceKey: string): string {
  return STORE_SLICE_DOMAINS[sliceKey] ?? sliceKey;
}

export function mapComponentNameToDomain(componentName: string): string {
  if (!componentName || componentName === 'App') {
    return 'core';
  }

  for (const [prefix, domain] of COMPONENT_PREFIX_DOMAINS) {
    if (componentName.startsWith(prefix)) {
      return domain;
    }
  }

  if (componentName.endsWith('Component')) {
    return 'features';
  }

  return 'core';
}
