Files
discord-decomp/sources/utils/GuildRoleRecordUtils.tsx
T
2026-07-28 01:06:53 +03:00

334 lines
12 KiB
TypeScript

/* Metro module 1942; source: utils/GuildRoleRecordUtils.tsx; dependencies: [1419, 1939, 483, 673, 1941, 2] */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as BigFlagUtilsModule from '../external/discord_common/js/shared/utils/BigFlagUtils.tsx'; /* Metro dependency 483 */
import * as PlainRecordModule from '../lib/PlainRecord.tsx'; /* Metro dependency 1419 */
import * as GuildRoleRecordModule from '../records/GuildRoleRecord.tsx'; /* Metro dependency 1939 */
function _fun21569(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#21569, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2069:6, offset: 0x00ef3e63, size: 269 bytes, params: 8, frame: 22
const env0_0 = require;
const _arrayLikeToArray_21572 = 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(a0, a1) {
var r2;
var value4;
var id;
var value5;
var object = {};
var value2 = _createForOfIteratorHelperLoose_21570(a1);
var value3 = value2();
if (!value3.done) {
for (r2 = value3; true; r2 = value5) {
value4 = r2.value;
id = value4.id;
object[id] = fromServer_21574(a0, value4);
value5 = value2();
if (value5.done) {
break;
}
}
}
return object;
};
const fromServer_215742 = fromServer_21574;
const closure3 = function(a0) {
return constructInPlace(GuildRoleRecordTypeTag, a0);
};
const fromSerialized2 = fromSerialized;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('utils/GuildRoleRecordUtils.tsx');
exports.isGuildRoleRecord = function(a0) {
return objectIsPlainRecordOfType(GuildRoleRecordTypeTag, a0);
};
exports.fromServerArray = closure;
exports.fromServer = fromServer_215742;
exports.constructGuildRoleInPlace = closure3;
exports.fromSerialized = fromSerialized2;
exports.fromSyncOperation = fromSyncOperation;
exports.fromSerializedPartition = function(a0, a1) {
var propertyName;
var object = {};
for (propertyName in a1) {
object[propertyName] = fromSerialized(a0, a1[propertyName]);
}
return object;
};
exports.toSerializedPartition = function(a0) {
var r11;
var propertyName;
var property;
var object2;
var object = {};
for (propertyName in a0) {
property = a0[propertyName];
object2 = {};
copyDataProperties(object2, property, r11);
property = property.permissions;
object2['permissions'] = property.toString();
object[propertyName] = object2;
r11 = property;
}
return object;
};
function _createForOfIteratorHelperLoose_21570(a0, a1) { // fn#21570, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2069:196, offset: 0x00ef3f70, 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 _fun21571;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_21572(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_21572(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_21572(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun21571;
}
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 _fun21571() { // fn#21571, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2069:767, 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 fromServer_21574(a0, a1) { // fn#21574, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2069:1251, offset: 0x00ef412d, size: 371 bytes, params: 3, frame: 19
var r6;
var moduleValue2;
var value;
const constructGuildRoleInPlaceBinding = constructGuildRoleInPlace;
const object = {};
object.id = a1.id;
object.name = a1.name;
object.guildId = a0;
object.permissions = BigFlagUtilsModule.deserialize(a1.permissions);
object.mentionable = a1.mentionable;
object.position = a1.position;
let color = a1.color;
object.color = color;
color = a1.color;
const value2 = null;
const value3 = 0;
if (value3 === color) {
r6 = value2;
} else {
moduleValue2 = require(673) /* metro dependency 673: ColorUtils */;
r6 = moduleValue2.int2hex(a1.color);
}
object.colorString = r6;
const colors = a1.colors;
object.colors = value2 != colors ? colors : value2;
if (value2 != a1.colors) {
value = require(1941) /* metro dependency 1941: EnhancedRoleColorUtils */;
value = value.extractColorStringsFromServerColors(a1.colors);
r6 = value;
} else {
r6 = value2;
}
object.colorStrings = r6;
object.hoist = a1.hoist;
const managed = a1.managed;
object.managed = value2 != managed && managed;
const tags = a1.tags;
object.tags = value2 != tags ? tags : {};
object.icon = a1.icon;
object.unicodeEmoji = a1.unicode_emoji;
const flags = a1.flags;
object.flags = value2 != flags ? flags : value3;
const description = a1.description;
object.description = value2 != description ? description : value2;
object.version = a1.version;
return constructGuildRoleInPlaceBinding(object);
}
function fromSerialized(a0, a1) { // fn#21576, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2069:1894, offset: 0x00ef42b8, size: 385 bytes, params: 3, frame: 18
var r5;
var moduleValue2;
var value;
const constructGuildRoleInPlaceBinding = constructGuildRoleInPlace;
const object = {};
object.id = a1.id;
object.name = a1.name;
object.guildId = a0;
object.permissions = BigFlagUtilsModule.deserialize(a1.permissions);
object.mentionable = a1.mentionable;
object.position = a1.position;
let color = a1.color;
object.color = color;
color = a1.color;
const value2 = null;
if (value2 != color) {
if (a1.color === 0) {
r5 = value2;
} else {
moduleValue2 = require(673) /* metro dependency 673: ColorUtils */;
r5 = moduleValue2.int2hex(a1.color);
}
} else {
r5 = value2;
}
object.colorString = r5;
const colors = a1.colors;
object.colors = value2 != colors ? colors : value2;
if (value2 != a1.colors) {
value = require(1941) /* metro dependency 1941: EnhancedRoleColorUtils */;
value = value.extractColorStringsFromServerColors(a1.colors);
r5 = value;
} else {
r5 = value2;
}
object.colorStrings = r5;
object.hoist = a1.hoist;
const managed = a1.managed;
object.managed = value2 != managed && managed;
const tags = a1.tags;
object.tags = value2 != tags ? tags : {};
object.icon = a1.icon;
object.unicodeEmoji = a1.unicodeEmoji;
const flags = a1.flags;
object.flags = value2 != flags ? flags : 0;
const description = a1.description;
object.description = value2 != description ? description : value2;
object.version = a1.version;
return constructGuildRoleInPlaceBinding(object);
}
function fromSyncOperation(a0, a1, a2) { // fn#21578, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2069:2803, offset: 0x00ef4451, size: 183 bytes, params: 4, frame: 19
var r4;
var value4;
var value5;
var value8;
var id;
var value9;
if (a1.op === 'full_sync') {
return fromServerArray(a0, a1.items);
}
const object = {};
copyDataProperties(object, a2, undefined);
const value2 = _createForOfIteratorHelperLoose_21570(a1.deletes);
const value3 = value2();
let done = value3.done;
if (!done) {
r4 = value3;
reducibleLoop2: while (true) {
value4 = r4.value;
delete object[value4];
value5 = value2();
done = value5.done;
if (done) {
break reducibleLoop2;
}
r4 = value5;
continue reducibleLoop2;
}
}
const value6 = _createForOfIteratorHelperLoose_21570(a1.writes);
const value7 = value6();
done = value7.done;
if (!done) {
r4 = value7;
reducibleLoop4: while (true) {
value8 = r4.value;
id = value8.id;
object[id] = fromServer_21574(a0, value8);
value9 = value6();
done = value9.done;
if (done) {
break reducibleLoop4;
}
r4 = value9;
continue reducibleLoop4;
}
}
return object;
}
}
global.__d(_fun21569, 1942, [1419, 1939, 483, 673, 1941,
2]) /* metro module 1942, dependencies: [1419, 1939, 483, 673, 1941, 2] */;