Files
discord-decomp/sources/modules/channel/VoiceChannelAnimationStateStore.tsx
2026-07-28 01:06:53 +03:00

524 lines
21 KiB
TypeScript

/* Metro module 12536; source: modules/channel/VoiceChannelAnimationStateStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 3969, 4297, 566, 694, 2] */
import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */
import PossibleConstructorReturn from '../../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */
import Module00017 from '../../by-id/module-00017.js'; /* Metro dependency 17 */
import Inherits from '../../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
import Flux from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import SelectedGuildStore from '../../stores/SelectedGuildStore.tsx'; /* Metro dependency 3969 */
import VoiceStateStore from '../../stores/VoiceStateStore.tsx'; /* Metro dependency 4297 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
function _fun95804(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#95804, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:6, offset: 0x0214f399, size: 474 bytes, params: 8, frame: 20
const _arrayLikeToArray_95810 = 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 closure = function() {
resetAllState();
return true;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_9 = {};
const env0_10 = {};
const Store = (Flux).Store;
let value = _fun95817(Store);
value.displayName = 'VoiceChannelAnimationStateStore';
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */,
{VOICE_STATE_UPDATES: VOICE_STATE_UPDATES_95822, CHANNEL_SELECT: CHANNEL_SELECT_95823, CONNECTION_OPEN: closure,
LOGOUT: closure});
(FileImportTrackerModule).fileFinishedImporting('modules/channel/VoiceChannelAnimationStateStore.tsx');
exports.default = value;
exports.AnimationStyle = {GENTLE_AMBIENT: 'GENTLE_AMBIENT', GENTLE_AMBIENT_WITH_INTRO: 'GENTLE_AMBIENT_WITH_INTRO',
HIGH_CONTRAST: 'HIGH_CONTRAST'};
function _isNativeReflectConstruct_95805() { // fn#95805, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:180, offset: 0x0214f573, 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_95805_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _createForOfIteratorHelperLoose_95808(a0, a1) { // fn#95808, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:373, offset: 0x0214f5d5, 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 _fun95809;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_95810(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_95810(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_95810(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun95809;
}
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 _fun95809() { // fn#95809, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:944, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return CreateClass >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof CreateClass === 'bigint' ? CreateClass : +CreateClass]};
}
}
function clearAnimationTimer(a0) { // fn#95811, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:1454, offset: 0x0214f749, size: 55 bytes, params: 2, frame: 13
if (env0_10[a0] != null) {
global.clearTimeout(env0_10[a0]);
delete env0_10[a0];
}
}
function scheduleTransitionToGentleAmbient(a0) { // fn#95812, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:1531, offset: 0x0214f780, size: 60 bytes, params: 2, frame: 15
const env0_0 = a0;
clearAnimationTimer(a0);
env0_10[a0] = global.setTimeout(_fun95813, 2000);
function _fun95813() { // fn#95813, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:1617, offset: 0x0214f7bc, size: 97 bytes, params: 1, frame: 16
var binding2;
var object;
let binding = env1_9;
const property = binding[env0_0];
if (property != null) {
binding = env1_9;
binding2 = env0_0;
object = {};
copyDataProperties(object, property, undefined);
object['style'] = env1_8.GENTLE_AMBIENT;
binding[binding2] = object;
binding = env1_12;
binding.emitChange();
}
delete env1_10[env0_0];
}
}
function resetAllState() { // fn#95814, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:1713, offset: 0x0214f81d, size: 90 bytes, params: 1, frame: 16
var object2;
var r3;
var property;
var clearTimeout;
var value4;
const Object = global.Object;
const value2 = Object.keys(object2);
let length = value2.length;
const value3 = 0;
if (value3 < length) {
for (r3 = value3; true; r3 = value4) {
property = value2[r3];
clearTimeout = global.clearTimeout;
clearTimeout(object2[property]);
value4 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1;
length = value2.length;
if (!(value4 < length)) {
break;
}
}
}
object2 = {};
env0_9 = {};
}
function updateChannelAnimationState(a0, a1) { // fn#95815, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:1853, offset: 0x0214f877, size: 248 bytes, params: 3, frame: 19
var r0;
var binding;
var object;
const property = env0_9[a0];
const userCount = property?.userCount;
const value3 = 0;
const r4 = userCount ?? value3;
const Math = global.Math;
const value4 = Math.max(value3, r4 + a1);
if (value3 !== r4) {
if (r4 > value3) {
if (value4 > r4) {
env0_9[a0] = {style: env0_8.HIGH_CONTRAST, userCount: value4};
scheduleTransitionToGentleAmbient(a0);
r0 = true;
} else if (value3 === value4) {
clearAnimationTimer(a0);
delete env0_9[a0];
r0 = true;
} else {
r0 = property != null && value4 !== r4;
if (r0) {
binding = env0_9;
object = {};
copyDataProperties(object, property, Math);
object['userCount'] = value4;
binding[a0] = object;
r0 = true;
}
}
} else if (value3 === value4) {
clearAnimationTimer(a0);
delete env0_9[a0];
r0 = true;
} else {
r0 = property != null && value4 !== r4;
if (r0) {
binding = env0_9;
object = {};
copyDataProperties(object, property, Math);
object['userCount'] = value4;
binding[a0] = object;
r0 = true;
}
}
} else if (value4 > value3) {
env0_9[a0] = {style: env0_8.GENTLE_AMBIENT_WITH_INTRO, userCount: value4};
scheduleTransitionToGentleAmbient(a0);
r0 = true;
} else if (r4 > value3) {
if (value4 > r4) {
env0_9[a0] = {style: env0_8.HIGH_CONTRAST, userCount: value4};
scheduleTransitionToGentleAmbient(a0);
r0 = true;
} else if (value3 === value4) {
clearAnimationTimer(a0);
delete env0_9[a0];
r0 = true;
} else {
r0 = property != null && value4 !== r4;
if (r0) {
binding = env0_9;
object = {};
copyDataProperties(object, property, Math);
object['userCount'] = value4;
binding[a0] = object;
r0 = true;
}
}
} else if (value3 === value4) {
clearAnimationTimer(a0);
delete env0_9[a0];
r0 = true;
} else {
r0 = property != null && value4 !== r4;
if (r0) {
binding = env0_9;
object = {};
copyDataProperties(object, property, Math);
object['userCount'] = value4;
binding[a0] = object;
r0 = true;
}
}
return r0;
}
function _fun95817(a0) { // fn#95817, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:2337, offset: 0x0214f980, size: 124 bytes, params: 2, frame: 16
const VoiceChannelAnimationStateStoreClass2 = VoiceChannelAnimationStateStoreClass;
Inherits(VoiceChannelAnimationStateStoreClass2, a0);
return CreateClass(VoiceChannelAnimationStateStoreClass2, [{key: 'initialize', value: function() {
this.waitFor(VoiceStateStore, SelectedGuildStore);
}}, {key: 'getAnimationStyle', value: value_95820}, {key: 'getUserCount', value: value_95821}]);
function VoiceChannelAnimationStateStoreClass() { // fn#95818, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:2349, offset: 0x01fd662f, size: 113 bytes, params: 1, frame: 20
const value = environment.__proto__;
env1_0(this, VoiceChannelAnimationStateStoreClass);
const value3 = env1_3(VoiceChannelAnimationStateStoreClass);
return env1_2(this, _isNativeReflectConstruct_95805() ? global.Reflect.construct(value3, arguments,
env1_3(this).constructor) : value3.apply(this, arguments));
}
function value_95820(a0) { // fn#95820, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:2809, offset: 0x0214fa1a, size: 46 bytes, params: 2, frame: 5
return env1_9[a0]?.style ?? env1_8.GENTLE_AMBIENT;
}
function value_95821(a0) { // fn#95821, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:2923, offset: 0x0214fa48, size: 45 bytes, params: 2, frame: 4
const value = environment.__proto__;
const userCount = env1_9[a0]?.userCount;
return userCount ?? 0;
}
}
function VOICE_STATE_UPDATES_95822({voiceStates}) { // fn#95822, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:3107, offset: 0x0214fa75, size: 334 bytes, params: 2, frame: 27
var r4;
var r15;
var r14;
var r2;
var r3;
var value8;
var guildId;
var oldChannelId;
var oldChannelId2;
var property;
var channelId;
var channelId2;
var value9;
var value12;
var updateChannelAnimationStateBinding;
var value13;
var value14;
const guildId2 = SelectedGuildStore.getGuildId();
let r0 = guildId2 !== env0_11 && guildId2 != null;
if (r0) {
}
const object = {};
const value5 = _createForOfIteratorHelperLoose_95808(voiceStates);
const value6 = value5();
let done = value6.done;
if (!done) {
r4 = value6;
while (true) {
value8 = r4.value;
guildId = value8.guildId;
if (guildId === guildId2) {
oldChannelId = value8.oldChannelId;
if (oldChannelId == null) {
continue;
}
oldChannelId = value8.oldChannelId;
oldChannelId2 = value8.oldChannelId;
property = object[oldChannelId2];
if (property != null) {
r15 = property;
continue;
}
r15 = 0;
continue;
object[oldChannelId] = r15 - 1;
channelId = value8.channelId;
if (channelId == null) {
break;
}
channelId = value8.channelId;
channelId2 = value8.channelId;
property = object[channelId2];
if (property != null) {
r14 = property;
continue;
}
r14 = 0;
continue;
object[channelId] = r14 + 1;
break;
}
value9 = value5();
done = value9.done;
if (done) {
break;
}
r4 = value9;
continue;
}
}
const Object = global.Object;
const value10 = Object.entries(object);
let length = value10.length;
if (0 < length) {
r2 = 0;
r3 = false;
while (true) {
property = value10[r2];
value12 = Module00057(property, 2);
updateChannelAnimationStateBinding = updateChannelAnimationState;
property = value12[0];
if (updateChannelAnimationStateBinding(property, value12[1])) {
value13 = true;
r3 = value13;
}
value14 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
length = value10.length;
if (value14 < length) {
r2 = value14;
continue;
}
r0 = r3;
break;
}
} else {
r0 = false;
}
return r0;
}
function CHANNEL_SELECT_95823({guildId}) { // fn#95823, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12726:3601, offset: 0x0214fbc3, size: 276 bytes, params: 2, frame: 23
var r8;
var r11;
var r1;
var property;
var channelId;
var channelId2;
var value5;
var value7;
var property2;
var binding;
var GENTLE_AMBIENT;
var value8;
if (guildId === env0_11) {
return false;
}
if (guildId == null) {
return false;
}
resetAllState();
const voiceStates = VoiceStateStore.getVoiceStates(guildId);
const object = {};
let Object = global.Object;
const value3 = Object.values(voiceStates);
let length = value3.length;
if (0 < length) {
r8 = 0;
while (true) {
property = value3[r8];
channelId = property.channelId;
if (channelId != null) {
channelId = property.channelId;
channelId2 = property.channelId;
property = object[channelId2];
if (property != null) {
r11 = property;
continue;
}
r11 = 0;
continue;
object[channelId] = r11 + 1;
}
value5 = typeof r8 === 'bigint' ? r8 + 1n : +r8 + 1;
length = value3.length;
if (value5 < length) {
r8 = value5;
continue;
}
break;
}
}
Object = global.Object;
const value6 = Object.entries(object);
length = value6.length;
if (0 < length) {
r1 = 0;
while (true) {
property = value6[r1];
value7 = Module00057(property, 2);
property = value7[0];
property2 = value7[1];
if (property2 > 0) {
binding = env0_9;
GENTLE_AMBIENT = env0_8.GENTLE_AMBIENT;
binding[property] = {style: GENTLE_AMBIENT, userCount: property2};
}
value8 = typeof r1 === 'bigint' ? r1 + 1n : +r1 + 1;
length = value6.length;
if (value8 < length) {
r1 = value8;
continue;
}
break;
}
}
return true;
}
}
global.__d(_fun95804, 12536, [6, 7, 15, 17, 18, 57, 3969, 4297, 566, 694,
2]) /* metro module 12536, dependencies: [6, 7, 15, 17, 18, 57, 3969, 4297, 566, 694, 2] */;