// Metro module 11988 (f11989). import { useCallback, useMemo, useState } from "react"; import { getSection } from "../../application_commands/ApplicationCommandIndexStore"; import { AnalyticEvents } from "../../../Constants"; import { AppLauncherRouteName } from "../../app_launcher/native/AppLauncherNativeConstants"; import { jsx } from "react/jsx-runtime"; import useIsAppDM from "../../app_dms/useIsAppDM"; import { installApplication } from "../../../utils/native/ApplicationUtils"; import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators"; import { copy } from "../../../utils/ClipboardUtils.native"; import { getApplicationInstallURL } from "../../applications/getApplicationInstallURL"; import { presentLinkCopied } from "../../toast/native/ToastUtils"; import { PlusSmallIcon } from "../../../design/components/Icon/native/redesign/generated/PlusSmallIcon"; import { intl, t } from "../../../intl/index.native"; import { Button } from "../../../design/components/Button/native/Button.native"; import ApplicationActionCreators from "../../applications/ApplicationActionCreators"; import ChannelActionCreators from "../../../actions/ChannelActionCreators"; import { getBestActiveInput } from "../../../utils/native/ChatInputUtils"; import { KeyboardTypes } from "../../keyboard/native/KeyboardTypes"; import AnalyticsUtils from "../../../utils/AnalyticsUtils"; function $mk116349($env) { return () => { const bestActiveInput = getBestActiveInput(); if (bestActiveInput != null) { const r7 = $env; const r21 = r7[0]; const isGuildInstalled = r21.isGuildInstalled; bestActiveInput.openCustomKeyboard({ type: KeyboardTypes.APP_LAUNCHER, context: { initialRouteName: AppLauncherRouteName.APPLICATION_VIEW, initiallyExpanded: true, application: r7[1], installOnDemand: isGuildInstalled ? !isGuildInstalled : !r21.isUserInstalled } }); } }; } let OpenAppButton; let env8232 = {}; const AddAppButton = function AddAppButton(a0) { let r14, r25, LinkExternalSmallIcon2, callback, callback2; let application, guildId; L4: { application = a0.application; guildId = a0.guildId; callback2 = useCallback(() => { installApplication({ applicationId: application.id, customInstallUrl: application.customInstallUrl, installParams: application.installParams, integrationTypesConfig: application.integrationTypesConfig, guildId }); ActionSheetActionCreators.hideActionSheet(); }, [application.customInstallUrl, application.id, application.installParams, application.integrationTypesConfig, guildId]); callback = useCallback(() => { copy(getApplicationInstallURL(application)); presentLinkCopied(); }, [application]); const customInstallUrl = application.customInstallUrl; if (customInstallUrl != null) { r25 = dependencyMap; if (!importDefault(r25[13]).isDiscordUrl(customInstallUrl)) { LinkExternalSmallIcon2 = require(r25[14]).LinkExternalSmallIcon; r14 = require; break L4; } } LinkExternalSmallIcon2 = PlusSmallIcon; r25 = dependencyMap; r14 = require; } const memo = useMemo(() => [{ name: "longpress", label: intl.string(t.XWDihq) }], []); const callback3 = useCallback((a0) => { if (a0.nativeEvent.actionName === "longPress") { copy(getApplicationInstallURL(application)); presentLinkCopied(); } }, [application]); return jsx(r14(r25[17]).Button, { text: r14(r25[16]).intl.string(r14(r25[16]).t.NgXl3C), onPress: callback2, onLongPress: callback, accessibilityActions: memo, onAccessibilityAction: callback3, icon: }); }; OpenAppButton = function OpenAppButton(props) { const { profileApplication, botUserId, channel } = props; const [loading, setState] = useState(false); const callback = useCallback(async () => { let application2, c27218_1, c27218_2; L21: { L17: { let env30477; c27218_2 = void 0; const r12 = env30477 = { $parent: env8232 }; c27218_1 = r12; env30477[0] = void 0; env30477[1] = void 0; const r33 = (0, getSection)({ type: "channel", channel }, profileApplication.id); env30477[0] = r33; if (r33.descriptor?.application == null) { setState(true); } const application3 = r33.descriptor?.application; application2 = application3; if (application3 == null) { application2 = await ApplicationActionCreators.fetchApplication(profileApplication.id); env30477[1] = application2; (0, setState)(false); if (env30477[0] == null) { break L21; } ActionSheetActionCreators.hideActionSheet(); await ChannelActionCreators.openPrivateChannel({ recipientIds: botUserId }); } else { env30477[1] = application2; (0, setState)(false); if (env30477[0] == null) { break L17; } ActionSheetActionCreators.hideActionSheet(); await ChannelActionCreators.openPrivateChannel({ recipientIds: botUserId }); } setTimeout($mk116349(c27218_1), 0); AnalyticsUtils.track(AnalyticEvents.APP_PROFILE_OPEN_APP_BUTTON_CLICKED, { application_id: env30477[1].id }); break L21; } return void 0; } }, [botUserId, channel, profileApplication.id]); return