195 lines
6.0 KiB
TypeScript
195 lines
6.0 KiB
TypeScript
// Metro module 7876 (f7877).
|
|
import { runMessageMarkupPostProcessors } from "./MarkupPostProcessors";
|
|
import MarkupUtils from "../markup/MarkupUtils";
|
|
function $mk79368() {
|
|
return (a0) => Array.isArray(a0) ? a0 : [a0];
|
|
}
|
|
let render;
|
|
const getInitialParserState = function getInitialParserState({ channelId, messageId, authorId, renderOptions }) {
|
|
return {
|
|
channelId,
|
|
messageId,
|
|
authorId,
|
|
allowLinks: Boolean(renderOptions.allowLinks),
|
|
allowDevLinks: Boolean(renderOptions.allowDevLinks),
|
|
allowGameMentions: Boolean(renderOptions.allowGameMentions),
|
|
allowTimeMentionInput: Boolean(renderOptions.allowTimeMentionInput),
|
|
formatInline: Boolean(renderOptions.formatInline),
|
|
noStyleAndInteraction: Boolean(renderOptions.noStyleAndInteraction),
|
|
allowHeading: Boolean(renderOptions.allowHeading),
|
|
allowList: Boolean(renderOptions.allowList),
|
|
previewLinkTarget: Boolean(renderOptions.previewLinkTarget),
|
|
disableAnimatedEmoji: Boolean(renderOptions.disableAnimatedEmoji),
|
|
allowEmojiLinks: false,
|
|
disableAutoBlockNewlines: true,
|
|
mentionChannels: [],
|
|
mentionGames: new Map(),
|
|
soundboardSounds: [],
|
|
muted: false,
|
|
unknownUserMentionPlaceholder: true,
|
|
viewingChannelId: renderOptions.viewingChannelId,
|
|
forceWhite: Boolean(renderOptions.forceWhite),
|
|
textColor: renderOptions.textColor,
|
|
disablePressableChannelMention: Boolean(renderOptions.disablePressableChannelMention)
|
|
};
|
|
};
|
|
render = function render(a0, a1, a2) {
|
|
const message = a1;
|
|
const { toAST = false, hideSimpleEmbedContent = true, formatInline = false, postProcessor } = a2;
|
|
let contentMessage2 = a2.contentMessage;
|
|
const contentMessage = contentMessage2;
|
|
const hasSpoilerEmbeds = false;
|
|
let hasBailedAst = false;
|
|
if (contentMessage == null) {
|
|
contentMessage2 = a1;
|
|
}
|
|
const content = contentMessage2.content;
|
|
const initialParserState = getInitialParserState({
|
|
channelId: a1.channel_id,
|
|
messageId: a1.id,
|
|
authorId: a1.author?.id,
|
|
renderOptions: a2
|
|
});
|
|
const allowEmojiLinks = a1.webhookId != null;
|
|
const allowLinks = allowEmojiLinks || initialParserState.allowLinks;
|
|
let mentionGames = a1.mentionGames;
|
|
if (mentionGames == null) {
|
|
mentionGames = new Map();
|
|
}
|
|
let soundboardSounds = a1.soundboardSounds;
|
|
if (soundboardSounds == null) {
|
|
soundboardSounds = [];
|
|
}
|
|
return {
|
|
hasSpoilerEmbeds,
|
|
hasBailedAst,
|
|
content: a0(content, true, {
|
|
...initialParserState,
|
|
allowLinks,
|
|
allowEmojiLinks,
|
|
mentionChannels: a1.mentionChannels,
|
|
mentionGames,
|
|
soundboardSounds
|
|
}, (a0, a1, a2) => {
|
|
hasBailedAst = a2 == null ? false : a2;
|
|
const r20 = runMessageMarkupPostProcessors({
|
|
ast: a0,
|
|
inline: a1,
|
|
hasBailedAst,
|
|
message,
|
|
contentMessage,
|
|
messageContent: content,
|
|
hideSimpleEmbedContent,
|
|
formatInline,
|
|
toAST
|
|
});
|
|
const ast = r20.ast;
|
|
hasSpoilerEmbeds = r20.hasSpoilerEmbeds;
|
|
return postProcessor != null ? postProcessor(ast, a1) : ast;
|
|
})
|
|
};
|
|
};
|
|
export default function renderMessageMarkup(a0, r5 = {}) {
|
|
return render(r5.formatInline ? MarkupUtils.parseInlineReply : MarkupUtils.parse, a0, r5);
|
|
};
|
|
export function getInitialParserStateFromMessage(a0, a1) {
|
|
const initialParserState = getInitialParserState({
|
|
channelId: a0.channel_id,
|
|
messageId: a0.id,
|
|
authorId: a0.author?.id,
|
|
renderOptions: a1
|
|
});
|
|
const allowEmojiLinks = a0.webhookId != null;
|
|
const allowLinks = allowEmojiLinks || initialParserState.allowLinks;
|
|
let mentionGames = a0.mentionGames;
|
|
if (mentionGames == null) {
|
|
mentionGames = new Map();
|
|
}
|
|
let soundboardSounds = a0.soundboardSounds;
|
|
if (soundboardSounds == null) {
|
|
soundboardSounds = [];
|
|
}
|
|
return {
|
|
...initialParserState,
|
|
allowLinks,
|
|
allowEmojiLinks,
|
|
mentionChannels: a0.mentionChannels,
|
|
mentionGames,
|
|
soundboardSounds
|
|
};
|
|
}
|
|
export { getInitialParserState };
|
|
export function renderMessageMarkupWithParser(a0, a1, r5 = {}) {
|
|
return render(a0, a1, r5);
|
|
}
|
|
export function renderMessageMarkupToAST(a0, r6 = {}) {
|
|
return render(r6.formatInline ? MarkupUtils.parseInlineReplyToAST : MarkupUtils.parseToAST, a0, {
|
|
...r6,
|
|
toAST: true
|
|
});
|
|
}
|
|
export function renderMessageContentMarkup(a0, { content: content2, guildId, channelId, messageId, authorId }) {
|
|
return a0(content2, true, {
|
|
allowLinks: false,
|
|
allowDevLinks: false,
|
|
allowEmojiLinks: false,
|
|
allowGameMentions: false,
|
|
mentionChannels: [],
|
|
mentionGames: new Map(),
|
|
soundboardSounds: [],
|
|
formatInline: true,
|
|
noStyleAndInteraction: false,
|
|
allowHeading: false,
|
|
allowList: false,
|
|
disableAutoBlockNewlines: true,
|
|
previewLinkTarget: false,
|
|
disableAnimatedEmoji: true,
|
|
guildId,
|
|
channelId,
|
|
messageId,
|
|
authorId,
|
|
muted: false,
|
|
disablePressableChannelMention: true
|
|
}, (a0) => Array.isArray(a0) ? a0 : [a0]);
|
|
}
|
|
export function renderAutomodMessageMarkup(a0, a1, a2) {
|
|
return (0, MarkupUtils.parseAutoModerationSystemMessage)(a0, true, {
|
|
allowLinks: false,
|
|
allowDevLinks: false,
|
|
allowEmojiLinks: false,
|
|
allowGameMentions: false,
|
|
mentionChannels: [],
|
|
mentionGames: new Map(),
|
|
soundboardSounds: [],
|
|
formatInline: false,
|
|
noStyleAndInteraction: false,
|
|
allowHeading: false,
|
|
allowList: false,
|
|
disableAutoBlockNewlines: true,
|
|
highlightWord: a1,
|
|
disableAnimatedEmoji: false,
|
|
channelId: a2,
|
|
muted: false
|
|
}, $mk79368());
|
|
}
|
|
export function renderAutomodMessageMarkupToAST(a0, a1, a2) {
|
|
return (0, MarkupUtils.parseAutoModerationSystemMessageToAST)(a0, true, {
|
|
allowLinks: false,
|
|
allowDevLinks: false,
|
|
allowEmojiLinks: false,
|
|
allowGameMentions: false,
|
|
mentionChannels: [],
|
|
mentionGames: new Map(),
|
|
soundboardSounds: [],
|
|
formatInline: false,
|
|
noStyleAndInteraction: false,
|
|
allowHeading: false,
|
|
allowList: false,
|
|
disableAutoBlockNewlines: true,
|
|
highlightWord: a1,
|
|
disableAnimatedEmoji: false,
|
|
channelId: a2,
|
|
muted: false
|
|
}, $mk79368());
|
|
}
|