/* Metro module 4625; source: modules/messages/MessageRecordUtils.tsx; dependencies: [4626, 3794, 1885, 1226, 3793, 1878, 4503, 661, 4627, 4096, 4634, 21, 4639, 4129, 4640, 3738, 4641, 4643, 2] */ import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */ import UserStore from '../../stores/UserStore.tsx'; /* Metro dependency 1878 */ import RelationshipStore from '../../stores/RelationshipStore.tsx'; /* Metro dependency 3793 */ import MessageRecord from '../../records/MessageRecord.tsx'; /* Metro dependency 3794 */ import InteractionRecord from '../../records/InteractionRecord.tsx'; /* Metro dependency 4626 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */ import * as MessageRecordModule from '../../records/MessageRecord.tsx'; /* Metro dependency 3794 */ import * as GiftCodeUtilsModule from '../../utils/GiftCodeUtils.tsx'; /* Metro dependency 4129 */ import * as MessageConstantsModule from './MessageConstants.tsx'; /* Metro dependency 4503 */ import * as InteractionComponentUtilsModule from '../interaction_components/InteractionComponentUtils.tsx'; /* Metro dependency 4627 */ import * as UseMessageAuthorModule from './useMessageAuthor.tsx'; /* Metro dependency 4634 */ import * as IsMessageMentionedModule from './isMessageMentioned.tsx'; /* Metro dependency 4639 */ import * as EmbedUtilsModule from '../../utils/EmbedUtils.tsx'; /* Metro dependency 4641 */ import * as StickersUtilsModule from '../stickers/StickersUtils.tsx'; /* Metro dependency 4643 */ function _fun39774(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#39774, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:6, offset: 0x010e9f9e, size: 429 bytes, params: 8, frame: 20 let env0_0 = require; const createMessageRecord2 = createMessageRecord; const transformAttachments = function(a0) { return a0.attachments == null ? [] : a0.attachments.map(_fun39779); }; const transformEmbeds = function(a0) { var env0_0 = a0; if (a0.embeds == null) { return []; } return require(dependencyMap[16]).mergeEmbedsOnURL(a0.embeds.map(_fun39782)); }; const transformMessageSnapshots = function(a0) { return a0.message_snapshots == null ? [] : a0.message_snapshots.map(_fun39787); }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); let value = MessageRecordModule; const env0_4 = value.MessageSnapshotRecord; const env0_5 = value.MinimalMessageRecord; value = importDefault(1885) /* metro dependency 1885: UserRecord */; value = new value({'id': '???', 'username': '???'}); (FileImportTrackerModule).fileFinishedImporting('modules/messages/MessageRecordUtils.tsx'); exports.createMessageRecord = createMessageRecord2; exports.updateServerMessage = function(a0, a1) { var r4; var r0; var object; if (a1.edited_timestamp != null) { object = {}; copyDataProperties(object, a1, r4); object['reactions'] = a0.reactions; object['interaction_data'] = a0.interaction_data; r0 = object; } else { object = {}; copyDataProperties(object, a0, r4); copyDataProperties(object, a1, r4); r0 = object; } return r0; }; exports.updateMessageRecord = updateMessageRecord; exports.canEditMessageWithStickers = canEditMessageWithStickers; exports.hasEphemeralAppearance = hasEphemeralAppearance; function createMinimalMessageRecord(a0) { // fn#39775, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:357, offset: 0x010ea14b, size: 313 bytes, params: 2, frame: 18 var r5; var r3; var value; const object = {}; copyDataProperties(object, a0, undefined); const Date = global.Date; const timestamp = a0.timestamp; const value2 = Object.create(Date.prototype, {constructor: {value: Date}}); let date = new Date(timestamp); object['timestamp'] = date instanceof Object ? date : value2; const edited_timestamp = a0.edited_timestamp; const value4 = null; if (value4 != edited_timestamp) { date = new global.Date(a0.edited_timestamp); } else { r5 = value4; } object['editedTimestamp'] = r5; object['attachments'] = transformAttachments(a0); object['embeds'] = transformEmbeds(a0); const transformComponents = InteractionComponentUtilsModule.transformComponents; const components = a0.components; object['components'] = Reflect.apply(transformComponents, InteractionComponentUtilsModule, [value4 != components ? components : []]); const NON_PARSED = MessageTypesSets.NON_PARSED; if (NON_PARSED.has(a0.type)) { r3 = []; } else { value = importDefault(4096) /* metro dependency 4096: findCodedLinks */; value = value(a0.content); r3 = value; } object['codedLinks'] = r3; value = Object.create(MinimalMessageRecord.prototype, {constructor: {value: MinimalMessageRecord}}); const minimalMessageRecord = new MinimalMessageRecord(object); return minimalMessageRecord instanceof Object ? minimalMessageRecord : value; } function createMessageRecord(a0) { // fn#39776, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:719, offset: 0x010ea284, size: 1327 bytes, params: 2, frame: 34 var r21; var r14; var r13; var r8; var userStoreBinding; var value5; var userRecord2; var userRecord3; var defaultImport; var isProbablyAValidSnowflake; var value11; var defaultImport2; var value12; let value = a1; const value2 = undefined; const r0 = value !== value2 ? value : {}; let reactions = r0.reactions; const interactionData = r0.interactionData; const minimalMessageRecord = createMinimalMessageRecord(a0); const mentions = a0.mentions; const value3 = null; let r19 = value3 == mentions ? value2 : mentions.map(function(a0) { return a0.id; }); r19 = value3 == r19 ? [] : r19; const mention_roles = a0.mention_roles; const r18 = value3 != mention_roles ? mention_roles : []; const mention_channels = a0.mention_channels; const r20 = value3 != mention_channels ? mention_channels : []; const mention_games = a0.mention_games; const r17 = value3 != mention_games ? mention_games : []; const message_reference = a0.message_reference; if (value3 == a0.author) { r21 = env0_15; } else if (value3 != a0.webhook_id) { userRecord3 = new userRecord(a0.author); } else { userStoreBinding = UserStore; value5 = userStoreBinding.getUser(a0.author.id); if (value3 != value5) { r21 = value5; } else { userRecord2 = new userRecord(a0.author); } } const messageAuthor = (UseMessageAuthorModule).getMessageAuthor({channel_id: a0.channel_id, author: r21}); const gift_info = value3 == a0 ? value2 : a0.gift_info; const gifting_prompt = a0.gifting_prompt; const r10 = value3 != a0.interaction ? InteractionRecord.createFromServer(a0.interaction) : value3; let type = a0.type; const THREAD_STARTER_MESSAGE = MessageTypes.THREAD_STARTER_MESSAGE; const r24 = type !== THREAD_STARTER_MESSAGE || value3 == a0.referenced_message || value3 == a0.referenced_message.author ? value2 : a0.referenced_message.author.id; let content = a0.content; type = a0.type; const PREMIUM_REFERRAL = MessageTypes.PREMIUM_REFERRAL; if (type !== PREMIUM_REFERRAL) { r14 = value2; } else { defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */; isProbablyAValidSnowflake = defaultImport.isProbablyAValidSnowflake; content = a0.content; content = Reflect.apply(isProbablyAValidSnowflake, defaultImport, [content]) ? a0.content : value2; value11 = ''; r14 = content; content = value11; } type = a0.type; const PREMIUM_GROUP_INVITE = MessageTypes.PREMIUM_GROUP_INVITE; if (type !== PREMIUM_GROUP_INVITE) { r13 = value2; } else { defaultImport2 = importDefault(21) /* metro dependency 21: SnowflakeUtils */; isProbablyAValidSnowflake = defaultImport2.isProbablyAValidSnowflake; content = a0.content; content = Reflect.apply(isProbablyAValidSnowflake, defaultImport2, [content]) ? a0.content : value2; value12 = ''; r13 = content; content = value12; } const messageRecordBinding = MessageRecord; const object = {}; copyDataProperties(object, a0, r24); copyDataProperties(object, messageAuthor, r24); copyDataProperties(object, minimalMessageRecord.toJS(), r24); object['author'] = r21; object['webhookId'] = a0.webhook_id; object['blocked'] = RelationshipStore.isBlockedForMessage(a0) || value3 != r24 && RelationshipStore.isBlocked(r24); object['ignored'] = RelationshipStore.isIgnoredForMessage(a0) || value3 != r24 && RelationshipStore.isIgnored(r24); let mention_everyone = a0.mention_everyone; object['mentionEveryone'] = mention_everyone; object['mentions'] = r19; object['mentionRoles'] = r18; object['mentionChannels'] = r20; object['mentionGames'] = r17; object['messageReference'] = message_reference; const isMentioned = IsMessageMentionedModule.isMentioned; const object2 = {}; object2.userId = AuthenticationStore.getId(); object2.channelId = a0.channel_id; mention_everyone = a0.mention_everyone; object2.mentionEveryone = value3 != mention_everyone && mention_everyone; object2.mentionUsers = r19; object2.mentionRoles = r18; object['mentioned'] = Reflect.apply(isMentioned, IsMessageMentionedModule, [object2]); const isGiftCodeEmbed2 = (GiftCodeUtilsModule).isGiftCodeEmbed(a0); const findGiftCodes = GiftCodeUtilsModule.findGiftCodes; object['giftCodes'] = isGiftCodeEmbed2 ? Reflect.apply(findGiftCodes, GiftCodeUtilsModule, [value3 == a0 ? value2 : a0.embeds[0].url]) : Reflect.apply(findGiftCodes, GiftCodeUtilsModule, [a0.content]); object['content'] = content; object['referralTrialOfferId'] = r14; object['premiumGroupInviteId'] = r13; object['call'] = transformMessageCall(a0.call, minimalMessageRecord.timestamp); object['messageSnapshots'] = transformMessageSnapshots(a0); const transformReactionsBinding = transformReactions; reactions = value3 == reactions ? a0.reactions : reactions; object['reactions'] = transformReactionsBinding(reactions, a0.poll); object['interaction'] = r10; object['interactionData'] = value3 != interactionData ? interactionData : a0.interaction_data; object['interactionMetadata'] = a0.interaction_metadata; object['roleSubscriptionData'] = a0.role_subscription_data; object['purchaseNotification'] = a0.purchase_notification; if (value3 == a0.poll) { r8 = value2; } else { value = importDefault(4640) /* metro dependency 4640: transformMessagPoll */; value = value(a0.poll); r8 = value; } object['poll'] = r8; object['sharedClientTheme'] = a0.shared_client_theme; object['giftInfo'] = value3 == gift_info ? value2 : gift_info; object['giftingPrompt'] = gifting_prompt; object['boostingPrompt'] = a0.boosting_prompt; value = Object.create(messageRecordBinding.prototype, {constructor: {value: messageRecordBinding}}); const messageRecord2 = new messageRecordBinding(); return messageRecord2 instanceof Object ? messageRecord2 : value; } function transformAttachments(a0) { // fn#39778, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:2833, offset: 0x010ea7b3, size: 46 bytes, params: 2, frame: 11 return a0.attachments == null ? [] : a0.attachments.map(_fun39779); function _fun39779(a0) { // fn#39779, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:2915, offset: 0x010ea7e1, size: 50 bytes, params: 2, frame: 13 const object = {}; copyDataProperties(object, a0, undefined); const filename = a0.filename; const startsWith = filename.startsWith; const value = environment.__proto__; object['spoiler'] = Reflect.apply(startsWith, filename, [SPOILER_ATTACHMENT_PREFIX]); return object; } } function transformMessageCall(a0, a1) { // fn#39780, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:2962, offset: 0x010ea813, size: 174 bytes, params: 3, frame: 16 var r2; var r1; var ended_timestamp; var defaultImport; var Date; var value3; var date; let value = null; if (value != a0) { ended_timestamp = a0.ended_timestamp; if (value != ended_timestamp) { defaultImport = importDefault(3738) /* metro dependency 3738 */; Date = global.Date; ended_timestamp = a0.ended_timestamp; value3 = Object.create(Date.prototype, {constructor: {value: Date}}); date = new Date(); r2 = defaultImport(date instanceof Object ? date : value3); } else { r2 = value; } if (value != r2) { value = importDefault(3738) /* metro dependency 3738 */; value = value.duration(r2.diff(a1)); r1 = value; } else { r1 = value; } return {participants: a0.participants, endedTimestamp: r2, duration: r1}; } return value; } function transformEmbeds(a0) { // fn#39781, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:3202, offset: 0x010ea8c1, size: 86 bytes, params: 2, frame: 12 const env0_0 = a0; if (a0.embeds == null) { return []; } return (EmbedUtilsModule).mergeEmbedsOnURL(a0.embeds.map(_fun39782)); function _fun39782(a0) { // fn#39782, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:3277, offset: 0x010ea917, size: 60 bytes, params: 2, frame: 15 let value = environment.__proto__; value = require(4641) /* metro dependency 4641: EmbedUtils */; const sanitizeEmbed = value.sanitizeEmbed; const binding = env0_0; return Reflect.apply(sanitizeEmbed, value, [binding.channel_id, binding.id, a0]); } } function transformReactions(a0, a1) { // fn#39783, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:3364, offset: 0x010ea953, size: 148 bytes, params: 3, frame: 17 var r6; var results; var r3; var r5; var value3; var answer_counts; var items2; let value = a0; if (value != null) { value3 = undefined; if (a1 == null) { r3 = value3; } else { results = a1.results; if (results == null) { r3 = value3; } else { answer_counts = results.answer_counts; r3 = answer_counts.map(function(a0) { var object = {}; object.count_details = {vote: a0.count}; object.me_vote = a0.me_voted; var object3 = {'id': null, 'name': '', 'animated': false}; object3.id = a0.id.toString(); object.emoji = object3; object.me = false; object.me_burst = false; object.count = a0.count; object.burst_count = 0; return object; }); r6 = answer_counts; } } r5 = value ?? []; items2 = []; value = arraySpread(items2, r5, 0, r6); r3 = r3 ?? []; arraySpread(items2, r3, value, r6); return items2.map(_fun39785); } if (a1?.results == null) { return []; } value3 = undefined; if (a1 == null) { r3 = value3; } else { results = a1.results; if (results == null) { r3 = value3; } else { answer_counts = results.answer_counts; r3 = answer_counts.map(function(a0) { var object = {}; object.count_details = {vote: a0.count}; object.me_vote = a0.me_voted; var object3 = {'id': null, 'name': '', 'animated': false}; object3.id = a0.id.toString(); object.emoji = object3; object.me = false; object.me_burst = false; object.count = a0.count; object.burst_count = 0; return object; }); r6 = answer_counts; } } r5 = value ?? []; items2 = []; value = arraySpread(items2, r5, 0, r6); r3 = r3 ?? []; arraySpread(items2, r3, value, r6); return items2.map(function(a0) { var r5; var property; var object = {}; copyDataProperties(object, a0, r5); var value = undefined; if ((object == null ? value : object.count_details) != null) { property = object.count_details.burst; value = 0; object.burst_count = property ?? value; property = object.count_details.normal; object.count = property ?? value; } if (object.count < 0) { object.count = 0; } if (object.burst_count < 0) { object.burst_count = 0; } return object; }); } function transformMessageSnapshots(a0) { // fn#39786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:3943, offset: 0x010eaacf, size: 46 bytes, params: 2, frame: 11 return a0.message_snapshots == null ? [] : a0.message_snapshots.map(_fun39787); function _fun39787({message, moderator_report}) { // fn#39787, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:4042, offset: 0x010eaafd, size: 68 bytes, params: 2, frame: 14 let value = environment.__proto__; const object = {}; object.message = createMinimalMessageRecord(message); object.moderator_report = moderator_report; value = Object.create(MessageSnapshotRecord.prototype, {constructor: {value: MessageSnapshotRecord}}); const messageSnapshotRecord = new MessageSnapshotRecord(object); return messageSnapshotRecord instanceof Object ? messageSnapshotRecord : value; } } function updateMessageRecord(a0, a1) { // fn#39789, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:4449, offset: 0x010eab9a, size: 960 bytes, params: 3, frame: 19 var r1; var r2; var r8; var set; var author; var userRecordBinding; var value23; var userRecord2; var moduleValue; var transformReactionsBinding; var defaultImport; var object; let value = a0; if (a1.edited_timestamp != null) { return createMessageRecord(a1, {reactions: value.reactions, interactionData: value.interactionData}); } let r6 = a1.call == null ? value : value.set('call', transformMessageCall(a1.call, value.timestamp)); let r7 = a1.attachments == null ? r6 : r6.set('attachments', transformAttachments(a1)); r6 = a1.application == null ? r7 : r7.set('application', a1.application); r7 = a1.activity == null ? r6 : r6.set('activity', a1.activity); r6 = a1.content != null && a1.content !== '' ? r7.set('content', a1.content) : r7; r7 = a1.embeds == null ? r6 : r6.set('embeds', transformEmbeds(a1)); r6 = a1.message_snapshots == null ? r7 : r7.set('messageSnapshots', transformMessageSnapshots(a1)); r7 = a1.pinned === r6.pinned ? r6 : r6.set('pinned', a1.pinned); if (r7.webhookId != null && a1.author != null) { set = r7.set; userRecordBinding = userRecord; author = a1.author; value23 = Object.create(userRecordBinding.prototype, {constructor: {value: userRecordBinding}}); userRecord2 = new userRecordBinding(); r6 = Reflect.apply(set, r7, ['author', userRecord2 instanceof Object ? userRecord2 : value23]); } else { r6 = r7; } r7 = a1.flags != null && a1.flags !== r6.flags ? r6.set('flags', a1.flags) : r6; if (a1.components == null) { r6 = r7; } else { set = r7.set; moduleValue = require(4627) /* metro dependency 4627: InteractionComponentUtils */; r6 = Reflect.apply(set, r7, ['components', moduleValue.transformComponents(a1.components)]); } r7 = a1.role_subscription_data == null ? r6 : r6.set('roleSubscriptionData', a1.role_subscription_data); let reactions = a1.reactions; if (reactions == null) { r6 = r7; } else { set = r7.set; transformReactionsBinding = transformReactions; reactions = value.reactions; reactions = reactions ?? a1.reactions; value = transformReactionsBinding(reactions); value = Reflect.apply(set, r7, ['reactions', value]); r6 = value; } if (a1.poll == null) { r7 = r6; } else { set = r6.set; value = importDefault(4640) /* metro dependency 4640: transformMessagPoll */; value = value(a1.poll); value = Reflect.apply(set, r6, ['poll', value]); r7 = value; } const mentions = a1.mentions; value = false; if (mentions != null) { set = r7.set; value = a1.mentions.map(function(a0) { return a0.id; }); value = Reflect.apply(set, r7, ['mentions', value]); r2 = true; r8 = value; } else { r2 = value; r8 = r7; } if (a1.mention_everyone == null) { r7 = r8; } else { value = r8.set('mentionEveryone', a1.mention_everyone); r2 = true; r7 = value; } if (a1.mention_roles == null) { r6 = r7; } else { value = r7.set('mentionRoles', a1.mention_roles); r2 = true; r6 = value; } if (r2) { set = r6.set; defaultImport = importDefault(4639) /* metro dependency 4639: isMessageMentioned */; object = {message: r6}; object.userId = AuthenticationStore.getId(); value = defaultImport(object); value = Reflect.apply(set, r6, ['mentioned', value]); r1 = value; } else { r1 = r6; } return r1; } function canEditMessageWithStickers(a0) { // fn#39791, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:5904, offset: 0x010eaf5a, size: 68 bytes, params: 2, frame: 12 var value; const getMessageStickers = (StickersUtilsModule).getMessageStickers; value = Reflect.apply(getMessageStickers, value, [a0]).length === 0; return value || a0.content !== ''; } function hasEphemeralAppearance(a0) { // fn#39792, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:5991, offset: 0x010eaf9e, size: 51 bytes, params: 2, frame: 12 const hasFlag = a0.hasFlag; const EPHEMERAL = MessageFlags.EPHEMERAL; return Reflect.apply(hasFlag, a0, [EPHEMERAL]) && a0.type !== MessageTypes.IN_GAME_MESSAGE_NUX; } } function _fun39785(a0) { // fn#39785, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4803:3715, offset: 0x010eaa4f, size: 128 bytes, params: 2, frame: 15 var burst; const object = {}; copyDataProperties(object, a0, undefined); let value = undefined; let count_details = object == null ? value : object.count_details; if (count_details != null) { count_details = object.count_details; burst = count_details.burst; value = 0; object.burst_count = burst ?? value; count_details = object.count_details; object.count = count_details.normal ?? value; } if (object.count < 0) { object.count = 0; } if (object.burst_count < 0) { object.burst_count = 0; } return object; } global.__d(_fun39774, 4625, [4626, 3794, 1885, 1226, 3793, 1878, 4503, 661, 4627, 4096, 4634, 21, 4639, 4129, 4640, 3738, 4641, 4643, 2]) /* metro module 4625, dependencies: [4626, 3794, 1885, 1226, 3793, 1878, 4503, 661, 4627, 4096, 4634, 21, 4639, 4129, 4640, 3738, 4641, 4643, 2] */;