// Module ID: 8680 // Function ID: 8681 // Name: getOnClick // Dependencies: [32, 5, 5015, 7800, 7505, 502, 2105, 2063, 4772, 5008, 2095, 4609, 5687, 1074, 1076, 7506, 573, 4773, 8681, 9820, 1980, 5769, 7521, 9919, 4771, 4776, 7959, 4477, 1241, 9607, 12225, 13262, 9625, 4801, 11802, 13266, 11093, 11768, 1366, 12049, 5698, 13267, 7815, 4968, 4942, 8428, 13268, 2] // Exports: default // Module 8680 (getOnClick) import DispatcherDefault from "Dispatcher" /* 573 */; import AnalyticsUtilsDefault from "AnalyticsUtils" /* 1241 */; import URLUtilsDefault from "URLUtils" /* 1366 */; import asyncRequireImpl from "asyncRequireImpl" /* 1980 */; import openURLDefault from "openURL" /* 4477 */; import CodedLink from "CodedLink" /* 4776 */; import AppAnalyticsUtilsDefault from "AppAnalyticsUtils" /* 4968 */; import QuestContent from "QuestContent" /* 5698 */; import safeTransitionToDefault from "safeTransitionTo" /* 7521 */; import InstantInviteActionCreatorsDefault from "InstantInviteActionCreators" /* 8681 */; import SocialLayerStorefrontNativeActionCreators from "SocialLayerStorefrontNativeActionCreators" /* 11093 */; import QuestUtils from "QuestUtils" /* 12049 */; import SuspiciousDownloadModalActionCreatorsDefault from "SuspiciousDownloadModalActionCreators" /* 13268 */; import _slicedToArray from "module_32" /* 32 */; import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */; import ApplicationStore from "ApplicationStore" /* 5015 */; import GuildScheduledEventStore from "GuildScheduledEventStore" /* 7800 */; import SocialLayerStorefrontStore from "SocialLayerStorefrontStore" /* 7505 */; import AuthenticationStore from "AuthenticationStore" /* 502 */; import GuildMemberStore from "GuildMemberStore" /* 2105 */; import GuildStore from "GuildStore" /* 2063 */; import InviteStore from "InviteStore" /* 4772 */; import MessageStore from "MessageStore" /* 5008 */; import SelectedChannelStore from "SelectedChannelStore" /* 2095 */; import SelectedGuildStore from "SelectedGuildStore" /* 4609 */; import SortedGuildStore from "SortedGuildStore" /* 5687 */; const require = globalThis.__r; require = fn; function openInviteModal() { const self = this; const apply = closure_18.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; } let closure_18 = async function _openInviteModal() { c3 = 0; c2 = 0; return (async (arg0, value, arg2) => { if (c2 === 2) { c2 = 3; throw new TypeError("Generator functions may not be called on executing generators"); } else if (tmp3 === 3) { if (arg0 === 1) { throw value; } else if (arg0 === 2) { const obj3 = { value, done: true }; return obj3; } else { return { value: "HermesInternal", done: null }; } } else { try { c2 = 2; if (0 === c3) { if (arg0 === 1) { c2 = 3; throw value; } else if (arg0 === 2) { c2 = 3; const obj4 = { value, done: true }; return obj4; } else { const obj5 = { type: "DISPLAYED_INVITE_SHOW", code, username: "Array", deeplinkAttemptId: "accessible", invite_instance_id }; c3 = 1; c2 = 1; const obj6 = { value: DispatcherDefault.dispatch(obj5), done: false }; return obj6; } } else if (arg0 === 1) { c2 = 3; throw value; } else if (arg0 === 2) { c2 = 3; obj = { value, done: true }; return obj; } else { c2 = 3; return { value: "HermesInternal", done: null }; } } catch (tmp9) { c2 = tmp; throw tmp9; } } })(); }; let closure_19 = async function _handleInviteCodedLink(arg0, arg1) { let code = arg0; closure_1 = arg1; c6 = 0; c7 = 0; return (async (arg0, value) => { if (c7 === 2) { c7 = 3; throw new TypeError("Generator functions may not be called on executing generators"); } else if (tmp5 === 3) { if (arg0 === 1) { throw value; } else if (arg0 === 2) { const obj2 = { value, done: true }; return obj2; } else { return { value: "HermesInternal", done: null }; } } else { try { c7 = 2; if (0 === c6) { if (arg0 === 1) { c7 = 3; throw value; } else if (arg0 === 2) { c7 = 3; const obj3 = { value, done: true }; return obj3; } else { closure_5 = tmp2; closure_4 = tmp3; closure_132_0 = undefined; closure_132_1 = undefined; let invite2; let flattenedGuildIds; closure_132_4 = undefined; closure_132_5 = undefined; closure_132_6 = undefined; let id2; let member; closure_132_9 = undefined; code = code.code; closure_132_0 = code; const inviteInstanceId = require("InviteCodeUtils").getInviteInstanceId(code, closure_1); closure_132_1 = inviteInstanceId; invite2 = invite.getInvite(code); let tmp12 = null != invite2; if (tmp12) { tmp12 = invite2.state !== constants.ERROR; } if (tmp12) { if (null != invite2) { if (invite2.state !== closure_133_13.EXPIRED) { if (invite2.state !== closure_133_13.BANNED) { if (invite2.state !== closure_133_13.ERROR) { flattenedGuildIds = closure_133_11.getFlattenedGuildIds(); let id; if (invite2 != null) { const guild = invite2.guild; if (guild != null) { id = guild.id; } } closure_132_4 = id; let hasItem = null != closure_132_4; if (hasItem) { hasItem = flattenedGuildIds.includes(closure_132_4); } closure_132_5 = hasItem; closure_132_6 = false; if (closure_132_5) { if (null != invite2.roles) { if (invite2.roles.length > 0) { id2 = closure_133_6.getId(); member = closure_133_7.getMember(closure_132_4, id2); let roles1; if (member != null) { roles1 = member.roles; } closure_3 = roles1; if (roles1 == null) { closure_3 = []; } const set = new Set(closure_3); closure_132_9 = set; const roles = invite2.roles; closure_132_6 = roles.some((id) => !set.has(id.id)); } } } if (closure_132_5) { if (!closure_132_6) { closure_133_1(closure_133_2[18]).transitionToInvite(invite2, { forceTransition: true }); const obj8 = closure_133_1(closure_133_2[18]); } } c6 = 3; c7 = 1; const obj5 = { value: closure_133_17(invite2, closure_132_0, closure_132_1), done: false }; return obj5; } } } c6 = 2; c7 = 1; const obj6 = { value: closure_133_17(invite2, closure_132_0, closure_132_1), done: false }; return obj6; } } else { const obj7 = { inviteInstanceId }; c6 = 1; c7 = 1; const obj9 = { value: InstantInviteActionCreatorsDefault.resolveInvite(code, "Markdown Link", obj7), done: false }; return obj9; } const obj12 = require("InviteCodeUtils"); } } else if (1 === tmp6) { if (arg0 === 1) { c7 = 3; throw value; } else if (arg0 === 2) { c7 = 3; const obj10 = { value, done: true }; return obj10; } else { invite = value.invite; c2 = invite; if (invite == null) { c2 = undefined; } invite2 = c2; } } else if (2 === tmp6) { if (arg0 === 1) { c7 = 3; throw value; } else if (arg0 === 2) { c7 = 3; const obj11 = { value, done: true }; return obj11; } } else if (arg0 === 1) { c7 = 3; throw value; } else if (arg0 === 2) { c7 = 3; obj = { value, done: true }; return obj; } c7 = 3; return { value: "HermesInternal", done: null }; } catch (tmp66) { c7 = tmp; throw tmp66; } } })(); }; const Constants = fn(1074); ({ AbortCodes, AnalyticEvents: closure_12, AppContext, InviteStates: map1, JoinGuildSources, Routes } = Constants); const CollectiblesShopConstants = fn(1076); ({ CollectibleShopTab: closure_14, CollectiblesMobileShopScreen: closure_15 } = CollectiblesShopConstants); const isGameShopPath = fn(7506).isGameShopPath; let obj = { skipExtensionCheck: "Array", analyticsLocations: [] }; const size = fn(2); let result = size.fileFinishedImporting("lib/getOnClick.tsx"); export default function getOnClick(url) { _require = url; let tmp = arg1; if (arg1 === undefined) { tmp = obj; } ({ analyticsLocations: importDefault, messageId: dependencyMap, channelId } = tmp); pathname = undefined; let obj2; obj = require("findCodedLinks"); const findCodedLinkResult = obj.findCodedLink(url); c3 = findCodedLinkResult; if (null != findCodedLinkResult) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } (function handleInviteCodedLink() { const self = this; const apply = closure_1_19.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; })(c3, paths); return true; }; } if (null != findCodedLinkResult) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } const code = _undefined.code; if (_undefined.type !== CodedLink.CodedLinkType.APP_DIRECTORY_PROFILE) { if (_undefined.type !== tmp3(4776).CodedLinkType.APP_DIRECTORY_STOREFRONT) { let result = tmp3(7959).parseStorefrontSkuCodedLink(code); if (result == null) { result = { applicationId: "HermesInternal", skuId: "Array" }; } const tmp3Result = tmp3(7959); } ({ applicationId, skuId } = result); const guildId = SelectedGuildStore.getGuildId(); if (null != applicationId) { obj = { application_id: applicationId, device_platform: "mobile_native", guild_id: guildId, channel_id: SelectedChannelStore.getChannelId() }; AnalyticsUtilsDefault.track(closure_2_12.APP_DIRECTORY_PROFILE_EMBED_URL_CLICKED, obj); } openURLDefault(closure_0); return true; } result = { applicationId: code, skuId: "Array" }; }; } if (null != findCodedLinkResult) { if (findCodedLinkResult.type === tmp2(4776).CodedLinkType.ACTIVITY_BOOKMARK) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } const code = _undefined.code; url = code; const application = obj2.getApplication(code); const uRL = new URL(_undefined.url); let searchParams = uRL.searchParams; value = searchParams.get("referrer_id"); closure_2 = value; _undefined = analyticsLocations(paths[29])(); const playInContext = url(paths[30]).getPlayInContext(code); const currentChannelId = playInContext.currentChannelId; ({ instanceId: obj2, isCurrentlyInInstance } = playInContext); if (playInContext.canLaunchInChannel) { let flag2 = !isCurrentlyInInstance; if (!isCurrentlyInInstance) { flag2 = null != currentChannelId; } if (flag2) { let searchParams2 = uRL.searchParams; const searchParams3 = uRL.searchParams; value2 = searchParams2.get("link_id"); const customActivityLinkParams = tmp7(tmp6[31]).getCustomActivityLinkParams(code, value2, searchParams3.get("custom_id")); url = pathname((applicationId) => { c3 = 0; c4 = 0; const iter = (function*(arg0) { yield applicationId(paths[32]).runPrimaryAppCommandOrJoinEmbeddedActivity({ channelId, applicationId, isStart: null == closure_1_5, embeddedActivitiesManager, customId, referrerId, analyticsLocations: uRL }); yield "HermesInternal"; closure_1 = tmp2; customId = applicationId.customId; return "PX_16"; })(); iter.next(); return iter; }); const tmp7Result = tmp7(tmp6[31]); customActivityLinkParams.then(function() { const self = this; const apply = closure_0.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; }).catch(() => { }); flag2 = true; const nextPromise = customActivityLinkParams.then(function() { const self = this; const apply = closure_0.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; }); } return flag2; } else { let id; if (application != null) { const bot = application.bot; if (bot != null) { id = bot.id; } } let flag = null != id; if (flag) { obj2 = { recipientIds: id }; const tmp5Result = tmp5(tmp6[33]); url = pathname((targetApplicationId) => { c3 = 0; c4 = 0; return (function*(arg0, value) { if (c4 === 2) { c4 = 3; throw new TypeError("Generator functions may not be called on executing generators"); } else if (tmp4 === 3) { if (arg0 === 1) { throw value; } else if (arg0 === 2) { obj2 = { value, done: true }; return obj2; } else { return { value: "HermesInternal", done: null }; } } else { try { c4 = 2; if (0 === c3) { if (arg0 === 1) { c4 = 3; throw value; } else if (arg0 === 2) { c4 = 3; const obj3 = { value, done: true }; return obj3; } else { referrerId = tmp5; closure_129_0 = targetApplicationId; let customId; const searchParams = tmp2.searchParams; const searchParams2 = tmp2.searchParams; value = searchParams.get("link_id"); c3 = 1; c4 = 1; const obj4 = { value: targetApplicationId(paths[31]).getCustomActivityLinkParams(targetApplicationId, value, searchParams2.get("custom_id")), done: false }; return obj4; } } else if (arg0 === 1) { c4 = 3; throw value; } else if (arg0 === 2) { c4 = 3; obj = { value, done: true }; return obj; } else { customId = value.customId; const obj5 = { targetApplicationId, channelId: closure_129_0, analyticsLocations: uRL, customId, referrerId }; analyticsLocations(paths[34])(obj5); c4 = 3; return { value: "HermesInternal", done: null }; } } catch (tmp6) { c4 = tmp; throw tmp6; } } })(); }); const openPrivateChannelResult = tmp5(tmp6[33]).openPrivateChannel(obj2); tmp5(tmp6[33]).openPrivateChannel(obj2).then(function() { const self = this; const apply = closure_0.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; }).catch(() => { }); flag = true; const nextPromise1 = tmp5(tmp6[33]).openPrivateChannel(obj2).then(function() { const self = this; const apply = closure_0.apply; if (typeof apply === "unknown") { let applyArgumentsResult = HermesBuiltin.applyArguments(self); } else { applyArgumentsResult = apply(self, arguments); } return applyArgumentsResult; }); } return flag; } obj = url(paths[30]); tmp5 = analyticsLocations; tmp7 = url; }; } } if (null != findCodedLinkResult) { if (findCodedLinkResult.type === tmp2(4776).CodedLinkType.GUILD_PRODUCT) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } [closure_0, closure_1] = _undefined.code.split("-"); const tmp2 = _slicedToArray(_undefined.code.split("-"), 2); asyncRequireImpl(13266, dependencyMap.paths).then((openGuildProductLink) => { openGuildProductLink.openGuildProductLink(url, analyticsLocations); }); return true; }; } } if (null != findCodedLinkResult) { if (findCodedLinkResult.type === tmp2(4776).CodedLinkType.SOCIAL_LAYER_STOREFRONT) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } const tmp2 = _slicedToArray(_undefined.code.split("-"), 2); const result = SocialLayerStorefrontNativeActionCreators.openSocialLayerStorefrontProductDetailsModal({ skuId: _slicedToArray(_undefined.code.split("-"), 2)[0], analyticsLocations }); return true; }; } } if (null != findCodedLinkResult) { if (findCodedLinkResult.type === tmp2(4776).CodedLinkType.SOCIAL_LAYER_STOREFRONT_APP) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } const tmp2 = _slicedToArray(_undefined.code.split("-"), 2); const result = SocialLayerStorefrontNativeActionCreators.openSocialLayerStorefrontProductDetailsModal({ skuId: _slicedToArray(_undefined.code.split("-"), 2)[0], analyticsLocations }); return true; }; } } if (null != findCodedLinkResult) { if (findCodedLinkResult.type === tmp2(4776).CodedLinkType.QUESTS_EMBED) { if (tmp2Result.getIsEligibleForQuests()) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } let toURLSafeResult = URLUtilsDefault.toURLSafe(_undefined.url); if (toURLSafeResult == null) { toURLSafeResult = {}; } const search = toURLSafeResult.search; let tmp4; let tmp5; if (null != search) { const _URLSearchParams = URLSearchParams; const uRLSearchParams = new URLSearchParams(search); value = uRLSearchParams.get("sort"); value2 = uRLSearchParams.get("filter"); tmp4 = value2; tmp5 = value; } obj2 = { scrollToQuestId: _undefined.code, sort: null, filter: null, fromContent: null }; if (tmp5 == null) { tmp5 = null; } obj2.sort = tmp5; if (tmp4 == null) { tmp4 = null; } obj2.filter = tmp4; obj2.fromContent = QuestContent.QuestContent.QUEST_SHARE_LINK; QuestUtils.openQuestHome(obj2); return true; }; } tmp2Result = tmp2(11768); } } if (null != findCodedLinkResult) { if (findCodedLinkResult.type === tmp2(4776).CodedLinkType.COLLECTIBLES_SHOP) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } const enabled = url(paths[41]).isVirtualCurrencyEnabled().enabled; obj = url(paths[41]); url(paths[20])(paths[42], paths.paths).then((openCollectiblesShopMobile) => { const tmp3 = _slicedToArray(code.code.split("-"), 2)[1]; if (enabled) { if (tmp2 === constants.ORBS) { let ORBS = constants2.ORBS; } obj = { analyticsSource: analyticsLocations[analyticsLocations.length - 1], analyticsLocations, screen: ORBS, initialProductSkuId: null }; let tmp9; if (tmp4) { tmp9 = tmp3; } obj.initialProductSkuId = tmp9; const result = openCollectiblesShopMobile.openCollectiblesShopMobile(obj); } ORBS = tmp4 ? tmp6.SHOP_ALL : tmp6.FEATURED_PAGE; }); return true; }; } } let toURLSafeResult = URLUtilsDefault.toURLSafe(url); if (toURLSafeResult == null) { toURLSafeResult = {}; } ({ host, hostname, pathname } = toURLSafeResult); ({ search, hash } = toURLSafeResult); let tmp6 = hostname; if (hostname == null) { tmp6 = null; } let isDiscordHostnameResult = URLUtilsDefault.isDiscordHostname(tmp6); if (!isDiscordHostnameResult) { if (host == null) { host = null; } if (hostname == null) { hostname = null; } isDiscordHostnameResult = tmp5(1366).isDiscordLocalhost(host, hostname); const tmp5Result3 = tmp5(1366); } if (isDiscordHostnameResult) { if (null != pathname) { if (isGameShopPath(pathname)) { return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } const result = url(paths[36]).openSocialLayerStorefrontUnsupportedOnMobileAlert(); return true; }; } } } if (null != pathname) { if (isDiscordHostnameResult) { if (tmp5Result4.isAppRoute(pathname)) { obj2 = { navigationReplace: false, openChannel: true }; if (null != search) { obj2.search = search; } if (null != hash) { obj2.hash = hash; } return (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } safeTransitionToDefault(pathname, obj2); return true; }; } tmp5Result4 = tmp5(1366); } } if (null != findCodedLinkResult) { if (findCodedLinkResult.type === tmp2(4776).CodedLinkType.APP_OAUTH2_LINK) { let fn = (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } AppAnalyticsUtilsDefault.trackWithMetadata(closure_2_12.APP_OAUTH2_LINK_EMBED_URL_CLICKED, { application_id: _undefined.code }); openURLDefault(closure_0); return true; }; } return fn; } let tmp5Result = URLUtilsDefault; let result = require("LinkUtils").tryParseEventDetailsPath(pathname); if (!tmp.skipExtensionCheck) { if (null != tmp2Result4.isSuspiciousDownload(url)) { fn = (preventDefault) => { if (preventDefault != null) { preventDefault.preventDefault(); } SuspiciousDownloadModalActionCreatorsDefault.show(closure_0); return true; }; } tmp2Result4 = tmp2(8428); } };