// Metro module 9551 (f9552). import { useEffect, useCallback } from "react"; import GuildAutomodMessageStore from "../../../guild_automod/GuildAutomodMessageStore"; import ReportToModStore from "../../../report_to_mod/ReportToModStore"; import SavedMessagesStore from "../../../saved_messages/SavedMessagesStore"; import { isMessageComponentsV2 } from "../../../../records/MessageRecord"; import AuthenticationStore from "../../../../stores/AuthenticationStore"; import GuildStore from "../../../../stores/GuildStore"; import PermissionStore from "../../../../stores/PermissionStore"; import { FileUploadErrorTypes } from "../../MessageConstants"; import { AnalyticEvents, AnalyticsPages, ChannelTypes, GuildFeatures, LOCAL_BOT_ID, MessageAttachmentFlags, MessageFlags, MessageStates, MessageTypes, MessageTypesSets, Permissions } from "../../../../Constants"; import useAnalyticsLocations, { AnalyticsLocationProvider } from "../../../app_analytics/useAnalyticsLocations"; import AnalyticsLocation from "../../../app_analytics/AnalyticsLocation"; import AppAnalyticsUtils from "../../../app_analytics/AppAnalyticsUtils"; import { showLongPressMessageActionSheet } from "./showLongPressMessageActionSheet"; import { useCanReplyToMessage } from "../../../replies/canReplyToMessage"; import { useCanForwardMessage } from "../../../forwarding/canForwardMessage"; import ForLaterExperiment from "../../../saved_messages/ForLaterExperiment"; import { useStateFromStoresArray, useStateFromStores } from "../../../../_bundle/Module589"; import hasForLaterPremiumType from "../../../saved_messages/hasForLaterPremiumType"; import { useIsNonModInLockedThread, useIsActiveChannelOrUnarchivableThread, computeCanStartPublicThread } from "../../../threads/ThreadHooks"; import useShouldHideMediaOptions from "../../../media_channel/useShouldHideMediaOptions"; import usePollMessageContextItemTypes, { PollMessageContextItemTypes } from "../../../polls/chat/usePollMessageContextItemTypes"; import { DeveloperMode } from "../../../user_settings/UserSettings"; import { useCanToggleGuildOfficialMessages } from "../../GuildOfficialMessageUtils"; import isMessagePinnable from "../../isMessagePinnable"; import { getAllTextDisplayContent } from "../../../interaction_components/InteractionComponentUtils"; import * as _Module1384 from "../../../../_bundle/Module1384"; import countContentTypes from "../../countContentTypes"; import { canRetryInteractionData } from "../../../interactions/InteractionUtils"; import { useIsReportToModEnabled } from "../../../report_to_mod/hooks/useReportToModHooks"; import { ActionSheetRow } from "../../../../design/components/Sheet/native/ActionSheetRow.native"; import { longPressMessageOptionHandler } from "./LongPressMessageActionSheetUtils"; import { ActionSheet } from "../../../../design/components/Sheet/native/ActionSheet.native"; import { isMetaQuest } from "../../../device/MetaQuestUtils.android"; import { shouldShowEmojiRow } from "../../../action_sheet/native/components/EmojiRowUtils"; import EmojiRow from "../../../action_sheet/native/components/EmojiRow"; import { intl, t } from "../../../../intl/index.native"; import { RetryIcon } from "../../../../design/components/Icon/native/redesign/generated/RetryIcon"; import { CopyIcon } from "../../../../design/components/Icon/native/redesign/generated/CopyIcon"; import { TrashIcon } from "../../../../design/components/Icon/native/redesign/generated/TrashIcon"; import { LinkIcon } from "../../../../design/components/Icon/native/redesign/generated/LinkIcon"; import { PencilIcon } from "../../../../design/components/Icon/native/redesign/generated/PencilIcon"; import { ArrowAngleLeftUpIcon } from "../../../../design/components/Icon/native/redesign/generated/ArrowAngleLeftUpIcon"; import ForwardingIcon from "../../../forwarding/native/ForwardingIcon"; import { ThreadIcon } from "../../../../design/components/Icon/native/redesign/generated/ThreadIcon"; import { ChatArrowRightIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatArrowRightIcon"; import { ChatMarkUnreadIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatMarkUnreadIcon"; import { ClockXIcon } from "../../../../design/components/Icon/native/redesign/generated/ClockXIcon"; import { ReactionIcon } from "../../../../design/components/Icon/native/redesign/generated/ReactionIcon"; import { AnnouncementsIcon } from "../../../../design/components/Icon/native/redesign/generated/AnnouncementsIcon"; import { PinIcon } from "../../../../design/components/Icon/native/redesign/generated/PinIcon"; import { StampIcon } from "../../../../design/components/Icon/native/redesign/generated/StampIcon"; import { StampXIcon } from "../../../../design/components/Icon/native/redesign/generated/StampXIcon"; import { NitroWheelIcon } from "../../../../design/components/Icon/native/redesign/generated/NitroWheelIcon"; import { BookmarkOutlineIcon } from "../../../../design/components/Icon/native/redesign/generated/BookmarkOutlineIcon"; import { BookmarkIcon } from "../../../../design/components/Icon/native/redesign/generated/BookmarkIcon"; import { ClockIcon } from "../../../../design/components/Icon/native/redesign/generated/ClockIcon"; import { RobotIcon } from "../../../../design/components/Icon/native/redesign/generated/RobotIcon"; import { ChatIcon } from "../../../../design/components/Icon/native/redesign/generated/ChatIcon"; import { AtIcon } from "../../../../design/components/Icon/native/redesign/generated/AtIcon"; import { DownloadIcon } from "../../../../design/components/Icon/native/redesign/generated/DownloadIcon"; import { IdIcon } from "../../../../design/components/Icon/native/redesign/generated/IdIcon"; import { XSmallBoldIcon } from "../../../../design/components/Icon/native/redesign/generated/XSmallBoldIcon"; import { FlagIcon } from "../../../../design/components/Icon/native/redesign/generated/FlagIcon"; import { ClydeIcon } from "../../../../design/components/Icon/native/redesign/generated/ClydeIcon"; import ReportToMod_messages from "../../../report_to_mod/ReportToMod.messages"; import { ImageWarningIcon } from "../../../../design/components/Icon/native/redesign/generated/ImageWarningIcon"; import { canReportMessageToMods } from "../../../report_to_mod/ReportToModUtils"; import { canReportUser, canReportMessage } from "../../../../utils/ReportUtils"; import canEditMessage from "../../canEditMessage"; import { isWebPlayerVideoUrl } from "../../MediaFormatTesters"; import { messageHasObscurableMedia } from "../../../explicit_media_redaction/ObscuredMediaUtils"; import { hasNonVoteReactions } from "../../../polls/PollsUtils"; import { canViewInteractionInfo } from "../../../applications/ApplicationInteractionInfoUtils"; export default function LongPressMessageActionSheet(a0) { let callback, isActiveChannelOrUnarchivableThread, props, props2, props3, props4, props5, props6, props7, props8, props9, props10, props11, props12, props13, props14, props15, props16, props17, props18, props19, props20, props21, props22, props23, props24, props25, props26, c17286_37, c17286_38; let c17286_0 = a0; const analyticsLocations = useAnalyticsLocations(AnalyticsLocation.MESSAGE_LONG_PRESS_MENU).analyticsLocations; let analyticsLocation = a0.analyticsLocation; if (analyticsLocation === void 0) { analyticsLocation = {}; } let c17286_2 = analyticsLocation; const { user, message, channel, chatInputRef, selectedMedia, actionSheetSource = void 0, canAddNewReactions = false } = a0; useEffect(() => { AppAnalyticsUtils.trackWithMetadata(AnalyticEvents.MESSAGE_ACTION_SHEET_OPENED, { channel_id: channel.id, guild_id: channel.guild_id, location: { page: channel.isPrivate() ? AnalyticsPages.DM_CHANNEL : AnalyticsPages.GUILD_CHANNEL, ...c17286_2 } }); }, [analyticsLocation, channel]); callback = useCallback(() => { showLongPressMessageActionSheet(c17286_0); }, [a0]); const canReplyToMessage2 = useCanReplyToMessage(channel, message); const canForwardMessage2 = useCanForwardMessage(message); const guild = GuildStore.getGuild(channel.guild_id); let enabled = ForLaterExperiment.useConfig({ location: "LongPressMessageActionSheet" }).enabled; const [r73, r74] = useStateFromStoresArray([SavedMessagesStore], () => [SavedMessagesStore.isMessageReminder(channel.id, message.id), SavedMessagesStore.isMessageBookmarked(channel.id, message.id)]); const hasForLaterPremiumType2 = hasForLaterPremiumType(); const isNonModInLockedThread = useIsNonModInLockedThread(channel); const shouldHideMediaOptions = useShouldHideMediaOptions(channel?.id); const r154 = GuildAutomodMessageStore.getMessage(message.id) != null; const interactionError = message.interactionError; const EXPLICIT_CONTENT = FileUploadErrorTypes.EXPLICIT_CONTENT; const pollMessageContextItemTypes = usePollMessageContextItemTypes(message); isActiveChannelOrUnarchivableThread = useIsActiveChannelOrUnarchivableThread(channel); const r69 = user == null ? void 0 : user.isNonUserBot(); const id = AuthenticationStore.getId(); const setting = DeveloperMode.getSetting(); const r49 = PermissionStore.can(Permissions.MANAGE_MESSAGES, channel); const r178 = PermissionStore.can(Permissions.SEND_MESSAGES, channel); const canToggleGuildOfficialMessages = useCanToggleGuildOfficialMessages(message, channel, "LongPressMessageActionSheet"); const id2 = message.author.id; const hasFlag = message.hasFlag(MessageFlags.CROSSPOSTED); const isMessagePinnable2 = isMessagePinnable(message, channel); const r64 = (hasFlag ? !hasFlag : channel.type === ChannelTypes.GUILD_ANNOUNCEMENT) && (guild == null ? void 0 : guild.features.has(GuildFeatures.NEWS)) && r178 && (id2 === id || r49) && message.type === MessageTypes.DEFAULT && !message.isPoll(); const r77 = computeCanStartPublicThread(channel, message); const contentMessage = message.getContentMessage(); const length = contentMessage.embeds.length; const r214 = isMessageComponentsV2(contentMessage) ? getAllTextDisplayContent(contentMessage.components) : contentMessage.content; const r65 = (r49 || message.canDeleteOwnMessage(id)) && length > 0 && message.author.id !== LOCAL_BOT_ID && !_Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL) && countContentTypes(message) >= 1; const r239 = (r154 ? !r154 : !(interactionError === EXPLICIT_CONTENT)) && (message.interactionData == null || canRetryInteractionData(message.interactionData)); const r252 = message.attachments.filter((attachment) => attachment.flags == null || !_Module1384.hasFlag(attachment.flags, MessageAttachmentFlags.IS_THUMBNAIL)); const r54 = message.author.id === id && (r252.length > 1 || message.content !== ""); const stateFromStores = useStateFromStores([ReportToModStore], () => ReportToModStore.hasReportedMessage(message.channel_id, message.id)); const id3 = guild?.id; const getProps = function getProps({ arrow, IconComponent, label, onActionExecuted, variant, disabled }) { return { arrow, icon: , label, onPress: () => { (0, longPressMessageOptionHandler)({ actionSheetSource, analyticsLocations, channel, chatInputRef, label, message, onBack: callback, onActionExecuted, selectedMedia, disabled }); }, variant, disabled }; }; const render = function render(a0) { return }> {a0 == null ? void 0 : a0.map((a0, a1) => {a0.map((item, index) => { const { icon, arrow } = item; return ; })} )} ; }; const isReportToModEnabled = useIsReportToModEnabled(id3); if (message.state === MessageStates.SEND_FAILED) { const r1103 = []; if (r239) { r1103.push(getProps({ label: intl.string(t["5911Lb"]), IconComponent: RetryIcon })); } if (r214 != null && r214.length > 0) { r1103.push(getProps({ label: intl.string(t.JrGD7E), IconComponent: CopyIcon })); } r1103.push(getProps({ label: intl.string(t.xwMqD7), IconComponent: TrashIcon, variant: "danger" })); return render([r1103]); } if (message.state === MessageStates.SENDING) { const r1059 = r214 != null && r214.length > 0; const r1062 = []; if (r1059) { r1062.push(getProps({ label: intl.string(t.JrGD7E), IconComponent: CopyIcon })); } r1062.push(getProps({ label: intl.string(t.xwMqD7), IconComponent: TrashIcon, variant: "danger" })); return render([r1062]); } if (message.type === MessageTypes.THREAD_STARTER_MESSAGE) { return render([[getProps({ label: intl.string(t.k5WiPf), IconComponent: LinkIcon })]]); } props = getProps({ label: intl.string(t.fsBWmS), IconComponent: PencilIcon }); props2 = getProps({ label: intl.string(t["5IEsGx"]), IconComponent: ArrowAngleLeftUpIcon }); props3 = getProps({ label: intl.string(t.I3ltXO), IconComponent: ForwardingIcon }); props4 = getProps({ label: intl.string(t.rBIGBL), IconComponent: ThreadIcon }); const r44 = getProps({ label: intl.string(t["39d0Wj"]), IconComponent: ThreadIcon }); const r45 = getProps({ label: intl.string(t["+TSRGD"]), IconComponent: ChatArrowRightIcon }); const r43 = getProps({ label: intl.string(t.JrGD7E), IconComponent: CopyIcon }); props5 = getProps({ label: intl.string(t.RpE9k7), IconComponent: ChatMarkUnreadIcon }); const r41 = getProps({ label: intl.string(t.grdwwt), IconComponent: ClockXIcon }); const r40 = getProps({ label: intl.string(t.gHp0C4), IconComponent: ReactionIcon }); props6 = getProps({ label: intl.string(t.MFGE51), IconComponent: AnnouncementsIcon }); props7 = getProps({ label: intl.string(t.CvQ18w), IconComponent: PinIcon }); props8 = getProps({ label: intl.string(t["Bse+F/"]), IconComponent: PinIcon }); props9 = getProps({ label: intl.string(t["lE/PG3"]), IconComponent: StampIcon }); props10 = getProps({ label: intl.string(t["2km5Gf"]), IconComponent: StampXIcon }); props11 = getProps({ label: intl.string(t.tpxJto), IconComponent: NitroWheelIcon }); props12 = getProps({ label: intl.string(t.tpxJto), IconComponent: BookmarkOutlineIcon }); props13 = getProps({ label: intl.string(t.SvXS1Z), IconComponent: BookmarkIcon }); props14 = getProps({ label: intl.string(t.mJ3P0N), IconComponent: ClockIcon, arrow: true }); props15 = getProps({ label: intl.string(t.vrbqs1), IconComponent: ClockIcon, arrow: true }); props16 = getProps({ label: intl.string(t.PHjkRE), IconComponent: RobotIcon, arrow: true }); props17 = getProps({ label: intl.string(t["g33r/P"]), IconComponent: ChatIcon }); props18 = getProps({ label: intl.string(t.P8tvKG), IconComponent: AtIcon }); const r26 = getProps({ label: intl.string(t["S/xNKV"]), IconComponent: DownloadIcon }); const r25 = getProps({ label: intl.string(t.JVuuz3), IconComponent: DownloadIcon }); const r24 = getProps({ label: intl.string(t.vbAEaA), IconComponent: DownloadIcon }); let r621 = false; try { const r630 = selectedMedia?.mediaUrl != null ? new URL(selectedMedia.mediaUrl) : null; r621 = selectedMedia?.mediaType === "image" && r630 != null && r630.hostname === "cdn.discordapp.com" && /\.(png|jpe?g|webp|avif|bmp|svg)(\?|$)/i.test(r630.pathname); } catch ($e) {} const r23 = getProps({ label: intl.string(r621 ? t["8xHmxo"] : t["92CPQ+"]), IconComponent: LinkIcon }); props19 = getProps({ label: intl.string(t.Xrt5Po), IconComponent: LinkIcon }); const r689 = getProps({ label: intl.string(t.Rjezbz), IconComponent: ClockIcon, arrow: true }); const r703 = getProps({ label: intl.string(t.zBoHlf), IconComponent: IdIcon }); props20 = getProps({ label: length > 1 ? intl.string(t.wUIMqa) : intl.string(t["4sxKOb"]), IconComponent: XSmallBoldIcon, variant: "danger" }); props21 = getProps({ label: intl.string(t.ZbtGBm), IconComponent: TrashIcon, variant: "danger" }); props22 = getProps({ label: intl.string(t.kFwAsa), IconComponent: TrashIcon, variant: "danger" }); props23 = getProps({ label: intl.string(t["+78Pfm"]), IconComponent: FlagIcon, variant: "danger" }); props24 = getProps({ label: intl.string(t.n5EBAJ), variant: "danger", IconComponent: ClydeIcon }); props25 = getProps({ label: intl.string(ReportToMod_messages["1D+vqy"]), IconComponent: FlagIcon, disabled: stateFromStores }); const r811 = getProps({ label: intl.string(t.ZH7P2h), IconComponent: ImageWarningIcon }); props26 = getProps({ label: intl.string(t.xwMqD7), IconComponent: TrashIcon, variant: "danger" }); c17286_37 = (() => { const r33 = actionSheetSource === "Preview" || _Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL); const r41 = []; if (r33) { r41.push(props4, props5, props12, props13, props11, props14, props15, props20, props26, props, props18, props17, props16, props21); } let r43 = isActiveChannelOrUnarchivableThread; if (isActiveChannelOrUnarchivableThread) { r43 = !_Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL); } if (!r43) { r41.push(props, props2, props20, props22, props26, props6, props7, props8, props9, props10, props5, props18, props16, props21); } if (_Module1384.hasFlag(message.flags, MessageFlags.EPHEMERAL)) { r41.push(props3, props2, props19, props23, props24, props25); } return new Set(r41); })(); const r827 = []; if (actionSheetSource === "Preview") { r827.unshift(r45); } if (r77) { r827.unshift(props4); } else if (message.hasFlag(MessageFlags.HAS_THREAD)) { r827.unshift(r44); } r827.unshift(props19); if (setting) { r827.unshift(r703); } if (isReportToModEnabled && canReportMessageToMods(message)) { r827.unshift(props24); r827.unshift(props25); } else if (user != null && canReportUser(user) && canReportMessage(message)) { r827.unshift(props23); } r827.unshift(props5); if (enabled) { enabled = r74 || r73 || channel.isPrivate() || PermissionStore.can(Permissions.READ_MESSAGE_HISTORY, channel); } L110: { if (enabled) { if (!hasForLaterPremiumType2 && !r74 && !r73) { r827.unshift(props11); break L110; } r827.unshift(r74 ? props13 : props12); r827.unshift(r73 ? props15 : props14); } } if (r65) { r827.unshift(props20); } if (!((r49 ? !r49 : !message.canDeleteOwnMessage(id)) || MessageTypesSets.UNDELETABLE.has(message.type))) { r827.unshift(props26); } if (canEditMessage(message, id) && !isNonModInLockedThread) { r827.unshift(props); } if (r64) { r827.unshift(props6); } const r901 = channel.type === ChannelTypes.GROUP_DM; if (!(channel.isPrivate() && !r901 || r69 === true)) { if (PermissionStore.can(Permissions.SEND_MESSAGES, channel) || r901) { r827.unshift(props18); } if (id !== user?.id) { r827.unshift(props17); } } if (isMessagePinnable2) { r827.unshift(message.pinned ? props8 : props7); } if (canToggleGuildOfficialMessages) { r827.unshift(_Module1384.hasFlag(message.flags, MessageFlags.IS_GUILD_OFFICIAL) ? props10 : props9); } if (r214 != null && r214.length > 0) { r827.unshift(r43); } if (canReplyToMessage2) { r827.unshift(props2); } if (canForwardMessage2) { r827.unshift(props3); } if (!(selectedMedia == null || shouldHideMediaOptions)) { L165: { r827.unshift(r23); if (selectedMedia.mediaType === "image") { r827.unshift(r26); } else { if (selectedMedia.mediaType === "video" && !isWebPlayerVideoUrl(selectedMedia.mediaUrl)) { r827.unshift(r25); break L165; } if (!(selectedMedia.mediaType !== "audio" && selectedMedia.mediaType !== "file")) { r827.unshift(r24); } } } if (messageHasObscurableMedia(message)) { r827.unshift(r811); } if (selectedMedia.sourceType === "attachment" && r54) { r827.unshift(props22); } } let r977 = message.reactions.length > 0; if (r977) { const isPoll = message.isPoll(); r977 = isPoll ? hasNonVoteReactions(message) : !isPoll; } if (r977) { r827.unshift(r40); if (r49) { r827.unshift(props21); } } for (const item of pollMessageContextItemTypes) { if (item === PollMessageContextItemTypes.END_EARLY) { r827.unshift(r41); } } r827.unshift(props16); if (canViewInteractionInfo(message)) { r827.unshift(r689); } c17286_38 = new Set(r827.filter((item) => !c17286_37.has(item))); return render([[props, props2, props3, props4], [r45, r44, r43, props5, r41, r40, props6, props7, props8, props9, props10, props11, props12, props13, props14, props15, props16, props17, props18, r26, r25, r24, r23, props19, r689, r703], [props20, props21, props22, props23, props24, props25, r811, props26]].map((a0) => a0.filter((item) => c17286_38.has(item))).filter((item) => item.length > 0)); };