import type {
  Message,
  Room,
  User
} from '../../../../shared-kernel';

export interface NotificationsSettings {
  enabled: boolean;
  showPreview: boolean;
  respectBusyStatus: boolean;
  mutedRooms: Record<string, boolean>;
  mutedChannels: Record<string, Record<string, boolean>>;
  roomBaselines: Record<string, number>;
  lastReadByChannel: Record<string, Record<string, number>>;
}

export interface NotificationsUnreadState {
  roomCounts: Record<string, number>;
  channelCounts: Record<string, Record<string, number>>;
}

export interface NotificationDeliveryContext {
  activeChannelId: string | null;
  currentRoomId: string | null;
  currentUser: User | null;
  isDocumentVisible: boolean;
  isWindowFocused: boolean;
  rooms: Room[];
}

export interface NotificationDisplayPayload {
  body: string;
  requestAttention: boolean;
  title: string;
}

export interface RoomUnreadCounts {
  channelCounts: Record<string, number>;
  roomCount: number;
}

export function createDefaultNotificationSettings(): NotificationsSettings {
  return {
    enabled: true,
    showPreview: true,
    respectBusyStatus: true,
    mutedRooms: {},
    mutedChannels: {},
    roomBaselines: {},
    lastReadByChannel: {}
  };
}

export function createEmptyUnreadState(): NotificationsUnreadState {
  return {
    roomCounts: {},
    channelCounts: {}
  };
}

export type NotificationMessage = Pick<
  Message,
  'channelId' | 'content' | 'id' | 'isDeleted' | 'roomId' | 'senderId' | 'senderName' | 'timestamp'
>;
