import {
  IconBook,
  IconCake,
  IconCalendar,
  IconCalendarDue,
  IconChartBar,
  IconClock,
  IconEditCircle,
  IconExternalLink,
  IconFileCertificate,
  IconFileCheck,
  IconFileDescription,
  IconFileDots,
  IconFolder,
  IconHeartHandshake,
  IconHome,
  IconMessage,
  IconNews,
  IconPhoneCall,
  IconReportMoney,
  IconRocket,
  IconRoute,
  IconSchool,
  IconShoppingBag,
  IconSitemap,
  IconStar,
  IconTargetArrow,
  IconUsers,
  IconUsersGroup,
  IconVideo,
} from '@material-hu/icons/tabler';

import { CommunityFeature } from 'src/types/communityFeatures';
import { UserPermissions } from 'src/utils/permissions';

export enum NotificationModuleCodes {
  ACKNOWLEDGEMENTS = 'ACKNOWLEDGEMENTS',
  ARTICLES = 'ARTICLES',
  BIRTHDAYS = 'BIRTHDAYS',
  CALL = 'CALL',
  COURSES = 'COURSES',
  DOCUMENTS = 'DOCUMENTS',
  DRAFTS = 'DRAFTS',
  EVENTS = 'EVENTS',
  FEED = 'FEED',
  GOALS = 'GOALS',
  GROUPS = 'GROUPS',
  KNOWLEDGE_LIBRARIES = 'KNOWLEDGE_LIBRARIES',
  LEARNING_PATHS = 'LEARNING_PATHS',
  LEARNING_SESSIONS = 'LEARNING_SESSIONS',
  LIVE_STREAM = 'LIVE_STREAM',
  MICROLOANS = 'MICROLOANS',
  PEOPLE_EXPERIENCE = 'PEOPLE_EXPERIENCE',
  PERFORMANCE_REVIEWS = 'PERFORMANCE_REVIEWS',
  TIME_OFF = 'TIME_OFF',
  TIME_TRACKING = 'TIME_TRACKING',
}

export enum NotificationChannelCodes {
  PUSH = 'PUSH',
  BELL = 'BELL',
  MAIL = 'MAIL',
}

export enum NotificationTypeCodes {
  NEW_GROUP_POST = 'NEW_GROUP_POST',
}

export const PermissionGuardedModules: Partial<
  Record<NotificationModuleCodes, UserPermissions[]>
> = {
  [NotificationModuleCodes.TIME_TRACKING]: [UserPermissions.VIEW_TIME_TRACKING],
};

export const CommunityFeatureGuardedModules: Partial<
  Record<NotificationModuleCodes, CommunityFeature[]>
> = {
  [NotificationModuleCodes.MICROLOANS]: [CommunityFeature.VIEW_MICROLOANS],
};

type ModuleIconDictionary = {
  [key: string]: React.ComponentType;
};

export const BASE_URL = 'humand.co';

export const AVATAR_COLORS = [
  'default',
  'primary',
  'highlight',
  'success',
  'error',
  'warning',
  'info',
] as const;

export type AvatarColor = (typeof AVATAR_COLORS)[number];

export const NOTIFICATION_PANEL_WIDTH = 424;

export const NOTIFICATIONS_PAGE_SIZE = 10;

/** Pixels from the bottom of the scroll container to trigger loading the next page. */
export const SCROLL_LOAD_MORE_THRESHOLD_PX = 80;

export const SKELETON_KEYS = Array.from(
  { length: 10 },
  (_, index) => `notifications-skeleton-${index + 1}`,
);

export const moduleIcons: ModuleIconDictionary = {
  FEED: IconHome,
  GROUPS: IconUsersGroup,
  NEWS: IconNews,
  CHATS: IconMessage,
  TICKETS: IconSitemap,
  ACKNOWLEDGEMENTS: IconStar,
  FORMS: IconFileDescription,
  TIME_TRACKING: IconClock,
  TIME_OFF: IconCalendar,
  PERFORMANCE_REVIEWS: IconRocket,
  GOALS: IconTargetArrow,
  USERS: IconUsers,
  FILES: IconFolder,
  COURSES: IconSchool,
  TRAINING: IconFileCertificate,
  ONBOARDING: IconFileCheck,
  SURVEYS: IconChartBar,
  DOCUMENTS: IconFileDots,
  MARKETPLACE: IconShoppingBag,
  KNOWLEDGE_LIBRARIES: IconBook,
  WIDGETS: IconExternalLink,
  EVENTS: IconCalendar,
  LIVE_STREAM: IconVideo,
  CALL: IconPhoneCall,
  PEOPLE_EXPERIENCE: IconHeartHandshake,
  LEARNING_PATHS: IconRoute,
  LEARNING_SESSIONS: IconCalendarDue,
  BIRTHDAYS: IconCake,
  ARTICLES: IconNews,
  DRAFTS: IconEditCircle,
  MICROLOANS: IconReportMoney,
};

export const notificationsModulesSet = new Set([
  'ARTICLES',
  'ACKNOWLEDGEMENTS',
  'BIRTHDAYS',
  'CALL',
  'CHATS',
  'COURSES',
  'DRAFTS',
  'DOCUMENTS',
  'EVENTS',
  'FEED',
  'FILES',
  'FORMS',
  'GOALS',
  'GROUPS',
  'KNOWLEDGE_LIBRARIES',
  'LEARNING_PATHS',
  'LEARNING_SESSIONS',
  'LIVE_STREAM',
  'MARKETPLACE',
  'NEWS',
  'ONBOARDING',
  'PEOPLE_EXPERIENCE',
  'PERFORMANCE_REVIEWS',
  'SURVEYS',
  'TICKETS',
  'TIME_OFF',
  'TIME_TRACKING',
  'TRAINING',
  'USERS',
  'WIDGETS',
  'MICROLOANS',
]);
