163 lines
4.0 KiB
TypeScript
163 lines
4.0 KiB
TypeScript
// Metro module 1937 (f1938).
|
|
import { constructInPlace, objectIsPlainRecordOfType } from "../lib/PlainRecord";
|
|
import { GuildRoleRecordTypeTag } from "../records/GuildRoleRecord";
|
|
import { deserialize } from "../_bundle/HighLow";
|
|
import { int2hex } from "../_bundle/int2hslRaw";
|
|
import { extractColorStringsFromServerColors } from "../modules/premium/enhanced_role_colors/EnhancedRoleColorUtils";
|
|
let fromServer, fromSerialized;
|
|
const fromServerArray = function fromServerArray(id, a1) {
|
|
const r0 = {};
|
|
for (const item of a1) {
|
|
r0[item.id] = fromServer(id, item);
|
|
}
|
|
return r0;
|
|
};
|
|
fromServer = function fromServer(a0, a1) {
|
|
const r6 = {
|
|
id: a1.id,
|
|
name: a1.name,
|
|
guildId: a0,
|
|
permissions: deserialize(a1.permissions),
|
|
mentionable: a1.mentionable,
|
|
position: a1.position,
|
|
color: a1.color,
|
|
colorString: a1.color !== 0 ? int2hex(a1.color) : null,
|
|
colors: null,
|
|
colorStrings: null,
|
|
hoist: null,
|
|
managed: null,
|
|
tags: null,
|
|
icon: null,
|
|
unicodeEmoji: null,
|
|
flags: null,
|
|
description: null,
|
|
version: null
|
|
};
|
|
let colors = a1.colors;
|
|
if (colors == null) {
|
|
colors = null;
|
|
}
|
|
r6.colors = colors;
|
|
r6.colorStrings = a1.colors != null ? extractColorStringsFromServerColors(a1.colors) : null;
|
|
r6.hoist = a1.hoist;
|
|
let managed = a1.managed;
|
|
if (managed == null) {
|
|
managed = false;
|
|
}
|
|
r6.managed = managed;
|
|
let tags = a1.tags;
|
|
if (tags == null) {
|
|
tags = {};
|
|
}
|
|
r6.tags = tags;
|
|
r6.icon = a1.icon;
|
|
r6.unicodeEmoji = a1.unicode_emoji;
|
|
let flags = a1.flags;
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
r6.flags = flags;
|
|
let description = a1.description;
|
|
if (description == null) {
|
|
description = null;
|
|
}
|
|
r6.description = description;
|
|
r6.version = a1.version;
|
|
return constructInPlace(GuildRoleRecordTypeTag, r6);
|
|
};
|
|
fromSerialized = function fromSerialized(a0, a1) {
|
|
const r6 = {
|
|
id: a1.id,
|
|
name: a1.name,
|
|
guildId: a0,
|
|
permissions: deserialize(a1.permissions),
|
|
mentionable: a1.mentionable,
|
|
position: a1.position,
|
|
color: a1.color,
|
|
colorString: a1.color != null ? a1.color !== 0 ? int2hex(a1.color) : null : null,
|
|
colors: null,
|
|
colorStrings: null,
|
|
hoist: null,
|
|
managed: null,
|
|
tags: null,
|
|
icon: null,
|
|
unicodeEmoji: null,
|
|
flags: null,
|
|
description: null,
|
|
version: null
|
|
};
|
|
let colors = a1.colors;
|
|
if (colors == null) {
|
|
colors = null;
|
|
}
|
|
r6.colors = colors;
|
|
r6.colorStrings = a1.colors != null ? extractColorStringsFromServerColors(a1.colors) : null;
|
|
r6.hoist = a1.hoist;
|
|
let managed = a1.managed;
|
|
if (managed == null) {
|
|
managed = false;
|
|
}
|
|
r6.managed = managed;
|
|
let tags = a1.tags;
|
|
if (tags == null) {
|
|
tags = {};
|
|
}
|
|
r6.tags = tags;
|
|
r6.icon = a1.icon;
|
|
r6.unicodeEmoji = a1.unicodeEmoji;
|
|
let flags = a1.flags;
|
|
if (flags == null) {
|
|
flags = 0;
|
|
}
|
|
r6.flags = flags;
|
|
let description = a1.description;
|
|
if (description == null) {
|
|
description = null;
|
|
}
|
|
r6.description = description;
|
|
r6.version = a1.version;
|
|
return constructInPlace(GuildRoleRecordTypeTag, r6);
|
|
};
|
|
export function isGuildRoleRecord(a0) {
|
|
return objectIsPlainRecordOfType(GuildRoleRecordTypeTag, a0);
|
|
}
|
|
export { fromServerArray };
|
|
export { fromServer };
|
|
export function constructGuildRoleInPlace(a0) {
|
|
return constructInPlace(GuildRoleRecordTypeTag, a0);
|
|
}
|
|
export { fromSerialized };
|
|
export function fromSyncOperation(a0, a1, a2) {
|
|
if (a1.op === "full_sync") {
|
|
return fromServerArray(a0, a1.items);
|
|
}
|
|
const r23 = {
|
|
...a2
|
|
};
|
|
for (const delete2 of a1.deletes) {
|
|
delete r23[delete2];
|
|
}
|
|
for (const write of a1.writes) {
|
|
r23[write.id] = fromServer(a0, write);
|
|
}
|
|
return r23;
|
|
}
|
|
export function fromSerializedPartition(a0, a1) {
|
|
const r3 = {};
|
|
for (const key in a1) {
|
|
r3[key] = fromSerialized(a0, a1[key]);
|
|
}
|
|
return r3;
|
|
}
|
|
export function toSerializedPartition(a0) {
|
|
const r2 = {};
|
|
for (const key in a0) {
|
|
const r9 = a0[key];
|
|
r2[key] = {
|
|
...r9,
|
|
permissions: r9.permissions.toString()
|
|
};
|
|
}
|
|
return r2;
|
|
}
|