Files
discord-decomp/sources/modules/premium/powerups/hooks/useBoostToUnlockFeaturedPowerup.tsx
T
2026-07-28 01:06:53 +03:00

277 lines
14 KiB
TypeScript

/* Metro module 14613; source: modules/premium/powerups/hooks/useBoostToUnlockFeaturedPowerup.tsx; dependencies: [57, 31, 1867, 8258, 8259, 661, 8188, 566, 8254, 14614, 2] */
import Module00057 from '../../../../by-id/module-00057.js'; /* Metro dependency 57 */
import GuildStore from '../../../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import UseGuildPowerupsBoostCount from './useGuildPowerupsBoostCount.tsx'; /* Metro dependency 8254 */
import GuildPowerupsStore from '../GuildPowerupsStore.tsx'; /* Metro dependency 8258 */
import * as FileImportTrackerModule from '../../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactModule from '../../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as FluxModule from '../../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as ConstantsModule from '../../../../Constants.tsx'; /* Metro dependency 661 */
import * as PowerupsModule from '../../../../external/discord_common/js/shared/shared-constants/Powerups.tsx'; /* Metro dependency 8188 */
import * as GuildPowerupsConstantsModule from '../constants/GuildPowerupsConstants.tsx'; /* Metro dependency 8259 */
import * as BoostToUnlockCoachmarkExperimentModule from '../experiments/BoostToUnlockCoachmarkExperiment.tsx'; /* Metro dependency 14614 */
function _fun110499(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#110499, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14810:6, offset: 0x0237b3ab, size: 456 bytes, params: 8, frame: 21
const env0_0 = require;
const _arrayLikeToArray_110502 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const GUILD_POWERUP_LEVEL_1_SKU_ID = (PowerupsModule).GUILD_POWERUP_LEVEL_1_SKU_ID;
const items2 = [{skuId: GUILD_POWERUP_LEVEL_1_SKU_ID, threshold: 1}];
const GUILD_POWERUP_LEVEL_2_SKU_ID = (PowerupsModule).GUILD_POWERUP_LEVEL_2_SKU_ID;
items2[1] = {skuId: GUILD_POWERUP_LEVEL_2_SKU_ID, threshold: 2};
const GUILD_POWERUP_LEVEL_3_SKU_ID = (PowerupsModule).GUILD_POWERUP_LEVEL_3_SKU_ID;
items2[2] = {skuId: GUILD_POWERUP_LEVEL_3_SKU_ID, threshold: 2};
const GUILD_POWERUP_TAG_SKU_ID = (PowerupsModule).GUILD_POWERUP_TAG_SKU_ID;
items2[3] = {skuId: GUILD_POWERUP_TAG_SKU_ID, threshold: 1};
const GUILD_POWERUP_ROLE_COLOR_SKU_ID = (PowerupsModule).GUILD_POWERUP_ROLE_COLOR_SKU_ID;
items2[4] = {skuId: GUILD_POWERUP_ROLE_COLOR_SKU_ID, threshold: 1};
const GUILD_TAGS_BADGE_PACK_FLEX_POWERUP_SKU_ID = (PowerupsModule).GUILD_TAGS_BADGE_PACK_FLEX_POWERUP_SKU_ID;
items2[5] = {skuId: GUILD_TAGS_BADGE_PACK_FLEX_POWERUP_SKU_ID, threshold: 1};
const GUILD_TAGS_BADGE_PACK_PETS_POWERUP_SKU_ID = (PowerupsModule).GUILD_TAGS_BADGE_PACK_PETS_POWERUP_SKU_ID;
items2[6] = {skuId: GUILD_TAGS_BADGE_PACK_PETS_POWERUP_SKU_ID, threshold: 1};
(FileImportTrackerModule).fileFinishedImporting('modules/premium/powerups/hooks/useBoostToUnlockFeaturedPowerup.tsx');
exports.default = useBoostToUnlockFeaturedPowerup;
function _createForOfIteratorHelperLoose_110500(a0, a1) { // fn#110500, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14810:214, offset: 0x0237b573, size: 372 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun110501;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_110502(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_110502(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_110502(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun110501;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun110501() { // fn#110501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14810:785, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function useBoostToUnlockFeaturedPowerup(a0) { // fn#110503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14810:1676, offset: 0x0237b6e7, size: 263 bytes, params: 2, frame: 20
const env0_0 = a0;
const stateForGuild = (FluxModule).useStateFromStores([GuildPowerupsStore],
_fun110504);
const available = (UseGuildPowerupsBoostCount)(a0).available;
const value2 = (FluxModule).useStateFromStores([GuildStore], _fun110505);
const env0_3 = value2;
const value3 = (BoostToUnlockCoachmarkExperimentModule).useBoostToUnlockCoachmarkEnabled('useBoostToUnlockFeaturedPowerup');
const binding = value3;
return binding.useMemo(_fun110507, [stateForGuild, available, value2, value3, env0_3(binding.useState(function() {
var Math = global.Math;
return Math.random();
}), 1)[0]]);
function _fun110504() { // fn#110504, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14810:1759, offset: 0x02379d82, size: 27 bytes, params: 1, frame: 11
return GuildPowerupsStore.getStateForGuild(env0_0);
}
function _fun110505() { // fn#110505, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14810:1845, offset: 0x0237b7ee, size: 70 bytes, params: 1, frame: 12
const value = environment.__proto__;
const guild = GuildStore.getGuild(env0_0);
return (guild == null ? undefined : guild.features.has(GuildFeatures.PREMIUM_TIER_3_OVERRIDE)) === true;
}
function _fun110507() { // fn#110507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14810:2088, offset: 0x0237b834, size: 303 bytes, params: 1, frame: 26
var environment;
var r5;
var r14;
var allPowerups;
var unlockedPowerups;
var items2;
var value2;
var value3;
var value4;
var done;
var value5;
var skuId;
var threshold;
var property;
var has;
var dependencies;
var every;
var cost;
var value6;
var value7;
var value8;
var push;
var value9;
var length;
var Math;
let stateForGuildBinding = stateForGuild;
if (stateForGuildBinding != null) {
reducibleJoin14: while (true) {
if (ReactModule) {
stateForGuildBinding = stateForGuild;
allPowerups = stateForGuildBinding.allPowerups;
unlockedPowerups = stateForGuildBinding.unlockedPowerups;
var env0_0 = unlockedPowerups;
items2 = [];
value2 = environment.__proto__;
value3 = _createForOfIteratorHelperLoose_110500(env1_9);
value4 = value3();
done = value4.done;
if (!done) {
r5 = value4;
reducibleLoop3: while (true) {
value5 = r5.value;
skuId = value5.skuId;
threshold = value5.threshold;
property = allPowerups[skuId];
reducibleJoin12: while (true) {
if (property == null) {
break reducibleJoin12;
}
if (env0_3) {
has = GUILD_POWERUP_TIER_3_OVERRIDDEN_SKUS.has;
if (Reflect.apply(has, GUILD_POWERUP_TIER_3_OVERRIDDEN_SKUS, [skuId])) {
break reducibleJoin12;
}
}
if (unlockedPowerups[skuId] != null) {
break reducibleJoin12;
}
dependencies = property.dependencies;
every = dependencies.every;
if (Reflect.apply(every, dependencies, [function(a0) {
return unlockedPowerups[a0] != null;
}])) {
cost = property.cost;
value6 = cost - available;
value7 = value6 > 0;
reducibleJoin10: while (true) {
if (value7) {
value8 = value6 <= threshold;
r14 = value8;
break reducibleJoin10;
}
r14 = value7;
break reducibleJoin10;
}
if (r14) {
push = items2.push;
Reflect.apply(push, items2, [property]);
break reducibleJoin12;
}
break reducibleJoin12;
}
break reducibleJoin12;
}
value9 = value3();
done = value9.done;
if (done) {
break reducibleLoop3;
}
r5 = value9;
continue reducibleLoop3;
}
}
length = items2.length;
if (length > 0) {
Math = global.Math;
return items2[Math.floor(env0_5 * items2.length)];
}
break reducibleJoin14;
}
break reducibleJoin14;
}
}
}
}
}
global.__d(_fun110499, 14613, [57, 31, 1867, 8258, 8259, 661, 8188, 566, 8254, 14614,
2]) /* metro module 14613, dependencies: [57, 31, 1867, 8258, 8259, 661, 8188, 566, 8254, 14614, 2] */;