/* Metro module 7100; source: modules/quests/utils/QuestServerUtils.tsx; dependencies: [57, 4242, 7101, 7098, 2] */ function _fun56749(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#56749, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:6, offset: 0x013d03df, size: 246 bytes, params: 8, frame: 21 const env0_0 = require; const closure = questConfigFromServer; const closure2 = questUserStatusFromServer; const closure3 = function(a0) { var tier = a0.tier; var value = null; return {userId: a0.user_id, questId: a0.quest_id, code: a0.code, platform: a0.platform, claimedAt: a0.claimed_at, tier: value != tier ? tier : value}; }; const _questsEntitlementFromServer = function(a0) { var object = {skuId: a0.sku_id}; object.tenantMetadata = _questsTenantMetadataFromServer(a0.tenant_metadata); object.consumed = a0.consumed; return object; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_2 = importDefault(57) /* metro dependency 57 */; (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/quests/utils/QuestServerUtils.tsx'); exports.isQuestWithKnownConfigVersion = isQuestWithKnownConfigVersion; exports.questConfigFromServer = closure; exports.questUserStatusFromServer = closure2; exports.questWithUserStatusFromServer = questWithUserStatusFromServer; exports.excludedQuestFromServer = function(a0) { return {id: a0.id, replacementId: a0.replacement_id}; }; exports.getClaimedQuestWithUserStatusFromServer = getClaimedQuestWithUserStatusFromServer; exports.questsRewardCodeFromServer = closure3; exports.questsEntitlementsFromServer = function(a0) { var object = {claimedAt: a0.claimed_at}; object.items = a0.entitlements.map(_questsEntitlementFromServer); object.errors = a0.errors; return object; }; } function questConfigFromServer(a0) { // fn#56750, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:108, offset: 0x013d04d5, size: 80 bytes, params: 2, frame: 13 let value = require(4242) /* metro dependency 4242 */; value = value.match(a0); value = value.with({config_version: 2}, _fun56751); return value.exhaustive(); } function progressFromServer(a0) { // fn#56752, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:238, offset: 0x013d054e, size: 189 bytes, params: 2, frame: 24 var r2; var r11; var property; var value5; var property2; var event_name; var value6; var updated_at; var completed_at; var heartbeat; var last_beat_at; var expires_at; var value7; const object2 = {}; const Object = global.Object; const value = Object.entries(a0); let length = value.length; const value2 = 0; const value4 = null; if (value2 < length) { r2 = value2; while (true) { property = value[r2]; value5 = env0_2(property, 2); property = value5[value2]; property2 = value5[1]; event_name = property2.event_name; value6 = property2.value; updated_at = property2.updated_at; completed_at = property2.completed_at; heartbeat = property2.heartbeat; if (value4 == heartbeat) { r11 = value4; } else { last_beat_at = heartbeat.last_beat_at; expires_at = heartbeat.expires_at; r11 = {lastBeatAt: last_beat_at, expiresAt: expires_at}; } object2[property] = {eventName: event_name, value: value6, updatedAt: updated_at, completedAt: completed_at, heartbeat: r11}; value7 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; length = value.length; if (value7 < length) { r2 = value7; continue; } break; } } return object2; } function questUserStatusFromServer({user_id, quest_id, enrolled_at, completed_at, claimed_at, claimed_tier, orb_quantity_claimed, last_stream_heartbeat_at, stream_progress_seconds, dismissed_quest_content, progress}) { // fn#56753, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:551, offset: 0x013d060b, size: 179 bytes, params: 2, frame: 14 const object2 = {}; object2.userId = user_id; object2.questId = quest_id; object2.enrolledAt = enrolled_at; object2.completedAt = completed_at; object2.claimedAt = claimed_at; object2.claimedTier = claimed_tier ?? null; object2.orbQuantityClaimed = orb_quantity_claimed ?? null; object2.lastStreamHeartbeatAt = last_stream_heartbeat_at; object2.streamProgressSeconds = stream_progress_seconds; object2.dismissedQuestContent = dismissed_quest_content; object2.progress = progressFromServer(progress); return object2; } function getSimpleRewardFromServer(a0) { // fn#56754, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:1004, offset: 0x013d06be, size: 193 bytes, params: 2, frame: 13 const type = a0.type; const QuestRewardTypes = (require(7098) /* metro dependency 7098: QuestRewardTypes */).QuestRewardTypes; const VIRTUAL_CURRENCY = QuestRewardTypes.VIRTUAL_CURRENCY; return type === VIRTUAL_CURRENCY ? {skuId: a0.sku_id, type: a0.type, name: a0.name, nameWithArticle: a0.name_with_article, collectibleProduct: a0.collectible_product, orbQuantity: a0.orb_quantity} : {skuId: a0.sku_id, type: a0.type, name: a0.name, nameWithArticle: a0.name_with_article, asset: a0.asset, assetVideo: a0.asset_video, collectibleProduct: a0.collectible_product}; } function getClaimedQuestFromServer(a0) { // fn#56755, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:1402, offset: 0x013d077f, size: 394 bytes, params: 2, frame: 14 const object2 = {}; object2.id = a0.id; object2.startsAt = a0.starts_at; object2.expiresAt = a0.expires_at; object2.features = a0.features; object2.messages = {questName: a0.messages.quest_name, gamePublisher: a0.messages.game_publisher, gameTitle: a0.messages.game_title}; object2.assets = {hero: a0.assets.hero, heroVideo: a0.assets.hero_video, questBarHero: a0.assets.quest_bar_hero, questBarHeroVideo: a0.assets.quest_bar_hero_video, gameTile: a0.assets.game_tile, logotype: a0.assets.logotype, logotypeLight: a0.assets.logotype_light, logotypeDark: a0.assets.logotype_dark, gameTileLight: a0.assets.game_tile_light, gameTileDark: a0.assets.game_tile_dark}; object2.colors = {primary: a0.colors.primary, secondary: a0.colors.secondary}; const rewards = a0.rewards; object2.rewards = rewards.map(getSimpleRewardFromServer); const value = require(7101) /* metro dependency 7101: Quest */; object2.cosponsorMetadata = value.questCosponsorMetadataFromServer(a0.cosponsor_metadata); return object2; } function _questsTenantMetadataFromServer(a0) { // fn#56757, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:2349, offset: 0x013d095b, size: 216 bytes, params: 2, frame: 16 var object; var questsRewardCodeFromServerBinding; const value = undefined; let quest_rewards = a0 == null ? value : a0.quest_rewards; if (quest_rewards == null) { return null; } quest_rewards = a0.quest_rewards; let reward = quest_rewards.reward; const tag = reward.tag; const QuestRewardTypes = (require(7098) /* metro dependency 7098: QuestRewardTypes */).QuestRewardTypes; const IN_GAME = QuestRewardTypes.IN_GAME; if (IN_GAME === tag) { return {questRewards: {reward: {tag: quest_rewards.reward.tag}}}; } const REWARD_CODE = QuestRewardTypes.REWARD_CODE; if (REWARD_CODE === tag) { object = {}; reward = quest_rewards.reward; object.tag = reward.tag; questsRewardCodeFromServerBinding = questsRewardCodeFromServer; reward = quest_rewards.reward; object.rewardCode = questsRewardCodeFromServerBinding(reward.reward_code); return {questRewards: {reward: object}}; } return value; } function isQuestWithKnownConfigVersion(a0) { // fn#56759, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:2987, offset: 0x013d0a68, size: 92 bytes, params: 2, frame: 13 var environment; var value; var property; var match; var config; var closure; var error; try { value = environment; property = dependencyMap[1]; value = require(property); match = value.match; config = a0.config; value = Reflect.apply(match, value, [config]); closure = function() { return true; }; value = value.with({config_version: 2}, closure); value = value.exhaustive(); } catch (error) { return false; } return value; } function questWithUserStatusFromServer(a0) { // fn#56761, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:3266, offset: 0x013d0ac4, size: 111 bytes, params: 2, frame: 14 const object2 = {}; object2.id = a0.id; object2.preview = a0.preview; object2.config = questConfigFromServer(a0.config); const user_status = a0.user_status; const value2 = null; object2.userStatus = value2 == user_status ? value2 : questUserStatusFromServer(a0.user_status); object2.targetedContent = a0.targeted_content; object2.trafficMetadataSealed = a0.traffic_metadata_sealed; return object2; } function getClaimedQuestWithUserStatusFromServer(a0) { // fn#56763, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:3696, offset: 0x013d0b50, size: 76 bytes, params: 2, frame: 14 const object2 = {}; object2.id = a0.id; object2.config = getClaimedQuestFromServer(a0.config); const user_status = a0.user_status; const value2 = null; object2.userStatus = value2 == user_status ? value2 : questUserStatusFromServer(a0.user_status); return object2; } function _fun56751(a0) { // fn#56751, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7278:191, offset: 0x013d0525, size: 41 bytes, params: 2, frame: 11 const value = environment.__proto__; return (require(7101) /* metro dependency 7101: Quest */).questFromServerV2(a0); }