466 lines
18 KiB
TypeScript
466 lines
18 KiB
TypeScript
/* Metro module 8258; source: modules/premium/powerups/GuildPowerupsStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 1867, 8259, 661, 566, 694, 2] */
|
|
function _fun66058(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#66058, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:6, offset: 0x01bea02c, size: 501 bytes, params: 8, frame: 19
|
|
let Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_0 = importDefault(6) /* metro dependency 6 */;
|
|
const env0_1 = importDefault(7) /* metro dependency 7 */;
|
|
const env0_2 = importDefault(15) /* metro dependency 15 */;
|
|
const env0_3 = importDefault(17) /* metro dependency 17 */;
|
|
const env0_4 = importDefault(18) /* metro dependency 18 */;
|
|
const env0_5 = importDefault(57) /* metro dependency 57 */;
|
|
const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */;
|
|
const env0_7 = (require(8259) /* metro dependency 8259: GuildPowerupsConstants */).PURCHASABLE_PREMIUM_FEATURES_BOOST_INFO;
|
|
let value = require(661) /* metro dependency 661: Constants */;
|
|
const env0_8 = value.AppliedGuildBoostsRequiredForBoostedGuildTier;
|
|
const env0_9 = value.BoostedGuildTiers;
|
|
const env0_10 = value.GuildFeatures;
|
|
let env0_11 = {};
|
|
const PersistedStore = (importDefault(566) /* metro dependency 566: flux */).PersistedStore;
|
|
value = _fun66066(PersistedStore);
|
|
value.displayName = 'GuildPowerupsStore';
|
|
value.persistKey = 'GuildPowerupsStore';
|
|
value.migrations = [function(a0) {
|
|
var r0;
|
|
var Object;
|
|
var value = a0;
|
|
if (value == null) {
|
|
r0 = value;
|
|
} else {
|
|
Object = global.Object;
|
|
value = global.Object.entries(value);
|
|
value = value.filter(_fun66076);
|
|
value = Object.fromEntries(value.map(_fun66077));
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}];
|
|
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {LOGOUT: function() {
|
|
env0_11 = {};
|
|
}, GUILD_POWERUP_CATALOG_FETCH_SUCCESS: GUILD_POWERUP_CATALOG_FETCH_SUCCESS,
|
|
GUILD_BOOST_ENTITLEMENTS_FETCH_SUCCESS: GUILD_BOOST_ENTITLEMENTS_FETCH_SUCCESS_66080,
|
|
GUILD_POWERUP_ENTITLEMENTS_CREATE: function(a0) {
|
|
recalculateState(a0, true);
|
|
}, GUILD_POWERUP_ENTITLEMENTS_DELETE: function(a0) {
|
|
recalculateState(a0, false);
|
|
}, GUILD_UPDATE: GUILD_UPDATE_66083,
|
|
GAME_SERVER_FETCH_INSTANCES_SUCCESS: GAME_SERVER_FETCH_INSTANCES_SUCCESS_66084});
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/premium/powerups/GuildPowerupsStore.tsx');
|
|
exports.default = value;
|
|
}
|
|
|
|
function _isNativeReflectConstruct_66059() { // fn#66059, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:318, offset: 0x01bea221, size: 98 bytes, params: 1, frame: 18
|
|
var Boolean;
|
|
var prototype;
|
|
var valueOf;
|
|
var call;
|
|
var Reflect;
|
|
var construct;
|
|
var closure;
|
|
var value;
|
|
var error;
|
|
try {
|
|
Boolean = global.Boolean;
|
|
prototype = Boolean.prototype;
|
|
valueOf = prototype.valueOf;
|
|
call = valueOf.call;
|
|
Reflect = global.Reflect;
|
|
construct = Reflect.construct;
|
|
Boolean = global.Boolean;
|
|
closure = function() {
|
|
};
|
|
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
|
|
value = Reflect.apply(call, valueOf, [value]);
|
|
var result = !value;
|
|
} catch (error) {
|
|
}
|
|
return (_isNativeReflectConstruct_66059_isNativeReflectConstruct = function() {
|
|
return !!result;
|
|
})();
|
|
}
|
|
|
|
function calculateAppliedBoosts(a0) { // fn#66062, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:520, offset: 0x01bea283, size: 343 bytes, params: 2, frame: 28
|
|
var r2;
|
|
var premiumTier;
|
|
var r0;
|
|
var r3;
|
|
var r4;
|
|
var r5;
|
|
var r16;
|
|
var r15;
|
|
var r17;
|
|
var features;
|
|
var property;
|
|
var value7;
|
|
var property2;
|
|
var value8;
|
|
var premiumFeatures;
|
|
var value9;
|
|
var value10;
|
|
var isEnabled;
|
|
var isEnabled2;
|
|
var value11;
|
|
var includedInLevel;
|
|
var value12;
|
|
var value13;
|
|
var boostPrice;
|
|
var value14;
|
|
var value15;
|
|
const guild = GuildStore.getGuild(a0);
|
|
const value3 = undefined;
|
|
if (guild == null) {
|
|
r2 = value3;
|
|
} else {
|
|
features = guild.features;
|
|
r2 = features.has(GuildFeatures.PREMIUM_TIER_3_OVERRIDE);
|
|
}
|
|
const value5 = 0;
|
|
if (r2 === true) {
|
|
r0 = value5;
|
|
} else {
|
|
premiumTier = guild == null ? value3 : guild.premiumTier;
|
|
property = AppliedGuildBoostsRequiredForBoostedGuildTier[premiumTier ?? BoostedGuildTiers.NONE];
|
|
r0 = property;
|
|
}
|
|
const Object = global.Object;
|
|
const value6 = Object.entries(PURCHASABLE_PREMIUM_FEATURES_BOOST_INFO);
|
|
let length = value6.length;
|
|
if (value5 < length) {
|
|
r3 = value3;
|
|
r4 = value5;
|
|
r5 = r0;
|
|
while (true) {
|
|
property = value6[r4];
|
|
value7 = env0_5(property, 2);
|
|
property = value7[value5];
|
|
property2 = value7[1];
|
|
value8 = guild != null;
|
|
if (value8) {
|
|
premiumFeatures = guild.premiumFeatures;
|
|
value9 = premiumFeatures != null;
|
|
r3 = premiumFeatures;
|
|
r16 = value9;
|
|
} else {
|
|
r16 = value8;
|
|
}
|
|
if (!r16) {
|
|
continue;
|
|
}
|
|
features = r3.features;
|
|
value10 = features.includes(property);
|
|
r16 = value10;
|
|
if (!r16) {
|
|
continue;
|
|
}
|
|
isEnabled = property2.isEnabled;
|
|
if (isEnabled == null) {
|
|
r15 = value3;
|
|
continue;
|
|
}
|
|
isEnabled2 = property2.isEnabled(a0);
|
|
r15 = isEnabled2;
|
|
value11 = r15 == null;
|
|
if (value11) {
|
|
r17 = value11;
|
|
continue;
|
|
}
|
|
r17 = r15;
|
|
continue;
|
|
r16 = r17;
|
|
if (!r16) {
|
|
continue;
|
|
}
|
|
includedInLevel = property2.includedInLevel;
|
|
value12 = includedInLevel == null;
|
|
if (value12) {
|
|
r15 = value12;
|
|
continue;
|
|
}
|
|
premiumTier = guild.premiumTier;
|
|
includedInLevel = property2.includedInLevel;
|
|
value13 = premiumTier < includedInLevel;
|
|
r15 = value13;
|
|
r16 = r15;
|
|
if (!r16) {
|
|
r15 = r5;
|
|
continue;
|
|
}
|
|
boostPrice = property2.boostPrice;
|
|
value14 = r5 + boostPrice;
|
|
r15 = value14;
|
|
value15 = typeof r4 === 'bigint' ? r4 + 1n : +r4 + 1;
|
|
length = value6.length;
|
|
if (value15 < length) {
|
|
r4 = value15;
|
|
r5 = r15;
|
|
continue;
|
|
}
|
|
r0 = r15;
|
|
break;
|
|
}
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function getStateForGuild_66063(a0) { // fn#66063, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:987, offset: 0x01bea3da, size: 77 bytes, params: 2, frame: 14
|
|
if (env0_11[a0] == null) {
|
|
env0_11[a0] = {allPowerups: {}, powerupCatalog: {}, unlockedPowerups: {},
|
|
appliedBoosts: calculateAppliedBoosts(a0)};
|
|
}
|
|
return env0_11[a0];
|
|
}
|
|
|
|
function recalculateState({guildId, entitlements}, a1) { // fn#66064, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:1151, offset: 0x01bea427, size: 112 bytes, params: 3, frame: 16
|
|
const env0_0 = a1;
|
|
const stateForGuild_66063 = getStateForGuild_66063(guildId);
|
|
entitlements.forEach(_fun66065);
|
|
const object3 = {};
|
|
copyDataProperties(object3, env0_11, entitlements);
|
|
const object4 = {};
|
|
copyDataProperties(object4, stateForGuild_66063, entitlements);
|
|
object4['appliedBoosts'] = calculateAppliedBoosts(guildId);
|
|
object3[guildId] = object4;
|
|
}
|
|
|
|
function _fun66066(a0) { // fn#66066, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:1386, offset: 0x01bea4c2, size: 228 bytes, params: 2, frame: 16
|
|
const closure = GuildPowerupsStore;
|
|
env0_4(closure, a0);
|
|
return env0_1(closure, [{key: 'initialize', value: function(a0) {
|
|
this.waitFor(GuildStore);
|
|
if (a0 != null) {
|
|
env1_11 = a0;
|
|
}
|
|
}}, {key: 'getState', value: value_66069}, {key: 'getStateForGuild', value: value_66070},
|
|
{key: 'shouldFetchCatalogForGuild', value: value_66071}, {key: 'shouldFetchPowerupsForGuild',
|
|
value: value_66072}, {key: 'hasFetchedPowerupCatalog', value: value_66073}, {key: 'hasFetchedUnlockedPowerups',
|
|
value: value_66074}]);
|
|
}
|
|
|
|
function _fun66075(a0) { // fn#66075, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:2533, offset: 0x01bea6d9, size: 86 bytes, params: 2, frame: 15
|
|
var r0;
|
|
var Object;
|
|
var fromEntries;
|
|
let value = a0;
|
|
if (value == null) {
|
|
r0 = value;
|
|
} else {
|
|
Object = global.Object;
|
|
fromEntries = Object.fromEntries;
|
|
value = global.Object.entries(value);
|
|
value = value.filter(function(a0) {
|
|
var r0;
|
|
var r1;
|
|
var r2;
|
|
var item3;
|
|
var value3;
|
|
var iterator = a0[Symbol.iterator]();
|
|
var iterator2 = iterator.next;
|
|
var item2 = Reflect.apply(iterator2, iterator, []);
|
|
var item = item2.value;
|
|
item2 = item2.done ? undefined : iterator;
|
|
var value = undefined;
|
|
var value2 = item2 === value;
|
|
if (value2) {
|
|
r0 = item2;
|
|
r1 = value;
|
|
r2 = value2;
|
|
} else {
|
|
item3 = Reflect.apply(iterator2, item2, []);
|
|
item = item3.value;
|
|
item3 = item3.done ? undefined : item2;
|
|
value3 = item3 === value;
|
|
if (value3) {
|
|
r0 = item3;
|
|
r1 = value;
|
|
r2 = value3;
|
|
} else {
|
|
r0 = item3;
|
|
r1 = item;
|
|
r2 = value3;
|
|
}
|
|
}
|
|
if (!r2) {
|
|
r0.return();
|
|
}
|
|
return r1 != null && typeof r1 === 'object';
|
|
});
|
|
value = Reflect.apply(fromEntries, Object, [value.map(_fun66077)]);
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function GUILD_POWERUP_CATALOG_FETCH_SUCCESS({guildId, allPowerups, powerupCatalog}) { // fn#66079, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:2914, offset: 0x01bea816, size: 129 bytes, params: 2, frame: 17
|
|
const stateForGuild_66063 = getStateForGuild_66063(guildId);
|
|
const object3 = {};
|
|
copyDataProperties(object3, env0_11, allPowerups);
|
|
const object4 = {};
|
|
copyDataProperties(object4, stateForGuild_66063, allPowerups);
|
|
object4['allPowerups'] = allPowerups;
|
|
object4['powerupCatalog'] = powerupCatalog;
|
|
const Date = global.Date;
|
|
object4['catalogFetchCooldown'] = Date.now();
|
|
object4['hasFetchedPowerupCatalog'] = true;
|
|
object3[guildId] = object4;
|
|
}
|
|
|
|
function GUILD_BOOST_ENTITLEMENTS_FETCH_SUCCESS_66080({guildId, unlockedPowerups}) { // fn#66080, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:3182, offset: 0x01bea897, size: 132 bytes, params: 2, frame: 17
|
|
const stateForGuild_66063 = getStateForGuild_66063(guildId);
|
|
const value3 = calculateAppliedBoosts(guildId);
|
|
const object3 = {};
|
|
copyDataProperties(object3, env0_11, unlockedPowerups);
|
|
const object4 = {};
|
|
copyDataProperties(object4, stateForGuild_66063, unlockedPowerups);
|
|
object4['unlockedPowerups'] = unlockedPowerups;
|
|
object4['appliedBoosts'] = value3;
|
|
const Date = global.Date;
|
|
object4['unlockedPowerupsFetchCooldown'] = Date.now();
|
|
object4['hasFetchedUnlockedPowerups'] = true;
|
|
object3[guildId] = object4;
|
|
}
|
|
|
|
function GUILD_UPDATE_66083({guild}) { // fn#66083, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:3650, offset: 0x01bea947, size: 64 bytes, params: 2, frame: 15
|
|
const id = guild.id;
|
|
const binding = env0_11;
|
|
const object2 = {};
|
|
const getStateForGuild_66063Binding = getStateForGuild_66063;
|
|
copyDataProperties(object2, getStateForGuild_66063Binding(id), getStateForGuild_66063Binding);
|
|
object2['appliedBoosts'] = calculateAppliedBoosts(id);
|
|
binding[id] = object2;
|
|
}
|
|
|
|
function GAME_SERVER_FETCH_INSTANCES_SUCCESS_66084({guildId}) { // fn#66084, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:3801, offset: 0x01bea987, size: 59 bytes, params: 2, frame: 15
|
|
const binding = env0_11;
|
|
const object2 = {};
|
|
const getStateForGuild_66063Binding = getStateForGuild_66063;
|
|
copyDataProperties(object2, getStateForGuild_66063Binding(guildId), getStateForGuild_66063Binding);
|
|
object2['appliedBoosts'] = calculateAppliedBoosts(guildId);
|
|
binding[guildId] = object2;
|
|
}
|
|
|
|
function _fun66065(a0) { // fn#66065, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:1244, offset: 0x01bea497, size: 43 bytes, params: 2, frame: 4
|
|
const unlockedPowerups = env0_1.unlockedPowerups;
|
|
const sku_id = a0.sku_id;
|
|
if (require) {
|
|
unlockedPowerups[sku_id] = a0;
|
|
} else {
|
|
delete unlockedPowerups[sku_id];
|
|
}
|
|
}
|
|
|
|
function value_66070(a0) { // fn#66070, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:1825, offset: 0x01bea5cc, size: 27 bytes, params: 2, frame: 3
|
|
return a0 != null ? env1_11[a0] : undefined;
|
|
}
|
|
|
|
function value_66071(a0) { // fn#66071, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:1906, offset: 0x01bea5e7, size: 73 bytes, params: 2, frame: 11
|
|
var r0;
|
|
var Date;
|
|
let value = environment.__proto__;
|
|
const catalogFetchCooldown = env1_11[a0]?.catalogFetchCooldown;
|
|
value = catalogFetchCooldown == null;
|
|
if (value) {
|
|
r0 = value;
|
|
} else {
|
|
value = catalogFetchCooldown + 86400000;
|
|
Date = global.Date;
|
|
value = value < Date.now();
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function value_66072(a0) { // fn#66072, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:2049, offset: 0x01bea630, size: 73 bytes, params: 2, frame: 11
|
|
var r0;
|
|
var Date;
|
|
let value = environment.__proto__;
|
|
const unlockedPowerupsFetchCooldown = env1_11[a0]?.unlockedPowerupsFetchCooldown;
|
|
value = unlockedPowerupsFetchCooldown == null;
|
|
if (value) {
|
|
r0 = value;
|
|
} else {
|
|
value = unlockedPowerupsFetchCooldown + 3600000;
|
|
Date = global.Date;
|
|
value = value < Date.now();
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function value_66073(a0) { // fn#66073, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:2197, offset: 0x01bea679, size: 48 bytes, params: 2, frame: 4
|
|
var r0;
|
|
var property;
|
|
let value = a0 != null;
|
|
if (value) {
|
|
value = environment.__proto__;
|
|
property = env1_11[a0];
|
|
value = undefined;
|
|
value = (property == null ? value : property.hasFetchedPowerupCatalog) === true;
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function value_66074(a0) { // fn#66074, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:2329, offset: 0x01bea6a9, size: 48 bytes, params: 2, frame: 4
|
|
var r0;
|
|
var property;
|
|
let value = a0 != null;
|
|
if (value) {
|
|
value = environment.__proto__;
|
|
property = env1_11[a0];
|
|
value = undefined;
|
|
value = (property == null ? value : property.hasFetchedUnlockedPowerups) === true;
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function _fun66077(a0) { // fn#66077, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8443:2635, offset: 0x01bea77c, size: 154 bytes, params: 2, frame: 16
|
|
var r0;
|
|
var r2;
|
|
var r3;
|
|
var item3;
|
|
var value3;
|
|
const iterator = a0[Symbol.iterator]();
|
|
const iterator2 = iterator.next;
|
|
let item2 = Reflect.apply(iterator2, iterator, []);
|
|
let item = item2.value;
|
|
item2 = item2.done ? undefined : iterator;
|
|
const value = undefined;
|
|
const value2 = item2 === value;
|
|
const r1 = value2 ? value : item;
|
|
if (value2) {
|
|
r0 = item2;
|
|
r2 = value2;
|
|
r3 = value;
|
|
} else {
|
|
item3 = Reflect.apply(iterator2, item2, []);
|
|
item = item3.value;
|
|
item3 = item3.done ? undefined : item2;
|
|
value3 = item3 === value;
|
|
if (value3) {
|
|
r0 = item3;
|
|
r2 = value3;
|
|
r3 = value;
|
|
} else {
|
|
r0 = item3;
|
|
r2 = value3;
|
|
r3 = item;
|
|
}
|
|
}
|
|
if (!r2) {
|
|
r0.return();
|
|
}
|
|
const items2 = [r1];
|
|
const object2 = {};
|
|
copyDataProperties(object2, r3, value);
|
|
object2['allPowerups'] = r3.allPowerups ?? ({});
|
|
object2['powerupCatalog'] = r3.powerupCatalog ?? ({});
|
|
object2['unlockedPowerups'] = r3.unlockedPowerups ?? ({});
|
|
items2[1] = object2;
|
|
return items2;
|
|
}
|
|
|