@sapphire/ratelimits 2.4.2 → 2.4.3

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.
@@ -4,25 +4,20 @@ var SapphireRatelimits = (() => {
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
6
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
8
7
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
8
  var __export = (target, all) => {
10
9
  for (var name in all)
11
10
  __defProp(target, name, { get: all[name], enumerable: true });
12
11
  };
13
- var __reExport = (target, module, copyDefault, desc) => {
14
- if (module && typeof module === "object" || typeof module === "function") {
15
- for (let key of __getOwnPropNames(module))
16
- if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
17
- __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable });
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
17
  }
19
- return target;
18
+ return to;
20
19
  };
21
- var __toCommonJS = /* @__PURE__ */ ((cache) => {
22
- return (module, temp) => {
23
- return cache && cache.get(module) || (temp = __reExport(__markAsModule({}), module, 1), cache && cache.set(module, temp), temp);
24
- };
25
- })(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
20
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
21
  var __publicField = (obj, key, value) => {
27
22
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
28
23
  return value;
@@ -73,505 +68,14 @@ var SapphireRatelimits = (() => {
73
68
  return this;
74
69
  }
75
70
  };
76
- __name(RateLimit, "RateLimit");
77
-
78
- // ../utilities/dist/index.mjs
79
- var __defProp2 = Object.defineProperty;
80
- var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
81
- function arrayStrictEquals(arr1, arr2) {
82
- if (arr1 === arr2)
83
- return true;
84
- if (arr1.length !== arr2.length)
85
- return false;
86
- for (let i = 0; i < arr1.length; i++) {
87
- if (arr1[i] !== arr2[i] || typeof arr1[i] !== typeof arr2[i])
88
- return false;
89
- }
90
- return true;
91
- }
92
- __name(arrayStrictEquals, "arrayStrictEquals");
93
- __name2(arrayStrictEquals, "arrayStrictEquals");
94
- function cast(value) {
95
- return value;
96
- }
97
- __name(cast, "cast");
98
- __name2(cast, "cast");
99
- function chunk(array, chunkSize) {
100
- if (!Array.isArray(array))
101
- throw new TypeError("entries must be an array.");
102
- if (!Number.isInteger(chunkSize))
103
- throw new TypeError("chunkSize must be an integer.");
104
- if (chunkSize < 1)
105
- throw new RangeError("chunkSize must be 1 or greater.");
106
- const clone = array.slice();
107
- const chunks = [];
108
- while (clone.length)
109
- chunks.push(clone.splice(0, chunkSize));
110
- return chunks;
111
- }
112
- __name(chunk, "chunk");
113
- __name2(chunk, "chunk");
114
- function classExtends(value, base) {
115
- let ctor = value;
116
- while (ctor !== null) {
117
- if (ctor === base)
118
- return true;
119
- ctor = Object.getPrototypeOf(ctor);
120
- }
121
- return false;
122
- }
123
- __name(classExtends, "classExtends");
124
- __name2(classExtends, "classExtends");
125
- var zws = String.fromCharCode(8203);
126
- function codeBlock(language, expression) {
127
- if (typeof expression === "string") {
128
- if (expression.length === 0)
129
- return `\`\`\`${zws}\`\`\``;
130
- return `\`\`\`${language}
131
- ${expression.replace(/```/, `\`${zws}\`\``).replace(/`$/g, `\`${zws}`)}\`\`\``;
132
- }
133
- return `\`\`\`${language}
134
- ${expression || zws}\`\`\``;
135
- }
136
- __name(codeBlock, "codeBlock");
137
- __name2(codeBlock, "codeBlock");
138
- function splitText(str, length, char = " ") {
139
- const x = str.substring(0, length).lastIndexOf(char);
140
- const pos = x === -1 ? length : x;
141
- return str.substring(0, pos);
142
- }
143
- __name(splitText, "splitText");
144
- __name2(splitText, "splitText");
145
- function cutText(str, length) {
146
- if (str.length < length)
147
- return str;
148
- const cut = splitText(str, length - 3);
149
- if (cut.length < length - 3)
150
- return `${cut}...`;
151
- return `${cut.slice(0, length - 3)}...`;
152
- }
153
- __name(cutText, "cutText");
154
- __name2(cutText, "cutText");
155
- function debounce(func, options = {}) {
156
- var _a;
157
- let lastArgs;
158
- let result;
159
- let timerId;
160
- let lastCallTime;
161
- let lastInvokeTime = 0;
162
- const wait = (_a = options.wait) != null ? _a : 0;
163
- const maxWait = typeof options.maxWait === "number" ? Math.max(options.maxWait, wait) : null;
164
- function invokeFunc(time) {
165
- const args = lastArgs;
166
- lastArgs = void 0;
167
- lastInvokeTime = time;
168
- result = func(...args);
169
- return result;
170
- }
171
- __name(invokeFunc, "invokeFunc");
172
- __name2(invokeFunc, "invokeFunc");
173
- function leadingEdge(time) {
174
- lastInvokeTime = time;
175
- timerId = setTimeout(timerExpired, wait);
176
- return result;
177
- }
178
- __name(leadingEdge, "leadingEdge");
179
- __name2(leadingEdge, "leadingEdge");
180
- function remainingWait(time) {
181
- const timeSinceLastCall = time - lastCallTime;
182
- const timeSinceLastInvoke = time - lastInvokeTime;
183
- const result2 = wait - timeSinceLastCall;
184
- return maxWait === null ? result2 : Math.min(result2, maxWait - timeSinceLastInvoke);
185
- }
186
- __name(remainingWait, "remainingWait");
187
- __name2(remainingWait, "remainingWait");
188
- function shouldInvoke(time) {
189
- const timeSinceLastCall = time - lastCallTime;
190
- const timeSinceLastInvoke = time - lastInvokeTime;
191
- return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxWait !== null && timeSinceLastInvoke >= maxWait;
192
- }
193
- __name(shouldInvoke, "shouldInvoke");
194
- __name2(shouldInvoke, "shouldInvoke");
195
- function timerExpired() {
196
- const time = Date.now();
197
- if (shouldInvoke(time)) {
198
- trailingEdge(time);
199
- return;
200
- }
201
- timerId = setTimeout(timerExpired, remainingWait(time));
202
- }
203
- __name(timerExpired, "timerExpired");
204
- __name2(timerExpired, "timerExpired");
205
- function trailingEdge(time) {
206
- timerId = void 0;
207
- return invokeFunc(time);
208
- }
209
- __name(trailingEdge, "trailingEdge");
210
- __name2(trailingEdge, "trailingEdge");
211
- function cancel() {
212
- if (timerId !== void 0) {
213
- clearTimeout(timerId);
214
- }
215
- lastInvokeTime = 0;
216
- lastArgs = void 0;
217
- lastCallTime = void 0;
218
- timerId = void 0;
219
- }
220
- __name(cancel, "cancel");
221
- __name2(cancel, "cancel");
222
- function flush() {
223
- return timerId === void 0 ? result : trailingEdge(Date.now());
224
- }
225
- __name(flush, "flush");
226
- __name2(flush, "flush");
227
- function debounced(...args) {
228
- const time = Date.now();
229
- const isInvoking = shouldInvoke(time);
230
- lastArgs = args;
231
- lastCallTime = time;
232
- if (isInvoking) {
233
- if (timerId === void 0) {
234
- return leadingEdge(lastCallTime);
235
- }
236
- if (maxWait !== null) {
237
- timerId = setTimeout(timerExpired, wait);
238
- return invokeFunc(lastCallTime);
239
- }
240
- }
241
- if (timerId === void 0) {
242
- timerId = setTimeout(timerExpired, wait);
243
- }
244
- return result;
245
- }
246
- __name(debounced, "debounced");
247
- __name2(debounced, "debounced");
248
- debounced.cancel = cancel;
249
- debounced.flush = flush;
250
- return debounced;
251
- }
252
- __name(debounce, "debounce");
253
- __name2(debounce, "debounce");
254
- var primitiveTypes = ["string", "bigint", "number", "boolean"];
255
- function isPrimitive(input) {
256
- return primitiveTypes.includes(typeof input);
257
- }
258
- __name(isPrimitive, "isPrimitive");
259
- __name2(isPrimitive, "isPrimitive");
260
- function deepClone(source) {
261
- if (source === null || isPrimitive(source)) {
262
- return source;
263
- }
264
- if (source instanceof Date) {
265
- const output = new source.constructor(source);
266
- return output;
267
- }
268
- if (Array.isArray(source)) {
269
- const output = new source.constructor(source.length);
270
- for (let i = 0; i < source.length; i++) {
271
- output[i] = deepClone(source[i]);
272
- }
273
- return output;
274
- }
275
- if (source instanceof Map) {
276
- const output = new source.constructor();
277
- for (const [key, value] of source.entries()) {
278
- output.set(key, deepClone(value));
279
- }
280
- return output;
281
- }
282
- if (source instanceof Set) {
283
- const output = new source.constructor();
284
- for (const value of source.values()) {
285
- output.add(deepClone(value));
286
- }
287
- return output;
288
- }
289
- if (typeof source === "object") {
290
- const output = new source.constructor();
291
- for (const [key, value] of Object.entries(source)) {
292
- Object.defineProperty(output, key, {
293
- configurable: true,
294
- enumerable: true,
295
- value: deepClone(value),
296
- writable: true
297
- });
298
- }
299
- return output;
300
- }
301
- return source;
302
- }
303
- __name(deepClone, "deepClone");
304
- __name2(deepClone, "deepClone");
305
- function isNullOrUndefined(value) {
306
- return value === void 0 || value === null;
307
- }
308
- __name(isNullOrUndefined, "isNullOrUndefined");
309
- __name2(isNullOrUndefined, "isNullOrUndefined");
310
- function filterNullAndUndefined(value) {
311
- return !isNullOrUndefined(value);
312
- }
313
- __name(filterNullAndUndefined, "filterNullAndUndefined");
314
- __name2(filterNullAndUndefined, "filterNullAndUndefined");
315
- function isNullOrUndefinedOrEmpty(value) {
316
- return isNullOrUndefined(value) || value.length === 0;
317
- }
318
- __name(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
319
- __name2(isNullOrUndefinedOrEmpty, "isNullOrUndefinedOrEmpty");
320
- function filterNullAndUndefinedAndEmpty(value) {
321
- return !isNullOrUndefinedOrEmpty(value);
322
- }
323
- __name(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
324
- __name2(filterNullAndUndefinedAndEmpty, "filterNullAndUndefinedAndEmpty");
325
- function isNullOrUndefinedOrZero(value) {
326
- return value === 0 || isNullOrUndefined(value);
327
- }
328
- __name(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
329
- __name2(isNullOrUndefinedOrZero, "isNullOrUndefinedOrZero");
330
- function filterNullAndUndefinedAndZero(value) {
331
- return !isNullOrUndefinedOrZero(value);
332
- }
333
- __name(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
334
- __name2(filterNullAndUndefinedAndZero, "filterNullAndUndefinedAndZero");
335
- function hasAtLeastOneKeyInMap(map, keys) {
336
- return keys.some((key) => map.has(key));
337
- }
338
- __name(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
339
- __name2(hasAtLeastOneKeyInMap, "hasAtLeastOneKeyInMap");
340
- var zws2 = String.fromCharCode(8203);
341
- function inlineCodeBlock(input) {
342
- return `\`${input.replace(/ /g, "\xA0").replace(/`/g, `\`${zws2}`)}\``;
343
- }
344
- __name(inlineCodeBlock, "inlineCodeBlock");
345
- __name2(inlineCodeBlock, "inlineCodeBlock");
346
- function isClass(input) {
347
- return typeof input === "function" && typeof input.prototype === "object";
348
- }
349
- __name(isClass, "isClass");
350
- __name2(isClass, "isClass");
351
- function isFunction(input) {
352
- return typeof input === "function";
353
- }
354
- __name(isFunction, "isFunction");
355
- __name2(isFunction, "isFunction");
356
- function isNumber(input) {
357
- return typeof input === "number" && !isNaN(input) && Number.isFinite(input);
358
- }
359
- __name(isNumber, "isNumber");
360
- __name2(isNumber, "isNumber");
361
- function isObject(input, constructorType) {
362
- return typeof input === "object" && input ? input.constructor === (constructorType != null ? constructorType : Object) : false;
363
- }
364
- __name(isObject, "isObject");
365
- __name2(isObject, "isObject");
366
- function hasThen(input) {
367
- return Reflect.has(input, "then") && isFunction(input.then);
368
- }
369
- __name(hasThen, "hasThen");
370
- __name2(hasThen, "hasThen");
371
- function hasCatch(input) {
372
- return Reflect.has(input, "catch") && isFunction(input.catch);
373
- }
374
- __name(hasCatch, "hasCatch");
375
- __name2(hasCatch, "hasCatch");
376
- function isThenable(input) {
377
- if (typeof input !== "object" || input === null)
378
- return false;
379
- return input instanceof Promise || input !== Promise.prototype && hasThen(input) && hasCatch(input);
380
- }
381
- __name(isThenable, "isThenable");
382
- __name2(isThenable, "isThenable");
383
- function makeObject(path, value, obj = {}) {
384
- if (path.includes(".")) {
385
- const route = path.split(".");
386
- const lastKey = route.pop();
387
- let reference = obj;
388
- for (const key of route) {
389
- if (!reference[key])
390
- reference[key] = {};
391
- reference = reference[key];
392
- }
393
- reference[lastKey] = value;
394
- } else {
395
- obj[path] = value;
396
- }
397
- return obj;
398
- }
399
- __name(makeObject, "makeObject");
400
- __name2(makeObject, "makeObject");
401
- function mergeDefault(base, overwrites) {
402
- if (!overwrites)
403
- return deepClone(base);
404
- for (const [baseKey, baseValue] of Object.entries(base)) {
405
- const overwritesValueAtBaseKey = Reflect.get(overwrites, baseKey);
406
- if (typeof overwritesValueAtBaseKey === "undefined") {
407
- Reflect.set(overwrites, baseKey, deepClone(baseValue));
408
- } else if (isObject(overwritesValueAtBaseKey)) {
409
- Reflect.set(overwrites, baseKey, mergeDefault(baseValue != null ? baseValue : {}, overwritesValueAtBaseKey));
410
- }
411
- }
412
- return overwrites;
413
- }
414
- __name(mergeDefault, "mergeDefault");
415
- __name2(mergeDefault, "mergeDefault");
416
- function mergeObjects(objTarget, objSource) {
417
- for (const [key, value] of Object.entries(objSource)) {
418
- const targetValue = Reflect.get(objTarget, key);
419
- if (isObject(value)) {
420
- Reflect.set(objTarget, key, isObject(targetValue) ? mergeObjects(targetValue, value) : value);
421
- } else if (!isObject(targetValue)) {
422
- Reflect.set(objTarget, key, value);
423
- }
424
- }
425
- return objTarget;
426
- }
427
- __name(mergeObjects, "mergeObjects");
428
- __name2(mergeObjects, "mergeObjects");
429
- function noop() {
430
- }
431
- __name(noop, "noop");
432
- __name2(noop, "noop");
433
- function objectToTuples(original, prefix = "") {
434
- const entries = [];
435
- for (const [key, value] of Object.entries(original)) {
436
- if (isObject(value)) {
437
- entries.push(...objectToTuples(value, `${prefix}${key}.`));
438
- } else {
439
- entries.push([`${prefix}${key}`, value]);
440
- }
441
- }
442
- return entries;
443
- }
444
- __name(objectToTuples, "objectToTuples");
445
- __name2(objectToTuples, "objectToTuples");
446
- function parseURL(url) {
447
- try {
448
- return new URL(url);
449
- } catch {
450
- return null;
451
- }
452
- }
453
- __name(parseURL, "parseURL");
454
- __name2(parseURL, "parseURL");
455
- function partition(array, predicate) {
456
- if (!Array.isArray(array))
457
- throw new TypeError("entries must be an array.");
458
- if (!isFunction(predicate))
459
- throw new TypeError("predicate must be an function that returns a boolean value.");
460
- const partitionOne = [];
461
- const partitionTwo = [];
462
- for (let i = 0; i < array.length; i++) {
463
- if (predicate(array[i], i)) {
464
- partitionOne.push(array[i]);
465
- } else {
466
- partitionTwo.push(array[i]);
467
- }
468
- }
469
- return [partitionOne, partitionTwo];
470
- }
471
- __name(partition, "partition");
472
- __name2(partition, "partition");
473
- function range(min, max, step) {
474
- return new Array(Math.floor((max - min) / step) + 1).fill(0).map((_val, i) => min + i * step);
475
- }
476
- __name(range, "range");
477
- __name2(range, "range");
478
- var REGEXPESC = /[-/\\^$*+?.()|[\]{}]/g;
479
- function regExpEsc(str) {
480
- return str.replace(REGEXPESC, "\\$&");
481
- }
482
- __name(regExpEsc, "regExpEsc");
483
- __name2(regExpEsc, "regExpEsc");
484
- function roundNumber(num, scale = 0) {
485
- if (!num.toString().includes("e")) {
486
- return Number(`${Math.round(Number(`${num}e+${scale}`))}e-${scale}`);
487
- }
488
- const arr = `${num}`.split("e");
489
- let sig = "";
490
- if (Number(arr[1]) + scale > 0) {
491
- sig = "+";
492
- }
493
- return Number(`${Math.round(Number(`${Number(arr[0])}e${sig}${Number(arr[1]) + scale}`))}e-${scale}`);
494
- }
495
- __name(roundNumber, "roundNumber");
496
- __name2(roundNumber, "roundNumber");
497
- var TO_TITLE_CASE = /[A-Za-zÀ-ÖØ-öø-ÿ]\S*/g;
498
- var baseVariants = {
499
- textchannel: "TextChannel",
500
- voicechannel: "VoiceChannel",
501
- categorychannel: "CategoryChannel",
502
- guildmember: "GuildMember"
503
- };
504
- function toTitleCase(str, options = {}) {
505
- const { additionalVariants = {}, caseSensitive } = options;
506
- const titleCaseVariants = {
507
- ...baseVariants,
508
- ...caseSensitive ? additionalVariants : Object.entries(additionalVariants).reduce((variants, [key, variant]) => ({ ...variants, [key.toLowerCase()]: variant }), {})
509
- };
510
- return str.replace(TO_TITLE_CASE, (txt) => {
511
- var _a;
512
- return (_a = titleCaseVariants[caseSensitive ? txt : txt.toLowerCase()]) != null ? _a : txt.charAt(0).toUpperCase() + txt.substring(1).toLowerCase();
513
- });
514
- }
515
- __name(toTitleCase, "toTitleCase");
516
- __name2(toTitleCase, "toTitleCase");
517
- function tryParse(value) {
518
- try {
519
- return JSON.parse(value);
520
- } catch (err) {
521
- return value;
522
- }
523
- }
524
- __name(tryParse, "tryParse");
525
- __name2(tryParse, "tryParse");
526
71
 
527
72
  // ../time-utilities/dist/index.mjs
528
- var __defProp3 = Object.defineProperty;
529
- var __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
530
- var __name3 = /* @__PURE__ */ __name((target, value) => __defProp3(target, "name", { value, configurable: true }), "__name");
73
+ var __defProp2 = Object.defineProperty;
74
+ var __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, "__defNormalProp");
531
75
  var __publicField2 = /* @__PURE__ */ __name((obj, key, value) => {
532
76
  __defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
533
77
  return value;
534
78
  }, "__publicField");
535
- var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
536
- var months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
537
- var tokens = /* @__PURE__ */ new Map([
538
- ["Y", 4],
539
- ["Q", 1],
540
- ["M", 4],
541
- ["D", 4],
542
- ["d", 4],
543
- ["X", 1],
544
- ["x", 1],
545
- ["H", 2],
546
- ["h", 2],
547
- ["a", 1],
548
- ["A", 1],
549
- ["m", 2],
550
- ["s", 2],
551
- ["S", 3],
552
- ["Z", 2],
553
- ["l", 4],
554
- ["L", 4],
555
- ["T", 1],
556
- ["t", 1]
557
- ]);
558
- var partRegex = /^(?:(\*)|(\d+)(?:-(\d+))?)(?:\/(\d+))?$/;
559
- var wildcardRegex = /\bh\b|\B\?\B/g;
560
- var allowedNum = [
561
- [0, 59],
562
- [0, 23],
563
- [1, 31],
564
- [1, 12],
565
- [0, 6]
566
- ];
567
- var predefined = {
568
- "@annually": "0 0 1 1 *",
569
- "@yearly": "0 0 1 1 *",
570
- "@monthly": "0 0 1 * *",
571
- "@weekly": "0 0 * * 0",
572
- "@daily": "0 0 * * *",
573
- "@hourly": "0 * * * *"
574
- };
575
79
  var cronTokens = {
576
80
  jan: 1,
577
81
  feb: 2,
@@ -624,90 +128,6 @@ ${expression || zws}\`\`\``;
624
128
  DEFAULT: "seconds"
625
129
  }
626
130
  };
627
- var DEFAULT_SEPARATORS = {
628
- left: " ",
629
- right: " "
630
- };
631
- var Cron = /* @__PURE__ */ __name(class {
632
- constructor(cron) {
633
- __publicField2(this, "cron");
634
- __publicField2(this, "normalized");
635
- __publicField2(this, "minutes");
636
- __publicField2(this, "hours");
637
- __publicField2(this, "days");
638
- __publicField2(this, "months");
639
- __publicField2(this, "dows");
640
- this.cron = cron.toLowerCase();
641
- this.normalized = Cron.normalize(this.cron);
642
- [this.minutes, this.hours, this.days, this.months, this.dows] = Cron.parseString(this.normalized);
643
- }
644
- next(outset = new Date(), origin = true) {
645
- if (!this.days.includes(outset.getUTCDate()) || !this.months.includes(outset.getUTCMonth() + 1) || !this.dows.includes(outset.getUTCDay())) {
646
- return this.next(new Date(outset.getTime() + 864e5), false);
647
- }
648
- if (!origin)
649
- return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), this.hours[0], this.minutes[0]));
650
- const now = new Date(outset.getTime() + 6e4);
651
- for (const hour of this.hours) {
652
- if (hour < now.getUTCHours())
653
- continue;
654
- for (const minute of this.minutes) {
655
- if (hour === now.getUTCHours() && minute < now.getUTCMinutes())
656
- continue;
657
- return new Date(Date.UTC(outset.getUTCFullYear(), outset.getUTCMonth(), outset.getUTCDate(), hour, minute));
658
- }
659
- }
660
- return this.next(new Date(outset.getTime() + 864e5), false);
661
- }
662
- static normalize(cron) {
663
- if (Reflect.has(predefined, cron))
664
- return Reflect.get(predefined, cron);
665
- const now = new Date();
666
- cron = cron.split(" ").map((val, i) => val.replace(wildcardRegex, (match) => {
667
- if (match === "h")
668
- return (Math.floor(Math.random() * allowedNum[i][1]) + allowedNum[i][0]).toString();
669
- if (match === "?") {
670
- switch (i) {
671
- case 0:
672
- return now.getUTCMinutes().toString();
673
- case 1:
674
- return now.getUTCHours().toString();
675
- case 2:
676
- return now.getUTCDate().toString();
677
- case 3:
678
- return now.getUTCMonth().toString();
679
- case 4:
680
- return now.getUTCDay().toString();
681
- }
682
- }
683
- return match;
684
- })).join(" ");
685
- return cron.replace(tokensRegex, (match) => String(Reflect.get(cronTokens, match)));
686
- }
687
- static parseString(cron) {
688
- const parts = cron.split(" ");
689
- if (parts.length !== 5)
690
- throw new Error("Invalid Cron Provided");
691
- return parts.map((part, i) => Cron.parsePart(part, i));
692
- }
693
- static parsePart(cronPart, id) {
694
- if (cronPart.includes(",")) {
695
- const res = [];
696
- for (const part of cronPart.split(","))
697
- res.push(...Cron.parsePart(part, id));
698
- return [...new Set(res)].sort((a, b) => a - b);
699
- }
700
- const [, wild, minStr, maxStr, step] = partRegex.exec(cronPart);
701
- let [min, max] = [parseInt(minStr, 10), parseInt(maxStr, 10)];
702
- if (wild)
703
- [min, max] = allowedNum[id];
704
- else if (!max && !step)
705
- return [min];
706
- [min, max] = [min, max || allowedNum[id][1]].sort((a, b) => a - b);
707
- return range(min, max, parseInt(step, 10) || 1);
708
- }
709
- }, "Cron");
710
- __name3(Cron, "Cron");
711
131
  var tokens2 = /* @__PURE__ */ new Map([
712
132
  ["nanosecond", 1 / 1e6],
713
133
  ["nanoseconds", 1 / 1e6],
@@ -748,7 +168,7 @@ ${expression || zws}\`\`\``;
748
168
  ["yrs", 1e3 * 60 * 60 * 24 * 365.25],
749
169
  ["y", 1e3 * 60 * 60 * 24 * 365.25]
750
170
  ]);
