Files
discord-decomp/sources/by-id/module-07132.js
T
2026-07-28 01:06:53 +03:00

534 lines
19 KiB
JavaScript

/* Metro module 7132; source: unknown; dependencies: [7133] */
import * as Module07133Module from './module-07133.js'; /* Metro dependency 7133 */
function _fun57045(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#57045, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:6, offset: 0x013dad85, size: 467 bytes, params: 8, frame: 14
const env0_0 = require;
const TDigest2 = TDigest;
const compare_centroid_means = function(a0, a1) {
return a0.mean > a1.mean ? 1 : a0.mean < a1.mean ? -1 : 0;
};
const compare_centroid_mean_cumns = function({mean_cumn}, a1) {
return mean_cumn - a1.mean_cumn;
};
const constructor_570492 = constructor_57049;
TDigest2.prototype.reset = function() {
this.centroids.clear();
this.n = 0;
this.nreset += 1;
this.last_cumulate = 0;
};
TDigest2.prototype.size = function() {
return this.centroids.size;
};
TDigest2.prototype.toArray = function(a0) {
if (a0) {
this._cumulate(true);
this.centroids.each(_fun57053);
} else {
this.centroids.each(_fun57054);
}
return [];
};
TDigest2.prototype.summary = summary;
TDigest2.prototype.push = function(a0, a1) {
var r4;
var r2;
var r1;
var value3;
var value = a0;
var value2 = a1;
reducibleJoin2: while (true) {
if (value2) {
r4 = value2;
break reducibleJoin2;
}
value3 = 1;
r4 = value3;
break reducibleJoin2;
}
var Array = global.Array;
reducibleJoin4: while (true) {
if (Array.isArray(value)) {
r2 = value;
break reducibleJoin4;
}
r2 = [value];
break reducibleJoin4;
}
value = 0;
if (value < r2.length) {
r1 = value;
reducibleLoop5: while (true) {
this._digest(r2[r1], r4);
value = typeof r1 === 'bigint' ? r1 + 1n : +r1 + 1;
if (value < r2.length) {
r1 = value;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
};
TDigest2.prototype.push_centroid = function(a0) {
var r2;
var r1;
var value = a0;
var property = global.Array;
reducibleJoin2: while (true) {
if (property.isArray(value)) {
r2 = value;
break reducibleJoin2;
}
r2 = [value];
break reducibleJoin2;
}
value = 0;
if (value < r2.length) {
r1 = value;
reducibleLoop3: while (true) {
property = r2[r1].mean;
this._digest(property, r2[r1].n);
value = typeof r1 === 'bigint' ? r1 + 1n : +r1 + 1;
if (value < r2.length) {
r1 = value;
continue reducibleLoop3;
}
break reducibleLoop3;
}
}
};
TDigest2.prototype._cumulate = _cumulate;
TDigest2.prototype.find_nearest = find_nearest;
TDigest2.prototype._new_centroid = function(a0, a1, a2) {
var object = {mean: a0, n: a1, cumn: a2};
this.centroids.insert(object);
this.n += a1;
return object;
};
TDigest2.prototype._addweight = _addweight;
TDigest2.prototype._digest = _digest;
TDigest2.prototype.bound_mean = function(a0) {
var r1;
var value = this.centroids.upperBound({mean: a0});
var value2 = value.prev();
object = [value2];
if (value2.mean === a0) {
r1 = value2;
} else {
value = value.next();
r1 = value;
}
object[1] = r1;
return object;
};
TDigest2.prototype.p_rank = function(a0) {
var value = a0;
var value2 = (global.Array.isArray(value) ? value : [value]).map(this._p_rank, this);
return global.Array.isArray(value) ? value2 : value2[0];
};
TDigest2.prototype._p_rank = _p_rank;
TDigest2.prototype.bound_mean_cumn = bound_mean_cumn;
TDigest2.prototype.percentile = function(a0) {
var value = a0;
var value2 = (global.Array.isArray(value) ? value : [value]).map(this._percentile, this);
return global.Array.isArray(value) ? value2 : value2[0];
};
TDigest2.prototype._percentile = _percentile;
TDigest2.prototype.compress = compress_57070;
const Object = global.Object;
constructor_570492.prototype = Object.create(TDigest2.prototype);
constructor_570492.prototype.constructor = constructor_570492;
constructor_570492.prototype.push = function(a0) {
TDigest.prototype.push.call(this, a0);
this.check_continuous();
};
constructor_570492.prototype._new_centroid = function(a0, a1, a2) {
this.n_unique += 1;
TDigest.prototype._new_centroid.call(this, a0, a1, a2);
};
constructor_570492.prototype._addweight = function(a0, a1, a2) {
if (a0.n === 1) {
this.n_unique -= 1;
}
TDigest.prototype._addweight.call(this, a0, a1, a2);
};
constructor_570492.prototype.check_continuous = check_continuous;
module.exports = {TDigest: TDigest2, Digest: constructor_570492};
function TDigest(a0, a1, a2) { // fn#57046, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:32, offset: 0x013daf58, size: 159 bytes, params: 4, frame: 14
const value = a0;
const value2 = a1;
const value3 = a2;
this.discrete = value === false;
this.delta = value || 0.01;
this.K = value2 === undefined ? 25 : value2;
this.CX = value3 === undefined ? 1.1 : value3;
const RBTree = (Module07133Module).RBTree;
this.centroids = new RBTree(compare_centroid_means);
this.nreset = 0;
this.reset();
}
function Digest(a0) { // fn#57049, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:381, offset: 0x013db04b, size: 157 bytes, params: 2, frame: 15
const value = a0;
this.config = value || ({});
let mode = this.config.mode;
mode = !mode ? 'auto' : mode;
this.mode = mode;
TDigest.call(this, this.mode === 'cont' && value.delta);
let ratio = this.config.ratio;
ratio = !ratio ? 0.9 : ratio;
this.digest_ratio = ratio;
let thresh = this.config.thresh;
thresh = !thresh ? 1000 : thresh;
this.digest_thresh = thresh;
this.n_unique = 0;
}
function toArray_57052(a0) { // fn#57052, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:791, offset: 0x013db12e, size: 79 bytes, params: 2, frame: 14
if (a0) {
this._cumulate(true);
this.centroids.each(_fun57053);
} else {
this.centroids.each(_fun57054);
}
return [];
function _fun57053(a0) { // fn#57053, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:862, offset: 0x00c786d6, size: 24 bytes, params: 2, frame: 11
env0_0.push(a0);
}
function _fun57054({mean, n}) { // fn#57054, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:909, offset: 0x013db17d, size: 48 bytes, params: 2, frame: 13
env0_0.push({mean: mean, n: n});
}
}
function _cumulate(a0) { // fn#57058, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:1523, offset: 0x013db36c, size: 109 bytes, params: 2, frame: 13
var binding;
if (this.n !== this.last_cumulate) {
if (a0) {
var env0_0 = 0;
this.centroids.each(_fun57059);
binding = env0_0;
this.last_cumulate = binding;
this.n = binding;
} else if (this.CX) {
if (!(this.CX > this.n / this.last_cumulate)) {
var env0_0 = 0;
this.centroids.each(_fun57059);
binding = env0_0;
this.last_cumulate = binding;
this.n = binding;
}
} else {
var env0_0 = 0;
this.centroids.each(_fun57059);
binding = env0_0;
this.last_cumulate = binding;
this.n = binding;
}
}
function _fun57059(a0) { // fn#57059, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:1647, offset: 0x013db3d9, size: 61 bytes, params: 2, frame: 5
a0.mean_cumn = env0_0 + a0.n / 2;
a0.cumn = env0_0 + a0.n;
}
}
function bound_mean_cumn(a0) { // fn#57067, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:3369, offset: 0x013db892, size: 110 bytes, params: 2, frame: 15
const centroids = this.centroids;
centroids._comparator = compare_centroid_mean_cumns;
const value2 = this.centroids.upperBound({mean_cumn: a0});
this.centroids._comparator = compare_centroid_means;
const value = value2.prev();
return [value, value && value.mean_cumn === a0 ? value : value2.next()];
}
}
function summary() { // fn#57055, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:981, offset: 0x013db1ad, size: 250 bytes, params: 1, frame: 12
value = (this.discrete ? 'exact ' : 'approximating ') + this.n;
value = value + ' samples using ' + this.size();
const items2 = [value + ' centroids'];
items2[1] = 'min = ' + this.percentile(0);
items2[2] = 'Q1 = ' + this.percentile(0.25);
items2[3] = 'Q2 = ' + this.percentile(0.5);
items2[4] = 'Q3 = ' + this.percentile(0.75);
items2[5] = 'max = ' + this.percentile(1);
return items2.join('\n');
}
function find_nearest(a0) { // fn#57060, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:1758, offset: 0x013db416, size: 192 bytes, params: 2, frame: 16
var r1;
var Math;
var abs;
var value5;
if (this.size() === 0) {
return null;
}
value = this.centroids.lowerBound({mean: a0});
const r0 = value.data() === null ? value.prev() : value.data();
let mean = r0.mean;
if (mean === a0) {
return r0;
}
if (this.discrete) {
return r0;
}
value = value.prev();
if (value) {
Math = global.Math;
abs = Math.abs;
mean = value.mean;
value5 = Reflect.apply(abs, Math, [mean - a0]);
Math = global.Math;
abs = Math.abs;
mean = r0.mean;
r1 = value5 < Reflect.apply(abs, Math, [mean - a0]) ? value : r0;
} else {
r1 = r0;
}
return r1;
}
function _addweight(a0, a1, a2) { // fn#57062, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:2133, offset: 0x013db515, size: 140 bytes, params: 4, frame: 6
if (a1 !== a0.mean) {
a0.mean = a0.mean + a2 * (a1 - a0.mean) / (a0.n + a2);
}
a0.cumn = a0.cumn + a2;
a0.mean_cumn = a0.mean_cumn + a2 / 2;
a0.n = a0.n + a2;
this.n = this.n + a2;
}
function _digest(a0, a1) { // fn#57063, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:2263, offset: 0x013db5a1, size: 366 bytes, params: 3, frame: 19
var mean_cumn;
var n;
var Math;
var floor;
let value = this.centroids.min();
const value2 = this.centroids.max();
const value3 = this.find_nearest(a0);
if (value3) {
if (value3.mean === a0) {
this._addweight(value3, a0, a1);
} else if (value3 === value) {
this._new_centroid(a0, a1, 0);
} else if (value3 === value2) {
this._new_centroid(a0, a1, this.n);
} else if (this.discrete) {
this._new_centroid(a0, a1, value3.cumn);
} else {
mean_cumn = value3.mean_cumn;
n = this.n;
value = mean_cumn / n;
Math = global.Math;
floor = Math.floor;
n = this.n;
value = Reflect.apply(floor, Math, [4 * n * this.delta * value * (1 - value)]);
n = value3.n;
if (value - n >= a1) {
this._addweight(value3, a0, a1);
} else {
this._new_centroid(a0, a1, value3.cumn);
}
}
} else if (value3 === value) {
this._new_centroid(a0, a1, 0);
} else if (value3 === value2) {
this._new_centroid(a0, a1, this.n);
} else if (this.discrete) {
this._new_centroid(a0, a1, value3.cumn);
} else {
mean_cumn = value3.mean_cumn;
n = this.n;
value = mean_cumn / n;
Math = global.Math;
floor = Math.floor;
n = this.n;
value = Reflect.apply(floor, Math, [4 * n * this.delta * value * (1 - value)]);
n = value3.n;
if (value - n >= a1) {
this._addweight(value3, a0, a1);
} else {
this._new_centroid(a0, a1, value3.cumn);
}
}
this._cumulate(false);
let r0 = !this.discrete && this.K;
if (r0) {
value = this.size();
value = value > this.K / this.delta;
r0 = value;
}
if (r0) {
this.compress();
}
}
function _p_rank(a0) { // fn#57066, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:3026, offset: 0x013db7ae, size: 228 bytes, params: 2, frame: 17
var r4;
var centroids;
var mean;
var property;
var property2;
var mean_cumn;
let value = this.size();
if (value !== 0) {
centroids = this.centroids;
mean = centroids.min().mean;
if (a0 < mean) {
return 0;
}
centroids = this.centroids;
mean = centroids.max().mean;
if (a0 > mean) {
return 1;
}
this._cumulate(true);
value = this.bound_mean(a0);
property = value[0];
property2 = value[1];
if (this.discrete) {
return property.cumn / this.n;
}
mean_cumn = property.mean_cumn;
if (property === property2) {
r4 = mean_cumn;
} else {
mean = property.mean;
value = a0 - mean;
value *= property2.mean_cumn - property.mean_cumn;
mean = property2.mean;
value = mean_cumn + value / (mean - property.mean);
r4 = value;
}
return r4 / this.n;
}
}
function _percentile(a0) { // fn#57069, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:3750, offset: 0x013db957, size: 227 bytes, params: 2, frame: 15
var mean;
var r0;
var centroids;
var value2;
var property;
var property2;
var mean_cumn;
let value = this.size();
if (value !== 0) {
this._cumulate(true);
centroids = this.centroids;
centroids.min();
centroids = this.centroids;
centroids.max();
value = this.n * a0;
value2 = this.bound_mean_cumn(value);
property = value2[0];
property2 = value2[1];
if (property2 === property) {
r0 = (property || property2).mean;
} else if (property === null) {
r0 = (property || property2).mean;
} else if (property2 === null) {
r0 = (property || property2).mean;
} else if (this.discrete) {
r0 = value <= property.cumn ? property.mean : property2.mean;
} else {
mean = property.mean;
mean_cumn = property.mean_cumn;
value -= mean_cumn;
value *= property2.mean - property.mean;
mean_cumn = property2.mean_cumn;
value = mean + value / (mean_cumn - property.mean_cumn);
r0 = value;
}
return r0;
}
}
function compress_57070() { // fn#57070, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:4075, offset: 0x013dba3a, size: 159 bytes, params: 1, frame: 20
var toArray;
var value;
var reset;
var length;
var push_centroid;
var Math;
var floor;
var Math2;
var random;
var value2;
var value3;
var splice;
var _cumulate;
reducibleJoin4: while (true) {
if (this.compressing) {
break reducibleJoin4;
}
toArray = this.toArray;
value = Reflect.apply(toArray, this, []);
reset = this.reset;
Reflect.apply(reset, this, []);
this.compressing = true;
length = value.length;
if (length > 0) {
reducibleLoop2: while (true) {
push_centroid = this.push_centroid;
Math = global.Math;
floor = Math.floor;
Math2 = global.Math;
random = Math2.random;
value2 = Reflect.apply(random, Math2, []);
length = value.length;
value3 = Reflect.apply(floor, Math, [value2 * length]);
splice = value.splice;
Reflect.apply(push_centroid, this, [Reflect.apply(splice, value, [value3, 1])[0]]);
length = value.length;
if (length > 0) {
continue reducibleLoop2;
}
break reducibleLoop2;
}
}
_cumulate = this._cumulate;
Reflect.apply(_cumulate, this, [true]);
this.compressing = false;
break reducibleJoin4;
}
}
function check_continuous() { // fn#57074, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7310:4760, offset: 0x013dbb9b, size: 143 bytes, params: 1, frame: 12
var r1;
var delta;
var r0;
let value = this.mode !== 'auto';
if (value) {
r1 = value;
} else {
value = this.size();
value = value < this.digest_thresh;
r1 = value;
}
value = !r1;
if (r1) {
r0 = value;
} else {
value = this.n_unique / this.size();
value = value > this.digest_ratio;
if (value) {
this.mode = 'cont';
this.discrete = false;
delta = this.config.delta;
delta = !delta ? 0.01 : delta;
this.delta = delta;
this.compress();
r1 = true;
} else {
r1 = value;
}
r0 = r1;
}
return r0;
}
global.__d(_fun57045, 7132, [7133]) /* metro module 7132, dependencies: [7133] */;