@opfr/services 1.2.0 → 1.4.0

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.
Files changed (62) hide show
  1. package/dist/index.es.js +1162 -1040
  2. package/dist/index.umd.js +1 -1
  3. package/dist/services/entities/helper.d.ts +1 -2
  4. package/dist/services/entities/helper.d.ts.map +1 -1
  5. package/dist/services/index.d.ts +2 -0
  6. package/dist/services/index.d.ts.map +1 -1
  7. package/dist/services/invitations/helper.d.ts +2 -7
  8. package/dist/services/invitations/helper.d.ts.map +1 -1
  9. package/dist/services/recipe/data.d.ts +3 -0
  10. package/dist/services/recipe/data.d.ts.map +1 -0
  11. package/dist/services/recipe/definition/model.d.ts +5 -0
  12. package/dist/services/recipe/definition/model.d.ts.map +1 -0
  13. package/dist/services/recipe/definition/schema.d.ts +13 -0
  14. package/dist/services/recipe/definition/schema.d.ts.map +1 -0
  15. package/dist/services/recipe/helper.d.ts +12 -0
  16. package/dist/services/recipe/helper.d.ts.map +1 -0
  17. package/dist/services/recipe/index.d.ts +3 -0
  18. package/dist/services/recipe/index.d.ts.map +1 -0
  19. package/dist/services/recipe/process/create.d.ts +3 -0
  20. package/dist/services/recipe/process/create.d.ts.map +1 -0
  21. package/dist/services/recipe/process/findMany.d.ts +5 -0
  22. package/dist/services/recipe/process/findMany.d.ts.map +1 -0
  23. package/dist/services/recipe/process/findOne.d.ts +4 -0
  24. package/dist/services/recipe/process/findOne.d.ts.map +1 -0
  25. package/dist/services/recipe/process/updateOne.d.ts +5 -0
  26. package/dist/services/recipe/process/updateOne.d.ts.map +1 -0
  27. package/dist/services/recipe/service.d.ts +24 -0
  28. package/dist/services/recipe/service.d.ts.map +1 -0
  29. package/dist/services/recipe/types.d.ts +24 -0
  30. package/dist/services/recipe/types.d.ts.map +1 -0
  31. package/dist/services/settings/definition/schema.d.ts.map +1 -1
  32. package/dist/services/settings/types.d.ts +4 -0
  33. package/dist/services/settings/types.d.ts.map +1 -1
  34. package/dist/services/user/helper.d.ts +0 -3
  35. package/dist/services/user/helper.d.ts.map +1 -1
  36. package/dist/services/user-cooldown/constants.d.ts +1 -1
  37. package/dist/services/user-cooldown/constants.d.ts.map +1 -1
  38. package/dist/services/user-inventory/helper.d.ts +7 -21
  39. package/dist/services/user-inventory/helper.d.ts.map +1 -1
  40. package/dist/services/user-meta/helper.d.ts +1 -7
  41. package/dist/services/user-meta/helper.d.ts.map +1 -1
  42. package/dist/services/user-quest/helper.d.ts +1 -0
  43. package/dist/services/user-quest/helper.d.ts.map +1 -1
  44. package/dist/services/user-rank/definition/model.d.ts +4 -0
  45. package/dist/services/user-rank/definition/model.d.ts.map +1 -0
  46. package/dist/services/user-rank/definition/schema.d.ts +13 -0
  47. package/dist/services/user-rank/definition/schema.d.ts.map +1 -0
  48. package/dist/services/user-rank/helper.d.ts +10 -0
  49. package/dist/services/user-rank/helper.d.ts.map +1 -0
  50. package/dist/services/user-rank/index.d.ts +3 -0
  51. package/dist/services/user-rank/index.d.ts.map +1 -0
  52. package/dist/services/user-rank/process/create.d.ts +4 -0
  53. package/dist/services/user-rank/process/create.d.ts.map +1 -0
  54. package/dist/services/user-rank/process/findOne.d.ts +5 -0
  55. package/dist/services/user-rank/process/findOne.d.ts.map +1 -0
  56. package/dist/services/user-rank/process/updateOne.d.ts +5 -0
  57. package/dist/services/user-rank/process/updateOne.d.ts.map +1 -0
  58. package/dist/services/user-rank/service.d.ts +14 -0
  59. package/dist/services/user-rank/service.d.ts.map +1 -0
  60. package/dist/services/user-rank/types.d.ts +10 -0
  61. package/dist/services/user-rank/types.d.ts.map +1 -0
  62. package/package.json +5 -5
