// Metro module 7994 (f7995). import { AttachmentType } from "./RowGeneratorConstants"; import { MessageAttachmentFlags } from "../../../../Constants"; import * as _Module1384 from "../../../../_bundle/Module1384"; import * as _MediaFormatTesters from "../../MediaFormatTesters"; import RowGeneratorUtils from "./RowGeneratorUtils"; import { isAndroid } from "../../../../utils/PlatformUtils"; import { AndroidExoPlayerHttpEngineExperiment } from "../../../media_uploads/experiments/AndroidExoPlayerHttpEngineExperiment"; import { sanitizeMediaDimension } from "./sanitizeMediaDimension"; import { intl, t } from "../../../../intl/index.native"; import * as _SuspiciousDownloadUtils from "../../../suspicious_downloads/SuspiciousDownloadUtils"; import getDisplayFilename from "../../getDisplayFilename"; import Module4728 from "../../../../_bundle/Module4728"; import { getAttachmentObscurityProps } from "./ExplicitMediaUtils"; import { HermesBuiltin } from "../../../../_hermes/prelude"; export default function transformMessageAttachments({ attachments, uploadAttachments, shouldInlineAttachmentMedia, gifAutoPlay, viewImageDescriptions, useReducedMotion, shouldObscureSpoiler, themedBackgroundColor, enabledContentHarmTypeFlags, shouldAgeVerify, colors }) { return attachments.filter((attachment) => attachment.flags == null || !_Module1384.hasFlag(attachment.flags, MessageAttachmentFlags.IS_THUMBNAIL)).map((item, index) => { let r28, videoUrl; const { proxy_url, url, filename, size, width, height, description, duration_secs, waveform, id, placeholder, placeholder_version } = item; let flags = item.flags; const isImageFile = _MediaFormatTesters.isImageFile(filename); const isAudioFile = _MediaFormatTesters.isAudioFile(filename); const isVideoFile = _MediaFormatTesters.isVideoFile(filename); const isWebPlayerVideoFile = _MediaFormatTesters.isWebPlayerVideoFile(filename); const r30 = isImageFile || isVideoFile; const r17 = uploadAttachments != null && index < uploadAttachments.length ? uploadAttachments[index] : void 0; const hasFlag = _Module1384.hasFlag(flags == null ? 0 : flags, MessageAttachmentFlags.IS_ANIMATED); if (isImageFile && (width != null && height != null)) { r28 = RowGeneratorUtils.getImageSrc(proxy_url, width, height, !gifAutoPlay); videoUrl = void 0; } else { let r58 = isVideoFile; if (r58) { let r59 = shouldInlineAttachmentMedia; if (!shouldInlineAttachmentMedia) { r59 = r17 != null; } r58 = r59; } r28 = url; videoUrl = void 0; if (r58) { const r61 = proxy_url != null ? proxy_url + "?format=webp" : url; videoUrl = proxy_url != null ? proxy_url !== "" ? proxy_url : url : url; r28 = r61; } } const mediaViewerHttpEngine = isAndroid() ? isVideoFile ? AndroidExoPlayerHttpEngineExperiment.getConfig({ location: "transformMessageAttachments" }).httpEngine : "default" : "default"; const r81 = r17 != null ? r17.width > 0 ? r17.width : width : width; const r83 = r17 != null ? r17.height > 0 ? r17.height : height : height; const width2 = sanitizeMediaDimension(shouldInlineAttachmentMedia ? r30 ? r81 ?? 0 : 0 : 0); const height2 = sanitizeMediaDimension(shouldInlineAttachmentMedia ? r30 ? r83 ?? 0 : 0 : 0); if (flags == null) { flags = 0; } const r104 = _Module1384.hasFlag(flags, MessageAttachmentFlags.IS_CLIP) ? { attachmentTagText: intl.string(t.gESDiU), attachmentTagIconType: "clip", attachmentTagBackgroundColor: colors.clipTagBackgroundColor, attachmentTagTextColor: colors.clipTagTextColor } : void 0; const url2 = r17 != null ? r17.localUri != null ? r30 ? shouldInlineAttachmentMedia ? r17.localUri : r28 : r28 : r28 : r28; const r120 = { url: url2, isSuspiciousDownload: url2 != null && _SuspiciousDownloadUtils.isSuspiciousDownload(url2) != null, videoUrl, filename: getDisplayFilename(item), size: Module4728.filesize(size), description, alt: intl.string(t.jCV1Tz).toUpperCase(), altTextHint: intl.string(t.fSiQ3A), showDescription: viewImageDescriptions, durationSecs: duration_secs, waveform, width: width2, height: height2, hint: isVideoFile ? intl.string(t["BEWw/7"]) : intl.string(t.IPzNKE), role: isVideoFile ? intl.string(t["/SCpvi"]) : intl.string(t.fKyfca), attachmentType: isImageFile ? AttachmentType.IMAGE : isVideoFile ? AttachmentType.VIDEO : isAudioFile ? AttachmentType.AUDIO : AttachmentType.OTHER, id, isAnimated: !useReducedMotion, uploaderId: r17?.uploaderId, uploaderItemId: r17?.uploaderItemId, backgroundColor: null, placeholder: null, placeholderVersion: null, mediaViewerBufferForPlaybackMs: 1000, mediaViewerBufferForPlaybackAfterRebufferMs: 1000, mediaViewerMinBufferMs: 20000, mediaViewerMaxBufferMs: 20000, mediaViewerEnableDecoderFallback: false, mediaViewerEnableAsyncBufferQueueing: true, mediaViewerHttpEngine: null, srcIsAnimated: null, inlinePlaybackDisabled: null }; let backgroundColor = themedBackgroundColor; if (themedBackgroundColor == null) { backgroundColor = void 0; } r120.backgroundColor = backgroundColor; r120.placeholder = placeholder; r120.placeholderVersion = placeholder_version; r120.mediaViewerHttpEngine = mediaViewerHttpEngine; r120.srcIsAnimated = hasFlag; r120.inlinePlaybackDisabled = isWebPlayerVideoFile; HermesBuiltin.copyDataProperties(r120, getAttachmentObscurityProps({ attachment: item, shouldObscureSpoiler, enabledContentHarmTypeFlags, shouldAgeVerify })); HermesBuiltin.copyDataProperties(r120, r104); return r120; }); };