Files
discord-decomp/_bundle/Module3813.js
T
2026-11-01 12:12:55 +02:00

184 lines
4.7 KiB
JavaScript

// Metro module 3813 (f3814).
import _slicedToArray from "./_slicedToArray";
import sortedIndexBy from "./sortedIndexBy";
let c2152_3 = [];
export class SecondaryIndexMap {
constructor(a0, a1, isEqual = (a0, a1) => a0 === a1) {
const r12 = {
__proto__: new.target.prototype,
valueMap: new Map(),
valueArray: null,
valueIndexes: null,
valueIndexesForGetter: null,
dirty: false,
_version: 0
};
r12.valueArray = [];
r12.valueIndexes = {};
r12.valueIndexesForGetter = {};
r12.indexBy = a0;
r12.sortBy = a1;
r12.isEqual = isEqual;
return r12;
}
get version() {
return this._version;
}
indexes(r1 = false) {
if (r1) {
return this.valueIndexes;
}
if (!r1 && this.dirty) {
const valueIndexesForGetter = {};
for (const item of Object.entries(this.valueIndexes)) {
const r33 = _slicedToArray(item, 2);
valueIndexesForGetter[r33[0]] = [...r33[1]];
}
this.valueIndexesForGetter = valueIndexesForGetter;
this.dirty = false;
}
return this.valueIndexesForGetter;
}
keys() {
return this.valueMap.keys();
}
values(a0, r4 = false) {
let valueArray;
if (a0 == null) {
valueArray = this.valueArray;
} else {
valueArray = this.indexes(r4)[a0];
if (valueArray == null) {
valueArray = c2152_3;
}
}
return valueArray;
}
size(a0) {
let length;
if (a0 == null) {
length = this.valueArray.length;
} else {
length = this.valueIndexes[a0]?.length;
if (length == null) {
length = 0;
}
}
return length;
}
clear() {
this.valueMap.clear();
this.valueArray = [];
this.valueIndexes = {};
this.valueIndexesForGetter = {};
}
has(a0) {
return this.valueMap.has(a0);
}
get(a0) {
return this.valueMap.get(a0);
}
set(a0, a1) {
let r35;
const r10 = this.get(a0);
let c13622_0 = r10;
let r3 = r10 != null || a1 != null;
if (r3) {
let r2 = r10 == null || a1 == null || !this.isEqual(r10, a1);
if (r2) {
if (a1 != null) {
this.valueMap.set(a0, a1);
} else {
this.valueMap.delete(a0);
}
const valueArray = this.valueArray;
const sortBy = this.sortBy;
if (r10 != null) {
const r15 = sortedIndexBy(valueArray, r10, sortBy);
const r29 = valueArray[r15];
let r30 = r15;
if (r29 !== r10) {
const r1 = valueArray.length - 1;
let r32 = r15;
r30 = r32;
if (r30 < r1) {
do {
const r33 = r32 + 1;
const r16 = valueArray[r33];
r30 = r33;
if (r16 === r10) {
break;
}
r35 = valueArray.length - 1;
r32 = r33;
r30 = r32;
} while (r30 < r35);
}
}
valueArray.splice(r30, 1);
}
if (a1 != null) {
valueArray.splice(sortedIndexBy(valueArray, a1, sortBy), 0, a1);
}
if (r10 != null) {
this.indexBy(r10).forEach((item) => {
let r24;
const index = this.getIndex(item);
const sortBy = this.sortBy;
if (c13622_0 != null) {
const r17 = sortedIndexBy(index, c13622_0, sortBy);
const r18 = index[r17];
let r19 = r17;
if (r18 !== c13622_0) {
const r1 = index.length - 1;
let r21 = r17;
r19 = r21;
if (r19 < r1) {
do {
const r22 = r21 + 1;
const r8 = index[r22];
r19 = r22;
if (r8 === c13622_0) {
break;
}
r24 = index.length - 1;
r21 = r22;
r19 = r21;
} while (r19 < r24);
}
}
index.splice(r19, 1);
}
});
}
if (a1 != null) {
this.indexBy(a1).forEach((item) => {
const index = this.getIndex(item);
const sortBy = this.sortBy;
if (a1 != null) {
index.splice(sortedIndexBy(index, a1, sortBy), 0, a1);
}
});
}
this.dirty = true;
this._version = this._version + 1;
r2 = true;
}
r3 = r2;
}
return r3;
}
delete(a0) {
return this.set(a0, null);
}
getIndex(a0) {
let r5 = this.valueIndexes[a0];
if (r5 == null) {
const r2 = [];
this.valueIndexes[a0] = r2;
r5 = r2;
}
return r5;
}
}