@wise-old-man/utils 3.1.16 → 3.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2627 @@
1
+ import dayjs from 'dayjs';
2
+ import customParseFormatPlugin from 'dayjs/plugin/customParseFormat.js';
3
+
4
+ var config = {
5
+ defaultUserAgent: `WiseOldMan JS Client v${process.env.npm_package_version}`,
6
+ baseAPIUrl: 'https://api.wiseoldman.net/v2'
7
+ };
8
+
9
+ /******************************************************************************
10
+ Copyright (c) Microsoft Corporation.
11
+
12
+ Permission to use, copy, modify, and/or distribute this software for any
13
+ purpose with or without fee is hereby granted.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
16
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
17
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
18
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
19
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
20
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21
+ PERFORMANCE OF THIS SOFTWARE.
22
+ ***************************************************************************** */
23
+ /* global Reflect, Promise */
24
+
25
+
26
+ function __rest(s, e) {
27
+ var t = {};
28
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
29
+ t[p] = s[p];
30
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
31
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
32
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
33
+ t[p[i]] = s[p[i]];
34
+ }
35
+ return t;
36
+ }
37
+
38
+ function __awaiter(thisArg, _arguments, P, generator) {
39
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
40
+ return new (P || (P = Promise))(function (resolve, reject) {
41
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
42
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
43
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
44
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
45
+ });
46
+ }
47
+
48
+ dayjs.extend(customParseFormatPlugin);
49
+ function traverseTransform(input, transformation) {
50
+ if (Array.isArray(input)) {
51
+ return input.map(item => traverseTransform(item, transformation));
52
+ }
53
+ if (input !== null && typeof input === 'object') {
54
+ return Object.fromEntries(Object.keys(input).map(key => [key, traverseTransform(input[key], transformation)]));
55
+ }
56
+ return transformation(input);
57
+ }
58
+ function isValidISODate(input) {
59
+ if (!input || typeof input !== 'string')
60
+ return false;
61
+ // DayJS has a bug with strict parsing with timezones https://github.com/iamkun/dayjs/issues/929
62
+ // So I'll just strip the "Z" timezone
63
+ return input.endsWith('Z') && dayjs(input.slice(0, -1), 'YYYY-MM-DDTHH:mm:ss.SSS', true).isValid();
64
+ }
65
+ function transformDates(input) {
66
+ return traverseTransform(input, val => (isValidISODate(val) ? new Date(val) : val));
67
+ }
68
+ function handleError(status, path, data) {
69
+ if (!data)
70
+ return;
71
+ if (status === 400) {
72
+ throw new BadRequestError(path, data.message, data.data);
73
+ }
74
+ if (status === 403) {
75
+ throw new ForbiddenError(path, data.message);
76
+ }
77
+ if (status === 404) {
78
+ throw new NotFoundError(path, data.message);
79
+ }
80
+ if (status === 429) {
81
+ throw new RateLimitError(path, data.message);
82
+ }
83
+ if (status === 500) {
84
+ throw new InternalServerError(path, data.message);
85
+ }
86
+ }
87
+ class BadRequestError extends Error {
88
+ constructor(resource, message, data) {
89
+ super(message);
90
+ this.name = 'BadRequestError';
91
+ this.resource = resource;
92
+ this.statusCode = 400;
93
+ this.data = data;
94
+ }
95
+ }
96
+ class ForbiddenError extends Error {
97
+ constructor(resource, message) {
98
+ super(message);
99
+ this.name = 'ForbiddenError';
100
+ this.resource = resource;
101
+ this.statusCode = 403;
102
+ }
103
+ }
104
+ class NotFoundError extends Error {
105
+ constructor(resource, message) {
106
+ super(message);
107
+ this.name = 'NotFoundError';
108
+ this.resource = resource;
109
+ this.statusCode = 404;
110
+ }
111
+ }
112
+ class RateLimitError extends Error {
113
+ constructor(resource, message) {
114
+ super(message);
115
+ this.name = 'RateLimitError';
116
+ this.resource = resource;
117
+ this.statusCode = 429;
118
+ }
119
+ }
120
+ class InternalServerError extends Error {
121
+ constructor(resource, message) {
122
+ super(message);
123
+ this.name = 'InternalServerError';
124
+ this.resource = resource;
125
+ this.statusCode = 500;
126
+ }
127
+ }
128
+
129
+ class BaseAPIClient {
130
+ constructor(headers, baseUrl) {
131
+ this.baseUrl = baseUrl;
132
+ this.headers = Object.assign({ Accept: 'application/json', 'Content-Type': 'application/json' }, headers);
133
+ }
134
+ buildParams(_a) {
135
+ var params = __rest(_a, []);
136
+ const builder = new URLSearchParams();
137
+ Object.keys(params)
138
+ .filter(k => params[k] !== undefined)
139
+ .forEach(k => builder.set(k, params[k]));
140
+ const query = builder.toString();
141
+ return query ? `?${query}` : '';
142
+ }
143
+ fetch({ method, path, body, params }) {
144
+ return __awaiter(this, void 0, void 0, function* () {
145
+ const req = { method, body: undefined, headers: this.headers };
146
+ let query = '';
147
+ if (body) {
148
+ req.body = JSON.stringify(body);
149
+ }
150
+ if (params) {
151
+ query = this.buildParams(params);
152
+ }
153
+ return yield fetch(this.baseUrl + path + query, req);
154
+ });
155
+ }
156
+ request({ method, path, body, params }) {
157
+ return __awaiter(this, void 0, void 0, function* () {
158
+ const res = yield this.fetch({ method, path, body, params });
159
+ const data = yield res.json();
160
+ if (res.ok) {
161
+ return transformDates(data);
162
+ }
163
+ handleError(res.status, path, data);
164
+ });
165
+ }
166
+ requestText({ method, path, body, params }) {
167
+ return __awaiter(this, void 0, void 0, function* () {
168
+ const res = yield this.fetch({ method, path, body, params });
169
+ const text = yield res.text();
170
+ if (res.ok) {
171
+ return text;
172
+ }
173
+ handleError(res.status, path, JSON.parse(text));
174
+ });
175
+ }
176
+ postRequest(path, body) {
177
+ return __awaiter(this, void 0, void 0, function* () {
178
+ return yield this.request({ method: 'POST', path, body: body || {} });
179
+ });
180
+ }
181
+ putRequest(path, body) {
182
+ return __awaiter(this, void 0, void 0, function* () {
183
+ return yield this.request({ method: 'PUT', path, body: body || {} });
184
+ });
185
+ }
186
+ deleteRequest(path, body) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ return yield this.request({ method: 'DELETE', path, body: body || {} });
189
+ });
190
+ }
191
+ getRequest(path, params) {
192
+ return __awaiter(this, void 0, void 0, function* () {
193
+ return yield this.request({ method: 'GET', path, params });
194
+ });
195
+ }
196
+ getText(path, params) {
197
+ return __awaiter(this, void 0, void 0, function* () {
198
+ return yield this.requestText({ method: 'GET', path, params });
199
+ });
200
+ }
201
+ }
202
+
203
+ class DeltasClient extends BaseAPIClient {
204
+ /**
205
+ * Fetches the current top leaderboard for a specific metric, period, playerType, playerBuild and country.
206
+ * @returns A list of deltas, with their respective players, values and dates included.
207
+ */
208
+ getDeltaLeaderboard(filter) {
209
+ return this.getRequest('/deltas/leaderboard', filter);
210
+ }
211
+ }
212
+
213
+ class GroupsClient extends BaseAPIClient {
214
+ /**
215
+ * Searches for groups that match a partial name.
216
+ * @returns A list of groups.
217
+ */
218
+ searchGroups(name, pagination) {
219
+ return this.getRequest('/groups', Object.assign({ name }, pagination));
220
+ }
221
+ /**
222
+ * Fetches a group's details, including a list of membership objects.
223
+ * @returns A group details object.
224
+ */
225
+ getGroupDetails(id) {
226
+ return this.getRequest(`/groups/${id}`);
227
+ }
228
+ /**
229
+ * Creates a new group.
230
+ * @returns The newly created group, and the verification code that authorizes future changes to it.
231
+ */
232
+ createGroup(payload) {
233
+ return this.postRequest('/groups', payload);
234
+ }
235
+ /**
236
+ * Edits an existing group.
237
+ * @returns The updated group.
238
+ */
239
+ editGroup(id, payload, verificationCode) {
240
+ return this.putRequest(`/groups/${id}`, Object.assign(Object.assign({}, payload), { verificationCode }));
241
+ }
242
+ /**
243
+ * Deletes an existing group.
244
+ * @returns A confirmation message.
245
+ */
246
+ deleteGroup(id, verificationCode) {
247
+ return this.deleteRequest(`/groups/${id}`, { verificationCode });
248
+ }
249
+ /**
250
+ * Adds all (valid) given usernames (and roles) to a group, ignoring duplicates.
251
+ * @returns The number of members added and a confirmation message.
252
+ */
253
+ addMembers(id, members, verificationCode) {
254
+ return this.postRequest(`/groups/${id}/members`, {
255
+ verificationCode,
256
+ members
257
+ });
258
+ }
259
+ /**
260
+ * Remove all given usernames from a group, ignoring usernames that aren't members.
261
+ * @returns The number of members removed and a confirmation message.
262
+ */
263
+ removeMembers(id, usernames, verificationCode) {
264
+ return this.deleteRequest(`/groups/${id}/members`, {
265
+ verificationCode,
266
+ members: usernames
267
+ });
268
+ }
269
+ /**
270
+ * Changes a player's role in a given group.
271
+ * @returns The updated membership, with player included.
272
+ */
273
+ changeRole(id, payload, verificationCode) {
274
+ return this.putRequest(`/groups/${id}/role`, Object.assign(Object.assign({}, payload), { verificationCode }));
275
+ }
276
+ /**
277
+ * Adds an "update" request to the queue, for each outdated group member.
278
+ * @returns The number of players to be updated and a confirmation message.
279
+ */
280
+ updateAll(id, verificationCode) {
281
+ return this.postRequest(`/groups/${id}/update-all`, {
282
+ verificationCode
283
+ });
284
+ }
285
+ /**
286
+ * Fetches all of the groups's competitions
287
+ * @returns A list of competitions.
288
+ */
289
+ getGroupCompetitions(id, pagination) {
290
+ return this.getRequest(`/groups/${id}/competitions`, Object.assign({}, pagination));
291
+ }
292
+ getGroupGains(id, filter, pagination) {
293
+ return this.getRequest(`/groups/${id}/gained`, Object.assign(Object.assign({}, pagination), filter));
294
+ }
295
+ /**
296
+ * Fetches a group members' latest achievements.
297
+ * @returns A list of achievements.
298
+ */
299
+ getGroupAchievements(id, pagination) {
300
+ return this.getRequest(`/groups/${id}/achievements`, Object.assign({}, pagination));
301
+ }
302
+ /**
303
+ * Fetches a group's record leaderboard for a specific metric and period.
304
+ * @returns A list of records, including their respective players.
305
+ */
306
+ getGroupRecords(id, filter, pagination) {
307
+ return this.getRequest(`/groups/${id}/records`, Object.assign(Object.assign({}, pagination), filter));
308
+ }
309
+ /**
310
+ * Fetches a group's hiscores for a specific metric.
311
+ * @returns A list of hiscores entries (value, rank), including their respective players.
312
+ */
313
+ getGroupHiscores(id, metric, pagination) {
314
+ return this.getRequest(`/groups/${id}/hiscores`, Object.assign(Object.assign({}, pagination), { metric }));
315
+ }
316
+ /**
317
+ * Fetches a group members' latest name changes.
318
+ * @returns A list of name change (approved) requests.
319
+ */
320
+ getGroupNameChanges(id, pagination) {
321
+ return this.getRequest(`/groups/${id}/name-changes`, Object.assign({}, pagination));
322
+ }
323
+ /**
324
+ * Fetches a group's general statistics.
325
+ * @returns An object with a few statistic values and an average stats snapshot.
326
+ */
327
+ getGroupStatistics(id) {
328
+ return this.getRequest(`/groups/${id}/statistics`);
329
+ }
330
+ /**
331
+ * Fetches a group's activity.
332
+ * @returns A list of a group's (join, leave and role changed) activity.
333
+ */
334
+ getGroupActivity(id, pagination) {
335
+ return this.getRequest(`/groups/${id}/activity`, Object.assign({}, pagination));
336
+ }
337
+ /**
338
+ * Fetches the groups's member list in CSV format.
339
+ * @returns A string containing the CSV content.
340
+ */
341
+ getMembersCSV(id) {
342
+ return this.getText(`/groups/${id}/csv`);
343
+ }
344
+ }
345
+
346
+ class PlayersClient extends BaseAPIClient {
347
+ /**
348
+ * Searches players by partial username.
349
+ * @returns A list of players.
350
+ */
351
+ searchPlayers(partialUsername, pagination) {
352
+ return this.getRequest('/players/search', Object.assign({ username: partialUsername }, pagination));
353
+ }
354
+ /**
355
+ * Updates/tracks a player.
356
+ * @returns The player's new details, including the latest snapshot.
357
+ */
358
+ updatePlayer(username) {
359
+ return this.postRequest(`/players/${username}`);
360
+ }
361
+ /**
362
+ * Asserts (and attempts to fix, if necessary) a player's game-mode type.
363
+ * @returns The updated player, and an indication of whether the type was changed.
364
+ */
365
+ assertPlayerType(username) {
366
+ return this.postRequest(`/players/${username}/assert-type`);
367
+ }
368
+ /**
369
+ * Fetches a player's details.
370
+ * @returns The player's details, including the latest snapshot.
371
+ */
372
+ getPlayerDetails(username) {
373
+ return this.getRequest(`/players/${username}`);
374
+ }
375
+ /**
376
+ * Fetches a player's details by ID.
377
+ * @returns The player's details, including the latest snapshot.
378
+ */
379
+ getPlayerDetailsById(id) {
380
+ return this.getRequest(`/players/id/${id}`);
381
+ }
382
+ /**
383
+ * Fetches a player's current achievements.
384
+ * @returns A list of achievements.
385
+ */
386
+ getPlayerAchievements(username) {
387
+ return this.getRequest(`/players/${username}/achievements`);
388
+ }
389
+ /**
390
+ * Fetches a player's current achievement progress.
391
+ * @returns A list of achievements (completed or otherwise), with their respective relative/absolute progress percentage.
392
+ */
393
+ getPlayerAchievementProgress(username) {
394
+ return this.getRequest(`/players/${username}/achievements/progress`);
395
+ }
396
+ /**
397
+ * Fetches all of the player's competition participations.
398
+ * @returns A list of participations, with the respective competition included.
399
+ */
400
+ getPlayerCompetitions(username, filter, pagination) {
401
+ return this.getRequest(`/players/${username}/competitions`, Object.assign(Object.assign({}, filter), pagination));
402
+ }
403
+ /**
404
+ * Fetches all of the player's competition participations' standings.
405
+ * @returns A list of participations, with the respective competition, rank and progress included.
406
+ */
407
+ getPlayerCompetitionStandings(username, filter) {
408
+ return this.getRequest(`/players/${username}/competitions/standings`, filter);
409
+ }
410
+ /**
411
+ * Fetches all of the player's group memberships.
412
+ * @returns A list of memberships, with the respective group included.
413
+ */
414
+ getPlayerGroups(username, pagination) {
415
+ return this.getRequest(`/players/${username}/groups`, pagination);
416
+ }
417
+ /**
418
+ * Fetches a player's gains, for a specific period or time range, as a [metric: data] map.
419
+ * @returns A map of each metric's gained data.
420
+ */
421
+ getPlayerGains(username, options) {
422
+ return this.getRequest(`/players/${username}/gained`, options);
423
+ }
424
+ /**
425
+ * Fetches a player's gains, for a specific period or time range, as an array.
426
+ * @returns An array of each metric's gained data.
427
+ */
428
+ getPlayerGainsAsArray(username, options) {
429
+ return this.getRequest(`/players/${username}/gained`, Object.assign(Object.assign({}, options), { formatting: 'array' }));
430
+ }
431
+ /**
432
+ * Fetches all of the player's records.
433
+ * @returns A list of records.
434
+ */
435
+ getPlayerRecords(username, options) {
436
+ return this.getRequest(`/players/${username}/records`, options);
437
+ }
438
+ /**
439
+ * Fetches all of the player's past snapshots.
440
+ * @returns A list of snapshots.
441
+ */
442
+ getPlayerSnapshots(username, filter, pagination) {
443
+ return this.getRequest(`/players/${username}/snapshots`, Object.assign(Object.assign({}, filter), pagination));
444
+ }
445
+ /**
446
+ * Fetches all of the player's past snapshots' timeline.
447
+ * @returns A list of timeseries data (value, rank, date)
448
+ */
449
+ getPlayerSnapshotTimeline(username, metric, options) {
450
+ return this.getRequest(`/players/${username}/snapshots/timeline`, Object.assign(Object.assign({}, options), { metric }));
451
+ }
452
+ /**
453
+ * Fetches all of the player's approved name changes.
454
+ * @returns A list of name changes.
455
+ */
456
+ getPlayerNames(username) {
457
+ return this.getRequest(`/players/${username}/names`);
458
+ }
459
+ /**
460
+ * Fetches all of archived players that previously held this username.
461
+ * @returns A list of player archives.
462
+ */
463
+ getPlayerArchives(username) {
464
+ return this.getRequest(`/players/${username}/archives`);
465
+ }
466
+ }
467
+
468
+ class RecordsClient extends BaseAPIClient {
469
+ /**
470
+ * Fetches the current records leaderboard for a specific metric, period, playerType, playerBuild and country.
471
+ * @returns A list of records, with their respective players, dates and values included.
472
+ */
473
+ getRecordLeaderboard(filter) {
474
+ return this.getRequest('/records/leaderboard', filter);
475
+ }
476
+ }
477
+
478
+ /**
479
+ * Prisma currently seems to ignore the @map() in enum declarations.
480
+ *
481
+ * So by declaring this enum in the schema file:
482
+ *
483
+ * enum NameChangeStatus {
484
+ * PENDING @map('pending')
485
+ * DENIED @map('denied')
486
+ * APPROVED @map('approved')
487
+ * }
488
+ *
489
+ * you would expect the prisma client to then generate the following object:
490
+ *
491
+ * const NameChangeStatus = {
492
+ * PENDING: 'pending',
493
+ * DENIED: 'denied',
494
+ * APPROVED: 'approved',
495
+ * }
496
+ *
497
+ * but unfortunately, the mapping is only used for queries, and the actual esulting object is this:
498
+ *
499
+ * const NameChangeStatus = {
500
+ * PENDING: 'PENDING',
501
+ * DENIED: 'DENIED',
502
+ * APPROVED: 'APPROVED',
503
+ * }
504
+ *
505
+ * And because I'd hate having to call enum values in lowercase, like:
506
+ * NameChangeStatus.pending
507
+ * Metric.king_black_dragon
508
+ * Period.day
509
+ *
510
+ * I'd rather do some mapping to ensure I have the best of both worlds,
511
+ * lowercase database values, but with uppercase in code.
512
+ * With the mappings below, we can now use prisma enums by calling them with uppercase, like:
513
+ *
514
+ * NameChangeStatus.PENDING
515
+ * Metric.KING_BLACK_DRAGON
516
+ * Period.DAY
517
+ *
518
+ */
519
+ const Skill = {
520
+ OVERALL: 'overall',
521
+ ATTACK: 'attack',
522
+ DEFENCE: 'defence',
523
+ STRENGTH: 'strength',
524
+ HITPOINTS: 'hitpoints',
525
+ RANGED: 'ranged',
526
+ PRAYER: 'prayer',
527
+ MAGIC: 'magic',
528
+ COOKING: 'cooking',
529
+ WOODCUTTING: 'woodcutting',
530
+ FLETCHING: 'fletching',
531
+ FISHING: 'fishing',
532
+ FIREMAKING: 'firemaking',
533
+ CRAFTING: 'crafting',
534
+ SMITHING: 'smithing',
535
+ MINING: 'mining',
536
+ HERBLORE: 'herblore',
537
+ AGILITY: 'agility',
538
+ THIEVING: 'thieving',
539
+ SLAYER: 'slayer',
540
+ FARMING: 'farming',
541
+ RUNECRAFTING: 'runecrafting',
542
+ HUNTER: 'hunter',
543
+ CONSTRUCTION: 'construction'
544
+ };
545
+ const Activity = {
546
+ LEAGUE_POINTS: 'league_points',
547
+ BOUNTY_HUNTER_HUNTER: 'bounty_hunter_hunter',
548
+ BOUNTY_HUNTER_ROGUE: 'bounty_hunter_rogue',
549
+ CLUE_SCROLLS_ALL: 'clue_scrolls_all',
550
+ CLUE_SCROLLS_BEGINNER: 'clue_scrolls_beginner',
551
+ CLUE_SCROLLS_EASY: 'clue_scrolls_easy',
552
+ CLUE_SCROLLS_MEDIUM: 'clue_scrolls_medium',
553
+ CLUE_SCROLLS_HARD: 'clue_scrolls_hard',
554
+ CLUE_SCROLLS_ELITE: 'clue_scrolls_elite',
555
+ CLUE_SCROLLS_MASTER: 'clue_scrolls_master',
556
+ LAST_MAN_STANDING: 'last_man_standing',
557
+ PVP_ARENA: 'pvp_arena',
558
+ SOUL_WARS_ZEAL: 'soul_wars_zeal',
559
+ GUARDIANS_OF_THE_RIFT: 'guardians_of_the_rift'
560
+ };
561
+ const Boss = {
562
+ ABYSSAL_SIRE: 'abyssal_sire',
563
+ ALCHEMICAL_HYDRA: 'alchemical_hydra',
564
+ ARTIO: 'artio',
565
+ BARROWS_CHESTS: 'barrows_chests',
566
+ BRYOPHYTA: 'bryophyta',
567
+ CALLISTO: 'callisto',
568
+ CALVARION: 'calvarion',
569
+ CERBERUS: 'cerberus',
570
+ CHAMBERS_OF_XERIC: 'chambers_of_xeric',
571
+ CHAMBERS_OF_XERIC_CM: 'chambers_of_xeric_challenge_mode',
572
+ CHAOS_ELEMENTAL: 'chaos_elemental',
573
+ CHAOS_FANATIC: 'chaos_fanatic',
574
+ COMMANDER_ZILYANA: 'commander_zilyana',
575
+ CORPOREAL_BEAST: 'corporeal_beast',
576
+ CRAZY_ARCHAEOLOGIST: 'crazy_archaeologist',
577
+ DAGANNOTH_PRIME: 'dagannoth_prime',
578
+ DAGANNOTH_REX: 'dagannoth_rex',
579
+ DAGANNOTH_SUPREME: 'dagannoth_supreme',
580
+ DERANGED_ARCHAEOLOGIST: 'deranged_archaeologist',
581
+ DUKE_SUCELLUS: 'duke_sucellus',
582
+ GENERAL_GRAARDOR: 'general_graardor',
583
+ GIANT_MOLE: 'giant_mole',
584
+ GROTESQUE_GUARDIANS: 'grotesque_guardians',
585
+ HESPORI: 'hespori',
586
+ KALPHITE_QUEEN: 'kalphite_queen',
587
+ KING_BLACK_DRAGON: 'king_black_dragon',
588
+ KRAKEN: 'kraken',
589
+ KREEARRA: 'kreearra',
590
+ KRIL_TSUTSAROTH: 'kril_tsutsaroth',
591
+ MIMIC: 'mimic',
592
+ NEX: 'nex',
593
+ NIGHTMARE: 'nightmare',
594
+ PHOSANIS_NIGHTMARE: 'phosanis_nightmare',
595
+ OBOR: 'obor',
596
+ PHANTOM_MUSPAH: 'phantom_muspah',
597
+ SARACHNIS: 'sarachnis',
598
+ SCORPIA: 'scorpia',
599
+ SCURRIUS: 'scurrius',
600
+ SKOTIZO: 'skotizo',
601
+ SPINDEL: 'spindel',
602
+ TEMPOROSS: 'tempoross',
603
+ THE_GAUNTLET: 'the_gauntlet',
604
+ THE_CORRUPTED_GAUNTLET: 'the_corrupted_gauntlet',
605
+ THE_LEVIATHAN: 'the_leviathan',
606
+ THE_WHISPERER: 'the_whisperer',
607
+ THEATRE_OF_BLOOD: 'theatre_of_blood',
608
+ THEATRE_OF_BLOOD_HARD_MODE: 'theatre_of_blood_hard_mode',
609
+ THERMONUCLEAR_SMOKE_DEVIL: 'thermonuclear_smoke_devil',
610
+ TOMBS_OF_AMASCUT: 'tombs_of_amascut',
611
+ TOMBS_OF_AMASCUT_EXPERT: 'tombs_of_amascut_expert',
612
+ TZKAL_ZUK: 'tzkal_zuk',
613
+ TZTOK_JAD: 'tztok_jad',
614
+ VARDORVIS: 'vardorvis',
615
+ VENENATIS: 'venenatis',
616
+ VETION: 'vetion',
617
+ VORKATH: 'vorkath',
618
+ WINTERTODT: 'wintertodt',
619
+ ZALCANO: 'zalcano',
620
+ ZULRAH: 'zulrah'
621
+ };
622
+ const ComputedMetric = {
623
+ EHP: 'ehp',
624
+ EHB: 'ehb'
625
+ };
626
+ const Metric = Object.assign(Object.assign(Object.assign(Object.assign({}, Skill), Activity), Boss), ComputedMetric);
627
+ const NameChangeStatus = {
628
+ PENDING: 'pending',
629
+ DENIED: 'denied',
630
+ APPROVED: 'approved'
631
+ };
632
+ const Period = {
633
+ FIVE_MIN: 'five_min',
634
+ DAY: 'day',
635
+ WEEK: 'week',
636
+ MONTH: 'month',
637
+ YEAR: 'year'
638
+ };
639
+ const PlayerType = {
640
+ UNKNOWN: 'unknown',
641
+ REGULAR: 'regular',
642
+ IRONMAN: 'ironman',
643
+ HARDCORE: 'hardcore',
644
+ ULTIMATE: 'ultimate'
645
+ };
646
+ const PlayerBuild = {
647
+ MAIN: 'main',
648
+ F2P: 'f2p',
649
+ F2P_LVL3: 'f2p_lvl3',
650
+ LVL3: 'lvl3',
651
+ ZERKER: 'zerker',
652
+ DEF1: 'def1',
653
+ HP10: 'hp10'
654
+ };
655
+ const PlayerStatus = {
656
+ ACTIVE: 'active',
657
+ UNRANKED: 'unranked',
658
+ FLAGGED: 'flagged',
659
+ ARCHIVED: 'archived',
660
+ BANNED: 'banned'
661
+ };
662
+ const CompetitionType = {
663
+ CLASSIC: 'classic',
664
+ TEAM: 'team'
665
+ };
666
+ const GroupRole = {
667
+ ACHIEVER: 'achiever',
668
+ ADAMANT: 'adamant',
669
+ ADEPT: 'adept',
670
+ ADMINISTRATOR: 'administrator',
671
+ ADMIRAL: 'admiral',
672
+ ADVENTURER: 'adventurer',
673
+ AIR: 'air',
674
+ ANCHOR: 'anchor',
675
+ APOTHECARY: 'apothecary',
676
+ ARCHER: 'archer',
677
+ ARMADYLEAN: 'armadylean',
678
+ ARTILLERY: 'artillery',
679
+ ARTISAN: 'artisan',
680
+ ASGARNIAN: 'asgarnian',
681
+ ASSASSIN: 'assassin',
682
+ ASSISTANT: 'assistant',
683
+ ASTRAL: 'astral',
684
+ ATHLETE: 'athlete',
685
+ ATTACKER: 'attacker',
686
+ BANDIT: 'bandit',
687
+ BANDOSIAN: 'bandosian',
688
+ BARBARIAN: 'barbarian',
689
+ BATTLEMAGE: 'battlemage',
690
+ BEAST: 'beast',
691
+ BERSERKER: 'berserker',
692
+ BLISTERWOOD: 'blisterwood',
693
+ BLOOD: 'blood',
694
+ BLUE: 'blue',
695
+ BOB: 'bob',
696
+ BODY: 'body',
697
+ BRASSICAN: 'brassican',
698
+ BRAWLER: 'brawler',
699
+ BRIGADIER: 'brigadier',
700
+ BRIGAND: 'brigand',
701
+ BRONZE: 'bronze',
702
+ BRUISER: 'bruiser',
703
+ BULWARK: 'bulwark',
704
+ BURGLAR: 'burglar',
705
+ BURNT: 'burnt',
706
+ CADET: 'cadet',
707
+ CAPTAIN: 'captain',
708
+ CARRY: 'carry',
709
+ CHAMPION: 'champion',
710
+ CHAOS: 'chaos',
711
+ CLERIC: 'cleric',
712
+ COLLECTOR: 'collector',
713
+ COLONEL: 'colonel',
714
+ COMMANDER: 'commander',
715
+ COMPETITOR: 'competitor',
716
+ COMPLETIONIST: 'completionist',
717
+ CONSTRUCTOR: 'constructor',
718
+ COOK: 'cook',
719
+ COORDINATOR: 'coordinator',
720
+ CORPORAL: 'corporal',
721
+ COSMIC: 'cosmic',
722
+ COUNCILLOR: 'councillor',
723
+ CRAFTER: 'crafter',
724
+ CREW: 'crew',
725
+ CRUSADER: 'crusader',
726
+ CUTPURSE: 'cutpurse',
727
+ DEATH: 'death',
728
+ DEFENDER: 'defender',
729
+ DEFILER: 'defiler',
730
+ DEPUTY_OWNER: 'deputy_owner',
731
+ DESTROYER: 'destroyer',
732
+ DIAMOND: 'diamond',
733
+ DISEASED: 'diseased',
734
+ DOCTOR: 'doctor',
735
+ DOGSBODY: 'dogsbody',
736
+ DRAGON: 'dragon',
737
+ DRAGONSTONE: 'dragonstone',
738
+ DRUID: 'druid',
739
+ DUELLIST: 'duellist',
740
+ EARTH: 'earth',
741
+ ELITE: 'elite',
742
+ EMERALD: 'emerald',
743
+ ENFORCER: 'enforcer',
744
+ EPIC: 'epic',
745
+ EXECUTIVE: 'executive',
746
+ EXPERT: 'expert',
747
+ EXPLORER: 'explorer',
748
+ FARMER: 'farmer',
749
+ FEEDER: 'feeder',
750
+ FIGHTER: 'fighter',
751
+ FIRE: 'fire',
752
+ FIREMAKER: 'firemaker',
753
+ FIRESTARTER: 'firestarter',
754
+ FISHER: 'fisher',
755
+ FLETCHER: 'fletcher',
756
+ FORAGER: 'forager',
757
+ FREMENNIK: 'fremennik',
758
+ GAMER: 'gamer',
759
+ GATHERER: 'gatherer',
760
+ GENERAL: 'general',
761
+ GNOME_CHILD: 'gnome_child',
762
+ GNOME_ELDER: 'gnome_elder',
763
+ GOBLIN: 'goblin',
764
+ GOLD: 'gold',
765
+ GOON: 'goon',
766
+ GREEN: 'green',
767
+ GREY: 'grey',
768
+ GUARDIAN: 'guardian',
769
+ GUTHIXIAN: 'guthixian',
770
+ HARPOON: 'harpoon',
771
+ HEALER: 'healer',
772
+ HELLCAT: 'hellcat',
773
+ HELPER: 'helper',
774
+ HERBOLOGIST: 'herbologist',
775
+ HERO: 'hero',
776
+ HOLY: 'holy',
777
+ HOARDER: 'hoarder',
778
+ HUNTER: 'hunter',
779
+ IGNITOR: 'ignitor',
780
+ ILLUSIONIST: 'illusionist',
781
+ IMP: 'imp',
782
+ INFANTRY: 'infantry',
783
+ INQUISITOR: 'inquisitor',
784
+ IRON: 'iron',
785
+ JADE: 'jade',
786
+ JUSTICIAR: 'justiciar',
787
+ KANDARIN: 'kandarin',
788
+ KARAMJAN: 'karamjan',
789
+ KHARIDIAN: 'kharidian',
790
+ KITTEN: 'kitten',
791
+ KNIGHT: 'knight',
792
+ LABOURER: 'labourer',
793
+ LAW: 'law',
794
+ LEADER: 'leader',
795
+ LEARNER: 'learner',
796
+ LEGACY: 'legacy',
797
+ LEGEND: 'legend',
798
+ LEGIONNAIRE: 'legionnaire',
799
+ LIEUTENANT: 'lieutenant',
800
+ LOOTER: 'looter',
801
+ LUMBERJACK: 'lumberjack',
802
+ MAGIC: 'magic',
803
+ MAGICIAN: 'magician',
804
+ MAJOR: 'major',
805
+ MAPLE: 'maple',
806
+ MARSHAL: 'marshal',
807
+ MASTER: 'master',
808
+ MAXED: 'maxed',
809
+ MEDIATOR: 'mediator',
810
+ MEDIC: 'medic',
811
+ MENTOR: 'mentor',
812
+ MEMBER: 'member',
813
+ MERCHANT: 'merchant',
814
+ MIND: 'mind',
815
+ MINER: 'miner',
816
+ MINION: 'minion',
817
+ MISTHALINIAN: 'misthalinian',
818
+ MITHRIL: 'mithril',
819
+ MODERATOR: 'moderator',
820
+ MONARCH: 'monarch',
821
+ MORYTANIAN: 'morytanian',
822
+ MYSTIC: 'mystic',
823
+ MYTH: 'myth',
824
+ NATURAL: 'natural',
825
+ NATURE: 'nature',
826
+ NECROMANCER: 'necromancer',
827
+ NINJA: 'ninja',
828
+ NOBLE: 'noble',
829
+ NOVICE: 'novice',
830
+ NURSE: 'nurse',
831
+ OAK: 'oak',
832
+ OFFICER: 'officer',
833
+ ONYX: 'onyx',
834
+ OPAL: 'opal',
835
+ ORACLE: 'oracle',
836
+ ORANGE: 'orange',
837
+ OWNER: 'owner',
838
+ PAGE: 'page',
839
+ PALADIN: 'paladin',
840
+ PAWN: 'pawn',
841
+ PILGRIM: 'pilgrim',
842
+ PINE: 'pine',
843
+ PINK: 'pink',
844
+ PREFECT: 'prefect',
845
+ PRIEST: 'priest',
846
+ PRIVATE: 'private',
847
+ PRODIGY: 'prodigy',
848
+ PROSELYTE: 'proselyte',
849
+ PROSPECTOR: 'prospector',
850
+ PROTECTOR: 'protector',
851
+ PURE: 'pure',
852
+ PURPLE: 'purple',
853
+ PYROMANCER: 'pyromancer',
854
+ QUESTER: 'quester',
855
+ RACER: 'racer',
856
+ RAIDER: 'raider',
857
+ RANGER: 'ranger',
858
+ RECORD_CHASER: 'record_chaser',
859
+ RECRUIT: 'recruit',
860
+ RECRUITER: 'recruiter',
861
+ RED_TOPAZ: 'red_topaz',
862
+ RED: 'red',
863
+ ROGUE: 'rogue',
864
+ RUBY: 'ruby',
865
+ RUNE: 'rune',
866
+ RUNECRAFTER: 'runecrafter',
867
+ SAGE: 'sage',
868
+ SAPPHIRE: 'sapphire',
869
+ SARADOMINIST: 'saradominist',
870
+ SAVIOUR: 'saviour',
871
+ SCAVENGER: 'scavenger',
872
+ SCHOLAR: 'scholar',
873
+ SCOURGE: 'scourge',
874
+ SCOUT: 'scout',
875
+ SCRIBE: 'scribe',
876
+ SEER: 'seer',
877
+ SENATOR: 'senator',
878
+ SENTRY: 'sentry',
879
+ SERENIST: 'serenist',
880
+ SERGEANT: 'sergeant',
881
+ SHAMAN: 'shaman',
882
+ SHERIFF: 'sheriff',
883
+ SHORT_GREEN_GUY: 'short_green_guy',
884
+ SKILLER: 'skiller',
885
+ SKULLED: 'skulled',
886
+ SLAYER: 'slayer',
887
+ SMITER: 'smiter',
888
+ SMITH: 'smith',
889
+ SMUGGLER: 'smuggler',
890
+ SNIPER: 'sniper',
891
+ SOUL: 'soul',
892
+ SPECIALIST: 'specialist',
893
+ SPEED_RUNNER: 'speed_runner',
894
+ SPELLCASTER: 'spellcaster',
895
+ SQUIRE: 'squire',
896
+ STAFF: 'staff',
897
+ STEEL: 'steel',
898
+ STRIDER: 'strider',
899
+ STRIKER: 'striker',
900
+ SUMMONER: 'summoner',
901
+ SUPERIOR: 'superior',
902
+ SUPERVISOR: 'supervisor',
903
+ TEACHER: 'teacher',
904
+ TEMPLAR: 'templar',
905
+ THERAPIST: 'therapist',
906
+ THIEF: 'thief',
907
+ TIRANNIAN: 'tirannian',
908
+ TRIALIST: 'trialist',
909
+ TRICKSTER: 'trickster',
910
+ TZKAL: 'tzkal',
911
+ TZTOK: 'tztok',
912
+ UNHOLY: 'unholy',
913
+ VAGRANT: 'vagrant',
914
+ VANGUARD: 'vanguard',
915
+ WALKER: 'walker',
916
+ WANDERER: 'wanderer',
917
+ WARDEN: 'warden',
918
+ WARLOCK: 'warlock',
919
+ WARRIOR: 'warrior',
920
+ WATER: 'water',
921
+ WILD: 'wild',
922
+ WILLOW: 'willow',
923
+ WILY: 'wily',
924
+ WINTUMBER: 'wintumber',
925
+ WITCH: 'witch',
926
+ WIZARD: 'wizard',
927
+ WORKER: 'worker',
928
+ WRATH: 'wrath',
929
+ XERICIAN: 'xerician',
930
+ YELLOW: 'yellow',
931
+ YEW: 'yew',
932
+ ZAMORAKIAN: 'zamorakian',
933
+ ZAROSIAN: 'zarosian',
934
+ ZEALOT: 'zealot',
935
+ ZENYTE: 'zenyte'
936
+ };
937
+ const Country = {
938
+ AD: 'AD',
939
+ AE: 'AE',
940
+ AF: 'AF',
941
+ AG: 'AG',
942
+ AI: 'AI',
943
+ AL: 'AL',
944
+ AM: 'AM',
945
+ AO: 'AO',
946
+ AQ: 'AQ',
947
+ AR: 'AR',
948
+ AS: 'AS',
949
+ AT: 'AT',
950
+ AU: 'AU',
951
+ AW: 'AW',
952
+ AX: 'AX',
953
+ AZ: 'AZ',
954
+ BA: 'BA',
955
+ BB: 'BB',
956
+ BD: 'BD',
957
+ BE: 'BE',
958
+ BF: 'BF',
959
+ BG: 'BG',
960
+ BH: 'BH',
961
+ BI: 'BI',
962
+ BJ: 'BJ',
963
+ BL: 'BL',
964
+ BM: 'BM',
965
+ BN: 'BN',
966
+ BO: 'BO',
967
+ BQ: 'BQ',
968
+ BR: 'BR',
969
+ BS: 'BS',
970
+ BT: 'BT',
971
+ BV: 'BV',
972
+ BW: 'BW',
973
+ BY: 'BY',
974
+ BZ: 'BZ',
975
+ CA: 'CA',
976
+ CC: 'CC',
977
+ CD: 'CD',
978
+ CF: 'CF',
979
+ CG: 'CG',
980
+ CH: 'CH',
981
+ CI: 'CI',
982
+ CK: 'CK',
983
+ CL: 'CL',
984
+ CM: 'CM',
985
+ CN: 'CN',
986
+ CO: 'CO',
987
+ CR: 'CR',
988
+ CU: 'CU',
989
+ CV: 'CV',
990
+ CW: 'CW',
991
+ CX: 'CX',
992
+ CY: 'CY',
993
+ CZ: 'CZ',
994
+ DE: 'DE',
995
+ DJ: 'DJ',
996
+ DK: 'DK',
997
+ DM: 'DM',
998
+ DO: 'DO',
999
+ DZ: 'DZ',
1000
+ EC: 'EC',
1001
+ EE: 'EE',
1002
+ EG: 'EG',
1003
+ EH: 'EH',
1004
+ ER: 'ER',
1005
+ ES: 'ES',
1006
+ ET: 'ET',
1007
+ FI: 'FI',
1008
+ FJ: 'FJ',
1009
+ FK: 'FK',
1010
+ FM: 'FM',
1011
+ FO: 'FO',
1012
+ FR: 'FR',
1013
+ GA: 'GA',
1014
+ GB: 'GB',
1015
+ GD: 'GD',
1016
+ GE: 'GE',
1017
+ GF: 'GF',
1018
+ GG: 'GG',
1019
+ GH: 'GH',
1020
+ GI: 'GI',
1021
+ GL: 'GL',
1022
+ GM: 'GM',
1023
+ GN: 'GN',
1024
+ GP: 'GP',
1025
+ GQ: 'GQ',
1026
+ GR: 'GR',
1027
+ GS: 'GS',
1028
+ GT: 'GT',
1029
+ GU: 'GU',
1030
+ GW: 'GW',
1031
+ GY: 'GY',
1032
+ HK: 'HK',
1033
+ HM: 'HM',
1034
+ HN: 'HN',
1035
+ HR: 'HR',
1036
+ HT: 'HT',
1037
+ HU: 'HU',
1038
+ ID: 'ID',
1039
+ IE: 'IE',
1040
+ IL: 'IL',
1041
+ IM: 'IM',
1042
+ IN: 'IN',
1043
+ IO: 'IO',
1044
+ IQ: 'IQ',
1045
+ IR: 'IR',
1046
+ IS: 'IS',
1047
+ IT: 'IT',
1048
+ JE: 'JE',
1049
+ JM: 'JM',
1050
+ JO: 'JO',
1051
+ JP: 'JP',
1052
+ KE: 'KE',
1053
+ KG: 'KG',
1054
+ KH: 'KH',
1055
+ KI: 'KI',
1056
+ KM: 'KM',
1057
+ KN: 'KN',
1058
+ KP: 'KP',
1059
+ KR: 'KR',
1060
+ KW: 'KW',
1061
+ KY: 'KY',
1062
+ KZ: 'KZ',
1063
+ LA: 'LA',
1064
+ LB: 'LB',
1065
+ LC: 'LC',
1066
+ LI: 'LI',
1067
+ LK: 'LK',
1068
+ LR: 'LR',
1069
+ LS: 'LS',
1070
+ LT: 'LT',
1071
+ LU: 'LU',
1072
+ LV: 'LV',
1073
+ LY: 'LY',
1074
+ MA: 'MA',
1075
+ MC: 'MC',
1076
+ MD: 'MD',
1077
+ ME: 'ME',
1078
+ MF: 'MF',
1079
+ MG: 'MG',
1080
+ MH: 'MH',
1081
+ MK: 'MK',
1082
+ ML: 'ML',
1083
+ MM: 'MM',
1084
+ MN: 'MN',
1085
+ MO: 'MO',
1086
+ MP: 'MP',
1087
+ MQ: 'MQ',
1088
+ MR: 'MR',
1089
+ MS: 'MS',
1090
+ MT: 'MT',
1091
+ MU: 'MU',
1092
+ MV: 'MV',
1093
+ MW: 'MW',
1094
+ MX: 'MX',
1095
+ MY: 'MY',
1096
+ MZ: 'MZ',
1097
+ NA: 'NA',
1098
+ NC: 'NC',
1099
+ NE: 'NE',
1100
+ NF: 'NF',
1101
+ NG: 'NG',
1102
+ NI: 'NI',
1103
+ NL: 'NL',
1104
+ NO: 'NO',
1105
+ NP: 'NP',
1106
+ NR: 'NR',
1107
+ NU: 'NU',
1108
+ NZ: 'NZ',
1109
+ OM: 'OM',
1110
+ PA: 'PA',
1111
+ PE: 'PE',
1112
+ PF: 'PF',
1113
+ PG: 'PG',
1114
+ PH: 'PH',
1115
+ PK: 'PK',
1116
+ PL: 'PL',
1117
+ PM: 'PM',
1118
+ PN: 'PN',
1119
+ PR: 'PR',
1120
+ PS: 'PS',
1121
+ PT: 'PT',
1122
+ PW: 'PW',
1123
+ PY: 'PY',
1124
+ QA: 'QA',
1125
+ RE: 'RE',
1126
+ RO: 'RO',
1127
+ RS: 'RS',
1128
+ RU: 'RU',
1129
+ RW: 'RW',
1130
+ SA: 'SA',
1131
+ SB: 'SB',
1132
+ SC: 'SC',
1133
+ SD: 'SD',
1134
+ SE: 'SE',
1135
+ SG: 'SG',
1136
+ SH: 'SH',
1137
+ SI: 'SI',
1138
+ SJ: 'SJ',
1139
+ SK: 'SK',
1140
+ SL: 'SL',
1141
+ SM: 'SM',
1142
+ SN: 'SN',
1143
+ SO: 'SO',
1144
+ SR: 'SR',
1145
+ SS: 'SS',
1146
+ ST: 'ST',
1147
+ SV: 'SV',
1148
+ SX: 'SX',
1149
+ SY: 'SY',
1150
+ SZ: 'SZ',
1151
+ TC: 'TC',
1152
+ TD: 'TD',
1153
+ TF: 'TF',
1154
+ TG: 'TG',
1155
+ TH: 'TH',
1156
+ TJ: 'TJ',
1157
+ TK: 'TK',
1158
+ TL: 'TL',
1159
+ TM: 'TM',
1160
+ TN: 'TN',
1161
+ TO: 'TO',
1162
+ TR: 'TR',
1163
+ TT: 'TT',
1164
+ TV: 'TV',
1165
+ TW: 'TW',
1166
+ TZ: 'TZ',
1167
+ UA: 'UA',
1168
+ UG: 'UG',
1169
+ UM: 'UM',
1170
+ US: 'US',
1171
+ UY: 'UY',
1172
+ UZ: 'UZ',
1173
+ VA: 'VA',
1174
+ VC: 'VC',
1175
+ VE: 'VE',
1176
+ VG: 'VG',
1177
+ VI: 'VI',
1178
+ VN: 'VN',
1179
+ VU: 'VU',
1180
+ WF: 'WF',
1181
+ WS: 'WS',
1182
+ YE: 'YE',
1183
+ YT: 'YT',
1184
+ ZA: 'ZA',
1185
+ ZM: 'ZM',
1186
+ ZW: 'ZW'
1187
+ };
1188
+ const ActivityType = {
1189
+ JOINED: 'joined',
1190
+ LEFT: 'left',
1191
+ CHANGED_ROLE: 'changed_role'
1192
+ };
1193
+
1194
+ var CompetitionStatus;
1195
+ (function (CompetitionStatus) {
1196
+ CompetitionStatus["UPCOMING"] = "upcoming";
1197
+ CompetitionStatus["ONGOING"] = "ongoing";
1198
+ CompetitionStatus["FINISHED"] = "finished";
1199
+ })(CompetitionStatus || (CompetitionStatus = {}));
1200
+ var CompetitionCSVTableType;
1201
+ (function (CompetitionCSVTableType) {
1202
+ CompetitionCSVTableType["TEAM"] = "team";
1203
+ CompetitionCSVTableType["TEAMS"] = "teams";
1204
+ CompetitionCSVTableType["PARTICIPANTS"] = "participants";
1205
+ })(CompetitionCSVTableType || (CompetitionCSVTableType = {}));
1206
+ const CompetitionTypeProps = {
1207
+ [CompetitionType.CLASSIC]: { name: 'Classic' },
1208
+ [CompetitionType.TEAM]: { name: 'Team' }
1209
+ };
1210
+ const CompetitionStatusProps = {
1211
+ [CompetitionStatus.UPCOMING]: { name: 'Upcoming' },
1212
+ [CompetitionStatus.ONGOING]: { name: 'Ongoing' },
1213
+ [CompetitionStatus.FINISHED]: { name: 'Finished' }
1214
+ };
1215
+ const COMPETITION_TYPES = Object.values(CompetitionType);
1216
+ const COMPETITION_STATUSES = Object.values(CompetitionStatus);
1217
+ function isCompetitionType(typeString) {
1218
+ return typeString in CompetitionTypeProps;
1219
+ }
1220
+ function isCompetitionStatus(statusString) {
1221
+ return statusString in CompetitionStatusProps;
1222
+ }
1223
+
1224
+ const CountryProps = {
1225
+ [Country.AD]: { code: 'AD', name: 'Andorra' },
1226
+ [Country.AE]: { code: 'AE', name: 'United Arab Emirates' },
1227
+ [Country.AF]: { code: 'AF', name: 'Afghanistan' },
1228
+ [Country.AG]: { code: 'AG', name: 'Antigua and Barbuda' },
1229
+ [Country.AI]: { code: 'AI', name: 'Anguilla' },
1230
+ [Country.AL]: { code: 'AL', name: 'Albania' },
1231
+ [Country.AM]: { code: 'AM', name: 'Armenia' },
1232
+ [Country.AO]: { code: 'AO', name: 'Angola' },
1233
+ [Country.AQ]: { code: 'AQ', name: 'Antarctica' },
1234
+ [Country.AR]: { code: 'AR', name: 'Argentina' },
1235
+ [Country.AS]: { code: 'AS', name: 'American Samoa' },
1236
+ [Country.AT]: { code: 'AT', name: 'Austria' },
1237
+ [Country.AU]: { code: 'AU', name: 'Australia' },
1238
+ [Country.AW]: { code: 'AW', name: 'Aruba' },
1239
+ [Country.AX]: { code: 'AX', name: 'Åland Islands' },
1240
+ [Country.AZ]: { code: 'AZ', name: 'Azerbaijan' },
1241
+ [Country.BA]: { code: 'BA', name: 'Bosnia and Herzegovina' },
1242
+ [Country.BB]: { code: 'BB', name: 'Barbados' },
1243
+ [Country.BD]: { code: 'BD', name: 'Bangladesh' },
1244
+ [Country.BE]: { code: 'BE', name: 'Belgium' },
1245
+ [Country.BF]: { code: 'BF', name: 'Burkina Faso' },
1246
+ [Country.BG]: { code: 'BG', name: 'Bulgaria' },
1247
+ [Country.BH]: { code: 'BH', name: 'Bahrain' },
1248
+ [Country.BI]: { code: 'BI', name: 'Burundi' },
1249
+ [Country.BJ]: { code: 'BJ', name: 'Benin' },
1250
+ [Country.BL]: { code: 'BL', name: 'Saint Barthélemy' },
1251
+ [Country.BM]: { code: 'BM', name: 'Bermuda' },
1252
+ [Country.BN]: { code: 'BN', name: 'Brunei Darussalam' },
1253
+ [Country.BO]: { code: 'BO', name: 'Bolivia' },
1254
+ [Country.BQ]: { code: 'BQ', name: 'Bonaire' },
1255
+ [Country.BR]: { code: 'BR', name: 'Brazil' },
1256
+ [Country.BS]: { code: 'BS', name: 'Bahamas' },
1257
+ [Country.BT]: { code: 'BT', name: 'Bhutan' },
1258
+ [Country.BV]: { code: 'BV', name: 'Bouvet Island' },
1259
+ [Country.BW]: { code: 'BW', name: 'Botswana' },
1260
+ [Country.BY]: { code: 'BY', name: 'Belarus' },
1261
+ [Country.BZ]: { code: 'BZ', name: 'Belize' },
1262
+ [Country.CA]: { code: 'CA', name: 'Canada' },
1263
+ [Country.CC]: { code: 'CC', name: 'Cocos (Keeling) Islands' },
1264
+ [Country.CD]: { code: 'CD', name: 'Congo' },
1265
+ [Country.CF]: { code: 'CF', name: 'Central African Republic' },
1266
+ [Country.CG]: { code: 'CG', name: 'Congo' },
1267
+ [Country.CH]: { code: 'CH', name: 'Switzerland' },
1268
+ [Country.CI]: { code: 'CI', name: "Côte d'Ivoire" },
1269
+ [Country.CK]: { code: 'CK', name: 'Cook Islands' },
1270
+ [Country.CL]: { code: 'CL', name: 'Chile' },
1271
+ [Country.CM]: { code: 'CM', name: 'Cameroon' },
1272
+ [Country.CN]: { code: 'CN', name: 'China' },
1273
+ [Country.CO]: { code: 'CO', name: 'Colombia' },
1274
+ [Country.CR]: { code: 'CR', name: 'Costa Rica' },
1275
+ [Country.CU]: { code: 'CU', name: 'Cuba' },
1276
+ [Country.CV]: { code: 'CV', name: 'Cabo Verde' },
1277
+ [Country.CW]: { code: 'CW', name: 'Curaçao' },
1278
+ [Country.CX]: { code: 'CX', name: 'Christmas Island' },
1279
+ [Country.CY]: { code: 'CY', name: 'Cyprus' },
1280
+ [Country.CZ]: { code: 'CZ', name: 'Czechia' },
1281
+ [Country.DE]: { code: 'DE', name: 'Germany' },
1282
+ [Country.DJ]: { code: 'DJ', name: 'Djibouti' },
1283
+ [Country.DK]: { code: 'DK', name: 'Denmark' },
1284
+ [Country.DM]: { code: 'DM', name: 'Dominica' },
1285
+ [Country.DO]: { code: 'DO', name: 'Dominican Republic' },
1286
+ [Country.DZ]: { code: 'DZ', name: 'Algeria' },
1287
+ [Country.EC]: { code: 'EC', name: 'Ecuador' },
1288
+ [Country.EE]: { code: 'EE', name: 'Estonia' },
1289
+ [Country.EG]: { code: 'EG', name: 'Egypt' },
1290
+ [Country.EH]: { code: 'EH', name: 'Western Sahara' },
1291
+ [Country.ER]: { code: 'ER', name: 'Eritrea' },
1292
+ [Country.ES]: { code: 'ES', name: 'Spain' },
1293
+ [Country.ET]: { code: 'ET', name: 'Ethiopia' },
1294
+ [Country.FI]: { code: 'FI', name: 'Finland' },
1295
+ [Country.FJ]: { code: 'FJ', name: 'Fiji' },
1296
+ [Country.FK]: { code: 'FK', name: 'Falkland Islands (Malvinas)' },
1297
+ [Country.FM]: { code: 'FM', name: 'Micronesia (Federated States of)' },
1298
+ [Country.FO]: { code: 'FO', name: 'Faroe Islands' },
1299
+ [Country.FR]: { code: 'FR', name: 'France' },
1300
+ [Country.GA]: { code: 'GA', name: 'Gabon' },
1301
+ [Country.GB]: { code: 'GB', name: 'United Kingdom' },
1302
+ [Country.GD]: { code: 'GD', name: 'Grenada' },
1303
+ [Country.GE]: { code: 'GE', name: 'Georgia' },
1304
+ [Country.GF]: { code: 'GF', name: 'French Guiana' },
1305
+ [Country.GG]: { code: 'GG', name: 'Guernsey' },
1306
+ [Country.GH]: { code: 'GH', name: 'Ghana' },
1307
+ [Country.GI]: { code: 'GI', name: 'Gibraltar' },
1308
+ [Country.GL]: { code: 'GL', name: 'Greenland' },
1309
+ [Country.GM]: { code: 'GM', name: 'Gambia' },
1310
+ [Country.GN]: { code: 'GN', name: 'Guinea' },
1311
+ [Country.GP]: { code: 'GP', name: 'Guadeloupe' },
1312
+ [Country.GQ]: { code: 'GQ', name: 'Equatorial Guinea' },
1313
+ [Country.GR]: { code: 'GR', name: 'Greece' },
1314
+ [Country.GS]: { code: 'GS', name: 'South Georgia and the South Sandwich Islands' },
1315
+ [Country.GT]: { code: 'GT', name: 'Guatemala' },
1316
+ [Country.GU]: { code: 'GU', name: 'Guam' },
1317
+ [Country.GW]: { code: 'GW', name: 'Guinea-Bissau' },
1318
+ [Country.GY]: { code: 'GY', name: 'Guyana' },
1319
+ [Country.HK]: { code: 'HK', name: 'Hong Kong' },
1320
+ [Country.HM]: { code: 'HM', name: 'Heard Island and McDonald Islands' },
1321
+ [Country.HN]: { code: 'HN', name: 'Honduras' },
1322
+ [Country.HR]: { code: 'HR', name: 'Croatia' },
1323
+ [Country.HT]: { code: 'HT', name: 'Haiti' },
1324
+ [Country.HU]: { code: 'HU', name: 'Hungary' },
1325
+ [Country.ID]: { code: 'ID', name: 'Indonesia' },
1326
+ [Country.IE]: { code: 'IE', name: 'Ireland' },
1327
+ [Country.IL]: { code: 'IL', name: 'Israel' },
1328
+ [Country.IM]: { code: 'IM', name: 'Isle of Man' },
1329
+ [Country.IN]: { code: 'IN', name: 'India' },
1330
+ [Country.IO]: { code: 'IO', name: 'British Indian Ocean Territory' },
1331
+ [Country.IQ]: { code: 'IQ', name: 'Iraq' },
1332
+ [Country.IR]: { code: 'IR', name: 'Iran (Islamic Republic of)' },
1333
+ [Country.IS]: { code: 'IS', name: 'Iceland' },
1334
+ [Country.IT]: { code: 'IT', name: 'Italy' },
1335
+ [Country.JE]: { code: 'JE', name: 'Jersey' },
1336
+ [Country.JM]: { code: 'JM', name: 'Jamaica' },
1337
+ [Country.JO]: { code: 'JO', name: 'Jordan' },
1338
+ [Country.JP]: { code: 'JP', name: 'Japan' },
1339
+ [Country.KE]: { code: 'KE', name: 'Kenya' },
1340
+ [Country.KG]: { code: 'KG', name: 'Kyrgyzstan' },
1341
+ [Country.KH]: { code: 'KH', name: 'Cambodia' },
1342
+ [Country.KI]: { code: 'KI', name: 'Kiribati' },
1343
+ [Country.KM]: { code: 'KM', name: 'Comoros' },
1344
+ [Country.KN]: { code: 'KN', name: 'Saint Kitts and Nevis' },
1345
+ [Country.KP]: { code: 'KP', name: "Korea (Democratic People's Republic of)" },
1346
+ [Country.KR]: { code: 'KR', name: 'Korea' },
1347
+ [Country.KW]: { code: 'KW', name: 'Kuwait' },
1348
+ [Country.KY]: { code: 'KY', name: 'Cayman Islands' },
1349
+ [Country.KZ]: { code: 'KZ', name: 'Kazakhstan' },
1350
+ [Country.LA]: { code: 'LA', name: "Lao People's Democratic Republic" },
1351
+ [Country.LB]: { code: 'LB', name: 'Lebanon' },
1352
+ [Country.LC]: { code: 'LC', name: 'Saint Lucia' },
1353
+ [Country.LI]: { code: 'LI', name: 'Liechtenstein' },
1354
+ [Country.LK]: { code: 'LK', name: 'Sri Lanka' },
1355
+ [Country.LR]: { code: 'LR', name: 'Liberia' },
1356
+ [Country.LS]: { code: 'LS', name: 'Lesotho' },
1357
+ [Country.LT]: { code: 'LT', name: 'Lithuania' },
1358
+ [Country.LU]: { code: 'LU', name: 'Luxembourg' },
1359
+ [Country.LV]: { code: 'LV', name: 'Latvia' },
1360
+ [Country.LY]: { code: 'LY', name: 'Libya' },
1361
+ [Country.MA]: { code: 'MA', name: 'Morocco' },
1362
+ [Country.MC]: { code: 'MC', name: 'Monaco' },
1363
+ [Country.MD]: { code: 'MD', name: 'Moldova' },
1364
+ [Country.ME]: { code: 'ME', name: 'Montenegro' },
1365
+ [Country.MF]: { code: 'MF', name: 'Saint Martin (French part)' },
1366
+ [Country.MG]: { code: 'MG', name: 'Madagascar' },
1367
+ [Country.MH]: { code: 'MH', name: 'Marshall Islands' },
1368
+ [Country.MK]: { code: 'MK', name: 'North Macedonia' },
1369
+ [Country.ML]: { code: 'ML', name: 'Mali' },
1370
+ [Country.MM]: { code: 'MM', name: 'Myanmar' },
1371
+ [Country.MN]: { code: 'MN', name: 'Mongolia' },
1372
+ [Country.MO]: { code: 'MO', name: 'Macao' },
1373
+ [Country.MP]: { code: 'MP', name: 'Northern Mariana Islands' },
1374
+ [Country.MQ]: { code: 'MQ', name: 'Martinique' },
1375
+ [Country.MR]: { code: 'MR', name: 'Mauritania' },
1376
+ [Country.MS]: { code: 'MS', name: 'Montserrat' },
1377
+ [Country.MT]: { code: 'MT', name: 'Malta' },
1378
+ [Country.MU]: { code: 'MU', name: 'Mauritius' },
1379
+ [Country.MV]: { code: 'MV', name: 'Maldives' },
1380
+ [Country.MW]: { code: 'MW', name: 'Malawi' },
1381
+ [Country.MX]: { code: 'MX', name: 'Mexico' },
1382
+ [Country.MY]: { code: 'MY', name: 'Malaysia' },
1383
+ [Country.MZ]: { code: 'MZ', name: 'Mozambique' },
1384
+ [Country.NA]: { code: 'NA', name: 'Namibia' },
1385
+ [Country.NC]: { code: 'NC', name: 'New Caledonia' },
1386
+ [Country.NE]: { code: 'NE', name: 'Niger' },
1387
+ [Country.NF]: { code: 'NF', name: 'Norfolk Island' },
1388
+ [Country.NG]: { code: 'NG', name: 'Nigeria' },
1389
+ [Country.NI]: { code: 'NI', name: 'Nicaragua' },
1390
+ [Country.NL]: { code: 'NL', name: 'Netherlands' },
1391
+ [Country.NO]: { code: 'NO', name: 'Norway' },
1392
+ [Country.NP]: { code: 'NP', name: 'Nepal' },
1393
+ [Country.NR]: { code: 'NR', name: 'Nauru' },
1394
+ [Country.NU]: { code: 'NU', name: 'Niue' },
1395
+ [Country.NZ]: { code: 'NZ', name: 'New Zealand' },
1396
+ [Country.OM]: { code: 'OM', name: 'Oman' },
1397
+ [Country.PA]: { code: 'PA', name: 'Panama' },
1398
+ [Country.PE]: { code: 'PE', name: 'Peru' },
1399
+ [Country.PF]: { code: 'PF', name: 'French Polynesia' },
1400
+ [Country.PG]: { code: 'PG', name: 'Papua New Guinea' },
1401
+ [Country.PH]: { code: 'PH', name: 'Philippines' },
1402
+ [Country.PK]: { code: 'PK', name: 'Pakistan' },
1403
+ [Country.PL]: { code: 'PL', name: 'Poland' },
1404
+ [Country.PM]: { code: 'PM', name: 'Saint Pierre and Miquelon' },
1405
+ [Country.PN]: { code: 'PN', name: 'Pitcairn' },
1406
+ [Country.PR]: { code: 'PR', name: 'Puerto Rico' },
1407
+ [Country.PS]: { code: 'PS', name: 'Palestine' },
1408
+ [Country.PT]: { code: 'PT', name: 'Portugal' },
1409
+ [Country.PW]: { code: 'PW', name: 'Palau' },
1410
+ [Country.PY]: { code: 'PY', name: 'Paraguay' },
1411
+ [Country.QA]: { code: 'QA', name: 'Qatar' },
1412
+ [Country.RE]: { code: 'RE', name: 'Réunion' },
1413
+ [Country.RO]: { code: 'RO', name: 'Romania' },
1414
+ [Country.RS]: { code: 'RS', name: 'Serbia' },
1415
+ [Country.RU]: { code: 'RU', name: 'Russian Federation' },
1416
+ [Country.RW]: { code: 'RW', name: 'Rwanda' },
1417
+ [Country.SA]: { code: 'SA', name: 'Saudi Arabia' },
1418
+ [Country.SB]: { code: 'SB', name: 'Solomon Islands' },
1419
+ [Country.SC]: { code: 'SC', name: 'Seychelles' },
1420
+ [Country.SD]: { code: 'SD', name: 'Sudan' },
1421
+ [Country.SE]: { code: 'SE', name: 'Sweden' },
1422
+ [Country.SG]: { code: 'SG', name: 'Singapore' },
1423
+ [Country.SH]: { code: 'SH', name: 'Saint Helena' },
1424
+ [Country.SI]: { code: 'SI', name: 'Slovenia' },
1425
+ [Country.SJ]: { code: 'SJ', name: 'Svalbard and Jan Mayen' },
1426
+ [Country.SK]: { code: 'SK', name: 'Slovakia' },
1427
+ [Country.SL]: { code: 'SL', name: 'Sierra Leone' },
1428
+ [Country.SM]: { code: 'SM', name: 'San Marino' },
1429
+ [Country.SN]: { code: 'SN', name: 'Senegal' },
1430
+ [Country.SO]: { code: 'SO', name: 'Somalia' },
1431
+ [Country.SR]: { code: 'SR', name: 'Suriname' },
1432
+ [Country.SS]: { code: 'SS', name: 'South Sudan' },
1433
+ [Country.ST]: { code: 'ST', name: 'Sao Tome and Principe' },
1434
+ [Country.SV]: { code: 'SV', name: 'El Salvador' },
1435
+ [Country.SX]: { code: 'SX', name: 'Sint Maarten (Dutch part)' },
1436
+ [Country.SY]: { code: 'SY', name: 'Syrian Arab Republic' },
1437
+ [Country.SZ]: { code: 'SZ', name: 'Eswatini' },
1438
+ [Country.TC]: { code: 'TC', name: 'Turks and Caicos Islands' },
1439
+ [Country.TD]: { code: 'TD', name: 'Chad' },
1440
+ [Country.TF]: { code: 'TF', name: 'French Southern Territories' },
1441
+ [Country.TG]: { code: 'TG', name: 'Togo' },
1442
+ [Country.TH]: { code: 'TH', name: 'Thailand' },
1443
+ [Country.TJ]: { code: 'TJ', name: 'Tajikistan' },
1444
+ [Country.TK]: { code: 'TK', name: 'Tokelau' },
1445
+ [Country.TL]: { code: 'TL', name: 'Timor-Leste' },
1446
+ [Country.TM]: { code: 'TM', name: 'Turkmenistan' },
1447
+ [Country.TN]: { code: 'TN', name: 'Tunisia' },
1448
+ [Country.TO]: { code: 'TO', name: 'Tonga' },
1449
+ [Country.TR]: { code: 'TR', name: 'Turkey' },
1450
+ [Country.TT]: { code: 'TT', name: 'Trinidad and Tobago' },
1451
+ [Country.TV]: { code: 'TV', name: 'Tuvalu' },
1452
+ [Country.TW]: { code: 'TW', name: 'Taiwan' },
1453
+ [Country.TZ]: { code: 'TZ', name: 'Tanzania' },
1454
+ [Country.UA]: { code: 'UA', name: 'Ukraine' },
1455
+ [Country.UG]: { code: 'UG', name: 'Uganda' },
1456
+ [Country.UM]: { code: 'UM', name: 'United States Minor Outlying Islands' },
1457
+ [Country.US]: { code: 'US', name: 'United States of America' },
1458
+ [Country.UY]: { code: 'UY', name: 'Uruguay' },
1459
+ [Country.UZ]: { code: 'UZ', name: 'Uzbekistan' },
1460
+ [Country.VA]: { code: 'VA', name: 'Holy See' },
1461
+ [Country.VC]: { code: 'VC', name: 'Saint Vincent and the Grenadines' },
1462
+ [Country.VE]: { code: 'VE', name: 'Venezuela (Bolivarian Republic of)' },
1463
+ [Country.VG]: { code: 'VG', name: 'Virgin Islands (British)' },
1464
+ [Country.VI]: { code: 'VI', name: 'Virgin Islands (U.S.)' },
1465
+ [Country.VN]: { code: 'VN', name: 'Viet Nam' },
1466
+ [Country.VU]: { code: 'VU', name: 'Vanuatu' },
1467
+ [Country.WF]: { code: 'WF', name: 'Wallis and Futuna' },
1468
+ [Country.WS]: { code: 'WS', name: 'Samoa' },
1469
+ [Country.YE]: { code: 'YE', name: 'Yemen' },
1470
+ [Country.YT]: { code: 'YT', name: 'Mayotte' },
1471
+ [Country.ZA]: { code: 'ZA', name: 'South Africa' },
1472
+ [Country.ZM]: { code: 'ZM', name: 'Zambia' },
1473
+ [Country.ZW]: { code: 'ZW', name: 'Zimbabwe' }
1474
+ };
1475
+ const COUNTRY_CODES = Object.values(Country);
1476
+ const COMMON_ALIASES = [
1477
+ { commonIdentifier: 'UK', trueIdentifier: 'GB' },
1478
+ { commonIdentifier: 'USA', trueIdentifier: 'US' }
1479
+ ];
1480
+ function isCountry(countryCodeString) {
1481
+ return countryCodeString in CountryProps;
1482
+ }
1483
+ function findCountry(countryIdentifier) {
1484
+ return findCountryByCode(countryIdentifier) || findCountryByName(countryIdentifier);
1485
+ }
1486
+ function findCountryByName(countryName) {
1487
+ return Object.values(CountryProps).find(c => c.name.toUpperCase() === countryName.toUpperCase());
1488
+ }
1489
+ function findCountryByCode(countryCode) {
1490
+ return Object.values(CountryProps).find(c => c.code === replaceCommonAliases(countryCode.toUpperCase()));
1491
+ }
1492
+ function replaceCommonAliases(countryCode) {
1493
+ var _a;
1494
+ if (!countryCode)
1495
+ return null;
1496
+ return ((_a = COMMON_ALIASES.find(ca => ca.commonIdentifier === countryCode)) === null || _a === void 0 ? void 0 : _a.trueIdentifier) || countryCode;
1497
+ }
1498
+
1499
+ // Maximum effective skill level at 13,034,431 experience.
1500
+ const MAX_LEVEL = 99;
1501
+ // The maximum virtual skill level for any skill (200M experience).
1502
+ const MAX_VIRTUAL_LEVEL = 126;
1503
+ // The maximum skill experience (200M experience).
1504
+ const MAX_SKILL_EXP = 200000000;
1505
+ // The minimum skill exp for level 99
1506
+ const SKILL_EXP_AT_99 = 13034431;
1507
+ // The maximum skill at exactly 99 on all skills
1508
+ const CAPPED_MAX_TOTAL_XP = 23 * SKILL_EXP_AT_99;
1509
+ // Builds a lookup table for each level's required experience
1510
+ // exp = XP_FOR_LEVEL[level - 1] || 13m = XP_FOR_LEVEL[98]
1511
+ const XP_FOR_LEVEL = (function () {
1512
+ let xp = 0;
1513
+ const array = [];
1514
+ for (let level = 1; level <= MAX_VIRTUAL_LEVEL; ++level) {
1515
+ array[level - 1] = Math.floor(xp / 4);
1516
+ xp += Math.floor(level + 300 * Math.pow(2, level / 7));
1517
+ }
1518
+ return array;
1519
+ })();
1520
+ function getExpForLevel(level) {
1521
+ if (level < 1 || level > MAX_VIRTUAL_LEVEL)
1522
+ return 0;
1523
+ return XP_FOR_LEVEL[level - 1];
1524
+ }
1525
+ function getLevel(exp, virtual = false) {
1526
+ if (!exp || exp < 0) {
1527
+ return 1;
1528
+ }
1529
+ let low = 0;
1530
+ let high = virtual ? XP_FOR_LEVEL.length - 1 : 98;
1531
+ while (low <= high) {
1532
+ const mid = Math.floor(low + (high - low) / 2);
1533
+ const xpForLevel = XP_FOR_LEVEL[mid];
1534
+ if (exp < xpForLevel) {
1535
+ high = mid - 1;
1536
+ }
1537
+ else if (exp > xpForLevel) {
1538
+ low = mid + 1;
1539
+ }
1540
+ else {
1541
+ return mid + 1;
1542
+ }
1543
+ }
1544
+ return high + 1;
1545
+ }
1546
+ function getCombatLevel(attack, strength, defence, ranged, magic, hitpoints, prayer) {
1547
+ if ([attack, strength, defence, ranged, magic, hitpoints, prayer].some(l => l === 0))
1548
+ return 0;
1549
+ const baseCombat = 0.25 * (defence + Math.max(hitpoints, 10) + Math.floor(prayer / 2));
1550
+ const meleeCombat = 0.325 * (attack + strength);
1551
+ const rangeCombat = 0.325 * Math.floor((3 * ranged) / 2);
1552
+ const mageCombat = 0.325 * Math.floor((3 * magic) / 2);
1553
+ return Math.floor(baseCombat + Math.max(meleeCombat, rangeCombat, mageCombat));
1554
+ }
1555
+
1556
+ function mapValues(obj, callback) {
1557
+ const clone = {};
1558
+ Object.keys(obj).forEach(k => {
1559
+ const key = k;
1560
+ clone[key] = callback(obj[key], key, obj);
1561
+ });
1562
+ return clone;
1563
+ }
1564
+
1565
+ const GROUP_ROLES = Object.values(GroupRole);
1566
+ const PRIVELEGED_GROUP_ROLES = [
1567
+ GroupRole.ADMINISTRATOR,
1568
+ GroupRole.OWNER,
1569
+ GroupRole.LEADER,
1570
+ GroupRole.DEPUTY_OWNER,
1571
+ GroupRole.MODERATOR
1572
+ ];
1573
+ const GroupRoleProps = mapValues({
1574
+ [GroupRole.ACHIEVER]: { name: 'Achiever' },
1575
+ [GroupRole.ADAMANT]: { name: 'Adamant' },
1576
+ [GroupRole.ADEPT]: { name: 'Adept' },
1577
+ [GroupRole.ADMINISTRATOR]: { name: 'Administrator' },
1578
+ [GroupRole.ADMIRAL]: { name: 'Admiral' },
1579
+ [GroupRole.ADVENTURER]: { name: 'Adventurer' },
1580
+ [GroupRole.AIR]: { name: 'Air' },
1581
+ [GroupRole.ANCHOR]: { name: 'Anchor' },
1582
+ [GroupRole.APOTHECARY]: { name: 'Apothecary' },
1583
+ [GroupRole.ARCHER]: { name: 'Archer' },
1584
+ [GroupRole.ARMADYLEAN]: { name: 'Armadylean' },
1585
+ [GroupRole.ARTILLERY]: { name: 'Artillery' },
1586
+ [GroupRole.ARTISAN]: { name: 'Artisan' },
1587
+ [GroupRole.ASGARNIAN]: { name: 'Asgarnian' },
1588
+ [GroupRole.ASSASSIN]: { name: 'Assassin' },
1589
+ [GroupRole.ASSISTANT]: { name: 'Assistant' },
1590
+ [GroupRole.ASTRAL]: { name: 'Astral' },
1591
+ [GroupRole.ATHLETE]: { name: 'Athlete' },
1592
+ [GroupRole.ATTACKER]: { name: 'Attacker' },
1593
+ [GroupRole.BANDIT]: { name: 'Bandit' },
1594
+ [GroupRole.BANDOSIAN]: { name: 'Bandosian' },
1595
+ [GroupRole.BARBARIAN]: { name: 'Barbarian' },
1596
+ [GroupRole.BATTLEMAGE]: { name: 'Battlemage' },
1597
+ [GroupRole.BEAST]: { name: 'Beast' },
1598
+ [GroupRole.BERSERKER]: { name: 'Berserker' },
1599
+ [GroupRole.BLISTERWOOD]: { name: 'Blisterwood' },
1600
+ [GroupRole.BLOOD]: { name: 'Blood' },
1601
+ [GroupRole.BLUE]: { name: 'Blue' },
1602
+ [GroupRole.BOB]: { name: 'Bob' },
1603
+ [GroupRole.BODY]: { name: 'Body' },
1604
+ [GroupRole.BRASSICAN]: { name: 'Brassican' },
1605
+ [GroupRole.BRAWLER]: { name: 'Brawler' },
1606
+ [GroupRole.BRIGADIER]: { name: 'Brigadier' },
1607
+ [GroupRole.BRIGAND]: { name: 'Brigand' },
1608
+ [GroupRole.BRONZE]: { name: 'Bronze' },
1609
+ [GroupRole.BRUISER]: { name: 'Bruiser' },
1610
+ [GroupRole.BULWARK]: { name: 'Bulwark' },
1611
+ [GroupRole.BURGLAR]: { name: 'Burglar' },
1612
+ [GroupRole.BURNT]: { name: 'Burnt' },
1613
+ [GroupRole.CADET]: { name: 'Cadet' },
1614
+ [GroupRole.CAPTAIN]: { name: 'Captain' },
1615
+ [GroupRole.CARRY]: { name: 'Carry' },
1616
+ [GroupRole.CHAMPION]: { name: 'Champion' },
1617
+ [GroupRole.CHAOS]: { name: 'Chaos' },
1618
+ [GroupRole.CLERIC]: { name: 'Cleric' },
1619
+ [GroupRole.COLLECTOR]: { name: 'Collector' },
1620
+ [GroupRole.COLONEL]: { name: 'Colonel' },
1621
+ [GroupRole.COMMANDER]: { name: 'Commander' },
1622
+ [GroupRole.COMPETITOR]: { name: 'Competitor' },
1623
+ [GroupRole.COMPLETIONIST]: { name: 'Completionist' },
1624
+ [GroupRole.CONSTRUCTOR]: { name: 'Constructor' },
1625
+ [GroupRole.COOK]: { name: 'Cook' },
1626
+ [GroupRole.COORDINATOR]: { name: 'Coordinator' },
1627
+ [GroupRole.CORPORAL]: { name: 'Corporal' },
1628
+ [GroupRole.COSMIC]: { name: 'Cosmic' },
1629
+ [GroupRole.COUNCILLOR]: { name: 'Councillor' },
1630
+ [GroupRole.CRAFTER]: { name: 'Crafter' },
1631
+ [GroupRole.CREW]: { name: 'Crew' },
1632
+ [GroupRole.CRUSADER]: { name: 'Crusader' },
1633
+ [GroupRole.CUTPURSE]: { name: 'Cutpurse' },
1634
+ [GroupRole.DEATH]: { name: 'Death' },
1635
+ [GroupRole.DEFENDER]: { name: 'Defender' },
1636
+ [GroupRole.DEFILER]: { name: 'Defiler' },
1637
+ [GroupRole.DEPUTY_OWNER]: { name: 'Deputy Owner' },
1638
+ [GroupRole.DESTROYER]: { name: 'Destroyer' },
1639
+ [GroupRole.DIAMOND]: { name: 'Diamond' },
1640
+ [GroupRole.DISEASED]: { name: 'Diseased' },
1641
+ [GroupRole.DOCTOR]: { name: 'Doctor' },
1642
+ [GroupRole.DOGSBODY]: { name: 'Dogsbody' },
1643
+ [GroupRole.DRAGON]: { name: 'Dragon' },
1644
+ [GroupRole.DRAGONSTONE]: { name: 'Dragonstone' },
1645
+ [GroupRole.DRUID]: { name: 'Druid' },
1646
+ [GroupRole.DUELLIST]: { name: 'Duellist' },
1647
+ [GroupRole.EARTH]: { name: 'Earth' },
1648
+ [GroupRole.ELITE]: { name: 'Elite' },
1649
+ [GroupRole.EMERALD]: { name: 'Emerald' },
1650
+ [GroupRole.ENFORCER]: { name: 'Enforcer' },
1651
+ [GroupRole.EPIC]: { name: 'Epic' },
1652
+ [GroupRole.EXECUTIVE]: { name: 'Executive' },
1653
+ [GroupRole.EXPERT]: { name: 'Expert' },
1654
+ [GroupRole.EXPLORER]: { name: 'Explorer' },
1655
+ [GroupRole.FARMER]: { name: 'Farmer' },
1656
+ [GroupRole.FEEDER]: { name: 'Feeder' },
1657
+ [GroupRole.FIGHTER]: { name: 'Fighter' },
1658
+ [GroupRole.FIRE]: { name: 'Fire' },
1659
+ [GroupRole.FIREMAKER]: { name: 'Firemaker' },
1660
+ [GroupRole.FIRESTARTER]: { name: 'Firestarter' },
1661
+ [GroupRole.FISHER]: { name: 'Fisher' },
1662
+ [GroupRole.FLETCHER]: { name: 'Fletcher' },
1663
+ [GroupRole.FORAGER]: { name: 'Forager' },
1664
+ [GroupRole.FREMENNIK]: { name: 'Fremennik' },
1665
+ [GroupRole.GAMER]: { name: 'Gamer' },
1666
+ [GroupRole.GATHERER]: { name: 'Gatherer' },
1667
+ [GroupRole.GENERAL]: { name: 'General' },
1668
+ [GroupRole.GNOME_CHILD]: { name: 'Gnome Child' },
1669
+ [GroupRole.GNOME_ELDER]: { name: 'Gnome Elder' },
1670
+ [GroupRole.GOBLIN]: { name: 'Goblin' },
1671
+ [GroupRole.GOLD]: { name: 'Gold' },
1672
+ [GroupRole.GOON]: { name: 'Goon' },
1673
+ [GroupRole.GREEN]: { name: 'Green' },
1674
+ [GroupRole.GREY]: { name: 'Grey' },
1675
+ [GroupRole.GUARDIAN]: { name: 'Guardian' },
1676
+ [GroupRole.GUTHIXIAN]: { name: 'Guthixian' },
1677
+ [GroupRole.HARPOON]: { name: 'Harpoon' },
1678
+ [GroupRole.HEALER]: { name: 'Healer' },
1679
+ [GroupRole.HELLCAT]: { name: 'Hellcat' },
1680
+ [GroupRole.HELPER]: { name: 'Helper' },
1681
+ [GroupRole.HERBOLOGIST]: { name: 'Herbologist' },
1682
+ [GroupRole.HERO]: { name: 'Hero' },
1683
+ [GroupRole.HOLY]: { name: 'Holy' },
1684
+ [GroupRole.HOARDER]: { name: 'Hoarder' },
1685
+ [GroupRole.HUNTER]: { name: 'Hunter' },
1686
+ [GroupRole.IGNITOR]: { name: 'Ignitor' },
1687
+ [GroupRole.ILLUSIONIST]: { name: 'Illusionist' },
1688
+ [GroupRole.IMP]: { name: 'Imp' },
1689
+ [GroupRole.INFANTRY]: { name: 'Infantry' },
1690
+ [GroupRole.INQUISITOR]: { name: 'Inquisitor' },
1691
+ [GroupRole.IRON]: { name: 'Iron' },
1692
+ [GroupRole.JADE]: { name: 'Jade' },
1693
+ [GroupRole.JUSTICIAR]: { name: 'Justiciar' },
1694
+ [GroupRole.KANDARIN]: { name: 'Kandarin' },
1695
+ [GroupRole.KARAMJAN]: { name: 'Karamjan' },
1696
+ [GroupRole.KHARIDIAN]: { name: 'Kharidian' },
1697
+ [GroupRole.KITTEN]: { name: 'Kitten' },
1698
+ [GroupRole.KNIGHT]: { name: 'Knight' },
1699
+ [GroupRole.LABOURER]: { name: 'Labourer' },
1700
+ [GroupRole.LAW]: { name: 'Law' },
1701
+ [GroupRole.LEADER]: { name: 'Leader' },
1702
+ [GroupRole.LEARNER]: { name: 'Learner' },
1703
+ [GroupRole.LEGACY]: { name: 'Legacy' },
1704
+ [GroupRole.LEGEND]: { name: 'Legend' },
1705
+ [GroupRole.LEGIONNAIRE]: { name: 'Legionnaire' },
1706
+ [GroupRole.LIEUTENANT]: { name: 'Lieutenant' },
1707
+ [GroupRole.LOOTER]: { name: 'Looter' },
1708
+ [GroupRole.LUMBERJACK]: { name: 'Lumberjack' },
1709
+ [GroupRole.MAGIC]: { name: 'Magic' },
1710
+ [GroupRole.MAGICIAN]: { name: 'Magician' },
1711
+ [GroupRole.MAJOR]: { name: 'Major' },
1712
+ [GroupRole.MAPLE]: { name: 'Maple' },
1713
+ [GroupRole.MARSHAL]: { name: 'Marshal' },
1714
+ [GroupRole.MASTER]: { name: 'Master' },
1715
+ [GroupRole.MAXED]: { name: 'Maxed' },
1716
+ [GroupRole.MEDIATOR]: { name: 'Mediator' },
1717
+ [GroupRole.MEDIC]: { name: 'Medic' },
1718
+ [GroupRole.MENTOR]: { name: 'Mentor' },
1719
+ [GroupRole.MEMBER]: { name: 'Member' },
1720
+ [GroupRole.MERCHANT]: { name: 'Merchant' },
1721
+ [GroupRole.MIND]: { name: 'Mind' },
1722
+ [GroupRole.MINER]: { name: 'Miner' },
1723
+ [GroupRole.MINION]: { name: 'Minion' },
1724
+ [GroupRole.MISTHALINIAN]: { name: 'Misthalinian' },
1725
+ [GroupRole.MITHRIL]: { name: 'Mithril' },
1726
+ [GroupRole.MODERATOR]: { name: 'Moderator' },
1727
+ [GroupRole.MONARCH]: { name: 'Monarch' },
1728
+ [GroupRole.MORYTANIAN]: { name: 'Morytanian' },
1729
+ [GroupRole.MYSTIC]: { name: 'Mystic' },
1730
+ [GroupRole.MYTH]: { name: 'Myth' },
1731
+ [GroupRole.NATURAL]: { name: 'Natural' },
1732
+ [GroupRole.NATURE]: { name: 'Nature' },
1733
+ [GroupRole.NECROMANCER]: { name: 'Necromancer' },
1734
+ [GroupRole.NINJA]: { name: 'Ninja' },
1735
+ [GroupRole.NOBLE]: { name: 'Noble' },
1736
+ [GroupRole.NOVICE]: { name: 'Novice' },
1737
+ [GroupRole.NURSE]: { name: 'Nurse' },
1738
+ [GroupRole.OAK]: { name: 'Oak' },
1739
+ [GroupRole.OFFICER]: { name: 'Officer' },
1740
+ [GroupRole.ONYX]: { name: 'Onyx' },
1741
+ [GroupRole.OPAL]: { name: 'Opal' },
1742
+ [GroupRole.ORACLE]: { name: 'Oracle' },
1743
+ [GroupRole.ORANGE]: { name: 'Orange' },
1744
+ [GroupRole.OWNER]: { name: 'Owner' },
1745
+ [GroupRole.PAGE]: { name: 'Page' },
1746
+ [GroupRole.PALADIN]: { name: 'Paladin' },
1747
+ [GroupRole.PAWN]: { name: 'Pawn' },
1748
+ [GroupRole.PILGRIM]: { name: 'Pilgrim' },
1749
+ [GroupRole.PINE]: { name: 'Pine' },
1750
+ [GroupRole.PINK]: { name: 'Pink' },
1751
+ [GroupRole.PREFECT]: { name: 'Prefect' },
1752
+ [GroupRole.PRIEST]: { name: 'Priest' },
1753
+ [GroupRole.PRIVATE]: { name: 'Private' },
1754
+ [GroupRole.PRODIGY]: { name: 'Prodigy' },
1755
+ [GroupRole.PROSELYTE]: { name: 'Proselyte' },
1756
+ [GroupRole.PROSPECTOR]: { name: 'Prospector' },
1757
+ [GroupRole.PROTECTOR]: { name: 'Protector' },
1758
+ [GroupRole.PURE]: { name: 'Pure' },
1759
+ [GroupRole.PURPLE]: { name: 'Purple' },
1760
+ [GroupRole.PYROMANCER]: { name: 'Pyromancer' },
1761
+ [GroupRole.QUESTER]: { name: 'Quester' },
1762
+ [GroupRole.RACER]: { name: 'Racer' },
1763
+ [GroupRole.RAIDER]: { name: 'Raider' },
1764
+ [GroupRole.RANGER]: { name: 'Ranger' },
1765
+ [GroupRole.RECORD_CHASER]: { name: 'Record-Chaser' },
1766
+ [GroupRole.RECRUIT]: { name: 'Recruit' },
1767
+ [GroupRole.RECRUITER]: { name: 'Recruiter' },
1768
+ [GroupRole.RED_TOPAZ]: { name: 'Red Topaz' },
1769
+ [GroupRole.RED]: { name: 'Red' },
1770
+ [GroupRole.ROGUE]: { name: 'Rogue' },
1771
+ [GroupRole.RUBY]: { name: 'Ruby' },
1772
+ [GroupRole.RUNE]: { name: 'Rune' },
1773
+ [GroupRole.RUNECRAFTER]: { name: 'Runecrafter' },
1774
+ [GroupRole.SAGE]: { name: 'Sage' },
1775
+ [GroupRole.SAPPHIRE]: { name: 'Sapphire' },
1776
+ [GroupRole.SARADOMINIST]: { name: 'Saradominist' },
1777
+ [GroupRole.SAVIOUR]: { name: 'Saviour' },
1778
+ [GroupRole.SCAVENGER]: { name: 'Scavenger' },
1779
+ [GroupRole.SCHOLAR]: { name: 'Scholar' },
1780
+ [GroupRole.SCOURGE]: { name: 'Scourge' },
1781
+ [GroupRole.SCOUT]: { name: 'Scout' },
1782
+ [GroupRole.SCRIBE]: { name: 'Scribe' },
1783
+ [GroupRole.SEER]: { name: 'Seer' },
1784
+ [GroupRole.SENATOR]: { name: 'Senator' },
1785
+ [GroupRole.SENTRY]: { name: 'Sentry' },
1786
+ [GroupRole.SERENIST]: { name: 'Serenist' },
1787
+ [GroupRole.SERGEANT]: { name: 'Sergeant' },
1788
+ [GroupRole.SHAMAN]: { name: 'Shaman' },
1789
+ [GroupRole.SHERIFF]: { name: 'Sheriff' },
1790
+ [GroupRole.SHORT_GREEN_GUY]: { name: 'Short Green Guy' },
1791
+ [GroupRole.SKILLER]: { name: 'Skiller' },
1792
+ [GroupRole.SKULLED]: { name: 'Skulled' },
1793
+ [GroupRole.SLAYER]: { name: 'Slayer' },
1794
+ [GroupRole.SMITER]: { name: 'Smiter' },
1795
+ [GroupRole.SMITH]: { name: 'Smith' },
1796
+ [GroupRole.SMUGGLER]: { name: 'Smuggler' },
1797
+ [GroupRole.SNIPER]: { name: 'Sniper' },
1798
+ [GroupRole.SOUL]: { name: 'Soul' },
1799
+ [GroupRole.SPECIALIST]: { name: 'Specialist' },
1800
+ [GroupRole.SPEED_RUNNER]: { name: 'Speed-Runner' },
1801
+ [GroupRole.SPELLCASTER]: { name: 'Spellcaster' },
1802
+ [GroupRole.SQUIRE]: { name: 'Squire' },
1803
+ [GroupRole.STAFF]: { name: 'Staff' },
1804
+ [GroupRole.STEEL]: { name: 'Steel' },
1805
+ [GroupRole.STRIDER]: { name: 'Strider' },
1806
+ [GroupRole.STRIKER]: { name: 'Striker' },
1807
+ [GroupRole.SUMMONER]: { name: 'Summoner' },
1808
+ [GroupRole.SUPERIOR]: { name: 'Superior' },
1809
+ [GroupRole.SUPERVISOR]: { name: 'Supervisor' },
1810
+ [GroupRole.TEACHER]: { name: 'Teacher' },
1811
+ [GroupRole.TEMPLAR]: { name: 'Templar' },
1812
+ [GroupRole.THERAPIST]: { name: 'Therapist' },
1813
+ [GroupRole.THIEF]: { name: 'Thief' },
1814
+ [GroupRole.TIRANNIAN]: { name: 'Tirannian' },
1815
+ [GroupRole.TRIALIST]: { name: 'Trialist' },
1816
+ [GroupRole.TRICKSTER]: { name: 'Trickster' },
1817
+ [GroupRole.TZKAL]: { name: 'TzKal' },
1818
+ [GroupRole.TZTOK]: { name: 'TzTok' },
1819
+ [GroupRole.UNHOLY]: { name: 'Unholy' },
1820
+ [GroupRole.VAGRANT]: { name: 'Vagrant' },
1821
+ [GroupRole.VANGUARD]: { name: 'Vanguard' },
1822
+ [GroupRole.WALKER]: { name: 'Walker' },
1823
+ [GroupRole.WANDERER]: { name: 'Wanderer' },
1824
+ [GroupRole.WARDEN]: { name: 'Warden' },
1825
+ [GroupRole.WARLOCK]: { name: 'Warlock' },
1826
+ [GroupRole.WARRIOR]: { name: 'Warrior' },
1827
+ [GroupRole.WATER]: { name: 'Water' },
1828
+ [GroupRole.WILD]: { name: 'Wild' },
1829
+ [GroupRole.WILLOW]: { name: 'Willow' },
1830
+ [GroupRole.WILY]: { name: 'Wily' },
1831
+ [GroupRole.WINTUMBER]: { name: 'Wintumber' },
1832
+ [GroupRole.WITCH]: { name: 'Witch' },
1833
+ [GroupRole.WIZARD]: { name: 'Wizard' },
1834
+ [GroupRole.WORKER]: { name: 'Worker' },
1835
+ [GroupRole.WRATH]: { name: 'Wrath' },
1836
+ [GroupRole.XERICIAN]: { name: 'Xerician' },
1837
+ [GroupRole.YELLOW]: { name: 'Yellow' },
1838
+ [GroupRole.YEW]: { name: 'Yew' },
1839
+ [GroupRole.ZAMORAKIAN]: { name: 'Zamorakian' },
1840
+ [GroupRole.ZAROSIAN]: { name: 'Zarosian' },
1841
+ [GroupRole.ZEALOT]: { name: 'Zealot' },
1842
+ [GroupRole.ZENYTE]: { name: 'Zenyte' }
1843
+ }, (props, key) => (Object.assign(Object.assign({}, props), { isPriveleged: PRIVELEGED_GROUP_ROLES.includes(key) })));
1844
+ function findGroupRole(roleName) {
1845
+ for (const [key, value] of Object.entries(GroupRoleProps)) {
1846
+ if (value.name.toUpperCase() === roleName.toUpperCase()) {
1847
+ return key;
1848
+ }
1849
+ }
1850
+ return null;
1851
+ }
1852
+ function isGroupRole(roleString) {
1853
+ return roleString in GroupRoleProps;
1854
+ }
1855
+
1856
+ var MetricType;
1857
+ (function (MetricType) {
1858
+ MetricType["SKILL"] = "skill";
1859
+ MetricType["BOSS"] = "boss";
1860
+ MetricType["ACTIVITY"] = "activity";
1861
+ MetricType["COMPUTED"] = "computed";
1862
+ })(MetricType || (MetricType = {}));
1863
+ var MetricMeasure;
1864
+ (function (MetricMeasure) {
1865
+ MetricMeasure["EXPERIENCE"] = "experience";
1866
+ MetricMeasure["KILLS"] = "kills";
1867
+ MetricMeasure["SCORE"] = "score";
1868
+ MetricMeasure["VALUE"] = "value";
1869
+ })(MetricMeasure || (MetricMeasure = {}));
1870
+ const SkillProps = mapValues({
1871
+ [Skill.OVERALL]: { name: 'Overall' },
1872
+ [Skill.ATTACK]: { name: 'Attack', isCombat: true },
1873
+ [Skill.DEFENCE]: { name: 'Defence', isCombat: true },
1874
+ [Skill.STRENGTH]: { name: 'Strength', isCombat: true },
1875
+ [Skill.HITPOINTS]: { name: 'Hitpoints', isCombat: true },
1876
+ [Skill.RANGED]: { name: 'Ranged', isCombat: true },
1877
+ [Skill.PRAYER]: { name: 'Prayer', isCombat: true },
1878
+ [Skill.MAGIC]: { name: 'Magic', isCombat: true },
1879
+ [Skill.COOKING]: { name: 'Cooking' },
1880
+ [Skill.WOODCUTTING]: { name: 'Woodcutting' },
1881
+ [Skill.FLETCHING]: { name: 'Fletching', isMembers: true },
1882
+ [Skill.FISHING]: { name: 'Fishing' },
1883
+ [Skill.FIREMAKING]: { name: 'Firemaking' },
1884
+ [Skill.CRAFTING]: { name: 'Crafting' },
1885
+ [Skill.SMITHING]: { name: 'Smithing' },
1886
+ [Skill.MINING]: { name: 'Mining' },
1887
+ [Skill.HERBLORE]: { name: 'Herblore', isMembers: true },
1888
+ [Skill.AGILITY]: { name: 'Agility', isMembers: true },
1889
+ [Skill.THIEVING]: { name: 'Thieving', isMembers: true },
1890
+ [Skill.SLAYER]: { name: 'Slayer', isMembers: true },
1891
+ [Skill.FARMING]: { name: 'Farming', isMembers: true },
1892
+ [Skill.RUNECRAFTING]: { name: 'Runecrafting' },
1893
+ [Skill.HUNTER]: { name: 'Hunter', isMembers: true },
1894
+ [Skill.CONSTRUCTION]: { name: 'Construction', isMembers: true }
1895
+ }, props => (Object.assign(Object.assign({}, props), { type: MetricType.SKILL, measure: MetricMeasure.EXPERIENCE, isCombat: 'isCombat' in props ? props.isCombat : false, isMembers: 'isMembers' in props ? props.isMembers : false })));
1896
+ const BossProps = mapValues({
1897
+ [Boss.ABYSSAL_SIRE]: { name: 'Abyssal Sire' },
1898
+ [Boss.ALCHEMICAL_HYDRA]: { name: 'Alchemical Hydra' },
1899
+ [Boss.ARTIO]: { name: 'Artio' },
1900
+ [Boss.BARROWS_CHESTS]: { name: 'Barrows Chests' },
1901
+ [Boss.BRYOPHYTA]: { name: 'Bryophyta', isMembers: false },
1902
+ [Boss.CALLISTO]: { name: 'Callisto' },
1903
+ [Boss.CALVARION]: { name: "Calvar'ion" },
1904
+ [Boss.CERBERUS]: { name: 'Cerberus' },
1905
+ [Boss.CHAMBERS_OF_XERIC]: { name: 'Chambers Of Xeric' },
1906
+ [Boss.CHAMBERS_OF_XERIC_CM]: { name: 'Chambers Of Xeric (CM)' },
1907
+ [Boss.CHAOS_ELEMENTAL]: { name: 'Chaos Elemental' },
1908
+ [Boss.CHAOS_FANATIC]: { name: 'Chaos Fanatic' },
1909
+ [Boss.COMMANDER_ZILYANA]: { name: 'Commander Zilyana' },
1910
+ [Boss.CORPOREAL_BEAST]: { name: 'Corporeal Beast' },
1911
+ [Boss.CRAZY_ARCHAEOLOGIST]: { name: 'Crazy Archaeologist' },
1912
+ [Boss.DAGANNOTH_PRIME]: { name: 'Dagannoth Prime' },
1913
+ [Boss.DAGANNOTH_REX]: { name: 'Dagannoth Rex' },
1914
+ [Boss.DAGANNOTH_SUPREME]: { name: 'Dagannoth Supreme' },
1915
+ [Boss.DERANGED_ARCHAEOLOGIST]: { name: 'Deranged Archaeologist' },
1916
+ [Boss.DUKE_SUCELLUS]: { name: 'Duke Sucellus' },
1917
+ [Boss.GENERAL_GRAARDOR]: { name: 'General Graardor' },
1918
+ [Boss.GIANT_MOLE]: { name: 'Giant Mole' },
1919
+ [Boss.GROTESQUE_GUARDIANS]: { name: 'Grotesque Guardians' },
1920
+ [Boss.HESPORI]: { name: 'Hespori' },
1921
+ [Boss.KALPHITE_QUEEN]: { name: 'Kalphite Queen' },
1922
+ [Boss.KING_BLACK_DRAGON]: { name: 'King Black Dragon' },
1923
+ [Boss.KRAKEN]: { name: 'Kraken' },
1924
+ [Boss.KREEARRA]: { name: "Kree'Arra" },
1925
+ [Boss.KRIL_TSUTSAROTH]: { name: "K'ril Tsutsaroth" },
1926
+ [Boss.MIMIC]: { name: 'Mimic', minimumValue: 1 },
1927
+ [Boss.NEX]: { name: 'Nex' },
1928
+ [Boss.NIGHTMARE]: { name: 'Nightmare' },
1929
+ [Boss.PHOSANIS_NIGHTMARE]: { name: "Phosani's Nightmare" },
1930
+ [Boss.OBOR]: { name: 'Obor', isMembers: false },
1931
+ [Boss.PHANTOM_MUSPAH]: { name: 'Phantom Muspah' },
1932
+ [Boss.SARACHNIS]: { name: 'Sarachnis' },
1933
+ [Boss.SCORPIA]: { name: 'Scorpia' },
1934
+ [Boss.SCURRIUS]: { name: 'Scurrius' },
1935
+ [Boss.SKOTIZO]: { name: 'Skotizo' },
1936
+ [Boss.SPINDEL]: { name: 'Spindel' },
1937
+ [Boss.TEMPOROSS]: { name: 'Tempoross' },
1938
+ [Boss.THE_GAUNTLET]: { name: 'The Gauntlet' },
1939
+ [Boss.THE_CORRUPTED_GAUNTLET]: { name: 'The Corrupted Gauntlet' },
1940
+ [Boss.THE_LEVIATHAN]: { name: 'The Leviathan' },
1941
+ [Boss.THE_WHISPERER]: { name: 'The Whisperer' },
1942
+ [Boss.THEATRE_OF_BLOOD]: { name: 'Theatre Of Blood' },
1943
+ [Boss.THEATRE_OF_BLOOD_HARD_MODE]: { name: 'Theatre Of Blood (HM)' },
1944
+ [Boss.THERMONUCLEAR_SMOKE_DEVIL]: { name: 'Thermonuclear Smoke Devil' },
1945
+ [Boss.TOMBS_OF_AMASCUT]: { name: 'Tombs of Amascut' },
1946
+ [Boss.TOMBS_OF_AMASCUT_EXPERT]: { name: 'Tombs of Amascut (Expert Mode)' },
1947
+ [Boss.TZKAL_ZUK]: { name: 'TzKal-Zuk', minimumValue: 1 },
1948
+ [Boss.TZTOK_JAD]: { name: 'TzTok-Jad' },
1949
+ [Boss.VARDORVIS]: { name: 'Vardorvis' },
1950
+ [Boss.VENENATIS]: { name: 'Venenatis' },
1951
+ [Boss.VETION]: { name: "Vet'ion" },
1952
+ [Boss.VORKATH]: { name: 'Vorkath' },
1953
+ [Boss.WINTERTODT]: { name: 'Wintertodt' },
1954
+ [Boss.ZALCANO]: { name: 'Zalcano' },
1955
+ [Boss.ZULRAH]: { name: 'Zulrah' }
1956
+ }, props => (Object.assign(Object.assign({}, props), { type: MetricType.BOSS, measure: MetricMeasure.KILLS, isMembers: 'isMembers' in props ? props.isMembers : true, minimumValue: 'minimumValue' in props ? props.minimumValue : 5 })));
1957
+ const ActivityProps = mapValues({
1958
+ [Activity.LEAGUE_POINTS]: { name: 'League Points', minimumValue: 100 },
1959
+ [Activity.BOUNTY_HUNTER_HUNTER]: { name: 'Bounty Hunter (Hunter)', minimumValue: 2 },
1960
+ [Activity.BOUNTY_HUNTER_ROGUE]: { name: 'Bounty Hunter (Rogue)', minimumValue: 2 },
1961
+ [Activity.CLUE_SCROLLS_ALL]: { name: 'Clue Scrolls (All)' },
1962
+ [Activity.CLUE_SCROLLS_BEGINNER]: { name: 'Clue Scrolls (Beginner)' },
1963
+ [Activity.CLUE_SCROLLS_EASY]: { name: 'Clue Scrolls (Easy)' },
1964
+ [Activity.CLUE_SCROLLS_MEDIUM]: { name: 'Clue Scrolls (Medium)' },
1965
+ [Activity.CLUE_SCROLLS_HARD]: { name: 'Clue Scrolls (Hard)' },
1966
+ [Activity.CLUE_SCROLLS_ELITE]: { name: 'Clue Scrolls (Elite)' },
1967
+ [Activity.CLUE_SCROLLS_MASTER]: { name: 'Clue Scrolls (Master)' },
1968
+ [Activity.LAST_MAN_STANDING]: { name: 'Last Man Standing', minimumValue: 500 },
1969
+ [Activity.PVP_ARENA]: { name: 'PvP Arena', minimumValue: 2525 },
1970
+ [Activity.SOUL_WARS_ZEAL]: { name: 'Soul Wars Zeal', minimumValue: 200 },
1971
+ [Activity.GUARDIANS_OF_THE_RIFT]: { name: 'Guardians of the Rift', minimumValue: 2 }
1972
+ }, props => (Object.assign(Object.assign({}, props), { type: MetricType.ACTIVITY, measure: MetricMeasure.SCORE, minimumValue: 'minimumValue' in props ? props.minimumValue : 1 })));
1973
+ const ComputedMetricProps = mapValues({
1974
+ [ComputedMetric.EHP]: { name: 'EHP' },
1975
+ [ComputedMetric.EHB]: { name: 'EHB' }
1976
+ }, props => (Object.assign(Object.assign({}, props), { type: MetricType.COMPUTED, measure: MetricMeasure.VALUE })));
1977
+ const MetricProps = Object.assign(Object.assign(Object.assign(Object.assign({}, SkillProps), BossProps), ActivityProps), ComputedMetricProps);
1978
+ const METRICS = Object.values(Metric);
1979
+ const SKILLS = Object.values(Skill);
1980
+ const BOSSES = Object.values(Boss);
1981
+ const ACTIVITIES = Object.values(Activity);
1982
+ const COMPUTED_METRICS = Object.values(ComputedMetric);
1983
+ const REAL_SKILLS = SKILLS.filter(s => s !== Skill.OVERALL);
1984
+ const F2P_BOSSES = BOSSES.filter(b => !MetricProps[b].isMembers);
1985
+ const MEMBER_SKILLS = SKILLS.filter(s => MetricProps[s].isMembers);
1986
+ const COMBAT_SKILLS = SKILLS.filter(s => MetricProps[s].isCombat);
1987
+ const REAL_METRICS = [...SKILLS, ...BOSSES, ...ACTIVITIES];
1988
+ function findMetric(metricName) {
1989
+ for (const [key, value] of Object.entries(MetricProps)) {
1990
+ if (value.name.toUpperCase() === metricName.toUpperCase())
1991
+ return key;
1992
+ }
1993
+ return null;
1994
+ }
1995
+ function isMetric(metric) {
1996
+ return metric in MetricProps;
1997
+ }
1998
+ function isSkill(metric) {
1999
+ return metric in SkillProps;
2000
+ }
2001
+ function isActivity(metric) {
2002
+ return metric in ActivityProps;
2003
+ }
2004
+ function isBoss(metric) {
2005
+ return metric in BossProps;
2006
+ }
2007
+ function isComputedMetric(metric) {
2008
+ return metric in ComputedMetricProps;
2009
+ }
2010
+ function getMetricRankKey(metric) {
2011
+ return `${metric}Rank`;
2012
+ }
2013
+ // Maybe someday I'll be good enough with TS to restrict the return type to the input metric type
2014
+ function getMetricValueKey(metric) {
2015
+ if (isSkill(metric)) {
2016
+ return `${metric}Experience`;
2017
+ }
2018
+ if (isBoss(metric)) {
2019
+ return `${metric}Kills`;
2020
+ }
2021
+ if (isActivity(metric)) {
2022
+ return `${metric}Score`;
2023
+ }
2024
+ return `${metric}Value`;
2025
+ }
2026
+ function getMetricMeasure(metric) {
2027
+ return MetricProps[metric].measure;
2028
+ }
2029
+ function getMetricName(metric) {
2030
+ return MetricProps[metric].name;
2031
+ }
2032
+ function getMinimumValue(metric) {
2033
+ return isBoss(metric) || isActivity(metric) ? MetricProps[metric].minimumValue : 1;
2034
+ }
2035
+ function getParentEfficiencyMetric(metric) {
2036
+ if (isBoss(metric))
2037
+ return Metric.EHB;
2038
+ if (isSkill(metric))
2039
+ return Metric.EHP;
2040
+ return null;
2041
+ }
2042
+ function parseMetricAbbreviation(abbreviation) {
2043
+ if (!abbreviation || abbreviation.length === 0) {
2044
+ return null;
2045
+ }
2046
+ const fixedAbbreviation = abbreviation.toLowerCase();
2047
+ if (isMetric(fixedAbbreviation)) {
2048
+ return fixedAbbreviation;
2049
+ }
2050
+ switch (fixedAbbreviation) {
2051
+ // Bosses
2052
+ case 'sire':
2053
+ return Metric.ABYSSAL_SIRE;
2054
+ case 'hydra':
2055
+ return Metric.ALCHEMICAL_HYDRA;
2056
+ case 'barrows':
2057
+ return Metric.BARROWS_CHESTS;
2058
+ case 'bryo':
2059
+ return Metric.BRYOPHYTA;
2060
+ case 'cerb':
2061
+ return Metric.CERBERUS;
2062
+ case 'cox':
2063
+ case 'xeric':
2064
+ case 'chambers':
2065
+ case 'olm':
2066
+ case 'raids':
2067
+ return Metric.CHAMBERS_OF_XERIC;
2068
+ case 'cox-cm':
2069
+ case 'xeric-cm':
2070
+ case 'chambers-cm':
2071
+ case 'olm-cm':
2072
+ case 'raids-cm':
2073
+ return Metric.CHAMBERS_OF_XERIC_CM;
2074
+ case 'chaos-ele':
2075
+ return Metric.CHAOS_ELEMENTAL;
2076
+ case 'fanatic':
2077
+ return Metric.CHAOS_FANATIC;
2078
+ case 'sara':
2079
+ case 'saradomin':
2080
+ case 'zilyana':
2081
+ case 'zily':
2082
+ return Metric.COMMANDER_ZILYANA;
2083
+ case 'corp':
2084
+ return Metric.CORPOREAL_BEAST;
2085
+ case 'crazy-arch':
2086
+ return Metric.CRAZY_ARCHAEOLOGIST;
2087
+ case 'prime':
2088
+ return Metric.DAGANNOTH_PRIME;
2089
+ case 'rex':
2090
+ return Metric.DAGANNOTH_REX;
2091
+ case 'supreme':
2092
+ return Metric.DAGANNOTH_SUPREME;
2093
+ case 'deranged-arch':
2094
+ return Metric.DERANGED_ARCHAEOLOGIST;
2095
+ case 'bandos':
2096
+ case 'graardor':
2097
+ return Metric.GENERAL_GRAARDOR;
2098
+ case 'mole':
2099
+ return Metric.GIANT_MOLE;
2100
+ case 'dusk':
2101
+ case 'dawn':
2102
+ case 'gargs':
2103
+ case 'guardians':
2104
+ case 'ggs':
2105
+ return Metric.GROTESQUE_GUARDIANS;
2106
+ case 'phantom':
2107
+ case 'muspah':
2108
+ return Metric.PHANTOM_MUSPAH;
2109
+ case 'kq':
2110
+ return Metric.KALPHITE_QUEEN;
2111
+ case 'kbd':
2112
+ return Metric.KING_BLACK_DRAGON;
2113
+ case 'kree':
2114
+ case 'kreearra':
2115
+ case 'armadyl':
2116
+ case 'arma':
2117
+ return Metric.KREEARRA;
2118
+ case 'zammy':
2119
+ case 'zamorak':
2120
+ case 'kril':
2121
+ case 'kril-tsutsaroth':
2122
+ return Metric.KRIL_TSUTSAROTH;
2123
+ case 'gaunt':
2124
+ case 'gauntlet':
2125
+ case 'the-gauntlet':
2126
+ return Metric.THE_GAUNTLET;
2127
+ case 'cgaunt':
2128
+ case 'cgauntlet':
2129
+ case 'corrupted':
2130
+ case 'corrupted-gauntlet':
2131
+ case 'the-corrupted-gauntlet':
2132
+ return Metric.THE_CORRUPTED_GAUNTLET;
2133
+ case 'tob':
2134
+ case 'theatre':
2135
+ case 'verzik':
2136
+ case 'tob-normal':
2137
+ return Metric.THEATRE_OF_BLOOD;
2138
+ case 'tob-hm':
2139
+ case 'tob-cm':
2140
+ case 'tob-hard-mode':
2141
+ case 'tob-hard':
2142
+ return Metric.THEATRE_OF_BLOOD_HARD_MODE;
2143
+ case 'toa':
2144
+ case 'tombs':
2145
+ case 'amascut':
2146
+ return Metric.TOMBS_OF_AMASCUT;
2147
+ case 'toa-expert':
2148
+ case 'toa-hm':
2149
+ case 'tombs-expert':
2150
+ case 'tombs-hm':
2151
+ case 'amascut-expert':
2152
+ case 'amascut-hm':
2153
+ return Metric.TOMBS_OF_AMASCUT_EXPERT;
2154
+ case 'nm':
2155
+ case 'tnm':
2156
+ case 'nmare':
2157
+ case 'the-nightmare':
2158
+ return Metric.NIGHTMARE;
2159
+ case 'pnm':
2160
+ case 'phosani':
2161
+ case 'phosanis':
2162
+ case 'phosani-nm':
2163
+ case 'phosani-nightmare':
2164
+ case 'phosanis nightmare':
2165
+ return Metric.PHOSANIS_NIGHTMARE;
2166
+ case 'thermy':
2167
+ case 'smoke-devil':
2168
+ return Metric.THERMONUCLEAR_SMOKE_DEVIL;
2169
+ case 'zuk':
2170
+ case 'inferno':
2171
+ return Metric.TZKAL_ZUK;
2172
+ case 'jad':
2173
+ case 'fight-caves':
2174
+ case 'fc':
2175
+ return Metric.TZTOK_JAD;
2176
+ case 'vork':
2177
+ case 'vorky':
2178
+ return Metric.VORKATH;
2179
+ case 'wt':
2180
+ return Metric.WINTERTODT;
2181
+ case 'snek':
2182
+ case 'zul':
2183
+ return Metric.ZULRAH;
2184
+ // Minigames and others
2185
+ case 'all-clues':
2186
+ case 'clues':
2187
+ return Metric.CLUE_SCROLLS_ALL;
2188
+ case 'beginner':
2189
+ case 'beginner-clues':
2190
+ case 'beg-clues':
2191
+ case 'beginners':
2192
+ return Metric.CLUE_SCROLLS_BEGINNER;
2193
+ case 'easy':
2194
+ case 'easy-clues':
2195
+ case 'easies':
2196
+ return Metric.CLUE_SCROLLS_EASY;
2197
+ case 'medium':
2198
+ case 'med':
2199
+ case 'meds':
2200
+ case 'medium-clues':
2201
+ case 'med-clues':
2202
+ case 'mediums':
2203
+ return Metric.CLUE_SCROLLS_MEDIUM;
2204
+ case 'hard':
2205
+ case 'hard-clues':
2206
+ case 'hards':
2207
+ return Metric.CLUE_SCROLLS_HARD;
2208
+ case 'elite':
2209
+ case 'elite-clues':
2210
+ case 'elites':
2211
+ return Metric.CLUE_SCROLLS_ELITE;
2212
+ case 'master':
2213
+ case 'master-clues':
2214
+ case 'masters':
2215
+ return Metric.CLUE_SCROLLS_MASTER;
2216
+ case 'lms':
2217
+ return Metric.LAST_MAN_STANDING;
2218
+ case 'league':
2219
+ case 'lp':
2220
+ case 'lps':
2221
+ return Metric.LEAGUE_POINTS;
2222
+ case 'sw':
2223
+ case 'zeal':
2224
+ case 'soul-wars':
2225
+ return Metric.SOUL_WARS_ZEAL;
2226
+ case 'rifts-closed':
2227
+ case 'gotr':
2228
+ case 'rifts':
2229
+ return Metric.GUARDIANS_OF_THE_RIFT;
2230
+ // Skills
2231
+ case 'runecraft':
2232
+ case 'rc':
2233
+ return Metric.RUNECRAFTING;
2234
+ case 'att':
2235
+ case 'atk':
2236
+ case 'attk':
2237
+ return Metric.ATTACK;
2238
+ case 'def':
2239
+ case 'defense':
2240
+ return Metric.DEFENCE;
2241
+ case 'str':
2242
+ return Metric.STRENGTH;
2243
+ case 'hp':
2244
+ return Metric.HITPOINTS;
2245
+ case 'range':
2246
+ return Metric.RANGED;
2247
+ case 'pray':
2248
+ return Metric.PRAYER;
2249
+ case 'mage':
2250
+ return Metric.MAGIC;
2251
+ case 'cook':
2252
+ return Metric.COOKING;
2253
+ case 'wc':
2254
+ return Metric.WOODCUTTING;
2255
+ case 'fletch':
2256
+ return Metric.FLETCHING;
2257
+ case 'fish':
2258
+ return Metric.FISHING;
2259
+ case 'fm':
2260
+ case 'burning':
2261
+ return Metric.FIREMAKING;
2262
+ case 'craft':
2263
+ return Metric.CRAFTING;
2264
+ case 'sm':
2265
+ case 'smith':
2266
+ return Metric.SMITHING;
2267
+ case 'mine':
2268
+ case 'smash':
2269
+ return Metric.MINING;
2270
+ case 'herb':
2271
+ return Metric.HERBLORE;
2272
+ case 'agi':
2273
+ case 'agil':
2274
+ return Metric.AGILITY;
2275
+ case 'thief':
2276
+ return Metric.THIEVING;
2277
+ case 'slay':
2278
+ return Metric.SLAYER;
2279
+ case 'farm':
2280
+ return Metric.FARMING;
2281
+ case 'hunt':
2282
+ case 'hunting':
2283
+ return Metric.HUNTER;
2284
+ case 'con':
2285
+ case 'cons':
2286
+ case 'const':
2287
+ return Metric.CONSTRUCTION;
2288
+ default:
2289
+ return null;
2290
+ }
2291
+ }
2292
+
2293
+ const CUSTOM_PERIOD_REGEX = /(\d+y)?(\d+m)?(\d+w)?(\d+d)?(\d+h)?/;
2294
+ const PeriodProps = {
2295
+ [Period.FIVE_MIN]: { name: '5 Min', milliseconds: 300000 },
2296
+ [Period.DAY]: { name: 'Day', milliseconds: 86400000 },
2297
+ [Period.WEEK]: { name: 'Week', milliseconds: 604800000 },
2298
+ [Period.MONTH]: { name: 'Month', milliseconds: 2678400000 },
2299
+ [Period.YEAR]: { name: 'Year', milliseconds: 31556926000 }
2300
+ };
2301
+ const PERIODS = Object.values(Period);
2302
+ function findPeriod(periodName) {
2303
+ for (const [key, value] of Object.entries(PeriodProps)) {
2304
+ if (value.name.toUpperCase() === periodName.toUpperCase())
2305
+ return key;
2306
+ }
2307
+ return null;
2308
+ }
2309
+ function isPeriod(periodString) {
2310
+ return periodString in PeriodProps;
2311
+ }
2312
+ function parsePeriodExpression(periodExpression) {
2313
+ const fixed = periodExpression.toLowerCase();
2314
+ if (isPeriod(fixed)) {
2315
+ return {
2316
+ expression: fixed,
2317
+ durationMs: PeriodProps[fixed].milliseconds
2318
+ };
2319
+ }
2320
+ const result = fixed.match(CUSTOM_PERIOD_REGEX);
2321
+ if (!result || result.length === 0 || result[0] !== fixed)
2322
+ return null;
2323
+ const years = result[1] ? parseInt(result[1].replace(/\D/g, '')) : 0;
2324
+ const months = result[2] ? parseInt(result[2].replace(/\D/g, '')) : 0;
2325
+ const weeks = result[3] ? parseInt(result[3].replace(/\D/g, '')) : 0;
2326
+ const days = result[4] ? parseInt(result[4].replace(/\D/g, '')) : 0;
2327
+ const hours = result[5] ? parseInt(result[5].replace(/\D/g, '')) : 0;
2328
+ const yearsMs = years * PeriodProps[Period.YEAR].milliseconds;
2329
+ const monthsMs = months * PeriodProps[Period.MONTH].milliseconds;
2330
+ const weeksMs = weeks * PeriodProps[Period.WEEK].milliseconds;
2331
+ const daysMs = days * PeriodProps[Period.DAY].milliseconds;
2332
+ const hoursMs = hours * (PeriodProps[Period.DAY].milliseconds / 24);
2333
+ const totalMs = yearsMs + monthsMs + weeksMs + daysMs + hoursMs;
2334
+ return {
2335
+ expression: result[0],
2336
+ durationMs: totalMs
2337
+ };
2338
+ }
2339
+
2340
+ const PlayerTypeProps = {
2341
+ [PlayerType.UNKNOWN]: { name: 'Unknown' },
2342
+ [PlayerType.REGULAR]: { name: 'Regular' },
2343
+ [PlayerType.IRONMAN]: { name: 'Ironman' },
2344
+ [PlayerType.HARDCORE]: { name: 'Hardcore' },
2345
+ [PlayerType.ULTIMATE]: { name: 'Ultimate' }
2346
+ };
2347
+ const PlayerBuildProps = {
2348
+ [PlayerBuild.MAIN]: { name: 'Main' },
2349
+ [PlayerBuild.F2P]: { name: 'F2P' },
2350
+ [PlayerBuild.F2P_LVL3]: { name: 'F2P & Level 3' },
2351
+ [PlayerBuild.LVL3]: { name: 'Level 3' },
2352
+ [PlayerBuild.ZERKER]: { name: 'Zerker Pure' },
2353
+ [PlayerBuild.DEF1]: { name: '1 Defence Pure' },
2354
+ [PlayerBuild.HP10]: { name: '10 Hitpoints Pure' }
2355
+ };
2356
+ const PlayerStatusProps = {
2357
+ [PlayerStatus.ACTIVE]: { name: 'Active' },
2358
+ [PlayerStatus.UNRANKED]: { name: 'Unranked' },
2359
+ [PlayerStatus.FLAGGED]: { name: 'Flagged' },
2360
+ [PlayerStatus.ARCHIVED]: { name: 'Archived' },
2361
+ [PlayerStatus.BANNED]: { name: 'Banned' }
2362
+ };
2363
+ const PLAYER_TYPES = Object.values(PlayerType);
2364
+ const PLAYER_BUILDS = Object.values(PlayerBuild);
2365
+ const PLAYER_STATUSES = Object.values(PlayerStatus);
2366
+ function isPlayerType(typeString) {
2367
+ return typeString in PlayerTypeProps;
2368
+ }
2369
+ function isPlayerBuild(buildString) {
2370
+ return buildString in PlayerBuildProps;
2371
+ }
2372
+ function isPlayerStatus(statusString) {
2373
+ return statusString in PlayerStatusProps;
2374
+ }
2375
+ function findPlayerType(typeName) {
2376
+ for (const [key, value] of Object.entries(PlayerTypeProps)) {
2377
+ if (value.name.toUpperCase() === typeName.toUpperCase())
2378
+ return key;
2379
+ }
2380
+ return null;
2381
+ }
2382
+ function findPlayerBuild(buildName) {
2383
+ for (const [key, value] of Object.entries(PlayerBuildProps)) {
2384
+ if (value.name.toUpperCase() === buildName.toUpperCase())
2385
+ return key;
2386
+ }
2387
+ return null;
2388
+ }
2389
+
2390
+ function formatNumber(num, withLetters = false, decimalPrecision = 2) {
2391
+ if (num === undefined || num === null)
2392
+ return -1;
2393
+ // If number is float
2394
+ if (num % 1 !== 0) {
2395
+ return (Math.round(num * 100) / 100).toLocaleString();
2396
+ }
2397
+ if ((num < 10000 && num > -10000) || !withLetters) {
2398
+ return num.toLocaleString();
2399
+ }
2400
+ // < 100k
2401
+ if (num < 100000 && num > -100000) {
2402
+ // If has no decimals, return as whole number instead (10.00k => 10k)
2403
+ if ((num / 1000) % 1 === 0)
2404
+ return `${num / 1000}k`;
2405
+ return `${(num / 1000).toFixed(decimalPrecision)}k`;
2406
+ }
2407
+ // < 10 million
2408
+ if (num < 10000000 && num > -10000000) {
2409
+ return `${Math.round(num / 1000)}k`;
2410
+ }
2411
+ // < 1 billion
2412
+ if (num < 1000000000 && num > -1000000000) {
2413
+ // If has no decimals, return as whole number instead (10.00m => 10m)
2414
+ if ((num / 1000000) % 1 === 0)
2415
+ return `${num / 1000000}m`;
2416
+ return `${(num / 1000000).toFixed(decimalPrecision)}m`;
2417
+ }
2418
+ // If has no decimals, return as whole number instead (10.00b => 10b)
2419
+ if ((num / 1000000000) % 1 === 0)
2420
+ return `${num / 1000000000}b`;
2421
+ return `${(num / 1000000000).toFixed(decimalPrecision)}b`;
2422
+ }
2423
+ function padNumber(value) {
2424
+ if (!value)
2425
+ return '00';
2426
+ return value < 10 ? `0${value}` : value.toString();
2427
+ }
2428
+ function round(num, cases) {
2429
+ return Math.round(num * Math.pow(10, cases)) / Math.pow(10, cases);
2430
+ }
2431
+
2432
+ var EfficiencyAlgorithmType;
2433
+ (function (EfficiencyAlgorithmType) {
2434
+ EfficiencyAlgorithmType["MAIN"] = "main";
2435
+ EfficiencyAlgorithmType["IRONMAN"] = "ironman";
2436
+ EfficiencyAlgorithmType["ULTIMATE"] = "ultimate";
2437
+ EfficiencyAlgorithmType["LVL3"] = "lvl3";
2438
+ EfficiencyAlgorithmType["F2P"] = "f2p";
2439
+ EfficiencyAlgorithmType["F2P_LVL3"] = "f2p_lvl3";
2440
+ EfficiencyAlgorithmType["F2P_IRONMAN"] = "f2p_ironman";
2441
+ EfficiencyAlgorithmType["F2P_LVL3_IRONMAN"] = "f2p_lvl3_ironman";
2442
+ })(EfficiencyAlgorithmType || (EfficiencyAlgorithmType = {}));
2443
+
2444
+ var MigrationDataSource;
2445
+ (function (MigrationDataSource) {
2446
+ MigrationDataSource[MigrationDataSource["TEMPLE_OSRS"] = 0] = "TEMPLE_OSRS";
2447
+ MigrationDataSource[MigrationDataSource["CRYSTAL_MATH_LABS"] = 1] = "CRYSTAL_MATH_LABS";
2448
+ })(MigrationDataSource || (MigrationDataSource = {}));
2449
+
2450
+ var SnapshotDataSource;
2451
+ (function (SnapshotDataSource) {
2452
+ SnapshotDataSource[SnapshotDataSource["HISCORES"] = 0] = "HISCORES";
2453
+ SnapshotDataSource[SnapshotDataSource["CRYSTAL_MATH_LABS"] = 1] = "CRYSTAL_MATH_LABS";
2454
+ })(SnapshotDataSource || (SnapshotDataSource = {}));
2455
+
2456
+ class EfficiencyClient extends BaseAPIClient {
2457
+ /**
2458
+ * Fetches the current efficiency leaderboard for a specific efficiency metric, playerType, playerBuild and country.
2459
+ * @returns A list of players.
2460
+ */
2461
+ getEfficiencyLeaderboards(filter, pagination) {
2462
+ return this.getRequest('/efficiency/leaderboard', Object.assign(Object.assign({}, filter), pagination));
2463
+ }
2464
+ /**
2465
+ * Fetches the top EHP (Efficient Hours Played) rates.
2466
+ * @returns A list of skilling methods and their bonus exp ratios.
2467
+ */
2468
+ getEHPRates(algorithmType) {
2469
+ return this.getRequest('/efficiency/rates', {
2470
+ metric: Metric.EHP,
2471
+ type: algorithmType
2472
+ });
2473
+ }
2474
+ /**
2475
+ * Fetches the top EHB (Efficient Hours Bossed) rates.
2476
+ * @returns A list of bosses and their respective "per-hour" kill rates.
2477
+ */
2478
+ getEHBRates(algorithmType) {
2479
+ return this.getRequest('/efficiency/rates', {
2480
+ metric: Metric.EHB,
2481
+ type: algorithmType
2482
+ });
2483
+ }
2484
+ }
2485
+
2486
+ class NameChangesClient extends BaseAPIClient {
2487
+ /**
2488
+ * Searches for name changes that match a name and/or status filter.
2489
+ * @returns A list of name changes.
2490
+ */
2491
+ searchNameChanges(filter, pagination) {
2492
+ return this.getRequest('/names', Object.assign(Object.assign({}, filter), pagination));
2493
+ }
2494
+ /**
2495
+ * Submits a name change request between two usernames (old and new).
2496
+ * @returns A pending name change request, to be reviewed and resolved at a later date.
2497
+ */
2498
+ submitNameChange(oldName, newName) {
2499
+ return this.postRequest('/names', { oldName, newName });
2500
+ }
2501
+ }
2502
+
2503
+ class CompetitionsClient extends BaseAPIClient {
2504
+ /**
2505
+ * Searches for competitions that match a title, type, metric and status filter.
2506
+ * @returns A list of competitions.
2507
+ */
2508
+ searchCompetitions(filter, pagination) {
2509
+ return this.getRequest('/competitions', Object.assign(Object.assign({}, filter), pagination));
2510
+ }
2511
+ /**
2512
+ * Fetches the competition's full details, including all the participants and their progress.
2513
+ * @returns A competition with a list of participants.
2514
+ */
2515
+ getCompetitionDetails(id, previewMetric) {
2516
+ return this.getRequest(`/competitions/${id}`, { metric: previewMetric });
2517
+ }
2518
+ /**
2519
+ * Fetches the competition's participant list in CSV format.
2520
+ * @returns A string containing the CSV content.
2521
+ */
2522
+ getCompetitionDetailsCSV(id, params) {
2523
+ return this.getText(`/competitions/${id}/csv`, Object.assign({ metric: params.previewMetric }, params));
2524
+ }
2525
+ /**
2526
+ * Fetches all the values (exp, kc, etc) in chronological order within the bounds
2527
+ * of the competition, for the top 5 participants.
2528
+ * @returns A list of competition progress objects, including the player and their value history over time.
2529
+ */
2530
+ getCompetitionTopHistory(id, previewMetric) {
2531
+ return this.getRequest(`/competitions/${id}/top-history`, {
2532
+ metric: previewMetric
2533
+ });
2534
+ }
2535
+ /**
2536
+ * Creates a new competition.
2537
+ * @returns The newly created competition, and the verification code that authorizes future changes to it.
2538
+ */
2539
+ createCompetition(payload) {
2540
+ return this.postRequest('/competitions', payload);
2541
+ }
2542
+ /**
2543
+ * Edits an existing competition.
2544
+ * @returns The updated competition.
2545
+ */
2546
+ editCompetition(id, payload, verificationCode) {
2547
+ return this.putRequest(`/competitions/${id}`, Object.assign(Object.assign({}, payload), { verificationCode }));
2548
+ }
2549
+ /**
2550
+ * Deletes an existing competition.
2551
+ * @returns A confirmation message.
2552
+ */
2553
+ deleteCompetition(id, verificationCode) {
2554
+ return this.deleteRequest(`/competitions/${id}`, { verificationCode });
2555
+ }
2556
+ /**
2557
+ * Adds all (valid) given participants to a competition, ignoring duplicates.
2558
+ * @returns The number of participants added and a confirmation message.
2559
+ */
2560
+ addParticipants(id, participants, verificationCode) {
2561
+ return this.postRequest(`/competitions/${id}/participants`, {
2562
+ verificationCode,
2563
+ participants
2564
+ });
2565
+ }
2566
+ /**
2567
+ * Remove all given usernames from a competition, ignoring usernames that aren't competing.
2568
+ * @returns The number of participants removed and a confirmation message.
2569
+ */
2570
+ removeParticipants(id, participants, verificationCode) {
2571
+ return this.deleteRequest(`/competitions/${id}/participants`, {
2572
+ verificationCode,
2573
+ participants
2574
+ });
2575
+ }
2576
+ /**
2577
+ * Adds all (valid) given teams to a team competition, ignoring duplicates.
2578
+ * @returns The number of participants added and a confirmation message.
2579
+ */
2580
+ addTeams(id, teams, verificationCode) {
2581
+ return this.postRequest(`/competitions/${id}/teams`, {
2582
+ verificationCode,
2583
+ teams
2584
+ });
2585
+ }
2586
+ /**
2587
+ * Remove all given team names from a competition, ignoring names that don't exist.
2588
+ * @returns The number of participants removed and a confirmation message.
2589
+ */
2590
+ removeTeams(id, teamNames, verificationCode) {
2591
+ return this.deleteRequest(`/competitions/${id}/teams`, {
2592
+ verificationCode,
2593
+ teamNames
2594
+ });
2595
+ }
2596
+ /**
2597
+ * Adds an "update" request to the queue, for each outdated competition participant.
2598
+ * @returns The number of players to be updated and a confirmation message.
2599
+ */
2600
+ updateAll(id, verificationCode) {
2601
+ return this.postRequest(`/competitions/${id}/update-all`, {
2602
+ verificationCode
2603
+ });
2604
+ }
2605
+ }
2606
+
2607
+ class WOMClient extends BaseAPIClient {
2608
+ constructor(options) {
2609
+ const baseApiUrl = (options === null || options === void 0 ? void 0 : options.baseAPIUrl) || config.baseAPIUrl;
2610
+ const headers = {
2611
+ 'x-user-agent': (options === null || options === void 0 ? void 0 : options.userAgent) || config.defaultUserAgent
2612
+ };
2613
+ if (options === null || options === void 0 ? void 0 : options.apiKey) {
2614
+ headers['x-api-key'] = options.apiKey;
2615
+ }
2616
+ super(headers, baseApiUrl);
2617
+ this.deltas = new DeltasClient(headers, baseApiUrl);
2618
+ this.groups = new GroupsClient(headers, baseApiUrl);
2619
+ this.players = new PlayersClient(headers, baseApiUrl);
2620
+ this.records = new RecordsClient(headers, baseApiUrl);
2621
+ this.efficiency = new EfficiencyClient(headers, baseApiUrl);
2622
+ this.nameChanges = new NameChangesClient(headers, baseApiUrl);
2623
+ this.competitions = new CompetitionsClient(headers, baseApiUrl);
2624
+ }
2625
+ }
2626
+
2627
+ export { ACTIVITIES, Activity, ActivityType, BOSSES, Boss, CAPPED_MAX_TOTAL_XP, COMBAT_SKILLS, COMPETITION_STATUSES, COMPETITION_TYPES, COMPUTED_METRICS, COUNTRY_CODES, CompetitionCSVTableType, CompetitionStatus, CompetitionStatusProps, CompetitionType, CompetitionTypeProps, ComputedMetric, Country, CountryProps, EfficiencyAlgorithmType, F2P_BOSSES, GROUP_ROLES, GroupRole, GroupRoleProps, MAX_LEVEL, MAX_SKILL_EXP, MAX_VIRTUAL_LEVEL, MEMBER_SKILLS, METRICS, Metric, MetricMeasure, MetricProps, MetricType, MigrationDataSource, NameChangeStatus, PERIODS, PLAYER_BUILDS, PLAYER_STATUSES, PLAYER_TYPES, PRIVELEGED_GROUP_ROLES, Period, PeriodProps, PlayerBuild, PlayerBuildProps, PlayerStatus, PlayerStatusProps, PlayerType, PlayerTypeProps, REAL_METRICS, REAL_SKILLS, SKILLS, SKILL_EXP_AT_99, Skill, SnapshotDataSource, WOMClient, findCountry, findCountryByCode, findCountryByName, findGroupRole, findMetric, findPeriod, findPlayerBuild, findPlayerType, formatNumber, getCombatLevel, getExpForLevel, getLevel, getMetricMeasure, getMetricName, getMetricRankKey, getMetricValueKey, getMinimumValue, getParentEfficiencyMetric, isActivity, isBoss, isCompetitionStatus, isCompetitionType, isComputedMetric, isCountry, isGroupRole, isMetric, isPeriod, isPlayerBuild, isPlayerStatus, isPlayerType, isSkill, padNumber, parseMetricAbbreviation, parsePeriodExpression, round };