{"version":3,"sources":["../src/types.ts"],"sourcesContent":["// import { DeepOmit } from \"deep-utility-types\"\r\nimport { Dispatch, SetStateAction } from \"react\"\r\nimport { TextInput } from \"react-native\"\r\nimport { Image } from \"react-native-svg\"\r\nimport { Message } from 'softchatjs-core'\r\n\r\nexport enum ClientActions {\r\n  INCOMING_MESSAGE = 'incomingMessage',\r\n  MESSAGES_READ = 'messagesRead',\r\n  USER_IS_TYPING = 'userIsTyping',\r\n  MESSAGE_ERROR = 'sendMessageError',\r\n  NEW_MESSAGE_REACTION = 'newMessageReaction',\r\n  ACK_HEALTH_CHECK = 'acknowledgeHealthCheck',\r\n  EDITED_MESSAGE = 'editedMessage'\r\n}\r\n\r\n// sent to the server\r\nexport enum ServerActions {\r\n  INITIALIZE = 'initialize',\r\n  SEND_MESSAGE = 'sendMessage',\r\n  SEND_MESSAGE_REPLY = 'sendMessageReply',\r\n  USER_TYPING = 'userTyping',\r\n  HEALTH_CHECK = 'healthCheck',\r\n  SEND_LOCATION = 'sendLocation',\r\n  READ_MESSAGES = 'readMessages',\r\n  DELETE_MESSAGE = 'deleteMessage',\r\n  EDIT_MESSAGE = 'editMessage',\r\n  SEND_MESSAGE_REACTION = 'sendMessageReaction',\r\n  CONNECTION_CLOSED = 'clearUserSession',\r\n}\r\n\r\ntype Timetamps = {\r\n  createdAt: string | Date\r\n  updatedAt: string | Date\r\n  deletedAt?: string | Date\r\n}\r\n\r\nexport type Prettify<T> = {\r\n  [K in keyof T]: T[K]\r\n} & {}\r\n\r\nexport enum AttachmentTypes {\r\n  NONE = 'none',\r\n  MAP = 'map',\r\n  MEDIA = 'media',\r\n  STICKER = 'sticker'\r\n}\r\n\r\nexport interface Participant extends User {\r\n  meta: UserMeta\r\n}\r\n\r\n// type User = UserMeta & Timetamps & {\r\n//   color?: string,\r\n//   expoPushToken?: string,\r\n//   id?: string,\r\n//   username?: string\r\n// }\r\ntype User = {\r\n  uid: string,\r\n  connectionId?: string,\r\n  projectId?: string,\r\n  meta: UserMeta\r\n} & Timetamps\r\n\r\nexport type UserMeta = {\r\n  username: string,\r\n  uid: string,\r\n  firstname?: string,\r\n  lastname?: string,\r\n  profileUrl?: string,\r\n  color?: string,\r\n  custom?: Record<string, string>,\r\n}\r\n\r\nexport enum MediaType {\r\n  VIDEO = 'video',\r\n  AUDIO = 'audio',\r\n  IMAGE = 'image',\r\n  DOCUMENT = 'document',\r\n  STICKER = 'sticker'\r\n}\r\n\r\nexport type Media = {\r\n  type: MediaType,\r\n  ext: string,\r\n  mediaId: string,\r\n  mediaUrl: string,\r\n  mimeType?: string,\r\n  meta?: {\r\n    aspectRatio?: number,\r\n    height?: number,\r\n    width?: number,\r\n    size?: number,\r\n    audioDurationSec?: number,\r\n  }\r\n}\r\n\r\nexport type Point = {\r\n  lng: number,\r\n  lat: number\r\n}\r\n\r\ntype QuotedMessage = Message | null\r\n\r\ntype ImageUploadState = {\r\n  isUploading: true,\r\n  base64: string\r\n}\r\n\r\n// export type Message = {\r\n//   conversationId: string,\r\n//   from: string,\r\n//   to: string,\r\n//   message: string,\r\n//   messageState: number,\r\n//   messageId: string,\r\n//   attachmentType?: AttachmentTypes,\r\n//   messageOwner: UserMeta,\r\n//   replyTo?: string,\r\n//   sharedLocation?: Point,\r\n//   sharedImage?: {\r\n//     url: string,\r\n//     aspectRatio?: number,\r\n//   },\r\n//   attachedMedia: Media[]\r\n//   token?: string,\r\n//   quotedMessageId: string,\r\n//   quotedMessage: QuotedMessage | null,\r\n//   reactions: Reaction[],\r\n//   lastEdited: Date | string | null,\r\n//   isUploading?: boolean\r\n// }\r\n// & \r\n// Timetamps\r\n// // when an image is being uploaded, message comes with the meta below:\r\n// & ImageUploadState\r\n\r\nexport type ParticipantListInfo = {\r\n  id: string;\r\n  uid: string,\r\n  projectId: string | null;\r\n  connectionId: string;\r\n  participantId: string,\r\n  participantDetails: UserMeta\r\n} & Timetamps\r\n\r\nexport type ConversationType = 'private-chat' | 'group-chat'| \"admin-chat\"\r\n\r\nexport type GroupChatMeta = {\r\n  groupName: string,\r\n  groupIcon?: string,\r\n  groupWallpaper?: string,\r\n  groupBanner?: string\r\n}\r\n\r\nexport type PrivateChatMeta = {\r\n  chatWallpaper?: string,\r\n}\r\n\r\nexport type Conversation = {\r\n  participants: string[],\r\n  admins: string[],\r\n  conversationId: string,\r\n  messages: Message[],\r\n  conversationType: ConversationType,\r\n  participantList: ParticipantListInfo[],\r\n  meta: PrivateChatMeta | null,\r\n  groupMeta: GroupChatMeta | null\r\n} & Timetamps\r\n\r\nexport type UploadContent = {\r\n  base64: string,\r\n  conversationId: string,\r\n  key: string\r\n}\r\n//  & Omit<Media, 'mediaUrl'>\r\n\r\nexport type IncomingMessage = {\r\n  action: ClientActions.INCOMING_MESSAGE,\r\n  message: Message\r\n}\r\n\r\nexport type WsPayLoad<Action, Data> = {\r\n  action: Action,\r\n  message: Data\r\n}\r\n\r\nexport type ReceivedAction = ServerActions\r\n\r\nexport type ReadMessages = {\r\n  uid: string\r\n  messageIds: string[],\r\n}\r\n\r\nexport type UserTyping = {\r\n  uid: string\r\n}\r\n\r\nexport type SetState<T> = Dispatch<SetStateAction<T>>\r\n\r\nexport type InitiateConnection = {\r\n  from: string,\r\n  to: string,\r\n  newConversation: boolean,\r\n  userDetails: UserMeta,\r\n  recipientMeta: UserMeta,\r\n}\r\n\r\nexport type StringOrNumber = string | number\r\n\r\n\r\nexport type Config = {\r\n  projectId: string,\r\n  apiKey: string,\r\n}\r\n\r\nexport type StartConversation = {\r\n  from: string,\r\n  recipientMeta: UserMeta\r\n  message: string\r\n}\r\n\r\nexport type Reaction = {\r\n  emoji: string,\r\n  uid: string\r\n}\r\n\r\nexport enum MessageStates {\r\n  NONE = 0,\r\n  FAILED = 1,\r\n  LOADING = 2,\r\n  SENT = 3,\r\n  DELIVERED = 4,\r\n  READ = 5,\r\n}\r\n\r\nexport type Children = React.ReactNode;\r\n\r\n// external\r\n\r\nexport type ChatBubbleRenderProps = {\r\n  message: Omit<Message, 'conversationId' | 'token' | 'shouldEdit'>\r\n}\r\n\r\nexport type ChatInputRenderProps = {\r\n  sendMessage: (externalInputRef: React.RefObject<TextInput>) => void;\r\n  value: string,\r\n  onValueChange: (value: string) => void;\r\n  openMediaOptions: (externalInputRef: React.RefObject<TextInput>) => void;\r\n  openEmojis: () => void;\r\n  onStopEditing: () => void;\r\n  isEditing: boolean,\r\n  onStartRecording: () => void;\r\n  onDeleteRecording: () => void;\r\n  sendVoiceMessage: () => void;\r\n  // Metering progress where key is the timestamp, metering represents loudness and height is metering height in percentage\r\n  meteringProgress: {[key: number]: { metering: number; height: number }};\r\n  isRecording: boolean,\r\n  // Audio duration in seconds\r\n  audioDuration: number,\r\n  // Is true when connection state changes or loading new messages\r\n  isLoading: boolean\r\n}\r\n\r\nexport type ConversationHeaderRenderProps = {\r\n  isConnected: boolean,  \r\n  isConnecting: boolean\r\n}\r\n\r\nexport type ChatHeaderRenderProps = {\r\n  conversationTitle: string | null | undefined, \r\n  conversationType: string,\r\n  activeUser: UserMeta | undefined,\r\n  groupMeta: GroupChatMeta | null\r\n}\r\n\r\nexport type ConversationListRenderProps = {\r\n  title: string | undefined,\r\n  recipient: UserMeta | undefined,\r\n  lastMessage: Message | undefined | null;\r\n  imageUrl: string | null\r\n}\r\n\r\ntype DefaultColors = {\r\n  primary: string,\r\n  secondary: string\r\n}\r\n\r\nexport type ChatTheme = {\r\n  background: DefaultColors & { disabled: string },\r\n  text: DefaultColors & { disabled: string },\r\n  action: DefaultColors,\r\n  icon: string,\r\n  divider: string,\r\n  chatBubble: {\r\n    left: {\r\n      bgColor: string,\r\n      messageColor: string,\r\n      messageTimeColor: string,\r\n      replyBorderColor: string\r\n    },\r\n    right: {\r\n      bgColor: string,\r\n      messageColor: string,\r\n      messageTimeColor: string,\r\n      replyBorderColor: string\r\n    }\r\n  }\r\n}\r\n\r\nexport type Emoji = {\r\n  emoji: string,\r\n  description: string,\r\n  category: string,\r\n  aliases: string[],\r\n  tags: string[],\r\n  unicode_version: string,\r\n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