Files
2026-07-28 01:06:53 +03:00

598 lines
25 KiB
TypeScript

/* Metro module 1867; source: stores/GuildStore.tsx; dependencies: [6, 7, 15, 17, 18, 1419, 1868, 1422, 1226, 661, 1417, 1421, 21, 1418, 1870, 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 SnowflakeUtils from '../utils/SnowflakeUtils.tsx'; /* Metro dependency 21 */
import AuthenticationStore from './AuthenticationStore.tsx'; /* Metro dependency 1226 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */
import * as FavoritesConstantsModule from '../modules/favorites/FavoritesConstants.tsx'; /* Metro dependency 1417 */
import * as PlainRecordModule from '../lib/PlainRecord.tsx'; /* Metro dependency 1419 */
import * as LibdiscoreStoreModule from '../modules/libdiscore/stores/LibdiscoreStore.tsx'; /* Metro dependency 1868 */
import * as LibdiscoreExperimentsModule from '../modules/libdiscore/libdiscoreExperiments.tsx'; /* Metro dependency 1870 */
function _fun20067(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#20067, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:6, offset: 0x00ebdd1d, size: 593 bytes, params: 8, frame: 19
const env0_0 = require;
const _arrayLikeToArray_20070 = 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});
let value = PlainRecordModule;
const env0_9 = value.constructInPlace;
const env0_10 = value.set;
const LibdiscoreStore = (LibdiscoreStoreModule).LibdiscoreStore;
value = require(1422) /* metro dependency 1422: GuildRecord */;
const env0_11 = value.GuildRecordTypeTag;
const env0_12 = value.updateJoinedAt;
const env0_13 = value.updateGameApplications;
_fun20076(LibdiscoreStore).displayName = 'GuildStore';
object = {BACKGROUND_SYNC: BACKGROUND_SYNC_20084, LOGOUT: function(a0, a1) {
a1.clear();
}, RESET_SOCKET: function(a0, a1) {
a1.clear();
}, CONNECTION_OPEN: CONNECTION_OPEN_20087, OVERLAY_INITIALIZE: OVERLAY_INITIALIZE_20088,
CACHE_LOADED: function({guilds}, a1) {
var r2;
var id;
var moduleValue;
var value4;
a1.clear();
var value2 = _createForOfIteratorHelperLoose_20068(guilds);
var value3 = value2();
if (!value3.done) {
for (r2 = value3; true; r2 = value4) {
guilds = r2.value;
id = guilds.id;
moduleValue = importAll(dependencyMap[13]);
a1.set(id, moduleValue.fromSerializedGuildRecord(guilds));
value4 = value2();
if (value4.done) {
break;
}
}
}
}, CACHE_LOADED_LAZY: CACHE_LOADED_LAZY_20090, GUILD_CREATE: GUILD_CREATE_20091, GUILD_UPDATE: function({guild},
a1) {
a1.set(guild.id, importAll(dependencyMap[13]).fromGuild(guild, a1.get(guild.id)));
}, GUILD_THEME_PREVIEW_SAVE_SUCCESS: function({guildId, guildTheme}, a1) {
updateGuildTheme(a1, guildId, guildTheme);
}, GUILD_SETTINGS_GUILD_THEME_SAVE_SUCCESS: function({guildId, guildTheme}, a1) {
updateGuildTheme(a1, guildId, guildTheme);
}, GUILD_DELETE: function({guild}, a1) {
if (!guild.unavailable) {
a1.remove(guild.id);
}
}, GUILD_MEMBER_ADD: GUILD_MEMBER_ADD,
GUILD_OFFICIAL_GAME_APPLICATIONS_UPDATE: GUILD_OFFICIAL_GAME_APPLICATIONS_UPDATE};
const LibdiscoreBatchStoreRefactorExperiment = (LibdiscoreExperimentsModule).LibdiscoreBatchStoreRefactorExperiment;
value = new value(object, LibdiscoreBatchStoreRefactorExperiment.getCachedBridgedStoreMode());
(FileImportTrackerModule).fileFinishedImporting('stores/GuildStore.tsx');
exports.default = value;
function _createForOfIteratorHelperLoose_20068(a0, a1) { // fn#20068, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:363, offset: 0x00ebdf6e, size: 370 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 _fun20069;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_20070(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_20070(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_20070(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun20069;
}
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 _fun20069() { // fn#20069, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:934, 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 _isNativeReflectConstruct_20071() { // fn#20071, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:1273, offset: 0x00ebe0e0, size: 94 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_20071_isNativeReflectConstruct = function() {
return !!result;
})();
}
function createGuildRecordFromRust(a0) { // fn#20074, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:1466, offset: 0x00ebe13e, size: 200 bytes, params: 2, frame: 19
var r7;
var date;
var value;
const constructInPlaceBinding = constructInPlace;
const object = {};
copyDataProperties(object, a0, undefined);
value = Reflect.apply((require(1421) /* metro dependency 1421: SetUtils */).toSetInplace, value, [a0.features]);
object['features'] = value;
const joinedAt = a0.joinedAt;
value = null;
if (value != joinedAt) {
date = new global.Date(a0.joinedAt);
} else {
r7 = value;
}
object['joinedAt'] = r7;
object['premiumProgressBarEnabledUserUpdatedAt'] = value != a0.premiumProgressBarEnabledUserUpdatedAt ? new global.Date(a0.premiumProgressBarEnabledUserUpdatedAt) : value;
return constructInPlaceBinding(GuildRecordTypeTag, object);
}
function updateGuildTheme(a0, a1, a2) { // fn#20075, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:1769, offset: 0x00ebe206, size: 60 bytes, params: 4, frame: 18
const value = a0.get(a1);
if (value != null) {
a0.set(a1, set(value, 'guildTheme', a2));
}
}
function _fun20076(a0) { // fn#20076, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:1861, offset: 0x00ebe242, size: 93 bytes, params: 2, frame: 16
const GuildStore2 = GuildStore;
Inherits(GuildStore2, a0);
return CreateClass(GuildStore2, [{key: 'stateWrapper', value: function() {
return this.database;
}}, {key: 'getGuildCount', value: function() {
return this.database.length();
}}]);
function GuildStore(a0) { // fn#20077, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:1873, offset: 0x00ebe29f, size: 253 bytes, params: 2, frame: 21
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_4;
binding(this, GuildStore);
const items2 = [];
arraySpread(items2, value, 0, items2);
value = env1_7(GuildStore);
binding = env1_6;
if (_isNativeReflectConstruct_20071()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items2, env1_7(this).constructor);
r0 = value;
} else {
value = value.apply(this, items2);
r0 = value;
}
value = binding(this, r0);
value.database = value.addKVDatabase('guilds', createGuildRecordFromRust);
value.getGuild = getGuild;
value.getGuilds = value.database.memoized(function(a0) {
var r1;
var object = {};
copyDataProperties(object, a0, r1);
return object;
});
value.getGuildsArray = value.database.memoized(function(a0) {
var Object = global.Object;
return Object.values(a0);
});
value.getGuildIds = value.database.memoized(_fun20081);
return value;
function getGuild(a0) { // fn#20078, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:2163, owner: GuildStore.getGuild, offset: 0x00ebe39c, size: 55 bytes, params: 2, frame: 12
var value;
if (a0 != null) {
value = environment.__proto__.__proto__;
return a0 === FAVORITES ? FAVORITES_GUILD_RECORD : env0_0.database.get(a0);
}
}
function _fun20081(a0) { // fn#20081, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:2354, offset: 0x00ebe3ea, size: 40 bytes, params: 2, frame: 11
const value = environment.__proto__.__proto__;
return (SnowflakeUtils).keys(a0);
}
}
}
function BACKGROUND_SYNC_20084({guilds}, a1) { // fn#20084, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:2607, offset: 0x00ebe431, size: 149 bytes, params: 3, frame: 23
var r2;
var r1;
var value4;
var get;
var id;
var value5;
var value6;
var data_mode;
var value7;
var set;
var moduleValue;
var fromBackgroundSync;
var value8;
const value2 = _createForOfIteratorHelperLoose_20068(guilds);
const value3 = value2();
let done = value3.done;
if (!done) {
r2 = value3;
while (true) {
value4 = r2.value;
get = a1.get;
id = value4.id;
value5 = Reflect.apply(get, a1, [id]);
value6 = value5 != null;
if (value6) {
data_mode = value4.data_mode;
value7 = data_mode !== 'unavailable';
r1 = value7;
} else {
r1 = value6;
}
if (!r1) {
continue;
}
set = a1.set;
id = value4.id;
moduleValue = importAll(1418) /* metro dependency 1418: GuildRecordUtils */;
fromBackgroundSync = moduleValue.fromBackgroundSync;
Reflect.apply(set, a1, [id, Reflect.apply(fromBackgroundSync, moduleValue, [value4, value5])]);
value8 = value2();
done = value8.done;
if (done) {
break;
}
r2 = value8;
continue;
}
}
}
function CONNECTION_OPEN_20087({guilds, unavailableGuilds}, a1) { // fn#20087, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:2875, offset: 0x00ebe4d7, size: 361 bytes, params: 3, frame: 26
var r7;
var r5;
var r2;
var value8;
var id;
var properties;
var moduleValue;
var fromServer;
var id2;
var value9;
var value11;
var value12;
var value14;
var remove;
var value15;
let value = a1.getAllRecords();
const Set = global.Set;
const Object = global.Object;
let set = new Set(Object.keys(value));
const value6 = _createForOfIteratorHelperLoose_20068(guilds);
const value7 = value6();
let done = value7.done;
if (!done) {
r7 = value7;
reducibleLoop1: while (true) {
value8 = r7.value;
id = value8.id;
set.delete(id);
properties = value8.properties;
if (properties == null) {
reducibleJoin3: while (true) {
if (value[value8.id] == null) {
throw new global.Error('Guild data was missing from store, but hash was still available.');
}
break reducibleJoin3;
}
}
set = a1.set;
id = value8.id;
moduleValue = importAll(1418) /* metro dependency 1418: GuildRecordUtils */;
fromServer = moduleValue.fromServer;
id2 = value8.id;
Reflect.apply(set, a1, [id, Reflect.apply(fromServer, moduleValue, [value8, value[id2]])]);
value9 = value6();
done = value9.done;
if (done) {
break reducibleLoop1;
}
r7 = value9;
continue reducibleLoop1;
}
}
value = _createForOfIteratorHelperLoose_20068(unavailableGuilds);
const value10 = value();
done = value10.done;
if (!done) {
r5 = value10;
reducibleLoop6: while (true) {
value11 = r5.value;
set.delete(value11);
value12 = value();
done = value12.done;
if (done) {
break reducibleLoop6;
}
r5 = value12;
continue reducibleLoop6;
}
}
value = _createForOfIteratorHelperLoose_20068(set);
const value13 = value();
done = value13.done;
if (!done) {
r2 = value13;
reducibleLoop8: while (true) {
value14 = r2.value;
remove = a1.remove;
Reflect.apply(remove, a1, [value14]);
value15 = value();
done = value15.done;
if (done) {
break reducibleLoop8;
}
r2 = value15;
continue reducibleLoop8;
}
}
}
function OVERLAY_INITIALIZE_20088({guilds}, a1) { // fn#20088, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:3414, offset: 0x00ebe640, size: 216 bytes, params: 3, frame: 28
var r1;
var r15;
var value3;
var value4;
var done;
var value5;
var properties;
var additionalFields;
var set;
var id;
var moduleValue;
var fromGuildPropertiesWithAdditionalFields;
var joinedAt;
var Date;
var prototype;
var value6;
var date;
var value7;
var premiumSubscriberCount;
var value8;
a1.clear();
if (guilds != null) {
value3 = _createForOfIteratorHelperLoose_20068(guilds);
value4 = value3();
done = value4.done;
if (!done) {
r1 = value4;
while (true) {
value5 = r1.value;
properties = value5.properties;
additionalFields = value5.additionalFields;
set = a1.set;
id = properties.id;
moduleValue = importAll(1418) /* metro dependency 1418: GuildRecordUtils */;
fromGuildPropertiesWithAdditionalFields = moduleValue.fromGuildPropertiesWithAdditionalFields;
joinedAt = additionalFields.joinedAt;
if (joinedAt != null) {
Date = global.Date;
joinedAt = additionalFields.joinedAt;
prototype = Date.prototype;
value6 = Object.create(prototype, {constructor: {value: Date}});
date = new Date();
value7 = date instanceof Object ? date : value6;
r15 = value7;
} else {
r15 = null;
}
premiumSubscriberCount = additionalFields.premiumSubscriberCount;
Reflect.apply(set, a1, [id, Reflect.apply(fromGuildPropertiesWithAdditionalFields, moduleValue,
[properties,
{joinedAt: r15, premiumSubscriberCount: premiumSubscriberCount}])]);
value8 = value3();
done = value8.done;
if (done) {
break;
}
r1 = value8;
continue;
}
}
}
}
function CACHE_LOADED_LAZY_20090({guilds}, a1) { // fn#20090, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:3922, offset: 0x00ebe78d, size: 130 bytes, params: 3, frame: 20
var r1;
var clear;
var value;
var value2;
var value3;
var done;
var value4;
var set;
var id;
var moduleValue;
var fromSerializedGuildRecord;
var value5;
reducibleJoin3: while (true) {
if (guilds.length === 0) {
break reducibleJoin3;
}
clear = a1.clear;
Reflect.apply(clear, a1, []);
value = environment;
value2 = _createForOfIteratorHelperLoose_20068(guilds);
value3 = value2();
done = value3.done;
if (done) {
break reducibleJoin3;
}
r1 = value3;
reducibleLoop2: while (true) {
value4 = r1.value;
set = a1.set;
id = value4.id;
moduleValue = importAll(1418) /* metro dependency 1418: GuildRecordUtils */;
fromSerializedGuildRecord = moduleValue.fromSerializedGuildRecord;
Reflect.apply(set, a1, [id, Reflect.apply(fromSerializedGuildRecord, moduleValue, [value4])]);
value5 = value2();
done = value5.done;
if (done) {
break reducibleJoin3;
}
r1 = value5;
continue reducibleLoop2;
}
}
}
function GUILD_CREATE_20091({guild}, a1) { // fn#20091, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:4110, offset: 0x00ebe80f, size: 133 bytes, params: 3, frame: 17
var set;
var moduleValue;
const get = a1.get;
let id = guild.id;
const value = Reflect.apply(get, a1, [id]);
if (guild.properties != null) {
set = a1.set;
id = guild.id;
moduleValue = importAll(1418) /* metro dependency 1418: GuildRecordUtils */;
Reflect.apply(set, a1, [id, moduleValue.fromServer(guild, value)]);
} else {
if (value == null) {
throw new global.Error('Guild data was missing from store, but hash was still available.');
}
set = a1.set;
id = guild.id;
moduleValue = importAll(1418) /* metro dependency 1418: GuildRecordUtils */;
Reflect.apply(set, a1, [id, moduleValue.fromServer(guild, value)]);
}
}
function GUILD_MEMBER_ADD({guildId, joinedAt, user}, a1) { // fn#20096, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:4645, offset: 0x00ebe930, size: 156 bytes, params: 3, frame: 18
var r5;
var date;
const id = AuthenticationStore.getId();
const value3 = a1.get(guildId);
if (id === user.id) {
if (value3 != null) {
if (typeof joinedAt !== 'string') {
r5 = joinedAt;
} else {
date = new global.Date(joinedAt);
}
joinedAt = value3.joinedAt;
if (r5 !== joinedAt && r5 != null) {
a1.set(guildId, updateJoinedAt(value3, r5));
}
}
}
}
function GUILD_OFFICIAL_GAME_APPLICATIONS_UPDATE({guildId, gameApplicationIds}, a1) { // fn#20097, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1994:4852, offset: 0x00ebe9cc, size: 63 bytes, params: 3, frame: 16
const value = a1.get(guildId);
if (value != null) {
a1.set(guildId, updateGameApplications(value, gameApplicationIds));
}
}
}
global.__d(_fun20067, 1867, [6, 7, 15, 17, 18, 1419, 1868, 1422, 1226, 661, 1417, 1421, 21, 1418, 1870,
2]) /* metro module 1867, dependencies: [6, 7, 15, 17, 18, 1419, 1868, 1422, 1226, 661, 1417, 1421, 21, 1418, 1870, 2] */;