// Metro module 3827 (f3828). import Record from "../lib/Record"; import { MessageFlags, MessageStates, MessageTypes } from "../Constants"; import * as _Module1384 from "../_bundle/Module1384"; import { emojiEquals } from "../modules/reactions/ReactionUtils"; import isForwardMessage from "../modules/forwarding/isForwardMessage"; import { ReactionTypes } from "../modules/messages/MessageReactionsTypes"; import { ApplicationIntegrationType } from "../_bundle/Module8028"; class MinimalMessageRecord extends Record { constructor(a0) { super(); let type = a0.type; if (type == null) { type = MessageTypes.DEFAULT; } this.type = type; let content = a0.content; if (content == null) { content = ""; } this.content = content; let attachments = a0.attachments; if (attachments == null) { attachments = []; } this.attachments = attachments; let embeds = a0.embeds; if (embeds == null) { embeds = []; } this.embeds = embeds; let timestamp = a0.timestamp; if (timestamp == null) { timestamp = new Date(); } this.timestamp = timestamp; let editedTimestamp = a0.editedTimestamp; if (editedTimestamp == null) { editedTimestamp = null; } this.editedTimestamp = editedTimestamp; let flags = a0.flags; if (flags == null) { flags = 0; } this.flags = flags; let components = a0.components; if (components == null) { components = []; } this.components = components; let codedLinks = a0.codedLinks; if (codedLinks == null) { codedLinks = []; } this.codedLinks = codedLinks; let stickers = a0.stickers; if (stickers == null) { stickers = []; } this.stickers = stickers; let sticker_items = a0.sticker_items; if (sticker_items == null) { sticker_items = a0.stickerItems; } if (sticker_items == null) { sticker_items = []; } this.stickerItems = sticker_items; let soundboard_sounds = a0.soundboard_sounds; if (soundboard_sounds == null) { soundboard_sounds = a0.soundboardSounds; } this.soundboardSounds = soundboard_sounds; } hasFlag(a0) { return _Module1384.hasFlag(this.flags, a0); } } class MessageRecord extends MinimalMessageRecord { constructor(a0) { let mentionGames2; super(a0); this.id = a0.id; this.channel_id = a0.channel_id; this.author = a0.author; this.customRenderedContent = a0.customRenderedContent; this.mentions = a0.mentions || []; this.mentionRoles = a0.mentionRoles || []; this.mentionChannels = a0.mentionChannels || []; if (a0.mentionGames instanceof Map) { mentionGames2 = a0.mentionGames; } else { const r24 = Map; let mentionGames = a0.mentionGames; if (mentionGames == null) { mentionGames = []; } mentionGames2 = new r24(mentionGames.map((mentionGame) => [mentionGame.id, mentionGame])); } this.mentionGames = mentionGames2; this.mentioned = a0.mentioned || false; this.pinned = a0.pinned || false; this.mentionEveryone = a0.mentionEveryone || false; this.tts = a0.tts || false; this.giftCodes = a0.giftCodes || []; this.state = a0.state || MessageStates.SENT; let nonce = a0.nonce; if (nonce == null) { nonce = void 0; } this.nonce = nonce; this.blocked = a0.blocked || false; this.ignored = a0.ignored || false; this.call = a0.call || null; this.bot = a0.bot || false; this.webhookId = a0.webhookId || null; this.reactions = a0.reactions || []; this.applicationId = a0.application_id || a0.applicationId || null; this.application = a0.application || null; this.activity = a0.activity || null; this.activityInstance = a0.activity_instance || a0.activityInstance || null; this.messageReference = a0.messageReference || null; this.isSearchHit = a0.hit || a0.isSearchHit || false; this.loggingName = a0.loggingName || null; this.colorString = a0.colorString; this.nick = a0.nick; this.interaction = a0.interaction || null; this.interactionData = a0.interactionData || null; this.interactionMetadata = a0.interactionMetadata || null; this.interactionError = a0.interactionError || null; this.roleSubscriptionData = a0.roleSubscriptionData; this.purchaseNotification = a0.purchaseNotification; this.poll = a0.poll; this.sharedClientTheme = a0.shared_client_theme || a0.sharedClientTheme; this.referralTrialOfferId = a0.referralTrialOfferId || null; this.premiumGroupInviteId = a0.premiumGroupInviteId || null; let gift_info = a0.gift_info; if (gift_info == null) { gift_info = a0.giftInfo; } this.giftInfo = gift_info; this.giftingPrompt = a0.giftingPrompt || null; this.boostingPrompt = a0.boostingPrompt || null; this.messageSnapshots = a0.messageSnapshots || []; this.isUnsupported = a0.isUnsupported || false; let changelog_id = a0.changelog_id; if (changelog_id == null) { changelog_id = a0.changelogId || null; } this.changelogId = changelog_id; let media_mention = a0.media_mention; if (media_mention == null) { media_mention = a0.mediaMention; } if (media_mention == null) { media_mention = null; } this.mediaMention = media_mention; let additionalName = a0.lobby_member?.additional_name; if (additionalName == null) { additionalName = a0.additionalName; } if (additionalName == null) { additionalName = null; } this.additionalName = additionalName; } isEdited() { return this.editedTimestamp != null; } getChannelId() { return this.channel_id; } getReaction(c13641_0) { return this.reactions.find((reaction) => emojiEquals(reaction.emoji, c13641_0)); } getContentMessage() { return isForwardMessage(this) ? this.messageSnapshots[0].message : this; } userHasReactedWithEmoji(c13642_0, c13642_1) { return this.reactions.some((reaction) => { if (emojiEquals(reaction.emoji, c13642_0)) { return c13642_1 && reaction.me || (c13642_1 ? !c13642_1 : reaction.me_burst); } }); } addReaction(a0) { let me_burst = arguments[1]; if (me_burst === void 0) { me_burst = false; } let c13643_1 = me_burst; let burst_colors = arguments[2]; if (burst_colors === void 0) { burst_colors = []; } let c13643_2 = burst_colors; let r4 = arguments[3]; if (r4 === void 0) { r4 = ReactionTypes.NORMAL; } const NORMAL = r4; let c13643_4 = -1; const r18 = this.reactions.map((reaction, index) => { const r16 = emojiEquals(reaction.emoji, a0); let r17 = reaction; if (r16) { c13643_4 = index; if (NORMAL === ReactionTypes.BURST) { if (c13643_1 && reaction.me_burst) { return reaction; } const burst_count = reaction.burst_count + 1; r17 = { ...reaction, me_burst: !!c13643_1 || reaction.me_burst, burst_count, count_details: { ...reaction.count_details, burst: burst_count }, burst_colors: reaction.burst_colors != null && reaction.burst_colors.length > 0 ? reaction.burst_colors : c13643_2 }; } else if (NORMAL === ReactionTypes.VOTE) { let r41 = reaction.count_details?.vote; if (r41 == null) { r41 = 0; } r17 = { ...reaction, count_details: { ...reaction.count_details, vote: c13643_1 ? reaction.me_vote ? r41 : r41 + 1 : r41 + 1 }, me_vote: !!c13643_1 || reaction.me_vote }; } else { if (c13643_1 && reaction.me) { return reaction; } const count = reaction.count + 1; r17 = { ...reaction, count, count_details: { ...reaction.count_details, normal: count }, me: !!c13643_1 || reaction.me }; } } return r17; }); if (c13643_4 === -1) { if (NORMAL === ReactionTypes.BURST) { r18.push({ emoji: a0, me: false, me_burst, count: 0, count_details: { burst: 1, normal: 0 }, burst_count: 1, burst_colors }); } else if (NORMAL === ReactionTypes.VOTE) { r18.push({ emoji: a0, me: false, me_burst: false, me_vote: me_burst, count: 0, count_details: { burst: 0, normal: 0, vote: 1 }, burst_count: 0, burst_colors: [] }); } else { r18.push({ emoji: a0, me: me_burst, me_burst: false, count: 1, count_details: { burst: 0, normal: 1 }, burst_count: 0, burst_colors: [] }); } } return this.set("reactions", r18); } addReactionBatch(a0, c13644_0) { return a0.reduce((acc, { users, emoji, reactionType }) => users.reduce((acc, user) => acc.addReaction(emoji, user === c13644_0, [], reactionType), acc), this); } removeReaction(c13645_0, r12 = false) { let c13645_1 = r12; let r13 = arguments[2]; if (r13 === void 0) { r13 = ReactionTypes.NORMAL; } const NORMAL2 = r13; let c13645_3 = -1; const r21 = this.reactions.map((reaction, index) => { let r32; const r17 = emojiEquals(reaction.emoji, c13645_0); let r18 = reaction; if (r17) { if (NORMAL2 === ReactionTypes.BURST) { const burst_count = c13645_1 && !reaction.me_burst ? reaction.burst_count : reaction.burst_count - 1; r32 = { ...reaction, burst_count, me_burst: c13645_1 ? !c13645_1 : reaction.me_burst, count_details: { ...reaction.count_details, burst: burst_count } }; } else if (NORMAL2 === ReactionTypes.VOTE) { let r40 = reaction.count_details?.vote; if (r40 == null) { r40 = 0; } r32 = { ...reaction, count_details: { ...reaction.count_details, vote: c13645_1 ? reaction.me_vote ? r40 - 1 : r40 : r40 - 1 }, me_vote: c13645_1 ? !c13645_1 : reaction.me_vote }; } else { const count = c13645_1 && !reaction.me ? reaction.count : reaction.count - 1; r32 = { ...reaction, count, me: c13645_1 ? !c13645_1 : reaction.me, count_details: { ...reaction.count_details, normal: count } }; } c13645_3 = index; r18 = r32; } return r18; }); let r23 = r21[c13645_3]; if (r23 == null) { r23 = {}; } const { count, burst_count, count_details } = r23; let r1 = c13645_3 !== -1 && count <= 0 && burst_count <= 0; if (r1) { let r28 = count_details?.normal; if (r28 == null) { r28 = 0; } r1 = r28 <= 0; } if (r1) { let r31 = count_details?.burst; if (r31 == null) { r31 = 0; } r1 = r31 <= 0; } if (r1) { let r34 = count_details?.vote; if (r34 == null) { r34 = 0; } r1 = r34 <= 0; } if (r1) { r21.splice(c13645_3, 1); } return this.set("reactions", r21); } removeReactionsForEmoji(c13646_0) { return this.set("reactions", this.reactions.filter((reaction) => !emojiEquals(reaction.emoji, c13646_0))); } isSystemDM() { return this.author.isSystemUser(); } isCommandType() { return this.type === MessageTypes.CHAT_INPUT_COMMAND || this.type === MessageTypes.CONTEXT_MENU_COMMAND; } isPoll() { return this.poll != null; } isInteractionPlaceholder() { return this.interaction != null && this.author.isNonUserBot(); } canDeleteOwnMessage(a0) { if (this.author.id === a0) { return true; } let r9 = this.interactionMetadata?.authorizing_integration_owners; if (r9 == null) { r9 = {}; } const interactionMetadata = this.interactionMetadata; return (interactionMetadata == null ? void 0 : interactionMetadata.user.id) === a0 && Object.keys(r9).length === 1 && ApplicationIntegrationType.USER_INSTALL in r9; } toJS() { return { ...this, mentionGames: [...this.mentionGames.values()], webkhook_id: this.webhookId, edited_timestamp: this.editedTimestamp, mention_everyone: this.mentionEveryone }; } isFirstMessageInForumPost(a0) { return this.id === this.channel_id && a0.isForumPost(); } } export default MessageRecord; export { MinimalMessageRecord }; export class ModeratorReport { constructor(a0) { this.reporting_user_id = a0.reporting_user_id; this.reported_user_id = a0.reported_user_id; this.reporting_member = a0.reporting_member; this.reported_member = a0.reported_member; } } class MessageSnapshotRecord extends Record { constructor(a0) { super(); this.message = new MinimalMessageRecord(a0.message); let moderator_report = a0.moderator_report; if (moderator_report == null) { moderator_report = null; } this.moderatorReport = moderator_report; } } export { MessageSnapshotRecord }; export function isMessageComponentsV2(a0) { return _Module1384.hasFlag(a0.flags, MessageFlags.IS_COMPONENTS_V2); }