package/dist/index.es.js CHANGED
@@ -1,35 +1,35 @@
1
- import { Schema as u, models as l, model as p, connect as ut, Types as ct } from "mongoose";
2
- import { randomBetween as Y, hasExpire as L, sameDay as ye, yesterday as k, capitalizeAllWords as ot, filterNullAndUndefined as N, pickFrom as dt, shuffle as Te, recordToArray as R, arrayToRecord as ve, mergeObjects as F, exclude as q, groupBy as lt, sortBy as De, seededRandom as pt, range as yt } from "@opfr/utils-lang";
3
- import ft from "node-cache";
4
- import { CREW_DEFAULT_DISINTEGRATION as Ae, CREW_DEFAULT_MEMBER_LIMIT as mt, QuestStatus as D, CREW_DEFAULT_XP_PERCENT as ht, DEFAULT_FACTION as wt, RANK_IDS_WITHOUT_BASIC as Oe, EQUIPMENT_SLOT as Be, EQUIPMENT_FROM_SLOT_TO_TYPE as gt, EFFECT_KEYS as St, CHARACTERISTICS as bt, getComputedCharacteristicValue as $t, getCurrentLevel as Et, HP_PER_VITALITY as Ut, DEFAULT_MAX_HP as It, transformToDBBuff as Tt, SHOP_DEFAULT_AVAILABLE_ENTITY_AMOUNT as Dt } from "@opfr/definitions";
5
- import * as fe from "events";
6
- const Q = "___ALL_ENTITIES___";
1
+ import { Schema as u, models as l, model as p, connect as ot, Types as dt } from "mongoose";
2
+ import { randomBetween as X, hasExpire as Q, sameDay as me, yesterday as N, capitalizeAllWords as lt, filterNullAndUndefined as F, pickFrom as pt, shuffle as Te, recordToArray as C, arrayToRecord as Be, mergeObjects as j, exclude as _, groupBy as yt, sortBy as Re, seededRandom as ft, range as mt } from "@opfr/utils-lang";
3
+ import ht from "node-cache";
4
+ import { CREW_DEFAULT_DISINTEGRATION as xe, CREW_DEFAULT_MEMBER_LIMIT as wt, QuestStatus as D, CREW_DEFAULT_XP_PERCENT as gt, DEFAULT_FACTION as St, GAME_TYPES as bt, RANK_IDS_WITHOUT_BASIC as Ce, EQUIPMENT_SLOT as qe, EFFECT_KEYS as $t, CHARACTERISTICS as Et, getComputedCharacteristicValue as Ut, getCurrentLevel as It, HP_PER_VITALITY as Dt, DEFAULT_MAX_HP as Ot, transformToDBBuff as Tt, SHOP_DEFAULT_AVAILABLE_ENTITY_AMOUNT as Rt } from "@opfr/definitions";
5
+ import * as he from "events";
6
+ const W = "___ALL_ENTITIES___";
7
7
  class f {
8
8
  cache;
9
9
  constructor(e) {
10
- this.cache = new ft({
10
+ this.cache = new ht({
11
11
  stdTTL: e,
12
12
  checkperiod: e * 0.2,
13
13
  useClones: !1
14
14
  });
15
15
  }
16
16
  async get(e) {
17
- const t = this.normalizeKey(e), a = this.cache.get(t);
18
- if (a)
19
- return a;
20
- const r = await this.fetchFromDb(e);
21
- return r && this.cache.set(t, r), r;
22
- }
23
- async update(e, t, a) {
24
- const r = await this.updateInDb(e, t, a);
25
- if (r) {
26
- const s = this.getKey(r);
27
- this.cache.del(Q), this.cache.set(this.normalizeKey(s), r);
17
+ const t = this.normalizeKey(e), r = this.cache.get(t);
18
+ if (r)
19
+ return r;
20
+ const a = await this.fetchFromDb(e);
21
+ return a && this.cache.set(t, a), a;
22
+ }
23
+ async update(e, t, r) {
24
+ const a = await this.updateInDb(e, t, r);
25
+ if (a) {
26
+ const s = this.getKey(a);
27
+ this.cache.del(W), this.cache.set(this.normalizeKey(s), a);
28
28
  }
29
- return r;
29
+ return a;
30
30
  }
31
31
  invalidate(e) {
32
- this.cache.del(Q), e && this.cache.del(this.normalizeKey(e));
32
+ this.cache.del(W), e && this.cache.del(this.normalizeKey(e));
33
33
  }
34
34
  clearAll() {
35
35
  this.cache.flushAll();
@@ -37,27 +37,27 @@ class f {
37
37
  }
38
38
  class b extends f {
39
39
  async getAll() {
40
- const e = this.cache.get(Q);
40
+ const e = this.cache.get(W);
41
41
  if (e)
42
42
  return e;
43
43
  const t = await this.fetchManyFromDb({});
44
- return this.cache.set(Q, t), t.forEach((a) => {
45
- this.cache.set(this.normalizeKey(this.getKey(a)), a);
44
+ return this.cache.set(W, t), t.forEach((r) => {
45
+ this.cache.set(this.normalizeKey(this.getKey(r)), r);
46
46
  }), t;
47
47
  }
48
48
  async getMany(e) {
49
49
  const t = await this.fetchManyFromDb(e);
50
- return t.forEach((a) => {
51
- this.cache.set(this.normalizeKey(this.getKey(a)), a);
50
+ return t.forEach((r) => {
51
+ this.cache.set(this.normalizeKey(this.getKey(r)), r);
52
52
  }), t;
53
53
  }
54
54
  }
55
- const _e = new fe.EventEmitter(), m = (n, e, t) => {
56
- _e.emit(n, e, t);
57
- }, xs = (n) => {
55
+ const ke = new he.EventEmitter(), m = (n, e, t) => {
56
+ ke.emit(n, e, t);
57
+ }, Js = (n) => {
58
58
  for (const [e, t] of Object.entries(n))
59
- _e.on(e, (a, r) => {
60
- t(a, r);
59
+ ke.on(e, (r, a) => {
60
+ t(r, a);
61
61
  });
62
62
  }, h = {
63
63
  CREW: "middleware/quest/CREW",
@@ -79,36 +79,36 @@ const _e = new fe.EventEmitter(), m = (n, e, t) => {
79
79
  USER_STATS_FLAGS: "middleware/quest/USER_STATS_FLAGS",
80
80
  USER_STATS_FREQUENCY: "middleware/quest/USER_STATS_FREQUENCY",
81
81
  USER_STATS_INVENTORY: "middleware/quest/USER_STATS_INVENTORY"
82
- }, xe = new fe.EventEmitter(), me = (n, e, t) => {
83
- xe.emit(n, e, t);
84
- }, qs = (n) => {
82
+ }, _e = new he.EventEmitter(), we = (n, e, t) => {
83
+ _e.emit(n, e, t);
84
+ }, Zs = (n) => {
85
85
  for (const [e, t] of Object.entries(n))
86
- xe.on(e, (a, r) => {
87
- t(a, r);
86
+ _e.on(e, (r, a) => {
87
+ t(r, a);
88
88
  });
89
- }, he = {
89
+ }, ge = {
90
90
  USER_INVENTORY: "middleware/raid/USER_INVENTORY",
91
91
  USER_QUEST: "middleware/raid/USER_QUEST",
92
92
  USER_RAID: "middleware/raid/USER_RAID"
93
- }, qe = new u(
93
+ }, Ne = new u(
94
94
  {
95
95
  createdBy: u.Types.ObjectId,
96
96
  name: String,
97
97
  description: String,
98
98
  channelId: String,
99
- memberLimit: { type: Number, default: mt },
100
- disintegration: { type: Number, default: Ae },
99
+ memberLimit: { type: Number, default: wt },
100
+ disintegration: { type: Number, default: xe },
101
101
  faction: String
102
102
  },
103
103
  { timestamps: !0, minimize: !1 }
104
104
  );
105
- qe.post("findOneAndUpdate", async function(n) {
105
+ Ne.post("findOneAndUpdate", async function(n) {
106
106
  m(h.CREW, n._id, n);
107
107
  });
108
- const W = l?.Crew || p("Crew", qe);
109
- class Ot extends f {
108
+ const G = l?.Crew || p("Crew", Ne);
109
+ class Ct extends f {
110
110
  async getCrewRank(e) {
111
- return (await W.aggregate([
111
+ return (await G.aggregate([
112
112
  {
113
113
  $lookup: {
114
114
  from: "crewmetas",
@@ -134,7 +134,7 @@ class Ot extends f {
134
134
  ]))[0];
135
135
  }
136
136
  getCrewRanking() {
137
- return W.aggregate([
137
+ return G.aggregate([
138
138
  {
139
139
  $lookup: {
140
140
  from: "crewmetas",
@@ -173,13 +173,13 @@ class Ot extends f {
173
173
  async applyDisintegration(e) {
174
174
  const t = await this.get(e);
175
175
  if (!t) return;
176
- const { memberLimit: a } = t, [r, s] = [a - 2, (a - 3) * 2 + 3];
176
+ const { memberLimit: r } = t, [a, s] = [r - 2, (r - 3) * 2 + 3];
177
177
  await this.update(e, [
178
178
  {
179
179
  $set: {
180
180
  disintegration: {
181
181
  $max: [
182
- { $add: ["$disintegration", -1 * Y(r, s)] },
182
+ { $add: ["$disintegration", -1 * X(a, s)] },
183
183
  0
184
184
  ]
185
185
  }
@@ -188,13 +188,13 @@ class Ot extends f {
188
188
  ]);
189
189
  }
190
190
  }
191
- const Ct = async (n) => {
192
- const e = await W.findById(n).lean();
191
+ const vt = async (n) => {
192
+ const e = await G.findById(n).lean();
193
193
  return e || null;
194
- }, Rt = (n, e) => W.findOneAndUpdate({ _id: n }, e, {
194
+ }, At = (n, e) => G.findOneAndUpdate({ _id: n }, e, {
195
195
  returnDocument: "after"
196
196
  }).lean();
197
- class Mt extends Ot {
197
+ class Mt extends Ct {
198
198
  constructor() {
199
199
  super(3600);
200
200
  }
@@ -205,23 +205,23 @@ class Mt extends Ot {
205
205
  return e;
206
206
  }
207
207
  fetchFromDb(e) {
208
- return Ct(e);
208
+ return vt(e);
209
209
  }
210
210
  updateInDb(e, t) {
211
- return Rt(e, t);
211
+ return At(e, t);
212
212
  }
213
213
  }
214
- const vt = new Mt();
215
- class At extends f {
214
+ const Bt = new Mt();
215
+ class xt extends f {
216
216
  async hasXpBuff(e) {
217
217
  const t = await this.get(e);
218
- if (!L(t.buffs.xp.expireAt))
218
+ if (!Q(t.buffs.xp.expireAt))
219
219
  return t.buffs.xp;
220
220
  }
221
221
  async calcXp(e, t) {
222
- const a = await vt.get(e);
223
- return a ? Math.ceil(
224
- t * (a.disintegration / Ae) * ((await this.hasXpBuff(e))?.boost ?? 1)
222
+ const r = await Bt.get(e);
223
+ return r ? Math.ceil(
224
+ t * (r.disintegration / xe) * ((await this.hasXpBuff(e))?.boost ?? 1)
225
225
  ) : 0;
226
226
  }
227
227
  async addXp(e, t) {
@@ -246,18 +246,18 @@ class At extends f {
246
246
  });
247
247
  }
248
248
  async addXpBuff(e, t) {
249
- const a = /* @__PURE__ */ new Date();
249
+ const r = /* @__PURE__ */ new Date();
250
250
  await this.update(e, [
251
251
  {
252
252
  $set: {
253
253
  "buffs.xp": {
254
254
  $cond: {
255
255
  if: {
256
- lt: ["$buffs.xp.expireAt", a]
256
+ lt: ["$buffs.xp.expireAt", r]
257
257
  },
258
258
  then: {
259
259
  boost: 1.1,
260
- expireAt: { $add: [a, t * 60 * 60 * 1e3] }
260
+ expireAt: { $add: [r, t * 60 * 60 * 1e3] }
261
261
  },
262
262
  else: {
263
263
  boost: 1.1,
@@ -272,7 +272,7 @@ class At extends f {
272
272
  ]);
273
273
  }
274
274
  }
275
- const y = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), ke = new u({
275
+ const y = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), Fe = new u({
276
276
  crew: {
277
277
  type: u.Types.ObjectId,
278
278
  required: !0,
@@ -288,25 +288,25 @@ const y = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), ke = new
288
288
  }
289
289
  }
290
290
  });
291
- ke.post("findOneAndUpdate", async function(n) {
291
+ Fe.post("findOneAndUpdate", async function(n) {
292
292
  m(
293
293
  h.CREW_META,
294
294
  n.crew._id,
295
295
  n
296
296
  );
297
297
  });
298
- const we = l?.CrewMeta || p("CrewMeta", ke), Bt = async (n) => await we.create({
298
+ const Se = l?.CrewMeta || p("CrewMeta", Fe), qt = async (n) => await Se.create({
299
299
  crew: n
300
300
  });
301
- async function _t(n) {
302
- const e = await we.findOne({ crew: n }).lean();
303
- return e || y(await Bt(n));
301
+ async function kt(n) {
302
+ const e = await Se.findOne({ crew: n }).lean();
303
+ return e || y(await qt(n));
304
304
  }
305
- const xt = (n, e) => we.findOneAndUpdate({ crew: n }, e, {
305
+ const _t = (n, e) => Se.findOneAndUpdate({ crew: n }, e, {
306
306
  returnDocument: "after",
307
307
  upsert: !0
308
308
  }).lean();
309
- class qt extends At {
309
+ class Nt extends xt {
310
310
  constructor() {
311
311
  super(300);
312
312
  }
@@ -317,23 +317,23 @@ class qt extends At {
317
317
  return e;
318
318
  }
319
319
  fetchFromDb(e) {
320
- return _t(e);
320
+ return kt(e);
321
321
  }
322
322
  updateInDb(e, t) {
323
- return xt(e, t);
323
+ return _t(e, t);
324
324
  }
325
325
  }
326
- const Ce = new qt();
327
- class kt extends f {
328
- async unlockBadge(e, t, a) {
326
+ const ve = new Nt();
327
+ class Ft extends f {
328
+ async unlockBadge(e, t, r) {
329
329
  t.isProgressive ? await this.update(e, {
330
- $addToSet: { unlockedBadges: `${t.id}_${a}` }
330
+ $addToSet: { unlockedBadges: `${t.id}_${r}` }
331
331
  }) : await this.update(e, {
332
332
  $addToSet: { unlockedBadges: t.id }
333
333
  });
334
334
  }
335
335
  }
336
- const Ne = new u({
336
+ const je = new u({
337
337
  crew: {
338
338
  type: u.Types.ObjectId,
339
339
  required: !0,
@@ -342,25 +342,25 @@ const Ne = new u({
342
342
  },
343
343
  unlockedBadges: { type: [String], default: [] }
344
344
  });
345
- Ne.post("findOneAndUpdate", async function(n) {
345
+ je.post("findOneAndUpdate", async function(n) {
346
346
  m(
347
347
  h.CREW_ORNAMENTS,
348
348
  n.crew._id,
349
349
  n
350
350
  );
351
351
  });
352
- const ge = l?.CrewOrnaments || p("CrewOrnaments", Ne), Nt = (n) => ge.create({
352
+ const be = l?.CrewOrnaments || p("CrewOrnaments", je), jt = (n) => be.create({
353
353
  crew: n
354
354
  });
355
- async function Ft(n) {
356
- const e = await ge.findOne({ crew: n }).lean();
357
- return e || y(await Nt(n));
355
+ async function zt(n) {
356
+ const e = await be.findOne({ crew: n }).lean();
357
+ return e || y(await jt(n));
358
358
  }
359
- const jt = (n, e) => ge.findOneAndUpdate({ crew: n }, e, {
359
+ const Kt = (n, e) => be.findOneAndUpdate({ crew: n }, e, {
360
360
  upsert: !0,
361
361
  returnDocument: "after"
362
362
  }).lean();
363
- class zt extends kt {
363
+ class Pt extends Ft {
364
364
  constructor() {
365
365
  super(300);
366
366
  }
@@ -371,14 +371,14 @@ class zt extends kt {
371
371
  return e;
372
372
  }
373
373
  fetchFromDb(e) {
374
- return Ft(e);
374
+ return zt(e);
375
375
  }
376
376
  updateInDb(e, t) {
377
- return jt(e, t);
377
+ return Kt(e, t);
378
378
  }
379
379
  }
380
- const ks = new zt();
381
- class Pt extends b {
380
+ const ei = new Pt();
381
+ class Ht extends b {
382
382
  async getStatus(e, t) {
383
383
  return (await this.get({ crew: e, questId: t })).status;
384
384
  }
@@ -386,8 +386,8 @@ class Pt extends b {
386
386
  return await this.getStatus(e, t) === "COMPLETED";
387
387
  }
388
388
  async isStreaking(e, t) {
389
- const { lastCompletionDate: a } = await this.get({ crew: e, questId: t });
390
- return !!a && ye(k(), a);
389
+ const { lastCompletionDate: r } = await this.get({ crew: e, questId: t });
390
+ return !!r && me(N(), r);
391
391
  }
392
392
  async completeQuest(e) {
393
393
  return this.update(
@@ -404,7 +404,7 @@ class Pt extends b {
404
404
  );
405
405
  }
406
406
  }
407
- const Fe = new u(
407
+ const ze = new u(
408
408
  {
409
409
  crew: {
410
410
  type: u.Types.ObjectId,
@@ -422,32 +422,32 @@ const Fe = new u(
422
422
  },
423
423
  { minimize: !1 }
424
424
  );
425
- Fe.post("findOneAndUpdate", function(n) {
425
+ ze.post("findOneAndUpdate", function(n) {
426
426
  m(
427
427
  h.CREW_QUEST,
428
428
  n.crew._id,
429
429
  n
430
430
  );
431
431
  });
432
- const X = l?.CrewQuest || p("CrewQuest", Fe);
433
- function Kt(n) {
434
- return X.find(n).lean();
432
+ const V = l?.CrewQuest || p("CrewQuest", ze);
433
+ function Lt(n) {
434
+ return V.find(n).lean();
435
435
  }
436
- const Ht = async (n) => await X.create({
436
+ const Qt = async (n) => await V.create({
437
437
  ...n
438
438
  });
439
- async function Lt(n) {
440
- const e = await X.findOne(n).lean();
441
- return e || y(await Ht(n));
439
+ async function Wt(n) {
440
+ const e = await V.findOne(n).lean();
441
+ return e || y(await Qt(n));
442
442
  }
443
- function Qt(n, e, t) {
444
- return X.findOneAndUpdate(n, e, {
443
+ function Gt(n, e, t) {
444
+ return V.findOneAndUpdate(n, e, {
445
445
  upsert: !0,
446
446
  ...t,
447
447
  returnDocument: "after"
448
448
  }).lean();
449
449
  }
450
- class Wt extends Pt {
450
+ class Yt extends Ht {
451
451
  constructor() {
452
452
  super(300);
453
453
  }
@@ -461,17 +461,17 @@ class Wt extends Pt {
461
461
  return { crew: e, questId: t };
462
462
  }
463
463
  fetchFromDb(e) {
464
- return Lt(e);
464
+ return Wt(e);
465
465
  }
466
466
  fetchManyFromDb(e) {
467
- return Kt(e);
467
+ return Lt(e);
468
468
  }
469
- updateInDb(e, t, a) {
470
- return Qt(e, t, a);
469
+ updateInDb(e, t, r) {
470
+ return Gt(e, t, r);
471
471
  }
472
472
  }
473
- const Ns = new Wt();
474
- class Gt extends f {
473
+ const ti = new Yt();
474
+ class Xt extends f {
475
475
  async setActualVoiceMembers(e, t) {
476
476
  await this.update(e, {
477
477
  $set: {
@@ -488,7 +488,7 @@ class Gt extends f {
488
488
  });
489
489
  }
490
490
  }
491
- const je = new u({
491
+ const Ke = new u({
492
492
  crew: {
493
493
  type: u.Types.ObjectId,
494
494
  required: !0,
@@ -501,28 +501,28 @@ const je = new u({
501
501
  connectedAt: { type: Date, default: /* @__PURE__ */ new Date(0) }
502
502
  }
503
503
  });
504
- je.post("findOneAndUpdate", function(n) {
504
+ Ke.post("findOneAndUpdate", function(n) {
505
505
  m(
506
506
  h.CREW_STATS_ENGAGEMENT,
507
507
  n.crew._id,
508
508
  n
509
509
  );
510
510
  });
511
- const Se = l?.CrewStatsEngagement || p(
511
+ const $e = l?.CrewStatsEngagement || p(
512
512
  "CrewStatsEngagement",
513
- je
514
- ), Yt = (n) => Se.create({
513
+ Ke
514
+ ), Vt = (n) => $e.create({
515
515
  crew: n
516
516
  });
517
- async function Xt(n) {
518
- const e = await Se.findOne({ crew: n }).lean();
519
- return e || y(await Yt(n));
517
+ async function Jt(n) {
518
+ const e = await $e.findOne({ crew: n }).lean();
519
+ return e || y(await Vt(n));
520
520
  }
521
- const Vt = (n, e) => Se.findOneAndUpdate({ crew: n }, e, {
521
+ const Zt = (n, e) => $e.findOneAndUpdate({ crew: n }, e, {
522
522
  upsert: !0,
523
523
  returnDocument: "after"
524
524
  }).lean();
525
- class Jt extends Gt {
525
+ class en extends Xt {
526
526
  constructor() {
527
527
  super(300);
528
528
  }
@@ -535,16 +535,16 @@ class Jt extends Gt {
535
535
  return e;
536
536
  }
537
537
  fetchFromDb(e) {
538
- return Xt(e);
538
+ return Jt(e);
539
539
  }
540
540
  updateInDb(e, t) {
541
- return Vt(e, t);
541
+ return Zt(e, t);
542
542
  }
543
543
  }
544
- const Fs = new Jt();
545
- class Zt extends f {
544
+ const ni = new en();
545
+ class tn extends f {
546
546
  }
547
- const ze = new u({
547
+ const Pe = new u({
548
548
  crew: {
549
549
  type: u.Types.ObjectId,
550
550
  required: !0,
@@ -553,28 +553,28 @@ const ze = new u({
553
553
  },
554
554
  streak80Percent: { type: Number, default: 0 }
555
555
  });
556
- ze.post("findOneAndUpdate", function(n) {
556
+ Pe.post("findOneAndUpdate", function(n) {
557
557
  m(
558
558
  h.CREW_STATS_FREQUENCY,
559
559
  n.crew._id,
560
560
  n
561
561
  );
562
562
  });
563
- const be = l?.CrewStatsFrequency || p(
563
+ const Ee = l?.CrewStatsFrequency || p(
564
564
  "CrewStatsFrequency",
565
- ze
566
- ), en = (n) => be.create({
565
+ Pe
566
+ ), nn = (n) => Ee.create({
567
567
  crew: n
568
568
  });
569
- async function tn(n) {
570
- const e = await be.findOne({ crew: n }).lean();
571
- return e || y(await en(n));
569
+ async function rn(n) {
570
+ const e = await Ee.findOne({ crew: n }).lean();
571
+ return e || y(await nn(n));
572
572
  }
573
- const nn = (n, e) => be.findOneAndUpdate({ crew: n }, e, {
573
+ const an = (n, e) => Ee.findOneAndUpdate({ crew: n }, e, {
574
574
  upsert: !0,
575
575
  returnDocument: "after"
576
576
  }).lean();
577
- class an extends Zt {
577
+ class sn extends tn {
578
578
  constructor() {
579
579
  super(300);
580
580
  }
@@ -585,13 +585,13 @@ class an extends Zt {
585
585
  return e;
586
586
  }
587
587
  fetchFromDb(e) {
588
- return tn(e);
588
+ return rn(e);
589
589
  }
590
590
  updateInDb(e, t) {
591
- return nn(e, t);
591
+ return an(e, t);
592
592
  }
593
593
  }
594
- const js = new an(), Pe = new u(
594
+ const ri = new sn(), He = new u(
595
595
  {
596
596
  user: {
597
597
  type: u.Types.ObjectId,
@@ -610,9 +610,9 @@ const js = new an(), Pe = new u(
610
610
  },
611
611
  { minimize: !1 }
612
612
  );
613
- Pe.post("findOneAndUpdate", function(n) {
614
- me(
615
- he.USER_QUEST,
613
+ He.post("findOneAndUpdate", function(n) {
614
+ we(
615
+ ge.USER_QUEST,
616
616
  n.user._id,
617
617
  n
618
618
  ), m(
@@ -621,7 +621,7 @@ Pe.post("findOneAndUpdate", function(n) {
621
621
  n
622
622
  );
623
623
  });
624
- const B = l?.UserQuest || p("UserQuest", Pe), rn = new u({
624
+ const x = l?.UserQuest || p("UserQuest", He), un = new u({
625
625
  user: {
626
626
  type: u.Types.ObjectId,
627
627
  required: !0,
@@ -636,12 +636,12 @@ const B = l?.UserQuest || p("UserQuest", Pe), rn = new u({
636
636
  commands: {
637
637
  work: { type: Date, default: /* @__PURE__ */ new Date(0) },
638
638
  dice: { type: Date, default: /* @__PURE__ */ new Date(0) },
639
- qod: { type: Date, default: /* @__PURE__ */ new Date(0) },
640
- guess: { type: Date, default: /* @__PURE__ */ new Date(0) },
641
- blackjack: { type: Date, default: /* @__PURE__ */ new Date(0) },
639
+ doubleOrQuit: { type: Date, default: /* @__PURE__ */ new Date(0) },
640
+ priceIsRight: { type: Date, default: /* @__PURE__ */ new Date(0) },
641
+ blackJack: { type: Date, default: /* @__PURE__ */ new Date(0) },
642
642
  rps: { type: Date, default: /* @__PURE__ */ new Date(0) }
643
643
  }
644
- }), V = l?.UserCooldown || p("UserCooldown", rn), Ke = new u(
644
+ }), J = l?.UserCooldown || p("UserCooldown", un), Le = new u(
645
645
  {
646
646
  user: {
647
647
  type: u.Types.ObjectId,
@@ -656,18 +656,18 @@ const B = l?.UserQuest || p("UserQuest", Pe), rn = new u({
656
656
  index: !0
657
657
  },
658
658
  permission: { type: String, default: "member", required: !0 },
659
- percent: { type: Number, default: ht }
659
+ percent: { type: Number, default: gt }
660
660
  },
661
661
  { minimize: !1 }
662
662
  );
663
- Ke.post("findOneAndUpdate", function(n) {
663
+ Le.post("findOneAndUpdate", function(n) {
664
664
  m(
665
665
  h.USER_CREW,
666
666
  n.user._id,
667
667
  n
668
668
  );
669
669
  });
670
- const _ = l?.UserCrew || p("UserCrew", Ke), sn = new u({
670
+ const q = l?.UserCrew || p("UserCrew", Le), cn = new u({
671
671
  user: {
672
672
  type: u.Types.ObjectId,
673
673
  required: !0,
@@ -683,7 +683,7 @@ const _ = l?.UserCrew || p("UserCrew", Ke), sn = new u({
683
683
  },
684
684
  previousCompletedQuest: { type: [String], default: [] },
685
685
  previousMessageSent: { type: Number, default: 0 }
686
- }), J = l?.UserDailyReport || p("UserDailyReport", sn), un = new u({
686
+ }), Z = l?.UserDailyReport || p("UserDailyReport", cn), on = new u({
687
687
  user: {
688
688
  type: u.Types.ObjectId,
689
689
  required: !0,
@@ -691,7 +691,7 @@ const _ = l?.UserCrew || p("UserCrew", Ke), sn = new u({
691
691
  ref: "User"
692
692
  },
693
693
  encyclopedia: { type: [String], default: [] }
694
- }), Z = l?.UserEncyclopedia || p("UserEncyclopedia", un), cn = new u({
694
+ }), ee = l?.UserEncyclopedia || p("UserEncyclopedia", on), dn = new u({
695
695
  user: {
696
696
  type: u.Types.ObjectId,
697
697
  required: !0,
@@ -708,7 +708,7 @@ const _ = l?.UserCrew || p("UserCrew", Ke), sn = new u({
708
708
  },
709
709
  default: null
710
710
  }
711
- }), ee = l?.UserGames || p("UserGames", cn), He = new u(
711
+ }), te = l?.UserGames || p("UserGames", dn), Qe = new u(
712
712
  {
713
713
  user: {
714
714
  type: u.Types.ObjectId,
@@ -730,9 +730,9 @@ const _ = l?.UserCrew || p("UserCrew", Ke), sn = new u({
730
730
  },
731
731
  { minimize: !1 }
732
732
  );
733
- He.post("findOneAndUpdate", function(n) {
734
- me(
735
- he.USER_INVENTORY,
733
+ Qe.post("findOneAndUpdate", function(n) {
734
+ we(
735
+ ge.USER_INVENTORY,
736
736
  n.user._id,
737
737
  n
738
738
  ), m(
@@ -741,14 +741,14 @@ He.post("findOneAndUpdate", function(n) {
741
741
  n
742
742
  );
743
743
  });
744
- const te = l?.UserInventory || p("UserInventory", He), on = new fe.EventEmitter(), dn = (n, e) => {
745
- on.emit(n, e);
746
- }, C = {
744
+ const ne = l?.UserInventory || p("UserInventory", Qe), ln = new he.EventEmitter(), pn = (n, e) => {
745
+ ln.emit(n, e);
746
+ }, R = {
747
747
  multiplier: { type: Number, default: 0 },
748
748
  origin: String,
749
749
  expireAt: { type: Date, default: null },
750
750
  startAt: { type: Date, default: null }
751
- }, Le = new u({
751
+ }, We = new u({
752
752
  user: {
753
753
  type: u.Types.ObjectId,
754
754
  required: !0,
@@ -771,33 +771,33 @@ const te = l?.UserInventory || p("UserInventory", He), on = new fe.EventEmitter(
771
771
  buffs: {
772
772
  cooldown: {
773
773
  casino: {
774
- type: [C],
774
+ type: [R],
775
775
  default: []
776
776
  },
777
777
  work: {
778
- type: [C],
778
+ type: [R],
779
779
  default: []
780
780
  }
781
781
  },
782
782
  berry: {
783
783
  work: {
784
- type: [C],
784
+ type: [R],
785
785
  default: []
786
786
  },
787
787
  global: {
788
- type: [C],
788
+ type: [R],
789
789
  default: []
790
790
  }
791
791
  },
792
792
  drop: {
793
793
  work: {
794
- type: [C],
794
+ type: [R],
795
795
  default: []
796
796
  }
797
797
  },
798
798
  xp: {
799
799
  global: {
800
- type: [C],
800
+ type: [R],
801
801
  default: []
802
802
  }
803
803
  }
@@ -825,14 +825,14 @@ const te = l?.UserInventory || p("UserInventory", He), on = new fe.EventEmitter(
825
825
  wisdom: { type: Number, default: 0 }
826
826
  }
827
827
  });
828
- Le.post("findOneAndUpdate", async function(n) {
828
+ We.post("findOneAndUpdate", async function(n) {
829
829
  m(
830
830
  h.USER_META,
831
831
  n.user._id,
832
832
  n
833
- ), n.hp <= 0 && dn("death", n.user._id);
833
+ ), n.hp <= 0 && pn("death", n.user._id);
834
834
  });
835
- const O = l?.UserMeta || p("UserMeta", Le), Qe = new u({
835
+ const T = l?.UserMeta || p("UserMeta", We), Ge = new u({
836
836
  user: {
837
837
  type: u.Types.ObjectId,
838
838
  required: !0,
@@ -849,14 +849,14 @@ const O = l?.UserMeta || p("UserMeta", Le), Qe = new u({
849
849
  unlockedBags: { type: [String], default: ["default"] },
850
850
  selectedBag: { type: String, default: "default" }
851
851
  });
852
- Qe.post("findOneAndUpdate", function(n) {
852
+ Ge.post("findOneAndUpdate", function(n) {
853
853
  m(
854
854
  h.USER_ORNAMENT,
855
855
  n.user._id,
856
856
  n
857
857
  );
858
858
  });
859
- const ne = l?.UserOrnament || p("UserOrnament", Qe), We = new u(
859
+ const re = l?.UserOrnament || p("UserOrnament", Ge), Ye = new u(
860
860
  {
861
861
  user: {
862
862
  type: u.Types.ObjectId,
@@ -880,14 +880,14 @@ const ne = l?.UserOrnament || p("UserOrnament", Qe), We = new u(
880
880
  },
881
881
  { minimize: !1 }
882
882
  );
883
- We.post("findOneAndUpdate", function(n) {
884
- me(
885
- he.USER_RAID,
883
+ Ye.post("findOneAndUpdate", function(n) {
884
+ we(
885
+ ge.USER_RAID,
886
886
  n.user._id,
887
887
  n
888
888
  );
889
889
  });
890
- const ae = l?.UserRaid || p("UserRaid", We), ln = new u({
890
+ const ae = l?.UserRaid || p("UserRaid", Ye), yn = new u({
891
891
  user: {
892
892
  type: u.Types.ObjectId,
893
893
  required: !0,
@@ -913,7 +913,7 @@ const ae = l?.UserRaid || p("UserRaid", We), ln = new u({
913
913
  rps: { type: Boolean, default: !1 }
914
914
  }
915
915
  }
916
- }), j = l?.UserSettings || p("UserSettings", ln), pn = new u(
916
+ }), z = l?.UserSettings || p("UserSettings", yn), fn = new u(
917
917
  {
918
918
  user: {
919
919
  type: u.Types.ObjectId,
@@ -925,7 +925,7 @@ const ae = l?.UserRaid || p("UserRaid", We), ln = new u({
925
925
  limit: { type: u.Types.Mixed, default: {} }
926
926
  },
927
927
  { minimize: !1 }
928
- ), re = l?.UserShop || p("UserShop", pn), Ge = new u({
928
+ ), se = l?.UserShop || p("UserShop", fn), Xe = new u({
929
929
  user: {
930
930
  type: u.Types.ObjectId,
931
931
  required: !0,
@@ -960,14 +960,14 @@ const ae = l?.UserRaid || p("UserRaid", We), ln = new u({
960
960
  guessInOneTryCount: { type: Number, default: 0 }
961
961
  }
962
962
  });
963
- Ge.post("findOneAndUpdate", function(n) {
963
+ Xe.post("findOneAndUpdate", function(n) {
964
964
  m(
965
965
  h.USER_STATS_CASINO,
966
966
  n.user._id,
967
967
  n
968
968
  );
969
969
  });
970
- const M = l?.UserStatsCasino || p("UserStatsCasino", Ge), Ye = new u({
970
+ const A = l?.UserStatsCasino || p("UserStatsCasino", Xe), Ve = new u({
971
971
  user: {
972
972
  type: u.Types.ObjectId,
973
973
  required: !0,
@@ -979,14 +979,14 @@ const M = l?.UserStatsCasino || p("UserStatsCasino", Ge), Ye = new u({
979
979
  timeCrewBeyond10PercentXp: { type: Number, default: 0 },
980
980
  timeCrewAbove90PercentXp: { type: Number, default: 0 }
981
981
  });
982
- Ye.post("findOneAndUpdate", function(n) {
982
+ Ve.post("findOneAndUpdate", function(n) {
983
983
  m(
984
984
  h.USER_STATS_CREW,
985
985
  n.user._id,
986
986
  n
987
987
  );
988
988
  });
989
- const se = l?.UserStatsCrew || p("UserStatsCrew", Ye), Xe = new u({
989
+ const ie = l?.UserStatsCrew || p("UserStatsCrew", Ve), Je = new u({
990
990
  user: {
991
991
  type: u.Types.ObjectId,
992
992
  required: !0,
@@ -997,14 +997,14 @@ const se = l?.UserStatsCrew || p("UserStatsCrew", Ye), Xe = new u({
997
997
  raidFinishedCount: { type: Number, default: 0 },
998
998
  totalSpentInShop: { type: Number, default: 0 }
999
999
  });
1000
- Xe.post("findOneAndUpdate", function(n) {
1000
+ Je.post("findOneAndUpdate", function(n) {
1001
1001
  m(
1002
1002
  h.USER_STATS_ECONOMY,
1003
1003
  n.user._id,
1004
1004
  n
1005
1005
  );
1006
1006
  });
1007
- const ie = l?.UserStatsEconomy || p("UserStatsEconomy", Xe), Ve = new u({
1007
+ const ue = l?.UserStatsEconomy || p("UserStatsEconomy", Je), Ze = new u({
1008
1008
  user: {
1009
1009
  type: u.Types.ObjectId,
1010
1010
  required: !0,
@@ -1016,17 +1016,17 @@ const ie = l?.UserStatsEconomy || p("UserStatsEconomy", Xe), Ve = new u({
1016
1016
  randomMessageClaimed: { type: Number, default: 0 },
1017
1017
  writeDifferentChatIds: { type: [String], default: [] }
1018
1018
  });
1019
- Ve.post("findOneAndUpdate", function(n) {
1019
+ Ze.post("findOneAndUpdate", function(n) {
1020
1020
  m(
1021
1021
  h.USER_STATS_ENGAGEMENT,
1022
1022
  n.user._id,
1023
1023
  n
1024
1024
  );
1025
1025
  });
1026
- const ue = l?.UserStatsEngagement || p(
1026
+ const ce = l?.UserStatsEngagement || p(
1027
1027
  "UserStatsEngagement",
1028
- Ve
1029
- ), Je = new u({
1028
+ Ze
1029
+ ), et = new u({
1030
1030
  user: {
1031
1031
  type: u.Types.ObjectId,
1032
1032
  required: !0,
@@ -1045,14 +1045,14 @@ const ue = l?.UserStatsEngagement || p(
1045
1045
  loseEverything: { type: Boolean, default: !1 }
1046
1046
  }
1047
1047
  });
1048
- Je.post("findOneAndUpdate", function(n) {
1048
+ et.post("findOneAndUpdate", function(n) {
1049
1049
  m(
1050
1050
  h.USER_STATS_FLAGS,
1051
1051
  n.user._id,
1052
1052
  n
1053
1053
  );
1054
1054
  });
1055
- const ce = l?.UserStatsFlags || p("UserStatsFlags", Je), Ze = new u({
1055
+ const oe = l?.UserStatsFlags || p("UserStatsFlags", et), tt = new u({
1056
1056
  user: {
1057
1057
  type: u.Types.ObjectId,
1058
1058
  required: !0,
@@ -1064,17 +1064,17 @@ const ce = l?.UserStatsFlags || p("UserStatsFlags", Je), Ze = new u({
1064
1064
  lastTimeRead: { type: Date, default: /* @__PURE__ */ new Date() }
1065
1065
  }
1066
1066
  });
1067
- Ze.post("findOneAndUpdate", function(n) {
1067
+ tt.post("findOneAndUpdate", function(n) {
1068
1068
  m(
1069
1069
  h.USER_STATS_FREQUENCY,
1070
1070
  n.user._id,
1071
1071
  n
1072
1072
  );
1073
1073
  });
1074
- const v = l?.UserStatsFrequency || p(
1074
+ const M = l?.UserStatsFrequency || p(
1075
1075
  "UserStatsFrequency",
1076
- Ze
1077
- ), et = new u({
1076
+ tt
1077
+ ), nt = new u({
1078
1078
  user: {
1079
1079
  type: u.Types.ObjectId,
1080
1080
  required: !0,
@@ -1101,32 +1101,32 @@ const v = l?.UserStatsFrequency || p(
1101
1101
  totalCrafted: { type: Number, default: 0 }
1102
1102
  }
1103
1103
  });
1104
- et.post("findOneAndUpdate", function(n) {
1104
+ nt.post("findOneAndUpdate", function(n) {
1105
1105
  m(
1106
1106
  h.USER_STATS_INVENTORY,
1107
1107
  n.user._id,
1108
1108
  n
1109
1109
  );
1110
1110
  });
1111
- const A = l?.UserStatsInventory || p(
1111
+ const B = l?.UserStatsInventory || p(
1112
1112
  "UserStatsInventory",
1113
- et
1114
- ), $e = new u({
1113
+ nt
1114
+ ), Ue = new u({
1115
1115
  discordId: { type: String, required: !0, unique: !0 },
1116
1116
  birthday: { type: Date, default: null, index: 1 },
1117
- faction: { type: String, default: wt, index: 1 },
1117
+ faction: { type: String, default: St, index: 1 },
1118
1118
  canChangeFaction: { type: Boolean, default: !1 },
1119
1119
  canChooseFaction: { type: Boolean, default: !1 }
1120
1120
  });
1121
- $e.post("findOneAndUpdate", function(n) {
1121
+ Ue.post("findOneAndUpdate", function(n) {
1122
1122
  m(h.USER, n._id, n);
1123
1123
  });
1124
- $e.post("deleteOne", async function() {
1124
+ Ue.post("deleteOne", async function() {
1125
1125
  const n = this.getQuery()._id;
1126
- await V.deleteOne({ user: n }), await _.deleteOne({ user: n }), await J.deleteOne({ user: n }), await Z.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await te.deleteOne({ user: n }), await O.deleteOne({ user: n }), await ne.deleteOne({ user: n }), await B.deleteMany({ user: n }), await ae.deleteOne({ user: n }), await j.deleteOne({ user: n }), await re.deleteOne({ user: n }), await M.deleteOne({ user: n }), await se.deleteOne({ user: n }), await ie.deleteOne({ user: n }), await ue.deleteOne({ user: n }), await ce.deleteOne({ user: n }), await v.deleteOne({ user: n }), await A.deleteOne({ user: n });
1126
+ await J.deleteOne({ user: n }), await q.deleteOne({ user: n }), await Z.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await te.deleteOne({ user: n }), await ne.deleteOne({ user: n }), await T.deleteOne({ user: n }), await re.deleteOne({ user: n }), await x.deleteMany({ user: n }), await ae.deleteOne({ user: n }), await z.deleteOne({ user: n }), await se.deleteOne({ user: n }), await A.deleteOne({ user: n }), await ie.deleteOne({ user: n }), await ue.deleteOne({ user: n }), await ce.deleteOne({ user: n }), await oe.deleteOne({ user: n }), await M.deleteOne({ user: n }), await B.deleteOne({ user: n });
1127
1127
  });
1128
- const $ = l?.User || p("User", $e);
1129
- class yn extends b {
1128
+ const $ = l?.User || p("User", Ue);
1129
+ class mn extends b {
1130
1130
  getByObjectId(e) {
1131
1131
  return this.update({ _id: e }, {});
1132
1132
  }
@@ -1182,34 +1182,6 @@ class yn extends b {
1182
1182
  }
1183
1183
  ]);
1184
1184
  }
1185
- async getFactionRank(e) {
1186
- const t = await this.get(e);
1187
- return (await $.aggregate([
1188
- {
1189
- $lookup: {
1190
- from: "usermetas",
1191
- localField: "_id",
1192
- foreignField: "user",
1193
- as: "meta"
1194
- }
1195
- },
1196
- { $unwind: "$meta" },
1197
- { $match: { faction: t.faction } },
1198
- {
1199
- $setWindowFields: {
1200
- sortBy: { "meta.xp.amount": -1 },
1201
- output: { rank: { $rank: {} } }
1202
- }
1203
- },
1204
- { $match: { _id: t._id } },
1205
- {
1206
- $project: {
1207
- _id: 0,
1208
- rank: 1
1209
- }
1210
- }
1211
- ]))[0];
1212
- }
1213
1185
  getFactionRanking(e) {
1214
1186
  return $.aggregate([
1215
1187
  { $match: { faction: e } },
@@ -1278,7 +1250,7 @@ class yn extends b {
1278
1250
  ]);
1279
1251
  }
1280
1252
  getQuestRanking() {
1281
- return B.aggregate([
1253
+ return x.aggregate([
1282
1254
  {
1283
1255
  $match: {
1284
1256
  status: D.COMPLETED
@@ -1352,18 +1324,18 @@ class yn extends b {
1352
1324
  await this.update({ discordId: e }, { $set: { faction: t } });
1353
1325
  }
1354
1326
  }
1355
- const fn = (n) => $.find(n), mn = (n) => $.create({
1327
+ const hn = (n) => $.find(n), wn = (n) => $.create({
1356
1328
  discordId: n
1357
1329
  });
1358
- async function hn(n) {
1330
+ async function gn(n) {
1359
1331
  const e = await $.findOne({ discordId: n }).lean();
1360
- return e || y(await mn(n));
1332
+ return e || y(await wn(n));
1361
1333
  }
1362
- const wn = (n, e) => $.findOneAndUpdate(n, e, {
1334
+ const Sn = (n, e) => $.findOneAndUpdate(n, e, {
1363
1335
  upsert: !0,
1364
1336
  returnDocument: "after"
1365
1337
  });
1366
- class gn extends yn {
1338
+ class bn extends mn {
1367
1339
  constructor() {
1368
1340
  super(3600);
1369
1341
  }
@@ -1374,23 +1346,16 @@ class gn extends yn {
1374
1346
  return e;
1375
1347
  }
1376
1348
  fetchFromDb(e) {
1377
- return hn(e);
1349
+ return gn(e);
1378
1350
  }
1379
1351
  fetchManyFromDb(e) {
1380
- return fn(e);
1352
+ return hn(e);
1381
1353
  }
1382
1354
  updateInDb(e, t) {
1383
- return wn(e, t);
1355
+ return Sn(e, t);
1384
1356
  }
1385
1357
  }
1386
- const Sn = new gn(), zs = [
1387
- "work",
1388
- "rps",
1389
- "blackjack",
1390
- "guess",
1391
- "qod",
1392
- "dice"
1393
- ], bn = new u(
1358
+ const $n = new bn(), ai = ["work", ...bt], En = new u(
1394
1359
  {
1395
1360
  user: {
1396
1361
  type: u.Types.ObjectId,
@@ -1402,53 +1367,53 @@ const Sn = new gn(), zs = [
1402
1367
  type: { type: String, required: !0 }
1403
1368
  },
1404
1369
  { minimize: !1 }
1405
- ), z = l?.Reminder || p("Reminder", bn), $n = async (n) => {
1406
- await z.deleteMany(n);
1407
- }, En = async (n, e) => {
1408
- await z.deleteOne({ user: n, type: e });
1370
+ ), K = l?.Reminder || p("Reminder", En), Un = async (n) => {
1371
+ await K.deleteMany(n);
1372
+ }, In = async (n, e) => {
1373
+ await K.deleteOne({ user: n, type: e });
1409
1374
  };
1410
- class Un extends b {
1375
+ class Dn extends b {
1411
1376
  getAllPassedReminder() {
1412
1377
  return this.getMany({ date: { $lte: /* @__PURE__ */ new Date() } });
1413
1378
  }
1414
- async addReminder(e, t, a) {
1415
- await this.update({ user: e, type: t }, { $set: { date: a } }, { upsert: !0 });
1379
+ async addReminder(e, t, r) {
1380
+ await this.update({ user: e, type: t }, { $set: { date: r } }, { upsert: !0 });
1416
1381
  }
1417
- async updateReminderDate(e, t, a) {
1382
+ async updateReminderDate(e, t, r) {
1418
1383
  await this.update({ user: e, type: t }, [
1419
1384
  {
1420
1385
  $set: {
1421
1386
  date: {
1422
- $add: ["$date", a]
1387
+ $add: ["$date", r]
1423
1388
  }
1424
1389
  }
1425
1390
  }
1426
1391
  ]);
1427
1392
  }
1428
1393
  async removeReminder(e, t) {
1429
- await En(e, t), this.invalidate({ user: e, type: t });
1394
+ await In(e, t), this.invalidate({ user: e, type: t });
1430
1395
  }
1431
1396
  async deleteSelectedReminders(e) {
1432
1397
  const t = await this.getMany({ _id: { $in: e } });
1433
- await $n({ _id: { $in: e } }), t.forEach((a) => {
1434
- this.invalidate({ user: a.user, type: a.type });
1398
+ await Un({ _id: { $in: e } }), t.forEach((r) => {
1399
+ this.invalidate({ user: r.user, type: r.type });
1435
1400
  });
1436
1401
  }
1437
1402
  }
1438
- function In(n, e = {}) {
1439
- return z.find(n, e).lean();
1403
+ function On(n, e = {}) {
1404
+ return K.find(n, e).lean();
1440
1405
  }
1441
1406
  async function Tn(n) {
1442
- const e = await z.findOne(n).lean();
1407
+ const e = await K.findOne(n).lean();
1443
1408
  return e || null;
1444
1409
  }
1445
- async function Dn(n, e, t) {
1446
- return z.findOneAndUpdate(n, e, {
1410
+ async function Rn(n, e, t) {
1411
+ return K.findOneAndUpdate(n, e, {
1447
1412
  ...t,
1448
1413
  returnDocument: "after"
1449
1414
  }).lean();
1450
1415
  }
1451
- class On extends Un {
1416
+ class Cn extends Dn {
1452
1417
  constructor() {
1453
1418
  super(300);
1454
1419
  }
@@ -1465,17 +1430,17 @@ class On extends Un {
1465
1430
  return Tn(e);
1466
1431
  }
1467
1432
  fetchManyFromDb(e, t) {
1468
- return In(e, t);
1433
+ return On(e, t);
1469
1434
  }
1470
- updateInDb(e, t, a = { upsert: !1 }) {
1471
- return Dn(e, t, a);
1435
+ updateInDb(e, t, r = { upsert: !1 }) {
1436
+ return Rn(e, t, r);
1472
1437
  }
1473
1438
  }
1474
- const H = new On();
1475
- class Cn extends b {
1439
+ const L = new Cn();
1440
+ class vn extends b {
1476
1441
  async isOrnamentIds(e, t = () => !0) {
1477
- const r = (await this.getAll()).filter(t).map(({ ornamentId: s }) => s);
1478
- return e.every((s) => r.includes(s));
1442
+ const a = (await this.getAll()).filter(t).map(({ ornamentId: s }) => s);
1443
+ return e.every((s) => a.includes(s));
1479
1444
  }
1480
1445
  isOrnament(e) {
1481
1446
  return !!e && "ornamentId" in e;
@@ -1511,40 +1476,40 @@ class Cn extends b {
1511
1476
  return (await this.getAll()).filter(this.isShopTitle);
1512
1477
  }
1513
1478
  formatBackgroundId(e) {
1514
- return e.ornamentId === "background_default" ? "par défaut" : `"${ot(e.ornamentId.split("_").join(" "))}"`;
1479
+ return e.ornamentId === "background_default" ? "par défaut" : `"${lt(e.ornamentId.split("_").join(" "))}"`;
1515
1480
  }
1516
1481
  pickOrnament(e) {
1517
1482
  const t = Math.random();
1518
- let a = 0;
1483
+ let r = 0;
1519
1484
  if (Object.keys(e).map((s) => parseFloat(s)).reduce((s, i) => s + i, 0) !== 1)
1520
1485
  throw RangeError(
1521
1486
  "pickOrnament - Sum of all odds (keys) must be equal to 1"
1522
1487
  );
1523
1488
  for (const [s, i] of Object.entries(e)) {
1524
1489
  const o = parseFloat(s);
1525
- if (t >= a + o) {
1526
- a += o;
1490
+ if (t >= r + o) {
1491
+ r += o;
1527
1492
  continue;
1528
1493
  }
1529
1494
  if (i.length !== 0)
1530
- return i[Y(0, i.length)];
1495
+ return i[X(0, i.length)];
1531
1496
  }
1532
1497
  throw Error("pickOrnament - All ods array were empty");
1533
1498
  }
1534
1499
  pickEachRarityOrnament(e, t) {
1535
- if (t.length !== Oe.length)
1500
+ if (t.length !== Ce.length)
1536
1501
  throw new RangeError(
1537
1502
  "pickEachRarityOrnament - must give same number of odds than ranks"
1538
1503
  );
1539
- return N(
1540
- t.map((a, r) => {
1541
- const s = Oe[r], i = e[s];
1542
- return Math.random() > a || !i || !i.length ? null : dt(i);
1504
+ return F(
1505
+ t.map((r, a) => {
1506
+ const s = Ce[a], i = e[s];
1507
+ return Math.random() > r || !i || !i.length ? null : pt(i);
1543
1508
  })
1544
1509
  );
1545
1510
  }
1546
1511
  }
1547
- const Rn = new u(
1512
+ const An = new u(
1548
1513
  {
1549
1514
  ornamentId: { unique: !0, index: 1, required: !0, type: String },
1550
1515
  type: { required: !0, type: String },
@@ -1558,23 +1523,23 @@ const Rn = new u(
1558
1523
  strength: Number
1559
1524
  },
1560
1525
  { minimize: !1 }
1561
- ), Ee = l?.Ornaments || p("Ornaments", Rn), Mn = async (n, e = {}) => Ee.find(n, e).lean();
1562
- async function vn(n) {
1563
- const e = await Ee.findOne({ ornamentId: n }).lean();
1526
+ ), Ie = l?.Ornaments || p("Ornaments", An), Mn = async (n, e = {}) => Ie.find(n, e).lean();
1527
+ async function Bn(n) {
1528
+ const e = await Ie.findOne({ ornamentId: n }).lean();
1564
1529
  return e || null;
1565
1530
  }
1566
- const An = (n, e) => Ee.findOneAndUpdate(n, e, {
1531
+ const xn = (n, e) => Ie.findOneAndUpdate(n, e, {
1567
1532
  returnDocument: "after"
1568
1533
  }).lean();
1569
- class Bn extends Cn {
1534
+ class qn extends vn {
1570
1535
  constructor() {
1571
1536
  super(3600);
1572
1537
  }
1573
1538
  updateInDb(e, t) {
1574
- return An(e, t);
1539
+ return xn(e, t);
1575
1540
  }
1576
1541
  fetchFromDb(e) {
1577
- return vn(e);
1542
+ return Bn(e);
1578
1543
  }
1579
1544
  fetchManyFromDb(e) {
1580
1545
  return Mn(e);
@@ -1586,7 +1551,7 @@ class Bn extends Cn {
1586
1551
  return e;
1587
1552
  }
1588
1553
  }
1589
- const g = new Bn(), _n = new u(
1554
+ const g = new qn(), kn = new u(
1590
1555
  {
1591
1556
  panoplyId: { unique: !0, index: 1, required: !0, type: String },
1592
1557
  name: { required: !0, type: String },
@@ -1600,43 +1565,43 @@ const g = new Bn(), _n = new u(
1600
1565
  halfBonus: u.Types.Mixed
1601
1566
  },
1602
1567
  { minimize: !1 }
1603
- ), P = l?.Panoplies || p("Panoplies", _n), xn = (n) => P.find(n).lean(), qn = async (n) => P.find(n).populate("equipments");
1604
- async function kn(n) {
1568
+ ), P = l?.Panoplies || p("Panoplies", kn), _n = (n) => P.find(n).lean(), Nn = async (n) => P.find(n).populate("equipments");
1569
+ async function Fn(n) {
1605
1570
  const e = await P.findOne({ panoplyId: n }).lean();
1606
1571
  return e || null;
1607
1572
  }
1608
- const Nn = async (n) => P.findOne(n).populate("equipments");
1609
- class Fn extends b {
1573
+ const jn = async (n) => P.findOne(n).populate("equipments");
1574
+ class zn extends b {
1610
1575
  getAllPopulated() {
1611
- return qn({});
1576
+ return Nn({});
1612
1577
  }
1613
1578
  getPopulated(e) {
1614
- return Nn({ panoplyId: e });
1579
+ return jn({ panoplyId: e });
1615
1580
  }
1616
1581
  hasPanoply(e, t) {
1617
- const a = N(Object.values(e)), r = t.equipments.filter(
1618
- (s) => a.find((i) => i.entityId === s.entityId)
1582
+ const r = F(Object.values(e)), a = t.equipments.filter(
1583
+ (s) => r.find((i) => i.entityId === s.entityId)
1619
1584
  ).length;
1620
- if (r === t.equipments.length)
1585
+ if (a === t.equipments.length)
1621
1586
  return t.fullBonus;
1622
- if (r >= t.equipments.length / 2)
1587
+ if (a >= t.equipments.length / 2)
1623
1588
  return t.halfBonus;
1624
1589
  }
1625
1590
  async getPanoplyBonus(e) {
1626
- const t = [], a = await this.getAllPopulated();
1627
- for (const r of a) {
1628
- const s = N(Object.values(e)), i = r.equipments.filter(
1591
+ const t = [], r = await this.getAllPopulated();
1592
+ for (const a of r) {
1593
+ const s = F(Object.values(e)), i = a.equipments.filter(
1629
1594
  (o) => s.find(({ entityId: c }) => c === o.entityId)
1630
1595
  );
1631
- i.length === r.equipments.length ? t.push([r, "full"]) : i.length >= r.equipments.length / 2 ? t.push([r, "half"]) : i.length >= 1 && t.push([r, null]);
1596
+ i.length === a.equipments.length ? t.push([a, "full"]) : i.length >= a.equipments.length / 2 ? t.push([a, "half"]) : i.length >= 1 && t.push([a, null]);
1632
1597
  }
1633
1598
  return t;
1634
1599
  }
1635
1600
  }
1636
- const jn = async (n, e) => P.findOneAndUpdate(n, e, {
1601
+ const Kn = async (n, e) => P.findOneAndUpdate(n, e, {
1637
1602
  returnDocument: "after"
1638
1603
  }).lean();
1639
- class zn extends Fn {
1604
+ class Pn extends zn {
1640
1605
  constructor() {
1641
1606
  super(3600);
1642
1607
  }
@@ -1647,17 +1612,17 @@ class zn extends Fn {
1647
1612
  return e;
1648
1613
  }
1649
1614
  updateInDb(e, t) {
1650
- return jn(e, t);
1615
+ return Kn(e, t);
1651
1616
  }
1652
1617
  fetchFromDb(e) {
1653
- return kn(e);
1618
+ return Fn(e);
1654
1619
  }
1655
1620
  fetchManyFromDb(e = {}) {
1656
- return xn(e);
1621
+ return _n(e);
1657
1622
  }
1658
1623
  }
1659
- const U = new zn();
1660
- class Pn extends b {
1624
+ const U = new Pn();
1625
+ class Hn extends b {
1661
1626
  isEntity(e) {
1662
1627
  return !!e && "entityId" in e;
1663
1628
  }
@@ -1668,7 +1633,7 @@ class Pn extends b {
1668
1633
  return e.category === "equipment";
1669
1634
  }
1670
1635
  async isEntityId(e, t = () => !0) {
1671
- return (await this.getAll()).filter(t).map(({ entityId: r }) => r).includes(e);
1636
+ return (await this.getAll()).filter(t).map(({ entityId: a }) => a).includes(e);
1672
1637
  }
1673
1638
  async getSomeStoreItems(e) {
1674
1639
  const t = (await this.getAll()).filter(this.isStoreItem);
@@ -1680,7 +1645,7 @@ class Pn extends b {
1680
1645
  }
1681
1646
  async getSomeObjectItems(e) {
1682
1647
  const t = (await this.getAll()).filter(this.isObjectItem);
1683
- return Te(t.filter((a) => !!a.shop?.price)).slice(
1648
+ return Te(t.filter((r) => !!r.shop?.price)).slice(
1684
1649
  0,
1685
1650
  e
1686
1651
  );
@@ -1695,14 +1660,14 @@ class Pn extends b {
1695
1660
  }
1696
1661
  async recordToEntityTuple(e) {
1697
1662
  const t = await this.getAll();
1698
- return R(e).reduce((a, [r, s]) => {
1699
- const i = t.find(({ entityId: o }) => o === r);
1700
- return i && a.push([i, s]), a;
1663
+ return C(e).reduce((r, [a, s]) => {
1664
+ const i = t.find(({ entityId: o }) => o === a);
1665
+ return i && r.push([i, s]), r;
1701
1666
  }, []);
1702
1667
  }
1703
1668
  async getAllEntitiesLimit() {
1704
1669
  const e = await this.getAll();
1705
- return ve(
1670
+ return Be(
1706
1671
  e.map((t) => [t.entityId, t.shop?.limit ?? 0])
1707
1672
  );
1708
1673
  }
@@ -1710,12 +1675,12 @@ class Pn extends b {
1710
1675
  return (await this.getAll()).filter(e);
1711
1676
  }
1712
1677
  async fromDBToEquipableEquipment(e) {
1713
- const a = (await this.getAll()).filter(this.isEquipment).find(
1714
- ({ entityId: r }) => r === e.entityId
1678
+ const r = (await this.getAll()).filter(this.isEquipment).find(
1679
+ ({ entityId: a }) => a === e.entityId
1715
1680
  );
1716
- if (!a)
1681
+ if (!r)
1717
1682
  throw new Error(`cannot find any equipment: ${e.entityId}`);
1718
- return this.seedEquipment(a, e.seed);
1683
+ return this.seedEquipment(r, e.seed);
1719
1684
  }
1720
1685
  async getUserEquipmentsCharacteristics(e) {
1721
1686
  let t = {
@@ -1726,18 +1691,18 @@ class Pn extends b {
1726
1691
  intelligence: 0,
1727
1692
  wisdom: 0
1728
1693
  };
1729
- const a = await U.getAllPopulated();
1730
- for (const r of Be) {
1731
- const s = e[r];
1732
- s && (t = F(
1694
+ const r = await U.getAllPopulated();
1695
+ for (const a of qe) {
1696
+ const s = e[a];
1697
+ s && (t = j(
1733
1698
  t,
1734
1699
  (await this.fromDBToEquipableEquipment(s)).characteristics,
1735
1700
  (i, o) => i + o
1736
1701
  ));
1737
1702
  }
1738
- for (const r of a) {
1739
- const s = U.hasPanoply(e, r);
1740
- s && !("target" in s) && (t = F(
1703
+ for (const a of r) {
1704
+ const s = U.hasPanoply(e, a);
1705
+ s && !("target" in s) && (t = j(
1741
1706
  t,
1742
1707
  s,
1743
1708
  (i, o) => i + o
@@ -1746,16 +1711,16 @@ class Pn extends b {
1746
1711
  return t;
1747
1712
  }
1748
1713
  getSomeItems(e, t) {
1749
- const a = [];
1750
- for (; a.length < e; ) {
1751
- const r = q(t, a, (s) => s.entityId);
1752
- a.push(
1714
+ const r = [];
1715
+ for (; r.length < e; ) {
1716
+ const a = _(t, r, (s) => s.entityId);
1717
+ r.push(
1753
1718
  g.pickOrnament(
1754
- lt(r, (s) => s.shop?.odd ?? 0)
1719
+ yt(a, (s) => s.shop?.odd ?? 0)
1755
1720
  )
1756
1721
  );
1757
1722
  }
1758
- return De(a, (r) => r.shop?.price ?? 0);
1723
+ return Re(r, (a) => a.shop?.price ?? 0);
1759
1724
  }
1760
1725
  filterCraftEntities(e) {
1761
1726
  return e.filter((t) => t.usage?.craft);
@@ -1811,45 +1776,42 @@ class Pn extends b {
1811
1776
  isSameEquipment(e, t) {
1812
1777
  return e.entityId === t.entityId && e.seed === t.seed;
1813
1778
  }
1814
- getEquipmentSlotType(e) {
1815
- return gt[e];
1816
- }
1817
1779
  seedEquipment(e, t) {
1818
- const a = pt(t), r = De(
1819
- R(e.characteristics),
1780
+ const r = ft(t), a = Re(
1781
+ C(e.characteristics),
1820
1782
  ([s]) => s
1821
1783
  );
1822
1784
  return {
1823
1785
  ...e,
1824
1786
  seed: t,
1825
1787
  characteristics: Object.fromEntries(
1826
- r.map(([s, i]) => [
1788
+ a.map(([s, i]) => [
1827
1789
  s,
1828
- Array.isArray(i) ? Y(i[0], i[1] + 1, a) : i
1790
+ Array.isArray(i) ? X(i[0], i[1] + 1, r) : i
1829
1791
  ])
1830
1792
  )
1831
1793
  };
1832
1794
  }
1833
1795
  isEquipped(e, t) {
1834
1796
  return !!Object.values(e).find(
1835
- (a) => a && this.isSameEquipment(a, t)
1797
+ (r) => r && this.isSameEquipment(r, t)
1836
1798
  );
1837
1799
  }
1838
1800
  calcILvl(e) {
1839
- return Object.values(e.characteristics).reduce((a, r) => a + r, 0) + e.level;
1801
+ return Object.values(e.characteristics).reduce((r, a) => r + a, 0) + e.level;
1840
1802
  }
1841
1803
  }
1842
- const Kn = new u(
1804
+ const Ln = new u(
1843
1805
  {
1844
1806
  type: {
1845
1807
  type: String,
1846
- enum: St,
1808
+ enum: $t,
1847
1809
  required: !0
1848
1810
  },
1849
1811
  params: { type: u.Types.Mixed }
1850
1812
  },
1851
1813
  { _id: !1 }
1852
- ), Hn = new u(
1814
+ ), Qn = new u(
1853
1815
  {
1854
1816
  entityId: { unique: !0, required: !0, type: String },
1855
1817
  type: { required: !0, type: String },
@@ -1871,7 +1833,7 @@ const Kn = new u(
1871
1833
  image: { required: !0, type: String },
1872
1834
  emojis: { required: !0, type: String },
1873
1835
  category: { required: !0, type: String },
1874
- effects: { type: [Kn], default: [] },
1836
+ effects: { type: [Ln], default: [] },
1875
1837
  rankId: String,
1876
1838
  usage: {
1877
1839
  _id: !1,
@@ -1932,31 +1894,31 @@ const Kn = new u(
1932
1894
  panoply: String
1933
1895
  },
1934
1896
  { minimize: !1 }
1935
- ), oe = l?.Entities || p("Entities", Hn), Ln = async (n) => await oe.create({
1897
+ ), de = l?.Entities || p("Entities", Qn), Wn = async (n) => await de.create({
1936
1898
  ...n
1937
- }), Qn = async (n, e = {}) => oe.find(n, e).lean();
1938
- async function Wn(n) {
1939
- const e = await oe.findOne({ entityId: n }).lean();
1899
+ }), Gn = async (n, e = {}) => de.find(n, e).lean();
1900
+ async function Yn(n) {
1901
+ const e = await de.findOne({ entityId: n }).lean();
1940
1902
  return e || null;
1941
1903
  }
1942
- const Gn = (n, e) => oe.findOneAndUpdate(n, e, {
1904
+ const Xn = (n, e) => de.findOneAndUpdate(n, e, {
1943
1905
  returnDocument: "after"
1944
1906
  }).lean();
1945
- class Yn extends Pn {
1907
+ class Vn extends Hn {
1946
1908
  constructor() {
1947
1909
  super(3600);
1948
1910
  }
1949
1911
  createInDb(e) {
1950
- return Ln(e);
1912
+ return Wn(e);
1951
1913
  }
1952
1914
  updateInDb(e, t) {
1953
- return Gn(e, t);
1915
+ return Xn(e, t);
1954
1916
  }
1955
1917
  fetchFromDb(e) {
1956
- return Wn(e);
1918
+ return Yn(e);
1957
1919
  }
1958
1920
  fetchManyFromDb(e) {
1959
- return Qn(e);
1921
+ return Gn(e);
1960
1922
  }
1961
1923
  normalizeKey(e) {
1962
1924
  return e;
@@ -1965,14 +1927,14 @@ class Yn extends Pn {
1965
1927
  return e.entityId;
1966
1928
  }
1967
1929
  }
1968
- const d = new Yn(), Xn = (n, e, t) => _.create({
1930
+ const d = new Vn(), Jn = (n, e, t) => q.create({
1969
1931
  user: n,
1970
1932
  crew: e,
1971
1933
  permission: t
1972
- }), Vn = async (n) => {
1973
- await _.deleteOne({ user: n });
1934
+ }), Zn = async (n) => {
1935
+ await q.deleteOne({ user: n });
1974
1936
  };
1975
- class Jn extends b {
1937
+ class er extends b {
1976
1938
  async updatePercent(e, t) {
1977
1939
  await this.update(e, {
1978
1940
  $set: {
@@ -1987,22 +1949,22 @@ class Jn extends b {
1987
1949
  }
1988
1950
  });
1989
1951
  }
1990
- async addUserToCrew(e, t, a) {
1991
- await Xn(e, t, a), this.invalidate(t);
1952
+ async addUserToCrew(e, t, r) {
1953
+ await Jn(e, t, r), this.invalidate(t);
1992
1954
  }
1993
1955
  async removeUserFromCrew(e, t) {
1994
- await Vn(e), this.invalidate(e), this.invalidate(t);
1956
+ await Zn(e), this.invalidate(e), this.invalidate(t);
1995
1957
  }
1996
1958
  async getAllUserIdsFromCrew(e) {
1997
- const t = e.toString(), a = this.cache.get(t);
1998
- if (a)
1999
- return a.map(({ user: s }) => s);
2000
- const r = await this.getMany({ crew: e });
2001
- return this.cache.set(t, r), r.map(({ user: s }) => s);
1959
+ const t = e.toString(), r = this.cache.get(t);
1960
+ if (r)
1961
+ return r.map(({ user: s }) => s);
1962
+ const a = await this.getMany({ crew: e });
1963
+ return this.cache.set(t, a), a.map(({ user: s }) => s);
2002
1964
  }
2003
1965
  }
2004
- const Zn = (n) => _.find(n).lean(), ea = (n) => _.findOne({ user: n }).lean(), ta = (n, e) => _.findOneAndUpdate({ user: n }, e, { returnDocument: "after" }).lean();
2005
- class na extends Jn {
1966
+ const tr = (n) => q.find(n).lean(), nr = (n) => q.findOne({ user: n }).lean(), rr = (n, e) => q.findOneAndUpdate({ user: n }, e, { returnDocument: "after" }).lean();
1967
+ class ar extends er {
2006
1968
  constructor() {
2007
1969
  super(300);
2008
1970
  }
@@ -2013,17 +1975,17 @@ class na extends Jn {
2013
1975
  return e;
2014
1976
  }
2015
1977
  fetchFromDb(e) {
2016
- return ea(e);
1978
+ return nr(e);
2017
1979
  }
2018
1980
  fetchManyFromDb(e) {
2019
- return Zn(e);
1981
+ return tr(e);
2020
1982
  }
2021
1983
  updateInDb(e, t) {
2022
- return ta(e, t);
1984
+ return rr(e, t);
2023
1985
  }
2024
1986
  }
2025
- const aa = new na();
2026
- class ra extends f {
1987
+ const sr = new ar();
1988
+ class ir extends f {
2027
1989
  hasAlreadyFoundEntity(e, t) {
2028
1990
  return e.encyclopedia.includes(t);
2029
1991
  }
@@ -2033,23 +1995,23 @@ class ra extends f {
2033
1995
  });
2034
1996
  }
2035
1997
  }
2036
- const sa = async (n) => await Z.create({
1998
+ const ur = async (n) => await ee.create({
2037
1999
  user: n
2038
2000
  });
2039
- async function ia(n) {
2040
- const e = await Z.findOne({ user: n }).lean();
2041
- return e || y(await sa(n));
2001
+ async function cr(n) {
2002
+ const e = await ee.findOne({ user: n }).lean();
2003
+ return e || y(await ur(n));
2042
2004
  }
2043
- const ua = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
2005
+ const or = (n, e) => ee.findOneAndUpdate({ user: n }, e, {
2044
2006
  upsert: !0,
2045
2007
  returnDocument: "after"
2046
2008
  }).lean();
2047
- class ca extends ra {
2009
+ class dr extends ir {
2048
2010
  constructor() {
2049
2011
  super(300);
2050
2012
  }
2051
2013
  fetchFromDb(e) {
2052
- return ia(e);
2014
+ return cr(e);
2053
2015
  }
2054
2016
  getKey({ user: e }) {
2055
2017
  return e;
@@ -2058,20 +2020,20 @@ class ca extends ra {
2058
2020
  return e.toString();
2059
2021
  }
2060
2022
  updateInDb(e, t) {
2061
- return ua(e, t);
2023
+ return or(e, t);
2062
2024
  }
2063
2025
  }
2064
- const pe = new ca();
2065
- class oa extends f {
2026
+ const fe = new dr();
2027
+ class lr extends f {
2066
2028
  getPanoplyEffectiveBonus(e, t) {
2067
- const a = N(
2029
+ const r = F(
2068
2030
  Object.values(e.equippedItems)
2069
- ), r = t.equipments.filter(
2070
- (s) => a.find((i) => i.entityId === s.entityId)
2031
+ ), a = t.equipments.filter(
2032
+ (s) => r.find((i) => i.entityId === s.entityId)
2071
2033
  ).length;
2072
- if (r === t.equipments.length)
2034
+ if (a === t.equipments.length)
2073
2035
  return t.fullBonus;
2074
- if (r >= t.equipments.length / 2)
2036
+ if (a >= t.equipments.length / 2)
2075
2037
  return t.halfBonus;
2076
2038
  }
2077
2039
  async getUserEquipmentsCharacteristics(e) {
@@ -2083,21 +2045,21 @@ class oa extends f {
2083
2045
  intelligence: 0,
2084
2046
  wisdom: 0
2085
2047
  };
2086
- const a = await U.getAllPopulated();
2087
- for (const r of Be) {
2088
- const s = e.equippedItems?.[r];
2048
+ const r = await U.getAllPopulated();
2049
+ for (const a of qe) {
2050
+ const s = e.equippedItems?.[a];
2089
2051
  if (!s)
2090
2052
  continue;
2091
2053
  const i = await d.fromDBToEquipableEquipment(s);
2092
- t = F(
2054
+ t = j(
2093
2055
  t,
2094
2056
  i.characteristics,
2095
2057
  (o, c) => o + c
2096
2058
  );
2097
2059
  }
2098
- for (const r of a) {
2099
- const s = this.getPanoplyEffectiveBonus(e, r);
2100
- s && !("target" in s) && (t = F(
2060
+ for (const a of r) {
2061
+ const s = this.getPanoplyEffectiveBonus(e, a);
2062
+ s && !("target" in s) && (t = j(
2101
2063
  t,
2102
2064
  s,
2103
2065
  (i, o) => i + o
@@ -2105,36 +2067,22 @@ class oa extends f {
2105
2067
  }
2106
2068
  return t;
2107
2069
  }
2108
- maxCraftQuantity(e, t) {
2109
- let a = 1 / 0;
2110
- for (const r of t)
2111
- a = Math.min(
2112
- a,
2113
- Math.floor((e.itemList[r.entityId] ?? 0) / r.size)
2114
- );
2115
- return a;
2116
- }
2117
- hasEnoughItemsForRecipe(e, t, a) {
2118
- for (const r of t)
2119
- if ((e.itemList[r.entityId] ?? 0) < r.size * a)
2120
- return !1;
2121
- return !0;
2122
- }
2123
- hasInventoryRequirements(e, t) {
2124
- return R(t).reduce(
2125
- (a, [r, s]) => a && (e.itemList[r] ?? 0) >= (s ?? 0),
2070
+ async hasInventoryRequirements(e, t) {
2071
+ const r = await this.get(e);
2072
+ return C(t).reduce(
2073
+ (a, [s, i]) => a && (r.itemList[s] ?? 0) >= (i ?? 0),
2126
2074
  !0
2127
2075
  );
2128
2076
  }
2129
- hasEnoughEntity(e, t, a) {
2130
- return (e.itemList[a] ?? 0) >= t;
2077
+ async hasEnoughEntity(e, t, r) {
2078
+ return ((await this.get(e)).itemList[r] ?? 0) >= t;
2131
2079
  }
2132
- getItemList(e) {
2133
- return Object.fromEntries(e.itemList);
2080
+ async getItemList(e) {
2081
+ return (await this.get(e)).itemList;
2134
2082
  }
2135
2083
  async calcBottleMultiplier(e, { bottle: { buffs: t } }) {
2136
- const a = await this.get(e), s = (await U.getPanoplyBonus(
2137
- a.equippedItems
2084
+ const r = await this.get(e), s = (await U.getPanoplyBonus(
2085
+ r.equippedItems
2138
2086
  )).find(
2139
2087
  ([i, o]) => i.panoplyId === "herbalist" && o !== null
2140
2088
  );
@@ -2147,58 +2095,52 @@ class oa extends f {
2147
2095
  })) : t;
2148
2096
  }
2149
2097
  async calcMinStreakForWorkLoot(e) {
2150
- const t = (await U.getPanoplyBonus(e.equippedItems)).find(
2151
- ([a, r]) => a.panoplyId === "marine" && r !== null
2098
+ const t = await this.get(e), r = (await U.getPanoplyBonus(t.equippedItems)).find(
2099
+ ([a, s]) => a.panoplyId === "marine" && s !== null
2152
2100
  );
2153
- return t && t[1] === "full" ? 10 : t && t[1] === "half" ? 20 : 1 / 0;
2101
+ return r && r[1] === "full" ? 10 : r && r[1] === "half" ? 20 : 1 / 0;
2154
2102
  }
2155
2103
  async hasRevolutionaryBuff(e) {
2156
2104
  const t = await this.get(e);
2157
2105
  return (await U.getPanoplyBonus(t.equippedItems)).find(
2158
- ([r, s]) => r.panoplyId === "revolutionary" && s !== null
2106
+ ([a, s]) => a.panoplyId === "revolutionary" && s !== null
2159
2107
  )?.[1] ?? null;
2160
2108
  }
2161
- async getRecipeResult(e, t) {
2162
- const a = (await U.getPanoplyBonus(e.equippedItems)).find(
2163
- ([r, s]) => r.panoplyId === "little_blacksmith" && s !== null
2164
- );
2165
- return a?.[1] === "full" && t === "chest_3" ? "chest_blacksmith_3" : a?.[1] === "half" && t === "chest_2" ? "chest_blacksmith_2" : a?.[1] === "half" && t === "chest_1" ? "chest_blacksmith_1" : t;
2166
- }
2167
2109
  /*
2168
2110
  ** UPDATES
2169
2111
  */
2170
- async addItem(e, t, a) {
2112
+ async addItem(e, t, r) {
2171
2113
  await this.update(e, {
2172
- $inc: { [`itemList.${t}`]: a }
2173
- }), await pe.addEntities(e, [t]);
2114
+ $inc: { [`itemList.${t}`]: r }
2115
+ }), await fe.addEntities(e, [t]);
2174
2116
  }
2175
2117
  async addItems(e, t) {
2176
2118
  await this.update(e, {
2177
2119
  $inc: Object.fromEntries(
2178
- Object.entries(t).filter(([, a]) => (a ?? 0) > 0).map(([a, r]) => [`itemList.${a}`, r])
2120
+ Object.entries(t).filter(([, r]) => (r ?? 0) > 0).map(([r, a]) => [`itemList.${r}`, a])
2179
2121
  )
2180
- }), await pe.addEntities(
2122
+ }), await fe.addEntities(
2181
2123
  e,
2182
- R(t).filter(([, a]) => a > 0).map(([a]) => a)
2124
+ C(t).filter(([, r]) => r > 0).map(([r]) => r)
2183
2125
  );
2184
2126
  }
2185
- async removeItem(e, t, a) {
2186
- a !== 0 && await this.update(e, [
2127
+ async removeItem(e, t, r) {
2128
+ r !== 0 && await this.update(e, [
2187
2129
  {
2188
2130
  $set: {
2189
2131
  [`itemList.${t}`]: {
2190
- $max: [{ $add: [`$itemList.${t}`, -a] }, 0]
2132
+ $max: [{ $add: [`$itemList.${t}`, -r] }, 0]
2191
2133
  }
2192
2134
  }
2193
2135
  }
2194
2136
  ]);
2195
2137
  }
2196
- async removeEquipment(e, t, a) {
2138
+ async removeEquipment(e, t, r) {
2197
2139
  await this.update(e, {
2198
2140
  $pull: {
2199
2141
  equipmentList: {
2200
2142
  entityId: t,
2201
- seed: a
2143
+ seed: r
2202
2144
  }
2203
2145
  }
2204
2146
  });
@@ -2209,9 +2151,9 @@ class oa extends f {
2209
2151
  async addEquipments(e, t) {
2210
2152
  await this.update(e, {
2211
2153
  $push: { equipmentList: { $each: t } }
2212
- }), await pe.addEntities(
2154
+ }), await fe.addEntities(
2213
2155
  e,
2214
- t.map((a) => a.entityId)
2156
+ t.map((r) => r.entityId)
2215
2157
  );
2216
2158
  }
2217
2159
  async saveEquipments(e) {
@@ -2224,64 +2166,64 @@ class oa extends f {
2224
2166
  ]);
2225
2167
  }
2226
2168
  async changeEquippedEquipment(e, t) {
2227
- const a = await this.get(e);
2228
- a?.equipmentSave[t] && await this.equip(e, a.equipmentSave[t]);
2169
+ const r = await this.get(e);
2170
+ r?.equipmentSave[t] && await this.equip(e, r.equipmentSave[t]);
2229
2171
  }
2230
2172
  async equip(e, t) {
2231
- const a = await I.getMaxHp(e), r = Object.fromEntries(
2232
- R(t).map(([s, i]) => [
2173
+ const r = await I.getMaxHp(e), a = Object.fromEntries(
2174
+ C(t).map(([s, i]) => [
2233
2175
  `equippedItems.${s}`,
2234
2176
  i
2235
2177
  ])
2236
2178
  );
2237
2179
  await this.update(e, {
2238
- $set: r
2239
- }), await I.updateHp(e, a);
2180
+ $set: a
2181
+ }), await I.updateHp(e, r);
2240
2182
  }
2241
2183
  async unequip(e, t) {
2242
- const a = await I.getMaxHp(e);
2184
+ const r = await I.getMaxHp(e);
2243
2185
  await this.update(e, {
2244
2186
  $set: {
2245
2187
  [`equippedItems.${t}`]: null
2246
2188
  }
2247
- }), await I.updateHp(e, a);
2248
- }
2249
- async craftItem(e, t, a, r, s) {
2250
- for (const { entityId: c, size: w } of t)
2251
- await this.removeItem(e, c, w * r);
2252
- const { entityId: i, size: o } = a;
2253
- await d.isEntityId(i, d.isEquipment) ? await this.addEquipments(e, [{ entityId: i, seed: s }]) : await d.isEntityId(i, d.isItem) && await this.addItem(e, i, o * r);
2254
- }
2255
- async dismantleEntity(e, t, a, r, s) {
2256
- d.isEquipment(t) ? await this.removeEquipment(e, t.entityId, s) : d.isItem(t) && await this.removeItem(e, t.entityId, r);
2257
- for (const { entityId: i, quantity: o } of a)
2258
- await d.isEntityId(i, d.isItem) && await this.addItem(e, i, r * o);
2189
+ }), await I.updateHp(e, r);
2190
+ }
2191
+ async craftItem(e, t, r, a) {
2192
+ for (const { entityId: o, size: c } of t.entities)
2193
+ await this.removeItem(e, o, c * r);
2194
+ const { entityId: s, size: i } = t.result;
2195
+ await d.isEntityId(s, d.isEquipment) ? await this.addEquipments(e, [{ entityId: s, seed: a }]) : await d.isEntityId(s, d.isItem) && await this.addItem(e, s, i * r);
2196
+ }
2197
+ async dismantleEntity(e, t, r, a, s) {
2198
+ d.isEquipment(t) ? await this.removeEquipment(e, t.entityId, s) : d.isItem(t) && await this.removeItem(e, t.entityId, a);
2199
+ for (const { entityId: i, quantity: o } of r)
2200
+ await d.isEntityId(i, d.isItem) && await this.addItem(e, i, a * o);
2259
2201
  await this.removeItem(e, "tools", 1);
2260
2202
  }
2261
- async enchantItem(e, t, a, r) {
2262
- await this.removeItem(e, t, r * 4), await this.removeItem(e, "enchanted_stone", r), await this.addItem(e, a, r);
2203
+ async enchantItem(e, t, r, a, s) {
2204
+ await this.removeItem(e, t, s * 4), await this.removeItem(e, a, s), await this.addItem(e, r, s);
2263
2205
  }
2264
2206
  async unlockRecipe(e, t) {
2265
2207
  await this.update(e, { $addToSet: { recipes: t } });
2266
2208
  }
2267
2209
  }
2268
- const da = (n) => te.create({
2210
+ const pr = (n) => ne.create({
2269
2211
  user: n
2270
2212
  });
2271
- async function la(n) {
2272
- const e = await te.findOne({ user: n }).lean();
2273
- return e || y(await da(n));
2213
+ async function yr(n) {
2214
+ const e = await ne.findOne({ user: n }).lean();
2215
+ return e || y(await pr(n));
2274
2216
  }
2275
- const pa = (n, e) => te.findOneAndUpdate({ user: n }, e, {
2217
+ const fr = (n, e) => ne.findOneAndUpdate({ user: n }, e, {
2276
2218
  upsert: !0,
2277
2219
  returnDocument: "after"
2278
2220
  }).lean();
2279
- class ya extends oa {
2221
+ class mr extends lr {
2280
2222
  constructor() {
2281
2223
  super(300);
2282
2224
  }
2283
2225
  fetchFromDb(e) {
2284
- return la(e);
2226
+ return yr(e);
2285
2227
  }
2286
2228
  normalizeKey(e) {
2287
2229
  return e.toString();
@@ -2290,19 +2232,17 @@ class ya extends oa {
2290
2232
  return e;
2291
2233
  }
2292
2234
  updateInDb(e, t) {
2293
- return pa(e, t);
2235
+ return fr(e, t);
2294
2236
  }
2295
2237
  }
2296
- const S = new ya();
2297
- class fa extends b {
2298
- getTotalCharacteristics({
2299
- characteristics: e,
2300
- scrolls: t
2301
- }) {
2302
- return ve(
2303
- bt.map((a) => [
2238
+ const w = new mr();
2239
+ class hr extends b {
2240
+ async getTotalCharacteristics(e) {
2241
+ const { characteristics: t, scrolls: r } = await this.get(e);
2242
+ return Be(
2243
+ Et.map((a) => [
2304
2244
  a,
2305
- $t(e[a]) + t[a]
2245
+ Ut(t[a]) + r[a]
2306
2246
  ])
2307
2247
  );
2308
2248
  }
@@ -2349,109 +2289,76 @@ class fa extends b {
2349
2289
  });
2350
2290
  }
2351
2291
  async calcXpBoost(e) {
2352
- const t = await this.get(e), { boost: a } = t.xp, r = a !== null && Date.now() < a.getTime() ? 0.2 : 0, s = Math.max(
2292
+ const t = await this.get(e), { boost: r } = t.xp, a = r !== null && Date.now() < r.getTime() ? 0.2 : 0, s = Math.max(
2353
2293
  t.premium ? 0.5 : 0,
2354
2294
  t.booster ? 0.25 : 0
2355
2295
  );
2356
- return r + s + t.buffs.xp.global.reduce(
2357
- (i, { expireAt: o, startAt: c, multiplier: w }) => c && c > /* @__PURE__ */ new Date() || o && L(o) ? i : i + w,
2296
+ return a + s + t.buffs.xp.global.reduce(
2297
+ (i, { expireAt: o, startAt: c, multiplier: S }) => c && c > /* @__PURE__ */ new Date() || o && Q(o) ? i : i + S,
2358
2298
  0
2359
2299
  );
2360
2300
  }
2361
2301
  calcMessageXp(e) {
2362
- const t = e.trim().length, a = 2;
2363
- return t < 10 ? 10 * a : t > 300 ? 300 * a : t * a;
2302
+ const t = e.trim().length, r = 2;
2303
+ return t < 10 ? 10 * r : t > 300 ? 300 * r : t * r;
2364
2304
  }
2365
2305
  async getXpDeathPenalties(e) {
2366
- const t = await this.get(e), a = Et(t.xp.amount);
2367
- return a <= 10 ? 5e3 : a <= 20 ? 1e4 : a <= 30 ? 2e4 : a <= 40 ? 3e4 : a <= 50 ? 5e4 : a <= 60 ? 75e3 : a <= 70 ? 15e4 : a <= 80 ? 25e4 : a <= 90 ? 4e5 : a <= 100 ? 75e4 : 14e6;
2306
+ const t = await this.get(e), r = It(t.xp.amount);
2307
+ return r <= 10 ? 5e3 : r <= 20 ? 1e4 : r <= 30 ? 2e4 : r <= 40 ? 3e4 : r <= 50 ? 5e4 : r <= 60 ? 75e3 : r <= 70 ? 15e4 : r <= 80 ? 25e4 : r <= 90 ? 4e5 : r <= 100 ? 75e4 : 14e6;
2368
2308
  }
2369
- async calcXp(e, t, a) {
2370
- return t *= 1 + await this.calcXpBoost(e), Math.ceil(t * a);
2309
+ async calcXp(e, t, r) {
2310
+ return t *= 1 + await this.calcXpBoost(e), Math.ceil(t * r);
2371
2311
  }
2372
- async calcBerry(e, t, a) {
2312
+ async calcBerry(e, t, r) {
2373
2313
  if (t <= 0) return t;
2374
- const r = a ? 1 : await this.calcBuffMultiplier(e, "berry", "global");
2375
- return Math.ceil(t * (r || 1));
2314
+ const a = r ? 1 : await this.calcBuffMultiplier(e, "berry", "global");
2315
+ return Math.ceil(t * (a || 1));
2376
2316
  }
2377
- async calcBuffMultiplier(e, t, a) {
2378
- return (await this.get(e)).buffs[t][a].reduce(
2379
- (i, { expireAt: o, startAt: c, multiplier: w }) => i + (/* @__PURE__ */ new Date() >= (c ?? /* @__PURE__ */ new Date()) && (!o || !L(o)) ? w : 0),
2317
+ async calcBuffMultiplier(e, t, r) {
2318
+ return (await this.get(e)).buffs[t][r].reduce(
2319
+ (i, { expireAt: o, startAt: c, multiplier: S }) => i + (/* @__PURE__ */ new Date() >= (c ?? /* @__PURE__ */ new Date()) && (!o || !Q(o)) ? S : 0),
2380
2320
  1
2381
2321
  );
2382
2322
  }
2383
2323
  async getMaxHp(e) {
2384
- const t = await this.get(e), a = await S.get(e), { vitality: r } = this.getTotalCharacteristics(t), s = await S.getUserEquipmentsCharacteristics(
2385
- a
2324
+ const t = await w.get(e), { vitality: r } = await this.getTotalCharacteristics(e), a = await w.getUserEquipmentsCharacteristics(
2325
+ t
2386
2326
  );
2387
- return (r + s.vitality) * Ut + It;
2327
+ return (r + a.vitality) * Dt + Ot;
2388
2328
  }
2389
2329
  async getHpRatio(e) {
2390
- const t = await this.get(e), a = await this.getMaxHp(e);
2391
- return Math.min(t.hp / a, 1);
2330
+ const t = await this.get(e), r = await this.getMaxHp(e);
2331
+ return Math.min(t.hp / r, 1);
2392
2332
  }
2393
2333
  async hasCharacteristicRequirement(e, t) {
2394
- const a = await this.get(e), r = await S.get(e), s = await S.getUserEquipmentsCharacteristics(
2334
+ const r = await w.get(e), a = await w.getUserEquipmentsCharacteristics(
2395
2335
  r
2396
- ), i = F(
2397
- this.getTotalCharacteristics(a),
2398
- s,
2399
- (o, c) => o + c
2336
+ ), s = j(
2337
+ await this.getTotalCharacteristics(e),
2338
+ a,
2339
+ (i, o) => i + o
2400
2340
  );
2401
2341
  if ("sum" in t) {
2402
- let o = 0;
2403
- for (const c of t.characteristics)
2404
- o += i[c] ?? 0;
2405
- return o >= t.sum;
2342
+ let i = 0;
2343
+ for (const o of t.characteristics)
2344
+ i += s[o] ?? 0;
2345
+ return i >= t.sum;
2406
2346
  } else {
2407
- for (const o of Object.keys(
2347
+ for (const i of Object.keys(
2408
2348
  t
2409
2349
  ))
2410
- if (i[o] < (t[o] ?? 0))
2350
+ if (s[i] < (t[i] ?? 0))
2411
2351
  return !1;
2412
2352
  return !0;
2413
2353
  }
2414
2354
  }
2415
- async getGlobalRank(e) {
2416
- return (await O.aggregate([
2417
- {
2418
- $setWindowFields: {
2419
- sortBy: { "xp.amount": -1 },
2420
- output: {
2421
- rank: { $rank: {} }
2422
- }
2423
- }
2424
- },
2425
- { $match: { user: e } },
2426
- { $project: { rank: 1 } }
2427
- ]))[0];
2428
- }
2429
- async getBerryRank(e) {
2430
- return (await O.aggregate([
2431
- {
2432
- $setWindowFields: {
2433
- sortBy: { berry: -1 },
2434
- output: {
2435
- rank: { $rank: {} }
2436
- }
2437
- }
2438
- },
2439
- { $match: { user: e } },
2440
- { $project: { rank: 1 } }
2441
- ]))[0];
2442
- }
2443
2355
  async hasMalusBuff(e) {
2444
- const t = await this.get(e), a = [
2445
- ...t.buffs.xp.global,
2446
- ...t.buffs.berry.global,
2447
- ...t.buffs.berry.work,
2448
- ...t.buffs.cooldown.work,
2449
- ...t.buffs.cooldown.casino,
2450
- ...t.buffs.drop.work
2451
- ];
2452
- for (const { multiplier: r, startAt: s, expireAt: i } of a)
2453
- if (r < 0 && (!i || !L(i)) && (s ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
2454
- return !0;
2356
+ const t = await this.get(e);
2357
+ for (const r of Object.values(t.buffs))
2358
+ for (const a of Object.values(r))
2359
+ for (const { multiplier: s, startAt: i, expireAt: o } of a)
2360
+ if (s < 0 && (!o || !Q(o)) && (i ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
2361
+ return !0;
2455
2362
  return !1;
2456
2363
  }
2457
2364
  /*
@@ -2479,7 +2386,7 @@ class fa extends b {
2479
2386
  }
2480
2387
  async updateBoost(e, t) {
2481
2388
  const {
2482
- xp: { boost: a }
2389
+ xp: { boost: r }
2483
2390
  } = await this.update(e, [
2484
2391
  {
2485
2392
  $set: {
@@ -2498,15 +2405,15 @@ class fa extends b {
2498
2405
  }
2499
2406
  }
2500
2407
  ]);
2501
- return a;
2408
+ return r;
2502
2409
  }
2503
2410
  async updateBuff(e, t) {
2504
2411
  if (Array.isArray(t)) {
2505
- for (const r of t)
2506
- await this.updateBuff(e, r);
2412
+ for (const a of t)
2413
+ await this.updateBuff(e, a);
2507
2414
  return;
2508
2415
  }
2509
- const a = Tt(t);
2416
+ const r = Tt(t);
2510
2417
  await this.update(e, [
2511
2418
  {
2512
2419
  $set: {
@@ -2531,10 +2438,10 @@ class fa extends b {
2531
2438
  then: {
2532
2439
  multiplier: t.multiplier,
2533
2440
  origin: t.origin,
2534
- expireAt: a.expireAt ? {
2441
+ expireAt: r.expireAt ? {
2535
2442
  $cond: {
2536
2443
  if: { $lt: ["$$buff.expireAt", /* @__PURE__ */ new Date()] },
2537
- then: a.expireAt,
2444
+ then: r.expireAt,
2538
2445
  else: {
2539
2446
  $add: [
2540
2447
  "$$buff.expireAt",
@@ -2587,7 +2494,7 @@ class fa extends b {
2587
2494
  },
2588
2495
  then: `$buffs.${t.target}`,
2589
2496
  else: {
2590
- $concatArrays: [`$buffs.${t.target}`, [{ ...a }]]
2497
+ $concatArrays: [`$buffs.${t.target}`, [{ ...r }]]
2591
2498
  }
2592
2499
  }
2593
2500
  }
@@ -2600,21 +2507,21 @@ class fa extends b {
2600
2507
  $pull: { [`buffs.${t.target}`]: { origin: t.origin } }
2601
2508
  });
2602
2509
  }
2603
- async updatePanoplyBuff(e, t, a, r) {
2604
- const s = await d.fromDBToEquipableEquipment(t), i = N(Object.values(a)), c = (await U.getAllPopulated()).find(
2605
- (T) => T.panoplyId === s.panoply
2510
+ async updatePanoplyBuff(e, t, r, a) {
2511
+ const s = await d.fromDBToEquipableEquipment(t), i = F(Object.values(r)), c = (await U.getAllPopulated()).find(
2512
+ (O) => O.panoplyId === s.panoply
2606
2513
  );
2607
2514
  if (!c)
2608
2515
  return;
2609
- const w = c.equipments.filter(
2610
- (T) => (i.find((K) => T.entityId === K.entityId) || !r && s.entityId === T.entityId) && (r ? s.entityId !== T.entityId : !0)
2611
- ).length, x = w === c.equipments.length ? c.fullBonus : w >= c.equipments.length / 2 ? c.halfBonus : void 0;
2612
- c.halfBonus && "target" in c.halfBonus && await this.removeBuff(e, c.halfBonus), c.fullBonus && "target" in c.fullBonus && await this.removeBuff(e, c.fullBonus), x && "target" in x && await this.updateBuff(e, x);
2516
+ const S = c.equipments.filter(
2517
+ (O) => (i.find((H) => O.entityId === H.entityId) || !a && s.entityId === O.entityId) && (a ? s.entityId !== O.entityId : !0)
2518
+ ).length, k = S === c.equipments.length ? c.fullBonus : S >= c.equipments.length / 2 ? c.halfBonus : void 0;
2519
+ c.halfBonus && "target" in c.halfBonus && await this.removeBuff(e, c.halfBonus), c.fullBonus && "target" in c.fullBonus && await this.removeBuff(e, c.fullBonus), k && "target" in k && await this.updateBuff(e, k);
2613
2520
  }
2614
2521
  async gainHp(e, t) {
2615
- const a = await this.get(e), s = await this.getMaxHp(e) - a.hp;
2522
+ const r = await this.get(e), s = await this.getMaxHp(e) - r.hp;
2616
2523
  await this.update(e, {
2617
- $set: { hp: a.hp + Math.floor(Math.min(t, s)) }
2524
+ $set: { hp: r.hp + Math.floor(Math.min(t, s)) }
2618
2525
  });
2619
2526
  }
2620
2527
  async loseHp(e, t) {
@@ -2625,14 +2532,14 @@ class fa extends b {
2625
2532
  ]);
2626
2533
  }
2627
2534
  async updateHp(e, t) {
2628
- const a = await this.getMaxHp(e);
2535
+ const r = await this.getMaxHp(e);
2629
2536
  await this.update(e, [
2630
2537
  {
2631
2538
  $set: {
2632
2539
  hp: {
2633
2540
  $round: [
2634
2541
  {
2635
- $multiply: [{ $divide: ["$hp", t] }, a]
2542
+ $multiply: [{ $divide: ["$hp", t] }, r]
2636
2543
  },
2637
2544
  0
2638
2545
  ]
@@ -2642,23 +2549,23 @@ class fa extends b {
2642
2549
  ]);
2643
2550
  }
2644
2551
  async addCharacteristics(e, t) {
2645
- const a = await this.getMaxHp(e), r = Object.fromEntries(
2552
+ const r = await this.getMaxHp(e), a = Object.fromEntries(
2646
2553
  Object.entries(t).filter(([, s]) => s !== 0).map(([s, i]) => [`characteristics.${s}`, i])
2647
2554
  );
2648
2555
  await this.update(e, {
2649
- $inc: r
2650
- }), await this.updateHp(e, a);
2556
+ $inc: a
2557
+ }), await this.updateHp(e, r);
2651
2558
  }
2652
2559
  async addScrollCharacteristic(e, t) {
2653
- const a = await this.getMaxHp(e), r = Object.fromEntries(
2560
+ const r = await this.getMaxHp(e), a = Object.fromEntries(
2654
2561
  Object.entries(t).filter(([, s]) => s !== 0).map(([s, i]) => [`scrolls.${s}`, i])
2655
2562
  );
2656
2563
  await this.update(e, {
2657
- $inc: r
2658
- }), await this.updateHp(e, a);
2564
+ $inc: a
2565
+ }), await this.updateHp(e, r);
2659
2566
  }
2660
2567
  async resetCharacteristics(e, t) {
2661
- const a = await this.getMaxHp(e), r = {
2568
+ const r = await this.getMaxHp(e), a = {
2662
2569
  vitality: 0,
2663
2570
  strength: 0,
2664
2571
  agility: 0,
@@ -2668,12 +2575,12 @@ class fa extends b {
2668
2575
  };
2669
2576
  t ? await this.update(e, {
2670
2577
  $set: {
2671
- characteristics: r,
2578
+ characteristics: a,
2672
2579
  "resetCharacteristics.free": !1
2673
2580
  }
2674
2581
  }) : await this.update(e, {
2675
2582
  $set: {
2676
- characteristics: r,
2583
+ characteristics: a,
2677
2584
  "resetCharacteristics.nextAvailable": new Date(
2678
2585
  Date.now() + 720 * 60 * 60 * 1e3
2679
2586
  )
@@ -2681,7 +2588,7 @@ class fa extends b {
2681
2588
  $inc: {
2682
2589
  berry: -1e8
2683
2590
  }
2684
- }), await this.updateHp(e, a);
2591
+ }), await this.updateHp(e, r);
2685
2592
  }
2686
2593
  async resetMinutesInVoiceToday(e) {
2687
2594
  await this.update(e, { $set: { "xp.voice.minutesInVoiceToday": 0 } });
@@ -2712,34 +2619,34 @@ class fa extends b {
2712
2619
  });
2713
2620
  }
2714
2621
  async updateUserXp(e, t) {
2715
- const a = await aa.get(e), r = a?.percent ?? 0, s = await this.calcXp(
2622
+ const r = await sr.get(e), a = r?.percent ?? 0, s = await this.calcXp(
2716
2623
  e,
2717
2624
  t,
2718
- (1 - r) * await this.getHpRatio(e)
2625
+ (1 - a) * await this.getHpRatio(e)
2719
2626
  );
2720
2627
  let i = 0;
2721
- return await this.addXp(e, s), a && (i = await Ce.calcXp(
2722
- a.crew,
2723
- t * r
2724
- ), await Ce.addXp(a.crew, i)), { userXp: s, crewXp: i };
2628
+ return await this.addXp(e, s), r && (i = await ve.calcXp(
2629
+ r.crew,
2630
+ t * a
2631
+ ), await ve.addXp(r.crew, i)), { userXp: s, crewXp: i };
2725
2632
  }
2726
- async updateUserBerry(e, t, a) {
2727
- const r = await this.calcBerry(e, t, a);
2728
- return await this.addBerry(e, r), r;
2633
+ async updateUserBerry(e, t, r) {
2634
+ const a = await this.calcBerry(e, t, r);
2635
+ return await this.addBerry(e, a), a;
2729
2636
  }
2730
2637
  }
2731
- const ma = (n) => O.find(n).lean(), ha = async (n) => await O.create({
2638
+ const wr = (n) => T.find(n).lean(), gr = async (n) => await T.create({
2732
2639
  user: n
2733
2640
  });
2734
- async function wa(n) {
2735
- const e = await O.findOne({ user: n }).lean();
2736
- return e || y(await ha(n));
2641
+ async function Sr(n) {
2642
+ const e = await T.findOne({ user: n }).lean();
2643
+ return e || y(await gr(n));
2737
2644
  }
2738
- const ga = (n, e) => O.findOneAndUpdate({ user: n }, e, {
2645
+ const br = (n, e) => T.findOneAndUpdate({ user: n }, e, {
2739
2646
  returnDocument: "after",
2740
2647
  upsert: !0
2741
2648
  }).lean();
2742
- class Sa extends fa {
2649
+ class $r extends hr {
2743
2650
  constructor() {
2744
2651
  super(300);
2745
2652
  }
@@ -2750,17 +2657,17 @@ class Sa extends fa {
2750
2657
  return e;
2751
2658
  }
2752
2659
  fetchFromDb(e) {
2753
- return wa(e);
2660
+ return Sr(e);
2754
2661
  }
2755
2662
  fetchManyFromDb(e) {
2756
- return ma(e);
2663
+ return wr(e);
2757
2664
  }
2758
2665
  updateInDb(e, t) {
2759
- return ga(e, t);
2666
+ return br(e, t);
2760
2667
  }
2761
2668
  }
2762
- const I = new Sa();
2763
- class ba extends b {
2669
+ const I = new $r();
2670
+ class Er extends b {
2764
2671
  async updateSendDailyQuest(e, t) {
2765
2672
  await this.update(e, { $set: { sendDailyQuest: t } });
2766
2673
  }
@@ -2770,8 +2677,8 @@ class ba extends b {
2770
2677
  async updateInventorySort(e, t) {
2771
2678
  await this.update(e, { $set: { "sort.inventory": t } });
2772
2679
  }
2773
- async updateReminderSettings(e, t, a) {
2774
- await this.update(e, { $set: { [`reminder.${t}`]: a } });
2680
+ async updateReminderSettings(e, t, r) {
2681
+ await this.update(e, { $set: { [`reminder.${t}`]: r } });
2775
2682
  }
2776
2683
  getUsersWithDailyReportEnable() {
2777
2684
  return this.getMany({
@@ -2779,18 +2686,18 @@ class ba extends b {
2779
2686
  });
2780
2687
  }
2781
2688
  }
2782
- const $a = (n) => j.find(n).lean(), Ea = async (n) => await j.create({
2689
+ const Ur = (n) => z.find(n).lean(), Ir = async (n) => await z.create({
2783
2690
  user: n
2784
2691
  });
2785
- async function Ua(n) {
2786
- const e = await j.findOne({ user: n }).lean();
2787
- return e || y(await Ea(n));
2692
+ async function Dr(n) {
2693
+ const e = await z.findOne({ user: n }).lean();
2694
+ return e || y(await Ir(n));
2788
2695
  }
2789
- const Ia = (n, e) => j.findOneAndUpdate({ user: n }, e, {
2696
+ const Or = (n, e) => z.findOneAndUpdate({ user: n }, e, {
2790
2697
  returnDocument: "after",
2791
2698
  upsert: !0
2792
2699
  }).lean();
2793
- class Ta extends ba {
2700
+ class Tr extends Er {
2794
2701
  constructor() {
2795
2702
  super(3600);
2796
2703
  }
@@ -2801,17 +2708,17 @@ class Ta extends ba {
2801
2708
  return e.user;
2802
2709
  }
2803
2710
  fetchFromDb(e) {
2804
- return Ua(e);
2711
+ return Dr(e);
2805
2712
  }
2806
2713
  fetchManyFromDb(e) {
2807
- return $a(e);
2714
+ return Ur(e);
2808
2715
  }
2809
2716
  updateInDb(e, t) {
2810
- return Ia(e, t);
2717
+ return Or(e, t);
2811
2718
  }
2812
2719
  }
2813
- const Re = new Ta();
2814
- class Da extends f {
2720
+ const Ae = new Tr();
2721
+ class Rr extends f {
2815
2722
  async getCommandCooldown(e, t) {
2816
2723
  return (await this.get(e)).commands[t];
2817
2724
  }
@@ -2836,24 +2743,24 @@ class Da extends f {
2836
2743
  }
2837
2744
  }
2838
2745
  }
2839
- ]), await H.updateReminderDate(
2746
+ ]), await L.updateReminderDate(
2840
2747
  e,
2841
2748
  "raid/special",
2842
2749
  -1 * t * 3600 * 1e3
2843
- ), await H.updateReminderDate(
2750
+ ), await L.updateReminderDate(
2844
2751
  e,
2845
2752
  "raid/classic",
2846
2753
  -1 * t * 3600 * 1e3
2847
2754
  );
2848
2755
  }
2849
- async startRaidCooldown(e, t, a) {
2850
- const { reminder: r } = await Re.get(e);
2756
+ async startRaidCooldown(e, t, r) {
2757
+ const { reminder: a } = await Ae.get(e);
2851
2758
  await this.update(e, {
2852
- $set: { [`raid.${t}`]: new Date(Date.now() + a) }
2853
- }), r.raid[t] && await H.addReminder(
2759
+ $set: { [`raid.${t}`]: new Date(Date.now() + r) }
2760
+ }), a.raid[t] && await L.addReminder(
2854
2761
  e,
2855
2762
  `raid/${t}`,
2856
- new Date(Date.now() + a)
2763
+ new Date(Date.now() + r)
2857
2764
  );
2858
2765
  }
2859
2766
  async lockUserCommand(e) {
@@ -2863,31 +2770,31 @@ class Da extends f {
2863
2770
  }
2864
2771
  }), await I.gainHp(e, 1);
2865
2772
  }
2866
- async useCommand(e, t, a) {
2867
- const { reminder: r } = await Re.get(e);
2773
+ async useCommand(e, t, r) {
2774
+ const { reminder: a } = await Ae.get(e);
2868
2775
  await this.update(e, {
2869
2776
  $set: {
2870
- [`commands.${t}`]: new Date(Date.now() + a)
2777
+ [`commands.${t}`]: new Date(Date.now() + r)
2871
2778
  }
2872
- }), r.commands[t] && await H.addReminder(
2779
+ }), a.commands[t] && await L.addReminder(
2873
2780
  e,
2874
2781
  `commands/${t}`,
2875
- new Date(Date.now() + a)
2782
+ new Date(Date.now() + r)
2876
2783
  );
2877
2784
  }
2878
2785
  }
2879
- const Oa = async (n) => await V.create({
2786
+ const Cr = async (n) => await J.create({
2880
2787
  user: n
2881
2788
  });
2882
- async function Ca(n) {
2883
- const e = await V.findOne({ user: n }).lean();
2884
- return e || y(await Oa(n));
2789
+ async function vr(n) {
2790
+ const e = await J.findOne({ user: n }).lean();
2791
+ return e || y(await Cr(n));
2885
2792
  }
2886
- const Ra = (n, e) => V.findOneAndUpdate({ user: n }, e, {
2793
+ const Ar = (n, e) => J.findOneAndUpdate({ user: n }, e, {
2887
2794
  returnDocument: "after",
2888
2795
  upsert: !0
2889
2796
  }).lean();
2890
- class Ma extends Da {
2797
+ class Mr extends Rr {
2891
2798
  constructor() {
2892
2799
  super(300);
2893
2800
  }
@@ -2898,14 +2805,14 @@ class Ma extends Da {
2898
2805
  return e.user;
2899
2806
  }
2900
2807
  fetchFromDb(e) {
2901
- return Ca(e);
2808
+ return vr(e);
2902
2809
  }
2903
2810
  updateInDb(e, t) {
2904
- return Ra(e, t);
2811
+ return Ar(e, t);
2905
2812
  }
2906
2813
  }
2907
- const va = new Ma();
2908
- class Aa extends f {
2814
+ const Br = new Mr();
2815
+ class xr extends f {
2909
2816
  async unlockTitle(e, t) {
2910
2817
  await g.isOrnamentIds([t], g.isTitle) && await this.update(e, { $addToSet: { unlockedTitles: t } });
2911
2818
  }
@@ -2938,9 +2845,9 @@ class Aa extends f {
2938
2845
  $set: { selectedBackground: t }
2939
2846
  });
2940
2847
  }
2941
- async unlockBadge(e, t, a) {
2848
+ async unlockBadge(e, t, r) {
2942
2849
  t.isProgressive ? await this.update(e, {
2943
- $addToSet: { unlockedBadges: `${t.id}_${a}` }
2850
+ $addToSet: { unlockedBadges: `${t.id}_${r}` }
2944
2851
  }) : await this.update(e, {
2945
2852
  $addToSet: { unlockedBadges: t.id }
2946
2853
  });
@@ -2974,18 +2881,18 @@ class Aa extends f {
2974
2881
  });
2975
2882
  }
2976
2883
  }
2977
- const Ba = async (n) => await ne.create({
2884
+ const qr = async (n) => await re.create({
2978
2885
  user: n
2979
2886
  });
2980
- async function _a(n) {
2981
- const e = await ne.findOne({ user: n }).lean();
2982
- return e || y(await Ba(n));
2887
+ async function kr(n) {
2888
+ const e = await re.findOne({ user: n }).lean();
2889
+ return e || y(await qr(n));
2983
2890
  }
2984
- const xa = async (n, e) => ne.findOneAndUpdate({ user: n }, e, {
2891
+ const _r = async (n, e) => re.findOneAndUpdate({ user: n }, e, {
2985
2892
  upsert: !0,
2986
2893
  returnDocument: "after"
2987
2894
  }).lean();
2988
- class qa extends Aa {
2895
+ class Nr extends xr {
2989
2896
  constructor() {
2990
2897
  super(300);
2991
2898
  }
@@ -2996,14 +2903,14 @@ class qa extends Aa {
2996
2903
  return e;
2997
2904
  }
2998
2905
  fetchFromDb(e) {
2999
- return _a(e);
2906
+ return kr(e);
3000
2907
  }
3001
2908
  updateInDb(e, t) {
3002
- return xa(e, t);
2909
+ return _r(e, t);
3003
2910
  }
3004
2911
  }
3005
- const G = new qa();
3006
- class ka extends b {
2912
+ const Y = new Nr();
2913
+ class Fr extends b {
3007
2914
  async getStatus(e, t) {
3008
2915
  return (await this.get({ user: e, questId: t })).status;
3009
2916
  }
@@ -3011,18 +2918,21 @@ class ka extends b {
3011
2918
  return await this.getStatus(e, t) === "COMPLETED";
3012
2919
  }
3013
2920
  async isStreaking(e, t) {
3014
- const { lastCompletionDate: a } = await this.get({ user: e, questId: t });
3015
- return !!a && ye(k(), a);
2921
+ const { lastCompletionDate: r } = await this.get({ user: e, questId: t });
2922
+ return !!r && me(N(), r);
3016
2923
  }
3017
2924
  async getStreakMultiplier(e, t) {
3018
- const a = await this.get({ user: e, questId: t });
3019
- return await this.isStreaking(e, t) ? 1 + Math.min(2, (a.streak ?? 0) / 10) : 1;
2925
+ const r = await this.get({ user: e, questId: t });
2926
+ return await this.isStreaking(e, t) ? 1 + Math.min(2, (r.streak ?? 0) / 10) : 1;
2927
+ }
2928
+ async getCompletedCount(e) {
2929
+ return (await this.getMany({ user: e, status: D.COMPLETED })).length;
3020
2930
  }
3021
2931
  async completeQuest(e, t = !1) {
3022
- const a = k();
3023
- a.setHours(0, 0, 0, 0);
3024
- const r = /* @__PURE__ */ new Date();
3025
- return r.setHours(0, 0, 0, 0), this.update(
2932
+ const r = N();
2933
+ r.setHours(0, 0, 0, 0);
2934
+ const a = /* @__PURE__ */ new Date();
2935
+ return a.setHours(0, 0, 0, 0), this.update(
3026
2936
  e,
3027
2937
  [
3028
2938
  {
@@ -3032,8 +2942,8 @@ class ka extends b {
3032
2942
  $cond: {
3033
2943
  if: {
3034
2944
  $and: [
3035
- { $gte: ["$lastCompletionDate", a] },
3036
- { $lt: ["$lastCompletionDate", r] }
2945
+ { $gte: ["$lastCompletionDate", r] },
2946
+ { $lt: ["$lastCompletionDate", a] }
3037
2947
  ]
3038
2948
  },
3039
2949
  then: { $add: [{ $ifNull: ["$streak", 0] }, 1] },
@@ -3050,24 +2960,24 @@ class ka extends b {
3050
2960
  );
3051
2961
  }
3052
2962
  }
3053
- function Na(n) {
3054
- return B.find(n).lean();
2963
+ function jr(n) {
2964
+ return x.find(n).lean();
3055
2965
  }
3056
- const Fa = async (n) => await B.create({
2966
+ const zr = async (n) => await x.create({
3057
2967
  ...n
3058
2968
  });
3059
- async function ja(n) {
3060
- const e = await B.findOne(n).lean();
3061
- return e || y(await Fa(n));
2969
+ async function Kr(n) {
2970
+ const e = await x.findOne(n).lean();
2971
+ return e || y(await zr(n));
3062
2972
  }
3063
- function za(n, e, t) {
3064
- return B.findOneAndUpdate(n, e, {
2973
+ function Pr(n, e, t) {
2974
+ return x.findOneAndUpdate(n, e, {
3065
2975
  upsert: !0,
3066
2976
  ...t,
3067
2977
  returnDocument: "after"
3068
2978
  }).lean();
3069
2979
  }
3070
- class Pa extends ka {
2980
+ class Hr extends Fr {
3071
2981
  constructor() {
3072
2982
  super(3600);
3073
2983
  }
@@ -3081,19 +2991,19 @@ class Pa extends ka {
3081
2991
  return { user: e, questId: t };
3082
2992
  }
3083
2993
  fetchFromDb(e) {
3084
- return ja(e);
2994
+ return Kr(e);
3085
2995
  }
3086
2996
  fetchManyFromDb(e) {
3087
- return Na(e);
2997
+ return jr(e);
3088
2998
  }
3089
- updateInDb(e, t, a) {
3090
- return za(e, t, a);
2999
+ updateInDb(e, t, r) {
3000
+ return Pr(e, t, r);
3091
3001
  }
3092
3002
  }
3093
- const Me = new Pa();
3094
- class Ka extends f {
3003
+ const Me = new Hr();
3004
+ class Lr extends f {
3095
3005
  async updateDailyReport(e) {
3096
- const t = await I.get(e), a = await G.get(e), r = await Me.getMany({
3006
+ const t = await I.get(e), r = await Y.get(e), a = await Me.getMany({
3097
3007
  user: e,
3098
3008
  status: D.COMPLETED
3099
3009
  });
@@ -3101,12 +3011,12 @@ class Ka extends f {
3101
3011
  $set: {
3102
3012
  xpYesterday: t.xp.amount,
3103
3013
  berryYesterday: t.berry,
3104
- previousCompletedQuest: r.map(
3014
+ previousCompletedQuest: a.map(
3105
3015
  ({ questId: s }) => s
3106
3016
  ),
3107
- "previousOrnament.unlockedBadges": a.unlockedBadges,
3108
- "previousOrnament.unlockedTitles": a.unlockedTitles,
3109
- "previousOrnament.unlockedBackgrounds": a.unlockedBackgrounds
3017
+ "previousOrnament.unlockedBadges": r.unlockedBadges,
3018
+ "previousOrnament.unlockedTitles": r.unlockedTitles,
3019
+ "previousOrnament.unlockedBackgrounds": r.unlockedBackgrounds
3110
3020
  // TODO
3111
3021
  // previousMessageSent: user.questMeta.messageSent,
3112
3022
  }
@@ -3114,8 +3024,8 @@ class Ka extends f {
3114
3024
  }
3115
3025
  async getDailyReport(e) {
3116
3026
  const t = await this.get(e), {
3117
- previousOrnament: a,
3118
- previousCompletedQuest: r,
3027
+ previousOrnament: r,
3028
+ previousCompletedQuest: a,
3119
3029
  xpYesterday: s,
3120
3030
  berryYesterday: i
3121
3031
  } = t;
@@ -3124,51 +3034,51 @@ class Ka extends f {
3124
3034
  const o = await I.get(e), c = await Me.getMany({
3125
3035
  user: e,
3126
3036
  status: D.COMPLETED
3127
- }), w = await G.get(e), { berry: x, xp: T } = o, { voice: K, amount: nt } = T, { unlockedBadges: at, unlockedBackgrounds: rt, unlockedTitles: st } = w;
3037
+ }), S = await Y.get(e), { berry: k, xp: O } = o, { voice: H, amount: at } = O, { unlockedBadges: st, unlockedBackgrounds: it, unlockedTitles: ut } = S;
3128
3038
  return {
3129
- berry: x - i,
3130
- xp: nt - s,
3039
+ berry: k - i,
3040
+ xp: at - s,
3131
3041
  // TODO
3132
3042
  // message: user.questMeta.messageSent - previousMessageSent,
3133
- voice: ye(K.lastConnection, k()) ? K.minutesInVoiceToday : 0,
3134
- quest: q(
3135
- c.map(({ questId: it }) => it),
3136
- r
3043
+ voice: me(H.lastConnection, N()) ? H.minutesInVoiceToday : 0,
3044
+ quest: _(
3045
+ c.map(({ questId: ct }) => ct),
3046
+ a
3137
3047
  ),
3138
- badge: q(at, a.unlockedBadges),
3139
- title: q(st, a.unlockedTitles),
3140
- background: q(
3141
- rt,
3142
- a.unlockedBackgrounds
3048
+ badge: _(st, r.unlockedBadges),
3049
+ title: _(ut, r.unlockedTitles),
3050
+ background: _(
3051
+ it,
3052
+ r.unlockedBackgrounds
3143
3053
  )
3144
3054
  };
3145
3055
  }
3146
3056
  async getAllDailyReportsToSend() {
3147
- const e = await Sn.getMany({
3057
+ const e = await $n.getMany({
3148
3058
  "settings.sendDailyReport": !0,
3149
3059
  faction: { $ne: "citizen" }
3150
3060
  });
3151
3061
  return await Promise.all(
3152
- e.map(async ({ _id: t, discordId: a }) => ({
3062
+ e.map(async ({ _id: t, discordId: r }) => ({
3153
3063
  ...await this.getDailyReport(t),
3154
3064
  user: t,
3155
- discordId: a
3065
+ discordId: r
3156
3066
  }))
3157
3067
  );
3158
3068
  }
3159
3069
  }
3160
- const Ha = (n) => J.create({
3070
+ const Qr = (n) => Z.create({
3161
3071
  user: n
3162
3072
  });
3163
- async function La(n) {
3164
- const e = await J.findOne({ user: n }).lean();
3165
- return e || y(await Ha(n));
3073
+ async function Wr(n) {
3074
+ const e = await Z.findOne({ user: n }).lean();
3075
+ return e || y(await Qr(n));
3166
3076
  }
3167
- const Qa = (n, e) => J.findOneAndUpdate({ user: n }, e, {
3077
+ const Gr = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
3168
3078
  upsert: !0,
3169
3079
  returnDocument: "after"
3170
3080
  }).lean();
3171
- class Wa extends Ka {
3081
+ class Yr extends Lr {
3172
3082
  constructor() {
3173
3083
  super(60);
3174
3084
  }
@@ -3179,21 +3089,21 @@ class Wa extends Ka {
3179
3089
  return e.user;
3180
3090
  }
3181
3091
  fetchFromDb(e) {
3182
- return La(e);
3092
+ return Wr(e);
3183
3093
  }
3184
3094
  updateInDb(e, t) {
3185
- return Qa(e, t);
3095
+ return Gr(e, t);
3186
3096
  }
3187
3097
  }
3188
- const Ps = new Wa();
3189
- class Ga extends f {
3190
- async setGuessGame(e, t, a, r) {
3098
+ const si = new Yr();
3099
+ class Xr extends f {
3100
+ async setGuessGame(e, t, r, a) {
3191
3101
  await this.update(e, {
3192
3102
  $set: {
3193
3103
  guess: {
3194
3104
  amount: t,
3195
- tries: a,
3196
- numberToGuess: r,
3105
+ tries: r,
3106
+ numberToGuess: a,
3197
3107
  lastGuess: 0
3198
3108
  }
3199
3109
  }
@@ -3217,18 +3127,18 @@ class Ga extends f {
3217
3127
  });
3218
3128
  }
3219
3129
  }
3220
- const Ya = async (n) => await ee.create({
3130
+ const Vr = async (n) => await te.create({
3221
3131
  user: n
3222
3132
  });
3223
- async function Xa(n) {
3224
- const e = await ee.findOne({ user: n }).lean();
3225
- return e || y(await Ya(n));
3133
+ async function Jr(n) {
3134
+ const e = await te.findOne({ user: n }).lean();
3135
+ return e || y(await Vr(n));
3226
3136
  }
3227
- const Va = (n, e) => ee.findOneAndUpdate({ user: n }, e, {
3137
+ const Zr = (n, e) => te.findOneAndUpdate({ user: n }, e, {
3228
3138
  upsert: !0,
3229
3139
  returnDocument: "after"
3230
3140
  }).lean();
3231
- class Ja extends Ga {
3141
+ class ea extends Xr {
3232
3142
  constructor() {
3233
3143
  super(300);
3234
3144
  }
@@ -3239,48 +3149,48 @@ class Ja extends Ga {
3239
3149
  return e;
3240
3150
  }
3241
3151
  fetchFromDb(e) {
3242
- return Xa(e);
3152
+ return Jr(e);
3243
3153
  }
3244
3154
  updateInDb(e, t) {
3245
- return Va(e, t);
3155
+ return Zr(e, t);
3246
3156
  }
3247
3157
  }
3248
- const Ks = new Ja();
3249
- class Za extends f {
3158
+ const ii = new ea();
3159
+ class ta extends f {
3250
3160
  async hasUnlockedRaid(e, t) {
3251
3161
  return (await this.get(e)).unlocked?.[t];
3252
3162
  }
3253
- async alreadyObtainedRaidReward(e, t, a) {
3254
- const r = await this.get(e);
3255
- return t in r.obtainedRewards ? r.obtainedRewards[t].includes(a) : !1;
3163
+ async alreadyObtainedRaidReward(e, t, r) {
3164
+ const a = await this.get(e);
3165
+ return t in a.obtainedRewards ? a.obtainedRewards[t].includes(r) : !1;
3256
3166
  }
3257
3167
  async getObtainedRaidReward(e, t) {
3258
3168
  return (await this.get(e)).obtainedRewards[t] ?? [];
3259
3169
  }
3260
- async fulfillCondition(e, t, a, r) {
3170
+ async fulfillCondition(e, t, r, a) {
3261
3171
  const s = await this.get(e);
3262
- return r === "include" ? a.every(
3172
+ return a === "include" ? r.every(
3263
3173
  (i) => (s.obtainedConditions[t] ?? []).includes(i)
3264
- ) : a.every(
3174
+ ) : r.every(
3265
3175
  (i) => !(s.obtainedConditions[t] ?? []).includes(i)
3266
3176
  );
3267
3177
  }
3268
3178
  async unlockRaid(e, t) {
3269
3179
  await this.update(e, { $set: { [`unlocked.${t}`]: !0 } });
3270
3180
  }
3271
- async startRaid(e, t, a, r, s) {
3181
+ async startRaid(e, t, r, a, s) {
3272
3182
  const i = Date.now();
3273
3183
  return await this.update(e, {
3274
3184
  $set: {
3275
3185
  currentRaid: {
3276
3186
  raidId: t,
3277
- buffItem: a,
3187
+ buffItem: r,
3278
3188
  seed: i,
3279
3189
  progression: [],
3280
3190
  rewards: {}
3281
3191
  }
3282
3192
  }
3283
- }), await va.startRaidCooldown(e, r, s), i;
3193
+ }), await Br.startRaidCooldown(e, a, s), i;
3284
3194
  }
3285
3195
  async resetRaid(e) {
3286
3196
  await this.update(e, {
@@ -3303,39 +3213,39 @@ class Za extends f {
3303
3213
  }
3304
3214
  });
3305
3215
  }
3306
- async claimReward(e, t, a) {
3216
+ async claimReward(e, t, r) {
3307
3217
  await this.update(e, {
3308
3218
  $addToSet: {
3309
- [`obtainedRewards.${t}`]: a
3219
+ [`obtainedRewards.${t}`]: r
3310
3220
  }
3311
3221
  });
3312
3222
  }
3313
3223
  async addRewardsToRaid(e, t) {
3314
3224
  await this.update(e, {
3315
3225
  $inc: Object.fromEntries(
3316
- R(t).filter(([a]) => a !== "title" && a !== "condition").map(([a, r]) => [`currentRaid.rewards.${a}`, r])
3226
+ C(t).filter(([r]) => r !== "title" && r !== "condition").map(([r, a]) => [`currentRaid.rewards.${r}`, a])
3317
3227
  ),
3318
3228
  ...t.title ? { $set: { "currentRaid.rewards.title": t.title } } : {}
3319
3229
  });
3320
3230
  }
3321
- async updateCondition(e, t, a) {
3231
+ async updateCondition(e, t, r) {
3322
3232
  await this.update(e, {
3323
3233
  $addToSet: {
3324
- [`obtainedConditions.${t}`]: a
3234
+ [`obtainedConditions.${t}`]: r
3325
3235
  }
3326
3236
  });
3327
3237
  }
3328
3238
  }
3329
- const er = (n) => ae.create({
3239
+ const na = (n) => ae.create({
3330
3240
  user: n
3331
- }), tr = async (n) => {
3241
+ }), ra = async (n) => {
3332
3242
  const e = await ae.findOne({ user: n }).lean();
3333
- return e || y(await er(n));
3334
- }, nr = (n, e) => ae.findOneAndUpdate({ user: n }, e, {
3243
+ return e || y(await na(n));
3244
+ }, aa = (n, e) => ae.findOneAndUpdate({ user: n }, e, {
3335
3245
  upsert: !0,
3336
3246
  returnDocument: "after"
3337
3247
  });
3338
- class ar extends Za {
3248
+ class sa extends ta {
3339
3249
  constructor() {
3340
3250
  super(3600);
3341
3251
  }
@@ -3346,32 +3256,144 @@ class ar extends Za {
3346
3256
  return e;
3347
3257
  }
3348
3258
  fetchFromDb(e) {
3349
- return tr(e);
3259
+ return ra(e);
3260
+ }
3261
+ updateInDb(e, t) {
3262
+ return aa(e, t);
3263
+ }
3264
+ }
3265
+ const ui = new sa(), ia = new u({
3266
+ user: {
3267
+ type: u.Types.ObjectId,
3268
+ required: !0,
3269
+ unique: !0,
3270
+ ref: "User"
3271
+ },
3272
+ xp: { type: Number, default: 0 },
3273
+ berry: { type: Number, default: 0 },
3274
+ faction: { type: Number, default: 0 }
3275
+ }), v = l?.UserRank || p("UserRank", ia);
3276
+ class ua extends f {
3277
+ async computeAllXpRanks() {
3278
+ const t = (await T.aggregate([
3279
+ {
3280
+ $setWindowFields: {
3281
+ sortBy: { "xp.amount": -1 },
3282
+ output: { xpRank: { $rank: {} } }
3283
+ }
3284
+ },
3285
+ { $project: { user: 1, xpRank: 1 } }
3286
+ ])).map(({ user: r, xpRank: a }) => ({
3287
+ updateOne: {
3288
+ filter: { user: r },
3289
+ update: { $set: { xp: a } },
3290
+ upsert: !0
3291
+ }
3292
+ }));
3293
+ t.length > 0 && await v.bulkWrite(t), this.clearAll();
3294
+ }
3295
+ async computeAllBerryRanks() {
3296
+ const t = (await T.aggregate([
3297
+ {
3298
+ $setWindowFields: {
3299
+ sortBy: { berry: -1 },
3300
+ output: { berryRank: { $rank: {} } }
3301
+ }
3302
+ },
3303
+ { $project: { user: 1, berryRank: 1 } }
3304
+ ])).map(({ user: r, berryRank: a }) => ({
3305
+ updateOne: {
3306
+ filter: { user: r },
3307
+ update: { $set: { berry: a } },
3308
+ upsert: !0
3309
+ }
3310
+ }));
3311
+ t.length > 0 && await v.bulkWrite(t), this.clearAll();
3312
+ }
3313
+ async computeAllFactionRanks() {
3314
+ const t = (await $.aggregate([
3315
+ {
3316
+ $lookup: {
3317
+ from: "usermetas",
3318
+ localField: "_id",
3319
+ foreignField: "user",
3320
+ as: "meta"
3321
+ }
3322
+ },
3323
+ { $unwind: "$meta" },
3324
+ {
3325
+ $setWindowFields: {
3326
+ partitionBy: "$faction",
3327
+ sortBy: { "meta.xp.amount": -1 },
3328
+ output: { factionRank: { $rank: {} } }
3329
+ }
3330
+ },
3331
+ { $project: { factionRank: 1 } }
3332
+ ])).map(({ _id: r, factionRank: a }) => ({
3333
+ updateOne: {
3334
+ filter: { user: r },
3335
+ update: { $set: { faction: a } },
3336
+ upsert: !0
3337
+ }
3338
+ }));
3339
+ t.length > 0 && await v.bulkWrite(t), this.clearAll();
3340
+ }
3341
+ async computeAllRanks() {
3342
+ await Promise.all([
3343
+ this.computeAllXpRanks(),
3344
+ this.computeAllBerryRanks(),
3345
+ this.computeAllFactionRanks()
3346
+ ]);
3347
+ }
3348
+ }
3349
+ const ca = async (n) => await v.create({
3350
+ user: n
3351
+ });
3352
+ async function oa(n) {
3353
+ const e = await v.findOne({ user: n }).lean();
3354
+ return e || y(await ca(n));
3355
+ }
3356
+ const da = (n, e) => v.findOneAndUpdate({ user: n }, e, {
3357
+ returnDocument: "after",
3358
+ upsert: !0
3359
+ }).lean();
3360
+ class la extends ua {
3361
+ constructor() {
3362
+ super(300);
3363
+ }
3364
+ normalizeKey(e) {
3365
+ return e.toString();
3366
+ }
3367
+ getKey(e) {
3368
+ return e.user;
3369
+ }
3370
+ fetchFromDb(e) {
3371
+ return oa(e);
3350
3372
  }
3351
3373
  updateInDb(e, t) {
3352
- return nr(e, t);
3374
+ return da(e, t);
3353
3375
  }
3354
3376
  }
3355
- const Hs = new ar();
3356
- class rr extends f {
3357
- async isBuyLimitReached(e, t, a) {
3358
- const r = await d.getAllEntitiesLimit();
3377
+ const ci = new la();
3378
+ class pa extends f {
3379
+ async isBuyLimitReached(e, t, r) {
3380
+ const a = await d.getAllEntitiesLimit();
3359
3381
  if (await d.isEntityId(t, d.isEquipment))
3360
3382
  return !1;
3361
3383
  const s = await this.get(e), i = s.limit?.[t];
3362
- let o = r[t];
3363
- const c = await S.hasRevolutionaryBuff(e);
3364
- return s.lastShopId !== a ? !1 : (c === "half" && t === "chest_2" && (o += 2), c === "full" && t === "chest_3" && (o += 1), !!(o && i && i >= o));
3384
+ let o = a[t];
3385
+ const c = await w.hasRevolutionaryBuff(e);
3386
+ return s.lastShopId !== r ? !1 : (c === "half" && t === "chest_2" && (o += 2), c === "full" && t === "chest_3" && (o += 1), !!(o && i && i >= o));
3365
3387
  }
3366
- async getShopItemRest(e, t, a, r = Dt) {
3388
+ async getShopItemRest(e, t, r, a = Rt) {
3367
3389
  const s = await d.getAllEntitiesLimit();
3368
3390
  if (await d.isEntityId(t, d.isEquipment))
3369
- return r;
3391
+ return a;
3370
3392
  let i = s[t];
3371
- const o = await this.get(e), c = o.limit?.[t], w = await S.hasRevolutionaryBuff(e);
3372
- return w === "half" && t === "chest_2" && (i += 2), w === "full" && t === "chest_3" && (i += 1), i ? o.lastShopId !== a ? i : c ? i - c : Math.min(i, r) : r;
3393
+ const o = await this.get(e), c = o.limit?.[t], S = await w.hasRevolutionaryBuff(e);
3394
+ return S === "half" && t === "chest_2" && (i += 2), S === "full" && t === "chest_3" && (i += 1), i ? o.lastShopId !== r ? i : c ? i - c : Math.min(i, a) : a;
3373
3395
  }
3374
- async increaseBuyLimit(e, t, a, r) {
3396
+ async increaseBuyLimit(e, t, r, a) {
3375
3397
  await this.update(e, [
3376
3398
  {
3377
3399
  $set: {
@@ -3380,15 +3402,15 @@ class rr extends f {
3380
3402
  if: { $eq: ["$lastShopId", t] },
3381
3403
  then: {
3382
3404
  $setField: {
3383
- field: a,
3405
+ field: r,
3384
3406
  input: { $ifNull: ["$limit", {}] },
3385
3407
  value: {
3386
- $add: [{ $ifNull: [`$limit.${a}`, 0] }, r]
3408
+ $add: [{ $ifNull: [`$limit.${r}`, 0] }, a]
3387
3409
  }
3388
3410
  }
3389
3411
  },
3390
3412
  else: {
3391
- [a]: r
3413
+ [r]: a
3392
3414
  }
3393
3415
  }
3394
3416
  },
@@ -3398,16 +3420,16 @@ class rr extends f {
3398
3420
  ]);
3399
3421
  }
3400
3422
  }
3401
- const sr = async (n) => await re.create({
3423
+ const ya = async (n) => await se.create({
3402
3424
  user: n
3403
- }), ir = async (n) => {
3404
- const e = await re.findOne({ user: n }).lean();
3405
- return e || y(await sr(n));
3406
- }, ur = (n, e) => re.findOneAndUpdate({ user: n }, e, {
3425
+ }), fa = async (n) => {
3426
+ const e = await se.findOne({ user: n }).lean();
3427
+ return e || y(await ya(n));
3428
+ }, ma = (n, e) => se.findOneAndUpdate({ user: n }, e, {
3407
3429
  upsert: !0,
3408
3430
  returnDocument: "after"
3409
3431
  }).lean();
3410
- class cr extends rr {
3432
+ class ha extends pa {
3411
3433
  constructor() {
3412
3434
  super(300);
3413
3435
  }
@@ -3418,14 +3440,14 @@ class cr extends rr {
3418
3440
  return e;
3419
3441
  }
3420
3442
  fetchFromDb(e) {
3421
- return ir(e);
3443
+ return fa(e);
3422
3444
  }
3423
3445
  updateInDb(e, t) {
3424
- return ur(e, t);
3446
+ return ma(e, t);
3425
3447
  }
3426
3448
  }
3427
- const Ls = new cr();
3428
- class or extends f {
3449
+ const oi = new ha();
3450
+ class wa extends f {
3429
3451
  async didSevenDoubleAtDoQ(e) {
3430
3452
  await this.update(e, {
3431
3453
  $inc: { "doubleOrQuit.sevenDoubleInARowCount": 1 }
@@ -3434,11 +3456,11 @@ class or extends f {
3434
3456
  async winWithBlackjack(e) {
3435
3457
  await this.update(e, { $inc: { "blackJack.blackJackCount": 1 } });
3436
3458
  }
3437
- async updateLastGames(e, t, a) {
3459
+ async updateLastGames(e, t, r) {
3438
3460
  await this.update(e, {
3439
3461
  $push: {
3440
3462
  lastGames: {
3441
- $each: [{ gameType: t, endState: a }],
3463
+ $each: [{ gameType: t, endState: r }],
3442
3464
  $position: 0,
3443
3465
  $slice: 20
3444
3466
  }
@@ -3449,19 +3471,19 @@ class or extends f {
3449
3471
  await this.update(e, { $inc: { drawCount: 1 } });
3450
3472
  }
3451
3473
  async bet666(e) {
3452
- const t = k();
3474
+ const t = N();
3453
3475
  t.setHours(0, 0, 0, 0);
3454
- const a = /* @__PURE__ */ new Date();
3455
- a.setHours(0, 0, 0, 0), await M.updateOne(
3476
+ const r = /* @__PURE__ */ new Date();
3477
+ r.setHours(0, 0, 0, 0), await A.updateOne(
3456
3478
  {
3457
3479
  user: e,
3458
3480
  "bet666.last": {
3459
3481
  $gte: t,
3460
- $lt: a
3482
+ $lt: r
3461
3483
  }
3462
3484
  },
3463
3485
  { $inc: { "bet666.count": 1 }, $set: { "bet666.last": /* @__PURE__ */ new Date() } }
3464
- ), await M.updateOne(
3486
+ ), await A.updateOne(
3465
3487
  {
3466
3488
  user: e,
3467
3489
  "bet666.last": {
@@ -3504,18 +3526,18 @@ class or extends f {
3504
3526
  await this.update(e, { $inc: { "dice.drawWithDoubleSixCount": 1 } });
3505
3527
  }
3506
3528
  }
3507
- const dr = async (n) => await M.create({
3529
+ const ga = async (n) => await A.create({
3508
3530
  user: n
3509
3531
  });
3510
- async function lr(n) {
3511
- const e = await M.findOne({ user: n }).lean();
3512
- return e || y(await dr(n));
3532
+ async function Sa(n) {
3533
+ const e = await A.findOne({ user: n }).lean();
3534
+ return e || y(await ga(n));
3513
3535
  }
3514
- const pr = (n, e) => M.findOneAndUpdate({ user: n }, e, {
3536
+ const ba = (n, e) => A.findOneAndUpdate({ user: n }, e, {
3515
3537
  upsert: !0,
3516
3538
  returnDocument: "after"
3517
3539
  }).lean();
3518
- class yr extends or {
3540
+ class $a extends wa {
3519
3541
  constructor() {
3520
3542
  super(300);
3521
3543
  }
@@ -3526,14 +3548,14 @@ class yr extends or {
3526
3548
  return e;
3527
3549
  }
3528
3550
  fetchFromDb(e) {
3529
- return lr(e);
3551
+ return Sa(e);
3530
3552
  }
3531
3553
  updateInDb(e, t) {
3532
- return pr(e, t);
3554
+ return ba(e, t);
3533
3555
  }
3534
3556
  }
3535
- const Qs = new yr();
3536
- class fr extends f {
3557
+ const di = new $a();
3558
+ class Ea extends f {
3537
3559
  async increaseXpGiven(e, t) {
3538
3560
  await this.update(e, {
3539
3561
  $inc: {
@@ -3555,18 +3577,18 @@ class fr extends f {
3555
3577
  t ? await this.update(e, { $set: { timeCrewAbove90PercentXp: 0 } }) : await this.update(e, { $inc: { timeCrewAbove90PercentXp: 1 } });
3556
3578
  }
3557
3579
  }
3558
- const mr = async (n) => await se.create({
3580
+ const Ua = async (n) => await ie.create({
3559
3581
  user: n
3560
3582
  });
3561
- async function hr(n) {
3562
- const e = await se.findOne({ user: n }).lean();
3563
- return e || y(await mr(n));
3583
+ async function Ia(n) {
3584
+ const e = await ie.findOne({ user: n }).lean();
3585
+ return e || y(await Ua(n));
3564
3586
  }
3565
- const wr = (n, e) => se.findOneAndUpdate({ user: n }, e, {
3587
+ const Da = (n, e) => ie.findOneAndUpdate({ user: n }, e, {
3566
3588
  upsert: !0,
3567
3589
  returnDocument: "after"
3568
3590
  }).lean();
3569
- class gr extends fr {
3591
+ class Oa extends Ea {
3570
3592
  constructor() {
3571
3593
  super(300);
3572
3594
  }
@@ -3577,14 +3599,14 @@ class gr extends fr {
3577
3599
  return e;
3578
3600
  }
3579
3601
  fetchFromDb(e) {
3580
- return hr(e);
3602
+ return Ia(e);
3581
3603
  }
3582
3604
  updateInDb(e, t) {
3583
- return wr(e, t);
3605
+ return Da(e, t);
3584
3606
  }
3585
3607
  }
3586
- const Ws = new gr();
3587
- class Sr extends f {
3608
+ const li = new Oa();
3609
+ class Ta extends f {
3588
3610
  async workIncrement(e) {
3589
3611
  await this.update(e, { $inc: { workCount: 1 } });
3590
3612
  }
@@ -3596,18 +3618,18 @@ class Sr extends f {
3596
3618
  });
3597
3619
  }
3598
3620
  }
3599
- const br = (n) => ie.create({
3621
+ const Ra = (n) => ue.create({
3600
3622
  user: n
3601
3623
  });
3602
- async function $r(n) {
3603
- const e = await ie.findOne({ user: n }).lean();
3604
- return e || y(await br(n));
3624
+ async function Ca(n) {
3625
+ const e = await ue.findOne({ user: n }).lean();
3626
+ return e || y(await Ra(n));
3605
3627
  }
3606
- const Er = (n, e) => ie.findOneAndUpdate({ user: n }, e, {
3628
+ const va = (n, e) => ue.findOneAndUpdate({ user: n }, e, {
3607
3629
  upsert: !0,
3608
3630
  returnDocument: "after"
3609
3631
  }).lean();
3610
- class Ur extends Sr {
3632
+ class Aa extends Ta {
3611
3633
  constructor() {
3612
3634
  super(300);
3613
3635
  }
@@ -3618,14 +3640,14 @@ class Ur extends Sr {
3618
3640
  return e;
3619
3641
  }
3620
3642
  fetchFromDb(e) {
3621
- return $r(e);
3643
+ return Ca(e);
3622
3644
  }
3623
3645
  updateInDb(e, t) {
3624
- return Er(e, t);
3646
+ return va(e, t);
3625
3647
  }
3626
3648
  }
3627
- const Ir = new Ur();
3628
- class Tr extends f {
3649
+ const Ma = new Aa();
3650
+ class Ba extends f {
3629
3651
  async randomMessageIncrement(e) {
3630
3652
  await this.update(e, { $inc: { randomMessageClaimed: 1 } });
3631
3653
  }
@@ -3643,18 +3665,18 @@ class Tr extends f {
3643
3665
  await this.update(e, { $inc: { totalMinutesInVoice: t } });
3644
3666
  }
3645
3667
  }
3646
- const Dr = async (n) => await ue.create({
3668
+ const xa = async (n) => await ce.create({
3647
3669
  user: n
3648
3670
  });
3649
- async function Or(n) {
3650
- const e = await ue.findOne({ user: n }).lean();
3651
- return e || y(await Dr(n));
3671
+ async function qa(n) {
3672
+ const e = await ce.findOne({ user: n }).lean();
3673
+ return e || y(await xa(n));
3652
3674
  }
3653
- const Cr = (n, e) => ue.findOneAndUpdate({ user: n }, e, {
3675
+ const ka = (n, e) => ce.findOneAndUpdate({ user: n }, e, {
3654
3676
  upsert: !0,
3655
3677
  returnDocument: "after"
3656
3678
  }).lean();
3657
- class Rr extends Tr {
3679
+ class _a extends Ba {
3658
3680
  constructor() {
3659
3681
  super(300);
3660
3682
  }
@@ -3667,14 +3689,14 @@ class Rr extends Tr {
3667
3689
  return e;
3668
3690
  }
3669
3691
  fetchFromDb(e) {
3670
- return Or(e);
3692
+ return qa(e);
3671
3693
  }
3672
3694
  updateInDb(e, t) {
3673
- return Cr(e, t);
3695
+ return ka(e, t);
3674
3696
  }
3675
3697
  }
3676
- const Gs = new Rr();
3677
- class Mr extends f {
3698
+ const pi = new _a();
3699
+ class Na extends f {
3678
3700
  async hasReportedSomeone(e) {
3679
3701
  await this.update(e, { $set: { reportedSomeone: !0 } });
3680
3702
  }
@@ -3705,18 +3727,18 @@ class Mr extends f {
3705
3727
  await this.update(e, { $set: { "gamblingFlags.lose10M": !0 } });
3706
3728
  }
3707
3729
  }
3708
- const vr = async (n) => await ce.create({
3730
+ const Fa = async (n) => await oe.create({
3709
3731
  user: n
3710
3732
  });
3711
- async function Ar(n) {
3712
- const e = await ce.findOne({ user: n }).lean();
3713
- return e || y(await vr(n));
3733
+ async function ja(n) {
3734
+ const e = await oe.findOne({ user: n }).lean();
3735
+ return e || y(await Fa(n));
3714
3736
  }
3715
- const Br = (n, e) => ce.findOneAndUpdate({ user: n }, e, {
3737
+ const za = (n, e) => oe.findOneAndUpdate({ user: n }, e, {
3716
3738
  upsert: !0,
3717
3739
  returnDocument: "after"
3718
3740
  }).lean();
3719
- class _r extends Mr {
3741
+ class Ka extends Na {
3720
3742
  constructor() {
3721
3743
  super(300);
3722
3744
  }
@@ -3727,17 +3749,17 @@ class _r extends Mr {
3727
3749
  return e;
3728
3750
  }
3729
3751
  fetchFromDb(e) {
3730
- return Ar(e);
3752
+ return ja(e);
3731
3753
  }
3732
3754
  updateInDb(e, t) {
3733
- return Br(e, t);
3755
+ return za(e, t);
3734
3756
  }
3735
3757
  }
3736
- const Ys = new _r();
3737
- class xr extends f {
3758
+ const yi = new Ka();
3759
+ class Pa extends f {
3738
3760
  async readEdito(e) {
3739
3761
  const t = /* @__PURE__ */ new Date();
3740
- t.setHours(0, 0, 0, 0), await v.updateOne(
3762
+ t.setHours(0, 0, 0, 0), await M.updateOne(
3741
3763
  {
3742
3764
  user: e,
3743
3765
  "edito.lastTimeRead": {
@@ -3748,7 +3770,7 @@ class xr extends f {
3748
3770
  $inc: { "edito.readToday": 1 },
3749
3771
  $set: { "edito.lastTimeRead": /* @__PURE__ */ new Date() }
3750
3772
  }
3751
- ), await v.updateOne(
3773
+ ), await M.updateOne(
3752
3774
  {
3753
3775
  user: e,
3754
3776
  "edito.lastTimeRead": {
@@ -3761,18 +3783,18 @@ class xr extends f {
3761
3783
  ), this.invalidate(e);
3762
3784
  }
3763
3785
  }
3764
- const qr = async (n) => await v.create({
3786
+ const Ha = async (n) => await M.create({
3765
3787
  user: n
3766
3788
  });
3767
- async function kr(n) {
3768
- const e = await v.findOne({ user: n }).lean();
3769
- return e || y(await qr(n));
3789
+ async function La(n) {
3790
+ const e = await M.findOne({ user: n }).lean();
3791
+ return e || y(await Ha(n));
3770
3792
  }
3771
- const Nr = (n, e) => v.findOneAndUpdate({ user: n }, e, {
3793
+ const Qa = (n, e) => M.findOneAndUpdate({ user: n }, e, {
3772
3794
  upsert: !0,
3773
3795
  returnDocument: "after"
3774
3796
  }).lean();
3775
- class Fr extends xr {
3797
+ class Wa extends Pa {
3776
3798
  constructor() {
3777
3799
  super(300);
3778
3800
  }
@@ -3783,52 +3805,52 @@ class Fr extends xr {
3783
3805
  return e;
3784
3806
  }
3785
3807
  fetchFromDb(e) {
3786
- return kr(e);
3808
+ return La(e);
3787
3809
  }
3788
3810
  updateInDb(e, t) {
3789
- return Nr(e, t);
3811
+ return Qa(e, t);
3790
3812
  }
3791
3813
  }
3792
- const Xs = new Fr();
3793
- class jr extends f {
3794
- async updateCraftStats(e, t, a) {
3795
- const r = await d.get(a);
3796
- !r || !d.isItem(r) || await this.update(e, {
3814
+ const fi = new Wa();
3815
+ class Ga extends f {
3816
+ async updateCraftStats(e, t, r) {
3817
+ const a = await d.get(r);
3818
+ !a || !d.isItem(a) || await this.update(e, {
3797
3819
  $inc: {
3798
- "crafts.cookedMeal": d.isCookedMeal(r) ? t : 0,
3799
- "crafts.scrolls": d.isScrollItem(r) ? t : 0,
3820
+ "crafts.cookedMeal": d.isCookedMeal(a) ? t : 0,
3821
+ "crafts.scrolls": d.isScrollItem(a) ? t : 0,
3800
3822
  "crafts.totalCrafted": t
3801
3823
  }
3802
3824
  });
3803
3825
  }
3804
- async incrementAlcoholDrink(e, t, a) {
3826
+ async incrementAlcoholDrink(e, t, r) {
3805
3827
  ["wine", "beer", "rhum"].includes(t) && await this.update(e, {
3806
3828
  $inc: {
3807
- "alcohols.wines": t === "wine" ? a : 0,
3808
- "alcohols.beers": t === "beer" ? a : 0,
3809
- "alcohols.rhums": t === "rhum" ? a : 0,
3810
- "alcohols.totalConsumed": a
3829
+ "alcohols.wines": t === "wine" ? r : 0,
3830
+ "alcohols.beers": t === "beer" ? r : 0,
3831
+ "alcohols.rhums": t === "rhum" ? r : 0,
3832
+ "alcohols.totalConsumed": r
3811
3833
  }
3812
3834
  });
3813
3835
  }
3814
3836
  async incrementBottleUsedToday(e, t) {
3815
- const a = /* @__PURE__ */ new Date();
3816
- a.setHours(0, 0, 0, 0), await A.updateOne(
3837
+ const r = /* @__PURE__ */ new Date();
3838
+ r.setHours(0, 0, 0, 0), await B.updateOne(
3817
3839
  {
3818
3840
  user: e,
3819
3841
  "bottle.lastUsed": {
3820
- $gte: a
3842
+ $gte: r
3821
3843
  }
3822
3844
  },
3823
3845
  {
3824
3846
  $inc: { "bottle.usedToday": t },
3825
3847
  $set: { "bottle.lastUsed": /* @__PURE__ */ new Date() }
3826
3848
  }
3827
- ), await A.updateOne(
3849
+ ), await B.updateOne(
3828
3850
  {
3829
3851
  user: e,
3830
3852
  "bottle.lastUsed": {
3831
- $lt: a
3853
+ $lt: r
3832
3854
  }
3833
3855
  },
3834
3856
  {
@@ -3850,18 +3872,18 @@ class jr extends f {
3850
3872
  });
3851
3873
  }
3852
3874
  }
3853
- const zr = async (n) => await A.create({
3875
+ const Ya = async (n) => await B.create({
3854
3876
  user: n
3855
3877
  });
3856
- async function Pr(n) {
3857
- const e = await A.findOne({ user: n }).lean();
3858
- return e || y(await zr(n));
3878
+ async function Xa(n) {
3879
+ const e = await B.findOne({ user: n }).lean();
3880
+ return e || y(await Ya(n));
3859
3881
  }
3860
- const Kr = (n, e) => A.findOneAndUpdate({ user: n }, e, {
3882
+ const Va = (n, e) => B.findOneAndUpdate({ user: n }, e, {
3861
3883
  upsert: !0,
3862
3884
  returnDocument: "after"
3863
3885
  }).lean();
3864
- class Hr extends jr {
3886
+ class Ja extends Ga {
3865
3887
  constructor() {
3866
3888
  super(300);
3867
3889
  }
@@ -3872,41 +3894,134 @@ class Hr extends jr {
3872
3894
  return e;
3873
3895
  }
3874
3896
  fetchFromDb(e) {
3875
- return Pr(e);
3897
+ return Xa(e);
3876
3898
  }
3877
3899
  updateInDb(e, t) {
3878
- return Kr(e, t);
3900
+ return Va(e, t);
3901
+ }
3902
+ }
3903
+ const mi = new Ja();
3904
+ class Za extends b {
3905
+ async maxCraftQuantity(e, t) {
3906
+ const r = await w.get(e);
3907
+ let a = 1 / 0;
3908
+ for (const s of t)
3909
+ a = Math.min(
3910
+ a,
3911
+ Math.floor(
3912
+ (r.itemList[s.entityId] ?? 0) / s.size
3913
+ )
3914
+ );
3915
+ return a;
3916
+ }
3917
+ async hasEnoughItemsForRecipe(e, t, r) {
3918
+ const a = await w.get(e);
3919
+ for (const s of t.entities)
3920
+ if ((a.itemList[s.entityId] ?? 0) < s.size * r)
3921
+ return !1;
3922
+ return !0;
3923
+ }
3924
+ decodeCraftId(e) {
3925
+ return e.split(";").map((t, r) => ({
3926
+ entityId: t === "null" ? null : t,
3927
+ index: r
3928
+ }));
3929
+ }
3930
+ encodeCraftId(e) {
3931
+ return e.map(({ entityId: t }) => `${t}`).join(";");
3932
+ }
3933
+ async isValidRecipe(e) {
3934
+ return !!(await this.getAll()).find((r) => r.craftId === e);
3935
+ }
3936
+ async getRecipeResult(e, t) {
3937
+ const r = await w.get(e), a = (await U.getPanoplyBonus(r.equippedItems)).find(
3938
+ ([s, i]) => s.panoplyId === "little_blacksmith" && i !== null
3939
+ );
3940
+ return a?.[1] === "full" && t === "chest_3" ? "chest_blacksmith_3" : a?.[1] === "half" && t === "chest_2" ? "chest_blacksmith_2" : a?.[1] === "half" && t === "chest_1" ? "chest_blacksmith_1" : t;
3879
3941
  }
3880
3942
  }
3881
- const Vs = new Hr(), Lr = new u({
3943
+ const es = new u(
3944
+ {
3945
+ entityId: { type: String, required: !0 },
3946
+ size: { type: Number, required: !0 }
3947
+ },
3948
+ { _id: !1 }
3949
+ ), ts = new u(
3950
+ {
3951
+ entityId: { type: String, required: !0 },
3952
+ size: { type: Number, required: !0 }
3953
+ },
3954
+ { _id: !1 }
3955
+ ), ns = new u(
3956
+ {
3957
+ craftId: { type: String, unique: !0, required: !0 },
3958
+ name: { type: String, required: !0 },
3959
+ entities: { type: [es], required: !0 },
3960
+ result: { type: ts, required: !0 }
3961
+ },
3962
+ { minimize: !1 }
3963
+ ), le = l?.Recipes || p("Recipes", ns), rs = async (n) => await le.create({
3964
+ ...n
3965
+ }), as = async (n, e = {}) => le.find(n, e).lean();
3966
+ async function ss(n) {
3967
+ const e = await le.findOne({ craftId: n }).lean();
3968
+ return e || null;
3969
+ }
3970
+ const is = (n, e) => le.findOneAndUpdate(n, e, {
3971
+ returnDocument: "after"
3972
+ }).lean();
3973
+ class us extends Za {
3974
+ constructor() {
3975
+ super(3600);
3976
+ }
3977
+ createInDb(e) {
3978
+ return rs(e);
3979
+ }
3980
+ updateInDb(e, t) {
3981
+ return is(e, t);
3982
+ }
3983
+ fetchFromDb(e) {
3984
+ return ss(e);
3985
+ }
3986
+ fetchManyFromDb(e) {
3987
+ return as(e);
3988
+ }
3989
+ normalizeKey(e) {
3990
+ return e;
3991
+ }
3992
+ getKey(e) {
3993
+ return e.craftId;
3994
+ }
3995
+ }
3996
+ const hi = new us(), cs = new u({
3882
3997
  bannedUserId: { type: String, index: !0, required: !0 },
3883
3998
  authorId: { type: String, required: !0 },
3884
3999
  unbannedTimestamp: { type: Date, index: 1 },
3885
4000
  reason: { type: String, required: !0 },
3886
4001
  guildId: { type: String, required: !0 }
3887
- }), de = l?.Bans || p("Bans", Lr), Qr = (n, e) => de.deleteOne({ bannedUserId: n, guildId: e });
3888
- class Wr extends b {
4002
+ }), pe = l?.Bans || p("Bans", cs), os = (n, e) => pe.deleteOne({ bannedUserId: n, guildId: e });
4003
+ class ds extends b {
3889
4004
  async getUnbanUsers() {
3890
4005
  return this.getMany({
3891
4006
  unbannedTimestamp: { $lte: /* @__PURE__ */ new Date(), $ne: null }
3892
4007
  });
3893
4008
  }
3894
- async banUserFromGuild({ bannedUserId: e, guildId: t, ...a }) {
3895
- await this.update({ bannedUserId: e, guildId: t }, { ...a });
4009
+ async banUserFromGuild({ bannedUserId: e, guildId: t, ...r }) {
4010
+ await this.update({ bannedUserId: e, guildId: t }, { ...r });
3896
4011
  }
3897
4012
  async isBannedFromGuild(e, t) {
3898
- const a = await this.get({ bannedUserId: e, guildId: t });
3899
- return !!(a && (!a.unbannedTimestamp || a.unbannedTimestamp > /* @__PURE__ */ new Date()));
4013
+ const r = await this.get({ bannedUserId: e, guildId: t });
4014
+ return !!(r && (!r.unbannedTimestamp || r.unbannedTimestamp > /* @__PURE__ */ new Date()));
3900
4015
  }
3901
4016
  async deleteBan(e, t) {
3902
- await Qr(e, t), this.invalidate({ bannedUserId: e, guildId: t });
4017
+ await os(e, t), this.invalidate({ bannedUserId: e, guildId: t });
3903
4018
  }
3904
4019
  }
3905
- const Gr = (n) => de.find(n).lean(), Yr = (n) => de.findOne(n).lean(), Xr = (n, e) => de.findOneAndUpdate(n, e, {
4020
+ const ls = (n) => pe.find(n).lean(), ps = (n) => pe.findOne(n).lean(), ys = (n, e) => pe.findOneAndUpdate(n, e, {
3906
4021
  returnDocument: "after",
3907
4022
  upsert: !0
3908
4023
  }).lean();
3909
- class Vr extends Wr {
4024
+ class fs extends ds {
3910
4025
  constructor() {
3911
4026
  super(3600 * 36);
3912
4027
  }
@@ -3917,16 +4032,16 @@ class Vr extends Wr {
3917
4032
  return { bannedUserId: e, guildId: t };
3918
4033
  }
3919
4034
  fetchFromDb(e) {
3920
- return Yr(e);
4035
+ return ps(e);
3921
4036
  }
3922
4037
  fetchManyFromDb(e) {
3923
- return Gr(e);
4038
+ return ls(e);
3924
4039
  }
3925
4040
  updateInDb(e, t) {
3926
- return Xr(e, t);
4041
+ return ys(e, t);
3927
4042
  }
3928
4043
  }
3929
- const Js = new Vr(), Jr = new u({
4044
+ const wi = new fs(), ms = new u({
3930
4045
  senderId: {
3931
4046
  type: u.Types.ObjectId,
3932
4047
  required: !0,
@@ -3943,35 +4058,36 @@ const Js = new Vr(), Jr = new u({
3943
4058
  meta: {
3944
4059
  rps: { type: String, default: void 0 }
3945
4060
  }
3946
- }), le = l?.Invitation || p("Invitation", Jr), Zr = (n) => le.create({
4061
+ }), ye = l?.Invitation || p("Invitation", ms), hs = (n) => ye.create({
3947
4062
  ...n
3948
- }), es = async (n) => {
3949
- await le.deleteMany({
4063
+ }), ws = async (n) => {
4064
+ await ye.deleteMany({
3950
4065
  ...n
3951
4066
  });
3952
4067
  };
3953
- class ts extends f {
4068
+ class gs extends f {
3954
4069
  async sendInvitation({
3955
4070
  senderId: e,
3956
4071
  receiverId: t,
3957
- gameMode: a,
3958
- ...r
4072
+ gameMode: r,
4073
+ ...a
3959
4074
  }) {
3960
- return await this.get({ senderId: e, gameMode: a, receiverId: t }) ? !1 : (await Zr({ ...r, senderId: e, gameMode: a, receiverId: t }), !0);
4075
+ return await this.get({ senderId: e, gameMode: r, receiverId: t }) ? null : await hs({ ...a, senderId: e, gameMode: r, receiverId: t });
3961
4076
  }
3962
- async receiveInvitation(e) {
3963
- return this.get(e);
3964
- }
3965
- async deleteInvitation(e) {
3966
- await es(e), this.invalidate(e);
4077
+ async deleteInvitation({
4078
+ senderId: e,
4079
+ receiverId: t,
4080
+ gameMode: r
4081
+ }) {
4082
+ await ws({ senderId: e, gameMode: r, receiverId: t }), this.invalidate({ senderId: e, gameMode: r, receiverId: t });
3967
4083
  }
3968
4084
  }
3969
- const ns = (n) => le.findOne({
4085
+ const Ss = (n) => ye.findOne({
3970
4086
  ...n
3971
- }).lean(), as = (n, e) => le.findOneAndUpdate(n, e, {
4087
+ }).lean(), bs = (n, e) => ye.findOneAndUpdate(n, e, {
3972
4088
  returnDocument: "after"
3973
4089
  }).lean();
3974
- class rs extends ts {
4090
+ class $s extends gs {
3975
4091
  constructor() {
3976
4092
  super(3600);
3977
4093
  }
@@ -3981,24 +4097,24 @@ class rs extends ts {
3981
4097
  getKey({
3982
4098
  receiverId: e,
3983
4099
  gameMode: t,
3984
- senderId: a
4100
+ senderId: r
3985
4101
  }) {
3986
- return { gameMode: t, receiverId: e, senderId: a };
4102
+ return { gameMode: t, receiverId: e, senderId: r };
3987
4103
  }
3988
4104
  fetchFromDb(e) {
3989
- return ns(e);
4105
+ return Ss(e);
3990
4106
  }
3991
4107
  updateInDb(e, t) {
3992
- return as(e, t);
4108
+ return bs(e, t);
3993
4109
  }
3994
4110
  }
3995
- const Zs = new rs();
3996
- class ss extends f {
4111
+ const gi = new $s();
4112
+ class Es extends f {
3997
4113
  async setEditoChannel(e, t) {
3998
4114
  await this.update({ guildId: e }, { $set: { "edito.channelId": t } });
3999
4115
  }
4000
4116
  async randomizeEditoPrice(e) {
4001
- const t = Y(100, 1001);
4117
+ const t = X(100, 1001);
4002
4118
  return await this.update({ guildId: e }, { $set: { "edito.price": t } }), t;
4003
4119
  }
4004
4120
  async setEditoMessageId(e, t) {
@@ -4022,11 +4138,11 @@ class ss extends f {
4022
4138
  { $set: { "crew.infoChannelId": t } }
4023
4139
  );
4024
4140
  }
4025
- async addCrewChannelId(e, t, a) {
4141
+ async addCrewChannelId(e, t, r) {
4026
4142
  await this.update(
4027
4143
  { guildId: e },
4028
4144
  {
4029
- $push: { "crew.crewChannelIds": { channelId: a, crewId: t } }
4145
+ $push: { "crew.crewChannelIds": { channelId: r, crewId: t } }
4030
4146
  }
4031
4147
  );
4032
4148
  }
@@ -4035,7 +4151,7 @@ class ss extends f {
4035
4151
  { guildId: e },
4036
4152
  {
4037
4153
  $set: Object.fromEntries(
4038
- Object.entries(t).map(([a, r]) => [`roles.${a}`, r])
4154
+ Object.entries(t).map(([r, a]) => [`roles.${r}`, a])
4039
4155
  )
4040
4156
  }
4041
4157
  );
@@ -4045,16 +4161,16 @@ class ss extends f {
4045
4161
  { guildId: e },
4046
4162
  {
4047
4163
  $set: Object.fromEntries(
4048
- Object.entries(t).map(([a, r]) => [
4049
- `channels.${a}`,
4050
- r
4164
+ Object.entries(t).map(([r, a]) => [
4165
+ `channels.${r}`,
4166
+ a
4051
4167
  ])
4052
4168
  )
4053
4169
  }
4054
4170
  );
4055
4171
  }
4056
4172
  }
4057
- const is = new u({
4173
+ const Us = new u({
4058
4174
  guildId: { type: String, required: !0, unique: !0 },
4059
4175
  ranking: {
4060
4176
  channelId: { type: String, default: null },
@@ -4063,7 +4179,11 @@ const is = new u({
4063
4179
  roles: {
4064
4180
  premium: { type: String, default: null },
4065
4181
  booster: { type: String, default: null },
4066
- scam: { type: String, default: null }
4182
+ scam: { type: String, default: null },
4183
+ factions: {
4184
+ canChange: { type: String, default: null },
4185
+ canChoose: { type: String, default: null }
4186
+ }
4067
4187
  },
4068
4188
  channels: {
4069
4189
  gambling: { type: String, default: null },
@@ -4096,16 +4216,16 @@ const is = new u({
4096
4216
  }
4097
4217
  },
4098
4218
  shopChannelId: { type: String, default: null }
4099
- }), Ue = l?.Settings || p("Settings", is), us = (n) => Ue.create({
4219
+ }), De = l?.Settings || p("Settings", Us), Is = (n) => De.create({
4100
4220
  guildId: n
4101
- }), cs = async (n) => {
4102
- const e = await Ue.findOne({ guildId: n }).lean();
4103
- return e || y(await us(n));
4104
- }, os = (n, e) => Ue.findOneAndUpdate(n, e, {
4221
+ }), Ds = async (n) => {
4222
+ const e = await De.findOne({ guildId: n }).lean();
4223
+ return e || y(await Is(n));
4224
+ }, Os = (n, e) => De.findOneAndUpdate(n, e, {
4105
4225
  upsert: !0,
4106
4226
  returnDocument: "after"
4107
4227
  }).lean();
4108
- class ds extends ss {
4228
+ class Ts extends Es {
4109
4229
  constructor() {
4110
4230
  super(3600 * 24 * 30);
4111
4231
  }
@@ -4116,13 +4236,13 @@ class ds extends ss {
4116
4236
  return e;
4117
4237
  }
4118
4238
  fetchFromDb(e) {
4119
- return cs(e);
4239
+ return Ds(e);
4120
4240
  }
4121
4241
  updateInDb(e, t) {
4122
- return os(e, t);
4242
+ return Os(e, t);
4123
4243
  }
4124
4244
  }
4125
- const ei = new ds(), ls = new u(
4245
+ const Si = new Ts(), Rs = new u(
4126
4246
  {
4127
4247
  shopType: { type: String, required: !0, unique: !0 },
4128
4248
  publishedAt: { type: Date, default: /* @__PURE__ */ new Date() },
@@ -4151,11 +4271,11 @@ const ei = new ds(), ls = new u(
4151
4271
  }
4152
4272
  },
4153
4273
  { minimize: !1 }
4154
- ), Ie = l?.Shop || p("Shop", ls), ps = (n) => Ie.create({
4274
+ ), Oe = l?.Shop || p("Shop", Rs), Cs = (n) => Oe.create({
4155
4275
  shopType: n
4156
- }), ys = async (n) => {
4157
- const e = await Ie.findOne({ shopType: n }).lean();
4158
- return e || y(await ps(n));
4276
+ }), vs = async (n) => {
4277
+ const e = await Oe.findOne({ shopType: n }).lean();
4278
+ return e || y(await Cs(n));
4159
4279
  };
4160
4280
  class E {
4161
4281
  toDBShopItem() {
@@ -4171,10 +4291,10 @@ class E {
4171
4291
  e,
4172
4292
  -1 * this.price * t,
4173
4293
  !1
4174
- ), await Ir.updateTotalSpentInShop(
4294
+ ), await Ma.updateTotalSpentInShop(
4175
4295
  e,
4176
4296
  this.price * t
4177
- )) : await S.removeItem(
4297
+ )) : await w.removeItem(
4178
4298
  e,
4179
4299
  this.currency,
4180
4300
  this.price * t
@@ -4208,7 +4328,7 @@ class E {
4208
4328
  return !1;
4209
4329
  }
4210
4330
  }
4211
- class fs extends E {
4331
+ class As extends E {
4212
4332
  price;
4213
4333
  size;
4214
4334
  currency;
@@ -4216,19 +4336,19 @@ class fs extends E {
4216
4336
  constructor({
4217
4337
  price: e,
4218
4338
  item: t,
4219
- size: a,
4220
- currency: r
4339
+ size: r,
4340
+ currency: a
4221
4341
  }) {
4222
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4342
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4223
4343
  }
4224
4344
  async onBuy(e, t) {
4225
- await super.onBuy(e, t), await G.unlockBackground(e, this.data.ornamentId);
4345
+ await super.onBuy(e, t), await Y.unlockBackground(e, this.data.ornamentId);
4226
4346
  }
4227
4347
  isBackground() {
4228
4348
  return !0;
4229
4349
  }
4230
4350
  }
4231
- class ms extends E {
4351
+ class Ms extends E {
4232
4352
  price;
4233
4353
  size;
4234
4354
  currency;
@@ -4236,19 +4356,19 @@ class ms extends E {
4236
4356
  constructor({
4237
4357
  price: e,
4238
4358
  item: t,
4239
- size: a,
4240
- currency: r
4359
+ size: r,
4360
+ currency: a
4241
4361
  }) {
4242
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4362
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4243
4363
  }
4244
4364
  async onBuy(e, t) {
4245
- await super.onBuy(e, t), await S.addItem(e, this.data.entityId, t);
4365
+ await super.onBuy(e, t), await w.addItem(e, this.data.entityId, t);
4246
4366
  }
4247
4367
  isBoostXp() {
4248
4368
  return !0;
4249
4369
  }
4250
4370
  }
4251
- class hs extends E {
4371
+ class Bs extends E {
4252
4372
  price;
4253
4373
  size;
4254
4374
  currency;
@@ -4256,19 +4376,19 @@ class hs extends E {
4256
4376
  constructor({
4257
4377
  price: e,
4258
4378
  item: t,
4259
- size: a,
4260
- currency: r
4379
+ size: r,
4380
+ currency: a
4261
4381
  }) {
4262
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4382
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4263
4383
  }
4264
4384
  async onBuy(e, t) {
4265
- await super.onBuy(e, t), await S.addItem(e, this.data.entityId, t);
4385
+ await super.onBuy(e, t), await w.addItem(e, this.data.entityId, t);
4266
4386
  }
4267
4387
  isChest() {
4268
4388
  return !0;
4269
4389
  }
4270
4390
  }
4271
- class ws extends E {
4391
+ class xs extends E {
4272
4392
  price;
4273
4393
  size;
4274
4394
  currency;
@@ -4276,19 +4396,19 @@ class ws extends E {
4276
4396
  constructor({
4277
4397
  price: e,
4278
4398
  item: t,
4279
- size: a,
4280
- currency: r
4399
+ size: r,
4400
+ currency: a
4281
4401
  }) {
4282
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4402
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4283
4403
  }
4284
4404
  async onBuy(e, t) {
4285
- await super.onBuy(e, t), await S.addItem(e, this.data.entityId, t);
4405
+ await super.onBuy(e, t), await w.addItem(e, this.data.entityId, t);
4286
4406
  }
4287
4407
  isObject() {
4288
4408
  return !0;
4289
4409
  }
4290
4410
  }
4291
- class gs extends E {
4411
+ class qs extends E {
4292
4412
  price;
4293
4413
  size;
4294
4414
  currency;
@@ -4296,22 +4416,22 @@ class gs extends E {
4296
4416
  constructor({
4297
4417
  price: e,
4298
4418
  item: t,
4299
- size: a,
4300
- currency: r
4419
+ size: r,
4420
+ currency: a
4301
4421
  }) {
4302
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4422
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4303
4423
  }
4304
4424
  async onBuy(e, t) {
4305
- await super.onBuy(e, t), await S.addEquipments(
4425
+ await super.onBuy(e, t), await w.addEquipments(
4306
4426
  e,
4307
- yt({ stop: t }).map(
4427
+ mt({ stop: t }).map(
4308
4428
  () => d.seedEquipment(
4309
4429
  { ...this.data },
4310
4430
  Date.now() - Math.round(Math.random() * 1e3)
4311
4431
  )
4312
- ).map((a) => ({
4313
- entityId: a.entityId,
4314
- seed: a.seed
4432
+ ).map((r) => ({
4433
+ entityId: r.entityId,
4434
+ seed: r.seed
4315
4435
  }))
4316
4436
  );
4317
4437
  }
@@ -4319,7 +4439,7 @@ class gs extends E {
4319
4439
  return !0;
4320
4440
  }
4321
4441
  }
4322
- class Ss extends E {
4442
+ class ks extends E {
4323
4443
  price;
4324
4444
  size;
4325
4445
  currency;
@@ -4327,19 +4447,19 @@ class Ss extends E {
4327
4447
  constructor({
4328
4448
  price: e,
4329
4449
  item: t,
4330
- size: a,
4331
- currency: r
4450
+ size: r,
4451
+ currency: a
4332
4452
  }) {
4333
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4453
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4334
4454
  }
4335
4455
  async onBuy(e, t) {
4336
- await super.onBuy(e, t), await S.addItem(e, this.data.entityId, t);
4456
+ await super.onBuy(e, t), await w.addItem(e, this.data.entityId, t);
4337
4457
  }
4338
4458
  isBottle() {
4339
4459
  return !0;
4340
4460
  }
4341
4461
  }
4342
- class bs extends E {
4462
+ class _s extends E {
4343
4463
  price;
4344
4464
  size;
4345
4465
  currency;
@@ -4347,19 +4467,19 @@ class bs extends E {
4347
4467
  constructor({
4348
4468
  price: e,
4349
4469
  item: t,
4350
- size: a,
4351
- currency: r
4470
+ size: r,
4471
+ currency: a
4352
4472
  }) {
4353
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4473
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4354
4474
  }
4355
4475
  async onBuy(e, t) {
4356
- await super.onBuy(e, t), await S.addItem(e, this.data.entityId, t);
4476
+ await super.onBuy(e, t), await w.addItem(e, this.data.entityId, t);
4357
4477
  }
4358
4478
  isRepair() {
4359
4479
  return !0;
4360
4480
  }
4361
4481
  }
4362
- class $s extends E {
4482
+ class Ns extends E {
4363
4483
  price;
4364
4484
  size;
4365
4485
  currency;
@@ -4367,19 +4487,19 @@ class $s extends E {
4367
4487
  constructor({
4368
4488
  price: e,
4369
4489
  item: t,
4370
- size: a,
4371
- currency: r
4490
+ size: r,
4491
+ currency: a
4372
4492
  }) {
4373
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4493
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4374
4494
  }
4375
4495
  async onBuy(e, t) {
4376
- await super.onBuy(e, t), await S.addItem(e, this.data.entityId, t);
4496
+ await super.onBuy(e, t), await w.addItem(e, this.data.entityId, t);
4377
4497
  }
4378
4498
  isStore() {
4379
4499
  return !0;
4380
4500
  }
4381
4501
  }
4382
- class Es extends E {
4502
+ class Fs extends E {
4383
4503
  price;
4384
4504
  size;
4385
4505
  currency;
@@ -4387,70 +4507,70 @@ class Es extends E {
4387
4507
  constructor({
4388
4508
  price: e,
4389
4509
  item: t,
4390
- size: a,
4391
- currency: r
4510
+ size: r,
4511
+ currency: a
4392
4512
  }) {
4393
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
4513
+ super(), this.data = t, this.price = e, this.size = r, this.currency = a;
4394
4514
  }
4395
4515
  async onBuy(e, t) {
4396
- await super.onBuy(e, t), await G.unlockTitle(e, this.data.ornamentId);
4516
+ await super.onBuy(e, t), await Y.unlockTitle(e, this.data.ornamentId);
4397
4517
  }
4398
4518
  isTitle() {
4399
4519
  return !0;
4400
4520
  }
4401
4521
  }
4402
- class Us extends f {
4522
+ class js extends f {
4403
4523
  async getShopItem(e, t) {
4404
- const r = (await this.get(e)).items.find((w) => w.id === t);
4405
- if (!r)
4524
+ const a = (await this.get(e)).items.find((S) => S.id === t);
4525
+ if (!a)
4406
4526
  return;
4407
- const { price: s, size: i, currency: o } = r, c = await d.get(r.id) ?? await g.get(r.id);
4527
+ const { price: s, size: i, currency: o } = a, c = await d.get(a.id) ?? await g.get(a.id);
4408
4528
  if (g.isOrnament(c) && g.isBackground(c))
4409
- return new fs({ price: s, item: c, size: i, currency: o });
4529
+ return new As({ price: s, item: c, size: i, currency: o });
4410
4530
  if (g.isOrnament(c) && g.isTitle(c))
4411
- return new Es({ price: s, item: c, size: i, currency: o });
4531
+ return new Fs({ price: s, item: c, size: i, currency: o });
4412
4532
  if (d.isEntity(c) && d.isChestItem(c))
4413
- return new hs({ price: s, item: c, size: i, currency: o });
4533
+ return new Bs({ price: s, item: c, size: i, currency: o });
4414
4534
  if (d.isEntity(c) && d.isBoostItem(c))
4415
- return new ms({ price: s, item: c, size: i, currency: o });
4535
+ return new Ms({ price: s, item: c, size: i, currency: o });
4416
4536
  if (d.isEntity(c) && d.isRepairItem(c))
4417
- return new bs({ price: s, item: c, size: i, currency: o });
4537
+ return new _s({ price: s, item: c, size: i, currency: o });
4418
4538
  if (d.isEntity(c) && d.isStoreItem(c))
4419
- return new $s({ price: s, item: c, size: i, currency: o });
4539
+ return new Ns({ price: s, item: c, size: i, currency: o });
4420
4540
  if (d.isEntity(c) && d.isObjectItem(c))
4421
- return new ws({ price: s, item: c, size: i, currency: o });
4541
+ return new xs({ price: s, item: c, size: i, currency: o });
4422
4542
  if (d.isEntity(c) && d.isEquipment(c))
4423
- return new gs({ price: s, item: c, size: i, currency: o });
4543
+ return new qs({ price: s, item: c, size: i, currency: o });
4424
4544
  if (d.isEntity(c) && d.isBottleItem(c))
4425
- return new Ss({ price: s, size: i, item: c, currency: o });
4545
+ return new ks({ price: s, size: i, item: c, currency: o });
4426
4546
  }
4427
4547
  async getShopItemList(e) {
4428
- const t = await this.get(e), a = [];
4429
- for (const { id: r } of t.items) {
4430
- const s = await this.getShopItem(e, r);
4431
- s && a.push(s);
4548
+ const t = await this.get(e), r = [];
4549
+ for (const { id: a } of t.items) {
4550
+ const s = await this.getShopItem(e, a);
4551
+ s && r.push(s);
4432
4552
  }
4433
- return a;
4553
+ return r;
4434
4554
  }
4435
4555
  getShopItemId(e) {
4436
4556
  return d.isEntity(e.data) ? e.data.entityId : e.data.ornamentId;
4437
4557
  }
4438
- async updateShopStats(e, t, a) {
4558
+ async updateShopStats(e, t, r) {
4439
4559
  await this.update(
4440
4560
  { shopType: e },
4441
4561
  {
4442
4562
  $inc: {
4443
- "stats.berrySpent": t.price * a,
4444
- "stats.itemBought": a,
4445
- "stats.chestBought": t.isChest() ? a : 0,
4446
- "stats.percentBought": t.isRepair() ? (t.data.effects.find((r) => r.type === "CREW_REPAIR")?.params.amount ?? 0) * a : 0,
4563
+ "stats.berrySpent": t.price * r,
4564
+ "stats.itemBought": r,
4565
+ "stats.chestBought": t.isChest() ? r : 0,
4566
+ "stats.percentBought": t.isRepair() ? (t.data.effects.find((a) => a.type === "CREW_REPAIR")?.params.amount ?? 0) * r : 0,
4447
4567
  "stats.boostTimeBought": t.isBoostXp() ? t.data.ms / (1440 * 60 * 1e3) : 0
4448
4568
  }
4449
4569
  }
4450
4570
  );
4451
4571
  }
4452
- async buyShopItem(e, t, a, r) {
4453
- const s = t.map((i) => (i.id === this.getShopItemId(a) && i.size && (i.size -= r), i));
4572
+ async buyShopItem(e, t, r, a) {
4573
+ const s = t.map((i) => (i.id === this.getShopItemId(r) && i.size && (i.size -= a), i));
4454
4574
  await this.update(
4455
4575
  { shopType: e },
4456
4576
  {
@@ -4481,8 +4601,8 @@ class Us extends f {
4481
4601
  );
4482
4602
  }
4483
4603
  }
4484
- const Is = (n, e) => Ie.findOneAndUpdate(n, e, { upsert: !0, returnDocument: "after" }).lean();
4485
- class Ts extends Us {
4604
+ const zs = (n, e) => Oe.findOneAndUpdate(n, e, { upsert: !0, returnDocument: "after" }).lean();
4605
+ class Ks extends js {
4486
4606
  constructor() {
4487
4607
  super(3600);
4488
4608
  }
@@ -4493,28 +4613,28 @@ class Ts extends Us {
4493
4613
  return e;
4494
4614
  }
4495
4615
  fetchFromDb(e) {
4496
- return ys(e);
4616
+ return vs(e);
4497
4617
  }
4498
4618
  updateInDb(e, t) {
4499
- return Is(e, t);
4619
+ return zs(e, t);
4500
4620
  }
4501
4621
  }
4502
- const ti = new Ts(), Ds = new u({
4622
+ const bi = new Ks(), Ps = new u({
4503
4623
  warnedUserId: { type: String, required: !0, index: !0 },
4504
4624
  authorId: String,
4505
4625
  date: { type: Date, default: Date.now() },
4506
4626
  reason: { type: String, default: null }
4507
- }), tt = l?.Warn || p("Warn", Ds), Os = (n) => tt.countDocuments(n);
4508
- class Cs extends b {
4627
+ }), rt = l?.Warn || p("Warn", Ps), Hs = (n) => rt.countDocuments(n);
4628
+ class Ls extends b {
4509
4629
  getUserWarns(e) {
4510
4630
  return this.getMany({ warnedUserId: e });
4511
4631
  }
4512
4632
  getUserWarnCount(e) {
4513
- return Os({ warnedUserId: e });
4633
+ return Hs({ warnedUserId: e });
4514
4634
  }
4515
4635
  }
4516
- const Rs = (n) => tt.find(n).lean();
4517
- class Ms extends Cs {
4636
+ const Qs = (n) => rt.find(n).lean();
4637
+ class Ws extends Ls {
4518
4638
  constructor() {
4519
4639
  super(300);
4520
4640
  }
@@ -4528,62 +4648,64 @@ class Ms extends Cs {
4528
4648
  throw new Error("Method not implemented.");
4529
4649
  }
4530
4650
  fetchManyFromDb(e) {
4531
- return Rs(e);
4651
+ return Qs(e);
4532
4652
  }
4533
4653
  updateInDb() {
4534
4654
  throw new Error("Method not implemented.");
4535
4655
  }
4536
4656
  }
4537
- const ni = new Ms(), ai = (n) => {
4538
- ut(n);
4657
+ const $i = new Ws(), Ei = (n) => {
4658
+ ot(n);
4539
4659
  };
4540
- class ri extends ct.ObjectId {
4660
+ class Ui extends dt.ObjectId {
4541
4661
  }
4542
4662
  export {
4543
- zs as COOLDOWN_COMMANDS,
4544
- ri as ObjectId,
4663
+ ai as COOLDOWN_COMMANDS,
4664
+ Ui as ObjectId,
4545
4665
  h as QUEST_MIDDLEWARE_EVENT_NAME,
4546
- he as RAID_MIDDLEWARE_EVENT_NAME,
4547
- Js as banService,
4548
- ai as connectToServices,
4549
- Ce as crewMetaService,
4550
- ks as crewOrnamentsService,
4551
- Ns as crewQuestService,
4552
- vt as crewService,
4553
- Fs as crewStatsEngagementService,
4554
- js as crewStatsFrequencyService,
4666
+ ge as RAID_MIDDLEWARE_EVENT_NAME,
4667
+ wi as banService,
4668
+ Ei as connectToServices,
4669
+ ve as crewMetaService,
4670
+ ei as crewOrnamentsService,
4671
+ ti as crewQuestService,
4672
+ Bt as crewService,
4673
+ ni as crewStatsEngagementService,
4674
+ ri as crewStatsFrequencyService,
4555
4675
  m as emitQuestMiddlewareEvent,
4556
- me as emitRaidMiddlewareEvent,
4676
+ we as emitRaidMiddlewareEvent,
4557
4677
  d as entityService,
4558
- ys as findShop,
4559
- Zs as invitationService,
4678
+ vs as findShop,
4679
+ gi as invitationService,
4560
4680
  g as ornamentService,
4561
4681
  U as panoplyService,
4562
- xs as registerQuestMiddlewareEvents,
4563
- qs as registerRaidMiddlewareEvents,
4564
- H as reminderService,
4565
- ei as settingsService,
4566
- Ie as shopModel,
4567
- ti as shopService,
4568
- va as userCooldownService,
4569
- aa as userCrewService,
4570
- Ps as userDailyReportService,
4571
- pe as userEncyclopediaService,
4572
- Ks as userGamesService,
4573
- S as userInventoryService,
4682
+ hi as recipeService,
4683
+ Js as registerQuestMiddlewareEvents,
4684
+ Zs as registerRaidMiddlewareEvents,
4685
+ L as reminderService,
4686
+ Si as settingsService,
4687
+ Oe as shopModel,
4688
+ bi as shopService,
4689
+ Br as userCooldownService,
4690
+ sr as userCrewService,
4691
+ si as userDailyReportService,
4692
+ fe as userEncyclopediaService,
4693
+ ii as userGamesService,
4694
+ w as userInventoryService,
4574
4695
  I as userMetaService,
4575
- G as userOrnamentService,
4696
+ Y as userOrnamentService,
4576
4697
  Me as userQuestService,
4577
- Hs as userRaidService,
4578
- Sn as userService,
4579
- Re as userSettingsService,
4580
- Ls as userShopService,
4581
- Qs as userStatsCasinoService,
4582
- Ws as userStatsCrewService,
4583
- Ir as userStatsEconomyService,
4584
- Gs as userStatsEngagementService,
4585
- Ys as userStatsFlagsService,
4586
- Xs as userStatsFrequencyService,
4587
- Vs as userStatsInventoryService,
4588
- ni as warnService
4698
+ ui as userRaidService,
4699
+ ci as userRankService,
4700
+ $n as userService,
4701
+ Ae as userSettingsService,
4702
+ oi as userShopService,
4703
+ di as userStatsCasinoService,
4704
+ li as userStatsCrewService,
4705
+ Ma as userStatsEconomyService,
4706
+ pi as userStatsEngagementService,
4707
+ yi as userStatsFlagsService,
4708
+ fi as userStatsFrequencyService,
4709
+ mi as userStatsInventoryService,
4710
+ $i as warnService
4589
4711
  };