@rstest/core 0.9.4 → 0.9.6

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 (52) hide show
  1. package/LICENSE.md +54 -202
  2. package/dist/0~8843.js +32 -14
  3. package/dist/{0~lib.js → 0~@babel/code-frame.js} +2 -2
  4. package/dist/0~@clack/prompts.js +1044 -0
  5. package/dist/0~browserLoader.js +1 -1
  6. package/dist/0~browser~1.js +19 -19
  7. package/dist/0~checkThresholds.js +2 -2
  8. package/dist/0~chokidar.js +43 -42
  9. package/dist/0~console.js +1 -1
  10. package/dist/0~fake-timers.js +1586 -0
  11. package/dist/0~generate.js +5 -5
  12. package/dist/0~happyDom.js +1 -1
  13. package/dist/0~jsdom.js +1 -1
  14. package/dist/0~listTests.js +3 -3
  15. package/dist/0~loadModule.js +1 -1
  16. package/dist/0~magic-string.es.js +1 -181
  17. package/dist/0~restart.js +1 -1
  18. package/dist/0~runTests.js +11 -4
  19. package/dist/0~snapshot.js +2140 -0
  20. package/dist/0~snapshot.js.LICENSE.txt +7 -0
  21. package/dist/0~utils.js +1 -1
  22. package/dist/1255.js +11 -11
  23. package/dist/1949.js +2919 -9808
  24. package/dist/1949.js.LICENSE.txt +1 -49
  25. package/dist/3145.js +415 -40
  26. package/dist/4411.js +245 -60
  27. package/dist/6830.js +62 -10
  28. package/dist/6887.js +15 -0
  29. package/dist/7552.js +22 -4918
  30. package/dist/9743.js +1982 -0
  31. package/dist/9784.js +1343 -0
  32. package/dist/{7552.js.LICENSE.txt → 9784.js.LICENSE.txt} +19 -8
  33. package/dist/browser-runtime/2~fake-timers.js +1760 -0
  34. package/dist/browser-runtime/2~magic-string.es.js +3 -189
  35. package/dist/browser-runtime/2~snapshot.js +2138 -0
  36. package/dist/browser-runtime/2~snapshot.js.LICENSE.txt +7 -0
  37. package/dist/browser-runtime/723.js +1818 -10300
  38. package/dist/browser-runtime/723.js.LICENSE.txt +0 -17
  39. package/dist/browser-runtime/index.d.ts +205 -16
  40. package/dist/browser.d.ts +55 -10
  41. package/dist/browser.js +2 -2
  42. package/dist/globalSetupWorker.js +2 -2
  43. package/dist/index.d.ts +78 -16
  44. package/dist/index.js +1 -1
  45. package/dist/mockRuntimeCode.js +2 -0
  46. package/dist/worker.d.ts +47 -10
  47. package/dist/worker.js +12 -10
  48. package/package.json +27 -28
  49. package/dist/0~dist.js +0 -1014
  50. package/dist/4899.js +0 -11
  51. package/dist/browser-runtime/rslib-runtime.js +0 -56
  52. /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
