Files
discord-decomp/sources/stores/LibraryApplicationStore.tsx
T
2026-07-27 16:20:00 +03:00

564 lines
24 KiB
TypeScript

/* Metro module 4270; source: stores/LibraryApplicationStore.tsx; dependencies: [6, 7, 15, 17, 18, 4271, 1226, 661, 587, 4278, 1391, 22, 566, 694, 2] */
function _fun36148(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#36148, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:6, offset: 0x01083f08, size: 567 bytes, params: 8, frame: 21
const env0_0 = require;
const _arrayLikeToArray_36154 = 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 = LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_4 = importDefault(6) /* metro dependency 6 */;
const env0_5 = importDefault(7) /* metro dependency 7 */;
const env0_6 = importDefault(15) /* metro dependency 15 */;
const env0_7 = importDefault(17) /* metro dependency 17 */;
const env0_8 = importDefault(18) /* metro dependency 18 */;
const libraryApplicationRecord = importDefault(4271) /* metro dependency 4271: LibraryApplicationRecord */;
const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const env0_11 = (require(661) /* metro dependency 661: Constants */).LibraryApplicationFlags;
let env0_14 = {};
let env0_15 = {};
const Set = global.Set;
let set = new Set();
const env0_17 = {};
const env0_18 = {};
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
_fun36162(Store).displayName = 'LibraryApplicationStore';
set = new set(importDefault(694) /* metro dependency 694: Dispatcher */, {LOGOUT: function() {
env0_13 = false;
}, LIBRARY_FETCH_SUCCESS: function({libraryApplications}) {
env0_14 = {};
setLibraryApplications(libraryApplications);
env0_13 = true;
}, SKU_PURCHASE_SUCCESS: function({libraryApplications}) {
setLibraryApplications(libraryApplications);
}, LIBRARY_APPLICATION_FLAGS_UPDATE_START: LIBRARY_APPLICATION_FLAGS_UPDATE_START,
LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: closure, LIBRARY_APPLICATION_UPDATE: closure,
LIBRARY_APPLICATION_ACTIVE_LAUNCH_OPTION_UPDATE: LIBRARY_APPLICATION_ACTIVE_LAUNCH_OPTION_UPDATE,
LIBRARY_APPLICATION_ACTIVE_BRANCH_UPDATE: LIBRARY_APPLICATION_ACTIVE_BRANCH_UPDATE,
LIBRARY_APPLICATIONS_TEST_MODE_ENABLED: LIBRARY_APPLICATIONS_TEST_MODE_ENABLED,
DEVELOPER_TEST_MODE_RESET: function() {
env0_15 = {};
}});
(require(2) /* metro dependency 2 */).fileFinishedImporting('stores/LibraryApplicationStore.tsx');
exports.default = set;
}
function _isNativeReflectConstruct_36149() { // fn#36149, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:205, offset: 0x0108413f, 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_36149_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _createForOfIteratorHelperLoose_36152(a0, a1) { // fn#36152, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:398, offset: 0x0108419d, 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 _fun36153;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_36154(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_36154(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_36154(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun36153;
}
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 getSavedData() { // fn#36155, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:1340, offset: 0x0108430f, size: 55 bytes, params: 1, frame: 12
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
return Storage.get(env0_12) ?? ({});
}
function saveActiveLaunchOptionIds() { // fn#36156, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:1460, offset: 0x01084346, size: 78 bytes, params: 1, frame: 16
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
const set = Storage.set;
const binding = env0_12;
const object2 = {};
const getSavedDataBinding = getSavedData;
copyDataProperties(object2, getSavedDataBinding(), getSavedDataBinding);
object2['activeLaunchOptionIds'] = env0_18;
Reflect.apply(set, Storage, [binding, object2]);
}
function saveActiveLibraryApplicationBranchIds() { // fn#36157, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:1565, offset: 0x01084394, size: 78 bytes, params: 1, frame: 16
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
const set = Storage.set;
const binding = env0_12;
const object2 = {};
const getSavedDataBinding = getSavedData;
copyDataProperties(object2, getSavedDataBinding(), getSavedDataBinding);
object2['activeLibraryApplicationBranchIds'] = env0_17;
Reflect.apply(set, Storage, [binding, object2]);
}
function setLibraryApplications(a0) { // fn#36158, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:1694, offset: 0x010843e2, size: 117 bytes, params: 2, frame: 19
var r2;
var value4;
var fromServer;
var moduleValue;
var getComboId;
var id;
var branchId;
var value5;
var value6;
const value2 = _createForOfIteratorHelperLoose_36152(a0);
const value3 = value2();
let done = value3.done;
if (!done) {
for (r2 = value3; true; r2 = value6) {
value4 = r2.value;
fromServer = LibraryApplicationRecord.createFromServer(value4);
moduleValue = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
getComboId = moduleValue.getComboId;
id = fromServer.id;
branchId = fromServer.branchId;
value5 = Reflect.apply(getComboId, moduleValue, [id, branchId]);
env0_14[value5] = fromServer;
value6 = value2();
done = value6.done;
if (done) {
break;
}
}
}
}
function LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS({libraryApplication}) { // fn#36159, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:1877, offset: 0x01084457, size: 96 bytes, params: 2, frame: 16
const fromServer = LibraryApplicationRecord.createFromServer(libraryApplication);
const comboId = (require(4278) /* metro dependency 4278: LibraryApplicationUtils */).getComboId(fromServer.id,
fromServer.branchId);
env0_14[comboId] = fromServer;
env0_16.delete(comboId);
}
function _getLibraryApplication(a0, a1) { // fn#36160, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:2027, offset: 0x010844b7, size: 67 bytes, params: 3, frame: 14
const comboId = (require(4278) /* metro dependency 4278: LibraryApplicationUtils */).getComboId(a0, a1);
return env0_14[comboId] ?? env0_15[comboId];
}
function _getAllLibraryApplications() { // fn#36161, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:2126, offset: 0x010844fa, size: 29 bytes, params: 1, frame: 12
const object2 = {};
copyDataProperties(object2, env0_14, copyDataProperties(object2, env0_15, undefined));
return object2;
}
function _fun36162(a0) { // fn#36162, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:2188, offset: 0x01084517, size: 360 bytes, params: 2, frame: 16
const closure = LibraryApplicationStore;
env0_8(closure, a0);
return env0_5(closure, [{key: 'initialize', value: value_36164}, {key: 'libraryApplications', get: function() {
return _fun36166(_fun36168);
}}, {key: 'getAllLibraryApplications', value: function() {
return _getAllLibraryApplications();
}}, {key: 'hasLibraryApplication', value: function() {
var property = global.Object;
property = property.keys(_getAllLibraryApplications()).length;
return property > 0;
}}, {key: 'hasApplication', value: value_36171}, {key: 'getLibraryApplication', value: value_36172},
{key: 'getActiveLibraryApplication', value: value_36173}, {key: 'isUpdatingFlags', value: value_36174},
{key: 'getActiveLaunchOptionId', value: value_36175}, {key: 'fetched', get: get_36176},
{key: 'entitledBranchIds', get: get_36177}, {key: 'hasRemovedLibraryApplicationThisSession', get: get_36180},
{key: 'whenInitialized', value: function(a0) {
var env0_0 = a0;
this.addConditionalChangeListener(_fun36182);
}}]);
}
function LIBRARY_APPLICATION_FLAGS_UPDATE_START({applicationId, branchId, flags}) { // fn#36186, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:4892, offset: 0x01084afc, size: 158 bytes, params: 2, frame: 17
var moduleValue2;
const comboId = (require(4278) /* metro dependency 4278: LibraryApplicationUtils */).getComboId(applicationId,
branchId);
const value3 = _getLibraryApplication(applicationId, branchId);
let r2 = value3 != null && !value3.isHidden();
if (r2) {
moduleValue2 = importAll(1391) /* metro dependency 1391: FlagUtils */;
r2 = moduleValue2.hasFlag(flags, LibraryApplicationFlags.HIDDEN);
}
if (r2) {
}
env0_16.add(comboId);
}
function LIBRARY_APPLICATION_ACTIVE_LAUNCH_OPTION_UPDATE({applicationId, branchId, launchOptionId}) { // fn#36187, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:5273, offset: 0x01084b9a, size: 77 bytes, params: 2, frame: 17
const binding = env0_18;
const libraryApplicationUtilsModule = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
const getComboId = libraryApplicationUtilsModule.getComboId;
binding[Reflect.apply(getComboId, libraryApplicationUtilsModule, [applicationId, branchId])] = launchOptionId;
saveActiveLaunchOptionIds();
}
function LIBRARY_APPLICATION_ACTIVE_BRANCH_UPDATE({applicationId, branchId}) { // fn#36188, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:5462, offset: 0x01084be7, size: 53 bytes, params: 2, frame: 11
if (env0_17[applicationId] === branchId) {
return false;
}
env0_17[applicationId] = branchId;
saveActiveLibraryApplicationBranchIds();
}
function LIBRARY_APPLICATIONS_TEST_MODE_ENABLED({libraryApplications}) { // fn#36189, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:5634, offset: 0x01084c1c, size: 108 bytes, params: 2, frame: 19
var r2;
var value4;
var moduleValue;
var getComboId;
var id;
var branchId;
var value5;
var value6;
const value2 = _createForOfIteratorHelperLoose_36152(libraryApplications);
const value3 = value2();
let done = value3.done;
if (!done) {
for (r2 = value3; true; r2 = value6) {
value4 = r2.value;
moduleValue = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
getComboId = moduleValue.getComboId;
id = value4.id;
branchId = value4.branchId;
value5 = Reflect.apply(getComboId, moduleValue, [id, branchId]);
env0_15[value5] = value4;
value6 = value2();
done = value6.done;
if (done) {
break;
}
}
}
}
function value_36164() { // fn#36164, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:2533, offset: 0x0108467f, size: 131 bytes, params: 1, frame: 13
var activeLaunchOptionIds;
var activeLibraryApplicationBranchIds;
this.waitFor(AuthenticationStore);
const Storage = (require(587) /* metro dependency 587: Storage */).Storage;
const value2 = Storage.get(env1_12);
if (value2 != null) {
activeLaunchOptionIds = value2.activeLaunchOptionIds;
if (activeLaunchOptionIds == null) {
saveActiveLaunchOptionIds();
} else {
activeLaunchOptionIds = value2.activeLaunchOptionIds;
}
activeLibraryApplicationBranchIds = value2.activeLibraryApplicationBranchIds;
if (activeLibraryApplicationBranchIds == null) {
saveActiveLibraryApplicationBranchIds();
} else {
activeLibraryApplicationBranchIds = value2.activeLibraryApplicationBranchIds;
}
}
}
function get_36165() { // fn#36165, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:2838, offset: 0x01084702, size: 21 bytes, params: 1, frame: 11
return getLibraryApplicationsFiltered(function(a0) {
return !a0.isHidden();
});
}
function value_36171(a0, a1) { // fn#36171, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:3240, offset: 0x010847c7, size: 97 bytes, params: 3, frame: 16
var r0;
let value = a2;
let r1 = value !== undefined ? value : false;
value = environment.__proto__;
const value2 = _getLibraryApplication(a0, a1);
const value3 = value2 != null;
if (value3) {
r1 = !r1 && value2.isHidden();
if (r1) {
r1 = !r1;
} else {
value = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
value = value.isUserEntitledToLibraryApplication(value2);
r1 = value;
}
r0 = r1;
} else {
r0 = value3;
}
return r0;
}
function value_36172(a0, a1) { // fn#36172, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:3416, offset: 0x01084828, size: 89 bytes, params: 3, frame: 16
var r0;
var value3;
let value = a2;
const r1 = value !== undefined ? value : false;
value = environment.__proto__;
const value2 = _getLibraryApplication(a0, a1);
if (r1) {
value3 = null;
if (value3 == value2) {
r0 = value2;
} else {
value = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
r0 = value.isUserEntitledToLibraryApplication(value2) ? value2 : value3;
}
} else {
r0 = value2;
}
return r0;
}
function value_36173(a0) { // fn#36173, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:3586, offset: 0x01084881, size: 249 bytes, params: 2, frame: 25
var r13;
var r0;
var r8;
var comboId;
var moduleValue2;
var isUserEntitledToLibraryApplication;
var isHidden;
var propertyName;
var propertyName2;
var id;
var moduleValue3;
let value = a1;
reducibleJoin2: while (true) {
if (value !== undefined) {
r13 = value;
break reducibleJoin2;
}
value = false;
r13 = value;
break reducibleJoin2;
}
value = environment.__proto__;
let property = env1_17[a0];
if (property != null) {
comboId = (require(4278) /* metro dependency 4278: LibraryApplicationUtils */).getComboId(a0, property);
property = env1_14[comboId];
reducibleJoin5: while (true) {
if (property != null) {
r0 = property;
break reducibleJoin5;
}
property = env1_15[comboId];
r0 = property;
break reducibleJoin5;
}
reducibleJoin9: while (true) {
if (r0 == null) {
break reducibleJoin9;
}
moduleValue2 = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
isUserEntitledToLibraryApplication = moduleValue2.isUserEntitledToLibraryApplication;
if (Reflect.apply(isUserEntitledToLibraryApplication, moduleValue2, [r0])) {
if (!r13) {
isHidden = r0.isHidden;
reducibleJoin17: while (true) {
if (Reflect.apply(isHidden, r0, [])) {
break reducibleJoin9;
}
break reducibleJoin17;
}
}
return r0;
}
break reducibleJoin9;
}
}
const value3 = _getAllLibraryApplications();
const properties = Object.keys(value3);
const properties2 = 0;
const properties3 = properties.length;
if (properties !== undefined) {
r8 = properties2;
reducibleLoop10: while (true) {
propertyName = properties[r8];
propertyName2 = r8 + 1;
if (propertyName === undefined) {
return undefined;
}
id = value3[propertyName].id;
if (id !== a0) {
r8 = propertyName2;
continue reducibleLoop10;
}
property = value3[propertyName];
moduleValue3 = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
isUserEntitledToLibraryApplication = moduleValue3.isUserEntitledToLibraryApplication;
if (Reflect.apply(isUserEntitledToLibraryApplication, moduleValue3, [property])) {
if (r13) {
return property;
}
isHidden = property.isHidden;
if (!Reflect.apply(isHidden, property, [])) {
return property;
}
r8 = propertyName2;
continue reducibleLoop10;
}
r8 = propertyName2;
continue reducibleLoop10;
}
}
}
function value_36174(a0, a1) { // fn#36174, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:3959, offset: 0x0108497a, size: 59 bytes, params: 3, frame: 15
let value = environment.__proto__;
const binding = env1_16;
const has = binding.has;
value = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
const getComboId = value.getComboId;
return Reflect.apply(has, binding, [Reflect.apply(getComboId, value, [a0, a1])]);
}
function value_36175(a0, a1) { // fn#36175, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:4051, offset: 0x010849b5, size: 53 bytes, params: 3, frame: 14
let value = environment.__proto__;
const binding = env1_18;
value = require(4278) /* metro dependency 4278: LibraryApplicationUtils */;
const getComboId = value.getComboId;
return binding[Reflect.apply(getComboId, value, [a0, a1])];
}
function get_36177() { // fn#36177, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:4172, offset: 0x010849ea, size: 90 bytes, params: 1, frame: 13
var environment;
let value = environment.__proto__;
value = (importDefault(22) /* metro dependency 22 */)(_getAllLibraryApplications());
value = value.values();
value = value.filter(_fun36178);
value = value.map(function(a0) {
return a0.branchId;
});
return value.value();
}
function value_36181(a0) { // fn#36181, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:4431, offset: 0x01084a78, size: 32 bytes, params: 2, frame: 11
const env0_0 = a0;
this.addConditionalChangeListener(_fun36182);
}
function getLibraryApplicationsFiltered(a0) { // fn#36166, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:2856, owner: get_36165.getLibraryApplicationsFiltered, offset: 0x01084717, size: 61 bytes, params: 2, frame: 12
var environment;
const env0_0 = a0;
let value = environment.__proto__.__proto__;
value = _getAllLibraryApplications();
const Object = global.Object;
Object.keys(value).forEach(_fun36167);
return value;
}
function _fun36178(a0) { // fn#36178, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:4246, offset: 0x01084a44, size: 41 bytes, params: 2, frame: 11
const value = environment.__proto__.__proto__;
return (require(4278) /* metro dependency 4278: LibraryApplicationUtils */).isUserEntitledToLibraryApplication(a0);
}
function _fun36182() { // fn#36182, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:4478, offset: 0x01084a98, size: 38 bytes, params: 1, frame: 11
if (env2_13) {
global.setImmediate(env0_0);
return false;
}
}
function _fun36167(a0) { // fn#36167, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4442:2965, offset: 0x01084754, size: 38 bytes, params: 2, frame: 13
if (!env0_0(env0_1[a0])) {
delete env0_1[a0];
}
}