Files
discord-decomp/sources/modules/markup/MarkupChannelMentionRule.tsx
T
2026-07-27 16:20:00 +03:00

329 lines
16 KiB
TypeScript

/* Metro module 6631; source: modules/markup/MarkupChannelMentionRule.tsx; dependencies: [1936, 1379, 1867, 3784, 3793, 1878, 661, 1861, 1423, 1244, 6632, 4800, 4805, 6633, 4246, 6629, 3855, 2] */
function _fun52498(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#52498, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:6, offset: 0x0132e236, size: 547 bytes, params: 8, frame: 21
var object5;
const env0_0 = require;
const makeLink = function(a0) {
return {type: 'link', content: [{type: 'text', content: a0}], target: a0, title: undefined};
};
const makeText = function(a0) {
return {type: 'text', content: a0};
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const gatedChannelStore = importDefault(1936) /* metro dependency 1936: GatedChannelStore */;
const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */;
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
const permissionStore = importDefault(3784) /* metro dependency 3784: PermissionStore */;
const relationshipStore = importDefault(3793) /* metro dependency 3793: RelationshipStore */;
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
const constantsModule = require(661) /* metro dependency 661: Constants */;
const env0_9 = constantsModule.ChannelTypes;
const env0_10 = constantsModule.ME;
object5 = {};
const object6 = {};
object6.order = (importDefault(6629) /* metro dependency 6629: MarkupTextRule */).order;
object6.requiredFirstCharacters = ['<'];
object6.match = function(a0) {
return RegExp('^<#(\\d+)>', '').exec(a0);
};
object6.parse = parse_52511;
object5.channelMention = object6;
const object7 = {};
object7.order = (importDefault(3855) /* metro dependency 3855 */).defaultRules.url.order - 0.5;
object7.requiredFirstCharacters = ['h'];
object7.match = match_52512;
object7.parse = parse_52513;
object5.channelOrMessageUrl = object7;
const object8 = {};
object8.order = (importDefault(3855) /* metro dependency 3855 */).defaultRules.url.order - 0.5;
object8.requiredFirstCharacters = ['h'];
object8.match = function(a0) {
var MEDIA_POST_URL_RE = require(dependencyMap[14]).MEDIA_POST_URL_RE;
return MEDIA_POST_URL_RE.exec(a0);
};
object8.parse = parse_52515;
object5.mediaPostLink = object8;
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/markup/MarkupChannelMentionRule.tsx');
exports.default = object5;
}
function makeGuild(a0) { // fn#52499, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:278, offset: 0x0132e459, size: 131 bytes, params: 2, frame: 18
const object2 = {type: 'guild'};
object2.guildId = a0.id;
const stringUtilsModule = require(1861) /* metro dependency 1861: StringUtils */;
object2.content = stringUtilsModule.truncateText(a0.name, 32);
object2.icon = (importDefault(1423) /* metro dependency 1423: AvatarUtils */).getGuildIconURL({id: a0.id,
icon: a0.icon, size: 40});
return object2;
}
function makeChannel({name, type, iconType}, a1) { // fn#52500, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:434, offset: 0x0132e4dc, size: 141 bytes, params: 3, frame: 16
const makeTextBinding = makeText;
let value = require(1861) /* metro dependency 1861: StringUtils */;
value = makeTextBinding(value.truncateText(name, 32));
return {type: 'channel', content: [a1 !== 'italics' ? value : {type: 'em', content: [value]}], channelType: type,
iconType: iconType};
}
function makeMessage(a0) { // fn#52501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:620, offset: 0x0132e569, size: 61 bytes, params: 2, frame: 12
const object2 = {type: 'channel'};
object2.content = [makeText('')];
object2.iconType = a0 ? 'post' : 'message';
return object2;
}
function getChannel(a0, a1) { // fn#52502, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:718, offset: 0x0132e5a6, size: 480 bytes, params: 3, frame: 25
var r0;
var r6;
var object2;
var type;
var isChannelTypeMentionable;
const env0_0 = a0;
var value;
const channel = ChannelStore.getChannel(a0);
const value3 = undefined;
const useChannelRoleSubscriptionStatusModule = require(6632) /* metro dependency 6632: useChannelRoleSubscriptionStatus */;
const getChannelRoleSubscriptionStatus = useChannelRoleSubscriptionStatusModule.getChannelRoleSubscriptionStatus;
const isSubscriptionGated = Reflect.apply(getChannelRoleSubscriptionStatus, useChannelRoleSubscriptionStatusModule,
[a0, ChannelStore, GatedChannelStore, PermissionStore]).isSubscriptionGated;
const mentionIconType = (require(4800) /* metro dependency 4800: ChannelUtils */).getMentionIconType(channel);
const value5 = null;
const r4 = value5 != mentionIconType ? mentionIconType : 'text';
if (value5 != a1) {
var value7 = a1.find(_fun52503);
if (value5 != value7) {
object2 = {};
object2.type = value7.type;
object2.id = value7.id;
object2.guildId = value7.guild_id;
object2.name = value7.name;
value = value5 != channel;
r6 = value && channel.isPrivate();
object2.isDm = r6;
value = value5 != channel;
r6 = value && channel.isForumPost();
object2.isForumPost = r6;
object2.isMentionable = true;
object2.canViewChannel = true;
object2.roleSubscriptionGated = isSubscriptionGated;
object2.iconType = r4;
object2.parentId = value5 == channel ? value3 : channel.parent_id;
return object2;
}
}
if (value5 != channel) {
object2 = {};
type = channel.type;
object2.type = type;
object2.id = channel.id;
object2.guildId = channel.guild_id;
object2.name = (require(4805) /* metro dependency 4805: useChannelName */).computeChannelName(channel,
UserStore,
RelationshipStore);
object2.isDm = channel.isPrivate();
object2.isForumPost = channel.isForumPost();
value = require(6633) /* metro dependency 6633: ChannelUtils */;
isChannelTypeMentionable = value.isChannelTypeMentionable;
type = channel.type;
object2.isMentionable = Reflect.apply(isChannelTypeMentionable, value, [type]);
value = require(4246) /* metro dependency 4246: LinkUtils */;
object2.canViewChannel = value.canViewChannel(channel);
object2.roleSubscriptionGated = isSubscriptionGated;
object2.iconType = r4;
object2.parentId = channel.parent_id;
r0 = object2;
} else {
r0 = value5;
}
return r0;
}
function handleUnknownChannel(a0, a1, a2, a3, a4) { // fn#52506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:1623, offset: 0x0132e7cd, size: 240 bytes, params: 6, frame: 19
const guild = GuildStore.getGuild(a0);
const value3 = null;
const id = value3 == guild ? undefined : guild.id;
const object3 = {type: 'channelMention', guildId: a0, channelId: a1, messageId: a2, originalLink: a4};
object3.inContent = value3 == guild || id === a3 ? value3 : [makeGuild(guild)];
const makeChannelBinding = makeChannel;
const object4 = {};
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
object4.name = intl.string((require(1244) /* metro dependency 1244: indexNative */).t.zLZPmk).toLowerCase();
const UNKNOWN = ChannelTypes.UNKNOWN;
object4.type = UNKNOWN;
object4.iconType = 'text';
object3.content = [makeChannelBinding(object4, 'italics')];
return object3;
}
function formatChannelMentionContent(a0, a1, a2, a3) { // fn#52507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:1955, offset: 0x0132e8bd, size: 388 bytes, params: 5, frame: 23
var value3;
var object;
var value;
const makeGuildBinding = makeGuild;
const value2 = undefined;
const guild = makeGuildBinding(a0);
const channel = makeChannel(a1);
const message = makeMessage(a1.isForumPost);
if (a2) {
if (a3) {
if (a1.isForumPost) {
value3 = ChannelStore.getChannel(a1.parentId);
if (value3 != null) {
makeChannelBinding = makeChannel;
object = {};
object.name = (require(4805) /* metro dependency 4805: useChannelName */).computeChannelName(value3,
UserStore,
RelationshipStore);
object.type = value3.type;
value = require(4800) /* metro dependency 4800: ChannelUtils */;
value = value.getMentionIconType(value3);
object.iconType = value ?? 'forum';
value = makeChannelBinding(object);
return {inContent: [value], content: [channel]};
}
return {inContent: [channel], content: [message]};
}
return {inContent: [channel], content: [message]};
}
}
return a2 ? a3 ? a2 ? a2 || a3 ? value2 : {inContent: [guild], content: [channel]} : a3 ? {inContent: [guild],
content: [a1.isForumPost ? channel : message]} : a2 || a3 ? value2 : {inContent: [guild],
content: [channel]} : {inContent: null, content: [channel]} : a2 ? a2 || a3 ? value2 : {inContent: [guild],
content: [channel]} : a3 ? {inContent: [guild],
content: [a1.isForumPost ? channel : message]} : a2 || a3 ? value2 : {inContent: [guild], content: [channel]};
}
function parseChannel(a0, a1, a2, a3) { // fn#52508, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:2462, offset: 0x0132ea41, size: 596 bytes, params: 5, frame: 23
var r0;
var object;
var value;
var makeTextBinding;
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
var guildId;
var getGuild;
var value3;
var object2;
var formatChannelMentionContentBinding;
var object5;
if (a0.canViewChannel) {
if (a0.isMentionable) {
object = {type: 'channelMention'};
object.channelId = a0.id;
guildId = a0.guildId;
object.guildId = guildId;
object.messageId = a1;
object.originalLink = a3;
getGuild = GuildStore.getGuild;
guildId = a0.guildId;
value3 = Reflect.apply(getGuild, GuildStore, [guildId]);
if (value3 == null) {
if (a0.isDm) {
object5 = {};
copyDataProperties(object5, object, undefined);
object5['guildId'] = ME;
object = [makeChannel(a0)];
object5['inContent'] = object;
object = [makeMessage(false)];
object5['content'] = object;
r0 = object5;
} else if (a3 != null) {
r0 = makeLink(a3);
} else {
makeTextBinding = makeText;
value = intl.string(t.J90oLW);
value = makeTextBinding('#' + value);
r0 = value;
}
return r0;
}
guildId = a0.guildId;
object2 = {};
copyDataProperties(object2, object, undefined);
formatChannelMentionContentBinding = formatChannelMentionContent;
value = guildId === a2;
copyDataProperties(object2, formatChannelMentionContentBinding(value3, a0, value, a1 != null), value);
return object2;
}
makeTextBinding = makeText;
value = '#' + a0.name;
return makeTextBinding(value);
}
object = {type: 'channel'};
object.content = [makeText(a0.roleSubscriptionGated ? a0.name : intl.string(t['/YzI63']))];
object.channelType = a0.roleSubscriptionGated ? a0.type : ChannelTypes.UNKNOWN;
object.iconType = 'locked';
return {type: 'channelMention', guildId: a0.guildId, channelId: a0.id, messageId: a1, inContent: null,
content: [object]};
}
function getGuildIdFromChannelId_52509(a0) { // fn#52509, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:214, offset: 0x0132ec95, size: 43 bytes, params: 2, frame: 11
var r0;
let value = ChannelStore.getChannel(a0);
if (value == null) {
r0 = undefined;
} else {
value = value.getGuildId();
r0 = value;
}
return r0;
}
function parse_52511([, property], a1, a2) { // fn#52511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:3390, offset: 0x0132ecde, size: 125 bytes, params: 4, frame: 20
if (a2.returnMentionIds) {
return {type: 'channelMention', id: property};
}
const channel = getChannel(property, a2.mentionChannels);
return channel == null ? handleUnknownChannel(null, property, null,
getGuildIdFromChannelId_52509(a2.channelId)) : parseChannel(channel, null,
getGuildIdFromChannelId_52509(a2.channelId));
}
function match_52512(a0) { // fn#52512, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:3747, offset: 0x0132ed5b, size: 141 bytes, params: 2, frame: 13
var regexp;
const CHANNEL_OR_MESSAGES_URL_RE = (require(4246) /* metro dependency 4246: LinkUtils */).CHANNEL_OR_MESSAGES_URL_RE;
const value = CHANNEL_OR_MESSAGES_URL_RE.exec(a0);
if (value == null) {
return value;
}
if (value[2] != null) {
regexp = RegExp('\\D', '');
if (regexp.test(value[2])) {
return null;
}
}
if (value[3] == null) {
return value;
}
regexp = RegExp('\\D', '');
return regexp.test(value[3]) ? null : value;
}
function parse_52513([property, property2, property3, property4], a1, a2) { // fn#52513, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:3914, offset: 0x0132ede8, size: 147 bytes, params: 4, frame: 23
if (property3 == null) {
return makeLink(property);
}
const channel = getChannel(property3, null);
return channel == null ? handleUnknownChannel(property2, property3, property4,
getGuildIdFromChannelId_52509(a2.channelId), property) : parseChannel(channel, property4,
getGuildIdFromChannelId_52509(a2.channelId), property);
}
function parse_52515([property, property2, property3, property4, property5], a1, a2) { // fn#52515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6809:4285, offset: 0x0132eeaa, size: 213 bytes, params: 4, frame: 24
if (property3 == null) {
return makeLink(property);
}
if (property4 == null) {
return makeLink(property);
}
const channel = getChannel(property4, null);
if (channel != null) {
return parseChannel(channel, property5, getGuildIdFromChannelId_52509(a2.channelId), property);
}
const channel2 = getChannel(property3, null);
return channel2 != null ? parseChannel(channel2, property5, getGuildIdFromChannelId_52509(a2.channelId),
property) : handleUnknownChannel(property2, property3, property5, getGuildIdFromChannelId_52509(a2.channelId),
property);
}