@@ -0,0 +1,1760 @@
1
+ import { __webpack_require__ } from "./723.js";
2
+ import "./723.js";
3
+ __webpack_require__.add({
4
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_rspack_exports, __webpack_require__) {
5
+ var every = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").every;
6
+ function hasCallsLeft(callMap, spy) {
7
+ if (void 0 === callMap[spy.id]) callMap[spy.id] = 0;
8
+ return callMap[spy.id] < spy.callCount;
9
+ }
10
+ function checkAdjacentCalls(callMap, spy, index, spies) {
11
+ var calledBeforeNext = true;
12
+ if (index !== spies.length - 1) calledBeforeNext = spy.calledBefore(spies[index + 1]);
13
+ if (hasCallsLeft(callMap, spy) && calledBeforeNext) {
14
+ callMap[spy.id] += 1;
15
+ return true;
16
+ }
17
+ return false;
18
+ }
19
+ function calledInOrder(spies) {
20
+ var callMap = {};
21
+ var _spies = arguments.length > 1 ? arguments : spies;
22
+ return every(_spies, checkAdjacentCalls.bind(null, callMap));
23
+ }
24
+ module.exports = calledInOrder;
25
+ },
26
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/class-name.js" (module) {
27
+ function className(value) {
28
+ const name = value.constructor && value.constructor.name;
29
+ return name || null;
30
+ }
31
+ module.exports = className;
32
+ },
33
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/deprecated.js" (__unused_rspack_module, exports, __webpack_require__) {
34
+ var process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
35
+ exports.wrap = function(func, msg) {
36
+ var wrapped = function() {
37
+ exports.printWarning(msg);
38
+ return func.apply(this, arguments);
39
+ };
40
+ if (func.prototype) wrapped.prototype = func.prototype;
41
+ return wrapped;
42
+ };
43
+ exports.defaultMsg = function(packageName, funcName) {
44
+ return `${packageName}.${funcName} is deprecated and will be removed from the public API in a future version of ${packageName}.`;
45
+ };
46
+ exports.printWarning = function(msg) {
47
+ if ("object" == typeof process && process.emitWarning) process.emitWarning(msg);
48
+ else if (console.info) console.info(msg);
49
+ else console.log(msg);
50
+ };
51
+ },
52
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/every.js" (module) {
53
+ module.exports = function every(obj, fn) {
54
+ var pass = true;
55
+ try {
56
+ obj.forEach(function() {
57
+ if (!fn.apply(this, arguments)) throw new Error();
58
+ });
59
+ } catch (e) {
60
+ pass = false;
61
+ }
62
+ return pass;
63
+ };
64
+ },
65
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/function-name.js" (module) {
66
+ module.exports = function functionName(func) {
67
+ if (!func) return "";
68
+ try {
69
+ return func.displayName || func.name || (String(func).match(/function ([^\s(]+)/) || [])[1];
70
+ } catch (e) {
71
+ return "";
72
+ }
73
+ };
74
+ },
75
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/global.js" (module, __unused_rspack_exports, __webpack_require__) {
76
+ var globalObject;
77
+ globalObject = void 0 !== __webpack_require__.g ? __webpack_require__.g : "u" > typeof window ? window : self;
78
+ module.exports = globalObject;
79
+ },
80
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/index.js" (module, __unused_rspack_exports, __webpack_require__) {
81
+ module.exports = {
82
+ global: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/global.js"),
83
+ calledInOrder: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js"),
84
+ className: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/class-name.js"),
85
+ deprecated: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/deprecated.js"),
86
+ every: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/every.js"),
87
+ functionName: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/function-name.js"),
88
+ orderByFirstCall: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/order-by-first-call.js"),
89
+ prototypes: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/index.js"),
90
+ typeOf: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/type-of.js"),
91
+ valueToString: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/value-to-string.js")
92
+ };
93
+ },
94
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/order-by-first-call.js" (module, __unused_rspack_exports, __webpack_require__) {
95
+ var sort = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").sort;
96
+ var slice = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").slice;
97
+ function comparator(a, b) {
98
+ var aCall = a.getCall(0);
99
+ var bCall = b.getCall(0);
100
+ var aId = aCall && aCall.callId || -1;
101
+ var bId = bCall && bCall.callId || -1;
102
+ return aId < bId ? -1 : 1;
103
+ }
104
+ function orderByFirstCall(spies) {
105
+ return sort(slice(spies), comparator);
106
+ }
107
+ module.exports = orderByFirstCall;
108
+ },
109
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js" (module, __unused_rspack_exports, __webpack_require__) {
110
+ var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
111
+ module.exports = copyPrototype(Array.prototype);
112
+ },
113
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js" (module, __unused_rspack_exports, __webpack_require__) {
114
+ var call = Function.call;
115
+ var throwsOnProto = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/throws-on-proto.js");
116
+ var disallowedProperties = [
117
+ "size",
118
+ "caller",
119
+ "callee",
120
+ "arguments"
121
+ ];
122
+ if (throwsOnProto) disallowedProperties.push("__proto__");
123
+ module.exports = function copyPrototypeMethods(prototype) {
124
+ return Object.getOwnPropertyNames(prototype).reduce(function(result, name) {
125
+ if (disallowedProperties.includes(name)) return result;
126
+ if ("function" != typeof prototype[name]) return result;
127
+ result[name] = call.bind(prototype[name]);
128
+ return result;
129
+ }, Object.create(null));
130
+ };
131
+ },
132
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/function.js" (module, __unused_rspack_exports, __webpack_require__) {
133
+ var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
134
+ module.exports = copyPrototype(Function.prototype);
135
+ },
136
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/index.js" (module, __unused_rspack_exports, __webpack_require__) {
137
+ module.exports = {
138
+ array: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js"),
139
+ function: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/function.js"),
140
+ map: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/map.js"),
141
+ object: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/object.js"),
142
+ set: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/set.js"),
143
+ string: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/string.js")
144
+ };
145
+ },
146
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/map.js" (module, __unused_rspack_exports, __webpack_require__) {
147
+ var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
148
+ module.exports = copyPrototype(Map.prototype);
149
+ },
150
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/object.js" (module, __unused_rspack_exports, __webpack_require__) {
151
+ var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
152
+ module.exports = copyPrototype(Object.prototype);
153
+ },
154
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/set.js" (module, __unused_rspack_exports, __webpack_require__) {
155
+ var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
156
+ module.exports = copyPrototype(Set.prototype);
157
+ },
158
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/string.js" (module, __unused_rspack_exports, __webpack_require__) {
159
+ var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
160
+ module.exports = copyPrototype(String.prototype);
161
+ },
162
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/throws-on-proto.js" (module) {
163
+ let throwsOnProto;
164
+ try {
165
+ const object = {};
166
+ object.__proto__;
167
+ throwsOnProto = false;
168
+ } catch (_) {
169
+ throwsOnProto = true;
170
+ }
171
+ module.exports = throwsOnProto;
172
+ },
173
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/type-of.js" (module, __unused_rspack_exports, __webpack_require__) {
174
+ var type = __webpack_require__("../../node_modules/.pnpm/type-detect@4.0.8/node_modules/type-detect/type-detect.js");
175
+ module.exports = function typeOf(value) {
176
+ return type(value).toLowerCase();
177
+ };
178
+ },
179
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/value-to-string.js" (module) {
180
+ function valueToString(value) {
181
+ if (value && value.toString) return value.toString();
182
+ return String(value);
183
+ }
184
+ module.exports = valueToString;
185
+ },
186
+ "../../node_modules/.pnpm/@sinonjs+fake-timers@15.2.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js" (__unused_rspack_module, exports, __webpack_require__) {
187
+ const globalObject = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/index.js").global;
188
+ let timersModule, timersPromisesModule;
189
+ try {
190
+ timersModule = __webpack_require__("../../node_modules/.pnpm/timers-browserify@2.0.12/node_modules/timers-browserify/main.js");
191
+ } catch (e) {}
192
+ try {
193
+ timersPromisesModule = __webpack_require__(Object(function __rspack_missing_module() {
194
+ var e = new Error("Cannot find module 'timers/promises'");
195
+ e.code = 'MODULE_NOT_FOUND';
196
+ throw e;
197
+ }()));
198
+ } catch (e) {}
199
+ function withGlobal(_global) {
200
+ const maxTimeout = Math.pow(2, 31) - 1;
201
+ const idCounterStart = 1e12;
202
+ const NOOP = function() {};
203
+ const NOOP_ARRAY = function() {
204
+ return [];
205
+ };
206
+ const isPresent = {};
207
+ let timeoutResult, addTimerReturnsObject = false;
208
+ if (_global.setTimeout) {
209
+ isPresent.setTimeout = true;
210
+ timeoutResult = _global.setTimeout(NOOP, 0);
211
+ addTimerReturnsObject = "object" == typeof timeoutResult;
212
+ }
213
+ isPresent.clearTimeout = Boolean(_global.clearTimeout);
214
+ isPresent.setInterval = Boolean(_global.setInterval);
215
+ isPresent.clearInterval = Boolean(_global.clearInterval);
216
+ isPresent.hrtime = _global.process && "function" == typeof _global.process.hrtime;
217
+ isPresent.hrtimeBigint = isPresent.hrtime && "function" == typeof _global.process.hrtime.bigint;
218
+ isPresent.nextTick = _global.process && "function" == typeof _global.process.nextTick;
219
+ const utilPromisify = _global.process && __webpack_require__("../../node_modules/.pnpm/util@0.12.5/node_modules/util/util.js").promisify;
220
+ isPresent.performance = _global.performance && "function" == typeof _global.performance.now;
221
+ const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
222
+ const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
223
+ isPresent.queueMicrotask = Object.prototype.hasOwnProperty.call(_global, "queueMicrotask");
224
+ isPresent.requestAnimationFrame = _global.requestAnimationFrame && "function" == typeof _global.requestAnimationFrame;
225
+ isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && "function" == typeof _global.cancelAnimationFrame;
226
+ isPresent.requestIdleCallback = _global.requestIdleCallback && "function" == typeof _global.requestIdleCallback;
227
+ isPresent.cancelIdleCallback = _global.cancelIdleCallback && "function" == typeof _global.cancelIdleCallback;
228
+ isPresent.setImmediate = _global.setImmediate && "function" == typeof _global.setImmediate;
229
+ isPresent.clearImmediate = _global.clearImmediate && "function" == typeof _global.clearImmediate;
230
+ isPresent.Intl = _global.Intl && "object" == typeof _global.Intl;
231
+ if (_global.clearTimeout) _global.clearTimeout(timeoutResult);
232
+ const NativeDate = _global.Date;
233
+ const NativeIntl = isPresent.Intl ? Object.defineProperties(Object.create(null), Object.getOwnPropertyDescriptors(_global.Intl)) : void 0;
234
+ let uniqueTimerId = idCounterStart;
235
+ let uniqueTimerOrder = 0;
236
+ if (void 0 === NativeDate) throw new Error("The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)");
237
+ isPresent.Date = true;
238
+ class FakePerformanceEntry {
239
+ constructor(name, entryType, startTime, duration){
240
+ this.name = name;
241
+ this.entryType = entryType;
242
+ this.startTime = startTime;
243
+ this.duration = duration;
244
+ }
245
+ toJSON() {
246
+ return JSON.stringify({
247
+ ...this
248
+ });
249
+ }
250
+ }
251
+ function isNumberFinite(num) {
252
+ if (Number.isFinite) return Number.isFinite(num);
253
+ return isFinite(num);
254
+ }
255
+ let isNearInfiniteLimit = false;
256
+ function checkIsNearInfiniteLimit(clock, i) {
257
+ if (clock.loopLimit && i === clock.loopLimit - 1) isNearInfiniteLimit = true;
258
+ }
259
+ function resetIsNearInfiniteLimit() {
260
+ isNearInfiniteLimit = false;
261
+ }
262
+ function parseTime(str) {
263
+ if (!str) return 0;
264
+ const strings = str.split(":");
265
+ const l = strings.length;
266
+ let i = l;
267
+ let ms = 0;
268
+ let parsed;
269
+ if (l > 3 || !/^(\d\d:){0,2}\d\d?$/.test(str)) throw new Error("tick only understands numbers, 'm:s' and 'h:m:s'. Each part must be two digits");
270
+ while(i--){
271
+ parsed = parseInt(strings[i], 10);
272
+ if (parsed >= 60) throw new Error(`Invalid time ${str}`);
273
+ ms += parsed * Math.pow(60, l - i - 1);
274
+ }
275
+ return 1000 * ms;
276
+ }
277
+ function nanoRemainder(msFloat) {
278
+ const modulo = 1e6;
279
+ const remainder = 1e6 * msFloat % modulo;
280
+ const positiveRemainder = remainder < 0 ? remainder + modulo : remainder;
281
+ return Math.floor(positiveRemainder);
282
+ }
283
+ function getEpoch(epoch) {
284
+ if (!epoch) return 0;
285
+ if ("function" == typeof epoch.getTime) return epoch.getTime();
286
+ if ("number" == typeof epoch) return epoch;
287
+ throw new TypeError("now should be milliseconds since UNIX epoch");
288
+ }
289
+ function inRange(from, to, timer) {
290
+ return timer && timer.callAt >= from && timer.callAt <= to;
291
+ }
292
+ function getInfiniteLoopError(clock, job) {
293
+ const infiniteLoopError = new Error(`Aborting after running ${clock.loopLimit} timers, assuming an infinite loop!`);
294
+ if (!job.error) return infiniteLoopError;
295
+ const computedTargetPattern = /target\.*[<|(|[].*?[>|\]|)]\s*/;
296
+ let clockMethodPattern = new RegExp(String(Object.keys(clock).join("|")));
297
+ if (addTimerReturnsObject) clockMethodPattern = new RegExp(`\\s+at (Object\\.)?(?:${Object.keys(clock).join("|")})\\s+`);
298
+ let matchedLineIndex = -1;
299
+ job.error.stack.split("\n").some(function(line, i) {
300
+ const matchedComputedTarget = line.match(computedTargetPattern);
301
+ if (matchedComputedTarget) {
302
+ matchedLineIndex = i;
303
+ return true;
304
+ }
305
+ const matchedClockMethod = line.match(clockMethodPattern);
306
+ if (matchedClockMethod) {
307
+ matchedLineIndex = i;
308
+ return false;
309
+ }
310
+ return matchedLineIndex >= 0;
311
+ });
312
+ const stack = `${infiniteLoopError}\n${job.type || "Microtask"} - ${job.func.name || "anonymous"}\n${job.error.stack.split("\n").slice(matchedLineIndex + 1).join("\n")}`;
313
+ try {
314
+ Object.defineProperty(infiniteLoopError, "stack", {
315
+ value: stack
316
+ });
317
+ } catch (e) {}
318
+ return infiniteLoopError;
319
+ }
320
+ function createDate() {
321
+ class ClockDate extends NativeDate {
322
+ constructor(year, month, date, hour, minute, second, ms){
323
+ if (0 === arguments.length) super(ClockDate.clock.now);
324
+ else super(...arguments);
325
+ Object.defineProperty(this, "constructor", {
326
+ value: NativeDate,
327
+ enumerable: false
328
+ });
329
+ }
330
+ static [Symbol.hasInstance](instance) {
331
+ return instance instanceof NativeDate;
332
+ }
333
+ }
334
+ ClockDate.isFake = true;
335
+ if (NativeDate.now) ClockDate.now = function now() {
336
+ return ClockDate.clock.now;
337
+ };
338
+ if (NativeDate.toSource) ClockDate.toSource = function toSource() {
339
+ return NativeDate.toSource();
340
+ };
341
+ ClockDate.toString = function toString() {
342
+ return NativeDate.toString();
343
+ };
344
+ const ClockDateProxy = new Proxy(ClockDate, {
345
+ apply () {
346
+ if (this instanceof ClockDate) throw new TypeError("A Proxy should only capture `new` calls with the `construct` handler. This is not supposed to be possible, so check the logic.");
347
+ return new NativeDate(ClockDate.clock.now).toString();
348
+ }
349
+ });
350
+ return ClockDateProxy;
351
+ }
352
+ function createIntl() {
353
+ const ClockIntl = {};
354
+ Object.getOwnPropertyNames(NativeIntl).forEach((property)=>ClockIntl[property] = NativeIntl[property]);
355
+ ClockIntl.DateTimeFormat = function(...args) {
356
+ const realFormatter = new NativeIntl.DateTimeFormat(...args);
357
+ const formatter = {};
358
+ [
359
+ "formatRange",
360
+ "formatRangeToParts",
361
+ "resolvedOptions"
362
+ ].forEach((method)=>{
363
+ formatter[method] = realFormatter[method].bind(realFormatter);
364
+ });
365
+ [
366
+ "format",
367
+ "formatToParts"
368
+ ].forEach((method)=>{
369
+ formatter[method] = function(date) {
370
+ return realFormatter[method](date || ClockIntl.clock.now);
371
+ };
372
+ });
373
+ return formatter;
374
+ };
375
+ ClockIntl.DateTimeFormat.prototype = Object.create(NativeIntl.DateTimeFormat.prototype);
376
+ ClockIntl.DateTimeFormat.supportedLocalesOf = NativeIntl.DateTimeFormat.supportedLocalesOf;
377
+ return ClockIntl;
378
+ }
379
+ function enqueueJob(clock, job) {
380
+ if (!clock.jobs) clock.jobs = [];
381
+ clock.jobs.push(job);
382
+ }
383
+ function runJobs(clock) {
384
+ if (!clock.jobs) return;
385
+ for(let i = 0; i < clock.jobs.length; i++){
386
+ const job = clock.jobs[i];
387
+ job.func.apply(null, job.args);
388
+ checkIsNearInfiniteLimit(clock, i);
389
+ if (clock.loopLimit && i > clock.loopLimit) throw getInfiniteLoopError(clock, job);
390
+ }
391
+ resetIsNearInfiniteLimit();
392
+ clock.jobs = [];
393
+ }
394
+ function addTimer(clock, timer) {
395
+ if (void 0 === timer.func) throw new Error("Callback must be provided to timer calls");
396
+ if ("function" != typeof timer.func) throw new TypeError(`[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`);
397
+ if (isNearInfiniteLimit) timer.error = new Error();
398
+ timer.type = timer.immediate ? "Immediate" : "Timeout";
399
+ if (Object.prototype.hasOwnProperty.call(timer, "delay")) {
400
+ if ("number" != typeof timer.delay) timer.delay = parseInt(timer.delay, 10);
401
+ if (!isNumberFinite(timer.delay)) timer.delay = 0;
402
+ timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
403
+ timer.delay = Math.max(0, timer.delay);
404
+ }
405
+ if (Object.prototype.hasOwnProperty.call(timer, "interval")) {
406
+ timer.type = "Interval";
407
+ timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
408
+ }
409
+ if (Object.prototype.hasOwnProperty.call(timer, "animation")) {
410
+ timer.type = "AnimationFrame";
411
+ timer.animation = true;
412
+ }
413
+ if (Object.prototype.hasOwnProperty.call(timer, "requestIdleCallback")) {
414
+ if (!timer.delay) timer.type = "IdleCallback";
415
+ timer.requestIdleCallback = true;
416
+ }
417
+ if (!clock.timers) {
418
+ clock.timers = {};
419
+ clock.timerHeap = new TimerHeap();
420
+ }
421
+ while(clock.timers && clock.timers[uniqueTimerId]){
422
+ uniqueTimerId++;
423
+ if (uniqueTimerId >= Number.MAX_SAFE_INTEGER) uniqueTimerId = idCounterStart;
424
+ }
425
+ timer.id = uniqueTimerId++;
426
+ if (uniqueTimerId >= Number.MAX_SAFE_INTEGER) uniqueTimerId = idCounterStart;
427
+ timer.order = uniqueTimerOrder++;
428
+ timer.createdAt = clock.now;
429
+ timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
430
+ clock.timers[timer.id] = timer;
431
+ clock.timerHeap.push(timer);
432
+ if (addTimerReturnsObject) {
433
+ const res = {
434
+ refed: true,
435
+ ref: function() {
436
+ this.refed = true;
437
+ return this;
438
+ },
439
+ unref: function() {
440
+ this.refed = false;
441
+ return this;
442
+ },
443
+ hasRef: function() {
444
+ return this.refed;
445
+ },
446
+ refresh: function() {
447
+ timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
448
+ clock.timerHeap.remove(timer);
449
+ timer.order = uniqueTimerOrder++;
450
+ clock.timers[timer.id] = timer;
451
+ clock.timerHeap.push(timer);
452
+ return this;
453
+ },
454
+ [Symbol.toPrimitive]: function() {
455
+ return timer.id;
456
+ }
457
+ };
458
+ return res;
459
+ }
460
+ return timer.id;
461
+ }
462
+ function compareTimers(a, b) {
463
+ if ("IdleCallback" === a.type && "IdleCallback" !== b.type) return 1;
464
+ if ("IdleCallback" !== a.type && "IdleCallback" === b.type) return -1;
465
+ if (a.callAt < b.callAt) return -1;
466
+ if (a.callAt > b.callAt) return 1;
467
+ if (a.immediate && !b.immediate) return -1;
468
+ if (!a.immediate && b.immediate) return 1;
469
+ if (a.order < b.order) return -1;
470
+ if (a.order > b.order) return 1;
471
+ if (a.createdAt < b.createdAt) return -1;
472
+ if (a.createdAt > b.createdAt) return 1;
473
+ if (a.id < b.id) return -1;
474
+ if (a.id > b.id) return 1;
475
+ return 0;
476
+ }
477
+ function TimerHeap() {
478
+ this.timers = [];
479
+ }
480
+ TimerHeap.prototype.peek = function() {
481
+ return this.timers[0];
482
+ };
483
+ TimerHeap.prototype.push = function(timer) {
484
+ this.timers.push(timer);
485
+ this.bubbleUp(this.timers.length - 1);
486
+ };
487
+ TimerHeap.prototype.pop = function() {
488
+ if (0 === this.timers.length) return;
489
+ const first = this.timers[0];
490
+ const last = this.timers.pop();
491
+ if (this.timers.length > 0) {
492
+ this.timers[0] = last;
493
+ last.heapIndex = 0;
494
+ this.bubbleDown(0);
495
+ }
496
+ delete first.heapIndex;
497
+ return first;
498
+ };
499
+ TimerHeap.prototype.remove = function(timer) {
500
+ const index = timer.heapIndex;
501
+ if (void 0 === index || this.timers[index] !== timer) return false;
502
+ const last = this.timers.pop();
503
+ if (timer !== last) {
504
+ this.timers[index] = last;
505
+ last.heapIndex = index;
506
+ if (compareTimers(last, timer) < 0) this.bubbleUp(index);
507
+ else this.bubbleDown(index);
508
+ }
509
+ delete timer.heapIndex;
510
+ return true;
511
+ };
512
+ TimerHeap.prototype.bubbleUp = function(index) {
513
+ const timer = this.timers[index];
514
+ let currentIndex = index;
515
+ while(currentIndex > 0){
516
+ const parentIndex = Math.floor((currentIndex - 1) / 2);
517
+ const parent = this.timers[parentIndex];
518
+ if (compareTimers(timer, parent) < 0) {
519
+ this.timers[currentIndex] = parent;
520
+ parent.heapIndex = currentIndex;
521
+ currentIndex = parentIndex;
522
+ } else break;
523
+ }
524
+ this.timers[currentIndex] = timer;
525
+ timer.heapIndex = currentIndex;
526
+ };
527
+ TimerHeap.prototype.bubbleDown = function(index) {
528
+ const timer = this.timers[index];
529
+ let currentIndex = index;
530
+ const halfLength = Math.floor(this.timers.length / 2);
531
+ while(currentIndex < halfLength){
532
+ const leftIndex = 2 * currentIndex + 1;
533
+ const rightIndex = leftIndex + 1;
534
+ let bestChildIndex = leftIndex;
535
+ let bestChild = this.timers[leftIndex];
536
+ if (rightIndex < this.timers.length && compareTimers(this.timers[rightIndex], bestChild) < 0) {
537
+ bestChildIndex = rightIndex;
538
+ bestChild = this.timers[rightIndex];
539
+ }
540
+ if (compareTimers(bestChild, timer) < 0) {
541
+ this.timers[currentIndex] = bestChild;
542
+ bestChild.heapIndex = currentIndex;
543
+ currentIndex = bestChildIndex;
544
+ } else break;
545
+ }
546
+ this.timers[currentIndex] = timer;
547
+ timer.heapIndex = currentIndex;
548
+ };
549
+ function firstTimerInRange(clock, from, to) {
550
+ if (!clock.timerHeap) return null;
551
+ const timers = clock.timerHeap.timers;
552
+ if (1 === timers.length && timers[0].requestIdleCallback) return timers[0];
553
+ const first = clock.timerHeap.peek();
554
+ if (first && inRange(from, to, first)) return first;
555
+ let timer = null;
556
+ for(let i = 0; i < timers.length; i++)if (inRange(from, to, timers[i]) && (!timer || 1 === compareTimers(timer, timers[i]))) timer = timers[i];
557
+ return timer;
558
+ }
559
+ function firstTimer(clock) {
560
+ if (!clock.timerHeap) return null;
561
+ return clock.timerHeap.peek() || null;
562
+ }
563
+ function lastTimer(clock) {
564
+ if (!clock.timerHeap) return null;
565
+ const timers = clock.timerHeap.timers;
566
+ let timer = null;
567
+ for(let i = 0; i < timers.length; i++)if (!timer || -1 === compareTimers(timer, timers[i])) timer = timers[i];
568
+ return timer;
569
+ }
570
+ function callTimer(clock, timer) {
571
+ if ("number" == typeof timer.interval) {
572
+ clock.timerHeap.remove(timer);
573
+ timer.callAt += timer.interval;
574
+ timer.order = uniqueTimerOrder++;
575
+ clock.timerHeap.push(timer);
576
+ } else {
577
+ delete clock.timers[timer.id];
578
+ clock.timerHeap.remove(timer);
579
+ }
580
+ if ("function" == typeof timer.func) timer.func.apply(null, timer.args);
581
+ }
582
+ function getClearHandler(ttype) {
583
+ if ("IdleCallback" === ttype || "AnimationFrame" === ttype) return `cancel${ttype}`;
584
+ return `clear${ttype}`;
585
+ }
586
+ function getScheduleHandler(ttype) {
587
+ if ("IdleCallback" === ttype || "AnimationFrame" === ttype) return `request${ttype}`;
588
+ return `set${ttype}`;
589
+ }
590
+ function createWarnOnce() {
591
+ let calls = 0;
592
+ return function(msg) {
593
+ calls++ || console.warn(msg);
594
+ };
595
+ }
596
+ const warnOnce = createWarnOnce();
597
+ function clearTimer(clock, timerId, ttype) {
598
+ if (!timerId) return;
599
+ if (!clock.timers) clock.timers = {};
600
+ const id = Number(timerId);
601
+ if (Number.isNaN(id) || id < idCounterStart) {
602
+ const handlerName = getClearHandler(ttype);
603
+ if (true === clock.shouldClearNativeTimers) {
604
+ const nativeHandler = clock[`_${handlerName}`];
605
+ return "function" == typeof nativeHandler ? nativeHandler(timerId) : void 0;
606
+ }
607
+ const stackTrace = new Error().stack.split("\n").slice(1).join("\n");
608
+ warnOnce(`FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.\nTo automatically clean-up native timers, use \`shouldClearNativeTimers\`.\n${stackTrace}`);
609
+ }
610
+ if (Object.prototype.hasOwnProperty.call(clock.timers, id)) {
611
+ const timer = clock.timers[id];
612
+ if (timer.type === ttype || "Timeout" === timer.type && "Interval" === ttype || "Interval" === timer.type && "Timeout" === ttype) {
613
+ delete clock.timers[id];
614
+ clock.timerHeap.remove(timer);
615
+ } else {
616
+ const clear = getClearHandler(ttype);
617
+ const schedule = getScheduleHandler(timer.type);
618
+ throw new Error(`Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`);
619
+ }
620
+ }
621
+ }
622
+ function uninstall(clock) {
623
+ let method, i, l;
624
+ const installedHrTime = "_hrtime";
625
+ const installedNextTick = "_nextTick";
626
+ for(i = 0, l = clock.methods.length; i < l; i++){
627
+ method = clock.methods[i];
628
+ if ("hrtime" === method && _global.process) _global.process.hrtime = clock[installedHrTime];
629
+ else if ("nextTick" === method && _global.process) _global.process.nextTick = clock[installedNextTick];
630
+ else if ("performance" === method) {
631
+ const originalPerfDescriptor = Object.getOwnPropertyDescriptor(clock, `_${method}`);
632
+ if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) Object.defineProperty(_global, method, originalPerfDescriptor);
633
+ else if (originalPerfDescriptor.configurable) _global[method] = clock[`_${method}`];
634
+ } else if (clock[method] && clock[method].hasOwnProperty) _global[method] = clock[`_${method}`];
635
+ else try {
636
+ delete _global[method];
637
+ } catch (ignore) {}
638
+ if (void 0 !== clock.timersModuleMethods) for(let j = 0; j < clock.timersModuleMethods.length; j++){
639
+ const entry = clock.timersModuleMethods[j];
640
+ timersModule[entry.methodName] = entry.original;
641
+ }
642
+ if (void 0 !== clock.timersPromisesModuleMethods) for(let j = 0; j < clock.timersPromisesModuleMethods.length; j++){
643
+ const entry = clock.timersPromisesModuleMethods[j];
644
+ timersPromisesModule[entry.methodName] = entry.original;
645
+ }
646
+ }
647
+ clock.setTickMode("manual");
648
+ clock.methods = [];
649
+ for (const [listener, signal] of clock.abortListenerMap.entries()){
650
+ signal.removeEventListener("abort", listener);
651
+ clock.abortListenerMap.delete(listener);
652
+ }
653
+ if (!clock.timerHeap) return [];
654
+ return clock.timerHeap.timers.slice();
655
+ }
656
+ function hijackMethod(target, method, clock) {
657
+ clock[method].hasOwnProperty = Object.prototype.hasOwnProperty.call(target, method);
658
+ clock[`_${method}`] = target[method];
659
+ if ("Date" === method) target[method] = clock[method];
660
+ else if ("Intl" === method) target[method] = clock[method];
661
+ else if ("performance" === method) {
662
+ const originalPerfDescriptor = Object.getOwnPropertyDescriptor(target, method);
663
+ if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) {
664
+ Object.defineProperty(clock, `_${method}`, originalPerfDescriptor);
665
+ const perfDescriptor = Object.getOwnPropertyDescriptor(clock, method);
666
+ Object.defineProperty(target, method, perfDescriptor);
667
+ } else target[method] = clock[method];
668
+ } else {
669
+ target[method] = function() {
670
+ return clock[method].apply(clock, arguments);
671
+ };
672
+ Object.defineProperties(target[method], Object.getOwnPropertyDescriptors(clock[method]));
673
+ }
674
+ target[method].clock = clock;
675
+ }
676
+ function doIntervalTick(clock, advanceTimeDelta) {
677
+ clock.tick(advanceTimeDelta);
678
+ }
679
+ const timers = {
680
+ setTimeout: _global.setTimeout,
681
+ clearTimeout: _global.clearTimeout,
682
+ setInterval: _global.setInterval,
683
+ clearInterval: _global.clearInterval,
684
+ Date: _global.Date
685
+ };
686
+ if (isPresent.setImmediate) timers.setImmediate = _global.setImmediate;
687
+ if (isPresent.clearImmediate) timers.clearImmediate = _global.clearImmediate;
688
+ if (isPresent.hrtime) timers.hrtime = _global.process.hrtime;
689
+ if (isPresent.nextTick) timers.nextTick = _global.process.nextTick;
690
+ if (isPresent.performance) timers.performance = _global.performance;
691
+ if (isPresent.requestAnimationFrame) timers.requestAnimationFrame = _global.requestAnimationFrame;
692
+ if (isPresent.queueMicrotask) timers.queueMicrotask = _global.queueMicrotask;
693
+ if (isPresent.cancelAnimationFrame) timers.cancelAnimationFrame = _global.cancelAnimationFrame;
694
+ if (isPresent.requestIdleCallback) timers.requestIdleCallback = _global.requestIdleCallback;
695
+ if (isPresent.cancelIdleCallback) timers.cancelIdleCallback = _global.cancelIdleCallback;
696
+ if (isPresent.Intl) timers.Intl = NativeIntl;
697
+ const originalSetTimeout = _global.setImmediate || _global.setTimeout;
698
+ const originalClearInterval = _global.clearInterval;
699
+ const originalSetInterval = _global.setInterval;
700
+ function createClock(start, loopLimit) {
701
+ start = Math.floor(getEpoch(start));
702
+ loopLimit = loopLimit || 1000;
703
+ let nanos = 0;
704
+ const adjustedSystemTime = [
705
+ 0,
706
+ 0
707
+ ];
708
+ const clock = {
709
+ now: start,
710
+ Date: createDate(),
711
+ loopLimit: loopLimit,
712
+ tickMode: {
713
+ mode: "manual",
714
+ counter: 0,
715
+ delta: void 0
716
+ }
717
+ };
718
+ clock.Date.clock = clock;
719
+ function getTimeToNextFrame() {
720
+ return 16 - (clock.now - start) % 16;
721
+ }
722
+ function hrtime(prev) {
723
+ const millisSinceStart = clock.now - adjustedSystemTime[0] - start;
724
+ const secsSinceStart = Math.floor(millisSinceStart / 1000);
725
+ const remainderInNanos = (millisSinceStart - 1e3 * secsSinceStart) * 1e6 + nanos - adjustedSystemTime[1];
726
+ if (Array.isArray(prev)) {
727
+ if (prev[1] > 1e9) throw new TypeError("Number of nanoseconds can't exceed a billion");
728
+ const oldSecs = prev[0];
729
+ let nanoDiff = remainderInNanos - prev[1];
730
+ let secDiff = secsSinceStart - oldSecs;
731
+ if (nanoDiff < 0) {
732
+ nanoDiff += 1e9;
733
+ secDiff -= 1;
734
+ }
735
+ return [
736
+ secDiff,
737
+ nanoDiff
738
+ ];
739
+ }
740
+ return [
741
+ secsSinceStart,
742
+ remainderInNanos
743
+ ];
744
+ }
745
+ function fakePerformanceNow() {
746
+ const hrt = hrtime();
747
+ const millis = 1000 * hrt[0] + hrt[1] / 1e6;
748
+ return millis;
749
+ }
750
+ if (isPresent.hrtimeBigint) hrtime.bigint = function() {
751
+ const parts = hrtime();
752
+ return BigInt(parts[0]) * BigInt(1e9) + BigInt(parts[1]);
753
+ };
754
+ if (isPresent.Intl) {
755
+ clock.Intl = createIntl();
756
+ clock.Intl.clock = clock;
757
+ }
758
+ clock.setTickMode = function(tickModeConfig) {
759
+ const { mode: newMode, delta: newDelta } = tickModeConfig;
760
+ const { mode: oldMode, delta: oldDelta } = clock.tickMode;
761
+ if (newMode === oldMode && newDelta === oldDelta) return;
762
+ if ("interval" === oldMode) originalClearInterval(clock.attachedInterval);
763
+ clock.tickMode = {
764
+ counter: clock.tickMode.counter + 1,
765
+ mode: newMode,
766
+ delta: newDelta
767
+ };
768
+ if ("nextAsync" === newMode) advanceUntilModeChanges();
769
+ else if ("interval" === newMode) createIntervalTick(clock, newDelta || 20);
770
+ };
771
+ async function advanceUntilModeChanges() {
772
+ async function newMacrotask() {
773
+ const channel = new MessageChannel();
774
+ await new Promise((resolve)=>{
775
+ channel.port1.onmessage = ()=>{
776
+ resolve();
777
+ channel.port1.close();
778
+ };
779
+ channel.port2.postMessage(void 0);
780
+ });
781
+ channel.port1.close();
782
+ channel.port2.close();
783
+ await new Promise((resolve)=>{
784
+ originalSetTimeout(resolve);
785
+ });
786
+ }
787
+ const { counter } = clock.tickMode;
788
+ while(clock.tickMode.counter === counter){
789
+ await newMacrotask();
790
+ if (clock.tickMode.counter !== counter) return;
791
+ clock.next();
792
+ }
793
+ }
794
+ function pauseAutoTickUntilFinished(promise) {
795
+ if ("nextAsync" !== clock.tickMode.mode) return promise;
796
+ clock.setTickMode({
797
+ mode: "manual"
798
+ });
799
+ return promise.finally(()=>{
800
+ clock.setTickMode({
801
+ mode: "nextAsync"
802
+ });
803
+ });
804
+ }
805
+ function getTimeToNextIdlePeriod() {
806
+ let timeToNextIdlePeriod = 0;
807
+ if (clock.countTimers() > 0) timeToNextIdlePeriod = 50;
808
+ return timeToNextIdlePeriod;
809
+ }
810
+ clock.requestIdleCallback = function requestIdleCallback(func, { timeout } = {}) {
811
+ const idleDeadline = {
812
+ didTimeout: true,
813
+ timeRemaining: getTimeToNextIdlePeriod
814
+ };
815
+ const result = addTimer(clock, {
816
+ func: func,
817
+ args: [
818
+ idleDeadline
819
+ ],
820
+ delay: timeout,
821
+ requestIdleCallback: true
822
+ });
823
+ return Number(result);
824
+ };
825
+ clock.cancelIdleCallback = function cancelIdleCallback(timerId) {
826
+ return clearTimer(clock, timerId, "IdleCallback");
827
+ };
828
+ clock.setTimeout = function setTimeout1(func, timeout) {
829
+ return addTimer(clock, {
830
+ func: func,
831
+ args: Array.prototype.slice.call(arguments, 2),
832
+ delay: timeout
833
+ });
834
+ };
835
+ if (void 0 !== _global.Promise && utilPromisify) clock.setTimeout[utilPromisify.custom] = function promisifiedSetTimeout(timeout, arg) {
836
+ return new _global.Promise(function setTimeoutExecutor(resolve) {
837
+ addTimer(clock, {
838
+ func: resolve,
839
+ args: [
840
+ arg
841
+ ],
842
+ delay: timeout
843
+ });
844
+ });
845
+ };
846
+ clock.clearTimeout = function clearTimeout1(timerId) {
847
+ return clearTimer(clock, timerId, "Timeout");
848
+ };
849
+ clock.nextTick = function nextTick(func) {
850
+ return enqueueJob(clock, {
851
+ func: func,
852
+ args: Array.prototype.slice.call(arguments, 1),
853
+ error: isNearInfiniteLimit ? new Error() : null
854
+ });
855
+ };
856
+ clock.queueMicrotask = function queueMicrotask(func) {
857
+ return clock.nextTick(func);
858
+ };
859
+ clock.setInterval = function setInterval1(func, timeout) {
860
+ timeout = parseInt(timeout, 10);
861
+ return addTimer(clock, {
862
+ func: func,
863
+ args: Array.prototype.slice.call(arguments, 2),
864
+ delay: timeout,
865
+ interval: timeout
866
+ });
867
+ };
868
+ clock.clearInterval = function clearInterval1(timerId) {
869
+ return clearTimer(clock, timerId, "Interval");
870
+ };
871
+ if (isPresent.setImmediate) {
872
+ clock.setImmediate = function setImmediate(func) {
873
+ return addTimer(clock, {
874
+ func: func,
875
+ args: Array.prototype.slice.call(arguments, 1),
876
+ immediate: true
877
+ });
878
+ };
879
+ if (void 0 !== _global.Promise && utilPromisify) clock.setImmediate[utilPromisify.custom] = function promisifiedSetImmediate(arg) {
880
+ return new _global.Promise(function setImmediateExecutor(resolve) {
881
+ addTimer(clock, {
882
+ func: resolve,
883
+ args: [
884
+ arg
885
+ ],
886
+ immediate: true
887
+ });
888
+ });
889
+ };
890
+ clock.clearImmediate = function clearImmediate(timerId) {
891
+ return clearTimer(clock, timerId, "Immediate");
892
+ };
893
+ }
894
+ clock.countTimers = function countTimers() {
895
+ return (clock.timerHeap ? clock.timerHeap.timers.length : 0) + (clock.jobs || []).length;
896
+ };
897
+ clock.requestAnimationFrame = function requestAnimationFrame(func) {
898
+ const result = addTimer(clock, {
899
+ func: func,
900
+ delay: getTimeToNextFrame(),
901
+ get args () {
902
+ return [
903
+ fakePerformanceNow()
904
+ ];
905
+ },
906
+ animation: true
907
+ });
908
+ return Number(result);
909
+ };
910
+ clock.cancelAnimationFrame = function cancelAnimationFrame(timerId) {
911
+ return clearTimer(clock, timerId, "AnimationFrame");
912
+ };
913
+ clock.runMicrotasks = function runMicrotasks() {
914
+ runJobs(clock);
915
+ };
916
+ function doTick(tickValue, isAsync, resolve, reject) {
917
+ const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
918
+ const ms = Math.floor(msFloat);
919
+ const remainder = nanoRemainder(msFloat);
920
+ let nanosTotal = nanos + remainder;
921
+ let tickTo = clock.now + ms;
922
+ if (msFloat < 0) throw new TypeError("Negative ticks are not supported");
923
+ if (nanosTotal >= 1e6) {
924
+ tickTo += 1;
925
+ nanosTotal -= 1e6;
926
+ }
927
+ nanos = nanosTotal;
928
+ let tickFrom = clock.now;
929
+ let previous = clock.now;
930
+ let timer, firstException, oldNow, nextPromiseTick, compensationCheck, postTimerCall;
931
+ clock.duringTick = true;
932
+ oldNow = clock.now;
933
+ runJobs(clock);
934
+ if (oldNow !== clock.now) {
935
+ tickFrom += clock.now - oldNow;
936
+ tickTo += clock.now - oldNow;
937
+ }
938
+ function doTickInner() {
939
+ timer = firstTimerInRange(clock, tickFrom, tickTo);
940
+ while(timer && tickFrom <= tickTo){
941
+ if (clock.timers[timer.id]) {
942
+ tickFrom = timer.callAt;
943
+ clock.now = timer.callAt;
944
+ oldNow = clock.now;
945
+ try {
946
+ runJobs(clock);
947
+ callTimer(clock, timer);
948
+ } catch (e) {
949
+ firstException = firstException || e;
950
+ }
951
+ if (isAsync) return void originalSetTimeout(nextPromiseTick);
952
+ compensationCheck();
953
+ }
954
+ postTimerCall();
955
+ }
956
+ oldNow = clock.now;
957
+ runJobs(clock);
958
+ if (oldNow !== clock.now) {
959
+ tickFrom += clock.now - oldNow;
960
+ tickTo += clock.now - oldNow;
961
+ }
962
+ clock.duringTick = false;
963
+ timer = firstTimerInRange(clock, tickFrom, tickTo);
964
+ if (timer) try {
965
+ clock.tick(tickTo - clock.now);
966
+ } catch (e) {
967
+ firstException = firstException || e;
968
+ }
969
+ else {
970
+ clock.now = tickTo;
971
+ nanos = nanosTotal;
972
+ }
973
+ if (firstException) throw firstException;
974
+ if (!isAsync) return clock.now;
975
+ resolve(clock.now);
976
+ }
977
+ nextPromiseTick = isAsync && function() {
978
+ try {
979
+ compensationCheck();
980
+ postTimerCall();
981
+ doTickInner();
982
+ } catch (e) {
983
+ reject(e);
984
+ }
985
+ };
986
+ compensationCheck = function() {
987
+ if (oldNow !== clock.now) {
988
+ tickFrom += clock.now - oldNow;
989
+ tickTo += clock.now - oldNow;
990
+ previous += clock.now - oldNow;
991
+ }
992
+ };
993
+ postTimerCall = function() {
994
+ timer = firstTimerInRange(clock, previous, tickTo);
995
+ previous = tickFrom;
996
+ };
997
+ return doTickInner();
998
+ }
999
+ clock.tick = function tick(tickValue) {
1000
+ return doTick(tickValue, false);
1001
+ };
1002
+ if (void 0 !== _global.Promise) clock.tickAsync = function tickAsync(tickValue) {
1003
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
1004
+ originalSetTimeout(function() {
1005
+ try {
1006
+ doTick(tickValue, true, resolve, reject);
1007
+ } catch (e) {
1008
+ reject(e);
1009
+ }
1010
+ });
1011
+ }));
1012
+ };
1013
+ clock.next = function next() {
1014
+ runJobs(clock);
1015
+ const timer = firstTimer(clock);
1016
+ if (!timer) return clock.now;
1017
+ clock.duringTick = true;
1018
+ try {
1019
+ clock.now = timer.callAt;
1020
+ callTimer(clock, timer);
1021
+ runJobs(clock);
1022
+ return clock.now;
1023
+ } finally{
1024
+ clock.duringTick = false;
1025
+ }
1026
+ };
1027
+ if (void 0 !== _global.Promise) clock.nextAsync = function nextAsync() {
1028
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
1029
+ originalSetTimeout(function() {
1030
+ try {
1031
+ const timer = firstTimer(clock);
1032
+ if (!timer) return void resolve(clock.now);
1033
+ let err;
1034
+ clock.duringTick = true;
1035
+ clock.now = timer.callAt;
1036
+ try {
1037
+ callTimer(clock, timer);
1038
+ } catch (e) {
1039
+ err = e;
1040
+ }
1041
+ clock.duringTick = false;
1042
+ originalSetTimeout(function() {
1043
+ if (err) reject(err);
1044
+ else resolve(clock.now);
1045
+ });
1046
+ } catch (e) {
1047
+ reject(e);
1048
+ }
1049
+ });
1050
+ }));
1051
+ };
1052
+ clock.runAll = function runAll() {
1053
+ let numTimers, i;
1054
+ runJobs(clock);
1055
+ for(i = 0; i < clock.loopLimit; i++){
1056
+ if (!clock.timers) {
1057
+ resetIsNearInfiniteLimit();
1058
+ return clock.now;
1059
+ }
1060
+ numTimers = clock.timerHeap.timers.length;
1061
+ if (0 === numTimers) {
1062
+ resetIsNearInfiniteLimit();
1063
+ return clock.now;
1064
+ }
1065
+ clock.next();
1066
+ checkIsNearInfiniteLimit(clock, i);
1067
+ }
1068
+ const excessJob = firstTimer(clock);
1069
+ throw getInfiniteLoopError(clock, excessJob);
1070
+ };
1071
+ clock.runToFrame = function runToFrame() {
1072
+ return clock.tick(getTimeToNextFrame());
1073
+ };
1074
+ if (void 0 !== _global.Promise) clock.runAllAsync = function runAllAsync() {
1075
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
1076
+ let i = 0;
1077
+ function doRun() {
1078
+ originalSetTimeout(function() {
1079
+ try {
1080
+ runJobs(clock);
1081
+ let numTimers;
1082
+ if (i < clock.loopLimit) {
1083
+ if (!clock.timerHeap) {
1084
+ resetIsNearInfiniteLimit();
1085
+ resolve(clock.now);
1086
+ return;
1087
+ }
1088
+ numTimers = clock.timerHeap.timers.length;
1089
+ if (0 === numTimers) {
1090
+ resetIsNearInfiniteLimit();
1091
+ resolve(clock.now);
1092
+ return;
1093
+ }
1094
+ clock.next();
1095
+ i++;
1096
+ doRun();
1097
+ checkIsNearInfiniteLimit(clock, i);
1098
+ return;
1099
+ }
1100
+ const excessJob = firstTimer(clock);
1101
+ reject(getInfiniteLoopError(clock, excessJob));
1102
+ } catch (e) {
1103
+ reject(e);
1104
+ }
1105
+ });
1106
+ }
1107
+ doRun();
1108
+ }));
1109
+ };
1110
+ clock.runToLast = function runToLast() {
1111
+ const timer = lastTimer(clock);
1112
+ if (!timer) {
1113
+ runJobs(clock);
1114
+ return clock.now;
1115
+ }
1116
+ return clock.tick(timer.callAt - clock.now);
1117
+ };
1118
+ if (void 0 !== _global.Promise) clock.runToLastAsync = function runToLastAsync() {
1119
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
1120
+ originalSetTimeout(function() {
1121
+ try {
1122
+ const timer = lastTimer(clock);
1123
+ if (!timer) {
1124
+ runJobs(clock);
1125
+ resolve(clock.now);
1126
+ }
1127
+ resolve(clock.tickAsync(timer.callAt - clock.now));
1128
+ } catch (e) {
1129
+ reject(e);
1130
+ }
1131
+ });
1132
+ }));
1133
+ };
1134
+ clock.reset = function reset() {
1135
+ nanos = 0;
1136
+ clock.timers = {};
1137
+ clock.timerHeap = new TimerHeap();
1138
+ clock.jobs = [];
1139
+ clock.now = start;
1140
+ };
1141
+ clock.setSystemTime = function setSystemTime(systemTime) {
1142
+ const newNow = getEpoch(systemTime);
1143
+ const difference = newNow - clock.now;
1144
+ let id, timer;
1145
+ adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
1146
+ adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
1147
+ clock.now = newNow;
1148
+ nanos = 0;
1149
+ for(id in clock.timers)if (Object.prototype.hasOwnProperty.call(clock.timers, id)) {
1150
+ timer = clock.timers[id];
1151
+ timer.createdAt += difference;
1152
+ timer.callAt += difference;
1153
+ }
1154
+ };
1155
+ clock.jump = function jump(tickValue) {
1156
+ const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
1157
+ const ms = Math.floor(msFloat);
1158
+ if (clock.timers) {
1159
+ for (const timer of Object.values(clock.timers))if (clock.now + ms > timer.callAt) timer.callAt = clock.now + ms;
1160
+ clock.timerHeap = new TimerHeap();
1161
+ for (const timer of Object.values(clock.timers))clock.timerHeap.push(timer);
1162
+ }
1163
+ clock.tick(ms);
1164
+ return clock.now;
1165
+ };
1166
+ if (isPresent.performance) {
1167
+ clock.performance = Object.create(null);
1168
+ clock.performance.now = fakePerformanceNow;
1169
+ }
1170
+ if (isPresent.hrtime) clock.hrtime = hrtime;
1171
+ return clock;
1172
+ }
1173
+ function createIntervalTick(clock, delta) {
1174
+ const intervalTick = doIntervalTick.bind(null, clock, delta);
1175
+ const intervalId = originalSetInterval(intervalTick, delta);
1176
+ clock.attachedInterval = intervalId;
1177
+ }
1178
+ function install(config) {
1179
+ if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || "number" == typeof config) throw new TypeError(`FakeTimers.install called with ${String(config)} install requires an object parameter`);
1180
+ if (true === _global.Date.isFake) throw new TypeError("Can't install fake timers twice on the same global object.");
1181
+ config = void 0 !== config ? config : {};
1182
+ config.shouldAdvanceTime = config.shouldAdvanceTime || false;
1183
+ config.advanceTimeDelta = config.advanceTimeDelta || 20;
1184
+ config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;
1185
+ const hasToFake = Object.prototype.hasOwnProperty.call(config, "toFake");
1186
+ const hasToNotFake = Object.prototype.hasOwnProperty.call(config, "toNotFake");
1187
+ if (hasToFake && hasToNotFake) throw new TypeError("config.toFake and config.toNotFake cannot be used together");
1188
+ if (config.target) throw new TypeError("config.target is no longer supported. Use `withGlobal(target)` instead.");
1189
+ function handleMissingTimer(timer) {
1190
+ if (config.ignoreMissingTimers) return;
1191
+ throw new ReferenceError(`non-existent timers and/or objects cannot be faked: '${timer}'`);
1192
+ }
1193
+ let i, l;
1194
+ const clock = createClock(config.now, config.loopLimit);
1195
+ clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
1196
+ clock.uninstall = function() {
1197
+ return uninstall(clock);
1198
+ };
1199
+ clock.abortListenerMap = new Map();
1200
+ if (hasToFake) {
1201
+ clock.methods = config.toFake || [];
1202
+ if (0 === clock.methods.length) clock.methods = Object.keys(timers);
1203
+ } else if (hasToNotFake) {
1204
+ const methodsToNotFake = config.toNotFake || [];
1205
+ clock.methods = Object.keys(timers).filter((method)=>!methodsToNotFake.includes(method));
1206
+ } else clock.methods = Object.keys(timers);
1207
+ if (true === config.shouldAdvanceTime) clock.setTickMode({
1208
+ mode: "interval",
1209
+ delta: config.advanceTimeDelta
1210
+ });
1211
+ if (clock.methods.includes("performance")) {
1212
+ const proto = (()=>{
1213
+ if (hasPerformanceConstructorPrototype) return _global.performance.constructor.prototype;
1214
+ if (hasPerformancePrototype) return _global.Performance.prototype;
1215
+ })();
1216
+ if (proto) {
1217
+ Object.getOwnPropertyNames(proto).forEach(function(name) {
1218
+ if ("now" !== name) clock.performance[name] = 0 === name.indexOf("getEntries") ? NOOP_ARRAY : NOOP;
1219
+ });
1220
+ clock.performance.mark = (name)=>new FakePerformanceEntry(name, "mark", 0, 0);
1221
+ clock.performance.measure = (name)=>new FakePerformanceEntry(name, "measure", 0, 100);
1222
+ clock.performance.timeOrigin = getEpoch(config.now);
1223
+ } else if ((config.toFake || []).includes("performance")) return handleMissingTimer("performance");
1224
+ }
1225
+ if (_global === globalObject && timersModule) clock.timersModuleMethods = [];
1226
+ if (_global === globalObject && timersPromisesModule) clock.timersPromisesModuleMethods = [];
1227
+ for(i = 0, l = clock.methods.length; i < l; i++){
1228
+ const nameOfMethodToReplace = clock.methods[i];
1229
+ if (!isPresent[nameOfMethodToReplace]) {
1230
+ handleMissingTimer(nameOfMethodToReplace);
1231
+ continue;
1232
+ }
1233
+ if ("hrtime" === nameOfMethodToReplace) {
1234
+ if (_global.process && "function" == typeof _global.process.hrtime) hijackMethod(_global.process, nameOfMethodToReplace, clock);
1235
+ } else if ("nextTick" === nameOfMethodToReplace) {
1236
+ if (_global.process && "function" == typeof _global.process.nextTick) hijackMethod(_global.process, nameOfMethodToReplace, clock);
1237
+ } else hijackMethod(_global, nameOfMethodToReplace, clock);
1238
+ if (void 0 !== clock.timersModuleMethods && timersModule[nameOfMethodToReplace]) {
1239
+ const original = timersModule[nameOfMethodToReplace];
1240
+ clock.timersModuleMethods.push({
1241
+ methodName: nameOfMethodToReplace,
1242
+ original: original
1243
+ });
1244
+ timersModule[nameOfMethodToReplace] = _global[nameOfMethodToReplace];
1245
+ }
1246
+ if (void 0 !== clock.timersPromisesModuleMethods) {
1247
+ if ("setTimeout" === nameOfMethodToReplace) {
1248
+ clock.timersPromisesModuleMethods.push({
1249
+ methodName: "setTimeout",
1250
+ original: timersPromisesModule.setTimeout
1251
+ });
1252
+ timersPromisesModule.setTimeout = (delay, value, options = {})=>new Promise((resolve, reject)=>{
1253
+ const abort = ()=>{
1254
+ options.signal.removeEventListener("abort", abort);
1255
+ clock.abortListenerMap.delete(abort);
1256
+ clock.clearTimeout(handle);
1257
+ reject(options.signal.reason);
1258
+ };
1259
+ const handle = clock.setTimeout(()=>{
1260
+ if (options.signal) {
1261
+ options.signal.removeEventListener("abort", abort);
1262
+ clock.abortListenerMap.delete(abort);
1263
+ }
1264
+ resolve(value);
1265
+ }, delay);
1266
+ if (options.signal) if (options.signal.aborted) abort();
1267
+ else {
1268
+ options.signal.addEventListener("abort", abort);
1269
+ clock.abortListenerMap.set(abort, options.signal);
1270
+ }
1271
+ });
1272
+ } else if ("setImmediate" === nameOfMethodToReplace) {
1273
+ clock.timersPromisesModuleMethods.push({
1274
+ methodName: "setImmediate",
1275
+ original: timersPromisesModule.setImmediate
1276
+ });
1277
+ timersPromisesModule.setImmediate = (value, options = {})=>new Promise((resolve, reject)=>{
1278
+ const abort = ()=>{
1279
+ options.signal.removeEventListener("abort", abort);
1280
+ clock.abortListenerMap.delete(abort);
1281
+ clock.clearImmediate(handle);
1282
+ reject(options.signal.reason);
1283
+ };
1284
+ const handle = clock.setImmediate(()=>{
1285
+ if (options.signal) {
1286
+ options.signal.removeEventListener("abort", abort);
1287
+ clock.abortListenerMap.delete(abort);
1288
+ }
1289
+ resolve(value);
1290
+ });
1291
+ if (options.signal) if (options.signal.aborted) abort();
1292
+ else {
1293
+ options.signal.addEventListener("abort", abort);
1294
+ clock.abortListenerMap.set(abort, options.signal);
1295
+ }
1296
+ });
1297
+ } else if ("setInterval" === nameOfMethodToReplace) {
1298
+ clock.timersPromisesModuleMethods.push({
1299
+ methodName: "setInterval",
1300
+ original: timersPromisesModule.setInterval
1301
+ });
1302
+ timersPromisesModule.setInterval = (delay, value, options = {})=>({
1303
+ [Symbol.asyncIterator]: ()=>{
1304
+ const createResolvable = ()=>{
1305
+ let resolve, reject;
1306
+ const promise = new Promise((res, rej)=>{
1307
+ resolve = res;
1308
+ reject = rej;
1309
+ });
1310
+ promise.resolve = resolve;
1311
+ promise.reject = reject;
1312
+ return promise;
1313
+ };
1314
+ let done = false;
1315
+ let hasThrown = false;
1316
+ let returnCall;
1317
+ let nextAvailable = 0;
1318
+ const nextQueue = [];
1319
+ const handle = clock.setInterval(()=>{
1320
+ if (nextQueue.length > 0) nextQueue.shift().resolve();
1321
+ else nextAvailable++;
1322
+ }, delay);
1323
+ const abort = ()=>{
1324
+ options.signal.removeEventListener("abort", abort);
1325
+ clock.abortListenerMap.delete(abort);
1326
+ clock.clearInterval(handle);
1327
+ done = true;
1328
+ for (const resolvable of nextQueue)resolvable.resolve();
1329
+ };
1330
+ if (options.signal) if (options.signal.aborted) done = true;
1331
+ else {
1332
+ options.signal.addEventListener("abort", abort);
1333
+ clock.abortListenerMap.set(abort, options.signal);
1334
+ }
1335
+ return {
1336
+ next: async ()=>{
1337
+ if (options.signal?.aborted && !hasThrown) {
1338
+ hasThrown = true;
1339
+ throw options.signal.reason;
1340
+ }
1341
+ if (done) return {
1342
+ done: true,
1343
+ value: void 0
1344
+ };
1345
+ if (nextAvailable > 0) {
1346
+ nextAvailable--;
1347
+ return {
1348
+ done: false,
1349
+ value: value
1350
+ };
1351
+ }
1352
+ const resolvable = createResolvable();
1353
+ nextQueue.push(resolvable);
1354
+ await resolvable;
1355
+ if (returnCall && 0 === nextQueue.length) returnCall.resolve();
1356
+ if (options.signal?.aborted && !hasThrown) {
1357
+ hasThrown = true;
1358
+ throw options.signal.reason;
1359
+ }
1360
+ if (done) return {
1361
+ done: true,
1362
+ value: void 0
1363
+ };
1364
+ return {
1365
+ done: false,
1366
+ value: value
1367
+ };
1368
+ },
1369
+ return: async ()=>{
1370
+ if (done) return {
1371
+ done: true,
1372
+ value: void 0
1373
+ };
1374
+ if (nextQueue.length > 0) {
1375
+ returnCall = createResolvable();
1376
+ await returnCall;
1377
+ }
1378
+ clock.clearInterval(handle);
1379
+ done = true;
1380
+ if (options.signal) {
1381
+ options.signal.removeEventListener("abort", abort);
1382
+ clock.abortListenerMap.delete(abort);
1383
+ }
1384
+ return {
1385
+ done: true,
1386
+ value: void 0
1387
+ };
1388
+ }
1389
+ };
1390
+ }
1391
+ });
1392
+ }
1393
+ }
1394
+ }
1395
+ return clock;
1396
+ }
1397
+ return {
1398
+ timers: timers,
1399
+ createClock: createClock,
1400
+ install: install,
1401
+ withGlobal: withGlobal
1402
+ };
1403
+ }
1404
+ const defaultImplementation = withGlobal(globalObject);
1405
+ defaultImplementation.timers;
1406
+ defaultImplementation.createClock;
1407
+ defaultImplementation.install;
1408
+ exports.withGlobal = withGlobal;
1409
+ },
1410
+ "../../node_modules/.pnpm/setimmediate@1.0.5/node_modules/setimmediate/setImmediate.js" (__unused_rspack_module, __unused_rspack_exports, __webpack_require__) {
1411
+ var process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
1412
+ (function(global, undefined) {
1413
+ "use strict";
1414
+ if (global.setImmediate) return;
1415
+ var nextHandle = 1;
1416
+ var tasksByHandle = {};
1417
+ var currentlyRunningATask = false;
1418
+ var doc = global.document;
1419
+ var registerImmediate;
1420
+ function setImmediate(callback) {
1421
+ if ("function" != typeof callback) callback = new Function("" + callback);
1422
+ var args = new Array(arguments.length - 1);
1423
+ for(var i = 0; i < args.length; i++)args[i] = arguments[i + 1];
1424
+ var task = {
1425
+ callback: callback,
1426
+ args: args
1427
+ };
1428
+ tasksByHandle[nextHandle] = task;
1429
+ registerImmediate(nextHandle);
1430
+ return nextHandle++;
1431
+ }
1432
+ function clearImmediate(handle) {
1433
+ delete tasksByHandle[handle];
1434
+ }
1435
+ function run(task) {
1436
+ var callback = task.callback;
1437
+ var args = task.args;
1438
+ switch(args.length){
1439
+ case 0:
1440
+ callback();
1441
+ break;
1442
+ case 1:
1443
+ callback(args[0]);
1444
+ break;
1445
+ case 2:
1446
+ callback(args[0], args[1]);
1447
+ break;
1448
+ case 3:
1449
+ callback(args[0], args[1], args[2]);
1450
+ break;
1451
+ default:
1452
+ callback.apply(undefined, args);
1453
+ break;
1454
+ }
1455
+ }
1456
+ function runIfPresent(handle) {
1457
+ if (currentlyRunningATask) setTimeout(runIfPresent, 0, handle);
1458
+ else {
1459
+ var task = tasksByHandle[handle];
1460
+ if (task) {
1461
+ currentlyRunningATask = true;
1462
+ try {
1463
+ run(task);
1464
+ } finally{
1465
+ clearImmediate(handle);
1466
+ currentlyRunningATask = false;
1467
+ }
1468
+ }
1469
+ }
1470
+ }
1471
+ function installNextTickImplementation() {
1472
+ registerImmediate = function(handle) {
1473
+ process.nextTick(function() {
1474
+ runIfPresent(handle);
1475
+ });
1476
+ };
1477
+ }
1478
+ function canUsePostMessage() {
1479
+ if (global.postMessage && !global.importScripts) {
1480
+ var postMessageIsAsynchronous = true;
1481
+ var oldOnMessage = global.onmessage;
1482
+ global.onmessage = function() {
1483
+ postMessageIsAsynchronous = false;
1484
+ };
1485
+ global.postMessage("", "*");
1486
+ global.onmessage = oldOnMessage;
1487
+ return postMessageIsAsynchronous;
1488
+ }
1489
+ }
1490
+ function installPostMessageImplementation() {
1491
+ var messagePrefix = "setImmediate$" + Math.random() + "$";
1492
+ var onGlobalMessage = function(event) {
1493
+ if (event.source === global && "string" == typeof event.data && 0 === event.data.indexOf(messagePrefix)) runIfPresent(+event.data.slice(messagePrefix.length));
1494
+ };
1495
+ if (global.addEventListener) global.addEventListener("message", onGlobalMessage, false);
1496
+ else global.attachEvent("onmessage", onGlobalMessage);
1497
+ registerImmediate = function(handle) {
1498
+ global.postMessage(messagePrefix + handle, "*");
1499
+ };
1500
+ }
1501
+ function installMessageChannelImplementation() {
1502
+ var channel = new MessageChannel();
1503
+ channel.port1.onmessage = function(event) {
1504
+ var handle = event.data;
1505
+ runIfPresent(handle);
1506
+ };
1507
+ registerImmediate = function(handle) {
1508
+ channel.port2.postMessage(handle);
1509
+ };
1510
+ }
1511
+ function installReadyStateChangeImplementation() {
1512
+ var html = doc.documentElement;
1513
+ registerImmediate = function(handle) {
1514
+ var script = doc.createElement("script");
1515
+ script.onreadystatechange = function() {
1516
+ runIfPresent(handle);
1517
+ script.onreadystatechange = null;
1518
+ html.removeChild(script);
1519
+ script = null;
1520
+ };
1521
+ html.appendChild(script);
1522
+ };
1523
+ }
1524
+ function installSetTimeoutImplementation() {
1525
+ registerImmediate = function(handle) {
1526
+ setTimeout(runIfPresent, 0, handle);
1527
+ };
1528
+ }
1529
+ var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
1530
+ attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
1531
+ if ("[object process]" === ({}).toString.call(global.process)) installNextTickImplementation();
1532
+ else if (canUsePostMessage()) installPostMessageImplementation();
1533
+ else if (global.MessageChannel) installMessageChannelImplementation();
1534
+ else if (doc && "onreadystatechange" in doc.createElement("script")) installReadyStateChangeImplementation();
1535
+ else installSetTimeoutImplementation();
1536
+ attachTo.setImmediate = setImmediate;
1537
+ attachTo.clearImmediate = clearImmediate;
1538
+ })("u" < typeof self ? void 0 === __webpack_require__.g ? this : __webpack_require__.g : self);
1539
+ },
1540
+ "../../node_modules/.pnpm/timers-browserify@2.0.12/node_modules/timers-browserify/main.js" (__unused_rspack_module, exports, __webpack_require__) {
1541
+ var scope = void 0 !== __webpack_require__.g && __webpack_require__.g || "u" > typeof self && self || window;
1542
+ var apply = Function.prototype.apply;
1543
+ exports.setTimeout = function() {
1544
+ return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
1545
+ };
1546
+ exports.setInterval = function() {
1547
+ return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
1548
+ };
1549
+ exports.clearTimeout = exports.clearInterval = function(timeout) {
1550
+ if (timeout) timeout.close();
1551
+ };
1552
+ function Timeout(id, clearFn) {
1553
+ this._id = id;
1554
+ this._clearFn = clearFn;
1555
+ }
1556
+ Timeout.prototype.unref = Timeout.prototype.ref = function() {};
1557
+ Timeout.prototype.close = function() {
1558
+ this._clearFn.call(scope, this._id);
1559
+ };
1560
+ exports.enroll = function(item, msecs) {
1561
+ clearTimeout(item._idleTimeoutId);
1562
+ item._idleTimeout = msecs;
1563
+ };
1564
+ exports.unenroll = function(item) {
1565
+ clearTimeout(item._idleTimeoutId);
1566
+ item._idleTimeout = -1;
1567
+ };
1568
+ exports._unrefActive = exports.active = function(item) {
1569
+ clearTimeout(item._idleTimeoutId);
1570
+ var msecs = item._idleTimeout;
1571
+ if (msecs >= 0) item._idleTimeoutId = setTimeout(function onTimeout() {
1572
+ if (item._onTimeout) item._onTimeout();
1573
+ }, msecs);
1574
+ };
1575
+ __webpack_require__("../../node_modules/.pnpm/setimmediate@1.0.5/node_modules/setimmediate/setImmediate.js");
1576
+ exports.setImmediate = "u" > typeof self && self.setImmediate || void 0 !== __webpack_require__.g && __webpack_require__.g.setImmediate || this && this.setImmediate;
1577
+ exports.clearImmediate = "u" > typeof self && self.clearImmediate || void 0 !== __webpack_require__.g && __webpack_require__.g.clearImmediate || this && this.clearImmediate;
1578
+ },
1579
+ "../../node_modules/.pnpm/type-detect@4.0.8/node_modules/type-detect/type-detect.js" (module, __unused_rspack_exports, __webpack_require__) {
1580
+ (function(global, factory) {
1581
+ module.exports = factory();
1582
+ })(0, function() {
1583
+ 'use strict';
1584
+ var promiseExists = 'function' == typeof Promise;
1585
+ var globalObject = 'object' == typeof self ? self : __webpack_require__.g;
1586
+ var symbolExists = "u" > typeof Symbol;
1587
+ var mapExists = "u" > typeof Map;
1588
+ var setExists = "u" > typeof Set;
1589
+ var weakMapExists = "u" > typeof WeakMap;
1590
+ var weakSetExists = "u" > typeof WeakSet;
1591
+ var dataViewExists = "u" > typeof DataView;
1592
+ var symbolIteratorExists = symbolExists && void 0 !== Symbol.iterator;
1593
+ var symbolToStringTagExists = symbolExists && void 0 !== Symbol.toStringTag;
1594
+ var setEntriesExists = setExists && 'function' == typeof Set.prototype.entries;
1595
+ var mapEntriesExists = mapExists && 'function' == typeof Map.prototype.entries;
1596
+ var setIteratorPrototype = setEntriesExists && Object.getPrototypeOf(new Set().entries());
1597
+ var mapIteratorPrototype = mapEntriesExists && Object.getPrototypeOf(new Map().entries());
1598
+ var arrayIteratorExists = symbolIteratorExists && 'function' == typeof Array.prototype[Symbol.iterator];
1599
+ var arrayIteratorPrototype = arrayIteratorExists && Object.getPrototypeOf([][Symbol.iterator]());
1600
+ var stringIteratorExists = symbolIteratorExists && 'function' == typeof String.prototype[Symbol.iterator];
1601
+ var stringIteratorPrototype = stringIteratorExists && Object.getPrototypeOf(''[Symbol.iterator]());
1602
+ var toStringLeftSliceLength = 8;
1603
+ var toStringRightSliceLength = -1;
1604
+ function typeDetect(obj) {
1605
+ var typeofObj = typeof obj;
1606
+ if ('object' !== typeofObj) return typeofObj;
1607
+ if (null === obj) return 'null';
1608
+ if (obj === globalObject) return 'global';
1609
+ if (Array.isArray(obj) && (false === symbolToStringTagExists || !(Symbol.toStringTag in obj))) return 'Array';
1610
+ if ('object' == typeof window && null !== window) {
1611
+ if ('object' == typeof window.location && obj === window.location) return 'Location';
1612
+ if ('object' == typeof window.document && obj === window.document) return 'Document';
1613
+ if ('object' == typeof window.navigator) {
1614
+ if ('object' == typeof window.navigator.mimeTypes && obj === window.navigator.mimeTypes) return 'MimeTypeArray';
1615
+ if ('object' == typeof window.navigator.plugins && obj === window.navigator.plugins) return 'PluginArray';
1616
+ }
1617
+ if (('function' == typeof window.HTMLElement || 'object' == typeof window.HTMLElement) && obj instanceof window.HTMLElement) {
1618
+ if ('BLOCKQUOTE' === obj.tagName) return 'HTMLQuoteElement';
1619
+ if ('TD' === obj.tagName) return 'HTMLTableDataCellElement';
1620
+ if ('TH' === obj.tagName) return 'HTMLTableHeaderCellElement';
1621
+ }
1622
+ }
1623
+ var stringTag = symbolToStringTagExists && obj[Symbol.toStringTag];
1624
+ if ('string' == typeof stringTag) return stringTag;
1625
+ var objPrototype = Object.getPrototypeOf(obj);
1626
+ if (objPrototype === RegExp.prototype) return 'RegExp';
1627
+ if (objPrototype === Date.prototype) return 'Date';
1628
+ if (promiseExists && objPrototype === Promise.prototype) return 'Promise';
1629
+ if (setExists && objPrototype === Set.prototype) return 'Set';
1630
+ if (mapExists && objPrototype === Map.prototype) return 'Map';
1631
+ if (weakSetExists && objPrototype === WeakSet.prototype) return 'WeakSet';
1632
+ if (weakMapExists && objPrototype === WeakMap.prototype) return 'WeakMap';
1633
+ if (dataViewExists && objPrototype === DataView.prototype) return 'DataView';
1634
+ if (mapExists && objPrototype === mapIteratorPrototype) return 'Map Iterator';
1635
+ if (setExists && objPrototype === setIteratorPrototype) return 'Set Iterator';
1636
+ if (arrayIteratorExists && objPrototype === arrayIteratorPrototype) return 'Array Iterator';
1637
+ if (stringIteratorExists && objPrototype === stringIteratorPrototype) return 'String Iterator';
1638
+ if (null === objPrototype) return 'Object';
1639
+ return Object.prototype.toString.call(obj).slice(toStringLeftSliceLength, toStringRightSliceLength);
1640
+ }
1641
+ return typeDetect;
1642
+ });
1643
+ }
1644
+ });
1645
+ var process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
1646
+ const RealDate = Date;
1647
+ const loadFakeTimersModule = ()=>{
1648
+ const loaded = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@15.2.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js");
1649
+ return {
1650
+ withGlobal: loaded.withGlobal
1651
+ };
1652
+ };
1653
+ class FakeTimers {
1654
+ _clock;
1655
+ _config;
1656
+ _fakingTime;
1657
+ _fakeTimers;
1658
+ constructor({ global, config = {} }){
1659
+ this._config = config;
1660
+ this._fakingTime = false;
1661
+ this._fakeTimers = loadFakeTimersModule().withGlobal(global);
1662
+ }
1663
+ clearAllTimers() {
1664
+ if (this._fakingTime) this._clock.reset();
1665
+ }
1666
+ dispose() {
1667
+ this.useRealTimers();
1668
+ }
1669
+ runAllTimers() {
1670
+ if (this._checkFakeTimers()) this._clock.runAll();
1671
+ }
1672
+ async runAllTimersAsync() {
1673
+ if (this._checkFakeTimers()) await this._clock.runAllAsync();
1674
+ }
1675
+ runOnlyPendingTimers() {
1676
+ if (this._checkFakeTimers()) this._clock.runToLast();
1677
+ }
1678
+ async runOnlyPendingTimersAsync() {
1679
+ if (this._checkFakeTimers()) await this._clock.runToLastAsync();
1680
+ }
1681
+ advanceTimersToNextTimer(steps = 1) {
1682
+ if (this._checkFakeTimers()) for(let i = steps; i > 0; i--){
1683
+ this._clock.next();
1684
+ this._clock.tick(0);
1685
+ if (0 === this._clock.countTimers()) break;
1686
+ }
1687
+ }
1688
+ async advanceTimersToNextTimerAsync(steps = 1) {
1689
+ if (this._checkFakeTimers()) for(let i = steps; i > 0; i--){
1690
+ await this._clock.nextAsync();
1691
+ await this._clock.tickAsync(0);
1692
+ if (0 === this._clock.countTimers()) break;
1693
+ }
1694
+ }
1695
+ advanceTimersByTime(msToRun) {
1696
+ if (this._checkFakeTimers()) this._clock.tick(msToRun);
1697
+ }
1698
+ async advanceTimersByTimeAsync(msToRun) {
1699
+ if (this._checkFakeTimers()) await this._clock.tickAsync(msToRun);
1700
+ }
1701
+ advanceTimersToNextFrame() {
1702
+ if (this._checkFakeTimers()) this._clock.runToFrame();
1703
+ }
1704
+ runAllTicks() {
1705
+ if (this._checkFakeTimers()) this._clock.runMicrotasks();
1706
+ }
1707
+ useRealTimers() {
1708
+ if (this._fakingTime) {
1709
+ this._clock.uninstall();
1710
+ this._fakingTime = false;
1711
+ }
1712
+ }
1713
+ useFakeTimers(fakeTimersConfig = {}) {
1714
+ if (this._fakingTime) this._clock.uninstall();
1715
+ const toFake = Object.keys(this._fakeTimers.timers).filter((timer)=>'nextTick' !== timer && 'queueMicrotask' !== timer);
1716
+ const isChildProcess = void 0 !== process && !!process.send;
1717
+ if (this._config?.toFake?.includes('nextTick') && isChildProcess) throw new Error('process.nextTick cannot be mocked inside child_process');
1718
+ this._clock = this._fakeTimers.install({
1719
+ loopLimit: 10000,
1720
+ shouldClearNativeTimers: true,
1721
+ now: Date.now(),
1722
+ toFake: [
1723
+ ...toFake
1724
+ ],
1725
+ ignoreMissingTimers: true,
1726
+ ...fakeTimersConfig
1727
+ });
1728
+ this._clock.reset();
1729
+ this._fakingTime = true;
1730
+ }
1731
+ reset() {
1732
+ if (this._checkFakeTimers()) {
1733
+ const { now } = this._clock;
1734
+ this._clock.reset();
1735
+ this._clock.setSystemTime(now);
1736
+ }
1737
+ }
1738
+ setSystemTime(now) {
1739
+ if (this._checkFakeTimers()) this._clock.setSystemTime(now);
1740
+ }
1741
+ getRealSystemTime() {
1742
+ return RealDate.now();
1743
+ }
1744
+ now() {
1745
+ if (this._fakingTime) return this._clock.now;
1746
+ return Date.now();
1747
+ }
1748
+ getTimerCount() {
1749
+ if (this._checkFakeTimers()) return this._clock.countTimers();
1750
+ return 0;
1751
+ }
1752
+ _checkFakeTimers() {
1753
+ if (!this._fakingTime) throw new Error('Timers are not mocked. Try calling "rstest.useFakeTimers()" first.');
1754
+ return this._fakingTime;
1755
+ }
1756
+ isFakeTimers() {
1757
+ return this._fakingTime;
1758
+ }
1759
+ }
1760
+ export { FakeTimers };