import {ThemeMode} from '@caj/configs/appVar';
import {
  AccountName,
  EMail,
  langCode,
  XAuthorization,
  timestamp,
  UserId,
  Username,
  WebSocketSessionId,
} from '@caj/configs/types';

export enum SourceProp {
  online = -1,
  offline = 0,
  cached = 1,
}

export interface BasicUserProp<T1> {
  source: SourceProp;
  url?: string;
  data?: T1;
}

export type ProfilePictureType = BasicUserProp<Blob | undefined>;

export interface ProfilePicture {
  lq: ProfilePictureType;
  hq?: ProfilePictureType;
}

export interface User {
  UserId: UserId;

  ProfilePicture: ProfilePicture;
  lastUpdateTimestamp: timestamp;
  AccountName: BasicUserProp<AccountName>;
  Username: BasicUserProp<Username>;
  Description: BasicUserProp<string>;
  FollowersCount: BasicUserProp<number>;
  FollowingCount: BasicUserProp<number>;
  XpLevel: BasicUserProp<number>;
  XpPoints: BasicUserProp<number>;
}

export interface MyUserAccount extends User {
  EMail: EMail;
  SessionId: XAuthorization;
  WebSocketSessionId: WebSocketSessionId;
  userSettings: userSettings;
}

export interface userSettings {
  theme: ThemeMode;
  lang: langCode;
}

export function createUserProp<T1>(
  source: SourceProp,
  data?: T1,
  url?: string,
): BasicUserProp<T1> {
  return {source, data, url};
}