751
- var _Duration = /* @__PURE__ */ __name(class {
171
+ var _Duration = class {
752
172
  constructor(pattern) {
753
173
  __publicField2(this, "offset");
754
174
  this.offset = _Duration.parse(pattern.toLowerCase());
@@ -772,9 +192,8 @@ ${expression || zws}\`\`\``;
772
192
  });
773
193
  return valid ? result : NaN;
774
194
  }
775
- }, "_Duration");
195
+ };
776
196
  var Duration = _Duration;
777
- __name3(Duration, "Duration");
778
197
  __publicField2(Duration, "kPatternRegex", /(-?\d*\.?\d+(?:e[-+]?\d+)?)\s*([a-zμ]*)/gi);
779
198
  __publicField2(Duration, "kCommaRegex", /,/g);
780
199
  __publicField2(Duration, "kAanRegex", /\ban?\b/gi);
@@ -787,40 +206,7 @@ ${expression || zws}\`\`\``;
787
206
  ["minute", 1e3 * 60],
788
207
  ["second", 1e3]
789
208
  ];
790
- var DurationFormatter = /* @__PURE__ */ __name(class {
791
- constructor(units = DEFAULT_UNITS) {
792
- this.units = units;
793
- }
794
- format(duration, precision = 7, {
795
- left: leftSeparator = DEFAULT_SEPARATORS.left,
796
- right: rightSeparator = DEFAULT_SEPARATORS.right
797
- } = DEFAULT_SEPARATORS) {
798
- const output = [];
799
- const negative = duration < 0;
800
- if (negative)
801
- duration *= -1;
802
- for (const [type, timeDuration] of kTimeDurations) {
803
- const substraction = duration / timeDuration;
804
- if (substraction < 1)
805
- continue;
806
- const floored = Math.floor(substraction);
807
- duration -= floored * timeDuration;
808
- output.push(addUnit(floored, this.units[type], leftSeparator));
809
- if (output.length >= precision)
810
- break;
811
- }
812
- return `${negative ? "-" : ""}${output.join(rightSeparator) || addUnit(0, this.units.second, leftSeparator)}`;
813
- }
814
- }, "DurationFormatter");
815
- __name3(DurationFormatter, "DurationFormatter");
816
- function addUnit(time, unit, separator) {
817
- if (Reflect.has(unit, time))
818
- return `${time}${separator}${Reflect.get(unit, time)}`;
819
- return `${time}${separator}${unit.DEFAULT}`;
820
- }
821
- __name(addUnit, "addUnit");
822
- __name3(addUnit, "addUnit");
823
- var TimerManager = /* @__PURE__ */ __name(class extends null {
209
+ var TimerManager = class extends null {
824
210
  static setTimeout(fn, delay, ...args) {
825
211
  const timeout = setTimeout(() => {
826
212
  this.storedTimeouts.delete(timeout);
@@ -850,167 +236,9 @@ ${expression || zws}\`\`\``;
850
236
  this.storedTimeouts.clear();
851
237
  this.storedIntervals.clear();
852
238
  }
853
- }, "TimerManager");
854
- __name3(TimerManager, "TimerManager");
239
+ };
855
240
  __publicField2(TimerManager, "storedTimeouts", /* @__PURE__ */ new Set());
856
241
  __publicField2(TimerManager, "storedIntervals", /* @__PURE__ */ new Set());
857
- var tokenResolvers = /* @__PURE__ */ new Map([
858
- ["Y", (time) => String(time.getFullYear()).slice(2)],
859
- ["YY", (time) => String(time.getFullYear()).slice(2)],
860
- ["YYY", (time) => String(time.getFullYear())],
861
- ["YYYY", (time) => String(time.getFullYear())],
862
- ["Q", (time) => String((time.getMonth() + 1) / 3)],
863
- ["M", (time) => String(time.getMonth() + 1)],
864
- ["MM", (time) => String(time.getMonth() + 1).padStart(2, "0")],
865
- ["MMM", (time) => months[time.getMonth()]],
866
- ["MMMM", (time) => months[time.getMonth()]],
867
- ["D", (time) => String(time.getDate())],
868
- ["DD", (time) => String(time.getDate()).padStart(2, "0")],
869
- ["DDD", (time) => String(Math.floor((time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5))],
870
- ["DDDD", (time) => String(Math.floor((time.getTime() - new Date(time.getFullYear(), 0, 0).getTime()) / 864e5))],
871
- [
872
- "d",
873
- (time) => {
874
- const day = String(time.getDate());
875
- if (day !== "11" && day.endsWith("1"))
876
- return `${day}st`;
877
- if (day !== "12" && day.endsWith("2"))
878
- return `${day}nd`;
879
- if (day !== "13" && day.endsWith("3"))
880
- return `${day}rd`;
881
- return `${day}th`;
882
- }
883
- ],
884
- ["dd", (time) => days[time.getDay()].slice(0, 2)],
885
- ["ddd", (time) => days[time.getDay()].slice(0, 3)],
886
- ["dddd", (time) => days[time.getDay()]],
887
- ["X", (time) => String(time.valueOf() / 1e3)],
888
- ["x", (time) => String(time.valueOf())],
889
- ["H", (time) => String(time.getHours())],
890
- ["HH", (time) => String(time.getHours()).padStart(2, "0")],
891
- ["h", (time) => String(time.getHours() % 12 || 12)],
892
- ["hh", (time) => String(time.getHours() % 12 || 12).padStart(2, "0")],
893
- ["a", (time) => time.getHours() < 12 ? "am" : "pm"],
894
- ["A", (time) => time.getHours() < 12 ? "AM" : "PM"],
895
- ["m", (time) => String(time.getMinutes())],
896
- ["mm", (time) => String(time.getMinutes()).padStart(2, "0")],
897
- ["s", (time) => String(time.getSeconds())],
898
- ["ss", (time) => String(time.getSeconds()).padStart(2, "0")],
899
- ["S", (time) => String(time.getMilliseconds())],
900
- ["SS", (time) => String(time.getMilliseconds()).padStart(2, "0")],
901
- ["SSS", (time) => String(time.getMilliseconds()).padStart(3, "0")],
902
- ["T", (time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`],
903
- [
904
- "t",
905
- (time) => `${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")}:${String(time.getSeconds()).padStart(2, "0")} ${time.getHours() < 12 ? "am" : "pm"}`
906
- ],
907
- ["L", (time) => `${String(time.getMonth() + 1).padStart(2, "0")}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
908
- ["l", (time) => `${String(time.getMonth() + 1)}/${String(time.getDate()).padStart(2, "0")}/${String(time.getFullYear())}`],
909
- ["LL", (time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
910
- ["ll", (time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())}`],
911
- [
912
- "LLL",
913
- (time) => `${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
914
- ],
915
- [
916
- "lll",
917
- (time) => `${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
918
- ],
919
- [
920
- "LLLL",
921
- (time) => `${days[time.getDay()]}, ${months[time.getMonth()]} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
922
- ],
923
- [
924
- "llll",
925
- (time) => `${days[time.getDay()].slice(0, 3)} ${months[time.getMonth()].slice(0, 3)} ${String(time.getDate()).padStart(2, "0")}, ${String(time.getFullYear())} ${String(time.getHours() % 12 || 12)}:${String(time.getMinutes()).padStart(2, "0")} ${time.getHours() < 12 ? "AM" : "PM"}`
926
- ],
927
- [
928
- "Z",
929
- (time) => {
930
- const offset = time.getTimezoneOffset();
931
- const unsigned = offset >= 0;
932
- const absolute = Math.abs(offset);
933
- return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
934
- }
935
- ],
936
- [
937
- "ZZ",
938
- (time) => {
939
- const offset = time.getTimezoneOffset();
940
- const unsigned = offset >= 0;
941
- const absolute = Math.abs(offset);
942
- return `${unsigned ? "+" : "-"}${String(Math.floor(absolute / 60)).padStart(2, "0")}:${String(absolute % 60).padStart(2, "0")}`;
943
- }
944
- ]
945
- ]);
946
- var Timestamp = /* @__PURE__ */ __name(class {
947
- constructor(pattern) {
948
- __publicField2(this, "pattern");
949
- __publicField2(this, "template");
950
- this.pattern = pattern;
951
- this.template = Timestamp.parse(pattern);
952
- }
953
- display(time = new Date()) {
954
- return Timestamp.display(this.template, time);
955
- }
956
- displayUTC(time) {
957
- return Timestamp.display(this.template, Timestamp.utc(time));
958
- }
959
- edit(pattern) {
960
- this.pattern = pattern;
961
- this.template = Timestamp.parse(pattern);
962
- return this;
963
- }
964
- toString() {
965
- return this.display();
966
- }
967
- static displayArbitrary(pattern, time = new Date()) {
968
- return Timestamp.display(Timestamp.parse(pattern), time);
969
- }
970
- static displayUTCArbitrary(pattern, time = new Date()) {
971
- return Timestamp.display(Timestamp.parse(pattern), Timestamp.utc(time));
972
- }
973
- static utc(time = new Date()) {
974
- time = Timestamp.resolveDate(time);
975
- return new Date(time.valueOf() + time.getTimezoneOffset() * 6e4);
976
- }
977
- static display(template, time) {
978
- let output = "";
979
- const parsedTime = Timestamp.resolveDate(time);
980
- for (const { content, type } of template)
981
- output += content || tokenResolvers.get(type)(parsedTime);
982
- return output;
983
- }
984
- static parse(pattern) {
985
- const template = [];
986
- for (let i = 0; i < pattern.length; i++) {
987
- let current = "";
988
- const currentChar = pattern[i];
989
- const tokenMax = tokens.get(currentChar);
990
- if (typeof tokenMax === "number") {
991
- current += currentChar;
992
- while (pattern[i + 1] === currentChar && current.length < tokenMax)
993
- current += pattern[++i];
994
- template.push({ type: current, content: null });
995
- } else if (currentChar === "[") {
996
- while (i + 1 < pattern.length && pattern[i + 1] !== "]")
997
- current += pattern[++i];
998
- i++;
999
- template.push({ type: "literal", content: current || "[" });
1000
- } else {
1001
- current += currentChar;
1002
- while (i + 1 < pattern.length && !tokens.has(pattern[i + 1]) && pattern[i + 1] !== "[")
1003
- current += pattern[++i];
1004
- template.push({ type: "literal", content: current });
1005
- }
1006
- }
1007
- return template;
1008
- }
1009
- static resolveDate(time) {
1010
- return time instanceof Date ? time : new Date(time);
1011
- }
1012
- }, "Timestamp");
1013
- __name3(Timestamp, "Timestamp");
1014
242
 
1015
243
  // src/lib/RateLimitManager.ts
1016
244
  var _RateLimitManager = class extends Map {
@@ -1046,23 +274,7 @@ ${expression || zws}\`\`\``;
1046
274
  }
1047
275
  };
1048
276
  var RateLimitManager = _RateLimitManager;
1049
- __name(RateLimitManager, "RateLimitManager");
1050
277
  __publicField(RateLimitManager, "sweepIntervalDuration", 3e4);
1051
278
  return __toCommonJS(src_exports);
1052
279
  })();
1053
- /**
1054
- * Split a string by its latest space character in a range from the character 0 to the selected one.
1055
- * @param str The text to split.
1056
- * @param length The length of the desired string.
1057
- * @param char The character to split with
1058
- * @copyright 2019 Antonio Román
1059
- * @license Apache-2.0
1060
- */
1061
- /**
1062
- * Split a text by its latest space character in a range from the character 0 to the selected one.
1063
- * @param str The text to split.
1064
- * @param length The length of the desired string.
1065
- * @copyright 2019 Antonio Román
1066
- * @license Apache-2.0
1067
- */
1068
280
  //# sourceMappingURL=index.global.js.map