236 lines
12 KiB
TypeScript
236 lines
12 KiB
TypeScript
/* Metro module 7100; source: modules/quests/utils/QuestServerUtils.tsx; dependencies: [57, 4242, 7101, 7098, 2] */
|
|
import Module00057 from '../../../by-id/module-00057.js'; /* Metro dependency 57 */
|
|
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as Module04242Module from '../../../by-id/module-04242.js'; /* Metro dependency 4242 */
|
|
import * as QuestRewardTypesModule from '../../../external/discord_common/js/shared/shared-constants/QuestRewardTypes.tsx'; /* Metro dependency 7098 */
|
|
import * as QuestModule from '../types/v2/Quest.tsx'; /* Metro dependency 7101 */
|
|
|
|
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 questConfigFromServer2 = questConfigFromServer;
|
|
const questUserStatusFromServer2 = 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});
|
|
(FileImportTrackerModule).fileFinishedImporting('modules/quests/utils/QuestServerUtils.tsx');
|
|
exports.isQuestWithKnownConfigVersion = isQuestWithKnownConfigVersion;
|
|
exports.questConfigFromServer = questConfigFromServer2;
|
|
exports.questUserStatusFromServer = questUserStatusFromServer2;
|
|
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 = Module04242Module;
|
|
value = value.match(a0);
|
|
value = value.with({config_version: 2}, _fun56751);
|
|
return value.exhaustive();
|
|
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 (QuestModule).questFromServerV2(a0);
|
|
}
|
|
|
|
}
|
|
|
|
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 object = {};
|
|
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 = Module00057(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};
|
|
}
|
|
object[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 object;
|
|
}
|
|
|
|
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 object = {};
|
|
object.userId = user_id;
|
|
object.questId = quest_id;
|
|
object.enrolledAt = enrolled_at;
|
|
object.completedAt = completed_at;
|
|
object.claimedAt = claimed_at;
|
|
object.claimedTier = claimed_tier ?? null;
|
|
object.orbQuantityClaimed = orb_quantity_claimed ?? null;
|
|
object.lastStreamHeartbeatAt = last_stream_heartbeat_at;
|
|
object.streamProgressSeconds = stream_progress_seconds;
|
|
object.dismissedQuestContent = dismissed_quest_content;
|
|
object.progress = progressFromServer(progress);
|
|
return object;
|
|
}
|
|
|
|
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 = (QuestRewardTypesModule).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 object = {};
|
|
object.id = a0.id;
|
|
object.startsAt = a0.starts_at;
|
|
object.expiresAt = a0.expires_at;
|
|
object.features = a0.features;
|
|
object.messages = {questName: a0.messages.quest_name, gamePublisher: a0.messages.game_publisher,
|
|
gameTitle: a0.messages.game_title};
|
|
object.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};
|
|
object.colors = {primary: a0.colors.primary, secondary: a0.colors.secondary};
|
|
const rewards = a0.rewards;
|
|
object.rewards = rewards.map(getSimpleRewardFromServer);
|
|
object.cosponsorMetadata = QuestModule.questCosponsorMetadataFromServer(a0.cosponsor_metadata);
|
|
return object;
|
|
}
|
|
|
|
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 object2;
|
|
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 = (QuestRewardTypesModule).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) {
|
|
object2 = {};
|
|
reward = quest_rewards.reward;
|
|
object2.tag = reward.tag;
|
|
questsRewardCodeFromServerBinding = questsRewardCodeFromServer;
|
|
reward = quest_rewards.reward;
|
|
object2.rewardCode = questsRewardCodeFromServerBinding(reward.reward_code);
|
|
return {questRewards: {reward: object2}};
|
|
}
|
|
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 object = {};
|
|
object.id = a0.id;
|
|
object.preview = a0.preview;
|
|
object.config = questConfigFromServer(a0.config);
|
|
const user_status = a0.user_status;
|
|
const value2 = null;
|
|
object.userStatus = value2 == user_status ? value2 : questUserStatusFromServer(a0.user_status);
|
|
object.targetedContent = a0.targeted_content;
|
|
object.trafficMetadataSealed = a0.traffic_metadata_sealed;
|
|
return object;
|
|
}
|
|
|
|
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 object = {};
|
|
object.id = a0.id;
|
|
object.config = getClaimedQuestFromServer(a0.config);
|
|
const user_status = a0.user_status;
|
|
const value2 = null;
|
|
object.userStatus = value2 == user_status ? value2 : questUserStatusFromServer(a0.user_status);
|
|
return object;
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun56749, 7100, [57, 4242, 7101, 7098,
|
|
2]) /* metro module 7100, dependencies: [57, 4242, 7101, 7098, 2] */;
|